@tbela99/css-parser
Version:
CSS parser, minifier and validator for node and the browser
1,417 lines (1,415 loc) • 1.34 MB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.CSSParser = {}));
})(this, (function (exports) { 'use strict';
/**
* Syntax validation enum
*/
var SyntaxValidationResult;
(function (SyntaxValidationResult) {
/** valid syntax */
SyntaxValidationResult[SyntaxValidationResult["Valid"] = 0] = "Valid";
/** drop invalid syntax */
SyntaxValidationResult[SyntaxValidationResult["Drop"] = 1] = "Drop";
/** preserve unknown at-rules, declarations and pseudo-classes */
SyntaxValidationResult[SyntaxValidationResult["Lenient"] = 2] = "Lenient";
})(SyntaxValidationResult || (SyntaxValidationResult = {}));
/**
* Enum of node statuses
*/
exports.EnumAstNodeStatus = void 0;
(function (EnumAstNodeStatus) {
/**
* Node passed validation
*/
EnumAstNodeStatus[EnumAstNodeStatus["Validated"] = 0] = "Validated";
/**
* Node is invalid
*/
EnumAstNodeStatus[EnumAstNodeStatus["Invalid"] = 1] = "Invalid";
/**
* node is not validated
*/
EnumAstNodeStatus[EnumAstNodeStatus["Unvalidated"] = 2] = "Unvalidated";
/**
* Node did not pass validation, but is preserved.
*/
EnumAstNodeStatus[EnumAstNodeStatus["ValidationFailed"] = 3] = "ValidationFailed";
/**
* Parsing the node is not supported yet or the node syntax definition does not exist.
*/
EnumAstNodeStatus[EnumAstNodeStatus["Unknown"] = 4] = "Unknown";
/**
* Failed to parse the node.
*/
EnumAstNodeStatus[EnumAstNodeStatus["Unparsed"] = 5] = "Unparsed";
/**
* Node is disallowed in the context
*/
EnumAstNodeStatus[EnumAstNodeStatus["Disallowed"] = 6] = "Disallowed";
/**
* Node is malformed
*/
EnumAstNodeStatus[EnumAstNodeStatus["Malformed"] = 7] = "Malformed";
})(exports.EnumAstNodeStatus || (exports.EnumAstNodeStatus = {}));
/**
* Enum of validation levels
* @deprecated
*/
exports.ValidationLevel = void 0;
(function (ValidationLevel) {
/**
* disable validation
*/
ValidationLevel[ValidationLevel["None"] = 0] = "None";
/**
* validate selectors
*/
ValidationLevel[ValidationLevel["Selector"] = 1] = "Selector";
/**
* validate at-rules
*/
ValidationLevel[ValidationLevel["AtRule"] = 2] = "AtRule";
/**
* validate declarations
*/
ValidationLevel[ValidationLevel["Declaration"] = 4] = "Declaration";
/**
* validate selectors and at-rules
*/
ValidationLevel[ValidationLevel["Default"] = 3] = "Default";
/**
* validate selectors, at-rules and declarations
*/
ValidationLevel[ValidationLevel["All"] = 7] = "All";
/**
* Report only. Apply validation and report nodes that are marked as invalid
*/
ValidationLevel[ValidationLevel["ReportOnly"] = 8] = "ReportOnly";
})(exports.ValidationLevel || (exports.ValidationLevel = {}));
/**
* Enum of all token types
*/
exports.EnumToken = void 0;
(function (EnumToken) {
/**
* comment token
*/
EnumToken[EnumToken["CommentTokenType"] = 0] = "CommentTokenType";
/**
* cdata section token
*/
EnumToken[EnumToken["CDOCOMMTokenType"] = 1] = "CDOCOMMTokenType";
/**
* style sheet node type
*/
EnumToken[EnumToken["StyleSheetNodeType"] = 2] = "StyleSheetNodeType";
/**
* at-rule node type
*/
EnumToken[EnumToken["AtRuleNodeType"] = 3] = "AtRuleNodeType";
/**
* rule node type
*/
EnumToken[EnumToken["RuleNodeType"] = 4] = "RuleNodeType";
/**
* declaration node type
*/
EnumToken[EnumToken["DeclarationNodeType"] = 5] = "DeclarationNodeType";
/**
* literal token type
*/
EnumToken[EnumToken["LiteralTokenType"] = 6] = "LiteralTokenType";
/**
* identifier token type
*/
EnumToken[EnumToken["IdenTokenType"] = 7] = "IdenTokenType";
/**
* dashed identifier token type
*/
EnumToken[EnumToken["DashedIdenTokenType"] = 8] = "DashedIdenTokenType";
/**
* comma token type
*/
EnumToken[EnumToken["CommaTokenType"] = 9] = "CommaTokenType";
/**
* colon token type
*/
EnumToken[EnumToken["ColonTokenType"] = 10] = "ColonTokenType";
/**
* semicolon token type
*/
EnumToken[EnumToken["SemiColonTokenType"] = 11] = "SemiColonTokenType";
/**
* number token type
*/
EnumToken[EnumToken["NumberTokenType"] = 12] = "NumberTokenType";
/**
* at-rule token type
*/
EnumToken[EnumToken["AtRuleTokenType"] = 13] = "AtRuleTokenType";
/**
* percentage token type
*/
EnumToken[EnumToken["PercentageTokenType"] = 14] = "PercentageTokenType";
/**
* function token type
*/
EnumToken[EnumToken["FunctionTokenType"] = 15] = "FunctionTokenType";
/**
* timeline function token type
*/
EnumToken[EnumToken["TimelineFunctionTokenType"] = 16] = "TimelineFunctionTokenType";
/**
* timing function token type
*/
EnumToken[EnumToken["TimingFunctionTokenType"] = 17] = "TimingFunctionTokenType";
/**
* url function token type
*/
EnumToken[EnumToken["UrlFunctionTokenType"] = 18] = "UrlFunctionTokenType";
/**
* image function token type
*/
EnumToken[EnumToken["ImageFunctionTokenType"] = 19] = "ImageFunctionTokenType";
/**
* string token type
*/
EnumToken[EnumToken["StringTokenType"] = 20] = "StringTokenType";
/**
* unclosed string token type
*/
EnumToken[EnumToken["UnclosedStringTokenType"] = 21] = "UnclosedStringTokenType";
/**
* dimension token type
*/
EnumToken[EnumToken["DimensionTokenType"] = 22] = "DimensionTokenType";
/**
* length token type
*/
EnumToken[EnumToken["LengthTokenType"] = 23] = "LengthTokenType";
/**
* angle token type
*/
EnumToken[EnumToken["AngleTokenType"] = 24] = "AngleTokenType";
/**
* time token type
*/
EnumToken[EnumToken["TimeTokenType"] = 25] = "TimeTokenType";
/**
* frequency token type
*/
EnumToken[EnumToken["FrequencyTokenType"] = 26] = "FrequencyTokenType";
/**
* resolution token type
*/
EnumToken[EnumToken["ResolutionTokenType"] = 27] = "ResolutionTokenType";
/**
* hash token type
*/
EnumToken[EnumToken["HashTokenType"] = 28] = "HashTokenType";
/**
* block start token type
*/
EnumToken[EnumToken["BlockStartTokenType"] = 29] = "BlockStartTokenType";
/**
* block end token type
*/
EnumToken[EnumToken["BlockEndTokenType"] = 30] = "BlockEndTokenType";
/**
* attribute start token type
*/
EnumToken[EnumToken["AttrStartTokenType"] = 31] = "AttrStartTokenType";
/**
* attribute end token type
*/
EnumToken[EnumToken["AttrEndTokenType"] = 32] = "AttrEndTokenType";
/**
* start parentheses token type
*/
EnumToken[EnumToken["StartParensTokenType"] = 33] = "StartParensTokenType";
/**
* end parentheses token type
*/
EnumToken[EnumToken["EndParensTokenType"] = 34] = "EndParensTokenType";
/**
* parentheses token type
*/
EnumToken[EnumToken["ParensTokenType"] = 35] = "ParensTokenType";
/**
* whitespace token type
*/
EnumToken[EnumToken["WhitespaceTokenType"] = 36] = "WhitespaceTokenType";
/**
* include match token type
*/
EnumToken[EnumToken["IncludeMatchTokenType"] = 37] = "IncludeMatchTokenType";
/**
* dash match token type
*/
EnumToken[EnumToken["DashMatchTokenType"] = 38] = "DashMatchTokenType";
/**
* equal match token type
*/
EnumToken[EnumToken["EqualMatchTokenType"] = 39] = "EqualMatchTokenType";
/**
* less than token type
*/
EnumToken[EnumToken["LtTokenType"] = 40] = "LtTokenType";
/**
* less than or equal to token type
*/
EnumToken[EnumToken["LteTokenType"] = 41] = "LteTokenType";
/**
* greater than token type
*/
EnumToken[EnumToken["GtTokenType"] = 42] = "GtTokenType";
/**
* greater than or equal to token type
*/
EnumToken[EnumToken["GteTokenType"] = 43] = "GteTokenType";
/**
* pseudo-class token type
*/
EnumToken[EnumToken["PseudoClassTokenType"] = 44] = "PseudoClassTokenType";
/**
* pseudo-class function token type
*/
EnumToken[EnumToken["PseudoClassFuncTokenType"] = 45] = "PseudoClassFuncTokenType";
/**
* delimiter token type
*/
EnumToken[EnumToken["DelimTokenType"] = 46] = "DelimTokenType";
/**
* URL token type
*/
EnumToken[EnumToken["UrlTokenTokenType"] = 47] = "UrlTokenTokenType";
/**
* end of file token type
*/
EnumToken[EnumToken["EOFTokenType"] = 48] = "EOFTokenType";
/**
* important token type
*/
EnumToken[EnumToken["ImportantTokenType"] = 49] = "ImportantTokenType";
/**
* color token type
*/
EnumToken[EnumToken["ColorTokenType"] = 50] = "ColorTokenType";
/**
* attribute token type
*/
EnumToken[EnumToken["AttrTokenType"] = 51] = "AttrTokenType";
/**
* bad comment token type
*/
EnumToken[EnumToken["BadCommentTokenType"] = 52] = "BadCommentTokenType";
/**
* bad cdo token type
*/
EnumToken[EnumToken["BadCdoTokenType"] = 53] = "BadCdoTokenType";
/**
* bad URL token type
*/
EnumToken[EnumToken["BadUrlTokenType"] = 54] = "BadUrlTokenType";
/**
* bad string token type
*/
EnumToken[EnumToken["BadStringTokenType"] = 55] = "BadStringTokenType";
/**
* binary expression token type
*/
EnumToken[EnumToken["BinaryExpressionTokenType"] = 56] = "BinaryExpressionTokenType";
/**
* unary expression token type
*/
EnumToken[EnumToken["UnaryExpressionTokenType"] = 57] = "UnaryExpressionTokenType";
/**
* flex token type
*/
EnumToken[EnumToken["FlexTokenType"] = 58] = "FlexTokenType";
/**
* token list token type
*/
EnumToken[EnumToken["ListToken"] = 59] = "ListToken";
/* arithmetic tokens */
/**
* addition token type
*/
EnumToken[EnumToken["Add"] = 60] = "Add";
/**
* multiplication token type
*/
EnumToken[EnumToken["Mul"] = 61] = "Mul";
/**
* division token type
*/
EnumToken[EnumToken["Div"] = 62] = "Div";
/**
* subtraction token type
*/
EnumToken[EnumToken["Sub"] = 63] = "Sub";
/* new tokens */
/**
* column combinator token type
*/
EnumToken[EnumToken["ColumnCombinatorTokenType"] = 64] = "ColumnCombinatorTokenType";
/**
* contain match token type
*/
EnumToken[EnumToken["ContainMatchTokenType"] = 65] = "ContainMatchTokenType";
/**
* start match token type
*/
EnumToken[EnumToken["StartMatchTokenType"] = 66] = "StartMatchTokenType";
/**
* end match token type
*/
EnumToken[EnumToken["EndMatchTokenType"] = 67] = "EndMatchTokenType";
/**
* match expression token type
*/
EnumToken[EnumToken["MatchExpressionTokenType"] = 68] = "MatchExpressionTokenType";
/**
* namespace attribute token type
*/
EnumToken[EnumToken["NameSpaceAttributeTokenType"] = 69] = "NameSpaceAttributeTokenType";
/**
* fraction token type
*/
EnumToken[EnumToken["FractionTokenType"] = 70] = "FractionTokenType";
/**
* identifier list token type
*/
EnumToken[EnumToken["IdenListTokenType"] = 71] = "IdenListTokenType";
/**
* grid template function token type
*/
EnumToken[EnumToken["GridTemplateFuncTokenType"] = 72] = "GridTemplateFuncTokenType";
/**
* keyframe rule node type
*/
EnumToken[EnumToken["KeyFramesRuleNodeType"] = 73] = "KeyFramesRuleNodeType";
/**
* class selector token type
*/
EnumToken[EnumToken["ClassSelectorTokenType"] = 74] = "ClassSelectorTokenType";
/**
* universal selector token type
*/
EnumToken[EnumToken["UniversalSelectorTokenType"] = 75] = "UniversalSelectorTokenType";
/**
* child combinator token type
*/
EnumToken[EnumToken["ChildCombinatorTokenType"] = 76] = "ChildCombinatorTokenType";
/**
* descendant combinator token type
*/
EnumToken[EnumToken["DescendantCombinatorTokenType"] = 77] = "DescendantCombinatorTokenType";
/**
* next sibling combinator token type
*/
EnumToken[EnumToken["NextSiblingCombinatorTokenType"] = 78] = "NextSiblingCombinatorTokenType";
/**
* subsequent sibling combinator token type
*/
EnumToken[EnumToken["SubsequentSiblingCombinatorTokenType"] = 79] = "SubsequentSiblingCombinatorTokenType";
/**
* nesting selector token type
*/
EnumToken[EnumToken["NestingSelectorTokenType"] = 80] = "NestingSelectorTokenType";
/**
* Invalid rule token type
* @deprecated
*/
EnumToken[EnumToken["InvalidRuleNodeType"] = 81] = "InvalidRuleNodeType";
/**
* invalid class selector token type
*/
EnumToken[EnumToken["InvalidClassSelectorTokenType"] = 82] = "InvalidClassSelectorTokenType";
/**
* invalid attribute token type
*/
EnumToken[EnumToken["InvalidAttrTokenType"] = 83] = "InvalidAttrTokenType";
/**
* Invalid at rule token type
* @deprecated
*/
EnumToken[EnumToken["InvalidAtRuleNodeType"] = 84] = "InvalidAtRuleNodeType";
/**
* media query condition token type
*/
EnumToken[EnumToken["MediaQueryConditionTokenType"] = 85] = "MediaQueryConditionTokenType";
/**
* media feature token type
*/
EnumToken[EnumToken["MediaFeatureTokenType"] = 86] = "MediaFeatureTokenType";
/**
* media feature only token type
*/
EnumToken[EnumToken["OnlyTokenType"] = 87] = "OnlyTokenType";
/**
* media feature not token type
*/
EnumToken[EnumToken["NotTokenType"] = 88] = "NotTokenType";
/**
* media feature and token type
*/
EnumToken[EnumToken["AndTokenType"] = 89] = "AndTokenType";
/**
* media feature or token type
*/
EnumToken[EnumToken["OrTokenType"] = 90] = "OrTokenType";
/**
* pseudo page token type
*/
EnumToken[EnumToken["PseudoPageTokenType"] = 91] = "PseudoPageTokenType";
/**
* pseudo element token type
*/
EnumToken[EnumToken["PseudoElementTokenType"] = 92] = "PseudoElementTokenType";
/**
* keyframe at rule node type
*/
EnumToken[EnumToken["KeyframesAtRuleNodeType"] = 93] = "KeyframesAtRuleNodeType";
/**
* invalid declaration node type.
* @deprecated
*/
EnumToken[EnumToken["InvalidDeclarationNodeType"] = 94] = "InvalidDeclarationNodeType";
/* css module nodes */
/**
* composes token node type
*/
EnumToken[EnumToken["ComposesSelectorNodeType"] = 95] = "ComposesSelectorNodeType";
/**
* css variable token type
*/
EnumToken[EnumToken["CssVariableTokenType"] = 96] = "CssVariableTokenType";
/**
* css variable import token type
*/
EnumToken[EnumToken["CssVariableImportTokenType"] = 97] = "CssVariableImportTokenType";
/**
* css variable declaration map token type
*/
EnumToken[EnumToken["CssVariableDeclarationMapTokenType"] = 98] = "CssVariableDeclarationMapTokenType";
/**
* media range query token type
*/
EnumToken[EnumToken["MediaRangeQueryTokenType"] = 99] = "MediaRangeQueryTokenType";
/**
* invalid media query token type
*/
EnumToken[EnumToken["InvalidMediaQueryTokenType"] = 100] = "InvalidMediaQueryTokenType";
/**
* supports query condition token type
*/
EnumToken[EnumToken["SupportsQueryConditionTokenType"] = 101] = "SupportsQueryConditionTokenType";
/**
* supports query unary condition token type
*/
EnumToken[EnumToken["SupportsQueryUnaryConditionTokenType"] = 102] = "SupportsQueryUnaryConditionTokenType";
/**
* when else query condition token type
*/
EnumToken[EnumToken["WhenElseQueryConditionTokenType"] = 103] = "WhenElseQueryConditionTokenType";
/**
* when else query unary condition token type
*/
EnumToken[EnumToken["WhenElseUnaryConditionTokenType"] = 104] = "WhenElseUnaryConditionTokenType";
/**
* container style range token type
*/
EnumToken[EnumToken["ContainerStyleRangeTokenType"] = 105] = "ContainerStyleRangeTokenType";
/**
* '*'
*/
EnumToken[EnumToken["Star"] = 106] = "Star";
/**
* '+'
*/
EnumToken[EnumToken["Plus"] = 107] = "Plus";
/**
* '~'
*/
EnumToken[EnumToken["Tilda"] = 108] = "Tilda";
/**
* '|'
*/
EnumToken[EnumToken["Pipe"] = 109] = "Pipe";
/**
* '::'
*/
EnumToken[EnumToken["DoubleColonTokenType"] = 110] = "DoubleColonTokenType";
/**
* math function token type such as'calc(' etc.
*/
EnumToken[EnumToken["MathFunctionTokenType"] = 111] = "MathFunctionTokenType";
/**
* transform function token type such as 'translate(' etc.
*/
EnumToken[EnumToken["TransformFunctionTokenType"] = 112] = "TransformFunctionTokenType";
/**
* when function token type such as 'supports(' etc.
*/
EnumToken[EnumToken["WhenElseFunctionTokenType"] = 113] = "WhenElseFunctionTokenType";
/**
* general enclosed function token type 'font-tech(' etc.
*/
EnumToken[EnumToken["GeneralEnclosedFunctionTokenType"] = 114] = "GeneralEnclosedFunctionTokenType";
/**
* supports function token type such as 'at-rule('
*/
EnumToken[EnumToken["SupportsFunctionTokenType"] = 115] = "SupportsFunctionTokenType";
/**
* container function token type such as 'style(' or 'scroll-state('
*/
EnumToken[EnumToken["ContainerFunctionTokenType"] = 116] = "ContainerFunctionTokenType";
/**
* unrecognized node token type
*/
EnumToken[EnumToken["RawNodeTokenType"] = 117] = "RawNodeTokenType";
/**
* media query boolean token type
* at-rule media not ()
* at-rule media only ()
*/
EnumToken[EnumToken["MediaQueryUnaryFeatureTokenType"] = 118] = "MediaQueryUnaryFeatureTokenType";
/**
* grid template function token type such as 'minmax('
*/
EnumToken[EnumToken["GridTemplateFuncTokenDefType"] = 119] = "GridTemplateFuncTokenDefType";
/**
* image function token type such as 'image(' etc.
*/
EnumToken[EnumToken["ImageFunctionTokenDefType"] = 120] = "ImageFunctionTokenDefType";
/**
* function token type such as 'view(' etc.
*/
EnumToken[EnumToken["TimelineFunctionTokenDefType"] = 121] = "TimelineFunctionTokenDefType";
/**
* function token type
*/
EnumToken[EnumToken["FunctionTokenDefType"] = 122] = "FunctionTokenDefType";
/**
* timing function token type such as 'linear(' etc.
*/
EnumToken[EnumToken["TimingFunctionTokenDefType"] = 123] = "TimingFunctionTokenDefType";
/**
* color function token type such as 'rgb(' etc.
*/
EnumToken[EnumToken["ColorFunctionTokenDefType"] = 124] = "ColorFunctionTokenDefType";
/**
* math function token type such as 'calc(' etc.
*/
EnumToken[EnumToken["MathFunctionTokenDefType"] = 125] = "MathFunctionTokenDefType";
/**
* container function token type such as 'style(' or 'scroll-state('
*/
EnumToken[EnumToken["ContainerFunctionTokenDefType"] = 126] = "ContainerFunctionTokenDefType";
/**
* url function token type 'url('
*/
EnumToken[EnumToken["UrlFunctionTokenDefType"] = 127] = "UrlFunctionTokenDefType";
/**
* pseudo-class function token type
*/
EnumToken[EnumToken["PseudoClassFunctionTokenDefType"] = 128] = "PseudoClassFunctionTokenDefType";
/**
* transform function token type such as 'translate(' etc.
*/
EnumToken[EnumToken["TransformFunctionTokenDefType"] = 129] = "TransformFunctionTokenDefType";
/**
* when function token type such as 'supports(' or 'media('
*/
EnumToken[EnumToken["WhenElseFunctionTokenDefType"] = 130] = "WhenElseFunctionTokenDefType";
/**
* general enclosed function token type 'font-tech(' etc.
*/
EnumToken[EnumToken["GeneralEnclosedFunctionTokenDefType"] = 131] = "GeneralEnclosedFunctionTokenDefType";
/**
* supports function token type 'font-tech('
*/
EnumToken[EnumToken["SupportsFunctionTokenDefType"] = 132] = "SupportsFunctionTokenDefType";
/**
* CDOCOMMTokenType not allowed in this context
*/
EnumToken[EnumToken["InvalidCommentTokenType"] = 133] = "InvalidCommentTokenType";
/**
* custom function token type '--function-name('
*/
EnumToken[EnumToken["CustomFunctionTokenDefType"] = 134] = "CustomFunctionTokenDefType";
/**
* custom function token type
*/
EnumToken[EnumToken["CustomFunctionTokenType"] = 135] = "CustomFunctionTokenType";
/**
* function tokens such as 'var(', 'env(', 'if(')
*/
EnumToken[EnumToken["WildCardFunctionTokenDefType"] = 136] = "WildCardFunctionTokenDefType";
/**
* function such as 'var()', 'env()', 'if()'
*/
EnumToken[EnumToken["WildCardFunctionTokenType"] = 137] = "WildCardFunctionTokenType";
/**
* if condition token
*/
EnumToken[EnumToken["IfConditionTokenType"] = 138] = "IfConditionTokenType";
/**
* if-Else condition token
*/
EnumToken[EnumToken["IfElseConditionTokenType"] = 139] = "IfElseConditionTokenType";
/**
* wrapped values token type like {Arial, sans-serif}
*/
EnumToken[EnumToken["WrappedValuesTokenType"] = 140] = "WrappedValuesTokenType";
/* aliases */
/**
* alias for time token type
*/
EnumToken[EnumToken["Time"] = 25] = "Time";
/**
* alias for identifier token type
*/
EnumToken[EnumToken["Iden"] = 7] = "Iden";
/**
* alias for end of file token type
*/
EnumToken[EnumToken["EOF"] = 48] = "EOF";
/**
* alias for hash token type
*/
EnumToken[EnumToken["Hash"] = 28] = "Hash";
/**
* alias for flex token type
*/
EnumToken[EnumToken["Flex"] = 58] = "Flex";
/**
* alias for angle token type
*/
EnumToken[EnumToken["Angle"] = 24] = "Angle";
/**
* alias for color token type
*/
EnumToken[EnumToken["Color"] = 50] = "Color";
/**
* alias for comma token type
*/
EnumToken[EnumToken["Comma"] = 9] = "Comma";
/**
* alias for string token type
*/
EnumToken[EnumToken["String"] = 20] = "String";
/**
* alias for length token type
*/
EnumToken[EnumToken["Length"] = 23] = "Length";
/**
* alias for number token type
*/
EnumToken[EnumToken["Number"] = 12] = "Number";
/**
* alias for percentage token type
*/
EnumToken[EnumToken["Perc"] = 14] = "Perc";
/**
* alias for literal token type
*/
EnumToken[EnumToken["Literal"] = 6] = "Literal";
/**
* alias for comment token type
*/
EnumToken[EnumToken["Comment"] = 0] = "Comment";
/**
* alias for url function token type
*/
EnumToken[EnumToken["UrlFunc"] = 18] = "UrlFunc";
/**
* alias for dimension token type
*/
EnumToken[EnumToken["Dimension"] = 22] = "Dimension";
/**
* alias for frequency token type
*/
EnumToken[EnumToken["Frequency"] = 26] = "Frequency";
/**
* alias for resolution token type
*/
EnumToken[EnumToken["Resolution"] = 27] = "Resolution";
/**
* alias for whitespace token type
*/
EnumToken[EnumToken["Whitespace"] = 36] = "Whitespace";
/**
* alias for identifier list token type
*/
EnumToken[EnumToken["IdenList"] = 71] = "IdenList";
/**
* alias for dashed identifier token type
*/
EnumToken[EnumToken["DashedIden"] = 8] = "DashedIden";
/**
* alias for grid template function token type
*/
EnumToken[EnumToken["GridTemplateFunc"] = 72] = "GridTemplateFunc";
/**
* alias for image function token type
*/
EnumToken[EnumToken["ImageFunc"] = 19] = "ImageFunc";
/**
* alias for comment node type
*/
EnumToken[EnumToken["CommentNodeType"] = 0] = "CommentNodeType";
/**
* alias for cdata section node type
*/
EnumToken[EnumToken["CDOCOMMNodeType"] = 1] = "CDOCOMMNodeType";
/**
* alias for timing function token type
*/
EnumToken[EnumToken["TimingFunction"] = 17] = "TimingFunction";
/**
* alias for timeline function token type
*/
EnumToken[EnumToken["TimelineFunction"] = 16] = "TimelineFunction";
})(exports.EnumToken || (exports.EnumToken = {}));
/**
* Supported color types enum
*/
exports.ColorType = void 0;
(function (ColorType) {
/**
* deprecated system colors
*/
ColorType[ColorType["SYS"] = 0] = "SYS";
/**
* deprecated system colors
*/
ColorType[ColorType["DPSYS"] = 1] = "DPSYS";
/**
* named colors
*/
ColorType[ColorType["LIT"] = 2] = "LIT";
/**
* colors as hex values
*/
ColorType[ColorType["HEX"] = 3] = "HEX";
/**
* colors as rgb values
*/
ColorType[ColorType["RGBA"] = 4] = "RGBA";
/**
* colors using rgb
*/
ColorType[ColorType["HSLA"] = 5] = "HSLA";
/**
* colors using hwb
*/
ColorType[ColorType["HWB"] = 6] = "HWB";
/**
* colors using cmyk
*/
ColorType[ColorType["CMYK"] = 7] = "CMYK";
/**
* colors using oklab
* */
ColorType[ColorType["OKLAB"] = 8] = "OKLAB";
/**
* colors using oklch
* */
ColorType[ColorType["OKLCH"] = 9] = "OKLCH";
/**
* colors using lab
*/
ColorType[ColorType["LAB"] = 10] = "LAB";
/**
* colors using lch
*/
ColorType[ColorType["LCH"] = 11] = "LCH";
/**
* colors using color() function
*/
ColorType[ColorType["COLOR"] = 12] = "COLOR";
/**
* color using srgb
*/
ColorType[ColorType["SRGB"] = 13] = "SRGB";
/**
* color using prophoto-rgb
*/
ColorType[ColorType["PROPHOTO_RGB"] = 14] = "PROPHOTO_RGB";
/**
* color using a98-rgb
*/
ColorType[ColorType["A98_RGB"] = 15] = "A98_RGB";
/**
* color using rec2020
*/
ColorType[ColorType["REC2020"] = 16] = "REC2020";
/**
* color using display-p3
*/
ColorType[ColorType["DISPLAY_P3"] = 17] = "DISPLAY_P3";
/**
* color using srgb-linear
*/
ColorType[ColorType["SRGB_LINEAR"] = 18] = "SRGB_LINEAR";
/**
* color using xyz-d50
*/
ColorType[ColorType["XYZ_D50"] = 19] = "XYZ_D50";
/**
* color using xyz-d65
*/
ColorType[ColorType["XYZ_D65"] = 20] = "XYZ_D65";
/**
* light-dark() color function
*/
ColorType[ColorType["LIGHT_DARK"] = 21] = "LIGHT_DARK";
/**
* color-mix() color function
*/
ColorType[ColorType["COLOR_MIX"] = 22] = "COLOR_MIX";
/**
* non-standard color
*/
ColorType[ColorType["NON_STD"] = 23] = "NON_STD";
/**
* custom color
*/
ColorType[ColorType["CUSTOM_COLOR"] = 24] = "CUSTOM_COLOR";
/**
* alpha() color function
*/
ColorType[ColorType["ALPHA"] = 25] = "ALPHA";
/**
* color using display-p3-linear
*/
ColorType[ColorType["DISPLAY_P3_LINEAR"] = 26] = "DISPLAY_P3_LINEAR";
/**
* alias for rgba
*/
ColorType[ColorType["RGB"] = 4] = "RGB";
/**
* alias for hsl
*/
ColorType[ColorType["HSL"] = 5] = "HSL";
/**
* alias for xyz-d65
*/
ColorType[ColorType["XYZ"] = 20] = "XYZ";
/**
* alias for cmyk
*/
ColorType[ColorType["DEVICE_CMYK"] = 7] = "DEVICE_CMYK";
})(exports.ColorType || (exports.ColorType = {}));
/**
* Supported module case transform
*/
exports.ModuleCaseTransformEnum = void 0;
(function (ModuleCaseTransformEnum) {
/**
* export class names as-is
*/
ModuleCaseTransformEnum[ModuleCaseTransformEnum["IgnoreCase"] = 1] = "IgnoreCase";
/**
* transform mapping key name to camel case
*/
ModuleCaseTransformEnum[ModuleCaseTransformEnum["CamelCase"] = 2] = "CamelCase";
/**
* transform class names and mapping key name to camel case
*/
ModuleCaseTransformEnum[ModuleCaseTransformEnum["CamelCaseOnly"] = 4] = "CamelCaseOnly";
/**
* transform mapping key name to dash case
*/
ModuleCaseTransformEnum[ModuleCaseTransformEnum["DashCase"] = 8] = "DashCase";
/**
* transform class names and mapping key name to dash case
*/
ModuleCaseTransformEnum[ModuleCaseTransformEnum["DashCaseOnly"] = 16] = "DashCaseOnly";
})(exports.ModuleCaseTransformEnum || (exports.ModuleCaseTransformEnum = {}));
/**
* Supported module scope
*/
exports.ModuleScopeEnumOptions = void 0;
(function (ModuleScopeEnumOptions) {
/**
* use the global scope
*/
ModuleScopeEnumOptions[ModuleScopeEnumOptions["Global"] = 32] = "Global";
/**
* use the local scope
*/
ModuleScopeEnumOptions[ModuleScopeEnumOptions["Local"] = 64] = "Local";
/**
* do not allow selector without an id or class
*/
ModuleScopeEnumOptions[ModuleScopeEnumOptions["Pure"] = 128] = "Pure";
/**
* export using ICSS module format
*/
ModuleScopeEnumOptions[ModuleScopeEnumOptions["ICSS"] = 256] = "ICSS";
/**
* use the shortest name possible. pattern is ignored.
* it will produce names such as
*
* ```css
* .a {
* content: 'a';
* }
*
* .b {
* content: 'b';
* }
*
* .c {
* content: 'c';
* }
* ...
* ```
*/
ModuleScopeEnumOptions[ModuleScopeEnumOptions["Shortest"] = 512] = "Shortest";
})(exports.ModuleScopeEnumOptions || (exports.ModuleScopeEnumOptions = {}));
// https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Styling_basics/Values_and_units#absolute_length_units
/**
* Convert length to px
* @param value
* @returns
*/
function length2Px(value) {
let result = null;
if (value.typ == exports.EnumToken.NumberTokenType) {
result = +value.val;
}
else {
switch (value.unit) {
case "cm":
// @ts-ignore
result = value.val * 37.8;
break;
case "mm":
// @ts-ignore
result = value.val * 3.78;
break;
case "Q":
// @ts-ignore
result = (value.val * 37.8) / 40;
break;
case "in":
// @ts-ignore
result = value.val / 96;
break;
case "pc":
// @ts-ignore
result = value.val / 16;
break;
case "pt":
// @ts-ignore
result = (value.val * 4) / 3;
break;
case "px":
result = +value.val;
break;
}
}
return isNaN(result) ? null : result;
}
/**
* minify number
* @param val
*/
function minifyNumber(val) {
val = String(val);
if (val === "0") {
return "0";
}
const chr = val.charAt(0);
if (chr == "-") {
const slice = val.slice(0, 2);
if (slice == "-0") {
return val.length == 2 ? "0" : "-" + val.slice(2);
}
}
if (chr == "0") {
return val.slice(1);
}
return val;
}
var declarations = {
"-ms-accelerator": {
syntax: "false | true"
},
"-ms-block-progression": {
syntax: "tb | rl | bt | lr"
},
"-ms-content-zoom-chaining": {
syntax: "none | chained"
},
"-ms-content-zoom-limit": {
syntax: "<'-ms-content-zoom-limit-min'> <'-ms-content-zoom-limit-max'>"
},
"-ms-content-zoom-limit-max": {
syntax: "<percentage>"
},
"-ms-content-zoom-limit-min": {
syntax: "<percentage>"
},
"-ms-content-zoom-snap": {
syntax: "<'-ms-content-zoom-snap-type'> || <'-ms-content-zoom-snap-points'>"
},
"-ms-content-zoom-snap-points": {
syntax: "snapInterval( <percentage>, <percentage> ) | snapList( <percentage># )"
},
"-ms-content-zoom-snap-type": {
syntax: "none | proximity | mandatory"
},
"-ms-content-zooming": {
syntax: "none | zoom"
},
"-ms-filter": {
syntax: "<string>"
},
"-ms-flow-from": {
syntax: "[ none | <custom-ident> ]#"
},
"-ms-flow-into": {
syntax: "[ none | <custom-ident> ]#"
},
"-ms-grid-columns": {
syntax: "none | <track-list> | <auto-track-list>"
},
"-ms-grid-rows": {
syntax: "none | <track-list> | <auto-track-list>"
},
"-ms-high-contrast-adjust": {
syntax: "auto | none"
},
"-ms-hyphenate-limit-chars": {
syntax: "auto | <integer>{1,3}"
},
"-ms-hyphenate-limit-lines": {
syntax: "no-limit | <integer>"
},
"-ms-hyphenate-limit-zone": {
syntax: "<percentage> | <length>"
},
"-ms-ime-align": {
syntax: "auto | after"
},
"-ms-overflow-style": {
syntax: " auto | none | scrollbar | -ms-autohiding-scrollbar"
},
"-ms-scroll-chaining": {
syntax: "chained | none"
},
"-ms-scroll-limit": {
syntax: "<'-ms-scroll-limit-x-min'> <'-ms-scroll-limit-y-min'> <'-ms-scroll-limit-x-max'> <'-ms-scroll-limit-y-max'>"
},
"-ms-scroll-limit-x-max": {
syntax: "auto | <length>"
},
"-ms-scroll-limit-x-min": {
syntax: "<length>"
},
"-ms-scroll-limit-y-max": {
syntax: "auto | <length>"
},
"-ms-scroll-limit-y-min": {
syntax: "<length>"
},
"-ms-scroll-rails": {
syntax: "none | railed"
},
"-ms-scroll-snap-points-x": {
syntax: "snapInterval( <length-percentage>, <length-percentage> ) | snapList( <length-percentage># )"
},
"-ms-scroll-snap-points-y": {
syntax: "snapInterval( <length-percentage>, <length-percentage> ) | snapList( <length-percentage># )"
},
"-ms-scroll-snap-type": {
syntax: "none | proximity | mandatory"
},
"-ms-scroll-snap-x": {
syntax: "<'-ms-scroll-snap-type'> <'-ms-scroll-snap-points-x'>"
},
"-ms-scroll-snap-y": {
syntax: "<'-ms-scroll-snap-type'> <'-ms-scroll-snap-points-y'>"
},
"-ms-scroll-translation": {
syntax: "none | vertical-to-horizontal"
},
"-ms-scrollbar-3dlight-color": {
syntax: "<color>"
},
"-ms-scrollbar-arrow-color": {
syntax: "<color>"
},
"-ms-scrollbar-base-color": {
syntax: "<color>"
},
"-ms-scrollbar-darkshadow-color": {
syntax: "<color>"
},
"-ms-scrollbar-face-color": {
syntax: "<color>"
},
"-ms-scrollbar-highlight-color": {
syntax: "<color>"
},
"-ms-scrollbar-shadow-color": {
syntax: "<color>"
},
"-ms-scrollbar-track-color": {
syntax: "<color>"
},
"-ms-text-autospace": {
syntax: "none | ideograph-alpha | ideograph-numeric | ideograph-parenthesis | ideograph-space"
},
"-ms-touch-select": {
syntax: "grippers | none"
},
"-ms-user-select": {
syntax: "none | element | text"
},
"-ms-wrap-flow": {
syntax: "auto | both | start | end | maximum | clear"
},
"-ms-wrap-margin": {
syntax: "<length>"
},
"-ms-wrap-through": {
syntax: "wrap | none"
},
"-moz-appearance": {
syntax: "none | button | button-arrow-down | button-arrow-next | button-arrow-previous | button-arrow-up | button-bevel | button-focus | caret | checkbox | checkbox-container | checkbox-label | checkmenuitem | dualbutton | groupbox | listbox | listitem | menuarrow | menubar | menucheckbox | menuimage | menuitem | menuitemtext | menulist | menulist-button | menulist-text | menulist-textfield | menupopup | menuradio | menuseparator | meterbar | meterchunk | progressbar | progressbar-vertical | progresschunk | progresschunk-vertical | radio | radio-container | radio-label | radiomenuitem | range | range-thumb | resizer | resizerpanel | scale-horizontal | scalethumbend | scalethumb-horizontal | scalethumbstart | scalethumbtick | scalethumb-vertical | scale-vertical | scrollbarbutton-down | scrollbarbutton-left | scrollbarbutton-right | scrollbarbutton-up | scrollbarthumb-horizontal | scrollbarthumb-vertical | scrollbartrack-horizontal | scrollbartrack-vertical | searchfield | separator | sheet | spinner | spinner-downbutton | spinner-textfield | spinner-upbutton | splitter | statusbar | statusbarpanel | tab | tabpanel | tabpanels | tab-scroll-arrow-back | tab-scroll-arrow-forward | textfield | textfield-multiline | toolbar | toolbarbutton | toolbarbutton-dropdown | toolbargripper | toolbox | tooltip | treeheader | treeheadercell | treeheadersortarrow | treeitem | treeline | treetwisty | treetwistyopen | treeview | -moz-mac-unified-toolbar | -moz-win-borderless-glass | -moz-win-browsertabbar-toolbox | -moz-win-communicationstext | -moz-win-communications-toolbox | -moz-win-exclude-glass | -moz-win-glass | -moz-win-mediatext | -moz-win-media-toolbox | -moz-window-button-box | -moz-window-button-box-maximized | -moz-window-button-close | -moz-window-button-maximize | -moz-window-button-minimize | -moz-window-button-restore | -moz-window-frame-bottom | -moz-window-frame-left | -moz-window-frame-right | -moz-window-titlebar | -moz-window-titlebar-maximized"
},
"-moz-binding": {
syntax: "<url> | none"
},
"-moz-border-bottom-colors": {
syntax: "<color>+ | none"
},
"-moz-border-left-colors": {
syntax: "<color>+ | none"
},
"-moz-border-right-colors": {
syntax: "<color>+ | none"
},
"-moz-border-top-colors": {
syntax: "<color>+ | none"
},
"-moz-context-properties": {
syntax: "none | [ fill | fill-opacity | stroke | stroke-opacity ]#"
},
"-moz-float-edge": {
syntax: "border-box | content-box | margin-box | padding-box"
},
"-moz-force-broken-image-icon": {
syntax: "0 | 1"
},
"-moz-orient": {
syntax: "inline | block | horizontal | vertical"
},
"-moz-outline-radius": {
syntax: "<outline-radius>{1,4} [ / <outline-radius>{1,4} ]?"
},
"-moz-outline-radius-bottomleft": {
syntax: "<outline-radius>"
},
"-moz-outline-radius-bottomright": {
syntax: "<outline-radius>"
},
"-moz-outline-radius-topleft": {
syntax: "<outline-radius>"
},
"-moz-outline-radius-topright": {
syntax: "<outline-radius>"
},
"-moz-stack-sizing": {
syntax: "ignore | stretch-to-fit"
},
"-moz-text-blink": {
syntax: "none | blink"
},
"-moz-user-focus": {
syntax: "ignore | normal | select-after | select-before | select-menu | select-same | select-all | none"
},
"-moz-user-input": {
syntax: "auto | none | enabled | disabled"
},
"-moz-user-modify": {
syntax: "read-only | read-write | write-only"
},
"-moz-window-dragging": {
syntax: "drag | no-drag"
},
"-moz-window-shadow": {
syntax: "default | menu | tooltip | sheet | none"
},
"-webkit-appearance": {
syntax: " none | button | button-bevel | caps-lock-indicator | caret | checkbox | default-button | inner-spin-button | listbox | listitem | media-controls-background | media-controls-fullscreen-background | media-current-time-display | media-enter-fullscreen-button | media-exit-fullscreen-button | media-fullscreen-button | media-mute-button | media-overlay-play-button | media-play-button | media-seek-back-button | media-seek-forward-button | media-slider | media-sliderthumb | media-time-remaining-display | media-toggle-closed-captions-button | media-volume-slider | media-volume-slider-container | media-volume-sliderthumb | menulist | menulist-button | menulist-text | menulist-textfield | meter | progress-bar | progress-bar-value | push-button | radio | scrollbarbutton-down | scrollbarbutton-left | scrollbarbutton-right | scrollbarbutton-up | scrollbargripper-horizontal | scrollbargripper-vertical | scrollbarthumb-horizontal | scrollbarthumb-vertical | scrollbartrack-horizontal | scrollbartrack-vertical | searchfield | searchfield-cancel-button | searchfield-decoration | searchfield-results-button | searchfield-results-decoration | slider-horizontal | slider-vertical | sliderthumb-horizontal | sliderthumb-vertical | square-button | textarea | textfield | -apple-pay-button"
},
"-webkit-border-after": {
syntax: "<'border-top'>"
},
"-webkit-border-after-color": {
syntax: "<'border-top-color'>"
},
"-webkit-border-after-style": {
syntax: "<'border-top-style'>"
},
"-webkit-border-after-width": {
syntax: "<'border-top-width'>"
},
"-webkit-border-before": {
syntax: "<'border-top'>"
},
"-webkit-border-before-color": {
syntax: "<'border-top-color'>"
},
"-webkit-border-before-style": {
syntax: "<'border-top-style'>"
},
"-webkit-border-before-width": {
syntax: "<'border-top-width'>"
},
"-webkit-border-end": {
syntax: "<'border-top'>"
},
"-webkit-border-end-color": {
syntax: "<'border-top-color'>"
},
"-webkit-border-end-style": {
syntax: "<'border-top-style'>"
},
"-webkit-border-end-width": {
syntax: "<'border-top-width'>"
},
"-webkit-border-start": {
syntax: "<'border-top'>"
},
"-webkit-border-start-color": {
syntax: "<'border-top-color'>"
},
"-webkit-border-start-style": {
syntax: "<'border-top-style'>"
},
"-webkit-border-start-width": {
syntax: "<'border-top-width'>"
},
"-webkit-box-reflect": {
syntax: "[ above | below | right | left ]? <length>? <image>?"
},
"-webkit-line-clamp": {
syntax: "none | <integer>"
},
"-webkit-mask": {
syntax: "[ <mask-reference> || <position> [ / <bg-size> ]? || <repeat-style> || [ <visual-box> | border | padding | content | text ] || [ <visual-box> | border | padding | content ] ]#"
},
"-webkit-mask-attachment": {
syntax: "<attachment>#"
},
"-webkit-mask-clip": {
syntax: "[ <coord-box> | no-clip | border | padding | content | text ]#"
},
"-webkit-mask-composite": {
syntax: "<composite-style>#"
},
"-webkit-mask-image": {
syntax: "<mask-reference>#"
},
"-webkit-mask-origin": {
syntax: "[ <coord-box> | border | padding | content ]#"
},
"-webkit-mask-position": {
syntax: "<position>#"
},
"-webkit-mask-position-x": {
syntax: "[ <length-percentage> | left | center | right ]#"
},
"-webkit-mask-position-y": {
syntax: "[ <length-percentage> | top | center | bottom ]#"
},
"-webkit-mask-repeat": {
syntax: "<repeat-style>#"
},
"-webkit-mask-repeat-x": {
syntax: "repeat | no-repeat | space | round"
},
"-webkit-mask-repeat-y": {
syntax: "repeat | no-repeat | space | round"
},
"-webkit-mask-size": {
syntax: "<bg-size>#"
},
"-webkit-overflow-scrolling": {
syntax: "auto | touch"
},
"-webkit-tap-highlight-color": {
syntax: "<color>"
},
"-webkit-text-fill-color": {
syntax: "<color>"
},
"-webkit-text-stroke": {
syntax: "<length> || <color>"
},
"-webkit-text-stroke-color": {
syntax: "<color>"
},
"-webkit-text-stroke-width": {
syntax: "<length>"
},
"-webkit-touch-callout": {
syntax: "default | none"
},
"-webkit-user-modify": {
syntax: "read-only | read-write | read-write-plaintext-only"
},
"-webkit-user-select": {
syntax: " auto | none | text | all"
},
"accent-color": {
syntax: "auto | <color>"
},
"align-content": {
syntax: "normal | <baseline-position> | <content-distribution> | <overflow-position>? <content-position>"
},
"align-items": {
syntax: "normal | stretch | <baseline-position> | [ <overflow-position>? <self-position> ] | anchor-center"
},
"align-self": {
syntax: "auto | normal | stretch | <baseline-position> | <overflow-position>? <self-position> | anchor-center"
},
"align-tracks": {
syntax: "[ normal | <baseline-position> | <content-distribution> | <overflow-position>? <content-position> ]#"
},
"alignment-baseline": {
syntax: " auto | baseline | before-edge | text-before-edge | middle | central | after-edge | text-after-edge | ideographic | alphabetic | hanging | mathematical"
},
all: {
syntax: "initial | inherit | unset | revert | revert-layer"
},
"anchor-name": {
syntax: "none | <dashed-ident>#"
},
"anchor-scope": {
syntax: "none | all | <dashed-ident>#"
},
animation: {
syntax: "<single-animation>#"
},
"animation-composition": {
syntax: "<single-animation-composition>#"
},
"animation-delay": {
syntax: "<time>#"
},
"animation-direction": {
syntax: "<single-animation-direction>#"
},
"animation-duration": {
syntax: "[ auto | <time [