@projectwallace/css-parser 0.19.1 → 0.19.3
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/README.md +1 -0
- package/dist/{arena-CsJhQRUX.js → arena-D123N1LO.js} +6 -2
- package/dist/{arena-7RLvyGPB.d.ts → arena-DnAc8Oy_.d.ts} +4 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/{css-node-BJnbanUS.js → css-node-D9rqMgMI.js} +3 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/{node-types-BZGPDESt.d.ts → node-types-Pa1MR4CP.d.ts} +7 -4
- package/dist/node-types.d.ts +1 -1
- package/dist/node-types.js +1 -1
- package/dist/parse-anplusb.d.ts +2 -2
- package/dist/parse-anplusb.js +2 -2
- package/dist/parse-atrule-prelude.d.ts +13 -4
- package/dist/parse-atrule-prelude.js +10 -10
- package/dist/parse-declaration.d.ts +3 -3
- package/dist/parse-declaration.js +5 -5
- package/dist/{parse-selector-B59fV-Ya.js → parse-selector-BMeyZ-oJ.js} +2 -2
- package/dist/parse-selector.d.ts +2 -2
- package/dist/parse-selector.js +1 -1
- package/dist/parse-value.d.ts +3 -3
- package/dist/parse-value.js +5 -5
- package/dist/parse.d.ts +9 -2
- package/dist/parse.js +6 -6
- package/dist/{value-node-parser-BBlVw-en.js → value-node-parser-ysQ7ssqf.js} +17 -5
- package/dist/walk.d.ts +1 -1
- package/dist/walk.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -100,6 +100,7 @@ Options:
|
|
|
100
100
|
- `parse_values` (default `true`) — parse declaration values into nodes
|
|
101
101
|
- `parse_selectors` (default `true`) — parse selectors into nodes
|
|
102
102
|
- `parse_atrule_preludes` (default `true`) — parse at-rule preludes into nodes
|
|
103
|
+
- `media_feature_range_name_as_child` (default `false`) — also add the feature name of a media range (`width` in `(400px < width < 1000px)`) as an `Identifier` child, so the children read in source order. `name` is set either way. **Deprecated:** this will become the default in 0.20.0 and the option will be removed, so opt in now to prepare
|
|
103
104
|
- `on_comment` — called for every comment (`{ start, end, length, line, column }`); comments are never part of the tree
|
|
104
105
|
|
|
105
106
|
### Sub-parsers
|
|
@@ -56,6 +56,9 @@ var CSSDataArena = class CSSDataArena {
|
|
|
56
56
|
overflow_lengths;
|
|
57
57
|
static GROWTH_FACTOR = 1.3;
|
|
58
58
|
static NODES_PER_KB = 210;
|
|
59
|
+
static NODES_PER_KB_NO_VALUES = 150;
|
|
60
|
+
static NODES_PER_KB_NO_SELECTORS = 180;
|
|
61
|
+
static NODES_PER_KB_NO_VALUES_NO_SELECTORS = 120;
|
|
59
62
|
static CAPACITY_BUFFER = 1.1;
|
|
60
63
|
constructor(initial_capacity = 1024) {
|
|
61
64
|
this.capacity = initial_capacity;
|
|
@@ -65,9 +68,10 @@ var CSSDataArena = class CSSDataArena {
|
|
|
65
68
|
this.view = new DataView(this.buffer);
|
|
66
69
|
this.overflow_lengths = /* @__PURE__ */ new Map();
|
|
67
70
|
}
|
|
68
|
-
static capacity_for_source(source_length) {
|
|
71
|
+
static capacity_for_source(source_length, parse_values = true, parse_selectors = true) {
|
|
72
|
+
const nodes_per_kb = parse_values ? parse_selectors ? CSSDataArena.NODES_PER_KB : CSSDataArena.NODES_PER_KB_NO_SELECTORS : parse_selectors ? CSSDataArena.NODES_PER_KB_NO_VALUES : CSSDataArena.NODES_PER_KB_NO_VALUES_NO_SELECTORS;
|
|
69
73
|
const size_in_kb = source_length / 1024;
|
|
70
|
-
const estimated_nodes = Math.ceil(size_in_kb *
|
|
74
|
+
const estimated_nodes = Math.ceil(size_in_kb * nodes_per_kb);
|
|
71
75
|
const capacity = Math.ceil(estimated_nodes * CSSDataArena.CAPACITY_BUFFER);
|
|
72
76
|
return Math.max(16, capacity);
|
|
73
77
|
}
|
|
@@ -56,9 +56,12 @@ declare class CSSDataArena {
|
|
|
56
56
|
private overflow_lengths;
|
|
57
57
|
private static readonly GROWTH_FACTOR;
|
|
58
58
|
private static readonly NODES_PER_KB;
|
|
59
|
+
private static readonly NODES_PER_KB_NO_VALUES;
|
|
60
|
+
private static readonly NODES_PER_KB_NO_SELECTORS;
|
|
61
|
+
private static readonly NODES_PER_KB_NO_VALUES_NO_SELECTORS;
|
|
59
62
|
private static readonly CAPACITY_BUFFER;
|
|
60
63
|
constructor(initial_capacity?: number);
|
|
61
|
-
static capacity_for_source(source_length: number): number;
|
|
64
|
+
static capacity_for_source(source_length: number, parse_values?: boolean, parse_selectors?: boolean): number;
|
|
62
65
|
get_count(): number;
|
|
63
66
|
get_capacity(): number;
|
|
64
67
|
get_growth_count(): number;
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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-
|
|
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-DnAc8Oy_.js";
|
|
2
2
|
//#region src/constants.d.ts
|
|
3
3
|
export declare const NODE_TYPES: {
|
|
4
4
|
readonly STYLESHEET: 1;
|
package/dist/constants.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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-
|
|
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-D123N1LO.js";
|
|
2
2
|
//#region src/constants.ts
|
|
3
3
|
const NODE_TYPES = {
|
|
4
4
|
STYLESHEET: 1,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./arena-
|
|
1
|
+
import "./arena-D123N1LO.js";
|
|
2
2
|
import { a as is_vendor_prefixed, o as is_whitespace, s as str_equals, u as str_starts_with } from "./string-utils-aEEsA2CS.js";
|
|
3
3
|
import { dimension_number_end } from "./parse-dimension.js";
|
|
4
4
|
//#region src/css-node.ts
|
|
@@ -185,6 +185,7 @@ var CSSNode = class CSSNode {
|
|
|
185
185
|
} else if (text.startsWith("\"") || text.startsWith("'")) return text;
|
|
186
186
|
}
|
|
187
187
|
if (type === 16 || type === 37) return this.get_content();
|
|
188
|
+
if (type === 38) return text;
|
|
188
189
|
if (type !== 4 && type !== 15 && type !== 24 && type !== 36 && type !== 41) return;
|
|
189
190
|
const start = this.arena.get_value_start(this.index);
|
|
190
191
|
const length = this.arena.get_value_length(this.index);
|
|
@@ -434,7 +435,7 @@ var CSSNode = class CSSNode {
|
|
|
434
435
|
plain.length = this.length;
|
|
435
436
|
plain.end = this.end;
|
|
436
437
|
}
|
|
437
|
-
if (deep && nodes_with_children.has(type)) {
|
|
438
|
+
if (deep && (nodes_with_children.has(type) || this.has_children)) {
|
|
438
439
|
plain.children = [];
|
|
439
440
|
plain.child_count = this.child_count;
|
|
440
441
|
plain.has_children = this.has_children;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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-
|
|
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-DnAc8Oy_.js";
|
|
2
2
|
import { NODE_TYPES } from "./constants.js";
|
|
3
3
|
import { C as TOKEN_SEMICOLON, D as TOKEN_WHITESPACE, E as TOKEN_URL, O as Token, S as TOKEN_RIGHT_PAREN, T as TOKEN_UNICODE_RANGE, _ as TOKEN_LEFT_PAREN, a as TOKEN_CDO, b as TOKEN_RIGHT_BRACE, c as TOKEN_COMMENT, d as TOKEN_EOF, f as TOKEN_FUNCTION, g as TOKEN_LEFT_BRACKET, h as TOKEN_LEFT_BRACE, i as TOKEN_CDC, k as TokenType, l as TOKEN_DELIM, m as TOKEN_IDENT, n as TOKEN_BAD_STRING, o as TOKEN_COLON, p as TOKEN_HASH, r as TOKEN_BAD_URL, s as TOKEN_COMMA, t as TOKEN_AT_KEYWORD, u as TOKEN_DIMENSION, v as TOKEN_NUMBER, w as TOKEN_STRING, x as TOKEN_RIGHT_BRACKET, y as TOKEN_PERCENTAGE } from "./token-types-Bqsf5FX-.js";
|
|
4
4
|
import { CommentInfo, LexerPosition, tokenize } from "./tokenize.js";
|
|
5
|
-
import { $ as is_atrule, A as Operator, At as is_pseudo_element_selector, B as SelectorList, Bt as is_type_selector, C as MediaFeature, Ct as is_nth_selector, D as NthOfSelector, Dt as is_prelude_operator, E as NestingSelector, Et as is_parenthesis, F as PseudoElementSelector, Ft as is_selector_list, G as SupportsQuery, Gt as CloneOptions, H as String, Ht as is_universal_selector, I as Ratio, It as is_string, J as UnicodeRange, K as ToPlain, Kt as PlainCSSNode, L as Raw, Lt as is_stylesheet, M as PreludeOperator, Mt as is_raw, N as PreludeSelectorList, Nt as is_rule, O as NthSelector, Ot as is_prelude_selectorlist, P as PseudoClassSelector, Pt as is_selector, Q as WithChildren, R as Rule, Rt as is_supports_declaration, S as LayerName, St as is_nth_of_selector, T as MediaType, Tt as is_operator, U as StyleSheet, Ut as is_url, V as SelectorNode, Vt as is_unicode_range, W as SupportsDeclaration, Wt as is_value, X as Url, Y as UniversalSelector, Z as Value, _ as IdSelector, _t as is_layer_name, a as Block, at as is_comment, b as IfCondition, bt as is_media_type, c as ClassSelector, ct as is_dimension, d as ContainerQuery, dt as is_hash, et as is_atrule_prelude, f as Declaration, ft as is_id_selector, g as Hash, gt as is_lang_selector, h as Function, ht as is_if_condition, i as AttributeSelector, it as is_combinator, j as Parenthesis, jt as is_ratio, k as Number, kt as is_pseudo_class_selector, l as Combinator, lt as is_feature_range, m as FeatureRange, mt as is_if_branch, n as Atrule, nt as is_block, ot as is_container_query, p as Dimension, pt as is_identifier, q as TypeSelector, r as AtrulePrelude, rt as is_class_selector, s as CSSNode, st as is_declaration, t as AnyNode, tt as is_attribute_selector, u as Comment, ut as is_function, v as Identifier, vt as is_media_feature, w as MediaQuery, wt as is_number, x as LangSelector, xt as is_nesting_selector, y as IfBranch, yt as is_media_query, z as Selector, zt as is_supports_query } from "./node-types-
|
|
5
|
+
import { $ as is_atrule, A as Operator, At as is_pseudo_element_selector, B as SelectorList, Bt as is_type_selector, C as MediaFeature, Ct as is_nth_selector, D as NthOfSelector, Dt as is_prelude_operator, E as NestingSelector, Et as is_parenthesis, F as PseudoElementSelector, Ft as is_selector_list, G as SupportsQuery, Gt as CloneOptions, H as String, Ht as is_universal_selector, I as Ratio, It as is_string, J as UnicodeRange, K as ToPlain, Kt as PlainCSSNode, L as Raw, Lt as is_stylesheet, M as PreludeOperator, Mt as is_raw, N as PreludeSelectorList, Nt as is_rule, O as NthSelector, Ot as is_prelude_selectorlist, P as PseudoClassSelector, Pt as is_selector, Q as WithChildren, R as Rule, Rt as is_supports_declaration, S as LayerName, St as is_nth_of_selector, T as MediaType, Tt as is_operator, U as StyleSheet, Ut as is_url, V as SelectorNode, Vt as is_unicode_range, W as SupportsDeclaration, Wt as is_value, X as Url, Y as UniversalSelector, Z as Value, _ as IdSelector, _t as is_layer_name, a as Block, at as is_comment, b as IfCondition, bt as is_media_type, c as ClassSelector, ct as is_dimension, d as ContainerQuery, dt as is_hash, et as is_atrule_prelude, f as Declaration, ft as is_id_selector, g as Hash, gt as is_lang_selector, h as Function, ht as is_if_condition, i as AttributeSelector, it as is_combinator, j as Parenthesis, jt as is_ratio, k as Number, kt as is_pseudo_class_selector, l as Combinator, lt as is_feature_range, m as FeatureRange, mt as is_if_branch, n as Atrule, nt as is_block, ot as is_container_query, p as Dimension, pt as is_identifier, q as TypeSelector, r as AtrulePrelude, rt as is_class_selector, s as CSSNode, st as is_declaration, t as AnyNode, tt as is_attribute_selector, u as Comment, ut as is_function, v as Identifier, vt as is_media_feature, w as MediaQuery, wt as is_number, x as LangSelector, xt as is_nesting_selector, y as IfBranch, yt as is_media_query, z as Selector, zt as is_supports_query } from "./node-types-Pa1MR4CP.js";
|
|
6
6
|
import { ParserOptions, parse } from "./parse.js";
|
|
7
7
|
import { parse_selector, parse_selector_list } from "./parse-selector.js";
|
|
8
8
|
import { parse_atrule_prelude } from "./parse-atrule-prelude.js";
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { n as tokenize } from "./tokenize-B2QSzdrM.js";
|
|
2
2
|
import { 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 } from "./token-types.js";
|
|
3
|
-
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-
|
|
3
|
+
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-D123N1LO.js";
|
|
4
4
|
import { a as is_vendor_prefixed, d as strip_vendor_prefix, l as str_index_of, r as is_custom, s as str_equals, u as str_starts_with } from "./string-utils-aEEsA2CS.js";
|
|
5
5
|
import { parse_dimension } from "./parse-dimension.js";
|
|
6
|
-
import { n as parse_selector, r as parse_selector_list } from "./parse-selector-
|
|
6
|
+
import { n as parse_selector, r as parse_selector_list } from "./parse-selector-BMeyZ-oJ.js";
|
|
7
7
|
import { parse_atrule_prelude } from "./parse-atrule-prelude.js";
|
|
8
8
|
import { parse_value } from "./parse-value.js";
|
|
9
9
|
import { parse_declaration } from "./parse-declaration.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
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-
|
|
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-DnAc8Oy_.js";
|
|
2
2
|
//#region src/css-node.d.ts
|
|
3
3
|
type TypeName = 'StyleSheet' | 'Rule' | 'Atrule' | 'Declaration' | 'Selector' | 'Comment' | 'Block' | 'Raw' | 'Identifier' | 'Number' | 'Dimension' | 'String' | 'Hash' | 'Function' | 'Operator' | 'Parentheses' | 'Url' | 'UnicodeRange' | 'Value' | 'SelectorList' | 'TypeSelector' | 'ClassSelector' | 'IdSelector' | 'AttributeSelector' | 'PseudoClassSelector' | 'PseudoElementSelector' | 'Combinator' | 'UniversalSelector' | 'NestingSelector' | 'Nth' | 'NthOf' | 'Lang' | 'MediaQuery' | 'Feature' | 'MediaType' | 'ContainerQuery' | 'SupportsQuery' | 'SupportsDeclaration' | 'Layer' | 'MediaFeatureRange' | 'AtrulePrelude' | 'PreludeSelectorList' | 'Ratio' | 'IfBranch' | 'IfCondition' | 'unknown';
|
|
4
4
|
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;
|
|
@@ -330,11 +330,14 @@ type PreludeSelectorList = WithClone<CSSNode & WithChildren<SelectorList> & {
|
|
|
330
330
|
readonly type_name: 'PreludeSelectorList';
|
|
331
331
|
readonly value: string;
|
|
332
332
|
}>;
|
|
333
|
-
type PreludeOperator = Leaf<typeof PRELUDE_OPERATOR, 'Operator'
|
|
334
|
-
|
|
333
|
+
type PreludeOperator = Leaf<typeof PRELUDE_OPERATOR, 'Operator', {
|
|
334
|
+
/** The operator keyword or range comparator, e.g. "and", "or", "not", "only", "to", "<", "<=", ">", ">=", "=" */
|
|
335
|
+
readonly value: string;
|
|
336
|
+
}>;
|
|
337
|
+
type FeatureRange = WithClone<CSSNode & WithChildren<Dimension | Function | Identifier | PreludeOperator> & {
|
|
335
338
|
readonly type: typeof FEATURE_RANGE;
|
|
336
339
|
readonly type_name: 'MediaFeatureRange';
|
|
337
|
-
/** The feature name in a range comparison, e.g. "width" from "(width >= 400px)" */
|
|
340
|
+
/** The feature name in a range comparison, e.g. "width" from "(width >= 400px)". Also present as an Identifier child, in source order. */
|
|
338
341
|
readonly name: string;
|
|
339
342
|
}>;
|
|
340
343
|
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;
|
package/dist/node-types.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as is_atrule, A as Operator, At as is_pseudo_element_selector, B as SelectorList, Bt as is_type_selector, C as MediaFeature, Ct as is_nth_selector, D as NthOfSelector, Dt as is_prelude_operator, E as NestingSelector, Et as is_parenthesis, F as PseudoElementSelector, Ft as is_selector_list, G as SupportsQuery, Gt as CloneOptions, H as String, Ht as is_universal_selector, I as Ratio, It as is_string, J as UnicodeRange, K as ToPlain, Kt as PlainCSSNode, L as Raw, Lt as is_stylesheet, M as PreludeOperator, Mt as is_raw, N as PreludeSelectorList, Nt as is_rule, O as NthSelector, Ot as is_prelude_selectorlist, P as PseudoClassSelector, Pt as is_selector, Q as WithChildren, R as Rule, Rt as is_supports_declaration, S as LayerName, St as is_nth_of_selector, T as MediaType, Tt as is_operator, U as StyleSheet, Ut as is_url, V as SelectorNode, Vt as is_unicode_range, W as SupportsDeclaration, Wt as is_value, X as Url, Y as UniversalSelector, Z as Value, _ as IdSelector, _t as is_layer_name, a as Block, at as is_comment, b as IfCondition, bt as is_media_type, c as ClassSelector, ct as is_dimension, d as ContainerQuery, dt as is_hash, et as is_atrule_prelude, f as Declaration, ft as is_id_selector, g as Hash, gt as is_lang_selector, h as Function, ht as is_if_condition, i as AttributeSelector, it as is_combinator, j as Parenthesis, jt as is_ratio, k as Number, kt as is_pseudo_class_selector, l as Combinator, lt as is_feature_range, m as FeatureRange, mt as is_if_branch, n as Atrule, nt as is_block, o as BlockChild, ot as is_container_query, p as Dimension, pt as is_identifier, q as TypeSelector, r as AtrulePrelude, rt as is_class_selector, s as CSSNode, st as is_declaration, t as AnyNode, tt as is_attribute_selector, u as Comment, ut as is_function, v as Identifier, vt as is_media_feature, w as MediaQuery, wt as is_number, x as LangSelector, xt as is_nesting_selector, y as IfBranch, yt as is_media_query, z as Selector, zt as is_supports_query } from "./node-types-
|
|
1
|
+
import { $ as is_atrule, A as Operator, At as is_pseudo_element_selector, B as SelectorList, Bt as is_type_selector, C as MediaFeature, Ct as is_nth_selector, D as NthOfSelector, Dt as is_prelude_operator, E as NestingSelector, Et as is_parenthesis, F as PseudoElementSelector, Ft as is_selector_list, G as SupportsQuery, Gt as CloneOptions, H as String, Ht as is_universal_selector, I as Ratio, It as is_string, J as UnicodeRange, K as ToPlain, Kt as PlainCSSNode, L as Raw, Lt as is_stylesheet, M as PreludeOperator, Mt as is_raw, N as PreludeSelectorList, Nt as is_rule, O as NthSelector, Ot as is_prelude_selectorlist, P as PseudoClassSelector, Pt as is_selector, Q as WithChildren, R as Rule, Rt as is_supports_declaration, S as LayerName, St as is_nth_of_selector, T as MediaType, Tt as is_operator, U as StyleSheet, Ut as is_url, V as SelectorNode, Vt as is_unicode_range, W as SupportsDeclaration, Wt as is_value, X as Url, Y as UniversalSelector, Z as Value, _ as IdSelector, _t as is_layer_name, a as Block, at as is_comment, b as IfCondition, bt as is_media_type, c as ClassSelector, ct as is_dimension, d as ContainerQuery, dt as is_hash, et as is_atrule_prelude, f as Declaration, ft as is_id_selector, g as Hash, gt as is_lang_selector, h as Function, ht as is_if_condition, i as AttributeSelector, it as is_combinator, j as Parenthesis, jt as is_ratio, k as Number, kt as is_pseudo_class_selector, l as Combinator, lt as is_feature_range, m as FeatureRange, mt as is_if_branch, n as Atrule, nt as is_block, o as BlockChild, ot as is_container_query, p as Dimension, pt as is_identifier, q as TypeSelector, r as AtrulePrelude, rt as is_class_selector, s as CSSNode, st as is_declaration, t as AnyNode, tt as is_attribute_selector, u as Comment, ut as is_function, v as Identifier, vt as is_media_feature, w as MediaQuery, wt as is_number, x as LangSelector, xt as is_nesting_selector, y as IfBranch, yt as is_media_query, z as Selector, zt as is_supports_query } from "./node-types-Pa1MR4CP.js";
|
|
2
2
|
export { AnyNode, Atrule, AtrulePrelude, AttributeSelector, Block, BlockChild, CSSNode, ClassSelector, type CloneOptions, Combinator, Comment, ContainerQuery, Declaration, Dimension, FeatureRange, Function, Hash, IdSelector, Identifier, IfBranch, IfCondition, LangSelector, LayerName, MediaFeature, MediaQuery, MediaType, NestingSelector, NthOfSelector, NthSelector, Number, Operator, Parenthesis, type PlainCSSNode, PreludeOperator, PreludeSelectorList, PseudoClassSelector, PseudoElementSelector, Ratio, Raw, Rule, Selector, SelectorList, SelectorNode, String, StyleSheet, SupportsDeclaration, SupportsQuery, ToPlain, TypeSelector, UnicodeRange, UniversalSelector, Url, Value, WithChildren, is_atrule, is_atrule_prelude, is_attribute_selector, is_block, is_class_selector, is_combinator, is_comment, is_container_query, 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 };
|
package/dist/node-types.js
CHANGED
package/dist/parse-anplusb.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { l as CSSDataArena } from "./arena-
|
|
2
|
-
import { O as NthSelector } from "./node-types-
|
|
1
|
+
import { l as CSSDataArena } from "./arena-DnAc8Oy_.js";
|
|
2
|
+
import { O as NthSelector } from "./node-types-Pa1MR4CP.js";
|
|
3
3
|
//#region src/parse-anplusb.d.ts
|
|
4
4
|
/** @internal */
|
|
5
5
|
export declare class ANplusBParser {
|
package/dist/parse-anplusb.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as Lexer } from "./tokenize-B2QSzdrM.js";
|
|
2
2
|
import "./token-types.js";
|
|
3
|
-
import { l as CSSDataArena } from "./arena-
|
|
3
|
+
import { l as CSSDataArena } from "./arena-D123N1LO.js";
|
|
4
4
|
import { l as str_index_of, s as str_equals } from "./string-utils-aEEsA2CS.js";
|
|
5
|
-
import { t as CSSNode } from "./css-node-
|
|
5
|
+
import { t as CSSNode } from "./css-node-D9rqMgMI.js";
|
|
6
6
|
//#region src/parse-anplusb.ts
|
|
7
7
|
/** @internal */
|
|
8
8
|
var ANplusBParser = class {
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
import { l as CSSDataArena } from "./arena-
|
|
2
|
-
import { t as AnyNode } from "./node-types-
|
|
1
|
+
import { l as CSSDataArena } from "./arena-DnAc8Oy_.js";
|
|
2
|
+
import { t as AnyNode } from "./node-types-Pa1MR4CP.js";
|
|
3
3
|
//#region src/parse-atrule-prelude.d.ts
|
|
4
4
|
/** @internal */
|
|
5
|
+
export interface PreludeParserOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Defaults to `false`, but this will become the default behavior in 0.20.0.
|
|
8
|
+
*
|
|
9
|
+
* @deprecated Opt-in only as a migration aid: in 0.20.0 this behavior is always on and the option will be removed.
|
|
10
|
+
*/
|
|
11
|
+
media_feature_range_name_as_child?: boolean;
|
|
12
|
+
}
|
|
5
13
|
export declare class AtRulePreludeParser {
|
|
6
14
|
private lexer;
|
|
7
15
|
private arena;
|
|
@@ -10,7 +18,7 @@ export declare class AtRulePreludeParser {
|
|
|
10
18
|
private value_node_parser;
|
|
11
19
|
private condition_parser;
|
|
12
20
|
private selector_parser;
|
|
13
|
-
constructor(arena: CSSDataArena, source: string);
|
|
21
|
+
constructor(arena: CSSDataArena, source: string, media_feature_range_name_as_child?: boolean);
|
|
14
22
|
parse_prelude(at_rule_name: string, start: number, end: number, line?: number, column?: number): number[];
|
|
15
23
|
private parse_prelude_dispatch;
|
|
16
24
|
private parse_media_query_list;
|
|
@@ -40,7 +48,8 @@ export declare class AtRulePreludeParser {
|
|
|
40
48
|
* Parse an at-rule prelude string and return an array of AST nodes
|
|
41
49
|
* @param at_rule_name - The name of the at-rule (e.g., "media", "supports", "layer")
|
|
42
50
|
* @param prelude - The at-rule prelude to parse (e.g., "(min-width: 768px)", "utilities")
|
|
51
|
+
* @param options - Parser options (`media_feature_range_name_as_child`: also add the feature name of a media range as an Identifier child. This will become the default behavior in 0.20.0.)
|
|
43
52
|
* @returns An array of CSSNode objects representing the parsed prelude
|
|
44
53
|
*/
|
|
45
|
-
export declare function parse_atrule_prelude(at_rule_name: string, prelude: string): AnyNode[];
|
|
54
|
+
export declare function parse_atrule_prelude(at_rule_name: string, prelude: string, options?: PreludeParserOptions): AnyNode[];
|
|
46
55
|
//#endregion
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { t as Lexer } from "./tokenize-B2QSzdrM.js";
|
|
2
2
|
import "./token-types.js";
|
|
3
|
-
import { l as CSSDataArena } from "./arena-
|
|
3
|
+
import { l as CSSDataArena } from "./arena-D123N1LO.js";
|
|
4
4
|
import { c as str_equals_range, d as strip_vendor_prefix, t as is_and_or_not_range } from "./string-utils-aEEsA2CS.js";
|
|
5
|
-
import { t as CSSNode } from "./css-node-
|
|
6
|
-
import { s as trim_boundaries, t as SelectorParser } from "./parse-selector-
|
|
7
|
-
import { n as ConditionParser, t as ValueNodeParser } from "./value-node-parser-
|
|
5
|
+
import { t as CSSNode } from "./css-node-D9rqMgMI.js";
|
|
6
|
+
import { s as trim_boundaries, t as SelectorParser } from "./parse-selector-BMeyZ-oJ.js";
|
|
7
|
+
import { n as ConditionParser, t as ValueNodeParser } from "./value-node-parser-ysQ7ssqf.js";
|
|
8
8
|
//#region src/parse-atrule-prelude.ts
|
|
9
|
-
/** @internal */
|
|
10
9
|
var AtRulePreludeParser = class {
|
|
11
10
|
lexer;
|
|
12
11
|
arena;
|
|
@@ -15,13 +14,13 @@ var AtRulePreludeParser = class {
|
|
|
15
14
|
value_node_parser;
|
|
16
15
|
condition_parser;
|
|
17
16
|
selector_parser;
|
|
18
|
-
constructor(arena, source) {
|
|
17
|
+
constructor(arena, source, media_feature_range_name_as_child = false) {
|
|
19
18
|
this.arena = arena;
|
|
20
19
|
this.source = source;
|
|
21
20
|
this.lexer = new Lexer(source);
|
|
22
21
|
this.prelude_end = 0;
|
|
23
|
-
this.value_node_parser = new ValueNodeParser(arena, source);
|
|
24
|
-
this.condition_parser = new ConditionParser(arena, source, this.value_node_parser);
|
|
22
|
+
this.value_node_parser = new ValueNodeParser(arena, source, media_feature_range_name_as_child);
|
|
23
|
+
this.condition_parser = new ConditionParser(arena, source, this.value_node_parser, media_feature_range_name_as_child);
|
|
25
24
|
this.selector_parser = new SelectorParser(arena, source);
|
|
26
25
|
}
|
|
27
26
|
parse_prelude(at_rule_name, start, end, line = 1, column = 1) {
|
|
@@ -421,11 +420,12 @@ var AtRulePreludeParser = class {
|
|
|
421
420
|
* Parse an at-rule prelude string and return an array of AST nodes
|
|
422
421
|
* @param at_rule_name - The name of the at-rule (e.g., "media", "supports", "layer")
|
|
423
422
|
* @param prelude - The at-rule prelude to parse (e.g., "(min-width: 768px)", "utilities")
|
|
423
|
+
* @param options - Parser options (`media_feature_range_name_as_child`: also add the feature name of a media range as an Identifier child. This will become the default behavior in 0.20.0.)
|
|
424
424
|
* @returns An array of CSSNode objects representing the parsed prelude
|
|
425
425
|
*/
|
|
426
|
-
function parse_atrule_prelude(at_rule_name, prelude) {
|
|
426
|
+
function parse_atrule_prelude(at_rule_name, prelude, options) {
|
|
427
427
|
const arena = new CSSDataArena(CSSDataArena.capacity_for_source(prelude.length));
|
|
428
|
-
return new AtRulePreludeParser(arena, prelude).parse_prelude(at_rule_name, 0, prelude.length).map((index) => new CSSNode(arena, prelude, index));
|
|
428
|
+
return new AtRulePreludeParser(arena, prelude, options?.media_feature_range_name_as_child ?? false).parse_prelude(at_rule_name, 0, prelude.length).map((index) => new CSSNode(arena, prelude, index));
|
|
429
429
|
}
|
|
430
430
|
//#endregion
|
|
431
431
|
export { AtRulePreludeParser, parse_atrule_prelude };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { l as CSSDataArena } from "./arena-
|
|
1
|
+
import { l as CSSDataArena } from "./arena-DnAc8Oy_.js";
|
|
2
2
|
import { Lexer } from "./tokenize.js";
|
|
3
|
-
import { f as Declaration } from "./node-types-
|
|
3
|
+
import { f as Declaration } from "./node-types-Pa1MR4CP.js";
|
|
4
4
|
//#region src/parse-declaration.d.ts
|
|
5
5
|
/** @internal */
|
|
6
6
|
export declare class DeclarationParser {
|
|
@@ -8,7 +8,7 @@ export declare class DeclarationParser {
|
|
|
8
8
|
private source;
|
|
9
9
|
private value_parser;
|
|
10
10
|
private lookahead_position;
|
|
11
|
-
constructor(arena: CSSDataArena, source: string, parse_values?: boolean);
|
|
11
|
+
constructor(arena: CSSDataArena, source: string, parse_values?: boolean, media_feature_range_name_as_child?: boolean);
|
|
12
12
|
parse_declaration(start: number, end: number, line?: number, column?: number): number | null;
|
|
13
13
|
parse_declaration_with_lexer(lexer: Lexer, end: number): number | null;
|
|
14
14
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { t as Lexer } from "./tokenize-B2QSzdrM.js";
|
|
2
2
|
import "./token-types.js";
|
|
3
|
-
import { l as CSSDataArena } from "./arena-
|
|
3
|
+
import { l as CSSDataArena } from "./arena-D123N1LO.js";
|
|
4
4
|
import { a as is_vendor_prefixed } from "./string-utils-aEEsA2CS.js";
|
|
5
|
-
import { t as CSSNode } from "./css-node-
|
|
6
|
-
import { a as skip_whitespace_and_comments_backward, o as skip_whitespace_and_comments_forward } from "./parse-selector-
|
|
5
|
+
import { t as CSSNode } from "./css-node-D9rqMgMI.js";
|
|
6
|
+
import { a as skip_whitespace_and_comments_backward, o as skip_whitespace_and_comments_forward } from "./parse-selector-BMeyZ-oJ.js";
|
|
7
7
|
import { ValueParser } from "./parse-value.js";
|
|
8
8
|
//#region src/parse-declaration.ts
|
|
9
9
|
/** @internal */
|
|
@@ -12,10 +12,10 @@ var DeclarationParser = class {
|
|
|
12
12
|
source;
|
|
13
13
|
value_parser;
|
|
14
14
|
lookahead_position = new Lexer("").save_position();
|
|
15
|
-
constructor(arena, source, parse_values = true) {
|
|
15
|
+
constructor(arena, source, parse_values = true, media_feature_range_name_as_child = false) {
|
|
16
16
|
this.arena = arena;
|
|
17
17
|
this.source = source;
|
|
18
|
-
this.value_parser = parse_values ? new ValueParser(arena, source) : null;
|
|
18
|
+
this.value_parser = parse_values ? new ValueParser(arena, source, media_feature_range_name_as_child) : null;
|
|
19
19
|
}
|
|
20
20
|
parse_declaration(start, end, line = 1, column = 1) {
|
|
21
21
|
const lexer = new Lexer(this.source);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as Lexer } from "./tokenize-B2QSzdrM.js";
|
|
2
2
|
import "./token-types.js";
|
|
3
|
-
import { l as CSSDataArena } from "./arena-
|
|
3
|
+
import { l as CSSDataArena } from "./arena-D123N1LO.js";
|
|
4
4
|
import { c as str_equals_range, n as is_combinator, o as is_whitespace } from "./string-utils-aEEsA2CS.js";
|
|
5
|
-
import { t as CSSNode } from "./css-node-
|
|
5
|
+
import { t as CSSNode } from "./css-node-D9rqMgMI.js";
|
|
6
6
|
import { ANplusBParser } from "./parse-anplusb.js";
|
|
7
7
|
//#region src/parse-utils.ts
|
|
8
8
|
function skip_whitespace_forward(source, pos, end) {
|
package/dist/parse-selector.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { l as CSSDataArena } from "./arena-
|
|
2
|
-
import { B as SelectorList, z as Selector } from "./node-types-
|
|
1
|
+
import { l as CSSDataArena } from "./arena-DnAc8Oy_.js";
|
|
2
|
+
import { B as SelectorList, z as Selector } from "./node-types-Pa1MR4CP.js";
|
|
3
3
|
//#region src/parse-selector.d.ts
|
|
4
4
|
/** @internal */
|
|
5
5
|
export declare class SelectorParser {
|
package/dist/parse-selector.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as SelectorParser, n as parse_selector, r as parse_selector_list } from "./parse-selector-
|
|
1
|
+
export { t as SelectorParser, n as parse_selector, r as parse_selector_list } from "./parse-selector-BMeyZ-oJ.js";
|
package/dist/parse-value.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { l as CSSDataArena } from "./arena-
|
|
2
|
-
import { Z as Value } from "./node-types-
|
|
1
|
+
import { l as CSSDataArena } from "./arena-DnAc8Oy_.js";
|
|
2
|
+
import { Z as Value } from "./node-types-Pa1MR4CP.js";
|
|
3
3
|
//#region src/parse-value.d.ts
|
|
4
4
|
/** @internal */
|
|
5
5
|
export declare class ValueParser {
|
|
6
6
|
private nodes;
|
|
7
7
|
private arena;
|
|
8
|
-
constructor(arena: CSSDataArena, source: string);
|
|
8
|
+
constructor(arena: CSSDataArena, source: string, media_feature_range_name_as_child?: boolean);
|
|
9
9
|
parse_value(start: number, end: number, start_line: number, start_column: number): number;
|
|
10
10
|
}
|
|
11
11
|
/**
|
package/dist/parse-value.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
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-D123N1LO.js";
|
|
2
|
+
import { t as CSSNode } from "./css-node-D9rqMgMI.js";
|
|
3
|
+
import { t as ValueNodeParser } from "./value-node-parser-ysQ7ssqf.js";
|
|
4
4
|
//#region src/parse-value.ts
|
|
5
5
|
/** @internal */
|
|
6
6
|
var ValueParser = class {
|
|
7
7
|
nodes;
|
|
8
8
|
arena;
|
|
9
|
-
constructor(arena, source) {
|
|
9
|
+
constructor(arena, source, media_feature_range_name_as_child = false) {
|
|
10
10
|
this.arena = arena;
|
|
11
|
-
this.nodes = new ValueNodeParser(arena, source);
|
|
11
|
+
this.nodes = new ValueNodeParser(arena, source, media_feature_range_name_as_child);
|
|
12
12
|
}
|
|
13
13
|
parse_value(start, end, start_line, start_column) {
|
|
14
14
|
const first_node = this.nodes.parse_chain(start, end, start_line, start_column);
|
package/dist/parse.d.ts
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
import { l as CSSDataArena } from "./arena-
|
|
1
|
+
import { l as CSSDataArena } from "./arena-DnAc8Oy_.js";
|
|
2
2
|
import { CommentInfo } from "./tokenize.js";
|
|
3
|
-
import { U as StyleSheet } from "./node-types-
|
|
3
|
+
import { U as StyleSheet } from "./node-types-Pa1MR4CP.js";
|
|
4
4
|
//#region src/parse.d.ts
|
|
5
5
|
export interface ParserOptions {
|
|
6
6
|
parse_values?: boolean;
|
|
7
7
|
parse_selectors?: boolean;
|
|
8
8
|
parse_atrule_preludes?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Also add the feature name of a media range, e.g. `width` in `(400px < width)`, as an Identifier child.
|
|
11
|
+
* Defaults to `false`, but this will become the default in 0.20.0.
|
|
12
|
+
*
|
|
13
|
+
* @deprecated Opt-in only as a migration aid: in 0.20.0 this behavior is always on and the option will be removed.
|
|
14
|
+
*/
|
|
15
|
+
media_feature_range_name_as_child?: boolean;
|
|
9
16
|
on_comment?: (info: CommentInfo) => void;
|
|
10
17
|
}
|
|
11
18
|
/** @internal */
|
package/dist/parse.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as Lexer } from "./tokenize-B2QSzdrM.js";
|
|
2
2
|
import "./token-types.js";
|
|
3
|
-
import { l as CSSDataArena } from "./arena-
|
|
4
|
-
import { t as CSSNode } from "./css-node-
|
|
5
|
-
import { a as skip_whitespace_and_comments_backward, o as skip_whitespace_and_comments_forward, t as SelectorParser } from "./parse-selector-
|
|
3
|
+
import { l as CSSDataArena } from "./arena-D123N1LO.js";
|
|
4
|
+
import { t as CSSNode } from "./css-node-D9rqMgMI.js";
|
|
5
|
+
import { a as skip_whitespace_and_comments_backward, o as skip_whitespace_and_comments_forward, t as SelectorParser } from "./parse-selector-BMeyZ-oJ.js";
|
|
6
6
|
import { AtRulePreludeParser } from "./parse-atrule-prelude.js";
|
|
7
7
|
import { DeclarationParser } from "./parse-declaration.js";
|
|
8
8
|
//#region src/parse.ts
|
|
@@ -55,11 +55,11 @@ var Parser = class {
|
|
|
55
55
|
this.parse_selectors_enabled = opts.parse_selectors ?? true;
|
|
56
56
|
this.parse_atrule_preludes_enabled = opts.parse_atrule_preludes ?? true;
|
|
57
57
|
this.lexer = new Lexer(source, opts.on_comment);
|
|
58
|
-
const capacity = CSSDataArena.capacity_for_source(source.length);
|
|
58
|
+
const capacity = CSSDataArena.capacity_for_source(source.length, this.parse_values_enabled, this.parse_selectors_enabled);
|
|
59
59
|
this.arena = new CSSDataArena(capacity);
|
|
60
60
|
this.selector_parser = this.parse_selectors_enabled ? new SelectorParser(this.arena, source) : null;
|
|
61
|
-
this.prelude_parser = this.parse_atrule_preludes_enabled ? new AtRulePreludeParser(this.arena, source) : null;
|
|
62
|
-
this.declaration_parser = new DeclarationParser(this.arena, source, this.parse_values_enabled);
|
|
61
|
+
this.prelude_parser = this.parse_atrule_preludes_enabled ? new AtRulePreludeParser(this.arena, source, opts.media_feature_range_name_as_child ?? false) : null;
|
|
62
|
+
this.declaration_parser = new DeclarationParser(this.arena, source, this.parse_values_enabled, opts.media_feature_range_name_as_child ?? false);
|
|
63
63
|
}
|
|
64
64
|
get_arena() {
|
|
65
65
|
return this.arena;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as Lexer } from "./tokenize-B2QSzdrM.js";
|
|
2
2
|
import "./token-types.js";
|
|
3
|
-
import "./arena-
|
|
3
|
+
import "./arena-D123N1LO.js";
|
|
4
4
|
import { c as str_equals_range, t as is_and_or_not_range } from "./string-utils-aEEsA2CS.js";
|
|
5
|
-
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-
|
|
5
|
+
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-BMeyZ-oJ.js";
|
|
6
6
|
//#region src/parse-condition.ts
|
|
7
7
|
var ConditionParser = class {
|
|
8
8
|
lexer;
|
|
@@ -11,7 +11,9 @@ var ConditionParser = class {
|
|
|
11
11
|
end = 0;
|
|
12
12
|
value_node_parser;
|
|
13
13
|
selector_parser;
|
|
14
|
-
|
|
14
|
+
media_feature_range_name_as_child;
|
|
15
|
+
constructor(arena, source, value_node_parser, media_feature_range_name_as_child = false) {
|
|
16
|
+
this.media_feature_range_name_as_child = media_feature_range_name_as_child;
|
|
15
17
|
this.arena = arena;
|
|
16
18
|
this.source = source;
|
|
17
19
|
this.lexer = new Lexer(source);
|
|
@@ -142,6 +144,14 @@ var ConditionParser = class {
|
|
|
142
144
|
if (this.lexer.token_type === 1) {
|
|
143
145
|
feature_name_start = this.lexer.token_start;
|
|
144
146
|
feature_name_end = this.lexer.token_end;
|
|
147
|
+
if (this.media_feature_range_name_as_child) {
|
|
148
|
+
const name_first = this.parse_feature_value(feature_name_start, feature_name_end);
|
|
149
|
+
if (name_first !== 0) {
|
|
150
|
+
if (first_child === 0) first_child = name_first;
|
|
151
|
+
else this.arena.set_next_sibling(last_child, name_first);
|
|
152
|
+
last_child = this.arena.get_last_sibling(name_first);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
145
155
|
} else {
|
|
146
156
|
const value_start = this.lexer.token_start;
|
|
147
157
|
let value_end = this.lexer.token_end;
|
|
@@ -314,10 +324,12 @@ var ValueNodeParser = class ValueNodeParser {
|
|
|
314
324
|
last_chain_node = 0;
|
|
315
325
|
_condition_parser = null;
|
|
316
326
|
get condition_parser() {
|
|
317
|
-
if (this._condition_parser === null) this._condition_parser = new ConditionParser(this.arena, this.source, new ValueNodeParser(this.arena, this.source));
|
|
327
|
+
if (this._condition_parser === null) this._condition_parser = new ConditionParser(this.arena, this.source, new ValueNodeParser(this.arena, this.source), this.media_feature_range_name_as_child);
|
|
318
328
|
return this._condition_parser;
|
|
319
329
|
}
|
|
320
|
-
|
|
330
|
+
media_feature_range_name_as_child;
|
|
331
|
+
constructor(arena, source, media_feature_range_name_as_child = false) {
|
|
332
|
+
this.media_feature_range_name_as_child = media_feature_range_name_as_child;
|
|
321
333
|
this.arena = arena;
|
|
322
334
|
this.source = source;
|
|
323
335
|
this.lexer = new Lexer(source);
|
package/dist/walk.d.ts
CHANGED
package/dist/walk.js
CHANGED