@projectwallace/css-parser 0.18.7 → 0.18.8

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.
@@ -1,6 +1,6 @@
1
1
  import { A as PARENTHESIS, B as STYLESHEET, C as MEDIA_QUERY, D as NTH_SELECTOR, E as NTH_OF_SELECTOR, F as RATIO, G as UNICODE_RANGE, H as SUPPORTS_DECLARATION, I as RAW, J as VALUE, K as UNIVERSAL_SELECTOR, L as SELECTOR, N as PSEUDO_CLASS_SELECTOR, O as NUMBER, P as PSEUDO_ELEMENT_SELECTOR, R as SELECTOR_LIST, S as MEDIA_FEATURE, T as NESTING_SELECTOR, U as SUPPORTS_QUERY, V as STYLE_RULE, W as TYPE_SELECTOR, _ as ID_SELECTOR, a as CLASS_SELECTOR, b as LANG_SELECTOR, c as CONTAINER_QUERY, d as DIMENSION, f as FEATURE_RANGE, g as IDENTIFIER, h as HASH, i as BLOCK, j as PRELUDE_OPERATOR, k as OPERATOR, m as FUNCTION, n as AT_RULE, o as COMBINATOR, p as FLAG_IMPORTANT, q as URL, r as AT_RULE_PRELUDE, s as COMMENT, t as ATTRIBUTE_SELECTOR, u as DECLARATION, v as IF_BRANCH, w as MEDIA_TYPE, x as LAYER_NAME, y as IF_CONDITION, z as STRING } from "./arena-BGvFdbj5.js";
2
2
  //#region src/constants.d.ts
3
- declare const NODE_TYPES: {
3
+ export declare const NODE_TYPES: {
4
4
  readonly STYLESHEET: 1;
5
5
  readonly STYLE_RULE: 2;
6
6
  readonly AT_RULE: 3;
@@ -48,4 +48,4 @@ declare const NODE_TYPES: {
48
48
  readonly RATIO: 58;
49
49
  };
50
50
  //#endregion
51
- export { ATTRIBUTE_SELECTOR, AT_RULE, AT_RULE_PRELUDE, BLOCK, CLASS_SELECTOR, COMBINATOR, COMMENT, CONTAINER_QUERY, DECLARATION, DIMENSION, FEATURE_RANGE, FLAG_IMPORTANT, FUNCTION, HASH, IDENTIFIER, ID_SELECTOR, IF_BRANCH, IF_CONDITION, LANG_SELECTOR, LAYER_NAME, MEDIA_FEATURE, MEDIA_QUERY, MEDIA_TYPE, NESTING_SELECTOR, NODE_TYPES, NTH_OF_SELECTOR, NTH_SELECTOR, NUMBER, OPERATOR, PARENTHESIS, PRELUDE_OPERATOR, PSEUDO_CLASS_SELECTOR, PSEUDO_ELEMENT_SELECTOR, RATIO, RAW, SELECTOR, SELECTOR_LIST, STRING, STYLESHEET, STYLE_RULE, SUPPORTS_DECLARATION, SUPPORTS_QUERY, TYPE_SELECTOR, UNICODE_RANGE, UNIVERSAL_SELECTOR, URL, VALUE };
51
+ export { ATTRIBUTE_SELECTOR, AT_RULE, AT_RULE_PRELUDE, BLOCK, CLASS_SELECTOR, COMBINATOR, COMMENT, CONTAINER_QUERY, DECLARATION, DIMENSION, FEATURE_RANGE, FLAG_IMPORTANT, FUNCTION, HASH, IDENTIFIER, ID_SELECTOR, IF_BRANCH, IF_CONDITION, LANG_SELECTOR, LAYER_NAME, MEDIA_FEATURE, MEDIA_QUERY, MEDIA_TYPE, NESTING_SELECTOR, NTH_OF_SELECTOR, NTH_SELECTOR, NUMBER, OPERATOR, PARENTHESIS, PRELUDE_OPERATOR, PSEUDO_CLASS_SELECTOR, PSEUDO_ELEMENT_SELECTOR, RATIO, RAW, SELECTOR, SELECTOR_LIST, STRING, STYLESHEET, STYLE_RULE, SUPPORTS_DECLARATION, SUPPORTS_QUERY, TYPE_SELECTOR, UNICODE_RANGE, UNIVERSAL_SELECTOR, URL, VALUE };
@@ -224,7 +224,7 @@ var CSSNode = class CSSNode {
224
224
  if (pos >= node_end) return null;
225
225
  let ch1 = this.source.charCodeAt(pos);
226
226
  let ch2 = pos + 1 < node_end ? this.source.charCodeAt(pos + 1) : 0;
227
- if (ch1 === 61) return this.source.substring(pos, pos + 1);
227
+ if (ch1 === 61) return this.source.at(pos);
228
228
  if (ch1 === 126 && ch2 === 61) return this.source.substring(pos, pos + 2);
229
229
  if (ch1 === 124 && ch2 === 61) return this.source.substring(pos, pos + 2);
230
230
  if (ch1 === 94 && ch2 === 61) return this.source.substring(pos, pos + 2);
@@ -243,7 +243,7 @@ var CSSNode = class CSSNode {
243
243
  while (pos < node_end && is_whitespace(this.source.charCodeAt(pos))) pos++;
244
244
  if (pos >= node_end) return null;
245
245
  let flag_ch = this.source.charCodeAt(pos);
246
- if (flag_ch === 105 || flag_ch === 73 || flag_ch === 115 || flag_ch === 83) return this.source.substring(pos, pos + 1);
246
+ if (flag_ch === 105 || flag_ch === 73 || flag_ch === 115 || flag_ch === 83) return this.source.at(pos);
247
247
  return null;
248
248
  }
249
249
  /** Get the unit for dimension nodes (e.g., "px" from "100px", "%" from "50%") */
package/dist/index.d.ts CHANGED
@@ -14,15 +14,15 @@ import { BREAK, SKIP, traverse, walk } from "./walk.js";
14
14
  * @param a Base string, MUST be lowercase!
15
15
  * @param b Compare string
16
16
  */
17
- declare function str_equals(a: string, b: string): boolean;
17
+ export declare function str_equals(a: string, b: string): boolean;
18
18
  /** Case-insensitive ASCII prefix check without allocations. `prefix` MUST be lowercase. */
19
- declare function str_starts_with(str: string, prefix: string): boolean;
19
+ export declare function str_starts_with(str: string, prefix: string): boolean;
20
20
  /** Case-insensitive substring search without allocations, or -1 if not found. `searchChar` MUST be lowercase. */
21
- declare function str_index_of(str: string, searchChar: string): number;
21
+ export declare function str_index_of(str: string, searchChar: string): number;
22
22
  /** True if the string/range is vendor-prefixed (-webkit-, -moz-, -ms-, -o-). `--custom-property` is not. */
23
- declare function is_vendor_prefixed(text: string): boolean;
24
- declare function is_vendor_prefixed(source: string, start: number, end: number): boolean;
23
+ export declare function is_vendor_prefixed(text: string): boolean;
24
+ export declare function is_vendor_prefixed(source: string, start: number, end: number): boolean;
25
25
  /** True if the string is a CSS custom property (starts with `--`). */
26
- declare function is_custom(str: string): boolean;
26
+ export declare function is_custom(str: string): boolean;
27
27
  //#endregion
28
- export { ATTRIBUTE_SELECTOR, AT_RULE, AT_RULE_PRELUDE, type AnyNode, type Atrule, type AtrulePrelude, type AttributeSelector, BLOCK, BREAK, type Block, CLASS_SELECTOR, COMBINATOR, COMMENT, CONTAINER_QUERY, type CSSNode, type ClassSelector, type CloneOptions, type Combinator, type Comment, type CommentInfo, type ContainerQuery, DECLARATION, DIMENSION, type Declaration, type Dimension, FEATURE_RANGE, FLAG_IMPORTANT, FUNCTION, type FeatureRange, type Function, HASH, type Hash, IDENTIFIER, ID_SELECTOR, IF_BRANCH, IF_CONDITION, type IdSelector, type Identifier, type IfBranch, type IfCondition, LANG_SELECTOR, LAYER_NAME, type LangSelector, type LayerName, type LexerPosition, MEDIA_FEATURE, MEDIA_QUERY, MEDIA_TYPE, type MediaFeature, type MediaQuery, type MediaType, NESTING_SELECTOR, NODE_TYPES, NTH_OF_SELECTOR, NTH_SELECTOR, NUMBER, type NestingSelector, type NthOfSelector, type NthSelector, type Number, OPERATOR, type Operator, PARENTHESIS, PRELUDE_OPERATOR, PSEUDO_CLASS_SELECTOR, PSEUDO_ELEMENT_SELECTOR, type Parenthesis, type ParserOptions, type PlainCSSNode, type PreludeOperator, type PreludeSelectorList, type PseudoClassSelector, type PseudoElementSelector, RATIO, RAW, type Ratio, type Raw, type Rule, SELECTOR, SELECTOR_LIST, SKIP, STRING, STYLESHEET, STYLE_RULE, SUPPORTS_DECLARATION, SUPPORTS_QUERY, type Selector, type SelectorList, type SelectorNode, type String, type StyleSheet, type SupportsDeclaration, type SupportsQuery, TOKEN_AT_KEYWORD, TOKEN_BAD_STRING, TOKEN_BAD_URL, TOKEN_CDC, TOKEN_CDO, TOKEN_COLON, TOKEN_COMMA, TOKEN_COMMENT, TOKEN_DELIM, TOKEN_DIMENSION, TOKEN_EOF, TOKEN_FUNCTION, TOKEN_HASH, TOKEN_IDENT, TOKEN_LEFT_BRACE, TOKEN_LEFT_BRACKET, TOKEN_LEFT_PAREN, TOKEN_NUMBER, TOKEN_PERCENTAGE, TOKEN_RIGHT_BRACE, TOKEN_RIGHT_BRACKET, TOKEN_RIGHT_PAREN, TOKEN_SEMICOLON, TOKEN_STRING, TOKEN_UNICODE_RANGE, TOKEN_URL, TOKEN_WHITESPACE, TYPE_NAMES, TYPE_SELECTOR, type ToPlain, Token, TokenType, type TypeSelector, UNICODE_RANGE, UNIVERSAL_SELECTOR, URL, type UnicodeRange, type UniversalSelector, type Url, VALUE, type Value, type WithChildren, is_atrule, is_atrule_prelude, is_attribute_selector, is_block, is_class_selector, is_combinator, is_comment, is_container_query, is_custom, is_declaration, is_dimension, is_feature_range, is_function, is_hash, is_id_selector, is_identifier, is_if_branch, is_if_condition, is_lang_selector, is_layer_name, is_media_feature, is_media_query, is_media_type, is_nesting_selector, is_nth_of_selector, is_nth_selector, is_number, is_operator, is_parenthesis, is_prelude_operator, is_prelude_selectorlist, is_pseudo_class_selector, is_pseudo_element_selector, is_ratio, is_raw, is_rule, is_selector, is_selector_list, is_string, is_stylesheet, is_supports_declaration, is_supports_query, is_type_selector, is_unicode_range, is_universal_selector, is_url, is_value, is_vendor_prefixed, parse, parse_atrule_prelude, parse_declaration, parse_dimension, parse_selector, parse_selector_list, parse_value, str_equals, str_index_of, str_starts_with, tokenize, traverse, walk };
28
+ export { ATTRIBUTE_SELECTOR, AT_RULE, AT_RULE_PRELUDE, type AnyNode, type Atrule, type AtrulePrelude, type AttributeSelector, BLOCK, BREAK, type Block, CLASS_SELECTOR, COMBINATOR, COMMENT, CONTAINER_QUERY, type CSSNode, type ClassSelector, type CloneOptions, type Combinator, type Comment, type CommentInfo, type ContainerQuery, DECLARATION, DIMENSION, type Declaration, type Dimension, FEATURE_RANGE, FLAG_IMPORTANT, FUNCTION, type FeatureRange, type Function, HASH, type Hash, IDENTIFIER, ID_SELECTOR, IF_BRANCH, IF_CONDITION, type IdSelector, type Identifier, type IfBranch, type IfCondition, LANG_SELECTOR, LAYER_NAME, type LangSelector, type LayerName, type LexerPosition, MEDIA_FEATURE, MEDIA_QUERY, MEDIA_TYPE, type MediaFeature, type MediaQuery, type MediaType, NESTING_SELECTOR, NODE_TYPES, NTH_OF_SELECTOR, NTH_SELECTOR, NUMBER, type NestingSelector, type NthOfSelector, type NthSelector, type Number, OPERATOR, type Operator, PARENTHESIS, PRELUDE_OPERATOR, PSEUDO_CLASS_SELECTOR, PSEUDO_ELEMENT_SELECTOR, type Parenthesis, type ParserOptions, type PlainCSSNode, type PreludeOperator, type PreludeSelectorList, type PseudoClassSelector, type PseudoElementSelector, RATIO, RAW, type Ratio, type Raw, type Rule, SELECTOR, SELECTOR_LIST, SKIP, STRING, STYLESHEET, STYLE_RULE, SUPPORTS_DECLARATION, SUPPORTS_QUERY, type Selector, type SelectorList, type SelectorNode, type String, type StyleSheet, type SupportsDeclaration, type SupportsQuery, TOKEN_AT_KEYWORD, TOKEN_BAD_STRING, TOKEN_BAD_URL, TOKEN_CDC, TOKEN_CDO, TOKEN_COLON, TOKEN_COMMA, TOKEN_COMMENT, TOKEN_DELIM, TOKEN_DIMENSION, TOKEN_EOF, TOKEN_FUNCTION, TOKEN_HASH, TOKEN_IDENT, TOKEN_LEFT_BRACE, TOKEN_LEFT_BRACKET, TOKEN_LEFT_PAREN, TOKEN_NUMBER, TOKEN_PERCENTAGE, TOKEN_RIGHT_BRACE, TOKEN_RIGHT_BRACKET, TOKEN_RIGHT_PAREN, TOKEN_SEMICOLON, TOKEN_STRING, TOKEN_UNICODE_RANGE, TOKEN_URL, TOKEN_WHITESPACE, TYPE_NAMES, TYPE_SELECTOR, type ToPlain, Token, TokenType, type TypeSelector, UNICODE_RANGE, UNIVERSAL_SELECTOR, URL, type UnicodeRange, type UniversalSelector, type Url, VALUE, type Value, type WithChildren, is_atrule, is_atrule_prelude, is_attribute_selector, is_block, is_class_selector, is_combinator, is_comment, is_container_query, is_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, parse, parse_atrule_prelude, parse_declaration, parse_dimension, parse_selector, parse_selector_list, parse_value, tokenize, traverse, walk };
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
- import { C as TOKEN_RIGHT_BRACKET, D as TOKEN_UNICODE_RANGE, E as TOKEN_STRING, O as TOKEN_URL, S as TOKEN_RIGHT_BRACE, T as TOKEN_SEMICOLON, _ as TOKEN_LEFT_BRACE, a as TOKEN_BAD_URL, b as TOKEN_NUMBER, c as TOKEN_COLON, d as TOKEN_DELIM, f as TOKEN_DIMENSION, g as TOKEN_IDENT, h as TOKEN_HASH, i as TOKEN_BAD_STRING, k as TOKEN_WHITESPACE, l as TOKEN_COMMA, m as TOKEN_FUNCTION, n as tokenize, o as TOKEN_CDC, p as TOKEN_EOF, r as TOKEN_AT_KEYWORD, s as TOKEN_CDO, u as TOKEN_COMMENT, v as TOKEN_LEFT_BRACKET, w as TOKEN_RIGHT_PAREN, x as TOKEN_PERCENTAGE, y as TOKEN_LEFT_PAREN } from "./tokenize-DK24ACbY.js";
1
+ import { C as TOKEN_RIGHT_BRACKET, D as TOKEN_UNICODE_RANGE, E as TOKEN_STRING, O as TOKEN_URL, S as TOKEN_RIGHT_BRACE, T as TOKEN_SEMICOLON, _ as TOKEN_LEFT_BRACE, a as TOKEN_BAD_URL, b as TOKEN_NUMBER, c as TOKEN_COLON, d as TOKEN_DELIM, f as TOKEN_DIMENSION, g as TOKEN_IDENT, h as TOKEN_HASH, i as TOKEN_BAD_STRING, k as TOKEN_WHITESPACE, l as TOKEN_COMMA, m as TOKEN_FUNCTION, n as tokenize, o as TOKEN_CDC, p as TOKEN_EOF, r as TOKEN_AT_KEYWORD, s as TOKEN_CDO, u as TOKEN_COMMENT, v as TOKEN_LEFT_BRACKET, w as TOKEN_RIGHT_PAREN, x as TOKEN_PERCENTAGE, y as TOKEN_LEFT_PAREN } from "./tokenize-BYl6GvyV.js";
2
2
  import { A as PARENTHESIS, B as STYLE_RULE, C as MEDIA_QUERY, D as NTH_SELECTOR, E as NTH_OF_SELECTOR, F as RAW, G as UNIVERSAL_SELECTOR, H as SUPPORTS_QUERY, I as SELECTOR, K as URL, L as SELECTOR_LIST, M as PSEUDO_CLASS_SELECTOR, N as PSEUDO_ELEMENT_SELECTOR, O as NUMBER, P as RATIO, R as STRING, S as MEDIA_FEATURE, T as NESTING_SELECTOR, U as TYPE_SELECTOR, V as SUPPORTS_DECLARATION, W as UNICODE_RANGE, _ as ID_SELECTOR, a as CLASS_SELECTOR, b as LANG_SELECTOR, c as CONTAINER_QUERY, d as DIMENSION, f as FEATURE_RANGE, g as IDENTIFIER, h as HASH, i as BLOCK, j as PRELUDE_OPERATOR, k as OPERATOR, m as FUNCTION, n as AT_RULE, o as COMBINATOR, p as FLAG_IMPORTANT, q as VALUE, r as AT_RULE_PRELUDE, s as COMMENT, t as ATTRIBUTE_SELECTOR, u as DECLARATION, v as IF_BRANCH, w as MEDIA_TYPE, x as LAYER_NAME, y as IF_CONDITION, z as STYLESHEET } from "./arena-e9O_g2AN.js";
3
3
  import { a as is_vendor_prefixed, i as is_custom, l as str_index_of, n as parse_dimension, s as str_equals, u as str_starts_with } from "./parse-dimension-CQELWb5z.js";
4
- import { n as TYPE_NAMES } from "./css-node-C6TLE3qd.js";
5
- import { n as parse_selector, r as parse_selector_list } from "./parse-selector-Ce5HUZJ5.js";
4
+ import { n as TYPE_NAMES } from "./css-node-CH5HqF0J.js";
5
+ import { n as parse_selector, r as parse_selector_list } from "./parse-selector-PhqFezCi.js";
6
6
  import { parse_atrule_prelude } from "./parse-atrule-prelude.js";
7
7
  import { parse_value } from "./parse-value.js";
8
8
  import { parse_declaration } from "./parse-declaration.js";
@@ -2,7 +2,7 @@ import { l as CSSDataArena } from "./arena-BGvFdbj5.js";
2
2
  import { D as NthSelector } from "./node-types-YnOKcNfU.js";
3
3
  //#region src/parse-anplusb.d.ts
4
4
  /** @internal */
5
- declare class ANplusBParser {
5
+ export declare class ANplusBParser {
6
6
  private lexer;
7
7
  private arena;
8
8
  private source;
@@ -21,6 +21,5 @@ declare class ANplusBParser {
21
21
  private skip_whitespace;
22
22
  private create_anplusb_node;
23
23
  }
24
- declare function parse_anplusb(expr: string): NthSelector | null;
25
- //#endregion
26
- export { ANplusBParser, parse_anplusb };
24
+ export declare function parse_anplusb(expr: string): NthSelector | null;
25
+ //#endregion
@@ -1,7 +1,7 @@
1
- import { t as Lexer } from "./tokenize-DK24ACbY.js";
1
+ import { t as Lexer } from "./tokenize-BYl6GvyV.js";
2
2
  import { l as CSSDataArena } from "./arena-e9O_g2AN.js";
3
3
  import { l as str_index_of, s as str_equals } from "./parse-dimension-CQELWb5z.js";
4
- import { t as CSSNode } from "./css-node-C6TLE3qd.js";
4
+ import { t as CSSNode } from "./css-node-CH5HqF0J.js";
5
5
  //#region src/parse-anplusb.ts
6
6
  /** @internal */
7
7
  var ANplusBParser = class {
@@ -2,7 +2,7 @@ import { l as CSSDataArena } from "./arena-BGvFdbj5.js";
2
2
  import { t as AnyNode } from "./node-types-YnOKcNfU.js";
3
3
  //#region src/parse-atrule-prelude.d.ts
4
4
  /** @internal */
5
- declare class AtRulePreludeParser {
5
+ export declare class AtRulePreludeParser {
6
6
  private lexer;
7
7
  private arena;
8
8
  private source;
@@ -40,6 +40,5 @@ declare class AtRulePreludeParser {
40
40
  * @param prelude - The at-rule prelude to parse (e.g., "(min-width: 768px)", "utilities")
41
41
  * @returns An array of CSSNode objects representing the parsed prelude
42
42
  */
43
- declare function parse_atrule_prelude(at_rule_name: string, prelude: string): AnyNode[];
44
- //#endregion
45
- export { AtRulePreludeParser, parse_atrule_prelude };
43
+ export declare function parse_atrule_prelude(at_rule_name: string, prelude: string): AnyNode[];
44
+ //#endregion
@@ -1,9 +1,9 @@
1
- import { t as Lexer } from "./tokenize-DK24ACbY.js";
1
+ import { t as Lexer } from "./tokenize-BYl6GvyV.js";
2
2
  import { l as CSSDataArena } from "./arena-e9O_g2AN.js";
3
3
  import { d as strip_vendor_prefix, s as str_equals } from "./parse-dimension-CQELWb5z.js";
4
- import { t as CSSNode } from "./css-node-C6TLE3qd.js";
5
- import { s as trim_boundaries } from "./parse-selector-Ce5HUZJ5.js";
6
- import { n as ConditionParser, t as ValueNodeParser } from "./value-node-parser-DfkneBdM.js";
4
+ import { t as CSSNode } from "./css-node-CH5HqF0J.js";
5
+ import { s as trim_boundaries } from "./parse-selector-PhqFezCi.js";
6
+ import { n as ConditionParser, t as ValueNodeParser } from "./value-node-parser-tjY982sG.js";
7
7
  //#region src/parse-atrule-prelude.ts
8
8
  /** @internal */
9
9
  var AtRulePreludeParser = class {
@@ -3,7 +3,7 @@ import { n as Lexer } from "./tokenize-CDEnYcVG.js";
3
3
  import { d as Declaration } from "./node-types-YnOKcNfU.js";
4
4
  //#region src/parse-declaration.d.ts
5
5
  /** @internal */
6
- declare class DeclarationParser {
6
+ export declare class DeclarationParser {
7
7
  private arena;
8
8
  private source;
9
9
  private value_parser;
@@ -16,6 +16,5 @@ declare class DeclarationParser {
16
16
  * @param source - The CSS declaration to parse (e.g., "color: red", "margin: 10px !important")
17
17
  * @returns The DECLARATION CSSNode
18
18
  */
19
- declare function parse_declaration(source: string): Declaration;
20
- //#endregion
21
- export { DeclarationParser, parse_declaration };
19
+ export declare function parse_declaration(source: string): Declaration;
20
+ //#endregion
@@ -1,8 +1,8 @@
1
- import { t as Lexer } from "./tokenize-DK24ACbY.js";
1
+ import { t as Lexer } from "./tokenize-BYl6GvyV.js";
2
2
  import { l as CSSDataArena } from "./arena-e9O_g2AN.js";
3
3
  import { a as is_vendor_prefixed } from "./parse-dimension-CQELWb5z.js";
4
- import { t as CSSNode } from "./css-node-C6TLE3qd.js";
5
- import { a as skip_whitespace_and_comments_backward, s as trim_boundaries } from "./parse-selector-Ce5HUZJ5.js";
4
+ import { t as CSSNode } from "./css-node-CH5HqF0J.js";
5
+ import { a as skip_whitespace_and_comments_backward, s as trim_boundaries } from "./parse-selector-PhqFezCi.js";
6
6
  import { ValueParser } from "./parse-value.js";
7
7
  //#region src/parse-declaration.ts
8
8
  /** @internal */
@@ -6,11 +6,10 @@
6
6
  * substrings for both.
7
7
  * @internal
8
8
  */
9
- declare function dimension_number_end(text: string): number;
9
+ export declare function dimension_number_end(text: string): number;
10
10
  /** Parse a dimension string into value and unit, e.g. "100px" → { value: 100, unit: "px" } or "2%" → { value: 2, unit: "%" } */
11
- declare function parse_dimension(text: string): {
11
+ export declare function parse_dimension(text: string): {
12
12
  value: number;
13
13
  unit: string;
14
14
  };
15
- //#endregion
16
- export { dimension_number_end, parse_dimension };
15
+ //#endregion
@@ -1,7 +1,7 @@
1
- import { t as Lexer } from "./tokenize-DK24ACbY.js";
1
+ import { t as Lexer } from "./tokenize-BYl6GvyV.js";
2
2
  import { l as CSSDataArena } from "./arena-e9O_g2AN.js";
3
3
  import { c as str_equals_range, o as is_whitespace, r as is_combinator } from "./parse-dimension-CQELWb5z.js";
4
- import { t as CSSNode } from "./css-node-C6TLE3qd.js";
4
+ import { t as CSSNode } from "./css-node-CH5HqF0J.js";
5
5
  import { ANplusBParser } from "./parse-anplusb.js";
6
6
  //#region src/parse-utils.ts
7
7
  /** @internal */
@@ -424,18 +424,20 @@ var SelectorParser = class {
424
424
  this.arena.set_content_start_delta(node, func_name_start - start);
425
425
  this.arena.set_content_length(node, func_name_end - func_name_start);
426
426
  this.arena.set_flag(node, 64);
427
- if (content_end > content_start) if (this.is_nth_pseudo(func_name_start, func_name_end)) {
428
- let child = this.parse_nth_expression(content_start, content_end);
429
- if (child !== null) this.arena.set_first_child(node, child);
430
- } else if (str_equals_range(this.source, func_name_start, func_name_end, "lang")) this.parse_lang_identifiers(content_start, content_end, node);
431
- else {
432
- let saved_selector_end = this.selector_end;
433
- const saved = this.lexer.save_position();
434
- let allow_relative = str_equals_range(this.source, func_name_start, func_name_end, "has");
435
- let child_selector = this.parse_selector(content_start, content_end, this.lexer.line, this.lexer.column, allow_relative);
436
- this.selector_end = saved_selector_end;
437
- this.lexer.restore_position(saved);
438
- if (child_selector !== null) this.arena.set_first_child(node, child_selector);
427
+ if (content_end > content_start) {
428
+ if (this.is_nth_pseudo(func_name_start, func_name_end)) {
429
+ let child = this.parse_nth_expression(content_start, content_end);
430
+ if (child !== null) this.arena.set_first_child(node, child);
431
+ } else if (str_equals_range(this.source, func_name_start, func_name_end, "lang")) this.parse_lang_identifiers(content_start, content_end, node);
432
+ else {
433
+ let saved_selector_end = this.selector_end;
434
+ const saved = this.lexer.save_position();
435
+ let allow_relative = str_equals_range(this.source, func_name_start, func_name_end, "has");
436
+ let child_selector = this.parse_selector(content_start, content_end, this.lexer.line, this.lexer.column, allow_relative);
437
+ this.selector_end = saved_selector_end;
438
+ this.lexer.restore_position(saved);
439
+ if (child_selector !== null) this.arena.set_first_child(node, child_selector);
440
+ }
439
441
  }
440
442
  return node;
441
443
  }
@@ -2,7 +2,7 @@ import { l as CSSDataArena } from "./arena-BGvFdbj5.js";
2
2
  import { R as Selector, z as SelectorList } from "./node-types-YnOKcNfU.js";
3
3
  //#region src/parse-selector.d.ts
4
4
  /** @internal */
5
- declare class SelectorParser {
5
+ export declare class SelectorParser {
6
6
  private lexer;
7
7
  private arena;
8
8
  private source;
@@ -32,7 +32,6 @@ declare class SelectorParser {
32
32
  private create_node;
33
33
  private skip_whitespace;
34
34
  }
35
- declare function parse_selector_list(source: string): SelectorList;
36
- declare function parse_selector(source: string): Selector;
37
- //#endregion
38
- export { SelectorParser, parse_selector, parse_selector_list };
35
+ export declare function parse_selector_list(source: string): SelectorList;
36
+ export declare function parse_selector(source: string): Selector;
37
+ //#endregion
@@ -1,2 +1,2 @@
1
- import { n as parse_selector, r as parse_selector_list, t as SelectorParser } from "./parse-selector-Ce5HUZJ5.js";
1
+ import { n as parse_selector, r as parse_selector_list, t as SelectorParser } from "./parse-selector-PhqFezCi.js";
2
2
  export { SelectorParser, parse_selector, parse_selector_list };
@@ -2,7 +2,7 @@ import { l as CSSDataArena } from "./arena-BGvFdbj5.js";
2
2
  import { X as Value } from "./node-types-YnOKcNfU.js";
3
3
  //#region src/parse-value.d.ts
4
4
  /** @internal */
5
- declare class ValueParser {
5
+ export declare class ValueParser {
6
6
  private nodes;
7
7
  private arena;
8
8
  constructor(arena: CSSDataArena, source: string);
@@ -13,6 +13,5 @@ declare class ValueParser {
13
13
  * @param value_string - The CSS value to parse (e.g., "1px solid red")
14
14
  * @returns A CSSNode VALUE wrapper containing the parsed value tokens as children
15
15
  */
16
- declare function parse_value(value_string: string): Value;
17
- //#endregion
18
- export { ValueParser, parse_value };
16
+ export declare function parse_value(value_string: string): Value;
17
+ //#endregion
@@ -1,6 +1,6 @@
1
1
  import { l as CSSDataArena } from "./arena-e9O_g2AN.js";
2
- import { t as CSSNode } from "./css-node-C6TLE3qd.js";
3
- import { t as ValueNodeParser } from "./value-node-parser-DfkneBdM.js";
2
+ import { t as CSSNode } from "./css-node-CH5HqF0J.js";
3
+ import { t as ValueNodeParser } from "./value-node-parser-tjY982sG.js";
4
4
  //#region src/parse-value.ts
5
5
  /** @internal */
6
6
  var ValueParser = class {
package/dist/parse.d.ts CHANGED
@@ -2,14 +2,14 @@ import { l as CSSDataArena } from "./arena-BGvFdbj5.js";
2
2
  import { t as CommentInfo } from "./tokenize-CDEnYcVG.js";
3
3
  import { H as StyleSheet } from "./node-types-YnOKcNfU.js";
4
4
  //#region src/parse.d.ts
5
- interface ParserOptions {
5
+ export interface ParserOptions {
6
6
  parse_values?: boolean;
7
7
  parse_selectors?: boolean;
8
8
  parse_atrule_preludes?: boolean;
9
9
  on_comment?: (info: CommentInfo) => void;
10
10
  }
11
11
  /** @internal */
12
- declare class Parser {
12
+ export declare class Parser {
13
13
  private source;
14
14
  private lexer;
15
15
  private arena;
@@ -40,6 +40,5 @@ declare class Parser {
40
40
  * @param options - Parser options
41
41
  * @returns The root CSSNode of the AST
42
42
  */
43
- declare function parse(source: string, options?: ParserOptions): StyleSheet;
44
- //#endregion
45
- export { Parser, ParserOptions, parse };
43
+ export declare function parse(source: string, options?: ParserOptions): StyleSheet;
44
+ //#endregion
package/dist/parse.js CHANGED
@@ -1,7 +1,7 @@
1
- import { t as Lexer } from "./tokenize-DK24ACbY.js";
1
+ import { t as Lexer } from "./tokenize-BYl6GvyV.js";
2
2
  import { l as CSSDataArena } from "./arena-e9O_g2AN.js";
3
- import { t as CSSNode } from "./css-node-C6TLE3qd.js";
4
- import { a as skip_whitespace_and_comments_backward, s as trim_boundaries, t as SelectorParser } from "./parse-selector-Ce5HUZJ5.js";
3
+ import { t as CSSNode } from "./css-node-CH5HqF0J.js";
4
+ import { a as skip_whitespace_and_comments_backward, s as trim_boundaries, t as SelectorParser } from "./parse-selector-PhqFezCi.js";
5
5
  import { AtRulePreludeParser } from "./parse-atrule-prelude.js";
6
6
  import { DeclarationParser } from "./parse-declaration.js";
7
7
  //#region src/parse.ts
@@ -189,13 +189,15 @@ var Parser = class {
189
189
  }
190
190
  let trimmed = trim_boundaries(this.source, prelude_start, prelude_end);
191
191
  let prelude_wrapper = null;
192
- if (trimmed) if (this.prelude_parser) {
193
- let prelude_nodes = this.prelude_parser.parse_prelude(at_rule_name, trimmed[0], trimmed[1], at_rule_line, at_rule_column);
194
- if (prelude_nodes.length > 0) {
195
- prelude_wrapper = this.arena.create_node(40, trimmed[0], trimmed[1] - trimmed[0], at_rule_line, at_rule_column);
196
- this.arena.append_children(prelude_wrapper, prelude_nodes);
192
+ if (trimmed) {
193
+ if (this.prelude_parser) {
194
+ let prelude_nodes = this.prelude_parser.parse_prelude(at_rule_name, trimmed[0], trimmed[1], at_rule_line, at_rule_column);
195
+ if (prelude_nodes.length > 0) {
196
+ prelude_wrapper = this.arena.create_node(40, trimmed[0], trimmed[1] - trimmed[0], at_rule_line, at_rule_column);
197
+ this.arena.append_children(prelude_wrapper, prelude_nodes);
198
+ } else prelude_wrapper = this.arena.create_node(8, trimmed[0], trimmed[1] - trimmed[0], at_rule_line, at_rule_column);
197
199
  } else prelude_wrapper = this.arena.create_node(8, trimmed[0], trimmed[1] - trimmed[0], at_rule_line, at_rule_column);
198
- } else prelude_wrapper = this.arena.create_node(8, trimmed[0], trimmed[1] - trimmed[0], at_rule_line, at_rule_column);
200
+ }
199
201
  let last_end = this.lexer.token_end;
200
202
  if (this.peek_type() === 23) {
201
203
  let block_start = this.lexer.token_end;
@@ -701,16 +701,7 @@ var Lexer = class {
701
701
  continue;
702
702
  }
703
703
  if (ch === CHAR_FORWARD_SLASH && this.pos + 1 < end && this.source.charCodeAt(this.pos + 1) === CHAR_ASTERISK) {
704
- this.advance();
705
- this.advance();
706
- while (this.pos < end) {
707
- if (this.source.charCodeAt(this.pos) === CHAR_ASTERISK && this.pos + 1 < end && this.source.charCodeAt(this.pos + 1) === CHAR_FORWARD_SLASH) {
708
- this.advance();
709
- this.advance();
710
- break;
711
- }
712
- this.advance();
713
- }
704
+ this._skip_comment();
714
705
  continue;
715
706
  }
716
707
  break;
package/dist/tokenize.js CHANGED
@@ -1,2 +1,2 @@
1
- import { n as tokenize, t as Lexer } from "./tokenize-DK24ACbY.js";
1
+ import { n as tokenize, t as Lexer } from "./tokenize-BYl6GvyV.js";
2
2
  export { Lexer, tokenize };
@@ -1,7 +1,7 @@
1
- import { t as Lexer } from "./tokenize-DK24ACbY.js";
1
+ import { t as Lexer } from "./tokenize-BYl6GvyV.js";
2
2
  import "./arena-e9O_g2AN.js";
3
3
  import { c as str_equals_range, s as str_equals } from "./parse-dimension-CQELWb5z.js";
4
- import { i as find_colon_at_depth_zero, o as skip_whitespace_and_comments_forward, s as trim_boundaries, t as SelectorParser } from "./parse-selector-Ce5HUZJ5.js";
4
+ import { i as find_colon_at_depth_zero, o as skip_whitespace_and_comments_forward, s as trim_boundaries, t as SelectorParser } from "./parse-selector-PhqFezCi.js";
5
5
  //#region src/parse-condition.ts
6
6
  /** @internal */
7
7
  var ConditionParser = class {
package/dist/walk.d.ts CHANGED
@@ -1,14 +1,14 @@
1
1
  import { o as CSSNode, t as AnyNode } from "./node-types-YnOKcNfU.js";
2
2
  //#region src/walk.d.ts
3
- declare const SKIP: unique symbol;
4
- declare const BREAK: unique symbol;
3
+ export declare const SKIP: unique symbol;
4
+ export declare const BREAK: unique symbol;
5
5
  type WalkCallback = (node: AnyNode, depth: number) => void | typeof SKIP | typeof BREAK;
6
6
  /**
7
7
  * Walk the AST depth-first, calling `callback` for each node. Return SKIP to skip
8
8
  * children, BREAK to stop. `depth` tracks rule nesting (STYLE_RULE/AT_RULE only),
9
9
  * not tree depth.
10
10
  */
11
- declare function walk(node: CSSNode, callback: WalkCallback, depth?: number): boolean;
11
+ export declare function walk(node: CSSNode, callback: WalkCallback, depth?: number): boolean;
12
12
  type WalkEnterLeaveCallback = (node: AnyNode) => void | typeof SKIP | typeof BREAK;
13
13
  interface WalkEnterLeaveOptions {
14
14
  enter?: WalkEnterLeaveCallback;
@@ -18,6 +18,5 @@ interface WalkEnterLeaveOptions {
18
18
  * Walk the AST depth-first, calling `enter` before children and `leave` after.
19
19
  * SKIP in enter skips children (leave still runs); BREAK stops (leave doesn't run).
20
20
  */
21
- declare function traverse(node: CSSNode, { enter, leave }?: WalkEnterLeaveOptions): boolean;
22
- //#endregion
23
- export { BREAK, SKIP, traverse, walk };
21
+ export declare function traverse(node: CSSNode, { enter, leave }?: WalkEnterLeaveOptions): boolean;
22
+ //#endregion
package/dist/walk.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./arena-e9O_g2AN.js";
2
- import { t as CSSNode } from "./css-node-C6TLE3qd.js";
2
+ import { t as CSSNode } from "./css-node-CH5HqF0J.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.7",
3
+ "version": "0.18.8",
4
4
  "description": "High-performance CSS lexer and parser, optimized for CSS inspection and analysis",
5
5
  "keywords": [
6
6
  "ast",
@@ -78,21 +78,21 @@
78
78
  "devDependencies": {
79
79
  "@projectwallace/preset-oxlint": "^0.0.11",
80
80
  "@types/node": "^26.1.1",
81
- "@vitest/coverage-v8": "^4.1.9",
81
+ "@vitest/coverage-v8": "^5.0.1",
82
82
  "bootstrap": "^5.3.8",
83
83
  "css-tree": "^3.1.0",
84
84
  "knip": "^6.18.0",
85
- "oxfmt": "^0.60.0",
85
+ "oxfmt": "^0.70.0",
86
86
  "oxlint": "^1.71.0",
87
87
  "pkg-pr-new": "^0.0.88",
88
88
  "postcss": "^8.5.15",
89
89
  "publint": "^0.3.21",
90
90
  "tailwindcss": "^2.2.8",
91
91
  "tinybench": "^6.0.2",
92
- "tsdown": "^0.22.3",
92
+ "tsdown": "^0.23.0",
93
93
  "typescript": "^7.0.2",
94
94
  "vite": "^8.0.16",
95
- "vitest": "^4.1.9"
95
+ "vitest": "^5.0.1"
96
96
  },
97
97
  "engines": {
98
98
  "pnpm": ">=11.0.0"