postcss-normalize-timing-functions
Advanced tools
Comparing version 4.0.2 to 5.0.0-rc.0
@@ -1,93 +0,103 @@ | ||
'use strict'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _postcss = require('postcss'); | ||
var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser")); | ||
var _postcssValueParser = require('postcss-value-parser'); | ||
var _cssnanoUtils = require("cssnano-utils"); | ||
var _postcssValueParser2 = _interopRequireDefault(_postcssValueParser); | ||
var _cssnanoUtilGetMatch = require('cssnano-util-get-match'); | ||
var _cssnanoUtilGetMatch2 = _interopRequireDefault(_cssnanoUtilGetMatch); | ||
var _map = require('./lib/map'); | ||
var _map2 = _interopRequireDefault(_map); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
const getMatch = (0, _cssnanoUtilGetMatch2.default)(_map2.default); | ||
const getValue = node => parseFloat(node.value); | ||
function evenValues(list, index) { | ||
return index % 2 === 0; | ||
} | ||
function reduce(node) { | ||
if (node.type !== 'function') { | ||
return false; | ||
} | ||
if (node.type !== 'function') { | ||
return false; | ||
} | ||
const lowerCasedValue = node.value.toLowerCase(); | ||
if (!node.value) { | ||
return; | ||
} | ||
if (lowerCasedValue === 'steps') { | ||
// Don't bother checking the step-end case as it has the same length | ||
// as steps(1) | ||
if (getValue(node.nodes[0]) === 1 && node.nodes[2] && node.nodes[2].value.toLowerCase() === 'start') { | ||
node.type = 'word'; | ||
node.value = 'step-start'; | ||
const lowerCasedValue = node.value.toLowerCase(); | ||
delete node.nodes; | ||
if (lowerCasedValue === 'steps') { | ||
// Don't bother checking the step-end case as it has the same length | ||
// as steps(1) | ||
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')) { | ||
node.type = 'word'; | ||
node.value = 'step-start'; | ||
delete node.nodes; | ||
return; | ||
} | ||
return; | ||
} | ||
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')) { | ||
node.type = 'word'; | ||
node.value = 'step-end'; | ||
delete node.nodes; | ||
return; | ||
} // The end case is actually the browser default, so it isn't required. | ||
// The end case is actually the browser default, so it isn't required. | ||
if (node.nodes[2] && node.nodes[2].value.toLowerCase() === 'end') { | ||
node.nodes = [node.nodes[0]]; | ||
return; | ||
} | ||
return false; | ||
if (node.nodes[2] && node.nodes[2].type === 'word' && (node.nodes[2].value.toLowerCase() === 'end' || node.nodes[2].value.toLowerCase() === 'jump-end')) { | ||
node.nodes = [node.nodes[0]]; | ||
return; | ||
} | ||
if (lowerCasedValue === 'cubic-bezier') { | ||
const match = getMatch(node.nodes.filter(evenValues).map(getValue)); | ||
return false; | ||
} | ||
if (match) { | ||
node.type = 'word'; | ||
node.value = match; | ||
if (lowerCasedValue === 'cubic-bezier') { | ||
const values = node.nodes.filter((list, index) => { | ||
return index % 2 === 0; | ||
}).map(getValue); | ||
delete node.nodes; | ||
if (values.length !== 4) { | ||
return; | ||
} | ||
return; | ||
} | ||
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); | ||
if (match) { | ||
node.type = 'word'; | ||
node.value = match; | ||
delete node.nodes; | ||
return; | ||
} | ||
} | ||
} | ||
exports.default = (0, _postcss.plugin)('postcss-normalize-timing-functions', () => { | ||
return css => { | ||
const cache = {}; | ||
function transform(value) { | ||
return (0, _postcssValueParser.default)(value).walk(reduce).toString(); | ||
} | ||
css.walkDecls(/(animation|transition)(-timing-function|$)/i, decl => { | ||
const value = decl.value; | ||
function pluginCreator() { | ||
return { | ||
postcssPlugin: 'postcss-normalize-timing-functions', | ||
if (cache[value]) { | ||
decl.value = cache[value]; | ||
OnceExit(css) { | ||
const cache = {}; | ||
css.walkDecls(/^(-\w+-)?(animation|transition)(-timing-function)?$/i, decl => { | ||
const value = decl.value; | ||
return; | ||
} | ||
if (cache[value]) { | ||
decl.value = cache[value]; | ||
return; | ||
} | ||
const result = (0, _postcssValueParser2.default)(value).walk(reduce).toString(); | ||
const result = transform(value); | ||
decl.value = result; | ||
cache[value] = result; | ||
}); | ||
} | ||
decl.value = result; | ||
cache[value] = result; | ||
}); | ||
}; | ||
}); | ||
module.exports = exports['default']; | ||
}; | ||
} | ||
pluginCreator.postcss = true; | ||
var _default = pluginCreator; | ||
exports.default = _default; | ||
module.exports = exports.default; |
{ | ||
"name": "postcss-normalize-timing-functions", | ||
"version": "4.0.2", | ||
"version": "5.0.0-rc.0", | ||
"description": "Normalize CSS animation/transition timing functions.", | ||
"main": "dist/index.js", | ||
"scripts": { | ||
"prepublish": "cross-env BABEL_ENV=publish babel src --out-dir dist --ignore /__tests__/" | ||
"prebuild": "del-cli dist", | ||
"build": "cross-env BABEL_ENV=publish babel src --config-file ../../babel.config.js --out-dir dist --ignore \"**/__tests__/\"", | ||
"prepublish": "yarn build" | ||
}, | ||
@@ -15,10 +17,5 @@ "files": [ | ||
"dependencies": { | ||
"cssnano-util-get-match": "^4.0.0", | ||
"postcss": "^7.0.0", | ||
"postcss-value-parser": "^3.0.0" | ||
"cssnano-utils": "^2.0.0-rc.0", | ||
"postcss-value-parser": "^4.1.0" | ||
}, | ||
"devDependencies": { | ||
"babel-cli": "^6.0.0", | ||
"cross-env": "^5.0.0" | ||
}, | ||
"author": { | ||
@@ -35,4 +32,11 @@ "name": "Ben Briggs", | ||
"engines": { | ||
"node": ">=6.9.0" | ||
} | ||
"node": "^10 || ^12 || >=14.0" | ||
}, | ||
"devDependencies": { | ||
"postcss": "^8.2.1" | ||
}, | ||
"peerDependencies": { | ||
"postcss": "^8.2.1" | ||
}, | ||
"gitHead": "8c16e67a4d24a13ac7e09a36d4faf504196efd0f" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7745
1
78
1
1
+ Addedcssnano-utils@^2.0.0-rc.0
+ Addedcssnano-utils@2.0.1(transitive)
+ Addednanoid@3.3.8(transitive)
+ Addedpicocolors@1.1.1(transitive)
+ Addedpostcss@8.4.49(transitive)
+ Addedpostcss-value-parser@4.2.0(transitive)
+ Addedsource-map-js@1.2.1(transitive)
- Removedcssnano-util-get-match@^4.0.0
- Removedpostcss@^7.0.0
- Removedcssnano-util-get-match@4.0.0(transitive)
- Removedpicocolors@0.2.1(transitive)
- Removedpostcss@7.0.39(transitive)
- Removedpostcss-value-parser@3.3.1(transitive)
- Removedsource-map@0.6.1(transitive)
Updatedpostcss-value-parser@^4.1.0