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

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.6.1 to 0.6.2

24

dist/cjs/png.js

@@ -12,2 +12,24 @@ "use strict";

function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
function toBinary(string) {
var codeUnits = new Uint16Array(string.length);
for (var i = 0; i < codeUnits.length; i++) {
codeUnits[i] = string.charCodeAt(i);
}
return String.fromCharCode.apply(String, _toConsumableArray(new Uint8Array(codeUnits.buffer)));
}
function downloadPng(source) {

@@ -26,3 +48,3 @@ var filename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _const.DEFAULT_FILENAME;

});
var imgsrc = "data:image/svg+xml;base64,".concat(btoa(safeSource));
var imgsrc = "data:image/svg+xml;base64,".concat(btoa(toBinary(safeSource)));
var image = new Image();

@@ -29,0 +51,0 @@

@@ -0,4 +1,26 @@

function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
import { commenceDownload } from './util';
import { DEFAULT_FILENAME } from './const';
function toBinary(string) {
var codeUnits = new Uint16Array(string.length);
for (var i = 0; i < codeUnits.length; i++) {
codeUnits[i] = string.charCodeAt(i);
}
return String.fromCharCode.apply(String, _toConsumableArray(new Uint8Array(codeUnits.buffer)));
}
function downloadPng(source) {

@@ -17,3 +39,3 @@ var filename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_FILENAME;

});
var imgsrc = "data:image/svg+xml;base64,".concat(btoa(safeSource));
var imgsrc = "data:image/svg+xml;base64,".concat(btoa(toBinary(safeSource)));
var image = new Image();

@@ -20,0 +42,0 @@

2

dist/main.js

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

!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,"downloadSvg",(function(){return a})),n.d(t,"downloadPng",(function(){return f}));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};const a=(e,t,n)=>c(u(e,n),t||l(e));t.default=a;const f=(e,t,n)=>d(u(e,n),t||l(e))}])}));
!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(()=>{"use strict";var e={866:(e,t,n)=>{n.r(t),n.d(t,{default:()=>d,downloadPng:()=>c,downloadSvg:()=>u});const o="http://www.w3.org/2000/xmlns/",r="http://www.w3.org/2000/svg",i=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",r),e.hasAttributeNS(o,"xmlns:xlink")||e.setAttributeNS(o,"xmlns:xlink","http://www.w3.org/1999/xlink"),"inline"===t?function(e,t){function n(e){const n=getComputedStyle(e);let o,r,i="";for(let e=0,l=n.length;e<l;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(r,"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),i=e.getBoundingClientRect();return{top:i.top,left:i.left,width:i.width,height:i.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)}const u=(e,t,n)=>function(e,t="untitled"){const n=URL.createObjectURL(new Blob([e.source],{type:"text/xml"}));s(`${t}.svg`,n,(()=>URL.revokeObjectURL(n)))}(i(e,n),t||l(e)),d=u,c=(e,t,n)=>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)};`)),l=`data:image/svg+xml;base64,${btoa(function(e){const t=new Uint16Array(e.length);for(let n=0;n<t.length;n++)t[n]=e.charCodeAt(n);return String.fromCharCode(...new Uint8Array(t.buffer))}(i))}`,u=new Image;u.onload=function(){r.scale(o,o),r.drawImage(u,0,0);const e=n.toDataURL("image/png");s(`${t}.png`,e,(()=>document.body.removeChild(n)))},u.src=l}(i(e,n),t||l(e))}},t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={exports:{}};return e[o](r,r.exports,n),r.exports}return n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n(866)})()}));
{
"name": "svg-crowbar",
"version": "0.6.1",
"version": "0.6.2",
"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",

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

"test": "BABEL_ENV=commonjs jest",
"test-ci": "BABEL_ENV=commonjs jest --runInBand",
"test-ci": "BABEL_ENV=commonjs jest --runInBand --forceExit",
"lint": "eslint ./src ./test",

@@ -18,7 +18,7 @@ "lint-fix": "eslint --fix ./src",

"build": "npm run clean && npm run build-umd && npm run build-cjs && npm run build-esm",
"build-umd": "webpack src/index.js --mode=production",
"build-umd-dev": "webpack src/index.js --mode=development",
"build-umd": "webpack ./src/index.js --mode=production",
"build-umd-dev": "webpack ./src/index.js --mode=development",
"build-cjs": "BABEL_ENV=commonjs babel src/* --out-dir dist/cjs --copy-files",
"build-esm": "BABEL_ENV=esmodules babel src/* --out-dir dist/esm --copy-files",
"prepublishOnly": "npm test && npm run build"
"prepublishOnly": "npm run test-ci && npm run build"
},

@@ -37,5 +37,5 @@ "repository": "git+https://github.com/cy6erskunk/svg-crowbar.git",

"devDependencies": {
"@babel/cli": "7.11.6",
"@babel/core": "7.11.6",
"@babel/preset-env": "7.11.5",
"@babel/cli": "7.12.8",
"@babel/core": "7.12.9",
"@babel/preset-env": "7.12.7",
"@cyberskunk/eslint-config": "1.0.0",

@@ -45,11 +45,11 @@ "@jest-runner/electron": "3.0.0",

"babel-eslint": "10.1.0",
"babel-jest": "26.3.0",
"electron": "10.1.1",
"eslint": "7.8.1",
"eslint-config-prettier": "6.11.0",
"eslint-plugin-prettier": "3.1.4",
"jest": "26.4.2",
"prettier": "2.1.1",
"webpack": "4.44.1",
"webpack-cli": "3.3.12"
"babel-jest": "26.6.3",
"electron": "10.1.6",
"eslint": "7.15.0",
"eslint-config-prettier": "6.15.0",
"eslint-plugin-prettier": "3.2.0",
"jest": "26.6.3",
"prettier": "2.2.1",
"webpack": "5.10.0",
"webpack-cli": "4.2.0"
},

@@ -56,0 +56,0 @@ "jest": {

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