1
0
mirror of https://github.com/S2-/minifyfromhtml.git synced 2025-08-02 20:00:05 +02:00

update minify

This commit is contained in:
s2
2020-02-07 22:55:28 +01:00
parent 439b2733a6
commit 9dc253a6be
77 changed files with 6154 additions and 24560 deletions

13
node_modules/clean-css/History.md generated vendored
View File

@@ -1,3 +1,16 @@
[4.2.3 / 2020-01-28](https://github.com/jakubpawlowicz/clean-css/compare/v4.2.2...v4.2.3)
==================
* Fixed issue [#1106](https://github.com/jakubpawlowicz/clean-css/issues/1106) - regression in handling RGBA/HSLA colors.
[4.2.2 / 2020-01-25](https://github.com/jakubpawlowicz/clean-css/compare/v4.2.1...v4.2.2)
==================
* Fixed error when property block has no value.
* Fixed issue [#1077](https://github.com/jakubpawlowicz/clean-css/issues/1077) - local fonts with color in name.
* Fixed issue [#1082](https://github.com/jakubpawlowicz/clean-css/issues/1082) - correctly convert colors if alpha >= 1.
* Fixed issue [#1085](https://github.com/jakubpawlowicz/clean-css/issues/1085) - prevent unquoting of grid elements.
[4.2.1 / 2018-08-07](https://github.com/jakubpawlowicz/clean-css/compare/v4.2.0...v4.2.1)
==================

View File

@@ -37,8 +37,13 @@ var IMPORT_PREFIX_PATTERN = /^@import/i;
var QUOTED_PATTERN = /^('.*'|".*")$/;
var QUOTED_BUT_SAFE_PATTERN = /^['"][a-zA-Z][a-zA-Z\d\-_]+['"]$/;
var URL_PREFIX_PATTERN = /^url\(/i;
var LOCAL_PREFIX_PATTERN = /^local\(/i;
var VARIABLE_NAME_PATTERN = /^--\S+$/;
function isLocal(value){
return LOCAL_PREFIX_PATTERN.test(value);
}
function isNegative(value) {
return value && value[1][0] == '-' && parseFloat(value[1]) < 0;
}
@@ -89,16 +94,25 @@ function optimizeBorderRadius(property) {
}
}
/**
* @param {string} name
* @param {string} value
* @param {Object} compatibility
* @return {string}
*/
function optimizeColors(name, value, compatibility) {
if (value.indexOf('#') === -1 && value.indexOf('rgb') == -1 && value.indexOf('hsl') == -1) {
if (!value.match(/#|rgb|hsl/gi)) {
return shortenHex(value);
}
value = value
.replace(/rgb\((\-?\d+),(\-?\d+),(\-?\d+)\)/g, function (match, red, green, blue) {
.replace(/(rgb|hsl)a?\((\-?\d+),(\-?\d+\%?),(\-?\d+\%?),(0*[1-9]+[0-9]*(\.?\d*)?)\)/gi, function (match, colorFn, p1, p2, p3, alpha) {
return (parseInt(alpha, 10) >= 1 ? colorFn + '(' + [p1,p2,p3].join(',') + ')' : match);
})
.replace(/rgb\((\-?\d+),(\-?\d+),(\-?\d+)\)/gi, function (match, red, green, blue) {
return shortenRgb(red, green, blue);
})
.replace(/hsl\((-?\d+),(-?\d+)%?,(-?\d+)%?\)/g, function (match, hue, saturation, lightness) {
.replace(/hsl\((-?\d+),(-?\d+)%?,(-?\d+)%?\)/gi, function (match, hue, saturation, lightness) {
return shortenHsl(hue, saturation, lightness);
})
.replace(/(^|[^='"])#([0-9a-f]{6})/gi, function (match, prefix, color, at, inputValue) {
@@ -115,12 +129,13 @@ function optimizeColors(name, value, compatibility) {
.replace(/(^|[^='"])#([0-9a-f]{3})/gi, function (match, prefix, color) {
return prefix + '#' + color.toLowerCase();
})
.replace(/(rgb|rgba|hsl|hsla)\(([^\)]+)\)/g, function (match, colorFunction, colorDef) {
.replace(/(rgb|rgba|hsl|hsla)\(([^\)]+)\)/gi, function (match, colorFunction, colorDef) {
var tokens = colorDef.split(',');
var applies = (colorFunction == 'hsl' && tokens.length == 3) ||
(colorFunction == 'hsla' && tokens.length == 4) ||
(colorFunction == 'rgb' && tokens.length == 3 && colorDef.indexOf('%') > 0) ||
(colorFunction == 'rgba' && tokens.length == 4 && colorDef.indexOf('%') > 0);
var colorFnLowercase = colorFunction && colorFunction.toLowerCase();
var applies = (colorFnLowercase == 'hsl' && tokens.length == 3) ||
(colorFnLowercase == 'hsla' && tokens.length == 4) ||
(colorFnLowercase == 'rgb' && tokens.length === 3 && colorDef.indexOf('%') > 0) ||
(colorFnLowercase == 'rgba' && tokens.length == 4 && colorDef.indexOf('%') > 0);
if (!applies) {
return match;
@@ -336,7 +351,7 @@ function optimizeZeroUnits(name, value) {
}
function removeQuotes(name, value) {
if (name == 'content' || name.indexOf('font-variation-settings') > -1 || name.indexOf('font-feature-settings') > -1 || name.indexOf('grid-') > -1) {
if (name == 'content' || name.indexOf('font-variation-settings') > -1 || name.indexOf('font-feature-settings') > -1 || name == 'grid' || name.indexOf('grid-') > -1) {
return value;
}
@@ -443,7 +458,7 @@ function optimizeBody(rule, properties, context) {
value = !options.compatibility.properties.urlQuotes ?
removeUrlQuotes(value) :
value;
} else if (isQuoted(value)) {
} else if (isQuoted(value) || isLocal(value)) {
value = levelOptions.removeQuotes ?
removeQuotes(name, value) :
value;

View File

@@ -6,11 +6,11 @@ var functionAnyRegexStr = '(' + variableRegexStr + '|' + functionNoVendorRegexSt
var calcRegex = new RegExp('^(\\-moz\\-|\\-webkit\\-)?calc\\([^\\)]+\\)$', 'i');
var decimalRegex = /[0-9]/;
var functionAnyRegex = new RegExp('^' + functionAnyRegexStr + '$', 'i');
var hslColorRegex = /^hsl\(\s{0,31}[\-\.]?\d+\s{0,31},\s{0,31}\.?\d+%\s{0,31},\s{0,31}\.?\d+%\s{0,31}\)|hsla\(\s{0,31}[\-\.]?\d+\s{0,31},\s{0,31}\.?\d+%\s{0,31},\s{0,31}\.?\d+%\s{0,31},\s{0,31}\.?\d+\s{0,31}\)$/;
var hslColorRegex = /^hsl\(\s{0,31}[\-\.]?\d+\s{0,31},\s{0,31}\.?\d+%\s{0,31},\s{0,31}\.?\d+%\s{0,31}\)|hsla\(\s{0,31}[\-\.]?\d+\s{0,31},\s{0,31}\.?\d+%\s{0,31},\s{0,31}\.?\d+%\s{0,31},\s{0,31}\.?\d+\s{0,31}\)$/i;
var identifierRegex = /^(\-[a-z0-9_][a-z0-9\-_]*|[a-z][a-z0-9\-_]*)$/i;
var namedEntityRegex = /^[a-z]+$/i;
var prefixRegex = /^-([a-z0-9]|-)*$/i;
var rgbColorRegex = /^rgb\(\s{0,31}[\d]{1,3}\s{0,31},\s{0,31}[\d]{1,3}\s{0,31},\s{0,31}[\d]{1,3}\s{0,31}\)|rgba\(\s{0,31}[\d]{1,3}\s{0,31},\s{0,31}[\d]{1,3}\s{0,31},\s{0,31}[\d]{1,3}\s{0,31},\s{0,31}[\.\d]+\s{0,31}\)$/;
var rgbColorRegex = /^rgb\(\s{0,31}[\d]{1,3}\s{0,31},\s{0,31}[\d]{1,3}\s{0,31},\s{0,31}[\d]{1,3}\s{0,31}\)|rgba\(\s{0,31}[\d]{1,3}\s{0,31},\s{0,31}[\d]{1,3}\s{0,31},\s{0,31}[\d]{1,3}\s{0,31},\s{0,31}[\.\d]+\s{0,31}\)$/i;
var timingFunctionRegex = /^(cubic\-bezier|steps)\([^\)]+\)$/;
var validTimeUnits = ['ms', 's'];
var urlRegex = /^url\([\s\S]+\)$/i;

View File

@@ -77,7 +77,9 @@ function lastPropertyIndex(tokens) {
function property(context, tokens, position, lastPropertyAt) {
var store = context.store;
var token = tokens[position];
var isPropertyBlock = token[2][0] == Token.PROPERTY_BLOCK;
var propertyValue = token[2];
var isPropertyBlock = propertyValue && propertyValue[0] === Token.PROPERTY_BLOCK;
var needsSemicolon;
if ( context.format ) {
@@ -111,7 +113,9 @@ function property(context, tokens, position, lastPropertyAt) {
case Token.PROPERTY:
store(context, token[1]);
store(context, colon(context));
value(context, token);
if (propertyValue) {
value(context, token);
}
store(context, needsSemicolon ? semicolon(context, Breaks.AfterProperty, isLast) : emptyCharacter);
break;
case Token.RAW:

12
node_modules/clean-css/package.json generated vendored
View File

@@ -1,8 +1,8 @@
{
"_from": "clean-css@^4.1.6",
"_id": "clean-css@4.2.1",
"_id": "clean-css@4.2.3",
"_inBundle": false,
"_integrity": "sha512-4ZxI6dy4lrY6FHzfiy1aEOXgu4LIsW2MhwG0VBKdcoGoH/XLFgaHSdLTGr4O8Be6A8r3MOphEiI8Gc1n0ecf3g==",
"_integrity": "sha512-VcMWDN54ZN/DS+g58HYL5/n4Zrqe8vHJpGA8KdgUXFU4fuP/aHNw8eld9SyEIyabIMJX/0RaY/fplOo5hYLSFA==",
"_location": "/clean-css",
"_phantomChildren": {},
"_requested": {
@@ -19,10 +19,10 @@
"/html-minifier",
"/minify"
],
"_resolved": "https://registry.npmjs.org/clean-css/-/clean-css-4.2.1.tgz",
"_shasum": "2d411ef76b8569b6d0c84068dabe85b0aa5e5c17",
"_resolved": "https://registry.npmjs.org/clean-css/-/clean-css-4.2.3.tgz",
"_shasum": "507b5de7d97b48ee53d84adb0160ff6216380f78",
"_spec": "clean-css@^4.1.6",
"_where": "F:\\projects\\p\\minifyfromhtml\\node_modules\\minify",
"_where": "/home/s2/Code/minifyfromhtml/node_modules/minify",
"author": {
"name": "Jakub Pawlowicz",
"email": "contact@jakubpawlowicz.com",
@@ -74,5 +74,5 @@
"prepublish": "npm run check",
"test": "vows"
},
"version": "4.2.1"
"version": "4.2.3"
}