@projectwallace/css-parser 0.18.12 → 0.19.0

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 CHANGED
@@ -231,7 +231,7 @@ decl.clone({ deep: false }).property // "color"
231
231
 
232
232
  ### String helpers
233
233
 
234
- Allocation-free helpers, handy when working with node names. Also available from `@projectwallace/css-parser/string-utils`; token type constants (`TOKEN_*`) are available from `@projectwallace/css-parser/token-types`. The lowercase argument is the first one for `str_equals` and the second one for `str_starts_with` and `str_index_of`. This inconsistency will be fixed in a future breaking change.
234
+ Allocation-free helpers, handy when working with node names. Also available from `@projectwallace/css-parser/string-utils`; token type constants (`TOKEN_*`) are available from `@projectwallace/css-parser/token-types`. The lowercase argument is always the first one.
235
235
 
236
236
  ```typescript
237
237
  import {
@@ -247,8 +247,8 @@ is_custom('--primary') // true
247
247
  is_vendor_prefixed('-webkit-transform') // true
248
248
  strip_vendor_prefix('-webkit-transform') // "transform"
249
249
  str_equals('media', 'MEDIA') // true
250
- str_starts_with('WEBKIT-transform', 'webkit') // true
251
- str_index_of('background-COLOR', 'color') // 11
250
+ str_starts_with('webkit', 'WEBKIT-transform') // true
251
+ str_index_of('color', 'background-COLOR') // 11
252
252
  ```
253
253
 
254
254
  ## Non-goals
@@ -1,5 +1,5 @@
1
1
  import "./arena-Bsf96CQK.js";
2
- import { a as is_vendor_prefixed, o as is_whitespace, s as str_equals, u as str_starts_with } from "./string-utils-DiRRd28d.js";
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
5
5
  const nodes_with_name = /* @__PURE__ */ new Set([
@@ -187,7 +187,7 @@ var CSSNode = class CSSNode {
187
187
  if (type === 11) return Number(text);
188
188
  if (type === 18) {
189
189
  if (first_child?.type === 13) return first_child.text;
190
- if (str_starts_with(text, "url(")) {
190
+ if (str_starts_with("url(", text)) {
191
191
  const open_paren = text.indexOf("(");
192
192
  const close_paren = text.lastIndexOf(")");
193
193
  if (open_paren !== -1 && close_paren !== -1 && close_paren > open_paren) return text.substring(open_paren + 1, close_paren).trim();
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import { A as PARENTHESIS, B as STYLESHEET, C as MEDIA_QUERY, D as NTH_SELECTOR,
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-CY0JK9_a.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-ZcWS9nNe.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";
@@ -10,5 +10,5 @@ import { parse_declaration } from "./parse-declaration.js";
10
10
  import { parse_value } from "./parse-value.js";
11
11
  import { parse_dimension } from "./parse-dimension.js";
12
12
  import { BREAK, SKIP, traverse, walk } from "./walk.js";
13
- import { a as str_starts_with, i as str_index_of, n as is_vendor_prefixed, o as strip_vendor_prefix, r as str_equals, t as is_custom } from "./string-helpers-BMWJduts.js";
13
+ import { a as str_starts_with, i as str_index_of, n as is_vendor_prefixed, o as strip_vendor_prefix, r as str_equals, t as is_custom } from "./string-helpers-t7UofIfp.js";
14
14
  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_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, strip_vendor_prefix, tokenize, traverse, walk };
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
- import { n as tokenize } from "./tokenize-Ccg58Z_k.js";
1
+ import { n as tokenize } from "./tokenize-CduZS6FG.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
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-Bsf96CQK.js";
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-DiRRd28d.js";
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-CqIpnBrQ.js";
6
+ import { n as parse_selector, r as parse_selector_list } from "./parse-selector-BJJ4gjdB.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";
@@ -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" */
@@ -319,7 +319,7 @@ type ContainerQuery = WithClone<CSSNode & WithChildren<Identifier | MediaFeature
319
319
  readonly type: typeof CONTAINER_QUERY;
320
320
  readonly type_name: 'ContainerQuery';
321
321
  }>;
322
- type SupportsQuery = WithClone<CSSNode & WithChildren<SupportsDeclaration> & {
322
+ type SupportsQuery = WithClone<CSSNode & WithChildren<SupportsDeclaration | SupportsQuery | PreludeOperator | Function> & {
323
323
  readonly type: typeof SUPPORTS_QUERY;
324
324
  readonly type_name: 'SupportsQuery';
325
325
  /** The supports condition text, e.g. "display: flex" from "supports(display: flex)" */
@@ -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-ZcWS9nNe.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,5 +1,5 @@
1
1
  import { l as CSSDataArena } from "./arena-DvT75bvK.js";
2
- import { O as NthSelector } from "./node-types-CY0JK9_a.js";
2
+ import { O as NthSelector } from "./node-types-ZcWS9nNe.js";
3
3
  //#region src/parse-anplusb.d.ts
4
4
  /** @internal */
5
5
  export declare class ANplusBParser {
@@ -1,8 +1,8 @@
1
- import { t as Lexer } from "./tokenize-Ccg58Z_k.js";
1
+ import { t as Lexer } from "./tokenize-CduZS6FG.js";
2
2
  import "./token-types.js";
3
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";
4
+ import { l as str_index_of, s as str_equals } from "./string-utils-aEEsA2CS.js";
5
+ import { t as CSSNode } from "./css-node-XDNQLChU.js";
6
6
  //#region src/parse-anplusb.ts
7
7
  /** @internal */
8
8
  var ANplusBParser = class {
@@ -31,7 +31,7 @@ var ANplusBParser = class {
31
31
  const node_start = start;
32
32
  this.skip_whitespace();
33
33
  if (this.lexer.pos >= this.expr_end) return null;
34
- this.lexer.next_token_fast(true);
34
+ this.lexer.next_token(true);
35
35
  if (this.lexer.token_type === 1) {
36
36
  const text = this.source.substring(this.lexer.token_start, this.lexer.token_end);
37
37
  if (str_equals("odd", text) || str_equals("even", text)) {
@@ -85,7 +85,7 @@ var ANplusBParser = class {
85
85
  }
86
86
  if (this.lexer.token_type === 9 && this.source.charCodeAt(this.lexer.token_start) === 43) {
87
87
  const saved = this.lexer.save_position();
88
- this.lexer.next_token_fast(true);
88
+ this.lexer.next_token(true);
89
89
  if (this.lexer.token_type === 1) {
90
90
  if (this.source.substring(this.lexer.token_start, this.lexer.token_end).charCodeAt(0) === 110) {
91
91
  a_start = saved.pos - 1;
@@ -110,7 +110,7 @@ var ANplusBParser = class {
110
110
  }
111
111
  if (this.lexer.token_type === 12) {
112
112
  const token_text = this.source.substring(this.lexer.token_start, this.lexer.token_end);
113
- const n_index = str_index_of(token_text, "n");
113
+ const n_index = str_index_of("n", token_text);
114
114
  if (n_index !== -1) {
115
115
  a_start = this.lexer.token_start;
116
116
  a_end = this.lexer.token_start + n_index + 1;
@@ -146,13 +146,13 @@ var ANplusBParser = class {
146
146
  parse_b_part() {
147
147
  this.skip_whitespace();
148
148
  if (this.lexer.pos >= this.expr_end) return null;
149
- this.lexer.next_token_fast(true);
149
+ this.lexer.next_token(true);
150
150
  if (this.lexer.token_type === 9) {
151
151
  const ch = this.source.charCodeAt(this.lexer.token_start);
152
152
  if (ch === 43 || ch === 45) {
153
153
  const sign = ch === 45 ? "-" : "";
154
154
  this.skip_whitespace();
155
- this.lexer.next_token_fast(true);
155
+ this.lexer.next_token(true);
156
156
  if (this.lexer.token_type === 10) {
157
157
  let num_text = this.source.substring(this.lexer.token_start, this.lexer.token_end);
158
158
  if (num_text.charCodeAt(0) === 43) num_text = num_text.substring(1);
@@ -1,5 +1,5 @@
1
1
  import { l as CSSDataArena } from "./arena-DvT75bvK.js";
2
- import { t as AnyNode } from "./node-types-CY0JK9_a.js";
2
+ import { t as AnyNode } from "./node-types-ZcWS9nNe.js";
3
3
  //#region src/parse-atrule-prelude.d.ts
4
4
  /** @internal */
5
5
  export declare class AtRulePreludeParser {
@@ -1,10 +1,10 @@
1
- import { t as Lexer } from "./tokenize-Ccg58Z_k.js";
1
+ import { t as Lexer } from "./tokenize-CduZS6FG.js";
2
2
  import "./token-types.js";
3
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";
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-XDNQLChU.js";
6
+ import { s as trim_boundaries } from "./parse-selector-BJJ4gjdB.js";
7
+ import { n as ConditionParser, t as ValueNodeParser } from "./value-node-parser-Duyvn_ok.js";
8
8
  //#region src/parse-atrule-prelude.ts
9
9
  /** @internal */
10
10
  var AtRulePreludeParser = class {
@@ -263,28 +263,31 @@ var AtRulePreludeParser = class {
263
263
  const name_end = this.lexer.token_type === 2 ? this.lexer.token_end - 1 : this.lexer.token_end;
264
264
  if (str_equals_range(this.source, this.lexer.token_start, name_end, "layer")) {
265
265
  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
- }
266
+ if (this.lexer.token_type === 1) {
267
+ const layer_node = this.create_node(37, layer_start, this.lexer.token_end);
268
+ this.arena.set_content_start_delta(layer_node, 0);
269
+ this.arena.set_content_length(layer_node, 0);
270
+ return layer_node;
278
271
  }
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
- }
272
+ const content_start = this.lexer.token_end;
273
+ const matched = this.scan_matching_paren();
274
+ const content_end = this.paren_content_end;
275
+ const layer_end = matched ? this.paren_close_end : this.lexer.pos;
276
+ const func_node = this.create_node(15, layer_start, layer_end);
277
+ this.arena.set_content_start_delta(func_node, 0);
278
+ this.arena.set_content_length(func_node, name_end - layer_start);
279
+ const trimmed = matched ? trim_boundaries(this.source, content_start, content_end) : null;
280
+ if (trimmed) {
281
+ const name_start = trimmed[0];
282
+ const name_length = trimmed[1] - name_start;
283
+ this.arena.set_value_start_delta(func_node, name_start - layer_start);
284
+ this.arena.set_value_length(func_node, name_length);
285
+ const name_node = this.create_node(37, name_start, trimmed[1]);
286
+ this.arena.set_content_start_delta(name_node, 0);
287
+ this.arena.set_content_length(name_node, name_length);
288
+ this.arena.set_first_child(func_node, name_node);
286
289
  }
287
- return layer_node;
290
+ return func_node;
288
291
  }
289
292
  }
290
293
  this.lexer.restore_position(saved);
@@ -296,19 +299,36 @@ var AtRulePreludeParser = class {
296
299
  if (this.lexer.token_type === 2) {
297
300
  if (str_equals_range(this.source, this.lexer.token_start, this.lexer.token_end - 1, "supports")) {
298
301
  const supports_start = this.lexer.token_start;
302
+ const name_end = this.lexer.token_end - 1;
299
303
  const content_start = this.lexer.token_end;
304
+ const line = this.lexer.line;
305
+ const column = this.lexer.column;
300
306
  this.scan_matching_paren();
301
307
  const content_end = this.paren_content_end;
302
308
  const supports_end = this.paren_close_end;
303
- const supports_node = this.create_node(36, supports_start, supports_end);
309
+ const func_node = this.create_node(15, supports_start, supports_end);
310
+ this.arena.set_content_start_delta(func_node, 0);
311
+ this.arena.set_content_length(func_node, name_end - supports_start);
304
312
  const trimmed = trim_boundaries(this.source, content_start, content_end);
305
313
  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);
314
+ const condition_start = trimmed[0];
315
+ const condition_end = trimmed[1];
316
+ const condition_length = condition_end - condition_start;
317
+ this.arena.set_value_start_delta(func_node, condition_start - supports_start);
318
+ this.arena.set_value_length(func_node, condition_length);
319
+ const decl_child = this.condition_parser.parse_supports_declaration_content(condition_start, condition_end);
320
+ if (decl_child === null) {
321
+ const children = this.condition_parser.parse_supports_condition(condition_start, condition_end, line, column);
322
+ this.arena.append_children(func_node, children);
323
+ } else {
324
+ const query = this.create_node(36, condition_start, condition_end);
325
+ this.arena.set_value_start_delta(query, 0);
326
+ this.arena.set_value_length(query, condition_length);
327
+ this.arena.set_first_child(query, decl_child);
328
+ this.arena.set_first_child(func_node, query);
329
+ }
310
330
  }
311
- return supports_node;
331
+ return func_node;
312
332
  }
313
333
  }
314
334
  this.lexer.restore_position(saved);
@@ -329,7 +349,7 @@ var AtRulePreludeParser = class {
329
349
  this.lexer.token_type = 26;
330
350
  return 26;
331
351
  }
332
- return this.lexer.next_token_fast(false);
352
+ return this.lexer.next_token(false);
333
353
  }
334
354
  parse_namespace_prelude() {
335
355
  const nodes = [];
@@ -1,6 +1,6 @@
1
1
  import { l as CSSDataArena } from "./arena-DvT75bvK.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-ZcWS9nNe.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-CduZS6FG.js";
2
2
  import "./token-types.js";
3
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";
4
+ import { a as is_vendor_prefixed } from "./string-utils-aEEsA2CS.js";
5
+ import { t as CSSNode } from "./css-node-XDNQLChU.js";
6
+ import { a as skip_whitespace_and_comments_backward, o as skip_whitespace_and_comments_forward } from "./parse-selector-BJJ4gjdB.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-CduZS6FG.js";
2
2
  import "./token-types.js";
3
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";
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-XDNQLChU.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
1
  import { l as CSSDataArena } from "./arena-DvT75bvK.js";
2
- import { B as SelectorList, z as Selector } from "./node-types-CY0JK9_a.js";
2
+ import { B as SelectorList, z as Selector } from "./node-types-ZcWS9nNe.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-BJJ4gjdB.js";
@@ -1,5 +1,5 @@
1
1
  import { l as CSSDataArena } from "./arena-DvT75bvK.js";
2
- import { Z as Value } from "./node-types-CY0JK9_a.js";
2
+ import { Z as Value } from "./node-types-ZcWS9nNe.js";
3
3
  //#region src/parse-value.d.ts
4
4
  /** @internal */
5
5
  export declare class ValueParser {
@@ -1,6 +1,6 @@
1
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";
2
+ import { t as CSSNode } from "./css-node-XDNQLChU.js";
3
+ import { t as ValueNodeParser } from "./value-node-parser-Duyvn_ok.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
1
  import { l as CSSDataArena } from "./arena-DvT75bvK.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-ZcWS9nNe.js";
4
4
  //#region src/parse.d.ts
5
5
  export interface ParserOptions {
6
6
  parse_values?: boolean;
package/dist/parse.js CHANGED
@@ -1,8 +1,8 @@
1
- import { t as Lexer } from "./tokenize-Ccg58Z_k.js";
1
+ import { t as Lexer } from "./tokenize-CduZS6FG.js";
2
2
  import "./token-types.js";
3
3
  import { l as CSSDataArena } from "./arena-Bsf96CQK.js";
4
- import { t as CSSNode } from "./css-node-yoUdFtNg.js";
5
- import { a as skip_whitespace_and_comments_backward, o as skip_whitespace_and_comments_forward, t as SelectorParser } from "./parse-selector-CqIpnBrQ.js";
4
+ import { t as CSSNode } from "./css-node-XDNQLChU.js";
5
+ import { a as skip_whitespace_and_comments_backward, o as skip_whitespace_and_comments_forward, t as SelectorParser } from "./parse-selector-BJJ4gjdB.js";
6
6
  import { AtRulePreludeParser } from "./parse-atrule-prelude.js";
7
7
  import { DeclarationParser } from "./parse-declaration.js";
8
8
  //#region src/parse.ts
@@ -68,7 +68,7 @@ var Parser = class {
68
68
  return this.source;
69
69
  }
70
70
  next_token() {
71
- this.lexer.next_token_fast(true);
71
+ this.lexer.next_token(true);
72
72
  }
73
73
  peek_type() {
74
74
  return this.lexer.token_type;
@@ -1,18 +1,16 @@
1
1
  //#region src/string-utils.d.ts
2
- /**
3
- * @param a Base string, MUST be lowercase!
4
- * @param b Compare string
5
- */
2
+ /** Case-insensitive ASCII equality without allocations. `a` MUST be lowercase. */
6
3
  declare function str_equals(a: string, b: string): boolean;
7
4
  /** Case-insensitive ASCII prefix check without allocations. `prefix` MUST be lowercase. */
8
- declare function str_starts_with(str: string, prefix: string): boolean;
9
- /** Case-insensitive substring search without allocations, or -1 if not found. `searchChar` MUST be lowercase. */
10
- declare function str_index_of(str: string, searchChar: string): number;
5
+ declare function str_starts_with(prefix: string, str: string): boolean;
6
+ /** Case-insensitive substring search without allocations, or -1 if not found. `search_char` MUST be lowercase. */
7
+ declare function str_index_of(search_char: string, str: string): number;
11
8
  /** True if the string/range is vendor-prefixed (-webkit-, -moz-, -ms-, -o-). `--custom-property` is not. */
12
9
  declare function is_vendor_prefixed(text: string): boolean;
13
10
  declare function is_vendor_prefixed(source: string, start: number, end: number): boolean;
14
11
  /** True if the string is a CSS custom property (starts with `--`). */
15
12
  declare function is_custom(str: string): boolean;
13
+ /** Strip a vendor prefix, e.g. `-webkit-keyframes` → `keyframes`. Returns the input unchanged if it has no prefix. */
16
14
  declare function strip_vendor_prefix(str: string): string;
17
15
  //#endregion
18
16
  export { str_starts_with as a, str_index_of as i, is_vendor_prefixed as n, strip_vendor_prefix as o, str_equals as r, is_custom as t };
@@ -1,2 +1,2 @@
1
- import { a as str_starts_with, i as str_index_of, n as is_vendor_prefixed, o as strip_vendor_prefix, r as str_equals, t as is_custom } from "./string-helpers-BMWJduts.js";
1
+ import { a as str_starts_with, i as str_index_of, n as is_vendor_prefixed, o as strip_vendor_prefix, r as str_equals, t as is_custom } from "./string-helpers-t7UofIfp.js";
2
2
  export { is_custom, is_vendor_prefixed, str_equals, str_index_of, str_starts_with, strip_vendor_prefix };
@@ -1 +1 @@
1
- export { r as is_custom, a as is_vendor_prefixed, s as str_equals, l as str_index_of, u as str_starts_with, d as strip_vendor_prefix } from "./string-utils-DiRRd28d.js";
1
+ export { r as is_custom, a as is_vendor_prefixed, s as str_equals, l as str_index_of, u as str_starts_with, d as strip_vendor_prefix } from "./string-utils-aEEsA2CS.js";
@@ -1,3 +1,4 @@
1
+ /** True if the character code is whitespace (space, tab, newline, CR, or FF). */
1
2
  function is_whitespace(ch) {
2
3
  return ch === 32 || ch === 9 || ch === 10 || ch === 13 || ch === 12;
3
4
  }
@@ -8,10 +9,7 @@ function is_combinator(ch) {
8
9
  function is_digit(ch) {
9
10
  return ch >= 48 && ch <= 57;
10
11
  }
11
- /**
12
- * @param a Base string, MUST be lowercase!
13
- * @param b Compare string
14
- */
12
+ /** Case-insensitive ASCII equality without allocations. `a` MUST be lowercase. */
15
13
  function str_equals(a, b) {
16
14
  if (a.length !== b.length) return false;
17
15
  for (let i = 0; i < a.length; i++) {
@@ -22,6 +20,10 @@ function str_equals(a, b) {
22
20
  }
23
21
  return true;
24
22
  }
23
+ /**
24
+ * Case-insensitive equality between `source[start, end)` and `literal`, without allocating a substring first.
25
+ * Same semantics as `str_equals(literal, source.substring(start, end))`. `literal` MUST be lowercase.
26
+ */
25
27
  function str_equals_range(source, start, end, literal) {
26
28
  if (end - start !== literal.length) return false;
27
29
  for (let i = 0; i < literal.length; i++) {
@@ -31,13 +33,14 @@ function str_equals_range(source, start, end, literal) {
31
33
  }
32
34
  return true;
33
35
  }
36
+ /** True if `source[start, end)` is and/or/not (case-insensitive). */
34
37
  function is_and_or_not_range(source, start, end) {
35
38
  const length = end - start;
36
39
  if (length === 3) return str_equals_range(source, start, end, "and") || str_equals_range(source, start, end, "not");
37
40
  return length === 2 && str_equals_range(source, start, end, "or");
38
41
  }
39
42
  /** Case-insensitive ASCII prefix check without allocations. `prefix` MUST be lowercase. */
40
- function str_starts_with(str, prefix) {
43
+ function str_starts_with(prefix, str) {
41
44
  if (str.length < prefix.length) return false;
42
45
  for (let i = 0; i < prefix.length; i++) {
43
46
  let ca = str.charCodeAt(i);
@@ -47,23 +50,23 @@ function str_starts_with(str, prefix) {
47
50
  }
48
51
  return true;
49
52
  }
50
- /** Case-insensitive substring search without allocations, or -1 if not found. `searchChar` MUST be lowercase. */
51
- function str_index_of(str, searchChar) {
52
- if (searchChar.length === 0) return -1;
53
- if (searchChar.length === 1) {
54
- const searchCode = searchChar.charCodeAt(0);
53
+ /** Case-insensitive substring search without allocations, or -1 if not found. `search_char` MUST be lowercase. */
54
+ function str_index_of(search_char, str) {
55
+ if (search_char.length === 0) return -1;
56
+ if (search_char.length === 1) {
57
+ const search_code = search_char.charCodeAt(0);
55
58
  for (let i = 0; i < str.length; i++) {
56
59
  let ca = str.charCodeAt(i);
57
60
  if (ca >= 65 && ca <= 90) ca |= 32;
58
- if (ca === searchCode) return i;
61
+ if (ca === search_code) return i;
59
62
  }
60
63
  return -1;
61
64
  }
62
- for (let i = 0; i <= str.length - searchChar.length; i++) {
65
+ for (let i = 0; i <= str.length - search_char.length; i++) {
63
66
  let match = true;
64
- for (let j = 0; j < searchChar.length; j++) {
67
+ for (let j = 0; j < search_char.length; j++) {
65
68
  let ca = str.charCodeAt(i + j);
66
- const cb = searchChar.charCodeAt(j);
69
+ const cb = search_char.charCodeAt(j);
67
70
  if (ca >= 65 && ca <= 90) ca |= 32;
68
71
  if (ca !== cb) {
69
72
  match = false;
@@ -90,6 +93,7 @@ function is_custom(str) {
90
93
  if (str.length < 3) return false;
91
94
  return str.charCodeAt(0) === 45 && str.charCodeAt(1) === 45;
92
95
  }
96
+ /** Strip a vendor prefix, e.g. `-webkit-keyframes` → `keyframes`. Returns the input unchanged if it has no prefix. */
93
97
  function strip_vendor_prefix(str) {
94
98
  if (!is_vendor_prefixed(str)) return str;
95
99
  for (let i = 2; i < str.length; i++) if (str.charCodeAt(i) === 45) return str.substring(i + 1);
@@ -111,7 +111,7 @@ var Lexer = class {
111
111
  this._line = line;
112
112
  this._line_offset = pos - column + 1;
113
113
  }
114
- next_token_fast(skip_whitespace = false) {
114
+ next_token(skip_whitespace = false) {
115
115
  const source = this.source;
116
116
  const source_length = source.length;
117
117
  while (true) {
@@ -619,16 +619,6 @@ var Lexer = class {
619
619
  this.token_column = column;
620
620
  return type;
621
621
  }
622
- next_token(skip_whitespace = false) {
623
- this.next_token_fast(skip_whitespace);
624
- return {
625
- type: this.token_type,
626
- start: this.token_start,
627
- end: this.token_end,
628
- line: this.token_line,
629
- column: this.token_column
630
- };
631
- }
632
622
  /**
633
623
  * Save complete lexer state for backtracking
634
624
  * @returns Object containing all lexer state
@@ -700,9 +690,15 @@ var Lexer = class {
700
690
  function* tokenize(source, on_comment) {
701
691
  const lexer = new Lexer(source, on_comment);
702
692
  while (true) {
703
- const token = lexer.next_token();
704
- if (!token || token.type === 26) break;
705
- yield token;
693
+ const type = lexer.next_token();
694
+ if (type === 26) break;
695
+ yield {
696
+ type,
697
+ start: lexer.token_start,
698
+ end: lexer.token_end,
699
+ line: lexer.token_line,
700
+ column: lexer.token_column
701
+ };
706
702
  }
707
703
  }
708
704
  //#endregion
@@ -34,7 +34,7 @@ export declare class Lexer {
34
34
  get line(): number;
35
35
  get column(): number;
36
36
  seek(pos: number, line: number, column?: number): void;
37
- next_token_fast(skip_whitespace?: boolean): TokenType;
37
+ next_token(skip_whitespace?: boolean): TokenType;
38
38
  private _scan_newlines;
39
39
  private _skip_comment;
40
40
  /**
@@ -69,7 +69,6 @@ export declare class Lexer {
69
69
  advance(count?: number): void;
70
70
  peek(offset?: number): number;
71
71
  make_token(type: TokenType, start: number, end: number, line?: number, column?: number): TokenType;
72
- next_token(skip_whitespace?: boolean): Token | null;
73
72
  /**
74
73
  * Save complete lexer state for backtracking
75
74
  * @returns Object containing all lexer state
package/dist/tokenize.js CHANGED
@@ -1 +1 @@
1
- export { t as Lexer, n as tokenize } from "./tokenize-Ccg58Z_k.js";
1
+ export { t as Lexer, n as tokenize } from "./tokenize-CduZS6FG.js";
@@ -1,8 +1,8 @@
1
- import { t as Lexer } from "./tokenize-Ccg58Z_k.js";
1
+ import { t as Lexer } from "./tokenize-CduZS6FG.js";
2
2
  import "./token-types.js";
3
3
  import "./arena-Bsf96CQK.js";
4
- import { c as str_equals_range, t as is_and_or_not_range } from "./string-utils-DiRRd28d.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-CqIpnBrQ.js";
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-BJJ4gjdB.js";
6
6
  //#region src/parse-condition.ts
7
7
  var ConditionParser = class {
8
8
  lexer;
@@ -29,7 +29,7 @@ var ConditionParser = class {
29
29
  this.lexer.token_type = 26;
30
30
  return 26;
31
31
  }
32
- return this.lexer.next_token_fast(false);
32
+ return this.lexer.next_token(false);
33
33
  }
34
34
  paren_content_end = 0;
35
35
  paren_close_end = 0;
@@ -209,6 +209,8 @@ var ConditionParser = class {
209
209
  const func_name_start = this.lexer.token_start;
210
210
  const func_name_end = this.lexer.token_end - 1;
211
211
  const content_start = this.lexer.token_end;
212
+ const content_line = this.lexer.line;
213
+ const content_column = this.lexer.column;
212
214
  this.scan_matching_paren();
213
215
  const content_end = this.paren_content_end;
214
216
  const func_end = this.paren_close_end;
@@ -222,7 +224,8 @@ var ConditionParser = class {
222
224
  if (selector_list !== null) this.arena.set_first_child(func_node, selector_list);
223
225
  } else if (str_equals_range(this.source, func_name_start, func_name_end, "style")) {
224
226
  const decl_child = this.parse_supports_declaration_content(content_start, content_end);
225
- if (decl_child !== null) this.arena.set_first_child(func_node, decl_child);
227
+ if (decl_child === null) this.append_nested_condition(func_node, content_start, content_end, content_line, content_column);
228
+ else this.arena.set_first_child(func_node, decl_child);
226
229
  }
227
230
  return func_node;
228
231
  }
@@ -231,6 +234,12 @@ var ConditionParser = class {
231
234
  if (colon_pos === -1) return null;
232
235
  return this.create_supports_declaration(content_start, content_end, colon_pos);
233
236
  }
237
+ append_nested_condition(parent, start, end, line, column) {
238
+ const saved = this.lexer.save_position();
239
+ const children = this.parse_supports_condition(start, end, line, column);
240
+ this.lexer.restore_position(saved);
241
+ this.arena.append_children(parent, children);
242
+ }
234
243
  parse_supports_condition(start, end, line, column) {
235
244
  const saved_end = this.end;
236
245
  this.end = end;
@@ -244,6 +253,8 @@ var ConditionParser = class {
244
253
  if (token_type === 21) {
245
254
  const feature_start = this.lexer.token_start;
246
255
  const content_start = this.lexer.pos;
256
+ const content_line = this.lexer.line;
257
+ const content_column = this.lexer.column;
247
258
  const matched = this.scan_matching_paren();
248
259
  const content_end = this.paren_content_end;
249
260
  const feature_end = this.paren_close_end;
@@ -254,7 +265,8 @@ var ConditionParser = class {
254
265
  this.arena.set_value_start_delta(query, trimmed[0] - feature_start);
255
266
  this.arena.set_value_length(query, trimmed[1] - trimmed[0]);
256
267
  const decl_child = this.parse_supports_declaration_content(trimmed[0], trimmed[1]);
257
- if (decl_child !== null) this.arena.set_first_child(query, decl_child);
268
+ if (decl_child === null) this.append_nested_condition(query, content_start, content_end, content_line, content_column);
269
+ else this.arena.set_first_child(query, decl_child);
258
270
  }
259
271
  nodes.push(query);
260
272
  }
@@ -295,7 +307,7 @@ var ValueNodeParser = class ValueNodeParser {
295
307
  let first_node = 0;
296
308
  let last_node = 0;
297
309
  while (this.lexer.pos < this.end) {
298
- this.lexer.next_token_fast(true);
310
+ this.lexer.next_token(true);
299
311
  if (this.lexer.token_start >= this.end) break;
300
312
  if (this.lexer.token_type === 26) break;
301
313
  const node = this.parse_value_node();
@@ -346,7 +358,7 @@ var ValueNodeParser = class ValueNodeParser {
346
358
  let content_end = this.lexer.pos;
347
359
  let close_end = this.lexer.token_end;
348
360
  while ((!bounded || this.lexer.pos < this.end) && depth > 0) {
349
- this.lexer.next_token_fast(false);
361
+ this.lexer.next_token(false);
350
362
  const token_type = this.lexer.token_type;
351
363
  if (token_type === 26) break;
352
364
  if (bounded && this.lexer.token_start >= this.end) break;
@@ -372,8 +384,8 @@ var ValueNodeParser = class ValueNodeParser {
372
384
  this.arena.set_content_length(node, name_end - start);
373
385
  if (is_url || str_equals_range(this.source, start, name_end, "src")) {
374
386
  const save_pos = this.lexer.save_position();
375
- this.lexer.next_token_fast(false);
376
- while (this.lexer.token_type === 13 && this.lexer.pos < this.end) this.lexer.next_token_fast(false);
387
+ this.lexer.next_token(false);
388
+ while (this.lexer.token_type === 13 && this.lexer.pos < this.end) this.lexer.next_token(false);
377
389
  const first_token_type = this.lexer.token_type;
378
390
  this.lexer.restore_position(save_pos);
379
391
  if (first_token_type === 5) {} else {
@@ -400,7 +412,7 @@ var ValueNodeParser = class ValueNodeParser {
400
412
  const content_start = end;
401
413
  let content_end = end;
402
414
  while (this.lexer.pos < this.end && paren_depth > 0) {
403
- this.lexer.next_token_fast(true);
415
+ this.lexer.next_token(true);
404
416
  const token_type = this.lexer.token_type;
405
417
  if (token_type === 26) break;
406
418
  if (this.lexer.token_start >= this.end) break;
@@ -438,7 +450,7 @@ var ValueNodeParser = class ValueNodeParser {
438
450
  let content_end = end;
439
451
  let if_closed = false;
440
452
  while (this.lexer.pos < this.end && !if_closed) {
441
- this.lexer.next_token_fast(false);
453
+ this.lexer.next_token(false);
442
454
  const tt = this.lexer.token_type;
443
455
  if (tt === 26) break;
444
456
  if (this.lexer.token_start >= this.end) break;
@@ -456,7 +468,7 @@ var ValueNodeParser = class ValueNodeParser {
456
468
  const condition_end_pos = this.arena.get_start_offset(condition_node) + this.arena.get_length(condition_node);
457
469
  let colon_found = false;
458
470
  while (this.lexer.pos < this.end) {
459
- this.lexer.next_token_fast(false);
471
+ this.lexer.next_token(false);
460
472
  const t = this.lexer.token_type;
461
473
  if (t === 26) break;
462
474
  if (this.lexer.token_start >= this.end) break;
@@ -478,7 +490,7 @@ var ValueNodeParser = class ValueNodeParser {
478
490
  let value_line = 0;
479
491
  let value_col = 0;
480
492
  if (colon_found && !if_closed) while (this.lexer.pos < this.end) {
481
- this.lexer.next_token_fast(false);
493
+ this.lexer.next_token(false);
482
494
  const t = this.lexer.token_type;
483
495
  if (t === 26) break;
484
496
  if (this.lexer.token_start >= this.end) break;
@@ -528,7 +540,7 @@ var ValueNodeParser = class ValueNodeParser {
528
540
  }
529
541
  next_significant_token() {
530
542
  while (this.lexer.pos < this.end) {
531
- this.lexer.next_token_fast(false);
543
+ this.lexer.next_token(false);
532
544
  if (this.lexer.token_start >= this.end) return 26;
533
545
  if (this.lexer.token_type === 13) continue;
534
546
  return this.lexer.token_type;
@@ -627,7 +639,7 @@ var ValueNodeParser = class ValueNodeParser {
627
639
  this.lexer.seek(start, this.lexer.line, this.lexer.column);
628
640
  const nodes = [];
629
641
  while (this.lexer.pos < this.end) {
630
- this.lexer.next_token_fast(true);
642
+ this.lexer.next_token(true);
631
643
  if (this.lexer.token_start >= this.end) break;
632
644
  if (this.lexer.token_type === 26) break;
633
645
  const node = this.parse_value_node();
@@ -644,7 +656,7 @@ var ValueNodeParser = class ValueNodeParser {
644
656
  let paren_depth = 1;
645
657
  let paren_end = end;
646
658
  while (this.lexer.pos < this.end && paren_depth > 0) {
647
- this.lexer.next_token_fast(true);
659
+ this.lexer.next_token(true);
648
660
  const token_type = this.lexer.token_type;
649
661
  if (token_type === 26) break;
650
662
  if (this.lexer.token_start >= this.end) break;
package/dist/walk.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { s as CSSNode, t as AnyNode } from "./node-types-CY0JK9_a.js";
1
+ import { s as CSSNode, t as AnyNode } from "./node-types-ZcWS9nNe.js";
2
2
  //#region src/walk.d.ts
3
3
  export declare const SKIP: unique symbol;
4
4
  export declare const BREAK: unique symbol;
package/dist/walk.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./arena-Bsf96CQK.js";
2
- import { t as CSSNode } from "./css-node-yoUdFtNg.js";
2
+ import { t as CSSNode } from "./css-node-XDNQLChU.js";
3
3
  import "./constants.js";
4
4
  //#region src/walk.ts
5
5
  const SKIP = Symbol("SKIP");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@projectwallace/css-parser",
3
- "version": "0.18.12",
3
+ "version": "0.19.0",
4
4
  "description": "High-performance CSS lexer and parser, optimized for CSS inspection and analysis",
5
5
  "keywords": [
6
6
  "ast",