Socket
Socket
Sign inDemoInstall

@gd-uikit/html-to-image

Package Overview
Dependencies
0
Maintainers
10
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.9.3 to 1.9.4

2

dist/html-to-image.js

@@ -15,3 +15,3 @@ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).htmlToImage={})}(this,(function(t){"use strict";

PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */function e(t,e,n,r){return new(n||(n=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(u,c)}a((r=r.apply(t,e||[])).next())}))}function n(t,e){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=e.call(t,u)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}}var r="application/font-woff",o="image/jpeg",i={woff:r,woff2:r,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:o,jpeg:o,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml"};function u(t){var e=function(t){var e=/\.([^./]*?)$/g.exec(t);return e?e[1]:""}(t).toLowerCase();return i[e]||""}function c(t){return-1!==t.search(/^(data:)/)}function a(t,e){return"data:"+e+";base64,"+t}var s,f=(s=0,function(){return s+=1,"u"+("0000"+(Math.random()*Math.pow(36,4)<<0).toString(36)).slice(-4)+s});function l(t){for(var e=[],n=0,r=t.length;n<r;n+=1)e.push(t[n]);return e}function h(t,e){var n=window.getComputedStyle(t).getPropertyValue(e);return parseFloat(n.replace("px",""))}function d(t,e){return void 0===e&&(e={}),t.toBlob?new Promise((function(n){return t.toBlob(n,e.type?e.type:"image/png",e.quality?e.quality:1)})):new Promise((function(n){for(var r=window.atob(t.toDataURL(e.type?e.type:void 0,e.quality?e.quality:void 0).split(",")[1]),o=r.length,i=new Uint8Array(o),u=0;u<o;u+=1)i[u]=r.charCodeAt(u);n(new Blob([i],{type:e.type?e.type:"image/png"}))}))}function v(t){return new Promise((function(e,n){var r=new Image;r.onload=function(){return e(r)},r.onerror=n,r.crossOrigin="anonymous",r.decoding="sync",r.src=t}))}function p(t){return e(this,void 0,void 0,(function(){return n(this,(function(e){return[2,Promise.resolve().then((function(){return(new XMLSerializer).serializeToString(t)})).then(encodeURIComponent).then((function(t){return"data:image/svg+xml;charset=utf-8,"+t}))]}))}))}var g={};function m(t,e){var n=function(t){var e=t.replace(/\?.*/,"");return/ttf|otf|eot|woff2?/i.test(e)&&(e=e.replace(/.*\//,"")),e}(t);if(null!=g[n])return g[n];e.cacheBust&&(t+=(/\?/.test(t)?"&":"?")+(new Date).getTime());var r=window.fetch(t,{mode:"cors",cache:"no-cache",credentials:"same-origin"}).then((function(t){return t.blob().then((function(e){return{blob:e,contentType:t.headers.get("Content-Type")||""}}))})).then((function(t){var e=t.blob,n=t.contentType;return new Promise((function(t,r){var o=new FileReader;o.onloadend=function(){return t({contentType:n,blob:o.result})},o.onerror=r,o.readAsDataURL(e)}))})).then((function(t){var e,n=t.blob;return{contentType:t.contentType,blob:(e=n,e.split(/,/)[1])}})).catch((function(n){var r="";if(e.imagePlaceholder){var o=e.imagePlaceholder.split(/,/);o&&o[1]&&(r=o[1])}var i="Failed to fetch resource: "+t;return n&&(i="string"==typeof n?n:n.message),i&&console.error(i),{blob:r,contentType:""}}));return g[n]=r,r}function y(t,e,n){var r="."+t+":"+e,o=n.cssText?function(t){var e=t.getPropertyValue("content");return t.cssText+" content: '"+e.replace(/'|"/g,"")+"';"}(n):function(t){return l(t).map((function(e){return e+": "+t.getPropertyValue(e)+(t.getPropertyPriority(e)?" !important":"")+";"})).join(" ")}(n);return document.createTextNode(r+"{"+o+"}")}function w(t,e,n){var r=window.getComputedStyle(t,n),o=r.getPropertyValue("content");if(""!==o&&"none"!==o){var i=f();try{e.className=e.className+" "+i}catch(t){return}var u=document.createElement("style");u.appendChild(y(i,n,r)),e.appendChild(u)}}function b(t){return e(this,void 0,void 0,(function(){var e;return n(this,(function(n){return"data:,"===(e=t.toDataURL())?[2,Promise.resolve(t.cloneNode(!1))]:[2,v(e)]}))}))}function P(t,r){return e(this,void 0,void 0,(function(){return n(this,(function(e){return[2,Promise.resolve(t.poster).then((function(t){return m(t,r)})).then((function(e){return a(e.blob,u(t.poster)||e.contentType)})).then((function(t){return v(t)}))]}))}))}function S(t,r){return e(this,void 0,void 0,(function(){return n(this,(function(e){return r instanceof Element?[2,Promise.resolve().then((function(){return function(t,e){var n=window.getComputedStyle(t),r=e.style;r&&(n.cssText?r.cssText=n.cssText:l(n).forEach((function(t){r.setProperty(t,n.getPropertyValue(t),n.getPropertyPriority(t))})))}(t,r)})).then((function(){return function(t,e){w(t,e,":before"),w(t,e,":after")}(t,r)})).then((function(){return function(t,e){t instanceof HTMLTextAreaElement&&(e.innerHTML=t.value),t instanceof HTMLInputElement&&e.setAttribute("value",t.value)}(t,r)})).then((function(){return r}))]:[2,Promise.resolve(r)]}))}))}function x(t,r,o){return e(this,void 0,void 0,(function(){return n(this,(function(i){return o||!r.filter||r.filter(t)?[2,Promise.resolve(t).then((function(t){return function(t,r){return e(this,void 0,void 0,(function(){return n(this,(function(e){return t instanceof HTMLCanvasElement?[2,b(t)]:t instanceof HTMLVideoElement&&t.poster?[2,P(t,r)]:[2,Promise.resolve(t.cloneNode(!1))]}))}))}(t,r)})).then((function(o){return function(t,r,o){var i;return e(this,void 0,void 0,(function(){var e;return n(this,(function(n){var u;return 0===(e=null!=(u=t).tagName&&"SLOT"===u.tagName.toUpperCase()&&t.assignedNodes?l(t.assignedNodes()):l((null!==(i=t.shadowRoot)&&void 0!==i?i:t).childNodes)).length||t instanceof HTMLVideoElement?[2,Promise.resolve(r)]:[2,e.reduce((function(t,e){return t.then((function(){return x(e,o)})).then((function(t){t&&r.appendChild(t)}))}),Promise.resolve()).then((function(){return r}))]}))}))}(t,o,r)})).then((function(e){return S(t,e)}))]:[2,Promise.resolve(null)]}))}))}var E=/url\((['"]?)([^'"]+?)\1\)/g,T=/url\([^)]+\)\s*format\((["'])([^"']+)\1\)/g,C=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function R(t){var e=[];return t.replace(E,(function(t,n,r){return e.push(r),t})),e.filter((function(t){return!c(t)}))}function L(t,e,n,r,o){var i=n?function(t,e){if(t.match(/^[a-z]+:\/\//i))return t;if(t.match(/^\/\//))return window.location.protocol+t;if(t.match(/^[a-z]+:/i))return t;var n=document.implementation.createHTMLDocument(),r=n.createElement("base"),o=n.createElement("a");return n.head.appendChild(r),n.body.appendChild(o),e&&(r.href=e),o.href=t,o.href}(e,n):e;return Promise.resolve(i).then((function(t){return o?o(t):m(t,r)})).then((function(t){return"string"==typeof t?a(t,u(e)):a(t.blob,u(e)||t.contentType)})).then((function(n){return t.replace((r=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1"),new RegExp("(url\\(['\"]?)("+r+")(['\"]?\\))","g")),"$1"+n+"$3");var r})).then((function(t){return t}),(function(){return i}))}function N(t){return-1!==t.search(E)}function k(t,r,o){return e(this,void 0,void 0,(function(){var e;return n(this,(function(n){return N(t)?(e=function(t,e){var n=e.preferredFontFormat;return n?t.replace(C,(function(t){for(;;){var e=T.exec(t)||[],r=e[0],o=e[2];if(!o)return"";if(o===n)return"src: "+r+";"}})):t}(t,o),[2,Promise.resolve(e).then(R).then((function(t){return t.reduce((function(t,e){return t.then((function(t){return L(t,e,r,o)}))}),Promise.resolve(e))}))]):[2,Promise.resolve(t)]}))}))}function A(t,r){return e(this,void 0,void 0,(function(){return n(this,(function(o){return t instanceof Element?[2,Promise.resolve(t).then((function(t){return function(t,r){var o;return e(this,void 0,void 0,(function(){var e;return n(this,(function(n){return(e=null===(o=t.style)||void 0===o?void 0:o.getPropertyValue("background"))?[2,Promise.resolve(e).then((function(t){return k(t,null,r)})).then((function(e){return t.style.setProperty("background",e,t.style.getPropertyPriority("background")),t}))]:[2,Promise.resolve(t)]}))}))}(t,r)})).then((function(t){return function(t,r){return e(this,void 0,void 0,(function(){var e;return n(this,(function(n){return t instanceof HTMLImageElement&&!c(t.src)||t instanceof SVGImageElement&&!c(t.href.baseVal)?(e=t instanceof HTMLImageElement?t.src:t.href.baseVal,[2,Promise.resolve(e).then((function(t){return m(t,r)})).then((function(t){return a(t.blob,u(e)||t.contentType)})).then((function(e){return new Promise((function(n,r){t.onload=n,t.onerror=r,t instanceof HTMLImageElement?(t.srcset="",t.src=e):t.href.baseVal=e}))})).then((function(){return t}),(function(){return t}))]):[2,Promise.resolve(t)]}))}))}(t,r)})).then((function(t){return function(t,r){return e(this,void 0,void 0,(function(){var e,o;return n(this,(function(n){return e=l(t.childNodes),o=e.map((function(t){return A(t,r)})),[2,Promise.all(o).then((function(){return t}))]}))}))}(t,r)}))]:[2,Promise.resolve(t)]}))}))}var I={};function M(t){var e=I[t];if(null!=e)return e;var n=window.fetch(t,{mode:"cors",cache:"no-cache",credentials:"same-origin"}).then((function(e){return{url:t,cssText:e.text()}}));return I[t]=n,n}function D(t){return e(this,void 0,void 0,(function(){return n(this,(function(e){return[2,t.cssText.then((function(e){var n=e,r=/url\(["']?([^"')]+)["']?\)/g,o=(n.match(/url\([^)]+\)/g)||[]).map((function(e){var o=e.replace(r,"$1");return o.startsWith("https://")||(o=new URL(o,t.url).href),window.fetch(o,{mode:"cors",cache:"no-cache",credentials:"same-origin"}).then((function(t){return t.blob()})).then((function(t){return new Promise((function(r,o){var i=new FileReader;i.onloadend=function(){n=n.replace(e,"url("+i.result+")"),r([e,i.result])},i.onerror=o,i.readAsDataURL(t)}))}))}));return Promise.all(o).then((function(){return n}))}))]}))}))}function V(t){if(null==t)return[];for(var e=[],n=t.replace(/(\/\*[\s\S]*?\*\/)/gi,""),r=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");;){if(null===(u=r.exec(n)))break;e.push(u[0])}n=n.replace(r,"");for(var o=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,i=new RegExp("((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})","gi");;){var u;if(null===(u=o.exec(n))){if(null===(u=i.exec(n)))break;o.lastIndex=i.lastIndex}else i.lastIndex=o.lastIndex;e.push(u[0])}return e}function H(t){return t.filter((function(t){return t.type===CSSRule.FONT_FACE_RULE})).filter((function(t){return N(t.style.getPropertyValue("src"))}))}function U(t){return e(this,void 0,void 0,(function(){return n(this,(function(r){return[2,new Promise((function(e,n){null==t.ownerDocument&&n(new Error("Provided element is not within a Document")),e(l(t.ownerDocument.styleSheets))})).then((function(t){return function(t){return e(this,void 0,void 0,(function(){var e,r;return n(this,(function(n){return e=[],r=[],t.forEach((function(e){if("cssRules"in e)try{l(e.cssRules).forEach((function(t,n){if(t.type===CSSRule.IMPORT_RULE){var o=n+1,i=M(t.href).then((function(t){return t?D(t):""})).then((function(t){return V(t).forEach((function(t){try{e.insertRule(t,t.startsWith("@import")?o+=1:e.cssRules.length)}catch(e){console.error("Error inserting rule from remote css",{rule:t,error:e})}}))})).catch((function(t){console.error("Error loading remote css",t.toString())}));r.push(i)}}))}catch(o){var n=t.find((function(t){return null==t.href}))||document.styleSheets[0];null!=e.href&&r.push(M(e.href).then((function(t){return t?D(t):""})).then((function(t){return V(t).forEach((function(t){n.insertRule(t,e.cssRules.length)}))})).catch((function(t){console.error("Error loading remote stylesheet",t.toString())}))),console.error("Error inlining remote css file",o.toString())}})),[2,Promise.all(r).then((function(){return t.forEach((function(t){if("cssRules"in t)try{l(t.cssRules).forEach((function(t){e.push(t)}))}catch(e){console.error("Error while reading CSS rules from "+t.href,e.toString())}})),e}))]}))}))}(t)})).then(H)]}))}))}function j(t,r){return e(this,void 0,void 0,(function(){return n(this,(function(e){return[2,U(t).then((function(t){return Promise.all(t.map((function(t){var e=t.parentStyleSheet?t.parentStyleSheet.href:null;return k(t.cssText,e,r)})))})).then((function(t){return t.join("\n")}))]}))}))}function F(t,e){void 0===e&&(e={});var n=e.width||function(t){var e=h(t,"border-left-width"),n=h(t,"border-right-width");return t.clientWidth+e+n}(t),r=e.height||function(t){var e=h(t,"border-top-width"),n=h(t,"border-bottom-width");return t.clientHeight+e+n}(t);return{width:n,height:r}}function B(t,r){return void 0===r&&(r={}),e(this,void 0,void 0,(function(){var o,i,u;return n(this,(function(c){return o=F(t,r),i=o.width,u=o.height,[2,Promise.resolve(t).then((function(t){return x(t,r,!0)})).then((function(t){return function(t,r){return e(this,void 0,void 0,(function(){return n(this,(function(e){return[2,(null!=r.fontEmbedCSS?Promise.resolve(r.fontEmbedCSS):j(t,r)).then((function(e){var n=document.createElement("style"),r=document.createTextNode(e);return n.appendChild(r),t.firstChild?t.insertBefore(n,t.firstChild):t.appendChild(n),t}))]}))}))}(t,r)})).then((function(t){return A(t,r)})).then((function(t){return function(t,e){var n=t.style;e.backgroundColor&&(n.backgroundColor=e.backgroundColor),e.width&&(n.width=e.width+"px"),e.height&&(n.height=e.height+"px");var r=e.style;return null!=r&&Object.keys(r).forEach((function(t){n[t]=r[t]})),t}(t,r)})).then((function(t){return function(t,r,o){return e(this,void 0,void 0,(function(){var e,i,u;return n(this,(function(n){return e="http://www.w3.org/2000/svg",i=document.createElementNS(e,"svg"),u=document.createElementNS(e,"foreignObject"),i.setAttribute("width",""+r),i.setAttribute("height",""+o),i.setAttribute("viewBox","0 0 "+r+" "+o),u.setAttribute("width","100%"),u.setAttribute("height","100%"),u.setAttribute("x","0"),u.setAttribute("y","0"),u.setAttribute("externalResourcesRequired","true"),i.appendChild(u),u.appendChild(t),[2,p(i)]}))}))}(t,i,u)}))]}))}))}var O=16384;function q(t,r){return void 0===r&&(r={}),e(this,void 0,void 0,(function(){return n(this,(function(e){return[2,B(t,r).then(v).then((function(e){var n=document.createElement("canvas"),o=n.getContext("2d"),i=r.pixelRatio||function(){var t,e;try{e=process}catch(t){}var n=e&&e.env?e.env.devicePixelRatio:null;return n&&(t=parseInt(n,10),Number.isNaN(t)&&(t=1)),t||window.devicePixelRatio||1}(),u=F(t,r),c=u.width,a=u.height,s=r.canvasWidth||c,f=r.canvasHeight||a;return n.width=s*i,n.height=f*i,r.skipAutoScale||function(t){(t.width>O||t.height>O)&&(t.width>O&&t.height>O?t.width>t.height?(t.height*=O/t.width,t.width=O):(t.width*=O/t.height,t.height=O):t.width>O?(t.height*=O/t.width,t.width=O):(t.width*=O/t.height,t.height=O))}(n),n.style.width=""+s,n.style.height=""+f,r.backgroundColor&&(o.fillStyle=r.backgroundColor,o.fillRect(0,0,n.width,n.height)),o.drawImage(e,0,0,n.width,n.height),n}))]}))}))}t.getFontEmbedCSS=function(t,r){return void 0===r&&(r={}),e(this,void 0,void 0,(function(){return n(this,(function(e){return[2,j(t,r)]}))}))},t.toBlob=function(t,r){return void 0===r&&(r={}),e(this,void 0,void 0,(function(){return n(this,(function(e){return[2,q(t,r).then(d)]}))}))},t.toCanvas=q,t.toJpeg=function(t,r){return void 0===r&&(r={}),e(this,void 0,void 0,(function(){return n(this,(function(e){return[2,q(t,r).then((function(t){return t.toDataURL("image/jpeg",r.quality||1)}))]}))}))},t.toPixelData=function(t,r){return void 0===r&&(r={}),e(this,void 0,void 0,(function(){var e,o,i;return n(this,(function(n){return e=F(t,r),o=e.width,i=e.height,[2,q(t,r).then((function(t){return t.getContext("2d").getImageData(0,0,o,i).data}))]}))}))},t.toPng=function(t,r){return void 0===r&&(r={}),e(this,void 0,void 0,(function(){return n(this,(function(e){return[2,q(t,r).then((function(t){return t.toDataURL()}))]}))}))},t.toSvg=B,Object.defineProperty(t,"__esModule",{value:!0})}));
***************************************************************************** */function e(t,e,n,r){return new(n||(n=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(u,c)}a((r=r.apply(t,e||[])).next())}))}function n(t,e){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=e.call(t,u)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}}var r="application/font-woff",o="image/jpeg",i={woff:r,woff2:r,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:o,jpeg:o,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml"};function u(t){var e=function(t){var e=/\.([^./]*?)$/g.exec(t);return e?e[1]:""}(t).toLowerCase();return i[e]||""}function c(t){return-1!==t.search(/^(data:)/)}function a(t,e){return"data:"+e+";base64,"+t}var s,f=(s=0,function(){return s+=1,"u"+("0000"+(Math.random()*Math.pow(36,4)<<0).toString(36)).slice(-4)+s});function l(t){for(var e=[],n=0,r=t.length;n<r;n+=1)e.push(t[n]);return e}function h(t,e){var n=window.getComputedStyle(t).getPropertyValue(e);return parseFloat(n.replace("px",""))}function d(t,e){return void 0===e&&(e={}),t.toBlob?new Promise((function(n){return t.toBlob(n,e.type?e.type:"image/png",e.quality?e.quality:1)})):new Promise((function(n){for(var r=window.atob(t.toDataURL(e.type?e.type:void 0,e.quality?e.quality:void 0).split(",")[1]),o=r.length,i=new Uint8Array(o),u=0;u<o;u+=1)i[u]=r.charCodeAt(u);n(new Blob([i],{type:e.type?e.type:"image/png"}))}))}function v(t){return new Promise((function(e,n){var r=new Image;r.onload=function(){return e(r)},r.onerror=n,r.crossOrigin="anonymous",r.decoding="sync",r.src=t}))}function p(t){return e(this,void 0,void 0,(function(){return n(this,(function(e){return[2,Promise.resolve().then((function(){return(new XMLSerializer).serializeToString(t)})).then(encodeURIComponent).then((function(t){return"data:image/svg+xml;charset=utf-8,"+t}))]}))}))}var g={};function m(t,e){var n=function(t){var e=t.replace(/\?.*/,"");return/ttf|otf|eot|woff2?/i.test(e)&&(e=e.replace(/.*\//,"")),e}(t);if(null!=g[n])return g[n];e.cacheBust&&(t+=(/\?/.test(t)?"&":"?")+(new Date).getTime());var r=window.fetch(t,{mode:"cors",cache:"no-cache"}).then((function(t){return t.blob().then((function(e){return{blob:e,contentType:t.headers.get("Content-Type")||""}}))})).then((function(t){var e=t.blob,n=t.contentType;return new Promise((function(t,r){var o=new FileReader;o.onloadend=function(){return t({contentType:n,blob:o.result})},o.onerror=r,o.readAsDataURL(e)}))})).then((function(t){var e,n=t.blob;return{contentType:t.contentType,blob:(e=n,e.split(/,/)[1])}})).catch((function(n){var r="";if(e.imagePlaceholder){var o=e.imagePlaceholder.split(/,/);o&&o[1]&&(r=o[1])}var i="Failed to fetch resource: "+t;return n&&(i="string"==typeof n?n:n.message),i&&console.error(i),{blob:r,contentType:""}}));return g[n]=r,r}function y(t,e,n){var r="."+t+":"+e,o=n.cssText?function(t){var e=t.getPropertyValue("content");return t.cssText+" content: '"+e.replace(/'|"/g,"")+"';"}(n):function(t){return l(t).map((function(e){return e+": "+t.getPropertyValue(e)+(t.getPropertyPriority(e)?" !important":"")+";"})).join(" ")}(n);return document.createTextNode(r+"{"+o+"}")}function w(t,e,n){var r=window.getComputedStyle(t,n),o=r.getPropertyValue("content");if(""!==o&&"none"!==o){var i=f();try{e.className=e.className+" "+i}catch(t){return}var u=document.createElement("style");u.appendChild(y(i,n,r)),e.appendChild(u)}}function b(t){return e(this,void 0,void 0,(function(){var e;return n(this,(function(n){return"data:,"===(e=t.toDataURL())?[2,Promise.resolve(t.cloneNode(!1))]:[2,v(e)]}))}))}function P(t,r){return e(this,void 0,void 0,(function(){return n(this,(function(e){return[2,Promise.resolve(t.poster).then((function(t){return m(t,r)})).then((function(e){return a(e.blob,u(t.poster)||e.contentType)})).then((function(t){return v(t)}))]}))}))}function S(t,r){return e(this,void 0,void 0,(function(){return n(this,(function(e){return r instanceof Element?[2,Promise.resolve().then((function(){return function(t,e){var n=window.getComputedStyle(t),r=e.style;r&&(n.cssText?r.cssText=n.cssText:l(n).forEach((function(t){r.setProperty(t,n.getPropertyValue(t),n.getPropertyPriority(t))})))}(t,r)})).then((function(){return function(t,e){w(t,e,":before"),w(t,e,":after")}(t,r)})).then((function(){return function(t,e){t instanceof HTMLTextAreaElement&&(e.innerHTML=t.value),t instanceof HTMLInputElement&&e.setAttribute("value",t.value)}(t,r)})).then((function(){return r}))]:[2,Promise.resolve(r)]}))}))}function x(t,r,o){return e(this,void 0,void 0,(function(){return n(this,(function(i){return o||!r.filter||r.filter(t)?[2,Promise.resolve(t).then((function(t){return function(t,r){return e(this,void 0,void 0,(function(){return n(this,(function(e){return t instanceof HTMLCanvasElement?[2,b(t)]:t instanceof HTMLVideoElement&&t.poster?[2,P(t,r)]:[2,Promise.resolve(t.cloneNode(!1))]}))}))}(t,r)})).then((function(o){return function(t,r,o){var i;return e(this,void 0,void 0,(function(){var e;return n(this,(function(n){var u;return 0===(e=null!=(u=t).tagName&&"SLOT"===u.tagName.toUpperCase()&&t.assignedNodes?l(t.assignedNodes()):l((null!==(i=t.shadowRoot)&&void 0!==i?i:t).childNodes)).length||t instanceof HTMLVideoElement?[2,Promise.resolve(r)]:[2,e.reduce((function(t,e){return t.then((function(){return x(e,o)})).then((function(t){t&&r.appendChild(t)}))}),Promise.resolve()).then((function(){return r}))]}))}))}(t,o,r)})).then((function(e){return S(t,e)}))]:[2,Promise.resolve(null)]}))}))}var E=/url\((['"]?)([^'"]+?)\1\)/g,T=/url\([^)]+\)\s*format\((["'])([^"']+)\1\)/g,C=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function R(t){var e=[];return t.replace(E,(function(t,n,r){return e.push(r),t})),e.filter((function(t){return!c(t)}))}function L(t,e,n,r,o){var i=n?function(t,e){if(t.match(/^[a-z]+:\/\//i))return t;if(t.match(/^\/\//))return window.location.protocol+t;if(t.match(/^[a-z]+:/i))return t;var n=document.implementation.createHTMLDocument(),r=n.createElement("base"),o=n.createElement("a");return n.head.appendChild(r),n.body.appendChild(o),e&&(r.href=e),o.href=t,o.href}(e,n):e;return Promise.resolve(i).then((function(t){return o?o(t):m(t,r)})).then((function(t){return"string"==typeof t?a(t,u(e)):a(t.blob,u(e)||t.contentType)})).then((function(n){return t.replace((r=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1"),new RegExp("(url\\(['\"]?)("+r+")(['\"]?\\))","g")),"$1"+n+"$3");var r})).then((function(t){return t}),(function(){return i}))}function N(t){return-1!==t.search(E)}function k(t,r,o){return e(this,void 0,void 0,(function(){var e;return n(this,(function(n){return N(t)?(e=function(t,e){var n=e.preferredFontFormat;return n?t.replace(C,(function(t){for(;;){var e=T.exec(t)||[],r=e[0],o=e[2];if(!o)return"";if(o===n)return"src: "+r+";"}})):t}(t,o),[2,Promise.resolve(e).then(R).then((function(t){return t.reduce((function(t,e){return t.then((function(t){return L(t,e,r,o)}))}),Promise.resolve(e))}))]):[2,Promise.resolve(t)]}))}))}function A(t,r){return e(this,void 0,void 0,(function(){return n(this,(function(o){return t instanceof Element?[2,Promise.resolve(t).then((function(t){return function(t,r){var o;return e(this,void 0,void 0,(function(){var e;return n(this,(function(n){return(e=null===(o=t.style)||void 0===o?void 0:o.getPropertyValue("background"))?[2,Promise.resolve(e).then((function(t){return k(t,null,r)})).then((function(e){return t.style.setProperty("background",e,t.style.getPropertyPriority("background")),t}))]:[2,Promise.resolve(t)]}))}))}(t,r)})).then((function(t){return function(t,r){return e(this,void 0,void 0,(function(){var e;return n(this,(function(n){return t instanceof HTMLImageElement&&!c(t.src)||t instanceof SVGImageElement&&!c(t.href.baseVal)?(e=t instanceof HTMLImageElement?t.src:t.href.baseVal,[2,Promise.resolve(e).then((function(t){return m(t,r)})).then((function(t){return a(t.blob,u(e)||t.contentType)})).then((function(e){return new Promise((function(n,r){t.onload=n,t.onerror=r,t instanceof HTMLImageElement?(t.srcset="",t.src=e):t.href.baseVal=e}))})).then((function(){return t}),(function(){return t}))]):[2,Promise.resolve(t)]}))}))}(t,r)})).then((function(t){return function(t,r){return e(this,void 0,void 0,(function(){var e,o;return n(this,(function(n){return e=l(t.childNodes),o=e.map((function(t){return A(t,r)})),[2,Promise.all(o).then((function(){return t}))]}))}))}(t,r)}))]:[2,Promise.resolve(t)]}))}))}var I={};function M(t){var e=I[t];if(null!=e)return e;var n=window.fetch(t,{mode:"cors",cache:"no-cache"}).then((function(e){return{url:t,cssText:e.text()}}));return I[t]=n,n}function D(t){return e(this,void 0,void 0,(function(){return n(this,(function(e){return[2,t.cssText.then((function(e){var n=e,r=/url\(["']?([^"')]+)["']?\)/g,o=(n.match(/url\([^)]+\)/g)||[]).map((function(e){var o=e.replace(r,"$1");return o.startsWith("https://")||(o=new URL(o,t.url).href),window.fetch(o,{mode:"cors",cache:"no-cache"}).then((function(t){return t.blob()})).then((function(t){return new Promise((function(r,o){var i=new FileReader;i.onloadend=function(){n=n.replace(e,"url("+i.result+")"),r([e,i.result])},i.onerror=o,i.readAsDataURL(t)}))}))}));return Promise.all(o).then((function(){return n}))}))]}))}))}function V(t){if(null==t)return[];for(var e=[],n=t.replace(/(\/\*[\s\S]*?\*\/)/gi,""),r=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");;){if(null===(u=r.exec(n)))break;e.push(u[0])}n=n.replace(r,"");for(var o=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,i=new RegExp("((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})","gi");;){var u;if(null===(u=o.exec(n))){if(null===(u=i.exec(n)))break;o.lastIndex=i.lastIndex}else i.lastIndex=o.lastIndex;e.push(u[0])}return e}function H(t){return t.filter((function(t){return t.type===CSSRule.FONT_FACE_RULE})).filter((function(t){return N(t.style.getPropertyValue("src"))}))}function U(t){return e(this,void 0,void 0,(function(){return n(this,(function(r){return[2,new Promise((function(e,n){null==t.ownerDocument&&n(new Error("Provided element is not within a Document")),e(l(t.ownerDocument.styleSheets))})).then((function(t){return function(t){return e(this,void 0,void 0,(function(){var e,r;return n(this,(function(n){return e=[],r=[],t.forEach((function(e){if("cssRules"in e)try{l(e.cssRules).forEach((function(t,n){if(t.type===CSSRule.IMPORT_RULE){var o=n+1,i=M(t.href).then((function(t){return t?D(t):""})).then((function(t){return V(t).forEach((function(t){try{e.insertRule(t,t.startsWith("@import")?o+=1:e.cssRules.length)}catch(e){console.error("Error inserting rule from remote css",{rule:t,error:e})}}))})).catch((function(t){console.error("Error loading remote css",t.toString())}));r.push(i)}}))}catch(o){var n=t.find((function(t){return null==t.href}))||document.styleSheets[0];null!=e.href&&r.push(M(e.href).then((function(t){return t?D(t):""})).then((function(t){return V(t).forEach((function(t){n.insertRule(t,e.cssRules.length)}))})).catch((function(t){console.error("Error loading remote stylesheet",t.toString())}))),console.error("Error inlining remote css file",o.toString())}})),[2,Promise.all(r).then((function(){return t.forEach((function(t){if("cssRules"in t)try{l(t.cssRules).forEach((function(t){e.push(t)}))}catch(e){console.error("Error while reading CSS rules from "+t.href,e.toString())}})),e}))]}))}))}(t)})).then(H)]}))}))}function j(t,r){return e(this,void 0,void 0,(function(){return n(this,(function(e){return[2,U(t).then((function(t){return Promise.all(t.map((function(t){var e=t.parentStyleSheet?t.parentStyleSheet.href:null;return k(t.cssText,e,r)})))})).then((function(t){return t.join("\n")}))]}))}))}function F(t,e){void 0===e&&(e={});var n=e.width||function(t){var e=h(t,"border-left-width"),n=h(t,"border-right-width");return t.clientWidth+e+n}(t),r=e.height||function(t){var e=h(t,"border-top-width"),n=h(t,"border-bottom-width");return t.clientHeight+e+n}(t);return{width:n,height:r}}function B(t,r){return void 0===r&&(r={}),e(this,void 0,void 0,(function(){var o,i,u;return n(this,(function(c){return o=F(t,r),i=o.width,u=o.height,[2,Promise.resolve(t).then((function(t){return x(t,r,!0)})).then((function(t){return function(t,r){return e(this,void 0,void 0,(function(){return n(this,(function(e){return[2,(null!=r.fontEmbedCSS?Promise.resolve(r.fontEmbedCSS):j(t,r)).then((function(e){var n=document.createElement("style"),r=document.createTextNode(e);return n.appendChild(r),t.firstChild?t.insertBefore(n,t.firstChild):t.appendChild(n),t}))]}))}))}(t,r)})).then((function(t){return A(t,r)})).then((function(t){return function(t,e){var n=t.style;e.backgroundColor&&(n.backgroundColor=e.backgroundColor),e.width&&(n.width=e.width+"px"),e.height&&(n.height=e.height+"px");var r=e.style;return null!=r&&Object.keys(r).forEach((function(t){n[t]=r[t]})),t}(t,r)})).then((function(t){return function(t,r,o){return e(this,void 0,void 0,(function(){var e,i,u;return n(this,(function(n){return e="http://www.w3.org/2000/svg",i=document.createElementNS(e,"svg"),u=document.createElementNS(e,"foreignObject"),i.setAttribute("width",""+r),i.setAttribute("height",""+o),i.setAttribute("viewBox","0 0 "+r+" "+o),u.setAttribute("width","100%"),u.setAttribute("height","100%"),u.setAttribute("x","0"),u.setAttribute("y","0"),u.setAttribute("externalResourcesRequired","true"),i.appendChild(u),u.appendChild(t),[2,p(i)]}))}))}(t,i,u)}))]}))}))}var O=16384;function q(t,r){return void 0===r&&(r={}),e(this,void 0,void 0,(function(){return n(this,(function(e){return[2,B(t,r).then(v).then((function(e){var n=document.createElement("canvas"),o=n.getContext("2d"),i=r.pixelRatio||function(){var t,e;try{e=process}catch(t){}var n=e&&e.env?e.env.devicePixelRatio:null;return n&&(t=parseInt(n,10),Number.isNaN(t)&&(t=1)),t||window.devicePixelRatio||1}(),u=F(t,r),c=u.width,a=u.height,s=r.canvasWidth||c,f=r.canvasHeight||a;return n.width=s*i,n.height=f*i,r.skipAutoScale||function(t){(t.width>O||t.height>O)&&(t.width>O&&t.height>O?t.width>t.height?(t.height*=O/t.width,t.width=O):(t.width*=O/t.height,t.height=O):t.width>O?(t.height*=O/t.width,t.width=O):(t.width*=O/t.height,t.height=O))}(n),n.style.width=""+s,n.style.height=""+f,r.backgroundColor&&(o.fillStyle=r.backgroundColor,o.fillRect(0,0,n.width,n.height)),o.drawImage(e,0,0,n.width,n.height),n}))]}))}))}t.getFontEmbedCSS=function(t,r){return void 0===r&&(r={}),e(this,void 0,void 0,(function(){return n(this,(function(e){return[2,j(t,r)]}))}))},t.toBlob=function(t,r){return void 0===r&&(r={}),e(this,void 0,void 0,(function(){return n(this,(function(e){return[2,q(t,r).then(d)]}))}))},t.toCanvas=q,t.toJpeg=function(t,r){return void 0===r&&(r={}),e(this,void 0,void 0,(function(){return n(this,(function(e){return[2,q(t,r).then((function(t){return t.toDataURL("image/jpeg",r.quality||1)}))]}))}))},t.toPixelData=function(t,r){return void 0===r&&(r={}),e(this,void 0,void 0,(function(){var e,o,i;return n(this,(function(n){return e=F(t,r),o=e.width,i=e.height,[2,q(t,r).then((function(t){return t.getContext("2d").getImageData(0,0,o,i).data}))]}))}))},t.toPng=function(t,r){return void 0===r&&(r={}),e(this,void 0,void 0,(function(){return n(this,(function(e){return[2,q(t,r).then((function(t){return t.toDataURL()}))]}))}))},t.toSvg=B,Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=html-to-image.js.map

@@ -22,3 +22,2 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

cache: 'no-cache',
credentials: 'same-origin',
})

@@ -48,3 +47,2 @@ .then((res) => ({

cache: 'no-cache',
credentials: 'same-origin',
})

@@ -51,0 +49,0 @@ .then((res) => res.blob())

@@ -46,3 +46,2 @@ import { parseDataUrlContent } from './util';

cache: 'no-cache',
credentials: 'same-origin',
})

@@ -49,0 +48,0 @@ .then((res) =>

@@ -52,3 +52,2 @@ "use strict";

cache: 'no-cache',
credentials: 'same-origin',
})

@@ -79,3 +78,2 @@ .then(function (res) { return ({

cache: 'no-cache',
credentials: 'same-origin',
})

@@ -82,0 +80,0 @@ .then(function (res) { return res.blob(); })

@@ -49,3 +49,2 @@ "use strict";

cache: 'no-cache',
credentials: 'same-origin',
})

@@ -52,0 +51,0 @@ .then(function (res) {

{
"name": "@gd-uikit/html-to-image",
"version": "1.9.3",
"version": "1.9.4",
"description": "Generates an image from a DOM node using HTML5 canvas and SVG.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

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

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc