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

update packages to latest version

This commit is contained in:
s2
2022-08-20 18:51:33 +02:00
parent 09663a35a5
commit 806ebf9a57
4513 changed files with 366205 additions and 92512 deletions

View File

@@ -87,18 +87,25 @@ function restructure(tokens, context) {
var mergeableTokens = [];
for (var i = sourceTokens.length - 1; i >= 0; i--) {
if (!isMergeable(serializeRules(sourceTokens[i][1]), mergeablePseudoClasses, mergeablePseudoElements, multiplePseudoMerging)) {
if (!isMergeable(
serializeRules(sourceTokens[i][1]),
mergeablePseudoClasses,
mergeablePseudoElements,
multiplePseudoMerging
)) {
continue;
}
mergeableTokens.unshift(sourceTokens[i]);
if (sourceTokens[i][2].length > 0 && uniqueTokensWithBody.indexOf(sourceTokens[i]) == -1)
if (sourceTokens[i][2].length > 0
&& uniqueTokensWithBody.indexOf(sourceTokens[i]) == -1) {
uniqueTokensWithBody.push(sourceTokens[i]);
}
}
return uniqueTokensWithBody.length > 1 ?
mergeableTokens :
[];
return uniqueTokensWithBody.length > 1
? mergeableTokens
: [];
}
function shortenIfPossible(position, movedProperty) {
@@ -110,15 +117,13 @@ function restructure(tokens, context) {
var qualifiedTokens = [];
var mergeableTokens = tokensToMerge(movableTokens[key]);
if (mergeableTokens.length < 2)
return;
if (mergeableTokens.length < 2) { return; }
var allFits = findAllFits(mergeableTokens, valueSize, 1);
var bestFit = allFits[0];
if (bestFit[1] > 0)
return sendToMultiPropertyMoveCache(position, movedProperty, allFits);
if (bestFit[1] > 0) { return sendToMultiPropertyMoveCache(position, movedProperty, allFits); }
for (var i = bestFit[0].length - 1; i >=0; i--) {
for (var i = bestFit[0].length - 1; i >= 0; i--) {
allSelectors = bestFit[0][i][1].concat(allSelectors);
qualifiedTokens.unshift(bestFit[0][i]);
}
@@ -142,7 +147,9 @@ function restructure(tokens, context) {
for (var i = tokensVariant.length - 1; i >= 0; i--) {
var subVariant = Array.prototype.slice.call(tokensVariant, 0);
subVariant.splice(i, 1);
differenceVariants = differenceVariants.concat(allCombinations(subVariant, propertySize, propertiesCount, level - 1));
differenceVariants = differenceVariants.concat(
allCombinations(subVariant, propertySize, propertiesCount, level - 1)
);
}
}
@@ -152,7 +159,9 @@ function restructure(tokens, context) {
function sizeDifference(tokensVariant, propertySize, propertiesCount) {
var allSelectorsSize = 0;
for (var i = tokensVariant.length - 1; i >= 0; i--) {
allSelectorsSize += tokensVariant[i][2].length > propertiesCount ? serializeRules(tokensVariant[i][1]).length : -1;
allSelectorsSize += tokensVariant[i][2].length > propertiesCount
? serializeRules(tokensVariant[i][1]).length
: -1;
}
return allSelectorsSize - (tokensVariant.length - 1) * propertySize + 1;
}
@@ -194,8 +203,7 @@ function restructure(tokens, context) {
var toMove = movableTokens[key];
if (toMove && toMove.length > 1) {
if (!shortenMultiMovesIfPossible(position, movedProperty))
shortenIfPossible(position, movedProperty);
if (!shortenMultiMovesIfPossible(position, movedProperty)) { shortenIfPossible(position, movedProperty); }
}
}
@@ -206,23 +214,20 @@ function restructure(tokens, context) {
var j, k;
var mergeableTokens = tokensToMerge(movableTokens[key]);
if (mergeableTokens.length < 2)
return;
if (mergeableTokens.length < 2) { return; }
movableLoop:
for (var value in movableTokens) {
var tokensList = movableTokens[value];
for (j = mergeableTokens.length - 1; j >= 0; j--) {
if (tokensList.indexOf(mergeableTokens[j]) == -1)
continue movableLoop;
if (tokensList.indexOf(mergeableTokens[j]) == -1) { continue movableLoop; }
}
candidates.push(value);
}
if (candidates.length < 2)
return false;
if (candidates.length < 2) { return false; }
for (j = candidates.length - 1; j >= 0; j--) {
for (k = movedProperties.length - 1; k >= 0; k--) {
@@ -251,8 +256,7 @@ function restructure(tokens, context) {
var mergeableTokens = propertiesAndMergableTokens[0][1];
var bestFit = findAllFits(mergeableTokens, valueSize, properties.length)[0];
if (bestFit[1] > 0)
return false;
if (bestFit[1] > 0) { return false; }
var allSelectors = [];
var qualifiedTokens = [];
@@ -270,8 +274,7 @@ function restructure(tokens, context) {
delete movableTokens[property[4]];
if (index > -1 && movedToBeDropped.indexOf(index) == -1)
movedToBeDropped.push(index);
if (index > -1 && movedToBeDropped.indexOf(index) == -1) { movedToBeDropped.push(index); }
}
return true;
@@ -280,8 +283,7 @@ function restructure(tokens, context) {
function boundToAnotherPropertyInCurrrentToken(property, movedProperty, token) {
var propertyName = property[0];
var movedPropertyName = movedProperty[0];
if (propertyName != movedPropertyName)
return false;
if (propertyName != movedPropertyName) { return false; }
var key = movedProperty[4];
var toMove = movableTokens[key];
@@ -325,9 +327,12 @@ function restructure(tokens, context) {
for (k = 0; k < movedCount; k++) {
var movedProperty = movedProperties[k];
if (movedToBeDropped.indexOf(k) == -1 && (!canReorderSingle(property, movedProperty, specificityCache) && !boundToAnotherPropertyInCurrrentToken(property, movedProperty, token) ||
movableTokens[movedProperty[4]] && movableTokens[movedProperty[4]].length === mergeLimit)) {
dropPropertiesAt(i + 1, movedProperty, token);
if (movedToBeDropped.indexOf(k) == -1 && (
!canReorderSingle(property, movedProperty, specificityCache)
&& !boundToAnotherPropertyInCurrrentToken(property, movedProperty, token)
|| movableTokens[movedProperty[4]] && movableTokens[movedProperty[4]].length === mergeLimit)
) {
dropPropertiesAt(i + 1, movedProperty);
if (movedToBeDropped.indexOf(k) == -1) {
movedToBeDropped.push(k);
@@ -344,8 +349,7 @@ function restructure(tokens, context) {
}
}
if (!isRule || unmovableInCurrentToken.indexOf(j) > -1)
continue;
if (!isRule || unmovableInCurrentToken.indexOf(j) > -1) { continue; }
var key = property[4];
@@ -377,8 +381,7 @@ function restructure(tokens, context) {
for (; position < tokens.length - 1; position++) {
var isImportRule = tokens[position][0] === Token.AT_RULE && tokens[position][1].indexOf('@import') === 0;
var isComment = tokens[position][0] === Token.COMMENT;
if (!(isImportRule || isComment))
break;
if (!(isImportRule || isComment)) { break; }
}
for (i = 0; i < movedProperties.length; i++) {