qrious
Advanced tools
Comparing version 2.2.0 to 2.3.0
@@ -0,1 +1,9 @@ | ||
## Version 2.3.0, 2017.05.31 | ||
* Enable setting of multiple properties at once resulting in a single re-render [#69](https://github.com/neocotic/qrious/issues/69) | ||
* Deferring or avoiding ImageRenderer [#71](https://github.com/neocotic/qrious/issues/71) | ||
* Switch to container-based Travis builds for faster boot times [#73](https://github.com/neocotic/qrious/issues/73) | ||
* Change code style to be more contributor-friendly [#75](https://github.com/neocotic/qrious/issues/75) | ||
* Improve download links in README [#76](https://github.com/neocotic/qrious/issues/76) | ||
## Version 2.2.0, 2016.10.30 | ||
@@ -2,0 +10,0 @@ |
@@ -1,7 +0,7 @@ | ||
/*! QRious v2.2.0 | (C) 2016 Alasdair Mercer | GPL v3 License | ||
/*! QRious v2.3.0 | (C) 2017 Alasdair Mercer | GPL v3 License | ||
Based on jsqrencode | (C) 2010 tz@execpc.com | GPL v3 License | ||
*/ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define("qrious",e):t.QRious=e()}(this,function(){"use strict";function t(t){return t&&t.__esModule?t.default:t}function e(t,e){return e={exports:{}},t(e,e.exports),e.exports}var n=function(t){if(void 0==t)throw TypeError("Can't call method on "+t);return t},r=n,i=function(t){return Object(r(t))},s={}.hasOwnProperty,o=function(t,e){return s.call(t,e)},u=e(function(t){var e=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=e)}),a=u,f="__core-js_shared__",c=a[f]||(a[f]={}),h=function(t){return c[t]||(c[t]={})},l=0,_=Math.random(),d=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++l+_).toString(36))},v=h("keys"),p=d,y=function(t){return v[t]||(v[t]=p(t))},g=o,k=i,b=y("IE_PROTO"),m=Object.prototype,w=Object.getPrototypeOf||function(t){return t=k(t),g(t,b)?t[b]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?m:null},B=e(function(t){var e=t.exports={version:"2.4.0"};"number"==typeof __e&&(__e=e)}),O=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t},M=O,S=function(t,e,n){if(M(t),void 0===e)return t;switch(n){case 1:return function(n){return t.call(e,n)};case 2:return function(n,r){return t.call(e,n,r)};case 3:return function(n,r,i){return t.call(e,n,r,i)}}return function(){return t.apply(e,arguments)}},E=function(t){return"object"==typeof t?null!==t:"function"==typeof t},A=E,j=function(t){if(!A(t))throw TypeError(t+" is not an object!");return t},L=function(t){try{return!!t()}catch(t){return!0}},N=!L(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a}),P=E,T=u.document,C=P(T)&&P(T.createElement),F=function(t){return C?T.createElement(t):{}},x=!N&&!L(function(){return 7!=Object.defineProperty(F("div"),"a",{get:function(){return 7}}).a}),z=E,U=function(t,e){if(!z(t))return t;var n,r;if(e&&"function"==typeof(n=t.toString)&&!z(r=n.call(t)))return r;if("function"==typeof(n=t.valueOf)&&!z(r=n.call(t)))return r;if(!e&&"function"==typeof(n=t.toString)&&!z(r=n.call(t)))return r;throw TypeError("Can't convert object to primitive value")},D=j,I=x,R=U,q=Object.defineProperty,K=N?Object.defineProperty:function(t,e,n){if(D(t),e=R(e,!0),D(n),I)try{return q(t,e,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported!");return"value"in n&&(t[e]=n.value),t},G={f:K},W=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},V=G,X=W,J=N?function(t,e,n){return V.f(t,e,X(1,n))}:function(t,e,n){return t[e]=n,t},H=u,Q=B,Y=S,Z=J,$="prototype",tt=function(t,e,n){var r,i,s,o=t&tt.F,u=t&tt.G,a=t&tt.S,f=t&tt.P,c=t&tt.B,h=t&tt.W,l=u?Q:Q[e]||(Q[e]={}),_=l[$],d=u?H:a?H[e]:(H[e]||{})[$];u&&(n=e);for(r in n)i=!o&&d&&void 0!==d[r],i&&r in l||(s=i?d[r]:n[r],l[r]=u&&"function"!=typeof d[r]?n[r]:c&&i?Y(s,H):h&&d[r]==s?function(t){var e=function(e,n,r){if(this instanceof t){switch(arguments.length){case 0:return new t;case 1:return new t(e);case 2:return new t(e,n)}return new t(e,n,r)}return t.apply(this,arguments)};return e[$]=t[$],e}(s):f&&"function"==typeof s?Y(Function.call,s):s,f&&((l.virtual||(l.virtual={}))[r]=s,t&tt.R&&_&&!_[r]&&Z(_,r,s)))};tt.F=1,tt.G=2,tt.S=4,tt.P=8,tt.B=16,tt.W=32,tt.U=64,tt.R=128;var et=tt,nt=et,rt=B,it=L,st=function(t,e){var n=(rt.Object||{})[t]||Object[t],r={};r[t]=e(n),nt(nt.S+nt.F*it(function(){n(1)}),"Object",r)},ot=i,ut=w;st("getPrototypeOf",function(){return function(t){return ut(ot(t))}});var at=B.Object.getPrototypeOf,ft=e(function(t){t.exports={default:at,__esModule:!0}}),ct=t(ft),ht=e(function(t,e){e.__esModule=!0,e.default=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}}),lt=t(ht),_t=et;_t(_t.S+_t.F*!N,"Object",{defineProperty:G.f});var dt=B.Object,vt=function(t,e,n){return dt.defineProperty(t,e,n)},pt=e(function(t){t.exports={default:vt,__esModule:!0}}),yt=e(function(t,e){function n(t){return t&&t.__esModule?t:{default:t}}e.__esModule=!0;var r=pt,i=n(r);e.default=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),(0,i.default)(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}()}),gt=t(yt),kt=Math.ceil,bt=Math.floor,mt=function(t){return isNaN(t=+t)?0:(t>0?bt:kt)(t)},wt=mt,Bt=n,Ot=function(t){return function(e,n){var r,i,s=String(Bt(e)),o=wt(n),u=s.length;return o<0||o>=u?t?"":void 0:(r=s.charCodeAt(o),r<55296||r>56319||o+1===u||(i=s.charCodeAt(o+1))<56320||i>57343?t?s.charAt(o):r:t?s.slice(o,o+2):(r-55296<<10)+(i-56320)+65536)}},Mt=!0,St=J,Et={},At={}.toString,jt=function(t){return At.call(t).slice(8,-1)},Lt=jt,Nt=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==Lt(t)?t.split(""):Object(t)},Pt=Nt,Tt=n,Ct=function(t){return Pt(Tt(t))},Ft=mt,xt=Math.min,zt=function(t){return t>0?xt(Ft(t),9007199254740991):0},Ut=mt,Dt=Math.max,It=Math.min,Rt=function(t,e){return t=Ut(t),t<0?Dt(t+e,0):It(t,e)},qt=Ct,Kt=zt,Gt=Rt,Wt=function(t){return function(e,n,r){var i,s=qt(e),o=Kt(s.length),u=Gt(r,o);if(t&&n!=n){for(;o>u;)if(i=s[u++],i!=i)return!0}else for(;o>u;u++)if((t||u in s)&&s[u]===n)return t||u||0;return!t&&-1}},Vt=o,Xt=Ct,Jt=Wt(!1),Ht=y("IE_PROTO"),Qt=function(t,e){var n,r=Xt(t),i=0,s=[];for(n in r)n!=Ht&&Vt(r,n)&&s.push(n);for(;e.length>i;)Vt(r,n=e[i++])&&(~Jt(s,n)||s.push(n));return s},Yt="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(","),Zt=Qt,$t=Yt,te=Object.keys||function(t){return Zt(t,$t)},ee=G,ne=j,re=te,ie=N?Object.defineProperties:function(t,e){ne(t);for(var n,r=re(e),i=r.length,s=0;i>s;)ee.f(t,n=r[s++],e[n]);return t},se=u.document&&document.documentElement,oe=j,ue=ie,ae=Yt,fe=y("IE_PROTO"),ce=function(){},he="prototype",le=function(){var t,e=F("iframe"),n=ae.length,r="<",i=">";for(e.style.display="none",se.appendChild(e),e.src="javascript:",t=e.contentWindow.document,t.open(),t.write(r+"script"+i+"document.F=Object"+r+"/script"+i),t.close(),le=t.F;n--;)delete le[he][ae[n]];return le()},_e=Object.create||function(t,e){var n;return null!==t?(ce[he]=oe(t),n=new ce,ce[he]=null,n[fe]=t):n=le(),void 0===e?n:ue(n,e)},de=e(function(t){var e=h("wks"),n=d,r=u.Symbol,i="function"==typeof r,s=t.exports=function(t){return e[t]||(e[t]=i&&r[t]||(i?r:n)("Symbol."+t))};s.store=e}),ve=G.f,pe=o,ye=de("toStringTag"),ge=function(t,e,n){t&&!pe(t=n?t:t.prototype,ye)&&ve(t,ye,{configurable:!0,value:e})},ke=_e,be=W,me=ge,we={};J(we,de("iterator"),function(){return this});var Be=function(t,e,n){t.prototype=ke(we,{next:be(1,n)}),me(t,e+" Iterator")},Oe=Mt,Me=et,Se=St,Ee=J,Ae=o,je=Et,Le=Be,Ne=ge,Pe=w,Te=de("iterator"),Ce=!([].keys&&"next"in[].keys()),Fe="@@iterator",xe="keys",ze="values",Ue=function(){return this},De=function(t,e,n,r,i,s,o){Le(n,e,r);var u,a,f,c=function(t){if(!Ce&&t in d)return d[t];switch(t){case xe:return function(){return new n(this,t)};case ze:return function(){return new n(this,t)}}return function(){return new n(this,t)}},h=e+" Iterator",l=i==ze,_=!1,d=t.prototype,v=d[Te]||d[Fe]||i&&d[i],p=v||c(i),y=i?l?c("entries"):p:void 0,g="Array"==e?d.entries||v:v;if(g&&(f=Pe(g.call(new t)),f!==Object.prototype&&(Ne(f,h,!0),Oe||Ae(f,Te)||Ee(f,Te,Ue))),l&&v&&v.name!==ze&&(_=!0,p=function(){return v.call(this)}),Oe&&!o||!Ce&&!_&&d[Te]||Ee(d,Te,p),je[e]=p,je[h]=Ue,i)if(u={values:l?p:c(ze),keys:s?p:c(xe),entries:y},o)for(a in u)a in d||Se(d,a,u[a]);else Me(Me.P+Me.F*(Ce||_),e,u);return u},Ie=Ot(!0);De(String,"String",function(t){this._t=String(t),this._i=0},function(){var t,e=this._t,n=this._i;return n>=e.length?{value:void 0,done:!0}:(t=Ie(e,n),this._i+=t.length,{value:t,done:!1})});var Re=function(){},qe=function(t,e){return{value:e,done:!!t}},Ke=Re,Ge=qe,We=Et,Ve=Ct;De(Array,"Array",function(t,e){this._t=Ve(t),this._i=0,this._k=e},function(){var t=this._t,e=this._k,n=this._i++;return!t||n>=t.length?(this._t=void 0,Ge(1)):"keys"==e?Ge(0,n):"values"==e?Ge(0,t[n]):Ge(0,[n,t[n]])},"values");We.Arguments=We.Array,Ke("keys"),Ke("values"),Ke("entries");for(var Xe=u,Je=J,He=Et,Qe=de("toStringTag"),Ye=["NodeList","DOMTokenList","MediaList","StyleSheetList","CSSRuleList"],Ze=0;Ze<5;Ze++){var $e=Ye[Ze],tn=Xe[$e],en=tn&&tn.prototype;en&&!en[Qe]&&Je(en,Qe,$e),He[$e]=He.Array}var nn=de,rn={f:nn},sn=rn.f("iterator"),on=e(function(t){t.exports={default:sn,__esModule:!0}}),un=e(function(t){var e=d("meta"),n=E,r=o,i=G.f,s=0,u=Object.isExtensible||function(){return!0},a=!L(function(){return u(Object.preventExtensions({}))}),f=function(t){i(t,e,{value:{i:"O"+ ++s,w:{}}})},c=function(t,i){if(!n(t))return"symbol"==typeof t?t:("string"==typeof t?"S":"P")+t;if(!r(t,e)){if(!u(t))return"F";if(!i)return"E";f(t)}return t[e].i},h=function(t,n){if(!r(t,e)){if(!u(t))return!0;if(!n)return!1;f(t)}return t[e].w},l=function(t){return a&&_.NEED&&u(t)&&!r(t,e)&&f(t),t},_=t.exports={KEY:e,NEED:!1,fastKey:c,getWeak:h,onFreeze:l}}),an=u,fn=B,cn=Mt,hn=rn,ln=G.f,_n=function(t){var e=fn.Symbol||(fn.Symbol=cn?{}:an.Symbol||{});"_"==t.charAt(0)||t in e||ln(e,t,{value:hn.f(t)})},dn=te,vn=Ct,pn=function(t,e){for(var n,r=vn(t),i=dn(r),s=i.length,o=0;s>o;)if(r[n=i[o++]]===e)return n},yn=Object.getOwnPropertySymbols,gn={f:yn},kn={}.propertyIsEnumerable,bn={f:kn},mn=te,wn=gn,Bn=bn,On=function(t){var e=mn(t),n=wn.f;if(n)for(var r,i=n(t),s=Bn.f,o=0;i.length>o;)s.call(t,r=i[o++])&&e.push(r);return e},Mn=jt,Sn=Array.isArray||function(t){return"Array"==Mn(t)},En=Qt,An=Yt.concat("length","prototype"),jn=Object.getOwnPropertyNames||function(t){return En(t,An)},Ln={f:jn},Nn=Ct,Pn=Ln.f,Tn={}.toString,Cn="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],Fn=function(t){try{return Pn(t)}catch(t){return Cn.slice()}},xn=function(t){return Cn&&"[object Window]"==Tn.call(t)?Fn(t):Pn(Nn(t))},zn={f:xn},Un=bn,Dn=W,In=Ct,Rn=U,qn=o,Kn=x,Gn=Object.getOwnPropertyDescriptor,Wn=N?Gn:function(t,e){if(t=In(t),e=Rn(e,!0),Kn)try{return Gn(t,e)}catch(t){}if(qn(t,e))return Dn(!Un.f.call(t,e),t[e])},Vn={f:Wn},Xn=u,Jn=o,Hn=N,Qn=et,Yn=St,Zn=un.KEY,$n=L,tr=h,er=ge,nr=d,rr=de,ir=rn,sr=_n,or=pn,ur=On,ar=Sn,fr=j,cr=Ct,hr=U,lr=W,_r=_e,dr=zn,vr=Vn,pr=G,yr=te,gr=vr.f,kr=pr.f,br=dr.f,mr=Xn.Symbol,wr=Xn.JSON,Br=wr&&wr.stringify,Or="prototype",Mr=rr("_hidden"),Sr=rr("toPrimitive"),Er={}.propertyIsEnumerable,Ar=tr("symbol-registry"),jr=tr("symbols"),Lr=tr("op-symbols"),Nr=Object[Or],Pr="function"==typeof mr,Tr=Xn.QObject,Cr=!Tr||!Tr[Or]||!Tr[Or].findChild,Fr=Hn&&$n(function(){return 7!=_r(kr({},"a",{get:function(){return kr(this,"a",{value:7}).a}})).a})?function(t,e,n){var r=gr(Nr,e);r&&delete Nr[e],kr(t,e,n),r&&t!==Nr&&kr(Nr,e,r)}:kr,xr=function(t){var e=jr[t]=_r(mr[Or]);return e._k=t,e},zr=Pr&&"symbol"==typeof mr.iterator?function(t){return"symbol"==typeof t}:function(t){return t instanceof mr},Ur=function(t,e,n){return t===Nr&&Ur(Lr,e,n),fr(t),e=hr(e,!0),fr(n),Jn(jr,e)?(n.enumerable?(Jn(t,Mr)&&t[Mr][e]&&(t[Mr][e]=!1),n=_r(n,{enumerable:lr(0,!1)})):(Jn(t,Mr)||kr(t,Mr,lr(1,{})),t[Mr][e]=!0),Fr(t,e,n)):kr(t,e,n)},Dr=function(t,e){fr(t);for(var n,r=ur(e=cr(e)),i=0,s=r.length;s>i;)Ur(t,n=r[i++],e[n]);return t},Ir=function(t,e){return void 0===e?_r(t):Dr(_r(t),e)},Rr=function(t){var e=Er.call(this,t=hr(t,!0));return!(this===Nr&&Jn(jr,t)&&!Jn(Lr,t))&&(!(e||!Jn(this,t)||!Jn(jr,t)||Jn(this,Mr)&&this[Mr][t])||e)},qr=function(t,e){if(t=cr(t),e=hr(e,!0),t!==Nr||!Jn(jr,e)||Jn(Lr,e)){var n=gr(t,e);return!n||!Jn(jr,e)||Jn(t,Mr)&&t[Mr][e]||(n.enumerable=!0),n}},Kr=function(t){for(var e,n=br(cr(t)),r=[],i=0;n.length>i;)Jn(jr,e=n[i++])||e==Mr||e==Zn||r.push(e);return r},Gr=function(t){for(var e,n=t===Nr,r=br(n?Lr:cr(t)),i=[],s=0;r.length>s;)!Jn(jr,e=r[s++])||n&&!Jn(Nr,e)||i.push(jr[e]);return i};Pr||(mr=function(){if(this instanceof mr)throw TypeError("Symbol is not a constructor!");var t=nr(arguments.length>0?arguments[0]:void 0),e=function(n){this===Nr&&e.call(Lr,n),Jn(this,Mr)&&Jn(this[Mr],t)&&(this[Mr][t]=!1),Fr(this,t,lr(1,n))};return Hn&&Cr&&Fr(Nr,t,{configurable:!0,set:e}),xr(t)},Yn(mr[Or],"toString",function(){return this._k}),vr.f=qr,pr.f=Ur,Ln.f=dr.f=Kr,bn.f=Rr,gn.f=Gr,Hn&&!Mt&&Yn(Nr,"propertyIsEnumerable",Rr,!0),ir.f=function(t){return xr(rr(t))}),Qn(Qn.G+Qn.W+Qn.F*!Pr,{Symbol:mr});for(var Wr="hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),Vr=0;Wr.length>Vr;)rr(Wr[Vr++]);for(var Wr=yr(rr.store),Vr=0;Wr.length>Vr;)sr(Wr[Vr++]);Qn(Qn.S+Qn.F*!Pr,"Symbol",{for:function(t){return Jn(Ar,t+="")?Ar[t]:Ar[t]=mr(t)},keyFor:function(t){if(zr(t))return or(Ar,t);throw TypeError(t+" is not a symbol!")},useSetter:function(){Cr=!0},useSimple:function(){Cr=!1}}),Qn(Qn.S+Qn.F*!Pr,"Object",{create:Ir,defineProperty:Ur,defineProperties:Dr,getOwnPropertyDescriptor:qr,getOwnPropertyNames:Kr,getOwnPropertySymbols:Gr}),wr&&Qn(Qn.S+Qn.F*(!Pr||$n(function(){var t=mr();return"[null]"!=Br([t])||"{}"!=Br({a:t})||"{}"!=Br(Object(t))})),"JSON",{stringify:function(t){if(void 0!==t&&!zr(t)){for(var e,n,r=[t],i=1;arguments.length>i;)r.push(arguments[i++]);return e=r[1],"function"==typeof e&&(n=e),!n&&ar(e)||(e=function(t,e){if(n&&(e=n.call(this,t,e)),!zr(e))return e}),r[1]=e,Br.apply(wr,r)}}}),mr[Or][Sr]||J(mr[Or],Sr,mr[Or].valueOf),er(mr,"Symbol"),er(Math,"Math",!0),er(Xn.JSON,"JSON",!0),_n("asyncIterator"),_n("observable");var Xr=B.Symbol,Jr=e(function(t){t.exports={default:Xr,__esModule:!0}}),Hr=e(function(t,e){function n(t){return t&&t.__esModule?t:{default:t}}e.__esModule=!0;var r=on,i=n(r),s=Jr,o=n(s),u="function"==typeof o.default&&"symbol"==typeof i.default?function(t){return typeof t}:function(t){return t&&"function"==typeof o.default&&t.constructor===o.default&&t!==o.default.prototype?"symbol":typeof t};e.default="function"==typeof o.default&&"symbol"===u(i.default)?function(t){return"undefined"==typeof t?"undefined":u(t)}:function(t){return t&&"function"==typeof o.default&&t.constructor===o.default&&t!==o.default.prototype?"symbol":"undefined"==typeof t?"undefined":u(t)}}),Qr=e(function(t,e){function n(t){return t&&t.__esModule?t:{default:t}}e.__esModule=!0;var r=Hr,i=n(r);e.default=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!==("undefined"==typeof e?"undefined":(0,i.default)(e))&&"function"!=typeof e?t:e}}),Yr=t(Qr),Zr=E,$r=j,ti=function(t,e){if($r(t),!Zr(e)&&null!==e)throw TypeError(e+": can't set as prototype!")},ei={set:Object.setPrototypeOf||("__proto__"in{}?function(t,e,n){try{n=S(Function.call,Vn.f(Object.prototype,"__proto__").set,2),n(t,[]),e=!(t instanceof Array)}catch(t){e=!0}return function(t,r){return ti(t,r),e?t.__proto__=r:n(t,r),t}}({},!1):void 0),check:ti},ni=et;ni(ni.S,"Object",{setPrototypeOf:ei.set});var ri=B.Object.setPrototypeOf,ii=e(function(t){t.exports={default:ri,__esModule:!0}}),si=et;si(si.S,"Object",{create:_e});var oi=B.Object,ui=function(t,e){return oi.create(t,e)},ai=e(function(t){t.exports={default:ui,__esModule:!0}}),fi=e(function(t,e){function n(t){return t&&t.__esModule?t:{default:t}}e.__esModule=!0;var r=ii,i=n(r),s=ai,o=n(s),u=Hr,a=n(u);e.default=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+("undefined"==typeof e?"undefined":(0,a.default)(e)));t.prototype=(0,o.default)(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(i.default?(0,i.default)(t,e):t.__proto__=e)}}),ci=t(fi),hi=function(){function t(){lt(this,t)}return gt(t,null,[{key:"abs",value:function(t){return null!=t?Math.abs(t):null}},{key:"privatize",value:function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t["_"+n]=e[n]);return t}},{key:"setter",value:function(t,e,n,r,i){var s=t[e],o=null!=n?n:r;return"function"==typeof i&&(o=i(o)),t[e]=o,o!==s}},{key:"throwUnimplemented",value:function(t,e){throw new Error('"'+e+'" method must be implemented on the '+t+" class")}},{key:"toUpperCase",value:function(t){return null!=t&&t.toUpperCase()}}]),t}(),li=function(){function t(){lt(this,t)}return gt(t,[{key:"getName",value:function(){hi.throwUnimplemented("Service","getName")}}]),t}(),_i=function(t){function e(){return lt(this,e),Yr(this,(e.__proto__||ct(e)).apply(this,arguments))}return ci(e,t),gt(e,[{key:"createCanvas",value:function(){hi.throwUnimplemented("ElementService","createCanvas")}},{key:"createImage",value:function(){hi.throwUnimplemented("ElementService","createImage")}},{key:"getName",value:function(){return"element"}},{key:"isCanvas",value:function(t){hi.throwUnimplemented("ElementService","isCanvas")}},{key:"isImage",value:function(t){hi.throwUnimplemented("ElementService","isImage")}}]),e}(li),di=function(t){function e(){return lt(this,e),Yr(this,(e.__proto__||ct(e)).apply(this,arguments))}return ci(e,t),gt(e,[{key:"createCanvas",value:function(){return document.createElement("canvas")}},{key:"createImage",value:function(){return document.createElement("img")}},{key:"isCanvas",value:function(t){return t instanceof HTMLCanvasElement}},{key:"isImage",value:function(t){return t instanceof HTMLImageElement}}]),e}(_i),vi=te,pi=gn,yi=bn,gi=i,ki=Nt,bi=Object.assign,mi=!bi||L(function(){var t={},e={},n=Symbol(),r="abcdefghijklmnopqrst";return t[n]=7,r.split("").forEach(function(t){e[t]=t}),7!=bi({},t)[n]||Object.keys(bi({},e)).join("")!=r})?function(t,e){for(var n=gi(t),r=arguments.length,i=1,s=pi.f,o=yi.f;r>i;)for(var u,a=ki(arguments[i++]),f=s?vi(a).concat(s(a)):vi(a),c=f.length,h=0;c>h;)o.call(a,u=f[h++])&&(n[u]=a[u]);return n}:bi,wi=et;wi(wi.S+wi.F,"Object",{assign:mi});var Bi=B.Object.assign,Oi=e(function(t){t.exports={default:Bi,__esModule:!0}}),Mi=t(Oi),Si=function(){function t(e){lt(this,t),this.qrious=e}return gt(t,[{key:"draw",value:function(t){hi.throwUnimplemented("Renderer","draw")}},{key:"getModuleSize",value:function(t){var e=this.qrious.padding||0,n=Math.floor((this.qrious.size-2*e)/t.width);return Math.max(1,n)}},{key:"getOffset",value:function(t){if(null!=this.qrious.padding)return this.qrious.padding;var e=this.getModuleSize(t),n=Math.floor((this.qrious.size-e*t.width)/2);return Math.max(0,n)}},{key:"render",value:function(t){this.resize(),this.reset(),this.draw(t)}},{key:"reset",value:function(){hi.throwUnimplemented("Renderer","reset")}},{key:"resize",value:function(){hi.throwUnimplemented("Renderer","resize")}}]),t}(),Ei=function(t){function e(){return lt(this,e),Yr(this,(e.__proto__||ct(e)).apply(this,arguments))}return ci(e,t),gt(e,[{key:"draw",value:function(t){var e=this.qrious,n=this.getModuleSize(t),r=this.getOffset(t),i=e.canvas.getContext("2d");i.fillStyle=e.foreground,i.globalAlpha=e.foregroundAlpha;for(var s=0;s<t.width;s++)for(var o=0;o<t.width;o++)t.buffer[o*t.width+s]&&i.fillRect(n*s+r,n*o+r,n,n)}},{key:"reset",value:function(){var t=this.qrious,e=t.canvas.getContext("2d");e.lineWidth=1,e.clearRect(0,0,t.size,t.size),e.fillStyle=t.background,e.globalAlpha=t.backgroundAlpha,e.fillRect(0,0,t.size,t.size)}},{key:"resize",value:function(){var t=this.qrious,e=t.canvas;e.width=t.size,e.height=t.size}}]),e}(Si),Ai=function(){function t(){lt(this,t)}return gt(t,null,[{key:"BLOCK",get:function(){return[0,11,15,19,23,27,31,16,18,20,22,24,26,28,20,22,24,24,26,28,28,22,24,24,26,26,28,28,24,24,26,26,26,28,28,24,26,26,26,28,28]}}]),t}(),ji=function(){function t(){lt(this,t)}return gt(t,null,[{key:"BLOCKS",get:function(){return[1,0,19,7,1,0,16,10,1,0,13,13,1,0,9,17,1,0,34,10,1,0,28,16,1,0,22,22,1,0,16,28,1,0,55,15,1,0,44,26,2,0,17,18,2,0,13,22,1,0,80,20,2,0,32,18,2,0,24,26,4,0,9,16,1,0,108,26,2,0,43,24,2,2,15,18,2,2,11,22,2,0,68,18,4,0,27,16,4,0,19,24,4,0,15,28,2,0,78,20,4,0,31,18,2,4,14,18,4,1,13,26,2,0,97,24,2,2,38,22,4,2,18,22,4,2,14,26,2,0,116,30,3,2,36,22,4,4,16,20,4,4,12,24,2,2,68,18,4,1,43,26,6,2,19,24,6,2,15,28,4,0,81,20,1,4,50,30,4,4,22,28,3,8,12,24,2,2,92,24,6,2,36,22,4,6,20,26,7,4,14,28,4,0,107,26,8,1,37,22,8,4,20,24,12,4,11,22,3,1,115,30,4,5,40,24,11,5,16,20,11,5,12,24,5,1,87,22,5,5,41,24,5,7,24,30,11,7,12,24,5,1,98,24,7,3,45,28,15,2,19,24,3,13,15,30,1,5,107,28,10,1,46,28,1,15,22,28,2,17,14,28,5,1,120,30,9,4,43,26,17,1,22,28,2,19,14,28,3,4,113,28,3,11,44,26,17,4,21,26,9,16,13,26,3,5,107,28,3,13,41,26,15,5,24,30,15,10,15,28,4,4,116,28,17,0,42,26,17,6,22,28,19,6,16,30,2,7,111,28,17,0,46,28,7,16,24,30,34,0,13,24,4,5,121,30,4,14,47,28,11,14,24,30,16,14,15,30,6,4,117,30,6,14,45,28,11,16,24,30,30,2,16,30,8,4,106,26,8,13,47,28,7,22,24,30,22,13,15,30,10,2,114,28,19,4,46,28,28,6,22,28,33,4,16,30,8,4,122,30,22,3,45,28,8,26,23,30,12,28,15,30,3,10,117,30,3,23,45,28,4,31,24,30,11,31,15,30,7,7,116,30,21,7,45,28,1,37,23,30,19,26,15,30,5,10,115,30,19,10,47,28,15,25,24,30,23,25,15,30,13,3,115,30,2,29,46,28,42,1,24,30,23,28,15,30,17,0,115,30,10,23,46,28,10,35,24,30,19,35,15,30,17,1,115,30,14,21,46,28,29,19,24,30,11,46,15,30,13,6,115,30,14,23,46,28,44,7,24,30,59,1,16,30,12,7,121,30,12,26,47,28,39,14,24,30,22,41,15,30,6,14,121,30,6,34,47,28,46,10,24,30,2,64,15,30,17,4,122,30,29,14,46,28,49,10,24,30,24,46,15,30,4,18,122,30,13,32,46,28,48,14,24,30,42,32,15,30,20,4,117,30,40,7,47,28,43,22,24,30,10,67,15,30,19,6,118,30,18,31,47,28,34,34,24,30,20,61,15,30]}},{key:"FINAL_FORMAT",get:function(){return[30660,29427,32170,30877,26159,25368,27713,26998,21522,20773,24188,23371,17913,16590,20375,19104,13663,12392,16177,14854,9396,8579,11994,11245,5769,5054,7399,6608,1890,597,3340,2107]}},{key:"LEVELS",get:function(){return{L:1,M:2,Q:3,H:4}}}]),t}(),Li=function(){function t(){lt(this,t)}return gt(t,null,[{key:"EXPONENT",get:function(){return[1,2,4,8,16,32,64,128,29,58,116,232,205,135,19,38,76,152,45,90,180,117,234,201,143,3,6,12,24,48,96,192,157,39,78,156,37,74,148,53,106,212,181,119,238,193,159,35,70,140,5,10,20,40,80,160,93,186,105,210,185,111,222,161,95,190,97,194,153,47,94,188,101,202,137,15,30,60,120,240,253,231,211,187,107,214,177,127,254,225,223,163,91,182,113,226,217,175,67,134,17,34,68,136,13,26,52,104,208,189,103,206,129,31,62,124,248,237,199,147,59,118,236,197,151,51,102,204,133,23,46,92,184,109,218,169,79,158,33,66,132,21,42,84,168,77,154,41,82,164,85,170,73,146,57,114,228,213,183,115,230,209,191,99,198,145,63,126,252,229,215,179,123,246,241,255,227,219,171,75,150,49,98,196,149,55,110,220,165,87,174,65,130,25,50,100,200,141,7,14,28,56,112,224,221,167,83,166,81,162,89,178,121,242,249,239,195,155,43,86,172,69,138,9,18,36,72,144,61,122,244,245,247,243,251,235,203,139,11,22,44,88,176,125,250,233,207,131,27,54,108,216,173,71,142,0]}},{key:"LOG",get:function(){return[255,0,1,25,2,50,26,198,3,223,51,238,27,104,199,75,4,100,224,14,52,141,239,129,28,193,105,248,200,8,76,113,5,138,101,47,225,36,15,33,53,147,142,218,240,18,130,69,29,181,194,125,106,39,249,185,201,154,9,120,77,228,114,166,6,191,139,98,102,221,48,253,226,152,37,179,16,145,34,136,54,208,148,206,143,150,219,189,241,210,19,92,131,56,70,64,30,66,182,163,195,72,126,110,107,58,40,84,250,133,186,61,202,94,155,159,10,21,121,43,78,212,229,172,115,243,167,87,7,112,192,247,140,128,99,13,103,74,222,237,49,197,254,24,227,165,153,119,38,184,180,124,17,68,146,217,35,32,137,46,55,63,209,91,149,188,207,205,144,135,151,178,220,252,190,97,242,86,211,171,20,42,93,158,132,60,57,83,71,109,65,162,31,45,67,216,183,123,164,118,196,23,73,236,127,12,111,246,108,161,59,82,41,157,85,170,251,96,134,177,187,204,62,90,203,89,95,176,156,169,160,81,11,245,22,235,122,117,44,215,79,174,213,233,230,231,173,232,116,214,244,234,168,80,88,175]}}]),t}(),Ni=function(){function t(){lt(this,t)}return gt(t,null,[{key:"BLOCK",get:function(){return[3220,1468,2713,1235,3062,1890,2119,1549,2344,2936,1117,2583,1330,2470,1667,2249,2028,3780,481,4011,142,3098,831,3445,592,2517,1776,2234,1951,2827,1070,2660,1345,3177]}}]),t}(),Pi=function(){function t(e){lt(this,t),this._badness=[],this._level=ji.LEVELS[e.level],this._polynomial=[],this._value=e.value,this._valueLength=this._value.length,this._version=0,this._stringBuffer=[];for(var n=void 0,r=void 0,i=void 0,s=void 0;this._version<40;){this._version++;var o=4*(this._level-1)+16*(this._version-1);if(i=ji.BLOCKS[o++],s=ji.BLOCKS[o++],n=ji.BLOCKS[o++],r=ji.BLOCKS[o],o=n*(i+s)+s-3+(this._version<=9),this._valueLength<=o)break}this._dataBlock=n,this._eccBlock=r,this._neccBlock1=i,this._neccBlock2=s,this.width=17+4*this._version,this.buffer=t._createArray(this.width*this.width),this._ecc=t._createArray(this._dataBlock+(this._dataBlock+this._eccBlock)*(this._neccBlock1+this._neccBlock2)+this._neccBlock2),this._mask=t._createArray((this.width*(this.width+1)+1)/2),this._insertFinders(),this._insertAlignments(),this.buffer[8+this.width*(this.width-8)]=1,this._insertTimingGap(),this._reverseMask(),this._insertTimingRowAndColumn(),this._insertVersion(),this._syncMask(),this._convertBitStream(this._value.length),this._calculatePolynomial(),this._appendEccToData(),this._interleaveBlocks(),this._pack(),this._finish()}return gt(t,null,[{key:"_createArray",value:function(t){for(var e=[],n=0;n<t;n++)e[n]=0;return e}},{key:"_getMaskBit",value:function(t,e){var n=void 0;return t>e&&(n=t,t=e,e=n),n=e,n+=e*e,n>>=1,n+=t}},{key:"_modN",value:function(t){for(;t>=255;)t-=255,t=(t>>8)+(255&t);return t}},{key:"N1",get:function(){return 3}},{key:"N2",get:function(){return 3}},{key:"N3",get:function(){return 40}},{key:"N4",get:function(){return 10}}]),gt(t,[{key:"_addAlignment",value:function(t,e){this.buffer[t+this.width*e]=1;for(var n=-2;n<2;n++)this.buffer[t+n+this.width*(e-2)]=1,this.buffer[t-2+this.width*(e+n+1)]=1,this.buffer[t+2+this.width*(e+n)]=1,this.buffer[t+n+1+this.width*(e+2)]=1;for(var r=0;r<2;r++)this._setMask(t-1,e+r),this._setMask(t+1,e-r),this._setMask(t-r,e-1),this._setMask(t+r,e+1)}},{key:"_appendData",value:function(e,n,r,i){for(var s=0;s<i;s++)this._stringBuffer[r+s]=0;for(var o=0;o<n;o++){var u=Li.LOG[this._stringBuffer[e+o]^this._stringBuffer[r]];if(255!==u)for(var a=1;a<i;a++)this._stringBuffer[r+a-1]=this._stringBuffer[r+a]^Li.EXPONENT[t._modN(u+this._polynomial[i-a])];else for(var f=r;f<r+i;f++)this._stringBuffer[f]=this._stringBuffer[f+1];this._stringBuffer[r+i-1]=255===u?0:Li.EXPONENT[t._modN(u+this._polynomial[0])]}}},{key:"_appendEccToData",value:function(){for(var t=0,e=this._calculateMaxLength(),n=0;n<this._neccBlock1;n++)this._appendData(t,this._dataBlock,e,this._eccBlock),t+=this._dataBlock,e+=this._eccBlock;for(var r=0;r<this._neccBlock2;r++)this._appendData(t,this._dataBlock+1,e,this._eccBlock),t+=this._dataBlock+1,e+=this._eccBlock}},{key:"_applyMask",value:function(t){var e=this.width;switch(t){case 0:for(var n=0;n<e;n++)for(var r=0;r<e;r++)r+n&1||this._isMasked(r,n)||(this.buffer[r+n*e]^=1);break;case 1:for(var i=0;i<e;i++)for(var s=0;s<e;s++)1&i||this._isMasked(s,i)||(this.buffer[s+i*e]^=1);break;case 2:for(var o=0;o<e;o++)for(var u=0,a=0;a<e;a++,u++)3===u&&(u=0),u||this._isMasked(a,o)||(this.buffer[a+o*e]^=1);break;case 3:for(var f=0,c=0;c<e;c++,f++){3===f&&(f=0);for(var h=f,l=0;l<e;l++,h++)3===h&&(h=0),h||this._isMasked(l,c)||(this.buffer[l+c*e]^=1)}break;case 4:for(var _=0;_<e;_++)for(var d=0,v=_>>1&1,p=0;p<e;p++,d++)3===d&&(d=0,v=!v),v||this._isMasked(p,_)||(this.buffer[p+_*e]^=1);break;case 5:for(var y=0,g=0;g<e;g++,y++){3===y&&(y=0);for(var k=0,b=0;b<e;b++,k++)3===k&&(k=0),(b&g&1)+!(!k|!y)||this._isMasked(b,g)||(this.buffer[b+g*e]^=1)}break;case 6:for(var m=0,w=0;w<e;w++,m++){3===m&&(m=0);for(var B=0,O=0;O<e;O++,B++)3===B&&(B=0),(O&w&1)+(B&&B===m)&1||this._isMasked(O,w)||(this.buffer[O+w*e]^=1)}break;case 7:for(var M=0,S=0;S<e;S++,M++){3===M&&(M=0);for(var E=0,A=0;A<e;A++,E++)3===E&&(E=0),(E&&E===M)+(A+S&1)&1||this._isMasked(A,S)||(this.buffer[A+S*e]^=1)}}}},{key:"_calculateMaxLength",value:function(){return this._dataBlock*(this._neccBlock1+this._neccBlock2)+this._neccBlock2}},{key:"_calculatePolynomial",value:function(){this._polynomial[0]=1;for(var e=0;e<this._eccBlock;e++){this._polynomial[e+1]=1;for(var n=e;n>0;n--)this._polynomial[n]=this._polynomial[n]?this._polynomial[n-1]^Li.EXPONENT[t._modN(Li.LOG[this._polynomial[n]]+e)]:this._polynomial[n-1];this._polynomial[0]=Li.EXPONENT[t._modN(Li.LOG[this._polynomial[0]]+e)]}for(var r=0;r<=this._eccBlock;r++)this._polynomial[r]=Li.LOG[this._polynomial[r]]}},{key:"_checkBadness",value:function(){for(var e=0,n=this.width,r=0;r<n-1;r++)for(var i=0;i<n-1;i++)(this.buffer[i+n*r]&&this.buffer[i+1+n*r]&&this.buffer[i+n*(r+1)]&&this.buffer[i+1+n*(r+1)]||!(this.buffer[i+n*r]||this.buffer[i+1+n*r]||this.buffer[i+n*(r+1)]||this.buffer[i+1+n*(r+1)]))&&(e+=t.N2);for(var s=0,o=0;o<n;o++){var u=0;this._badness[0]=0;for(var a=0,f=0;f<n;f++){var c=this.buffer[f+n*o];a===c?this._badness[u]++:this._badness[++u]=1,a=c,s+=a?1:-1}e+=this._getBadness(u)}s<0&&(s=-s);var h=0,l=s;for(l+=l<<2,l<<=1;l>n*n;)l-=n*n,h++;e+=h*t.N4;for(var _=0;_<n;_++){var d=0;this._badness[0]=0;for(var v=0,p=0;p<n;p++){var y=this.buffer[_+n*p];v===y?this._badness[d]++:this._badness[++d]=1,v=y}e+=this._getBadness(d)}return e}},{key:"_convertBitStream",value:function(t){for(var e=0;e<t;e++)this._ecc[e]=this._value.charCodeAt(e);this._stringBuffer=this._ecc.slice(0);var n=this._calculateMaxLength();t>=n-2&&(t=n-2,this._version>9&&t--);var r=t;if(this._version>9){for(this._stringBuffer[r+2]=0,this._stringBuffer[r+3]=0;r--;){var i=this._stringBuffer[r];this._stringBuffer[r+3]|=255&i<<4,this._stringBuffer[r+2]=i>>4}this._stringBuffer[2]|=255&t<<4,this._stringBuffer[1]=t>>4,this._stringBuffer[0]=64|t>>12}else{for(this._stringBuffer[r+1]=0,this._stringBuffer[r+2]=0;r--;){var s=this._stringBuffer[r];this._stringBuffer[r+2]|=255&s<<4,this._stringBuffer[r+1]=s>>4}this._stringBuffer[1]|=255&t<<4,this._stringBuffer[0]=64|t>>4}for(r=t+3-(this._version<10);r<n;)this._stringBuffer[r++]=236,this._stringBuffer[r++]=17}},{key:"_getBadness",value:function(e){for(var n=0,r=0;r<=e;r++)this._badness[r]>=5&&(n+=t.N1+this._badness[r]-5);for(var i=3;i<e-1;i+=2)this._badness[i-2]===this._badness[i+2]&&this._badness[i+2]===this._badness[i-1]&&this._badness[i-1]===this._badness[i+1]&&3*this._badness[i-1]===this._badness[i]&&(0===this._badness[i-3]||i+3>e||3*this._badness[i-3]>=4*this._badness[i]||3*this._badness[i+3]>=4*this._badness[i])&&(n+=t.N3);return n}},{key:"_finish",value:function(){this._stringBuffer=this.buffer.slice(0);var t=0,e=void 0,n=3e4;for(e=0;e<8;e++){this._applyMask(e);var r=this._checkBadness();if(r<n&&(n=r,t=e),7===t)break;this.buffer=this._stringBuffer.slice(0)}for(t!==e&&this._applyMask(t),n=ji.FINAL_FORMAT[t+(this._level-1<<3)],e=0;e<8;e++,n>>=1)1&n&&(this.buffer[this.width-1-e+8*this.width]=1,e<6?this.buffer[8+this.width*e]=1:this.buffer[8+this.width*(e+1)]=1);for(e=0;e<7;e++,n>>=1)1&n&&(this.buffer[8+this.width*(this.width-7+e)]=1,e?this.buffer[6-e+8*this.width]=1:this.buffer[7+8*this.width]=1)}},{key:"_interleaveBlocks",value:function(){var t=this._calculateMaxLength(),e=void 0,n=0;for(e=0;e<this._dataBlock;e++){for(var r=0;r<this._neccBlock1;r++)this._ecc[n++]=this._stringBuffer[e+r*this._dataBlock];for(var i=0;i<this._neccBlock2;i++)this._ecc[n++]=this._stringBuffer[this._neccBlock1*this._dataBlock+e+i*(this._dataBlock+1)]}for(var s=0;s<this._neccBlock2;s++)this._ecc[n++]=this._stringBuffer[this._neccBlock1*this._dataBlock+e+s*(this._dataBlock+1)];for(e=0;e<this._eccBlock;e++)for(var o=0;o<this._neccBlock1+this._neccBlock2;o++)this._ecc[n++]=this._stringBuffer[t+e+o*this._eccBlock];this._stringBuffer=this._ecc}},{key:"_insertAlignments",value:function(){var t=this.width;if(this._version>1)for(var e=Ai.BLOCK[this._version],n=t-7;;){for(var r=t-7;r>e-3&&(this._addAlignment(r,n),!(r<e));)r-=e;if(n<=e+9)break;n-=e,this._addAlignment(6,n),this._addAlignment(n,6)}}},{key:"_insertFinders",value:function(){for(var t=this.width,e=0;e<3;e++){var n=0,r=0;1===e&&(n=t-7),2===e&&(r=t-7),this.buffer[r+3+t*(n+3)]=1;for(var i=0;i<6;i++)this.buffer[r+i+t*n]=1,this.buffer[r+t*(n+i+1)]=1,this.buffer[r+6+t*(n+i)]=1,this.buffer[r+i+1+t*(n+6)]=1;for(var s=1;s<5;s++)this._setMask(r+s,n+1), | ||
this._setMask(r+1,n+s+1),this._setMask(r+5,n+s),this._setMask(r+s+1,n+5);for(var o=2;o<4;o++)this.buffer[r+o+t*(n+2)]=1,this.buffer[r+2+t*(n+o+1)]=1,this.buffer[r+4+t*(n+o)]=1,this.buffer[r+o+1+t*(n+4)]=1}}},{key:"_insertTimingGap",value:function(){for(var t=this.width,e=0;e<7;e++)this._setMask(7,e),this._setMask(t-8,e),this._setMask(7,e+t-7);for(var n=0;n<8;n++)this._setMask(n,7),this._setMask(n+t-8,7),this._setMask(n,t-8)}},{key:"_insertTimingRowAndColumn",value:function(){for(var t=this.width,e=0;e<t-14;e++)1&e?(this._setMask(8+e,6),this._setMask(6,8+e)):(this.buffer[8+e+6*t]=1,this.buffer[6+t*(8+e)]=1)}},{key:"_insertVersion",value:function(){var t=this.width;if(this._version>6)for(var e=Ni.BLOCK[this._version-7],n=17,r=0;r<6;r++)for(var i=0;i<3;i++,n--)1&(n>11?this._version>>n-12:e>>n)?(this.buffer[5-r+t*(2-i+t-11)]=1,this.buffer[2-i+t-11+t*(5-r)]=1):(this._setMask(5-r,2-i+t-11),this._setMask(2-i+t-11,5-r))}},{key:"_isMasked",value:function(e,n){var r=t._getMaskBit(e,n);return 1===this._mask[r]}},{key:"_pack",value:function(){for(var t=this.width-1,e=this.width-1,n=1,r=1,i=(this._dataBlock+this._eccBlock)*(this._neccBlock1+this._neccBlock2)+this._neccBlock2,s=0;s<i;s++)for(var o=this._stringBuffer[s],u=0;u<8;u++,o<<=1){128&o&&(this.buffer[t+this.width*e]=1);do r?t--:(t++,n?0!==e?e--:(t-=2,n=!n,6===t&&(t--,e=9)):e!==this.width-1?e++:(t-=2,n=!n,6===t&&(t--,e-=8))),r=!r;while(this._isMasked(t,e))}}},{key:"_reverseMask",value:function(){for(var t=this.width,e=0;e<9;e++)this._setMask(e,8);for(var n=0;n<8;n++)this._setMask(n+t-8,8),this._setMask(8,n);for(var r=0;r<7;r++)this._setMask(8,r+t-7)}},{key:"_setMask",value:function(e,n){var r=t._getMaskBit(e,n);this._mask[r]=1}},{key:"_syncMask",value:function(){for(var t=this.width,e=0;e<t;e++)for(var n=0;n<=e;n++)this.buffer[n+t*e]&&this._setMask(n,e)}}]),t}(),Ti=function(t){function e(){return lt(this,e),Yr(this,(e.__proto__||ct(e)).apply(this,arguments))}return ci(e,t),gt(e,[{key:"draw",value:function(){var t=this.qrious;t.image.src=t.toDataURL()}},{key:"reset",value:function(){var t=this.qrious;t.image.src=""}},{key:"resize",value:function(){var t=this.qrious,e=t.image;e.width=t.size,e.height=t.size}}]),e}(Si),Ci=function(){function t(){lt(this,t),this._services={}}return gt(t,[{key:"getService",value:function(t){var e=this._services[t];if(!e)throw new Error("Service is not being managed with name: "+t);return e}},{key:"setService",value:function(t,e){if(this._services[t])throw new Error("Service is already managed with name: "+t);e&&(this._services[t]=e)}}]),t}(),Fi=function(){function t(e){lt(this,t),e=t._parseOptions(e),hi.privatize(this,e);var n=this._element,r=t._serviceManager.getService("element");this.canvas=n&&r.isCanvas(n)?n:r.createCanvas(),this.canvas.qrious=this,this.image=n&&r.isImage(n)?n:r.createImage(),this.image.qrious=this,this._renderers=[new Ei(this),new Ti(this)],this.update()}return gt(t,null,[{key:"use",value:function(e){t._serviceManager.setService(e.getName(),e)}},{key:"_parseOptions",value:function(e){return e=Mi({},t.DEFAULTS,e),e.backgroundAlpha=hi.abs(e.backgroundAlpha),e.foregroundAlpha=hi.abs(e.foregroundAlpha),e.level=hi.toUpperCase(e.level),e.padding=hi.abs(e.padding),e.size=hi.abs(e.size),e}},{key:"DEFAULTS",get:function(){return{background:"white",backgroundAlpha:1,foreground:"black",foregroundAlpha:1,level:"L",mime:"image/png",padding:null,size:100,value:""}}},{key:"VERSION",get:function(){return"2.2.0"}}]),gt(t,[{key:"toDataURL",value:function(t){return this.canvas.toDataURL(t||this.mime)}},{key:"update",value:function(){var t=new Pi({level:this.level,value:this.value});this._renderers.forEach(function(e){return e.render(t)})}},{key:"background",get:function(){return this._background},set:function(e){var n=hi.setter(this,"_background",e,t.DEFAULTS.background);n&&this.update()}},{key:"backgroundAlpha",get:function(){return this._backgroundAlpha},set:function(e){var n=hi.setter(this,"_backgroundAlpha",e,t.DEFAULTS.backgroundAlpha);n&&this.update()}},{key:"foreground",get:function(){return this._foreground},set:function(e){var n=hi.setter(this,"_foreground",e,t.DEFAULTS.foreground);n&&this.update()}},{key:"foregroundAlpha",get:function(){return this._foregroundAlpha},set:function(e){var n=hi.setter(this,"_foregroundAlpha",e,t.DEFAULTS.foregroundAlpha);n&&this.update()}},{key:"level",get:function(){return this._level},set:function(e){var n=hi.setter(this,"_level",e,t.DEFAULTS.level,hi.toUpperCase);n&&this.update()}},{key:"mime",get:function(){return this._mime},set:function(e){var n=hi.setter(this,"_mime",e,t.DEFAULTS.mime);n&&this.update()}},{key:"padding",get:function(){return this._padding},set:function(e){var n=hi.setter(this,"_padding",e,t.DEFAULTS.padding,hi.abs);n&&this.update()}},{key:"size",get:function(){return this._size},set:function(e){var n=hi.setter(this,"_size",e,t.DEFAULTS.size,hi.abs);n&&this.update()}},{key:"value",get:function(){return this._value},set:function(e){var n=hi.setter(this,"_value",e,t.DEFAULTS.value);n&&this.update()}}]),t}();return Fi._serviceManager=new Ci,Fi.use(new di),Fi}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define("qrious",e):t.QRious=e()}(this,function(){"use strict";function t(t){return t&&t.__esModule?t.default:t}function e(t,e){return e={exports:{}},t(e,e.exports),e.exports}var n=function(t){if(void 0==t)throw TypeError("Can't call method on "+t);return t},r=function(t){return Object(n(t))},i={}.hasOwnProperty,s=function(t,e){return i.call(t,e)},o=e(function(t){var e=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=e)}),u=o["__core-js_shared__"]||(o["__core-js_shared__"]={}),a=function(t){return u[t]||(u[t]={})},f=0,c=Math.random(),h=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++f+c).toString(36))},l=a("keys"),_=function(t){return l[t]||(l[t]=h(t))},v=_("IE_PROTO"),d=Object.prototype,p=Object.getPrototypeOf||function(t){return t=r(t),s(t,v)?t[v]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?d:null},y=e(function(t){var e=t.exports={version:"2.4.0"};"number"==typeof __e&&(__e=e)}),g=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t},k=function(t,e,n){if(g(t),void 0===e)return t;switch(n){case 1:return function(n){return t.call(e,n)};case 2:return function(n,r){return t.call(e,n,r)};case 3:return function(n,r,i){return t.call(e,n,r,i)}}return function(){return t.apply(e,arguments)}},b=function(t){return"object"==typeof t?null!==t:"function"==typeof t},m=function(t){if(!b(t))throw TypeError(t+" is not an object!");return t},w=function(t){try{return!!t()}catch(t){return!0}},B=!w(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a}),O=o.document,M=b(O)&&b(O.createElement),S=function(t){return M?O.createElement(t):{}},E=!B&&!w(function(){return 7!=Object.defineProperty(S("div"),"a",{get:function(){return 7}}).a}),j=function(t,e){if(!b(t))return t;var n,r;if(e&&"function"==typeof(n=t.toString)&&!b(r=n.call(t)))return r;if("function"==typeof(n=t.valueOf)&&!b(r=n.call(t)))return r;if(!e&&"function"==typeof(n=t.toString)&&!b(r=n.call(t)))return r;throw TypeError("Can't convert object to primitive value")},A=Object.defineProperty,N=B?Object.defineProperty:function(t,e,n){if(m(t),e=j(e,!0),m(n),E)try{return A(t,e,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported!");return"value"in n&&(t[e]=n.value),t},P={f:N},L=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},C=B?function(t,e,n){return P.f(t,e,L(1,n))}:function(t,e,n){return t[e]=n,t},T=function(t,e,n){var r,i,s,u=t&T.F,a=t&T.G,f=t&T.S,c=t&T.P,h=t&T.B,l=t&T.W,_=a?y:y[e]||(y[e]={}),v=_.prototype,d=a?o:f?o[e]:(o[e]||{}).prototype;a&&(n=e);for(r in n)(i=!u&&d&&void 0!==d[r])&&r in _||(s=i?d[r]:n[r],_[r]=a&&"function"!=typeof d[r]?n[r]:h&&i?k(s,o):l&&d[r]==s?function(t){var e=function(e,n,r){if(this instanceof t){switch(arguments.length){case 0:return new t;case 1:return new t(e);case 2:return new t(e,n)}return new t(e,n,r)}return t.apply(this,arguments)};return e.prototype=t.prototype,e}(s):c&&"function"==typeof s?k(Function.call,s):s,c&&((_.virtual||(_.virtual={}))[r]=s,t&T.R&&v&&!v[r]&&C(v,r,s)))};T.F=1,T.G=2,T.S=4,T.P=8,T.B=16,T.W=32,T.U=64,T.R=128;var x=T;!function(t,e){var n=(y.Object||{})[t]||Object[t],r={};r[t]=e(n),x(x.S+x.F*w(function(){n(1)}),"Object",r)}("getPrototypeOf",function(){return function(t){return p(r(t))}});var R=y.Object.getPrototypeOf,F=e(function(t){t.exports={default:R,__esModule:!0}}),I=t(F),z=e(function(t,e){e.__esModule=!0,e.default=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}}),U=t(z);x(x.S+x.F*!B,"Object",{defineProperty:P.f});var D=y.Object,K=function(t,e,n){return D.defineProperty(t,e,n)},V=e(function(t){t.exports={default:K,__esModule:!0}}),q=e(function(t,e){e.__esModule=!0;var n=function(t){return t&&t.__esModule?t:{default:t}}(V);e.default=function(){function t(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),(0,n.default)(t,i.key,i)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}()}),G=t(q),W=Math.ceil,X=Math.floor,J=function(t){return isNaN(t=+t)?0:(t>0?X:W)(t)},H=C,Q={},Y={}.toString,Z=function(t){return Y.call(t).slice(8,-1)},$=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==Z(t)?t.split(""):Object(t)},tt=function(t){return $(n(t))},et=Math.min,nt=function(t){return t>0?et(J(t),9007199254740991):0},rt=Math.max,it=Math.min,st=function(t,e){return t=J(t),t<0?rt(t+e,0):it(t,e)},ot=function(t){return function(e,n,r){var i,s=tt(e),o=nt(s.length),u=st(r,o);if(t&&n!=n){for(;o>u;)if((i=s[u++])!=i)return!0}else for(;o>u;u++)if((t||u in s)&&s[u]===n)return t||u||0;return!t&&-1}}(!1),ut=_("IE_PROTO"),at=function(t,e){var n,r=tt(t),i=0,o=[];for(n in r)n!=ut&&s(r,n)&&o.push(n);for(;e.length>i;)s(r,n=e[i++])&&(~ot(o,n)||o.push(n));return o},ft="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(","),ct=Object.keys||function(t){return at(t,ft)},ht=B?Object.defineProperties:function(t,e){m(t);for(var n,r=ct(e),i=r.length,s=0;i>s;)P.f(t,n=r[s++],e[n]);return t},lt=o.document&&document.documentElement,_t=_("IE_PROTO"),vt=function(){},dt=function(){var t,e=S("iframe"),n=ft.length;for(e.style.display="none",lt.appendChild(e),e.src="javascript:",t=e.contentWindow.document,t.open(),t.write("<script>document.F=Object<\/script>"),t.close(),dt=t.F;n--;)delete dt.prototype[ft[n]];return dt()},pt=Object.create||function(t,e){var n;return null!==t?(vt.prototype=m(t),n=new vt,vt.prototype=null,n[_t]=t):n=dt(),void 0===e?n:ht(n,e)},yt=e(function(t){var e=a("wks"),n=o.Symbol,r="function"==typeof n;(t.exports=function(t){return e[t]||(e[t]=r&&n[t]||(r?n:h)("Symbol."+t))}).store=e}),gt=P.f,kt=yt("toStringTag"),bt=function(t,e,n){t&&!s(t=n?t:t.prototype,kt)&>(t,kt,{configurable:!0,value:e})},mt={};C(mt,yt("iterator"),function(){return this});var wt=function(t,e,n){t.prototype=pt(mt,{next:L(1,n)}),bt(t,e+" Iterator")},Bt=yt("iterator"),Ot=!([].keys&&"next"in[].keys()),Mt=function(){return this},St=function(t,e,n,r,i,s,o){wt(n,e,r);var u,a,f,c=function(t){if(!Ot&&t in v)return v[t];switch(t){case"keys":case"values":return function(){return new n(this,t)}}return function(){return new n(this,t)}},h=e+" Iterator",l="values"==i,_=!1,v=t.prototype,d=v[Bt]||v["@@iterator"]||i&&v[i],y=d||c(i),g=i?l?c("entries"):y:void 0,k="Array"==e?v.entries||d:d;if(k&&(f=p(k.call(new t)))!==Object.prototype&&bt(f,h,!0),l&&d&&"values"!==d.name&&(_=!0,y=function(){return d.call(this)}),o&&(Ot||_||!v[Bt])&&C(v,Bt,y),Q[e]=y,Q[h]=Mt,i)if(u={values:l?y:c("values"),keys:s?y:c("keys"),entries:g},o)for(a in u)a in v||H(v,a,u[a]);else x(x.P+x.F*(Ot||_),e,u);return u},Et=function(t){return function(e,r){var i,s,o=String(n(e)),u=J(r),a=o.length;return u<0||u>=a?t?"":void 0:(i=o.charCodeAt(u),i<55296||i>56319||u+1===a||(s=o.charCodeAt(u+1))<56320||s>57343?t?o.charAt(u):i:t?o.slice(u,u+2):s-56320+(i-55296<<10)+65536)}}(!0);St(String,"String",function(t){this._t=String(t),this._i=0},function(){var t,e=this._t,n=this._i;return n>=e.length?{value:void 0,done:!0}:(t=Et(e,n),this._i+=t.length,{value:t,done:!1})});var jt=function(t,e){return{value:e,done:!!t}};St(Array,"Array",function(t,e){this._t=tt(t),this._i=0,this._k=e},function(){var t=this._t,e=this._k,n=this._i++;return!t||n>=t.length?(this._t=void 0,jt(1)):"keys"==e?jt(0,n):"values"==e?jt(0,t[n]):jt(0,[n,t[n]])},"values");Q.Arguments=Q.Array;for(var At=yt("toStringTag"),Nt=["NodeList","DOMTokenList","MediaList","StyleSheetList","CSSRuleList"],Pt=0;Pt<5;Pt++){var Lt=Nt[Pt],Ct=o[Lt],Tt=Ct&&Ct.prototype;Tt&&!Tt[At]&&C(Tt,At,Lt),Q[Lt]=Q.Array}var xt=yt,Rt={f:xt},Ft=Rt.f("iterator"),It=e(function(t){t.exports={default:Ft,__esModule:!0}}),zt=e(function(t){var e=h("meta"),n=P.f,r=0,i=Object.isExtensible||function(){return!0},o=!w(function(){return i(Object.preventExtensions({}))}),u=function(t){n(t,e,{value:{i:"O"+ ++r,w:{}}})},a=function(t,n){if(!b(t))return"symbol"==typeof t?t:("string"==typeof t?"S":"P")+t;if(!s(t,e)){if(!i(t))return"F";if(!n)return"E";u(t)}return t[e].i},f=function(t,n){if(!s(t,e)){if(!i(t))return!0;if(!n)return!1;u(t)}return t[e].w},c=function(t){return o&&l.NEED&&i(t)&&!s(t,e)&&u(t),t},l=t.exports={KEY:e,NEED:!1,fastKey:a,getWeak:f,onFreeze:c}}),Ut=P.f,Dt=function(t){var e=y.Symbol||(y.Symbol={});"_"==t.charAt(0)||t in e||Ut(e,t,{value:Rt.f(t)})},Kt=function(t,e){for(var n,r=tt(t),i=ct(r),s=i.length,o=0;s>o;)if(r[n=i[o++]]===e)return n},Vt=Object.getOwnPropertySymbols,qt={f:Vt},Gt={}.propertyIsEnumerable,Wt={f:Gt},Xt=function(t){var e=ct(t),n=qt.f;if(n)for(var r,i=n(t),s=Wt.f,o=0;i.length>o;)s.call(t,r=i[o++])&&e.push(r);return e},Jt=Array.isArray||function(t){return"Array"==Z(t)},Ht=ft.concat("length","prototype"),Qt=Object.getOwnPropertyNames||function(t){return at(t,Ht)},Yt={f:Qt},Zt=Yt.f,$t={}.toString,te="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],ee=function(t){try{return Zt(t)}catch(t){return te.slice()}},ne=function(t){return te&&"[object Window]"==$t.call(t)?ee(t):Zt(tt(t))},re={f:ne},ie=Object.getOwnPropertyDescriptor,se=B?ie:function(t,e){if(t=tt(t),e=j(e,!0),E)try{return ie(t,e)}catch(t){}if(s(t,e))return L(!Wt.f.call(t,e),t[e])},oe={f:se},ue=zt.KEY,ae=oe.f,fe=P.f,ce=re.f,he=o.Symbol,le=o.JSON,_e=le&&le.stringify,ve=yt("_hidden"),de=yt("toPrimitive"),pe={}.propertyIsEnumerable,ye=a("symbol-registry"),ge=a("symbols"),ke=a("op-symbols"),be=Object.prototype,me="function"==typeof he,we=o.QObject,Be=!we||!we.prototype||!we.prototype.findChild,Oe=B&&w(function(){return 7!=pt(fe({},"a",{get:function(){return fe(this,"a",{value:7}).a}})).a})?function(t,e,n){var r=ae(be,e);r&&delete be[e],fe(t,e,n),r&&t!==be&&fe(be,e,r)}:fe,Me=function(t){var e=ge[t]=pt(he.prototype);return e._k=t,e},Se=me&&"symbol"==typeof he.iterator?function(t){return"symbol"==typeof t}:function(t){return t instanceof he},Ee=function(t,e,n){return t===be&&Ee(ke,e,n),m(t),e=j(e,!0),m(n),s(ge,e)?(n.enumerable?(s(t,ve)&&t[ve][e]&&(t[ve][e]=!1),n=pt(n,{enumerable:L(0,!1)})):(s(t,ve)||fe(t,ve,L(1,{})),t[ve][e]=!0),Oe(t,e,n)):fe(t,e,n)},je=function(t,e){m(t);for(var n,r=Xt(e=tt(e)),i=0,s=r.length;s>i;)Ee(t,n=r[i++],e[n]);return t},Ae=function(t,e){return void 0===e?pt(t):je(pt(t),e)},Ne=function(t){var e=pe.call(this,t=j(t,!0));return!(this===be&&s(ge,t)&&!s(ke,t))&&(!(e||!s(this,t)||!s(ge,t)||s(this,ve)&&this[ve][t])||e)},Pe=function(t,e){if(t=tt(t),e=j(e,!0),t!==be||!s(ge,e)||s(ke,e)){var n=ae(t,e);return!n||!s(ge,e)||s(t,ve)&&t[ve][e]||(n.enumerable=!0),n}},Le=function(t){for(var e,n=ce(tt(t)),r=[],i=0;n.length>i;)s(ge,e=n[i++])||e==ve||e==ue||r.push(e);return r},Ce=function(t){for(var e,n=t===be,r=ce(n?ke:tt(t)),i=[],o=0;r.length>o;)!s(ge,e=r[o++])||n&&!s(be,e)||i.push(ge[e]);return i};me||(he=function(){if(this instanceof he)throw TypeError("Symbol is not a constructor!");var t=h(arguments.length>0?arguments[0]:void 0),e=function(n){this===be&&e.call(ke,n),s(this,ve)&&s(this[ve],t)&&(this[ve][t]=!1),Oe(this,t,L(1,n))};return B&&Be&&Oe(be,t,{configurable:!0,set:e}),Me(t)},H(he.prototype,"toString",function(){return this._k}),oe.f=Pe,P.f=Ee,Yt.f=re.f=Le,Wt.f=Ne,qt.f=Ce,Rt.f=function(t){return Me(yt(t))}),x(x.G+x.W+x.F*!me,{Symbol:he});for(var Te="hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),xe=0;Te.length>xe;)yt(Te[xe++]);for(var Te=ct(yt.store),xe=0;Te.length>xe;)Dt(Te[xe++]);x(x.S+x.F*!me,"Symbol",{for:function(t){return s(ye,t+="")?ye[t]:ye[t]=he(t)},keyFor:function(t){if(Se(t))return Kt(ye,t);throw TypeError(t+" is not a symbol!")},useSetter:function(){Be=!0},useSimple:function(){Be=!1}}),x(x.S+x.F*!me,"Object",{create:Ae,defineProperty:Ee,defineProperties:je,getOwnPropertyDescriptor:Pe,getOwnPropertyNames:Le,getOwnPropertySymbols:Ce}),le&&x(x.S+x.F*(!me||w(function(){var t=he();return"[null]"!=_e([t])||"{}"!=_e({a:t})||"{}"!=_e(Object(t))})),"JSON",{stringify:function(t){if(void 0!==t&&!Se(t)){for(var e,n,r=[t],i=1;arguments.length>i;)r.push(arguments[i++]);return e=r[1],"function"==typeof e&&(n=e),!n&&Jt(e)||(e=function(t,e){if(n&&(e=n.call(this,t,e)),!Se(e))return e}),r[1]=e,_e.apply(le,r)}}}),he.prototype[de]||C(he.prototype,de,he.prototype.valueOf),bt(he,"Symbol"),bt(Math,"Math",!0),bt(o.JSON,"JSON",!0),Dt("asyncIterator"),Dt("observable");var Re=y.Symbol,Fe=e(function(t){t.exports={default:Re,__esModule:!0}}),Ie=e(function(t,e){function n(t){return t&&t.__esModule?t:{default:t}}e.__esModule=!0;var r=n(It),i=n(Fe),s="function"==typeof i.default&&"symbol"==typeof r.default?function(t){return typeof t}:function(t){return t&&"function"==typeof i.default&&t.constructor===i.default&&t!==i.default.prototype?"symbol":typeof t};e.default="function"==typeof i.default&&"symbol"===s(r.default)?function(t){return void 0===t?"undefined":s(t)}:function(t){return t&&"function"==typeof i.default&&t.constructor===i.default&&t!==i.default.prototype?"symbol":void 0===t?"undefined":s(t)}}),ze=e(function(t,e){e.__esModule=!0;var n=function(t){return t&&t.__esModule?t:{default:t}}(Ie);e.default=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!==(void 0===e?"undefined":(0,n.default)(e))&&"function"!=typeof e?t:e}}),Ue=t(ze),De=function(t,e){if(m(t),!b(e)&&null!==e)throw TypeError(e+": can't set as prototype!")},Ke={set:Object.setPrototypeOf||("__proto__"in{}?function(t,e,n){try{n=k(Function.call,oe.f(Object.prototype,"__proto__").set,2),n(t,[]),e=!(t instanceof Array)}catch(t){e=!0}return function(t,r){return De(t,r),e?t.__proto__=r:n(t,r),t}}({},!1):void 0),check:De};x(x.S,"Object",{setPrototypeOf:Ke.set});var Ve=y.Object.setPrototypeOf,qe=e(function(t){t.exports={default:Ve,__esModule:!0}});x(x.S,"Object",{create:pt});var Ge=y.Object,We=function(t,e){return Ge.create(t,e)},Xe=e(function(t){t.exports={default:We,__esModule:!0}}),Je=e(function(t,e){function n(t){return t&&t.__esModule?t:{default:t}}e.__esModule=!0;var r=n(qe),i=n(Xe),s=n(Ie);e.default=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+(void 0===e?"undefined":(0,s.default)(e)));t.prototype=(0,i.default)(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(r.default?(0,r.default)(t,e):t.__proto__=e)}}),He=t(Je),Qe=function(){function t(){U(this,t)}return G(t,null,[{key:"abs",value:function(t){return null!=t?Math.abs(t):null}},{key:"hasOwn",value:function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}},{key:"throwUnimplemented",value:function(t,e){throw new Error('"'+e+'" method must be implemented on the '+t+" class")}},{key:"toUpperCase",value:function(t){return null!=t?t.toUpperCase():null}}]),t}(),Ye=function(){function t(){U(this,t)}return G(t,[{key:"getName",value:function(){Qe.throwUnimplemented("Service","getName")}}]),t}(),Ze=function(t){function e(){return U(this,e),Ue(this,(e.__proto__||I(e)).apply(this,arguments))}return He(e,t),G(e,[{key:"createCanvas",value:function(){Qe.throwUnimplemented("ElementService","createCanvas")}},{key:"createImage",value:function(){Qe.throwUnimplemented("ElementService","createImage")}},{key:"getName",value:function(){return"element"}},{key:"isCanvas",value:function(t){Qe.throwUnimplemented("ElementService","isCanvas")}},{key:"isImage",value:function(t){Qe.throwUnimplemented("ElementService","isImage")}}]),e}(Ye),$e=function(t){function e(){return U(this,e),Ue(this,(e.__proto__||I(e)).apply(this,arguments))}return He(e,t),G(e,[{key:"createCanvas",value:function(){return document.createElement("canvas")}},{key:"createImage",value:function(){return document.createElement("img")}},{key:"isCanvas",value:function(t){return t instanceof HTMLCanvasElement}},{key:"isImage",value:function(t){return t instanceof HTMLImageElement}}]),e}(Ze),tn=function(){function t(e,n,r){U(this,t),this.qrious=e,this.element=n,this.element.qrious=e,this.enabled=Boolean(r)}return G(t,[{key:"draw",value:function(t){Qe.throwUnimplemented("Renderer","draw")}},{key:"getElement",value:function(){return this.enabled||(this.enabled=!0,this.render()),this.element}},{key:"getModuleSize",value:function(t){var e=this.qrious,n=e.padding||0,r=Math.floor((e.size-2*n)/t.width);return Math.max(1,r)}},{key:"getOffset",value:function(t){var e=this.qrious,n=e.padding;if(null!=n)return n;var r=this.getModuleSize(t),i=Math.floor((e.size-r*t.width)/2);return Math.max(0,i)}},{key:"render",value:function(t){this.enabled&&(this.resize(),this.reset(),this.draw(t))}},{key:"reset",value:function(){Qe.throwUnimplemented("Renderer","reset")}},{key:"resize",value:function(){Qe.throwUnimplemented("Renderer","resize")}}]),t}(),en=function(t){function e(){return U(this,e),Ue(this,(e.__proto__||I(e)).apply(this,arguments))}return He(e,t),G(e,[{key:"draw",value:function(t){var e=this.qrious,n=this.getModuleSize(t),r=this.getOffset(t),i=this.element.getContext("2d");i.fillStyle=e.foreground,i.globalAlpha=e.foregroundAlpha;for(var s=0;s<t.width;s++)for(var o=0;o<t.width;o++)t.buffer[o*t.width+s]&&i.fillRect(n*s+r,n*o+r,n,n)}},{key:"reset",value:function(){var t=this.qrious,e=this.element.getContext("2d"),n=t.size;e.lineWidth=1,e.clearRect(0,0,n,n),e.fillStyle=t.background,e.globalAlpha=t.backgroundAlpha,e.fillRect(0,0,n,n)}},{key:"resize",value:function(){this.element.width=this.element.height=this.qrious.size}}]),e}(tn),nn=function(){function t(){U(this,t)}return G(t,null,[{key:"BLOCK",get:function(){return[0,11,15,19,23,27,31,16,18,20,22,24,26,28,20,22,24,24,26,28,28,22,24,24,26,26,28,28,24,24,26,26,26,28,28,24,26,26,26,28,28]}}]),t}(),rn=function(){function t(){U(this,t)}return G(t,null,[{key:"BLOCKS",get:function(){return[1,0,19,7,1,0,16,10,1,0,13,13,1,0,9,17,1,0,34,10,1,0,28,16,1,0,22,22,1,0,16,28,1,0,55,15,1,0,44,26,2,0,17,18,2,0,13,22,1,0,80,20,2,0,32,18,2,0,24,26,4,0,9,16,1,0,108,26,2,0,43,24,2,2,15,18,2,2,11,22,2,0,68,18,4,0,27,16,4,0,19,24,4,0,15,28,2,0,78,20,4,0,31,18,2,4,14,18,4,1,13,26,2,0,97,24,2,2,38,22,4,2,18,22,4,2,14,26,2,0,116,30,3,2,36,22,4,4,16,20,4,4,12,24,2,2,68,18,4,1,43,26,6,2,19,24,6,2,15,28,4,0,81,20,1,4,50,30,4,4,22,28,3,8,12,24,2,2,92,24,6,2,36,22,4,6,20,26,7,4,14,28,4,0,107,26,8,1,37,22,8,4,20,24,12,4,11,22,3,1,115,30,4,5,40,24,11,5,16,20,11,5,12,24,5,1,87,22,5,5,41,24,5,7,24,30,11,7,12,24,5,1,98,24,7,3,45,28,15,2,19,24,3,13,15,30,1,5,107,28,10,1,46,28,1,15,22,28,2,17,14,28,5,1,120,30,9,4,43,26,17,1,22,28,2,19,14,28,3,4,113,28,3,11,44,26,17,4,21,26,9,16,13,26,3,5,107,28,3,13,41,26,15,5,24,30,15,10,15,28,4,4,116,28,17,0,42,26,17,6,22,28,19,6,16,30,2,7,111,28,17,0,46,28,7,16,24,30,34,0,13,24,4,5,121,30,4,14,47,28,11,14,24,30,16,14,15,30,6,4,117,30,6,14,45,28,11,16,24,30,30,2,16,30,8,4,106,26,8,13,47,28,7,22,24,30,22,13,15,30,10,2,114,28,19,4,46,28,28,6,22,28,33,4,16,30,8,4,122,30,22,3,45,28,8,26,23,30,12,28,15,30,3,10,117,30,3,23,45,28,4,31,24,30,11,31,15,30,7,7,116,30,21,7,45,28,1,37,23,30,19,26,15,30,5,10,115,30,19,10,47,28,15,25,24,30,23,25,15,30,13,3,115,30,2,29,46,28,42,1,24,30,23,28,15,30,17,0,115,30,10,23,46,28,10,35,24,30,19,35,15,30,17,1,115,30,14,21,46,28,29,19,24,30,11,46,15,30,13,6,115,30,14,23,46,28,44,7,24,30,59,1,16,30,12,7,121,30,12,26,47,28,39,14,24,30,22,41,15,30,6,14,121,30,6,34,47,28,46,10,24,30,2,64,15,30,17,4,122,30,29,14,46,28,49,10,24,30,24,46,15,30,4,18,122,30,13,32,46,28,48,14,24,30,42,32,15,30,20,4,117,30,40,7,47,28,43,22,24,30,10,67,15,30,19,6,118,30,18,31,47,28,34,34,24,30,20,61,15,30]}},{key:"FINAL_FORMAT",get:function(){return[30660,29427,32170,30877,26159,25368,27713,26998,21522,20773,24188,23371,17913,16590,20375,19104,13663,12392,16177,14854,9396,8579,11994,11245,5769,5054,7399,6608,1890,597,3340,2107]}},{key:"LEVELS",get:function(){return{L:1,M:2,Q:3,H:4}}}]),t}(),sn=function(){function t(){U(this,t)}return G(t,null,[{key:"EXPONENT",get:function(){return[1,2,4,8,16,32,64,128,29,58,116,232,205,135,19,38,76,152,45,90,180,117,234,201,143,3,6,12,24,48,96,192,157,39,78,156,37,74,148,53,106,212,181,119,238,193,159,35,70,140,5,10,20,40,80,160,93,186,105,210,185,111,222,161,95,190,97,194,153,47,94,188,101,202,137,15,30,60,120,240,253,231,211,187,107,214,177,127,254,225,223,163,91,182,113,226,217,175,67,134,17,34,68,136,13,26,52,104,208,189,103,206,129,31,62,124,248,237,199,147,59,118,236,197,151,51,102,204,133,23,46,92,184,109,218,169,79,158,33,66,132,21,42,84,168,77,154,41,82,164,85,170,73,146,57,114,228,213,183,115,230,209,191,99,198,145,63,126,252,229,215,179,123,246,241,255,227,219,171,75,150,49,98,196,149,55,110,220,165,87,174,65,130,25,50,100,200,141,7,14,28,56,112,224,221,167,83,166,81,162,89,178,121,242,249,239,195,155,43,86,172,69,138,9,18,36,72,144,61,122,244,245,247,243,251,235,203,139,11,22,44,88,176,125,250,233,207,131,27,54,108,216,173,71,142,0]}},{key:"LOG",get:function(){return[255,0,1,25,2,50,26,198,3,223,51,238,27,104,199,75,4,100,224,14,52,141,239,129,28,193,105,248,200,8,76,113,5,138,101,47,225,36,15,33,53,147,142,218,240,18,130,69,29,181,194,125,106,39,249,185,201,154,9,120,77,228,114,166,6,191,139,98,102,221,48,253,226,152,37,179,16,145,34,136,54,208,148,206,143,150,219,189,241,210,19,92,131,56,70,64,30,66,182,163,195,72,126,110,107,58,40,84,250,133,186,61,202,94,155,159,10,21,121,43,78,212,229,172,115,243,167,87,7,112,192,247,140,128,99,13,103,74,222,237,49,197,254,24,227,165,153,119,38,184,180,124,17,68,146,217,35,32,137,46,55,63,209,91,149,188,207,205,144,135,151,178,220,252,190,97,242,86,211,171,20,42,93,158,132,60,57,83,71,109,65,162,31,45,67,216,183,123,164,118,196,23,73,236,127,12,111,246,108,161,59,82,41,157,85,170,251,96,134,177,187,204,62,90,203,89,95,176,156,169,160,81,11,245,22,235,122,117,44,215,79,174,213,233,230,231,173,232,116,214,244,234,168,80,88,175]}}]),t}(),on=function(){function t(){U(this,t)}return G(t,null,[{key:"BLOCK",get:function(){return[3220,1468,2713,1235,3062,1890,2119,1549,2344,2936,1117,2583,1330,2470,1667,2249,2028,3780,481,4011,142,3098,831,3445,592,2517,1776,2234,1951,2827,1070,2660,1345,3177]}}]),t}(),un=function(){function t(e){U(this,t),this._badness=[],this._level=rn.LEVELS[e.level],this._polynomial=[],this._value=e.value,this._valueLength=this._value.length,this._version=0,this._stringBuffer=[];for(var n=void 0,r=void 0,i=void 0,s=void 0;this._version<40;){this._version++;var o=4*(this._level-1)+16*(this._version-1);if(i=rn.BLOCKS[o++],s=rn.BLOCKS[o++],n=rn.BLOCKS[o++],r=rn.BLOCKS[o],o=n*(i+s)+s-3+(this._version<=9),this._valueLength<=o)break}this._dataBlock=n,this._eccBlock=r,this._neccBlock1=i,this._neccBlock2=s,this.width=17+4*this._version,this.buffer=t._createArray(this.width*this.width),this._ecc=t._createArray(this._dataBlock+(this._dataBlock+this._eccBlock)*(this._neccBlock1+this._neccBlock2)+this._neccBlock2),this._mask=t._createArray((this.width*(this.width+1)+1)/2),this._insertFinders(),this._insertAlignments(),this.buffer[8+this.width*(this.width-8)]=1,this._insertTimingGap(),this._reverseMask(),this._insertTimingRowAndColumn(),this._insertVersion(),this._syncMask(),this._convertBitStream(this._value.length),this._calculatePolynomial(),this._appendEccToData(),this._interleaveBlocks(),this._pack(),this._finish()}return G(t,null,[{key:"_createArray",value:function(t){for(var e=[],n=0;n<t;n++)e[n]=0;return e}},{key:"_getMaskBit",value:function(t,e){var n=void 0;return t>e&&(n=t,t=e,e=n),n=e,n+=e*e,n>>=1,n+=t}},{key:"_modN",value:function(t){for(;t>=255;)t-=255,t=(t>>8)+(255&t);return t}},{key:"N1",get:function(){return 3}},{key:"N2",get:function(){return 3}},{key:"N3",get:function(){return 40}},{key:"N4",get:function(){return 10}}]),G(t,[{key:"_addAlignment",value:function(t,e){this.buffer[t+this.width*e]=1;for(var n=-2;n<2;n++)this.buffer[t+n+this.width*(e-2)]=1,this.buffer[t-2+this.width*(e+n+1)]=1,this.buffer[t+2+this.width*(e+n)]=1,this.buffer[t+n+1+this.width*(e+2)]=1;for(var r=0;r<2;r++)this._setMask(t-1,e+r),this._setMask(t+1,e-r),this._setMask(t-r,e-1),this._setMask(t+r,e+1)}},{key:"_appendData",value:function(e,n,r,i){for(var s=0;s<i;s++)this._stringBuffer[r+s]=0;for(var o=0;o<n;o++){var u=sn.LOG[this._stringBuffer[e+o]^this._stringBuffer[r]];if(255!==u)for(var a=1;a<i;a++)this._stringBuffer[r+a-1]=this._stringBuffer[r+a]^sn.EXPONENT[t._modN(u+this._polynomial[i-a])];else for(var f=r;f<r+i;f++)this._stringBuffer[f]=this._stringBuffer[f+1];this._stringBuffer[r+i-1]=255===u?0:sn.EXPONENT[t._modN(u+this._polynomial[0])]}}},{key:"_appendEccToData",value:function(){for(var t=0,e=this._calculateMaxLength(),n=0;n<this._neccBlock1;n++)this._appendData(t,this._dataBlock,e,this._eccBlock),t+=this._dataBlock,e+=this._eccBlock;for(var r=0;r<this._neccBlock2;r++)this._appendData(t,this._dataBlock+1,e,this._eccBlock),t+=this._dataBlock+1,e+=this._eccBlock}},{key:"_applyMask",value:function(t){var e=this.width;switch(t){case 0:for(var n=0;n<e;n++)for(var r=0;r<e;r++)r+n&1||this._isMasked(r,n)||(this.buffer[r+n*e]^=1);break;case 1:for(var i=0;i<e;i++)for(var s=0;s<e;s++)1&i||this._isMasked(s,i)||(this.buffer[s+i*e]^=1);break;case 2:for(var o=0;o<e;o++)for(var u=0,a=0;a<e;a++,u++)3===u&&(u=0),u||this._isMasked(a,o)||(this.buffer[a+o*e]^=1);break;case 3:for(var f=0,c=0;c<e;c++,f++){3===f&&(f=0);for(var h=f,l=0;l<e;l++,h++)3===h&&(h=0),h||this._isMasked(l,c)||(this.buffer[l+c*e]^=1)}break;case 4:for(var _=0;_<e;_++)for(var v=0,d=_>>1&1,p=0;p<e;p++,v++)3===v&&(v=0,d=!d),d||this._isMasked(p,_)||(this.buffer[p+_*e]^=1);break;case 5:for(var y=0,g=0;g<e;g++,y++){3===y&&(y=0);for(var k=0,b=0;b<e;b++,k++)3===k&&(k=0),(b&g&1)+!(!k|!y)||this._isMasked(b,g)||(this.buffer[b+g*e]^=1)}break;case 6:for(var m=0,w=0;w<e;w++,m++){3===m&&(m=0);for(var B=0,O=0;O<e;O++,B++)3===B&&(B=0),(O&w&1)+(B&&B===m)&1||this._isMasked(O,w)||(this.buffer[O+w*e]^=1)}break;case 7:for(var M=0,S=0;S<e;S++,M++){3===M&&(M=0);for(var E=0,j=0;j<e;j++,E++)3===E&&(E=0),(E&&E===M)+(j+S&1)&1||this._isMasked(j,S)||(this.buffer[j+S*e]^=1)}}}},{key:"_calculateMaxLength",value:function(){return this._dataBlock*(this._neccBlock1+this._neccBlock2)+this._neccBlock2}},{key:"_calculatePolynomial",value:function(){this._polynomial[0]=1;for(var e=0;e<this._eccBlock;e++){this._polynomial[e+1]=1;for(var n=e;n>0;n--)this._polynomial[n]=this._polynomial[n]?this._polynomial[n-1]^sn.EXPONENT[t._modN(sn.LOG[this._polynomial[n]]+e)]:this._polynomial[n-1];this._polynomial[0]=sn.EXPONENT[t._modN(sn.LOG[this._polynomial[0]]+e)]}for(var r=0;r<=this._eccBlock;r++)this._polynomial[r]=sn.LOG[this._polynomial[r]]}},{key:"_checkBadness",value:function(){for(var e=0,n=this.width,r=0;r<n-1;r++)for(var i=0;i<n-1;i++)(this.buffer[i+n*r]&&this.buffer[i+1+n*r]&&this.buffer[i+n*(r+1)]&&this.buffer[i+1+n*(r+1)]||!(this.buffer[i+n*r]||this.buffer[i+1+n*r]||this.buffer[i+n*(r+1)]||this.buffer[i+1+n*(r+1)]))&&(e+=t.N2);for(var s=0,o=0;o<n;o++){var u=0;this._badness[0]=0;for(var a=0,f=0;f<n;f++){var c=this.buffer[f+n*o];a===c?this._badness[u]++:this._badness[++u]=1,a=c,s+=a?1:-1}e+=this._getBadness(u)}s<0&&(s=-s);var h=0,l=s;for(l+=l<<2,l<<=1;l>n*n;)l-=n*n,h++;e+=h*t.N4;for(var _=0;_<n;_++){var v=0;this._badness[0]=0;for(var d=0,p=0;p<n;p++){var y=this.buffer[_+n*p];d===y?this._badness[v]++:this._badness[++v]=1,d=y}e+=this._getBadness(v)}return e}},{key:"_convertBitStream",value:function(t){for(var e=0;e<t;e++)this._ecc[e]=this._value.charCodeAt(e);this._stringBuffer=this._ecc.slice(0);var n=this._calculateMaxLength();t>=n-2&&(t=n-2,this._version>9&&t--);var r=t;if(this._version>9){for(this._stringBuffer[r+2]=0,this._stringBuffer[r+3]=0;r--;){var i=this._stringBuffer[r];this._stringBuffer[r+3]|=255&i<<4,this._stringBuffer[r+2]=i>>4}this._stringBuffer[2]|=255&t<<4,this._stringBuffer[1]=t>>4,this._stringBuffer[0]=64|t>>12}else{for(this._stringBuffer[r+1]=0,this._stringBuffer[r+2]=0;r--;){var s=this._stringBuffer[r];this._stringBuffer[r+2]|=255&s<<4,this._stringBuffer[r+1]=s>>4}this._stringBuffer[1]|=255&t<<4,this._stringBuffer[0]=64|t>>4}for(r=t+3-(this._version<10);r<n;)this._stringBuffer[r++]=236,this._stringBuffer[r++]=17}},{key:"_getBadness",value:function(e){for(var n=0,r=0;r<=e;r++)this._badness[r]>=5&&(n+=t.N1+this._badness[r]-5);for(var i=3;i<e-1;i+=2)this._badness[i-2]===this._badness[i+2]&&this._badness[i+2]===this._badness[i-1]&&this._badness[i-1]===this._badness[i+1]&&3*this._badness[i-1]===this._badness[i]&&(0===this._badness[i-3]||i+3>e||3*this._badness[i-3]>=4*this._badness[i]||3*this._badness[i+3]>=4*this._badness[i])&&(n+=t.N3);return n}},{key:"_finish",value:function(){this._stringBuffer=this.buffer.slice(0);var t=0,e=void 0,n=3e4;for(e=0;e<8;e++){this._applyMask(e);var r=this._checkBadness();if(r<n&&(n=r,t=e),7===t)break;this.buffer=this._stringBuffer.slice(0)}for(t!==e&&this._applyMask(t),n=rn.FINAL_FORMAT[t+(this._level-1<<3)],e=0;e<8;e++,n>>=1)1&n&&(this.buffer[this.width-1-e+8*this.width]=1,e<6?this.buffer[8+this.width*e]=1:this.buffer[8+this.width*(e+1)]=1);for(e=0;e<7;e++,n>>=1)1&n&&(this.buffer[8+this.width*(this.width-7+e)]=1,e?this.buffer[6-e+8*this.width]=1:this.buffer[7+8*this.width]=1)}},{key:"_interleaveBlocks",value:function(){var t=this._calculateMaxLength(),e=void 0,n=0;for(e=0;e<this._dataBlock;e++){for(var r=0;r<this._neccBlock1;r++)this._ecc[n++]=this._stringBuffer[e+r*this._dataBlock];for(var i=0;i<this._neccBlock2;i++)this._ecc[n++]=this._stringBuffer[this._neccBlock1*this._dataBlock+e+i*(this._dataBlock+1)]}for(var s=0;s<this._neccBlock2;s++)this._ecc[n++]=this._stringBuffer[this._neccBlock1*this._dataBlock+e+s*(this._dataBlock+1)];for(e=0;e<this._eccBlock;e++)for(var o=0;o<this._neccBlock1+this._neccBlock2;o++)this._ecc[n++]=this._stringBuffer[t+e+o*this._eccBlock];this._stringBuffer=this._ecc}},{key:"_insertAlignments",value:function(){var t=this.width;if(this._version>1)for(var e=nn.BLOCK[this._version],n=t-7;;){for(var r=t-7;r>e-3&&(this._addAlignment(r,n),!(r<e));)r-=e;if(n<=e+9)break;n-=e,this._addAlignment(6,n),this._addAlignment(n,6)}}},{key:"_insertFinders",value:function(){for(var t=this.width,e=0;e<3;e++){var n=0,r=0;1===e&&(n=t-7),2===e&&(r=t-7),this.buffer[r+3+t*(n+3)]=1;for(var i=0;i<6;i++)this.buffer[r+i+t*n]=1,this.buffer[r+t*(n+i+1)]=1,this.buffer[r+6+t*(n+i)]=1,this.buffer[r+i+1+t*(n+6)]=1;for(var s=1;s<5;s++)this._setMask(r+s,n+1),this._setMask(r+1,n+s+1),this._setMask(r+5,n+s),this._setMask(r+s+1,n+5);for(var o=2;o<4;o++)this.buffer[r+o+t*(n+2)]=1,this.buffer[r+2+t*(n+o+1)]=1,this.buffer[r+4+t*(n+o)]=1,this.buffer[r+o+1+t*(n+4)]=1}}},{key:"_insertTimingGap",value:function(){for(var t=this.width,e=0;e<7;e++)this._setMask(7,e),this._setMask(t-8,e),this._setMask(7,e+t-7);for(var n=0;n<8;n++)this._setMask(n,7),this._setMask(n+t-8,7),this._setMask(n,t-8)}},{key:"_insertTimingRowAndColumn",value:function(){for(var t=this.width,e=0;e<t-14;e++)1&e?(this._setMask(8+e,6),this._setMask(6,8+e)):(this.buffer[8+e+6*t]=1,this.buffer[6+t*(8+e)]=1)}},{key:"_insertVersion",value:function(){var t=this.width;if(this._version>6)for(var e=on.BLOCK[this._version-7],n=17,r=0;r<6;r++)for(var i=0;i<3;i++,n--)1&(n>11?this._version>>n-12:e>>n)?(this.buffer[5-r+t*(2-i+t-11)]=1,this.buffer[2-i+t-11+t*(5-r)]=1):(this._setMask(5-r,2-i+t-11),this._setMask(2-i+t-11,5-r))}},{key:"_isMasked",value:function(e,n){var r=t._getMaskBit(e,n);return 1===this._mask[r]}},{key:"_pack",value:function(){for(var t=this.width-1,e=this.width-1,n=1,r=1,i=(this._dataBlock+this._eccBlock)*(this._neccBlock1+this._neccBlock2)+this._neccBlock2,s=0;s<i;s++)for(var o=this._stringBuffer[s],u=0;u<8;u++,o<<=1){128&o&&(this.buffer[t+this.width*e]=1);do{r?t--:(t++,n?0!==e?e--:(t-=2,n=!n,6===t&&(t--,e=9)):e!==this.width-1?e++:(t-=2,n=!n,6===t&&(t--,e-=8))),r=!r}while(this._isMasked(t,e))}}},{key:"_reverseMask",value:function(){for(var t=this.width,e=0;e<9;e++)this._setMask(e,8);for(var n=0;n<8;n++)this._setMask(n+t-8,8), | ||
this._setMask(8,n);for(var r=0;r<7;r++)this._setMask(8,r+t-7)}},{key:"_setMask",value:function(e,n){var r=t._getMaskBit(e,n);this._mask[r]=1}},{key:"_syncMask",value:function(){for(var t=this.width,e=0;e<t;e++)for(var n=0;n<=e;n++)this.buffer[n+t*e]&&this._setMask(n,e)}}]),t}(),an=function(t){function e(){return U(this,e),Ue(this,(e.__proto__||I(e)).apply(this,arguments))}return He(e,t),G(e,[{key:"draw",value:function(){this.element.src=this.qrious.toDataURL()}},{key:"reset",value:function(){this.element.src=""}},{key:"resize",value:function(){this.element.width=this.element.height=this.qrious.size}}]),e}(tn),fn=function(){function t(e,n,r,i){U(this,t),this._name=e,this._defaultValue=n,this._valueTransformer=r,this._fieldName="function"==typeof i?i(this):"_"+e}return G(t,[{key:"transform",value:function(t){var e=this._valueTransformer;return"function"==typeof e?e(t,this):t}},{key:"fieldName",get:function(){return this._fieldName}},{key:"name",get:function(){return this._name}},{key:"defaultValue",get:function(){return this._defaultValue}}]),t}(),cn=Wt.f,hn=function(t){return function(e){for(var n,r=tt(e),i=ct(r),s=i.length,o=0,u=[];s>o;)cn.call(r,n=i[o++])&&u.push(t?[n,r[n]]:r[n]);return u}}(!1);x(x.S,"Object",{values:function(t){return hn(t)}});var ln=y.Object.values,_n=e(function(t){t.exports={default:ln,__esModule:!0}}),vn=t(_n),dn=function(){function t(e){var n=this;U(this,t),this._options={},e.forEach(function(t){n._options[t.name]=t})}return G(t,null,[{key:"_get",value:function(t,e){return e[t.fieldName]}},{key:"_set",value:function(t,e,n){var r=t.fieldName,i=n[r],s=t.transform(null!=e?e:t.defaultValue);return n[r]=s,s!==i}}]),G(t,[{key:"applyDefaults",value:function(e){var n=this._options;for(var r in n)if(Qe.hasOwn(n,r)){var i=n[r];t._set(i,i.defaultValue,e)}}},{key:"exists",value:function(t){return null!=this._options[t]}},{key:"get",value:function(e,n){return t._get(this._options[e],n)}},{key:"getAll",value:function(e){var n=this._options,r={};for(var i in n)Qe.hasOwn(n,i)&&(r[i]=t._get(n[i],e));return r}},{key:"set",value:function(e,n,r){var i=this._options[e];if(!i)throw new Error("Invalid option: "+e);return t._set(i,n,r)}},{key:"setAll",value:function(t,e){if(!t)return!1;var n=!1;for(var r in t)Qe.hasOwn(t,r)&&this.set(r,t[r],e)&&(n=!0);return n}},{key:"options",get:function(){return vn(this._options)}}]),t}(),pn=function(){function t(){U(this,t),this._services={}}return G(t,[{key:"getService",value:function(t){var e=this._services[t];if(!e)throw new Error("Service is not being managed with name: "+t);return e}},{key:"setService",value:function(t,e){if(this._services[t])throw new Error("Service is already managed with name: "+t);e&&(this._services[t]=e)}}]),t}(),yn=new dn([new fn("background","white"),new fn("backgroundAlpha",1,Qe.abs),new fn("element"),new fn("foreground","black"),new fn("foregroundAlpha",1,Qe.abs),new fn("level","L",Qe.toUpperCase),new fn("mime","image/png"),new fn("padding",null,Qe.abs),new fn("size",100,Qe.abs),new fn("value","")]),gn=new pn,kn=function(){function t(e){U(this,t),yn.applyDefaults(this),yn.setAll(e,this);var n=yn.get("element",this),r=gn.getService("element"),i=n&&r.isCanvas(n)?n:r.createCanvas(),s=n&&r.isImage(n)?n:r.createImage();this._canvasRenderer=new en(this,i,!0),this._imageRenderer=new an(this,s,s===n),this.update()}return G(t,null,[{key:"use",value:function(t){gn.setService(t.getName(),t)}},{key:"DEFAULTS",get:function(){var t={};return yn.options.forEach(function(e){t[e.name]=e.defaultValue}),t}},{key:"VERSION",get:function(){return"2.3.0"}}]),G(t,[{key:"get",value:function(){return yn.getAll(this)}},{key:"set",value:function(t){yn.setAll(t,this)&&this.update()}},{key:"toDataURL",value:function(t){return this.canvas.toDataURL(t||this.mime)}},{key:"update",value:function(){var t=new un({level:this.level,value:this.value});this._canvasRenderer.render(t),this._imageRenderer.render(t)}},{key:"background",get:function(){return yn.get("background",this)},set:function(t){yn.set("background",t,this)&&this.update()}},{key:"backgroundAlpha",get:function(){return yn.get("backgroundAlpha",this)},set:function(t){yn.set("backgroundAlpha",t,this)&&this.update()}},{key:"canvas",get:function(){return this._canvasRenderer.getElement()}},{key:"foreground",get:function(){return yn.get("foreground",this)},set:function(t){yn.set("foreground",t,this)&&this.update()}},{key:"foregroundAlpha",get:function(){return yn.get("foregroundAlpha",this)},set:function(t){yn.set("foregroundAlpha",t,this)&&this.update()}},{key:"image",get:function(){return this._imageRenderer.getElement()}},{key:"level",get:function(){return yn.get("level",this)},set:function(t){yn.set("level",t,this)&&this.update()}},{key:"mime",get:function(){return yn.get("mime",this)},set:function(t){yn.set("mime",t,this)&&this.update()}},{key:"padding",get:function(){return yn.get("padding",this)},set:function(t){yn.set("padding",t,this)&&this.update()}},{key:"size",get:function(){return yn.get("size",this)},set:function(t){yn.set("size",t,this)&&this.update()}},{key:"value",get:function(){return yn.get("value",this)},set:function(t){yn.set("value",t,this)&&this.update()}}]),t}();return kn.use(new $e),kn}); | ||
//# sourceMappingURL=qrious.min.js.map |
QRious | ||
Copyright (C) 2016 Alasdair Mercer | ||
Copyright (C) 2017 Alasdair Mercer | ||
Copyright (C) 2010 Tom Zerucha | ||
@@ -4,0 +4,0 @@ |
{ | ||
"name": "qrious", | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"description": "Library for QR code generation using canvas", | ||
@@ -27,20 +27,20 @@ "homepage": "https://github.com/neocotic/qrious", | ||
"optionalDependencies": { | ||
"canvas": "^1.3.12" | ||
"canvas": "^1.6.5" | ||
}, | ||
"devDependencies": { | ||
"babel-eslint": "^7.0.0", | ||
"babel-plugin-transform-runtime": "^6.15.0", | ||
"babel-preset-es2015": "^6.16.0", | ||
"babel-runtime": "^6.11.6", | ||
"eslint-config-skelp": "^0.1.5", | ||
"babel-eslint": "^7.2.3", | ||
"babel-plugin-transform-runtime": "^6.23.0", | ||
"babel-preset-es2015": "^6.24.1", | ||
"babel-runtime": "^6.23.0", | ||
"eslint-config-notninja": "^0.1.1", | ||
"grunt": "^1.0.1", | ||
"grunt-cli": "^1.2.0", | ||
"grunt-contrib-clean": "^1.0.0", | ||
"grunt-contrib-clean": "^1.1.0", | ||
"grunt-contrib-watch": "^1.0.0", | ||
"grunt-eslint": "^19.0.0", | ||
"grunt-rollup": "^0.8.0", | ||
"rollup-plugin-babel": "^2.6.1", | ||
"rollup-plugin-commonjs": "^5.0.4", | ||
"rollup-plugin-node-resolve": "^2.0.0", | ||
"rollup-plugin-uglify": "^1.0.1", | ||
"grunt-rollup": "^1.0.1", | ||
"rollup-plugin-babel": "^2.7.1", | ||
"rollup-plugin-commonjs": "^8.0.2", | ||
"rollup-plugin-node-resolve": "~2.0.0", | ||
"rollup-plugin-uglify": "^1.0.2", | ||
"semver": "^5.3.0" | ||
@@ -50,2 +50,3 @@ }, | ||
"main": "dist/cjs/qrious.js", | ||
"module": "src/runtime/node.js", | ||
"jsnext:main": "src/runtime/node.js", | ||
@@ -52,0 +53,0 @@ "scripts": { |
@@ -11,5 +11,6 @@ .oooooo. ooooooooo. o8o | ||
[![Chat](https://img.shields.io/gitter/room/neocotic/qrious.svg?style=flat-square)](https://gitter.im/neocotic/qrious) | ||
[![Build Status](https://img.shields.io/travis/neocotic/qrious/develop.svg?style=flat-square)](https://travis-ci.org/neocotic/qrious) | ||
[![Dependency Status](https://img.shields.io/david/neocotic/qrious.svg?style=flat-square)](https://david-dm.org/neocotic/qrious) | ||
[![Dev Dependency Status](https://img.shields.io/david/dev/neocotic/qrious.svg?style=flat-square)](https://david-dm.org/neocotic/qrious#info=devDependencies) | ||
[![Optional Dependency Status](https://img.shields.io/david/optional/neocotic/qrious.svg?style=flat-square)](https://david-dm.org/neocotic/qrious?type=optional) | ||
[![Dev Dependency Status](https://img.shields.io/david/dev/neocotic/qrious.svg?style=flat-square)](https://david-dm.org/neocotic/qrious?type=dev) | ||
[![License](https://img.shields.io/npm/l/qrious.svg?style=flat-square)](https://github.com/neocotic/qrious/blob/master/LICENSE.md) | ||
@@ -41,4 +42,4 @@ [![Release](https://img.shields.io/npm/v/qrious.svg?style=flat-square)](https://www.npmjs.com/package/qrious) | ||
* [Development Version](https://github.com/neocotic/qrious/blob/master/dist/umd/qrious.js) | ||
* [Production Version](https://github.com/neocotic/qrious/blob/master/dist/umd/qrious.min.js) | ||
* [Development Version](https://cdn.rawgit.com/neocotic/qrious/master/dist/umd/qrious.js) (123kb - [Source Map](https://cdn.rawgit.com/neocotic/qrious/master/dist/umd/qrious.js.map)) | ||
* [Production Version](https://cdn.rawgit.com/neocotic/qrious/master/dist/umd/qrious.min.js) (37kb - [Source Map](https://cdn.rawgit.com/neocotic/qrious/master/dist/umd/qrious.min.js.map)) | ||
@@ -79,4 +80,4 @@ ### Node.js Dependencies | ||
value: 'https://github.com/neocotic/qrious' | ||
}) | ||
})() | ||
}); | ||
})(); | ||
</script> | ||
@@ -90,14 +91,14 @@ </body> | ||
``` javascript | ||
const express = require('express') | ||
const QRious = require('qrious') | ||
const express = require('express'); | ||
const QRious = require('qrious'); | ||
const app = express() | ||
const app = express(); | ||
app.get('/qr', (req, res) => { | ||
const qr = new QRious({ value: 'https://github.com/neocotic/qrious' }) | ||
const qr = new QRious({ value: 'https://github.com/neocotic/qrious' }); | ||
res.end(new Buffer(qr.toDataURL(), 'base64')) | ||
}) | ||
res.end(new Buffer(qr.toDataURL(), 'base64')); | ||
}); | ||
app.listen(3000) | ||
app.listen(3000); | ||
``` | ||
@@ -125,13 +126,31 @@ | ||
``` javascript | ||
const qr = new QRious() | ||
qr.background = '#000' | ||
qr.backgroundAlpha = 0.8 | ||
qr.foreground = '#fff' | ||
qr.foregroundAlpha = 0.8 | ||
qr.level = 'H' | ||
qr.padding = 25 | ||
qr.size = 500 | ||
qr.value = 'https://github.com/neocotic/qrious' | ||
const qr = new QRious(); | ||
qr.background = 'green'; | ||
qr.backgroundAlpha = 0.8; | ||
qr.foreground = 'blue'; | ||
qr.foregroundAlpha = 0.8; | ||
qr.level = 'H'; | ||
qr.padding = 25; | ||
qr.size = 500; | ||
qr.value = 'https://github.com/neocotic/qrious'; | ||
``` | ||
The QR code will automatically update when you change one of these fields, so be wary when you plan on changing lots of | ||
fields at the same time. You probably want to make a single call to `set(options)` instead as it will only update the QR | ||
code once: | ||
``` javascript | ||
const qr = new QRious(); | ||
qr.set({ | ||
background: 'green', | ||
backgroundAlpha: 0.8, | ||
foreground: 'blue', | ||
foregroundAlpha: 0.8, | ||
level: 'H', | ||
padding: 25, | ||
size: 500, | ||
value: 'https://github.com/neocotic/qrious' | ||
}); | ||
``` | ||
These can also be passed as options to the constructor itself: | ||
@@ -141,5 +160,5 @@ | ||
const qr = new QRious({ | ||
background: '#000', | ||
background: 'green', | ||
backgroundAlpha: 0.8, | ||
foreground: '#fff', | ||
foreground: 'blue', | ||
foregroundAlpha: 0.8, | ||
@@ -150,3 +169,3 @@ level: 'H', | ||
value: 'https://github.com/neocotic/qrious' | ||
}) | ||
}); | ||
``` | ||
@@ -163,5 +182,5 @@ | ||
value: 'https://github.com/neocotic/qrious' | ||
}) | ||
}); | ||
qr.canvas.parentNode.appendChild(qr.image) | ||
qr.canvas.parentNode.appendChild(qr.image); | ||
``` | ||
@@ -172,9 +191,9 @@ | ||
``` javascript | ||
const canvas = document.querySelector('canvas') | ||
const canvas = document.querySelector('canvas'); | ||
const qr = new QRious({ | ||
element: canvas, | ||
value: 'https://github.com/neocotic/qrious' | ||
}) | ||
}); | ||
console.log(qr === canvas.qrious) | ||
qr === canvas.qrious; | ||
//=> true | ||
@@ -191,7 +210,7 @@ ``` | ||
value: 'https://github.com/neocotic/qrious' | ||
}) | ||
}); | ||
console.log(qr.toDataURL()) | ||
qr.toDataURL(); | ||
//=> "data:image/png;base64,iVBOR...AIpqDnseH86KAAAAAElFTkSuQmCC" | ||
console.log(qr.toDataURL('image/jpeg')) | ||
qr.toDataURL('image/jpeg'); | ||
//=> "data:image/jpeg;base64,/9j/...xqAqIqgKFAAAAAq3RRQAUUUUAf/Z" | ||
@@ -205,4 +224,4 @@ ``` | ||
``` javascript | ||
console.log(QRious.VERSION) | ||
//=> "2.2.0" | ||
QRious.VERSION; | ||
//=> "2.3.0" | ||
``` | ||
@@ -236,5 +255,5 @@ | ||
Copyright © 2016 Alasdair Mercer | ||
Copyright © 2017 Alasdair Mercer | ||
Copyright © 2010 Tom Zerucha | ||
See [LICENSE.md](https://github.com/neocotic/qrious/blob/master/LICENSE.md) for more information on our GPLv3 license. |
/* | ||
* QRious | ||
* Copyright (C) 2016 Alasdair Mercer | ||
* Copyright (C) 2017 Alasdair Mercer | ||
* Copyright (C) 2010 Tom Zerucha | ||
@@ -41,3 +41,3 @@ * | ||
26, 26, 28, 28, 24, 24, 26, 26, 26, 28, 28, 24, 26, 26, 26, 28, 28 | ||
] | ||
]; | ||
} | ||
@@ -47,2 +47,2 @@ | ||
export default Alignment | ||
export default Alignment; |
/* | ||
* QRious | ||
* Copyright (C) 2016 Alasdair Mercer | ||
* Copyright (C) 2017 Alasdair Mercer | ||
* Copyright (C) 2010 Tom Zerucha | ||
@@ -81,3 +81,3 @@ * | ||
19, 6, 118, 30, 18, 31, 47, 28, 34, 34, 24, 30, 20, 61, 15, 30 | ||
] | ||
]; | ||
} | ||
@@ -102,3 +102,3 @@ | ||
0x1689, 0x13be, 0x1ce7, 0x19d0, 0x0762, 0x0255, 0x0d0c, 0x083b | ||
] | ||
]; | ||
} | ||
@@ -119,3 +119,3 @@ | ||
H: 4 | ||
} | ||
}; | ||
} | ||
@@ -125,2 +125,2 @@ | ||
export default ErrorCorrection | ||
export default ErrorCorrection; |
568
src/Frame.js
/* | ||
* QRious | ||
* Copyright (C) 2016 Alasdair Mercer | ||
* Copyright (C) 2017 Alasdair Mercer | ||
* Copyright (C) 2010 Tom Zerucha | ||
@@ -20,6 +20,6 @@ * | ||
import Alignment from './Alignment' | ||
import ErrorCorrection from './ErrorCorrection' | ||
import Galois from './Galois' | ||
import Version from './Version' | ||
import Alignment from './Alignment'; | ||
import ErrorCorrection from './ErrorCorrection'; | ||
import Galois from './Galois'; | ||
import Version from './Version'; | ||
@@ -34,26 +34,26 @@ /** | ||
static _createArray(length) { | ||
const array = [] | ||
const array = []; | ||
for (let i = 0; i < length; i++) { | ||
array[i] = 0 | ||
array[i] = 0; | ||
} | ||
return array | ||
return array; | ||
} | ||
static _getMaskBit(x, y) { | ||
let bit | ||
let bit; | ||
if (x > y) { | ||
bit = x | ||
x = y | ||
y = bit | ||
bit = x; | ||
x = y; | ||
y = bit; | ||
} | ||
bit = y | ||
bit += y * y | ||
bit >>= 1 | ||
bit += x | ||
bit = y; | ||
bit += y * y; | ||
bit >>= 1; | ||
bit += x; | ||
return bit | ||
return bit; | ||
} | ||
@@ -63,7 +63,7 @@ | ||
while (x >= 255) { | ||
x -= 255 | ||
x = (x >> 8) + (x & 255) | ||
x -= 255; | ||
x = (x >> 8) + (x & 255); | ||
} | ||
return x | ||
return x; | ||
} | ||
@@ -73,12 +73,12 @@ | ||
static get N1() { | ||
return 3 | ||
return 3; | ||
} | ||
static get N2() { | ||
return 3 | ||
return 3; | ||
} | ||
static get N3() { | ||
return 40 | ||
return 40; | ||
} | ||
static get N4() { | ||
return 10 | ||
return 10; | ||
} | ||
@@ -93,36 +93,36 @@ | ||
constructor(options) { | ||
this._badness = [] | ||
this._level = ErrorCorrection.LEVELS[options.level] | ||
this._polynomial = [] | ||
this._value = options.value | ||
this._valueLength = this._value.length | ||
this._version = 0 | ||
this._stringBuffer = [] | ||
this._badness = []; | ||
this._level = ErrorCorrection.LEVELS[options.level]; | ||
this._polynomial = []; | ||
this._value = options.value; | ||
this._valueLength = this._value.length; | ||
this._version = 0; | ||
this._stringBuffer = []; | ||
let dataBlock | ||
let eccBlock | ||
let neccBlock1 | ||
let neccBlock2 | ||
let dataBlock; | ||
let eccBlock; | ||
let neccBlock1; | ||
let neccBlock2; | ||
while (this._version < 40) { | ||
this._version++ | ||
this._version++; | ||
let index = ((this._level - 1) * 4) + ((this._version - 1) * 16) | ||
let index = ((this._level - 1) * 4) + ((this._version - 1) * 16); | ||
neccBlock1 = ErrorCorrection.BLOCKS[index++] | ||
neccBlock2 = ErrorCorrection.BLOCKS[index++] | ||
dataBlock = ErrorCorrection.BLOCKS[index++] | ||
eccBlock = ErrorCorrection.BLOCKS[index] | ||
neccBlock1 = ErrorCorrection.BLOCKS[index++]; | ||
neccBlock2 = ErrorCorrection.BLOCKS[index++]; | ||
dataBlock = ErrorCorrection.BLOCKS[index++]; | ||
eccBlock = ErrorCorrection.BLOCKS[index]; | ||
index = (dataBlock * (neccBlock1 + neccBlock2)) + neccBlock2 - 3 + (this._version <= 9) | ||
index = (dataBlock * (neccBlock1 + neccBlock2)) + neccBlock2 - 3 + (this._version <= 9); | ||
if (this._valueLength <= index) { | ||
break | ||
break; | ||
} | ||
} | ||
this._dataBlock = dataBlock | ||
this._eccBlock = eccBlock | ||
this._neccBlock1 = neccBlock1 | ||
this._neccBlock2 = neccBlock2 | ||
this._dataBlock = dataBlock; | ||
this._eccBlock = eccBlock; | ||
this._neccBlock1 = neccBlock1; | ||
this._neccBlock2 = neccBlock2; | ||
@@ -136,3 +136,3 @@ /** | ||
// FIXME: Ensure that it fits instead of being truncated. | ||
this.width = 17 + (4 * this._version) | ||
this.width = 17 + (4 * this._version); | ||
@@ -145,42 +145,42 @@ /** | ||
*/ | ||
this.buffer = Frame._createArray(this.width * this.width) | ||
this.buffer = Frame._createArray(this.width * this.width); | ||
this._ecc = Frame._createArray(this._dataBlock + ((this._dataBlock + this._eccBlock) * | ||
(this._neccBlock1 + this._neccBlock2)) + this._neccBlock2) | ||
this._mask = Frame._createArray(((this.width * (this.width + 1)) + 1) / 2) | ||
(this._neccBlock1 + this._neccBlock2)) + this._neccBlock2); | ||
this._mask = Frame._createArray(((this.width * (this.width + 1)) + 1) / 2); | ||
this._insertFinders() | ||
this._insertAlignments() | ||
this._insertFinders(); | ||
this._insertAlignments(); | ||
// Insert single foreground cell. | ||
this.buffer[8 + (this.width * (this.width - 8))] = 1 | ||
this.buffer[8 + (this.width * (this.width - 8))] = 1; | ||
this._insertTimingGap() | ||
this._reverseMask() | ||
this._insertTimingRowAndColumn() | ||
this._insertVersion() | ||
this._syncMask() | ||
this._convertBitStream(this._value.length) | ||
this._calculatePolynomial() | ||
this._appendEccToData() | ||
this._interleaveBlocks() | ||
this._pack() | ||
this._finish() | ||
this._insertTimingGap(); | ||
this._reverseMask(); | ||
this._insertTimingRowAndColumn(); | ||
this._insertVersion(); | ||
this._syncMask(); | ||
this._convertBitStream(this._value.length); | ||
this._calculatePolynomial(); | ||
this._appendEccToData(); | ||
this._interleaveBlocks(); | ||
this._pack(); | ||
this._finish(); | ||
} | ||
_addAlignment(x, y) { | ||
this.buffer[x + (this.width * y)] = 1 | ||
this.buffer[x + (this.width * y)] = 1; | ||
for (let i = -2; i < 2; i++) { | ||
this.buffer[x + i + (this.width * (y - 2))] = 1 | ||
this.buffer[x - 2 + (this.width * (y + i + 1))] = 1 | ||
this.buffer[x + 2 + (this.width * (y + i))] = 1 | ||
this.buffer[x + i + 1 + (this.width * (y + 2))] = 1 | ||
this.buffer[x + i + (this.width * (y - 2))] = 1; | ||
this.buffer[x - 2 + (this.width * (y + i + 1))] = 1; | ||
this.buffer[x + 2 + (this.width * (y + i))] = 1; | ||
this.buffer[x + i + 1 + (this.width * (y + 2))] = 1; | ||
} | ||
for (let i = 0; i < 2; i++) { | ||
this._setMask(x - 1, y + i) | ||
this._setMask(x + 1, y - i) | ||
this._setMask(x - i, y - 1) | ||
this._setMask(x + i, y + 1) | ||
this._setMask(x - 1, y + i); | ||
this._setMask(x + 1, y - i); | ||
this._setMask(x - i, y - 1); | ||
this._setMask(x + i, y + 1); | ||
} | ||
@@ -191,7 +191,7 @@ } | ||
for (let i = 0; i < eccLength; i++) { | ||
this._stringBuffer[ecc + i] = 0 | ||
this._stringBuffer[ecc + i] = 0; | ||
} | ||
for (let i = 0; i < dataLength; i++) { | ||
const bit = Galois.LOG[this._stringBuffer[data + i] ^ this._stringBuffer[ecc]] | ||
const bit = Galois.LOG[this._stringBuffer[data + i] ^ this._stringBuffer[ecc]]; | ||
@@ -201,7 +201,7 @@ if (bit !== 255) { | ||
this._stringBuffer[ecc + j - 1] = this._stringBuffer[ecc + j] ^ | ||
Galois.EXPONENT[Frame._modN(bit + this._polynomial[eccLength - j])] | ||
Galois.EXPONENT[Frame._modN(bit + this._polynomial[eccLength - j])]; | ||
} | ||
} else { | ||
for (let j = ecc; j < ecc + eccLength; j++) { | ||
this._stringBuffer[j] = this._stringBuffer[j + 1] | ||
this._stringBuffer[j] = this._stringBuffer[j + 1]; | ||
} | ||
@@ -211,3 +211,3 @@ } | ||
this._stringBuffer[ecc + eccLength - 1] = bit === 255 ? 0 | ||
: Galois.EXPONENT[Frame._modN(bit + this._polynomial[0])] | ||
: Galois.EXPONENT[Frame._modN(bit + this._polynomial[0])]; | ||
} | ||
@@ -217,17 +217,17 @@ } | ||
_appendEccToData() { | ||
let data = 0 | ||
let ecc = this._calculateMaxLength() | ||
let data = 0; | ||
let ecc = this._calculateMaxLength(); | ||
for (let i = 0; i < this._neccBlock1; i++) { | ||
this._appendData(data, this._dataBlock, ecc, this._eccBlock) | ||
this._appendData(data, this._dataBlock, ecc, this._eccBlock); | ||
data += this._dataBlock | ||
ecc += this._eccBlock | ||
data += this._dataBlock; | ||
ecc += this._eccBlock; | ||
} | ||
for (let i = 0; i < this._neccBlock2; i++) { | ||
this._appendData(data, this._dataBlock + 1, ecc, this._eccBlock) | ||
this._appendData(data, this._dataBlock + 1, ecc, this._eccBlock); | ||
data += this._dataBlock + 1 | ||
ecc += this._eccBlock | ||
data += this._dataBlock + 1; | ||
ecc += this._eccBlock; | ||
} | ||
@@ -237,3 +237,3 @@ } | ||
_applyMask(mask) { | ||
const width = this.width | ||
const width = this.width; | ||
@@ -245,3 +245,3 @@ switch (mask) { | ||
if (!((x + y) & 1) && !this._isMasked(x, y)) { | ||
this.buffer[x + (y * width)] ^= 1 | ||
this.buffer[x + (y * width)] ^= 1; | ||
} | ||
@@ -251,3 +251,3 @@ } | ||
break | ||
break; | ||
case 1: | ||
@@ -257,3 +257,3 @@ for (let y = 0; y < width; y++) { | ||
if (!(y & 1) && !this._isMasked(x, y)) { | ||
this.buffer[x + (y * width)] ^= 1 | ||
this.buffer[x + (y * width)] ^= 1; | ||
} | ||
@@ -263,3 +263,3 @@ } | ||
break | ||
break; | ||
case 2: | ||
@@ -269,7 +269,7 @@ for (let y = 0; y < width; y++) { | ||
if (r3x === 3) { | ||
r3x = 0 | ||
r3x = 0; | ||
} | ||
if (!r3x && !this._isMasked(x, y)) { | ||
this.buffer[x + (y * width)] ^= 1 | ||
this.buffer[x + (y * width)] ^= 1; | ||
} | ||
@@ -279,7 +279,7 @@ } | ||
break | ||
break; | ||
case 3: | ||
for (let r3y = 0, y = 0; y < width; y++, r3y++) { | ||
if (r3y === 3) { | ||
r3y = 0 | ||
r3y = 0; | ||
} | ||
@@ -289,7 +289,7 @@ | ||
if (r3x === 3) { | ||
r3x = 0 | ||
r3x = 0; | ||
} | ||
if (!r3x && !this._isMasked(x, y)) { | ||
this.buffer[x + (y * width)] ^= 1 | ||
this.buffer[x + (y * width)] ^= 1; | ||
} | ||
@@ -299,3 +299,3 @@ } | ||
break | ||
break; | ||
case 4: | ||
@@ -305,8 +305,8 @@ for (let y = 0; y < width; y++) { | ||
if (r3x === 3) { | ||
r3x = 0 | ||
r3y = !r3y | ||
r3x = 0; | ||
r3y = !r3y; | ||
} | ||
if (!r3y && !this._isMasked(x, y)) { | ||
this.buffer[x + (y * width)] ^= 1 | ||
this.buffer[x + (y * width)] ^= 1; | ||
} | ||
@@ -316,7 +316,7 @@ } | ||
break | ||
break; | ||
case 5: | ||
for (let r3y = 0, y = 0; y < width; y++, r3y++) { | ||
if (r3y === 3) { | ||
r3y = 0 | ||
r3y = 0; | ||
} | ||
@@ -326,7 +326,7 @@ | ||
if (r3x === 3) { | ||
r3x = 0 | ||
r3x = 0; | ||
} | ||
if (!((x & y & 1) + !(!r3x | !r3y)) && !this._isMasked(x, y)) { | ||
this.buffer[x + (y * width)] ^= 1 | ||
this.buffer[x + (y * width)] ^= 1; | ||
} | ||
@@ -336,7 +336,7 @@ } | ||
break | ||
break; | ||
case 6: | ||
for (let r3y = 0, y = 0; y < width; y++, r3y++) { | ||
if (r3y === 3) { | ||
r3y = 0 | ||
r3y = 0; | ||
} | ||
@@ -346,7 +346,7 @@ | ||
if (r3x === 3) { | ||
r3x = 0 | ||
r3x = 0; | ||
} | ||
if (!((x & y & 1) + (r3x && r3x === r3y) & 1) && !this._isMasked(x, y)) { | ||
this.buffer[x + (y * width)] ^= 1 | ||
this.buffer[x + (y * width)] ^= 1; | ||
} | ||
@@ -356,7 +356,7 @@ } | ||
break | ||
break; | ||
case 7: | ||
for (let r3y = 0, y = 0; y < width; y++, r3y++) { | ||
if (r3y === 3) { | ||
r3y = 0 | ||
r3y = 0; | ||
} | ||
@@ -366,7 +366,7 @@ | ||
if (r3x === 3) { | ||
r3x = 0 | ||
r3x = 0; | ||
} | ||
if (!((r3x && r3x === r3y) + (x + y & 1) & 1) && !this._isMasked(x, y)) { | ||
this.buffer[x + (y * width)] ^= 1 | ||
this.buffer[x + (y * width)] ^= 1; | ||
} | ||
@@ -376,3 +376,3 @@ } | ||
break | ||
break; | ||
} | ||
@@ -382,17 +382,17 @@ } | ||
_calculateMaxLength() { | ||
return (this._dataBlock * (this._neccBlock1 + this._neccBlock2)) + this._neccBlock2 | ||
return (this._dataBlock * (this._neccBlock1 + this._neccBlock2)) + this._neccBlock2; | ||
} | ||
_calculatePolynomial() { | ||
this._polynomial[0] = 1 | ||
this._polynomial[0] = 1; | ||
for (let i = 0; i < this._eccBlock; i++) { | ||
this._polynomial[i + 1] = 1 | ||
this._polynomial[i + 1] = 1; | ||
for (let j = i; j > 0; j--) { | ||
this._polynomial[j] = this._polynomial[j] ? this._polynomial[j - 1] ^ | ||
Galois.EXPONENT[Frame._modN(Galois.LOG[this._polynomial[j]] + i)] : this._polynomial[j - 1] | ||
Galois.EXPONENT[Frame._modN(Galois.LOG[this._polynomial[j]] + i)] : this._polynomial[j - 1]; | ||
} | ||
this._polynomial[0] = Galois.EXPONENT[Frame._modN(Galois.LOG[this._polynomial[0]] + i)] | ||
this._polynomial[0] = Galois.EXPONENT[Frame._modN(Galois.LOG[this._polynomial[0]] + i)]; | ||
} | ||
@@ -402,3 +402,3 @@ | ||
for (let i = 0; i <= this._eccBlock; i++) { | ||
this._polynomial[i] = Galois.LOG[this._polynomial[i]] | ||
this._polynomial[i] = Galois.LOG[this._polynomial[i]]; | ||
} | ||
@@ -408,4 +408,4 @@ } | ||
_checkBadness() { | ||
let bad = 0 | ||
const width = this.width | ||
let bad = 0; | ||
const width = this.width; | ||
@@ -425,3 +425,3 @@ // Blocks of same colour. | ||
this.buffer[x + 1 + (width * (y + 1))])) { | ||
bad += Frame.N2 | ||
bad += Frame.N2; | ||
} | ||
@@ -431,64 +431,64 @@ } | ||
let bw = 0 | ||
let bw = 0; | ||
// X runs. | ||
for (let y = 0; y < width; y++) { | ||
let h = 0 | ||
let h = 0; | ||
this._badness[0] = 0 | ||
this._badness[0] = 0; | ||
for (let b = 0, x = 0; x < width; x++) { | ||
const b1 = this.buffer[x + (width * y)] | ||
const b1 = this.buffer[x + (width * y)]; | ||
if (b === b1) { | ||
this._badness[h]++ | ||
this._badness[h]++; | ||
} else { | ||
this._badness[++h] = 1 | ||
this._badness[++h] = 1; | ||
} | ||
b = b1 | ||
bw += b ? 1 : -1 | ||
b = b1; | ||
bw += b ? 1 : -1; | ||
} | ||
bad += this._getBadness(h) | ||
bad += this._getBadness(h); | ||
} | ||
if (bw < 0) { | ||
bw = -bw | ||
bw = -bw; | ||
} | ||
let count = 0 | ||
let big = bw | ||
big += big << 2 | ||
big <<= 1 | ||
let count = 0; | ||
let big = bw; | ||
big += big << 2; | ||
big <<= 1; | ||
while (big > width * width) { | ||
big -= width * width | ||
count++ | ||
big -= width * width; | ||
count++; | ||
} | ||
bad += count * Frame.N4 | ||
bad += count * Frame.N4; | ||
// Y runs. | ||
for (let x = 0; x < width; x++) { | ||
let h = 0 | ||
let h = 0; | ||
this._badness[0] = 0 | ||
this._badness[0] = 0; | ||
for (let b = 0, y = 0; y < width; y++) { | ||
const b1 = this.buffer[x + (width * y)] | ||
const b1 = this.buffer[x + (width * y)]; | ||
if (b === b1) { | ||
this._badness[h]++ | ||
this._badness[h]++; | ||
} else { | ||
this._badness[++h] = 1 | ||
this._badness[++h] = 1; | ||
} | ||
b = b1 | ||
b = b1; | ||
} | ||
bad += this._getBadness(h) | ||
bad += this._getBadness(h); | ||
} | ||
return bad | ||
return bad; | ||
} | ||
@@ -499,14 +499,14 @@ | ||
for (let i = 0; i < length; i++) { | ||
this._ecc[i] = this._value.charCodeAt(i) | ||
this._ecc[i] = this._value.charCodeAt(i); | ||
} | ||
this._stringBuffer = this._ecc.slice(0) | ||
this._stringBuffer = this._ecc.slice(0); | ||
const maxLength = this._calculateMaxLength() | ||
const maxLength = this._calculateMaxLength(); | ||
if (length >= maxLength - 2) { | ||
length = maxLength - 2 | ||
length = maxLength - 2; | ||
if (this._version > 9) { | ||
length-- | ||
length--; | ||
} | ||
@@ -516,39 +516,39 @@ } | ||
// Shift and re-pack to insert length prefix. | ||
let index = length | ||
let index = length; | ||
if (this._version > 9) { | ||
this._stringBuffer[index + 2] = 0 | ||
this._stringBuffer[index + 3] = 0 | ||
this._stringBuffer[index + 2] = 0; | ||
this._stringBuffer[index + 3] = 0; | ||
while (index--) { | ||
const bit = this._stringBuffer[index] | ||
const bit = this._stringBuffer[index]; | ||
this._stringBuffer[index + 3] |= 255 & (bit << 4) | ||
this._stringBuffer[index + 2] = bit >> 4 | ||
this._stringBuffer[index + 3] |= 255 & (bit << 4); | ||
this._stringBuffer[index + 2] = bit >> 4; | ||
} | ||
this._stringBuffer[2] |= 255 & (length << 4) | ||
this._stringBuffer[1] = length >> 4 | ||
this._stringBuffer[0] = 0x40 | (length >> 12) | ||
this._stringBuffer[2] |= 255 & (length << 4); | ||
this._stringBuffer[1] = length >> 4; | ||
this._stringBuffer[0] = 0x40 | (length >> 12); | ||
} else { | ||
this._stringBuffer[index + 1] = 0 | ||
this._stringBuffer[index + 2] = 0 | ||
this._stringBuffer[index + 1] = 0; | ||
this._stringBuffer[index + 2] = 0; | ||
while (index--) { | ||
const bit = this._stringBuffer[index] | ||
const bit = this._stringBuffer[index]; | ||
this._stringBuffer[index + 2] |= 255 & (bit << 4) | ||
this._stringBuffer[index + 1] = bit >> 4 | ||
this._stringBuffer[index + 2] |= 255 & (bit << 4); | ||
this._stringBuffer[index + 1] = bit >> 4; | ||
} | ||
this._stringBuffer[1] |= 255 & (length << 4) | ||
this._stringBuffer[0] = 0x40 | (length >> 4) | ||
this._stringBuffer[1] |= 255 & (length << 4); | ||
this._stringBuffer[0] = 0x40 | (length >> 4); | ||
} | ||
// Fill to end with pad pattern. | ||
index = length + 3 - (this._version < 10) | ||
index = length + 3 - (this._version < 10); | ||
while (index < maxLength) { | ||
this._stringBuffer[index++] = 0xec | ||
this._stringBuffer[index++] = 0x11 | ||
this._stringBuffer[index++] = 0xec; | ||
this._stringBuffer[index++] = 0x11; | ||
} | ||
@@ -558,7 +558,7 @@ } | ||
_getBadness(length) { | ||
let badRuns = 0 | ||
let badRuns = 0; | ||
for (let i = 0; i <= length; i++) { | ||
if (this._badness[i] >= 5) { | ||
badRuns += Frame.N1 + this._badness[i] - 5 | ||
badRuns += Frame.N1 + this._badness[i] - 5; | ||
} | ||
@@ -577,7 +577,7 @@ } | ||
this._badness[i + 3] * 3 >= this._badness[i] * 4)) { | ||
badRuns += Frame.N3 | ||
badRuns += Frame.N3; | ||
} | ||
} | ||
return badRuns | ||
return badRuns; | ||
} | ||
@@ -587,7 +587,7 @@ | ||
// Save pre-mask copy of frame. | ||
this._stringBuffer = this.buffer.slice(0) | ||
this._stringBuffer = this.buffer.slice(0); | ||
let bit = 0 | ||
let i | ||
let mask = 30000 | ||
let bit = 0; | ||
let i; | ||
let mask = 30000; | ||
@@ -600,10 +600,10 @@ /* | ||
// Returns foreground-background imbalance. | ||
this._applyMask(i) | ||
this._applyMask(i); | ||
const currentMask = this._checkBadness() | ||
const currentMask = this._checkBadness(); | ||
// Is current mask better than previous best? | ||
if (currentMask < mask) { | ||
mask = currentMask | ||
bit = i | ||
mask = currentMask; | ||
bit = i; | ||
} | ||
@@ -613,7 +613,7 @@ | ||
if (bit === 7) { | ||
break | ||
break; | ||
} | ||
// Reset for next pass. | ||
this.buffer = this._stringBuffer.slice(0) | ||
this.buffer = this._stringBuffer.slice(0); | ||
} | ||
@@ -623,7 +623,7 @@ | ||
if (bit !== i) { | ||
this._applyMask(bit) | ||
this._applyMask(bit); | ||
} | ||
// Add in final mask/ECC level bytes. | ||
mask = ErrorCorrection.FINAL_FORMAT[bit + (this._level - 1 << 3)] | ||
mask = ErrorCorrection.FINAL_FORMAT[bit + (this._level - 1 << 3)]; | ||
@@ -633,8 +633,8 @@ // Low byte. | ||
if (mask & 1) { | ||
this.buffer[this.width - 1 - i + (this.width * 8)] = 1 | ||
this.buffer[this.width - 1 - i + (this.width * 8)] = 1; | ||
if (i < 6) { | ||
this.buffer[8 + (this.width * i)] = 1 | ||
this.buffer[8 + (this.width * i)] = 1; | ||
} else { | ||
this.buffer[8 + (this.width * (i + 1))] = 1 | ||
this.buffer[8 + (this.width * (i + 1))] = 1; | ||
} | ||
@@ -647,8 +647,8 @@ } | ||
if (mask & 1) { | ||
this.buffer[8 + (this.width * (this.width - 7 + i))] = 1 | ||
this.buffer[8 + (this.width * (this.width - 7 + i))] = 1; | ||
if (i) { | ||
this.buffer[6 - i + (this.width * 8)] = 1 | ||
this.buffer[6 - i + (this.width * 8)] = 1; | ||
} else { | ||
this.buffer[7 + (this.width * 8)] = 1 | ||
this.buffer[7 + (this.width * 8)] = 1; | ||
} | ||
@@ -660,13 +660,13 @@ } | ||
_interleaveBlocks() { | ||
const maxLength = this._calculateMaxLength() | ||
let i | ||
let k = 0 | ||
const maxLength = this._calculateMaxLength(); | ||
let i; | ||
let k = 0; | ||
for (i = 0; i < this._dataBlock; i++) { | ||
for (let j = 0; j < this._neccBlock1; j++) { | ||
this._ecc[k++] = this._stringBuffer[i + (j * this._dataBlock)] | ||
this._ecc[k++] = this._stringBuffer[i + (j * this._dataBlock)]; | ||
} | ||
for (let j = 0; j < this._neccBlock2; j++) { | ||
this._ecc[k++] = this._stringBuffer[(this._neccBlock1 * this._dataBlock) + i + (j * (this._dataBlock + 1))] | ||
this._ecc[k++] = this._stringBuffer[(this._neccBlock1 * this._dataBlock) + i + (j * (this._dataBlock + 1))]; | ||
} | ||
@@ -676,3 +676,3 @@ } | ||
for (let j = 0; j < this._neccBlock2; j++) { | ||
this._ecc[k++] = this._stringBuffer[(this._neccBlock1 * this._dataBlock) + i + (j * (this._dataBlock + 1))] | ||
this._ecc[k++] = this._stringBuffer[(this._neccBlock1 * this._dataBlock) + i + (j * (this._dataBlock + 1))]; | ||
} | ||
@@ -682,37 +682,37 @@ | ||
for (let j = 0; j < this._neccBlock1 + this._neccBlock2; j++) { | ||
this._ecc[k++] = this._stringBuffer[maxLength + i + (j * this._eccBlock)] | ||
this._ecc[k++] = this._stringBuffer[maxLength + i + (j * this._eccBlock)]; | ||
} | ||
} | ||
this._stringBuffer = this._ecc | ||
this._stringBuffer = this._ecc; | ||
} | ||
_insertAlignments() { | ||
const width = this.width | ||
const width = this.width; | ||
if (this._version > 1) { | ||
const i = Alignment.BLOCK[this._version] | ||
let y = width - 7 | ||
const i = Alignment.BLOCK[this._version]; | ||
let y = width - 7; | ||
for (;;) { | ||
let x = width - 7 | ||
let x = width - 7; | ||
while (x > i - 3) { | ||
this._addAlignment(x, y) | ||
this._addAlignment(x, y); | ||
if (x < i) { | ||
break | ||
break; | ||
} | ||
x -= i | ||
x -= i; | ||
} | ||
if (y <= i + 9) { | ||
break | ||
break; | ||
} | ||
y -= i | ||
y -= i; | ||
this._addAlignment(6, y) | ||
this._addAlignment(y, 6) | ||
this._addAlignment(6, y); | ||
this._addAlignment(y, 6); | ||
} | ||
@@ -723,36 +723,36 @@ } | ||
_insertFinders() { | ||
const width = this.width | ||
const width = this.width; | ||
for (let i = 0; i < 3; i++) { | ||
let j = 0 | ||
let y = 0 | ||
let j = 0; | ||
let y = 0; | ||
if (i === 1) { | ||
j = width - 7 | ||
j = width - 7; | ||
} | ||
if (i === 2) { | ||
y = width - 7 | ||
y = width - 7; | ||
} | ||
this.buffer[y + 3 + (width * (j + 3))] = 1 | ||
this.buffer[y + 3 + (width * (j + 3))] = 1; | ||
for (let x = 0; x < 6; x++) { | ||
this.buffer[y + x + (width * j)] = 1 | ||
this.buffer[y + (width * (j + x + 1))] = 1 | ||
this.buffer[y + 6 + (width * (j + x))] = 1 | ||
this.buffer[y + x + 1 + (width * (j + 6))] = 1 | ||
this.buffer[y + x + (width * j)] = 1; | ||
this.buffer[y + (width * (j + x + 1))] = 1; | ||
this.buffer[y + 6 + (width * (j + x))] = 1; | ||
this.buffer[y + x + 1 + (width * (j + 6))] = 1; | ||
} | ||
for (let x = 1; x < 5; x++) { | ||
this._setMask(y + x, j + 1) | ||
this._setMask(y + 1, j + x + 1) | ||
this._setMask(y + 5, j + x) | ||
this._setMask(y + x + 1, j + 5) | ||
this._setMask(y + x, j + 1); | ||
this._setMask(y + 1, j + x + 1); | ||
this._setMask(y + 5, j + x); | ||
this._setMask(y + x + 1, j + 5); | ||
} | ||
for (let x = 2; x < 4; x++) { | ||
this.buffer[y + x + (width * (j + 2))] = 1 | ||
this.buffer[y + 2 + (width * (j + x + 1))] = 1 | ||
this.buffer[y + 4 + (width * (j + x))] = 1 | ||
this.buffer[y + x + 1 + (width * (j + 4))] = 1 | ||
this.buffer[y + x + (width * (j + 2))] = 1; | ||
this.buffer[y + 2 + (width * (j + x + 1))] = 1; | ||
this.buffer[y + 4 + (width * (j + x))] = 1; | ||
this.buffer[y + x + 1 + (width * (j + 4))] = 1; | ||
} | ||
@@ -763,14 +763,14 @@ } | ||
_insertTimingGap() { | ||
const width = this.width | ||
const width = this.width; | ||
for (let y = 0; y < 7; y++) { | ||
this._setMask(7, y) | ||
this._setMask(width - 8, y) | ||
this._setMask(7, y + width - 7) | ||
this._setMask(7, y); | ||
this._setMask(width - 8, y); | ||
this._setMask(7, y + width - 7); | ||
} | ||
for (let x = 0; x < 8; x++) { | ||
this._setMask(x, 7) | ||
this._setMask(x + width - 8, 7) | ||
this._setMask(x, width - 8) | ||
this._setMask(x, 7); | ||
this._setMask(x + width - 8, 7); | ||
this._setMask(x, width - 8); | ||
} | ||
@@ -780,11 +780,11 @@ } | ||
_insertTimingRowAndColumn() { | ||
const width = this.width | ||
const width = this.width; | ||
for (let x = 0; x < width - 14; x++) { | ||
if (x & 1) { | ||
this._setMask(8 + x, 6) | ||
this._setMask(6, 8 + x) | ||
this._setMask(8 + x, 6); | ||
this._setMask(6, 8 + x); | ||
} else { | ||
this.buffer[8 + x + (width * 6)] = 1 | ||
this.buffer[6 + (width * (8 + x))] = 1 | ||
this.buffer[8 + x + (width * 6)] = 1; | ||
this.buffer[6 + (width * (8 + x))] = 1; | ||
} | ||
@@ -795,7 +795,7 @@ } | ||
_insertVersion() { | ||
const width = this.width | ||
const width = this.width; | ||
if (this._version > 6) { | ||
const i = Version.BLOCK[this._version - 7] | ||
let j = 17 | ||
const i = Version.BLOCK[this._version - 7]; | ||
let j = 17; | ||
@@ -805,7 +805,7 @@ for (let x = 0; x < 6; x++) { | ||
if (1 & (j > 11 ? this._version >> j - 12 : i >> j)) { | ||
this.buffer[5 - x + (width * (2 - y + width - 11))] = 1 | ||
this.buffer[2 - y + width - 11 + (width * (5 - x))] = 1 | ||
this.buffer[5 - x + (width * (2 - y + width - 11))] = 1; | ||
this.buffer[2 - y + width - 11 + (width * (5 - x))] = 1; | ||
} else { | ||
this._setMask(5 - x, 2 - y + width - 11) | ||
this._setMask(2 - y + width - 11, 5 - x) | ||
this._setMask(5 - x, 2 - y + width - 11); | ||
this._setMask(2 - y + width - 11, 5 - x); | ||
} | ||
@@ -818,22 +818,22 @@ } | ||
_isMasked(x, y) { | ||
const bit = Frame._getMaskBit(x, y) | ||
const bit = Frame._getMaskBit(x, y); | ||
return this._mask[bit] === 1 | ||
return this._mask[bit] === 1; | ||
} | ||
_pack() { | ||
let x = this.width - 1 | ||
let y = this.width - 1 | ||
let k = 1 | ||
let v = 1 | ||
let x = this.width - 1; | ||
let y = this.width - 1; | ||
let k = 1; | ||
let v = 1; | ||
// Interleaved data and ECC codes. | ||
const length = ((this._dataBlock + this._eccBlock) * (this._neccBlock1 + this._neccBlock2)) + this._neccBlock2 | ||
const length = ((this._dataBlock + this._eccBlock) * (this._neccBlock1 + this._neccBlock2)) + this._neccBlock2; | ||
for (let i = 0; i < length; i++) { | ||
let bit = this._stringBuffer[i] | ||
let bit = this._stringBuffer[i]; | ||
for (let j = 0; j < 8; j++, bit <<= 1) { | ||
if (0x80 & bit) { | ||
this.buffer[x + (this.width * y)] = 1 | ||
this.buffer[x + (this.width * y)] = 1; | ||
} | ||
@@ -844,27 +844,27 @@ | ||
if (v) { | ||
x-- | ||
x--; | ||
} else { | ||
x++ | ||
x++; | ||
if (k) { | ||
if (y !== 0) { | ||
y-- | ||
y--; | ||
} else { | ||
x -= 2 | ||
k = !k | ||
x -= 2; | ||
k = !k; | ||
if (x === 6) { | ||
x-- | ||
y = 9 | ||
x--; | ||
y = 9; | ||
} | ||
} | ||
} else if (y !== this.width - 1) { | ||
y++ | ||
y++; | ||
} else { | ||
x -= 2 | ||
k = !k | ||
x -= 2; | ||
k = !k; | ||
if (x === 6) { | ||
x-- | ||
y -= 8 | ||
x--; | ||
y -= 8; | ||
} | ||
@@ -874,4 +874,4 @@ } | ||
v = !v | ||
} while (this._isMasked(x, y)) | ||
v = !v; | ||
} while (this._isMasked(x, y)); | ||
} | ||
@@ -882,15 +882,15 @@ } | ||
_reverseMask() { | ||
const width = this.width | ||
const width = this.width; | ||
for (let x = 0; x < 9; x++) { | ||
this._setMask(x, 8) | ||
this._setMask(x, 8); | ||
} | ||
for (let x = 0; x < 8; x++) { | ||
this._setMask(x + width - 8, 8) | ||
this._setMask(8, x) | ||
this._setMask(x + width - 8, 8); | ||
this._setMask(8, x); | ||
} | ||
for (let y = 0; y < 7; y++) { | ||
this._setMask(8, y + width - 7) | ||
this._setMask(8, y + width - 7); | ||
} | ||
@@ -900,9 +900,9 @@ } | ||
_setMask(x, y) { | ||
const bit = Frame._getMaskBit(x, y) | ||
const bit = Frame._getMaskBit(x, y); | ||
this._mask[bit] = 1 | ||
this._mask[bit] = 1; | ||
} | ||
_syncMask() { | ||
const width = this.width | ||
const width = this.width; | ||
@@ -912,3 +912,3 @@ for (let y = 0; y < width; y++) { | ||
if (this.buffer[x + (width * y)]) { | ||
this._setMask(x, y) | ||
this._setMask(x, y); | ||
} | ||
@@ -921,3 +921,3 @@ } | ||
export default Frame | ||
export default Frame; | ||
@@ -924,0 +924,0 @@ /** |
/* | ||
* QRious | ||
* Copyright (C) 2016 Alasdair Mercer | ||
* Copyright (C) 2017 Alasdair Mercer | ||
* Copyright (C) 2010 Tom Zerucha | ||
@@ -52,3 +52,3 @@ * | ||
0x2c, 0x58, 0xb0, 0x7d, 0xfa, 0xe9, 0xcf, 0x83, 0x1b, 0x36, 0x6c, 0xd8, 0xad, 0x47, 0x8e, 0x00 | ||
] | ||
]; | ||
} | ||
@@ -81,3 +81,3 @@ | ||
0x4f, 0xae, 0xd5, 0xe9, 0xe6, 0xe7, 0xad, 0xe8, 0x74, 0xd6, 0xf4, 0xea, 0xa8, 0x50, 0x58, 0xaf | ||
] | ||
]; | ||
} | ||
@@ -87,2 +87,2 @@ | ||
export default Galois | ||
export default Galois; |
/* | ||
* QRious | ||
* Copyright (C) 2016 Alasdair Mercer | ||
* Copyright (C) 2017 Alasdair Mercer | ||
* Copyright (C) 2010 Tom Zerucha | ||
@@ -20,8 +20,24 @@ * | ||
import CanvasRenderer from './renderer/CanvasRenderer' | ||
import Frame from './Frame' | ||
import ImageRenderer from './renderer/ImageRenderer' | ||
import ServiceManager from './service/ServiceManager' | ||
import Utilities from './util/Utilities' | ||
import CanvasRenderer from './renderer/CanvasRenderer'; | ||
import Frame from './Frame'; | ||
import ImageRenderer from './renderer/ImageRenderer'; | ||
import Option from './option/Option'; | ||
import OptionManager from './option/OptionManager'; | ||
import ServiceManager from './service/ServiceManager'; | ||
import Utilities from './util/Utilities'; | ||
const optionManager = new OptionManager([ | ||
new Option('background', 'white'), | ||
new Option('backgroundAlpha', 1, Utilities.abs), | ||
new Option('element'), | ||
new Option('foreground', 'black'), | ||
new Option('foregroundAlpha', 1, Utilities.abs), | ||
new Option('level', 'L', Utilities.toUpperCase), | ||
new Option('mime', 'image/png'), | ||
new Option('padding', null, Utilities.abs), | ||
new Option('size', 100, Utilities.abs), | ||
new Option('value', '') | ||
]); | ||
const serviceManager = new ServiceManager(); | ||
/** | ||
@@ -38,2 +54,3 @@ * Enables configuration of a QR code generator which uses HTML5 <code>canvas</code> for rendering. | ||
* @return {QRious~Options} The default options. | ||
* @deprecated Since 2.3.0 | ||
* @public | ||
@@ -43,13 +60,9 @@ * @static | ||
static get DEFAULTS() { | ||
return { | ||
background: 'white', | ||
backgroundAlpha: 1, | ||
foreground: 'black', | ||
foregroundAlpha: 1, | ||
level: 'L', | ||
mime: 'image/png', | ||
padding: null, | ||
size: 100, | ||
value: '' | ||
} | ||
const result = {}; | ||
optionManager.options.forEach((option) => { | ||
result[option.name] = option.defaultValue; | ||
}); | ||
return result; | ||
} | ||
@@ -65,3 +78,3 @@ | ||
static get VERSION() { | ||
return '2.2.0' | ||
return '2.3.0'; | ||
} | ||
@@ -79,16 +92,5 @@ | ||
static use(service) { | ||
QRious._serviceManager.setService(service.getName(), service) | ||
serviceManager.setService(service.getName(), service); | ||
} | ||
static _parseOptions(options) { | ||
options = Object.assign({}, QRious.DEFAULTS, options) | ||
options.backgroundAlpha = Utilities.abs(options.backgroundAlpha) | ||
options.foregroundAlpha = Utilities.abs(options.foregroundAlpha) | ||
options.level = Utilities.toUpperCase(options.level) | ||
options.padding = Utilities.abs(options.padding) | ||
options.size = Utilities.abs(options.size) | ||
return options | ||
} | ||
/** | ||
@@ -98,36 +100,49 @@ * Creates a new instance of {@link QRious} based on the <code>options</code> provided. | ||
* @param {QRious~Options} [options] - the options to be used | ||
* @throws {Error} If any <code>options</code> are invalid. | ||
* @public | ||
*/ | ||
constructor(options) { | ||
options = QRious._parseOptions(options) | ||
optionManager.applyDefaults(this); | ||
optionManager.setAll(options, this); | ||
Utilities.privatize(this, options) | ||
const element = optionManager.get('element', this); | ||
const elementService = serviceManager.getService('element'); | ||
const canvas = element && elementService.isCanvas(element) ? element : elementService.createCanvas(); | ||
const image = element && elementService.isImage(element) ? element : elementService.createImage(); | ||
const element = this._element | ||
const elementService = QRious._serviceManager.getService('element') | ||
this._canvasRenderer = new CanvasRenderer(this, canvas, true); | ||
this._imageRenderer = new ImageRenderer(this, image, image === element); | ||
/** | ||
* The <code>canvas</code> being used to render the QR code for this {@link QRious}. | ||
* | ||
* @public | ||
* @type {*} | ||
*/ | ||
this.canvas = element && elementService.isCanvas(element) ? element : elementService.createCanvas() | ||
this.canvas.qrious = this | ||
this.update(); | ||
} | ||
/** | ||
* The <code>img</code> to contain the rendered QR code for this {@link QRious}. | ||
* | ||
* @public | ||
* @type {*} | ||
*/ | ||
this.image = element && elementService.isImage(element) ? element : elementService.createImage() | ||
this.image.qrious = this | ||
/** | ||
* Returns all of the options configured for this {@link QRious}. | ||
* | ||
* Any changes made to the returned object will not be reflected in the options themselves or their corresponding | ||
* underlying fields. | ||
* | ||
* @return {Object.<string, *>} A copy of the applied options. | ||
* @public | ||
*/ | ||
get() { | ||
return optionManager.getAll(this); | ||
} | ||
this._renderers = [ | ||
new CanvasRenderer(this), | ||
new ImageRenderer(this) | ||
] | ||
this.update() | ||
/** | ||
* Sets all of the specified <code>options</code> and automatically updates this {@link QRious} if any of the | ||
* underlying fields are changed as a result. | ||
* | ||
* This is the preferred method for updating multiple options at one time to avoid unnecessary updates between | ||
* changes. | ||
* | ||
* @param {QRious~Options} options - the options to be set | ||
* @return {void} | ||
* @throws {Error} If any <code>options</code> are invalid. | ||
* @public | ||
*/ | ||
set(options) { | ||
if (optionManager.setAll(options, this)) { | ||
this.update(); | ||
} | ||
} | ||
@@ -143,3 +158,3 @@ | ||
toDataURL(mime) { | ||
return this.canvas.toDataURL(mime || this.mime) | ||
return this.canvas.toDataURL(mime || this.mime); | ||
} | ||
@@ -157,5 +172,6 @@ | ||
value: this.value | ||
}) | ||
}); | ||
this._renderers.forEach((renderer) => renderer.render(frame)) | ||
this._canvasRenderer.render(frame); | ||
this._imageRenderer.render(frame); | ||
} | ||
@@ -170,7 +186,8 @@ | ||
get background() { | ||
return this._background | ||
return optionManager.get('background', this); | ||
} | ||
/** | ||
* Sets the background color for the QR code to <code>background</code>. | ||
* Sets the background color for the QR code to <code>background</code> and automatically updates this {@link QRious} | ||
* if the underlying field is changed as a result. | ||
* | ||
@@ -181,6 +198,4 @@ * @param {string} [background="white"] - the background color to be set | ||
set background(background) { | ||
const changed = Utilities.setter(this, '_background', background, QRious.DEFAULTS.background) | ||
if (changed) { | ||
this.update() | ||
if (optionManager.set('background', background, this)) { | ||
this.update(); | ||
} | ||
@@ -196,7 +211,8 @@ } | ||
get backgroundAlpha() { | ||
return this._backgroundAlpha | ||
return optionManager.get('backgroundAlpha', this); | ||
} | ||
/** | ||
* Sets the background alpha for the QR code to <code>backgroundAlpha</code>. | ||
* Sets the background alpha for the QR code to <code>backgroundAlpha</code> and automatically updates this | ||
* {@link QRious} if the underlying field is changed as a result. | ||
* | ||
@@ -207,6 +223,4 @@ * @param {number} [backgroundAlpha=1] - the background alpha to be set | ||
set backgroundAlpha(backgroundAlpha) { | ||
const changed = Utilities.setter(this, '_backgroundAlpha', backgroundAlpha, QRious.DEFAULTS.backgroundAlpha) | ||
if (changed) { | ||
this.update() | ||
if (optionManager.set('backgroundAlpha', backgroundAlpha, this)) { | ||
this.update(); | ||
} | ||
@@ -216,2 +230,12 @@ } | ||
/** | ||
* Returns the <code>canvas</code> element being used to render the QR code for this {@link QRious}. | ||
* | ||
* @return {*} The <code>canvas</code> element. | ||
* @public | ||
*/ | ||
get canvas() { | ||
return this._canvasRenderer.getElement(); | ||
} | ||
/** | ||
* Returns the foreground color for the QR code. | ||
@@ -223,7 +247,8 @@ * | ||
get foreground() { | ||
return this._foreground | ||
return optionManager.get('foreground', this); | ||
} | ||
/** | ||
* Sets the foreground color for the QR code to <code>foreground</code>. | ||
* Sets the foreground color for the QR code to <code>foreground</code> and automatically updates this {@link QRious} | ||
* if the underlying field is changed as a result. | ||
* | ||
@@ -234,6 +259,4 @@ * @param {string} [foreground="black"] - the foreground color to be set | ||
set foreground(foreground) { | ||
const changed = Utilities.setter(this, '_foreground', foreground, QRious.DEFAULTS.foreground) | ||
if (changed) { | ||
this.update() | ||
if (optionManager.set('foreground', foreground, this)) { | ||
this.update(); | ||
} | ||
@@ -249,7 +272,8 @@ } | ||
get foregroundAlpha() { | ||
return this._foregroundAlpha | ||
return optionManager.get('foregroundAlpha', this); | ||
} | ||
/** | ||
* Sets the foreground alpha for the QR code to <code>foregroundAlpha</code>. | ||
* Sets the foreground alpha for the QR code to <code>foregroundAlpha</code> and automatically updates this | ||
* {@link QRious} if the underlying field is changed as a result. | ||
* | ||
@@ -260,6 +284,4 @@ * @param {number} [foregroundAlpha=1] - the foreground alpha to be set | ||
set foregroundAlpha(foregroundAlpha) { | ||
const changed = Utilities.setter(this, '_foregroundAlpha', foregroundAlpha, QRious.DEFAULTS.foregroundAlpha) | ||
if (changed) { | ||
this.update() | ||
if (optionManager.set('foregroundAlpha', foregroundAlpha, this)) { | ||
this.update(); | ||
} | ||
@@ -269,2 +291,12 @@ } | ||
/** | ||
* Returns the <code>img</code> element being used to render the QR code for this {@link QRious}. | ||
* | ||
* @return {*} The <code>img</code> element. | ||
* @public | ||
*/ | ||
get image() { | ||
return this._imageRenderer.getElement(); | ||
} | ||
/** | ||
* Returns the error correction level for the QR code. | ||
@@ -276,7 +308,8 @@ * | ||
get level() { | ||
return this._level | ||
return optionManager.get('level', this); | ||
} | ||
/** | ||
* Sets the error correction level for the QR code to <code>level</code>. | ||
* Sets the error correction level for the QR code to <code>level</code> and automatically updates this {@link QRious} | ||
* if the underlying field is changed as a result. | ||
* | ||
@@ -289,6 +322,4 @@ * <code>level</code> will be transformed to upper case to aid mapping to known ECC level blocks. | ||
set level(level) { | ||
const changed = Utilities.setter(this, '_level', level, QRious.DEFAULTS.level, Utilities.toUpperCase) | ||
if (changed) { | ||
this.update() | ||
if (optionManager.set('level', level, this)) { | ||
this.update(); | ||
} | ||
@@ -304,7 +335,8 @@ } | ||
get mime() { | ||
return this._mime | ||
return optionManager.get('mime', this); | ||
} | ||
/** | ||
* Sets the MIME type for the image rendered for the QR code to <code>mime</code>. | ||
* Sets the MIME type for the image rendered for the QR code to <code>mime</code> and automatically updates this | ||
* {@link QRious} if the underlying field is changed as a result. | ||
* | ||
@@ -315,6 +347,4 @@ * @param {string} [mime="image/png"] - the image MIME type to be set | ||
set mime(mime) { | ||
const changed = Utilities.setter(this, '_mime', mime, QRious.DEFAULTS.mime) | ||
if (changed) { | ||
this.update() | ||
if (optionManager.set('mime', mime, this)) { | ||
this.update(); | ||
} | ||
@@ -330,7 +360,8 @@ } | ||
get padding() { | ||
return this._padding | ||
return optionManager.get('padding', this); | ||
} | ||
/** | ||
* Sets the padding for the QR code to <code>padding</code>. | ||
* Sets the padding for the QR code to <code>padding</code> and automatically updates this {@link QRious} if the | ||
* underlying field is changed as a result. | ||
* | ||
@@ -344,6 +375,4 @@ * <code>padding</code> will be transformed to ensure that it is always an absolute positive numbers (e.g. | ||
set padding(padding) { | ||
const changed = Utilities.setter(this, '_padding', padding, QRious.DEFAULTS.padding, Utilities.abs) | ||
if (changed) { | ||
this.update() | ||
if (optionManager.set('padding', padding, this)) { | ||
this.update(); | ||
} | ||
@@ -359,7 +388,8 @@ } | ||
get size() { | ||
return this._size | ||
return optionManager.get('size', this); | ||
} | ||
/** | ||
* Sets the size of the QR code to <code>size</code>. | ||
* Sets the size of the QR code to <code>size</code> and automatically updates this {@link QRious} if the underlying | ||
* field is changed as a result. | ||
* | ||
@@ -373,6 +403,4 @@ * <code>size</code> will be transformed to ensure that it is always an absolute positive numbers (e.g. | ||
set size(size) { | ||
const changed = Utilities.setter(this, '_size', size, QRious.DEFAULTS.size, Utilities.abs) | ||
if (changed) { | ||
this.update() | ||
if (optionManager.set('size', size, this)) { | ||
this.update(); | ||
} | ||
@@ -388,7 +416,8 @@ } | ||
get value() { | ||
return this._value | ||
return optionManager.get('value', this); | ||
} | ||
/** | ||
* Sets the value of the QR code to <code>value</code>. | ||
* Sets the value of the QR code to <code>value</code> and automatically updates this {@link QRious} if the underlying | ||
* field is changed as a result. | ||
* | ||
@@ -399,6 +428,4 @@ * @param {string} [value=""] - the value to be set | ||
set value(value) { | ||
const changed = Utilities.setter(this, '_value', value, QRious.DEFAULTS.value) | ||
if (changed) { | ||
this.update() | ||
if (optionManager.set('value', value, this)) { | ||
this.update(); | ||
} | ||
@@ -409,6 +436,4 @@ } | ||
QRious._serviceManager = new ServiceManager() | ||
export default QRious; | ||
export default QRious | ||
/** | ||
@@ -415,0 +440,0 @@ * The options used by {@link QRious}. |
/* | ||
* QRious | ||
* Copyright (C) 2016 Alasdair Mercer | ||
* Copyright (C) 2017 Alasdair Mercer | ||
* Copyright (C) 2010 Tom Zerucha | ||
@@ -20,3 +20,3 @@ * | ||
import Renderer from './Renderer' | ||
import Renderer from './Renderer'; | ||
@@ -35,9 +35,9 @@ /** | ||
draw(frame) { | ||
const qrious = this.qrious | ||
const moduleSize = this.getModuleSize(frame) | ||
const offset = this.getOffset(frame) | ||
const context = qrious.canvas.getContext('2d') | ||
const qrious = this.qrious; | ||
const moduleSize = this.getModuleSize(frame); | ||
const offset = this.getOffset(frame); | ||
const context = this.element.getContext('2d'); | ||
context.fillStyle = qrious.foreground | ||
context.globalAlpha = qrious.foregroundAlpha | ||
context.fillStyle = qrious.foreground; | ||
context.globalAlpha = qrious.foregroundAlpha; | ||
@@ -47,3 +47,3 @@ for (let i = 0; i < frame.width; i++) { | ||
if (frame.buffer[(j * frame.width) + i]) { | ||
context.fillRect((moduleSize * i) + offset, (moduleSize * j) + offset, moduleSize, moduleSize) | ||
context.fillRect((moduleSize * i) + offset, (moduleSize * j) + offset, moduleSize, moduleSize); | ||
} | ||
@@ -58,10 +58,11 @@ } | ||
reset() { | ||
const qrious = this.qrious | ||
const context = qrious.canvas.getContext('2d') | ||
const qrious = this.qrious; | ||
const context = this.element.getContext('2d'); | ||
const size = qrious.size; | ||
context.lineWidth = 1 | ||
context.clearRect(0, 0, qrious.size, qrious.size) | ||
context.fillStyle = qrious.background | ||
context.globalAlpha = qrious.backgroundAlpha | ||
context.fillRect(0, 0, qrious.size, qrious.size) | ||
context.lineWidth = 1; | ||
context.clearRect(0, 0, size, size); | ||
context.fillStyle = qrious.background; | ||
context.globalAlpha = qrious.backgroundAlpha; | ||
context.fillRect(0, 0, size, size); | ||
} | ||
@@ -73,7 +74,3 @@ | ||
resize() { | ||
const qrious = this.qrious | ||
const canvas = qrious.canvas | ||
canvas.width = qrious.size | ||
canvas.height = qrious.size | ||
this.element.width = this.element.height = this.qrious.size; | ||
} | ||
@@ -83,2 +80,2 @@ | ||
export default CanvasRenderer | ||
export default CanvasRenderer; |
/* | ||
* QRious | ||
* Copyright (C) 2016 Alasdair Mercer | ||
* Copyright (C) 2017 Alasdair Mercer | ||
* Copyright (C) 2010 Tom Zerucha | ||
@@ -20,3 +20,3 @@ * | ||
import Renderer from './Renderer' | ||
import Renderer from './Renderer'; | ||
@@ -38,5 +38,3 @@ /** | ||
draw() { | ||
const qrious = this.qrious | ||
qrious.image.src = qrious.toDataURL() | ||
this.element.src = this.qrious.toDataURL(); | ||
} | ||
@@ -48,5 +46,3 @@ | ||
reset() { | ||
const qrious = this.qrious | ||
qrious.image.src = '' | ||
this.element.src = ''; | ||
} | ||
@@ -58,7 +54,3 @@ | ||
resize() { | ||
const qrious = this.qrious | ||
const image = qrious.image | ||
image.width = qrious.size | ||
image.height = qrious.size | ||
this.element.width = this.element.height = this.qrious.size; | ||
} | ||
@@ -68,2 +60,2 @@ | ||
export default ImageRenderer | ||
export default ImageRenderer; |
/* | ||
* QRious | ||
* Copyright (C) 2016 Alasdair Mercer | ||
* Copyright (C) 2017 Alasdair Mercer | ||
* Copyright (C) 2010 Tom Zerucha | ||
@@ -20,3 +20,3 @@ * | ||
import Utilities from '../util/Utilities' | ||
import Utilities from '../util/Utilities'; | ||
@@ -26,4 +26,7 @@ /** | ||
* | ||
* A renderer may be dependant on the rendering of another element, so ordering of their execution is important. | ||
* A renderer may be dependant on the rendering of another element, so the ordering of their execution is important. | ||
* | ||
* The rendering of a element can be deferred by disabling the renderer initially, however, any attempt get the element | ||
* from the renderer will result in it being immediately enabled and the element being rendered. | ||
* | ||
* @public | ||
@@ -34,8 +37,10 @@ */ | ||
/** | ||
* Creates a new instance of {@link Renderer} for the <code>qrious</code> instance provided. | ||
* Creates a new instance of {@link Renderer} for the <code>qrious</code> instance and <code>element</code> provided. | ||
* | ||
* @param {QRious} qrious - the {@link QRious} instance to be used | ||
* @param {*} element - the element onto which the QR code is to be rendered | ||
* @param {boolean} [enabled] - <code>true</code> this {@link Renderer} is enabled; otherwise <code>false</code>. | ||
* @public | ||
*/ | ||
constructor(qrious) { | ||
constructor(qrious, element, enabled) { | ||
/** | ||
@@ -47,3 +52,20 @@ * The {@link QRious} instance. | ||
*/ | ||
this.qrious = qrious | ||
this.qrious = qrious; | ||
/** | ||
* The element onto which this {@link Renderer} is rendering the QR code. | ||
* | ||
* @protected | ||
* @type {*} | ||
*/ | ||
this.element = element; | ||
this.element.qrious = qrious; | ||
/** | ||
* Whether this {@link Renderer} is enabled. | ||
* | ||
* @protected | ||
* @type {boolean} | ||
*/ | ||
this.enabled = Boolean(enabled); | ||
} | ||
@@ -61,6 +83,24 @@ | ||
draw(frame) { | ||
Utilities.throwUnimplemented('Renderer', 'draw') | ||
Utilities.throwUnimplemented('Renderer', 'draw'); | ||
} | ||
/** | ||
* Returns the element onto which this {@link Renderer} is rendering the QR code. | ||
* | ||
* If this method is called while this {@link Renderer} is disabled, it will be immediately enabled and rendered | ||
* before the element is returned. | ||
* | ||
* @return {*} The element. | ||
* @public | ||
*/ | ||
getElement() { | ||
if (!this.enabled) { | ||
this.enabled = true; | ||
this.render(); | ||
} | ||
return this.element; | ||
} | ||
/** | ||
* Calculates the size (in pixel units) to represent an individual module within the QR code based on the | ||
@@ -80,6 +120,7 @@ * <code>frame</code> provided. | ||
getModuleSize(frame) { | ||
const padding = this.qrious.padding || 0 | ||
const pixels = Math.floor((this.qrious.size - (padding * 2)) / frame.width) | ||
const qrious = this.qrious; | ||
const padding = qrious.padding || 0; | ||
const pixels = Math.floor((qrious.size - (padding * 2)) / frame.width); | ||
return Math.max(1, pixels) | ||
return Math.max(1, pixels); | ||
} | ||
@@ -100,10 +141,13 @@ | ||
getOffset(frame) { | ||
if (this.qrious.padding != null) { | ||
return this.qrious.padding | ||
const qrious = this.qrious; | ||
const padding = qrious.padding; | ||
if (padding != null) { | ||
return padding; | ||
} | ||
const moduleSize = this.getModuleSize(frame) | ||
const offset = Math.floor((this.qrious.size - (moduleSize * frame.width)) / 2) | ||
const moduleSize = this.getModuleSize(frame); | ||
const offset = Math.floor((qrious.size - (moduleSize * frame.width)) / 2); | ||
return Math.max(0, offset) | ||
return Math.max(0, offset); | ||
} | ||
@@ -119,5 +163,7 @@ | ||
render(frame) { | ||
this.resize() | ||
this.reset() | ||
this.draw(frame) | ||
if (this.enabled) { | ||
this.resize(); | ||
this.reset(); | ||
this.draw(frame); | ||
} | ||
} | ||
@@ -134,3 +180,3 @@ | ||
reset() { | ||
Utilities.throwUnimplemented('Renderer', 'reset') | ||
Utilities.throwUnimplemented('Renderer', 'reset'); | ||
} | ||
@@ -147,3 +193,3 @@ | ||
resize() { | ||
Utilities.throwUnimplemented('Renderer', 'resize') | ||
Utilities.throwUnimplemented('Renderer', 'resize'); | ||
} | ||
@@ -153,2 +199,2 @@ | ||
export default Renderer | ||
export default Renderer; |
/* | ||
* QRious | ||
* Copyright (C) 2016 Alasdair Mercer | ||
* Copyright (C) 2017 Alasdair Mercer | ||
* Copyright (C) 2010 Tom Zerucha | ||
@@ -20,7 +20,7 @@ * | ||
import BrowserElementService from '../service/element/BrowserElementService' | ||
import QRious from '../QRious' | ||
import BrowserElementService from '../service/element/BrowserElementService'; | ||
import QRious from '../QRious'; | ||
QRious.use(new BrowserElementService()) | ||
QRious.use(new BrowserElementService()); | ||
export default QRious | ||
export default QRious; |
/* | ||
* QRious | ||
* Copyright (C) 2016 Alasdair Mercer | ||
* Copyright (C) 2017 Alasdair Mercer | ||
* Copyright (C) 2010 Tom Zerucha | ||
@@ -20,7 +20,7 @@ * | ||
import NodeElementService from '../service/element/NodeElementService' | ||
import QRious from '../QRious' | ||
import NodeElementService from '../service/element/NodeElementService'; | ||
import QRious from '../QRious'; | ||
QRious.use(new NodeElementService()) | ||
QRious.use(new NodeElementService()); | ||
export default QRious | ||
export default QRious; |
/* | ||
* QRious | ||
* Copyright (C) 2016 Alasdair Mercer | ||
* Copyright (C) 2017 Alasdair Mercer | ||
* Copyright (C) 2010 Tom Zerucha | ||
@@ -20,3 +20,3 @@ * | ||
import ElementService from './ElementService' | ||
import ElementService from './ElementService'; | ||
@@ -35,3 +35,3 @@ /** | ||
createCanvas() { | ||
return document.createElement('canvas') | ||
return document.createElement('canvas'); | ||
} | ||
@@ -43,3 +43,3 @@ | ||
createImage() { | ||
return document.createElement('img') | ||
return document.createElement('img'); | ||
} | ||
@@ -51,3 +51,3 @@ | ||
isCanvas(element) { | ||
return element instanceof HTMLCanvasElement | ||
return element instanceof HTMLCanvasElement; | ||
} | ||
@@ -59,3 +59,3 @@ | ||
isImage(element) { | ||
return element instanceof HTMLImageElement | ||
return element instanceof HTMLImageElement; | ||
} | ||
@@ -65,2 +65,2 @@ | ||
export default BrowserElementService | ||
export default BrowserElementService; |
/* | ||
* QRious | ||
* Copyright (C) 2016 Alasdair Mercer | ||
* Copyright (C) 2017 Alasdair Mercer | ||
* Copyright (C) 2010 Tom Zerucha | ||
@@ -20,4 +20,4 @@ * | ||
import Service from '../Service' | ||
import Utilities from '../../util/Utilities' | ||
import Service from '../Service'; | ||
import Utilities from '../../util/Utilities'; | ||
@@ -39,3 +39,3 @@ /** | ||
createCanvas() { | ||
Utilities.throwUnimplemented('ElementService', 'createCanvas') | ||
Utilities.throwUnimplemented('ElementService', 'createCanvas'); | ||
} | ||
@@ -50,3 +50,3 @@ | ||
createImage() { | ||
Utilities.throwUnimplemented('ElementService', 'createImage') | ||
Utilities.throwUnimplemented('ElementService', 'createImage'); | ||
} | ||
@@ -58,3 +58,3 @@ | ||
getName() { | ||
return 'element' | ||
return 'element'; | ||
} | ||
@@ -70,3 +70,3 @@ | ||
isCanvas(element) { | ||
Utilities.throwUnimplemented('ElementService', 'isCanvas') | ||
Utilities.throwUnimplemented('ElementService', 'isCanvas'); | ||
} | ||
@@ -82,3 +82,3 @@ | ||
isImage(element) { | ||
Utilities.throwUnimplemented('ElementService', 'isImage') | ||
Utilities.throwUnimplemented('ElementService', 'isImage'); | ||
} | ||
@@ -88,2 +88,2 @@ | ||
export default ElementService | ||
export default ElementService; |
/* | ||
* QRious | ||
* Copyright (C) 2016 Alasdair Mercer | ||
* Copyright (C) 2017 Alasdair Mercer | ||
* Copyright (C) 2010 Tom Zerucha | ||
@@ -20,5 +20,5 @@ * | ||
import Canvas, { Image } from 'canvas' | ||
import Canvas, { Image } from 'canvas'; | ||
import ElementService from './ElementService' | ||
import ElementService from './ElementService'; | ||
@@ -38,3 +38,3 @@ /** | ||
static isSupported() { | ||
return Canvas != null | ||
return Canvas != null; | ||
} | ||
@@ -46,3 +46,3 @@ | ||
createCanvas() { | ||
return new Canvas() | ||
return new Canvas(); | ||
} | ||
@@ -54,3 +54,3 @@ | ||
createImage() { | ||
return new Image() | ||
return new Image(); | ||
} | ||
@@ -62,3 +62,3 @@ | ||
isCanvas(element) { | ||
return element instanceof Canvas | ||
return element instanceof Canvas; | ||
} | ||
@@ -70,3 +70,3 @@ | ||
isImage(element) { | ||
return element instanceof Image | ||
return element instanceof Image; | ||
} | ||
@@ -76,2 +76,2 @@ | ||
export default NodeElementService | ||
export default NodeElementService; |
/* | ||
* QRious | ||
* Copyright (C) 2016 Alasdair Mercer | ||
* Copyright (C) 2017 Alasdair Mercer | ||
* Copyright (C) 2010 Tom Zerucha | ||
@@ -20,3 +20,3 @@ * | ||
import Utilities from '../util/Utilities' | ||
import Utilities from '../util/Utilities'; | ||
@@ -37,3 +37,3 @@ /** | ||
getName() { | ||
Utilities.throwUnimplemented('Service', 'getName') | ||
Utilities.throwUnimplemented('Service', 'getName'); | ||
} | ||
@@ -43,2 +43,2 @@ | ||
export default Service | ||
export default Service; |
/* | ||
* QRious | ||
* Copyright (C) 2016 Alasdair Mercer | ||
* Copyright (C) 2017 Alasdair Mercer | ||
* Copyright (C) 2010 Tom Zerucha | ||
@@ -33,3 +33,3 @@ * | ||
constructor() { | ||
this._services = {} | ||
this._services = {}; | ||
} | ||
@@ -46,8 +46,8 @@ | ||
getService(name) { | ||
const service = this._services[name] | ||
const service = this._services[name]; | ||
if (!service) { | ||
throw new Error(`Service is not being managed with name: ${name}`) | ||
throw new Error(`Service is not being managed with name: ${name}`); | ||
} | ||
return service | ||
return service; | ||
} | ||
@@ -67,7 +67,7 @@ | ||
if (this._services[name]) { | ||
throw new Error(`Service is already managed with name: ${name}`) | ||
throw new Error(`Service is already managed with name: ${name}`); | ||
} | ||
if (service) { | ||
this._services[name] = service | ||
this._services[name] = service; | ||
} | ||
@@ -78,2 +78,2 @@ } | ||
export default ServiceManager | ||
export default ServiceManager; |
/* | ||
* QRious | ||
* Copyright (C) 2016 Alasdair Mercer | ||
* Copyright (C) 2017 Alasdair Mercer | ||
* Copyright (C) 2010 Tom Zerucha | ||
@@ -40,56 +40,20 @@ * | ||
static abs(value) { | ||
return value != null ? Math.abs(value) : null | ||
return value != null ? Math.abs(value) : null; | ||
} | ||
/** | ||
* Copies all properties from the <code>source</code> object to the <code>target</code> object, however, all property | ||
* names on the <code>target</code> will be prefixed with an underscore, used to indicate that they are private. | ||
* Returns whether the specified <code>object</code> has a property with the specified <code>name</code> as an own | ||
* (not inherited) property. | ||
* | ||
* @param {Object} target - the object to which the private fields are to be copied | ||
* @param {Object} source - the object from which the fields are to be copied | ||
* @return {Object} A reference to the <code>target</code> object. | ||
* @param {Object} object - the object on which the property is to be checked | ||
* @param {string} name - the name of the property to be checked | ||
* @return {boolean} <code>true</code> if <code>object</code> has an own property with <code>name</code>. | ||
* @public | ||
* @static | ||
*/ | ||
static privatize(target, source) { | ||
for (const key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[`_${key}`] = source[key] | ||
} | ||
} | ||
return target | ||
static hasOwn(object, name) { | ||
return Object.prototype.hasOwnProperty.call(object, name); | ||
} | ||
/** | ||
* Sets the specified <code>value</code> on a given field on the <code>object</code> provided. | ||
* | ||
* If <code>value</code> is <code>null</code>, the specified default value will be used instead. | ||
* | ||
* An optional <code>transformer</code> can be specified which will be used to transform the value (or default value) | ||
* before it is assigned to the field. | ||
* | ||
* @param {Object} object - the object whose field is to be set with <code>value</code> | ||
* @param {string} fieldName - the field to be set with <code>value</code> | ||
* @param {*} value - the value to be set on the named field | ||
* @param {*} [defaultValue] - the value to be used if <code>value</code> is <code>null</code> | ||
* @param {Function} [transformer] - a function used to transform the value before it is assigned to the named field | ||
* @return {boolean} <code>true</code> if the value of the field has changed as a result of the assignment; otherwise | ||
* <code>false</code>. | ||
* @public | ||
* @static | ||
*/ | ||
static setter(object, fieldName, value, defaultValue, transformer) { | ||
const oldValue = object[fieldName] | ||
let newValue = value != null ? value : defaultValue | ||
if (typeof transformer === 'function') { | ||
newValue = transformer(newValue) | ||
} | ||
object[fieldName] = newValue | ||
return newValue !== oldValue | ||
} | ||
/** | ||
* Throws an error indicating that the a given method on a specific class has not been implemented. | ||
@@ -105,3 +69,3 @@ * | ||
static throwUnimplemented(className, methodName) { | ||
throw new Error(`"${methodName}" method must be implemented on the ${className} class`) | ||
throw new Error(`"${methodName}" method must be implemented on the ${className} class`); | ||
} | ||
@@ -118,3 +82,3 @@ | ||
static toUpperCase(string) { | ||
return string != null && string.toUpperCase() | ||
return string != null ? string.toUpperCase() : null; | ||
} | ||
@@ -124,2 +88,2 @@ | ||
export default Utilities | ||
export default Utilities; |
/* | ||
* QRious | ||
* Copyright (C) 2016 Alasdair Mercer | ||
* Copyright (C) 2017 Alasdair Mercer | ||
* Copyright (C) 2010 Tom Zerucha | ||
@@ -39,3 +39,3 @@ * | ||
0x6f0, 0x8ba, 0x79f, 0xb0b, 0x42e, 0xa64, 0x541, 0xc69 | ||
] | ||
]; | ||
} | ||
@@ -45,2 +45,2 @@ | ||
export default Version | ||
export default Version; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
996291
29
9342
248