@projectwallace/css-parser 0.13.11 → 0.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- import { y as CSSDataArena } from "./arena-BtlVZlkG.js";
2
- import { r as CSSNode } from "./css-node-CudZ-lzp.js";
1
+ import { l as CSSDataArena } from "./arena-D6TANE5e.js";
2
+ import { G as Value } from "./node-types-De9R2IIL.js";
3
3
 
4
4
  //#region src/parse-value.d.ts
5
5
  /** @internal */
@@ -24,6 +24,6 @@ declare class ValueParser {
24
24
  * @param value_string - The CSS value to parse (e.g., "1px solid red")
25
25
  * @returns A CSSNode VALUE wrapper containing the parsed value tokens as children
26
26
  */
27
- declare function parse_value(value_string: string): CSSNode;
27
+ declare function parse_value(value_string: string): Value;
28
28
  //#endregion
29
29
  export { ValueParser, parse_value };
@@ -1,7 +1,7 @@
1
1
  import { t as Lexer } from "./tokenize-BSycRGm0.js";
2
- import { y as CSSDataArena } from "./arena-CDAx4eAB.js";
2
+ import { l as CSSDataArena } from "./arena-CveFYH2l.js";
3
3
  import { a as is_whitespace, o as str_equals } from "./parse-dimension-CCn_XRDe.js";
4
- import { r as CSSNode } from "./css-node-BYpol6td.js";
4
+ import { t as CSSNode } from "./css-node-DwKXZuNm.js";
5
5
  //#region src/parse-value.ts
6
6
  /** @internal */
7
7
  var ValueParser = class {
package/dist/parse.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { y as CSSDataArena } from "./arena-BtlVZlkG.js";
1
+ import { l as CSSDataArena } from "./arena-D6TANE5e.js";
2
2
  import { t as CommentInfo } from "./tokenize-CyiJelQC.js";
3
- import { r as CSSNode } from "./css-node-CudZ-lzp.js";
3
+ import { R as StyleSheet } from "./node-types-De9R2IIL.js";
4
4
 
5
5
  //#region src/parse.d.ts
6
6
  interface ParserOptions {
@@ -26,7 +26,7 @@ declare class Parser {
26
26
  private next_token;
27
27
  private peek_type;
28
28
  private is_eof;
29
- parse(): CSSNode;
29
+ parse(): StyleSheet;
30
30
  private parse_rule;
31
31
  private parse_style_rule;
32
32
  private parse_selector;
@@ -40,6 +40,6 @@ 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): CSSNode;
43
+ declare function parse(source: string, options?: ParserOptions): StyleSheet;
44
44
  //#endregion
45
45
  export { Parser, ParserOptions, parse };
package/dist/parse.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { t as Lexer } from "./tokenize-BSycRGm0.js";
2
- import { y as CSSDataArena } from "./arena-CDAx4eAB.js";
3
- import { r as CSSNode } from "./css-node-BYpol6td.js";
2
+ import { l as CSSDataArena } from "./arena-CveFYH2l.js";
3
+ import { t as CSSNode } from "./css-node-DwKXZuNm.js";
4
4
  import { i as trim_boundaries } from "./parse-utils-BxrmqJxI.js";
5
5
  import { SelectorParser } from "./parse-selector.js";
6
6
  import { AtRulePreludeParser } from "./parse-atrule-prelude.js";
package/dist/walk.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { r as CSSNode } from "./css-node-CudZ-lzp.js";
1
+ import { o as CSSNode, t as AnyNode } from "./node-types-De9R2IIL.js";
2
2
 
3
3
  //#region src/walk.d.ts
4
4
  declare const SKIP: unique symbol;
5
5
  declare const BREAK: unique symbol;
6
- type WalkCallback = (node: CSSNode, depth: number) => void | typeof SKIP | typeof BREAK;
6
+ type WalkCallback = (node: AnyNode, depth: number) => void | typeof SKIP | typeof BREAK;
7
7
  /**
8
8
  * Walk the AST in depth-first order, calling the callback for each node.
9
9
  * Return SKIP to skip children, BREAK to stop traversal. See API.md for examples.
@@ -14,7 +14,7 @@ type WalkCallback = (node: CSSNode, depth: number) => void | typeof SKIP | typeo
14
14
  * @param depth - Starting depth (default: 0)
15
15
  */
16
16
  declare function walk(node: CSSNode, callback: WalkCallback, depth?: number): boolean;
17
- type WalkEnterLeaveCallback = (node: CSSNode) => void | typeof SKIP | typeof BREAK;
17
+ type WalkEnterLeaveCallback = (node: AnyNode) => void | typeof SKIP | typeof BREAK;
18
18
  interface WalkEnterLeaveOptions {
19
19
  enter?: WalkEnterLeaveCallback;
20
20
  leave?: WalkEnterLeaveCallback;
package/dist/walk.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./arena-CDAx4eAB.js";
1
+ import "./arena-CveFYH2l.js";
2
2
  import "./constants.js";
3
3
  //#region src/walk.ts
4
4
  const SKIP = Symbol("SKIP");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@projectwallace/css-parser",
3
- "version": "0.13.11",
3
+ "version": "0.14.1",
4
4
  "description": "High-performance CSS lexer and parser, optimized for CSS inspection and analysis",
5
5
  "keywords": [
6
6
  "ast",
@@ -1,213 +0,0 @@
1
- import { A as MEDIA_FEATURE, B as PSEUDO_CLASS_SELECTOR, D as ID_SELECTOR, E as IDENTIFIER, F as NTH_SELECTOR, G as STRING, H as RAW, I as NUMBER, J as SUPPORTS_QUERY, K as STYLESHEET, L as OPERATOR, M as MEDIA_TYPE, N as NESTING_SELECTOR, O as LANG_SELECTOR, P as NTH_OF_SELECTOR, Q as VALUE, R as PARENTHESIS, S as FEATURE_RANGE, T as HASH, U as SELECTOR, V as PSEUDO_ELEMENT_SELECTOR, W as SELECTOR_LIST, X as UNIVERSAL_SELECTOR, Y as TYPE_SELECTOR, Z as URL, _ as COMMENT, b as DECLARATION, f as AT_RULE, g as COMBINATOR, h as CLASS_SELECTOR, j as MEDIA_QUERY, k as LAYER_NAME, m as BLOCK, p as AT_RULE_PRELUDE, q as STYLE_RULE, t as ATTRIBUTE_SELECTOR, v as CONTAINER_QUERY, w as FUNCTION, x as DIMENSION, y as CSSDataArena, z as PRELUDE_OPERATOR } from "./arena-BtlVZlkG.js";
2
-
3
- //#region src/css-node.d.ts
4
- declare const TYPE_NAMES: {
5
- readonly 1: "StyleSheet";
6
- readonly 2: "Rule";
7
- readonly 3: "Atrule";
8
- readonly 4: "Declaration";
9
- readonly 5: "Selector";
10
- readonly 6: "Comment";
11
- readonly 7: "Block";
12
- readonly 8: "Raw";
13
- readonly 10: "Identifier";
14
- readonly 11: "Number";
15
- readonly 12: "Dimension";
16
- readonly 13: "String";
17
- readonly 14: "Hash";
18
- readonly 15: "Function";
19
- readonly 16: "Operator";
20
- readonly 17: "Parentheses";
21
- readonly 18: "Url";
22
- readonly 19: "UnicodeRange";
23
- readonly 50: "Value";
24
- readonly 20: "SelectorList";
25
- readonly 21: "TypeSelector";
26
- readonly 22: "ClassSelector";
27
- readonly 23: "IdSelector";
28
- readonly 24: "AttributeSelector";
29
- readonly 25: "PseudoClassSelector";
30
- readonly 26: "PseudoElementSelector";
31
- readonly 27: "Combinator";
32
- readonly 28: "UniversalSelector";
33
- readonly 29: "NestingSelector";
34
- readonly 30: "Nth";
35
- readonly 31: "NthOf";
36
- readonly 56: "Lang";
37
- readonly 32: "MediaQuery";
38
- readonly 33: "Feature";
39
- readonly 34: "MediaType";
40
- readonly 35: "ContainerQuery";
41
- readonly 36: "SupportsQuery";
42
- readonly 37: "Layer";
43
- readonly 38: "Operator";
44
- readonly 39: "MediaFeatureRange";
45
- readonly 40: "AtrulePrelude";
46
- };
47
- type TypeName = (typeof TYPE_NAMES)[keyof typeof TYPE_NAMES] | 'unknown';
48
- declare const ATTR_OPERATOR_NAMES: Record<number, string | null>;
49
- declare const ATTR_FLAG_NAMES: Record<number, string | null>;
50
- type CSSNodeType = typeof STYLESHEET | typeof STYLE_RULE | typeof AT_RULE | typeof DECLARATION | typeof SELECTOR | typeof COMMENT | typeof BLOCK | typeof RAW | typeof IDENTIFIER | typeof NUMBER | typeof DIMENSION | typeof STRING | typeof HASH | typeof FUNCTION | typeof OPERATOR | typeof PARENTHESIS | typeof URL | typeof VALUE | typeof SELECTOR_LIST | typeof TYPE_SELECTOR | typeof CLASS_SELECTOR | typeof ID_SELECTOR | typeof ATTRIBUTE_SELECTOR | typeof PSEUDO_CLASS_SELECTOR | typeof PSEUDO_ELEMENT_SELECTOR | typeof COMBINATOR | typeof UNIVERSAL_SELECTOR | typeof NESTING_SELECTOR | typeof NTH_SELECTOR | typeof NTH_OF_SELECTOR | typeof LANG_SELECTOR | typeof MEDIA_QUERY | typeof MEDIA_FEATURE | typeof MEDIA_TYPE | typeof CONTAINER_QUERY | typeof SUPPORTS_QUERY | typeof LAYER_NAME | typeof PRELUDE_OPERATOR | typeof FEATURE_RANGE | typeof AT_RULE_PRELUDE;
51
- interface CloneOptions {
52
- /**
53
- * Recursively clone all children
54
- * @default true
55
- */
56
- deep?: boolean;
57
- /**
58
- * Include location information (line, column, start, length)
59
- * @default false
60
- */
61
- locations?: boolean;
62
- }
63
- type PlainCSSNode = {
64
- type: number;
65
- type_name: TypeName;
66
- text: string;
67
- children?: PlainCSSNode[];
68
- name?: string;
69
- property?: string;
70
- value?: PlainCSSNode | string | number | null;
71
- unit?: string;
72
- prelude?: PlainCSSNode | null;
73
- is_important?: boolean;
74
- is_vendor_prefixed?: boolean;
75
- is_browserhack?: boolean;
76
- has_error?: boolean;
77
- attr_operator?: string | null;
78
- attr_flags?: string | null;
79
- nth_a?: string | null;
80
- nth_b?: string | null;
81
- line?: number;
82
- column?: number;
83
- start?: number;
84
- length?: number;
85
- end?: number;
86
- };
87
- declare class CSSNode {
88
- private arena;
89
- private source;
90
- private index;
91
- constructor(arena: CSSDataArena, source: string, index: number);
92
- /**
93
- * @internal
94
- * Get the arena (for internal/advanced use only)
95
- */
96
- __get_arena(): CSSDataArena;
97
- private get_content;
98
- /** Get node type as number (for performance) */
99
- get type(): CSSNodeType;
100
- /** Get node type as human-readable string */
101
- get type_name(): TypeName;
102
- /** Get the full text of this node from source */
103
- get text(): string;
104
- /** Get the "content" text (at-rule name for at-rules, layer name for import layers) */
105
- get name(): string | undefined;
106
- /**
107
- * Alias for name (for declarations: "color" in "color: blue")
108
- * More semantic than `name` for declaration nodes
109
- */
110
- get property(): string | undefined;
111
- /**
112
- * Get the value text (for declarations: "blue" in "color: blue")
113
- * For dimension/number nodes: returns the numeric value as a number
114
- * For string nodes: returns the string content without quotes
115
- * For URL nodes with quoted string: returns the string with quotes (consistent with STRING node)
116
- * For URL nodes with unquoted URL: returns the URL content without quotes
117
- */
118
- get value(): CSSNode | string | number | null | undefined;
119
- /** Get the numeric value for NUMBER and DIMENSION nodes, or null for other node types */
120
- get value_as_number(): number | null;
121
- /**
122
- * Get the prelude node:
123
- * - For at-rules: AT_RULE_PRELUDE wrapper containing structured prelude children (media queries, layer names, etc.)
124
- * - For style rules: SELECTOR_LIST or SELECTOR node
125
- * Returns null if no prelude exists
126
- */
127
- get prelude(): CSSNode | null | undefined;
128
- /**
129
- * Get the attribute operator (for attribute selectors: =, ~=, |=, ^=, $=, *=)
130
- * Returns one of the ATTR_OPERATOR_* constants
131
- */
132
- get attr_operator(): number | undefined;
133
- /**
134
- * Get the attribute flags (for attribute selectors: i, s)
135
- * Returns one of the ATTR_FLAG_* constants
136
- */
137
- get attr_flags(): number | undefined;
138
- /** Get the unit for dimension nodes (e.g., "px" from "100px", "%" from "50%") */
139
- get unit(): string | undefined;
140
- /** Check if this declaration has !important */
141
- get is_important(): boolean | undefined;
142
- /** Check if this declaration has a browser hack prefix */
143
- get is_browserhack(): boolean | undefined;
144
- /** Check if this has a vendor prefix (computed on-demand) */
145
- get is_vendor_prefixed(): boolean;
146
- /** Check if this node has an error */
147
- get has_error(): boolean;
148
- /** Check if this node has a prelude (at-rules and style rules) */
149
- get has_prelude(): boolean;
150
- /** Check if this rule has a block { } */
151
- get has_block(): boolean;
152
- /** Check if this style rule has declarations */
153
- get has_declarations(): boolean;
154
- /** Get the block node (for style rules and at-rules with blocks) */
155
- get block(): CSSNode | null;
156
- /** Check if this block is empty (no declarations or rules, only comments allowed) */
157
- get is_empty(): boolean | undefined;
158
- /** Get start line number */
159
- get line(): number;
160
- /** Get start column number */
161
- get column(): number;
162
- /** Get start offset in source */
163
- get start(): number;
164
- /** Get length in source */
165
- get length(): number;
166
- /**
167
- * Get end offset in source
168
- * End is not stored, must be calculated
169
- */
170
- get end(): number;
171
- /** Get first child node */
172
- get first_child(): CSSNode | null;
173
- /** Get next sibling node */
174
- get next_sibling(): CSSNode | null;
175
- /** Check if this node has a next sibling */
176
- get has_next(): boolean;
177
- /**
178
- * Check if this node has children
179
- * For pseudo-class/pseudo-element functions, returns true if FLAG_HAS_PARENS is set
180
- * This allows formatters to distinguish :lang() from :hover
181
- */
182
- get has_children(): boolean;
183
- /** Count children without allocating an intermediate array */
184
- get child_count(): number;
185
- /** Get all children as an array */
186
- get children(): CSSNode[];
187
- /** Make CSSNode iterable over its children */
188
- [Symbol.iterator](): Iterator<CSSNode>;
189
- /** Get the 'a' coefficient from An+B expression (e.g., "2n" from "2n+1", "odd" from "odd") */
190
- get nth_a(): string | undefined;
191
- /** Get the 'b' coefficient from An+B expression (e.g., "+1" from "2n+1") */
192
- get nth_b(): string | undefined;
193
- /** Get the An+B formula node from :nth-child(2n+1 of .foo) */
194
- get nth(): CSSNode | undefined;
195
- /** Get the selector list from :nth-child(2n+1 of .foo) */
196
- get selector(): CSSNode | undefined;
197
- /**
198
- * Get selector list from pseudo-class functions
199
- * Works for :is(.a), :not(.b), :has(.c), :where(.d), :nth-child(2n of .e)
200
- */
201
- get selector_list(): CSSNode | undefined;
202
- /**
203
- * Clone this node as a mutable plain JavaScript object with children as arrays.
204
- * See API.md for examples.
205
- *
206
- * @param options - Cloning configuration
207
- * @param options.deep - Recursively clone children (default: true)
208
- * @param options.locations - Include line/column/start/length (default: false)
209
- */
210
- clone(options?: CloneOptions): PlainCSSNode;
211
- }
212
- //#endregion
213
- export { CloneOptions as a, CSSNodeType as i, ATTR_OPERATOR_NAMES as n, PlainCSSNode as o, CSSNode as r, TYPE_NAMES as s, ATTR_FLAG_NAMES as t };