diff options
Diffstat (limited to 'node_modules/postcss-discard-overridden')
| -rw-r--r-- | node_modules/postcss-discard-overridden/LICENSE | 20 | ||||
| -rw-r--r-- | node_modules/postcss-discard-overridden/README.md | 158 | ||||
| -rw-r--r-- | node_modules/postcss-discard-overridden/package.json | 37 | ||||
| -rw-r--r-- | node_modules/postcss-discard-overridden/src/index.js | 94 |
4 files changed, 0 insertions, 309 deletions
diff --git a/node_modules/postcss-discard-overridden/LICENSE b/node_modules/postcss-discard-overridden/LICENSE deleted file mode 100644 index f901ded7..00000000 --- a/node_modules/postcss-discard-overridden/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -The MIT License (MIT) - -Copyright 2016 Justineo <justice360@gmail.com> - -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-discard-overridden/README.md b/node_modules/postcss-discard-overridden/README.md deleted file mode 100644 index ad69e50e..00000000 --- a/node_modules/postcss-discard-overridden/README.md +++ /dev/null @@ -1,158 +0,0 @@ -# PostCSS Discard Overridden - -[PostCSS] plugin to discard overridden `@keyframes` or `@counter-style`. - -`@keyframes` or `@counter-style` will be overridden by those who share the same identifiers and appear later in stylesheets. So we can discard all of them except the last one. When defined inside a `@media` or `@supports` rule, `@keyframes` and `@counter-style` rules only override global rules in some of the client browsers so they need handled separately. This plugin has taken care of this and transforms the PostCss AST **safely**. - -[PostCSS]: https://github.com/postcss/postcss - -```css -@-webkit-keyframes fade-in { - 0% { - opacity: 0; - } - 100% { - opacity: 0.8; - } -} -@keyframes fade-in { - 0% { - opacity: 0; - } - 100% { - opacity: 0.8; - } -} -@media (max-width: 500px) { - @-webkit-keyframes fade-in { - 0% { - opacity: 0; - } - 100% { - opacity: 1; - } - } - @keyframes fade-in { - 0% { - opacity: 0; - } - 100% { - opacity: 1; - } - } - @-webkit-keyframes fade-in { - 0% { - opacity: 0; - } - 100% { - opacity: 0.8; - } - } - @keyframes fade-in { - 0% { - opacity: 0; - } - 100% { - opacity: 0.8; - } - } - @supports (display: flex) { - @-webkit-keyframes fade-in { - 0% { - opacity: 0; - } - 100% { - opacity: 1; - } - } - @keyframes fade-in { - 0% { - opacity: 0; - } - 100% { - opacity: 1; - } - } - } -} -@-webkit-keyframes fade-in { - 0% { - opacity: 0; - } - 100% { - opacity: 1; - } -} -@keyframes fade-in { - 0% { - opacity: 0; - } - 100% { - opacity: 1; - } -} -``` - -```css -@media (max-width: 500px) { - @-webkit-keyframes fade-in { - 0% { - opacity: 0; - } - 100% { - opacity: 0.8; - } - } - @keyframes fade-in { - 0% { - opacity: 0; - } - 100% { - opacity: 0.8; - } - } - @supports (display: flex) { - @-webkit-keyframes fade-in { - 0% { - opacity: 0; - } - 100% { - opacity: 1; - } - } - @keyframes fade-in { - 0% { - opacity: 0; - } - 100% { - opacity: 1; - } - } - } -} -@-webkit-keyframes fade-in { - 0% { - opacity: 0; - } - 100% { - opacity: 1; - } -} -@keyframes fade-in { - 0% { - opacity: 0; - } - 100% { - opacity: 1; - } -} -``` - -## Usage - -See the [PostCSS documentation](https://github.com/postcss/postcss#usage) for -examples for your environment. - -## Contributors - -See [CONTRIBUTORS.md](https://github.com/cssnano/cssnano/blob/master/CONTRIBUTORS.md). diff --git a/node_modules/postcss-discard-overridden/package.json b/node_modules/postcss-discard-overridden/package.json deleted file mode 100644 index f989038f..00000000 --- a/node_modules/postcss-discard-overridden/package.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "name": "postcss-discard-overridden", - "version": "6.0.2", - "description": "PostCSS plugin to discard overridden @keyframes or @counter-style.", - "main": "src/index.js", - "types": "types/index.d.ts", - "files": [ - "LICENSE", - "src" - ], - "keywords": [ - "postcss", - "css", - "postcss-plugin", - "at-rules", - "@keyframes", - "@counter-style" - ], - "author": "Justineo <justice360@gmail.com>", - "license": "MIT", - "repository": "cssnano/cssnano", - "bugs": { - "url": "https://github.com/cssnano/cssnano/issues" - }, - "homepage": "https://github.com/cssnano/cssnano", - "engines": { - "node": "^14 || ^16 || >=18.0" - }, - "devDependencies": { - "diff": "^5.2.0", - "picocolors": "^1.0.0", - "postcss": "^8.4.35" - }, - "peerDependencies": { - "postcss": "^8.4.31" - } -}
\ No newline at end of file diff --git a/node_modules/postcss-discard-overridden/src/index.js b/node_modules/postcss-discard-overridden/src/index.js deleted file mode 100644 index 97c8f62e..00000000 --- a/node_modules/postcss-discard-overridden/src/index.js +++ /dev/null @@ -1,94 +0,0 @@ -'use strict'; -const OVERRIDABLE_RULES = new Set(['keyframes', 'counter-style']); -const SCOPE_RULES = new Set(['media', 'supports']); - -/** - * @param {string} prop - * @return {string} - */ -function vendorUnprefixed(prop) { - return prop.replace(/^-\w+-/, ''); -} - -/** - * @param {string} name - * @return {boolean} - */ -function isOverridable(name) { - return OVERRIDABLE_RULES.has(vendorUnprefixed(name.toLowerCase())); -} - -/** - * @param {string} name - * @return {boolean} - */ -function isScope(name) { - return SCOPE_RULES.has(vendorUnprefixed(name.toLowerCase())); -} - -/** - * @param {import('postcss').AtRule} node - * @return {string} - */ -function getScope(node) { - /** @type {import('postcss').Container<import('postcss').ChildNode> | import('postcss').Document | undefined} */ - let current = node.parent; - - const chain = [node.name.toLowerCase(), node.params]; - - while (current) { - if ( - current.type === 'atrule' && - isScope(/** @type import('postcss').AtRule */ (current).name) - ) { - chain.unshift( - /** @type import('postcss').AtRule */ (current).name + - ' ' + - /** @type import('postcss').AtRule */ (current).params - ); - } - current = current.parent; - } - - return chain.join('|'); -} - -/** - * @type {import('postcss').PluginCreator<void>} - * @return {import('postcss').Plugin} - */ -function pluginCreator() { - return { - postcssPlugin: 'postcss-discard-overridden', - prepare() { - const cache = new Map(); - /** @type {{node: import('postcss').AtRule, scope: string}[]} */ - const rules = []; - - return { - OnceExit(css) { - css.walkAtRules((node) => { - if (isOverridable(node.name)) { - const scope = getScope(node); - - cache.set(scope, node); - rules.push({ - node, - scope, - }); - } - }); - - rules.forEach((rule) => { - if (cache.get(rule.scope) !== rule.node) { - rule.node.remove(); - } - }); - }, - }; - }, - }; -} - -pluginCreator.postcss = true; -module.exports = pluginCreator; |
