sheetom 0.1.0-rc.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/LICENSE +21 -0
- package/README.md +154 -0
- package/SECURITY.md +13 -0
- package/compatibility/WPT-LICENSE.md +15 -0
- package/compatibility/baselines/0.1.0-rc.0.json +70 -0
- package/compatibility/baselines/README.md +3 -0
- package/compatibility/schemas/compatibility-report.schema.json +68 -0
- package/compatibility/schemas/compatibility-resolutions.schema.json +28 -0
- package/compatibility/schemas/operation-fixture.schema.json +87 -0
- package/compatibility/schemas/wpt-mappings.schema.json +47 -0
- package/dist/index.cjs +3644 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +325 -0
- package/dist/index.d.ts +325 -0
- package/dist/index.js +3595 -0
- package/dist/index.js.map +1 -0
- package/docs/api.md +80 -0
- package/docs/releasing.md +56 -0
- package/package.json +91 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,3644 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
|
+
get: ((k) => from[k]).bind(null, key),
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
20
|
+
value: mod,
|
|
21
|
+
enumerable: true
|
|
22
|
+
}) : target, mod));
|
|
23
|
+
//#endregion
|
|
24
|
+
let lightningcss = require("lightningcss");
|
|
25
|
+
let css_tree = require("css-tree");
|
|
26
|
+
css_tree = __toESM(css_tree, 1);
|
|
27
|
+
let _csstools_css_tokenizer = require("@csstools/css-tokenizer");
|
|
28
|
+
let cssstyle = require("cssstyle");
|
|
29
|
+
//#region src/internal/declaration-block.ts
|
|
30
|
+
/** Owns ordered declaration records and all atomic mutation decisions. */
|
|
31
|
+
var DeclarationBlock = class {
|
|
32
|
+
#codec;
|
|
33
|
+
#reportDiagnostic;
|
|
34
|
+
#records = [];
|
|
35
|
+
constructor(codec, reportDiagnostic) {
|
|
36
|
+
this.#codec = codec;
|
|
37
|
+
this.#reportDiagnostic = reportDiagnostic;
|
|
38
|
+
}
|
|
39
|
+
replace(declarations) {
|
|
40
|
+
if (!declarations) {
|
|
41
|
+
this.#records.splice(0);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const winners = /* @__PURE__ */ new Map();
|
|
45
|
+
let sourceIndex = 0;
|
|
46
|
+
const consider = (record, subIndex) => {
|
|
47
|
+
if (winners.get(record.name)?.important && !record.important) return;
|
|
48
|
+
winners.set(record.name, {
|
|
49
|
+
...record,
|
|
50
|
+
sourceIndex,
|
|
51
|
+
subIndex
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
for (const declaration of declarations) {
|
|
55
|
+
const name = declaration.name.startsWith("--") ? declaration.name : declaration.name.toLowerCase();
|
|
56
|
+
const propertyValue = this.#codec.parseValue(name, declaration.value);
|
|
57
|
+
if (!propertyValue) {
|
|
58
|
+
sourceIndex += 1;
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
const longhands = this.#codec.shorthandLonghands(name);
|
|
62
|
+
if (propertyValue.pendingSubstitution && longhands) {
|
|
63
|
+
const pendingGroup = {
|
|
64
|
+
shorthand: name,
|
|
65
|
+
observableValue: propertyValue.observableValue,
|
|
66
|
+
safeValue: propertyValue.safeValue
|
|
67
|
+
};
|
|
68
|
+
for (let index = 0; index < longhands.length; index += 1) {
|
|
69
|
+
const longhand = longhands[index];
|
|
70
|
+
if (!longhand) continue;
|
|
71
|
+
consider({
|
|
72
|
+
name: longhand,
|
|
73
|
+
observableValue: "",
|
|
74
|
+
safeValue: "",
|
|
75
|
+
pendingSubstitution: true,
|
|
76
|
+
important: declaration.important,
|
|
77
|
+
pendingGroup
|
|
78
|
+
}, index);
|
|
79
|
+
}
|
|
80
|
+
sourceIndex += 1;
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
const expansion = this.#codec.expandFourSide(name, propertyValue, declaration.important) ?? this.#codec.expandShorthand(name, propertyValue, declaration.important);
|
|
84
|
+
if (expansion) {
|
|
85
|
+
for (let index = 0; index < expansion.length; index += 1) {
|
|
86
|
+
const record = expansion[index];
|
|
87
|
+
if (record) consider(record, index);
|
|
88
|
+
}
|
|
89
|
+
sourceIndex += 1;
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
consider({
|
|
93
|
+
name,
|
|
94
|
+
...propertyValue,
|
|
95
|
+
important: declaration.important,
|
|
96
|
+
pendingGroup: null
|
|
97
|
+
}, 0);
|
|
98
|
+
sourceIndex += 1;
|
|
99
|
+
}
|
|
100
|
+
const records = [...winners.values()].sort((left, right) => {
|
|
101
|
+
if (left.important !== right.important) return left.important ? 1 : -1;
|
|
102
|
+
return left.sourceIndex - right.sourceIndex || left.subIndex - right.subIndex;
|
|
103
|
+
});
|
|
104
|
+
this.#records.splice(0, this.#records.length, ...records);
|
|
105
|
+
}
|
|
106
|
+
get length() {
|
|
107
|
+
return this.#records.length;
|
|
108
|
+
}
|
|
109
|
+
item(index) {
|
|
110
|
+
return this.#records[this.#codec.normalizeIndex(index)]?.name ?? "";
|
|
111
|
+
}
|
|
112
|
+
getPropertyValue(name) {
|
|
113
|
+
const normalizedName = name.startsWith("--") ? name : name.toLowerCase();
|
|
114
|
+
const shorthand = this.#shorthand(normalizedName, false);
|
|
115
|
+
if (shorthand) return shorthand.value;
|
|
116
|
+
return this.#records.find((record) => record.name === normalizedName)?.observableValue ?? "";
|
|
117
|
+
}
|
|
118
|
+
getPropertyPriority(name) {
|
|
119
|
+
const normalizedName = name.startsWith("--") ? name : name.toLowerCase();
|
|
120
|
+
const shorthand = this.#shorthand(normalizedName, false);
|
|
121
|
+
if (shorthand) return shorthand.important ? "important" : "";
|
|
122
|
+
return this.#records.find((record) => record.name === normalizedName)?.important ? "important" : "";
|
|
123
|
+
}
|
|
124
|
+
setProperty(name, value, priority) {
|
|
125
|
+
const normalizedName = name.startsWith("--") ? name : name.toLowerCase();
|
|
126
|
+
const normalizedPriority = priority.toLowerCase();
|
|
127
|
+
if (normalizedPriority !== "" && normalizedPriority !== "important") {
|
|
128
|
+
this.#reportDiagnostic("INVALID_PRIORITY", normalizedName, priority);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
if (value === "") {
|
|
132
|
+
this.removeProperty(normalizedName);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const parsed = this.#codec.parseValue(normalizedName, value);
|
|
136
|
+
if (!parsed) {
|
|
137
|
+
this.#reportDiagnostic("INVALID_PROPERTY_VALUE", normalizedName, value);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
const important = normalizedPriority === "important";
|
|
141
|
+
const longhands = this.#codec.shorthandLonghands(normalizedName);
|
|
142
|
+
if (parsed.pendingSubstitution && longhands) {
|
|
143
|
+
const pendingGroup = {
|
|
144
|
+
shorthand: normalizedName,
|
|
145
|
+
observableValue: parsed.observableValue,
|
|
146
|
+
safeValue: parsed.safeValue
|
|
147
|
+
};
|
|
148
|
+
for (const longhand of longhands) this.#commitRecord(longhand, {
|
|
149
|
+
observableValue: "",
|
|
150
|
+
safeValue: "",
|
|
151
|
+
pendingSubstitution: true
|
|
152
|
+
}, important, pendingGroup);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
const expansion = this.#codec.expandFourSide(normalizedName, parsed, important) ?? this.#codec.expandShorthand(normalizedName, parsed, important);
|
|
156
|
+
if (expansion) {
|
|
157
|
+
for (const record of expansion) this.#commitRecord(record.name, record, record.important, record.pendingGroup);
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
this.#commitRecord(normalizedName, parsed, important);
|
|
161
|
+
}
|
|
162
|
+
removeProperty(name) {
|
|
163
|
+
const normalizedName = name.startsWith("--") ? name : name.toLowerCase();
|
|
164
|
+
const longhands = this.#codec.shorthandLonghands(normalizedName);
|
|
165
|
+
if (longhands) {
|
|
166
|
+
const previousValue = this.getPropertyValue(normalizedName);
|
|
167
|
+
const names = /* @__PURE__ */ new Set([normalizedName, ...longhands]);
|
|
168
|
+
for (let index = this.#records.length - 1; index >= 0; index -= 1) {
|
|
169
|
+
const record = this.#records[index];
|
|
170
|
+
if (record && names.has(record.name)) this.#records.splice(index, 1);
|
|
171
|
+
}
|
|
172
|
+
return previousValue;
|
|
173
|
+
}
|
|
174
|
+
const index = this.#records.findIndex((record) => record.name === normalizedName);
|
|
175
|
+
if (index === -1) return "";
|
|
176
|
+
const [removed] = this.#records.splice(index, 1);
|
|
177
|
+
return removed?.observableValue ?? "";
|
|
178
|
+
}
|
|
179
|
+
serialize(safe, indent, separator) {
|
|
180
|
+
const declarations = [];
|
|
181
|
+
const writtenPendingGroups = /* @__PURE__ */ new Set();
|
|
182
|
+
const writtenStaticShorthands = /* @__PURE__ */ new Set();
|
|
183
|
+
const staticShorthands = /* @__PURE__ */ new Map();
|
|
184
|
+
for (const name of [
|
|
185
|
+
"padding",
|
|
186
|
+
"margin",
|
|
187
|
+
"inset",
|
|
188
|
+
"border-width",
|
|
189
|
+
"border-style",
|
|
190
|
+
"border-color",
|
|
191
|
+
"scroll-margin",
|
|
192
|
+
"scroll-padding"
|
|
193
|
+
]) {
|
|
194
|
+
const shorthand = this.#shorthand(name, safe);
|
|
195
|
+
if (shorthand) staticShorthands.set(name, shorthand);
|
|
196
|
+
}
|
|
197
|
+
for (const record of this.#records) {
|
|
198
|
+
const pendingGroup = record.pendingGroup;
|
|
199
|
+
if (pendingGroup) {
|
|
200
|
+
const shorthand = this.#shorthand(pendingGroup.shorthand, safe);
|
|
201
|
+
if (shorthand) {
|
|
202
|
+
if (writtenPendingGroups.has(pendingGroup)) continue;
|
|
203
|
+
declarations.push(`${indent}${pendingGroup.shorthand}: ${shorthand.value}${shorthand.important ? " !important" : ""};`);
|
|
204
|
+
writtenPendingGroups.add(pendingGroup);
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
let staticShorthandWritten = false;
|
|
209
|
+
for (const [name, shorthand] of staticShorthands) {
|
|
210
|
+
if (!this.#codec.shorthandLonghands(name)?.includes(record.name)) continue;
|
|
211
|
+
if (!writtenStaticShorthands.has(name)) {
|
|
212
|
+
declarations.push(`${indent}${name}: ${shorthand.value}${shorthand.important ? " !important" : ""};`);
|
|
213
|
+
writtenStaticShorthands.add(name);
|
|
214
|
+
}
|
|
215
|
+
staticShorthandWritten = true;
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
if (staticShorthandWritten) continue;
|
|
219
|
+
const name = record.name.startsWith("--") ? this.#codec.serializeIdentifier(record.name) : record.name;
|
|
220
|
+
const value = safe ? record.safeValue : record.observableValue;
|
|
221
|
+
declarations.push(`${indent}${name}: ${value}${record.important ? " !important" : ""};`);
|
|
222
|
+
}
|
|
223
|
+
return declarations.join(separator);
|
|
224
|
+
}
|
|
225
|
+
#commitRecord(name, parsed, important, pendingGroup = null) {
|
|
226
|
+
const existing = this.#records.find((record) => record.name === name);
|
|
227
|
+
if (existing) {
|
|
228
|
+
existing.observableValue = parsed.observableValue;
|
|
229
|
+
existing.safeValue = parsed.safeValue;
|
|
230
|
+
existing.pendingSubstitution = parsed.pendingSubstitution;
|
|
231
|
+
existing.important = important;
|
|
232
|
+
existing.pendingGroup = pendingGroup;
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
this.#records.push({
|
|
236
|
+
name,
|
|
237
|
+
...parsed,
|
|
238
|
+
important,
|
|
239
|
+
pendingGroup
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
#shorthand(name, safe) {
|
|
243
|
+
const longhands = this.#codec.shorthandLonghands(name);
|
|
244
|
+
if (!longhands) return null;
|
|
245
|
+
const records = longhands.map((longhand) => this.#records.find((record) => record.name === longhand));
|
|
246
|
+
if (records.some((record) => record === void 0)) return null;
|
|
247
|
+
const first = records[0];
|
|
248
|
+
if (!first || records.some((record) => record?.important !== first.important)) return null;
|
|
249
|
+
const pendingGroup = first.pendingGroup;
|
|
250
|
+
if (pendingGroup?.shorthand === name && records.every((record) => record?.pendingGroup === pendingGroup)) return {
|
|
251
|
+
value: safe ? pendingGroup.safeValue : pendingGroup.observableValue,
|
|
252
|
+
important: first.important
|
|
253
|
+
};
|
|
254
|
+
if (records.some((record) => record?.pendingGroup)) return null;
|
|
255
|
+
if (!this.#codec.isFourSideShorthand(name) || records.length !== 4) return null;
|
|
256
|
+
const [top, right, bottom, left] = records;
|
|
257
|
+
if (!top || !right || !bottom || !left) return null;
|
|
258
|
+
return {
|
|
259
|
+
value: compressFourSides([
|
|
260
|
+
top,
|
|
261
|
+
right,
|
|
262
|
+
bottom,
|
|
263
|
+
left
|
|
264
|
+
].map((record) => safe ? record.safeValue : record.observableValue)),
|
|
265
|
+
important: first.important
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
function compressFourSides([top, right, bottom, left]) {
|
|
270
|
+
if (top === right && top === bottom && top === left) return top;
|
|
271
|
+
if (top === bottom && right === left) return `${top} ${right}`;
|
|
272
|
+
if (right === left) return `${top} ${right} ${bottom}`;
|
|
273
|
+
return [
|
|
274
|
+
top,
|
|
275
|
+
right,
|
|
276
|
+
bottom,
|
|
277
|
+
left
|
|
278
|
+
].join(" ");
|
|
279
|
+
}
|
|
280
|
+
//#endregion
|
|
281
|
+
//#region src/internal/css-rule-scanner.ts
|
|
282
|
+
const trivia = /* @__PURE__ */ new Set([
|
|
283
|
+
_csstools_css_tokenizer.TokenType.Whitespace,
|
|
284
|
+
_csstools_css_tokenizer.TokenType.Comment,
|
|
285
|
+
_csstools_css_tokenizer.TokenType.CDO,
|
|
286
|
+
_csstools_css_tokenizer.TokenType.CDC
|
|
287
|
+
]);
|
|
288
|
+
const closingFor = /* @__PURE__ */ new Map([
|
|
289
|
+
[_csstools_css_tokenizer.TokenType.Function, _csstools_css_tokenizer.TokenType.CloseParen],
|
|
290
|
+
[_csstools_css_tokenizer.TokenType.OpenParen, _csstools_css_tokenizer.TokenType.CloseParen],
|
|
291
|
+
[_csstools_css_tokenizer.TokenType.OpenSquare, _csstools_css_tokenizer.TokenType.CloseSquare],
|
|
292
|
+
[_csstools_css_tokenizer.TokenType.OpenCurly, _csstools_css_tokenizer.TokenType.CloseCurly]
|
|
293
|
+
]);
|
|
294
|
+
/** Consumes top-level CSS Syntax rules and retains their exact UTF-16 spans. */
|
|
295
|
+
function scanTopLevelRules(css) {
|
|
296
|
+
const tokens = (0, _csstools_css_tokenizer.tokenize)({ css });
|
|
297
|
+
const rules = [];
|
|
298
|
+
let index = 0;
|
|
299
|
+
while (index < tokens.length) {
|
|
300
|
+
const token = tokens[index];
|
|
301
|
+
if (!token || token[0] === _csstools_css_tokenizer.TokenType.EOF) break;
|
|
302
|
+
if (trivia.has(token[0]) || token[0] === _csstools_css_tokenizer.TokenType.Semicolon) {
|
|
303
|
+
index += 1;
|
|
304
|
+
continue;
|
|
305
|
+
}
|
|
306
|
+
if (token[0] === _csstools_css_tokenizer.TokenType.CloseCurly) {
|
|
307
|
+
index += 1;
|
|
308
|
+
continue;
|
|
309
|
+
}
|
|
310
|
+
const start = token[2];
|
|
311
|
+
const stack = [];
|
|
312
|
+
let end = token[3];
|
|
313
|
+
let foundBoundary = false;
|
|
314
|
+
for (; index < tokens.length; index += 1) {
|
|
315
|
+
const current = tokens[index];
|
|
316
|
+
if (!current || current[0] === _csstools_css_tokenizer.TokenType.EOF) break;
|
|
317
|
+
end = current[3];
|
|
318
|
+
const closing = closingFor.get(current[0]);
|
|
319
|
+
if (closing) {
|
|
320
|
+
stack.push(closing);
|
|
321
|
+
continue;
|
|
322
|
+
}
|
|
323
|
+
const expected = stack.at(-1);
|
|
324
|
+
if (expected && current[0] === expected) {
|
|
325
|
+
stack.pop();
|
|
326
|
+
if (current[0] === _csstools_css_tokenizer.TokenType.CloseCurly && stack.length === 0) {
|
|
327
|
+
index += 1;
|
|
328
|
+
foundBoundary = true;
|
|
329
|
+
break;
|
|
330
|
+
}
|
|
331
|
+
continue;
|
|
332
|
+
}
|
|
333
|
+
if (current[0] === _csstools_css_tokenizer.TokenType.Semicolon && stack.length === 0) {
|
|
334
|
+
index += 1;
|
|
335
|
+
foundBoundary = true;
|
|
336
|
+
break;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
const sourceEnd = foundBoundary ? end + 1 : css.length;
|
|
340
|
+
const rule = css.slice(start, sourceEnd).trim();
|
|
341
|
+
if (rule !== "") rules.push(rule);
|
|
342
|
+
}
|
|
343
|
+
return rules;
|
|
344
|
+
}
|
|
345
|
+
//#endregion
|
|
346
|
+
//#region src/internal/rule-tree.ts
|
|
347
|
+
/** Owns child-list identity and parent propagation for every live rule node. */
|
|
348
|
+
var RuleTree = class {
|
|
349
|
+
#children = /* @__PURE__ */ new WeakMap();
|
|
350
|
+
#setParentage;
|
|
351
|
+
#parentStyleSheet;
|
|
352
|
+
constructor(setParentage, parentStyleSheet) {
|
|
353
|
+
this.#setParentage = setParentage;
|
|
354
|
+
this.#parentStyleSheet = parentStyleSheet;
|
|
355
|
+
}
|
|
356
|
+
createChildren(owner) {
|
|
357
|
+
const children = [];
|
|
358
|
+
this.#children.set(owner, children);
|
|
359
|
+
return children;
|
|
360
|
+
}
|
|
361
|
+
children(owner) {
|
|
362
|
+
return this.#children.get(owner) ?? [];
|
|
363
|
+
}
|
|
364
|
+
replace(owner, children) {
|
|
365
|
+
const current = this.#children.get(owner);
|
|
366
|
+
if (!current) return;
|
|
367
|
+
for (const child of current) this.attach(child, null, null);
|
|
368
|
+
current.splice(0, current.length, ...children);
|
|
369
|
+
for (const child of children) this.attach(child, owner, this.#parentStyleSheet(owner));
|
|
370
|
+
}
|
|
371
|
+
attach(node, parentRule, parentStyleSheet) {
|
|
372
|
+
this.#setParentage(node, parentRule, parentStyleSheet);
|
|
373
|
+
for (const child of this.#children.get(node) ?? []) this.attach(child, node, parentStyleSheet);
|
|
374
|
+
}
|
|
375
|
+
};
|
|
376
|
+
//#endregion
|
|
377
|
+
//#region src/internal/serializer.ts
|
|
378
|
+
/** Formats reparsable CSS from immutable descriptions of live rule state. */
|
|
379
|
+
var Serializer = class {
|
|
380
|
+
#describe;
|
|
381
|
+
constructor(describe) {
|
|
382
|
+
this.#describe = describe;
|
|
383
|
+
}
|
|
384
|
+
serialize(node) {
|
|
385
|
+
const plan = this.#describe(node);
|
|
386
|
+
if (plan.kind === "raw") return `${plan.cssText}\n`;
|
|
387
|
+
if (plan.kind === "declarations") return `${plan.declarations}${plan.declarations === "" ? "" : "\n"}`;
|
|
388
|
+
const contents = [];
|
|
389
|
+
if (plan.declarations) contents.push(plan.declarations);
|
|
390
|
+
for (const child of plan.children ?? []) contents.push(indent(this.serialize(child).trimEnd()));
|
|
391
|
+
if (contents.length === 0) return `${plan.header} {\n}\n`;
|
|
392
|
+
return `${plan.header} {\n${contents.join("\n")}\n}\n`;
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
function indent(value) {
|
|
396
|
+
return value.split("\n").map((line) => ` ${line}`).join("\n");
|
|
397
|
+
}
|
|
398
|
+
//#endregion
|
|
399
|
+
//#region src/chromium-properties.ts
|
|
400
|
+
const chromiumSupportedProperties = /* @__PURE__ */ new Set([
|
|
401
|
+
"-webkit-align-content",
|
|
402
|
+
"-webkit-align-items",
|
|
403
|
+
"-webkit-align-self",
|
|
404
|
+
"-webkit-animation",
|
|
405
|
+
"-webkit-animation-delay",
|
|
406
|
+
"-webkit-animation-direction",
|
|
407
|
+
"-webkit-animation-duration",
|
|
408
|
+
"-webkit-animation-fill-mode",
|
|
409
|
+
"-webkit-animation-iteration-count",
|
|
410
|
+
"-webkit-animation-name",
|
|
411
|
+
"-webkit-animation-play-state",
|
|
412
|
+
"-webkit-animation-timing-function",
|
|
413
|
+
"-webkit-app-region",
|
|
414
|
+
"-webkit-appearance",
|
|
415
|
+
"-webkit-backface-visibility",
|
|
416
|
+
"-webkit-background-clip",
|
|
417
|
+
"-webkit-background-origin",
|
|
418
|
+
"-webkit-background-size",
|
|
419
|
+
"-webkit-border-after",
|
|
420
|
+
"-webkit-border-after-color",
|
|
421
|
+
"-webkit-border-after-style",
|
|
422
|
+
"-webkit-border-after-width",
|
|
423
|
+
"-webkit-border-before",
|
|
424
|
+
"-webkit-border-before-color",
|
|
425
|
+
"-webkit-border-before-style",
|
|
426
|
+
"-webkit-border-before-width",
|
|
427
|
+
"-webkit-border-bottom-left-radius",
|
|
428
|
+
"-webkit-border-bottom-right-radius",
|
|
429
|
+
"-webkit-border-end",
|
|
430
|
+
"-webkit-border-end-color",
|
|
431
|
+
"-webkit-border-end-style",
|
|
432
|
+
"-webkit-border-end-width",
|
|
433
|
+
"-webkit-border-horizontal-spacing",
|
|
434
|
+
"-webkit-border-image",
|
|
435
|
+
"-webkit-border-radius",
|
|
436
|
+
"-webkit-border-start",
|
|
437
|
+
"-webkit-border-start-color",
|
|
438
|
+
"-webkit-border-start-style",
|
|
439
|
+
"-webkit-border-start-width",
|
|
440
|
+
"-webkit-border-top-left-radius",
|
|
441
|
+
"-webkit-border-top-right-radius",
|
|
442
|
+
"-webkit-border-vertical-spacing",
|
|
443
|
+
"-webkit-box-align",
|
|
444
|
+
"-webkit-box-decoration-break",
|
|
445
|
+
"-webkit-box-direction",
|
|
446
|
+
"-webkit-box-flex",
|
|
447
|
+
"-webkit-box-ordinal-group",
|
|
448
|
+
"-webkit-box-orient",
|
|
449
|
+
"-webkit-box-pack",
|
|
450
|
+
"-webkit-box-reflect",
|
|
451
|
+
"-webkit-box-shadow",
|
|
452
|
+
"-webkit-box-sizing",
|
|
453
|
+
"-webkit-clip-path",
|
|
454
|
+
"-webkit-column-break-after",
|
|
455
|
+
"-webkit-column-break-before",
|
|
456
|
+
"-webkit-column-break-inside",
|
|
457
|
+
"-webkit-column-count",
|
|
458
|
+
"-webkit-column-gap",
|
|
459
|
+
"-webkit-column-rule",
|
|
460
|
+
"-webkit-column-rule-color",
|
|
461
|
+
"-webkit-column-rule-style",
|
|
462
|
+
"-webkit-column-rule-width",
|
|
463
|
+
"-webkit-column-span",
|
|
464
|
+
"-webkit-column-width",
|
|
465
|
+
"-webkit-columns",
|
|
466
|
+
"-webkit-filter",
|
|
467
|
+
"-webkit-flex",
|
|
468
|
+
"-webkit-flex-basis",
|
|
469
|
+
"-webkit-flex-direction",
|
|
470
|
+
"-webkit-flex-flow",
|
|
471
|
+
"-webkit-flex-grow",
|
|
472
|
+
"-webkit-flex-shrink",
|
|
473
|
+
"-webkit-flex-wrap",
|
|
474
|
+
"-webkit-font-feature-settings",
|
|
475
|
+
"-webkit-font-smoothing",
|
|
476
|
+
"-webkit-hyphenate-character",
|
|
477
|
+
"-webkit-justify-content",
|
|
478
|
+
"-webkit-line-break",
|
|
479
|
+
"-webkit-line-clamp",
|
|
480
|
+
"-webkit-locale",
|
|
481
|
+
"-webkit-logical-height",
|
|
482
|
+
"-webkit-logical-width",
|
|
483
|
+
"-webkit-margin-after",
|
|
484
|
+
"-webkit-margin-before",
|
|
485
|
+
"-webkit-margin-end",
|
|
486
|
+
"-webkit-margin-start",
|
|
487
|
+
"-webkit-mask",
|
|
488
|
+
"-webkit-mask-box-image",
|
|
489
|
+
"-webkit-mask-box-image-outset",
|
|
490
|
+
"-webkit-mask-box-image-repeat",
|
|
491
|
+
"-webkit-mask-box-image-slice",
|
|
492
|
+
"-webkit-mask-box-image-source",
|
|
493
|
+
"-webkit-mask-box-image-width",
|
|
494
|
+
"-webkit-mask-clip",
|
|
495
|
+
"-webkit-mask-composite",
|
|
496
|
+
"-webkit-mask-image",
|
|
497
|
+
"-webkit-mask-origin",
|
|
498
|
+
"-webkit-mask-position",
|
|
499
|
+
"-webkit-mask-position-x",
|
|
500
|
+
"-webkit-mask-position-y",
|
|
501
|
+
"-webkit-mask-repeat",
|
|
502
|
+
"-webkit-mask-size",
|
|
503
|
+
"-webkit-max-logical-height",
|
|
504
|
+
"-webkit-max-logical-width",
|
|
505
|
+
"-webkit-min-logical-height",
|
|
506
|
+
"-webkit-min-logical-width",
|
|
507
|
+
"-webkit-opacity",
|
|
508
|
+
"-webkit-order",
|
|
509
|
+
"-webkit-padding-after",
|
|
510
|
+
"-webkit-padding-before",
|
|
511
|
+
"-webkit-padding-end",
|
|
512
|
+
"-webkit-padding-start",
|
|
513
|
+
"-webkit-perspective",
|
|
514
|
+
"-webkit-perspective-origin",
|
|
515
|
+
"-webkit-perspective-origin-x",
|
|
516
|
+
"-webkit-perspective-origin-y",
|
|
517
|
+
"-webkit-print-color-adjust",
|
|
518
|
+
"-webkit-rtl-ordering",
|
|
519
|
+
"-webkit-ruby-position",
|
|
520
|
+
"-webkit-shape-image-threshold",
|
|
521
|
+
"-webkit-shape-margin",
|
|
522
|
+
"-webkit-shape-outside",
|
|
523
|
+
"-webkit-tap-highlight-color",
|
|
524
|
+
"-webkit-text-combine",
|
|
525
|
+
"-webkit-text-decorations-in-effect",
|
|
526
|
+
"-webkit-text-emphasis",
|
|
527
|
+
"-webkit-text-emphasis-color",
|
|
528
|
+
"-webkit-text-emphasis-position",
|
|
529
|
+
"-webkit-text-emphasis-style",
|
|
530
|
+
"-webkit-text-fill-color",
|
|
531
|
+
"-webkit-text-orientation",
|
|
532
|
+
"-webkit-text-security",
|
|
533
|
+
"-webkit-text-size-adjust",
|
|
534
|
+
"-webkit-text-stroke",
|
|
535
|
+
"-webkit-text-stroke-color",
|
|
536
|
+
"-webkit-text-stroke-width",
|
|
537
|
+
"-webkit-transform",
|
|
538
|
+
"-webkit-transform-origin",
|
|
539
|
+
"-webkit-transform-origin-x",
|
|
540
|
+
"-webkit-transform-origin-y",
|
|
541
|
+
"-webkit-transform-origin-z",
|
|
542
|
+
"-webkit-transform-style",
|
|
543
|
+
"-webkit-transition",
|
|
544
|
+
"-webkit-transition-delay",
|
|
545
|
+
"-webkit-transition-duration",
|
|
546
|
+
"-webkit-transition-property",
|
|
547
|
+
"-webkit-transition-timing-function",
|
|
548
|
+
"-webkit-user-drag",
|
|
549
|
+
"-webkit-user-modify",
|
|
550
|
+
"-webkit-user-select",
|
|
551
|
+
"-webkit-writing-mode",
|
|
552
|
+
"accent-color",
|
|
553
|
+
"align-content",
|
|
554
|
+
"align-items",
|
|
555
|
+
"align-self",
|
|
556
|
+
"alignment-baseline",
|
|
557
|
+
"all",
|
|
558
|
+
"anchor-name",
|
|
559
|
+
"anchor-scope",
|
|
560
|
+
"animation",
|
|
561
|
+
"animation-composition",
|
|
562
|
+
"animation-delay",
|
|
563
|
+
"animation-direction",
|
|
564
|
+
"animation-duration",
|
|
565
|
+
"animation-fill-mode",
|
|
566
|
+
"animation-iteration-count",
|
|
567
|
+
"animation-name",
|
|
568
|
+
"animation-play-state",
|
|
569
|
+
"animation-range",
|
|
570
|
+
"animation-range-end",
|
|
571
|
+
"animation-range-start",
|
|
572
|
+
"animation-timeline",
|
|
573
|
+
"animation-timing-function",
|
|
574
|
+
"animation-trigger",
|
|
575
|
+
"app-region",
|
|
576
|
+
"appearance",
|
|
577
|
+
"aspect-ratio",
|
|
578
|
+
"backdrop-filter",
|
|
579
|
+
"backface-visibility",
|
|
580
|
+
"background",
|
|
581
|
+
"background-attachment",
|
|
582
|
+
"background-blend-mode",
|
|
583
|
+
"background-clip",
|
|
584
|
+
"background-color",
|
|
585
|
+
"background-image",
|
|
586
|
+
"background-origin",
|
|
587
|
+
"background-position",
|
|
588
|
+
"background-position-x",
|
|
589
|
+
"background-position-y",
|
|
590
|
+
"background-repeat",
|
|
591
|
+
"background-size",
|
|
592
|
+
"baseline-shift",
|
|
593
|
+
"baseline-source",
|
|
594
|
+
"block-size",
|
|
595
|
+
"border",
|
|
596
|
+
"border-block",
|
|
597
|
+
"border-block-color",
|
|
598
|
+
"border-block-end",
|
|
599
|
+
"border-block-end-color",
|
|
600
|
+
"border-block-end-style",
|
|
601
|
+
"border-block-end-width",
|
|
602
|
+
"border-block-start",
|
|
603
|
+
"border-block-start-color",
|
|
604
|
+
"border-block-start-style",
|
|
605
|
+
"border-block-start-width",
|
|
606
|
+
"border-block-style",
|
|
607
|
+
"border-block-width",
|
|
608
|
+
"border-bottom",
|
|
609
|
+
"border-bottom-color",
|
|
610
|
+
"border-bottom-left-radius",
|
|
611
|
+
"border-bottom-right-radius",
|
|
612
|
+
"border-bottom-style",
|
|
613
|
+
"border-bottom-width",
|
|
614
|
+
"border-collapse",
|
|
615
|
+
"border-color",
|
|
616
|
+
"border-end-end-radius",
|
|
617
|
+
"border-end-start-radius",
|
|
618
|
+
"border-image",
|
|
619
|
+
"border-image-outset",
|
|
620
|
+
"border-image-repeat",
|
|
621
|
+
"border-image-slice",
|
|
622
|
+
"border-image-source",
|
|
623
|
+
"border-image-width",
|
|
624
|
+
"border-inline",
|
|
625
|
+
"border-inline-color",
|
|
626
|
+
"border-inline-end",
|
|
627
|
+
"border-inline-end-color",
|
|
628
|
+
"border-inline-end-style",
|
|
629
|
+
"border-inline-end-width",
|
|
630
|
+
"border-inline-start",
|
|
631
|
+
"border-inline-start-color",
|
|
632
|
+
"border-inline-start-style",
|
|
633
|
+
"border-inline-start-width",
|
|
634
|
+
"border-inline-style",
|
|
635
|
+
"border-inline-width",
|
|
636
|
+
"border-left",
|
|
637
|
+
"border-left-color",
|
|
638
|
+
"border-left-style",
|
|
639
|
+
"border-left-width",
|
|
640
|
+
"border-radius",
|
|
641
|
+
"border-right",
|
|
642
|
+
"border-right-color",
|
|
643
|
+
"border-right-style",
|
|
644
|
+
"border-right-width",
|
|
645
|
+
"border-shape",
|
|
646
|
+
"border-spacing",
|
|
647
|
+
"border-start-end-radius",
|
|
648
|
+
"border-start-start-radius",
|
|
649
|
+
"border-style",
|
|
650
|
+
"border-top",
|
|
651
|
+
"border-top-color",
|
|
652
|
+
"border-top-left-radius",
|
|
653
|
+
"border-top-right-radius",
|
|
654
|
+
"border-top-style",
|
|
655
|
+
"border-top-width",
|
|
656
|
+
"border-width",
|
|
657
|
+
"bottom",
|
|
658
|
+
"box-decoration-break",
|
|
659
|
+
"box-shadow",
|
|
660
|
+
"box-sizing",
|
|
661
|
+
"break-after",
|
|
662
|
+
"break-before",
|
|
663
|
+
"break-inside",
|
|
664
|
+
"buffered-rendering",
|
|
665
|
+
"caption-side",
|
|
666
|
+
"caret-animation",
|
|
667
|
+
"caret-color",
|
|
668
|
+
"caret-shape",
|
|
669
|
+
"clear",
|
|
670
|
+
"clip",
|
|
671
|
+
"clip-path",
|
|
672
|
+
"clip-rule",
|
|
673
|
+
"color",
|
|
674
|
+
"color-interpolation",
|
|
675
|
+
"color-interpolation-filters",
|
|
676
|
+
"color-rendering",
|
|
677
|
+
"color-scheme",
|
|
678
|
+
"column-count",
|
|
679
|
+
"column-fill",
|
|
680
|
+
"column-gap",
|
|
681
|
+
"column-height",
|
|
682
|
+
"column-rule",
|
|
683
|
+
"column-rule-break",
|
|
684
|
+
"column-rule-color",
|
|
685
|
+
"column-rule-inset",
|
|
686
|
+
"column-rule-inset-cap",
|
|
687
|
+
"column-rule-inset-cap-end",
|
|
688
|
+
"column-rule-inset-cap-start",
|
|
689
|
+
"column-rule-inset-end",
|
|
690
|
+
"column-rule-inset-junction",
|
|
691
|
+
"column-rule-inset-junction-end",
|
|
692
|
+
"column-rule-inset-junction-start",
|
|
693
|
+
"column-rule-inset-start",
|
|
694
|
+
"column-rule-style",
|
|
695
|
+
"column-rule-visibility-items",
|
|
696
|
+
"column-rule-width",
|
|
697
|
+
"column-span",
|
|
698
|
+
"column-width",
|
|
699
|
+
"column-wrap",
|
|
700
|
+
"columns",
|
|
701
|
+
"contain",
|
|
702
|
+
"contain-intrinsic-block-size",
|
|
703
|
+
"contain-intrinsic-height",
|
|
704
|
+
"contain-intrinsic-inline-size",
|
|
705
|
+
"contain-intrinsic-size",
|
|
706
|
+
"contain-intrinsic-width",
|
|
707
|
+
"container",
|
|
708
|
+
"container-name",
|
|
709
|
+
"container-type",
|
|
710
|
+
"content",
|
|
711
|
+
"content-visibility",
|
|
712
|
+
"corner-block-end-shape",
|
|
713
|
+
"corner-block-start-shape",
|
|
714
|
+
"corner-bottom-left-shape",
|
|
715
|
+
"corner-bottom-right-shape",
|
|
716
|
+
"corner-bottom-shape",
|
|
717
|
+
"corner-end-end-shape",
|
|
718
|
+
"corner-end-start-shape",
|
|
719
|
+
"corner-inline-end-shape",
|
|
720
|
+
"corner-inline-start-shape",
|
|
721
|
+
"corner-left-shape",
|
|
722
|
+
"corner-right-shape",
|
|
723
|
+
"corner-shape",
|
|
724
|
+
"corner-start-end-shape",
|
|
725
|
+
"corner-start-start-shape",
|
|
726
|
+
"corner-top-left-shape",
|
|
727
|
+
"corner-top-right-shape",
|
|
728
|
+
"corner-top-shape",
|
|
729
|
+
"counter-increment",
|
|
730
|
+
"counter-reset",
|
|
731
|
+
"counter-set",
|
|
732
|
+
"cursor",
|
|
733
|
+
"cx",
|
|
734
|
+
"cy",
|
|
735
|
+
"d",
|
|
736
|
+
"direction",
|
|
737
|
+
"display",
|
|
738
|
+
"dominant-baseline",
|
|
739
|
+
"dynamic-range-limit",
|
|
740
|
+
"empty-cells",
|
|
741
|
+
"field-sizing",
|
|
742
|
+
"fill",
|
|
743
|
+
"fill-opacity",
|
|
744
|
+
"fill-rule",
|
|
745
|
+
"filter",
|
|
746
|
+
"flex",
|
|
747
|
+
"flex-basis",
|
|
748
|
+
"flex-direction",
|
|
749
|
+
"flex-flow",
|
|
750
|
+
"flex-grow",
|
|
751
|
+
"flex-line-count",
|
|
752
|
+
"flex-shrink",
|
|
753
|
+
"flex-wrap",
|
|
754
|
+
"float",
|
|
755
|
+
"flood-color",
|
|
756
|
+
"flood-opacity",
|
|
757
|
+
"font",
|
|
758
|
+
"font-family",
|
|
759
|
+
"font-feature-settings",
|
|
760
|
+
"font-kerning",
|
|
761
|
+
"font-language-override",
|
|
762
|
+
"font-optical-sizing",
|
|
763
|
+
"font-palette",
|
|
764
|
+
"font-size",
|
|
765
|
+
"font-size-adjust",
|
|
766
|
+
"font-stretch",
|
|
767
|
+
"font-style",
|
|
768
|
+
"font-synthesis",
|
|
769
|
+
"font-synthesis-small-caps",
|
|
770
|
+
"font-synthesis-style",
|
|
771
|
+
"font-synthesis-weight",
|
|
772
|
+
"font-variant",
|
|
773
|
+
"font-variant-alternates",
|
|
774
|
+
"font-variant-caps",
|
|
775
|
+
"font-variant-east-asian",
|
|
776
|
+
"font-variant-emoji",
|
|
777
|
+
"font-variant-ligatures",
|
|
778
|
+
"font-variant-numeric",
|
|
779
|
+
"font-variant-position",
|
|
780
|
+
"font-variation-settings",
|
|
781
|
+
"font-weight",
|
|
782
|
+
"forced-color-adjust",
|
|
783
|
+
"gap",
|
|
784
|
+
"grid",
|
|
785
|
+
"grid-area",
|
|
786
|
+
"grid-auto-columns",
|
|
787
|
+
"grid-auto-flow",
|
|
788
|
+
"grid-auto-rows",
|
|
789
|
+
"grid-column",
|
|
790
|
+
"grid-column-end",
|
|
791
|
+
"grid-column-gap",
|
|
792
|
+
"grid-column-start",
|
|
793
|
+
"grid-gap",
|
|
794
|
+
"grid-row",
|
|
795
|
+
"grid-row-end",
|
|
796
|
+
"grid-row-gap",
|
|
797
|
+
"grid-row-start",
|
|
798
|
+
"grid-template",
|
|
799
|
+
"grid-template-areas",
|
|
800
|
+
"grid-template-columns",
|
|
801
|
+
"grid-template-rows",
|
|
802
|
+
"height",
|
|
803
|
+
"hyphenate-character",
|
|
804
|
+
"hyphenate-limit-chars",
|
|
805
|
+
"hyphens",
|
|
806
|
+
"image-orientation",
|
|
807
|
+
"image-rendering",
|
|
808
|
+
"initial-letter",
|
|
809
|
+
"inline-size",
|
|
810
|
+
"inset",
|
|
811
|
+
"inset-block",
|
|
812
|
+
"inset-block-end",
|
|
813
|
+
"inset-block-start",
|
|
814
|
+
"inset-inline",
|
|
815
|
+
"inset-inline-end",
|
|
816
|
+
"inset-inline-start",
|
|
817
|
+
"interactivity",
|
|
818
|
+
"interest-delay",
|
|
819
|
+
"interest-delay-end",
|
|
820
|
+
"interest-delay-start",
|
|
821
|
+
"interpolate-size",
|
|
822
|
+
"isolation",
|
|
823
|
+
"justify-content",
|
|
824
|
+
"justify-items",
|
|
825
|
+
"justify-self",
|
|
826
|
+
"left",
|
|
827
|
+
"letter-spacing",
|
|
828
|
+
"lighting-color",
|
|
829
|
+
"line-break",
|
|
830
|
+
"line-height",
|
|
831
|
+
"list-style",
|
|
832
|
+
"list-style-image",
|
|
833
|
+
"list-style-position",
|
|
834
|
+
"list-style-type",
|
|
835
|
+
"margin",
|
|
836
|
+
"margin-block",
|
|
837
|
+
"margin-block-end",
|
|
838
|
+
"margin-block-start",
|
|
839
|
+
"margin-bottom",
|
|
840
|
+
"margin-inline",
|
|
841
|
+
"margin-inline-end",
|
|
842
|
+
"margin-inline-start",
|
|
843
|
+
"margin-left",
|
|
844
|
+
"margin-right",
|
|
845
|
+
"margin-top",
|
|
846
|
+
"marker",
|
|
847
|
+
"marker-end",
|
|
848
|
+
"marker-mid",
|
|
849
|
+
"marker-start",
|
|
850
|
+
"mask",
|
|
851
|
+
"mask-clip",
|
|
852
|
+
"mask-composite",
|
|
853
|
+
"mask-image",
|
|
854
|
+
"mask-mode",
|
|
855
|
+
"mask-origin",
|
|
856
|
+
"mask-position",
|
|
857
|
+
"mask-repeat",
|
|
858
|
+
"mask-size",
|
|
859
|
+
"mask-type",
|
|
860
|
+
"math-depth",
|
|
861
|
+
"math-shift",
|
|
862
|
+
"math-style",
|
|
863
|
+
"max-block-size",
|
|
864
|
+
"max-height",
|
|
865
|
+
"max-inline-size",
|
|
866
|
+
"max-width",
|
|
867
|
+
"min-block-size",
|
|
868
|
+
"min-height",
|
|
869
|
+
"min-inline-size",
|
|
870
|
+
"min-width",
|
|
871
|
+
"mix-blend-mode",
|
|
872
|
+
"object-fit",
|
|
873
|
+
"object-position",
|
|
874
|
+
"object-view-box",
|
|
875
|
+
"offset",
|
|
876
|
+
"offset-anchor",
|
|
877
|
+
"offset-distance",
|
|
878
|
+
"offset-path",
|
|
879
|
+
"offset-position",
|
|
880
|
+
"offset-rotate",
|
|
881
|
+
"opacity",
|
|
882
|
+
"order",
|
|
883
|
+
"orphans",
|
|
884
|
+
"outline",
|
|
885
|
+
"outline-color",
|
|
886
|
+
"outline-offset",
|
|
887
|
+
"outline-style",
|
|
888
|
+
"outline-width",
|
|
889
|
+
"overflow",
|
|
890
|
+
"overflow-anchor",
|
|
891
|
+
"overflow-block",
|
|
892
|
+
"overflow-clip-margin",
|
|
893
|
+
"overflow-inline",
|
|
894
|
+
"overflow-wrap",
|
|
895
|
+
"overflow-x",
|
|
896
|
+
"overflow-y",
|
|
897
|
+
"overlay",
|
|
898
|
+
"overscroll-behavior",
|
|
899
|
+
"overscroll-behavior-block",
|
|
900
|
+
"overscroll-behavior-inline",
|
|
901
|
+
"overscroll-behavior-x",
|
|
902
|
+
"overscroll-behavior-y",
|
|
903
|
+
"padding",
|
|
904
|
+
"padding-block",
|
|
905
|
+
"padding-block-end",
|
|
906
|
+
"padding-block-start",
|
|
907
|
+
"padding-bottom",
|
|
908
|
+
"padding-inline",
|
|
909
|
+
"padding-inline-end",
|
|
910
|
+
"padding-inline-start",
|
|
911
|
+
"padding-left",
|
|
912
|
+
"padding-right",
|
|
913
|
+
"padding-top",
|
|
914
|
+
"page",
|
|
915
|
+
"page-break-after",
|
|
916
|
+
"page-break-before",
|
|
917
|
+
"page-break-inside",
|
|
918
|
+
"page-margin-safety",
|
|
919
|
+
"page-orientation",
|
|
920
|
+
"paint-order",
|
|
921
|
+
"perspective",
|
|
922
|
+
"perspective-origin",
|
|
923
|
+
"place-content",
|
|
924
|
+
"place-items",
|
|
925
|
+
"place-self",
|
|
926
|
+
"pointer-events",
|
|
927
|
+
"position",
|
|
928
|
+
"position-anchor",
|
|
929
|
+
"position-area",
|
|
930
|
+
"position-try",
|
|
931
|
+
"position-try-fallbacks",
|
|
932
|
+
"position-try-order",
|
|
933
|
+
"position-visibility",
|
|
934
|
+
"print-color-adjust",
|
|
935
|
+
"quotes",
|
|
936
|
+
"r",
|
|
937
|
+
"reading-flow",
|
|
938
|
+
"reading-order",
|
|
939
|
+
"resize",
|
|
940
|
+
"right",
|
|
941
|
+
"rotate",
|
|
942
|
+
"row-gap",
|
|
943
|
+
"row-rule",
|
|
944
|
+
"row-rule-break",
|
|
945
|
+
"row-rule-color",
|
|
946
|
+
"row-rule-inset",
|
|
947
|
+
"row-rule-inset-cap",
|
|
948
|
+
"row-rule-inset-cap-end",
|
|
949
|
+
"row-rule-inset-cap-start",
|
|
950
|
+
"row-rule-inset-end",
|
|
951
|
+
"row-rule-inset-junction",
|
|
952
|
+
"row-rule-inset-junction-end",
|
|
953
|
+
"row-rule-inset-junction-start",
|
|
954
|
+
"row-rule-inset-start",
|
|
955
|
+
"row-rule-style",
|
|
956
|
+
"row-rule-visibility-items",
|
|
957
|
+
"row-rule-width",
|
|
958
|
+
"ruby-align",
|
|
959
|
+
"ruby-overhang",
|
|
960
|
+
"ruby-position",
|
|
961
|
+
"rule",
|
|
962
|
+
"rule-break",
|
|
963
|
+
"rule-color",
|
|
964
|
+
"rule-inset",
|
|
965
|
+
"rule-inset-cap",
|
|
966
|
+
"rule-inset-end",
|
|
967
|
+
"rule-inset-junction",
|
|
968
|
+
"rule-inset-start",
|
|
969
|
+
"rule-overlap",
|
|
970
|
+
"rule-style",
|
|
971
|
+
"rule-visibility-items",
|
|
972
|
+
"rule-width",
|
|
973
|
+
"rx",
|
|
974
|
+
"ry",
|
|
975
|
+
"scale",
|
|
976
|
+
"scroll-behavior",
|
|
977
|
+
"scroll-initial-target",
|
|
978
|
+
"scroll-margin",
|
|
979
|
+
"scroll-margin-block",
|
|
980
|
+
"scroll-margin-block-end",
|
|
981
|
+
"scroll-margin-block-start",
|
|
982
|
+
"scroll-margin-bottom",
|
|
983
|
+
"scroll-margin-inline",
|
|
984
|
+
"scroll-margin-inline-end",
|
|
985
|
+
"scroll-margin-inline-start",
|
|
986
|
+
"scroll-margin-left",
|
|
987
|
+
"scroll-margin-right",
|
|
988
|
+
"scroll-margin-top",
|
|
989
|
+
"scroll-marker-group",
|
|
990
|
+
"scroll-padding",
|
|
991
|
+
"scroll-padding-block",
|
|
992
|
+
"scroll-padding-block-end",
|
|
993
|
+
"scroll-padding-block-start",
|
|
994
|
+
"scroll-padding-bottom",
|
|
995
|
+
"scroll-padding-inline",
|
|
996
|
+
"scroll-padding-inline-end",
|
|
997
|
+
"scroll-padding-inline-start",
|
|
998
|
+
"scroll-padding-left",
|
|
999
|
+
"scroll-padding-right",
|
|
1000
|
+
"scroll-padding-top",
|
|
1001
|
+
"scroll-snap-align",
|
|
1002
|
+
"scroll-snap-stop",
|
|
1003
|
+
"scroll-snap-type",
|
|
1004
|
+
"scroll-target-group",
|
|
1005
|
+
"scroll-timeline",
|
|
1006
|
+
"scroll-timeline-axis",
|
|
1007
|
+
"scroll-timeline-name",
|
|
1008
|
+
"scrollbar-color",
|
|
1009
|
+
"scrollbar-gutter",
|
|
1010
|
+
"scrollbar-width",
|
|
1011
|
+
"shape-image-threshold",
|
|
1012
|
+
"shape-margin",
|
|
1013
|
+
"shape-outside",
|
|
1014
|
+
"shape-rendering",
|
|
1015
|
+
"size",
|
|
1016
|
+
"speak",
|
|
1017
|
+
"stop-color",
|
|
1018
|
+
"stop-opacity",
|
|
1019
|
+
"stroke",
|
|
1020
|
+
"stroke-dasharray",
|
|
1021
|
+
"stroke-dashoffset",
|
|
1022
|
+
"stroke-linecap",
|
|
1023
|
+
"stroke-linejoin",
|
|
1024
|
+
"stroke-miterlimit",
|
|
1025
|
+
"stroke-opacity",
|
|
1026
|
+
"stroke-width",
|
|
1027
|
+
"tab-size",
|
|
1028
|
+
"table-layout",
|
|
1029
|
+
"text-align",
|
|
1030
|
+
"text-align-last",
|
|
1031
|
+
"text-anchor",
|
|
1032
|
+
"text-autospace",
|
|
1033
|
+
"text-box",
|
|
1034
|
+
"text-box-edge",
|
|
1035
|
+
"text-box-trim",
|
|
1036
|
+
"text-combine-upright",
|
|
1037
|
+
"text-decoration",
|
|
1038
|
+
"text-decoration-color",
|
|
1039
|
+
"text-decoration-line",
|
|
1040
|
+
"text-decoration-skip-ink",
|
|
1041
|
+
"text-decoration-style",
|
|
1042
|
+
"text-decoration-thickness",
|
|
1043
|
+
"text-emphasis",
|
|
1044
|
+
"text-emphasis-color",
|
|
1045
|
+
"text-emphasis-position",
|
|
1046
|
+
"text-emphasis-style",
|
|
1047
|
+
"text-fit",
|
|
1048
|
+
"text-indent",
|
|
1049
|
+
"text-justify",
|
|
1050
|
+
"text-orientation",
|
|
1051
|
+
"text-overflow",
|
|
1052
|
+
"text-rendering",
|
|
1053
|
+
"text-shadow",
|
|
1054
|
+
"text-size-adjust",
|
|
1055
|
+
"text-spacing-trim",
|
|
1056
|
+
"text-transform",
|
|
1057
|
+
"text-underline-offset",
|
|
1058
|
+
"text-underline-position",
|
|
1059
|
+
"text-wrap",
|
|
1060
|
+
"text-wrap-mode",
|
|
1061
|
+
"text-wrap-style",
|
|
1062
|
+
"timeline-scope",
|
|
1063
|
+
"timeline-trigger",
|
|
1064
|
+
"timeline-trigger-activation-range",
|
|
1065
|
+
"timeline-trigger-activation-range-end",
|
|
1066
|
+
"timeline-trigger-activation-range-start",
|
|
1067
|
+
"timeline-trigger-active-range",
|
|
1068
|
+
"timeline-trigger-active-range-end",
|
|
1069
|
+
"timeline-trigger-active-range-start",
|
|
1070
|
+
"timeline-trigger-name",
|
|
1071
|
+
"timeline-trigger-source",
|
|
1072
|
+
"top",
|
|
1073
|
+
"touch-action",
|
|
1074
|
+
"transform",
|
|
1075
|
+
"transform-box",
|
|
1076
|
+
"transform-origin",
|
|
1077
|
+
"transform-style",
|
|
1078
|
+
"transition",
|
|
1079
|
+
"transition-behavior",
|
|
1080
|
+
"transition-delay",
|
|
1081
|
+
"transition-duration",
|
|
1082
|
+
"transition-property",
|
|
1083
|
+
"transition-timing-function",
|
|
1084
|
+
"translate",
|
|
1085
|
+
"trigger-scope",
|
|
1086
|
+
"unicode-bidi",
|
|
1087
|
+
"user-select",
|
|
1088
|
+
"vector-effect",
|
|
1089
|
+
"vertical-align",
|
|
1090
|
+
"view-timeline",
|
|
1091
|
+
"view-timeline-axis",
|
|
1092
|
+
"view-timeline-inset",
|
|
1093
|
+
"view-timeline-name",
|
|
1094
|
+
"view-transition-class",
|
|
1095
|
+
"view-transition-group",
|
|
1096
|
+
"view-transition-name",
|
|
1097
|
+
"view-transition-scope",
|
|
1098
|
+
"visibility",
|
|
1099
|
+
"white-space",
|
|
1100
|
+
"white-space-collapse",
|
|
1101
|
+
"widows",
|
|
1102
|
+
"width",
|
|
1103
|
+
"will-change",
|
|
1104
|
+
"word-break",
|
|
1105
|
+
"word-spacing",
|
|
1106
|
+
"word-wrap",
|
|
1107
|
+
"writing-mode",
|
|
1108
|
+
"x",
|
|
1109
|
+
"y",
|
|
1110
|
+
"z-index",
|
|
1111
|
+
"zoom"
|
|
1112
|
+
]);
|
|
1113
|
+
const chromiumShorthandLonghands = {
|
|
1114
|
+
"-webkit-align-content": ["align-content"],
|
|
1115
|
+
"-webkit-align-items": ["align-items"],
|
|
1116
|
+
"-webkit-align-self": ["align-self"],
|
|
1117
|
+
"-webkit-animation": [
|
|
1118
|
+
"animation-duration",
|
|
1119
|
+
"animation-timing-function",
|
|
1120
|
+
"animation-delay",
|
|
1121
|
+
"animation-iteration-count",
|
|
1122
|
+
"animation-direction",
|
|
1123
|
+
"animation-fill-mode",
|
|
1124
|
+
"animation-play-state",
|
|
1125
|
+
"animation-name",
|
|
1126
|
+
"animation-timeline",
|
|
1127
|
+
"animation-range-start",
|
|
1128
|
+
"animation-range-end"
|
|
1129
|
+
],
|
|
1130
|
+
"-webkit-animation-delay": ["animation-delay"],
|
|
1131
|
+
"-webkit-animation-direction": ["animation-direction"],
|
|
1132
|
+
"-webkit-animation-duration": ["animation-duration"],
|
|
1133
|
+
"-webkit-animation-fill-mode": ["animation-fill-mode"],
|
|
1134
|
+
"-webkit-animation-iteration-count": ["animation-iteration-count"],
|
|
1135
|
+
"-webkit-animation-name": ["animation-name"],
|
|
1136
|
+
"-webkit-animation-play-state": ["animation-play-state"],
|
|
1137
|
+
"-webkit-animation-timing-function": ["animation-timing-function"],
|
|
1138
|
+
"-webkit-app-region": ["app-region"],
|
|
1139
|
+
"-webkit-appearance": ["appearance"],
|
|
1140
|
+
"-webkit-backface-visibility": ["backface-visibility"],
|
|
1141
|
+
"-webkit-background-clip": ["background-clip"],
|
|
1142
|
+
"-webkit-background-origin": ["background-origin"],
|
|
1143
|
+
"-webkit-background-size": ["background-size"],
|
|
1144
|
+
"-webkit-border-after": [
|
|
1145
|
+
"border-block-end-width",
|
|
1146
|
+
"border-block-end-style",
|
|
1147
|
+
"border-block-end-color"
|
|
1148
|
+
],
|
|
1149
|
+
"-webkit-border-after-color": ["border-block-end-color"],
|
|
1150
|
+
"-webkit-border-after-style": ["border-block-end-style"],
|
|
1151
|
+
"-webkit-border-after-width": ["border-block-end-width"],
|
|
1152
|
+
"-webkit-border-before": [
|
|
1153
|
+
"border-block-start-width",
|
|
1154
|
+
"border-block-start-style",
|
|
1155
|
+
"border-block-start-color"
|
|
1156
|
+
],
|
|
1157
|
+
"-webkit-border-before-color": ["border-block-start-color"],
|
|
1158
|
+
"-webkit-border-before-style": ["border-block-start-style"],
|
|
1159
|
+
"-webkit-border-before-width": ["border-block-start-width"],
|
|
1160
|
+
"-webkit-border-bottom-left-radius": ["border-bottom-left-radius"],
|
|
1161
|
+
"-webkit-border-bottom-right-radius": ["border-bottom-right-radius"],
|
|
1162
|
+
"-webkit-border-end": [
|
|
1163
|
+
"border-inline-end-width",
|
|
1164
|
+
"border-inline-end-style",
|
|
1165
|
+
"border-inline-end-color"
|
|
1166
|
+
],
|
|
1167
|
+
"-webkit-border-end-color": ["border-inline-end-color"],
|
|
1168
|
+
"-webkit-border-end-style": ["border-inline-end-style"],
|
|
1169
|
+
"-webkit-border-end-width": ["border-inline-end-width"],
|
|
1170
|
+
"-webkit-border-radius": [
|
|
1171
|
+
"border-top-left-radius",
|
|
1172
|
+
"border-top-right-radius",
|
|
1173
|
+
"border-bottom-right-radius",
|
|
1174
|
+
"border-bottom-left-radius"
|
|
1175
|
+
],
|
|
1176
|
+
"-webkit-border-start": [
|
|
1177
|
+
"border-inline-start-width",
|
|
1178
|
+
"border-inline-start-style",
|
|
1179
|
+
"border-inline-start-color"
|
|
1180
|
+
],
|
|
1181
|
+
"-webkit-border-start-color": ["border-inline-start-color"],
|
|
1182
|
+
"-webkit-border-start-style": ["border-inline-start-style"],
|
|
1183
|
+
"-webkit-border-start-width": ["border-inline-start-width"],
|
|
1184
|
+
"-webkit-border-top-left-radius": ["border-top-left-radius"],
|
|
1185
|
+
"-webkit-border-top-right-radius": ["border-top-right-radius"],
|
|
1186
|
+
"-webkit-box-shadow": ["box-shadow"],
|
|
1187
|
+
"-webkit-box-sizing": ["box-sizing"],
|
|
1188
|
+
"-webkit-clip-path": ["clip-path"],
|
|
1189
|
+
"-webkit-column-break-after": ["break-after"],
|
|
1190
|
+
"-webkit-column-break-before": ["break-before"],
|
|
1191
|
+
"-webkit-column-break-inside": ["break-inside"],
|
|
1192
|
+
"-webkit-column-count": ["column-count"],
|
|
1193
|
+
"-webkit-column-gap": ["column-gap"],
|
|
1194
|
+
"-webkit-column-rule": [
|
|
1195
|
+
"column-rule-width",
|
|
1196
|
+
"column-rule-style",
|
|
1197
|
+
"column-rule-color"
|
|
1198
|
+
],
|
|
1199
|
+
"-webkit-column-rule-color": ["column-rule-color"],
|
|
1200
|
+
"-webkit-column-rule-style": ["column-rule-style"],
|
|
1201
|
+
"-webkit-column-rule-width": ["column-rule-width"],
|
|
1202
|
+
"-webkit-column-span": ["column-span"],
|
|
1203
|
+
"-webkit-column-width": ["column-width"],
|
|
1204
|
+
"-webkit-columns": [
|
|
1205
|
+
"column-width",
|
|
1206
|
+
"column-count",
|
|
1207
|
+
"column-height",
|
|
1208
|
+
"column-wrap"
|
|
1209
|
+
],
|
|
1210
|
+
"-webkit-filter": ["filter"],
|
|
1211
|
+
"-webkit-flex": [
|
|
1212
|
+
"flex-grow",
|
|
1213
|
+
"flex-shrink",
|
|
1214
|
+
"flex-basis"
|
|
1215
|
+
],
|
|
1216
|
+
"-webkit-flex-basis": ["flex-basis"],
|
|
1217
|
+
"-webkit-flex-direction": ["flex-direction"],
|
|
1218
|
+
"-webkit-flex-flow": ["flex-direction", "flex-wrap"],
|
|
1219
|
+
"-webkit-flex-grow": ["flex-grow"],
|
|
1220
|
+
"-webkit-flex-shrink": ["flex-shrink"],
|
|
1221
|
+
"-webkit-flex-wrap": ["flex-wrap"],
|
|
1222
|
+
"-webkit-font-feature-settings": ["font-feature-settings"],
|
|
1223
|
+
"-webkit-hyphenate-character": ["hyphenate-character"],
|
|
1224
|
+
"-webkit-justify-content": ["justify-content"],
|
|
1225
|
+
"-webkit-logical-height": ["block-size"],
|
|
1226
|
+
"-webkit-logical-width": ["inline-size"],
|
|
1227
|
+
"-webkit-margin-after": ["margin-block-end"],
|
|
1228
|
+
"-webkit-margin-before": ["margin-block-start"],
|
|
1229
|
+
"-webkit-margin-end": ["margin-inline-end"],
|
|
1230
|
+
"-webkit-margin-start": ["margin-inline-start"],
|
|
1231
|
+
"-webkit-mask": [
|
|
1232
|
+
"mask-image",
|
|
1233
|
+
"-webkit-mask-position-x",
|
|
1234
|
+
"-webkit-mask-position-y",
|
|
1235
|
+
"mask-size",
|
|
1236
|
+
"mask-repeat",
|
|
1237
|
+
"mask-origin",
|
|
1238
|
+
"mask-clip",
|
|
1239
|
+
"mask-composite",
|
|
1240
|
+
"mask-mode"
|
|
1241
|
+
],
|
|
1242
|
+
"-webkit-mask-box-image": [
|
|
1243
|
+
"-webkit-mask-box-image-source",
|
|
1244
|
+
"-webkit-mask-box-image-slice",
|
|
1245
|
+
"-webkit-mask-box-image-width",
|
|
1246
|
+
"-webkit-mask-box-image-outset",
|
|
1247
|
+
"-webkit-mask-box-image-repeat"
|
|
1248
|
+
],
|
|
1249
|
+
"-webkit-mask-clip": ["mask-clip"],
|
|
1250
|
+
"-webkit-mask-composite": ["mask-composite"],
|
|
1251
|
+
"-webkit-mask-image": ["mask-image"],
|
|
1252
|
+
"-webkit-mask-origin": ["mask-origin"],
|
|
1253
|
+
"-webkit-mask-position": ["-webkit-mask-position-x", "-webkit-mask-position-y"],
|
|
1254
|
+
"-webkit-mask-repeat": ["mask-repeat"],
|
|
1255
|
+
"-webkit-mask-size": ["mask-size"],
|
|
1256
|
+
"-webkit-max-logical-height": ["max-block-size"],
|
|
1257
|
+
"-webkit-max-logical-width": ["max-inline-size"],
|
|
1258
|
+
"-webkit-min-logical-height": ["min-block-size"],
|
|
1259
|
+
"-webkit-min-logical-width": ["min-inline-size"],
|
|
1260
|
+
"-webkit-opacity": ["opacity"],
|
|
1261
|
+
"-webkit-order": ["order"],
|
|
1262
|
+
"-webkit-padding-after": ["padding-block-end"],
|
|
1263
|
+
"-webkit-padding-before": ["padding-block-start"],
|
|
1264
|
+
"-webkit-padding-end": ["padding-inline-end"],
|
|
1265
|
+
"-webkit-padding-start": ["padding-inline-start"],
|
|
1266
|
+
"-webkit-perspective": ["perspective"],
|
|
1267
|
+
"-webkit-perspective-origin": ["perspective-origin"],
|
|
1268
|
+
"-webkit-print-color-adjust": ["print-color-adjust"],
|
|
1269
|
+
"-webkit-shape-image-threshold": ["shape-image-threshold"],
|
|
1270
|
+
"-webkit-shape-margin": ["shape-margin"],
|
|
1271
|
+
"-webkit-shape-outside": ["shape-outside"],
|
|
1272
|
+
"-webkit-text-emphasis": ["text-emphasis-style", "text-emphasis-color"],
|
|
1273
|
+
"-webkit-text-emphasis-color": ["text-emphasis-color"],
|
|
1274
|
+
"-webkit-text-emphasis-position": ["text-emphasis-position"],
|
|
1275
|
+
"-webkit-text-emphasis-style": ["text-emphasis-style"],
|
|
1276
|
+
"-webkit-text-size-adjust": ["text-size-adjust"],
|
|
1277
|
+
"-webkit-text-stroke": ["-webkit-text-stroke-width", "-webkit-text-stroke-color"],
|
|
1278
|
+
"-webkit-transform": ["transform"],
|
|
1279
|
+
"-webkit-transform-origin": ["transform-origin"],
|
|
1280
|
+
"-webkit-transform-style": ["transform-style"],
|
|
1281
|
+
"-webkit-transition": [
|
|
1282
|
+
"transition-property",
|
|
1283
|
+
"transition-duration",
|
|
1284
|
+
"transition-timing-function",
|
|
1285
|
+
"transition-delay",
|
|
1286
|
+
"transition-behavior"
|
|
1287
|
+
],
|
|
1288
|
+
"-webkit-transition-delay": ["transition-delay"],
|
|
1289
|
+
"-webkit-transition-duration": ["transition-duration"],
|
|
1290
|
+
"-webkit-transition-property": ["transition-property"],
|
|
1291
|
+
"-webkit-transition-timing-function": ["transition-timing-function"],
|
|
1292
|
+
"-webkit-user-select": ["user-select"],
|
|
1293
|
+
"animation": [
|
|
1294
|
+
"animation-duration",
|
|
1295
|
+
"animation-timing-function",
|
|
1296
|
+
"animation-delay",
|
|
1297
|
+
"animation-iteration-count",
|
|
1298
|
+
"animation-direction",
|
|
1299
|
+
"animation-fill-mode",
|
|
1300
|
+
"animation-play-state",
|
|
1301
|
+
"animation-name",
|
|
1302
|
+
"animation-timeline",
|
|
1303
|
+
"animation-range-start",
|
|
1304
|
+
"animation-range-end"
|
|
1305
|
+
],
|
|
1306
|
+
"animation-range": ["animation-range-start", "animation-range-end"],
|
|
1307
|
+
"background": [
|
|
1308
|
+
"background-image",
|
|
1309
|
+
"background-position-x",
|
|
1310
|
+
"background-position-y",
|
|
1311
|
+
"background-size",
|
|
1312
|
+
"background-repeat",
|
|
1313
|
+
"background-attachment",
|
|
1314
|
+
"background-origin",
|
|
1315
|
+
"background-clip",
|
|
1316
|
+
"background-color"
|
|
1317
|
+
],
|
|
1318
|
+
"background-position": ["background-position-x", "background-position-y"],
|
|
1319
|
+
"border": [
|
|
1320
|
+
"border-top-color",
|
|
1321
|
+
"border-top-style",
|
|
1322
|
+
"border-top-width",
|
|
1323
|
+
"border-right-color",
|
|
1324
|
+
"border-right-style",
|
|
1325
|
+
"border-right-width",
|
|
1326
|
+
"border-bottom-color",
|
|
1327
|
+
"border-bottom-style",
|
|
1328
|
+
"border-bottom-width",
|
|
1329
|
+
"border-left-color",
|
|
1330
|
+
"border-left-style",
|
|
1331
|
+
"border-left-width",
|
|
1332
|
+
"border-image-source",
|
|
1333
|
+
"border-image-slice",
|
|
1334
|
+
"border-image-width",
|
|
1335
|
+
"border-image-outset",
|
|
1336
|
+
"border-image-repeat"
|
|
1337
|
+
],
|
|
1338
|
+
"border-block": [
|
|
1339
|
+
"border-block-start-color",
|
|
1340
|
+
"border-block-start-style",
|
|
1341
|
+
"border-block-start-width",
|
|
1342
|
+
"border-block-end-color",
|
|
1343
|
+
"border-block-end-style",
|
|
1344
|
+
"border-block-end-width"
|
|
1345
|
+
],
|
|
1346
|
+
"border-block-color": ["border-block-start-color", "border-block-end-color"],
|
|
1347
|
+
"border-block-end": [
|
|
1348
|
+
"border-block-end-width",
|
|
1349
|
+
"border-block-end-style",
|
|
1350
|
+
"border-block-end-color"
|
|
1351
|
+
],
|
|
1352
|
+
"border-block-start": [
|
|
1353
|
+
"border-block-start-width",
|
|
1354
|
+
"border-block-start-style",
|
|
1355
|
+
"border-block-start-color"
|
|
1356
|
+
],
|
|
1357
|
+
"border-block-style": ["border-block-start-style", "border-block-end-style"],
|
|
1358
|
+
"border-block-width": ["border-block-start-width", "border-block-end-width"],
|
|
1359
|
+
"border-bottom": [
|
|
1360
|
+
"border-bottom-width",
|
|
1361
|
+
"border-bottom-style",
|
|
1362
|
+
"border-bottom-color"
|
|
1363
|
+
],
|
|
1364
|
+
"border-color": [
|
|
1365
|
+
"border-top-color",
|
|
1366
|
+
"border-right-color",
|
|
1367
|
+
"border-bottom-color",
|
|
1368
|
+
"border-left-color"
|
|
1369
|
+
],
|
|
1370
|
+
"border-image": [
|
|
1371
|
+
"border-image-source",
|
|
1372
|
+
"border-image-slice",
|
|
1373
|
+
"border-image-width",
|
|
1374
|
+
"border-image-outset",
|
|
1375
|
+
"border-image-repeat"
|
|
1376
|
+
],
|
|
1377
|
+
"border-inline": [
|
|
1378
|
+
"border-inline-start-color",
|
|
1379
|
+
"border-inline-start-style",
|
|
1380
|
+
"border-inline-start-width",
|
|
1381
|
+
"border-inline-end-color",
|
|
1382
|
+
"border-inline-end-style",
|
|
1383
|
+
"border-inline-end-width"
|
|
1384
|
+
],
|
|
1385
|
+
"border-inline-color": ["border-inline-start-color", "border-inline-end-color"],
|
|
1386
|
+
"border-inline-end": [
|
|
1387
|
+
"border-inline-end-width",
|
|
1388
|
+
"border-inline-end-style",
|
|
1389
|
+
"border-inline-end-color"
|
|
1390
|
+
],
|
|
1391
|
+
"border-inline-start": [
|
|
1392
|
+
"border-inline-start-width",
|
|
1393
|
+
"border-inline-start-style",
|
|
1394
|
+
"border-inline-start-color"
|
|
1395
|
+
],
|
|
1396
|
+
"border-inline-style": ["border-inline-start-style", "border-inline-end-style"],
|
|
1397
|
+
"border-inline-width": ["border-inline-start-width", "border-inline-end-width"],
|
|
1398
|
+
"border-left": [
|
|
1399
|
+
"border-left-width",
|
|
1400
|
+
"border-left-style",
|
|
1401
|
+
"border-left-color"
|
|
1402
|
+
],
|
|
1403
|
+
"border-radius": [
|
|
1404
|
+
"border-top-left-radius",
|
|
1405
|
+
"border-top-right-radius",
|
|
1406
|
+
"border-bottom-right-radius",
|
|
1407
|
+
"border-bottom-left-radius"
|
|
1408
|
+
],
|
|
1409
|
+
"border-right": [
|
|
1410
|
+
"border-right-width",
|
|
1411
|
+
"border-right-style",
|
|
1412
|
+
"border-right-color"
|
|
1413
|
+
],
|
|
1414
|
+
"border-spacing": ["-webkit-border-horizontal-spacing", "-webkit-border-vertical-spacing"],
|
|
1415
|
+
"border-style": [
|
|
1416
|
+
"border-top-style",
|
|
1417
|
+
"border-right-style",
|
|
1418
|
+
"border-bottom-style",
|
|
1419
|
+
"border-left-style"
|
|
1420
|
+
],
|
|
1421
|
+
"border-top": [
|
|
1422
|
+
"border-top-width",
|
|
1423
|
+
"border-top-style",
|
|
1424
|
+
"border-top-color"
|
|
1425
|
+
],
|
|
1426
|
+
"border-width": [
|
|
1427
|
+
"border-top-width",
|
|
1428
|
+
"border-right-width",
|
|
1429
|
+
"border-bottom-width",
|
|
1430
|
+
"border-left-width"
|
|
1431
|
+
],
|
|
1432
|
+
"column-rule": [
|
|
1433
|
+
"column-rule-width",
|
|
1434
|
+
"column-rule-style",
|
|
1435
|
+
"column-rule-color"
|
|
1436
|
+
],
|
|
1437
|
+
"column-rule-inset": [
|
|
1438
|
+
"column-rule-inset-cap-start",
|
|
1439
|
+
"column-rule-inset-cap-end",
|
|
1440
|
+
"column-rule-inset-junction-start",
|
|
1441
|
+
"column-rule-inset-junction-end"
|
|
1442
|
+
],
|
|
1443
|
+
"column-rule-inset-cap": ["column-rule-inset-cap-start", "column-rule-inset-cap-end"],
|
|
1444
|
+
"column-rule-inset-end": ["column-rule-inset-cap-end", "column-rule-inset-junction-end"],
|
|
1445
|
+
"column-rule-inset-junction": ["column-rule-inset-junction-start", "column-rule-inset-junction-end"],
|
|
1446
|
+
"column-rule-inset-start": ["column-rule-inset-cap-start", "column-rule-inset-junction-start"],
|
|
1447
|
+
"columns": [
|
|
1448
|
+
"column-width",
|
|
1449
|
+
"column-count",
|
|
1450
|
+
"column-height",
|
|
1451
|
+
"column-wrap"
|
|
1452
|
+
],
|
|
1453
|
+
"contain-intrinsic-size": ["contain-intrinsic-width", "contain-intrinsic-height"],
|
|
1454
|
+
"container": ["container-name", "container-type"],
|
|
1455
|
+
"corner-block-end-shape": ["corner-end-start-shape", "corner-end-end-shape"],
|
|
1456
|
+
"corner-block-start-shape": ["corner-start-start-shape", "corner-start-end-shape"],
|
|
1457
|
+
"corner-bottom-shape": ["corner-bottom-left-shape", "corner-bottom-right-shape"],
|
|
1458
|
+
"corner-inline-end-shape": ["corner-start-end-shape", "corner-end-end-shape"],
|
|
1459
|
+
"corner-inline-start-shape": ["corner-start-start-shape", "corner-end-start-shape"],
|
|
1460
|
+
"corner-left-shape": ["corner-top-left-shape", "corner-bottom-left-shape"],
|
|
1461
|
+
"corner-right-shape": ["corner-top-right-shape", "corner-bottom-right-shape"],
|
|
1462
|
+
"corner-shape": [
|
|
1463
|
+
"corner-top-left-shape",
|
|
1464
|
+
"corner-top-right-shape",
|
|
1465
|
+
"corner-bottom-right-shape",
|
|
1466
|
+
"corner-bottom-left-shape"
|
|
1467
|
+
],
|
|
1468
|
+
"corner-top-shape": ["corner-top-left-shape", "corner-top-right-shape"],
|
|
1469
|
+
"flex": [
|
|
1470
|
+
"flex-grow",
|
|
1471
|
+
"flex-shrink",
|
|
1472
|
+
"flex-basis"
|
|
1473
|
+
],
|
|
1474
|
+
"flex-flow": ["flex-direction", "flex-wrap"],
|
|
1475
|
+
"font": [
|
|
1476
|
+
"font-style",
|
|
1477
|
+
"font-variant-ligatures",
|
|
1478
|
+
"font-variant-caps",
|
|
1479
|
+
"font-variant-numeric",
|
|
1480
|
+
"font-variant-east-asian",
|
|
1481
|
+
"font-variant-alternates",
|
|
1482
|
+
"font-variant-position",
|
|
1483
|
+
"font-variant-emoji",
|
|
1484
|
+
"font-weight",
|
|
1485
|
+
"font-stretch",
|
|
1486
|
+
"font-size",
|
|
1487
|
+
"line-height",
|
|
1488
|
+
"font-family",
|
|
1489
|
+
"font-optical-sizing",
|
|
1490
|
+
"font-size-adjust",
|
|
1491
|
+
"font-kerning",
|
|
1492
|
+
"font-feature-settings",
|
|
1493
|
+
"font-variation-settings",
|
|
1494
|
+
"font-language-override"
|
|
1495
|
+
],
|
|
1496
|
+
"font-synthesis": [
|
|
1497
|
+
"font-synthesis-weight",
|
|
1498
|
+
"font-synthesis-style",
|
|
1499
|
+
"font-synthesis-small-caps"
|
|
1500
|
+
],
|
|
1501
|
+
"font-variant": [
|
|
1502
|
+
"font-variant-ligatures",
|
|
1503
|
+
"font-variant-caps",
|
|
1504
|
+
"font-variant-alternates",
|
|
1505
|
+
"font-variant-numeric",
|
|
1506
|
+
"font-variant-east-asian",
|
|
1507
|
+
"font-variant-position",
|
|
1508
|
+
"font-variant-emoji"
|
|
1509
|
+
],
|
|
1510
|
+
"gap": ["row-gap", "column-gap"],
|
|
1511
|
+
"grid": [
|
|
1512
|
+
"grid-template-rows",
|
|
1513
|
+
"grid-template-columns",
|
|
1514
|
+
"grid-template-areas",
|
|
1515
|
+
"grid-auto-flow",
|
|
1516
|
+
"grid-auto-rows",
|
|
1517
|
+
"grid-auto-columns"
|
|
1518
|
+
],
|
|
1519
|
+
"grid-area": [
|
|
1520
|
+
"grid-row-start",
|
|
1521
|
+
"grid-column-start",
|
|
1522
|
+
"grid-row-end",
|
|
1523
|
+
"grid-column-end"
|
|
1524
|
+
],
|
|
1525
|
+
"grid-column": ["grid-column-start", "grid-column-end"],
|
|
1526
|
+
"grid-column-gap": ["column-gap"],
|
|
1527
|
+
"grid-gap": ["row-gap", "column-gap"],
|
|
1528
|
+
"grid-row": ["grid-row-start", "grid-row-end"],
|
|
1529
|
+
"grid-row-gap": ["row-gap"],
|
|
1530
|
+
"grid-template": [
|
|
1531
|
+
"grid-template-rows",
|
|
1532
|
+
"grid-template-columns",
|
|
1533
|
+
"grid-template-areas"
|
|
1534
|
+
],
|
|
1535
|
+
"inset": [
|
|
1536
|
+
"top",
|
|
1537
|
+
"right",
|
|
1538
|
+
"bottom",
|
|
1539
|
+
"left"
|
|
1540
|
+
],
|
|
1541
|
+
"inset-block": ["inset-block-start", "inset-block-end"],
|
|
1542
|
+
"inset-inline": ["inset-inline-start", "inset-inline-end"],
|
|
1543
|
+
"interest-delay": ["interest-delay-start", "interest-delay-end"],
|
|
1544
|
+
"list-style": [
|
|
1545
|
+
"list-style-position",
|
|
1546
|
+
"list-style-image",
|
|
1547
|
+
"list-style-type"
|
|
1548
|
+
],
|
|
1549
|
+
"margin": [
|
|
1550
|
+
"margin-top",
|
|
1551
|
+
"margin-right",
|
|
1552
|
+
"margin-bottom",
|
|
1553
|
+
"margin-left"
|
|
1554
|
+
],
|
|
1555
|
+
"margin-block": ["margin-block-start", "margin-block-end"],
|
|
1556
|
+
"margin-inline": ["margin-inline-start", "margin-inline-end"],
|
|
1557
|
+
"marker": [
|
|
1558
|
+
"marker-start",
|
|
1559
|
+
"marker-mid",
|
|
1560
|
+
"marker-end"
|
|
1561
|
+
],
|
|
1562
|
+
"mask": [
|
|
1563
|
+
"mask-image",
|
|
1564
|
+
"-webkit-mask-position-x",
|
|
1565
|
+
"-webkit-mask-position-y",
|
|
1566
|
+
"mask-size",
|
|
1567
|
+
"mask-repeat",
|
|
1568
|
+
"mask-origin",
|
|
1569
|
+
"mask-clip",
|
|
1570
|
+
"mask-composite",
|
|
1571
|
+
"mask-mode"
|
|
1572
|
+
],
|
|
1573
|
+
"mask-position": ["-webkit-mask-position-x", "-webkit-mask-position-y"],
|
|
1574
|
+
"offset": [
|
|
1575
|
+
"offset-position",
|
|
1576
|
+
"offset-path",
|
|
1577
|
+
"offset-distance",
|
|
1578
|
+
"offset-rotate",
|
|
1579
|
+
"offset-anchor"
|
|
1580
|
+
],
|
|
1581
|
+
"outline": [
|
|
1582
|
+
"outline-color",
|
|
1583
|
+
"outline-style",
|
|
1584
|
+
"outline-width"
|
|
1585
|
+
],
|
|
1586
|
+
"overflow": ["overflow-x", "overflow-y"],
|
|
1587
|
+
"overscroll-behavior": ["overscroll-behavior-x", "overscroll-behavior-y"],
|
|
1588
|
+
"padding": [
|
|
1589
|
+
"padding-top",
|
|
1590
|
+
"padding-right",
|
|
1591
|
+
"padding-bottom",
|
|
1592
|
+
"padding-left"
|
|
1593
|
+
],
|
|
1594
|
+
"padding-block": ["padding-block-start", "padding-block-end"],
|
|
1595
|
+
"padding-inline": ["padding-inline-start", "padding-inline-end"],
|
|
1596
|
+
"page-break-after": ["break-after"],
|
|
1597
|
+
"page-break-before": ["break-before"],
|
|
1598
|
+
"page-break-inside": ["break-inside"],
|
|
1599
|
+
"place-content": ["align-content", "justify-content"],
|
|
1600
|
+
"place-items": ["align-items", "justify-items"],
|
|
1601
|
+
"place-self": ["align-self", "justify-self"],
|
|
1602
|
+
"position-try": ["position-try-order", "position-try-fallbacks"],
|
|
1603
|
+
"row-rule": [
|
|
1604
|
+
"row-rule-width",
|
|
1605
|
+
"row-rule-style",
|
|
1606
|
+
"row-rule-color"
|
|
1607
|
+
],
|
|
1608
|
+
"row-rule-inset": [
|
|
1609
|
+
"row-rule-inset-cap-start",
|
|
1610
|
+
"row-rule-inset-cap-end",
|
|
1611
|
+
"row-rule-inset-junction-start",
|
|
1612
|
+
"row-rule-inset-junction-end"
|
|
1613
|
+
],
|
|
1614
|
+
"row-rule-inset-cap": ["row-rule-inset-cap-start", "row-rule-inset-cap-end"],
|
|
1615
|
+
"row-rule-inset-end": ["row-rule-inset-cap-end", "row-rule-inset-junction-end"],
|
|
1616
|
+
"row-rule-inset-junction": ["row-rule-inset-junction-start", "row-rule-inset-junction-end"],
|
|
1617
|
+
"row-rule-inset-start": ["row-rule-inset-cap-start", "row-rule-inset-junction-start"],
|
|
1618
|
+
"rule": [
|
|
1619
|
+
"column-rule-width",
|
|
1620
|
+
"column-rule-style",
|
|
1621
|
+
"column-rule-color",
|
|
1622
|
+
"row-rule-width",
|
|
1623
|
+
"row-rule-style",
|
|
1624
|
+
"row-rule-color"
|
|
1625
|
+
],
|
|
1626
|
+
"rule-break": ["row-rule-break", "column-rule-break"],
|
|
1627
|
+
"rule-color": ["column-rule-color", "row-rule-color"],
|
|
1628
|
+
"rule-inset": [
|
|
1629
|
+
"row-rule-inset-cap-start",
|
|
1630
|
+
"row-rule-inset-cap-end",
|
|
1631
|
+
"row-rule-inset-junction-start",
|
|
1632
|
+
"row-rule-inset-junction-end",
|
|
1633
|
+
"column-rule-inset-cap-start",
|
|
1634
|
+
"column-rule-inset-cap-end",
|
|
1635
|
+
"column-rule-inset-junction-start",
|
|
1636
|
+
"column-rule-inset-junction-end"
|
|
1637
|
+
],
|
|
1638
|
+
"rule-inset-cap": [
|
|
1639
|
+
"row-rule-inset-cap-start",
|
|
1640
|
+
"row-rule-inset-cap-end",
|
|
1641
|
+
"column-rule-inset-cap-start",
|
|
1642
|
+
"column-rule-inset-cap-end"
|
|
1643
|
+
],
|
|
1644
|
+
"rule-inset-end": [
|
|
1645
|
+
"column-rule-inset-cap-end",
|
|
1646
|
+
"column-rule-inset-junction-end",
|
|
1647
|
+
"row-rule-inset-cap-end",
|
|
1648
|
+
"row-rule-inset-junction-end"
|
|
1649
|
+
],
|
|
1650
|
+
"rule-inset-junction": [
|
|
1651
|
+
"row-rule-inset-junction-start",
|
|
1652
|
+
"row-rule-inset-junction-end",
|
|
1653
|
+
"column-rule-inset-junction-start",
|
|
1654
|
+
"column-rule-inset-junction-end"
|
|
1655
|
+
],
|
|
1656
|
+
"rule-inset-start": [
|
|
1657
|
+
"column-rule-inset-cap-start",
|
|
1658
|
+
"column-rule-inset-junction-start",
|
|
1659
|
+
"row-rule-inset-cap-start",
|
|
1660
|
+
"row-rule-inset-junction-start"
|
|
1661
|
+
],
|
|
1662
|
+
"rule-style": ["column-rule-style", "row-rule-style"],
|
|
1663
|
+
"rule-visibility-items": ["column-rule-visibility-items", "row-rule-visibility-items"],
|
|
1664
|
+
"rule-width": ["column-rule-width", "row-rule-width"],
|
|
1665
|
+
"scroll-margin": [
|
|
1666
|
+
"scroll-margin-top",
|
|
1667
|
+
"scroll-margin-right",
|
|
1668
|
+
"scroll-margin-bottom",
|
|
1669
|
+
"scroll-margin-left"
|
|
1670
|
+
],
|
|
1671
|
+
"scroll-margin-block": ["scroll-margin-block-start", "scroll-margin-block-end"],
|
|
1672
|
+
"scroll-margin-inline": ["scroll-margin-inline-start", "scroll-margin-inline-end"],
|
|
1673
|
+
"scroll-padding": [
|
|
1674
|
+
"scroll-padding-top",
|
|
1675
|
+
"scroll-padding-right",
|
|
1676
|
+
"scroll-padding-bottom",
|
|
1677
|
+
"scroll-padding-left"
|
|
1678
|
+
],
|
|
1679
|
+
"scroll-padding-block": ["scroll-padding-block-start", "scroll-padding-block-end"],
|
|
1680
|
+
"scroll-padding-inline": ["scroll-padding-inline-start", "scroll-padding-inline-end"],
|
|
1681
|
+
"scroll-timeline": ["scroll-timeline-name", "scroll-timeline-axis"],
|
|
1682
|
+
"text-box": ["text-box-trim", "text-box-edge"],
|
|
1683
|
+
"text-decoration": [
|
|
1684
|
+
"text-decoration-line",
|
|
1685
|
+
"text-decoration-thickness",
|
|
1686
|
+
"text-decoration-style",
|
|
1687
|
+
"text-decoration-color"
|
|
1688
|
+
],
|
|
1689
|
+
"text-emphasis": ["text-emphasis-style", "text-emphasis-color"],
|
|
1690
|
+
"text-wrap": ["text-wrap-mode", "text-wrap-style"],
|
|
1691
|
+
"timeline-trigger": [
|
|
1692
|
+
"timeline-trigger-name",
|
|
1693
|
+
"timeline-trigger-source",
|
|
1694
|
+
"timeline-trigger-activation-range-start",
|
|
1695
|
+
"timeline-trigger-activation-range-end",
|
|
1696
|
+
"timeline-trigger-active-range-start",
|
|
1697
|
+
"timeline-trigger-active-range-end"
|
|
1698
|
+
],
|
|
1699
|
+
"timeline-trigger-activation-range": ["timeline-trigger-activation-range-start", "timeline-trigger-activation-range-end"],
|
|
1700
|
+
"timeline-trigger-active-range": ["timeline-trigger-active-range-start", "timeline-trigger-active-range-end"],
|
|
1701
|
+
"transition": [
|
|
1702
|
+
"transition-property",
|
|
1703
|
+
"transition-duration",
|
|
1704
|
+
"transition-timing-function",
|
|
1705
|
+
"transition-delay",
|
|
1706
|
+
"transition-behavior"
|
|
1707
|
+
],
|
|
1708
|
+
"view-timeline": [
|
|
1709
|
+
"view-timeline-name",
|
|
1710
|
+
"view-timeline-axis",
|
|
1711
|
+
"view-timeline-inset"
|
|
1712
|
+
],
|
|
1713
|
+
"white-space": ["white-space-collapse", "text-wrap-mode"],
|
|
1714
|
+
"word-wrap": ["overflow-wrap"]
|
|
1715
|
+
};
|
|
1716
|
+
//#endregion
|
|
1717
|
+
//#region src/internal/shorthand-registry.ts
|
|
1718
|
+
const fourSideShorthandNames = /* @__PURE__ */ new Set([
|
|
1719
|
+
"padding",
|
|
1720
|
+
"margin",
|
|
1721
|
+
"inset",
|
|
1722
|
+
"border-width",
|
|
1723
|
+
"border-style",
|
|
1724
|
+
"border-color",
|
|
1725
|
+
"scroll-margin",
|
|
1726
|
+
"scroll-padding"
|
|
1727
|
+
]);
|
|
1728
|
+
function isFourSideShorthand(name) {
|
|
1729
|
+
return fourSideShorthandNames.has(name);
|
|
1730
|
+
}
|
|
1731
|
+
function getShorthandLonghands(name) {
|
|
1732
|
+
if (!Object.hasOwn(chromiumShorthandLonghands, name)) return null;
|
|
1733
|
+
return chromiumShorthandLonghands[name] ?? null;
|
|
1734
|
+
}
|
|
1735
|
+
function splitTopLevelWhitespace(value) {
|
|
1736
|
+
const components = [];
|
|
1737
|
+
let current = "";
|
|
1738
|
+
let depth = 0;
|
|
1739
|
+
let quote = "";
|
|
1740
|
+
let escaped = false;
|
|
1741
|
+
for (const character of value) {
|
|
1742
|
+
if (escaped) {
|
|
1743
|
+
current += character;
|
|
1744
|
+
escaped = false;
|
|
1745
|
+
continue;
|
|
1746
|
+
}
|
|
1747
|
+
if (character === "\\") {
|
|
1748
|
+
current += character;
|
|
1749
|
+
escaped = true;
|
|
1750
|
+
continue;
|
|
1751
|
+
}
|
|
1752
|
+
if (quote !== "") {
|
|
1753
|
+
current += character;
|
|
1754
|
+
if (character === quote) quote = "";
|
|
1755
|
+
continue;
|
|
1756
|
+
}
|
|
1757
|
+
if (character === "\"" || character === "'") {
|
|
1758
|
+
current += character;
|
|
1759
|
+
quote = character;
|
|
1760
|
+
continue;
|
|
1761
|
+
}
|
|
1762
|
+
if (character === "(" || character === "[" || character === "{") {
|
|
1763
|
+
current += character;
|
|
1764
|
+
depth += 1;
|
|
1765
|
+
continue;
|
|
1766
|
+
}
|
|
1767
|
+
if (character === ")" || character === "]" || character === "}") {
|
|
1768
|
+
current += character;
|
|
1769
|
+
if (depth > 0) depth -= 1;
|
|
1770
|
+
continue;
|
|
1771
|
+
}
|
|
1772
|
+
if (/\s/.test(character) && depth === 0) {
|
|
1773
|
+
if (current !== "") components.push(current);
|
|
1774
|
+
current = "";
|
|
1775
|
+
continue;
|
|
1776
|
+
}
|
|
1777
|
+
current += character;
|
|
1778
|
+
}
|
|
1779
|
+
if (current !== "") components.push(current);
|
|
1780
|
+
return components;
|
|
1781
|
+
}
|
|
1782
|
+
function expandFourSides(value) {
|
|
1783
|
+
const components = splitTopLevelWhitespace(value);
|
|
1784
|
+
if (components.length < 1 || components.length > 4) return null;
|
|
1785
|
+
const top = components[0];
|
|
1786
|
+
if (top === void 0) return null;
|
|
1787
|
+
const right = components[1] ?? top;
|
|
1788
|
+
return [
|
|
1789
|
+
top,
|
|
1790
|
+
right,
|
|
1791
|
+
components[2] ?? top,
|
|
1792
|
+
components[3] ?? right
|
|
1793
|
+
];
|
|
1794
|
+
}
|
|
1795
|
+
function expandStaticFourSide(name, parsed, important) {
|
|
1796
|
+
if (!fourSideShorthandNames.has(name)) return null;
|
|
1797
|
+
const longhands = getShorthandLonghands(name);
|
|
1798
|
+
if (!longhands || longhands.length !== 4) return null;
|
|
1799
|
+
const observableSides = expandFourSides(parsed.observableValue);
|
|
1800
|
+
const safeSides = expandFourSides(parsed.safeValue);
|
|
1801
|
+
if (!observableSides || !safeSides) return null;
|
|
1802
|
+
const records = [];
|
|
1803
|
+
for (let index = 0; index < longhands.length; index += 1) {
|
|
1804
|
+
const longhand = longhands[index];
|
|
1805
|
+
const observableValue = observableSides[index];
|
|
1806
|
+
const safeValue = safeSides[index];
|
|
1807
|
+
if (!longhand || observableValue === void 0 || safeValue === void 0) return null;
|
|
1808
|
+
records.push({
|
|
1809
|
+
name: longhand,
|
|
1810
|
+
observableValue,
|
|
1811
|
+
safeValue,
|
|
1812
|
+
pendingSubstitution: false,
|
|
1813
|
+
important,
|
|
1814
|
+
pendingGroup: null
|
|
1815
|
+
});
|
|
1816
|
+
}
|
|
1817
|
+
return records;
|
|
1818
|
+
}
|
|
1819
|
+
function expandStaticShorthand(name, parsed, important) {
|
|
1820
|
+
const longhands = getShorthandLonghands(name);
|
|
1821
|
+
if (!longhands || longhands.length === 0 || parsed.pendingSubstitution) return null;
|
|
1822
|
+
const observableStyle = new cssstyle.CSSStyleDeclaration();
|
|
1823
|
+
const safeStyle = new cssstyle.CSSStyleDeclaration();
|
|
1824
|
+
observableStyle.setProperty(name, parsed.observableValue);
|
|
1825
|
+
safeStyle.setProperty(name, parsed.safeValue);
|
|
1826
|
+
const fallbackValues = name === "border" ? {
|
|
1827
|
+
"border-image-source": "none",
|
|
1828
|
+
"border-image-slice": "100%",
|
|
1829
|
+
"border-image-width": "1",
|
|
1830
|
+
"border-image-outset": "0",
|
|
1831
|
+
"border-image-repeat": "stretch"
|
|
1832
|
+
} : {};
|
|
1833
|
+
const orderedLonghands = name === "border" ? [
|
|
1834
|
+
"border-top-width",
|
|
1835
|
+
"border-right-width",
|
|
1836
|
+
"border-bottom-width",
|
|
1837
|
+
"border-left-width",
|
|
1838
|
+
"border-top-style",
|
|
1839
|
+
"border-right-style",
|
|
1840
|
+
"border-bottom-style",
|
|
1841
|
+
"border-left-style",
|
|
1842
|
+
"border-top-color",
|
|
1843
|
+
"border-right-color",
|
|
1844
|
+
"border-bottom-color",
|
|
1845
|
+
"border-left-color",
|
|
1846
|
+
"border-image-source",
|
|
1847
|
+
"border-image-slice",
|
|
1848
|
+
"border-image-width",
|
|
1849
|
+
"border-image-outset",
|
|
1850
|
+
"border-image-repeat"
|
|
1851
|
+
] : longhands;
|
|
1852
|
+
const pendingGroup = {
|
|
1853
|
+
shorthand: name,
|
|
1854
|
+
observableValue: parsed.observableValue,
|
|
1855
|
+
safeValue: parsed.safeValue
|
|
1856
|
+
};
|
|
1857
|
+
const records = [];
|
|
1858
|
+
for (const longhand of orderedLonghands) {
|
|
1859
|
+
if (!longhands.includes(longhand)) return null;
|
|
1860
|
+
const observableValue = observableStyle.getPropertyValue(longhand) || fallbackValues[longhand] || "";
|
|
1861
|
+
const safeValue = safeStyle.getPropertyValue(longhand) || fallbackValues[longhand] || "";
|
|
1862
|
+
if (observableValue === "" || safeValue === "") return null;
|
|
1863
|
+
records.push({
|
|
1864
|
+
name: longhand,
|
|
1865
|
+
observableValue,
|
|
1866
|
+
safeValue,
|
|
1867
|
+
pendingSubstitution: false,
|
|
1868
|
+
important,
|
|
1869
|
+
pendingGroup
|
|
1870
|
+
});
|
|
1871
|
+
}
|
|
1872
|
+
return records;
|
|
1873
|
+
}
|
|
1874
|
+
//#endregion
|
|
1875
|
+
//#region src/internal/value-gate.ts
|
|
1876
|
+
const encoder$1 = new TextEncoder();
|
|
1877
|
+
const decoder$1 = new TextDecoder();
|
|
1878
|
+
const zeroLengthProperties = /* @__PURE__ */ new Set([
|
|
1879
|
+
"width",
|
|
1880
|
+
"height",
|
|
1881
|
+
"min-width",
|
|
1882
|
+
"min-height",
|
|
1883
|
+
"max-width",
|
|
1884
|
+
"max-height",
|
|
1885
|
+
"padding",
|
|
1886
|
+
...[
|
|
1887
|
+
"padding-top",
|
|
1888
|
+
"padding-right",
|
|
1889
|
+
"padding-bottom",
|
|
1890
|
+
"padding-left"
|
|
1891
|
+
]
|
|
1892
|
+
]);
|
|
1893
|
+
for (const shorthand of [
|
|
1894
|
+
"padding",
|
|
1895
|
+
"margin",
|
|
1896
|
+
"inset",
|
|
1897
|
+
"border-width",
|
|
1898
|
+
"scroll-margin",
|
|
1899
|
+
"scroll-padding"
|
|
1900
|
+
]) {
|
|
1901
|
+
zeroLengthProperties.add(shorthand);
|
|
1902
|
+
for (const longhand of chromiumShorthandLonghands[shorthand] ?? []) zeroLengthProperties.add(longhand);
|
|
1903
|
+
}
|
|
1904
|
+
function isUnknownRecord(value) {
|
|
1905
|
+
return typeof value === "object" && value !== null;
|
|
1906
|
+
}
|
|
1907
|
+
function isToken(value, type, tokenValue) {
|
|
1908
|
+
if (!isUnknownRecord(value) || value.type !== "token") return false;
|
|
1909
|
+
const token = value.value;
|
|
1910
|
+
if (!isUnknownRecord(token) || token.type !== type) return false;
|
|
1911
|
+
return tokenValue === void 0 || token.value === tokenValue;
|
|
1912
|
+
}
|
|
1913
|
+
function isWhitespaceToken(value) {
|
|
1914
|
+
return isToken(value, "white-space");
|
|
1915
|
+
}
|
|
1916
|
+
function significantTokens(values) {
|
|
1917
|
+
return values.filter((value) => !isWhitespaceToken(value));
|
|
1918
|
+
}
|
|
1919
|
+
function functionValue(value) {
|
|
1920
|
+
if (!isUnknownRecord(value) || value.type !== "function") return null;
|
|
1921
|
+
const details = value.value;
|
|
1922
|
+
if (!isUnknownRecord(details) || typeof details.name !== "string") return null;
|
|
1923
|
+
if (!Array.isArray(details.arguments)) return null;
|
|
1924
|
+
return {
|
|
1925
|
+
name: details.name.toLowerCase(),
|
|
1926
|
+
arguments: details.arguments
|
|
1927
|
+
};
|
|
1928
|
+
}
|
|
1929
|
+
function isValidAttrType(value) {
|
|
1930
|
+
const typeFunction = functionValue(value);
|
|
1931
|
+
if (!typeFunction || typeFunction.name !== "type") return false;
|
|
1932
|
+
const tokens = significantTokens(typeFunction.arguments);
|
|
1933
|
+
if (tokens.length === 1 && isToken(tokens[0], "delim", "*")) return true;
|
|
1934
|
+
if (tokens.length < 3) return false;
|
|
1935
|
+
if (!isToken(tokens[0], "delim", "<")) return false;
|
|
1936
|
+
if (!isToken(tokens[tokens.length - 1], "delim", ">")) return false;
|
|
1937
|
+
let depth = 0;
|
|
1938
|
+
for (const token of tokens) {
|
|
1939
|
+
if (isToken(token, "delim", "<")) depth += 1;
|
|
1940
|
+
if (!isToken(token, "delim", ">")) continue;
|
|
1941
|
+
depth -= 1;
|
|
1942
|
+
if (depth < 0) return false;
|
|
1943
|
+
}
|
|
1944
|
+
return depth === 0;
|
|
1945
|
+
}
|
|
1946
|
+
function isValidAttrFunction(argumentsList) {
|
|
1947
|
+
const tokens = significantTokens(argumentsList);
|
|
1948
|
+
if (!isToken(tokens[0], "ident")) return false;
|
|
1949
|
+
if (tokens.length === 1) return true;
|
|
1950
|
+
let index = 1;
|
|
1951
|
+
const second = tokens[index];
|
|
1952
|
+
if (isToken(second, "comma")) return true;
|
|
1953
|
+
if (isValidAttrType(second)) index += 1;
|
|
1954
|
+
else if (isToken(second, "ident") || isToken(second, "delim", "%")) index += 1;
|
|
1955
|
+
else return false;
|
|
1956
|
+
if (index === tokens.length) return true;
|
|
1957
|
+
return isToken(tokens[index], "comma");
|
|
1958
|
+
}
|
|
1959
|
+
function isConditionFunction(value) {
|
|
1960
|
+
const condition = functionValue(value);
|
|
1961
|
+
if (!condition || ![
|
|
1962
|
+
"media",
|
|
1963
|
+
"style",
|
|
1964
|
+
"supports"
|
|
1965
|
+
].includes(condition.name)) return false;
|
|
1966
|
+
return significantTokens(condition.arguments).length > 0;
|
|
1967
|
+
}
|
|
1968
|
+
function isElseToken(value) {
|
|
1969
|
+
return isToken(value, "ident", "else");
|
|
1970
|
+
}
|
|
1971
|
+
function isValidIfFunction(argumentsList) {
|
|
1972
|
+
const tokens = significantTokens(argumentsList);
|
|
1973
|
+
const branches = [[]];
|
|
1974
|
+
for (const token of tokens) {
|
|
1975
|
+
if (isToken(token, "semicolon")) {
|
|
1976
|
+
branches.push([]);
|
|
1977
|
+
continue;
|
|
1978
|
+
}
|
|
1979
|
+
branches[branches.length - 1]?.push(token);
|
|
1980
|
+
}
|
|
1981
|
+
if (branches.length === 0 || branches.some((branch) => branch.length === 0)) return false;
|
|
1982
|
+
let hasCondition = false;
|
|
1983
|
+
for (let index = 0; index < branches.length; index += 1) {
|
|
1984
|
+
const branch = branches[index];
|
|
1985
|
+
if (!branch) return false;
|
|
1986
|
+
const colonIndex = branch.findIndex((token) => isToken(token, "colon"));
|
|
1987
|
+
if (colonIndex <= 0 || colonIndex === branch.length - 1) return false;
|
|
1988
|
+
const condition = branch.slice(0, colonIndex);
|
|
1989
|
+
if (condition.length === 1 && isElseToken(condition[0])) {
|
|
1990
|
+
if (index !== branches.length - 1) return false;
|
|
1991
|
+
continue;
|
|
1992
|
+
}
|
|
1993
|
+
if (!condition.some(isConditionFunction)) return false;
|
|
1994
|
+
hasCondition = true;
|
|
1995
|
+
}
|
|
1996
|
+
return hasCondition;
|
|
1997
|
+
}
|
|
1998
|
+
function analyzeSubstitutions(value) {
|
|
1999
|
+
if (Array.isArray(value)) {
|
|
2000
|
+
let found = false;
|
|
2001
|
+
for (const item of value) {
|
|
2002
|
+
const result = analyzeSubstitutions(item);
|
|
2003
|
+
found ||= result.found;
|
|
2004
|
+
if (!result.valid) return {
|
|
2005
|
+
found,
|
|
2006
|
+
valid: false
|
|
2007
|
+
};
|
|
2008
|
+
}
|
|
2009
|
+
return {
|
|
2010
|
+
found,
|
|
2011
|
+
valid: true
|
|
2012
|
+
};
|
|
2013
|
+
}
|
|
2014
|
+
if (!isUnknownRecord(value)) return {
|
|
2015
|
+
found: false,
|
|
2016
|
+
valid: true
|
|
2017
|
+
};
|
|
2018
|
+
let found = value.type === "var" || value.type === "env";
|
|
2019
|
+
const cssFunction = functionValue(value);
|
|
2020
|
+
if (cssFunction?.name === "attr") {
|
|
2021
|
+
found = true;
|
|
2022
|
+
if (!isValidAttrFunction(cssFunction.arguments)) return {
|
|
2023
|
+
found,
|
|
2024
|
+
valid: false
|
|
2025
|
+
};
|
|
2026
|
+
}
|
|
2027
|
+
if (cssFunction?.name === "if") {
|
|
2028
|
+
found = true;
|
|
2029
|
+
if (!isValidIfFunction(cssFunction.arguments)) return {
|
|
2030
|
+
found,
|
|
2031
|
+
valid: false
|
|
2032
|
+
};
|
|
2033
|
+
}
|
|
2034
|
+
for (const key in value) {
|
|
2035
|
+
if (!Object.hasOwn(value, key)) continue;
|
|
2036
|
+
const result = analyzeSubstitutions(value[key]);
|
|
2037
|
+
found ||= result.found;
|
|
2038
|
+
if (!result.valid) return {
|
|
2039
|
+
found,
|
|
2040
|
+
valid: false
|
|
2041
|
+
};
|
|
2042
|
+
}
|
|
2043
|
+
return {
|
|
2044
|
+
found,
|
|
2045
|
+
valid: true
|
|
2046
|
+
};
|
|
2047
|
+
}
|
|
2048
|
+
function serializeIdentifier(value) {
|
|
2049
|
+
const characters = [...value];
|
|
2050
|
+
let result = "";
|
|
2051
|
+
for (let index = 0; index < characters.length; index += 1) {
|
|
2052
|
+
const character = characters[index];
|
|
2053
|
+
if (character === void 0) continue;
|
|
2054
|
+
const codePoint = character.codePointAt(0) ?? 0;
|
|
2055
|
+
if (codePoint === 0) {
|
|
2056
|
+
result += "�";
|
|
2057
|
+
continue;
|
|
2058
|
+
}
|
|
2059
|
+
if (codePoint >= 1 && codePoint <= 31 || codePoint === 127) {
|
|
2060
|
+
result += `\\${codePoint.toString(16)} `;
|
|
2061
|
+
continue;
|
|
2062
|
+
}
|
|
2063
|
+
if (codePoint >= 48 && codePoint <= 57 && (index === 0 || index === 1 && characters[0] === "-")) {
|
|
2064
|
+
result += `\\${codePoint.toString(16)} `;
|
|
2065
|
+
continue;
|
|
2066
|
+
}
|
|
2067
|
+
if (index === 0 && character === "-" && characters.length === 1) {
|
|
2068
|
+
result += "\\-";
|
|
2069
|
+
continue;
|
|
2070
|
+
}
|
|
2071
|
+
if (codePoint >= 128 || character === "-" || character === "_" || codePoint >= 48 && codePoint <= 57 || codePoint >= 65 && codePoint <= 90 || codePoint >= 97 && codePoint <= 122) {
|
|
2072
|
+
result += character;
|
|
2073
|
+
continue;
|
|
2074
|
+
}
|
|
2075
|
+
result += `\\${character}`;
|
|
2076
|
+
}
|
|
2077
|
+
return result;
|
|
2078
|
+
}
|
|
2079
|
+
function containsPriorityDelimiter(value) {
|
|
2080
|
+
let found = false;
|
|
2081
|
+
css_tree.tokenize(value, (type, start, end) => {
|
|
2082
|
+
if (css_tree.tokenNames[type] !== "delim-token") return;
|
|
2083
|
+
if (value.slice(start, end) === "!") found = true;
|
|
2084
|
+
});
|
|
2085
|
+
return found;
|
|
2086
|
+
}
|
|
2087
|
+
function canonicalizeLeadingDecimal(value) {
|
|
2088
|
+
const replacements = [];
|
|
2089
|
+
css_tree.tokenize(value, (type, start, end) => {
|
|
2090
|
+
const tokenName = css_tree.tokenNames[type];
|
|
2091
|
+
if (tokenName === void 0 || ![
|
|
2092
|
+
"number-token",
|
|
2093
|
+
"percentage-token",
|
|
2094
|
+
"dimension-token"
|
|
2095
|
+
].includes(tokenName)) return;
|
|
2096
|
+
const token = value.slice(start, end);
|
|
2097
|
+
const normalized = token.replace(/^([+-]?)\.(\d)/, "$10.$2");
|
|
2098
|
+
if (normalized !== token) replacements.push({
|
|
2099
|
+
start,
|
|
2100
|
+
end,
|
|
2101
|
+
value: normalized
|
|
2102
|
+
});
|
|
2103
|
+
});
|
|
2104
|
+
let result = value;
|
|
2105
|
+
for (let index = replacements.length - 1; index >= 0; index -= 1) {
|
|
2106
|
+
const replacement = replacements[index];
|
|
2107
|
+
if (!replacement) continue;
|
|
2108
|
+
result = `${result.slice(0, replacement.start)}${replacement.value}${result.slice(replacement.end)}`;
|
|
2109
|
+
}
|
|
2110
|
+
return result;
|
|
2111
|
+
}
|
|
2112
|
+
function parsePropertyValue(name, observableValue) {
|
|
2113
|
+
if (name === "--") return null;
|
|
2114
|
+
if (!name.startsWith("--") && !chromiumSupportedProperties.has(name)) return null;
|
|
2115
|
+
if (containsPriorityDelimiter(observableValue)) return null;
|
|
2116
|
+
let declaration;
|
|
2117
|
+
try {
|
|
2118
|
+
const result = (0, lightningcss.transformStyleAttribute)({
|
|
2119
|
+
code: encoder$1.encode(`${name.startsWith("--") ? serializeIdentifier(name) : name}: ${observableValue}`),
|
|
2120
|
+
visitor: { Declaration(candidate) {
|
|
2121
|
+
declaration = candidate;
|
|
2122
|
+
} }
|
|
2123
|
+
});
|
|
2124
|
+
if (!isUnknownRecord(declaration)) return null;
|
|
2125
|
+
if (!Object.hasOwn(declaration, "property")) return null;
|
|
2126
|
+
const pendingSubstitution = declaration.property === "unparsed";
|
|
2127
|
+
if (pendingSubstitution) {
|
|
2128
|
+
const analysis = analyzeSubstitutions(declaration);
|
|
2129
|
+
if (!analysis.found || !analysis.valid) return null;
|
|
2130
|
+
}
|
|
2131
|
+
const serialized = decoder$1.decode(result.code);
|
|
2132
|
+
const colonIndex = serialized.indexOf(":");
|
|
2133
|
+
if (colonIndex === -1) return null;
|
|
2134
|
+
const trimmedObservableValue = canonicalizeLeadingDecimal(observableValue.trim());
|
|
2135
|
+
return {
|
|
2136
|
+
observableValue: trimmedObservableValue === "0" && zeroLengthProperties.has(name) ? "0px" : trimmedObservableValue,
|
|
2137
|
+
safeValue: serialized.slice(colonIndex + 1).trim(),
|
|
2138
|
+
pendingSubstitution
|
|
2139
|
+
};
|
|
2140
|
+
} catch {
|
|
2141
|
+
return null;
|
|
2142
|
+
}
|
|
2143
|
+
}
|
|
2144
|
+
function parseAtruleDescriptorValue(atrule, name, observableValue) {
|
|
2145
|
+
if (containsPriorityDelimiter(observableValue)) return null;
|
|
2146
|
+
try {
|
|
2147
|
+
if (css_tree.lexer.matchAtruleDescriptor(atrule, name, observableValue).error) return null;
|
|
2148
|
+
const prelude = atrule === "counter-style" ? " sheetom" : "";
|
|
2149
|
+
const result = (0, lightningcss.transform)({
|
|
2150
|
+
filename: "sheetom-descriptor.css",
|
|
2151
|
+
code: encoder$1.encode(`@${atrule}${prelude} { ${name}: ${observableValue}; }`)
|
|
2152
|
+
});
|
|
2153
|
+
const serializedSheet = decoder$1.decode(result.code);
|
|
2154
|
+
const parsed = css_tree.parse(serializedSheet, { positions: true });
|
|
2155
|
+
if (parsed.type !== "StyleSheet") return null;
|
|
2156
|
+
const rule = parsed.children.first;
|
|
2157
|
+
if (rule?.type !== "Atrule" || !rule.block) return null;
|
|
2158
|
+
const declaration = rule.block.children.first;
|
|
2159
|
+
if (declaration?.type !== "Declaration") return null;
|
|
2160
|
+
const valueLocation = declaration.value.loc;
|
|
2161
|
+
const serializedValue = valueLocation ? serializedSheet.slice(valueLocation.start.offset, valueLocation.end.offset) : css_tree.generate(declaration.value);
|
|
2162
|
+
return {
|
|
2163
|
+
observableValue: serializedValue,
|
|
2164
|
+
safeValue: serializedValue,
|
|
2165
|
+
pendingSubstitution: false
|
|
2166
|
+
};
|
|
2167
|
+
} catch {
|
|
2168
|
+
return null;
|
|
2169
|
+
}
|
|
2170
|
+
}
|
|
2171
|
+
//#endregion
|
|
2172
|
+
//#region src/internal/webidl-construction.ts
|
|
2173
|
+
let internalConstructionDepth = 0;
|
|
2174
|
+
function constructInternally(factory) {
|
|
2175
|
+
internalConstructionDepth += 1;
|
|
2176
|
+
try {
|
|
2177
|
+
return factory();
|
|
2178
|
+
} finally {
|
|
2179
|
+
internalConstructionDepth -= 1;
|
|
2180
|
+
}
|
|
2181
|
+
}
|
|
2182
|
+
function assertInternalConstructor(name) {
|
|
2183
|
+
if (internalConstructionDepth > 0) return;
|
|
2184
|
+
throw new TypeError(`Failed to construct '${name}': Illegal constructor`);
|
|
2185
|
+
}
|
|
2186
|
+
//#endregion
|
|
2187
|
+
//#region src/index.ts
|
|
2188
|
+
const encoder = new TextEncoder();
|
|
2189
|
+
const decoder = new TextDecoder();
|
|
2190
|
+
const arrayIndexPattern = /^(0|[1-9]\d*)$/;
|
|
2191
|
+
const regularSheetMetadata = /* @__PURE__ */ new WeakMap();
|
|
2192
|
+
const ruleParentage = /* @__PURE__ */ new WeakMap();
|
|
2193
|
+
const unsignedLongRange = 2 ** 32;
|
|
2194
|
+
const pageMarginRuleNames = /* @__PURE__ */ new Set([
|
|
2195
|
+
"top-left-corner",
|
|
2196
|
+
"top-left",
|
|
2197
|
+
"top-center",
|
|
2198
|
+
"top-right",
|
|
2199
|
+
"top-right-corner",
|
|
2200
|
+
"right-top",
|
|
2201
|
+
"right-middle",
|
|
2202
|
+
"right-bottom",
|
|
2203
|
+
"bottom-right-corner",
|
|
2204
|
+
"bottom-right",
|
|
2205
|
+
"bottom-center",
|
|
2206
|
+
"bottom-left",
|
|
2207
|
+
"bottom-left-corner",
|
|
2208
|
+
"left-bottom",
|
|
2209
|
+
"left-middle",
|
|
2210
|
+
"left-top"
|
|
2211
|
+
]);
|
|
2212
|
+
const ignoreDiagnostic = () => {};
|
|
2213
|
+
const ruleDiagnostics = /* @__PURE__ */ new WeakMap();
|
|
2214
|
+
const ruleTree = new RuleTree((rule, parentRule, parentStyleSheet) => {
|
|
2215
|
+
ruleParentage.set(rule, {
|
|
2216
|
+
parentRule,
|
|
2217
|
+
parentStyleSheet
|
|
2218
|
+
});
|
|
2219
|
+
}, (rule) => rule.parentStyleSheet);
|
|
2220
|
+
const safeSerializer = new Serializer(describeRuleSafe);
|
|
2221
|
+
function parseDeclarationValue(declaration, name, observableValue) {
|
|
2222
|
+
const atrule = declaration.parentRule instanceof CSSFontFaceRule ? "font-face" : null;
|
|
2223
|
+
if (atrule) return parseAtruleDescriptorValue(atrule, name, observableValue);
|
|
2224
|
+
return parsePropertyValue(name, observableValue);
|
|
2225
|
+
}
|
|
2226
|
+
function namedPropertyToCSS(property) {
|
|
2227
|
+
if (property === "cssFloat") return "float";
|
|
2228
|
+
let cssName = property.replace(/[A-Z]/g, (character) => `-${character.toLowerCase()}`);
|
|
2229
|
+
if (/^(webkit|moz|ms|o)-/.test(cssName)) cssName = `-${cssName}`;
|
|
2230
|
+
return cssName;
|
|
2231
|
+
}
|
|
2232
|
+
function normalizeSelectorText(value) {
|
|
2233
|
+
let parsed;
|
|
2234
|
+
try {
|
|
2235
|
+
parsed = css_tree.parse(value, { context: "selectorList" });
|
|
2236
|
+
} catch {
|
|
2237
|
+
return null;
|
|
2238
|
+
}
|
|
2239
|
+
if (parsed.type !== "SelectorList" || parsed.children.isEmpty) return null;
|
|
2240
|
+
try {
|
|
2241
|
+
const generated = css_tree.generate(parsed);
|
|
2242
|
+
const result = (0, lightningcss.transform)({
|
|
2243
|
+
filename: "sheetom-selector.css",
|
|
2244
|
+
code: encoder.encode(`${generated} { --sheetom-probe: 0; }`)
|
|
2245
|
+
});
|
|
2246
|
+
const serialized = decoder.decode(result.code);
|
|
2247
|
+
const blockIndex = serialized.indexOf(" {");
|
|
2248
|
+
if (blockIndex === -1) return null;
|
|
2249
|
+
return serialized.slice(0, blockIndex);
|
|
2250
|
+
} catch {
|
|
2251
|
+
return null;
|
|
2252
|
+
}
|
|
2253
|
+
}
|
|
2254
|
+
function toUnsignedLong(value) {
|
|
2255
|
+
const number = Number(value);
|
|
2256
|
+
if (!Number.isFinite(number) || number === 0) return 0;
|
|
2257
|
+
return (Math.trunc(number) % unsignedLongRange + unsignedLongRange) % unsignedLongRange;
|
|
2258
|
+
}
|
|
2259
|
+
function requireArguments(actual, required, interfaceName, operation) {
|
|
2260
|
+
if (actual >= required) return;
|
|
2261
|
+
throw new TypeError(`Failed to execute '${operation}' on '${interfaceName}': ${required} ${required === 1 ? "argument" : "arguments"} required, but only ${actual} present.`);
|
|
2262
|
+
}
|
|
2263
|
+
function lockOwnProperties(target, ...properties) {
|
|
2264
|
+
for (const property of properties) {
|
|
2265
|
+
const descriptor = Object.getOwnPropertyDescriptor(target, property);
|
|
2266
|
+
if (!descriptor || !("value" in descriptor)) continue;
|
|
2267
|
+
Object.defineProperty(target, property, {
|
|
2268
|
+
...descriptor,
|
|
2269
|
+
writable: false
|
|
2270
|
+
});
|
|
2271
|
+
}
|
|
2272
|
+
}
|
|
2273
|
+
/** Base class for live stylesheet rules. */
|
|
2274
|
+
var CSSRule = class {
|
|
2275
|
+
static STYLE_RULE = 1;
|
|
2276
|
+
static CHARSET_RULE = 2;
|
|
2277
|
+
static IMPORT_RULE = 3;
|
|
2278
|
+
static MEDIA_RULE = 4;
|
|
2279
|
+
static FONT_FACE_RULE = 5;
|
|
2280
|
+
static PAGE_RULE = 6;
|
|
2281
|
+
static KEYFRAMES_RULE = 7;
|
|
2282
|
+
static KEYFRAME_RULE = 8;
|
|
2283
|
+
static MARGIN_RULE = 9;
|
|
2284
|
+
static NAMESPACE_RULE = 10;
|
|
2285
|
+
static COUNTER_STYLE_RULE = 11;
|
|
2286
|
+
static SUPPORTS_RULE = 12;
|
|
2287
|
+
static FONT_FEATURE_VALUES_RULE = 14;
|
|
2288
|
+
#type;
|
|
2289
|
+
constructor(type) {
|
|
2290
|
+
assertInternalConstructor(new.target.name);
|
|
2291
|
+
this.#type = type;
|
|
2292
|
+
ruleParentage.set(this, {
|
|
2293
|
+
parentRule: null,
|
|
2294
|
+
parentStyleSheet: null
|
|
2295
|
+
});
|
|
2296
|
+
}
|
|
2297
|
+
get parentRule() {
|
|
2298
|
+
return ruleParentage.get(this)?.parentRule ?? null;
|
|
2299
|
+
}
|
|
2300
|
+
get type() {
|
|
2301
|
+
return this.#type;
|
|
2302
|
+
}
|
|
2303
|
+
get parentStyleSheet() {
|
|
2304
|
+
return ruleParentage.get(this)?.parentStyleSheet ?? null;
|
|
2305
|
+
}
|
|
2306
|
+
get cssText() {
|
|
2307
|
+
return "";
|
|
2308
|
+
}
|
|
2309
|
+
set cssText(_value) {}
|
|
2310
|
+
};
|
|
2311
|
+
for (const [name, value] of Object.entries({
|
|
2312
|
+
STYLE_RULE: CSSRule.STYLE_RULE,
|
|
2313
|
+
CHARSET_RULE: CSSRule.CHARSET_RULE,
|
|
2314
|
+
IMPORT_RULE: CSSRule.IMPORT_RULE,
|
|
2315
|
+
MEDIA_RULE: CSSRule.MEDIA_RULE,
|
|
2316
|
+
FONT_FACE_RULE: CSSRule.FONT_FACE_RULE,
|
|
2317
|
+
PAGE_RULE: CSSRule.PAGE_RULE,
|
|
2318
|
+
KEYFRAMES_RULE: CSSRule.KEYFRAMES_RULE,
|
|
2319
|
+
KEYFRAME_RULE: CSSRule.KEYFRAME_RULE,
|
|
2320
|
+
MARGIN_RULE: CSSRule.MARGIN_RULE,
|
|
2321
|
+
NAMESPACE_RULE: CSSRule.NAMESPACE_RULE,
|
|
2322
|
+
COUNTER_STYLE_RULE: CSSRule.COUNTER_STYLE_RULE,
|
|
2323
|
+
SUPPORTS_RULE: CSSRule.SUPPORTS_RULE,
|
|
2324
|
+
FONT_FEATURE_VALUES_RULE: CSSRule.FONT_FEATURE_VALUES_RULE
|
|
2325
|
+
})) Object.defineProperty(CSSRule.prototype, name, {
|
|
2326
|
+
value,
|
|
2327
|
+
writable: false,
|
|
2328
|
+
enumerable: true,
|
|
2329
|
+
configurable: false
|
|
2330
|
+
});
|
|
2331
|
+
/** A stable, live, indexed collection of rules. */
|
|
2332
|
+
var CSSRuleList = class {
|
|
2333
|
+
#rules;
|
|
2334
|
+
/** @internal */
|
|
2335
|
+
constructor(rules) {
|
|
2336
|
+
assertInternalConstructor("CSSRuleList");
|
|
2337
|
+
this.#rules = rules;
|
|
2338
|
+
return new Proxy(this, {
|
|
2339
|
+
get(target, property) {
|
|
2340
|
+
if (typeof property !== "string" || !arrayIndexPattern.test(property)) {
|
|
2341
|
+
const result = Reflect.get(target, property, target);
|
|
2342
|
+
return typeof result === "function" ? result.bind(target) : result;
|
|
2343
|
+
}
|
|
2344
|
+
return target.#rules[Number(property)];
|
|
2345
|
+
},
|
|
2346
|
+
set(target, property, value) {
|
|
2347
|
+
if (typeof property === "string" && arrayIndexPattern.test(property)) return false;
|
|
2348
|
+
return Reflect.set(target, property, value, target);
|
|
2349
|
+
}
|
|
2350
|
+
});
|
|
2351
|
+
}
|
|
2352
|
+
get length() {
|
|
2353
|
+
return this.#rules.length;
|
|
2354
|
+
}
|
|
2355
|
+
item(index) {
|
|
2356
|
+
requireArguments(arguments.length, 1, "CSSRuleList", "item");
|
|
2357
|
+
return this.#rules[toUnsignedLong(index)] ?? null;
|
|
2358
|
+
}
|
|
2359
|
+
};
|
|
2360
|
+
function normalizeMediaText(value) {
|
|
2361
|
+
try {
|
|
2362
|
+
const result = (0, lightningcss.transform)({
|
|
2363
|
+
filename: "sheetom-media.css",
|
|
2364
|
+
code: encoder.encode(`@media ${value} { .sheetom-probe { --sheetom: 0; } }`)
|
|
2365
|
+
});
|
|
2366
|
+
const serialized = decoder.decode(result.code);
|
|
2367
|
+
const blockIndex = serialized.indexOf("{");
|
|
2368
|
+
if (!serialized.startsWith("@media ") || blockIndex === -1) return null;
|
|
2369
|
+
return serialized.slice(7, blockIndex).trim();
|
|
2370
|
+
} catch {
|
|
2371
|
+
return null;
|
|
2372
|
+
}
|
|
2373
|
+
}
|
|
2374
|
+
function normalizeConditionalPrelude(name, value) {
|
|
2375
|
+
try {
|
|
2376
|
+
const result = (0, lightningcss.transform)({
|
|
2377
|
+
filename: `sheetom-${name}.css`,
|
|
2378
|
+
code: encoder.encode(`@${name} ${value} { .sheetom-probe { --sheetom: 0; } }`)
|
|
2379
|
+
});
|
|
2380
|
+
const serialized = decoder.decode(result.code);
|
|
2381
|
+
const blockIndex = serialized.indexOf("{");
|
|
2382
|
+
const prefix = `@${name} `;
|
|
2383
|
+
if (!serialized.startsWith(prefix) || blockIndex === -1) return value;
|
|
2384
|
+
return serialized.slice(prefix.length, blockIndex).trim();
|
|
2385
|
+
} catch {
|
|
2386
|
+
return value;
|
|
2387
|
+
}
|
|
2388
|
+
}
|
|
2389
|
+
function splitMediaQueries(value) {
|
|
2390
|
+
const queries = [];
|
|
2391
|
+
let start = 0;
|
|
2392
|
+
let depth = 0;
|
|
2393
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
2394
|
+
const character = value[index];
|
|
2395
|
+
if (character === "(") depth += 1;
|
|
2396
|
+
if (character === ")" && depth > 0) depth -= 1;
|
|
2397
|
+
if (character !== "," || depth !== 0) continue;
|
|
2398
|
+
queries.push(value.slice(start, index).trim());
|
|
2399
|
+
start = index + 1;
|
|
2400
|
+
}
|
|
2401
|
+
queries.push(value.slice(start).trim());
|
|
2402
|
+
return queries.filter((query) => query !== "");
|
|
2403
|
+
}
|
|
2404
|
+
/** A live serialized list of media queries. */
|
|
2405
|
+
var MediaList = class {
|
|
2406
|
+
#mediaText;
|
|
2407
|
+
constructor(mediaText = "") {
|
|
2408
|
+
assertInternalConstructor("MediaList");
|
|
2409
|
+
const input = `${mediaText}`.trim();
|
|
2410
|
+
this.#mediaText = input === "" ? "" : normalizeMediaText(input) ?? "not all";
|
|
2411
|
+
return new Proxy(this, {
|
|
2412
|
+
get(target, property) {
|
|
2413
|
+
if (typeof property !== "string" || !arrayIndexPattern.test(property)) {
|
|
2414
|
+
const result = Reflect.get(target, property, target);
|
|
2415
|
+
return typeof result === "function" ? result.bind(target) : result;
|
|
2416
|
+
}
|
|
2417
|
+
return target.item(Number(property)) || void 0;
|
|
2418
|
+
},
|
|
2419
|
+
set(target, property, value) {
|
|
2420
|
+
if (typeof property === "string" && arrayIndexPattern.test(property)) return false;
|
|
2421
|
+
return Reflect.set(target, property, value, target);
|
|
2422
|
+
}
|
|
2423
|
+
});
|
|
2424
|
+
}
|
|
2425
|
+
get mediaText() {
|
|
2426
|
+
return this.#mediaText;
|
|
2427
|
+
}
|
|
2428
|
+
set mediaText(value) {
|
|
2429
|
+
const input = `${value}`.trim();
|
|
2430
|
+
if (input === "") {
|
|
2431
|
+
this.#mediaText = "";
|
|
2432
|
+
return;
|
|
2433
|
+
}
|
|
2434
|
+
const normalized = normalizeMediaText(input);
|
|
2435
|
+
this.#mediaText = normalized ?? "not all";
|
|
2436
|
+
}
|
|
2437
|
+
get length() {
|
|
2438
|
+
return splitMediaQueries(this.#mediaText).length;
|
|
2439
|
+
}
|
|
2440
|
+
item(index) {
|
|
2441
|
+
requireArguments(arguments.length, 1, "MediaList", "item");
|
|
2442
|
+
return splitMediaQueries(this.#mediaText)[toUnsignedLong(index)] ?? null;
|
|
2443
|
+
}
|
|
2444
|
+
appendMedium(medium) {
|
|
2445
|
+
requireArguments(arguments.length, 1, "MediaList", "appendMedium");
|
|
2446
|
+
const normalized = normalizeMediaText(`${medium}`);
|
|
2447
|
+
if (!normalized) return;
|
|
2448
|
+
const existing = splitMediaQueries(this.#mediaText);
|
|
2449
|
+
if (existing.includes(normalized)) return;
|
|
2450
|
+
this.#mediaText = [...existing, normalized].join(", ");
|
|
2451
|
+
}
|
|
2452
|
+
deleteMedium(medium) {
|
|
2453
|
+
requireArguments(arguments.length, 1, "MediaList", "deleteMedium");
|
|
2454
|
+
const normalized = normalizeMediaText(`${medium}`);
|
|
2455
|
+
const existing = splitMediaQueries(this.#mediaText);
|
|
2456
|
+
const index = normalized ? existing.indexOf(normalized) : -1;
|
|
2457
|
+
if (index === -1) throw new DOMException("The medium was not found.", "NotFoundError");
|
|
2458
|
+
existing.splice(index, 1);
|
|
2459
|
+
this.#mediaText = existing.join(", ");
|
|
2460
|
+
}
|
|
2461
|
+
};
|
|
2462
|
+
function indentRuleText(value) {
|
|
2463
|
+
return value.split("\n").map((line) => ` ${line}`).join("\n");
|
|
2464
|
+
}
|
|
2465
|
+
/** A rule containing a live nested rule list. */
|
|
2466
|
+
var CSSGroupingRule = class extends CSSRule {
|
|
2467
|
+
cssRules;
|
|
2468
|
+
constructor(type) {
|
|
2469
|
+
super(type);
|
|
2470
|
+
const rules = ruleTree.createChildren(this);
|
|
2471
|
+
this.cssRules = new CSSRuleList(rules);
|
|
2472
|
+
lockOwnProperties(this, "cssRules");
|
|
2473
|
+
}
|
|
2474
|
+
insertRule(ruleText, index = 0) {
|
|
2475
|
+
requireArguments(arguments.length, 1, this.constructor.name, "insertRule");
|
|
2476
|
+
const rules = ruleTree.children(this);
|
|
2477
|
+
const normalizedIndex = toUnsignedLong(index);
|
|
2478
|
+
if (normalizedIndex > rules.length) throw new DOMException("The index is outside the allowed range.", "IndexSizeError");
|
|
2479
|
+
const input = `${ruleText}`;
|
|
2480
|
+
if (!(this instanceof CSSPageRule) && parsedAtRuleName(input) === "import") throw new DOMException("@import rules cannot be inserted inside a group rule.", "HierarchyRequestError");
|
|
2481
|
+
const rule = parseStrictRule(input, ruleDiagnostics.get(this) ?? ignoreDiagnostic, false, this);
|
|
2482
|
+
if (!rule) throw new DOMException("The rule could not be parsed.", "SyntaxError");
|
|
2483
|
+
if (this instanceof CSSStyleRule && rule instanceof CSSStyleRule && !rule.selectorText.trimStart().startsWith("&")) rule.selectorText = `& ${rule.selectorText}`;
|
|
2484
|
+
rules.splice(normalizedIndex, 0, rule);
|
|
2485
|
+
attachRuleTree(rule, this, this.parentStyleSheet);
|
|
2486
|
+
return normalizedIndex;
|
|
2487
|
+
}
|
|
2488
|
+
deleteRule(index) {
|
|
2489
|
+
requireArguments(arguments.length, 1, this.constructor.name, "deleteRule");
|
|
2490
|
+
const rules = ruleTree.children(this);
|
|
2491
|
+
const normalizedIndex = toUnsignedLong(index);
|
|
2492
|
+
if (normalizedIndex >= rules.length) throw new DOMException("The index is outside the allowed range.", "IndexSizeError");
|
|
2493
|
+
const [removed] = rules.splice(normalizedIndex, 1);
|
|
2494
|
+
if (removed) attachRuleTree(removed, null, null);
|
|
2495
|
+
}
|
|
2496
|
+
serializeGroup(header) {
|
|
2497
|
+
const rules = ruleTree.children(this);
|
|
2498
|
+
if (rules.length === 0) return `${header} { }`;
|
|
2499
|
+
return `${header} {\n${rules.map((rule) => indentRuleText(rule.cssText)).join("\n")}\n}`;
|
|
2500
|
+
}
|
|
2501
|
+
};
|
|
2502
|
+
/** A grouping rule controlled by a serialized condition. */
|
|
2503
|
+
var CSSConditionRule = class extends CSSGroupingRule {
|
|
2504
|
+
#conditionText;
|
|
2505
|
+
constructor(type, conditionText) {
|
|
2506
|
+
super(type);
|
|
2507
|
+
this.#conditionText = conditionText;
|
|
2508
|
+
}
|
|
2509
|
+
get conditionText() {
|
|
2510
|
+
return this.#conditionText;
|
|
2511
|
+
}
|
|
2512
|
+
};
|
|
2513
|
+
/** A live `@media` rule. */
|
|
2514
|
+
var CSSMediaRule = class extends CSSConditionRule {
|
|
2515
|
+
media;
|
|
2516
|
+
constructor(conditionText) {
|
|
2517
|
+
const media = new MediaList(conditionText);
|
|
2518
|
+
super(CSSRule.MEDIA_RULE, media.mediaText);
|
|
2519
|
+
this.media = media;
|
|
2520
|
+
lockOwnProperties(this, "media");
|
|
2521
|
+
}
|
|
2522
|
+
get conditionText() {
|
|
2523
|
+
return this.media.mediaText;
|
|
2524
|
+
}
|
|
2525
|
+
get cssText() {
|
|
2526
|
+
return this.serializeGroup(`@media ${this.media.mediaText}`);
|
|
2527
|
+
}
|
|
2528
|
+
set cssText(_value) {}
|
|
2529
|
+
};
|
|
2530
|
+
/** A live `@supports` rule. */
|
|
2531
|
+
var CSSSupportsRule = class extends CSSConditionRule {
|
|
2532
|
+
constructor(conditionText) {
|
|
2533
|
+
super(CSSRule.SUPPORTS_RULE, normalizeConditionalPrelude("supports", conditionText));
|
|
2534
|
+
}
|
|
2535
|
+
get cssText() {
|
|
2536
|
+
return this.serializeGroup(`@supports ${this.conditionText}`);
|
|
2537
|
+
}
|
|
2538
|
+
set cssText(_value) {}
|
|
2539
|
+
};
|
|
2540
|
+
/** A live `@container` rule. */
|
|
2541
|
+
var CSSContainerRule = class extends CSSConditionRule {
|
|
2542
|
+
containerName;
|
|
2543
|
+
containerQuery;
|
|
2544
|
+
constructor(conditionText) {
|
|
2545
|
+
const normalizedCondition = normalizeConditionalPrelude("container", conditionText);
|
|
2546
|
+
super(0, normalizedCondition);
|
|
2547
|
+
const openingParenthesis = normalizedCondition.indexOf("(");
|
|
2548
|
+
this.containerName = openingParenthesis === -1 ? "" : normalizedCondition.slice(0, openingParenthesis).trim();
|
|
2549
|
+
this.containerQuery = openingParenthesis === -1 ? normalizedCondition : normalizedCondition.slice(openingParenthesis).trim();
|
|
2550
|
+
lockOwnProperties(this, "containerName", "containerQuery");
|
|
2551
|
+
}
|
|
2552
|
+
get cssText() {
|
|
2553
|
+
return this.serializeGroup(`@container ${this.conditionText}`);
|
|
2554
|
+
}
|
|
2555
|
+
set cssText(_value) {}
|
|
2556
|
+
};
|
|
2557
|
+
/** A live block-form `@layer` rule. */
|
|
2558
|
+
var CSSLayerBlockRule = class extends CSSGroupingRule {
|
|
2559
|
+
name;
|
|
2560
|
+
constructor(name) {
|
|
2561
|
+
super(0);
|
|
2562
|
+
this.name = name;
|
|
2563
|
+
lockOwnProperties(this, "name");
|
|
2564
|
+
}
|
|
2565
|
+
get cssText() {
|
|
2566
|
+
return this.serializeGroup(`@layer${this.name === "" ? "" : ` ${this.name}`}`);
|
|
2567
|
+
}
|
|
2568
|
+
set cssText(_value) {}
|
|
2569
|
+
};
|
|
2570
|
+
/** A live `@scope` rule. */
|
|
2571
|
+
var CSSScopeRule = class extends CSSGroupingRule {
|
|
2572
|
+
start;
|
|
2573
|
+
end;
|
|
2574
|
+
constructor(start, end) {
|
|
2575
|
+
super(0);
|
|
2576
|
+
this.start = start;
|
|
2577
|
+
this.end = end;
|
|
2578
|
+
lockOwnProperties(this, "start", "end");
|
|
2579
|
+
}
|
|
2580
|
+
get cssText() {
|
|
2581
|
+
const start = this.start === null ? "" : ` (${this.start})`;
|
|
2582
|
+
const end = this.end === null ? "" : ` to (${this.end})`;
|
|
2583
|
+
return this.serializeGroup(`@scope${start}${end}`);
|
|
2584
|
+
}
|
|
2585
|
+
set cssText(_value) {}
|
|
2586
|
+
};
|
|
2587
|
+
/** A live `@starting-style` rule. */
|
|
2588
|
+
var CSSStartingStyleRule = class extends CSSGroupingRule {
|
|
2589
|
+
constructor() {
|
|
2590
|
+
super(0);
|
|
2591
|
+
}
|
|
2592
|
+
get cssText() {
|
|
2593
|
+
return this.serializeGroup("@starting-style");
|
|
2594
|
+
}
|
|
2595
|
+
set cssText(_value) {}
|
|
2596
|
+
};
|
|
2597
|
+
/** A non-loading `@import` rule with mutable media. */
|
|
2598
|
+
var CSSImportRule = class extends CSSRule {
|
|
2599
|
+
media;
|
|
2600
|
+
styleSheet = null;
|
|
2601
|
+
layerName;
|
|
2602
|
+
supportsText;
|
|
2603
|
+
#rawHref;
|
|
2604
|
+
constructor(href, mediaText = "", layerName = null, supportsText = null) {
|
|
2605
|
+
super(CSSRule.IMPORT_RULE);
|
|
2606
|
+
this.#rawHref = href;
|
|
2607
|
+
this.media = new MediaList(mediaText);
|
|
2608
|
+
this.layerName = layerName;
|
|
2609
|
+
this.supportsText = supportsText;
|
|
2610
|
+
lockOwnProperties(this, "media", "styleSheet", "layerName", "supportsText");
|
|
2611
|
+
}
|
|
2612
|
+
get href() {
|
|
2613
|
+
const baseURL = this.parentStyleSheet?.baseURL;
|
|
2614
|
+
if (!baseURL || baseURL === "about:blank") return this.#rawHref;
|
|
2615
|
+
try {
|
|
2616
|
+
return new URL(this.#rawHref, baseURL).href;
|
|
2617
|
+
} catch {
|
|
2618
|
+
return this.#rawHref;
|
|
2619
|
+
}
|
|
2620
|
+
}
|
|
2621
|
+
get cssText() {
|
|
2622
|
+
return `@import url("${this.#rawHref.replace(/["\\]/g, (character) => `\\${character}`)}")${this.layerName === null ? "" : this.layerName === "" ? " layer" : ` layer(${this.layerName})`}${this.supportsText === null ? "" : ` supports(${this.supportsText})`}${this.media.mediaText === "" ? "" : ` ${this.media.mediaText}`};`;
|
|
2623
|
+
}
|
|
2624
|
+
set cssText(_value) {}
|
|
2625
|
+
};
|
|
2626
|
+
var CSSGenericRule = class extends CSSRule {
|
|
2627
|
+
#cssText;
|
|
2628
|
+
constructor(type, cssText) {
|
|
2629
|
+
super(type);
|
|
2630
|
+
this.#cssText = cssText;
|
|
2631
|
+
}
|
|
2632
|
+
get cssText() {
|
|
2633
|
+
return this.#cssText;
|
|
2634
|
+
}
|
|
2635
|
+
set cssText(_value) {}
|
|
2636
|
+
};
|
|
2637
|
+
var CSSOpaqueRule = class extends CSSGenericRule {};
|
|
2638
|
+
/** A live declaration block with indexed, named, and method-based access. */
|
|
2639
|
+
var CSSStyleDeclaration = class {
|
|
2640
|
+
parentRule;
|
|
2641
|
+
#block;
|
|
2642
|
+
constructor(parentRule) {
|
|
2643
|
+
assertInternalConstructor("CSSStyleDeclaration");
|
|
2644
|
+
this.parentRule = parentRule;
|
|
2645
|
+
lockOwnProperties(this, "parentRule");
|
|
2646
|
+
this.#block = new DeclarationBlock({
|
|
2647
|
+
parseValue: (name, value) => parseDeclarationValue(this, name, value),
|
|
2648
|
+
shorthandLonghands: getShorthandLonghands,
|
|
2649
|
+
expandFourSide: expandStaticFourSide,
|
|
2650
|
+
expandShorthand: expandStaticShorthand,
|
|
2651
|
+
serializeIdentifier,
|
|
2652
|
+
normalizeIndex: toUnsignedLong,
|
|
2653
|
+
isFourSideShorthand
|
|
2654
|
+
}, (code, property, input) => {
|
|
2655
|
+
const priority = code === "INVALID_PRIORITY";
|
|
2656
|
+
(ruleDiagnostics.get(this.parentRule) ?? ignoreDiagnostic)({
|
|
2657
|
+
code,
|
|
2658
|
+
severity: "warning",
|
|
2659
|
+
operation: "setProperty",
|
|
2660
|
+
message: priority ? `The mutation was ignored because ${input} is not a valid priority.` : `The value was ignored because it is invalid for ${property}.`,
|
|
2661
|
+
property,
|
|
2662
|
+
input,
|
|
2663
|
+
location: null
|
|
2664
|
+
});
|
|
2665
|
+
});
|
|
2666
|
+
return new Proxy(this, {
|
|
2667
|
+
get(target, property) {
|
|
2668
|
+
if (typeof property === "string" && arrayIndexPattern.test(property)) return target.item(Number(property)) || void 0;
|
|
2669
|
+
if (typeof property === "string" && !Reflect.has(target, property)) return target.getPropertyValue(namedPropertyToCSS(property));
|
|
2670
|
+
const result = Reflect.get(target, property, target);
|
|
2671
|
+
return typeof result === "function" ? result.bind(target) : result;
|
|
2672
|
+
},
|
|
2673
|
+
set(target, property, value) {
|
|
2674
|
+
if (typeof property === "string" && !Reflect.has(target, property)) {
|
|
2675
|
+
Reflect.apply(target.setProperty, target, [namedPropertyToCSS(property), value]);
|
|
2676
|
+
return true;
|
|
2677
|
+
}
|
|
2678
|
+
return Reflect.set(target, property, value, target);
|
|
2679
|
+
}
|
|
2680
|
+
});
|
|
2681
|
+
}
|
|
2682
|
+
get cssText() {
|
|
2683
|
+
return this.#block.serialize(false, "", " ");
|
|
2684
|
+
}
|
|
2685
|
+
set cssText(value) {
|
|
2686
|
+
let parsed;
|
|
2687
|
+
try {
|
|
2688
|
+
parsed = css_tree.parse(`${value}`, { context: "declarationList" });
|
|
2689
|
+
} catch {
|
|
2690
|
+
this.#block.replace(null);
|
|
2691
|
+
return;
|
|
2692
|
+
}
|
|
2693
|
+
if (parsed.type !== "DeclarationList") {
|
|
2694
|
+
this.#block.replace(null);
|
|
2695
|
+
return;
|
|
2696
|
+
}
|
|
2697
|
+
const declarations = [];
|
|
2698
|
+
for (const child of parsed.children) {
|
|
2699
|
+
if (child.type !== "Declaration") continue;
|
|
2700
|
+
declarations.push({
|
|
2701
|
+
name: child.property,
|
|
2702
|
+
value: css_tree.generate(child.value),
|
|
2703
|
+
important: child.important === true || child.important === "important"
|
|
2704
|
+
});
|
|
2705
|
+
}
|
|
2706
|
+
this.#block.replace(declarations);
|
|
2707
|
+
}
|
|
2708
|
+
get length() {
|
|
2709
|
+
return this.#block.length;
|
|
2710
|
+
}
|
|
2711
|
+
item(index) {
|
|
2712
|
+
requireArguments(arguments.length, 1, "CSSStyleDeclaration", "item");
|
|
2713
|
+
return this.#block.item(index);
|
|
2714
|
+
}
|
|
2715
|
+
getPropertyValue(name) {
|
|
2716
|
+
requireArguments(arguments.length, 1, "CSSStyleDeclaration", "getPropertyValue");
|
|
2717
|
+
return this.#block.getPropertyValue(`${name}`);
|
|
2718
|
+
}
|
|
2719
|
+
getPropertyPriority(name) {
|
|
2720
|
+
requireArguments(arguments.length, 1, "CSSStyleDeclaration", "getPropertyPriority");
|
|
2721
|
+
return this.#block.getPropertyPriority(`${name}`);
|
|
2722
|
+
}
|
|
2723
|
+
setProperty(name, value, priority = "") {
|
|
2724
|
+
requireArguments(arguments.length, 2, "CSSStyleDeclaration", "setProperty");
|
|
2725
|
+
const stringName = `${name}`;
|
|
2726
|
+
const stringValue = value === null ? "" : `${value}`;
|
|
2727
|
+
const stringPriority = priority === null ? "" : `${priority}`;
|
|
2728
|
+
this.#block.setProperty(stringName, stringValue, stringPriority);
|
|
2729
|
+
}
|
|
2730
|
+
removeProperty(name) {
|
|
2731
|
+
requireArguments(arguments.length, 1, "CSSStyleDeclaration", "removeProperty");
|
|
2732
|
+
return this.#block.removeProperty(`${name}`);
|
|
2733
|
+
}
|
|
2734
|
+
/** @internal */
|
|
2735
|
+
serializeSafe(indent) {
|
|
2736
|
+
return this.#block.serialize(true, indent, "\n");
|
|
2737
|
+
}
|
|
2738
|
+
};
|
|
2739
|
+
/** A live `@font-face` descriptor rule. */
|
|
2740
|
+
var CSSFontFaceRule = class extends CSSRule {
|
|
2741
|
+
style;
|
|
2742
|
+
constructor() {
|
|
2743
|
+
super(CSSRule.FONT_FACE_RULE);
|
|
2744
|
+
this.style = new CSSStyleDeclaration(this);
|
|
2745
|
+
lockOwnProperties(this, "style");
|
|
2746
|
+
}
|
|
2747
|
+
get cssText() {
|
|
2748
|
+
return `@font-face {${this.style.cssText === "" ? "" : ` ${this.style.cssText}`} }`;
|
|
2749
|
+
}
|
|
2750
|
+
set cssText(_value) {}
|
|
2751
|
+
};
|
|
2752
|
+
/** Declarations ordered after a nested style rule. */
|
|
2753
|
+
var CSSNestedDeclarations = class extends CSSRule {
|
|
2754
|
+
#style;
|
|
2755
|
+
constructor() {
|
|
2756
|
+
super(0);
|
|
2757
|
+
this.#style = new CSSStyleDeclaration(this);
|
|
2758
|
+
}
|
|
2759
|
+
get style() {
|
|
2760
|
+
return this.#style;
|
|
2761
|
+
}
|
|
2762
|
+
set style(cssText) {
|
|
2763
|
+
this.#style.cssText = `${cssText}`;
|
|
2764
|
+
}
|
|
2765
|
+
get cssText() {
|
|
2766
|
+
return this.style.cssText;
|
|
2767
|
+
}
|
|
2768
|
+
set cssText(_value) {}
|
|
2769
|
+
};
|
|
2770
|
+
/** A page-margin rule nested inside `CSSPageRule`. */
|
|
2771
|
+
var CSSMarginRule = class extends CSSRule {
|
|
2772
|
+
name;
|
|
2773
|
+
style;
|
|
2774
|
+
constructor(name) {
|
|
2775
|
+
super(CSSRule.MARGIN_RULE);
|
|
2776
|
+
this.name = name;
|
|
2777
|
+
this.style = new CSSStyleDeclaration(this);
|
|
2778
|
+
lockOwnProperties(this, "name", "style");
|
|
2779
|
+
}
|
|
2780
|
+
get cssText() {
|
|
2781
|
+
return `@${this.name} {${this.style.cssText === "" ? "" : ` ${this.style.cssText}`} }`;
|
|
2782
|
+
}
|
|
2783
|
+
set cssText(_value) {}
|
|
2784
|
+
};
|
|
2785
|
+
/** A live `@page` rule with declarations and margin rules. */
|
|
2786
|
+
var CSSPageRule = class extends CSSGroupingRule {
|
|
2787
|
+
style;
|
|
2788
|
+
#selectorText;
|
|
2789
|
+
constructor(selectorText) {
|
|
2790
|
+
super(CSSRule.PAGE_RULE);
|
|
2791
|
+
this.#selectorText = selectorText;
|
|
2792
|
+
this.style = new CSSStyleDeclaration(this);
|
|
2793
|
+
lockOwnProperties(this, "style");
|
|
2794
|
+
}
|
|
2795
|
+
get selectorText() {
|
|
2796
|
+
return this.#selectorText;
|
|
2797
|
+
}
|
|
2798
|
+
set selectorText(value) {
|
|
2799
|
+
this.#selectorText = `${value}`.trim();
|
|
2800
|
+
}
|
|
2801
|
+
get cssText() {
|
|
2802
|
+
const contents = [];
|
|
2803
|
+
if (this.style.cssText !== "") contents.push(this.style.cssText);
|
|
2804
|
+
for (const child of ruleTree.children(this)) contents.push(child.cssText);
|
|
2805
|
+
return `@page${this.selectorText === "" ? "" : ` ${this.selectorText}`} {${contents.length === 0 ? "" : ` ${contents.join(" ")}`} }`;
|
|
2806
|
+
}
|
|
2807
|
+
set cssText(_value) {}
|
|
2808
|
+
};
|
|
2809
|
+
/** A live `@position-try` declaration rule. */
|
|
2810
|
+
var CSSPositionTryRule = class extends CSSRule {
|
|
2811
|
+
name;
|
|
2812
|
+
style;
|
|
2813
|
+
constructor(name) {
|
|
2814
|
+
super(0);
|
|
2815
|
+
this.name = name;
|
|
2816
|
+
this.style = new CSSStyleDeclaration(this);
|
|
2817
|
+
lockOwnProperties(this, "name", "style");
|
|
2818
|
+
}
|
|
2819
|
+
get cssText() {
|
|
2820
|
+
return `@position-try ${this.name} {${this.style.cssText === "" ? "" : ` ${this.style.cssText}`} }`;
|
|
2821
|
+
}
|
|
2822
|
+
set cssText(_value) {}
|
|
2823
|
+
};
|
|
2824
|
+
function normalizeKeyText(value) {
|
|
2825
|
+
const parts = value.split(",").map((part) => part.trim());
|
|
2826
|
+
if (parts.length === 0 || parts.some((part) => part === "")) return null;
|
|
2827
|
+
const normalized = [];
|
|
2828
|
+
for (const part of parts) {
|
|
2829
|
+
const lower = part.toLowerCase();
|
|
2830
|
+
if (lower === "from") {
|
|
2831
|
+
normalized.push("0%");
|
|
2832
|
+
continue;
|
|
2833
|
+
}
|
|
2834
|
+
if (lower === "to") {
|
|
2835
|
+
normalized.push("100%");
|
|
2836
|
+
continue;
|
|
2837
|
+
}
|
|
2838
|
+
const match = lower.match(/^([+-]?(?:\d+(?:\.\d*)?|\.\d+))%$/);
|
|
2839
|
+
if (!match) return null;
|
|
2840
|
+
const percentage = Number(match[1]);
|
|
2841
|
+
if (percentage < 0 || percentage > 100) return null;
|
|
2842
|
+
normalized.push(`${percentage}%`);
|
|
2843
|
+
}
|
|
2844
|
+
return normalized.join(", ");
|
|
2845
|
+
}
|
|
2846
|
+
/** One mutable keyframe selector and declaration block. */
|
|
2847
|
+
var CSSKeyframeRule = class extends CSSRule {
|
|
2848
|
+
style;
|
|
2849
|
+
#keyText;
|
|
2850
|
+
constructor(keyText) {
|
|
2851
|
+
super(CSSRule.KEYFRAME_RULE);
|
|
2852
|
+
this.#keyText = normalizeKeyText(keyText) ?? keyText;
|
|
2853
|
+
this.style = new CSSStyleDeclaration(this);
|
|
2854
|
+
lockOwnProperties(this, "style");
|
|
2855
|
+
}
|
|
2856
|
+
get keyText() {
|
|
2857
|
+
return this.#keyText;
|
|
2858
|
+
}
|
|
2859
|
+
set keyText(value) {
|
|
2860
|
+
const normalized = normalizeKeyText(`${value}`);
|
|
2861
|
+
if (normalized !== null) this.#keyText = normalized;
|
|
2862
|
+
}
|
|
2863
|
+
get cssText() {
|
|
2864
|
+
return `${this.keyText} {${this.style.cssText === "" ? "" : ` ${this.style.cssText}`} }`;
|
|
2865
|
+
}
|
|
2866
|
+
set cssText(_value) {}
|
|
2867
|
+
};
|
|
2868
|
+
/** A mutable `@keyframes` rule. */
|
|
2869
|
+
var CSSKeyframesRule = class extends CSSRule {
|
|
2870
|
+
cssRules;
|
|
2871
|
+
#name;
|
|
2872
|
+
constructor(name) {
|
|
2873
|
+
super(CSSRule.KEYFRAMES_RULE);
|
|
2874
|
+
this.#name = name;
|
|
2875
|
+
const rules = ruleTree.createChildren(this);
|
|
2876
|
+
this.cssRules = new CSSRuleList(rules);
|
|
2877
|
+
lockOwnProperties(this, "cssRules");
|
|
2878
|
+
}
|
|
2879
|
+
get name() {
|
|
2880
|
+
return this.#name;
|
|
2881
|
+
}
|
|
2882
|
+
set name(value) {
|
|
2883
|
+
this.#name = `${value}`;
|
|
2884
|
+
}
|
|
2885
|
+
get length() {
|
|
2886
|
+
return this.cssRules.length;
|
|
2887
|
+
}
|
|
2888
|
+
appendRule(ruleText) {
|
|
2889
|
+
requireArguments(arguments.length, 1, "CSSKeyframesRule", "appendRule");
|
|
2890
|
+
const parsed = parseKeyframeRule(`${ruleText}`, ruleDiagnostics.get(this) ?? ignoreDiagnostic);
|
|
2891
|
+
if (!parsed) return;
|
|
2892
|
+
ruleTree.children(this).push(parsed);
|
|
2893
|
+
attachRuleTree(parsed, this, this.parentStyleSheet);
|
|
2894
|
+
}
|
|
2895
|
+
deleteRule(select) {
|
|
2896
|
+
requireArguments(arguments.length, 1, "CSSKeyframesRule", "deleteRule");
|
|
2897
|
+
const normalized = normalizeKeyText(`${select}`);
|
|
2898
|
+
if (normalized === null) return;
|
|
2899
|
+
const rules = ruleTree.children(this);
|
|
2900
|
+
let index = -1;
|
|
2901
|
+
for (let candidate = rules.length - 1; candidate >= 0; candidate -= 1) {
|
|
2902
|
+
const rule = rules[candidate];
|
|
2903
|
+
if (!(rule instanceof CSSKeyframeRule) || rule.keyText !== normalized) continue;
|
|
2904
|
+
index = candidate;
|
|
2905
|
+
break;
|
|
2906
|
+
}
|
|
2907
|
+
if (index === -1) return;
|
|
2908
|
+
const [removed] = rules.splice(index, 1);
|
|
2909
|
+
if (removed) attachRuleTree(removed, null, null);
|
|
2910
|
+
}
|
|
2911
|
+
findRule(select) {
|
|
2912
|
+
requireArguments(arguments.length, 1, "CSSKeyframesRule", "findRule");
|
|
2913
|
+
const normalized = normalizeKeyText(`${select}`);
|
|
2914
|
+
if (normalized === null) return null;
|
|
2915
|
+
const rules = ruleTree.children(this);
|
|
2916
|
+
for (let index = rules.length - 1; index >= 0; index -= 1) {
|
|
2917
|
+
const rule = rules[index];
|
|
2918
|
+
if (rule instanceof CSSKeyframeRule && rule.keyText === normalized) return rule;
|
|
2919
|
+
}
|
|
2920
|
+
return null;
|
|
2921
|
+
}
|
|
2922
|
+
get cssText() {
|
|
2923
|
+
const rules = ruleTree.children(this);
|
|
2924
|
+
if (rules.length === 0) return `@keyframes ${this.name} { }`;
|
|
2925
|
+
return `@keyframes ${this.name} { \n${rules.map((rule) => indentRuleText(rule.cssText)).join("\n")}\n}`;
|
|
2926
|
+
}
|
|
2927
|
+
set cssText(_value) {}
|
|
2928
|
+
};
|
|
2929
|
+
const counterDescriptorNames = [
|
|
2930
|
+
"system",
|
|
2931
|
+
"symbols",
|
|
2932
|
+
"additive-symbols",
|
|
2933
|
+
"negative",
|
|
2934
|
+
"prefix",
|
|
2935
|
+
"suffix",
|
|
2936
|
+
"range",
|
|
2937
|
+
"pad",
|
|
2938
|
+
"speak-as",
|
|
2939
|
+
"fallback"
|
|
2940
|
+
];
|
|
2941
|
+
/** A mutable `@counter-style` descriptor rule. */
|
|
2942
|
+
var CSSCounterStyleRule = class extends CSSRule {
|
|
2943
|
+
#descriptors = /* @__PURE__ */ new Map();
|
|
2944
|
+
#name;
|
|
2945
|
+
constructor(name) {
|
|
2946
|
+
super(CSSRule.COUNTER_STYLE_RULE);
|
|
2947
|
+
this.#name = name;
|
|
2948
|
+
}
|
|
2949
|
+
get name() {
|
|
2950
|
+
return this.#name;
|
|
2951
|
+
}
|
|
2952
|
+
set name(value) {
|
|
2953
|
+
this.#name = `${value}`;
|
|
2954
|
+
}
|
|
2955
|
+
get system() {
|
|
2956
|
+
return this.#get("system");
|
|
2957
|
+
}
|
|
2958
|
+
set system(value) {
|
|
2959
|
+
this.#set("system", value);
|
|
2960
|
+
}
|
|
2961
|
+
get symbols() {
|
|
2962
|
+
return this.#get("symbols");
|
|
2963
|
+
}
|
|
2964
|
+
set symbols(value) {
|
|
2965
|
+
this.#set("symbols", value);
|
|
2966
|
+
}
|
|
2967
|
+
get additiveSymbols() {
|
|
2968
|
+
return this.#get("additive-symbols");
|
|
2969
|
+
}
|
|
2970
|
+
set additiveSymbols(value) {
|
|
2971
|
+
this.#set("additive-symbols", value);
|
|
2972
|
+
}
|
|
2973
|
+
get negative() {
|
|
2974
|
+
return this.#get("negative");
|
|
2975
|
+
}
|
|
2976
|
+
set negative(value) {
|
|
2977
|
+
this.#set("negative", value);
|
|
2978
|
+
}
|
|
2979
|
+
get prefix() {
|
|
2980
|
+
return this.#get("prefix");
|
|
2981
|
+
}
|
|
2982
|
+
set prefix(value) {
|
|
2983
|
+
this.#set("prefix", value);
|
|
2984
|
+
}
|
|
2985
|
+
get suffix() {
|
|
2986
|
+
return this.#get("suffix");
|
|
2987
|
+
}
|
|
2988
|
+
set suffix(value) {
|
|
2989
|
+
this.#set("suffix", value);
|
|
2990
|
+
}
|
|
2991
|
+
get range() {
|
|
2992
|
+
return this.#get("range");
|
|
2993
|
+
}
|
|
2994
|
+
set range(value) {
|
|
2995
|
+
this.#set("range", value);
|
|
2996
|
+
}
|
|
2997
|
+
get pad() {
|
|
2998
|
+
return this.#get("pad");
|
|
2999
|
+
}
|
|
3000
|
+
set pad(value) {
|
|
3001
|
+
this.#set("pad", value);
|
|
3002
|
+
}
|
|
3003
|
+
get speakAs() {
|
|
3004
|
+
return this.#get("speak-as");
|
|
3005
|
+
}
|
|
3006
|
+
set speakAs(value) {
|
|
3007
|
+
this.#set("speak-as", value);
|
|
3008
|
+
}
|
|
3009
|
+
get fallback() {
|
|
3010
|
+
return this.#get("fallback");
|
|
3011
|
+
}
|
|
3012
|
+
set fallback(value) {
|
|
3013
|
+
this.#set("fallback", value);
|
|
3014
|
+
}
|
|
3015
|
+
#get(name) {
|
|
3016
|
+
return this.#descriptors.get(name) ?? "";
|
|
3017
|
+
}
|
|
3018
|
+
#set(name, value) {
|
|
3019
|
+
const text = `${value}`;
|
|
3020
|
+
if (text === "") {
|
|
3021
|
+
this.#descriptors.delete(name);
|
|
3022
|
+
return;
|
|
3023
|
+
}
|
|
3024
|
+
const parsed = parseAtruleDescriptorValue("counter-style", name, text);
|
|
3025
|
+
if (!parsed) return;
|
|
3026
|
+
this.#descriptors.set(name, parsed.observableValue);
|
|
3027
|
+
}
|
|
3028
|
+
/** @internal */
|
|
3029
|
+
setParsedDescriptor(name, value) {
|
|
3030
|
+
if (!counterDescriptorNames.includes(name)) return;
|
|
3031
|
+
this.#set(name, value);
|
|
3032
|
+
}
|
|
3033
|
+
get cssText() {
|
|
3034
|
+
const declarations = [];
|
|
3035
|
+
for (const name of counterDescriptorNames) {
|
|
3036
|
+
const value = this.#descriptors.get(name);
|
|
3037
|
+
if (value !== void 0) declarations.push(`${name}: ${value};`);
|
|
3038
|
+
}
|
|
3039
|
+
return `@counter-style ${this.name} {${declarations.length === 0 ? "" : ` ${declarations.join(" ")}`} }`;
|
|
3040
|
+
}
|
|
3041
|
+
set cssText(_value) {}
|
|
3042
|
+
};
|
|
3043
|
+
/** A live map exposed by one font-feature-values category. */
|
|
3044
|
+
var CSSFontFeatureValuesMap = class {
|
|
3045
|
+
#values = /* @__PURE__ */ new Map();
|
|
3046
|
+
constructor() {
|
|
3047
|
+
assertInternalConstructor("CSSFontFeatureValuesMap");
|
|
3048
|
+
}
|
|
3049
|
+
get size() {
|
|
3050
|
+
return this.#values.size;
|
|
3051
|
+
}
|
|
3052
|
+
set(featureValueName, values) {
|
|
3053
|
+
const name = `${featureValueName}`;
|
|
3054
|
+
if (!/^[-_a-zA-Z][-_a-zA-Z0-9]*$/.test(name)) throw new DOMException("The feature value name is invalid.", "SyntaxError");
|
|
3055
|
+
const normalized = Array.from(values, (value) => Math.trunc(Number(value)));
|
|
3056
|
+
if (normalized.some((value) => !Number.isFinite(value) || value < 0)) throw new TypeError("Feature values must be non-negative integers.");
|
|
3057
|
+
this.#values.set(name, normalized);
|
|
3058
|
+
return this;
|
|
3059
|
+
}
|
|
3060
|
+
clear() {
|
|
3061
|
+
this.#values.clear();
|
|
3062
|
+
}
|
|
3063
|
+
delete(name) {
|
|
3064
|
+
return this.#values.delete(`${name}`);
|
|
3065
|
+
}
|
|
3066
|
+
get(name) {
|
|
3067
|
+
const value = this.#values.get(`${name}`);
|
|
3068
|
+
return value ? [...value] : void 0;
|
|
3069
|
+
}
|
|
3070
|
+
has(name) {
|
|
3071
|
+
return this.#values.has(`${name}`);
|
|
3072
|
+
}
|
|
3073
|
+
entries() {
|
|
3074
|
+
return new Map([...this.#values].map(([name, values]) => [name, [...values]])).entries();
|
|
3075
|
+
}
|
|
3076
|
+
keys() {
|
|
3077
|
+
return this.#values.keys();
|
|
3078
|
+
}
|
|
3079
|
+
values() {
|
|
3080
|
+
return new Map([...this.#values].map(([name, values]) => [name, [...values]])).values();
|
|
3081
|
+
}
|
|
3082
|
+
forEach(callback, thisArg) {
|
|
3083
|
+
for (const [name, values] of this.#values) callback.call(thisArg, [...values], name, this);
|
|
3084
|
+
}
|
|
3085
|
+
[Symbol.iterator]() {
|
|
3086
|
+
return this.entries();
|
|
3087
|
+
}
|
|
3088
|
+
};
|
|
3089
|
+
const fontFeatureMapNames = [
|
|
3090
|
+
"annotation",
|
|
3091
|
+
"ornaments",
|
|
3092
|
+
"stylistic",
|
|
3093
|
+
"swash",
|
|
3094
|
+
"character-variant",
|
|
3095
|
+
"styleset"
|
|
3096
|
+
];
|
|
3097
|
+
/** A mutable `@font-feature-values` rule. */
|
|
3098
|
+
var CSSFontFeatureValuesRule = class extends CSSRule {
|
|
3099
|
+
annotation = new CSSFontFeatureValuesMap();
|
|
3100
|
+
ornaments = new CSSFontFeatureValuesMap();
|
|
3101
|
+
stylistic = new CSSFontFeatureValuesMap();
|
|
3102
|
+
swash = new CSSFontFeatureValuesMap();
|
|
3103
|
+
characterVariant = new CSSFontFeatureValuesMap();
|
|
3104
|
+
styleset = new CSSFontFeatureValuesMap();
|
|
3105
|
+
#fontFamily;
|
|
3106
|
+
constructor(fontFamily) {
|
|
3107
|
+
super(CSSRule.FONT_FEATURE_VALUES_RULE);
|
|
3108
|
+
this.#fontFamily = fontFamily;
|
|
3109
|
+
lockOwnProperties(this, "annotation", "ornaments", "stylistic", "swash", "characterVariant", "styleset");
|
|
3110
|
+
}
|
|
3111
|
+
get fontFamily() {
|
|
3112
|
+
return this.#fontFamily;
|
|
3113
|
+
}
|
|
3114
|
+
set fontFamily(value) {
|
|
3115
|
+
this.#fontFamily = `${value}`.trim();
|
|
3116
|
+
}
|
|
3117
|
+
/** @internal */
|
|
3118
|
+
featureMap(name) {
|
|
3119
|
+
switch (name) {
|
|
3120
|
+
case "annotation": return this.annotation;
|
|
3121
|
+
case "ornaments": return this.ornaments;
|
|
3122
|
+
case "stylistic": return this.stylistic;
|
|
3123
|
+
case "swash": return this.swash;
|
|
3124
|
+
case "character-variant": return this.characterVariant;
|
|
3125
|
+
case "styleset": return this.styleset;
|
|
3126
|
+
default: return null;
|
|
3127
|
+
}
|
|
3128
|
+
}
|
|
3129
|
+
get cssText() {
|
|
3130
|
+
const blocks = [];
|
|
3131
|
+
for (const name of fontFeatureMapNames) {
|
|
3132
|
+
const map = this.featureMap(name);
|
|
3133
|
+
if (!map || map.size === 0) continue;
|
|
3134
|
+
const declarations = [...map].map(([key, values]) => `${key}: ${values.join(" ")};`).join(" ");
|
|
3135
|
+
blocks.push(`@${name} { ${declarations} }`);
|
|
3136
|
+
}
|
|
3137
|
+
return `@font-feature-values ${this.fontFamily} {${blocks.length === 0 ? "" : ` ${blocks.join(" ")}`} }`;
|
|
3138
|
+
}
|
|
3139
|
+
set cssText(_value) {}
|
|
3140
|
+
};
|
|
3141
|
+
/** A live style rule with declarations and nested rules. */
|
|
3142
|
+
var CSSStyleRule = class extends CSSGroupingRule {
|
|
3143
|
+
style;
|
|
3144
|
+
#selectorText;
|
|
3145
|
+
constructor(selectorText) {
|
|
3146
|
+
super(CSSRule.STYLE_RULE);
|
|
3147
|
+
this.#selectorText = normalizeSelectorText(`${selectorText}`) ?? `${selectorText}`;
|
|
3148
|
+
this.style = new CSSStyleDeclaration(this);
|
|
3149
|
+
lockOwnProperties(this, "style");
|
|
3150
|
+
}
|
|
3151
|
+
get selectorText() {
|
|
3152
|
+
return this.#selectorText;
|
|
3153
|
+
}
|
|
3154
|
+
set selectorText(value) {
|
|
3155
|
+
const normalized = normalizeSelectorText(`${value}`);
|
|
3156
|
+
if (normalized === null) return;
|
|
3157
|
+
this.#selectorText = normalized;
|
|
3158
|
+
}
|
|
3159
|
+
get cssText() {
|
|
3160
|
+
const declarations = this.style.cssText;
|
|
3161
|
+
const children = ruleTree.children(this);
|
|
3162
|
+
if (children.length === 0) return declarations === "" ? `${this.selectorText} { }` : `${this.selectorText} { ${declarations} }`;
|
|
3163
|
+
const contents = [];
|
|
3164
|
+
if (declarations !== "") contents.push(indentRuleText(declarations));
|
|
3165
|
+
for (const child of children) contents.push(indentRuleText(child.cssText));
|
|
3166
|
+
return `${this.selectorText} {\n${contents.join("\n")}\n}`;
|
|
3167
|
+
}
|
|
3168
|
+
set cssText(_value) {}
|
|
3169
|
+
};
|
|
3170
|
+
function createStyleRule(node, reportDiagnostic) {
|
|
3171
|
+
const selectorText = normalizeSelectorText(css_tree.generate(node.prelude));
|
|
3172
|
+
if (selectorText === null) return null;
|
|
3173
|
+
const rule = new CSSStyleRule(selectorText);
|
|
3174
|
+
ruleDiagnostics.set(rule, reportDiagnostic);
|
|
3175
|
+
let declarationNodes = [];
|
|
3176
|
+
const childRules = [];
|
|
3177
|
+
let foundNestedRule = false;
|
|
3178
|
+
const flushDeclarations = () => {
|
|
3179
|
+
if (declarationNodes.length === 0) return;
|
|
3180
|
+
const declarationText = declarationNodes.map((child) => css_tree.generate(child)).join(";");
|
|
3181
|
+
if (!foundNestedRule) {
|
|
3182
|
+
rule.style.cssText = declarationText;
|
|
3183
|
+
declarationNodes = [];
|
|
3184
|
+
return;
|
|
3185
|
+
}
|
|
3186
|
+
const nestedDeclarations = new CSSNestedDeclarations();
|
|
3187
|
+
ruleDiagnostics.set(nestedDeclarations, reportDiagnostic);
|
|
3188
|
+
nestedDeclarations.style.cssText = declarationText;
|
|
3189
|
+
childRules.push(nestedDeclarations);
|
|
3190
|
+
declarationNodes = [];
|
|
3191
|
+
};
|
|
3192
|
+
for (const child of node.block.children) {
|
|
3193
|
+
if (child.type === "Declaration") {
|
|
3194
|
+
declarationNodes.push(child);
|
|
3195
|
+
continue;
|
|
3196
|
+
}
|
|
3197
|
+
if (child.type !== "Rule" && child.type !== "Atrule") continue;
|
|
3198
|
+
flushDeclarations();
|
|
3199
|
+
foundNestedRule = true;
|
|
3200
|
+
const parsedChild = createRuleFromNode(child, reportDiagnostic, true);
|
|
3201
|
+
if (parsedChild) childRules.push(parsedChild);
|
|
3202
|
+
}
|
|
3203
|
+
flushDeclarations();
|
|
3204
|
+
replaceGroupingRules(rule, childRules);
|
|
3205
|
+
return rule;
|
|
3206
|
+
}
|
|
3207
|
+
function declarationTextFromBlock(block) {
|
|
3208
|
+
const declarations = [];
|
|
3209
|
+
for (const child of block.children) if (child.type === "Declaration") declarations.push(css_tree.generate(child));
|
|
3210
|
+
return declarations.join(";");
|
|
3211
|
+
}
|
|
3212
|
+
function generateDescriptorInput(value) {
|
|
3213
|
+
if (value.type === "Raw") return value.value;
|
|
3214
|
+
return value.children.toArray().map((child) => css_tree.generate(child)).join(" ");
|
|
3215
|
+
}
|
|
3216
|
+
function createKeyframeRuleFromNode(node, reportDiagnostic) {
|
|
3217
|
+
return constructInternally(() => {
|
|
3218
|
+
const rule = new CSSKeyframeRule(css_tree.generate(node.prelude));
|
|
3219
|
+
ruleDiagnostics.set(rule, reportDiagnostic);
|
|
3220
|
+
rule.style.cssText = declarationTextFromBlock(node.block);
|
|
3221
|
+
return rule;
|
|
3222
|
+
});
|
|
3223
|
+
}
|
|
3224
|
+
function parseKeyframeRule(ruleText, reportDiagnostic) {
|
|
3225
|
+
try {
|
|
3226
|
+
const parsed = css_tree.parse(`@keyframes sheetom { ${ruleText} }`);
|
|
3227
|
+
if (parsed.type !== "StyleSheet") return null;
|
|
3228
|
+
const keyframes = parsed.children.first;
|
|
3229
|
+
if (keyframes?.type !== "Atrule" || !keyframes.block) return null;
|
|
3230
|
+
const node = keyframes.block.children.first;
|
|
3231
|
+
if (node?.type !== "Rule" || keyframes.block.children.size !== 1) return null;
|
|
3232
|
+
return createKeyframeRuleFromNode(node, reportDiagnostic);
|
|
3233
|
+
} catch {
|
|
3234
|
+
return null;
|
|
3235
|
+
}
|
|
3236
|
+
}
|
|
3237
|
+
function replaceKeyframeRules(rule, rules) {
|
|
3238
|
+
ruleTree.replace(rule, rules);
|
|
3239
|
+
}
|
|
3240
|
+
function replaceGroupingRules(group, rules) {
|
|
3241
|
+
ruleTree.replace(group, rules);
|
|
3242
|
+
}
|
|
3243
|
+
function attachRuleTree(rule, parentRule, parentStyleSheet) {
|
|
3244
|
+
ruleTree.attach(rule, parentRule, parentStyleSheet);
|
|
3245
|
+
}
|
|
3246
|
+
function serializeRuleSafe(rule) {
|
|
3247
|
+
return safeSerializer.serialize(rule);
|
|
3248
|
+
}
|
|
3249
|
+
function describeRuleSafe(rule) {
|
|
3250
|
+
if (rule instanceof CSSStyleRule) return {
|
|
3251
|
+
kind: "block",
|
|
3252
|
+
header: rule.selectorText,
|
|
3253
|
+
declarations: rule.style.serializeSafe(" "),
|
|
3254
|
+
children: ruleTree.children(rule)
|
|
3255
|
+
};
|
|
3256
|
+
if (rule instanceof CSSNestedDeclarations) return {
|
|
3257
|
+
kind: "declarations",
|
|
3258
|
+
declarations: rule.style.serializeSafe("")
|
|
3259
|
+
};
|
|
3260
|
+
if (rule instanceof CSSFontFaceRule || rule instanceof CSSMarginRule || rule instanceof CSSPositionTryRule || rule instanceof CSSKeyframeRule) {
|
|
3261
|
+
const blockIndex = rule.cssText.indexOf("{");
|
|
3262
|
+
return {
|
|
3263
|
+
kind: "block",
|
|
3264
|
+
header: rule.cssText.slice(0, blockIndex).trimEnd(),
|
|
3265
|
+
declarations: rule.style.serializeSafe(" ")
|
|
3266
|
+
};
|
|
3267
|
+
}
|
|
3268
|
+
if (rule instanceof CSSKeyframesRule) return {
|
|
3269
|
+
kind: "block",
|
|
3270
|
+
header: `@keyframes ${rule.name}`,
|
|
3271
|
+
children: ruleTree.children(rule)
|
|
3272
|
+
};
|
|
3273
|
+
if (rule instanceof CSSPageRule) return {
|
|
3274
|
+
kind: "block",
|
|
3275
|
+
header: `@page${rule.selectorText === "" ? "" : ` ${rule.selectorText}`}`,
|
|
3276
|
+
declarations: rule.style.serializeSafe(" "),
|
|
3277
|
+
children: ruleTree.children(rule)
|
|
3278
|
+
};
|
|
3279
|
+
if (!(rule instanceof CSSGroupingRule)) return {
|
|
3280
|
+
kind: "raw",
|
|
3281
|
+
cssText: rule.cssText
|
|
3282
|
+
};
|
|
3283
|
+
const blockIndex = rule.cssText.indexOf("{");
|
|
3284
|
+
return {
|
|
3285
|
+
kind: "block",
|
|
3286
|
+
header: blockIndex === -1 ? rule.cssText : rule.cssText.slice(0, blockIndex).trimEnd(),
|
|
3287
|
+
children: ruleTree.children(rule)
|
|
3288
|
+
};
|
|
3289
|
+
}
|
|
3290
|
+
function parseScopePrelude(prelude) {
|
|
3291
|
+
const text = prelude.trim();
|
|
3292
|
+
if (text === "") return [null, null];
|
|
3293
|
+
const consumeGroup = (value) => {
|
|
3294
|
+
if (!value.startsWith("(")) return [null, value];
|
|
3295
|
+
let depth = 0;
|
|
3296
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
3297
|
+
const character = value[index];
|
|
3298
|
+
if (character === "(") depth += 1;
|
|
3299
|
+
if (character !== ")") continue;
|
|
3300
|
+
depth -= 1;
|
|
3301
|
+
if (depth !== 0) continue;
|
|
3302
|
+
return [value.slice(1, index).trim(), value.slice(index + 1).trim()];
|
|
3303
|
+
}
|
|
3304
|
+
return [null, value];
|
|
3305
|
+
};
|
|
3306
|
+
const [start, remainder] = consumeGroup(text);
|
|
3307
|
+
if (!remainder.startsWith("to")) return [start, null];
|
|
3308
|
+
const [end] = consumeGroup(remainder.slice(2).trim());
|
|
3309
|
+
return [start, end];
|
|
3310
|
+
}
|
|
3311
|
+
function parseImportPrelude(prelude) {
|
|
3312
|
+
const hrefMatch = prelude.match(/^(?:url\(\s*(?:"([^"]*)"|'([^']*)'|([^)]*))\s*\)|"([^"]*)"|'([^']*)')\s*(.*)$/);
|
|
3313
|
+
if (!hrefMatch) return null;
|
|
3314
|
+
const href = hrefMatch[1] ?? hrefMatch[2] ?? hrefMatch[3]?.trim() ?? hrefMatch[4] ?? hrefMatch[5];
|
|
3315
|
+
if (href === void 0) return null;
|
|
3316
|
+
let remainder = hrefMatch[6]?.trim() ?? "";
|
|
3317
|
+
let layer = null;
|
|
3318
|
+
let supports = null;
|
|
3319
|
+
const layerMatch = remainder.match(/^layer(?:\(([^)]*)\))?(?:\s+|$)(.*)$/);
|
|
3320
|
+
if (layerMatch) {
|
|
3321
|
+
layer = layerMatch[1]?.trim() ?? "";
|
|
3322
|
+
remainder = layerMatch[2]?.trim() ?? "";
|
|
3323
|
+
}
|
|
3324
|
+
if (remainder.startsWith("supports(")) {
|
|
3325
|
+
let depth = 0;
|
|
3326
|
+
let end = -1;
|
|
3327
|
+
for (let index = 8; index < remainder.length; index += 1) {
|
|
3328
|
+
const character = remainder[index];
|
|
3329
|
+
if (character === "(") depth += 1;
|
|
3330
|
+
if (character !== ")") continue;
|
|
3331
|
+
depth -= 1;
|
|
3332
|
+
if (depth !== 0) continue;
|
|
3333
|
+
end = index;
|
|
3334
|
+
break;
|
|
3335
|
+
}
|
|
3336
|
+
if (end !== -1) {
|
|
3337
|
+
supports = remainder.slice(9, end).trim();
|
|
3338
|
+
remainder = remainder.slice(end + 1).trim();
|
|
3339
|
+
}
|
|
3340
|
+
}
|
|
3341
|
+
return {
|
|
3342
|
+
href,
|
|
3343
|
+
media: remainder,
|
|
3344
|
+
layer,
|
|
3345
|
+
supports
|
|
3346
|
+
};
|
|
3347
|
+
}
|
|
3348
|
+
function createRuleFromNode(node, reportDiagnostic, preserveImports) {
|
|
3349
|
+
return constructInternally(() => createRuleFromNodeInternal(node, reportDiagnostic, preserveImports));
|
|
3350
|
+
}
|
|
3351
|
+
function createRuleFromNodeInternal(node, reportDiagnostic, preserveImports) {
|
|
3352
|
+
if (node.type === "Rule") return createStyleRule(node, reportDiagnostic);
|
|
3353
|
+
const name = node.name.toLowerCase();
|
|
3354
|
+
if (name === "import" && !preserveImports) return null;
|
|
3355
|
+
const prelude = node.prelude ? css_tree.generate(node.prelude) : "";
|
|
3356
|
+
let rule;
|
|
3357
|
+
switch (name) {
|
|
3358
|
+
case "import": {
|
|
3359
|
+
const parsedImport = parseImportPrelude(prelude);
|
|
3360
|
+
if (!parsedImport) return null;
|
|
3361
|
+
rule = new CSSImportRule(parsedImport.href, parsedImport.media, parsedImport.layer, parsedImport.supports);
|
|
3362
|
+
break;
|
|
3363
|
+
}
|
|
3364
|
+
case "font-face": {
|
|
3365
|
+
const fontFace = new CSSFontFaceRule();
|
|
3366
|
+
if (node.block) fontFace.style.cssText = declarationTextFromBlock(node.block);
|
|
3367
|
+
rule = fontFace;
|
|
3368
|
+
break;
|
|
3369
|
+
}
|
|
3370
|
+
case "page": {
|
|
3371
|
+
const page = new CSSPageRule(prelude);
|
|
3372
|
+
if (node.block) {
|
|
3373
|
+
page.style.cssText = declarationTextFromBlock(node.block);
|
|
3374
|
+
const margins = [];
|
|
3375
|
+
for (const child of node.block.children) {
|
|
3376
|
+
if (child.type !== "Atrule" || !child.block) continue;
|
|
3377
|
+
const margin = new CSSMarginRule(child.name.toLowerCase());
|
|
3378
|
+
margin.style.cssText = declarationTextFromBlock(child.block);
|
|
3379
|
+
ruleDiagnostics.set(margin, reportDiagnostic);
|
|
3380
|
+
margins.push(margin);
|
|
3381
|
+
}
|
|
3382
|
+
replaceGroupingRules(page, margins);
|
|
3383
|
+
}
|
|
3384
|
+
rule = page;
|
|
3385
|
+
break;
|
|
3386
|
+
}
|
|
3387
|
+
case "position-try": {
|
|
3388
|
+
if (!prelude.startsWith("--")) return null;
|
|
3389
|
+
const positionTry = new CSSPositionTryRule(prelude);
|
|
3390
|
+
if (node.block) positionTry.style.cssText = declarationTextFromBlock(node.block);
|
|
3391
|
+
rule = positionTry;
|
|
3392
|
+
break;
|
|
3393
|
+
}
|
|
3394
|
+
case "keyframes":
|
|
3395
|
+
case "-webkit-keyframes": {
|
|
3396
|
+
if (prelude === "") return null;
|
|
3397
|
+
const keyframes = new CSSKeyframesRule(prelude);
|
|
3398
|
+
if (node.block) {
|
|
3399
|
+
const frames = [];
|
|
3400
|
+
for (const child of node.block.children) if (child.type === "Rule") frames.push(createKeyframeRuleFromNode(child, reportDiagnostic));
|
|
3401
|
+
replaceKeyframeRules(keyframes, frames);
|
|
3402
|
+
}
|
|
3403
|
+
rule = keyframes;
|
|
3404
|
+
break;
|
|
3405
|
+
}
|
|
3406
|
+
case "counter-style": {
|
|
3407
|
+
if (prelude === "") return null;
|
|
3408
|
+
const counterStyle = new CSSCounterStyleRule(prelude);
|
|
3409
|
+
if (node.block) for (const child of node.block.children) {
|
|
3410
|
+
if (child.type !== "Declaration") continue;
|
|
3411
|
+
counterStyle.setParsedDescriptor(child.property.toLowerCase(), generateDescriptorInput(child.value));
|
|
3412
|
+
}
|
|
3413
|
+
rule = counterStyle;
|
|
3414
|
+
break;
|
|
3415
|
+
}
|
|
3416
|
+
case "font-feature-values": {
|
|
3417
|
+
if (prelude === "") return null;
|
|
3418
|
+
const featureValues = new CSSFontFeatureValuesRule(prelude);
|
|
3419
|
+
if (node.block) for (const child of node.block.children) {
|
|
3420
|
+
if (child.type !== "Atrule" || !child.block) continue;
|
|
3421
|
+
const map = featureValues.featureMap(child.name.toLowerCase());
|
|
3422
|
+
if (!map) continue;
|
|
3423
|
+
for (const declaration of child.block.children) {
|
|
3424
|
+
if (declaration.type !== "Declaration") continue;
|
|
3425
|
+
const values = css_tree.generate(declaration.value).trim().split(/\s+/).map((value) => Number(value));
|
|
3426
|
+
if (values.some((value) => !Number.isFinite(value))) continue;
|
|
3427
|
+
map.set(declaration.property, values);
|
|
3428
|
+
}
|
|
3429
|
+
}
|
|
3430
|
+
rule = featureValues;
|
|
3431
|
+
break;
|
|
3432
|
+
}
|
|
3433
|
+
case "media":
|
|
3434
|
+
if (prelude === "") return null;
|
|
3435
|
+
rule = new CSSMediaRule(prelude);
|
|
3436
|
+
break;
|
|
3437
|
+
case "supports":
|
|
3438
|
+
if (prelude === "") return null;
|
|
3439
|
+
rule = new CSSSupportsRule(prelude);
|
|
3440
|
+
break;
|
|
3441
|
+
case "container":
|
|
3442
|
+
if (prelude === "") return null;
|
|
3443
|
+
rule = new CSSContainerRule(prelude);
|
|
3444
|
+
break;
|
|
3445
|
+
case "layer":
|
|
3446
|
+
if (!node.block) return new CSSGenericRule(0, css_tree.generate(node));
|
|
3447
|
+
rule = new CSSLayerBlockRule(prelude);
|
|
3448
|
+
break;
|
|
3449
|
+
case "scope": {
|
|
3450
|
+
const [start, end] = parseScopePrelude(prelude);
|
|
3451
|
+
rule = new CSSScopeRule(start, end);
|
|
3452
|
+
break;
|
|
3453
|
+
}
|
|
3454
|
+
case "starting-style":
|
|
3455
|
+
rule = new CSSStartingStyleRule();
|
|
3456
|
+
break;
|
|
3457
|
+
default: return new CSSGenericRule(genericRuleType(name), css_tree.generate(node));
|
|
3458
|
+
}
|
|
3459
|
+
ruleDiagnostics.set(rule, reportDiagnostic);
|
|
3460
|
+
if (!(rule instanceof CSSGroupingRule) || rule instanceof CSSPageRule || !node.block) return rule;
|
|
3461
|
+
const children = [];
|
|
3462
|
+
for (const child of node.block.children) {
|
|
3463
|
+
if (child.type !== "Rule" && child.type !== "Atrule") continue;
|
|
3464
|
+
const parsedChild = createRuleFromNode(child, reportDiagnostic, true);
|
|
3465
|
+
if (parsedChild) children.push(parsedChild);
|
|
3466
|
+
}
|
|
3467
|
+
replaceGroupingRules(rule, children);
|
|
3468
|
+
return rule;
|
|
3469
|
+
}
|
|
3470
|
+
function parseStrictRule(ruleText, reportDiagnostic, preserveImports = false, parentRule = null) {
|
|
3471
|
+
let parsed;
|
|
3472
|
+
try {
|
|
3473
|
+
parsed = css_tree.parse(ruleText);
|
|
3474
|
+
} catch {
|
|
3475
|
+
return null;
|
|
3476
|
+
}
|
|
3477
|
+
if (parsed.type !== "StyleSheet" || parsed.children.size !== 1) return null;
|
|
3478
|
+
const node = parsed.children.first;
|
|
3479
|
+
if (!node) return null;
|
|
3480
|
+
if (node.type !== "Rule" && node.type !== "Atrule") return null;
|
|
3481
|
+
if (parentRule instanceof CSSPageRule) {
|
|
3482
|
+
if (node.type !== "Atrule" || !node.block || !pageMarginRuleNames.has(node.name.toLowerCase())) return null;
|
|
3483
|
+
return constructInternally(() => {
|
|
3484
|
+
const margin = new CSSMarginRule(node.name.toLowerCase());
|
|
3485
|
+
margin.style.cssText = declarationTextFromBlock(node.block);
|
|
3486
|
+
ruleDiagnostics.set(margin, reportDiagnostic);
|
|
3487
|
+
return margin;
|
|
3488
|
+
});
|
|
3489
|
+
}
|
|
3490
|
+
if (node.type === "Atrule" && node.name.toLowerCase() === "import" && !preserveImports) return null;
|
|
3491
|
+
return createRuleFromNode(node, reportDiagnostic, preserveImports);
|
|
3492
|
+
}
|
|
3493
|
+
function parsedAtRuleName(ruleText) {
|
|
3494
|
+
try {
|
|
3495
|
+
const parsed = css_tree.parse(ruleText);
|
|
3496
|
+
if (parsed.type !== "StyleSheet" || parsed.children.size !== 1) return null;
|
|
3497
|
+
const node = parsed.children.first;
|
|
3498
|
+
return node?.type === "Atrule" ? node.name.toLowerCase() : null;
|
|
3499
|
+
} catch {
|
|
3500
|
+
return null;
|
|
3501
|
+
}
|
|
3502
|
+
}
|
|
3503
|
+
function genericRuleType(name) {
|
|
3504
|
+
switch (name.toLowerCase()) {
|
|
3505
|
+
case "import": return CSSRule.IMPORT_RULE;
|
|
3506
|
+
case "media": return CSSRule.MEDIA_RULE;
|
|
3507
|
+
case "font-face": return CSSRule.FONT_FACE_RULE;
|
|
3508
|
+
case "page": return CSSRule.PAGE_RULE;
|
|
3509
|
+
case "keyframes":
|
|
3510
|
+
case "-webkit-keyframes": return CSSRule.KEYFRAMES_RULE;
|
|
3511
|
+
case "namespace": return CSSRule.NAMESPACE_RULE;
|
|
3512
|
+
case "supports": return CSSRule.SUPPORTS_RULE;
|
|
3513
|
+
default: return 0;
|
|
3514
|
+
}
|
|
3515
|
+
}
|
|
3516
|
+
function parseStyleSheetRules(cssText, reportDiagnostic, preserveImports) {
|
|
3517
|
+
const rules = [];
|
|
3518
|
+
for (const rawRule of scanTopLevelRules(cssText)) {
|
|
3519
|
+
const rule = parseStrictRule(rawRule, reportDiagnostic, preserveImports);
|
|
3520
|
+
if (rule) {
|
|
3521
|
+
rules.push(rule);
|
|
3522
|
+
continue;
|
|
3523
|
+
}
|
|
3524
|
+
if (!preserveImports) continue;
|
|
3525
|
+
rules.push(constructInternally(() => new CSSOpaqueRule(0, rawRule)));
|
|
3526
|
+
}
|
|
3527
|
+
return rules;
|
|
3528
|
+
}
|
|
3529
|
+
/** A mutable, browser-shaped authoring stylesheet. */
|
|
3530
|
+
var CSSStyleSheet = class {
|
|
3531
|
+
cssRules;
|
|
3532
|
+
media;
|
|
3533
|
+
ownerNode = null;
|
|
3534
|
+
parentStyleSheet = null;
|
|
3535
|
+
ownerRule = null;
|
|
3536
|
+
title = null;
|
|
3537
|
+
type = "text/css";
|
|
3538
|
+
disabled;
|
|
3539
|
+
#rules = [];
|
|
3540
|
+
#diagnostics;
|
|
3541
|
+
#constructedBaseURL;
|
|
3542
|
+
constructor(options = {}) {
|
|
3543
|
+
const normalizedOptions = options ?? {};
|
|
3544
|
+
this.#diagnostics = Boolean(normalizedOptions.diagnostics) ? [] : null;
|
|
3545
|
+
this.#constructedBaseURL = normalizedOptions.baseURL === void 0 ? "about:blank" : `${normalizedOptions.baseURL}`;
|
|
3546
|
+
const media = normalizedOptions.media === void 0 ? "" : `${normalizedOptions.media}`;
|
|
3547
|
+
this.media = constructInternally(() => new MediaList(media));
|
|
3548
|
+
this.disabled = Boolean(normalizedOptions.disabled);
|
|
3549
|
+
this.cssRules = constructInternally(() => new CSSRuleList(this.#rules));
|
|
3550
|
+
lockOwnProperties(this, "cssRules", "media", "ownerNode", "parentStyleSheet", "ownerRule", "title", "type");
|
|
3551
|
+
}
|
|
3552
|
+
get href() {
|
|
3553
|
+
return regularSheetMetadata.get(this)?.href ?? null;
|
|
3554
|
+
}
|
|
3555
|
+
get baseURL() {
|
|
3556
|
+
return regularSheetMetadata.get(this)?.baseURL ?? this.#constructedBaseURL;
|
|
3557
|
+
}
|
|
3558
|
+
#reportDiagnostic = (diagnostic) => {
|
|
3559
|
+
this.#diagnostics?.push(diagnostic);
|
|
3560
|
+
};
|
|
3561
|
+
insertRule(ruleText, index = 0) {
|
|
3562
|
+
requireArguments(arguments.length, 1, "CSSStyleSheet", "insertRule");
|
|
3563
|
+
const normalizedIndex = toUnsignedLong(index);
|
|
3564
|
+
if (normalizedIndex > this.#rules.length) throw new DOMException("The index is outside the allowed range.", "IndexSizeError");
|
|
3565
|
+
const regular = regularSheetMetadata.has(this);
|
|
3566
|
+
const rule = parseStrictRule(`${ruleText}`, this.#reportDiagnostic, regular);
|
|
3567
|
+
if (!rule) throw new DOMException("The rule could not be parsed.", "SyntaxError");
|
|
3568
|
+
const precedingRules = this.#rules.slice(0, normalizedIndex);
|
|
3569
|
+
const followingRules = this.#rules.slice(normalizedIndex);
|
|
3570
|
+
if (rule instanceof CSSImportRule ? precedingRules.some((candidate) => !(candidate instanceof CSSImportRule)) : followingRules.some((candidate) => candidate instanceof CSSImportRule)) throw new DOMException("The rule violates stylesheet ordering.", "HierarchyRequestError");
|
|
3571
|
+
attachRuleTree(rule, null, this);
|
|
3572
|
+
this.#rules.splice(normalizedIndex, 0, rule);
|
|
3573
|
+
return normalizedIndex;
|
|
3574
|
+
}
|
|
3575
|
+
deleteRule(index) {
|
|
3576
|
+
requireArguments(arguments.length, 1, "CSSStyleSheet", "deleteRule");
|
|
3577
|
+
const normalizedIndex = toUnsignedLong(index);
|
|
3578
|
+
if (normalizedIndex >= this.#rules.length) throw new DOMException("The index is outside the allowed range.", "IndexSizeError");
|
|
3579
|
+
const [removed] = this.#rules.splice(normalizedIndex, 1);
|
|
3580
|
+
if (!removed) return;
|
|
3581
|
+
attachRuleTree(removed, null, null);
|
|
3582
|
+
}
|
|
3583
|
+
replaceSync(cssText) {
|
|
3584
|
+
requireArguments(arguments.length, 1, "CSSStyleSheet", "replaceSync");
|
|
3585
|
+
const replacement = parseStyleSheetRules(`${cssText}`, this.#reportDiagnostic, regularSheetMetadata.has(this));
|
|
3586
|
+
for (const rule of this.#rules) attachRuleTree(rule, null, null);
|
|
3587
|
+
for (const rule of replacement) attachRuleTree(rule, null, this);
|
|
3588
|
+
this.#rules.splice(0, this.#rules.length, ...replacement);
|
|
3589
|
+
}
|
|
3590
|
+
async replace(cssText) {
|
|
3591
|
+
requireArguments(arguments.length, 1, "CSSStyleSheet", "replace");
|
|
3592
|
+
this.replaceSync(cssText);
|
|
3593
|
+
return this;
|
|
3594
|
+
}
|
|
3595
|
+
/** Serialize current state as reparsable CSS without mutating live objects. */
|
|
3596
|
+
serialize() {
|
|
3597
|
+
return this.#rules.map(serializeRuleSafe).join("");
|
|
3598
|
+
}
|
|
3599
|
+
/** Drain opt-in mutation diagnostics without affecting CSSOM behavior. */
|
|
3600
|
+
takeDiagnostics() {
|
|
3601
|
+
if (!this.#diagnostics) return [];
|
|
3602
|
+
return this.#diagnostics.splice(0);
|
|
3603
|
+
}
|
|
3604
|
+
};
|
|
3605
|
+
/** Forgivingly parse an existing regular stylesheet without loading imports. */
|
|
3606
|
+
function parseStyleSheet(cssText, options = {}) {
|
|
3607
|
+
const sheet = new CSSStyleSheet(options);
|
|
3608
|
+
const href = options.href ?? null;
|
|
3609
|
+
regularSheetMetadata.set(sheet, {
|
|
3610
|
+
href,
|
|
3611
|
+
baseURL: options.baseURL ?? href ?? "about:blank"
|
|
3612
|
+
});
|
|
3613
|
+
sheet.replaceSync(`${cssText}`);
|
|
3614
|
+
return sheet;
|
|
3615
|
+
}
|
|
3616
|
+
//#endregion
|
|
3617
|
+
exports.CSSConditionRule = CSSConditionRule;
|
|
3618
|
+
exports.CSSContainerRule = CSSContainerRule;
|
|
3619
|
+
exports.CSSCounterStyleRule = CSSCounterStyleRule;
|
|
3620
|
+
exports.CSSFontFaceRule = CSSFontFaceRule;
|
|
3621
|
+
exports.CSSFontFeatureValuesMap = CSSFontFeatureValuesMap;
|
|
3622
|
+
exports.CSSFontFeatureValuesRule = CSSFontFeatureValuesRule;
|
|
3623
|
+
exports.CSSGroupingRule = CSSGroupingRule;
|
|
3624
|
+
exports.CSSImportRule = CSSImportRule;
|
|
3625
|
+
exports.CSSKeyframeRule = CSSKeyframeRule;
|
|
3626
|
+
exports.CSSKeyframesRule = CSSKeyframesRule;
|
|
3627
|
+
exports.CSSLayerBlockRule = CSSLayerBlockRule;
|
|
3628
|
+
exports.CSSMarginRule = CSSMarginRule;
|
|
3629
|
+
exports.CSSMediaRule = CSSMediaRule;
|
|
3630
|
+
exports.CSSNestedDeclarations = CSSNestedDeclarations;
|
|
3631
|
+
exports.CSSPageRule = CSSPageRule;
|
|
3632
|
+
exports.CSSPositionTryRule = CSSPositionTryRule;
|
|
3633
|
+
exports.CSSRule = CSSRule;
|
|
3634
|
+
exports.CSSRuleList = CSSRuleList;
|
|
3635
|
+
exports.CSSScopeRule = CSSScopeRule;
|
|
3636
|
+
exports.CSSStartingStyleRule = CSSStartingStyleRule;
|
|
3637
|
+
exports.CSSStyleDeclaration = CSSStyleDeclaration;
|
|
3638
|
+
exports.CSSStyleRule = CSSStyleRule;
|
|
3639
|
+
exports.CSSStyleSheet = CSSStyleSheet;
|
|
3640
|
+
exports.CSSSupportsRule = CSSSupportsRule;
|
|
3641
|
+
exports.MediaList = MediaList;
|
|
3642
|
+
exports.parseStyleSheet = parseStyleSheet;
|
|
3643
|
+
|
|
3644
|
+
//# sourceMappingURL=index.cjs.map
|