postcss-reduce-initial 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 +18 -8
- package/src/lib/ignoreProps.js +2 -0
- package/types/index.d.ts +13 -3
- package/types/index.d.ts.map +1 -0
- package/types/lib/ignoreProps.d.ts +3 -0
- package/types/lib/ignoreProps.d.ts.map +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "postcss-reduce-initial",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "Reduce initial definitions to the actual initial value, where possible.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -30,12 +30,12 @@
|
|
|
30
30
|
"url": "https://github.com/cssnano/cssnano/issues"
|
|
31
31
|
},
|
|
32
32
|
"engines": {
|
|
33
|
-
"node": "^
|
|
33
|
+
"node": "^18.12.0 || ^20.9.0 || >=22.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/caniuse-api": "^3.0.6",
|
|
37
37
|
"html-to-text": "^9.0.5",
|
|
38
|
-
"postcss": "^8.4.
|
|
38
|
+
"postcss": "^8.4.38"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"postcss": "^8.4.31"
|
package/src/index.js
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
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 fromInitial = require('./data/fromInitial.json');
|
|
5
6
|
const toInitial = require('./data/toInitial.json');
|
|
7
|
+
const ignoreProps = require('./lib/ignoreProps.js');
|
|
6
8
|
|
|
7
9
|
const initial = 'initial';
|
|
8
10
|
|
|
9
11
|
// In most of the browser including chrome the initial for `writing-mode` is not `horizontal-tb`. Ref https://github.com/cssnano/cssnano/pull/905
|
|
10
|
-
const defaultIgnoreProps =
|
|
11
|
-
|
|
12
|
+
const defaultIgnoreProps = ignoreProps;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @typedef {{ overrideBrowserslist?: string | string[] }} AutoprefixerOptions
|
|
16
|
+
* @typedef {Pick<browserslist.Options, 'stats' | 'path' | 'env'>} BrowserslistOptions
|
|
17
|
+
* @typedef {{ignore?: string[]} & AutoprefixerOptions & BrowserslistOptions} Options
|
|
18
|
+
*/
|
|
12
19
|
|
|
13
20
|
/**
|
|
14
21
|
* @type {import('postcss').PluginCreator<Options>}
|
|
@@ -18,13 +25,16 @@ const defaultIgnoreProps = ['writing-mode', 'transform-box'];
|
|
|
18
25
|
function pluginCreator(options = {}) {
|
|
19
26
|
return {
|
|
20
27
|
postcssPlugin: 'postcss-reduce-initial',
|
|
21
|
-
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @param {import('postcss').Result & {opts: BrowserslistOptions & {file?: string}}} result
|
|
31
|
+
*/
|
|
22
32
|
prepare(result) {
|
|
23
|
-
const
|
|
24
|
-
const browsers = browserslist(
|
|
25
|
-
stats:
|
|
26
|
-
path:
|
|
27
|
-
env:
|
|
33
|
+
const { stats, env, from, file } = result.opts || {};
|
|
34
|
+
const browsers = browserslist(options.overrideBrowserslist, {
|
|
35
|
+
stats: options.stats || stats,
|
|
36
|
+
path: options.path || dirname(from || file || __filename),
|
|
37
|
+
env: options.env || env,
|
|
28
38
|
});
|
|
29
39
|
|
|
30
40
|
const initialSupport = isSupported('css-initial-value', browsers);
|
package/types/index.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
export = pluginCreator;
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* @typedef {{ overrideBrowserslist?: string | string[] }} AutoprefixerOptions
|
|
4
|
+
* @typedef {Pick<browserslist.Options, 'stats' | 'path' | 'env'>} BrowserslistOptions
|
|
5
|
+
* @typedef {{ignore?: string[]} & AutoprefixerOptions & BrowserslistOptions} Options
|
|
6
|
+
*/
|
|
3
7
|
/**
|
|
4
8
|
* @type {import('postcss').PluginCreator<Options>}
|
|
5
9
|
* @param {Options} options
|
|
@@ -7,9 +11,15 @@ export = pluginCreator;
|
|
|
7
11
|
*/
|
|
8
12
|
declare function pluginCreator(options?: Options): import('postcss').Plugin;
|
|
9
13
|
declare namespace pluginCreator {
|
|
10
|
-
export { postcss, Options };
|
|
14
|
+
export { postcss, AutoprefixerOptions, BrowserslistOptions, Options };
|
|
11
15
|
}
|
|
12
16
|
type Options = {
|
|
13
17
|
ignore?: string[];
|
|
14
|
-
};
|
|
18
|
+
} & AutoprefixerOptions & BrowserslistOptions;
|
|
15
19
|
declare var postcss: true;
|
|
20
|
+
type AutoprefixerOptions = {
|
|
21
|
+
overrideBrowserslist?: string | string[];
|
|
22
|
+
};
|
|
23
|
+
type BrowserslistOptions = Pick<browserslist.Options, 'stats' | 'path' | 'env'>;
|
|
24
|
+
import browserslist = require("browserslist");
|
|
25
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":";AAaA;;;;GAIG;AAEH;;;;GAIG;AACH,yCAHW,OAAO,GACN,OAAO,SAAS,EAAE,MAAM,CAsDnC;;;;eA5DY;IAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;CAAC,GAAG,mBAAmB,GAAG,mBAAmB;;2BAF/D;IAAE,oBAAoB,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;CAAE;2BAC5C,KAAK,oBAAoB,EAAE,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ignoreProps.d.ts","sourceRoot":"","sources":["../../src/lib/ignoreProps.js"],"names":[],"mappings":""}
|