@inscreen/html-to-image
Advanced tools
Comparing version 1.11.11-is15 to 1.11.11-is16
@@ -1,2 +0,2 @@ | ||
!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";function e(t,e,n,r){return new(n||(n=Promise))((function(i,o){function c(t){try{a(r.next(t))}catch(t){o(t)}}function u(t){try{a(r.throw(t))}catch(t){o(t)}}function a(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,u)}a((r=r.apply(t,e||[])).next())}))}function n(t,e){var n,r,i,o,c={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(u){return function(a){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(c=0)),c;)try{if(n=1,r&&(i=2&u[0]?r.return:u[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,u[1])).done)return i;switch(r=0,i&&(u=[2&u[0],i.value]),u[0]){case 0:case 1:i=u;break;case 4:return c.label++,{value:u[1],done:!1};case 5:c.label++,r=u[1],u=[0];continue;case 7:u=c.ops.pop(),c.trys.pop();continue;default:if(!(i=c.trys,(i=i.length>0&&i[i.length-1])||6!==u[0]&&2!==u[0])){c=0;continue}if(3===u[0]&&(!i||u[1]>i[0]&&u[1]<i[3])){c.label=u[1];break}if(6===u[0]&&c.label<i[1]){c.label=i[1],i=u;break}if(i&&c.label<i[2]){c.label=i[2],c.ops.push(u);break}i[2]&&c.ops.pop(),c.trys.pop();continue}u=e.call(t,c)}catch(t){u=[6,t],r=0}finally{n=i=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,a])}}}function r(t,e,n){if(n||2===arguments.length)for(var r,i=0,o=e.length;i<o;i++)!r&&i in e||(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return t.concat(r||Array.prototype.slice.call(e))}var i,o=(i=0,function(){return i+=1,"u".concat("0000".concat((Math.random()*Math.pow(36,4)<<0).toString(36)).slice(-4)).concat(i)});function c(t){return Array.from(t)}function u(t,e){var n=(t.ownerDocument.defaultView||window).getComputedStyle(t).getPropertyValue(e);return n?parseFloat(n.replace("px","")):0}function a(t,e){void 0===e&&(e={});var n,r,i,o,c=e.width||(i=u(n=t,"border-left-width"),o=u(n,"border-right-width"),((null===(r=n.getBoundingClientRect())||void 0===r?void 0:r.width)||n.clientWidth)+i+o),a=e.height||function(t){var e,n=u(t,"border-top-width"),r=u(t,"border-bottom-width");return((null===(e=t.getBoundingClientRect())||void 0===e?void 0:e.height)||t.clientHeight)+n+r}(t);return{width:c,height:a}}var s=16384;function l(t,e){return void 0===e&&(e={}),t.toBlob?new Promise((function(n){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]),i=r.length,o=new Uint8Array(i),c=0;c<i;c+=1)o[c]=r.charCodeAt(c);n(new Blob([o],{type:e.type?e.type:"image/png"}))}))}function f(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,".concat(t)}))]}))}))}function h(t,r,i){return e(this,void 0,void 0,(function(){var e,o,c;return n(this,(function(n){return e="http://www.w3.org/2000/svg",o=document.createElementNS(e,"svg"),c=document.createElementNS(e,"foreignObject"),o.setAttribute("width","".concat(r)),o.setAttribute("height","".concat(i)),o.setAttribute("viewBox","0 0 ".concat(r," ").concat(i)),c.setAttribute("width","100%"),c.setAttribute("height","100%"),c.setAttribute("x","0"),c.setAttribute("y","0"),c.setAttribute("externalResourcesRequired","true"),o.appendChild(c),c.appendChild(t),[2,f(o)]}))}))}var d=function(t,e){return t instanceof t.ownerDocument.defaultView[e.name]},v=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return console.error.apply(console,r(["[inScreen]"],t,!1))};function g(t,e,n){var r=".".concat(t,":").concat(e),i=n.cssText?function(t){var e=t.getPropertyValue("content");return"".concat(t.cssText," content: '").concat(e.replace(/'|"/g,""),"';")}(n):function(t){return c(t).map((function(e){var n=t.getPropertyValue(e),r=t.getPropertyPriority(e);return"".concat(e,": ").concat(n).concat(r?" !important":"",";")})).join(" ")}(n);return document.createTextNode("".concat(r,"{").concat(i,"}"))}function p(t,e,n){var r=window.getComputedStyle(t,n),i=r.getPropertyValue("content");if(""!==i&&"none"!==i){var c=o();try{e.className="".concat(e.className," ").concat(c)}catch(t){return}var u=document.createElement("style");u.appendChild(g(c,n,r)),e.appendChild(u)}}function m(t){return d(t,HTMLCanvasElement)?function(t){try{var e=t.toDataURL();if("data:,"===e)return t.cloneNode(!1);var n=document.createElement("img");return n.src=e,n}catch(e){return v("Unable to inline canvas contents, canvas is tainted",t),null}}(t):d(t,HTMLVideoElement)?function(t){try{var e=void 0;if(t.currentSrc){var n=document.createElement("canvas"),r=n.getContext("2d");n.width=t.clientWidth,n.height=t.clientHeight,null==r||r.drawImage(t,0,0,n.width,n.height),e=n.toDataURL()}var i=document.createElement("img");return i.src=null!=e?e:t.poster,i}catch(e){return v("Unable to clone video as it is tainted",t),null}}(t):d(t,HTMLIFrameElement)?function(t){var e;try{if(null===(e=null==t?void 0:t.contentDocument)||void 0===e?void 0:e.body)return w(t.contentDocument.body,{})}catch(e){v("Failed to clone iframe",t)}return t.cloneNode(!1)}(t):t.cloneNode(!1)}function w(t,e){if(function(t){return 3===t.nodeType}(t))return document.createTextNode(t.data);if(!function(t){return 1===t.nodeType}(t))return t.cloneNode(!1);if(e.filter&&!e.filter(t))return null;var n=window.getComputedStyle(t);if("none"===n.getPropertyValue("display"))return null;var r=m(t);return r?(function(t,e,n){var r=e.style;r&&(n.cssText?(r.cssText=n.cssText,r.transformOrigin=n.transformOrigin):c(n).forEach((function(i){var o=n.getPropertyValue(i);if("font-size"===i&&o.endsWith("px")){var c=Math.floor(parseFloat(o.substring(0,o.length-2)))-.1;o="".concat(c,"px")}"display"===i&&"inline"===o&&d(t,HTMLIFrameElement)&&(o="block"),"d"===i&&e.getAttribute("d")&&(o="path(".concat(e.getAttribute("d"),")")),r.setProperty(i,o,n.getPropertyPriority(i))})))}(t,r,n),function(t,e){p(t,e,":before"),p(t,e,":after")}(t,r),function(t,e){d(t,HTMLTextAreaElement)&&(e.innerHTML=t.value),d(t,HTMLInputElement)&&e.setAttribute("value",t.value)}(t,r),function(t,e){if(d(t,HTMLSelectElement)){var n=e,r=Array.from(n.children).find((function(e){return t.value===e.getAttribute("value")}));r&&r.setAttribute("selected","")}}(t,r),function(t,e,n){var r,i,o,u=[];if(0===(u=null!=(o=t).tagName&&"SLOT"===o.tagName.toUpperCase()&&t.assignedNodes?c(t.assignedNodes()):d(t,HTMLIFrameElement)&&(null===(r=t.contentDocument)||void 0===r?void 0:r.body)?c(t.contentDocument.body.childNodes):c((null!==(i=t.shadowRoot)&&void 0!==i?i:t).childNodes)).length||d(t,HTMLVideoElement))return e;for(var a=0;a<u.length;a++){var s=w(u[a],n);s&&e.appendChild(s)}}(t,r,e),function(t,e){if(0!==t.scrollTop||0!==t.scrollLeft)for(var n=0;n<e.children.length;n++){var r=e.children[n];if(!("style"in r))return;r.style.transform=new DOMMatrix(r.style.transform).translateSelf(-t.scrollLeft,-t.scrollTop).toString()}}(t,r),r):null}var y="application/font-woff",b="image/jpeg",x={woff:y,woff2:y,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:b,jpeg:b,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function S(t){var e=function(t){var e=/\.([^./]*?)$/g.exec(t);return e?e[1]:""}(t).toLowerCase();return x[e]||""}function E(t){return-1!==t.search(/^(data:)/)}function R(t,e){return"data:".concat(e,";base64,").concat(t)}function C(t,r,i){return e(this,void 0,void 0,(function(){var e,o;return n(this,(function(n){switch(n.label){case 0:return[4,fetch(t,r)];case 1:if(404===(e=n.sent()).status)throw new Error('Resource "'.concat(e.url,'" not found'));return[4,e.blob()];case 2:return o=n.sent(),[2,new Promise((function(t,n){var r=new FileReader;r.onerror=n,r.onloadend=function(){try{t(i({res:e,result:r.result}))}catch(t){n(t)}},r.readAsDataURL(o)}))]}}))}))}var T={};function P(t,r,i){return e(this,void 0,void 0,(function(){var e,o,c,u,a;return n(this,(function(n){switch(n.label){case 0:if(e=function(t,e,n){var r=t.replace(/\?.*/,"");return n&&(r=t),/ttf|otf|eot|woff2?/i.test(r)&&(r=r.replace(/.*\//,"")),e?"[".concat(e,"]").concat(r):r}(t,r,i.includeQueryParams),null!=T[e])return[2,T[e]];i.cacheBust&&(t+=(/\?/.test(t)?"&":"?")+(new Date).getTime()),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,C(t,i.fetchRequestInit,(function(t){var e=t.res,n=t.result;return r||(r=e.headers.get("Content-Type")||""),function(t){return t.split(/,/)[1]}(n)}))];case 2:return c=n.sent(),o=R(c,r),[3,4];case 3:return u=n.sent(),o=i.imagePlaceholder||"",a="Failed to fetch resource: ".concat(t),u&&(a="string"==typeof u?u:u.message),a&&v(a),[3,4];case 4:return T[e]=o,[2,o]}}))}))}var L=/url\((['"]?)([^'"]+?)\1\)/g,A=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,N=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function k(t,r,i,o,c){return e(this,void 0,void 0,(function(){var e,u,a,s;return n(this,(function(n){switch(n.label){case 0:return n.trys.push([0,5,,6]),e=i?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"),i=n.createElement("a");return n.head.appendChild(r),n.body.appendChild(i),e&&(r.href=e),i.href=t,i.href}(r,i):r,u=S(r),a=void 0,c?[4,c(e)]:[3,2];case 1:return s=n.sent(),a=R(s,u),[3,4];case 2:return[4,P(e,u,o)];case 3:a=n.sent(),n.label=4;case 4:return[2,t.replace((l=r,f=l.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1"),new RegExp("(url\\(['\"]?)(".concat(f,")(['\"]?\\))"),"g")),"$1".concat(a,"$3"))];case 5:return n.sent(),[3,6];case 6:return[2,t]}var l,f}))}))}function D(t){return-1!==t.search(L)}function I(t,r,i){return e(this,void 0,void 0,(function(){var e,o;return n(this,(function(n){return D(t)?(e=function(t,e){var n=e.preferredFontFormat;return n?t.replace(N,(function(t){for(;;){var e=A.exec(t)||[],r=e[0],i=e[2];if(!i)return"";if(i===n)return"src: ".concat(r,";")}})):t}(t,i),o=function(t){var e=[];return t.replace(L,(function(t,n,r){return e.push(r),t})),e.filter((function(t){return!E(t)}))}(e),[2,o.reduce((function(t,e){return t.then((function(t){return k(t,e,r,i)}))}),Promise.resolve(e))]):[2,t]}))}))}function M(t,r,i){var o;return e(this,void 0,void 0,(function(){var e,c;return n(this,(function(n){switch(n.label){case 0:return(e=null===(o=r.style)||void 0===o?void 0:o.getPropertyValue(t))?[4,I(e,null,i)]:[3,2];case 1:return c=n.sent(),r.style.setProperty(t,c,r.style.getPropertyPriority(t)),[2,!0];case 2:return[2,!1]}}))}))}function V(t,r){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,M("background",t,r)];case 1:return e.sent()?[3,3]:[4,M("background-image",t,r)];case 2:e.sent(),e.label=3;case 3:return[4,M("mask",t,r)];case 4:return e.sent()?[3,6]:[4,M("mask-image",t,r)];case 5:e.sent(),e.label=6;case 6:return[2]}}))}))}function F(t,r){return e(this,void 0,void 0,(function(){var e,i,o;return n(this,(function(n){switch(n.label){case 0:return(e=d(t,HTMLImageElement))&&!E(t.src)||d(t,SVGImageElement)&&!E(t.href.baseVal)?[4,P(i=e?t.src:t.href.baseVal,S(i),r)]:[2];case 1:o=n.sent(),n.label=2;case 2:return n.trys.push([2,4,,5]),[4,new Promise((function(n,r){t.onload=n,t.onerror=r;var i=t;i.decode&&(i.decode=n),"lazy"===i.loading&&(i.loading="eager"),e?(t.srcset="",t.src=o):t.href.baseVal=o}))];case 3:return n.sent(),[3,5];case 4:return n.sent(),v("Failed to fetch image: ".concat(i)),[3,5];case 5:return[2]}}))}))}function H(t,r){return e(this,void 0,void 0,(function(){var e,i;return n(this,(function(n){switch(n.label){case 0:return e=c(t.childNodes),i=e.map((function(t){return U(t,r)})),[4,Promise.all(i).then((function(){return t}))];case 1:return n.sent(),[2]}}))}))}function U(t,r){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return d(t,Element)?[4,V(t,r)]:[3,4];case 1:return e.sent(),[4,F(t,r)];case 2:return e.sent(),[4,H(t,r)];case 3:e.sent(),e.label=4;case 4:return[2]}}))}))}var j={};function B(t){return e(this,void 0,void 0,(function(){var e,r;return n(this,(function(n){switch(n.label){case 0:return null!=(e=j[t])?[2,e]:[4,fetch(t)];case 1:return[4,n.sent().text()];case 2:return r=n.sent(),e={url:t,cssText:r},j[t]=e,[2,e]}}))}))}function O(t,r){return e(this,void 0,void 0,(function(){var i,o,c,u,a=this;return n(this,(function(s){return i=t.cssText,o=/url\(["']?([^"')]+)["']?\)/g,c=i.match(/url\([^)]+\)/g)||[],u=c.map((function(c){return e(a,void 0,void 0,(function(){var e;return n(this,(function(n){return(e=c.replace(o,"$1")).startsWith("https://")||(e=new URL(e,t.url).href),[2,C(e,r.fetchRequestInit,(function(t){var e=t.result;return i=i.replace(c,"url(".concat(e,")")),[c,e]}))]}))}))})),[2,Promise.all(u).then((function(){return i}))]}))}))}function q(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===(c=r.exec(n)))break;e.push(c[0])}n=n.replace(r,"");for(var i=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,o=new RegExp("((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})","gi");;){var c;if(null===(c=i.exec(n))){if(null===(c=o.exec(n)))break;i.lastIndex=o.lastIndex}else o.lastIndex=i.lastIndex;e.push(c[0])}return e}function z(t,r){return e(this,void 0,void 0,(function(){var e,i;return n(this,(function(n){return e=[],i=[],t.filter((function(t){try{return"cssRules"in t&&t.cssRules}catch(t){return!1}})).forEach((function(e){try{c(e.cssRules||[]).forEach((function(t,n){if(t.type===CSSRule.IMPORT_RULE){var o=n+1,c=B(t.href).then((function(t){return O(t,r)})).then((function(t){return q(t).forEach((function(t){try{e.insertRule(t,t.startsWith("@import")?o+=1:e.cssRules.length)}catch(e){v("Error inserting rule from remote css",{rule:t,error:e})}}))})).catch((function(t){v("Error loading remote css",t.toString())}));i.push(c)}}))}catch(o){var n=t.find((function(t){return null==t.href}))||document.styleSheets[0];null!=e.href&&i.push(B(e.href).then((function(t){return O(t,r)})).then((function(t){return q(t).forEach((function(t){n.insertRule(t,e.cssRules.length)}))})).catch((function(t){v("Error loading remote stylesheet",t)}))),v("Error inlining remote css file",o)}})),[2,Promise.all(i).then((function(){return t.filter((function(t){try{return"cssRules"in t&&t.cssRules}catch(t){return!1}})).forEach((function(t){try{c(t.cssRules||[]).forEach((function(t){e.push(t)}))}catch(e){v("Error while reading CSS rules from ".concat(t.href),e)}})),e}))]}))}))}function W(t){return t.filter((function(t){return t.type===CSSRule.FONT_FACE_RULE})).filter((function(t){return D(t.style.getPropertyValue("src"))}))}function $(t,r){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:if(null==t.ownerDocument)throw new Error("Provided element is not within a Document");return[4,z(c(t.ownerDocument.styleSheets),r)];case 1:return[2,W(e.sent())]}}))}))}function _(t,r){return e(this,void 0,void 0,(function(){var e;return n(this,(function(n){switch(n.label){case 0:return[4,$(t,r)];case 1:return e=n.sent(),[4,Promise.all(e.map((function(t){var e=t.parentStyleSheet?t.parentStyleSheet.href:null;return I(t.cssText,e,r)})))];case 2:return[2,n.sent().join("\n")]}}))}))}function G(t,r){return e(this,void 0,void 0,(function(){var e,i,o,c,u;return n(this,(function(n){switch(n.label){case 0:return null==r.fontEmbedCSS?[3,1]:(i=r.fontEmbedCSS,[3,5]);case 1:return r.skipFonts?(o=null,[3,4]):[3,2];case 2:return[4,_(t,r)];case 3:o=n.sent(),n.label=4;case 4:i=o,n.label=5;case 5:return(e=i)&&(c=document.createElement("style"),u=document.createTextNode(e),c.appendChild(u),t.firstChild?t.insertBefore(c,t.firstChild):t.appendChild(c)),[2]}}))}))}function J(t,r){return void 0===r&&(r={}),e(this,void 0,void 0,(function(){var e,i,o,c;return n(this,(function(n){switch(n.label){case 0:return e=a(t,r),i=e.width,o=e.height,[4,G(c=w(t,r),r)];case 1:return n.sent(),[4,U(c,r)];case 2:return n.sent(),function(t,e){var n=t.style;e.backgroundColor&&(n.backgroundColor=e.backgroundColor),e.width&&(n.width="".concat(e.width,"px")),e.height&&(n.height="".concat(e.height,"px"));var r=e.style;null!=r&&Object.keys(r).forEach((function(t){n[t]=r[t]}))}(c,r),[4,h(c,i,o)];case 3:return[2,n.sent()]}}))}))}function Q(t,r){return void 0===r&&(r={}),e(this,void 0,void 0,(function(){var e,i,o,c,u,l,f,h,d,v;return n(this,(function(n){switch(n.label){case 0:return e=a(t,r),i=e.width,o=e.height,[4,J(t,r)];case 1:return c=n.sent(),[4,(g=c,new Promise((function(t,e){var n=new Image;n.decode=function(){return t(n)},n.onload=function(){return t(n)},n.onerror=e,n.crossOrigin="anonymous",n.decoding="async",n.src=g})))];case 2:return u=n.sent(),l=document.createElement("canvas"),f=l.getContext("2d"),h=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}(),d=r.canvasWidth||i,v=r.canvasHeight||o,l.width=d*h,l.height=v*h,r.skipAutoScale||function(t){(t.width>s||t.height>s)&&(t.width>s&&t.height>s?t.width>t.height?(t.height*=s/t.width,t.width=s):(t.width*=s/t.height,t.height=s):t.width>s?(t.height*=s/t.width,t.width=s):(t.width*=s/t.height,t.height=s))}(l),l.style.width="".concat(d),l.style.height="".concat(v),r.backgroundColor&&(f.fillStyle=r.backgroundColor,f.fillRect(0,0,l.width,l.height)),f.drawImage(u,0,0,l.width,l.height),[2,l]}var g}))}))}t.getFontEmbedCSS=function(t,r){return void 0===r&&(r={}),e(this,void 0,void 0,(function(){return n(this,(function(e){return[2,_(t,r)]}))}))},t.toBlob=function(t,r){return void 0===r&&(r={}),e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,Q(t,r)];case 1:return[4,l(e.sent(),r)];case 2:return[2,e.sent()]}}))}))},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){switch(e.label){case 0:return[4,Q(t,r)];case 1:return[2,e.sent().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,i,o,c;return n(this,(function(n){switch(n.label){case 0:return e=a(t,r),i=e.width,o=e.height,[4,Q(t,r)];case 1:return c=n.sent(),[2,c.getContext("2d").getImageData(0,0,i,o).data]}}))}))},t.toPng=function(t,r){return void 0===r&&(r={}),e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,Q(t,r)];case 1:return[2,e.sent().toDataURL()]}}))}))},t.toSvg=J})); | ||
!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";function e(t,e,n,r){return new(n||(n=Promise))((function(i,o){function c(t){try{a(r.next(t))}catch(t){o(t)}}function u(t){try{a(r.throw(t))}catch(t){o(t)}}function a(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,u)}a((r=r.apply(t,e||[])).next())}))}function n(t,e){var n,r,i,o,c={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(u){return function(a){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(c=0)),c;)try{if(n=1,r&&(i=2&u[0]?r.return:u[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,u[1])).done)return i;switch(r=0,i&&(u=[2&u[0],i.value]),u[0]){case 0:case 1:i=u;break;case 4:return c.label++,{value:u[1],done:!1};case 5:c.label++,r=u[1],u=[0];continue;case 7:u=c.ops.pop(),c.trys.pop();continue;default:if(!(i=c.trys,(i=i.length>0&&i[i.length-1])||6!==u[0]&&2!==u[0])){c=0;continue}if(3===u[0]&&(!i||u[1]>i[0]&&u[1]<i[3])){c.label=u[1];break}if(6===u[0]&&c.label<i[1]){c.label=i[1],i=u;break}if(i&&c.label<i[2]){c.label=i[2],c.ops.push(u);break}i[2]&&c.ops.pop(),c.trys.pop();continue}u=e.call(t,c)}catch(t){u=[6,t],r=0}finally{n=i=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,a])}}}function r(t,e,n){if(n||2===arguments.length)for(var r,i=0,o=e.length;i<o;i++)!r&&i in e||(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return t.concat(r||Array.prototype.slice.call(e))}var i,o=(i=0,function(){return i+=1,"u".concat("0000".concat((Math.random()*Math.pow(36,4)<<0).toString(36)).slice(-4)).concat(i)});function c(t){return Array.from(t)}function u(t,e){var n=(t.ownerDocument.defaultView||window).getComputedStyle(t).getPropertyValue(e);return n?parseFloat(n.replace("px","")):0}function a(t,e){void 0===e&&(e={});var n,r,i,o,c=e.width||(i=u(n=t,"border-left-width"),o=u(n,"border-right-width"),((null===(r=n.getBoundingClientRect())||void 0===r?void 0:r.width)||n.clientWidth)+i+o),a=e.height||function(t){var e,n=u(t,"border-top-width"),r=u(t,"border-bottom-width");return((null===(e=t.getBoundingClientRect())||void 0===e?void 0:e.height)||t.clientHeight)+n+r}(t);return{width:c,height:a}}var s=16384;function l(t,e){return void 0===e&&(e={}),t.toBlob?new Promise((function(n){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]),i=r.length,o=new Uint8Array(i),c=0;c<i;c+=1)o[c]=r.charCodeAt(c);n(new Blob([o],{type:e.type?e.type:"image/png"}))}))}function f(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,".concat(t)}))]}))}))}function h(t,r,i){return e(this,void 0,void 0,(function(){var e,o,c;return n(this,(function(n){return e="http://www.w3.org/2000/svg",o=document.createElementNS(e,"svg"),c=document.createElementNS(e,"foreignObject"),o.setAttribute("width","".concat(r)),o.setAttribute("height","".concat(i)),o.setAttribute("viewBox","0 0 ".concat(r," ").concat(i)),c.setAttribute("width","100%"),c.setAttribute("height","100%"),c.setAttribute("x","0"),c.setAttribute("y","0"),c.setAttribute("externalResourcesRequired","true"),o.appendChild(c),c.appendChild(t),[2,f(o)]}))}))}var d=function(t,e){return t instanceof t.ownerDocument.defaultView[e.name]},v=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return console.error.apply(console,r(["[inScreen]"],t,!1))};function g(t,e,n){var r=".".concat(t,":").concat(e),i=n.cssText?function(t){var e=t.getPropertyValue("content");return"".concat(t.cssText," content: '").concat(e.replace(/'|"/g,""),"';")}(n):function(t){return c(t).map((function(e){var n=t.getPropertyValue(e),r=t.getPropertyPriority(e);return"".concat(e,": ").concat(n).concat(r?" !important":"",";")})).join(" ")}(n);return document.createTextNode("".concat(r,"{").concat(i,"}"))}function p(t,e,n){var r=window.getComputedStyle(t,n),i=r.getPropertyValue("content");if(""!==i&&"none"!==i){var c=o();try{e.className="".concat(e.className," ").concat(c)}catch(t){return}var u=document.createElement("style");u.appendChild(g(c,n,r)),e.appendChild(u)}}function m(t){return d(t,HTMLCanvasElement)?function(t){try{var e=t.toDataURL();if("data:,"===e)return t.cloneNode(!1);var n=document.createElement("img");return n.src=e,n}catch(e){return v("Unable to inline canvas contents, canvas is tainted",t),null}}(t):d(t,HTMLVideoElement)?function(t){try{var e=void 0;if(t.currentSrc){var n=document.createElement("canvas"),r=n.getContext("2d");n.width=t.clientWidth,n.height=t.clientHeight,null==r||r.drawImage(t,0,0,n.width,n.height),e=n.toDataURL()}var i=document.createElement("img");return i.src=null!=e?e:t.poster,i}catch(e){return v("Unable to clone video as it is tainted",t),null}}(t):d(t,HTMLIFrameElement)?function(t){var e;try{if(null===(e=null==t?void 0:t.contentDocument)||void 0===e?void 0:e.body)return w(t.contentDocument.body,{})}catch(e){v("Failed to clone iframe",t)}return t.cloneNode(!1)}(t):t.cloneNode(!1)}function w(t,e){if(function(t){return 3===t.nodeType}(t))return document.createTextNode(t.data);if(!function(t){return 1===t.nodeType}(t))return t.cloneNode(!1);if(e.filter&&!e.filter(t))return null;var n=window.getComputedStyle(t);if("none"===n.getPropertyValue("display"))return null;var r=m(t);return r?(function(t,e,n){var r=e.style;r&&(n.cssText?(r.cssText=n.cssText,r.transformOrigin=n.transformOrigin):c(n).forEach((function(i){var o=n.getPropertyValue(i);if("font-size"===i&&o.endsWith("px")){var c=Math.floor(parseFloat(o.substring(0,o.length-2)))-.1;o="".concat(c,"px")}"display"===i&&"inline"===o&&d(t,HTMLIFrameElement)&&(o="block"),"d"===i&&e.getAttribute("d")&&(o="path(".concat(e.getAttribute("d"),")")),r.setProperty(i,o,n.getPropertyPriority(i))})))}(t,r,n),function(t,e){p(t,e,":before"),p(t,e,":after")}(t,r),function(t,e){d(t,HTMLTextAreaElement)&&(e.innerHTML=t.value),d(t,HTMLInputElement)&&e.setAttribute("value",t.value)}(t,r),function(t,e){if(d(t,HTMLSelectElement)){var n=e,r=Array.from(n.children).find((function(e){return t.value===e.getAttribute("value")}));r&&r.setAttribute("selected","")}}(t,r),function(t,e,n){var r,i,o,u=[];if(0===(u=null!=(o=t).tagName&&"SLOT"===o.tagName.toUpperCase()&&t.assignedNodes?c(t.assignedNodes()):d(t,HTMLIFrameElement)&&(null===(r=t.contentDocument)||void 0===r?void 0:r.body)?c(t.contentDocument.body.childNodes):c((null!==(i=t.shadowRoot)&&void 0!==i?i:t).childNodes)).length||d(t,HTMLVideoElement))return e;for(var a=0;a<u.length;a++){var s=w(u[a],n);s&&e.appendChild(s)}}(t,r,e),function(t,e){if(0!==t.scrollTop||0!==t.scrollLeft)for(var n=0;n<e.children.length;n++){var r=e.children[n];if(!("style"in r))return;r.style.transform=new DOMMatrix(r.style.transform).translateSelf(-t.scrollLeft,-t.scrollTop).toString()}}(t,r),r):null}var y="application/font-woff",b="image/jpeg",x={woff:y,woff2:y,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:b,jpeg:b,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function S(t){var e=function(t){var e=/\.([^./]*?)$/g.exec(t);return e?e[1]:""}(t).toLowerCase();return x[e]||""}function E(t){return-1!==t.search(/^(data:)/)}function C(t,e){return"data:".concat(e,";base64,").concat(t)}function R(t,r,i){return e(this,void 0,void 0,(function(){var e,o;return n(this,(function(n){switch(n.label){case 0:return[4,fetch(t,r)];case 1:if(404===(e=n.sent()).status)throw new Error('Resource "'.concat(e.url,'" not found'));return[4,e.blob()];case 2:return o=n.sent(),[2,new Promise((function(t,n){var r=new FileReader;r.onerror=n,r.onloadend=function(){try{t(i({res:e,result:r.result}))}catch(t){n(t)}},r.readAsDataURL(o)}))]}}))}))}var P={};function T(t,r,i){return e(this,void 0,void 0,(function(){var e,o,c,u,a;return n(this,(function(n){switch(n.label){case 0:if(e=function(t,e,n){var r=t.replace(/\?.*/,"");return n&&(r=t),/ttf|otf|eot|woff2?/i.test(r)&&(r=r.replace(/.*\//,"")),e?"[".concat(e,"]").concat(r):r}(t,r,i.includeQueryParams),null!=P[e])return[2,P[e]];i.useCorsProxy&&(t=i.customCorsProxyUrl+encodeURIComponent(t)),i.cacheBust&&(t+=(/\?/.test(t)?"&":"?")+(new Date).getTime()),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,R(t,i.fetchRequestInit,(function(t){var e=t.res,n=t.result;return r||(r=e.headers.get("Content-Type")||""),function(t){return t.split(/,/)[1]}(n)}))];case 2:return c=n.sent(),o=C(c,r),[3,4];case 3:return u=n.sent(),o=i.imagePlaceholder||"",a="Failed to fetch resource: ".concat(t),u&&(a="string"==typeof u?u:u.message),a&&v(a),[3,4];case 4:return P[e]=o,[2,o]}}))}))}var L=/url\((['"]?)([^'"]+?)\1\)/g,A=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,N=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function I(t,r,i,o,c){return e(this,void 0,void 0,(function(){var e,u,a,s;return n(this,(function(n){switch(n.label){case 0:return n.trys.push([0,5,,6]),e=i?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"),i=n.createElement("a");return n.head.appendChild(r),n.body.appendChild(i),e&&(r.href=e),i.href=t,i.href}(r,i):r,u=S(r),a=void 0,c?[4,c(e)]:[3,2];case 1:return s=n.sent(),a=C(s,u),[3,4];case 2:return[4,T(e,u,o)];case 3:a=n.sent(),n.label=4;case 4:return[2,t.replace((l=r,f=l.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1"),new RegExp("(url\\(['\"]?)(".concat(f,")(['\"]?\\))"),"g")),"$1".concat(a,"$3"))];case 5:return n.sent(),[3,6];case 6:return[2,t]}var l,f}))}))}function k(t){return-1!==t.search(L)}function D(t,r,i){return e(this,void 0,void 0,(function(){var e,o;return n(this,(function(n){return k(t)?(e=function(t,e){var n=e.preferredFontFormat;return n?t.replace(N,(function(t){for(;;){var e=A.exec(t)||[],r=e[0],i=e[2];if(!i)return"";if(i===n)return"src: ".concat(r,";")}})):t}(t,i),o=function(t){var e=[];return t.replace(L,(function(t,n,r){return e.push(r),t})),e.filter((function(t){return!E(t)}))}(e),[2,o.reduce((function(t,e){return t.then((function(t){return I(t,e,r,i)}))}),Promise.resolve(e))]):[2,t]}))}))}function M(t,r,i){var o;return e(this,void 0,void 0,(function(){var e,c;return n(this,(function(n){switch(n.label){case 0:return(e=null===(o=r.style)||void 0===o?void 0:o.getPropertyValue(t))?[4,D(e,null,i)]:[3,2];case 1:return c=n.sent(),r.style.setProperty(t,c,r.style.getPropertyPriority(t)),[2,!0];case 2:return[2,!1]}}))}))}function U(t,r){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,M("background",t,r)];case 1:return e.sent()?[3,3]:[4,M("background-image",t,r)];case 2:e.sent(),e.label=3;case 3:return[4,M("mask",t,r)];case 4:return e.sent()?[3,6]:[4,M("mask-image",t,r)];case 5:e.sent(),e.label=6;case 6:return[2]}}))}))}function V(t,r){return e(this,void 0,void 0,(function(){var e,i,o;return n(this,(function(n){switch(n.label){case 0:return(e=d(t,HTMLImageElement))&&!E(t.src)||d(t,SVGImageElement)&&!E(t.href.baseVal)?[4,T(i=e?t.src:t.href.baseVal,S(i),r)]:[2];case 1:o=n.sent(),n.label=2;case 2:return n.trys.push([2,4,,5]),[4,new Promise((function(n,r){t.onload=n,t.onerror=r;var i=t;i.decode&&(i.decode=n),"lazy"===i.loading&&(i.loading="eager"),e?(t.srcset="",t.src=o):t.href.baseVal=o}))];case 3:return n.sent(),[3,5];case 4:return n.sent(),v("Failed to fetch image: ".concat(i)),[3,5];case 5:return[2]}}))}))}function F(t,r){return e(this,void 0,void 0,(function(){var e,i;return n(this,(function(n){switch(n.label){case 0:return e=c(t.childNodes),i=e.map((function(t){return H(t,r)})),[4,Promise.all(i).then((function(){return t}))];case 1:return n.sent(),[2]}}))}))}function H(t,r){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return d(t,Element)?[4,U(t,r)]:[3,4];case 1:return e.sent(),[4,V(t,r)];case 2:return e.sent(),[4,F(t,r)];case 3:e.sent(),e.label=4;case 4:return[2]}}))}))}var j={};function B(t){return e(this,void 0,void 0,(function(){var e,r;return n(this,(function(n){switch(n.label){case 0:return null!=(e=j[t])?[2,e]:[4,fetch(t)];case 1:return[4,n.sent().text()];case 2:return r=n.sent(),e={url:t,cssText:r},j[t]=e,[2,e]}}))}))}function O(t,r){return e(this,void 0,void 0,(function(){var i,o,c,u,a=this;return n(this,(function(s){return i=t.cssText,o=/url\(["']?([^"')]+)["']?\)/g,c=i.match(/url\([^)]+\)/g)||[],u=c.map((function(c){return e(a,void 0,void 0,(function(){var e;return n(this,(function(n){return(e=c.replace(o,"$1")).startsWith("https://")||(e=new URL(e,t.url).href),[2,R(e,r.fetchRequestInit,(function(t){var e=t.result;return i=i.replace(c,"url(".concat(e,")")),[c,e]}))]}))}))})),[2,Promise.all(u).then((function(){return i}))]}))}))}function q(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===(c=r.exec(n)))break;e.push(c[0])}n=n.replace(r,"");for(var i=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,o=new RegExp("((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})","gi");;){var c;if(null===(c=i.exec(n))){if(null===(c=o.exec(n)))break;i.lastIndex=o.lastIndex}else o.lastIndex=i.lastIndex;e.push(c[0])}return e}function z(t,r){return e(this,void 0,void 0,(function(){var e,i;return n(this,(function(n){return e=[],i=[],t.filter((function(t){try{return"cssRules"in t&&t.cssRules}catch(t){return!1}})).forEach((function(e){try{c(e.cssRules||[]).forEach((function(t,n){if(t.type===CSSRule.IMPORT_RULE){var o=n+1,c=B(t.href).then((function(t){return O(t,r)})).then((function(t){return q(t).forEach((function(t){try{e.insertRule(t,t.startsWith("@import")?o+=1:e.cssRules.length)}catch(e){v("Error inserting rule from remote css",{rule:t,error:e})}}))})).catch((function(t){v("Error loading remote css",t.toString())}));i.push(c)}}))}catch(o){var n=t.find((function(t){return null==t.href}))||document.styleSheets[0];null!=e.href&&i.push(B(e.href).then((function(t){return O(t,r)})).then((function(t){return q(t).forEach((function(t){n.insertRule(t,e.cssRules.length)}))})).catch((function(t){v("Error loading remote stylesheet",t)}))),v("Error inlining remote css file",o)}})),[2,Promise.all(i).then((function(){return t.filter((function(t){try{return"cssRules"in t&&t.cssRules}catch(t){return!1}})).forEach((function(t){try{c(t.cssRules||[]).forEach((function(t){e.push(t)}))}catch(e){v("Error while reading CSS rules from ".concat(t.href),e)}})),e}))]}))}))}function W(t){return t.filter((function(t){return t.type===CSSRule.FONT_FACE_RULE})).filter((function(t){return k(t.style.getPropertyValue("src"))}))}function $(t,r){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:if(null==t.ownerDocument)throw new Error("Provided element is not within a Document");return[4,z(c(t.ownerDocument.styleSheets),r)];case 1:return[2,W(e.sent())]}}))}))}function _(t,r){return e(this,void 0,void 0,(function(){var e;return n(this,(function(n){switch(n.label){case 0:return[4,$(t,r)];case 1:return e=n.sent(),[4,Promise.all(e.map((function(t){var e=t.parentStyleSheet?t.parentStyleSheet.href:null;return D(t.cssText,e,r)})))];case 2:return[2,n.sent().join("\n")]}}))}))}function G(t,r){return e(this,void 0,void 0,(function(){var e,i,o,c,u;return n(this,(function(n){switch(n.label){case 0:return null==r.fontEmbedCSS?[3,1]:(i=r.fontEmbedCSS,[3,5]);case 1:return r.skipFonts?(o=null,[3,4]):[3,2];case 2:return[4,_(t,r)];case 3:o=n.sent(),n.label=4;case 4:i=o,n.label=5;case 5:return(e=i)&&(c=document.createElement("style"),u=document.createTextNode(e),c.appendChild(u),t.firstChild?t.insertBefore(c,t.firstChild):t.appendChild(c)),[2]}}))}))}function J(t,r){return void 0===r&&(r={}),e(this,void 0,void 0,(function(){var e,i,o,c;return n(this,(function(n){switch(n.label){case 0:return e=a(t,r),i=e.width,o=e.height,[4,G(c=w(t,r),r)];case 1:return n.sent(),[4,H(c,r)];case 2:return n.sent(),function(t,e){var n=t.style;e.backgroundColor&&(n.backgroundColor=e.backgroundColor),e.width&&(n.width="".concat(e.width,"px")),e.height&&(n.height="".concat(e.height,"px"));var r=e.style;null!=r&&Object.keys(r).forEach((function(t){n[t]=r[t]}))}(c,r),[4,h(c,i,o)];case 3:return[2,n.sent()]}}))}))}function Q(t,r){return void 0===r&&(r={}),e(this,void 0,void 0,(function(){var e,i,o,c,u,l,f,h,d,v;return n(this,(function(n){switch(n.label){case 0:return e=a(t,r),i=e.width,o=e.height,[4,J(t,r)];case 1:return c=n.sent(),[4,(g=c,new Promise((function(t,e){var n=new Image;n.decode=function(){return t(n)},n.onload=function(){return t(n)},n.onerror=e,n.crossOrigin="anonymous",n.decoding="async",n.src=g})))];case 2:return u=n.sent(),l=document.createElement("canvas"),f=l.getContext("2d"),h=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}(),d=r.canvasWidth||i,v=r.canvasHeight||o,l.width=d*h,l.height=v*h,r.skipAutoScale||function(t){(t.width>s||t.height>s)&&(t.width>s&&t.height>s?t.width>t.height?(t.height*=s/t.width,t.width=s):(t.width*=s/t.height,t.height=s):t.width>s?(t.height*=s/t.width,t.width=s):(t.width*=s/t.height,t.height=s))}(l),l.style.width="".concat(d),l.style.height="".concat(v),r.backgroundColor&&(f.fillStyle=r.backgroundColor,f.fillRect(0,0,l.width,l.height)),f.drawImage(u,0,0,l.width,l.height),[2,l]}var g}))}))}t.getFontEmbedCSS=function(t,r){return void 0===r&&(r={}),e(this,void 0,void 0,(function(){return n(this,(function(e){return[2,_(t,r)]}))}))},t.toBlob=function(t,r){return void 0===r&&(r={}),e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,Q(t,r)];case 1:return[4,l(e.sent(),r)];case 2:return[2,e.sent()]}}))}))},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){switch(e.label){case 0:return[4,Q(t,r)];case 1:return[2,e.sent().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,i,o,c;return n(this,(function(n){switch(n.label){case 0:return e=a(t,r),i=e.width,o=e.height,[4,Q(t,r)];case 1:return c=n.sent(),[2,c.getContext("2d").getImageData(0,0,i,o).data]}}))}))},t.toPng=function(t,r){return void 0===r&&(r={}),e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,Q(t,r)];case 1:return[2,e.sent().toDataURL()]}}))}))},t.toSvg=J})); | ||
//# sourceMappingURL=html-to-image.js.map |
@@ -48,2 +48,6 @@ import { consoleError } from './util'; | ||
} | ||
if (options.useCorsProxy) { | ||
// eslint-disable-next-line no-param-reassign | ||
resourceUrl = options.customCorsProxyUrl + encodeURIComponent(resourceUrl); | ||
} | ||
// ref: https://developer.mozilla.org/en/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest#Bypassing_the_cache | ||
@@ -50,0 +54,0 @@ if (options.cacheBust) { |
@@ -86,2 +86,4 @@ export interface Options { | ||
fetchRequestInit?: RequestInit; | ||
useCorsProxy?: boolean; | ||
customCorsProxyUrl?: string; | ||
} |
@@ -106,2 +106,6 @@ "use strict"; | ||
} | ||
if (options.useCorsProxy) { | ||
// eslint-disable-next-line no-param-reassign | ||
resourceUrl = options.customCorsProxyUrl + encodeURIComponent(resourceUrl); | ||
} | ||
// ref: https://developer.mozilla.org/en/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest#Bypassing_the_cache | ||
@@ -108,0 +112,0 @@ if (options.cacheBust) { |
@@ -86,2 +86,4 @@ export interface Options { | ||
fetchRequestInit?: RequestInit; | ||
useCorsProxy?: boolean; | ||
customCorsProxyUrl?: string; | ||
} |
{ | ||
"name": "@inscreen/html-to-image", | ||
"version": "1.11.11-is15", | ||
"version": "1.11.11-is16", | ||
"description": "Generates an image from a DOM node using HTML5 canvas and SVG.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -77,2 +77,7 @@ import { Options } from './types' | ||
if (options.useCorsProxy) { | ||
// eslint-disable-next-line no-param-reassign | ||
resourceUrl = options.customCorsProxyUrl + encodeURIComponent(resourceUrl) | ||
} | ||
// ref: https://developer.mozilla.org/en/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest#Bypassing_the_cache | ||
@@ -79,0 +84,0 @@ if (options.cacheBust) { |
@@ -94,2 +94,6 @@ export interface Options { | ||
fetchRequestInit?: RequestInit | ||
useCorsProxy?: boolean | ||
customCorsProxyUrl?: string | ||
} |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
294219
3925