@tbela99/css-parser 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/{LICENSE → LICENSE.md} +1 -1
  2. package/README.md +191 -80
  3. package/dist/config.json.js +20 -1
  4. package/dist/index-umd-web.js +3210 -1352
  5. package/dist/index.cjs +3211 -1353
  6. package/dist/index.d.ts +910 -0
  7. package/dist/lib/ast/expand.js +1 -1
  8. package/dist/lib/ast/features/calc.js +1 -2
  9. package/dist/lib/ast/features/inlinecssvariables.js +1 -1
  10. package/dist/lib/ast/features/shorthand.js +1 -1
  11. package/dist/lib/ast/math/expression.js +38 -3
  12. package/dist/lib/ast/math/math.js +2 -2
  13. package/dist/lib/ast/minify.js +0 -1
  14. package/dist/lib/ast/types.js +1 -0
  15. package/dist/lib/ast/utils/minifyfeature.js +4 -3
  16. package/dist/lib/parser/declaration/list.js +1 -1
  17. package/dist/lib/parser/declaration/map.js +129 -26
  18. package/dist/lib/parser/declaration/set.js +1 -1
  19. package/dist/lib/parser/parse.js +325 -303
  20. package/dist/lib/parser/tokenize.js +220 -223
  21. package/dist/lib/parser/utils/declaration.js +1 -1
  22. package/dist/lib/parser/utils/syntax.js +159 -23
  23. package/dist/lib/parser/utils/type.js +2 -2
  24. package/dist/lib/renderer/color/a98rgb.js +64 -0
  25. package/dist/lib/renderer/color/color.js +521 -0
  26. package/dist/lib/renderer/color/colormix.js +337 -0
  27. package/dist/lib/renderer/color/hex.js +92 -0
  28. package/dist/lib/renderer/color/hsl.js +118 -0
  29. package/dist/lib/renderer/color/hsv.js +20 -0
  30. package/dist/lib/renderer/color/hwb.js +101 -0
  31. package/dist/lib/renderer/color/lab.js +136 -0
  32. package/dist/lib/renderer/color/lch.js +79 -0
  33. package/dist/lib/renderer/color/oklab.js +121 -0
  34. package/dist/lib/renderer/color/oklch.js +65 -0
  35. package/dist/lib/renderer/color/p3.js +57 -0
  36. package/dist/lib/renderer/color/prophotorgb.js +56 -0
  37. package/dist/lib/renderer/color/rec2020.js +70 -0
  38. package/dist/lib/renderer/color/relativecolor.js +152 -0
  39. package/dist/lib/renderer/color/rgb.js +44 -0
  40. package/dist/lib/renderer/color/srgb.js +261 -0
  41. package/dist/lib/renderer/color/utils/components.js +20 -0
  42. package/dist/lib/renderer/color/utils/constants.js +191 -0
  43. package/dist/lib/renderer/color/utils/matrix.js +35 -0
  44. package/dist/lib/renderer/color/xyz.js +64 -0
  45. package/dist/lib/renderer/color/xyzd50.js +33 -0
  46. package/dist/lib/renderer/render.js +61 -32
  47. package/dist/node/index.js +1 -1
  48. package/dist/node/load.js +1 -1
  49. package/dist/web/index.js +1 -1
  50. package/package.json +15 -14
  51. package/quickjs.sh +1 -0
  52. package/dist/lib/ast/features/utils/math.js +0 -95
  53. package/dist/lib/iterable/set.js +0 -48
  54. package/dist/lib/iterable/weakmap.js +0 -53
  55. package/dist/lib/renderer/utils/calccolor.js +0 -238
  56. package/dist/lib/renderer/utils/color.js +0 -371
  57. package/dist/lib/renderer/utils/hex.js +0 -124
  58. package/dist/lib/renderer/utils/hsl.js +0 -49
  59. package/dist/lib/renderer/utils/hsv.js +0 -15
  60. package/dist/lib/renderer/utils/hwb.js +0 -50
  61. package/dist/lib/renderer/utils/rgb.js +0 -66
@@ -0,0 +1,910 @@
1
+ declare enum EnumToken {
2
+ CommentTokenType = 0,
3
+ CDOCOMMTokenType = 1,
4
+ StyleSheetNodeType = 2,
5
+ AtRuleNodeType = 3,
6
+ RuleNodeType = 4,
7
+ DeclarationNodeType = 5,
8
+ LiteralTokenType = 6,
9
+ IdenTokenType = 7,
10
+ DashedIdenTokenType = 8,
11
+ CommaTokenType = 9,
12
+ ColonTokenType = 10,
13
+ SemiColonTokenType = 11,
14
+ NumberTokenType = 12,
15
+ AtRuleTokenType = 13,
16
+ PercentageTokenType = 14,
17
+ FunctionTokenType = 15,
18
+ TimelineFunctionTokenType = 16,
19
+ TimingFunctionTokenType = 17,
20
+ UrlFunctionTokenType = 18,
21
+ ImageFunctionTokenType = 19,
22
+ StringTokenType = 20,
23
+ UnclosedStringTokenType = 21,
24
+ DimensionTokenType = 22,
25
+ LengthTokenType = 23,
26
+ AngleTokenType = 24,
27
+ TimeTokenType = 25,
28
+ FrequencyTokenType = 26,
29
+ ResolutionTokenType = 27,
30
+ HashTokenType = 28,
31
+ BlockStartTokenType = 29,
32
+ BlockEndTokenType = 30,
33
+ AttrStartTokenType = 31,
34
+ AttrEndTokenType = 32,
35
+ StartParensTokenType = 33,
36
+ EndParensTokenType = 34,
37
+ ParensTokenType = 35,
38
+ WhitespaceTokenType = 36,
39
+ IncludeMatchTokenType = 37,
40
+ DashMatchTokenType = 38,
41
+ LtTokenType = 39,
42
+ LteTokenType = 40,
43
+ GtTokenType = 41,
44
+ GteTokenType = 42,
45
+ PseudoClassTokenType = 43,
46
+ PseudoClassFuncTokenType = 44,
47
+ DelimTokenType = 45,
48
+ UrlTokenTokenType = 46,
49
+ EOFTokenType = 47,
50
+ ImportantTokenType = 48,
51
+ ColorTokenType = 49,
52
+ AttrTokenType = 50,
53
+ BadCommentTokenType = 51,
54
+ BadCdoTokenType = 52,
55
+ BadUrlTokenType = 53,
56
+ BadStringTokenType = 54,
57
+ BinaryExpressionTokenType = 55,
58
+ UnaryExpressionTokenType = 56,
59
+ FlexTokenType = 57,
60
+ ListToken = 58,
61
+ Add = 59,
62
+ Mul = 60,
63
+ Div = 61,
64
+ Sub = 62,
65
+ ColumnCombinatorTokenType = 63,
66
+ ContainMatchTokenType = 64,
67
+ StartMatchTokenType = 65,
68
+ EndMatchTokenType = 66,
69
+ MatchExpressionTokenType = 67,
70
+ NameSpaceAttributeTokenType = 68,
71
+ FractionTokenType = 69,
72
+ IdenListTokenType = 70,
73
+ GridTemplateFuncTokenType = 71,
74
+ Time = 25,
75
+ Iden = 7,
76
+ EOF = 47,
77
+ Hash = 28,
78
+ Flex = 57,
79
+ Angle = 24,
80
+ Color = 49,
81
+ Comma = 9,
82
+ String = 20,
83
+ Length = 23,
84
+ Number = 12,
85
+ Perc = 14,
86
+ Literal = 6,
87
+ Comment = 0,
88
+ UrlFunc = 18,
89
+ Dimension = 22,
90
+ Frequency = 26,
91
+ Resolution = 27,
92
+ Whitespace = 36,
93
+ IdenList = 70,
94
+ DashedIden = 8,
95
+ GridTemplateFunc = 71,
96
+ ImageFunc = 19,
97
+ CommentNodeType = 0,
98
+ CDOCOMMNodeType = 1,
99
+ TimingFunction = 17,
100
+ TimelineFunction = 16
101
+ }
102
+
103
+ declare function minify(ast: AstNode, options?: ParserOptions | MinifyOptions, recursive?: boolean, errors?: ErrorDescription[], nestingContent?: boolean, context?: {
104
+ [key: string]: any;
105
+ }): AstNode;
106
+
107
+ declare function walk(node: AstNode, filter?: WalkerFilter): Generator<WalkResult>;
108
+ declare function walkValues(values: Token[], root?: AstNode | null, filter?: WalkerValueFilter): Generator<WalkAttributesResult>;
109
+
110
+ declare function expand(ast: AstNode): AstNode;
111
+
112
+ declare function renderToken(token: Token, options?: RenderOptions, cache?: {
113
+ [key: string]: any;
114
+ }, reducer?: (acc: string, curr: Token) => string, errors?: ErrorDescription[]): string;
115
+
116
+ declare function parseString(src: string, options?: {
117
+ location: boolean;
118
+ }): Token[];
119
+ declare function parseTokens(tokens: Token[], options?: ParseTokenOptions): Token[];
120
+
121
+ export declare interface BaseToken {
122
+
123
+ typ: EnumToken;
124
+ loc?: Location;
125
+ }
126
+
127
+ export declare interface LiteralToken extends BaseToken {
128
+
129
+ typ: EnumToken.LiteralTokenType;
130
+ val: string;
131
+ }
132
+
133
+
134
+ export declare interface IdentToken extends BaseToken {
135
+
136
+ typ: EnumToken.IdenTokenType,
137
+ val: string;
138
+ }
139
+
140
+ export declare interface IdentListToken extends BaseToken {
141
+
142
+ typ: EnumToken.IdenListTokenType,
143
+ val: string;
144
+ }
145
+
146
+ export declare interface DashedIdentToken extends BaseToken {
147
+
148
+ typ: EnumToken.DashedIdenTokenType,
149
+ val: string;
150
+ }
151
+
152
+ export declare interface CommaToken extends BaseToken {
153
+
154
+ typ: EnumToken.CommaTokenType
155
+ }
156
+
157
+ export declare interface ColonToken extends BaseToken {
158
+
159
+ typ: EnumToken.ColonTokenType
160
+ }
161
+
162
+ export declare interface SemiColonToken extends BaseToken {
163
+
164
+ typ: EnumToken.SemiColonTokenType
165
+ }
166
+
167
+ export declare interface NumberToken extends BaseToken {
168
+
169
+ typ: EnumToken.NumberTokenType,
170
+ val: string | FractionToken;
171
+ }
172
+
173
+ export declare interface AtRuleToken extends BaseToken {
174
+
175
+ typ: EnumToken.AtRuleTokenType,
176
+ val: string;
177
+ }
178
+
179
+ export declare interface PercentageToken extends BaseToken {
180
+
181
+ typ: EnumToken.PercentageTokenType,
182
+ val: string | FractionToken;
183
+ }
184
+
185
+ export declare interface FlexToken extends BaseToken {
186
+
187
+ typ: EnumToken.FlexTokenType,
188
+ val: string | FractionToken;
189
+ }
190
+
191
+ export declare interface FunctionToken extends BaseToken {
192
+
193
+ typ: EnumToken.FunctionTokenType,
194
+ val: string;
195
+ chi: Token[];
196
+ }
197
+
198
+ export declare interface GridTemplateFuncToken extends BaseToken {
199
+
200
+ typ: EnumToken.GridTemplateFuncTokenType,
201
+ val: string;
202
+ chi: Token[];
203
+ }
204
+
205
+ export declare interface FunctionURLToken extends BaseToken {
206
+
207
+ typ: EnumToken.UrlFunctionTokenType,
208
+ val: 'url';
209
+ chi: Array<UrlToken | CommentToken>;
210
+ }
211
+
212
+ export declare interface FunctionImageToken extends BaseToken {
213
+
214
+ typ: EnumToken.ImageFunctionTokenType,
215
+ val: 'linear-gradient' | 'radial-gradient' | 'repeating-linear-gradient' | 'repeating-radial-gradient' | 'conic-gradient' | 'image' | 'image-set' | 'element' | 'cross-fade';
216
+ chi: Array<UrlToken | CommentToken>;
217
+ }
218
+
219
+ export declare interface TimingFunctionToken extends BaseToken {
220
+
221
+ typ: EnumToken.TimingFunctionTokenType;
222
+ val: string;
223
+ chi: Token[];
224
+ }
225
+
226
+ export declare interface TimelineFunctionToken extends BaseToken {
227
+
228
+ typ: EnumToken.TimelineFunctionTokenType;
229
+ val: string;
230
+ chi: Token[];
231
+ }
232
+
233
+ export declare interface StringToken extends BaseToken {
234
+
235
+ typ: EnumToken.StringTokenType;
236
+ val: string;
237
+ }
238
+
239
+ export declare interface BadStringToken extends BaseToken {
240
+
241
+ typ: EnumToken.BadStringTokenType;
242
+ val: string;
243
+ }
244
+
245
+ export declare interface UnclosedStringToken extends BaseToken {
246
+
247
+ typ: EnumToken.UnclosedStringTokenType;
248
+ val: string;
249
+ }
250
+
251
+ export declare interface DimensionToken extends BaseToken {
252
+
253
+ typ: EnumToken.DimensionTokenType;
254
+ val: string | FractionToken;
255
+ unit: string;
256
+ }
257
+
258
+ export declare interface LengthToken extends BaseToken {
259
+
260
+ typ: EnumToken.LengthTokenType;
261
+ val: string | FractionToken;
262
+ unit: string;
263
+ }
264
+
265
+ export declare interface AngleToken extends BaseToken {
266
+
267
+ typ: EnumToken.AngleTokenType;
268
+ val: string | FractionToken;
269
+ unit: string;
270
+ }
271
+
272
+ export declare interface TimeToken extends BaseToken {
273
+
274
+ typ: EnumToken.TimeTokenType;
275
+ val: string | FractionToken;
276
+ unit: 'ms' | 's';
277
+ }
278
+
279
+ export declare interface FrequencyToken extends BaseToken {
280
+
281
+ typ: EnumToken.FrequencyTokenType;
282
+ val: string | FractionToken;
283
+ unit: 'Hz' | 'Khz';
284
+ }
285
+
286
+ export declare interface ResolutionToken extends BaseToken {
287
+
288
+ typ: EnumToken.ResolutionTokenType;
289
+ val: string | FractionToken;
290
+ unit: 'dpi' | 'dpcm' | 'dppx' | 'x';
291
+ }
292
+
293
+ export declare interface HashToken extends BaseToken {
294
+
295
+ typ: EnumToken.HashTokenType;
296
+ val: string;
297
+ }
298
+
299
+ export declare interface BlockStartToken extends BaseToken {
300
+
301
+ typ: EnumToken.BlockStartTokenType
302
+ }
303
+
304
+ export declare interface BlockEndToken extends BaseToken {
305
+
306
+ typ: EnumToken.BlockEndTokenType
307
+ }
308
+
309
+ export declare interface AttrStartToken extends BaseToken {
310
+
311
+ typ: EnumToken.AttrStartTokenType;
312
+ chi?: Token[];
313
+ }
314
+
315
+ export declare interface AttrEndToken extends BaseToken {
316
+
317
+ typ: EnumToken.AttrEndTokenType
318
+ }
319
+
320
+ export declare interface ParensStartToken extends BaseToken {
321
+
322
+ typ: EnumToken.StartParensTokenType;
323
+ }
324
+
325
+ export declare interface ParensEndToken extends BaseToken {
326
+
327
+ typ: EnumToken.EndParensTokenType
328
+ }
329
+
330
+ export declare interface ParensToken extends BaseToken {
331
+
332
+ typ: EnumToken.ParensTokenType;
333
+ chi: Token[];
334
+ }
335
+
336
+ export declare interface WhitespaceToken extends BaseToken {
337
+
338
+ typ: EnumToken.WhitespaceTokenType
339
+ }
340
+
341
+ export declare interface CommentToken extends BaseToken {
342
+
343
+ typ: EnumToken.CommentTokenType;
344
+ val: string;
345
+ }
346
+
347
+ export declare interface BadCommentToken extends BaseToken {
348
+
349
+ typ: EnumToken.BadCommentTokenType;
350
+ val: string;
351
+ }
352
+
353
+ export declare interface CDOCommentToken extends BaseToken {
354
+
355
+ typ: EnumToken.CDOCOMMTokenType;
356
+ val: string;
357
+ }
358
+
359
+ export declare interface BadCDOCommentToken extends BaseToken {
360
+
361
+ typ: EnumToken.BadCdoTokenType;
362
+ val: string;
363
+ }
364
+
365
+ export declare interface IncludeMatchToken extends BaseToken {
366
+
367
+ typ: EnumToken.IncludeMatchTokenType;
368
+ // val: '~=';
369
+ }
370
+
371
+ export declare interface DashMatchToken extends BaseToken {
372
+
373
+ typ: EnumToken.DashMatchTokenType;
374
+ // val: '|=';
375
+ }
376
+
377
+ export declare interface StartMatchToken extends BaseToken {
378
+
379
+ typ: EnumToken.StartMatchTokenType;
380
+ // val: '^=';
381
+ }
382
+
383
+ export declare interface EndMatchToken extends BaseToken {
384
+
385
+ typ: EnumToken.EndMatchTokenType;
386
+ // val: '|=';
387
+ }
388
+
389
+ export declare interface ContainMatchToken extends BaseToken {
390
+
391
+ typ: EnumToken.ContainMatchTokenType;
392
+ // val: '|=';
393
+ }
394
+
395
+ export declare interface LessThanToken extends BaseToken {
396
+
397
+ typ: EnumToken.LtTokenType;
398
+ }
399
+
400
+ export declare interface LessThanOrEqualToken extends BaseToken {
401
+
402
+ typ: EnumToken.LteTokenType;
403
+ }
404
+
405
+ export declare interface GreaterThanToken extends BaseToken {
406
+
407
+ typ: EnumToken.GtTokenType;
408
+ }
409
+
410
+ export declare interface GreaterThanOrEqualToken extends BaseToken {
411
+
412
+ typ: EnumToken.GteTokenType;
413
+ }
414
+
415
+ export declare interface ColumnCombinatorToken extends BaseToken {
416
+
417
+ typ: EnumToken.ColumnCombinatorTokenType;
418
+ }
419
+
420
+ export declare interface PseudoClassToken extends BaseToken {
421
+
422
+ typ: EnumToken.PseudoClassTokenType;
423
+ val: string;
424
+ }
425
+
426
+ export declare interface PseudoClassFunctionToken extends BaseToken {
427
+
428
+ typ: EnumToken.PseudoClassFuncTokenType;
429
+ val: string;
430
+ chi: Token[];
431
+ }
432
+
433
+ export declare interface DelimToken extends BaseToken {
434
+
435
+ typ: EnumToken.DelimTokenType;
436
+ val: '=';
437
+ }
438
+
439
+ export declare interface BadUrlToken extends BaseToken {
440
+
441
+ typ: EnumToken.BadUrlTokenType,
442
+ val: string;
443
+ }
444
+
445
+ export declare interface UrlToken extends BaseToken {
446
+
447
+ typ: EnumToken.UrlTokenTokenType,
448
+ val: string;
449
+ }
450
+
451
+ export declare interface EOFToken extends BaseToken {
452
+
453
+ typ: EnumToken.EOFTokenType;
454
+ }
455
+
456
+ export declare interface ImportantToken extends BaseToken {
457
+
458
+ typ: EnumToken.ImportantTokenType;
459
+ }
460
+
461
+ export declare type ColorKind = 'lit' | 'hex' | 'rgb' | 'rgba' | 'hsl' | 'hsla' | 'hwb' | 'device-cmyk' | 'oklab' | 'oklch' | 'lab' | 'lch' | 'color';
462
+
463
+ // export declare type HueInterpolationMethod = 'shorter' | 'longer' | 'increasing' | 'decreasing';
464
+
465
+ export declare interface ColorToken extends BaseToken {
466
+
467
+ typ: EnumToken.ColorTokenType;
468
+ val: string;
469
+ kin: ColorKind;
470
+ chi?: Token[];
471
+ /* calculated */
472
+ cal?: 'rel' | 'mix';
473
+ }
474
+
475
+ export declare interface AttrToken extends BaseToken {
476
+
477
+ typ: EnumToken.AttrTokenType,
478
+ chi: Token[]
479
+ }
480
+
481
+ export declare interface AddToken extends BaseToken {
482
+
483
+ typ: EnumToken.Add;
484
+ }
485
+
486
+ export declare interface SubToken extends BaseToken {
487
+
488
+ typ: EnumToken.Sub;
489
+ }
490
+
491
+ export declare interface DivToken extends BaseToken {
492
+
493
+ typ: EnumToken.Div;
494
+ }
495
+
496
+ export declare interface MulToken extends BaseToken {
497
+
498
+ typ: EnumToken.Mul;
499
+ }
500
+
501
+ export declare interface UnaryExpression extends BaseToken {
502
+
503
+ typ: EnumToken.UnaryExpressionTokenType
504
+ sign: EnumToken.Add | EnumToken.Sub;
505
+ val: UnaryExpressionNode;
506
+ }
507
+
508
+ export declare interface FractionToken extends BaseToken {
509
+
510
+ typ: EnumToken.FractionTokenType;
511
+ l: NumberToken;
512
+ r: NumberToken;
513
+ }
514
+
515
+ export declare interface BinaryExpressionToken extends BaseToken {
516
+
517
+ typ: EnumToken.BinaryExpressionTokenType
518
+ op: EnumToken.Add | EnumToken.Sub | EnumToken.Div | EnumToken.Mul;
519
+ l: BinaryExpressionNode | Token;
520
+ r: BinaryExpressionNode | Token;
521
+ }
522
+
523
+ export declare interface MatchExpressionToken extends BaseToken {
524
+
525
+ typ: EnumToken.MatchExpressionTokenType
526
+ op: EnumToken.DashMatchTokenType | EnumToken.StartMatchTokenType | EnumToken.ContainMatchTokenType | EnumToken.EndMatchTokenType | EnumToken.IncludeMatchTokenType;
527
+ l: Token;
528
+ r: Token;
529
+ attr?: 'i' | 's';
530
+ }
531
+
532
+ export declare interface NameSpaceAttributeToken extends BaseToken {
533
+
534
+ typ: EnumToken.NameSpaceAttributeTokenType
535
+ l?: Token;
536
+ r: Token;
537
+ }
538
+
539
+ export declare interface ListToken extends BaseToken {
540
+
541
+ typ: EnumToken.ListToken
542
+ chi: Token[];
543
+ }
544
+
545
+ export declare type UnaryExpressionNode =
546
+ BinaryExpressionNode
547
+ | NumberToken
548
+ | DimensionToken
549
+ | TimeToken
550
+ | LengthToken
551
+ | AngleToken
552
+ | FrequencyToken;
553
+
554
+ export declare type BinaryExpressionNode = NumberToken | DimensionToken | PercentageToken | FlexToken | FractionToken |
555
+ AngleToken | LengthToken | FrequencyToken | BinaryExpressionToken | FunctionToken | ParensToken;
556
+
557
+ export declare type Token =
558
+ LiteralToken
559
+ | IdentToken
560
+ | IdentListToken
561
+ | DashedIdentToken
562
+ | CommaToken
563
+ | ColonToken
564
+ | SemiColonToken
565
+ |
566
+ NumberToken
567
+ | AtRuleToken
568
+ | PercentageToken
569
+ | FlexToken
570
+ | FunctionURLToken
571
+ | FunctionImageToken
572
+ | TimingFunctionToken
573
+ | TimelineFunctionToken
574
+ | FunctionToken
575
+ | GridTemplateFuncToken
576
+ | DimensionToken
577
+ | LengthToken
578
+ |
579
+ AngleToken
580
+ | StringToken
581
+ | TimeToken
582
+ | FrequencyToken
583
+ | ResolutionToken
584
+ |
585
+ UnclosedStringToken
586
+ | HashToken
587
+ | BadStringToken
588
+ | BlockStartToken
589
+ | BlockEndToken
590
+ |
591
+ AttrStartToken
592
+ | AttrEndToken
593
+ | ParensStartToken
594
+ | ParensEndToken
595
+ | ParensToken
596
+ | CDOCommentToken
597
+ |
598
+ BadCDOCommentToken
599
+ | CommentToken
600
+ | BadCommentToken
601
+ | WhitespaceToken
602
+ | IncludeMatchToken
603
+ | StartMatchToken
604
+ | EndMatchToken
605
+ | ContainMatchToken | MatchExpressionToken | NameSpaceAttributeToken
606
+ |
607
+ DashMatchToken
608
+ | LessThanToken
609
+ | LessThanOrEqualToken
610
+ | GreaterThanToken
611
+ | GreaterThanOrEqualToken
612
+ | ColumnCombinatorToken
613
+ |
614
+ ListToken
615
+ | PseudoClassToken
616
+ | PseudoClassFunctionToken
617
+ | DelimToken
618
+ | BinaryExpressionToken
619
+ | UnaryExpression
620
+ | FractionToken
621
+ |
622
+ AddToken
623
+ | SubToken
624
+ | DivToken
625
+ | MulToken
626
+ |
627
+ BadUrlToken
628
+ | UrlToken
629
+ | ImportantToken
630
+ | ColorToken
631
+ | AttrToken
632
+ | EOFToken;
633
+
634
+ export declare interface Position {
635
+
636
+ ind: number;
637
+ lin: number;
638
+ col: number;
639
+ }
640
+
641
+ export declare interface Location {
642
+
643
+ sta: Position;
644
+ // end: Position;
645
+ src: string;
646
+ }
647
+
648
+ export declare interface Node {
649
+
650
+ typ: EnumToken;
651
+ loc?: Location;
652
+ }
653
+
654
+ export declare interface AstComment extends Node {
655
+
656
+ typ: EnumToken.CommentNodeType | EnumToken.CDOCOMMNodeType,
657
+ val: string;
658
+ }
659
+
660
+ export declare interface AstDeclaration extends Node {
661
+
662
+ nam: string,
663
+ val: Token[];
664
+ typ: EnumToken.DeclarationNodeType
665
+ }
666
+
667
+ export declare interface AstRule$1 extends Node {
668
+
669
+ typ: EnumToken.RuleNodeType;
670
+ sel: string;
671
+ chi: Array<AstDeclaration | AstComment | AstRuleList>;
672
+ optimized?: OptimizedSelector;
673
+ raw?: RawSelectorTokens;
674
+ }
675
+
676
+ export declare type RawSelectorTokens = string[][];
677
+
678
+ export declare interface OptimizedSelector {
679
+ match: boolean;
680
+ optimized: string[];
681
+ selector: string[][],
682
+ reducible: boolean;
683
+ }
684
+
685
+ export declare interface AstAtRule$1 extends Node {
686
+
687
+ typ: AtRuleNodeType,
688
+ nam: string;
689
+ val: string;
690
+ chi?: Array<AstDeclaration | AstComment> | Array<AstRule$1 | AstComment>
691
+ }
692
+
693
+ export declare interface AstRuleList extends Node {
694
+
695
+ typ: StyleSheetNodeType | RuleNodeType | AtRuleNodeType,
696
+ chi: Array<Node | AstComment>
697
+ }
698
+
699
+ export declare interface AstRuleStyleSheet$1 extends AstRuleList {
700
+ typ: StyleSheetNodeType,
701
+ chi: Array<AstRuleList | AstComment>
702
+ }
703
+
704
+ export declare type AstNode =
705
+ AstRuleStyleSheet$1
706
+ | AstRuleList
707
+ | AstComment
708
+ | AstAtRule$1
709
+ | AstRule$1
710
+ | AstDeclaration;
711
+
712
+ /**
713
+ * Declaration visitor handler
714
+ */
715
+ export declare type DeclarationVisitorHandler = (node: AstDeclaration) => AstDeclaration | AstDeclaration[] | null | Promise<AstDeclaration | AstDeclaration[] | null>;
716
+ /**
717
+ * Rule visitor handler
718
+ */
719
+ export declare type RuleVisitorHandler = (node: AstRule$1) => AstRule$1 | AstRule$1[] | null | Promise<AstRule$1 | AstRule$1[] | null>;
720
+
721
+ /**
722
+ * AtRule visitor handler
723
+ */
724
+ export declare type AtRuleVisitorHandler = (node: AstAtRule$1) => AstAtRule$1 | AstAtRule$1[] | null | Promise<AstAtRule$1 | AstAtRule$1[] | null>;
725
+
726
+ /**
727
+ * Value visitor handler
728
+ */
729
+ export declare type ValueVisitorHandler = (node: Token) => Token | Token[] | null | Promise<Token | Token[] | null>;
730
+
731
+
732
+ export declare interface VisitorNodeMap {
733
+
734
+ AtRule?: Record<string, AtRuleVisitorHandler> | AtRuleVisitorHandler;
735
+ Declaration?: Record<string, DeclarationVisitorHandler> | DeclarationVisitorHandler;
736
+ Rule?: RuleVisitorHandler;
737
+ Value?: Record<EnumToken, ValueVisitorHandler> | ValueVisitorHandler;
738
+ }
739
+
740
+ export declare type WalkerOption = 'ignore' | 'stop' | 'children' | 'ignore-children' | null;
741
+ /**
742
+ * returned value:
743
+ * - 'ignore': ignore this node and its children
744
+ * - 'stop': stop walking the tree
745
+ * - 'children': walk the children and ignore the node itself
746
+ * - 'ignore-children': walk the node and ignore children
747
+ */
748
+ export declare type WalkerFilter = (node: AstNode) => WalkerOption;
749
+
750
+ /**
751
+ * returned value:
752
+ * - 'ignore': ignore this node and its children
753
+ * - 'stop': stop walking the tree
754
+ * - 'children': walk the children and ignore the node itself
755
+ * - 'ignore-children': walk the node and ignore children
756
+ */
757
+ export declare type WalkerValueFilter = (node: Token) => WalkerOption;
758
+
759
+ export declare interface WalkResult {
760
+ node: AstNode;
761
+ parent?: AstRuleList;
762
+ root?: AstRuleList;
763
+ }
764
+
765
+ export declare interface WalkAttributesResult {
766
+ value: Token;
767
+ root?: AstNode;
768
+ parent: FunctionToken | ParensToken | BinaryExpressionToken | null;
769
+ }
770
+
771
+ export declare interface ErrorDescription {
772
+
773
+ // drop rule or declaration | fix rule or declaration
774
+ action: 'drop' | 'ignore';
775
+ message: string;
776
+ location?: {
777
+ src: string,
778
+ lin: number,
779
+ col: number;
780
+ };
781
+ error?: Error;
782
+ }
783
+
784
+ export declare interface MinifyFeature {
785
+
786
+ ordering: number;
787
+
788
+ register: (options: MinifyOptions | ParserOptions) => void;
789
+ run: (ast: AstRule | AstAtRule, options: ParserOptions = {}, parent: AstRule | AstAtRule | AstRuleStyleSheet, context: {
790
+ [key: string]: any
791
+ }) => void;
792
+ cleanup?: (ast: AstRuleStyleSheet, options: ParserOptions = {}, context: { [key: string]: any }) => void;
793
+ }
794
+
795
+ export declare interface ParserOptions extends PropertyListOptions {
796
+
797
+ minify?: boolean;
798
+ src?: string;
799
+ sourcemap?: boolean;
800
+ nestingRules?: boolean;
801
+ expandNestingRules?: boolean;
802
+ removeCharset?: boolean;
803
+ removeEmpty?: boolean;
804
+ resolveUrls?: boolean;
805
+ resolveImport?: boolean;
806
+ cwd?: string;
807
+ parseColor?: boolean;
808
+ removeDuplicateDeclarations?: boolean;
809
+ computeShorthand?: boolean;
810
+ inlineCssVariables?: boolean;
811
+ computeCalcExpression?: boolean;
812
+ load?: (url: string, currentUrl: string) => Promise<string>;
813
+ dirname?: (path: string) => string;
814
+ resolve?: (url: string, currentUrl: string, currentWorkingDirectory?: string) => {
815
+ absolute: string;
816
+ relative: string;
817
+ };
818
+ visitor?: VisitorNodeMap;
819
+ signal?: AbortSignal;
820
+ }
821
+
822
+ export declare interface MinifyOptions extends ParserOptions {
823
+
824
+ features: MinifyFeature[];
825
+ }
826
+
827
+ export declare interface ResolvedPath {
828
+ absolute: string;
829
+ relative: string;
830
+ }
831
+
832
+ export declare interface RenderOptions {
833
+
834
+ minify?: boolean;
835
+ expandNestingRules?: boolean;
836
+ preserveLicense?: boolean;
837
+ sourcemap?: boolean;
838
+ indent?: string;
839
+ newLine?: string;
840
+ removeComments?: boolean;
841
+ convertColor?: boolean;
842
+ output?: string;
843
+ cwd?: string;
844
+ load?: (url: string, currentUrl: string) => Promise<string>;
845
+ resolve?: (url: string, currentUrl: string, currentWorkingDirectory?: string) => ResolvedPath;
846
+
847
+ }
848
+
849
+ export declare interface TransformOptions extends ParserOptions, RenderOptions {
850
+
851
+ }
852
+
853
+ export declare interface ParseResult {
854
+ ast: AstRuleStyleSheet;
855
+ errors: ErrorDescription[];
856
+ stats: {
857
+ bytesIn: number;
858
+ parse: string;
859
+ minify: string;
860
+ total: string;
861
+ }
862
+ }
863
+
864
+ export declare interface RenderResult {
865
+ code: string;
866
+ errors: ErrorDescription[];
867
+ stats: {
868
+ total: string;
869
+ },
870
+ map?: SourceMapObject
871
+ }
872
+
873
+ export declare interface TransformResult extends ParseResult, RenderResult {
874
+
875
+ stats: {
876
+ bytesIn: number;
877
+ bytesOut: number;
878
+ parse: string;
879
+ minify: string;
880
+ render: string;
881
+ total: string;
882
+ }
883
+ }
884
+
885
+ export declare interface ParseTokenOptions extends ParserOptions {
886
+ }
887
+
888
+ export declare interface SourceMapObject {
889
+ version: number;
890
+ file?: string;
891
+ sourceRoot?: string;
892
+ sources?: string[];
893
+ sourcesContent?: Array<string | null>;
894
+ names?: string[];
895
+ mappings: string;
896
+ }
897
+
898
+ declare function dirname(path: string): string;
899
+ declare function resolve(url: string, currentDirectory: string, cwd?: string): {
900
+ absolute: string;
901
+ relative: string;
902
+ };
903
+
904
+ declare function load(url: string, currentFile: string): Promise<string>;
905
+
906
+ declare function render(data: AstNode, options?: RenderOptions): RenderResult;
907
+ declare function parse(iterator: string, opt?: ParserOptions): Promise<ParseResult>;
908
+ declare function transform(css: string, options?: TransformOptions): Promise<TransformResult>;
909
+
910
+ export { EnumToken, dirname, expand, load, minify, parse, parseString, parseTokens, render, renderToken, resolve, transform, walk, walkValues };