@tbela99/css-parser 1.3.2 → 1.3.3

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
@@ -29,7 +29,7 @@ declare enum ValidationLevel {
29
29
  /**
30
30
  * enum of all token types
31
31
  */
32
- declare enum EnumToken {
32
+ declare enum EnumToken$1 {
33
33
  /**
34
34
  * comment token
35
35
  */
@@ -325,7 +325,7 @@ declare enum EnumToken {
325
325
  /**
326
326
  * keyframe rule node type
327
327
  */
328
- KeyFrameRuleNodeType = 73,
328
+ KeyFramesRuleNodeType = 73,
329
329
  /**
330
330
  * class selector token type
331
331
  */
@@ -405,7 +405,7 @@ declare enum EnumToken {
405
405
  /**
406
406
  * keyframe at rule node type
407
407
  */
408
- KeyframeAtRuleNodeType = 93,
408
+ KeyframesAtRuleNodeType = 93,
409
409
  /**
410
410
  * invalid declaration node type
411
411
  */
@@ -643,53 +643,143 @@ declare enum ColorType {
643
643
  *
644
644
  * @private
645
645
  */
646
- declare function minify(ast: AstNode, options: ParserOptions | MinifyFeatureOptions, recursive: boolean, errors?: ErrorDescription[], nestingContent?: boolean): AstNode;
646
+ declare function minify(ast: AstNode$1, options: ParserOptions | MinifyFeatureOptions, recursive: boolean, errors?: ErrorDescription[], nestingContent?: boolean): AstNode$1;
647
647
 
648
+ /**
649
+ * options for the walk function
650
+ */
648
651
  declare enum WalkerOptionEnum {
649
652
  /**
650
653
  * ignore the current node and its children
651
654
  */
652
- Ignore = 0,
655
+ Ignore = 1,
653
656
  /**
654
657
  * stop walking the tree
655
658
  */
656
- Stop = 1,
659
+ Stop = 2,
657
660
  /**
658
661
  * ignore node and process children
659
662
  */
660
- Children = 2,
663
+ Children = 4,
661
664
  /**
662
665
  * ignore children
663
666
  */
664
- IgnoreChildren = 3
667
+ IgnoreChildren = 8
665
668
  }
669
+ /**
670
+ * event types for the walkValues function
671
+ */
666
672
  declare enum WalkerValueEvent {
667
673
  /**
668
674
  * enter node
669
675
  */
670
- Enter = 0,
676
+ Enter = 1,
671
677
  /**
672
678
  * leave node
673
679
  */
674
- Leave = 1
680
+ Leave = 2
675
681
  }
676
682
  /**
677
683
  * walk ast nodes
678
- * @param node
679
- * @param filter
684
+ * @param node initial node
685
+ * @param filter control the walk process
686
+ * @param reverse walk in reverse order
687
+ *
688
+ * ```ts
689
+ *
690
+ * import {walk} from '@tbela99/css-parser';
691
+ *
692
+ * const css = `
693
+ * body { color: color(from var(--base-color) display-p3 r calc(g + 0.24) calc(b + 0.15)); }
694
+ *
695
+ * html,
696
+ * body {
697
+ * line-height: 1.474;
698
+ * }
699
+ *
700
+ * .ruler {
701
+ *
702
+ * height: 10px;
703
+ * }
704
+ * `;
705
+ *
706
+ * for (const {node, parent, root} of walk(ast)) {
707
+ *
708
+ * // do something with node
709
+ * }
710
+ * ```
711
+ *
712
+ * Using a filter to control the walk process:
713
+ *
714
+ * ```ts
715
+ *
716
+ * import {walk} from '@tbela99/css-parser';
717
+ *
718
+ * const css = `
719
+ * body { color: color(from var(--base-color) display-p3 r calc(g + 0.24) calc(b + 0.15)); }
720
+ *
721
+ * html,
722
+ * body {
723
+ * line-height: 1.474;
724
+ * }
725
+ *
726
+ * .ruler {
727
+ *
728
+ * height: 10px;
729
+ * }
730
+ * `;
731
+ *
732
+ * for (const {node, parent, root} of walk(ast, (node) => {
733
+ *
734
+ * if (node.typ == EnumToken.AstRule && node.sel.includes('html')) {
735
+ *
736
+ * // skip the children of the current node
737
+ * return WalkerOptionEnum.IgnoreChildren;
738
+ * }
739
+ * })) {
740
+ *
741
+ * // do something with node
742
+ * }
743
+ * ```
680
744
  */
681
- declare function walk(node: AstNode, filter?: WalkerFilter): Generator<WalkResult>;
745
+ declare function walk(node: AstNode$1, filter?: WalkerFilter | null, reverse?: boolean): Generator<WalkResult>;
682
746
  /**
683
747
  * walk ast node value tokens
684
748
  * @param values
685
749
  * @param root
686
750
  * @param filter
687
751
  * @param reverse
752
+ *
753
+ * Example:
754
+ *
755
+ * ```ts
756
+ *
757
+ * import {EnumToken, walk} from '@tbela99/css-parser';
758
+ *
759
+ * const css = `
760
+ * body { color: color(from var(--base-color) display-p3 r calc(g + 0.24) calc(b + 0.15)); }
761
+ *
762
+ * html,
763
+ * body {
764
+ * line-height: 1.474;
765
+ * }
766
+ *
767
+ * .ruler {
768
+ *
769
+ * height: 10px;
770
+ * }
771
+ * `;
772
+ *
773
+ * for (const {value} of walkValues(result.ast.chi[0].chi[0].val, null, null,true)) {
774
+ *
775
+ * console.error([EnumToken[value.typ], value.val]);
776
+ * }
777
+ *
688
778
  */
689
- declare function walkValues(values: Token[], root?: AstNode | Token | null, filter?: WalkerValueFilter | {
779
+ declare function walkValues(values: Token$1[], root?: AstNode$1 | Token$1 | null, filter?: WalkerValueFilter | null | {
690
780
  event?: WalkerValueEvent;
691
781
  fn?: WalkerValueFilter;
692
- type?: EnumToken | EnumToken[] | ((token: Token) => boolean);
782
+ type?: EnumToken$1 | EnumToken$1[] | ((token: Token$1) => boolean);
693
783
  }, reverse?: boolean): Generator<WalkAttributesResult>;
694
784
 
695
785
  /**
@@ -698,7 +788,7 @@ declare function walkValues(values: Token[], root?: AstNode | Token | null, filt
698
788
  *
699
789
  * @private
700
790
  */
701
- declare function expand(ast: AstNode): AstNode;
791
+ declare function expand(ast: AstNode$1): AstNode$1;
702
792
 
703
793
  /**
704
794
  *
@@ -707,9 +797,9 @@ declare function expand(ast: AstNode): AstNode;
707
797
  *
708
798
  * @private
709
799
  */
710
- declare function renderToken(token: Token, options?: RenderOptions, cache?: {
800
+ declare function renderToken(token: Token$1, options?: RenderOptions, cache?: {
711
801
  [key: string]: any;
712
- }, reducer?: (acc: string, curr: Token) => string, errors?: ErrorDescription[]): string;
802
+ }, reducer?: (acc: string, curr: Token$1) => string, errors?: ErrorDescription[]): string;
713
803
 
714
804
  /**
715
805
  * Source map class
@@ -748,7 +838,7 @@ declare class SourceMap {
748
838
  * console.log(declarations);
749
839
  * ```
750
840
  */
751
- declare function parseDeclarations(declaration: string): Promise<AstDeclaration[]>;
841
+ declare function parseDeclarations(declaration: string): Promise<Array<AstDeclaration | AstComment>>;
752
842
  /**
753
843
  * parse css string and return an array of tokens
754
844
  * @param src
@@ -771,7 +861,7 @@ declare function parseDeclarations(declaration: string): Promise<AstDeclaration[
771
861
  */
772
862
  declare function parseString(src: string, options?: {
773
863
  location: boolean;
774
- }): Token[];
864
+ }): Token$1[];
775
865
  /**
776
866
  * parse function tokens in a token array
777
867
  * @param tokens
@@ -792,524 +882,784 @@ declare function parseString(src: string, options?: {
792
882
  *
793
883
  * @private
794
884
  */
795
- declare function parseTokens(tokens: Token[], options?: ParseTokenOptions): Token[];
885
+ declare function parseTokens(tokens: Token$1[], options?: ParseTokenOptions): Token$1[];
796
886
 
887
+ /**
888
+ * Literal token
889
+ */
797
890
  export declare interface LiteralToken extends BaseToken {
798
891
 
799
- typ: EnumToken.LiteralTokenType;
892
+ typ: EnumToken$1.LiteralTokenType;
800
893
  val: string;
801
894
  }
802
895
 
896
+ /**
897
+ * Class selector token
898
+ */
803
899
  export declare interface ClassSelectorToken extends BaseToken {
804
900
 
805
- typ: EnumToken.ClassSelectorTokenType;
901
+ typ: EnumToken$1.ClassSelectorTokenType;
806
902
  val: string;
807
903
  }
808
904
 
905
+ /**
906
+ * Invalid class selector token
907
+ */
809
908
  export declare interface InvalidClassSelectorToken extends BaseToken {
810
909
 
811
- typ: EnumToken.InvalidClassSelectorTokenType;
910
+ typ: EnumToken$1.InvalidClassSelectorTokenType;
812
911
  val: string;
813
912
  }
814
913
 
914
+ /**
915
+ * Universal selector token
916
+ */
815
917
  export declare interface UniversalSelectorToken extends BaseToken {
816
918
 
817
- typ: EnumToken.UniversalSelectorTokenType;
919
+ typ: EnumToken$1.UniversalSelectorTokenType;
818
920
  }
819
921
 
820
-
922
+ /**
923
+ * Ident token
924
+ */
821
925
  export declare interface IdentToken extends BaseToken {
822
926
 
823
- typ: EnumToken.IdenTokenType,
927
+ typ: EnumToken$1.IdenTokenType,
824
928
  val: string;
825
929
  }
826
930
 
931
+ /**
932
+ * Ident list token
933
+ */
827
934
  export declare interface IdentListToken extends BaseToken {
828
935
 
829
- typ: EnumToken.IdenListTokenType,
936
+ typ: EnumToken$1.IdenListTokenType,
830
937
  val: string;
831
938
  }
832
939
 
940
+ /**
941
+ * Dashed ident token
942
+ */
833
943
  export declare interface DashedIdentToken extends BaseToken {
834
944
 
835
- typ: EnumToken.DashedIdenTokenType,
945
+ typ: EnumToken$1.DashedIdenTokenType,
836
946
  val: string;
837
947
  }
838
948
 
949
+ /**
950
+ * Comma token
951
+ */
839
952
  export declare interface CommaToken extends BaseToken {
840
953
 
841
- typ: EnumToken.CommaTokenType
954
+ typ: EnumToken$1.CommaTokenType
842
955
  }
843
956
 
957
+ /**
958
+ * Colon token
959
+ */
844
960
  export declare interface ColonToken extends BaseToken {
845
961
 
846
- typ: EnumToken.ColonTokenType
962
+ typ: EnumToken$1.ColonTokenType
847
963
  }
848
964
 
965
+ /**
966
+ * Semicolon token
967
+ */
849
968
  export declare interface SemiColonToken extends BaseToken {
850
969
 
851
- typ: EnumToken.SemiColonTokenType
970
+ typ: EnumToken$1.SemiColonTokenType
852
971
  }
853
972
 
973
+ /**
974
+ * Nesting selector token
975
+ */
854
976
  export declare interface NestingSelectorToken extends BaseToken {
855
977
 
856
- typ: EnumToken.NestingSelectorTokenType
978
+ typ: EnumToken$1.NestingSelectorTokenType
857
979
  }
858
980
 
981
+ /**
982
+ * Number token
983
+ */
859
984
  export declare interface NumberToken extends BaseToken {
860
985
 
861
- typ: EnumToken.NumberTokenType,
986
+ typ: EnumToken$1.NumberTokenType,
862
987
  val: number | FractionToken;
863
988
  }
864
989
 
990
+ /**
991
+ * At rule token
992
+ */
865
993
  export declare interface AtRuleToken extends BaseToken {
866
994
 
867
- typ: EnumToken.AtRuleTokenType,
995
+ typ: EnumToken$1.AtRuleTokenType,
868
996
  val: string;
869
997
  pre: string;
870
998
  }
871
999
 
1000
+ /**
1001
+ * Percentage token
1002
+ */
872
1003
  export declare interface PercentageToken extends BaseToken {
873
1004
 
874
- typ: EnumToken.PercentageTokenType,
1005
+ typ: EnumToken$1.PercentageTokenType,
875
1006
  val: number | FractionToken;
876
1007
  }
877
1008
 
1009
+ /**
1010
+ * Flex token
1011
+ */
878
1012
  export declare interface FlexToken extends BaseToken {
879
1013
 
880
- typ: EnumToken.FlexTokenType,
1014
+ typ: EnumToken$1.FlexTokenType,
881
1015
  val: number | FractionToken;
882
1016
  }
883
1017
 
1018
+ /**
1019
+ * Function token
1020
+ */
884
1021
  export declare interface FunctionToken extends BaseToken {
885
1022
 
886
- typ: EnumToken.FunctionTokenType,
1023
+ typ: EnumToken$1.FunctionTokenType,
887
1024
  val: string;
888
- chi: Token[];
1025
+ chi: Token$1[];
889
1026
  }
890
1027
 
1028
+ /**
1029
+ * Grid template function token
1030
+ */
891
1031
  export declare interface GridTemplateFuncToken extends BaseToken {
892
1032
 
893
- typ: EnumToken.GridTemplateFuncTokenType,
1033
+ typ: EnumToken$1.GridTemplateFuncTokenType,
894
1034
  val: string;
895
- chi: Token[];
1035
+ chi: Token$1[];
896
1036
  }
897
1037
 
1038
+ /**
1039
+ * Function URL token
1040
+ */
898
1041
  export declare interface FunctionURLToken extends BaseToken {
899
1042
 
900
- typ: EnumToken.UrlFunctionTokenType,
1043
+ typ: EnumToken$1.UrlFunctionTokenType,
901
1044
  val: 'url';
902
1045
  chi: Array<UrlToken | CommentToken>;
903
1046
  }
904
1047
 
1048
+ /**
1049
+ * Function image token
1050
+ */
905
1051
  export declare interface FunctionImageToken extends BaseToken {
906
1052
 
907
- typ: EnumToken.ImageFunctionTokenType,
1053
+ typ: EnumToken$1.ImageFunctionTokenType,
908
1054
  val: 'linear-gradient' | 'radial-gradient' | 'repeating-linear-gradient' | 'repeating-radial-gradient' | 'conic-gradient' | 'image' | 'image-set' | 'element' | 'cross-fade';
909
1055
  chi: Array<UrlToken | CommentToken>;
910
1056
  }
911
1057
 
1058
+ /**
1059
+ * Timing function token
1060
+ */
912
1061
  export declare interface TimingFunctionToken extends BaseToken {
913
1062
 
914
- typ: EnumToken.TimingFunctionTokenType;
1063
+ typ: EnumToken$1.TimingFunctionTokenType;
915
1064
  val: string;
916
- chi: Token[];
1065
+ chi: Token$1[];
917
1066
  }
918
1067
 
1068
+ /**
1069
+ * Timeline function token
1070
+ */
919
1071
  export declare interface TimelineFunctionToken extends BaseToken {
920
1072
 
921
- typ: EnumToken.TimelineFunctionTokenType;
1073
+ typ: EnumToken$1.TimelineFunctionTokenType;
922
1074
  val: string;
923
- chi: Token[];
1075
+ chi: Token$1[];
924
1076
  }
925
1077
 
1078
+ /**
1079
+ * String token
1080
+ */
926
1081
  export declare interface StringToken extends BaseToken {
927
1082
 
928
- typ: EnumToken.StringTokenType;
1083
+ typ: EnumToken$1.StringTokenType;
929
1084
  val: string;
930
1085
  }
931
1086
 
1087
+ /**
1088
+ * Bad string token
1089
+ */
932
1090
  export declare interface BadStringToken extends BaseToken {
933
1091
 
934
- typ: EnumToken.BadStringTokenType;
1092
+ typ: EnumToken$1.BadStringTokenType;
935
1093
  val: string;
936
1094
  }
937
1095
 
1096
+ /**
1097
+ * Unclosed string token
1098
+ */
938
1099
  export declare interface UnclosedStringToken extends BaseToken {
939
1100
 
940
- typ: EnumToken.UnclosedStringTokenType;
1101
+ typ: EnumToken$1.UnclosedStringTokenType;
941
1102
  val: string;
942
1103
  }
943
1104
 
1105
+ /**
1106
+ * Dimension token
1107
+ */
944
1108
  export declare interface DimensionToken extends BaseToken {
945
1109
 
946
- typ: EnumToken.DimensionTokenType;
1110
+ typ: EnumToken$1.DimensionTokenType;
947
1111
  val: number | FractionToken;
948
1112
  unit: string;
949
1113
  }
950
1114
 
1115
+ /**
1116
+ * Length token
1117
+ */
951
1118
  export declare interface LengthToken extends BaseToken {
952
1119
 
953
- typ: EnumToken.LengthTokenType;
1120
+ typ: EnumToken$1.LengthTokenType;
954
1121
  val: number | FractionToken;
955
1122
  unit: string;
956
1123
  }
957
1124
 
1125
+ /**
1126
+ * Angle token
1127
+ */
958
1128
  export declare interface AngleToken extends BaseToken {
959
1129
 
960
- typ: EnumToken.AngleTokenType;
1130
+ typ: EnumToken$1.AngleTokenType;
961
1131
  val: number | FractionToken;
962
1132
  unit: string;
963
1133
  }
964
1134
 
1135
+ /**
1136
+ * Time token
1137
+ */
965
1138
  export declare interface TimeToken extends BaseToken {
966
1139
 
967
- typ: EnumToken.TimeTokenType;
1140
+ typ: EnumToken$1.TimeTokenType;
968
1141
  val: number | FractionToken;
969
1142
  unit: 'ms' | 's';
970
1143
  }
971
1144
 
1145
+ /**
1146
+ * Frequency token
1147
+ */
972
1148
  export declare interface FrequencyToken extends BaseToken {
973
1149
 
974
- typ: EnumToken.FrequencyTokenType;
1150
+ typ: EnumToken$1.FrequencyTokenType;
975
1151
  val: number | FractionToken;
976
1152
  unit: 'Hz' | 'Khz';
977
1153
  }
978
1154
 
1155
+ /**
1156
+ * Resolution token
1157
+ */
979
1158
  export declare interface ResolutionToken extends BaseToken {
980
1159
 
981
- typ: EnumToken.ResolutionTokenType;
1160
+ typ: EnumToken$1.ResolutionTokenType;
982
1161
  val: number | FractionToken;
983
1162
  unit: 'dpi' | 'dpcm' | 'dppx' | 'x';
984
1163
  }
985
1164
 
1165
+ /**
1166
+ * Hash token
1167
+ */
986
1168
  export declare interface HashToken extends BaseToken {
987
1169
 
988
- typ: EnumToken.HashTokenType;
1170
+ typ: EnumToken$1.HashTokenType;
989
1171
  val: string;
990
1172
  }
991
1173
 
1174
+ /**
1175
+ * Block start token
1176
+ */
992
1177
  export declare interface BlockStartToken extends BaseToken {
993
1178
 
994
- typ: EnumToken.BlockStartTokenType
1179
+ typ: EnumToken$1.BlockStartTokenType
995
1180
  }
996
1181
 
1182
+ /**
1183
+ * Block end token
1184
+ */
997
1185
  export declare interface BlockEndToken extends BaseToken {
998
1186
 
999
- typ: EnumToken.BlockEndTokenType
1187
+ typ: EnumToken$1.BlockEndTokenType
1000
1188
  }
1001
1189
 
1190
+ /**
1191
+ * Attribute start token
1192
+ */
1002
1193
  export declare interface AttrStartToken extends BaseToken {
1003
1194
 
1004
- typ: EnumToken.AttrStartTokenType;
1005
- chi?: Token[];
1195
+ typ: EnumToken$1.AttrStartTokenType;
1196
+ chi?: Token$1[];
1006
1197
  }
1007
1198
 
1199
+ /**
1200
+ * Attribute end token
1201
+ */
1008
1202
  export declare interface AttrEndToken extends BaseToken {
1009
1203
 
1010
- typ: EnumToken.AttrEndTokenType
1204
+ typ: EnumToken$1.AttrEndTokenType
1011
1205
  }
1012
1206
 
1207
+ /**
1208
+ * Parenthesis start token
1209
+ */
1013
1210
  export declare interface ParensStartToken extends BaseToken {
1014
1211
 
1015
- typ: EnumToken.StartParensTokenType;
1212
+ typ: EnumToken$1.StartParensTokenType;
1016
1213
  }
1017
1214
 
1215
+ /**
1216
+ * Parenthesis end token
1217
+ */
1018
1218
  export declare interface ParensEndToken extends BaseToken {
1019
1219
 
1020
- typ: EnumToken.EndParensTokenType
1220
+ typ: EnumToken$1.EndParensTokenType
1021
1221
  }
1022
1222
 
1223
+ /**
1224
+ * Parenthesis token
1225
+ */
1023
1226
  export declare interface ParensToken extends BaseToken {
1024
1227
 
1025
- typ: EnumToken.ParensTokenType;
1026
- chi: Token[];
1228
+ typ: EnumToken$1.ParensTokenType;
1229
+ chi: Token$1[];
1027
1230
  }
1028
1231
 
1232
+ /**
1233
+ * Whitespace token
1234
+ */
1029
1235
  export declare interface WhitespaceToken extends BaseToken {
1030
1236
 
1031
- typ: EnumToken.WhitespaceTokenType
1237
+ typ: EnumToken$1.WhitespaceTokenType
1032
1238
  }
1033
1239
 
1240
+ /**
1241
+ * Comment token
1242
+ */
1034
1243
  export declare interface CommentToken extends BaseToken {
1035
1244
 
1036
- typ: EnumToken.CommentTokenType;
1245
+ typ: EnumToken$1.CommentTokenType;
1037
1246
  val: string;
1038
1247
  }
1039
1248
 
1249
+ /**
1250
+ * Bad comment token
1251
+ */
1040
1252
  export declare interface BadCommentToken extends BaseToken {
1041
1253
 
1042
- typ: EnumToken.BadCommentTokenType;
1254
+ typ: EnumToken$1.BadCommentTokenType;
1043
1255
  val: string;
1044
1256
  }
1045
1257
 
1258
+ /**
1259
+ * CDO comment token
1260
+ */
1046
1261
  export declare interface CDOCommentToken extends BaseToken {
1047
1262
 
1048
- typ: EnumToken.CDOCOMMTokenType;
1263
+ typ: EnumToken$1.CDOCOMMTokenType;
1049
1264
  val: string;
1050
1265
  }
1051
1266
 
1267
+ /**
1268
+ * Bad CDO comment token
1269
+ */
1052
1270
  export declare interface BadCDOCommentToken extends BaseToken {
1053
1271
 
1054
- typ: EnumToken.BadCdoTokenType;
1272
+ typ: EnumToken$1.BadCdoTokenType;
1055
1273
  val: string;
1056
1274
  }
1057
1275
 
1276
+ /**
1277
+ * Include match token
1278
+ */
1058
1279
  export declare interface IncludeMatchToken extends BaseToken {
1059
1280
 
1060
- typ: EnumToken.IncludeMatchTokenType;
1281
+ typ: EnumToken$1.IncludeMatchTokenType;
1061
1282
  // val: '~=';
1062
1283
  }
1063
1284
 
1285
+ /**
1286
+ * Dash match token
1287
+ */
1064
1288
  export declare interface DashMatchToken extends BaseToken {
1065
1289
 
1066
- typ: EnumToken.DashMatchTokenType;
1290
+ typ: EnumToken$1.DashMatchTokenType;
1067
1291
  // val: '|=';
1068
1292
  }
1069
1293
 
1294
+ /**
1295
+ * Equal match token
1296
+ */
1070
1297
  export declare interface EqualMatchToken extends BaseToken {
1071
1298
 
1072
- typ: EnumToken.EqualMatchTokenType;
1299
+ typ: EnumToken$1.EqualMatchTokenType;
1073
1300
  // val: '|=';
1074
1301
  }
1075
1302
 
1303
+ /**
1304
+ * Start match token
1305
+ */
1076
1306
  export declare interface StartMatchToken extends BaseToken {
1077
1307
 
1078
- typ: EnumToken.StartMatchTokenType;
1308
+ typ: EnumToken$1.StartMatchTokenType;
1079
1309
  // val: '^=';
1080
1310
  }
1081
1311
 
1312
+ /**
1313
+ * End match token
1314
+ */
1082
1315
  export declare interface EndMatchToken extends BaseToken {
1083
1316
 
1084
- typ: EnumToken.EndMatchTokenType;
1317
+ typ: EnumToken$1.EndMatchTokenType;
1085
1318
  // val: '|=';
1086
1319
  }
1087
1320
 
1321
+ /**
1322
+ * Contain match token
1323
+ */
1088
1324
  export declare interface ContainMatchToken extends BaseToken {
1089
1325
 
1090
- typ: EnumToken.ContainMatchTokenType;
1326
+ typ: EnumToken$1.ContainMatchTokenType;
1091
1327
  // val: '|=';
1092
1328
  }
1093
1329
 
1330
+ /**
1331
+ * Less than token
1332
+ */
1094
1333
  export declare interface LessThanToken extends BaseToken {
1095
1334
 
1096
- typ: EnumToken.LtTokenType;
1335
+ typ: EnumToken$1.LtTokenType;
1097
1336
  }
1098
1337
 
1338
+ /**
1339
+ * Less than or equal token
1340
+ */
1099
1341
  export declare interface LessThanOrEqualToken extends BaseToken {
1100
1342
 
1101
- typ: EnumToken.LteTokenType;
1343
+ typ: EnumToken$1.LteTokenType;
1102
1344
  }
1103
1345
 
1346
+ /**
1347
+ * Greater than token
1348
+ */
1104
1349
  export declare interface GreaterThanToken extends BaseToken {
1105
1350
 
1106
- typ: EnumToken.GtTokenType;
1351
+ typ: EnumToken$1.GtTokenType;
1107
1352
  }
1108
1353
 
1354
+ /**
1355
+ * Greater than or equal token
1356
+ */
1109
1357
  export declare interface GreaterThanOrEqualToken extends BaseToken {
1110
1358
 
1111
- typ: EnumToken.GteTokenType;
1359
+ typ: EnumToken$1.GteTokenType;
1112
1360
  }
1113
1361
 
1362
+ /**
1363
+ * Column combinator token
1364
+ */
1114
1365
  export declare interface ColumnCombinatorToken extends BaseToken {
1115
1366
 
1116
- typ: EnumToken.ColumnCombinatorTokenType;
1367
+ typ: EnumToken$1.ColumnCombinatorTokenType;
1117
1368
  }
1118
1369
 
1370
+ /**
1371
+ * Pseudo class token
1372
+ */
1119
1373
  export declare interface PseudoClassToken extends BaseToken {
1120
1374
 
1121
- typ: EnumToken.PseudoClassTokenType;
1375
+ typ: EnumToken$1.PseudoClassTokenType;
1122
1376
  val: string;
1123
1377
  }
1124
1378
 
1379
+ /**
1380
+ * Pseudo element token
1381
+ */
1125
1382
  export declare interface PseudoElementToken extends BaseToken {
1126
1383
 
1127
- typ: EnumToken.PseudoElementTokenType;
1384
+ typ: EnumToken$1.PseudoElementTokenType;
1128
1385
  val: string;
1129
1386
  }
1130
1387
 
1388
+ /**
1389
+ * Pseudo page token
1390
+ */
1131
1391
  export declare interface PseudoPageToken extends BaseToken {
1132
1392
 
1133
- typ: EnumToken.PseudoPageTokenType;
1393
+ typ: EnumToken$1.PseudoPageTokenType;
1134
1394
  val: string;
1135
1395
  }
1136
1396
 
1397
+ /**
1398
+ * Pseudo class function token
1399
+ */
1137
1400
  export declare interface PseudoClassFunctionToken extends BaseToken {
1138
1401
 
1139
- typ: EnumToken.PseudoClassFuncTokenType;
1402
+ typ: EnumToken$1.PseudoClassFuncTokenType;
1140
1403
  val: string;
1141
- chi: Token[];
1404
+ chi: Token$1[];
1142
1405
  }
1143
1406
 
1407
+ /**
1408
+ * Delim token
1409
+ */
1144
1410
  export declare interface DelimToken extends BaseToken {
1145
1411
 
1146
- typ: EnumToken.DelimTokenType;
1412
+ typ: EnumToken$1.DelimTokenType;
1147
1413
  }
1148
1414
 
1415
+ /**
1416
+ * Bad URL token
1417
+ */
1149
1418
  export declare interface BadUrlToken extends BaseToken {
1150
1419
 
1151
- typ: EnumToken.BadUrlTokenType,
1420
+ typ: EnumToken$1.BadUrlTokenType,
1152
1421
  val: string;
1153
1422
  }
1154
1423
 
1424
+ /**
1425
+ * URL token
1426
+ */
1155
1427
  export declare interface UrlToken extends BaseToken {
1156
1428
 
1157
- typ: EnumToken.UrlTokenTokenType,
1429
+ typ: EnumToken$1.UrlTokenTokenType,
1158
1430
  val: string;
1159
1431
  }
1160
1432
 
1433
+ /**
1434
+ * EOF token
1435
+ */
1161
1436
  export declare interface EOFToken extends BaseToken {
1162
1437
 
1163
- typ: EnumToken.EOFTokenType;
1438
+ typ: EnumToken$1.EOFTokenType;
1164
1439
  }
1165
1440
 
1441
+ /**
1442
+ * Important token
1443
+ */
1166
1444
  export declare interface ImportantToken extends BaseToken {
1167
1445
 
1168
- typ: EnumToken.ImportantTokenType;
1446
+ typ: EnumToken$1.ImportantTokenType;
1169
1447
  }
1170
1448
 
1449
+ /**
1450
+ * Color token
1451
+ */
1171
1452
  export declare interface ColorToken extends BaseToken {
1172
1453
 
1173
- typ: EnumToken.ColorTokenType;
1454
+ typ: EnumToken$1.ColorTokenType;
1174
1455
  val: string;
1175
1456
  kin: ColorType;
1176
- chi?: Token[];
1457
+ chi?: Token$1[];
1177
1458
  /* calculated */
1178
1459
  cal?: 'rel' | 'mix';
1179
1460
  }
1180
1461
 
1462
+ /**
1463
+ * Attribute token
1464
+ */
1181
1465
  export declare interface AttrToken extends BaseToken {
1182
1466
 
1183
- typ: EnumToken.AttrTokenType,
1184
- chi: Token[]
1467
+ typ: EnumToken$1.AttrTokenType,
1468
+ chi: Token$1[]
1185
1469
  }
1186
1470
 
1471
+ /**
1472
+ * Invalid attribute token
1473
+ */
1187
1474
  export declare interface InvalidAttrToken extends BaseToken {
1188
1475
 
1189
- typ: EnumToken.InvalidAttrTokenType,
1190
- chi: Token[]
1476
+ typ: EnumToken$1.InvalidAttrTokenType,
1477
+ chi: Token$1[]
1191
1478
  }
1192
1479
 
1480
+ /**
1481
+ * Child combinator token
1482
+ */
1193
1483
  export declare interface ChildCombinatorToken extends BaseToken {
1194
1484
 
1195
- typ: EnumToken.ChildCombinatorTokenType
1485
+ typ: EnumToken$1.ChildCombinatorTokenType
1196
1486
  }
1197
1487
 
1488
+ /**
1489
+ * Media feature token
1490
+ */
1198
1491
  export declare interface MediaFeatureToken extends BaseToken {
1199
1492
 
1200
- typ: EnumToken.MediaFeatureTokenType,
1493
+ typ: EnumToken$1.MediaFeatureTokenType,
1201
1494
  val: string;
1202
1495
  }
1203
1496
 
1497
+ /**
1498
+ * Media feature not token
1499
+ */
1204
1500
  export declare interface MediaFeatureNotToken extends BaseToken {
1205
1501
 
1206
- typ: EnumToken.MediaFeatureNotTokenType,
1207
- val: Token;
1502
+ typ: EnumToken$1.MediaFeatureNotTokenType,
1503
+ val: Token$1;
1208
1504
  }
1209
1505
 
1506
+ /**
1507
+ * Media feature only token
1508
+ */
1210
1509
  export declare interface MediaFeatureOnlyToken extends BaseToken {
1211
1510
 
1212
- typ: EnumToken.MediaFeatureOnlyTokenType,
1213
- val: Token;
1511
+ typ: EnumToken$1.MediaFeatureOnlyTokenType,
1512
+ val: Token$1;
1214
1513
  }
1215
1514
 
1515
+ /**
1516
+ * Media feature and token
1517
+ */
1216
1518
  export declare interface MediaFeatureAndToken extends BaseToken {
1217
1519
 
1218
- typ: EnumToken.MediaFeatureAndTokenType;
1520
+ typ: EnumToken$1.MediaFeatureAndTokenType;
1219
1521
  }
1220
1522
 
1523
+ /**
1524
+ * Media feature or token
1525
+ */
1221
1526
  export declare interface MediaFeatureOrToken extends BaseToken {
1222
1527
 
1223
- typ: EnumToken.MediaFeatureOrTokenType;
1528
+ typ: EnumToken$1.MediaFeatureOrTokenType;
1224
1529
  }
1225
1530
 
1531
+ /**
1532
+ * Media query condition token
1533
+ */
1226
1534
  export declare interface MediaQueryConditionToken extends BaseToken {
1227
1535
 
1228
- typ: EnumToken.MediaQueryConditionTokenType,
1229
- l: Token,
1536
+ typ: EnumToken$1.MediaQueryConditionTokenType,
1537
+ l: Token$1,
1230
1538
  op: ColonToken | GreaterThanToken | LessThanToken | GreaterThanOrEqualToken | LessThanOrEqualToken,
1231
- r: Token[]
1539
+ r: Token$1[]
1232
1540
  }
1233
1541
 
1542
+ /**
1543
+ * Descendant combinator token
1544
+ */
1234
1545
  export declare interface DescendantCombinatorToken extends BaseToken {
1235
1546
 
1236
- typ: EnumToken.DescendantCombinatorTokenType
1547
+ typ: EnumToken$1.DescendantCombinatorTokenType
1237
1548
  }
1238
1549
 
1550
+ /**
1551
+ * Next sibling combinator token
1552
+ */
1239
1553
  export declare interface NextSiblingCombinatorToken extends BaseToken {
1240
1554
 
1241
- typ: EnumToken.NextSiblingCombinatorTokenType
1555
+ typ: EnumToken$1.NextSiblingCombinatorTokenType
1242
1556
  }
1243
1557
 
1558
+ /**
1559
+ * Subsequent sibling combinator token
1560
+ */
1244
1561
  export declare interface SubsequentCombinatorToken extends BaseToken {
1245
1562
 
1246
- typ: EnumToken.SubsequentSiblingCombinatorTokenType
1563
+ typ: EnumToken$1.SubsequentSiblingCombinatorTokenType
1247
1564
  }
1248
1565
 
1566
+ /**
1567
+ * Add token
1568
+ */
1249
1569
  export declare interface AddToken extends BaseToken {
1250
1570
 
1251
- typ: EnumToken.Add;
1571
+ typ: EnumToken$1.Add;
1252
1572
  }
1253
1573
 
1574
+ /**
1575
+ * Sub token
1576
+ */
1254
1577
  export declare interface SubToken extends BaseToken {
1255
1578
 
1256
- typ: EnumToken.Sub;
1579
+ typ: EnumToken$1.Sub;
1257
1580
  }
1258
1581
 
1582
+ /**
1583
+ * Div token
1584
+ */
1259
1585
  export declare interface DivToken extends BaseToken {
1260
1586
 
1261
- typ: EnumToken.Div;
1587
+ typ: EnumToken$1.Div;
1262
1588
  }
1263
1589
 
1590
+ /**
1591
+ * Mul token
1592
+ */
1264
1593
  export declare interface MulToken extends BaseToken {
1265
1594
 
1266
- typ: EnumToken.Mul;
1595
+ typ: EnumToken$1.Mul;
1267
1596
  }
1268
1597
 
1598
+ /**
1599
+ * Unary expression token
1600
+ */
1269
1601
  export declare interface UnaryExpression extends BaseToken {
1270
1602
 
1271
- typ: EnumToken.UnaryExpressionTokenType
1272
- sign: EnumToken.Add | EnumToken.Sub;
1603
+ typ: EnumToken$1.UnaryExpressionTokenType
1604
+ sign: EnumToken$1.Add | EnumToken$1.Sub;
1273
1605
  val: UnaryExpressionNode;
1274
1606
  }
1275
1607
 
1608
+ /**
1609
+ * Fraction token
1610
+ */
1276
1611
  export declare interface FractionToken extends BaseToken {
1277
1612
 
1278
- typ: EnumToken.FractionTokenType;
1613
+ typ: EnumToken$1.FractionTokenType;
1279
1614
  l: NumberToken;
1280
1615
  r: NumberToken;
1281
1616
  }
1282
1617
 
1618
+ /**
1619
+ * Binary expression token
1620
+ */
1283
1621
  export declare interface BinaryExpressionToken extends BaseToken {
1284
1622
 
1285
- typ: EnumToken.BinaryExpressionTokenType
1286
- op: EnumToken.Add | EnumToken.Sub | EnumToken.Div | EnumToken.Mul;
1287
- l: BinaryExpressionNode | Token;
1288
- r: BinaryExpressionNode | Token;
1623
+ typ: EnumToken$1.BinaryExpressionTokenType
1624
+ op: EnumToken$1.Add | EnumToken$1.Sub | EnumToken$1.Div | EnumToken$1.Mul;
1625
+ l: BinaryExpressionNode | Token$1;
1626
+ r: BinaryExpressionNode | Token$1;
1289
1627
  }
1290
1628
 
1629
+ /**
1630
+ * Match expression token
1631
+ */
1291
1632
  export declare interface MatchExpressionToken extends BaseToken {
1292
1633
 
1293
- typ: EnumToken.MatchExpressionTokenType
1634
+ typ: EnumToken$1.MatchExpressionTokenType
1294
1635
  op: EqualMatchToken | DashMatchToken | StartMatchToken | ContainMatchToken | EndMatchToken | IncludeMatchToken;
1295
- l: Token;
1296
- r: Token;
1636
+ l: Token$1;
1637
+ r: Token$1;
1297
1638
  attr?: 'i' | 's';
1298
1639
  }
1299
1640
 
1641
+ /**
1642
+ * Name space attribute token
1643
+ */
1300
1644
  export declare interface NameSpaceAttributeToken extends BaseToken {
1301
1645
 
1302
- typ: EnumToken.NameSpaceAttributeTokenType
1303
- l?: Token;
1304
- r: Token;
1646
+ typ: EnumToken$1.NameSpaceAttributeTokenType
1647
+ l?: Token$1;
1648
+ r: Token$1;
1305
1649
  }
1306
1650
 
1651
+ /**
1652
+ * List token
1653
+ */
1307
1654
  export declare interface ListToken extends BaseToken {
1308
1655
 
1309
- typ: EnumToken.ListToken
1310
- chi: Token[];
1656
+ typ: EnumToken$1.ListToken
1657
+ chi: Token$1[];
1311
1658
  }
1312
1659
 
1660
+ /**
1661
+ * Unary expression node
1662
+ */
1313
1663
  export declare type UnaryExpressionNode =
1314
1664
  BinaryExpressionNode
1315
1665
  | NumberToken
@@ -1319,10 +1669,16 @@ export declare type UnaryExpressionNode =
1319
1669
  | AngleToken
1320
1670
  | FrequencyToken;
1321
1671
 
1672
+ /**
1673
+ * Binary expression node
1674
+ */
1322
1675
  export declare type BinaryExpressionNode = NumberToken | DimensionToken | PercentageToken | FlexToken | FractionToken |
1323
1676
  AngleToken | LengthToken | FrequencyToken | BinaryExpressionToken | FunctionToken | ParensToken;
1324
1677
 
1325
- export declare type Token =
1678
+ /**
1679
+ * Token
1680
+ */
1681
+ export declare type Token$1 =
1326
1682
  InvalidClassSelectorToken
1327
1683
  | InvalidAttrToken
1328
1684
  |
@@ -1477,7 +1833,7 @@ interface Position$1 {
1477
1833
  lin: number;
1478
1834
  col: number;
1479
1835
  }
1480
- interface ValidationToken {
1836
+ interface ValidationToken$1 {
1481
1837
  typ: ValidationTokenEnum;
1482
1838
  pos: Position$1;
1483
1839
  isList?: boolean;
@@ -1495,7 +1851,7 @@ interface ValidationToken {
1495
1851
  export declare interface ValidationSyntaxNode {
1496
1852
 
1497
1853
  syntax: string;
1498
- ast?: ValidationToken[];
1854
+ ast?: ValidationToken$1[];
1499
1855
  }
1500
1856
 
1501
1857
  interface ValidationSelectorOptions extends ValidationOptions {
@@ -1517,16 +1873,16 @@ export declare interface ValidationConfiguration {
1517
1873
  interface ValidationResult {
1518
1874
 
1519
1875
  valid: SyntaxValidationResult;
1520
- node: AstNode | Token | null;
1521
- syntax: ValidationToken | string | null;
1876
+ node: AstNode$1 | Token$1 | null;
1877
+ syntax: ValidationToken$1 | string | null;
1522
1878
  error: string;
1523
1879
  cycle?: boolean;
1524
1880
  }
1525
1881
 
1526
1882
  interface ValidationSyntaxResult extends ValidationResult {
1527
1883
 
1528
- syntax: ValidationToken | string | null;
1529
- context: Context<Token> | Token[];
1884
+ syntax: ValidationToken$1 | string | null;
1885
+ context: Context<Token$1> | Token$1[];
1530
1886
  }
1531
1887
 
1532
1888
  interface Context<Type> {
@@ -1565,6 +1921,8 @@ interface Context<Type> {
1565
1921
  * @param token
1566
1922
  * @param to
1567
1923
  *
1924
+ * @private
1925
+ *
1568
1926
  * <code>
1569
1927
  *
1570
1928
  * const token = {typ: EnumToken.ColorTokenType, kin: ColorType.HEX, val: '#F00'}
@@ -1632,67 +1990,112 @@ export declare interface Location {
1632
1990
 
1633
1991
  export declare interface BaseToken {
1634
1992
 
1635
- typ: EnumToken;
1993
+ /**
1994
+ * token type
1995
+ */
1996
+ typ: EnumToken$1;
1997
+ /**
1998
+ * location info
1999
+ */
1636
2000
  loc?: Location;
1637
- tokens?: Token[];
1638
- parent?: AstRuleList;
2001
+ /**
2002
+ * prelude or selector tokens
2003
+ */
2004
+ tokens?: Token$1[] | null;
2005
+ /**
2006
+ * parent node
2007
+ */
2008
+ parent?: AstRuleList | null;
2009
+ /**
2010
+ * @private
2011
+ */
1639
2012
  validSyntax?: boolean;
1640
2013
  }
1641
2014
 
2015
+ /**
2016
+ * comment node
2017
+ */
1642
2018
  export declare interface AstComment extends BaseToken {
1643
2019
 
1644
- typ: EnumToken.CommentNodeType | EnumToken.CDOCOMMNodeType,
2020
+ typ: EnumToken$1.CommentNodeType | EnumToken$1.CDOCOMMNodeType,
1645
2021
  val: string;
1646
2022
  }
1647
2023
 
2024
+ /**
2025
+ * declaration node
2026
+ */
1648
2027
  export declare interface AstDeclaration extends BaseToken {
1649
2028
 
1650
2029
  nam: string,
1651
- val: Token[];
1652
- typ: EnumToken.DeclarationNodeType
2030
+ val: Token$1[];
2031
+ typ: EnumToken$1.DeclarationNodeType
1653
2032
  }
1654
2033
 
2034
+ /**
2035
+ * rule node
2036
+ */
1655
2037
  export declare interface AstRule extends BaseToken {
1656
2038
 
1657
- typ: EnumToken.RuleNodeType;
2039
+ typ: EnumToken$1.RuleNodeType;
1658
2040
  sel: string;
1659
2041
  chi: Array<AstDeclaration | AstComment | AstRuleList>;
1660
2042
  optimized?: OptimizedSelector | null;
1661
2043
  raw?: RawSelectorTokens | null;
1662
2044
  }
1663
2045
 
2046
+ /**
2047
+ * invalid rule node
2048
+ */
1664
2049
  export declare interface AstInvalidRule extends BaseToken {
1665
2050
 
1666
- typ: EnumToken.InvalidRuleTokenType;
2051
+ typ: EnumToken$1.InvalidRuleTokenType;
1667
2052
  sel: string;
1668
- chi: Array<AstNode>;
2053
+ chi: Array<AstNode$1>;
1669
2054
  }
1670
2055
 
2056
+ /**
2057
+ * invalid declaration node
2058
+ */
1671
2059
  export declare interface AstInvalidDeclaration extends BaseToken {
1672
2060
 
1673
- typ: EnumToken.InvalidDeclarationNodeType;
1674
- val: Array<AstNode>;
2061
+ typ: EnumToken$1.InvalidDeclarationNodeType;
2062
+ val: Array<AstNode$1>;
1675
2063
  }
1676
2064
 
2065
+ /**
2066
+ * invalid at rule node
2067
+ */
1677
2068
  export declare interface AstInvalidAtRule extends BaseToken {
1678
2069
 
1679
- typ: EnumToken.InvalidAtRuleTokenType;
2070
+ typ: EnumToken$1.InvalidAtRuleTokenType;
2071
+ nam: string;
1680
2072
  val: string;
1681
- chi?: Array<AstNode>;
2073
+ chi?: Array<AstNode$1>;
1682
2074
  }
1683
2075
 
2076
+ /**
2077
+ * keyframe rule node
2078
+ */
1684
2079
  export declare interface AstKeyFrameRule extends BaseToken {
1685
2080
 
1686
- typ: EnumToken.KeyFrameRuleNodeType;
2081
+ typ: EnumToken$1.KeyFramesRuleNodeType;
1687
2082
  sel: string;
1688
2083
  chi: Array<AstDeclaration | AstComment>;
1689
2084
  optimized?: OptimizedSelector;
1690
2085
  raw?: RawSelectorTokens;
1691
- tokens?: Token[]
2086
+ tokens?: Token$1[]
1692
2087
  }
1693
2088
 
2089
+ /**
2090
+ * raw selector tokens
2091
+ */
1694
2092
  export declare type RawSelectorTokens = string[][];
1695
2093
 
2094
+ /**
2095
+ * optimized selector
2096
+ *
2097
+ * @private
2098
+ */
1696
2099
  export declare interface OptimizedSelector {
1697
2100
  match: boolean;
1698
2101
  optimized: string[];
@@ -1700,74 +2103,108 @@ export declare interface OptimizedSelector {
1700
2103
  reducible: boolean;
1701
2104
  }
1702
2105
 
2106
+ /**
2107
+ * optimized selector token
2108
+ *
2109
+ * @private
2110
+ */
1703
2111
  export declare interface OptimizedSelectorToken {
1704
2112
  match: boolean;
1705
- optimized: Token[];
1706
- selector: Token[][],
2113
+ optimized: Token$1[];
2114
+ selector: Token$1[][],
1707
2115
  reducible: boolean;
1708
2116
  }
1709
2117
 
2118
+ /**
2119
+ * at rule node
2120
+ */
1710
2121
  export declare interface AstAtRule extends BaseToken {
1711
2122
 
1712
- typ: EnumToken.AtRuleNodeType,
2123
+ typ: EnumToken$1.AtRuleNodeType,
1713
2124
  nam: string;
1714
2125
  val: string;
1715
2126
  chi?: Array<AstDeclaration | AstInvalidDeclaration | AstComment> | Array<AstRule | AstComment>
1716
2127
  }
1717
2128
 
1718
- export declare interface AstKeyframeRule extends BaseToken {
2129
+ /**
2130
+ * keyframe rule node
2131
+ */
2132
+ export declare interface AstKeyframesRule extends BaseToken {
1719
2133
 
1720
- typ: EnumToken.KeyFrameRuleNodeType;
2134
+ typ: EnumToken$1.KeyFramesRuleNodeType;
1721
2135
  sel: string;
1722
2136
  chi: Array<AstDeclaration | AstInvalidDeclaration | AstComment | AstRuleList>;
1723
2137
  optimized?: OptimizedSelector;
1724
2138
  raw?: RawSelectorTokens;
1725
2139
  }
1726
2140
 
1727
- export declare interface AstKeyframAtRule extends BaseToken {
2141
+ /**
2142
+ * keyframe at rule node
2143
+ */
2144
+ export declare interface AstKeyframesAtRule extends BaseToken {
1728
2145
 
1729
- typ: EnumToken.KeyframeAtRuleNodeType,
2146
+ typ: EnumToken$1.KeyframesAtRuleNodeType,
1730
2147
  nam: string;
1731
2148
  val: string;
1732
- chi: Array<AstKeyframeRule | AstComment>;
2149
+ chi: Array<AstKeyframesRule | AstComment>;
1733
2150
  }
1734
2151
 
2152
+ /**
2153
+ * rule list node
2154
+ */
1735
2155
  export declare interface AstRuleList extends BaseToken {
1736
2156
 
1737
- typ: EnumToken.StyleSheetNodeType | EnumToken.RuleNodeType | EnumToken.AtRuleNodeType | EnumToken.KeyframeAtRuleNodeType | EnumToken.KeyFrameRuleNodeType | EnumToken.InvalidRuleTokenType | EnumToken.InvalidAtRuleTokenType,
2157
+ typ: EnumToken$1.StyleSheetNodeType | EnumToken$1.RuleNodeType | EnumToken$1.AtRuleNodeType | EnumToken$1.KeyframesAtRuleNodeType | EnumToken$1.KeyFramesRuleNodeType | EnumToken$1.InvalidRuleTokenType | EnumToken$1.InvalidAtRuleTokenType,
1738
2158
  chi: Array<BaseToken | AstComment>;
1739
2159
  }
1740
2160
 
1741
- export declare interface AstRuleStyleSheet extends AstRuleList {
1742
- typ: EnumToken.StyleSheetNodeType,
1743
- chi: Array<AstRuleList | AstComment>
2161
+ /**
2162
+ * rule list node
2163
+ */
2164
+ export declare interface AstStyleSheet extends AstRuleList {
2165
+ typ: EnumToken$1.StyleSheetNodeType,
2166
+ chi: Array<AstRuleList | AstComment>;
2167
+ tokens?: null;
1744
2168
  }
1745
2169
 
1746
- export declare type AstNode =
1747
- AstRuleStyleSheet
2170
+ /**
2171
+ * ast node
2172
+ */
2173
+ export declare type AstNode$1 =
2174
+ AstStyleSheet
1748
2175
  | AstRuleList
1749
2176
  | AstComment
1750
2177
  | AstAtRule
1751
2178
  | AstRule
1752
2179
  | AstDeclaration
1753
- | AstKeyframAtRule
2180
+ | AstKeyframesAtRule
1754
2181
  | AstKeyFrameRule
1755
2182
  | AstInvalidRule
1756
2183
  | AstInvalidDeclaration;
1757
2184
 
2185
+ export declare type VisitorEventType = 'Enter' | 'Leave' ;
2186
+ export declare type GenericVisitorResult<T> = T | T[] | Promise<T> | Promise<T[]> | null | Promise<null>;
2187
+ export declare type GenericVisitorHandler<T> = ((node: T, parent?: AstNode | Token, root?: AstNode | Token) => GenericVisitorResult<T>);
2188
+ export declare type GenericVisitorAstNodeHandlerMap<T> =
2189
+ Record<string, GenericVisitorHandler<T>>
2190
+ | GenericVisitorHandler<T>
2191
+ | { type: VisitorEventType, handler: Record<string, GenericVisitorHandler<T>> | GenericVisitorHandler<T> };
2192
+
2193
+ export declare type ValueVisitorHandler = GenericVisitorHandler<Token>;
2194
+
1758
2195
  /**
1759
2196
  * Declaration visitor handler
1760
2197
  */
1761
- export declare type DeclarationVisitorHandler = (node: AstDeclaration) => (AstDeclaration | AstDeclaration[] | null | Promise<AstDeclaration> | Promise<AstDeclaration[]> | Promise<null>);
2198
+ export declare type DeclarationVisitorHandler = GenericVisitorHandler<AstDeclaration>;
1762
2199
  /**
1763
2200
  * Rule visitor handler
1764
2201
  */
1765
- export declare type RuleVisitorHandler = (node: AstRule) => (AstRule | AstRule[] | null | Promise<AstRule> | Promise<AstRule[]> | Promise<null>);
2202
+ export declare type RuleVisitorHandler = GenericVisitorHandler<AstRule>;
1766
2203
 
1767
2204
  /**
1768
2205
  * AtRule visitor handler
1769
2206
  */
1770
- export declare type AtRuleVisitorHandler = (node: AstAtRule) => (AstAtRule | AstAtRule[] | null | Promise<AstAtRule> | Promise<AstAtRule[]> | Promise<null>);
2207
+ export declare type AtRuleVisitorHandler = GenericVisitorHandler<AstAtRule>;
1771
2208
 
1772
2209
  /**
1773
2210
  * node visitor callback map
@@ -1817,7 +2254,7 @@ export declare interface VisitorNodeMap {
1817
2254
  * // @media tv,screen{.foo{height:calc(40px/3)}}
1818
2255
  * ```
1819
2256
  */
1820
- AtRule?: Record<string, AtRuleVisitorHandler> | AtRuleVisitorHandler;
2257
+ AtRule?: GenericVisitorAstNodeHandlerMap<AstAtRule>;
1821
2258
  /**
1822
2259
  * declaration visitor
1823
2260
  *
@@ -1919,7 +2356,7 @@ export declare interface VisitorNodeMap {
1919
2356
  * // .foo{width:calc(40px/3);padding:10px}.selector{padding:20px}
1920
2357
  * ```
1921
2358
  */
1922
- Declaration?: Record<string, DeclarationVisitorHandler> | DeclarationVisitorHandler;
2359
+ Declaration?: GenericVisitorAstNodeHandlerMap<AstDeclaration>;
1923
2360
 
1924
2361
  /**
1925
2362
  * rule visitor
@@ -1961,7 +2398,71 @@ export declare interface VisitorNodeMap {
1961
2398
  * // .foo{width:3px;.foo{width:3px}}
1962
2399
  * ```
1963
2400
  */
1964
- Rule?: RuleVisitorHandler;
2401
+ Rule?: GenericVisitorAstNodeHandlerMap<AstRule>;
2402
+
2403
+ KeyframesRule?: GenericVisitorAstNodeHandlerMap<AstKeyframesRule>;
2404
+
2405
+ KeyframesAtRule?: GenericVisitorAstNodeHandlerMap<AstKeyframesAtRule> | Record<string, GenericVisitorAstNodeHandlerMap<AstKeyframesAtRule>>;
2406
+
2407
+ /**
2408
+ * value visitor
2409
+ */
2410
+ Value?: GenericVisitorHandler<Token> | Record<keyof EnumToken, GenericVisitorHandler<Token>> | {
2411
+ type: VisitorEventType,
2412
+ handler: GenericVisitorHandler<Token> | Record<keyof EnumToken, GenericVisitorHandler<Token>>
2413
+ };
2414
+
2415
+ /**
2416
+ * generic token visitor. the key name is of type keyof EnumToken.
2417
+ * generic tokens are called for every token of the specified type.
2418
+ *
2419
+ * ```ts
2420
+ *
2421
+ * import {transform, parse, parseDeclarations} from "@tbela99/css-parser";
2422
+ *
2423
+ * const options: ParserOptions = {
2424
+ *
2425
+ * inlineCssVariables: true,
2426
+ * visitor: {
2427
+ *
2428
+ * // Stylesheet node visitor
2429
+ * StyleSheetNodeType: async (node) => {
2430
+ *
2431
+ * // insert a new rule
2432
+ * node.chi.unshift(await parse('html {--base-color: pink}').then(result => result.ast.chi[0]))
2433
+ * },
2434
+ * ColorTokenType: (node) => {
2435
+ *
2436
+ * // dump all color tokens
2437
+ * // console.debug(node);
2438
+ * },
2439
+ * FunctionTokenType: (node) => {
2440
+ *
2441
+ * // dump all function tokens
2442
+ * // console.debug(node);
2443
+ * },
2444
+ * DeclarationNodeType: (node) => {
2445
+ *
2446
+ * // dump all declaration nodes
2447
+ * // console.debug(node);
2448
+ * }
2449
+ * }
2450
+ * };
2451
+ *
2452
+ * const css = `
2453
+ *
2454
+ * body { color: color(from var(--base-color) display-p3 r calc(g + 0.24) calc(b + 0.15)); }
2455
+ * `;
2456
+ *
2457
+ * console.debug(await transform(css, options));
2458
+ *
2459
+ * // body {color:#f3fff0}
2460
+ * ```
2461
+ */
2462
+ [key: keyof EnumToken]: GenericVisitorHandler<Token> | {
2463
+ type: VisitorEventType,
2464
+ handler: GenericVisitorHandler<Token>
2465
+ };
1965
2466
  }
1966
2467
 
1967
2468
  export declare interface PropertyListOptions {
@@ -1980,16 +2481,18 @@ export declare interface ParseInfo {
1980
2481
 
1981
2482
  /**
1982
2483
  * feature walk mode
2484
+ *
2485
+ * @internal
1983
2486
  */
1984
2487
  declare enum FeatureWalkMode {
1985
2488
  /**
1986
2489
  * pre process
1987
2490
  */
1988
- Pre = 0,
2491
+ Pre = 1,
1989
2492
  /**
1990
2493
  * post process
1991
2494
  */
1992
- Post = 1
2495
+ Post = 2
1993
2496
  }
1994
2497
 
1995
2498
  /**
@@ -2018,7 +2521,7 @@ interface ShorthandPropertyType {
2018
2521
  types: string[];
2019
2522
  multiple: boolean;
2020
2523
  separator: {
2021
- typ: keyof EnumToken;
2524
+ typ: keyof EnumToken$1;
2022
2525
  val: string
2023
2526
  };
2024
2527
  keywords: string[];
@@ -2037,13 +2540,13 @@ interface PropertyMapType {
2037
2540
  required?: boolean;
2038
2541
  multiple?: boolean;
2039
2542
  prefix?: {
2040
- typ: keyof EnumToken;
2543
+ typ: keyof EnumToken$1;
2041
2544
  val: string
2042
2545
  };
2043
2546
  previous?: string;
2044
2547
  separator?: {
2045
2548
 
2046
- typ: keyof EnumToken;
2549
+ typ: keyof EnumToken$1;
2047
2550
  };
2048
2551
  constraints?: {
2049
2552
  [key: string]: {
@@ -2061,7 +2564,7 @@ interface ShorthandMapType {
2061
2564
  default: string[];
2062
2565
  mapping?: Record<string, string>;
2063
2566
  multiple?: boolean;
2064
- separator?: { typ: keyof EnumToken; val?: string };
2567
+ separator?: { typ: keyof EnumToken$1; val?: string };
2065
2568
  set?: Record<string, string[]>
2066
2569
  properties: {
2067
2570
  [property: string]: PropertyMapType;
@@ -2069,7 +2572,7 @@ interface ShorthandMapType {
2069
2572
  }
2070
2573
 
2071
2574
  interface ShorthandProperties {
2072
- types: EnumToken[];
2575
+ types: EnumToken$1[];
2073
2576
  default: string[];
2074
2577
  keywords: string[];
2075
2578
  required?: boolean;
@@ -2100,11 +2603,17 @@ interface ShorthandType {
2100
2603
 
2101
2604
  // generated from config.json at https://app.quicktype.io/?l=ts
2102
2605
 
2606
+ /**
2607
+ * @private
2608
+ */
2103
2609
  export declare interface PropertiesConfig {
2104
2610
  properties: PropertiesConfigProperties;
2105
2611
  map: Map$1;
2106
2612
  }
2107
2613
 
2614
+ /**
2615
+ * @private
2616
+ */
2108
2617
  interface Map$1 {
2109
2618
  border: Border;
2110
2619
  "border-color": BackgroundPositionClass;
@@ -2133,6 +2642,9 @@ interface Map$1 {
2133
2642
  "background-size": BackgroundPositionClass;
2134
2643
  }
2135
2644
 
2645
+ /**
2646
+ * @private
2647
+ */
2136
2648
  interface Background {
2137
2649
  shorthand: string;
2138
2650
  pattern: string;
@@ -2143,6 +2655,9 @@ interface Background {
2143
2655
  properties: BackgroundProperties;
2144
2656
  }
2145
2657
 
2658
+ /**
2659
+ * @private
2660
+ */
2146
2661
  interface BackgroundProperties {
2147
2662
  "background-repeat": BackgroundRepeat;
2148
2663
  "background-color": PurpleBackgroundAttachment;
@@ -2154,6 +2669,9 @@ interface BackgroundProperties {
2154
2669
  "background-size": BackgroundSize;
2155
2670
  }
2156
2671
 
2672
+ /**
2673
+ * @private
2674
+ */
2157
2675
  interface PurpleBackgroundAttachment {
2158
2676
  types: string[];
2159
2677
  default: string[];
@@ -2162,6 +2680,9 @@ interface PurpleBackgroundAttachment {
2162
2680
  mapping?: BackgroundAttachmentMapping;
2163
2681
  }
2164
2682
 
2683
+ /**
2684
+ * @private
2685
+ */
2165
2686
  interface BackgroundAttachmentMapping {
2166
2687
  "ultra-condensed": string;
2167
2688
  "extra-condensed": string;
@@ -2174,6 +2695,9 @@ interface BackgroundAttachmentMapping {
2174
2695
  "ultra-expanded": string;
2175
2696
  }
2176
2697
 
2698
+ /**
2699
+ * @private
2700
+ */
2177
2701
  interface BackgroundPosition {
2178
2702
  multiple: boolean;
2179
2703
  types: string[];
@@ -2183,14 +2707,23 @@ interface BackgroundPosition {
2183
2707
  constraints: BackgroundPositionConstraints;
2184
2708
  }
2185
2709
 
2710
+ /**
2711
+ * @private
2712
+ */
2186
2713
  interface BackgroundPositionConstraints {
2187
2714
  mapping: ConstraintsMapping;
2188
2715
  }
2189
2716
 
2717
+ /**
2718
+ * @private
2719
+ */
2190
2720
  interface ConstraintsMapping {
2191
2721
  max: number;
2192
2722
  }
2193
2723
 
2724
+ /**
2725
+ * @private
2726
+ */
2194
2727
  interface BackgroundPositionMapping {
2195
2728
  left: string;
2196
2729
  top: string;
@@ -2199,6 +2732,9 @@ interface BackgroundPositionMapping {
2199
2732
  right: string;
2200
2733
  }
2201
2734
 
2735
+ /**
2736
+ * @private
2737
+ */
2202
2738
  interface BackgroundRepeat {
2203
2739
  types: any[];
2204
2740
  default: string[];
@@ -2207,6 +2743,9 @@ interface BackgroundRepeat {
2207
2743
  mapping: BackgroundRepeatMapping;
2208
2744
  }
2209
2745
 
2746
+ /**
2747
+ * @private
2748
+ */
2210
2749
  interface BackgroundRepeatMapping {
2211
2750
  "repeat no-repeat": string;
2212
2751
  "no-repeat repeat": string;
@@ -2216,6 +2755,9 @@ interface BackgroundRepeatMapping {
2216
2755
  "no-repeat no-repeat": string;
2217
2756
  }
2218
2757
 
2758
+ /**
2759
+ * @private
2760
+ */
2219
2761
  interface BackgroundSize {
2220
2762
  multiple: boolean;
2221
2763
  previous: string;
@@ -2226,23 +2768,38 @@ interface BackgroundSize {
2226
2768
  mapping: BackgroundSizeMapping;
2227
2769
  }
2228
2770
 
2771
+ /**
2772
+ * @private
2773
+ */
2229
2774
  interface BackgroundSizeMapping {
2230
2775
  "auto auto": string;
2231
2776
  }
2232
2777
 
2778
+ /**
2779
+ * @private
2780
+ */
2233
2781
  interface Prefix {
2234
2782
  typ: string;
2235
2783
  val: string;
2236
2784
  }
2237
2785
 
2786
+ /**
2787
+ * @private
2788
+ */
2238
2789
  interface Separator {
2239
2790
  typ: string;
2240
2791
  }
2241
2792
 
2793
+ /**
2794
+ * @private
2795
+ */
2242
2796
  interface BackgroundPositionClass {
2243
2797
  shorthand: string;
2244
2798
  }
2245
2799
 
2800
+ /**
2801
+ * @private
2802
+ */
2246
2803
  interface Border {
2247
2804
  shorthand: string;
2248
2805
  pattern: string;
@@ -2251,15 +2808,24 @@ interface Border {
2251
2808
  properties: BorderProperties;
2252
2809
  }
2253
2810
 
2811
+ /**
2812
+ * @private
2813
+ */
2254
2814
  interface BorderProperties {
2255
2815
  "border-color": BorderColorClass;
2256
2816
  "border-style": BorderColorClass;
2257
2817
  "border-width": BorderColorClass;
2258
2818
  }
2259
2819
 
2820
+ /**
2821
+ * @private
2822
+ */
2260
2823
  interface BorderColorClass {
2261
2824
  }
2262
2825
 
2826
+ /**
2827
+ * @private
2828
+ */
2263
2829
  interface Font {
2264
2830
  shorthand: string;
2265
2831
  pattern: string;
@@ -2268,6 +2834,9 @@ interface Font {
2268
2834
  properties: FontProperties;
2269
2835
  }
2270
2836
 
2837
+ /**
2838
+ * @private
2839
+ */
2271
2840
  interface FontProperties {
2272
2841
  "font-weight": FontWeight;
2273
2842
  "font-style": PurpleBackgroundAttachment;
@@ -2278,6 +2847,9 @@ interface FontProperties {
2278
2847
  "font-family": FontFamily;
2279
2848
  }
2280
2849
 
2850
+ /**
2851
+ * @private
2852
+ */
2281
2853
  interface FontFamily {
2282
2854
  types: string[];
2283
2855
  default: any[];
@@ -2287,6 +2859,9 @@ interface FontFamily {
2287
2859
  separator: Separator;
2288
2860
  }
2289
2861
 
2862
+ /**
2863
+ * @private
2864
+ */
2290
2865
  interface FontWeight {
2291
2866
  types: string[];
2292
2867
  default: string[];
@@ -2295,15 +2870,24 @@ interface FontWeight {
2295
2870
  mapping: FontWeightMapping;
2296
2871
  }
2297
2872
 
2873
+ /**
2874
+ * @private
2875
+ */
2298
2876
  interface FontWeightConstraints {
2299
2877
  value: Value;
2300
2878
  }
2301
2879
 
2880
+ /**
2881
+ * @private
2882
+ */
2302
2883
  interface Value {
2303
2884
  min: string;
2304
2885
  max: string;
2305
2886
  }
2306
2887
 
2888
+ /**
2889
+ * @private
2890
+ */
2307
2891
  interface FontWeightMapping {
2308
2892
  thin: string;
2309
2893
  hairline: string;
@@ -2324,6 +2908,9 @@ interface FontWeightMapping {
2324
2908
  "ultra black": string;
2325
2909
  }
2326
2910
 
2911
+ /**
2912
+ * @private
2913
+ */
2327
2914
  interface LineHeight {
2328
2915
  types: string[];
2329
2916
  default: string[];
@@ -2332,6 +2919,9 @@ interface LineHeight {
2332
2919
  prefix: Prefix;
2333
2920
  }
2334
2921
 
2922
+ /**
2923
+ * @private
2924
+ */
2335
2925
  interface Outline {
2336
2926
  shorthand: string;
2337
2927
  pattern: string;
@@ -2340,12 +2930,18 @@ interface Outline {
2340
2930
  properties: OutlineProperties;
2341
2931
  }
2342
2932
 
2933
+ /**
2934
+ * @private
2935
+ */
2343
2936
  interface OutlineProperties {
2344
2937
  "outline-color": PurpleBackgroundAttachment;
2345
2938
  "outline-style": PurpleBackgroundAttachment;
2346
2939
  "outline-width": PurpleBackgroundAttachment;
2347
2940
  }
2348
2941
 
2942
+ /**
2943
+ * @private
2944
+ */
2349
2945
  interface PropertiesConfigProperties {
2350
2946
  inset: BorderRadius;
2351
2947
  top: BackgroundPositionClass;
@@ -2384,6 +2980,9 @@ interface PropertiesConfigProperties {
2384
2980
  "border-left-color": BackgroundPositionClass;
2385
2981
  }
2386
2982
 
2983
+ /**
2984
+ * @private
2985
+ */
2387
2986
  interface BorderColor {
2388
2987
  shorthand: string;
2389
2988
  map?: string;
@@ -2392,6 +2991,9 @@ interface BorderColor {
2392
2991
  keywords: string[];
2393
2992
  }
2394
2993
 
2994
+ /**
2995
+ * @private
2996
+ */
2395
2997
  interface BorderRadius {
2396
2998
  shorthand: string;
2397
2999
  properties: string[];
@@ -2401,38 +3003,36 @@ interface BorderRadius {
2401
3003
  keywords: string[];
2402
3004
  }
2403
3005
 
2404
- export declare type WalkerOption = WalkerOptionEnum | Token | null;
3006
+ /**
3007
+ * node walker option
3008
+ */
3009
+ export declare type WalkerOption = WalkerOptionEnum | Token$1 | null;
2405
3010
  /**
2406
3011
  * returned value:
2407
- * - WalkerOptionEnum.Ignore: ignore this node and its children
2408
- * - WalkerOptionEnum.Stop: stop walking the tree
2409
- * - WalkerOptionEnum.Children: walk the children and ignore the node itself
2410
- * - WalkerOptionEnum.IgnoreChildren: walk the node and ignore children
3012
+ * - {@link WalkerOptionEnum.Ignore}: ignore this node and its children
3013
+ * - {@link WalkerOptionEnum.Stop}: stop walking the tree
3014
+ * - {@link WalkerOptionEnum.Children}: walk the children and ignore the current node
3015
+ * - {@link WalkerOptionEnum.IgnoreChildren}: walk the node and ignore children
2411
3016
  */
2412
- export declare type WalkerFilter = (node: AstNode) => WalkerOption;
3017
+ export declare type WalkerFilter = (node: AstNode$1) => WalkerOption;
2413
3018
 
2414
3019
  /**
2415
- * returned value:
2416
- * - 'ignore': ignore this node and its children
2417
- * - 'stop': stop walking the tree
2418
- * - 'children': walk the children and ignore the node itself
2419
- * - 'ignore-children': walk the node and ignore children
3020
+ * filter nod
2420
3021
  */
2421
- export declare type WalkerValueFilter = (node: AstNode | Token, parent?: FunctionToken | ParensToken | BinaryExpressionToken, event?: WalkerValueEvent) => WalkerOption | null;
3022
+ export declare type WalkerValueFilter = (node: AstNode$1 | Token$1, parent?: AstNode$1 | Token$1 | null, event?: WalkerValueEvent) => WalkerOption | null;
2422
3023
 
2423
3024
  export declare interface WalkResult {
2424
- node: AstNode;
3025
+ node: AstNode$1;
2425
3026
  parent?: AstRuleList;
2426
- root?: AstNode;
3027
+ root?: AstNode$1;
2427
3028
  }
2428
3029
 
2429
3030
  export declare interface WalkAttributesResult {
2430
- value: Token;
2431
- previousValue: Token | null;
2432
- nextValue: Token | null;
2433
- root?: AstNode;
2434
- parent: AstNode | Token | null;
2435
- list: Token[] | null;
3031
+ value: Token$1;
3032
+ previousValue: Token$1 | null;
3033
+ nextValue: Token$1 | null;
3034
+ root?: AstNode$1 | Token$1 | null;
3035
+ parent: AstNode$1 | Token$1 | null;
2436
3036
  }
2437
3037
 
2438
3038
  /**
@@ -2456,7 +3056,7 @@ export declare interface ErrorDescription {
2456
3056
  /**
2457
3057
  * error node
2458
3058
  */
2459
- node?: Token | AstNode | null;
3059
+ node?: Token$1 | AstNode$1 | null;
2460
3060
  /**
2461
3061
  * error location
2462
3062
  */
@@ -2491,7 +3091,7 @@ interface ValidationOptions {
2491
3091
  *
2492
3092
  * @private
2493
3093
  */
2494
- visited?: WeakMap<Token, Map<string, Set<ValidationToken>>>;
3094
+ visited?: WeakMap<Token$1, Map<string, Set<ValidationToken>>>;
2495
3095
  /**
2496
3096
  * is optional
2497
3097
  *
@@ -2542,13 +3142,37 @@ interface MinifyOptions {
2542
3142
  */
2543
3143
  nestingRules?: boolean;
2544
3144
  /**
2545
- * expand nested rules
2546
- */
2547
- expandNestingRules?: boolean;
2548
- /**
2549
- * remove duplicate declarations from the same rule
3145
+ * remove duplicate declarations from the same rule. if passed as a string array, duplicated declarations are removed, except for those in the array
3146
+ *
3147
+ *
3148
+ * ```ts
3149
+ *
3150
+ * import {transform} from '@tbela99/css-parser';
3151
+ *
3152
+ * const css = `
3153
+ *
3154
+ * .table {
3155
+ *
3156
+ * width: 100%;
3157
+ * width: calc(100% + 40px);
3158
+ * margin-left: 20px;
3159
+ * margin-left: min(100% , 20px)
3160
+ * }
3161
+ *
3162
+ * `;
3163
+ * const result = await transform(css, {
3164
+ *
3165
+ * beautify: true,
3166
+ * validation: true,
3167
+ * removeDuplicateDeclarations: ['width']
3168
+ * }
3169
+ * );
3170
+ *
3171
+ * console.log(result.code);
3172
+ *
3173
+ * ```
2550
3174
  */
2551
- removeDuplicateDeclarations?: boolean;
3175
+ removeDuplicateDeclarations?: boolean | string[];
2552
3176
  /**
2553
3177
  * compute shorthand properties
2554
3178
  */
@@ -2571,12 +3195,22 @@ interface MinifyOptions {
2571
3195
  * remove empty ast nodes
2572
3196
  */
2573
3197
  removeEmpty?: boolean;
3198
+ /**
3199
+ * remove css prefix
3200
+ */
3201
+ removePrefix?: boolean;
2574
3202
  /**
2575
3203
  * define minification passes.
2576
3204
  */
2577
3205
  pass?: number;
2578
3206
  }
2579
3207
 
3208
+ export declare type LoadResult =
3209
+ Promise<ReadableStream<Uint8Array>>
3210
+ | ReadableStream<Uint8Array>
3211
+ | string
3212
+ | Promise<string>;
3213
+
2580
3214
  /**
2581
3215
  * parser options
2582
3216
  */
@@ -2591,34 +3225,30 @@ export declare interface ParserOptions extends MinifyOptions, MinifyFeatureOptio
2591
3225
  */
2592
3226
  sourcemap?: boolean | 'inline';
2593
3227
  /**
2594
- * remove @charset at-rule
3228
+ * remove at-rule charset
2595
3229
  */
2596
3230
  removeCharset?: boolean;
2597
- /**
2598
- * resolve urls
2599
- */
2600
- resolveUrls?: boolean;
2601
3231
  /**
2602
3232
  * resolve import
2603
3233
  */
2604
3234
  resolveImport?: boolean;
2605
3235
  /**
2606
3236
  * current working directory
2607
- * @ignore
3237
+ *
3238
+ * @internal
2608
3239
  */
2609
3240
  cwd?: string;
2610
3241
  /**
2611
- * remove css prefix
3242
+ * expand nested rules
2612
3243
  */
2613
- removePrefix?: boolean;
3244
+ expandNestingRules?: boolean;
2614
3245
  /**
2615
- * get file or url as stream
3246
+ * url and file loader
2616
3247
  * @param url
2617
3248
  * @param currentUrl
2618
3249
  *
2619
- * @private
2620
3250
  */
2621
- getStream?: (url: string, currentUrl: string) => Promise<ReadableStream<string>>;
3251
+ load?: (url: string, currentUrl: string) => LoadResult;
2622
3252
  /**
2623
3253
  * get directory name
2624
3254
  * @param path
@@ -2627,17 +3257,21 @@ export declare interface ParserOptions extends MinifyOptions, MinifyFeatureOptio
2627
3257
  */
2628
3258
  dirname?: (path: string) => string;
2629
3259
  /**
2630
- * resolve path
3260
+ * resolve urls
3261
+ */
3262
+ resolveUrls?: boolean;
3263
+ /**
3264
+ * url and path resolver
2631
3265
  * @param url
2632
3266
  * @param currentUrl
2633
3267
  * @param currentWorkingDirectory
2634
3268
  *
2635
- * @private
2636
3269
  */
2637
3270
  resolve?: (url: string, currentUrl: string, currentWorkingDirectory?: string) => {
2638
3271
  absolute: string;
2639
3272
  relative: string;
2640
3273
  };
3274
+
2641
3275
  /**
2642
3276
  * node visitor
2643
3277
  * {@link VisitorNodeMap}
@@ -2658,6 +3292,8 @@ export declare interface ParserOptions extends MinifyOptions, MinifyFeatureOptio
2658
3292
  signal?: AbortSignal;
2659
3293
  /**
2660
3294
  * set parent node
3295
+ *
3296
+ * @private
2661
3297
  */
2662
3298
  setParent?: boolean;
2663
3299
  /**
@@ -2665,7 +3301,7 @@ export declare interface ParserOptions extends MinifyOptions, MinifyFeatureOptio
2665
3301
  *
2666
3302
  * @private
2667
3303
  */
2668
- cache?: WeakMap<AstNode, string>;
3304
+ cache?: WeakMap<AstNode$1, string>;
2669
3305
  }
2670
3306
 
2671
3307
  /**
@@ -2678,7 +3314,7 @@ export declare interface MinifyFeatureOptions {
2678
3314
  /**
2679
3315
  * minify features
2680
3316
  *
2681
- * @internal
3317
+ * @private
2682
3318
  */
2683
3319
  features?: MinifyFeature[];
2684
3320
  }
@@ -2695,13 +3331,9 @@ export declare interface MinifyFeature {
2695
3331
  */
2696
3332
  ordering: number;
2697
3333
  /**
2698
- * use in pre process
3334
+ * process mode
2699
3335
  */
2700
- preProcess: boolean;
2701
- /**
2702
- * use in post process
2703
- */
2704
- postProcess: boolean;
3336
+ processMode: FeatureWalkMode;
2705
3337
  /**
2706
3338
  * register feature
2707
3339
  * @param options
@@ -2715,9 +3347,9 @@ export declare interface MinifyFeature {
2715
3347
  * @param context
2716
3348
  * @param mode
2717
3349
  */
2718
- run: (ast: AstRule | AstAtRule, options: ParserOptions, parent: AstRule | AstAtRule | AstRuleStyleSheet, context: {
3350
+ run: (ast: AstRule | AstAtRule, options: ParserOptions, parent: AstRule | AstAtRule | AstStyleSheet, context: {
2719
3351
  [key: string]: any
2720
- }, mode: FeatureWalkMode) => void;
3352
+ }, mode: FeatureWalkMode) => AstNode$1 | null;
2721
3353
  }
2722
3354
 
2723
3355
  /**
@@ -2741,15 +3373,31 @@ export declare interface ResolvedPath {
2741
3373
  export declare interface RenderOptions {
2742
3374
 
2743
3375
  /**
2744
- * minify ast node.
3376
+ * minify css values.
2745
3377
  */
2746
3378
  minify?: boolean;
2747
3379
  /**
2748
3380
  * pretty print css
3381
+ *
3382
+ * ```ts
3383
+ * const result = await transform(css, {beautify: true});
3384
+ * ```
2749
3385
  */
2750
3386
  beautify?: boolean;
2751
3387
  /**
2752
- * remove empty rule lists from the ast
3388
+ * remove empty nodes. empty nodes are removed by default
3389
+ *
3390
+ * ```ts
3391
+ *
3392
+ * const css = `
3393
+ * @supports selector(:-ms-input-placeholder) {
3394
+ *
3395
+ * :-ms-input-placeholder {
3396
+ *
3397
+ * }
3398
+ * }`;
3399
+ * const result = await transform(css, {removeEmpty: false});
3400
+ * ```
2753
3401
  */
2754
3402
  removeEmpty?: boolean;
2755
3403
  /**
@@ -2781,7 +3429,7 @@ export declare interface RenderOptions {
2781
3429
  */
2782
3430
  convertColor?: boolean | ColorType;
2783
3431
  /**
2784
- * ernder the node along with its parents
3432
+ * render the node along with its parents
2785
3433
  */
2786
3434
  withParents?: boolean;
2787
3435
  /**
@@ -2849,7 +3497,7 @@ export declare interface ParseResult {
2849
3497
  /**
2850
3498
  * parsed ast tree
2851
3499
  */
2852
- ast: AstRuleStyleSheet;
3500
+ ast: AstStyleSheet;
2853
3501
  /**
2854
3502
  * parse errors
2855
3503
  */
@@ -2957,7 +3605,7 @@ export declare interface TokenizeResult {
2957
3605
  /**
2958
3606
  * token type hint
2959
3607
  */
2960
- hint?: EnumToken;
3608
+ hint?: EnumToken$1;
2961
3609
  /**
2962
3610
  * token start position
2963
3611
  */
@@ -3023,7 +3671,7 @@ export declare interface VariableScopeInfo {
3023
3671
  /**
3024
3672
  * declaration values
3025
3673
  */
3026
- values: Token[];
3674
+ values: Token$1[];
3027
3675
  }
3028
3676
 
3029
3677
  /**
@@ -3043,7 +3691,8 @@ export declare interface SourceMapObject {
3043
3691
  /**
3044
3692
  * return the directory name of a path
3045
3693
  * @param path
3046
- * @internal
3694
+ *
3695
+ * @private
3047
3696
  */
3048
3697
  declare function dirname(path: string): string;
3049
3698
  /**
@@ -3059,21 +3708,17 @@ declare function resolve(url: string, currentDirectory: string, cwd?: string): {
3059
3708
  relative: string;
3060
3709
  };
3061
3710
 
3062
- /**
3063
- * node module entry point
3064
- * @module node
3065
- */
3066
-
3067
3711
  /**
3068
3712
  * load file or url as stream
3069
3713
  * @param url
3070
3714
  * @param currentFile
3715
+ * @throws Error file not found
3071
3716
  *
3072
3717
  * @private
3073
3718
  */
3074
- declare function getStream(url: string, currentFile?: string): Promise<ReadableStream<string>>;
3719
+ declare function load(url: string, currentFile?: string): Promise<ReadableStream<Uint8Array> | string>;
3075
3720
  /**
3076
- * render ast tree
3721
+ * render the ast tree
3077
3722
  * @param data
3078
3723
  * @param options
3079
3724
  *
@@ -3083,21 +3728,31 @@ declare function getStream(url: string, currentFile?: string): Promise<ReadableS
3083
3728
  *
3084
3729
  * import {render, ColorType} from '@tbela99/css-parser';
3085
3730
  *
3086
- * // remote file
3087
- * let result = render(ast);
3088
- * console.log(result.code);
3731
+ * const css = 'body { color: color(from hsl(0 100% 50%) xyz x y z); }';
3732
+ * const parseResult = await parse(css);
3089
3733
  *
3090
- * // local file
3091
- * result = await parseFile(ast, {beatify: true, convertColor: ColorType.SRGB});
3734
+ * let renderResult = render(parseResult.ast);
3092
3735
  * console.log(result.code);
3736
+ *
3737
+ * // body{color:red}
3738
+ *
3739
+ *
3740
+ * renderResult = render(parseResult.ast, {beautify: true, convertColor: ColorType.SRGB});
3741
+ * console.log(renderResult.code);
3742
+ *
3743
+ * // body {
3744
+ * // color: color(srgb 1 0 0)
3745
+ * // }
3093
3746
  * ```
3094
3747
  */
3095
- declare function render(data: AstNode, options?: RenderOptions): RenderResult;
3748
+ declare function render(data: AstNode$1, options?: RenderOptions): RenderResult;
3096
3749
  /**
3097
3750
  * parse css file
3098
3751
  * @param file url or path
3099
3752
  * @param options
3100
3753
  *
3754
+ * @throws Error file not found
3755
+ *
3101
3756
  * Example:
3102
3757
  *
3103
3758
  * ```ts
@@ -3117,17 +3772,17 @@ declare function parseFile(file: string, options?: ParserOptions): Promise<Parse
3117
3772
  /**
3118
3773
  * parse css
3119
3774
  * @param stream
3120
- * @param opt
3775
+ * @param options
3121
3776
  *
3122
3777
  * Example:
3123
3778
  *
3124
3779
  * ```ts
3125
3780
  *
3126
- * import {transform} from '@tbela99/css-parser';
3781
+ * import {parse} from '@tbela99/css-parser';
3127
3782
  *
3128
3783
  * // css string
3129
- * let result = await transform(css);
3130
- * console.log(result.code);
3784
+ * let result = await parse(css);
3785
+ * console.log(result.ast);
3131
3786
  * ```
3132
3787
  *
3133
3788
  * Example using stream
@@ -3140,29 +3795,31 @@ declare function parseFile(file: string, options?: ParserOptions): Promise<Parse
3140
3795
  * // usage: node index.ts < styles.css or cat styles.css | node index.ts
3141
3796
  *
3142
3797
  * const readableStream = Readable.toWeb(process.stdin);
3143
- * const result = await parse(readableStream, {beautify: true});
3798
+ * let result = await parse(readableStream, {beautify: true});
3144
3799
  *
3145
3800
  * console.log(result.ast);
3146
3801
  * ```
3147
3802
  *
3148
- * Example using fetch
3803
+ * Example using fetch and readable stream
3149
3804
  *
3150
3805
  * ```ts
3151
3806
  *
3152
3807
  * import {parse} from '@tbela99/css-parser';
3153
3808
  *
3154
3809
  * const response = await fetch('https://docs.deno.com/styles.css');
3155
- * result = await parse(response.body, {beautify: true});
3810
+ * const result = await parse(response.body, {beautify: true});
3156
3811
  *
3157
3812
  * console.log(result.ast);
3158
3813
  * ```
3159
3814
  */
3160
- declare function parse(stream: string | ReadableStream<string>, opt?: ParserOptions): Promise<ParseResult>;
3815
+ declare function parse(stream: string | ReadableStream<Uint8Array>, options?: ParserOptions): Promise<ParseResult>;
3161
3816
  /**
3162
3817
  * transform css file
3163
3818
  * @param file url or path
3164
3819
  * @param options
3165
3820
  *
3821
+ * @throws Error file not found
3822
+ *
3166
3823
  * Example:
3167
3824
  *
3168
3825
  * ```ts
@@ -3191,7 +3848,7 @@ declare function transformFile(file: string, options?: TransformOptions): Promis
3191
3848
  * import {transform} from '@tbela99/css-parser';
3192
3849
  *
3193
3850
  * // css string
3194
- * let result = await transform(css);
3851
+ * const result = await transform(css);
3195
3852
  * console.log(result.code);
3196
3853
  * ```
3197
3854
  *
@@ -3222,7 +3879,7 @@ declare function transformFile(file: string, options?: TransformOptions): Promis
3222
3879
  * console.log(result.code);
3223
3880
  * ```
3224
3881
  */
3225
- declare function transform(css: string | ReadableStream<string>, options?: TransformOptions): Promise<TransformResult>;
3882
+ declare function transform(css: string | ReadableStream<Uint8Array>, options?: TransformOptions): Promise<TransformResult>;
3226
3883
 
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 };
3884
+ export { ColorType, EnumToken$1 as EnumToken, FeatureWalkMode, SourceMap, ValidationLevel, WalkerOptionEnum, WalkerValueEvent, convertColor, dirname, expand, isOkLabClose, load, mathFuncs, minify, okLabDistance, parse, parseDeclarations, parseFile, parseString, parseTokens, render, renderToken, resolve, transform, transformFile, transformFunctions, walk, walkValues };
3885
+ export type { AddToken, AngleToken, AstAtRule, AstComment, AstDeclaration, AstInvalidAtRule, AstInvalidDeclaration, AstInvalidRule, AstKeyFrameRule, AstKeyframesAtRule, AstKeyframesRule, AstNode$1 as AstNode, AstRule, AstRuleList, AstStyleSheet, 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, GenericVisitorAstNodeHandlerMap, GenericVisitorHandler, GenericVisitorResult, GreaterThanOrEqualToken, GreaterThanToken, GridTemplateFuncToken, HashToken, IdentListToken, IdentToken, ImportantToken, IncludeMatchToken, InvalidAttrToken, InvalidClassSelectorToken, LengthToken, LessThanOrEqualToken, LessThanToken, LineHeight, ListToken, LiteralToken, LoadResult, 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$1 as Token, TokenizeResult, TransformOptions, TransformResult, UnaryExpression, UnaryExpressionNode, UnclosedStringToken, UniversalSelectorToken, UrlToken, ValidationConfiguration, ValidationOptions, ValidationResult, ValidationSelectorOptions, ValidationSyntaxNode, ValidationSyntaxResult, Value, ValueVisitorHandler, VariableScopeInfo, VisitorEventType, VisitorNodeMap, WalkAttributesResult, WalkResult, WalkerFilter, WalkerOption, WalkerValueFilter, WhitespaceToken };