@projectwallace/css-parser 0.13.9 → 0.13.10
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/dist/arena-BtlVZlkG.d.ts +105 -0
- package/dist/arena-CDAx4eAB.js +220 -0
- package/dist/constants.d.ts +47 -0
- package/dist/constants.js +46 -0
- package/dist/{css-node-DqyvMXBN.d.ts → css-node-B9tSb6YD.d.ts} +3 -105
- package/dist/{css-node-Uj4oBgaw.js → css-node-CZf-PvCf.js} +2 -220
- package/dist/index.d.ts +5 -77
- package/dist/index.js +4 -95
- package/dist/parse-anplusb.d.ts +2 -1
- package/dist/parse-anplusb.js +2 -1
- package/dist/parse-atrule-prelude.d.ts +2 -1
- package/dist/parse-atrule-prelude.js +3 -2
- package/dist/parse-declaration.d.ts +3 -2
- package/dist/parse-declaration.js +3 -2
- package/dist/parse-selector.d.ts +2 -1
- package/dist/parse-selector.js +3 -2
- package/dist/parse-value.d.ts +2 -1
- package/dist/parse-value.js +2 -1
- package/dist/parse.d.ts +3 -2
- package/dist/parse.js +3 -2
- package/dist/tokenize.d.ts +1 -1
- package/dist/walk.d.ts +34 -0
- package/dist/walk.js +53 -0
- package/package.json +11 -3
- /package/dist/{parse-utils-DnsZRpfd.js → parse-utils-BxrmqJxI.js} +0 -0
- /package/dist/{tokenize-odLrcjj2.d.ts → tokenize-CyiJelQC.d.ts} +0 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
//#region src/arena.d.ts
|
|
2
|
+
declare const STYLESHEET = 1;
|
|
3
|
+
declare const STYLE_RULE = 2;
|
|
4
|
+
declare const AT_RULE = 3;
|
|
5
|
+
declare const DECLARATION = 4;
|
|
6
|
+
declare const SELECTOR = 5;
|
|
7
|
+
declare const COMMENT = 6;
|
|
8
|
+
declare const BLOCK = 7;
|
|
9
|
+
declare const RAW = 8;
|
|
10
|
+
declare const IDENTIFIER = 10;
|
|
11
|
+
declare const NUMBER = 11;
|
|
12
|
+
declare const DIMENSION = 12;
|
|
13
|
+
declare const STRING = 13;
|
|
14
|
+
declare const HASH = 14;
|
|
15
|
+
declare const FUNCTION = 15;
|
|
16
|
+
declare const OPERATOR = 16;
|
|
17
|
+
declare const PARENTHESIS = 17;
|
|
18
|
+
declare const URL = 18;
|
|
19
|
+
declare const SELECTOR_LIST = 20;
|
|
20
|
+
declare const TYPE_SELECTOR = 21;
|
|
21
|
+
declare const CLASS_SELECTOR = 22;
|
|
22
|
+
declare const ID_SELECTOR = 23;
|
|
23
|
+
declare const ATTRIBUTE_SELECTOR = 24;
|
|
24
|
+
declare const PSEUDO_CLASS_SELECTOR = 25;
|
|
25
|
+
declare const PSEUDO_ELEMENT_SELECTOR = 26;
|
|
26
|
+
declare const COMBINATOR = 27;
|
|
27
|
+
declare const UNIVERSAL_SELECTOR = 28;
|
|
28
|
+
declare const NESTING_SELECTOR = 29;
|
|
29
|
+
declare const NTH_SELECTOR = 30;
|
|
30
|
+
declare const NTH_OF_SELECTOR = 31;
|
|
31
|
+
declare const LANG_SELECTOR = 56;
|
|
32
|
+
declare const MEDIA_QUERY = 32;
|
|
33
|
+
declare const MEDIA_FEATURE = 33;
|
|
34
|
+
declare const MEDIA_TYPE = 34;
|
|
35
|
+
declare const CONTAINER_QUERY = 35;
|
|
36
|
+
declare const SUPPORTS_QUERY = 36;
|
|
37
|
+
declare const LAYER_NAME = 37;
|
|
38
|
+
declare const PRELUDE_OPERATOR = 38;
|
|
39
|
+
declare const FEATURE_RANGE = 39;
|
|
40
|
+
declare const AT_RULE_PRELUDE = 40;
|
|
41
|
+
declare const VALUE = 50;
|
|
42
|
+
declare const FLAG_IMPORTANT: number;
|
|
43
|
+
declare const ATTR_OPERATOR_NONE = 0;
|
|
44
|
+
declare const ATTR_OPERATOR_EQUAL = 1;
|
|
45
|
+
declare const ATTR_OPERATOR_TILDE_EQUAL = 2;
|
|
46
|
+
declare const ATTR_OPERATOR_PIPE_EQUAL = 3;
|
|
47
|
+
declare const ATTR_OPERATOR_CARET_EQUAL = 4;
|
|
48
|
+
declare const ATTR_OPERATOR_DOLLAR_EQUAL = 5;
|
|
49
|
+
declare const ATTR_OPERATOR_STAR_EQUAL = 6;
|
|
50
|
+
declare const ATTR_FLAG_NONE = 0;
|
|
51
|
+
declare const ATTR_FLAG_CASE_INSENSITIVE = 1;
|
|
52
|
+
declare const ATTR_FLAG_CASE_SENSITIVE = 2;
|
|
53
|
+
/** @internal */
|
|
54
|
+
declare class CSSDataArena {
|
|
55
|
+
private buffer;
|
|
56
|
+
private view;
|
|
57
|
+
private capacity;
|
|
58
|
+
private count;
|
|
59
|
+
private growth_count;
|
|
60
|
+
private overflow_lengths;
|
|
61
|
+
private static readonly GROWTH_FACTOR;
|
|
62
|
+
private static readonly NODES_PER_KB;
|
|
63
|
+
private static readonly CAPACITY_BUFFER;
|
|
64
|
+
constructor(initial_capacity?: number);
|
|
65
|
+
static capacity_for_source(source_length: number): number;
|
|
66
|
+
get_count(): number;
|
|
67
|
+
get_capacity(): number;
|
|
68
|
+
get_growth_count(): number;
|
|
69
|
+
private node_offset;
|
|
70
|
+
get_type(node_index: number): number;
|
|
71
|
+
get_flags(node_index: number): number;
|
|
72
|
+
get_start_offset(node_index: number): number;
|
|
73
|
+
get_length(node_index: number): number;
|
|
74
|
+
get_content_start(node_index: number): number;
|
|
75
|
+
get_content_length(node_index: number): number;
|
|
76
|
+
get_attr_operator(node_index: number): number;
|
|
77
|
+
get_attr_flags(node_index: number): number;
|
|
78
|
+
get_first_child(node_index: number): number;
|
|
79
|
+
get_next_sibling(node_index: number): number;
|
|
80
|
+
get_start_line(node_index: number): number;
|
|
81
|
+
get_start_column(node_index: number): number;
|
|
82
|
+
get_value_start(node_index: number): number;
|
|
83
|
+
get_value_length(node_index: number): number;
|
|
84
|
+
set_type(node_index: number, type: number): void;
|
|
85
|
+
set_flags(node_index: number, flags: number): void;
|
|
86
|
+
set_length(node_index: number, length: number): void;
|
|
87
|
+
set_content_start_delta(node_index: number, delta: number): void;
|
|
88
|
+
set_content_length(node_index: number, length: number): void;
|
|
89
|
+
set_attr_operator(node_index: number, operator: number): void;
|
|
90
|
+
set_attr_flags(node_index: number, flags: number): void;
|
|
91
|
+
set_first_child(node_index: number, childIndex: number): void;
|
|
92
|
+
set_next_sibling(node_index: number, siblingIndex: number): void;
|
|
93
|
+
set_value_start_delta(node_index: number, delta: number): void;
|
|
94
|
+
set_value_length(node_index: number, length: number): void;
|
|
95
|
+
private grow;
|
|
96
|
+
create_node(type: number, start_offset: number, length: number, start_line: number, start_column: number): number;
|
|
97
|
+
append_children(parent_index: number, children: number[]): void;
|
|
98
|
+
has_children(node_index: number): boolean;
|
|
99
|
+
has_next_sibling(node_index: number): boolean;
|
|
100
|
+
set_flag(node_index: number, flag: number): void;
|
|
101
|
+
clear_flag(node_index: number, flag: number): void;
|
|
102
|
+
has_flag(node_index: number, flag: number): boolean;
|
|
103
|
+
}
|
|
104
|
+
//#endregion
|
|
105
|
+
export { MEDIA_FEATURE as A, PSEUDO_CLASS_SELECTOR as B, FLAG_IMPORTANT as C, ID_SELECTOR as D, IDENTIFIER as E, NTH_SELECTOR as F, STRING as G, RAW as H, NUMBER as I, SUPPORTS_QUERY as J, STYLESHEET as K, OPERATOR as L, MEDIA_TYPE as M, NESTING_SELECTOR as N, LANG_SELECTOR as O, NTH_OF_SELECTOR as P, VALUE as Q, PARENTHESIS as R, FEATURE_RANGE as S, HASH as T, SELECTOR as U, PSEUDO_ELEMENT_SELECTOR as V, SELECTOR_LIST as W, UNIVERSAL_SELECTOR as X, TYPE_SELECTOR as Y, URL as Z, COMMENT as _, ATTR_OPERATOR_CARET_EQUAL as a, DECLARATION as b, ATTR_OPERATOR_NONE as c, ATTR_OPERATOR_TILDE_EQUAL as d, AT_RULE as f, COMBINATOR as g, CLASS_SELECTOR as h, ATTR_FLAG_NONE as i, MEDIA_QUERY as j, LAYER_NAME as k, ATTR_OPERATOR_PIPE_EQUAL as l, BLOCK as m, ATTR_FLAG_CASE_INSENSITIVE as n, ATTR_OPERATOR_DOLLAR_EQUAL as o, AT_RULE_PRELUDE as p, STYLE_RULE as q, ATTR_FLAG_CASE_SENSITIVE as r, ATTR_OPERATOR_EQUAL as s, ATTRIBUTE_SELECTOR as t, ATTR_OPERATOR_STAR_EQUAL as u, CONTAINER_QUERY as v, FUNCTION as w, DIMENSION as x, CSSDataArena as y, PRELUDE_OPERATOR as z };
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
//#region src/arena.ts
|
|
2
|
+
let BYTES_PER_NODE = 36;
|
|
3
|
+
const STYLESHEET = 1;
|
|
4
|
+
const STYLE_RULE = 2;
|
|
5
|
+
const AT_RULE = 3;
|
|
6
|
+
const DECLARATION = 4;
|
|
7
|
+
const SELECTOR = 5;
|
|
8
|
+
const COMMENT = 6;
|
|
9
|
+
const BLOCK = 7;
|
|
10
|
+
const RAW = 8;
|
|
11
|
+
const IDENTIFIER = 10;
|
|
12
|
+
const NUMBER = 11;
|
|
13
|
+
const DIMENSION = 12;
|
|
14
|
+
const STRING = 13;
|
|
15
|
+
const HASH = 14;
|
|
16
|
+
const FUNCTION = 15;
|
|
17
|
+
const OPERATOR = 16;
|
|
18
|
+
const PARENTHESIS = 17;
|
|
19
|
+
const URL = 18;
|
|
20
|
+
const SELECTOR_LIST = 20;
|
|
21
|
+
const TYPE_SELECTOR = 21;
|
|
22
|
+
const CLASS_SELECTOR = 22;
|
|
23
|
+
const ID_SELECTOR = 23;
|
|
24
|
+
const ATTRIBUTE_SELECTOR = 24;
|
|
25
|
+
const PSEUDO_CLASS_SELECTOR = 25;
|
|
26
|
+
const PSEUDO_ELEMENT_SELECTOR = 26;
|
|
27
|
+
const COMBINATOR = 27;
|
|
28
|
+
const UNIVERSAL_SELECTOR = 28;
|
|
29
|
+
const NESTING_SELECTOR = 29;
|
|
30
|
+
const NTH_SELECTOR = 30;
|
|
31
|
+
const NTH_OF_SELECTOR = 31;
|
|
32
|
+
const LANG_SELECTOR = 56;
|
|
33
|
+
const MEDIA_QUERY = 32;
|
|
34
|
+
const MEDIA_FEATURE = 33;
|
|
35
|
+
const MEDIA_TYPE = 34;
|
|
36
|
+
const CONTAINER_QUERY = 35;
|
|
37
|
+
const SUPPORTS_QUERY = 36;
|
|
38
|
+
const LAYER_NAME = 37;
|
|
39
|
+
const PRELUDE_OPERATOR = 38;
|
|
40
|
+
const FEATURE_RANGE = 39;
|
|
41
|
+
const AT_RULE_PRELUDE = 40;
|
|
42
|
+
const VALUE = 50;
|
|
43
|
+
const FLAG_IMPORTANT = 1;
|
|
44
|
+
const ATTR_OPERATOR_NONE = 0;
|
|
45
|
+
const ATTR_OPERATOR_EQUAL = 1;
|
|
46
|
+
const ATTR_OPERATOR_TILDE_EQUAL = 2;
|
|
47
|
+
const ATTR_OPERATOR_PIPE_EQUAL = 3;
|
|
48
|
+
const ATTR_OPERATOR_CARET_EQUAL = 4;
|
|
49
|
+
const ATTR_OPERATOR_DOLLAR_EQUAL = 5;
|
|
50
|
+
const ATTR_OPERATOR_STAR_EQUAL = 6;
|
|
51
|
+
const ATTR_FLAG_NONE = 0;
|
|
52
|
+
const ATTR_FLAG_CASE_INSENSITIVE = 1;
|
|
53
|
+
const ATTR_FLAG_CASE_SENSITIVE = 2;
|
|
54
|
+
/** @internal */
|
|
55
|
+
var CSSDataArena = class CSSDataArena {
|
|
56
|
+
buffer;
|
|
57
|
+
view;
|
|
58
|
+
capacity;
|
|
59
|
+
count;
|
|
60
|
+
growth_count;
|
|
61
|
+
overflow_lengths;
|
|
62
|
+
static GROWTH_FACTOR = 1.3;
|
|
63
|
+
static NODES_PER_KB = 325;
|
|
64
|
+
static CAPACITY_BUFFER = 1.2;
|
|
65
|
+
constructor(initial_capacity = 1024) {
|
|
66
|
+
this.capacity = initial_capacity;
|
|
67
|
+
this.count = 1;
|
|
68
|
+
this.growth_count = 0;
|
|
69
|
+
this.buffer = new ArrayBuffer(initial_capacity * BYTES_PER_NODE);
|
|
70
|
+
this.view = new DataView(this.buffer);
|
|
71
|
+
this.overflow_lengths = /* @__PURE__ */ new Map();
|
|
72
|
+
}
|
|
73
|
+
static capacity_for_source(source_length) {
|
|
74
|
+
let size_in_kb = source_length / 1024;
|
|
75
|
+
let estimated_nodes = Math.ceil(size_in_kb * CSSDataArena.NODES_PER_KB);
|
|
76
|
+
let capacity = Math.ceil(estimated_nodes * CSSDataArena.CAPACITY_BUFFER);
|
|
77
|
+
return Math.max(16, capacity);
|
|
78
|
+
}
|
|
79
|
+
get_count() {
|
|
80
|
+
return this.count;
|
|
81
|
+
}
|
|
82
|
+
get_capacity() {
|
|
83
|
+
return this.capacity;
|
|
84
|
+
}
|
|
85
|
+
get_growth_count() {
|
|
86
|
+
return this.growth_count;
|
|
87
|
+
}
|
|
88
|
+
node_offset(node_index) {
|
|
89
|
+
return node_index * BYTES_PER_NODE;
|
|
90
|
+
}
|
|
91
|
+
get_type(node_index) {
|
|
92
|
+
return this.view.getUint8(this.node_offset(node_index));
|
|
93
|
+
}
|
|
94
|
+
get_flags(node_index) {
|
|
95
|
+
return this.view.getUint8(this.node_offset(node_index) + 1);
|
|
96
|
+
}
|
|
97
|
+
get_start_offset(node_index) {
|
|
98
|
+
return this.view.getUint32(this.node_offset(node_index) + 12, true);
|
|
99
|
+
}
|
|
100
|
+
get_length(node_index) {
|
|
101
|
+
if (this.has_flag(node_index, 4)) {
|
|
102
|
+
const overflow_length = this.overflow_lengths.get(node_index);
|
|
103
|
+
if (overflow_length !== void 0) return overflow_length;
|
|
104
|
+
}
|
|
105
|
+
return this.view.getUint16(this.node_offset(node_index) + 2, true);
|
|
106
|
+
}
|
|
107
|
+
get_content_start(node_index) {
|
|
108
|
+
return this.get_start_offset(node_index) + this.view.getUint16(this.node_offset(node_index) + 16, true);
|
|
109
|
+
}
|
|
110
|
+
get_content_length(node_index) {
|
|
111
|
+
return this.view.getUint16(this.node_offset(node_index) + 20, true);
|
|
112
|
+
}
|
|
113
|
+
get_attr_operator(node_index) {
|
|
114
|
+
return this.view.getUint8(this.node_offset(node_index) + 32);
|
|
115
|
+
}
|
|
116
|
+
get_attr_flags(node_index) {
|
|
117
|
+
return this.view.getUint8(this.node_offset(node_index) + 33);
|
|
118
|
+
}
|
|
119
|
+
get_first_child(node_index) {
|
|
120
|
+
return this.view.getUint32(this.node_offset(node_index) + 4, true);
|
|
121
|
+
}
|
|
122
|
+
get_next_sibling(node_index) {
|
|
123
|
+
return this.view.getUint32(this.node_offset(node_index) + 8, true);
|
|
124
|
+
}
|
|
125
|
+
get_start_line(node_index) {
|
|
126
|
+
return this.view.getUint32(this.node_offset(node_index) + 24, true);
|
|
127
|
+
}
|
|
128
|
+
get_start_column(node_index) {
|
|
129
|
+
return this.view.getUint32(this.node_offset(node_index) + 28, true);
|
|
130
|
+
}
|
|
131
|
+
get_value_start(node_index) {
|
|
132
|
+
return this.get_start_offset(node_index) + this.view.getUint16(this.node_offset(node_index) + 18, true);
|
|
133
|
+
}
|
|
134
|
+
get_value_length(node_index) {
|
|
135
|
+
return this.view.getUint16(this.node_offset(node_index) + 22, true);
|
|
136
|
+
}
|
|
137
|
+
set_type(node_index, type) {
|
|
138
|
+
this.view.setUint8(this.node_offset(node_index), type);
|
|
139
|
+
}
|
|
140
|
+
set_flags(node_index, flags) {
|
|
141
|
+
this.view.setUint8(this.node_offset(node_index) + 1, flags);
|
|
142
|
+
}
|
|
143
|
+
set_length(node_index, length) {
|
|
144
|
+
if (length > 65535) {
|
|
145
|
+
this.view.setUint16(this.node_offset(node_index) + 2, 65535, true);
|
|
146
|
+
this.set_flag(node_index, 4);
|
|
147
|
+
this.overflow_lengths.set(node_index, length);
|
|
148
|
+
} else this.view.setUint16(this.node_offset(node_index) + 2, length, true);
|
|
149
|
+
}
|
|
150
|
+
set_content_start_delta(node_index, delta) {
|
|
151
|
+
this.view.setUint16(this.node_offset(node_index) + 16, delta, true);
|
|
152
|
+
}
|
|
153
|
+
set_content_length(node_index, length) {
|
|
154
|
+
this.view.setUint16(this.node_offset(node_index) + 20, length, true);
|
|
155
|
+
}
|
|
156
|
+
set_attr_operator(node_index, operator) {
|
|
157
|
+
this.view.setUint8(this.node_offset(node_index) + 32, operator);
|
|
158
|
+
}
|
|
159
|
+
set_attr_flags(node_index, flags) {
|
|
160
|
+
this.view.setUint8(this.node_offset(node_index) + 33, flags);
|
|
161
|
+
}
|
|
162
|
+
set_first_child(node_index, childIndex) {
|
|
163
|
+
this.view.setUint32(this.node_offset(node_index) + 4, childIndex, true);
|
|
164
|
+
}
|
|
165
|
+
set_next_sibling(node_index, siblingIndex) {
|
|
166
|
+
this.view.setUint32(this.node_offset(node_index) + 8, siblingIndex, true);
|
|
167
|
+
}
|
|
168
|
+
set_value_start_delta(node_index, delta) {
|
|
169
|
+
this.view.setUint16(this.node_offset(node_index) + 18, delta, true);
|
|
170
|
+
}
|
|
171
|
+
set_value_length(node_index, length) {
|
|
172
|
+
this.view.setUint16(this.node_offset(node_index) + 22, length, true);
|
|
173
|
+
}
|
|
174
|
+
grow() {
|
|
175
|
+
this.growth_count++;
|
|
176
|
+
let new_capacity = Math.ceil(this.capacity * CSSDataArena.GROWTH_FACTOR);
|
|
177
|
+
let new_buffer = new ArrayBuffer(new_capacity * BYTES_PER_NODE);
|
|
178
|
+
new Uint8Array(new_buffer).set(new Uint8Array(this.buffer));
|
|
179
|
+
this.buffer = new_buffer;
|
|
180
|
+
this.view = new DataView(new_buffer);
|
|
181
|
+
this.capacity = new_capacity;
|
|
182
|
+
}
|
|
183
|
+
create_node(type, start_offset, length, start_line, start_column) {
|
|
184
|
+
if (this.count >= this.capacity) this.grow();
|
|
185
|
+
const node_index = this.count;
|
|
186
|
+
this.count++;
|
|
187
|
+
const offset = node_index * BYTES_PER_NODE;
|
|
188
|
+
this.view.setUint8(offset, type);
|
|
189
|
+
this.view.setUint32(offset + 12, start_offset, true);
|
|
190
|
+
this.view.setUint32(offset + 24, start_line, true);
|
|
191
|
+
this.view.setUint32(offset + 28, start_column, true);
|
|
192
|
+
this.set_length(node_index, length);
|
|
193
|
+
return node_index;
|
|
194
|
+
}
|
|
195
|
+
append_children(parent_index, children) {
|
|
196
|
+
if (children.length === 0) return;
|
|
197
|
+
const offset = this.node_offset(parent_index);
|
|
198
|
+
this.view.setUint32(offset + 4, children[0], true);
|
|
199
|
+
for (let i = 0; i < children.length - 1; i++) this.set_next_sibling(children[i], children[i + 1]);
|
|
200
|
+
}
|
|
201
|
+
has_children(node_index) {
|
|
202
|
+
return this.get_first_child(node_index) !== 0;
|
|
203
|
+
}
|
|
204
|
+
has_next_sibling(node_index) {
|
|
205
|
+
return this.get_next_sibling(node_index) !== 0;
|
|
206
|
+
}
|
|
207
|
+
set_flag(node_index, flag) {
|
|
208
|
+
let current_flags = this.get_flags(node_index);
|
|
209
|
+
this.set_flags(node_index, current_flags | flag);
|
|
210
|
+
}
|
|
211
|
+
clear_flag(node_index, flag) {
|
|
212
|
+
let current_flags = this.get_flags(node_index);
|
|
213
|
+
this.set_flags(node_index, current_flags & ~flag);
|
|
214
|
+
}
|
|
215
|
+
has_flag(node_index, flag) {
|
|
216
|
+
return (this.get_flags(node_index) & flag) !== 0;
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
//#endregion
|
|
220
|
+
export { MEDIA_FEATURE as A, PSEUDO_CLASS_SELECTOR as B, FLAG_IMPORTANT as C, ID_SELECTOR as D, IDENTIFIER as E, NTH_SELECTOR as F, STRING as G, RAW as H, NUMBER as I, SUPPORTS_QUERY as J, STYLESHEET as K, OPERATOR as L, MEDIA_TYPE as M, NESTING_SELECTOR as N, LANG_SELECTOR as O, NTH_OF_SELECTOR as P, VALUE as Q, PARENTHESIS as R, FEATURE_RANGE as S, HASH as T, SELECTOR as U, PSEUDO_ELEMENT_SELECTOR as V, SELECTOR_LIST as W, UNIVERSAL_SELECTOR as X, TYPE_SELECTOR as Y, URL as Z, COMMENT as _, ATTR_OPERATOR_CARET_EQUAL as a, DECLARATION as b, ATTR_OPERATOR_NONE as c, ATTR_OPERATOR_TILDE_EQUAL as d, AT_RULE as f, COMBINATOR as g, CLASS_SELECTOR as h, ATTR_FLAG_NONE as i, MEDIA_QUERY as j, LAYER_NAME as k, ATTR_OPERATOR_PIPE_EQUAL as l, BLOCK as m, ATTR_FLAG_CASE_INSENSITIVE as n, ATTR_OPERATOR_DOLLAR_EQUAL as o, AT_RULE_PRELUDE as p, STYLE_RULE as q, ATTR_FLAG_CASE_SENSITIVE as r, ATTR_OPERATOR_EQUAL as s, ATTRIBUTE_SELECTOR as t, ATTR_OPERATOR_STAR_EQUAL as u, CONTAINER_QUERY as v, FUNCTION as w, DIMENSION as x, CSSDataArena as y, PRELUDE_OPERATOR as z };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { A as MEDIA_FEATURE, B as PSEUDO_CLASS_SELECTOR, C as FLAG_IMPORTANT, 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, a as ATTR_OPERATOR_CARET_EQUAL, b as DECLARATION, c as ATTR_OPERATOR_NONE, d as ATTR_OPERATOR_TILDE_EQUAL, f as AT_RULE, g as COMBINATOR, h as CLASS_SELECTOR, i as ATTR_FLAG_NONE, j as MEDIA_QUERY, k as LAYER_NAME, l as ATTR_OPERATOR_PIPE_EQUAL, m as BLOCK, n as ATTR_FLAG_CASE_INSENSITIVE, o as ATTR_OPERATOR_DOLLAR_EQUAL, p as AT_RULE_PRELUDE, q as STYLE_RULE, r as ATTR_FLAG_CASE_SENSITIVE, s as ATTR_OPERATOR_EQUAL, t as ATTRIBUTE_SELECTOR, u as ATTR_OPERATOR_STAR_EQUAL, v as CONTAINER_QUERY, w as FUNCTION, x as DIMENSION, z as PRELUDE_OPERATOR } from "./arena-BtlVZlkG.js";
|
|
2
|
+
|
|
3
|
+
//#region src/constants.d.ts
|
|
4
|
+
declare const NODE_TYPES: {
|
|
5
|
+
readonly STYLESHEET: 1;
|
|
6
|
+
readonly STYLE_RULE: 2;
|
|
7
|
+
readonly AT_RULE: 3;
|
|
8
|
+
readonly DECLARATION: 4;
|
|
9
|
+
readonly SELECTOR: 5;
|
|
10
|
+
readonly COMMENT: 6;
|
|
11
|
+
readonly BLOCK: 7;
|
|
12
|
+
readonly RAW: 8;
|
|
13
|
+
readonly IDENTIFIER: 10;
|
|
14
|
+
readonly NUMBER: 11;
|
|
15
|
+
readonly DIMENSION: 12;
|
|
16
|
+
readonly STRING: 13;
|
|
17
|
+
readonly HASH: 14;
|
|
18
|
+
readonly FUNCTION: 15;
|
|
19
|
+
readonly OPERATOR: 16;
|
|
20
|
+
readonly PARENTHESIS: 17;
|
|
21
|
+
readonly URL: 18;
|
|
22
|
+
readonly VALUE: 50;
|
|
23
|
+
readonly SELECTOR_LIST: 20;
|
|
24
|
+
readonly TYPE_SELECTOR: 21;
|
|
25
|
+
readonly CLASS_SELECTOR: 22;
|
|
26
|
+
readonly ID_SELECTOR: 23;
|
|
27
|
+
readonly ATTRIBUTE_SELECTOR: 24;
|
|
28
|
+
readonly PSEUDO_CLASS_SELECTOR: 25;
|
|
29
|
+
readonly PSEUDO_ELEMENT_SELECTOR: 26;
|
|
30
|
+
readonly COMBINATOR: 27;
|
|
31
|
+
readonly UNIVERSAL_SELECTOR: 28;
|
|
32
|
+
readonly NESTING_SELECTOR: 29;
|
|
33
|
+
readonly NTH_SELECTOR: 30;
|
|
34
|
+
readonly NTH_OF_SELECTOR: 31;
|
|
35
|
+
readonly LANG_SELECTOR: 56;
|
|
36
|
+
readonly MEDIA_QUERY: 32;
|
|
37
|
+
readonly MEDIA_FEATURE: 33;
|
|
38
|
+
readonly MEDIA_TYPE: 34;
|
|
39
|
+
readonly CONTAINER_QUERY: 35;
|
|
40
|
+
readonly SUPPORTS_QUERY: 36;
|
|
41
|
+
readonly LAYER_NAME: 37;
|
|
42
|
+
readonly PRELUDE_OPERATOR: 38;
|
|
43
|
+
readonly FEATURE_RANGE: 39;
|
|
44
|
+
readonly AT_RULE_PRELUDE: 40;
|
|
45
|
+
};
|
|
46
|
+
//#endregion
|
|
47
|
+
export { ATTRIBUTE_SELECTOR, ATTR_FLAG_CASE_INSENSITIVE, ATTR_FLAG_CASE_SENSITIVE, ATTR_FLAG_NONE, ATTR_OPERATOR_CARET_EQUAL, ATTR_OPERATOR_DOLLAR_EQUAL, ATTR_OPERATOR_EQUAL, ATTR_OPERATOR_NONE, ATTR_OPERATOR_PIPE_EQUAL, ATTR_OPERATOR_STAR_EQUAL, ATTR_OPERATOR_TILDE_EQUAL, AT_RULE, AT_RULE_PRELUDE, BLOCK, CLASS_SELECTOR, COMBINATOR, COMMENT, CONTAINER_QUERY, DECLARATION, DIMENSION, FEATURE_RANGE, FLAG_IMPORTANT, FUNCTION, HASH, IDENTIFIER, ID_SELECTOR, 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, RAW, SELECTOR, SELECTOR_LIST, STRING, STYLESHEET, STYLE_RULE, SUPPORTS_QUERY, TYPE_SELECTOR, UNIVERSAL_SELECTOR, URL, VALUE };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { A as MEDIA_FEATURE, B as PSEUDO_CLASS_SELECTOR, C as FLAG_IMPORTANT, 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, a as ATTR_OPERATOR_CARET_EQUAL, b as DECLARATION, c as ATTR_OPERATOR_NONE, d as ATTR_OPERATOR_TILDE_EQUAL, f as AT_RULE, g as COMBINATOR, h as CLASS_SELECTOR, i as ATTR_FLAG_NONE, j as MEDIA_QUERY, k as LAYER_NAME, l as ATTR_OPERATOR_PIPE_EQUAL, m as BLOCK, n as ATTR_FLAG_CASE_INSENSITIVE, o as ATTR_OPERATOR_DOLLAR_EQUAL, p as AT_RULE_PRELUDE, q as STYLE_RULE, r as ATTR_FLAG_CASE_SENSITIVE, s as ATTR_OPERATOR_EQUAL, t as ATTRIBUTE_SELECTOR, u as ATTR_OPERATOR_STAR_EQUAL, v as CONTAINER_QUERY, w as FUNCTION, x as DIMENSION, z as PRELUDE_OPERATOR } from "./arena-CDAx4eAB.js";
|
|
2
|
+
//#region src/constants.ts
|
|
3
|
+
const NODE_TYPES = {
|
|
4
|
+
STYLESHEET: 1,
|
|
5
|
+
STYLE_RULE: 2,
|
|
6
|
+
AT_RULE: 3,
|
|
7
|
+
DECLARATION: 4,
|
|
8
|
+
SELECTOR: 5,
|
|
9
|
+
COMMENT: 6,
|
|
10
|
+
BLOCK: 7,
|
|
11
|
+
RAW: 8,
|
|
12
|
+
IDENTIFIER: 10,
|
|
13
|
+
NUMBER: 11,
|
|
14
|
+
DIMENSION: 12,
|
|
15
|
+
STRING: 13,
|
|
16
|
+
HASH: 14,
|
|
17
|
+
FUNCTION: 15,
|
|
18
|
+
OPERATOR: 16,
|
|
19
|
+
PARENTHESIS: 17,
|
|
20
|
+
URL: 18,
|
|
21
|
+
VALUE: 50,
|
|
22
|
+
SELECTOR_LIST: 20,
|
|
23
|
+
TYPE_SELECTOR: 21,
|
|
24
|
+
CLASS_SELECTOR: 22,
|
|
25
|
+
ID_SELECTOR: 23,
|
|
26
|
+
ATTRIBUTE_SELECTOR: 24,
|
|
27
|
+
PSEUDO_CLASS_SELECTOR: 25,
|
|
28
|
+
PSEUDO_ELEMENT_SELECTOR: 26,
|
|
29
|
+
COMBINATOR: 27,
|
|
30
|
+
UNIVERSAL_SELECTOR: 28,
|
|
31
|
+
NESTING_SELECTOR: 29,
|
|
32
|
+
NTH_SELECTOR: 30,
|
|
33
|
+
NTH_OF_SELECTOR: 31,
|
|
34
|
+
LANG_SELECTOR: 56,
|
|
35
|
+
MEDIA_QUERY: 32,
|
|
36
|
+
MEDIA_FEATURE: 33,
|
|
37
|
+
MEDIA_TYPE: 34,
|
|
38
|
+
CONTAINER_QUERY: 35,
|
|
39
|
+
SUPPORTS_QUERY: 36,
|
|
40
|
+
LAYER_NAME: 37,
|
|
41
|
+
PRELUDE_OPERATOR: 38,
|
|
42
|
+
FEATURE_RANGE: 39,
|
|
43
|
+
AT_RULE_PRELUDE: 40
|
|
44
|
+
};
|
|
45
|
+
//#endregion
|
|
46
|
+
export { ATTRIBUTE_SELECTOR, ATTR_FLAG_CASE_INSENSITIVE, ATTR_FLAG_CASE_SENSITIVE, ATTR_FLAG_NONE, ATTR_OPERATOR_CARET_EQUAL, ATTR_OPERATOR_DOLLAR_EQUAL, ATTR_OPERATOR_EQUAL, ATTR_OPERATOR_NONE, ATTR_OPERATOR_PIPE_EQUAL, ATTR_OPERATOR_STAR_EQUAL, ATTR_OPERATOR_TILDE_EQUAL, AT_RULE, AT_RULE_PRELUDE, BLOCK, CLASS_SELECTOR, COMBINATOR, COMMENT, CONTAINER_QUERY, DECLARATION, DIMENSION, FEATURE_RANGE, FLAG_IMPORTANT, FUNCTION, HASH, IDENTIFIER, ID_SELECTOR, 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, RAW, SELECTOR, SELECTOR_LIST, STRING, STYLESHEET, STYLE_RULE, SUPPORTS_QUERY, TYPE_SELECTOR, UNIVERSAL_SELECTOR, URL, VALUE };
|
|
@@ -1,107 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
declare const STYLE_RULE = 2;
|
|
4
|
-
declare const AT_RULE = 3;
|
|
5
|
-
declare const DECLARATION = 4;
|
|
6
|
-
declare const SELECTOR = 5;
|
|
7
|
-
declare const COMMENT = 6;
|
|
8
|
-
declare const BLOCK = 7;
|
|
9
|
-
declare const RAW = 8;
|
|
10
|
-
declare const IDENTIFIER = 10;
|
|
11
|
-
declare const NUMBER = 11;
|
|
12
|
-
declare const DIMENSION = 12;
|
|
13
|
-
declare const STRING = 13;
|
|
14
|
-
declare const HASH = 14;
|
|
15
|
-
declare const FUNCTION = 15;
|
|
16
|
-
declare const OPERATOR = 16;
|
|
17
|
-
declare const PARENTHESIS = 17;
|
|
18
|
-
declare const URL = 18;
|
|
19
|
-
declare const SELECTOR_LIST = 20;
|
|
20
|
-
declare const TYPE_SELECTOR = 21;
|
|
21
|
-
declare const CLASS_SELECTOR = 22;
|
|
22
|
-
declare const ID_SELECTOR = 23;
|
|
23
|
-
declare const ATTRIBUTE_SELECTOR = 24;
|
|
24
|
-
declare const PSEUDO_CLASS_SELECTOR = 25;
|
|
25
|
-
declare const PSEUDO_ELEMENT_SELECTOR = 26;
|
|
26
|
-
declare const COMBINATOR = 27;
|
|
27
|
-
declare const UNIVERSAL_SELECTOR = 28;
|
|
28
|
-
declare const NESTING_SELECTOR = 29;
|
|
29
|
-
declare const NTH_SELECTOR = 30;
|
|
30
|
-
declare const NTH_OF_SELECTOR = 31;
|
|
31
|
-
declare const LANG_SELECTOR = 56;
|
|
32
|
-
declare const MEDIA_QUERY = 32;
|
|
33
|
-
declare const MEDIA_FEATURE = 33;
|
|
34
|
-
declare const MEDIA_TYPE = 34;
|
|
35
|
-
declare const CONTAINER_QUERY = 35;
|
|
36
|
-
declare const SUPPORTS_QUERY = 36;
|
|
37
|
-
declare const LAYER_NAME = 37;
|
|
38
|
-
declare const PRELUDE_OPERATOR = 38;
|
|
39
|
-
declare const FEATURE_RANGE = 39;
|
|
40
|
-
declare const AT_RULE_PRELUDE = 40;
|
|
41
|
-
declare const VALUE = 50;
|
|
42
|
-
declare const FLAG_IMPORTANT: number;
|
|
43
|
-
declare const ATTR_OPERATOR_NONE = 0;
|
|
44
|
-
declare const ATTR_OPERATOR_EQUAL = 1;
|
|
45
|
-
declare const ATTR_OPERATOR_TILDE_EQUAL = 2;
|
|
46
|
-
declare const ATTR_OPERATOR_PIPE_EQUAL = 3;
|
|
47
|
-
declare const ATTR_OPERATOR_CARET_EQUAL = 4;
|
|
48
|
-
declare const ATTR_OPERATOR_DOLLAR_EQUAL = 5;
|
|
49
|
-
declare const ATTR_OPERATOR_STAR_EQUAL = 6;
|
|
50
|
-
declare const ATTR_FLAG_NONE = 0;
|
|
51
|
-
declare const ATTR_FLAG_CASE_INSENSITIVE = 1;
|
|
52
|
-
declare const ATTR_FLAG_CASE_SENSITIVE = 2;
|
|
53
|
-
/** @internal */
|
|
54
|
-
declare class CSSDataArena {
|
|
55
|
-
private buffer;
|
|
56
|
-
private view;
|
|
57
|
-
private capacity;
|
|
58
|
-
private count;
|
|
59
|
-
private growth_count;
|
|
60
|
-
private overflow_lengths;
|
|
61
|
-
private static readonly GROWTH_FACTOR;
|
|
62
|
-
private static readonly NODES_PER_KB;
|
|
63
|
-
private static readonly CAPACITY_BUFFER;
|
|
64
|
-
constructor(initial_capacity?: number);
|
|
65
|
-
static capacity_for_source(source_length: number): number;
|
|
66
|
-
get_count(): number;
|
|
67
|
-
get_capacity(): number;
|
|
68
|
-
get_growth_count(): number;
|
|
69
|
-
private node_offset;
|
|
70
|
-
get_type(node_index: number): number;
|
|
71
|
-
get_flags(node_index: number): number;
|
|
72
|
-
get_start_offset(node_index: number): number;
|
|
73
|
-
get_length(node_index: number): number;
|
|
74
|
-
get_content_start(node_index: number): number;
|
|
75
|
-
get_content_length(node_index: number): number;
|
|
76
|
-
get_attr_operator(node_index: number): number;
|
|
77
|
-
get_attr_flags(node_index: number): number;
|
|
78
|
-
get_first_child(node_index: number): number;
|
|
79
|
-
get_next_sibling(node_index: number): number;
|
|
80
|
-
get_start_line(node_index: number): number;
|
|
81
|
-
get_start_column(node_index: number): number;
|
|
82
|
-
get_value_start(node_index: number): number;
|
|
83
|
-
get_value_length(node_index: number): number;
|
|
84
|
-
set_type(node_index: number, type: number): void;
|
|
85
|
-
set_flags(node_index: number, flags: number): void;
|
|
86
|
-
set_length(node_index: number, length: number): void;
|
|
87
|
-
set_content_start_delta(node_index: number, delta: number): void;
|
|
88
|
-
set_content_length(node_index: number, length: number): void;
|
|
89
|
-
set_attr_operator(node_index: number, operator: number): void;
|
|
90
|
-
set_attr_flags(node_index: number, flags: number): void;
|
|
91
|
-
set_first_child(node_index: number, childIndex: number): void;
|
|
92
|
-
set_next_sibling(node_index: number, siblingIndex: number): void;
|
|
93
|
-
set_value_start_delta(node_index: number, delta: number): void;
|
|
94
|
-
set_value_length(node_index: number, length: number): void;
|
|
95
|
-
private grow;
|
|
96
|
-
create_node(type: number, start_offset: number, length: number, start_line: number, start_column: number): number;
|
|
97
|
-
append_children(parent_index: number, children: number[]): void;
|
|
98
|
-
has_children(node_index: number): boolean;
|
|
99
|
-
has_next_sibling(node_index: number): boolean;
|
|
100
|
-
set_flag(node_index: number, flag: number): void;
|
|
101
|
-
clear_flag(node_index: number, flag: number): void;
|
|
102
|
-
has_flag(node_index: number, flag: number): boolean;
|
|
103
|
-
}
|
|
104
|
-
//#endregion
|
|
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
|
+
|
|
105
3
|
//#region src/css-node.d.ts
|
|
106
4
|
declare const TYPE_NAMES: {
|
|
107
5
|
readonly 1: "StyleSheet";
|
|
@@ -310,4 +208,4 @@ declare class CSSNode {
|
|
|
310
208
|
clone(options?: CloneOptions): PlainCSSNode;
|
|
311
209
|
}
|
|
312
210
|
//#endregion
|
|
313
|
-
export {
|
|
211
|
+
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 };
|
|
@@ -1,223 +1,5 @@
|
|
|
1
|
+
import "./arena-CDAx4eAB.js";
|
|
1
2
|
import { a as is_whitespace, c as str_starts_with, i as is_vendor_prefixed, t as parse_dimension } from "./parse-dimension-CCn_XRDe.js";
|
|
2
|
-
//#region src/arena.ts
|
|
3
|
-
let BYTES_PER_NODE = 36;
|
|
4
|
-
const STYLESHEET = 1;
|
|
5
|
-
const STYLE_RULE = 2;
|
|
6
|
-
const AT_RULE = 3;
|
|
7
|
-
const DECLARATION = 4;
|
|
8
|
-
const SELECTOR = 5;
|
|
9
|
-
const COMMENT = 6;
|
|
10
|
-
const BLOCK = 7;
|
|
11
|
-
const RAW = 8;
|
|
12
|
-
const IDENTIFIER = 10;
|
|
13
|
-
const NUMBER = 11;
|
|
14
|
-
const DIMENSION = 12;
|
|
15
|
-
const STRING = 13;
|
|
16
|
-
const HASH = 14;
|
|
17
|
-
const FUNCTION = 15;
|
|
18
|
-
const OPERATOR = 16;
|
|
19
|
-
const PARENTHESIS = 17;
|
|
20
|
-
const URL = 18;
|
|
21
|
-
const SELECTOR_LIST = 20;
|
|
22
|
-
const TYPE_SELECTOR = 21;
|
|
23
|
-
const CLASS_SELECTOR = 22;
|
|
24
|
-
const ID_SELECTOR = 23;
|
|
25
|
-
const ATTRIBUTE_SELECTOR = 24;
|
|
26
|
-
const PSEUDO_CLASS_SELECTOR = 25;
|
|
27
|
-
const PSEUDO_ELEMENT_SELECTOR = 26;
|
|
28
|
-
const COMBINATOR = 27;
|
|
29
|
-
const UNIVERSAL_SELECTOR = 28;
|
|
30
|
-
const NESTING_SELECTOR = 29;
|
|
31
|
-
const NTH_SELECTOR = 30;
|
|
32
|
-
const NTH_OF_SELECTOR = 31;
|
|
33
|
-
const LANG_SELECTOR = 56;
|
|
34
|
-
const MEDIA_QUERY = 32;
|
|
35
|
-
const MEDIA_FEATURE = 33;
|
|
36
|
-
const MEDIA_TYPE = 34;
|
|
37
|
-
const CONTAINER_QUERY = 35;
|
|
38
|
-
const SUPPORTS_QUERY = 36;
|
|
39
|
-
const LAYER_NAME = 37;
|
|
40
|
-
const PRELUDE_OPERATOR = 38;
|
|
41
|
-
const FEATURE_RANGE = 39;
|
|
42
|
-
const AT_RULE_PRELUDE = 40;
|
|
43
|
-
const VALUE = 50;
|
|
44
|
-
const FLAG_IMPORTANT = 1;
|
|
45
|
-
const ATTR_OPERATOR_NONE = 0;
|
|
46
|
-
const ATTR_OPERATOR_EQUAL = 1;
|
|
47
|
-
const ATTR_OPERATOR_TILDE_EQUAL = 2;
|
|
48
|
-
const ATTR_OPERATOR_PIPE_EQUAL = 3;
|
|
49
|
-
const ATTR_OPERATOR_CARET_EQUAL = 4;
|
|
50
|
-
const ATTR_OPERATOR_DOLLAR_EQUAL = 5;
|
|
51
|
-
const ATTR_OPERATOR_STAR_EQUAL = 6;
|
|
52
|
-
const ATTR_FLAG_NONE = 0;
|
|
53
|
-
const ATTR_FLAG_CASE_INSENSITIVE = 1;
|
|
54
|
-
const ATTR_FLAG_CASE_SENSITIVE = 2;
|
|
55
|
-
/** @internal */
|
|
56
|
-
var CSSDataArena = class CSSDataArena {
|
|
57
|
-
buffer;
|
|
58
|
-
view;
|
|
59
|
-
capacity;
|
|
60
|
-
count;
|
|
61
|
-
growth_count;
|
|
62
|
-
overflow_lengths;
|
|
63
|
-
static GROWTH_FACTOR = 1.3;
|
|
64
|
-
static NODES_PER_KB = 325;
|
|
65
|
-
static CAPACITY_BUFFER = 1.2;
|
|
66
|
-
constructor(initial_capacity = 1024) {
|
|
67
|
-
this.capacity = initial_capacity;
|
|
68
|
-
this.count = 1;
|
|
69
|
-
this.growth_count = 0;
|
|
70
|
-
this.buffer = new ArrayBuffer(initial_capacity * BYTES_PER_NODE);
|
|
71
|
-
this.view = new DataView(this.buffer);
|
|
72
|
-
this.overflow_lengths = /* @__PURE__ */ new Map();
|
|
73
|
-
}
|
|
74
|
-
static capacity_for_source(source_length) {
|
|
75
|
-
let size_in_kb = source_length / 1024;
|
|
76
|
-
let estimated_nodes = Math.ceil(size_in_kb * CSSDataArena.NODES_PER_KB);
|
|
77
|
-
let capacity = Math.ceil(estimated_nodes * CSSDataArena.CAPACITY_BUFFER);
|
|
78
|
-
return Math.max(16, capacity);
|
|
79
|
-
}
|
|
80
|
-
get_count() {
|
|
81
|
-
return this.count;
|
|
82
|
-
}
|
|
83
|
-
get_capacity() {
|
|
84
|
-
return this.capacity;
|
|
85
|
-
}
|
|
86
|
-
get_growth_count() {
|
|
87
|
-
return this.growth_count;
|
|
88
|
-
}
|
|
89
|
-
node_offset(node_index) {
|
|
90
|
-
return node_index * BYTES_PER_NODE;
|
|
91
|
-
}
|
|
92
|
-
get_type(node_index) {
|
|
93
|
-
return this.view.getUint8(this.node_offset(node_index));
|
|
94
|
-
}
|
|
95
|
-
get_flags(node_index) {
|
|
96
|
-
return this.view.getUint8(this.node_offset(node_index) + 1);
|
|
97
|
-
}
|
|
98
|
-
get_start_offset(node_index) {
|
|
99
|
-
return this.view.getUint32(this.node_offset(node_index) + 12, true);
|
|
100
|
-
}
|
|
101
|
-
get_length(node_index) {
|
|
102
|
-
if (this.has_flag(node_index, 4)) {
|
|
103
|
-
const overflow_length = this.overflow_lengths.get(node_index);
|
|
104
|
-
if (overflow_length !== void 0) return overflow_length;
|
|
105
|
-
}
|
|
106
|
-
return this.view.getUint16(this.node_offset(node_index) + 2, true);
|
|
107
|
-
}
|
|
108
|
-
get_content_start(node_index) {
|
|
109
|
-
return this.get_start_offset(node_index) + this.view.getUint16(this.node_offset(node_index) + 16, true);
|
|
110
|
-
}
|
|
111
|
-
get_content_length(node_index) {
|
|
112
|
-
return this.view.getUint16(this.node_offset(node_index) + 20, true);
|
|
113
|
-
}
|
|
114
|
-
get_attr_operator(node_index) {
|
|
115
|
-
return this.view.getUint8(this.node_offset(node_index) + 32);
|
|
116
|
-
}
|
|
117
|
-
get_attr_flags(node_index) {
|
|
118
|
-
return this.view.getUint8(this.node_offset(node_index) + 33);
|
|
119
|
-
}
|
|
120
|
-
get_first_child(node_index) {
|
|
121
|
-
return this.view.getUint32(this.node_offset(node_index) + 4, true);
|
|
122
|
-
}
|
|
123
|
-
get_next_sibling(node_index) {
|
|
124
|
-
return this.view.getUint32(this.node_offset(node_index) + 8, true);
|
|
125
|
-
}
|
|
126
|
-
get_start_line(node_index) {
|
|
127
|
-
return this.view.getUint32(this.node_offset(node_index) + 24, true);
|
|
128
|
-
}
|
|
129
|
-
get_start_column(node_index) {
|
|
130
|
-
return this.view.getUint32(this.node_offset(node_index) + 28, true);
|
|
131
|
-
}
|
|
132
|
-
get_value_start(node_index) {
|
|
133
|
-
return this.get_start_offset(node_index) + this.view.getUint16(this.node_offset(node_index) + 18, true);
|
|
134
|
-
}
|
|
135
|
-
get_value_length(node_index) {
|
|
136
|
-
return this.view.getUint16(this.node_offset(node_index) + 22, true);
|
|
137
|
-
}
|
|
138
|
-
set_type(node_index, type) {
|
|
139
|
-
this.view.setUint8(this.node_offset(node_index), type);
|
|
140
|
-
}
|
|
141
|
-
set_flags(node_index, flags) {
|
|
142
|
-
this.view.setUint8(this.node_offset(node_index) + 1, flags);
|
|
143
|
-
}
|
|
144
|
-
set_length(node_index, length) {
|
|
145
|
-
if (length > 65535) {
|
|
146
|
-
this.view.setUint16(this.node_offset(node_index) + 2, 65535, true);
|
|
147
|
-
this.set_flag(node_index, 4);
|
|
148
|
-
this.overflow_lengths.set(node_index, length);
|
|
149
|
-
} else this.view.setUint16(this.node_offset(node_index) + 2, length, true);
|
|
150
|
-
}
|
|
151
|
-
set_content_start_delta(node_index, delta) {
|
|
152
|
-
this.view.setUint16(this.node_offset(node_index) + 16, delta, true);
|
|
153
|
-
}
|
|
154
|
-
set_content_length(node_index, length) {
|
|
155
|
-
this.view.setUint16(this.node_offset(node_index) + 20, length, true);
|
|
156
|
-
}
|
|
157
|
-
set_attr_operator(node_index, operator) {
|
|
158
|
-
this.view.setUint8(this.node_offset(node_index) + 32, operator);
|
|
159
|
-
}
|
|
160
|
-
set_attr_flags(node_index, flags) {
|
|
161
|
-
this.view.setUint8(this.node_offset(node_index) + 33, flags);
|
|
162
|
-
}
|
|
163
|
-
set_first_child(node_index, childIndex) {
|
|
164
|
-
this.view.setUint32(this.node_offset(node_index) + 4, childIndex, true);
|
|
165
|
-
}
|
|
166
|
-
set_next_sibling(node_index, siblingIndex) {
|
|
167
|
-
this.view.setUint32(this.node_offset(node_index) + 8, siblingIndex, true);
|
|
168
|
-
}
|
|
169
|
-
set_value_start_delta(node_index, delta) {
|
|
170
|
-
this.view.setUint16(this.node_offset(node_index) + 18, delta, true);
|
|
171
|
-
}
|
|
172
|
-
set_value_length(node_index, length) {
|
|
173
|
-
this.view.setUint16(this.node_offset(node_index) + 22, length, true);
|
|
174
|
-
}
|
|
175
|
-
grow() {
|
|
176
|
-
this.growth_count++;
|
|
177
|
-
let new_capacity = Math.ceil(this.capacity * CSSDataArena.GROWTH_FACTOR);
|
|
178
|
-
let new_buffer = new ArrayBuffer(new_capacity * BYTES_PER_NODE);
|
|
179
|
-
new Uint8Array(new_buffer).set(new Uint8Array(this.buffer));
|
|
180
|
-
this.buffer = new_buffer;
|
|
181
|
-
this.view = new DataView(new_buffer);
|
|
182
|
-
this.capacity = new_capacity;
|
|
183
|
-
}
|
|
184
|
-
create_node(type, start_offset, length, start_line, start_column) {
|
|
185
|
-
if (this.count >= this.capacity) this.grow();
|
|
186
|
-
const node_index = this.count;
|
|
187
|
-
this.count++;
|
|
188
|
-
const offset = node_index * BYTES_PER_NODE;
|
|
189
|
-
this.view.setUint8(offset, type);
|
|
190
|
-
this.view.setUint32(offset + 12, start_offset, true);
|
|
191
|
-
this.view.setUint32(offset + 24, start_line, true);
|
|
192
|
-
this.view.setUint32(offset + 28, start_column, true);
|
|
193
|
-
this.set_length(node_index, length);
|
|
194
|
-
return node_index;
|
|
195
|
-
}
|
|
196
|
-
append_children(parent_index, children) {
|
|
197
|
-
if (children.length === 0) return;
|
|
198
|
-
const offset = this.node_offset(parent_index);
|
|
199
|
-
this.view.setUint32(offset + 4, children[0], true);
|
|
200
|
-
for (let i = 0; i < children.length - 1; i++) this.set_next_sibling(children[i], children[i + 1]);
|
|
201
|
-
}
|
|
202
|
-
has_children(node_index) {
|
|
203
|
-
return this.get_first_child(node_index) !== 0;
|
|
204
|
-
}
|
|
205
|
-
has_next_sibling(node_index) {
|
|
206
|
-
return this.get_next_sibling(node_index) !== 0;
|
|
207
|
-
}
|
|
208
|
-
set_flag(node_index, flag) {
|
|
209
|
-
let current_flags = this.get_flags(node_index);
|
|
210
|
-
this.set_flags(node_index, current_flags | flag);
|
|
211
|
-
}
|
|
212
|
-
clear_flag(node_index, flag) {
|
|
213
|
-
let current_flags = this.get_flags(node_index);
|
|
214
|
-
this.set_flags(node_index, current_flags & ~flag);
|
|
215
|
-
}
|
|
216
|
-
has_flag(node_index, flag) {
|
|
217
|
-
return (this.get_flags(node_index) & flag) !== 0;
|
|
218
|
-
}
|
|
219
|
-
};
|
|
220
|
-
//#endregion
|
|
221
3
|
//#region src/css-node.ts
|
|
222
4
|
const TYPE_NAMES = {
|
|
223
5
|
[1]: "StyleSheet",
|
|
@@ -644,4 +426,4 @@ var CSSNode = class CSSNode {
|
|
|
644
426
|
}
|
|
645
427
|
};
|
|
646
428
|
//#endregion
|
|
647
|
-
export {
|
|
429
|
+
export { TYPE_NAMES as i, ATTR_OPERATOR_NAMES as n, CSSNode as r, ATTR_FLAG_NAMES as t };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,43 +1,15 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
import {
|
|
1
|
+
import { A as MEDIA_FEATURE, B as PSEUDO_CLASS_SELECTOR, C as FLAG_IMPORTANT, 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, a as ATTR_OPERATOR_CARET_EQUAL, b as DECLARATION, c as ATTR_OPERATOR_NONE, d as ATTR_OPERATOR_TILDE_EQUAL, f as AT_RULE, g as COMBINATOR, h as CLASS_SELECTOR, i as ATTR_FLAG_NONE, j as MEDIA_QUERY, k as LAYER_NAME, l as ATTR_OPERATOR_PIPE_EQUAL, m as BLOCK, n as ATTR_FLAG_CASE_INSENSITIVE, o as ATTR_OPERATOR_DOLLAR_EQUAL, p as AT_RULE_PRELUDE, q as STYLE_RULE, r as ATTR_FLAG_CASE_SENSITIVE, s as ATTR_OPERATOR_EQUAL, t as ATTRIBUTE_SELECTOR, u as ATTR_OPERATOR_STAR_EQUAL, v as CONTAINER_QUERY, w as FUNCTION, x as DIMENSION, z as PRELUDE_OPERATOR } from "./arena-BtlVZlkG.js";
|
|
2
|
+
import { NODE_TYPES } from "./constants.js";
|
|
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-CyiJelQC.js";
|
|
4
|
+
import { a as CloneOptions, i as CSSNodeType, n as ATTR_OPERATOR_NAMES, o as PlainCSSNode, r as CSSNode, s as TYPE_NAMES, t as ATTR_FLAG_NAMES } from "./css-node-B9tSb6YD.js";
|
|
3
5
|
import { ParserOptions, parse } from "./parse.js";
|
|
4
6
|
import { parse_selector } from "./parse-selector.js";
|
|
5
7
|
import { parse_atrule_prelude } from "./parse-atrule-prelude.js";
|
|
6
8
|
import { parse_declaration } from "./parse-declaration.js";
|
|
7
9
|
import { parse_value } from "./parse-value.js";
|
|
8
10
|
import { parse_dimension } from "./parse-dimension.js";
|
|
11
|
+
import { BREAK, SKIP, traverse, walk } from "./walk.js";
|
|
9
12
|
|
|
10
|
-
//#region src/walk.d.ts
|
|
11
|
-
declare const SKIP: unique symbol;
|
|
12
|
-
declare const BREAK: unique symbol;
|
|
13
|
-
type WalkCallback = (node: CSSNode, depth: number) => void | typeof SKIP | typeof BREAK;
|
|
14
|
-
/**
|
|
15
|
-
* Walk the AST in depth-first order, calling the callback for each node.
|
|
16
|
-
* Return SKIP to skip children, BREAK to stop traversal. See API.md for examples.
|
|
17
|
-
*
|
|
18
|
-
* @param node - The root node to start walking from
|
|
19
|
-
* @param callback - Function called for each node. Receives the node and its nesting depth.
|
|
20
|
-
* Depth increments only for STYLE_RULE and AT_RULE nodes (tracks rule nesting, not tree depth).
|
|
21
|
-
* @param depth - Starting depth (default: 0)
|
|
22
|
-
*/
|
|
23
|
-
declare function walk(node: CSSNode, callback: WalkCallback, depth?: number): boolean;
|
|
24
|
-
type WalkEnterLeaveCallback = (node: CSSNode) => void | typeof SKIP | typeof BREAK;
|
|
25
|
-
interface WalkEnterLeaveOptions {
|
|
26
|
-
enter?: WalkEnterLeaveCallback;
|
|
27
|
-
leave?: WalkEnterLeaveCallback;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Walk the AST in depth-first order, calling enter before visiting children and leave after.
|
|
31
|
-
* Return SKIP in enter to skip children (leave still called), BREAK to stop (leave NOT called). See API.md for examples.
|
|
32
|
-
*
|
|
33
|
-
* @param node - The root node to start walking from
|
|
34
|
-
* @param options - Object with optional enter and leave callback functions
|
|
35
|
-
*/
|
|
36
|
-
declare function traverse(node: CSSNode, {
|
|
37
|
-
enter,
|
|
38
|
-
leave
|
|
39
|
-
}?: WalkEnterLeaveOptions): boolean;
|
|
40
|
-
//#endregion
|
|
41
13
|
//#region src/string-utils.d.ts
|
|
42
14
|
/**
|
|
43
15
|
* @param a Base string, MUST be lowercase!
|
|
@@ -103,48 +75,4 @@ declare function is_vendor_prefixed(source: string, start: number, end: number):
|
|
|
103
75
|
*/
|
|
104
76
|
declare function is_custom(str: string): boolean;
|
|
105
77
|
//#endregion
|
|
106
|
-
//#region src/constants.d.ts
|
|
107
|
-
declare const NODE_TYPES: {
|
|
108
|
-
readonly STYLESHEET: 1;
|
|
109
|
-
readonly STYLE_RULE: 2;
|
|
110
|
-
readonly AT_RULE: 3;
|
|
111
|
-
readonly DECLARATION: 4;
|
|
112
|
-
readonly SELECTOR: 5;
|
|
113
|
-
readonly COMMENT: 6;
|
|
114
|
-
readonly BLOCK: 7;
|
|
115
|
-
readonly RAW: 8;
|
|
116
|
-
readonly IDENTIFIER: 10;
|
|
117
|
-
readonly NUMBER: 11;
|
|
118
|
-
readonly DIMENSION: 12;
|
|
119
|
-
readonly STRING: 13;
|
|
120
|
-
readonly HASH: 14;
|
|
121
|
-
readonly FUNCTION: 15;
|
|
122
|
-
readonly OPERATOR: 16;
|
|
123
|
-
readonly PARENTHESIS: 17;
|
|
124
|
-
readonly URL: 18;
|
|
125
|
-
readonly VALUE: 50;
|
|
126
|
-
readonly SELECTOR_LIST: 20;
|
|
127
|
-
readonly TYPE_SELECTOR: 21;
|
|
128
|
-
readonly CLASS_SELECTOR: 22;
|
|
129
|
-
readonly ID_SELECTOR: 23;
|
|
130
|
-
readonly ATTRIBUTE_SELECTOR: 24;
|
|
131
|
-
readonly PSEUDO_CLASS_SELECTOR: 25;
|
|
132
|
-
readonly PSEUDO_ELEMENT_SELECTOR: 26;
|
|
133
|
-
readonly COMBINATOR: 27;
|
|
134
|
-
readonly UNIVERSAL_SELECTOR: 28;
|
|
135
|
-
readonly NESTING_SELECTOR: 29;
|
|
136
|
-
readonly NTH_SELECTOR: 30;
|
|
137
|
-
readonly NTH_OF_SELECTOR: 31;
|
|
138
|
-
readonly LANG_SELECTOR: 56;
|
|
139
|
-
readonly MEDIA_QUERY: 32;
|
|
140
|
-
readonly MEDIA_FEATURE: 33;
|
|
141
|
-
readonly MEDIA_TYPE: 34;
|
|
142
|
-
readonly CONTAINER_QUERY: 35;
|
|
143
|
-
readonly SUPPORTS_QUERY: 36;
|
|
144
|
-
readonly LAYER_NAME: 37;
|
|
145
|
-
readonly PRELUDE_OPERATOR: 38;
|
|
146
|
-
readonly FEATURE_RANGE: 39;
|
|
147
|
-
readonly AT_RULE_PRELUDE: 40;
|
|
148
|
-
};
|
|
149
|
-
//#endregion
|
|
150
78
|
export { ATTRIBUTE_SELECTOR, ATTR_FLAG_CASE_INSENSITIVE, ATTR_FLAG_CASE_SENSITIVE, ATTR_FLAG_NAMES, ATTR_FLAG_NONE, ATTR_OPERATOR_CARET_EQUAL, ATTR_OPERATOR_DOLLAR_EQUAL, ATTR_OPERATOR_EQUAL, ATTR_OPERATOR_NAMES, ATTR_OPERATOR_NONE, ATTR_OPERATOR_PIPE_EQUAL, ATTR_OPERATOR_STAR_EQUAL, ATTR_OPERATOR_TILDE_EQUAL, AT_RULE, AT_RULE_PRELUDE, BLOCK, BREAK, CLASS_SELECTOR, COMBINATOR, COMMENT, CONTAINER_QUERY, CSSNode, type CSSNodeType, type CloneOptions, type CommentInfo, DECLARATION, DIMENSION, FEATURE_RANGE, FLAG_IMPORTANT, FUNCTION, HASH, IDENTIFIER, ID_SELECTOR, LANG_SELECTOR, LAYER_NAME, type LexerPosition, 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, type ParserOptions, type PlainCSSNode, RAW, SELECTOR, SELECTOR_LIST, SKIP, STRING, STYLESHEET, STYLE_RULE, SUPPORTS_QUERY, 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, Token, TokenType, UNIVERSAL_SELECTOR, URL, VALUE, is_custom, is_vendor_prefixed, parse, parse_atrule_prelude, parse_declaration, parse_dimension, parse_selector, parse_value, str_equals, str_index_of, str_starts_with, tokenize, traverse, walk };
|
package/dist/index.js
CHANGED
|
@@ -1,103 +1,12 @@
|
|
|
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-BSycRGm0.js";
|
|
2
|
-
import {
|
|
2
|
+
import { A as MEDIA_FEATURE, B as PSEUDO_CLASS_SELECTOR, C as FLAG_IMPORTANT, 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, a as ATTR_OPERATOR_CARET_EQUAL, b as DECLARATION, c as ATTR_OPERATOR_NONE, d as ATTR_OPERATOR_TILDE_EQUAL, f as AT_RULE, g as COMBINATOR, h as CLASS_SELECTOR, i as ATTR_FLAG_NONE, j as MEDIA_QUERY, k as LAYER_NAME, l as ATTR_OPERATOR_PIPE_EQUAL, m as BLOCK, n as ATTR_FLAG_CASE_INSENSITIVE, o as ATTR_OPERATOR_DOLLAR_EQUAL, p as AT_RULE_PRELUDE, q as STYLE_RULE, r as ATTR_FLAG_CASE_SENSITIVE, s as ATTR_OPERATOR_EQUAL, t as ATTRIBUTE_SELECTOR, u as ATTR_OPERATOR_STAR_EQUAL, v as CONTAINER_QUERY, w as FUNCTION, x as DIMENSION, z as PRELUDE_OPERATOR } from "./arena-CDAx4eAB.js";
|
|
3
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-CCn_XRDe.js";
|
|
4
|
+
import { i as TYPE_NAMES, n as ATTR_OPERATOR_NAMES, r as CSSNode, t as ATTR_FLAG_NAMES } from "./css-node-CZf-PvCf.js";
|
|
4
5
|
import { parse_selector } from "./parse-selector.js";
|
|
5
6
|
import { parse_atrule_prelude } from "./parse-atrule-prelude.js";
|
|
6
7
|
import { parse_value } from "./parse-value.js";
|
|
7
8
|
import { parse_declaration } from "./parse-declaration.js";
|
|
8
9
|
import { parse } from "./parse.js";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
STYLESHEET: 1,
|
|
12
|
-
STYLE_RULE: 2,
|
|
13
|
-
AT_RULE: 3,
|
|
14
|
-
DECLARATION: 4,
|
|
15
|
-
SELECTOR: 5,
|
|
16
|
-
COMMENT: 6,
|
|
17
|
-
BLOCK: 7,
|
|
18
|
-
RAW: 8,
|
|
19
|
-
IDENTIFIER: 10,
|
|
20
|
-
NUMBER: 11,
|
|
21
|
-
DIMENSION: 12,
|
|
22
|
-
STRING: 13,
|
|
23
|
-
HASH: 14,
|
|
24
|
-
FUNCTION: 15,
|
|
25
|
-
OPERATOR: 16,
|
|
26
|
-
PARENTHESIS: 17,
|
|
27
|
-
URL: 18,
|
|
28
|
-
VALUE: 50,
|
|
29
|
-
SELECTOR_LIST: 20,
|
|
30
|
-
TYPE_SELECTOR: 21,
|
|
31
|
-
CLASS_SELECTOR: 22,
|
|
32
|
-
ID_SELECTOR: 23,
|
|
33
|
-
ATTRIBUTE_SELECTOR: 24,
|
|
34
|
-
PSEUDO_CLASS_SELECTOR: 25,
|
|
35
|
-
PSEUDO_ELEMENT_SELECTOR: 26,
|
|
36
|
-
COMBINATOR: 27,
|
|
37
|
-
UNIVERSAL_SELECTOR: 28,
|
|
38
|
-
NESTING_SELECTOR: 29,
|
|
39
|
-
NTH_SELECTOR: 30,
|
|
40
|
-
NTH_OF_SELECTOR: 31,
|
|
41
|
-
LANG_SELECTOR: 56,
|
|
42
|
-
MEDIA_QUERY: 32,
|
|
43
|
-
MEDIA_FEATURE: 33,
|
|
44
|
-
MEDIA_TYPE: 34,
|
|
45
|
-
CONTAINER_QUERY: 35,
|
|
46
|
-
SUPPORTS_QUERY: 36,
|
|
47
|
-
LAYER_NAME: 37,
|
|
48
|
-
PRELUDE_OPERATOR: 38,
|
|
49
|
-
FEATURE_RANGE: 39,
|
|
50
|
-
AT_RULE_PRELUDE: 40
|
|
51
|
-
};
|
|
52
|
-
//#endregion
|
|
53
|
-
//#region src/walk.ts
|
|
54
|
-
const SKIP = Symbol("SKIP");
|
|
55
|
-
const BREAK = Symbol("BREAK");
|
|
56
|
-
/**
|
|
57
|
-
* Walk the AST in depth-first order, calling the callback for each node.
|
|
58
|
-
* Return SKIP to skip children, BREAK to stop traversal. See API.md for examples.
|
|
59
|
-
*
|
|
60
|
-
* @param node - The root node to start walking from
|
|
61
|
-
* @param callback - Function called for each node. Receives the node and its nesting depth.
|
|
62
|
-
* Depth increments only for STYLE_RULE and AT_RULE nodes (tracks rule nesting, not tree depth).
|
|
63
|
-
* @param depth - Starting depth (default: 0)
|
|
64
|
-
*/
|
|
65
|
-
function walk(node, callback, depth = 0) {
|
|
66
|
-
const result = callback(node, depth);
|
|
67
|
-
if (result === BREAK) return false;
|
|
68
|
-
if (result === SKIP) return true;
|
|
69
|
-
let child_depth = depth;
|
|
70
|
-
if (node.type === 2 || node.type === 3) child_depth = depth + 1;
|
|
71
|
-
let child = node.first_child;
|
|
72
|
-
while (child) {
|
|
73
|
-
if (!walk(child, callback, child_depth)) return false;
|
|
74
|
-
child = child.next_sibling;
|
|
75
|
-
}
|
|
76
|
-
return true;
|
|
77
|
-
}
|
|
78
|
-
const NOOP = function() {};
|
|
79
|
-
/**
|
|
80
|
-
* Walk the AST in depth-first order, calling enter before visiting children and leave after.
|
|
81
|
-
* Return SKIP in enter to skip children (leave still called), BREAK to stop (leave NOT called). See API.md for examples.
|
|
82
|
-
*
|
|
83
|
-
* @param node - The root node to start walking from
|
|
84
|
-
* @param options - Object with optional enter and leave callback functions
|
|
85
|
-
*/
|
|
86
|
-
function traverse(node, { enter = NOOP, leave = NOOP } = {}) {
|
|
87
|
-
const enter_result = enter(node);
|
|
88
|
-
if (enter_result === BREAK) return false;
|
|
89
|
-
if (enter_result !== SKIP) {
|
|
90
|
-
let child = node.first_child;
|
|
91
|
-
while (child) {
|
|
92
|
-
if (!traverse(child, {
|
|
93
|
-
enter,
|
|
94
|
-
leave
|
|
95
|
-
})) return false;
|
|
96
|
-
child = child.next_sibling;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
if (leave(node) === BREAK) return false;
|
|
100
|
-
return true;
|
|
101
|
-
}
|
|
102
|
-
//#endregion
|
|
10
|
+
import { NODE_TYPES } from "./constants.js";
|
|
11
|
+
import { BREAK, SKIP, traverse, walk } from "./walk.js";
|
|
103
12
|
export { ATTRIBUTE_SELECTOR, ATTR_FLAG_CASE_INSENSITIVE, ATTR_FLAG_CASE_SENSITIVE, ATTR_FLAG_NAMES, ATTR_FLAG_NONE, ATTR_OPERATOR_CARET_EQUAL, ATTR_OPERATOR_DOLLAR_EQUAL, ATTR_OPERATOR_EQUAL, ATTR_OPERATOR_NAMES, ATTR_OPERATOR_NONE, ATTR_OPERATOR_PIPE_EQUAL, ATTR_OPERATOR_STAR_EQUAL, ATTR_OPERATOR_TILDE_EQUAL, AT_RULE, AT_RULE_PRELUDE, BLOCK, BREAK, CLASS_SELECTOR, COMBINATOR, COMMENT, CONTAINER_QUERY, CSSNode, DECLARATION, DIMENSION, FEATURE_RANGE, FLAG_IMPORTANT, FUNCTION, HASH, IDENTIFIER, ID_SELECTOR, 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, RAW, SELECTOR, SELECTOR_LIST, SKIP, STRING, STYLESHEET, STYLE_RULE, SUPPORTS_QUERY, 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, UNIVERSAL_SELECTOR, URL, VALUE, is_custom, is_vendor_prefixed, parse, parse_atrule_prelude, parse_declaration, parse_dimension, parse_selector, parse_value, str_equals, str_index_of, str_starts_with, tokenize, traverse, walk };
|
package/dist/parse-anplusb.d.ts
CHANGED
package/dist/parse-anplusb.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { t as Lexer } from "./tokenize-BSycRGm0.js";
|
|
2
|
-
import {
|
|
2
|
+
import { y as CSSDataArena } from "./arena-CDAx4eAB.js";
|
|
3
3
|
import { o as str_equals, s as str_index_of } from "./parse-dimension-CCn_XRDe.js";
|
|
4
|
+
import { r as CSSNode } from "./css-node-CZf-PvCf.js";
|
|
4
5
|
//#region src/parse-anplusb.ts
|
|
5
6
|
/** @internal */
|
|
6
7
|
var ANplusBParser = class {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { t as Lexer } from "./tokenize-BSycRGm0.js";
|
|
2
|
-
import {
|
|
2
|
+
import { y as CSSDataArena } from "./arena-CDAx4eAB.js";
|
|
3
3
|
import { a as is_whitespace, l as strip_vendor_prefix, o as str_equals } from "./parse-dimension-CCn_XRDe.js";
|
|
4
|
-
import {
|
|
4
|
+
import { r as CSSNode } from "./css-node-CZf-PvCf.js";
|
|
5
|
+
import { i as trim_boundaries, n as skip_whitespace_and_comments_forward } from "./parse-utils-BxrmqJxI.js";
|
|
5
6
|
//#region src/parse-atrule-prelude.ts
|
|
6
7
|
/** @internal */
|
|
7
8
|
var AtRulePreludeParser = class {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { y as CSSDataArena } from "./arena-BtlVZlkG.js";
|
|
2
|
+
import { n as Lexer } from "./tokenize-CyiJelQC.js";
|
|
3
|
+
import { r as CSSNode } from "./css-node-B9tSb6YD.js";
|
|
3
4
|
|
|
4
5
|
//#region src/parse-declaration.d.ts
|
|
5
6
|
/** @internal */
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { t as Lexer } from "./tokenize-BSycRGm0.js";
|
|
2
|
-
import {
|
|
2
|
+
import { y as CSSDataArena } from "./arena-CDAx4eAB.js";
|
|
3
3
|
import { i as is_vendor_prefixed } from "./parse-dimension-CCn_XRDe.js";
|
|
4
|
-
import {
|
|
4
|
+
import { r as CSSNode } from "./css-node-CZf-PvCf.js";
|
|
5
|
+
import { i as trim_boundaries } from "./parse-utils-BxrmqJxI.js";
|
|
5
6
|
import { ValueParser } from "./parse-value.js";
|
|
6
7
|
//#region src/parse-declaration.ts
|
|
7
8
|
/** @internal */
|
package/dist/parse-selector.d.ts
CHANGED
package/dist/parse-selector.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { t as Lexer } from "./tokenize-BSycRGm0.js";
|
|
2
|
-
import {
|
|
2
|
+
import { y as CSSDataArena } from "./arena-CDAx4eAB.js";
|
|
3
3
|
import { a as is_whitespace, n as is_combinator, o as str_equals } from "./parse-dimension-CCn_XRDe.js";
|
|
4
|
-
import {
|
|
4
|
+
import { r as CSSNode } from "./css-node-CZf-PvCf.js";
|
|
5
|
+
import { n as skip_whitespace_and_comments_forward, r as skip_whitespace_forward, t as skip_whitespace_and_comments_backward } from "./parse-utils-BxrmqJxI.js";
|
|
5
6
|
import { ANplusBParser } from "./parse-anplusb.js";
|
|
6
7
|
//#region src/parse-selector.ts
|
|
7
8
|
/** @internal */
|
package/dist/parse-value.d.ts
CHANGED
package/dist/parse-value.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { t as Lexer } from "./tokenize-BSycRGm0.js";
|
|
2
|
-
import {
|
|
2
|
+
import { y as CSSDataArena } from "./arena-CDAx4eAB.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-CZf-PvCf.js";
|
|
4
5
|
//#region src/parse-value.ts
|
|
5
6
|
/** @internal */
|
|
6
7
|
var ValueParser = class {
|
package/dist/parse.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { y as CSSDataArena } from "./arena-BtlVZlkG.js";
|
|
2
|
+
import { t as CommentInfo } from "./tokenize-CyiJelQC.js";
|
|
3
|
+
import { r as CSSNode } from "./css-node-B9tSb6YD.js";
|
|
3
4
|
|
|
4
5
|
//#region src/parse.d.ts
|
|
5
6
|
interface ParserOptions {
|
package/dist/parse.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { t as Lexer } from "./tokenize-BSycRGm0.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { y as CSSDataArena } from "./arena-CDAx4eAB.js";
|
|
3
|
+
import { r as CSSNode } from "./css-node-CZf-PvCf.js";
|
|
4
|
+
import { i as trim_boundaries } from "./parse-utils-BxrmqJxI.js";
|
|
4
5
|
import { SelectorParser } from "./parse-selector.js";
|
|
5
6
|
import { AtRulePreludeParser } from "./parse-atrule-prelude.js";
|
|
6
7
|
import { DeclarationParser } from "./parse-declaration.js";
|
package/dist/tokenize.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as tokenize, n as Lexer, r as LexerPosition, t as CommentInfo } from "./tokenize-
|
|
1
|
+
import { i as tokenize, n as Lexer, r as LexerPosition, t as CommentInfo } from "./tokenize-CyiJelQC.js";
|
|
2
2
|
export { CommentInfo, Lexer, LexerPosition, tokenize };
|
package/dist/walk.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { r as CSSNode } from "./css-node-B9tSb6YD.js";
|
|
2
|
+
|
|
3
|
+
//#region src/walk.d.ts
|
|
4
|
+
declare const SKIP: unique symbol;
|
|
5
|
+
declare const BREAK: unique symbol;
|
|
6
|
+
type WalkCallback = (node: CSSNode, depth: number) => void | typeof SKIP | typeof BREAK;
|
|
7
|
+
/**
|
|
8
|
+
* Walk the AST in depth-first order, calling the callback for each node.
|
|
9
|
+
* Return SKIP to skip children, BREAK to stop traversal. See API.md for examples.
|
|
10
|
+
*
|
|
11
|
+
* @param node - The root node to start walking from
|
|
12
|
+
* @param callback - Function called for each node. Receives the node and its nesting depth.
|
|
13
|
+
* Depth increments only for STYLE_RULE and AT_RULE nodes (tracks rule nesting, not tree depth).
|
|
14
|
+
* @param depth - Starting depth (default: 0)
|
|
15
|
+
*/
|
|
16
|
+
declare function walk(node: CSSNode, callback: WalkCallback, depth?: number): boolean;
|
|
17
|
+
type WalkEnterLeaveCallback = (node: CSSNode) => void | typeof SKIP | typeof BREAK;
|
|
18
|
+
interface WalkEnterLeaveOptions {
|
|
19
|
+
enter?: WalkEnterLeaveCallback;
|
|
20
|
+
leave?: WalkEnterLeaveCallback;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Walk the AST in depth-first order, calling enter before visiting children and leave after.
|
|
24
|
+
* Return SKIP in enter to skip children (leave still called), BREAK to stop (leave NOT called). See API.md for examples.
|
|
25
|
+
*
|
|
26
|
+
* @param node - The root node to start walking from
|
|
27
|
+
* @param options - Object with optional enter and leave callback functions
|
|
28
|
+
*/
|
|
29
|
+
declare function traverse(node: CSSNode, {
|
|
30
|
+
enter,
|
|
31
|
+
leave
|
|
32
|
+
}?: WalkEnterLeaveOptions): boolean;
|
|
33
|
+
//#endregion
|
|
34
|
+
export { BREAK, SKIP, traverse, walk };
|
package/dist/walk.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import "./arena-CDAx4eAB.js";
|
|
2
|
+
import "./constants.js";
|
|
3
|
+
//#region src/walk.ts
|
|
4
|
+
const SKIP = Symbol("SKIP");
|
|
5
|
+
const BREAK = Symbol("BREAK");
|
|
6
|
+
/**
|
|
7
|
+
* Walk the AST in depth-first order, calling the callback for each node.
|
|
8
|
+
* Return SKIP to skip children, BREAK to stop traversal. See API.md for examples.
|
|
9
|
+
*
|
|
10
|
+
* @param node - The root node to start walking from
|
|
11
|
+
* @param callback - Function called for each node. Receives the node and its nesting depth.
|
|
12
|
+
* Depth increments only for STYLE_RULE and AT_RULE nodes (tracks rule nesting, not tree depth).
|
|
13
|
+
* @param depth - Starting depth (default: 0)
|
|
14
|
+
*/
|
|
15
|
+
function walk(node, callback, depth = 0) {
|
|
16
|
+
const result = callback(node, depth);
|
|
17
|
+
if (result === BREAK) return false;
|
|
18
|
+
if (result === SKIP) return true;
|
|
19
|
+
let child_depth = depth;
|
|
20
|
+
if (node.type === 2 || node.type === 3) child_depth = depth + 1;
|
|
21
|
+
let child = node.first_child;
|
|
22
|
+
while (child) {
|
|
23
|
+
if (!walk(child, callback, child_depth)) return false;
|
|
24
|
+
child = child.next_sibling;
|
|
25
|
+
}
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
const NOOP = function() {};
|
|
29
|
+
/**
|
|
30
|
+
* Walk the AST in depth-first order, calling enter before visiting children and leave after.
|
|
31
|
+
* Return SKIP in enter to skip children (leave still called), BREAK to stop (leave NOT called). See API.md for examples.
|
|
32
|
+
*
|
|
33
|
+
* @param node - The root node to start walking from
|
|
34
|
+
* @param options - Object with optional enter and leave callback functions
|
|
35
|
+
*/
|
|
36
|
+
function traverse(node, { enter = NOOP, leave = NOOP } = {}) {
|
|
37
|
+
const enter_result = enter(node);
|
|
38
|
+
if (enter_result === BREAK) return false;
|
|
39
|
+
if (enter_result !== SKIP) {
|
|
40
|
+
let child = node.first_child;
|
|
41
|
+
while (child) {
|
|
42
|
+
if (!traverse(child, {
|
|
43
|
+
enter,
|
|
44
|
+
leave
|
|
45
|
+
})) return false;
|
|
46
|
+
child = child.next_sibling;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (leave(node) === BREAK) return false;
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
export { BREAK, SKIP, traverse, walk };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@projectwallace/css-parser",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.10",
|
|
4
4
|
"description": "High-performance CSS lexer and parser, optimized for CSS inspection and analysis",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ast",
|
|
@@ -60,6 +60,14 @@
|
|
|
60
60
|
"./parse-dimension": {
|
|
61
61
|
"types": "./dist/parse-dimension.d.ts",
|
|
62
62
|
"import": "./dist/parse-dimension.js"
|
|
63
|
+
},
|
|
64
|
+
"./walker": {
|
|
65
|
+
"types": "./dist/walk.d.ts",
|
|
66
|
+
"import": "./dist/walk.js"
|
|
67
|
+
},
|
|
68
|
+
"./nodes": {
|
|
69
|
+
"types": "./dist/constants.d.ts",
|
|
70
|
+
"import": "./dist/constants.js"
|
|
63
71
|
}
|
|
64
72
|
},
|
|
65
73
|
"scripts": {
|
|
@@ -81,8 +89,8 @@
|
|
|
81
89
|
"@vitest/coverage-v8": "^4.0.8",
|
|
82
90
|
"bootstrap": "^5.3.8",
|
|
83
91
|
"css-tree": "^3.1.0",
|
|
84
|
-
"knip": "^
|
|
85
|
-
"oxfmt": "^0.
|
|
92
|
+
"knip": "^6.0.1",
|
|
93
|
+
"oxfmt": "^0.41.0",
|
|
86
94
|
"oxlint": "^1.28.0",
|
|
87
95
|
"postcss": "^8.5.6",
|
|
88
96
|
"publint": "^0.3.18",
|
|
File without changes
|
|
File without changes
|