projecte_ionic/node_modules/postcss-color-functional-notation/index.cjs.js.map

1 line
10 KiB
Plaintext
Raw Normal View History

2022-02-09 18:30:03 +01:00
{"version":3,"file":"index.cjs.js","sources":["index.js"],"sourcesContent":["import postcss from 'postcss';\nimport valuesParser from 'postcss-values-parser';\n\nexport default postcss.plugin('postcss-color-functional-notation', opts => {\n\tconst preserve = 'preserve' in Object(opts) ? Boolean(opts.preserve) : false;\n\n\treturn root => {\n\t\troot.walkDecls(decl => {\n\t\t\tconst { value: originalValue } = decl;\n\n\t\t\tif (colorAnyRegExp.test(originalValue)) {\n\t\t\t\tconst valueAST = valuesParser(originalValue).parse();\n\n\t\t\t\tvalueAST.walkType('func', node => {\n\t\t\t\t\tif (colorRegExp.test(node.value)) {\n\t\t\t\t\t\tconst children = node.nodes.slice(1, -1);\n\t\t\t\t\t\tconst isFunctionalHSL = matchFunctionalHSL(node, children);\n\t\t\t\t\t\tconst isFunctionalRGB1 = matchFunctionalRGB1(node, children);\n\t\t\t\t\t\tconst isFunctionalRGB2 = matchFunctionalRGB2(node, children);\n\n\t\t\t\t\t\tif (isFunctionalHSL || isFunctionalRGB1 || isFunctionalRGB2) {\n\t\t\t\t\t\t\tconst slashNode = children[3];\n\t\t\t\t\t\t\tconst alphaNode = children[4];\n\n\t\t\t\t\t\t\tif (alphaNode) {\n\t\t\t\t\t\t\t\tif (isPercentage(alphaNode) && !isCalc(alphaNode)) {\n\t\t\t\t\t\t\t\t\talphaNode.unit = '';\n\t\t\t\t\t\t\t\t\talphaNode.value = String(alphaNode.value / 100);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tif (isHslRgb(node)) {\n\t\t\t\t\t\t\t\t\tnode.value += 'a';\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else if (isHslaRgba(node)) {\n\t\t\t\t\t\t\t\tnode.value = node.value.slice(0, -1);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (slashNode && isSlash(slashNode)) {\n\t\t\t\t\t\t\t\tslashNode.replaceWith( newComma() );\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (isFunctionalRGB2) {\n\t\t\t\t\t\t\t\tchildren[0].unit = children[1].unit = children[2].unit = '';\n\n\t\t\t\t\t\t\t\tchildren[0].value = String(Math.floor(children[0].value * 255 / 100));\n\t\t\t\t\t\t\t\tchildren[1].value = String(Math.floor(children[1].value * 255 / 100));\n\t\t\t\t\t\t\t\tchildren[2].value = String(Math.floor(children[2].value * 255 / 100));\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tnode.nodes.splice(3, 0, [ newComma() ]);\n\t\t\t\t\t\t\tnode.nodes.splice(2, 0, [ newComma() ]);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\tconst modifiedValue = String(valueAST);\n\n\t\t\t\tif (modifiedValue !== originalValue) {\n\t\t\t\t\tif (preserve) {\n\t\t\t\t\t\tdecl.cloneBefore({ value: modifiedValue });\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdecl.value = modifiedValue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t};\n});\n\nconst alphaUnitMatch = /^%?$/i;\nconst calcFuncMatch = /^calc$/i;\nconst colorAnyRegExp = /(^|[^\\w-])(hsla?|rgba?)\\(/i;\nconst colorRegExp = /^(hsla?|rgba?)$/i;\nconst hslishRegExp = /^hsla?$/i;\nconst hslRgbFuncMatch = /^(hsl|rgb)$/i;\nconst hslaRgbaFuncMatch = /^(hsla|rgba)$/i;\nconst hueUnitMatch = /^(deg|grad|rad|turn)?$/i;\nconst rgbishRegExp = /^rgba?$/i;\nconst isAlphaValue = node => isCalc(node) || node.type === 'number' && alphaUnitMatch.test(node.unit);\nconst isCalc = node => node.type === 'func' && calcFuncMatch.test(node.value);\nconst isHue = node => isCalc(node) || node.type === 'number' && hueUnitMatch.test(node.unit);\nconst isNumber = node => isCalc(node) || node.type === 'number' && node.unit === '';\nconst isPercentage = node => isCalc(node) || node.type === 'number' && (node.unit === '%' || node.unit === '' && node.value === '0');\nconst isHslish = node => node.type === 'func' && hslishRegExp.test(node.value);\nconst isHslRgb = node => node.type === 'func' && hslRgbFuncMatch.test(node.value);\nconst isHslaRgba = node => node.type === 'func' && hslaRgbaFuncMatch.test(node.value);\nconst isRgbish = node => node.type === 'func' && rgbishRegExp.test(node.value);\nconst isSlash = node => node.type === 'operator' && node.value === '/';\nconst functionalHSLMatch = [isHue, isPercentage, isPercentage, isSlash, isAlphaValue];\nconst functionalRGB1Match = [isNumber, isNumber, isNumber, isSlash, isAlphaValue];\nconst functionalRGB2Match = [isPercentage, isPercentage, isPercentage, isSlash, isAlphaValue];\n\nconst matchFunctionalHSL = (node, children)