From 47c0081b8e436201b4fdbfb7bcab6c1332a5551a Mon Sep 17 00:00:00 2001 From: ongspxm Date: Fri, 8 Mar 2019 00:17:57 +0800 Subject: [PATCH 01/20] err msg for qr code that are too long --- src/popup/modules/UserInterface.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/popup/modules/UserInterface.js b/src/popup/modules/UserInterface.js index 4e4eb123..666366ed 100644 --- a/src/popup/modules/UserInterface.js +++ b/src/popup/modules/UserInterface.js @@ -109,8 +109,15 @@ const refreshQrCode = throttle(() => { CommonMessages.hideError(); } - QrCreator.setTextInternal(text); - QrCreator.generate(); + try { + QrCreator.setTextInternal(text); + QrCreator.generate(); + } catch (e) { + if (e === "Data too long") { + CommonMessages.showError("Cannot generate Qr Code, data size too big."); + Logger.logError("Data exceeds maximum size:", text.length); + } + } }, QR_CODE_REFRESH_TIMEOUT); /** From 8f250b3eb38e963baca77b1bd4894ea924a1404d Mon Sep 17 00:00:00 2001 From: ongspxm Date: Fri, 8 Mar 2019 07:49:13 +0800 Subject: [PATCH 02/20] rethrowing error --- src/popup/modules/UserInterface.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/popup/modules/UserInterface.js b/src/popup/modules/UserInterface.js index 666366ed..421b9ed0 100644 --- a/src/popup/modules/UserInterface.js +++ b/src/popup/modules/UserInterface.js @@ -116,6 +116,8 @@ const refreshQrCode = throttle(() => { if (e === "Data too long") { CommonMessages.showError("Cannot generate Qr Code, data size too big."); Logger.logError("Data exceeds maximum size:", text.length); + } else { + throw e; } } }, QR_CODE_REFRESH_TIMEOUT); From 6a5ec8cf4d69de79544216480d968e7e9e723f60 Mon Sep 17 00:00:00 2001 From: ongspxm Date: Fri, 8 Mar 2019 08:42:27 +0800 Subject: [PATCH 03/20] make kjua throw the same kind of error --- src/popup/modules/QrLib/kjua.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/popup/modules/QrLib/kjua.js b/src/popup/modules/QrLib/kjua.js index 04f634cb..e88a8144 100644 --- a/src/popup/modules/QrLib/kjua.js +++ b/src/popup/modules/QrLib/kjua.js @@ -111,8 +111,13 @@ export function set(tag, value) { * @returns {HTMLElement} */ export function getQr() { - Logger.logInfo("generated new qr kjua code", kjuaOptions); - return kjua(kjuaOptions); + try { + Logger.logInfo("generated new qr kjua code", kjuaOptions); + return kjua(kjuaOptions); + } catch (err) { + throw err.message.startsWith("code length overflow.") + ? "Data too long" : err; + } } /** From 26e25037d5bf12b7c922d0e03dc23f795113831c Mon Sep 17 00:00:00 2001 From: ongspxm Date: Fri, 8 Mar 2019 09:05:28 +0800 Subject: [PATCH 04/20] shift err messags to localized form --- src/_locales/en/messages.json | 4 ++++ src/popup/modules/UserInterface.js | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index a7e7d10c..08a2581e 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -80,6 +80,10 @@ "message": "Permission request failed.", "description": "Error shown when a permission request failed. This indicates a technical error and does NOT mean the user declined the permission." }, + "errorQrCodeOverflow": { + "message": "Cannot generate QR Code, data size too big.", + "description": "Error shown when QR code cannot be generated due to overflow in input size." + }, "requestDownloadPermissionForQr": { "message": "To continue to save the QR code, we need the download permission.", "description": "Shown, when the user is asked to allow the download permission to save the QR code." diff --git a/src/popup/modules/UserInterface.js b/src/popup/modules/UserInterface.js index 421b9ed0..4c01eb5c 100644 --- a/src/popup/modules/UserInterface.js +++ b/src/popup/modules/UserInterface.js @@ -113,8 +113,9 @@ const refreshQrCode = throttle(() => { QrCreator.setTextInternal(text); QrCreator.generate(); } catch (e) { + // Error thrown from qrcodegen & kjua wrapper when code too long if (e === "Data too long") { - CommonMessages.showError("Cannot generate Qr Code, data size too big."); + CommonMessages.showError("errorQrCodeOverflow", true); Logger.logError("Data exceeds maximum size:", text.length); } else { throw e; From 342c5f351acc51ec8e75006153887635fb666b92 Mon Sep 17 00:00:00 2001 From: rugk Date: Sun, 10 Mar 2019 17:27:39 +0800 Subject: [PATCH 05/20] Update src/_locales/en/messages.json Co-Authored-By: ongspxm --- src/_locales/en/messages.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index 08a2581e..f1495a64 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -81,7 +81,7 @@ "description": "Error shown when a permission request failed. This indicates a technical error and does NOT mean the user declined the permission." }, "errorQrCodeOverflow": { - "message": "Cannot generate QR Code, data size too big.", + "message": "Cannot generate QR code, the provided text is too much.", "description": "Error shown when QR code cannot be generated due to overflow in input size." }, "requestDownloadPermissionForQr": { From 99c99a173fef2e701a841b8d6a3ba50351006762 Mon Sep 17 00:00:00 2001 From: ongspxm Date: Sun, 10 Mar 2019 23:34:20 +0800 Subject: [PATCH 06/20] make error non dismissable --- src/popup/modules/QrLib/kjua.js | 3 ++- src/popup/modules/UserInterface.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/popup/modules/QrLib/kjua.js b/src/popup/modules/QrLib/kjua.js index e88a8144..44c6307d 100644 --- a/src/popup/modules/QrLib/kjua.js +++ b/src/popup/modules/QrLib/kjua.js @@ -111,8 +111,9 @@ export function set(tag, value) { * @returns {HTMLElement} */ export function getQr() { + Logger.logInfo("generated new qr kjua code", kjuaOptions); + try { - Logger.logInfo("generated new qr kjua code", kjuaOptions); return kjua(kjuaOptions); } catch (err) { throw err.message.startsWith("code length overflow.") diff --git a/src/popup/modules/UserInterface.js b/src/popup/modules/UserInterface.js index 4c01eb5c..0b4126fa 100644 --- a/src/popup/modules/UserInterface.js +++ b/src/popup/modules/UserInterface.js @@ -115,7 +115,7 @@ const refreshQrCode = throttle(() => { } catch (e) { // Error thrown from qrcodegen & kjua wrapper when code too long if (e === "Data too long") { - CommonMessages.showError("errorQrCodeOverflow", true); + CommonMessages.showError("errorQrCodeOverflow"); Logger.logError("Data exceeds maximum size:", text.length); } else { throw e; From 6afc6f159efb5b91163213ce1cdf7a8ebc90c8db Mon Sep 17 00:00:00 2001 From: ongspxm Date: Mon, 11 Mar 2019 13:29:17 +0800 Subject: [PATCH 07/20] wip. adding err --- src/popup/modules/QrLib/kjua.js | 4 +++- src/popup/modules/QrLib/qrerr.js | 12 ++++++++++++ src/popup/modules/QrLib/qrgen.js | 9 ++++++++- 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 src/popup/modules/QrLib/qrerr.js diff --git a/src/popup/modules/QrLib/kjua.js b/src/popup/modules/QrLib/kjua.js index 44c6307d..272311ff 100644 --- a/src/popup/modules/QrLib/kjua.js +++ b/src/popup/modules/QrLib/kjua.js @@ -3,10 +3,12 @@ * * @module QrLib/kjua * @requires /common/modules/Logger + * @requires qrerr */ /* globals kjua */ import * as Logger from "/common/modules/Logger/Logger.js"; +import * as QrErr from "./qrerr.js"; /** * The type of QR code this library generates. @@ -117,7 +119,7 @@ export function getQr() { return kjua(kjuaOptions); } catch (err) { throw err.message.startsWith("code length overflow.") - ? "Data too long" : err; + ? new QrErr.DataOverflowError() : err; } } diff --git a/src/popup/modules/QrLib/qrerr.js b/src/popup/modules/QrLib/qrerr.js new file mode 100644 index 00000000..46f4639c --- /dev/null +++ b/src/popup/modules/QrLib/qrerr.js @@ -0,0 +1,12 @@ +/** + * Errors in QR code generation + * + * @module QrLib/qrerr + */ + +export class DataOverflowError extends Error { + constructor(...params) { + super(...params); + this.message = 'data overflow error'; + } +} diff --git a/src/popup/modules/QrLib/qrgen.js b/src/popup/modules/QrLib/qrgen.js index f5bc73d3..557fe241 100644 --- a/src/popup/modules/QrLib/qrgen.js +++ b/src/popup/modules/QrLib/qrgen.js @@ -7,6 +7,7 @@ /* globals qrcodegen */ import * as Logger from "/common/modules/Logger/Logger.js"; +import * as QrErr from "./qrerr.js"; const QRC = qrcodegen.QrCode; @@ -101,7 +102,13 @@ export function set(tag, value) { export function getQr() { Logger.logInfo("generated new QrGen qr code"); - const qrElem = QRC.encodeText(qrText, qrErrorCorrection); + try { + const qrElem = QRC.encodeText(qrText, qrErrorCorrection); + } catch (err) { + throw (err === 'Data too long') + ? QrErr.DataOverflowError : err; + } + const svgString = qrElem.toSvgString(qrQuietZone); return getSvgElement(svgString); From 2c85babe08a7b96bd4435a3155183680d1e7dc9f Mon Sep 17 00:00:00 2001 From: ongspxm Date: Mon, 11 Mar 2019 17:58:10 +0800 Subject: [PATCH 08/20] using qrError --- src/popup/modules/QrLib/{qrerr.js => QrErrors.js} | 0 src/popup/modules/QrLib/kjua.js | 6 +++--- src/popup/modules/QrLib/qrgen.js | 7 ++++--- src/popup/modules/UserInterface.js | 6 ++++-- 4 files changed, 11 insertions(+), 8 deletions(-) rename src/popup/modules/QrLib/{qrerr.js => QrErrors.js} (100%) diff --git a/src/popup/modules/QrLib/qrerr.js b/src/popup/modules/QrLib/QrErrors.js similarity index 100% rename from src/popup/modules/QrLib/qrerr.js rename to src/popup/modules/QrLib/QrErrors.js diff --git a/src/popup/modules/QrLib/kjua.js b/src/popup/modules/QrLib/kjua.js index 272311ff..d67ca19b 100644 --- a/src/popup/modules/QrLib/kjua.js +++ b/src/popup/modules/QrLib/kjua.js @@ -3,12 +3,12 @@ * * @module QrLib/kjua * @requires /common/modules/Logger - * @requires qrerr + * @requires QrErrors */ /* globals kjua */ import * as Logger from "/common/modules/Logger/Logger.js"; -import * as QrErr from "./qrerr.js"; +import * as QrError from "./QrErrors.js"; /** * The type of QR code this library generates. @@ -119,7 +119,7 @@ export function getQr() { return kjua(kjuaOptions); } catch (err) { throw err.message.startsWith("code length overflow.") - ? new QrErr.DataOverflowError() : err; + ? new QrError.DataOverflowError() : err; } } diff --git a/src/popup/modules/QrLib/qrgen.js b/src/popup/modules/QrLib/qrgen.js index 557fe241..6410ac22 100644 --- a/src/popup/modules/QrLib/qrgen.js +++ b/src/popup/modules/QrLib/qrgen.js @@ -3,11 +3,12 @@ * * @module QrLib/qrgen * @requires /common/modules/Logger + * @requires QrErrors */ /* globals qrcodegen */ import * as Logger from "/common/modules/Logger/Logger.js"; -import * as QrErr from "./qrerr.js"; +import * as QrError from "./QrErrors.js"; const QRC = qrcodegen.QrCode; @@ -105,8 +106,8 @@ export function getQr() { try { const qrElem = QRC.encodeText(qrText, qrErrorCorrection); } catch (err) { - throw (err === 'Data too long') - ? QrErr.DataOverflowError : err; + throw (err === "Data too long") + ? QrError.DataOverflowError : err; } const svgString = qrElem.toSvgString(qrQuietZone); diff --git a/src/popup/modules/UserInterface.js b/src/popup/modules/UserInterface.js index 0b4126fa..dba56e49 100644 --- a/src/popup/modules/UserInterface.js +++ b/src/popup/modules/UserInterface.js @@ -8,6 +8,7 @@ * @requires /common/modules/Logger * @requires /common/modules/AddonSettings * @requires /common/modules/MessageHandler + * @requires ./QrLib/QrErrors * @requires ./QrCreator */ // lodash @@ -20,6 +21,7 @@ import * as Logger from "/common/modules/Logger/Logger.js"; import * as AddonSettings from "/common/modules/AddonSettings/AddonSettings.js"; import * as CommonMessages from "/common/modules/MessageHandler/CommonMessages.js"; +import * as QrError from "./QrLib/QrErrors.js"; import * as QrCreator from "./QrCreator.js"; import {createMenu} from "/common/modules/ContextMenu.js"; @@ -114,11 +116,11 @@ const refreshQrCode = throttle(() => { QrCreator.generate(); } catch (e) { // Error thrown from qrcodegen & kjua wrapper when code too long - if (e === "Data too long") { + if (e instanceof QrError.DataOverflowError) { CommonMessages.showError("errorQrCodeOverflow"); Logger.logError("Data exceeds maximum size:", text.length); } else { - throw e; + throw e; } } }, QR_CODE_REFRESH_TIMEOUT); From b18ce753388d16a0b525b8d244dbedb49344c622 Mon Sep 17 00:00:00 2001 From: ongspxm Date: Mon, 11 Mar 2019 18:00:00 +0800 Subject: [PATCH 09/20] indentation --- src/popup/modules/QrLib/QrErrors.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/popup/modules/QrLib/QrErrors.js b/src/popup/modules/QrLib/QrErrors.js index 46f4639c..f47d1339 100644 --- a/src/popup/modules/QrLib/QrErrors.js +++ b/src/popup/modules/QrLib/QrErrors.js @@ -1,12 +1,12 @@ /** * Errors in QR code generation * - * @module QrLib/qrerr + * @module QrLib/QrErrors */ export class DataOverflowError extends Error { - constructor(...params) { - super(...params); - this.message = 'data overflow error'; - } + constructor(...params) { + super(...params); + this.message = 'data overflow error'; + } } From d33af1a7ebfce55f283402ba203d2b1ca4dc2693 Mon Sep 17 00:00:00 2001 From: ongspxm Date: Tue, 12 Mar 2019 00:18:12 +0800 Subject: [PATCH 10/20] updated naming system --- src/popup/modules/QrLib/{QrErrors.js => QrError.js} | 0 src/popup/modules/QrLib/kjua.js | 2 +- src/popup/modules/QrLib/qrgen.js | 2 +- src/popup/modules/UserInterface.js | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) rename src/popup/modules/QrLib/{QrErrors.js => QrError.js} (100%) diff --git a/src/popup/modules/QrLib/QrErrors.js b/src/popup/modules/QrLib/QrError.js similarity index 100% rename from src/popup/modules/QrLib/QrErrors.js rename to src/popup/modules/QrLib/QrError.js diff --git a/src/popup/modules/QrLib/kjua.js b/src/popup/modules/QrLib/kjua.js index d67ca19b..74d7fd92 100644 --- a/src/popup/modules/QrLib/kjua.js +++ b/src/popup/modules/QrLib/kjua.js @@ -8,7 +8,7 @@ /* globals kjua */ import * as Logger from "/common/modules/Logger/Logger.js"; -import * as QrError from "./QrErrors.js"; +import * as QrError from "./QrError.js"; /** * The type of QR code this library generates. diff --git a/src/popup/modules/QrLib/qrgen.js b/src/popup/modules/QrLib/qrgen.js index 6410ac22..92504e2b 100644 --- a/src/popup/modules/QrLib/qrgen.js +++ b/src/popup/modules/QrLib/qrgen.js @@ -8,7 +8,7 @@ /* globals qrcodegen */ import * as Logger from "/common/modules/Logger/Logger.js"; -import * as QrError from "./QrErrors.js"; +import * as QrError from "./QrError.js"; const QRC = qrcodegen.QrCode; diff --git a/src/popup/modules/UserInterface.js b/src/popup/modules/UserInterface.js index dba56e49..5054662c 100644 --- a/src/popup/modules/UserInterface.js +++ b/src/popup/modules/UserInterface.js @@ -21,7 +21,7 @@ import * as Logger from "/common/modules/Logger/Logger.js"; import * as AddonSettings from "/common/modules/AddonSettings/AddonSettings.js"; import * as CommonMessages from "/common/modules/MessageHandler/CommonMessages.js"; -import * as QrError from "./QrLib/QrErrors.js"; +import * as QrError from "./QrLib/QrError.js"; import * as QrCreator from "./QrCreator.js"; import {createMenu} from "/common/modules/ContextMenu.js"; From e1b537e31f644b3cab5cf14334d74fa2c8369c94 Mon Sep 17 00:00:00 2001 From: ongspxm Date: Mon, 18 Mar 2019 17:23:38 +0800 Subject: [PATCH 11/20] updated kjua lib --- src/popup/lib/kjua-2.0.min.js | 2 ++ src/popup/lib/kjua.min.js | 2 -- src/popup/qrcode.html | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 src/popup/lib/kjua-2.0.min.js delete mode 100644 src/popup/lib/kjua.min.js diff --git a/src/popup/lib/kjua-2.0.min.js b/src/popup/lib/kjua-2.0.min.js new file mode 100644 index 00000000..259b56e8 --- /dev/null +++ b/src/popup/lib/kjua-2.0.min.js @@ -0,0 +1,2 @@ +/*! kjua v0.2.0 - https://larsjung.de/kjua/ */ +!function(r,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.kjua=t():r.kjua=t()}(this,function(){return function(r){function t(n){if(e[n])return e[n].exports;var o=e[n]={exports:{},id:n,loaded:!1};return r[n].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var e={};return t.m=r,t.c=e,t.p="",t(0)}([function(r,t,e){"use strict";var n=e(1),o=n.create_canvas,i=n.canvas_to_img,a=n.dpr,u=e(2),f=e(3),c=e(4);r.exports=function(r){var t=Object.assign({},u,r),e=f(t.text,t.ecLevel,t.minVersion,t.quiet),n=t.ratio||a,l=o(t.size,n),s=l.getContext("2d");return s.scale(n,n),c(e,s,t),"image"===t.render?i(l):l}},function(r,t){"use strict";var e=window,n=e.document,o=e.devicePixelRatio||1,i=function(r){return n.createElement(r)},a=function(r,t){return r.getAttribute(t)},u=function(r,t,e){return r.setAttribute(t,e)},f=function(r,t){var e=i("canvas");return u(e,"width",r*t),u(e,"height",r*t),e.style.width=r+"px",e.style.height=r+"px",e},c=function(r){var t=i("img");return u(t,"crossorigin","anonymous"),u(t,"src",r.toDataURL("image/png")),u(t,"width",a(r,"width")),u(t,"height",a(r,"height")),t.style.width=r.style.width,t.style.height=r.style.height,t};r.exports={create_canvas:f,canvas_to_img:c,dpr:o}},function(r,t){"use strict";r.exports={render:"image",crisp:!0,minVersion:1,ecLevel:"L",size:200,ratio:null,fill:"#333",back:"#fff",text:"no text",rounded:0,quiet:0,mode:"plain",mSize:30,mPosX:50,mPosY:50,label:"no label",fontname:"sans",fontcolor:"#333",image:null}},function(r,t){"use strict";var e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},n=/code length overflow/i,o=function(){var e=function(){function r(t,e){if("undefined"==typeof t.length)throw new Error(t.length+"/"+e);var n=function(){for(var r=0;r=7&&T(r),null==d&&(d=x(l,s,w)),b(d,t)},m=function(r,t){for(var e=-1;e<=7;e+=1)if(!(r+e<=-1||h<=r+e))for(var n=-1;n<=7;n+=1)t+n<=-1||h<=t+n||(0<=e&&e<=6&&(0==n||6==n)||0<=n&&n<=6&&(0==e||6==e)||2<=e&&e<=4&&2<=n&&n<=4?g[r+e][t+n]=!0:g[r+e][t+n]=!1)},A=function(){for(var r=0,t=0,e=0;e<8;e+=1){p(!0,e);var n=i.getLostPoint(y);(0==e||r>n)&&(r=n,t=e)}return t},B=function(){for(var r=8;r>e&1);g[Math.floor(e/3)][e%3+h-8-3]=n}for(var e=0;e<18;e+=1){var n=!r&&1==(t>>e&1);g[e%3+h-8-3][Math.floor(e/3)]=n}},M=function(r,t){for(var e=s<<3|t,n=i.getBCHTypeInfo(e),o=0;o<15;o+=1){var a=!r&&1==(n>>o&1);o<6?g[o][8]=a:o<8?g[o+1][8]=a:g[h-15+o][8]=a}for(var o=0;o<15;o+=1){var a=!r&&1==(n>>o&1);o<8?g[8][h-o-1]=a:o<9?g[8][15-o-1+1]=a:g[8][15-o-1]=a}g[h-8][8]=!r},b=function(r,t){for(var e=-1,n=h-1,o=7,a=0,u=i.getMaskFunction(t),f=h-1;f>0;f-=2)for(6==f&&(f-=1);;){for(var c=0;c<2;c+=1)if(null==g[n][f-c]){var l=!1;a>>o&1));var s=u(n,f-c);s&&(l=!l),g[n][f-c]=l,o-=1,o==-1&&(a+=1,o=7)}if(n+=e,n<0||h<=n){n-=e,e=-e;break}}},k=function(t,e){for(var n=0,o=0,a=0,u=new Array(e.length),f=new Array(e.length),c=0;c=0?d.getAt(w):0}}for(var y=0,g=0;g8*g)throw new Error("code length overflow. ("+c.getLengthInBits()+">"+8*g+")");for(c.getLengthInBits()+4<=8*g&&c.put(0,4);c.getLengthInBits()%8!=0;)c.putBit(!1);for(;;){if(c.getLengthInBits()>=8*g)break;if(c.put(o,8),c.getLengthInBits()>=8*g)break;c.put(a,8)}return k(c,n)};return y.addData=function(r){var t=c(r);w.push(t),d=null},y.isDark=function(r,t){if(r<0||h<=r||t<0||h<=t)throw new Error(r+","+t);return g[r][t]},y.getModuleCount=function(){return h},y.make=function(){p(!1,A())},y.createTableTag=function(r,t){r=r||2,t="undefined"==typeof t?4*r:t;var e="";e+='";for(var o=0;o';e+=""}return e+="",e+="
"},y.createImgTag=function(r,t){r=r||2,t="undefined"==typeof t?4*r:t;var e=y.getModuleCount()*r+2*t,n=t,o=e-t;return v(e,e,function(t,e){if(n<=t&&t>>8),t.push(255&a)):t.push(n)}}return t}};var e={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},n={L:1,M:0,Q:3,H:2},o={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},i=function(){var t=[[],[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]],n=1335,i=7973,u=21522,f={},c=function(r){for(var t=0;0!=r;)t+=1,r>>>=1;return t};return f.getBCHTypeInfo=function(r){for(var t=r<<10;c(t)-c(n)>=0;)t^=n<=0;)t^=i<5&&(e+=3+i-5)}for(var n=0;n=256;)t-=255;return r[t]},n}(),u=function(){var r=[[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]],t=function(r,t){var e={};return e.totalCount=r,e.dataCount=t,e},e={},o=function(t,e){switch(e){case n.L:return r[4*(t-1)+0];case n.M:return r[4*(t-1)+1];case n.Q:return r[4*(t-1)+2];case n.H:return r[4*(t-1)+3];default:return}};return e.getRSBlocks=function(r,e){var n=o(r,e);if("undefined"==typeof n)throw new Error("bad rs block @ typeNumber:"+r+"/errorCorrectLevel:"+e);for(var i=n.length/3,a=new Array,u=0;u>>7-t%8&1)},e.put=function(r,t){for(var n=0;n>>t-n-1&1))},e.getLengthInBits=function(){return t},e.putBit=function(e){var n=Math.floor(t/8);r.length<=n&&r.push(0),e&&(r[n]|=128>>>t%8),t+=1},e},c=function(r){var n=e.MODE_8BIT_BYTE,o=t.stringToBytes(r),i={};return i.getMode=function(){return n},i.getLength=function(r){return o.length},i.write=function(r){for(var t=0;t>>8)},t.writeBytes=function(r,e,n){e=e||0,n=n||r.length;for(var o=0;o0&&(t+=","),t+=r[e];return t+="]"},t},s=function(){var r=0,t=0,e=0,n="",o={},i=function(r){n+=String.fromCharCode(a(63&r))},a=function(r){if(r<0);else{if(r<26)return 65+r;if(r<52)return 97+(r-26);if(r<62)return 48+(r-52);if(62==r)return 43;if(63==r)return 47}throw new Error("n:"+r)};return o.writeByte=function(n){for(r=r<<8|255&n,t+=8,e+=1;t>=6;)i(r>>>t-6),t-=6},o.flush=function(){if(t>0&&(i(r<<6-t),r=0,t=0),e%3!=0)for(var o=3-e%3,a=0;a=t.length){if(0==o)return-1;throw new Error("unexpected end of file./"+o)}var r=t.charAt(e);if(e+=1,"="==r)return o=0,-1;r.match(/^\s$/)||(n=n<<6|a(r.charCodeAt(0)),o+=6)}var i=n>>>o-8&255;return o-=8,i};var a=function(r){if(65<=r&&r<=90)return r-65;if(97<=r&&r<=122)return r-97+26;if(48<=r&&r<=57)return r-48+52;if(43==r)return 62;if(47==r)return 63;throw new Error("c:"+r)};return i},h=function(r,t){var e=r,n=t,o=new Array(r*t),i={};i.setPixel=function(r,t,n){o[t*e+r]=n},i.write=function(r){r.writeString("GIF87a"),r.writeShort(e),r.writeShort(n),r.writeByte(128),r.writeByte(0),r.writeByte(0),r.writeByte(0),r.writeByte(0),r.writeByte(0),r.writeByte(255),r.writeByte(255),r.writeByte(255),r.writeString(","),r.writeShort(0),r.writeShort(0),r.writeShort(e),r.writeShort(n),r.writeByte(0);var t=2,o=u(t);r.writeByte(t);for(var i=0;o.length-i>255;)r.writeByte(255),r.writeBytes(o,i,255),i+=255;r.writeByte(o.length-i),r.writeBytes(o,i,o.length-i),r.writeByte(0),r.writeString(";")};var a=function(r){var t=r,e=0,n=0,o={};return o.write=function(r,o){if(r>>>o!=0)throw new Error("length over");for(;e+o>=8;)t.writeByte(255&(r<>>=8-e,n=0,e=0;n|=r<0&&t.writeByte(n)},o},u=function(r){for(var t=1<>6,128|63&n):n<55296||n>=57344?t.push(224|n>>12,128|n>>6&63,128|63&n):(e++,n=65536+((1023&n)<<10|1023&r.charCodeAt(e)),t.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|63&n))}return t}return t(r)}}(e),e}(),i=function(r,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;i=Math.max(1,i);for(var a=i;a<=40;a+=1)try{var u=function(){var e=o(a,t);e.addData(r),e.make();var n=e.getModuleCount(),i=function(r,t){return r>=0&&r=0&&t0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"L",e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=i(r,t,e);if(o){var a=o.isDark;o.moduleCount+=2*n,o.isDark=function(r,t){return a(r-n,t-n)}}return o};r.exports=a},function(r,t,e){"use strict";var n=e(5),o=e(6),i=function(r,t){r.fillStyle=t.back,r.fillRect(0,0,t.size,t.size)},a=function(r,t,e,n,o,i){r.isDark(o,i)&&t.rect(i*n,o*n,n,n)},u=function(r,t,e){if(r){var o=e.rounded>0&&e.rounded<=100?n:a,i=r.moduleCount,u=e.size/i,f=0;e.crisp&&(u=Math.floor(u),f=Math.floor((e.size-u*i)/2)),t.translate(f,f),t.beginPath();for(var c=0;c=7&&T(r),null==d&&(d=x(l,s,w)),b(d,t)},m=function(r,t){for(var e=-1;e<=7;e+=1)if(!(r+e<=-1||h<=r+e))for(var n=-1;n<=7;n+=1)t+n<=-1||h<=t+n||(0<=e&&e<=6&&(0==n||6==n)||0<=n&&n<=6&&(0==e||6==e)||2<=e&&e<=4&&2<=n&&n<=4?g[r+e][t+n]=!0:g[r+e][t+n]=!1)},A=function(){for(var r=0,t=0,e=0;e<8;e+=1){p(!0,e);var n=i.getLostPoint(y);(0==e||r>n)&&(r=n,t=e)}return t},B=function(){for(var r=8;r>e&1);g[Math.floor(e/3)][e%3+h-8-3]=n}for(var e=0;e<18;e+=1){var n=!r&&1==(t>>e&1);g[e%3+h-8-3][Math.floor(e/3)]=n}},M=function(r,t){for(var e=s<<3|t,n=i.getBCHTypeInfo(e),o=0;o<15;o+=1){var a=!r&&1==(n>>o&1);o<6?g[o][8]=a:o<8?g[o+1][8]=a:g[h-15+o][8]=a}for(var o=0;o<15;o+=1){var a=!r&&1==(n>>o&1);o<8?g[8][h-o-1]=a:o<9?g[8][15-o-1+1]=a:g[8][15-o-1]=a}g[h-8][8]=!r},b=function(r,t){for(var e=-1,n=h-1,o=7,a=0,u=i.getMaskFunction(t),f=h-1;f>0;f-=2)for(6==f&&(f-=1);;){for(var c=0;c<2;c+=1)if(null==g[n][f-c]){var l=!1;a>>o&1));var s=u(n,f-c);s&&(l=!l),g[n][f-c]=l,o-=1,o==-1&&(a+=1,o=7)}if(n+=e,n<0||h<=n){n-=e,e=-e;break}}},k=function(t,e){for(var n=0,o=0,a=0,u=new Array(e.length),f=new Array(e.length),c=0;c=0?d.getAt(w):0}}for(var y=0,g=0;g8*g)throw new Error("code length overflow. ("+c.getLengthInBits()+">"+8*g+")");for(c.getLengthInBits()+4<=8*g&&c.put(0,4);c.getLengthInBits()%8!=0;)c.putBit(!1);for(;;){if(c.getLengthInBits()>=8*g)break;if(c.put(o,8),c.getLengthInBits()>=8*g)break;c.put(a,8)}return k(c,n)};return y.addData=function(r){var t=c(r);w.push(t),d=null},y.isDark=function(r,t){if(r<0||h<=r||t<0||h<=t)throw new Error(r+","+t);return g[r][t]},y.getModuleCount=function(){return h},y.make=function(){p(!1,A())},y.createTableTag=function(r,t){r=r||2,t="undefined"==typeof t?4*r:t;var e="";e+='";for(var o=0;o';e+=""}return e+="",e+="
"},y.createImgTag=function(r,t){r=r||2,t="undefined"==typeof t?4*r:t;var e=y.getModuleCount()*r+2*t,n=t,o=e-t;return v(e,e,function(t,e){if(n<=t&&t>>8),t.push(255&a)):t.push(n)}}return t}};var e={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},n={L:1,M:0,Q:3,H:2},o={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},i=function(){var t=[[],[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]],n=1335,i=7973,u=21522,f={},c=function(r){for(var t=0;0!=r;)t+=1,r>>>=1;return t};return f.getBCHTypeInfo=function(r){for(var t=r<<10;c(t)-c(n)>=0;)t^=n<=0;)t^=i<5&&(e+=3+i-5)}for(var n=0;n=256;)t-=255;return r[t]},n}(),u=function(){var r=[[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]],t=function(r,t){var e={};return e.totalCount=r,e.dataCount=t,e},e={},o=function(t,e){switch(e){case n.L:return r[4*(t-1)+0];case n.M:return r[4*(t-1)+1];case n.Q:return r[4*(t-1)+2];case n.H:return r[4*(t-1)+3];default:return}};return e.getRSBlocks=function(r,e){var n=o(r,e);if("undefined"==typeof n)throw new Error("bad rs block @ typeNumber:"+r+"/errorCorrectLevel:"+e);for(var i=n.length/3,a=new Array,u=0;u>>7-t%8&1)},e.put=function(r,t){for(var n=0;n>>t-n-1&1))},e.getLengthInBits=function(){return t},e.putBit=function(e){var n=Math.floor(t/8);r.length<=n&&r.push(0),e&&(r[n]|=128>>>t%8),t+=1},e},c=function(r){var n=e.MODE_8BIT_BYTE,o=t.stringToBytes(r),i={};return i.getMode=function(){return n},i.getLength=function(r){return o.length},i.write=function(r){for(var t=0;t>>8)},t.writeBytes=function(r,e,n){e=e||0,n=n||r.length;for(var o=0;o0&&(t+=","),t+=r[e];return t+="]"},t},s=function(){var r=0,t=0,e=0,n="",o={},i=function(r){n+=String.fromCharCode(a(63&r))},a=function(r){if(r<0);else{if(r<26)return 65+r;if(r<52)return 97+(r-26);if(r<62)return 48+(r-52);if(62==r)return 43;if(63==r)return 47}throw new Error("n:"+r)};return o.writeByte=function(n){for(r=r<<8|255&n,t+=8,e+=1;t>=6;)i(r>>>t-6),t-=6},o.flush=function(){if(t>0&&(i(r<<6-t),r=0,t=0),e%3!=0)for(var o=3-e%3,a=0;a=t.length){if(0==o)return-1;throw new Error("unexpected end of file./"+o)}var r=t.charAt(e);if(e+=1,"="==r)return o=0,-1;r.match(/^\s$/)||(n=n<<6|a(r.charCodeAt(0)),o+=6)}var i=n>>>o-8&255;return o-=8,i};var a=function(r){if(65<=r&&r<=90)return r-65;if(97<=r&&r<=122)return r-97+26;if(48<=r&&r<=57)return r-48+52;if(43==r)return 62;if(47==r)return 63;throw new Error("c:"+r)};return i},h=function(r,t){var e=r,n=t,o=new Array(r*t),i={};i.setPixel=function(r,t,n){o[t*e+r]=n},i.write=function(r){r.writeString("GIF87a"),r.writeShort(e),r.writeShort(n),r.writeByte(128),r.writeByte(0),r.writeByte(0),r.writeByte(0),r.writeByte(0),r.writeByte(0),r.writeByte(255),r.writeByte(255),r.writeByte(255),r.writeString(","),r.writeShort(0),r.writeShort(0),r.writeShort(e),r.writeShort(n),r.writeByte(0);var t=2,o=u(t);r.writeByte(t);for(var i=0;o.length-i>255;)r.writeByte(255),r.writeBytes(o,i,255),i+=255;r.writeByte(o.length-i),r.writeBytes(o,i,o.length-i),r.writeByte(0),r.writeString(";")};var a=function(r){var t=r,e=0,n=0,o={};return o.write=function(r,o){if(r>>>o!=0)throw new Error("length over");for(;e+o>=8;)t.writeByte(255&(r<>>=8-e,n=0,e=0;n|=r<0&&t.writeByte(n)},o},u=function(r){for(var t=1<>6,128|63&n):n<55296||n>=57344?t.push(224|n>>12,128|n>>6&63,128|63&n):(e++,n=65536+((1023&n)<<10|1023&r.charCodeAt(e)),t.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|63&n))}return t}return t(r)}}(e),e}(),i=function(r,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;i=Math.max(1,i);for(var a=i;a<=40;a+=1)try{var u=function(){var e=o(a,t);e.addData(r),e.make();var n=e.getModuleCount(),i=function(r,t){return r>=0&&r=0&&t0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"L",e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=i(r,t,e);if(o){var a=o.isDark;o.moduleCount+=2*n,o.isDark=function(r,t){return a(r-n,t-n)}}return o};r.exports=a},function(r,t,e){"use strict";var n=e(5),o=e(6),i=function(r,t){r.fillStyle=t.back,r.fillRect(0,0,t.size,t.size)},a=function(r,t,e,n,o,i){r.isDark(o,i)&&t.rect(i*n,o*n,n,n)},u=function(r,t,e){if(r){var o=e.rounded>0&&e.rounded<=100?n:a,i=r.moduleCount,u=e.size/i,f=0;e.crisp&&(u=Math.floor(u),f=Math.floor((e.size-u*i)/2)),t.translate(f,f),t.beginPath();for(var c=0;c - + From ad4396d81edeec305697bd796fd149807fa5823a Mon Sep 17 00:00:00 2001 From: rugk Date: Mon, 18 Mar 2019 17:25:08 +0800 Subject: [PATCH 12/20] Update src/popup/modules/UserInterface.js Co-Authored-By: ongspxm --- src/popup/modules/UserInterface.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/popup/modules/UserInterface.js b/src/popup/modules/UserInterface.js index ea560d0f..28fa1bc5 100644 --- a/src/popup/modules/UserInterface.js +++ b/src/popup/modules/UserInterface.js @@ -117,7 +117,7 @@ const refreshQrCode = throttle(() => { // Error thrown from qrcodegen & kjua wrapper when code too long if (e instanceof QrError.DataOverflowError) { CommonMessages.showError("errorQrCodeOverflow"); - Logger.logError("Data exceeds maximum size:", text.length); + Logger.logError("Maximum size of QR code data exceeded with", text.length, "characters."); } else { throw e; } From 67513dcafd089630a9e085131a6343e09ef78171 Mon Sep 17 00:00:00 2001 From: ongspxm Date: Mon, 18 Mar 2019 19:35:46 +0800 Subject: [PATCH 13/20] eslint --- src/popup/modules/QrLib/QrError.js | 2 +- src/popup/modules/QrLib/kjua.js | 2 +- src/popup/modules/QrLib/qrgen.js | 6 ++---- src/popup/modules/UserInterface.js | 1 - 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/popup/modules/QrLib/QrError.js b/src/popup/modules/QrLib/QrError.js index f47d1339..8a3a73f5 100644 --- a/src/popup/modules/QrLib/QrError.js +++ b/src/popup/modules/QrLib/QrError.js @@ -7,6 +7,6 @@ export class DataOverflowError extends Error { constructor(...params) { super(...params); - this.message = 'data overflow error'; + this.message = "data overflow error"; } } diff --git a/src/popup/modules/QrLib/kjua.js b/src/popup/modules/QrLib/kjua.js index 2d74e610..357f1cfa 100644 --- a/src/popup/modules/QrLib/kjua.js +++ b/src/popup/modules/QrLib/kjua.js @@ -116,7 +116,7 @@ export function getQr() { return kjua(kjuaOptions); } catch (err) { throw err.message.startsWith("code length overflow.") - ? new QrError.DataOverflowError() : err; + ? new QrError.DataOverflowError() : err; } } diff --git a/src/popup/modules/QrLib/qrgen.js b/src/popup/modules/QrLib/qrgen.js index e1612652..a1aedbd4 100644 --- a/src/popup/modules/QrLib/qrgen.js +++ b/src/popup/modules/QrLib/qrgen.js @@ -103,12 +103,10 @@ export function getQr() { try { const qrElem = QRC.encodeText(qrText, qrErrorCorrection); + const svgString = qrElem.toSvgString(qrQuietZone); + return getSvgElement(svgString); } catch (err) { throw (err === "Data too long") ? QrError.DataOverflowError : err; } - - const svgString = qrElem.toSvgString(qrQuietZone); - - return getSvgElement(svgString); } diff --git a/src/popup/modules/UserInterface.js b/src/popup/modules/UserInterface.js index ea560d0f..a9cf8998 100644 --- a/src/popup/modules/UserInterface.js +++ b/src/popup/modules/UserInterface.js @@ -117,7 +117,6 @@ const refreshQrCode = throttle(() => { // Error thrown from qrcodegen & kjua wrapper when code too long if (e instanceof QrError.DataOverflowError) { CommonMessages.showError("errorQrCodeOverflow"); - Logger.logError("Data exceeds maximum size:", text.length); } else { throw e; } From a594aab1f9565d7c90567aee722d5a3718712ee8 Mon Sep 17 00:00:00 2001 From: rugk Date: Tue, 19 Mar 2019 14:48:39 +0100 Subject: [PATCH 14/20] Change file name of kjua lib --- src/popup/lib/{kjua-2.0.min.js => kjua-0.2.0.min.js} | 0 src/popup/qrcode.html | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename src/popup/lib/{kjua-2.0.min.js => kjua-0.2.0.min.js} (100%) diff --git a/src/popup/lib/kjua-2.0.min.js b/src/popup/lib/kjua-0.2.0.min.js similarity index 100% rename from src/popup/lib/kjua-2.0.min.js rename to src/popup/lib/kjua-0.2.0.min.js diff --git a/src/popup/qrcode.html b/src/popup/qrcode.html index 33c15bc8..974dfe3b 100644 --- a/src/popup/qrcode.html +++ b/src/popup/qrcode.html @@ -6,7 +6,7 @@ - + From d283ee33c00477f218b7a21a8d28c9d9aa3d2c44 Mon Sep 17 00:00:00 2001 From: rugk Date: Tue, 19 Mar 2019 23:33:35 +0800 Subject: [PATCH 15/20] Update src/popup/modules/QrLib/QrError.js Co-Authored-By: ongspxm --- src/popup/modules/QrLib/QrError.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/popup/modules/QrLib/QrError.js b/src/popup/modules/QrLib/QrError.js index 8a3a73f5..541319a7 100644 --- a/src/popup/modules/QrLib/QrError.js +++ b/src/popup/modules/QrLib/QrError.js @@ -7,6 +7,6 @@ export class DataOverflowError extends Error { constructor(...params) { super(...params); - this.message = "data overflow error"; + this.message = "The QR code was given too much data."; } } From 0df9d0a3c0f4e98aff0656b81e0b0bd1eba2ab73 Mon Sep 17 00:00:00 2001 From: ongspxm Date: Wed, 20 Mar 2019 00:12:09 +0800 Subject: [PATCH 16/20] update error --- src/popup/modules/QrLib/QrError.js | 5 +++-- src/popup/modules/QrLib/qrgen.js | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/popup/modules/QrLib/QrError.js b/src/popup/modules/QrLib/QrError.js index 541319a7..513805d8 100644 --- a/src/popup/modules/QrLib/QrError.js +++ b/src/popup/modules/QrLib/QrError.js @@ -5,8 +5,9 @@ */ export class DataOverflowError extends Error { - constructor(...params) { + constructor(...rparams) { + let params = rparams.length>0 + ? rparams : ["The QR code was given too much data."]; super(...params); - this.message = "The QR code was given too much data."; } } diff --git a/src/popup/modules/QrLib/qrgen.js b/src/popup/modules/QrLib/qrgen.js index dbfa85c4..c8f7d580 100644 --- a/src/popup/modules/QrLib/qrgen.js +++ b/src/popup/modules/QrLib/qrgen.js @@ -106,6 +106,6 @@ export function getQr() { return getSvgElement(svgString); } catch (err) { throw (err === "Data too long") - ? QrError.DataOverflowError : err; + ? new QrError.DataOverflowError() : err; } } From 76399a7dcbb1e103901367436358d84ad6fc0fde Mon Sep 17 00:00:00 2001 From: rugk Date: Wed, 20 Mar 2019 17:33:07 +0800 Subject: [PATCH 17/20] Update src/_locales/en/messages.json Co-Authored-By: ongspxm --- src/_locales/en/messages.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index b657fb1b..39f0b278 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -81,7 +81,7 @@ "description": "Error shown when a permission request failed. This indicates a technical error and does NOT mean the user declined the permission." }, "errorQrCodeOverflow": { - "message": "Cannot generate QR code, the provided text is too much.", + "message": "Cannot generate QR code, the provided text is too long.", "description": "Error shown when QR code cannot be generated due to overflow in input size." }, "requestDownloadPermissionForQr": { From 45731beac5578c4a8d8f4c8a0387bfd7fa869b11 Mon Sep 17 00:00:00 2001 From: rugk Date: Wed, 20 Mar 2019 17:35:38 +0800 Subject: [PATCH 18/20] Update src/popup/modules/UserInterface.js Co-Authored-By: ongspxm --- src/popup/modules/UserInterface.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/popup/modules/UserInterface.js b/src/popup/modules/UserInterface.js index 53ef5695..ced7585b 100644 --- a/src/popup/modules/UserInterface.js +++ b/src/popup/modules/UserInterface.js @@ -113,7 +113,7 @@ const refreshQrCode = throttle(() => { QrCreator.setTextInternal(text); QrCreator.generate(); } catch (e) { - // Error thrown from qrcodegen & kjua wrapper when code too long + // error thrown from qrcodegen & kjua wrapper when text input is too long if (e instanceof QrError.DataOverflowError) { CommonMessages.showError("errorQrCodeOverflow"); console.error("Maximum size of QR code data exceeded with", text.length, "characters."); From 95c87dc5f92551b4a1dcf7d09433567ce9bf9417 Mon Sep 17 00:00:00 2001 From: ongspxm Date: Wed, 20 Mar 2019 17:36:32 +0800 Subject: [PATCH 19/20] update code style --- src/popup/modules/QrLib/QrError.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/popup/modules/QrLib/QrError.js b/src/popup/modules/QrLib/QrError.js index 513805d8..87d03bbe 100644 --- a/src/popup/modules/QrLib/QrError.js +++ b/src/popup/modules/QrLib/QrError.js @@ -5,9 +5,9 @@ */ export class DataOverflowError extends Error { - constructor(...rparams) { - let params = rparams.length>0 - ? rparams : ["The QR code was given too much data."]; - super(...params); + constructor(message, ...params) { + super( + message || "The QR code was given too much data.", + ...params); } } From f91faad5964cc92d1a029be1f27c5c43b78b5df6 Mon Sep 17 00:00:00 2001 From: rugk Date: Wed, 20 Mar 2019 23:09:28 +0800 Subject: [PATCH 20/20] Update src/popup/modules/QrLib/QrError.js Co-Authored-By: ongspxm --- src/popup/modules/QrLib/QrError.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/popup/modules/QrLib/QrError.js b/src/popup/modules/QrLib/QrError.js index 87d03bbe..ff2a1bf7 100644 --- a/src/popup/modules/QrLib/QrError.js +++ b/src/popup/modules/QrLib/QrError.js @@ -1,7 +1,7 @@ /** * Errors in QR code generation * - * @module QrLib/QrErrors + * @module QrLib/QrError */ export class DataOverflowError extends Error {