Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

postcss-svgo

Package Overview
Dependencies
Maintainers
7
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-svgo - npm Package Compare versions

Comparing version 5.0.0-rc.1 to 5.0.0-rc.2

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

# [5.0.0-rc.2](https://github.com/cssnano/cssnano/compare/postcss-svgo@5.0.0-rc.1...postcss-svgo@5.0.0-rc.2) (2021-03-15)
### Bug Fixes
* update SVGO ([aa07cfd](https://github.com/cssnano/cssnano/commit/aa07cfd62c82ed4b1e87219eea8d0ed99635e4ca))
# [5.0.0-rc.1](https://github.com/cssnano/cssnano/compare/postcss-svgo@5.0.0-rc.0...postcss-svgo@5.0.0-rc.1) (2021-03-04)

@@ -8,0 +19,0 @@

83

dist/index.js

@@ -10,3 +10,3 @@ "use strict";

var _svgo = _interopRequireDefault(require("svgo"));
var _svgo = require("svgo");

@@ -23,4 +23,3 @@ var _isSvg = _interopRequireDefault(require("is-svg"));

function minifyPromise(decl, getSvgo, opts) {
const promises = [];
function minify(decl, opts) {
const parsed = (0, _postcssValueParser.default)(decl.value);

@@ -68,44 +67,42 @@ decl.value = parsed.walk(node => {

promises.push(getSvgo().optimize(svg).then(result => {
let data, optimizedValue;
let result;
if (isBase64) {
data = Buffer.from(result.data).toString('base64');
optimizedValue = 'data:image/svg+xml;base64,' + data + url.hash;
} 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
try {
result = (0, _svgo.optimize)(svg, opts);
data = data.replace(/#/g, '%23');
optimizedValue = 'data:image/svg+xml;charset=utf-8,' + data;
quote = isUriEncoded ? '"' : "'";
if (result.error) {
throw new Error(`${PLUGIN}: ${result.error}`);
}
} catch (error) {
throw new Error(`${PLUGIN}: ${error}`);
}
node.nodes[0] = Object.assign({}, node.nodes[0], {
value: optimizedValue,
quote: quote,
type: 'string',
before: '',
after: ''
});
}).catch(error => {
throw new Error(`${PLUGIN}: ${error}`);
}));
let data, optimizedValue;
if (isBase64) {
data = Buffer.from(result.data).toString('base64');
optimizedValue = 'data:image/svg+xml;base64,' + data + url.hash;
} 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: ''
});
return false;
});
return Promise.all(promises).then(() => decl.value = decl.value.toString());
decl.value = decl.value.toString();
}
function pluginCreator(opts = {}) {
let svgo = null;
const getSvgo = () => {
if (!svgo) {
svgo = new _svgo.default(opts);
}
return svgo;
};
return {

@@ -115,12 +112,8 @@ postcssPlugin: PLUGIN,

OnceExit(css) {
return new Promise((resolve, reject) => {
const svgoQueue = [];
css.walkDecls(decl => {
if (!dataURI.test(decl.value)) {
return;
}
css.walkDecls(decl => {
if (!dataURI.test(decl.value)) {
return;
}
svgoQueue.push(minifyPromise(decl, getSvgo, opts));
});
return Promise.all(svgoQueue).then(resolve, reject);
minify(decl, opts);
});

@@ -127,0 +120,0 @@ }

{
"name": "postcss-svgo",
"version": "5.0.0-rc.1",
"version": "5.0.0-rc.2",
"description": "Optimise inline SVG with PostCSS.",

@@ -35,3 +35,3 @@ "main": "dist/index.js",

"postcss-value-parser": "^4.1.0",
"svgo": "^1.3.2"
"svgo": "^2.2.2"
},

@@ -50,3 +50,3 @@ "bugs": {

},
"gitHead": "114efb0092fff944dd4c8a28d184add24d8fde3e"
"gitHead": "5ba19ca54892f76ba6b2b698b4d88adcabd4451b"
}

@@ -46,18 +46,2 @@ # [postcss][postcss]-svgo

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

@@ -64,0 +48,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc