@projectwallace/css-parser 0.14.9 → 0.15.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/dist/{arena-D6TANE5e.d.ts → arena-CSK5NfHq.d.ts} +2 -1
- package/dist/{arena-CveFYH2l.js → arena-DnV0a_Ne.js} +2 -1
- package/dist/constants.d.ts +3 -2
- package/dist/constants.js +3 -2
- package/dist/{css-node-DwKXZuNm.js → css-node-C3t4b8Jt.js} +67 -29
- package/dist/index.d.ts +3 -3
- package/dist/index.js +6 -3
- package/dist/{node-types-CfWcbFWR.d.ts → node-types-DJytj0FB.d.ts} +39 -13
- package/dist/parse-anplusb.d.ts +2 -2
- package/dist/parse-anplusb.js +5 -5
- package/dist/parse-atrule-prelude.d.ts +4 -2
- package/dist/parse-atrule-prelude.js +49 -11
- package/dist/parse-declaration.d.ts +2 -2
- package/dist/parse-declaration.js +2 -2
- package/dist/parse-selector.d.ts +2 -2
- package/dist/parse-selector.js +45 -42
- package/dist/parse-value.d.ts +2 -2
- package/dist/parse-value.js +3 -3
- package/dist/parse.d.ts +2 -2
- package/dist/parse.js +20 -20
- package/dist/walk.d.ts +1 -1
- package/dist/walk.js +1 -1
- package/package.json +10 -10
|
@@ -40,6 +40,7 @@ declare const PRELUDE_OPERATOR = 38;
|
|
|
40
40
|
declare const FEATURE_RANGE = 39;
|
|
41
41
|
declare const AT_RULE_PRELUDE = 40;
|
|
42
42
|
declare const PRELUDE_SELECTORLIST = 41;
|
|
43
|
+
declare const SUPPORTS_DECLARATION = 57;
|
|
43
44
|
declare const VALUE = 50;
|
|
44
45
|
declare const FLAG_IMPORTANT: number;
|
|
45
46
|
/** @internal */
|
|
@@ -90,4 +91,4 @@ declare class CSSDataArena {
|
|
|
90
91
|
has_flag(node_index: number, flag: number): boolean;
|
|
91
92
|
}
|
|
92
93
|
//#endregion
|
|
93
|
-
export { PRELUDE_SELECTORLIST as A,
|
|
94
|
+
export { PRELUDE_SELECTORLIST as A, SUPPORTS_QUERY as B, NESTING_SELECTOR as C, OPERATOR as D, NUMBER as E, SELECTOR_LIST as F, VALUE as G, UNICODE_RANGE as H, STRING as I, STYLESHEET as L, PSEUDO_ELEMENT_SELECTOR as M, RAW as N, PARENTHESIS as O, SELECTOR as P, STYLE_RULE as R, MEDIA_TYPE as S, NTH_SELECTOR as T, UNIVERSAL_SELECTOR as U, TYPE_SELECTOR as V, URL as W, ID_SELECTOR as _, CLASS_SELECTOR as a, MEDIA_FEATURE as b, CONTAINER_QUERY as c, DIMENSION as d, FEATURE_RANGE as f, IDENTIFIER as g, HASH as h, BLOCK as i, PSEUDO_CLASS_SELECTOR as j, PRELUDE_OPERATOR as k, CSSDataArena as l, FUNCTION as m, AT_RULE as n, COMBINATOR as o, FLAG_IMPORTANT as p, AT_RULE_PRELUDE as r, COMMENT as s, ATTRIBUTE_SELECTOR as t, DECLARATION as u, LANG_SELECTOR as v, NTH_OF_SELECTOR as w, MEDIA_QUERY as x, LAYER_NAME as y, SUPPORTS_DECLARATION as z };
|
|
@@ -40,6 +40,7 @@ const LAYER_NAME = 37;
|
|
|
40
40
|
const PRELUDE_OPERATOR = 38;
|
|
41
41
|
const FEATURE_RANGE = 39;
|
|
42
42
|
const AT_RULE_PRELUDE = 40;
|
|
43
|
+
const SUPPORTS_DECLARATION = 57;
|
|
43
44
|
const VALUE = 50;
|
|
44
45
|
const FLAG_IMPORTANT = 1;
|
|
45
46
|
/** @internal */
|
|
@@ -196,4 +197,4 @@ var CSSDataArena = class CSSDataArena {
|
|
|
196
197
|
}
|
|
197
198
|
};
|
|
198
199
|
//#endregion
|
|
199
|
-
export { PSEUDO_CLASS_SELECTOR as A,
|
|
200
|
+
export { PSEUDO_CLASS_SELECTOR as A, TYPE_SELECTOR as B, NESTING_SELECTOR as C, OPERATOR as D, NUMBER as E, STRING as F, UNIVERSAL_SELECTOR as H, STYLESHEET as I, STYLE_RULE as L, RAW as M, SELECTOR as N, PARENTHESIS as O, SELECTOR_LIST as P, SUPPORTS_DECLARATION as R, MEDIA_TYPE as S, NTH_SELECTOR as T, URL as U, UNICODE_RANGE as V, VALUE as W, ID_SELECTOR as _, CLASS_SELECTOR as a, MEDIA_FEATURE as b, CONTAINER_QUERY as c, DIMENSION as d, FEATURE_RANGE as f, IDENTIFIER as g, HASH as h, BLOCK as i, PSEUDO_ELEMENT_SELECTOR as j, PRELUDE_OPERATOR as k, CSSDataArena as l, FUNCTION as m, AT_RULE as n, COMBINATOR as o, FLAG_IMPORTANT as p, AT_RULE_PRELUDE as r, COMMENT as s, ATTRIBUTE_SELECTOR as t, DECLARATION as u, LANG_SELECTOR as v, NTH_OF_SELECTOR as w, MEDIA_QUERY as x, LAYER_NAME as y, SUPPORTS_QUERY as z };
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as
|
|
1
|
+
import { B as SUPPORTS_QUERY, C as NESTING_SELECTOR, D as OPERATOR, E as NUMBER, F as SELECTOR_LIST, G as VALUE, H as UNICODE_RANGE, I as STRING, L as STYLESHEET, M as PSEUDO_ELEMENT_SELECTOR, N as RAW, O as PARENTHESIS, P as SELECTOR, R as STYLE_RULE, S as MEDIA_TYPE, T as NTH_SELECTOR, U as UNIVERSAL_SELECTOR, V as TYPE_SELECTOR, W as URL, _ as ID_SELECTOR, a as CLASS_SELECTOR, b as MEDIA_FEATURE, c as CONTAINER_QUERY, d as DIMENSION, f as FEATURE_RANGE, g as IDENTIFIER, h as HASH, i as BLOCK, j as PSEUDO_CLASS_SELECTOR, k as PRELUDE_OPERATOR, m as FUNCTION, n as AT_RULE, o as COMBINATOR, p as FLAG_IMPORTANT, r as AT_RULE_PRELUDE, s as COMMENT, t as ATTRIBUTE_SELECTOR, u as DECLARATION, v as LANG_SELECTOR, w as NTH_OF_SELECTOR, x as MEDIA_QUERY, y as LAYER_NAME, z as SUPPORTS_DECLARATION } from "./arena-CSK5NfHq.js";
|
|
2
2
|
|
|
3
3
|
//#region src/constants.d.ts
|
|
4
4
|
declare const NODE_TYPES: {
|
|
@@ -39,10 +39,11 @@ declare const NODE_TYPES: {
|
|
|
39
39
|
readonly MEDIA_TYPE: 34;
|
|
40
40
|
readonly CONTAINER_QUERY: 35;
|
|
41
41
|
readonly SUPPORTS_QUERY: 36;
|
|
42
|
+
readonly SUPPORTS_DECLARATION: 57;
|
|
42
43
|
readonly LAYER_NAME: 37;
|
|
43
44
|
readonly PRELUDE_OPERATOR: 38;
|
|
44
45
|
readonly FEATURE_RANGE: 39;
|
|
45
46
|
readonly AT_RULE_PRELUDE: 40;
|
|
46
47
|
};
|
|
47
48
|
//#endregion
|
|
48
|
-
export { ATTRIBUTE_SELECTOR, AT_RULE, AT_RULE_PRELUDE, BLOCK, CLASS_SELECTOR, COMBINATOR, COMMENT, CONTAINER_QUERY, DECLARATION, DIMENSION, FEATURE_RANGE, FLAG_IMPORTANT, FUNCTION, HASH, IDENTIFIER, ID_SELECTOR, LANG_SELECTOR, LAYER_NAME, MEDIA_FEATURE, MEDIA_QUERY, MEDIA_TYPE, NESTING_SELECTOR, NODE_TYPES, NTH_OF_SELECTOR, NTH_SELECTOR, NUMBER, OPERATOR, PARENTHESIS, PRELUDE_OPERATOR, PSEUDO_CLASS_SELECTOR, PSEUDO_ELEMENT_SELECTOR, RAW, SELECTOR, SELECTOR_LIST, STRING, STYLESHEET, STYLE_RULE, SUPPORTS_QUERY, TYPE_SELECTOR, UNICODE_RANGE, UNIVERSAL_SELECTOR, URL, VALUE };
|
|
49
|
+
export { ATTRIBUTE_SELECTOR, AT_RULE, AT_RULE_PRELUDE, BLOCK, CLASS_SELECTOR, COMBINATOR, COMMENT, CONTAINER_QUERY, DECLARATION, DIMENSION, FEATURE_RANGE, FLAG_IMPORTANT, FUNCTION, HASH, IDENTIFIER, ID_SELECTOR, LANG_SELECTOR, LAYER_NAME, MEDIA_FEATURE, MEDIA_QUERY, MEDIA_TYPE, NESTING_SELECTOR, NODE_TYPES, NTH_OF_SELECTOR, NTH_SELECTOR, NUMBER, OPERATOR, PARENTHESIS, PRELUDE_OPERATOR, PSEUDO_CLASS_SELECTOR, PSEUDO_ELEMENT_SELECTOR, RAW, SELECTOR, SELECTOR_LIST, STRING, STYLESHEET, STYLE_RULE, SUPPORTS_DECLARATION, SUPPORTS_QUERY, TYPE_SELECTOR, UNICODE_RANGE, UNIVERSAL_SELECTOR, URL, VALUE };
|
package/dist/constants.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as PSEUDO_CLASS_SELECTOR, B as
|
|
1
|
+
import { A as PSEUDO_CLASS_SELECTOR, B as TYPE_SELECTOR, C as NESTING_SELECTOR, D as OPERATOR, E as NUMBER, F as STRING, H as UNIVERSAL_SELECTOR, I as STYLESHEET, L as STYLE_RULE, M as RAW, N as SELECTOR, O as PARENTHESIS, P as SELECTOR_LIST, R as SUPPORTS_DECLARATION, S as MEDIA_TYPE, T as NTH_SELECTOR, U as URL, V as UNICODE_RANGE, W as VALUE, _ as ID_SELECTOR, a as CLASS_SELECTOR, b as MEDIA_FEATURE, c as CONTAINER_QUERY, d as DIMENSION, f as FEATURE_RANGE, g as IDENTIFIER, h as HASH, i as BLOCK, j as PSEUDO_ELEMENT_SELECTOR, k as PRELUDE_OPERATOR, m as FUNCTION, n as AT_RULE, o as COMBINATOR, p as FLAG_IMPORTANT, r as AT_RULE_PRELUDE, s as COMMENT, t as ATTRIBUTE_SELECTOR, u as DECLARATION, v as LANG_SELECTOR, w as NTH_OF_SELECTOR, x as MEDIA_QUERY, y as LAYER_NAME, z as SUPPORTS_QUERY } from "./arena-DnV0a_Ne.js";
|
|
2
2
|
//#region src/constants.ts
|
|
3
3
|
const NODE_TYPES = {
|
|
4
4
|
STYLESHEET: 1,
|
|
@@ -38,10 +38,11 @@ const NODE_TYPES = {
|
|
|
38
38
|
MEDIA_TYPE: 34,
|
|
39
39
|
CONTAINER_QUERY: 35,
|
|
40
40
|
SUPPORTS_QUERY: 36,
|
|
41
|
+
SUPPORTS_DECLARATION: 57,
|
|
41
42
|
LAYER_NAME: 37,
|
|
42
43
|
PRELUDE_OPERATOR: 38,
|
|
43
44
|
FEATURE_RANGE: 39,
|
|
44
45
|
AT_RULE_PRELUDE: 40
|
|
45
46
|
};
|
|
46
47
|
//#endregion
|
|
47
|
-
export { ATTRIBUTE_SELECTOR, AT_RULE, AT_RULE_PRELUDE, BLOCK, CLASS_SELECTOR, COMBINATOR, COMMENT, CONTAINER_QUERY, DECLARATION, DIMENSION, FEATURE_RANGE, FLAG_IMPORTANT, FUNCTION, HASH, IDENTIFIER, ID_SELECTOR, LANG_SELECTOR, LAYER_NAME, MEDIA_FEATURE, MEDIA_QUERY, MEDIA_TYPE, NESTING_SELECTOR, NODE_TYPES, NTH_OF_SELECTOR, NTH_SELECTOR, NUMBER, OPERATOR, PARENTHESIS, PRELUDE_OPERATOR, PSEUDO_CLASS_SELECTOR, PSEUDO_ELEMENT_SELECTOR, RAW, SELECTOR, SELECTOR_LIST, STRING, STYLESHEET, STYLE_RULE, SUPPORTS_QUERY, TYPE_SELECTOR, UNICODE_RANGE, UNIVERSAL_SELECTOR, URL, VALUE };
|
|
48
|
+
export { ATTRIBUTE_SELECTOR, AT_RULE, AT_RULE_PRELUDE, BLOCK, CLASS_SELECTOR, COMBINATOR, COMMENT, CONTAINER_QUERY, DECLARATION, DIMENSION, FEATURE_RANGE, FLAG_IMPORTANT, FUNCTION, HASH, IDENTIFIER, ID_SELECTOR, LANG_SELECTOR, LAYER_NAME, MEDIA_FEATURE, MEDIA_QUERY, MEDIA_TYPE, NESTING_SELECTOR, NODE_TYPES, NTH_OF_SELECTOR, NTH_SELECTOR, NUMBER, OPERATOR, PARENTHESIS, PRELUDE_OPERATOR, PSEUDO_CLASS_SELECTOR, PSEUDO_ELEMENT_SELECTOR, RAW, SELECTOR, SELECTOR_LIST, STRING, STYLESHEET, STYLE_RULE, SUPPORTS_DECLARATION, SUPPORTS_QUERY, TYPE_SELECTOR, UNICODE_RANGE, UNIVERSAL_SELECTOR, URL, VALUE };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./arena-
|
|
1
|
+
import "./arena-DnV0a_Ne.js";
|
|
2
2
|
import { a as is_whitespace, c as str_starts_with, i as is_vendor_prefixed, t as parse_dimension } from "./parse-dimension-CCn_XRDe.js";
|
|
3
3
|
//#region src/css-node.ts
|
|
4
4
|
const TYPE_NAMES = {
|
|
@@ -39,12 +39,29 @@ const TYPE_NAMES = {
|
|
|
39
39
|
[34]: "MediaType",
|
|
40
40
|
[35]: "ContainerQuery",
|
|
41
41
|
[36]: "SupportsQuery",
|
|
42
|
+
[57]: "SupportsDeclaration",
|
|
42
43
|
[37]: "Layer",
|
|
43
44
|
[38]: "Operator",
|
|
44
45
|
[39]: "MediaFeatureRange",
|
|
45
46
|
[40]: "AtrulePrelude",
|
|
46
47
|
[41]: "PreludeSelectorList"
|
|
47
48
|
};
|
|
49
|
+
const nodes_with_name = new Set([
|
|
50
|
+
3,
|
|
51
|
+
10,
|
|
52
|
+
15,
|
|
53
|
+
21,
|
|
54
|
+
22,
|
|
55
|
+
23,
|
|
56
|
+
24,
|
|
57
|
+
25,
|
|
58
|
+
26,
|
|
59
|
+
27,
|
|
60
|
+
28,
|
|
61
|
+
56,
|
|
62
|
+
37,
|
|
63
|
+
39
|
|
64
|
+
]);
|
|
48
65
|
const nodes_with_children = new Set([
|
|
49
66
|
1,
|
|
50
67
|
5,
|
|
@@ -59,8 +76,26 @@ const nodes_with_children = new Set([
|
|
|
59
76
|
32,
|
|
60
77
|
33,
|
|
61
78
|
35,
|
|
62
|
-
39
|
|
79
|
+
39,
|
|
80
|
+
36,
|
|
81
|
+
57
|
|
63
82
|
]);
|
|
83
|
+
const enumerable_properties = [
|
|
84
|
+
"name",
|
|
85
|
+
"namespace",
|
|
86
|
+
"property",
|
|
87
|
+
"value",
|
|
88
|
+
"unit",
|
|
89
|
+
"attr_operator",
|
|
90
|
+
"attr_flags",
|
|
91
|
+
"nth_a",
|
|
92
|
+
"nth_b",
|
|
93
|
+
"selector",
|
|
94
|
+
"is_browserhack",
|
|
95
|
+
"is_vendor_prefixed",
|
|
96
|
+
"has_error",
|
|
97
|
+
"is_important"
|
|
98
|
+
];
|
|
64
99
|
var CSSNode = class CSSNode {
|
|
65
100
|
arena;
|
|
66
101
|
source;
|
|
@@ -99,9 +134,27 @@ var CSSNode = class CSSNode {
|
|
|
99
134
|
}
|
|
100
135
|
/** Get the "content" text (at-rule name for at-rules, layer name for import layers) */
|
|
101
136
|
get name() {
|
|
137
|
+
if (!nodes_with_name.has(this.type)) return;
|
|
102
138
|
let { type } = this;
|
|
103
|
-
if (type ===
|
|
104
|
-
|
|
139
|
+
if (type === 28) return null;
|
|
140
|
+
let content = this.get_content();
|
|
141
|
+
if (type === 56 && content === "") return null;
|
|
142
|
+
return content;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Namespace prefix for type and universal selectors.
|
|
146
|
+
* - `null` — no namespace qualifier (plain `div` or `*`)
|
|
147
|
+
* - `''` — empty namespace (`|div` or `|*`)
|
|
148
|
+
* - `'ns'` — named namespace (`ns|div` or `ns|*`)
|
|
149
|
+
* - `'*'` — any namespace (`*|div` or `*|*`)
|
|
150
|
+
*/
|
|
151
|
+
get namespace() {
|
|
152
|
+
let { type } = this;
|
|
153
|
+
if (type !== 21 && type !== 28) return void 0;
|
|
154
|
+
if (!this.arena.has_flag(this.index, 16)) return null;
|
|
155
|
+
let start = this.arena.get_value_start(this.index);
|
|
156
|
+
let length = this.arena.get_value_length(this.index);
|
|
157
|
+
return this.source.substring(start, start + length);
|
|
105
158
|
}
|
|
106
159
|
/**
|
|
107
160
|
* Alias for name (for declarations: "color" in "color: blue")
|
|
@@ -124,6 +177,7 @@ var CSSNode = class CSSNode {
|
|
|
124
177
|
if (type === 3) return void 0;
|
|
125
178
|
if (type === 34) return text;
|
|
126
179
|
if (type === 4 && first_child) return first_child;
|
|
180
|
+
if (type === 33) return first_child ?? null;
|
|
127
181
|
if (type === 12) return parse_dimension(text).value;
|
|
128
182
|
if (type === 11) return Number.parseFloat(text);
|
|
129
183
|
if (type === 18) {
|
|
@@ -218,6 +272,7 @@ var CSSNode = class CSSNode {
|
|
|
218
272
|
case 3: return is_vendor_prefixed(this.get_content());
|
|
219
273
|
case 15: return is_vendor_prefixed(this.get_content());
|
|
220
274
|
case 10: return is_vendor_prefixed(this.text);
|
|
275
|
+
case 33: return is_vendor_prefixed(this.get_content());
|
|
221
276
|
default: return false;
|
|
222
277
|
}
|
|
223
278
|
}
|
|
@@ -238,6 +293,8 @@ var CSSNode = class CSSNode {
|
|
|
238
293
|
}
|
|
239
294
|
/** Check if this style rule has declarations */
|
|
240
295
|
get has_declarations() {
|
|
296
|
+
let { type } = this;
|
|
297
|
+
if (type !== 3 && type !== 2) return void 0;
|
|
241
298
|
return this.arena.has_flag(this.index, 32);
|
|
242
299
|
}
|
|
243
300
|
/** Get the block node (for style rules and at-rules with blocks) */
|
|
@@ -354,7 +411,7 @@ var CSSNode = class CSSNode {
|
|
|
354
411
|
let { type, arena, index } = this;
|
|
355
412
|
if (type !== 30 && type !== 31) return void 0;
|
|
356
413
|
let len = arena.get_content_length(index);
|
|
357
|
-
if (len === 0) return
|
|
414
|
+
if (len === 0) return null;
|
|
358
415
|
let start = arena.get_content_start(index);
|
|
359
416
|
return this.source.substring(start, start + len);
|
|
360
417
|
}
|
|
@@ -363,7 +420,7 @@ var CSSNode = class CSSNode {
|
|
|
363
420
|
let { type, arena, index, source } = this;
|
|
364
421
|
if (type !== 30 && type !== 31) return void 0;
|
|
365
422
|
let len = arena.get_value_length(index);
|
|
366
|
-
if (len === 0) return
|
|
423
|
+
if (len === 0) return null;
|
|
367
424
|
let start = arena.get_value_start(index);
|
|
368
425
|
let value = source.substring(start, start + len);
|
|
369
426
|
let check_pos = start - 1;
|
|
@@ -400,35 +457,16 @@ var CSSNode = class CSSNode {
|
|
|
400
457
|
*/
|
|
401
458
|
clone(options = {}) {
|
|
402
459
|
const { deep = true, locations = false } = options;
|
|
403
|
-
let { type
|
|
460
|
+
let { type } = this;
|
|
404
461
|
let plain = {
|
|
405
462
|
type,
|
|
406
463
|
type_name: this.type_name,
|
|
407
464
|
text: this.text
|
|
408
465
|
};
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
plain.value = value;
|
|
413
|
-
if (unit) plain.unit = unit;
|
|
414
|
-
}
|
|
415
|
-
if (type === 4) {
|
|
416
|
-
let { is_important, is_browserhack } = this;
|
|
417
|
-
if (is_important) plain.is_important = true;
|
|
418
|
-
if (is_browserhack) plain.is_browserhack = true;
|
|
419
|
-
}
|
|
420
|
-
let { is_vendor_prefixed, has_error } = this;
|
|
421
|
-
if (is_vendor_prefixed) plain.is_vendor_prefixed = true;
|
|
422
|
-
if (has_error) plain.has_error = true;
|
|
423
|
-
if (type === 24) {
|
|
424
|
-
plain.attr_operator = this.attr_operator;
|
|
425
|
-
plain.attr_flags = this.attr_flags;
|
|
426
|
-
}
|
|
427
|
-
if (type === 30 || type === 31) {
|
|
428
|
-
plain.nth_a = this.nth_a;
|
|
429
|
-
plain.nth_b = this.nth_b;
|
|
466
|
+
for (let key of enumerable_properties) {
|
|
467
|
+
let val = this[key];
|
|
468
|
+
if (val !== void 0 && val !== false) plain[key] = val;
|
|
430
469
|
}
|
|
431
|
-
if (type === 31) plain.selector = this.selector;
|
|
432
470
|
if (locations) {
|
|
433
471
|
plain.line = this.line;
|
|
434
472
|
plain.column = this.column;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { B as
|
|
1
|
+
import { B as SUPPORTS_QUERY, C as NESTING_SELECTOR, D as OPERATOR, E as NUMBER, F as SELECTOR_LIST, G as VALUE, H as UNICODE_RANGE, I as STRING, L as STYLESHEET, M as PSEUDO_ELEMENT_SELECTOR, N as RAW, O as PARENTHESIS, P as SELECTOR, R as STYLE_RULE, S as MEDIA_TYPE, T as NTH_SELECTOR, U as UNIVERSAL_SELECTOR, V as TYPE_SELECTOR, W as URL, _ as ID_SELECTOR, a as CLASS_SELECTOR, b as MEDIA_FEATURE, c as CONTAINER_QUERY, d as DIMENSION, f as FEATURE_RANGE, g as IDENTIFIER, h as HASH, i as BLOCK, j as PSEUDO_CLASS_SELECTOR, k as PRELUDE_OPERATOR, m as FUNCTION, n as AT_RULE, o as COMBINATOR, p as FLAG_IMPORTANT, r as AT_RULE_PRELUDE, s as COMMENT, t as ATTRIBUTE_SELECTOR, u as DECLARATION, v as LANG_SELECTOR, w as NTH_OF_SELECTOR, x as MEDIA_QUERY, y as LAYER_NAME, z as SUPPORTS_DECLARATION } from "./arena-CSK5NfHq.js";
|
|
2
2
|
import { NODE_TYPES } from "./constants.js";
|
|
3
3
|
import { A as TOKEN_URL, C as TOKEN_PERCENTAGE, D as TOKEN_SEMICOLON, E as TOKEN_RIGHT_PAREN, M as Token, N as TokenType, O as TOKEN_STRING, S as TOKEN_NUMBER, T as TOKEN_RIGHT_BRACKET, _ as TOKEN_HASH, a as TOKEN_AT_KEYWORD, b as TOKEN_LEFT_BRACKET, c as TOKEN_CDC, d as TOKEN_COMMA, f as TOKEN_COMMENT, g as TOKEN_FUNCTION, h as TOKEN_EOF, i as tokenize, j as TOKEN_WHITESPACE, k as TOKEN_UNICODE_RANGE, l as TOKEN_CDO, m as TOKEN_DIMENSION, o as TOKEN_BAD_STRING, p as TOKEN_DELIM, r as LexerPosition, s as TOKEN_BAD_URL, t as CommentInfo, u as TOKEN_COLON, v as TOKEN_IDENT, w as TOKEN_RIGHT_BRACE, x as TOKEN_LEFT_PAREN, y as TOKEN_LEFT_BRACE } from "./tokenize-CyiJelQC.js";
|
|
4
|
-
import { $ as
|
|
4
|
+
import { $ as is_class_selector, A as PreludeSelectorList, At as is_stylesheet, B as SupportsDeclaration, Bt as TYPE_NAMES, C as NestingSelector, Ct as is_pseudo_class_selector, D as Operator, Dt as is_selector, E as Number, Et as is_rule, F as Selector, Ft as is_universal_selector, G as UniversalSelector, H as ToPlain, I as SelectorList, It as is_url, J as WithChildren, K as Url, L as SelectorNode, Lt as is_value, M as PseudoElementSelector, Mt as is_supports_query, N as Raw, Nt as is_type_selector, O as Parenthesis, Ot as is_selector_list, P as Rule, Pt as is_unicode_range, Q as is_block, R as String, Rt as CloneOptions, S as MediaType, St as is_prelude_selectorlist, T as NthSelector, Tt as is_raw, U as TypeSelector, V as SupportsQuery, W as UnicodeRange, X as is_atrule_prelude, Y as is_atrule, Z as is_attribute_selector, _ as Identifier, _t as is_nth_selector, a as Block, at as is_feature_range, b as MediaFeature, bt as is_parenthesis, c as Combinator, ct as is_id_selector, d as Declaration, dt as is_layer_name, et as is_combinator, f as Dimension, ft as is_media_feature, g as IdSelector, gt as is_nth_of_selector, h as Hash, ht as is_nesting_selector, i as AttributeSelector, it as is_dimension, j as PseudoClassSelector, jt as is_supports_declaration, k as PreludeOperator, kt as is_string, l as Comment, lt as is_identifier, m as Function, mt as is_media_type, n as Atrule, nt as is_container_query, o as CSSNode, ot as is_function, p as FeatureRange, pt as is_media_query, q as Value, r as AtrulePrelude, rt as is_declaration, s as ClassSelector, st as is_hash, t as AnyNode, tt as is_comment, u as ContainerQuery, ut as is_lang_selector, v as LangSelector, vt as is_number, w as NthOfSelector, wt as is_pseudo_element_selector, x as MediaQuery, xt as is_prelude_operator, y as LayerName, yt as is_operator, z as StyleSheet, zt as PlainCSSNode } from "./node-types-DJytj0FB.js";
|
|
5
5
|
import { ParserOptions, parse } from "./parse.js";
|
|
6
6
|
import { parse_selector } from "./parse-selector.js";
|
|
7
7
|
import { parse_atrule_prelude } from "./parse-atrule-prelude.js";
|
|
@@ -75,4 +75,4 @@ declare function is_vendor_prefixed(source: string, start: number, end: number):
|
|
|
75
75
|
*/
|
|
76
76
|
declare function is_custom(str: string): boolean;
|
|
77
77
|
//#endregion
|
|
78
|
-
export { ATTRIBUTE_SELECTOR, AT_RULE, AT_RULE_PRELUDE, type AnyNode, type Atrule, type AtrulePrelude, type AttributeSelector, BLOCK, BREAK, type Block, CLASS_SELECTOR, COMBINATOR, COMMENT, CONTAINER_QUERY, type CSSNode, type ClassSelector, type CloneOptions, type Combinator, type Comment, type CommentInfo, type ContainerQuery, DECLARATION, DIMENSION, type Declaration, type Dimension, FEATURE_RANGE, FLAG_IMPORTANT, FUNCTION, type FeatureRange, type Function, HASH, type Hash, IDENTIFIER, ID_SELECTOR, type IdSelector, type Identifier, LANG_SELECTOR, LAYER_NAME, type LangSelector, type LayerName, type LexerPosition, MEDIA_FEATURE, MEDIA_QUERY, MEDIA_TYPE, type MediaFeature, type MediaQuery, type MediaType, NESTING_SELECTOR, NODE_TYPES, NTH_OF_SELECTOR, NTH_SELECTOR, NUMBER, type NestingSelector, type NthOfSelector, type NthSelector, type Number, OPERATOR, type Operator, PARENTHESIS, PRELUDE_OPERATOR, PSEUDO_CLASS_SELECTOR, PSEUDO_ELEMENT_SELECTOR, type Parenthesis, type ParserOptions, type PlainCSSNode, type PreludeOperator, type PreludeSelectorList, type PseudoClassSelector, type PseudoElementSelector, RAW, type Raw, type Rule, SELECTOR, SELECTOR_LIST, SKIP, STRING, STYLESHEET, STYLE_RULE, SUPPORTS_QUERY, type Selector, type SelectorList, type SelectorNode, type String, type StyleSheet, type SupportsQuery, TOKEN_AT_KEYWORD, TOKEN_BAD_STRING, TOKEN_BAD_URL, TOKEN_CDC, TOKEN_CDO, TOKEN_COLON, TOKEN_COMMA, TOKEN_COMMENT, TOKEN_DELIM, TOKEN_DIMENSION, TOKEN_EOF, TOKEN_FUNCTION, TOKEN_HASH, TOKEN_IDENT, TOKEN_LEFT_BRACE, TOKEN_LEFT_BRACKET, TOKEN_LEFT_PAREN, TOKEN_NUMBER, TOKEN_PERCENTAGE, TOKEN_RIGHT_BRACE, TOKEN_RIGHT_BRACKET, TOKEN_RIGHT_PAREN, TOKEN_SEMICOLON, TOKEN_STRING, TOKEN_UNICODE_RANGE, TOKEN_URL, TOKEN_WHITESPACE, TYPE_NAMES, TYPE_SELECTOR, type ToPlain, Token, TokenType, type TypeSelector, UNICODE_RANGE, UNIVERSAL_SELECTOR, URL, type UnicodeRange, type UniversalSelector, type Url, VALUE, type Value, type WithChildren, is_atrule, is_atrule_prelude, is_attribute_selector, is_block, is_class_selector, is_combinator, is_comment, is_container_query, is_custom, is_declaration, is_dimension, is_feature_range, is_function, is_hash, is_id_selector, is_identifier, is_lang_selector, is_layer_name, is_media_feature, is_media_query, is_media_type, is_nesting_selector, is_nth_of_selector, is_nth_selector, is_number, is_operator, is_parenthesis, is_prelude_operator, is_prelude_selectorlist, is_pseudo_class_selector, is_pseudo_element_selector, is_raw, is_rule, is_selector, is_selector_list, is_string, is_stylesheet, is_supports_query, is_type_selector, is_unicode_range, is_universal_selector, is_url, is_value, is_vendor_prefixed, parse, parse_atrule_prelude, parse_declaration, parse_dimension, parse_selector, parse_value, str_equals, str_index_of, str_starts_with, tokenize, traverse, walk };
|
|
78
|
+
export { ATTRIBUTE_SELECTOR, AT_RULE, AT_RULE_PRELUDE, type AnyNode, type Atrule, type AtrulePrelude, type AttributeSelector, BLOCK, BREAK, type Block, CLASS_SELECTOR, COMBINATOR, COMMENT, CONTAINER_QUERY, type CSSNode, type ClassSelector, type CloneOptions, type Combinator, type Comment, type CommentInfo, type ContainerQuery, DECLARATION, DIMENSION, type Declaration, type Dimension, FEATURE_RANGE, FLAG_IMPORTANT, FUNCTION, type FeatureRange, type Function, HASH, type Hash, IDENTIFIER, ID_SELECTOR, type IdSelector, type Identifier, LANG_SELECTOR, LAYER_NAME, type LangSelector, type LayerName, type LexerPosition, MEDIA_FEATURE, MEDIA_QUERY, MEDIA_TYPE, type MediaFeature, type MediaQuery, type MediaType, NESTING_SELECTOR, NODE_TYPES, NTH_OF_SELECTOR, NTH_SELECTOR, NUMBER, type NestingSelector, type NthOfSelector, type NthSelector, type Number, OPERATOR, type Operator, PARENTHESIS, PRELUDE_OPERATOR, PSEUDO_CLASS_SELECTOR, PSEUDO_ELEMENT_SELECTOR, type Parenthesis, type ParserOptions, type PlainCSSNode, type PreludeOperator, type PreludeSelectorList, type PseudoClassSelector, type PseudoElementSelector, RAW, type Raw, type Rule, SELECTOR, SELECTOR_LIST, SKIP, STRING, STYLESHEET, STYLE_RULE, SUPPORTS_DECLARATION, SUPPORTS_QUERY, type Selector, type SelectorList, type SelectorNode, type String, type StyleSheet, type SupportsDeclaration, type SupportsQuery, TOKEN_AT_KEYWORD, TOKEN_BAD_STRING, TOKEN_BAD_URL, TOKEN_CDC, TOKEN_CDO, TOKEN_COLON, TOKEN_COMMA, TOKEN_COMMENT, TOKEN_DELIM, TOKEN_DIMENSION, TOKEN_EOF, TOKEN_FUNCTION, TOKEN_HASH, TOKEN_IDENT, TOKEN_LEFT_BRACE, TOKEN_LEFT_BRACKET, TOKEN_LEFT_PAREN, TOKEN_NUMBER, TOKEN_PERCENTAGE, TOKEN_RIGHT_BRACE, TOKEN_RIGHT_BRACKET, TOKEN_RIGHT_PAREN, TOKEN_SEMICOLON, TOKEN_STRING, TOKEN_UNICODE_RANGE, TOKEN_URL, TOKEN_WHITESPACE, TYPE_NAMES, TYPE_SELECTOR, type ToPlain, Token, TokenType, type TypeSelector, UNICODE_RANGE, UNIVERSAL_SELECTOR, URL, type UnicodeRange, type UniversalSelector, type Url, VALUE, type Value, type WithChildren, is_atrule, is_atrule_prelude, is_attribute_selector, is_block, is_class_selector, is_combinator, is_comment, is_container_query, is_custom, is_declaration, is_dimension, is_feature_range, is_function, is_hash, is_id_selector, is_identifier, is_lang_selector, is_layer_name, is_media_feature, is_media_query, is_media_type, is_nesting_selector, is_nth_of_selector, is_nth_selector, is_number, is_operator, is_parenthesis, is_prelude_operator, is_prelude_selectorlist, is_pseudo_class_selector, is_pseudo_element_selector, is_raw, is_rule, is_selector, is_selector_list, is_string, is_stylesheet, is_supports_declaration, is_supports_query, is_type_selector, is_unicode_range, is_universal_selector, is_url, is_value, is_vendor_prefixed, parse, parse_atrule_prelude, parse_declaration, parse_dimension, parse_selector, parse_value, str_equals, str_index_of, str_starts_with, tokenize, traverse, walk };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { C as TOKEN_RIGHT_BRACKET, D as TOKEN_UNICODE_RANGE, E as TOKEN_STRING, O as TOKEN_URL, S as TOKEN_RIGHT_BRACE, T as TOKEN_SEMICOLON, _ as TOKEN_LEFT_BRACE, a as TOKEN_BAD_URL, b as TOKEN_NUMBER, c as TOKEN_COLON, d as TOKEN_DELIM, f as TOKEN_DIMENSION, g as TOKEN_IDENT, h as TOKEN_HASH, i as TOKEN_BAD_STRING, k as TOKEN_WHITESPACE, l as TOKEN_COMMA, m as TOKEN_FUNCTION, n as tokenize, o as TOKEN_CDC, p as TOKEN_EOF, r as TOKEN_AT_KEYWORD, s as TOKEN_CDO, u as TOKEN_COMMENT, v as TOKEN_LEFT_BRACKET, w as TOKEN_RIGHT_PAREN, x as TOKEN_PERCENTAGE, y as TOKEN_LEFT_PAREN } from "./tokenize-BSycRGm0.js";
|
|
2
|
-
import { A as PSEUDO_CLASS_SELECTOR, B as
|
|
2
|
+
import { A as PSEUDO_CLASS_SELECTOR, B as TYPE_SELECTOR, C as NESTING_SELECTOR, D as OPERATOR, E as NUMBER, F as STRING, H as UNIVERSAL_SELECTOR, I as STYLESHEET, L as STYLE_RULE, M as RAW, N as SELECTOR, O as PARENTHESIS, P as SELECTOR_LIST, R as SUPPORTS_DECLARATION, S as MEDIA_TYPE, T as NTH_SELECTOR, U as URL, V as UNICODE_RANGE, W as VALUE, _ as ID_SELECTOR, a as CLASS_SELECTOR, b as MEDIA_FEATURE, c as CONTAINER_QUERY, d as DIMENSION, f as FEATURE_RANGE, g as IDENTIFIER, h as HASH, i as BLOCK, j as PSEUDO_ELEMENT_SELECTOR, k as PRELUDE_OPERATOR, m as FUNCTION, n as AT_RULE, o as COMBINATOR, p as FLAG_IMPORTANT, r as AT_RULE_PRELUDE, s as COMMENT, t as ATTRIBUTE_SELECTOR, u as DECLARATION, v as LANG_SELECTOR, w as NTH_OF_SELECTOR, x as MEDIA_QUERY, y as LAYER_NAME, z as SUPPORTS_QUERY } from "./arena-DnV0a_Ne.js";
|
|
3
3
|
import { c as str_starts_with, i as is_vendor_prefixed, o as str_equals, r as is_custom, s as str_index_of, t as parse_dimension } from "./parse-dimension-CCn_XRDe.js";
|
|
4
|
-
import { n as TYPE_NAMES } from "./css-node-
|
|
4
|
+
import { n as TYPE_NAMES } from "./css-node-C3t4b8Jt.js";
|
|
5
5
|
import { parse_selector } from "./parse-selector.js";
|
|
6
6
|
import { parse_atrule_prelude } from "./parse-atrule-prelude.js";
|
|
7
7
|
import { parse_value } from "./parse-value.js";
|
|
@@ -124,6 +124,9 @@ function is_container_query(node) {
|
|
|
124
124
|
function is_supports_query(node) {
|
|
125
125
|
return node.type === 36;
|
|
126
126
|
}
|
|
127
|
+
function is_supports_declaration(node) {
|
|
128
|
+
return node.type === 57;
|
|
129
|
+
}
|
|
127
130
|
function is_layer_name(node) {
|
|
128
131
|
return node.type === 37;
|
|
129
132
|
}
|
|
@@ -137,4 +140,4 @@ function is_prelude_selectorlist(node) {
|
|
|
137
140
|
return node.type === 41;
|
|
138
141
|
}
|
|
139
142
|
//#endregion
|
|
140
|
-
export { ATTRIBUTE_SELECTOR, AT_RULE, AT_RULE_PRELUDE, BLOCK, BREAK, CLASS_SELECTOR, COMBINATOR, COMMENT, CONTAINER_QUERY, DECLARATION, DIMENSION, FEATURE_RANGE, FLAG_IMPORTANT, FUNCTION, HASH, IDENTIFIER, ID_SELECTOR, LANG_SELECTOR, LAYER_NAME, MEDIA_FEATURE, MEDIA_QUERY, MEDIA_TYPE, NESTING_SELECTOR, NODE_TYPES, NTH_OF_SELECTOR, NTH_SELECTOR, NUMBER, OPERATOR, PARENTHESIS, PRELUDE_OPERATOR, PSEUDO_CLASS_SELECTOR, PSEUDO_ELEMENT_SELECTOR, RAW, SELECTOR, SELECTOR_LIST, SKIP, STRING, STYLESHEET, STYLE_RULE, SUPPORTS_QUERY, TOKEN_AT_KEYWORD, TOKEN_BAD_STRING, TOKEN_BAD_URL, TOKEN_CDC, TOKEN_CDO, TOKEN_COLON, TOKEN_COMMA, TOKEN_COMMENT, TOKEN_DELIM, TOKEN_DIMENSION, TOKEN_EOF, TOKEN_FUNCTION, TOKEN_HASH, TOKEN_IDENT, TOKEN_LEFT_BRACE, TOKEN_LEFT_BRACKET, TOKEN_LEFT_PAREN, TOKEN_NUMBER, TOKEN_PERCENTAGE, TOKEN_RIGHT_BRACE, TOKEN_RIGHT_BRACKET, TOKEN_RIGHT_PAREN, TOKEN_SEMICOLON, TOKEN_STRING, TOKEN_UNICODE_RANGE, TOKEN_URL, TOKEN_WHITESPACE, TYPE_NAMES, TYPE_SELECTOR, UNICODE_RANGE, UNIVERSAL_SELECTOR, URL, VALUE, is_atrule, is_atrule_prelude, is_attribute_selector, is_block, is_class_selector, is_combinator, is_comment, is_container_query, is_custom, is_declaration, is_dimension, is_feature_range, is_function, is_hash, is_id_selector, is_identifier, is_lang_selector, is_layer_name, is_media_feature, is_media_query, is_media_type, is_nesting_selector, is_nth_of_selector, is_nth_selector, is_number, is_operator, is_parenthesis, is_prelude_operator, is_prelude_selectorlist, is_pseudo_class_selector, is_pseudo_element_selector, is_raw, is_rule, is_selector, is_selector_list, is_string, is_stylesheet, is_supports_query, is_type_selector, is_unicode_range, is_universal_selector, is_url, is_value, is_vendor_prefixed, parse, parse_atrule_prelude, parse_declaration, parse_dimension, parse_selector, parse_value, str_equals, str_index_of, str_starts_with, tokenize, traverse, walk };
|
|
143
|
+
export { ATTRIBUTE_SELECTOR, AT_RULE, AT_RULE_PRELUDE, BLOCK, BREAK, CLASS_SELECTOR, COMBINATOR, COMMENT, CONTAINER_QUERY, DECLARATION, DIMENSION, FEATURE_RANGE, FLAG_IMPORTANT, FUNCTION, HASH, IDENTIFIER, ID_SELECTOR, LANG_SELECTOR, LAYER_NAME, MEDIA_FEATURE, MEDIA_QUERY, MEDIA_TYPE, NESTING_SELECTOR, NODE_TYPES, NTH_OF_SELECTOR, NTH_SELECTOR, NUMBER, OPERATOR, PARENTHESIS, PRELUDE_OPERATOR, PSEUDO_CLASS_SELECTOR, PSEUDO_ELEMENT_SELECTOR, RAW, SELECTOR, SELECTOR_LIST, SKIP, STRING, STYLESHEET, STYLE_RULE, SUPPORTS_DECLARATION, SUPPORTS_QUERY, TOKEN_AT_KEYWORD, TOKEN_BAD_STRING, TOKEN_BAD_URL, TOKEN_CDC, TOKEN_CDO, TOKEN_COLON, TOKEN_COMMA, TOKEN_COMMENT, TOKEN_DELIM, TOKEN_DIMENSION, TOKEN_EOF, TOKEN_FUNCTION, TOKEN_HASH, TOKEN_IDENT, TOKEN_LEFT_BRACE, TOKEN_LEFT_BRACKET, TOKEN_LEFT_PAREN, TOKEN_NUMBER, TOKEN_PERCENTAGE, TOKEN_RIGHT_BRACE, TOKEN_RIGHT_BRACKET, TOKEN_RIGHT_PAREN, TOKEN_SEMICOLON, TOKEN_STRING, TOKEN_UNICODE_RANGE, TOKEN_URL, TOKEN_WHITESPACE, TYPE_NAMES, TYPE_SELECTOR, UNICODE_RANGE, UNIVERSAL_SELECTOR, URL, VALUE, is_atrule, is_atrule_prelude, is_attribute_selector, is_block, is_class_selector, is_combinator, is_comment, is_container_query, is_custom, is_declaration, is_dimension, is_feature_range, is_function, is_hash, is_id_selector, is_identifier, is_lang_selector, is_layer_name, is_media_feature, is_media_query, is_media_type, is_nesting_selector, is_nth_of_selector, is_nth_selector, is_number, is_operator, is_parenthesis, is_prelude_operator, is_prelude_selectorlist, is_pseudo_class_selector, is_pseudo_element_selector, is_raw, is_rule, is_selector, is_selector_list, is_string, is_stylesheet, is_supports_declaration, is_supports_query, is_type_selector, is_unicode_range, is_universal_selector, is_url, is_value, is_vendor_prefixed, parse, parse_atrule_prelude, parse_declaration, parse_dimension, parse_selector, parse_value, str_equals, str_index_of, str_starts_with, tokenize, traverse, walk };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as PRELUDE_SELECTORLIST, B as
|
|
1
|
+
import { A as PRELUDE_SELECTORLIST, B as SUPPORTS_QUERY, C as NESTING_SELECTOR, D as OPERATOR, E as NUMBER, F as SELECTOR_LIST, G as VALUE, H as UNICODE_RANGE, I as STRING, L as STYLESHEET, M as PSEUDO_ELEMENT_SELECTOR, N as RAW, O as PARENTHESIS, P as SELECTOR, R as STYLE_RULE, S as MEDIA_TYPE, T as NTH_SELECTOR, U as UNIVERSAL_SELECTOR, V as TYPE_SELECTOR, W as URL, _ as ID_SELECTOR, a as CLASS_SELECTOR, b as MEDIA_FEATURE, c as CONTAINER_QUERY, d as DIMENSION, f as FEATURE_RANGE, g as IDENTIFIER, h as HASH, i as BLOCK, j as PSEUDO_CLASS_SELECTOR, k as PRELUDE_OPERATOR, m as FUNCTION, n as AT_RULE, o as COMBINATOR, r as AT_RULE_PRELUDE, s as COMMENT, t as ATTRIBUTE_SELECTOR, u as DECLARATION, v as LANG_SELECTOR, w as NTH_OF_SELECTOR, x as MEDIA_QUERY, y as LAYER_NAME, z as SUPPORTS_DECLARATION } from "./arena-CSK5NfHq.js";
|
|
2
2
|
|
|
3
3
|
//#region src/css-node.d.ts
|
|
4
4
|
declare const TYPE_NAMES: {
|
|
@@ -39,6 +39,7 @@ declare const TYPE_NAMES: {
|
|
|
39
39
|
readonly 34: "MediaType";
|
|
40
40
|
readonly 35: "ContainerQuery";
|
|
41
41
|
readonly 36: "SupportsQuery";
|
|
42
|
+
readonly 57: "SupportsDeclaration";
|
|
42
43
|
readonly 37: "Layer";
|
|
43
44
|
readonly 38: "Operator";
|
|
44
45
|
readonly 39: "MediaFeatureRange";
|
|
@@ -46,7 +47,7 @@ declare const TYPE_NAMES: {
|
|
|
46
47
|
readonly 41: "PreludeSelectorList";
|
|
47
48
|
};
|
|
48
49
|
type TypeName = (typeof TYPE_NAMES)[keyof typeof TYPE_NAMES] | 'unknown';
|
|
49
|
-
type CSSNodeType = typeof STYLESHEET | typeof STYLE_RULE | typeof AT_RULE | typeof DECLARATION | typeof SELECTOR | typeof COMMENT | typeof BLOCK | typeof RAW | typeof IDENTIFIER | typeof NUMBER | typeof DIMENSION | typeof STRING | typeof HASH | typeof FUNCTION | typeof OPERATOR | typeof PARENTHESIS | typeof URL | typeof UNICODE_RANGE | typeof VALUE | typeof SELECTOR_LIST | typeof TYPE_SELECTOR | typeof CLASS_SELECTOR | typeof ID_SELECTOR | typeof ATTRIBUTE_SELECTOR | typeof PSEUDO_CLASS_SELECTOR | typeof PSEUDO_ELEMENT_SELECTOR | typeof COMBINATOR | typeof UNIVERSAL_SELECTOR | typeof NESTING_SELECTOR | typeof NTH_SELECTOR | typeof NTH_OF_SELECTOR | typeof LANG_SELECTOR | typeof MEDIA_QUERY | typeof MEDIA_FEATURE | typeof MEDIA_TYPE | typeof CONTAINER_QUERY | typeof SUPPORTS_QUERY | typeof LAYER_NAME | typeof PRELUDE_OPERATOR | typeof FEATURE_RANGE | typeof AT_RULE_PRELUDE | typeof PRELUDE_SELECTORLIST;
|
|
50
|
+
type CSSNodeType = typeof STYLESHEET | typeof STYLE_RULE | typeof AT_RULE | typeof DECLARATION | typeof SELECTOR | typeof COMMENT | typeof BLOCK | typeof RAW | typeof IDENTIFIER | typeof NUMBER | typeof DIMENSION | typeof STRING | typeof HASH | typeof FUNCTION | typeof OPERATOR | typeof PARENTHESIS | typeof URL | typeof UNICODE_RANGE | typeof VALUE | typeof SELECTOR_LIST | typeof TYPE_SELECTOR | typeof CLASS_SELECTOR | typeof ID_SELECTOR | typeof ATTRIBUTE_SELECTOR | typeof PSEUDO_CLASS_SELECTOR | typeof PSEUDO_ELEMENT_SELECTOR | typeof COMBINATOR | typeof UNIVERSAL_SELECTOR | typeof NESTING_SELECTOR | typeof NTH_SELECTOR | typeof NTH_OF_SELECTOR | typeof LANG_SELECTOR | typeof MEDIA_QUERY | typeof MEDIA_FEATURE | typeof MEDIA_TYPE | typeof CONTAINER_QUERY | typeof SUPPORTS_QUERY | typeof LAYER_NAME | typeof PRELUDE_OPERATOR | typeof FEATURE_RANGE | typeof AT_RULE_PRELUDE | typeof PRELUDE_SELECTORLIST | typeof SUPPORTS_DECLARATION;
|
|
50
51
|
interface CloneOptions {
|
|
51
52
|
/**
|
|
52
53
|
* Recursively clone all children
|
|
@@ -148,7 +149,6 @@ type StyleSheet = CSSNode & WithChildren & {
|
|
|
148
149
|
};
|
|
149
150
|
type Rule = CSSNode & {
|
|
150
151
|
readonly type: typeof STYLE_RULE;
|
|
151
|
-
readonly name: string;
|
|
152
152
|
readonly has_declarations: boolean;
|
|
153
153
|
clone(options?: CloneOptions): ToPlain<Rule>;
|
|
154
154
|
} & /** SELECTOR_LIST (parse_selectors=true) or RAW (parse_selectors=false) */({
|
|
@@ -199,9 +199,27 @@ type SelectorList = CSSNode & WithChildren<Selector> & {
|
|
|
199
199
|
readonly type: typeof SELECTOR_LIST;
|
|
200
200
|
clone(options?: CloneOptions): ToPlain<SelectorList>;
|
|
201
201
|
};
|
|
202
|
+
/**
|
|
203
|
+
* A node that appears as a direct child of a Block.
|
|
204
|
+
*
|
|
205
|
+
* Identical to `Raw | Declaration | Atrule | Rule` except that `next_sibling`
|
|
206
|
+
* is narrowed to the same union instead of the generic `CSSNode`. This is
|
|
207
|
+
* safe because none of these four types use WithChildren themselves, so
|
|
208
|
+
* there is no recursive type graph to trigger TS2589.
|
|
209
|
+
*/
|
|
210
|
+
type BlockChild = (Raw | Declaration | Atrule | Rule) & ({
|
|
211
|
+
readonly has_next: false;
|
|
212
|
+
readonly next_sibling: null;
|
|
213
|
+
} | {
|
|
214
|
+
readonly has_next: true;
|
|
215
|
+
readonly next_sibling: Raw | Declaration | Atrule | Rule;
|
|
216
|
+
});
|
|
202
217
|
type Block = CSSNode & WithChildren<Raw | Declaration | Atrule | Rule> & {
|
|
203
218
|
readonly type: typeof BLOCK;
|
|
204
|
-
readonly is_empty: boolean;
|
|
219
|
+
readonly is_empty: boolean; /** Block children with next_sibling narrowed to the Block child union. */
|
|
220
|
+
readonly first_child: BlockChild;
|
|
221
|
+
readonly children: BlockChild[];
|
|
222
|
+
[Symbol.iterator](): Iterator<BlockChild>;
|
|
205
223
|
clone(options?: CloneOptions): ToPlain<Block>;
|
|
206
224
|
};
|
|
207
225
|
type Comment = CSSNode & {
|
|
@@ -266,8 +284,9 @@ type Value = CSSNode & WithChildren<ValueLike> & {
|
|
|
266
284
|
clone(options?: CloneOptions): ToPlain<Value>;
|
|
267
285
|
};
|
|
268
286
|
type TypeSelector = CSSNode & {
|
|
269
|
-
readonly type: typeof TYPE_SELECTOR; /**
|
|
270
|
-
readonly name: string;
|
|
287
|
+
readonly type: typeof TYPE_SELECTOR; /** Local element name, e.g. "div" in both "div" and "ns|div" */
|
|
288
|
+
readonly name: string; /** Namespace prefix: null if no qualifier, '' for |div, 'ns' for ns|div, '*' for *|div */
|
|
289
|
+
readonly namespace: string | null;
|
|
271
290
|
clone(options?: CloneOptions): ToPlain<TypeSelector>;
|
|
272
291
|
};
|
|
273
292
|
type ClassSelector = CSSNode & {
|
|
@@ -304,8 +323,9 @@ type Combinator = CSSNode & {
|
|
|
304
323
|
clone(options?: CloneOptions): ToPlain<Combinator>;
|
|
305
324
|
};
|
|
306
325
|
type UniversalSelector = CSSNode & {
|
|
307
|
-
readonly type: typeof UNIVERSAL_SELECTOR; /**
|
|
308
|
-
readonly name:
|
|
326
|
+
readonly type: typeof UNIVERSAL_SELECTOR; /** Always null — universal selector has no element name */
|
|
327
|
+
readonly name: null; /** Namespace prefix: null if no qualifier, '' for |*, 'ns' for ns|*, '*' for *|* */
|
|
328
|
+
readonly namespace: string | null;
|
|
309
329
|
clone(options?: CloneOptions): ToPlain<UniversalSelector>;
|
|
310
330
|
};
|
|
311
331
|
type NestingSelector = CSSNode & {
|
|
@@ -337,9 +357,10 @@ type MediaQuery = CSSNode & WithChildren<MediaFeature | PreludeOperator | MediaT
|
|
|
337
357
|
readonly type: typeof MEDIA_QUERY;
|
|
338
358
|
clone(options?: CloneOptions): ToPlain<MediaQuery>;
|
|
339
359
|
};
|
|
340
|
-
type MediaFeature = CSSNode &
|
|
360
|
+
type MediaFeature = CSSNode & {
|
|
341
361
|
readonly type: typeof MEDIA_FEATURE; /** Feature name, e.g. "min-width" */
|
|
342
|
-
readonly property: string;
|
|
362
|
+
readonly property: string; /** Feature value node, or null for boolean features like (hover) */
|
|
363
|
+
readonly value: CSSNode | null;
|
|
343
364
|
clone(options?: CloneOptions): ToPlain<MediaFeature>;
|
|
344
365
|
};
|
|
345
366
|
type MediaType = CSSNode & {
|
|
@@ -351,11 +372,15 @@ type ContainerQuery = CSSNode & WithChildren<Identifier | MediaFeature | Functio
|
|
|
351
372
|
readonly type: typeof CONTAINER_QUERY;
|
|
352
373
|
clone(options?: CloneOptions): ToPlain<ContainerQuery>;
|
|
353
374
|
};
|
|
354
|
-
type SupportsQuery = CSSNode & {
|
|
375
|
+
type SupportsQuery = CSSNode & WithChildren<SupportsDeclaration> & {
|
|
355
376
|
readonly type: typeof SUPPORTS_QUERY; /** The supports condition text, e.g. "display: flex" from "supports(display: flex)" */
|
|
356
377
|
readonly value: string;
|
|
357
378
|
clone(options?: CloneOptions): ToPlain<SupportsQuery>;
|
|
358
379
|
};
|
|
380
|
+
type SupportsDeclaration = CSSNode & WithChildren<Declaration> & {
|
|
381
|
+
readonly type: typeof SUPPORTS_DECLARATION;
|
|
382
|
+
clone(options?: CloneOptions): ToPlain<SupportsDeclaration>;
|
|
383
|
+
};
|
|
359
384
|
type LayerName = CSSNode & {
|
|
360
385
|
readonly type: typeof LAYER_NAME;
|
|
361
386
|
readonly name: string; /** Alias for name — the layer name string, e.g. "base" from "layer(base)" */
|
|
@@ -392,7 +417,7 @@ type FeatureRange = CSSNode & WithChildren<Dimension | Operator> & {
|
|
|
392
417
|
readonly name: string;
|
|
393
418
|
clone(options?: CloneOptions): ToPlain<FeatureRange>;
|
|
394
419
|
};
|
|
395
|
-
type AnyNode = StyleSheet | Rule | Atrule | Declaration | Selector | SelectorList | Block | Comment | Raw | Identifier | Number | Dimension | String | Hash | Function | Operator | Parenthesis | Url | UnicodeRange | Value | TypeSelector | ClassSelector | IdSelector | AttributeSelector | PseudoClassSelector | PseudoElementSelector | Combinator | UniversalSelector | NestingSelector | NthSelector | NthOfSelector | LangSelector | AtrulePrelude | MediaQuery | MediaFeature | MediaType | ContainerQuery | SupportsQuery | LayerName | PreludeOperator | FeatureRange | PreludeSelectorList;
|
|
420
|
+
type AnyNode = StyleSheet | Rule | Atrule | Declaration | Selector | SelectorList | Block | Comment | Raw | Identifier | Number | Dimension | String | Hash | Function | Operator | Parenthesis | Url | UnicodeRange | Value | TypeSelector | ClassSelector | IdSelector | AttributeSelector | PseudoClassSelector | PseudoElementSelector | Combinator | UniversalSelector | NestingSelector | NthSelector | NthOfSelector | LangSelector | AtrulePrelude | MediaQuery | MediaFeature | MediaType | ContainerQuery | SupportsQuery | SupportsDeclaration | LayerName | PreludeOperator | FeatureRange | PreludeSelectorList;
|
|
396
421
|
declare function is_stylesheet(node: CSSNode): node is StyleSheet;
|
|
397
422
|
declare function is_rule(node: CSSNode): node is Rule;
|
|
398
423
|
declare function is_atrule(node: CSSNode): node is Atrule;
|
|
@@ -431,9 +456,10 @@ declare function is_media_feature(node: CSSNode): node is MediaFeature;
|
|
|
431
456
|
declare function is_media_type(node: CSSNode): node is MediaType;
|
|
432
457
|
declare function is_container_query(node: CSSNode): node is ContainerQuery;
|
|
433
458
|
declare function is_supports_query(node: CSSNode): node is SupportsQuery;
|
|
459
|
+
declare function is_supports_declaration(node: CSSNode): node is SupportsDeclaration;
|
|
434
460
|
declare function is_layer_name(node: CSSNode): node is LayerName;
|
|
435
461
|
declare function is_prelude_operator(node: CSSNode): node is PreludeOperator;
|
|
436
462
|
declare function is_feature_range(node: CSSNode): node is FeatureRange;
|
|
437
463
|
declare function is_prelude_selectorlist(node: CSSNode): node is PreludeSelectorList;
|
|
438
464
|
//#endregion
|
|
439
|
-
export {
|
|
465
|
+
export { is_class_selector as $, PreludeSelectorList as A, is_stylesheet as At, SupportsDeclaration as B, TYPE_NAMES as Bt, NestingSelector as C, is_pseudo_class_selector as Ct, Operator as D, is_selector as Dt, Number as E, is_rule as Et, Selector as F, is_universal_selector as Ft, UniversalSelector as G, ToPlain as H, SelectorList as I, is_url as It, WithChildren as J, Url as K, SelectorNode as L, is_value as Lt, PseudoElementSelector as M, is_supports_query as Mt, Raw as N, is_type_selector as Nt, Parenthesis as O, is_selector_list as Ot, Rule as P, is_unicode_range as Pt, is_block as Q, String as R, CloneOptions as Rt, MediaType as S, is_prelude_selectorlist as St, NthSelector as T, is_raw as Tt, TypeSelector as U, SupportsQuery as V, UnicodeRange as W, is_atrule_prelude as X, is_atrule as Y, is_attribute_selector as Z, Identifier as _, is_nth_selector as _t, Block as a, is_feature_range as at, MediaFeature as b, is_parenthesis as bt, Combinator as c, is_id_selector as ct, Declaration as d, is_layer_name as dt, is_combinator as et, Dimension as f, is_media_feature as ft, IdSelector as g, is_nth_of_selector as gt, Hash as h, is_nesting_selector as ht, AttributeSelector as i, is_dimension as it, PseudoClassSelector as j, is_supports_declaration as jt, PreludeOperator as k, is_string as kt, Comment as l, is_identifier as lt, Function as m, is_media_type as mt, Atrule as n, is_container_query as nt, CSSNode as o, is_function as ot, FeatureRange as p, is_media_query as pt, Value as q, AtrulePrelude as r, is_declaration as rt, ClassSelector as s, is_hash as st, AnyNode as t, is_comment as tt, ContainerQuery as u, is_lang_selector as ut, LangSelector as v, is_number as vt, NthOfSelector as w, is_pseudo_element_selector as wt, MediaQuery as x, is_prelude_operator as xt, LayerName as y, is_operator as yt, StyleSheet as z, PlainCSSNode as zt };
|
package/dist/parse-anplusb.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { l as CSSDataArena } from "./arena-
|
|
2
|
-
import { T as NthSelector } from "./node-types-
|
|
1
|
+
import { l as CSSDataArena } from "./arena-CSK5NfHq.js";
|
|
2
|
+
import { T as NthSelector } from "./node-types-DJytj0FB.js";
|
|
3
3
|
|
|
4
4
|
//#region src/parse-anplusb.d.ts
|
|
5
5
|
/** @internal */
|
package/dist/parse-anplusb.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as Lexer } from "./tokenize-BSycRGm0.js";
|
|
2
|
-
import { l as CSSDataArena } from "./arena-
|
|
2
|
+
import { l as CSSDataArena } from "./arena-DnV0a_Ne.js";
|
|
3
3
|
import { o as str_equals, s as str_index_of } from "./parse-dimension-CCn_XRDe.js";
|
|
4
|
-
import { t as CSSNode } from "./css-node-
|
|
4
|
+
import { t as CSSNode } from "./css-node-C3t4b8Jt.js";
|
|
5
5
|
//#region src/parse-anplusb.ts
|
|
6
6
|
/** @internal */
|
|
7
7
|
var ANplusBParser = class {
|
|
@@ -58,7 +58,7 @@ var ANplusBParser = class {
|
|
|
58
58
|
b_start = this.lexer.token_start;
|
|
59
59
|
b_end = this.lexer.token_end;
|
|
60
60
|
}
|
|
61
|
-
return this.create_anplusb_node(node_start, a_start, a_end, b
|
|
61
|
+
return this.create_anplusb_node(node_start, a_start, a_end, b === null ? 0 : b_start, b === null ? 0 : b_end);
|
|
62
62
|
}
|
|
63
63
|
if (first_char === 110) {
|
|
64
64
|
if (this.lexer.token_end > this.lexer.token_start + 1) {
|
|
@@ -78,7 +78,7 @@ var ANplusBParser = class {
|
|
|
78
78
|
b_start = this.lexer.token_start;
|
|
79
79
|
b_end = this.lexer.token_end;
|
|
80
80
|
}
|
|
81
|
-
return this.create_anplusb_node(node_start, a_start, a_end, b
|
|
81
|
+
return this.create_anplusb_node(node_start, a_start, a_end, b === null ? 0 : b_start, b === null ? 0 : b_end);
|
|
82
82
|
}
|
|
83
83
|
return null;
|
|
84
84
|
}
|
|
@@ -102,7 +102,7 @@ var ANplusBParser = class {
|
|
|
102
102
|
b_start = this.lexer.token_start;
|
|
103
103
|
b_end = this.lexer.token_end;
|
|
104
104
|
}
|
|
105
|
-
return this.create_anplusb_node(node_start, a_start, a_end, b
|
|
105
|
+
return this.create_anplusb_node(node_start, a_start, a_end, b === null ? 0 : b_start, b === null ? 0 : b_end);
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
this.lexer.restore_position(saved);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { l as CSSDataArena } from "./arena-
|
|
2
|
-
import { t as AnyNode } from "./node-types-
|
|
1
|
+
import { l as CSSDataArena } from "./arena-CSK5NfHq.js";
|
|
2
|
+
import { t as AnyNode } from "./node-types-DJytj0FB.js";
|
|
3
3
|
|
|
4
4
|
//#region src/parse-atrule-prelude.d.ts
|
|
5
5
|
/** @internal */
|
|
@@ -18,6 +18,8 @@ declare class AtRulePreludeParser {
|
|
|
18
18
|
private parse_media_feature;
|
|
19
19
|
private parse_container_query;
|
|
20
20
|
private parse_supports_query;
|
|
21
|
+
private find_colon_at_depth_zero;
|
|
22
|
+
private create_supports_declaration;
|
|
21
23
|
private parse_layer_names;
|
|
22
24
|
private parse_function_prelude;
|
|
23
25
|
private parse_identifier;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as Lexer } from "./tokenize-BSycRGm0.js";
|
|
2
|
-
import { l as CSSDataArena } from "./arena-
|
|
2
|
+
import { l as CSSDataArena } from "./arena-DnV0a_Ne.js";
|
|
3
3
|
import { a as is_whitespace, l as strip_vendor_prefix, o as str_equals } from "./parse-dimension-CCn_XRDe.js";
|
|
4
|
-
import { t as CSSNode } from "./css-node-
|
|
4
|
+
import { t as CSSNode } from "./css-node-C3t4b8Jt.js";
|
|
5
5
|
import { i as trim_boundaries, n as skip_whitespace_and_comments_forward } from "./parse-utils-BxrmqJxI.js";
|
|
6
6
|
//#region src/parse-atrule-prelude.ts
|
|
7
7
|
/** @internal */
|
|
@@ -138,7 +138,13 @@ var AtRulePreludeParser = class {
|
|
|
138
138
|
}
|
|
139
139
|
j++;
|
|
140
140
|
}
|
|
141
|
-
if (colon_pos
|
|
141
|
+
if (colon_pos === -1) {
|
|
142
|
+
let trimmed = trim_boundaries(this.source, content_start, content_end);
|
|
143
|
+
if (trimmed) {
|
|
144
|
+
this.arena.set_content_start_delta(feature, trimmed[0] - feature_start);
|
|
145
|
+
this.arena.set_content_length(feature, trimmed[1] - trimmed[0]);
|
|
146
|
+
}
|
|
147
|
+
} else {
|
|
142
148
|
let name_trimmed = trim_boundaries(this.source, content_start, colon_pos);
|
|
143
149
|
if (name_trimmed) {
|
|
144
150
|
this.arena.set_content_start_delta(feature, name_trimmed[0] - feature_start);
|
|
@@ -149,12 +155,6 @@ var AtRulePreludeParser = class {
|
|
|
149
155
|
let value_nodes = this.parse_feature_value(value_trimmed[0], value_trimmed[1]);
|
|
150
156
|
if (value_nodes.length > 0) this.arena.append_children(feature, value_nodes);
|
|
151
157
|
}
|
|
152
|
-
} else {
|
|
153
|
-
let trimmed = trim_boundaries(this.source, content_start, content_end);
|
|
154
|
-
if (trimmed) {
|
|
155
|
-
this.arena.set_content_start_delta(feature, trimmed[0] - feature_start);
|
|
156
|
-
this.arena.set_content_length(feature, trimmed[1] - trimmed[0]);
|
|
157
|
-
}
|
|
158
158
|
}
|
|
159
159
|
return feature;
|
|
160
160
|
}
|
|
@@ -237,6 +237,11 @@ var AtRulePreludeParser = class {
|
|
|
237
237
|
if (trimmed) {
|
|
238
238
|
this.arena.set_value_start_delta(query, trimmed[0] - feature_start);
|
|
239
239
|
this.arena.set_value_length(query, trimmed[1] - trimmed[0]);
|
|
240
|
+
let colon_pos = this.find_colon_at_depth_zero(trimmed[0], trimmed[1]);
|
|
241
|
+
if (colon_pos !== -1) {
|
|
242
|
+
let decl_child = this.create_supports_declaration(trimmed[0], trimmed[1], colon_pos);
|
|
243
|
+
this.arena.append_children(query, [decl_child]);
|
|
244
|
+
}
|
|
240
245
|
}
|
|
241
246
|
nodes.push(query);
|
|
242
247
|
}
|
|
@@ -250,6 +255,39 @@ var AtRulePreludeParser = class {
|
|
|
250
255
|
}
|
|
251
256
|
return nodes;
|
|
252
257
|
}
|
|
258
|
+
find_colon_at_depth_zero(start, end) {
|
|
259
|
+
let depth = 0;
|
|
260
|
+
for (let i = start; i < end; i++) {
|
|
261
|
+
let ch = this.source.charCodeAt(i);
|
|
262
|
+
if (ch === 40) depth++;
|
|
263
|
+
else if (ch === 41) depth--;
|
|
264
|
+
else if (ch === 58 && depth === 0) return i;
|
|
265
|
+
}
|
|
266
|
+
return -1;
|
|
267
|
+
}
|
|
268
|
+
create_supports_declaration(content_start, content_end, colon_pos) {
|
|
269
|
+
let prop_trimmed = trim_boundaries(this.source, content_start, colon_pos);
|
|
270
|
+
let val_trimmed = trim_boundaries(this.source, colon_pos + 1, content_end);
|
|
271
|
+
if (!prop_trimmed) return this.create_node(57, content_start, content_end);
|
|
272
|
+
let decl_start = prop_trimmed[0];
|
|
273
|
+
let decl_end = val_trimmed ? val_trimmed[1] : colon_pos + 1;
|
|
274
|
+
let decl = this.create_node(4, decl_start, decl_end);
|
|
275
|
+
this.arena.set_content_start_delta(decl, 0);
|
|
276
|
+
this.arena.set_content_length(decl, prop_trimmed[1] - prop_trimmed[0]);
|
|
277
|
+
if (val_trimmed) {
|
|
278
|
+
let value_nodes = this.parse_feature_value(val_trimmed[0], val_trimmed[1]);
|
|
279
|
+
let value_node;
|
|
280
|
+
if (value_nodes.length === 0) value_node = this.arena.create_node(50, val_trimmed[0], 0, this.lexer.token_line, this.lexer.token_column);
|
|
281
|
+
else {
|
|
282
|
+
value_node = this.arena.create_node(50, val_trimmed[0], val_trimmed[1] - val_trimmed[0], this.lexer.token_line, this.lexer.token_column);
|
|
283
|
+
this.arena.append_children(value_node, value_nodes);
|
|
284
|
+
}
|
|
285
|
+
this.arena.append_children(decl, [value_node]);
|
|
286
|
+
}
|
|
287
|
+
let supports_decl = this.create_node(57, content_start, content_end);
|
|
288
|
+
this.arena.append_children(supports_decl, [decl]);
|
|
289
|
+
return supports_decl;
|
|
290
|
+
}
|
|
253
291
|
parse_layer_names() {
|
|
254
292
|
let nodes = [];
|
|
255
293
|
while (this.lexer.pos < this.prelude_end) {
|
|
@@ -295,8 +333,8 @@ var AtRulePreludeParser = class {
|
|
|
295
333
|
this.skip_whitespace();
|
|
296
334
|
if (this.lexer.pos >= this.prelude_end) return [];
|
|
297
335
|
let url_node = this.parse_import_url();
|
|
298
|
-
if (url_node
|
|
299
|
-
|
|
336
|
+
if (url_node === null) return [];
|
|
337
|
+
nodes.push(url_node);
|
|
300
338
|
this.skip_whitespace();
|
|
301
339
|
if (this.lexer.pos >= this.prelude_end) return nodes;
|
|
302
340
|
let layer_node = this.parse_import_layer();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { l as CSSDataArena } from "./arena-
|
|
1
|
+
import { l as CSSDataArena } from "./arena-CSK5NfHq.js";
|
|
2
2
|
import { n as Lexer } from "./tokenize-CyiJelQC.js";
|
|
3
|
-
import { d as Declaration } from "./node-types-
|
|
3
|
+
import { d as Declaration } from "./node-types-DJytj0FB.js";
|
|
4
4
|
|
|
5
5
|
//#region src/parse-declaration.d.ts
|
|
6
6
|
/** @internal */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as Lexer } from "./tokenize-BSycRGm0.js";
|
|
2
|
-
import { l as CSSDataArena } from "./arena-
|
|
2
|
+
import { l as CSSDataArena } from "./arena-DnV0a_Ne.js";
|
|
3
3
|
import { i as is_vendor_prefixed } from "./parse-dimension-CCn_XRDe.js";
|
|
4
|
-
import { t as CSSNode } from "./css-node-
|
|
4
|
+
import { t as CSSNode } from "./css-node-C3t4b8Jt.js";
|
|
5
5
|
import { i as trim_boundaries } from "./parse-utils-BxrmqJxI.js";
|
|
6
6
|
import { ValueParser } from "./parse-value.js";
|
|
7
7
|
//#region src/parse-declaration.ts
|
package/dist/parse-selector.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { l as CSSDataArena } from "./arena-
|
|
2
|
-
import { I as SelectorList } from "./node-types-
|
|
1
|
+
import { l as CSSDataArena } from "./arena-CSK5NfHq.js";
|
|
2
|
+
import { I as SelectorList } from "./node-types-DJytj0FB.js";
|
|
3
3
|
|
|
4
4
|
//#region src/parse-selector.d.ts
|
|
5
5
|
/** @internal */
|
package/dist/parse-selector.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as Lexer } from "./tokenize-BSycRGm0.js";
|
|
2
|
-
import { l as CSSDataArena } from "./arena-
|
|
2
|
+
import { l as CSSDataArena } from "./arena-DnV0a_Ne.js";
|
|
3
3
|
import { a as is_whitespace, n as is_combinator, o as str_equals } from "./parse-dimension-CCn_XRDe.js";
|
|
4
|
-
import { t as CSSNode } from "./css-node-
|
|
4
|
+
import { t as CSSNode } from "./css-node-C3t4b8Jt.js";
|
|
5
5
|
import { n as skip_whitespace_and_comments_forward, r as skip_whitespace_forward, t as skip_whitespace_and_comments_backward } from "./parse-utils-BxrmqJxI.js";
|
|
6
6
|
import { ANplusBParser } from "./parse-anplusb.js";
|
|
7
7
|
//#region src/parse-selector.ts
|
|
@@ -53,7 +53,7 @@ var SelectorParser = class {
|
|
|
53
53
|
continue;
|
|
54
54
|
} else break;
|
|
55
55
|
}
|
|
56
|
-
if (selectors.length
|
|
56
|
+
if (selectors.length > 0) {
|
|
57
57
|
let list_node = this.arena.create_node(20, list_start, this.lexer.pos - list_start, list_line, list_column);
|
|
58
58
|
this.arena.append_children(list_node, selectors);
|
|
59
59
|
return list_node;
|
|
@@ -77,8 +77,8 @@ var SelectorParser = class {
|
|
|
77
77
|
}
|
|
78
78
|
while (this.lexer.pos < this.selector_end) {
|
|
79
79
|
let compound = this.parse_compound_selector();
|
|
80
|
-
if (compound
|
|
81
|
-
|
|
80
|
+
if (compound === null) break;
|
|
81
|
+
components.push(compound);
|
|
82
82
|
let combinator = this.try_parse_combinator();
|
|
83
83
|
if (combinator !== null) {
|
|
84
84
|
components.push(combinator);
|
|
@@ -115,11 +115,11 @@ var SelectorParser = class {
|
|
|
115
115
|
if (this.lexer.token_start >= this.selector_end) break;
|
|
116
116
|
if (this.lexer.token_type === 26) break;
|
|
117
117
|
let part = this.parse_simple_selector();
|
|
118
|
-
if (part
|
|
119
|
-
else {
|
|
118
|
+
if (part === null) {
|
|
120
119
|
this.lexer.restore_position(saved);
|
|
121
120
|
break;
|
|
122
121
|
}
|
|
122
|
+
parts.push(part);
|
|
123
123
|
}
|
|
124
124
|
if (parts.length === 0) return null;
|
|
125
125
|
for (let i = 0; i < parts.length - 1; i++) this.arena.set_next_sibling(parts[i], parts[i + 1]);
|
|
@@ -132,13 +132,14 @@ var SelectorParser = class {
|
|
|
132
132
|
switch (token_type) {
|
|
133
133
|
case 1: return this.parse_type_or_namespace_selector(start, end);
|
|
134
134
|
case 4: return this.create_node(23, start, end);
|
|
135
|
-
case 9:
|
|
135
|
+
case 9: {
|
|
136
136
|
let ch = this.source.charCodeAt(start);
|
|
137
137
|
if (ch === 46) return this.parse_class_selector(start);
|
|
138
138
|
else if (ch === 42) return this.parse_universal_or_namespace_selector(start, end);
|
|
139
139
|
else if (ch === 38) return this.create_node(29, start, end);
|
|
140
140
|
else if (ch === 124) return this.parse_empty_namespace_selector(start);
|
|
141
141
|
return null;
|
|
142
|
+
}
|
|
142
143
|
case 19: return this.parse_attribute_selector(start);
|
|
143
144
|
case 16: return this.parse_pseudo(start);
|
|
144
145
|
case 2: return this.parse_pseudo_function(start, end);
|
|
@@ -148,7 +149,7 @@ var SelectorParser = class {
|
|
|
148
149
|
default: return null;
|
|
149
150
|
}
|
|
150
151
|
}
|
|
151
|
-
parse_namespace_local_part(selector_start, namespace_start,
|
|
152
|
+
parse_namespace_local_part(selector_start, namespace_start, namespace_prefix_length) {
|
|
152
153
|
const saved = this.lexer.save_position();
|
|
153
154
|
this.lexer.next_token_fast(false);
|
|
154
155
|
let node_type;
|
|
@@ -158,9 +159,14 @@ var SelectorParser = class {
|
|
|
158
159
|
this.lexer.restore_position(saved);
|
|
159
160
|
return null;
|
|
160
161
|
}
|
|
161
|
-
let
|
|
162
|
-
this.
|
|
163
|
-
this.
|
|
162
|
+
let local_start = this.lexer.token_start;
|
|
163
|
+
let local_end = this.lexer.token_end;
|
|
164
|
+
let node = this.create_node(node_type, selector_start, local_end);
|
|
165
|
+
this.arena.set_flag(node, 16);
|
|
166
|
+
this.arena.set_content_start_delta(node, local_start - selector_start);
|
|
167
|
+
this.arena.set_content_length(node, local_end - local_start);
|
|
168
|
+
this.arena.set_value_start_delta(node, namespace_start - selector_start);
|
|
169
|
+
this.arena.set_value_length(node, namespace_prefix_length);
|
|
164
170
|
return node;
|
|
165
171
|
}
|
|
166
172
|
parse_type_or_namespace_selector(start, end) {
|
|
@@ -171,8 +177,8 @@ var SelectorParser = class {
|
|
|
171
177
|
this.lexer.pos++;
|
|
172
178
|
let node = this.parse_namespace_local_part(start, start, end - start);
|
|
173
179
|
if (node !== null) return node;
|
|
174
|
-
|
|
175
|
-
|
|
180
|
+
}
|
|
181
|
+
this.lexer.restore_position(saved);
|
|
176
182
|
return this.create_node(21, start, end);
|
|
177
183
|
}
|
|
178
184
|
parse_universal_or_namespace_selector(start, end) {
|
|
@@ -182,12 +188,12 @@ var SelectorParser = class {
|
|
|
182
188
|
this.lexer.pos++;
|
|
183
189
|
let node = this.parse_namespace_local_part(start, start, end - start);
|
|
184
190
|
if (node !== null) return node;
|
|
185
|
-
|
|
186
|
-
|
|
191
|
+
}
|
|
192
|
+
this.lexer.restore_position(saved);
|
|
187
193
|
return this.create_node(28, start, end);
|
|
188
194
|
}
|
|
189
195
|
parse_empty_namespace_selector(start) {
|
|
190
|
-
return this.parse_namespace_local_part(start, start,
|
|
196
|
+
return this.parse_namespace_local_part(start, start, 0);
|
|
191
197
|
}
|
|
192
198
|
try_parse_combinator() {
|
|
193
199
|
const saved_whitespace_start = this.lexer.save_position();
|
|
@@ -287,14 +293,11 @@ var SelectorParser = class {
|
|
|
287
293
|
if (c === 92) pos += 2;
|
|
288
294
|
else pos++;
|
|
289
295
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
if (is_whitespace(this.source.charCodeAt(pos))) break;
|
|
294
|
-
pos++;
|
|
295
|
-
}
|
|
296
|
-
value_end = pos;
|
|
296
|
+
} else while (pos < end) {
|
|
297
|
+
if (is_whitespace(this.source.charCodeAt(pos))) break;
|
|
298
|
+
pos++;
|
|
297
299
|
}
|
|
300
|
+
value_end = pos;
|
|
298
301
|
if (value_end > value_start) {
|
|
299
302
|
this.arena.set_value_start_delta(node, value_start - this.arena.get_start_offset(node));
|
|
300
303
|
this.arena.set_value_length(node, value_end - value_start);
|
|
@@ -398,24 +401,24 @@ var SelectorParser = class {
|
|
|
398
401
|
}
|
|
399
402
|
parse_nth_expression(start, end) {
|
|
400
403
|
let of_index = this.find_of_keyword(start, end);
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
404
|
+
let anplusb_parser = new ANplusBParser(this.arena, this.source);
|
|
405
|
+
if (of_index === -1) return anplusb_parser.parse_anplusb(start, end, this.lexer.line);
|
|
406
|
+
let anplusb_node = anplusb_parser.parse_anplusb(start, of_index, this.lexer.line);
|
|
407
|
+
let selector_start = of_index + 2;
|
|
408
|
+
selector_start = skip_whitespace_forward(this.source, selector_start, end);
|
|
409
|
+
let saved_selector_end = this.selector_end;
|
|
410
|
+
const saved = this.lexer.save_position();
|
|
411
|
+
this.selector_end = end;
|
|
412
|
+
this.lexer.pos = selector_start;
|
|
413
|
+
let selector_list = this.parse_selector_list();
|
|
414
|
+
this.selector_end = saved_selector_end;
|
|
415
|
+
this.lexer.restore_position(saved);
|
|
416
|
+
let of_node = this.arena.create_node(31, start, end - start, this.lexer.line, 1);
|
|
417
|
+
if (anplusb_node !== null && selector_list !== null) {
|
|
418
|
+
this.arena.set_first_child(of_node, anplusb_node);
|
|
419
|
+
this.arena.set_next_sibling(anplusb_node, selector_list);
|
|
420
|
+
} else if (anplusb_node !== null) this.arena.set_first_child(of_node, anplusb_node);
|
|
421
|
+
return of_node;
|
|
419
422
|
}
|
|
420
423
|
find_of_keyword(start, end) {
|
|
421
424
|
let i = start;
|
package/dist/parse-value.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { l as CSSDataArena } from "./arena-
|
|
2
|
-
import {
|
|
1
|
+
import { l as CSSDataArena } from "./arena-CSK5NfHq.js";
|
|
2
|
+
import { q as Value } from "./node-types-DJytj0FB.js";
|
|
3
3
|
|
|
4
4
|
//#region src/parse-value.d.ts
|
|
5
5
|
/** @internal */
|
package/dist/parse-value.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as Lexer } from "./tokenize-BSycRGm0.js";
|
|
2
|
-
import { l as CSSDataArena } from "./arena-
|
|
2
|
+
import { l as CSSDataArena } from "./arena-DnV0a_Ne.js";
|
|
3
3
|
import { a as is_whitespace, o as str_equals } from "./parse-dimension-CCn_XRDe.js";
|
|
4
|
-
import { t as CSSNode } from "./css-node-
|
|
4
|
+
import { t as CSSNode } from "./css-node-C3t4b8Jt.js";
|
|
5
5
|
//#region src/parse-value.ts
|
|
6
6
|
/** @internal */
|
|
7
7
|
var ValueParser = class {
|
|
@@ -21,7 +21,7 @@ var ValueParser = class {
|
|
|
21
21
|
let value_nodes = this.parse_value_tokens();
|
|
22
22
|
if (value_nodes.length === 0) return this.arena.create_node(50, start, 0, start_line, start_column);
|
|
23
23
|
let first_node_start = this.arena.get_start_offset(value_nodes[0]);
|
|
24
|
-
let last_node_index = value_nodes
|
|
24
|
+
let last_node_index = value_nodes.at(-1);
|
|
25
25
|
let last_node_end = this.arena.get_start_offset(last_node_index) + this.arena.get_length(last_node_index);
|
|
26
26
|
let value_node = this.arena.create_node(50, first_node_start, last_node_end - first_node_start, start_line, start_column);
|
|
27
27
|
this.arena.append_children(value_node, value_nodes);
|
package/dist/parse.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { l as CSSDataArena } from "./arena-
|
|
1
|
+
import { l as CSSDataArena } from "./arena-CSK5NfHq.js";
|
|
2
2
|
import { t as CommentInfo } from "./tokenize-CyiJelQC.js";
|
|
3
|
-
import { z as StyleSheet } from "./node-types-
|
|
3
|
+
import { z as StyleSheet } from "./node-types-DJytj0FB.js";
|
|
4
4
|
|
|
5
5
|
//#region src/parse.d.ts
|
|
6
6
|
interface ParserOptions {
|
package/dist/parse.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as Lexer } from "./tokenize-BSycRGm0.js";
|
|
2
|
-
import { l as CSSDataArena } from "./arena-
|
|
3
|
-
import { t as CSSNode } from "./css-node-
|
|
2
|
+
import { l as CSSDataArena } from "./arena-DnV0a_Ne.js";
|
|
3
|
+
import { t as CSSNode } from "./css-node-C3t4b8Jt.js";
|
|
4
4
|
import { i as trim_boundaries } from "./parse-utils-BxrmqJxI.js";
|
|
5
5
|
import { SelectorParser } from "./parse-selector.js";
|
|
6
6
|
import { AtRulePreludeParser } from "./parse-atrule-prelude.js";
|
|
@@ -35,7 +35,8 @@ var Parser = class {
|
|
|
35
35
|
this.parse_selectors_enabled = opts.parse_selectors ?? true;
|
|
36
36
|
this.parse_atrule_preludes_enabled = opts.parse_atrule_preludes ?? true;
|
|
37
37
|
this.lexer = new Lexer(source, opts.on_comment);
|
|
38
|
-
|
|
38
|
+
let capacity = CSSDataArena.capacity_for_source(source.length);
|
|
39
|
+
this.arena = new CSSDataArena(capacity);
|
|
39
40
|
this.selector_parser = this.parse_selectors_enabled ? new SelectorParser(this.arena, source) : null;
|
|
40
41
|
this.prelude_parser = this.parse_atrule_preludes_enabled ? new AtRulePreludeParser(this.arena, source) : null;
|
|
41
42
|
this.declaration_parser = new DeclarationParser(this.arena, source, this.parse_values_enabled);
|
|
@@ -61,8 +62,8 @@ var Parser = class {
|
|
|
61
62
|
let rules = [];
|
|
62
63
|
while (!this.is_eof()) {
|
|
63
64
|
let rule = this.parse_rule();
|
|
64
|
-
if (rule
|
|
65
|
-
else
|
|
65
|
+
if (rule === null) this.next_token();
|
|
66
|
+
else rules.push(rule);
|
|
66
67
|
}
|
|
67
68
|
this.arena.append_children(stylesheet, rules);
|
|
68
69
|
return new CSSNode(this.arena, this.source, stylesheet);
|
|
@@ -92,8 +93,8 @@ var Parser = class {
|
|
|
92
93
|
if (token_type === 24) break;
|
|
93
94
|
if (token_type === 3) {
|
|
94
95
|
let nested_at_rule = this.parse_atrule();
|
|
95
|
-
if (nested_at_rule
|
|
96
|
-
else
|
|
96
|
+
if (nested_at_rule === null) this.next_token();
|
|
97
|
+
else block_children.push(nested_at_rule);
|
|
97
98
|
continue;
|
|
98
99
|
}
|
|
99
100
|
let declaration = this.parse_declaration();
|
|
@@ -103,8 +104,8 @@ var Parser = class {
|
|
|
103
104
|
continue;
|
|
104
105
|
}
|
|
105
106
|
let nested_rule = this.parse_style_rule();
|
|
106
|
-
if (nested_rule
|
|
107
|
-
else
|
|
107
|
+
if (nested_rule === null) this.next_token();
|
|
108
|
+
else block_children.push(nested_rule);
|
|
108
109
|
}
|
|
109
110
|
let block_end = this.lexer.token_start;
|
|
110
111
|
let rule_end = this.lexer.token_end;
|
|
@@ -195,16 +196,16 @@ var Parser = class {
|
|
|
195
196
|
if (has_declarations) while (!this.is_eof()) {
|
|
196
197
|
if (this.peek_type() === 24) break;
|
|
197
198
|
let declaration = this.parse_declaration();
|
|
198
|
-
if (declaration
|
|
199
|
-
else
|
|
199
|
+
if (declaration === null) this.next_token();
|
|
200
|
+
else block_children.push(declaration);
|
|
200
201
|
}
|
|
201
202
|
else while (!this.is_eof()) {
|
|
202
203
|
let token_type = this.peek_type();
|
|
203
204
|
if (token_type === 24) break;
|
|
204
205
|
if (token_type === 3) {
|
|
205
206
|
let nested_at_rule = this.parse_atrule();
|
|
206
|
-
if (nested_at_rule
|
|
207
|
-
else
|
|
207
|
+
if (nested_at_rule === null) this.next_token();
|
|
208
|
+
else block_children.push(nested_at_rule);
|
|
208
209
|
continue;
|
|
209
210
|
}
|
|
210
211
|
let declaration = this.parse_declaration();
|
|
@@ -213,8 +214,8 @@ var Parser = class {
|
|
|
213
214
|
continue;
|
|
214
215
|
}
|
|
215
216
|
let nested_rule = this.parse_style_rule();
|
|
216
|
-
if (nested_rule
|
|
217
|
-
else
|
|
217
|
+
if (nested_rule === null) this.next_token();
|
|
218
|
+
else block_children.push(nested_rule);
|
|
218
219
|
}
|
|
219
220
|
if (this.peek_type() === 24) {
|
|
220
221
|
let block_end = this.lexer.token_start;
|
|
@@ -228,12 +229,11 @@ var Parser = class {
|
|
|
228
229
|
at_rule_children.push(block_node);
|
|
229
230
|
this.arena.set_length(at_rule, last_end - at_rule_start);
|
|
230
231
|
this.arena.append_children(at_rule, at_rule_children);
|
|
231
|
-
} else if (this.peek_type() === 17) {
|
|
232
|
-
last_end = this.lexer.token_end;
|
|
233
|
-
this.next_token();
|
|
234
|
-
this.arena.set_length(at_rule, last_end - at_rule_start);
|
|
235
|
-
if (prelude_wrapper !== null) this.arena.append_children(at_rule, [prelude_wrapper]);
|
|
236
232
|
} else {
|
|
233
|
+
if (this.peek_type() === 17) {
|
|
234
|
+
last_end = this.lexer.token_end;
|
|
235
|
+
this.next_token();
|
|
236
|
+
}
|
|
237
237
|
this.arena.set_length(at_rule, last_end - at_rule_start);
|
|
238
238
|
if (prelude_wrapper !== null) this.arena.append_children(at_rule, [prelude_wrapper]);
|
|
239
239
|
}
|
package/dist/walk.d.ts
CHANGED
package/dist/walk.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@projectwallace/css-parser",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "High-performance CSS lexer and parser, optimized for CSS inspection and analysis",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ast",
|
|
@@ -83,22 +83,22 @@
|
|
|
83
83
|
"precommit": "npm run test -- --run; npm run lint; npm run check"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
|
-
"@codecov/rollup-plugin": "^
|
|
87
|
-
"@projectwallace/preset-oxlint": "^0.0.
|
|
86
|
+
"@codecov/rollup-plugin": "^2.0.1",
|
|
87
|
+
"@projectwallace/preset-oxlint": "^0.0.10",
|
|
88
88
|
"@types/node": "^24.10.1",
|
|
89
|
-
"@vitest/coverage-v8": "^4.
|
|
89
|
+
"@vitest/coverage-v8": "^4.1.5",
|
|
90
90
|
"bootstrap": "^5.3.8",
|
|
91
91
|
"css-tree": "^3.1.0",
|
|
92
|
-
"knip": "^6.0
|
|
93
|
-
"oxfmt": "^0.
|
|
94
|
-
"oxlint": "^1.
|
|
92
|
+
"knip": "^6.11.0",
|
|
93
|
+
"oxfmt": "^0.47.0",
|
|
94
|
+
"oxlint": "^1.62.0",
|
|
95
95
|
"postcss": "^8.5.6",
|
|
96
96
|
"publint": "^0.3.18",
|
|
97
97
|
"tailwindcss": "^2.2.8",
|
|
98
|
-
"tinybench": "^6.0.
|
|
98
|
+
"tinybench": "^6.0.1",
|
|
99
99
|
"tsdown": "^0.21.0",
|
|
100
|
-
"typescript": "^6.0.
|
|
101
|
-
"vitest": "^4.
|
|
100
|
+
"typescript": "^6.0.3",
|
|
101
|
+
"vitest": "^4.1.5"
|
|
102
102
|
},
|
|
103
103
|
"issues": "https://github.com/projectwallace/css-parser/issues"
|
|
104
104
|
}
|