@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/dist/{arena-DfpuGV9Y.d.ts → arena-Bx5vp6Sl.d.ts} +2 -7
- package/dist/{arena-CCye9VYE.js → arena-CFwM4uQs.js} +10 -7
- package/dist/constants.d.ts +1 -2
- package/dist/constants.js +1 -1
- package/dist/{css-node-TR2T5Q7D.js → css-node-B3EzCweR.js} +12 -46
- package/dist/index.d.ts +6 -56
- package/dist/index.js +3 -3
- package/dist/node-types-BRnQyc9B.d.ts +395 -0
- package/dist/parse-anplusb.d.ts +2 -3
- package/dist/parse-anplusb.js +3 -3
- package/dist/parse-atrule-prelude.d.ts +3 -4
- package/dist/parse-atrule-prelude.js +78 -81
- package/dist/parse-declaration.d.ts +2 -3
- package/dist/parse-declaration.js +7 -7
- package/dist/{parse-dimension-B0AZRxxt.js → parse-dimension-ouWXNHdx.js} +5 -58
- package/dist/parse-dimension.d.ts +1 -12
- package/dist/parse-dimension.js +1 -1
- package/dist/parse-selector.d.ts +2 -3
- package/dist/parse-selector.js +27 -30
- package/dist/{parse-utils-BmXnziOy.js → parse-utils-D7srNG13.js} +5 -38
- package/dist/parse-value.d.ts +3 -14
- package/dist/parse-value.js +11 -157
- package/dist/parse.d.ts +2 -3
- package/dist/parse.js +59 -43
- package/dist/value-node-parser-CZ47v3hp.js +176 -0
- package/dist/walk.d.ts +7 -18
- package/dist/walk.js +7 -14
- package/package.json +7 -6
- package/dist/node-types-BrZu8T2C.d.ts +0 -508
|
@@ -0,0 +1,395 @@
|
|
|
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-Bx5vp6Sl.js";
|
|
2
|
+
//#region src/css-node.d.ts
|
|
3
|
+
declare const TYPE_NAMES: {
|
|
4
|
+
readonly 1: 'StyleSheet';
|
|
5
|
+
readonly 2: 'Rule';
|
|
6
|
+
readonly 3: 'Atrule';
|
|
7
|
+
readonly 4: 'Declaration';
|
|
8
|
+
readonly 5: 'Selector';
|
|
9
|
+
readonly 6: 'Comment';
|
|
10
|
+
readonly 7: 'Block';
|
|
11
|
+
readonly 8: 'Raw';
|
|
12
|
+
readonly 10: 'Identifier';
|
|
13
|
+
readonly 11: 'Number';
|
|
14
|
+
readonly 12: 'Dimension';
|
|
15
|
+
readonly 13: 'String';
|
|
16
|
+
readonly 14: 'Hash';
|
|
17
|
+
readonly 15: 'Function';
|
|
18
|
+
readonly 16: 'Operator';
|
|
19
|
+
readonly 17: 'Parentheses';
|
|
20
|
+
readonly 18: 'Url';
|
|
21
|
+
readonly 19: 'UnicodeRange';
|
|
22
|
+
readonly 50: 'Value';
|
|
23
|
+
readonly 20: 'SelectorList';
|
|
24
|
+
readonly 21: 'TypeSelector';
|
|
25
|
+
readonly 22: 'ClassSelector';
|
|
26
|
+
readonly 23: 'IdSelector';
|
|
27
|
+
readonly 24: 'AttributeSelector';
|
|
28
|
+
readonly 25: 'PseudoClassSelector';
|
|
29
|
+
readonly 26: 'PseudoElementSelector';
|
|
30
|
+
readonly 27: 'Combinator';
|
|
31
|
+
readonly 28: 'UniversalSelector';
|
|
32
|
+
readonly 29: 'NestingSelector';
|
|
33
|
+
readonly 30: 'Nth';
|
|
34
|
+
readonly 31: 'NthOf';
|
|
35
|
+
readonly 56: 'Lang';
|
|
36
|
+
readonly 32: 'MediaQuery';
|
|
37
|
+
readonly 33: 'Feature';
|
|
38
|
+
readonly 34: 'MediaType';
|
|
39
|
+
readonly 35: 'ContainerQuery';
|
|
40
|
+
readonly 36: 'SupportsQuery';
|
|
41
|
+
readonly 57: 'SupportsDeclaration';
|
|
42
|
+
readonly 37: 'Layer';
|
|
43
|
+
readonly 38: 'Operator';
|
|
44
|
+
readonly 39: 'MediaFeatureRange';
|
|
45
|
+
readonly 40: 'AtrulePrelude';
|
|
46
|
+
readonly 41: 'PreludeSelectorList';
|
|
47
|
+
};
|
|
48
|
+
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 | typeof SUPPORTS_DECLARATION;
|
|
50
|
+
interface CloneOptions {
|
|
51
|
+
/**
|
|
52
|
+
* Recursively clone all children
|
|
53
|
+
* @default true
|
|
54
|
+
*/
|
|
55
|
+
deep?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Include location information (line, column, start, length)
|
|
58
|
+
* @default false
|
|
59
|
+
*/
|
|
60
|
+
locations?: boolean;
|
|
61
|
+
}
|
|
62
|
+
type PlainCSSNode = {
|
|
63
|
+
type: number;
|
|
64
|
+
type_name: TypeName;
|
|
65
|
+
text: string;
|
|
66
|
+
children?: PlainCSSNode[];
|
|
67
|
+
child_count?: number;
|
|
68
|
+
has_children?: boolean;
|
|
69
|
+
name?: string;
|
|
70
|
+
property?: string;
|
|
71
|
+
value?: PlainCSSNode | string | number | null;
|
|
72
|
+
unit?: string;
|
|
73
|
+
prelude?: PlainCSSNode | null;
|
|
74
|
+
is_important?: boolean;
|
|
75
|
+
is_vendor_prefixed?: boolean;
|
|
76
|
+
is_browserhack?: boolean;
|
|
77
|
+
has_error?: boolean;
|
|
78
|
+
attr_operator?: string | null;
|
|
79
|
+
attr_flags?: string | null;
|
|
80
|
+
nth_a?: string | null;
|
|
81
|
+
nth_b?: string | null;
|
|
82
|
+
line?: number;
|
|
83
|
+
column?: number;
|
|
84
|
+
start?: number;
|
|
85
|
+
length?: number;
|
|
86
|
+
end?: number;
|
|
87
|
+
};
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region src/node-types.d.ts
|
|
90
|
+
type CSSNode = {
|
|
91
|
+
readonly type: CSSNodeType;
|
|
92
|
+
readonly type_name: TypeName;
|
|
93
|
+
readonly text: string;
|
|
94
|
+
readonly has_error: boolean;
|
|
95
|
+
readonly is_vendor_prefixed: boolean;
|
|
96
|
+
readonly line: number;
|
|
97
|
+
readonly column: number;
|
|
98
|
+
readonly start: number;
|
|
99
|
+
readonly length: number;
|
|
100
|
+
readonly end: number;
|
|
101
|
+
readonly first_child: CSSNode | null;
|
|
102
|
+
clone(options?: CloneOptions): PlainCSSNode;
|
|
103
|
+
} & ({
|
|
104
|
+
readonly has_next: false;
|
|
105
|
+
readonly next_sibling: null;
|
|
106
|
+
} | {
|
|
107
|
+
readonly has_next: true;
|
|
108
|
+
readonly next_sibling: CSSNode;
|
|
109
|
+
});
|
|
110
|
+
/**
|
|
111
|
+
* A boolean discriminant paired with the value it gates, e.g. `has_prelude` /
|
|
112
|
+
* `prelude`: `T` when the flag is true, `null` when it's false.
|
|
113
|
+
*/
|
|
114
|
+
type Toggle<HasKey extends string, ValueKey extends string, T> = ({ readonly [K in HasKey]: true; } & { readonly [K in ValueKey]: T; }) | ({ readonly [K in HasKey]: false; } & { readonly [K in ValueKey]: null; });
|
|
115
|
+
/** Adds a `clone()` whose return type is `ToPlain<T>` for this exact T. */
|
|
116
|
+
type WithClone<T extends CSSNode> = T & {
|
|
117
|
+
clone(options?: CloneOptions): ToPlain<T>;
|
|
118
|
+
};
|
|
119
|
+
/** A node with no children: CSSNode + a literal type tag + any extra fields. */
|
|
120
|
+
type Leaf<Type extends CSSNodeType, Name extends TypeName, Extra = {}> = WithClone<CSSNode & Extra & {
|
|
121
|
+
readonly type: Type;
|
|
122
|
+
readonly type_name: Name;
|
|
123
|
+
}>;
|
|
124
|
+
/** Mixin for container node types (StyleSheet, Block, SelectorList, …). Leaf nodes never carry children, so they skip this. */
|
|
125
|
+
interface WithChildren<T = AnyNode> {
|
|
126
|
+
readonly has_children: boolean;
|
|
127
|
+
readonly child_count: number;
|
|
128
|
+
readonly children: T[];
|
|
129
|
+
readonly first_child: T;
|
|
130
|
+
[Symbol.iterator](): Iterator<T>;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Maps a CssNodeCommon subtype to its clone() equivalent: `type` narrowed to
|
|
134
|
+
* T's literal, subtype-specific fields with CssNodeCommon refs replaced by
|
|
135
|
+
* PlainCSSNode, and traversal props (first_child, next_sibling, …) dropped
|
|
136
|
+
* since clone() never serialises them.
|
|
137
|
+
*/
|
|
138
|
+
type ToPlain<T extends CSSNode> = PlainCSSNode & {
|
|
139
|
+
type: T['type'];
|
|
140
|
+
} & { [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]; };
|
|
141
|
+
type StyleSheet = WithClone<CSSNode & WithChildren & {
|
|
142
|
+
readonly type: typeof STYLESHEET;
|
|
143
|
+
readonly type_name: 'StyleSheet';
|
|
144
|
+
}>;
|
|
145
|
+
type Rule = WithClone<CSSNode &
|
|
146
|
+
/** SELECTOR_LIST (parse_selectors=true) or RAW (parse_selectors=false) */
|
|
147
|
+
Toggle<'has_prelude', 'prelude', SelectorList | Raw> & Toggle<'has_block', 'block', Block> & {
|
|
148
|
+
readonly type: typeof STYLE_RULE;
|
|
149
|
+
readonly type_name: 'Rule';
|
|
150
|
+
readonly has_declarations: boolean;
|
|
151
|
+
}>;
|
|
152
|
+
type Atrule = WithClone<CSSNode &
|
|
153
|
+
/** AT_RULE_PRELUDE (parse_atrule_preludes=true) or RAW (parse_atrule_preludes=false) */
|
|
154
|
+
Toggle<'has_prelude', 'prelude', AtrulePrelude | Raw> & Toggle<'has_block', 'block', Block> & {
|
|
155
|
+
readonly type: typeof AT_RULE;
|
|
156
|
+
readonly type_name: 'Atrule';
|
|
157
|
+
/** At-rule keyword, e.g. "media", "keyframes" */
|
|
158
|
+
readonly name: string;
|
|
159
|
+
readonly has_declarations: boolean;
|
|
160
|
+
}>;
|
|
161
|
+
type Declaration = Leaf<typeof DECLARATION, 'Declaration', {
|
|
162
|
+
/** Property name, e.g. "color" */
|
|
163
|
+
readonly property: string;
|
|
164
|
+
/** VALUE node (parse_values=true), RAW node (parse_values=false), or null */
|
|
165
|
+
readonly value: Value | Raw | null;
|
|
166
|
+
readonly is_important: boolean;
|
|
167
|
+
readonly is_browserhack: boolean;
|
|
168
|
+
}>;
|
|
169
|
+
type SelectorNode = TypeSelector | IdSelector | ClassSelector | NthSelector | NthOfSelector | LangSelector | NestingSelector | AttributeSelector | UniversalSelector | PseudoClassSelector | PseudoElementSelector;
|
|
170
|
+
type Selector = WithClone<CSSNode & WithChildren<SelectorNode> & {
|
|
171
|
+
readonly type: typeof SELECTOR;
|
|
172
|
+
readonly type_name: 'Selector';
|
|
173
|
+
}>;
|
|
174
|
+
type SelectorList = WithClone<CSSNode & WithChildren<Selector> & {
|
|
175
|
+
readonly type: typeof SELECTOR_LIST;
|
|
176
|
+
readonly type_name: 'SelectorList';
|
|
177
|
+
}>;
|
|
178
|
+
/**
|
|
179
|
+
* A direct child of a Block: `Raw | Declaration | Atrule | Rule` with
|
|
180
|
+
* `next_sibling` narrowed to the same union instead of generic `CSSNode`.
|
|
181
|
+
* Safe since none of the four use WithChildren, avoiding TS2589.
|
|
182
|
+
*/
|
|
183
|
+
type BlockChild = (Raw | Declaration | Atrule | Rule) & Toggle<'has_next', 'next_sibling', Raw | Declaration | Atrule | Rule>;
|
|
184
|
+
type Block = WithClone<CSSNode & WithChildren<Raw | Declaration | Atrule | Rule> & {
|
|
185
|
+
readonly type: typeof BLOCK;
|
|
186
|
+
readonly type_name: 'Block';
|
|
187
|
+
readonly is_empty: boolean;
|
|
188
|
+
/** Block children with next_sibling narrowed to the Block child union. */
|
|
189
|
+
readonly first_child: BlockChild;
|
|
190
|
+
readonly children: BlockChild[];
|
|
191
|
+
[Symbol.iterator](): Iterator<BlockChild>;
|
|
192
|
+
}>;
|
|
193
|
+
type Comment = Leaf<typeof COMMENT, 'Comment'>;
|
|
194
|
+
type Raw = Leaf<typeof RAW, 'Raw'>;
|
|
195
|
+
type ValueLike = Function | Identifier | Operator | Parenthesis | Url | UnicodeRange | String | Hash | Dimension | Number;
|
|
196
|
+
type Identifier = Leaf<typeof IDENTIFIER, 'Identifier', {
|
|
197
|
+
readonly name: string;
|
|
198
|
+
}>;
|
|
199
|
+
type Number = Leaf<typeof NUMBER, 'Number', {
|
|
200
|
+
readonly value: number;
|
|
201
|
+
}>;
|
|
202
|
+
type Dimension = Leaf<typeof DIMENSION, 'Dimension', {
|
|
203
|
+
readonly value: number;
|
|
204
|
+
/** Unit string, e.g. "px", "%" */
|
|
205
|
+
readonly unit: string;
|
|
206
|
+
}>;
|
|
207
|
+
type String = Leaf<typeof STRING, 'String'>;
|
|
208
|
+
type Hash = Leaf<typeof HASH, 'Hash'>;
|
|
209
|
+
type Function = WithClone<CSSNode & WithChildren<ValueLike> & {
|
|
210
|
+
readonly type: typeof FUNCTION;
|
|
211
|
+
readonly type_name: 'Function';
|
|
212
|
+
/** Function name, e.g. "rgb", "calc" */
|
|
213
|
+
readonly name: string;
|
|
214
|
+
/** Function arguments as raw text, e.g. "255, 0, 0" for rgb(255, 0, 0) */
|
|
215
|
+
readonly value: string | null;
|
|
216
|
+
}>;
|
|
217
|
+
type Operator = Leaf<typeof OPERATOR, 'Operator', {
|
|
218
|
+
/** The operator character(s), e.g. ",", "+", "-" */
|
|
219
|
+
readonly value: string;
|
|
220
|
+
}>;
|
|
221
|
+
type Parenthesis = WithClone<CSSNode & WithChildren & {
|
|
222
|
+
readonly type: typeof PARENTHESIS;
|
|
223
|
+
readonly type_name: 'Parentheses';
|
|
224
|
+
}>;
|
|
225
|
+
type Url = Leaf<typeof URL, 'Url', {
|
|
226
|
+
/** URL content, e.g. '"image.png"' (with quotes) or 'mycursor.cur' (unquoted) */
|
|
227
|
+
readonly value: string | null;
|
|
228
|
+
}>;
|
|
229
|
+
type UnicodeRange = Leaf<typeof UNICODE_RANGE, 'UnicodeRange'>;
|
|
230
|
+
type Value = WithClone<CSSNode & WithChildren<ValueLike> & {
|
|
231
|
+
readonly type: typeof VALUE;
|
|
232
|
+
readonly type_name: 'Value';
|
|
233
|
+
}>;
|
|
234
|
+
type TypeSelector = Leaf<typeof TYPE_SELECTOR, 'TypeSelector', {
|
|
235
|
+
/** Local element name, e.g. "div" in both "div" and "ns|div" */
|
|
236
|
+
readonly name: string;
|
|
237
|
+
/** Namespace prefix: null if no qualifier, '' for |div, 'ns' for ns|div, '*' for *|div */
|
|
238
|
+
readonly namespace: string | null;
|
|
239
|
+
}>;
|
|
240
|
+
type ClassSelector = Leaf<typeof CLASS_SELECTOR, 'ClassSelector', {
|
|
241
|
+
/** Class name without dot, e.g. "foo" from ".foo" */
|
|
242
|
+
readonly name: string;
|
|
243
|
+
}>;
|
|
244
|
+
type IdSelector = Leaf<typeof ID_SELECTOR, 'IdSelector', {
|
|
245
|
+
/** Id without hash, e.g. "bar" from "#bar" */
|
|
246
|
+
readonly name: string;
|
|
247
|
+
}>;
|
|
248
|
+
type AttributeSelector = Leaf<typeof ATTRIBUTE_SELECTOR, 'AttributeSelector', {
|
|
249
|
+
/** Attribute name, e.g. "href" from "[href]" */
|
|
250
|
+
readonly name: string;
|
|
251
|
+
/** Operator string, e.g. "=", "~=", "|="; null if no operator ([attr] form) */
|
|
252
|
+
readonly attr_operator: string | null;
|
|
253
|
+
/** Flag character, e.g. "i", "s"; null if no flag */
|
|
254
|
+
readonly attr_flags: string | null;
|
|
255
|
+
/** Attribute value, e.g. "external" from [rel="external"] */
|
|
256
|
+
readonly value: string | null;
|
|
257
|
+
}>;
|
|
258
|
+
type PseudoClassSelector = WithClone<CSSNode & WithChildren<Selector | NthOfSelector> & {
|
|
259
|
+
readonly type: typeof PSEUDO_CLASS_SELECTOR;
|
|
260
|
+
readonly type_name: 'PseudoClassSelector';
|
|
261
|
+
/** Pseudo-class name without colon, e.g. "hover" */
|
|
262
|
+
readonly name: string;
|
|
263
|
+
}>;
|
|
264
|
+
type PseudoElementSelector = WithClone<CSSNode & WithChildren<SelectorList> & {
|
|
265
|
+
readonly type: typeof PSEUDO_ELEMENT_SELECTOR;
|
|
266
|
+
readonly type_name: 'PseudoElementSelector';
|
|
267
|
+
/** Pseudo-element name without colons, e.g. "before" */
|
|
268
|
+
readonly name: string;
|
|
269
|
+
}>;
|
|
270
|
+
type Combinator = Leaf<typeof COMBINATOR, 'Combinator', {
|
|
271
|
+
/** Combinator character(s), e.g. " ", ">", "~", "+", "||", "/deep/" */
|
|
272
|
+
readonly name: string;
|
|
273
|
+
}>;
|
|
274
|
+
type UniversalSelector = Leaf<typeof UNIVERSAL_SELECTOR, 'UniversalSelector', {
|
|
275
|
+
/** Always null — universal selector has no element name */
|
|
276
|
+
readonly name: null;
|
|
277
|
+
/** Namespace prefix: null if no qualifier, '' for |*, 'ns' for ns|*, '*' for *|* */
|
|
278
|
+
readonly namespace: string | null;
|
|
279
|
+
}>;
|
|
280
|
+
type NestingSelector = Leaf<typeof NESTING_SELECTOR, 'NestingSelector'>;
|
|
281
|
+
type NthSelector = Leaf<typeof NTH_SELECTOR, 'Nth', {
|
|
282
|
+
/** 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)`). */
|
|
283
|
+
readonly nth_a: string | null;
|
|
284
|
+
/** 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)`). */
|
|
285
|
+
readonly nth_b: string | null;
|
|
286
|
+
}>;
|
|
287
|
+
type NthOfSelector = Leaf<typeof NTH_OF_SELECTOR, 'NthOf', {
|
|
288
|
+
/** The An+B formula node */
|
|
289
|
+
readonly nth: NthSelector | null;
|
|
290
|
+
/** The selector list from :nth-child(An+B of <selector>) */
|
|
291
|
+
readonly selector: SelectorList | null;
|
|
292
|
+
}>;
|
|
293
|
+
type LangSelector = Leaf<typeof LANG_SELECTOR, 'Lang', {
|
|
294
|
+
/** `"nl"`, `en-US` */
|
|
295
|
+
readonly name: string | null;
|
|
296
|
+
}>;
|
|
297
|
+
type AtrulePrelude = WithClone<CSSNode & WithChildren<Raw | MediaQuery | MediaType | ContainerQuery | SupportsQuery | LayerName | PreludeOperator | PreludeSelectorList | Parenthesis | Url> & {
|
|
298
|
+
readonly type: typeof AT_RULE_PRELUDE;
|
|
299
|
+
readonly type_name: 'AtrulePrelude';
|
|
300
|
+
}>;
|
|
301
|
+
type MediaQuery = WithClone<CSSNode & WithChildren<MediaFeature | PreludeOperator | MediaType | FeatureRange> & {
|
|
302
|
+
readonly type: typeof MEDIA_QUERY;
|
|
303
|
+
readonly type_name: 'MediaQuery';
|
|
304
|
+
}>;
|
|
305
|
+
type MediaFeature = Leaf<typeof MEDIA_FEATURE, 'Feature', {
|
|
306
|
+
/** Feature name, e.g. "min-width" */
|
|
307
|
+
readonly property: string;
|
|
308
|
+
/** Feature value node, or null for boolean features like (hover) */
|
|
309
|
+
readonly value: CSSNode | null;
|
|
310
|
+
}>;
|
|
311
|
+
type MediaType = Leaf<typeof MEDIA_TYPE, 'MediaType', {
|
|
312
|
+
/** Media type text, e.g. "screen", "print" */
|
|
313
|
+
readonly value: string;
|
|
314
|
+
}>;
|
|
315
|
+
type ContainerQuery = WithClone<CSSNode & WithChildren<Identifier | MediaFeature | Function> & {
|
|
316
|
+
readonly type: typeof CONTAINER_QUERY;
|
|
317
|
+
readonly type_name: 'ContainerQuery';
|
|
318
|
+
}>;
|
|
319
|
+
type SupportsQuery = WithClone<CSSNode & WithChildren<SupportsDeclaration> & {
|
|
320
|
+
readonly type: typeof SUPPORTS_QUERY;
|
|
321
|
+
readonly type_name: 'SupportsQuery';
|
|
322
|
+
/** The supports condition text, e.g. "display: flex" from "supports(display: flex)" */
|
|
323
|
+
readonly value: string;
|
|
324
|
+
}>;
|
|
325
|
+
type SupportsDeclaration = WithClone<CSSNode & WithChildren<Declaration> & {
|
|
326
|
+
readonly type: typeof SUPPORTS_DECLARATION;
|
|
327
|
+
readonly type_name: 'SupportsDeclaration';
|
|
328
|
+
}>;
|
|
329
|
+
type LayerName = Leaf<typeof LAYER_NAME, 'Layer', {
|
|
330
|
+
readonly name: string;
|
|
331
|
+
/** Alias for name — the layer name string, e.g. "base" from "layer(base)" */
|
|
332
|
+
readonly value: string;
|
|
333
|
+
}>;
|
|
334
|
+
/**
|
|
335
|
+
* A parenthesised selector argument in an at-rule prelude, e.g. `(.parent)`
|
|
336
|
+
* in `@scope (.parent) to (.child)`. Distinct from SELECTOR_LIST, which
|
|
337
|
+
* already means "matches elements", so tooling can tell scoping arguments
|
|
338
|
+
* apart from real selectors. `value` is the trimmed text inside the parens.
|
|
339
|
+
*/
|
|
340
|
+
type PreludeSelectorList = Leaf<typeof PRELUDE_SELECTORLIST, 'PreludeSelectorList', {
|
|
341
|
+
readonly value: string;
|
|
342
|
+
}>;
|
|
343
|
+
type PreludeOperator = Leaf<typeof PRELUDE_OPERATOR, 'Operator'>;
|
|
344
|
+
type FeatureRange = WithClone<CSSNode & WithChildren<Dimension | Operator> & {
|
|
345
|
+
readonly type: typeof FEATURE_RANGE;
|
|
346
|
+
readonly type_name: 'MediaFeatureRange';
|
|
347
|
+
/** The feature name in a range comparison, e.g. "width" from "(width >= 400px)" */
|
|
348
|
+
readonly name: string;
|
|
349
|
+
}>;
|
|
350
|
+
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;
|
|
351
|
+
declare function is_stylesheet(node: CSSNode): node is StyleSheet;
|
|
352
|
+
declare function is_rule(node: CSSNode): node is Rule;
|
|
353
|
+
declare function is_atrule(node: CSSNode): node is Atrule;
|
|
354
|
+
declare function is_declaration(node: CSSNode): node is Declaration;
|
|
355
|
+
declare function is_selector(node: CSSNode): node is Selector;
|
|
356
|
+
declare function is_selector_list(node: CSSNode): node is SelectorList;
|
|
357
|
+
declare function is_block(node: CSSNode): node is Block;
|
|
358
|
+
declare function is_comment(node: CSSNode): node is Comment;
|
|
359
|
+
declare function is_raw(node: CSSNode): node is Raw;
|
|
360
|
+
declare function is_identifier(node: CSSNode): node is Identifier;
|
|
361
|
+
declare function is_number(node: CSSNode): node is Number;
|
|
362
|
+
declare function is_dimension(node: CSSNode): node is Dimension;
|
|
363
|
+
declare function is_string(node: CSSNode): node is String;
|
|
364
|
+
declare function is_hash(node: CSSNode): node is Hash;
|
|
365
|
+
declare function is_function(node: CSSNode): node is Function;
|
|
366
|
+
declare function is_operator(node: CSSNode): node is Operator;
|
|
367
|
+
declare function is_parenthesis(node: CSSNode): node is Parenthesis;
|
|
368
|
+
declare function is_url(node: CSSNode): node is Url;
|
|
369
|
+
declare function is_unicode_range(node: CSSNode): node is UnicodeRange;
|
|
370
|
+
declare function is_value(node: CSSNode): node is Value;
|
|
371
|
+
declare function is_type_selector(node: CSSNode): node is TypeSelector;
|
|
372
|
+
declare function is_class_selector(node: CSSNode): node is ClassSelector;
|
|
373
|
+
declare function is_id_selector(node: CSSNode): node is IdSelector;
|
|
374
|
+
declare function is_attribute_selector(node: CSSNode): node is AttributeSelector;
|
|
375
|
+
declare function is_pseudo_class_selector(node: CSSNode): node is PseudoClassSelector;
|
|
376
|
+
declare function is_pseudo_element_selector(node: CSSNode): node is PseudoElementSelector;
|
|
377
|
+
declare function is_combinator(node: CSSNode): node is Combinator;
|
|
378
|
+
declare function is_universal_selector(node: CSSNode): node is UniversalSelector;
|
|
379
|
+
declare function is_nesting_selector(node: CSSNode): node is NestingSelector;
|
|
380
|
+
declare function is_nth_selector(node: CSSNode): node is NthSelector;
|
|
381
|
+
declare function is_nth_of_selector(node: CSSNode): node is NthOfSelector;
|
|
382
|
+
declare function is_lang_selector(node: CSSNode): node is LangSelector;
|
|
383
|
+
declare function is_atrule_prelude(node: CSSNode): node is AtrulePrelude;
|
|
384
|
+
declare function is_media_query(node: CSSNode): node is MediaQuery;
|
|
385
|
+
declare function is_media_feature(node: CSSNode): node is MediaFeature;
|
|
386
|
+
declare function is_media_type(node: CSSNode): node is MediaType;
|
|
387
|
+
declare function is_container_query(node: CSSNode): node is ContainerQuery;
|
|
388
|
+
declare function is_supports_query(node: CSSNode): node is SupportsQuery;
|
|
389
|
+
declare function is_supports_declaration(node: CSSNode): node is SupportsDeclaration;
|
|
390
|
+
declare function is_layer_name(node: CSSNode): node is LayerName;
|
|
391
|
+
declare function is_prelude_operator(node: CSSNode): node is PreludeOperator;
|
|
392
|
+
declare function is_feature_range(node: CSSNode): node is FeatureRange;
|
|
393
|
+
declare function is_prelude_selectorlist(node: CSSNode): node is PreludeSelectorList;
|
|
394
|
+
//#endregion
|
|
395
|
+
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,6 +1,5 @@
|
|
|
1
|
-
import { l as CSSDataArena } from "./arena-
|
|
2
|
-
import { T as NthSelector } from "./node-types-
|
|
3
|
-
|
|
1
|
+
import { l as CSSDataArena } from "./arena-Bx5vp6Sl.js";
|
|
2
|
+
import { T as NthSelector } from "./node-types-BRnQyc9B.js";
|
|
4
3
|
//#region src/parse-anplusb.d.ts
|
|
5
4
|
/** @internal */
|
|
6
5
|
declare class ANplusBParser {
|
package/dist/parse-anplusb.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as Lexer } from "./tokenize-BiRLfVbm.js";
|
|
2
|
-
import { l as CSSDataArena } from "./arena-
|
|
3
|
-
import { o as str_equals, s as str_index_of } from "./parse-dimension-
|
|
4
|
-
import { t as CSSNode } from "./css-node-
|
|
2
|
+
import { l as CSSDataArena } from "./arena-CFwM4uQs.js";
|
|
3
|
+
import { o as str_equals, s as str_index_of } from "./parse-dimension-ouWXNHdx.js";
|
|
4
|
+
import { t as CSSNode } from "./css-node-B3EzCweR.js";
|
|
5
5
|
//#region src/parse-anplusb.ts
|
|
6
6
|
/** @internal */
|
|
7
7
|
var ANplusBParser = class {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { l as CSSDataArena } from "./arena-
|
|
2
|
-
import { t as AnyNode } from "./node-types-
|
|
3
|
-
|
|
1
|
+
import { l as CSSDataArena } from "./arena-Bx5vp6Sl.js";
|
|
2
|
+
import { t as AnyNode } from "./node-types-BRnQyc9B.js";
|
|
4
3
|
//#region src/parse-atrule-prelude.d.ts
|
|
5
4
|
/** @internal */
|
|
6
5
|
declare class AtRulePreludeParser {
|
|
@@ -8,6 +7,7 @@ declare class AtRulePreludeParser {
|
|
|
8
7
|
private arena;
|
|
9
8
|
private source;
|
|
10
9
|
private prelude_end;
|
|
10
|
+
private value_node_parser;
|
|
11
11
|
constructor(arena: CSSDataArena, source: string);
|
|
12
12
|
parse_prelude(at_rule_name: string, start: number, end: number, line?: number, column?: number): number[];
|
|
13
13
|
private parse_prelude_dispatch;
|
|
@@ -31,7 +31,6 @@ declare class AtRulePreludeParser {
|
|
|
31
31
|
private skip_whitespace;
|
|
32
32
|
private peek_token_type;
|
|
33
33
|
private next_token;
|
|
34
|
-
private parse_value_token;
|
|
35
34
|
private parse_feature_value;
|
|
36
35
|
private parse_namespace_prelude;
|
|
37
36
|
private parse_scope_prelude;
|