postcss-normalize-positions 8.0.0 → 8.0.2

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
@@ -39,6 +39,6 @@ See [CONTRIBUTORS.md](https://github.com/cssnano/cssnano/blob/master/CONTRIBUTOR
39
39
 
40
40
  ## License
41
41
 
42
- MIT © [Ben Briggs](http://beneb.info)
42
+ MIT © [Ben Briggs](https://beneb.info)
43
43
 
44
44
  [postcss]: https://github.com/postcss/postcss
package/package.json CHANGED
@@ -1,9 +1,17 @@
1
1
  {
2
2
  "name": "postcss-normalize-positions",
3
- "version": "8.0.0",
3
+ "version": "8.0.2",
4
4
  "description": "Normalize keyword values for position into length values.",
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
  "src",
9
17
  "LICENSE-MIT",
@@ -19,9 +27,12 @@
19
27
  "author": {
20
28
  "name": "Ben Briggs",
21
29
  "email": "beneb.info@gmail.com",
22
- "url": "http://beneb.info"
30
+ "url": "https://beneb.info"
31
+ },
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "cssnano/cssnano"
23
35
  },
24
- "repository": "cssnano/cssnano",
25
36
  "dependencies": {
26
37
  "postcss-value-parser": "^4.2.0"
27
38
  },
@@ -32,9 +43,9 @@
32
43
  "node": "^22.11.0 || ^24.11.0 || >=26.0"
33
44
  },
34
45
  "devDependencies": {
35
- "postcss": "^8.5.14"
46
+ "postcss": "^8.5.25"
36
47
  },
37
48
  "peerDependencies": {
38
- "postcss": "^8.5.14"
49
+ "postcss": "^8.5.25"
39
50
  }
40
51
  }
package/src/index.js CHANGED
@@ -14,6 +14,8 @@ const verticalValue = new Map([
14
14
  ]);
15
15
  const mathFunctions = new Set(['calc', 'min', 'max', 'clamp']);
16
16
  const variableFunctions = new Set(['var', 'env', 'constant']);
17
+ const propFilterRegex =
18
+ /^(background(-position)?|(-\w+-)?perspective-origin)$/i;
17
19
  /**
18
20
  * @param {valueParser.Node} node
19
21
  * @return {boolean}
@@ -140,15 +142,9 @@ function transform(value) {
140
142
  }
141
143
 
142
144
  if (ranges[rangeIndex].start !== null) {
143
- if (node.type === 'space') {
144
- return;
145
- } else if (isPositionKeyword) {
145
+ if (node.type !== 'space' && isPositionKeyword) {
146
146
  ranges[rangeIndex].end = index;
147
-
148
- return;
149
147
  }
150
-
151
- return;
152
148
  }
153
149
  });
154
150
 
@@ -194,13 +190,9 @@ function transform(value) {
194
190
  if (horizontal.has(firstNode) && verticalValue.has(secondNode)) {
195
191
  nodes[0].value = /** @type {string} */ (horizontal.get(firstNode));
196
192
  nodes[2].value = /** @type {string} */ (verticalValue.get(secondNode));
197
-
198
- return;
199
193
  } else if (verticalValue.has(firstNode) && horizontal.has(secondNode)) {
200
194
  nodes[0].value = /** @type {string} */ (horizontal.get(secondNode));
201
195
  nodes[2].value = /** @type {string} */ (verticalValue.get(firstNode));
202
-
203
- return;
204
196
  }
205
197
  }
206
198
  });
@@ -209,40 +201,41 @@ function transform(value) {
209
201
  }
210
202
 
211
203
  /**
212
- * @type {import('postcss').PluginCreator<void>}
213
204
  * @return {import('postcss').Plugin}
214
205
  */
215
206
  function pluginCreator() {
216
207
  return {
217
208
  postcssPlugin: 'postcss-normalize-positions',
218
209
 
210
+ /**
211
+ * @param {import('postcss').Root} css
212
+ */
219
213
  OnceExit(css) {
220
214
  const cache = new Map();
221
215
 
222
- css.walkDecls(
223
- /^(background(-position)?|(-\w+-)?perspective-origin)$/i,
224
- (decl) => {
225
- const value = decl.value;
216
+ css.walkDecls(propFilterRegex, (decl) => {
217
+ const value = decl.value;
226
218
 
227
- if (!value) {
228
- return;
229
- }
219
+ if (!value) {
220
+ return;
221
+ }
230
222
 
231
- if (cache.has(value)) {
232
- decl.value = cache.get(value);
223
+ if (cache.has(value)) {
224
+ decl.value = cache.get(value);
233
225
 
234
- return;
235
- }
226
+ return;
227
+ }
236
228
 
237
- const result = transform(value);
229
+ const result = transform(value);
238
230
 
239
- decl.value = result;
240
- cache.set(value, result);
241
- }
242
- );
231
+ decl.value = result;
232
+ cache.set(value, result);
233
+ });
243
234
  },
244
235
  };
245
236
  }
246
237
 
247
238
  pluginCreator.postcss = true;
248
- module.exports = pluginCreator;
239
+ module.exports = /** @type {import('postcss').PluginCreator<void>}*/ (
240
+ pluginCreator
241
+ );
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":";AAkNA;;;GAGG;AACH,kCAFY,OAAO,SAAS,EAAE,MAAM,CAgCnC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":""}