summaryrefslogtreecommitdiff
path: root/node_modules/postcss-js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/postcss-js')
-rw-r--r--node_modules/postcss-js/LICENSE20
-rw-r--r--node_modules/postcss-js/README.md22
-rw-r--r--node_modules/postcss-js/async.js15
-rw-r--r--node_modules/postcss-js/index.js11
-rw-r--r--node_modules/postcss-js/index.mjs8
-rw-r--r--node_modules/postcss-js/objectifier.js85
-rw-r--r--node_modules/postcss-js/package.json42
-rw-r--r--node_modules/postcss-js/parser.js104
-rw-r--r--node_modules/postcss-js/process-result.js11
-rw-r--r--node_modules/postcss-js/sync.js12
10 files changed, 330 insertions, 0 deletions
diff --git a/node_modules/postcss-js/LICENSE b/node_modules/postcss-js/LICENSE
new file mode 100644
index 0000000..d3bd672
--- /dev/null
+++ b/node_modules/postcss-js/LICENSE
@@ -0,0 +1,20 @@
+The MIT License (MIT)
+
+Copyright 2015 Andrey Sitnik <andrey@sitnik.ru>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/node_modules/postcss-js/README.md b/node_modules/postcss-js/README.md
new file mode 100644
index 0000000..a29e3b0
--- /dev/null
+++ b/node_modules/postcss-js/README.md
@@ -0,0 +1,22 @@
+# PostCSS JS
+
+<img align="right" width="135" height="95"
+ title="Philosopher’s stone, logo of PostCSS"
+ src="https://postcss.org/logo-leftp.svg">
+
+[PostCSS] for CSS-in-JS and styles in JS objects.
+
+For example, to use [Stylelint] or [RTLCSS] plugins in your workflow.
+
+<a href="https://evilmartians.com/?utm_source=postcss-js">
+ <img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg"
+ alt="Sponsored by Evil Martians" width="236" height="54">
+</a>
+
+[Stylelint]: https://github.com/stylelint/stylelint
+[PostCSS]: https://github.com/postcss/postcss
+[RTLCSS]: https://github.com/MohammadYounes/rtlcss
+
+
+## Docs
+Read full docs **[here](https://github.com/postcss/postcss-js#readme)**.
diff --git a/node_modules/postcss-js/async.js b/node_modules/postcss-js/async.js
new file mode 100644
index 0000000..4c2f3c6
--- /dev/null
+++ b/node_modules/postcss-js/async.js
@@ -0,0 +1,15 @@
+let postcss = require('postcss')
+
+let processResult = require('./process-result')
+let parse = require('./parser')
+
+module.exports = function async(plugins) {
+ let processor = postcss(plugins)
+ return async input => {
+ let result = await processor.process(input, {
+ parser: parse,
+ from: undefined
+ })
+ return processResult(result)
+ }
+}
diff --git a/node_modules/postcss-js/index.js b/node_modules/postcss-js/index.js
new file mode 100644
index 0000000..8a4274e
--- /dev/null
+++ b/node_modules/postcss-js/index.js
@@ -0,0 +1,11 @@
+let objectify = require('./objectifier')
+let parse = require('./parser')
+let async = require('./async')
+let sync = require('./sync')
+
+module.exports = {
+ objectify,
+ parse,
+ async,
+ sync
+}
diff --git a/node_modules/postcss-js/index.mjs b/node_modules/postcss-js/index.mjs
new file mode 100644
index 0000000..d14b61c
--- /dev/null
+++ b/node_modules/postcss-js/index.mjs
@@ -0,0 +1,8 @@
+import index from './index.js'
+
+export default index
+
+export const objectify = index.objectify
+export const parse = index.parse
+export const async = index.async
+export const sync = index.sync
diff --git a/node_modules/postcss-js/objectifier.js b/node_modules/postcss-js/objectifier.js
new file mode 100644
index 0000000..a4708b8
--- /dev/null
+++ b/node_modules/postcss-js/objectifier.js
@@ -0,0 +1,85 @@
+let camelcase = require('camelcase-css')
+
+let UNITLESS = {
+ boxFlex: true,
+ boxFlexGroup: true,
+ columnCount: true,
+ flex: true,
+ flexGrow: true,
+ flexPositive: true,
+ flexShrink: true,
+ flexNegative: true,
+ fontWeight: true,
+ lineClamp: true,
+ lineHeight: true,
+ opacity: true,
+ order: true,
+ orphans: true,
+ tabSize: true,
+ widows: true,
+ zIndex: true,
+ zoom: true,
+ fillOpacity: true,
+ strokeDashoffset: true,
+ strokeOpacity: true,
+ strokeWidth: true
+}
+
+function atRule(node) {
+ if (typeof node.nodes === 'undefined') {
+ return true
+ } else {
+ return process(node)
+ }
+}
+
+function process(node) {
+ let name
+ let result = {}
+
+ node.each(child => {
+ if (child.type === 'atrule') {
+ name = '@' + child.name
+ if (child.params) name += ' ' + child.params
+ if (typeof result[name] === 'undefined') {
+ result[name] = atRule(child)
+ } else if (Array.isArray(result[name])) {
+ result[name].push(atRule(child))
+ } else {
+ result[name] = [result[name], atRule(child)]
+ }
+ } else if (child.type === 'rule') {
+ let body = process(child)
+ if (result[child.selector]) {
+ for (let i in body) {
+ result[child.selector][i] = body[i]
+ }
+ } else {
+ result[child.selector] = body
+ }
+ } else if (child.type === 'decl') {
+ if (child.prop[0] === '-' && child.prop[1] === '-') {
+ name = child.prop
+ } else if (child.parent && child.parent.selector === ':export') {
+ name = child.prop
+ } else {
+ name = camelcase(child.prop)
+ }
+ let value = child.value
+ if (!isNaN(child.value) && UNITLESS[name]) {
+ value = parseFloat(child.value)
+ }
+ if (child.important) value += ' !important'
+ if (typeof result[name] === 'undefined') {
+ result[name] = value
+ } else if (Array.isArray(result[name])) {
+ result[name].push(value)
+ } else {
+ result[name] = [result[name], value]
+ }
+ }
+ })
+ return result
+}
+
+module.exports = process
diff --git a/node_modules/postcss-js/package.json b/node_modules/postcss-js/package.json
new file mode 100644
index 0000000..ce0ff35
--- /dev/null
+++ b/node_modules/postcss-js/package.json
@@ -0,0 +1,42 @@
+{
+ "name": "postcss-js",
+ "version": "4.0.1",
+ "description": "PostCSS for CSS-in-JS and styles in JS objects",
+ "keywords": [
+ "postcss",
+ "postcss-runner",
+ "js",
+ "inline",
+ "react",
+ "css",
+ "cssinjs"
+ ],
+ "author": "Andrey Sitnik <andrey@sitnik.ru>",
+ "license": "MIT",
+ "repository": "postcss/postcss-js",
+ "engines": {
+ "node": "^12 || ^14 || >= 16"
+ },
+ "exports": {
+ ".": {
+ "require": "./index.js",
+ "import": "./index.mjs"
+ },
+ "./package.json": "./package.json",
+ "./async": "./async.js",
+ "./objectifier": "./objectifier.js",
+ "./parser": "./parser.js",
+ "./process-result": "./process-result.js",
+ "./sync": "./sync.js"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/postcss/"
+ },
+ "peerDependencies": {
+ "postcss": "^8.4.21"
+ },
+ "dependencies": {
+ "camelcase-css": "^2.0.1"
+ }
+}
diff --git a/node_modules/postcss-js/parser.js b/node_modules/postcss-js/parser.js
new file mode 100644
index 0000000..17ae264
--- /dev/null
+++ b/node_modules/postcss-js/parser.js
@@ -0,0 +1,104 @@
+let postcss = require('postcss')
+
+let IMPORTANT = /\s*!important\s*$/i
+
+let UNITLESS = {
+ 'box-flex': true,
+ 'box-flex-group': true,
+ 'column-count': true,
+ 'flex': true,
+ 'flex-grow': true,
+ 'flex-positive': true,
+ 'flex-shrink': true,
+ 'flex-negative': true,
+ 'font-weight': true,
+ 'line-clamp': true,
+ 'line-height': true,
+ 'opacity': true,
+ 'order': true,
+ 'orphans': true,
+ 'tab-size': true,
+ 'widows': true,
+ 'z-index': true,
+ 'zoom': true,
+ 'fill-opacity': true,
+ 'stroke-dashoffset': true,
+ 'stroke-opacity': true,
+ 'stroke-width': true
+}
+
+function dashify(str) {
+ return str
+ .replace(/([A-Z])/g, '-$1')
+ .replace(/^ms-/, '-ms-')
+ .toLowerCase()
+}
+
+function decl(parent, name, value) {
+ if (value === false || value === null) return
+
+ if (!name.startsWith('--')) {
+ name = dashify(name)
+ }
+
+ if (typeof value === 'number') {
+ if (value === 0 || UNITLESS[name]) {
+ value = value.toString()
+ } else {
+ value += 'px'
+ }
+ }
+
+ if (name === 'css-float') name = 'float'
+
+ if (IMPORTANT.test(value)) {
+ value = value.replace(IMPORTANT, '')
+ parent.push(postcss.decl({ prop: name, value, important: true }))
+ } else {
+ parent.push(postcss.decl({ prop: name, value }))
+ }
+}
+
+function atRule(parent, parts, value) {
+ let node = postcss.atRule({ name: parts[1], params: parts[3] || '' })
+ if (typeof value === 'object') {
+ node.nodes = []
+ parse(value, node)
+ }
+ parent.push(node)
+}
+
+function parse(obj, parent) {
+ let name, value, node
+ for (name in obj) {
+ value = obj[name]
+ if (value === null || typeof value === 'undefined') {
+ continue
+ } else if (name[0] === '@') {
+ let parts = name.match(/@(\S+)(\s+([\W\w]*)\s*)?/)
+ if (Array.isArray(value)) {
+ for (let i of value) {
+ atRule(parent, parts, i)
+ }
+ } else {
+ atRule(parent, parts, value)
+ }
+ } else if (Array.isArray(value)) {
+ for (let i of value) {
+ decl(parent, name, i)
+ }
+ } else if (typeof value === 'object') {
+ node = postcss.rule({ selector: name })
+ parse(value, node)
+ parent.push(node)
+ } else {
+ decl(parent, name, value)
+ }
+ }
+}
+
+module.exports = function (obj) {
+ let root = postcss.root()
+ parse(obj, root)
+ return root
+}
diff --git a/node_modules/postcss-js/process-result.js b/node_modules/postcss-js/process-result.js
new file mode 100644
index 0000000..215a95c
--- /dev/null
+++ b/node_modules/postcss-js/process-result.js
@@ -0,0 +1,11 @@
+let objectify = require('./objectifier')
+
+module.exports = function processResult(result) {
+ if (console && console.warn) {
+ result.warnings().forEach(warn => {
+ let source = warn.plugin || 'PostCSS'
+ console.warn(source + ': ' + warn.text)
+ })
+ }
+ return objectify(result.root)
+}
diff --git a/node_modules/postcss-js/sync.js b/node_modules/postcss-js/sync.js
new file mode 100644
index 0000000..745bd27
--- /dev/null
+++ b/node_modules/postcss-js/sync.js
@@ -0,0 +1,12 @@
+let postcss = require('postcss')
+
+let processResult = require('./process-result')
+let parse = require('./parser')
+
+module.exports = function (plugins) {
+ let processor = postcss(plugins)
+ return input => {
+ let result = processor.process(input, { parser: parse, from: undefined })
+ return processResult(result)
+ }
+}