postcss-normalize-positions 5.0.0-rc.2 → 5.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/dist/index.js +24 -31
- package/package.json +10 -11
- package/CHANGELOG.md +0 -63
package/dist/index.js
CHANGED
|
@@ -7,20 +7,15 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _postcssValueParser = _interopRequireWildcard(require("postcss-value-parser"));
|
|
9
9
|
|
|
10
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var
|
|
10
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
11
11
|
|
|
12
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
12
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
13
13
|
|
|
14
|
-
const directionKeywords = ['top', 'right', 'bottom', 'left', 'center'];
|
|
14
|
+
const directionKeywords = new Set(['top', 'right', 'bottom', 'left', 'center']);
|
|
15
15
|
const center = '50%';
|
|
16
|
-
const horizontal =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
const verticalValue = {
|
|
21
|
-
bottom: '100%',
|
|
22
|
-
top: '0'
|
|
23
|
-
};
|
|
16
|
+
const horizontal = new Map([['right', '100%'], ['left', '0']]);
|
|
17
|
+
const verticalValue = new Map([['bottom', '100%'], ['top', '0']]);
|
|
18
|
+
const mathFunctions = new Set(['calc', 'min', 'max', 'clamp']);
|
|
24
19
|
|
|
25
20
|
function isCommaNode(node) {
|
|
26
21
|
return node.type === 'div' && node.value === ',';
|
|
@@ -39,7 +34,7 @@ function isMathFunctionNode(node) {
|
|
|
39
34
|
return false;
|
|
40
35
|
}
|
|
41
36
|
|
|
42
|
-
return
|
|
37
|
+
return mathFunctions.has(node.value.toLowerCase());
|
|
43
38
|
}
|
|
44
39
|
|
|
45
40
|
function isNumberNode(node) {
|
|
@@ -104,7 +99,7 @@ function transform(value) {
|
|
|
104
99
|
return;
|
|
105
100
|
}
|
|
106
101
|
|
|
107
|
-
const isPositionKeyword = node.type === 'word' && directionKeywords.
|
|
102
|
+
const isPositionKeyword = node.type === 'word' && directionKeywords.has(node.value.toLowerCase()) || isDimensionNode(node) || isNumberNode(node) || isMathFunctionNode(node);
|
|
108
103
|
|
|
109
104
|
if (ranges[rangeIndex].start === null && isPositionKeyword) {
|
|
110
105
|
ranges[rangeIndex].start = index;
|
|
@@ -142,34 +137,32 @@ function transform(value) {
|
|
|
142
137
|
nodes[2].value = nodes[1].value = '';
|
|
143
138
|
}
|
|
144
139
|
|
|
145
|
-
const map =
|
|
146
|
-
center
|
|
147
|
-
});
|
|
140
|
+
const map = new Map([...horizontal, ['center', center]]);
|
|
148
141
|
|
|
149
|
-
if (
|
|
150
|
-
nodes[0].value = map
|
|
142
|
+
if (map.has(firstNode)) {
|
|
143
|
+
nodes[0].value = map.get(firstNode);
|
|
151
144
|
}
|
|
152
145
|
|
|
153
146
|
return;
|
|
154
147
|
}
|
|
155
148
|
|
|
156
|
-
if (firstNode === 'center' && directionKeywords.
|
|
149
|
+
if (firstNode === 'center' && directionKeywords.has(secondNode)) {
|
|
157
150
|
nodes[0].value = nodes[1].value = '';
|
|
158
151
|
|
|
159
|
-
if (
|
|
160
|
-
nodes[2].value = horizontal
|
|
152
|
+
if (horizontal.has(secondNode)) {
|
|
153
|
+
nodes[2].value = horizontal.get(secondNode);
|
|
161
154
|
}
|
|
162
155
|
|
|
163
156
|
return;
|
|
164
157
|
}
|
|
165
158
|
|
|
166
|
-
if (
|
|
167
|
-
nodes[0].value = horizontal
|
|
168
|
-
nodes[2].value = verticalValue
|
|
159
|
+
if (horizontal.has(firstNode) && verticalValue.has(secondNode)) {
|
|
160
|
+
nodes[0].value = horizontal.get(firstNode);
|
|
161
|
+
nodes[2].value = verticalValue.get(secondNode);
|
|
169
162
|
return;
|
|
170
|
-
} else if (
|
|
171
|
-
nodes[0].value = horizontal
|
|
172
|
-
nodes[2].value = verticalValue
|
|
163
|
+
} else if (verticalValue.has(firstNode) && horizontal.has(secondNode)) {
|
|
164
|
+
nodes[0].value = horizontal.get(secondNode);
|
|
165
|
+
nodes[2].value = verticalValue.get(firstNode);
|
|
173
166
|
return;
|
|
174
167
|
}
|
|
175
168
|
});
|
|
@@ -181,7 +174,7 @@ function pluginCreator() {
|
|
|
181
174
|
postcssPlugin: 'postcss-normalize-positions',
|
|
182
175
|
|
|
183
176
|
OnceExit(css) {
|
|
184
|
-
const cache =
|
|
177
|
+
const cache = new Map();
|
|
185
178
|
css.walkDecls(/^(background(-position)?|(-\w+-)?perspective-origin)$/i, decl => {
|
|
186
179
|
const value = decl.value;
|
|
187
180
|
|
|
@@ -189,14 +182,14 @@ function pluginCreator() {
|
|
|
189
182
|
return;
|
|
190
183
|
}
|
|
191
184
|
|
|
192
|
-
if (cache
|
|
193
|
-
decl.value = cache
|
|
185
|
+
if (cache.has(value)) {
|
|
186
|
+
decl.value = cache.get(value);
|
|
194
187
|
return;
|
|
195
188
|
}
|
|
196
189
|
|
|
197
190
|
const result = transform(value);
|
|
198
191
|
decl.value = result;
|
|
199
|
-
cache
|
|
192
|
+
cache.set(value, result);
|
|
200
193
|
});
|
|
201
194
|
}
|
|
202
195
|
|
package/package.json
CHANGED
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "postcss-normalize-positions",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.3",
|
|
4
4
|
"description": "Normalize keyword values for position into length values.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist",
|
|
8
8
|
"LICENSE-MIT"
|
|
9
9
|
],
|
|
10
|
-
"scripts": {
|
|
11
|
-
"prebuild": "del-cli dist",
|
|
12
|
-
"build": "cross-env BABEL_ENV=publish babel src --config-file ../../babel.config.js --out-dir dist --ignore \"**/__tests__/\"",
|
|
13
|
-
"prepublish": "yarn build"
|
|
14
|
-
},
|
|
15
10
|
"keywords": [
|
|
16
11
|
"css",
|
|
17
12
|
"postcss",
|
|
@@ -26,7 +21,7 @@
|
|
|
26
21
|
},
|
|
27
22
|
"repository": "cssnano/cssnano",
|
|
28
23
|
"dependencies": {
|
|
29
|
-
"postcss-value-parser": "^4.
|
|
24
|
+
"postcss-value-parser": "^4.2.0"
|
|
30
25
|
},
|
|
31
26
|
"bugs": {
|
|
32
27
|
"url": "https://github.com/cssnano/cssnano/issues"
|
|
@@ -35,10 +30,14 @@
|
|
|
35
30
|
"node": "^10 || ^12 || >=14.0"
|
|
36
31
|
},
|
|
37
32
|
"devDependencies": {
|
|
38
|
-
"postcss": "^8.2.
|
|
33
|
+
"postcss": "^8.2.15"
|
|
39
34
|
},
|
|
40
35
|
"peerDependencies": {
|
|
41
|
-
"postcss": "^8.2.
|
|
36
|
+
"postcss": "^8.2.15"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"prebuild": "rimraf dist",
|
|
40
|
+
"build": "babel src --config-file ../../babel.config.json --out-dir dist --ignore \"**/__tests__/\""
|
|
42
41
|
},
|
|
43
|
-
"
|
|
44
|
-
}
|
|
42
|
+
"readme": "# [postcss][postcss]-normalize-positions\n\n> Normalize positions with PostCSS.\n\n## Install\n\nWith [npm](https://npmjs.org/package/postcss-normalize-positions) do:\n\n```\nnpm install postcss-normalize-positions --save\n```\n\n## Example\n\n### Input\n\n```css\ndiv {\n background-position: bottom left;\n}\n```\n\n### Output\n\n```css\ndiv {\n background-position:0 100%;\n}\n``` \n\n## Usage\n\nSee the [PostCSS documentation](https://github.com/postcss/postcss#usage) for\nexamples for your environment.\n\n## Contributors\n\nSee [CONTRIBUTORS.md](https://github.com/cssnano/cssnano/blob/master/CONTRIBUTORS.md).\n\n## License\n\nMIT © [Ben Briggs](http://beneb.info)\n\n[postcss]: https://github.com/postcss/postcss\n"
|
|
43
|
+
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
# Change Log
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
-
|
|
6
|
-
# [5.0.0-rc.2](https://github.com/cssnano/cssnano/compare/postcss-normalize-positions@5.0.0-rc.1...postcss-normalize-positions@5.0.0-rc.2) (2021-03-15)
|
|
7
|
-
|
|
8
|
-
**Note:** Version bump only for package postcss-normalize-positions
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
# [5.0.0-rc.1](https://github.com/cssnano/cssnano/compare/postcss-normalize-positions@5.0.0-rc.0...postcss-normalize-positions@5.0.0-rc.1) (2021-03-04)
|
|
15
|
-
|
|
16
|
-
**Note:** Version bump only for package postcss-normalize-positions
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
# 5.0.0-rc.0 (2021-02-19)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
### Bug Fixes
|
|
26
|
-
|
|
27
|
-
* **postcss-normalize-positions:** correct optimize math (`calc` and etc) and variable functions (`var` and `env`) ([#750](https://github.com/cssnano/cssnano/issues/750)) ([a81e8df](https://github.com/cssnano/cssnano/commit/a81e8dfc1ad26067d5a9efab8081072cd4b15c44))
|
|
28
|
-
* **postcss-normalize-repeat-style:** better handle css variables ([#753](https://github.com/cssnano/cssnano/issues/753)) ([7e18b0c](https://github.com/cssnano/cssnano/commit/7e18b0cbcd7cb5de58e60ab4ef1900a4d8eeefec))
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
### chore
|
|
32
|
-
|
|
33
|
-
* minimum require version of node is 10.13 ([#871](https://github.com/cssnano/cssnano/issues/871)) ([28bda24](https://github.com/cssnano/cssnano/commit/28bda243e32ce3ba89b3c358a5f78727b3732f11))
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
### Features
|
|
37
|
-
|
|
38
|
-
* migarete to PostCSS 8 ([#975](https://github.com/cssnano/cssnano/issues/975)) ([40b82dc](https://github.com/cssnano/cssnano/commit/40b82dca7f53ac02cd4fe62846dec79b898ccb49))
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
### BREAKING CHANGES
|
|
42
|
-
|
|
43
|
-
* minimum supported `postcss` version is `8.2.1`
|
|
44
|
-
* minimum require version of node is 10.13
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
## 4.1.9 (2019-02-12)
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
### Performance Improvements
|
|
52
|
-
|
|
53
|
-
* **postcss-normalize-positions:** increase perf ([#694](https://github.com/cssnano/cssnano/issues/694)) ([95639da](https://github.com/cssnano/cssnano/commit/95639da5659aef112586b9334a1e13ac0b61a525))
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
## 4.1.1 (2018-09-24)
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
### Bug Fixes
|
|
61
|
-
|
|
62
|
-
* handle uppercase property and values on `postcss-normalize-positions` ([#607](https://github.com/cssnano/cssnano/issues/607)) ([c521423](https://github.com/cssnano/cssnano/commit/c521423d5939039b771ba1b12fad5fe377a6c612))
|
|
63
|
-
* **postcss-merge-longhand:** not mangle border output ([#555](https://github.com/cssnano/cssnano/issues/555)) ([9a70605](https://github.com/cssnano/cssnano/commit/9a706050b621e7795a9bf74eb7110b5c81804ffe)), closes [#553](https://github.com/cssnano/cssnano/issues/553) [#554](https://github.com/cssnano/cssnano/issues/554)
|