@projectwallace/css-parser 0.18.4 → 0.18.5
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-C-ZXJe7F.js → arena-DKhfTFT5.js} +2 -1
- package/dist/{arena-C-uRgG5-.d.ts → arena-DcrS77hW.d.ts} +2 -1
- package/dist/constants.d.ts +3 -2
- package/dist/constants.js +3 -2
- package/dist/{css-node-Briho45Z.js → css-node-DKr6cufe.js} +19 -4
- package/dist/index.d.ts +3 -3
- package/dist/index.js +7 -4
- package/dist/{node-types-Dh1wEDRK.d.ts → node-types-u3Sbl3_p.d.ts} +33 -6
- package/dist/parse-anplusb.d.ts +2 -2
- package/dist/parse-anplusb.js +2 -2
- package/dist/parse-atrule-prelude.d.ts +3 -10
- package/dist/parse-atrule-prelude.js +20 -220
- package/dist/parse-declaration.d.ts +2 -2
- package/dist/parse-declaration.js +3 -3
- package/dist/parse-selector-DBdUc04T.js +534 -0
- package/dist/parse-selector.d.ts +2 -2
- package/dist/parse-selector.js +1 -460
- 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 +3 -4
- package/dist/value-node-parser-JFFFJVX-.js +661 -0
- package/dist/walk.d.ts +1 -1
- package/dist/walk.js +2 -2
- package/package.json +3 -2
- package/dist/parse-utils-D7srNG13.js +0 -65
- package/dist/value-node-parser-B0WfJCvC.js +0 -173
|
@@ -18,6 +18,7 @@ const OPERATOR = 16;
|
|
|
18
18
|
const PARENTHESIS = 17;
|
|
19
19
|
const URL = 18;
|
|
20
20
|
const UNICODE_RANGE = 19;
|
|
21
|
+
const IF_BRANCH = 59;
|
|
21
22
|
const SELECTOR_LIST = 20;
|
|
22
23
|
const TYPE_SELECTOR = 21;
|
|
23
24
|
const CLASS_SELECTOR = 22;
|
|
@@ -217,4 +218,4 @@ var CSSDataArena = class CSSDataArena {
|
|
|
217
218
|
}
|
|
218
219
|
};
|
|
219
220
|
//#endregion
|
|
220
|
-
export {
|
|
221
|
+
export { PRELUDE_OPERATOR as A, SUPPORTS_DECLARATION as B, MEDIA_TYPE as C, NUMBER as D, NTH_SELECTOR as E, SELECTOR as F, URL as G, TYPE_SELECTOR as H, SELECTOR_LIST as I, VALUE as K, STRING as L, PSEUDO_ELEMENT_SELECTOR as M, RATIO as N, OPERATOR as O, RAW as P, STYLESHEET as R, MEDIA_QUERY as S, NTH_OF_SELECTOR as T, UNICODE_RANGE as U, SUPPORTS_QUERY as V, UNIVERSAL_SELECTOR as W, ID_SELECTOR as _, CLASS_SELECTOR as a, LAYER_NAME 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, PARENTHESIS 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, IF_BRANCH as v, NESTING_SELECTOR as w, MEDIA_FEATURE as x, LANG_SELECTOR as y, STYLE_RULE as z };
|
|
@@ -17,6 +17,7 @@ declare const OPERATOR = 16;
|
|
|
17
17
|
declare const PARENTHESIS = 17;
|
|
18
18
|
declare const URL = 18;
|
|
19
19
|
declare const UNICODE_RANGE = 19;
|
|
20
|
+
declare const IF_BRANCH = 59;
|
|
20
21
|
declare const SELECTOR_LIST = 20;
|
|
21
22
|
declare const TYPE_SELECTOR = 21;
|
|
22
23
|
declare const CLASS_SELECTOR = 22;
|
|
@@ -95,4 +96,4 @@ declare class CSSDataArena {
|
|
|
95
96
|
has_flag(node_index: number, flag: number): boolean;
|
|
96
97
|
}
|
|
97
98
|
//#endregion
|
|
98
|
-
export {
|
|
99
|
+
export { PRELUDE_OPERATOR as A, STYLE_RULE as B, MEDIA_TYPE as C, NUMBER as D, NTH_SELECTOR as E, RAW as F, UNIVERSAL_SELECTOR as G, SUPPORTS_QUERY as H, SELECTOR as I, URL as K, SELECTOR_LIST as L, PSEUDO_CLASS_SELECTOR as M, PSEUDO_ELEMENT_SELECTOR as N, OPERATOR as O, RATIO as P, STRING as R, MEDIA_QUERY as S, NTH_OF_SELECTOR as T, TYPE_SELECTOR as U, SUPPORTS_DECLARATION as V, UNICODE_RANGE as W, ID_SELECTOR as _, CLASS_SELECTOR as a, LAYER_NAME as b, CONTAINER_QUERY as c, DIMENSION as d, FEATURE_RANGE as f, IDENTIFIER as g, HASH as h, BLOCK as i, PRELUDE_SELECTORLIST as j, PARENTHESIS as k, CSSDataArena as l, FUNCTION as m, AT_RULE as n, COMBINATOR as o, FLAG_IMPORTANT as p, VALUE as q, AT_RULE_PRELUDE as r, COMMENT as s, ATTRIBUTE_SELECTOR as t, DECLARATION as u, IF_BRANCH as v, NESTING_SELECTOR as w, MEDIA_FEATURE as x, LANG_SELECTOR as y, STYLESHEET as z };
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as
|
|
1
|
+
import { A as PRELUDE_OPERATOR, B as STYLE_RULE, C as MEDIA_TYPE, D as NUMBER, E as NTH_SELECTOR, F as RAW, G as UNIVERSAL_SELECTOR, H as SUPPORTS_QUERY, I as SELECTOR, K as URL, L as SELECTOR_LIST, M as PSEUDO_CLASS_SELECTOR, N as PSEUDO_ELEMENT_SELECTOR, O as OPERATOR, P as RATIO, R as STRING, S as MEDIA_QUERY, T as NTH_OF_SELECTOR, U as TYPE_SELECTOR, V as SUPPORTS_DECLARATION, W as UNICODE_RANGE, _ as ID_SELECTOR, a as CLASS_SELECTOR, b as LAYER_NAME, c as CONTAINER_QUERY, d as DIMENSION, f as FEATURE_RANGE, g as IDENTIFIER, h as HASH, i as BLOCK, k as PARENTHESIS, m as FUNCTION, n as AT_RULE, o as COMBINATOR, p as FLAG_IMPORTANT, q as VALUE, r as AT_RULE_PRELUDE, s as COMMENT, t as ATTRIBUTE_SELECTOR, u as DECLARATION, v as IF_BRANCH, w as NESTING_SELECTOR, x as MEDIA_FEATURE, y as LANG_SELECTOR, z as STYLESHEET } from "./arena-DcrS77hW.js";
|
|
2
2
|
//#region src/constants.d.ts
|
|
3
3
|
declare const NODE_TYPES: {
|
|
4
4
|
readonly STYLESHEET: 1;
|
|
@@ -19,6 +19,7 @@ declare const NODE_TYPES: {
|
|
|
19
19
|
readonly PARENTHESIS: 17;
|
|
20
20
|
readonly URL: 18;
|
|
21
21
|
readonly UNICODE_RANGE: 19;
|
|
22
|
+
readonly IF_BRANCH: 59;
|
|
22
23
|
readonly VALUE: 50;
|
|
23
24
|
readonly SELECTOR_LIST: 20;
|
|
24
25
|
readonly TYPE_SELECTOR: 21;
|
|
@@ -46,4 +47,4 @@ declare const NODE_TYPES: {
|
|
|
46
47
|
readonly RATIO: 58;
|
|
47
48
|
};
|
|
48
49
|
//#endregion
|
|
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, RATIO, RAW, SELECTOR, SELECTOR_LIST, STRING, STYLESHEET, STYLE_RULE, SUPPORTS_DECLARATION, SUPPORTS_QUERY, TYPE_SELECTOR, UNICODE_RANGE, UNIVERSAL_SELECTOR, URL, VALUE };
|
|
50
|
+
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, IF_BRANCH, 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, RATIO, 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
|
|
1
|
+
import { A as PRELUDE_OPERATOR, B as SUPPORTS_DECLARATION, C as MEDIA_TYPE, D as NUMBER, E as NTH_SELECTOR, F as SELECTOR, G as URL, H as TYPE_SELECTOR, I as SELECTOR_LIST, K as VALUE, L as STRING, M as PSEUDO_ELEMENT_SELECTOR, N as RATIO, O as OPERATOR, P as RAW, R as STYLESHEET, S as MEDIA_QUERY, T as NTH_OF_SELECTOR, U as UNICODE_RANGE, V as SUPPORTS_QUERY, W as UNIVERSAL_SELECTOR, _ as ID_SELECTOR, a as CLASS_SELECTOR, b as LAYER_NAME, 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 PARENTHESIS, 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 IF_BRANCH, w as NESTING_SELECTOR, x as MEDIA_FEATURE, y as LANG_SELECTOR, z as STYLE_RULE } from "./arena-DKhfTFT5.js";
|
|
2
2
|
//#region src/constants.ts
|
|
3
3
|
const NODE_TYPES = {
|
|
4
4
|
STYLESHEET: 1,
|
|
@@ -19,6 +19,7 @@ const NODE_TYPES = {
|
|
|
19
19
|
PARENTHESIS: 17,
|
|
20
20
|
URL: 18,
|
|
21
21
|
UNICODE_RANGE: 19,
|
|
22
|
+
IF_BRANCH: 59,
|
|
22
23
|
VALUE: 50,
|
|
23
24
|
SELECTOR_LIST: 20,
|
|
24
25
|
TYPE_SELECTOR: 21,
|
|
@@ -46,4 +47,4 @@ const NODE_TYPES = {
|
|
|
46
47
|
RATIO: 58
|
|
47
48
|
};
|
|
48
49
|
//#endregion
|
|
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, RATIO, RAW, SELECTOR, SELECTOR_LIST, STRING, STYLESHEET, STYLE_RULE, SUPPORTS_DECLARATION, SUPPORTS_QUERY, TYPE_SELECTOR, UNICODE_RANGE, UNIVERSAL_SELECTOR, URL, VALUE };
|
|
50
|
+
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, IF_BRANCH, 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, RATIO, RAW, SELECTOR, SELECTOR_LIST, STRING, STYLESHEET, STYLE_RULE, SUPPORTS_DECLARATION, SUPPORTS_QUERY, TYPE_SELECTOR, UNICODE_RANGE, UNIVERSAL_SELECTOR, URL, VALUE };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./arena-
|
|
2
|
-
import { a as is_whitespace, c as str_starts_with, i as is_vendor_prefixed, t as parse_dimension } from "./parse-dimension-ouWXNHdx.js";
|
|
1
|
+
import "./arena-DKhfTFT5.js";
|
|
2
|
+
import { a as is_whitespace, c as str_starts_with, i as is_vendor_prefixed, o as str_equals, t as parse_dimension } from "./parse-dimension-ouWXNHdx.js";
|
|
3
3
|
//#region src/css-node.ts
|
|
4
4
|
const TYPE_NAMES = {
|
|
5
5
|
[1]: "StyleSheet",
|
|
@@ -45,7 +45,8 @@ const TYPE_NAMES = {
|
|
|
45
45
|
[39]: "MediaFeatureRange",
|
|
46
46
|
[40]: "AtrulePrelude",
|
|
47
47
|
[41]: "PreludeSelectorList",
|
|
48
|
-
[58]: "Ratio"
|
|
48
|
+
[58]: "Ratio",
|
|
49
|
+
[59]: "IfBranch"
|
|
49
50
|
};
|
|
50
51
|
const nodes_with_name = /* @__PURE__ */ new Set([
|
|
51
52
|
3,
|
|
@@ -79,7 +80,8 @@ const nodes_with_children = /* @__PURE__ */ new Set([
|
|
|
79
80
|
35,
|
|
80
81
|
39,
|
|
81
82
|
36,
|
|
82
|
-
57
|
|
83
|
+
57,
|
|
84
|
+
59
|
|
83
85
|
]);
|
|
84
86
|
const enumerable_properties = [
|
|
85
87
|
"name",
|
|
@@ -92,6 +94,8 @@ const enumerable_properties = [
|
|
|
92
94
|
"nth_a",
|
|
93
95
|
"nth_b",
|
|
94
96
|
"selector",
|
|
97
|
+
"condition",
|
|
98
|
+
"is_else",
|
|
95
99
|
"is_browserhack",
|
|
96
100
|
"is_vendor_prefixed",
|
|
97
101
|
"has_error",
|
|
@@ -178,6 +182,7 @@ var CSSNode = class CSSNode {
|
|
|
178
182
|
if (type === 4 && first_child) return first_child;
|
|
179
183
|
if (type === 33) return first_child ?? null;
|
|
180
184
|
if (type === 57) return first_child?.first_child ?? null;
|
|
185
|
+
if (type === 59) return first_child?.next_sibling ?? null;
|
|
181
186
|
if (type === 12) return parse_dimension(text).value;
|
|
182
187
|
if (type === 11) return Number(text);
|
|
183
188
|
if (type === 18) {
|
|
@@ -251,6 +256,16 @@ var CSSNode = class CSSNode {
|
|
|
251
256
|
if (this.type !== 58) return void 0;
|
|
252
257
|
return this.first_child?.next_sibling ?? void 0;
|
|
253
258
|
}
|
|
259
|
+
/** Get the parsed condition node of an if() branch, e.g. the Function "style(--active: 1)" or the Identifier "else" */
|
|
260
|
+
get condition() {
|
|
261
|
+
if (this.type !== 59) return;
|
|
262
|
+
return this.first_child ?? void 0;
|
|
263
|
+
}
|
|
264
|
+
/** True when this is the else branch of an if() function */
|
|
265
|
+
get is_else() {
|
|
266
|
+
if (this.type !== 59) return void 0;
|
|
267
|
+
return str_equals("else", this.get_content());
|
|
268
|
+
}
|
|
254
269
|
/** Check if this declaration has !important */
|
|
255
270
|
get is_important() {
|
|
256
271
|
if (this.type !== 4) return void 0;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { B as
|
|
1
|
+
import { A as PRELUDE_OPERATOR, B as STYLE_RULE, C as MEDIA_TYPE, D as NUMBER, E as NTH_SELECTOR, F as RAW, G as UNIVERSAL_SELECTOR, H as SUPPORTS_QUERY, I as SELECTOR, K as URL, L as SELECTOR_LIST, M as PSEUDO_CLASS_SELECTOR, N as PSEUDO_ELEMENT_SELECTOR, O as OPERATOR, P as RATIO, R as STRING, S as MEDIA_QUERY, T as NTH_OF_SELECTOR, U as TYPE_SELECTOR, V as SUPPORTS_DECLARATION, W as UNICODE_RANGE, _ as ID_SELECTOR, a as CLASS_SELECTOR, b as LAYER_NAME, c as CONTAINER_QUERY, d as DIMENSION, f as FEATURE_RANGE, g as IDENTIFIER, h as HASH, i as BLOCK, k as PARENTHESIS, m as FUNCTION, n as AT_RULE, o as COMBINATOR, p as FLAG_IMPORTANT, q as VALUE, r as AT_RULE_PRELUDE, s as COMMENT, t as ATTRIBUTE_SELECTOR, u as DECLARATION, v as IF_BRANCH, w as NESTING_SELECTOR, x as MEDIA_FEATURE, y as LANG_SELECTOR, z as STYLESHEET } from "./arena-DcrS77hW.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-CDEnYcVG.js";
|
|
4
|
-
import { $ as
|
|
4
|
+
import { $ as is_attribute_selector, A as PreludeOperator, At as is_rule, B as String, Bt as is_url, C as MediaType, Ct as is_parenthesis, D as Number, Dt as is_pseudo_element_selector, E as NthSelector, Et as is_pseudo_class_selector, F as Raw, Ft as is_supports_declaration, G as TypeSelector, H as SupportsDeclaration, Ht as CloneOptions, I as Rule, It as is_supports_query, J as Url, K as UnicodeRange, L as Selector, Lt as is_type_selector, M as PseudoClassSelector, Mt as is_selector_list, N as PseudoElementSelector, Nt as is_string, O as Operator, Ot as is_ratio, P as Ratio, Pt as is_stylesheet, Q as is_atrule_prelude, R as SelectorList, Rt as is_unicode_range, S as MediaQuery, St as is_operator, T as NthOfSelector, Tt as is_prelude_selectorlist, U as SupportsQuery, Ut as PlainCSSNode, V as StyleSheet, Vt as is_value, W as ToPlain, Wt as TYPE_NAMES, X as WithChildren, Y as Value, Z as is_atrule, _ as Identifier, _t as is_media_type, a as Block, at as is_declaration, b as LayerName, bt as is_nth_selector, c as Combinator, ct as is_function, d as Declaration, dt as is_identifier, et as is_block, f as Dimension, ft as is_if_branch, g as IdSelector, gt as is_media_query, h as Hash, ht as is_media_feature, i as AttributeSelector, it as is_container_query, j as PreludeSelectorList, jt as is_selector, k as Parenthesis, kt as is_raw, l as Comment, lt as is_hash, m as Function, mt as is_layer_name, n as Atrule, nt as is_combinator, o as CSSNode, ot as is_dimension, p as FeatureRange, pt as is_lang_selector, q as UniversalSelector, r as AtrulePrelude, rt as is_comment, s as ClassSelector, st as is_feature_range, t as AnyNode, tt as is_class_selector, u as ContainerQuery, ut as is_id_selector, v as IfBranch, vt as is_nesting_selector, w as NestingSelector, wt as is_prelude_operator, x as MediaFeature, xt as is_number, y as LangSelector, yt as is_nth_of_selector, z as SelectorNode, zt as is_universal_selector } from "./node-types-u3Sbl3_p.js";
|
|
5
5
|
import { ParserOptions, parse } from "./parse.js";
|
|
6
6
|
import { parse_selector, parse_selector_list } from "./parse-selector.js";
|
|
7
7
|
import { parse_atrule_prelude } from "./parse-atrule-prelude.js";
|
|
@@ -25,4 +25,4 @@ declare function is_vendor_prefixed(source: string, start: number, end: number):
|
|
|
25
25
|
/** True if the string is a CSS custom property (starts with `--`). */
|
|
26
26
|
declare function is_custom(str: string): boolean;
|
|
27
27
|
//#endregion
|
|
28
|
-
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, RATIO, RAW, type Ratio, 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_ratio, 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_selector_list, parse_value, str_equals, str_index_of, str_starts_with, tokenize, traverse, walk };
|
|
28
|
+
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, IF_BRANCH, type IdSelector, type Identifier, type IfBranch, 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, RATIO, RAW, type Ratio, 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_if_branch, 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_ratio, 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_selector_list, parse_value, str_equals, str_index_of, str_starts_with, tokenize, traverse, walk };
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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-DK24ACbY.js";
|
|
2
|
-
import { A as
|
|
2
|
+
import { A as PRELUDE_OPERATOR, B as SUPPORTS_DECLARATION, C as MEDIA_TYPE, D as NUMBER, E as NTH_SELECTOR, F as SELECTOR, G as URL, H as TYPE_SELECTOR, I as SELECTOR_LIST, K as VALUE, L as STRING, M as PSEUDO_ELEMENT_SELECTOR, N as RATIO, O as OPERATOR, P as RAW, R as STYLESHEET, S as MEDIA_QUERY, T as NTH_OF_SELECTOR, U as UNICODE_RANGE, V as SUPPORTS_QUERY, W as UNIVERSAL_SELECTOR, _ as ID_SELECTOR, a as CLASS_SELECTOR, b as LAYER_NAME, 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 PARENTHESIS, 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 IF_BRANCH, w as NESTING_SELECTOR, x as MEDIA_FEATURE, y as LANG_SELECTOR, z as STYLE_RULE } from "./arena-DKhfTFT5.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-ouWXNHdx.js";
|
|
4
|
-
import { n as TYPE_NAMES } from "./css-node-
|
|
5
|
-
import { parse_selector, parse_selector_list } from "./parse-selector.js";
|
|
4
|
+
import { n as TYPE_NAMES } from "./css-node-DKr6cufe.js";
|
|
5
|
+
import { n as parse_selector, r as parse_selector_list } from "./parse-selector-DBdUc04T.js";
|
|
6
6
|
import { parse_atrule_prelude } from "./parse-atrule-prelude.js";
|
|
7
7
|
import { parse_value } from "./parse-value.js";
|
|
8
8
|
import { parse_declaration } from "./parse-declaration.js";
|
|
@@ -67,6 +67,9 @@ function is_url(node) {
|
|
|
67
67
|
function is_unicode_range(node) {
|
|
68
68
|
return node.type === 19;
|
|
69
69
|
}
|
|
70
|
+
function is_if_branch(node) {
|
|
71
|
+
return node.type === 59;
|
|
72
|
+
}
|
|
70
73
|
function is_value(node) {
|
|
71
74
|
return node.type === 50;
|
|
72
75
|
}
|
|
@@ -143,4 +146,4 @@ function is_prelude_selectorlist(node) {
|
|
|
143
146
|
return node.type === 41;
|
|
144
147
|
}
|
|
145
148
|
//#endregion
|
|
146
|
-
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, RATIO, 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_ratio, 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_selector_list, parse_value, str_equals, str_index_of, str_starts_with, tokenize, traverse, walk };
|
|
149
|
+
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, IF_BRANCH, 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, RATIO, 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_if_branch, 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_ratio, 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_selector_list, parse_value, str_equals, str_index_of, str_starts_with, tokenize, traverse, walk };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as PRELUDE_OPERATOR, B as STYLE_RULE, C as MEDIA_TYPE, D as NUMBER, E as NTH_SELECTOR, F as RAW, G as UNIVERSAL_SELECTOR, H as SUPPORTS_QUERY, I as SELECTOR, K as URL, L as SELECTOR_LIST, M as PSEUDO_CLASS_SELECTOR, N as PSEUDO_ELEMENT_SELECTOR, O as OPERATOR, P as RATIO, R as STRING, S as MEDIA_QUERY, T as NTH_OF_SELECTOR, U as TYPE_SELECTOR, V as SUPPORTS_DECLARATION, W as UNICODE_RANGE, _ as ID_SELECTOR, a as CLASS_SELECTOR, b as LAYER_NAME, c as CONTAINER_QUERY, d as DIMENSION, f as FEATURE_RANGE, g as IDENTIFIER, h as HASH, i as BLOCK, j as PRELUDE_SELECTORLIST, k as PARENTHESIS, m as FUNCTION, n as AT_RULE, o as COMBINATOR, q as VALUE, r as AT_RULE_PRELUDE, s as COMMENT, t as ATTRIBUTE_SELECTOR, u as DECLARATION, v as IF_BRANCH, w as NESTING_SELECTOR, x as MEDIA_FEATURE, y as LANG_SELECTOR, z as STYLESHEET } from "./arena-DcrS77hW.js";
|
|
2
2
|
//#region src/css-node.d.ts
|
|
3
3
|
declare const TYPE_NAMES: {
|
|
4
4
|
readonly 1: 'StyleSheet';
|
|
@@ -45,9 +45,10 @@ declare const TYPE_NAMES: {
|
|
|
45
45
|
readonly 40: 'AtrulePrelude';
|
|
46
46
|
readonly 41: 'PreludeSelectorList';
|
|
47
47
|
readonly 58: 'Ratio';
|
|
48
|
+
readonly 59: 'IfBranch';
|
|
48
49
|
};
|
|
49
50
|
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 | typeof RATIO;
|
|
51
|
+
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 | typeof RATIO | typeof IF_BRANCH;
|
|
51
52
|
interface CloneOptions {
|
|
52
53
|
/**
|
|
53
54
|
* Recursively clone all children
|
|
@@ -74,6 +75,8 @@ type PlainCSSNode = {
|
|
|
74
75
|
prelude?: PlainCSSNode | null;
|
|
75
76
|
left?: PlainCSSNode;
|
|
76
77
|
right?: PlainCSSNode;
|
|
78
|
+
condition?: PlainCSSNode;
|
|
79
|
+
is_else?: boolean;
|
|
77
80
|
is_important?: boolean;
|
|
78
81
|
is_vendor_prefixed?: boolean;
|
|
79
82
|
is_browserhack?: boolean;
|
|
@@ -195,7 +198,7 @@ type Block = WithClone<CSSNode & WithChildren<Raw | Declaration | Atrule | Rule>
|
|
|
195
198
|
}>;
|
|
196
199
|
type Comment = Leaf<typeof COMMENT, 'Comment'>;
|
|
197
200
|
type Raw = Leaf<typeof RAW, 'Raw'>;
|
|
198
|
-
type ValueLike = Function | Identifier | Operator | Parenthesis | Url | UnicodeRange | String | Hash | Dimension | Number | Ratio | SelectorList | SupportsDeclaration;
|
|
201
|
+
type ValueLike = Function | IfBranch | Identifier | Operator | Parenthesis | Url | UnicodeRange | String | Hash | Dimension | Number | Ratio | SelectorList | SupportsDeclaration;
|
|
199
202
|
type Identifier = Leaf<typeof IDENTIFIER, 'Identifier', {
|
|
200
203
|
readonly name: string;
|
|
201
204
|
}>;
|
|
@@ -214,7 +217,7 @@ type Dimension = Leaf<typeof DIMENSION, 'Dimension', {
|
|
|
214
217
|
}>;
|
|
215
218
|
type String = Leaf<typeof STRING, 'String'>;
|
|
216
219
|
type Hash = Leaf<typeof HASH, 'Hash'>;
|
|
217
|
-
type Function = WithClone<CSSNode & WithChildren<ValueLike> & {
|
|
220
|
+
type Function = WithClone<CSSNode & WithChildren<ValueLike | MediaFeature | SupportsDeclaration | SupportsQuery | FeatureRange | PreludeOperator> & {
|
|
218
221
|
readonly type: typeof FUNCTION;
|
|
219
222
|
readonly type_name: 'Function';
|
|
220
223
|
/** Function name, e.g. "rgb", "calc" */
|
|
@@ -239,6 +242,29 @@ type Value = WithClone<CSSNode & WithChildren<ValueLike> & {
|
|
|
239
242
|
readonly type: typeof VALUE;
|
|
240
243
|
readonly type_name: 'Value';
|
|
241
244
|
}>;
|
|
245
|
+
/**
|
|
246
|
+
* One branch inside a CSS `if()` inline conditional function.
|
|
247
|
+
*
|
|
248
|
+
* Each branch corresponds to a `<condition>: <value>` pair in:
|
|
249
|
+
* `if( <condition>: <value>; … else: <fallback> )`
|
|
250
|
+
*
|
|
251
|
+
* - `condition` — the parsed condition node (Function, e.g. `style(--x: 1)`, or Identifier `else`)
|
|
252
|
+
* - `value` — the value text, e.g. `"green"`; `null` when omitted
|
|
253
|
+
* - `is_else` — `true` for the `else` branch
|
|
254
|
+
* - `first_child` — same node as `condition`
|
|
255
|
+
* - `children` — condition node followed by parsed value nodes
|
|
256
|
+
*/
|
|
257
|
+
type IfBranch = CSSNode & WithChildren<Function | Identifier | Value> & {
|
|
258
|
+
readonly type: typeof IF_BRANCH;
|
|
259
|
+
readonly type_name: 'IfBranch';
|
|
260
|
+
/** The parsed condition node, e.g. the Function "style(--active: 1)" or the Identifier "else" */
|
|
261
|
+
readonly condition: Function | Identifier;
|
|
262
|
+
/** The parsed value as a VALUE node, or null when the branch value is empty */
|
|
263
|
+
readonly value: Value | null;
|
|
264
|
+
/** True when this is the else branch */
|
|
265
|
+
readonly is_else: boolean;
|
|
266
|
+
clone(options?: CloneOptions): ToPlain<IfBranch>;
|
|
267
|
+
};
|
|
242
268
|
type TypeSelector = Leaf<typeof TYPE_SELECTOR, 'TypeSelector', {
|
|
243
269
|
/** Local element name, e.g. "div" in both "div" and "ns|div" */
|
|
244
270
|
readonly name: string;
|
|
@@ -359,7 +385,7 @@ type FeatureRange = WithClone<CSSNode & WithChildren<Dimension | PreludeOperator
|
|
|
359
385
|
/** The feature name in a range comparison, e.g. "width" from "(width >= 400px)" */
|
|
360
386
|
readonly name: string;
|
|
361
387
|
}>;
|
|
362
|
-
type AnyNode = StyleSheet | Rule | Atrule | Declaration | Selector | SelectorList | Block | Comment | Raw | Identifier | Number | Dimension | Ratio | 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;
|
|
388
|
+
type AnyNode = StyleSheet | Rule | Atrule | Declaration | Selector | SelectorList | Block | Comment | Raw | Identifier | Number | Dimension | Ratio | String | Hash | Function | Operator | Parenthesis | Url | UnicodeRange | IfBranch | Value | TypeSelector | ClassSelector | IdSelector | AttributeSelector | PseudoClassSelector | PseudoElementSelector | Combinator | UniversalSelector | NestingSelector | NthSelector | NthOfSelector | LangSelector | AtrulePrelude | MediaQuery | MediaFeature | MediaType | ContainerQuery | SupportsQuery | SupportsDeclaration | LayerName | PreludeOperator | FeatureRange | PreludeSelectorList;
|
|
363
389
|
declare function is_stylesheet(node: CSSNode): node is StyleSheet;
|
|
364
390
|
declare function is_rule(node: CSSNode): node is Rule;
|
|
365
391
|
declare function is_atrule(node: CSSNode): node is Atrule;
|
|
@@ -379,6 +405,7 @@ declare function is_operator(node: CSSNode): node is Operator;
|
|
|
379
405
|
declare function is_parenthesis(node: CSSNode): node is Parenthesis;
|
|
380
406
|
declare function is_url(node: CSSNode): node is Url;
|
|
381
407
|
declare function is_unicode_range(node: CSSNode): node is UnicodeRange;
|
|
408
|
+
declare function is_if_branch(node: CSSNode): node is IfBranch;
|
|
382
409
|
declare function is_value(node: CSSNode): node is Value;
|
|
383
410
|
declare function is_type_selector(node: CSSNode): node is TypeSelector;
|
|
384
411
|
declare function is_class_selector(node: CSSNode): node is ClassSelector;
|
|
@@ -405,4 +432,4 @@ declare function is_feature_range(node: CSSNode): node is FeatureRange;
|
|
|
405
432
|
declare function is_ratio(node: CSSNode): node is Ratio;
|
|
406
433
|
declare function is_prelude_selectorlist(node: CSSNode): node is PreludeSelectorList;
|
|
407
434
|
//#endregion
|
|
408
|
-
export {
|
|
435
|
+
export { is_attribute_selector as $, PreludeOperator as A, is_rule as At, String as B, is_url as Bt, MediaType as C, is_parenthesis as Ct, Number as D, is_pseudo_element_selector as Dt, NthSelector as E, is_pseudo_class_selector as Et, Raw as F, is_supports_declaration as Ft, TypeSelector as G, SupportsDeclaration as H, CloneOptions as Ht, Rule as I, is_supports_query as It, Url as J, UnicodeRange as K, Selector as L, is_type_selector as Lt, PseudoClassSelector as M, is_selector_list as Mt, PseudoElementSelector as N, is_string as Nt, Operator as O, is_ratio as Ot, Ratio as P, is_stylesheet as Pt, is_atrule_prelude as Q, SelectorList as R, is_unicode_range as Rt, MediaQuery as S, is_operator as St, NthOfSelector as T, is_prelude_selectorlist as Tt, SupportsQuery as U, PlainCSSNode as Ut, StyleSheet as V, is_value as Vt, ToPlain as W, TYPE_NAMES as Wt, WithChildren as X, Value as Y, is_atrule as Z, Identifier as _, is_media_type as _t, Block as a, is_declaration as at, LayerName as b, is_nth_selector as bt, Combinator as c, is_function as ct, Declaration as d, is_identifier as dt, is_block as et, Dimension as f, is_if_branch as ft, IdSelector as g, is_media_query as gt, Hash as h, is_media_feature as ht, AttributeSelector as i, is_container_query as it, PreludeSelectorList as j, is_selector as jt, Parenthesis as k, is_raw as kt, Comment as l, is_hash as lt, Function as m, is_layer_name as mt, Atrule as n, is_combinator as nt, CSSNode as o, is_dimension as ot, FeatureRange as p, is_lang_selector as pt, UniversalSelector as q, AtrulePrelude as r, is_comment as rt, ClassSelector as s, is_feature_range as st, AnyNode as t, is_class_selector as tt, ContainerQuery as u, is_id_selector as ut, IfBranch as v, is_nesting_selector as vt, NestingSelector as w, is_prelude_operator as wt, MediaFeature as x, is_number as xt, LangSelector as y, is_nth_of_selector as yt, SelectorNode as z, is_universal_selector as zt };
|
package/dist/parse-anplusb.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { l as CSSDataArena } from "./arena-
|
|
2
|
-
import {
|
|
1
|
+
import { l as CSSDataArena } from "./arena-DcrS77hW.js";
|
|
2
|
+
import { E as NthSelector } from "./node-types-u3Sbl3_p.js";
|
|
3
3
|
//#region src/parse-anplusb.d.ts
|
|
4
4
|
/** @internal */
|
|
5
5
|
declare class ANplusBParser {
|
package/dist/parse-anplusb.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as Lexer } from "./tokenize-DK24ACbY.js";
|
|
2
|
-
import { l as CSSDataArena } from "./arena-
|
|
2
|
+
import { l as CSSDataArena } from "./arena-DKhfTFT5.js";
|
|
3
3
|
import { o as str_equals, s as str_index_of } from "./parse-dimension-ouWXNHdx.js";
|
|
4
|
-
import { t as CSSNode } from "./css-node-
|
|
4
|
+
import { t as CSSNode } from "./css-node-DKr6cufe.js";
|
|
5
5
|
//#region src/parse-anplusb.ts
|
|
6
6
|
/** @internal */
|
|
7
7
|
var ANplusBParser = class {
|
|
@@ -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-DcrS77hW.js";
|
|
2
|
+
import { t as AnyNode } from "./node-types-u3Sbl3_p.js";
|
|
3
3
|
//#region src/parse-atrule-prelude.d.ts
|
|
4
4
|
/** @internal */
|
|
5
5
|
declare class AtRulePreludeParser {
|
|
@@ -8,7 +8,7 @@ declare class AtRulePreludeParser {
|
|
|
8
8
|
private source;
|
|
9
9
|
private prelude_end;
|
|
10
10
|
private value_node_parser;
|
|
11
|
-
private
|
|
11
|
+
private condition_parser;
|
|
12
12
|
constructor(arena: CSSDataArena, source: string);
|
|
13
13
|
parse_prelude(at_rule_name: string, start: number, end: number, line?: number, column?: number): number[];
|
|
14
14
|
private parse_prelude_dispatch;
|
|
@@ -16,13 +16,9 @@ declare class AtRulePreludeParser {
|
|
|
16
16
|
private create_node;
|
|
17
17
|
private is_and_or_not;
|
|
18
18
|
private scan_matching_paren;
|
|
19
|
-
private parse_function_condition;
|
|
20
19
|
private parse_single_media_query;
|
|
21
|
-
private parse_media_feature;
|
|
22
20
|
private parse_container_query;
|
|
23
21
|
private parse_supports_query;
|
|
24
|
-
private find_colon_at_depth_zero;
|
|
25
|
-
private create_supports_declaration;
|
|
26
22
|
private parse_layer_names;
|
|
27
23
|
private parse_function_prelude;
|
|
28
24
|
private parse_identifier;
|
|
@@ -34,12 +30,9 @@ declare class AtRulePreludeParser {
|
|
|
34
30
|
private skip_whitespace;
|
|
35
31
|
private peek_token_type;
|
|
36
32
|
private next_token;
|
|
37
|
-
private parse_feature_value;
|
|
38
|
-
private wrap_ratio_value;
|
|
39
33
|
private parse_namespace_prelude;
|
|
40
34
|
private parse_scope_prelude;
|
|
41
35
|
private parse_custom_media_prelude;
|
|
42
|
-
private parse_feature_range;
|
|
43
36
|
}
|
|
44
37
|
/**
|
|
45
38
|
* Parse an at-rule prelude string and return an array of AST nodes
|