Comparing version 0.6.0 to 0.7.0
@@ -1,2 +0,2 @@ | ||
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.qrcodelib=t()}}(function(){return function t(e,r,n){function o(s,a){if(!r[s]){if(!e[s]){var f="function"==typeof require&&require;if(!a&&f)return f(s,!0);if(i)return i(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var l=r[s]={exports:{}};e[s][0].call(l.exports,function(t){var r=e[s][1][t];return o(r?r:t)},l,l.exports,t,e,r,n)}return r[s].exports}for(var i="function"==typeof require&&require,s=0;s<n.length;s++)o(n[s]);return o}({1:[function(t,e,r){var n=t("./utils").getSymbolSize;r.getRowColCoords=function(t){if(1===t)return[];for(var e=Math.floor(t/7)+2,r=n(t),o=145===r?26:2*Math.ceil((r-13)/(2*e-2)),i=[r-7],s=1;s<e-1;s++)i[s]=i[s-1]-o;return i.push(6),i.reverse()},r.getPositions=function(t){for(var e=[],n=r.getRowColCoords(t),o=n.length,i=0;i<o;i++)for(var s=0;s<o;s++)0===i&&0===s||0===i&&s===o-1||i===o-1&&0===s||e.push([n[i],n[s]]);return e}},{"./utils":15}],2:[function(t,e,r){function n(){this.buffer=[],this.length=0}n.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 r=0;r<e;r++)this.putBit(1===(t>>>e-r-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++}},e.exports=n},{}],3:[function(t,e,r){function n(t){if(!t||t<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=t,this.data=new o(t*t),this.data.fill(0),this.reservedBit=new o(t*t),this.reservedBit.fill(0)}var o=t("../utils/buffer");n.prototype.set=function(t,e,r,n){var o=t*this.size+e;this.data[o]=r,n&&(this.reservedBit[o]=!0)},n.prototype.get=function(t,e){return this.data[t*this.size+e]},n.prototype.xor=function(t,e,r){this.data[t*this.size+e]^=r},n.prototype.isReserved=function(t,e){return this.reservedBit[t*this.size+e]},e.exports=n},{"../utils/buffer":20}],4:[function(t,e,r){function n(t){this.mode=i.BYTE,this.data=new o(t)}var o=t("../utils/buffer"),i=t("./mode");n.getCharCountIndicator=function(t){if(t>=1&&t<10)return 8;if(t>=10&&t<41)return 16;throw new Error("version: "+t)},n.prototype={getLength:function(t){return this.data.length},append:function(t){return this.data=o.concat([this.data,new o(t)]),this},write:function(t){for(var e=0,r=this.data.length;e<r;e++)t.put(this.data[e],8)},getCharCountIndicator:n.getCharCountIndicator},e.exports=n},{"../utils/buffer":20,"./mode":11}],5:[function(t,e,r){var n=t("./error-correction-level"),o=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],i=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];r.getBlocksCount=function(t,e){switch(e){case n.L:return o[4*(t-1)+0];case n.M:return o[4*(t-1)+1];case n.Q:return o[4*(t-1)+2];case n.H:return o[4*(t-1)+3];default:return}},r.getTotalCodewordsCount=function(t,e){switch(e){case n.L:return i[4*(t-1)+0];case n.M:return i[4*(t-1)+1];case n.Q:return i[4*(t-1)+2];case n.H:return i[4*(t-1)+3];default:return}}},{"./error-correction-level":6}],6:[function(t,e,r){e.exports={L:1,M:0,Q:3,H:2}},{}],7:[function(t,e,r){var n=t("./utils").getSymbolSize,o=7;r.getPositions=function(t){var e=n(t);return[[0,0],[e-o,0],[0,e-o]]}},{"./utils":15}],8:[function(t,e,r){var n=t("./utils"),o=1335,i=21522,s=n.getBCHDigit(o);r.getEncodedBits=function(t,e){for(var r=t<<3|e,a=r<<10;n.getBCHDigit(a)-s>=0;)a^=o<<n.getBCHDigit(a)-s;return(r<<10|a)^i}},{"./utils":15}],9:[function(t,e,r){var n=t("../utils/buffer"),o=new n(512),i=new n(256);!function(){for(var t=1,e=0;e<255;e++)o[e]=t,i[t]=e,t<<=1,256&t&&(t^=285);for(e=255;e<512;e++)o[e]=o[e-255]}(),r.log=function(t){if(t<1)throw new Error("log("+t+")");return i[t]},r.exp=function(t){return o[t]},r.mul=function(t,e){return 0===t||0===e?0:o[i[t]+i[e]]}},{"../utils/buffer":20}],10:[function(t,e,r){function n(t){for(var e=t.size,r=0,n=0;n<e;n++)for(var o=0;o<e;o++){for(var i=0,s=t.get(n,o),a=-1;a<=1;a++)if(!(n+a<0||e<=n+a))for(var u=-1;u<=1;u++)o+u<0||e<=o+u||0===a&&0===u||s===t.get(n+a,o+u)&&i++;i>5&&(r+=f.N1+i-5)}return r}function o(t){for(var e=t.size,r=0,n=0;n<e-1;n++)for(var o=0;o<e-1;o++){var i=0;t.get(n,o)&&i++,t.get(n+1,o)&&i++,t.get(n,o+1)&&i++,t.get(n+1,o+1)&&i++,0!==i&&4!==i||(r+=f.N2)}return r}function i(t){var e,r,n=t.size,o=0;for(e=0;e<n;e++)for(r=0;r<n-6;r++)t.get(e,r)&&!t.get(e,r+1)&&t.get(e,r+2)&&t.get(e,r+3)&&t.get(e,r+4)&&!t.get(e,r+5)&&t.get(e,r+6)&&(o+=f.N3);for(r=0;r<n;r++)for(e=0;e<n-6;e++)t.get(e,r)&&!t.get(e+1,r)&&t.get(e+2,r)&&t.get(e+3,r)&&t.get(e+4,r)&&!t.get(e+5,r)&&t.get(e+6,r)&&(o+=f.N3);return o}function s(t){for(var e=0,r=t.size,n=0;n<r;n++)for(var o=0;o<r;o++)t.get(o,n)&&e++;var i=Math.abs(100*e/r/r-50)/5;return i*f.N4}function a(t,e,n){switch(t){case r.Patterns.PATTERN000:return(e+n)%2===0;case r.Patterns.PATTERN001:return e%2===0;case r.Patterns.PATTERN010:return n%3===0;case r.Patterns.PATTERN011:return(e+n)%3===0;case r.Patterns.PATTERN100:return(Math.floor(e/2)+Math.floor(n/3))%2===0;case r.Patterns.PATTERN101:return e*n%2+e*n%3===0;case r.Patterns.PATTERN110:return(e*n%2+e*n%3)%2===0;case r.Patterns.PATTERN111:return(e*n%3+(e+n)%2)%2===0;default:throw new Error("bad maskPattern:"+t)}}r.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var f={N1:3,N2:3,N3:40,N4:10};r.applyMask=function(t,e){for(var r=e.size,n=0;n<r;n++)for(var o=0;o<r;o++)e.isReserved(o,n)||e.xor(o,n,a(t,o,n))},r.getBestMask=function(t){for(var e=Object.keys(r.Patterns).length,a=0,f=1/0,u=0;u<e;u++){r.applyMask(u,t);var l=n(t)+o(t)+i(t)+s(t);r.applyMask(u,t),l<f&&(f=l,a=u)}return a}},{}],11:[function(t,e,r){e.exports={NUMERIC:1,ALPHA_NUM:2,BYTE:4,KANJI:8}},{}],12:[function(t,e,r){var n=t("../utils/buffer"),o=t("./galois-field");r.mul=function(t,e){var r=new n(t.length+e.length-1);r.fill(0);for(var i=0;i<t.length;i++)for(var s=0;s<e.length;s++)r[i+s]^=o.mul(t[i],e[s]);return r},r.mod=function(t,e){for(var r=new n(t);r.length-e.length>=0;){for(var i=r[0],s=0;s<e.length;s++)r[s]^=o.mul(e[s],i);for(var a=0;a<r.length&&0===r[a];)a++;r=r.slice(a)}return r},r.generateECPolynomial=function(t){for(var e=new n([1]),i=0;i<t;i++)e=r.mul(e,[1,o.exp(i)]);return e}},{"../utils/buffer":20,"./galois-field":9}],13:[function(t,e,r){function n(t,e){for(var r=t.size,n=m.getPositions(e),o=0;o<n.length;o++)for(var i=n[o][0],s=n[o][1],a=-1;a<=7;a++)if(!(i+a<=-1||r<=i+a))for(var f=-1;f<=7;f++)s+f<=-1||r<=s+f||(a>=0&&a<=6&&(0===f||6===f)||f>=0&&f<=6&&(0===a||6===a)||a>=2&&a<=4&&f>=2&&f<=4?t.set(i+a,s+f,!0,!0):t.set(i+a,s+f,!1,!0))}function o(t){for(var e=t.size,r=8;r<e-8;r++){var n=r%2===0;t.set(r,6,n,!0),t.set(6,r,n,!0)}}function i(t,e){for(var r=w.getPositions(e),n=0;n<r.length;n++)for(var o=r[n][0],i=r[n][1],s=-2;s<=2;s++)for(var a=-2;a<=2;a++)s===-2||2===s||a===-2||2===a||0===s&&0===a?t.set(o+s,i+a,!0,!0):t.set(o+s,i+a,!1,!0)}function s(t,e,r){for(var n,o,i,s=t.size,a=B.getEncodedBits(e),f=0;f<18;f++)n=Math.floor(f/3),o=f%3+s-8-3,i=!r&&1===(a>>f&1),t.set(n,o,i,!0),t.set(o,n,i,!0)}function a(t,e,r,n){var o,i,s=t.size,a=A.getEncodedBits(e,r);for(o=0;o<15;o++)i=!n&&1===(a>>o&1),o<6?t.set(o,8,i,!0):o<8?t.set(o+1,8,i,!0):t.set(s-15+o,8,i,!0),o<8?t.set(8,s-o-1,i,!0):o<9?t.set(8,15-o-1+1,i,!0):t.set(8,15-o-1,i,!0);t.set(s-8,8,!n,!0)}function f(t,e){for(var r=t.size,n=-1,o=r-1,i=7,s=0,a=r-1;a>0;a-=2)for(6===a&&a--;;){for(var f=0;f<2;f++)if(!t.isReserved(o,a-f)){var u=!1;s<e.length&&(u=1===(e[s]>>>i&1)),t.set(o,a-f,u),i--,i===-1&&(s++,i=7)}if(o+=n,o<0||r<=o){o-=n,n=-n;break}}}function u(t,e,r){var n=new p;n.put(r.mode,4),n.put(r.getLength(),r.getCharCountIndicator(t)),r.write(n);var o=d.getSymbolTotalCodewords(t),i=C.getTotalCodewordsCount(t,e),s=8*(o-i);for(n.getLengthInBits()+4<=s&&n.put(0,4);n.getLengthInBits()%8!==0;)n.putBit(0);for(var a=(s-n.getLengthInBits())/8,f=0;f<a;f++)n.put(f%2?17:236,8);return l(n,t,e)}function l(t,e,r){for(var n=d.getSymbolTotalCodewords(e),o=C.getTotalCodewordsCount(e,r),i=n-o,s=C.getBlocksCount(e,r),a=n%s,f=s-a,u=Math.floor(n/s),l=Math.floor(i/s),h=l+1,g=u-l,v=new E(g),p=0,y=new Array(s),w=new Array(s),m=0,b=new c(t.buffer),B=0;B<s;B++){var A=B<f?l:h;y[B]=b.slice(p,p+A),w[B]=v.encode(y[B]),p+=A,m=Math.max(m,A)}var T,R,P=new c(n),M=0;for(T=0;T<m;T++)for(R=0;R<s;R++)T<y[R].length&&(P[M++]=y[R][T]);for(T=0;T<g;T++)for(R=0;R<s;R++)T<w[R].length&&(P[M++]=w[R][T]);return P}function h(t,e){this.version=t,this.errorCorrectionLevel=e,this.modules=null,this.moduleCount=0,this.dataCache=null,this.data=null}var c=t("../utils/buffer"),d=t("./utils"),g=t("./error-correction-level"),v=t("./byte-data"),p=t("./bit-buffer"),y=t("./bit-matrix"),w=t("./alignment-pattern"),m=t("./finder-pattern"),b=t("./mask-pattern"),C=t("./error-correction-code"),E=t("./reed-solomon-encoder"),B=t("./version"),A=t("./format-info");e.exports=h,h.prototype.addData=function(t){this.data?this.data.append(t):this.data=new v(t),this.dataCache=null},h.prototype.isDark=function(t,e){if(t<0||this.moduleCount<=t||e<0||this.moduleCount<=e)throw new Error(t+","+e);return this.modules.get(t,e)},h.prototype.getModuleCount=function(){return this.moduleCount},h.prototype.make=function(){if(null===this.dataCache){"undefined"==typeof this.errorCorrectionLevel&&(this.errorCorrectionLevel=g.H);var t=B.getBestVersionForData(this.data,this.errorCorrectionLevel);if(!t)throw new Error("The amount of data is too big to be stored in a QR Code");if(this.version){if(this.version<t)throw new Error("\nThe chosen QR Code version cannot contain this amount of data.\nMax characters allowed with current config: "+B.getCapacity(this.version,this.errorCorrectionLevel)+"\nMinimum version required to store current data: "+t+"\n")}else this.version=t;this.dataCache=u(this.version,this.errorCorrectionLevel,this.data)}this.moduleCount=d.getSymbolSize(this.version),this.modules=new y(this.moduleCount),n(this.modules,this.version),o(this.modules),i(this.modules,this.version),a(this.modules,this.errorCorrectionLevel,0,!0),this.version>=7&&s(this.modules,this.version,!0),f(this.modules,this.dataCache);var e=b.getBestMask(this.modules);b.applyMask(e,this.modules),a(this.modules,this.errorCorrectionLevel,e),this.version>=7&&s(this.modules,this.version)}},{"../utils/buffer":20,"./alignment-pattern":1,"./bit-buffer":2,"./bit-matrix":3,"./byte-data":4,"./error-correction-code":5,"./error-correction-level":6,"./finder-pattern":7,"./format-info":8,"./mask-pattern":10,"./reed-solomon-encoder":14,"./utils":15,"./version":16}],14:[function(t,e,r){function n(t){this.genPoly=void 0,this.degree=t,this.degree&&this.initialize(this.degree)}var o=t("../utils/buffer"),i=t("./polynomial");n.prototype.initialize=function(t){this.degree=t,this.genPoly=i.generateECPolynomial(this.degree)},n.prototype.encode=function(t){if(!this.genPoly)throw new Error("Encoder not initialized");var e=new o(this.degree);e.fill(0);var r=o.concat([t,e],t.length+this.degree),n=i.mod(r,this.genPoly),s=this.degree-n.length;if(s>0){var a=new o(this.degree);return a.fill(0),n.copy(a,s),a}return n},e.exports=n},{"../utils/buffer":20,"./polynomial":12}],15:[function(t,e,r){var n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];r.getSymbolSize=function(t){if(!t)throw new Error('"version" cannot be null or undefined');if(t<1||t>40)throw new Error('"version" should be in range from 1 to 40');return 4*t+17},r.getSymbolTotalCodewords=function(t){return n[t]},r.getBCHDigit=function(t){for(var e=0;0!==t;)e++,t>>>=1;return e}},{}],16:[function(t,e,r){var n=t("../utils/buffer"),o=t("./utils"),i=t("./error-correction-code"),s=t("./error-correction-level"),a=t("./byte-data"),f=7973,u=o.getBCHDigit(f),l=function(t,e){for(var n=1;n<=40;n++)if(t<=r.getCapacity(n,e))return n};r.isValidVersion=function(t){return!isNaN(t)&&t>=1&&t<=40},r.getCapacity=function(t,e){if(!r.isValidVersion(t))throw new Error("Invalid QR Code version");var n=o.getSymbolTotalCodewords(t),s=i.getTotalCodewordsCount(t,e),f=8*(n-s),u=a.getCharCountIndicator(t)+4;return Math.floor((f-u)/8)},r.getBestVersionForData=function(t,e){var r;r=t instanceof a?t.getLength():n.isBuffer(t)?t.length:new n(t).length;var o=e;return"undefined"==typeof o&&(o=s.H),l(r,o)},r.getEncodedBits=function(t){if(!r.isValidVersion(t)||t<7)throw new Error("Invalid QR Code version");for(var e=t<<12;o.getBCHDigit(e)-u>=0;)e^=f<<o.getBCHDigit(e)-u;return t<<12|e}},{"../utils/buffer":20,"./byte-data":4,"./error-correction-code":5,"./error-correction-level":6,"./utils":15}],17:[function(t,e,r){var n=t("./renderer/qrcode-draw.js");n.qrcodedraw=n.QRCodeDraw,e.exports=n},{"./renderer/qrcode-draw.js":18}],18:[function(t,e,r){function n(){}var o=t("../core/qrcode"),i=t("../core/error-correction-level");r.QRCodeDraw=n,r.QRErrorCorrectLevel=i,r.QRCode=o,n.prototype={scale:4,defaultMargin:20,marginScaleFactor:5,color:{dark:"black",light:"white"},QRErrorCorrectLevel:i,draw:function(t,e,r,n){var i,s=Array.prototype.slice.call(arguments);if(n=s.pop(),t=s.shift(),e=s.shift(),r=s.shift()||{},"function"!=typeof n)throw new Error("callback required");"object"!=typeof r&&(r.errorCorrectLevel=r),this.scale=r.scale||this.scale,this.margin="undefined"==typeof r.margin?this.defaultMargin:r.margin;try{var a=new o(r.version,r.errorCorrectLevel),f=this.scale||4,u=t.getContext("2d"),l=0;a.addData(e),a.make();var h=this.marginWidth(),c=h;l=this.dataWidth(a)+2*h,this.resetCanvas(t,u,l);for(var d=0,g=a.getModuleCount();d<g;d++){for(var v=h,p=0,y=a.getModuleCount();p<y;p++)a.isDark(d,p)?(u.fillStyle=this.color.dark,u.fillRect(v,c,f,f)):this.color.light&&(u.fillStyle=this.color.light,u.fillRect(v,c,f,f)),v+=f;c+=f}}catch(t){i=t}n(i,t,l)},drawBitArray:function(){var t,e=Array.prototype.slice.call(arguments),r=e.pop(),n=e.shift(),i=e.shift()||{};if("function"!=typeof r)throw new Error("callback required as last argument");try{var s,a=new o(i.version,i.errorCorrectLevel),f=0,u=0;a.addData(n),a.make(),f=this.dataWidth(a,1),s=new Array(f*f);for(var l=0,h=a.getModuleCount();l<h;l++)for(var c=0,d=a.getModuleCount();c<d;c++)a.isDark(l,c)?s[u]=1:s[u]=0,u++}catch(e){t=e,console.log(e.stack)}r(t,s,f)},marginWidth:function(){var t=this.margin;return this.scale=this.scale||4,this.scale*this.marginScaleFactor>t&&t>0&&(t=this.scale*this.marginScaleFactor),t},dataWidth:function(t,e){return t.getModuleCount()*(e||this.scale||4)},resetCanvas:function(t,e,r){e.clearRect(0,0,t.width,t.height),t.style||(t.style={}),t.style.height=t.height=r,t.style.width=t.width=r,this.color.light?(e.fillStyle=this.color.light,e.fillRect(0,0,t.width,t.height)):e.clearRect(0,0,t.width,t.height)}}},{"../core/error-correction-level":6,"../core/qrcode":13}],19:[function(t,e,r){e.exports=Array.isArray||function(t){return"[object Array]"==={}.toString.call(t)}},{}],20:[function(t,e,r){"use strict";function n(t,e,r){return"number"==typeof t?a(t):p(t,e,r)}function o(t){if(t>=w)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+w.toString(16)+" bytes");return 0|t}function i(t){return t!==t}function s(t){var e=new Uint8Array(t);return e.__proto__=n.prototype,e}function a(t){return s(t<0?0:0|o(t))}function f(t){var e=0|d(t),r=s(e),n=r.write(t);return n!==e&&(r=r.slice(0,n)),r}function u(t){for(var e=t.length<0?0:0|o(t.length),r=s(e),n=0;n<e;n+=1)r[n]=255&t[n];return r}function l(t,e,r){if(t.byteLength,e<0||t.byteLength<e)throw new RangeError("'offset' is out of bounds");if(t.byteLength<e+(r||0))throw new RangeError("'length' is out of bounds");var o;return o=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),o.__proto__=n.prototype,o}function h(t){if(n.isBuffer(t)){var e=0|o(t.length),r=s(e);return 0===r.length?r:(t.copy(r,0,0,e),r)}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||i(t.length)?s(0):u(t);if("Buffer"===t.type&&Array.isArray(t.data))return u(t.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function c(t,e){e=e||1/0;for(var r,n=t.length,o=null,i=[],s=0;s<n;++s){if(r=t.charCodeAt(s),r>55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=(o-55296<<10|r-56320)+65536}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function d(t){if(n.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var e=t.length;return 0===e?0:c(t).length}function g(t,e,r,n){for(var o=0;o<n&&!(o+r>=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function v(t,e,r,n){return g(c(e,t.length-r),t,r,n)}function p(t,e,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?l(t,e,r):"string"==typeof t?f(t,e):h(t)}var y=t("./is-array"),w=2147483647;n.prototype.__proto__=Uint8Array.prototype,n.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&n[Symbol.species]===n&&Object.defineProperty(n,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),n.prototype.write=function(t,e,r){void 0===e?(r=this.length,e=0):void 0===r&&"string"==typeof e?(r=this.length,e=0):isFinite(e)&&(e|=0,isFinite(r)?r|=0:r=void 0);var n=this.length-e;if((void 0===r||r>n)&&(r=n),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");return v(this,t,e,r)},n.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r,t<0&&(t=0)):t>r&&(t=r),e<0?(e+=r,e<0&&(e=0)):e>r&&(e=r),e<t&&(e=t);var o=this.subarray(t,e);return o.__proto__=n.prototype,o},n.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);var o,i=n-r;if(this===t&&r<e&&e<n)for(o=i-1;o>=0;--o)t[o+e]=this[o+r];else if(i<1e3)for(o=0;o<i;++o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+i),e);return i},n.prototype.fill=function(t,e,r){if("string"==typeof t){if("string"==typeof e?(e=0,r=this.length):"string"==typeof r&&(r=this.length),1===t.length){var o=t.charCodeAt(0);o<256&&(t=o)}}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0);var i;if("number"==typeof t)for(i=e;i<r;++i)this[i]=t;else{var s=n.isBuffer(t)?t:new n(t),a=s.length;for(i=0;i<r-e;++i)this[i+e]=s[i%a]}return this},n.concat=function(t,e){if(!y(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return s(null,0);var r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var o=a(e),i=0;for(r=0;r<t.length;++r){var f=t[r];if(!n.isBuffer(f))throw new TypeError('"list" argument must be an Array of Buffers');f.copy(o,i),i+=f.length}return o},n.byteLength=d,n.prototype._isBuffer=!0,n.isBuffer=function(t){return!(null==t||!t._isBuffer)},e.exports=n},{"./is-array":19}]},{},[17])(17)}); | ||
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.qrcodelib=t()}}(function(){return function t(e,r,n){function o(a,s){if(!r[a]){if(!e[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(i)return i(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var c=r[a]={exports:{}};e[a][0].call(c.exports,function(t){var r=e[a][1][t];return o(r?r:t)},c,c.exports,t,e,r,n)}return r[a].exports}for(var i="function"==typeof require&&require,a=0;a<n.length;a++)o(n[a]);return o}({1:[function(t,e,r){var n=t("./utils").getSymbolSize;r.getRowColCoords=function(t){if(1===t)return[];for(var e=Math.floor(t/7)+2,r=n(t),o=145===r?26:2*Math.ceil((r-13)/(2*e-2)),i=[r-7],a=1;a<e-1;a++)i[a]=i[a-1]-o;return i.push(6),i.reverse()},r.getPositions=function(t){for(var e=[],n=r.getRowColCoords(t),o=n.length,i=0;i<o;i++)for(var a=0;a<o;a++)0===i&&0===a||0===i&&a===o-1||i===o-1&&0===a||e.push([n[i],n[a]]);return e}},{"./utils":20}],2:[function(t,e,r){function n(t){this.mode=o.ALPHANUMERIC,this.data=t}var o=t("./mode"),i=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];n.getBitsLength=function(t){return 11*Math.floor(t/2)+6*(t%2)},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(t){var e;for(e=0;e+2<=this.data.length;e+=2){var r=45*i.indexOf(this.data[e]);r+=i.indexOf(this.data[e+1]),t.put(r,11)}this.data.length%2&&t.put(i.indexOf(this.data[e]),6)},e.exports=n},{"./mode":13}],3:[function(t,e,r){function n(){this.buffer=[],this.length=0}n.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 r=0;r<e;r++)this.putBit(1===(t>>>e-r-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++}},e.exports=n},{}],4:[function(t,e,r){function n(t){if(!t||t<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=t,this.data=new o(t*t),this.data.fill(0),this.reservedBit=new o(t*t),this.reservedBit.fill(0)}var o=t("../utils/buffer");n.prototype.set=function(t,e,r,n){var o=t*this.size+e;this.data[o]=r,n&&(this.reservedBit[o]=!0)},n.prototype.get=function(t,e){return this.data[t*this.size+e]},n.prototype.xor=function(t,e,r){this.data[t*this.size+e]^=r},n.prototype.isReserved=function(t,e){return this.reservedBit[t*this.size+e]},e.exports=n},{"../utils/buffer":25}],5:[function(t,e,r){function n(t){this.mode=i.BYTE,this.data=new o(t)}var o=t("../utils/buffer"),i=t("./mode");n.getBitsLength=function(t){return 8*t},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(t){for(var e=0,r=this.data.length;e<r;e++)t.put(this.data[e],8)},e.exports=n},{"../utils/buffer":25,"./mode":13}],6:[function(t,e,r){var n=t("./error-correction-level"),o=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],i=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];r.getBlocksCount=function(t,e){switch(e){case n.L:return o[4*(t-1)+0];case n.M:return o[4*(t-1)+1];case n.Q:return o[4*(t-1)+2];case n.H:return o[4*(t-1)+3];default:return}},r.getTotalCodewordsCount=function(t,e){switch(e){case n.L:return i[4*(t-1)+0];case n.M:return i[4*(t-1)+1];case n.Q:return i[4*(t-1)+2];case n.H:return i[4*(t-1)+3];default:return}}},{"./error-correction-level":7}],7:[function(t,e,r){function n(t){if("string"!=typeof t)throw new Error("Param is not a string");var e=t.toLowerCase();switch(e){case"l":case"low":return r.L;case"m":case"medium":return r.M;case"q":case"quartile":return r.Q;case"h":case"high":return r.H;default:throw new Error("Unknown EC Level: "+t)}}r.L={bit:1},r.M={bit:0},r.Q={bit:3},r.H={bit:2},r.isValid=function(t){return t&&"undefined"!=typeof t.bit&&t.bit>=0&&t.bit<4},r.from=function(t,e){if(r.isValid(t))return t;try{return n(t)}catch(t){return e}}},{}],8:[function(t,e,r){var n=t("./utils").getSymbolSize,o=7;r.getPositions=function(t){var e=n(t);return[[0,0],[e-o,0],[0,e-o]]}},{"./utils":20}],9:[function(t,e,r){var n=t("./utils"),o=1335,i=21522,a=n.getBCHDigit(o);r.getEncodedBits=function(t,e){for(var r=t.bit<<3|e,s=r<<10;n.getBCHDigit(s)-a>=0;)s^=o<<n.getBCHDigit(s)-a;return(r<<10|s)^i}},{"./utils":20}],10:[function(t,e,r){var n=t("../utils/buffer"),o=new n(512),i=new n(256);!function(){for(var t=1,e=0;e<255;e++)o[e]=t,i[t]=e,t<<=1,256&t&&(t^=285);for(e=255;e<512;e++)o[e]=o[e-255]}(),r.log=function(t){if(t<1)throw new Error("log("+t+")");return i[t]},r.exp=function(t){return o[t]},r.mul=function(t,e){return 0===t||0===e?0:o[i[t]+i[e]]}},{"../utils/buffer":25}],11:[function(t,e,r){function n(t){this.mode=o.KANJI,this.data=t}var o=t("./mode"),i=t("./utils");n.getBitsLength=function(t){return 13*t},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(t){var e;for(e=0;e<this.data.length;e++){var r=i.toSJIS(this.data[e]);if(r>=33088&&r<=40956)r-=33088;else{if(!(r>=57408&&r<=60351))throw new Error("Invalid SJIS character: "+this.data[e]+"\nMake sure your charset is UTF-8");r-=49472}r=192*(r>>>8&255)+(255&r),t.put(r,13)}},e.exports=n},{"./mode":13,"./utils":20}],12:[function(t,e,r){function n(t){for(var e=t.size,r=0,n=0;n<e;n++)for(var o=0;o<e;o++){for(var i=0,a=t.get(n,o),s=-1;s<=1;s++)if(!(n+s<0||e<=n+s))for(var f=-1;f<=1;f++)o+f<0||e<=o+f||0===s&&0===f||a===t.get(n+s,o+f)&&i++;i>5&&(r+=u.N1+i-5)}return r}function o(t){for(var e=t.size,r=0,n=0;n<e-1;n++)for(var o=0;o<e-1;o++){var i=0;t.get(n,o)&&i++,t.get(n+1,o)&&i++,t.get(n,o+1)&&i++,t.get(n+1,o+1)&&i++,0!==i&&4!==i||(r+=u.N2)}return r}function i(t){var e,r,n=t.size,o=0;for(e=0;e<n;e++)for(r=0;r<n-6;r++)t.get(e,r)&&!t.get(e,r+1)&&t.get(e,r+2)&&t.get(e,r+3)&&t.get(e,r+4)&&!t.get(e,r+5)&&t.get(e,r+6)&&(o+=u.N3);for(r=0;r<n;r++)for(e=0;e<n-6;e++)t.get(e,r)&&!t.get(e+1,r)&&t.get(e+2,r)&&t.get(e+3,r)&&t.get(e+4,r)&&!t.get(e+5,r)&&t.get(e+6,r)&&(o+=u.N3);return o}function a(t){for(var e=0,r=t.size,n=0;n<r;n++)for(var o=0;o<r;o++)t.get(o,n)&&e++;var i=Math.abs(100*e/r/r-50)/5;return i*u.N4}function s(t,e,n){switch(t){case r.Patterns.PATTERN000:return(e+n)%2===0;case r.Patterns.PATTERN001:return e%2===0;case r.Patterns.PATTERN010:return n%3===0;case r.Patterns.PATTERN011:return(e+n)%3===0;case r.Patterns.PATTERN100:return(Math.floor(e/2)+Math.floor(n/3))%2===0;case r.Patterns.PATTERN101:return e*n%2+e*n%3===0;case r.Patterns.PATTERN110:return(e*n%2+e*n%3)%2===0;case r.Patterns.PATTERN111:return(e*n%3+(e+n)%2)%2===0;default:throw new Error("bad maskPattern:"+t)}}r.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var u={N1:3,N2:3,N3:40,N4:10};r.applyMask=function(t,e){for(var r=e.size,n=0;n<r;n++)for(var o=0;o<r;o++)e.isReserved(o,n)||e.xor(o,n,s(t,o,n))},r.getBestMask=function(t){for(var e=Object.keys(r.Patterns).length,s=0,u=1/0,f=0;f<e;f++){r.applyMask(f,t);var c=n(t)+o(t)+i(t)+a(t);r.applyMask(f,t),c<u&&(u=c,s=f)}return s}},{}],13:[function(t,e,r){function n(t){if("string"!=typeof t)throw new Error("Param is not a string");var e=t.toLowerCase();switch(e){case"numeric":return r.NUMERIC;case"alphanumeric":return r.ALPHANUMERIC;case"kanji":return r.KANJI;case"byte":return r.BYTE;default:throw new Error("Unknown mode: "+t)}}var o=t("./version"),i=t("./regex");r.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},r.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},r.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},r.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},r.MIXED={bit:-1},r.getCharCountIndicator=function(t,e){if(!t.ccBits)throw new Error("Invalid mode: "+t);if(!o.isValid(e))throw new Error("Invalid version: "+e);return e>=1&&e<10?t.ccBits[0]:e<27?t.ccBits[1]:t.ccBits[2]},r.getBestModeForData=function(t){return i.testNumeric(t)?r.NUMERIC:i.testAlphanumeric(t)?r.ALPHANUMERIC:i.testKanji(t)?r.KANJI:r.BYTE},r.toString=function(t){if(t&&t.id)return t.id;throw new Error("Invalid mode")},r.isValid=function(t){return t&&t.bit&&t.ccBits},r.from=function(t,e){if(r.isValid(t))return t;try{return n(t)}catch(t){return e}}},{"./regex":18,"./version":21}],14:[function(t,e,r){function n(t){this.mode=o.NUMERIC,this.data=t.toString()}var o=t("./mode");n.getBitsLength=function(t){return 10*Math.floor(t/3)+(t%3?t%3*3+1:0)},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(t){var e,r,n;for(e=0;e+3<=this.data.length;e+=3)r=this.data.substr(e,3),n=parseInt(r,10),t.put(n,10);var o=this.data.length-e;o>0&&(r=this.data.substr(e),n=parseInt(r,10),t.put(n,3*o+1))},e.exports=n},{"./mode":13}],15:[function(t,e,r){var n=t("../utils/buffer"),o=t("./galois-field");r.mul=function(t,e){var r=new n(t.length+e.length-1);r.fill(0);for(var i=0;i<t.length;i++)for(var a=0;a<e.length;a++)r[i+a]^=o.mul(t[i],e[a]);return r},r.mod=function(t,e){for(var r=new n(t);r.length-e.length>=0;){for(var i=r[0],a=0;a<e.length;a++)r[a]^=o.mul(e[a],i);for(var s=0;s<r.length&&0===r[s];)s++;r=r.slice(s)}return r},r.generateECPolynomial=function(t){for(var e=new n([1]),i=0;i<t;i++)e=r.mul(e,[1,o.exp(i)]);return e}},{"../utils/buffer":25,"./galois-field":10}],16:[function(t,e,r){function n(t,e){for(var r=t.size,n=m.getPositions(e),o=0;o<n.length;o++)for(var i=n[o][0],a=n[o][1],s=-1;s<=7;s++)if(!(i+s<=-1||r<=i+s))for(var u=-1;u<=7;u++)a+u<=-1||r<=a+u||(s>=0&&s<=6&&(0===u||6===u)||u>=0&&u<=6&&(0===s||6===s)||s>=2&&s<=4&&u>=2&&u<=4?t.set(i+s,a+u,!0,!0):t.set(i+s,a+u,!1,!0))}function o(t){for(var e=t.size,r=8;r<e-8;r++){var n=r%2===0;t.set(r,6,n,!0),t.set(6,r,n,!0)}}function i(t,e){for(var r=w.getPositions(e),n=0;n<r.length;n++)for(var o=r[n][0],i=r[n][1],a=-2;a<=2;a++)for(var s=-2;s<=2;s++)a===-2||2===a||s===-2||2===s||0===a&&0===s?t.set(o+a,i+s,!0,!0):t.set(o+a,i+s,!1,!0)}function a(t,e,r){for(var n,o,i,a=t.size,s=A.getEncodedBits(e),u=0;u<18;u++)n=Math.floor(u/3),o=u%3+a-8-3,i=!r&&1===(s>>u&1),t.set(n,o,i,!0),t.set(o,n,i,!0)}function s(t,e,r,n){var o,i,a=t.size,s=C.getEncodedBits(e,r);for(o=0;o<15;o++)i=!n&&1===(s>>o&1),o<6?t.set(o,8,i,!0):o<8?t.set(o+1,8,i,!0):t.set(a-15+o,8,i,!0),o<8?t.set(8,a-o-1,i,!0):o<9?t.set(8,15-o-1+1,i,!0):t.set(8,15-o-1,i,!0);t.set(a-8,8,!n,!0)}function u(t,e){for(var r=t.size,n=-1,o=r-1,i=7,a=0,s=r-1;s>0;s-=2)for(6===s&&s--;;){for(var u=0;u<2;u++)if(!t.isReserved(o,s-u)){var f=!1;a<e.length&&(f=1===(e[a]>>>i&1)),t.set(o,s-u,f),i--,i===-1&&(a++,i=7)}if(o+=n,o<0||r<=o){o-=n,n=-n;break}}}function f(t,e,r){var n=new v;r.forEach(function(e){n.put(e.mode.bit,4),n.put(e.getLength(),M.getCharCountIndicator(e.mode,t)),e.write(n)});var o=g.getSymbolTotalCodewords(t),i=b.getTotalCodewordsCount(t,e),a=8*(o-i);for(n.getLengthInBits()+4<=a&&n.put(0,4);n.getLengthInBits()%8!==0;)n.putBit(0);for(var s=(a-n.getLengthInBits())/8,u=0;u<s;u++)n.put(u%2?17:236,8);return c(n,t,e)}function c(t,e,r){for(var n=g.getSymbolTotalCodewords(e),o=b.getTotalCodewordsCount(e,r),i=n-o,a=b.getBlocksCount(e,r),s=n%a,u=a-s,f=Math.floor(n/a),c=Math.floor(i/a),h=c+1,l=f-c,p=new B(l),v=0,y=new Array(a),w=new Array(a),m=0,E=new d(t.buffer),A=0;A<a;A++){var C=A<u?c:h;y[A]=E.slice(v,v+C),w[A]=p.encode(y[A]),v+=C,m=Math.max(m,C)}var M,R,T=new d(n),N=0;for(M=0;M<m;M++)for(R=0;R<a;R++)M<y[R].length&&(T[N++]=y[R][M]);for(M=0;M<l;M++)for(R=0;R<a;R++)M<w[R].length&&(T[N++]=w[R][M]);return T}function h(t,e,r){var c;if(T(t))c=R.fromArray(t);else{if("string"!=typeof t)throw new Error("Invalid data");var h=e;if(!h){var l=R.rawSplit(t);h=A.getBestVersionForData(l,r)}c=R.fromString(t,h)}var d=A.getBestVersionForData(c,r);if(!d)throw new Error("The amount of data is too big to be stored in a QR Code");if(e){if(e<d)throw new Error("\nThe chosen QR Code version cannot contain this amount of data.\nMinimum version required to store current data is: "+d+".\n")}else e=d;var p=f(e,r,c),v=g.getSymbolSize(e),w=new y(v);n(w,e),o(w),i(w,e),s(w,r,0,!0),e>=7&&a(w,e,!0),u(w,p);var m=E.getBestMask(w);return E.applyMask(m,w),s(w,r,m),e>=7&&a(w,e),{data:w,version:e,errorCorrectionLevel:r,maskPattern:m}}function l(t,e){if("undefined"==typeof t||""===t)throw new Error("No input text");this.errorCorrectionLevel=p.M,this.version=void 0,"undefined"!=typeof e&&(this.errorCorrectionLevel=p.from(e.errorCorrectionLevel,p.M),this.version=A.from(e.version),e.toSJISFunc&&g.setToSJISFunction(e.toSJISFunc));var r=h(t,this.version,this.errorCorrectionLevel);this.version=r.version,this.modules=r.data}var d=t("../utils/buffer"),g=t("./utils"),p=t("./error-correction-level"),v=t("./bit-buffer"),y=t("./bit-matrix"),w=t("./alignment-pattern"),m=t("./finder-pattern"),E=t("./mask-pattern"),b=t("./error-correction-code"),B=t("./reed-solomon-encoder"),A=t("./version"),C=t("./format-info"),M=t("./mode"),R=t("./segments"),T=t("../utils/is-array");e.exports=l,l.prototype.isDark=function(t,e){var r=this.modules.size;if(t<0||r<=t||e<0||r<=e)throw new Error(t+","+e);return this.modules.get(t,e)},l.prototype.getModuleCount=function(){return this.modules.size}},{"../utils/buffer":25,"../utils/is-array":24,"./alignment-pattern":1,"./bit-buffer":3,"./bit-matrix":4,"./error-correction-code":6,"./error-correction-level":7,"./finder-pattern":8,"./format-info":9,"./mask-pattern":12,"./mode":13,"./reed-solomon-encoder":17,"./segments":19,"./utils":20,"./version":21}],17:[function(t,e,r){function n(t){this.genPoly=void 0,this.degree=t,this.degree&&this.initialize(this.degree)}var o=t("../utils/buffer"),i=t("./polynomial");n.prototype.initialize=function(t){this.degree=t,this.genPoly=i.generateECPolynomial(this.degree)},n.prototype.encode=function(t){if(!this.genPoly)throw new Error("Encoder not initialized");var e=new o(this.degree);e.fill(0);var r=o.concat([t,e],t.length+this.degree),n=i.mod(r,this.genPoly),a=this.degree-n.length;if(a>0){var s=new o(this.degree);return s.fill(0),n.copy(s,a),s}return n},e.exports=n},{"../utils/buffer":25,"./polynomial":15}],18:[function(t,e,r){var n="[0-9]+",o="[A-Z $%*+-./:]+",i="(?:[ -〿]|[-ゟ]|[゠-ヿ]|[-]|[一-龯]|[★-☆]|[←-↕]|※|[―‐∥…‥‘’“”≠]|[Α-ё]|[§¨±´×÷])+",a="(?:(?![A-Z0-9 $%*+-./:]|"+i+").)+";r.KANJI=new RegExp(i,"g"),r.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+-./:]+","g"),r.BYTE=new RegExp(a,"g"),r.NUMERIC=new RegExp(n,"g"),r.ALPHANUMERIC=new RegExp(o,"g");var s=new RegExp("^"+i+"$"),u=new RegExp("^"+n+"$"),f=new RegExp("^[A-Z0-9 $%*+-./:]+$");r.testKanji=function(t){return s.test(t)},r.testNumeric=function(t){return u.test(t)},r.testAlphanumeric=function(t){return f.test(t)}},{}],19:[function(t,e,r){function n(t){return unescape(encodeURIComponent(t)).length}function o(t,e,r){for(var n,o=[];null!==(n=t.exec(r));)o.push({data:n[0],index:n.index,mode:e,length:n[0].length});return o}function i(t){var e,r,n=o(v.NUMERIC,h.NUMERIC,t),i=o(v.ALPHANUMERIC,h.ALPHANUMERIC,t);y.isKanjiModeEnabled()?(e=o(v.BYTE,h.BYTE,t),r=o(v.KANJI,h.KANJI,t)):(e=o(v.BYTE_KANJI,h.BYTE,t),r=[]);var a=n.concat(i,e,r);return a.sort(function(t,e){return t.index-e.index}).map(function(t){return{data:t.data,mode:t.mode,length:t.length}})}function a(t,e){switch(e){case h.NUMERIC:return l.getBitsLength(t);case h.ALPHANUMERIC:return d.getBitsLength(t);case h.KANJI:return p.getBitsLength(t);case h.BYTE:return g.getBitsLength(t)}}function s(t){return t.reduce(function(t,e){var r=t.length-1>=0?t[t.length-1]:null;return r&&r.mode===e.mode?(t[t.length-1].data+=e.data,t):(t.push(e),t)},[])}function u(t){for(var e=[],r=0;r<t.length;r++){var o=t[r];switch(o.mode){case h.NUMERIC:e.push([o,{data:o.data,mode:h.ALPHANUMERIC,length:o.length},{data:o.data,mode:h.BYTE,length:o.length}]);break;case h.ALPHANUMERIC:e.push([o,{data:o.data,mode:h.BYTE,length:o.length}]);break;case h.KANJI:e.push([o,{data:o.data,mode:h.BYTE,length:n(o.data)}]);break;case h.BYTE:e.push([{data:o.data,mode:h.BYTE,length:n(o.data)}])}}return e}function f(t,e){for(var r={},n={start:{}},o=["start"],i=0;i<t.length;i++){for(var s=t[i],u=[],f=0;f<s.length;f++){var c=s[f],l=""+i+f;u.push(l),r[l]={node:c,lastCount:0},n[l]={};for(var d=0;d<o.length;d++){var g=o[d];r[g]&&r[g].node.mode===c.mode?(n[g][l]=a(r[g].lastCount+c.length,c.mode)-a(r[g].lastCount,c.mode),r[g].lastCount+=c.length):(r[g]&&(r[g].lastCount=c.length),n[g][l]=a(c.length,c.mode)+4+h.getCharCountIndicator(c.mode,e))}}o=u}for(d=0;d<o.length;d++)n[o[d]].end=0;return{map:n,table:r}}function c(t,e){var r,n=h.getBestModeForData(t);if(r=h.from(e,n),r!==h.BYTE&&r.bit<n.bit)throw new Error('"'+t+'" cannot be encoded with mode '+h.toString(r)+".\n Suggested mode is: "+h.toString(n));switch(r!==h.KANJI||y.isKanjiModeEnabled()||(r=h.BYTE),r){case h.NUMERIC:return new l(t);case h.ALPHANUMERIC:return new d(t);case h.KANJI:return new p(t);case h.BYTE:return new g(t)}}var h=t("./mode"),l=t("./numeric-data"),d=t("./alphanumeric-data"),g=t("./byte-data"),p=t("./kanji-data"),v=t("./regex"),y=t("./utils"),w=t("dijkstrajs");r.fromArray=function(t){return t.reduce(function(t,e){return"string"==typeof e?t.push(c(e,null)):e.data&&t.push(c(e.data,e.mode)),t},[])},r.fromString=function(t,e){for(var n=i(t,y.isKanjiModeEnabled()),o=u(n),a=f(o,e),c=w.find_path(a.map,"start","end"),h=[],l=1;l<c.length-1;l++)h.push(a.table[c[l]].node);return r.fromArray(s(h))},r.rawSplit=function(t){return r.fromArray(i(t,y.isKanjiModeEnabled()))}},{"./alphanumeric-data":2,"./byte-data":5,"./kanji-data":11,"./mode":13,"./numeric-data":14,"./regex":18,"./utils":20,dijkstrajs:26}],20:[function(t,e,r){var n,o=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];r.getSymbolSize=function(t){if(!t)throw new Error('"version" cannot be null or undefined');if(t<1||t>40)throw new Error('"version" should be in range from 1 to 40');return 4*t+17},r.getSymbolTotalCodewords=function(t){return o[t]},r.getBCHDigit=function(t){for(var e=0;0!==t;)e++,t>>>=1;return e},r.setToSJISFunction=function(t){if("function"!=typeof t)throw new Error('"toSJISFunc" is not a valid function.');n=t},r.isKanjiModeEnabled=function(){return"undefined"!=typeof n},r.toSJIS=function(t){return n(t)}},{}],21:[function(t,e,r){function n(t,e,n){for(var o=1;o<=40;o++)if(e<=r.getCapacity(o,n,t))return o}function o(t,e){return c.getCharCountIndicator(t,e)+4}function i(t,e){var r=0;return t.forEach(function(t){var n=o(t.mode,e);r+=n+t.getBitsLength()}),r}function a(t,e){for(var n=1;n<=40;n++){var o=i(t,n);if(o<=r.getCapacity(n,e,c.MIXED))return n}}var s=t("./utils"),u=t("./error-correction-code"),f=t("./error-correction-level"),c=t("./mode"),h=t("../utils/is-array"),l=7973,d=s.getBCHDigit(l);r.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40},r.from=function(t,e){return r.isValid(t)?parseInt(t,10):e},r.getCapacity=function(t,e,n){if(!r.isValid(t))throw new Error("Invalid QR Code version");"undefined"==typeof n&&(n=c.BYTE);var i=s.getSymbolTotalCodewords(t),a=u.getTotalCodewordsCount(t,e),f=8*(i-a);if(n===c.MIXED)return f;var h=f-o(n,t);switch(n){case c.NUMERIC:return Math.floor(h/10*3);case c.ALPHANUMERIC:return Math.floor(h/11*2);case c.KANJI:return Math.floor(h/13);case c.BYTE:default:return Math.floor(h/8)}},r.getBestVersionForData=function(t,e){var r,o=f.from(e,f.M);if(h(t)){if(t.length>1)return a(t,o);if(0===t.length)return 1;r=t[0]}else r=t;return n(r.mode,r.getLength(),o)},r.getEncodedBits=function(t){if(!r.isValid(t)||t<7)throw new Error("Invalid QR Code version");for(var e=t<<12;s.getBCHDigit(e)-d>=0;)e^=l<<s.getBCHDigit(e)-d;return t<<12|e}},{"../utils/is-array":24,"./error-correction-code":6,"./error-correction-level":7,"./mode":13,"./utils":20}],22:[function(t,e,r){var n=t("./renderer/qrcode-draw.js");n.qrcodedraw=n.QRCodeDraw,e.exports=n},{"./renderer/qrcode-draw.js":23}],23:[function(t,e,r){function n(){}var o=t("../core/qrcode"),i=t("../core/error-correction-level");r.QRCodeDraw=n,r.QRErrorCorrectLevel=i,r.QRCode=o,n.prototype={scale:4,defaultMargin:20,marginScaleFactor:5,color:{dark:"black",light:"white"},QRErrorCorrectLevel:i,draw:function(t,e,r,n){var i,a=Array.prototype.slice.call(arguments);if(n=a.pop(),t=a.shift(),e=a.shift(),r=a.shift()||{},"function"!=typeof n)throw new Error("callback required");"object"!=typeof r&&(r.errorCorrectionLevel=r),this.scale=r.scale||this.scale,this.margin="undefined"==typeof r.margin?this.defaultMargin:r.margin;try{var s=new o(e,r),u=this.scale||4,f=t.getContext("2d"),c=0,h=this.marginWidth(),l=h;c=this.dataWidth(s)+2*h,this.resetCanvas(t,f,c);for(var d=0,g=s.getModuleCount();d<g;d++){for(var p=h,v=0,y=s.getModuleCount();v<y;v++)s.isDark(d,v)?(f.fillStyle=this.color.dark,f.fillRect(p,l,u,u)):this.color.light&&(f.fillStyle=this.color.light,f.fillRect(p,l,u,u)),p+=u;l+=u}}catch(t){i=t}n(i,t,c)},drawBitArray:function(){var t,e=Array.prototype.slice.call(arguments),r=e.pop(),n=e.shift(),i=e.shift()||{};if("function"!=typeof r)throw new Error("callback required as last argument");try{var a,s=new o(n,i),u=0,f=0;u=this.dataWidth(s,1),a=new Array(u*u);for(var c=0,h=s.getModuleCount();c<h;c++)for(var l=0,d=s.getModuleCount();l<d;l++)s.isDark(c,l)?a[f]=1:a[f]=0,f++}catch(e){t=e,console.log(e.stack)}r(t,a,u)},marginWidth:function(){var t=this.margin;return this.scale=this.scale||4,this.scale*this.marginScaleFactor>t&&t>0&&(t=this.scale*this.marginScaleFactor),t},dataWidth:function(t,e){return t.getModuleCount()*(e||this.scale||4)},resetCanvas:function(t,e,r){e.clearRect(0,0,t.width,t.height),t.style||(t.style={}),t.style.height=t.height=r,t.style.width=t.width=r,this.color.light?(e.fillStyle=this.color.light,e.fillRect(0,0,t.width,t.height)):e.clearRect(0,0,t.width,t.height)}}},{"../core/error-correction-level":7,"../core/qrcode":16}],24:[function(t,e,r){e.exports=Array.isArray||function(t){return"[object Array]"==={}.toString.call(t)}},{}],25:[function(t,e,r){"use strict";function n(t,e,r){return"number"==typeof t?s(t):v(t,e,r)}function o(t){if(t>=w)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+w.toString(16)+" bytes");return 0|t}function i(t){return t!==t}function a(t){var e=new Uint8Array(t);return e.__proto__=n.prototype,e}function s(t){return a(t<0?0:0|o(t))}function u(t){var e=0|d(t),r=a(e),n=r.write(t);return n!==e&&(r=r.slice(0,n)),r}function f(t){for(var e=t.length<0?0:0|o(t.length),r=a(e),n=0;n<e;n+=1)r[n]=255&t[n];return r}function c(t,e,r){if(t.byteLength,e<0||t.byteLength<e)throw new RangeError("'offset' is out of bounds");if(t.byteLength<e+(r||0))throw new RangeError("'length' is out of bounds");var o;return o=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),o.__proto__=n.prototype,o}function h(t){if(n.isBuffer(t)){var e=0|o(t.length),r=a(e);return 0===r.length?r:(t.copy(r,0,0,e),r)}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||i(t.length)?a(0):f(t);if("Buffer"===t.type&&Array.isArray(t.data))return f(t.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function l(t,e){e=e||1/0;for(var r,n=t.length,o=null,i=[],a=0;a<n;++a){if(r=t.charCodeAt(a),r>55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=(o-55296<<10|r-56320)+65536}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function d(t){if(n.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var e=t.length;return 0===e?0:l(t).length}function g(t,e,r,n){for(var o=0;o<n&&!(o+r>=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function p(t,e,r,n){return g(l(e,t.length-r),t,r,n)}function v(t,e,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?c(t,e,r):"string"==typeof t?u(t,e):h(t)}var y=t("./is-array"),w=2147483647;n.prototype.__proto__=Uint8Array.prototype,n.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&n[Symbol.species]===n&&Object.defineProperty(n,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),n.prototype.write=function(t,e,r){void 0===e?(r=this.length,e=0):void 0===r&&"string"==typeof e?(r=this.length,e=0):isFinite(e)&&(e|=0,isFinite(r)?r|=0:r=void 0);var n=this.length-e;if((void 0===r||r>n)&&(r=n),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");return p(this,t,e,r)},n.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r,t<0&&(t=0)):t>r&&(t=r),e<0?(e+=r,e<0&&(e=0)):e>r&&(e=r),e<t&&(e=t);var o=this.subarray(t,e);return o.__proto__=n.prototype,o},n.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);var o,i=n-r;if(this===t&&r<e&&e<n)for(o=i-1;o>=0;--o)t[o+e]=this[o+r];else if(i<1e3)for(o=0;o<i;++o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+i),e);return i},n.prototype.fill=function(t,e,r){if("string"==typeof t){if("string"==typeof e?(e=0,r=this.length):"string"==typeof r&&(r=this.length),1===t.length){var o=t.charCodeAt(0);o<256&&(t=o)}}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0);var i;if("number"==typeof t)for(i=e;i<r;++i)this[i]=t;else{var a=n.isBuffer(t)?t:new n(t),s=a.length;for(i=0;i<r-e;++i)this[i+e]=a[i%s]}return this},n.concat=function(t,e){if(!y(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return a(null,0);var r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var o=s(e),i=0;for(r=0;r<t.length;++r){var u=t[r];if(!n.isBuffer(u))throw new TypeError('"list" argument must be an Array of Buffers');u.copy(o,i),i+=u.length}return o},n.byteLength=d,n.prototype._isBuffer=!0,n.isBuffer=function(t){return!(null==t||!t._isBuffer)},e.exports=n},{"./is-array":24}],26:[function(t,e,r){"use strict";var n={single_source_shortest_paths:function(t,e,r){var o={},i={};i[e]=0;var a=n.PriorityQueue.make();a.push(e,0);for(var s,u,f,c,h,l,d,g,p;!a.empty();){s=a.pop(),u=s.value,c=s.cost,h=t[u]||{};for(f in h)h.hasOwnProperty(f)&&(l=h[f],d=c+l,g=i[f],p="undefined"==typeof i[f],(p||g>d)&&(i[f]=d,a.push(f,d),o[f]=u))}if("undefined"!=typeof r&&"undefined"==typeof i[r]){var v=["Could not find a path from ",e," to ",r,"."].join("");throw new Error(v)}return o},extract_shortest_path_from_predecessor_list:function(t,e){for(var r,n=[],o=e;o;)n.push(o),r=t[o],o=t[o];return n.reverse(),n},find_path:function(t,e,r){var o=n.single_source_shortest_paths(t,e,r);return n.extract_shortest_path_from_predecessor_list(o,r)},PriorityQueue:{make:function(t){var e,r=n.PriorityQueue,o={};t=t||{};for(e in r)r.hasOwnProperty(e)&&(o[e]=r[e]);return o.queue=[],o.sorter=t.sorter||r.default_sorter,o},default_sorter:function(t,e){return t.cost-e.cost},push:function(t,e){var r={value:t,cost:e};this.queue.push(r),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};"undefined"!=typeof e&&(e.exports=n)},{}]},{},[22])(22)}); | ||
//# sourceMappingURL=qrcode.min.js.map |
@@ -9,33 +9,21 @@ var Buffer = require('../utils/buffer') | ||
ByteData.getCharCountIndicator = function getCharCountIndicator (version) { | ||
if (version >= 1 && version < 10) { | ||
// 1 - 9 | ||
return 8 | ||
} else if (version >= 10 && version < 41) { | ||
// 10 - 40 | ||
return 16 | ||
} else { | ||
throw new Error('version: ' + version) | ||
} | ||
ByteData.getBitsLength = function getBitsLength (length) { | ||
return length * 8 | ||
} | ||
ByteData.prototype = { | ||
getLength: function (buffer) { | ||
return this.data.length | ||
}, | ||
ByteData.prototype.getLength = function getLength () { | ||
return this.data.length | ||
} | ||
append: function (data) { | ||
this.data = Buffer.concat([this.data, new Buffer(data)]) | ||
return this | ||
}, | ||
ByteData.prototype.getBitsLength = function getBitsLength () { | ||
return ByteData.getBitsLength(this.data.length) | ||
} | ||
write: function (buffer) { | ||
for (var i = 0, l = this.data.length; i < l; i++) { | ||
buffer.put(this.data[i], 8) | ||
} | ||
}, | ||
getCharCountIndicator: ByteData.getCharCountIndicator | ||
ByteData.prototype.write = function (bitBuffer) { | ||
for (var i = 0, l = this.data.length; i < l; i++) { | ||
bitBuffer.put(this.data[i], 8) | ||
} | ||
} | ||
module.exports = ByteData | ||
@@ -1,6 +0,50 @@ | ||
module.exports = { | ||
L: 1, | ||
M: 0, | ||
Q: 3, | ||
H: 2 | ||
exports.L = { bit: 1 } | ||
exports.M = { bit: 0 } | ||
exports.Q = { bit: 3 } | ||
exports.H = { bit: 2 } | ||
function fromString (string) { | ||
if (typeof string !== 'string') { | ||
throw new Error('Param is not a string') | ||
} | ||
var lcStr = string.toLowerCase() | ||
switch (lcStr) { | ||
case 'l': | ||
case 'low': | ||
return exports.L | ||
case 'm': | ||
case 'medium': | ||
return exports.M | ||
case 'q': | ||
case 'quartile': | ||
return exports.Q | ||
case 'h': | ||
case 'high': | ||
return exports.H | ||
default: | ||
throw new Error('Unknown EC Level: ' + string) | ||
} | ||
} | ||
exports.isValid = function isValid (level) { | ||
return level && typeof level.bit !== 'undefined' && | ||
level.bit >= 0 && level.bit < 4 | ||
} | ||
exports.from = function from (value, defaultValue) { | ||
if (exports.isValid(value)) { | ||
return value | ||
} | ||
try { | ||
return fromString(value) | ||
} catch (e) { | ||
return defaultValue | ||
} | ||
} |
@@ -18,3 +18,3 @@ var Utils = require('./utils') | ||
exports.getEncodedBits = function getEncodedBits (errorCorrectionLevel, mask) { | ||
var data = ((errorCorrectionLevel << 3) | mask) | ||
var data = ((errorCorrectionLevel.bit << 3) | mask) | ||
var d = data << 10 | ||
@@ -21,0 +21,0 @@ |
@@ -0,34 +1,167 @@ | ||
var Version = require('./version') | ||
var Regex = require('./regex') | ||
/** | ||
* Data modes | ||
* Numeric mode encodes data from the decimal digit set (0 - 9) | ||
* (byte values 30HEX to 39HEX). | ||
* Normally, 3 data characters are represented by 10 bits. | ||
* | ||
* @type {Object} | ||
*/ | ||
module.exports = { | ||
/** | ||
* Numeric mode encodes data from the decimal digit set (0 - 9) (byte values 30HEX to 39HEX). | ||
* Normally, 3 data characters are represented by 10 bits. | ||
*/ | ||
NUMERIC: 1 << 0, | ||
exports.NUMERIC = { | ||
id: 'Numeric', | ||
bit: 1 << 0, | ||
ccBits: [10, 12, 14] | ||
} | ||
/** | ||
* Alphanumeric mode encodes data from a set of 45 characters, | ||
* i.e. 10 numeric digits (0 - 9), | ||
* 26 alphabetic characters (A - Z), | ||
* and 9 symbols (SP, $, %, *, +, -, ., /, :). | ||
* Normally, two input characters are represented by 11 bits. | ||
*/ | ||
ALPHA_NUM: 1 << 1, | ||
/** | ||
* Alphanumeric mode encodes data from a set of 45 characters, | ||
* i.e. 10 numeric digits (0 - 9), | ||
* 26 alphabetic characters (A - Z), | ||
* and 9 symbols (SP, $, %, *, +, -, ., /, :). | ||
* Normally, two input characters are represented by 11 bits. | ||
* | ||
* @type {Object} | ||
*/ | ||
exports.ALPHANUMERIC = { | ||
id: 'Alphanumeric', | ||
bit: 1 << 1, | ||
ccBits: [9, 11, 13] | ||
} | ||
/** | ||
* In byte mode, data is encoded at 8 bits per character. | ||
*/ | ||
BYTE: 1 << 2, | ||
/** | ||
* In byte mode, data is encoded at 8 bits per character. | ||
* | ||
* @type {Object} | ||
*/ | ||
exports.BYTE = { | ||
id: 'Byte', | ||
bit: 1 << 2, | ||
ccBits: [8, 16, 16] | ||
} | ||
/** | ||
* The Kanji mode efficiently encodes Kanji characters in accordance with the Shift JIS system | ||
* based on JIS X 0208. The Shift JIS values are shifted from the JIS X 0208 values. | ||
* JIS X 0208 gives details of the shift coded representation. | ||
* Each two-byte character value is compacted to a 13-bit binary codeword. | ||
*/ | ||
KANJI: 1 << 3 | ||
/** | ||
* The Kanji mode efficiently encodes Kanji characters in accordance with | ||
* the Shift JIS system based on JIS X 0208. | ||
* The Shift JIS values are shifted from the JIS X 0208 values. | ||
* JIS X 0208 gives details of the shift coded representation. | ||
* Each two-byte character value is compacted to a 13-bit binary codeword. | ||
* | ||
* @type {Object} | ||
*/ | ||
exports.KANJI = { | ||
id: 'Kanji', | ||
bit: 1 << 3, | ||
ccBits: [8, 10, 12] | ||
} | ||
/** | ||
* Mixed mode will contain a sequences of data in a combination of any of | ||
* the modes described above | ||
* | ||
* @type {Object} | ||
*/ | ||
exports.MIXED = { | ||
bit: -1 | ||
} | ||
/** | ||
* Returns the number of bits needed to store the data length | ||
* according to QR Code specifications. | ||
* | ||
* @param {Mode} mode Data mode | ||
* @param {Number} version QR Code version | ||
* @return {Number} Number of bits | ||
*/ | ||
exports.getCharCountIndicator = function getCharCountIndicator (mode, version) { | ||
if (!mode.ccBits) throw new Error('Invalid mode: ' + mode) | ||
if (!Version.isValid(version)) { | ||
throw new Error('Invalid version: ' + version) | ||
} | ||
if (version >= 1 && version < 10) return mode.ccBits[0] | ||
else if (version < 27) return mode.ccBits[1] | ||
return mode.ccBits[2] | ||
} | ||
/** | ||
* Returns the most efficient mode to store the specified data | ||
* | ||
* @param {String} dataStr Input data string | ||
* @return {Mode} Best mode | ||
*/ | ||
exports.getBestModeForData = function getBestModeForData (dataStr) { | ||
if (Regex.testNumeric(dataStr)) return exports.NUMERIC | ||
else if (Regex.testAlphanumeric(dataStr)) return exports.ALPHANUMERIC | ||
else if (Regex.testKanji(dataStr)) return exports.KANJI | ||
else return exports.BYTE | ||
} | ||
/** | ||
* Return mode name as string | ||
* | ||
* @param {Mode} mode Mode object | ||
* @returns {String} Mode name | ||
*/ | ||
exports.toString = function toString (mode) { | ||
if (mode && mode.id) return mode.id | ||
throw new Error('Invalid mode') | ||
} | ||
/** | ||
* Check if input param is a valid mode object | ||
* | ||
* @param {Mode} mode Mode object | ||
* @returns {Boolean} True if valid mode, false otherwise | ||
*/ | ||
exports.isValid = function isValid (mode) { | ||
return mode && mode.bit && mode.ccBits | ||
} | ||
/** | ||
* Get mode object from its name | ||
* | ||
* @param {String} string Mode name | ||
* @returns {Mode} Mode object | ||
*/ | ||
function fromString (string) { | ||
if (typeof string !== 'string') { | ||
throw new Error('Param is not a string') | ||
} | ||
var lcStr = string.toLowerCase() | ||
switch (lcStr) { | ||
case 'numeric': | ||
return exports.NUMERIC | ||
case 'alphanumeric': | ||
return exports.ALPHANUMERIC | ||
case 'kanji': | ||
return exports.KANJI | ||
case 'byte': | ||
return exports.BYTE | ||
default: | ||
throw new Error('Unknown mode: ' + string) | ||
} | ||
} | ||
/** | ||
* Returns mode from a value. | ||
* If value is not a valid mode, returns defaultValue | ||
* | ||
* @param {Mode|String} value Encoding mode | ||
* @param {Mode} defaultValue Fallback value | ||
* @return {Mode} Encoding mode | ||
*/ | ||
exports.from = function from (value, defaultValue) { | ||
if (exports.isValid(value)) { | ||
return value | ||
} | ||
try { | ||
return fromString(value) | ||
} catch (e) { | ||
return defaultValue | ||
} | ||
} |
var Buffer = require('../utils/buffer') | ||
var Utils = require('./utils') | ||
var ECLevel = require('./error-correction-level') | ||
var ByteData = require('./byte-data') | ||
var BitBuffer = require('./bit-buffer') | ||
@@ -14,2 +13,5 @@ var BitMatrix = require('./bit-matrix') | ||
var FormatInfo = require('./format-info') | ||
var Mode = require('./mode') | ||
var Segments = require('./segments') | ||
var isArray = require('../utils/is-array') | ||
@@ -152,3 +154,3 @@ /** | ||
* @param {BitMatrix} matrix Modules matrix | ||
* @param {Number} errorCorrectionLevel Error correction level | ||
* @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level | ||
* @param {Number} maskPattern Mask pattern reference value | ||
@@ -238,22 +240,26 @@ * @param {Boolean} reserve If true, marks bits as reserved and set their values to 0 | ||
* @param {Number} version QR Code version | ||
* @param {Number} errorCorrectionLevel Error correction level | ||
* @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level | ||
* @param {ByteData} data Data input | ||
* @return {Buffer} Buffer containing encoded codewords | ||
*/ | ||
function createData (version, errorCorrectionLevel, data) { | ||
function createData (version, errorCorrectionLevel, segments) { | ||
// Prepare data buffer | ||
var buffer = new BitBuffer() | ||
// prefix data with mode indicator (4 bits in byte mode) | ||
buffer.put(data.mode, 4) | ||
segments.forEach(function (data) { | ||
// prefix data with mode indicator (4 bits) | ||
buffer.put(data.mode.bit, 4) | ||
// Prefix data with character count indicator. | ||
// The character count indicator is a string of bits that represents the number of characters | ||
// that are being encoded. The character count indicator must be placed after the mode indicator | ||
// and must be a certain number of bits long, depending on the QR version and data mode | ||
// @see {@link ByteData.getCharCountIndicator}. | ||
buffer.put(data.getLength(), data.getCharCountIndicator(version)) | ||
// Prefix data with character count indicator. | ||
// The character count indicator is a string of bits that represents the | ||
// number of characters that are being encoded. | ||
// The character count indicator must be placed after the mode indicator | ||
// and must be a certain number of bits long, depending on the QR version | ||
// and data mode | ||
// @see {@link Mode.getCharCountIndicator}. | ||
buffer.put(data.getLength(), Mode.getCharCountIndicator(data.mode, version)) | ||
// add binary data sequence to buffer | ||
data.write(buffer) | ||
// add binary data sequence to buffer | ||
data.write(buffer) | ||
}) | ||
@@ -301,3 +307,3 @@ // Calculate required number of bits | ||
* @param {Number} version QR Code version | ||
* @param {Number} errorCorrectionLevel Error correction level | ||
* @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level | ||
* @return {Buffer} Buffer containing encoded codewords | ||
@@ -381,93 +387,63 @@ */ | ||
/** | ||
* QR Code | ||
* Build QR Code symbol | ||
* | ||
* @param {Number} version QR Code version | ||
* @param {Number} errorCorrectionLevel Error correction level | ||
* @param {String} data Input string | ||
* @param {Number} version QR Code version | ||
* @param {ErrorCorretionLevel} errorCorrectionLevel Error level | ||
* @return {Object} Object containing symbol data | ||
*/ | ||
function QRCode (version, errorCorrectionLevel) { | ||
this.version = version | ||
this.errorCorrectionLevel = errorCorrectionLevel | ||
this.modules = null | ||
this.moduleCount = 0 | ||
this.dataCache = null | ||
this.data = null | ||
} | ||
function createSymbol (data, version, errorCorrectionLevel) { | ||
var segments | ||
/** | ||
* Add datas to store | ||
* | ||
* @param {String, Number, Array, Buffer} data | ||
*/ | ||
QRCode.prototype.addData = function addData (data) { | ||
if (this.data) this.data.append(data) | ||
else this.data = new ByteData(data) | ||
if (isArray(data)) { | ||
segments = Segments.fromArray(data) | ||
} else if (typeof data === 'string') { | ||
var estimatedVersion = version | ||
this.dataCache = null | ||
} | ||
if (!estimatedVersion) { | ||
var rawSegments = Segments.rawSplit(data) | ||
/** | ||
* Return value of module at position | ||
* | ||
* @param {Number} row Row | ||
* @param {Number} col Column | ||
* @return {Boolean} Module value (black/white) | ||
*/ | ||
QRCode.prototype.isDark = function isDark (row, col) { | ||
if (row < 0 || this.moduleCount <= row || col < 0 || this.moduleCount <= col) { | ||
throw new Error(row + ',' + col) | ||
// Estimate best version that can contain raw splitted segments | ||
estimatedVersion = Version.getBestVersionForData(rawSegments, | ||
errorCorrectionLevel) | ||
} | ||
// Build optimized segments | ||
// If estimated version is undefined, try with the highest version | ||
segments = Segments.fromString(data, estimatedVersion) | ||
} else { | ||
throw new Error('Invalid data') | ||
} | ||
return this.modules.get(row, col) | ||
} | ||
// Get the min version that can contain data | ||
var bestVersion = Version.getBestVersionForData(segments, | ||
errorCorrectionLevel) | ||
/** | ||
* Return QR Code size (number of modules in row/col) | ||
* | ||
* @return {Number} size | ||
*/ | ||
QRCode.prototype.getModuleCount = function getModuleCount () { | ||
return this.moduleCount | ||
} | ||
// If no version is found, data cannot be stored | ||
if (!bestVersion) { | ||
throw new Error('The amount of data is too big to be stored in a QR Code') | ||
} | ||
/** | ||
* Build QR Code symbol | ||
*/ | ||
QRCode.prototype.make = function make () { | ||
if (this.dataCache === null) { | ||
// Use higher error correction level as default | ||
if (typeof this.errorCorrectionLevel === 'undefined') this.errorCorrectionLevel = ECLevel.H | ||
// If not specified, use min version as default | ||
if (!version) { | ||
version = bestVersion | ||
// Get the min version that can contain data | ||
var bestVersion = Version.getBestVersionForData(this.data, this.errorCorrectionLevel) | ||
// Check if the specified version can contain the data | ||
} else if (version < bestVersion) { | ||
throw new Error('\n' + | ||
'The chosen QR Code version cannot contain this amount of data.\n' + | ||
'Minimum version required to store current data is: ' + bestVersion + '.\n' | ||
) | ||
} | ||
// If no version is found, data cannot be stored | ||
if (!bestVersion) { | ||
throw new Error('The amount of data is too big to be stored in a QR Code') | ||
} | ||
var dataBits = createData(version, errorCorrectionLevel, segments) | ||
// If not specified, use min version as default | ||
if (!this.version) { | ||
this.version = bestVersion | ||
// Check if the specified version can contain the data | ||
} else if (this.version < bestVersion) { | ||
throw new Error('\n' + | ||
'The chosen QR Code version cannot contain this amount of data.\n' + | ||
'Max characters allowed with current config: ' + | ||
Version.getCapacity(this.version, this.errorCorrectionLevel) + '\n' + | ||
'Minimum version required to store current data: ' + bestVersion + '\n' | ||
) | ||
} | ||
this.dataCache = createData(this.version, this.errorCorrectionLevel, this.data) | ||
} | ||
// Allocate matrix buffer | ||
this.moduleCount = Utils.getSymbolSize(this.version) | ||
this.modules = new BitMatrix(this.moduleCount) | ||
var moduleCount = Utils.getSymbolSize(version) | ||
var modules = new BitMatrix(moduleCount) | ||
// Add function modules | ||
setupFinderPattern(this.modules, this.version) | ||
setupTimingPattern(this.modules) | ||
setupAlignmentPattern(this.modules, this.version) | ||
setupFinderPattern(modules, version) | ||
setupTimingPattern(modules) | ||
setupAlignmentPattern(modules, version) | ||
@@ -478,23 +454,87 @@ // Add temporary blank bits for format info and version info just to set them as reserved. | ||
// These blocks will be replaced with correct values later in code. | ||
setupFormatInfo(this.modules, this.errorCorrectionLevel, 0, true) | ||
if (this.version >= 7) { | ||
setupVersionInfo(this.modules, this.version, true) | ||
setupFormatInfo(modules, errorCorrectionLevel, 0, true) | ||
if (version >= 7) { | ||
setupVersionInfo(modules, version, true) | ||
} | ||
// Add data codewords | ||
setupData(this.modules, this.dataCache) | ||
setupData(modules, dataBits) | ||
// Find best mask pattern | ||
var maskPattern = MaskPattern.getBestMask(this.modules) | ||
var maskPattern = MaskPattern.getBestMask(modules) | ||
// Apply mask pattern | ||
MaskPattern.applyMask(maskPattern, this.modules) | ||
MaskPattern.applyMask(maskPattern, modules) | ||
// Replace format info bits with correct values | ||
setupFormatInfo(this.modules, this.errorCorrectionLevel, maskPattern) | ||
setupFormatInfo(modules, errorCorrectionLevel, maskPattern) | ||
// Replace version info bits with correct values | ||
if (this.version >= 7) { | ||
setupVersionInfo(this.modules, this.version) | ||
if (version >= 7) { | ||
setupVersionInfo(modules, version) | ||
} | ||
return { | ||
data: modules, | ||
version: version, | ||
errorCorrectionLevel: errorCorrectionLevel, | ||
maskPattern: maskPattern | ||
} | ||
} | ||
/** | ||
* QR Code | ||
* | ||
* @param {String | Array} data Input data | ||
* @param {Object} options Optional configurations | ||
* @param {Number} options.version QR Code version | ||
* @param {String} options.errorCorrectionLevel Error correction level | ||
* @param {Function} options.toSJISFunc Helper func to convert utf8 to sjis | ||
*/ | ||
function QRCode (data, options) { | ||
if (typeof data === 'undefined' || data === '') { | ||
throw new Error('No input text') | ||
} | ||
this.errorCorrectionLevel = ECLevel.M | ||
this.version = undefined | ||
if (typeof options !== 'undefined') { | ||
// Use higher error correction level as default | ||
this.errorCorrectionLevel = ECLevel.from(options.errorCorrectionLevel, ECLevel.M) | ||
this.version = Version.from(options.version) | ||
if (options.toSJISFunc) { | ||
Utils.setToSJISFunction(options.toSJISFunc) | ||
} | ||
} | ||
var qr = createSymbol(data, this.version, this.errorCorrectionLevel) | ||
this.version = qr.version | ||
this.modules = qr.data | ||
} | ||
/** | ||
* Return value of module at position | ||
* | ||
* @param {Number} row Row | ||
* @param {Number} col Column | ||
* @return {Boolean} Module value (black/white) | ||
*/ | ||
QRCode.prototype.isDark = function isDark (row, col) { | ||
var size = this.modules.size | ||
if (row < 0 || size <= row || col < 0 || size <= col) { | ||
throw new Error(row + ',' + col) | ||
} | ||
return this.modules.get(row, col) | ||
} | ||
/** | ||
* Return QR Code size (number of modules in row/col) | ||
* | ||
* @return {Number} size | ||
*/ | ||
QRCode.prototype.getModuleCount = function getModuleCount () { | ||
return this.modules.size | ||
} |
@@ -0,1 +1,2 @@ | ||
var toSJISFunction | ||
var CODEWORDS_COUNT = [ | ||
@@ -47,1 +48,17 @@ 0, // Not used | ||
} | ||
exports.setToSJISFunction = function setToSJISFunction (f) { | ||
if (typeof f !== 'function') { | ||
throw new Error('"toSJISFunc" is not a valid function.') | ||
} | ||
toSJISFunction = f | ||
} | ||
exports.isKanjiModeEnabled = function () { | ||
return typeof toSJISFunction !== 'undefined' | ||
} | ||
exports.toSJIS = function toSJIS (kanji) { | ||
return toSJISFunction(kanji) | ||
} |
@@ -1,6 +0,6 @@ | ||
var Buffer = require('../utils/buffer') | ||
var Utils = require('./utils') | ||
var ECCode = require('./error-correction-code') | ||
var ECLevel = require('./error-correction-level') | ||
var ByteData = require('./byte-data') | ||
var Mode = require('./mode') | ||
var isArray = require('../utils/is-array') | ||
@@ -11,5 +11,7 @@ // Generator polynomial used to encode version information | ||
var getBestVersionForDataLength = function getBestVersionForDataLength (length, errorCorrectionLevel) { | ||
function getBestVersionForDataLength (mode, length, errorCorrectionLevel) { | ||
for (var currentVersion = 1; currentVersion <= 40; currentVersion++) { | ||
if (length <= exports.getCapacity(currentVersion, errorCorrectionLevel)) return currentVersion | ||
if (length <= exports.getCapacity(currentVersion, errorCorrectionLevel, mode)) { | ||
return currentVersion | ||
} | ||
} | ||
@@ -20,2 +22,29 @@ | ||
function getReservedBitsCount (mode, version) { | ||
// Character count indicator + mode indicator bits | ||
return Mode.getCharCountIndicator(mode, version) + 4 | ||
} | ||
function getTotalBitsFromDataArray (segments, version) { | ||
var totalBits = 0 | ||
segments.forEach(function (data) { | ||
var reservedBits = getReservedBitsCount(data.mode, version) | ||
totalBits += reservedBits + data.getBitsLength() | ||
}) | ||
return totalBits | ||
} | ||
function getBestVersionForMixedData (segments, errorCorrectionLevel) { | ||
for (var currentVersion = 1; currentVersion <= 40; currentVersion++) { | ||
var length = getTotalBitsFromDataArray(segments, currentVersion) | ||
if (length <= exports.getCapacity(currentVersion, errorCorrectionLevel, Mode.MIXED)) { | ||
return currentVersion | ||
} | ||
} | ||
return undefined | ||
} | ||
/** | ||
@@ -27,3 +56,3 @@ * Check if QR Code version is valid | ||
*/ | ||
exports.isValidVersion = function isValidVersion (version) { | ||
exports.isValid = function isValid (version) { | ||
return !isNaN(version) && version >= 1 && version <= 40 | ||
@@ -33,2 +62,18 @@ } | ||
/** | ||
* Returns version number from a value. | ||
* If value is not a valid version, returns defaultValue | ||
* | ||
* @param {Number|String} value QR Code version | ||
* @param {Number} defaultValue Fallback value | ||
* @return {Number} QR Code version number | ||
*/ | ||
exports.from = function from (value, defaultValue) { | ||
if (exports.isValid(value)) { | ||
return parseInt(value, 10) | ||
} | ||
return defaultValue | ||
} | ||
/** | ||
* Returns how much data can be stored with the specified QR code version | ||
@@ -39,9 +84,13 @@ * and error correction level | ||
* @param {Number} errorCorrectionLevel Error correction level | ||
* @param {Mode} mode Data mode | ||
* @return {Number} Quantity of storable data | ||
*/ | ||
exports.getCapacity = function getCapacity (version, errorCorrectionLevel) { | ||
if (!exports.isValidVersion(version)) { | ||
exports.getCapacity = function getCapacity (version, errorCorrectionLevel, mode) { | ||
if (!exports.isValid(version)) { | ||
throw new Error('Invalid QR Code version') | ||
} | ||
// Use Byte mode as default | ||
if (typeof mode === 'undefined') mode = Mode.BYTE | ||
// Total codewords for this QR code version (Data + Error correction) | ||
@@ -56,7 +105,21 @@ var totalCodewords = Utils.getSymbolTotalCodewords(version) | ||
// Character count indicator + mode indicator bits | ||
var reservedBits = ByteData.getCharCountIndicator(version) + 4 | ||
if (mode === Mode.MIXED) return dataTotalCodewordsBits | ||
var usableBits = dataTotalCodewordsBits - getReservedBitsCount(mode, version) | ||
// Return max number of storable codewords | ||
return Math.floor((dataTotalCodewordsBits - reservedBits) / 8) | ||
switch (mode) { | ||
case Mode.NUMERIC: | ||
return Math.floor((usableBits / 10) * 3) | ||
case Mode.ALPHANUMERIC: | ||
return Math.floor((usableBits / 11) * 2) | ||
case Mode.KANJI: | ||
return Math.floor(usableBits / 13) | ||
case Mode.BYTE: | ||
default: | ||
return Math.floor(usableBits / 8) | ||
} | ||
} | ||
@@ -67,18 +130,27 @@ | ||
* | ||
* @param {Buffer, Array, ByteData} data Data buffer | ||
* @param {Segment} data Segment of data | ||
* @param {Number} [errorCorrectionLevel=H] Error correction level | ||
* @param {Mode} mode Data mode | ||
* @return {Number} QR Code version | ||
*/ | ||
exports.getBestVersionForData = function getBestVersionForData (data, errorCorrectionLevel) { | ||
var dataLength | ||
var seg | ||
if (data instanceof ByteData) dataLength = data.getLength() | ||
else if (Buffer.isBuffer(data)) dataLength = data.length | ||
else dataLength = new Buffer(data).length | ||
var ecl = ECLevel.from(errorCorrectionLevel, ECLevel.M) | ||
var ecl = errorCorrectionLevel | ||
if (isArray(data)) { | ||
if (data.length > 1) { | ||
return getBestVersionForMixedData(data, ecl) | ||
} | ||
if (typeof ecl === 'undefined') ecl = ECLevel.H | ||
if (data.length === 0) { | ||
return 1 | ||
} | ||
return getBestVersionForDataLength(dataLength, ecl) | ||
seg = data[0] | ||
} else { | ||
seg = data | ||
} | ||
return getBestVersionForDataLength(seg.mode, seg.getLength(), ecl) | ||
} | ||
@@ -97,3 +169,3 @@ | ||
exports.getEncodedBits = function getEncodedBits (version) { | ||
if (!exports.isValidVersion(version) || version < 7) { | ||
if (!exports.isValid(version) || version < 7) { | ||
throw new Error('Invalid QR Code version') | ||
@@ -100,0 +172,0 @@ } |
@@ -57,3 +57,3 @@ /* | ||
if (textKeys[ec]) { | ||
options.errorCorrectLevel = textKeys[ec] | ||
options.errorCorrectionLevel = textKeys[ec] | ||
} | ||
@@ -216,3 +216,3 @@ } | ||
var drawInstance = new QRCodeDraw() | ||
drawInstance.drawBitArray(text, function (error, bits, width) { | ||
drawInstance.drawBitArray(text, options, function (error, bits, width) { | ||
if (!error) { | ||
@@ -234,3 +234,3 @@ var code = terminalRender.renderBits(bits, width) | ||
var drawInstance = new QRCodeDraw() | ||
drawInstance.drawBitArray(text, function (error, bits, width) { | ||
drawInstance.drawBitArray(text, options, function (error, bits, width) { | ||
if (!error) { | ||
@@ -237,0 +237,0 @@ var code = svgRender.renderBits(bits, width, options) |
@@ -53,3 +53,3 @@ /* | ||
if (typeof options !== 'object') { | ||
options.errorCorrectLevel = options | ||
options.errorCorrectionLevel = options | ||
} | ||
@@ -62,3 +62,3 @@ | ||
try { | ||
var qr = new QRCodeLib(options.version, options.errorCorrectLevel) | ||
var qr = new QRCodeLib(text, options) | ||
var scale = this.scale || 4 | ||
@@ -68,5 +68,2 @@ var ctx = canvas.getContext('2d') | ||
qr.addData(text) | ||
qr.make() | ||
var margin = this.marginWidth() | ||
@@ -116,3 +113,3 @@ var currenty = margin | ||
try { | ||
var qr = new QRCodeLib(options.version, options.errorCorrectLevel) | ||
var qr = new QRCodeLib(text, options) | ||
var width = 0 | ||
@@ -122,5 +119,2 @@ var bits | ||
qr.addData(text) | ||
qr.make() | ||
width = this.dataWidth(qr, 1) | ||
@@ -127,0 +121,0 @@ bits = new Array(width * width) |
{ | ||
"name": "qrcode", | ||
"description": "QRCode / 2d Barcode api with both server side and client side support using canvas", | ||
"version": "0.6.0", | ||
"version": "0.7.0", | ||
"author": "Ryan Day <soldair@gmail.com>", | ||
@@ -22,3 +22,4 @@ "contributors": [ | ||
"build", | ||
"lib" | ||
"lib", | ||
"helper" | ||
], | ||
@@ -39,6 +40,7 @@ "homepage": "http://github.com/soldair/node-qrcode", | ||
"canvas": "~1.3.4", | ||
"colors": "*" | ||
"colors": "*", | ||
"dijkstrajs": "^1.0.1" | ||
}, | ||
"devDependencies": { | ||
"browserify": "^13.1.1", | ||
"browserify": "^14.1.0", | ||
"canvasutil": "*", | ||
@@ -49,3 +51,3 @@ "express": "2.5.x", | ||
"tap": "*", | ||
"uglify-js": "^2.7.4" | ||
"uglify-js": "^2.7.5" | ||
}, | ||
@@ -52,0 +54,0 @@ "repository": { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
497338
39
6660
0
3
3
9
+ Addeddijkstrajs@^1.0.1
+ Addeddijkstrajs@1.0.3(transitive)