postcss-normalize-timing-functions 4.0.2 → 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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,75 @@
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](https://github.com/cssnano/cssnano/compare/postcss-normalize-timing-functions@5.0.0-rc.2...postcss-normalize-timing-functions@5.0.0) (2021-04-06)
7
+
8
+ **Note:** Version bump only for package postcss-normalize-timing-functions
9
+
10
+
11
+
12
+
13
+
14
+ # [5.0.0-rc.2](https://github.com/cssnano/cssnano/compare/postcss-normalize-timing-functions@5.0.0-rc.1...postcss-normalize-timing-functions@5.0.0-rc.2) (2021-03-15)
15
+
16
+ **Note:** Version bump only for package postcss-normalize-timing-functions
17
+
18
+
19
+
20
+
21
+
22
+ # [5.0.0-rc.1](https://github.com/cssnano/cssnano/compare/postcss-normalize-timing-functions@5.0.0-rc.0...postcss-normalize-timing-functions@5.0.0-rc.1) (2021-03-04)
23
+
24
+ **Note:** Version bump only for package postcss-normalize-timing-functions
25
+
26
+
27
+
28
+
29
+
30
+ # 5.0.0-rc.0 (2021-02-19)
31
+
32
+
33
+ ### Bug Fixes
34
+
35
+ * **postcss-normalize-timing-functions:** do not break invalid syntax ([#748](https://github.com/cssnano/cssnano/issues/748)) ([efd2077](https://github.com/cssnano/cssnano/commit/efd20775be85f9845cb343c69b5dc1bb25672a42))
36
+
37
+
38
+ ### chore
39
+
40
+ * minimum require version of node is 10.13 ([#871](https://github.com/cssnano/cssnano/issues/871)) ([28bda24](https://github.com/cssnano/cssnano/commit/28bda243e32ce3ba89b3c358a5f78727b3732f11))
41
+
42
+
43
+ ### Features
44
+
45
+ * migarete to PostCSS 8 ([#975](https://github.com/cssnano/cssnano/issues/975)) ([40b82dc](https://github.com/cssnano/cssnano/commit/40b82dca7f53ac02cd4fe62846dec79b898ccb49))
46
+
47
+
48
+ ### BREAKING CHANGES
49
+
50
+ * minimum supported `postcss` version is `8.2.1`
51
+ * minimum require version of node is 10.13
52
+
53
+
54
+
55
+ ## 4.1.9 (2019-02-12)
56
+
57
+
58
+ ### Bug Fixes
59
+
60
+ * **postcss-normalize-timing-functions:** cache ([#693](https://github.com/cssnano/cssnano/issues/693)) ([7e6e481](https://github.com/cssnano/cssnano/commit/7e6e481244964bf77a1085d8db3f516597b264e9))
61
+
62
+
63
+ ### Performance Improvements
64
+
65
+ * **postcss-normalize-timing-functions:** increase perf ([#687](https://github.com/cssnano/cssnano/issues/687)) ([2bef7d1](https://github.com/cssnano/cssnano/commit/2bef7d1f4f9f6dc33d0a4fb120926a85b08403e7))
66
+
67
+
68
+
69
+ ## 4.1.1 (2018-09-24)
70
+
71
+
72
+ ### Bug Fixes
73
+
74
+ * do not lowercased property ([#606](https://github.com/cssnano/cssnano/issues/606)) ([d40c657](https://github.com/cssnano/cssnano/commit/d40c6577f1d942d00aade671f5e7ab422870c517))
75
+ * **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,103 @@
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 _postcss = require('postcss');
8
+ var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
8
9
 
9
- var _postcssValueParser = require('postcss-value-parser');
10
-
11
- var _postcssValueParser2 = _interopRequireDefault(_postcssValueParser);
12
-
13
- var _cssnanoUtilGetMatch = require('cssnano-util-get-match');
14
-
15
- var _cssnanoUtilGetMatch2 = _interopRequireDefault(_cssnanoUtilGetMatch);
16
-
17
- var _map = require('./lib/map');
18
-
19
- var _map2 = _interopRequireDefault(_map);
10
+ var _cssnanoUtils = require("cssnano-utils");
20
11
 
21
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22
13
 
23
- const getMatch = (0, _cssnanoUtilGetMatch2.default)(_map2.default);
24
14
  const getValue = node => parseFloat(node.value);
25
15
 
26
- function evenValues(list, index) {
27
- return index % 2 === 0;
28
- }
29
-
30
16
  function reduce(node) {
31
- if (node.type !== 'function') {
32
- return false;
17
+ if (node.type !== 'function') {
18
+ return false;
19
+ }
20
+
21
+ if (!node.value) {
22
+ return;
23
+ }
24
+
25
+ const lowerCasedValue = node.value.toLowerCase();
26
+
27
+ if (lowerCasedValue === 'steps') {
28
+ // Don't bother checking the step-end case as it has the same length
29
+ // as steps(1)
30
+ if (node.nodes[0].type === 'word' && getValue(node.nodes[0]) === 1 && node.nodes[2] && node.nodes[2].type === 'word' && (node.nodes[2].value.toLowerCase() === 'start' || node.nodes[2].value.toLowerCase() === 'jump-start')) {
31
+ node.type = 'word';
32
+ node.value = 'step-start';
33
+ delete node.nodes;
34
+ return;
33
35
  }
34
36
 
35
- const lowerCasedValue = node.value.toLowerCase();
36
-
37
- if (lowerCasedValue === 'steps') {
38
- // Don't bother checking the step-end case as it has the same length
39
- // as steps(1)
40
- if (getValue(node.nodes[0]) === 1 && node.nodes[2] && node.nodes[2].value.toLowerCase() === 'start') {
41
- node.type = 'word';
42
- node.value = 'step-start';
37
+ if (node.nodes[0].type === 'word' && getValue(node.nodes[0]) === 1 && node.nodes[2] && node.nodes[2].type === 'word' && (node.nodes[2].value.toLowerCase() === 'end' || node.nodes[2].value.toLowerCase() === 'jump-end')) {
38
+ node.type = 'word';
39
+ node.value = 'step-end';
40
+ delete node.nodes;
41
+ return;
42
+ } // The end case is actually the browser default, so it isn't required.
43
43
 
44
- delete node.nodes;
45
44
 
46
- return;
47
- }
45
+ if (node.nodes[2] && node.nodes[2].type === 'word' && (node.nodes[2].value.toLowerCase() === 'end' || node.nodes[2].value.toLowerCase() === 'jump-end')) {
46
+ node.nodes = [node.nodes[0]];
47
+ return;
48
+ }
48
49
 
49
- // The end case is actually the browser default, so it isn't required.
50
- if (node.nodes[2] && node.nodes[2].value.toLowerCase() === 'end') {
51
- node.nodes = [node.nodes[0]];
50
+ return false;
51
+ }
52
52
 
53
- return;
54
- }
53
+ if (lowerCasedValue === 'cubic-bezier') {
54
+ const values = node.nodes.filter((list, index) => {
55
+ return index % 2 === 0;
56
+ }).map(getValue);
55
57
 
56
- return false;
58
+ if (values.length !== 4) {
59
+ return;
57
60
  }
58
61
 
59
- if (lowerCasedValue === 'cubic-bezier') {
60
- const match = getMatch(node.nodes.filter(evenValues).map(getValue));
61
-
62
- if (match) {
63
- node.type = 'word';
64
- node.value = match;
65
-
66
- delete node.nodes;
62
+ const match = (0, _cssnanoUtils.getMatch)([['ease', [0.25, 0.1, 0.25, 1]], ['linear', [0, 0, 1, 1]], ['ease-in', [0.42, 0, 1, 1]], ['ease-out', [0, 0, 0.58, 1]], ['ease-in-out', [0.42, 0, 0.58, 1]]])(values);
67
63
 
68
- return;
69
- }
64
+ if (match) {
65
+ node.type = 'word';
66
+ node.value = match;
67
+ delete node.nodes;
68
+ return;
70
69
  }
70
+ }
71
+ }
72
+
73
+ function transform(value) {
74
+ return (0, _postcssValueParser.default)(value).walk(reduce).toString();
71
75
  }
72
76
 
73
- exports.default = (0, _postcss.plugin)('postcss-normalize-timing-functions', () => {
74
- return css => {
75
- const cache = {};
77
+ function pluginCreator() {
78
+ return {
79
+ postcssPlugin: 'postcss-normalize-timing-functions',
76
80
 
77
- css.walkDecls(/(animation|transition)(-timing-function|$)/i, decl => {
78
- const value = decl.value;
81
+ OnceExit(css) {
82
+ const cache = {};
83
+ css.walkDecls(/^(-\w+-)?(animation|transition)(-timing-function)?$/i, decl => {
84
+ const value = decl.value;
79
85
 
80
- if (cache[value]) {
81
- decl.value = cache[value];
86
+ if (cache[value]) {
87
+ decl.value = cache[value];
88
+ return;
89
+ }
82
90
 
83
- return;
84
- }
91
+ const result = transform(value);
92
+ decl.value = result;
93
+ cache[value] = result;
94
+ });
95
+ }
85
96
 
86
- const result = (0, _postcssValueParser2.default)(value).walk(reduce).toString();
97
+ };
98
+ }
87
99
 
88
- decl.value = result;
89
- cache[value] = result;
90
- });
91
- };
92
- });
93
- module.exports = exports['default'];
100
+ pluginCreator.postcss = true;
101
+ var _default = pluginCreator;
102
+ exports.default = _default;
103
+ module.exports = exports.default;
package/package.json CHANGED
@@ -1,10 +1,12 @@
1
1
  {
2
2
  "name": "postcss-normalize-timing-functions",
3
- "version": "4.0.2",
3
+ "version": "5.0.0",
4
4
  "description": "Normalize CSS animation/transition timing functions.",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
7
- "prepublish": "cross-env BABEL_ENV=publish babel src --out-dir dist --ignore /__tests__/"
7
+ "prebuild": "del-cli dist",
8
+ "build": "cross-env BABEL_ENV=publish babel src --config-file ../../babel.config.js --out-dir dist --ignore \"**/__tests__/\"",
9
+ "prepublish": "yarn build"
8
10
  },
9
11
  "files": [
10
12
  "LICENSE-MIT",
@@ -12,13 +14,8 @@
12
14
  ],
13
15
  "license": "MIT",
14
16
  "dependencies": {
15
- "cssnano-util-get-match": "^4.0.0",
16
- "postcss": "^7.0.0",
17
- "postcss-value-parser": "^3.0.0"
18
- },
19
- "devDependencies": {
20
- "babel-cli": "^6.0.0",
21
- "cross-env": "^5.0.0"
17
+ "cssnano-utils": "^2.0.0",
18
+ "postcss-value-parser": "^4.1.0"
22
19
  },
23
20
  "author": {
24
21
  "name": "Ben Briggs",
@@ -31,6 +28,13 @@
31
28
  },
32
29
  "homepage": "https://github.com/cssnano/cssnano",
33
30
  "engines": {
34
- "node": ">=6.9.0"
35
- }
31
+ "node": "^10 || ^12 || >=14.0"
32
+ },
33
+ "devDependencies": {
34
+ "postcss": "^8.2.1"
35
+ },
36
+ "peerDependencies": {
37
+ "postcss": "^8.2.1"
38
+ },
39
+ "gitHead": "0e2c3bf5835bafcdc8783bef66f730a24194c8f3"
36
40
  }
package/dist/lib/map.js DELETED
@@ -1,7 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = [['ease', [0.25, 0.1, 0.25, 1]], ['linear', [0, 0, 1, 1]], ['ease-in', [0.42, 0, 1, 1]], ['ease-out', [0, 0, 0.58, 1]], ['ease-in-out', [0.42, 0, 0.58, 1]]];
7
- module.exports = exports['default'];