@projectwallace/css-parser 0.14.1 → 0.14.7
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/index.d.ts +2 -2
- package/dist/{node-types-De9R2IIL.d.ts → node-types-DXNwTg3_.d.ts} +119 -142
- package/dist/parse-anplusb.d.ts +1 -1
- package/dist/parse-atrule-prelude.d.ts +1 -1
- package/dist/parse-declaration.d.ts +1 -1
- package/dist/parse-selector.d.ts +1 -1
- package/dist/parse-selector.js +0 -1
- package/dist/parse-value.d.ts +1 -1
- package/dist/parse.d.ts +1 -1
- package/dist/walk.d.ts +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { B as TYPE_SELECTOR, C as NESTING_SELECTOR, D as OPERATOR, E as NUMBER, F as SELECTOR_LIST, H as UNIVERSAL_SELECTOR, 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 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_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_QUERY } from "./arena-D6TANE5e.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_combinator, A as PreludeSelectorList, At as is_supports_query, B as SupportsQuery, C as NestingSelector, Ct as is_pseudo_element_selector, D as Operator, Dt as is_selector_list, E as Number, Et as is_selector, F as Selector, Ft as is_value, G as Url, H as TypeSelector, I as SelectorList, It as CloneOptions, J as is_atrule, K as Value, L as SelectorNode, Lt as TYPE_NAMES, M as PseudoElementSelector, Mt as is_unicode_range, N as Raw, Nt as is_universal_selector, O as Parenthesis, Ot as is_string, P as Rule, Pt as is_url, Q as is_class_selector, R as String, S as MediaType, St as is_pseudo_class_selector, T as NthSelector, Tt as is_rule, U as UnicodeRange, V as ToPlain, W as UniversalSelector, X as is_attribute_selector, Y as is_atrule_prelude, Z as is_block, _ as Identifier, _t as is_number, a as Block, at as is_function, b as MediaFeature, bt as is_prelude_operator, c as Combinator, ct as is_identifier, d as Declaration, dt as is_media_feature, et as is_comment, f as Dimension, ft as is_media_query, g as IdSelector, gt as is_nth_selector, h as Hash, ht as is_nth_of_selector, i as AttributeSelector, it as is_feature_range, j as PseudoClassSelector, jt as is_type_selector, k as PreludeOperator, kt as is_stylesheet, l as Comment, lt as is_lang_selector, m as Function, mt as is_nesting_selector, n as Atrule, nt as is_declaration, o as CSSNode, ot as is_hash, p as FeatureRange, pt as is_media_type, q as WithChildren, r as AtrulePrelude, rt as is_dimension, s as ClassSelector, st as is_id_selector, t as AnyNode, tt as is_container_query, u as ContainerQuery, ut as is_layer_name, v as LangSelector, vt as is_operator, w as NthOfSelector, wt as is_raw, x as MediaQuery, xt as is_prelude_selectorlist, y as LayerName, yt as is_parenthesis, z as StyleSheet } from "./node-types-DXNwTg3_.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 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 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 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 };
|
|
@@ -87,7 +87,7 @@ type PlainCSSNode = {
|
|
|
87
87
|
};
|
|
88
88
|
//#endregion
|
|
89
89
|
//#region src/node-types.d.ts
|
|
90
|
-
|
|
90
|
+
type CSSNode = {
|
|
91
91
|
readonly type: CSSNodeType;
|
|
92
92
|
readonly type_name: TypeName;
|
|
93
93
|
readonly text: string;
|
|
@@ -98,13 +98,15 @@ interface CSSNode {
|
|
|
98
98
|
readonly start: number;
|
|
99
99
|
readonly length: number;
|
|
100
100
|
readonly end: number;
|
|
101
|
-
/** Low-level linked-list pointer used by walk()/traverse(). Prefer .children on nodes that have it. */
|
|
102
101
|
readonly first_child: CSSNode | null;
|
|
103
|
-
/** Low-level linked-list pointer used by walk()/traverse(). */
|
|
104
|
-
readonly next_sibling: CSSNode | null;
|
|
105
|
-
readonly has_next: boolean;
|
|
106
102
|
clone(options?: CloneOptions): PlainCSSNode;
|
|
107
|
-
}
|
|
103
|
+
} & ({
|
|
104
|
+
readonly has_next: false;
|
|
105
|
+
readonly next_sibling: null;
|
|
106
|
+
} | {
|
|
107
|
+
readonly has_next: true;
|
|
108
|
+
readonly next_sibling: CSSNode;
|
|
109
|
+
});
|
|
108
110
|
/**
|
|
109
111
|
* Mixin for node types that have child nodes.
|
|
110
112
|
*
|
|
@@ -117,6 +119,7 @@ interface WithChildren<T = AnyNode> {
|
|
|
117
119
|
readonly has_children: boolean;
|
|
118
120
|
readonly child_count: number;
|
|
119
121
|
readonly children: T[];
|
|
122
|
+
readonly first_child: T;
|
|
120
123
|
[Symbol.iterator](): Iterator<T>;
|
|
121
124
|
}
|
|
122
125
|
/**
|
|
@@ -139,10 +142,10 @@ interface WithChildren<T = AnyNode> {
|
|
|
139
142
|
type ToPlain<T extends CSSNode> = PlainCSSNode & {
|
|
140
143
|
type: T['type'];
|
|
141
144
|
} & { [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] };
|
|
142
|
-
|
|
145
|
+
type StyleSheet = CSSNode & WithChildren & {
|
|
143
146
|
readonly type: typeof STYLESHEET;
|
|
144
147
|
clone(options?: CloneOptions): ToPlain<StyleSheet>;
|
|
145
|
-
}
|
|
148
|
+
};
|
|
146
149
|
type Rule = CSSNode & {
|
|
147
150
|
readonly type: typeof STYLE_RULE;
|
|
148
151
|
readonly name: string;
|
|
@@ -179,211 +182,186 @@ type Atrule = CSSNode & {
|
|
|
179
182
|
readonly has_block: false;
|
|
180
183
|
readonly block: null;
|
|
181
184
|
});
|
|
182
|
-
|
|
183
|
-
readonly type: typeof DECLARATION;
|
|
184
|
-
/**
|
|
185
|
-
readonly property: string;
|
|
186
|
-
/** VALUE node (parse_values=true), RAW node (parse_values=false), or null */
|
|
185
|
+
type Declaration = CSSNode & {
|
|
186
|
+
readonly type: typeof DECLARATION; /** Property name, e.g. "color" */
|
|
187
|
+
readonly property: string; /** VALUE node (parse_values=true), RAW node (parse_values=false), or null */
|
|
187
188
|
readonly value: Value | Raw | null;
|
|
188
189
|
readonly is_important: boolean;
|
|
189
190
|
readonly is_browserhack: boolean;
|
|
190
191
|
clone(options?: CloneOptions): ToPlain<Declaration>;
|
|
191
|
-
}
|
|
192
|
+
};
|
|
192
193
|
type SelectorNode = TypeSelector | IdSelector | ClassSelector | NthSelector | NthOfSelector | LangSelector | NestingSelector | AttributeSelector | UniversalSelector | PseudoClassSelector | PseudoElementSelector;
|
|
193
|
-
|
|
194
|
+
type Selector = CSSNode & WithChildren<SelectorNode> & {
|
|
194
195
|
readonly type: typeof SELECTOR;
|
|
195
196
|
clone(options?: CloneOptions): ToPlain<Selector>;
|
|
196
|
-
}
|
|
197
|
-
|
|
197
|
+
};
|
|
198
|
+
type SelectorList = CSSNode & WithChildren<Selector> & {
|
|
198
199
|
readonly type: typeof SELECTOR_LIST;
|
|
199
200
|
clone(options?: CloneOptions): ToPlain<SelectorList>;
|
|
200
|
-
}
|
|
201
|
-
|
|
201
|
+
};
|
|
202
|
+
type Block = CSSNode & WithChildren<Raw | Declaration | Atrule | Rule> & {
|
|
202
203
|
readonly type: typeof BLOCK;
|
|
203
204
|
readonly is_empty: boolean;
|
|
204
205
|
clone(options?: CloneOptions): ToPlain<Block>;
|
|
205
|
-
}
|
|
206
|
-
|
|
206
|
+
};
|
|
207
|
+
type Comment = CSSNode & {
|
|
207
208
|
readonly type: typeof COMMENT;
|
|
208
209
|
clone(options?: CloneOptions): ToPlain<Comment>;
|
|
209
|
-
}
|
|
210
|
-
|
|
210
|
+
};
|
|
211
|
+
type Raw = CSSNode & {
|
|
211
212
|
readonly type: typeof RAW;
|
|
212
213
|
clone(options?: CloneOptions): ToPlain<Raw>;
|
|
213
|
-
}
|
|
214
|
+
};
|
|
214
215
|
type ValueLike = Function | Identifier | Operator | Parenthesis | Url | UnicodeRange | String | Hash | Dimension | Number;
|
|
215
|
-
|
|
216
|
+
type Identifier = CSSNode & {
|
|
216
217
|
readonly type: typeof IDENTIFIER;
|
|
217
218
|
readonly name: string;
|
|
218
219
|
clone(options?: CloneOptions): ToPlain<Identifier>;
|
|
219
|
-
}
|
|
220
|
-
|
|
220
|
+
};
|
|
221
|
+
type Number = CSSNode & {
|
|
221
222
|
readonly type: typeof NUMBER;
|
|
222
223
|
readonly value: number;
|
|
223
224
|
clone(options?: CloneOptions): ToPlain<Number>;
|
|
224
|
-
}
|
|
225
|
-
|
|
225
|
+
};
|
|
226
|
+
type Dimension = CSSNode & {
|
|
226
227
|
readonly type: typeof DIMENSION;
|
|
227
|
-
readonly value: number;
|
|
228
|
-
/** Unit string, e.g. "px", "%" */
|
|
228
|
+
readonly value: number; /** Unit string, e.g. "px", "%" */
|
|
229
229
|
readonly unit: string;
|
|
230
230
|
clone(options?: CloneOptions): ToPlain<Dimension>;
|
|
231
|
-
}
|
|
232
|
-
|
|
231
|
+
};
|
|
232
|
+
type String = CSSNode & {
|
|
233
233
|
readonly type: typeof STRING;
|
|
234
234
|
clone(options?: CloneOptions): ToPlain<String>;
|
|
235
|
-
}
|
|
236
|
-
|
|
235
|
+
};
|
|
236
|
+
type Hash = CSSNode & {
|
|
237
237
|
readonly type: typeof HASH;
|
|
238
238
|
clone(options?: CloneOptions): ToPlain<Hash>;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
readonly type: typeof FUNCTION;
|
|
242
|
-
/** Function
|
|
243
|
-
readonly name: string;
|
|
244
|
-
/** Function arguments as raw text, e.g. "255, 0, 0" for rgb(255, 0, 0) */
|
|
239
|
+
};
|
|
240
|
+
type Function = CSSNode & WithChildren<ValueLike> & {
|
|
241
|
+
readonly type: typeof FUNCTION; /** Function name, e.g. "rgb", "calc" */
|
|
242
|
+
readonly name: string; /** Function arguments as raw text, e.g. "255, 0, 0" for rgb(255, 0, 0) */
|
|
245
243
|
readonly value: string | null;
|
|
246
244
|
clone(options?: CloneOptions): ToPlain<Function>;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
readonly type: typeof OPERATOR;
|
|
250
|
-
/** The operator character(s), e.g. ",", "+", "-" */
|
|
245
|
+
};
|
|
246
|
+
type Operator = CSSNode & {
|
|
247
|
+
readonly type: typeof OPERATOR; /** The operator character(s), e.g. ",", "+", "-" */
|
|
251
248
|
readonly value: string;
|
|
252
249
|
clone(options?: CloneOptions): ToPlain<Operator>;
|
|
253
|
-
}
|
|
254
|
-
|
|
250
|
+
};
|
|
251
|
+
type Parenthesis = CSSNode & WithChildren & {
|
|
255
252
|
readonly type: typeof PARENTHESIS;
|
|
256
253
|
clone(options?: CloneOptions): ToPlain<Parenthesis>;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
readonly type: typeof URL;
|
|
260
|
-
/** URL content, e.g. '"image.png"' (with quotes) or 'mycursor.cur' (unquoted) */
|
|
254
|
+
};
|
|
255
|
+
type Url = CSSNode & {
|
|
256
|
+
readonly type: typeof URL; /** URL content, e.g. '"image.png"' (with quotes) or 'mycursor.cur' (unquoted) */
|
|
261
257
|
readonly value: string | null;
|
|
262
258
|
clone(options?: CloneOptions): ToPlain<Url>;
|
|
263
|
-
}
|
|
264
|
-
|
|
259
|
+
};
|
|
260
|
+
type UnicodeRange = CSSNode & {
|
|
265
261
|
readonly type: typeof UNICODE_RANGE;
|
|
266
262
|
clone(options?: CloneOptions): ToPlain<UnicodeRange>;
|
|
267
|
-
}
|
|
268
|
-
|
|
263
|
+
};
|
|
264
|
+
type Value = CSSNode & WithChildren<ValueLike> & {
|
|
269
265
|
readonly type: typeof VALUE;
|
|
270
266
|
clone(options?: CloneOptions): ToPlain<Value>;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
readonly type: typeof TYPE_SELECTOR;
|
|
274
|
-
/** Element type, e.g. "div", "span" */
|
|
267
|
+
};
|
|
268
|
+
type TypeSelector = CSSNode & {
|
|
269
|
+
readonly type: typeof TYPE_SELECTOR; /** Element type, e.g. "div", "span" */
|
|
275
270
|
readonly name: string;
|
|
276
271
|
clone(options?: CloneOptions): ToPlain<TypeSelector>;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
readonly type: typeof CLASS_SELECTOR;
|
|
280
|
-
/** Class name without dot, e.g. "foo" from ".foo" */
|
|
272
|
+
};
|
|
273
|
+
type ClassSelector = CSSNode & {
|
|
274
|
+
readonly type: typeof CLASS_SELECTOR; /** Class name without dot, e.g. "foo" from ".foo" */
|
|
281
275
|
readonly name: string;
|
|
282
276
|
clone(options?: CloneOptions): ToPlain<ClassSelector>;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
readonly type: typeof ID_SELECTOR;
|
|
286
|
-
/** Id without hash, e.g. "bar" from "#bar" */
|
|
277
|
+
};
|
|
278
|
+
type IdSelector = CSSNode & {
|
|
279
|
+
readonly type: typeof ID_SELECTOR; /** Id without hash, e.g. "bar" from "#bar" */
|
|
287
280
|
readonly name: string;
|
|
288
281
|
clone(options?: CloneOptions): ToPlain<IdSelector>;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
readonly type: typeof ATTRIBUTE_SELECTOR;
|
|
292
|
-
/**
|
|
293
|
-
readonly
|
|
294
|
-
/**
|
|
295
|
-
readonly attr_operator: string | null;
|
|
296
|
-
/** Flag character, e.g. "i", "s"; null if no flag */
|
|
297
|
-
readonly attr_flags: string | null;
|
|
298
|
-
/** Attribute value, e.g. "external" from [rel="external"] */
|
|
282
|
+
};
|
|
283
|
+
type AttributeSelector = CSSNode & {
|
|
284
|
+
readonly type: typeof ATTRIBUTE_SELECTOR; /** Attribute name, e.g. "href" from "[href]" */
|
|
285
|
+
readonly name: string; /** Operator string, e.g. "=", "~=", "|="; null if no operator ([attr] form) */
|
|
286
|
+
readonly attr_operator: string | null; /** Flag character, e.g. "i", "s"; null if no flag */
|
|
287
|
+
readonly attr_flags: string | null; /** Attribute value, e.g. "external" from [rel="external"] */
|
|
299
288
|
readonly value: string | null;
|
|
300
289
|
clone(options?: CloneOptions): ToPlain<AttributeSelector>;
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
readonly type: typeof PSEUDO_CLASS_SELECTOR;
|
|
304
|
-
/** Pseudo-class name without colon, e.g. "hover" */
|
|
290
|
+
};
|
|
291
|
+
type PseudoClassSelector = CSSNode & WithChildren<Selector> & {
|
|
292
|
+
readonly type: typeof PSEUDO_CLASS_SELECTOR; /** Pseudo-class name without colon, e.g. "hover" */
|
|
305
293
|
readonly name: string;
|
|
306
294
|
clone(options?: CloneOptions): ToPlain<PseudoClassSelector>;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
readonly type: typeof PSEUDO_ELEMENT_SELECTOR;
|
|
310
|
-
/** Pseudo-element name without colons, e.g. "before" */
|
|
295
|
+
};
|
|
296
|
+
type PseudoElementSelector = CSSNode & WithChildren<Selector> & {
|
|
297
|
+
readonly type: typeof PSEUDO_ELEMENT_SELECTOR; /** Pseudo-element name without colons, e.g. "before" */
|
|
311
298
|
readonly name: string;
|
|
312
299
|
clone(options?: CloneOptions): ToPlain<PseudoElementSelector>;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
readonly type: typeof COMBINATOR;
|
|
316
|
-
/** Combinator character(s), e.g. " ", ">", "~", "+", "||", "/deep/" */
|
|
300
|
+
};
|
|
301
|
+
type Combinator = CSSNode & {
|
|
302
|
+
readonly type: typeof COMBINATOR; /** Combinator character(s), e.g. " ", ">", "~", "+", "||", "/deep/" */
|
|
317
303
|
readonly name: string;
|
|
318
304
|
clone(options?: CloneOptions): ToPlain<Combinator>;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
readonly type: typeof UNIVERSAL_SELECTOR;
|
|
322
|
-
/** Namespace qualifier (e.g. 'ns' in 'ns|*'), null if no namespace */
|
|
305
|
+
};
|
|
306
|
+
type UniversalSelector = CSSNode & {
|
|
307
|
+
readonly type: typeof UNIVERSAL_SELECTOR; /** Namespace qualifier (e.g. 'ns' in 'ns|*'), null if no namespace */
|
|
323
308
|
readonly name: string | null;
|
|
324
309
|
clone(options?: CloneOptions): ToPlain<UniversalSelector>;
|
|
325
|
-
}
|
|
326
|
-
|
|
310
|
+
};
|
|
311
|
+
type NestingSelector = CSSNode & {
|
|
327
312
|
readonly type: typeof NESTING_SELECTOR;
|
|
328
313
|
clone(options?: CloneOptions): ToPlain<NestingSelector>;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
readonly type: typeof NTH_SELECTOR;
|
|
332
|
-
/** The `
|
|
333
|
-
readonly nth_a: string | null;
|
|
334
|
-
/** 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)`). */
|
|
314
|
+
};
|
|
315
|
+
type NthSelector = CSSNode & {
|
|
316
|
+
readonly type: typeof NTH_SELECTOR; /** 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)`). */
|
|
317
|
+
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)`). */
|
|
335
318
|
readonly nth_b: string | null;
|
|
336
319
|
clone(options?: CloneOptions): ToPlain<NthSelector>;
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
readonly type: typeof NTH_OF_SELECTOR;
|
|
340
|
-
/** The An+B
|
|
341
|
-
readonly nth: NthSelector | null;
|
|
342
|
-
/** The selector list from :nth-child(An+B of <selector>) */
|
|
320
|
+
};
|
|
321
|
+
type NthOfSelector = CSSNode & {
|
|
322
|
+
readonly type: typeof NTH_OF_SELECTOR; /** The An+B formula node */
|
|
323
|
+
readonly nth: NthSelector | null; /** The selector list from :nth-child(An+B of <selector>) */
|
|
343
324
|
readonly selector: SelectorList | null;
|
|
344
325
|
clone(options?: CloneOptions): ToPlain<NthOfSelector>;
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
readonly type: typeof LANG_SELECTOR;
|
|
326
|
+
};
|
|
327
|
+
type LangSelector = CSSNode & {
|
|
328
|
+
readonly type: typeof LANG_SELECTOR; /** `"nl"`, `en-US` */
|
|
329
|
+
readonly name: string | null;
|
|
348
330
|
clone(options?: CloneOptions): ToPlain<LangSelector>;
|
|
349
|
-
}
|
|
350
|
-
|
|
331
|
+
};
|
|
332
|
+
type AtrulePrelude = CSSNode & WithChildren<Raw | MediaQuery | MediaType | ContainerQuery | SupportsQuery | LayerName | PreludeOperator | PreludeSelectorList | Parenthesis | Url> & {
|
|
351
333
|
readonly type: typeof AT_RULE_PRELUDE;
|
|
352
334
|
clone(options?: CloneOptions): ToPlain<AtrulePrelude>;
|
|
353
|
-
}
|
|
354
|
-
|
|
335
|
+
};
|
|
336
|
+
type MediaQuery = CSSNode & WithChildren<MediaFeature | PreludeOperator | MediaType | FeatureRange> & {
|
|
355
337
|
readonly type: typeof MEDIA_QUERY;
|
|
356
338
|
clone(options?: CloneOptions): ToPlain<MediaQuery>;
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
readonly type: typeof MEDIA_FEATURE;
|
|
360
|
-
/** Feature name, e.g. "min-width" */
|
|
339
|
+
};
|
|
340
|
+
type MediaFeature = CSSNode & WithChildren & {
|
|
341
|
+
readonly type: typeof MEDIA_FEATURE; /** Feature name, e.g. "min-width" */
|
|
361
342
|
readonly property: string;
|
|
362
343
|
clone(options?: CloneOptions): ToPlain<MediaFeature>;
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
readonly type: typeof MEDIA_TYPE;
|
|
366
|
-
/** Media type text, e.g. "screen", "print" */
|
|
344
|
+
};
|
|
345
|
+
type MediaType = CSSNode & {
|
|
346
|
+
readonly type: typeof MEDIA_TYPE; /** Media type text, e.g. "screen", "print" */
|
|
367
347
|
readonly value: string;
|
|
368
348
|
clone(options?: CloneOptions): ToPlain<MediaType>;
|
|
369
|
-
}
|
|
370
|
-
|
|
349
|
+
};
|
|
350
|
+
type ContainerQuery = CSSNode & WithChildren<Identifier | MediaFeature | Function> & {
|
|
371
351
|
readonly type: typeof CONTAINER_QUERY;
|
|
372
352
|
clone(options?: CloneOptions): ToPlain<ContainerQuery>;
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
readonly type: typeof SUPPORTS_QUERY;
|
|
376
|
-
/** The supports condition text, e.g. "display: flex" from "supports(display: flex)" */
|
|
353
|
+
};
|
|
354
|
+
type SupportsQuery = CSSNode & {
|
|
355
|
+
readonly type: typeof SUPPORTS_QUERY; /** The supports condition text, e.g. "display: flex" from "supports(display: flex)" */
|
|
377
356
|
readonly value: string;
|
|
378
357
|
clone(options?: CloneOptions): ToPlain<SupportsQuery>;
|
|
379
|
-
}
|
|
380
|
-
|
|
358
|
+
};
|
|
359
|
+
type LayerName = CSSNode & {
|
|
381
360
|
readonly type: typeof LAYER_NAME;
|
|
382
|
-
readonly name: string;
|
|
383
|
-
/** Alias for name — the layer name string, e.g. "base" from "layer(base)" */
|
|
361
|
+
readonly name: string; /** Alias for name — the layer name string, e.g. "base" from "layer(base)" */
|
|
384
362
|
readonly value: string;
|
|
385
363
|
clone(options?: CloneOptions): ToPlain<LayerName>;
|
|
386
|
-
}
|
|
364
|
+
};
|
|
387
365
|
/**
|
|
388
366
|
* A parenthesised selector argument in an at-rule prelude.
|
|
389
367
|
*
|
|
@@ -400,21 +378,20 @@ interface LayerName extends CSSNode {
|
|
|
400
378
|
* `value` is the raw selector text inside the parentheses, trimmed of
|
|
401
379
|
* whitespace: ".parent" from "(.parent)".
|
|
402
380
|
*/
|
|
403
|
-
|
|
381
|
+
type PreludeSelectorList = CSSNode & {
|
|
404
382
|
readonly type: typeof PRELUDE_SELECTORLIST;
|
|
405
383
|
readonly value: string;
|
|
406
384
|
clone(options?: CloneOptions): ToPlain<PreludeSelectorList>;
|
|
407
|
-
}
|
|
408
|
-
|
|
385
|
+
};
|
|
386
|
+
type PreludeOperator = CSSNode & {
|
|
409
387
|
readonly type: typeof PRELUDE_OPERATOR;
|
|
410
388
|
clone(options?: CloneOptions): ToPlain<PreludeOperator>;
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
readonly type: typeof FEATURE_RANGE;
|
|
414
|
-
/** The feature name in a range comparison, e.g. "width" from "(width >= 400px)" */
|
|
389
|
+
};
|
|
390
|
+
type FeatureRange = CSSNode & WithChildren<Dimension | Operator> & {
|
|
391
|
+
readonly type: typeof FEATURE_RANGE; /** The feature name in a range comparison, e.g. "width" from "(width >= 400px)" */
|
|
415
392
|
readonly name: string;
|
|
416
393
|
clone(options?: CloneOptions): ToPlain<FeatureRange>;
|
|
417
|
-
}
|
|
394
|
+
};
|
|
418
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;
|
|
419
396
|
declare function is_stylesheet(node: CSSNode): node is StyleSheet;
|
|
420
397
|
declare function is_rule(node: CSSNode): node is Rule;
|
|
@@ -459,4 +436,4 @@ declare function is_prelude_operator(node: CSSNode): node is PreludeOperator;
|
|
|
459
436
|
declare function is_feature_range(node: CSSNode): node is FeatureRange;
|
|
460
437
|
declare function is_prelude_selectorlist(node: CSSNode): node is PreludeSelectorList;
|
|
461
438
|
//#endregion
|
|
462
|
-
export {
|
|
439
|
+
export { is_combinator as $, PreludeSelectorList as A, is_supports_query as At, SupportsQuery as B, NestingSelector as C, is_pseudo_element_selector as Ct, Operator as D, is_selector_list as Dt, Number as E, is_selector as Et, Selector as F, is_value as Ft, Url as G, TypeSelector as H, SelectorList as I, CloneOptions as It, is_atrule as J, Value as K, SelectorNode as L, TYPE_NAMES as Lt, PseudoElementSelector as M, is_unicode_range as Mt, Raw as N, is_universal_selector as Nt, Parenthesis as O, is_string as Ot, Rule as P, is_url as Pt, is_class_selector as Q, String as R, MediaType as S, is_pseudo_class_selector as St, NthSelector as T, is_rule as Tt, UnicodeRange as U, ToPlain as V, UniversalSelector as W, is_attribute_selector as X, is_atrule_prelude as Y, is_block as Z, Identifier as _, is_number as _t, Block as a, is_function as at, MediaFeature as b, is_prelude_operator as bt, Combinator as c, is_identifier as ct, Declaration as d, is_media_feature as dt, is_comment as et, Dimension as f, is_media_query as ft, IdSelector as g, is_nth_selector as gt, Hash as h, is_nth_of_selector as ht, AttributeSelector as i, is_feature_range as it, PseudoClassSelector as j, is_type_selector as jt, PreludeOperator as k, is_stylesheet as kt, Comment as l, is_lang_selector as lt, Function as m, is_nesting_selector as mt, Atrule as n, is_declaration as nt, CSSNode as o, is_hash as ot, FeatureRange as p, is_media_type as pt, WithChildren as q, AtrulePrelude as r, is_dimension as rt, ClassSelector as s, is_id_selector as st, AnyNode as t, is_container_query as tt, ContainerQuery as u, is_layer_name as ut, LangSelector as v, is_operator as vt, NthOfSelector as w, is_raw as wt, MediaQuery as x, is_prelude_selectorlist as xt, LayerName as y, is_parenthesis as yt, StyleSheet as z };
|
package/dist/parse-anplusb.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { l as CSSDataArena } from "./arena-D6TANE5e.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-DXNwTg3_.js";
|
|
4
4
|
|
|
5
5
|
//#region src/parse-declaration.d.ts
|
|
6
6
|
/** @internal */
|
package/dist/parse-selector.d.ts
CHANGED
package/dist/parse-selector.js
CHANGED
|
@@ -393,7 +393,6 @@ var SelectorParser = class {
|
|
|
393
393
|
if (this.lexer.pos >= end) break;
|
|
394
394
|
}
|
|
395
395
|
if (first_child !== null) this.arena.set_first_child(parent_node, first_child);
|
|
396
|
-
if (last_child !== null) {}
|
|
397
396
|
this.selector_end = saved_selector_end;
|
|
398
397
|
this.lexer = saved_lexer;
|
|
399
398
|
}
|
package/dist/parse-value.d.ts
CHANGED
package/dist/parse.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { l as CSSDataArena } from "./arena-D6TANE5e.js";
|
|
2
2
|
import { t as CommentInfo } from "./tokenize-CyiJelQC.js";
|
|
3
|
-
import {
|
|
3
|
+
import { z as StyleSheet } from "./node-types-DXNwTg3_.js";
|
|
4
4
|
|
|
5
5
|
//#region src/parse.d.ts
|
|
6
6
|
interface ParserOptions {
|
package/dist/walk.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@projectwallace/css-parser",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.7",
|
|
4
4
|
"description": "High-performance CSS lexer and parser, optimized for CSS inspection and analysis",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ast",
|
|
@@ -90,14 +90,14 @@
|
|
|
90
90
|
"bootstrap": "^5.3.8",
|
|
91
91
|
"css-tree": "^3.1.0",
|
|
92
92
|
"knip": "^6.0.1",
|
|
93
|
-
"oxfmt": "^0.
|
|
93
|
+
"oxfmt": "^0.43.0",
|
|
94
94
|
"oxlint": "^1.28.0",
|
|
95
95
|
"postcss": "^8.5.6",
|
|
96
96
|
"publint": "^0.3.18",
|
|
97
97
|
"tailwindcss": "^2.2.8",
|
|
98
98
|
"tinybench": "^6.0.0",
|
|
99
99
|
"tsdown": "^0.21.0",
|
|
100
|
-
"typescript": "^
|
|
100
|
+
"typescript": "^6.0.2",
|
|
101
101
|
"vitest": "^4.0.8"
|
|
102
102
|
},
|
|
103
103
|
"issues": "https://github.com/projectwallace/css-parser/issues"
|