@projectwallace/css-parser 0.16.2 → 0.18.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@projectwallace/css-parser",
3
- "version": "0.16.2",
3
+ "version": "0.18.0",
4
4
  "description": "High-performance CSS lexer and parser, optimized for CSS inspection and analysis",
5
5
  "keywords": [
6
6
  "ast",
@@ -20,6 +20,7 @@
20
20
  "dist"
21
21
  ],
22
22
  "type": "module",
23
+ "sideEffects": false,
23
24
  "main": "./dist/index.js",
24
25
  "module": "./dist/index.js",
25
26
  "types": "./dist/index.d.ts",
@@ -75,20 +76,20 @@
75
76
  "provenance": true
76
77
  },
77
78
  "devDependencies": {
78
- "@projectwallace/preset-oxlint": "^0.0.10",
79
- "@types/node": "^24.10.1",
79
+ "@projectwallace/preset-oxlint": "^0.0.11",
80
+ "@types/node": "^26.1.1",
80
81
  "@vitest/coverage-v8": "^4.1.9",
81
82
  "bootstrap": "^5.3.8",
82
83
  "css-tree": "^3.1.0",
83
84
  "knip": "^6.18.0",
84
- "oxfmt": "^0.56.0",
85
+ "oxfmt": "^0.59.0",
85
86
  "oxlint": "^1.71.0",
86
87
  "postcss": "^8.5.15",
87
88
  "publint": "^0.3.21",
88
89
  "tailwindcss": "^2.2.8",
89
90
  "tinybench": "^6.0.2",
90
91
  "tsdown": "^0.22.3",
91
- "typescript": "^6.0.3",
92
+ "typescript": "^7.0.2",
92
93
  "vite": "^8.0.16",
93
94
  "vitest": "^4.1.9"
94
95
  },
@@ -105,6 +106,6 @@
105
106
  "lint": "oxlint --config .oxlintrc.json && oxfmt --check",
106
107
  "check": "tsc --noEmit",
107
108
  "knip": "knip",
108
- "precommit": "pnpm run test -- --run; pnpm run lint; pnpm run check"
109
+ "precommit": "pnpm run test --run; pnpm run lint; pnpm run check"
109
110
  }
110
111
  }
@@ -1,508 +0,0 @@
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-DfpuGV9Y.js";
2
-
3
- //#region src/css-node.d.ts
4
- declare const TYPE_NAMES: {
5
- readonly 1: "StyleSheet";
6
- readonly 2: "Rule";
7
- readonly 3: "Atrule";
8
- readonly 4: "Declaration";
9
- readonly 5: "Selector";
10
- readonly 6: "Comment";
11
- readonly 7: "Block";
12
- readonly 8: "Raw";
13
- readonly 10: "Identifier";
14
- readonly 11: "Number";
15
- readonly 12: "Dimension";
16
- readonly 13: "String";
17
- readonly 14: "Hash";
18
- readonly 15: "Function";
19
- readonly 16: "Operator";
20
- readonly 17: "Parentheses";
21
- readonly 18: "Url";
22
- readonly 19: "UnicodeRange";
23
- readonly 50: "Value";
24
- readonly 20: "SelectorList";
25
- readonly 21: "TypeSelector";
26
- readonly 22: "ClassSelector";
27
- readonly 23: "IdSelector";
28
- readonly 24: "AttributeSelector";
29
- readonly 25: "PseudoClassSelector";
30
- readonly 26: "PseudoElementSelector";
31
- readonly 27: "Combinator";
32
- readonly 28: "UniversalSelector";
33
- readonly 29: "NestingSelector";
34
- readonly 30: "Nth";
35
- readonly 31: "NthOf";
36
- readonly 56: "Lang";
37
- readonly 32: "MediaQuery";
38
- readonly 33: "Feature";
39
- readonly 34: "MediaType";
40
- readonly 35: "ContainerQuery";
41
- readonly 36: "SupportsQuery";
42
- readonly 57: "SupportsDeclaration";
43
- readonly 37: "Layer";
44
- readonly 38: "Operator";
45
- readonly 39: "MediaFeatureRange";
46
- readonly 40: "AtrulePrelude";
47
- readonly 41: "PreludeSelectorList";
48
- };
49
- type TypeName = (typeof TYPE_NAMES)[keyof typeof TYPE_NAMES] | 'unknown';
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;
51
- interface CloneOptions {
52
- /**
53
- * Recursively clone all children
54
- * @default true
55
- */
56
- deep?: boolean;
57
- /**
58
- * Include location information (line, column, start, length)
59
- * @default false
60
- */
61
- locations?: boolean;
62
- }
63
- type PlainCSSNode = {
64
- type: number;
65
- type_name: TypeName;
66
- text: string;
67
- children?: PlainCSSNode[];
68
- child_count?: number;
69
- has_children?: boolean;
70
- name?: string;
71
- property?: string;
72
- value?: PlainCSSNode | string | number | null;
73
- unit?: string;
74
- prelude?: PlainCSSNode | null;
75
- is_important?: boolean;
76
- is_vendor_prefixed?: boolean;
77
- is_browserhack?: boolean;
78
- has_error?: boolean;
79
- attr_operator?: string | null;
80
- attr_flags?: string | null;
81
- nth_a?: string | null;
82
- nth_b?: string | null;
83
- line?: number;
84
- column?: number;
85
- start?: number;
86
- length?: number;
87
- end?: number;
88
- };
89
- //#endregion
90
- //#region src/node-types.d.ts
91
- type CSSNode = {
92
- readonly type: CSSNodeType;
93
- readonly type_name: TypeName;
94
- readonly text: string;
95
- readonly has_error: boolean;
96
- readonly is_vendor_prefixed: boolean;
97
- readonly line: number;
98
- readonly column: number;
99
- readonly start: number;
100
- readonly length: number;
101
- readonly end: number;
102
- readonly first_child: CSSNode | null;
103
- clone(options?: CloneOptions): PlainCSSNode;
104
- } & ({
105
- readonly has_next: false;
106
- readonly next_sibling: null;
107
- } | {
108
- readonly has_next: true;
109
- readonly next_sibling: CSSNode;
110
- });
111
- /**
112
- * Mixin for node types that have child nodes.
113
- *
114
- * Only a subset of node types expose children — structural and container nodes
115
- * like StyleSheet, Block, SelectorList, Value, Function, etc. Leaf nodes
116
- * (Identifier, Number, Dimension, …) do not extend WithChildren, reflecting
117
- * that they never carry child nodes in a well-formed tree.
118
- */
119
- interface WithChildren<T = AnyNode> {
120
- readonly has_children: boolean;
121
- readonly child_count: number;
122
- readonly children: T[];
123
- readonly first_child: T;
124
- [Symbol.iterator](): Iterator<T>;
125
- }
126
- /**
127
- * Maps a CssNodeCommon subtype interface to its plain-object equivalent,
128
- * as returned by clone().
129
- *
130
- * The result is always a subtype of PlainCSSNode (the intersection starts
131
- * with PlainCSSNode), with two additions:
132
- * - `type` is narrowed to T's specific literal (enables discriminated unions)
133
- * - subtype-specific properties (those not on CssNodeCommon) are added with
134
- * CssNodeCommon references replaced by PlainCSSNode
135
- *
136
- * Traversal properties (first_child, next_sibling, etc.) are excluded since
137
- * they live on CssNodeCommon and are never serialised by clone().
138
- *
139
- * const rule = root.first_child as Rule
140
- * rule.clone().prelude // PlainCSSNode | null — not PlainCSSNode | undefined
141
- * rule.clone().block // PlainCSSNode | null
142
- */
143
- type ToPlain<T extends CSSNode> = PlainCSSNode & {
144
- type: T['type'];
145
- } & { [K in Exclude<keyof T, keyof CSSNode | symbol | 'attr_operator' | 'attr_flags' | 'has_children' | 'child_count' | 'children'> as T[K] extends ((...args: any[]) => any) ? never : K]: T[K] extends CSSNode | null | undefined ? PlainCSSNode | Exclude<T[K], CSSNode> : T[K] extends CSSNode[] ? PlainCSSNode[] : T[K] };
146
- type StyleSheet = CSSNode & WithChildren & {
147
- readonly type: typeof STYLESHEET;
148
- readonly type_name: 'StyleSheet';
149
- clone(options?: CloneOptions): ToPlain<StyleSheet>;
150
- };
151
- type Rule = CSSNode & {
152
- readonly type: typeof STYLE_RULE;
153
- readonly type_name: 'Rule';
154
- readonly has_declarations: boolean;
155
- clone(options?: CloneOptions): ToPlain<Rule>;
156
- } & /** SELECTOR_LIST (parse_selectors=true) or RAW (parse_selectors=false) */({
157
- readonly has_prelude: true;
158
- readonly prelude: SelectorList | Raw;
159
- } | {
160
- readonly has_prelude: false;
161
- readonly prelude: null;
162
- }) & ({
163
- readonly has_block: true;
164
- readonly block: Block;
165
- } | {
166
- readonly has_block: false;
167
- readonly block: null;
168
- });
169
- type Atrule = CSSNode & {
170
- readonly type: typeof AT_RULE;
171
- readonly type_name: 'Atrule'; /** At-rule keyword, e.g. "media", "keyframes" */
172
- readonly name: string;
173
- readonly has_declarations: boolean;
174
- clone(options?: CloneOptions): ToPlain<Atrule>;
175
- } & /** AT_RULE_PRELUDE (parse_atrule_preludes=true) or RAW (parse_atrule_preludes=false) */({
176
- readonly has_prelude: true;
177
- readonly prelude: AtrulePrelude | Raw;
178
- } | {
179
- readonly has_prelude: false;
180
- readonly prelude: null;
181
- }) & ({
182
- readonly has_block: true;
183
- readonly block: Block;
184
- } | {
185
- readonly has_block: false;
186
- readonly block: null;
187
- });
188
- type Declaration = CSSNode & {
189
- readonly type: typeof DECLARATION;
190
- readonly type_name: 'Declaration'; /** Property name, e.g. "color" */
191
- readonly property: string; /** VALUE node (parse_values=true), RAW node (parse_values=false), or null */
192
- readonly value: Value | Raw | null;
193
- readonly is_important: boolean;
194
- readonly is_browserhack: boolean;
195
- clone(options?: CloneOptions): ToPlain<Declaration>;
196
- };
197
- type SelectorNode = TypeSelector | IdSelector | ClassSelector | NthSelector | NthOfSelector | LangSelector | NestingSelector | AttributeSelector | UniversalSelector | PseudoClassSelector | PseudoElementSelector;
198
- type Selector = CSSNode & WithChildren<SelectorNode> & {
199
- readonly type: typeof SELECTOR;
200
- readonly type_name: 'Selector';
201
- clone(options?: CloneOptions): ToPlain<Selector>;
202
- };
203
- type SelectorList = CSSNode & WithChildren<Selector> & {
204
- readonly type: typeof SELECTOR_LIST;
205
- readonly type_name: 'SelectorList';
206
- clone(options?: CloneOptions): ToPlain<SelectorList>;
207
- };
208
- /**
209
- * A node that appears as a direct child of a Block.
210
- *
211
- * Identical to `Raw | Declaration | Atrule | Rule` except that `next_sibling`
212
- * is narrowed to the same union instead of the generic `CSSNode`. This is
213
- * safe because none of these four types use WithChildren themselves, so
214
- * there is no recursive type graph to trigger TS2589.
215
- */
216
- type BlockChild = (Raw | Declaration | Atrule | Rule) & ({
217
- readonly has_next: false;
218
- readonly next_sibling: null;
219
- } | {
220
- readonly has_next: true;
221
- readonly next_sibling: Raw | Declaration | Atrule | Rule;
222
- });
223
- type Block = CSSNode & WithChildren<Raw | Declaration | Atrule | Rule> & {
224
- readonly type: typeof BLOCK;
225
- readonly type_name: 'Block';
226
- readonly is_empty: boolean; /** Block children with next_sibling narrowed to the Block child union. */
227
- readonly first_child: BlockChild;
228
- readonly children: BlockChild[];
229
- [Symbol.iterator](): Iterator<BlockChild>;
230
- clone(options?: CloneOptions): ToPlain<Block>;
231
- };
232
- type Comment = CSSNode & {
233
- readonly type: typeof COMMENT;
234
- readonly type_name: 'Comment';
235
- clone(options?: CloneOptions): ToPlain<Comment>;
236
- };
237
- type Raw = CSSNode & {
238
- readonly type: typeof RAW;
239
- readonly type_name: 'Raw';
240
- clone(options?: CloneOptions): ToPlain<Raw>;
241
- };
242
- type ValueLike = Function | Identifier | Operator | Parenthesis | Url | UnicodeRange | String | Hash | Dimension | Number;
243
- type Identifier = CSSNode & {
244
- readonly type: typeof IDENTIFIER;
245
- readonly type_name: 'Identifier';
246
- readonly name: string;
247
- clone(options?: CloneOptions): ToPlain<Identifier>;
248
- };
249
- type Number = CSSNode & {
250
- readonly type: typeof NUMBER;
251
- readonly type_name: 'Number';
252
- readonly value: number;
253
- clone(options?: CloneOptions): ToPlain<Number>;
254
- };
255
- type Dimension = CSSNode & {
256
- readonly type: typeof DIMENSION;
257
- readonly type_name: 'Dimension';
258
- readonly value: number; /** Unit string, e.g. "px", "%" */
259
- readonly unit: string;
260
- clone(options?: CloneOptions): ToPlain<Dimension>;
261
- };
262
- type String = CSSNode & {
263
- readonly type: typeof STRING;
264
- readonly type_name: 'String';
265
- clone(options?: CloneOptions): ToPlain<String>;
266
- };
267
- type Hash = CSSNode & {
268
- readonly type: typeof HASH;
269
- readonly type_name: 'Hash';
270
- clone(options?: CloneOptions): ToPlain<Hash>;
271
- };
272
- type Function = CSSNode & WithChildren<ValueLike> & {
273
- readonly type: typeof FUNCTION;
274
- readonly type_name: 'Function'; /** Function name, e.g. "rgb", "calc" */
275
- readonly name: string; /** Function arguments as raw text, e.g. "255, 0, 0" for rgb(255, 0, 0) */
276
- readonly value: string | null;
277
- clone(options?: CloneOptions): ToPlain<Function>;
278
- };
279
- type Operator = CSSNode & {
280
- readonly type: typeof OPERATOR;
281
- readonly type_name: 'Operator'; /** The operator character(s), e.g. ",", "+", "-" */
282
- readonly value: string;
283
- clone(options?: CloneOptions): ToPlain<Operator>;
284
- };
285
- type Parenthesis = CSSNode & WithChildren & {
286
- readonly type: typeof PARENTHESIS;
287
- readonly type_name: 'Parentheses';
288
- clone(options?: CloneOptions): ToPlain<Parenthesis>;
289
- };
290
- type Url = CSSNode & {
291
- readonly type: typeof URL;
292
- readonly type_name: 'Url'; /** URL content, e.g. '"image.png"' (with quotes) or 'mycursor.cur' (unquoted) */
293
- readonly value: string | null;
294
- clone(options?: CloneOptions): ToPlain<Url>;
295
- };
296
- type UnicodeRange = CSSNode & {
297
- readonly type: typeof UNICODE_RANGE;
298
- readonly type_name: 'UnicodeRange';
299
- clone(options?: CloneOptions): ToPlain<UnicodeRange>;
300
- };
301
- type Value = CSSNode & WithChildren<ValueLike> & {
302
- readonly type: typeof VALUE;
303
- readonly type_name: 'Value';
304
- clone(options?: CloneOptions): ToPlain<Value>;
305
- };
306
- type TypeSelector = CSSNode & {
307
- readonly type: typeof TYPE_SELECTOR;
308
- readonly type_name: 'TypeSelector'; /** Local element name, e.g. "div" in both "div" and "ns|div" */
309
- readonly name: string; /** Namespace prefix: null if no qualifier, '' for |div, 'ns' for ns|div, '*' for *|div */
310
- readonly namespace: string | null;
311
- clone(options?: CloneOptions): ToPlain<TypeSelector>;
312
- };
313
- type ClassSelector = CSSNode & {
314
- readonly type: typeof CLASS_SELECTOR;
315
- readonly type_name: 'ClassSelector'; /** Class name without dot, e.g. "foo" from ".foo" */
316
- readonly name: string;
317
- clone(options?: CloneOptions): ToPlain<ClassSelector>;
318
- };
319
- type IdSelector = CSSNode & {
320
- readonly type: typeof ID_SELECTOR;
321
- readonly type_name: 'IdSelector'; /** Id without hash, e.g. "bar" from "#bar" */
322
- readonly name: string;
323
- clone(options?: CloneOptions): ToPlain<IdSelector>;
324
- };
325
- type AttributeSelector = CSSNode & {
326
- readonly type: typeof ATTRIBUTE_SELECTOR;
327
- readonly type_name: 'AttributeSelector'; /** Attribute name, e.g. "href" from "[href]" */
328
- readonly name: string; /** Operator string, e.g. "=", "~=", "|="; null if no operator ([attr] form) */
329
- readonly attr_operator: string | null; /** Flag character, e.g. "i", "s"; null if no flag */
330
- readonly attr_flags: string | null; /** Attribute value, e.g. "external" from [rel="external"] */
331
- readonly value: string | null;
332
- clone(options?: CloneOptions): ToPlain<AttributeSelector>;
333
- };
334
- type PseudoClassSelector = CSSNode & WithChildren<Selector | NthOfSelector> & {
335
- readonly type: typeof PSEUDO_CLASS_SELECTOR;
336
- readonly type_name: 'PseudoClassSelector'; /** Pseudo-class name without colon, e.g. "hover" */
337
- readonly name: string;
338
- clone(options?: CloneOptions): ToPlain<PseudoClassSelector>;
339
- };
340
- type PseudoElementSelector = CSSNode & WithChildren<SelectorList> & {
341
- readonly type: typeof PSEUDO_ELEMENT_SELECTOR;
342
- readonly type_name: 'PseudoElementSelector'; /** Pseudo-element name without colons, e.g. "before" */
343
- readonly name: string;
344
- clone(options?: CloneOptions): ToPlain<PseudoElementSelector>;
345
- };
346
- type Combinator = CSSNode & {
347
- readonly type: typeof COMBINATOR;
348
- readonly type_name: 'Combinator'; /** Combinator character(s), e.g. " ", ">", "~", "+", "||", "/deep/" */
349
- readonly name: string;
350
- clone(options?: CloneOptions): ToPlain<Combinator>;
351
- };
352
- type UniversalSelector = CSSNode & {
353
- readonly type: typeof UNIVERSAL_SELECTOR;
354
- readonly type_name: 'UniversalSelector'; /** Always null — universal selector has no element name */
355
- readonly name: null; /** Namespace prefix: null if no qualifier, '' for |*, 'ns' for ns|*, '*' for *|* */
356
- readonly namespace: string | null;
357
- clone(options?: CloneOptions): ToPlain<UniversalSelector>;
358
- };
359
- type NestingSelector = CSSNode & {
360
- readonly type: typeof NESTING_SELECTOR;
361
- readonly type_name: 'NestingSelector';
362
- clone(options?: CloneOptions): ToPlain<NestingSelector>;
363
- };
364
- type NthSelector = CSSNode & {
365
- readonly type: typeof NTH_SELECTOR;
366
- readonly type_name: 'Nth'; /** The `An` part of the An+B formula, including keywords `odd`/`even`. Null when only a B value is present (e.g. `:nth-child(3)`). */
367
- readonly nth_a: string | null; /** The `+B` part of the An+B formula. Null when only an A value is present (e.g. `:nth-child(2n)` or `:nth-child(odd)`). */
368
- readonly nth_b: string | null;
369
- clone(options?: CloneOptions): ToPlain<NthSelector>;
370
- };
371
- type NthOfSelector = CSSNode & {
372
- readonly type: typeof NTH_OF_SELECTOR;
373
- readonly type_name: 'NthOf'; /** The An+B formula node */
374
- readonly nth: NthSelector | null; /** The selector list from :nth-child(An+B of <selector>) */
375
- readonly selector: SelectorList | null;
376
- clone(options?: CloneOptions): ToPlain<NthOfSelector>;
377
- };
378
- type LangSelector = CSSNode & {
379
- readonly type: typeof LANG_SELECTOR;
380
- readonly type_name: 'Lang'; /** `"nl"`, `en-US` */
381
- readonly name: string | null;
382
- clone(options?: CloneOptions): ToPlain<LangSelector>;
383
- };
384
- type AtrulePrelude = CSSNode & WithChildren<Raw | MediaQuery | MediaType | ContainerQuery | SupportsQuery | LayerName | PreludeOperator | PreludeSelectorList | Parenthesis | Url> & {
385
- readonly type: typeof AT_RULE_PRELUDE;
386
- readonly type_name: 'AtrulePrelude';
387
- clone(options?: CloneOptions): ToPlain<AtrulePrelude>;
388
- };
389
- type MediaQuery = CSSNode & WithChildren<MediaFeature | PreludeOperator | MediaType | FeatureRange> & {
390
- readonly type: typeof MEDIA_QUERY;
391
- readonly type_name: 'MediaQuery';
392
- clone(options?: CloneOptions): ToPlain<MediaQuery>;
393
- };
394
- type MediaFeature = CSSNode & {
395
- readonly type: typeof MEDIA_FEATURE;
396
- readonly type_name: 'Feature'; /** Feature name, e.g. "min-width" */
397
- readonly property: string; /** Feature value node, or null for boolean features like (hover) */
398
- readonly value: CSSNode | null;
399
- clone(options?: CloneOptions): ToPlain<MediaFeature>;
400
- };
401
- type MediaType = CSSNode & {
402
- readonly type: typeof MEDIA_TYPE;
403
- readonly type_name: 'MediaType'; /** Media type text, e.g. "screen", "print" */
404
- readonly value: string;
405
- clone(options?: CloneOptions): ToPlain<MediaType>;
406
- };
407
- type ContainerQuery = CSSNode & WithChildren<Identifier | MediaFeature | Function> & {
408
- readonly type: typeof CONTAINER_QUERY;
409
- readonly type_name: 'ContainerQuery';
410
- clone(options?: CloneOptions): ToPlain<ContainerQuery>;
411
- };
412
- type SupportsQuery = CSSNode & WithChildren<SupportsDeclaration> & {
413
- readonly type: typeof SUPPORTS_QUERY;
414
- readonly type_name: 'SupportsQuery'; /** The supports condition text, e.g. "display: flex" from "supports(display: flex)" */
415
- readonly value: string;
416
- clone(options?: CloneOptions): ToPlain<SupportsQuery>;
417
- };
418
- type SupportsDeclaration = CSSNode & WithChildren<Declaration> & {
419
- readonly type: typeof SUPPORTS_DECLARATION;
420
- readonly type_name: 'SupportsDeclaration';
421
- clone(options?: CloneOptions): ToPlain<SupportsDeclaration>;
422
- };
423
- type LayerName = CSSNode & {
424
- readonly type: typeof LAYER_NAME;
425
- readonly type_name: 'Layer';
426
- readonly name: string; /** Alias for name — the layer name string, e.g. "base" from "layer(base)" */
427
- readonly value: string;
428
- clone(options?: CloneOptions): ToPlain<LayerName>;
429
- };
430
- /**
431
- * A parenthesised selector argument in an at-rule prelude.
432
- *
433
- * This node type exists because at-rule preludes that contain selectors (like
434
- * @scope) cannot reuse SELECTOR_LIST: that type already appears inside the
435
- * rule's block, and mixing the two would make traversal ambiguous. A distinct
436
- * type lets walkers and tooling distinguish "this is a selector used as a
437
- * scoping argument" from "this is a selector that matches elements".
438
- *
439
- * Currently produced only by @scope:
440
- * @scope (.parent) to (.child) { }
441
- * ^^^^^^^^^ ^^^^^^^^ — each parenthesised group is a PRELUDE_SELECTORLIST
442
- *
443
- * `value` is the raw selector text inside the parentheses, trimmed of
444
- * whitespace: ".parent" from "(.parent)".
445
- */
446
- type PreludeSelectorList = CSSNode & {
447
- readonly type: typeof PRELUDE_SELECTORLIST;
448
- readonly type_name: 'PreludeSelectorList';
449
- readonly value: string;
450
- clone(options?: CloneOptions): ToPlain<PreludeSelectorList>;
451
- };
452
- type PreludeOperator = CSSNode & {
453
- readonly type: typeof PRELUDE_OPERATOR;
454
- readonly type_name: 'Operator';
455
- clone(options?: CloneOptions): ToPlain<PreludeOperator>;
456
- };
457
- type FeatureRange = CSSNode & WithChildren<Dimension | Operator> & {
458
- readonly type: typeof FEATURE_RANGE;
459
- readonly type_name: 'MediaFeatureRange'; /** The feature name in a range comparison, e.g. "width" from "(width >= 400px)" */
460
- readonly name: string;
461
- clone(options?: CloneOptions): ToPlain<FeatureRange>;
462
- };
463
- 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;
464
- declare function is_stylesheet(node: CSSNode): node is StyleSheet;
465
- declare function is_rule(node: CSSNode): node is Rule;
466
- declare function is_atrule(node: CSSNode): node is Atrule;
467
- declare function is_declaration(node: CSSNode): node is Declaration;
468
- declare function is_selector(node: CSSNode): node is Selector;
469
- declare function is_selector_list(node: CSSNode): node is SelectorList;
470
- declare function is_block(node: CSSNode): node is Block;
471
- declare function is_comment(node: CSSNode): node is Comment;
472
- declare function is_raw(node: CSSNode): node is Raw;
473
- declare function is_identifier(node: CSSNode): node is Identifier;
474
- declare function is_number(node: CSSNode): node is Number;
475
- declare function is_dimension(node: CSSNode): node is Dimension;
476
- declare function is_string(node: CSSNode): node is String;
477
- declare function is_hash(node: CSSNode): node is Hash;
478
- declare function is_function(node: CSSNode): node is Function;
479
- declare function is_operator(node: CSSNode): node is Operator;
480
- declare function is_parenthesis(node: CSSNode): node is Parenthesis;
481
- declare function is_url(node: CSSNode): node is Url;
482
- declare function is_unicode_range(node: CSSNode): node is UnicodeRange;
483
- declare function is_value(node: CSSNode): node is Value;
484
- declare function is_type_selector(node: CSSNode): node is TypeSelector;
485
- declare function is_class_selector(node: CSSNode): node is ClassSelector;
486
- declare function is_id_selector(node: CSSNode): node is IdSelector;
487
- declare function is_attribute_selector(node: CSSNode): node is AttributeSelector;
488
- declare function is_pseudo_class_selector(node: CSSNode): node is PseudoClassSelector;
489
- declare function is_pseudo_element_selector(node: CSSNode): node is PseudoElementSelector;
490
- declare function is_combinator(node: CSSNode): node is Combinator;
491
- declare function is_universal_selector(node: CSSNode): node is UniversalSelector;
492
- declare function is_nesting_selector(node: CSSNode): node is NestingSelector;
493
- declare function is_nth_selector(node: CSSNode): node is NthSelector;
494
- declare function is_nth_of_selector(node: CSSNode): node is NthOfSelector;
495
- declare function is_lang_selector(node: CSSNode): node is LangSelector;
496
- declare function is_atrule_prelude(node: CSSNode): node is AtrulePrelude;
497
- declare function is_media_query(node: CSSNode): node is MediaQuery;
498
- declare function is_media_feature(node: CSSNode): node is MediaFeature;
499
- declare function is_media_type(node: CSSNode): node is MediaType;
500
- declare function is_container_query(node: CSSNode): node is ContainerQuery;
501
- declare function is_supports_query(node: CSSNode): node is SupportsQuery;
502
- declare function is_supports_declaration(node: CSSNode): node is SupportsDeclaration;
503
- declare function is_layer_name(node: CSSNode): node is LayerName;
504
- declare function is_prelude_operator(node: CSSNode): node is PreludeOperator;
505
- declare function is_feature_range(node: CSSNode): node is FeatureRange;
506
- declare function is_prelude_selectorlist(node: CSSNode): node is PreludeSelectorList;
507
- //#endregion
508
- 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 };