postcss-normalize-repeat-style 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
@@ -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,19 @@
1
1
  {
2
2
  "name": "postcss-normalize-repeat-style",
3
- "version": "8.0.1",
3
+ "version": "8.0.3",
4
4
  "description": "Convert two value syntax for repeat-style into one value.",
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
+ "./src/lib/map": "./src/lib/map.js",
14
+ "./src/lib/map.js": "./src/lib/map.js",
15
+ "./package.json": "./package.json"
16
+ },
7
17
  "files": [
8
18
  "LICENSE-MIT",
9
19
  "src",
@@ -16,9 +26,12 @@
16
26
  "author": {
17
27
  "name": "Ben Briggs",
18
28
  "email": "beneb.info@gmail.com",
19
- "url": "http://beneb.info"
29
+ "url": "https://beneb.info"
30
+ },
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "cssnano/cssnano"
20
34
  },
21
- "repository": "cssnano/cssnano",
22
35
  "bugs": {
23
36
  "url": "https://github.com/cssnano/cssnano/issues"
24
37
  },
@@ -27,9 +40,12 @@
27
40
  "node": "^22.11.0 || ^24.11.0 || >=26.0"
28
41
  },
29
42
  "devDependencies": {
30
- "postcss": "^8.5.15"
43
+ "postcss": "^8.5.26"
31
44
  },
32
45
  "peerDependencies": {
33
- "postcss": "^8.5.15"
46
+ "postcss": "^8.5.26"
47
+ },
48
+ "scripts": {
49
+ "test": "node --test"
34
50
  }
35
51
  }
package/src/index.js CHANGED
@@ -2,6 +2,7 @@
2
2
  const valueParser = require('postcss-value-parser');
3
3
  const mappings = require('./lib/map');
4
4
 
5
+ const repeatPropertyRegex = /^(background(-repeat)?|(-\w+-)?mask-repeat)$/i;
5
6
  /**
6
7
  * @param {unknown} item
7
8
  * @param {number} index
@@ -49,17 +50,17 @@ function transform(value) {
49
50
  let rangeIndex = 0;
50
51
  let shouldContinue = true;
51
52
 
52
- parsed.nodes.forEach((node, index) => {
53
+ for (const [index, node] of parsed.nodes.entries()) {
53
54
  // After comma (`,`) follows next background
54
55
  if (isCommaNode(node)) {
55
56
  rangeIndex += 1;
56
57
  shouldContinue = true;
57
58
 
58
- return;
59
+ continue;
59
60
  }
60
61
 
61
62
  if (!shouldContinue) {
62
- return;
63
+ continue;
63
64
  }
64
65
 
65
66
  // After separator (`/`) follows `background-size` values
@@ -67,7 +68,7 @@ function transform(value) {
67
68
  if (node.type === 'div' && node.value === '/') {
68
69
  shouldContinue = false;
69
70
 
70
- return;
71
+ continue;
71
72
  }
72
73
 
73
74
  if (!ranges[rangeIndex]) {
@@ -83,7 +84,7 @@ function transform(value) {
83
84
  ranges[rangeIndex].start = null;
84
85
  ranges[rangeIndex].end = null;
85
86
 
86
- return;
87
+ continue;
87
88
  }
88
89
 
89
90
  const isRepeatKeyword =
@@ -93,25 +94,19 @@ function transform(value) {
93
94
  ranges[rangeIndex].start = index;
94
95
  ranges[rangeIndex].end = index;
95
96
 
96
- return;
97
+ continue;
97
98
  }
98
99
 
99
100
  if (ranges[rangeIndex].start !== null) {
100
- if (node.type === 'space') {
101
- return;
102
- } else if (isRepeatKeyword) {
101
+ if (node.type !== 'space' && isRepeatKeyword) {
103
102
  ranges[rangeIndex].end = index;
104
-
105
- return;
106
103
  }
107
-
108
- return;
109
104
  }
110
- });
105
+ }
111
106
 
112
- ranges.forEach((range) => {
107
+ for (const range of ranges) {
113
108
  if (range.start === null) {
114
- return;
109
+ continue;
115
110
  }
116
111
 
117
112
  const nodes = parsed.nodes.slice(
@@ -120,7 +115,7 @@ function transform(value) {
120
115
  );
121
116
 
122
117
  if (nodes.length !== 3) {
123
- return;
118
+ continue;
124
119
  }
125
120
  const key = nodes
126
121
  .filter(evenValues)
@@ -133,13 +128,12 @@ function transform(value) {
133
128
  nodes[0].value = match;
134
129
  nodes[1].value = nodes[2].value = '';
135
130
  }
136
- });
131
+ }
137
132
 
138
133
  return parsed.toString();
139
134
  }
140
135
 
141
136
  /**
142
- * @type {import('postcss').PluginCreator<void>}
143
137
  * @return {import('postcss').Plugin}
144
138
  */
145
139
  function pluginCreator() {
@@ -148,28 +142,28 @@ function pluginCreator() {
148
142
  prepare() {
149
143
  const cache = new Map();
150
144
  return {
145
+ /**
146
+ * @param {import('postcss').Root} css
147
+ */
151
148
  OnceExit(css) {
152
- css.walkDecls(
153
- /^(background(-repeat)?|(-\w+-)?mask-repeat)$/i,
154
- (decl) => {
155
- const value = decl.value;
149
+ css.walkDecls(repeatPropertyRegex, (decl) => {
150
+ const value = decl.value;
156
151
 
157
- if (!value) {
158
- return;
159
- }
152
+ if (!value) {
153
+ return;
154
+ }
160
155
 
161
- if (cache.has(value)) {
162
- decl.value = cache.get(value);
156
+ if (cache.has(value)) {
157
+ decl.value = cache.get(value);
163
158
 
164
- return;
165
- }
159
+ return;
160
+ }
166
161
 
167
- const result = transform(value);
162
+ const result = transform(value);
168
163
 
169
- decl.value = result;
170
- cache.set(value, result);
171
- }
172
- );
164
+ decl.value = result;
165
+ cache.set(value, result);
166
+ });
173
167
  },
174
168
  };
175
169
  },
@@ -177,4 +171,6 @@ function pluginCreator() {
177
171
  }
178
172
 
179
173
  pluginCreator.postcss = true;
180
- module.exports = pluginCreator;
174
+ module.exports = /** @type {import('postcss').PluginCreator<void>}*/ (
175
+ pluginCreator
176
+ );
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":";AA4IA;;;GAGG;AACH,kCAFY,OAAO,SAAS,EAAE,MAAM,CAkCnC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":""}