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

use minify

This commit is contained in:
s2
2019-04-15 10:35:12 +02:00
parent 9528e1e8e1
commit 86e1333c3e
9417 changed files with 70210 additions and 462173 deletions

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

@@ -1,7 +1,25 @@
[4.2.1 / 2018-08-07](https://github.com/jakubpawlowicz/clean-css/compare/v4.2.0...v4.2.1)
==================
* Fixes giving `breakWith` option via a string.
[4.2.0 / 2018-08-02](https://github.com/jakubpawlowicz/clean-css/compare/4.1...4.2.0)
==================
* Adds `process` method for compatibility with optimize-css-assets-webpack-plugin.
* Fixed issue [#861](https://github.com/jakubpawlowicz/clean-css/issues/861) - new `transition` property optimizer.
* Fixed issue [#895](https://github.com/jakubpawlowicz/clean-css/issues/895) - ignoring specific styles.
* Fixed issue [#947](https://github.com/jakubpawlowicz/clean-css/issues/947) - selector based filtering.
* Fixed issue [#964](https://github.com/jakubpawlowicz/clean-css/issues/964) - adds configurable line breaks.
* Fixed issue [#986](https://github.com/jakubpawlowicz/clean-css/issues/986) - level 2 optimizations and CSS 4 colors.
* Fixed issue [#1000](https://github.com/jakubpawlowicz/clean-css/issues/1000) - carriage return handling in tokenizer.
* Fixed issue [#1038](https://github.com/jakubpawlowicz/clean-css/issues/1038) - `font-variation-settings` quoting.
* Fixes ReDOS vulnerabilities in validator code.
[4.1.11 / 2018-03-06](https://github.com/jakubpawlowicz/clean-css/compare/v4.1.10...v4.1.11)
==================
* Fixes ReDOS vulnerabilities in validator code.
* Backports fixes to ReDOS vulnerabilities in validator code.
[4.1.10 / 2018-03-05](https://github.com/jakubpawlowicz/clean-css/compare/v4.1.9...v4.1.10)
==================
@@ -83,6 +101,11 @@
* Fixed issue [#920](https://github.com/jakubpawlowicz/clean-css/issues/920) - allows skipping certain properties in level 2 optimizations.
* Fixed issue [#934](https://github.com/jakubpawlowicz/clean-css/issues/934) - smarter longhand into shorthand merging.
[4.0.13 / 2017-05-10](https://github.com/jakubpawlowicz/clean-css/compare/v4.0.12...v4.0.13)
==================
* Backports [#939](https://github.com/jakubpawlowicz/clean-css/issues/939) - semicolon after `@apply` at rule.
[4.0.12 / 2017-04-12](https://github.com/jakubpawlowicz/clean-css/compare/v4.0.11...v4.0.12)
==================
@@ -205,6 +228,11 @@
* Fixed issue [#857](https://github.com/jakubpawlowicz/clean-css/issues/857) - normalizes CleanCSS API interface.
* Fixed issue [#863](https://github.com/jakubpawlowicz/clean-css/issues/863) - adds `transform` callback for custom optimizations.
[3.4.26 / 2017-05-10](https://github.com/jakubpawlowicz/clean-css/compare/v3.4.25...v3.4.26)
==================
* Backports [#939](https://github.com/jakubpawlowicz/clean-css/issues/939) - semicolon after `@apply` at-rule.
[3.4.25 / 2017-02-22](https://github.com/jakubpawlowicz/clean-css/compare/v3.4.24...v3.4.25)
==================

50
node_modules/clean-css/README.md generated vendored
View File

@@ -9,7 +9,7 @@
[![Linux Build Status](https://img.shields.io/travis/jakubpawlowicz/clean-css/master.svg?style=flat&label=Linux%20build)](https://travis-ci.org/jakubpawlowicz/clean-css)
[![Windows Build status](https://img.shields.io/appveyor/ci/jakubpawlowicz/clean-css/master.svg?style=flat&label=Windows%20build)](https://ci.appveyor.com/project/jakubpawlowicz/clean-css/branch/master)
[![Dependency Status](https://img.shields.io/david/jakubpawlowicz/clean-css.svg?style=flat)](https://david-dm.org/jakubpawlowicz/clean-css)
[![NPM Downloads](https://img.shields.io/npm/dm/clean-css.svg)](https://www.npmjs.com/package/clean-css)
[![NPM Downloads](https://img.shields.io/npm/dm/clean-css.svg)](https://npmcharts.com/compare/clean-css?minimal=true)
[![Twitter](https://img.shields.io/badge/Twitter-@cleancss-blue.svg)](https://twitter.com/cleancss)
clean-css is a fast and efficient CSS optimizer for [Node.js](http://nodejs.org/) platform and [any modern browser](https://jakubpawlowicz.github.io/clean-css).
@@ -23,6 +23,7 @@ According to [tests](http://goalsmashers.github.io/css-minification-benchmark/)
- [Use](#use)
* [Important: 4.0 breaking changes](#important-40-breaking-changes)
* [What's new in version 4.1](#whats-new-in-version-41)
* [What's new in version 4.2](#whats-new-in-version-42)
* [Constructor options](#constructor-options)
* [Compatibility modes](#compatibility-modes)
* [Fetch option](#fetch-option)
@@ -40,6 +41,7 @@ According to [tests](http://goalsmashers.github.io/css-minification-benchmark/)
* [How to process remote `@import`s correctly?](#how-to-process-remote-imports-correctly)
* [How to apply arbitrary transformations to CSS properties?](#how-to-apply-arbitrary-transformations-to-css-properties)
* [How to specify a custom rounding precision?](#how-to-specify-a-custom-rounding-precision)
* [How to keep a CSS fragment intact?](#how-to-keep-a-css-fragment-intact)
* [How to preserve a comment block?](#how-to-preserve-a-comment-block)
* [How to rebase relative image URLs?](#how-to-rebase-relative-image-urls)
* [How to work with source maps?](#how-to-work-with-source-maps)
@@ -59,7 +61,7 @@ clean-css requires Node.js 4.0+ (tested on Linux, OS X, and Windows)
# Install
```
npm install clean-css
npm install --save-dev clean-css
```
# Use
@@ -112,6 +114,16 @@ clean-css 4.1 introduces the following changes / features:
* `removeUnusedAtRules` level 2 optimization controlling removal of unused `@counter-style`, `@font-face`, `@keyframes`, and `@namespace` at rules;
* the [web interface](https://jakubpawlowicz.github.io/clean-css) gets an improved settings panel with "reset to defaults", instant option changes, and settings being persisted across sessions.
## What's new in version 4.2
clean-css 4.2 introduces the following changes / features:
* Adds `process` method for compatibility with optimize-css-assets-webpack-plugin;
* new `transition` property optimizer;
* preserves any CSS content between `/* clean-css ignore:start */` and `/* clean-css ignore:end */` comments;
* allows filtering based on selector in `transform` callback, see [example](#how-to-apply-arbitrary-transformations-to-css-properties);
* adds configurable line breaks via `format: { breakWith: 'lf' }` option.
## Constructor options
clean-css constructor accepts a hash as a parameter with the following options available:
@@ -253,6 +265,7 @@ new CleanCSS({
beforeBlockEnds: false, // controls if a line break comes before a block ends; defaults to `false`
betweenSelectors: false // controls if a line break comes between selectors; defaults to `false`
},
breakWith: '\n', // controls the new line character, can be `'\r\n'` or `'\n'` (aliased as `'windows'` and `'unix'` or `'crlf'` and `'lf'`); defaults to system one, so former on Windows and latter on Unix
indentBy: 0, // controls number of characters to indent with; defaults to `0`
indentWith: 'space', // controls a character to indent with, can be `'space'` or `'tab'`; defaults to `'space'`
spaces: { // controls where to insert spaces
@@ -356,6 +369,7 @@ new CleanCSS({
tidyAtRules: true, // controls at-rules (e.g. `@charset`, `@import`) optimizing; defaults to `true`
tidyBlockScopes: true, // controls block scopes (e.g. `@media`) optimizing; defaults to `true`
tidySelectors: true, // controls selectors optimizing; defaults to `true`,
semicolonAfterLastProperty: false, // controls removing trailing semicolons in rule; defaults to `false` - means remove
transform: function () {} // defines a callback for fine-grained property optimization; defaults to no-op
}
}
@@ -523,7 +537,7 @@ var source = '.block{background-image:url(/path/to/image.png)}';
var output = new CleanCSS({
level: {
1: {
transform: function (propertyName, propertyValue) {
transform: function (propertyName, propertyValue, selector /* `selector` available since 4.2.0-pre */) {
if (propertyName == 'background-image' && propertyValue.indexOf('/path/to') > -1) {
return propertyValue.replace('/path/to', '../valid/path/to');
}
@@ -553,6 +567,36 @@ new CleanCSS({
which sets all units rounding precision to 3 digits except `px` unit precision of 5 digits.
## How to keep a CSS fragment intact?
Note: available in the current master, to be released in 4.2.0.
Wrap the CSS fragment in special comments which instruct clean-css to preserve it, e.g.
```css
.block-1 {
color: red
}
/* clean-css ignore:start */
.block-special {
color: transparent
}
/* clean-css ignore:end */
.block-2 {
margin: 0
}
```
Optimizing this CSS will result in the following output:
```css
.block-1{color:red}
.block-special {
color: transparent
}
.block-2{margin:0}
```
## How to preserve a comment block?
Use the `/*!` notation instead of the standard one `/*`:

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

@@ -46,6 +46,22 @@ var CleanCSS = module.exports = function CleanCSS(options) {
};
};
// for compatibility with optimize-css-assets-webpack-plugin
CleanCSS.process = function (input, opts) {
var cleanCss;
var optsTo = opts.to;
delete opts.to;
cleanCss = new CleanCSS(Object.assign({ returnPromise: true, rebaseTo: optsTo }, opts));
return cleanCss.minify(input)
.then(function(output) {
return { css: output.styles };
});
};
CleanCSS.prototype.minify = function (input, maybeSourceMap, maybeCallback) {
var options = this.options;

View File

@@ -19,6 +19,8 @@ var Marker = require('../../tokenizer/marker');
var formatPosition = require('../../utils/format-position');
var split = require('../../utils/split');
var serializeRules = require('../../writer/one-time').rules;
var IgnoreProperty = 'ignore-property';
var CHARSET_TOKEN = '@charset';
@@ -334,7 +336,7 @@ function optimizeZeroUnits(name, value) {
}
function removeQuotes(name, value) {
if (name == 'content' || 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.indexOf('grid-') > -1) {
return value;
}
@@ -349,8 +351,9 @@ function removeUrlQuotes(value) {
value;
}
function transformValue(propertyName, propertyValue, transformCallback) {
var transformedValue = transformCallback(propertyName, propertyValue);
function transformValue(propertyName, propertyValue, rule, transformCallback) {
var selector = serializeRules(rule);
var transformedValue = transformCallback(propertyName, propertyValue, selector);
if (transformedValue === undefined) {
return propertyValue;
@@ -363,7 +366,7 @@ function transformValue(propertyName, propertyValue, transformCallback) {
//
function optimizeBody(properties, context) {
function optimizeBody(rule, properties, context) {
var options = context.options;
var levelOptions = options.level[OptimizationLevel.One];
var property, name, type, value;
@@ -408,7 +411,7 @@ function optimizeBody(properties, context) {
}
if (property.block) {
optimizeBody(property.value[0][1], context);
optimizeBody(rule, property.value[0][1], context);
continue;
}
@@ -467,7 +470,7 @@ function optimizeBody(properties, context) {
}
}
value = transformValue(name, value, levelOptions.transform);
value = transformValue(name, value, rule, levelOptions.transform);
if (value === IgnoreProperty) {
property.unused = true;
@@ -637,7 +640,7 @@ function level1Optimize(tokens, context) {
mayHaveCharset = true;
break;
case Token.AT_RULE_BLOCK:
optimizeBody(token[2], context);
optimizeBody(token[1], token[2], context);
afterRules = true;
break;
case Token.NESTED_BLOCK:
@@ -651,7 +654,7 @@ function level1Optimize(tokens, context) {
case Token.RULE:
token[1] = levelOptions.tidySelectors ? tidyRules(token[1], !ie7Hack, adjacentSpace, format, context.warnings) : token[1];
token[1] = token[1].length > 1 ? sortSelectors(token[1], levelOptions.selectorsSortingMethod) : token[1];
optimizeBody(token[2], context);
optimizeBody(token[1], token[2], context);
afterRules = true;
break;
}

View File

@@ -68,7 +68,7 @@ function removeWhitespace(value, format) {
character = value[i];
isNewLineNix = character == Marker.NEW_LINE_NIX;
isNewLineWin = character == Marker.NEW_LINE_NIX && value[i - 1] == Marker.NEW_LINE_WIN;
isNewLineWin = character == Marker.NEW_LINE_NIX && value[i - 1] == Marker.CARRIAGE_RETURN;
isQuoted = isSingleQuoted || isDoubleQuoted;
isRelation = !isAttribute && !isEscaped && roundBracketLevel === 0 && RELATION_PATTERN.test(character);
isWhitespace = WHITESPACE_PATTERN.test(character);

View File

@@ -105,7 +105,7 @@ function animation(property, compactable, validator) {
} else if (validator.isTime(value[1]) && !delaySet) {
delay.value = [value];
delaySet = true;
} else if ((validator.isGlobal(value[1]) || validator.isAnimationTimingFunction(value[1])) && !timingSet) {
} else if ((validator.isGlobal(value[1]) || validator.isTimingFunction(value[1])) && !timingSet) {
timing.value = [value];
timingSet = true;
} else if ((validator.isAnimationIterationCountKeyword(value[1]) || validator.isPositiveNumber(value[1])) && !iterationSet) {
@@ -523,6 +523,53 @@ function listStyle(property, compactable, validator) {
return components;
}
function transition(property, compactable, validator) {
var prop = _wrapDefault(property.name + '-property', property, compactable);
var duration = _wrapDefault(property.name + '-duration', property, compactable);
var timing = _wrapDefault(property.name + '-timing-function', property, compactable);
var delay = _wrapDefault(property.name + '-delay', property, compactable);
var components = [prop, duration, timing, delay];
var values = property.value;
var value;
var durationSet = false;
var delaySet = false;
var propSet = false;
var timingSet = false;
var i;
var l;
if (property.value.length == 1 && property.value[0][1] == 'inherit') {
prop.value = duration.value = timing.value = delay.value = property.value;
return components;
}
if (values.length > 1 && _anyIsInherit(values)) {
throw new InvalidPropertyError('Invalid animation values at ' + formatPosition(values[0][2][0]) + '. Ignoring.');
}
for (i = 0, l = values.length; i < l; i++) {
value = values[i];
if (validator.isTime(value[1]) && !durationSet) {
duration.value = [value];
durationSet = true;
} else if (validator.isTime(value[1]) && !delaySet) {
delay.value = [value];
delaySet = true;
} else if ((validator.isGlobal(value[1]) || validator.isTimingFunction(value[1])) && !timingSet) {
timing.value = [value];
timingSet = true;
} else if (validator.isIdentifier(value[1]) && !propSet) {
prop.value = [value];
propSet = true;
} else {
throw new InvalidPropertyError('Invalid animation value at ' + formatPosition(value[2][0]) + '. Ignoring.');
}
}
return components;
}
function widthStyleColor(property, compactable, validator) {
var descriptor = compactable[property.name];
var components = [
@@ -592,5 +639,6 @@ module.exports = {
fourValues: fourValues,
listStyle: listStyle,
multiplex: multiplex,
outline: widthStyleColor
outline: widthStyleColor,
transition: transition
};

View File

@@ -20,16 +20,6 @@ function animationName(validator, value1, value2) {
return validator.isAnimationNameKeyword(value2) || validator.isIdentifier(value2);
}
function animationTimingFunction(validator, value1, value2) {
if (!understandable(validator, value1, value2, 0, true) && !(validator.isAnimationTimingFunction(value2) || validator.isGlobal(value2))) {
return false;
} else if (validator.isVariable(value1) && validator.isVariable(value2)) {
return true;
}
return validator.isAnimationTimingFunction(value2) || validator.isGlobal(value2);
}
function areSameFunction(validator, value1, value2) {
if (!validator.isFunction(value1) || !validator.isFunction(value2)) {
return false;
@@ -129,14 +119,22 @@ function keywordWithGlobal(propertyName) {
};
}
function propertyName(validator, value1, value2) {
if (!understandable(validator, value1, value2, 0, true) && !validator.isIdentifier(value2)) {
return false;
} else if (validator.isVariable(value1) && validator.isVariable(value2)) {
return true;
}
return validator.isIdentifier(value2);
}
function sameFunctionOrValue(validator, value1, value2) {
return areSameFunction(validator, value1, value2) ?
true :
value1 === value2;
}
function textShadow(validator, value1, value2) {
if (!understandable(validator, value1, value2, 0, true) && !(validator.isUnit(value2) || validator.isColor(value2) || validator.isGlobal(value2))) {
return false;
@@ -165,6 +163,16 @@ function time(validator, value1, value2) {
return sameFunctionOrValue(validator, value1, value2);
}
function timingFunction(validator, value1, value2) {
if (!understandable(validator, value1, value2, 0, true) && !(validator.isTimingFunction(value2) || validator.isGlobal(value2))) {
return false;
} else if (validator.isVariable(value1) && validator.isVariable(value2)) {
return true;
}
return validator.isTimingFunction(value2) || validator.isGlobal(value2);
}
function unit(validator, value1, value2) {
if (!understandable(validator, value1, value2, 0, true) && !validator.isUnit(value2)) {
return false;
@@ -224,7 +232,9 @@ module.exports = {
color: color,
components: components,
image: image,
propertyName: propertyName,
time: time,
timingFunction: timingFunction,
unit: unit,
unitOrNumber: unitOrNumber
},
@@ -234,7 +244,6 @@ module.exports = {
animationIterationCount: animationIterationCount,
animationName: animationName,
animationPlayState: keywordWithGlobal('animation-play-state'),
animationTimingFunction: animationTimingFunction,
backgroundAttachment: keyword('background-attachment'),
backgroundClip: keywordWithGlobal('background-clip'),
backgroundOrigin: keyword('background-origin'),

View File

@@ -38,7 +38,7 @@ var compactable = {
'animation': {
canOverride: canOverride.generic.components([
canOverride.generic.time,
canOverride.property.animationTimingFunction,
canOverride.generic.timingFunction,
canOverride.generic.time,
canOverride.property.animationIterationCount,
canOverride.property.animationDirection,
@@ -159,7 +159,7 @@ var compactable = {
]
},
'animation-timing-function': {
canOverride: canOverride.property.animationTimingFunction,
canOverride: canOverride.generic.timingFunction,
componentOf: [
'animation'
],
@@ -918,6 +918,82 @@ var compactable = {
'-webkit-'
]
},
'transition': {
breakUp: breakUp.multiplex(breakUp.transition),
canOverride: canOverride.generic.components([
canOverride.property.transitionProperty,
canOverride.generic.time,
canOverride.generic.timingFunction,
canOverride.generic.time
]),
components: [
'transition-property',
'transition-duration',
'transition-timing-function',
'transition-delay'
],
defaultValue: 'none',
restore: restore.multiplex(restore.withoutDefaults),
shorthand: true,
vendorPrefixes: [
'-moz-',
'-o-',
'-webkit-'
]
},
'transition-delay': {
canOverride: canOverride.generic.time,
componentOf: [
'transition'
],
defaultValue: '0s',
intoMultiplexMode: 'real',
vendorPrefixes: [
'-moz-',
'-o-',
'-webkit-'
]
},
'transition-duration': {
canOverride: canOverride.generic.time,
componentOf: [
'transition'
],
defaultValue: '0s',
intoMultiplexMode: 'real',
vendorPrefixes: [
'-moz-',
'-o-',
'-webkit-'
]
},
'transition-property': {
canOverride: canOverride.generic.propertyName,
componentOf: [
'transition'
],
defaultValue: 'all',
intoMultiplexMode: 'placeholder',
placeholderValue: '_', // it's a short value that won't match any property and still be a valid `transition-property`
vendorPrefixes: [
'-moz-',
'-o-',
'-webkit-'
]
},
'transition-timing-function': {
canOverride: canOverride.generic.timingFunction,
componentOf: [
'transition'
],
defaultValue: 'ease',
intoMultiplexMode: 'real',
vendorPrefixes: [
'-moz-',
'-o-',
'-webkit-'
]
},
'vertical-align': {
canOverride: canOverride.property.verticalAlign,
defaultValue: 'baseline'

View File

@@ -8,7 +8,6 @@ var sameVendorPrefixesIn = require('./vendor-prefixes').same;
var compactable = require('../compactable');
var deepClone = require('../clone').deep;
var deepClone = require('../clone').deep;
var restoreWithComponents = require('../restore-with-components');
var shallowClone = require('../clone').shallow;
@@ -95,10 +94,11 @@ function turnShorthandValueIntoMultiplex(property, size) {
}
function turnLonghandValueIntoMultiplex(property, size) {
var withRealValue = compactable[property.name].intoMultiplexMode == 'real';
var withValue = withRealValue ?
var descriptor = compactable[property.name];
var withRealValue = descriptor.intoMultiplexMode == 'real';
var withValue = descriptor.intoMultiplexMode == 'real' ?
property.value.slice(0) :
compactable[property.name].defaultValue;
(descriptor.intoMultiplexMode == 'placeholder' ? descriptor.placeholderValue : descriptor.defaultValue);
var i = multiplexSize(property);
var j;
var m = withValue.length;

View File

@@ -3,21 +3,24 @@ var functionVendorRegexStr = '\\-(\\-|[A-Z]|[0-9])+\\(.*?\\)';
var variableRegexStr = 'var\\(\\-\\-[^\\)]+\\)';
var functionAnyRegexStr = '(' + variableRegexStr + '|' + functionNoVendorRegexStr + '|' + functionVendorRegexStr + ')';
var animationTimingFunctionRegex = /^(cubic\-bezier|steps)\([^\)]+\)$/;
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 identifierRegex = /^(\-[a-z0-9_][a-z0-9\-_]*|[a-z][a-z0-9\-_]*)$/i;
var longHexColorRegex = /^#[0-9a-f]{6}$/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 shortHexColorRegex = /^#[0-9a-f]{3}$/i;
var timingFunctionRegex = /^(cubic\-bezier|steps)\([^\)]+\)$/;
var validTimeUnits = ['ms', 's'];
var urlRegex = /^url\([\s\S]+\)$/i;
var variableRegex = new RegExp('^' + variableRegexStr + '$', 'i');
var eightValueColorRegex = /^#[0-9a-f]{8}$/i;
var fourValueColorRegex = /^#[0-9a-f]{4}$/i;
var sixValueColorRegex = /^#[0-9a-f]{6}$/i;
var threeValueColorRegex = /^#[0-9a-f]{3}$/i;
var DECIMAL_DOT = '.';
var MINUS_SIGN = '-';
var PLUS_SIGN = '+';
@@ -41,6 +44,15 @@ var Keywords = {
'ridge',
'solid'
],
'*-timing-function': [
'ease',
'ease-in',
'ease-in-out',
'ease-out',
'linear',
'step-end',
'step-start'
],
'animation-direction': [
'alternate',
'alternate-reverse',
@@ -63,15 +75,6 @@ var Keywords = {
'paused',
'running'
],
'animation-timing-function': [
'ease',
'ease-in',
'ease-in-out',
'ease-out',
'linear',
'step-end',
'step-start'
],
'background-attachment': [
'fixed',
'inherit',
@@ -342,14 +345,6 @@ var Units = [
'vw'
];
function isAnimationTimingFunction() {
var isTimingFunctionKeyword = isKeyword('animation-timing-function');
return function (value) {
return isTimingFunctionKeyword(value) || animationTimingFunctionRegex.test(value);
};
}
function isColor(value) {
return value != 'auto' &&
(
@@ -373,7 +368,7 @@ function isFunction(value) {
}
function isHexColor(value) {
return shortHexColorRegex.test(value) || longHexColorRegex.test(value);
return threeValueColorRegex.test(value) || fourValueColorRegex.test(value) || sixValueColorRegex.test(value) || eightValueColorRegex.test(value);
}
function isHslColor(value) {
@@ -426,6 +421,14 @@ function isTime(value) {
numberUpTo > -1 && validTimeUnits.indexOf(value.slice(numberUpTo + 1)) > -1;
}
function isTimingFunction() {
var isTimingFunctionKeyword = isKeyword('*-timing-function');
return function (value) {
return isTimingFunctionKeyword(value) || timingFunctionRegex.test(value);
};
}
function isUnit(validUnits, value) {
var numberUpTo = scanForNumber(value);
@@ -484,7 +487,7 @@ function validator(compatibility) {
isAnimationIterationCountKeyword: isKeyword('animation-iteration-count'),
isAnimationNameKeyword: isKeyword('animation-name'),
isAnimationPlayStateKeyword: isKeyword('animation-play-state'),
isAnimationTimingFunction: isAnimationTimingFunction(),
isTimingFunction: isTimingFunction(),
isBackgroundAttachmentKeyword: isKeyword('background-attachment'),
isBackgroundClipKeyword: isKeyword('background-clip'),
isBackgroundOriginKeyword: isKeyword('background-origin'),

View File

@@ -1,3 +1,5 @@
var systemLineBreak = require('os').EOL;
var override = require('../utils/override');
var Breaks = {
@@ -12,6 +14,12 @@ var Breaks = {
BetweenSelectors: 'betweenSelectors'
};
var BreakWith = {
CarriageReturnLineFeed: '\r\n',
LineFeed: '\n',
System: systemLineBreak
};
var IndentWith = {
Space: ' ',
Tab: '\t'
@@ -25,10 +33,12 @@ var Spaces = {
var DEFAULTS = {
breaks: breaks(false),
breakWith: BreakWith.System,
indentBy: 0,
indentWith: IndentWith.Space,
spaces: spaces(false),
wrapAt: false
wrapAt: false,
semicolonAfterLastProperty: false
};
var BEAUTIFY_ALIAS = 'beautify';
@@ -75,6 +85,10 @@ function formatFrom(source) {
return false;
}
if (typeof source == 'object' && 'breakWith' in source) {
source = override(source, { breakWith: mapBreakWith(source.breakWith) });
}
if (typeof source == 'object' && 'indentBy' in source) {
source = override(source, { indentBy: parseInt(source.indentBy) });
}
@@ -133,6 +147,8 @@ function toHash(string) {
accumulator[name] = parseInt(value);
} else if (name == 'indentWith') {
accumulator[name] = mapIndentWith(value);
} else if (name == 'breakWith') {
accumulator[name] = mapBreakWith(value);
}
return accumulator;
@@ -167,6 +183,21 @@ function normalizeValue(value) {
}
}
function mapBreakWith(value) {
switch (value) {
case 'windows':
case 'crlf':
case BreakWith.CarriageReturnLineFeed:
return BreakWith.CarriageReturnLineFeed;
case 'unix':
case 'lf':
case BreakWith.LineFeed:
return BreakWith.LineFeed;
default:
return systemLineBreak;
}
}
function mapIndentWith(value) {
switch (value) {
case 'space':

View File

@@ -2,6 +2,7 @@ var Marker = {
ASTERISK: '*',
AT: '@',
BACK_SLASH: '\\',
CARRIAGE_RETURN: '\r',
CLOSE_CURLY_BRACKET: '}',
CLOSE_ROUND_BRACKET: ')',
CLOSE_SQUARE_BRACKET: ']',
@@ -12,7 +13,6 @@ var Marker = {
FORWARD_SLASH: '/',
INTERNAL: '-clean-css-',
NEW_LINE_NIX: '\n',
NEW_LINE_WIN: '\r',
OPEN_CURLY_BRACKET: '{',
OPEN_ROUND_BRACKET: '(',
OPEN_SQUARE_BRACKET: '[',

View File

@@ -9,6 +9,7 @@ var Token = {
PROPERTY_BLOCK: 'property-block', // e.g. `--var:{color:red}`
PROPERTY_NAME: 'property-name', // e.g. `color`
PROPERTY_VALUE: 'property-value', // e.g. `red`
RAW: 'raw', // e.g. anything between /* clean-css ignore:start */ and /* clean-css ignore:end */ comments
RULE: 'rule', // e.g `div > a{...}`
RULE_SCOPE: 'rule-scope' // e.g `div > a`
};

View File

@@ -28,6 +28,9 @@ var BLOCK_RULES = [
'@supports'
];
var IGNORE_END_COMMENT_PATTERN = /\/\* clean\-css ignore:end \*\/$/;
var IGNORE_START_COMMENT_PATTERN = /^\/\* clean\-css ignore:start \*\//;
var PAGE_MARGIN_BOXES = [
'@bottom-center',
'@bottom-left',
@@ -88,11 +91,13 @@ function intoTokens(source, externalContext, internalContext, isNested) {
var buffer = [];
var buffers = [];
var serializedBuffer;
var serializedBufferPart;
var roundBracketLevel = 0;
var isQuoted;
var isSpace;
var isNewLineNix;
var isNewLineWin;
var isCarriageReturn;
var isCommentStart;
var wasCommentStart = false;
var isCommentEnd;
@@ -100,9 +105,11 @@ function intoTokens(source, externalContext, internalContext, isNested) {
var isCommentEndMarker;
var isEscaped;
var wasEscaped = false;
var isRaw = false;
var seekingValue = false;
var seekingPropertyBlockClosing = false;
var position = internalContext.position;
var lastCommentStartAt;
for (; position.index < source.length; position.index++) {
var character = source[position.index];
@@ -110,7 +117,8 @@ function intoTokens(source, externalContext, internalContext, isNested) {
isQuoted = level == Level.SINGLE_QUOTE || level == Level.DOUBLE_QUOTE;
isSpace = character == Marker.SPACE || character == Marker.TAB;
isNewLineNix = character == Marker.NEW_LINE_NIX;
isNewLineWin = character == Marker.NEW_LINE_NIX && source[position.index - 1] == Marker.NEW_LINE_WIN;
isNewLineWin = character == Marker.NEW_LINE_NIX && source[position.index - 1] == Marker.CARRIAGE_RETURN;
isCarriageReturn = character == Marker.CARRIAGE_RETURN && source[position.index + 1] && source[position.index + 1] != Marker.NEW_LINE_NIX;
isCommentStart = !wasCommentEnd && level != Level.COMMENT && !isQuoted && character == Marker.ASTERISK && source[position.index - 1] == Marker.FORWARD_SLASH;
isCommentEndMarker = !wasCommentStart && !isQuoted && character == Marker.FORWARD_SLASH && source[position.index - 1] == Marker.ASTERISK;
isCommentEnd = level == Level.COMMENT && isCommentEndMarker;
@@ -125,6 +133,8 @@ function intoTokens(source, externalContext, internalContext, isNested) {
buffer.push(character);
} else if (!isCommentEnd && level == Level.COMMENT) {
buffer.push(character);
} else if (!isCommentStart && !isCommentEnd && isRaw) {
buffer.push(character);
} else if (isCommentStart && (level == Level.BLOCK || level == Level.RULE) && buffer.length > 1) {
// comment start within block preceded by some content, e.g. div/*<--
metadatas.push(metadata);
@@ -141,6 +151,33 @@ function intoTokens(source, externalContext, internalContext, isNested) {
levels.push(level);
level = Level.COMMENT;
buffer.push(character);
} else if (isCommentEnd && isIgnoreStartComment(buffer)) {
// ignore:start comment end, e.g. /* clean-css ignore:start */<--
serializedBuffer = buffer.join('').trim() + character;
lastToken = [Token.COMMENT, serializedBuffer, [originalMetadata(metadata, serializedBuffer, externalContext)]];
newTokens.push(lastToken);
isRaw = true;
metadata = metadatas.pop() || null;
buffer = buffers.pop() || [];
} else if (isCommentEnd && isIgnoreEndComment(buffer)) {
// ignore:start comment end, e.g. /* clean-css ignore:end */<--
serializedBuffer = buffer.join('') + character;
lastCommentStartAt = serializedBuffer.lastIndexOf(Marker.FORWARD_SLASH + Marker.ASTERISK);
serializedBufferPart = serializedBuffer.substring(0, lastCommentStartAt);
lastToken = [Token.RAW, serializedBufferPart, [originalMetadata(metadata, serializedBufferPart, externalContext)]];
newTokens.push(lastToken);
serializedBufferPart = serializedBuffer.substring(lastCommentStartAt);
metadata = [position.line, position.column - serializedBufferPart.length + 1, position.source];
lastToken = [Token.COMMENT, serializedBufferPart, [originalMetadata(metadata, serializedBufferPart, externalContext)]];
newTokens.push(lastToken);
isRaw = false;
level = levels.pop();
metadata = metadatas.pop() || null;
buffer = buffers.pop() || [];
} else if (isCommentEnd) {
// comment end, e.g. /* comment */<--
serializedBuffer = buffer.join('').trim() + character;
@@ -448,7 +485,7 @@ function intoTokens(source, externalContext, internalContext, isNested) {
} else if (buffer.length == 1 && isNewLineWin) {
// ignore windows newline which is composed of two characters
buffer.pop();
} else if (buffer.length > 0 || !isSpace && !isNewLineNix && !isNewLineWin) {
} else if (buffer.length > 0 || !isSpace && !isNewLineNix && !isNewLineWin && !isCarriageReturn) {
// any character
buffer.push(character);
}
@@ -458,8 +495,8 @@ function intoTokens(source, externalContext, internalContext, isNested) {
wasCommentStart = isCommentStart;
wasCommentEnd = isCommentEnd;
position.line = (isNewLineWin || isNewLineNix) ? position.line + 1 : position.line;
position.column = (isNewLineWin || isNewLineNix) ? 0 : position.column + 1;
position.line = (isNewLineWin || isNewLineNix || isCarriageReturn) ? position.line + 1 : position.line;
position.column = (isNewLineWin || isNewLineNix || isCarriageReturn) ? 0 : position.column + 1;
}
if (seekingValue) {
@@ -480,6 +517,14 @@ function intoTokens(source, externalContext, internalContext, isNested) {
return allTokens;
}
function isIgnoreStartComment(buffer) {
return IGNORE_START_COMMENT_PATTERN.test(buffer.join('') + Marker.FORWARD_SLASH);
}
function isIgnoreEndComment(buffer) {
return IGNORE_END_COMMENT_PATTERN.test(buffer.join('') + Marker.FORWARD_SLASH);
}
function originalMetadata(metadata, value, externalContext, selectorFallbacks) {
var source = metadata[2];

View File

@@ -1,4 +1,3 @@
var lineBreak = require('os').EOL;
var emptyCharacter = '';
var Breaks = require('../options/format').Breaks;
@@ -79,7 +78,20 @@ function property(context, tokens, position, lastPropertyAt) {
var store = context.store;
var token = tokens[position];
var isPropertyBlock = token[2][0] == Token.PROPERTY_BLOCK;
var needsSemicolon = position < lastPropertyAt || isPropertyBlock;
var needsSemicolon;
if ( context.format ) {
if ( context.format.semicolonAfterLastProperty || isPropertyBlock ) {
needsSemicolon = true;
} else if ( position < lastPropertyAt ) {
needsSemicolon = true;
} else {
needsSemicolon = false;
}
} else {
needsSemicolon = position < lastPropertyAt || isPropertyBlock;
}
var isLast = position === lastPropertyAt;
switch (token[0]) {
@@ -101,6 +113,9 @@ function property(context, tokens, position, lastPropertyAt) {
store(context, colon(context));
value(context, token);
store(context, needsSemicolon ? semicolon(context, Breaks.AfterProperty, isLast) : emptyCharacter);
break;
case Token.RAW:
store(context, token);
}
}
@@ -137,7 +152,7 @@ function openBrace(context, where, needsPrefixSpace) {
context.indentWith = context.format.indentWith.repeat(context.indentBy);
return (needsPrefixSpace && allowsSpace(context, Spaces.BeforeBlockBegins) ? Marker.SPACE : emptyCharacter) +
Marker.OPEN_CURLY_BRACKET +
(allowsBreak(context, where) ? lineBreak : emptyCharacter) +
(allowsBreak(context, where) ? context.format.breakWith : emptyCharacter) +
context.indentWith;
} else {
return Marker.OPEN_CURLY_BRACKET;
@@ -148,10 +163,10 @@ function closeBrace(context, where, beforeBlockEnd, isLast) {
if (context.format) {
context.indentBy -= context.format.indentBy;
context.indentWith = context.format.indentWith.repeat(context.indentBy);
return (allowsBreak(context, Breaks.AfterProperty) || beforeBlockEnd && allowsBreak(context, Breaks.BeforeBlockEnds) ? lineBreak : emptyCharacter) +
return (allowsBreak(context, Breaks.AfterProperty) || beforeBlockEnd && allowsBreak(context, Breaks.BeforeBlockEnds) ? context.format.breakWith : emptyCharacter) +
context.indentWith +
Marker.CLOSE_CURLY_BRACKET +
(isLast ? emptyCharacter : (allowsBreak(context, where) ? lineBreak : emptyCharacter) + context.indentWith);
(isLast ? emptyCharacter : (allowsBreak(context, where) ? context.format.breakWith : emptyCharacter) + context.indentWith);
} else {
return Marker.CLOSE_CURLY_BRACKET;
}
@@ -165,13 +180,13 @@ function colon(context) {
function semicolon(context, where, isLast) {
return context.format ?
Marker.SEMICOLON + (isLast || !allowsBreak(context, where) ? emptyCharacter : lineBreak + context.indentWith) :
Marker.SEMICOLON + (isLast || !allowsBreak(context, where) ? emptyCharacter : context.format.breakWith + context.indentWith) :
Marker.SEMICOLON;
}
function comma(context) {
return context.format ?
Marker.COMMA + (allowsBreak(context, Breaks.BetweenSelectors) ? lineBreak : emptyCharacter) + context.indentWith :
Marker.COMMA + (allowsBreak(context, Breaks.BetweenSelectors) ? context.format.breakWith : emptyCharacter) + context.indentWith :
Marker.COMMA;
}
@@ -204,7 +219,10 @@ function all(context, tokens) {
break;
case Token.COMMENT:
store(context, token);
store(context, allowsBreak(context, Breaks.AfterComment) ? lineBreak : emptyCharacter);
store(context, allowsBreak(context, Breaks.AfterComment) ? context.format.breakWith : emptyCharacter);
break;
case Token.RAW:
store(context, token);
break;
case Token.RULE:
rules(context, token[1]);

View File

@@ -1,7 +1,5 @@
var all = require('./helpers').all;
var lineBreak = require('os').EOL;
function store(serializeContext, token) {
var value = typeof token == 'string' ?
token :
@@ -15,8 +13,8 @@ function store(serializeContext, token) {
function wrap(serializeContext, value) {
if (serializeContext.column + value.length > serializeContext.format.wrapAt) {
track(serializeContext, lineBreak);
serializeContext.output.push(lineBreak);
track(serializeContext, serializeContext.format.breakWith);
serializeContext.output.push(serializeContext.format.breakWith);
}
}

View File

@@ -1,7 +1,6 @@
var SourceMapGenerator = require('source-map').SourceMapGenerator;
var all = require('./helpers').all;
var lineBreak = require('os').EOL;
var isRemoteResource = require('../utils/is-remote-resource');
var isWindows = process.platform == 'win32';
@@ -23,8 +22,8 @@ function store(serializeContext, element) {
function wrap(serializeContext, value) {
if (serializeContext.column + value.length > serializeContext.format.wrapAt) {
track(serializeContext, lineBreak, false);
serializeContext.output.push(lineBreak);
track(serializeContext, serializeContext.format.breakWith, false);
serializeContext.output.push(serializeContext.format.breakWith);
}
}

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

@@ -1,32 +1,28 @@
{
"_args": [
[
"clean-css@4.1.11",
"E:\\projects\\p\\minifyfromhtml"
]
],
"_from": "clean-css@4.1.11",
"_id": "clean-css@4.1.11",
"_from": "clean-css@^4.1.6",
"_id": "clean-css@4.2.1",
"_inBundle": false,
"_integrity": "sha1-Ls3xRaujj1R0DybO/Q/z4D4SXWo=",
"_integrity": "sha512-4ZxI6dy4lrY6FHzfiy1aEOXgu4LIsW2MhwG0VBKdcoGoH/XLFgaHSdLTGr4O8Be6A8r3MOphEiI8Gc1n0ecf3g==",
"_location": "/clean-css",
"_phantomChildren": {},
"_requested": {
"type": "version",
"type": "range",
"registry": true,
"raw": "clean-css@4.1.11",
"raw": "clean-css@^4.1.6",
"name": "clean-css",
"escapedName": "clean-css",
"rawSpec": "4.1.11",
"rawSpec": "^4.1.6",
"saveSpec": null,
"fetchSpec": "4.1.11"
"fetchSpec": "^4.1.6"
},
"_requiredBy": [
"/"
"/html-minifier",
"/minify"
],
"_resolved": "https://registry.npmjs.org/clean-css/-/clean-css-4.1.11.tgz",
"_spec": "4.1.11",
"_where": "E:\\projects\\p\\minifyfromhtml",
"_resolved": "https://registry.npmjs.org/clean-css/-/clean-css-4.2.1.tgz",
"_shasum": "2d411ef76b8569b6d0c84068dabe85b0aa5e5c17",
"_spec": "clean-css@^4.1.6",
"_where": "F:\\projects\\p\\minifyfromhtml\\node_modules\\minify",
"author": {
"name": "Jakub Pawlowicz",
"email": "contact@jakubpawlowicz.com",
@@ -35,9 +31,11 @@
"bugs": {
"url": "https://github.com/jakubpawlowicz/clean-css/issues"
},
"bundleDependencies": false,
"dependencies": {
"source-map": "0.5.x"
"source-map": "~0.6.0"
},
"deprecated": false,
"description": "A well-tested CSS minifier",
"devDependencies": {
"browserify": "^14.0.0",
@@ -76,5 +74,5 @@
"prepublish": "npm run check",
"test": "vows"
},
"version": "4.1.11"
"version": "4.2.1"
}