@projectwallace/css-parser 0.16.2 → 0.18.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.
@@ -84,14 +84,9 @@ declare class CSSDataArena {
84
84
  private grow;
85
85
  create_node(type: number, start_offset: number, length: number, start_line: number, start_column: number): number;
86
86
  append_children(parent_index: number, children: number[]): void;
87
- /**
88
- * Shrink the buffer to exactly the number of live nodes, releasing wasted capacity.
89
- * Call once after parsing is complete. Safe to call multiple times (no-op if already tight).
90
- *
91
- * @see https://doc.rust-lang.org/std/vec/struct.Vec.html#method.shrink_to_fit
92
- * @see https://en.cppreference.com/w/cpp/container/vector/shrink_to_fit
93
- */
87
+ /** Shrink the buffer to the live node count, releasing wasted capacity. Call once after parsing; no-op if already tight. */
94
88
  trim(): void;
89
+ get_last_sibling(node_index: number): number;
95
90
  has_children(node_index: number): boolean;
96
91
  has_next_sibling(node_index: number): boolean;
97
92
  set_flag(node_index: number, flag: number): void;
@@ -178,13 +178,7 @@ var CSSDataArena = class CSSDataArena {
178
178
  this.view.setUint32(offset + 4, children[0], true);
179
179
  for (let i = 0; i < children.length - 1; i++) this.set_next_sibling(children[i], children[i + 1]);
180
180
  }
181
- /**
182
- * Shrink the buffer to exactly the number of live nodes, releasing wasted capacity.
183
- * Call once after parsing is complete. Safe to call multiple times (no-op if already tight).
184
- *
185
- * @see https://doc.rust-lang.org/std/vec/struct.Vec.html#method.shrink_to_fit
186
- * @see https://en.cppreference.com/w/cpp/container/vector/shrink_to_fit
187
- */
181
+ /** Shrink the buffer to the live node count, releasing wasted capacity. Call once after parsing; no-op if already tight. */
188
182
  trim() {
189
183
  if (this.count === this.capacity) return;
190
184
  let byte_count = this.count * BYTES_PER_NODE;
@@ -194,6 +188,15 @@ var CSSDataArena = class CSSDataArena {
194
188
  this.view = new DataView(new_buffer);
195
189
  this.capacity = this.count;
196
190
  }
191
+ get_last_sibling(node_index) {
192
+ let node = node_index;
193
+ let next = this.get_next_sibling(node);
194
+ while (next !== 0) {
195
+ node = next;
196
+ next = this.get_next_sibling(node);
197
+ }
198
+ return node;
199
+ }
197
200
  has_children(node_index) {
198
201
  return this.get_first_child(node_index) !== 0;
199
202
  }
@@ -1,5 +1,4 @@
1
- import { B as SUPPORTS_QUERY, C as NESTING_SELECTOR, D as OPERATOR, E as NUMBER, F as SELECTOR_LIST, G as VALUE, H as UNICODE_RANGE, I as STRING, L as STYLESHEET, M as PSEUDO_ELEMENT_SELECTOR, N as RAW, O as PARENTHESIS, P as SELECTOR, R as STYLE_RULE, S as MEDIA_TYPE, T as NTH_SELECTOR, U as UNIVERSAL_SELECTOR, V as TYPE_SELECTOR, W as URL, _ as ID_SELECTOR, a as CLASS_SELECTOR, b as MEDIA_FEATURE, c as CONTAINER_QUERY, d as DIMENSION, f as FEATURE_RANGE, g as IDENTIFIER, h as HASH, i as BLOCK, j as PSEUDO_CLASS_SELECTOR, k as PRELUDE_OPERATOR, m as FUNCTION, n as AT_RULE, o as COMBINATOR, p as FLAG_IMPORTANT, r as AT_RULE_PRELUDE, s as COMMENT, t as ATTRIBUTE_SELECTOR, u as DECLARATION, v as LANG_SELECTOR, w as NTH_OF_SELECTOR, x as MEDIA_QUERY, y as LAYER_NAME, z as SUPPORTS_DECLARATION } from "./arena-DfpuGV9Y.js";
2
-
1
+ import { B as SUPPORTS_QUERY, C as NESTING_SELECTOR, D as OPERATOR, E as NUMBER, F as SELECTOR_LIST, G as VALUE, H as UNICODE_RANGE, I as STRING, L as STYLESHEET, M as PSEUDO_ELEMENT_SELECTOR, N as RAW, O as PARENTHESIS, P as SELECTOR, R as STYLE_RULE, S as MEDIA_TYPE, T as NTH_SELECTOR, U as UNIVERSAL_SELECTOR, V as TYPE_SELECTOR, W as URL, _ as ID_SELECTOR, a as CLASS_SELECTOR, b as MEDIA_FEATURE, c as CONTAINER_QUERY, d as DIMENSION, f as FEATURE_RANGE, g as IDENTIFIER, h as HASH, i as BLOCK, j as PSEUDO_CLASS_SELECTOR, k as PRELUDE_OPERATOR, m as FUNCTION, n as AT_RULE, o as COMBINATOR, p as FLAG_IMPORTANT, r as AT_RULE_PRELUDE, s as COMMENT, t as ATTRIBUTE_SELECTOR, u as DECLARATION, v as LANG_SELECTOR, w as NTH_OF_SELECTOR, x as MEDIA_QUERY, y as LAYER_NAME, z as SUPPORTS_DECLARATION } from "./arena-Bx5vp6Sl.js";
3
2
  //#region src/constants.d.ts
4
3
  declare const NODE_TYPES: {
5
4
  readonly STYLESHEET: 1;
package/dist/constants.js CHANGED
@@ -1,4 +1,4 @@
1
- import { A as PSEUDO_CLASS_SELECTOR, B as TYPE_SELECTOR, C as NESTING_SELECTOR, D as OPERATOR, E as NUMBER, F as STRING, H as UNIVERSAL_SELECTOR, I as STYLESHEET, L as STYLE_RULE, M as RAW, N as SELECTOR, O as PARENTHESIS, P as SELECTOR_LIST, R as SUPPORTS_DECLARATION, S as MEDIA_TYPE, T as NTH_SELECTOR, U as URL, V as UNICODE_RANGE, W as VALUE, _ as ID_SELECTOR, a as CLASS_SELECTOR, b as MEDIA_FEATURE, c as CONTAINER_QUERY, d as DIMENSION, f as FEATURE_RANGE, g as IDENTIFIER, h as HASH, i as BLOCK, j as PSEUDO_ELEMENT_SELECTOR, k as PRELUDE_OPERATOR, m as FUNCTION, n as AT_RULE, o as COMBINATOR, p as FLAG_IMPORTANT, r as AT_RULE_PRELUDE, s as COMMENT, t as ATTRIBUTE_SELECTOR, u as DECLARATION, v as LANG_SELECTOR, w as NTH_OF_SELECTOR, x as MEDIA_QUERY, y as LAYER_NAME, z as SUPPORTS_QUERY } from "./arena-CCye9VYE.js";
1
+ import { A as PSEUDO_CLASS_SELECTOR, B as TYPE_SELECTOR, C as NESTING_SELECTOR, D as OPERATOR, E as NUMBER, F as STRING, H as UNIVERSAL_SELECTOR, I as STYLESHEET, L as STYLE_RULE, M as RAW, N as SELECTOR, O as PARENTHESIS, P as SELECTOR_LIST, R as SUPPORTS_DECLARATION, S as MEDIA_TYPE, T as NTH_SELECTOR, U as URL, V as UNICODE_RANGE, W as VALUE, _ as ID_SELECTOR, a as CLASS_SELECTOR, b as MEDIA_FEATURE, c as CONTAINER_QUERY, d as DIMENSION, f as FEATURE_RANGE, g as IDENTIFIER, h as HASH, i as BLOCK, j as PSEUDO_ELEMENT_SELECTOR, k as PRELUDE_OPERATOR, m as FUNCTION, n as AT_RULE, o as COMBINATOR, p as FLAG_IMPORTANT, r as AT_RULE_PRELUDE, s as COMMENT, t as ATTRIBUTE_SELECTOR, u as DECLARATION, v as LANG_SELECTOR, w as NTH_OF_SELECTOR, x as MEDIA_QUERY, y as LAYER_NAME, z as SUPPORTS_QUERY } from "./arena-CFwM4uQs.js";
2
2
  //#region src/constants.ts
3
3
  const NODE_TYPES = {
4
4
  STYLESHEET: 1,
@@ -1,5 +1,5 @@
1
- import "./arena-CCye9VYE.js";
2
- import { a as is_whitespace, c as str_starts_with, i as is_vendor_prefixed, t as parse_dimension } from "./parse-dimension-B0AZRxxt.js";
1
+ import "./arena-CFwM4uQs.js";
2
+ import { a as is_whitespace, c as str_starts_with, i as is_vendor_prefixed, t as parse_dimension } from "./parse-dimension-ouWXNHdx.js";
3
3
  //#region src/css-node.ts
4
4
  const TYPE_NAMES = {
5
5
  [1]: "StyleSheet",
@@ -149,13 +149,7 @@ var CSSNode = class CSSNode {
149
149
  if (type === 56 && content === "") return null;
150
150
  return content;
151
151
  }
152
- /**
153
- * Namespace prefix for type and universal selectors.
154
- * - `null` — no namespace qualifier (plain `div` or `*`)
155
- * - `''` — empty namespace (`|div` or `|*`)
156
- * - `'ns'` — named namespace (`ns|div` or `ns|*`)
157
- * - `'*'` — any namespace (`*|div` or `*|*`)
158
- */
152
+ /** Namespace prefix for type/universal selectors: null (none), '' (`|div`), 'ns' (`ns|div`), or '*' (`*|div`). */
159
153
  get namespace() {
160
154
  let { type } = this;
161
155
  if (type !== 21 && type !== 28) return void 0;
@@ -164,21 +158,15 @@ var CSSNode = class CSSNode {
164
158
  let length = this.arena.get_value_length(this.index);
165
159
  return this.source.substring(start, start + length);
166
160
  }
167
- /**
168
- * Alias for name (for declarations: "color" in "color: blue")
169
- * More semantic than `name` for declaration nodes
170
- */
161
+ /** Alias for `name` on declarations ("color" in "color: blue"), more semantic than `name` there. */
171
162
  get property() {
172
163
  let { type } = this;
173
164
  if (type !== 4 && type !== 33) return;
174
165
  return this.get_content();
175
166
  }
176
167
  /**
177
- * Get the value text (for declarations: "1px solid blue" in "border: 1px solid blue")
178
- * For dimension/number nodes: returns the numeric value as a number
179
- * For string nodes: returns the string content without quotes
180
- * For URL nodes with quoted string: returns the string with quotes (consistent with STRING node)
181
- * For URL nodes with unquoted URL: returns the URL content without quotes
168
+ * Declarations: the value text ("1px solid blue"). Dimension/number: the numeric value.
169
+ * String: content without quotes. URL: quoted string keeps quotes, unquoted URL doesn't.
182
170
  */
183
171
  get value() {
184
172
  let { type, text, first_child } = this;
@@ -203,12 +191,7 @@ var CSSNode = class CSSNode {
203
191
  if (length === 0) return null;
204
192
  return this.source.substring(start, start + length);
205
193
  }
206
- /**
207
- * Get the prelude node:
208
- * - For at-rules: AT_RULE_PRELUDE wrapper containing structured prelude children (media queries, layer names, etc.)
209
- * - For style rules: SELECTOR_LIST or SELECTOR node
210
- * Returns null if no prelude exists
211
- */
194
+ /** At-rules: AT_RULE_PRELUDE wrapper (media queries, layer names, …). Style rules: SELECTOR_LIST/SELECTOR. Null if none. */
212
195
  get prelude() {
213
196
  if (this.type === 3) {
214
197
  let first = this.first_child;
@@ -217,11 +200,7 @@ var CSSNode = class CSSNode {
217
200
  }
218
201
  if (this.type === 2) return this.first_child;
219
202
  }
220
- /**
221
- * Get the attribute operator (for attribute selectors: =, ~=, |=, ^=, $=, *=)
222
- * Returns the operator string, or null if no operator is present ([attr] form).
223
- * Derived from source text between the attribute name and value.
224
- */
203
+ /** Attribute selector operator (=, ~=, |=, ^=, $=, *=), or null for the bare `[attr]` form. */
225
204
  get attr_operator() {
226
205
  if (this.type !== 24) return void 0;
227
206
  let content_end = this.arena.get_content_start(this.index) + this.arena.get_content_length(this.index);
@@ -239,11 +218,7 @@ var CSSNode = class CSSNode {
239
218
  if (ch1 === 42 && ch2 === 61) return this.source.substring(pos, pos + 2);
240
219
  return null;
241
220
  }
242
- /**
243
- * Get the attribute flags (for attribute selectors: i, s)
244
- * Returns "i" (case-insensitive), "s" (case-sensitive), or null if no flag is present.
245
- * Derived from source text after the attribute value.
246
- */
221
+ /** Attribute selector flag: "i" (case-insensitive), "s" (case-sensitive), or null if absent. */
247
222
  get attr_flags() {
248
223
  if (this.type !== 24) return void 0;
249
224
  let value_len = this.arena.get_value_length(this.index);
@@ -375,11 +350,7 @@ var CSSNode = class CSSNode {
375
350
  get has_next() {
376
351
  return this.arena.get_next_sibling(this.index) !== 0;
377
352
  }
378
- /**
379
- * Check if this node has children
380
- * For pseudo-class/pseudo-element functions, returns true if FLAG_HAS_PARENS is set
381
- * This allows formatters to distinguish :lang() from :hover
382
- */
353
+ /** Whether this node has children. For pseudo-class/element functions, tracks FLAG_HAS_PARENS so formatters can tell `:lang()` from `:hover`. */
383
354
  get has_children() {
384
355
  let { type } = this;
385
356
  if (type === 25 || type === 26) {
@@ -456,13 +427,8 @@ var CSSNode = class CSSNode {
456
427
  return this.first_child?.next_sibling ?? void 0;
457
428
  }
458
429
  /**
459
- * Clone this node as a mutable plain JavaScript object with children as arrays.
460
- * See API.md for examples.
461
- * Warning: this should be used sparingly because it potentially consumes a lot of memory.
462
- *
463
- * @param options - Cloning configuration
464
- * @param options.deep - Recursively clone children (default: true)
465
- * @param options.locations - Include line/column/start/length (default: false)
430
+ * Clone this node as a mutable plain object with children as arrays.
431
+ * Use sparingly — can consume a lot of memory.
466
432
  */
467
433
  clone(options = {}) {
468
434
  const { deep = true, locations = false } = options;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { B as SUPPORTS_QUERY, C as NESTING_SELECTOR, D as OPERATOR, E as NUMBER, F as SELECTOR_LIST, G as VALUE, H as UNICODE_RANGE, I as STRING, L as STYLESHEET, M as PSEUDO_ELEMENT_SELECTOR, N as RAW, O as PARENTHESIS, P as SELECTOR, R as STYLE_RULE, S as MEDIA_TYPE, T as NTH_SELECTOR, U as UNIVERSAL_SELECTOR, V as TYPE_SELECTOR, W as URL, _ as ID_SELECTOR, a as CLASS_SELECTOR, b as MEDIA_FEATURE, c as CONTAINER_QUERY, d as DIMENSION, f as FEATURE_RANGE, g as IDENTIFIER, h as HASH, i as BLOCK, j as PSEUDO_CLASS_SELECTOR, k as PRELUDE_OPERATOR, m as FUNCTION, n as AT_RULE, o as COMBINATOR, p as FLAG_IMPORTANT, r as AT_RULE_PRELUDE, s as COMMENT, t as ATTRIBUTE_SELECTOR, u as DECLARATION, v as LANG_SELECTOR, w as NTH_OF_SELECTOR, x as MEDIA_QUERY, y as LAYER_NAME, z as SUPPORTS_DECLARATION } from "./arena-DfpuGV9Y.js";
1
+ import { B as SUPPORTS_QUERY, C as NESTING_SELECTOR, D as OPERATOR, E as NUMBER, F as SELECTOR_LIST, G as VALUE, H as UNICODE_RANGE, I as STRING, L as STYLESHEET, M as PSEUDO_ELEMENT_SELECTOR, N as RAW, O as PARENTHESIS, P as SELECTOR, R as STYLE_RULE, S as MEDIA_TYPE, T as NTH_SELECTOR, U as UNIVERSAL_SELECTOR, V as TYPE_SELECTOR, W as URL, _ as ID_SELECTOR, a as CLASS_SELECTOR, b as MEDIA_FEATURE, c as CONTAINER_QUERY, d as DIMENSION, f as FEATURE_RANGE, g as IDENTIFIER, h as HASH, i as BLOCK, j as PSEUDO_CLASS_SELECTOR, k as PRELUDE_OPERATOR, m as FUNCTION, n as AT_RULE, o as COMBINATOR, p as FLAG_IMPORTANT, r as AT_RULE_PRELUDE, s as COMMENT, t as ATTRIBUTE_SELECTOR, u as DECLARATION, v as LANG_SELECTOR, w as NTH_OF_SELECTOR, x as MEDIA_QUERY, y as LAYER_NAME, z as SUPPORTS_DECLARATION } from "./arena-Bx5vp6Sl.js";
2
2
  import { NODE_TYPES } from "./constants.js";
3
3
  import { A as TOKEN_URL, C as TOKEN_PERCENTAGE, D as TOKEN_SEMICOLON, E as TOKEN_RIGHT_PAREN, M as Token, N as TokenType, O as TOKEN_STRING, S as TOKEN_NUMBER, T as TOKEN_RIGHT_BRACKET, _ as TOKEN_HASH, a as TOKEN_AT_KEYWORD, b as TOKEN_LEFT_BRACKET, c as TOKEN_CDC, d as TOKEN_COMMA, f as TOKEN_COMMENT, g as TOKEN_FUNCTION, h as TOKEN_EOF, i as tokenize, j as TOKEN_WHITESPACE, k as TOKEN_UNICODE_RANGE, l as TOKEN_CDO, m as TOKEN_DIMENSION, o as TOKEN_BAD_STRING, p as TOKEN_DELIM, r as LexerPosition, s as TOKEN_BAD_URL, t as CommentInfo, u as TOKEN_COLON, v as TOKEN_IDENT, w as TOKEN_RIGHT_BRACE, x as TOKEN_LEFT_PAREN, y as TOKEN_LEFT_BRACE } from "./tokenize-DeZYFa9R.js";
4
- import { $ as is_class_selector, A as PreludeSelectorList, At as is_stylesheet, B as SupportsDeclaration, Bt as TYPE_NAMES, C as NestingSelector, Ct as is_pseudo_class_selector, D as Operator, Dt as is_selector, E as Number, Et as is_rule, F as Selector, Ft as is_universal_selector, G as UniversalSelector, H as ToPlain, I as SelectorList, It as is_url, J as WithChildren, K as Url, L as SelectorNode, Lt as is_value, M as PseudoElementSelector, Mt as is_supports_query, N as Raw, Nt as is_type_selector, O as Parenthesis, Ot as is_selector_list, P as Rule, Pt as is_unicode_range, Q as is_block, R as String, Rt as CloneOptions, S as MediaType, St as is_prelude_selectorlist, T as NthSelector, Tt as is_raw, U as TypeSelector, V as SupportsQuery, W as UnicodeRange, X as is_atrule_prelude, Y as is_atrule, Z as is_attribute_selector, _ as Identifier, _t as is_nth_selector, a as Block, at as is_feature_range, b as MediaFeature, bt as is_parenthesis, c as Combinator, ct as is_id_selector, d as Declaration, dt as is_layer_name, et as is_combinator, f as Dimension, ft as is_media_feature, g as IdSelector, gt as is_nth_of_selector, h as Hash, ht as is_nesting_selector, i as AttributeSelector, it as is_dimension, j as PseudoClassSelector, jt as is_supports_declaration, k as PreludeOperator, kt as is_string, l as Comment, lt as is_identifier, m as Function, mt as is_media_type, n as Atrule, nt as is_container_query, o as CSSNode, ot as is_function, p as FeatureRange, pt as is_media_query, q as Value, r as AtrulePrelude, rt as is_declaration, s as ClassSelector, st as is_hash, t as AnyNode, tt as is_comment, u as ContainerQuery, ut as is_lang_selector, v as LangSelector, vt as is_number, w as NthOfSelector, wt as is_pseudo_element_selector, x as MediaQuery, xt as is_prelude_operator, y as LayerName, yt as is_operator, z as StyleSheet, zt as PlainCSSNode } from "./node-types-BrZu8T2C.js";
4
+ import { $ as is_class_selector, A as PreludeSelectorList, At as is_stylesheet, B as SupportsDeclaration, Bt as TYPE_NAMES, C as NestingSelector, Ct as is_pseudo_class_selector, D as Operator, Dt as is_selector, E as Number, Et as is_rule, F as Selector, Ft as is_universal_selector, G as UniversalSelector, H as ToPlain, I as SelectorList, It as is_url, J as WithChildren, K as Url, L as SelectorNode, Lt as is_value, M as PseudoElementSelector, Mt as is_supports_query, N as Raw, Nt as is_type_selector, O as Parenthesis, Ot as is_selector_list, P as Rule, Pt as is_unicode_range, Q as is_block, R as String, Rt as CloneOptions, S as MediaType, St as is_prelude_selectorlist, T as NthSelector, Tt as is_raw, U as TypeSelector, V as SupportsQuery, W as UnicodeRange, X as is_atrule_prelude, Y as is_atrule, Z as is_attribute_selector, _ as Identifier, _t as is_nth_selector, a as Block, at as is_feature_range, b as MediaFeature, bt as is_parenthesis, c as Combinator, ct as is_id_selector, d as Declaration, dt as is_layer_name, et as is_combinator, f as Dimension, ft as is_media_feature, g as IdSelector, gt as is_nth_of_selector, h as Hash, ht as is_nesting_selector, i as AttributeSelector, it as is_dimension, j as PseudoClassSelector, jt as is_supports_declaration, k as PreludeOperator, kt as is_string, l as Comment, lt as is_identifier, m as Function, mt as is_media_type, n as Atrule, nt as is_container_query, o as CSSNode, ot as is_function, p as FeatureRange, pt as is_media_query, q as Value, r as AtrulePrelude, rt as is_declaration, s as ClassSelector, st as is_hash, t as AnyNode, tt as is_comment, u as ContainerQuery, ut as is_lang_selector, v as LangSelector, vt as is_number, w as NthOfSelector, wt as is_pseudo_element_selector, x as MediaQuery, xt as is_prelude_operator, y as LayerName, yt as is_operator, z as StyleSheet, zt as PlainCSSNode } from "./node-types-BRnQyc9B.js";
5
5
  import { ParserOptions, parse } from "./parse.js";
6
6
  import { parse_selector, parse_selector_list } from "./parse-selector.js";
7
7
  import { parse_atrule_prelude } from "./parse-atrule-prelude.js";
@@ -9,70 +9,20 @@ import { parse_declaration } from "./parse-declaration.js";
9
9
  import { parse_value } from "./parse-value.js";
10
10
  import { parse_dimension } from "./parse-dimension.js";
11
11
  import { BREAK, SKIP, traverse, walk } from "./walk.js";
12
-
13
12
  //#region src/string-utils.d.ts
14
13
  /**
15
14
  * @param a Base string, MUST be lowercase!
16
15
  * @param b Compare string
17
16
  */
18
17
  declare function str_equals(a: string, b: string): boolean;
19
- /**
20
- * Case-insensitive ASCII prefix check without allocations
21
- * Returns true if string `str` starts with prefix (case-insensitive)
22
- *
23
- * IMPORTANT: prefix MUST be lowercase for correct comparison
24
- *
25
- * @param str - The string to check
26
- * @param prefix - The lowercase prefix to match against
27
- */
18
+ /** Case-insensitive ASCII prefix check without allocations. `prefix` MUST be lowercase. */
28
19
  declare function str_starts_with(str: string, prefix: string): boolean;
29
- /**
30
- * Case-insensitive character/substring search without allocations
31
- * Returns the index of the first occurrence of searchChar (case-insensitive)
32
- *
33
- * IMPORTANT: searchChar MUST be lowercase for correct comparison
34
- *
35
- * @param str - The string to search in
36
- * @param searchChar - The lowercase character/substring to find
37
- * @returns The index of the first match, or -1 if not found
38
- */
20
+ /** Case-insensitive substring search without allocations, or -1 if not found. `searchChar` MUST be lowercase. */
39
21
  declare function str_index_of(str: string, searchChar: string): number;
40
- /**
41
- * Check if a string range has a vendor prefix
42
- *
43
- * @param source - The source string
44
- * @param start - Start offset in source
45
- * @param end - End offset in source
46
- * @returns true if the range starts with a vendor prefix (-webkit-, -moz-, -ms-, -o-)
47
- *
48
- * Detects vendor prefixes by checking:
49
- * 1. Starts with a single hyphen (not --)
50
- * 2. Contains at least 3 characters (shortest is -o-)
51
- * 3. Has a second hyphen after the vendor name
52
- *
53
- * Examples:
54
- * - `-webkit-transform` → true
55
- * - `-moz-appearance` → true
56
- * - `-ms-filter` → true
57
- * - `-o-border-image` → true
58
- * - `--custom-property` → false (CSS custom property)
59
- * - `border-radius` → false (doesn't start with hyphen)
60
- */
22
+ /** True if the string/range is vendor-prefixed (-webkit-, -moz-, -ms-, -o-). `--custom-property` is not. */
61
23
  declare function is_vendor_prefixed(text: string): boolean;
62
24
  declare function is_vendor_prefixed(source: string, start: number, end: number): boolean;
63
- /**
64
- * Check if a string is a CSS custom property (starts with --)
65
- *
66
- * @param str - The string to check
67
- * @returns true if the string starts with -- (custom property)
68
- *
69
- * Examples:
70
- * - `--primary-color` → true
71
- * - `--my-var` → true
72
- * - `-webkit-transform` → false (vendor prefix, not custom)
73
- * - `border-radius` → false (standard property)
74
- * - `color` → false
75
- */
25
+ /** True if the string is a CSS custom property (starts with `--`). */
76
26
  declare function is_custom(str: string): boolean;
77
27
  //#endregion
78
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, type IdSelector, type Identifier, 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, RAW, 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_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_raw, is_rule, is_selector, is_selector_list, is_string, is_stylesheet, is_supports_declaration, is_supports_query, is_type_selector, is_unicode_range, is_universal_selector, is_url, is_value, is_vendor_prefixed, parse, parse_atrule_prelude, parse_declaration, parse_dimension, parse_selector, parse_selector_list, parse_value, str_equals, str_index_of, str_starts_with, tokenize, traverse, walk };
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { C as TOKEN_RIGHT_BRACKET, D as TOKEN_UNICODE_RANGE, E as TOKEN_STRING, O as TOKEN_URL, S as TOKEN_RIGHT_BRACE, T as TOKEN_SEMICOLON, _ as TOKEN_LEFT_BRACE, a as TOKEN_BAD_URL, b as TOKEN_NUMBER, c as TOKEN_COLON, d as TOKEN_DELIM, f as TOKEN_DIMENSION, g as TOKEN_IDENT, h as TOKEN_HASH, i as TOKEN_BAD_STRING, k as TOKEN_WHITESPACE, l as TOKEN_COMMA, m as TOKEN_FUNCTION, n as tokenize, o as TOKEN_CDC, p as TOKEN_EOF, r as TOKEN_AT_KEYWORD, s as TOKEN_CDO, u as TOKEN_COMMENT, v as TOKEN_LEFT_BRACKET, w as TOKEN_RIGHT_PAREN, x as TOKEN_PERCENTAGE, y as TOKEN_LEFT_PAREN } from "./tokenize-BiRLfVbm.js";
2
- import { A as PSEUDO_CLASS_SELECTOR, B as TYPE_SELECTOR, C as NESTING_SELECTOR, D as OPERATOR, E as NUMBER, F as STRING, H as UNIVERSAL_SELECTOR, I as STYLESHEET, L as STYLE_RULE, M as RAW, N as SELECTOR, O as PARENTHESIS, P as SELECTOR_LIST, R as SUPPORTS_DECLARATION, S as MEDIA_TYPE, T as NTH_SELECTOR, U as URL, V as UNICODE_RANGE, W as VALUE, _ as ID_SELECTOR, a as CLASS_SELECTOR, b as MEDIA_FEATURE, c as CONTAINER_QUERY, d as DIMENSION, f as FEATURE_RANGE, g as IDENTIFIER, h as HASH, i as BLOCK, j as PSEUDO_ELEMENT_SELECTOR, k as PRELUDE_OPERATOR, m as FUNCTION, n as AT_RULE, o as COMBINATOR, p as FLAG_IMPORTANT, r as AT_RULE_PRELUDE, s as COMMENT, t as ATTRIBUTE_SELECTOR, u as DECLARATION, v as LANG_SELECTOR, w as NTH_OF_SELECTOR, x as MEDIA_QUERY, y as LAYER_NAME, z as SUPPORTS_QUERY } from "./arena-CCye9VYE.js";
3
- import { c as str_starts_with, i as is_vendor_prefixed, o as str_equals, r as is_custom, s as str_index_of, t as parse_dimension } from "./parse-dimension-B0AZRxxt.js";
4
- import { n as TYPE_NAMES } from "./css-node-TR2T5Q7D.js";
2
+ import { A as PSEUDO_CLASS_SELECTOR, B as TYPE_SELECTOR, C as NESTING_SELECTOR, D as OPERATOR, E as NUMBER, F as STRING, H as UNIVERSAL_SELECTOR, I as STYLESHEET, L as STYLE_RULE, M as RAW, N as SELECTOR, O as PARENTHESIS, P as SELECTOR_LIST, R as SUPPORTS_DECLARATION, S as MEDIA_TYPE, T as NTH_SELECTOR, U as URL, V as UNICODE_RANGE, W as VALUE, _ as ID_SELECTOR, a as CLASS_SELECTOR, b as MEDIA_FEATURE, c as CONTAINER_QUERY, d as DIMENSION, f as FEATURE_RANGE, g as IDENTIFIER, h as HASH, i as BLOCK, j as PSEUDO_ELEMENT_SELECTOR, k as PRELUDE_OPERATOR, m as FUNCTION, n as AT_RULE, o as COMBINATOR, p as FLAG_IMPORTANT, r as AT_RULE_PRELUDE, s as COMMENT, t as ATTRIBUTE_SELECTOR, u as DECLARATION, v as LANG_SELECTOR, w as NTH_OF_SELECTOR, x as MEDIA_QUERY, y as LAYER_NAME, z as SUPPORTS_QUERY } from "./arena-CFwM4uQs.js";
3
+ import { c as str_starts_with, i as is_vendor_prefixed, o as str_equals, r as is_custom, s as str_index_of, t as parse_dimension } from "./parse-dimension-ouWXNHdx.js";
4
+ import { n as TYPE_NAMES } from "./css-node-B3EzCweR.js";
5
5
  import { parse_selector, parse_selector_list } from "./parse-selector.js";
6
6
  import { parse_atrule_prelude } from "./parse-atrule-prelude.js";
7
7
  import { parse_value } from "./parse-value.js";