flow like the river
This commit is contained in:
commit
013fe673f3
42435 changed files with 5764238 additions and 0 deletions
22
BACK_BACK/node_modules/postcss-svgo/LICENSE-MIT
generated
vendored
Executable file
22
BACK_BACK/node_modules/postcss-svgo/LICENSE-MIT
generated
vendored
Executable 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.
|
||||
126
BACK_BACK/node_modules/postcss-svgo/README.md
generated
vendored
Executable file
126
BACK_BACK/node_modules/postcss-svgo/README.md
generated
vendored
Executable file
|
|
@ -0,0 +1,126 @@
|
|||
# [postcss][postcss]-svgo
|
||||
|
||||
> 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>');
|
||||
}
|
||||
|
||||
h2 {
|
||||
background: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iTGF5ZXJfMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+PGNpcmNsZSBjeD0iNTAiIGN5PSI1MCIgcj0iNDAiIGZpbGw9InllbGxvdyIgLz48IS0tdGVzdCBjb21tZW50LS0+PC9zdmc+');
|
||||
}
|
||||
```
|
||||
|
||||
### 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>');
|
||||
}
|
||||
|
||||
h2 {
|
||||
background: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxjaXJjbGUgY3g9IjUwIiBjeT0iNTAiIHI9IjQwIiBmaWxsPSIjZmYwIi8+PC9zdmc+');
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## 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
|
||||
|
||||
See [CONTRIBUTORS.md](https://github.com/cssnano/cssnano/blob/master/CONTRIBUTORS.md).
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Ben Briggs](http://beneb.info)
|
||||
|
||||
[postcss]: https://github.com/postcss/postcss
|
||||
[plugins]: https://github.com/svg/svgo/tree/master/plugins
|
||||
127
BACK_BACK/node_modules/postcss-svgo/dist/index.js
generated
vendored
Executable file
127
BACK_BACK/node_modules/postcss-svgo/dist/index.js
generated
vendored
Executable file
|
|
@ -0,0 +1,127 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
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 _url = require('./lib/url');
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
const PLUGIN = 'postcss-svgo';
|
||||
const dataURI = /data:image\/svg\+xml(;((charset=)?utf-8|base64))?,/i;
|
||||
const dataURIBase64 = /data:image\/svg\+xml;base64,/i;
|
||||
|
||||
function minifyPromise(decl, getSvgo, opts, postcssResult) {
|
||||
const promises = [];
|
||||
const parsed = (0, _postcssValueParser2.default)(decl.value);
|
||||
|
||||
decl.value = parsed.walk(node => {
|
||||
if (node.type !== 'function' || node.value.toLowerCase() !== 'url' || !node.nodes.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
let { value, quote } = node.nodes[0];
|
||||
let isBase64, isUriEncoded;
|
||||
let svg = value.replace(dataURI, '');
|
||||
|
||||
if (dataURIBase64.test(value)) {
|
||||
svg = Buffer.from(svg, 'base64').toString('utf8');
|
||||
isBase64 = true;
|
||||
} else {
|
||||
let decodedUri;
|
||||
|
||||
try {
|
||||
decodedUri = (0, _url.decode)(svg);
|
||||
isUriEncoded = decodedUri !== svg;
|
||||
} catch (e) {
|
||||
// Swallow exception if we cannot decode the value
|
||||
isUriEncoded = false;
|
||||
}
|
||||
|
||||
if (isUriEncoded) {
|
||||
svg = decodedUri;
|
||||
}
|
||||
|
||||
if (opts.encode !== undefined) {
|
||||
isUriEncoded = opts.encode;
|
||||
}
|
||||
}
|
||||
|
||||
promises.push(getSvgo().optimize(svg).then(result => {
|
||||
if (result.error) {
|
||||
decl.warn(postcssResult, `${result.error}`);
|
||||
return;
|
||||
}
|
||||
let data, optimizedValue;
|
||||
|
||||
if (isBase64) {
|
||||
data = Buffer.from(result.data).toString('base64');
|
||||
optimizedValue = 'data:image/svg+xml;base64,' + data;
|
||||
} else {
|
||||
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/cssnano/cssnano/issues/245
|
||||
data = data.replace(/#/g, '%23');
|
||||
optimizedValue = 'data:image/svg+xml;charset=utf-8,' + data;
|
||||
quote = isUriEncoded ? '"' : '\'';
|
||||
}
|
||||
|
||||
node.nodes[0] = Object.assign({}, node.nodes[0], {
|
||||
value: optimizedValue,
|
||||
quote: quote,
|
||||
type: 'string',
|
||||
before: '',
|
||||
after: ''
|
||||
});
|
||||
}).catch(error => {
|
||||
decl.warn(postcssResult, `${error}`);
|
||||
}));
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
return Promise.all(promises).then(() => decl.value = decl.value.toString());
|
||||
}
|
||||
|
||||
exports.default = _postcss2.default.plugin(PLUGIN, (opts = {}) => {
|
||||
let svgo = null;
|
||||
|
||||
const getSvgo = () => {
|
||||
if (!svgo) {
|
||||
svgo = new _svgo2.default(opts);
|
||||
}
|
||||
|
||||
return svgo;
|
||||
};
|
||||
|
||||
return (css, result) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const svgoQueue = [];
|
||||
|
||||
css.walkDecls(decl => {
|
||||
if (!dataURI.test(decl.value)) {
|
||||
return;
|
||||
}
|
||||
|
||||
svgoQueue.push(minifyPromise(decl, getSvgo, opts, result));
|
||||
});
|
||||
|
||||
return Promise.all(svgoQueue).then(resolve, reject);
|
||||
});
|
||||
};
|
||||
});
|
||||
module.exports = exports['default'];
|
||||
11
BACK_BACK/node_modules/postcss-svgo/dist/lib/url.js
generated
vendored
Executable file
11
BACK_BACK/node_modules/postcss-svgo/dist/lib/url.js
generated
vendored
Executable file
|
|
@ -0,0 +1,11 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: 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, ' ');
|
||||
};
|
||||
|
||||
const decode = exports.decode = decodeURIComponent;
|
||||
46
BACK_BACK/node_modules/postcss-svgo/package.json
generated
vendored
Executable file
46
BACK_BACK/node_modules/postcss-svgo/package.json
generated
vendored
Executable file
|
|
@ -0,0 +1,46 @@
|
|||
{
|
||||
"name": "postcss-svgo",
|
||||
"version": "4.0.3",
|
||||
"description": "Optimise inline SVG with PostCSS.",
|
||||
"main": "dist/index.js",
|
||||
"scripts": {
|
||||
"prepublish": "cross-env BABEL_ENV=publish babel src --out-dir dist --ignore /__tests__/"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE-MIT",
|
||||
"dist"
|
||||
],
|
||||
"keywords": [
|
||||
"css",
|
||||
"minify",
|
||||
"optimise",
|
||||
"postcss",
|
||||
"postcss-plugin",
|
||||
"svg",
|
||||
"svgo"
|
||||
],
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"babel-cli": "^6.0.0",
|
||||
"cross-env": "^5.0.0",
|
||||
"pleeease-filters": "^4.0.0"
|
||||
},
|
||||
"homepage": "https://github.com/cssnano/cssnano",
|
||||
"author": {
|
||||
"name": "Ben Briggs",
|
||||
"email": "beneb.info@gmail.com",
|
||||
"url": "http://beneb.info"
|
||||
},
|
||||
"repository": "cssnano/cssnano",
|
||||
"dependencies": {
|
||||
"postcss": "^7.0.0",
|
||||
"postcss-value-parser": "^3.0.0",
|
||||
"svgo": "^1.0.0"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/cssnano/cssnano/issues"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue