postcss-reduce-transforms 8.0.1 → 8.0.3

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/LICENSE-MIT CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) Ben Briggs <beneb.info@gmail.com> (http://beneb.info)
1
+ Copyright (c) Ben Briggs <beneb.info@gmail.com> (https://beneb.info)
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person
4
4
  obtaining a copy of this software and associated documentation
package/README.md CHANGED
@@ -42,6 +42,6 @@ See [CONTRIBUTORS.md](https://github.com/cssnano/cssnano/blob/master/CONTRIBUTOR
42
42
 
43
43
  ## License
44
44
 
45
- MIT © [Ben Briggs](http://beneb.info)
45
+ MIT © [Ben Briggs](https://beneb.info)
46
46
 
47
47
  [postcss]: https://github.com/postcss/postcss
package/package.json CHANGED
@@ -1,9 +1,17 @@
1
1
  {
2
2
  "name": "postcss-reduce-transforms",
3
- "version": "8.0.1",
3
+ "version": "8.0.3",
4
4
  "description": "Reduce transform functions with PostCSS.",
5
- "main": "src/index.js",
6
- "types": "types/index.d.ts",
5
+ "exports": {
6
+ ".": {
7
+ "types": "./types/index.d.ts",
8
+ "default": "./src/index.js"
9
+ },
10
+ "./src": "./src/index.js",
11
+ "./src/index": "./src/index.js",
12
+ "./src/index.js": "./src/index.js",
13
+ "./package.json": "./package.json"
14
+ },
7
15
  "files": [
8
16
  "LICENSE-MIT",
9
17
  "src",
@@ -14,9 +22,12 @@
14
22
  "author": {
15
23
  "name": "Ben Briggs",
16
24
  "email": "beneb.info@gmail.com",
17
- "url": "http://beneb.info"
25
+ "url": "https://beneb.info"
26
+ },
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "cssnano/cssnano"
18
30
  },
19
- "repository": "cssnano/cssnano",
20
31
  "dependencies": {
21
32
  "postcss-value-parser": "^4.2.0"
22
33
  },
@@ -27,9 +38,12 @@
27
38
  "node": "^22.11.0 || ^24.11.0 || >=26.0"
28
39
  },
29
40
  "devDependencies": {
30
- "postcss": "^8.5.15"
41
+ "postcss": "^8.5.26"
31
42
  },
32
43
  "peerDependencies": {
33
- "postcss": "^8.5.15"
44
+ "postcss": "^8.5.26"
45
+ },
46
+ "scripts": {
47
+ "test": "node --test"
34
48
  }
35
49
  }
package/src/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
  const valueParser = require('postcss-value-parser');
3
3
 
4
+ const transformRegex = /transform$/i;
4
5
  /**
5
6
  * @param {(number|string)[]} list
6
7
  * @param {valueParser.Node} node
@@ -142,8 +143,6 @@ function scale(node, values) {
142
143
  if (first === 1) {
143
144
  node.value = 'scaleY';
144
145
  node.nodes = [nodes[2]];
145
-
146
- return;
147
146
  }
148
147
  }
149
148
 
@@ -180,8 +179,6 @@ function scale3d(node, values) {
180
179
  if (first === 1 && second === 1) {
181
180
  node.value = 'scaleZ';
182
181
  node.nodes = [nodes[4]];
183
-
184
- return;
185
182
  }
186
183
  }
187
184
 
@@ -208,8 +205,6 @@ function translate(node, values) {
208
205
  if (values[0] === 0) {
209
206
  node.value = 'translateY';
210
207
  node.nodes = [nodes[2]];
211
-
212
- return;
213
208
  }
214
209
  }
215
210
 
@@ -264,14 +259,18 @@ function reduce(node) {
264
259
  const normalizedReducerName = normalizeReducerName(node.value);
265
260
  const reducer = reducers.get(normalizedReducerName);
266
261
  if (reducer !== undefined) {
267
- reducer(node, node.nodes.reduce(getValues, []));
262
+ /** @type {(number|string)[]} */
263
+ let values = [];
264
+ for (const [index, child] of node.nodes.entries()) {
265
+ values = getValues(values, child, index);
266
+ }
267
+ reducer(node, values);
268
268
  }
269
269
  }
270
270
  return false;
271
271
  }
272
272
 
273
273
  /**
274
- * @type {import('postcss').PluginCreator<void>}
275
274
  * @return {import('postcss').Plugin}
276
275
  */
277
276
  function pluginCreator() {
@@ -280,8 +279,11 @@ function pluginCreator() {
280
279
  prepare() {
281
280
  const cache = new Map();
282
281
  return {
282
+ /**
283
+ * @param {import('postcss').Root} css
284
+ */
283
285
  OnceExit(css) {
284
- css.walkDecls(/transform$/i, (decl) => {
286
+ css.walkDecls(transformRegex, (decl) => {
285
287
  const value = decl.value;
286
288
 
287
289
  if (!value) {
@@ -306,4 +308,6 @@ function pluginCreator() {
306
308
  }
307
309
 
308
310
  pluginCreator.postcss = true;
309
- module.exports = pluginCreator;
311
+ module.exports = /** @type {import('postcss').PluginCreator<void>} */ (
312
+ pluginCreator
313
+ );
package/types/index.d.ts CHANGED
@@ -1,10 +1,3 @@
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
- let postcss: true;
9
- }
1
+ declare const _exports: import("postcss").PluginCreator<void>;
2
+ export = _exports;
10
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":";AAgRA;;;GAGG;AACH,kCAFY,OAAO,SAAS,EAAE,MAAM,CA+BnC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":""}