postcss-reduce-initial 5.0.1 → 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 CHANGED
@@ -85,10 +85,7 @@ See [CONTRIBUTORS.md](https://github.com/cssnano/cssnano/blob/master/CONTRIBUTOR
85
85
 
86
86
  ## License
87
87
 
88
- [Template:CSSData] by Mozilla Contributors is licensed under [CC-BY-SA 2.5].
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,19 +1,14 @@
1
1
  {
2
2
  "name": "postcss-reduce-initial",
3
- "version": "5.0.1",
3
+ "version": "5.1.0",
4
4
  "description": "Reduce initial definitions to the actual initial value, where possible.",
5
- "main": "dist/index.js",
5
+ "main": "src/index.js",
6
+ "types": "types/index.d.ts",
6
7
  "files": [
7
- "data",
8
- "dist/index.js",
9
- "LICENSE-MIT"
8
+ "src",
9
+ "LICENSE-MIT",
10
+ "types"
10
11
  ],
11
- "scripts": {
12
- "acquire": "node ./src/acquire.mjs",
13
- "prebuild": "del-cli dist",
14
- "build": "cross-env BABEL_ENV=publish babel src --config-file ../../babel.config.json --out-dir dist --ignore '**/__tests__/,src/acquire.mjs'",
15
- "prepublish": "yarn build"
16
- },
17
12
  "keywords": [
18
13
  "css",
19
14
  "postcss",
@@ -28,7 +23,7 @@
28
23
  },
29
24
  "repository": "cssnano/cssnano",
30
25
  "dependencies": {
31
- "browserslist": "^4.16.0",
26
+ "browserslist": "^4.16.6",
32
27
  "caniuse-api": "^3.0.0"
33
28
  },
34
29
  "bugs": {
@@ -38,10 +33,14 @@
38
33
  "node": "^10 || ^12 || >=14.0"
39
34
  },
40
35
  "devDependencies": {
36
+ "@types/caniuse-api": "^3.0.2",
41
37
  "postcss": "^8.2.15"
42
38
  },
43
39
  "peerDependencies": {
44
40
  "postcss": "^8.2.15"
45
41
  },
46
- "gitHead": "28c247175032fa03f04911cde56ad82d74d211cc"
47
- }
42
+ "scripts": {
43
+ "acquire": "node ./src/script/acquire.mjs"
44
+ },
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"
46
+ }
@@ -1,7 +1,10 @@
1
1
  {
2
+ "-webkit-line-clamp": "none",
3
+ "accent-color": "auto",
2
4
  "align-content": "normal",
3
5
  "align-items": "normal",
4
6
  "align-self": "auto",
7
+ "align-tracks": "normal",
5
8
  "animation-delay": "0s",
6
9
  "animation-direction": "normal",
7
10
  "animation-duration": "0s",
@@ -10,6 +13,7 @@
10
13
  "animation-name": "none",
11
14
  "animation-timing-function": "ease",
12
15
  "appearance": "auto",
16
+ "aspect-ratio": "auto",
13
17
  "azimuth": "center",
14
18
  "backdrop-filter": "none",
15
19
  "background-attachment": "scroll",
@@ -65,6 +69,7 @@
65
69
  "clear": "none",
66
70
  "clip": "auto",
67
71
  "clip-path": "none",
72
+ "color-scheme": "normal",
68
73
  "column-count": "auto",
69
74
  "column-gap": "normal",
70
75
  "column-rule-style": "none",
@@ -75,6 +80,7 @@
75
80
  "content": "normal",
76
81
  "counter-increment": "none",
77
82
  "counter-reset": "none",
83
+ "counter-set": "none",
78
84
  "cursor": "auto",
79
85
  "direction": "ltr",
80
86
  "empty-cells": "show",
@@ -102,6 +108,7 @@
102
108
  "font-variant-numeric": "normal",
103
109
  "font-variant-position": "normal",
104
110
  "font-weight": "normal",
111
+ "forced-color-adjust": "auto",
105
112
  "grid-auto-columns": "auto",
106
113
  "grid-auto-flow": "row",
107
114
  "grid-auto-rows": "auto",
@@ -117,7 +124,6 @@
117
124
  "hanging-punctuation": "none",
118
125
  "height": "auto",
119
126
  "hyphens": "manual",
120
- "image-orientation": "0deg",
121
127
  "image-rendering": "auto",
122
128
  "image-resolution": "1dppx",
123
129
  "ime-mode": "auto",
@@ -135,11 +141,13 @@
135
141
  "justify-content": "normal",
136
142
  "justify-items": "legacy",
137
143
  "justify-self": "auto",
144
+ "justify-tracks": "normal",
138
145
  "left": "auto",
139
146
  "letter-spacing": "normal",
140
147
  "line-break": "auto",
141
148
  "line-clamp": "none",
142
149
  "line-height": "normal",
150
+ "line-height-step": "0",
143
151
  "list-style-image": "none",
144
152
  "list-style-type": "disc",
145
153
  "margin-block": "0",
@@ -152,6 +160,7 @@
152
160
  "margin-left": "0",
153
161
  "margin-right": "0",
154
162
  "margin-top": "0",
163
+ "margin-trim": "none",
155
164
  "mask-border-mode": "alpha",
156
165
  "mask-border-outset": "0",
157
166
  "mask-border-slice": "0",
@@ -160,7 +169,10 @@
160
169
  "mask-composite": "add",
161
170
  "mask-image": "none",
162
171
  "mask-position": "center",
172
+ "mask-repeat": "repeat",
163
173
  "mask-size": "auto",
174
+ "masonry-auto-flow": "pack",
175
+ "math-style": "normal",
164
176
  "max-block-size": "0",
165
177
  "max-height": "none",
166
178
  "max-inline-size": "0",
@@ -185,8 +197,14 @@
185
197
  "outline-width": "medium",
186
198
  "overflow-anchor": "auto",
187
199
  "overflow-block": "auto",
200
+ "overflow-clip-margin": "0px",
188
201
  "overflow-inline": "auto",
189
202
  "overflow-wrap": "normal",
203
+ "overscroll-behavior": "auto",
204
+ "overscroll-behavior-block": "auto",
205
+ "overscroll-behavior-inline": "auto",
206
+ "overscroll-behavior-x": "auto",
207
+ "overscroll-behavior-y": "auto",
190
208
  "padding-block": "0",
191
209
  "padding-block-end": "0",
192
210
  "padding-block-start": "0",
@@ -209,9 +227,9 @@
209
227
  "right": "auto",
210
228
  "rotate": "none",
211
229
  "row-gap": "normal",
212
- "ruby-position": "over",
213
230
  "scale": "none",
214
231
  "scrollbar-color": "auto",
232
+ "scrollbar-gutter": "auto",
215
233
  "scrollbar-width": "auto",
216
234
  "scroll-behavior": "auto",
217
235
  "scroll-margin": "0",
@@ -242,6 +260,8 @@
242
260
  "scroll-snap-points-y": "none",
243
261
  "scroll-snap-stop": "normal",
244
262
  "scroll-snap-type": "none",
263
+ "scroll-snap-type-x": "none",
264
+ "scroll-snap-type-y": "none",
245
265
  "shape-image-threshold": "0.0",
246
266
  "shape-margin": "0",
247
267
  "shape-outside": "none",
@@ -252,6 +272,7 @@
252
272
  "text-decoration-line": "none",
253
273
  "text-decoration-skip-ink": "auto",
254
274
  "text-decoration-style": "solid",
275
+ "text-decoration-thickness": "auto",
255
276
  "text-emphasis-style": "none",
256
277
  "text-indent": "0",
257
278
  "text-justify": "auto",
@@ -260,6 +281,7 @@
260
281
  "text-rendering": "auto",
261
282
  "text-shadow": "none",
262
283
  "text-transform": "none",
284
+ "text-underline-offset": "auto",
263
285
  "text-underline-position": "auto",
264
286
  "top": "auto",
265
287
  "touch-action": "auto",
@@ -271,6 +293,7 @@
271
293
  "transition-timing-function": "ease",
272
294
  "translate": "none",
273
295
  "unicode-bidi": "normal",
296
+ "user-select": "auto",
274
297
  "white-space": "normal",
275
298
  "widows": "2",
276
299
  "width": "auto",
@@ -17,17 +17,18 @@
17
17
  "box-sizing": "content-box",
18
18
  "column-rule-color": "currentcolor",
19
19
  "font-synthesis": "weight style",
20
+ "image-orientation": "from-image",
20
21
  "mask-clip": "border-box",
21
22
  "mask-mode": "match-source",
22
23
  "mask-origin": "border-box",
23
- "mask-repeat": "repeat",
24
24
  "mask-type": "luminance",
25
25
  "ruby-align": "space-around",
26
26
  "ruby-merge": "separate",
27
+ "ruby-position": "alternate",
27
28
  "text-decoration-color": "currentcolor",
28
29
  "text-emphasis-color": "currentcolor",
29
30
  "text-emphasis-position": "over right",
30
- "transform-box": "border-box",
31
+ "transform-box": "view-box",
31
32
  "transform-origin": "50% 50% 0",
32
33
  "vertical-align": "baseline",
33
34
  "writing-mode": "horizontal-tb"
package/src/index.js ADDED
@@ -0,0 +1,68 @@
1
+ 'use strict';
2
+ const browserslist = require('browserslist');
3
+ const { isSupported } = require('caniuse-api');
4
+ const fromInitial = require('./data/fromInitial.json');
5
+ const toInitial = require('./data/toInitial.json');
6
+
7
+ const initial = 'initial';
8
+
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
+ const defaultIgnoreProps = ['writing-mode', 'transform-box'];
11
+
12
+ /**
13
+ * @type {import('postcss').PluginCreator<void>}
14
+ * @return {import('postcss').Plugin}
15
+ */
16
+ function pluginCreator() {
17
+ return {
18
+ postcssPlugin: 'postcss-reduce-initial',
19
+ /** @param {import('postcss').Result & {opts: browserslist.Options & {ignore?: string[]}}} result */
20
+ prepare(result) {
21
+ const resultOpts = result.opts || {};
22
+ const browsers = browserslist(null, {
23
+ stats: resultOpts.stats,
24
+ path: __dirname,
25
+ env: resultOpts.env,
26
+ });
27
+
28
+ const initialSupport = isSupported('css-initial-value', browsers);
29
+ return {
30
+ OnceExit(css) {
31
+ css.walkDecls((decl) => {
32
+ const lowerCasedProp = decl.prop.toLowerCase();
33
+ const ignoreProp = new Set(
34
+ defaultIgnoreProps.concat(resultOpts.ignore || [])
35
+ );
36
+
37
+ if (ignoreProp.has(lowerCasedProp)) {
38
+ return;
39
+ }
40
+
41
+ if (
42
+ initialSupport &&
43
+ Object.prototype.hasOwnProperty.call(toInitial, lowerCasedProp) &&
44
+ decl.value.toLowerCase() ===
45
+ toInitial[/** @type {keyof toInitial} */ (lowerCasedProp)]
46
+ ) {
47
+ decl.value = initial;
48
+ return;
49
+ }
50
+
51
+ if (
52
+ decl.value.toLowerCase() !== initial ||
53
+ !fromInitial[/** @type {keyof fromInitial} */ (lowerCasedProp)]
54
+ ) {
55
+ return;
56
+ }
57
+
58
+ decl.value =
59
+ fromInitial[/** @type {keyof fromInitial} */ (lowerCasedProp)];
60
+ });
61
+ },
62
+ };
63
+ },
64
+ };
65
+ }
66
+
67
+ pluginCreator.postcss = true;
68
+ module.exports = pluginCreator;
@@ -0,0 +1,9 @@
1
+ export = pluginCreator;
2
+ /**
3
+ * @type {import('postcss').PluginCreator<void>}
4
+ * @return {import('postcss').Plugin}
5
+ */
6
+ declare function pluginCreator(): import('postcss').Plugin;
7
+ declare namespace pluginCreator {
8
+ const postcss: true;
9
+ }
package/CHANGELOG.md DELETED
@@ -1,79 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
-
6
- ## [5.0.1](https://github.com/cssnano/cssnano/compare/postcss-reduce-initial@5.0.0...postcss-reduce-initial@5.0.1) (2021-05-19)
7
-
8
- **Note:** Version bump only for package postcss-reduce-initial
9
-
10
-
11
-
12
-
13
-
14
- # [5.0.0](https://github.com/cssnano/cssnano/compare/postcss-reduce-initial@5.0.0-rc.2...postcss-reduce-initial@5.0.0) (2021-04-06)
15
-
16
- **Note:** Version bump only for package postcss-reduce-initial
17
-
18
-
19
-
20
-
21
-
22
- # [5.0.0-rc.2](https://github.com/cssnano/cssnano/compare/postcss-reduce-initial@5.0.0-rc.1...postcss-reduce-initial@5.0.0-rc.2) (2021-03-15)
23
-
24
- **Note:** Version bump only for package postcss-reduce-initial
25
-
26
-
27
-
28
-
29
-
30
- # [5.0.0-rc.1](https://github.com/cssnano/cssnano/compare/postcss-reduce-initial@5.0.0-rc.0...postcss-reduce-initial@5.0.0-rc.1) (2021-03-04)
31
-
32
- **Note:** Version bump only for package postcss-reduce-initial
33
-
34
-
35
-
36
-
37
-
38
- # 5.0.0-rc.0 (2021-02-19)
39
-
40
-
41
- ### Bug Fixes
42
-
43
- * min-width/height issue ([#852](https://github.com/cssnano/cssnano/issues/852)) ([f6e767b](https://github.com/cssnano/cssnano/commit/f6e767b7ba672c5c1b4a1350f23b4b65a4851f96))
44
-
45
-
46
- ### chore
47
-
48
- * minimum require version of node is 10.13 ([#871](https://github.com/cssnano/cssnano/issues/871)) ([28bda24](https://github.com/cssnano/cssnano/commit/28bda243e32ce3ba89b3c358a5f78727b3732f11))
49
-
50
-
51
- ### Features
52
-
53
- * migarete to PostCSS 8 ([#975](https://github.com/cssnano/cssnano/issues/975)) ([40b82dc](https://github.com/cssnano/cssnano/commit/40b82dca7f53ac02cd4fe62846dec79b898ccb49))
54
- * **postcss-reduce-initial:** added ignore options ([#929](https://github.com/cssnano/cssnano/issues/929)) ([2e63fe5](https://github.com/cssnano/cssnano/commit/2e63fe55b8059fc14d78aa11920d7ebf9a3682a1))
55
-
56
-
57
- ### BREAKING CHANGES
58
-
59
- * minimum supported `postcss` version is `8.2.1`
60
- * minimum require version of node is 10.13
61
-
62
-
63
-
64
- ## 4.1.9 (2019-02-12)
65
-
66
-
67
- ### Bug Fixes
68
-
69
- * **postcss-reduce-initial:** handle uppercase value toInitial ([#685](https://github.com/cssnano/cssnano/issues/685)) ([0e7beb3](https://github.com/cssnano/cssnano/commit/0e7beb3508fa8f85db67e3464bf8b8941bb6ca12))
70
- * change mask-repeat initial value on repeat ([#679](https://github.com/cssnano/cssnano/issues/679)) ([cebd6d5](https://github.com/cssnano/cssnano/commit/cebd6d5b789a9c700f92dc8b40cdd8ef9545441a))
71
-
72
-
73
-
74
- ## 4.1.1 (2018-09-24)
75
-
76
-
77
- ### Bug Fixes
78
-
79
- * **postcss-merge-longhand:** not mangle border output ([#555](https://github.com/cssnano/cssnano/issues/555)) ([9a70605](https://github.com/cssnano/cssnano/commit/9a706050b621e7795a9bf74eb7110b5c81804ffe)), closes [#553](https://github.com/cssnano/cssnano/issues/553) [#554](https://github.com/cssnano/cssnano/issues/554)
package/dist/index.js DELETED
@@ -1,66 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _browserslist = _interopRequireDefault(require("browserslist"));
9
-
10
- var _caniuseApi = require("caniuse-api");
11
-
12
- var _fromInitial = _interopRequireDefault(require("../data/fromInitial.json"));
13
-
14
- var _toInitial = _interopRequireDefault(require("../data/toInitial.json"));
15
-
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
- const initial = 'initial'; // In most of the browser including chrome the initial for `writing-mode` is not `horizontal-tb`. Ref https://github.com/cssnano/cssnano/pull/905
19
-
20
- const defaultIgnoreProps = ['writing-mode'];
21
-
22
- function pluginCreator() {
23
- return {
24
- postcssPlugin: 'postcss-reduce-initial',
25
-
26
- prepare(result) {
27
- const resultOpts = result.opts || {};
28
- const browsers = (0, _browserslist.default)(null, {
29
- stats: resultOpts.stats,
30
- path: __dirname,
31
- env: resultOpts.env
32
- });
33
- const initialSupport = (0, _caniuseApi.isSupported)('css-initial-value', browsers);
34
- return {
35
- OnceExit(css) {
36
- css.walkDecls(decl => {
37
- const lowerCasedProp = decl.prop.toLowerCase();
38
- const ignoreProp = defaultIgnoreProps.concat(resultOpts.ignore || []);
39
-
40
- if (ignoreProp.includes(lowerCasedProp)) {
41
- return;
42
- }
43
-
44
- if (initialSupport && Object.prototype.hasOwnProperty.call(_toInitial.default, lowerCasedProp) && decl.value.toLowerCase() === _toInitial.default[lowerCasedProp]) {
45
- decl.value = initial;
46
- return;
47
- }
48
-
49
- if (decl.value.toLowerCase() !== initial || !_fromInitial.default[lowerCasedProp]) {
50
- return;
51
- }
52
-
53
- decl.value = _fromInitial.default[lowerCasedProp];
54
- });
55
- }
56
-
57
- };
58
- }
59
-
60
- };
61
- }
62
-
63
- pluginCreator.postcss = true;
64
- var _default = pluginCreator;
65
- exports.default = _default;
66
- module.exports = exports.default;