postcss-reduce-transforms 5.0.4 → 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
@@ -19,7 +19,7 @@ see the [tests](src/__tests__/index.js).
19
19
 
20
20
  ```css
21
21
  h1 {
22
- transform: rotate3d(0, 0, 1, 20deg);
22
+ transform: rotate3d(0, 0, 1, 20deg);
23
23
  }
24
24
  ```
25
25
 
@@ -27,7 +27,7 @@ h1 {
27
27
 
28
28
  ```css
29
29
  h1 {
30
- transform: rotate(20deg);
30
+ transform: rotate(20deg);
31
31
  }
32
32
  ```
33
33
 
package/package.json CHANGED
@@ -1,11 +1,13 @@
1
1
  {
2
2
  "name": "postcss-reduce-transforms",
3
- "version": "5.0.4",
3
+ "version": "5.1.0",
4
4
  "description": "Reduce transform functions with PostCSS.",
5
5
  "main": "src/index.js",
6
+ "types": "types/index.d.ts",
6
7
  "files": [
7
8
  "LICENSE-MIT",
8
- "src"
9
+ "src",
10
+ "types"
9
11
  ],
10
12
  "license": "MIT",
11
13
  "homepage": "https://github.com/cssnano/cssnano",
@@ -30,5 +32,5 @@
30
32
  "peerDependencies": {
31
33
  "postcss": "^8.2.15"
32
34
  },
33
- "readme": "# [postcss][postcss]-reduce-transforms\n\n> Reduce transform functions with PostCSS.\n\n## Install\n\nWith [npm](https://npmjs.org/package/postcss-reduce-transforms) do:\n\n```\nnpm install postcss-reduce-transforms --save\n```\n\n## Example\n\nThis module will reduce transform functions where possible. For more examples,\nsee the [tests](src/__tests__/index.js).\n\n### Input\n\n```css\nh1 {\n transform: rotate3d(0, 0, 1, 20deg);\n}\n```\n\n### Output\n\n```css\nh1 {\n transform: rotate(20deg);\n}\n```\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\nMIT © [Ben Briggs](http://beneb.info)\n\n[postcss]: https://github.com/postcss/postcss\n"
35
+ "readme": "# [postcss][postcss]-reduce-transforms\n\n> Reduce transform functions with PostCSS.\n\n## Install\n\nWith [npm](https://npmjs.org/package/postcss-reduce-transforms) do:\n\n```\nnpm install postcss-reduce-transforms --save\n```\n\n## Example\n\nThis module will reduce transform functions where possible. For more examples,\nsee the [tests](src/__tests__/index.js).\n\n### Input\n\n```css\nh1 {\n transform: rotate3d(0, 0, 1, 20deg);\n}\n```\n\n### Output\n\n```css\nh1 {\n transform: rotate(20deg);\n}\n```\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\nMIT © [Ben Briggs](http://beneb.info)\n\n[postcss]: https://github.com/postcss/postcss\n"
34
36
  }
package/src/index.js CHANGED
@@ -1,8 +1,15 @@
1
1
  'use strict';
2
2
  const valueParser = require('postcss-value-parser');
3
3
 
4
+ /**
5
+ * @param {(number|string)[]} list
6
+ * @param {valueParser.Node} node
7
+ * @param {number} index
8
+ * @return {(number|string)[]}
9
+ */
4
10
  function getValues(list, node, index) {
5
11
  if (index % 2 === 0) {
12
+ /** @type {number|string} */
6
13
  let value = NaN;
7
14
 
8
15
  if (
@@ -21,6 +28,11 @@ function getValues(list, node, index) {
21
28
  return list;
22
29
  }
23
30
 
31
+ /**
32
+ * @param {valueParser.FunctionNode} node
33
+ * @param {(number|string)[]} values
34
+ * @return {void}
35
+ */
24
36
  function matrix3d(node, values) {
25
37
  if (values.length !== 16) {
26
38
  return;
@@ -65,6 +77,11 @@ const rotate3dMappings = new Map([
65
77
  [[0, 0, 1].toString(), 'rotate'], // rotate3d(0, 0, 1, a) => rotate(a)
66
78
  ]);
67
79
 
80
+ /**
81
+ * @param {valueParser.FunctionNode} node
82
+ * @param {(number|string)[]} values
83
+ * @return {void}
84
+ */
68
85
  function rotate3d(node, values) {
69
86
  if (values.length !== 4) {
70
87
  return;
@@ -79,6 +96,11 @@ function rotate3d(node, values) {
79
96
  }
80
97
  }
81
98
 
99
+ /**
100
+ * @param {valueParser.FunctionNode} node
101
+ * @param {(number|string)[]} values
102
+ * @return {void}
103
+ */
82
104
  function rotateZ(node, values) {
83
105
  if (values.length !== 1) {
84
106
  return;
@@ -88,6 +110,11 @@ function rotateZ(node, values) {
88
110
  node.value = 'rotate';
89
111
  }
90
112
 
113
+ /**
114
+ * @param {valueParser.FunctionNode} node
115
+ * @param {(number|string)[]} values
116
+ * @return {void}
117
+ */
91
118
  function scale(node, values) {
92
119
  if (values.length !== 2) {
93
120
  return;
@@ -120,6 +147,11 @@ function scale(node, values) {
120
147
  }
121
148
  }
122
149
 
150
+ /**
151
+ * @param {valueParser.FunctionNode} node
152
+ * @param {(number|string)[]} values
153
+ * @return {void}
154
+ */
123
155
  function scale3d(node, values) {
124
156
  if (values.length !== 3) {
125
157
  return;
@@ -153,6 +185,11 @@ function scale3d(node, values) {
153
185
  }
154
186
  }
155
187
 
188
+ /**
189
+ * @param {valueParser.FunctionNode} node
190
+ * @param {(number|string)[]} values
191
+ * @return {void}
192
+ */
156
193
  function translate(node, values) {
157
194
  if (values.length !== 2) {
158
195
  return;
@@ -176,6 +213,11 @@ function translate(node, values) {
176
213
  }
177
214
  }
178
215
 
216
+ /**
217
+ * @param {valueParser.FunctionNode} node
218
+ * @param {(number|string)[]} values
219
+ * @return {void}
220
+ */
179
221
  function translate3d(node, values) {
180
222
  if (values.length !== 3) {
181
223
  return;
@@ -199,7 +241,10 @@ const reducers = new Map([
199
241
  ['translate', translate],
200
242
  ['translate3d', translate3d],
201
243
  ]);
202
-
244
+ /**
245
+ * @param {string} name
246
+ * @return {string}
247
+ */
203
248
  function normalizeReducerName(name) {
204
249
  const lowerCasedName = name.toLowerCase();
205
250
 
@@ -210,6 +255,10 @@ function normalizeReducerName(name) {
210
255
  return lowerCasedName;
211
256
  }
212
257
 
258
+ /**
259
+ * @param {valueParser.Node} node
260
+ * @return {false}
261
+ */
213
262
  function reduce(node) {
214
263
  if (node.type === 'function') {
215
264
  const normalizedReducerName = normalizeReducerName(node.value);
@@ -221,6 +270,10 @@ function reduce(node) {
221
270
  return false;
222
271
  }
223
272
 
273
+ /**
274
+ * @type {import('postcss').PluginCreator<void>}
275
+ * @return {import('postcss').Plugin}
276
+ */
224
277
  function pluginCreator() {
225
278
  return {
226
279
  postcssPlugin: 'postcss-reduce-transforms',
@@ -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
+ }