postcss-merge-idents 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
@@ -71,7 +71,7 @@ See [CONTRIBUTORS.md](https://github.com/cssnano/cssnano/blob/master/CONTRIBUTOR
71
71
 
72
72
  ## License
73
73
 
74
- MIT © [Ben Briggs](http://beneb.info)
74
+ MIT © [Ben Briggs](https://beneb.info)
75
75
 
76
76
 
77
77
  [postcss]: https://github.com/postcss/postcss
package/package.json CHANGED
@@ -1,9 +1,17 @@
1
1
  {
2
2
  "name": "postcss-merge-idents",
3
- "version": "8.0.1",
3
+ "version": "8.0.3",
4
4
  "description": "Merge keyframe and counter style identifiers.",
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",
@@ -20,12 +28,15 @@
20
28
  "author": {
21
29
  "name": "Ben Briggs",
22
30
  "email": "beneb.info@gmail.com",
23
- "url": "http://beneb.info"
31
+ "url": "https://beneb.info"
32
+ },
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "cssnano/cssnano"
24
36
  },
25
- "repository": "cssnano/cssnano",
26
37
  "dependencies": {
27
38
  "postcss-value-parser": "^4.2.0",
28
- "cssnano-utils": "^6.0.1"
39
+ "cssnano-utils": "^6.0.3"
29
40
  },
30
41
  "bugs": {
31
42
  "url": "https://github.com/cssnano/cssnano/issues"
@@ -34,9 +45,12 @@
34
45
  "node": "^22.11.0 || ^24.11.0 || >=26.0"
35
46
  },
36
47
  "devDependencies": {
37
- "postcss": "^8.5.15"
48
+ "postcss": "^8.5.26"
38
49
  },
39
50
  "peerDependencies": {
40
- "postcss": "^8.5.15"
51
+ "postcss": "^8.5.26"
52
+ },
53
+ "scripts": {
54
+ "test": "node --test"
41
55
  }
42
56
  }
package/src/index.js CHANGED
@@ -2,6 +2,10 @@
2
2
  const valueParser = require('postcss-value-parser');
3
3
  const { sameParent } = require('cssnano-utils');
4
4
 
5
+ const keyframesRegex = /keyframes/i;
6
+ const animationRegex = /animation/i;
7
+ const counterStyleRegex = /counter-style/i;
8
+ const listStyleSystemRegex = /(list-style|system)/i;
5
9
  /**
6
10
  * @param {Record<string, string>} obj
7
11
  * @return {(key: string) => string}
@@ -15,11 +19,7 @@ function canonical(obj) {
15
19
  * @return {string}
16
20
  */
17
21
  return function recurse(key) {
18
- if (
19
- Object.prototype.hasOwnProperty.call(obj, key) &&
20
- obj[key] !== key &&
21
- stack
22
- ) {
22
+ if (Object.hasOwn(obj, key) && obj[key] !== key && stack) {
23
23
  stack--;
24
24
 
25
25
  return recurse(obj[key]);
@@ -38,8 +38,8 @@ function canonical(obj) {
38
38
  function mergeAtRules(css) {
39
39
  const pairs = [
40
40
  {
41
- atrule: /keyframes/i,
42
- decl: /animation/i,
41
+ atrule: keyframesRegex,
42
+ decl: animationRegex,
43
43
  /** @type {import('postcss').AtRule[]} */
44
44
  cache: [],
45
45
  replacements: {},
@@ -49,8 +49,8 @@ function mergeAtRules(css) {
49
49
  removals: [],
50
50
  },
51
51
  {
52
- atrule: /counter-style/i,
53
- decl: /(list-style|system)/i,
52
+ atrule: counterStyleRegex,
53
+ decl: listStyleSystemRegex,
54
54
  cache: [],
55
55
  replacements: {},
56
56
  decls: [],
@@ -79,7 +79,7 @@ function mergeAtRules(css) {
79
79
  } else {
80
80
  const toString = node.nodes ? node.nodes.toString() : '';
81
81
 
82
- relevant.cache.forEach((cached) => {
82
+ for (const cached of relevant.cache) {
83
83
  const cachedStringContent = cached.nodes
84
84
  ? cached.nodes.toString()
85
85
  : '';
@@ -94,7 +94,7 @@ function mergeAtRules(css) {
94
94
  relevant.removals.push(cached);
95
95
  relevant.replacements[cached.params] = node.params;
96
96
  }
97
- });
97
+ }
98
98
 
99
99
  relevant.cache.push(node);
100
100
 
@@ -115,10 +115,10 @@ function mergeAtRules(css) {
115
115
  }
116
116
  });
117
117
 
118
- pairs.forEach((pair) => {
119
- let canon = canonical(pair.replacements);
118
+ for (const pair of pairs) {
119
+ const canon = canonical(pair.replacements);
120
120
 
121
- pair.decls.forEach((decl) => {
121
+ for (const decl of pair.decls) {
122
122
  decl.value = valueParser(decl.value)
123
123
  .walk((node) => {
124
124
  if (node.type === 'word') {
@@ -126,19 +126,22 @@ function mergeAtRules(css) {
126
126
  }
127
127
  })
128
128
  .toString();
129
- });
130
- pair.removals.forEach((cached) => cached.remove());
131
- });
129
+ }
130
+ for (const cached of pair.removals) {
131
+ cached.remove();
132
+ }
133
+ }
132
134
  }
133
135
 
134
136
  /**
135
- * @type {import('postcss').PluginCreator<void>}
136
137
  * @return {import('postcss').Plugin}
137
138
  */
138
139
  function pluginCreator() {
139
140
  return {
140
141
  postcssPlugin: 'postcss-merge-idents',
141
-
142
+ /**
143
+ * @param {import('postcss').Root} css
144
+ */
142
145
  OnceExit(css) {
143
146
  mergeAtRules(css);
144
147
  },
@@ -146,4 +149,6 @@ function pluginCreator() {
146
149
  }
147
150
 
148
151
  pluginCreator.postcss = true;
149
- module.exports = pluginCreator;
152
+ module.exports = /** @type {import('postcss').PluginCreator<void>} */ (
153
+ pluginCreator
154
+ );
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":";AAqIA;;;GAGG;AACH,kCAFY,OAAO,SAAS,EAAE,MAAM,CAUnC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":""}