aboutsummaryrefslogtreecommitdiff
path: root/node_modules/postcss-svgo
diff options
context:
space:
mode:
authorruki <waruqi@gmail.com>2018-11-08 00:38:48 +0800
committerruki <waruqi@gmail.com>2018-11-07 21:53:09 +0800
commit26105034da4fcce7ac883c899d781f016559310d (patch)
treec459a5dc4e3aa0972d9919033ece511ce76dd129 /node_modules/postcss-svgo
parent2c77f00f1a7ecb6c8192f9c16d3b2001b254a107 (diff)
downloadxmake-docs-26105034da4fcce7ac883c899d781f016559310d.tar.gz
xmake-docs-26105034da4fcce7ac883c899d781f016559310d.zip
switch to vuepress
Diffstat (limited to 'node_modules/postcss-svgo')
-rw-r--r--node_modules/postcss-svgo/CHANGELOG.md67
-rw-r--r--node_modules/postcss-svgo/LICENSE-MIT22
-rw-r--r--node_modules/postcss-svgo/README.md130
-rw-r--r--node_modules/postcss-svgo/dist/index.js108
-rw-r--r--node_modules/postcss-svgo/dist/lib/url.js9
l---------node_modules/postcss-svgo/node_modules/.bin/svgo1
-rw-r--r--node_modules/postcss-svgo/package.json67
7 files changed, 404 insertions, 0 deletions
diff --git a/node_modules/postcss-svgo/CHANGELOG.md b/node_modules/postcss-svgo/CHANGELOG.md
new file mode 100644
index 00000000..4a547e8f
--- /dev/null
+++ b/node_modules/postcss-svgo/CHANGELOG.md
@@ -0,0 +1,67 @@
+# 2.1.6
+
+* Resolves an issue where postcss-svgo would convert colours to hex codes
+ without URL-encoding the `#`.
+
+# 2.1.5
+
+* Bump svgo to v0.7.x.
+
+# 2.1.4
+
+* Fixes an issue where postcss-svgo would throw with some SVGs that were
+ not properly URI encoded.
+
+# 2.1.3
+
+* Upgrade is-svg to version 2.
+
+# 2.1.2
+
+* Fixes an issue with processing some malformed URIs (thanks to @TrySound).
+
+# 2.1.1
+
+* Bump SVGO to 0.6.1 (thanks to @shinnn).
+
+# 2.1.0
+
+* Adds `encode` option (thanks to @TrySound).
+
+# 2.0.4
+
+* Updates postcss-value-parser to version 3 (thanks to @TrySound).
+
+# 2.0.3
+
+* Uses postcss-value-parser instead of async-replace to reduce cssnano's
+ download size (thanks to @TrySound).
+
+# 2.0.2
+
+* Fixed an issue where the module was not handling exceptions from
+ decoding URLs.
+* The module will now convert all SVG wrapping quotes to single quotes, which
+ is consistent with SVGO's output.
+
+# 2.0.1
+
+* Fixed an issue where the `charset` definition was being removed from the
+ SVG source, breaking IE compatibility (thanks to @ophyros).
+
+# 2.0.0
+
+* Upgraded to PostCSS 5.0.
+
+# 1.1.0
+
+* Adds support for uri-encoded SVG files, for better compatibility
+ with postcss-svg.
+
+# 1.0.1
+
+* Push ES5 build to npm.
+
+# 1.0.0
+
+* Initial release.
diff --git a/node_modules/postcss-svgo/LICENSE-MIT b/node_modules/postcss-svgo/LICENSE-MIT
new file mode 100644
index 00000000..fd0e863a
--- /dev/null
+++ b/node_modules/postcss-svgo/LICENSE-MIT
@@ -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.
diff --git a/node_modules/postcss-svgo/README.md b/node_modules/postcss-svgo/README.md
new file mode 100644
index 00000000..59a685e7
--- /dev/null
+++ b/node_modules/postcss-svgo/README.md
@@ -0,0 +1,130 @@
+# [postcss][postcss]-svgo [![Build Status](https://travis-ci.org/ben-eb/postcss-svgo.svg?branch=master)][ci] [![NPM version](https://badge.fury.io/js/postcss-svgo.svg)][npm] [![Dependency Status](https://gemnasium.com/ben-eb/postcss-svgo.svg)][deps]
+
+> Optimise inline SVG with PostCSS.
+
+
+## Install
+
+With [npm](https://npmjs.org/package/postcss-svgo) do:
+
+```
+npm install postcss-svgo --save
+```
+
+
+## Example
+
+### Input
+
+```css
+h1 {
+ background: url('data:image/svg+xml;charset=utf-8,<?xml version="1.0" encoding="utf-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve"><circle cx="50" cy="50" r="40" fill="yellow" /></svg>');
+}
+```
+
+### Output
+
+```css
+h1 {
+ background: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg"><circle cx="50" cy="50" r="40" fill="%23ff0"/></svg>');
+}
+```
+
+
+## API
+
+### `svgo([options])`
+
+Note that postcss-svgo is an *asynchronous* processor. It cannot be used
+like this:
+
+```js
+var result = postcss([ svgo() ]).process(css).css;
+console.log(result);
+```
+
+Instead make sure your PostCSS runner uses the asynchronous API:
+
+```js
+postcss([ svgo() ]).process(css).then(function (result) {
+ console.log(result.css);
+});
+```
+
+#### options
+
+##### encode
+
+Type: `boolean`
+Default: `undefined`
+
+If `true`, it will encode URL-unsafe characters such as `<`, `>` and `&`;
+`false` will decode these characters, and `undefined` will neither encode nor
+decode the original input. Note that regardless of this setting, `#` will
+always be URL-encoded.
+
+##### plugins
+
+Optionally, you can customise the output by specifying the `plugins` option. You
+will need to provide the config in comma separated objects, like the example
+below. Note that you can either disable the plugin by setting it to `false`,
+or pass different options to change the default behaviour.
+
+```js
+var postcss = require('postcss');
+var svgo = require('postcss-svgo');
+
+var opts = {
+ plugins: [{
+ removeDoctype: false
+ }, {
+ removeComments: false
+ }, {
+ cleanupNumericValues: {
+ floatPrecision: 2
+ }
+ }, {
+ convertColors: {
+ names2hex: false,
+ rgb2hex: false
+ }
+ }]
+};
+
+postcss([ svgo(opts) ]).process(css).then(function (result) {
+ console.log(result.css)
+});
+```
+
+You can view the [full list of plugins here][plugins].
+
+
+## Usage
+
+See the [PostCSS documentation](https://github.com/postcss/postcss#usage) for
+examples for your environment.
+
+
+## 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-svgo/commits?author=ben-eb) [๐Ÿ“–](https://github.com/ben-eb/postcss-svgo/commits?author=ben-eb) ๐Ÿ‘€ [โš ๏ธ](https://github.com/ben-eb/postcss-svgo/commits?author=ben-eb) | [<img src="https://avatars.githubusercontent.com/u/7263665?v=3" width="100px;"/><br /><sub>Sebastian Misch</sub>](https://sebastian-misch.de)<br />[๐Ÿ’ป](https://github.com/ben-eb/postcss-svgo/commits?author=sbstnmsch) [โš ๏ธ](https://github.com/ben-eb/postcss-svgo/commits?author=sbstnmsch) | [<img src="https://avatars.githubusercontent.com/u/11319202?v=3" width="100px;"/><br /><sub>ะ’ัั‡ะตัะปะฐะฒ ะ›ััˆะตะฝะบะพ</sub>](https://github.com/ophyros)<br />[๐Ÿ’ป](https://github.com/ben-eb/postcss-svgo/commits?author=ophyros) [โš ๏ธ](https://github.com/ben-eb/postcss-svgo/commits?author=ophyros) | [<img src="https://avatars.githubusercontent.com/u/1131567?v=3" width="100px;"/><br /><sub>shinnn</sub>](https://shinnn.github.io)<br />[๐Ÿ’ป](https://github.com/ben-eb/postcss-svgo/commits?author=shinnn) | [<img src="https://avatars.githubusercontent.com/u/45338?v=3" width="100px;"/><br /><sub>Jung-gun Lim</sub>](https://github.com/j6lim)<br />[๐Ÿ›](https://github.com/ben-eb/postcss-svgo/issues?q=author%3Aj6lim) | [<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-svgo/commits?author=TrySound) ๐Ÿ‘€ [โš ๏ธ](https://github.com/ben-eb/postcss-svgo/commits?author=TrySound) | [<img src="https://avatars.githubusercontent.com/u/368561?v=3" width="100px;"/><br /><sub>Piotr Walczyszyn</sub>](http://outof.me)<br />[๐Ÿ›](https://github.com/ben-eb/postcss-svgo/issues?q=author%3Apwalczyszyn) |
+| :---: | :---: | :---: | :---: | :---: | :---: | :---: |
+<!-- 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-svgo
+[deps]: https://gemnasium.com/ben-eb/postcss-svgo
+[npm]: http://badge.fury.io/js/postcss-svgo
+[postcss]: https://github.com/postcss/postcss
+[plugins]: https://github.com/svg/svgo/tree/master/plugins
diff --git a/node_modules/postcss-svgo/dist/index.js b/node_modules/postcss-svgo/dist/index.js
new file mode 100644
index 00000000..466a6356
--- /dev/null
+++ b/node_modules/postcss-svgo/dist/index.js
@@ -0,0 +1,108 @@
+'use strict';
+
+exports.__esModule = true;
+
+var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
+
+var _postcss = require('postcss');
+
+var _postcss2 = _interopRequireDefault(_postcss);
+
+var _postcssValueParser = require('postcss-value-parser');
+
+var _postcssValueParser2 = _interopRequireDefault(_postcssValueParser);
+
+var _svgo = require('svgo');
+
+var _svgo2 = _interopRequireDefault(_svgo);
+
+var _isSvg = require('is-svg');
+
+var _isSvg2 = _interopRequireDefault(_isSvg);
+
+var _url = require('./lib/url');
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+var PLUGIN = 'postcss-svgo';
+var dataURI = /data:image\/svg\+xml(;(charset=)?utf-8)?,/;
+
+function minifyPromise(svgo, decl, opts) {
+ var promises = [];
+
+ decl.value = (0, _postcssValueParser2.default)(decl.value).walk(function (node) {
+ if (node.type !== 'function' || node.value !== 'url' || !node.nodes.length) {
+ return;
+ }
+ var value = node.nodes[0].value;
+
+ var decodedUri = void 0,
+ isUriEncoded = void 0;
+
+ try {
+ decodedUri = (0, _url.decode)(value);
+ isUriEncoded = decodedUri !== value;
+ } catch (e) {
+ // Swallow exception if we cannot decode the value
+ isUriEncoded = false;
+ }
+
+ if (isUriEncoded) {
+ value = decodedUri;
+ }
+ if (opts.encode !== undefined) {
+ isUriEncoded = opts.encode;
+ }
+
+ var svg = value.replace(dataURI, '');
+
+ if (!(0, _isSvg2.default)(svg)) {
+ return;
+ }
+
+ promises.push(new Promise(function (resolve, reject) {
+ return svgo.optimize(svg, function (result) {
+ if (result.error) {
+ return reject(PLUGIN + ': ' + result.error);
+ }
+ var data = isUriEncoded ? (0, _url.encode)(result.data) : result.data;
+ // Should always encode # otherwise we yield a broken SVG
+ // in Firefox (works in Chrome however). See this issue:
+ // https://github.com/ben-eb/cssnano/issues/245
+ data = data.replace(/#/g, '%23');
+ node.nodes[0] = _extends({}, node.nodes[0], {
+ value: 'data:image/svg+xml;charset=utf-8,' + data,
+ quote: isUriEncoded ? '"' : '\'',
+ type: 'string',
+ before: '',
+ after: ''
+ });
+ return resolve();
+ });
+ }));
+
+ return false;
+ });
+
+ return Promise.all(promises).then(function () {
+ return decl.value = decl.value.toString();
+ });
+}
+
+exports.default = _postcss2.default.plugin(PLUGIN, function () {
+ var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
+
+ var svgo = new _svgo2.default(opts);
+ return function (css) {
+ return new Promise(function (resolve, reject) {
+ var promises = [];
+ css.walkDecls(function (decl) {
+ if (dataURI.test(decl.value)) {
+ promises.push(minifyPromise(svgo, decl, opts));
+ }
+ });
+ return Promise.all(promises).then(resolve, reject);
+ });
+ };
+});
+module.exports = exports['default']; \ No newline at end of file
diff --git a/node_modules/postcss-svgo/dist/lib/url.js b/node_modules/postcss-svgo/dist/lib/url.js
new file mode 100644
index 00000000..21aaa158
--- /dev/null
+++ b/node_modules/postcss-svgo/dist/lib/url.js
@@ -0,0 +1,9 @@
+'use strict';
+
+exports.__esModule = true;
+exports.encode = encode;
+function encode(data) {
+ return data.replace(/"/g, '\'').replace(/%/g, '%25').replace(/</g, '%3C').replace(/>/g, '%3E').replace(/&/g, '%26').replace(/#/g, '%23').replace(/\s+/g, ' ');
+};
+
+var decode = exports.decode = decodeURIComponent; \ No newline at end of file
diff --git a/node_modules/postcss-svgo/node_modules/.bin/svgo b/node_modules/postcss-svgo/node_modules/.bin/svgo
new file mode 120000
index 00000000..a8d8be9a
--- /dev/null
+++ b/node_modules/postcss-svgo/node_modules/.bin/svgo
@@ -0,0 +1 @@
+../../../svgo/bin/svgo \ No newline at end of file
diff --git a/node_modules/postcss-svgo/package.json b/node_modules/postcss-svgo/package.json
new file mode 100644
index 00000000..a5ebd016
--- /dev/null
+++ b/node_modules/postcss-svgo/package.json
@@ -0,0 +1,67 @@
+{
+ "name": "postcss-svgo",
+ "version": "2.1.6",
+ "description": "Optimise inline SVG with PostCSS.",
+ "main": "dist/index.js",
+ "scripts": {
+ "contributorAdd": "all-contributors add",
+ "contributorGenerate": "all-contributors generate",
+ "pretest": "eslint src",
+ "prepublish": "del-cli dist && BABEL_ENV=publish babel src --out-dir dist --ignore /__tests__/",
+ "report": "nyc report --reporter=html",
+ "test": "nyc --reporter=text ava src/__tests__",
+ "test-012": "nyc --reporter=text ava src/__tests__"
+ },
+ "files": [
+ "LICENSE-MIT",
+ "dist"
+ ],
+ "keywords": [
+ "css",
+ "minify",
+ "optimise",
+ "postcss",
+ "postcss-plugin",
+ "svg",
+ "svgo"
+ ],
+ "license": "MIT",
+ "devDependencies": {
+ "all-contributors-cli": "^3.0.5",
+ "ava": "^0.16.0",
+ "babel-cli": "^6.4.5",
+ "babel-core": "^6.4.5",
+ "babel-plugin-add-module-exports": "^0.2.0",
+ "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",
+ "coveralls": "^2.11.6",
+ "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",
+ "nyc": "^10.0.0",
+ "pleeease-filters": "^3.0.0"
+ },
+ "homepage": "https://github.com/ben-eb/postcss-svgo",
+ "author": {
+ "name": "Ben Briggs",
+ "email": "beneb.info@gmail.com",
+ "url": "http://beneb.info"
+ },
+ "repository": "ben-eb/postcss-svgo",
+ "dependencies": {
+ "is-svg": "^2.0.0",
+ "postcss": "^5.0.14",
+ "postcss-value-parser": "^3.2.3",
+ "svgo": "^0.7.0"
+ },
+ "ava": {
+ "require": "babel-register"
+ },
+ "eslintConfig": {
+ "extends": "cssnano"
+ }
+}