Socket
Socket
Sign inDemoInstall

easyqrcodejs-nodejs

Package Overview
Dependencies
113
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.7.2 to 4.0.0

canvas2svg.js

12

demo/demo_node.js

@@ -156,3 +156,3 @@ const QRCode = require('../index.min');

// logo: "https://avatars1.githubusercontent.com/u/4082017?s=160&v=4", // LOGO
logo: "avatars.png", // LOGO
logo: "./avatars.png", // LOGO
// logo:"http://127.0.0.1:8020/easy-qrcodejs/demo/logo.png",

@@ -226,6 +226,10 @@ // logoWidth:80,

qrcode5.toDataURL().then(data=>{
console.info('======QRCode JPG DataURL======')
qrcode5.toSVGText().then(data=>{
console.info('======QRCode SVG Data Text======')
console.info(data)
console.info('')
});
});
qrcode8.saveSVG({
path: 'qrcode.svg'
})
/**
* EasyQRCodeJS-NodeJS
*
* NodeJS QRCode generator. Can get standard base64 image data url text or save image to file. Cross-browser QRCode generator for pure javascript. Support Dot style, Logo, Background image, Colorful, Title etc. settings. Support binary(hex) data mode. (Running without DOM on server side)
* NodeJS QRCode generator. Can save image or svg to file, get standard base64 image data url text or get SVG serialized text. Cross-browser QRCode generator for pure javascript. Support Dot style, Logo, Background image, Colorful, Title etc. settings. support binary mode.(Running without DOM on server side)
*
* Version 3.7.2
* Version 4.0.0
*

@@ -26,4 +26,11 @@ * @author [ inthinkcolor@gmail.com ]

var jsdom = require('jsdom');
var C2S = require('./canvas2svg');
var fs = require('fs');
const {
JSDOM
} = jsdom;
const win = new JSDOM().window;
function QR8bitByte(data, binary) {

@@ -1067,14 +1074,9 @@ this.mode = QRMode.MODE_8BIT_BYTE;

this._htOption = htOption;
this._canvas = createCanvas(200, 200)
if (this._htOption._drawer == 'svg') {
this._oContext = {};
} else {
this._oContext = this._canvas.getContext("2d");
}
this._oContext = this._canvas.getContext("2d");
this._oContext.patternQuality = 'best'; //'fast'|'good'|'best'|'nearest'|'bilinear'
this._oContext.quality = 'best'; //'fast'|'good'|'best'|'nearest'|'bilinear'
this._oContext.textDrawingMode = 'path'; // 'path'|'glyph'
this._oContext.antialias = 'gray'; // 'default'|'none'|'gray'|'subpixel'
this._bSupportDataURI = null;

@@ -1089,8 +1091,4 @@ };

Drawing.prototype.draw = function(oQRCode) {
var _oContext = this._oContext;
var _htOption = this._htOption;
if (!_htOption.title && !_htOption.subTitle) {

@@ -1114,2 +1112,18 @@ _htOption.height -= _htOption.titleHeight;

if (this._htOption._drawer == 'svg') {
this._oContext = new C2S({
document: win.document,
XMLSerializer: win.XMLSerializer,
width: this._canvas.width,
height: this._canvas.height
});
}
this._oContext.patternQuality = 'best'; //'fast'|'good'|'best'|'nearest'|'bilinear'
this._oContext.quality = 'best'; //'fast'|'good'|'best'|'nearest'|'bilinear'
this._oContext.textDrawingMode = 'path'; // 'path'|'glyph'
this._oContext.antialias = 'gray'; // 'default'|'none'|'gray'|'subpixel'
var _oContext = this._oContext;
var autoColorDark = "rgba(0, 0, 0, .6)";

@@ -1281,4 +1295,2 @@ var autoColorLight = "rgba(255, 255, 255, .7)";

function generateLogoImg(img) {

@@ -1382,26 +1394,34 @@ var imgContainerW = Math.round(_htOption.width / 3.5);

}
if (this._htOption._drawer == 'svg') {
let data = this._oContext.getSerializedSvg();
fs.writeFile(makeOptions.path, data, 'utf8', function(err) {
if (err) {
t.reject(err);
}
t.resolve({});
});
} else {
var out = fs.createWriteStream(makeOptions.path)
var out = fs.createWriteStream(makeOptions.path)
var stream = undefined;
var stream = undefined;
if (this._htOption.format == 'PNG') {
stream = this._canvas.createPNGStream({
compressionLevel: this._htOption.compressionLevel
})
} else {
stream = this._canvas.createJPEGStream({
quality: this._htOption.quality
})
}
if (this._htOption.format == 'PNG') {
stream = this._canvas.createPNGStream({
compressionLevel: this._htOption.compressionLevel
stream.pipe(out);
out.on('finish', () => {
t.resolve({});
})
} else {
stream = this._canvas.createJPEGStream({
quality: this._htOption.quality
})
}
stream.pipe(out);
out.on('finish', () => {
t.resolve({});
})
} else if (makeOptions.makeType == 'URL') {
} else if (makeOptions.makeType == 'URL') {

@@ -1411,19 +1431,18 @@ if (this._htOption.onRenderingStart) {

}
if (this._htOption.format == 'PNG') {
// dataUrl = this._canvas.toDataURL()
this._canvas.toDataURL((err, data) => {
t.resolve(data);
}) // defaults to PNG
if (this._htOption._drawer == 'svg') {
let data = this._oContext.getSerializedSvg();
t.resolve(data);
} else {
this._canvas.toDataURL('image/jpeg', (err, data) => {
t.resolve(data);
})
if (this._htOption.format == 'PNG') {
// dataUrl = this._canvas.toDataURL()
this._canvas.toDataURL((err, data) => {
t.resolve(data);
}) // defaults to PNG
} else {
this._canvas.toDataURL('image/jpeg', (err, data) => {
t.resolve(data);
})
}
}
}
};

@@ -1521,4 +1540,2 @@

binary: false // Whether it is binary mode, default is text mode.
};

@@ -1570,2 +1587,6 @@ if (typeof vOption === 'string') {

if (!this._htOption.drawer || (this._htOption.drawer != 'svg' && this._htOption.drawer != 'canvas')) {
this._htOption.drawer = 'canvas';
}
this._htOption.height = this._htOption.height + this._htOption.titleHeight;

@@ -1579,15 +1600,4 @@

/**
* Support save PNG image file
* @param {Object} path Make the QRCode
*/
QRCode.prototype.saveImage = function(saveOptions) {
var defOptions = {
makeType: 'FILE',
path: null
}
saveOptions = Object.assign(defOptions, saveOptions);
// Save to image file or svg file
QRCode.prototype._toSave = function(saveOptions) {
var _oDrawing = new Drawing(this._htOption);

@@ -1598,4 +1608,5 @@ _oDrawing.makeOptions = saveOptions;

var t = this;
return new Promise(resolve => {
return new Promise((resolve, reject) => {
_oDrawing.resolve = resolve;
_oDrawing.reject = reject;
_oDrawing.draw(t._oQRCode);

@@ -1607,13 +1618,37 @@ })

}
}
/**
* Support save PNG image file
* @param {Object} path Make the QRCode
*/
QRCode.prototype.saveImage = function(saveOptions) {
var defOptions = {
makeType: 'FILE',
path: null
}
this._htOption._drawer = 'canvas';
saveOptions = Object.assign(defOptions, saveOptions);
return this._toSave(saveOptions);
};
/**
* get standard base64 image data url text: data:image/png;base64, ...
* Save to SVG file
*/
QRCode.prototype.toDataURL = function(format) {
QRCode.prototype.saveSVG = function(saveOptions) {
var defOptions = {
makeType: 'FILE',
path: null
}
this._htOption._drawer = 'svg';
saveOptions = Object.assign(defOptions, saveOptions);
return this._toSave(saveOptions);
};
// Get Base64 or SVG text
QRCode.prototype._toData = function(drawer) {
var defOptions = {
makeType: 'URL'
}
this._htOption._drawer = drawer;

@@ -1625,4 +1660,5 @@ var _oDrawing = new Drawing(this._htOption);

var t = this;
return new Promise(resolve => {
return new Promise((resolve, reject) => {
_oDrawing.resolve = resolve;
_oDrawing.reject = reject;
_oDrawing.draw(t._oQRCode);

@@ -1634,5 +1670,18 @@ })

}
}
/**
*Get standard base64 image data url text: 'data:image/png;base64, ...' or SVG data text
*/
QRCode.prototype.toDataURL = function() {
return this._toData('canvas');
};
/**
* Get SVG data text: '<svg xmlns:xlink="http://www.w3.org/1999/xlink" ...'
*/
QRCode.prototype.toSVGText = function() {
return this._toData('svg');
};
/**

@@ -1639,0 +1688,0 @@ * @name QRCode.CorrectLevel

/**
* EasyQRCodeJS-NodeJS
*
* NodeJS QRCode generator. Can get standard base64 image data url text or save image to file. Cross-browser QRCode generator for pure javascript. Support Dot style, Logo, Background image, Colorful, Title etc. settings. Support binary(hex) data mode. (Running without DOM on server side)
* NodeJS QRCode generator. Can save image or svg to file, get standard base64 image data url text or get SVG serialized text. Cross-browser QRCode generator for pure javascript. Support Dot style, Logo, Background image, Colorful, Title etc. settings. support binary mode.(Running without DOM on server side)
*
* Version 3.7.2
* Version 4.0.0
*

@@ -20,2 +20,2 @@ * @author [ inthinkcolor@gmail.com ]

*/
var{createCanvas:createCanvas,loadImage:loadImage,Image:Image}=require("canvas"),fs=require("fs");function QR8bitByte(t,e){this.mode=QRMode.MODE_8BIT_BYTE,this.data=t,this.parsedData=[];for(var o=0,i=this.data.length;o<i;o++){var r=[],n=this.data.charCodeAt(o);e?r[0]=n:n>65536?(r[0]=240|(1835008&n)>>>18,r[1]=128|(258048&n)>>>12,r[2]=128|(4032&n)>>>6,r[3]=128|63&n):n>2048?(r[0]=224|(61440&n)>>>12,r[1]=128|(4032&n)>>>6,r[2]=128|63&n):n>128?(r[0]=192|(1984&n)>>>6,r[1]=128|63&n):r[0]=n,this.parsedData.push(r)}this.parsedData=Array.prototype.concat.apply([],this.parsedData),this.parsedData.length!=this.data.length&&(this.parsedData.unshift(191),this.parsedData.unshift(187),this.parsedData.unshift(239))}function QRCodeModel(t,e){this.typeNumber=t,this.errorCorrectLevel=e,this.modules=null,this.moduleCount=0,this.dataCache=null,this.dataList=[]}QR8bitByte.prototype={getLength:function(t){return this.parsedData.length},write:function(t){for(var e=0,o=this.parsedData.length;e<o;e++)t.put(this.parsedData[e],8)}},QRCodeModel.prototype={addData:function(t,e){var o=new QR8bitByte(t,e);this.dataList.push(o),this.dataCache=null},isDark:function(t,e){if(t<0||this.moduleCount<=t||e<0||this.moduleCount<=e)throw new Error(t+","+e);return this.modules[t][e][0]},getEye:function(t,e){if(t<0||this.moduleCount<=t||e<0||this.moduleCount<=e)throw new Error(t+","+e);var o=this.modules[t][e];if(o[1]){var i="P"+o[1]+"_"+o[2];return"A"==o[2]&&(i="A"+o[1]),{isDarkBlock:o[0],type:i}}return null},getModuleCount:function(){return this.moduleCount},make:function(){this.makeImpl(!1,this.getBestMaskPattern())},makeImpl:function(t,e){this.moduleCount=4*this.typeNumber+17,this.modules=new Array(this.moduleCount);for(var o=0;o<this.moduleCount;o++){this.modules[o]=new Array(this.moduleCount);for(var i=0;i<this.moduleCount;i++)this.modules[o][i]=[]}this.setupPositionProbePattern(0,0,"TL"),this.setupPositionProbePattern(this.moduleCount-7,0,"BL"),this.setupPositionProbePattern(0,this.moduleCount-7,"TR"),this.setupPositionAdjustPattern("A"),this.setupTimingPattern(),this.setupTypeInfo(t,e),this.typeNumber>=7&&this.setupTypeNumber(t),null==this.dataCache&&(this.dataCache=QRCodeModel.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,e)},setupPositionProbePattern:function(t,e,o){for(var i=-1;i<=7;i++)if(!(t+i<=-1||this.moduleCount<=t+i))for(var r=-1;r<=7;r++)e+r<=-1||this.moduleCount<=e+r||(0<=i&&i<=6&&(0==r||6==r)||0<=r&&r<=6&&(0==i||6==i)||2<=i&&i<=4&&2<=r&&r<=4?(this.modules[t+i][e+r][0]=!0,this.modules[t+i][e+r][2]=o,this.modules[t+i][e+r][1]=-0==i||-0==r||6==i||6==r?"O":"I"):this.modules[t+i][e+r][0]=!1)},getBestMaskPattern:function(){for(var t=0,e=0,o=0;o<8;o++){this.makeImpl(!0,o);var i=QRUtil.getLostPoint(this);(0==o||t>i)&&(t=i,e=o)}return e},createMovieClip:function(t,e,o){var i=t.createEmptyMovieClip(e,o);this.make();for(var r=0;r<this.modules.length;r++)for(var n=1*r,a=0;a<this.modules[r].length;a++){var s=1*a;this.modules[r][a][0]&&(i.beginFill(0,100),i.moveTo(s,n),i.lineTo(s+1,n),i.lineTo(s+1,n+1),i.lineTo(s,n+1),i.endFill())}return i},setupTimingPattern:function(){for(var t=8;t<this.moduleCount-8;t++)null==this.modules[t][6][0]&&(this.modules[t][6][0]=t%2==0);for(var e=8;e<this.moduleCount-8;e++)null==this.modules[6][e][0]&&(this.modules[6][e][0]=e%2==0)},setupPositionAdjustPattern:function(t){for(var e=QRUtil.getPatternPosition(this.typeNumber),o=0;o<e.length;o++)for(var i=0;i<e.length;i++){var r=e[o],n=e[i];if(null==this.modules[r][n][0])for(var a=-2;a<=2;a++)for(var s=-2;s<=2;s++)-2==a||2==a||-2==s||2==s||0==a&&0==s?(this.modules[r+a][n+s][0]=!0,this.modules[r+a][n+s][2]=t,this.modules[r+a][n+s][1]=-2==a||-2==s||2==a||2==s?"O":"I"):this.modules[r+a][n+s][0]=!1}},setupTypeNumber:function(t){for(var e=QRUtil.getBCHTypeNumber(this.typeNumber),o=0;o<18;o++){var i=!t&&1==(e>>o&1);this.modules[Math.floor(o/3)][o%3+this.moduleCount-8-3][0]=i}for(o=0;o<18;o++){i=!t&&1==(e>>o&1);this.modules[o%3+this.moduleCount-8-3][Math.floor(o/3)][0]=i}},setupTypeInfo:function(t,e){for(var o=this.errorCorrectLevel<<3|e,i=QRUtil.getBCHTypeInfo(o),r=0;r<15;r++){var n=!t&&1==(i>>r&1);r<6?this.modules[r][8][0]=n:r<8?this.modules[r+1][8][0]=n:this.modules[this.moduleCount-15+r][8][0]=n}for(r=0;r<15;r++){n=!t&&1==(i>>r&1);r<8?this.modules[8][this.moduleCount-r-1][0]=n:r<9?this.modules[8][15-r-1+1][0]=n:this.modules[8][15-r-1][0]=n}this.modules[this.moduleCount-8][8][0]=!t},mapData:function(t,e){for(var o=-1,i=this.moduleCount-1,r=7,n=0,a=this.moduleCount-1;a>0;a-=2)for(6==a&&a--;;){for(var s=0;s<2;s++)if(null==this.modules[i][a-s][0]){var h=!1;n<t.length&&(h=1==(t[n]>>>r&1)),QRUtil.getMask(e,i,a-s)&&(h=!h),this.modules[i][a-s][0]=h,-1==--r&&(n++,r=7)}if((i+=o)<0||this.moduleCount<=i){i-=o,o=-o;break}}}},QRCodeModel.PAD0=236,QRCodeModel.PAD1=17,QRCodeModel.createData=function(t,e,o){for(var i=QRRSBlock.getRSBlocks(t,e),r=new QRBitBuffer,n=0;n<o.length;n++){var a=o[n];r.put(a.mode,4),r.put(a.getLength(),QRUtil.getLengthInBits(a.mode,t)),a.write(r)}var s=0;for(n=0;n<i.length;n++)s+=i[n].dataCount;if(r.getLengthInBits()>8*s)throw new Error("code length overflow. ("+r.getLengthInBits()+">"+8*s+")");for(r.getLengthInBits()+4<=8*s&&r.put(0,4);r.getLengthInBits()%8!=0;)r.putBit(!1);for(;!(r.getLengthInBits()>=8*s||(r.put(QRCodeModel.PAD0,8),r.getLengthInBits()>=8*s));)r.put(QRCodeModel.PAD1,8);return QRCodeModel.createBytes(r,i)},QRCodeModel.createBytes=function(t,e){for(var o=0,i=0,r=0,n=new Array(e.length),a=new Array(e.length),s=0;s<e.length;s++){var h=e[s].dataCount,l=e[s].totalCount-h;i=Math.max(i,h),r=Math.max(r,l),n[s]=new Array(h);for(var u=0;u<n[s].length;u++)n[s][u]=255&t.buffer[u+o];o+=h;var g=QRUtil.getErrorCorrectPolynomial(l),d=new QRPolynomial(n[s],g.getLength()-1).mod(g);a[s]=new Array(g.getLength()-1);for(u=0;u<a[s].length;u++){var f=u+d.getLength()-a[s].length;a[s][u]=f>=0?d.get(f):0}}var c=0;for(u=0;u<e.length;u++)c+=e[u].totalCount;var p=new Array(c),R=0;for(u=0;u<i;u++)for(s=0;s<e.length;s++)u<n[s].length&&(p[R++]=n[s][u]);for(u=0;u<r;u++)for(s=0;s<e.length;s++)u<a[s].length&&(p[R++]=a[s][u]);return p};for(var QRMode={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},QRErrorCorrectLevel={L:1,M:0,Q:3,H:2},QRMaskPattern={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},QRUtil={PATTERN_POSITION_TABLE:[[],[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]],G15:1335,G18:7973,G15_MASK:21522,getBCHTypeInfo:function(t){for(var e=t<<10;QRUtil.getBCHDigit(e)-QRUtil.getBCHDigit(QRUtil.G15)>=0;)e^=QRUtil.G15<<QRUtil.getBCHDigit(e)-QRUtil.getBCHDigit(QRUtil.G15);return(t<<10|e)^QRUtil.G15_MASK},getBCHTypeNumber:function(t){for(var e=t<<12;QRUtil.getBCHDigit(e)-QRUtil.getBCHDigit(QRUtil.G18)>=0;)e^=QRUtil.G18<<QRUtil.getBCHDigit(e)-QRUtil.getBCHDigit(QRUtil.G18);return t<<12|e},getBCHDigit:function(t){for(var e=0;0!=t;)e++,t>>>=1;return e},getPatternPosition:function(t){return QRUtil.PATTERN_POSITION_TABLE[t-1]},getMask:function(t,e,o){switch(t){case QRMaskPattern.PATTERN000:return(e+o)%2==0;case QRMaskPattern.PATTERN001:return e%2==0;case QRMaskPattern.PATTERN010:return o%3==0;case QRMaskPattern.PATTERN011:return(e+o)%3==0;case QRMaskPattern.PATTERN100:return(Math.floor(e/2)+Math.floor(o/3))%2==0;case QRMaskPattern.PATTERN101:return e*o%2+e*o%3==0;case QRMaskPattern.PATTERN110:return(e*o%2+e*o%3)%2==0;case QRMaskPattern.PATTERN111:return(e*o%3+(e+o)%2)%2==0;default:throw new Error("bad maskPattern:"+t)}},getErrorCorrectPolynomial:function(t){for(var e=new QRPolynomial([1],0),o=0;o<t;o++)e=e.multiply(new QRPolynomial([1,QRMath.gexp(o)],0));return e},getLengthInBits:function(t,e){if(1<=e&&e<10)switch(t){case QRMode.MODE_NUMBER:return 10;case QRMode.MODE_ALPHA_NUM:return 9;case QRMode.MODE_8BIT_BYTE:case QRMode.MODE_KANJI:return 8;default:throw new Error("mode:"+t)}else if(e<27)switch(t){case QRMode.MODE_NUMBER:return 12;case QRMode.MODE_ALPHA_NUM:return 11;case QRMode.MODE_8BIT_BYTE:return 16;case QRMode.MODE_KANJI:return 10;default:throw new Error("mode:"+t)}else{if(!(e<41))throw new Error("type:"+e);switch(t){case QRMode.MODE_NUMBER:return 14;case QRMode.MODE_ALPHA_NUM:return 13;case QRMode.MODE_8BIT_BYTE:return 16;case QRMode.MODE_KANJI:return 12;default:throw new Error("mode:"+t)}}},getLostPoint:function(t){for(var e=t.getModuleCount(),o=0,i=0;i<e;i++)for(var r=0;r<e;r++){for(var n=0,a=t.isDark(i,r),s=-1;s<=1;s++)if(!(i+s<0||e<=i+s))for(var h=-1;h<=1;h++)r+h<0||e<=r+h||0==s&&0==h||a==t.isDark(i+s,r+h)&&n++;n>5&&(o+=3+n-5)}for(i=0;i<e-1;i++)for(r=0;r<e-1;r++){var l=0;t.isDark(i,r)&&l++,t.isDark(i+1,r)&&l++,t.isDark(i,r+1)&&l++,t.isDark(i+1,r+1)&&l++,0!=l&&4!=l||(o+=3)}for(i=0;i<e;i++)for(r=0;r<e-6;r++)t.isDark(i,r)&&!t.isDark(i,r+1)&&t.isDark(i,r+2)&&t.isDark(i,r+3)&&t.isDark(i,r+4)&&!t.isDark(i,r+5)&&t.isDark(i,r+6)&&(o+=40);for(r=0;r<e;r++)for(i=0;i<e-6;i++)t.isDark(i,r)&&!t.isDark(i+1,r)&&t.isDark(i+2,r)&&t.isDark(i+3,r)&&t.isDark(i+4,r)&&!t.isDark(i+5,r)&&t.isDark(i+6,r)&&(o+=40);var u=0;for(r=0;r<e;r++)for(i=0;i<e;i++)t.isDark(i,r)&&u++;return o+=10*(Math.abs(100*u/e/e-50)/5)}},QRMath={glog:function(t){if(t<1)throw new Error("glog("+t+")");return QRMath.LOG_TABLE[t]},gexp:function(t){for(;t<0;)t+=255;for(;t>=256;)t-=255;return QRMath.EXP_TABLE[t]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)},i=0;i<8;i++)QRMath.EXP_TABLE[i]=1<<i;for(i=8;i<256;i++)QRMath.EXP_TABLE[i]=QRMath.EXP_TABLE[i-4]^QRMath.EXP_TABLE[i-5]^QRMath.EXP_TABLE[i-6]^QRMath.EXP_TABLE[i-8];for(i=0;i<255;i++)QRMath.LOG_TABLE[QRMath.EXP_TABLE[i]]=i;function QRPolynomial(t,e){if(void 0==t.length)throw new Error(t.length+"/"+e);for(var o=0;o<t.length&&0==t[o];)o++;this.num=new Array(t.length-o+e);for(var i=0;i<t.length-o;i++)this.num[i]=t[i+o]}function QRRSBlock(t,e){this.totalCount=t,this.dataCount=e}function QRBitBuffer(){this.buffer=[],this.length=0}QRPolynomial.prototype={get:function(t){return this.num[t]},getLength:function(){return this.num.length},multiply:function(t){for(var e=new Array(this.getLength()+t.getLength()-1),o=0;o<this.getLength();o++)for(var i=0;i<t.getLength();i++)e[o+i]^=QRMath.gexp(QRMath.glog(this.get(o))+QRMath.glog(t.get(i)));return new QRPolynomial(e,0)},mod:function(t){if(this.getLength()-t.getLength()<0)return this;for(var e=QRMath.glog(this.get(0))-QRMath.glog(t.get(0)),o=new Array(this.getLength()),i=0;i<this.getLength();i++)o[i]=this.get(i);for(i=0;i<t.getLength();i++)o[i]^=QRMath.gexp(QRMath.glog(t.get(i))+e);return new QRPolynomial(o,0).mod(t)}},QRRSBlock.RS_BLOCK_TABLE=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12,7,37,13],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],QRRSBlock.getRSBlocks=function(t,e){var o=QRRSBlock.getRsBlockTable(t,e);if(void 0==o)throw new Error("bad rs block @ typeNumber:"+t+"/errorCorrectLevel:"+e);for(var i=o.length/3,r=[],n=0;n<i;n++)for(var a=o[3*n+0],s=o[3*n+1],h=o[3*n+2],l=0;l<a;l++)r.push(new QRRSBlock(s,h));return r},QRRSBlock.getRsBlockTable=function(t,e){switch(e){case QRErrorCorrectLevel.L:return QRRSBlock.RS_BLOCK_TABLE[4*(t-1)+0];case QRErrorCorrectLevel.M:return QRRSBlock.RS_BLOCK_TABLE[4*(t-1)+1];case QRErrorCorrectLevel.Q:return QRRSBlock.RS_BLOCK_TABLE[4*(t-1)+2];case QRErrorCorrectLevel.H:return QRRSBlock.RS_BLOCK_TABLE[4*(t-1)+3];default:return}},QRBitBuffer.prototype={get:function(t){var e=Math.floor(t/8);return 1==(this.buffer[e]>>>7-t%8&1)},put:function(t,e){for(var o=0;o<e;o++)this.putBit(1==(t>>>e-o-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){var e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),t&&(this.buffer[e]|=128>>>this.length%8),this.length++}};var QRCodeLimitLength=[[17,14,11,7],[32,26,20,14],[53,42,32,24],[78,62,46,34],[106,84,60,44],[134,106,74,58],[154,122,86,64],[192,152,108,84],[230,180,130,98],[271,213,151,119],[321,251,177,137],[367,287,203,155],[425,331,241,177],[458,362,258,194],[520,412,292,220],[586,450,322,250],[644,504,364,280],[718,560,394,310],[792,624,442,338],[858,666,482,382],[929,711,509,403],[1003,779,565,439],[1091,857,611,461],[1171,911,661,511],[1273,997,715,535],[1367,1059,751,593],[1465,1125,805,625],[1528,1190,868,658],[1628,1264,908,698],[1732,1370,982,742],[1840,1452,1030,790],[1952,1538,1112,842],[2068,1628,1168,898],[2188,1722,1228,958],[2303,1809,1283,983],[2431,1911,1351,1051],[2563,1989,1423,1093],[2699,2099,1499,1139],[2809,2213,1579,1219],[2953,2331,1663,1273]];function _getTypeNumber(t,e){for(var o=e.correctLevel,i=1,r=_getUTF8Length(t),n=0,a=QRCodeLimitLength.length;n<=a;n++){var s=0;switch(o){case QRErrorCorrectLevel.L:s=QRCodeLimitLength[n][0];break;case QRErrorCorrectLevel.M:s=QRCodeLimitLength[n][1];break;case QRErrorCorrectLevel.Q:s=QRCodeLimitLength[n][2];break;case QRErrorCorrectLevel.H:s=QRCodeLimitLength[n][3]}if(r<=s)break;i++}if(i>QRCodeLimitLength.length)throw new Error("Too long data");return 0!=e.version&&(i<=e.version?(i=e.version,e.runVersion=i):(console.warn("QR Code version "+e.version+" too small, run version use "+i),e.runVersion=i)),i}function _getUTF8Length(t){var e=encodeURI(t).toString().replace(/\%[0-9a-fA-F]{2}/g,"a");return e.length+(e.length!=t.length?3:0)}var Drawing=function(t){this._bIsPainted=!1,this._htOption=t,this._canvas=createCanvas(200,200),this._oContext=this._canvas.getContext("2d"),this._oContext.patternQuality="best",this._oContext.quality="best",this._oContext.textDrawingMode="path",this._oContext.antialias="gray",this._bSupportDataURI=null};function QRCode(t){if(this._htOption={width:256,height:256,typeNumber:4,colorDark:"#000000",colorLight:"#ffffff",correctLevel:QRErrorCorrectLevel.H,dotScale:1,quietZone:0,quietZoneColor:"transparent",title:"",titleFont:"bold 16px Arial",titleColor:"#000000",titleBackgroundColor:"#ffffff",titleHeight:0,titleTop:30,subTitle:"",subTitleFont:"14px Arial",subTitleColor:"#4F4F4F",subTitleTop:60,logo:void 0,logoWidth:void 0,logoHeight:void 0,logoBackgroundColor:"#ffffff",logoBackgroundTransparent:!1,PO:void 0,PI:void 0,PO_TL:void 0,PI_TL:void 0,PO_TR:void 0,PI_TR:void 0,PO_BL:void 0,PI_BL:void 0,AO:void 0,AI:void 0,timing:void 0,timing_H:void 0,timing_V:void 0,backgroundImage:void 0,backgroundImageAlpha:1,autoColor:!1,onRenderingStart:void 0,format:"PNG",compressionLevel:6,quality:.75,version:0,binary:!1},"string"==typeof t&&(t={text:t}),t)for(var e in t)this._htOption[e]=t[e];(this._htOption.version<0||this._htOption.version>40)&&(console.warn("QR Code version '"+this._htOption.version+"' is invalidate, reset to 0"),this._htOption.version=0),this._htOption.format=this._htOption.format.toUpperCase(),"PNG"!=this._htOption.format&&"JPG"!=this._htOption.format&&(console.warn("Image format '"+this._htOption.format+"' is invalidate, reset to 'PNG'"),this._htOption.format="PNG"),"PNG"==this._htOption.format&&(this._htOption.compressionLevel<0||this._htOption.compressionLevel>9)?(console.warn(this._htOption.compressionLevel+" is invalidate, PNG compressionLevel must between 0 and 9, now reset to 6. "),this._htOption.compressionLevel=1):(this._htOption.quality<0||this._htOption.quality>1)&&(console.warn(this._htOption.quality+" is invalidate, JPG quality must between 0 and 1, now reset to 0.75. "),this._htOption.quality=.75),(this._htOption.dotScale<0||this._htOption.dotScale>1)&&(console.warn(this._htOption.dotScale+" , is invalidate, dotScale must greater than 0, less than or equal to 1, now reset to 1. "),this._htOption.dotScale=1),(this._htOption.backgroundImageAlpha<0||this._htOption.backgroundImageAlpha>1)&&(console.warn(this._htOption.backgroundImageAlpha+" , is invalidate, backgroundImageAlpha must between 0 and 1, now reset to 1. "),this._htOption.backgroundImageAlpha=1),this._htOption.height=this._htOption.height+this._htOption.titleHeight,this._oQRCode=null,this._oQRCode=new QRCodeModel(_getTypeNumber(this._htOption.text,this._htOption),this._htOption.correctLevel),this._oQRCode.addData(this._htOption.text,this._htOption.binary),this._oQRCode.make()}Drawing.prototype.draw=function(t){var e=this._oContext,o=this._htOption;o.title||o.subTitle||(o.height-=o.titleHeight,o.titleHeight=0);var i=t.getModuleCount(),r=Math.round(o.width/i),n=Math.round((o.height-o.titleHeight)/i);o.quietZone=Math.round(o.quietZone),this._htOption.width=r*i,this._htOption.height=n*i+o.titleHeight,this._canvas.width=this._htOption.width+2*this._htOption.quietZone,this._canvas.height=this._htOption.height+2*this._htOption.quietZone;var a="rgba(0, 0, 0, .6)",s="rgba(255, 255, 255, .7)";"JPG"==o.format?("transparent"==o.quietZoneColor&&(o.quietZoneColor="#ffffff"),o.logoBackgroundTransparent=!1,a=o.colorDark,s=o.colorLight,o.colorLight,e.fillStyle="#ffffff",e.fillRect(0,0,this._canvas.width,this._canvas.height)):(e.lineWidth=0,e.fillStyle=this._htOption.colorLight,e.fillRect(0,0,this._canvas.width,this._canvas.height));var h=this;function l(){e.lineWidth=0,e.fillStyle=o.quietZoneColor,e.fillRect(0,0,h._canvas.width,o.quietZone),e.fillRect(0,o.quietZone,o.quietZone,h._canvas.height-2*o.quietZone),e.fillRect(h._canvas.width-o.quietZone,o.quietZone,o.quietZone,h._canvas.height-2*o.quietZone),e.fillRect(0,h._canvas.height-o.quietZone,h._canvas.width,o.quietZone)}if(o.backgroundImage){var u=new Image;u.onload=function(){e.globalAlpha=1,e.globalAlpha=o.backgroundImageAlpha,e.drawImage(u,0,o.titleHeight,o.width+2*o.quietZone,o.height+2*o.quietZone-o.titleHeight),e.globalAlpha=1,g.call(h,t)},u.src=o.backgroundImage}else g.call(h,t);function g(t){for(var u=0;u<i;u++)for(var g=0;g<i;g++){var d=g*r+o.quietZone,f=u*n+o.quietZone,c=t.isDark(u,g),p=t.getEye(u,g);if(p){c=p.isDarkBlock;var R=p.type,m=o[R]||o[R.substring(0,2)]||o.colorDark;e.lineWidth=0,e.strokeStyle=c?m:o.colorLight,e.fillStyle=c?m:o.colorLight,e.fillRect(d,o.titleHeight+f,r,n)}else{e.lineWidth=0,e.strokeStyle=c?o.colorDark:o.colorLight,e.fillStyle=c?o.colorDark:o.colorLight;var v=o.dotScale;if(6==u){v=1;var _=o.timing_H||o.timing||o.colorDark;e.fillStyle=c?_:o.colorLight,e.strokeStyle=e.fillStyle,e.fillRect(d+r*(1-v)/2,o.titleHeight+f+n*(1-v)/2,r*v,n*v)}else if(6==g){v=1;var C=o.timing_V||o.timing||o.colorDark;e.fillStyle=c?C:o.colorLight,e.strokeStyle=e.fillStyle,e.fillRect(d+r*(1-v)/2,o.titleHeight+f+n*(1-v)/2,r*v,n*v)}else o.backgroundImage?(o.autoColor?(e.strokeStyle=c?a:s,e.fillStyle=c?a:s):(e.fillStyle=c?o.colorDark:o.colorLight,e.strokeStyle=e.fillStyle),e.fillRect(d+r*(1-v)/2,o.titleHeight+f+n*(1-v)/2,r*v,n*v)):(e.strokeStyle=e.fillStyle,e.fillRect(d+r*(1-v)/2,o.titleHeight+f+n*(1-v)/2,r*v,n*v))}1==o.dotScale||p||(e.strokeStyle=o.colorLight)}if(o.title&&(e.fillStyle=o.titleBackgroundColor,e.fillRect(0,0,h._canvas.width,o.titleHeight+this._htOption.quietZone),e.font=o.titleFont,e.fillStyle=o.titleColor,e.textAlign="center",e.fillText(o.title,h._canvas.width/2,this._htOption.quietZone+this._htOption.titleTop)),o.subTitle&&(e.font=o.subTitleFont,e.fillStyle=o.subTitleColor,e.fillText(o.subTitle,h._canvas.width/2,this._htOption.quietZone+this._htOption.subTitleTop)),o.logo){var Q=new Image;Q.src=o.logo;var L=this;function T(t){var i=Math.round(o.width/3.5),r=Math.round(o.height/3.5);i!==r&&(i=r),o.logoWidth&&(i=Math.round(o.logoWidth)),o.logoHeight&&(r=Math.round(o.logoHeight));var n,a,s=(o.width+2*o.quietZone-i)/2,h=(o.height+o.titleHeight+2*o.quietZone-r)/2;o.logoBackgroundTransparent||(e.fillStyle=o.logoBackgroundColor,e.fillRect(s,h,i,r)),void 0===t.naturalWidth?(n=t.width,a=t.height):(n=t.naturalWidth,a=t.naturalHeight);var u=Math.min(i/n,r/a),g=n*u,d=a*u;e.drawImage(t,s+(i-g)/2,h+(r-d)/2,g,d),L._bIsPainted=!0,o.quietZone>0&&o.quietZoneColor&&l(),L.makeImage()}if(Q.onload=function(){T(Q)},Q.onerror=function(t){console.error(t)},Q.complete)return Q.onload=null,void T(Q)}else this._bIsPainted=!0,o.quietZone>0&&o.quietZoneColor&&l(),this.makeImage()}},Drawing.prototype.makeImage=function(){var t=this.makeOptions,e=this;if("FILE"==t.makeType){this._htOption.onRenderingStart&&this._htOption.onRenderingStart(this._htOption);var o=fs.createWriteStream(t.path);("PNG"==this._htOption.format?this._canvas.createPNGStream({compressionLevel:this._htOption.compressionLevel}):this._canvas.createJPEGStream({quality:this._htOption.quality})).pipe(o),o.on("finish",()=>{e.resolve({})})}else"URL"==t.makeType&&(this._htOption.onRenderingStart&&this._htOption.onRenderingStart(this._htOption),"PNG"==this._htOption.format?this._canvas.toDataURL((t,o)=>{e.resolve(o)}):this._canvas.toDataURL("image/jpeg",(t,o)=>{e.resolve(o)}))},Drawing.prototype.isPainted=function(){return this._bIsPainted},Drawing.prototype.round=function(t){return t?Math.floor(1e3*t)/1e3:t},QRCode.prototype.saveImage=function(t){t=Object.assign({makeType:"FILE",path:null},t);var e=new Drawing(this._htOption);e.makeOptions=t;try{var o=this;return new Promise(t=>{e.resolve=t,e.draw(o._oQRCode)})}catch(t){console.error(t)}},QRCode.prototype.toDataURL=function(t){var e=new Drawing(this._htOption);e.makeOptions={makeType:"URL"};try{var o=this;return new Promise(t=>{e.resolve=t,e.draw(o._oQRCode)})}catch(t){console.error(t)}},QRCode.CorrectLevel=QRErrorCorrectLevel,module.exports=QRCode;
var{createCanvas:createCanvas,loadImage:loadImage,Image:Image}=require("canvas"),jsdom=require("jsdom"),C2S=require("./canvas2svg"),fs=require("fs");const{JSDOM:JSDOM}=jsdom,win=(new JSDOM).window;function QR8bitByte(t,e){this.mode=QRMode.MODE_8BIT_BYTE,this.data=t,this.parsedData=[];for(var o=0,i=this.data.length;o<i;o++){var r=[],n=this.data.charCodeAt(o);e?r[0]=n:n>65536?(r[0]=240|(1835008&n)>>>18,r[1]=128|(258048&n)>>>12,r[2]=128|(4032&n)>>>6,r[3]=128|63&n):n>2048?(r[0]=224|(61440&n)>>>12,r[1]=128|(4032&n)>>>6,r[2]=128|63&n):n>128?(r[0]=192|(1984&n)>>>6,r[1]=128|63&n):r[0]=n,this.parsedData.push(r)}this.parsedData=Array.prototype.concat.apply([],this.parsedData),this.parsedData.length!=this.data.length&&(this.parsedData.unshift(191),this.parsedData.unshift(187),this.parsedData.unshift(239))}function QRCodeModel(t,e){this.typeNumber=t,this.errorCorrectLevel=e,this.modules=null,this.moduleCount=0,this.dataCache=null,this.dataList=[]}QR8bitByte.prototype={getLength:function(t){return this.parsedData.length},write:function(t){for(var e=0,o=this.parsedData.length;e<o;e++)t.put(this.parsedData[e],8)}},QRCodeModel.prototype={addData:function(t,e){var o=new QR8bitByte(t,e);this.dataList.push(o),this.dataCache=null},isDark:function(t,e){if(t<0||this.moduleCount<=t||e<0||this.moduleCount<=e)throw new Error(t+","+e);return this.modules[t][e][0]},getEye:function(t,e){if(t<0||this.moduleCount<=t||e<0||this.moduleCount<=e)throw new Error(t+","+e);var o=this.modules[t][e];if(o[1]){var i="P"+o[1]+"_"+o[2];return"A"==o[2]&&(i="A"+o[1]),{isDarkBlock:o[0],type:i}}return null},getModuleCount:function(){return this.moduleCount},make:function(){this.makeImpl(!1,this.getBestMaskPattern())},makeImpl:function(t,e){this.moduleCount=4*this.typeNumber+17,this.modules=new Array(this.moduleCount);for(var o=0;o<this.moduleCount;o++){this.modules[o]=new Array(this.moduleCount);for(var i=0;i<this.moduleCount;i++)this.modules[o][i]=[]}this.setupPositionProbePattern(0,0,"TL"),this.setupPositionProbePattern(this.moduleCount-7,0,"BL"),this.setupPositionProbePattern(0,this.moduleCount-7,"TR"),this.setupPositionAdjustPattern("A"),this.setupTimingPattern(),this.setupTypeInfo(t,e),this.typeNumber>=7&&this.setupTypeNumber(t),null==this.dataCache&&(this.dataCache=QRCodeModel.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,e)},setupPositionProbePattern:function(t,e,o){for(var i=-1;i<=7;i++)if(!(t+i<=-1||this.moduleCount<=t+i))for(var r=-1;r<=7;r++)e+r<=-1||this.moduleCount<=e+r||(0<=i&&i<=6&&(0==r||6==r)||0<=r&&r<=6&&(0==i||6==i)||2<=i&&i<=4&&2<=r&&r<=4?(this.modules[t+i][e+r][0]=!0,this.modules[t+i][e+r][2]=o,this.modules[t+i][e+r][1]=-0==i||-0==r||6==i||6==r?"O":"I"):this.modules[t+i][e+r][0]=!1)},getBestMaskPattern:function(){for(var t=0,e=0,o=0;o<8;o++){this.makeImpl(!0,o);var i=QRUtil.getLostPoint(this);(0==o||t>i)&&(t=i,e=o)}return e},createMovieClip:function(t,e,o){var i=t.createEmptyMovieClip(e,o);this.make();for(var r=0;r<this.modules.length;r++)for(var n=1*r,a=0;a<this.modules[r].length;a++){var s=1*a;this.modules[r][a][0]&&(i.beginFill(0,100),i.moveTo(s,n),i.lineTo(s+1,n),i.lineTo(s+1,n+1),i.lineTo(s,n+1),i.endFill())}return i},setupTimingPattern:function(){for(var t=8;t<this.moduleCount-8;t++)null==this.modules[t][6][0]&&(this.modules[t][6][0]=t%2==0);for(var e=8;e<this.moduleCount-8;e++)null==this.modules[6][e][0]&&(this.modules[6][e][0]=e%2==0)},setupPositionAdjustPattern:function(t){for(var e=QRUtil.getPatternPosition(this.typeNumber),o=0;o<e.length;o++)for(var i=0;i<e.length;i++){var r=e[o],n=e[i];if(null==this.modules[r][n][0])for(var a=-2;a<=2;a++)for(var s=-2;s<=2;s++)-2==a||2==a||-2==s||2==s||0==a&&0==s?(this.modules[r+a][n+s][0]=!0,this.modules[r+a][n+s][2]=t,this.modules[r+a][n+s][1]=-2==a||-2==s||2==a||2==s?"O":"I"):this.modules[r+a][n+s][0]=!1}},setupTypeNumber:function(t){for(var e=QRUtil.getBCHTypeNumber(this.typeNumber),o=0;o<18;o++){var i=!t&&1==(e>>o&1);this.modules[Math.floor(o/3)][o%3+this.moduleCount-8-3][0]=i}for(o=0;o<18;o++){i=!t&&1==(e>>o&1);this.modules[o%3+this.moduleCount-8-3][Math.floor(o/3)][0]=i}},setupTypeInfo:function(t,e){for(var o=this.errorCorrectLevel<<3|e,i=QRUtil.getBCHTypeInfo(o),r=0;r<15;r++){var n=!t&&1==(i>>r&1);r<6?this.modules[r][8][0]=n:r<8?this.modules[r+1][8][0]=n:this.modules[this.moduleCount-15+r][8][0]=n}for(r=0;r<15;r++){n=!t&&1==(i>>r&1);r<8?this.modules[8][this.moduleCount-r-1][0]=n:r<9?this.modules[8][15-r-1+1][0]=n:this.modules[8][15-r-1][0]=n}this.modules[this.moduleCount-8][8][0]=!t},mapData:function(t,e){for(var o=-1,i=this.moduleCount-1,r=7,n=0,a=this.moduleCount-1;a>0;a-=2)for(6==a&&a--;;){for(var s=0;s<2;s++)if(null==this.modules[i][a-s][0]){var h=!1;n<t.length&&(h=1==(t[n]>>>r&1)),QRUtil.getMask(e,i,a-s)&&(h=!h),this.modules[i][a-s][0]=h,-1==--r&&(n++,r=7)}if((i+=o)<0||this.moduleCount<=i){i-=o,o=-o;break}}}},QRCodeModel.PAD0=236,QRCodeModel.PAD1=17,QRCodeModel.createData=function(t,e,o){for(var i=QRRSBlock.getRSBlocks(t,e),r=new QRBitBuffer,n=0;n<o.length;n++){var a=o[n];r.put(a.mode,4),r.put(a.getLength(),QRUtil.getLengthInBits(a.mode,t)),a.write(r)}var s=0;for(n=0;n<i.length;n++)s+=i[n].dataCount;if(r.getLengthInBits()>8*s)throw new Error("code length overflow. ("+r.getLengthInBits()+">"+8*s+")");for(r.getLengthInBits()+4<=8*s&&r.put(0,4);r.getLengthInBits()%8!=0;)r.putBit(!1);for(;!(r.getLengthInBits()>=8*s||(r.put(QRCodeModel.PAD0,8),r.getLengthInBits()>=8*s));)r.put(QRCodeModel.PAD1,8);return QRCodeModel.createBytes(r,i)},QRCodeModel.createBytes=function(t,e){for(var o=0,i=0,r=0,n=new Array(e.length),a=new Array(e.length),s=0;s<e.length;s++){var h=e[s].dataCount,l=e[s].totalCount-h;i=Math.max(i,h),r=Math.max(r,l),n[s]=new Array(h);for(var u=0;u<n[s].length;u++)n[s][u]=255&t.buffer[u+o];o+=h;var g=QRUtil.getErrorCorrectPolynomial(l),d=new QRPolynomial(n[s],g.getLength()-1).mod(g);a[s]=new Array(g.getLength()-1);for(u=0;u<a[s].length;u++){var c=u+d.getLength()-a[s].length;a[s][u]=c>=0?d.get(c):0}}var f=0;for(u=0;u<e.length;u++)f+=e[u].totalCount;var p=new Array(f),v=0;for(u=0;u<i;u++)for(s=0;s<e.length;s++)u<n[s].length&&(p[v++]=n[s][u]);for(u=0;u<r;u++)for(s=0;s<e.length;s++)u<a[s].length&&(p[v++]=a[s][u]);return p};for(var QRMode={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},QRErrorCorrectLevel={L:1,M:0,Q:3,H:2},QRMaskPattern={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},QRUtil={PATTERN_POSITION_TABLE:[[],[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]],G15:1335,G18:7973,G15_MASK:21522,getBCHTypeInfo:function(t){for(var e=t<<10;QRUtil.getBCHDigit(e)-QRUtil.getBCHDigit(QRUtil.G15)>=0;)e^=QRUtil.G15<<QRUtil.getBCHDigit(e)-QRUtil.getBCHDigit(QRUtil.G15);return(t<<10|e)^QRUtil.G15_MASK},getBCHTypeNumber:function(t){for(var e=t<<12;QRUtil.getBCHDigit(e)-QRUtil.getBCHDigit(QRUtil.G18)>=0;)e^=QRUtil.G18<<QRUtil.getBCHDigit(e)-QRUtil.getBCHDigit(QRUtil.G18);return t<<12|e},getBCHDigit:function(t){for(var e=0;0!=t;)e++,t>>>=1;return e},getPatternPosition:function(t){return QRUtil.PATTERN_POSITION_TABLE[t-1]},getMask:function(t,e,o){switch(t){case QRMaskPattern.PATTERN000:return(e+o)%2==0;case QRMaskPattern.PATTERN001:return e%2==0;case QRMaskPattern.PATTERN010:return o%3==0;case QRMaskPattern.PATTERN011:return(e+o)%3==0;case QRMaskPattern.PATTERN100:return(Math.floor(e/2)+Math.floor(o/3))%2==0;case QRMaskPattern.PATTERN101:return e*o%2+e*o%3==0;case QRMaskPattern.PATTERN110:return(e*o%2+e*o%3)%2==0;case QRMaskPattern.PATTERN111:return(e*o%3+(e+o)%2)%2==0;default:throw new Error("bad maskPattern:"+t)}},getErrorCorrectPolynomial:function(t){for(var e=new QRPolynomial([1],0),o=0;o<t;o++)e=e.multiply(new QRPolynomial([1,QRMath.gexp(o)],0));return e},getLengthInBits:function(t,e){if(1<=e&&e<10)switch(t){case QRMode.MODE_NUMBER:return 10;case QRMode.MODE_ALPHA_NUM:return 9;case QRMode.MODE_8BIT_BYTE:case QRMode.MODE_KANJI:return 8;default:throw new Error("mode:"+t)}else if(e<27)switch(t){case QRMode.MODE_NUMBER:return 12;case QRMode.MODE_ALPHA_NUM:return 11;case QRMode.MODE_8BIT_BYTE:return 16;case QRMode.MODE_KANJI:return 10;default:throw new Error("mode:"+t)}else{if(!(e<41))throw new Error("type:"+e);switch(t){case QRMode.MODE_NUMBER:return 14;case QRMode.MODE_ALPHA_NUM:return 13;case QRMode.MODE_8BIT_BYTE:return 16;case QRMode.MODE_KANJI:return 12;default:throw new Error("mode:"+t)}}},getLostPoint:function(t){for(var e=t.getModuleCount(),o=0,i=0;i<e;i++)for(var r=0;r<e;r++){for(var n=0,a=t.isDark(i,r),s=-1;s<=1;s++)if(!(i+s<0||e<=i+s))for(var h=-1;h<=1;h++)r+h<0||e<=r+h||0==s&&0==h||a==t.isDark(i+s,r+h)&&n++;n>5&&(o+=3+n-5)}for(i=0;i<e-1;i++)for(r=0;r<e-1;r++){var l=0;t.isDark(i,r)&&l++,t.isDark(i+1,r)&&l++,t.isDark(i,r+1)&&l++,t.isDark(i+1,r+1)&&l++,0!=l&&4!=l||(o+=3)}for(i=0;i<e;i++)for(r=0;r<e-6;r++)t.isDark(i,r)&&!t.isDark(i,r+1)&&t.isDark(i,r+2)&&t.isDark(i,r+3)&&t.isDark(i,r+4)&&!t.isDark(i,r+5)&&t.isDark(i,r+6)&&(o+=40);for(r=0;r<e;r++)for(i=0;i<e-6;i++)t.isDark(i,r)&&!t.isDark(i+1,r)&&t.isDark(i+2,r)&&t.isDark(i+3,r)&&t.isDark(i+4,r)&&!t.isDark(i+5,r)&&t.isDark(i+6,r)&&(o+=40);var u=0;for(r=0;r<e;r++)for(i=0;i<e;i++)t.isDark(i,r)&&u++;return o+=10*(Math.abs(100*u/e/e-50)/5)}},QRMath={glog:function(t){if(t<1)throw new Error("glog("+t+")");return QRMath.LOG_TABLE[t]},gexp:function(t){for(;t<0;)t+=255;for(;t>=256;)t-=255;return QRMath.EXP_TABLE[t]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)},i=0;i<8;i++)QRMath.EXP_TABLE[i]=1<<i;for(i=8;i<256;i++)QRMath.EXP_TABLE[i]=QRMath.EXP_TABLE[i-4]^QRMath.EXP_TABLE[i-5]^QRMath.EXP_TABLE[i-6]^QRMath.EXP_TABLE[i-8];for(i=0;i<255;i++)QRMath.LOG_TABLE[QRMath.EXP_TABLE[i]]=i;function QRPolynomial(t,e){if(void 0==t.length)throw new Error(t.length+"/"+e);for(var o=0;o<t.length&&0==t[o];)o++;this.num=new Array(t.length-o+e);for(var i=0;i<t.length-o;i++)this.num[i]=t[i+o]}function QRRSBlock(t,e){this.totalCount=t,this.dataCount=e}function QRBitBuffer(){this.buffer=[],this.length=0}QRPolynomial.prototype={get:function(t){return this.num[t]},getLength:function(){return this.num.length},multiply:function(t){for(var e=new Array(this.getLength()+t.getLength()-1),o=0;o<this.getLength();o++)for(var i=0;i<t.getLength();i++)e[o+i]^=QRMath.gexp(QRMath.glog(this.get(o))+QRMath.glog(t.get(i)));return new QRPolynomial(e,0)},mod:function(t){if(this.getLength()-t.getLength()<0)return this;for(var e=QRMath.glog(this.get(0))-QRMath.glog(t.get(0)),o=new Array(this.getLength()),i=0;i<this.getLength();i++)o[i]=this.get(i);for(i=0;i<t.getLength();i++)o[i]^=QRMath.gexp(QRMath.glog(t.get(i))+e);return new QRPolynomial(o,0).mod(t)}},QRRSBlock.RS_BLOCK_TABLE=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12,7,37,13],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],QRRSBlock.getRSBlocks=function(t,e){var o=QRRSBlock.getRsBlockTable(t,e);if(void 0==o)throw new Error("bad rs block @ typeNumber:"+t+"/errorCorrectLevel:"+e);for(var i=o.length/3,r=[],n=0;n<i;n++)for(var a=o[3*n+0],s=o[3*n+1],h=o[3*n+2],l=0;l<a;l++)r.push(new QRRSBlock(s,h));return r},QRRSBlock.getRsBlockTable=function(t,e){switch(e){case QRErrorCorrectLevel.L:return QRRSBlock.RS_BLOCK_TABLE[4*(t-1)+0];case QRErrorCorrectLevel.M:return QRRSBlock.RS_BLOCK_TABLE[4*(t-1)+1];case QRErrorCorrectLevel.Q:return QRRSBlock.RS_BLOCK_TABLE[4*(t-1)+2];case QRErrorCorrectLevel.H:return QRRSBlock.RS_BLOCK_TABLE[4*(t-1)+3];default:return}},QRBitBuffer.prototype={get:function(t){var e=Math.floor(t/8);return 1==(this.buffer[e]>>>7-t%8&1)},put:function(t,e){for(var o=0;o<e;o++)this.putBit(1==(t>>>e-o-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){var e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),t&&(this.buffer[e]|=128>>>this.length%8),this.length++}};var QRCodeLimitLength=[[17,14,11,7],[32,26,20,14],[53,42,32,24],[78,62,46,34],[106,84,60,44],[134,106,74,58],[154,122,86,64],[192,152,108,84],[230,180,130,98],[271,213,151,119],[321,251,177,137],[367,287,203,155],[425,331,241,177],[458,362,258,194],[520,412,292,220],[586,450,322,250],[644,504,364,280],[718,560,394,310],[792,624,442,338],[858,666,482,382],[929,711,509,403],[1003,779,565,439],[1091,857,611,461],[1171,911,661,511],[1273,997,715,535],[1367,1059,751,593],[1465,1125,805,625],[1528,1190,868,658],[1628,1264,908,698],[1732,1370,982,742],[1840,1452,1030,790],[1952,1538,1112,842],[2068,1628,1168,898],[2188,1722,1228,958],[2303,1809,1283,983],[2431,1911,1351,1051],[2563,1989,1423,1093],[2699,2099,1499,1139],[2809,2213,1579,1219],[2953,2331,1663,1273]];function _getTypeNumber(t,e){for(var o=e.correctLevel,i=1,r=_getUTF8Length(t),n=0,a=QRCodeLimitLength.length;n<=a;n++){var s=0;switch(o){case QRErrorCorrectLevel.L:s=QRCodeLimitLength[n][0];break;case QRErrorCorrectLevel.M:s=QRCodeLimitLength[n][1];break;case QRErrorCorrectLevel.Q:s=QRCodeLimitLength[n][2];break;case QRErrorCorrectLevel.H:s=QRCodeLimitLength[n][3]}if(r<=s)break;i++}if(i>QRCodeLimitLength.length)throw new Error("Too long data");return 0!=e.version&&(i<=e.version?(i=e.version,e.runVersion=i):(console.warn("QR Code version "+e.version+" too small, run version use "+i),e.runVersion=i)),i}function _getUTF8Length(t){var e=encodeURI(t).toString().replace(/\%[0-9a-fA-F]{2}/g,"a");return e.length+(e.length!=t.length?3:0)}var Drawing=function(t){this._bIsPainted=!1,this._htOption=t,this._canvas=createCanvas(200,200),"svg"==this._htOption._drawer?this._oContext={}:this._oContext=this._canvas.getContext("2d"),this._bSupportDataURI=null};function QRCode(t){if(this._htOption={width:256,height:256,typeNumber:4,colorDark:"#000000",colorLight:"#ffffff",correctLevel:QRErrorCorrectLevel.H,dotScale:1,quietZone:0,quietZoneColor:"transparent",title:"",titleFont:"bold 16px Arial",titleColor:"#000000",titleBackgroundColor:"#ffffff",titleHeight:0,titleTop:30,subTitle:"",subTitleFont:"14px Arial",subTitleColor:"#4F4F4F",subTitleTop:60,logo:void 0,logoWidth:void 0,logoHeight:void 0,logoBackgroundColor:"#ffffff",logoBackgroundTransparent:!1,PO:void 0,PI:void 0,PO_TL:void 0,PI_TL:void 0,PO_TR:void 0,PI_TR:void 0,PO_BL:void 0,PI_BL:void 0,AO:void 0,AI:void 0,timing:void 0,timing_H:void 0,timing_V:void 0,backgroundImage:void 0,backgroundImageAlpha:1,autoColor:!1,onRenderingStart:void 0,format:"PNG",compressionLevel:6,quality:.75,version:0,binary:!1},"string"==typeof t&&(t={text:t}),t)for(var e in t)this._htOption[e]=t[e];(this._htOption.version<0||this._htOption.version>40)&&(console.warn("QR Code version '"+this._htOption.version+"' is invalidate, reset to 0"),this._htOption.version=0),this._htOption.format=this._htOption.format.toUpperCase(),"PNG"!=this._htOption.format&&"JPG"!=this._htOption.format&&(console.warn("Image format '"+this._htOption.format+"' is invalidate, reset to 'PNG'"),this._htOption.format="PNG"),"PNG"==this._htOption.format&&(this._htOption.compressionLevel<0||this._htOption.compressionLevel>9)?(console.warn(this._htOption.compressionLevel+" is invalidate, PNG compressionLevel must between 0 and 9, now reset to 6. "),this._htOption.compressionLevel=1):(this._htOption.quality<0||this._htOption.quality>1)&&(console.warn(this._htOption.quality+" is invalidate, JPG quality must between 0 and 1, now reset to 0.75. "),this._htOption.quality=.75),(this._htOption.dotScale<0||this._htOption.dotScale>1)&&(console.warn(this._htOption.dotScale+" , is invalidate, dotScale must greater than 0, less than or equal to 1, now reset to 1. "),this._htOption.dotScale=1),(this._htOption.backgroundImageAlpha<0||this._htOption.backgroundImageAlpha>1)&&(console.warn(this._htOption.backgroundImageAlpha+" , is invalidate, backgroundImageAlpha must between 0 and 1, now reset to 1. "),this._htOption.backgroundImageAlpha=1),(!this._htOption.drawer||"svg"!=this._htOption.drawer&&"canvas"!=this._htOption.drawer)&&(this._htOption.drawer="canvas"),this._htOption.height=this._htOption.height+this._htOption.titleHeight,this._oQRCode=null,this._oQRCode=new QRCodeModel(_getTypeNumber(this._htOption.text,this._htOption),this._htOption.correctLevel),this._oQRCode.addData(this._htOption.text,this._htOption.binary),this._oQRCode.make()}Drawing.prototype.draw=function(t){var e=this._htOption;e.title||e.subTitle||(e.height-=e.titleHeight,e.titleHeight=0);var o=t.getModuleCount(),i=Math.round(e.width/o),r=Math.round((e.height-e.titleHeight)/o);e.quietZone=Math.round(e.quietZone),this._htOption.width=i*o,this._htOption.height=r*o+e.titleHeight,this._canvas.width=this._htOption.width+2*this._htOption.quietZone,this._canvas.height=this._htOption.height+2*this._htOption.quietZone,"svg"==this._htOption._drawer&&(this._oContext=new C2S({document:win.document,XMLSerializer:win.XMLSerializer,width:this._canvas.width,height:this._canvas.height})),this._oContext.patternQuality="best",this._oContext.quality="best",this._oContext.textDrawingMode="path",this._oContext.antialias="gray";var n=this._oContext,a="rgba(0, 0, 0, .6)",s="rgba(255, 255, 255, .7)";"JPG"==e.format?("transparent"==e.quietZoneColor&&(e.quietZoneColor="#ffffff"),e.logoBackgroundTransparent=!1,a=e.colorDark,s=e.colorLight,e.colorLight,n.fillStyle="#ffffff",n.fillRect(0,0,this._canvas.width,this._canvas.height)):(n.lineWidth=0,n.fillStyle=this._htOption.colorLight,n.fillRect(0,0,this._canvas.width,this._canvas.height));var h=this;function l(){n.lineWidth=0,n.fillStyle=e.quietZoneColor,n.fillRect(0,0,h._canvas.width,e.quietZone),n.fillRect(0,e.quietZone,e.quietZone,h._canvas.height-2*e.quietZone),n.fillRect(h._canvas.width-e.quietZone,e.quietZone,e.quietZone,h._canvas.height-2*e.quietZone),n.fillRect(0,h._canvas.height-e.quietZone,h._canvas.width,e.quietZone)}if(e.backgroundImage){var u=new Image;u.onload=function(){n.globalAlpha=1,n.globalAlpha=e.backgroundImageAlpha,n.drawImage(u,0,e.titleHeight,e.width+2*e.quietZone,e.height+2*e.quietZone-e.titleHeight),n.globalAlpha=1,g.call(h,t)},u.src=e.backgroundImage}else g.call(h,t);function g(t){for(var u=0;u<o;u++)for(var g=0;g<o;g++){var d=g*i+e.quietZone,c=u*r+e.quietZone,f=t.isDark(u,g),p=t.getEye(u,g);if(p){f=p.isDarkBlock;var v=p.type,R=e[v]||e[v.substring(0,2)]||e.colorDark;n.lineWidth=0,n.strokeStyle=f?R:e.colorLight,n.fillStyle=f?R:e.colorLight,n.fillRect(d,e.titleHeight+c,i,r)}else{n.lineWidth=0,n.strokeStyle=f?e.colorDark:e.colorLight,n.fillStyle=f?e.colorDark:e.colorLight;var m=e.dotScale;if(6==u){m=1;var _=e.timing_H||e.timing||e.colorDark;n.fillStyle=f?_:e.colorLight,n.strokeStyle=n.fillStyle,n.fillRect(d+i*(1-m)/2,e.titleHeight+c+r*(1-m)/2,i*m,r*m)}else if(6==g){m=1;var C=e.timing_V||e.timing||e.colorDark;n.fillStyle=f?C:e.colorLight,n.strokeStyle=n.fillStyle,n.fillRect(d+i*(1-m)/2,e.titleHeight+c+r*(1-m)/2,i*m,r*m)}else e.backgroundImage?(e.autoColor?(n.strokeStyle=f?a:s,n.fillStyle=f?a:s):(n.fillStyle=f?e.colorDark:e.colorLight,n.strokeStyle=n.fillStyle),n.fillRect(d+i*(1-m)/2,e.titleHeight+c+r*(1-m)/2,i*m,r*m)):(n.strokeStyle=n.fillStyle,n.fillRect(d+i*(1-m)/2,e.titleHeight+c+r*(1-m)/2,i*m,r*m))}1==e.dotScale||p||(n.strokeStyle=e.colorLight)}if(e.title&&(n.fillStyle=e.titleBackgroundColor,n.fillRect(0,0,h._canvas.width,e.titleHeight+this._htOption.quietZone),n.font=e.titleFont,n.fillStyle=e.titleColor,n.textAlign="center",n.fillText(e.title,h._canvas.width/2,this._htOption.quietZone+this._htOption.titleTop)),e.subTitle&&(n.font=e.subTitleFont,n.fillStyle=e.subTitleColor,n.fillText(e.subTitle,h._canvas.width/2,this._htOption.quietZone+this._htOption.subTitleTop)),e.logo){var Q=new Image;Q.src=e.logo;var L=this;function w(t){var o=Math.round(e.width/3.5),i=Math.round(e.height/3.5);o!==i&&(o=i),e.logoWidth&&(o=Math.round(e.logoWidth)),e.logoHeight&&(i=Math.round(e.logoHeight));var r,a,s=(e.width+2*e.quietZone-o)/2,h=(e.height+e.titleHeight+2*e.quietZone-i)/2;e.logoBackgroundTransparent||(n.fillStyle=e.logoBackgroundColor,n.fillRect(s,h,o,i)),void 0===t.naturalWidth?(r=t.width,a=t.height):(r=t.naturalWidth,a=t.naturalHeight);var u=Math.min(o/r,i/a),g=r*u,d=a*u;n.drawImage(t,s+(o-g)/2,h+(i-d)/2,g,d),L._bIsPainted=!0,e.quietZone>0&&e.quietZoneColor&&l(),L.makeImage()}if(Q.onload=function(){w(Q)},Q.onerror=function(t){console.error(t)},Q.complete)return Q.onload=null,void w(Q)}else this._bIsPainted=!0,e.quietZone>0&&e.quietZoneColor&&l(),this.makeImage()}},Drawing.prototype.makeImage=function(){var t=this.makeOptions,e=this;if("FILE"==t.makeType)if(this._htOption.onRenderingStart&&this._htOption.onRenderingStart(this._htOption),"svg"==this._htOption._drawer){let o=this._oContext.getSerializedSvg();fs.writeFile(t.path,o,"utf8",function(t){t&&e.reject(t),e.resolve({})})}else{var o=fs.createWriteStream(t.path);("PNG"==this._htOption.format?this._canvas.createPNGStream({compressionLevel:this._htOption.compressionLevel}):this._canvas.createJPEGStream({quality:this._htOption.quality})).pipe(o),o.on("finish",()=>{e.resolve({})})}else if("URL"==t.makeType)if(this._htOption.onRenderingStart&&this._htOption.onRenderingStart(this._htOption),"svg"==this._htOption._drawer){let t=this._oContext.getSerializedSvg();e.resolve(t)}else"PNG"==this._htOption.format?this._canvas.toDataURL((t,o)=>{e.resolve(o)}):this._canvas.toDataURL("image/jpeg",(t,o)=>{e.resolve(o)})},Drawing.prototype.isPainted=function(){return this._bIsPainted},Drawing.prototype.round=function(t){return t?Math.floor(1e3*t)/1e3:t},QRCode.prototype._toSave=function(t){var e=new Drawing(this._htOption);e.makeOptions=t;try{var o=this;return new Promise((t,i)=>{e.resolve=t,e.reject=i,e.draw(o._oQRCode)})}catch(t){console.error(t)}},QRCode.prototype.saveImage=function(t){return this._htOption._drawer="canvas",t=Object.assign({makeType:"FILE",path:null},t),this._toSave(t)},QRCode.prototype.saveSVG=function(t){return this._htOption._drawer="svg",t=Object.assign({makeType:"FILE",path:null},t),this._toSave(t)},QRCode.prototype._toData=function(t){this._htOption._drawer=t;var e=new Drawing(this._htOption);e.makeOptions={makeType:"URL"};try{var o=this;return new Promise((t,i)=>{e.resolve=t,e.reject=i,e.draw(o._oQRCode)})}catch(t){console.error(t)}},QRCode.prototype.toDataURL=function(){return this._toData("canvas")},QRCode.prototype.toSVGText=function(){return this._toData("svg")},QRCode.CorrectLevel=QRErrorCorrectLevel,module.exports=QRCode;
{
"name": "easyqrcodejs-nodejs",
"version": "3.7.2",
"description": "NodeJS QRCode generator. Can get standard base64 image data url text or save image to file. Cross-browser QRCode generator for pure javascript. Support Dot style, Logo, Background image, Colorful, Title etc. settings. support binary mode.(Running without DOM on server side)",
"version": "4.0.0",
"description": "NodeJS QRCode generator. Can save image or svg to file, get standard base64 image data url text or get SVG serialized text. Cross-browser QRCode generator for pure javascript. Support Dot style, Logo, Background image, Colorful, Title etc. settings. support binary mode.(Running without DOM on server side)",
"main": "index.min.js",

@@ -44,5 +44,6 @@ "scripts": {},

"dependencies": {
"canvas": "^2.6.0"
"canvas": "^2.6.0",
"jsdom": "^16.4.0"
},
"devDependencies": {}
}
# EasyQRCodeJS-NodeJS
EasyQRCodeJS-NodeJS is a NodeJS server side javascript QRCode image generator. Support setting Dot style, Logo, Background image, Colorful, Title and more. Support binary(hex) data mode.
EasyQRCodeJS-NodeJS is a NodeJS server side javascript QRCode image(PNG/JPEG/SVG/Base64 data url) generator. Support setting Dot style, Logo, Background image, Colorful, Title and more. Support binary(hex) data mode.
EasyQRCodeJS-NodeJS 是一个 NodeJS 环境下的服务端 JavaScript QRCode 图片生成模块。支持点状风格,Logo,背景图片,规则色彩控制,标题等设置。支持二进制数据模式。
EasyQRCodeJS-NodeJS 是一个 NodeJS 环境下的服务端 JavaScript QRCode 图片(PNG/JPEG/SVG/Base64 data url)生成模块。支持点状风格,Logo,背景图片,规则色彩控制,标题等设置。支持二进制数据模式。

@@ -31,3 +31,3 @@ ## Table of contents

| [EasyQRCodeJS](https://github.com/ushelp/EasyQRCodeJS) | **Running with DOM on CLIENT-SIDE .** Browser(IE6+, Chrome, Firefox, Safari, Opera, Mobile Safari, Android, Windows Mobile, ETC.), Electron, NW.js, ETC. |
| [EasyQRCodeJS-NodeJS](https://github.com/ushelp/EasyQRCodeJS-NodeJS) | **Running without DOM on SERVER-SIDE**. Save image to file or get data url text. NodeJS, Electron, NW.js, ETC.|
| [EasyQRCodeJS-NodeJS](https://github.com/ushelp/EasyQRCodeJS-NodeJS) | **Running without DOM on SERVER-SIDE**. Save image to file(PNG/JPEG/SVG) or get data url text. NodeJS, Electron, NW.js, ETC.|
| [EasyQRCode-React-Native](https://github.com/ushelp/EasyQRCode-React-Native) | **A QRCode generator for React Native**. Generate QRCode image or get base64 data url text. |

@@ -41,6 +41,8 @@

- Support save PNG image file
- Support save PNG/JPEG/SVG image file
- Support get standard base64 image data url text: `data:image/png;base64, ...`
- Support get SVG data text: `<svg xmlns:xlink="http://www.w3.org/1999/xlink" ...`
- Required Patterns that support dot style

@@ -73,3 +75,5 @@

- 支持获得 Base64 编码的标准图形 URL 字符串:`data:image/png;base64, ...`
- 支持获得 SVG 图形文本: `<svg xmlns:xlink="http://www.w3.org/1999/xlink" ...`
- 支持点形风格的 Required Patterns

@@ -166,3 +170,3 @@

logo:"http://127.0.0.1:8020/easy-qrcodejs/demo/logo.png",
logoWidth:80, // widht. default is automatic width
logoWidth:80, // width. default is automatic width
logoHeight:80 // height. default is automatic height

@@ -327,9 +331,17 @@ logoBackgroundColor:'#fffff', // Logo backgroud color, Invalid when `logBgTransparent` is true; default is '#ffffff'

qrcode.toDataURL().then(data=>{
console.info('======QRCode PNG DataURL======')
console.info('======QRCode PNG Base64 DataURL======')
console.info(data);
});
```
- **toSVGText()**
```JS
// Get SVG data text: '<svg xmlns:xlink="http://www.w3.org/1999/xlink" ...'
qrcode.toSVGText().then(data=>{
console.info('======QRCode SVG Data Text======')
console.info(data)
}).then(data=>{
console.log("`q-premium1.png` Base64 image has been generated.");
});
});
```
## TypeScript Support

@@ -336,0 +348,0 @@

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

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