GoScrobble/web/node_modules/postcss-env-function/index.es.mjs.map

1 line
13 KiB
Plaintext
Raw Permalink Normal View History

2022-04-25 02:47:15 +00:00
{"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