postcss-normalize-unicode 4.0.1 → 5.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.
Files changed (3) hide show
  1. package/CHANGELOG.md +55 -3
  2. package/dist/index.js +82 -61
  3. package/package.json +15 -11
package/CHANGELOG.md CHANGED
@@ -1,4 +1,56 @@
1
- # 4.0.0-rc.0
1
+ # Change Log
2
2
 
3
- * Initial commit. This module was previously part of other cssnano modules and
4
- has been extracted out.
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](https://github.com/cssnano/cssnano/compare/postcss-normalize-unicode@5.0.0-rc.2...postcss-normalize-unicode@5.0.0) (2021-04-06)
7
+
8
+ **Note:** Version bump only for package postcss-normalize-unicode
9
+
10
+
11
+
12
+
13
+
14
+ # [5.0.0-rc.2](https://github.com/cssnano/cssnano/compare/postcss-normalize-unicode@5.0.0-rc.1...postcss-normalize-unicode@5.0.0-rc.2) (2021-03-15)
15
+
16
+ **Note:** Version bump only for package postcss-normalize-unicode
17
+
18
+
19
+
20
+
21
+
22
+ # [5.0.0-rc.1](https://github.com/cssnano/cssnano/compare/postcss-normalize-unicode@5.0.0-rc.0...postcss-normalize-unicode@5.0.0-rc.1) (2021-03-04)
23
+
24
+ **Note:** Version bump only for package postcss-normalize-unicode
25
+
26
+
27
+
28
+
29
+
30
+ # 5.0.0-rc.0 (2021-02-19)
31
+
32
+
33
+ ### chore
34
+
35
+ * minimum require version of node is 10.13 ([#871](https://github.com/cssnano/cssnano/issues/871)) ([28bda24](https://github.com/cssnano/cssnano/commit/28bda243e32ce3ba89b3c358a5f78727b3732f11))
36
+
37
+
38
+ ### Features
39
+
40
+ * migarete to PostCSS 8 ([#975](https://github.com/cssnano/cssnano/issues/975)) ([40b82dc](https://github.com/cssnano/cssnano/commit/40b82dca7f53ac02cd4fe62846dec79b898ccb49))
41
+
42
+
43
+ ### BREAKING CHANGES
44
+
45
+ * minimum supported `postcss` version is `8.2.1`
46
+ * minimum require version of node is 10.13
47
+
48
+
49
+
50
+ ## 4.1.1 (2018-09-24)
51
+
52
+
53
+ ### Bug Fixes
54
+
55
+ * postcss-normalize-unicode add browserslist to dependencies ([#577](https://github.com/cssnano/cssnano/issues/577)) ([39ec020](https://github.com/cssnano/cssnano/commit/39ec020d9d6fc6ed72bf8de6e856752726d4fb51))
56
+ * **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)
package/dist/index.js CHANGED
@@ -1,93 +1,114 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
- value: true
4
+ value: true
5
5
  });
6
+ exports.default = void 0;
6
7
 
7
- var _browserslist = require('browserslist');
8
+ var _browserslist = _interopRequireDefault(require("browserslist"));
8
9
 
9
- var _browserslist2 = _interopRequireDefault(_browserslist);
10
+ var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
10
11
 
11
- var _postcss = require('postcss');
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
13
 
13
- var _postcss2 = _interopRequireDefault(_postcss);
14
+ const regexLowerCaseUPrefix = /^u(?=\+)/;
14
15
 
15
- var _postcssValueParser = require('postcss-value-parser');
16
+ function unicode(range) {
17
+ const values = range.slice(2).split('-');
16
18
 
17
- var _postcssValueParser2 = _interopRequireDefault(_postcssValueParser);
19
+ if (values.length < 2) {
20
+ return range;
21
+ }
18
22
 
19
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
+ const left = values[0].split('');
24
+ const right = values[1].split('');
20
25
 
21
- const regexLowerCaseUPrefix = /^u(?=\+)/;
26
+ if (left.length !== right.length) {
27
+ return range;
28
+ }
22
29
 
23
- function unicode(range) {
24
- const values = range.slice(2).split('-');
25
- if (values.length < 2) {
26
- return range;
30
+ let questionCounter = 0;
31
+ const merged = left.reduce((group, value, index) => {
32
+ if (group === false) {
33
+ return false;
27
34
  }
28
- const left = values[0].split('');
29
- const right = values[1].split('');
30
35
 
31
- if (left.length !== right.length) {
32
- return range;
36
+ if (value === right[index] && !questionCounter) {
37
+ return group + value;
33
38
  }
34
39
 
35
- let questionCounter = 0;
40
+ if (value === '0' && right[index] === 'f') {
41
+ questionCounter++;
42
+ return group + '?';
43
+ }
36
44
 
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+');
45
+ return false;
46
+ }, 'u+'); // The maximum number of wildcard characters (?) for ranges is 5.
50
47
 
51
- /*
52
- * The maximum number of wildcard characters (?) for ranges is 5.
53
- */
48
+ if (merged && questionCounter < 6) {
49
+ return merged;
50
+ }
54
51
 
55
- if (merged && questionCounter < 6) {
56
- return merged;
57
- }
58
-
59
- return range;
52
+ return range;
60
53
  }
61
-
62
54
  /*
63
55
  * IE and Edge before 16 version ignore the unicode-range if the 'U' is lowercase
64
56
  *
65
57
  * https://caniuse.com/#search=unicode-range
66
58
  */
67
59
 
60
+
68
61
  function hasLowerCaseUPrefixBug(browser) {
69
- return ~(0, _browserslist2.default)('ie <=11, edge <= 15').indexOf(browser);
62
+ return ~(0, _browserslist.default)('ie <=11, edge <= 15').indexOf(browser);
63
+ }
64
+
65
+ function transform(value, isLegacy = false) {
66
+ return (0, _postcssValueParser.default)(value).walk(child => {
67
+ if (child.type === 'unicode-range') {
68
+ const transformed = unicode(child.value.toLowerCase());
69
+ child.value = isLegacy ? transformed.replace(regexLowerCaseUPrefix, 'U') : transformed;
70
+ }
71
+
72
+ return false;
73
+ }).toString();
70
74
  }
71
75
 
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;
76
+ function pluginCreator() {
77
+ return {
78
+ postcssPlugin: 'postcss-normalize-unicode',
79
+
80
+ prepare(result) {
81
+ const cache = {};
82
+ const resultOpts = result.opts || {};
83
+ const browsers = (0, _browserslist.default)(null, {
84
+ stats: resultOpts.stats,
85
+ path: __dirname,
86
+ env: resultOpts.env
87
+ });
88
+ const isLegacy = browsers.some(hasLowerCaseUPrefixBug);
89
+ return {
90
+ OnceExit(css) {
91
+ css.walkDecls(/^unicode-range$/i, decl => {
92
+ const value = decl.value;
93
+
94
+ if (cache[value]) {
95
+ decl.value = cache[value];
96
+ return;
97
+ }
98
+
99
+ const newValue = transform(value, isLegacy);
100
+ decl.value = newValue;
101
+ cache[value] = newValue;
102
+ });
77
103
  }
78
- return false;
79
- }).toString();
104
+
105
+ };
106
+ }
107
+
108
+ };
80
109
  }
81
110
 
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
- };
92
- });
93
- module.exports = exports['default'];
111
+ pluginCreator.postcss = true;
112
+ var _default = pluginCreator;
113
+ exports.default = _default;
114
+ module.exports = exports.default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postcss-normalize-unicode",
3
- "version": "4.0.1",
3
+ "version": "5.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,7 +8,9 @@
8
8
  "LICENSE-MIT"
9
9
  ],
10
10
  "scripts": {
11
- "prepublish": "cross-env BABEL_ENV=publish babel src --out-dir dist --ignore /__tests__/"
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"
12
14
  },
13
15
  "keywords": [
14
16
  "css",
@@ -16,10 +18,6 @@
16
18
  "postcss-plugin"
17
19
  ],
18
20
  "license": "MIT",
19
- "devDependencies": {
20
- "babel-cli": "^6.0.0",
21
- "cross-env": "^5.0.0"
22
- },
23
21
  "homepage": "https://github.com/cssnano/cssnano",
24
22
  "author": {
25
23
  "name": "Ben Briggs",
@@ -28,14 +26,20 @@
28
26
  },
29
27
  "repository": "cssnano/cssnano",
30
28
  "dependencies": {
31
- "browserslist": "^4.0.0",
32
- "postcss": "^7.0.0",
33
- "postcss-value-parser": "^3.0.0"
29
+ "browserslist": "^4.16.0",
30
+ "postcss-value-parser": "^4.1.0"
34
31
  },
35
32
  "bugs": {
36
33
  "url": "https://github.com/cssnano/cssnano/issues"
37
34
  },
38
35
  "engines": {
39
- "node": ">=6.9.0"
40
- }
36
+ "node": "^10 || ^12 || >=14.0"
37
+ },
38
+ "devDependencies": {
39
+ "postcss": "^8.2.1"
40
+ },
41
+ "peerDependencies": {
42
+ "postcss": "^8.2.1"
43
+ },
44
+ "gitHead": "0e2c3bf5835bafcdc8783bef66f730a24194c8f3"
41
45
  }