@projectwallace/css-parser 0.18.8 → 0.18.11

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.
Files changed (40) hide show
  1. package/README.md +186 -18
  2. package/dist/{arena-e9O_g2AN.js → arena-Bsf96CQK.js} +27 -19
  3. package/dist/{arena-BGvFdbj5.d.ts → arena-DvT75bvK.d.ts} +2 -0
  4. package/dist/constants.d.ts +1 -1
  5. package/dist/constants.js +1 -1
  6. package/dist/{css-node-CH5HqF0J.js → css-node-yoUdFtNg.js} +101 -106
  7. package/dist/index.d.ts +6 -20
  8. package/dist/index.js +9 -146
  9. package/dist/{node-types-YnOKcNfU.d.ts → node-types-DG8OKqPu.d.ts} +8 -54
  10. package/dist/node-types.d.ts +2 -0
  11. package/dist/node-types.js +142 -0
  12. package/dist/parse-anplusb.d.ts +2 -2
  13. package/dist/parse-anplusb.js +5 -4
  14. package/dist/parse-atrule-prelude.d.ts +4 -3
  15. package/dist/parse-atrule-prelude.js +82 -77
  16. package/dist/parse-declaration.d.ts +4 -3
  17. package/dist/parse-declaration.js +28 -26
  18. package/dist/parse-dimension.js +46 -1
  19. package/dist/{parse-selector-PhqFezCi.js → parse-selector-CqIpnBrQ.js} +74 -89
  20. package/dist/parse-selector.d.ts +2 -2
  21. package/dist/parse-selector.js +1 -2
  22. package/dist/parse-value.d.ts +2 -2
  23. package/dist/parse-value.js +8 -8
  24. package/dist/parse.d.ts +3 -3
  25. package/dist/parse.js +49 -47
  26. package/dist/string-helpers-BMWJduts.d.ts +18 -0
  27. package/dist/string-helpers.d.ts +2 -0
  28. package/dist/string-helpers.js +1 -0
  29. package/dist/{parse-dimension-CQELWb5z.js → string-utils-DiRRd28d.js} +9 -59
  30. package/dist/token-types-Bqsf5FX-.d.ts +38 -0
  31. package/dist/token-types.d.ts +2 -0
  32. package/dist/token-types.js +30 -0
  33. package/dist/{tokenize-BYl6GvyV.js → tokenize-Ccg58Z_k.js} +79 -96
  34. package/dist/tokenize.d.ts +97 -2
  35. package/dist/tokenize.js +1 -2
  36. package/dist/{value-node-parser-tjY982sG.js → value-node-parser-D0qnA_bD.js} +153 -219
  37. package/dist/walk.d.ts +3 -2
  38. package/dist/walk.js +2 -2
  39. package/package.json +29 -18
  40. package/dist/tokenize-CDEnYcVG.d.ts +0 -133
@@ -1,62 +1,32 @@
1
+ import "./token-types.js";
1
2
  //#region src/char-types.ts
2
- let CHAR_ALPHA = 1;
3
- let CHAR_HEX = 4;
4
- let char_types = /* @__PURE__ */ new Uint8Array(128);
3
+ const CHAR_ALPHA = 1;
4
+ const CHAR_HEX = 4;
5
+ const CHAR_WHITESPACE = 8;
6
+ const char_types = /* @__PURE__ */ new Uint8Array(128);
5
7
  for (let i = 48; i <= 57; i++) char_types[i] = 2;
6
8
  for (let i = 48; i <= 57; i++) char_types[i] |= CHAR_HEX;
7
9
  for (let i = 65; i <= 70; i++) char_types[i] = CHAR_HEX;
8
10
  for (let i = 97; i <= 102; i++) char_types[i] = CHAR_HEX;
9
11
  for (let i = 65; i <= 90; i++) char_types[i] |= CHAR_ALPHA;
10
12
  for (let i = 97; i <= 122; i++) char_types[i] |= CHAR_ALPHA;
11
- char_types[32] = 8;
12
- char_types[9] = 8;
13
+ char_types[32] = CHAR_WHITESPACE;
14
+ char_types[9] = CHAR_WHITESPACE;
13
15
  char_types[10] = 16;
14
16
  char_types[13] = 16;
15
17
  char_types[12] = 16;
16
18
  for (let i = 0; i < 128; i++) if (char_types[i] & 3) char_types[i] |= 32;
17
19
  char_types[45] |= 32;
18
20
  char_types[95] |= 32;
21
+ for (let i = 0; i < 128; i++) if (char_types[i] & CHAR_ALPHA) char_types[i] |= 64;
22
+ char_types[95] |= 64;
19
23
  function is_hex_digit(ch) {
20
24
  return ch < 128 && (char_types[ch] & CHAR_HEX) !== 0;
21
25
  }
22
- function is_alpha(ch) {
23
- return ch < 128 && (char_types[ch] & CHAR_ALPHA) !== 0;
24
- }
25
26
  function is_ident_start(ch) {
26
- if (ch >= 128) return true;
27
- if (ch === 95) return true;
28
- return is_alpha(ch);
27
+ return ch >= 128 || (char_types[ch] & 64) !== 0;
29
28
  }
30
29
  //#endregion
31
- //#region src/token-types.ts
32
- const TOKEN_IDENT = 1;
33
- const TOKEN_FUNCTION = 2;
34
- const TOKEN_AT_KEYWORD = 3;
35
- const TOKEN_HASH = 4;
36
- const TOKEN_STRING = 5;
37
- const TOKEN_BAD_STRING = 6;
38
- const TOKEN_URL = 7;
39
- const TOKEN_BAD_URL = 8;
40
- const TOKEN_DELIM = 9;
41
- const TOKEN_NUMBER = 10;
42
- const TOKEN_PERCENTAGE = 11;
43
- const TOKEN_DIMENSION = 12;
44
- const TOKEN_WHITESPACE = 13;
45
- const TOKEN_CDO = 14;
46
- const TOKEN_CDC = 15;
47
- const TOKEN_COLON = 16;
48
- const TOKEN_SEMICOLON = 17;
49
- const TOKEN_COMMA = 18;
50
- const TOKEN_LEFT_BRACKET = 19;
51
- const TOKEN_RIGHT_BRACKET = 20;
52
- const TOKEN_LEFT_PAREN = 21;
53
- const TOKEN_RIGHT_PAREN = 22;
54
- const TOKEN_LEFT_BRACE = 23;
55
- const TOKEN_RIGHT_BRACE = 24;
56
- const TOKEN_COMMENT = 25;
57
- const TOKEN_EOF = 26;
58
- const TOKEN_UNICODE_RANGE = 27;
59
- //#endregion
60
30
  //#region src/tokenize.ts
61
31
  function is_newline(ch) {
62
32
  return ch < 128 && (char_types[ch] & 16) !== 0;
@@ -150,7 +120,7 @@ var Lexer = class {
150
120
  let line = this._line;
151
121
  let line_offset = this._line_offset;
152
122
  while (pos < source_length) {
153
- let ch = source.charCodeAt(pos);
123
+ const ch = source.charCodeAt(pos);
154
124
  if (ch >= 128 || (char_types[ch] & 24) === 0) break;
155
125
  pos++;
156
126
  if ((char_types[ch] & 16) !== 0) {
@@ -164,10 +134,10 @@ var Lexer = class {
164
134
  this._line_offset = line_offset;
165
135
  }
166
136
  if (this.pos >= source_length) return this.make_token(26, this.pos, this.pos);
167
- let ch = source.charCodeAt(this.pos);
168
- let start = this.pos;
169
- let start_line = this._line;
170
- let start_column = this.pos - this._line_offset + 1;
137
+ const ch = source.charCodeAt(this.pos);
138
+ const start = this.pos;
139
+ const start_line = this._line;
140
+ const start_column = this.pos - this._line_offset + 1;
171
141
  switch (ch) {
172
142
  case CHAR_LEFT_BRACE:
173
143
  this.pos++;
@@ -197,14 +167,15 @@ var Lexer = class {
197
167
  this.pos++;
198
168
  return this.make_token(22, start, this.pos, start_line, start_column);
199
169
  }
200
- if (ch < 128 && (char_types[ch] & 24) !== 0) return this.consume_whitespace(start_line, start_column);
170
+ const ch_type = ch < 128 ? char_types[ch] : 0;
171
+ if ((ch_type & 24) !== 0) return this.consume_whitespace(start_line, start_column);
201
172
  if (ch === CHAR_FORWARD_SLASH && this.pos + 1 < source_length && source.charCodeAt(this.pos + 1) === CHAR_ASTERISK) {
202
173
  this._skip_comment();
203
174
  continue;
204
175
  }
205
- if (is_ident_start(ch)) return this.consume_ident_or_function(start_line, start_column);
176
+ if (ch >= 128 || (ch_type & 64) !== 0) return this.consume_ident_or_function(start_line, start_column);
206
177
  if (ch === CHAR_HYPHEN) {
207
- let next = this.pos + 1 < source_length ? source.charCodeAt(this.pos + 1) : 0;
178
+ const next = this.pos + 1 < source_length ? source.charCodeAt(this.pos + 1) : 0;
208
179
  if (next === CHAR_HYPHEN && this.pos + 2 < source_length && source.charCodeAt(this.pos + 2) === CHAR_GREATER_THAN) {
209
180
  this.pos += 3;
210
181
  return this.make_token(15, start, this.pos, start_line, start_column);
@@ -212,24 +183,24 @@ var Lexer = class {
212
183
  if (is_ident_start(next) || next === CHAR_HYPHEN) return this.consume_ident_or_function(start_line, start_column);
213
184
  if (next < 128 && (char_types[next] & 2) !== 0) return this.consume_number(start_line, start_column);
214
185
  if (next === CHAR_DOT) {
215
- let next2 = this.pos + 2 < source_length ? source.charCodeAt(this.pos + 2) : 0;
186
+ const next2 = this.pos + 2 < source_length ? source.charCodeAt(this.pos + 2) : 0;
216
187
  if (next2 < 128 && (char_types[next2] & 2) !== 0) return this.consume_number(start_line, start_column);
217
188
  }
218
189
  }
219
190
  if (ch === CHAR_BACKSLASH) {
220
- let next = this.pos + 1 < source_length ? source.charCodeAt(this.pos + 1) : 0;
191
+ const next = this.pos + 1 < source_length ? source.charCodeAt(this.pos + 1) : 0;
221
192
  if (next !== 0 && !is_newline(next)) return this.consume_ident_or_function(start_line, start_column);
222
193
  }
223
- if (ch < 128 && (char_types[ch] & 2) !== 0) return this.consume_number(start_line, start_column);
194
+ if ((ch_type & 2) !== 0) return this.consume_number(start_line, start_column);
224
195
  if (ch === CHAR_DOT) {
225
- let next = this.pos + 1 < source_length ? source.charCodeAt(this.pos + 1) : 0;
196
+ const next = this.pos + 1 < source_length ? source.charCodeAt(this.pos + 1) : 0;
226
197
  if (next < 128 && (char_types[next] & 2) !== 0) return this.consume_number(start_line, start_column);
227
198
  }
228
199
  if (ch === CHAR_PLUS) {
229
- let next = this.pos + 1 < source_length ? source.charCodeAt(this.pos + 1) : 0;
200
+ const next = this.pos + 1 < source_length ? source.charCodeAt(this.pos + 1) : 0;
230
201
  if (next < 128 && (char_types[next] & 2) !== 0) return this.consume_number(start_line, start_column);
231
202
  if (next === CHAR_DOT) {
232
- let next2 = this.pos + 2 < source_length ? source.charCodeAt(this.pos + 2) : 0;
203
+ const next2 = this.pos + 2 < source_length ? source.charCodeAt(this.pos + 2) : 0;
233
204
  if (next2 < 128 && (char_types[next2] & 2) !== 0) return this.consume_number(start_line, start_column);
234
205
  }
235
206
  }
@@ -249,7 +220,7 @@ var Lexer = class {
249
220
  _scan_newlines(from, to) {
250
221
  const source = this.source;
251
222
  for (let i = from; i < to; i++) {
252
- let c = source.charCodeAt(i);
223
+ const c = source.charCodeAt(i);
253
224
  if (c === CHAR_LINE_FEED) {
254
225
  this._line++;
255
226
  this._line_offset = i + 1;
@@ -266,11 +237,11 @@ var Lexer = class {
266
237
  _skip_comment() {
267
238
  const source = this.source;
268
239
  const source_length = source.length;
269
- let comment_start = this.pos;
270
- let comment_line = this._line;
271
- let comment_column = this.pos - this._line_offset + 1;
240
+ const comment_start = this.pos;
241
+ const comment_line = this._line;
242
+ const comment_column = this.pos - this._line_offset + 1;
272
243
  this.pos += 2;
273
- let end_idx = source.indexOf("*/", this.pos);
244
+ const end_idx = source.indexOf("*/", this.pos);
274
245
  if (end_idx < 0) {
275
246
  this._scan_newlines(this.pos, source_length);
276
247
  this.pos = source_length;
@@ -303,7 +274,7 @@ var Lexer = class {
303
274
  const source_length = source.length;
304
275
  let pos = this.pos;
305
276
  while (pos < source_length) {
306
- let ch = source.charCodeAt(pos);
277
+ const ch = source.charCodeAt(pos);
307
278
  if (ch === target) {
308
279
  this.pos = pos;
309
280
  return true;
@@ -345,7 +316,7 @@ var Lexer = class {
345
316
  const source = this.source;
346
317
  let pos = this.pos;
347
318
  while (pos < end) {
348
- let ch = source.charCodeAt(pos);
319
+ const ch = source.charCodeAt(pos);
349
320
  if (ch < 128 && DECL_VALUE_STOP[ch] !== 0) {
350
321
  this.pos = pos;
351
322
  return ch;
@@ -379,12 +350,12 @@ var Lexer = class {
379
350
  consume_whitespace(start_line, start_column) {
380
351
  const source = this.source;
381
352
  const source_length = source.length;
382
- let start = this.pos;
353
+ const start = this.pos;
383
354
  let pos = start;
384
355
  let line = this._line;
385
356
  let line_offset = this._line_offset;
386
357
  while (pos < source_length) {
387
- let ch = source.charCodeAt(pos);
358
+ const ch = source.charCodeAt(pos);
388
359
  if (ch >= 128 || (char_types[ch] & 24) === 0) break;
389
360
  pos++;
390
361
  if ((char_types[ch] & 16) !== 0) {
@@ -401,10 +372,10 @@ var Lexer = class {
401
372
  consume_string(quote, start_line, start_column) {
402
373
  const source = this.source;
403
374
  const source_length = source.length;
404
- let start = this.pos;
375
+ const start = this.pos;
405
376
  this.pos++;
406
377
  while (this.pos < source_length) {
407
- let ch = source.charCodeAt(this.pos);
378
+ const ch = source.charCodeAt(this.pos);
408
379
  if (ch === quote) {
409
380
  this.pos++;
410
381
  return this.make_token(5, start, this.pos, start_line, start_column);
@@ -413,7 +384,7 @@ var Lexer = class {
413
384
  if (ch === CHAR_BACKSLASH) {
414
385
  this.pos++;
415
386
  if (this.pos < source_length) {
416
- let next = source.charCodeAt(this.pos);
387
+ const next = source.charCodeAt(this.pos);
417
388
  if (is_hex_digit(next)) this.consume_hex_escape();
418
389
  else if (next < 128 && (char_types[next] & 16) !== 0) {
419
390
  this.pos++;
@@ -438,7 +409,7 @@ var Lexer = class {
438
409
  count++;
439
410
  }
440
411
  if (this.pos < source_length) {
441
- let ch = source.charCodeAt(this.pos);
412
+ const ch = source.charCodeAt(this.pos);
442
413
  if (ch < 128 && (char_types[ch] & 24) !== 0) {
443
414
  this.pos++;
444
415
  if ((char_types[ch] & 16) !== 0) {
@@ -452,41 +423,41 @@ var Lexer = class {
452
423
  consume_number(start_line, start_column) {
453
424
  const source = this.source;
454
425
  const source_length = source.length;
455
- let start = this.pos;
426
+ const start = this.pos;
456
427
  let pos = start;
457
- let ch = source.charCodeAt(pos);
428
+ const ch = source.charCodeAt(pos);
458
429
  if (ch === CHAR_PLUS || ch === CHAR_HYPHEN) pos++;
459
430
  while (pos < source_length) {
460
- let ch = source.charCodeAt(pos);
431
+ const ch = source.charCodeAt(pos);
461
432
  if (ch >= 128 || (char_types[ch] & 2) === 0) break;
462
433
  pos++;
463
434
  }
464
435
  if (pos < source_length && source.charCodeAt(pos) === CHAR_DOT && pos + 1 < source_length) {
465
- let next = source.charCodeAt(pos + 1);
436
+ const next = source.charCodeAt(pos + 1);
466
437
  if (next < 128 && (char_types[next] & 2) !== 0) {
467
438
  pos++;
468
439
  while (pos < source_length) {
469
- let ch = source.charCodeAt(pos);
440
+ const ch = source.charCodeAt(pos);
470
441
  if (ch >= 128 || (char_types[ch] & 2) === 0) break;
471
442
  pos++;
472
443
  }
473
444
  }
474
445
  }
475
446
  if (pos < source_length) {
476
- let ch = source.charCodeAt(pos);
447
+ const ch = source.charCodeAt(pos);
477
448
  if (ch === CHAR_LOWERCASE_E || ch === CHAR_UPPERCASE_E) {
478
- let next = pos + 1 < source_length ? source.charCodeAt(pos + 1) : 0;
479
- let is_next_digit = next < 128 && (char_types[next] & 2) !== 0;
480
- let next2 = pos + 2 < source_length ? source.charCodeAt(pos + 2) : 0;
481
- let is_next2_digit = next2 < 128 && (char_types[next2] & 2) !== 0;
449
+ const next = pos + 1 < source_length ? source.charCodeAt(pos + 1) : 0;
450
+ const is_next_digit = next < 128 && (char_types[next] & 2) !== 0;
451
+ const next2 = pos + 2 < source_length ? source.charCodeAt(pos + 2) : 0;
452
+ const is_next2_digit = next2 < 128 && (char_types[next2] & 2) !== 0;
482
453
  if (is_next_digit || (next === CHAR_PLUS || next === CHAR_HYPHEN) && is_next2_digit) {
483
454
  pos++;
484
455
  if (pos < source_length) {
485
- let sign = source.charCodeAt(pos);
456
+ const sign = source.charCodeAt(pos);
486
457
  if (sign === CHAR_PLUS || sign === CHAR_HYPHEN) pos++;
487
458
  }
488
459
  while (pos < source_length) {
489
- let ch = source.charCodeAt(pos);
460
+ const ch = source.charCodeAt(pos);
490
461
  if (ch >= 128 || (char_types[ch] & 2) === 0) break;
491
462
  pos++;
492
463
  }
@@ -494,7 +465,7 @@ var Lexer = class {
494
465
  }
495
466
  }
496
467
  if (pos < source_length) {
497
- let ch = source.charCodeAt(pos);
468
+ const ch = source.charCodeAt(pos);
498
469
  if (ch === CHAR_PERCENT) {
499
470
  pos++;
500
471
  this.pos = pos;
@@ -502,7 +473,7 @@ var Lexer = class {
502
473
  }
503
474
  if (is_ident_start(ch) || ch === CHAR_HYPHEN && is_ident_start(pos + 1 < source_length ? source.charCodeAt(pos + 1) : 0)) {
504
475
  while (pos < source_length) {
505
- let ch = source.charCodeAt(pos);
476
+ const ch = source.charCodeAt(pos);
506
477
  if (ch < 128 && (char_types[ch] & 32) === 0) break;
507
478
  pos++;
508
479
  }
@@ -516,14 +487,14 @@ var Lexer = class {
516
487
  consume_ident_or_function(start_line, start_column) {
517
488
  const source = this.source;
518
489
  const source_length = source.length;
519
- let start = this.pos;
490
+ const start = this.pos;
520
491
  let pos = start;
521
492
  while (pos < source_length) {
522
- let ch = source.charCodeAt(pos);
493
+ const ch = source.charCodeAt(pos);
523
494
  if (ch === CHAR_BACKSLASH) {
524
495
  this.pos = pos;
525
496
  if (this.pos + 1 >= source_length) break;
526
- let next = source.charCodeAt(this.pos + 1);
497
+ const next = source.charCodeAt(this.pos + 1);
527
498
  if (is_newline(next)) break;
528
499
  this.pos++;
529
500
  if (is_hex_digit(next)) {
@@ -533,7 +504,7 @@ var Lexer = class {
533
504
  this.pos++;
534
505
  }
535
506
  if (this.pos < source_length) {
536
- let ws = source.charCodeAt(this.pos);
507
+ const ws = source.charCodeAt(this.pos);
537
508
  if (ws < 128 && (char_types[ws] & 24) !== 0) this.advance();
538
509
  }
539
510
  } else this.pos++;
@@ -543,7 +514,7 @@ var Lexer = class {
543
514
  }
544
515
  this.pos = pos;
545
516
  if (this.pos - start === 1) {
546
- let first_ch = source.charCodeAt(start);
517
+ const first_ch = source.charCodeAt(start);
547
518
  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);
548
519
  }
549
520
  if (this.pos < source_length && source.charCodeAt(this.pos) === CHAR_LEFT_PAREN) {
@@ -559,7 +530,7 @@ var Lexer = class {
559
530
  let hex_digits = 0;
560
531
  let has_question = false;
561
532
  while (this.pos < source_length && hex_digits < 6) {
562
- let ch = source.charCodeAt(this.pos);
533
+ const ch = source.charCodeAt(this.pos);
563
534
  if (is_hex_digit(ch)) {
564
535
  if (has_question) break;
565
536
  this.pos++;
@@ -586,10 +557,10 @@ var Lexer = class {
586
557
  consume_at_keyword(start_line, start_column) {
587
558
  const source = this.source;
588
559
  const source_length = source.length;
589
- let start = this.pos;
560
+ const start = this.pos;
590
561
  let pos = start + 1;
591
562
  while (pos < source_length) {
592
- let ch = source.charCodeAt(pos);
563
+ const ch = source.charCodeAt(pos);
593
564
  if (ch < 128 && (char_types[ch] & 32) === 0) break;
594
565
  pos++;
595
566
  }
@@ -599,10 +570,10 @@ var Lexer = class {
599
570
  consume_hash(start_line, start_column) {
600
571
  const source = this.source;
601
572
  const source_length = source.length;
602
- let start = this.pos;
573
+ const start = this.pos;
603
574
  let pos = start + 1;
604
575
  while (pos < source_length) {
605
- let ch = source.charCodeAt(pos);
576
+ const ch = source.charCodeAt(pos);
606
577
  if (ch < 128 && (char_types[ch] & 32) === 0) break;
607
578
  pos++;
608
579
  }
@@ -612,7 +583,7 @@ var Lexer = class {
612
583
  advance(count = 1) {
613
584
  if (count === 1) {
614
585
  if (this.pos >= this.source.length) return;
615
- let ch = this.source.charCodeAt(this.pos);
586
+ const ch = this.source.charCodeAt(this.pos);
616
587
  this.pos++;
617
588
  if (ch < 128 && (char_types[ch] & 16) !== 0) {
618
589
  if (ch === CHAR_CARRIAGE_RETURN && this.pos < this.source.length && this.source.charCodeAt(this.pos) === CHAR_LINE_FEED) this.pos++;
@@ -623,7 +594,7 @@ var Lexer = class {
623
594
  }
624
595
  for (let i = 0; i < count; i++) {
625
596
  if (this.pos >= this.source.length) break;
626
- let ch = this.source.charCodeAt(this.pos);
597
+ const ch = this.source.charCodeAt(this.pos);
627
598
  this.pos++;
628
599
  if (ch < 128 && (char_types[ch] & 16) !== 0) {
629
600
  if (ch === CHAR_CARRIAGE_RETURN && this.pos < this.source.length && this.source.charCodeAt(this.pos) === CHAR_LINE_FEED) {
@@ -636,7 +607,7 @@ var Lexer = class {
636
607
  }
637
608
  }
638
609
  peek(offset = 1) {
639
- let index = this.pos + offset;
610
+ const index = this.pos + offset;
640
611
  if (index >= this.source.length) return 0;
641
612
  return this.source.charCodeAt(index);
642
613
  }
@@ -675,6 +646,18 @@ var Lexer = class {
675
646
  token_column: this.token_column
676
647
  };
677
648
  }
649
+ save_position_into(target) {
650
+ target.pos = this.pos;
651
+ target.line = this._line;
652
+ target.column = this.pos - this._line_offset + 1;
653
+ target._line_offset = this._line_offset;
654
+ target.token_type = this.token_type;
655
+ target.token_start = this.token_start;
656
+ target.token_end = this.token_end;
657
+ target.token_line = this.token_line;
658
+ target.token_column = this.token_column;
659
+ return target;
660
+ }
678
661
  /**
679
662
  * Restore lexer state from saved position
680
663
  * @param saved The saved position to restore
@@ -695,7 +678,7 @@ var Lexer = class {
695
678
  */
696
679
  skip_whitespace_in_range(end) {
697
680
  while (this.pos < end) {
698
- let ch = this.source.charCodeAt(this.pos);
681
+ const ch = this.source.charCodeAt(this.pos);
699
682
  if (ch < 128 && (char_types[ch] & 24) !== 0) {
700
683
  this.advance();
701
684
  continue;
@@ -723,4 +706,4 @@ function* tokenize(source, on_comment) {
723
706
  }
724
707
  }
725
708
  //#endregion
726
- export { TOKEN_RIGHT_BRACKET as C, TOKEN_UNICODE_RANGE as D, TOKEN_STRING as E, TOKEN_URL as O, TOKEN_RIGHT_BRACE as S, TOKEN_SEMICOLON as T, TOKEN_LEFT_BRACE as _, TOKEN_BAD_URL as a, TOKEN_NUMBER as b, TOKEN_COLON as c, TOKEN_DELIM as d, TOKEN_DIMENSION as f, TOKEN_IDENT as g, TOKEN_HASH as h, TOKEN_BAD_STRING as i, TOKEN_WHITESPACE as k, TOKEN_COMMA as l, TOKEN_FUNCTION as m, tokenize as n, TOKEN_CDC as o, TOKEN_EOF as p, TOKEN_AT_KEYWORD as r, TOKEN_CDO as s, Lexer as t, TOKEN_COMMENT as u, TOKEN_LEFT_BRACKET as v, TOKEN_RIGHT_PAREN as w, TOKEN_PERCENTAGE as x, TOKEN_LEFT_PAREN as y };
709
+ export { tokenize as n, Lexer as t };
@@ -1,2 +1,97 @@
1
- import { i as tokenize, n as Lexer, r as LexerPosition, t as CommentInfo } from "./tokenize-CDEnYcVG.js";
2
- export { CommentInfo, Lexer, LexerPosition, tokenize };
1
+ import { O as Token, k as TokenType } from "./token-types-Bqsf5FX-.js";
2
+ //#region src/tokenize.d.ts
3
+ export interface LexerPosition {
4
+ pos: number;
5
+ line: number;
6
+ column: number;
7
+ _line_offset: number;
8
+ token_type: TokenType;
9
+ token_start: number;
10
+ token_end: number;
11
+ token_line: number;
12
+ token_column: number;
13
+ }
14
+ export interface CommentInfo {
15
+ start: number;
16
+ end: number;
17
+ length: number;
18
+ line: number;
19
+ column: number;
20
+ }
21
+ /** @internal */
22
+ export declare class Lexer {
23
+ source: string;
24
+ pos: number;
25
+ private _line;
26
+ private _line_offset;
27
+ on_comment: ((info: CommentInfo) => void) | undefined;
28
+ token_type: TokenType;
29
+ token_start: number;
30
+ token_end: number;
31
+ token_line: number;
32
+ token_column: number;
33
+ constructor(source: string, on_comment?: (info: CommentInfo) => void);
34
+ get line(): number;
35
+ get column(): number;
36
+ seek(pos: number, line: number, column?: number): void;
37
+ next_token_fast(skip_whitespace?: boolean): TokenType;
38
+ private _scan_newlines;
39
+ private _skip_comment;
40
+ /**
41
+ * Fast-forward to the next `target` char that isn't inside a string or comment, without
42
+ * fully tokenizing what's in between — used by callers that only need to know *where a
43
+ * construct ends* (e.g. a selector's `{`), since the sub-parser for that construct
44
+ * re-tokenizes the span properly afterward.
45
+ *
46
+ * Strings go through consume_string and comments through _skip_comment, so escapes and
47
+ * on_comment callbacks behave identically to real tokenization. Ordinary characters cost
48
+ * one SKIP_SCAN_INTERESTING lookup each, same as consume_ident_or_function's inner loop.
49
+ *
50
+ * Returns true with this.pos at target, or false with this.pos at source_length.
51
+ */
52
+ skip_to_unquoted(target: number): boolean;
53
+ /**
54
+ * Same approach as skip_to_unquoted, but stops at any of `; { } ( ) !` — the stop
55
+ * characters parse-declaration.ts's value scan needs (paren depth, statement end,
56
+ * !important). The caller decides what each one means; this only locates the next one.
57
+ *
58
+ * Returns the stop character's code (this.pos left at it), or 0 at `end` if none found.
59
+ */
60
+ skip_to_declaration_stop(end: number): number;
61
+ consume_whitespace(start_line: number, start_column: number): TokenType;
62
+ consume_string(quote: number, start_line: number, start_column: number): TokenType;
63
+ consume_hex_escape(): void;
64
+ consume_number(start_line: number, start_column: number): TokenType;
65
+ consume_ident_or_function(start_line: number, start_column: number): TokenType;
66
+ consume_unicode_range(start: number, start_line: number, start_column: number): TokenType;
67
+ consume_at_keyword(start_line: number, start_column: number): TokenType;
68
+ consume_hash(start_line: number, start_column: number): TokenType;
69
+ advance(count?: number): void;
70
+ peek(offset?: number): number;
71
+ make_token(type: TokenType, start: number, end: number, line?: number, column?: number): TokenType;
72
+ next_token(skip_whitespace?: boolean): Token | null;
73
+ /**
74
+ * Save complete lexer state for backtracking
75
+ * @returns Object containing all lexer state
76
+ */
77
+ save_position(): LexerPosition;
78
+ save_position_into(target: LexerPosition): LexerPosition;
79
+ /**
80
+ * Restore lexer state from saved position
81
+ * @param saved The saved position to restore
82
+ */
83
+ restore_position(saved: LexerPosition): void;
84
+ /**
85
+ * Skip whitespace and comments within a range, maintaining line/column tracking
86
+ * @param end The end boundary (exclusive)
87
+ */
88
+ skip_whitespace_in_range(end: number): void;
89
+ }
90
+ /**
91
+ * Tokenize CSS source code
92
+ * @param source - The CSS source code to tokenize
93
+ * @param on_comment - Optional callback for comment tokens
94
+ * @yields CSS tokens
95
+ */
96
+ export declare function tokenize(source: string, on_comment?: (info: CommentInfo) => void): Generator<Token, void, undefined>;
97
+ //#endregion
package/dist/tokenize.js CHANGED
@@ -1,2 +1 @@
1
- import { n as tokenize, t as Lexer } from "./tokenize-BYl6GvyV.js";
2
- export { Lexer, tokenize };
1
+ export { t as Lexer, n as tokenize } from "./tokenize-Ccg58Z_k.js";