From 1f21b358b00b2848d3288608a21f1b2e9d0e7f6c Mon Sep 17 00:00:00 2001 From: nuintun Date: Sun, 17 Mar 2024 19:06:12 +0800 Subject: [PATCH] feat: Update examples --- packages/examples/src/js/workers/decode.ts | 2 -- packages/examples/static/index.html | 2 +- .../public/js/{323447b9c8826aa4.js => 7341aaa9fd0f97f7.js} | 2 +- .../public/js/{6882e97c80aacfde.js => cff1a2626b2bc43b.js} | 2 +- 4 files changed, 3 insertions(+), 5 deletions(-) rename packages/examples/static/public/js/{323447b9c8826aa4.js => 7341aaa9fd0f97f7.js} (98%) rename packages/examples/static/public/js/{6882e97c80aacfde.js => cff1a2626b2bc43b.js} (91%) diff --git a/packages/examples/src/js/workers/decode.ts b/packages/examples/src/js/workers/decode.ts index 736e0a10..f60a3a95 100644 --- a/packages/examples/src/js/workers/decode.ts +++ b/packages/examples/src/js/workers/decode.ts @@ -74,8 +74,6 @@ function decode(bytes: Uint8Array, charset: Charset): string { // 无 ECI 时默认编码为 ISO-8859-1,此时才进行编码检查。 if (charset === Charset.ISO_8859_1) { label = chardet.detect(bytes); - - console.log(label); } // 编码检查失败,使用默认编码。 diff --git a/packages/examples/static/index.html b/packages/examples/static/index.html index bc4d2d2f..a6026cb2 100644 --- a/packages/examples/static/index.html +++ b/packages/examples/static/index.html @@ -1 +1 @@ -二维码
\ No newline at end of file +二维码
\ No newline at end of file diff --git a/packages/examples/static/public/js/323447b9c8826aa4.js b/packages/examples/static/public/js/7341aaa9fd0f97f7.js similarity index 98% rename from packages/examples/static/public/js/323447b9c8826aa4.js rename to packages/examples/static/public/js/7341aaa9fd0f97f7.js index 8680f90b..fca3ad0e 100644 --- a/packages/examples/static/public/js/323447b9c8826aa4.js +++ b/packages/examples/static/public/js/7341aaa9fd0f97f7.js @@ -1 +1 @@ -!function(){"use strict";var e,t,n,r,o,u,i,f={},a={};function c(e){var t=a[e];if(void 0!==t)return t.exports;var n=a[e]={exports:{}};return f[e](n,n.exports,c),n.exports}c.m=f,e=[],c.O=function(t,n,r,o){if(n){o=o||0;for(var u=e.length;u>0&&e[u-1][2]>o;u--)e[u]=e[u-1];e[u]=[n,r,o];return}for(var i=1/0,u=0;u=o&&Object.keys(c.O).every(function(e){return c.O[e](n[a])})?n.splice(a--,1):(f=!1,o0&&e[u-1][2]>o;u--)e[u]=e[u-1];e[u]=[n,r,o];return}for(var i=1/0,u=0;u=o&&Object.keys(c.O).every(function(e){return c.O[e](n[a])})?n.splice(a--,1):(f=!1,o * @description A pure JavaScript QRCode encode and decode library. * @see https://github.com/nuintun/qrcode#readme - */function(e){let t=e.read(8);if((128&t)==0)return 127&t;if((192&t)==128)return(63&t)<<8|e.read(8);if((224&t)==192)return(31&t)<<16|e.read(16);throw Error("illegal extended channel interpretation value")}(g);break;default:if(l===eo.HANZI&&1!==g.read(4))throw Error("illegal hanzi subset");let m=g.read(l.getCharacterCountBits(t));switch(l){case eo.ALPHANUMERIC:a+=function(e,t,n){let r="";for(;t>1;){if(11>e.available())throw Error("illegal bits length");let n=e.read(11);r+=o(ef,n/45)+o(ef,n%45),t-=2}if(1===t){if(6>e.available())throw Error("illegal bits length");r+=o(ef,e.read(6))}return n?ec(r):r}(g,m,f||c);break;case eo.BYTE:a+=function(e,t,n,s,o){if(e.available()<8*t)throw Error("illegal bits length");let l=new Uint8Array(t),w=null!=o?function(e){let t=r.get(e);if(t)return t;throw Error("illegal charset value")}(o):i.ISO_8859_1;for(let n=0;n0;){let i=e.read(13),s=i/96<<8|i%96;s<2560?s+=41377:s+=42657,r[n]=s>>8&255,r[n+1]=255&s,t--,n+=2}return new TextDecoder("gb2312").decode(r)}(g,m);break;case eo.KANJI:a+=function(e,t){if(e.available()<13*t)throw Error("illegal bits length");let n=0,r=new Uint8Array(2*t);for(;t>0;){let i=e.read(13),s=i/192<<8|i%192;s<7936?s+=33088:s+=49472,r[n]=s>>8&255,r[n+1]=255&s,t--,n+=2}return new TextDecoder("shift-jis").decode(r)}(g,m);break;case eo.NUMERIC:a+=function(e,t){let n="";for(;t>=3;){if(10>e.available())throw Error("illegal bits length");let r=e.read(10);if(r>=1e3)throw Error("illegal numeric codeword");n+=o(eu,r/100)+o(eu,r/10%10)+o(eu,r%10),t-=3}if(2===t){if(7>e.available())throw Error("illegal bits length");let t=e.read(7);if(t>=100)throw Error("illegal numeric codeword");n+=o(eu,t/10)+o(eu,t%10)}else if(1===t){if(4>e.available())throw Error("illegal bits length");let t=e.read(4);if(t>=10)throw Error("illegal numeric codeword");n+=o(eu,t)}return n}(g,m);break;default:throw Error("illegal mode")}}while(l!==eo.TERMINATOR);return f?h=Object.freeze(["GS1"]):c&&(h=Object.freeze(["AIM",u])),s=null!=w?f?4:c?6:2:f?3:c?5:1,{content:a,codewords:e,structured:d,symbology:`]Q${s}`,fnc1:h}}(n,t,this.#em),t,s,l,w)}}var eS,eO=n(6275),ek=n.n(eO);function e_(e){return{x:e.x,y:e.y}}function eM(e){return{x:e.x,y:e.y,moduleSize:e.moduleSize}}function eT(e,t){let n=null;t===i.ISO_8859_1&&console.log(n=ek().detect(e)),null==n&&(n=t.label);try{return new TextDecoder(n).decode(e)}catch(t){return new TextDecoder("utf-8").decode(e)}}self.addEventListener("message",async e=>{let{data:t}=e,{uid:n,image:r}=t,{width:i,height:s}=r,o=new OffscreenCanvas(i,s).getContext("2d");o.drawImage(r,0,0);let l=function(e,t,n){if(e.length!==t*n)throw Error("luminances length must be equals to width * height");return t<40||n<40?function(e,t,n){let r=new a(t,n),i=new Int32Array(32);for(let r=1;r<5;r++){let s=0|4*t/5,o=(0|n*r/5)*t;for(let n=0|t/5;n>3]++}}let s=function(e){let t=0,n=0,r=0,{length:i}=e;for(let s=0;sn&&(t=s,n=e[s]),e[s]>r&&(r=e[s]);let s=0,o=0;for(let n=0;no&&(s=n,o=i)}if(t>s&&([t,s]=[s,t]),s-t<=2)return -1;let l=-1,w=s-1;for(let n=s-1;n>t;n--){let i=n-t,o=i*i*(s-n)*(r-e[n]);o>l&&(w=n,l=o)}return w<<3}(i);if(s>0)for(let i=0;iw&&(w=n)}if(w-a>24)for(n++,r+=t;n<8;n++,r+=t)for(let t=0;t<8;t++)o+=e[r+t]}let f=o>>6;if(w-a<=24&&(f=a/2,n>0&&s>0)){let e=(r[n-1][s]+2*r[n][s-1]+r[n-1][s-1])/4;a>10}}return i}(o.getImageData(0,0,i,s)),i,s);t.invert&&l.flip();let w=new en({strict:t.strict}).detect(l),h=[],d=new eE({decode:eT}),g=w.next();for(;!g.done;){let e=!1,t=g.value;try{let{size:n,finder:r,alignment:i}=t,s=d.decode(t.matrix),{topLeft:o,topRight:l,bottomLeft:w}=r,a=t.mapping(0,0),u=t.mapping(n,0),f=t.mapping(n,n),c=t.mapping(0,n),g=t.mapping(6.5,6.5),m=t.mapping(n-6.5,6.5),b=t.mapping(6.5,n-6.5);h.push({fnc1:s.fnc1,mask:s.mask,level:s.level,mirror:s.mirror,content:s.content,version:s.version,corrected:s.corrected,symbology:s.symbology,structured:s.structured,alignment:i?eM(i):null,finder:[eM(o),eM(l),eM(w)],timing:[e_(g),e_(m),e_(b)],corners:[e_(a),e_(u),e_(f),e_(c)]}),e=!0}catch{}g=w.next(e)}h.length>0?self.postMessage({type:"ok",payload:{uid:n,image:r,items:h}},[r]):self.postMessage({type:"error",message:"未发现二维码"})})}},o={};function l(e){var t=o[e];if(void 0!==t)return t.exports;var n=o[e]={exports:{}};return s[e].call(n.exports,n,n.exports,l),n.exports}l.m=s,l.x=function(){var e=l.O(void 0,[275],function(){return l(7399)});return l.O(e)},e=[],l.O=function(t,n,r,i){if(n){i=i||0;for(var s=e.length;s>0&&e[s-1][2]>i;s--)e[s]=e[s-1];e[s]=[n,r,i];return}for(var o=1/0,s=0;s=i&&Object.keys(l.O).every(function(e){return l.O[e](n[a])})?n.splice(a--,1):(w=!1,i1;){if(11>e.available())throw Error("illegal bits length");let n=e.read(11);r+=o(ef,n/45)+o(ef,n%45),t-=2}if(1===t){if(6>e.available())throw Error("illegal bits length");r+=o(ef,e.read(6))}return n?ec(r):r}(g,m,f||c);break;case eo.BYTE:a+=function(e,t,n,s,o){if(e.available()<8*t)throw Error("illegal bits length");let l=new Uint8Array(t),w=null!=o?function(e){let t=r.get(e);if(t)return t;throw Error("illegal charset value")}(o):i.ISO_8859_1;for(let n=0;n0;){let i=e.read(13),s=i/96<<8|i%96;s<2560?s+=41377:s+=42657,r[n]=s>>8&255,r[n+1]=255&s,t--,n+=2}return new TextDecoder("gb2312").decode(r)}(g,m);break;case eo.KANJI:a+=function(e,t){if(e.available()<13*t)throw Error("illegal bits length");let n=0,r=new Uint8Array(2*t);for(;t>0;){let i=e.read(13),s=i/192<<8|i%192;s<7936?s+=33088:s+=49472,r[n]=s>>8&255,r[n+1]=255&s,t--,n+=2}return new TextDecoder("shift-jis").decode(r)}(g,m);break;case eo.NUMERIC:a+=function(e,t){let n="";for(;t>=3;){if(10>e.available())throw Error("illegal bits length");let r=e.read(10);if(r>=1e3)throw Error("illegal numeric codeword");n+=o(eu,r/100)+o(eu,r/10%10)+o(eu,r%10),t-=3}if(2===t){if(7>e.available())throw Error("illegal bits length");let t=e.read(7);if(t>=100)throw Error("illegal numeric codeword");n+=o(eu,t/10)+o(eu,t%10)}else if(1===t){if(4>e.available())throw Error("illegal bits length");let t=e.read(4);if(t>=10)throw Error("illegal numeric codeword");n+=o(eu,t)}return n}(g,m);break;default:throw Error("illegal mode")}}while(l!==eo.TERMINATOR);return f?h=Object.freeze(["GS1"]):c&&(h=Object.freeze(["AIM",u])),s=null!=w?f?4:c?6:2:f?3:c?5:1,{content:a,codewords:e,structured:d,symbology:`]Q${s}`,fnc1:h}}(n,t,this.#em),t,s,l,w)}}var eS,eO=n(6275),ek=n.n(eO);function e_(e){return{x:e.x,y:e.y}}function eM(e){return{x:e.x,y:e.y,moduleSize:e.moduleSize}}function eT(e,t){let n=null;t===i.ISO_8859_1&&(n=ek().detect(e)),null==n&&(n=t.label);try{return new TextDecoder(n).decode(e)}catch(t){return new TextDecoder("utf-8").decode(e)}}self.addEventListener("message",async e=>{let{data:t}=e,{uid:n,image:r}=t,{width:i,height:s}=r,o=new OffscreenCanvas(i,s).getContext("2d");o.drawImage(r,0,0);let l=function(e,t,n){if(e.length!==t*n)throw Error("luminances length must be equals to width * height");return t<40||n<40?function(e,t,n){let r=new a(t,n),i=new Int32Array(32);for(let r=1;r<5;r++){let s=0|4*t/5,o=(0|n*r/5)*t;for(let n=0|t/5;n>3]++}}let s=function(e){let t=0,n=0,r=0,{length:i}=e;for(let s=0;sn&&(t=s,n=e[s]),e[s]>r&&(r=e[s]);let s=0,o=0;for(let n=0;no&&(s=n,o=i)}if(t>s&&([t,s]=[s,t]),s-t<=2)return -1;let l=-1,w=s-1;for(let n=s-1;n>t;n--){let i=n-t,o=i*i*(s-n)*(r-e[n]);o>l&&(w=n,l=o)}return w<<3}(i);if(s>0)for(let i=0;iw&&(w=n)}if(w-a>24)for(n++,r+=t;n<8;n++,r+=t)for(let t=0;t<8;t++)o+=e[r+t]}let f=o>>6;if(w-a<=24&&(f=a/2,n>0&&s>0)){let e=(r[n-1][s]+2*r[n][s-1]+r[n-1][s-1])/4;a>10}}return i}(o.getImageData(0,0,i,s)),i,s);t.invert&&l.flip();let w=new en({strict:t.strict}).detect(l),h=[],d=new eE({decode:eT}),g=w.next();for(;!g.done;){let e=!1,t=g.value;try{let{size:n,finder:r,alignment:i}=t,s=d.decode(t.matrix),{topLeft:o,topRight:l,bottomLeft:w}=r,a=t.mapping(0,0),u=t.mapping(n,0),f=t.mapping(n,n),c=t.mapping(0,n),g=t.mapping(6.5,6.5),m=t.mapping(n-6.5,6.5),b=t.mapping(6.5,n-6.5);h.push({fnc1:s.fnc1,mask:s.mask,level:s.level,mirror:s.mirror,content:s.content,version:s.version,corrected:s.corrected,symbology:s.symbology,structured:s.structured,alignment:i?eM(i):null,finder:[eM(o),eM(l),eM(w)],timing:[e_(g),e_(m),e_(b)],corners:[e_(a),e_(u),e_(f),e_(c)]}),e=!0}catch{}g=w.next(e)}h.length>0?self.postMessage({type:"ok",payload:{uid:n,image:r,items:h}},[r]):self.postMessage({type:"error",message:"未发现二维码"})})}},o={};function l(e){var t=o[e];if(void 0!==t)return t.exports;var n=o[e]={exports:{}};return s[e].call(n.exports,n,n.exports,l),n.exports}l.m=s,l.x=function(){var e=l.O(void 0,[275],function(){return l(7399)});return l.O(e)},e=[],l.O=function(t,n,r,i){if(n){i=i||0;for(var s=e.length;s>0&&e[s-1][2]>i;s--)e[s]=e[s-1];e[s]=[n,r,i];return}for(var o=1/0,s=0;s=i&&Object.keys(l.O).every(function(e){return l.O[e](n[a])})?n.splice(a--,1):(w=!1,i