@projectwallace/css-analyzer 5.0.2 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"analyzer.module.js","sources":["../src/selectors/specificity.js","../src/aggregate-collection.js","../src/rules/rules.js","../src/values/colors.js","../src/countable-collection.js","../src/values/font-families.js","../src/values/font-sizes.js","../src/declarations/declarations.js","../src/selectors/selectors.js","../src/properties/properties.js","../src/values/values.js","../src/values/animations.js","../src/vendor-prefix.js","../src/values/vendor-prefix.js","../src/atrules/atrules.js","../src/context-collection.js","../src/index.js"],"sourcesContent":["import * as csstree from 'css-tree'\n\n/**\n * @typedef {[number, number, number]} Specificity\n *\n * @typedef {import('css-tree').Selector} Selector\n */\n\n/**\n * Compare specificity A to Specificity B\n * @param {Specificity} a - Specificity A\n * @param {Specificity} b - Specificity B\n * @returns {number} sortIndex - 0 when a==b, 1 when a<b, -1 when a>b\n */\nfunction compareSpecificity(a, b) {\n if (a[0] === b[0]) {\n if (a[1] === b[1]) {\n return b[2] - a[2]\n }\n\n return b[1] - a[1]\n }\n\n return b[0] - a[0]\n}\n\n/**\n *\n * @param {import('css-tree').SelectorList} selectorListAst\n * @returns {Selector} topSpecificitySelector\n */\nfunction selectorListSpecificities(selectorListAst) {\n const childSelectors = []\n csstree.walk(selectorListAst, {\n visit: 'Selector',\n enter(node) {\n childSelectors.push(analyzeSpecificity(node))\n }\n })\n\n return childSelectors.sort((a, b) => compareSpecificity(a.specificity, b.specificity))\n}\n\n/**\n * Get the Specificity for the AST of a Selector Node\n * @param {import('css-tree').Node} ast - AST Node for a Selector\n * @return {Object}\n * @property {Specificity} specificity\n * @property {number} complexity\n */\nconst analyzeSpecificity = (ast) => {\n let A = 0\n let B = 0\n let C = 0\n let complexity = 0\n let isA11y = false\n\n csstree.walk(ast, {\n enter: function (selector) {\n switch (selector.type) {\n case 'IdSelector': {\n A++\n complexity++\n break\n }\n case 'ClassSelector': {\n B++\n complexity++\n break\n }\n case 'AttributeSelector': {\n B++\n complexity++\n\n if (Boolean(selector.value)) {\n complexity++\n }\n isA11y = selector.name.name === 'role' || selector.name.name.startsWith('aria-')\n break\n }\n case 'PseudoElementSelector':\n case 'TypeSelector': {\n if (selector.name !== '*') {\n C++\n }\n complexity++\n break\n }\n case 'PseudoClassSelector': {\n if (['before', 'after', 'first-letter', 'first-line'].includes(selector.name)) {\n C++\n complexity++\n return this.skip\n }\n // The specificity of an :is(), :not(), or :has() pseudo-class is\n // replaced by the specificity of the most specific complex\n // selector in its selector list argument.\n\n // CSSTree doesn't parse the arguments of :is, :has and :matches,\n // so we need to create an AST out of them ourselves\n if (['is', 'has', 'matches'].includes(selector.name)) {\n const rawSelectorList = csstree.find(selector, ({ type }) => type === 'Raw')\n const childAst = csstree.parse(rawSelectorList.value, { context: 'selectorList' })\n const selectorList = selectorListSpecificities(childAst)\n const [topA, topB, topC] = selectorList[0].specificity\n A += topA\n B += topB\n C += topC\n\n for (let i = 0; i < selectorList.length; i++) {\n complexity += selectorList[i].complexity\n }\n complexity++\n return\n }\n\n // CSSTree *does* parse the arguments of the :not() pseudo-class,\n // so we have direct access to the AST, instead of having to parse\n // the arguments ourselves.\n if (selector.name === 'not') {\n const selectorList = selectorListSpecificities(selector)\n const [topA, topB, topC] = selectorList[0].specificity\n A += topA\n B += topB\n C += topC\n\n for (let i = 0; i < selectorList.length; i++) {\n complexity += selectorList[i].complexity\n }\n complexity++\n return this.skip\n }\n\n // The specificity of an :nth-child() or :nth-last-child() selector\n // is the specificity of the pseudo class itself (counting as one\n // pseudo-class selector) plus the specificity of the most\n // specific complex selector in its selector list argument (if any).\n if (['nth-child', 'nth-last-child'].includes(selector.name)) {\n // +1 for the pseudo class itself\n B++\n\n const childSelectors = selectorListSpecificities(selector)\n\n if (childSelectors.length === 0) {\n return\n }\n\n const [topA, topB, topC] = childSelectors[0].specificity\n A += topA\n B += topB\n C += topC\n\n for (let i = 0; i < childSelectors.length; i++) {\n complexity += childSelectors[i].complexity;\n }\n\n complexity++\n return\n }\n\n // The specificity of a :where() pseudo-class is replaced by zero,\n // but it does count towards complexity.\n if (selector.name === 'where') {\n const rawSelectorList = csstree.find(selector, ({ type }) => type === 'Raw')\n const childAst = csstree.parse(rawSelectorList.value, { context: 'selectorList' })\n const childSelectors = selectorListSpecificities(childAst)\n\n for (let i = 0; i < childSelectors.length; i++) {\n complexity += childSelectors[i].complexity;\n }\n\n complexity++\n return\n }\n\n // Regular pseudo classes have specificity [0,1,0]\n complexity++\n B++\n break\n }\n case 'Combinator': {\n complexity++\n break\n }\n }\n }\n })\n\n return {\n /** @type Specificity */\n specificity: [A, B, C],\n complexity,\n isId: A > 0,\n isA11y\n }\n}\n\nexport {\n analyzeSpecificity,\n compareSpecificity,\n}","/**\n * Find the mode (most occurring value) in an array of Numbers\n * Takes the mean/average of multiple values if multiple values occur the same amount of times.\n *\n * @see https://github.com/angus-c/just/blob/684af9ca0c7808bc78543ec89379b1fdfce502b1/packages/array-mode/index.js\n * @param {Array} arr - Array to find the mode value for\n * @returns {Number} mode - The `mode` value of `arr`\n */\nfunction Mode(arr) {\n const frequencies = Object.create(null)\n let maxOccurrences = -1\n let maxOccurenceCount = 0\n let sum = 0\n\n for (let i = 0; i < arr.length; i++) {\n const element = arr[i]\n const updatedCount = (frequencies[element] || 0) + 1\n frequencies[element] = updatedCount\n\n if (updatedCount > maxOccurrences) {\n maxOccurrences = updatedCount\n maxOccurenceCount = 0\n sum = 0\n }\n\n if (updatedCount >= maxOccurrences) {\n maxOccurenceCount++\n sum += element\n }\n }\n\n return sum / maxOccurenceCount\n}\n\n/**\n * Find the middle number in an Array of Numbers\n * Returns the average of 2 numbers if the Array length is an even number\n * @see https://github.com/angus-c/just/blob/684af9ca0c7808bc78543ec89379b1fdfce502b1/packages/array-median/index.js\n * @param {Array} arr - A sorted Array\n * @returns {Number} - The array's Median\n */\nfunction Median(arr) {\n const middle = arr.length / 2\n const lowerMiddleRank = Math.floor(middle)\n\n if (middle !== lowerMiddleRank) {\n return arr[lowerMiddleRank]\n }\n return (arr[lowerMiddleRank] + arr[lowerMiddleRank - 1]) / 2\n}\n\nclass AggregateCollection {\n constructor(size) {\n /** @type Number[] */\n this.items = new Uint8Array(size)\n this.sum = 0\n this.cursor = 0\n }\n\n /**\n * Add a new Integer to the AggregateCollection\n * @param {number} item - The item to add to the AggregateCollection\n */\n add(item) {\n this.items[this.cursor] = (item)\n this.sum += item\n this.cursor++\n }\n\n aggregate() {\n if (this.cursor === 0) {\n return {\n min: 0,\n max: 0,\n mean: 0,\n mode: 0,\n median: 0,\n range: 0,\n sum: 0,\n }\n }\n\n /** @type Number[] */\n const sorted = new Uint8Array(\n this.items.slice(0, this.cursor)\n ).sort((a, b) => a - b)\n const min = sorted[0]\n const max = sorted[sorted.length - 1]\n\n const mode = Mode(sorted)\n const median = Median(sorted)\n\n return {\n min,\n max,\n mean: this.sum / this.cursor,\n mode,\n median,\n range: max - min,\n sum: this.sum,\n }\n }\n\n toArray() {\n return Array.from(\n this.items.subarray(0, this.cursor)\n )\n }\n}\n\nexport {\n AggregateCollection\n}","import * as csstree from 'css-tree'\nimport { AggregateCollection } from '../aggregate-collection.js'\n\nconst analyzeRules = ({ rules }) => {\n const totalRules = rules.length\n const selectorsPerRule = new AggregateCollection(totalRules)\n const declarationsPerRule = new AggregateCollection(totalRules)\n\n let emptyRules = 0\n\n for (let i = 0; i < totalRules; i++) {\n let selectors = 0\n let declarations = 0\n\n csstree.walk(rules[i], {\n enter: function (childNode) {\n if (childNode.type === 'Selector') {\n selectors++\n return this.skip\n }\n\n if (childNode.type === 'Declaration') {\n declarations++\n return this.skip\n }\n }\n })\n\n if (declarations === 0) {\n emptyRules++\n }\n\n // For later aggregations\n selectorsPerRule.add(selectors)\n declarationsPerRule.add(declarations)\n }\n\n return {\n total: totalRules,\n empty: {\n total: emptyRules,\n ratio: totalRules === 0 ? 0 : emptyRules / totalRules\n },\n selectors: {\n ...selectorsPerRule.aggregate(),\n items: selectorsPerRule.toArray(),\n },\n declarations: {\n ...declarationsPerRule.aggregate(),\n items: declarationsPerRule.toArray()\n },\n }\n}\n\nexport {\n analyzeRules\n}","export const colorNames = {\n // CSS Named Colors\n // Spec: https://drafts.csswg.org/css-color/#named-colors\n aliceblue: 1,\n antiquewhite: 1,\n aqua: 1,\n aquamarine: 1,\n azure: 1,\n beige: 1,\n bisque: 1,\n black: 1,\n blanchedalmond: 1,\n blue: 1,\n blueviolet: 1,\n brown: 1,\n burlywood: 1,\n cadetblue: 1,\n chartreuse: 1,\n chocolate: 1,\n coral: 1,\n cornflowerblue: 1,\n cornsilk: 1,\n crimson: 1,\n cyan: 1,\n darkblue: 1,\n darkcyan: 1,\n darkgoldenrod: 1,\n darkgray: 1,\n darkgreen: 1,\n darkgrey: 1,\n darkkhaki: 1,\n darkmagenta: 1,\n darkolivegreen: 1,\n darkorange: 1,\n darkorchid: 1,\n darkred: 1,\n darksalmon: 1,\n darkseagreen: 1,\n darkslateblue: 1,\n darkslategray: 1,\n darkslategrey: 1,\n darkturquoise: 1,\n darkviolet: 1,\n deeppink: 1,\n deepskyblue: 1,\n dimgray: 1,\n dimgrey: 1,\n dodgerblue: 1,\n firebrick: 1,\n floralwhite: 1,\n forestgreen: 1,\n fuchsia: 1,\n gainsboro: 1,\n ghostwhite: 1,\n gold: 1,\n goldenrod: 1,\n gray: 1,\n green: 1,\n greenyellow: 1,\n grey: 1,\n honeydew: 1,\n hotpink: 1,\n indianred: 1,\n indigo: 1,\n ivory: 1,\n khaki: 1,\n lavender: 1,\n lavenderblush: 1,\n lawngreen: 1,\n lemonchiffon: 1,\n lightblue: 1,\n lightcoral: 1,\n lightcyan: 1,\n lightgoldenrodyellow: 1,\n lightgray: 1,\n lightgreen: 1,\n lightgrey: 1,\n lightpink: 1,\n lightsalmon: 1,\n lightseagreen: 1,\n lightskyblue: 1,\n lightslategray: 1,\n lightslategrey: 1,\n lightsteelblue: 1,\n lightyellow: 1,\n lime: 1,\n limegreen: 1,\n linen: 1,\n magenta: 1,\n maroon: 1,\n mediumaquamarine: 1,\n mediumblue: 1,\n mediumorchid: 1,\n mediumpurple: 1,\n mediumseagreen: 1,\n mediumslateblue: 1,\n mediumspringgreen: 1,\n mediumturquoise: 1,\n mediumvioletred: 1,\n midnightblue: 1,\n mintcream: 1,\n mistyrose: 1,\n moccasin: 1,\n navajowhite: 1,\n navy: 1,\n oldlace: 1,\n olive: 1,\n olivedrab: 1,\n orange: 1,\n orangered: 1,\n orchid: 1,\n palegoldenrod: 1,\n palegreen: 1,\n paleturquoise: 1,\n palevioletred: 1,\n papayawhip: 1,\n peachpuff: 1,\n peru: 1,\n pink: 1,\n plum: 1,\n powderblue: 1,\n purple: 1,\n rebeccapurple: 1,\n red: 1,\n rosybrown: 1,\n royalblue: 1,\n saddlebrown: 1,\n salmon: 1,\n sandybrown: 1,\n seagreen: 1,\n seashell: 1,\n sienna: 1,\n silver: 1,\n skyblue: 1,\n slateblue: 1,\n slategray: 1,\n slategrey: 1,\n snow: 1,\n springgreen: 1,\n steelblue: 1,\n tan: 1,\n teal: 1,\n thistle: 1,\n tomato: 1,\n turquoise: 1,\n violet: 1,\n wheat: 1,\n white: 1,\n whitesmoke: 1,\n yellow: 1,\n yellowgreen: 1,\n\n // CSS System Colors\n // Spec: https://drafts.csswg.org/css-color/#css-system-colors\n canvas: 1,\n canvastext: 1,\n linktext: 1,\n visitedtext: 1,\n activetext: 1,\n buttonface: 1,\n buttontext: 1,\n buttonborder: 1,\n field: 1,\n fieldtext: 1,\n highlight: 1,\n highlighttext: 1,\n selecteditem: 1,\n selecteditemtext: 1,\n mark: 1,\n marktext: 1,\n graytext: 1,\n\n // TODO: Deprecated CSS System colors\n // Spec: https://drafts.csswg.org/css-color/#deprecated-system-colors\n}\n\nexport const colorFunctions = {\n rgb: 1,\n rgba: 1,\n hsl: 1,\n hsla: 1,\n hwb: 1,\n lab: 1,\n lch: 1,\n oklab: 1,\n oklch: 1,\n color: 1,\n}\n\nexport const analyzeColors = ({ colors }) => {\n return colors.count()\n}\n","class CountableCollection {\n /**\n * @param {string[]} initial\n */\n constructor(initial) {\n this.items = {}\n this.total = 0\n this.totalUnique = 0\n\n if (initial) {\n for (let index = 0; index < initial.length; index++) {\n this.push(initial[index])\n }\n }\n }\n\n /**\n *\n * @param {string} item\n */\n push(item) {\n this.total++\n\n if (this.items[item]) {\n this.items[item]++\n return\n }\n\n this.items[item] = 1\n this.totalUnique++\n }\n\n size() {\n return this.total\n }\n\n count() {\n return {\n total: this.total,\n totalUnique: this.totalUnique,\n unique: this.items,\n uniquenessRatio: this.total === 0 ? 0 : this.totalUnique / this.total,\n }\n }\n}\n\nexport {\n CountableCollection\n}","import * as csstree from 'css-tree'\nimport { CountableCollection } from '../countable-collection.js'\n\nconst systemKeywords = {\n // Global CSS keywords\n 'inherit': 1,\n 'initial': 1,\n 'unset': 1,\n 'revert': 1,\n\n // System font keywords\n 'caption': 1,\n 'icon': 1,\n 'menu': 1,\n 'message-box': 1,\n 'small-caption': 1,\n 'status-bar': 1,\n}\n\nconst keywordDisallowList = {\n // font-weight, font-stretch, font-style\n 'normal': 1,\n\n // font-size keywords\n 'xx-small': 1,\n 'x-small': 1,\n 'small': 1,\n 'medium': 1,\n 'large': 1,\n 'x-large': 1,\n 'xx-large': 1,\n 'larger': 1,\n 'smaller': 1,\n\n // font-weight keywords\n 'bold': 1,\n 'bolder': 1,\n 'lighter': 1,\n\n // font-stretch keywords\n 'ultra-condensed': 1,\n 'extra-condensed': 1,\n 'condensed': 1,\n 'semi-condensed': 1,\n 'semi-expanded': 1,\n 'expanded': 1,\n 'extra-expanded': 1,\n 'ultra-expanded': 1,\n\n // font-style keywords\n 'italic': 1,\n 'oblique': 1,\n}\n\nconst COMMA = 44 // ','.charCodeAt(0) === 44\n\nconst analyzeFontFamilies = ({ fontValues, fontFamilyValues }) => {\n const all = new CountableCollection(fontFamilyValues)\n\n for (let index = 0; index < fontValues.length; index++) {\n const value = fontValues[index]\n\n // Avoid tree traversal as soon as possible\n const firstChild = value.children.first\n\n if (firstChild.type === 'Identifier' && systemKeywords[firstChild.name]) {\n continue\n }\n\n const parts = []\n\n csstree.walk(value, {\n reverse: true,\n enter: function (fontNode) {\n if (fontNode.type === 'String') {\n return parts.unshift(fontNode)\n }\n if (fontNode.type === 'Operator' && fontNode.value.charCodeAt(0) === COMMA) {\n return parts.unshift(fontNode)\n }\n if (fontNode.type === 'Identifier') {\n if (keywordDisallowList[fontNode.name]) {\n return this.skip\n }\n return parts.unshift(fontNode)\n }\n }\n })\n\n all.push(parts.map(csstree.generate).join(''))\n }\n\n return all.count()\n}\n\nexport {\n analyzeFontFamilies\n}","import * as csstree from 'css-tree'\nimport { CountableCollection } from '../countable-collection.js'\n\nconst sizeKeywords = {\n 'xx-small': 1,\n 'x-small': 1,\n 'small': 1,\n 'medium': 1,\n 'large': 1,\n 'x-large': 1,\n 'xx-large': 1,\n 'larger': 1,\n 'smaller': 1,\n}\n\nconst keywords = {\n // Global CSS keywords\n 'inherit': 1,\n 'initial': 1,\n 'unset': 1,\n 'revert': 1,\n\n // System font keywords\n 'caption': 1,\n 'icon': 1,\n 'menu': 1,\n 'message-box': 1,\n 'small-caption': 1,\n 'status-bar': 1,\n}\n\nconst ZERO = 48 // '0'.charCodeAt(0) === 48\nconst SLASH = 47 // '/'.charCodeAt(0) === 47\n\nconst analyzeFontSizes = ({ stringifyNode, fontSizeValues, fontValues }) => {\n const all = new CountableCollection(fontSizeValues)\n\n for (let index = 0; index < fontValues.length; index++) {\n const fontNode = fontValues[index];\n // Try to eliminate a keyword before we continue\n const firstChild = fontNode.children.first\n\n if (firstChild.type === 'Identifier' && keywords[firstChild.name]) {\n continue\n }\n\n let operator = false\n let size\n\n csstree.walk(fontNode, {\n enter: function (fontNode) {\n switch (fontNode.type) {\n case 'Number': {\n // Special case for `font: 0/0 a`\n if (fontNode.value.charCodeAt(0) === ZERO) {\n size = '0'\n return this.break\n }\n }\n case 'Operator': {\n if (fontNode.value.charCodeAt(0) === SLASH) {\n operator = true\n }\n break\n }\n case 'Dimension': {\n if (!operator) {\n size = stringifyNode(fontNode)\n return this.break\n }\n }\n case 'Identifier': {\n if (sizeKeywords[fontNode.name]) {\n size = fontNode.name\n return this.break\n }\n }\n }\n }\n })\n\n if (size) {\n all.push(size)\n }\n }\n\n return all.count()\n}\n\nexport {\n analyzeFontSizes\n}","const analyzeDeclarations = ({ stringifyNode, declarations }) => {\n const total = declarations.length\n const cache = Object.create(null)\n let importants = 0\n let totalUnique = 0\n let totalInKeyframes = 0\n\n for (let i = 0; i < total; i++) {\n const declaration = declarations[i]\n\n if (declaration.important === true) {\n importants++\n\n if (declaration.inKeyframe) {\n totalInKeyframes++\n }\n }\n\n const stringified = stringifyNode(declaration)\n\n if (!cache[stringified]) {\n cache[stringified] = 1\n totalUnique++\n }\n }\n\n return {\n total,\n unique: {\n total: totalUnique,\n ratio: total === 0 ? 0 : totalUnique / total,\n },\n importants: {\n total: importants,\n ratio: total === 0 ? 0 : importants / total,\n inKeyframes: {\n total: totalInKeyframes,\n ratio: importants === 0 ? 0 : totalInKeyframes / importants,\n },\n },\n }\n}\n\nexport {\n analyzeDeclarations\n}","import { analyzeSpecificity, compareSpecificity } from './specificity.js'\nimport { AggregateCollection } from '../aggregate-collection.js'\nimport { CountableCollection } from '../countable-collection.js'\n\n/** @typedef {[number, number, number]} Specificity */\n\nconst analyzeSelectors = ({ stringifyNode, selectors }) => {\n const counts = Object.create(null)\n const cache = Object.create(null)\n const totalSelectors = selectors.length\n\n /** @type Specificity|undefined */\n let maxSpecificity\n /** @type Specificity|undefined */\n let minSpecificity\n let specificityA = new AggregateCollection(totalSelectors)\n let specificityB = new AggregateCollection(totalSelectors)\n let specificityC = new AggregateCollection(totalSelectors)\n let totalUnique = 0\n const complexityAggregator = new AggregateCollection(totalSelectors);\n\n const specificities = []\n const complexities = []\n const ids = new CountableCollection()\n const a11y = new CountableCollection()\n const keyframes = new CountableCollection()\n\n for (let i = 0; i < totalSelectors; i++) {\n const node = selectors[i];\n const value = stringifyNode(node)\n\n if (node.isKeyframeSelector) {\n keyframes.push(value)\n // Do not attempt to further analyze <keyframe-selectors>\n continue\n }\n\n const { specificity, complexity, isId, isA11y } = cache[value] || analyzeSpecificity(node)\n\n if (isId) {\n ids.push(value)\n }\n\n if (isA11y) {\n a11y.push(value)\n }\n\n if (!cache[value]) {\n cache[value] = { complexity, specificity, isId, isA11y }\n totalUnique++\n counts[value] = 1\n } else {\n counts[value]++\n }\n\n complexityAggregator.add(complexity)\n\n if (maxSpecificity === undefined) {\n maxSpecificity = specificity\n }\n\n if (minSpecificity === undefined) {\n minSpecificity = specificity\n }\n\n specificityA.add(specificity[0])\n specificityB.add(specificity[1])\n specificityC.add(specificity[2])\n\n if (minSpecificity !== undefined && compareSpecificity(minSpecificity, specificity) < 0) {\n minSpecificity = specificity\n }\n\n if (maxSpecificity !== undefined && compareSpecificity(maxSpecificity, specificity) > 0) {\n maxSpecificity = specificity\n }\n\n specificities.push(specificity)\n complexities.push(complexity)\n }\n\n const aggregatesA = specificityA.aggregate()\n const aggregatesB = specificityB.aggregate()\n const aggregatesC = specificityC.aggregate()\n const complexityCount = new CountableCollection(complexities).count()\n\n return {\n total: totalSelectors,\n totalUnique,\n uniquenessRatio: totalSelectors === 0 ? 0 : totalUnique / totalSelectors,\n specificity: {\n sum: [aggregatesA.sum, aggregatesB.sum, aggregatesC.sum],\n min: minSpecificity,\n max: maxSpecificity,\n mean: [aggregatesA.mean, aggregatesB.mean, aggregatesC.mean],\n mode: [aggregatesA.mode, aggregatesB.mode, aggregatesC.mode],\n median: [aggregatesA.median, aggregatesB.median, aggregatesC.median],\n items: specificities\n },\n complexity: {\n ...complexityAggregator.aggregate(),\n ...complexityCount,\n items: complexities,\n },\n id: {\n ...ids.count(),\n ratio: totalSelectors === 0 ? 0 : ids.size() / totalSelectors,\n },\n accessibility: {\n ...a11y.count(),\n ratio: totalSelectors === 0 ? 0 : a11y.size() / totalSelectors,\n },\n keyframes: {\n ...keyframes.count(),\n ratio: totalSelectors === 0 ? 0 : keyframes.size() / totalSelectors,\n }\n }\n}\n\nexport {\n analyzeSelectors\n}","import { CountableCollection } from '../countable-collection.js'\n\nconst analyzeProperties = ({ properties }) => {\n const all = new CountableCollection(properties.map(p => p.authored))\n const prefixed = new CountableCollection()\n const hacks = new CountableCollection()\n const customs = new CountableCollection()\n const totalProperties = properties.length\n\n for (let i = 0; i < totalProperties; i++) {\n const property = properties[i]\n\n if (property.vendor) {\n prefixed.push(property.authored)\n continue\n }\n\n if (property.hack) {\n hacks.push(property.authored)\n continue\n }\n\n if (property.custom) {\n customs.push(property.authored)\n continue\n }\n }\n\n return {\n ...all.count(),\n prefixed: {\n ...prefixed.count(),\n ratio: prefixed.size() / totalProperties,\n },\n custom: {\n ...customs.count(),\n ratio: customs.size() / totalProperties,\n },\n browserhacks: {\n ...hacks.count(),\n ratio: hacks.size() / totalProperties,\n }\n }\n}\n\nexport {\n analyzeProperties\n}","import { CountableCollection } from '../countable-collection.js'\n\nconst keywords = {\n 'auto': 1,\n 'inherit': 1,\n 'initial': 1,\n 'unset': 1,\n 'revert': 1,\n 'none': 1, // for `text-shadow`\n}\n\nconst analyzeValues = ({ values, stringifyNode }) => {\n const all = new CountableCollection()\n\n for (let i = 0; i < values.length; i++) {\n const node = values[i]\n const firstChild = node.children.first\n\n if (!firstChild) continue\n if (firstChild.type === 'Identifier' && keywords[firstChild.name]) continue\n\n all.push(stringifyNode(node))\n }\n\n return all.count()\n}\n\nexport {\n analyzeValues\n}","import { CountableCollection } from '../countable-collection.js'\n\nconst timingKeywords = {\n 'linear': 1,\n 'ease': 1,\n 'ease-in': 1,\n 'ease-out': 1,\n 'ease-in-out': 1,\n 'step-start': 1,\n 'step-end': 1,\n}\n\nconst analyzeAnimations = ({ animations, durations, timingFunctions, stringifyNode }) => {\n const allDurations = new CountableCollection(durations.map(stringifyNode))\n const allTimingFunctions = new CountableCollection(timingFunctions.map(stringifyNode))\n\n for (let index = 0; index < animations.length; index++) {\n const node = animations[index]\n // Flag to know if we've grabbed the first Duration\n // yet (the first Dimension in a shorthand)\n let durationFound = false\n\n node.value.children.forEach(child => {\n // Right after a ',' we start over again\n if (child.type === 'Operator') {\n return durationFound = false\n }\n if (child.type === 'Dimension' && durationFound === false) {\n durationFound = true\n return allDurations.push(stringifyNode(child))\n }\n if (child.type === 'Identifier' && timingKeywords[child.name]) {\n return allTimingFunctions.push(stringifyNode(child))\n }\n if (child.type === 'Function'\n && (\n child.name === 'cubic-bezier' || child.name === 'steps'\n )\n ) {\n return allTimingFunctions.push(stringifyNode(child))\n }\n })\n }\n\n return {\n durations: allDurations.count(),\n timingFunctions: allTimingFunctions.count(),\n }\n}\n\nexport {\n analyzeAnimations\n}","const HYPHENMINUS = 45; // '-'.charCodeAt()\n\nfunction hasVendorPrefix(keyword) {\n if (keyword.charCodeAt(0) === HYPHENMINUS && keyword.charCodeAt(1) !== HYPHENMINUS) {\n // String must have a 2nd occurrence of '-', at least at position 3 (offset=2)\n if (keyword.indexOf('-', 2) !== -1) {\n return true\n }\n }\n\n return false\n}\n\nexport {\n hasVendorPrefix\n}","import { CountableCollection } from '../countable-collection.js'\nimport { hasVendorPrefix } from '../vendor-prefix.js'\n\nfunction isAstVendorPrefixed(children) {\n children = children.toArray()\n\n for (let index = 0; index < children.length; index++) {\n const child = children[index];\n\n if (child.type === 'Identifier' && child.name.length >= 3) {\n if (hasVendorPrefix(child.name)) {\n return true\n }\n }\n\n if (child.type === 'Function') {\n if (hasVendorPrefix(child.name)) {\n return true\n }\n\n if (child.children && isAstVendorPrefixed(child.children)) {\n return true\n }\n }\n }\n return false\n}\n\nconst analyzeVendorPrefixes = ({ values, stringifyNode }) => {\n const all = new CountableCollection()\n\n for (let i = 0; i < values.length; i++) {\n const value = values[i]\n\n if (value.children && isAstVendorPrefixed(value.children)) {\n all.push(stringifyNode(value))\n }\n }\n\n return all.count()\n}\n\nexport {\n analyzeVendorPrefixes\n}","import { CountableCollection } from '../countable-collection.js'\nimport { hasVendorPrefix } from '../vendor-prefix.js'\n\nconst analyzeAtRules = ({ atrules, stringifyNode }) => {\n const fontfaces = []\n const imports = new CountableCollection()\n const medias = new CountableCollection()\n const charsets = new CountableCollection()\n const supports = new CountableCollection()\n const keyframes = new CountableCollection()\n const prefixedKeyframes = new CountableCollection()\n const containers = new CountableCollection()\n\n const machine = {\n 'font-face': (node) => {\n const descriptors = {}\n\n node.block.children.forEach(descriptor => {\n descriptors[descriptor.property] = stringifyNode(descriptor.value)\n })\n\n fontfaces.push(descriptors)\n },\n 'media': node => medias.push(node.prelude.value),\n 'supports': node => supports.push(node.prelude.value),\n 'keyframes': node => keyframes.push(`@${node.name} ${node.prelude.value}`),\n 'import': node => imports.push(node.prelude.value),\n 'charset': node => charsets.push(node.prelude.value),\n 'container': node => containers.push(node.prelude.value),\n }\n\n for (let i = 0; i < atrules.length; i++) {\n const node = atrules[i]\n const nodeName = node.name\n const action = machine[nodeName]\n if (action) {\n action(node)\n continue\n }\n\n if (nodeName.endsWith('keyframes')) {\n const name = `@${nodeName} ${node.prelude.value}`\n keyframes.push(name)\n\n if (hasVendorPrefix(nodeName)) {\n prefixedKeyframes.push(name)\n }\n continue\n }\n }\n\n return {\n fontface: {\n total: fontfaces.length,\n totalUnique: fontfaces.length,\n unique: fontfaces,\n uniquenessRatio: 1\n },\n import: imports.count(),\n media: medias.count(),\n charset: charsets.count(),\n supports: supports.count(),\n keyframes: {\n ...keyframes.count(),\n prefixed: {\n ...prefixedKeyframes.count(),\n ratio: keyframes.size() === 0 ? 0 : prefixedKeyframes.size() / keyframes.size()\n }\n },\n container: containers.count(),\n }\n}\n\nexport {\n analyzeAtRules\n}","import { CountableCollection } from './countable-collection.js'\n\nclass ContextCollection {\n constructor() {\n this.list = new CountableCollection()\n this.contexts = {}\n this.contextCount = 0\n }\n\n push(item, context) {\n this.list.push(item)\n\n if (!this.contexts[context]) {\n this.contexts[context] = new CountableCollection()\n this.contextCount++\n }\n\n this.contexts[context].push(item)\n }\n\n count() {\n const itemsPerContext = {}\n\n for (let context in this.contexts) {\n itemsPerContext[context] = this.contexts[context].count()\n }\n\n return Object.assign(this.list.count(), {\n itemsPerContext\n })\n }\n}\n\nexport {\n ContextCollection\n}","import * as csstree from 'css-tree'\nimport { compareSpecificity } from './selectors/specificity.js'\nimport { analyzeRules } from './rules/rules.js'\nimport { analyzeColors, colorFunctions, colorNames } from './values/colors.js'\nimport { analyzeFontFamilies } from './values/font-families.js'\nimport { analyzeFontSizes } from './values/font-sizes.js'\nimport { analyzeDeclarations } from './declarations/declarations.js'\nimport { analyzeSelectors } from './selectors/selectors.js'\nimport { analyzeProperties } from './properties/properties.js'\nimport { analyzeValues } from './values/values.js'\nimport { analyzeAnimations } from './values/animations.js'\nimport { analyzeVendorPrefixes } from './values/vendor-prefix.js'\nimport { analyzeAtRules } from './atrules/atrules.js'\nimport { CountableCollection } from './countable-collection.js'\nimport { ContextCollection } from './context-collection.js'\n\n/**\n *\n * @param {string} css\n * @returns\n */\nconst analyze = (css) => {\n const start = new Date()\n\n // We need all lines later on when we need to stringify the AST again\n // e.g. for Selectors\n const lines = css.split(/\\r?\\n/)\n\n /**\n * Recreate the authored CSS from a CSSTree node\n * @param {import('css-tree').Node} node - Node from CSSTree AST to stringify\n * @returns {string} str - The stringified node\n */\n function stringifyNode(node) {\n const start = node.loc.start\n const end = node.loc.end\n const lineCount = end.line - start.line\n\n // Single-line nodes\n if (lineCount === 0) {\n return lines[start.line - 1].substring(start.column - 1, end.column - 1)\n }\n\n // Multi-line nodes\n const value = []\n\n for (let i = start.line; i <= end.line; i++) {\n const line = lines[i - 1]\n // First line\n if (i === start.line) {\n value.push(line.substring(start.column - 1))\n continue\n }\n // Last line\n if (i === end.line) {\n value.push(line.substring(0, end.column - 1))\n continue\n }\n // All lines in between first and last\n value.push(line)\n }\n\n return value.join('\\n')\n }\n\n const startParse = new Date()\n let totalComments = 0\n let commentsSize = 0\n\n const ast = csstree.parse(css, {\n parseAtrulePrelude: false,\n parseCustomProperty: true, // To find font-families, colors, etc.\n positions: true, // So we can use stringifyNode()\n onComment: function (comment) {\n totalComments++\n commentsSize += comment.length\n },\n })\n\n const startAnalysis = new Date()\n const atrules = []\n const rules = []\n const selectors = []\n const declarations = []\n const properties = []\n const values = []\n const zindex = []\n const textShadows = []\n const boxShadows = []\n const fontValues = []\n const fontFamilyValues = []\n const fontSizeValues = []\n const animations = []\n const timingFunctions = []\n const durations = []\n const colors = new ContextCollection()\n const units = new ContextCollection()\n\n csstree.walk(ast, {\n enter: function (node) {\n switch (node.type) {\n case 'Atrule': {\n atrules.push(node)\n break\n }\n case 'Rule': {\n rules.push(node)\n break\n }\n case 'Selector': {\n selectors.push({\n ...node,\n isKeyframeSelector: this.atrule && this.atrule.name.endsWith('keyframes')\n })\n\n // Avoid further walking of selectors to not mess with\n // our specificity calculations in case of a selector\n // with :where() or :is() that contain SelectorLists\n // as children\n return this.skip\n }\n case 'Dimension': {\n if (!this.declaration) {\n break\n }\n\n units.push(node.unit, this.declaration.property)\n\n return this.skip\n }\n case 'Declaration': {\n declarations.push({\n ...node,\n inKeyframe: this.atrule && this.atrule.name.endsWith('keyframes')\n })\n\n const { value, property } = node\n const fullProperty = {\n authored: property,\n ...csstree.property(property)\n }\n\n properties.push(fullProperty)\n values.push(value)\n\n switch (fullProperty.basename) {\n case 'z-index': {\n zindex.push(value)\n break\n }\n case 'text-shadow': {\n textShadows.push(value)\n break\n }\n case 'box-shadow': {\n boxShadows.push(value)\n break\n }\n case 'font': {\n fontValues.push(value)\n break\n }\n case 'font-family': {\n fontFamilyValues.push(stringifyNode(value))\n // Prevent analyzer to find color names in this property\n return this.skip\n }\n case 'font-size': {\n fontSizeValues.push(stringifyNode(value))\n break\n }\n case 'transition':\n case 'animation': {\n animations.push(node)\n break\n }\n case 'animation-duration':\n case 'transition-duration': {\n durations.push(value)\n break\n }\n case 'transition-timing-function':\n case 'animation-timing-function': {\n timingFunctions.push(value)\n break\n }\n }\n\n csstree.walk(node.value, {\n enter: function (valueNode) {\n switch (valueNode.type) {\n case 'Hash': {\n colors.push(stringifyNode(valueNode), property)\n\n return this.skip\n }\n case 'Identifier': {\n const { name } = valueNode\n // Bail out if it can't be a color name\n // 20 === 'lightgoldenrodyellow'.length\n // 3 === 'red'.length\n if (name.length > 20 || name.length < 3) {\n return this.skip\n }\n if (colorNames[name.toLowerCase()]) {\n colors.push(stringifyNode(valueNode), property)\n }\n return this.skip\n }\n case 'Function': {\n if (colorFunctions[valueNode.name.toLowerCase()]) {\n colors.push(stringifyNode(valueNode), property)\n }\n // No this.skip here intentionally,\n // otherwise we'll miss colors in linear-gradient() etc.\n }\n }\n }\n })\n }\n }\n }\n })\n\n return {\n stylesheet: {\n sourceLinesOfCode: atrules.length + selectors.length + declarations.length,\n linesOfCode: lines.length,\n size: css.length,\n comments: {\n total: totalComments,\n size: commentsSize,\n },\n },\n atrules: analyzeAtRules({ atrules, stringifyNode }),\n rules: analyzeRules({ rules }),\n selectors: analyzeSelectors({ stringifyNode, selectors }),\n declarations: analyzeDeclarations({ stringifyNode, declarations }),\n properties: analyzeProperties({ properties }),\n values: {\n colors: analyzeColors({ colors }),\n fontFamilies: analyzeFontFamilies({ stringifyNode, fontValues, fontFamilyValues }),\n fontSizes: analyzeFontSizes({ stringifyNode, fontValues, fontSizeValues }),\n zindexes: analyzeValues({ values: zindex, stringifyNode }),\n textShadows: analyzeValues({ values: textShadows, stringifyNode }),\n boxShadows: analyzeValues({ values: boxShadows, stringifyNode }),\n animations: analyzeAnimations({ animations, timingFunctions, durations, stringifyNode }),\n prefixes: analyzeVendorPrefixes({ values, stringifyNode }),\n units: units.count(),\n },\n __meta__: {\n parseTime: startAnalysis - startParse,\n analyzeTime: new Date() - startAnalysis,\n total: new Date() - start\n }\n }\n}\n\nexport { analyze, compareSpecificity }"],"names":["compareSpecificity","a","b","selectorListSpecificities","selectorListAst","childSelectors","csstree","walk","visit","enter","node","push","analyzeSpecificity","sort","specificity","ast","A","B","C","complexity","isA11y","selector","type","Boolean","value","name","startsWith","includes","skip","rawSelectorList","find","selectorList","parse","context","i","length","isId","AggregateCollection","size","this","items","Uint8Array","sum","cursor","add","item","aggregate","min","max","mean","mode","median","range","arr","middle","lowerMiddleRank","sorted","slice","frequencies","Object","create","maxOccurrences","maxOccurenceCount","element","updatedCount","Mode","Math","floor","toArray","Array","from","subarray","analyzeRules","rules","totalRules","selectorsPerRule","declarationsPerRule","emptyRules","selectors","declarations","childNode","total","empty","ratio","colorNames","aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen","canvas","canvastext","linktext","visitedtext","activetext","buttonface","buttontext","buttonborder","field","fieldtext","highlight","highlighttext","selecteditem","selecteditemtext","mark","marktext","graytext","colorFunctions","rgb","rgba","hsl","hsla","hwb","lab","lch","oklab","oklch","color","CountableCollection","initial","totalUnique","index","count","unique","uniquenessRatio","systemKeywords","inherit","unset","revert","caption","icon","menu","keywordDisallowList","normal","small","medium","large","larger","smaller","bold","bolder","lighter","condensed","expanded","italic","oblique","analyzeFontFamilies","fontValues","all","fontFamilyValues","firstChild","children","first","parts","reverse","fontNode","charCodeAt","unshift","map","generate","join","sizeKeywords","keywords","analyzeFontSizes","stringifyNode","fontSizeValues","operator","analyzeDeclarations","cache","importants","totalInKeyframes","declaration","important","inKeyframe","stringified","inKeyframes","analyzeSelectors","maxSpecificity","minSpecificity","counts","totalSelectors","specificityA","specificityB","specificityC","complexityAggregator","specificities","complexities","ids","a11y","keyframes","isKeyframeSelector","undefined","aggregatesA","aggregatesB","aggregatesC","complexityCount","id","accessibility","analyzeProperties","properties","p","authored","prefixed","hacks","customs","totalProperties","property","vendor","hack","custom","browserhacks","auto","none","analyzeValues","values","timingKeywords","linear","ease","analyzeAnimations","animations","timingFunctions","allDurations","durations","allTimingFunctions","durationFound","forEach","child","hasVendorPrefix","keyword","indexOf","isAstVendorPrefixed","analyzeVendorPrefixes","analyzeAtRules","atrules","fontfaces","imports","medias","charsets","supports","prefixedKeyframes","containers","machine","descriptors","block","descriptor","media","prelude","import","charset","container","nodeName","action","endsWith","fontface","ContextCollection","list","contexts","contextCount","itemsPerContext","assign","analyze","css","start","Date","lines","split","loc","end","line","substring","column","startParse","totalComments","commentsSize","parseAtrulePrelude","parseCustomProperty","positions","onComment","comment","startAnalysis","zindex","textShadows","boxShadows","colors","units","atrule","unit","fullProperty","basename","valueNode","toLowerCase","stylesheet","sourceLinesOfCode","linesOfCode","comments","fontFamilies","fontSizes","zindexes","prefixes","__meta__","parseTime","anal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CP,EAAO/Z,KAAKwS,EAAc6H,GAAYnF,WAajD,CACLqF,WAAY,CACVC,kBAAmB3D,EAAQrV,OAAS2C,EAAU3C,OAAS4C,EAAa5C,OACpEiZ,YAAa7B,EAAMpX,OACnBG,KAAM8W,EAAIjX,OACVkZ,SAAU,CACRpW,MAAO8U,EACPzX,KAAM0X,IAGVxC,QAASD,EAAe,CAAEC,QAAAA,EAASrE,cAAAA,IACnC1O,MAAOD,EAAa,CAAEC,MAAAA,IACtBK,UAAWiP,EAAiB,CAAEZ,cAAAA,EAAerO,UAAAA,IAC7CC,aAAcuO,EAAoB,CAAEH,cAAAA,EAAepO,aAAAA,IACnDuQ,WAAYD,EAAkB,CAAEC,WAAAA,IAChCe,OAAQ,CACNqE,UAAsB,CAAEA,OAAAA,KbnDEA,OAChBjK,SamDV6K,aAAcrJ,EAAoB,CAAEkB,cAAAA,EAAejB,WAAAA,EAAYE,iBAAAA,IAC/DmJ,UAAWrI,EAAiB,CAAEC,cAAAA,EAAejB,WAAAA,EAAYkB,eAAAA,IACzDoI,SAAUpF,EAAc,CAAEC,OAAQkE,EAAQpH,cAAAA,IAC1CqH,YAAapE,EAAc,CAAEC,OAAQmE,EAAarH,cAAAA,IAClDsH,WAAYrE,EAAc,CAAEC,OAAQoE,EAAYtH,cAAAA,IAChDuD,WAAYD,EAAkB,CAAEC,WAAAA,EAAYC,gBAAAA,EAAiBE,UAAAA,EAAW1D,cAAAA,IACxEsI,SAAUnE,EAAsB,CAAEjB,OAAAA,EAAQlD,cAAAA,IAC1CwH,MAAOA,EAAMlK,SAEfiL,SAAU,CACRC,UAAWrB,EAAgBR,EAC3B8B,YAAa,IAAItC,KAASgB,EAC1BrV,MAAO,IAAIqU,KAASD"}
1
+ {"version":3,"file":"analyzer.module.js","sources":["../src/selectors/specificity.js","../src/aggregate-collection.js","../src/rules/rules.js","../src/values/colors.js","../src/countable-collection.js","../src/values/font-families.js","../src/values/font-sizes.js","../src/declarations/declarations.js","../src/selectors/selectors.js","../src/properties/properties.js","../src/values/values.js","../src/values/animations.js","../src/vendor-prefix.js","../src/values/vendor-prefix.js","../src/atrules/atrules.js","../src/context-collection.js","../src/index.js"],"sourcesContent":["import * as csstree from 'css-tree'\n\n/**\n * Compare specificity A to Specificity B\n * @param {[number,number,number]} a - Specificity A\n * @param {[number,number,number]} b - Specificity B\n * @returns {number} sortIndex - 0 when a==b, 1 when a<b, -1 when a>b\n */\nfunction compareSpecificity(a, b) {\n if (a[0] === b[0]) {\n if (a[1] === b[1]) {\n return b[2] - a[2]\n }\n\n return b[1] - a[1]\n }\n\n return b[0] - a[0]\n}\n\n/**\n *\n * @param {import('css-tree').SelectorList} selectorListAst\n * @returns {Selector} topSpecificitySelector\n */\nfunction selectorListSpecificities(selectorListAst) {\n const childSelectors = []\n csstree.walk(selectorListAst, {\n visit: 'Selector',\n enter(node) {\n childSelectors.push(analyzeSpecificity(node))\n }\n })\n\n return childSelectors.sort((a, b) => compareSpecificity(a.specificity, b.specificity))\n}\n\n/**\n * Get the Specificity for the AST of a Selector Node\n * @param {import('css-tree').Selector} ast - AST Node for a Selector\n * @return {Object}\n * @property {[number,number,number]} specificity\n * @property {number} complexity\n * @property {Boolean} isId\n * @property {Boolean} isA11y\n */\nconst analyzeSpecificity = (ast) => {\n let A = 0\n let B = 0\n let C = 0\n let complexity = 0\n let isA11y = false\n\n csstree.walk(ast, {\n enter: function (selector) {\n switch (selector.type) {\n case 'IdSelector': {\n A++\n complexity++\n break\n }\n case 'ClassSelector': {\n B++\n complexity++\n break\n }\n case 'AttributeSelector': {\n B++\n complexity++\n\n if (Boolean(selector.value)) {\n complexity++\n }\n isA11y = selector.name.name === 'role' || selector.name.name.startsWith('aria-')\n break\n }\n case 'PseudoElementSelector':\n case 'TypeSelector': {\n if (selector.name !== '*') {\n C++\n }\n complexity++\n break\n }\n case 'PseudoClassSelector': {\n if (['before', 'after', 'first-letter', 'first-line'].includes(selector.name)) {\n C++\n complexity++\n return this.skip\n }\n // The specificity of an :is(), :not(), or :has() pseudo-class is\n // replaced by the specificity of the most specific complex\n // selector in its selector list argument.\n\n // CSSTree doesn't parse the arguments of :is, :has and :matches,\n // so we need to create an AST out of them ourselves\n if (['is', 'has', 'matches'].includes(selector.name)) {\n const rawSelectorList = csstree.find(selector, ({ type }) => type === 'Raw')\n const childAst = csstree.parse(rawSelectorList.value, { context: 'selectorList' })\n const selectorList = selectorListSpecificities(childAst)\n const [topA, topB, topC] = selectorList[0].specificity\n A += topA\n B += topB\n C += topC\n\n for (let i = 0; i < selectorList.length; i++) {\n complexity += selectorList[i].complexity\n }\n complexity++\n return\n }\n\n // CSSTree *does* parse the arguments of the :not() pseudo-class,\n // so we have direct access to the AST, instead of having to parse\n // the arguments ourselves.\n if (selector.name === 'not') {\n const selectorList = selectorListSpecificities(selector)\n const [topA, topB, topC] = selectorList[0].specificity\n A += topA\n B += topB\n C += topC\n\n for (let i = 0; i < selectorList.length; i++) {\n complexity += selectorList[i].complexity\n }\n complexity++\n return this.skip\n }\n\n // The specificity of an :nth-child() or :nth-last-child() selector\n // is the specificity of the pseudo class itself (counting as one\n // pseudo-class selector) plus the specificity of the most\n // specific complex selector in its selector list argument (if any).\n if (['nth-child', 'nth-last-child'].includes(selector.name)) {\n // +1 for the pseudo class itself\n B++\n\n const childSelectors = selectorListSpecificities(selector)\n\n if (childSelectors.length === 0) {\n return\n }\n\n const [topA, topB, topC] = childSelectors[0].specificity\n A += topA\n B += topB\n C += topC\n\n for (let i = 0; i < childSelectors.length; i++) {\n complexity += childSelectors[i].complexity;\n }\n\n complexity++\n return\n }\n\n // The specificity of a :where() pseudo-class is replaced by zero,\n // but it does count towards complexity.\n if (selector.name === 'where') {\n const rawSelectorList = csstree.find(selector, ({ type }) => type === 'Raw')\n const childAst = csstree.parse(rawSelectorList.value, { context: 'selectorList' })\n const childSelectors = selectorListSpecificities(childAst)\n\n for (let i = 0; i < childSelectors.length; i++) {\n complexity += childSelectors[i].complexity;\n }\n\n complexity++\n return\n }\n\n // Regular pseudo classes have specificity [0,1,0]\n complexity++\n B++\n break\n }\n case 'Combinator': {\n complexity++\n break\n }\n }\n }\n })\n\n return {\n /** @type {[number,number,number]} */\n specificity: [A, B, C],\n complexity,\n isId: A > 0,\n isA11y\n }\n}\n\nexport {\n analyzeSpecificity,\n compareSpecificity,\n}","/**\n * Find the mode (most occurring value) in an array of Numbers\n * Takes the mean/average of multiple values if multiple values occur the same amount of times.\n *\n * @see https://github.com/angus-c/just/blob/684af9ca0c7808bc78543ec89379b1fdfce502b1/packages/array-mode/index.js\n * @param {Array} arr - Array to find the mode value for\n * @returns {Number} mode - The `mode` value of `arr`\n */\nfunction Mode(arr) {\n const frequencies = Object.create(null)\n let maxOccurrences = -1\n let maxOccurenceCount = 0\n let sum = 0\n\n for (let i = 0; i < arr.length; i++) {\n const element = arr[i]\n const updatedCount = (frequencies[element] || 0) + 1\n frequencies[element] = updatedCount\n\n if (updatedCount > maxOccurrences) {\n maxOccurrences = updatedCount\n maxOccurenceCount = 0\n sum = 0\n }\n\n if (updatedCount >= maxOccurrences) {\n maxOccurenceCount++\n sum += element\n }\n }\n\n return sum / maxOccurenceCount\n}\n\n/**\n * Find the middle number in an Array of Numbers\n * Returns the average of 2 numbers if the Array length is an even number\n * @see https://github.com/angus-c/just/blob/684af9ca0c7808bc78543ec89379b1fdfce502b1/packages/array-median/index.js\n * @param {Array} arr - A sorted Array\n * @returns {Number} - The array's Median\n */\nfunction Median(arr) {\n const middle = arr.length / 2\n const lowerMiddleRank = Math.floor(middle)\n\n if (middle !== lowerMiddleRank) {\n return arr[lowerMiddleRank]\n }\n return (arr[lowerMiddleRank] + arr[lowerMiddleRank - 1]) / 2\n}\n\nclass AggregateCollection {\n constructor(size) {\n /** @type number[] */\n this.items = new Uint8Array(size)\n this.sum = 0\n this.cursor = 0\n }\n\n /**\n * Add a new Integer at the end of this AggregateCollection\n * @param {number} item - The item to add\n */\n add(item) {\n this.items[this.cursor] = item\n this.sum += item\n this.cursor++\n }\n\n aggregate() {\n if (this.cursor === 0) {\n return {\n min: 0,\n max: 0,\n mean: 0,\n mode: 0,\n median: 0,\n range: 0,\n sum: 0,\n }\n }\n\n /** @type Number[] */\n const sorted = new Uint8Array(\n this.items.slice(0, this.cursor)\n ).sort((a, b) => a - b)\n const min = sorted[0]\n const max = sorted[sorted.length - 1]\n\n const mode = Mode(sorted)\n const median = Median(sorted)\n\n return {\n min,\n max,\n mean: this.sum / this.cursor,\n mode,\n median,\n range: max - min,\n sum: this.sum,\n }\n }\n\n /**\n * @returns {number[]} All items in this collection\n */\n toArray() {\n return Array.from(\n this.items.subarray(0, this.cursor)\n )\n }\n}\n\nexport {\n AggregateCollection\n}","import * as csstree from 'css-tree'\nimport { AggregateCollection } from '../aggregate-collection.js'\n\nconst analyzeRules = ({ rules }) => {\n /** @type number */\n const totalRules = rules.length\n const selectorsPerRule = new AggregateCollection(totalRules)\n const declarationsPerRule = new AggregateCollection(totalRules)\n\n let emptyRules = 0\n\n for (let i = 0; i < totalRules; i++) {\n let selectors = 0\n let declarations = 0\n\n csstree.walk(rules[i], {\n enter: function (childNode) {\n if (childNode.type === 'Selector') {\n selectors++\n return this.skip\n }\n\n if (childNode.type === 'Declaration') {\n declarations++\n return this.skip\n }\n }\n })\n\n if (declarations === 0) {\n emptyRules++\n }\n\n // For later aggregations\n selectorsPerRule.add(selectors)\n declarationsPerRule.add(declarations)\n }\n\n return {\n total: totalRules,\n empty: {\n total: emptyRules,\n ratio: totalRules === 0 ? 0 : emptyRules / totalRules\n },\n selectors: {\n ...selectorsPerRule.aggregate(),\n items: selectorsPerRule.toArray(),\n },\n declarations: {\n ...declarationsPerRule.aggregate(),\n items: declarationsPerRule.toArray()\n },\n }\n}\n\nexport {\n analyzeRules\n}","export const colorNames = {\n // CSS Named Colors\n // Spec: https://drafts.csswg.org/css-color/#named-colors\n aliceblue: 1,\n antiquewhite: 1,\n aqua: 1,\n aquamarine: 1,\n azure: 1,\n beige: 1,\n bisque: 1,\n black: 1,\n blanchedalmond: 1,\n blue: 1,\n blueviolet: 1,\n brown: 1,\n burlywood: 1,\n cadetblue: 1,\n chartreuse: 1,\n chocolate: 1,\n coral: 1,\n cornflowerblue: 1,\n cornsilk: 1,\n crimson: 1,\n cyan: 1,\n darkblue: 1,\n darkcyan: 1,\n darkgoldenrod: 1,\n darkgray: 1,\n darkgreen: 1,\n darkgrey: 1,\n darkkhaki: 1,\n darkmagenta: 1,\n darkolivegreen: 1,\n darkorange: 1,\n darkorchid: 1,\n darkred: 1,\n darksalmon: 1,\n darkseagreen: 1,\n darkslateblue: 1,\n darkslategray: 1,\n darkslategrey: 1,\n darkturquoise: 1,\n darkviolet: 1,\n deeppink: 1,\n deepskyblue: 1,\n dimgray: 1,\n dimgrey: 1,\n dodgerblue: 1,\n firebrick: 1,\n floralwhite: 1,\n forestgreen: 1,\n fuchsia: 1,\n gainsboro: 1,\n ghostwhite: 1,\n gold: 1,\n goldenrod: 1,\n gray: 1,\n green: 1,\n greenyellow: 1,\n grey: 1,\n honeydew: 1,\n hotpink: 1,\n indianred: 1,\n indigo: 1,\n ivory: 1,\n khaki: 1,\n lavender: 1,\n lavenderblush: 1,\n lawngreen: 1,\n lemonchiffon: 1,\n lightblue: 1,\n lightcoral: 1,\n lightcyan: 1,\n lightgoldenrodyellow: 1,\n lightgray: 1,\n lightgreen: 1,\n lightgrey: 1,\n lightpink: 1,\n lightsalmon: 1,\n lightseagreen: 1,\n lightskyblue: 1,\n lightslategray: 1,\n lightslategrey: 1,\n lightsteelblue: 1,\n lightyellow: 1,\n lime: 1,\n limegreen: 1,\n linen: 1,\n magenta: 1,\n maroon: 1,\n mediumaquamarine: 1,\n mediumblue: 1,\n mediumorchid: 1,\n mediumpurple: 1,\n mediumseagreen: 1,\n mediumslateblue: 1,\n mediumspringgreen: 1,\n mediumturquoise: 1,\n mediumvioletred: 1,\n midnightblue: 1,\n mintcream: 1,\n mistyrose: 1,\n moccasin: 1,\n navajowhite: 1,\n navy: 1,\n oldlace: 1,\n olive: 1,\n olivedrab: 1,\n orange: 1,\n orangered: 1,\n orchid: 1,\n palegoldenrod: 1,\n palegreen: 1,\n paleturquoise: 1,\n palevioletred: 1,\n papayawhip: 1,\n peachpuff: 1,\n peru: 1,\n pink: 1,\n plum: 1,\n powderblue: 1,\n purple: 1,\n rebeccapurple: 1,\n red: 1,\n rosybrown: 1,\n royalblue: 1,\n saddlebrown: 1,\n salmon: 1,\n sandybrown: 1,\n seagreen: 1,\n seashell: 1,\n sienna: 1,\n silver: 1,\n skyblue: 1,\n slateblue: 1,\n slategray: 1,\n slategrey: 1,\n snow: 1,\n springgreen: 1,\n steelblue: 1,\n tan: 1,\n teal: 1,\n thistle: 1,\n tomato: 1,\n turquoise: 1,\n violet: 1,\n wheat: 1,\n white: 1,\n whitesmoke: 1,\n yellow: 1,\n yellowgreen: 1,\n\n // CSS System Colors\n // Spec: https://drafts.csswg.org/css-color/#css-system-colors\n canvas: 1,\n canvastext: 1,\n linktext: 1,\n visitedtext: 1,\n activetext: 1,\n buttonface: 1,\n buttontext: 1,\n buttonborder: 1,\n field: 1,\n fieldtext: 1,\n highlight: 1,\n highlighttext: 1,\n selecteditem: 1,\n selecteditemtext: 1,\n mark: 1,\n marktext: 1,\n graytext: 1,\n\n // TODO: Deprecated CSS System colors\n // Spec: https://drafts.csswg.org/css-color/#deprecated-system-colors\n}\n\nexport const colorFunctions = {\n rgb: 1,\n rgba: 1,\n hsl: 1,\n hsla: 1,\n hwb: 1,\n lab: 1,\n lch: 1,\n oklab: 1,\n oklch: 1,\n color: 1,\n}\n","class CountableCollection {\n /**\n * @param {string[]} initial\n */\n constructor(initial) {\n /** @type [index: string]: string */\n this.items = {}\n /** @type number */\n this.total = 0\n /** @type number */\n this.totalUnique = 0\n\n if (initial) {\n for (let index = 0; index < initial.length; index++) {\n this.push(initial[index])\n }\n }\n }\n\n /**\n * Push an item to the end of this collection\n * @param {string} item\n * @returns {void}\n */\n push(item) {\n this.total++\n\n if (this.items[item]) {\n this.items[item]++\n return\n }\n\n this.items[item] = 1\n this.totalUnique++\n }\n\n /**\n * Get the size of this collection\n * @returns {number} the size of this collection\n */\n size() {\n return this.total\n }\n\n /**\n * Get the counts of this collection, like total, uniques, etc.\n */\n count() {\n return {\n total: this.total,\n totalUnique: this.totalUnique,\n unique: this.items,\n uniquenessRatio: this.total === 0 ? 0 : this.totalUnique / this.total,\n }\n }\n}\n\nexport {\n CountableCollection\n}","import * as csstree from 'css-tree'\nimport { CountableCollection } from '../countable-collection.js'\n\nconst systemKeywords = {\n // Global CSS keywords\n 'inherit': 1,\n 'initial': 1,\n 'unset': 1,\n 'revert': 1,\n\n // System font keywords\n 'caption': 1,\n 'icon': 1,\n 'menu': 1,\n 'message-box': 1,\n 'small-caption': 1,\n 'status-bar': 1,\n}\n\nconst keywordDisallowList = {\n // font-weight, font-stretch, font-style\n 'normal': 1,\n\n // font-size keywords\n 'xx-small': 1,\n 'x-small': 1,\n 'small': 1,\n 'medium': 1,\n 'large': 1,\n 'x-large': 1,\n 'xx-large': 1,\n 'larger': 1,\n 'smaller': 1,\n\n // font-weight keywords\n 'bold': 1,\n 'bolder': 1,\n 'lighter': 1,\n\n // font-stretch keywords\n 'ultra-condensed': 1,\n 'extra-condensed': 1,\n 'condensed': 1,\n 'semi-condensed': 1,\n 'semi-expanded': 1,\n 'expanded': 1,\n 'extra-expanded': 1,\n 'ultra-expanded': 1,\n\n // font-style keywords\n 'italic': 1,\n 'oblique': 1,\n}\n\nconst COMMA = 44 // ','.charCodeAt(0) === 44\n\nconst analyzeFontFamilies = ({ fontValues, fontFamilyValues }) => {\n const all = new CountableCollection(fontFamilyValues)\n\n for (let index = 0; index < fontValues.length; index++) {\n const value = fontValues[index]\n\n // Avoid tree traversal as soon as possible\n const firstChild = value.children.first\n\n if (firstChild.type === 'Identifier' && systemKeywords[firstChild.name]) {\n continue\n }\n\n const parts = []\n\n csstree.walk(value, {\n reverse: true,\n enter: function (fontNode) {\n if (fontNode.type === 'String') {\n return parts.unshift(fontNode)\n }\n if (fontNode.type === 'Operator' && fontNode.value.charCodeAt(0) === COMMA) {\n return parts.unshift(fontNode)\n }\n if (fontNode.type === 'Identifier') {\n if (keywordDisallowList[fontNode.name]) {\n return this.skip\n }\n return parts.unshift(fontNode)\n }\n }\n })\n\n all.push(parts.map(csstree.generate).join(''))\n }\n\n return all.count()\n}\n\nexport {\n analyzeFontFamilies\n}","import * as csstree from 'css-tree'\nimport { CountableCollection } from '../countable-collection.js'\n\nconst sizeKeywords = {\n 'xx-small': 1,\n 'x-small': 1,\n 'small': 1,\n 'medium': 1,\n 'large': 1,\n 'x-large': 1,\n 'xx-large': 1,\n 'larger': 1,\n 'smaller': 1,\n}\n\nconst keywords = {\n // Global CSS keywords\n 'inherit': 1,\n 'initial': 1,\n 'unset': 1,\n 'revert': 1,\n\n // System font keywords\n 'caption': 1,\n 'icon': 1,\n 'menu': 1,\n 'message-box': 1,\n 'small-caption': 1,\n 'status-bar': 1,\n}\n\nconst ZERO = 48 // '0'.charCodeAt(0) === 48\nconst SLASH = 47 // '/'.charCodeAt(0) === 47\n\nconst analyzeFontSizes = ({ stringifyNode, fontSizeValues, fontValues }) => {\n const all = new CountableCollection(fontSizeValues)\n\n for (let index = 0; index < fontValues.length; index++) {\n const fontNode = fontValues[index];\n // Try to eliminate a keyword before we continue\n const firstChild = fontNode.children.first\n\n if (firstChild.type === 'Identifier' && keywords[firstChild.name]) {\n continue\n }\n\n let operator = false\n let size\n\n csstree.walk(fontNode, {\n enter: function (fontNode) {\n switch (fontNode.type) {\n case 'Number': {\n // Special case for `font: 0/0 a`\n if (fontNode.value.charCodeAt(0) === ZERO) {\n size = '0'\n return this.break\n }\n }\n case 'Operator': {\n if (fontNode.value.charCodeAt(0) === SLASH) {\n operator = true\n }\n break\n }\n case 'Dimension': {\n if (!operator) {\n size = stringifyNode(fontNode)\n return this.break\n }\n }\n case 'Identifier': {\n if (sizeKeywords[fontNode.name]) {\n size = fontNode.name\n return this.break\n }\n }\n }\n }\n })\n\n if (size) {\n all.push(size)\n }\n }\n\n return all.count()\n}\n\nexport {\n analyzeFontSizes\n}","const analyzeDeclarations = ({ stringifyNode, declarations }) => {\n /** @type number */\n const total = declarations.length\n const cache = Object.create(null)\n let importants = 0\n let totalUnique = 0\n let totalInKeyframes = 0\n\n for (let i = 0; i < total; i++) {\n const declaration = declarations[i]\n\n if (declaration.important === true) {\n importants++\n\n if (declaration.inKeyframe) {\n totalInKeyframes++\n }\n }\n\n const stringified = stringifyNode(declaration)\n\n if (!cache[stringified]) {\n cache[stringified] = 1\n totalUnique++\n }\n }\n\n return {\n total,\n unique: {\n total: totalUnique,\n ratio: total === 0 ? 0 : totalUnique / total,\n },\n importants: {\n total: importants,\n ratio: total === 0 ? 0 : importants / total,\n inKeyframes: {\n total: totalInKeyframes,\n ratio: importants === 0 ? 0 : totalInKeyframes / importants,\n },\n },\n }\n}\n\nexport {\n analyzeDeclarations\n}","import { analyzeSpecificity, compareSpecificity } from './specificity.js'\nimport { AggregateCollection } from '../aggregate-collection.js'\nimport { CountableCollection } from '../countable-collection.js'\n\nconst analyzeSelectors = ({ stringifyNode, selectors }) => {\n const counts = Object.create(null)\n const cache = Object.create(null)\n /** @type number */\n const totalSelectors = selectors.length\n\n /** @type [number,number,number] */\n let maxSpecificity\n /** @type [number,number,number] */\n let minSpecificity\n let specificityA = new AggregateCollection(totalSelectors)\n let specificityB = new AggregateCollection(totalSelectors)\n let specificityC = new AggregateCollection(totalSelectors)\n let totalUnique = 0\n const complexityAggregator = new AggregateCollection(totalSelectors);\n\n /** @type [number,number,number][] */\n const specificities = []\n /** @type number[] */\n const complexities = []\n const ids = new CountableCollection()\n const a11y = new CountableCollection()\n const keyframes = new CountableCollection()\n\n for (let i = 0; i < totalSelectors; i++) {\n /** @type import('css-tree').Selector */\n const node = selectors[i];\n /** @type string */\n const value = stringifyNode(node)\n\n if (node.isKeyframeSelector) {\n keyframes.push(value)\n // Do not attempt to further analyze <keyframe-selectors>\n continue\n }\n\n const { specificity, complexity, isId, isA11y } = cache[value] || analyzeSpecificity(node)\n\n if (isId) {\n ids.push(value)\n }\n\n if (isA11y) {\n a11y.push(value)\n }\n\n if (!cache[value]) {\n cache[value] = { complexity, specificity, isId, isA11y }\n totalUnique++\n counts[value] = 1\n } else {\n counts[value]++\n }\n\n complexityAggregator.add(complexity)\n\n if (maxSpecificity === undefined) {\n maxSpecificity = specificity\n }\n\n if (minSpecificity === undefined) {\n minSpecificity = specificity\n }\n\n specificityA.add(specificity[0])\n specificityB.add(specificity[1])\n specificityC.add(specificity[2])\n\n if (minSpecificity !== undefined && compareSpecificity(minSpecificity, specificity) < 0) {\n minSpecificity = specificity\n }\n\n if (maxSpecificity !== undefined && compareSpecificity(maxSpecificity, specificity) > 0) {\n maxSpecificity = specificity\n }\n\n specificities.push(specificity)\n complexities.push(complexity)\n }\n\n const aggregatesA = specificityA.aggregate()\n const aggregatesB = specificityB.aggregate()\n const aggregatesC = specificityC.aggregate()\n const complexityCount = new CountableCollection(complexities).count()\n\n return {\n total: totalSelectors,\n totalUnique,\n uniquenessRatio: totalSelectors === 0 ? 0 : totalUnique / totalSelectors,\n specificity: {\n /** @type [number, number, number] */\n min: minSpecificity,\n /** @type [number, number, number] */\n max: maxSpecificity,\n /** @type [number, number, number] */\n sum: [aggregatesA.sum, aggregatesB.sum, aggregatesC.sum],\n /** @type [number, number, number] */\n mean: [aggregatesA.mean, aggregatesB.mean, aggregatesC.mean],\n /** @type [number, number, number] */\n mode: [aggregatesA.mode, aggregatesB.mode, aggregatesC.mode],\n /** @type [number, number, number] */\n median: [aggregatesA.median, aggregatesB.median, aggregatesC.median],\n /** @type [number, number, number][] */\n items: specificities\n },\n complexity: {\n ...complexityAggregator.aggregate(),\n ...complexityCount,\n items: complexities,\n },\n id: {\n ...ids.count(),\n ratio: totalSelectors === 0 ? 0 : ids.size() / totalSelectors,\n },\n accessibility: {\n ...a11y.count(),\n ratio: totalSelectors === 0 ? 0 : a11y.size() / totalSelectors,\n },\n keyframes: {\n ...keyframes.count(),\n ratio: totalSelectors === 0 ? 0 : keyframes.size() / totalSelectors,\n }\n }\n}\n\nexport {\n analyzeSelectors\n}","import { CountableCollection } from '../countable-collection.js'\n\nconst analyzeProperties = ({ properties }) => {\n const all = new CountableCollection(properties.map(p => p.authored))\n const prefixed = new CountableCollection()\n const hacks = new CountableCollection()\n const customs = new CountableCollection()\n const totalProperties = properties.length\n\n for (let i = 0; i < totalProperties; i++) {\n const property = properties[i]\n\n if (property.vendor) {\n prefixed.push(property.authored)\n continue\n }\n\n if (property.hack) {\n hacks.push(property.authored)\n continue\n }\n\n if (property.custom) {\n customs.push(property.authored)\n continue\n }\n }\n\n return {\n ...all.count(),\n prefixed: {\n ...prefixed.count(),\n ratio: prefixed.size() / totalProperties,\n },\n custom: {\n ...customs.count(),\n ratio: customs.size() / totalProperties,\n },\n browserhacks: {\n ...hacks.count(),\n ratio: hacks.size() / totalProperties,\n }\n }\n}\n\nexport {\n analyzeProperties\n}","import { CountableCollection } from '../countable-collection.js'\n\nconst keywords = {\n 'auto': 1,\n 'inherit': 1,\n 'initial': 1,\n 'unset': 1,\n 'revert': 1,\n 'none': 1, // for `text-shadow`\n}\n\nconst analyzeValues = ({ values, stringifyNode }) => {\n const all = new CountableCollection()\n\n for (let i = 0; i < values.length; i++) {\n const node = values[i]\n const firstChild = node.children.first\n\n if (!firstChild) continue\n if (firstChild.type === 'Identifier' && keywords[firstChild.name]) continue\n\n all.push(stringifyNode(node))\n }\n\n return all.count()\n}\n\nexport {\n analyzeValues\n}","import { CountableCollection } from '../countable-collection.js'\n\nconst timingKeywords = {\n 'linear': 1,\n 'ease': 1,\n 'ease-in': 1,\n 'ease-out': 1,\n 'ease-in-out': 1,\n 'step-start': 1,\n 'step-end': 1,\n}\n\nconst analyzeAnimations = ({ animations, durations, timingFunctions, stringifyNode }) => {\n const allDurations = new CountableCollection(durations.map(stringifyNode))\n const allTimingFunctions = new CountableCollection(timingFunctions.map(stringifyNode))\n\n for (let index = 0; index < animations.length; index++) {\n const node = animations[index]\n // Flag to know if we've grabbed the first Duration\n // yet (the first Dimension in a shorthand)\n let durationFound = false\n\n node.value.children.forEach(child => {\n // Right after a ',' we start over again\n if (child.type === 'Operator') {\n return durationFound = false\n }\n if (child.type === 'Dimension' && durationFound === false) {\n durationFound = true\n return allDurations.push(stringifyNode(child))\n }\n if (child.type === 'Identifier' && timingKeywords[child.name]) {\n return allTimingFunctions.push(stringifyNode(child))\n }\n if (child.type === 'Function'\n && (\n child.name === 'cubic-bezier' || child.name === 'steps'\n )\n ) {\n return allTimingFunctions.push(stringifyNode(child))\n }\n })\n }\n\n return {\n durations: allDurations.count(),\n timingFunctions: allTimingFunctions.count(),\n }\n}\n\nexport {\n analyzeAnimations\n}","const HYPHENMINUS = 45; // '-'.charCodeAt()\n\n/**\n * @param {string} keyword\n * @returns {boolean}\n */\nfunction hasVendorPrefix(keyword) {\n if (keyword.charCodeAt(0) === HYPHENMINUS && keyword.charCodeAt(1) !== HYPHENMINUS) {\n // String must have a 2nd occurrence of '-', at least at position 3 (offset=2)\n if (keyword.indexOf('-', 2) !== -1) {\n return true\n }\n }\n\n return false\n}\n\nexport {\n hasVendorPrefix\n}","import { CountableCollection } from '../countable-collection.js'\nimport { hasVendorPrefix } from '../vendor-prefix.js'\n\nfunction isAstVendorPrefixed(children) {\n children = children.toArray()\n\n for (let index = 0; index < children.length; index++) {\n const child = children[index];\n\n if (child.type === 'Identifier' && child.name.length >= 3) {\n if (hasVendorPrefix(child.name)) {\n return true\n }\n }\n\n if (child.type === 'Function') {\n if (hasVendorPrefix(child.name)) {\n return true\n }\n\n if (child.children && isAstVendorPrefixed(child.children)) {\n return true\n }\n }\n }\n return false\n}\n\nconst analyzeVendorPrefixes = ({ values, stringifyNode }) => {\n const all = new CountableCollection()\n\n for (let i = 0; i < values.length; i++) {\n /** @type {import('css-tree').Value} */\n const value = values[i]\n\n if (value.children && isAstVendorPrefixed(value.children)) {\n all.push(stringifyNode(value))\n }\n }\n\n return all.count()\n}\n\nexport {\n analyzeVendorPrefixes\n}","import { CountableCollection } from '../countable-collection.js'\nimport { hasVendorPrefix } from '../vendor-prefix.js'\n\nconst analyzeAtRules = ({ atrules, stringifyNode }) => {\n /** @type {{[index: string]: string}[]} */\n const fontfaces = []\n const imports = new CountableCollection()\n const medias = new CountableCollection()\n const charsets = new CountableCollection()\n const supports = new CountableCollection()\n const keyframes = new CountableCollection()\n const prefixedKeyframes = new CountableCollection()\n const containers = new CountableCollection()\n\n const machine = {\n 'font-face': (node) => {\n /** @type {[index: string]: string} */\n const descriptors = {}\n\n node.block.children.forEach(\n /** @param {import('css-tree').Declaration} descriptor */\n descriptor => (descriptors[descriptor.property] = stringifyNode(descriptor.value))\n )\n\n fontfaces.push(descriptors)\n },\n 'media': node => medias.push(node.prelude.value),\n 'supports': node => supports.push(node.prelude.value),\n 'keyframes': node => keyframes.push(`@${node.name} ${node.prelude.value}`),\n 'import': node => imports.push(node.prelude.value),\n 'charset': node => charsets.push(node.prelude.value),\n 'container': node => containers.push(node.prelude.value),\n }\n\n for (let i = 0; i < atrules.length; i++) {\n /** @type {import('css-tree').Atrule} */\n const node = atrules[i]\n const nodeName = node.name\n const action = machine[nodeName]\n if (action) {\n action(node)\n continue\n }\n\n if (nodeName.endsWith('keyframes')) {\n const name = `@${nodeName} ${node.prelude.value}`\n keyframes.push(name)\n\n if (hasVendorPrefix(nodeName)) {\n prefixedKeyframes.push(name)\n }\n continue\n }\n }\n\n return {\n fontface: {\n total: fontfaces.length,\n totalUnique: fontfaces.length,\n unique: fontfaces,\n uniquenessRatio: 1\n },\n import: imports.count(),\n media: medias.count(),\n charset: charsets.count(),\n supports: supports.count(),\n keyframes: {\n ...keyframes.count(),\n prefixed: {\n ...prefixedKeyframes.count(),\n ratio: keyframes.size() === 0 ? 0 : prefixedKeyframes.size() / keyframes.size()\n }\n },\n container: containers.count(),\n }\n}\n\nexport {\n analyzeAtRules\n}","import { CountableCollection } from './countable-collection.js'\n\nclass ContextCollection {\n constructor() {\n this.list = new CountableCollection()\n /** @type {[index; string]: CountableCollection} */\n this.contexts = {}\n this.contextCount = 0\n }\n\n /**\n * Add an item to this list's context\n * @param {string} item Item to push\n * @param {string} context Context to push Item to\n */\n push(item, context) {\n this.list.push(item)\n\n if (!this.contexts[context]) {\n this.contexts[context] = new CountableCollection()\n this.contextCount++\n }\n\n this.contexts[context].push(item)\n }\n\n count() {\n /** @type {[index: string]: string} */\n const itemsPerContext = {}\n\n for (let context in this.contexts) {\n itemsPerContext[context] = this.contexts[context].count()\n }\n\n return Object.assign(this.list.count(), {\n itemsPerContext\n })\n }\n}\n\nexport {\n ContextCollection\n}","import * as csstree from 'css-tree'\nimport { compareSpecificity } from './selectors/specificity.js'\nimport { analyzeRules } from './rules/rules.js'\nimport { colorFunctions, colorNames } from './values/colors.js'\nimport { analyzeFontFamilies } from './values/font-families.js'\nimport { analyzeFontSizes } from './values/font-sizes.js'\nimport { analyzeDeclarations } from './declarations/declarations.js'\nimport { analyzeSelectors } from './selectors/selectors.js'\nimport { analyzeProperties } from './properties/properties.js'\nimport { analyzeValues } from './values/values.js'\nimport { analyzeAnimations } from './values/animations.js'\nimport { analyzeVendorPrefixes } from './values/vendor-prefix.js'\nimport { analyzeAtRules } from './atrules/atrules.js'\nimport { ContextCollection } from './context-collection.js'\nimport { CountableCollection } from './countable-collection.js'\n\n/**\n * Analyze CSS\n * @param {string} css\n */\nconst analyze = (css) => {\n const start = new Date()\n\n // We need all lines later on when we need to stringify the AST again\n // e.g. for Selectors\n const lines = css.split(/\\r?\\n/)\n\n /**\n * Recreate the authored CSS from a CSSTree node\n * @param {import('css-tree').CssNode} node - Node from CSSTree AST to stringify\n * @returns {string} str - The stringified node\n */\n function stringifyNode(node) {\n const start = node.loc.start\n const end = node.loc.end\n const lineCount = end.line - start.line\n\n // Single-line nodes\n if (lineCount === 0) {\n return lines[start.line - 1].substring(start.column - 1, end.column - 1)\n }\n\n // Multi-line nodes\n const value = []\n\n for (let i = start.line; i <= end.line; i++) {\n const line = lines[i - 1]\n // First line\n if (i === start.line) {\n value.push(line.substring(start.column - 1))\n continue\n }\n // Last line\n if (i === end.line) {\n value.push(line.substring(0, end.column - 1))\n continue\n }\n // All lines in between first and last\n value.push(line)\n }\n\n return value.join('\\n')\n }\n\n const startParse = new Date()\n let totalComments = 0\n let commentsSize = 0\n\n const ast = csstree.parse(css, {\n parseAtrulePrelude: false,\n parseCustomProperty: true, // To find font-families, colors, etc.\n positions: true, // So we can use stringifyNode()\n onComment: function (comment) {\n totalComments++\n commentsSize += comment.length\n },\n })\n\n const startAnalysis = new Date()\n const atrules = []\n const rules = []\n const selectors = []\n const declarations = []\n const properties = []\n const values = []\n const zindex = []\n const textShadows = []\n const boxShadows = []\n const fontValues = []\n const fontFamilyValues = []\n const fontSizeValues = []\n const animations = []\n const timingFunctions = []\n const durations = []\n const colors = new ContextCollection()\n const units = new ContextCollection()\n const embeds = new CountableCollection()\n\n csstree.walk(ast, {\n enter: function (node) {\n switch (node.type) {\n case 'Atrule': {\n atrules.push(node)\n break\n }\n case 'Rule': {\n rules.push(node)\n break\n }\n case 'Selector': {\n selectors.push({\n ...node,\n isKeyframeSelector: this.atrule && this.atrule.name.endsWith('keyframes')\n })\n\n // Avoid further walking of selectors to not mess with\n // our specificity calculations in case of a selector\n // with :where() or :is() that contain SelectorLists\n // as children\n return this.skip\n }\n case 'Dimension': {\n if (!this.declaration) {\n break\n }\n\n units.push(node.unit, this.declaration.property)\n\n return this.skip\n }\n case 'Url': {\n if (node.value.startsWith('data:')) {\n embeds.push(node.value)\n }\n break\n }\n case 'Declaration': {\n declarations.push({\n ...node,\n inKeyframe: this.atrule && this.atrule.name.endsWith('keyframes')\n })\n\n const { value, property } = node\n const fullProperty = {\n authored: property,\n ...csstree.property(property)\n }\n\n properties.push(fullProperty)\n values.push(value)\n\n switch (fullProperty.basename) {\n case 'z-index': {\n zindex.push(value)\n break\n }\n case 'text-shadow': {\n textShadows.push(value)\n break\n }\n case 'box-shadow': {\n boxShadows.push(value)\n break\n }\n case 'font': {\n fontValues.push(value)\n break\n }\n case 'font-family': {\n fontFamilyValues.push(stringifyNode(value))\n // Prevent analyzer to find color names in this property\n return this.skip\n }\n case 'font-size': {\n fontSizeValues.push(stringifyNode(value))\n break\n }\n case 'transition':\n case 'animation': {\n animations.push(node)\n break\n }\n case 'animation-duration':\n case 'transition-duration': {\n durations.push(value)\n break\n }\n case 'transition-timing-function':\n case 'animation-timing-function': {\n timingFunctions.push(value)\n break\n }\n }\n\n csstree.walk(node.value, {\n enter: function (valueNode) {\n switch (valueNode.type) {\n case 'Hash': {\n colors.push(stringifyNode(valueNode), property)\n\n return this.skip\n }\n case 'Identifier': {\n const { name } = valueNode\n // Bail out if it can't be a color name\n // 20 === 'lightgoldenrodyellow'.length\n // 3 === 'red'.length\n if (name.length > 20 || name.length < 3) {\n return this.skip\n }\n if (colorNames[name.toLowerCase()]) {\n colors.push(stringifyNode(valueNode), property)\n }\n return this.skip\n }\n case 'Function': {\n if (colorFunctions[valueNode.name.toLowerCase()]) {\n colors.push(stringifyNode(valueNode), property)\n }\n // No this.skip here intentionally,\n // otherwise we'll miss colors in linear-gradient() etc.\n }\n }\n }\n })\n }\n }\n }\n })\n const embeddedContent = embeds.count()\n const embedSize = Object.keys(embeddedContent.unique).join('').length\n\n return {\n stylesheet: {\n sourceLinesOfCode: atrules.length + selectors.length + declarations.length,\n linesOfCode: lines.length,\n size: css.length,\n comments: {\n total: totalComments,\n size: commentsSize,\n },\n embeddedContent: Object.assign(embeddedContent, {\n size: {\n total: embedSize,\n ratio: css.length === 0 ? 0 : embedSize / css.length,\n },\n }),\n },\n atrules: analyzeAtRules({ atrules, stringifyNode }),\n rules: analyzeRules({ rules }),\n selectors: analyzeSelectors({ stringifyNode, selectors }),\n declarations: analyzeDeclarations({ stringifyNode, declarations }),\n properties: analyzeProperties({ properties }),\n values: {\n colors: colors.count(),\n fontFamilies: analyzeFontFamilies({ stringifyNode, fontValues, fontFamilyValues }),\n fontSizes: analyzeFontSizes({ stringifyNode, fontValues, fontSizeValues }),\n zindexes: analyzeValues({ values: zindex, stringifyNode }),\n textShadows: analyzeValues({ values: textShadows, stringifyNode }),\n boxShadows: analyzeValues({ values: boxShadows, stringifyNode }),\n animations: analyzeAnimations({ animations, timingFunctions, durations, stringifyNode }),\n prefixes: analyzeVendorPrefixes({ values, stringifyNode }),\n units: units.count(),\n },\n __meta__: {\n parseTime: startAnalysis - startParse,\n analyzeTime: new Date() - startAnalysis,\n total: new Date() - start\n }\n }\n}\n\nexport {\n analyze,\n compareSpecificity,\n}\n"],"names":["compareSpecificity","a","b","selectorListSpecificities","selectorListAst","childSelectors","csstree","walk","visit","enter","node","push","analyzeSpecificity","sort","specificity","ast","A","B","C","complexity","isA11y","selector","type","Boolean","value","name","startsWith","includes","skip","rawSelectorList","find","selectorList","parse","context","i","length","isId","AggregateCollection","size","this","items","Uint8Array","sum","cursor","add","item","aggregate","min","max","mean","mode","median","range","arr","middle","lowerMiddleRank","sorted","slice","frequencies","Object","create","maxOccurrences","maxOccurenceCount","element","updatedCount","Mode","Math","floor","toArray","Array","from","subarray","analyzeRules","rules","totalRules","selectorsPerRule","declarationsPerRule","emptyRules","selectors","declarations","childNode","total","empty","ratio","colorNames","aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen","canvas","canvastext","linktext","visitedtext","activetext","buttonface","buttontext","buttonborder","field","fieldtext","highlight","highlighttext","selecteditem","selecteditemtext","mark","marktext","graytext","colorFunctions","rgb","rgba","hsl","hsla","hwb","lab","lch","oklab","oklch","color","CountableCollection","initial","totalUnique","index","count","unique","uniquenessRatio","systemKeywords","inherit","unset","revert","caption","icon","menu","keywordDisallowList","normal","small","medium","large","larger","smaller","bold","bolder","lighter","condensed","expanded","italic","oblique","analyzeFontFamilies","fontValues","all","fontFamilyValues","firstChild","children","first","parts","reverse","fontNode","charCodeAt","unshift","map","generate","join","sizeKeywords","keywords","analyzeFontSizes","stringifyNode","fontSizeValues","operator","analyzeDeclarations","cache","importants","totalInKeyframes","declaration","important","inKeyframe","stringified","inKeyframes","analyzeSelectors","maxSpecificity","minSpecificity","counts","totalSelectors","specificityA","specificityB","specificityC","complexityAggregator","specificities","complexities","ids","a11y","keyframes","isKeyframeSelector","undefined","aggregatesA","aggregatesB","aggregatesC","complexityCount","id","accessibility","analyzeProperties","properties","p","authored","prefixed","hacks","customs","totalProperties","property","vendor","hack","custom","browserhacks","auto","none","analyzeValues","values","timingKeywords","linear","ease","analyzeAnimations","animations","timingFunctions","allDurations","durations","allTimingFunctions","durationFound","forEach","child","hasVendorPrefix","keyword","indexOf","isAstVendorPrefixed","analyzeVendorPrefixes","analyzeAtRules","atrules","fontfaces","imports","medias","charsets","supports","prefixedKeyframes","containers","machine","descriptors","block","descriptor","media","prelude","import","charset","container","nodeName","action","endsWith","fontface","ContextCollection","list","contexts","contextCount","itemsPerContext","assign","analyze","css","start","Date","lines","split","loc","end","line","substring","column","startParse","totalComments","commentsSize","parseAtrulePrelude","parseCustomProperty","positions","onComment","comment","startAnalysis","zindex","textShadows","boxShadows","colors","units","embeds","atrule","unit","fullProperty","basename","valueNode","toLowerCase","embeddedContent","embedSize","keys","stylesheet","sourceLinesOfCode","linesOfCode","comments","fontFamilies","fontSizes","zindexes","prefixes","__meta__","parseTime","analyzeTime"],"mappings":"2OAQA,SAASA,EAAmBC,EAAGC,GAC7B,OAAID,EAAE,KAAOC,EAAE,GACTD,EAAE,KAAOC,EAAE,GACNA,EAAE,GAAKD,EAAE,GAGXC,EAAE,GAAKD,EAAE,GAGXC,EAAE,GAAKD,EAAE,GAQlB,SAASE,EAA0BC,GACjC,IAAMC,EAAiB,GAQvB,OAPAC,EAAQC,KAAKH,EAAiB,CAC5BI,MAAO,WACPC,eAAMC,GACJL,EAAeM,KAAKC,EAAmBF,OAIpCL,EAAeQ,KAAK,SAACZ,EAAGC,UAAMF,EAAmBC,EAAEa,YAAaZ,EAAEY,eAY3E,IAAMF,EAAqB,SAACG,GAC1B,IAAIC,EAAI,EACJC,EAAI,EACJC,EAAI,EACJC,EAAa,EACbC,GAAS,EAqIb,OAnIAd,EAAQC,KAAKQ,EAAK,CAChBN,MAAO,SAAUY,GACf,OAAQA,EAASC,MACf,IAAK,aACHN,IACAG,IACA,MAEF,IAAK,gBACHF,IACAE,IACA,MAEF,IAAK,oBACHF,IACAE,IAEII,QAAQF,EAASG,QACnBL,IAEFC,EAAgC,SAAvBC,EAASI,KAAKA,MAAmBJ,EAASI,KAAKA,KAAKC,WAAW,SACxE,MAE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epO,aAAAA,IACnDuQ,WAAYD,EAAkB,CAAEC,WAAAA,IAChCe,OAAQ,CACNqE,OAAQA,EAAOjK,QACfiL,aAAczJ,EAAoB,CAAEkB,cAAAA,EAAejB,WAAAA,EAAYE,iBAAAA,IAC/DuJ,UAAWzI,EAAiB,CAAEC,cAAAA,EAAejB,WAAAA,EAAYkB,eAAAA,IACzDwI,SAAUxF,EAAc,CAAEC,OAAQkE,EAAQpH,cAAAA,IAC1CqH,YAAapE,EAAc,CAAEC,OAAQmE,EAAarH,cAAAA,IAClDsH,WAAYrE,EAAc,CAAEC,OAAQoE,EAAYtH,cAAAA,IAChDuD,WAAYD,EAAkB,CAAEC,WAAAA,EAAYC,gBAAAA,EAAiBE,UAAAA,EAAW1D,cAAAA,IACxE0I,SAAUvE,EAAsB,CAAEjB,OAAAA,EAAQlD,cAAAA,IAC1CwH,MAAOA,EAAMlK,SAEfqL,SAAU,CACRC,UAAWzB,EAAgBR,EAC3BkC,YAAa,IAAI1C,KAASgB,EAC1BrV,MAAO,IAAIqU,KAASD"}
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("css-tree")):"function"==typeof define&&define.amd?define(["exports","css-tree"],t):t((e||self).cssAnalyzer={},e.cssTree)}(this,function(e,t){function n(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e,t}var r=/*#__PURE__*/n(t);function i(){return i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},i.apply(this,arguments)}function a(e,t){return e[0]===t[0]?e[1]===t[1]?t[2]-e[2]:t[1]-e[1]:t[0]-e[0]}function s(e){var t=[];return r.walk(e,{visit:"Selector",enter:function(e){t.push(o(e))}}),t.sort(function(e,t){return a(e.specificity,t.specificity)})}var o=function(e){var t=0,n=0,i=0,a=0,o=!1;return r.walk(e,{enter:function(e){switch(e.type){case"IdSelector":t++,a++;break;case"ClassSelector":n++,a++;break;case"AttributeSelector":n++,a++,Boolean(e.value)&&a++,o="role"===e.name.name||e.name.name.startsWith("aria-");break;case"PseudoElementSelector":case"TypeSelector":"*"!==e.name&&i++,a++;break;case"PseudoClassSelector":if(["before","after","first-letter","first-line"].includes(e.name))return i++,a++,this.skip;if(["is","has","matches"].includes(e.name)){var u=r.find(e,function(e){return"Raw"===e.type}),l=s(r.parse(u.value,{context:"selectorList"})),c=l[0].specificity;t+=c[0],n+=c[1],i+=c[2];for(var h=0;h<l.length;h++)a+=l[h].complexity;return void a++}if("not"===e.name){var d=s(e),f=d[0].specificity;t+=f[0],n+=f[1],i+=f[2];for(var m=0;m<d.length;m++)a+=d[m].complexity;return a++,this.skip}if(["nth-child","nth-last-child"].includes(e.name)){n++;var p=s(e);if(0===p.length)return;var g=p[0].specificity;t+=g[0],n+=g[1],i+=g[2];for(var y=0;y<p.length;y++)a+=p[y].complexity;return void a++}if("where"===e.name){for(var v=r.find(e,function(e){return"Raw"===e.type}),b=s(r.parse(v.value,{context:"selectorList"})),w=0;w<b.length;w++)a+=b[w].complexity;return void a++}a++,n++;break;case"Combinator":a++}}}),{specificity:[t,n,i],complexity:a,isId:t>0,isA11y:o}},u=/*#__PURE__*/function(){function e(e){this.items=new Uint8Array(e),this.sum=0,this.cursor=0}var t=e.prototype;return t.add=function(e){this.items[this.cursor]=e,this.sum+=e,this.cursor++},t.aggregate=function(){if(0===this.cursor)return{min:0,max:0,mean:0,mode:0,median:0,range:0,sum:0};var e,t,n,r=new Uint8Array(this.items.slice(0,this.cursor)).sort(function(e,t){return e-t}),i=r[0],a=r[r.length-1],s=function(e){for(var t=Object.create(null),n=-1,r=0,i=0,a=0;a<e.length;a++){var s=e[a],o=(t[s]||0)+1;t[s]=o,o>n&&(n=o,r=0,i=0),o>=n&&(r++,i+=s)}return i/r}(r),o=(t=(e=r).length/2)!==(n=Math.floor(t))?e[n]:(e[n]+e[n-1])/2;return{min:i,max:a,mean:this.sum/this.cursor,mode:s,median:o,range:a-i,sum:this.sum}},t.toArray=function(){return Array.from(this.items.subarray(0,this.cursor))},e}(),l=function(e){for(var t=e.rules,n=t.length,a=new u(n),s=new u(n),o=0,l=function(e){var n=0,i=0;r.walk(t[e],{enter:function(e){return"Selector"===e.type?(n++,this.skip):"Declaration"===e.type?(i++,this.skip):void 0}}),0===i&&o++,a.add(n),s.add(i)},c=0;c<n;c++)l(c);return{total:n,empty:{total:o,ratio:0===n?0:o/n},selectors:i({},a.aggregate(),{items:a.toArray()}),declarations:i({},s.aggregate(),{items:s.toArray()})}},c={aliceblue:1,antiquewhite:1,aqua:1,aquamarine:1,azure:1,beige:1,bisque:1,black:1,blanchedalmond:1,blue:1,blueviolet:1,brown:1,burlywood:1,cadetblue:1,chartreuse:1,chocolate:1,coral:1,cornflowerblue:1,cornsilk:1,crimson:1,cyan:1,darkblue:1,darkcyan:1,darkgoldenrod:1,darkgray:1,darkgreen:1,darkgrey:1,darkkhaki:1,darkmagenta:1,darkolivegreen:1,darkorange:1,darkorchid:1,darkred:1,darksalmon:1,darkseagreen:1,darkslateblue:1,darkslategray:1,darkslategrey:1,darkturquoise:1,darkviolet:1,deeppink:1,deepskyblue:1,dimgray:1,dimgrey:1,dodgerblue:1,firebrick:1,floralwhite:1,forestgreen:1,fuchsia:1,gainsboro:1,ghostwhite:1,gold:1,goldenrod:1,gray:1,green:1,greenyellow:1,grey:1,honeydew:1,hotpink:1,indianred:1,indigo:1,ivory:1,khaki:1,lavender:1,lavenderblush:1,lawngreen:1,lemonchiffon:1,lightblue:1,lightcoral:1,lightcyan:1,lightgoldenrodyellow:1,lightgray:1,lightgreen:1,lightgrey:1,lightpink:1,lightsalmon:1,lightseagreen:1,lightskyblue:1,lightslategray:1,lightslategrey:1,lightsteelblue:1,lightyellow:1,lime:1,limegreen:1,linen:1,magenta:1,maroon:1,mediumaquamarine:1,mediumblue:1,mediumorchid:1,mediumpurple:1,mediumseagreen:1,mediumslateblue:1,mediumspringgreen:1,mediumturquoise:1,mediumvioletred:1,midnightblue:1,mintcream:1,mistyrose:1,moccasin:1,navajowhite:1,navy:1,oldlace:1,olive:1,olivedrab:1,orange:1,orangered:1,orchid:1,palegoldenrod:1,palegreen:1,paleturquoise:1,palevioletred:1,papayawhip:1,peachpuff:1,peru:1,pink:1,plum:1,powderblue:1,purple:1,rebeccapurple:1,red:1,rosybrown:1,royalblue:1,saddlebrown:1,salmon:1,sandybrown:1,seagreen:1,seashell:1,sienna:1,silver:1,skyblue:1,slateblue:1,slategray:1,slategrey:1,snow:1,springgreen:1,steelblue:1,tan:1,teal:1,thistle:1,tomato:1,turquoise:1,violet:1,wheat:1,white:1,whitesmoke:1,yellow:1,yellowgreen:1,canvas:1,canvastext:1,linktext:1,visitedtext:1,activetext:1,buttonface:1,buttontext:1,buttonborder:1,field:1,fieldtext:1,highlight:1,highlighttext:1,selecteditem:1,selecteditemtext:1,mark:1,marktext:1,graytext:1},h={rgb:1,rgba:1,hsl:1,hsla:1,hwb:1,lab:1,lch:1,oklab:1,oklch:1,color:1},d=/*#__PURE__*/function(){function e(e){if(this.items={},this.total=0,this.totalUnique=0,e)for(var t=0;t<e.length;t++)this.push(e[t])}var t=e.prototype;return t.push=function(e){this.total++,this.items[e]?this.items[e]++:(this.items[e]=1,this.totalUnique++)},t.size=function(){return this.total},t.count=function(){return{total:this.total,totalUnique:this.totalUnique,unique:this.items,uniquenessRatio:0===this.total?0:this.totalUnique/this.total}},e}(),f={inherit:1,initial:1,unset:1,revert:1,caption:1,icon:1,menu:1,"message-box":1,"small-caption":1,"status-bar":1},m={normal:1,"xx-small":1,"x-small":1,small:1,medium:1,large:1,"x-large":1,"xx-large":1,larger:1,smaller:1,bold:1,bolder:1,lighter:1,"ultra-condensed":1,"extra-condensed":1,condensed:1,"semi-condensed":1,"semi-expanded":1,expanded:1,"extra-expanded":1,"ultra-expanded":1,italic:1,oblique:1},p=function(e){for(var t=e.fontValues,n=new d(e.fontFamilyValues),i=function(e){var i=t[e],a=i.children.first;if("Identifier"===a.type&&f[a.name])return"continue";var s=[];r.walk(i,{reverse:!0,enter:function(e){return"String"===e.type||"Operator"===e.type&&44===e.value.charCodeAt(0)?s.unshift(e):"Identifier"===e.type?m[e.name]?this.skip:s.unshift(e):void 0}}),n.push(s.map(r.generate).join(""))},a=0;a<t.length;a++)i(a);return n.count()},g={"xx-small":1,"x-small":1,small:1,medium:1,large:1,"x-large":1,"xx-large":1,larger:1,smaller:1},y={inherit:1,initial:1,unset:1,revert:1,caption:1,icon:1,menu:1,"message-box":1,"small-caption":1,"status-bar":1},v=function(e){for(var t=e.stringifyNode,n=e.fontValues,i=new d(e.fontSizeValues),a=function(e){var a=n[e],s=a.children.first;if("Identifier"===s.type&&y[s.name])return"continue";var o=!1,u=void 0;r.walk(a,{enter:function(e){switch(e.type){case"Number":if(48===e.value.charCodeAt(0))return u="0",this.break;case"Operator":47===e.value.charCodeAt(0)&&(o=!0);break;case"Dimension":if(!o)return u=t(e),this.break;case"Identifier":if(g[e.name])return u=e.name,this.break}}}),u&&i.push(u)},s=0;s<n.length;s++)a(s);return i.count()},b=function(e){for(var t=e.stringifyNode,n=e.declarations,r=n.length,i=Object.create(null),a=0,s=0,o=0,u=0;u<r;u++){var l=n[u];!0===l.important&&(a++,l.inKeyframe&&o++);var c=t(l);i[c]||(i[c]=1,s++)}return{total:r,unique:{total:s,ratio:0===r?0:s/r},importants:{total:a,ratio:0===r?0:a/r,inKeyframes:{total:o,ratio:0===a?0:o/a}}}},w=function(e){for(var t,n,r=e.stringifyNode,s=e.selectors,l=Object.create(null),c=Object.create(null),h=s.length,f=new u(h),m=new u(h),p=new u(h),g=0,y=new u(h),v=[],b=[],w=new d,k=new d,x=new d,q=0;q<h;q++){var z=s[q],A=r(z);if(z.isKeyframeSelector)x.push(A);else{var O=c[A]||o(z),N=O.specificity,S=O.complexity,C=O.isId,j=O.isA11y;C&&w.push(A),j&&k.push(A),c[A]?l[A]++:(c[A]={complexity:S,specificity:N,isId:C,isA11y:j},g++,l[A]=1),y.add(S),void 0===t&&(t=N),void 0===n&&(n=N),f.add(N[0]),m.add(N[1]),p.add(N[2]),void 0!==n&&a(n,N)<0&&(n=N),void 0!==t&&a(t,N)>0&&(t=N),v.push(N),b.push(S)}}var I=f.aggregate(),D=m.aggregate(),F=p.aggregate(),U=new d(b).count();return{total:h,totalUnique:g,uniquenessRatio:0===h?0:g/h,specificity:{sum:[I.sum,D.sum,F.sum],min:n,max:t,mean:[I.mean,D.mean,F.mean],mode:[I.mode,D.mode,F.mode],median:[I.median,D.median,F.median],items:v},complexity:i({},y.aggregate(),U,{items:b}),id:i({},w.count(),{ratio:0===h?0:w.size()/h}),accessibility:i({},k.count(),{ratio:0===h?0:k.size()/h}),keyframes:i({},x.count(),{ratio:0===h?0:x.size()/h})}},k=function(e){for(var t=e.properties,n=new d(t.map(function(e){return e.authored})),r=new d,a=new d,s=new d,o=t.length,u=0;u<o;u++){var l=t[u];l.vendor?r.push(l.authored):l.hack?a.push(l.authored):l.custom&&s.push(l.authored)}return i({},n.count(),{prefixed:i({},r.count(),{ratio:r.size()/o}),custom:i({},s.count(),{ratio:s.size()/o}),browserhacks:i({},a.count(),{ratio:a.size()/o})})},x={auto:1,inherit:1,initial:1,unset:1,revert:1,none:1},q=function(e){for(var t=e.values,n=e.stringifyNode,r=new d,i=0;i<t.length;i++){var a=t[i],s=a.children.first;s&&("Identifier"===s.type&&x[s.name]||r.push(n(a)))}return r.count()},z={linear:1,ease:1,"ease-in":1,"ease-out":1,"ease-in-out":1,"step-start":1,"step-end":1},A=function(e){for(var t=e.animations,n=e.timingFunctions,r=e.stringifyNode,i=new d(e.durations.map(r)),a=new d(n.map(r)),s=function(e){var n=!1;t[e].value.children.forEach(function(e){return"Operator"===e.type?n=!1:"Dimension"===e.type&&!1===n?(n=!0,i.push(r(e))):"Identifier"===e.type&&z[e.name]?a.push(r(e)):"Function"!==e.type||"cubic-bezier"!==e.name&&"steps"!==e.name?void 0:a.push(r(e))})},o=0;o<t.length;o++)s(o);return{durations:i.count(),timingFunctions:a.count()}};function O(e){return 45===e.charCodeAt(0)&&45!==e.charCodeAt(1)&&-1!==e.indexOf("-",2)}function N(e){e=e.toArray();for(var t=0;t<e.length;t++){var n=e[t];if("Identifier"===n.type&&n.name.length>=3&&O(n.name))return!0;if("Function"===n.type){if(O(n.name))return!0;if(n.children&&N(n.children))return!0}}return!1}var S=function(e){for(var t=e.values,n=e.stringifyNode,r=new d,i=0;i<t.length;i++){var a=t[i];a.children&&N(a.children)&&r.push(n(a))}return r.count()},C=function(e){for(var t=e.atrules,n=e.stringifyNode,r=[],a=new d,s=new d,o=new d,u=new d,l=new d,c=new d,h=new d,f={"font-face":function(e){var t={};e.block.children.forEach(function(e){t[e.property]=n(e.value)}),r.push(t)},media:function(e){return s.push(e.prelude.value)},supports:function(e){return u.push(e.prelude.value)},keyframes:function(e){return l.push("@"+e.name+" "+e.prelude.value)},import:function(e){return a.push(e.prelude.value)},charset:function(e){return o.push(e.prelude.value)},container:function(e){return h.push(e.prelude.value)}},m=0;m<t.length;m++){var p=t[m],g=p.name,y=f[g];if(y)y(p);else if(g.endsWith("keyframes")){var v="@"+g+" "+p.prelude.value;l.push(v),O(g)&&c.push(v)}}return{fontface:{total:r.length,totalUnique:r.length,unique:r,uniquenessRatio:1},import:a.count(),media:s.count(),charset:o.count(),supports:u.count(),keyframes:i({},l.count(),{prefixed:i({},c.count(),{ratio:0===l.size()?0:c.size()/l.size()})}),container:h.count()}},j=/*#__PURE__*/function(){function e(){this.list=new d,this.contexts={},this.contextCount=0}var t=e.prototype;return t.push=function(e,t){this.list.push(e),this.contexts[t]||(this.contexts[t]=new d,this.contextCount++),this.contexts[t].push(e)},t.count=function(){var e={};for(var t in this.contexts)e[t]=this.contexts[t].count();return Object.assign(this.list.count(),{itemsPerContext:e})},e}();e.analyze=function(e){var t=new Date,n=e.split(/\r?\n/);function a(e){var t=e.loc.start,r=e.loc.end;if(0==r.line-t.line)return n[t.line-1].substring(t.column-1,r.column-1);for(var i=[],a=t.line;a<=r.line;a++){var s=n[a-1];i.push(a!==t.line?a!==r.line?s:s.substring(0,r.column-1):s.substring(t.column-1))}return i.join("\n")}var s,o=new Date,u=0,d=0,f=r.parse(e,{parseAtrulePrelude:!1,parseCustomProperty:!0,positions:!0,onComment:function(e){u++,d+=e.length}}),m=new Date,g=[],y=[],x=[],z=[],O=[],N=[],I=[],D=[],F=[],U=[],P=[],V=[],R=[],T=[],_=[],K=new j,L=new j;return r.walk(f,{enter:function(e){switch(e.type){case"Atrule":g.push(e);break;case"Rule":y.push(e);break;case"Selector":return x.push(i({},e,{isKeyframeSelector:this.atrule&&this.atrule.name.endsWith("keyframes")})),this.skip;case"Dimension":if(!this.declaration)break;return L.push(e.unit,this.declaration.property),this.skip;case"Declaration":z.push(i({},e,{inKeyframe:this.atrule&&this.atrule.name.endsWith("keyframes")}));var t=e.value,n=e.property,s=i({authored:n},r.property(n));switch(O.push(s),N.push(t),s.basename){case"z-index":I.push(t);break;case"text-shadow":D.push(t);break;case"box-shadow":F.push(t);break;case"font":U.push(t);break;case"font-family":return P.push(a(t)),this.skip;case"font-size":V.push(a(t));break;case"transition":case"animation":R.push(e);break;case"animation-duration":case"transition-duration":_.push(t);break;case"transition-timing-function":case"animation-timing-function":T.push(t)}r.walk(e.value,{enter:function(e){switch(e.type){case"Hash":return K.push(a(e),n),this.skip;case"Identifier":var t=e.name;return t.length>20||t.length<3||c[t.toLowerCase()]&&K.push(a(e),n),this.skip;case"Function":h[e.name.toLowerCase()]&&K.push(a(e),n)}}})}}}),{stylesheet:{sourceLinesOfCode:g.length+x.length+z.length,linesOfCode:n.length,size:e.length,comments:{total:u,size:d}},atrules:C({atrules:g,stringifyNode:a}),rules:l({rules:y}),selectors:w({stringifyNode:a,selectors:x}),declarations:b({stringifyNode:a,declarations:z}),properties:k({properties:O}),values:{colors:(s={colors:K},s.colors.count()),fontFamilies:p({stringifyNode:a,fontValues:U,fontFamilyValues:P}),fontSizes:v({stringifyNode:a,fontValues:U,fontSizeValues:V}),zindexes:q({values:I,stringifyNode:a}),textShadows:q({values:D,stringifyNode:a}),boxShadows:q({values:F,stringifyNode:a}),animations:A({animations:R,timingFunctions:T,durations:_,stringifyNode:a}),prefixes:S({values:N,stringifyNode:a}),units:L.count()},__meta__:{parseTime:m-o,analyzeTime:new Date-m,total:new Date-t}}},e.compareSpecificity=a});
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("css-tree")):"function"==typeof define&&define.amd?define(["exports","css-tree"],t):t((e||self).cssAnalyzer={},e.cssTree)}(this,function(e,t){function n(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e,t}var r=/*#__PURE__*/n(t);function i(){return i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},i.apply(this,arguments)}function a(e,t){return e[0]===t[0]?e[1]===t[1]?t[2]-e[2]:t[1]-e[1]:t[0]-e[0]}function s(e){var t=[];return r.walk(e,{visit:"Selector",enter:function(e){t.push(o(e))}}),t.sort(function(e,t){return a(e.specificity,t.specificity)})}var o=function(e){var t=0,n=0,i=0,a=0,o=!1;return r.walk(e,{enter:function(e){switch(e.type){case"IdSelector":t++,a++;break;case"ClassSelector":n++,a++;break;case"AttributeSelector":n++,a++,Boolean(e.value)&&a++,o="role"===e.name.name||e.name.name.startsWith("aria-");break;case"PseudoElementSelector":case"TypeSelector":"*"!==e.name&&i++,a++;break;case"PseudoClassSelector":if(["before","after","first-letter","first-line"].includes(e.name))return i++,a++,this.skip;if(["is","has","matches"].includes(e.name)){var u=r.find(e,function(e){return"Raw"===e.type}),l=s(r.parse(u.value,{context:"selectorList"})),c=l[0].specificity;t+=c[0],n+=c[1],i+=c[2];for(var h=0;h<l.length;h++)a+=l[h].complexity;return void a++}if("not"===e.name){var d=s(e),f=d[0].specificity;t+=f[0],n+=f[1],i+=f[2];for(var m=0;m<d.length;m++)a+=d[m].complexity;return a++,this.skip}if(["nth-child","nth-last-child"].includes(e.name)){n++;var p=s(e);if(0===p.length)return;var g=p[0].specificity;t+=g[0],n+=g[1],i+=g[2];for(var y=0;y<p.length;y++)a+=p[y].complexity;return void a++}if("where"===e.name){for(var v=r.find(e,function(e){return"Raw"===e.type}),b=s(r.parse(v.value,{context:"selectorList"})),k=0;k<b.length;k++)a+=b[k].complexity;return void a++}a++,n++;break;case"Combinator":a++}}}),{specificity:[t,n,i],complexity:a,isId:t>0,isA11y:o}},u=/*#__PURE__*/function(){function e(e){this.items=new Uint8Array(e),this.sum=0,this.cursor=0}var t=e.prototype;return t.add=function(e){this.items[this.cursor]=e,this.sum+=e,this.cursor++},t.aggregate=function(){if(0===this.cursor)return{min:0,max:0,mean:0,mode:0,median:0,range:0,sum:0};var e,t,n,r=new Uint8Array(this.items.slice(0,this.cursor)).sort(function(e,t){return e-t}),i=r[0],a=r[r.length-1],s=function(e){for(var t=Object.create(null),n=-1,r=0,i=0,a=0;a<e.length;a++){var s=e[a],o=(t[s]||0)+1;t[s]=o,o>n&&(n=o,r=0,i=0),o>=n&&(r++,i+=s)}return i/r}(r),o=(t=(e=r).length/2)!==(n=Math.floor(t))?e[n]:(e[n]+e[n-1])/2;return{min:i,max:a,mean:this.sum/this.cursor,mode:s,median:o,range:a-i,sum:this.sum}},t.toArray=function(){return Array.from(this.items.subarray(0,this.cursor))},e}(),l=function(e){for(var t=e.rules,n=t.length,a=new u(n),s=new u(n),o=0,l=function(e){var n=0,i=0;r.walk(t[e],{enter:function(e){return"Selector"===e.type?(n++,this.skip):"Declaration"===e.type?(i++,this.skip):void 0}}),0===i&&o++,a.add(n),s.add(i)},c=0;c<n;c++)l(c);return{total:n,empty:{total:o,ratio:0===n?0:o/n},selectors:i({},a.aggregate(),{items:a.toArray()}),declarations:i({},s.aggregate(),{items:s.toArray()})}},c={aliceblue:1,antiquewhite:1,aqua:1,aquamarine:1,azure:1,beige:1,bisque:1,black:1,blanchedalmond:1,blue:1,blueviolet:1,brown:1,burlywood:1,cadetblue:1,chartreuse:1,chocolate:1,coral:1,cornflowerblue:1,cornsilk:1,crimson:1,cyan:1,darkblue:1,darkcyan:1,darkgoldenrod:1,darkgray:1,darkgreen:1,darkgrey:1,darkkhaki:1,darkmagenta:1,darkolivegreen:1,darkorange:1,darkorchid:1,darkred:1,darksalmon:1,darkseagreen:1,darkslateblue:1,darkslategray:1,darkslategrey:1,darkturquoise:1,darkviolet:1,deeppink:1,deepskyblue:1,dimgray:1,dimgrey:1,dodgerblue:1,firebrick:1,floralwhite:1,forestgreen:1,fuchsia:1,gainsboro:1,ghostwhite:1,gold:1,goldenrod:1,gray:1,green:1,greenyellow:1,grey:1,honeydew:1,hotpink:1,indianred:1,indigo:1,ivory:1,khaki:1,lavender:1,lavenderblush:1,lawngreen:1,lemonchiffon:1,lightblue:1,lightcoral:1,lightcyan:1,lightgoldenrodyellow:1,lightgray:1,lightgreen:1,lightgrey:1,lightpink:1,lightsalmon:1,lightseagreen:1,lightskyblue:1,lightslategray:1,lightslategrey:1,lightsteelblue:1,lightyellow:1,lime:1,limegreen:1,linen:1,magenta:1,maroon:1,mediumaquamarine:1,mediumblue:1,mediumorchid:1,mediumpurple:1,mediumseagreen:1,mediumslateblue:1,mediumspringgreen:1,mediumturquoise:1,mediumvioletred:1,midnightblue:1,mintcream:1,mistyrose:1,moccasin:1,navajowhite:1,navy:1,oldlace:1,olive:1,olivedrab:1,orange:1,orangered:1,orchid:1,palegoldenrod:1,palegreen:1,paleturquoise:1,palevioletred:1,papayawhip:1,peachpuff:1,peru:1,pink:1,plum:1,powderblue:1,purple:1,rebeccapurple:1,red:1,rosybrown:1,royalblue:1,saddlebrown:1,salmon:1,sandybrown:1,seagreen:1,seashell:1,sienna:1,silver:1,skyblue:1,slateblue:1,slategray:1,slategrey:1,snow:1,springgreen:1,steelblue:1,tan:1,teal:1,thistle:1,tomato:1,turquoise:1,violet:1,wheat:1,white:1,whitesmoke:1,yellow:1,yellowgreen:1,canvas:1,canvastext:1,linktext:1,visitedtext:1,activetext:1,buttonface:1,buttontext:1,buttonborder:1,field:1,fieldtext:1,highlight:1,highlighttext:1,selecteditem:1,selecteditemtext:1,mark:1,marktext:1,graytext:1},h={rgb:1,rgba:1,hsl:1,hsla:1,hwb:1,lab:1,lch:1,oklab:1,oklch:1,color:1},d=/*#__PURE__*/function(){function e(e){if(this.items={},this.total=0,this.totalUnique=0,e)for(var t=0;t<e.length;t++)this.push(e[t])}var t=e.prototype;return t.push=function(e){this.total++,this.items[e]?this.items[e]++:(this.items[e]=1,this.totalUnique++)},t.size=function(){return this.total},t.count=function(){return{total:this.total,totalUnique:this.totalUnique,unique:this.items,uniquenessRatio:0===this.total?0:this.totalUnique/this.total}},e}(),f={inherit:1,initial:1,unset:1,revert:1,caption:1,icon:1,menu:1,"message-box":1,"small-caption":1,"status-bar":1},m={normal:1,"xx-small":1,"x-small":1,small:1,medium:1,large:1,"x-large":1,"xx-large":1,larger:1,smaller:1,bold:1,bolder:1,lighter:1,"ultra-condensed":1,"extra-condensed":1,condensed:1,"semi-condensed":1,"semi-expanded":1,expanded:1,"extra-expanded":1,"ultra-expanded":1,italic:1,oblique:1},p=function(e){for(var t=e.fontValues,n=new d(e.fontFamilyValues),i=function(e){var i=t[e],a=i.children.first;if("Identifier"===a.type&&f[a.name])return"continue";var s=[];r.walk(i,{reverse:!0,enter:function(e){return"String"===e.type||"Operator"===e.type&&44===e.value.charCodeAt(0)?s.unshift(e):"Identifier"===e.type?m[e.name]?this.skip:s.unshift(e):void 0}}),n.push(s.map(r.generate).join(""))},a=0;a<t.length;a++)i(a);return n.count()},g={"xx-small":1,"x-small":1,small:1,medium:1,large:1,"x-large":1,"xx-large":1,larger:1,smaller:1},y={inherit:1,initial:1,unset:1,revert:1,caption:1,icon:1,menu:1,"message-box":1,"small-caption":1,"status-bar":1},v=function(e){for(var t=e.stringifyNode,n=e.fontValues,i=new d(e.fontSizeValues),a=function(e){var a=n[e],s=a.children.first;if("Identifier"===s.type&&y[s.name])return"continue";var o=!1,u=void 0;r.walk(a,{enter:function(e){switch(e.type){case"Number":if(48===e.value.charCodeAt(0))return u="0",this.break;case"Operator":47===e.value.charCodeAt(0)&&(o=!0);break;case"Dimension":if(!o)return u=t(e),this.break;case"Identifier":if(g[e.name])return u=e.name,this.break}}}),u&&i.push(u)},s=0;s<n.length;s++)a(s);return i.count()},b=function(e){for(var t=e.stringifyNode,n=e.declarations,r=n.length,i=Object.create(null),a=0,s=0,o=0,u=0;u<r;u++){var l=n[u];!0===l.important&&(a++,l.inKeyframe&&o++);var c=t(l);i[c]||(i[c]=1,s++)}return{total:r,unique:{total:s,ratio:0===r?0:s/r},importants:{total:a,ratio:0===r?0:a/r,inKeyframes:{total:o,ratio:0===a?0:o/a}}}},k=function(e){for(var t,n,r=e.stringifyNode,s=e.selectors,l=Object.create(null),c=Object.create(null),h=s.length,f=new u(h),m=new u(h),p=new u(h),g=0,y=new u(h),v=[],b=[],k=new d,w=new d,x=new d,q=0;q<h;q++){var z=s[q],O=r(z);if(z.isKeyframeSelector)x.push(O);else{var A=c[O]||o(z),j=A.specificity,C=A.complexity,N=A.isId,S=A.isA11y;N&&k.push(O),S&&w.push(O),c[O]?l[O]++:(c[O]={complexity:C,specificity:j,isId:N,isA11y:S},g++,l[O]=1),y.add(C),void 0===t&&(t=j),void 0===n&&(n=j),f.add(j[0]),m.add(j[1]),p.add(j[2]),void 0!==n&&a(n,j)<0&&(n=j),void 0!==t&&a(t,j)>0&&(t=j),v.push(j),b.push(C)}}var I=f.aggregate(),D=m.aggregate(),U=p.aggregate(),F=new d(b).count();return{total:h,totalUnique:g,uniquenessRatio:0===h?0:g/h,specificity:{min:n,max:t,sum:[I.sum,D.sum,U.sum],mean:[I.mean,D.mean,U.mean],mode:[I.mode,D.mode,U.mode],median:[I.median,D.median,U.median],items:v},complexity:i({},y.aggregate(),F,{items:b}),id:i({},k.count(),{ratio:0===h?0:k.size()/h}),accessibility:i({},w.count(),{ratio:0===h?0:w.size()/h}),keyframes:i({},x.count(),{ratio:0===h?0:x.size()/h})}},w=function(e){for(var t=e.properties,n=new d(t.map(function(e){return e.authored})),r=new d,a=new d,s=new d,o=t.length,u=0;u<o;u++){var l=t[u];l.vendor?r.push(l.authored):l.hack?a.push(l.authored):l.custom&&s.push(l.authored)}return i({},n.count(),{prefixed:i({},r.count(),{ratio:r.size()/o}),custom:i({},s.count(),{ratio:s.size()/o}),browserhacks:i({},a.count(),{ratio:a.size()/o})})},x={auto:1,inherit:1,initial:1,unset:1,revert:1,none:1},q=function(e){for(var t=e.values,n=e.stringifyNode,r=new d,i=0;i<t.length;i++){var a=t[i],s=a.children.first;s&&("Identifier"===s.type&&x[s.name]||r.push(n(a)))}return r.count()},z={linear:1,ease:1,"ease-in":1,"ease-out":1,"ease-in-out":1,"step-start":1,"step-end":1},O=function(e){for(var t=e.animations,n=e.timingFunctions,r=e.stringifyNode,i=new d(e.durations.map(r)),a=new d(n.map(r)),s=function(e){var n=!1;t[e].value.children.forEach(function(e){return"Operator"===e.type?n=!1:"Dimension"===e.type&&!1===n?(n=!0,i.push(r(e))):"Identifier"===e.type&&z[e.name]?a.push(r(e)):"Function"!==e.type||"cubic-bezier"!==e.name&&"steps"!==e.name?void 0:a.push(r(e))})},o=0;o<t.length;o++)s(o);return{durations:i.count(),timingFunctions:a.count()}};function A(e){return 45===e.charCodeAt(0)&&45!==e.charCodeAt(1)&&-1!==e.indexOf("-",2)}function j(e){e=e.toArray();for(var t=0;t<e.length;t++){var n=e[t];if("Identifier"===n.type&&n.name.length>=3&&A(n.name))return!0;if("Function"===n.type){if(A(n.name))return!0;if(n.children&&j(n.children))return!0}}return!1}var C=function(e){for(var t=e.values,n=e.stringifyNode,r=new d,i=0;i<t.length;i++){var a=t[i];a.children&&j(a.children)&&r.push(n(a))}return r.count()},N=function(e){for(var t=e.atrules,n=e.stringifyNode,r=[],a=new d,s=new d,o=new d,u=new d,l=new d,c=new d,h=new d,f={"font-face":function(e){var t={};e.block.children.forEach(function(e){return t[e.property]=n(e.value)}),r.push(t)},media:function(e){return s.push(e.prelude.value)},supports:function(e){return u.push(e.prelude.value)},keyframes:function(e){return l.push("@"+e.name+" "+e.prelude.value)},import:function(e){return a.push(e.prelude.value)},charset:function(e){return o.push(e.prelude.value)},container:function(e){return h.push(e.prelude.value)}},m=0;m<t.length;m++){var p=t[m],g=p.name,y=f[g];if(y)y(p);else if(g.endsWith("keyframes")){var v="@"+g+" "+p.prelude.value;l.push(v),A(g)&&c.push(v)}}return{fontface:{total:r.length,totalUnique:r.length,unique:r,uniquenessRatio:1},import:a.count(),media:s.count(),charset:o.count(),supports:u.count(),keyframes:i({},l.count(),{prefixed:i({},c.count(),{ratio:0===l.size()?0:c.size()/l.size()})}),container:h.count()}},S=/*#__PURE__*/function(){function e(){this.list=new d,this.contexts={},this.contextCount=0}var t=e.prototype;return t.push=function(e,t){this.list.push(e),this.contexts[t]||(this.contexts[t]=new d,this.contextCount++),this.contexts[t].push(e)},t.count=function(){var e={};for(var t in this.contexts)e[t]=this.contexts[t].count();return Object.assign(this.list.count(),{itemsPerContext:e})},e}();e.analyze=function(e){var t=new Date,n=e.split(/\r?\n/);function a(e){var t=e.loc.start,r=e.loc.end;if(0==r.line-t.line)return n[t.line-1].substring(t.column-1,r.column-1);for(var i=[],a=t.line;a<=r.line;a++){var s=n[a-1];i.push(a!==t.line?a!==r.line?s:s.substring(0,r.column-1):s.substring(t.column-1))}return i.join("\n")}var s=new Date,o=0,u=0,f=r.parse(e,{parseAtrulePrelude:!1,parseCustomProperty:!0,positions:!0,onComment:function(e){o++,u+=e.length}}),m=new Date,g=[],y=[],x=[],z=[],A=[],j=[],I=[],D=[],U=[],F=[],P=[],V=[],R=[],T=[],_=[],K=new S,L=new S,W=new d;r.walk(f,{enter:function(e){switch(e.type){case"Atrule":g.push(e);break;case"Rule":y.push(e);break;case"Selector":return x.push(i({},e,{isKeyframeSelector:this.atrule&&this.atrule.name.endsWith("keyframes")})),this.skip;case"Dimension":if(!this.declaration)break;return L.push(e.unit,this.declaration.property),this.skip;case"Url":e.value.startsWith("data:")&&W.push(e.value);break;case"Declaration":z.push(i({},e,{inKeyframe:this.atrule&&this.atrule.name.endsWith("keyframes")}));var t=e.value,n=e.property,s=i({authored:n},r.property(n));switch(A.push(s),j.push(t),s.basename){case"z-index":I.push(t);break;case"text-shadow":D.push(t);break;case"box-shadow":U.push(t);break;case"font":F.push(t);break;case"font-family":return P.push(a(t)),this.skip;case"font-size":V.push(a(t));break;case"transition":case"animation":R.push(e);break;case"animation-duration":case"transition-duration":_.push(t);break;case"transition-timing-function":case"animation-timing-function":T.push(t)}r.walk(e.value,{enter:function(e){switch(e.type){case"Hash":return K.push(a(e),n),this.skip;case"Identifier":var t=e.name;return t.length>20||t.length<3||c[t.toLowerCase()]&&K.push(a(e),n),this.skip;case"Function":h[e.name.toLowerCase()]&&K.push(a(e),n)}}})}}});var E=W.count(),M=Object.keys(E.unique).join("").length;return{stylesheet:{sourceLinesOfCode:g.length+x.length+z.length,linesOfCode:n.length,size:e.length,comments:{total:o,size:u},embeddedContent:Object.assign(E,{size:{total:M,ratio:0===e.length?0:M/e.length}})},atrules:N({atrules:g,stringifyNode:a}),rules:l({rules:y}),selectors:k({stringifyNode:a,selectors:x}),declarations:b({stringifyNode:a,declarations:z}),properties:w({properties:A}),values:{colors:K.count(),fontFamilies:p({stringifyNode:a,fontValues:F,fontFamilyValues:P}),fontSizes:v({stringifyNode:a,fontValues:F,fontSizeValues:V}),zindexes:q({values:I,stringifyNode:a}),textShadows:q({values:D,stringifyNode:a}),boxShadows:q({values:U,stringifyNode:a}),animations:O({animations:R,timingFunctions:T,durations:_,stringifyNode:a}),prefixes:C({values:j,stringifyNode:a}),units:L.count()},__meta__:{parseTime:m-s,analyzeTime:new Date-m,total:new Date-t}}},e.compareSpecificity=a});
2
2
  //# sourceMappingURL=analyzer.umd.js.map