This commit is contained in:
2024-03-22 03:47:51 +05:30
parent 8bcf3d211e
commit 89819f6fe2
28440 changed files with 3211033 additions and 2 deletions

22
node_modules/postcss-merge-idents/LICENSE-MIT generated vendored Normal file
View File

@@ -0,0 +1,22 @@
Copyright (c) Ben Briggs <beneb.info@gmail.com> (http://beneb.info)
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.

77
node_modules/postcss-merge-idents/README.md generated vendored Normal file
View File

@@ -0,0 +1,77 @@
# [postcss][postcss]-merge-idents
> Merge keyframe and counter style identifiers.
## Install
With [npm](https://npmjs.org/package/postcss-merge-idents) do:
```
npm install postcss-merge-idents --save
```
## Example
This module will merge identifiers such as `@keyframes` and `@counter-style`,
if their properties are identical. Then, it will update those declarations that
depend on the duplicated property.
### Input
```css
@keyframes rotate {
from { transform: rotate(0) }
to { transform: rotate(360deg) }
}
@keyframes flip {
from { transform: rotate(0) }
to { transform: rotate(360deg) }
}
.rotate {
animation-name: rotate
}
.flip {
animation-name: flip
}
```
### Output
```css
@keyframes flip {
from { transform: rotate(0) }
to { transform: rotate(360deg) }
}
.rotate {
animation-name: flip
}
.flip {
animation-name: flip
}
```
## 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).
## License
MIT © [Ben Briggs](http://beneb.info)
[postcss]: https://github.com/postcss/postcss

43
node_modules/postcss-merge-idents/package.json generated vendored Normal file
View File

@@ -0,0 +1,43 @@
{
"name": "postcss-merge-idents",
"version": "5.1.1",
"description": "Merge keyframe and counter style identifiers.",
"main": "src/index.js",
"types": "types/index.d.ts",
"files": [
"src",
"LICENSE-MIT",
"types"
],
"keywords": [
"css",
"merge",
"postcss",
"postcss-plugin"
],
"license": "MIT",
"homepage": "https://github.com/cssnano/cssnano",
"author": {
"name": "Ben Briggs",
"email": "beneb.info@gmail.com",
"url": "http://beneb.info"
},
"repository": "cssnano/cssnano",
"dependencies": {
"cssnano-utils": "^3.1.0",
"postcss-value-parser": "^4.2.0"
},
"bugs": {
"url": "https://github.com/cssnano/cssnano/issues"
},
"engines": {
"node": "^10 || ^12 || >=14.0"
},
"devDependencies": {
"postcss": "^8.2.15"
},
"peerDependencies": {
"postcss": "^8.2.15"
},
"readme": "# [postcss][postcss]-merge-idents\n\n> Merge keyframe and counter style identifiers.\n\n\n## Install\n\nWith [npm](https://npmjs.org/package/postcss-merge-idents) do:\n\n```\nnpm install postcss-merge-idents --save\n```\n\n\n## Example\n\nThis module will merge identifiers such as `@keyframes` and `@counter-style`,\nif their properties are identical. Then, it will update those declarations that\ndepend on the duplicated property.\n\n### Input\n\n```css\n@keyframes rotate {\n from { transform: rotate(0) }\n to { transform: rotate(360deg) }\n}\n\n@keyframes flip {\n from { transform: rotate(0) }\n to { transform: rotate(360deg) }\n}\n\n.rotate {\n animation-name: rotate\n}\n\n.flip {\n animation-name: flip\n}\n```\n\n### Output\n\n```css\n@keyframes flip {\n from { transform: rotate(0) }\n to { transform: rotate(360deg) }\n}\n\n.rotate {\n animation-name: flip\n}\n\n.flip {\n animation-name: flip\n}\n```\n\n\n## Usage\n\nSee the [PostCSS documentation](https://github.com/postcss/postcss#usage) for\nexamples for your environment.\n\n\n## Contributors\n\nSee [CONTRIBUTORS.md](https://github.com/cssnano/cssnano/blob/master/CONTRIBUTORS.md).\n\n\n## License\n\nMIT © [Ben Briggs](http://beneb.info)\n\n\n[postcss]: https://github.com/postcss/postcss\n"
}

146
node_modules/postcss-merge-idents/src/index.js generated vendored Normal file
View File

@@ -0,0 +1,146 @@
'use strict';
const valueParser = require('postcss-value-parser');
const { sameParent } = require('cssnano-utils');
/**
* @param {Record<string, string>} obj
* @return {(key: string) => string}
*/
function canonical(obj) {
// Prevent potential infinite loops
let stack = 50;
/**
* @param {string} key
* @return {string}
*/
return function recurse(key) {
if (
Object.prototype.hasOwnProperty.call(obj, key) &&
obj[key] !== key &&
stack
) {
stack--;
return recurse(obj[key]);
}
stack = 50;
return key;
};
}
/**
* @param {import('postcss').Root} css
* @return {void}
*/
function mergeAtRules(css) {
const pairs = [
{
atrule: /keyframes/i,
decl: /animation/i,
/** @type {import('postcss').AtRule[]} */
cache: [],
replacements: {},
/** @type {import('postcss').Declaration[]} */
decls: [],
/** @type {import('postcss').AtRule[]} */
removals: [],
},
{
atrule: /counter-style/i,
decl: /(list-style|system)/i,
cache: [],
replacements: {},
decls: [],
removals: [],
},
];
/**
* @type {{atrule: RegExp, decl: RegExp, replacements: Record<string, string>, removals: import('postcss').AtRule[], cache: import('postcss').AtRule[], decls: import('postcss').Declaration[]}}
*/
let relevant;
css.walk((node) => {
if (node.type === 'atrule') {
relevant = pairs.filter((pair) =>
pair.atrule.test(node.name.toLowerCase())
)[0];
if (!relevant) {
return;
}
if (relevant.cache.length < 1) {
relevant.cache.push(node);
return;
} else {
let toString = node.nodes.toString();
relevant.cache.forEach((cached) => {
if (
cached.name.toLowerCase() === node.name.toLowerCase() &&
sameParent(
/** @type {any} */ (cached),
/** @type {any} */ (node)
) &&
cached.nodes.toString() === toString
) {
relevant.removals.push(cached);
relevant.replacements[cached.params] = node.params;
}
});
relevant.cache.push(node);
return;
}
}
if (node.type === 'decl') {
relevant = pairs.filter((pair) =>
pair.decl.test(node.prop.toLowerCase())
)[0];
if (!relevant) {
return;
}
relevant.decls.push(node);
}
});
pairs.forEach((pair) => {
let canon = canonical(pair.replacements);
pair.decls.forEach((decl) => {
decl.value = valueParser(decl.value)
.walk((node) => {
if (node.type === 'word') {
node.value = canon(node.value);
}
})
.toString();
});
pair.removals.forEach((cached) => cached.remove());
});
}
/**
* @type {import('postcss').PluginCreator<void>}
* @return {import('postcss').Plugin}
*/
function pluginCreator() {
return {
postcssPlugin: 'postcss-merge-idents',
OnceExit(css) {
mergeAtRules(css);
},
};
}
pluginCreator.postcss = true;
module.exports = pluginCreator;

9
node_modules/postcss-merge-idents/types/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,9 @@
export = pluginCreator;
/**
* @type {import('postcss').PluginCreator<void>}
* @return {import('postcss').Plugin}
*/
declare function pluginCreator(): import('postcss').Plugin;
declare namespace pluginCreator {
const postcss: true;
}