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 +1 -1
- package/README.md +1 -1
- package/package.json +22 -8
- package/src/index.js +25 -20
- package/types/index.d.ts +2 -9
- package/types/index.d.ts.map +1 -1
package/LICENSE-MIT
CHANGED
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "postcss-merge-idents",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.3",
|
|
4
4
|
"description": "Merge keyframe and counter style identifiers.",
|
|
5
|
-
"
|
|
6
|
-
|
|
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": "
|
|
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.
|
|
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.
|
|
48
|
+
"postcss": "^8.5.26"
|
|
38
49
|
},
|
|
39
50
|
"peerDependencies": {
|
|
40
|
-
"postcss": "^8.5.
|
|
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:
|
|
42
|
-
decl:
|
|
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:
|
|
53
|
-
decl:
|
|
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
|
|
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
|
-
|
|
119
|
-
|
|
118
|
+
for (const pair of pairs) {
|
|
119
|
+
const canon = canonical(pair.replacements);
|
|
120
120
|
|
|
121
|
-
pair.decls
|
|
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
|
-
|
|
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 =
|
|
152
|
+
module.exports = /** @type {import('postcss').PluginCreator<void>} */ (
|
|
153
|
+
pluginCreator
|
|
154
|
+
);
|
package/types/index.d.ts
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
|
|
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
|
package/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":""}
|