postcss-normalize-unicode 4.0.0-nightly.2020.9.3 → 4.0.0
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/CHANGELOG.md +4 -0
- package/dist/index.js +62 -73
- package/package.json +10 -9
package/CHANGELOG.md
ADDED
package/dist/index.js
CHANGED
|
@@ -1,104 +1,93 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
4
|
+
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = void 0;
|
|
7
6
|
|
|
8
|
-
var _browserslist =
|
|
7
|
+
var _browserslist = require('browserslist');
|
|
9
8
|
|
|
10
|
-
var
|
|
9
|
+
var _browserslist2 = _interopRequireDefault(_browserslist);
|
|
11
10
|
|
|
12
|
-
var
|
|
11
|
+
var _postcss = require('postcss');
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
var _postcss2 = _interopRequireDefault(_postcss);
|
|
15
14
|
|
|
16
|
-
|
|
15
|
+
var _postcssValueParser = require('postcss-value-parser');
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
const values = range.slice(2).split('-');
|
|
20
|
-
|
|
21
|
-
if (values.length < 2) {
|
|
22
|
-
return range;
|
|
23
|
-
}
|
|
17
|
+
var _postcssValueParser2 = _interopRequireDefault(_postcssValueParser);
|
|
24
18
|
|
|
25
|
-
|
|
26
|
-
const right = values[1].split('');
|
|
19
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
20
|
|
|
28
|
-
|
|
29
|
-
return range;
|
|
30
|
-
}
|
|
21
|
+
const regexLowerCaseUPrefix = /^u(?=\+)/;
|
|
31
22
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (
|
|
35
|
-
|
|
23
|
+
function unicode(range) {
|
|
24
|
+
const values = range.slice(2).split('-');
|
|
25
|
+
if (values.length < 2) {
|
|
26
|
+
return range;
|
|
36
27
|
}
|
|
28
|
+
const left = values[0].split('');
|
|
29
|
+
const right = values[1].split('');
|
|
37
30
|
|
|
38
|
-
if (
|
|
39
|
-
|
|
31
|
+
if (left.length !== right.length) {
|
|
32
|
+
return range;
|
|
40
33
|
}
|
|
41
34
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
35
|
+
let questionCounter = 0;
|
|
36
|
+
|
|
37
|
+
const merged = left.reduce((group, value, index) => {
|
|
38
|
+
if (group === false) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
if (value === right[index] && !questionCounter) {
|
|
42
|
+
return group + value;
|
|
43
|
+
}
|
|
44
|
+
if (value === '0' && right[index] === 'f') {
|
|
45
|
+
questionCounter++;
|
|
46
|
+
return group + '?';
|
|
47
|
+
}
|
|
48
|
+
return false;
|
|
49
|
+
}, 'u+');
|
|
50
|
+
|
|
51
|
+
/*
|
|
52
|
+
* The maximum number of wildcard characters (?) for ranges is 5.
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
if (merged && questionCounter < 6) {
|
|
56
|
+
return merged;
|
|
45
57
|
}
|
|
46
58
|
|
|
47
|
-
return
|
|
48
|
-
}, 'u+'); // The maximum number of wildcard characters (?) for ranges is 5.
|
|
49
|
-
|
|
50
|
-
if (merged && questionCounter < 6) {
|
|
51
|
-
return merged;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return range;
|
|
59
|
+
return range;
|
|
55
60
|
}
|
|
61
|
+
|
|
56
62
|
/*
|
|
57
63
|
* IE and Edge before 16 version ignore the unicode-range if the 'U' is lowercase
|
|
58
64
|
*
|
|
59
65
|
* https://caniuse.com/#search=unicode-range
|
|
60
66
|
*/
|
|
61
67
|
|
|
62
|
-
|
|
63
68
|
function hasLowerCaseUPrefixBug(browser) {
|
|
64
|
-
|
|
69
|
+
return ~(0, _browserslist2.default)('ie <=11, edge <= 15').indexOf(browser);
|
|
65
70
|
}
|
|
66
71
|
|
|
67
|
-
function transform(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}).toString();
|
|
72
|
+
function transform(legacy = false, node) {
|
|
73
|
+
node.value = (0, _postcssValueParser2.default)(node.value).walk(child => {
|
|
74
|
+
if (child.type === 'word') {
|
|
75
|
+
const transformed = unicode(child.value.toLowerCase());
|
|
76
|
+
child.value = legacy ? transformed.replace(regexLowerCaseUPrefix, 'U') : transformed;
|
|
77
|
+
}
|
|
78
|
+
return false;
|
|
79
|
+
}).toString();
|
|
76
80
|
}
|
|
77
81
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
css.walkDecls(/^unicode-range$/i, decl => {
|
|
89
|
-
const value = decl.value;
|
|
90
|
-
|
|
91
|
-
if (cache[value]) {
|
|
92
|
-
decl.value = cache[value];
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const newValue = transform(value, isLegacy);
|
|
97
|
-
decl.value = newValue;
|
|
98
|
-
cache[value] = newValue;
|
|
99
|
-
});
|
|
100
|
-
};
|
|
82
|
+
exports.default = _postcss2.default.plugin('postcss-normalize-unicode', () => {
|
|
83
|
+
return (css, result) => {
|
|
84
|
+
const resultOpts = result.opts || {};
|
|
85
|
+
const browsers = (0, _browserslist2.default)(null, {
|
|
86
|
+
stats: resultOpts.stats,
|
|
87
|
+
path: __dirname,
|
|
88
|
+
env: resultOpts.env
|
|
89
|
+
});
|
|
90
|
+
css.walkDecls(/^unicode-range$/i, transform.bind(null, browsers.some(hasLowerCaseUPrefixBug)));
|
|
91
|
+
};
|
|
101
92
|
});
|
|
102
|
-
|
|
103
|
-
exports.default = _default;
|
|
104
|
-
module.exports = exports.default;
|
|
93
|
+
module.exports = exports['default'];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "postcss-normalize-unicode",
|
|
3
|
-
"version": "4.0.0
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Normalize unicode-range descriptors, and can convert to wildcard ranges.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -8,9 +8,7 @@
|
|
|
8
8
|
"LICENSE-MIT"
|
|
9
9
|
],
|
|
10
10
|
"scripts": {
|
|
11
|
-
"
|
|
12
|
-
"build": "cross-env BABEL_ENV=publish babel src --config-file ../../babel.config.js --out-dir dist --ignore \"**/__tests__/\"",
|
|
13
|
-
"prepublish": ""
|
|
11
|
+
"prepublish": "cross-env BABEL_ENV=publish babel src --out-dir dist --ignore /__tests__/"
|
|
14
12
|
},
|
|
15
13
|
"keywords": [
|
|
16
14
|
"css",
|
|
@@ -18,6 +16,10 @@
|
|
|
18
16
|
"postcss-plugin"
|
|
19
17
|
],
|
|
20
18
|
"license": "MIT",
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"babel-cli": "^6.0.0",
|
|
21
|
+
"cross-env": "^5.0.0"
|
|
22
|
+
},
|
|
21
23
|
"homepage": "https://github.com/cssnano/cssnano",
|
|
22
24
|
"author": {
|
|
23
25
|
"name": "Ben Briggs",
|
|
@@ -26,14 +28,13 @@
|
|
|
26
28
|
},
|
|
27
29
|
"repository": "cssnano/cssnano",
|
|
28
30
|
"dependencies": {
|
|
29
|
-
"
|
|
30
|
-
"postcss": "^
|
|
31
|
-
"postcss-value-parser": "^3.3.1"
|
|
31
|
+
"postcss": "^6.0.0",
|
|
32
|
+
"postcss-value-parser": "^3.0.0"
|
|
32
33
|
},
|
|
33
34
|
"bugs": {
|
|
34
35
|
"url": "https://github.com/cssnano/cssnano/issues"
|
|
35
36
|
},
|
|
36
37
|
"engines": {
|
|
37
|
-
"node": ">=
|
|
38
|
+
"node": ">=6.9.0"
|
|
38
39
|
}
|
|
39
|
-
}
|
|
40
|
+
}
|