This repository has been archived on 2020-11-02. You can view files and clone it, but cannot push or open issues or pull requests.
TripSit_Suite/node_modules/postcss-env-function/index.es.mjs.map
2020-11-01 22:46:04 +00:00

1 line
13 KiB
Plaintext

{"version":3,"file":"index.es.mjs","sources":["lib/get-fn-value.js","lib/update-env-value.js","lib/is-env-func.js","lib/walk-env-funcs.js","lib/get-replaced-value.js","lib/is-atrule.js","lib/is-decl.js","lib/get-supported-value.js","lib/set-supported-value.js","lib/import-from.js","index.js"],"sourcesContent":["const dashedMatch = /^--/;\n\n// returns the value of a css function as a string\nexport default (node) => {\n\tconst value = String(node.nodes.slice(1, -1));\n\n\treturn dashedMatch.test(value) ? value : undefined;\n};\n","import getFnValue from './get-fn-value';\n\n// update a node with an environment value\nexport default (node, variables) => {\n\t// get the value of a css function as a string\n\tconst value = getFnValue(node);\n\n\tif (typeof value === 'string' && value in variables) {\n\t\tnode.replaceWith(\n\t\t\t...asClonedArrayWithBeforeSpacing(variables[value], node.raws.before)\n\t\t);\n\t}\n};\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","// returns whether a node is a css env() function\nexport default (node) => node && node.type === 'func' && node.value === 'env';\n","import isEnvFunc from './is-env-func';\n\n// walks a node recursively and runs a function using its children\nexport default function walk(node, fn) {\n\tnode.nodes.slice(0).forEach(childNode => {\n\t\tif (childNode.nodes) {\n\t\t\twalk(childNode, fn);\n\t\t}\n\n\t\tif (isEnvFunc(childNode)) {\n\t\t\tfn(childNode);\n\t\t}\n\t});\n}\n","import parser from 'postcss-values-parser';\nimport updateEnvValue from './update-env-value';\nimport walkEnvFuncs from './walk-env-funcs';\n\n// returns a value replaced with environment variables\nexport default (originalValue, variables) => {\n\t// get the ast of the original value\n\tconst ast = parser(originalValue).parse();\n\n\t// walk all of the css env() functions\n\twalkEnvFuncs(ast, node => {\n\t\t// update the environment value for the css env() function\n\t\tupdateEnvValue(node, variables);\n\t});\n\n\t// return the stringified ast\n\treturn String(ast);\n};\n","// returns whether a node is an at-rule\nexport default (node) => node && node.type === 'atrule';\n","// returns whether a node is a declaration\nexport default (node) => node && node.type === 'decl';\n","import isAtrule from './is-atrule';\nimport isDecl from './is-decl';\n\n// returns a value from an at-rule or declaration\nexport default (node) => isAtrule(node) && node.params || isDecl(node) && node.value;\n","import isAtrule from './is-atrule';\nimport isDecl from './is-decl';\n\n// assigns a value to an at-rule or declaration\nexport default function (node, value) {\n\tif (isAtrule(node)) {\n\t\tnode.params = value;\n\t}\n\n\tif (isDecl(node)) {\n\t\tnode.value = value;\n\t}\n}\n","import fs from 'fs';\nimport path from 'path';\nimport valueParser from 'postcss-values-parser';\n\n/* Import Custom Properties from Object\n/* ========================================================================== */\n\nfunction importEnvironmentVariablesFromObject(object) {\n\tconst environmentVariables = Object.assign(\n\t\t{},\n\t\tObject(object).environmentVariables || Object(object)['environment-variables']\n\t);\n\n\tfor (const key in environmentVariables) {\n\t\tenvironmentVariables[key] = valueParser(environmentVariables[key]).parse().nodes;\n\t}\n\n\treturn environmentVariables;\n}\n\n/* Import Custom Properties from JSON file\n/* ========================================================================== */\n\nasync function importEnvironmentVariablesFromJSONFile(from) {\n\tconst object = await readJSON(path.resolve(from));\n\n\treturn importEnvironmentVariablesFromObject(object);\n}\n\n/* Import Custom Properties from JS file\n/* ========================================================================== */\n\nasync function importEnvironmentVariablesFromJSFile(from) {\n\tconst object = await import(path.resolve(from));\n\n\treturn importEnvironmentVariablesFromObject(object);\n}\n\n/* Import Custom Properties from Sources\n/* ========================================================================== */\n\nexport default function importEnvironmentVariablesFromSources(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.environmentVariables || opts['environment-variables']) {\n\t\t\treturn opts\n\t\t}\n\n\t\t// source pathname\n\t\tconst from = 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 (environmentVariables, source) => {\n\t\tconst { type, from } = await source;\n\n\t\tif (type === 'js') {\n\t\t\treturn Object.assign(environmentVariables, await importEnvironmentVariablesFromJSFile(from));\n\t\t}\n\n\t\tif (type === 'json') {\n\t\t\treturn Object.assign(environmentVariables, await importEnvironmentVariablesFromJSONFile(from));\n\t\t}\n\n\t\treturn Object.assign(environmentVariables, importEnvironmentVariablesFromObject(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","import postcss from 'postcss';\nimport getReplacedValue from './lib/get-replaced-value';\nimport getSupportedValue from './lib/get-supported-value';\nimport setSupportedValue from './lib/set-supported-value';\nimport importEnvironmentVariablesFromSources from './lib/import-from';\n\nexport default postcss.plugin('postcss-env-fn', opts => {\n\t// sources to import environment variables from\n\tconst importFrom = [].concat(Object(opts).importFrom || []);\n\n\t// promise any environment variables are imported\n\tconst environmentVariablesPromise = importEnvironmentVariablesFromSources(importFrom);\n\n\treturn async root => {\n\t\tconst environmentVariables = await environmentVariablesPromise;\n\n\t\troot.walk(node => {\n\t\t\tconst supportedValue = getSupportedValue(node);\n\n\t\t\tif (supportedValue) {\n\t\t\t\tconst replacedValue = getReplacedValue(supportedValue, environmentVariables);\n\n\t\t\t\tif (replacedValue !== supportedValue) {\n\t\t\t\t\tsetSupportedValue(node, replacedValue);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t};\n});\n"],"names":["dashedMatch","node","value","String","nodes","slice","test","undefined","variables","getFnValue","replaceWith","asClonedArrayWithBeforeSpacing","raws","before","array","beforeSpacing","clonedArray","asClonedArray","parent","map","asClonedNode","cloneNode","constructor","key","Object","Array","assign","type","walk","fn","forEach","childNode","isEnvFunc","originalValue","ast","parser","parse","walkEnvFuncs","updateEnvValue","isAtrule","params","isDecl","importEnvironmentVariablesFromObject","object","environmentVariables","valueParser","importEnvironmentVariablesFromJSONFile","from","readJSON","path","resolve","importEnvironmentVariablesFromJSFile","importEnvironmentVariablesFromSources","sources","source","Promise","Function","opts","extname","toLowerCase","reduce","readFile","reject","fs","error","result","JSON","postcss","plugin","importFrom","concat","environmentVariablesPromise","root","supportedValue","getSupportedValue","replacedValue","getReplacedValue","setSupportedValue"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAMA,WAAW,GAAG,KAApB;;AAGA,kBAAgBC,IAAD,IAAU;QAClBC,KAAK,GAAGC,MAAM,CAACF,IAAI,CAACG,KAAL,CAAWC,KAAX,CAAiB,CAAjB,EAAoB,CAAC,CAArB,CAAD,CAApB;SAEOL,WAAW,CAACM,IAAZ,CAAiBJ,KAAjB,IAA0BA,KAA1B,GAAkCK,SAAzC;CAHD;;ACAA,sBAAe,CAACN,IAAD,EAAOO,SAAP,KAAqB;;QAE7BN,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