Comparing version 2.2.1 to 2.2.2
@@ -1,1 +0,1 @@ | ||
"use strict";const e=e=>{const r=new Error(`lean-qr error ${e}`);throw r.code=e,r},r=(e,r)=>r.map((r=>e[r])),n=["content","minCorrectionLevel","maxCorrectionLevel","minVersion","maxVersion","mask","modes"],t=[...n,"on","off","padX","padY"],o={"image-rendering":"pixelated"},s=e=>{try{return e()}catch(e){return void console.warn(e.message)}};exports.makeAsyncComponent=({createElement:s,useEffect:c,useRef:a}=e(6),l=e(7),m={})=>e=>{const i={...m,...e},u=a(null),d=a([null,{}]);return c((()=>{try{((e,r,n)=>n.some((n=>e[n]!==r[n])))(i,d.current[1],n)&&(d.current[0]=l(i.content,i)),d.current[0].toCanvas(u.current,i),u.current.hidden=!1}catch(e){console.warn(e.message),u.current.hidden=!0}d.current[1]=i}),r(i,t)),s("canvas",{ref:u,style:o,className:i.className})},exports.makeSyncComponent=({createElement:c,useMemo:a}=e(6),l=e(7),m=e(8),i={})=>e=>{const u={...i,...e},d=a((()=>s((()=>l(u.content,u)))),r(u,n)),f=a((()=>d&&s((()=>m(d,u)))),[d,...r(u,t)]);return f?c("img",{src:f,style:o,className:u.className}):null}; | ||
"use strict";const e=e=>{const r=new Error(`lean-qr error ${e}`);throw r.code=e,r},r=(e,r)=>r.map((r=>e[r])),n=["content","minCorrectionLevel","maxCorrectionLevel","minVersion","maxVersion","mask","trailer","modes"],t=[...n,"on","off","padX","padY"],s={"image-rendering":"pixelated"},o=e=>{try{return e()}catch(e){return void console.warn(e.message)}};exports.makeAsyncComponent=({createElement:a,useEffect:c,useRef:l}=e(6),i=e(7),m={})=>e=>{const u={...m,...e},d=l(null),f=l([null,{}]);return c((()=>{d.current.hidden=!o((()=>(((e,r,n)=>n.some((n=>e[n]!==r[n])))(u,f.current[1],n)&&(f.current[0]=i(u.content,u)),f.current[0].toCanvas(d.current,u),1))),f.current[1]=u}),r(u,t)),a("canvas",{ref:d,style:s,className:u.className})},exports.makeSyncComponent=({createElement:a,useMemo:c}=e(6),l=e(7),i=e(8),m={})=>e=>{const u={...m,...e},d=c((()=>o((()=>l(u.content,u)))),r(u,n)),f=c((()=>d&&o((()=>i(d,u)))),[d,...r(u,t)]);return f?a("img",{src:f,style:s,className:u.className}):null}; |
@@ -1,1 +0,1 @@ | ||
"use strict";const t=(t,o)=>o.match(/.{4}/g).map((o=>{const e=o.charCodeAt(0)-35,r=o.charCodeAt(1)-35,n=92*o.charCodeAt(2)+o.charCodeAt(3)-3255,s=n>>5;return{t:t,o:8*(r*s+e*(s+1)),l:e?[[r,s],[e,s+1]]:[[r,s]],u:31&n}})),o=[t(1,"#$)b#$.y#$6>#$?'#$Hq#%:q#%>C#%E##%Ka%%:q#'?G%%C;#'HQ$&KA$(AQ$(EC($HS$(M)'&J[(&HS''K_*%Iw('MI')L%'+H1%-J{'+Mi-&L%**Ka-(KA&0KA#4KA$4KA)0KA*/MI1)MI'4Mi5'Mi'7L%)6LE"),t(0,"#$(a#$,w#$2Y#%.A#%27#',W#'-}%%0M%&/i$'29'$4e%)/i$+0-('13((1S&*2{$-3?',29.&2Y0&1U#41u#43?1'3_1)2{0+3_'63?&92{:&2{*82{-63_@%3?:-3?813?:13?=/3_E)3_1@3?C03?*K3_B53_"),t(3,"#$'`#$*u#%)-#%+]%%(I#')s'%()%')Q''(k%))s''*{)'*9'+*7(.(k*(+a%2)s2$*{$4*{'4*Y(2+a)4*{3*+a1.+a3.+a9*+a)?*{=++AB'+aH$+A<2+a$M+aF-+a6@+a*O+a1J+a-Q+a-T+a1S+a9N+aEE+a"),t(2,"#$&@#$(s#%'i#'&?%%')#'(S$''m%'(1'''K%)(S+&'K'*(3'/')(.'K*.'K0&(U4%(36%(33,'m-2(S)6(u#E'k13(U%A(u09(U'D(u?/(UB.(U=6(U<:(U?:(UF6(UQ.(U$^(uL9(Uc%(UQ;(UCM(Uf-(U`7(U")],e={min:0,L:0,M:1,Q:2,H:3,max:3},r=t=>new Uint8Array(t),n=t=>{const o=new Error(`lean-qr error ${t}`);throw o.code=t,o},s=t=>"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:".indexOf(t),f=t=>t.charCodeAt(0),c=(...t)=>(o,e)=>t.forEach((t=>t(o,e))),a=t=>o=>{o.eci!==t&&(o.push(7,4),o.push(t,8),o.eci=t)},l=t=>(o,e)=>{o.push(4,4),o.push(t.length,8+8*(e>9)),t.forEach((t=>o.push(t,8)))},i=(t,o,e,r,n=(r?o=>c(a(r),t(o)):t))=>(n.test=o,n.est=e,n.eci=r,n),u=i((t=>(o,e)=>{o.push(1,4),o.push(t.length,10+2*(e>26)+2*(e>9));let r=0;for(;r<t.length-2;r+=3)o.push(+t.slice(r,r+3),10);r<t.length-1?o.push(+t.slice(r,r+2),7):r<t.length&&o.push(+t[r],4)}),/./.test.bind(/[0-9]/),((t,o)=>14+2*(o>26)+2*(o>9)+10*t.length/3)),$=i((t=>(o,e)=>{o.push(2,4),o.push(t.length,9+2*(e>26)+2*(e>9));let r=0;for(;r<t.length-1;r+=2)o.push(45*s(t[r])+s(t[r+1]),11);r<t.length&&o.push(s(t[r]),6)}),(t=>s(t)>=0),((t,o)=>13+2*(o>26)+2*(o>9)+5.5*t.length)),_=i((t=>l([...t].map(f))),(t=>f(t)<128),((t,o)=>12+8*(o>9)+8*t.length)),U=i(_,(t=>f(t)<256),_.est,3),m=new TextEncoder,p=i((t=>l(m.encode(t))),(()=>1),((t,o)=>12+8*(o>9)+8*m.encode(t).length),26);let d=()=>{const t=new Map,o=new TextDecoder("sjis"),e=r(2);for(const[r,n,s]of[[33088,40957,33088],[57408,60352,49472]])for(let f=r;f<n;++f)e[0]=f>>8,e[1]=255&f,t.set(o.decode(e),192*(f-s>>8)+(f-s&255));return t.delete("\ufffd"),d=()=>t,t};const K=i((t=>(o,e)=>{o.push(8,4),o.push(t.length,8+2*(e>26)+2*(e>9));for(const e of t)o.push(d().get(e),13)}),(t=>d().has(t)),((t,o)=>12+2*(o>26)+2*(o>9)+13*t.length)),M=t=>t.reduce(((t,o)=>o.$<t.$?o:t)),h=[u,$,_,U,K,p],A={auto:(t,{modes:o=h}={})=>(e,r)=>{let s=[{$:0}];for(let e=0;e<t.length;++e)s=o.filter((o=>o.test(t[e]))).map((o=>M(s.map((n=>{const s=n._===o?n.U:e,f=n._===o?n.m:n,c=t.slice(s,e+1),a=o.eci??f.K;return{_:o,m:f,U:s,h:c,$:f.$+12*(a!==f.i)+Math.ceil(o.est(c,r)),K:a}}))))),s.length||n(5);const f=[];for(let t=M(s);t._;t=t.m)f.unshift(t._(t.h));f.forEach((t=>t(e,r)))},multi:c,eci:a,numeric:u,alphaNumeric:$,bytes:l,ascii:_,iso8859_1:U,shift_jis:K,utf8:p},y=t=>({A:r(t),S:0,push(t,o){for(let e=o,r=8-(7&this.S);e>0;e-=r,r=8)this.A[this.S>>>3]|=t<<r>>>e,this.S+=e<r?e:r}}),E=(t,o=t*t,e=r(o))=>({size:t,C:e,g:()=>E(t,e),get:(o,r)=>o>=0&&o<t&&!!(1&e[r*t+o]),I:(o,r)=>2&e[r*t+o],v(o,r,n,s=1){e[r*t+o]=2*s|!!n},Y(o,r){e[r*t+o]^=1},toString({on:o="##",off:e=" ",lf:r="\n",padX:n=4,padY:s=4}={}){let f="";for(let c=-s;c<t+s;++c){for(let r=-n;r<t+n;++r)f+=this.get(r,c)?o:e;f+=r}return f},toImageData(o,{on:e=[0,0,0],off:r=[0,0,0,0],padX:n=4,padY:s=4}={}){const f=t+2*n,c=t+2*s,a=o.createImageData(f,c),l=new Uint32Array(a.data.buffer);a.data.set([...e,255]);const i=l[0];a.data.set([...r,255]);const u=l[0];for(let t=0;t<c;++t)for(let o=0;o<f;++o)l[t*f+o]=this.get(o-n,t-s)?i:u;return a},toCanvas(t,o){const e=t.getContext("2d"),r=this.toImageData(e,o);t.width=r.width,t.height=r.height,e.putImageData(r,0,0)},toDataURL({type:t="image/png",scale:o=1,...e}={}){const r=document.createElement("canvas"),n=r.getContext("2d"),s=this.toImageData(n,e);return r.width=s.width*o,r.height=s.height*o,n.putImageData(s,0,0),n.imageSmoothingEnabled=!1,n.globalCompositeOperation="copy",n.drawImage(r,0,0,s.width,s.height,0,0,r.width,r.height),r.toDataURL(t,1)}}),L=[(t,o)=>!(1&(t^o)),(t,o)=>!(1&o),t=>!(t%3),(t,o)=>!((t+o)%3),(t,o)=>!(1&((t/3|0)^o>>1)),(t,o)=>!((t&o&1)+t*o%3),(t,o)=>!((t&o&1)+t*o%3&1),(t,o)=>!((1&(t^o))+t*o%3&1)],S=r(512);S[0]=1;for(let t=0,o=1;t<255;S[++t]=o)S[o+256]=t,o*=2,256&o&&(o^=285);const w=t=>S[t%255],x=t=>S[t+256],C=(t,o)=>{const e=r(t.length+o.length-1);for(let r=0;r<t.length;++r)for(let n=0;n<o.length;++n)e[r+n]^=w(t[r]+o[n]);return e.map(x)},g=(t,o)=>{const e=r(t.length+o.length-1);e.set(t,0);for(let r=0;r<t.length;++r)if(e[r]){const t=x(e[r]);for(let n=0;n<o.length;++n)e[r+n]^=w(o[n]+t)}return e.slice(t.length)},H=[[0],[0,0]];for(let t=1,o=H[1];t<30;++t){const e=C(o,[0,t]);H.push(e),o=e}const Q=(t,o)=>{const e=[[],[]];let n=0,s=0;for(const[r,f]of o.l)for(let c=0;c<r;++c,n+=f){const r=t.slice(n,n+f);e[0].push(r),e[1].push(g(r,H[o.u])),s+=f+o.u}const f=r(s);let c=0;for(const t of e)for(let o,e=0;c!==o;++e){o=c;for(const o of t)e<o.length&&(f[c++]=o[e])}return f},I=(t,o,e)=>{let r=t<<e-1;for(let t=134217728;t;t>>>=1)r&t&&(r^=o*(t>>>e-1));return r},v=(t,o)=>{const e=(o,e,r,n,s)=>{for(;n-- >0;)for(let f=r;f-- >0;)t.v(o+f,e+n,s)},r=(t,o)=>{e(t-3,o-3,7,7,1),e(t-2,o-2,5,5,0),e(t-1,o-1,3,3,1)},n=(o,r)=>{e(o-2,r-2,5,5,1),e(o-1,r-1,3,3,0),t.v(o,r,1)},s=4*o+17;e(7,0,2,9,0),e(s-8,0,8,9,0);for(let o=0;o<s;++o)t.v(o,6,!(1&o));if(r(3,3),r(s-4,3),o>1){const t=1+(o/7|0),e=2*((s-13)/t/2+.75|0),r=[];for(let o=0;o<t;++o)r.push(s-7-o*e),o&&n(r[o],6);for(let o=0;o<t;++o)for(let e=0;e<t;++e)n(r[o],r[e])}if(o>6)for(let e=o<<12|I(o,7973,13),r=0;r<6;++r)for(let o=12;o-- >9;e>>>=1)t.v(s-o,r,1&e);for(let o=0;o<s;++o)for(let e=o;e<s;++e)t.C[e*s+o]=t.C[o*s+e];t.v(8,s-8,1)},Y=t=>{const o=t.size,e=[];for(let r=o-2,n=o,s=-1;r>=0;r-=2){for(5===r&&(r=4);n+=s,-1!==n&&n!==o;)t.I(r+1,n)||e.push([r+1,n]),t.I(r,n)||e.push([r,n]);s*=-1}return e},k=(t,o,e)=>{o.forEach((([o,r],n)=>t.v(o,r,e[n>>3]<<(7&n)&128,0)))},B=(t,o,e,r)=>{const n=t.size;for(let e=0;e<n;++e)for(let r=0;r<n;++r)o(r,e)&&!t.I(r,e)&&t.Y(r,e);const s=r<<3|e;let f=21522^(s<<10|I(s,1335,11));for(let o=8;o-- >0;f>>=1)t.v(8,(o>1?7:8)-o,1&f),t.v(n-8+o,8,1&f);for(let o=7;o-- >0;f>>=1)t.v(o>5?7:o,8,1&f),t.v(8,n-o-1,1&f)},D=(t,o,e)=>{for(let r=0;r<t.size;++r)for(let n=0,s=o,f=o;n<t.size;++n)s=e(s,t.get(n,r)),f=e(f,t.get(r,n))},b=t=>((t,o=0)=>(D(t,[0],(([t,e],r)=>r!==e?[1,r]:(4===t?o+=3:t>4&&++o,[t+1,e]))),o))(t)+3*((t,o=0)=>{for(let e=1;e<t.size;++e)for(let r=1,n=t.get(e-1,0),s=t.get(e,0)===n;r<t.size;++r){const f=t.get(e-1,r),c=t.get(e,r)===f;o+=s&&c&&n===f,n=f,s=c}return o})(t)+40*((t,o=0)=>(D(t,0,((t,e)=>{const r=(t>>>1|2098176)&(3047517^e-1);return 2049&r&&++o,r})),o))(t)+10*((t,o=0)=>(D(t,0,((t,e)=>o+=e)),20*Math.abs(o/(t.size*t.size*2)-.5)|0))(t),q=[],J=(t=n(1),{minCorrectionLevel:r=e.min,maxCorrectionLevel:s=e.max,minVersion:f=1,maxVersion:c=40,mask:a,...l}={})=>{s<r&&n(3),c<f&&n(2),"string"==typeof t&&(t=A.auto(t,l));for(let e=f,n=0;e<=c;++e){if(o[r][e-1].o<n)continue;const f=y(2956);t(f,e),n=f.S;for(let t=s;t>=r;--t){const r=o[t][e-1];if(r.o<n)continue;for(f.push(0,4),f.S=f.S+7&-8;f.S<r.o;)f.push(60433,16);let s=q[e];s||(q[e]=s=E(4*e+17),v(s,e),s.p=Y(s));const c=s.g();return k(c,s.p,Q(f.A,r)),(L[a??-1]?[L[a]]:L).map(((t,o)=>{const e=c.g();return B(e,t,a??o,r.t),e.s=b(e),e})).reduce(((t,o)=>o.s<t.s?o:t))}}n(4)};J.with=(...t)=>(o,e)=>J(o,{modes:[...h,...t],...e}),exports.correction=e,exports.generate=J,exports.mode=A; | ||
"use strict";const t=(t,o)=>o.match(/.{4}/g).map((o=>{const e=o.charCodeAt(0)-35,r=o.charCodeAt(1)-35,n=92*o.charCodeAt(2)+o.charCodeAt(3)-3255,s=n>>5;return{t:t,o:8*(r*s+e*(s+1)),l:e?[[r,s],[e,s+1]]:[[r,s]],u:31&n}})),o=[t(1,"#$)b#$.y#$6>#$?'#$Hq#%:q#%>C#%E##%Ka%%:q#'?G%%C;#'HQ$&KA$(AQ$(EC($HS$(M)'&J[(&HS''K_*%Iw('MI')L%'+H1%-J{'+Mi-&L%**Ka-(KA&0KA#4KA$4KA)0KA*/MI1)MI'4Mi5'Mi'7L%)6LE"),t(0,"#$(a#$,w#$2Y#%.A#%27#',W#'-}%%0M%&/i$'29'$4e%)/i$+0-('13((1S&*2{$-3?',29.&2Y0&1U#41u#43?1'3_1)2{0+3_'63?&92{:&2{*82{-63_@%3?:-3?813?:13?=/3_E)3_1@3?C03?*K3_B53_"),t(3,"#$'`#$*u#%)-#%+]%%(I#')s'%()%')Q''(k%))s''*{)'*9'+*7(.(k*(+a%2)s2$*{$4*{'4*Y(2+a)4*{3*+a1.+a3.+a9*+a)?*{=++AB'+aH$+A<2+a$M+aF-+a6@+a*O+a1J+a-Q+a-T+a1S+a9N+aEE+a"),t(2,"#$&@#$(s#%'i#'&?%%')#'(S$''m%'(1'''K%)(S+&'K'*(3'/')(.'K*.'K0&(U4%(36%(33,'m-2(S)6(u#E'k13(U%A(u09(U'D(u?/(UB.(U=6(U<:(U?:(UF6(UQ.(U$^(uL9(Uc%(UQ;(UCM(Uf-(U`7(U")],e={min:0,L:0,M:1,Q:2,H:3,max:3},r=t=>new Uint8Array(t),n=t=>{const o=new Error(`lean-qr error ${t}`);throw o.code=t,o},s=t=>"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:".indexOf(t),f=t=>t.charCodeAt(0),c=(...t)=>(o,e)=>t.forEach((t=>t(o,e))),a=t=>o=>{o.eci!==t&&(o.push(7,4),o.push(t,8),o.eci=t)},i=t=>(o,e)=>{o.push(4,4),o.push(t.length,8+8*(e>9)),t.forEach((t=>o.push(t,8)))},l=(t,o,e,r,n=(r?o=>c(a(r),t(o)):t))=>(n.test=o,n.est=e,n.eci=r,n),u=l((t=>(o,e)=>{o.push(1,4),o.push(t.length,10+2*(e>26)+2*(e>9));let r=0;for(;r<t.length-2;r+=3)o.push(+t.slice(r,r+3),10);r<t.length-1?o.push(+t.slice(r,r+2),7):r<t.length&&o.push(+t[r],4)}),/./.test.bind(/[0-9]/),((t,o)=>14+2*(o>26)+2*(o>9)+10*t.length/3)),$=l((t=>(o,e)=>{o.push(2,4),o.push(t.length,9+2*(e>26)+2*(e>9));let r=0;for(;r<t.length-1;r+=2)o.push(45*s(t[r])+s(t[r+1]),11);r<t.length&&o.push(s(t[r]),6)}),(t=>s(t)>=0),((t,o)=>13+2*(o>26)+2*(o>9)+5.5*t.length)),_=l((t=>i([...t].map(f))),(t=>f(t)<128),((t,o)=>12+8*(o>9)+8*t.length)),U=l(_,(t=>f(t)<256),_.est,3),m=new TextEncoder,p=l((t=>i(m.encode(t))),(()=>1),((t,o)=>12+8*(o>9)+8*m.encode(t).length),26);let d=()=>{const t=new Map,o=new TextDecoder("sjis"),e=r(2);for(const[r,n,s]of[[33088,40957,33088],[57408,60352,49472]])for(let f=r;f<n;++f)e[0]=f>>8,e[1]=255&f,t.set(o.decode(e),192*(f-s>>8)+(f-s&255));return t.delete("\ufffd"),d=()=>t,t};const K=l((t=>(o,e)=>{o.push(8,4),o.push(t.length,8+2*(e>26)+2*(e>9));for(const e of t)o.push(d().get(e),13)}),(t=>d().has(t)),((t,o)=>12+2*(o>26)+2*(o>9)+13*t.length)),M=t=>t.reduce(((t,o)=>o.$<t.$?o:t)),h=[u,$,_,U,K,p],A={auto:(t,{modes:o=h}={})=>(e,r)=>{let s=[{$:0}];for(let e=0;e<t.length;++e)s=o.filter((o=>o.test(t[e]))).map((o=>M(s.map((n=>{const s=n._===o?n.U:e,f=n._===o?n.m:n,c=t.slice(s,e+1),a=o.eci??f.K;return{_:o,m:f,U:s,h:c,$:f.$+12*(a!==f.i)+Math.ceil(o.est(c,r)),K:a}}))))),s.length||n(5);const f=[];for(let t=M(s);t._;t=t.m)f.unshift(t._(t.h));f.forEach((t=>t(e,r)))},multi:c,eci:a,numeric:u,alphaNumeric:$,bytes:i,ascii:_,iso8859_1:U,shift_jis:K,utf8:p},y=t=>({A:r(t),S:0,push(t,o){for(let e=o,r=8-(7&this.S);e>0;e-=r,r=8)this.A[this.S>>>3]|=t<<r>>>e,this.S+=e<r?e:r}}),E=(t,o=t*t,e=r(o))=>({size:t,C:e,g:()=>E(t,e),get:(o,r)=>o>=0&&o<t&&!!(1&e[r*t+o]),I:(o,r)=>2&e[r*t+o],v(o,r,n,s=1){e[r*t+o]=2*s|!!n},Y(o,r){e[r*t+o]^=1},toString({on:o="##",off:e=" ",lf:r="\n",padX:n=4,padY:s=4}={}){let f="";for(let c=-s;c<t+s;++c){for(let r=-n;r<t+n;++r)f+=this.get(r,c)?o:e;f+=r}return f},toImageData(o,{on:e=[0,0,0],off:r=[0,0,0,0],padX:n=4,padY:s=4}={}){const f=t+2*n,c=t+2*s,a=o.createImageData(f,c),i=new Uint32Array(a.data.buffer);a.data.set([...e,255]);const l=i[0];a.data.set([...r,255]);const u=i[0];for(let t=0;t<c;++t)for(let o=0;o<f;++o)i[t*f+o]=this.get(o-n,t-s)?l:u;return a},toCanvas(t,o){const e=t.getContext("2d"),r=this.toImageData(e,o);t.width=r.width,t.height=r.height,e.putImageData(r,0,0)},toDataURL({type:t="image/png",scale:o=1,...e}={}){const r=document.createElement("canvas"),n=r.getContext("2d"),s=this.toImageData(n,e);return r.width=s.width*o,r.height=s.height*o,n.putImageData(s,0,0),n.imageSmoothingEnabled=!1,n.globalCompositeOperation="copy",n.drawImage(r,0,0,s.width,s.height,0,0,r.width,r.height),r.toDataURL(t,1)}}),L=[(t,o)=>!(1&(t^o)),(t,o)=>!(1&o),t=>!(t%3),(t,o)=>!((t+o)%3),(t,o)=>!(1&((t/3|0)^o>>1)),(t,o)=>!((t&o&1)+t*o%3),(t,o)=>!((t&o&1)+t*o%3&1),(t,o)=>!((1&(t^o))+t*o%3&1)],S=r(512);S[0]=1;for(let t=0,o=1;t<255;S[++t]=o)S[o+256]=t,o*=2,256&o&&(o^=285);const w=t=>S[t%255],x=t=>S[t+256],C=(t,o)=>{const e=r(t.length+o.length-1);for(let r=0;r<t.length;++r)for(let n=0;n<o.length;++n)e[r+n]^=w(t[r]+o[n]);return e.map(x)},g=(t,o)=>{const e=r(t.length+o.length-1);e.set(t,0);for(let r=0;r<t.length;++r)if(e[r]){const t=x(e[r]);for(let n=0;n<o.length;++n)e[r+n]^=w(o[n]+t)}return e.slice(t.length)},H=[[0],[0,0]];for(let t=1,o=H[1];t<30;++t){const e=C(o,[0,t]);H.push(e),o=e}const Q=(t,o)=>{const e=[[],[]];let n=0,s=0;for(const[r,f]of o.l)for(let c=0;c<r;++c,n+=f){const r=t.slice(n,n+f);e[0].push(r),e[1].push(g(r,H[o.u])),s+=f+o.u}const f=r(s);let c=0;for(const t of e)for(let o,e=0;c!==o;++e){o=c;for(const o of t)e<o.length&&(f[c++]=o[e])}return f},I=(t,o,e)=>{let r=t<<e-1;for(let t=134217728;t;t>>>=1)r&t&&(r^=o*(t>>>e-1));return r},v=(t,o)=>{const e=(o,e,r,n,s)=>{for(;n-- >0;)for(let f=r;f-- >0;)t.v(o+f,e+n,s)},r=(t,o)=>{e(t-3,o-3,7,7,1),e(t-2,o-2,5,5,0),e(t-1,o-1,3,3,1)},n=(o,r)=>{e(o-2,r-2,5,5,1),e(o-1,r-1,3,3,0),t.v(o,r,1)},s=4*o+17;e(7,0,2,9,0),e(s-8,0,8,9,0);for(let o=0;o<s;++o)t.v(o,6,!(1&o));if(r(3,3),r(s-4,3),o>1){const t=1+(o/7|0),e=2*((s-13)/t/2+.75|0);for(let o=0;o<t;++o){const r=s-7-o*e;o&&n(r,6);for(let o=0;o<t;++o)n(r,s-7-o*e)}}if(o>6)for(let e=o<<12|I(o,7973,13),r=0;r<6;++r)for(let o=12;o-- >9;e>>>=1)t.v(s-o,r,1&e);for(let o=0;o<s;++o)for(let e=o;e<s;++e)t.C[e*s+o]=t.C[o*s+e];t.v(8,s-8,1)},Y=t=>{const o=t.size,e=[];for(let r=o-2,n=o,s=-1;r>=0;r-=2){for(5===r&&(r=4);n+=s,-1!==n&&n!==o;)t.I(r+1,n)||e.push([r+1,n]),t.I(r,n)||e.push([r,n]);s*=-1}return e},k=(t,o,e)=>{o.forEach((([o,r],n)=>t.v(o,r,e[n>>3]<<(7&n)&128,0)))},B=(t,o,e,r)=>{const n=t.size;for(let e=0;e<n;++e)for(let r=0;r<n;++r)o(r,e)&&!t.I(r,e)&&t.Y(r,e);const s=r<<3|e;let f=21522^(s<<10|I(s,1335,11));for(let o=8;o-- >0;f>>=1)t.v(8,(o>1?7:8)-o,1&f),t.v(n-8+o,8,1&f);for(let o=7;o-- >0;f>>=1)t.v(o>5?7:o,8,1&f),t.v(8,n-o-1,1&f)},D=(t,o,e)=>{for(let r=0;r<t.size;++r)for(let n=0,s=o,f=o;n<t.size;++n)s=e(s,t.get(n,r)),f=e(f,t.get(r,n))},b=t=>((t,o=0)=>(D(t,[0],(([t,e],r)=>r!==e?[1,r]:(4===t?o+=3:t>4&&++o,[t+1,e]))),o))(t)+3*((t,o=0)=>{for(let e=1;e<t.size;++e)for(let r=1,n=t.get(e-1,0),s=t.get(e,0)===n;r<t.size;++r){const f=t.get(e-1,r),c=t.get(e,r)===f;o+=s&&c&&n===f,n=f,s=c}return o})(t)+40*((t,o=0)=>(D(t,0,((t,e)=>{const r=(t>>>1|2098176)&(3047517^e-1);return 2049&r&&++o,r})),o))(t)+10*((t,o=0)=>(D(t,0,((t,e)=>o+=e)),20*Math.abs(o/(t.size*t.size*2)-.5)|0))(t),q=[],J=(t=n(1),{minCorrectionLevel:r=e.min,maxCorrectionLevel:s=e.max,minVersion:f=1,maxVersion:c=40,mask:a,trailer:i=60433,...l}={})=>{s<r&&n(3),c<f&&n(2),"string"==typeof t&&(t=A.auto(t,l));for(let e=f,n=0;e<=c;++e){if(o[r][e-1].o<n)continue;const f=y(2956);t(f,e),n=f.S;for(let t=s;t>=r;--t){const r=o[t][e-1];if(r.o<n)continue;for(f.push(0,4),f.S=f.S+7&-8;f.S<r.o;)f.push(i,16);let s=q[e];s||(q[e]=s=E(4*e+17),v(s,e),s.p=Y(s));const c=s.g();return k(c,s.p,Q(f.A,r)),(L[a??-1]?[L[a]]:L).map(((t,o)=>{const e=c.g();return B(e,t,a??o,r.t),e.s=b(e),e})).reduce(((t,o)=>o.s<t.s?o:t))}}n(4)};J.with=(...t)=>(o,e)=>J(o,{modes:[...h,...t],...e}),exports.correction=e,exports.generate=J,exports.mode=A; |
@@ -98,2 +98,3 @@ declare module 'lean-qr' { | ||
mask?: null | Mask; | ||
trailer?: number; | ||
} | ||
@@ -100,0 +101,0 @@ |
{ | ||
"name": "lean-qr", | ||
"version": "2.2.1", | ||
"version": "2.2.2", | ||
"description": "minimal QR code generation", | ||
@@ -30,4 +30,3 @@ "files": [ | ||
"start": "static-server --index index.html --port 8080", | ||
"test:unit": "lean-test -x '**/*.int.*' -x '**/*.browser.*'", | ||
"test": "lean-test --target=node,chrome,firefox -x '**/*.int.*' -x '**/*.browser.*' && lean-test -i '**/*.int.test.*' && lean-test --target=chrome,firefox --preprocess=rollup -i '**/*.browser.test.*' && ./test-package/run.sh && prettier --check ." | ||
"test": "lean-test --target=node,chrome,firefox -x '**/*.node.*' -x '**/*.browser.*' && lean-test -i '**/*.node.test.*' && lean-test --target=chrome,firefox --preprocess=rollup -i '**/*.browser.test.*' && ./test-package/run.sh && prettier --check ." | ||
}, | ||
@@ -34,0 +33,0 @@ "repository": { |
@@ -335,2 +335,17 @@ # Lean QR | ||
## Trailer | ||
ISO 18004 requires `0b11101100_00010001` (`0xEC11` / `60433`) be used as | ||
padding bytes at the end of a message, but you can customise this otherwise | ||
dead space with any 16-bit value (`0x0000` – `0xFFFF`). | ||
```javascript | ||
const code = generate(mode.alphaNumeric('LEAN-QR LIBRARY'), { | ||
trailer: 0x0000, | ||
}); | ||
``` | ||
Combining a large minimum version with a trailer of `0x0000` will reveal the | ||
pattern of the chosen `mask`. | ||
## Output | ||
@@ -597,2 +612,3 @@ | ||
mask={null} | ||
trailer={0xEC11} | ||
padX={4} | ||
@@ -599,0 +615,0 @@ padY={4} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
55330
267
739