diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2026-05-18 23:10:59 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2026-05-18 23:41:44 +0800 |
| commit | fc87c009806dcc98867f6b58efe29b042aa01dee (patch) | |
| tree | 8f59b3f4a5b66e9dfef2d40c8d318e258a521228 /node_modules/postcss-import/lib | |
| parent | 3336b2356ee6152d9c6ae59bd9b87ccbc0958407 (diff) | |
node: updatemain
Diffstat (limited to 'node_modules/postcss-import/lib')
| -rw-r--r-- | node_modules/postcss-import/lib/assign-layer-names.js | 17 | ||||
| -rw-r--r-- | node_modules/postcss-import/lib/data-url.js | 17 | ||||
| -rw-r--r-- | node_modules/postcss-import/lib/join-layer.js | 9 | ||||
| -rw-r--r-- | node_modules/postcss-import/lib/join-media.js | 28 | ||||
| -rw-r--r-- | node_modules/postcss-import/lib/load-content.js | 12 | ||||
| -rw-r--r-- | node_modules/postcss-import/lib/parse-statements.js | 172 | ||||
| -rw-r--r-- | node_modules/postcss-import/lib/process-content.js | 59 | ||||
| -rw-r--r-- | node_modules/postcss-import/lib/resolve-id.js | 42 |
8 files changed, 0 insertions, 356 deletions
diff --git a/node_modules/postcss-import/lib/assign-layer-names.js b/node_modules/postcss-import/lib/assign-layer-names.js deleted file mode 100644 index 18cfcc71..00000000 --- a/node_modules/postcss-import/lib/assign-layer-names.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict" - -module.exports = function (layer, node, state, options) { - layer.forEach((layerPart, i) => { - if (layerPart.trim() === "") { - if (options.nameLayer) { - layer[i] = options - .nameLayer(state.anonymousLayerCounter++, state.rootFilename) - .toString() - } else { - throw node.error( - `When using anonymous layers in @import you must also set the "nameLayer" plugin option` - ) - } - } - }) -} diff --git a/node_modules/postcss-import/lib/data-url.js b/node_modules/postcss-import/lib/data-url.js deleted file mode 100644 index a59c5fb5..00000000 --- a/node_modules/postcss-import/lib/data-url.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict" - -const dataURLRegexp = /^data:text\/css;base64,/i - -function isValid(url) { - return dataURLRegexp.test(url) -} - -function contents(url) { - // "data:text/css;base64,".length === 21 - return Buffer.from(url.slice(21), "base64").toString() -} - -module.exports = { - isValid, - contents, -} diff --git a/node_modules/postcss-import/lib/join-layer.js b/node_modules/postcss-import/lib/join-layer.js deleted file mode 100644 index 9d915193..00000000 --- a/node_modules/postcss-import/lib/join-layer.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict" - -module.exports = function (parentLayer, childLayer) { - if (!parentLayer.length && childLayer.length) return childLayer - if (parentLayer.length && !childLayer.length) return parentLayer - if (!parentLayer.length && !childLayer.length) return [] - - return parentLayer.concat(childLayer) -} diff --git a/node_modules/postcss-import/lib/join-media.js b/node_modules/postcss-import/lib/join-media.js deleted file mode 100644 index fcaaecd3..00000000 --- a/node_modules/postcss-import/lib/join-media.js +++ /dev/null @@ -1,28 +0,0 @@ -"use strict" - -const startsWithKeywordRegexp = /^(all|not|only|print|screen)/i - -module.exports = function (parentMedia, childMedia) { - if (!parentMedia.length && childMedia.length) return childMedia - if (parentMedia.length && !childMedia.length) return parentMedia - if (!parentMedia.length && !childMedia.length) return [] - - const media = [] - - parentMedia.forEach(parentItem => { - const parentItemStartsWithKeyword = startsWithKeywordRegexp.test(parentItem) - - childMedia.forEach(childItem => { - const childItemStartsWithKeyword = startsWithKeywordRegexp.test(childItem) - if (parentItem !== childItem) { - if (childItemStartsWithKeyword && !parentItemStartsWithKeyword) { - media.push(`${childItem} and ${parentItem}`) - } else { - media.push(`${parentItem} and ${childItem}`) - } - } - }) - }) - - return media -} diff --git a/node_modules/postcss-import/lib/load-content.js b/node_modules/postcss-import/lib/load-content.js deleted file mode 100644 index c10b57e4..00000000 --- a/node_modules/postcss-import/lib/load-content.js +++ /dev/null @@ -1,12 +0,0 @@ -"use strict" - -const readCache = require("read-cache") -const dataURL = require("./data-url") - -module.exports = filename => { - if (dataURL.isValid(filename)) { - return dataURL.contents(filename) - } - - return readCache(filename, "utf-8") -} diff --git a/node_modules/postcss-import/lib/parse-statements.js b/node_modules/postcss-import/lib/parse-statements.js deleted file mode 100644 index 0c94e5a4..00000000 --- a/node_modules/postcss-import/lib/parse-statements.js +++ /dev/null @@ -1,172 +0,0 @@ -"use strict" - -// external tooling -const valueParser = require("postcss-value-parser") - -// extended tooling -const { stringify } = valueParser - -function split(params, start) { - const list = [] - const last = params.reduce((item, node, index) => { - if (index < start) return "" - if (node.type === "div" && node.value === ",") { - list.push(item) - return "" - } - return item + stringify(node) - }, "") - list.push(last) - return list -} - -module.exports = function (result, styles) { - const statements = [] - let nodes = [] - - styles.each(node => { - let stmt - if (node.type === "atrule") { - if (node.name === "import") stmt = parseImport(result, node) - else if (node.name === "media") stmt = parseMedia(result, node) - else if (node.name === "charset") stmt = parseCharset(result, node) - } - - if (stmt) { - if (nodes.length) { - statements.push({ - type: "nodes", - nodes, - media: [], - layer: [], - }) - nodes = [] - } - statements.push(stmt) - } else nodes.push(node) - }) - - if (nodes.length) { - statements.push({ - type: "nodes", - nodes, - media: [], - layer: [], - }) - } - - return statements -} - -function parseMedia(result, atRule) { - const params = valueParser(atRule.params).nodes - return { - type: "media", - node: atRule, - media: split(params, 0), - layer: [], - } -} - -function parseCharset(result, atRule) { - if (atRule.prev()) { - return result.warn("@charset must precede all other statements", { - node: atRule, - }) - } - return { - type: "charset", - node: atRule, - media: [], - layer: [], - } -} - -function parseImport(result, atRule) { - let prev = atRule.prev() - if (prev) { - do { - if ( - prev.type !== "comment" && - (prev.type !== "atrule" || - (prev.name !== "import" && - prev.name !== "charset" && - !(prev.name === "layer" && !prev.nodes))) - ) { - return result.warn( - "@import must precede all other statements (besides @charset or empty @layer)", - { node: atRule } - ) - } - prev = prev.prev() - } while (prev) - } - - if (atRule.nodes) { - return result.warn( - "It looks like you didn't end your @import statement correctly. " + - "Child nodes are attached to it.", - { node: atRule } - ) - } - - const params = valueParser(atRule.params).nodes - const stmt = { - type: "import", - node: atRule, - media: [], - layer: [], - } - - // prettier-ignore - if ( - !params.length || - ( - params[0].type !== "string" || - !params[0].value - ) && - ( - params[0].type !== "function" || - params[0].value !== "url" || - !params[0].nodes.length || - !params[0].nodes[0].value - ) - ) { - return result.warn(`Unable to find uri in '${ atRule.toString() }'`, { - node: atRule, - }) - } - - if (params[0].type === "string") stmt.uri = params[0].value - else stmt.uri = params[0].nodes[0].value - stmt.fullUri = stringify(params[0]) - - let remainder = params - if (remainder.length > 2) { - if ( - (remainder[2].type === "word" || remainder[2].type === "function") && - remainder[2].value === "layer" - ) { - if (remainder[1].type !== "space") { - return result.warn("Invalid import layer statement", { node: atRule }) - } - - if (remainder[2].nodes) { - stmt.layer = [stringify(remainder[2].nodes)] - } else { - stmt.layer = [""] - } - remainder = remainder.slice(2) - } - } - - if (remainder.length > 2) { - if (remainder[1].type !== "space") { - return result.warn("Invalid import media statement", { node: atRule }) - } - - stmt.media = split(remainder, 2) - } - - return stmt -} diff --git a/node_modules/postcss-import/lib/process-content.js b/node_modules/postcss-import/lib/process-content.js deleted file mode 100644 index ec413e06..00000000 --- a/node_modules/postcss-import/lib/process-content.js +++ /dev/null @@ -1,59 +0,0 @@ -"use strict" - -// builtin tooling -const path = require("path") - -// placeholder tooling -let sugarss - -module.exports = function processContent( - result, - content, - filename, - options, - postcss -) { - const { plugins } = options - const ext = path.extname(filename) - - const parserList = [] - - // SugarSS support: - if (ext === ".sss") { - if (!sugarss) { - try { - sugarss = require("sugarss") - } catch {} // Ignore - } - if (sugarss) - return runPostcss(postcss, content, filename, plugins, [sugarss]) - } - - // Syntax support: - if (result.opts.syntax?.parse) { - parserList.push(result.opts.syntax.parse) - } - - // Parser support: - if (result.opts.parser) parserList.push(result.opts.parser) - // Try the default as a last resort: - parserList.push(null) - - return runPostcss(postcss, content, filename, plugins, parserList) -} - -function runPostcss(postcss, content, filename, plugins, parsers, index) { - if (!index) index = 0 - return postcss(plugins) - .process(content, { - from: filename, - parser: parsers[index], - }) - .catch(err => { - // If there's an error, try the next parser - index++ - // If there are no parsers left, throw it - if (index === parsers.length) throw err - return runPostcss(postcss, content, filename, plugins, parsers, index) - }) -} diff --git a/node_modules/postcss-import/lib/resolve-id.js b/node_modules/postcss-import/lib/resolve-id.js deleted file mode 100644 index ffef034c..00000000 --- a/node_modules/postcss-import/lib/resolve-id.js +++ /dev/null @@ -1,42 +0,0 @@ -"use strict" - -// external tooling -const resolve = require("resolve") - -const moduleDirectories = ["web_modules", "node_modules"] - -function resolveModule(id, opts) { - return new Promise((res, rej) => { - resolve(id, opts, (err, path) => (err ? rej(err) : res(path))) - }) -} - -module.exports = function (id, base, options) { - const paths = options.path - - const resolveOpts = { - basedir: base, - moduleDirectory: moduleDirectories.concat(options.addModulesDirectories), - paths, - extensions: [".css"], - packageFilter: function processPackage(pkg) { - if (pkg.style) pkg.main = pkg.style - else if (!pkg.main || !/\.css$/.test(pkg.main)) pkg.main = "index.css" - return pkg - }, - preserveSymlinks: false, - } - - return resolveModule(`./${id}`, resolveOpts) - .catch(() => resolveModule(id, resolveOpts)) - .catch(() => { - if (paths.indexOf(base) === -1) paths.unshift(base) - - throw new Error( - `Failed to find '${id}' - in [ - ${paths.join(",\n ")} - ]` - ) - }) -} |
