@projectwallace/css-parser 0.15.0 → 0.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  //#region src/char-types.ts
2
2
  let CHAR_ALPHA = 1;
3
3
  let CHAR_HEX = 4;
4
- let char_types = new Uint8Array(128);
4
+ let char_types = /* @__PURE__ */ new Uint8Array(128);
5
5
  for (let i = 48; i <= 57; i++) char_types[i] = 2;
6
6
  for (let i = 48; i <= 57; i++) char_types[i] |= CHAR_HEX;
7
7
  for (let i = 65; i <= 70; i++) char_types[i] = CHAR_HEX;
@@ -13,7 +13,7 @@ char_types[9] = 8;
13
13
  char_types[10] = 16;
14
14
  char_types[13] = 16;
15
15
  char_types[12] = 16;
16
- for (let i = 0; i < 128; i++) if (char_types[i] & (CHAR_ALPHA | 2)) char_types[i] |= 32;
16
+ for (let i = 0; i < 128; i++) if (char_types[i] & 3) char_types[i] |= 32;
17
17
  char_types[45] |= 32;
18
18
  char_types[95] |= 32;
19
19
  function is_hex_digit(ch) {
@@ -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
- if (skip_whitespace) while (this.pos < this.source.length) {
134
- let ch = this.source.charCodeAt(this.pos);
135
- if (ch >= 128 || (char_types[ch] & 24) === 0) break;
136
- this.advance();
137
- }
138
- if (this.pos >= this.source.length) return this.make_token(26, this.pos, this.pos);
139
- let ch = this.source.charCodeAt(this.pos);
140
- let start = this.pos;
141
- let start_line = this.line;
142
- let start_column = this.column;
143
- switch (ch) {
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
- let comment_end = this.pos;
186
- if (this.on_comment) this.on_comment({
187
- start: comment_start,
188
- end: comment_end,
189
- length: comment_end - comment_start,
190
- line: comment_line,
191
- column: comment_column
192
- });
193
- return this.next_token_fast(skip_whitespace);
194
- }
195
- if (ch === CHAR_DOUBLE_QUOTE || ch === CHAR_SINGLE_QUOTE) return this.consume_string(ch, start_line, start_column);
196
- if (ch < 128 && (char_types[ch] & 2) !== 0) return this.consume_number(start_line, start_column);
197
- if (ch === CHAR_DOT) {
198
- let next = this.peek();
199
- if (next < 128 && (char_types[next] & 2) !== 0) return this.consume_number(start_line, start_column);
200
- }
201
- if (ch === CHAR_LESS_THAN && this.pos + 3 < this.source.length) {
202
- if (this.peek() === CHAR_EXCLAMATION && this.peek(2) === CHAR_HYPHEN && this.peek(3) === CHAR_HYPHEN) {
203
- this.advance(4);
204
- return this.make_token(14, start, this.pos, start_line, start_column);
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
- if (ch === CHAR_HYPHEN && this.pos + 2 < this.source.length) {
208
- if (this.peek() === CHAR_HYPHEN && this.peek(2) === CHAR_GREATER_THAN) {
209
- this.advance(3);
210
- return this.make_token(15, start, this.pos, start_line, start_column);
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
- if (ch === CHAR_AT_SIGN) return this.consume_at_keyword(start_line, start_column);
214
- if (ch === CHAR_HASH) return this.consume_hash(start_line, start_column);
215
- if (is_ident_start(ch)) return this.consume_ident_or_function(start_line, start_column);
216
- if (ch === CHAR_HYPHEN) {
217
- let next = this.peek();
218
- if (is_ident_start(next) || next === CHAR_HYPHEN) return this.consume_ident_or_function(start_line, start_column);
219
- }
220
- if (ch === CHAR_BACKSLASH) {
221
- let next = this.peek();
222
- if (next !== 0 && !is_newline(next)) return this.consume_ident_or_function(start_line, start_column);
223
- }
224
- if (ch === CHAR_HYPHEN || ch === CHAR_PLUS) {
225
- let next = this.peek();
226
- if (next < 128 && (char_types[next] & 2) !== 0) return this.consume_number(start_line, start_column);
227
- if (next === CHAR_DOT) {
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 < this.source.length) {
238
- let ch = this.source.charCodeAt(this.pos);
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.advance();
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.advance();
247
- while (this.pos < this.source.length) {
248
- let ch = this.source.charCodeAt(this.pos);
282
+ this.pos++;
283
+ while (this.pos < source_length) {
284
+ let ch = source.charCodeAt(this.pos);
249
285
  if (ch === quote) {
250
- this.advance();
286
+ this.pos++;
251
287
  return this.make_token(5, start, this.pos, start_line, start_column);
252
288
  }
253
- if (is_newline(ch)) return this.make_token(6, start, this.pos, start_line, start_column);
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.advance();
256
- if (this.pos < this.source.length) {
257
- let next = this.source.charCodeAt(this.pos);
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 (!is_newline(next)) this.advance();
260
- else this.advance();
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.advance();
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 < this.source.length) {
271
- if (!is_hex_digit(this.source.charCodeAt(this.pos))) break;
272
- this.advance();
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 < this.source.length) {
276
- let ch = this.source.charCodeAt(this.pos);
277
- if (is_whitespace(ch) || is_newline(ch)) this.advance();
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 = this.source.charCodeAt(this.pos);
283
- if (ch === CHAR_PLUS || ch === CHAR_HYPHEN) this.advance();
284
- while (this.pos < this.source.length) {
285
- let ch = this.source.charCodeAt(this.pos);
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.advance();
338
+ this.pos++;
288
339
  }
289
- if (this.pos < this.source.length && this.source.charCodeAt(this.pos) === CHAR_DOT && this.pos + 1 < this.source.length) {
290
- let next = this.peek();
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.advance();
293
- while (this.pos < this.source.length) {
294
- let ch = this.source.charCodeAt(this.pos);
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.advance();
347
+ this.pos++;
297
348
  }
298
349
  }
299
350
  }
300
- if (this.pos < this.source.length) {
301
- let ch = this.source.charCodeAt(this.pos);
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.peek();
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.peek(2);
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.advance();
309
- if (this.pos < this.source.length) {
310
- let sign = this.source.charCodeAt(this.pos);
311
- if (sign === CHAR_PLUS || sign === CHAR_HYPHEN) this.advance();
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 < this.source.length) {
314
- let ch = this.source.charCodeAt(this.pos);
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.advance();
367
+ this.pos++;
317
368
  }
318
369
  }
319
370
  }
320
371
  }
321
- if (this.pos < this.source.length) {
322
- let ch = this.source.charCodeAt(this.pos);
372
+ if (this.pos < source_length) {
373
+ let ch = source.charCodeAt(this.pos);
323
374
  if (ch === CHAR_PERCENT) {
324
- this.advance();
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.peek())) {
328
- while (this.pos < this.source.length) {
329
- let ch = this.source.charCodeAt(this.pos);
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.advance();
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 < this.source.length) {
341
- let ch = this.source.charCodeAt(this.pos);
393
+ while (this.pos < source_length) {
394
+ let ch = source.charCodeAt(this.pos);
342
395
  if (ch === CHAR_BACKSLASH) {
343
- if (this.pos + 1 >= this.source.length) break;
344
- let next = this.peek();
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.advance();
399
+ this.pos++;
347
400
  if (is_hex_digit(next)) {
348
- this.advance();
349
- for (let i = 0; i < 5 && this.pos < this.source.length; i++) {
350
- if (!is_hex_digit(this.source.charCodeAt(this.pos))) break;
351
- this.advance();
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 < this.source.length) {
354
- let ws = this.source.charCodeAt(this.pos);
355
- if (is_whitespace(ws) || is_newline(ws)) this.advance();
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.advance();
358
- } else if (ch >= 128 || (char_types[ch] & 32) !== 0) this.advance();
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 = this.source.charCodeAt(start);
363
- if ((first_ch === CHAR_LOWERCASE_U || first_ch === CHAR_UPPERCASE_U) && this.pos < this.source.length && this.source.charCodeAt(this.pos) === CHAR_PLUS) return this.consume_unicode_range(start, start_line, start_column);
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 < this.source.length && this.source.charCodeAt(this.pos) === CHAR_LEFT_PAREN) {
366
- this.advance();
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.advance();
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 < this.source.length && hex_digits < 6) {
376
- let ch = this.source.charCodeAt(this.pos);
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.advance();
434
+ this.pos++;
380
435
  hex_digits++;
381
436
  } else if (ch === CHAR_QUESTION_MARK) {
382
- this.advance();
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 < this.source.length && this.source.charCodeAt(this.pos) === CHAR_HYPHEN) {
389
- if (this.pos + 1 < this.source.length && is_hex_digit(this.source.charCodeAt(this.pos + 1))) {
390
- this.advance();
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 < this.source.length && end_hex_digits < 6) if (is_hex_digit(this.source.charCodeAt(this.pos))) {
393
- this.advance();
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.advance();
403
- while (this.pos < this.source.length) {
404
- let ch = this.source.charCodeAt(this.pos);
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.advance();
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.advance();
413
- while (this.pos < this.source.length) {
414
- let ch = this.source.charCodeAt(this.pos);
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.advance();
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.line, column = this.column) {
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.column,
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;
@@ -1,2 +1,2 @@
1
- import { i as tokenize, n as Lexer, r as LexerPosition, t as CommentInfo } from "./tokenize-CyiJelQC.js";
1
+ import { i as tokenize, n as Lexer, r as LexerPosition, t as CommentInfo } from "./tokenize-DeZYFa9R.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-BSycRGm0.js";
1
+ import { n as tokenize, t as Lexer } from "./tokenize-BiRLfVbm.js";
2
2
  export { Lexer, tokenize };
package/dist/walk.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { o as CSSNode, t as AnyNode } from "./node-types-DJytj0FB.js";
1
+ import { o as CSSNode, t as AnyNode } from "./node-types-BrZu8T2C.js";
2
2
 
3
3
  //#region src/walk.d.ts
4
4
  declare const SKIP: unique symbol;