@tbela99/css-parser 1.3.0 → 1.3.2

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/index.d.ts CHANGED
@@ -1,5 +1,16 @@
1
1
  /**
2
- * validation level enum
2
+ * syntax validation enum
3
+ */
4
+ declare enum SyntaxValidationResult {
5
+ /** valid syntax */
6
+ Valid = 0,
7
+ /** drop invalid syntax */
8
+ Drop = 1,
9
+ /** preserve unknown at-rules, declarations and pseudo-classes */
10
+ Lenient = 2
11
+ }
12
+ /**
13
+ * enum of validation levels
3
14
  */
4
15
  declare enum ValidationLevel {
5
16
  /**
@@ -16,134 +27,500 @@ declare enum ValidationLevel {
16
27
  All = 2
17
28
  }
18
29
  /**
19
- * token types enum
30
+ * enum of all token types
20
31
  */
21
32
  declare enum EnumToken {
33
+ /**
34
+ * comment token
35
+ */
22
36
  CommentTokenType = 0,
37
+ /**
38
+ * cdata section token
39
+ */
23
40
  CDOCOMMTokenType = 1,
41
+ /**
42
+ * style sheet node type
43
+ */
24
44
  StyleSheetNodeType = 2,
45
+ /**
46
+ * at-rule node type
47
+ */
25
48
  AtRuleNodeType = 3,
49
+ /**
50
+ * rule node type
51
+ */
26
52
  RuleNodeType = 4,
53
+ /**
54
+ * declaration node type
55
+ */
27
56
  DeclarationNodeType = 5,
57
+ /**
58
+ * literal token type
59
+ */
28
60
  LiteralTokenType = 6,
61
+ /**
62
+ * identifier token type
63
+ */
29
64
  IdenTokenType = 7,
65
+ /**
66
+ * dashed identifier token type
67
+ */
30
68
  DashedIdenTokenType = 8,
69
+ /**
70
+ * comma token type
71
+ */
31
72
  CommaTokenType = 9,
73
+ /**
74
+ * colon token type
75
+ */
32
76
  ColonTokenType = 10,
77
+ /**
78
+ * semicolon token type
79
+ */
33
80
  SemiColonTokenType = 11,
81
+ /**
82
+ * number token type
83
+ */
34
84
  NumberTokenType = 12,
85
+ /**
86
+ * at-rule token type
87
+ */
35
88
  AtRuleTokenType = 13,
89
+ /**
90
+ * percentage token type
91
+ */
36
92
  PercentageTokenType = 14,
93
+ /**
94
+ * function token type
95
+ */
37
96
  FunctionTokenType = 15,
97
+ /**
98
+ * timeline function token type
99
+ */
38
100
  TimelineFunctionTokenType = 16,
101
+ /**
102
+ * timing function token type
103
+ */
39
104
  TimingFunctionTokenType = 17,
105
+ /**
106
+ * url function token type
107
+ */
40
108
  UrlFunctionTokenType = 18,
109
+ /**
110
+ * image function token type
111
+ */
41
112
  ImageFunctionTokenType = 19,
113
+ /**
114
+ * string token type
115
+ */
42
116
  StringTokenType = 20,
117
+ /**
118
+ * unclosed string token type
119
+ */
43
120
  UnclosedStringTokenType = 21,
121
+ /**
122
+ * dimension token type
123
+ */
44
124
  DimensionTokenType = 22,
125
+ /**
126
+ * length token type
127
+ */
45
128
  LengthTokenType = 23,
129
+ /**
130
+ * angle token type
131
+ */
46
132
  AngleTokenType = 24,
133
+ /**
134
+ * time token type
135
+ */
47
136
  TimeTokenType = 25,
137
+ /**
138
+ * frequency token type
139
+ */
48
140
  FrequencyTokenType = 26,
141
+ /**
142
+ * resolution token type
143
+ */
49
144
  ResolutionTokenType = 27,
145
+ /**
146
+ * hash token type
147
+ */
50
148
  HashTokenType = 28,
149
+ /**
150
+ * block start token type
151
+ */
51
152
  BlockStartTokenType = 29,
153
+ /**
154
+ * block end token type
155
+ */
52
156
  BlockEndTokenType = 30,
157
+ /**
158
+ * attribute start token type
159
+ */
53
160
  AttrStartTokenType = 31,
161
+ /**
162
+ * attribute end token type
163
+ */
54
164
  AttrEndTokenType = 32,
165
+ /**
166
+ * start parentheses token type
167
+ */
55
168
  StartParensTokenType = 33,
169
+ /**
170
+ * end parentheses token type
171
+ */
56
172
  EndParensTokenType = 34,
173
+ /**
174
+ * parentheses token type
175
+ */
57
176
  ParensTokenType = 35,
177
+ /**
178
+ * whitespace token type
179
+ */
58
180
  WhitespaceTokenType = 36,
181
+ /**
182
+ * include match token type
183
+ */
59
184
  IncludeMatchTokenType = 37,
185
+ /**
186
+ * dash match token type
187
+ */
60
188
  DashMatchTokenType = 38,
189
+ /**
190
+ * equal match token type
191
+ */
61
192
  EqualMatchTokenType = 39,
193
+ /**
194
+ * less than token type
195
+ */
62
196
  LtTokenType = 40,
197
+ /**
198
+ * less than or equal to token type
199
+ */
63
200
  LteTokenType = 41,
201
+ /**
202
+ * greater than token type
203
+ */
64
204
  GtTokenType = 42,
205
+ /**
206
+ * greater than or equal to token type
207
+ */
65
208
  GteTokenType = 43,
209
+ /**
210
+ * pseudo-class token type
211
+ */
66
212
  PseudoClassTokenType = 44,
213
+ /**
214
+ * pseudo-class function token type
215
+ */
67
216
  PseudoClassFuncTokenType = 45,
217
+ /**
218
+ * delimiter token type
219
+ */
68
220
  DelimTokenType = 46,
221
+ /**
222
+ * URL token type
223
+ */
69
224
  UrlTokenTokenType = 47,
225
+ /**
226
+ * end of file token type
227
+ */
70
228
  EOFTokenType = 48,
229
+ /**
230
+ * important token type
231
+ */
71
232
  ImportantTokenType = 49,
233
+ /**
234
+ * color token type
235
+ */
72
236
  ColorTokenType = 50,
237
+ /**
238
+ * attribute token type
239
+ */
73
240
  AttrTokenType = 51,
241
+ /**
242
+ * bad comment token type
243
+ */
74
244
  BadCommentTokenType = 52,
245
+ /**
246
+ * bad cdo token type
247
+ */
75
248
  BadCdoTokenType = 53,
249
+ /**
250
+ * bad URL token type
251
+ */
76
252
  BadUrlTokenType = 54,
253
+ /**
254
+ * bad string token type
255
+ */
77
256
  BadStringTokenType = 55,
257
+ /**
258
+ * binary expression token type
259
+ */
78
260
  BinaryExpressionTokenType = 56,
261
+ /**
262
+ * unary expression token type
263
+ */
79
264
  UnaryExpressionTokenType = 57,
265
+ /**
266
+ * flex token type
267
+ */
80
268
  FlexTokenType = 58,
269
+ /**
270
+ * token list token type
271
+ */
81
272
  ListToken = 59,
273
+ /**
274
+ * addition token type
275
+ */
82
276
  Add = 60,
277
+ /**
278
+ * multiplication token type
279
+ */
83
280
  Mul = 61,
281
+ /**
282
+ * division token type
283
+ */
84
284
  Div = 62,
285
+ /**
286
+ * subtraction token type
287
+ */
85
288
  Sub = 63,
289
+ /**
290
+ * column combinator token type
291
+ */
86
292
  ColumnCombinatorTokenType = 64,
293
+ /**
294
+ * contain match token type
295
+ */
87
296
  ContainMatchTokenType = 65,
297
+ /**
298
+ * start match token type
299
+ */
88
300
  StartMatchTokenType = 66,
301
+ /**
302
+ * end match token type
303
+ */
89
304
  EndMatchTokenType = 67,
305
+ /**
306
+ * match expression token type
307
+ */
90
308
  MatchExpressionTokenType = 68,
309
+ /**
310
+ * namespace attribute token type
311
+ */
91
312
  NameSpaceAttributeTokenType = 69,
313
+ /**
314
+ * fraction token type
315
+ */
92
316
  FractionTokenType = 70,
317
+ /**
318
+ * identifier list token type
319
+ */
93
320
  IdenListTokenType = 71,
321
+ /**
322
+ * grid template function token type
323
+ */
94
324
  GridTemplateFuncTokenType = 72,
325
+ /**
326
+ * keyframe rule node type
327
+ */
95
328
  KeyFrameRuleNodeType = 73,
329
+ /**
330
+ * class selector token type
331
+ */
96
332
  ClassSelectorTokenType = 74,
333
+ /**
334
+ * universal selector token type
335
+ */
97
336
  UniversalSelectorTokenType = 75,
337
+ /**
338
+ * child combinator token type
339
+ */
98
340
  ChildCombinatorTokenType = 76,// >
341
+ /**
342
+ * descendant combinator token type
343
+ */
99
344
  DescendantCombinatorTokenType = 77,// whitespace
345
+ /**
346
+ * next sibling combinator token type
347
+ */
100
348
  NextSiblingCombinatorTokenType = 78,// +
349
+ /**
350
+ * subsequent sibling combinator token type
351
+ */
101
352
  SubsequentSiblingCombinatorTokenType = 79,// ~
353
+ /**
354
+ * nesting selector token type
355
+ */
102
356
  NestingSelectorTokenType = 80,// &
357
+ /**
358
+ * invalid rule token type
359
+ */
103
360
  InvalidRuleTokenType = 81,
361
+ /**
362
+ * invalid class selector token type
363
+ */
104
364
  InvalidClassSelectorTokenType = 82,
365
+ /**
366
+ * invalid attribute token type
367
+ */
105
368
  InvalidAttrTokenType = 83,
369
+ /**
370
+ * invalid at rule token type
371
+ */
106
372
  InvalidAtRuleTokenType = 84,
373
+ /**
374
+ * media query condition token type
375
+ */
107
376
  MediaQueryConditionTokenType = 85,
377
+ /**
378
+ * media feature token type
379
+ */
108
380
  MediaFeatureTokenType = 86,
381
+ /**
382
+ * media feature only token type
383
+ */
109
384
  MediaFeatureOnlyTokenType = 87,
385
+ /**
386
+ * media feature not token type
387
+ */
110
388
  MediaFeatureNotTokenType = 88,
389
+ /**
390
+ * media feature and token type
391
+ */
111
392
  MediaFeatureAndTokenType = 89,
393
+ /**
394
+ * media feature or token type
395
+ */
112
396
  MediaFeatureOrTokenType = 90,
397
+ /**
398
+ * pseudo page token type
399
+ */
113
400
  PseudoPageTokenType = 91,
401
+ /**
402
+ * pseudo element token type
403
+ */
114
404
  PseudoElementTokenType = 92,
405
+ /**
406
+ * keyframe at rule node type
407
+ */
115
408
  KeyframeAtRuleNodeType = 93,
409
+ /**
410
+ * invalid declaration node type
411
+ */
116
412
  InvalidDeclarationNodeType = 94,
413
+ /**
414
+ * alias for time token type
415
+ */
117
416
  Time = 25,
417
+ /**
418
+ * alias for identifier token type
419
+ */
118
420
  Iden = 7,
421
+ /**
422
+ * alias for end of file token type
423
+ */
119
424
  EOF = 48,
425
+ /**
426
+ * alias for hash token type
427
+ */
120
428
  Hash = 28,
429
+ /**
430
+ * alias for flex token type
431
+ */
121
432
  Flex = 58,
433
+ /**
434
+ * alias for angle token type
435
+ */
122
436
  Angle = 24,
437
+ /**
438
+ * alias for color token type
439
+ */
123
440
  Color = 50,
441
+ /**
442
+ * alias for comma token type
443
+ */
124
444
  Comma = 9,
445
+ /**
446
+ * alias for string token type
447
+ */
125
448
  String = 20,
449
+ /**
450
+ * alias for length token type
451
+ */
126
452
  Length = 23,
453
+ /**
454
+ * alias for number token type
455
+ */
127
456
  Number = 12,
457
+ /**
458
+ * alias for percentage token type
459
+ */
128
460
  Perc = 14,
461
+ /**
462
+ * alias for literal token type
463
+ */
129
464
  Literal = 6,
465
+ /**
466
+ * alias for comment token type
467
+ */
130
468
  Comment = 0,
469
+ /**
470
+ * alias for url function token type
471
+ */
131
472
  UrlFunc = 18,
473
+ /**
474
+ * alias for dimension token type
475
+ */
132
476
  Dimension = 22,
477
+ /**
478
+ * alias for frequency token type
479
+ */
133
480
  Frequency = 26,
481
+ /**
482
+ * alias for resolution token type
483
+ */
134
484
  Resolution = 27,
485
+ /**
486
+ * alias for whitespace token type
487
+ */
135
488
  Whitespace = 36,
489
+ /**
490
+ * alias for identifier list token type
491
+ */
136
492
  IdenList = 71,
493
+ /**
494
+ * alias for dashed identifier token type
495
+ */
137
496
  DashedIden = 8,
497
+ /**
498
+ * alias for grid template function token type
499
+ */
138
500
  GridTemplateFunc = 72,
501
+ /**
502
+ * alias for image function token type
503
+ */
139
504
  ImageFunc = 19,
505
+ /**
506
+ * alias for comment node type
507
+ */
140
508
  CommentNodeType = 0,
509
+ /**
510
+ * alias for cdata section node type
511
+ */
141
512
  CDOCOMMNodeType = 1,
513
+ /**
514
+ * alias for timing function token type
515
+ */
142
516
  TimingFunction = 17,
517
+ /**
518
+ * alias for timeline function token type
519
+ */
143
520
  TimelineFunction = 16
144
521
  }
145
522
  /**
146
- * color types enum
523
+ * supported color types enum
147
524
  */
148
525
  declare enum ColorType {
149
526
  /**
@@ -257,26 +634,43 @@ declare enum ColorType {
257
634
  }
258
635
 
259
636
  /**
260
- * minify ast
637
+ * apply minification rules to the ast tree
261
638
  * @param ast
262
639
  * @param options
263
640
  * @param recursive
264
641
  * @param errors
265
642
  * @param nestingContent
266
- * @param context
643
+ *
644
+ * @private
267
645
  */
268
- declare function minify(ast: AstNode, options?: ParserOptions, recursive?: boolean, errors?: ErrorDescription[], nestingContent?: boolean, context?: {
269
- [key: string]: any;
270
- }): AstNode;
646
+ declare function minify(ast: AstNode, options: ParserOptions | MinifyFeatureOptions, recursive: boolean, errors?: ErrorDescription[], nestingContent?: boolean): AstNode;
271
647
 
272
648
  declare enum WalkerOptionEnum {
649
+ /**
650
+ * ignore the current node and its children
651
+ */
273
652
  Ignore = 0,
653
+ /**
654
+ * stop walking the tree
655
+ */
274
656
  Stop = 1,
657
+ /**
658
+ * ignore node and process children
659
+ */
275
660
  Children = 2,
661
+ /**
662
+ * ignore children
663
+ */
276
664
  IgnoreChildren = 3
277
665
  }
278
666
  declare enum WalkerValueEvent {
667
+ /**
668
+ * enter node
669
+ */
279
670
  Enter = 0,
671
+ /**
672
+ * leave node
673
+ */
280
674
  Leave = 1
281
675
  }
282
676
  /**
@@ -299,49 +693,104 @@ declare function walkValues(values: Token[], root?: AstNode | Token | null, filt
299
693
  }, reverse?: boolean): Generator<WalkAttributesResult>;
300
694
 
301
695
  /**
302
- * expand nested css ast
696
+ * expand css nesting ast nodes
303
697
  * @param ast
698
+ *
699
+ * @private
304
700
  */
305
701
  declare function expand(ast: AstNode): AstNode;
306
702
 
307
703
  /**
308
- * render ast token
704
+ *
309
705
  * @param token
310
706
  * @param options
311
- * @param cache
312
- * @param reducer
313
- * @param errors
707
+ *
708
+ * @private
314
709
  */
315
710
  declare function renderToken(token: Token, options?: RenderOptions, cache?: {
316
711
  [key: string]: any;
317
712
  }, reducer?: (acc: string, curr: Token) => string, errors?: ErrorDescription[]): string;
318
713
 
319
714
  /**
320
- * Calculate the distance between two okLab colors.
321
- * @param okLab1
322
- * @param okLab2
715
+ * Source map class
716
+ * @internal
323
717
  */
324
- declare function okLabDistance(okLab1: [number, number, number], okLab2: [number, number, number]): number;
718
+ declare class SourceMap {
719
+ #private;
720
+ /**
721
+ * Last location
722
+ */
723
+ lastLocation: Location | null;
724
+ /**
725
+ * Add a location
726
+ * @param source
727
+ * @param original
728
+ */
729
+ add(source: Location, original: Location): void;
730
+ /**
731
+ * Convert to URL encoded string
732
+ */
733
+ toUrl(): string;
734
+ /**
735
+ * Convert to JSON object
736
+ */
737
+ toJSON(): SourceMapObject;
738
+ }
739
+
325
740
  /**
326
- * Check if two colors are close.
327
- * @param color1
328
- * @param color2
329
- * @param threshold
741
+ * parse a string as an array of declaration nodes
742
+ * @param declaration
743
+ *
744
+ * Example:
745
+ * ````ts
746
+ *
747
+ * const declarations = await parseDeclarations('color: red; background: blue');
748
+ * console.log(declarations);
749
+ * ```
330
750
  */
331
- declare function isOkLabClose(color1: ColorToken, color2: ColorToken, threshold?: number): boolean;
332
-
751
+ declare function parseDeclarations(declaration: string): Promise<AstDeclaration[]>;
333
752
  /**
334
- * parse css string
753
+ * parse css string and return an array of tokens
335
754
  * @param src
336
755
  * @param options
756
+ *
757
+ * @private
758
+ *
759
+ * Example:
760
+ *
761
+ * ```ts
762
+ *
763
+ * import {parseString} from '@tbela99/css-parser';
764
+ *
765
+ * let tokens = parseString('body { color: red; }');
766
+ * console.log(tokens);
767
+ *
768
+ * tokens = parseString('#c322c980');
769
+ * console.log(tokens);
770
+ * ```
337
771
  */
338
772
  declare function parseString(src: string, options?: {
339
773
  location: boolean;
340
774
  }): Token[];
341
775
  /**
342
- * parse token array into a tree structure
776
+ * parse function tokens in a token array
343
777
  * @param tokens
344
778
  * @param options
779
+ *
780
+ * Example:
781
+ *
782
+ * ```ts
783
+ *
784
+ * import {parseString, parseTokens} from '@tbela99/css-parser';
785
+ *
786
+ * let tokens = parseString('body { color: red; }');
787
+ * console.log(parseTokens(tokens));
788
+ *
789
+ * tokens = parseString('#c322c980');
790
+ * console.log(parseTokens(tokens));
791
+ * ```
792
+ *
793
+ * @private
345
794
  */
346
795
  declare function parseTokens(tokens: Token[], options?: ParseTokenOptions): Token[];
347
796
 
@@ -1016,6 +1465,13 @@ declare enum ValidationTokenEnum {
1016
1465
  Character = 39,
1017
1466
  InfinityToken = 40
1018
1467
  }
1468
+ declare const enum ValidationSyntaxGroupEnum {
1469
+ Declarations = "declarations",
1470
+ Functions = "functions",
1471
+ Syntaxes = "syntaxes",
1472
+ Selectors = "selectors",
1473
+ AtRules = "atRules"
1474
+ }
1019
1475
  interface Position$1 {
1020
1476
  ind: number;
1021
1477
  lin: number;
@@ -1036,24 +1492,141 @@ interface ValidationToken {
1036
1492
  };
1037
1493
  }
1038
1494
 
1495
+ export declare interface ValidationSyntaxNode {
1496
+
1497
+ syntax: string;
1498
+ ast?: ValidationToken[];
1499
+ }
1500
+
1501
+ interface ValidationSelectorOptions extends ValidationOptions {
1502
+
1503
+ nestedSelector?: boolean;
1504
+ }
1505
+
1506
+ export declare interface ValidationConfiguration {
1507
+
1508
+ [ValidationSyntaxGroupEnum.Declarations]: ValidationSyntaxNode;
1509
+ [ValidationSyntaxGroupEnum.Functions]: ValidationSyntaxNode;
1510
+ [ValidationSyntaxGroupEnum.Syntaxes]: ValidationSyntaxNode;
1511
+ [ValidationSyntaxGroupEnum.Selectors]: ValidationSyntaxNode;
1512
+ [ValidationSyntaxGroupEnum.AtRules]: ValidationSyntaxNode;
1513
+ }
1514
+
1515
+ //= Record<keyof ValidationSyntaxGroupEnum, ValidationSyntaxNode>;
1516
+
1517
+ interface ValidationResult {
1518
+
1519
+ valid: SyntaxValidationResult;
1520
+ node: AstNode | Token | null;
1521
+ syntax: ValidationToken | string | null;
1522
+ error: string;
1523
+ cycle?: boolean;
1524
+ }
1525
+
1526
+ interface ValidationSyntaxResult extends ValidationResult {
1527
+
1528
+ syntax: ValidationToken | string | null;
1529
+ context: Context<Token> | Token[];
1530
+ }
1531
+
1532
+ interface Context<Type> {
1533
+
1534
+ index: number;
1535
+
1536
+ /**
1537
+ * The length of the context tokens to be consumed
1538
+ */
1539
+
1540
+ readonly length: number;
1541
+
1542
+ current<Type>(): Type | null;
1543
+
1544
+ update<Type>(context: Context<Type>): void;
1545
+
1546
+ consume<Type>(token: Type, howMany?: number): boolean;
1547
+
1548
+ peek<Type>(): Type | null;
1549
+
1550
+ // tokens<Type>(): Type[];
1551
+
1552
+ next<Type>(): Type | null;
1553
+
1554
+ consume<Type>(token: Type, howMany?: number): boolean;
1555
+
1556
+ slice<Type>(): Type[];
1557
+
1558
+ clone<Type>(): Context<Type>;
1559
+
1560
+ done(): boolean;
1561
+ }
1562
+
1039
1563
  /**
1040
1564
  * Converts a color to another color space
1041
1565
  * @param token
1042
1566
  * @param to
1567
+ *
1568
+ * <code>
1569
+ *
1570
+ * const token = {typ: EnumToken.ColorTokenType, kin: ColorType.HEX, val: '#F00'}
1571
+ * const result = convertColor(token, ColorType.LCH);
1572
+ *
1573
+ * </code>
1043
1574
  */
1044
1575
  declare function convertColor(token: ColorToken, to: ColorType): ColorToken | null;
1045
1576
 
1577
+ /**
1578
+ * Calculate the distance between two okLab colors.
1579
+ * @param okLab1
1580
+ * @param okLab2
1581
+ *
1582
+ * @private
1583
+ */
1584
+ declare function okLabDistance(okLab1: [number, number, number], okLab2: [number, number, number]): number;
1585
+ /**
1586
+ * Check if two colors are close in okLab space.
1587
+ * @param color1
1588
+ * @param color2
1589
+ * @param threshold
1590
+ *
1591
+ * @private
1592
+ */
1593
+ declare function isOkLabClose(color1: ColorToken, color2: ColorToken, threshold?: number): boolean;
1594
+
1595
+ /**
1596
+ * Position
1597
+ */
1046
1598
  export declare interface Position {
1047
1599
 
1600
+ /**
1601
+ * index in the source
1602
+ */
1048
1603
  ind: number;
1604
+ /**
1605
+ * line number
1606
+ */
1049
1607
  lin: number;
1608
+ /**
1609
+ * column number
1610
+ */
1050
1611
  col: number;
1051
1612
  }
1052
1613
 
1614
+ /**
1615
+ * token or node location
1616
+ */
1053
1617
  export declare interface Location {
1054
1618
 
1619
+ /**
1620
+ * start position
1621
+ */
1055
1622
  sta: Position;
1623
+ /**
1624
+ * end position
1625
+ */
1056
1626
  end: Position;
1627
+ /**
1628
+ * source file
1629
+ */
1057
1630
  src: string;
1058
1631
  }
1059
1632
 
@@ -1101,6 +1674,13 @@ export declare interface AstInvalidDeclaration extends BaseToken {
1101
1674
  val: Array<AstNode>;
1102
1675
  }
1103
1676
 
1677
+ export declare interface AstInvalidAtRule extends BaseToken {
1678
+
1679
+ typ: EnumToken.InvalidAtRuleTokenType;
1680
+ val: string;
1681
+ chi?: Array<AstNode>;
1682
+ }
1683
+
1104
1684
  export declare interface AstKeyFrameRule extends BaseToken {
1105
1685
 
1106
1686
  typ: EnumToken.KeyFrameRuleNodeType;
@@ -1120,6 +1700,13 @@ export declare interface OptimizedSelector {
1120
1700
  reducible: boolean;
1121
1701
  }
1122
1702
 
1703
+ export declare interface OptimizedSelectorToken {
1704
+ match: boolean;
1705
+ optimized: Token[];
1706
+ selector: Token[][],
1707
+ reducible: boolean;
1708
+ }
1709
+
1123
1710
  export declare interface AstAtRule extends BaseToken {
1124
1711
 
1125
1712
  typ: EnumToken.AtRuleNodeType,
@@ -1171,37 +1758,210 @@ export declare type AstNode =
1171
1758
  /**
1172
1759
  * Declaration visitor handler
1173
1760
  */
1174
- export declare type DeclarationVisitorHandler = (node: AstDeclaration) => AstDeclaration | AstDeclaration[] | null | Promise<AstDeclaration | AstDeclaration[] | null>;
1761
+ export declare type DeclarationVisitorHandler = (node: AstDeclaration) => (AstDeclaration | AstDeclaration[] | null | Promise<AstDeclaration> | Promise<AstDeclaration[]> | Promise<null>);
1175
1762
  /**
1176
1763
  * Rule visitor handler
1177
1764
  */
1178
- export declare type RuleVisitorHandler = (node: AstRule) => AstRule | AstRule[] | null | Promise<AstRule | AstRule[] | null>;
1765
+ export declare type RuleVisitorHandler = (node: AstRule) => (AstRule | AstRule[] | null | Promise<AstRule> | Promise<AstRule[]> | Promise<null>);
1179
1766
 
1180
1767
  /**
1181
1768
  * AtRule visitor handler
1182
1769
  */
1183
- export declare type AtRuleVisitorHandler = (node: AstAtRule) => AstAtRule | AstAtRule[] | null | Promise<AstAtRule | AstAtRule[] | null>;
1770
+ export declare type AtRuleVisitorHandler = (node: AstAtRule) => (AstAtRule | AstAtRule[] | null | Promise<AstAtRule> | Promise<AstAtRule[]> | Promise<null>);
1184
1771
 
1185
1772
  /**
1186
- * Value visitor handler
1773
+ * node visitor callback map
1774
+ *
1187
1775
  */
1188
- export declare type ValueVisitorHandler = (node: Token) => Token | Token[] | null | Promise<Token | Token[] | null>;
1189
-
1190
-
1191
1776
  export declare interface VisitorNodeMap {
1192
1777
 
1778
+ /**
1779
+ * at rule visitor
1780
+ *
1781
+ * Example: change media at-rule prelude
1782
+ *
1783
+ * ```ts
1784
+ *
1785
+ * import {transform, AstAtRule, ParserOptions} from "@tbela99/css-parser";
1786
+ *
1787
+ * const options: ParserOptions = {
1788
+ *
1789
+ * visitor: {
1790
+ *
1791
+ * AtRule: {
1792
+ *
1793
+ * media: (node: AstAtRule): AstAtRule => {
1794
+ *
1795
+ * node.val = 'tv,screen';
1796
+ * return node
1797
+ * }
1798
+ * }
1799
+ * }
1800
+ * };
1801
+ *
1802
+ * const css = `
1803
+ *
1804
+ * @media screen {
1805
+ *
1806
+ * .foo {
1807
+ *
1808
+ * height: calc(100px * 2/ 15);
1809
+ * }
1810
+ * }
1811
+ * `;
1812
+ *
1813
+ * const result = await transform(css, options);
1814
+ *
1815
+ * console.debug(result.code);
1816
+ *
1817
+ * // @media tv,screen{.foo{height:calc(40px/3)}}
1818
+ * ```
1819
+ */
1193
1820
  AtRule?: Record<string, AtRuleVisitorHandler> | AtRuleVisitorHandler;
1821
+ /**
1822
+ * declaration visitor
1823
+ *
1824
+ * Example: add 'width: 3px' everytime a declaration with the name 'height' is found
1825
+ *
1826
+ * ```ts
1827
+ *
1828
+ * import {transform, parseDeclarations} from "@tbela99/css-parser";
1829
+ *
1830
+ * const options: ParserOptions = {
1831
+ *
1832
+ * removeEmpty: false,
1833
+ * visitor: {
1834
+ *
1835
+ * Declaration: {
1836
+ *
1837
+ * // called only for height declaration
1838
+ * height: (node: AstDeclaration): AstDeclaration[] => {
1839
+ *
1840
+ *
1841
+ * return [
1842
+ * node,
1843
+ * {
1844
+ *
1845
+ * typ: EnumToken.DeclarationNodeType,
1846
+ * nam: 'width',
1847
+ * val: [
1848
+ * <LengthToken>{
1849
+ * typ: EnumToken.LengthTokenType,
1850
+ * val: 3,
1851
+ * unit: 'px'
1852
+ * }
1853
+ * ]
1854
+ * }
1855
+ * ];
1856
+ * }
1857
+ * }
1858
+ * }
1859
+ * };
1860
+ *
1861
+ * const css = `
1862
+ *
1863
+ * .foo {
1864
+ * height: calc(100px * 2/ 15);
1865
+ * }
1866
+ * .selector {
1867
+ * color: lch(from peru calc(l * 0.8) calc(c * 0.7) calc(h + 180))
1868
+ * }
1869
+ * `;
1870
+ *
1871
+ * console.debug(await transform(css, options));
1872
+ *
1873
+ * // .foo{height:calc(40px/3);width:3px}.selector{color:#0880b0}
1874
+ * ```
1875
+ *
1876
+ * Example: rename 'margin' to 'padding' and 'height' to 'width'
1877
+ *
1878
+ * ```ts
1879
+ * import {AstDeclaration, ParserOptions, transform} from "../src/node.ts";
1880
+ *
1881
+ * const options: ParserOptions = {
1882
+ *
1883
+ * visitor: {
1884
+ *
1885
+ * // called for every declaration
1886
+ * Declaration: (node: AstDeclaration): null => {
1887
+ *
1888
+ *
1889
+ * if (node.nam == 'height') {
1890
+ *
1891
+ * node.nam = 'width';
1892
+ * }
1893
+ *
1894
+ * else if (node.nam == 'margin') {
1895
+ *
1896
+ * node.nam = 'padding'
1897
+ * }
1898
+ *
1899
+ * return null;
1900
+ * }
1901
+ * }
1902
+ * };
1903
+ *
1904
+ * const css = `
1905
+ *
1906
+ * .foo {
1907
+ * height: calc(100px * 2/ 15);
1908
+ * margin: 10px;
1909
+ * }
1910
+ * .selector {
1911
+ *
1912
+ * margin: 20px;}
1913
+ * `;
1914
+ *
1915
+ * const result = await transform(css, options);
1916
+ *
1917
+ * console.debug(result.code);
1918
+ *
1919
+ * // .foo{width:calc(40px/3);padding:10px}.selector{padding:20px}
1920
+ * ```
1921
+ */
1194
1922
  Declaration?: Record<string, DeclarationVisitorHandler> | DeclarationVisitorHandler;
1195
- Rule?: RuleVisitorHandler;
1196
- Value?: Record<EnumToken, ValueVisitorHandler> | ValueVisitorHandler;
1197
- }
1198
1923
 
1199
- declare class SourceMap {
1200
- #private;
1201
- lastLocation: Location | null;
1202
- add(source: Location, original: Location): void;
1203
- toUrl(): string;
1204
- toJSON(): SourceMapObject;
1924
+ /**
1925
+ * rule visitor
1926
+ *
1927
+ * Example: add 'width: 3px' to every rule with the selector '.foo'
1928
+ *
1929
+ * ```ts
1930
+ *
1931
+ * import {transform, parseDeclarations} from "@tbela99/css-parser";
1932
+ *
1933
+ * const options: ParserOptions = {
1934
+ *
1935
+ * removeEmpty: false,
1936
+ * visitor: {
1937
+ *
1938
+ * Rule: async (node: AstRule): Promise<AstRule | null> => {
1939
+ *
1940
+ * if (node.sel == '.foo') {
1941
+ *
1942
+ * node.chi.push(...await parseDeclarations('width: 3px'));
1943
+ * return node;
1944
+ * }
1945
+ *
1946
+ * return null;
1947
+ * }
1948
+ * }
1949
+ * };
1950
+ *
1951
+ * const css = `
1952
+ *
1953
+ * .foo {
1954
+ * .foo {
1955
+ * }
1956
+ * }
1957
+ * `;
1958
+ *
1959
+ * console.debug(await transform(css, options));
1960
+ *
1961
+ * // .foo{width:3px;.foo{width:3px}}
1962
+ * ```
1963
+ */
1964
+ Rule?: RuleVisitorHandler;
1205
1965
  }
1206
1966
 
1207
1967
  export declare interface PropertyListOptions {
@@ -1210,11 +1970,437 @@ export declare interface PropertyListOptions {
1210
1970
  computeShorthand?: boolean;
1211
1971
  }
1212
1972
 
1973
+ export declare interface ParseInfo {
1974
+
1975
+ buffer: string;
1976
+ stream: string;
1977
+ position: Position;
1978
+ currentPosition: Position;
1979
+ }
1980
+
1981
+ /**
1982
+ * feature walk mode
1983
+ */
1213
1984
  declare enum FeatureWalkMode {
1985
+ /**
1986
+ * pre process
1987
+ */
1214
1988
  Pre = 0,
1989
+ /**
1990
+ * post process
1991
+ */
1215
1992
  Post = 1
1216
1993
  }
1217
1994
 
1995
+ /**
1996
+ * supported transform functions
1997
+ *
1998
+ * @internal
1999
+ */
2000
+ declare const transformFunctions: string[];
2001
+ /**
2002
+ * supported math functions
2003
+ *
2004
+ * @internal
2005
+ */
2006
+ declare const mathFuncs: string[];
2007
+
2008
+ interface PropertyType {
2009
+
2010
+ shorthand: string;
2011
+ }
2012
+
2013
+ interface ShorthandPropertyType {
2014
+
2015
+ shorthand: string;
2016
+ map?: string;
2017
+ properties: string[];
2018
+ types: string[];
2019
+ multiple: boolean;
2020
+ separator: {
2021
+ typ: keyof EnumToken;
2022
+ val: string
2023
+ };
2024
+ keywords: string[];
2025
+ }
2026
+
2027
+ interface PropertySetType {
2028
+
2029
+ [key: string]: PropertyType | ShorthandPropertyType;
2030
+ }
2031
+
2032
+ interface PropertyMapType {
2033
+
2034
+ default: string[];
2035
+ types: string[];
2036
+ keywords: string[];
2037
+ required?: boolean;
2038
+ multiple?: boolean;
2039
+ prefix?: {
2040
+ typ: keyof EnumToken;
2041
+ val: string
2042
+ };
2043
+ previous?: string;
2044
+ separator?: {
2045
+
2046
+ typ: keyof EnumToken;
2047
+ };
2048
+ constraints?: {
2049
+ [key: string]: {
2050
+ [key: string]: any;
2051
+ }
2052
+ };
2053
+ mapping?: Record<string, string>
2054
+ }
2055
+
2056
+ interface ShorthandMapType {
2057
+
2058
+ shorthand: string;
2059
+ pattern: string;
2060
+ keywords: string[];
2061
+ default: string[];
2062
+ mapping?: Record<string, string>;
2063
+ multiple?: boolean;
2064
+ separator?: { typ: keyof EnumToken; val?: string };
2065
+ set?: Record<string, string[]>
2066
+ properties: {
2067
+ [property: string]: PropertyMapType;
2068
+ }
2069
+ }
2070
+
2071
+ interface ShorthandProperties {
2072
+ types: EnumToken[];
2073
+ default: string[];
2074
+ keywords: string[];
2075
+ required?: boolean;
2076
+ multiple?: boolean;
2077
+ constraints?: Array<any>;
2078
+ mapping?: {
2079
+ [key: string]: any;
2080
+ };
2081
+ validation?: {
2082
+ [key: string]: any;
2083
+ };
2084
+ prefix?: string;
2085
+ }
2086
+
2087
+ interface ShorthandDef {
2088
+ shorthand: string;
2089
+ pattern: string;
2090
+ keywords: string;
2091
+ defaults: string[];
2092
+ multiple?: boolean;
2093
+ separator?: string;
2094
+ }
2095
+
2096
+ interface ShorthandType {
2097
+ shorthand: string;
2098
+ properties: ShorthandProperties;
2099
+ }
2100
+
2101
+ // generated from config.json at https://app.quicktype.io/?l=ts
2102
+
2103
+ export declare interface PropertiesConfig {
2104
+ properties: PropertiesConfigProperties;
2105
+ map: Map$1;
2106
+ }
2107
+
2108
+ interface Map$1 {
2109
+ border: Border;
2110
+ "border-color": BackgroundPositionClass;
2111
+ "border-style": BackgroundPositionClass;
2112
+ "border-width": BackgroundPositionClass;
2113
+ outline: Outline;
2114
+ "outline-color": BackgroundPositionClass;
2115
+ "outline-style": BackgroundPositionClass;
2116
+ "outline-width": BackgroundPositionClass;
2117
+ font: Font;
2118
+ "font-weight": BackgroundPositionClass;
2119
+ "font-style": BackgroundPositionClass;
2120
+ "font-size": BackgroundPositionClass;
2121
+ "line-height": BackgroundPositionClass;
2122
+ "font-stretch": BackgroundPositionClass;
2123
+ "font-variant": BackgroundPositionClass;
2124
+ "font-family": BackgroundPositionClass;
2125
+ background: Background;
2126
+ "background-repeat": BackgroundPositionClass;
2127
+ "background-color": BackgroundPositionClass;
2128
+ "background-image": BackgroundPositionClass;
2129
+ "background-attachment": BackgroundPositionClass;
2130
+ "background-clip": BackgroundPositionClass;
2131
+ "background-origin": BackgroundPositionClass;
2132
+ "background-position": BackgroundPositionClass;
2133
+ "background-size": BackgroundPositionClass;
2134
+ }
2135
+
2136
+ interface Background {
2137
+ shorthand: string;
2138
+ pattern: string;
2139
+ keywords: string[];
2140
+ default: any[];
2141
+ multiple: boolean;
2142
+ separator: Separator;
2143
+ properties: BackgroundProperties;
2144
+ }
2145
+
2146
+ interface BackgroundProperties {
2147
+ "background-repeat": BackgroundRepeat;
2148
+ "background-color": PurpleBackgroundAttachment;
2149
+ "background-image": PurpleBackgroundAttachment;
2150
+ "background-attachment": PurpleBackgroundAttachment;
2151
+ "background-clip": PurpleBackgroundAttachment;
2152
+ "background-origin": PurpleBackgroundAttachment;
2153
+ "background-position": BackgroundPosition;
2154
+ "background-size": BackgroundSize;
2155
+ }
2156
+
2157
+ interface PurpleBackgroundAttachment {
2158
+ types: string[];
2159
+ default: string[];
2160
+ keywords: string[];
2161
+ required?: boolean;
2162
+ mapping?: BackgroundAttachmentMapping;
2163
+ }
2164
+
2165
+ interface BackgroundAttachmentMapping {
2166
+ "ultra-condensed": string;
2167
+ "extra-condensed": string;
2168
+ condensed: string;
2169
+ "semi-condensed": string;
2170
+ normal: string;
2171
+ "semi-expanded": string;
2172
+ expanded: string;
2173
+ "extra-expanded": string;
2174
+ "ultra-expanded": string;
2175
+ }
2176
+
2177
+ interface BackgroundPosition {
2178
+ multiple: boolean;
2179
+ types: string[];
2180
+ default: string[];
2181
+ keywords: string[];
2182
+ mapping: BackgroundPositionMapping;
2183
+ constraints: BackgroundPositionConstraints;
2184
+ }
2185
+
2186
+ interface BackgroundPositionConstraints {
2187
+ mapping: ConstraintsMapping;
2188
+ }
2189
+
2190
+ interface ConstraintsMapping {
2191
+ max: number;
2192
+ }
2193
+
2194
+ interface BackgroundPositionMapping {
2195
+ left: string;
2196
+ top: string;
2197
+ center: string;
2198
+ bottom: string;
2199
+ right: string;
2200
+ }
2201
+
2202
+ interface BackgroundRepeat {
2203
+ types: any[];
2204
+ default: string[];
2205
+ multiple: boolean;
2206
+ keywords: string[];
2207
+ mapping: BackgroundRepeatMapping;
2208
+ }
2209
+
2210
+ interface BackgroundRepeatMapping {
2211
+ "repeat no-repeat": string;
2212
+ "no-repeat repeat": string;
2213
+ "repeat repeat": string;
2214
+ "space space": string;
2215
+ "round round": string;
2216
+ "no-repeat no-repeat": string;
2217
+ }
2218
+
2219
+ interface BackgroundSize {
2220
+ multiple: boolean;
2221
+ previous: string;
2222
+ prefix: Prefix;
2223
+ types: string[];
2224
+ default: string[];
2225
+ keywords: string[];
2226
+ mapping: BackgroundSizeMapping;
2227
+ }
2228
+
2229
+ interface BackgroundSizeMapping {
2230
+ "auto auto": string;
2231
+ }
2232
+
2233
+ interface Prefix {
2234
+ typ: string;
2235
+ val: string;
2236
+ }
2237
+
2238
+ interface Separator {
2239
+ typ: string;
2240
+ }
2241
+
2242
+ interface BackgroundPositionClass {
2243
+ shorthand: string;
2244
+ }
2245
+
2246
+ interface Border {
2247
+ shorthand: string;
2248
+ pattern: string;
2249
+ keywords: string[];
2250
+ default: string[];
2251
+ properties: BorderProperties;
2252
+ }
2253
+
2254
+ interface BorderProperties {
2255
+ "border-color": BorderColorClass;
2256
+ "border-style": BorderColorClass;
2257
+ "border-width": BorderColorClass;
2258
+ }
2259
+
2260
+ interface BorderColorClass {
2261
+ }
2262
+
2263
+ interface Font {
2264
+ shorthand: string;
2265
+ pattern: string;
2266
+ keywords: string[];
2267
+ default: any[];
2268
+ properties: FontProperties;
2269
+ }
2270
+
2271
+ interface FontProperties {
2272
+ "font-weight": FontWeight;
2273
+ "font-style": PurpleBackgroundAttachment;
2274
+ "font-size": PurpleBackgroundAttachment;
2275
+ "line-height": LineHeight;
2276
+ "font-stretch": PurpleBackgroundAttachment;
2277
+ "font-variant": PurpleBackgroundAttachment;
2278
+ "font-family": FontFamily;
2279
+ }
2280
+
2281
+ interface FontFamily {
2282
+ types: string[];
2283
+ default: any[];
2284
+ keywords: string[];
2285
+ required: boolean;
2286
+ multiple: boolean;
2287
+ separator: Separator;
2288
+ }
2289
+
2290
+ interface FontWeight {
2291
+ types: string[];
2292
+ default: string[];
2293
+ keywords: string[];
2294
+ constraints: FontWeightConstraints;
2295
+ mapping: FontWeightMapping;
2296
+ }
2297
+
2298
+ interface FontWeightConstraints {
2299
+ value: Value;
2300
+ }
2301
+
2302
+ interface Value {
2303
+ min: string;
2304
+ max: string;
2305
+ }
2306
+
2307
+ interface FontWeightMapping {
2308
+ thin: string;
2309
+ hairline: string;
2310
+ "extra light": string;
2311
+ "ultra light": string;
2312
+ light: string;
2313
+ normal: string;
2314
+ regular: string;
2315
+ medium: string;
2316
+ "semi bold": string;
2317
+ "demi bold": string;
2318
+ bold: string;
2319
+ "extra bold": string;
2320
+ "ultra bold": string;
2321
+ black: string;
2322
+ heavy: string;
2323
+ "extra black": string;
2324
+ "ultra black": string;
2325
+ }
2326
+
2327
+ interface LineHeight {
2328
+ types: string[];
2329
+ default: string[];
2330
+ keywords: string[];
2331
+ previous: string;
2332
+ prefix: Prefix;
2333
+ }
2334
+
2335
+ interface Outline {
2336
+ shorthand: string;
2337
+ pattern: string;
2338
+ keywords: string[];
2339
+ default: string[];
2340
+ properties: OutlineProperties;
2341
+ }
2342
+
2343
+ interface OutlineProperties {
2344
+ "outline-color": PurpleBackgroundAttachment;
2345
+ "outline-style": PurpleBackgroundAttachment;
2346
+ "outline-width": PurpleBackgroundAttachment;
2347
+ }
2348
+
2349
+ interface PropertiesConfigProperties {
2350
+ inset: BorderRadius;
2351
+ top: BackgroundPositionClass;
2352
+ right: BackgroundPositionClass;
2353
+ bottom: BackgroundPositionClass;
2354
+ left: BackgroundPositionClass;
2355
+ margin: BorderRadius;
2356
+ "margin-top": BackgroundPositionClass;
2357
+ "margin-right": BackgroundPositionClass;
2358
+ "margin-bottom": BackgroundPositionClass;
2359
+ "margin-left": BackgroundPositionClass;
2360
+ padding: BorderColor;
2361
+ "padding-top": BackgroundPositionClass;
2362
+ "padding-right": BackgroundPositionClass;
2363
+ "padding-bottom": BackgroundPositionClass;
2364
+ "padding-left": BackgroundPositionClass;
2365
+ "border-radius": BorderRadius;
2366
+ "border-top-left-radius": BackgroundPositionClass;
2367
+ "border-top-right-radius": BackgroundPositionClass;
2368
+ "border-bottom-right-radius": BackgroundPositionClass;
2369
+ "border-bottom-left-radius": BackgroundPositionClass;
2370
+ "border-width": BorderColor;
2371
+ "border-top-width": BackgroundPositionClass;
2372
+ "border-right-width": BackgroundPositionClass;
2373
+ "border-bottom-width": BackgroundPositionClass;
2374
+ "border-left-width": BackgroundPositionClass;
2375
+ "border-style": BorderColor;
2376
+ "border-top-style": BackgroundPositionClass;
2377
+ "border-right-style": BackgroundPositionClass;
2378
+ "border-bottom-style": BackgroundPositionClass;
2379
+ "border-left-style": BackgroundPositionClass;
2380
+ "border-color": BorderColor;
2381
+ "border-top-color": BackgroundPositionClass;
2382
+ "border-right-color": BackgroundPositionClass;
2383
+ "border-bottom-color": BackgroundPositionClass;
2384
+ "border-left-color": BackgroundPositionClass;
2385
+ }
2386
+
2387
+ interface BorderColor {
2388
+ shorthand: string;
2389
+ map?: string;
2390
+ properties: string[];
2391
+ types: string[];
2392
+ keywords: string[];
2393
+ }
2394
+
2395
+ interface BorderRadius {
2396
+ shorthand: string;
2397
+ properties: string[];
2398
+ types: string[];
2399
+ multiple: boolean;
2400
+ separator: null | string;
2401
+ keywords: string[];
2402
+ }
2403
+
1218
2404
  export declare type WalkerOption = WalkerOptionEnum | Token | null;
1219
2405
  /**
1220
2406
  * returned value:
@@ -1249,173 +2435,601 @@ export declare interface WalkAttributesResult {
1249
2435
  list: Token[] | null;
1250
2436
  }
1251
2437
 
2438
+ /**
2439
+ * error description
2440
+ */
1252
2441
  export declare interface ErrorDescription {
1253
2442
 
1254
- // drop rule or declaration | fix rule or declaration
2443
+ /**
2444
+ * drop rule or declaration
2445
+ */
2446
+
1255
2447
  action: 'drop' | 'ignore';
2448
+ /**
2449
+ * error message
2450
+ */
1256
2451
  message: string;
2452
+ /**
2453
+ * syntax error description
2454
+ */
1257
2455
  syntax?: string | null;
2456
+ /**
2457
+ * error node
2458
+ */
1258
2459
  node?: Token | AstNode | null;
2460
+ /**
2461
+ * error location
2462
+ */
1259
2463
  location?: Location;
2464
+ /**
2465
+ * error object
2466
+ */
1260
2467
  error?: Error;
2468
+ /**
2469
+ * raw tokens
2470
+ */
1261
2471
  rawTokens?: TokenizeResult[];
1262
2472
  }
1263
2473
 
2474
+ /**
2475
+ * css validation options
2476
+ */
1264
2477
  interface ValidationOptions {
1265
2478
 
2479
+ /**
2480
+ * enable css validation
2481
+ *
2482
+ * see {@link ValidationLevel}
2483
+ */
1266
2484
  validation?: boolean | ValidationLevel;
2485
+ /**
2486
+ * lenient validation. retain nodes that failed validation
2487
+ */
1267
2488
  lenient?: boolean;
2489
+ /**
2490
+ * visited tokens
2491
+ *
2492
+ * @private
2493
+ */
1268
2494
  visited?: WeakMap<Token, Map<string, Set<ValidationToken>>>;
1269
- isOptional?:boolean | null;
1270
- isRepeatable?:boolean | null;
1271
- isList?:boolean | null;
1272
- occurence?:boolean | null;
2495
+ /**
2496
+ * is optional
2497
+ *
2498
+ * @private
2499
+ */
2500
+ isOptional?: boolean | null;
2501
+ /**
2502
+ * is repeatable
2503
+ *
2504
+ * @private
2505
+ */
2506
+ isRepeatable?: boolean | null;
2507
+ /**
2508
+ * is list
2509
+ *
2510
+ * @private
2511
+ */
2512
+ isList?: boolean | null;
2513
+ /**
2514
+ * occurence
2515
+ *
2516
+ * @private
2517
+ */
2518
+ occurence?: boolean | null;
2519
+ /**
2520
+ * at least once
2521
+ *
2522
+ * @private
2523
+ */
1273
2524
  atLeastOnce?: boolean | null;
1274
2525
  }
1275
2526
 
2527
+ /**
2528
+ * minify options
2529
+ */
1276
2530
  interface MinifyOptions {
1277
2531
 
2532
+ /**
2533
+ * enable minification
2534
+ */
1278
2535
  minify?: boolean;
2536
+ /**
2537
+ * parse color tokens
2538
+ */
1279
2539
  parseColor?: boolean;
2540
+ /**
2541
+ * generate nested rules
2542
+ */
1280
2543
  nestingRules?: boolean;
2544
+ /**
2545
+ * expand nested rules
2546
+ */
1281
2547
  expandNestingRules?: boolean;
2548
+ /**
2549
+ * remove duplicate declarations from the same rule
2550
+ */
1282
2551
  removeDuplicateDeclarations?: boolean;
2552
+ /**
2553
+ * compute shorthand properties
2554
+ */
1283
2555
  computeShorthand?: boolean;
2556
+ /**
2557
+ * compute transform functions
2558
+ * see supported functions {@link transformFunctions}
2559
+ */
1284
2560
  computeTransform?: boolean;
2561
+ /**
2562
+ * compute math functions
2563
+ * see supported functions {@link mathFuncs}
2564
+ */
1285
2565
  computeCalcExpression?: boolean;
2566
+ /**
2567
+ * inline css variables
2568
+ */
1286
2569
  inlineCssVariables?: boolean;
2570
+ /**
2571
+ * remove empty ast nodes
2572
+ */
1287
2573
  removeEmpty?: boolean;
2574
+ /**
2575
+ * define minification passes.
2576
+ */
1288
2577
  pass?: number;
1289
2578
  }
1290
2579
 
2580
+ /**
2581
+ * parser options
2582
+ */
1291
2583
  export declare interface ParserOptions extends MinifyOptions, MinifyFeatureOptions, ValidationOptions, PropertyListOptions {
1292
2584
 
2585
+ /**
2586
+ * source file to be used for sourcemap
2587
+ */
1293
2588
  src?: string;
2589
+ /**
2590
+ * include sourcemap in the ast. sourcemap info is always generated
2591
+ */
1294
2592
  sourcemap?: boolean | 'inline';
2593
+ /**
2594
+ * remove @charset at-rule
2595
+ */
1295
2596
  removeCharset?: boolean;
2597
+ /**
2598
+ * resolve urls
2599
+ */
1296
2600
  resolveUrls?: boolean;
2601
+ /**
2602
+ * resolve import
2603
+ */
1297
2604
  resolveImport?: boolean;
2605
+ /**
2606
+ * current working directory
2607
+ * @ignore
2608
+ */
1298
2609
  cwd?: string;
2610
+ /**
2611
+ * remove css prefix
2612
+ */
1299
2613
  removePrefix?: boolean;
1300
- load?: (url: string, currentUrl: string) => Promise<string>;
2614
+ /**
2615
+ * get file or url as stream
2616
+ * @param url
2617
+ * @param currentUrl
2618
+ *
2619
+ * @private
2620
+ */
2621
+ getStream?: (url: string, currentUrl: string) => Promise<ReadableStream<string>>;
2622
+ /**
2623
+ * get directory name
2624
+ * @param path
2625
+ *
2626
+ * @private
2627
+ */
1301
2628
  dirname?: (path: string) => string;
2629
+ /**
2630
+ * resolve path
2631
+ * @param url
2632
+ * @param currentUrl
2633
+ * @param currentWorkingDirectory
2634
+ *
2635
+ * @private
2636
+ */
1302
2637
  resolve?: (url: string, currentUrl: string, currentWorkingDirectory?: string) => {
1303
2638
  absolute: string;
1304
2639
  relative: string;
1305
2640
  };
2641
+ /**
2642
+ * node visitor
2643
+ * {@link VisitorNodeMap}
2644
+ */
1306
2645
  visitor?: VisitorNodeMap;
2646
+ /**
2647
+ * abort signal
2648
+ *
2649
+ * Example: abort after 10 seconds
2650
+ * ```ts
2651
+ *
2652
+ * const result = await parse(cssString, {
2653
+ * signal: AbortSignal.timeout(10000)
2654
+ * });
2655
+ *
2656
+ * ```
2657
+ */
1307
2658
  signal?: AbortSignal;
2659
+ /**
2660
+ * set parent node
2661
+ */
1308
2662
  setParent?: boolean;
2663
+ /**
2664
+ * cache
2665
+ *
2666
+ * @private
2667
+ */
1309
2668
  cache?: WeakMap<AstNode, string>;
1310
2669
  }
1311
2670
 
1312
- export declare interface MinifyFeatureOptions {
2671
+ /**
2672
+ * minify feature options
2673
+ *
2674
+ * @internal
2675
+ */
2676
+ export declare interface MinifyFeatureOptions {
1313
2677
 
2678
+ /**
2679
+ * minify features
2680
+ *
2681
+ * @internal
2682
+ */
1314
2683
  features?: MinifyFeature[];
1315
2684
  }
1316
2685
 
2686
+ /**
2687
+ * minify feature
2688
+ *
2689
+ * @internal
2690
+ */
1317
2691
  export declare interface MinifyFeature {
1318
2692
 
2693
+ /**
2694
+ * ordering
2695
+ */
1319
2696
  ordering: number;
1320
-
1321
- register(options: MinifyFeatureOptions | ParserOptions): void;
1322
-
1323
- // run(ast: AstRule | AstAtRule, options: ParserOptions = {}, parent: AstRule | AstAtRule | AstRuleStyleSheet, context: { [key: string]: any }): void;
1324
-
1325
- // cleanup?(ast: AstRuleStyleSheet, options: ParserOptions = {}, context: { [key: string]: any }): void;
1326
- }
1327
-
1328
- export declare interface MinifyFeature {
1329
-
1330
- ordering: number;
2697
+ /**
2698
+ * use in pre process
2699
+ */
1331
2700
  preProcess: boolean;
2701
+ /**
2702
+ * use in post process
2703
+ */
1332
2704
  postProcess: boolean;
2705
+ /**
2706
+ * register feature
2707
+ * @param options
2708
+ */
1333
2709
  register: (options: MinifyFeatureOptions | ParserOptions) => void;
2710
+ /**
2711
+ * run feature
2712
+ * @param ast
2713
+ * @param options
2714
+ * @param parent
2715
+ * @param context
2716
+ * @param mode
2717
+ */
1334
2718
  run: (ast: AstRule | AstAtRule, options: ParserOptions, parent: AstRule | AstAtRule | AstRuleStyleSheet, context: {
1335
2719
  [key: string]: any
1336
2720
  }, mode: FeatureWalkMode) => void;
1337
2721
  }
1338
2722
 
2723
+ /**
2724
+ * resolved path
2725
+ * @internal
2726
+ */
1339
2727
  export declare interface ResolvedPath {
2728
+ /**
2729
+ * absolute path
2730
+ */
1340
2731
  absolute: string;
2732
+ /**
2733
+ * relative path
2734
+ */
1341
2735
  relative: string;
1342
2736
  }
1343
2737
 
2738
+ /**
2739
+ * ast node render options
2740
+ */
1344
2741
  export declare interface RenderOptions {
1345
2742
 
2743
+ /**
2744
+ * minify ast node.
2745
+ */
1346
2746
  minify?: boolean;
2747
+ /**
2748
+ * pretty print css
2749
+ */
1347
2750
  beautify?: boolean;
2751
+ /**
2752
+ * remove empty rule lists from the ast
2753
+ */
1348
2754
  removeEmpty?: boolean;
2755
+ /**
2756
+ * expand nesting rules
2757
+ */
1349
2758
  expandNestingRules?: boolean;
2759
+ /**
2760
+ * preserve license comments. license comments are comments that start with /*!
2761
+ */
1350
2762
  preserveLicense?: boolean;
2763
+ /**
2764
+ * generate sourcemap object. 'inline' will embed it in the css
2765
+ */
1351
2766
  sourcemap?: boolean | 'inline';
2767
+ /**
2768
+ * indent string
2769
+ */
1352
2770
  indent?: string;
2771
+ /**
2772
+ * new line string
2773
+ */
1353
2774
  newLine?: string;
2775
+ /**
2776
+ * remove comments
2777
+ */
1354
2778
  removeComments?: boolean;
2779
+ /**
2780
+ * convert color to the specified color space. 'true' will convert to HEX
2781
+ */
1355
2782
  convertColor?: boolean | ColorType;
2783
+ /**
2784
+ * ernder the node along with its parents
2785
+ */
1356
2786
  withParents?: boolean;
2787
+ /**
2788
+ * output file. used for url resolution
2789
+ * @internal
2790
+ */
1357
2791
  output?: string;
2792
+ /**
2793
+ * current working directory
2794
+ * @internal
2795
+ */
1358
2796
  cwd?: string;
1359
- load?: (url: string, currentUrl: string) => Promise<string>;
2797
+ /**
2798
+ * resolve path
2799
+ * @internal
2800
+ */
1360
2801
  resolve?: (url: string, currentUrl: string, currentWorkingDirectory?: string) => ResolvedPath;
1361
2802
  }
1362
2803
 
2804
+ /**
2805
+ * transform options
2806
+ */
1363
2807
  export declare interface TransformOptions extends ParserOptions, RenderOptions {
1364
2808
 
1365
2809
  }
1366
2810
 
2811
+ /**
2812
+ * parse result stats object
2813
+ */
1367
2814
  export declare interface ParseResultStats {
2815
+ /**
2816
+ * source file
2817
+ */
1368
2818
  src: string;
2819
+ /**
2820
+ * bytes read
2821
+ */
1369
2822
  bytesIn: number;
2823
+ /**
2824
+ * bytes read from imported files
2825
+ */
1370
2826
  importedBytesIn: number;
2827
+ /**
2828
+ * parse time
2829
+ */
1371
2830
  parse: string;
2831
+ /**
2832
+ * minify time
2833
+ */
1372
2834
  minify: string;
2835
+ /**
2836
+ * total time
2837
+ */
1373
2838
  total: string;
2839
+ /**
2840
+ * imported files stats
2841
+ */
1374
2842
  imports: ParseResultStats[]
1375
2843
  }
1376
2844
 
2845
+ /**
2846
+ * parse result object
2847
+ */
1377
2848
  export declare interface ParseResult {
2849
+ /**
2850
+ * parsed ast tree
2851
+ */
1378
2852
  ast: AstRuleStyleSheet;
2853
+ /**
2854
+ * parse errors
2855
+ */
1379
2856
  errors: ErrorDescription[];
2857
+ /**
2858
+ * parse stats
2859
+ */
1380
2860
  stats: ParseResultStats
1381
2861
  }
1382
2862
 
2863
+ /**
2864
+ * render result object
2865
+ */
1383
2866
  export declare interface RenderResult {
2867
+ /**
2868
+ * rendered css
2869
+ */
1384
2870
  code: string;
2871
+ /**
2872
+ * render errors
2873
+ */
1385
2874
  errors: ErrorDescription[];
2875
+ /**
2876
+ * render stats
2877
+ */
1386
2878
  stats: {
2879
+ /**
2880
+ * render time
2881
+ */
1387
2882
  total: string;
1388
2883
  },
2884
+ /**
2885
+ * source map
2886
+ */
1389
2887
  map?: SourceMap
1390
2888
  }
1391
2889
 
2890
+ /**
2891
+ * transform result object
2892
+ */
1392
2893
  export declare interface TransformResult extends ParseResult, RenderResult {
1393
2894
 
2895
+ /**
2896
+ * transform stats
2897
+ */
1394
2898
  stats: {
2899
+ /**
2900
+ * source file
2901
+ */
1395
2902
  src: string;
2903
+ /**
2904
+ * bytes read
2905
+ */
1396
2906
  bytesIn: number;
2907
+ /**
2908
+ * generated css size
2909
+ */
1397
2910
  bytesOut: number;
2911
+ /**
2912
+ * bytes read from imported files
2913
+ */
1398
2914
  importedBytesIn: number;
2915
+ /**
2916
+ * parse time
2917
+ */
1399
2918
  parse: string;
2919
+ /**
2920
+ * minify time
2921
+ */
1400
2922
  minify: string;
2923
+ /**
2924
+ * render time
2925
+ */
1401
2926
  render: string;
2927
+ /**
2928
+ * total time
2929
+ */
1402
2930
  total: string;
2931
+ /**
2932
+ * imported files stats
2933
+ */
1403
2934
  imports: ParseResultStats[];
1404
2935
  }
1405
2936
  }
1406
2937
 
2938
+ /**
2939
+ * parse token options
2940
+ */
1407
2941
  export declare interface ParseTokenOptions extends ParserOptions {
1408
2942
  }
1409
2943
 
2944
+ /**
2945
+ * tokenize result object
2946
+ * @internal
2947
+ */
1410
2948
  export declare interface TokenizeResult {
2949
+ /**
2950
+ * token
2951
+ */
1411
2952
  token: string;
2953
+ /**
2954
+ * token length
2955
+ */
1412
2956
  len: number;
2957
+ /**
2958
+ * token type hint
2959
+ */
1413
2960
  hint?: EnumToken;
2961
+ /**
2962
+ * token start position
2963
+ */
1414
2964
  sta: Position;
2965
+ /**
2966
+ * token end position
2967
+ */
1415
2968
  end: Position;
2969
+ /**
2970
+ * bytes in
2971
+ */
1416
2972
  bytesIn: number;
1417
2973
  }
1418
2974
 
2975
+ /**
2976
+ * matched selector object
2977
+ * @internal
2978
+ */
2979
+ export declare interface MatchedSelector {
2980
+ /**
2981
+ * matched selector
2982
+ */
2983
+ match: string[][];
2984
+ /**
2985
+ * selector 1
2986
+ */
2987
+ selector1: string[][];
2988
+ /**
2989
+ * selector 2
2990
+ */
2991
+ selector2: string[][];
2992
+ /**
2993
+ * selectors partially match
2994
+ */
2995
+ eq: boolean
2996
+ }
2997
+
2998
+ /**
2999
+ * variable scope info object
3000
+ * @internal
3001
+ */
3002
+ export declare interface VariableScopeInfo {
3003
+ /**
3004
+ * global scope
3005
+ */
3006
+ globalScope: boolean;
3007
+ /**
3008
+ * parent nodes
3009
+ */
3010
+ parent: Set<AstRule | AstAtRule>;
3011
+ /**
3012
+ * declaration count
3013
+ */
3014
+ declarationCount: number;
3015
+ /**
3016
+ * replaceable
3017
+ */
3018
+ replaceable: boolean;
3019
+ /**
3020
+ * declaration node
3021
+ */
3022
+ node: AstDeclaration;
3023
+ /**
3024
+ * declaration values
3025
+ */
3026
+ values: Token[];
3027
+ }
3028
+
3029
+ /**
3030
+ * source map object
3031
+ * @internal
3032
+ */
1419
3033
  export declare interface SourceMapObject {
1420
3034
  version: number;
1421
3035
  file?: string;
@@ -1429,13 +3043,16 @@ export declare interface SourceMapObject {
1429
3043
  /**
1430
3044
  * return the directory name of a path
1431
3045
  * @param path
3046
+ * @internal
1432
3047
  */
1433
3048
  declare function dirname(path: string): string;
1434
3049
  /**
1435
3050
  * resolve path
1436
- * @param url
1437
- * @param currentDirectory
1438
- * @param cwd
3051
+ * @param url url or path to resolve
3052
+ * @param currentDirectory directory used to resolve the path
3053
+ * @param cwd current working directory
3054
+ *
3055
+ * @private
1439
3056
  */
1440
3057
  declare function resolve(url: string, currentDirectory: string, cwd?: string): {
1441
3058
  absolute: string;
@@ -1443,23 +3060,169 @@ declare function resolve(url: string, currentDirectory: string, cwd?: string): {
1443
3060
  };
1444
3061
 
1445
3062
  /**
1446
- * load file
3063
+ * node module entry point
3064
+ * @module node
3065
+ */
3066
+
3067
+ /**
3068
+ * load file or url as stream
1447
3069
  * @param url
1448
3070
  * @param currentFile
3071
+ *
3072
+ * @private
1449
3073
  */
1450
- declare function load(url: string, currentFile?: string): Promise<string>;
1451
-
3074
+ declare function getStream(url: string, currentFile?: string): Promise<ReadableStream<string>>;
1452
3075
  /**
1453
- * render ast node
3076
+ * render ast tree
3077
+ * @param data
3078
+ * @param options
3079
+ *
3080
+ * Example:
3081
+ *
3082
+ * ```ts
3083
+ *
3084
+ * import {render, ColorType} from '@tbela99/css-parser';
3085
+ *
3086
+ * // remote file
3087
+ * let result = render(ast);
3088
+ * console.log(result.code);
3089
+ *
3090
+ * // local file
3091
+ * result = await parseFile(ast, {beatify: true, convertColor: ColorType.SRGB});
3092
+ * console.log(result.code);
3093
+ * ```
1454
3094
  */
1455
3095
  declare function render(data: AstNode, options?: RenderOptions): RenderResult;
3096
+ /**
3097
+ * parse css file
3098
+ * @param file url or path
3099
+ * @param options
3100
+ *
3101
+ * Example:
3102
+ *
3103
+ * ```ts
3104
+ *
3105
+ * import {parseFile} from '@tbela99/css-parser';
3106
+ *
3107
+ * // remote file
3108
+ * let result = await parseFile('https://docs.deno.com/styles.css');
3109
+ * console.log(result.ast);
3110
+ *
3111
+ * // local file
3112
+ * result = await parseFile('./css/styles.css');
3113
+ * console.log(result.ast);
3114
+ * ```
3115
+ */
3116
+ declare function parseFile(file: string, options?: ParserOptions): Promise<ParseResult>;
1456
3117
  /**
1457
3118
  * parse css
3119
+ * @param stream
3120
+ * @param opt
3121
+ *
3122
+ * Example:
3123
+ *
3124
+ * ```ts
3125
+ *
3126
+ * import {transform} from '@tbela99/css-parser';
3127
+ *
3128
+ * // css string
3129
+ * let result = await transform(css);
3130
+ * console.log(result.code);
3131
+ * ```
3132
+ *
3133
+ * Example using stream
3134
+ *
3135
+ * ```ts
3136
+ *
3137
+ * import {parse} from '@tbela99/css-parser';
3138
+ * import {Readable} from "node:stream";
3139
+ *
3140
+ * // usage: node index.ts < styles.css or cat styles.css | node index.ts
3141
+ *
3142
+ * const readableStream = Readable.toWeb(process.stdin);
3143
+ * const result = await parse(readableStream, {beautify: true});
3144
+ *
3145
+ * console.log(result.ast);
3146
+ * ```
3147
+ *
3148
+ * Example using fetch
3149
+ *
3150
+ * ```ts
3151
+ *
3152
+ * import {parse} from '@tbela99/css-parser';
3153
+ *
3154
+ * const response = await fetch('https://docs.deno.com/styles.css');
3155
+ * result = await parse(response.body, {beautify: true});
3156
+ *
3157
+ * console.log(result.ast);
3158
+ * ```
3159
+ */
3160
+ declare function parse(stream: string | ReadableStream<string>, opt?: ParserOptions): Promise<ParseResult>;
3161
+ /**
3162
+ * transform css file
3163
+ * @param file url or path
3164
+ * @param options
3165
+ *
3166
+ * Example:
3167
+ *
3168
+ * ```ts
3169
+ *
3170
+ * import {transformFile} from '@tbela99/css-parser';
3171
+ *
3172
+ * // remote file
3173
+ * let result = await transformFile('https://docs.deno.com/styles.css');
3174
+ * console.log(result.code);
3175
+ *
3176
+ * // local file
3177
+ * result = await transformFile('./css/styles.css');
3178
+ * console.log(result.code);
3179
+ * ```
1458
3180
  */
1459
- declare function parse(iterator: string, opt?: ParserOptions): Promise<ParseResult>;
3181
+ declare function transformFile(file: string, options?: TransformOptions): Promise<TransformResult>;
1460
3182
  /**
1461
- * parse and render css
3183
+ * transform css
3184
+ * @param css
3185
+ * @param options
3186
+ *
3187
+ * Example:
3188
+ *
3189
+ * ```ts
3190
+ *
3191
+ * import {transform} from '@tbela99/css-parser';
3192
+ *
3193
+ * // css string
3194
+ * let result = await transform(css);
3195
+ * console.log(result.code);
3196
+ * ```
3197
+ *
3198
+ * Example using stream
3199
+ *
3200
+ * ```ts
3201
+ *
3202
+ * import {transform} from '@tbela99/css-parser';
3203
+ * import {Readable} from "node:stream";
3204
+ *
3205
+ * // usage: node index.ts < styles.css or cat styles.css | node index.ts
3206
+ *
3207
+ * const readableStream = Readable.toWeb(process.stdin);
3208
+ * const result = await transform(readableStream, {beautify: true});
3209
+ *
3210
+ * console.log(result.code);
3211
+ * ```
3212
+ *
3213
+ * Example using fetch
3214
+ *
3215
+ * ```ts
3216
+ *
3217
+ * import {transform} from '@tbela99/css-parser';
3218
+ *
3219
+ * const response = await fetch('https://docs.deno.com/styles.css');
3220
+ * result = await transform(response.body, {beautify: true});
3221
+ *
3222
+ * console.log(result.code);
3223
+ * ```
1462
3224
  */
1463
- declare function transform(css: string, options?: TransformOptions): Promise<TransformResult>;
3225
+ declare function transform(css: string | ReadableStream<string>, options?: TransformOptions): Promise<TransformResult>;
1464
3226
 
1465
- export { ColorType, EnumToken, ValidationLevel, convertColor, dirname, expand, isOkLabClose, load, minify, okLabDistance, parse, parseString, parseTokens, render, renderToken, resolve, transform, walk, walkValues };
3227
+ export { ColorType, EnumToken, FeatureWalkMode, SourceMap, ValidationLevel, WalkerOptionEnum, WalkerValueEvent, convertColor, dirname, expand, getStream, isOkLabClose, mathFuncs, minify, okLabDistance, parse, parseDeclarations, parseFile, parseString, parseTokens, render, renderToken, resolve, transform, transformFile, transformFunctions, walk, walkValues };
3228
+ export type { AddToken, AngleToken, AstAtRule, AstComment, AstDeclaration, AstInvalidAtRule, AstInvalidDeclaration, AstInvalidRule, AstKeyFrameRule, AstKeyframAtRule, AstKeyframeRule, AstNode, AstRule, AstRuleList, AstRuleStyleSheet, AtRuleToken, AtRuleVisitorHandler, AttrEndToken, AttrStartToken, AttrToken, Background, BackgroundAttachmentMapping, BackgroundPosition, BackgroundPositionClass, BackgroundPositionConstraints, BackgroundPositionMapping, BackgroundProperties, BackgroundRepeat, BackgroundRepeatMapping, BackgroundSize, BackgroundSizeMapping, BadCDOCommentToken, BadCommentToken, BadStringToken, BadUrlToken, BaseToken, BinaryExpressionNode, BinaryExpressionToken, BlockEndToken, BlockStartToken, Border, BorderColor, BorderColorClass, BorderProperties, BorderRadius, CDOCommentToken, ChildCombinatorToken, ClassSelectorToken, ColonToken, ColorToken, ColumnCombinatorToken, CommaToken, CommentToken, ConstraintsMapping, ContainMatchToken, Context, DashMatchToken, DashedIdentToken, DeclarationVisitorHandler, DelimToken, DescendantCombinatorToken, DimensionToken, DivToken, EOFToken, EndMatchToken, EqualMatchToken, ErrorDescription, FlexToken, Font, FontFamily, FontProperties, FontWeight, FontWeightConstraints, FontWeightMapping, FractionToken, FrequencyToken, FunctionImageToken, FunctionToken, FunctionURLToken, GreaterThanOrEqualToken, GreaterThanToken, GridTemplateFuncToken, HashToken, IdentListToken, IdentToken, ImportantToken, IncludeMatchToken, InvalidAttrToken, InvalidClassSelectorToken, LengthToken, LessThanOrEqualToken, LessThanToken, LineHeight, ListToken, LiteralToken, Location, Map$1 as Map, MatchExpressionToken, MatchedSelector, MediaFeatureAndToken, MediaFeatureNotToken, MediaFeatureOnlyToken, MediaFeatureOrToken, MediaFeatureToken, MediaQueryConditionToken, MinifyFeature, MinifyFeatureOptions, MinifyOptions, MulToken, NameSpaceAttributeToken, NestingSelectorToken, NextSiblingCombinatorToken, NumberToken, OptimizedSelector, OptimizedSelectorToken, Outline, OutlineProperties, ParensEndToken, ParensStartToken, ParensToken, ParseInfo, ParseResult, ParseResultStats, ParseTokenOptions, ParserOptions, PercentageToken, Position, Prefix, PropertiesConfig, PropertiesConfigProperties, PropertyListOptions, PropertyMapType, PropertySetType, PropertyType, PseudoClassFunctionToken, PseudoClassToken, PseudoElementToken, PseudoPageToken, PurpleBackgroundAttachment, RawSelectorTokens, RenderOptions, RenderResult, ResolutionToken, ResolvedPath, RuleVisitorHandler, SemiColonToken, Separator, ShorthandDef, ShorthandMapType, ShorthandProperties, ShorthandPropertyType, ShorthandType, SourceMapObject, StartMatchToken, StringToken, SubToken, SubsequentCombinatorToken, TimeToken, TimelineFunctionToken, TimingFunctionToken, Token, TokenizeResult, TransformOptions, TransformResult, UnaryExpression, UnaryExpressionNode, UnclosedStringToken, UniversalSelectorToken, UrlToken, ValidationConfiguration, ValidationOptions, ValidationResult, ValidationSelectorOptions, ValidationSyntaxNode, ValidationSyntaxResult, Value, VariableScopeInfo, VisitorNodeMap, WalkAttributesResult, WalkResult, WalkerFilter, WalkerOption, WalkerValueFilter, WhitespaceToken };