1
0
mirror of https://github.com/S2-/minifyfromhtml.git synced 2025-08-03 12:20:04 +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

125
node_modules/clean-css/lib/clean.js generated vendored
View File

@@ -1,8 +1,6 @@
/**
* Clean-css - https://github.com/jakubpawlowicz/clean-css
* Clean-css - https://github.com/clean-css/clean-css
* Released under the terms of MIT license
*
* Copyright (C) 2017 JakubPawlowicz.com
*/
var level0Optimize = require('./optimizer/level-0/optimize');
@@ -50,14 +48,15 @@ var CleanCSS = module.exports = function CleanCSS(options) {
};
};
// for compatibility with optimize-css-assets-webpack-plugin
CleanCSS.process = function (input, opts) {
CleanCSS.process = function(input, opts) {
var cleanCss;
var optsTo = opts.to;
delete opts.to;
cleanCss = new CleanCSS(Object.assign({ returnPromise: true, rebaseTo: optsTo }, opts));
cleanCss = new CleanCSS(Object.assign({
returnPromise: true, rebaseTo: optsTo
}, opts));
return cleanCss.minify(input)
.then(function(output) {
@@ -65,37 +64,34 @@ CleanCSS.process = function (input, opts) {
});
};
CleanCSS.prototype.minify = function (input, maybeSourceMap, maybeCallback) {
CleanCSS.prototype.minify = function(input, maybeSourceMap, maybeCallback) {
var options = this.options;
if (options.returnPromise) {
return new Promise(function (resolve, reject) {
minifyAll(input, options, maybeSourceMap, function (errors, output) {
return errors ?
reject(errors) :
resolve(output);
return new Promise(function(resolve, reject) {
minifyAll(input, options, maybeSourceMap, function(errors, output) {
return errors
? reject(errors)
: resolve(output);
});
});
} else {
return minifyAll(input, options, maybeSourceMap, maybeCallback);
}
return minifyAll(input, options, maybeSourceMap, maybeCallback);
};
function minifyAll(input, options, maybeSourceMap, maybeCallback) {
if (options.batch && Array.isArray(input)) {
return minifyInBatchesFromArray(input, options, maybeSourceMap, maybeCallback);
} else if (options.batch && (typeof input == 'object')) {
} if (options.batch && (typeof input == 'object')) {
return minifyInBatchesFromHash(input, options, maybeSourceMap, maybeCallback);
} else {
return minify(input, options, maybeSourceMap, maybeCallback);
}
return minify(input, options, maybeSourceMap, maybeCallback);
}
function minifyInBatchesFromArray(input, options, maybeSourceMap, maybeCallback) {
var callback = typeof maybeCallback == 'function' ?
maybeCallback :
(typeof maybeSourceMap == 'function' ? maybeSourceMap : null);
var callback = typeof maybeCallback == 'function'
? maybeCallback
: (typeof maybeSourceMap == 'function' ? maybeSourceMap : null);
var errors = [];
var outputAsHash = {};
var inputValue;
@@ -103,7 +99,10 @@ function minifyInBatchesFromArray(input, options, maybeSourceMap, maybeCallback)
function whenHashBatchDone(innerErrors, output) {
outputAsHash = Object.assign(outputAsHash, output);
errors.concat(innerErrors);
if (innerErrors !== null) {
errors = errors.concat(innerErrors);
}
}
for (i = 0, l = input.length; i < l; i++) {
@@ -113,19 +112,19 @@ function minifyInBatchesFromArray(input, options, maybeSourceMap, maybeCallback)
inputValue = input[i];
outputAsHash[inputValue] = minify([inputValue], options);
errors.concat(outputAsHash[inputValue].errors);
errors = errors.concat(outputAsHash[inputValue].errors);
}
}
return callback ?
callback(errors.length > 0 ? errors : null, outputAsHash) :
outputAsHash;
return callback
? callback(errors.length > 0 ? errors : null, outputAsHash)
: outputAsHash;
}
function minifyInBatchesFromHash(input, options, maybeSourceMap, maybeCallback) {
var callback = typeof maybeCallback == 'function' ?
maybeCallback :
(typeof maybeSourceMap == 'function' ? maybeSourceMap : null);
var callback = typeof maybeCallback == 'function'
? maybeCallback
: (typeof maybeSourceMap == 'function' ? maybeSourceMap : null);
var errors = [];
var outputAsHash = {};
var inputKey;
@@ -135,21 +134,21 @@ function minifyInBatchesFromHash(input, options, maybeSourceMap, maybeCallback)
inputValue = input[inputKey];
outputAsHash[inputKey] = minify(inputValue.styles, options, inputValue.sourceMap);
errors.concat(outputAsHash[inputKey].errors);
errors = errors.concat(outputAsHash[inputKey].errors);
}
return callback ?
callback(errors.length > 0 ? errors : null, outputAsHash) :
outputAsHash;
return callback
? callback(errors.length > 0 ? errors : null, outputAsHash)
: outputAsHash;
}
function minify(input, options, maybeSourceMap, maybeCallback) {
var sourceMap = typeof maybeSourceMap != 'function' ?
maybeSourceMap :
null;
var callback = typeof maybeCallback == 'function' ?
maybeCallback :
(typeof maybeSourceMap == 'function' ? maybeSourceMap : null);
var sourceMap = typeof maybeSourceMap != 'function'
? maybeSourceMap
: null;
var callback = typeof maybeCallback == 'function'
? maybeCallback
: (typeof maybeSourceMap == 'function' ? maybeSourceMap : null);
var context = {
stats: {
efficiency: 0,
@@ -158,9 +157,7 @@ function minify(input, options, maybeSourceMap, maybeCallback) {
startedAt: Date.now(),
timeSpent: 0
},
cache: {
specificity: {}
},
cache: { specificity: {} },
errors: [],
inlinedStylesheets: [],
inputSourceMapTracker: inputSourceMapTracker(),
@@ -178,26 +175,25 @@ function minify(input, options, maybeSourceMap, maybeCallback) {
}
if (options.rebase && !options.explicitRebaseTo) {
implicitRebaseToWarning =
'You have set `rebase: true` without giving `rebaseTo` option, which, in this case, defaults to the current working directory. ' +
'You are then warned this can lead to unexpected URL rebasing (aka here be dragons)! ' +
'If you are OK with the clean-css output, then you can get rid of this warning by giving clean-css a `rebaseTo: process.cwd()` option.';
implicitRebaseToWarning = 'You have set `rebase: true` without giving `rebaseTo` option, which, in this case, defaults to the current working directory. '
+ 'You are then warned this can lead to unexpected URL rebasing (aka here be dragons)! '
+ 'If you are OK with the clean-css output, then you can get rid of this warning by giving clean-css a `rebaseTo: process.cwd()` option.';
context.warnings.push(implicitRebaseToWarning);
}
return runner(context.localOnly)(function () {
return readSources(input, context, function (tokens) {
var serialize = context.options.sourceMap ?
serializeStylesAndSourceMap :
serializeStyles;
return runner(context.localOnly)(function() {
return readSources(input, context, function(tokens) {
var serialize = context.options.sourceMap
? serializeStylesAndSourceMap
: serializeStyles;
var optimizedTokens = optimize(tokens, context);
var optimizedStyles = serialize(optimizedTokens, context);
var output = withMetadata(optimizedStyles, context);
return callback ?
callback(context.errors.length > 0 ? context.errors : null, output) :
output;
return callback
? callback(context.errors.length > 0 ? context.errors : null, output)
: output;
});
});
}
@@ -205,21 +201,20 @@ function minify(input, options, maybeSourceMap, maybeCallback) {
function runner(localOnly) {
// to always execute code asynchronously when a callback is given
// more at blog.izs.me/post/59142742143/designing-apis-for-asynchrony
return localOnly ?
function (callback) { return callback(); } :
process.nextTick;
return localOnly
? function(callback) { return callback(); }
: process.nextTick;
}
function optimize(tokens, context) {
var optimized;
var optimized = level0Optimize(tokens, context);
optimized = level0Optimize(tokens, context);
optimized = OptimizationLevel.One in context.options.level ?
level1Optimize(tokens, context) :
tokens;
optimized = OptimizationLevel.Two in context.options.level ?
level2Optimize(tokens, context, true) :
optimized;
optimized = OptimizationLevel.One in context.options.level
? level1Optimize(tokens, context)
: tokens;
optimized = OptimizationLevel.Two in context.options.level
? level2Optimize(tokens, context, true)
: optimized;
return optimized;
}