Socket
Socket
Sign inDemoInstall

easyqrcodejs-nodejs

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

easyqrcodejs-nodejs - npm Package Compare versions

Comparing version 3.3.0 to 3.4.0

demo/q.jpg

110

demo/demo_node.js
const QRCode = require('../index.min');
var qrcode = new QRCode({
// ================================ PNG Configs
var config={
// ====== Basic

@@ -14,7 +18,5 @@ text: "www.easyproject.cn/donation",

dotScale: 1 // Must be greater than 0, less than or equal to 1. default is 1
});
}
var qrcode2 = new QRCode({
var config2={
// ====== Basic

@@ -30,3 +32,3 @@ text: "www.easyproject.cn/donation",

colorLight: "#FFFACD",
// === Posotion Pattern(Eye) Color

@@ -53,8 +55,6 @@ PI: '#BF3030',

backgroundImageAlpha: 0.3,
autoColor: true,
});
autoColor: true
}
var qrcode3 = new QRCode({
var config3={
// ====== Basic

@@ -65,3 +65,2 @@ text: "www.easyproject.cn/donation",

height: 400,
quietZone: 20,
correctLevel: QRCode.CorrectLevel.H, // L, M, Q, H

@@ -71,3 +70,6 @@ dotScale: 0.5 ,// Must be greater than 0, less than or equal to 1. default is 1

colorLight: "#FFFACD",
// QuietZone
quietZone:15,
// === Title

@@ -77,3 +79,3 @@ title: 'EasyQRCode', // Title

titleColor: "#004284", // Title Color
titleBackgroundColor: "#fffff", // Title Background
titleBackgroundColor: "#ffffff", // Title Background
titleHeight: 70, // Title height, include subTitle

@@ -114,3 +116,3 @@ titleTop: 25, // Title draw position(Y coordinate), default is 30

logoBackgroundTransparent: false, // Whether use transparent image, default is false
// === Background image

@@ -121,9 +123,8 @@ backgroundImage: 'logo.png',

onRenderingStart:function(){
console.info("The QRCode file `q3.png` was created.");
onRenderingStart:function(options){
console.info("The QRCode file `q3."+options.format+"` was created.");
}
});
}
var qrcode4 = new QRCode({
var config4={
// ====== Basic

@@ -134,3 +135,2 @@ text: "www.easyproject.cn/donation",

height: 400,
quietZone: 20,
correctLevel: QRCode.CorrectLevel.H, // L, M, Q, H

@@ -140,7 +140,7 @@ dotScale: 0.5 ,// Must be greater than 0, less than or equal to 1. default is 1

colorLight: "#FFFACD",
// QuietZone
quietZone:15,
quietZoneColor:'#00CED1',
// QuietZone
quietZone:15,
quietZoneColor:'#00CED1',
// === Posotion Pattern(Eye) Color

@@ -172,25 +172,24 @@ PI: '#BF3030',

logoBackgroundTransparent: false // Whether use transparent image, default is false
});
}
// ================================ PNG Test
var qrcode = new QRCode(config);
var qrcode2 = new QRCode(config2);
var qrcode3 = new QRCode(config3);
var qrcode4 = new QRCode(config4);
qrcode.saveImage({
path: 'q.png',
compressionLevel: 6
path: 'q.png'
});
qrcode2.saveImage({
path: 'q2.png'
});
qrcode3.saveImage({
path: 'q3.png'
});
qrcode4.saveImage({
path: 'q4.png'
});
qrcode.toDataURL().then(data=>{

@@ -202,1 +201,40 @@ console.info('======QRCode PNG DataURL======')

// ================================ JPG Test
var config5 = Object.assign({}, config, {
format:'JPG'
});
var config6 = Object.assign({}, config2, {
format:'JPG'
});
var config7 = Object.assign({}, config3, {
format:'JPG'
});
var config8 = Object.assign({}, config4, {
format:'JPG'
});
var qrcode5 = new QRCode(config5);
var qrcode6 = new QRCode(config6);
var qrcode7 = new QRCode(config7);
var qrcode8 = new QRCode(config8);
qrcode5.saveImage({
path: 'q.jpg'
});
qrcode6.saveImage({
path: 'q2.jpg'
});
qrcode7.saveImage({
path: 'q3.jpg'
});
qrcode8.saveImage({
path: 'q4.jpg'
});
qrcode5.toDataURL().then(data=>{
console.info('======QRCode JPG DataURL======')
console.info(data)
console.info('')
});

@@ -6,3 +6,3 @@ /**

*
* Version 3.3.0
* Version 3.4.0
*

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

Drawing.prototype.draw = function(oQRCode) {

@@ -1073,4 +1074,2 @@ var _oContext = this._oContext;

if (!_htOption.title && !_htOption.subTitle) {

@@ -1081,3 +1080,2 @@ _htOption.height -= _htOption.titleHeight;

var nCount = oQRCode.getModuleCount();

@@ -1087,12 +1085,34 @@ var nWidth = Math.round(_htOption.width / nCount);

this._htOption.width = nWidth * nCount;
_htOption.quietZone = Math.round(_htOption.quietZone);
this._htOption.width = nWidth * nCount;
this._htOption.height = nHeight * nCount + _htOption.titleHeight;
this._htOption.quietZone = Math.round(this._htOption.quietZone);
this._canvas.width = this._htOption.width + this._htOption.quietZone * 2;
this._canvas.height = this._htOption.height + this._htOption.quietZone * 2;
this._htOption.autoColor=true;
var autoColorDark="rgba(0, 0, 0, .6)";
var autoColorLight="rgba(255, 255, 255, .7)";
var notAutoColorLight="rgba(0,0,0,0)";
// JPG
if(_htOption.format=='JPG' ){
if( _htOption.quietZoneColor=='transparent'){
_htOption.quietZoneColor='#ffffff';
}
_htOption.logoBackgroundTransparent=false;
autoColorDark= _htOption.colorDark;
autoColorLight= _htOption.colorLight;
notAutoColorLight=_htOption.colorLight;
_oContext.fillStyle = "#ffffff";
_oContext.fillRect(0, 0, this._canvas.width, this._canvas.height);
}
var t = this;

@@ -1104,2 +1124,3 @@

_oContext.fillStyle = _htOption.quietZoneColor;
_oContext.fillRect(0, 0, t._canvas.width, _htOption.quietZone);

@@ -1134,5 +1155,3 @@ // left

function drawQrcode(oQRCode) {
if(_htOption.quietZone>0 && _htOption.quietZoneColor){
drawQuietZoneColor();
}
for (var row = 0; row < nCount; row++) {

@@ -1188,13 +1207,15 @@ for (var col = 0; col < nCount; col++) {

if (_htOption.autoColor) {
_oContext.strokeStyle = bIsDark ? "rgba(0, 0, 0, .6)" : "rgba(255, 255, 255, .7)";
_oContext.fillStyle = bIsDark ? "rgba(0, 0, 0, .6)" : "rgba(255, 255, 255, .7)";
_oContext.strokeStyle = bIsDark ? autoColorDark : autoColorLight;
_oContext.fillStyle = bIsDark ? autoColorDark : autoColorLight;
} else {
_oContext.strokeStyle = bIsDark ? _htOption.colorDark : "rgba(0,0,0,0)";
_oContext.fillStyle = bIsDark ? _htOption.colorDark : "rgba(0,0,0,0)";
// _oContext.strokeStyle = bIsDark ? _htOption.colorDark : notAutoColorLight;
_oContext.fillStyle = bIsDark ? _htOption.colorDark : notAutoColorLight;
_oContext.strokeStyle = _oContext.fillStyle;
}
_oContext.fillRect(nLeft + nWidth * (1 - nowDotScale) / 2, _htOption.titleHeight + nTop + nHeight * (1 -
nowDotScale) / 2, nWidth * nowDotScale, nHeight * nowDotScale);
_oContext.fillRect(nLeft + nWidth * (1 - nowDotScale) / 2, _htOption.titleHeight + nTop + nHeight * (1 -
nowDotScale) / 2, nWidth * nowDotScale, nHeight * nowDotScale);
} else {
_oContext.strokeStyle = _oContext.fillStyle;
_oContext.fillRect(nLeft + nWidth * (1 - nowDotScale) / 2, _htOption.titleHeight + nTop + nHeight * (1 -

@@ -1216,3 +1237,3 @@ nowDotScale) / 2, nWidth * nowDotScale, nHeight * nowDotScale);

_oContext.fillStyle = _htOption.titleBackgroundColor;
_oContext.fillRect(0, 0, t._canvas.width, _htOption.titleHeight);
_oContext.fillRect(0, 0, t._canvas.width, _htOption.titleHeight+this._htOption.quietZone);

@@ -1222,3 +1243,3 @@ _oContext.font = _htOption.titleFont;

_oContext.textAlign = 'center';
_oContext.fillText(_htOption.title, t._canvas.width / 2, 30);
_oContext.fillText(_htOption.title, t._canvas.width / 2, this._htOption.quietZone+30);
}

@@ -1229,7 +1250,5 @@

_oContext.fillStyle = _htOption.subTitleColor;
_oContext.fillText(_htOption.subTitle, t._canvas.width / 2, 60);
_oContext.fillText(_htOption.subTitle, t._canvas.width / 2, this._htOption.quietZone+60);
}
if (_htOption.logo) {

@@ -1270,3 +1289,7 @@ var img = new Image();

_this._bIsPainted = true;
if(_htOption.quietZone>0 && _htOption.quietZoneColor){
drawQuietZoneColor();
}
_this.makeImage();

@@ -1284,4 +1307,2 @@ }

if (img.complete) {

@@ -1295,8 +1316,10 @@ img.onload = null;

this._bIsPainted = true;
if(_htOption.quietZone>0 && _htOption.quietZoneColor){
drawQuietZoneColor();
}
this.makeImage();
}
}

@@ -1310,2 +1333,3 @@

Drawing.prototype.makeImage = function() {
var makeOptions = this.makeOptions;

@@ -1317,9 +1341,20 @@ var t=this;

if (this._htOption.onRenderingStart) {
this._htOption.onRenderingStart();
this._htOption.onRenderingStart(this._htOption);
}
var out = fs.createWriteStream(makeOptions.path)
var stream = this._canvas.createPNGStream({
compressionLevel: makeOptions.compressionLevel
})
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
})
}

@@ -1332,13 +1367,21 @@ stream.pipe(out);

} else if (makeOptions.makeType == 'URL') {
if (this._htOption.onRenderingStart) {
this._htOption.onRenderingStart();
this._htOption.onRenderingStart(this._htOption);
}
// dataUrl = this._canvas.toDataURL()
this._canvas.toDataURL((err, data) => {
t.resolve(data);
}) // defaults to PNG
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);
})
}
}

@@ -1427,4 +1470,8 @@

// ==== Event Handler
onRenderingStart: undefined
onRenderingStart: undefined,
// ==== Images format
format: 'PNG', // 'PNG', 'JPG'
compressionLevel: 6, // ZLIB compression level (0-9). default is 6
quality: 0.75 // An object specifying the quality (0 to 1). default is 0.75. (JPGs only)
};

@@ -1443,3 +1490,19 @@ if (typeof vOption === 'string') {

}
this._htOption.format=this._htOption.format.toUpperCase();
if(this._htOption.format!='PNG' && this._htOption.format!='JPG'){
console.warn("Image format '"+this._htOption.format+"' is invalidate, reset to 'PNG'")
this._htOption.format='PNG';
}
if (this._htOption.format=='PNG' && (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;
}else if(this._htOption.quality < 0 || this._htOption.quality > 1) {
console.warn(this._htOption.compressionLevel +
" is invalidate, JPG quality must between 0 and 1, now reset to 0.75. ")
this._htOption.quality = 0.75;
}
if (this._htOption.dotScale < 0 || this._htOption.dotScale > 1) {

@@ -1473,14 +1536,6 @@ console.warn(this._htOption.dotScale +

makeType: 'FILE',
path: null,
compressionLevel: 6 // ZLIB compression level between 0 and 9
path: null
}
saveOptions = Object.assign(defOptions, saveOptions);
if (saveOptions.compressionLevel < 0 || saveOptions.compressionLevel > 9) {
console.warn(saveOptions.compressionLevel +
" is invalidate, compressionLevel must between 0 and 9, now reset to 6. ")
saveOptions.compressionLevel = 1;
}
saveOptions = Object.assign(defOptions, saveOptions);
var _oDrawing = new Drawing(this._htOption);

@@ -1505,3 +1560,3 @@ _oDrawing.makeOptions = saveOptions;

*/
QRCode.prototype.toDataURL = function() {
QRCode.prototype.toDataURL = function(format) {

@@ -1508,0 +1563,0 @@ var defOptions = {

@@ -6,3 +6,3 @@ /**

*
* Version 3.3.0
* Version 3.4.0
*

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

*/
"use strict";function QR8bitByte(t){this.mode=QRMode.MODE_8BIT_BYTE,this.data=t,this.parsedData=[];for(var e=0,o=this.data.length;e<o;e++){var r=[],i=this.data.charCodeAt(e);i>65536?(r[0]=240|(1835008&i)>>>18,r[1]=128|(258048&i)>>>12,r[2]=128|(4032&i)>>>6,r[3]=128|63&i):i>2048?(r[0]=224|(61440&i)>>>12,r[1]=128|(4032&i)>>>6,r[2]=128|63&i):i>128?(r[0]=192|(1984&i)>>>6,r[1]=128|63&i):r[0]=i,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=[]}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 r=0;r<t.length-o;r++)this.num[r]=t[r+o]}function QRRSBlock(t,e){this.totalCount=t,this.dataCount=e}function QRBitBuffer(){this.buffer=[],this.length=0}function _getTypeNumber(t,e){for(var o=1,r=_getUTF8Length(t),i=0,n=QRCodeLimitLength.length;i<=n;i++){var a=0;switch(e){case QRErrorCorrectLevel.L:a=QRCodeLimitLength[i][0];break;case QRErrorCorrectLevel.M:a=QRCodeLimitLength[i][1];break;case QRErrorCorrectLevel.Q:a=QRCodeLimitLength[i][2];break;case QRErrorCorrectLevel.H:a=QRCodeLimitLength[i][3]}if(r<=a)break;o++}if(o>QRCodeLimitLength.length)throw new Error("Too long data");return o}function _getUTF8Length(t){var e=encodeURI(t).toString().replace(/\%[0-9a-fA-F]{2}/g,"a");return e.length+(e.length!=t?3:0)}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:0,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},"string"==typeof t&&(t={text:t}),t)for(var e in t)this._htOption[e]=t[e];(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.correctLevel),this._htOption.correctLevel),this._oQRCode.addData(this._htOption.text),this._oQRCode.make()}var _require=require("canvas"),createCanvas=_require.createCanvas,loadImage=_require.loadImage,Image=_require.Image,fs=require("fs");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){var e=new QR8bitByte(t);this.dataList.push(e),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 r="P"+o[1]+"_"+o[2];return"A"==o[2]&&(r="A"+o[1]),{isDarkBlock:o[0],type:r}}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 r=0;r<this.moduleCount;r++)this.modules[o][r]=[]}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 r=-1;r<=7;r++)if(!(t+r<=-1||this.moduleCount<=t+r))for(var i=-1;i<=7;i++)e+i<=-1||this.moduleCount<=e+i||(0<=r&&r<=6&&(0==i||6==i)||0<=i&&i<=6&&(0==r||6==r)||2<=r&&r<=4&&2<=i&&i<=4?(this.modules[t+r][e+i][0]=!0,this.modules[t+r][e+i][2]=o,this.modules[t+r][e+i][1]=-0==r||-0==i||6==r||6==i?"O":"I"):this.modules[t+r][e+i][0]=!1)},getBestMaskPattern:function(){for(var t=0,e=0,o=0;o<8;o++){this.makeImpl(!0,o);var r=QRUtil.getLostPoint(this);(0==o||t>r)&&(t=r,e=o)}return e},createMovieClip:function(t,e,o){var r=t.createEmptyMovieClip(e,o);this.make();for(var i=0;i<this.modules.length;i++)for(var n=1*i,a=0;a<this.modules[i].length;a++){var l=1*a,s=this.modules[i][a][0];s&&(r.beginFill(0,100),r.moveTo(l,n),r.lineTo(l+1,n),r.lineTo(l+1,n+1),r.lineTo(l,n+1),r.endFill())}return r},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 r=0;r<e.length;r++){var i=e[o],n=e[r];if(null==this.modules[i][n][0])for(var a=-2;a<=2;a++)for(var l=-2;l<=2;l++)-2==a||2==a||-2==l||2==l||0==a&&0==l?(this.modules[i+a][n+l][0]=!0,this.modules[i+a][n+l][2]=t,this.modules[i+a][n+l][1]=-2==a||-2==l||2==a||2==l?"O":"I"):this.modules[i+a][n+l][0]=!1}},setupTypeNumber:function(t){for(var e=QRUtil.getBCHTypeNumber(this.typeNumber),o=0;o<18;o++){var r=!t&&1==(e>>o&1);this.modules[Math.floor(o/3)][o%3+this.moduleCount-8-3][0]=r}for(var o=0;o<18;o++){var r=!t&&1==(e>>o&1);this.modules[o%3+this.moduleCount-8-3][Math.floor(o/3)][0]=r}},setupTypeInfo:function(t,e){for(var o=this.errorCorrectLevel<<3|e,r=QRUtil.getBCHTypeInfo(o),i=0;i<15;i++){var n=!t&&1==(r>>i&1);i<6?this.modules[i][8][0]=n:i<8?this.modules[i+1][8][0]=n:this.modules[this.moduleCount-15+i][8][0]=n}for(var i=0;i<15;i++){var n=!t&&1==(r>>i&1);i<8?this.modules[8][this.moduleCount-i-1][0]=n:i<9?this.modules[8][15-i-1+1][0]=n:this.modules[8][15-i-1][0]=n}this.modules[this.moduleCount-8][8][0]=!t},mapData:function(t,e){for(var o=-1,r=this.moduleCount-1,i=7,n=0,a=this.moduleCount-1;a>0;a-=2)for(6==a&&a--;;){for(var l=0;l<2;l++)if(null==this.modules[r][a-l][0]){var s=!1;n<t.length&&(s=1==(t[n]>>>i&1));var h=QRUtil.getMask(e,r,a-l);h&&(s=!s),this.modules[r][a-l][0]=s,i--,-1==i&&(n++,i=7)}if((r+=o)<0||this.moduleCount<=r){r-=o,o=-o;break}}}},QRCodeModel.PAD0=236,QRCodeModel.PAD1=17,QRCodeModel.createData=function(t,e,o){for(var r=QRRSBlock.getRSBlocks(t,e),i=new QRBitBuffer,n=0;n<o.length;n++){var a=o[n];i.put(a.mode,4),i.put(a.getLength(),QRUtil.getLengthInBits(a.mode,t)),a.write(i)}for(var l=0,n=0;n<r.length;n++)l+=r[n].dataCount;if(i.getLengthInBits()>8*l)throw new Error("code length overflow. ("+i.getLengthInBits()+">"+8*l+")");for(i.getLengthInBits()+4<=8*l&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(!1);for(;;){if(i.getLengthInBits()>=8*l)break;if(i.put(QRCodeModel.PAD0,8),i.getLengthInBits()>=8*l)break;i.put(QRCodeModel.PAD1,8)}return QRCodeModel.createBytes(i,r)},QRCodeModel.createBytes=function(t,e){for(var o=0,r=0,i=0,n=new Array(e.length),a=new Array(e.length),l=0;l<e.length;l++){var s=e[l].dataCount,h=e[l].totalCount-s;r=Math.max(r,s),i=Math.max(i,h),n[l]=new Array(s);for(var u=0;u<n[l].length;u++)n[l][u]=255&t.buffer[u+o];o+=s;var g=QRUtil.getErrorCorrectPolynomial(h),d=new QRPolynomial(n[l],g.getLength()-1),c=d.mod(g);a[l]=new Array(g.getLength()-1);for(var u=0;u<a[l].length;u++){var f=u+c.getLength()-a[l].length;a[l][u]=f>=0?c.get(f):0}}for(var R=0,u=0;u<e.length;u++)R+=e[u].totalCount;for(var v=new Array(R),m=0,u=0;u<r;u++)for(var l=0;l<e.length;l++)u<n[l].length&&(v[m++]=n[l][u]);for(var u=0;u<i;u++)for(var l=0;l<e.length;l++)u<a[l].length&&(v[m++]=a[l][u]);return v};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,r=0;r<e;r++)for(var i=0;i<e;i++){for(var n=0,a=t.isDark(r,i),l=-1;l<=1;l++)if(!(r+l<0||e<=r+l))for(var s=-1;s<=1;s++)i+s<0||e<=i+s||0==l&&0==s||a==t.isDark(r+l,i+s)&&n++;n>5&&(o+=3+n-5)}for(var r=0;r<e-1;r++)for(var i=0;i<e-1;i++){var h=0;t.isDark(r,i)&&h++,t.isDark(r+1,i)&&h++,t.isDark(r,i+1)&&h++,t.isDark(r+1,i+1)&&h++,0!=h&&4!=h||(o+=3)}for(var r=0;r<e;r++)for(var i=0;i<e-6;i++)t.isDark(r,i)&&!t.isDark(r,i+1)&&t.isDark(r,i+2)&&t.isDark(r,i+3)&&t.isDark(r,i+4)&&!t.isDark(r,i+5)&&t.isDark(r,i+6)&&(o+=40);for(var i=0;i<e;i++)for(var r=0;r<e-6;r++)t.isDark(r,i)&&!t.isDark(r+1,i)&&t.isDark(r+2,i)&&t.isDark(r+3,i)&&t.isDark(r+4,i)&&!t.isDark(r+5,i)&&t.isDark(r+6,i)&&(o+=40);for(var u=0,i=0;i<e;i++)for(var r=0;r<e;r++)t.isDark(r,i)&&u++;return o+=Math.abs(100*u/e/e-50)/5*10}},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(var 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(var i=0;i<255;i++)QRMath.LOG_TABLE[QRMath.EXP_TABLE[i]]=i;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 r=0;r<t.getLength();r++)e[o+r]^=QRMath.gexp(QRMath.glog(this.get(o))+QRMath.glog(t.get(r)));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()),r=0;r<this.getLength();r++)o[r]=this.get(r);for(var r=0;r<t.getLength();r++)o[r]^=QRMath.gexp(QRMath.glog(t.get(r))+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],[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 r=o.length/3,i=[],n=0;n<r;n++)for(var a=o[3*n+0],l=o[3*n+1],s=o[3*n+2],h=0;h<a;h++)i.push(new QRRSBlock(l,s));return i},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]],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._bIsPainted=!1,this._bSupportDataURI=null};Drawing.prototype.draw=function(t){function e(){r.lineWidth=0,r.fillStyle=i.quietZoneColor,r.fillRect(0,0,s._canvas.width,i.quietZone),r.fillRect(0,i.quietZone,i.quietZone,s._canvas.height-2*i.quietZone),r.fillRect(s._canvas.width-i.quietZone,i.quietZone,i.quietZone,s._canvas.height-2*i.quietZone),r.fillRect(0,s._canvas.height-i.quietZone,s._canvas.width,i.quietZone)}function o(t){i.quietZone>0&&i.quietZoneColor&&e();for(var o=0;o<n;o++)for(var h=0;h<n;h++){var u=h*a+i.quietZone,g=o*l+i.quietZone,d=t.isDark(o,h),c=t.getEye(o,h);if(c){d=c.isDarkBlock;var f=c.type,R=i[f]||i[f.substring(0,2)]||i.colorDark;r.lineWidth=0,r.strokeStyle=d?R:i.colorLight,r.fillStyle=d?R:i.colorLight,r.fillRect(u,i.titleHeight+g,a,l)}else{r.lineWidth=0,r.strokeStyle=d?i.colorDark:i.colorLight,r.fillStyle=d?i.colorDark:i.colorLight;var v=i.dotScale;if(6==o){v=1;var m=i.timing_H||i.timing||i.colorDark;r.fillStyle=d?m:i.colorLight,r.strokeStyle=r.fillStyle,r.fillRect(u+a*(1-v)/2,i.titleHeight+g+l*(1-v)/2,a*v,l*v)}else if(6==h){v=1;var p=i.timing_V||i.timing||i.colorDark;r.fillStyle=d?p:i.colorLight,r.strokeStyle=r.fillStyle,r.fillRect(u+a*(1-v)/2,i.titleHeight+g+l*(1-v)/2,a*v,l*v)}else i.backgroundImage?(i.autoColor?(r.strokeStyle=d?"rgba(0, 0, 0, .6)":"rgba(255, 255, 255, .7)",r.fillStyle=d?"rgba(0, 0, 0, .6)":"rgba(255, 255, 255, .7)"):(r.strokeStyle=d?i.colorDark:"rgba(0,0,0,0)",r.fillStyle=d?i.colorDark:"rgba(0,0,0,0)",r.strokeStyle=r.fillStyle),r.fillRect(u+a*(1-v)/2,i.titleHeight+g+l*(1-v)/2,a*v,l*v)):(r.strokeStyle=r.fillStyle,r.fillRect(u+a*(1-v)/2,i.titleHeight+g+l*(1-v)/2,a*v,l*v))}1==i.dotScale||c||(r.strokeStyle=i.colorLight)}if(i.title&&(r.fillStyle=i.titleBackgroundColor,r.fillRect(0,0,s._canvas.width,i.titleHeight),r.font=i.titleFont,r.fillStyle=i.titleColor,r.textAlign="center",r.fillText(i.title,s._canvas.width/2,30)),i.subTitle&&(r.font=i.subTitleFont,r.fillStyle=i.subTitleColor,r.fillText(i.subTitle,s._canvas.width/2,60)),i.logo){var _=function(){var t=Math.round(i.width/3.5),e=Math.round(i.height/3.5);t!=e&&(t=e),i.logoWidth&&(t=Math.round(i.logoWidth)),i.logoHeight&&(e=Math.round(i.logoHeight)),i.logoBackgroundTransparent||(r.fillStyle=i.logoBackgroundColor,r.fillRect((i.width+2*i.quietZone-t)/2,(i.height+i.titleHeight+2*i.quietZone-e)/2,t,t)),r.drawImage(Q,(i.width+2*i.quietZone-t)/2,(i.height+i.titleHeight+2*i.quietZone-e)/2,t,e),C._bIsPainted=!0,C.makeImage()},Q=new Image;Q.src=i.logo;var C=this;if(Q.onload=function(){_()},Q.onerror=function(t){console.error(t)},Q.complete)return Q.onload=null,void _()}else this._bIsPainted=!0,this.makeImage()}var r=this._oContext,i=this._htOption;i.title||i.subTitle||(i.height-=i.titleHeight,i.titleHeight=0);var n=t.getModuleCount(),a=Math.round(i.width/n),l=Math.round((i.height-i.titleHeight)/n);this._htOption.width=a*n,this._htOption.height=l*n+i.titleHeight,this._htOption.quietZone=Math.round(this._htOption.quietZone),this._canvas.width=this._htOption.width+2*this._htOption.quietZone,this._canvas.height=this._htOption.height+2*this._htOption.quietZone;var s=this;if(i.backgroundImage){var h=new Image;h.onload=function(){r.globalAlpha=1,r.globalAlpha=i.backgroundImageAlpha,r.drawImage(h,0,i.titleHeight,i.width+2*i.quietZone,i.height+2*i.quietZone-i.titleHeight),r.globalAlpha=1,o.call(s,t)},h.src=i.backgroundImage}else o.call(s,t)},Drawing.prototype.makeImage=function(){var t=this.makeOptions,e=this;if("FILE"==t.makeType){this._htOption.onRenderingStart&&this._htOption.onRenderingStart();var o=fs.createWriteStream(t.path);this._canvas.createPNGStream({compressionLevel:t.compressionLevel}).pipe(o),o.on("finish",function(){e.resolve({})})}else"URL"==t.makeType&&(this._htOption.onRenderingStart&&this._htOption.onRenderingStart(),this._canvas.toDataURL(function(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){var e={makeType:"FILE",path:null,compressionLevel:6};t=Object.assign(e,t),(t.compressionLevel<0||t.compressionLevel>9)&&(console.warn(t.compressionLevel+" is invalidate, compressionLevel must between 0 and 9, now reset to 6. "),t.compressionLevel=1);var o=new Drawing(this._htOption);o.makeOptions=t;try{var r=this;return new Promise(function(t){o.resolve=t,o.draw(r._oQRCode)})}catch(t){console.error(t)}},QRCode.prototype.toDataURL=function(){var t={makeType:"URL"},e=new Drawing(this._htOption);e.makeOptions=t;try{var o=this;return new Promise(function(t){e.resolve=t,e.draw(o._oQRCode)})}catch(t){console.error(t)}},QRCode.CorrectLevel=QRErrorCorrectLevel,module.exports=QRCode;
"use strict";function QR8bitByte(t){this.mode=QRMode.MODE_8BIT_BYTE,this.data=t,this.parsedData=[];for(var e=0,o=this.data.length;e<o;e++){var i=[],r=this.data.charCodeAt(e);r>65536?(i[0]=240|(1835008&r)>>>18,i[1]=128|(258048&r)>>>12,i[2]=128|(4032&r)>>>6,i[3]=128|63&r):r>2048?(i[0]=224|(61440&r)>>>12,i[1]=128|(4032&r)>>>6,i[2]=128|63&r):r>128?(i[0]=192|(1984&r)>>>6,i[1]=128|63&r):i[0]=r,this.parsedData.push(i)}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=[]}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}function _getTypeNumber(t,e){for(var o=1,i=_getUTF8Length(t),r=0,n=QRCodeLimitLength.length;r<=n;r++){var a=0;switch(e){case QRErrorCorrectLevel.L:a=QRCodeLimitLength[r][0];break;case QRErrorCorrectLevel.M:a=QRCodeLimitLength[r][1];break;case QRErrorCorrectLevel.Q:a=QRCodeLimitLength[r][2];break;case QRErrorCorrectLevel.H:a=QRCodeLimitLength[r][3]}if(i<=a)break;o++}if(o>QRCodeLimitLength.length)throw new Error("Too long data");return o}function _getUTF8Length(t){var e=encodeURI(t).toString().replace(/\%[0-9a-fA-F]{2}/g,"a");return e.length+(e.length!=t?3:0)}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:0,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},"string"==typeof t&&(t={text:t}),t)for(var e in t)this._htOption[e]=t[e];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.compressionLevel+" 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.correctLevel),this._htOption.correctLevel),this._oQRCode.addData(this._htOption.text),this._oQRCode.make()}var _require=require("canvas"),createCanvas=_require.createCanvas,loadImage=_require.loadImage,Image=_require.Image,fs=require("fs");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){var e=new QR8bitByte(t);this.dataList.push(e),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 l=1*a,s=this.modules[r][a][0];s&&(i.beginFill(0,100),i.moveTo(l,n),i.lineTo(l+1,n),i.lineTo(l+1,n+1),i.lineTo(l,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 l=-2;l<=2;l++)-2==a||2==a||-2==l||2==l||0==a&&0==l?(this.modules[r+a][n+l][0]=!0,this.modules[r+a][n+l][2]=t,this.modules[r+a][n+l][1]=-2==a||-2==l||2==a||2==l?"O":"I"):this.modules[r+a][n+l][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(var o=0;o<18;o++){var 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(var r=0;r<15;r++){var 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 l=0;l<2;l++)if(null==this.modules[i][a-l][0]){var s=!1;n<t.length&&(s=1==(t[n]>>>r&1));var h=QRUtil.getMask(e,i,a-l);h&&(s=!s),this.modules[i][a-l][0]=s,r--,-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)}for(var l=0,n=0;n<i.length;n++)l+=i[n].dataCount;if(r.getLengthInBits()>8*l)throw new Error("code length overflow. ("+r.getLengthInBits()+">"+8*l+")");for(r.getLengthInBits()+4<=8*l&&r.put(0,4);r.getLengthInBits()%8!=0;)r.putBit(!1);for(;;){if(r.getLengthInBits()>=8*l)break;if(r.put(QRCodeModel.PAD0,8),r.getLengthInBits()>=8*l)break;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),l=0;l<e.length;l++){var s=e[l].dataCount,h=e[l].totalCount-s;i=Math.max(i,s),r=Math.max(r,h),n[l]=new Array(s);for(var u=0;u<n[l].length;u++)n[l][u]=255&t.buffer[u+o];o+=s;var g=QRUtil.getErrorCorrectPolynomial(h),d=new QRPolynomial(n[l],g.getLength()-1),f=d.mod(g);a[l]=new Array(g.getLength()-1);for(var u=0;u<a[l].length;u++){var c=u+f.getLength()-a[l].length;a[l][u]=c>=0?f.get(c):0}}for(var p=0,u=0;u<e.length;u++)p+=e[u].totalCount;for(var R=new Array(p),v=0,u=0;u<i;u++)for(var l=0;l<e.length;l++)u<n[l].length&&(R[v++]=n[l][u]);for(var u=0;u<r;u++)for(var l=0;l<e.length;l++)u<a[l].length&&(R[v++]=a[l][u]);return R};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),l=-1;l<=1;l++)if(!(i+l<0||e<=i+l))for(var s=-1;s<=1;s++)r+s<0||e<=r+s||0==l&&0==s||a==t.isDark(i+l,r+s)&&n++;n>5&&(o+=3+n-5)}for(var i=0;i<e-1;i++)for(var r=0;r<e-1;r++){var h=0;t.isDark(i,r)&&h++,t.isDark(i+1,r)&&h++,t.isDark(i,r+1)&&h++,t.isDark(i+1,r+1)&&h++,0!=h&&4!=h||(o+=3)}for(var i=0;i<e;i++)for(var 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(var r=0;r<e;r++)for(var 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);for(var u=0,r=0;r<e;r++)for(var i=0;i<e;i++)t.isDark(i,r)&&u++;return o+=Math.abs(100*u/e/e-50)/5*10}},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(var 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(var i=0;i<255;i++)QRMath.LOG_TABLE[QRMath.EXP_TABLE[i]]=i;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(var 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],[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],l=o[3*n+1],s=o[3*n+2],h=0;h<a;h++)r.push(new QRRSBlock(l,s));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]],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._bIsPainted=!1,this._bSupportDataURI=null};Drawing.prototype.draw=function(t){function e(){i.lineWidth=0,i.fillStyle=r.quietZoneColor,i.fillRect(0,0,g._canvas.width,r.quietZone),i.fillRect(0,r.quietZone,r.quietZone,g._canvas.height-2*r.quietZone),i.fillRect(g._canvas.width-r.quietZone,r.quietZone,r.quietZone,g._canvas.height-2*r.quietZone),i.fillRect(0,g._canvas.height-r.quietZone,g._canvas.width,r.quietZone)}function o(t){for(var o=0;o<n;o++)for(var d=0;d<n;d++){var f=d*a+r.quietZone,c=o*l+r.quietZone,p=t.isDark(o,d),R=t.getEye(o,d);if(R){p=R.isDarkBlock;var v=R.type,m=r[v]||r[v.substring(0,2)]||r.colorDark;i.lineWidth=0,i.strokeStyle=p?m:r.colorLight,i.fillStyle=p?m:r.colorLight,i.fillRect(f,r.titleHeight+c,a,l)}else{i.lineWidth=0,i.strokeStyle=p?r.colorDark:r.colorLight,i.fillStyle=p?r.colorDark:r.colorLight;var _=r.dotScale;if(6==o){_=1;var C=r.timing_H||r.timing||r.colorDark;i.fillStyle=p?C:r.colorLight,i.strokeStyle=i.fillStyle,i.fillRect(f+a*(1-_)/2,r.titleHeight+c+l*(1-_)/2,a*_,l*_)}else if(6==d){_=1;var Q=r.timing_V||r.timing||r.colorDark;i.fillStyle=p?Q:r.colorLight,i.strokeStyle=i.fillStyle,i.fillRect(f+a*(1-_)/2,r.titleHeight+c+l*(1-_)/2,a*_,l*_)}else r.backgroundImage?(r.autoColor?(i.strokeStyle=p?s:h,i.fillStyle=p?s:h):(i.fillStyle=p?r.colorDark:u,i.strokeStyle=i.fillStyle),i.fillRect(f+a*(1-_)/2,r.titleHeight+c+l*(1-_)/2,a*_,l*_)):(i.strokeStyle=i.fillStyle,i.fillRect(f+a*(1-_)/2,r.titleHeight+c+l*(1-_)/2,a*_,l*_))}1==r.dotScale||R||(i.strokeStyle=r.colorLight)}if(r.title&&(i.fillStyle=r.titleBackgroundColor,i.fillRect(0,0,g._canvas.width,r.titleHeight+this._htOption.quietZone),i.font=r.titleFont,i.fillStyle=r.titleColor,i.textAlign="center",i.fillText(r.title,g._canvas.width/2,this._htOption.quietZone+30)),r.subTitle&&(i.font=r.subTitleFont,i.fillStyle=r.subTitleColor,i.fillText(r.subTitle,g._canvas.width/2,this._htOption.quietZone+60)),r.logo){var L=function(){var t=Math.round(r.width/3.5),o=Math.round(r.height/3.5);t!=o&&(t=o),r.logoWidth&&(t=Math.round(r.logoWidth)),r.logoHeight&&(o=Math.round(r.logoHeight)),r.logoBackgroundTransparent||(i.fillStyle=r.logoBackgroundColor,i.fillRect((r.width+2*r.quietZone-t)/2,(r.height+r.titleHeight+2*r.quietZone-o)/2,t,t)),i.drawImage(k,(r.width+2*r.quietZone-t)/2,(r.height+r.titleHeight+2*r.quietZone-o)/2,t,o),T._bIsPainted=!0,r.quietZone>0&&r.quietZoneColor&&e(),T.makeImage()},k=new Image;k.src=r.logo;var T=this;if(k.onload=function(){L()},k.onerror=function(t){console.error(t)},k.complete)return k.onload=null,void L()}else this._bIsPainted=!0,r.quietZone>0&&r.quietZoneColor&&e(),this.makeImage()}var i=this._oContext,r=this._htOption;r.title||r.subTitle||(r.height-=r.titleHeight,r.titleHeight=0);var n=t.getModuleCount(),a=Math.round(r.width/n),l=Math.round((r.height-r.titleHeight)/n);r.quietZone=Math.round(r.quietZone),this._htOption.width=a*n,this._htOption.height=l*n+r.titleHeight,this._canvas.width=this._htOption.width+2*this._htOption.quietZone,this._canvas.height=this._htOption.height+2*this._htOption.quietZone,this._htOption.autoColor=!0;var s="rgba(0, 0, 0, .6)",h="rgba(255, 255, 255, .7)",u="rgba(0,0,0,0)";"JPG"==r.format&&("transparent"==r.quietZoneColor&&(r.quietZoneColor="#ffffff"),r.logoBackgroundTransparent=!1,s=r.colorDark,h=r.colorLight,u=r.colorLight,i.fillStyle="#ffffff",i.fillRect(0,0,this._canvas.width,this._canvas.height));var g=this;if(r.backgroundImage){var d=new Image;d.onload=function(){i.globalAlpha=1,i.globalAlpha=r.backgroundImageAlpha,i.drawImage(d,0,r.titleHeight,r.width+2*r.quietZone,r.height+2*r.quietZone-r.titleHeight),i.globalAlpha=1,o.call(g,t)},d.src=r.backgroundImage}else o.call(g,t)},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),i=void 0;i="PNG"==this._htOption.format?this._canvas.createPNGStream({compressionLevel:this._htOption.compressionLevel}):this._canvas.createJPEGStream({quality:this._htOption.quality}),i.pipe(o),o.on("finish",function(){e.resolve({})})}else"URL"==t.makeType&&(this._htOption.onRenderingStart&&this._htOption.onRenderingStart(this._htOption),"PNG"==this._htOption.format?this._canvas.toDataURL(function(t,o){e.resolve(o)}):this._canvas.toDataURL("image/jpeg",function(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){var e={makeType:"FILE",path:null};t=Object.assign(e,t);var o=new Drawing(this._htOption);o.makeOptions=t;try{var i=this;return new Promise(function(t){o.resolve=t,o.draw(i._oQRCode)})}catch(t){console.error(t)}},QRCode.prototype.toDataURL=function(t){var e={makeType:"URL"},o=new Drawing(this._htOption);o.makeOptions=e;try{var i=this;return new Promise(function(t){o.resolve=t,o.draw(i._oQRCode)})}catch(t){console.error(t)}},QRCode.CorrectLevel=QRErrorCorrectLevel,module.exports=QRCode;
{
"name": "easyqrcodejs-nodejs",
"version": "3.3.0",
"version": "3.4.0",
"description": "NodeJS QRCode generator. Support Dot style, Logo, Background image, Colorful, Title, etc.",

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

@@ -198,75 +198,83 @@ # EasyQRCodeJS-NodeJS

/*
onRenderingStart: undefined
onRenderingStart: undefined,
*/
// ==== Images format
/*
format: 'PNG', // 'PNG', 'JPG'
compressionLevel: 6, // ZLIB compression level (0-9). default is 6
quality: 0.75 // An object specifying the quality (0 to 1). default is 0.75. (JPGs only)
*/
}
```
| Option | Required | Type | Defaults | Description | Compatibility |
| --- | --- |--- | --- |--- | --- |
| Basic options| --- | ---|---|---|---|
| **text** | Y | String |`''` | Text | &nbsp; |
| **width** | N | Number | `256` | Width | &nbsp; |
| **height** | N | Number | `256` | Height | &nbsp; |
| **colorDark** | N | String | `#000000` | Dark CSS color | &nbsp; |
| **colorLight** | N | String | `#ffffff` | Light CSS color | &nbsp; |
| **correctLevel** | N | Enum | `QRCode.CorrectLevel.H` | `QRCode.CorrectLevel.H`<br/>`QRCode.CorrectLevel.Q` <br/> `QRCode.CorrectLevel.M` <br/> `QRCode.CorrectLevel.L`| &nbsp; |
| **dotScale** | N | Number | `1.0` |Dot style required Patterns. Ranges: `0-1.0` | &nbsp; |
| Quiet Zone| --- | ---|---|---|---|
| **quietZone** | N | Number | `0` | Quiet Zone size | &nbsp; |
| **quietZoneColor** | N | String | `transparent` | Background CSS color to Quiet Zone | &nbsp; |
| Logo options| --- | ---|---|---|---|
| **logo** | N | String | `undefined` | Logo Image Path. If use relative address, relative to `easy.qrcode.min.js` | &nbsp; |
| **logoWidth** | N | Number | `undefined` | Height | &nbsp; |
| **logoHeight** | N | Number | `undefined` | Width | &nbsp; |
| **logoBackgroundTransparent** | N | Boolean | `false` | Whether the background transparent image(`PNG`) shows transparency. When `true`, `logoBackgroundColor` is invalid | &nbsp; |
| **logoBackgroundColor** | N | String | `#ffffff` | Set Background CSS Color when image background transparent. Valid when `logoBackgroundTransparent` is `false` | &nbsp; |
| Backgroud Image options| ---|--- |---|---|---|
| **backgroundImage** | N | String | `undefined` | Background Image Path. If use relative address, relative to `easy.qrcode.min.js` | &nbsp; |
| **backgroundImageAlpha** | N | Number | `1.0` | Background image transparency. Ranges: `0-1.0` | &nbsp; |
| **autoColor** | N | Boolean | `false` | Automatic color adjustment | &nbsp; |
| Posotion Pattern Color options| --- | ---|---|---|---|
| **PO** | N | String | `undefined` | Global Posotion Outer CSS color. if not set, the defaut is `colorDark` | &nbsp; |
| **PI** | N | String | `undefined` | Global Posotion Inner CSS color. if not set, the defaut is `colorDark` | &nbsp; |
| **PO_TL** | N | String | `undefined` | Posotion Outer CSS color - Top Left | &nbsp; |
| **PI_TL** | N | String | `undefined` | Posotion Inner CSS color - Top Left | &nbsp; |
| **PO_TR** | N | String | `undefined` | Posotion Outer CSS color - Top Right | &nbsp; |
| **PI_TR** | N | String | `undefined` | Posotion Inner CSS color - Top Right | &nbsp; |
| **PO_BL** | N | String | `undefined` | Posotion Outer CSS color - Bottom Left | &nbsp; |
| **PI_BL** | N | String | `undefined` | Posotion Inner CSS color - Bottom Left | &nbsp; |
| Alignment Color options| --- |--- |---|---|---|
| **AO** | N | String | `undefined` | Alignment Outer CSS color. if not set, the defaut is `colorDark` | &nbsp; |
| **AI** | N | String | `undefined` | Alignment Inner CSS color. if not set, the defaut is `colorDark` | &nbsp; |
| Timing Pattern Color options| --- | ---|---|---|---|
| **timing** | N | String | `undefined` | Global Timing CSS color. if not set, the defaut is `colorDark` | &nbsp; |
| **timing_H** | N | String | `undefined` | Horizontal timing CSS color | &nbsp; |
| **timing_V** | N | String | `undefined` | Vertical timing CSS color | &nbsp; |
| Title options| --- | ---|---|---|---|
| **title** | N | String | `''` | | &nbsp; |
| **titleFont** | N | String | `bold 16px Arial` | CSS Font | &nbsp; |
| **titleColor** | N | String | `#000000` | CSS color | &nbsp; |
| **titleBackgroundColor** | N | String | `#ffffff` | CSS color| &nbsp; |
| **titleHeight** | N | Number | `0` | Title Height, Include subTitle | &nbsp; |
| **titleTop** | N | Number | `30` | draws y coordinates.| &nbsp; |
| SubTitle options| --- | ---|---|---|---|
| **subTitle** | N | String | `''` | | &nbsp; |
| **subTitleFont** | N | String | `14px Arial` | CSS Font | &nbsp; |
| **subTitleColor** | N | String | `#4F4F4F` | CSS color | &nbsp; |
| **subTitleTop** | N | Number | `0` | draws y coordinates. default is 0| &nbsp; |
| Event Handler options| --- | ---|---|---|---|
| **onRenderingStart** | N | Function | `undefined` | Callback function when rendering start work. can use to hide loading state or handling. | &nbsp; |
| Option | Required | Type | Defaults | Description |
| --- | --- |--- | --- |--- |
| Basic options| --- | ---|---|---|
| **text** | Y | String |`''` | Text |
| **width** | N | Number | `256` | Width |
| **height** | N | Number | `256` | Height |
| **colorDark** | N | String | `#000000` | Dark CSS color |
| **colorLight** | N | String | `#ffffff` | Light CSS color |
| **correctLevel** | N | Enum | `QRCode.CorrectLevel.H` | `QRCode.CorrectLevel.H`<br/>`QRCode.CorrectLevel.Q` <br/> `QRCode.CorrectLevel.M` <br/> `QRCode.CorrectLevel.L`|
| **dotScale** | N | Number | `1.0` |Dot style required Patterns. Ranges: `0-1.0` |
| Quiet Zone| --- | ---|---|---|
| **quietZone** | N | Number | `0` | Quiet Zone size |
| **quietZoneColor** | N | String | `transparent` | Background CSS color to Quiet Zone |
| Logo options| --- | ---|---|---|
| **logo** | N | String | `undefined` | Logo Image Path. If use relative address, relative to `easy.qrcode.min.js` |
| **logoWidth** | N | Number | `undefined` | Height |
| **logoHeight** | N | Number | `undefined` | Width |
| **logoBackgroundTransparent** | N | Boolean | `false` | Whether the background transparent image(`PNG`) shows transparency. When `true`, `logoBackgroundColor` is invalid |
| **logoBackgroundColor** | N | String | `#ffffff` | Set Background CSS Color when image background transparent. Valid when `logoBackgroundTransparent` is `false` |
| Backgroud Image options| ---|--- |---|---|
| **backgroundImage** | N | String | `undefined` | Background Image Path. If use relative address, relative to `easy.qrcode.min.js` |
| **backgroundImageAlpha** | N | Number | `1.0` | Background image transparency. Ranges: `0-1.0` |
| **autoColor** | N | Boolean | `false` | Automatic color adjustment |
| Posotion Pattern Color options| --- | ---|---|---|
| **PO** | N | String | `undefined` | Global Posotion Outer CSS color. if not set, the defaut is `colorDark` |
| **PI** | N | String | `undefined` | Global Posotion Inner CSS color. if not set, the defaut is `colorDark` |
| **PO_TL** | N | String | `undefined` | Posotion Outer CSS color - Top Left |
| **PI_TL** | N | String | `undefined` | Posotion Inner CSS color - Top Left |
| **PO_TR** | N | String | `undefined` | Posotion Outer CSS color - Top Right |
| **PI_TR** | N | String | `undefined` | Posotion Inner CSS color - Top Right |
| **PO_BL** | N | String | `undefined` | Posotion Outer CSS color - Bottom Left |
| **PI_BL** | N | String | `undefined` | Posotion Inner CSS color - Bottom Left |
| Alignment Color options| --- |--- |---|---|
| **AO** | N | String | `undefined` | Alignment Outer CSS color. if not set, the defaut is `colorDark` |
| **AI** | N | String | `undefined` | Alignment Inner CSS color. if not set, the defaut is `colorDark` |
| Timing Pattern Color options| --- | ---|---|---|
| **timing** | N | String | `undefined` | Global Timing CSS color. if not set, the defaut is `colorDark` |
| **timing_H** | N | String | `undefined` | Horizontal timing CSS color |
| **timing_V** | N | String | `undefined` | Vertical timing CSS color |
| Title options| --- | ---|---|---|
| **title** | N | String | `''` | |
| **titleFont** | N | String | `bold 16px Arial` | CSS Font |
| **titleColor** | N | String | `#000000` | CSS color |
| **titleBackgroundColor** | N | String | `#ffffff` | CSS color|
| **titleHeight** | N | Number | `0` | Title Height, Include subTitle |
| **titleTop** | N | Number | `30` | draws y coordinates.|
| SubTitle options| --- | ---|---|---|
| **subTitle** | N | String | `''` | |
| **subTitleFont** | N | String | `14px Arial` | CSS Font |
| **subTitleColor** | N | String | `#4F4F4F` | CSS color |
| **subTitleTop** | N | Number | `0` | draws y coordinates. default is 0|
| Event Handler options| --- | ---|---|---|
| **onRenderingStart(qrCodeOptions)** | N | Function | `undefined` | Callback function when rendering start work. can use to hide loading state or handling. |
| Images format options| --- | ---|---|---|
| **format** | N | String | `PNG` | 'PNG' or 'JPG' |
| **compressionLevel** | N | Number | `6` | ZLIB compression level between 0 and 9. (**PNGs only**) |
| **quality** | N | Number | `0.75` | An object specifying the quality (0 to 1). (**JPGs only**) |
### Methods
- **saveImage(ImagesFormatOptions)**
### Method
- **saveImage(options)**
```JS
// Save Images to file
// Save PNG Images to file
qrcode.saveImage({
path: 'q.png', // file path
compressionLevel: 6 // ZLIB compression level between 0 and 9. default is 6
path: 'q.png' // file path
});
```
- **toDataURL()**

@@ -286,2 +294,4 @@

## End

@@ -288,0 +298,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc