summaryrefslogtreecommitdiff
path: root/node_modules/postcss/lib/processor.js
diff options
context:
space:
mode:
authorChristian Cleberg <[email protected]>2026-04-18 22:32:53 -0500
committerChristian Cleberg <[email protected]>2026-04-18 22:32:53 -0500
commit580e798e16346eb894eb899edac82d2efdf40adc (patch)
tree6dec3b7db678f781138b40d34da37d21ac8fbe7d /node_modules/postcss/lib/processor.js
downloadbrand-bench-580e798e16346eb894eb899edac82d2efdf40adc.tar.gz
brand-bench-580e798e16346eb894eb899edac82d2efdf40adc.tar.bz2
brand-bench-580e798e16346eb894eb899edac82d2efdf40adc.zip
initial commit
Diffstat (limited to 'node_modules/postcss/lib/processor.js')
-rw-r--r--node_modules/postcss/lib/processor.js67
1 files changed, 67 insertions, 0 deletions
diff --git a/node_modules/postcss/lib/processor.js b/node_modules/postcss/lib/processor.js
new file mode 100644
index 0000000..5eda6c4
--- /dev/null
+++ b/node_modules/postcss/lib/processor.js
@@ -0,0 +1,67 @@
+'use strict'
+
+let Document = require('./document')
+let LazyResult = require('./lazy-result')
+let NoWorkResult = require('./no-work-result')
+let Root = require('./root')
+
+class Processor {
+ constructor(plugins = []) {
+ this.version = '8.5.10'
+ this.plugins = this.normalize(plugins)
+ }
+
+ normalize(plugins) {
+ let normalized = []
+ for (let i of plugins) {
+ if (i.postcss === true) {
+ i = i()
+ } else if (i.postcss) {
+ i = i.postcss
+ }
+
+ if (typeof i === 'object' && Array.isArray(i.plugins)) {
+ normalized = normalized.concat(i.plugins)
+ } else if (typeof i === 'object' && i.postcssPlugin) {
+ normalized.push(i)
+ } else if (typeof i === 'function') {
+ normalized.push(i)
+ } else if (typeof i === 'object' && (i.parse || i.stringify)) {
+ if (process.env.NODE_ENV !== 'production') {
+ throw new Error(
+ 'PostCSS syntaxes cannot be used as plugins. Instead, please use ' +
+ 'one of the syntax/parser/stringifier options as outlined ' +
+ 'in your PostCSS runner documentation.'
+ )
+ }
+ } else {
+ throw new Error(i + ' is not a PostCSS plugin')
+ }
+ }
+ return normalized
+ }
+
+ process(css, opts = {}) {
+ if (
+ !this.plugins.length &&
+ !opts.parser &&
+ !opts.stringifier &&
+ !opts.syntax
+ ) {
+ return new NoWorkResult(this, css, opts)
+ } else {
+ return new LazyResult(this, css, opts)
+ }
+ }
+
+ use(plugin) {
+ this.plugins = this.plugins.concat(this.normalize([plugin]))
+ return this
+ }
+}
+
+module.exports = Processor
+Processor.default = Processor
+
+Root.registerProcessor(Processor)
+Document.registerProcessor(Processor)