@projectwallace/css-parser 0.18.5 → 0.18.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/{arena-DcrS77hW.d.ts → arena-BGvFdbj5.d.ts} +2 -1
- package/dist/{arena-DKhfTFT5.js → arena-e9O_g2AN.js} +2 -1
- package/dist/constants.d.ts +3 -2
- package/dist/constants.js +3 -2
- package/dist/{css-node-DKr6cufe.js → css-node-C6TLE3qd.js} +12 -6
- package/dist/index.d.ts +3 -3
- package/dist/index.js +8 -5
- package/dist/{node-types-u3Sbl3_p.d.ts → node-types-YnOKcNfU.d.ts} +24 -8
- package/dist/parse-anplusb.d.ts +2 -2
- package/dist/parse-anplusb.js +3 -3
- package/dist/parse-atrule-prelude.d.ts +2 -2
- package/dist/parse-atrule-prelude.js +5 -5
- package/dist/parse-declaration.d.ts +2 -2
- package/dist/parse-declaration.js +4 -4
- package/dist/{parse-dimension-ouWXNHdx.js → parse-dimension-CQELWb5z.js} +28 -3
- package/dist/parse-dimension.d.ts +9 -1
- package/dist/parse-dimension.js +2 -2
- package/dist/{parse-selector-DBdUc04T.js → parse-selector-Ce5HUZJ5.js} +17 -20
- package/dist/parse-selector.d.ts +2 -2
- package/dist/parse-selector.js +1 -1
- 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 -3
- package/dist/{value-node-parser-JFFFJVX-.js → value-node-parser-DfkneBdM.js} +99 -26
- package/dist/walk.d.ts +1 -1
- package/dist/walk.js +2 -2
- package/package.json +1 -1
|
@@ -18,6 +18,7 @@ declare const PARENTHESIS = 17;
|
|
|
18
18
|
declare const URL = 18;
|
|
19
19
|
declare const UNICODE_RANGE = 19;
|
|
20
20
|
declare const IF_BRANCH = 59;
|
|
21
|
+
declare const IF_CONDITION = 60;
|
|
21
22
|
declare const SELECTOR_LIST = 20;
|
|
22
23
|
declare const TYPE_SELECTOR = 21;
|
|
23
24
|
declare const CLASS_SELECTOR = 22;
|
|
@@ -96,4 +97,4 @@ declare class CSSDataArena {
|
|
|
96
97
|
has_flag(node_index: number, flag: number): boolean;
|
|
97
98
|
}
|
|
98
99
|
//#endregion
|
|
99
|
-
export {
|
|
100
|
+
export { PARENTHESIS as A, STYLESHEET as B, MEDIA_QUERY as C, NTH_SELECTOR as D, NTH_OF_SELECTOR as E, RATIO as F, UNICODE_RANGE as G, SUPPORTS_DECLARATION as H, RAW as I, VALUE as J, UNIVERSAL_SELECTOR as K, SELECTOR as L, PRELUDE_SELECTORLIST as M, PSEUDO_CLASS_SELECTOR as N, NUMBER as O, PSEUDO_ELEMENT_SELECTOR as P, SELECTOR_LIST as R, MEDIA_FEATURE as S, NESTING_SELECTOR as T, SUPPORTS_QUERY as U, STYLE_RULE as V, TYPE_SELECTOR as W, ID_SELECTOR as _, CLASS_SELECTOR as a, LANG_SELECTOR as b, CONTAINER_QUERY as c, DIMENSION as d, FEATURE_RANGE as f, IDENTIFIER as g, HASH as h, BLOCK as i, PRELUDE_OPERATOR as j, OPERATOR as k, CSSDataArena as l, FUNCTION as m, AT_RULE as n, COMBINATOR as o, FLAG_IMPORTANT as p, URL as q, AT_RULE_PRELUDE as r, COMMENT as s, ATTRIBUTE_SELECTOR as t, DECLARATION as u, IF_BRANCH as v, MEDIA_TYPE as w, LAYER_NAME as x, IF_CONDITION as y, STRING as z };
|
|
@@ -19,6 +19,7 @@ const PARENTHESIS = 17;
|
|
|
19
19
|
const URL = 18;
|
|
20
20
|
const UNICODE_RANGE = 19;
|
|
21
21
|
const IF_BRANCH = 59;
|
|
22
|
+
const IF_CONDITION = 60;
|
|
22
23
|
const SELECTOR_LIST = 20;
|
|
23
24
|
const TYPE_SELECTOR = 21;
|
|
24
25
|
const CLASS_SELECTOR = 22;
|
|
@@ -218,4 +219,4 @@ var CSSDataArena = class CSSDataArena {
|
|
|
218
219
|
}
|
|
219
220
|
};
|
|
220
221
|
//#endregion
|
|
221
|
-
export {
|
|
222
|
+
export { PARENTHESIS as A, STYLE_RULE as B, MEDIA_QUERY as C, NTH_SELECTOR as D, NTH_OF_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, NUMBER as O, RATIO as P, STRING as R, MEDIA_FEATURE as S, NESTING_SELECTOR as T, TYPE_SELECTOR as U, SUPPORTS_DECLARATION as V, UNICODE_RANGE as W, ID_SELECTOR as _, CLASS_SELECTOR as a, LANG_SELECTOR as b, CONTAINER_QUERY as c, DIMENSION as d, FEATURE_RANGE as f, IDENTIFIER as g, HASH as h, BLOCK as i, PRELUDE_OPERATOR as j, OPERATOR 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, MEDIA_TYPE as w, LAYER_NAME as x, IF_CONDITION as y, STYLESHEET as z };
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as PARENTHESIS, B as STYLESHEET, C as MEDIA_QUERY, D as NTH_SELECTOR, E as NTH_OF_SELECTOR, F as RATIO, G as UNICODE_RANGE, H as SUPPORTS_DECLARATION, I as RAW, J as VALUE, K as UNIVERSAL_SELECTOR, L as SELECTOR, N as PSEUDO_CLASS_SELECTOR, O as NUMBER, P as PSEUDO_ELEMENT_SELECTOR, R as SELECTOR_LIST, S as MEDIA_FEATURE, T as NESTING_SELECTOR, U as SUPPORTS_QUERY, V as STYLE_RULE, W as TYPE_SELECTOR, _ as ID_SELECTOR, a as CLASS_SELECTOR, b as LANG_SELECTOR, c as CONTAINER_QUERY, d as DIMENSION, f as FEATURE_RANGE, g as IDENTIFIER, h as HASH, i as BLOCK, j as PRELUDE_OPERATOR, k as OPERATOR, m as FUNCTION, n as AT_RULE, o as COMBINATOR, p as FLAG_IMPORTANT, q as URL, r as AT_RULE_PRELUDE, s as COMMENT, t as ATTRIBUTE_SELECTOR, u as DECLARATION, v as IF_BRANCH, w as MEDIA_TYPE, x as LAYER_NAME, y as IF_CONDITION, z as STRING } from "./arena-BGvFdbj5.js";
|
|
2
2
|
//#region src/constants.d.ts
|
|
3
3
|
declare const NODE_TYPES: {
|
|
4
4
|
readonly STYLESHEET: 1;
|
|
@@ -20,6 +20,7 @@ declare const NODE_TYPES: {
|
|
|
20
20
|
readonly URL: 18;
|
|
21
21
|
readonly UNICODE_RANGE: 19;
|
|
22
22
|
readonly IF_BRANCH: 59;
|
|
23
|
+
readonly IF_CONDITION: 60;
|
|
23
24
|
readonly VALUE: 50;
|
|
24
25
|
readonly SELECTOR_LIST: 20;
|
|
25
26
|
readonly TYPE_SELECTOR: 21;
|
|
@@ -47,4 +48,4 @@ declare const NODE_TYPES: {
|
|
|
47
48
|
readonly RATIO: 58;
|
|
48
49
|
};
|
|
49
50
|
//#endregion
|
|
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 };
|
|
51
|
+
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, IF_CONDITION, 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 PARENTHESIS, B as STYLE_RULE, C as MEDIA_QUERY, D as NTH_SELECTOR, E as NTH_OF_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 NUMBER, P as RATIO, R as STRING, S as MEDIA_FEATURE, T as NESTING_SELECTOR, U as TYPE_SELECTOR, V as SUPPORTS_DECLARATION, W as UNICODE_RANGE, _ as ID_SELECTOR, a as CLASS_SELECTOR, b as LANG_SELECTOR, c as CONTAINER_QUERY, d as DIMENSION, f as FEATURE_RANGE, g as IDENTIFIER, h as HASH, i as BLOCK, j as PRELUDE_OPERATOR, k as OPERATOR, 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 MEDIA_TYPE, x as LAYER_NAME, y as IF_CONDITION, z as STYLESHEET } from "./arena-e9O_g2AN.js";
|
|
2
2
|
//#region src/constants.ts
|
|
3
3
|
const NODE_TYPES = {
|
|
4
4
|
STYLESHEET: 1,
|
|
@@ -20,6 +20,7 @@ const NODE_TYPES = {
|
|
|
20
20
|
URL: 18,
|
|
21
21
|
UNICODE_RANGE: 19,
|
|
22
22
|
IF_BRANCH: 59,
|
|
23
|
+
IF_CONDITION: 60,
|
|
23
24
|
VALUE: 50,
|
|
24
25
|
SELECTOR_LIST: 20,
|
|
25
26
|
TYPE_SELECTOR: 21,
|
|
@@ -47,4 +48,4 @@ const NODE_TYPES = {
|
|
|
47
48
|
RATIO: 58
|
|
48
49
|
};
|
|
49
50
|
//#endregion
|
|
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 };
|
|
51
|
+
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, IF_CONDITION, 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
|
|
1
|
+
import "./arena-e9O_g2AN.js";
|
|
2
|
+
import { a as is_vendor_prefixed, o as is_whitespace, s as str_equals, t as dimension_number_end, u as str_starts_with } from "./parse-dimension-CQELWb5z.js";
|
|
3
3
|
//#region src/css-node.ts
|
|
4
4
|
const TYPE_NAMES = {
|
|
5
5
|
[1]: "StyleSheet",
|
|
@@ -46,7 +46,8 @@ const TYPE_NAMES = {
|
|
|
46
46
|
[40]: "AtrulePrelude",
|
|
47
47
|
[41]: "PreludeSelectorList",
|
|
48
48
|
[58]: "Ratio",
|
|
49
|
-
[59]: "IfBranch"
|
|
49
|
+
[59]: "IfBranch",
|
|
50
|
+
[60]: "IfCondition"
|
|
50
51
|
};
|
|
51
52
|
const nodes_with_name = /* @__PURE__ */ new Set([
|
|
52
53
|
3,
|
|
@@ -81,7 +82,8 @@ const nodes_with_children = /* @__PURE__ */ new Set([
|
|
|
81
82
|
39,
|
|
82
83
|
36,
|
|
83
84
|
57,
|
|
84
|
-
59
|
|
85
|
+
59,
|
|
86
|
+
60
|
|
85
87
|
]);
|
|
86
88
|
const enumerable_properties = [
|
|
87
89
|
"name",
|
|
@@ -183,7 +185,10 @@ var CSSNode = class CSSNode {
|
|
|
183
185
|
if (type === 33) return first_child ?? null;
|
|
184
186
|
if (type === 57) return first_child?.first_child ?? null;
|
|
185
187
|
if (type === 59) return first_child?.next_sibling ?? null;
|
|
186
|
-
if (type === 12)
|
|
188
|
+
if (type === 12) {
|
|
189
|
+
let num_str = text.substring(0, dimension_number_end(text));
|
|
190
|
+
return num_str ? Number.parseFloat(num_str) : 0;
|
|
191
|
+
}
|
|
187
192
|
if (type === 11) return Number(text);
|
|
188
193
|
if (type === 18) {
|
|
189
194
|
if (first_child?.type === 13) return first_child.text;
|
|
@@ -244,7 +249,8 @@ var CSSNode = class CSSNode {
|
|
|
244
249
|
/** Get the unit for dimension nodes (e.g., "px" from "100px", "%" from "50%") */
|
|
245
250
|
get unit() {
|
|
246
251
|
if (this.type !== 12) return void 0;
|
|
247
|
-
|
|
252
|
+
let text = this.text;
|
|
253
|
+
return text.substring(dimension_number_end(text));
|
|
248
254
|
}
|
|
249
255
|
/** Numerator for ratio values, e.g. the Number "16" in `aspect-ratio: 16/9` */
|
|
250
256
|
get left() {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as PARENTHESIS, B as STYLESHEET, C as MEDIA_QUERY, D as NTH_SELECTOR, E as NTH_OF_SELECTOR, F as RATIO, G as UNICODE_RANGE, H as SUPPORTS_DECLARATION, I as RAW, J as VALUE, K as UNIVERSAL_SELECTOR, L as SELECTOR, N as PSEUDO_CLASS_SELECTOR, O as NUMBER, P as PSEUDO_ELEMENT_SELECTOR, R as SELECTOR_LIST, S as MEDIA_FEATURE, T as NESTING_SELECTOR, U as SUPPORTS_QUERY, V as STYLE_RULE, W as TYPE_SELECTOR, _ as ID_SELECTOR, a as CLASS_SELECTOR, b as LANG_SELECTOR, c as CONTAINER_QUERY, d as DIMENSION, f as FEATURE_RANGE, g as IDENTIFIER, h as HASH, i as BLOCK, j as PRELUDE_OPERATOR, k as OPERATOR, m as FUNCTION, n as AT_RULE, o as COMBINATOR, p as FLAG_IMPORTANT, q as URL, r as AT_RULE_PRELUDE, s as COMMENT, t as ATTRIBUTE_SELECTOR, u as DECLARATION, v as IF_BRANCH, w as MEDIA_TYPE, x as LAYER_NAME, y as IF_CONDITION, z as STRING } from "./arena-BGvFdbj5.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_atrule_prelude, A as Parenthesis, At as is_ratio, B as SelectorNode, Bt as is_unicode_range, C as MediaQuery, Ct as is_number, D as NthSelector, Dt as is_prelude_selectorlist, E as NthOfSelector, Et as is_prelude_operator, F as Ratio, Ft as is_string, G as ToPlain, Gt as PlainCSSNode, H as StyleSheet, Ht as is_url, I as Raw, It as is_stylesheet, J as UniversalSelector, K as TypeSelector, Kt as TYPE_NAMES, L as Rule, Lt as is_supports_declaration, M as PreludeSelectorList, Mt as is_rule, N as PseudoClassSelector, Nt as is_selector, O as Number, Ot as is_pseudo_class_selector, P as PseudoElementSelector, Pt as is_selector_list, Q as is_atrule, R as Selector, Rt as is_supports_query, S as MediaFeature, St as is_nth_selector, T as NestingSelector, Tt as is_parenthesis, U as SupportsDeclaration, Ut as is_value, V as String, Vt as is_universal_selector, W as SupportsQuery, Wt as CloneOptions, X as Value, Y as Url, Z as WithChildren, _ as Identifier, _t as is_media_feature, a as Block, at as is_container_query, b as LangSelector, bt as is_nesting_selector, c as Combinator, ct as is_feature_range, d as Declaration, dt as is_id_selector, et as is_attribute_selector, f as Dimension, ft as is_identifier, g as IdSelector, gt as is_layer_name, h as Hash, ht as is_lang_selector, i as AttributeSelector, it as is_comment, j as PreludeOperator, jt as is_raw, k as Operator, kt as is_pseudo_element_selector, l as Comment, lt as is_function, m as Function, mt as is_if_condition, n as Atrule, nt as is_class_selector, o as CSSNode, ot as is_declaration, p as FeatureRange, pt as is_if_branch, q as UnicodeRange, r as AtrulePrelude, rt as is_combinator, s as ClassSelector, st as is_dimension, t as AnyNode, tt as is_block, u as ContainerQuery, ut as is_hash, v as IfBranch, vt as is_media_query, w as MediaType, wt as is_operator, x as LayerName, xt as is_nth_of_selector, y as IfCondition, yt as is_media_type, z as SelectorList, zt as is_type_selector } from "./node-types-YnOKcNfU.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, 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 };
|
|
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, IF_CONDITION, type IdSelector, type Identifier, type IfBranch, type IfCondition, 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_if_condition, 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
|
|
3
|
-
import {
|
|
4
|
-
import { n as TYPE_NAMES } from "./css-node-
|
|
5
|
-
import { n as parse_selector, r as parse_selector_list } from "./parse-selector-
|
|
2
|
+
import { A as PARENTHESIS, B as STYLE_RULE, C as MEDIA_QUERY, D as NTH_SELECTOR, E as NTH_OF_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 NUMBER, P as RATIO, R as STRING, S as MEDIA_FEATURE, T as NESTING_SELECTOR, U as TYPE_SELECTOR, V as SUPPORTS_DECLARATION, W as UNICODE_RANGE, _ as ID_SELECTOR, a as CLASS_SELECTOR, b as LANG_SELECTOR, c as CONTAINER_QUERY, d as DIMENSION, f as FEATURE_RANGE, g as IDENTIFIER, h as HASH, i as BLOCK, j as PRELUDE_OPERATOR, k as OPERATOR, 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 MEDIA_TYPE, x as LAYER_NAME, y as IF_CONDITION, z as STYLESHEET } from "./arena-e9O_g2AN.js";
|
|
3
|
+
import { a as is_vendor_prefixed, i as is_custom, l as str_index_of, n as parse_dimension, s as str_equals, u as str_starts_with } from "./parse-dimension-CQELWb5z.js";
|
|
4
|
+
import { n as TYPE_NAMES } from "./css-node-C6TLE3qd.js";
|
|
5
|
+
import { n as parse_selector, r as parse_selector_list } from "./parse-selector-Ce5HUZJ5.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";
|
|
@@ -70,6 +70,9 @@ function is_unicode_range(node) {
|
|
|
70
70
|
function is_if_branch(node) {
|
|
71
71
|
return node.type === 59;
|
|
72
72
|
}
|
|
73
|
+
function is_if_condition(node) {
|
|
74
|
+
return node.type === 60;
|
|
75
|
+
}
|
|
73
76
|
function is_value(node) {
|
|
74
77
|
return node.type === 50;
|
|
75
78
|
}
|
|
@@ -146,4 +149,4 @@ function is_prelude_selectorlist(node) {
|
|
|
146
149
|
return node.type === 41;
|
|
147
150
|
}
|
|
148
151
|
//#endregion
|
|
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 };
|
|
152
|
+
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, IF_CONDITION, 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_if_condition, 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 PARENTHESIS, B as STYLESHEET, C as MEDIA_QUERY, D as NTH_SELECTOR, E as NTH_OF_SELECTOR, F as RATIO, G as UNICODE_RANGE, H as SUPPORTS_DECLARATION, I as RAW, J as VALUE, K as UNIVERSAL_SELECTOR, L as SELECTOR, M as PRELUDE_SELECTORLIST, N as PSEUDO_CLASS_SELECTOR, O as NUMBER, P as PSEUDO_ELEMENT_SELECTOR, R as SELECTOR_LIST, S as MEDIA_FEATURE, T as NESTING_SELECTOR, U as SUPPORTS_QUERY, V as STYLE_RULE, W as TYPE_SELECTOR, _ as ID_SELECTOR, a as CLASS_SELECTOR, b as LANG_SELECTOR, c as CONTAINER_QUERY, d as DIMENSION, f as FEATURE_RANGE, g as IDENTIFIER, h as HASH, i as BLOCK, j as PRELUDE_OPERATOR, k as OPERATOR, m as FUNCTION, n as AT_RULE, o as COMBINATOR, q as URL, r as AT_RULE_PRELUDE, s as COMMENT, t as ATTRIBUTE_SELECTOR, u as DECLARATION, v as IF_BRANCH, w as MEDIA_TYPE, x as LAYER_NAME, y as IF_CONDITION, z as STRING } from "./arena-BGvFdbj5.js";
|
|
2
2
|
//#region src/css-node.d.ts
|
|
3
3
|
declare const TYPE_NAMES: {
|
|
4
4
|
readonly 1: 'StyleSheet';
|
|
@@ -46,9 +46,10 @@ declare const TYPE_NAMES: {
|
|
|
46
46
|
readonly 41: 'PreludeSelectorList';
|
|
47
47
|
readonly 58: 'Ratio';
|
|
48
48
|
readonly 59: 'IfBranch';
|
|
49
|
+
readonly 60: 'IfCondition';
|
|
49
50
|
};
|
|
50
51
|
type TypeName = (typeof TYPE_NAMES)[keyof typeof TYPE_NAMES] | 'unknown';
|
|
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;
|
|
52
|
+
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 | typeof IF_CONDITION;
|
|
52
53
|
interface CloneOptions {
|
|
53
54
|
/**
|
|
54
55
|
* Recursively clone all children
|
|
@@ -242,23 +243,37 @@ type Value = WithClone<CSSNode & WithChildren<ValueLike> & {
|
|
|
242
243
|
readonly type: typeof VALUE;
|
|
243
244
|
readonly type_name: 'Value';
|
|
244
245
|
}>;
|
|
246
|
+
/**
|
|
247
|
+
* A compound `if()`-branch condition combining multiple tests with `not`/`and`/`or`,
|
|
248
|
+
* e.g. `not style(--scheme: light)` or `style(--a: 1) and media(width > 600px)`.
|
|
249
|
+
*
|
|
250
|
+
* Children are the flat sequence of PreludeOperator ("not"/"and"/"or") and
|
|
251
|
+
* Function (`style()`/`media()`/`supports()`) nodes, in source order — the same
|
|
252
|
+
* shape `@supports`'s own compound condition uses.
|
|
253
|
+
*/
|
|
254
|
+
type IfCondition = WithClone<CSSNode & WithChildren<Function | PreludeOperator> & {
|
|
255
|
+
readonly type: typeof IF_CONDITION;
|
|
256
|
+
readonly type_name: 'IfCondition';
|
|
257
|
+
}>;
|
|
245
258
|
/**
|
|
246
259
|
* One branch inside a CSS `if()` inline conditional function.
|
|
247
260
|
*
|
|
248
261
|
* Each branch corresponds to a `<condition>: <value>` pair in:
|
|
249
262
|
* `if( <condition>: <value>; … else: <fallback> )`
|
|
250
263
|
*
|
|
251
|
-
* - `condition` — the parsed condition node
|
|
264
|
+
* - `condition` — the parsed condition node: a Function (e.g. `style(--x: 1)`), an
|
|
265
|
+
* Identifier (`else`), or an IfCondition for compound `not`/`and`/`or` conditions
|
|
266
|
+
* (e.g. `not style(--x: 1)`)
|
|
252
267
|
* - `value` — the value text, e.g. `"green"`; `null` when omitted
|
|
253
268
|
* - `is_else` — `true` for the `else` branch
|
|
254
269
|
* - `first_child` — same node as `condition`
|
|
255
270
|
* - `children` — condition node followed by parsed value nodes
|
|
256
271
|
*/
|
|
257
|
-
type IfBranch = CSSNode & WithChildren<Function | Identifier | Value> & {
|
|
272
|
+
type IfBranch = CSSNode & WithChildren<Function | Identifier | IfCondition | Value> & {
|
|
258
273
|
readonly type: typeof IF_BRANCH;
|
|
259
274
|
readonly type_name: 'IfBranch';
|
|
260
|
-
/** The parsed condition node, e.g. the Function "style(--active: 1)"
|
|
261
|
-
readonly condition: Function | Identifier;
|
|
275
|
+
/** The parsed condition node, e.g. the Function "style(--active: 1)", the Identifier "else", or an IfCondition for compound conditions */
|
|
276
|
+
readonly condition: Function | Identifier | IfCondition;
|
|
262
277
|
/** The parsed value as a VALUE node, or null when the branch value is empty */
|
|
263
278
|
readonly value: Value | null;
|
|
264
279
|
/** True when this is the else branch */
|
|
@@ -385,7 +400,7 @@ type FeatureRange = WithClone<CSSNode & WithChildren<Dimension | PreludeOperator
|
|
|
385
400
|
/** The feature name in a range comparison, e.g. "width" from "(width >= 400px)" */
|
|
386
401
|
readonly name: string;
|
|
387
402
|
}>;
|
|
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;
|
|
403
|
+
type AnyNode = StyleSheet | Rule | Atrule | Declaration | Selector | SelectorList | Block | Comment | Raw | Identifier | Number | Dimension | Ratio | String | Hash | Function | Operator | Parenthesis | Url | UnicodeRange | IfBranch | IfCondition | Value | TypeSelector | ClassSelector | IdSelector | AttributeSelector | PseudoClassSelector | PseudoElementSelector | Combinator | UniversalSelector | NestingSelector | NthSelector | NthOfSelector | LangSelector | AtrulePrelude | MediaQuery | MediaFeature | MediaType | ContainerQuery | SupportsQuery | SupportsDeclaration | LayerName | PreludeOperator | FeatureRange | PreludeSelectorList;
|
|
389
404
|
declare function is_stylesheet(node: CSSNode): node is StyleSheet;
|
|
390
405
|
declare function is_rule(node: CSSNode): node is Rule;
|
|
391
406
|
declare function is_atrule(node: CSSNode): node is Atrule;
|
|
@@ -406,6 +421,7 @@ declare function is_parenthesis(node: CSSNode): node is Parenthesis;
|
|
|
406
421
|
declare function is_url(node: CSSNode): node is Url;
|
|
407
422
|
declare function is_unicode_range(node: CSSNode): node is UnicodeRange;
|
|
408
423
|
declare function is_if_branch(node: CSSNode): node is IfBranch;
|
|
424
|
+
declare function is_if_condition(node: CSSNode): node is IfCondition;
|
|
409
425
|
declare function is_value(node: CSSNode): node is Value;
|
|
410
426
|
declare function is_type_selector(node: CSSNode): node is TypeSelector;
|
|
411
427
|
declare function is_class_selector(node: CSSNode): node is ClassSelector;
|
|
@@ -432,4 +448,4 @@ declare function is_feature_range(node: CSSNode): node is FeatureRange;
|
|
|
432
448
|
declare function is_ratio(node: CSSNode): node is Ratio;
|
|
433
449
|
declare function is_prelude_selectorlist(node: CSSNode): node is PreludeSelectorList;
|
|
434
450
|
//#endregion
|
|
435
|
-
export {
|
|
451
|
+
export { is_atrule_prelude as $, Parenthesis as A, is_ratio as At, SelectorNode as B, is_unicode_range as Bt, MediaQuery as C, is_number as Ct, NthSelector as D, is_prelude_selectorlist as Dt, NthOfSelector as E, is_prelude_operator as Et, Ratio as F, is_string as Ft, ToPlain as G, PlainCSSNode as Gt, StyleSheet as H, is_url as Ht, Raw as I, is_stylesheet as It, UniversalSelector as J, TypeSelector as K, TYPE_NAMES as Kt, Rule as L, is_supports_declaration as Lt, PreludeSelectorList as M, is_rule as Mt, PseudoClassSelector as N, is_selector as Nt, Number as O, is_pseudo_class_selector as Ot, PseudoElementSelector as P, is_selector_list as Pt, is_atrule as Q, Selector as R, is_supports_query as Rt, MediaFeature as S, is_nth_selector as St, NestingSelector as T, is_parenthesis as Tt, SupportsDeclaration as U, is_value as Ut, String as V, is_universal_selector as Vt, SupportsQuery as W, CloneOptions as Wt, Value as X, Url as Y, WithChildren as Z, Identifier as _, is_media_feature as _t, Block as a, is_container_query as at, LangSelector as b, is_nesting_selector as bt, Combinator as c, is_feature_range as ct, Declaration as d, is_id_selector as dt, is_attribute_selector as et, Dimension as f, is_identifier as ft, IdSelector as g, is_layer_name as gt, Hash as h, is_lang_selector as ht, AttributeSelector as i, is_comment as it, PreludeOperator as j, is_raw as jt, Operator as k, is_pseudo_element_selector as kt, Comment as l, is_function as lt, Function as m, is_if_condition as mt, Atrule as n, is_class_selector as nt, CSSNode as o, is_declaration as ot, FeatureRange as p, is_if_branch as pt, UnicodeRange as q, AtrulePrelude as r, is_combinator as rt, ClassSelector as s, is_dimension as st, AnyNode as t, is_block as tt, ContainerQuery as u, is_hash as ut, IfBranch as v, is_media_query as vt, MediaType as w, is_operator as wt, LayerName as x, is_nth_of_selector as xt, IfCondition as y, is_media_type as yt, SelectorList as z, is_type_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-BGvFdbj5.js";
|
|
2
|
+
import { D as NthSelector } from "./node-types-YnOKcNfU.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-
|
|
3
|
-
import {
|
|
4
|
-
import { t as CSSNode } from "./css-node-
|
|
2
|
+
import { l as CSSDataArena } from "./arena-e9O_g2AN.js";
|
|
3
|
+
import { l as str_index_of, s as str_equals } from "./parse-dimension-CQELWb5z.js";
|
|
4
|
+
import { t as CSSNode } from "./css-node-C6TLE3qd.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-BGvFdbj5.js";
|
|
2
|
+
import { t as AnyNode } from "./node-types-YnOKcNfU.js";
|
|
3
3
|
//#region src/parse-atrule-prelude.d.ts
|
|
4
4
|
/** @internal */
|
|
5
5
|
declare class AtRulePreludeParser {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { t as Lexer } from "./tokenize-DK24ACbY.js";
|
|
2
|
-
import { l as CSSDataArena } from "./arena-
|
|
3
|
-
import {
|
|
4
|
-
import { t as CSSNode } from "./css-node-
|
|
5
|
-
import { s as trim_boundaries } from "./parse-selector-
|
|
6
|
-
import { n as ConditionParser, t as ValueNodeParser } from "./value-node-parser-
|
|
2
|
+
import { l as CSSDataArena } from "./arena-e9O_g2AN.js";
|
|
3
|
+
import { d as strip_vendor_prefix, s as str_equals } from "./parse-dimension-CQELWb5z.js";
|
|
4
|
+
import { t as CSSNode } from "./css-node-C6TLE3qd.js";
|
|
5
|
+
import { s as trim_boundaries } from "./parse-selector-Ce5HUZJ5.js";
|
|
6
|
+
import { n as ConditionParser, t as ValueNodeParser } from "./value-node-parser-DfkneBdM.js";
|
|
7
7
|
//#region src/parse-atrule-prelude.ts
|
|
8
8
|
/** @internal */
|
|
9
9
|
var AtRulePreludeParser = class {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { l as CSSDataArena } from "./arena-
|
|
1
|
+
import { l as CSSDataArena } from "./arena-BGvFdbj5.js";
|
|
2
2
|
import { n as Lexer } from "./tokenize-CDEnYcVG.js";
|
|
3
|
-
import { d as Declaration } from "./node-types-
|
|
3
|
+
import { d as Declaration } from "./node-types-YnOKcNfU.js";
|
|
4
4
|
//#region src/parse-declaration.d.ts
|
|
5
5
|
/** @internal */
|
|
6
6
|
declare class DeclarationParser {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as Lexer } from "./tokenize-DK24ACbY.js";
|
|
2
|
-
import { l as CSSDataArena } from "./arena-
|
|
3
|
-
import {
|
|
4
|
-
import { t as CSSNode } from "./css-node-
|
|
5
|
-
import { a as skip_whitespace_and_comments_backward, s as trim_boundaries } from "./parse-selector-
|
|
2
|
+
import { l as CSSDataArena } from "./arena-e9O_g2AN.js";
|
|
3
|
+
import { a as is_vendor_prefixed } from "./parse-dimension-CQELWb5z.js";
|
|
4
|
+
import { t as CSSNode } from "./css-node-C6TLE3qd.js";
|
|
5
|
+
import { a as skip_whitespace_and_comments_backward, s as trim_boundaries } from "./parse-selector-Ce5HUZJ5.js";
|
|
6
6
|
import { ValueParser } from "./parse-value.js";
|
|
7
7
|
//#region src/parse-declaration.ts
|
|
8
8
|
/** @internal */
|
|
@@ -27,6 +27,20 @@ function str_equals(a, b) {
|
|
|
27
27
|
}
|
|
28
28
|
return true;
|
|
29
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Case-insensitive equality between `source[start, end)` and `literal`, without allocating
|
|
32
|
+
* a substring first. Same semantics as `str_equals(literal, source.substring(start, end))`.
|
|
33
|
+
* `literal` MUST be lowercase.
|
|
34
|
+
*/
|
|
35
|
+
function str_equals_range(source, start, end, literal) {
|
|
36
|
+
if (end - start !== literal.length) return false;
|
|
37
|
+
for (let i = 0; i < literal.length; i++) {
|
|
38
|
+
let ch = source.charCodeAt(start + i);
|
|
39
|
+
ch |= 32;
|
|
40
|
+
if (ch !== literal.charCodeAt(i)) return false;
|
|
41
|
+
}
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
30
44
|
/** Case-insensitive ASCII prefix check without allocations. `prefix` MUST be lowercase. */
|
|
31
45
|
function str_starts_with(str, prefix) {
|
|
32
46
|
if (str.length < prefix.length) return false;
|
|
@@ -89,8 +103,14 @@ function strip_vendor_prefix(str) {
|
|
|
89
103
|
}
|
|
90
104
|
//#endregion
|
|
91
105
|
//#region src/parse-dimension.ts
|
|
92
|
-
/**
|
|
93
|
-
|
|
106
|
+
/**
|
|
107
|
+
* Find where a dimension's numeric part ends, e.g. 3 for "100px" or 2 for "2%".
|
|
108
|
+
* No allocation — callers that only need `value` or only `unit` can slice just
|
|
109
|
+
* the part they want instead of going through `parse_dimension`'s object + two
|
|
110
|
+
* substrings for both.
|
|
111
|
+
* @internal
|
|
112
|
+
*/
|
|
113
|
+
function dimension_number_end(text) {
|
|
94
114
|
let num_end = 0;
|
|
95
115
|
for (let i = 0; i < text.length; i++) {
|
|
96
116
|
let ch = text.charCodeAt(i);
|
|
@@ -113,6 +133,11 @@ function parse_dimension(text) {
|
|
|
113
133
|
if (is_digit(ch) || ch === 46 || ch === 45 || ch === 43) num_end = i + 1;
|
|
114
134
|
else break;
|
|
115
135
|
}
|
|
136
|
+
return num_end;
|
|
137
|
+
}
|
|
138
|
+
/** Parse a dimension string into value and unit, e.g. "100px" → { value: 100, unit: "px" } or "2%" → { value: 2, unit: "%" } */
|
|
139
|
+
function parse_dimension(text) {
|
|
140
|
+
let num_end = dimension_number_end(text);
|
|
116
141
|
let num_str = text.substring(0, num_end);
|
|
117
142
|
let unit = text.substring(num_end);
|
|
118
143
|
return {
|
|
@@ -121,4 +146,4 @@ function parse_dimension(text) {
|
|
|
121
146
|
};
|
|
122
147
|
}
|
|
123
148
|
//#endregion
|
|
124
|
-
export {
|
|
149
|
+
export { is_vendor_prefixed as a, str_equals_range as c, strip_vendor_prefix as d, is_custom as i, str_index_of as l, parse_dimension as n, is_whitespace as o, is_combinator as r, str_equals as s, dimension_number_end as t, str_starts_with as u };
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
//#region src/parse-dimension.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Find where a dimension's numeric part ends, e.g. 3 for "100px" or 2 for "2%".
|
|
4
|
+
* No allocation — callers that only need `value` or only `unit` can slice just
|
|
5
|
+
* the part they want instead of going through `parse_dimension`'s object + two
|
|
6
|
+
* substrings for both.
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
declare function dimension_number_end(text: string): number;
|
|
2
10
|
/** Parse a dimension string into value and unit, e.g. "100px" → { value: 100, unit: "px" } or "2%" → { value: 2, unit: "%" } */
|
|
3
11
|
declare function parse_dimension(text: string): {
|
|
4
12
|
value: number;
|
|
5
13
|
unit: string;
|
|
6
14
|
};
|
|
7
15
|
//#endregion
|
|
8
|
-
export { parse_dimension };
|
|
16
|
+
export { dimension_number_end, parse_dimension };
|
package/dist/parse-dimension.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { parse_dimension };
|
|
1
|
+
import { n as parse_dimension, t as dimension_number_end } from "./parse-dimension-CQELWb5z.js";
|
|
2
|
+
export { dimension_number_end, parse_dimension };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as Lexer } from "./tokenize-DK24ACbY.js";
|
|
2
|
-
import { l as CSSDataArena } from "./arena-
|
|
3
|
-
import {
|
|
4
|
-
import { t as CSSNode } from "./css-node-
|
|
2
|
+
import { l as CSSDataArena } from "./arena-e9O_g2AN.js";
|
|
3
|
+
import { c as str_equals_range, o as is_whitespace, r as is_combinator } from "./parse-dimension-CQELWb5z.js";
|
|
4
|
+
import { t as CSSNode } from "./css-node-C6TLE3qd.js";
|
|
5
5
|
import { ANplusBParser } from "./parse-anplusb.js";
|
|
6
6
|
//#region src/parse-utils.ts
|
|
7
7
|
/** @internal */
|
|
@@ -424,26 +424,23 @@ var SelectorParser = class {
|
|
|
424
424
|
this.arena.set_content_start_delta(node, func_name_start - start);
|
|
425
425
|
this.arena.set_content_length(node, func_name_end - func_name_start);
|
|
426
426
|
this.arena.set_flag(node, 64);
|
|
427
|
-
if (content_end > content_start) {
|
|
428
|
-
let
|
|
429
|
-
if (this.
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
this.lexer.restore_position(saved);
|
|
440
|
-
if (child_selector !== null) this.arena.set_first_child(node, child_selector);
|
|
441
|
-
}
|
|
427
|
+
if (content_end > content_start) if (this.is_nth_pseudo(func_name_start, func_name_end)) {
|
|
428
|
+
let child = this.parse_nth_expression(content_start, content_end);
|
|
429
|
+
if (child !== null) this.arena.set_first_child(node, child);
|
|
430
|
+
} else if (str_equals_range(this.source, func_name_start, func_name_end, "lang")) this.parse_lang_identifiers(content_start, content_end, node);
|
|
431
|
+
else {
|
|
432
|
+
let saved_selector_end = this.selector_end;
|
|
433
|
+
const saved = this.lexer.save_position();
|
|
434
|
+
let allow_relative = str_equals_range(this.source, func_name_start, func_name_end, "has");
|
|
435
|
+
let child_selector = this.parse_selector(content_start, content_end, this.lexer.line, this.lexer.column, allow_relative);
|
|
436
|
+
this.selector_end = saved_selector_end;
|
|
437
|
+
this.lexer.restore_position(saved);
|
|
438
|
+
if (child_selector !== null) this.arena.set_first_child(node, child_selector);
|
|
442
439
|
}
|
|
443
440
|
return node;
|
|
444
441
|
}
|
|
445
|
-
is_nth_pseudo(
|
|
446
|
-
return
|
|
442
|
+
is_nth_pseudo(start, end) {
|
|
443
|
+
return str_equals_range(this.source, start, end, "nth-child") || str_equals_range(this.source, start, end, "nth-last-child") || str_equals_range(this.source, start, end, "nth-of-type") || str_equals_range(this.source, start, end, "nth-last-of-type") || str_equals_range(this.source, start, end, "nth-col") || str_equals_range(this.source, start, end, "nth-last-col");
|
|
447
444
|
}
|
|
448
445
|
parse_lang_identifiers(start, end, parent_node) {
|
|
449
446
|
const saved_position = this.lexer.save_position();
|
package/dist/parse-selector.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { l as CSSDataArena } from "./arena-
|
|
2
|
-
import {
|
|
1
|
+
import { l as CSSDataArena } from "./arena-BGvFdbj5.js";
|
|
2
|
+
import { R as Selector, z as SelectorList } from "./node-types-YnOKcNfU.js";
|
|
3
3
|
//#region src/parse-selector.d.ts
|
|
4
4
|
/** @internal */
|
|
5
5
|
declare class SelectorParser {
|
package/dist/parse-selector.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as parse_selector, r as parse_selector_list, t as SelectorParser } from "./parse-selector-
|
|
1
|
+
import { n as parse_selector, r as parse_selector_list, t as SelectorParser } from "./parse-selector-Ce5HUZJ5.js";
|
|
2
2
|
export { SelectorParser, parse_selector, parse_selector_list };
|
package/dist/parse-value.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { l as CSSDataArena } from "./arena-
|
|
2
|
-
import {
|
|
1
|
+
import { l as CSSDataArena } from "./arena-BGvFdbj5.js";
|
|
2
|
+
import { X as Value } from "./node-types-YnOKcNfU.js";
|
|
3
3
|
//#region src/parse-value.d.ts
|
|
4
4
|
/** @internal */
|
|
5
5
|
declare class ValueParser {
|
package/dist/parse-value.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { l as CSSDataArena } from "./arena-
|
|
2
|
-
import { t as CSSNode } from "./css-node-
|
|
3
|
-
import { t as ValueNodeParser } from "./value-node-parser-
|
|
1
|
+
import { l as CSSDataArena } from "./arena-e9O_g2AN.js";
|
|
2
|
+
import { t as CSSNode } from "./css-node-C6TLE3qd.js";
|
|
3
|
+
import { t as ValueNodeParser } from "./value-node-parser-DfkneBdM.js";
|
|
4
4
|
//#region src/parse-value.ts
|
|
5
5
|
/** @internal */
|
|
6
6
|
var ValueParser = class {
|
package/dist/parse.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { l as CSSDataArena } from "./arena-
|
|
1
|
+
import { l as CSSDataArena } from "./arena-BGvFdbj5.js";
|
|
2
2
|
import { t as CommentInfo } from "./tokenize-CDEnYcVG.js";
|
|
3
|
-
import {
|
|
3
|
+
import { H as StyleSheet } from "./node-types-YnOKcNfU.js";
|
|
4
4
|
//#region src/parse.d.ts
|
|
5
5
|
interface ParserOptions {
|
|
6
6
|
parse_values?: boolean;
|
package/dist/parse.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as Lexer } from "./tokenize-DK24ACbY.js";
|
|
2
|
-
import { l as CSSDataArena } from "./arena-
|
|
3
|
-
import { t as CSSNode } from "./css-node-
|
|
4
|
-
import { a as skip_whitespace_and_comments_backward, s as trim_boundaries, t as SelectorParser } from "./parse-selector-
|
|
2
|
+
import { l as CSSDataArena } from "./arena-e9O_g2AN.js";
|
|
3
|
+
import { t as CSSNode } from "./css-node-C6TLE3qd.js";
|
|
4
|
+
import { a as skip_whitespace_and_comments_backward, s as trim_boundaries, t as SelectorParser } from "./parse-selector-Ce5HUZJ5.js";
|
|
5
5
|
import { AtRulePreludeParser } from "./parse-atrule-prelude.js";
|
|
6
6
|
import { DeclarationParser } from "./parse-declaration.js";
|
|
7
7
|
//#region src/parse.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as Lexer } from "./tokenize-DK24ACbY.js";
|
|
2
|
-
import "./arena-
|
|
3
|
-
import {
|
|
4
|
-
import { i as find_colon_at_depth_zero, o as skip_whitespace_and_comments_forward, s as trim_boundaries, t as SelectorParser } from "./parse-selector-
|
|
2
|
+
import "./arena-e9O_g2AN.js";
|
|
3
|
+
import { c as str_equals_range, s as str_equals } from "./parse-dimension-CQELWb5z.js";
|
|
4
|
+
import { i as find_colon_at_depth_zero, o as skip_whitespace_and_comments_forward, s as trim_boundaries, t as SelectorParser } from "./parse-selector-Ce5HUZJ5.js";
|
|
5
5
|
//#region src/parse-condition.ts
|
|
6
6
|
/** @internal */
|
|
7
7
|
var ConditionParser = class {
|
|
@@ -316,8 +316,9 @@ var ValueNodeParser = class ValueNodeParser {
|
|
|
316
316
|
while (this.lexer.pos < this.end) {
|
|
317
317
|
this.lexer.next_token_fast(false);
|
|
318
318
|
if (this.lexer.token_start >= this.end) break;
|
|
319
|
-
|
|
320
|
-
if (
|
|
319
|
+
let token_type = this.lexer.token_type;
|
|
320
|
+
if (token_type === 26) break;
|
|
321
|
+
if (token_type === 13) continue;
|
|
321
322
|
let node = this.parse_value_node();
|
|
322
323
|
if (node !== null) {
|
|
323
324
|
if (first_node === 0) first_node = node;
|
|
@@ -328,11 +329,6 @@ var ValueNodeParser = class ValueNodeParser {
|
|
|
328
329
|
this.last_chain_node = last_node;
|
|
329
330
|
return first_node;
|
|
330
331
|
}
|
|
331
|
-
is_whitespace_inline() {
|
|
332
|
-
if (this.lexer.token_start >= this.lexer.token_end) return false;
|
|
333
|
-
for (let i = this.lexer.token_start; i < this.lexer.token_end; i++) if (!is_whitespace(this.source.charCodeAt(i))) return false;
|
|
334
|
-
return true;
|
|
335
|
-
}
|
|
336
332
|
parse_value_node() {
|
|
337
333
|
let token_type = this.lexer.token_type;
|
|
338
334
|
let start = this.lexer.token_start;
|
|
@@ -390,15 +386,15 @@ var ValueNodeParser = class ValueNodeParser {
|
|
|
390
386
|
}
|
|
391
387
|
parse_function_node(start, end) {
|
|
392
388
|
let name_end = end - 1;
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
let node = this.arena.create_node(
|
|
389
|
+
if (str_equals_range(this.source, start, name_end, "if")) return this.parse_if_function_node(start, end);
|
|
390
|
+
let is_url = str_equals_range(this.source, start, name_end, "url");
|
|
391
|
+
let node = this.arena.create_node(is_url ? 18 : 15, start, 0, this.lexer.token_line, this.lexer.token_column);
|
|
396
392
|
this.arena.set_content_start_delta(node, 0);
|
|
397
393
|
this.arena.set_content_length(node, name_end - start);
|
|
398
|
-
if (
|
|
394
|
+
if (is_url || str_equals_range(this.source, start, name_end, "src")) {
|
|
399
395
|
let save_pos = this.lexer.save_position();
|
|
400
396
|
this.lexer.next_token_fast(false);
|
|
401
|
-
while (this.
|
|
397
|
+
while (this.lexer.token_type === 13 && this.lexer.pos < this.end) this.lexer.next_token_fast(false);
|
|
402
398
|
let first_token_type = this.lexer.token_type;
|
|
403
399
|
this.lexer.restore_position(save_pos);
|
|
404
400
|
if (first_token_type === 5) {} else {
|
|
@@ -435,7 +431,7 @@ var ValueNodeParser = class ValueNodeParser {
|
|
|
435
431
|
break;
|
|
436
432
|
}
|
|
437
433
|
}
|
|
438
|
-
if (
|
|
434
|
+
if (token_type === 13) continue;
|
|
439
435
|
let arg_node = this.parse_value_node();
|
|
440
436
|
if (arg_node !== null) {
|
|
441
437
|
if (first_arg === 0) first_arg = arg_node;
|
|
@@ -482,13 +478,11 @@ var ValueNodeParser = class ValueNodeParser {
|
|
|
482
478
|
func_end = this.lexer.token_end;
|
|
483
479
|
break;
|
|
484
480
|
}
|
|
485
|
-
if (
|
|
481
|
+
if (tt === 13 || tt === 17 || tt === 16) continue;
|
|
486
482
|
let branch_start = this.lexer.token_start;
|
|
487
483
|
let branch_line = this.lexer.token_line;
|
|
488
484
|
let branch_col = this.lexer.token_column;
|
|
489
|
-
let condition_node;
|
|
490
|
-
if (tt === 2) condition_node = this.parse_if_condition_function(this.lexer.token_start, this.lexer.token_end);
|
|
491
|
-
else condition_node = this.parse_value_node();
|
|
485
|
+
let condition_node = this.parse_if_condition();
|
|
492
486
|
if (condition_node === null) continue;
|
|
493
487
|
let condition_end_pos = this.arena.get_start_offset(condition_node) + this.arena.get_length(condition_node);
|
|
494
488
|
let colon_found = false;
|
|
@@ -497,7 +491,7 @@ var ValueNodeParser = class ValueNodeParser {
|
|
|
497
491
|
let t = this.lexer.token_type;
|
|
498
492
|
if (t === 26) break;
|
|
499
493
|
if (this.lexer.token_start >= this.end) break;
|
|
500
|
-
if (
|
|
494
|
+
if (t === 13) continue;
|
|
501
495
|
if (t === 16) {
|
|
502
496
|
colon_found = true;
|
|
503
497
|
break;
|
|
@@ -519,7 +513,7 @@ var ValueNodeParser = class ValueNodeParser {
|
|
|
519
513
|
let t = this.lexer.token_type;
|
|
520
514
|
if (t === 26) break;
|
|
521
515
|
if (this.lexer.token_start >= this.end) break;
|
|
522
|
-
if (
|
|
516
|
+
if (t === 13) continue;
|
|
523
517
|
if (t === 17) break;
|
|
524
518
|
if (t === 22) {
|
|
525
519
|
content_end = this.lexer.token_start;
|
|
@@ -563,6 +557,83 @@ var ValueNodeParser = class ValueNodeParser {
|
|
|
563
557
|
this.arena.append_children(node, branches);
|
|
564
558
|
return node;
|
|
565
559
|
}
|
|
560
|
+
is_and_or_not(str) {
|
|
561
|
+
return str_equals("and", str) || str_equals("or", str) || str_equals("not", str);
|
|
562
|
+
}
|
|
563
|
+
next_significant_token() {
|
|
564
|
+
while (this.lexer.pos < this.end) {
|
|
565
|
+
this.lexer.next_token_fast(false);
|
|
566
|
+
if (this.lexer.token_start >= this.end) return 26;
|
|
567
|
+
if (this.lexer.token_type === 13) continue;
|
|
568
|
+
return this.lexer.token_type;
|
|
569
|
+
}
|
|
570
|
+
return 26;
|
|
571
|
+
}
|
|
572
|
+
/**
|
|
573
|
+
* Parse an if()-branch condition:
|
|
574
|
+
* <if-condition> = <boolean-expr[ <if-test> ]> | else
|
|
575
|
+
* <if-test> = style(…) | media(…) | supports(…)
|
|
576
|
+
* i.e. a single test function, the bare "else" identifier, or those test functions
|
|
577
|
+
* combined with not/and/or (e.g. "not style(--x: 1)", "style(--a: 1) and media(width > 600px)").
|
|
578
|
+
* Called with the lexer's current token already positioned at the condition's first token.
|
|
579
|
+
* A simple single-function/"else" condition returns that node directly, unwrapped (matching
|
|
580
|
+
* prior behavior); a compound not/and/or condition wraps the flat operator/function chain in
|
|
581
|
+
* an IF_CONDITION node so IfBranch.condition/.value (single first_child/next_sibling hops)
|
|
582
|
+
* still see exactly one node for "the condition".
|
|
583
|
+
*/
|
|
584
|
+
parse_if_condition() {
|
|
585
|
+
if (this.lexer.token_type === 1) {
|
|
586
|
+
let text = this.source.substring(this.lexer.token_start, this.lexer.token_end);
|
|
587
|
+
if (str_equals("else", text)) return this.parse_value_node();
|
|
588
|
+
}
|
|
589
|
+
let first = 0;
|
|
590
|
+
let last = 0;
|
|
591
|
+
let component_count = 0;
|
|
592
|
+
let compound = false;
|
|
593
|
+
for (;;) {
|
|
594
|
+
let tt = this.lexer.token_type;
|
|
595
|
+
let component = null;
|
|
596
|
+
let is_operator = false;
|
|
597
|
+
if (tt === 2) component = this.parse_if_condition_function(this.lexer.token_start, this.lexer.token_end);
|
|
598
|
+
else if (tt === 1) {
|
|
599
|
+
let text = this.source.substring(this.lexer.token_start, this.lexer.token_end);
|
|
600
|
+
if (this.is_and_or_not(text)) {
|
|
601
|
+
is_operator = true;
|
|
602
|
+
component = this.arena.create_node(38, this.lexer.token_start, this.lexer.token_end - this.lexer.token_start, this.lexer.token_line, this.lexer.token_column);
|
|
603
|
+
} else component = this.parse_value_node();
|
|
604
|
+
} else component = this.parse_value_node();
|
|
605
|
+
if (component !== null) {
|
|
606
|
+
component_count++;
|
|
607
|
+
if (first === 0) first = component;
|
|
608
|
+
else this.arena.set_next_sibling(last, component);
|
|
609
|
+
last = component;
|
|
610
|
+
}
|
|
611
|
+
if (tt !== 2 && !is_operator) break;
|
|
612
|
+
let saved = this.lexer.save_position();
|
|
613
|
+
let next_tt = this.next_significant_token();
|
|
614
|
+
if (next_tt === 2) {
|
|
615
|
+
compound = true;
|
|
616
|
+
continue;
|
|
617
|
+
}
|
|
618
|
+
if (next_tt === 1) {
|
|
619
|
+
let text = this.source.substring(this.lexer.token_start, this.lexer.token_end);
|
|
620
|
+
if (this.is_and_or_not(text)) {
|
|
621
|
+
compound = true;
|
|
622
|
+
continue;
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
this.lexer.restore_position(saved);
|
|
626
|
+
break;
|
|
627
|
+
}
|
|
628
|
+
if (first === 0) return null;
|
|
629
|
+
if (component_count === 1 && !compound) return first;
|
|
630
|
+
let wrapper_start = this.arena.get_start_offset(first);
|
|
631
|
+
let last_sibling = this.arena.get_last_sibling(first);
|
|
632
|
+
let wrapper_end = this.arena.get_start_offset(last_sibling) + this.arena.get_length(last_sibling);
|
|
633
|
+
let wrapper = this.arena.create_node(60, wrapper_start, wrapper_end - wrapper_start, this.arena.get_start_line(first), this.arena.get_start_column(first));
|
|
634
|
+
this.arena.set_first_child(wrapper, first);
|
|
635
|
+
return wrapper;
|
|
636
|
+
}
|
|
566
637
|
/**
|
|
567
638
|
* Parse a condition function inside if() — style(), supports(), or media(). Content parsing
|
|
568
639
|
* is delegated to the shared ConditionParser (see parse-condition.ts), so these produce the
|
|
@@ -597,7 +668,8 @@ var ValueNodeParser = class ValueNodeParser {
|
|
|
597
668
|
let child_nodes = [];
|
|
598
669
|
if (str_equals("style", func_name)) {
|
|
599
670
|
let decl = this.condition_parser.parse_supports_declaration_content(content_start, content_end);
|
|
600
|
-
if (decl
|
|
671
|
+
if (decl === null) child_nodes = this.condition_parser.parse_supports_condition(content_start, content_end, func_line, func_col);
|
|
672
|
+
else child_nodes = [decl];
|
|
601
673
|
} else if (str_equals("supports", func_name)) {
|
|
602
674
|
let decl = this.condition_parser.parse_supports_declaration_content(content_start, content_end);
|
|
603
675
|
if (decl === null) child_nodes = this.condition_parser.parse_supports_condition(content_start, content_end, func_line, func_col);
|
|
@@ -617,8 +689,9 @@ var ValueNodeParser = class ValueNodeParser {
|
|
|
617
689
|
while (this.lexer.pos < this.end) {
|
|
618
690
|
this.lexer.next_token_fast(false);
|
|
619
691
|
if (this.lexer.token_start >= this.end) break;
|
|
620
|
-
|
|
621
|
-
if (
|
|
692
|
+
let token_type = this.lexer.token_type;
|
|
693
|
+
if (token_type === 26) break;
|
|
694
|
+
if (token_type === 13) continue;
|
|
622
695
|
let node = this.parse_value_node();
|
|
623
696
|
if (node !== null) nodes.push(node);
|
|
624
697
|
}
|
|
@@ -644,7 +717,7 @@ var ValueNodeParser = class ValueNodeParser {
|
|
|
644
717
|
break;
|
|
645
718
|
}
|
|
646
719
|
}
|
|
647
|
-
if (
|
|
720
|
+
if (token_type === 13) continue;
|
|
648
721
|
let child_node = this.parse_value_node();
|
|
649
722
|
if (child_node !== null) {
|
|
650
723
|
if (first_child === 0) first_child = child_node;
|
package/dist/walk.d.ts
CHANGED
package/dist/walk.js
CHANGED