diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2026-05-18 23:10:59 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2026-05-18 23:41:44 +0800 |
| commit | fc87c009806dcc98867f6b58efe29b042aa01dee (patch) | |
| tree | 8f59b3f4a5b66e9dfef2d40c8d318e258a521228 /node_modules/postcss-convert-values | |
| parent | 3336b2356ee6152d9c6ae59bd9b87ccbc0958407 (diff) | |
node: updatemain
Diffstat (limited to 'node_modules/postcss-convert-values')
9 files changed, 0 insertions, 524 deletions
diff --git a/node_modules/postcss-convert-values/LICENSE-MIT b/node_modules/postcss-convert-values/LICENSE-MIT deleted file mode 100644 index fd0e863a..00000000 --- a/node_modules/postcss-convert-values/LICENSE-MIT +++ /dev/null @@ -1,22 +0,0 @@ -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. diff --git a/node_modules/postcss-convert-values/README.md b/node_modules/postcss-convert-values/README.md deleted file mode 100644 index 5378fc36..00000000 --- a/node_modules/postcss-convert-values/README.md +++ /dev/null @@ -1,98 +0,0 @@ -# [postcss][postcss]-convert-values - -> Convert values with PostCSS (e.g. ms -> s) - -## Install - -With [npm](https://npmjs.org/package/postcss-convert-values) do: - -``` -npm install postcss-convert-values --save -``` - -## Example - -This plugin reduces CSS size by converting values to use different units -where possible; for example, `500ms` can be represented as `.5s`. You can -read more about these units in [this article][csstricks]. - -### Input - -```css -h1 { - font-size: 16px; - width: 0em -} -``` - -### Output - -```css -h1 { - font-size: 1pc; - width: 0 -} -``` - -Note that this plugin only covers conversions for duration and absolute length -values. For color conversions, use [postcss-colormin][colormin]. - -## API - -### convertValues([options]) - -#### options - -##### length - -Type: `boolean` -Default: `true` - -Pass `false` to disable conversion from `px` to other absolute length units, -such as `pc` & `pt` & vice versa. - -##### time - -Type: `boolean` -Default: `true` - -Pass `false` to disable conversion from `ms` to `s` & vice versa. - -##### angle - -Type: `boolean` -Default: `true` - -Pass `false` to disable conversion from `deg` to `turn` & vice versa. - -##### precision - -Type: `boolean|number` -Default: `false` - -Specify any numeric value here to round `px` values to that many decimal places; -for example, using `{precision: 2}` will round `6.66667px` to `6.67px`, and -`{precision: 0}` will round it to `7px`. Passing `false` (the default) will -leave these values as is. - -It is recommended for most use cases to set this option to `2`. - - -## 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 -[csstricks]: https://css-tricks.com/the-lengths-of-css/ diff --git a/node_modules/postcss-convert-values/package.json b/node_modules/postcss-convert-values/package.json deleted file mode 100644 index 673a2b2e..00000000 --- a/node_modules/postcss-convert-values/package.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "name": "postcss-convert-values", - "version": "6.1.0", - "description": "Convert values with PostCSS (e.g. ms -> s)", - "main": "src/index.js", - "types": "types/index.d.ts", - "files": [ - "LICENSE-MIT", - "src", - "types" - ], - "keywords": [ - "css", - "optimisation", - "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": { - "browserslist": "^4.23.0", - "postcss-value-parser": "^4.2.0" - }, - "bugs": { - "url": "https://github.com/cssnano/cssnano/issues" - }, - "engines": { - "node": "^14 || ^16 || >=18.0" - }, - "devDependencies": { - "postcss": "^8.4.35" - }, - "peerDependencies": { - "postcss": "^8.4.31" - } -}
\ No newline at end of file diff --git a/node_modules/postcss-convert-values/src/index.js b/node_modules/postcss-convert-values/src/index.js deleted file mode 100644 index 85755753..00000000 --- a/node_modules/postcss-convert-values/src/index.js +++ /dev/null @@ -1,237 +0,0 @@ -'use strict'; -const { dirname } = require('path'); -const valueParser = require('postcss-value-parser'); -const browserslist = require('browserslist'); -const convert = require('./lib/convert.js'); - -const LENGTH_UNITS = new Set([ - 'em', - 'ex', - 'ch', - 'rem', - 'vw', - 'vh', - 'vmin', - 'vmax', - 'cm', - 'mm', - 'q', - 'in', - 'pt', - 'pc', - 'px', -]); - -// These properties only accept percentages, so no point in trying to transform -const notALength = new Set([ - 'descent-override', - 'ascent-override', - 'font-stretch', - 'size-adjust', - 'line-gap-override', -]); - -// Can't change the unit on these properties when they're 0 -const keepWhenZero = new Set([ - 'stroke-dashoffset', - 'stroke-width', - 'line-height', -]); - -// Can't remove the % on these properties when they're 0 on IE 11 -const keepZeroPercent = new Set(['max-height', 'height', 'min-width']); - -/** - * Numbers without digits after the dot are technically invalid, - * but in that case css-value-parser returns the dot as part of the unit, - * so we use this to remove the dot. - * - * @param {string} item - * @return {string} - */ -function stripLeadingDot(item) { - if (item.charCodeAt(0) === '.'.charCodeAt(0)) { - return item.slice(1); - } else { - return item; - } -} - -/** - * @param {valueParser.Node} node - * @param {Options} opts - * @param {boolean} keepZeroUnit - * @return {void} - */ -function parseWord(node, opts, keepZeroUnit) { - const pair = valueParser.unit(node.value); - if (pair) { - const num = Number(pair.number); - const u = stripLeadingDot(pair.unit); - if (num === 0) { - node.value = - 0 + - (keepZeroUnit || (!LENGTH_UNITS.has(u.toLowerCase()) && u !== '%') - ? u - : ''); - } else { - node.value = convert(num, u, opts); - - if ( - typeof opts.precision === 'number' && - u.toLowerCase() === 'px' && - pair.number.includes('.') - ) { - const precision = Math.pow(10, opts.precision); - node.value = - Math.round(parseFloat(node.value) * precision) / precision + u; - } - } - } -} - -/** - * @param {valueParser.WordNode} node - * @return {void} - */ -function clampOpacity(node) { - const pair = valueParser.unit(node.value); - if (!pair) { - return; - } - let num = Number(pair.number); - if (num > 1) { - node.value = pair.unit === '%' ? num + pair.unit : 1 + pair.unit; - } else if (num < 0) { - node.value = 0 + pair.unit; - } -} - -/** - * @param {import('postcss').Declaration} decl - * @param {string[]} browsers - * @return {boolean} - */ -function shouldKeepZeroUnit(decl, browsers) { - const { parent } = decl; - const lowerCasedProp = decl.prop.toLowerCase(); - - return ( - (decl.value.includes('%') && - keepZeroPercent.has(lowerCasedProp) && - browsers.includes('ie 11')) || - (lowerCasedProp === 'stroke-dasharray' && - parent && - parent.parent && - parent.parent.type === 'atrule' && - /** @type {import('postcss').AtRule} */ - (parent.parent).name.toLowerCase() === 'keyframes') || - (lowerCasedProp === 'initial-value' && - parent && - parent.type === 'atrule' && - /** @type {import('postcss').AtRule} */ - (parent).name === 'property' && - /** @type {import('postcss').AtRule} */ - (parent).nodes !== undefined && - /** @type {import('postcss').AtRule} */ - (parent).nodes.some( - (node) => - node.type === 'decl' && - node.prop.toLowerCase() === 'syntax' && - node.value === "'<percentage>'" - )) || - keepWhenZero.has(lowerCasedProp) - ); -} -/** - * @param {Options} opts - * @param {string[]} browsers - * @param {import('postcss').Declaration} decl - * @return {void} - */ -function transform(opts, browsers, decl) { - const lowerCasedProp = decl.prop.toLowerCase(); - if ( - lowerCasedProp.includes('flex') || - lowerCasedProp.indexOf('--') === 0 || - notALength.has(lowerCasedProp) - ) { - return; - } - - decl.value = valueParser(decl.value) - .walk((node) => { - const lowerCasedValue = node.value.toLowerCase(); - - if (node.type === 'word') { - parseWord(node, opts, shouldKeepZeroUnit(decl, browsers)); - if ( - lowerCasedProp === 'opacity' || - lowerCasedProp === 'shape-image-threshold' - ) { - clampOpacity(node); - } - } else if (node.type === 'function') { - if ( - lowerCasedValue === 'calc' || - lowerCasedValue === 'min' || - lowerCasedValue === 'max' || - lowerCasedValue === 'clamp' || - lowerCasedValue === 'hsl' || - lowerCasedValue === 'hsla' - ) { - valueParser.walk(node.nodes, (n) => { - if (n.type === 'word') { - parseWord(n, opts, true); - } - }); - return false; - } - if (lowerCasedValue === 'url') { - return false; - } - } - }) - .toString(); -} - -const plugin = 'postcss-convert-values'; - -/** - * @typedef {Parameters<typeof convert>[2]} ConvertOptions - * @typedef {{ overrideBrowserslist?: string | string[] }} AutoprefixerOptions - * @typedef {Pick<browserslist.Options, 'stats' | 'path' | 'env'>} BrowserslistOptions - * @typedef {{precision?: false | number} & ConvertOptions & AutoprefixerOptions & BrowserslistOptions} Options - */ - -/** - * @type {import('postcss').PluginCreator<Options>} - * @param {Options} opts - * @return {import('postcss').Plugin} - */ -function pluginCreator(opts = { precision: false }) { - return { - postcssPlugin: plugin, - - /** - * @param {import('postcss').Result & {opts: BrowserslistOptions & {file?: string}}} result - */ - prepare(result) { - const { stats, env, from, file } = result.opts || {}; - const browsers = browserslist(opts.overrideBrowserslist, { - stats: opts.stats || stats, - path: opts.path || dirname(from || file || __filename), - env: opts.env || env, - }); - - return { - OnceExit(css) { - css.walkDecls((decl) => transform(opts, browsers, decl)); - }, - }; - }, - }; -} - -pluginCreator.postcss = true; -module.exports = pluginCreator; diff --git a/node_modules/postcss-convert-values/src/lib/convert.js b/node_modules/postcss-convert-values/src/lib/convert.js deleted file mode 100644 index aa6555cf..00000000 --- a/node_modules/postcss-convert-values/src/lib/convert.js +++ /dev/null @@ -1,85 +0,0 @@ -'use strict'; -const lengthConv = new Map([ - ['in', 96], - ['px', 1], - ['pt', 4 / 3], - ['pc', 16], -]); - -const timeConv = new Map([ - ['s', 1000], - ['ms', 1], -]); - -const angleConv = new Map([ - ['turn', 360], - ['deg', 1], -]); -/** - * @param {number} number - * @return {string} - */ -function dropLeadingZero(number) { - const value = String(number); - - if (number % 1) { - if (value[0] === '0') { - return value.slice(1); - } - - if (value[0] === '-' && value[1] === '0') { - return '-' + value.slice(2); - } - } - - return value; -} -/** - * @param {number} number - * @param {string} originalUnit - * @param {lengthConv | timeConv | angleConv} conversions - * @return {string} - */ -function transform(number, originalUnit, conversions) { - let conversionUnits = [...conversions.keys()].filter((u) => { - return originalUnit !== u; - }); - - const base = number * /** @type {number} */ (conversions.get(originalUnit)); - - return conversionUnits - .map( - (u) => - dropLeadingZero(base / /** @type {number} */ (conversions.get(u))) + u - ) - .reduce((a, b) => (a.length < b.length ? a : b)); -} - -/** - * @param {number} number - * @param {string} unit - * @param {{time?: boolean, length?: boolean, angle?: boolean}} options - * @return {string} - */ -module.exports = function (number, unit, { time, length, angle }) { - let value = dropLeadingZero(number) + (unit ? unit : ''); - let converted; - const lowerCaseUnit = unit.toLowerCase(); - if (length !== false && lengthConv.has(lowerCaseUnit)) { - converted = transform(number, lowerCaseUnit, lengthConv); - } - - if (time !== false && timeConv.has(lowerCaseUnit)) { - converted = transform(number, lowerCaseUnit, timeConv); - } - - if (angle !== false && angleConv.has(lowerCaseUnit)) { - converted = transform(number, lowerCaseUnit, angleConv); - } - - if (converted && converted.length < value.length) { - value = converted; - } - - return value; -}; diff --git a/node_modules/postcss-convert-values/types/index.d.ts b/node_modules/postcss-convert-values/types/index.d.ts deleted file mode 100644 index efcdadcc..00000000 --- a/node_modules/postcss-convert-values/types/index.d.ts +++ /dev/null @@ -1,31 +0,0 @@ -export = pluginCreator; -/** - * @typedef {Parameters<typeof convert>[2]} ConvertOptions - * @typedef {{ overrideBrowserslist?: string | string[] }} AutoprefixerOptions - * @typedef {Pick<browserslist.Options, 'stats' | 'path' | 'env'>} BrowserslistOptions - * @typedef {{precision?: false | number} & ConvertOptions & AutoprefixerOptions & BrowserslistOptions} Options - */ -/** - * @type {import('postcss').PluginCreator<Options>} - * @param {Options} opts - * @return {import('postcss').Plugin} - */ -declare function pluginCreator(opts?: Options): import('postcss').Plugin; -declare namespace pluginCreator { - export { postcss, ConvertOptions, AutoprefixerOptions, BrowserslistOptions, Options }; -} -type Options = { - precision?: false | number; -} & ConvertOptions & AutoprefixerOptions & BrowserslistOptions; -declare var postcss: true; -type ConvertOptions = [number: number, unit: string, { - time?: boolean | undefined; - length?: boolean | undefined; - angle?: boolean | undefined; -}][2]; -type AutoprefixerOptions = { - overrideBrowserslist?: string | string[]; -}; -type BrowserslistOptions = Pick<browserslist.Options, 'stats' | 'path' | 'env'>; -import browserslist = require("browserslist"); -//# sourceMappingURL=index.d.ts.map
\ No newline at end of file diff --git a/node_modules/postcss-convert-values/types/index.d.ts.map b/node_modules/postcss-convert-values/types/index.d.ts.map deleted file mode 100644 index c6d32079..00000000 --- a/node_modules/postcss-convert-values/types/index.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":";AAuMA;;;;;GAKG;AAEH;;;;GAIG;AACH,sCAHW,OAAO,GACN,OAAO,SAAS,EAAE,MAAM,CAwBnC;;;;eA9BY;IAAC,SAAS,CAAC,EAAE,KAAK,GAAG,MAAM,CAAA;CAAC,GAAG,cAAc,GAAG,mBAAmB,GAAG,mBAAmB;;sBAHzF;;;;GAA2B,CAAC,CAAC;2BAC7B;IAAE,oBAAoB,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;CAAE;2BAC5C,KAAK,oBAAoB,EAAE,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC"}
\ No newline at end of file diff --git a/node_modules/postcss-convert-values/types/lib/convert.d.ts b/node_modules/postcss-convert-values/types/lib/convert.d.ts deleted file mode 100644 index db5c8096..00000000 --- a/node_modules/postcss-convert-values/types/lib/convert.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -declare function _exports(number: number, unit: string, { time, length, angle }: { - time?: boolean; - length?: boolean; - angle?: boolean; -}): string; -export = _exports; -//# sourceMappingURL=convert.d.ts.map
\ No newline at end of file diff --git a/node_modules/postcss-convert-values/types/lib/convert.d.ts.map b/node_modules/postcss-convert-values/types/lib/convert.d.ts.map deleted file mode 100644 index a2888d59..00000000 --- a/node_modules/postcss-convert-values/types/lib/convert.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../../src/lib/convert.js"],"names":[],"mappings":"AA+DiB,kCALN,MAAM,QACN,MAAM,2BACN;IAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAC,GAClD,MAAM,CAuBjB"}
\ No newline at end of file |
