@projectwallace/css-parser 0.18.12 → 0.19.1

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.
Files changed (36) hide show
  1. package/README.md +28 -107
  2. package/dist/{arena-DvT75bvK.d.ts → arena-7RLvyGPB.d.ts} +0 -1
  3. package/dist/{arena-Bsf96CQK.js → arena-CsJhQRUX.js} +0 -1
  4. package/dist/constants.d.ts +1 -1
  5. package/dist/constants.js +1 -1
  6. package/dist/{css-node-yoUdFtNg.js → css-node-BJnbanUS.js} +5 -54
  7. package/dist/index.d.ts +3 -3
  8. package/dist/index.js +4 -4
  9. package/dist/{node-types-CY0JK9_a.d.ts → node-types-BZGPDESt.d.ts} +13 -30
  10. package/dist/node-types.d.ts +1 -1
  11. package/dist/node-types.js +1 -1
  12. package/dist/parse-anplusb.d.ts +2 -10
  13. package/dist/parse-anplusb.js +9 -17
  14. package/dist/parse-atrule-prelude.d.ts +3 -2
  15. package/dist/parse-atrule-prelude.js +68 -33
  16. package/dist/parse-declaration.d.ts +2 -2
  17. package/dist/parse-declaration.js +14 -14
  18. package/dist/parse-dimension.js +1 -1
  19. package/dist/{parse-selector-CqIpnBrQ.js → parse-selector-B59fV-Ya.js} +14 -14
  20. package/dist/parse-selector.d.ts +2 -2
  21. package/dist/parse-selector.js +1 -1
  22. package/dist/parse-value.d.ts +2 -2
  23. package/dist/parse-value.js +3 -3
  24. package/dist/parse.d.ts +2 -2
  25. package/dist/parse.js +5 -5
  26. package/dist/{string-helpers-BMWJduts.d.ts → string-helpers-t7UofIfp.d.ts} +5 -7
  27. package/dist/string-helpers.d.ts +1 -1
  28. package/dist/string-helpers.js +1 -1
  29. package/dist/{string-utils-DiRRd28d.js → string-utils-aEEsA2CS.js} +18 -14
  30. package/dist/{tokenize-Ccg58Z_k.js → tokenize-B2QSzdrM.js} +10 -45
  31. package/dist/tokenize.d.ts +1 -33
  32. package/dist/tokenize.js +1 -1
  33. package/dist/{value-node-parser-BBwBxFR_.js → value-node-parser-BBlVw-en.js} +54 -21
  34. package/dist/walk.d.ts +1 -1
  35. package/dist/walk.js +2 -2
  36. package/package.json +1 -1
@@ -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-DvT75bvK.js";
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-7RLvyGPB.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;
@@ -170,7 +170,7 @@ type Dimension = Leaf<typeof DIMENSION, 'Dimension', {
170
170
  }>;
171
171
  type String = Leaf<typeof STRING, 'String'>;
172
172
  type Hash = Leaf<typeof HASH, 'Hash'>;
173
- type Function = WithClone<CSSNode & WithChildren<ValueLike | MediaFeature | SupportsDeclaration | SupportsQuery | FeatureRange | PreludeOperator> & {
173
+ type Function = WithClone<CSSNode & WithChildren<ValueLike | MediaFeature | SupportsDeclaration | SupportsQuery | LayerName | FeatureRange | PreludeOperator> & {
174
174
  readonly type: typeof FUNCTION;
175
175
  readonly type_name: 'Function';
176
176
  /** Function name, e.g. "rgb", "calc" */
@@ -195,40 +195,19 @@ type Value = WithClone<CSSNode & WithChildren<ValueLike> & {
195
195
  readonly type: typeof VALUE;
196
196
  readonly type_name: 'Value';
197
197
  }>;
198
- /**
199
- * A compound `if()`-branch condition combining multiple tests with `not`/`and`/`or`,
200
- * e.g. `not style(--scheme: light)` or `style(--a: 1) and media(width > 600px)`.
201
- *
202
- * Children are the flat sequence of PreludeOperator ("not"/"and"/"or") and
203
- * Function (`style()`/`media()`/`supports()`) nodes, in source order — the same
204
- * shape `@supports`'s own compound condition uses.
205
- */
198
+ /** Compound `if()` condition: a flat sequence of `not`/`and`/`or` operators and `style()`/`media()`/`supports()` functions, e.g. `not style(--a: 1)`. */
206
199
  type IfCondition = WithClone<CSSNode & WithChildren<Function | PreludeOperator> & {
207
200
  readonly type: typeof IF_CONDITION;
208
201
  readonly type_name: 'IfCondition';
209
202
  }>;
210
- /**
211
- * One branch inside a CSS `if()` inline conditional function.
212
- *
213
- * Each branch corresponds to a `<condition>: <value>` pair in:
214
- * `if( <condition>: <value>; … else: <fallback> )`
215
- *
216
- * - `condition` — the parsed condition node: a Function (e.g. `style(--x: 1)`), an
217
- * Identifier (`else`), or an IfCondition for compound `not`/`and`/`or` conditions
218
- * (e.g. `not style(--x: 1)`)
219
- * - `value` — the value text, e.g. `"green"`; `null` when omitted
220
- * - `is_else` — `true` for the `else` branch
221
- * - `first_child` — same node as `condition`
222
- * - `children` — condition node followed by parsed value nodes
223
- */
203
+ /** A `<condition>: <value>` branch of an `if()` function. `children` is the condition followed by the parsed value nodes. */
224
204
  type IfBranch = CSSNode & WithChildren<Function | Identifier | IfCondition | Value> & {
225
205
  readonly type: typeof IF_BRANCH;
226
206
  readonly type_name: 'IfBranch';
227
- /** The parsed condition node, e.g. the Function "style(--active: 1)", the Identifier "else", or an IfCondition for compound conditions */
207
+ /** Function (`style(--x: 1)`), Identifier (`else`) or IfCondition */
228
208
  readonly condition: Function | Identifier | IfCondition;
229
- /** The parsed value as a VALUE node, or null when the branch value is empty */
209
+ /** Branch value, or null when empty */
230
210
  readonly value: Value | null;
231
- /** True when this is the else branch */
232
211
  readonly is_else: boolean;
233
212
  clone(options?: CloneOptions): ToPlain<IfBranch>;
234
213
  };
@@ -319,7 +298,7 @@ type ContainerQuery = WithClone<CSSNode & WithChildren<Identifier | MediaFeature
319
298
  readonly type: typeof CONTAINER_QUERY;
320
299
  readonly type_name: 'ContainerQuery';
321
300
  }>;
322
- type SupportsQuery = WithClone<CSSNode & WithChildren<SupportsDeclaration> & {
301
+ type SupportsQuery = WithClone<CSSNode & WithChildren<SupportsDeclaration | SupportsQuery | PreludeOperator | Function> & {
323
302
  readonly type: typeof SUPPORTS_QUERY;
324
303
  readonly type_name: 'SupportsQuery';
325
304
  /** The supports condition text, e.g. "display: flex" from "supports(display: flex)" */
@@ -342,9 +321,13 @@ type LayerName = Leaf<typeof LAYER_NAME, 'Layer', {
342
321
  * A parenthesised selector argument in an at-rule prelude, e.g. `(.parent)`
343
322
  * in `@scope (.parent) to (.child)`. Distinct from SELECTOR_LIST, which
344
323
  * already means "matches elements", so tooling can tell scoping arguments
345
- * apart from real selectors. `value` is the trimmed text inside the parens.
324
+ * apart from real selectors. `value` is the trimmed text inside the parens;
325
+ * the parsed selectors are available as a single `SelectorList` child
326
+ * (absent when the parens are empty).
346
327
  */
347
- type PreludeSelectorList = Leaf<typeof PRELUDE_SELECTORLIST, 'PreludeSelectorList', {
328
+ type PreludeSelectorList = WithClone<CSSNode & WithChildren<SelectorList> & {
329
+ readonly type: typeof PRELUDE_SELECTORLIST;
330
+ readonly type_name: 'PreludeSelectorList';
348
331
  readonly value: string;
349
332
  }>;
350
333
  type PreludeOperator = Leaf<typeof PRELUDE_OPERATOR, 'Operator'>;
@@ -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-CY0JK9_a.js";
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-BZGPDESt.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 };
@@ -1,4 +1,4 @@
1
- import "./arena-Bsf96CQK.js";
1
+ import "./arena-CsJhQRUX.js";
2
2
  //#region src/node-types.ts
3
3
  function is_stylesheet(node) {
4
4
  return node.type === 1;
@@ -1,5 +1,5 @@
1
- import { l as CSSDataArena } from "./arena-DvT75bvK.js";
2
- import { O as NthSelector } from "./node-types-CY0JK9_a.js";
1
+ import { l as CSSDataArena } from "./arena-7RLvyGPB.js";
2
+ import { O as NthSelector } from "./node-types-BZGPDESt.js";
3
3
  //#region src/parse-anplusb.d.ts
4
4
  /** @internal */
5
5
  export declare class ANplusBParser {
@@ -8,15 +8,7 @@ export declare class ANplusBParser {
8
8
  private source;
9
9
  private expr_end;
10
10
  constructor(arena: CSSDataArena, source: string);
11
- /**
12
- * Parse An+B expression
13
- * Examples: odd, even, 3, n, -n, 2n, 2n+1, -3n-5
14
- */
15
11
  parse_anplusb(start: number, end: number, line?: number): number | null;
16
- /**
17
- * Parse the b part after 'n'
18
- * Handles: +5, -3, whitespace variations
19
- */
20
12
  private parse_b_part;
21
13
  private skip_whitespace;
22
14
  private create_anplusb_node;
@@ -1,8 +1,8 @@
1
- import { t as Lexer } from "./tokenize-Ccg58Z_k.js";
1
+ import { t as Lexer } from "./tokenize-B2QSzdrM.js";
2
2
  import "./token-types.js";
3
- import { l as CSSDataArena } from "./arena-Bsf96CQK.js";
4
- import { l as str_index_of, s as str_equals } from "./string-utils-DiRRd28d.js";
5
- import { t as CSSNode } from "./css-node-yoUdFtNg.js";
3
+ import { l as CSSDataArena } from "./arena-CsJhQRUX.js";
4
+ import { l as str_index_of, s as str_equals } from "./string-utils-aEEsA2CS.js";
5
+ import { t as CSSNode } from "./css-node-BJnbanUS.js";
6
6
  //#region src/parse-anplusb.ts
7
7
  /** @internal */
8
8
  var ANplusBParser = class {
@@ -16,10 +16,6 @@ var ANplusBParser = class {
16
16
  this.lexer = new Lexer(source);
17
17
  this.expr_end = 0;
18
18
  }
19
- /**
20
- * Parse An+B expression
21
- * Examples: odd, even, 3, n, -n, 2n, 2n+1, -3n-5
22
- */
23
19
  parse_anplusb(start, end, line = 1) {
24
20
  this.expr_end = end;
25
21
  this.lexer.seek(start, line);
@@ -31,7 +27,7 @@ var ANplusBParser = class {
31
27
  const node_start = start;
32
28
  this.skip_whitespace();
33
29
  if (this.lexer.pos >= this.expr_end) return null;
34
- this.lexer.next_token_fast(true);
30
+ this.lexer.next_token(true);
35
31
  if (this.lexer.token_type === 1) {
36
32
  const text = this.source.substring(this.lexer.token_start, this.lexer.token_end);
37
33
  if (str_equals("odd", text) || str_equals("even", text)) {
@@ -85,7 +81,7 @@ var ANplusBParser = class {
85
81
  }
86
82
  if (this.lexer.token_type === 9 && this.source.charCodeAt(this.lexer.token_start) === 43) {
87
83
  const saved = this.lexer.save_position();
88
- this.lexer.next_token_fast(true);
84
+ this.lexer.next_token(true);
89
85
  if (this.lexer.token_type === 1) {
90
86
  if (this.source.substring(this.lexer.token_start, this.lexer.token_end).charCodeAt(0) === 110) {
91
87
  a_start = saved.pos - 1;
@@ -110,7 +106,7 @@ var ANplusBParser = class {
110
106
  }
111
107
  if (this.lexer.token_type === 12) {
112
108
  const token_text = this.source.substring(this.lexer.token_start, this.lexer.token_end);
113
- const n_index = str_index_of(token_text, "n");
109
+ const n_index = str_index_of("n", token_text);
114
110
  if (n_index !== -1) {
115
111
  a_start = this.lexer.token_start;
116
112
  a_end = this.lexer.token_start + n_index + 1;
@@ -139,20 +135,16 @@ var ANplusBParser = class {
139
135
  }
140
136
  return null;
141
137
  }
142
- /**
143
- * Parse the b part after 'n'
144
- * Handles: +5, -3, whitespace variations
145
- */
146
138
  parse_b_part() {
147
139
  this.skip_whitespace();
148
140
  if (this.lexer.pos >= this.expr_end) return null;
149
- this.lexer.next_token_fast(true);
141
+ this.lexer.next_token(true);
150
142
  if (this.lexer.token_type === 9) {
151
143
  const ch = this.source.charCodeAt(this.lexer.token_start);
152
144
  if (ch === 43 || ch === 45) {
153
145
  const sign = ch === 45 ? "-" : "";
154
146
  this.skip_whitespace();
155
- this.lexer.next_token_fast(true);
147
+ this.lexer.next_token(true);
156
148
  if (this.lexer.token_type === 10) {
157
149
  let num_text = this.source.substring(this.lexer.token_start, this.lexer.token_end);
158
150
  if (num_text.charCodeAt(0) === 43) num_text = num_text.substring(1);
@@ -1,5 +1,5 @@
1
- import { l as CSSDataArena } from "./arena-DvT75bvK.js";
2
- import { t as AnyNode } from "./node-types-CY0JK9_a.js";
1
+ import { l as CSSDataArena } from "./arena-7RLvyGPB.js";
2
+ import { t as AnyNode } from "./node-types-BZGPDESt.js";
3
3
  //#region src/parse-atrule-prelude.d.ts
4
4
  /** @internal */
5
5
  export declare class AtRulePreludeParser {
@@ -9,6 +9,7 @@ export declare class AtRulePreludeParser {
9
9
  private prelude_end;
10
10
  private value_node_parser;
11
11
  private condition_parser;
12
+ private selector_parser;
12
13
  constructor(arena: CSSDataArena, source: string);
13
14
  parse_prelude(at_rule_name: string, start: number, end: number, line?: number, column?: number): number[];
14
15
  private parse_prelude_dispatch;
@@ -1,10 +1,10 @@
1
- import { t as Lexer } from "./tokenize-Ccg58Z_k.js";
1
+ import { t as Lexer } from "./tokenize-B2QSzdrM.js";
2
2
  import "./token-types.js";
3
- import { l as CSSDataArena } from "./arena-Bsf96CQK.js";
4
- import { c as str_equals_range, d as strip_vendor_prefix, t as is_and_or_not_range } from "./string-utils-DiRRd28d.js";
5
- import { t as CSSNode } from "./css-node-yoUdFtNg.js";
6
- import { s as trim_boundaries } from "./parse-selector-CqIpnBrQ.js";
7
- import { n as ConditionParser, t as ValueNodeParser } from "./value-node-parser-BBwBxFR_.js";
3
+ import { l as CSSDataArena } from "./arena-CsJhQRUX.js";
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-BJnbanUS.js";
6
+ import { s as trim_boundaries, t as SelectorParser } from "./parse-selector-B59fV-Ya.js";
7
+ import { n as ConditionParser, t as ValueNodeParser } from "./value-node-parser-BBlVw-en.js";
8
8
  //#region src/parse-atrule-prelude.ts
9
9
  /** @internal */
10
10
  var AtRulePreludeParser = class {
@@ -14,6 +14,7 @@ var AtRulePreludeParser = class {
14
14
  prelude_end;
15
15
  value_node_parser;
16
16
  condition_parser;
17
+ selector_parser;
17
18
  constructor(arena, source) {
18
19
  this.arena = arena;
19
20
  this.source = source;
@@ -21,6 +22,7 @@ var AtRulePreludeParser = class {
21
22
  this.prelude_end = 0;
22
23
  this.value_node_parser = new ValueNodeParser(arena, source);
23
24
  this.condition_parser = new ConditionParser(arena, source, this.value_node_parser);
25
+ this.selector_parser = new SelectorParser(arena, source);
24
26
  }
25
27
  parse_prelude(at_rule_name, start, end, line = 1, column = 1) {
26
28
  this.prelude_end = end;
@@ -263,28 +265,34 @@ var AtRulePreludeParser = class {
263
265
  const name_end = this.lexer.token_type === 2 ? this.lexer.token_end - 1 : this.lexer.token_end;
264
266
  if (str_equals_range(this.source, this.lexer.token_start, name_end, "layer")) {
265
267
  const layer_start = this.lexer.token_start;
266
- let layer_end = this.lexer.token_end;
267
- let content_start = 0;
268
- let content_length = 0;
269
- if (this.lexer.token_type === 2) {
270
- content_start = this.lexer.pos;
271
- const matched = this.scan_matching_paren();
272
- const content_end = this.paren_content_end;
273
- const close_end = this.paren_close_end;
274
- if (matched) {
275
- content_length = content_end - content_start;
276
- layer_end = close_end;
277
- }
268
+ if (this.lexer.token_type === 1) {
269
+ const layer_node = this.create_node(37, layer_start, this.lexer.token_end);
270
+ this.arena.set_content_start_delta(layer_node, 0);
271
+ this.arena.set_content_length(layer_node, 0);
272
+ return layer_node;
278
273
  }
279
- const layer_node = this.create_node(37, layer_start, layer_end);
280
- if (content_length > 0) {
281
- const trimmed = trim_boundaries(this.source, content_start, content_start + content_length);
282
- if (trimmed) {
283
- this.arena.set_content_start_delta(layer_node, trimmed[0] - layer_start);
284
- this.arena.set_content_length(layer_node, trimmed[1] - trimmed[0]);
285
- }
274
+ const content_start = this.lexer.token_end;
275
+ const after_open = this.lexer.save_position();
276
+ const matched = this.scan_matching_paren();
277
+ const content_end = this.paren_content_end;
278
+ const layer_end = matched ? this.paren_close_end : this.lexer.pos;
279
+ const func_node = this.create_node(15, layer_start, layer_end);
280
+ this.arena.set_content_start_delta(func_node, 0);
281
+ this.arena.set_content_length(func_node, name_end - layer_start);
282
+ const trimmed = matched ? trim_boundaries(this.source, content_start, content_end) : null;
283
+ if (trimmed) {
284
+ this.arena.set_value_start_delta(func_node, trimmed[0] - layer_start);
285
+ this.arena.set_value_length(func_node, trimmed[1] - trimmed[0]);
286
+ const after_close = this.lexer.save_position();
287
+ const saved_prelude_end = this.prelude_end;
288
+ this.lexer.restore_position(after_open);
289
+ this.prelude_end = content_end;
290
+ const names = this.parse_layer_names();
291
+ this.prelude_end = saved_prelude_end;
292
+ this.lexer.restore_position(after_close);
293
+ this.arena.append_children(func_node, names);
286
294
  }
287
- return layer_node;
295
+ return func_node;
288
296
  }
289
297
  }
290
298
  this.lexer.restore_position(saved);
@@ -296,19 +304,36 @@ var AtRulePreludeParser = class {
296
304
  if (this.lexer.token_type === 2) {
297
305
  if (str_equals_range(this.source, this.lexer.token_start, this.lexer.token_end - 1, "supports")) {
298
306
  const supports_start = this.lexer.token_start;
307
+ const name_end = this.lexer.token_end - 1;
299
308
  const content_start = this.lexer.token_end;
309
+ const line = this.lexer.line;
310
+ const column = this.lexer.column;
300
311
  this.scan_matching_paren();
301
312
  const content_end = this.paren_content_end;
302
313
  const supports_end = this.paren_close_end;
303
- const supports_node = this.create_node(36, supports_start, supports_end);
314
+ const func_node = this.create_node(15, supports_start, supports_end);
315
+ this.arena.set_content_start_delta(func_node, 0);
316
+ this.arena.set_content_length(func_node, name_end - supports_start);
304
317
  const trimmed = trim_boundaries(this.source, content_start, content_end);
305
318
  if (trimmed) {
306
- this.arena.set_value_start_delta(supports_node, trimmed[0] - supports_start);
307
- this.arena.set_value_length(supports_node, trimmed[1] - trimmed[0]);
308
- const decl_child = this.condition_parser.parse_supports_declaration_content(trimmed[0], trimmed[1]);
309
- if (decl_child !== null) this.arena.set_first_child(supports_node, decl_child);
319
+ const condition_start = trimmed[0];
320
+ const condition_end = trimmed[1];
321
+ const condition_length = condition_end - condition_start;
322
+ this.arena.set_value_start_delta(func_node, condition_start - supports_start);
323
+ this.arena.set_value_length(func_node, condition_length);
324
+ const decl_child = this.condition_parser.parse_supports_declaration_content(condition_start, condition_end);
325
+ if (decl_child === null) {
326
+ const children = this.condition_parser.parse_supports_condition(condition_start, condition_end, line, column);
327
+ this.arena.append_children(func_node, children);
328
+ } else {
329
+ const query = this.create_node(36, condition_start, condition_end);
330
+ this.arena.set_value_start_delta(query, 0);
331
+ this.arena.set_value_length(query, condition_length);
332
+ this.arena.set_first_child(query, decl_child);
333
+ this.arena.set_first_child(func_node, query);
334
+ }
310
335
  }
311
- return supports_node;
336
+ return func_node;
312
337
  }
313
338
  }
314
339
  this.lexer.restore_position(saved);
@@ -329,7 +354,7 @@ var AtRulePreludeParser = class {
329
354
  this.lexer.token_type = 26;
330
355
  return 26;
331
356
  }
332
- return this.lexer.next_token_fast(false);
357
+ return this.lexer.next_token(false);
333
358
  }
334
359
  parse_namespace_prelude() {
335
360
  const nodes = [];
@@ -355,6 +380,8 @@ var AtRulePreludeParser = class {
355
380
  this.next_token();
356
381
  const paren_start = this.lexer.token_start;
357
382
  const content_start = this.lexer.pos;
383
+ const content_line = this.lexer.token_line;
384
+ const content_column = this.lexer.token_column;
358
385
  this.scan_matching_paren();
359
386
  const content_end = this.paren_content_end;
360
387
  const paren_end = this.paren_close_end;
@@ -363,6 +390,14 @@ var AtRulePreludeParser = class {
363
390
  if (trimmed) {
364
391
  this.arena.set_value_start_delta(scope_node, trimmed[0] - paren_start);
365
392
  this.arena.set_value_length(scope_node, trimmed[1] - trimmed[0]);
393
+ let line = content_line;
394
+ let column = content_column;
395
+ for (let i = content_start; i < trimmed[0]; i++) if (this.source.charCodeAt(i) === 10) {
396
+ line++;
397
+ column = 1;
398
+ } else column++;
399
+ const selector_list = this.selector_parser.parse_selector(trimmed[0], trimmed[1], line, column, false);
400
+ if (selector_list !== null) this.arena.set_first_child(scope_node, selector_list);
366
401
  }
367
402
  nodes.push(scope_node);
368
403
  } else if (token_type === 1) {
@@ -1,6 +1,6 @@
1
- import { l as CSSDataArena } from "./arena-DvT75bvK.js";
1
+ import { l as CSSDataArena } from "./arena-7RLvyGPB.js";
2
2
  import { Lexer } from "./tokenize.js";
3
- import { f as Declaration } from "./node-types-CY0JK9_a.js";
3
+ import { f as Declaration } from "./node-types-BZGPDESt.js";
4
4
  //#region src/parse-declaration.d.ts
5
5
  /** @internal */
6
6
  export declare class DeclarationParser {
@@ -1,9 +1,9 @@
1
- import { t as Lexer } from "./tokenize-Ccg58Z_k.js";
1
+ import { t as Lexer } from "./tokenize-B2QSzdrM.js";
2
2
  import "./token-types.js";
3
- import { l as CSSDataArena } from "./arena-Bsf96CQK.js";
4
- import { a as is_vendor_prefixed } from "./string-utils-DiRRd28d.js";
5
- import { t as CSSNode } from "./css-node-yoUdFtNg.js";
6
- import { a as skip_whitespace_and_comments_backward, o as skip_whitespace_and_comments_forward } from "./parse-selector-CqIpnBrQ.js";
3
+ import { l as CSSDataArena } from "./arena-CsJhQRUX.js";
4
+ import { a as is_vendor_prefixed } from "./string-utils-aEEsA2CS.js";
5
+ import { t as CSSNode } from "./css-node-BJnbanUS.js";
6
+ import { a as skip_whitespace_and_comments_backward, o as skip_whitespace_and_comments_forward } from "./parse-selector-B59fV-Ya.js";
7
7
  import { ValueParser } from "./parse-value.js";
8
8
  //#region src/parse-declaration.ts
9
9
  /** @internal */
@@ -20,7 +20,7 @@ var DeclarationParser = class {
20
20
  parse_declaration(start, end, line = 1, column = 1) {
21
21
  const lexer = new Lexer(this.source);
22
22
  lexer.seek(start, line, column);
23
- lexer.next_token_fast(true);
23
+ lexer.next_token(true);
24
24
  return this.parse_declaration_with_lexer(lexer, end);
25
25
  }
26
26
  parse_declaration_with_lexer(lexer, end) {
@@ -54,7 +54,7 @@ var DeclarationParser = class {
54
54
  browser_hack_start = lexer.token_start;
55
55
  browser_hack_line = lexer.token_line;
56
56
  browser_hack_column = lexer.token_column;
57
- lexer.next_token_fast(true);
57
+ lexer.next_token(true);
58
58
  if (lexer.token_type === 1) {
59
59
  has_browser_hack = true;
60
60
  initial_saved = delim_saved;
@@ -66,7 +66,7 @@ var DeclarationParser = class {
66
66
  const decl_line = has_browser_hack ? browser_hack_line : lexer.token_line;
67
67
  const decl_column = has_browser_hack ? browser_hack_column : lexer.token_column;
68
68
  const saved = lexer.save_position_into(this.lookahead_position);
69
- lexer.next_token_fast(true);
69
+ lexer.next_token(true);
70
70
  if (lexer.token_type !== 16) {
71
71
  lexer.restore_position(initial_saved ?? saved);
72
72
  return null;
@@ -97,7 +97,7 @@ var DeclarationParser = class {
97
97
  }
98
98
  if (stop_ch === 59 && paren_depth === 0) {
99
99
  value_end = skip_whitespace_and_comments_backward(this.source, lexer.pos, value_start);
100
- lexer.next_token_fast(false);
100
+ lexer.next_token(false);
101
101
  break;
102
102
  }
103
103
  if (stop_ch === 125 && paren_depth === 0) {
@@ -108,7 +108,7 @@ var DeclarationParser = class {
108
108
  last_end = skip_whitespace_and_comments_backward(this.source, lexer.pos, value_start);
109
109
  value_end = last_end;
110
110
  }
111
- lexer.next_token_fast(false);
111
+ lexer.next_token(false);
112
112
  break;
113
113
  }
114
114
  if (stop_ch === 123) {
@@ -118,10 +118,10 @@ var DeclarationParser = class {
118
118
  if (stop_ch === 33) {
119
119
  value_end = lexer.pos;
120
120
  lexer.pos++;
121
- if (lexer.next_token_fast(true) === 1) {
121
+ if (lexer.next_token(true) === 1) {
122
122
  has_important = true;
123
123
  last_end = lexer.token_end;
124
- lexer.next_token_fast(true);
124
+ lexer.next_token(true);
125
125
  break;
126
126
  }
127
127
  last_end = lexer.token_end;
@@ -131,7 +131,7 @@ var DeclarationParser = class {
131
131
  if (stop_ch === 0) {
132
132
  last_end = skip_whitespace_and_comments_backward(this.source, lexer.pos, value_start);
133
133
  value_end = last_end;
134
- lexer.next_token_fast(false);
134
+ lexer.next_token(false);
135
135
  break;
136
136
  }
137
137
  lexer.pos++;
@@ -160,7 +160,7 @@ var DeclarationParser = class {
160
160
  if (has_browser_hack) this.arena.set_flag(declaration, 128);
161
161
  if (lexer.token_type === 17) {
162
162
  last_end = lexer.token_end;
163
- lexer.next_token_fast(true);
163
+ lexer.next_token(true);
164
164
  }
165
165
  this.arena.set_length(declaration, last_end - prop_start);
166
166
  return declaration;
@@ -1,4 +1,4 @@
1
- import { i as is_digit } from "./string-utils-DiRRd28d.js";
1
+ import { i as is_digit } from "./string-utils-aEEsA2CS.js";
2
2
  //#region src/parse-dimension.ts
3
3
  /**
4
4
  * Find where a dimension's numeric part ends, e.g. 3 for "100px" or 2 for "2%".
@@ -1,8 +1,8 @@
1
- import { t as Lexer } from "./tokenize-Ccg58Z_k.js";
1
+ import { t as Lexer } from "./tokenize-B2QSzdrM.js";
2
2
  import "./token-types.js";
3
- import { l as CSSDataArena } from "./arena-Bsf96CQK.js";
4
- import { c as str_equals_range, n as is_combinator, o as is_whitespace } from "./string-utils-DiRRd28d.js";
5
- import { t as CSSNode } from "./css-node-yoUdFtNg.js";
3
+ import { l as CSSDataArena } from "./arena-CsJhQRUX.js";
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-BJnbanUS.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) {
@@ -112,7 +112,7 @@ var SelectorParser = class {
112
112
  }
113
113
  this.skip_whitespace();
114
114
  if (this.lexer.pos >= this.selector_end) break;
115
- this.lexer.next_token_fast(false);
115
+ this.lexer.next_token(false);
116
116
  if (this.lexer.token_type === 18) {
117
117
  this.skip_whitespace();
118
118
  continue;
@@ -131,7 +131,7 @@ var SelectorParser = class {
131
131
  this.skip_whitespace();
132
132
  if (allow_relative && this.lexer.pos < this.selector_end) {
133
133
  const saved = this.lexer.save_position();
134
- this.lexer.next_token_fast(false);
134
+ this.lexer.next_token(false);
135
135
  if (this.lexer.token_type === 9) {
136
136
  const ch = this.source.charCodeAt(this.lexer.token_start);
137
137
  if (ch === 62 || ch === 43 || ch === 126) {
@@ -164,7 +164,7 @@ var SelectorParser = class {
164
164
  let last_part = 0;
165
165
  while (this.lexer.pos < this.selector_end) {
166
166
  const saved = this.lexer.save_position();
167
- this.lexer.next_token_fast(false);
167
+ this.lexer.next_token(false);
168
168
  if (this.lexer.token_start >= this.selector_end) break;
169
169
  if (this.lexer.token_type === 26) break;
170
170
  const part = this.parse_simple_selector();
@@ -204,7 +204,7 @@ var SelectorParser = class {
204
204
  }
205
205
  parse_namespace_local_part(selector_start, namespace_start, namespace_prefix_length) {
206
206
  const saved = this.lexer.save_position();
207
- this.lexer.next_token_fast(false);
207
+ this.lexer.next_token(false);
208
208
  let node_type;
209
209
  if (this.lexer.token_type === 1) node_type = 21;
210
210
  else if (this.lexer.token_type === 9 && this.source.charCodeAt(this.lexer.token_start) === 42) node_type = 28;
@@ -257,7 +257,7 @@ var SelectorParser = class {
257
257
  this.lexer.restore_position(saved_whitespace_start);
258
258
  return null;
259
259
  }
260
- this.lexer.next_token_fast(false);
260
+ this.lexer.next_token(false);
261
261
  if (this.lexer.token_type === 18) {
262
262
  this.lexer.restore_position(saved_whitespace_start);
263
263
  return null;
@@ -276,7 +276,7 @@ var SelectorParser = class {
276
276
  }
277
277
  parse_class_selector(dot_pos) {
278
278
  const saved = this.lexer.save_position();
279
- this.lexer.next_token_fast(false);
279
+ this.lexer.next_token(false);
280
280
  if (this.lexer.token_type !== 1) {
281
281
  this.lexer.restore_position(saved);
282
282
  return null;
@@ -289,7 +289,7 @@ var SelectorParser = class {
289
289
  const content_start = start + 1;
290
290
  let content_end = content_start;
291
291
  while (this.lexer.pos < this.selector_end && bracket_depth > 0) {
292
- this.lexer.next_token_fast(false);
292
+ this.lexer.next_token(false);
293
293
  const token_type = this.lexer.token_type;
294
294
  if (token_type === 19) bracket_depth++;
295
295
  else if (token_type === 20) {
@@ -371,7 +371,7 @@ var SelectorParser = class {
371
371
  is_pseudo_element = true;
372
372
  this.lexer.pos++;
373
373
  } else this.lexer.restore_position(saved_ws);
374
- this.lexer.next_token_fast(false);
374
+ this.lexer.next_token(false);
375
375
  const token_type = this.lexer.token_type;
376
376
  if (token_type === 1) {
377
377
  const node = this.create_node(is_pseudo_element ? 26 : 25, start, this.lexer.token_end);
@@ -393,7 +393,7 @@ var SelectorParser = class {
393
393
  let paren_depth = 1;
394
394
  let end = this.lexer.token_end;
395
395
  while (this.lexer.pos < this.selector_end && paren_depth > 0) {
396
- this.lexer.next_token_fast(false);
396
+ this.lexer.next_token(false);
397
397
  const token_type = this.lexer.token_type;
398
398
  if (token_type === 21 || token_type === 2) paren_depth++;
399
399
  else if (token_type === 22) {
@@ -437,7 +437,7 @@ var SelectorParser = class {
437
437
  let first_child = null;
438
438
  let last_child = null;
439
439
  while (this.lexer.pos < end) {
440
- this.lexer.next_token_fast(false);
440
+ this.lexer.next_token(false);
441
441
  const token_type = this.lexer.token_type;
442
442
  const token_start = this.lexer.token_start;
443
443
  const token_end = this.lexer.token_end;
@@ -1,5 +1,5 @@
1
- import { l as CSSDataArena } from "./arena-DvT75bvK.js";
2
- import { B as SelectorList, z as Selector } from "./node-types-CY0JK9_a.js";
1
+ import { l as CSSDataArena } from "./arena-7RLvyGPB.js";
2
+ import { B as SelectorList, z as Selector } from "./node-types-BZGPDESt.js";
3
3
  //#region src/parse-selector.d.ts
4
4
  /** @internal */
5
5
  export declare class SelectorParser {
@@ -1 +1 @@
1
- export { t as SelectorParser, n as parse_selector, r as parse_selector_list } from "./parse-selector-CqIpnBrQ.js";
1
+ export { t as SelectorParser, n as parse_selector, r as parse_selector_list } from "./parse-selector-B59fV-Ya.js";
@@ -1,5 +1,5 @@
1
- import { l as CSSDataArena } from "./arena-DvT75bvK.js";
2
- import { Z as Value } from "./node-types-CY0JK9_a.js";
1
+ import { l as CSSDataArena } from "./arena-7RLvyGPB.js";
2
+ import { Z as Value } from "./node-types-BZGPDESt.js";
3
3
  //#region src/parse-value.d.ts
4
4
  /** @internal */
5
5
  export declare class ValueParser {
@@ -1,6 +1,6 @@
1
- import { l as CSSDataArena } from "./arena-Bsf96CQK.js";
2
- import { t as CSSNode } from "./css-node-yoUdFtNg.js";
3
- import { t as ValueNodeParser } from "./value-node-parser-BBwBxFR_.js";
1
+ import { l as CSSDataArena } from "./arena-CsJhQRUX.js";
2
+ import { t as CSSNode } from "./css-node-BJnbanUS.js";
3
+ import { t as ValueNodeParser } from "./value-node-parser-BBlVw-en.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-DvT75bvK.js";
1
+ import { l as CSSDataArena } from "./arena-7RLvyGPB.js";
2
2
  import { CommentInfo } from "./tokenize.js";
3
- import { U as StyleSheet } from "./node-types-CY0JK9_a.js";
3
+ import { U as StyleSheet } from "./node-types-BZGPDESt.js";
4
4
  //#region src/parse.d.ts
5
5
  export interface ParserOptions {
6
6
  parse_values?: boolean;