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

save-html-as-image-enhanced

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

save-html-as-image-enhanced - npm Package Compare versions

Comparing version 1.7.4 to 1.7.5

2

dist/index.js

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

var t=require("html-to-image"),e=require("save-svg-as-png"),n=require("file-saver");function r(){return(r=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function i(t,e){var n;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return o(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=t[Symbol.iterator]()).next.bind(n)}var u=/*#__PURE__*/"undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function a(t,e,n){if(!t.s){if(n instanceof l){if(!n.s)return void(n.o=a.bind(null,t,e));1&e&&(e=n.s),n=n.v}if(n&&n.then)return void n.then(a.bind(null,t,e),a.bind(null,t,2));t.s=e,t.v=n;var r=t.o;r&&r(t)}}var l=/*#__PURE__*/function(){function t(){}return t.prototype.then=function(e,n){var r=new t,o=this.s;if(o){var i=1&o?e:n;if(i){try{a(r,1,i(this.v))}catch(t){a(r,2,t)}return r}return this}return this.o=function(t){try{var o=t.v;1&t.s?a(r,1,e?e(o):o):n?a(r,1,n(o)):a(r,2,o)}catch(t){a(r,2,t)}},r},t}();function c(t){return t instanceof l&&1&t.s}var f={filename:"Image",forceFixText:!1,printDate:!0},s=function(t){var e=window.getComputedStyle(t);t.style.color=e.color},h=function(t){var e=window.getComputedStyle(t);t.style.width=e.width,t.style.height=e.height},d=function(t,e){void 0===e&&(e=["b","h1","h2","h3","h4","h5","h6","i","mark","p","small","strong"]);for(var n,r=i(t.querySelectorAll(e));!(n=r()).done;){var o=n.value;o.style.fontFamily=window.getComputedStyle(o).fontFamily,o.style.fontSize=window.getComputedStyle(o).fontSize,o.style.fontWeight=window.getComputedStyle(o).fontWeight,o.style.width=window.getComputedStyle(o).width}},v=function(t){return"hide-when-downloading"!==t.className},y=function(t,o,v,y){void 0===y&&(y="png");try{var g=function(){!function(t){for(var e,n=i(t.querySelectorAll([".remove-when-downloading"]));!(e=n()).done;){var r=e.value;r.style.display=r.getAttribute("original_display")}}(t),n.saveAs(m,function(t){if(t.printDate){var e=(new Date).toDateString();return t.filename+" ("+e+")"}return t.filename||"Image"}(p)+"."+y)},p=function(t){return r({},f,t)}(o||{}),m=null;(function(t,e){void 0===e&&(e=!1);var n=t.querySelectorAll("svg");!function(t){d(t,[".fixed-text"])}(t),e&&d(t);for(var r,o=i(n);!(r=o()).done;){var u=r.value;s(u),h(u)}})(t,p.forceFixText),function(t){for(var e,n=i(t.querySelectorAll([".remove-when-downloading"]));!(e=n()).done;){var r=e.value;r.setAttribute("original_display",window.getComputedStyle(r).display),r.style.display="none"}}(t),function(t){for(var e,n=i(t.querySelectorAll([".show-when-downloading"]));!(e=n()).done;){var r=e.value;r.setAttribute("original_display",window.getComputedStyle(r).display),r.style.display="inherit"}}(t);var w=function(t,e){try{var n=Promise.resolve(v()).then(function(t){m=t})}catch(t){return e()}return n&&n.then?n.then(void 0,e):n}(0,function(){return Promise.resolve(function(t){try{var n=t.querySelectorAll("svg"),r=[],o=function(t,e,n){if("function"==typeof t[u]){var r,o,i,f=t[u]();if(function t(n){try{for(;!(r=f.next()).done;)if((n=e(r.value))&&n.then){if(!c(n))return void n.then(t,i||(i=a.bind(null,o=new l,2)));n=n.v}o?a(o,1,n):o=n}catch(t){a(o||(o=new l),2,t)}}(),f.return){var s=function(t){try{r.done||f.return()}catch(t){}return t};if(o&&o.then)return o.then(s,function(t){throw s(t)});s()}return o}if(!("length"in t))throw new TypeError("Object is not iterable");for(var h=[],d=0;d<t.length;d++)h.push(t[d]);return function(t,e,n){var r,o,i=-1;return function n(u){try{for(;++i<t.length;)if((u=e(i))&&u.then){if(!c(u))return void u.then(n,o||(o=a.bind(null,r=new l,2)));u=u.v}r?a(r,1,u):r=u}catch(t){a(r||(r=new l),2,t)}}(),r}(h,function(t){return e(h[t])})}(n,function(t){function n(){u.dataset.icon=o,u.width=t.clientWidth,u.height=t.clientHeight,t.replaceWith(u)}var o=t.getAttribute("data-icon"),i=r.find(function(t){return t.dataIcon===o}),u=document.createElement("img"),a=function(){if(!i)return Promise.resolve(e.svgAsPngUri(t,"icon.png")).then(function(t){u.src=t,r.push({dataIcon:o,uri:t})});u.src=i.uri}();return a&&a.then?a.then(n):n()});return Promise.resolve(o&&o.then?o.then(function(){}):void 0)}catch(t){return Promise.reject(t)}}(t)).then(function(){return Promise.resolve(v()).then(function(){return Promise.resolve(v()).then(function(t){m=t})})})});return Promise.resolve(w&&w.then?w.then(g):g())}catch(t){return Promise.reject(t)}},g=function(t,e,n){void 0===n&&(n="png");var o=e.backgroundColor,i=e.quality,u=e.pixelRatio,a=e.style,l=r({},function(t,e){if(e.width&&e.height)return{width:e.width,height:e.height};var n=window.getComputedStyle(t),r=n.height;return{width:Number.parseInt(n.width.replace("px",""),10)+4,height:Number.parseInt(r.replace("px",""),10)+4}}(t,e),{pixelRatio:1});return a&&(l=r({},l,{style:a})),o&&(l=r({},l,{backgroundColor:o})),u&&u>0&&(l=r({},l,{pixelRatio:u})),i&&n.includes("jpeg")&&(l=r({},l,{quality:i>=0&&i<=1?i:1})),l||{}},p=function(e,n,o){void 0===n&&(n={}),void 0===o&&(o={});try{return Promise.resolve(y(e,n,function(){return t.toPng(e,r({filter:v},g(e,o,"png")))},"png")).then(function(){})}catch(t){return Promise.reject(t)}};exports.downloadDOM=function(t,e,n){void 0===e&&(e="Image"),void 0===n&&(n=!1);try{return Promise.resolve(p(t,{forceFixText:n,filename:e})).then(function(){})}catch(t){return Promise.reject(t)}},exports.saveAsJpeg=function(e,n,o){void 0===n&&(n={}),void 0===o&&(o={});try{return Promise.resolve(y(e,n,function(){return t.toJpeg(e,r({filter:v},g(e,o,"jpeg")))},"jpeg")).then(function(){})}catch(t){return Promise.reject(t)}},exports.saveAsPng=p;
var t=require("html-to-image"),e=require("save-svg-as-png"),n=require("file-saver");function r(){return(r=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function i(t,e){var n;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return o(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=t[Symbol.iterator]()).next.bind(n)}var u=/*#__PURE__*/"undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function a(t,e,n){if(!t.s){if(n instanceof l){if(!n.s)return void(n.o=a.bind(null,t,e));1&e&&(e=n.s),n=n.v}if(n&&n.then)return void n.then(a.bind(null,t,e),a.bind(null,t,2));t.s=e,t.v=n;var r=t.o;r&&r(t)}}var l=/*#__PURE__*/function(){function t(){}return t.prototype.then=function(e,n){var r=new t,o=this.s;if(o){var i=1&o?e:n;if(i){try{a(r,1,i(this.v))}catch(t){a(r,2,t)}return r}return this}return this.o=function(t){try{var o=t.v;1&t.s?a(r,1,e?e(o):o):n?a(r,1,n(o)):a(r,2,o)}catch(t){a(r,2,t)}},r},t}();function c(t){return t instanceof l&&1&t.s}var f={filename:"Image",forceFixText:!1,printDate:!0},s=function(t){var e=window.getComputedStyle(t);t.style.color=e.color},h=function(t){var e=window.getComputedStyle(t);t.style.width=e.width,t.style.height=e.height},d=function(t,e){void 0===e&&(e=["b","h1","h2","h3","h4","h5","h6","i","mark","p","small","strong"]);for(var n,r=i(t.querySelectorAll(e));!(n=r()).done;){var o=n.value;o.style.fontFamily=window.getComputedStyle(o).fontFamily,o.style.fontSize=window.getComputedStyle(o).fontSize,o.style.fontWeight=window.getComputedStyle(o).fontWeight,o.style.width=window.getComputedStyle(o).width}},v=function(t){return"hide-when-downloading"!==t.className},y=function(t,o,v,y){void 0===y&&(y="png");try{var g=function(){!function(t){for(var e,n=i(t.querySelectorAll([".remove-when-downloading",".show-when-downloading"]));!(e=n()).done;){var r=e.value;r.style.display=r.getAttribute("original_display")}}(t),n.saveAs(m,function(t){if(t.printDate){var e=(new Date).toDateString();return t.filename+" ("+e+")"}return t.filename||"Image"}(p)+"."+y)},p=function(t){return r({},f,t)}(o||{}),m=null;(function(t,e){void 0===e&&(e=!1);var n=t.querySelectorAll("svg");!function(t){d(t,[".fixed-text"])}(t),e&&d(t);for(var r,o=i(n);!(r=o()).done;){var u=r.value;s(u),h(u)}})(t,p.forceFixText),function(t){for(var e,n=i(t.querySelectorAll([".remove-when-downloading"]));!(e=n()).done;){var r=e.value;r.setAttribute("original_display",window.getComputedStyle(r).display),r.style.display="none"}}(t),function(t){for(var e,n=i(t.querySelectorAll([".show-when-downloading"]));!(e=n()).done;){var r=e.value;r.setAttribute("original_display",window.getComputedStyle(r).display),r.style.display="inherit"}}(t);var w=function(t,e){try{var n=Promise.resolve(v()).then(function(t){m=t})}catch(t){return e()}return n&&n.then?n.then(void 0,e):n}(0,function(){return Promise.resolve(function(t){try{var n=t.querySelectorAll("svg"),r=[],o=function(t,e,n){if("function"==typeof t[u]){var r,o,i,f=t[u]();if(function t(n){try{for(;!(r=f.next()).done;)if((n=e(r.value))&&n.then){if(!c(n))return void n.then(t,i||(i=a.bind(null,o=new l,2)));n=n.v}o?a(o,1,n):o=n}catch(t){a(o||(o=new l),2,t)}}(),f.return){var s=function(t){try{r.done||f.return()}catch(t){}return t};if(o&&o.then)return o.then(s,function(t){throw s(t)});s()}return o}if(!("length"in t))throw new TypeError("Object is not iterable");for(var h=[],d=0;d<t.length;d++)h.push(t[d]);return function(t,e,n){var r,o,i=-1;return function n(u){try{for(;++i<t.length;)if((u=e(i))&&u.then){if(!c(u))return void u.then(n,o||(o=a.bind(null,r=new l,2)));u=u.v}r?a(r,1,u):r=u}catch(t){a(r||(r=new l),2,t)}}(),r}(h,function(t){return e(h[t])})}(n,function(t){function n(){u.dataset.icon=o,u.width=t.clientWidth,u.height=t.clientHeight,t.replaceWith(u)}var o=t.getAttribute("data-icon"),i=r.find(function(t){return t.dataIcon===o}),u=document.createElement("img"),a=function(){if(!i)return Promise.resolve(e.svgAsPngUri(t,"icon.png")).then(function(t){u.src=t,r.push({dataIcon:o,uri:t})});u.src=i.uri}();return a&&a.then?a.then(n):n()});return Promise.resolve(o&&o.then?o.then(function(){}):void 0)}catch(t){return Promise.reject(t)}}(t)).then(function(){return Promise.resolve(v()).then(function(){return Promise.resolve(v()).then(function(t){m=t})})})});return Promise.resolve(w&&w.then?w.then(g):g())}catch(t){return Promise.reject(t)}},g=function(t,e,n){void 0===n&&(n="png");var o=e.backgroundColor,i=e.quality,u=e.pixelRatio,a=e.style,l=r({},function(t,e){if(e.width&&e.height)return{width:e.width,height:e.height};var n=window.getComputedStyle(t),r=n.height;return{width:Number.parseInt(n.width.replace("px",""),10)+4,height:Number.parseInt(r.replace("px",""),10)+4}}(t,e),{pixelRatio:1});return a&&(l=r({},l,{style:a})),o&&(l=r({},l,{backgroundColor:o})),u&&u>0&&(l=r({},l,{pixelRatio:u})),i&&n.includes("jpeg")&&(l=r({},l,{quality:i>=0&&i<=1?i:1})),l||{}},p=function(e,n,o){void 0===n&&(n={}),void 0===o&&(o={});try{return Promise.resolve(y(e,n,function(){return t.toPng(e,r({filter:v},g(e,o,"png")))},"png")).then(function(){})}catch(t){return Promise.reject(t)}};exports.downloadDOM=function(t,e,n){void 0===e&&(e="Image"),void 0===n&&(n=!1);try{return Promise.resolve(p(t,{forceFixText:n,filename:e})).then(function(){})}catch(t){return Promise.reject(t)}},exports.saveAsJpeg=function(e,n,o){void 0===n&&(n={}),void 0===o&&(o={});try{return Promise.resolve(y(e,n,function(){return t.toJpeg(e,r({filter:v},g(e,o,"jpeg")))},"jpeg")).then(function(){})}catch(t){return Promise.reject(t)}},exports.saveAsPng=p;
//# sourceMappingURL=index.js.map

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

import{toJpeg as t,toPng as e}from"html-to-image";import{svgAsPngUri as n}from"save-svg-as-png";import{saveAs as r}from"file-saver";function o(){return(o=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function u(t,e){var n;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return i(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=t[Symbol.iterator]()).next.bind(n)}var a=/*#__PURE__*/"undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function l(t,e,n){if(!t.s){if(n instanceof c){if(!n.s)return void(n.o=l.bind(null,t,e));1&e&&(e=n.s),n=n.v}if(n&&n.then)return void n.then(l.bind(null,t,e),l.bind(null,t,2));t.s=e,t.v=n;var r=t.o;r&&r(t)}}var c=/*#__PURE__*/function(){function t(){}return t.prototype.then=function(e,n){var r=new t,o=this.s;if(o){var i=1&o?e:n;if(i){try{l(r,1,i(this.v))}catch(t){l(r,2,t)}return r}return this}return this.o=function(t){try{var o=t.v;1&t.s?l(r,1,e?e(o):o):n?l(r,1,n(o)):l(r,2,o)}catch(t){l(r,2,t)}},r},t}();function f(t){return t instanceof c&&1&t.s}var h={filename:"Image",forceFixText:!1,printDate:!0},d=function(t){var e=window.getComputedStyle(t);t.style.color=e.color},s=function(t){var e=window.getComputedStyle(t);t.style.width=e.width,t.style.height=e.height},v=function(t,e){void 0===e&&(e=["b","h1","h2","h3","h4","h5","h6","i","mark","p","small","strong"]);for(var n,r=u(t.querySelectorAll(e));!(n=r()).done;){var o=n.value;o.style.fontFamily=window.getComputedStyle(o).fontFamily,o.style.fontSize=window.getComputedStyle(o).fontSize,o.style.fontWeight=window.getComputedStyle(o).fontWeight,o.style.width=window.getComputedStyle(o).width}},y=function(t){return"hide-when-downloading"!==t.className},m=function(t,e,i,y){void 0===y&&(y="png");try{var m=function(){!function(t){for(var e,n=u(t.querySelectorAll([".remove-when-downloading"]));!(e=n()).done;){var r=e.value;r.style.display=r.getAttribute("original_display")}}(t),r(g,function(t){if(t.printDate){var e=(new Date).toDateString();return t.filename+" ("+e+")"}return t.filename||"Image"}(p)+"."+y)},p=function(t){return o({},h,t)}(e||{}),g=null;(function(t,e){void 0===e&&(e=!1);var n=t.querySelectorAll("svg");!function(t){v(t,[".fixed-text"])}(t),e&&v(t);for(var r,o=u(n);!(r=o()).done;){var i=r.value;d(i),s(i)}})(t,p.forceFixText),function(t){for(var e,n=u(t.querySelectorAll([".remove-when-downloading"]));!(e=n()).done;){var r=e.value;r.setAttribute("original_display",window.getComputedStyle(r).display),r.style.display="none"}}(t),function(t){for(var e,n=u(t.querySelectorAll([".show-when-downloading"]));!(e=n()).done;){var r=e.value;r.setAttribute("original_display",window.getComputedStyle(r).display),r.style.display="inherit"}}(t);var w=function(t,e){try{var n=Promise.resolve(i()).then(function(t){g=t})}catch(t){return e()}return n&&n.then?n.then(void 0,e):n}(0,function(){return Promise.resolve(function(t){try{var e=t.querySelectorAll("svg"),r=[],o=function(t,e,n){if("function"==typeof t[a]){var r,o,i,u=t[a]();if(function t(n){try{for(;!(r=u.next()).done;)if((n=e(r.value))&&n.then){if(!f(n))return void n.then(t,i||(i=l.bind(null,o=new c,2)));n=n.v}o?l(o,1,n):o=n}catch(t){l(o||(o=new c),2,t)}}(),u.return){var h=function(t){try{r.done||u.return()}catch(t){}return t};if(o&&o.then)return o.then(h,function(t){throw h(t)});h()}return o}if(!("length"in t))throw new TypeError("Object is not iterable");for(var d=[],s=0;s<t.length;s++)d.push(t[s]);return function(t,e,n){var r,o,i=-1;return function n(u){try{for(;++i<t.length;)if((u=e(i))&&u.then){if(!f(u))return void u.then(n,o||(o=l.bind(null,r=new c,2)));u=u.v}r?l(r,1,u):r=u}catch(t){l(r||(r=new c),2,t)}}(),r}(d,function(t){return e(d[t])})}(e,function(t){function e(){u.dataset.icon=o,u.width=t.clientWidth,u.height=t.clientHeight,t.replaceWith(u)}var o=t.getAttribute("data-icon"),i=r.find(function(t){return t.dataIcon===o}),u=document.createElement("img"),a=function(){if(!i)return Promise.resolve(n(t,"icon.png")).then(function(t){u.src=t,r.push({dataIcon:o,uri:t})});u.src=i.uri}();return a&&a.then?a.then(e):e()});return Promise.resolve(o&&o.then?o.then(function(){}):void 0)}catch(t){return Promise.reject(t)}}(t)).then(function(){return Promise.resolve(i()).then(function(){return Promise.resolve(i()).then(function(t){g=t})})})});return Promise.resolve(w&&w.then?w.then(m):m())}catch(t){return Promise.reject(t)}},p=function(t,e,n){void 0===n&&(n="png");var r=e.backgroundColor,i=e.quality,u=e.pixelRatio,a=e.style,l=o({},function(t,e){if(e.width&&e.height)return{width:e.width,height:e.height};var n=window.getComputedStyle(t),r=n.height;return{width:Number.parseInt(n.width.replace("px",""),10)+4,height:Number.parseInt(r.replace("px",""),10)+4}}(t,e),{pixelRatio:1});return a&&(l=o({},l,{style:a})),r&&(l=o({},l,{backgroundColor:r})),u&&u>0&&(l=o({},l,{pixelRatio:u})),i&&n.includes("jpeg")&&(l=o({},l,{quality:i>=0&&i<=1?i:1})),l||{}},g=function(e,n,r){void 0===n&&(n={}),void 0===r&&(r={});try{return Promise.resolve(m(e,n,function(){return t(e,o({filter:y},p(e,r,"jpeg")))},"jpeg")).then(function(){})}catch(t){return Promise.reject(t)}},w=function(t,n,r){void 0===n&&(n={}),void 0===r&&(r={});try{return Promise.resolve(m(t,n,function(){return e(t,o({filter:y},p(t,r,"png")))},"png")).then(function(){})}catch(t){return Promise.reject(t)}},b=function(t,e,n){void 0===e&&(e="Image"),void 0===n&&(n=!1);try{return Promise.resolve(w(t,{forceFixText:n,filename:e})).then(function(){})}catch(t){return Promise.reject(t)}};export{b as downloadDOM,g as saveAsJpeg,w as saveAsPng};
import{toJpeg as t,toPng as e}from"html-to-image";import{svgAsPngUri as n}from"save-svg-as-png";import{saveAs as r}from"file-saver";function o(){return(o=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function u(t,e){var n;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return i(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=t[Symbol.iterator]()).next.bind(n)}var a=/*#__PURE__*/"undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function l(t,e,n){if(!t.s){if(n instanceof c){if(!n.s)return void(n.o=l.bind(null,t,e));1&e&&(e=n.s),n=n.v}if(n&&n.then)return void n.then(l.bind(null,t,e),l.bind(null,t,2));t.s=e,t.v=n;var r=t.o;r&&r(t)}}var c=/*#__PURE__*/function(){function t(){}return t.prototype.then=function(e,n){var r=new t,o=this.s;if(o){var i=1&o?e:n;if(i){try{l(r,1,i(this.v))}catch(t){l(r,2,t)}return r}return this}return this.o=function(t){try{var o=t.v;1&t.s?l(r,1,e?e(o):o):n?l(r,1,n(o)):l(r,2,o)}catch(t){l(r,2,t)}},r},t}();function f(t){return t instanceof c&&1&t.s}var h={filename:"Image",forceFixText:!1,printDate:!0},d=function(t){var e=window.getComputedStyle(t);t.style.color=e.color},s=function(t){var e=window.getComputedStyle(t);t.style.width=e.width,t.style.height=e.height},v=function(t,e){void 0===e&&(e=["b","h1","h2","h3","h4","h5","h6","i","mark","p","small","strong"]);for(var n,r=u(t.querySelectorAll(e));!(n=r()).done;){var o=n.value;o.style.fontFamily=window.getComputedStyle(o).fontFamily,o.style.fontSize=window.getComputedStyle(o).fontSize,o.style.fontWeight=window.getComputedStyle(o).fontWeight,o.style.width=window.getComputedStyle(o).width}},y=function(t){return"hide-when-downloading"!==t.className},m=function(t,e,i,y){void 0===y&&(y="png");try{var m=function(){!function(t){for(var e,n=u(t.querySelectorAll([".remove-when-downloading",".show-when-downloading"]));!(e=n()).done;){var r=e.value;r.style.display=r.getAttribute("original_display")}}(t),r(g,function(t){if(t.printDate){var e=(new Date).toDateString();return t.filename+" ("+e+")"}return t.filename||"Image"}(p)+"."+y)},p=function(t){return o({},h,t)}(e||{}),g=null;(function(t,e){void 0===e&&(e=!1);var n=t.querySelectorAll("svg");!function(t){v(t,[".fixed-text"])}(t),e&&v(t);for(var r,o=u(n);!(r=o()).done;){var i=r.value;d(i),s(i)}})(t,p.forceFixText),function(t){for(var e,n=u(t.querySelectorAll([".remove-when-downloading"]));!(e=n()).done;){var r=e.value;r.setAttribute("original_display",window.getComputedStyle(r).display),r.style.display="none"}}(t),function(t){for(var e,n=u(t.querySelectorAll([".show-when-downloading"]));!(e=n()).done;){var r=e.value;r.setAttribute("original_display",window.getComputedStyle(r).display),r.style.display="inherit"}}(t);var w=function(t,e){try{var n=Promise.resolve(i()).then(function(t){g=t})}catch(t){return e()}return n&&n.then?n.then(void 0,e):n}(0,function(){return Promise.resolve(function(t){try{var e=t.querySelectorAll("svg"),r=[],o=function(t,e,n){if("function"==typeof t[a]){var r,o,i,u=t[a]();if(function t(n){try{for(;!(r=u.next()).done;)if((n=e(r.value))&&n.then){if(!f(n))return void n.then(t,i||(i=l.bind(null,o=new c,2)));n=n.v}o?l(o,1,n):o=n}catch(t){l(o||(o=new c),2,t)}}(),u.return){var h=function(t){try{r.done||u.return()}catch(t){}return t};if(o&&o.then)return o.then(h,function(t){throw h(t)});h()}return o}if(!("length"in t))throw new TypeError("Object is not iterable");for(var d=[],s=0;s<t.length;s++)d.push(t[s]);return function(t,e,n){var r,o,i=-1;return function n(u){try{for(;++i<t.length;)if((u=e(i))&&u.then){if(!f(u))return void u.then(n,o||(o=l.bind(null,r=new c,2)));u=u.v}r?l(r,1,u):r=u}catch(t){l(r||(r=new c),2,t)}}(),r}(d,function(t){return e(d[t])})}(e,function(t){function e(){u.dataset.icon=o,u.width=t.clientWidth,u.height=t.clientHeight,t.replaceWith(u)}var o=t.getAttribute("data-icon"),i=r.find(function(t){return t.dataIcon===o}),u=document.createElement("img"),a=function(){if(!i)return Promise.resolve(n(t,"icon.png")).then(function(t){u.src=t,r.push({dataIcon:o,uri:t})});u.src=i.uri}();return a&&a.then?a.then(e):e()});return Promise.resolve(o&&o.then?o.then(function(){}):void 0)}catch(t){return Promise.reject(t)}}(t)).then(function(){return Promise.resolve(i()).then(function(){return Promise.resolve(i()).then(function(t){g=t})})})});return Promise.resolve(w&&w.then?w.then(m):m())}catch(t){return Promise.reject(t)}},p=function(t,e,n){void 0===n&&(n="png");var r=e.backgroundColor,i=e.quality,u=e.pixelRatio,a=e.style,l=o({},function(t,e){if(e.width&&e.height)return{width:e.width,height:e.height};var n=window.getComputedStyle(t),r=n.height;return{width:Number.parseInt(n.width.replace("px",""),10)+4,height:Number.parseInt(r.replace("px",""),10)+4}}(t,e),{pixelRatio:1});return a&&(l=o({},l,{style:a})),r&&(l=o({},l,{backgroundColor:r})),u&&u>0&&(l=o({},l,{pixelRatio:u})),i&&n.includes("jpeg")&&(l=o({},l,{quality:i>=0&&i<=1?i:1})),l||{}},g=function(e,n,r){void 0===n&&(n={}),void 0===r&&(r={});try{return Promise.resolve(m(e,n,function(){return t(e,o({filter:y},p(e,r,"jpeg")))},"jpeg")).then(function(){})}catch(t){return Promise.reject(t)}},w=function(t,n,r){void 0===n&&(n={}),void 0===r&&(r={});try{return Promise.resolve(m(t,n,function(){return e(t,o({filter:y},p(t,r,"png")))},"png")).then(function(){})}catch(t){return Promise.reject(t)}},b=function(t,e,n){void 0===e&&(e="Image"),void 0===n&&(n=!1);try{return Promise.resolve(w(t,{forceFixText:n,filename:e})).then(function(){})}catch(t){return Promise.reject(t)}};export{b as downloadDOM,g as saveAsJpeg,w as saveAsPng};
//# sourceMappingURL=index.modern.js.map
{
"name": "save-html-as-image-enhanced",
"version": "1.7.4",
"version": "1.7.5",
"description": "Save the html as image like png or jpg",

@@ -5,0 +5,0 @@ "source": "src/index.js",

@@ -187,4 +187,3 @@ /* jslint browser */

const recoveryElements = (node) => {
const els = node.querySelectorAll(['.remove-when-downloading']);
const els = node.querySelectorAll(['.remove-when-downloading', '.show-when-downloading']);
for (const element of els) {

@@ -191,0 +190,0 @@ element.style.display = element.getAttribute('original_display');

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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