{"version":3,"file":"index.esm.mjs","sources":["lib/get-custom-properties-from-root.js","lib/get-custom-properties-from-imports.js","lib/transform-value-ast.js","lib/transform-properties.js","lib/write-custom-properties-to-exports.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 getCustomPropertiesFromRoot(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().nodes;\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 valueParser from 'postcss-values-parser';\nimport getCustomPropertiesFromRoot from './get-custom-properties-from-root';\n\n/* Get Custom Properties from CSS File\n/* ========================================================================== */\n\nasync function getCustomPropertiesFromCSSFile(from) {\n\tconst css = await readFile(from);\n\tconst root = postcss.parse(css, { from });\n\n\treturn getCustomPropertiesFromRoot(root, { preserve: true });\n}\n\n/* Get Custom Properties from Object\n/* ========================================================================== */\n\nfunction getCustomPropertiesFromObject(object) {\n\tconst customProperties = Object.assign(\n\t\t{},\n\t\tObject(object).customProperties,\n\t\tObject(object)['custom-properties']\n\t);\n\n\tfor (const key in customProperties) {\n\t\tcustomProperties[key] = valueParser(String(customProperties[key])).parse().nodes;\n\t}\n\n\treturn customProperties;\n}\n\n/* Get Custom Properties from JSON file\n/* ========================================================================== */\n\nasync function getCustomPropertiesFromJSONFile(from) {\n\tconst object = await readJSON(from);\n\n\treturn getCustomPropertiesFromObject(object);\n}\n\n/* Get Custom Properties from JS file\n/* ========================================================================== */\n\nasync function getCustomPropertiesFromJSFile(from) {\n\tconst object = await import(from);\n\n\treturn getCustomPropertiesFromObject(object);\n}\n\n/* Get Custom Properties from Imports\n/* ========================================================================== */\n\nexport default function getCustomPropertiesFromImports(sources) {\n\treturn sources.map(source => {\n\t\tif (source instanceof Promise) {\n\t\t\treturn source;\n\t\t} else if (source instanceof Function) {\n\t\t\treturn source();\n\t\t}\n\n\t\t// read the source as an object\n\t\tconst opts = source === Object(source) ? source : { from: String(source) };\n\n\t\t// skip objects with Custom Properties\n\t\tif (opts.customProperties || opts['custom-properties']) {\n\t\t\treturn opts\n\t\t}\n\n\t\t// source pathname\n\t\tconst from = path.resolve(String(opts.from || ''));\n\n\t\t// type of file being read from\n\t\tconst type = (opts.type || path.extname(from).slice(1)).toLowerCase();\n\n\t\treturn { type, from };\n\t}).reduce(async (customProperties, source) => {\n\t\tconst { type, from } = await source;\n\n\t\tif (type === 'css') {\n\t\t\treturn Object.assign(await customProperties, await getCustomPropertiesFromCSSFile(from));\n\t\t}\n\n\t\tif (type === 'js') {\n\t\t\treturn Object.assign(await customProperties, await getCustomPropertiesFromJSFile(from));\n\t\t}\n\n\t\tif (type === 'json') {\n\t\t\treturn Object.assign(await customProperties, await getCustomPropertiesFromJSONFile(from));\n\t\t}\n\n\t\treturn Object.assign(await customProperties, await getCustomPropertiesFromObject(await source));\n\t}, {});\n}\n\n/* Helper utilities\n/* ========================================================================== */\n\nconst readFile = from => new Promise((resolve, reject) => {\n\tfs.readFile(from, 'utf8', (error, result) => {\n\t\tif (error) {\n\t\t\treject(error);\n\t\t} else {\n\t\t\tresolve(result);\n\t\t}\n\t});\n});\n\nconst readJSON = async from => JSON.parse(await readFile(from));\n","export default function transformValueAST(root, customProperties) {\n\tif (root.nodes && root.nodes.length) {\n\t\troot.nodes.slice().forEach(child => {\n\t\t\tif (isVarFunction(child)) {\n\t\t\t\t// eslint-disable-next-line no-unused-vars\n\t\t\t\tconst [propertyNode, comma, ...fallbacks] = child.nodes.slice(1, -1);\n\t\t\t\tconst { value: name } = propertyNode;\n\n\t\t\t\tif (name in customProperties) {\n\t\t\t\t\t// conditionally replace a known custom property\n\t\t\t\t\tconst nodes = asClonedArrayWithBeforeSpacing(customProperties[name], child.raws.before);\n\n\t\t\t\t\tchild.replaceWith(...nodes);\n\n\t\t\t\t\tretransformValueAST({ nodes }, customProperties, name);\n\t\t\t\t} else if (fallbacks.length) {\n\t\t\t\t\t// conditionally replace a custom property with a fallback\n\t\t\t\t\tconst index = root.nodes.indexOf(child);\n\n\t\t\t\t\tif (index !== -1) {\n\t\t\t\t\t\troot.nodes.splice(index, 1, ...asClonedArrayWithBeforeSpacing(fallbacks, child.raws.before));\n\t\t\t\t\t}\n\n\t\t\t\t\ttransformValueAST(root, customProperties);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\ttransformValueAST(child, customProperties);\n\t\t\t}\n\t\t});\n\t}\n\n\treturn root;\n}\n\n// retransform the current ast without a custom property (to prevent recursion)\nfunction retransformValueAST(root, customProperties, withoutProperty) {\n\tconst nextCustomProperties = Object.assign({}, customProperties);\n\n\tdelete nextCustomProperties[withoutProperty];\n\n\treturn transformValueAST(root, nextCustomProperties);\n}\n\n// match var() functions\nconst varRegExp = /^var$/i;\n\n// whether the node is a var() function\nconst isVarFunction = node => node.type === 'func' && varRegExp.test(node.value) && Object(node.nodes).length > 0;\n\n// return an array with its nodes cloned, preserving the raw\nconst asClonedArrayWithBeforeSpacing = (array, beforeSpacing) => {\n\tconst clonedArray = asClonedArray(array, null);\n\n\tif (clonedArray[0]) {\n\t\tclonedArray[0].raws.before = beforeSpacing;\n\t}\n\n\treturn clonedArray;\n};\n\n// return an array with its nodes cloned\nconst asClonedArray = (array, parent) => array.map(node => asClonedNode(node, parent));\n\n// return a cloned node\nconst asClonedNode = (node, parent) => {\n\tconst cloneNode = new node.constructor(node);\n\n\tfor (const key in node) {\n\t\tif (key === 'parent') {\n\t\t\tcloneNode.parent = parent;\n\t\t} else if (Object(node[key]).constructor === Array) {\n\t\t\tcloneNode[key] = asClonedArray(node.nodes, cloneNode);\n\t\t} else if (Object(node[key]).constructor === Object) {\n\t\t\tcloneNode[key] = Object.assign({}, node[key]);\n\t\t}\n\t}\n\n\treturn cloneNode;\n};\n","import valueParser from 'postcss-values-parser';\nimport transformValueAST from './transform-value-ast';\n\n// transform custom pseudo selectors with custom selectors\nexport default (root, customProperties, opts) => {\n\t// walk decls that can be transformed\n\troot.walkDecls(decl => {\n\t\tif (isTransformableDecl(decl)) {\n\t\t\tconst originalValue = decl.value;\n\t\t\tconst valueAST = valueParser(originalValue).parse();\n\t\t\tconst value = String(transformValueAST(valueAST, customProperties));\n\n\t\t\t// conditionally transform values that have changed\n\t\t\tif (value !== originalValue) {\n\t\t\t\tif (opts.preserve) {\n\t\t\t\t\tdecl.cloneBefore({ value });\n\t\t\t\t} else {\n\t\t\t\t\tdecl.value = value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t});\n};\n\n// match custom properties\nconst customPropertyRegExp = /^--[A-z][\\w-]*$/;\n\n// match custom property inclusions\nconst customPropertiesRegExp = /(^|[^\\w-])var\\([\\W\\w]+\\)/;\n\n// whether the declaration should be potentially transformed\nconst isTransformableDecl = decl => !customPropertyRegExp.test(decl.prop) && customPropertiesRegExp.test(decl.value);\n","import fs from 'fs';\nimport path from 'path';\n\n/* Write Custom Properties to CSS File\n/* ========================================================================== */\n\nasync function writeCustomPropertiesToCssFile(to, customProperties) {\n\tconst cssContent = Object.keys(customProperties).reduce((cssLines, name) => {\n\t\tcssLines.push(`\\t${name}: ${customProperties[name]};`);\n\n\t\treturn cssLines;\n\t}, []).join('\\n');\n\tconst css = `:root {\\n${cssContent}\\n}\\n`;\n\n\tawait writeFile(to, css);\n}\n\n/* Write Custom Properties to JSON file\n/* ========================================================================== */\n\nasync function writeCustomPropertiesToJsonFile(to, customProperties) {\n\tconst jsonContent = JSON.stringify({\n\t\t'custom-properties': customProperties\n\t}, null, ' ');\n\tconst json = `${jsonContent}\\n`;\n\n\tawait writeFile(to, json);\n}\n\n/* Write Custom Properties to Common JS file\n/* ========================================================================== */\n\nasync function writeCustomPropertiesToCjsFile(to, customProperties) {\n\tconst jsContents = Object.keys(customProperties).reduce((jsLines, name) => {\n\t\tjsLines.push(`\\t\\t'${escapeForJS(name)}': '${escapeForJS(customProperties[name])}'`);\n\n\t\treturn jsLines;\n\t}, []).join(',\\n');\n\tconst js = `module.exports = {\\n\\tcustomProperties: {\\n${jsContents}\\n\\t}\\n};\\n`;\n\n\tawait writeFile(to, js);\n}\n\n/* Write Custom Properties to Module JS file\n/* ========================================================================== */\n\nasync function writeCustomPropertiesToMjsFile(to, customProperties) {\n\tconst mjsContents = Object.keys(customProperties).reduce((mjsLines, name) => {\n\t\tmjsLines.push(`\\t'${escapeForJS(name)}': '${escapeForJS(customProperties[name])}'`);\n\n\t\treturn mjsLines;\n\t}, []).join(',\\n');\n\tconst mjs = `export const customProperties = {\\n${mjsContents}\\n};\\n`;\n\n\tawait writeFile(to, mjs);\n}\n\n/* Write Custom Properties to Exports\n/* ========================================================================== */\n\nexport default function writeCustomPropertiesToExports(customProperties, destinations) {\n\treturn Promise.all(destinations.map(async destination => {\n\t\tif (destination instanceof Function) {\n\t\t\tawait destination(defaultCustomPropertiesToJSON(customProperties));\n\t\t} else {\n\t\t\t// read the destination as an object\n\t\t\tconst opts = destination === Object(destination) ? destination : { to: String(destination) };\n\n\t\t\t// transformer for Custom Properties into a JSON-compatible object\n\t\t\tconst toJSON = opts.toJSON || defaultCustomPropertiesToJSON;\n\n\t\t\tif ('customProperties' in opts) {\n\t\t\t\t// write directly to an object as customProperties\n\t\t\t\topts.customProperties = toJSON(customProperties);\n\t\t\t} else if ('custom-properties' in opts) {\n\t\t\t\t// write directly to an object as custom-properties\n\t\t\t\topts['custom-properties'] = toJSON(customProperties);\n\t\t\t} else {\n\t\t\t\t// destination pathname\n\t\t\t\tconst to = String(opts.to || '');\n\n\t\t\t\t// type of file being written to\n\t\t\t\tconst type = (opts.type || path.extname(opts.to).slice(1)).toLowerCase();\n\n\t\t\t\t// transformed Custom Properties\n\t\t\t\tconst customPropertiesJSON = toJSON(customProperties);\n\n\t\t\t\tif (type === 'css') {\n\t\t\t\t\tawait writeCustomPropertiesToCssFile(to, customPropertiesJSON);\n\t\t\t\t}\n\n\t\t\t\tif (type === 'js') {\n\t\t\t\t\tawait writeCustomPropertiesToCjsFile(to, customPropertiesJSON);\n\t\t\t\t}\n\n\t\t\t\tif (type === 'json') {\n\t\t\t\t\tawait writeCustomPropertiesToJsonFile(to, customPropertiesJSON);\n\t\t\t\t}\n\n\t\t\t\tif (type === 'mjs') {\n\t\t\t\t\tawait writeCustomPropertiesToMjsFile(to, customPropertiesJSON);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}));\n}\n\n/* Helper utilities\n/* ========================================================================== */\n\nconst defaultCustomPropertiesToJSON = customProperties => {\n\treturn Object.keys(customProperties).reduce((customPropertiesJSON, key) => {\n\t\tcustomPropertiesJSON[key] = String(customProperties[key]);\n\n\t\treturn customPropertiesJSON;\n\t}, {});\n};\n\nconst writeFile = (to, text) => new Promise((resolve, reject) => {\n\tfs.writeFile(to, text, error => {\n\t\tif (error) {\n\t\t\treject(error);\n\t\t} else {\n\t\t\tresolve();\n\t\t}\n\t});\n});\n\nconst escapeForJS = string => string.replace(/\\\\([\\s\\S])|(')/g, '\\\\$1$2').replace(/\\n/g, '\\\\n').replace(/\\r/g, '\\\\r');\n","import postcss from 'postcss';\nimport getCustomPropertiesFromRoot from './lib/get-custom-properties-from-root';\nimport getCustomPropertiesFromImports from './lib/get-custom-properties-from-imports';\nimport transformProperties from './lib/transform-properties';\nimport writeCustomPropertiesToExports from './lib/write-custom-properties-to-exports';\n\nexport default postcss.plugin('postcss-custom-properties', opts => {\n\t// whether to preserve custom selectors and rules using them\n\tconst preserve = 'preserve' in Object(opts) ? Boolean(opts.preserve) : true;\n\n\t// sources to import custom selectors from\n\tconst importFrom = [].concat(Object(opts).importFrom || []);\n\n\t// destinations to export custom selectors to\n\tconst exportTo = [].concat(Object(opts).exportTo || []);\n\n\t// promise any custom selectors are imported\n\tconst customPropertiesPromise = getCustomPropertiesFromImports(importFrom);\n\n\treturn async root => {\n\t\tconst customProperties = Object.assign(\n\t\t\tawait customPropertiesPromise,\n\t\t\tgetCustomPropertiesFromRoot(root, { preserve })\n\t\t);\n\n\t\tawait writeCustomPropertiesToExports(customProperties, exportTo);\n\n\t\ttransformProperties(root, customProperties, { preserve });\n\t};\n});\n"],"names":["getCustomPropertiesFromRoot","root","opts","customPropertiesFromHtmlElement","customPropertiesFromRootPsuedo","nodes","slice","forEach","rule","customPropertiesObject","isHtmlRule","isRootRule","decl","isCustomDecl","prop","valueParser","value","parse","preserve","remove","isEmptyParent","htmlSelectorRegExp","rootSelectorRegExp","customPropertyRegExp","node","type","test","selector","Object","length","getCustomPropertiesFromCSSFile","from","css","readFile","postcss","getCustomPropertiesFromObject","object","customProperties","assign","key","String","getCustomPropertiesFromJSONFile","readJSON","getCustomPropertiesFromJSFile","getCustomPropertiesFromImports","sources","map","source","Promise","Function","path","resolve","extname","toLowerCase","reduce","reject","fs","error","result","JSON","transformValueAST","child","isVarFunction","propertyNode","comma","fallbacks","name","asClonedArrayWithBeforeSpacing","raws","before","replaceWith","retransformValueAST","index","indexOf","splice","withoutProperty","nextCustomProperties","varRegExp","array","beforeSpacing","clonedArray","asClonedArray","parent","asClonedNode","cloneNode","constructor","Array","walkDecls","isTransformableDecl","originalValue","valueAST","cloneBefore","customPropertiesRegExp","writeCustomPropertiesToCssFile","to","cssContent","keys","cssLines","push","join","writeFile","writeCustomPropertiesToJsonFile","jsonContent","stringify","json","writeCustomPropertiesToCjsFile","jsContents","jsLines","escapeForJS","js","writeCustomPropertiesToMjsFile","mjsContents","mjsLines","mjs","writeCustomPropertiesToExports","destinations","all","destination","defaultCustomPropertiesToJSON","toJSON","customPropertiesJSON","text","string","replace","plugin","Boolean","importFrom","concat","exportTo","customPropertiesPromise","transformProperties"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGe,SAASA,2BAAT,CAAqCC,IAArC,EAA2CC,IAA3C,EAAiD;;QAEzDC,+BAA+B,GAAG,EAAxC;QACMC,8BAA8B,GAAG,EAAvC,CAH+D;;EAM/DH,IAAI,CAACI,KAAL,CAAWC,KAAX,GAAmBC,OAAnB,CAA2BC,IAAI,IAAI;UAC5BC,sBAAsB,GAAGC,UAAU,CAACF,IAAD,CAAV,GAC5BL,+BAD4B,GAE7BQ,UAAU,CAACH,IAAD,CAAV,GACCJ,8BADD,GAEA,IAJF,CADkC;;QAQ9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