postcss-colormin 6.0.3 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/index.js +31 -11
- package/src/minifyColor.js +1 -1
- package/types/index.d.ts +34 -4
- package/types/index.d.ts.map +1 -0
- package/types/minifyColor.d.ts +2 -1
- package/types/minifyColor.d.ts.map +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "postcss-colormin",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "Minify colors in your CSS files with PostCSS.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -36,11 +36,11 @@
|
|
|
36
36
|
"url": "https://github.com/cssnano/cssnano/issues"
|
|
37
37
|
},
|
|
38
38
|
"engines": {
|
|
39
|
-
"node": "^
|
|
39
|
+
"node": "^18.12.0 || ^20.9.0 || >=22.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/caniuse-api": "^3.0.6",
|
|
43
|
-
"postcss": "^8.4.
|
|
43
|
+
"postcss": "^8.4.38"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"postcss": "^8.4.31"
|
package/src/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
+
const { dirname } = require('path');
|
|
2
3
|
const browserslist = require('browserslist');
|
|
3
4
|
const { isSupported } = require('caniuse-api');
|
|
4
5
|
const valueParser = require('postcss-value-parser');
|
|
@@ -41,7 +42,7 @@ function isMathFunctionNode(node) {
|
|
|
41
42
|
|
|
42
43
|
/**
|
|
43
44
|
* @param {string} value
|
|
44
|
-
* @param {
|
|
45
|
+
* @param {Options} options
|
|
45
46
|
* @return {string}
|
|
46
47
|
*/
|
|
47
48
|
function transform(value, options) {
|
|
@@ -83,9 +84,9 @@ function transform(value, options) {
|
|
|
83
84
|
}
|
|
84
85
|
|
|
85
86
|
/**
|
|
86
|
-
* @param {
|
|
87
|
+
* @param {Options} options
|
|
87
88
|
* @param {string[]} browsers
|
|
88
|
-
* @return {
|
|
89
|
+
* @return {Options}
|
|
89
90
|
*/
|
|
90
91
|
function addPluginDefaults(options, browsers) {
|
|
91
92
|
const defaults = {
|
|
@@ -98,22 +99,41 @@ function addPluginDefaults(options, browsers) {
|
|
|
98
99
|
};
|
|
99
100
|
return { ...defaults, ...options };
|
|
100
101
|
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @typedef {object} MinifyColorOptions
|
|
105
|
+
* @property {boolean} [hex]
|
|
106
|
+
* @property {boolean} [alphaHex]
|
|
107
|
+
* @property {boolean} [rgb]
|
|
108
|
+
* @property {boolean} [hsl]
|
|
109
|
+
* @property {boolean} [name]
|
|
110
|
+
* @property {boolean} [transparent]
|
|
111
|
+
*/
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* @typedef {{ overrideBrowserslist?: string | string[] }} AutoprefixerOptions
|
|
115
|
+
* @typedef {Pick<browserslist.Options, 'stats' | 'path' | 'env'>} BrowserslistOptions
|
|
116
|
+
* @typedef {MinifyColorOptions & AutoprefixerOptions & BrowserslistOptions} Options
|
|
117
|
+
*/
|
|
118
|
+
|
|
101
119
|
/**
|
|
102
|
-
* @type {import('postcss').PluginCreator<
|
|
103
|
-
* @param {
|
|
120
|
+
* @type {import('postcss').PluginCreator<Options>}
|
|
121
|
+
* @param {Options} config
|
|
104
122
|
* @return {import('postcss').Plugin}
|
|
105
123
|
*/
|
|
106
124
|
function pluginCreator(config = {}) {
|
|
107
125
|
return {
|
|
108
126
|
postcssPlugin: 'postcss-colormin',
|
|
109
127
|
|
|
128
|
+
/**
|
|
129
|
+
* @param {import('postcss').Result & {opts: BrowserslistOptions & {file?: string}}} result
|
|
130
|
+
*/
|
|
110
131
|
prepare(result) {
|
|
111
|
-
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
env: resultOptions.env,
|
|
132
|
+
const { stats, env, from, file } = result.opts || {};
|
|
133
|
+
const browsers = browserslist(config.overrideBrowserslist, {
|
|
134
|
+
stats: config.stats || stats,
|
|
135
|
+
path: config.path || dirname(from || file || __filename),
|
|
136
|
+
env: config.env || env,
|
|
117
137
|
});
|
|
118
138
|
|
|
119
139
|
const cache = new Map();
|
package/src/minifyColor.js
CHANGED
|
@@ -9,7 +9,7 @@ extend(/** @type {any[]} */ ([namesPlugin, minifierPlugin]));
|
|
|
9
9
|
* Performs color value minification
|
|
10
10
|
*
|
|
11
11
|
* @param {string} input - CSS value
|
|
12
|
-
* @param {
|
|
12
|
+
* @param {import('./index.js').MinifyColorOptions} options - object with colord.minify() options
|
|
13
13
|
* @return {string}
|
|
14
14
|
*/
|
|
15
15
|
module.exports = function minifyColor(input, options = {}) {
|
package/types/index.d.ts
CHANGED
|
@@ -1,10 +1,40 @@
|
|
|
1
1
|
export = pluginCreator;
|
|
2
2
|
/**
|
|
3
|
-
* @
|
|
4
|
-
* @
|
|
3
|
+
* @typedef {object} MinifyColorOptions
|
|
4
|
+
* @property {boolean} [hex]
|
|
5
|
+
* @property {boolean} [alphaHex]
|
|
6
|
+
* @property {boolean} [rgb]
|
|
7
|
+
* @property {boolean} [hsl]
|
|
8
|
+
* @property {boolean} [name]
|
|
9
|
+
* @property {boolean} [transparent]
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* @typedef {{ overrideBrowserslist?: string | string[] }} AutoprefixerOptions
|
|
13
|
+
* @typedef {Pick<browserslist.Options, 'stats' | 'path' | 'env'>} BrowserslistOptions
|
|
14
|
+
* @typedef {MinifyColorOptions & AutoprefixerOptions & BrowserslistOptions} Options
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* @type {import('postcss').PluginCreator<Options>}
|
|
18
|
+
* @param {Options} config
|
|
5
19
|
* @return {import('postcss').Plugin}
|
|
6
20
|
*/
|
|
7
|
-
declare function pluginCreator(config?:
|
|
21
|
+
declare function pluginCreator(config?: Options): import('postcss').Plugin;
|
|
8
22
|
declare namespace pluginCreator {
|
|
9
|
-
|
|
23
|
+
export { postcss, MinifyColorOptions, AutoprefixerOptions, BrowserslistOptions, Options };
|
|
10
24
|
}
|
|
25
|
+
type Options = MinifyColorOptions & AutoprefixerOptions & BrowserslistOptions;
|
|
26
|
+
declare var postcss: true;
|
|
27
|
+
type MinifyColorOptions = {
|
|
28
|
+
hex?: boolean | undefined;
|
|
29
|
+
alphaHex?: boolean | undefined;
|
|
30
|
+
rgb?: boolean | undefined;
|
|
31
|
+
hsl?: boolean | undefined;
|
|
32
|
+
name?: boolean | undefined;
|
|
33
|
+
transparent?: boolean | undefined;
|
|
34
|
+
};
|
|
35
|
+
type AutoprefixerOptions = {
|
|
36
|
+
overrideBrowserslist?: string | string[];
|
|
37
|
+
};
|
|
38
|
+
type BrowserslistOptions = Pick<browserslist.Options, 'stats' | 'path' | 'env'>;
|
|
39
|
+
import browserslist = require("browserslist");
|
|
40
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":";AAsGA;;;;;;;;GAQG;AAEH;;;;GAIG;AAEH;;;;GAIG;AACH,wCAHW,OAAO,GACN,OAAO,SAAS,EAAE,MAAM,CAsDnC;;;;eA5DY,kBAAkB,GAAG,mBAAmB,GAAG,mBAAmB;;;;;;;;;;2BAF9D;IAAE,oBAAoB,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;CAAE;2BAC5C,KAAK,oBAAoB,EAAE,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC"}
|
package/types/minifyColor.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"minifyColor.d.ts","sourceRoot":"","sources":["../src/minifyColor.js"],"names":[],"mappings":"AAciB,iCAJN,MAAM,YACN,OAAO,YAAY,EAAE,kBAAkB,GACtC,MAAM,CAejB"}
|