Added logging, changed some directory structure

This commit is contained in:
2018-01-13 21:33:40 -05:00
parent f079a5f067
commit 8e72ffb917
73656 changed files with 35284 additions and 53718 deletions

View File

@@ -0,0 +1,146 @@
# 2.6.1
* Resolves an issue where IE hacks were being removed from `0` values
(thanks to @Justineo).
# 2.6.0
* Added clamping of the values for the `shape-image-threshold` property, using
the same logic as introduced in version `2.5.0`.
# 2.5.0
* Added clamping of the values for the `opacity` property to the `0-1` range.
For example, this will convert `opacity: 1.1` to `opacity: 1`.
# 2.4.1
* Resolves an issue where the units would be stripped from zero values in
custom properties (thanks to @jgerigmeyer).
# 2.4.0
* Added a `precision` option to enable rounding of decimal places for
`px` values.
# 2.3.6
* Resolves an issue with the last patch where `height: 0em` was not being
converted to `height: 0`.
# 2.3.5
* Resolves an issue where certain properties inside `@keyframes` rules would
break animation in IE due to the percentage being stripped. Now, the
percentage is preserved for these properties.
# 2.3.4
* Does not convert `height:0%` to `height:0` (and the same for `max-height`), as
they produce different results.
# 2.3.3
* Updates postcss-value-parser to version 3 (thanks to @TrySound).
# 2.3.2
* Fixed a regression where `0%` in color functions was being transformed to `0`
(thanks to @TrySound).
# 2.3.1
* Fixed a behaviour where `0deg` was being converted to `0`.
# 2.3.0
* Added an option to convert between `turn` & `deg` (thanks to @TrySound).
# 2.2.1
* Fixes a behaviour where the module would remove units from zero values inside
calc functions (thanks to @marek-saji & @TrySound).
# 2.2.0
* Renames `opts.convertLength` & `opts.convertTime` to
`opts.length` & `opts.time`; the old options will now print deprecation
warnings (thanks to @TrySound).
# 2.1.0
* Adds options to enable/disable unit conversion for time & length values.
# 2.0.1
* Bump postcss-value-parser to `2.0.2`.
# 2.0.0
* Upgraded to PostCSS 5.
# 1.3.1
* Fixes an issue where the module would convert values in gradient/url functions
since 1.3.0.
# 1.3.0
* Converted the module to use ES6.
* balanced-match, css-list & some integrated code has been replaced with
postcss-value-parser; reducing the number of moving parts in this module, and
providing a more futureproof way of parsing CSS numeric values.
# 1.2.5
* Fixes an issue where uppercase units (such as PX) were being deleted.
# 1.2.4
* Fixes convert not px or ms
# 1.2.3
* Adds support for `ch` units; previously they were removed.
* Upgrades css-list to `0.1.0`, code tidied up.
# 1.2.2
* Added support for viewport units (thanks to @TrySound).
# 1.2.1
* Fixes regressions introduced by the previous patch. Better support for
negative value transforms.
# 1.2.0
* Adds support for slash/comma separated values (thanks to @TrySound).
# 1.1.1
* Fixes an issue where trailing zeroes were not being removed in
values that were not `0` (thanks to @TrySound).
# 1.1.0
* Adds support for removing leading zeroes from `rem` values
(thanks to @tunnckoCore).
# 1.0.3
* Fixed a bug where filenames were being incorrectly transformed.
# 1.0.2
* Fixed a bug where `1.` and `.0` were not being optimised to `1` and `0`,
respectively.
# 1.0.1
* Fixed a bug where `undefined` would be stringified as the unit value, if the
value did not have a unit.
# 1.0.0
* Initial release.

View File

@@ -0,0 +1,22 @@
Copyright (c) Ben Briggs <beneb.info@gmail.com> (http://beneb.info)
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,106 @@
# [postcss][postcss]-convert-values [![Build Status](https://travis-ci.org/ben-eb/postcss-convert-values.svg?branch=master)][ci] [![NPM version](https://badge.fury.io/js/postcss-convert-values.svg)][npm] [![Dependency Status](https://gemnasium.com/ben-eb/postcss-convert-values.svg)][deps]
> Convert values with PostCSS (e.g. ms -> s)
## Install
With [npm](https://npmjs.org/package/postcss-convert-values) do:
```
npm install postcss-convert-values --save
```
## Example
This plugin reduces CSS size by converting values to use different units
where possible; for example, `500ms` can be represented as `.5s`. You can
read more about these units in [this article][csstricks].
### Input
```css
h1 {
font-size: 16px;
width: 0em
}
```
### Output
```css
h1 {
font-size: 1pc;
width: 0
}
```
Note that this plugin only covers conversions for duration and absolute length
values. For color conversions, use [postcss-colormin][colormin].
## API
### convertValues([options])
#### options
##### length
Type: `boolean`
Default: `true`
Pass `false` to disable conversion from `px` to other absolute length units,
such as `pc` & `pt` & vice versa.
##### time
Type: `boolean`
Default: `true`
Pass `false` to disable conversion from `ms` to `s` & vice versa.
##### angle
Type: `boolean`
Default: `true`
Pass `false` to disable conversion from `deg` to `turn` & vice versa.
##### precision
Type: `boolean|number`
Default: `false`
Specify any numeric value here to round `px` values to that many decimal places;
for example, using `{precision: 2}` will round `6.66667px` to `6.67px`, and
`{precision: 0}` will round it to `7px`. Passing `false` (the default) will
leave these values as is.
It is recommended for most use cases to set this option to `2`.
## Contributors
Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
| [<img src="https://avatars.githubusercontent.com/u/1282980?v=3" width="100px;"/><br /><sub>Ben Briggs</sub>](http://beneb.info)<br />[💻](https://github.com/ben-eb/postcss-convert-values/commits?author=ben-eb) [📖](https://github.com/ben-eb/postcss-convert-values/commits?author=ben-eb) 👀 [⚠️](https://github.com/ben-eb/postcss-convert-values/commits?author=ben-eb) | [<img src="https://avatars.githubusercontent.com/u/5635476?v=3" width="100px;"/><br /><sub>Bogdan Chadkin</sub>](https://github.com/TrySound)<br />[💻](https://github.com/ben-eb/postcss-convert-values/commits?author=TrySound) [📖](https://github.com/ben-eb/postcss-convert-values/commits?author=TrySound) 👀 [⚠️](https://github.com/ben-eb/postcss-convert-values/commits?author=TrySound) | [<img src="https://avatars.githubusercontent.com/u/177485?v=3" width="100px;"/><br /><sub>Roman Komarov</sub>](http://kizu.ru/en/)<br />[🐛](https://github.com/ben-eb/postcss-convert-values/issues?q=author%3Akizu) | [<img src="https://avatars.githubusercontent.com/u/5103477?v=3" width="100px;"/><br /><sub>Dmitry Kiselyov</sub>](http://codepen.io/dmitrykiselyov)<br />[🐛](https://github.com/ben-eb/postcss-convert-values/issues?q=author%3Admitrykiselyov) | [<img src="https://avatars.githubusercontent.com/u/5038030?v=3" width="100px;"/><br /><sub>Charlike Mike Reagent</sub>](http://www.tunnckocore.tk)<br />[💻](https://github.com/ben-eb/postcss-convert-values/commits?author=tunnckoCore) [⚠️](https://github.com/ben-eb/postcss-convert-values/commits?author=tunnckoCore) | [<img src="https://avatars.githubusercontent.com/u/815848?v=3" width="100px;"/><br /><sub>Vyacheslav Shebanov</sub>](https://github.com/Termina1)<br />[📖](https://github.com/ben-eb/postcss-convert-values/commits?author=Termina1) | [<img src="https://avatars.githubusercontent.com/u/192323?v=3" width="100px;"/><br /><sub>Marek saji Augustynowicz</sub>](http://twitter.com/saji_)<br />[💻](https://github.com/ben-eb/postcss-convert-values/commits?author=marek-saji) [⚠️](https://github.com/ben-eb/postcss-convert-values/commits?author=marek-saji) |
| :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| [<img src="https://avatars.githubusercontent.com/u/552316?v=3" width="100px;"/><br /><sub>Jonny Gerig Meyer</sub>](www.oddbird.net)<br />[💻](https://github.com/ben-eb/postcss-convert-values/commits?author=jgerigmeyer) [⚠️](https://github.com/ben-eb/postcss-convert-values/commits?author=jgerigmeyer) | [<img src="https://avatars.githubusercontent.com/u/1726061?v=3" width="100px;"/><br /><sub>GU Yiling</sub>](http://lync.in/)<br />[💻](https://github.com/ben-eb/postcss-convert-values/commits?author=Justineo) [⚠️](https://github.com/ben-eb/postcss-convert-values/commits?author=Justineo) |
<!-- ALL-CONTRIBUTORS-LIST:END -->
This project follows the [all-contributors] specification. Contributions of
any kind welcome!
## License
MIT © [Ben Briggs](http://beneb.info)
[all-contributors]: https://github.com/kentcdodds/all-contributors
[ci]: https://travis-ci.org/ben-eb/postcss-convert-values
[colormin]: https://github.com/ben-eb/postcss-colormin
[deps]: https://gemnasium.com/ben-eb/postcss-convert-values
[npm]: http://badge.fury.io/js/postcss-convert-values
[postcss]: https://github.com/postcss/postcss
[csstricks]: https://css-tricks.com/the-lengths-of-css/

View File

@@ -0,0 +1,108 @@
'use strict';
exports.__esModule = true;
var _postcss = require('postcss');
var _postcss2 = _interopRequireDefault(_postcss);
var _postcssValueParser = require('postcss-value-parser');
var _postcssValueParser2 = _interopRequireDefault(_postcssValueParser);
var _convert = require('./lib/convert');
var _convert2 = _interopRequireDefault(_convert);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var LENGTH_UNITS = ['em', 'ex', 'ch', 'rem', 'vw', 'vh', 'vmin', 'vmax', 'cm', 'mm', 'q', 'in', 'pt', 'pc', 'px'];
function parseWord(node, opts, keepZeroUnit) {
var pair = (0, _postcssValueParser.unit)(node.value);
if (pair) {
var num = Number(pair.number);
var u = pair.unit.toLowerCase();
if (num === 0) {
node.value = keepZeroUnit || !~LENGTH_UNITS.indexOf(u) && u !== '%' ? 0 + u : 0;
} else {
node.value = (0, _convert2.default)(num, u, opts);
if (typeof opts.precision === 'number' && u === 'px' && ~pair.number.indexOf('.')) {
var precision = Math.pow(10, opts.precision);
node.value = Math.round(parseFloat(node.value) * precision) / precision + u;
}
}
}
}
function clampOpacity(node) {
var pair = (0, _postcssValueParser.unit)(node.value);
if (!pair) {
return;
}
var num = Number(pair.number);
if (num > 1) {
node.value = 1 + pair.unit;
} else if (num < 0) {
node.value = 0 + pair.unit;
}
}
function shouldStripPercent(_ref) {
var value = _ref.value,
prop = _ref.prop,
parent = _ref.parent;
return ~value.indexOf('%') && (prop === 'max-height' || prop === 'height') || parent.parent && parent.parent.name === 'keyframes' && prop === 'stroke-dasharray' || prop === 'stroke-dashoffset' || prop === 'stroke-width';
}
function transform(opts) {
return function (decl) {
var prop = decl.prop;
if (~prop.indexOf('flex') || prop.indexOf('--') === 0) {
return;
}
decl.value = (0, _postcssValueParser2.default)(decl.value).walk(function (node) {
if (node.type === 'word') {
parseWord(node, opts, shouldStripPercent(decl));
if (prop === 'opacity' || prop === 'shape-image-threshold') {
clampOpacity(node);
}
} else if (node.type === 'function') {
if (node.value === 'calc' || node.value === 'hsl' || node.value === 'hsla') {
(0, _postcssValueParser.walk)(node.nodes, function (n) {
if (n.type === 'word') {
parseWord(n, opts, true);
}
});
return false;
}
if (node.value === 'url') {
return false;
}
}
}).toString();
};
}
var plugin = 'postcss-convert-values';
exports.default = _postcss2.default.plugin(plugin, function () {
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { precision: false };
if (opts.length === undefined && opts.convertLength !== undefined) {
console.warn(plugin + ': `convertLength` option is deprecated. Use `length`');
opts.length = opts.convertLength;
}
if (opts.length === undefined && opts.convertTime !== undefined) {
console.warn(plugin + ': `convertTime` option is deprecated. Use `time`');
opts.time = opts.convertTime;
}
return function (css) {
return css.walkDecls(transform(opts));
};
});
module.exports = exports['default'];

View File

@@ -0,0 +1,88 @@
'use strict';
exports.__esModule = true;
exports.default = function (number, unit, _ref) {
var time = _ref.time,
length = _ref.length,
angle = _ref.angle;
var value = dropLeadingZero(number) + (unit ? unit : '');
var converted = void 0;
if (length !== false && unit in lengthConv) {
converted = transform(number, unit, lengthConv);
}
if (time !== false && unit in timeConv) {
converted = transform(number, unit, timeConv);
}
if (angle !== false && unit in angleConv) {
converted = transform(number, unit, angleConv);
}
if (converted && converted.length < value.length) {
value = converted;
}
return value;
};
var lengthConv = {
in: 96,
px: 1,
pt: 4 / 3,
pc: 16
};
var timeConv = {
s: 1000,
ms: 1
};
var angleConv = {
turn: 360,
deg: 1
};
function dropLeadingZero(number) {
var value = String(number);
if (number % 1) {
if (value[0] === '0') {
return value.slice(1);
}
if (value[0] === '-' && value[1] === '0') {
return '-' + value.slice(2);
}
}
return value;
}
function transform(number, unit, conversion) {
var one = void 0,
base = void 0;
var convertionUnits = Object.keys(conversion).filter(function (u) {
if (conversion[u] === 1) {
one = u;
}
return unit !== u;
});
if (unit === one) {
base = number / conversion[unit];
} else {
base = number * conversion[unit];
}
return convertionUnits.map(function (u) {
return dropLeadingZero(base / conversion[u]) + u;
}).reduce(function (a, b) {
return a.length < b.length ? a : b;
});
}
module.exports = exports['default'];

View File

@@ -0,0 +1,92 @@
{
"_args": [
[
"postcss-convert-values@2.6.1",
"C:\\Users\\deranjer\\go\\src\\github.com\\deranjer\\goTorrent\\torrent-project"
]
],
"_from": "postcss-convert-values@2.6.1",
"_id": "postcss-convert-values@2.6.1",
"_inBundle": false,
"_integrity": "sha1-u9hZPFwf0uPRwyK7kl3K6Nrk1i0=",
"_location": "/css-loader/postcss-convert-values",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "postcss-convert-values@2.6.1",
"name": "postcss-convert-values",
"escapedName": "postcss-convert-values",
"rawSpec": "2.6.1",
"saveSpec": null,
"fetchSpec": "2.6.1"
},
"_requiredBy": [
"/css-loader/cssnano"
],
"_resolved": "https://registry.npmjs.org/postcss-convert-values/-/postcss-convert-values-2.6.1.tgz",
"_spec": "2.6.1",
"_where": "C:\\Users\\deranjer\\go\\src\\github.com\\deranjer\\goTorrent\\torrent-project",
"author": {
"name": "Ben Briggs",
"email": "beneb.info@gmail.com",
"url": "http://beneb.info"
},
"ava": {
"require": "babel-register"
},
"bugs": {
"url": "https://github.com/ben-eb/postcss-convert-values/issues"
},
"dependencies": {
"postcss": "^5.0.11",
"postcss-value-parser": "^3.1.2"
},
"description": "Convert values with PostCSS (e.g. ms -> s)",
"devDependencies": {
"all-contributors-cli": "^3.0.5",
"ava": "^0.17.0",
"babel-cli": "^6.3.17",
"babel-core": "^6.3.26",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-preset-es2015": "^6.3.13",
"babel-preset-es2015-loose": "^7.0.0",
"babel-preset-stage-0": "^6.3.13",
"babel-register": "^6.9.0",
"del-cli": "^0.2.0",
"eslint": "^3.0.0",
"eslint-config-cssnano": "^3.0.0",
"eslint-plugin-babel": "^3.3.0",
"eslint-plugin-import": "^2.0.1"
},
"eslintConfig": {
"extends": "cssnano"
},
"files": [
"LICENSE-MIT",
"dist"
],
"homepage": "https://github.com/ben-eb/postcss-convert-values",
"keywords": [
"css",
"optimisation",
"postcss",
"postcss-plugin"
],
"license": "MIT",
"main": "dist/index.js",
"name": "postcss-convert-values",
"repository": {
"type": "git",
"url": "git+https://github.com/ben-eb/postcss-convert-values.git"
},
"scripts": {
"contributorAdd": "all-contributors add",
"contributorGenerate": "all-contributors generate",
"prepublish": "del-cli dist && BABEL_ENV=publish babel src --out-dir dist --ignore /__tests__/",
"pretest": "eslint src",
"test": "ava",
"test-012": "ava"
},
"version": "2.6.1"
}