Socket
Socket
Sign inDemoInstall

svg-crowbar

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svg-crowbar - npm Package Compare versions

Comparing version 0.5.0 to 0.6.0-0

6

dist/cjs/png.js

@@ -15,6 +15,7 @@ "use strict";

var canvas = document.createElement('canvas');
var dpr = window.devicePixelRatio || 1;
document.body.appendChild(canvas);
canvas.setAttribute('id', 'svg-image');
canvas.setAttribute('width', source.width);
canvas.setAttribute('height', source.height);
canvas.setAttribute('width', source.width * dpr);
canvas.setAttribute('height', source.height * dpr);
canvas.style.display = 'none';

@@ -29,2 +30,3 @@ var context = canvas.getContext('2d');

function onLoad() {
context.scale(dpr, dpr);
context.drawImage(image, 0, 0);

@@ -31,0 +33,0 @@ var canvasdata = canvas.toDataURL('image/png');

@@ -7,6 +7,7 @@ import { commenceDownload } from './util';

var canvas = document.createElement('canvas');
var dpr = window.devicePixelRatio || 1;
document.body.appendChild(canvas);
canvas.setAttribute('id', 'svg-image');
canvas.setAttribute('width', source.width);
canvas.setAttribute('height', source.height);
canvas.setAttribute('width', source.width * dpr);
canvas.setAttribute('height', source.height * dpr);
canvas.style.display = 'none';

@@ -21,2 +22,3 @@ var context = canvas.getContext('2d');

function onLoad() {
context.scale(dpr, dpr);
context.drawImage(image, 0, 0);

@@ -23,0 +25,0 @@ var canvasdata = canvas.toDataURL('image/png');

@@ -1,1 +0,1 @@

!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n=e();for(var o in n)("object"==typeof exports?exports:t)[o]=n[o]}}(this,(function(){return function(t){var e={};function n(o){if(e[o])return e[o].exports;var r=e[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(o,r,function(e){return t[e]}.bind(null,r));return o},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";n.r(e),n.d(e,"downloadPng",(function(){return a}));const o="http://www.w3.org/2000/xmlns/",r="http://www.w3.org/1999/xlink",i="http://www.w3.org/2000/svg";var u=function(t,{css:e="inline"}={}){if(!(t instanceof SVGElement))throw new Error("SVG element is required");t.setAttribute("version","1.1"),t.removeAttribute("xmlns"),t.removeAttribute("xlink"),t.hasAttributeNS(o,"xmlns")||t.setAttributeNS(o,"xmlns",i),t.hasAttributeNS(o,"xmlns:xlink")||t.setAttributeNS(o,"xmlns:xlink",r),"inline"===e?function(t,e){function n(t){const n=getComputedStyle(t);let o,r,i="";for(let t=0,u=n.length;t<u;t++)o=n[t],r=n.getPropertyValue(o),r!==e.getPropertyValue(o)&&(i+=`${o}:${r};`);t.setAttribute("style",i)}const o=function(t){const e=[];return e.push(t),function t(n){if(n&&n.hasChildNodes()){let o=n.firstChild;for(;o;)1===o.nodeType&&"SCRIPT"!==o.nodeName&&(e.push(o),t(o)),o=o.nextSibling}}(t),e}(t);let r=o.length;for(;r--;)n(o[r])}(t,function(){let t=document.createElementNS(i,"svg");document.body.appendChild(t),t.style.all="initial";const e=getComputedStyle(t);return document.body.removeChild(t),t=null,e}()):"internal"===e&&function(t){const e=document.createElement("style");e.innerHTML=Array.from(document.styleSheets).map(t=>Array.from(t.cssRules).map(t=>t.cssText).join(" ")).join(" "),t.prepend(e)}(t);const n=(new XMLSerializer).serializeToString(t),u=t.getBoundingClientRect();return{top:u.top,left:u.left,width:u.width,height:u.height,class:t.getAttribute("class"),id:t.getAttribute("id"),name:t.getAttribute("name"),childElementCount:t.childElementCount,source:'<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">'+n}};function l(t){if(!(t instanceof SVGElement))throw new Error("SVG Element is required");return t.getAttribute("id")||t.getAttribute("class")||document.title.replace(/[^a-z0-9]/gi,"-").toLowerCase()||"untitled"}function s(t,e,n){const o=document.createElement("a");document.body.appendChild(o),o.setAttribute("class","svg-crowbar"),o.setAttribute("download",t),o.setAttribute("href",e),o.style.display="none",o.click(),setTimeout(()=>{n&&n(),document.body.removeChild(o)},10)}var c=function(t,e="untitled"){const n=URL.createObjectURL(new Blob([t.source],{type:"text/xml"}));s(`${e}.svg`,n,()=>URL.revokeObjectURL(n))};var d=function(t,e="untitled"){const n=document.createElement("canvas");document.body.appendChild(n),n.setAttribute("id","svg-image"),n.setAttribute("width",t.width),n.setAttribute("height",t.height),n.style.display="none";const o=n.getContext("2d"),r=t.source.replace(/[\u00A0-\u2666]/g,t=>`&#${t.charCodeAt(0)};`),i=`data:image/svg+xml;base64,${btoa(r)}`,u=new Image;u.onload=function(){o.drawImage(u,0,0);const t=n.toDataURL("image/png");s(`${e}.png`,t,()=>document.body.removeChild(n))},u.src=i};e.default=(t,e,n)=>c(u(t,n),e||l(t));const a=(t,e,n)=>d(u(t,n),e||l(t))}])}));
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var o in n)("object"==typeof exports?exports:e)[o]=n[o]}}(this,(function(){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";n.r(t),n.d(t,"downloadPng",(function(){return a}));const o="http://www.w3.org/2000/xmlns/",r="http://www.w3.org/1999/xlink",i="http://www.w3.org/2000/svg";var u=function(e,{css:t="inline"}={}){if(!(e instanceof SVGElement))throw new Error("SVG element is required");e.setAttribute("version","1.1"),e.removeAttribute("xmlns"),e.removeAttribute("xlink"),e.hasAttributeNS(o,"xmlns")||e.setAttributeNS(o,"xmlns",i),e.hasAttributeNS(o,"xmlns:xlink")||e.setAttributeNS(o,"xmlns:xlink",r),"inline"===t?function(e,t){function n(e){const n=getComputedStyle(e);let o,r,i="";for(let e=0,u=n.length;e<u;e++)o=n[e],r=n.getPropertyValue(o),r!==t.getPropertyValue(o)&&(i+=`${o}:${r};`);e.setAttribute("style",i)}const o=function(e){const t=[];return t.push(e),function e(n){if(n&&n.hasChildNodes()){let o=n.firstChild;for(;o;)1===o.nodeType&&"SCRIPT"!==o.nodeName&&(t.push(o),e(o)),o=o.nextSibling}}(e),t}(e);let r=o.length;for(;r--;)n(o[r])}(e,function(){let e=document.createElementNS(i,"svg");document.body.appendChild(e),e.style.all="initial";const t=getComputedStyle(e);return document.body.removeChild(e),e=null,t}()):"internal"===t&&function(e){const t=document.createElement("style");t.innerHTML=Array.from(document.styleSheets).map(e=>Array.from(e.cssRules).map(e=>e.cssText).join(" ")).join(" "),e.prepend(t)}(e);const n=(new XMLSerializer).serializeToString(e),u=e.getBoundingClientRect();return{top:u.top,left:u.left,width:u.width,height:u.height,class:e.getAttribute("class"),id:e.getAttribute("id"),name:e.getAttribute("name"),childElementCount:e.childElementCount,source:'<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">'+n}};function l(e){if(!(e instanceof SVGElement))throw new Error("SVG Element is required");return e.getAttribute("id")||e.getAttribute("class")||document.title.replace(/[^a-z0-9]/gi,"-").toLowerCase()||"untitled"}function s(e,t,n){const o=document.createElement("a");document.body.appendChild(o),o.setAttribute("class","svg-crowbar"),o.setAttribute("download",e),o.setAttribute("href",t),o.style.display="none",o.click(),setTimeout(()=>{n&&n(),document.body.removeChild(o)},10)}var c=function(e,t="untitled"){const n=URL.createObjectURL(new Blob([e.source],{type:"text/xml"}));s(t+".svg",n,()=>URL.revokeObjectURL(n))};var d=function(e,t="untitled"){const n=document.createElement("canvas"),o=window.devicePixelRatio||1;document.body.appendChild(n),n.setAttribute("id","svg-image"),n.setAttribute("width",e.width*o),n.setAttribute("height",e.height*o),n.style.display="none";const r=n.getContext("2d"),i=e.source.replace(/[\u00A0-\u2666]/g,e=>`&#${e.charCodeAt(0)};`),u="data:image/svg+xml;base64,"+btoa(i),l=new Image;l.onload=function(){r.scale(o,o),r.drawImage(l,0,0);const e=n.toDataURL("image/png");s(t+".png",e,()=>document.body.removeChild(n))},l.src=u};t.default=(e,t,n)=>c(u(e,n),t||l(e));const a=(e,t,n)=>d(u(e,n),t||l(e))}])}));
{
"name": "svg-crowbar",
"version": "0.5.0",
"version": "0.6.0-0",
"description": "A library based on a Chrome-specific bookmarklet that extracts SVG nodes and accompanying styles from an HTML document and downloads them as an SVG file",

@@ -33,18 +33,18 @@ "main": "./dist/cjs/index.js",

},
"homepage": "https://github.com/cy6erskunk/svg-crowbar#readme",
"homepage": "https://svg-crowbar.js.org/",
"devDependencies": {
"@babel/cli": "^7.8.4",
"@babel/core": "7.9.0",
"@babel/preset-env": "7.9.5",
"@babel/cli": "7.8.4",
"@babel/core": "7.9.6",
"@babel/preset-env": "7.9.6",
"@cyberskunk/eslint-config": "1.0.0",
"@jest-runner/electron": "2.0.3",
"@jest-runner/electron": "3.0.0",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "10.1.0",
"babel-jest": "25.3.0",
"electron": "8.2.3",
"eslint": "6.8.0",
"babel-jest": "26.0.1",
"electron": "9.0.0",
"eslint": "7.0.0",
"eslint-config-prettier": "6.11.0",
"eslint-plugin-prettier": "3.1.3",
"jest": "25.3.0",
"prettier": "1.19.1",
"jest": "26.0.1",
"prettier": "2.0.5",
"webpack": "4.43.0",

@@ -51,0 +51,0 @@ "webpack-cli": "3.3.11"

@@ -5,2 +5,3 @@ # SVG Crowbar Library

[![Build Status](https://travis-ci.com/cy6erskunk/svg-crowbar.svg?branch=master)](https://travis-ci.com/cy6erskunk/svg-crowbar)
![Copy README to gh-pages branch](https://github.com/cy6erskunk/svg-crowbar/workflows/Copy%20README%20to%20gh-pages%20branch/badge.svg)

@@ -34,2 +35,4 @@ A standalone 3.5Kb JS client library based on Chrome [bookmarklet](https://nytimes.github.io/svg-crowbar/).

### Options
- **svgElement** *(required)*

@@ -36,0 +39,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