@projectwallace/css-parser 0.14.10 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{arena-D6TANE5e.d.ts → arena-CSK5NfHq.d.ts} +2 -1
- package/dist/{arena-CveFYH2l.js → arena-DnV0a_Ne.js} +2 -1
- package/dist/constants.d.ts +3 -2
- package/dist/constants.js +3 -2
- package/dist/{css-node-DMd5jbdm.js → css-node-BTgoFWDU.js} +34 -4
- package/dist/index.d.ts +5 -5
- package/dist/index.js +8 -5
- package/dist/{node-types-D282RMOz.d.ts → node-types-mntWKkN-.d.ts} +81 -29
- package/dist/parse-anplusb.d.ts +2 -2
- package/dist/parse-anplusb.js +6 -6
- package/dist/parse-atrule-prelude.d.ts +4 -2
- package/dist/parse-atrule-prelude.js +53 -17
- package/dist/parse-declaration.d.ts +3 -3
- package/dist/parse-declaration.js +3 -3
- package/dist/parse-selector.d.ts +6 -9
- package/dist/parse-selector.js +56 -55
- package/dist/parse-value.d.ts +2 -2
- package/dist/parse-value.js +4 -4
- package/dist/parse.d.ts +3 -3
- package/dist/parse.js +21 -21
- package/dist/{tokenize-BSycRGm0.js → tokenize-BxUina14.js} +240 -181
- package/dist/{tokenize-CyiJelQC.d.ts → tokenize-mV23Aiyb.d.ts} +1 -0
- package/dist/tokenize.d.ts +1 -1
- package/dist/tokenize.js +1 -1
- package/dist/walk.d.ts +1 -1
- package/dist/walk.js +47 -14
- package/package.json +109 -103
|
@@ -94,6 +94,7 @@ const CHAR_UPPERCASE_U = 85;
|
|
|
94
94
|
const CHAR_QUESTION_MARK = 63;
|
|
95
95
|
const CHAR_CARRIAGE_RETURN = 13;
|
|
96
96
|
const CHAR_LINE_FEED = 10;
|
|
97
|
+
const CHAR_FORM_FEED = 12;
|
|
97
98
|
/** @internal */
|
|
98
99
|
var Lexer = class {
|
|
99
100
|
source;
|
|
@@ -130,205 +131,255 @@ var Lexer = class {
|
|
|
130
131
|
this._line_offset = pos - column + 1;
|
|
131
132
|
}
|
|
132
133
|
next_token_fast(skip_whitespace = false) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
this.
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
case CHAR_LEFT_BRACE:
|
|
145
|
-
this.advance();
|
|
146
|
-
return this.make_token(23, start, this.pos, start_line, start_column);
|
|
147
|
-
case CHAR_RIGHT_BRACE:
|
|
148
|
-
this.advance();
|
|
149
|
-
return this.make_token(24, start, this.pos, start_line, start_column);
|
|
150
|
-
case CHAR_COLON:
|
|
151
|
-
this.advance();
|
|
152
|
-
return this.make_token(16, start, this.pos, start_line, start_column);
|
|
153
|
-
case CHAR_SEMICOLON:
|
|
154
|
-
this.advance();
|
|
155
|
-
return this.make_token(17, start, this.pos, start_line, start_column);
|
|
156
|
-
case CHAR_COMMA:
|
|
157
|
-
this.advance();
|
|
158
|
-
return this.make_token(18, start, this.pos, start_line, start_column);
|
|
159
|
-
case CHAR_LEFT_BRACKET:
|
|
160
|
-
this.advance();
|
|
161
|
-
return this.make_token(19, start, this.pos, start_line, start_column);
|
|
162
|
-
case CHAR_RIGHT_BRACKET:
|
|
163
|
-
this.advance();
|
|
164
|
-
return this.make_token(20, start, this.pos, start_line, start_column);
|
|
165
|
-
case CHAR_LEFT_PAREN:
|
|
166
|
-
this.advance();
|
|
167
|
-
return this.make_token(21, start, this.pos, start_line, start_column);
|
|
168
|
-
case CHAR_RIGHT_PAREN:
|
|
169
|
-
this.advance();
|
|
170
|
-
return this.make_token(22, start, this.pos, start_line, start_column);
|
|
171
|
-
}
|
|
172
|
-
if (ch < 128 && (char_types[ch] & 24) !== 0) return this.consume_whitespace(start_line, start_column);
|
|
173
|
-
if (ch === CHAR_FORWARD_SLASH && this.peek() === CHAR_ASTERISK) {
|
|
174
|
-
let comment_start = start;
|
|
175
|
-
let comment_line = start_line;
|
|
176
|
-
let comment_column = start_column;
|
|
177
|
-
this.advance(2);
|
|
178
|
-
while (this.pos < this.source.length - 1) {
|
|
179
|
-
if (this.source.charCodeAt(this.pos) === CHAR_ASTERISK && this.peek() === CHAR_FORWARD_SLASH) {
|
|
180
|
-
this.advance(2);
|
|
181
|
-
break;
|
|
134
|
+
const source = this.source;
|
|
135
|
+
const source_length = source.length;
|
|
136
|
+
while (true) {
|
|
137
|
+
if (skip_whitespace) while (this.pos < source_length) {
|
|
138
|
+
let ch = source.charCodeAt(this.pos);
|
|
139
|
+
if (ch >= 128 || (char_types[ch] & 24) === 0) break;
|
|
140
|
+
this.pos++;
|
|
141
|
+
if ((char_types[ch] & 16) !== 0) {
|
|
142
|
+
if (ch === CHAR_CARRIAGE_RETURN && this.pos < source_length && source.charCodeAt(this.pos) === CHAR_LINE_FEED) this.pos++;
|
|
143
|
+
this._line++;
|
|
144
|
+
this._line_offset = this.pos;
|
|
182
145
|
}
|
|
183
|
-
this.advance();
|
|
184
146
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
147
|
+
if (this.pos >= source_length) return this.make_token(26, this.pos, this.pos);
|
|
148
|
+
let ch = source.charCodeAt(this.pos);
|
|
149
|
+
let start = this.pos;
|
|
150
|
+
let start_line = this._line;
|
|
151
|
+
let start_column = this.pos - this._line_offset + 1;
|
|
152
|
+
switch (ch) {
|
|
153
|
+
case CHAR_LEFT_BRACE:
|
|
154
|
+
this.pos++;
|
|
155
|
+
return this.make_token(23, start, this.pos, start_line, start_column);
|
|
156
|
+
case CHAR_RIGHT_BRACE:
|
|
157
|
+
this.pos++;
|
|
158
|
+
return this.make_token(24, start, this.pos, start_line, start_column);
|
|
159
|
+
case CHAR_COLON:
|
|
160
|
+
this.pos++;
|
|
161
|
+
return this.make_token(16, start, this.pos, start_line, start_column);
|
|
162
|
+
case CHAR_SEMICOLON:
|
|
163
|
+
this.pos++;
|
|
164
|
+
return this.make_token(17, start, this.pos, start_line, start_column);
|
|
165
|
+
case CHAR_COMMA:
|
|
166
|
+
this.pos++;
|
|
167
|
+
return this.make_token(18, start, this.pos, start_line, start_column);
|
|
168
|
+
case CHAR_LEFT_BRACKET:
|
|
169
|
+
this.pos++;
|
|
170
|
+
return this.make_token(19, start, this.pos, start_line, start_column);
|
|
171
|
+
case CHAR_RIGHT_BRACKET:
|
|
172
|
+
this.pos++;
|
|
173
|
+
return this.make_token(20, start, this.pos, start_line, start_column);
|
|
174
|
+
case CHAR_LEFT_PAREN:
|
|
175
|
+
this.pos++;
|
|
176
|
+
return this.make_token(21, start, this.pos, start_line, start_column);
|
|
177
|
+
case CHAR_RIGHT_PAREN:
|
|
178
|
+
this.pos++;
|
|
179
|
+
return this.make_token(22, start, this.pos, start_line, start_column);
|
|
205
180
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
181
|
+
if (ch < 128 && (char_types[ch] & 24) !== 0) return this.consume_whitespace(start_line, start_column);
|
|
182
|
+
if (ch === CHAR_FORWARD_SLASH && this.pos + 1 < source_length && source.charCodeAt(this.pos + 1) === CHAR_ASTERISK) {
|
|
183
|
+
let comment_start = start;
|
|
184
|
+
let comment_line = start_line;
|
|
185
|
+
let comment_column = start_column;
|
|
186
|
+
this.pos += 2;
|
|
187
|
+
let end_idx = source.indexOf("*/", this.pos);
|
|
188
|
+
if (end_idx < 0) {
|
|
189
|
+
this._scan_newlines(this.pos, source_length);
|
|
190
|
+
this.pos = source_length;
|
|
191
|
+
} else {
|
|
192
|
+
this._scan_newlines(this.pos, end_idx);
|
|
193
|
+
this.pos = end_idx + 2;
|
|
194
|
+
}
|
|
195
|
+
if (this.on_comment) this.on_comment({
|
|
196
|
+
start: comment_start,
|
|
197
|
+
end: this.pos,
|
|
198
|
+
length: this.pos - comment_start,
|
|
199
|
+
line: comment_line,
|
|
200
|
+
column: comment_column
|
|
201
|
+
});
|
|
202
|
+
continue;
|
|
211
203
|
}
|
|
204
|
+
if (ch === CHAR_DOUBLE_QUOTE || ch === CHAR_SINGLE_QUOTE) return this.consume_string(ch, start_line, start_column);
|
|
205
|
+
if (ch < 128 && (char_types[ch] & 2) !== 0) return this.consume_number(start_line, start_column);
|
|
206
|
+
if (ch === CHAR_DOT) {
|
|
207
|
+
let next = this.pos + 1 < source_length ? source.charCodeAt(this.pos + 1) : 0;
|
|
208
|
+
if (next < 128 && (char_types[next] & 2) !== 0) return this.consume_number(start_line, start_column);
|
|
209
|
+
}
|
|
210
|
+
if (ch === CHAR_LESS_THAN && this.pos + 3 < source_length) {
|
|
211
|
+
if (source.charCodeAt(this.pos + 1) === CHAR_EXCLAMATION && source.charCodeAt(this.pos + 2) === CHAR_HYPHEN && source.charCodeAt(this.pos + 3) === CHAR_HYPHEN) {
|
|
212
|
+
this.pos += 4;
|
|
213
|
+
return this.make_token(14, start, this.pos, start_line, start_column);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
if (ch === CHAR_HYPHEN && this.pos + 2 < source_length) {
|
|
217
|
+
if (source.charCodeAt(this.pos + 1) === CHAR_HYPHEN && source.charCodeAt(this.pos + 2) === CHAR_GREATER_THAN) {
|
|
218
|
+
this.pos += 3;
|
|
219
|
+
return this.make_token(15, start, this.pos, start_line, start_column);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
if (ch === CHAR_AT_SIGN) return this.consume_at_keyword(start_line, start_column);
|
|
223
|
+
if (ch === CHAR_HASH) return this.consume_hash(start_line, start_column);
|
|
224
|
+
if (is_ident_start(ch)) return this.consume_ident_or_function(start_line, start_column);
|
|
225
|
+
if (ch === CHAR_HYPHEN) {
|
|
226
|
+
let next = this.pos + 1 < source_length ? source.charCodeAt(this.pos + 1) : 0;
|
|
227
|
+
if (is_ident_start(next) || next === CHAR_HYPHEN) return this.consume_ident_or_function(start_line, start_column);
|
|
228
|
+
}
|
|
229
|
+
if (ch === CHAR_BACKSLASH) {
|
|
230
|
+
let next = this.pos + 1 < source_length ? source.charCodeAt(this.pos + 1) : 0;
|
|
231
|
+
if (next !== 0 && !is_newline(next)) return this.consume_ident_or_function(start_line, start_column);
|
|
232
|
+
}
|
|
233
|
+
if (ch === CHAR_HYPHEN || ch === CHAR_PLUS) {
|
|
234
|
+
let next = this.pos + 1 < source_length ? source.charCodeAt(this.pos + 1) : 0;
|
|
235
|
+
if (next < 128 && (char_types[next] & 2) !== 0) return this.consume_number(start_line, start_column);
|
|
236
|
+
if (next === CHAR_DOT) {
|
|
237
|
+
let next2 = this.pos + 2 < source_length ? source.charCodeAt(this.pos + 2) : 0;
|
|
238
|
+
if (next2 < 128 && (char_types[next2] & 2) !== 0) return this.consume_number(start_line, start_column);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
this.pos++;
|
|
242
|
+
return this.make_token(9, start, this.pos, start_line, start_column);
|
|
212
243
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
let
|
|
218
|
-
if (
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
let next2 = this.peek(2);
|
|
229
|
-
if (next2 < 128 && (char_types[next2] & 2) !== 0) return this.consume_number(start_line, start_column);
|
|
244
|
+
}
|
|
245
|
+
_scan_newlines(from, to) {
|
|
246
|
+
const source = this.source;
|
|
247
|
+
for (let i = from; i < to; i++) {
|
|
248
|
+
let c = source.charCodeAt(i);
|
|
249
|
+
if (c === CHAR_LINE_FEED) {
|
|
250
|
+
this._line++;
|
|
251
|
+
this._line_offset = i + 1;
|
|
252
|
+
} else if (c === CHAR_CARRIAGE_RETURN) {
|
|
253
|
+
this._line++;
|
|
254
|
+
if (i + 1 < to && source.charCodeAt(i + 1) === CHAR_LINE_FEED) i++;
|
|
255
|
+
this._line_offset = i + 1;
|
|
256
|
+
} else if (c === CHAR_FORM_FEED) {
|
|
257
|
+
this._line++;
|
|
258
|
+
this._line_offset = i + 1;
|
|
230
259
|
}
|
|
231
260
|
}
|
|
232
|
-
this.advance();
|
|
233
|
-
return this.make_token(9, start, this.pos, start_line, start_column);
|
|
234
261
|
}
|
|
235
262
|
consume_whitespace(start_line, start_column) {
|
|
263
|
+
const source = this.source;
|
|
264
|
+
const source_length = source.length;
|
|
236
265
|
let start = this.pos;
|
|
237
|
-
while (this.pos <
|
|
238
|
-
let ch =
|
|
266
|
+
while (this.pos < source_length) {
|
|
267
|
+
let ch = source.charCodeAt(this.pos);
|
|
239
268
|
if (ch >= 128 || (char_types[ch] & 24) === 0) break;
|
|
240
|
-
this.
|
|
269
|
+
this.pos++;
|
|
270
|
+
if ((char_types[ch] & 16) !== 0) {
|
|
271
|
+
if (ch === CHAR_CARRIAGE_RETURN && this.pos < source_length && source.charCodeAt(this.pos) === CHAR_LINE_FEED) this.pos++;
|
|
272
|
+
this._line++;
|
|
273
|
+
this._line_offset = this.pos;
|
|
274
|
+
}
|
|
241
275
|
}
|
|
242
276
|
return this.make_token(13, start, this.pos, start_line, start_column);
|
|
243
277
|
}
|
|
244
278
|
consume_string(quote, start_line, start_column) {
|
|
279
|
+
const source = this.source;
|
|
280
|
+
const source_length = source.length;
|
|
245
281
|
let start = this.pos;
|
|
246
|
-
this.
|
|
247
|
-
while (this.pos <
|
|
248
|
-
let ch =
|
|
282
|
+
this.pos++;
|
|
283
|
+
while (this.pos < source_length) {
|
|
284
|
+
let ch = source.charCodeAt(this.pos);
|
|
249
285
|
if (ch === quote) {
|
|
250
|
-
this.
|
|
286
|
+
this.pos++;
|
|
251
287
|
return this.make_token(5, start, this.pos, start_line, start_column);
|
|
252
288
|
}
|
|
253
|
-
if (
|
|
289
|
+
if (ch < 128 && (char_types[ch] & 16) !== 0) return this.make_token(6, start, this.pos, start_line, start_column);
|
|
254
290
|
if (ch === CHAR_BACKSLASH) {
|
|
255
|
-
this.
|
|
256
|
-
if (this.pos <
|
|
257
|
-
let next =
|
|
291
|
+
this.pos++;
|
|
292
|
+
if (this.pos < source_length) {
|
|
293
|
+
let next = source.charCodeAt(this.pos);
|
|
258
294
|
if (is_hex_digit(next)) this.consume_hex_escape();
|
|
259
|
-
else if (
|
|
260
|
-
|
|
295
|
+
else if (next < 128 && (char_types[next] & 16) !== 0) {
|
|
296
|
+
this.pos++;
|
|
297
|
+
if (next === CHAR_CARRIAGE_RETURN && this.pos < source_length && source.charCodeAt(this.pos) === CHAR_LINE_FEED) this.pos++;
|
|
298
|
+
this._line++;
|
|
299
|
+
this._line_offset = this.pos;
|
|
300
|
+
} else this.pos++;
|
|
261
301
|
}
|
|
262
302
|
continue;
|
|
263
303
|
}
|
|
264
|
-
this.
|
|
304
|
+
this.pos++;
|
|
265
305
|
}
|
|
266
306
|
return this.make_token(6, start, this.pos, start_line, start_column);
|
|
267
307
|
}
|
|
268
308
|
consume_hex_escape() {
|
|
309
|
+
const source = this.source;
|
|
310
|
+
const source_length = source.length;
|
|
269
311
|
let count = 0;
|
|
270
|
-
while (count < 6 && this.pos <
|
|
271
|
-
if (!is_hex_digit(
|
|
272
|
-
this.
|
|
312
|
+
while (count < 6 && this.pos < source_length) {
|
|
313
|
+
if (!is_hex_digit(source.charCodeAt(this.pos))) break;
|
|
314
|
+
this.pos++;
|
|
273
315
|
count++;
|
|
274
316
|
}
|
|
275
|
-
if (this.pos <
|
|
276
|
-
let ch =
|
|
277
|
-
if (
|
|
317
|
+
if (this.pos < source_length) {
|
|
318
|
+
let ch = source.charCodeAt(this.pos);
|
|
319
|
+
if (ch < 128 && (char_types[ch] & 24) !== 0) {
|
|
320
|
+
this.pos++;
|
|
321
|
+
if ((char_types[ch] & 16) !== 0) {
|
|
322
|
+
if (ch === CHAR_CARRIAGE_RETURN && this.pos < source_length && source.charCodeAt(this.pos) === CHAR_LINE_FEED) this.pos++;
|
|
323
|
+
this._line++;
|
|
324
|
+
this._line_offset = this.pos;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
278
327
|
}
|
|
279
328
|
}
|
|
280
329
|
consume_number(start_line, start_column) {
|
|
330
|
+
const source = this.source;
|
|
331
|
+
const source_length = source.length;
|
|
281
332
|
let start = this.pos;
|
|
282
|
-
let ch =
|
|
283
|
-
if (ch === CHAR_PLUS || ch === CHAR_HYPHEN) this.
|
|
284
|
-
while (this.pos <
|
|
285
|
-
let ch =
|
|
333
|
+
let ch = source.charCodeAt(this.pos);
|
|
334
|
+
if (ch === CHAR_PLUS || ch === CHAR_HYPHEN) this.pos++;
|
|
335
|
+
while (this.pos < source_length) {
|
|
336
|
+
let ch = source.charCodeAt(this.pos);
|
|
286
337
|
if (ch >= 128 || (char_types[ch] & 2) === 0) break;
|
|
287
|
-
this.
|
|
338
|
+
this.pos++;
|
|
288
339
|
}
|
|
289
|
-
if (this.pos <
|
|
290
|
-
let next = this.
|
|
340
|
+
if (this.pos < source_length && source.charCodeAt(this.pos) === CHAR_DOT && this.pos + 1 < source_length) {
|
|
341
|
+
let next = source.charCodeAt(this.pos + 1);
|
|
291
342
|
if (next < 128 && (char_types[next] & 2) !== 0) {
|
|
292
|
-
this.
|
|
293
|
-
while (this.pos <
|
|
294
|
-
let ch =
|
|
343
|
+
this.pos++;
|
|
344
|
+
while (this.pos < source_length) {
|
|
345
|
+
let ch = source.charCodeAt(this.pos);
|
|
295
346
|
if (ch >= 128 || (char_types[ch] & 2) === 0) break;
|
|
296
|
-
this.
|
|
347
|
+
this.pos++;
|
|
297
348
|
}
|
|
298
349
|
}
|
|
299
350
|
}
|
|
300
|
-
if (this.pos <
|
|
301
|
-
let ch =
|
|
351
|
+
if (this.pos < source_length) {
|
|
352
|
+
let ch = source.charCodeAt(this.pos);
|
|
302
353
|
if (ch === CHAR_LOWERCASE_E || ch === CHAR_UPPERCASE_E) {
|
|
303
|
-
let next = this.
|
|
354
|
+
let next = this.pos + 1 < source_length ? source.charCodeAt(this.pos + 1) : 0;
|
|
304
355
|
let is_next_digit = next < 128 && (char_types[next] & 2) !== 0;
|
|
305
|
-
let next2 = this.
|
|
356
|
+
let next2 = this.pos + 2 < source_length ? source.charCodeAt(this.pos + 2) : 0;
|
|
306
357
|
let is_next2_digit = next2 < 128 && (char_types[next2] & 2) !== 0;
|
|
307
358
|
if (is_next_digit || (next === CHAR_PLUS || next === CHAR_HYPHEN) && is_next2_digit) {
|
|
308
|
-
this.
|
|
309
|
-
if (this.pos <
|
|
310
|
-
let sign =
|
|
311
|
-
if (sign === CHAR_PLUS || sign === CHAR_HYPHEN) this.
|
|
359
|
+
this.pos++;
|
|
360
|
+
if (this.pos < source_length) {
|
|
361
|
+
let sign = source.charCodeAt(this.pos);
|
|
362
|
+
if (sign === CHAR_PLUS || sign === CHAR_HYPHEN) this.pos++;
|
|
312
363
|
}
|
|
313
|
-
while (this.pos <
|
|
314
|
-
let ch =
|
|
364
|
+
while (this.pos < source_length) {
|
|
365
|
+
let ch = source.charCodeAt(this.pos);
|
|
315
366
|
if (ch >= 128 || (char_types[ch] & 2) === 0) break;
|
|
316
|
-
this.
|
|
367
|
+
this.pos++;
|
|
317
368
|
}
|
|
318
369
|
}
|
|
319
370
|
}
|
|
320
371
|
}
|
|
321
|
-
if (this.pos <
|
|
322
|
-
let ch =
|
|
372
|
+
if (this.pos < source_length) {
|
|
373
|
+
let ch = source.charCodeAt(this.pos);
|
|
323
374
|
if (ch === CHAR_PERCENT) {
|
|
324
|
-
this.
|
|
375
|
+
this.pos++;
|
|
325
376
|
return this.make_token(11, start, this.pos, start_line, start_column);
|
|
326
377
|
}
|
|
327
|
-
if (is_ident_start(ch) || ch === CHAR_HYPHEN && is_ident_start(this.
|
|
328
|
-
while (this.pos <
|
|
329
|
-
let ch =
|
|
378
|
+
if (is_ident_start(ch) || ch === CHAR_HYPHEN && is_ident_start(this.pos + 1 < source_length ? source.charCodeAt(this.pos + 1) : 0)) {
|
|
379
|
+
while (this.pos < source_length) {
|
|
380
|
+
let ch = source.charCodeAt(this.pos);
|
|
330
381
|
if (ch < 128 && (char_types[ch] & 32) === 0) break;
|
|
331
|
-
this.
|
|
382
|
+
this.pos++;
|
|
332
383
|
}
|
|
333
384
|
return this.make_token(12, start, this.pos, start_line, start_column);
|
|
334
385
|
}
|
|
@@ -336,61 +387,65 @@ var Lexer = class {
|
|
|
336
387
|
return this.make_token(10, start, this.pos, start_line, start_column);
|
|
337
388
|
}
|
|
338
389
|
consume_ident_or_function(start_line, start_column) {
|
|
390
|
+
const source = this.source;
|
|
391
|
+
const source_length = source.length;
|
|
339
392
|
let start = this.pos;
|
|
340
|
-
while (this.pos <
|
|
341
|
-
let ch =
|
|
393
|
+
while (this.pos < source_length) {
|
|
394
|
+
let ch = source.charCodeAt(this.pos);
|
|
342
395
|
if (ch === CHAR_BACKSLASH) {
|
|
343
|
-
if (this.pos + 1 >=
|
|
344
|
-
let next = this.
|
|
396
|
+
if (this.pos + 1 >= source_length) break;
|
|
397
|
+
let next = source.charCodeAt(this.pos + 1);
|
|
345
398
|
if (is_newline(next)) break;
|
|
346
|
-
this.
|
|
399
|
+
this.pos++;
|
|
347
400
|
if (is_hex_digit(next)) {
|
|
348
|
-
this.
|
|
349
|
-
for (let i = 0; i < 5 && this.pos <
|
|
350
|
-
if (!is_hex_digit(
|
|
351
|
-
this.
|
|
401
|
+
this.pos++;
|
|
402
|
+
for (let i = 0; i < 5 && this.pos < source_length; i++) {
|
|
403
|
+
if (!is_hex_digit(source.charCodeAt(this.pos))) break;
|
|
404
|
+
this.pos++;
|
|
352
405
|
}
|
|
353
|
-
if (this.pos <
|
|
354
|
-
let ws =
|
|
355
|
-
if (
|
|
406
|
+
if (this.pos < source_length) {
|
|
407
|
+
let ws = source.charCodeAt(this.pos);
|
|
408
|
+
if (ws < 128 && (char_types[ws] & 24) !== 0) this.advance();
|
|
356
409
|
}
|
|
357
|
-
} else this.
|
|
358
|
-
} else if (ch >= 128 || (char_types[ch] & 32) !== 0) this.
|
|
410
|
+
} else this.pos++;
|
|
411
|
+
} else if (ch >= 128 || (char_types[ch] & 32) !== 0) this.pos++;
|
|
359
412
|
else break;
|
|
360
413
|
}
|
|
361
414
|
if (this.pos - start === 1) {
|
|
362
|
-
let first_ch =
|
|
363
|
-
if ((first_ch === CHAR_LOWERCASE_U || first_ch === CHAR_UPPERCASE_U) && this.pos <
|
|
415
|
+
let first_ch = source.charCodeAt(start);
|
|
416
|
+
if ((first_ch === CHAR_LOWERCASE_U || first_ch === CHAR_UPPERCASE_U) && this.pos < source_length && source.charCodeAt(this.pos) === CHAR_PLUS) return this.consume_unicode_range(start, start_line, start_column);
|
|
364
417
|
}
|
|
365
|
-
if (this.pos <
|
|
366
|
-
this.
|
|
418
|
+
if (this.pos < source_length && source.charCodeAt(this.pos) === CHAR_LEFT_PAREN) {
|
|
419
|
+
this.pos++;
|
|
367
420
|
return this.make_token(2, start, this.pos, start_line, start_column);
|
|
368
421
|
}
|
|
369
422
|
return this.make_token(1, start, this.pos, start_line, start_column);
|
|
370
423
|
}
|
|
371
424
|
consume_unicode_range(start, start_line, start_column) {
|
|
372
|
-
this.
|
|
425
|
+
const source = this.source;
|
|
426
|
+
const source_length = source.length;
|
|
427
|
+
this.pos++;
|
|
373
428
|
let hex_digits = 0;
|
|
374
429
|
let has_question = false;
|
|
375
|
-
while (this.pos <
|
|
376
|
-
let ch =
|
|
430
|
+
while (this.pos < source_length && hex_digits < 6) {
|
|
431
|
+
let ch = source.charCodeAt(this.pos);
|
|
377
432
|
if (is_hex_digit(ch)) {
|
|
378
433
|
if (has_question) break;
|
|
379
|
-
this.
|
|
434
|
+
this.pos++;
|
|
380
435
|
hex_digits++;
|
|
381
436
|
} else if (ch === CHAR_QUESTION_MARK) {
|
|
382
|
-
this.
|
|
437
|
+
this.pos++;
|
|
383
438
|
hex_digits++;
|
|
384
439
|
has_question = true;
|
|
385
440
|
} else break;
|
|
386
441
|
}
|
|
387
442
|
if (has_question) return this.make_token(27, start, this.pos, start_line, start_column);
|
|
388
|
-
if (this.pos <
|
|
389
|
-
if (this.pos + 1 <
|
|
390
|
-
this.
|
|
443
|
+
if (this.pos < source_length && source.charCodeAt(this.pos) === CHAR_HYPHEN) {
|
|
444
|
+
if (this.pos + 1 < source_length && is_hex_digit(source.charCodeAt(this.pos + 1))) {
|
|
445
|
+
this.pos++;
|
|
391
446
|
let end_hex_digits = 0;
|
|
392
|
-
while (this.pos <
|
|
393
|
-
this.
|
|
447
|
+
while (this.pos < source_length && end_hex_digits < 6) if (is_hex_digit(source.charCodeAt(this.pos))) {
|
|
448
|
+
this.pos++;
|
|
394
449
|
end_hex_digits++;
|
|
395
450
|
} else break;
|
|
396
451
|
}
|
|
@@ -398,22 +453,26 @@ var Lexer = class {
|
|
|
398
453
|
return this.make_token(27, start, this.pos, start_line, start_column);
|
|
399
454
|
}
|
|
400
455
|
consume_at_keyword(start_line, start_column) {
|
|
456
|
+
const source = this.source;
|
|
457
|
+
const source_length = source.length;
|
|
401
458
|
let start = this.pos;
|
|
402
|
-
this.
|
|
403
|
-
while (this.pos <
|
|
404
|
-
let ch =
|
|
459
|
+
this.pos++;
|
|
460
|
+
while (this.pos < source_length) {
|
|
461
|
+
let ch = source.charCodeAt(this.pos);
|
|
405
462
|
if (ch < 128 && (char_types[ch] & 32) === 0) break;
|
|
406
|
-
this.
|
|
463
|
+
this.pos++;
|
|
407
464
|
}
|
|
408
465
|
return this.make_token(3, start, this.pos, start_line, start_column);
|
|
409
466
|
}
|
|
410
467
|
consume_hash(start_line, start_column) {
|
|
468
|
+
const source = this.source;
|
|
469
|
+
const source_length = source.length;
|
|
411
470
|
let start = this.pos;
|
|
412
|
-
this.
|
|
413
|
-
while (this.pos <
|
|
414
|
-
let ch =
|
|
471
|
+
this.pos++;
|
|
472
|
+
while (this.pos < source_length) {
|
|
473
|
+
let ch = source.charCodeAt(this.pos);
|
|
415
474
|
if (ch < 128 && (char_types[ch] & 32) === 0) break;
|
|
416
|
-
this.
|
|
475
|
+
this.pos++;
|
|
417
476
|
}
|
|
418
477
|
return this.make_token(4, start, this.pos, start_line, start_column);
|
|
419
478
|
}
|
|
@@ -448,7 +507,7 @@ var Lexer = class {
|
|
|
448
507
|
if (index >= this.source.length) return 0;
|
|
449
508
|
return this.source.charCodeAt(index);
|
|
450
509
|
}
|
|
451
|
-
make_token(type, start, end, line = this.
|
|
510
|
+
make_token(type, start, end, line = this._line, column = this.pos - this._line_offset + 1) {
|
|
452
511
|
this.token_type = type;
|
|
453
512
|
this.token_start = start;
|
|
454
513
|
this.token_end = end;
|
|
@@ -474,7 +533,7 @@ var Lexer = class {
|
|
|
474
533
|
return {
|
|
475
534
|
pos: this.pos,
|
|
476
535
|
line: this._line,
|
|
477
|
-
column: this.
|
|
536
|
+
column: this.pos - this._line_offset + 1,
|
|
478
537
|
_line_offset: this._line_offset,
|
|
479
538
|
token_type: this.token_type,
|
|
480
539
|
token_start: this.token_start,
|
|
@@ -71,6 +71,7 @@ declare class Lexer {
|
|
|
71
71
|
get column(): number;
|
|
72
72
|
seek(pos: number, line: number, column?: number): void;
|
|
73
73
|
next_token_fast(skip_whitespace?: boolean): TokenType;
|
|
74
|
+
private _scan_newlines;
|
|
74
75
|
consume_whitespace(start_line: number, start_column: number): TokenType;
|
|
75
76
|
consume_string(quote: number, start_line: number, start_column: number): TokenType;
|
|
76
77
|
consume_hex_escape(): void;
|
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-mV23Aiyb.js";
|
|
2
2
|
export { CommentInfo, Lexer, LexerPosition, tokenize };
|
package/dist/tokenize.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as tokenize, t as Lexer } from "./tokenize-
|
|
1
|
+
import { n as tokenize, t as Lexer } from "./tokenize-BxUina14.js";
|
|
2
2
|
export { Lexer, tokenize };
|
package/dist/walk.d.ts
CHANGED
package/dist/walk.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import "./arena-
|
|
1
|
+
import "./arena-DnV0a_Ne.js";
|
|
2
|
+
import { t as CSSNode } from "./css-node-BTgoFWDU.js";
|
|
2
3
|
import "./constants.js";
|
|
3
4
|
//#region src/walk.ts
|
|
4
5
|
const SKIP = Symbol("SKIP");
|
|
@@ -16,12 +17,29 @@ function walk(node, callback, depth = 0) {
|
|
|
16
17
|
const result = callback(node, depth);
|
|
17
18
|
if (result === BREAK) return false;
|
|
18
19
|
if (result === SKIP) return true;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
const impl = node;
|
|
21
|
+
const arena = impl.__get_arena();
|
|
22
|
+
const source = impl.__get_source();
|
|
23
|
+
const index = impl.__get_index();
|
|
24
|
+
const type = arena.get_type(index);
|
|
25
|
+
const child_depth = type === 2 || type === 3 ? depth + 1 : depth;
|
|
26
|
+
let child = arena.get_first_child(index);
|
|
27
|
+
while (child !== 0) {
|
|
28
|
+
if (!_walk(arena, source, child, callback, child_depth)) return false;
|
|
29
|
+
child = arena.get_next_sibling(child);
|
|
30
|
+
}
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
function _walk(arena, source, index, callback, depth) {
|
|
34
|
+
const result = callback(new CSSNode(arena, source, index), depth);
|
|
35
|
+
if (result === BREAK) return false;
|
|
36
|
+
if (result === SKIP) return true;
|
|
37
|
+
const type = arena.get_type(index);
|
|
38
|
+
const child_depth = type === 2 || type === 3 ? depth + 1 : depth;
|
|
39
|
+
let child = arena.get_first_child(index);
|
|
40
|
+
while (child !== 0) {
|
|
41
|
+
if (!_walk(arena, source, child, callback, child_depth)) return false;
|
|
42
|
+
child = arena.get_next_sibling(child);
|
|
25
43
|
}
|
|
26
44
|
return true;
|
|
27
45
|
}
|
|
@@ -37,13 +55,28 @@ function traverse(node, { enter = NOOP, leave = NOOP } = {}) {
|
|
|
37
55
|
const enter_result = enter(node);
|
|
38
56
|
if (enter_result === BREAK) return false;
|
|
39
57
|
if (enter_result !== SKIP) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
child
|
|
58
|
+
const impl = node;
|
|
59
|
+
const arena = impl.__get_arena();
|
|
60
|
+
const source = impl.__get_source();
|
|
61
|
+
const index = impl.__get_index();
|
|
62
|
+
let child = arena.get_first_child(index);
|
|
63
|
+
while (child !== 0) {
|
|
64
|
+
if (!_traverse(arena, source, child, enter, leave)) return false;
|
|
65
|
+
child = arena.get_next_sibling(child);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (leave(node) === BREAK) return false;
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
function _traverse(arena, source, index, enter, leave) {
|
|
72
|
+
const node = new CSSNode(arena, source, index);
|
|
73
|
+
const enter_result = enter(node);
|
|
74
|
+
if (enter_result === BREAK) return false;
|
|
75
|
+
if (enter_result !== SKIP) {
|
|
76
|
+
let child = arena.get_first_child(index);
|
|
77
|
+
while (child !== 0) {
|
|
78
|
+
if (!_traverse(arena, source, child, enter, leave)) return false;
|
|
79
|
+
child = arena.get_next_sibling(child);
|
|
47
80
|
}
|
|
48
81
|
}
|
|
49
82
|
if (leave(node) === BREAK) return false;
|