postcss-reduce-initial 5.0.3 → 5.1.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/README.md +1 -4
- package/package.json +7 -5
- package/{data → src/data}/fromInitial.json +0 -0
- package/{data → src/data}/toInitial.json +0 -0
- package/src/index.js +12 -6
- package/types/index.d.ts +9 -0
package/README.md
CHANGED
|
@@ -85,10 +85,7 @@ See [CONTRIBUTORS.md](https://github.com/cssnano/cssnano/blob/master/CONTRIBUTOR
|
|
|
85
85
|
|
|
86
86
|
## License
|
|
87
87
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
[template:cssdata]: https://developer.mozilla.org/en-US/docs/Template:CSSData
|
|
91
|
-
[cc-by-sa 2.5]: http://creativecommons.org/licenses/by-sa/2.5/
|
|
88
|
+
This program uses a list of CSS properties derived from data maintained my the MDN team at Mozilla and licensed under the [CC0 1.0 Universal Public Domain Dedication](https://creativecommons.org/publicdomain/zero/1.0/).
|
|
92
89
|
|
|
93
90
|
MIT © [Ben Briggs](http://beneb.info)
|
|
94
91
|
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "postcss-reduce-initial",
|
|
3
|
-
"version": "5.0
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"description": "Reduce initial definitions to the actual initial value, where possible.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
|
+
"types": "types/index.d.ts",
|
|
6
7
|
"files": [
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
8
|
+
"src",
|
|
9
|
+
"LICENSE-MIT",
|
|
10
|
+
"types"
|
|
10
11
|
],
|
|
11
12
|
"keywords": [
|
|
12
13
|
"css",
|
|
@@ -32,6 +33,7 @@
|
|
|
32
33
|
"node": "^10 || ^12 || >=14.0"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
36
|
+
"@types/caniuse-api": "^3.0.2",
|
|
35
37
|
"postcss": "^8.2.15"
|
|
36
38
|
},
|
|
37
39
|
"peerDependencies": {
|
|
@@ -40,5 +42,5 @@
|
|
|
40
42
|
"scripts": {
|
|
41
43
|
"acquire": "node ./src/script/acquire.mjs"
|
|
42
44
|
},
|
|
43
|
-
"readme": "# [postcss][postcss]-reduce-initial\n\n> Reduce `initial` definitions to the _actual_ initial value, where possible.\n\n## Install\n\nWith [npm](https://npmjs.org/package/postcss-reduce-initial) do:\n\n```\nnpm install postcss-reduce-initial --save\n```\n\n## Examples\n\nSee the [data](data) for more conversions. This data is courtesy\nof Mozilla.\n\n### Convert `initial` values\n\nWhen the `initial` keyword is longer than the property value, it will\nbe converted:\n\n#### Input\n\n```css\nh1 {\n min-width: initial;\n}\n```\n\n#### Output\n\n```css\nh1 {\n min-width: 0;\n}\n```\n\n### Convert values back to `initial`\n\nWhen the `initial` value is smaller than the property value, it will\nbe converted:\n\n#### Input\n\n```css\nh1 {\n transform-box: border-box;\n}\n```\n\n#### Output\n\n```css\nh1 {\n transform-box: initial;\n}\n```\n\nThis conversion is only applied when you supply a browsers list that all support\nthe `initial` keyword; it's worth noting that Internet Explorer has no support.\n\n## API\n\n### reduceInitial([options])\n\n#### options\n\n##### ignore\n\nType: `Array<String>`\nDefault: `undefined`\n\nIt contains the Array of properties that will be ignored while reducing its value to initial.\nExample : `{ ignore : [\"min-height\"] }`\n\n## Usage\n\nSee the [PostCSS documentation](https://github.com/postcss/postcss#usage) for\nexamples for your environment.\n\n## Contributors\n\nSee [CONTRIBUTORS.md](https://github.com/cssnano/cssnano/blob/master/CONTRIBUTORS.md).\n\n## License\n\
|
|
45
|
+
"readme": "# [postcss][postcss]-reduce-initial\n\n> Reduce `initial` definitions to the _actual_ initial value, where possible.\n\n## Install\n\nWith [npm](https://npmjs.org/package/postcss-reduce-initial) do:\n\n```\nnpm install postcss-reduce-initial --save\n```\n\n## Examples\n\nSee the [data](data) for more conversions. This data is courtesy\nof Mozilla.\n\n### Convert `initial` values\n\nWhen the `initial` keyword is longer than the property value, it will\nbe converted:\n\n#### Input\n\n```css\nh1 {\n min-width: initial;\n}\n```\n\n#### Output\n\n```css\nh1 {\n min-width: 0;\n}\n```\n\n### Convert values back to `initial`\n\nWhen the `initial` value is smaller than the property value, it will\nbe converted:\n\n#### Input\n\n```css\nh1 {\n transform-box: border-box;\n}\n```\n\n#### Output\n\n```css\nh1 {\n transform-box: initial;\n}\n```\n\nThis conversion is only applied when you supply a browsers list that all support\nthe `initial` keyword; it's worth noting that Internet Explorer has no support.\n\n## API\n\n### reduceInitial([options])\n\n#### options\n\n##### ignore\n\nType: `Array<String>`\nDefault: `undefined`\n\nIt contains the Array of properties that will be ignored while reducing its value to initial.\nExample : `{ ignore : [\"min-height\"] }`\n\n## Usage\n\nSee the [PostCSS documentation](https://github.com/postcss/postcss#usage) for\nexamples for your environment.\n\n## Contributors\n\nSee [CONTRIBUTORS.md](https://github.com/cssnano/cssnano/blob/master/CONTRIBUTORS.md).\n\n## License\n\nThis program uses a list of CSS properties derived from data maintained my the MDN team at Mozilla and licensed under the [CC0 1.0 Universal Public Domain Dedication](https://creativecommons.org/publicdomain/zero/1.0/).\n\nMIT © [Ben Briggs](http://beneb.info)\n\n[postcss]: https://github.com/postcss/postcss\n"
|
|
44
46
|
}
|
|
File without changes
|
|
File without changes
|
package/src/index.js
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
const browserslist = require('browserslist');
|
|
3
3
|
const { isSupported } = require('caniuse-api');
|
|
4
|
-
const fromInitial = require('
|
|
5
|
-
const toInitial = require('
|
|
4
|
+
const fromInitial = require('./data/fromInitial.json');
|
|
5
|
+
const toInitial = require('./data/toInitial.json');
|
|
6
6
|
|
|
7
7
|
const initial = 'initial';
|
|
8
8
|
|
|
9
9
|
// 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
10
|
const defaultIgnoreProps = ['writing-mode', 'transform-box'];
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* @type {import('postcss').PluginCreator<void>}
|
|
14
|
+
* @return {import('postcss').Plugin}
|
|
15
|
+
*/
|
|
12
16
|
function pluginCreator() {
|
|
13
17
|
return {
|
|
14
18
|
postcssPlugin: 'postcss-reduce-initial',
|
|
15
|
-
|
|
19
|
+
/** @param {import('postcss').Result & {opts: browserslist.Options & {ignore?: string[]}}} result */
|
|
16
20
|
prepare(result) {
|
|
17
21
|
const resultOpts = result.opts || {};
|
|
18
22
|
const browsers = browserslist(null, {
|
|
@@ -37,7 +41,8 @@ function pluginCreator() {
|
|
|
37
41
|
if (
|
|
38
42
|
initialSupport &&
|
|
39
43
|
Object.prototype.hasOwnProperty.call(toInitial, lowerCasedProp) &&
|
|
40
|
-
decl.value.toLowerCase() ===
|
|
44
|
+
decl.value.toLowerCase() ===
|
|
45
|
+
toInitial[/** @type {keyof toInitial} */ (lowerCasedProp)]
|
|
41
46
|
) {
|
|
42
47
|
decl.value = initial;
|
|
43
48
|
return;
|
|
@@ -45,12 +50,13 @@ function pluginCreator() {
|
|
|
45
50
|
|
|
46
51
|
if (
|
|
47
52
|
decl.value.toLowerCase() !== initial ||
|
|
48
|
-
!fromInitial[lowerCasedProp]
|
|
53
|
+
!fromInitial[/** @type {keyof fromInitial} */ (lowerCasedProp)]
|
|
49
54
|
) {
|
|
50
55
|
return;
|
|
51
56
|
}
|
|
52
57
|
|
|
53
|
-
decl.value =
|
|
58
|
+
decl.value =
|
|
59
|
+
fromInitial[/** @type {keyof fromInitial} */ (lowerCasedProp)];
|
|
54
60
|
});
|
|
55
61
|
},
|
|
56
62
|
};
|
package/types/index.d.ts
ADDED