projecte_ionic/node_modules/postcss-color-mod-function/index.es.mjs.map

1 line
107 KiB
Plaintext
Raw Permalink Normal View History

2022-02-09 18:30:03 +01:00
{"version":3,"file":"index.es.mjs","sources":["lib/get-custom-properties.js","lib/import-from.js","lib/conversions.js","lib/color.js","lib/manage-unresolved.js","lib/transform.js","index.js"],"sourcesContent":["import valueParser from 'postcss-values-parser';\n\n// return custom selectors from the css root, conditionally removing them\nexport default function getCustomProperties(root, opts) {\n\t// initialize custom selectors\n\tconst customPropertiesFromHtmlElement = {};\n\tconst customPropertiesFromRootPsuedo = {};\n\n\t// for each html or :root rule\n\troot.nodes.slice().forEach(rule => {\n\t\tconst customPropertiesObject = isHtmlRule(rule)\n\t\t\t? customPropertiesFromHtmlElement\n\t\t: isRootRule(rule)\n\t\t\t? customPropertiesFromRootPsuedo\n\t\t: null;\n\n\t\t// for each custom property\n\t\tif (customPropertiesObject) {\n\t\t\trule.nodes.slice().forEach(decl => {\n\t\t\t\tif (isCustomDecl(decl)) {\n\t\t\t\t\tconst { prop } = decl;\n\n\t\t\t\t\t// write the parsed value to the custom property\n\t\t\t\t\tcustomPropertiesObject[prop] = valueParser(decl.value).parse();\n\n\t\t\t\t\t// conditionally remove the custom property declaration\n\t\t\t\t\tif (!opts.preserve) {\n\t\t\t\t\t\tdecl.remove();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t// conditionally remove the empty html or :root rule\n\t\t\tif (!opts.preserve && isEmptyParent(rule)) {\n\t\t\t\trule.remove();\n\t\t\t}\n\t\t}\n\t});\n\n\t// return all custom properties, preferring :root properties over html properties\n\treturn { ...customPropertiesFromHtmlElement, ...customPropertiesFromRootPsuedo };\n}\n\n// match html and :root rules\nconst htmlSelectorRegExp = /^html$/i;\nconst rootSelectorRegExp = /^:root$/i;\nconst customPropertyRegExp = /^--[A-z][\\w-]*$/;\n\n// whether the node is an html or :root rule\nconst isHtmlRule = node => node.type === 'rule' && htmlSelectorRegExp.test(node.selector) && Object(node.nodes).length;\nconst isRootRule = node => node.type === 'rule' && rootSelectorRegExp.test(node.selector) && Object(node.nodes).length;\n\n// whether the node is an custom property\nconst isCustomDecl = node => node.type === 'decl' && customPropertyRegExp.test(node.prop);\n\n// whether the node is a parent without children\nconst isEmptyParent = node => Object(node.nodes).length === 0;\n","import fs from 'fs';\nimport path from 'path';\nimport postcss from 'postcss';\nimport getCustomProperties from './get-custom-properties';\nimport valueParser from 'postcss-values-parser';\n\n/* Import Custom Properties from CSS AST\n/* ========================================================================== */\n\nfunction importCustomPropertiesFromCSSAST(root) {\n\treturn getCustomProperties(root, { preserve: true });\n}\n\n/* Import Custom Properties from CSS File\n/* ========================================================================== */\n\nasync function importCustomPropertiesFromCSSFile(from) {\n\tconst css = await readFile(from);\n\tconst root = postcss.parse(css, { from });\n\n\treturn importCustomPropertiesFromCSSAST(root);\n}\n\n/* Import Custom Properties from Object\n/* ========================================================================== */\n\nfunction importCustomPropertiesFromObject(object) {\n\tconst customProperties = Object.assign(\n\t\t{},\n\t\tObject(object).customProperties || Object(object)['custom-properties']\n\t);\n\n\tfor (const prop in customProperties) {\n\t\tcustomProperties[prop] = valueParser(customProperties[prop]).parse();\n\t}\n\n\treturn customProperties;\n}\n\n/* Import Custom Properties from JSON file\n/* ========================================================================== */\n\nasync function importCustomPropertiesFromJSONFile(from) {\n\tconst object = await readJSON(from);\n\n\treturn importCustomPropertiesFromObject(object);\n}\n\n/* Import Custom Properties from JS file\n/* ========================================================================== */\n\nasync function importCustomPropertiesFromJSFile(from) {\n\tconst object = await import(from);\n\n\treturn importCustomPropertiesFromObject(object);\n}\n\n/*