postcss-normalize-timing-functions 5.0.3 → 5.1.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/package.json +4 -2
- package/src/index.js +19 -6
- package/types/index.d.ts +9 -0
package/package.json
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "postcss-normalize-timing-functions",
|
|
3
|
-
"version": "5.0
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"description": "Normalize CSS animation/transition timing functions.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
|
+
"types": "types/index.d.ts",
|
|
6
7
|
"files": [
|
|
7
8
|
"LICENSE-MIT",
|
|
8
|
-
"src"
|
|
9
|
+
"src",
|
|
10
|
+
"types"
|
|
9
11
|
],
|
|
10
12
|
"license": "MIT",
|
|
11
13
|
"dependencies": {
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
const valueParser = require('postcss-value-parser');
|
|
3
3
|
|
|
4
|
+
/** @type {(node: valueParser.Node) => number} */
|
|
4
5
|
const getValue = (node) => parseFloat(node.value);
|
|
5
6
|
|
|
6
7
|
/* Works because toString() normalizes the formatting,
|
|
@@ -12,6 +13,10 @@ const conversions = new Map([
|
|
|
12
13
|
[[0, 0, 0.58, 1].toString(), 'ease-out'],
|
|
13
14
|
[[0.42, 0, 0.58, 1].toString(), 'ease-in-out'],
|
|
14
15
|
]);
|
|
16
|
+
/**
|
|
17
|
+
* @param {valueParser.Node} node
|
|
18
|
+
* @return {void | false}
|
|
19
|
+
*/
|
|
15
20
|
function reduce(node) {
|
|
16
21
|
if (node.type !== 'function') {
|
|
17
22
|
return false;
|
|
@@ -34,10 +39,10 @@ function reduce(node) {
|
|
|
34
39
|
(node.nodes[2].value.toLowerCase() === 'start' ||
|
|
35
40
|
node.nodes[2].value.toLowerCase() === 'jump-start')
|
|
36
41
|
) {
|
|
37
|
-
node.type = 'word';
|
|
42
|
+
/** @type string */ (node.type) = 'word';
|
|
38
43
|
node.value = 'step-start';
|
|
39
44
|
|
|
40
|
-
delete node.nodes;
|
|
45
|
+
delete (/** @type Partial<valueParser.FunctionNode> */ (node).nodes);
|
|
41
46
|
|
|
42
47
|
return;
|
|
43
48
|
}
|
|
@@ -50,10 +55,10 @@ function reduce(node) {
|
|
|
50
55
|
(node.nodes[2].value.toLowerCase() === 'end' ||
|
|
51
56
|
node.nodes[2].value.toLowerCase() === 'jump-end')
|
|
52
57
|
) {
|
|
53
|
-
node.type = 'word';
|
|
58
|
+
/** @type string */ (node.type) = 'word';
|
|
54
59
|
node.value = 'step-end';
|
|
55
60
|
|
|
56
|
-
delete node.nodes;
|
|
61
|
+
delete (/** @type Partial<valueParser.FunctionNode> */ (node).nodes);
|
|
57
62
|
|
|
58
63
|
return;
|
|
59
64
|
}
|
|
@@ -87,20 +92,28 @@ function reduce(node) {
|
|
|
87
92
|
const match = conversions.get(values.toString());
|
|
88
93
|
|
|
89
94
|
if (match) {
|
|
90
|
-
node.type = 'word';
|
|
95
|
+
/** @type string */ (node.type) = 'word';
|
|
91
96
|
node.value = match;
|
|
92
97
|
|
|
93
|
-
delete node.nodes;
|
|
98
|
+
delete (/** @type Partial<valueParser.FunctionNode> */ (node).nodes);
|
|
94
99
|
|
|
95
100
|
return;
|
|
96
101
|
}
|
|
97
102
|
}
|
|
98
103
|
}
|
|
99
104
|
|
|
105
|
+
/**
|
|
106
|
+
* @param {string} value
|
|
107
|
+
* @return {string}
|
|
108
|
+
*/
|
|
100
109
|
function transform(value) {
|
|
101
110
|
return valueParser(value).walk(reduce).toString();
|
|
102
111
|
}
|
|
103
112
|
|
|
113
|
+
/**
|
|
114
|
+
* @type {import('postcss').PluginCreator<void>}
|
|
115
|
+
* @return {import('postcss').Plugin}
|
|
116
|
+
*/
|
|
104
117
|
function pluginCreator() {
|
|
105
118
|
return {
|
|
106
119
|
postcssPlugin: 'postcss-normalize-timing-functions',
|
package/types/index.d.ts
ADDED