mirror of
https://github.com/S2-/minifyfromhtml.git
synced 2025-08-04 12:40:05 +02:00
update packages to latest version
This commit is contained in:
123
node_modules/clean-css/lib/reader/apply-source-maps.js
generated
vendored
123
node_modules/clean-css/lib/reader/apply-source-maps.js
generated
vendored
@@ -29,9 +29,9 @@ function applySourceMaps(tokens, context, callback) {
|
||||
warnings: context.warnings
|
||||
};
|
||||
|
||||
return context.options.sourceMap && tokens.length > 0 ?
|
||||
doApplySourceMaps(applyContext) :
|
||||
callback(tokens);
|
||||
return context.options.sourceMap && tokens.length > 0
|
||||
? doApplySourceMaps(applyContext)
|
||||
: callback(tokens);
|
||||
}
|
||||
|
||||
function doApplySourceMaps(applyContext) {
|
||||
@@ -76,7 +76,7 @@ function findTokenSource(token) {
|
||||
}
|
||||
|
||||
function fetchAndApplySourceMap(sourceMapComment, source, singleSourceTokens, applyContext) {
|
||||
return extractInputSourceMapFrom(sourceMapComment, applyContext, function (inputSourceMap) {
|
||||
return extractInputSourceMapFrom(sourceMapComment, applyContext, function(inputSourceMap) {
|
||||
if (inputSourceMap) {
|
||||
applyContext.inputSourceMapTracker.track(source, inputSourceMap);
|
||||
applySourceMapRecursively(singleSourceTokens, applyContext.inputSourceMapTracker);
|
||||
@@ -96,8 +96,8 @@ function extractInputSourceMapFrom(sourceMapComment, applyContext, whenSourceMap
|
||||
if (isDataUriResource(uri)) {
|
||||
sourceMap = extractInputSourceMapFromDataUri(uri);
|
||||
return whenSourceMapReady(sourceMap);
|
||||
} else if (isRemoteResource(uri)) {
|
||||
return loadInputSourceMapFromRemoteUri(uri, applyContext, function (sourceMap) {
|
||||
} if (isRemoteResource(uri)) {
|
||||
return loadInputSourceMapFromRemoteUri(uri, applyContext, function(sourceMap) {
|
||||
var parsedMap;
|
||||
|
||||
if (sourceMap) {
|
||||
@@ -108,20 +108,18 @@ function extractInputSourceMapFrom(sourceMapComment, applyContext, whenSourceMap
|
||||
whenSourceMapReady(null);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// at this point `uri` is already rebased, see lib/reader/rebase.js#rebaseSourceMapComment
|
||||
// it is rebased to be consistent with rebasing other URIs
|
||||
// however here we need to resolve it back to read it from disk
|
||||
absoluteUri = path.resolve(applyContext.rebaseTo, uri);
|
||||
sourceMap = loadInputSourceMapFromLocalUri(absoluteUri, applyContext);
|
||||
|
||||
if (sourceMap) {
|
||||
rebasedMap = rebaseLocalMap(sourceMap, absoluteUri, applyContext.rebaseTo);
|
||||
return whenSourceMapReady(rebasedMap);
|
||||
} else {
|
||||
return whenSourceMapReady(null);
|
||||
}
|
||||
}
|
||||
// at this point `uri` is already rebased, see lib/reader/rebase.js#rebaseSourceMapComment
|
||||
// it is rebased to be consistent with rebasing other URIs
|
||||
// however here we need to resolve it back to read it from disk
|
||||
absoluteUri = path.resolve(applyContext.rebaseTo, uri);
|
||||
sourceMap = loadInputSourceMapFromLocalUri(absoluteUri, applyContext);
|
||||
|
||||
if (sourceMap) {
|
||||
rebasedMap = rebaseLocalMap(sourceMap, absoluteUri, applyContext.rebaseTo);
|
||||
return whenSourceMapReady(rebasedMap);
|
||||
}
|
||||
return whenSourceMapReady(null);
|
||||
}
|
||||
|
||||
function extractInputSourceMapFromDataUri(uri) {
|
||||
@@ -143,15 +141,15 @@ function loadInputSourceMapFromRemoteUri(uri, applyContext, whenLoaded) {
|
||||
if (applyContext.localOnly) {
|
||||
applyContext.warnings.push('Cannot fetch remote resource from "' + uri + '" as no callback given.');
|
||||
return whenLoaded(null);
|
||||
} else if (isRuntimeResource) {
|
||||
} if (isRuntimeResource) {
|
||||
applyContext.warnings.push('Cannot fetch "' + uri + '" as no protocol given.');
|
||||
return whenLoaded(null);
|
||||
} else if (!isAllowed) {
|
||||
} if (!isAllowed) {
|
||||
applyContext.warnings.push('Cannot fetch "' + uri + '" as resource is not allowed.');
|
||||
return whenLoaded(null);
|
||||
}
|
||||
|
||||
applyContext.fetch(uri, applyContext.inlineRequest, applyContext.inlineTimeout, function (error, body) {
|
||||
applyContext.fetch(uri, applyContext.inlineRequest, applyContext.inlineTimeout, function(error, body) {
|
||||
if (error) {
|
||||
applyContext.warnings.push('Missing source map at "' + uri + '" - ' + error);
|
||||
return whenLoaded(null);
|
||||
@@ -168,9 +166,12 @@ function loadInputSourceMapFromLocalUri(uri, applyContext) {
|
||||
if (!fs.existsSync(uri) || !fs.statSync(uri).isFile()) {
|
||||
applyContext.warnings.push('Ignoring local source map at "' + uri + '" as resource is missing.');
|
||||
return null;
|
||||
} else if (!isAllowed) {
|
||||
} if (!isAllowed) {
|
||||
applyContext.warnings.push('Cannot fetch "' + uri + '" as resource is not allowed.');
|
||||
return null;
|
||||
} if (!fs.statSync(uri).size) {
|
||||
applyContext.warnings.push('Cannot fetch "' + uri + '" as resource is empty.');
|
||||
return null;
|
||||
}
|
||||
|
||||
sourceMap = fs.readFileSync(uri, 'utf-8');
|
||||
@@ -185,44 +186,44 @@ function applySourceMapRecursively(tokens, inputSourceMapTracker) {
|
||||
token = tokens[i];
|
||||
|
||||
switch (token[0]) {
|
||||
case Token.AT_RULE:
|
||||
applySourceMapTo(token, inputSourceMapTracker);
|
||||
break;
|
||||
case Token.AT_RULE_BLOCK:
|
||||
applySourceMapRecursively(token[1], inputSourceMapTracker);
|
||||
applySourceMapRecursively(token[2], inputSourceMapTracker);
|
||||
break;
|
||||
case Token.AT_RULE_BLOCK_SCOPE:
|
||||
applySourceMapTo(token, inputSourceMapTracker);
|
||||
break;
|
||||
case Token.NESTED_BLOCK:
|
||||
applySourceMapRecursively(token[1], inputSourceMapTracker);
|
||||
applySourceMapRecursively(token[2], inputSourceMapTracker);
|
||||
break;
|
||||
case Token.NESTED_BLOCK_SCOPE:
|
||||
applySourceMapTo(token, inputSourceMapTracker);
|
||||
break;
|
||||
case Token.COMMENT:
|
||||
applySourceMapTo(token, inputSourceMapTracker);
|
||||
break;
|
||||
case Token.PROPERTY:
|
||||
applySourceMapRecursively(token, inputSourceMapTracker);
|
||||
break;
|
||||
case Token.PROPERTY_BLOCK:
|
||||
applySourceMapRecursively(token[1], inputSourceMapTracker);
|
||||
break;
|
||||
case Token.PROPERTY_NAME:
|
||||
applySourceMapTo(token, inputSourceMapTracker);
|
||||
break;
|
||||
case Token.PROPERTY_VALUE:
|
||||
applySourceMapTo(token, inputSourceMapTracker);
|
||||
break;
|
||||
case Token.RULE:
|
||||
applySourceMapRecursively(token[1], inputSourceMapTracker);
|
||||
applySourceMapRecursively(token[2], inputSourceMapTracker);
|
||||
break;
|
||||
case Token.RULE_SCOPE:
|
||||
applySourceMapTo(token, inputSourceMapTracker);
|
||||
case Token.AT_RULE:
|
||||
applySourceMapTo(token, inputSourceMapTracker);
|
||||
break;
|
||||
case Token.AT_RULE_BLOCK:
|
||||
applySourceMapRecursively(token[1], inputSourceMapTracker);
|
||||
applySourceMapRecursively(token[2], inputSourceMapTracker);
|
||||
break;
|
||||
case Token.AT_RULE_BLOCK_SCOPE:
|
||||
applySourceMapTo(token, inputSourceMapTracker);
|
||||
break;
|
||||
case Token.NESTED_BLOCK:
|
||||
applySourceMapRecursively(token[1], inputSourceMapTracker);
|
||||
applySourceMapRecursively(token[2], inputSourceMapTracker);
|
||||
break;
|
||||
case Token.NESTED_BLOCK_SCOPE:
|
||||
applySourceMapTo(token, inputSourceMapTracker);
|
||||
break;
|
||||
case Token.COMMENT:
|
||||
applySourceMapTo(token, inputSourceMapTracker);
|
||||
break;
|
||||
case Token.PROPERTY:
|
||||
applySourceMapRecursively(token, inputSourceMapTracker);
|
||||
break;
|
||||
case Token.PROPERTY_BLOCK:
|
||||
applySourceMapRecursively(token[1], inputSourceMapTracker);
|
||||
break;
|
||||
case Token.PROPERTY_NAME:
|
||||
applySourceMapTo(token, inputSourceMapTracker);
|
||||
break;
|
||||
case Token.PROPERTY_VALUE:
|
||||
applySourceMapTo(token, inputSourceMapTracker);
|
||||
break;
|
||||
case Token.RULE:
|
||||
applySourceMapRecursively(token[1], inputSourceMapTracker);
|
||||
applySourceMapRecursively(token[2], inputSourceMapTracker);
|
||||
break;
|
||||
case Token.RULE_SCOPE:
|
||||
applySourceMapTo(token, inputSourceMapTracker);
|
||||
}
|
||||
}
|
||||
|
||||
|
8
node_modules/clean-css/lib/reader/extract-import-url-and-media.js
generated
vendored
8
node_modules/clean-css/lib/reader/extract-import-url-and-media.js
generated
vendored
@@ -3,10 +3,10 @@ var split = require('../utils/split');
|
||||
var BRACE_PREFIX = /^\(/;
|
||||
var BRACE_SUFFIX = /\)$/;
|
||||
var IMPORT_PREFIX_PATTERN = /^@import/i;
|
||||
var QUOTE_PREFIX_PATTERN = /['"]\s*/;
|
||||
var QUOTE_SUFFIX_PATTERN = /\s*['"]/;
|
||||
var URL_PREFIX_PATTERN = /^url\(\s*/i;
|
||||
var URL_SUFFIX_PATTERN = /\s*\)/i;
|
||||
var QUOTE_PREFIX_PATTERN = /['"]\s{0,31}/;
|
||||
var QUOTE_SUFFIX_PATTERN = /\s{0,31}['"]/;
|
||||
var URL_PREFIX_PATTERN = /^url\(\s{0,31}/i;
|
||||
var URL_SUFFIX_PATTERN = /\s{0,31}\)/i;
|
||||
|
||||
function extractImportUrlAndMedia(atRuleValue) {
|
||||
var uri;
|
||||
|
6
node_modules/clean-css/lib/reader/input-source-map-tracker.js
generated
vendored
6
node_modules/clean-css/lib/reader/input-source-map-tracker.js
generated
vendored
@@ -42,9 +42,9 @@ function originalPositionFor(maps, metadata, range, selectorFallbacks) {
|
||||
return originalPositionFor(maps, [line - 1, column, source], range, selectorFallbacks - 1);
|
||||
}
|
||||
|
||||
return originalPosition.line !== null ?
|
||||
toMetadata(originalPosition) :
|
||||
metadata;
|
||||
return originalPosition.line !== null
|
||||
? toMetadata(originalPosition)
|
||||
: metadata;
|
||||
}
|
||||
|
||||
function toMetadata(asHash) {
|
||||
|
14
node_modules/clean-css/lib/reader/is-allowed-resource.js
generated
vendored
14
node_modules/clean-css/lib/reader/is-allowed-resource.js
generated
vendored
@@ -9,7 +9,7 @@ var HTTP_PROTOCOL = 'http:';
|
||||
function isAllowedResource(uri, isRemote, rules) {
|
||||
var match;
|
||||
var absoluteUri;
|
||||
var allowed = isRemote ? false : true;
|
||||
var allowed = !isRemote;
|
||||
var rule;
|
||||
var isNegated;
|
||||
var normalizedRule;
|
||||
@@ -23,13 +23,13 @@ function isAllowedResource(uri, isRemote, rules) {
|
||||
uri = HTTP_PROTOCOL + uri;
|
||||
}
|
||||
|
||||
match = isRemote ?
|
||||
url.parse(uri).host :
|
||||
uri;
|
||||
match = isRemote
|
||||
? url.parse(uri).host
|
||||
: uri;
|
||||
|
||||
absoluteUri = isRemote ?
|
||||
uri :
|
||||
path.resolve(uri);
|
||||
absoluteUri = isRemote
|
||||
? uri
|
||||
: path.resolve(uri);
|
||||
|
||||
for (i = 0; i < rules.length; i++) {
|
||||
rule = rules[i];
|
||||
|
25
node_modules/clean-css/lib/reader/load-original-sources.js
generated
vendored
25
node_modules/clean-css/lib/reader/load-original-sources.js
generated
vendored
@@ -21,9 +21,9 @@ function loadOriginalSources(context, callback) {
|
||||
warnings: context.warnings
|
||||
};
|
||||
|
||||
return context.options.sourceMap && context.options.sourceMapInlineSources ?
|
||||
doLoadOriginalSources(loadContext) :
|
||||
callback();
|
||||
return context.options.sourceMap && context.options.sourceMapInlineSources
|
||||
? doLoadOriginalSources(loadContext)
|
||||
: callback();
|
||||
}
|
||||
|
||||
function uriToSourceMapping(allSourceMapConsumers) {
|
||||
@@ -71,17 +71,16 @@ function loadOriginalSource(uri, loadContext) {
|
||||
var content;
|
||||
|
||||
if (isRemoteResource(uri)) {
|
||||
return loadOriginalSourceFromRemoteUri(uri, loadContext, function (content) {
|
||||
return loadOriginalSourceFromRemoteUri(uri, loadContext, function(content) {
|
||||
loadContext.index++;
|
||||
loadContext.sourcesContent[uri] = content;
|
||||
return doLoadOriginalSources(loadContext);
|
||||
});
|
||||
} else {
|
||||
content = loadOriginalSourceFromLocalUri(uri, loadContext);
|
||||
loadContext.index++;
|
||||
loadContext.sourcesContent[uri] = content;
|
||||
return doLoadOriginalSources(loadContext);
|
||||
}
|
||||
content = loadOriginalSourceFromLocalUri(uri, loadContext);
|
||||
loadContext.index++;
|
||||
loadContext.sourcesContent[uri] = content;
|
||||
return doLoadOriginalSources(loadContext);
|
||||
}
|
||||
|
||||
function loadOriginalSourceFromRemoteUri(uri, loadContext, whenLoaded) {
|
||||
@@ -91,15 +90,15 @@ function loadOriginalSourceFromRemoteUri(uri, loadContext, whenLoaded) {
|
||||
if (loadContext.localOnly) {
|
||||
loadContext.warnings.push('Cannot fetch remote resource from "' + uri + '" as no callback given.');
|
||||
return whenLoaded(null);
|
||||
} else if (isRuntimeResource) {
|
||||
} if (isRuntimeResource) {
|
||||
loadContext.warnings.push('Cannot fetch "' + uri + '" as no protocol given.');
|
||||
return whenLoaded(null);
|
||||
} else if (!isAllowed) {
|
||||
} if (!isAllowed) {
|
||||
loadContext.warnings.push('Cannot fetch "' + uri + '" as resource is not allowed.');
|
||||
return whenLoaded(null);
|
||||
}
|
||||
|
||||
loadContext.fetch(uri, loadContext.inlineRequest, loadContext.inlineTimeout, function (error, content) {
|
||||
loadContext.fetch(uri, loadContext.inlineRequest, loadContext.inlineTimeout, function(error, content) {
|
||||
if (error) {
|
||||
loadContext.warnings.push('Missing original source at "' + uri + '" - ' + error);
|
||||
}
|
||||
@@ -115,7 +114,7 @@ function loadOriginalSourceFromLocalUri(relativeUri, loadContext) {
|
||||
if (!fs.existsSync(absoluteUri) || !fs.statSync(absoluteUri).isFile()) {
|
||||
loadContext.warnings.push('Ignoring local source map at "' + absoluteUri + '" as resource is missing.');
|
||||
return null;
|
||||
} else if (!isAllowed) {
|
||||
} if (!isAllowed) {
|
||||
loadContext.warnings.push('Cannot fetch "' + absoluteUri + '" as resource is not allowed.');
|
||||
return null;
|
||||
}
|
||||
|
44
node_modules/clean-css/lib/reader/load-remote-resource.js
generated
vendored
44
node_modules/clean-css/lib/reader/load-remote-resource.js
generated
vendored
@@ -25,11 +25,11 @@ function loadRemoteResource(uri, inlineRequest, inlineTimeout, callback) {
|
||||
requestOptions.path = requestOptions.href;
|
||||
}
|
||||
|
||||
fetch = (proxyProtocol && !isHttpsResource(proxyProtocol)) || isHttpResource(uri) ?
|
||||
http.get :
|
||||
https.get;
|
||||
fetch = (proxyProtocol && !isHttpsResource(proxyProtocol)) || isHttpResource(uri)
|
||||
? http.get
|
||||
: https.get;
|
||||
|
||||
fetch(requestOptions, function (res) {
|
||||
fetch(requestOptions, function(res) {
|
||||
var chunks = [];
|
||||
var movedUri;
|
||||
|
||||
@@ -39,36 +39,36 @@ function loadRemoteResource(uri, inlineRequest, inlineTimeout, callback) {
|
||||
|
||||
if (res.statusCode < 200 || res.statusCode > 399) {
|
||||
return callback(res.statusCode, null);
|
||||
} else if (res.statusCode > 299) {
|
||||
} if (res.statusCode > 299) {
|
||||
movedUri = url.resolve(uri, res.headers.location);
|
||||
return loadRemoteResource(movedUri, inlineRequest, inlineTimeout, callback);
|
||||
}
|
||||
|
||||
res.on('data', function (chunk) {
|
||||
res.on('data', function(chunk) {
|
||||
chunks.push(chunk.toString());
|
||||
});
|
||||
res.on('end', function () {
|
||||
res.on('end', function() {
|
||||
var body = chunks.join('');
|
||||
callback(null, body);
|
||||
});
|
||||
})
|
||||
.on('error', function (res) {
|
||||
if (errorHandled) {
|
||||
return;
|
||||
}
|
||||
.on('error', function(res) {
|
||||
if (errorHandled) {
|
||||
return;
|
||||
}
|
||||
|
||||
errorHandled = true;
|
||||
callback(res.message, null);
|
||||
})
|
||||
.on('timeout', function () {
|
||||
if (errorHandled) {
|
||||
return;
|
||||
}
|
||||
errorHandled = true;
|
||||
callback(res.message, null);
|
||||
})
|
||||
.on('timeout', function() {
|
||||
if (errorHandled) {
|
||||
return;
|
||||
}
|
||||
|
||||
errorHandled = true;
|
||||
callback('timeout', null);
|
||||
})
|
||||
.setTimeout(inlineTimeout);
|
||||
errorHandled = true;
|
||||
callback('timeout', null);
|
||||
})
|
||||
.setTimeout(inlineTimeout);
|
||||
}
|
||||
|
||||
module.exports = loadRemoteResource;
|
||||
|
2
node_modules/clean-css/lib/reader/match-data-uri.js
generated
vendored
2
node_modules/clean-css/lib/reader/match-data-uri.js
generated
vendored
@@ -1,4 +1,4 @@
|
||||
var DATA_URI_PATTERN = /^data:(\S*?)?(;charset=[^;]+)?(;[^,]+?)?,(.+)/;
|
||||
var DATA_URI_PATTERN = /^data:(\S*?)?(;charset=(?:(?!;charset=)[^;])+)?(;[^,]+?)?,(.+)/;
|
||||
|
||||
function matchDataUri(uri) {
|
||||
return DATA_URI_PATTERN.exec(uri);
|
||||
|
103
node_modules/clean-css/lib/reader/read-sources.js
generated
vendored
103
node_modules/clean-css/lib/reader/read-sources.js
generated
vendored
@@ -19,11 +19,12 @@ var isImport = require('../utils/is-import');
|
||||
var isRemoteResource = require('../utils/is-remote-resource');
|
||||
|
||||
var UNKNOWN_URI = 'uri:unknown';
|
||||
var FILE_RESOURCE_PROTOCOL = 'file://';
|
||||
|
||||
function readSources(input, context, callback) {
|
||||
return doReadSources(input, context, function (tokens) {
|
||||
return applySourceMaps(tokens, context, function () {
|
||||
return loadOriginalSources(context, function () { return callback(tokens); });
|
||||
return doReadSources(input, context, function(tokens) {
|
||||
return applySourceMaps(tokens, context, function() {
|
||||
return loadOriginalSources(context, function() { return callback(tokens); });
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -31,11 +32,11 @@ function readSources(input, context, callback) {
|
||||
function doReadSources(input, context, callback) {
|
||||
if (typeof input == 'string') {
|
||||
return fromString(input, context, callback);
|
||||
} else if (Buffer.isBuffer(input)) {
|
||||
} if (Buffer.isBuffer(input)) {
|
||||
return fromString(input.toString(), context, callback);
|
||||
} else if (Array.isArray(input)) {
|
||||
} if (Array.isArray(input)) {
|
||||
return fromArray(input, context, callback);
|
||||
} else if (typeof input == 'object') {
|
||||
} if (typeof input == 'object') {
|
||||
return fromHash(input, context, callback);
|
||||
}
|
||||
}
|
||||
@@ -49,13 +50,11 @@ function fromString(input, context, callback) {
|
||||
}
|
||||
|
||||
function fromArray(input, context, callback) {
|
||||
var inputAsImports = input.reduce(function (accumulator, uriOrHash) {
|
||||
var inputAsImports = input.reduce(function(accumulator, uriOrHash) {
|
||||
if (typeof uriOrHash === 'string') {
|
||||
return addStringSource(uriOrHash, accumulator);
|
||||
} else {
|
||||
return addHashSource(uriOrHash, context, accumulator);
|
||||
}
|
||||
|
||||
return addHashSource(uriOrHash, context, accumulator);
|
||||
}, []);
|
||||
|
||||
return fromStyles(inputAsImports.join(''), context, { inline: ['all'] }, callback);
|
||||
@@ -102,9 +101,9 @@ function normalizeUri(uri) {
|
||||
return uri;
|
||||
}
|
||||
|
||||
absoluteUri = path.isAbsolute(uri) ?
|
||||
uri :
|
||||
path.resolve(uri);
|
||||
absoluteUri = path.isAbsolute(uri)
|
||||
? uri
|
||||
: path.resolve(uri);
|
||||
relativeToCurrentPath = path.relative(currentPath, absoluteUri);
|
||||
normalizedUri = normalizePath(relativeToCurrentPath);
|
||||
|
||||
@@ -112,12 +111,12 @@ function normalizeUri(uri) {
|
||||
}
|
||||
|
||||
function trackSourceMap(sourceMap, uri, context) {
|
||||
var parsedMap = typeof sourceMap == 'string' ?
|
||||
JSON.parse(sourceMap) :
|
||||
sourceMap;
|
||||
var rebasedMap = isRemoteResource(uri) ?
|
||||
rebaseRemoteMap(parsedMap, uri) :
|
||||
rebaseLocalMap(parsedMap, uri || UNKNOWN_URI, context.options.rebaseTo);
|
||||
var parsedMap = typeof sourceMap == 'string'
|
||||
? JSON.parse(sourceMap)
|
||||
: sourceMap;
|
||||
var rebasedMap = isRemoteResource(uri)
|
||||
? rebaseRemoteMap(parsedMap, uri)
|
||||
: rebaseLocalMap(parsedMap, uri || UNKNOWN_URI, context.options.rebaseTo);
|
||||
|
||||
context.inputSourceMapTracker.track(uri, rebasedMap);
|
||||
}
|
||||
@@ -147,9 +146,9 @@ function fromStyles(styles, context, parentInlinerContext, callback) {
|
||||
tokens = tokenize(styles, context);
|
||||
tokens = rebase(tokens, context.options.rebase, context.validator, rebaseConfig);
|
||||
|
||||
return allowsAnyImports(parentInlinerContext.inline) ?
|
||||
inline(tokens, context, parentInlinerContext, callback) :
|
||||
callback(tokens);
|
||||
return allowsAnyImports(parentInlinerContext.inline)
|
||||
? inline(tokens, context, parentInlinerContext, callback)
|
||||
: callback(tokens);
|
||||
}
|
||||
|
||||
function allowsAnyImports(inline) {
|
||||
@@ -188,7 +187,7 @@ function doInlineImports(inlinerContext) {
|
||||
if (token[0] == Token.AT_RULE && isImport(token[1])) {
|
||||
inlinerContext.sourceTokens.splice(0, i);
|
||||
return inlineStylesheet(token, inlinerContext);
|
||||
} else if (token[0] == Token.AT_RULE || token[0] == Token.COMMENT) {
|
||||
} if (token[0] == Token.AT_RULE || token[0] == Token.COMMENT) {
|
||||
inlinerContext.outputTokens.push(token);
|
||||
} else {
|
||||
inlinerContext.outputTokens.push(token);
|
||||
@@ -206,9 +205,9 @@ function inlineStylesheet(token, inlinerContext) {
|
||||
var mediaQuery = uriAndMediaQuery[1];
|
||||
var metadata = token[2];
|
||||
|
||||
return isRemoteResource(uri) ?
|
||||
inlineRemoteStylesheet(uri, mediaQuery, metadata, inlinerContext) :
|
||||
inlineLocalStylesheet(uri, mediaQuery, metadata, inlinerContext);
|
||||
return isRemoteResource(uri)
|
||||
? inlineRemoteStylesheet(uri, mediaQuery, metadata, inlinerContext)
|
||||
: inlineLocalStylesheet(uri, mediaQuery, metadata, inlinerContext);
|
||||
}
|
||||
|
||||
function inlineRemoteStylesheet(uri, mediaQuery, metadata, inlinerContext) {
|
||||
@@ -221,25 +220,25 @@ function inlineRemoteStylesheet(uri, mediaQuery, metadata, inlinerContext) {
|
||||
inlinerContext.warnings.push('Ignoring remote @import of "' + uri + '" as it has already been imported.');
|
||||
inlinerContext.sourceTokens = inlinerContext.sourceTokens.slice(1);
|
||||
return doInlineImports(inlinerContext);
|
||||
} else if (inlinerContext.localOnly && inlinerContext.afterContent) {
|
||||
} if (inlinerContext.localOnly && inlinerContext.afterContent) {
|
||||
inlinerContext.warnings.push('Ignoring remote @import of "' + uri + '" as no callback given and after other content.');
|
||||
inlinerContext.sourceTokens = inlinerContext.sourceTokens.slice(1);
|
||||
return doInlineImports(inlinerContext);
|
||||
} else if (isRuntimeResource) {
|
||||
} if (isRuntimeResource) {
|
||||
inlinerContext.warnings.push('Skipping remote @import of "' + uri + '" as no protocol given.');
|
||||
inlinerContext.outputTokens = inlinerContext.outputTokens.concat(inlinerContext.sourceTokens.slice(0, 1));
|
||||
inlinerContext.sourceTokens = inlinerContext.sourceTokens.slice(1);
|
||||
return doInlineImports(inlinerContext);
|
||||
} else if (inlinerContext.localOnly && !isLoaded) {
|
||||
} if (inlinerContext.localOnly && !isLoaded) {
|
||||
inlinerContext.warnings.push('Skipping remote @import of "' + uri + '" as no callback given.');
|
||||
inlinerContext.outputTokens = inlinerContext.outputTokens.concat(inlinerContext.sourceTokens.slice(0, 1));
|
||||
inlinerContext.sourceTokens = inlinerContext.sourceTokens.slice(1);
|
||||
return doInlineImports(inlinerContext);
|
||||
} else if (!isAllowed && inlinerContext.afterContent) {
|
||||
} if (!isAllowed && inlinerContext.afterContent) {
|
||||
inlinerContext.warnings.push('Ignoring remote @import of "' + uri + '" as resource is not allowed and after other content.');
|
||||
inlinerContext.sourceTokens = inlinerContext.sourceTokens.slice(1);
|
||||
return doInlineImports(inlinerContext);
|
||||
} else if (!isAllowed) {
|
||||
} if (!isAllowed) {
|
||||
inlinerContext.warnings.push('Skipping remote @import of "' + uri + '" as resource is not allowed.');
|
||||
inlinerContext.outputTokens = inlinerContext.outputTokens.concat(inlinerContext.sourceTokens.slice(0, 1));
|
||||
inlinerContext.sourceTokens = inlinerContext.sourceTokens.slice(1);
|
||||
@@ -252,7 +251,7 @@ function inlineRemoteStylesheet(uri, mediaQuery, metadata, inlinerContext) {
|
||||
if (error) {
|
||||
inlinerContext.errors.push('Broken @import declaration of "' + uri + '" - ' + error);
|
||||
|
||||
return process.nextTick(function () {
|
||||
return process.nextTick(function() {
|
||||
inlinerContext.outputTokens = inlinerContext.outputTokens.concat(inlinerContext.sourceTokens.slice(0, 1));
|
||||
inlinerContext.sourceTokens = inlinerContext.sourceTokens.slice(1);
|
||||
doInlineImports(inlinerContext);
|
||||
@@ -266,7 +265,7 @@ function inlineRemoteStylesheet(uri, mediaQuery, metadata, inlinerContext) {
|
||||
inlinerContext.externalContext.sourcesContent[uri] = importedStyles;
|
||||
inlinerContext.externalContext.stats.originalSize += importedStyles.length;
|
||||
|
||||
return fromStyles(importedStyles, inlinerContext.externalContext, inlinerContext, function (importedTokens) {
|
||||
return fromStyles(importedStyles, inlinerContext.externalContext, inlinerContext, function(importedTokens) {
|
||||
importedTokens = wrapInMedia(importedTokens, mediaQuery, metadata);
|
||||
|
||||
inlinerContext.outputTokens = inlinerContext.outputTokens.concat(importedTokens);
|
||||
@@ -276,37 +275,38 @@ function inlineRemoteStylesheet(uri, mediaQuery, metadata, inlinerContext) {
|
||||
});
|
||||
}
|
||||
|
||||
return isLoaded ?
|
||||
whenLoaded(null, inlinerContext.externalContext.sourcesContent[uri]) :
|
||||
inlinerContext.fetch(uri, inlinerContext.inlineRequest, inlinerContext.inlineTimeout, whenLoaded);
|
||||
return isLoaded
|
||||
? whenLoaded(null, inlinerContext.externalContext.sourcesContent[uri])
|
||||
: inlinerContext.fetch(uri, inlinerContext.inlineRequest, inlinerContext.inlineTimeout, whenLoaded);
|
||||
}
|
||||
|
||||
function inlineLocalStylesheet(uri, mediaQuery, metadata, inlinerContext) {
|
||||
var protocolLessUri = uri.replace(FILE_RESOURCE_PROTOCOL, '');
|
||||
var currentPath = path.resolve('');
|
||||
var absoluteUri = path.isAbsolute(uri) ?
|
||||
path.resolve(currentPath, uri[0] == '/' ? uri.substring(1) : uri) :
|
||||
path.resolve(inlinerContext.rebaseTo, uri);
|
||||
var absoluteUri = path.isAbsolute(protocolLessUri)
|
||||
? path.resolve(currentPath, protocolLessUri[0] == '/' ? protocolLessUri.substring(1) : protocolLessUri)
|
||||
: path.resolve(inlinerContext.rebaseTo, protocolLessUri);
|
||||
var relativeToCurrentPath = path.relative(currentPath, absoluteUri);
|
||||
var importedStyles;
|
||||
var isAllowed = isAllowedResource(uri, false, inlinerContext.inline);
|
||||
var isAllowed = isAllowedResource(protocolLessUri, false, inlinerContext.inline);
|
||||
var normalizedPath = normalizePath(relativeToCurrentPath);
|
||||
var isLoaded = normalizedPath in inlinerContext.externalContext.sourcesContent;
|
||||
|
||||
if (inlinerContext.inlinedStylesheets.indexOf(absoluteUri) > -1) {
|
||||
inlinerContext.warnings.push('Ignoring local @import of "' + uri + '" as it has already been imported.');
|
||||
} else if (!isLoaded && (!fs.existsSync(absoluteUri) || !fs.statSync(absoluteUri).isFile())) {
|
||||
inlinerContext.errors.push('Ignoring local @import of "' + uri + '" as resource is missing.');
|
||||
inlinerContext.warnings.push('Ignoring local @import of "' + protocolLessUri + '" as it has already been imported.');
|
||||
} else if (isAllowed && !isLoaded && (!fs.existsSync(absoluteUri) || !fs.statSync(absoluteUri).isFile())) {
|
||||
inlinerContext.errors.push('Ignoring local @import of "' + protocolLessUri + '" as resource is missing.');
|
||||
} else if (!isAllowed && inlinerContext.afterContent) {
|
||||
inlinerContext.warnings.push('Ignoring local @import of "' + uri + '" as resource is not allowed and after other content.');
|
||||
inlinerContext.warnings.push('Ignoring local @import of "' + protocolLessUri + '" as resource is not allowed and after other content.');
|
||||
} else if (inlinerContext.afterContent) {
|
||||
inlinerContext.warnings.push('Ignoring local @import of "' + uri + '" as after other content.');
|
||||
inlinerContext.warnings.push('Ignoring local @import of "' + protocolLessUri + '" as after other content.');
|
||||
} else if (!isAllowed) {
|
||||
inlinerContext.warnings.push('Skipping local @import of "' + uri + '" as resource is not allowed.');
|
||||
inlinerContext.warnings.push('Skipping local @import of "' + protocolLessUri + '" as resource is not allowed.');
|
||||
inlinerContext.outputTokens = inlinerContext.outputTokens.concat(inlinerContext.sourceTokens.slice(0, 1));
|
||||
} else {
|
||||
importedStyles = isLoaded ?
|
||||
inlinerContext.externalContext.sourcesContent[normalizedPath] :
|
||||
fs.readFileSync(absoluteUri, 'utf-8');
|
||||
importedStyles = isLoaded
|
||||
? inlinerContext.externalContext.sourcesContent[normalizedPath]
|
||||
: fs.readFileSync(absoluteUri, 'utf-8');
|
||||
|
||||
inlinerContext.inlinedStylesheets.push(absoluteUri);
|
||||
inlinerContext.inline = inlinerContext.externalContext.options.inline;
|
||||
@@ -315,7 +315,7 @@ function inlineLocalStylesheet(uri, mediaQuery, metadata, inlinerContext) {
|
||||
inlinerContext.externalContext.sourcesContent[normalizedPath] = importedStyles;
|
||||
inlinerContext.externalContext.stats.originalSize += importedStyles.length;
|
||||
|
||||
return fromStyles(importedStyles, inlinerContext.externalContext, inlinerContext, function (importedTokens) {
|
||||
return fromStyles(importedStyles, inlinerContext.externalContext, inlinerContext, function(importedTokens) {
|
||||
importedTokens = wrapInMedia(importedTokens, mediaQuery, metadata);
|
||||
|
||||
inlinerContext.outputTokens = inlinerContext.outputTokens.concat(importedTokens);
|
||||
@@ -333,9 +333,8 @@ function inlineLocalStylesheet(uri, mediaQuery, metadata, inlinerContext) {
|
||||
function wrapInMedia(tokens, mediaQuery, metadata) {
|
||||
if (mediaQuery) {
|
||||
return [[Token.NESTED_BLOCK, [[Token.NESTED_BLOCK_SCOPE, '@media ' + mediaQuery, metadata]], tokens]];
|
||||
} else {
|
||||
return tokens;
|
||||
}
|
||||
return tokens;
|
||||
}
|
||||
|
||||
module.exports = readSources;
|
||||
|
42
node_modules/clean-css/lib/reader/rebase.js
generated
vendored
42
node_modules/clean-css/lib/reader/rebase.js
generated
vendored
@@ -8,9 +8,9 @@ var isImport = require('../utils/is-import');
|
||||
var SOURCE_MAP_COMMENT_PATTERN = /^\/\*# sourceMappingURL=(\S+) \*\/$/;
|
||||
|
||||
function rebase(tokens, rebaseAll, validator, rebaseConfig) {
|
||||
return rebaseAll ?
|
||||
rebaseEverything(tokens, validator, rebaseConfig) :
|
||||
rebaseAtRules(tokens, validator, rebaseConfig);
|
||||
return rebaseAll
|
||||
? rebaseEverything(tokens, validator, rebaseConfig)
|
||||
: rebaseAtRules(tokens, validator, rebaseConfig);
|
||||
}
|
||||
|
||||
function rebaseEverything(tokens, validator, rebaseConfig) {
|
||||
@@ -21,21 +21,21 @@ function rebaseEverything(tokens, validator, rebaseConfig) {
|
||||
token = tokens[i];
|
||||
|
||||
switch (token[0]) {
|
||||
case Token.AT_RULE:
|
||||
rebaseAtRule(token, validator, rebaseConfig);
|
||||
break;
|
||||
case Token.AT_RULE_BLOCK:
|
||||
rebaseProperties(token[2], validator, rebaseConfig);
|
||||
break;
|
||||
case Token.COMMENT:
|
||||
rebaseSourceMapComment(token, rebaseConfig);
|
||||
break;
|
||||
case Token.NESTED_BLOCK:
|
||||
rebaseEverything(token[2], validator, rebaseConfig);
|
||||
break;
|
||||
case Token.RULE:
|
||||
rebaseProperties(token[2], validator, rebaseConfig);
|
||||
break;
|
||||
case Token.AT_RULE:
|
||||
rebaseAtRule(token, validator, rebaseConfig);
|
||||
break;
|
||||
case Token.AT_RULE_BLOCK:
|
||||
rebaseProperties(token[2], validator, rebaseConfig);
|
||||
break;
|
||||
case Token.COMMENT:
|
||||
rebaseSourceMapComment(token, rebaseConfig);
|
||||
break;
|
||||
case Token.NESTED_BLOCK:
|
||||
rebaseEverything(token[2], validator, rebaseConfig);
|
||||
break;
|
||||
case Token.RULE:
|
||||
rebaseProperties(token[2], validator, rebaseConfig);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,9 +50,9 @@ function rebaseAtRules(tokens, validator, rebaseConfig) {
|
||||
token = tokens[i];
|
||||
|
||||
switch (token[0]) {
|
||||
case Token.AT_RULE:
|
||||
rebaseAtRule(token, validator, rebaseConfig);
|
||||
break;
|
||||
case Token.AT_RULE:
|
||||
rebaseAtRule(token, validator, rebaseConfig);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
27
node_modules/clean-css/lib/reader/rewrite-url.js
generated
vendored
27
node_modules/clean-css/lib/reader/rewrite-url.js
generated
vendored
@@ -11,7 +11,7 @@ var URL_SUFFIX = ')';
|
||||
var PROTOCOL_LESS_PREFIX_PATTERN = /^[^\w\d]*\/\//;
|
||||
var QUOTE_PREFIX_PATTERN = /^["']/;
|
||||
var QUOTE_SUFFIX_PATTERN = /["']$/;
|
||||
var ROUND_BRACKETS_PATTERN = /[\(\)]/;
|
||||
var ROUND_BRACKETS_PATTERN = /[()]/;
|
||||
var URL_PREFIX_PATTERN = /^url\(/i;
|
||||
var URL_SUFFIX_PATTERN = /\)$/;
|
||||
var WHITESPACE_PATTERN = /\s/;
|
||||
@@ -35,9 +35,9 @@ function rebase(uri, rebaseConfig) {
|
||||
return url.resolve(rebaseConfig.toBase, uri);
|
||||
}
|
||||
|
||||
return rebaseConfig.absolute ?
|
||||
normalize(absolute(uri, rebaseConfig)) :
|
||||
normalize(relative(uri, rebaseConfig));
|
||||
return rebaseConfig.absolute
|
||||
? normalize(absolute(uri, rebaseConfig))
|
||||
: normalize(relative(uri, rebaseConfig));
|
||||
}
|
||||
|
||||
function isAbsolute(uri) {
|
||||
@@ -73,13 +73,12 @@ function normalize(uri) {
|
||||
function quoteFor(unquotedUrl) {
|
||||
if (unquotedUrl.indexOf(SINGLE_QUOTE) > -1) {
|
||||
return DOUBLE_QUOTE;
|
||||
} else if (unquotedUrl.indexOf(DOUBLE_QUOTE) > -1) {
|
||||
} if (unquotedUrl.indexOf(DOUBLE_QUOTE) > -1) {
|
||||
return SINGLE_QUOTE;
|
||||
} else if (hasWhitespace(unquotedUrl) || hasRoundBrackets(unquotedUrl)) {
|
||||
} if (hasWhitespace(unquotedUrl) || hasRoundBrackets(unquotedUrl)) {
|
||||
return SINGLE_QUOTE;
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
function hasWhitespace(url) {
|
||||
@@ -101,13 +100,13 @@ function rewriteUrl(originalUrl, rebaseConfig, pathOnly) {
|
||||
.replace(QUOTE_SUFFIX_PATTERN, '')
|
||||
.trim();
|
||||
|
||||
var quote = strippedUrl[0] == SINGLE_QUOTE || strippedUrl[0] == DOUBLE_QUOTE ?
|
||||
strippedUrl[0] :
|
||||
quoteFor(unquotedUrl);
|
||||
var quote = strippedUrl[0] == SINGLE_QUOTE || strippedUrl[0] == DOUBLE_QUOTE
|
||||
? strippedUrl[0]
|
||||
: quoteFor(unquotedUrl);
|
||||
|
||||
return pathOnly ?
|
||||
rebase(unquotedUrl, rebaseConfig) :
|
||||
URL_PREFIX + quote + rebase(unquotedUrl, rebaseConfig) + quote + URL_SUFFIX;
|
||||
return pathOnly
|
||||
? rebase(unquotedUrl, rebaseConfig)
|
||||
: URL_PREFIX + quote + rebase(unquotedUrl, rebaseConfig) + quote + URL_SUFFIX;
|
||||
}
|
||||
|
||||
module.exports = rewriteUrl;
|
||||
|
Reference in New Issue
Block a user