//--------------------------------------------------------------------- // uQRCode二维码生成插件 v3.6.0 Basic // // uQRCode是一款基于Javascript环境开发的二维码生成插件,适用所有Javascript运行环境的前端应用和Node.js。 // // Copyright (c) Sansnn uQRCode All rights reserved. // // Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // // github地址: // https://github.com/Sansnn/uQRCode // // npm地址: // https://www.npmjs.com/package/uqrcodejs // // uni-app插件市场地址: // https://ext.dcloud.net.cn/plugin?id=1287 // // 复制使用请保留本段注释,感谢支持开源! // //--------------------------------------------------------------------- //--------------------------------------------------------------------- // QRCode for JavaScript // // Copyright (c) 2009 Kazuhiko Arase // // URL: http://www.d-project.com/ // // Licensed under the MIT license: // http://www.opensource.org/licenses/mit-license.php // // The word "QR Code" is registered trademark of // DENSO WAVE INCORPORATED // http://www.denso-wave.com/qrcode/faqpatent-e.html // //--------------------------------------------------------------------- "use strict";let uQRCode;!function(){function o(o){this.mode=d.MODE_8BIT_BYTE,this.data=o}function e(o,e){this.typeNumber=o,this.errorCorrectLevel=e,this.modules=null,this.moduleCount=0,this.dataCache=null,this.dataList=new Array}function r(o,e){if(null==o.length)throw new Error(o.length+"/"+e);for(var r=0;r{i(o)}).catch(o=>{n(o)}).finally(()=>{if(e.length){const r=e.shift();o(r.task,r.resolve,r.reject)}else r=!1})}let e=this.waitingQueue=[],r=this.isRunning=!1;this.exec=function(t){return new Promise((i,n)=>{r?e.push({task:t,resolve:i,reject:n}):(r=!0,o(t,i,n))})}}function a(o){this.errMsg=o}function u(o,e){var r=this.data="",t=this.size=200,i=this.typeNumber=-1,n=(this.errorCorrectLevel=s.H,this.useDynamicSize=!1,this.dynamicSize=void 0,this.margin=0),a=(this.backgroundColor="#FFFFFF",this.backgroundImageSrc=void 0,this.backgroundImageWidth=void 0),d=this.backgroundImageHeight=void 0,g=this.backgroundImageX=void 0,l=this.backgroundImageY=void 0,h=(this.backgroundImageAlpha=1,this.backgroundImageBorderRadius=0,this.foregroundColor="#000000",this.foregroundImageSrc=void 0,this.foregroundImageWidth=void 0),c=this.foregroundImageHeight=void 0,m=this.foregroundImageX=void 0,f=this.foregroundImageY=void 0,v=this.foregroundImagePadding=0,C=(this.foregroundImageBackgroundColor="#FFFFFF",this.foregroundImageBorderRadius=0),p=this.foregroundImageShadowOffsetX=0,b=this.foregroundImageShadowOffsetY=0,y=this.foregroundImageShadowBlur=0,k=(this.foregroundImageShadowColor="#808080",this.foregroundPadding=0,this.foregroundRadius=1),I=this.positionProbeBackgroundColor=void 0,w=this.positionProbeForegroundColor=void 0,B=this.separatorColor=void 0,T=this.positionAdjustBackgroundColor=void 0,P=this.positionAdjustForegroundColor=void 0,S=this.timingBackgroundColor=void 0,A=this.timingForegroundColor=void 0,E=this.typeNumberBackgroundColor=void 0,D=this.typeNumberForegroundColor=void 0,N=this.darkBlockColor=void 0,L=(this.style="default",this.patterns=[],this.canvasContext=void 0);this.queue=!1,this.modules=[],this.moduleCount=0,this.drawModules=[];Object.defineProperties(this,{data:{get:()=>(""!==r&&void 0!==r||console.error("[uQRCode]: data must be set!"),r),set(o){r=o}},size:{get:()=>t,set(o){t=Number(o)}},typeNumber:{get:()=>i,set(o){i=Number(o)}},margin:{get:()=>n,set(o){n=Number(o)}},backgroundImageWidth:{get(){return void 0===a?this.dynamicSize:this.useDynamicSize?this.dynamicSize/this.size*a:a},set(o){a=Number(o)}},backgroundImageHeight:{get(){return void 0===d?this.dynamicSize:this.useDynamicSize?this.dynamicSize/this.size*d:d},set(o){d=Number(o)}},backgroundImageX:{get(){return void 0===g?0:this.useDynamicSize?this.dynamicSize/this.size*g:g},set(o){g=Number(o)}},backgroundImageY:{get(){return void 0===l?0:this.useDynamicSize?this.dynamicSize/this.size*l:l},set(o){l=Number(o)}},foregroundImageWidth:{get(){return void 0===h?(this.dynamicSize-2*this.margin)/4:this.useDynamicSize?this.dynamicSize/this.size*h:h},set(o){h=Number(o)}},foregroundImageHeight:{get(){return void 0===c?(this.dynamicSize-2*this.margin)/4:this.useDynamicSize?this.dynamicSize/this.size*c:c},set(o){c=Number(o)}},foregroundImageX:{get(){return void 0===m?this.dynamicSize/2-this.foregroundImageWidth/2:this.useDynamicSize?this.dynamicSize/this.size*m:m},set(o){m=Number(o)}},foregroundImageY:{get(){return void 0===f?this.dynamicSize/2-this.foregroundImageHeight/2:this.useDynamicSize?this.dynamicSize/this.size*f:f},set(o){f=Number(o)}},foregroundImagePadding:{get(){return this.useDynamicSize?this.dynamicSize/this.size*v:v},set(o){v=Number(o)}},foregroundImageBorderRadius:{get(){return this.useDynamicSize?this.dynamicSize/this.size*C:C},set(o){C=Number(o)}},foregroundImageShadowOffsetX:{get(){return this.useDynamicSize?this.dynamicSize/this.size*p:p},set(o){p=Number(o)}},foregroundImageShadowOffsetY:{get(){return this.useDynamicSize?this.dynamicSize/this.size*b:b},set(o){b=Number(o)}},foregroundImageShadowBlur:{get(){return this.useDynamicSize?this.dynamicSize/this.size*y:y},set(o){y=Number(o)}},foregroundRadius:{get:()=>k,set(o){k=o>1?1:o<0?0:o}},positionProbeBackgroundColor:{get(){return I||this.backgroundColor},set(o){I=o}},positionProbeForegroundColor:{get(){return w||this.foregroundColor},set(o){w=o}},separatorColor:{get(){return B||this.backgroundColor},set(o){B=o}},positionAdjustBackgroundColor:{get(){return T||this.backgroundColor},set(o){T=o}},positionAdjustForegroundColor:{get(){return P||this.foregroundColor},set(o){P=o}},timingBackgroundColor:{get(){return S||this.backgroundColor},set(o){S=o}},timingForegroundColor:{get(){return A||this.foregroundColor},set(o){A=o}},typeNumberBackgroundColor:{get(){return E||this.backgroundColor},set(o){E=o}},typeNumberForegroundColor:{get(){return D||this.foregroundColor},set(o){D=o}},darkBlockColor:{get(){return N||this.foregroundColor},set(o){N=o}},canvasContext:{get:()=>(void 0===L&&console.error("[uQRCode]: use drawCanvas, you need to set the canvasContext!"),L),set(o){L=u.getCanvasContext(o)}}}),o&&this.setOptions(o),e&&(this.canvasContext=u.getCanvasContext(e))}o.prototype={getLength:function(o){return this.data.length},write:function(o){for(var e=0;e=7&&this.setupTypeNumber(o),null==this.dataCache&&(this.dataCache=e.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,r)},setupPositionProbePattern:function(o,e){for(var r=-1;r<=7;r++)if(!(o+r<=-1||this.moduleCount<=o+r))for(var t=-1;t<=7;t++)e+t<=-1||this.moduleCount<=e+t||(this.modules[o+r][e+t]=0<=r&&r<=6&&(0==t||6==t)||0<=t&&t<=6&&(0==r||6==r)||2<=r&&r<=4&&2<=t&&t<=4)},getBestMaskPattern:function(){for(var o=0,e=0,r=0;r<8;r++){this.makeImpl(!0,r);var t=l.getLostPoint(this);(0==r||o>t)&&(o=t,e=r)}return e},createMovieClip:function(o,e,r){var t=o.createEmptyMovieClip(e,r),i=1;this.make();for(var n=0;n>r&1);this.modules[Math.floor(r/3)][r%3+this.moduleCount-8-3]=t}for(r=0;r<18;r++){t=!o&&1==(e>>r&1);this.modules[r%3+this.moduleCount-8-3][Math.floor(r/3)]=t}},setupTypeInfo:function(o,e){for(var r=this.errorCorrectLevel<<3|e,t=l.getBCHTypeInfo(r),i=0;i<15;i++){var n=!o&&1==(t>>i&1);i<6?this.modules[i][8]=n:i<8?this.modules[i+1][8]=n:this.modules[this.moduleCount-15+i][8]=n}for(i=0;i<15;i++){n=!o&&1==(t>>i&1);i<8?this.modules[8][this.moduleCount-i-1]=n:i<9?this.modules[8][15-i-1+1]=n:this.modules[8][15-i-1]=n}this.modules[this.moduleCount-8][8]=!o},mapData:function(o,e){for(var r=-1,t=this.moduleCount-1,i=7,n=0,a=this.moduleCount-1;a>0;a-=2)for(6==a&&a--;;){for(var u=0;u<2;u++)if(null==this.modules[t][a-u]){var d=!1;n>>i&1));var s=l.getMask(e,t,a-u);s&&(d=!d),this.modules[t][a-u]=d,i--,-1==i&&(n++,i=7)}if(t+=r,t<0||this.moduleCount<=t){t-=r,r=-r;break}}}},e.PAD0=236,e.PAD1=17,e.createData=function(o,r,n){for(var a=t.getRSBlocks(o,r),u=new i,d=0;d8*g)throw new Error("code length overflow. ("+u.getLengthInBits()+">"+8*g+")");for(u.getLengthInBits()+4<=8*g&&u.put(0,4);u.getLengthInBits()%8!=0;)u.putBit(!1);for(;!(u.getLengthInBits()>=8*g||(u.put(e.PAD0,8),u.getLengthInBits()>=8*g));)u.put(e.PAD1,8);return e.createBytes(u,a)},e.createBytes=function(o,e){for(var t=0,i=0,n=0,a=new Array(e.length),u=new Array(e.length),d=0;d=0?f.get(v):0}}var C=0;for(h=0;h=0;)e^=l.G15<=0;)e^=l.G18<>>=1;return e},getPatternPosition:function(o){return l.PATTERN_POSITION_TABLE[o-1]},getMask:function(o,e,r){switch(o){case g.PATTERN000:return(e+r)%2==0;case g.PATTERN001:return e%2==0;case g.PATTERN010:return r%3==0;case g.PATTERN011:return(e+r)%3==0;case g.PATTERN100:return(Math.floor(e/2)+Math.floor(r/3))%2==0;case g.PATTERN101:return e*r%2+e*r%3==0;case g.PATTERN110:return(e*r%2+e*r%3)%2==0;case g.PATTERN111:return(e*r%3+(e+r)%2)%2==0;default:throw new Error("bad maskPattern:"+o)}},getErrorCorrectPolynomial:function(o){for(var e=new r([1],0),t=0;t5&&(r+=3+n-5)}for(t=0;t=256;)o-=255;return h.EXP_TABLE[o]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)},c=0;c<8;c++)h.EXP_TABLE[c]=1<>>7-o%8&1)},put:function(o,e){for(var r=0;r>>e-r-1&1))},getLengthInBits:function(){return this.length},putBit:function(o){var e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),o&&(this.buffer[e]|=128>>>this.length%8),this.length++}},u.errorCorrectLevel=s,u.queue=new n,u.queueLoadImage=new n,u.isQueueLoadImage=!1,u.loadImageCache=[],u.utf16To8=function(o){for(var e,r="",t=0;t=1&&e<=127?r+=o.charAt(t):e>2047?(r+=String.fromCharCode(224|e>>12&15),r+=String.fromCharCode(128|e>>6&63),r+=String.fromCharCode(128|e>>0&63)):(r+=String.fromCharCode(192|e>>6&31),r+=String.fromCharCode(128|e>>0&63));return r},u.deepReplace=function(o={},e={},r=!1){let t;t=r?o:{...o};for(let o in e){var i=e[o];null!=i&&(i.constructor==Object?t[o]=this.deepReplace(t[o],i):i.constructor!=String||i?t[o]=i:t[o]=t[o])}return t},u.getSomePropertyToNewObject=function(o={},e=[]){let r={};return e.forEach(e=>{r[e]=o[e]}),r},u.getCanvasContext=function(o){return o.setFillStyle=o.setFillStyle||function(e){o.fillStyle=e},o.setFontSize=o.setFontSize||function(e){o.font=`${e}px`},o.setTextAlign=o.setTextAlign||function(e){o.textAlign=e},o.setTextBaseline=o.setTextBaseline||function(e){o.textBaseline=e},o.draw=o.draw||function(o,e){e&&e()},o},u.getLoadImage=function(o){return"function"==typeof o?function(e,r=!1){return u.isQueueLoadImage?u.queueLoadImage.exec(()=>new Promise((t,i)=>{setTimeout(()=>{const r=u.loadImageCache.find(o=>o.src==e);r?t(r.img):o(e).then(o=>{u.loadImageCache.push({src:e,img:o}),t(o)}).catch(o=>{i(o)})},r?150:10)})):o(e)}:function(o){return Promise.resolve(o)}};var m=u.loadImage=function(o){return Promise.resolve(o)};Object.defineProperty(u,"loadImage",{get:()=>m,set(o){m=u.getLoadImage(o)}}),u.prototype={setOptions(o){var e,r,t,i,n,a,d,s,g,l,h,c,m,f,v,C,p,b,y,k,I,w,B,T,P,S,A,E,D,N,L,R,z,M,x,_,O,F,H,X,j,Y,Q,G,K,W,q,U,$,J,V,Z,oo,eo,ro,to,io,no,ao;o&&u.deepReplace(this,{data:o.data||o.text,size:o.size,typeNumber:o.typeNumber,errorCorrectLevel:o.errorCorrectLevel,useDynamicSize:o.useDynamicSize,margin:o.margin,backgroundColor:o.backgroundColor||(null===(e=o.background)||void 0===e?void 0:e.color),backgroundImageSrc:o.backgroundImageSrc||(null===(r=o.background)||void 0===r?void 0:null===(t=r.image)||void 0===t?void 0:t.src),backgroundImageWidth:o.backgroundImageWidth||(null===(i=o.background)||void 0===i?void 0:null===(n=i.image)||void 0===n?void 0:n.width),backgroundImageHeight:o.backgroundImageHeight||(null===(a=o.background)||void 0===a?void 0:null===(d=a.image)||void 0===d?void 0:d.height),backgroundImageX:o.backgroundImageX||(null===(s=o.background)||void 0===s?void 0:null===(g=s.image)||void 0===g?void 0:g.x),backgroundImageY:o.backgroundImageY||(null===(l=o.background)||void 0===l?void 0:null===(h=l.image)||void 0===h?void 0:h.y),backgroundImageAlpha:o.backgroundImageAlpha||(null===(c=o.background)||void 0===c?void 0:null===(m=c.image)||void 0===m?void 0:m.alpha),backgroundImageBorderRadius:o.backgroundImageBorderRadius||(null===(f=o.background)||void 0===f?void 0:null===(v=f.image)||void 0===v?void 0:v.borderRadius),foregroundColor:o.foregroundColor||(null===(C=o.foreground)||void 0===C?void 0:C.color),foregroundImageSrc:o.foregroundImageSrc||(null===(p=o.foreground)||void 0===p?void 0:null===(b=p.image)||void 0===b?void 0:b.src),foregroundImageWidth:o.foregroundImageWidth||(null===(y=o.foreground)||void 0===y?void 0:null===(k=y.image)||void 0===k?void 0:k.width),foregroundImageHeight:o.foregroundImageHeight||(null===(I=o.foreground)||void 0===I?void 0:null===(w=I.image)||void 0===w?void 0:w.height),foregroundImageX:o.foregroundImageX||(null===(B=o.foreground)||void 0===B?void 0:null===(T=B.image)||void 0===T?void 0:T.x),foregroundImageY:o.foregroundImageY||(null===(P=o.foreground)||void 0===P?void 0:null===(S=P.image)||void 0===S?void 0:S.y),foregroundImagePadding:o.foregroundImagePadding||(null===(A=o.foreground)||void 0===A?void 0:null===(E=A.image)||void 0===E?void 0:E.padding),foregroundImageBackgroundColor:o.foregroundImageBackgroundColor||(null===(D=o.foreground)||void 0===D?void 0:null===(N=D.image)||void 0===N?void 0:N.backgroundColor),foregroundImageBorderRadius:o.foregroundImageBorderRadius||(null===(L=o.foreground)||void 0===L?void 0:null===(R=L.image)||void 0===R?void 0:R.borderRadius),foregroundImageShadowOffsetX:o.foregroundImageShadowOffsetX||(null===(z=o.foreground)||void 0===z?void 0:null===(M=z.image)||void 0===M?void 0:M.shadowOffsetX),foregroundImageShadowOffsetY:o.foregroundImageShadowOffsetY||(null===(x=o.foreground)||void 0===x?void 0:null===(_=x.image)||void 0===_?void 0:_.shadowOffsetY),foregroundImageShadowBlur:o.foregroundImageShadowBlur||(null===(O=o.foreground)||void 0===O?void 0:null===(F=O.image)||void 0===F?void 0:F.shadowBlur),foregroundImageShadowColor:o.foregroundImageShadowColor||(null===(H=o.foreground)||void 0===H?void 0:null===(X=H.image)||void 0===X?void 0:X.shadowColor),foregroundPadding:o.foregroundPadding,foregroundRadius:o.foregroundRadius,positionProbeBackgroundColor:o.positionProbeBackgroundColor||(null===(j=o.positionProbe)||void 0===j?void 0:j.backgroundColor)||(null===(Y=o.positionDetection)||void 0===Y?void 0:Y.backgroundColor),positionProbeForegroundColor:o.positionProbeForegroundColor||(null===(Q=o.positionProbe)||void 0===Q?void 0:Q.foregroundColor)||(null===(G=o.positionDetection)||void 0===G?void 0:G.foregroundColor),separatorColor:o.separatorColor||(null===(K=o.separator)||void 0===K?void 0:K.color),positionAdjustBackgroundColor:o.positionAdjustBackgroundColor||(null===(W=o.positionAdjust)||void 0===W?void 0:W.backgroundColor)||(null===(q=o.alignment)||void 0===q?void 0:q.backgroundColor),positionAdjustForegroundColor:o.positionAdjustForegroundColor||(null===(U=o.positionAdjust)||void 0===U?void 0:U.foregroundColor)||(null===($=o.alignment)||void 0===$?void 0:$.foregroundColor),timingBackgroundColor:o.timingBackgroundColor||(null===(J=o.timing)||void 0===J?void 0:J.backgroundColor),timingForegroundColor:o.timingForegroundColor||(null===(V=o.timing)||void 0===V?void 0:V.foregroundColor),typeNumberBackgroundColor:o.typeNumberBackgroundColor||(null===(Z=o.typeNumber)||void 0===Z?void 0:Z.backgroundColor)||(null===(oo=o.versionInformation)||void 0===oo?void 0:oo.backgroundColor),typeNumberForegroundColor:o.typeNumberForegroundColor||(null===(eo=o.typeNumber)||void 0===eo?void 0:eo.foregroundColor)||(null===(ro=o.versionInformation)||void 0===ro?void 0:ro.foregroundColor),darkBlockColor:o.darkBlockColor||(null===(to=o.darkBlock)||void 0===to?void 0:to.color),style:o.style,patterns:o.patterns||(null===(io=o.art)||void 0===io?void 0:io.patterns)||(null===(no=o.art)||void 0===no?void 0:null===(ao=no.shape)||void 0===ao?void 0:ao.map(o=>(o.imageSrc=o.image,o))),queue:o.queue},!0)},make(){this.foregroundColor===this.backgroundColor&&console.error("[uQRCode]: foregroundColor and backgroundColor cannot be the same!");var o=new e(this.typeNumber,this.errorCorrectLevel);o.addData(u.utf16To8(this.data.toString())),o.make(),this.typeNumber=o.typeNumber,this.modules=o.modules,this.moduleCount=o.moduleCount;var r=this.size-2*this.margin;this.dynamicSize=Math.ceil(r/o.moduleCount)*o.moduleCount+2*this.margin,this.useDynamicSize||(this.dynamicSize=this.size),this.paintData(),this.paintPositionProbe(),this.paintSeparator(),this.paintTiming(),this.paintPositionAdjust(),this.paintDarkBlock(),this.paintTypeNumber(),this.getDrawModules()},paintData(){let{dynamicSize:o,margin:e,backgroundColor:r,foregroundColor:t,foregroundPadding:i,style:n,modules:a,moduleCount:u}=this,d=(o-2*e)/u,s=d,g=0;i>0&&"liquid"!=n&&"art"!=n&&(g=s*i/2,s-=2*g);for(var l=0;l{var i=o[e[0]][e[1]],a=o[e[0]+n][e[1]],u=o[e[0]][e[1]+n];u.type.push("positionProbe"),a.type.push("positionProbe"),i.type.push("positionProbe"),i.color=1==e[2]?t:r,a.color=1==e[2]?t:r,u.color=1==e[2]?t:r})},paintSeparator(){let{modules:o,moduleCount:e,separatorColor:r}=this;[[7,0],[7,1],[7,2],[7,3],[7,4],[7,5],[7,6],[7,7],[0,7],[1,7],[2,7],[3,7],[4,7],[5,7],[6,7]].forEach(t=>{var i=o[t[0]][t[1]],n=o[e-t[0]-1][t[1]],a=o[t[0]][e-t[1]-1];a.type.push("separator"),n.type.push("separator"),i.type.push("separator"),i.color=r,n.color=r,a.color=r})},paintPositionAdjust(){let{typeNumber:o,modules:e,moduleCount:r,foregroundColor:t,backgroundColor:i,positionAdjustForegroundColor:n,positionAdjustBackgroundColor:a,timingForegroundColor:u,timingBackgroundColor:d}=this;const s=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],g=s[o-1];if(g){const o=[[-2,-2,1],[-1,-2,1],[0,-2,1],[1,-2,1],[2,-2,1],[-2,-1,1],[-1,-1,0],[0,-1,0],[1,-1,0],[2,-1,1],[-2,0,1],[-1,0,0],[0,0,1],[1,0,0],[2,0,1],[-2,1,1],[-1,1,0],[0,1,0],[1,1,0],[2,1,1],[-2,2,1],[-1,2,1],[0,2,1],[1,2,1],[2,2,1]],s=g.length;for(let l=0;lr-9-1&&c<9||c>r-9-1&&s<9||o.forEach(o=>{var r=e[s+o[0]][c+o[1]];r.type.push("positionAdjust"),r.type.includes("timing")?1==o[2]?r.color=n==t?u:n:r.color=n==t&&a==i?d:a:r.color=1==o[2]?n:a})}}},paintTiming(){let{modules:o,moduleCount:e,timingForegroundColor:r,timingBackgroundColor:t}=this,i=e-16;for(let e=0;e{var n=e[o[0]][o[1]];n.type.push("typeNumber"),n.color="1"==a[r]?i:t})},getDrawModules(){let o=this.drawModules=[],{modules:e,moduleCount:r,dynamicSize:t,backgroundColor:i,backgroundImageSrc:n,backgroundImageX:a,backgroundImageY:u,backgroundImageWidth:d,backgroundImageHeight:s,backgroundImageAlpha:g,backgroundImageBorderRadius:l,style:h,patterns:c,foregroundImageSrc:m,foregroundImageX:f,foregroundImageY:v,foregroundImageWidth:C,foregroundImageHeight:p,foregroundImagePadding:b,foregroundImageBackgroundColor:y,foregroundImageBorderRadius:k,foregroundImageShadowOffsetX:I,foregroundImageShadowOffsetY:w,foregroundImageShadowBlur:B,foregroundImageShadowColor:T}=this;i&&o.push({name:"background",type:"box",color:i,x:0,y:0,width:t,height:t}),n&&o.push({name:"backgroundImage",type:"image",imageSrc:n,imageSource:"backgroundImageSrc",x:a,y:u,width:d,height:s,alpha:g,borderRadius:l});for(var P=0;Po||0>e||o>=r||e>=r)&&this.modules[o][e].isBlack},drawCanvas(){let{canvasContext:o,foregroundColor:e,backgroundColor:r,queue:t,style:i}=this;if(e===r)return Promise.reject(new a("[uQRCode]: foregroundColor and backgroundColor cannot be the same!"));let n=async(e,r)=>{try{o.draw(!1),await this.styleDefault(),o.draw(!0),setTimeout(e,150)}catch(o){if(!(o instanceof a))throw o;r(o)}};return new Promise((o,e)=>{t?u.queue.exec(()=>new Promise((o,e)=>{n(o,e)})).then(()=>{setTimeout(o,150)}).catch(o=>{e(o)}):n(o,e)})},draw(){return this.drawCanvas()},async styleDefault(){let{drawModules:o,canvasContext:e,backgroundColor:r,margin:t,queue:i}=this;for(var n=0;n0?d.backgroundColor:"rgba(0,0,0,0)"),e.fill(),e.beginPath(),e.moveTo(s+c,g),e.arcTo(s+l,g,s+l,g+h,c),e.arcTo(s+l,g+h,s,g+h,c),e.arcTo(s,g+h,s,g,c),e.arcTo(s,g,s+l,g,c),e.closePath(),e.strokeStyle="rgba(0,0,0,0)",e.stroke(),e.clip();try{m=await u.loadImage(d.imageSrc);e.drawImage(m,d.x,d.y,d.width,d.height)}catch(o){throw console.error(`[uQRCode]: ${d.imageSource} invalid!`),new a(`[uQRCode]: ${d.imageSource} invalid!`)}}}i&&e.draw(!0),e.restore()}}},uQRCode=u,uQRCode.export=function(){var o,e;o="undefined"!=typeof window?window:global,e=uQRCode,"undefined"!=typeof module&&"object"==typeof exports?module.exports=e:"function"==typeof define&&(define.amd||define.cmd)?define(function(){return e}):o.UQRCode=e}}(); //--------------------------------------------------------------------- // 默认导出方式,非vite(vue3)使用该方式。 // ↓ //--------------------------------------------------------------------- uQRCode.export(); //--------------------------------------------------------------------- // ES6导出方式,vite(vue3)使用该方式。 // ↓ //--------------------------------------------------------------------- // export default uQRCode;