@projectwallace/css-parser 0.18.12 → 0.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -107
- package/dist/{arena-DvT75bvK.d.ts → arena-7RLvyGPB.d.ts} +0 -1
- package/dist/{arena-Bsf96CQK.js → arena-CsJhQRUX.js} +0 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/{css-node-yoUdFtNg.js → css-node-BJnbanUS.js} +5 -54
- package/dist/index.d.ts +3 -3
- package/dist/index.js +4 -4
- package/dist/{node-types-CY0JK9_a.d.ts → node-types-BZGPDESt.d.ts} +13 -30
- package/dist/node-types.d.ts +1 -1
- package/dist/node-types.js +1 -1
- package/dist/parse-anplusb.d.ts +2 -10
- package/dist/parse-anplusb.js +9 -17
- package/dist/parse-atrule-prelude.d.ts +3 -2
- package/dist/parse-atrule-prelude.js +68 -33
- package/dist/parse-declaration.d.ts +2 -2
- package/dist/parse-declaration.js +14 -14
- package/dist/parse-dimension.js +1 -1
- package/dist/{parse-selector-CqIpnBrQ.js → parse-selector-B59fV-Ya.js} +14 -14
- package/dist/parse-selector.d.ts +2 -2
- package/dist/parse-selector.js +1 -1
- package/dist/parse-value.d.ts +2 -2
- package/dist/parse-value.js +3 -3
- package/dist/parse.d.ts +2 -2
- package/dist/parse.js +5 -5
- package/dist/{string-helpers-BMWJduts.d.ts → string-helpers-t7UofIfp.d.ts} +5 -7
- package/dist/string-helpers.d.ts +1 -1
- package/dist/string-helpers.js +1 -1
- package/dist/{string-utils-DiRRd28d.js → string-utils-aEEsA2CS.js} +18 -14
- package/dist/{tokenize-Ccg58Z_k.js → tokenize-B2QSzdrM.js} +10 -45
- package/dist/tokenize.d.ts +1 -33
- package/dist/tokenize.js +1 -1
- package/dist/{value-node-parser-BBwBxFR_.js → value-node-parser-BBlVw-en.js} +54 -21
- package/dist/walk.d.ts +1 -1
- package/dist/walk.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ Heavily influenced by [CSSTree](https://github.com/csstree/csstree). Some parsin
|
|
|
14
14
|
- **Full modern CSS** — CSS Nesting, `:is()`, `:where()`, `:has()`, `@layer`, `@container`
|
|
15
15
|
- **Error-tolerant** — keeps parsing through malformed input; one bad rule won't kill the file
|
|
16
16
|
- **Precise source locations** — line, column, offset, and length on every node
|
|
17
|
-
- **Tiny footprint** — tree-shakeable subparsers; as small as 278 bytes gzipped, < 16 kB
|
|
17
|
+
- **Tiny footprint** — tree-shakeable subparsers; as small as 278 bytes gzipped, < 16 kB worst case
|
|
18
18
|
|
|
19
19
|
## Installation
|
|
20
20
|
|
|
@@ -65,34 +65,30 @@ for (const rule of ast) {
|
|
|
65
65
|
|
|
66
66
|
## API
|
|
67
67
|
|
|
68
|
-
Everything is exported from the package root. Each part is also available from its own entry point, so you can import only what you need
|
|
68
|
+
Everything is exported from the package root. Each part is also available from its own entry point, so you can import only what you need. Node properties and return types ship as TypeScript types.
|
|
69
69
|
|
|
70
70
|
### Entry points
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
| `@projectwallace/css-parser/string-utils` | `is_custom`, `is_vendor_prefixed`, `strip_vendor_prefix`, `str_equals`, `str_starts_with`, `str_index_of` |
|
|
87
|
-
| `@projectwallace/css-parser/token-types` | Token type constants (`TOKEN_*`) |
|
|
72
|
+
- `@projectwallace/css-parser` — everything below, except the `Lexer` and `Parser` classes
|
|
73
|
+
- `/parse` — `parse`, `Parser`, `ParserOptions`
|
|
74
|
+
- `/parse-selector` — `parse_selector`, `parse_selector_list`
|
|
75
|
+
- `/parse-atrule-prelude` — `parse_atrule_prelude`
|
|
76
|
+
- `/parse-declaration` — `parse_declaration`
|
|
77
|
+
- `/parse-value` — `parse_value`
|
|
78
|
+
- `/parse-anplusb` — `parse_anplusb`
|
|
79
|
+
- `/parse-dimension` — `parse_dimension`
|
|
80
|
+
- `/tokenizer` — `tokenize`, `Lexer`
|
|
81
|
+
- `/walker` — `walk`, `traverse`, `SKIP`, `BREAK`
|
|
82
|
+
- `/nodes` — node type constants (`STYLE_RULE`, `DECLARATION`, …), `NODE_TYPES`
|
|
83
|
+
- `/node-types` — type guards (`is_declaration`, `is_rule`, …) and node types (`CSSNode`, `Rule`, …)
|
|
84
|
+
- `/string-utils` — `is_custom`, `is_vendor_prefixed`, `strip_vendor_prefix`, `str_equals`, `str_starts_with`, `str_index_of`
|
|
85
|
+
- `/token-types` — token type constants (`TOKEN_*`)
|
|
88
86
|
|
|
89
87
|
### `parse(source, options?)`
|
|
90
88
|
|
|
91
|
-
|
|
89
|
+
Returns the root `StyleSheet` node. Nodes are iterable and expose `first_child`, `next_sibling`, `children`, `text`, `line`, `column`, `start`, `end` and `length`.
|
|
92
90
|
|
|
93
91
|
```typescript
|
|
94
|
-
import { parse } from '@projectwallace/css-parser'
|
|
95
|
-
|
|
96
92
|
const ast = parse('body { color: red; }')
|
|
97
93
|
const rule = ast.first_child
|
|
98
94
|
rule.block.first_child.property // "color"
|
|
@@ -104,72 +100,26 @@ Options:
|
|
|
104
100
|
- `parse_values` (default `true`) — parse declaration values into nodes
|
|
105
101
|
- `parse_selectors` (default `true`) — parse selectors into nodes
|
|
106
102
|
- `parse_atrule_preludes` (default `true`) — parse at-rule preludes into nodes
|
|
107
|
-
- `on_comment` — called for every comment; comments are never part of the tree
|
|
108
|
-
|
|
109
|
-
```typescript
|
|
110
|
-
const comments = []
|
|
111
|
-
parse('/* hi */ a { color: red }', {
|
|
112
|
-
parse_values: false,
|
|
113
|
-
on_comment: (info) => comments.push(info), // { start, end, length, line, column }
|
|
114
|
-
})
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
### `parse_selector(source)` and `parse_selector_list(source)`
|
|
103
|
+
- `on_comment` — called for every comment (`{ start, end, length, line, column }`); comments are never part of the tree
|
|
118
104
|
|
|
119
|
-
|
|
105
|
+
### Sub-parsers
|
|
120
106
|
|
|
121
107
|
```typescript
|
|
122
|
-
import { parse_selector, parse_selector_list } from '@projectwallace/css-parser'
|
|
123
|
-
|
|
124
108
|
parse_selector('a.b > c').children.map((part) => part.text) // ["a", ".b", ">", "c"]
|
|
125
109
|
parse_selector_list('h1, h2').children.map((s) => s.text) // ["h1", "h2"]
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
### `parse_declaration(source)`
|
|
129
|
-
|
|
130
|
-
```typescript
|
|
131
|
-
import { parse_declaration } from '@projectwallace/css-parser'
|
|
132
110
|
|
|
133
111
|
const decl = parse_declaration('color: red !important')
|
|
134
112
|
decl.property // "color"
|
|
135
113
|
decl.is_important // true
|
|
136
|
-
decl.value.text // "red"
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
### `parse_value(source)`
|
|
140
|
-
|
|
141
|
-
Parses a declaration value into a `Value` node with one child per component.
|
|
142
|
-
|
|
143
|
-
```typescript
|
|
144
|
-
import { parse_value } from '@projectwallace/css-parser'
|
|
145
114
|
|
|
146
115
|
for (const node of parse_value('10px 20px')) {
|
|
147
|
-
|
|
116
|
+
node.type_name // "Dimension"
|
|
148
117
|
}
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
### `parse_atrule_prelude(name, prelude)`
|
|
152
|
-
|
|
153
|
-
Returns an array of nodes for the prelude of the at-rule called `name` (without the `@`).
|
|
154
|
-
|
|
155
|
-
```typescript
|
|
156
|
-
import { parse_atrule_prelude } from '@projectwallace/css-parser'
|
|
157
118
|
|
|
158
|
-
const [query] = parse_atrule_prelude('media', '(min-width: 768px)')
|
|
119
|
+
const [query] = parse_atrule_prelude('media', '(min-width: 768px)') // name without the `@`
|
|
159
120
|
query.type_name // "MediaQuery"
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
### `parse_dimension(text)`
|
|
163
|
-
|
|
164
|
-
Splits a number from its unit. It works for anything shaped like a number followed by a unit: lengths (`100px`), percentages (`2%`), durations (`200ms`) and so on. It does not validate; text without a leading number gives `value: 0`.
|
|
165
121
|
|
|
166
|
-
|
|
167
|
-
import { parse_dimension } from '@projectwallace/css-parser'
|
|
168
|
-
|
|
169
|
-
parse_dimension('100px') // { value: 100, unit: "px" }
|
|
170
|
-
parse_dimension('2%') // { value: 2, unit: "%" }
|
|
171
|
-
parse_dimension('1.5e3s') // { value: 1500, unit: "s" }
|
|
172
|
-
parse_dimension('5') // { value: 5, unit: "" }
|
|
122
|
+
parse_dimension('1.5e3s') // { value: 1500, unit: "s" } (no validation; no leading number gives `value: 0`)
|
|
173
123
|
```
|
|
174
124
|
|
|
175
125
|
### `walk(node, callback)` and `traverse(node, { enter, leave })`
|
|
@@ -177,28 +127,13 @@ parse_dimension('5') // { value: 5, unit: "" }
|
|
|
177
127
|
Both walk the tree depth-first. Return `SKIP` to skip the children of a node and `BREAK` to stop entirely. `walk` also passes a `depth` that counts rule and at-rule nesting. `traverse` calls `enter` before and `leave` after the children (`leave` still runs after `SKIP`, but not after `BREAK`).
|
|
178
128
|
|
|
179
129
|
```typescript
|
|
180
|
-
import {
|
|
181
|
-
parse,
|
|
182
|
-
walk,
|
|
183
|
-
traverse,
|
|
184
|
-
SKIP,
|
|
185
|
-
BREAK,
|
|
186
|
-
DECLARATION,
|
|
187
|
-
AT_RULE,
|
|
188
|
-
} from '@projectwallace/css-parser'
|
|
189
|
-
|
|
190
|
-
const ast = parse('@media screen { a { color: red; margin: 0 } }')
|
|
191
|
-
|
|
192
130
|
walk(ast, (node) => {
|
|
193
|
-
if (node.type === DECLARATION)
|
|
194
|
-
console.log(node.property) // "color"
|
|
195
|
-
return BREAK
|
|
196
|
-
}
|
|
131
|
+
if (node.type === DECLARATION) return BREAK
|
|
197
132
|
})
|
|
198
133
|
|
|
199
134
|
traverse(ast, {
|
|
200
135
|
enter(node) {
|
|
201
|
-
if (node.type === AT_RULE) return SKIP
|
|
136
|
+
if (node.type === AT_RULE) return SKIP
|
|
202
137
|
},
|
|
203
138
|
leave(node) {},
|
|
204
139
|
})
|
|
@@ -209,8 +144,6 @@ traverse(ast, {
|
|
|
209
144
|
A generator of tokens; comments are skipped and reported through `on_comment`.
|
|
210
145
|
|
|
211
146
|
```typescript
|
|
212
|
-
import { tokenize } from '@projectwallace/css-parser'
|
|
213
|
-
|
|
214
147
|
for (const token of tokenize('a { color: red }')) {
|
|
215
148
|
console.log(token.type, token.start, token.end)
|
|
216
149
|
}
|
|
@@ -218,37 +151,25 @@ for (const token of tokenize('a { color: red }')) {
|
|
|
218
151
|
|
|
219
152
|
### Node types, type guards and `clone()`
|
|
220
153
|
|
|
221
|
-
|
|
154
|
+
Type guards such as `is_declaration()` narrow a node to its specific type. `node.clone({ deep?, locations? })` returns a mutable plain-object copy of a node.
|
|
222
155
|
|
|
223
156
|
```typescript
|
|
224
|
-
import { parse, is_declaration } from '@projectwallace/css-parser'
|
|
225
|
-
|
|
226
157
|
const decl = parse('a { color: red }').first_child.block.first_child
|
|
227
158
|
is_declaration(decl) // true
|
|
228
159
|
decl.type_name // "Declaration"
|
|
229
|
-
decl.clone({ deep: false }).property // "color"
|
|
230
160
|
```
|
|
231
161
|
|
|
232
162
|
### String helpers
|
|
233
163
|
|
|
234
|
-
Allocation-free helpers, handy when working with node names.
|
|
164
|
+
Allocation-free helpers, handy when working with node names. The lowercase argument is always the first one.
|
|
235
165
|
|
|
236
166
|
```typescript
|
|
237
|
-
import {
|
|
238
|
-
is_custom,
|
|
239
|
-
is_vendor_prefixed,
|
|
240
|
-
strip_vendor_prefix,
|
|
241
|
-
str_equals,
|
|
242
|
-
str_starts_with,
|
|
243
|
-
str_index_of,
|
|
244
|
-
} from '@projectwallace/css-parser'
|
|
245
|
-
|
|
246
167
|
is_custom('--primary') // true
|
|
247
168
|
is_vendor_prefixed('-webkit-transform') // true
|
|
248
169
|
strip_vendor_prefix('-webkit-transform') // "transform"
|
|
249
170
|
str_equals('media', 'MEDIA') // true
|
|
250
|
-
str_starts_with('
|
|
251
|
-
str_index_of('
|
|
171
|
+
str_starts_with('webkit', 'WEBKIT-transform') // true
|
|
172
|
+
str_index_of('color', 'background-COLOR') // 11
|
|
252
173
|
```
|
|
253
174
|
|
|
254
175
|
## Non-goals
|
|
@@ -89,7 +89,6 @@ declare class CSSDataArena {
|
|
|
89
89
|
private grow;
|
|
90
90
|
create_node(type: number, start_offset: number, length: number, start_line: number, start_column: number): number;
|
|
91
91
|
append_children(parent_index: number, children: number[]): void;
|
|
92
|
-
/** Shrink the buffer to the live node count, releasing wasted capacity. Call once after parsing; no-op if already tight. */
|
|
93
92
|
trim(): void;
|
|
94
93
|
get_last_sibling(node_index: number): number;
|
|
95
94
|
has_children(node_index: number): boolean;
|
|
@@ -189,7 +189,6 @@ var CSSDataArena = class CSSDataArena {
|
|
|
189
189
|
this.view.setUint32(offset + 4, children[0], true);
|
|
190
190
|
for (let i = 0; i < children.length - 1; i++) this.set_next_sibling(children[i], children[i + 1]);
|
|
191
191
|
}
|
|
192
|
-
/** Shrink the buffer to the live node count, releasing wasted capacity. Call once after parsing; no-op if already tight. */
|
|
193
192
|
trim() {
|
|
194
193
|
if (this.count === this.capacity) return;
|
|
195
194
|
const byte_count = this.count * BYTES_PER_NODE;
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as PARENTHESIS, B as STYLESHEET, C as MEDIA_QUERY, D as NTH_SELECTOR, E as NTH_OF_SELECTOR, F as RATIO, G as UNICODE_RANGE, H as SUPPORTS_DECLARATION, I as RAW, J as VALUE, K as UNIVERSAL_SELECTOR, L as SELECTOR, 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-
|
|
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-7RLvyGPB.js";
|
|
2
2
|
//#region src/constants.d.ts
|
|
3
3
|
export declare const NODE_TYPES: {
|
|
4
4
|
readonly STYLESHEET: 1;
|
package/dist/constants.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
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-
|
|
1
|
+
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-CsJhQRUX.js";
|
|
2
2
|
//#region src/constants.ts
|
|
3
3
|
const NODE_TYPES = {
|
|
4
4
|
STYLESHEET: 1,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./arena-
|
|
2
|
-
import { a as is_vendor_prefixed, o as is_whitespace, s as str_equals, u as str_starts_with } from "./string-utils-
|
|
1
|
+
import "./arena-CsJhQRUX.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([
|
|
@@ -36,7 +36,8 @@ const nodes_with_children = /* @__PURE__ */ new Set([
|
|
|
36
36
|
36,
|
|
37
37
|
57,
|
|
38
38
|
59,
|
|
39
|
-
60
|
|
39
|
+
60,
|
|
40
|
+
41
|
|
40
41
|
]);
|
|
41
42
|
const enumerable_properties = [
|
|
42
43
|
"name",
|
|
@@ -82,11 +83,9 @@ var CSSNode = class CSSNode {
|
|
|
82
83
|
if (length === 0) return "";
|
|
83
84
|
return this.source.substring(start, start + length);
|
|
84
85
|
}
|
|
85
|
-
/** Get node type as number (for performance) */
|
|
86
86
|
get type() {
|
|
87
87
|
return this.arena.get_type(this.index);
|
|
88
88
|
}
|
|
89
|
-
/** Get node type as human-readable string */
|
|
90
89
|
get type_name() {
|
|
91
90
|
switch (this.type) {
|
|
92
91
|
case 1: return "StyleSheet";
|
|
@@ -138,13 +137,11 @@ var CSSNode = class CSSNode {
|
|
|
138
137
|
default: return "unknown";
|
|
139
138
|
}
|
|
140
139
|
}
|
|
141
|
-
/** Get the full text of this node from source */
|
|
142
140
|
get text() {
|
|
143
141
|
const start = this.arena.get_start_offset(this.index);
|
|
144
142
|
const length = this.arena.get_length(this.index);
|
|
145
143
|
return this.source.substring(start, start + length);
|
|
146
144
|
}
|
|
147
|
-
/** Get the "content" text (at-rule name for at-rules, layer name for import layers) */
|
|
148
145
|
get name() {
|
|
149
146
|
if (!nodes_with_name.has(this.type)) return;
|
|
150
147
|
const { type } = this;
|
|
@@ -153,7 +150,6 @@ var CSSNode = class CSSNode {
|
|
|
153
150
|
if (type === 56 && content === "") return null;
|
|
154
151
|
return content;
|
|
155
152
|
}
|
|
156
|
-
/** Namespace prefix for type/universal selectors: null (none), '' (`|div`), 'ns' (`ns|div`), or '*' (`*|div`). */
|
|
157
153
|
get namespace() {
|
|
158
154
|
const { type } = this;
|
|
159
155
|
if (type !== 21 && type !== 28) return void 0;
|
|
@@ -162,16 +158,11 @@ var CSSNode = class CSSNode {
|
|
|
162
158
|
const length = this.arena.get_value_length(this.index);
|
|
163
159
|
return this.source.substring(start, start + length);
|
|
164
160
|
}
|
|
165
|
-
/** Alias for `name` on declarations ("color" in "color: blue"), more semantic than `name` there. */
|
|
166
161
|
get property() {
|
|
167
162
|
const { type } = this;
|
|
168
163
|
if (type !== 4 && type !== 33 && type !== 57) return;
|
|
169
164
|
return this.get_content();
|
|
170
165
|
}
|
|
171
|
-
/**
|
|
172
|
-
* Declarations: the value text ("1px solid blue"). Dimension/number: the numeric value.
|
|
173
|
-
* String: content without quotes. URL: quoted string keeps quotes, unquoted URL doesn't.
|
|
174
|
-
*/
|
|
175
166
|
get value() {
|
|
176
167
|
const { type, text, first_child } = this;
|
|
177
168
|
if (type === 3) return void 0;
|
|
@@ -187,7 +178,7 @@ var CSSNode = class CSSNode {
|
|
|
187
178
|
if (type === 11) return Number(text);
|
|
188
179
|
if (type === 18) {
|
|
189
180
|
if (first_child?.type === 13) return first_child.text;
|
|
190
|
-
if (str_starts_with(
|
|
181
|
+
if (str_starts_with("url(", text)) {
|
|
191
182
|
const open_paren = text.indexOf("(");
|
|
192
183
|
const close_paren = text.lastIndexOf(")");
|
|
193
184
|
if (open_paren !== -1 && close_paren !== -1 && close_paren > open_paren) return text.substring(open_paren + 1, close_paren).trim();
|
|
@@ -200,7 +191,6 @@ var CSSNode = class CSSNode {
|
|
|
200
191
|
if (length === 0) return null;
|
|
201
192
|
return this.source.substring(start, start + length);
|
|
202
193
|
}
|
|
203
|
-
/** At-rules: AT_RULE_PRELUDE wrapper (media queries, layer names, …). Style rules: SELECTOR_LIST/SELECTOR. Null if none. */
|
|
204
194
|
get prelude() {
|
|
205
195
|
if (this.type === 3) {
|
|
206
196
|
const first = this.first_child;
|
|
@@ -209,7 +199,6 @@ var CSSNode = class CSSNode {
|
|
|
209
199
|
}
|
|
210
200
|
if (this.type === 2) return this.first_child;
|
|
211
201
|
}
|
|
212
|
-
/** Attribute selector operator (=, ~=, |=, ^=, $=, *=), or null for the bare `[attr]` form. */
|
|
213
202
|
get attr_operator() {
|
|
214
203
|
if (this.type !== 24) return void 0;
|
|
215
204
|
const content_end = this.arena.get_content_start(this.index) + this.arena.get_content_length(this.index);
|
|
@@ -227,7 +216,6 @@ var CSSNode = class CSSNode {
|
|
|
227
216
|
if (ch1 === 42 && ch2 === 61) return this.source.substring(pos, pos + 2);
|
|
228
217
|
return null;
|
|
229
218
|
}
|
|
230
|
-
/** Attribute selector flag: "i" (case-insensitive), "s" (case-sensitive), or null if absent. */
|
|
231
219
|
get attr_flags() {
|
|
232
220
|
if (this.type !== 24) return void 0;
|
|
233
221
|
const value_len = this.arena.get_value_length(this.index);
|
|
@@ -241,43 +229,35 @@ var CSSNode = class CSSNode {
|
|
|
241
229
|
if (flag_ch === 105 || flag_ch === 73 || flag_ch === 115 || flag_ch === 83) return this.source.at(pos);
|
|
242
230
|
return null;
|
|
243
231
|
}
|
|
244
|
-
/** Get the unit for dimension nodes (e.g., "px" from "100px", "%" from "50%") */
|
|
245
232
|
get unit() {
|
|
246
233
|
if (this.type !== 12) return void 0;
|
|
247
234
|
const text = this.text;
|
|
248
235
|
return text.substring(dimension_number_end(text));
|
|
249
236
|
}
|
|
250
|
-
/** Numerator for ratio values, e.g. the Number "16" in `aspect-ratio: 16/9` */
|
|
251
237
|
get left() {
|
|
252
238
|
if (this.type !== 58) return void 0;
|
|
253
239
|
return this.first_child ?? void 0;
|
|
254
240
|
}
|
|
255
|
-
/** Denominator for ratio values, e.g. the Number "9" in `aspect-ratio: 16/9` */
|
|
256
241
|
get right() {
|
|
257
242
|
if (this.type !== 58) return void 0;
|
|
258
243
|
return this.first_child?.next_sibling ?? void 0;
|
|
259
244
|
}
|
|
260
|
-
/** Get the parsed condition node of an if() branch, e.g. the Function "style(--active: 1)" or the Identifier "else" */
|
|
261
245
|
get condition() {
|
|
262
246
|
if (this.type !== 59) return;
|
|
263
247
|
return this.first_child ?? void 0;
|
|
264
248
|
}
|
|
265
|
-
/** True when this is the else branch of an if() function */
|
|
266
249
|
get is_else() {
|
|
267
250
|
if (this.type !== 59) return void 0;
|
|
268
251
|
return str_equals("else", this.get_content());
|
|
269
252
|
}
|
|
270
|
-
/** Check if this declaration has !important */
|
|
271
253
|
get is_important() {
|
|
272
254
|
if (this.type !== 4) return void 0;
|
|
273
255
|
return this.arena.has_flag(this.index, 1);
|
|
274
256
|
}
|
|
275
|
-
/** Check if this declaration has a browser hack prefix */
|
|
276
257
|
get is_browserhack() {
|
|
277
258
|
if (this.type !== 4) return void 0;
|
|
278
259
|
return this.arena.has_flag(this.index, 128);
|
|
279
260
|
}
|
|
280
|
-
/** Check if this has a vendor prefix (computed on-demand) */
|
|
281
261
|
get is_vendor_prefixed() {
|
|
282
262
|
switch (this.type) {
|
|
283
263
|
case 4: return is_vendor_prefixed(this.get_content());
|
|
@@ -290,28 +270,23 @@ var CSSNode = class CSSNode {
|
|
|
290
270
|
default: return false;
|
|
291
271
|
}
|
|
292
272
|
}
|
|
293
|
-
/** Check if this node has an error */
|
|
294
273
|
get has_error() {
|
|
295
274
|
return this.arena.has_flag(this.index, 2);
|
|
296
275
|
}
|
|
297
|
-
/** Check if this node has a prelude (at-rules and style rules) */
|
|
298
276
|
get has_prelude() {
|
|
299
277
|
const { type } = this;
|
|
300
278
|
if (type === 3) return this.first_child !== null && this.first_child.type !== 7;
|
|
301
279
|
if (type === 2) return this.first_child !== null;
|
|
302
280
|
return false;
|
|
303
281
|
}
|
|
304
|
-
/** Check if this rule has a block { } */
|
|
305
282
|
get has_block() {
|
|
306
283
|
return this.arena.has_flag(this.index, 8);
|
|
307
284
|
}
|
|
308
|
-
/** Check if this style rule has declarations */
|
|
309
285
|
get has_declarations() {
|
|
310
286
|
const { type } = this;
|
|
311
287
|
if (type !== 3 && type !== 2) return void 0;
|
|
312
288
|
return this.arena.has_flag(this.index, 32);
|
|
313
289
|
}
|
|
314
|
-
/** Get the block node (for style rules and at-rules with blocks) */
|
|
315
290
|
get block() {
|
|
316
291
|
const { type } = this;
|
|
317
292
|
if (type === 2) {
|
|
@@ -331,7 +306,6 @@ var CSSNode = class CSSNode {
|
|
|
331
306
|
}
|
|
332
307
|
return null;
|
|
333
308
|
}
|
|
334
|
-
/** Check if this block is empty (no declarations or rules, only comments allowed) */
|
|
335
309
|
get is_empty() {
|
|
336
310
|
if (this.type !== 7) return void 0;
|
|
337
311
|
let child = this.first_child;
|
|
@@ -341,46 +315,34 @@ var CSSNode = class CSSNode {
|
|
|
341
315
|
}
|
|
342
316
|
return true;
|
|
343
317
|
}
|
|
344
|
-
/** Get start line number */
|
|
345
318
|
get line() {
|
|
346
319
|
return this.arena.get_start_line(this.index);
|
|
347
320
|
}
|
|
348
|
-
/** Get start column number */
|
|
349
321
|
get column() {
|
|
350
322
|
return this.arena.get_start_column(this.index);
|
|
351
323
|
}
|
|
352
|
-
/** Get start offset in source */
|
|
353
324
|
get start() {
|
|
354
325
|
return this.arena.get_start_offset(this.index);
|
|
355
326
|
}
|
|
356
|
-
/** Get length in source */
|
|
357
327
|
get length() {
|
|
358
328
|
return this.arena.get_length(this.index);
|
|
359
329
|
}
|
|
360
|
-
/**
|
|
361
|
-
* Get end offset in source
|
|
362
|
-
* End is not stored, must be calculated
|
|
363
|
-
*/
|
|
364
330
|
get end() {
|
|
365
331
|
return this.start + this.length;
|
|
366
332
|
}
|
|
367
|
-
/** Get first child node */
|
|
368
333
|
get first_child() {
|
|
369
334
|
const child_index = this.arena.get_first_child(this.index);
|
|
370
335
|
if (child_index === 0) return null;
|
|
371
336
|
return new CSSNode(this.arena, this.source, child_index);
|
|
372
337
|
}
|
|
373
|
-
/** Get next sibling node */
|
|
374
338
|
get next_sibling() {
|
|
375
339
|
const sibling_index = this.arena.get_next_sibling(this.index);
|
|
376
340
|
if (sibling_index === 0) return null;
|
|
377
341
|
return new CSSNode(this.arena, this.source, sibling_index);
|
|
378
342
|
}
|
|
379
|
-
/** Check if this node has a next sibling */
|
|
380
343
|
get has_next() {
|
|
381
344
|
return this.arena.get_next_sibling(this.index) !== 0;
|
|
382
345
|
}
|
|
383
|
-
/** Whether this node has children. For pseudo-class/element functions, tracks FLAG_HAS_PARENS so formatters can tell `:lang()` from `:hover`. */
|
|
384
346
|
get has_children() {
|
|
385
347
|
const { type } = this;
|
|
386
348
|
if (type === 25 || type === 26) {
|
|
@@ -388,7 +350,6 @@ var CSSNode = class CSSNode {
|
|
|
388
350
|
}
|
|
389
351
|
return this.arena.has_children(this.index);
|
|
390
352
|
}
|
|
391
|
-
/** Count children without allocating an intermediate array */
|
|
392
353
|
get child_count() {
|
|
393
354
|
let count = 0;
|
|
394
355
|
let child_index = this.arena.get_first_child(this.index);
|
|
@@ -398,7 +359,6 @@ var CSSNode = class CSSNode {
|
|
|
398
359
|
}
|
|
399
360
|
return count;
|
|
400
361
|
}
|
|
401
|
-
/** Get all children as an array */
|
|
402
362
|
get children() {
|
|
403
363
|
const result = [];
|
|
404
364
|
let child = this.first_child;
|
|
@@ -408,7 +368,6 @@ var CSSNode = class CSSNode {
|
|
|
408
368
|
}
|
|
409
369
|
return result;
|
|
410
370
|
}
|
|
411
|
-
/** Make CSSNode iterable over its children */
|
|
412
371
|
*[Symbol.iterator]() {
|
|
413
372
|
let child = this.first_child;
|
|
414
373
|
while (child) {
|
|
@@ -416,7 +375,6 @@ var CSSNode = class CSSNode {
|
|
|
416
375
|
child = child.next_sibling;
|
|
417
376
|
}
|
|
418
377
|
}
|
|
419
|
-
/** Get the 'a' coefficient from An+B expression (e.g., "2n" from "2n+1", "odd" from "odd") */
|
|
420
378
|
get nth_a() {
|
|
421
379
|
const { type, arena, index } = this;
|
|
422
380
|
if (type !== 30 && type !== 31) return void 0;
|
|
@@ -425,7 +383,6 @@ var CSSNode = class CSSNode {
|
|
|
425
383
|
const start = arena.get_content_start(index);
|
|
426
384
|
return this.source.substring(start, start + len);
|
|
427
385
|
}
|
|
428
|
-
/** Get the 'b' coefficient from An+B expression (e.g., "+1" from "2n+1") */
|
|
429
386
|
get nth_b() {
|
|
430
387
|
const { type, arena, index, source } = this;
|
|
431
388
|
if (type !== 30 && type !== 31) return void 0;
|
|
@@ -446,20 +403,14 @@ var CSSNode = class CSSNode {
|
|
|
446
403
|
}
|
|
447
404
|
return value;
|
|
448
405
|
}
|
|
449
|
-
/** Get the An+B formula node from :nth-child(2n+1 of .foo) */
|
|
450
406
|
get nth() {
|
|
451
407
|
if (this.type !== 31) return void 0;
|
|
452
408
|
return this.first_child ?? void 0;
|
|
453
409
|
}
|
|
454
|
-
/** Get the selector list from :nth-child(2n+1 of .foo) */
|
|
455
410
|
get selector() {
|
|
456
411
|
if (this.type !== 31) return void 0;
|
|
457
412
|
return this.first_child?.next_sibling ?? void 0;
|
|
458
413
|
}
|
|
459
|
-
/**
|
|
460
|
-
* Clone this node as a mutable plain object with children as arrays.
|
|
461
|
-
* Use sparingly — can consume a lot of memory.
|
|
462
|
-
*/
|
|
463
414
|
clone(options = {}) {
|
|
464
415
|
const { deep = true, locations = false } = options;
|
|
465
416
|
const { type } = this;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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-
|
|
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-7RLvyGPB.js";
|
|
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-
|
|
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-BZGPDESt.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-
|
|
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-
|
|
1
|
+
import { n as tokenize } from "./tokenize-B2QSzdrM.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
|
-
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-
|
|
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-
|
|
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-CsJhQRUX.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-
|
|
6
|
+
import { n as parse_selector, r as parse_selector_list } from "./parse-selector-B59fV-Ya.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";
|