first
This commit is contained in:
22
node_modules/postcss-minify-gradients/LICENSE-MIT
generated
vendored
Normal file
22
node_modules/postcss-minify-gradients/LICENSE-MIT
generated
vendored
Normal 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.
|
53
node_modules/postcss-minify-gradients/README.md
generated
vendored
Normal file
53
node_modules/postcss-minify-gradients/README.md
generated
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
# [postcss][postcss]-minify-gradients
|
||||
|
||||
> Minify gradient parameters with PostCSS.
|
||||
|
||||
## Install
|
||||
|
||||
With [npm](https://npmjs.org/package/postcss-minify-gradients) do:
|
||||
|
||||
```
|
||||
npm install postcss-minify-gradients
|
||||
```
|
||||
|
||||
|
||||
## Example
|
||||
|
||||
Where possible, this module will minify gradient parameters. It can convert
|
||||
linear gradient directional syntax to angles, remove the unnecessary `0%` and
|
||||
`100%` start and end values, and minimise color stops that use the same length
|
||||
values (the browser will adjust the value automatically).
|
||||
|
||||
### Input
|
||||
|
||||
```css
|
||||
h1 {
|
||||
background: linear-gradient(to bottom, #ffe500 0%, #ffe500 50%, #121 50%, #121 100%)
|
||||
}
|
||||
```
|
||||
|
||||
### Output
|
||||
|
||||
```css
|
||||
h1 {
|
||||
background: linear-gradient(180deg, #ffe500, #ffe500 50%, #121 0, #121)
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## 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
|
70
node_modules/postcss-minify-gradients/package.json
generated
vendored
Normal file
70
node_modules/postcss-minify-gradients/package.json
generated
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
{
|
||||
"_from": "postcss-minify-gradients@^5.1.1",
|
||||
"_id": "postcss-minify-gradients@5.1.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-VGvXMTpCEo4qHTNSa9A0a3D+dxGFZCYwR6Jokk+/3oB6flu2/PnPXAh2x7x52EkY5xlIHLm+Le8tJxe/7TNhzw==",
|
||||
"_location": "/postcss-minify-gradients",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "postcss-minify-gradients@^5.1.1",
|
||||
"name": "postcss-minify-gradients",
|
||||
"escapedName": "postcss-minify-gradients",
|
||||
"rawSpec": "^5.1.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^5.1.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/cssnano-preset-default"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/postcss-minify-gradients/-/postcss-minify-gradients-5.1.1.tgz",
|
||||
"_shasum": "f1fe1b4f498134a5068240c2f25d46fcd236ba2c",
|
||||
"_spec": "postcss-minify-gradients@^5.1.1",
|
||||
"_where": "C:\\Users\\zhouxueli\\Desktop\\scheduling-app\\node_modules\\cssnano-preset-default",
|
||||
"author": {
|
||||
"name": "Ben Briggs",
|
||||
"email": "beneb.info@gmail.com",
|
||||
"url": "http://beneb.info"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/cssnano/cssnano/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"colord": "^2.9.1",
|
||||
"cssnano-utils": "^3.1.0",
|
||||
"postcss-value-parser": "^4.2.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Minify gradient parameters with PostCSS.",
|
||||
"devDependencies": {
|
||||
"postcss": "^8.2.15"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^10 || ^12 || >=14.0"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE-MIT",
|
||||
"src",
|
||||
"types"
|
||||
],
|
||||
"homepage": "https://github.com/cssnano/cssnano",
|
||||
"keywords": [
|
||||
"css",
|
||||
"postcss",
|
||||
"postcss-plugin"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "src/index.js",
|
||||
"name": "postcss-minify-gradients",
|
||||
"peerDependencies": {
|
||||
"postcss": "^8.2.15"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/cssnano/cssnano.git"
|
||||
},
|
||||
"types": "types/index.d.ts",
|
||||
"version": "5.1.1"
|
||||
}
|
224
node_modules/postcss-minify-gradients/src/index.js
generated
vendored
Normal file
224
node_modules/postcss-minify-gradients/src/index.js
generated
vendored
Normal file
@ -0,0 +1,224 @@
|
||||
'use strict';
|
||||
const valueParser = require('postcss-value-parser');
|
||||
const { getArguments } = require('cssnano-utils');
|
||||
const isColorStop = require('./isColorStop.js');
|
||||
|
||||
const angles = {
|
||||
top: '0deg',
|
||||
right: '90deg',
|
||||
bottom: '180deg',
|
||||
left: '270deg',
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {valueParser.Dimension} a
|
||||
* @param {valueParser.Dimension} b
|
||||
* @return {boolean}
|
||||
*/
|
||||
function isLessThan(a, b) {
|
||||
return (
|
||||
a.unit.toLowerCase() === b.unit.toLowerCase() &&
|
||||
parseFloat(a.number) >= parseFloat(b.number)
|
||||
);
|
||||
}
|
||||
/**
|
||||
* @param {import('postcss').Declaration} decl
|
||||
* @return {void}
|
||||
*/
|
||||
function optimise(decl) {
|
||||
const value = decl.value;
|
||||
|
||||
if (!value) {
|
||||
return;
|
||||
}
|
||||
|
||||
const normalizedValue = value.toLowerCase();
|
||||
|
||||
if (normalizedValue.includes('var(') || normalizedValue.includes('env(')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!normalizedValue.includes('gradient')) {
|
||||
return;
|
||||
}
|
||||
|
||||
decl.value = valueParser(value)
|
||||
.walk((node) => {
|
||||
if (node.type !== 'function' || !node.nodes.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const lowerCasedValue = node.value.toLowerCase();
|
||||
|
||||
if (
|
||||
lowerCasedValue === 'linear-gradient' ||
|
||||
lowerCasedValue === 'repeating-linear-gradient' ||
|
||||
lowerCasedValue === '-webkit-linear-gradient' ||
|
||||
lowerCasedValue === '-webkit-repeating-linear-gradient'
|
||||
) {
|
||||
let args = getArguments(node);
|
||||
|
||||
if (
|
||||
node.nodes[0].value.toLowerCase() === 'to' &&
|
||||
args[0].length === 3
|
||||
) {
|
||||
node.nodes = node.nodes.slice(2);
|
||||
node.nodes[0].value =
|
||||
angles[
|
||||
/** @type {'top'|'right'|'bottom'|'left'}*/ (
|
||||
node.nodes[0].value.toLowerCase()
|
||||
)
|
||||
];
|
||||
}
|
||||
|
||||
/** @type {valueParser.Dimension | false} */
|
||||
let lastStop;
|
||||
|
||||
args.forEach((arg, index) => {
|
||||
if (arg.length !== 3) {
|
||||
return;
|
||||
}
|
||||
|
||||
let isFinalStop = index === args.length - 1;
|
||||
let thisStop = valueParser.unit(arg[2].value);
|
||||
|
||||
if (lastStop === undefined) {
|
||||
lastStop = thisStop;
|
||||
|
||||
if (
|
||||
!isFinalStop &&
|
||||
lastStop &&
|
||||
lastStop.number === '0' &&
|
||||
lastStop.unit.toLowerCase() !== 'deg'
|
||||
) {
|
||||
arg[1].value = arg[2].value = '';
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (lastStop && thisStop && isLessThan(lastStop, thisStop)) {
|
||||
arg[2].value = '0';
|
||||
}
|
||||
|
||||
lastStop = thisStop;
|
||||
|
||||
if (isFinalStop && arg[2].value === '100%') {
|
||||
arg[1].value = arg[2].value = '';
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (
|
||||
lowerCasedValue === 'radial-gradient' ||
|
||||
lowerCasedValue === 'repeating-radial-gradient'
|
||||
) {
|
||||
let args = getArguments(node);
|
||||
/** @type {valueParser.Dimension | false} */
|
||||
let lastStop;
|
||||
|
||||
const hasAt = args[0].find((n) => n.value.toLowerCase() === 'at');
|
||||
|
||||
args.forEach((arg, index) => {
|
||||
if (!arg[2] || (!index && hasAt)) {
|
||||
return;
|
||||
}
|
||||
|
||||
let thisStop = valueParser.unit(arg[2].value);
|
||||
|
||||
if (!lastStop) {
|
||||
lastStop = thisStop;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (lastStop && thisStop && isLessThan(lastStop, thisStop)) {
|
||||
arg[2].value = '0';
|
||||
}
|
||||
|
||||
lastStop = thisStop;
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (
|
||||
lowerCasedValue === '-webkit-radial-gradient' ||
|
||||
lowerCasedValue === '-webkit-repeating-radial-gradient'
|
||||
) {
|
||||
let args = getArguments(node);
|
||||
/** @type {valueParser.Dimension | false} */
|
||||
let lastStop;
|
||||
|
||||
args.forEach((arg) => {
|
||||
let color;
|
||||
let stop;
|
||||
|
||||
if (arg[2] !== undefined) {
|
||||
if (arg[0].type === 'function') {
|
||||
color = `${arg[0].value}(${valueParser.stringify(arg[0].nodes)})`;
|
||||
} else {
|
||||
color = arg[0].value;
|
||||
}
|
||||
|
||||
if (arg[2].type === 'function') {
|
||||
stop = `${arg[2].value}(${valueParser.stringify(arg[2].nodes)})`;
|
||||
} else {
|
||||
stop = arg[2].value;
|
||||
}
|
||||
} else {
|
||||
if (arg[0].type === 'function') {
|
||||
color = `${arg[0].value}(${valueParser.stringify(arg[0].nodes)})`;
|
||||
}
|
||||
|
||||
color = arg[0].value;
|
||||
}
|
||||
|
||||
color = color.toLowerCase();
|
||||
|
||||
const colorStop =
|
||||
stop !== undefined
|
||||
? isColorStop(color, stop.toLowerCase())
|
||||
: isColorStop(color);
|
||||
|
||||
if (!colorStop || !arg[2]) {
|
||||
return;
|
||||
}
|
||||
|
||||
let thisStop = valueParser.unit(arg[2].value);
|
||||
|
||||
if (!lastStop) {
|
||||
lastStop = thisStop;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (lastStop && thisStop && isLessThan(lastStop, thisStop)) {
|
||||
arg[2].value = '0';
|
||||
}
|
||||
|
||||
lastStop = thisStop;
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.toString();
|
||||
}
|
||||
/**
|
||||
* @type {import('postcss').PluginCreator<void>}
|
||||
* @return {import('postcss').Plugin}
|
||||
*/
|
||||
function pluginCreator() {
|
||||
return {
|
||||
postcssPlugin: 'postcss-minify-gradients',
|
||||
OnceExit(css) {
|
||||
css.walkDecls(optimise);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
pluginCreator.postcss = true;
|
||||
module.exports = pluginCreator;
|
62
node_modules/postcss-minify-gradients/src/isColorStop.js
generated
vendored
Normal file
62
node_modules/postcss-minify-gradients/src/isColorStop.js
generated
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
'use strict';
|
||||
const { unit } = require('postcss-value-parser');
|
||||
const { colord, extend } = require('colord');
|
||||
const namesPlugin = require('colord/plugins/names');
|
||||
|
||||
extend([/** @type {any} */ (namesPlugin)]);
|
||||
|
||||
/* Code derived from https://github.com/pigcan/is-color-stop */
|
||||
|
||||
const lengthUnits = new Set([
|
||||
'PX',
|
||||
'IN',
|
||||
'CM',
|
||||
'MM',
|
||||
'EM',
|
||||
'REM',
|
||||
'POINTS',
|
||||
'PC',
|
||||
'EX',
|
||||
'CH',
|
||||
'VW',
|
||||
'VH',
|
||||
'VMIN',
|
||||
'VMAX',
|
||||
'%',
|
||||
]);
|
||||
|
||||
/**
|
||||
* @param {string} input
|
||||
* @return {boolean}
|
||||
*/
|
||||
function isCSSLengthUnit(input) {
|
||||
return lengthUnits.has(input.toUpperCase());
|
||||
}
|
||||
/**
|
||||
* @param {string|undefined} str
|
||||
* @return {boolean}
|
||||
*/
|
||||
function isStop(str) {
|
||||
if (str) {
|
||||
let stop = false;
|
||||
const node = unit(str);
|
||||
if (node) {
|
||||
const number = Number(node.number);
|
||||
if (number === 0 || (!isNaN(number) && isCSSLengthUnit(node.unit))) {
|
||||
stop = true;
|
||||
}
|
||||
} else {
|
||||
stop = /^calc\(\S+\)$/g.test(str);
|
||||
}
|
||||
return stop;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* @param {string} color
|
||||
* @param {string} [stop]
|
||||
* @return {boolean}
|
||||
*/
|
||||
module.exports = function isColorStop(color, stop) {
|
||||
return colord(color).isValid() && isStop(stop);
|
||||
};
|
9
node_modules/postcss-minify-gradients/types/index.d.ts
generated
vendored
Normal file
9
node_modules/postcss-minify-gradients/types/index.d.ts
generated
vendored
Normal 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;
|
||||
}
|
2
node_modules/postcss-minify-gradients/types/isColorStop.d.ts
generated
vendored
Normal file
2
node_modules/postcss-minify-gradients/types/isColorStop.d.ts
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
declare function _exports(color: string, stop?: string | undefined): boolean;
|
||||
export = _exports;
|
Reference in New Issue
Block a user