postcss-colormin 4.0.0-rc.0 → 4.0.2

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/README.md CHANGED
@@ -34,7 +34,7 @@ examples for your environment.
34
34
 
35
35
  ## Contributors
36
36
 
37
- See [CONTRIBUTORS.md](https://github.com/ben-eb/cssnano/blob/master/CONTRIBUTORS.md).
37
+ See [CONTRIBUTORS.md](https://github.com/cssnano/cssnano/blob/master/CONTRIBUTORS.md).
38
38
 
39
39
 
40
40
  ## License
package/dist/colours.js CHANGED
@@ -18,26 +18,22 @@ var _toShorthand2 = _interopRequireDefault(_toShorthand);
18
18
 
19
19
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
20
 
21
- var shorter = function shorter(a, b) {
22
- return (a && a.length < b.length ? a : b).toLowerCase();
23
- };
24
-
25
- exports.default = function (colour) {
26
- var legacy = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
21
+ const shorter = (a, b) => (a && a.length < b.length ? a : b).toLowerCase();
27
22
 
23
+ exports.default = (colour, legacy = false) => {
28
24
  try {
29
- var parsed = (0, _color2.default)(colour.toLowerCase());
30
- var alpha = parsed.alpha();
25
+ const parsed = (0, _color2.default)(colour.toLowerCase());
26
+ const alpha = parsed.alpha();
31
27
  if (alpha === 1) {
32
- var toHex = (0, _toShorthand2.default)(parsed.hex().toLowerCase());
28
+ const toHex = (0, _toShorthand2.default)(parsed.hex().toLowerCase());
33
29
  return shorter(_keywords2.default[toHex], toHex);
34
30
  } else {
35
- var rgb = parsed.rgb();
31
+ const rgb = parsed.rgb();
36
32
  if (!legacy && !rgb.color[0] && !rgb.color[1] && !rgb.color[2] && !alpha) {
37
33
  return 'transparent';
38
34
  }
39
- var hsla = parsed.hsl().round().string();
40
- var rgba = rgb.string();
35
+ let hsla = parsed.hsl().string();
36
+ let rgba = rgb.string();
41
37
  return hsla.length < rgba.length ? hsla : rgba;
42
38
  }
43
39
  } catch (e) {
package/dist/index.js CHANGED
@@ -23,8 +23,8 @@ var _colours2 = _interopRequireDefault(_colours);
23
23
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24
24
 
25
25
  function walk(parent, callback) {
26
- parent.nodes.forEach(function (node, index) {
27
- var bubble = callback(node, index, parent);
26
+ parent.nodes.forEach((node, index) => {
27
+ const bubble = callback(node, index, parent);
28
28
  if (node.nodes && bubble !== false) {
29
29
  walk(node, callback);
30
30
  }
@@ -35,19 +35,18 @@ function transform(legacy, decl) {
35
35
  if (/^(composes|font|filter|-webkit-tap-highlight-color)/i.test(decl.prop)) {
36
36
  return;
37
37
  }
38
- var ast = (0, _postcssValueParser2.default)(decl.value);
39
- walk(ast, function (node, index, parent) {
38
+ const ast = (0, _postcssValueParser2.default)(decl.value);
39
+ walk(ast, (node, index, parent) => {
40
40
  if (node.type === 'function') {
41
- if (/^(rgb|hsl)a?$/.test(node.value)) {
42
- var value = node.value;
43
-
41
+ if (/^(rgb|hsl)a?$/i.test(node.value)) {
42
+ const { value } = node;
44
43
  node.value = (0, _colours2.default)((0, _postcssValueParser.stringify)(node), legacy);
45
44
  node.type = 'word';
46
- var next = parent.nodes[index + 1];
47
- if (node.value !== value && next && next.type === 'word') {
45
+ const next = parent.nodes[index + 1];
46
+ if (node.value !== value && next && (next.type === 'word' || next.type === 'function')) {
48
47
  parent.nodes.splice(index + 1, 0, { type: 'space', value: ' ' });
49
48
  }
50
- } else if (node.value === 'calc') {
49
+ } else if (node.value.toLowerCase() === 'calc') {
51
50
  return false;
52
51
  }
53
52
  } else if (node.type === 'word') {
@@ -68,10 +67,10 @@ function hasTransparentBug(browser) {
68
67
  return ~['ie 8', 'ie 9'].indexOf(browser);
69
68
  }
70
69
 
71
- exports.default = _postcss2.default.plugin('postcss-colormin', function () {
72
- return function (css, result) {
73
- var resultOpts = result.opts || {};
74
- var browsers = (0, _browserslist2.default)(null, {
70
+ exports.default = _postcss2.default.plugin('postcss-colormin', () => {
71
+ return (css, result) => {
72
+ const resultOpts = result.opts || {};
73
+ const browsers = (0, _browserslist2.default)(null, {
75
74
  stats: resultOpts.stats,
76
75
  path: __dirname,
77
76
  env: resultOpts.env
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
 
7
- exports.default = function (hex) {
7
+ exports.default = hex => {
8
8
  if (hex[1] === hex[2] && hex[3] === hex[4] && hex[5] === hex[6]) {
9
9
  return '#' + hex[2] + hex[4] + hex[6];
10
10
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postcss-colormin",
3
- "version": "4.0.0-rc.0",
3
+ "version": "4.0.2",
4
4
  "description": "Minify colors in your CSS files with PostCSS.",
5
5
  "main": "dist/index.js",
6
6
  "files": [
@@ -22,28 +22,28 @@
22
22
  "license": "MIT",
23
23
  "devDependencies": {
24
24
  "babel-cli": "^6.0.0",
25
- "cross-env": "^3.0.0",
25
+ "cross-env": "^5.0.0",
26
26
  "css-color-names": "0.0.4",
27
27
  "write-file": "^1.0.0"
28
28
  },
29
- "homepage": "https://github.com/ben-eb/cssnano",
29
+ "homepage": "https://github.com/cssnano/cssnano",
30
30
  "author": {
31
31
  "name": "Ben Briggs",
32
32
  "email": "beneb.info@gmail.com",
33
33
  "url": "http://beneb.info"
34
34
  },
35
- "repository": "ben-eb/cssnano",
35
+ "repository": "cssnano/cssnano",
36
36
  "dependencies": {
37
- "browserslist": "^2.0.0",
38
- "color": "^1.0.0",
37
+ "browserslist": "^4.0.0",
38
+ "color": "^3.0.0",
39
39
  "has": "^1.0.0",
40
- "postcss": "^6.0.0",
40
+ "postcss": "^7.0.0",
41
41
  "postcss-value-parser": "^3.0.0"
42
42
  },
43
43
  "bugs": {
44
- "url": "https://github.com/ben-eb/cssnano/issues"
44
+ "url": "https://github.com/cssnano/cssnano/issues"
45
45
  },
46
46
  "engines": {
47
- "node": ">=4"
47
+ "node": ">=6.9.0"
48
48
  }
49
49
  }