Comparing version 2.0.0 to 2.1.0
@@ -1,1 +0,1 @@ | ||
"use strict";const t=(t,r)=>r.match(/.{4}/g).map((r=>{const e=r.charCodeAt(0)-35,o=r.charCodeAt(1)-35,n=92*r.charCodeAt(2)+r.charCodeAt(3)-3255,s=n>>5;return{i:t,c:8*(o*s+e*(s+1)),g:e?[[o,s],[e,s+1]]:[[o,s]],s:31&n}})),r=[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},o=t=>"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:".indexOf(t),n=t=>t.charCodeAt(0),s=(...t)=>(r,e)=>t.forEach((t=>t(r,e))),i=t=>r=>{r.eci!==t&&(r.push(7,4),r.push(t,8),r.eci=t)},a=t=>(r,e)=>{r.push(4,4),r.push(t.length,8+8*(e>9)),t.forEach((t=>r.push(t,8)))},f=(t,r,e,o)=>{const n=o?r=>s(i(o),t(r)):t;return n.test=r,n.est=e,n.eci=o,n},l=f((t=>(r,e)=>{r.push(1,4),r.push(t.length,10+2*(e>26)+2*(e>9));let o=0;for(;o<t.length-2;o+=3)r.push(+t.slice(o,o+3),10);o<t.length-1?r.push(+t.slice(o,o+2),7):o<t.length&&r.push(+t[o],4)}),/./.test.bind(/[0-9]/),((t,r)=>14+2*(r>26)+2*(r>9)+10*t.length/3)),c=f((t=>(r,e)=>{r.push(2,4),r.push(t.length,9+2*(e>26)+2*(e>9));let n=0;for(;n<t.length-1;n+=2)r.push(45*o(t[n])+o(t[n+1]),11);n<t.length&&r.push(o(t[n]),6)}),(t=>o(t)>=0),((t,r)=>13+2*(r>26)+2*(r>9)+5.5*t.length)),u=f((t=>a([...t].map(n))),(t=>n(t)<128),((t,r)=>12+8*(r>9)+8*t.length)),h=f(u,(t=>n(t)<256),u.est,3),$=new TextEncoder,U=f((t=>a($.encode(t))),(()=>1),((t,r)=>12+8*(r>9)+8*$.encode(t).length),26),w=t=>t.reduce(((t,r)=>r.e<t.e?r:t)),m=[l,c,u,h,U],A={auto:(t,{modes:r=m}={})=>(e,o)=>{let n=[{e:0}];for(let e=0;e<t.length;++e)if(n=r.filter((r=>r.test(t[e]))).map((r=>w(n.map((n=>{const s=n.m===r?n.s:e,i=n.m===r?n.p:n,a=t.slice(s,e+1),f=r.eci??i.i;return{m:r,p:i,s:s,v:a,e:i.e+12*(f!==i.i)+Math.ceil(r.est(a,o)),i:f}}))))),!n.length)throw new Error("Unencodable");const s=[];for(let t=w(n);t.m;t=t.p)s.unshift(t.m(t.v));s.forEach((t=>t(e,o)))},multi:s,eci:i,numeric:l,alphaNumeric:c,bytes:a,ascii:u,iso8859_1:h,utf8:U};class d{constructor(t){this.t=new Uint8Array(t),this.o=0}push(t,r){for(let e=r,o=8-(7&this.o);e>0;e-=o,o=8)this.t[this.o>>>3]|=t<<o>>>e,this.o+=e<o?e:o}}class K{constructor({size:t,d:r}){this.size=t,this.d=new Uint8Array(r||t*t)}get=(t,r)=>t>=0&&t<this.size&&!!(1&this.d[r*this.size+t]);l=(t,r)=>2&this.d[r*this.size+t];u(t,r,e,o=1){this.d[r*this.size+t]=2*o|!!e}h(t,r){this.d[r*this.size+t]^=1}toString({on:t="##",off:r=" ",lf:e="\n",padX:o=4,padY:n=4}={}){let s="";for(let i=-n;i<this.size+n;++i){for(let e=-o;e<this.size+o;++e)s+=this.get(e,i)?t:r;s+=e}return s}toImageData(t,{on:r=[0,0,0],off:e=[0,0,0,0],padX:o=4,padY:n=4}={}){const s=this.size+2*o,i=this.size+2*n,a=t.createImageData(s,i),f=new Uint32Array(a.data.buffer);a.data.set([...r,255]);const l=f[0];a.data.set([...e,255]);const c=f[0];for(let t=0;t<i;++t)for(let r=0;r<s;++r)f[t*s+r]=this.get(r-o,t-n)?l:c;return a}toCanvas(t,r){const e=t.getContext("2d"),o=this.toImageData(e,r);t.width=o.width,t.height=o.height,e.putImageData(o,0,0)}toDataURL({type:t="image/png",scale:r=1,...e}={}){const o=document.createElement("canvas"),n=o.getContext("2d"),s=this.toImageData(n,e);return o.width=s.width*r,o.height=s.height*r,n.putImageData(s,0,0),n.imageSmoothingEnabled=!1,n.globalCompositeOperation="copy",n.drawImage(o,0,0,s.width,s.height,0,0,o.width,o.height),o.toDataURL(t,1)}}const p=[(t,r)=>!(1&(t^r)),(t,r)=>!(1&r),t=>!(t%3),(t,r)=>!((t+r)%3),(t,r)=>!(1&((t/3|0)^r>>1)),(t,r)=>!((t&r&1)+t*r%3),(t,r)=>!((t&r&1)+t*r%3&1),(t,r)=>!((1&(t^r))+t*r%3&1)],M=new Uint8Array(512);M[0]=1;for(let t=0,r=1;t<255;M[++t]=r)M[r+256]=t,r*=2,256&r&&(r^=285);const E=t=>M[t%255],y=t=>M[t+256],_=(t,r)=>{const e=new Uint8Array(t.length+r.length-1);for(let o=0;o<t.length;++o)for(let n=0;n<r.length;++n)e[o+n]^=E(t[o]+r[n]);return e.map(y)},g=(t,r)=>{const e=new Uint8Array(t.length+r.length-1);e.set(t,0);for(let o=0;o<t.length;++o)if(e[o]){const t=y(e[o]);for(let n=0;n<r.length;++n)e[o+n]^=E(r[n]+t)}return e.slice(t.length)},L=[[0],[0,0]];for(let t=1,r=L[1];t<30;++t){const e=_(r,[0,t]);L.push(e),r=e}const C=(t,r)=>{const e=[[],[]];let o=0,n=0;for(const[s,i]of r.g)for(let a=0;a<s;++a,o+=i){const s=t.slice(o,o+i);e[0].push(s),e[1].push(g(s,L[r.s])),n+=i+r.s}const s=new Uint8Array(n);let i=0;for(const t of e)for(let r,e=0;i!==r;++e){r=i;for(const r of t)e<r.length&&(s[i++]=r[e])}return s},S=(t,r,e)=>{let o=t<<e-1;for(let t=134217728;t;t>>>=1)o&t&&(o^=r*(t>>>e-1));return o},H=(t,r,e,o,n,s)=>{for(let i=e;i<n;++i)for(let e=r;e<o;++e)t.u(e,i,s)},Q=(t,r,e)=>{H(t,r-3,e-3,r+4,e+4,1),H(t,r-2,e-2,r+3,e+3,0),H(t,r-1,e-1,r+2,e+2,1)},v=(t,r,e)=>{H(t,r-2,e-2,r+3,e+3,1),H(t,r-1,e-1,r+2,e+2,0),t.u(r,e,1)},x=(t,r)=>{const e=4*r+17;Q(t,3,3),Q(t,e-4,3),Q(t,3,e-4),H(t,0,7,9,9,0),H(t,7,0,9,7,0),H(t,e-8,7,e,9,0),H(t,e-8,0,e-7,7,0),H(t,7,e-8,9,e,0),H(t,0,e-8,7,e-7,0),t.u(8,e-8,1);for(let r=8;r<e-8;++r)t.u(r,6,!(1&r)),t.u(6,r,!(1&r));if(r>=2){const o=1+(r/7|0),n=2*((e-13)/o/2+.75|0),s=[6];for(let t=o;t-- >0;)s.push(e-7-t*n);for(let r=0;r<=o;++r)for(let e=0;e<=o;++e)!r&&!e||!r&&e===o||r===o&&!e||v(t,s[r],s[e])}if(r>=7)for(let o=r<<12|S(r,7973,13),n=0;n<6;++n)for(let r=12;r-- >9;o>>>=1)t.u(n,e-r,1&o),t.u(e-r,n,1&o)},I=t=>{const r=t.size,e=[];for(let o=r-2,n=r,s=-1;o>=0;o-=2){for(5===o&&(o=4);n+=s,-1!==n&&n!==r;)t.l(o+1,n)||e.push([o+1,n]),t.l(o,n)||e.push([o,n]);s*=-1}return e},B=(t,r,e)=>{r.forEach((([r,o],n)=>t.u(r,o,e[n>>3]<<(7&n)&128,0)))},Y=(t,r,e,o)=>{const n=t.size;for(let e=0;e<n;++e)for(let o=0;o<n;++o)r(o,e)&&!t.l(o,e)&&t.h(o,e);const s=o<<3|e;let i=21522^(s<<10|S(s,1335,11));for(let r=8;r-- >0;i>>=1)t.u(8,(r>1?7:8)-r,1&i),t.u(n-8+r,8,1&i);for(let r=7;r-- >0;i>>=1)t.u(r>5?7:r,8,1&i),t.u(8,n-r-1,1&i)},k=(t,r,e)=>{for(let o=0;o<t.size;++o){let n=r,s=r;for(let r=0;r<t.size;++r)n=e(n,t.get(r,o)),s=e(s,t.get(o,r))}},D=t=>(t=>{let r=0;return k(t,[0],(([t,e],o)=>o!==e?[1,o]:(4===t?r+=3:t>4&&++r,[t+1,e]))),r})(t)+3*(t=>{let r=0;for(let e=1;e<t.size;++e){let o=t.get(e-1,0),n=t.get(e,0)===o;for(let s=1;s<t.size;++s){const i=t.get(e-1,s),a=t.get(e,s)===i;r+=n&&a&&o===i,o=i,n=a}}return r})(t)+40*(t=>{let r=0;return k(t,0,((t,e)=>{const o=(t>>>1|2098176)&(3047517^e-1);return 2049&o&&++r,o})),r})(t)+(t=>{let r=0;for(let e=0;e<t.size;++e)for(let o=0;o<t.size;++o)r+=t.get(o,e);return 10*(20*Math.abs(r/(t.size*t.size)-.5)|0)})(t),J=[],T=(t,{minCorrectionLevel:o=e.min,maxCorrectionLevel:n=e.max,minVersion:s=1,maxVersion:i=40,mask:a,...f}={})=>{if(n<o)throw new Error("Bad correction range");if(i<s)throw new Error("Bad version range");"string"==typeof t&&(t=A.auto(t,f));for(let e=s,f=0;e<=i;++e){if(r[o][e-1].c<f)continue;const s=new d(2956);t(s,e),f=s.o;for(let t=n;t>=o;--t){const o=r[t][e-1];if(o.c<f)continue;for(s.push(0,4),s.o=s.o+7&-8;s.o<o.c;)s.push(60433,16);let n=J[e];n||(J[e]=n=new K({size:4*e+17}),x(n,e),n.p=I(n));const i=new K(n);return B(i,n.p,C(s.t,o)),(p[a??-1]?[p[a]]:p).map(((t,r)=>{const e=new K(i);return Y(e,t,a??r,o.i),e.s=D(e),e})).reduce(((t,r)=>r.s<t.s?r:t))}}throw new Error("Too much data")};T.with=(...t)=>(r,e)=>T(r,{modes:[...m,...t],...e}),exports.correction=e,exports.generate=T,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=>{throw new Error(t)},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,d=l((t=>i(m.encode(t))),(()=>1),((t,o)=>12+8*(o>9)+8*m.encode(t).length),26);let p=()=>{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"),p=()=>t,t};const h=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(p().get(e),13)}),(t=>p().has(t)),((t,o)=>12+2*(o>26)+2*(o>9)+13*t.length)),K=t=>t.reduce(((t,o)=>o.$<t.$?o:t)),M=[u,$,_,U,h,d],A={auto:(t,{modes:o=M}={})=>(e,r)=>{let s=[{$:0}];for(let e=0;e<t.length;++e)s=o.filter((o=>o.test(t[e]))).map((o=>K(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.h;return{_:o,m:f,U:s,K:c,$:f.$+12*(a!==f.i)+Math.ceil(o.est(c,r)),h:a}}))))),s.length||n("Unencodable");const f=[];for(let t=K(s);t._;t=t.m)f.unshift(t._(t.K));f.forEach((t=>t(e,r)))},multi:c,eci:a,numeric:u,alphaNumeric:$,bytes:i,ascii:_,iso8859_1:U,shift_jis:h,utf8:d},g=t=>({A:r(t),g:0,push(t,o){for(let e=o,r=8-(7&this.g);e>0;e-=r,r=8)this.A[this.g>>>3]|=t<<r>>>e,this.g+=e<r?e:r}}),y=(t,o=t*t,e=r(o))=>({size:t,S:e,C:()=>y(t,e),get:(o,r)=>o>=0&&o<t&&!!(1&e[r*t+o]),v:(o,r)=>2&e[r*t+o],B(o,r,n,s=1){e[r*t+o]=2*s|!!n},I(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)}}),E=[(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)],L=r(512);L[0]=1;for(let t=0,o=1;t<255;L[++t]=o)L[o+256]=t,o*=2,256&o&&(o^=285);const S=t=>L[t%255],w=t=>L[t+256],x=(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]^=S(t[r]+o[n]);return e.map(w)},C=(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=w(e[r]);for(let n=0;n<o.length;++n)e[r+n]^=S(o[n]+t)}return e.slice(t.length)},H=[[0],[0,0]];for(let t=1,o=H[1];t<30;++t){const e=x(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(C(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},v=(t,o,e)=>{let r=t<<e-1;for(let t=134217728;t;t>>>=1)r&t&&(r^=o*(t>>>e-1));return r},B=(t,o)=>{const e=(o,e,r,n,s)=>{for(;n-- >0;)for(let f=r;f-- >0;)t.B(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.B(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.B(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|v(o,7973,13),r=0;r<6;++r)for(let o=12;o-- >9;e>>>=1)t.B(s-o,r,1&e);for(let o=0;o<s;++o)for(let e=o;e<s;++e)t.S[e*s+o]=t.S[o*s+e];t.B(8,s-8,1)},I=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.v(r+1,n)||e.push([r+1,n]),t.v(r,n)||e.push([r,n]);s*=-1}return e},Y=(t,o,e)=>{o.forEach((([o,r],n)=>t.B(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.v(r,e)&&t.I(r,e);const s=r<<3|e;let f=21522^(s<<10|v(s,1335,11));for(let o=8;o-- >0;f>>=1)t.B(8,(o>1?7:8)-o,1&f),t.B(n-8+o,8,1&f);for(let o=7;o-- >0;f>>=1)t.B(o>5?7:o,8,1&f),t.B(8,n-o-1,1&f)},k=(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))},D=t=>((t,o=0)=>(k(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)=>(k(t,0,((t,e)=>{const r=(t>>>1|2098176)&(3047517^e-1);return 2049&r&&++o,r})),o))(t)+10*((t,o=0)=>(k(t,0,((t,e)=>o+=e)),20*Math.abs(o/(t.size*t.size*2)-.5)|0))(t),T=[],J=(t,{minCorrectionLevel:r=e.min,maxCorrectionLevel:s=e.max,minVersion:f=1,maxVersion:c=40,mask:a,...i}={})=>{s<r&&n("Bad correction range"),c<f&&n("Bad version range"),"string"==typeof t&&(t=A.auto(t,i));for(let e=f,n=0;e<=c;++e){if(o[r][e-1].o<n)continue;const f=g(2956);t(f,e),n=f.g;for(let t=s;t>=r;--t){const r=o[t][e-1];if(r.o<n)continue;for(f.push(0,4),f.g=f.g+7&-8;f.g<r.o;)f.push(60433,16);let s=T[e];s||(T[e]=s=y(4*e+17),B(s,e),s.p=I(s));const c=s.C();return Y(c,s.p,Q(f.A,r)),(E[a??-1]?[E[a]]:E).map(((t,o)=>{const e=c.C();return b(e,t,a??o,r.t),e.s=D(e),e})).reduce(((t,o)=>o.s<t.s?o:t))}}n("Too much data")};J.with=(...t)=>(o,e)=>J(o,{modes:[...M,...t],...e}),exports.correction=e,exports.generate=J,exports.mode=A; |
@@ -78,2 +78,3 @@ declare module 'lean-qr' { | ||
iso8859_1: ModeFactory; | ||
shift_jis: ModeFactory; | ||
utf8: ModeFactory; | ||
@@ -137,7 +138,1 @@ }; | ||
} | ||
declare module 'lean-qr/extras/jis' { | ||
import type { ModeFactory } from 'lean-qr'; | ||
export const shift_jis: ModeFactory; | ||
} |
{ | ||
"name": "lean-qr", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "minimal QR code generation", | ||
@@ -14,5 +14,3 @@ "files": [ | ||
"./extras/svg": "./build/extras/svg.js", | ||
"./extras/svg.js": "./build/extras/svg.js", | ||
"./extras/jis": "./build/extras/jis.js", | ||
"./extras/jis.js": "./build/extras/jis.js" | ||
"./extras/svg.js": "./build/extras/svg.js" | ||
}, | ||
@@ -19,0 +17,0 @@ "types": "index.d.ts", |
@@ -65,8 +65,5 @@ # Lean QR | ||
npx lean-qr 'MY MESSAGE HERE' | ||
``` | ||
The commandline tool includes all extras by default (SVG output and Shift-JIS mode): | ||
npx lean-qr '漢字' | ||
```shell | ||
npx lean-qr '漢字' | ||
npx lean-qr --format svg 'hello' | ||
@@ -94,3 +91,3 @@ ``` | ||
| `mode.iso8859_1` | 8 / 1 | ISO-8859-1 | | ||
| `shift_jis` | 13 / 1 | See notes below | | ||
| `mode.shift_jis` | 13 / 1 | See notes below | | ||
| `mode.utf8` | varies | Unicode | | ||
@@ -103,2 +100,5 @@ | ||
`shift_jis` supports all double-byte Shift-JIS characters in the ranges: | ||
[0x8140 – 0x9FFC], [0xE040 – 0xEBBF]. | ||
### `multi` | ||
@@ -167,39 +167,2 @@ | ||
### `shift_jis` | ||
This is not included in the main library to keep it small, but if you need | ||
Shift-JIS encoding, you can access it from a separate import (adds ~20kB): | ||
```javascript | ||
import { shift_jis } from 'lean-qr/extras/jis'; | ||
const code = generate(shift_jis('漢字')); | ||
``` | ||
It can also be registered to be automatically considered alongside other | ||
possible modes: | ||
```javascript | ||
const myGenerate = generate.with(shift_jis); | ||
const code = myGenerate('漢字'); | ||
``` | ||
Or for more control you can specify all modes explicitly: | ||
```javascript | ||
const code = generate(mode.auto('漢字', { | ||
modes: [ | ||
mode.numeric, | ||
mode.alphaNumeric, | ||
mode.ascii, | ||
mode.iso8859_1, | ||
shift_jis, | ||
mode.utf8, | ||
], | ||
})); | ||
``` | ||
The supported character set is all double-byte Shift-JIS characters in the | ||
ranges: [0x8140 – 0x9FFC], [0xE040 – 0xEBBF]. | ||
### Custom modes | ||
@@ -233,5 +196,31 @@ | ||
For example the implementation of `ascii`: | ||
You can then register it using `.with` to be automatically considered | ||
alongside other possible modes: | ||
```javascript | ||
const myGenerate = generate.with(myCustomMode); | ||
const code = myGenerate('text'); | ||
``` | ||
Or for more control you can specify all modes explicitly: | ||
```javascript | ||
const code = generate('text', { | ||
modes: [ | ||
myCustomMode, | ||
mode.numeric, | ||
mode.alphaNumeric, | ||
mode.ascii, | ||
mode.iso8859_1, | ||
mode.shift_jis, | ||
mode.utf8, | ||
], | ||
}); | ||
``` | ||
#### Example | ||
The implementation of `ascii`: | ||
```javascript | ||
const ascii = (value) => (data, version) => { | ||
@@ -555,4 +544,7 @@ data.push(0b0100, 4); | ||
space (some QR codes may change, but the meaning will be the same); | ||
- `shift_jis` mode (and custom modes) can now be registered more easily, | ||
using `updatedGenerator = generator.with(shift_jis)`; | ||
- `shift_jis` mode is now available by default (the `extras/jis` export | ||
has been removed); | ||
- custom modes can now be registered using | ||
`updatedGenerator = generator.with(myCustomMode)`, avoiding the need to | ||
specify all the default modes; | ||
- `toSvgSource` / `toSvgDataURL` now accept `rgb()` / `rgba()` syntax for | ||
@@ -559,0 +551,0 @@ colours, matching `toSvg`; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
35082
7
169
559