vue3-image-compressor 1.0.8 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -2
- package/dist/assets/imageWorker-B_HCdCy9.js +24 -0
- package/dist/vue-image-compressor.js +98 -100
- package/dist/vue-image-compressor.umd.cjs +1 -1
- package/package.json +1 -1
- package/src/composables/useWorker.ts +1 -2
- package/src/utils/compressFile.ts +1 -2
- package/src/workers/imageWorker.ts +1 -1
- package/dist/assets/imageWorker-Qv3pCULy.js +0 -1042
package/README.md
CHANGED
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
## 🚀 在线 Demo
|
|
6
6
|
|
|
7
|
-
[
|
|
7
|
+
**👉 [点击在线体验 Demo](https://think_chl.github.io/vue-compressor/)**
|
|
8
|
+
|
|
9
|
+
直接上传图片即可试用,无需安装。也可以使用下面的徽章快速访问:
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
[](https://think_chl.github.io/vue-compressor/)
|
|
10
12
|
|
|
11
13
|
## 架构分析
|
|
12
14
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
(function(){"use strict";function Nr(c,l){return c({noInitialRun:!0,locateFile:l==null?void 0:l.locateFile})}var Jr=function(){var c=self.location.href;return function(i){i=i||{};var i=typeof i<"u"?i:{},v,_;i.ready=new Promise(function(r,e){v=r,_=e});var p={},m;for(m in i)i.hasOwnProperty(m)&&(p[m]=i[m]);var or="./this.program",W=function(r,e){throw e},Qr=!0,P="";function Xr(r){return i.locateFile?i.locateFile(r,P):P+r}var ar;P=self.location.href,c&&(P=c),P.indexOf("blob:")!==0?P=P.substr(0,P.lastIndexOf("/")+1):P="",ar=function(r){var e=new XMLHttpRequest;return e.open("GET",r,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)};var Yr=i.print||console.log.bind(console),O=i.printErr||console.warn.bind(console);for(m in p)p.hasOwnProperty(m)&&(i[m]=p[m]);p=null,i.arguments&&i.arguments,i.thisProgram&&(or=i.thisProgram),i.quit&&(W=i.quit);var q;i.wasmBinary&&(q=i.wasmBinary),i.noExitRuntime,typeof WebAssembly!="object"&&Q("no native wasm support detected");var J,yr=!1,mr=new TextDecoder("utf8");function $r(r,e,n){for(var t=e+n,a=e;r[a]&&!(a>=t);)++a;return mr.decode(r.subarray?r.subarray(e,a):new Uint8Array(r.slice(e,a)))}function wr(r,e){if(!r)return"";for(var n=r+e,t=r;!(t>=n)&&y[t];)++t;return mr.decode(y.subarray(r,t))}function Kr(r,e,n,t){if(!(t>0))return 0;for(var a=n,u=n+t-1,f=0;f<r.length;++f){var o=r.charCodeAt(f);if(o>=55296&&o<=57343){var s=r.charCodeAt(++f);o=65536+((o&1023)<<10)|s&1023}if(o<=127){if(n>=u)break;e[n++]=o}else if(o<=2047){if(n+1>=u)break;e[n++]=192|o>>6,e[n++]=128|o&63}else if(o<=65535){if(n+2>=u)break;e[n++]=224|o>>12,e[n++]=128|o>>6&63,e[n++]=128|o&63}else{if(n+3>=u)break;e[n++]=240|o>>18,e[n++]=128|o>>12&63,e[n++]=128|o>>6&63,e[n++]=128|o&63}}return e[n]=0,n-a}function Zr(r,e,n){return Kr(r,y,e,n)}function re(r){for(var e=0,n=0;n<r.length;++n){var t=r.charCodeAt(n);t>=55296&&t<=57343&&(t=65536+((t&1023)<<10)|r.charCodeAt(++n)&1023),t<=127?++e:t<=2047?e+=2:t<=65535?e+=3:e+=4}return e}var ee=new TextDecoder("utf-16le");function ne(r,e){for(var n=r,t=n>>1,a=t+e/2;!(t>=a)&&G[t];)++t;return n=t<<1,ee.decode(y.subarray(r,n))}function te(r,e,n){if(n===void 0&&(n=2147483647),n<2)return 0;n-=2;for(var t=e,a=n<r.length*2?n/2:r.length,u=0;u<a;++u){var f=r.charCodeAt(u);V[e>>1]=f,e+=2}return V[e>>1]=0,e-t}function ie(r){return r.length*2}function oe(r,e){for(var n=0,t="";!(n>=e/4);){var a=w[r+n*4>>2];if(a==0)break;if(++n,a>=65536){var u=a-65536;t+=String.fromCharCode(55296|u>>10,56320|u&1023)}else t+=String.fromCharCode(a)}return t}function ae(r,e,n){if(n===void 0&&(n=2147483647),n<4)return 0;for(var t=e,a=t+n-4,u=0;u<r.length;++u){var f=r.charCodeAt(u);if(f>=55296&&f<=57343){var o=r.charCodeAt(++u);f=65536+((f&1023)<<10)|o&1023}if(w[e>>2]=f,e+=4,e+4>a)break}return w[e>>2]=0,e-t}function ue(r){for(var e=0,n=0;n<r.length;++n){var t=r.charCodeAt(n);t>=55296&&t<=57343&&++n,e+=4}return e}function fe(r,e,n){for(var t=0;t<r.length;++t)L[e++>>0]=r.charCodeAt(t);L[e>>0]=0}function ce(r,e){return r%e>0&&(r+=e-r%e),r}var ur,L,y,V,G,w,F,br,Ar;function Tr(r){ur=r,i.HEAP8=L=new Int8Array(r),i.HEAP16=V=new Int16Array(r),i.HEAP32=w=new Int32Array(r),i.HEAPU8=y=new Uint8Array(r),i.HEAPU16=G=new Uint16Array(r),i.HEAPU32=F=new Uint32Array(r),i.HEAPF32=br=new Float32Array(r),i.HEAPF64=Ar=new Float64Array(r)}i.INITIAL_MEMORY;var x,Er=[],Cr=[],Pr=[];function se(){if(i.preRun)for(typeof i.preRun=="function"&&(i.preRun=[i.preRun]);i.preRun.length;)ge(i.preRun.shift());fr(Er)}function le(){fr(Cr)}function de(){if(i.postRun)for(typeof i.postRun=="function"&&(i.postRun=[i.postRun]);i.postRun.length;)he(i.postRun.shift());fr(Pr)}function ge(r){Er.unshift(r)}function ve(r){Cr.unshift(r)}function he(r){Pr.unshift(r)}var M=0,z=null;function pe(r){M++,i.monitorRunDependencies&&i.monitorRunDependencies(M)}function _e(r){if(M--,i.monitorRunDependencies&&i.monitorRunDependencies(M),M==0&&z){var e=z;z=null,e()}}i.preloadedImages={},i.preloadedAudios={};function Q(r){i.onAbort&&i.onAbort(r),r+="",O(r),yr=!0,r="abort("+r+"). Build with -s ASSERTIONS=1 for more info.";var e=new WebAssembly.RuntimeError(r);throw _(e),e}var ye="data:application/octet-stream;base64,";function Fr(r){return r.startsWith(ye)}if(i.locateFile){var E="mozjpeg_enc.wasm";Fr(E)||(E=Xr(E))}else var E=new URL(""+new URL("../codecs/mozjpeg/enc/mozjpeg_enc.wasm",self.location.href).href,self.location.href).toString();function Rr(r){try{if(r==E&&q)return new Uint8Array(q);if(ar)return ar(r);throw"both async and sync fetching of the wasm failed"}catch(e){Q(e)}}function me(){return!q&&Qr&&typeof fetch=="function"?fetch(E,{credentials:"same-origin"}).then(function(r){if(!r.ok)throw"failed to load wasm binary file at '"+E+"'";return r.arrayBuffer()}).catch(function(){return Rr(E)}):Promise.resolve().then(function(){return Rr(E)})}function we(){var r={a:wn};function e(f,o){var s=f.exports;i.asm=s,J=i.asm.C,Tr(J.buffer),x=i.asm.I,ve(i.asm.D),_e()}pe();function n(f){e(f.instance)}function t(f){return me().then(function(o){var s=WebAssembly.instantiate(o,r);return s}).then(f,function(o){O("failed to asynchronously prepare wasm: "+o),Q(o)})}function a(){return!q&&typeof WebAssembly.instantiateStreaming=="function"&&!Fr(E)&&typeof fetch=="function"?fetch(E,{credentials:"same-origin"}).then(function(f){var o=WebAssembly.instantiateStreaming(f,r);return o.then(n,function(s){return O("wasm streaming compile failed: "+s),O("falling back to ArrayBuffer instantiation"),t(n)})}):t(n)}if(i.instantiateWasm)try{var u=i.instantiateWasm(r,e);return u}catch(f){return O("Module.instantiateWasm callback failed with error: "+f),!1}return a().catch(_),{}}function fr(r){for(;r.length>0;){var e=r.shift();if(typeof e=="function"){e(i);continue}var n=e.func;typeof n=="number"?e.arg===void 0?x.get(n)():x.get(n)(e.arg):n(e.arg===void 0?null:e.arg)}}function En(r,e){}function be(r,e){return void 0}var X={};function Ur(r){for(;r.length;){var e=r.pop(),n=r.pop();n(e)}}function Y(r){return this.fromWireType(F[r>>2])}var j={},k={},$={},Ae=48,Te=57;function Sr(r){if(r===void 0)return"_unknown";r=r.replace(/[^a-zA-Z0-9_]/g,"$");var e=r.charCodeAt(0);return e>=Ae&&e<=Te?"_"+r:r}function Wr(r,e){return r=Sr(r),new Function("body","return function "+r+`() {
|
|
2
|
+
"use strict"; return body.apply(this, arguments);
|
|
3
|
+
};
|
|
4
|
+
`)(e)}function cr(r,e){var n=Wr(e,function(t){this.name=e,this.message=t;var a=new Error(t).stack;a!==void 0&&(this.stack=this.toString()+`
|
|
5
|
+
`+a.replace(/^Error(:[^\n]*)?\n/,""))});return n.prototype=Object.create(r.prototype),n.prototype.constructor=n,n.prototype.toString=function(){return this.message===void 0?this.name:this.name+": "+this.message},n}var Mr=void 0;function kr(r){throw new Mr(r)}function Dr(r,e,n){r.forEach(function(o){$[o]=e});function t(o){var s=n(o);s.length!==r.length&&kr("Mismatched type converter count");for(var d=0;d<r.length;++d)R(r[d],s[d])}var a=new Array(e.length),u=[],f=0;e.forEach(function(o,s){k.hasOwnProperty(o)?a[s]=k[o]:(u.push(o),j.hasOwnProperty(o)||(j[o]=[]),j[o].push(function(){a[s]=k[o],++f,f===u.length&&t(a)}))}),u.length===0&&t(a)}function Ee(r){var e=X[r];delete X[r];var n=e.rawConstructor,t=e.rawDestructor,a=e.fields,u=a.map(function(f){return f.getterReturnType}).concat(a.map(function(f){return f.setterArgumentType}));Dr([r],u,function(f){var o={};return a.forEach(function(s,d){var g=s.fieldName,h=f[d],D=s.getter,C=s.getterContext,S=f[d+a.length],I=s.setter,H=s.setterContext;o[g]={read:function(hr){return h.fromWireType(D(C,hr))},write:function(hr,Tn){var Br=[];I(H,hr,S.toWireType(Br,Tn)),Ur(Br)}}}),[{name:e.name,fromWireType:function(s){var d={};for(var g in o)d[g]=o[g].read(s);return t(s),d},toWireType:function(s,d){for(var g in o)if(!(g in d))throw new TypeError('Missing field: "'+g+'"');var h=n();for(g in o)o[g].write(h,d[g]);return s!==null&&s.push(t,h),h},argPackAdvance:8,readValueFromPointer:Y,destructorFunction:t}]})}function Ce(r,e,n,t,a){}function sr(r){switch(r){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+r)}}function Pe(){for(var r=new Array(256),e=0;e<256;++e)r[e]=String.fromCharCode(e);Ir=r}var Ir=void 0;function b(r){for(var e="",n=r;y[n];)e+=Ir[y[n++]];return e}var Or=void 0;function A(r){throw new Or(r)}function R(r,e,n){if(n=n||{},!("argPackAdvance"in e))throw new TypeError("registerType registeredInstance requires argPackAdvance");var t=e.name;if(r||A('type "'+t+'" must have a positive integer typeid pointer'),k.hasOwnProperty(r)){if(n.ignoreDuplicateRegistrations)return;A("Cannot register type '"+t+"' twice")}if(k[r]=e,delete $[r],j.hasOwnProperty(r)){var a=j[r];delete j[r],a.forEach(function(u){u()})}}function Fe(r,e,n,t,a){var u=sr(n);e=b(e),R(r,{name:e,fromWireType:function(f){return!!f},toWireType:function(f,o){return o?t:a},argPackAdvance:8,readValueFromPointer:function(f){var o;if(n===1)o=L;else if(n===2)o=V;else if(n===4)o=w;else throw new TypeError("Unknown boolean type size: "+e);return this.fromWireType(o[f>>u])},destructorFunction:null})}var lr=[],T=[{},{value:void 0},{value:null},{value:!0},{value:!1}];function jr(r){r>4&&--T[r].refcount===0&&(T[r]=void 0,lr.push(r))}function Re(){for(var r=0,e=5;e<T.length;++e)T[e]!==void 0&&++r;return r}function Ue(){for(var r=5;r<T.length;++r)if(T[r]!==void 0)return T[r];return null}function Se(){i.count_emval_handles=Re,i.get_first_emval=Ue}function K(r){switch(r){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:{var e=lr.length?lr.pop():T.length;return T[e]={refcount:1,value:r},e}}}function We(r,e){e=b(e),R(r,{name:e,fromWireType:function(n){var t=T[n].value;return jr(n),t},toWireType:function(n,t){return K(t)},argPackAdvance:8,readValueFromPointer:Y,destructorFunction:null})}function dr(r){if(r===null)return"null";var e=typeof r;return e==="object"||e==="array"||e==="function"?r.toString():""+r}function Me(r,e){switch(e){case 2:return function(n){return this.fromWireType(br[n>>2])};case 3:return function(n){return this.fromWireType(Ar[n>>3])};default:throw new TypeError("Unknown float type: "+r)}}function ke(r,e,n){var t=sr(n);e=b(e),R(r,{name:e,fromWireType:function(a){return a},toWireType:function(a,u){if(typeof u!="number"&&typeof u!="boolean")throw new TypeError('Cannot convert "'+dr(u)+'" to '+this.name);return u},argPackAdvance:8,readValueFromPointer:Me(e,t),destructorFunction:null})}function De(r,e){if(!(r instanceof Function))throw new TypeError("new_ called with constructor type "+typeof r+" which is not a function");var n=Wr(r.name||"unknownFunctionName",function(){});n.prototype=r.prototype;var t=new n,a=r.apply(t,e);return a instanceof Object?a:t}function Ie(r,e,n,t,a){var u=e.length;u<2&&A("argTypes array size mismatch! Must at least get return value and 'this' types!"),e[1];for(var f=!1,o=1;o<e.length;++o)if(e[o]!==null&&e[o].destructorFunction===void 0){f=!0;break}for(var s=e[0].name!=="void",d="",g="",o=0;o<u-2;++o)d+=(o!==0?", ":"")+"arg"+o,g+=(o!==0?", ":"")+"arg"+o+"Wired";var h="return function "+Sr(r)+"("+d+`) {
|
|
6
|
+
if (arguments.length !== `+(u-2)+`) {
|
|
7
|
+
throwBindingError('function `+r+" called with ' + arguments.length + ' arguments, expected "+(u-2)+` args!');
|
|
8
|
+
}
|
|
9
|
+
`;f&&(h+=`var destructors = [];
|
|
10
|
+
`);for(var D=f?"destructors":"null",C=["throwBindingError","invoker","fn","runDestructors","retType","classParam"],S=[A,t,a,Ur,e[0],e[1]],o=0;o<u-2;++o)h+="var arg"+o+"Wired = argType"+o+".toWireType("+D+", arg"+o+"); // "+e[o+2].name+`
|
|
11
|
+
`,C.push("argType"+o),S.push(e[o+2]);if(h+=(s?"var rv = ":"")+"invoker(fn"+(g.length>0?", ":"")+g+`);
|
|
12
|
+
`,f)h+=`runDestructors(destructors);
|
|
13
|
+
`;else for(var o=2;o<e.length;++o){var I=o===1?"thisWired":"arg"+(o-2)+"Wired";e[o].destructorFunction!==null&&(h+=I+"_dtor("+I+"); // "+e[o].name+`
|
|
14
|
+
`,C.push(I+"_dtor"),S.push(e[o].destructorFunction))}s&&(h+=`var ret = retType.fromWireType(rv);
|
|
15
|
+
return ret;
|
|
16
|
+
`),h+=`}
|
|
17
|
+
`,C.push(h);var H=De(Function,C).apply(null,S);return H}function Oe(r,e,n){if(r[e].overloadTable===void 0){var t=r[e];r[e]=function(){return r[e].overloadTable.hasOwnProperty(arguments.length)||A("Function '"+n+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+r[e].overloadTable+")!"),r[e].overloadTable[arguments.length].apply(this,arguments)},r[e].overloadTable=[],r[e].overloadTable[t.argCount]=t}}function je(r,e,n){i.hasOwnProperty(r)?((n===void 0||i[r].overloadTable!==void 0&&i[r].overloadTable[n]!==void 0)&&A("Cannot register public name '"+r+"' twice"),Oe(i,r,r),i.hasOwnProperty(n)&&A("Cannot register multiple overloads of a function with the same number of arguments ("+n+")!"),i[r].overloadTable[n]=e):(i[r]=e,n!==void 0&&(i[r].numArguments=n))}function He(r,e){for(var n=[],t=0;t<r;t++)n.push(w[(e>>2)+t]);return n}function qe(r,e,n){i.hasOwnProperty(r)||kr("Replacing nonexistant public symbol"),i[r].overloadTable!==void 0&&n!==void 0?i[r].overloadTable[n]=e:(i[r]=e,i[r].argCount=n)}function Le(r,e,n){var t=i["dynCall_"+r];return n&&n.length?t.apply(null,[e].concat(n)):t.call(null,e)}function Ve(r,e,n){return r.includes("j")?Le(r,e,n):x.get(e).apply(null,n)}function xe(r,e){var n=[];return function(){n.length=arguments.length;for(var t=0;t<arguments.length;t++)n[t]=arguments[t];return Ve(r,e,n)}}function B(r,e){r=b(r);function n(){return r.includes("j")?xe(r,e):x.get(e)}var t=n();return typeof t!="function"&&A("unknown function pointer with signature "+r+": "+e),t}var Hr=void 0;function qr(r){var e=zr(r),n=b(e);return U(e),n}function ze(r,e){var n=[],t={};function a(u){if(!t[u]&&!k[u]){if($[u]){$[u].forEach(a);return}n.push(u),t[u]=!0}}throw e.forEach(a),new Hr(r+": "+n.map(qr).join([", "]))}function Be(r,e,n,t,a,u){var f=He(e,n);r=b(r),a=B(t,a),je(r,function(){ze("Cannot call "+r+" due to unbound types",f)},e-1),Dr([],f,function(o){var s=[o[0],null].concat(o.slice(1));return qe(r,Ie(r,s,null,a,u),e-1),[]})}function Ne(r,e,n){switch(e){case 0:return n?function(a){return L[a]}:function(a){return y[a]};case 1:return n?function(a){return V[a>>1]}:function(a){return G[a>>1]};case 2:return n?function(a){return w[a>>2]}:function(a){return F[a>>2]};default:throw new TypeError("Unknown integer type: "+r)}}function Je(r,e,n,t,a){e=b(e),a===-1&&(a=4294967295);var u=sr(n),f=function(d){return d};if(t===0){var o=32-8*n;f=function(d){return d<<o>>>o}}var s=e.includes("unsigned");R(r,{name:e,fromWireType:f,toWireType:function(d,g){if(typeof g!="number"&&typeof g!="boolean")throw new TypeError('Cannot convert "'+dr(g)+'" to '+this.name);if(g<t||g>a)throw new TypeError('Passing a number "'+dr(g)+'" from JS side to C/C++ side to an argument of type "'+e+'", which is outside the valid range ['+t+", "+a+"]!");return s?g>>>0:g|0},argPackAdvance:8,readValueFromPointer:Ne(e,u,t!==0),destructorFunction:null})}function Ge(r,e,n){var t=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],a=t[e];function u(f){f=f>>2;var o=F,s=o[f],d=o[f+1];return new a(ur,d,s)}n=b(n),R(r,{name:n,fromWireType:u,argPackAdvance:8,readValueFromPointer:u},{ignoreDuplicateRegistrations:!0})}function Qe(r,e){e=b(e);var n=e==="std::string";R(r,{name:e,fromWireType:function(t){var a=F[t>>2],u;if(n)for(var f=t+4,o=0;o<=a;++o){var s=t+4+o;if(o==a||y[s]==0){var d=s-f,g=wr(f,d);u===void 0?u=g:(u+="\0",u+=g),f=s+1}}else{for(var h=new Array(a),o=0;o<a;++o)h[o]=String.fromCharCode(y[t+4+o]);u=h.join("")}return U(t),u},toWireType:function(t,a){a instanceof ArrayBuffer&&(a=new Uint8Array(a));var u,f=typeof a=="string";f||a instanceof Uint8Array||a instanceof Uint8ClampedArray||a instanceof Int8Array||A("Cannot pass non-string to std::string"),n&&f?u=function(){return re(a)}:u=function(){return a.length};var o=u(),s=gr(4+o+1);if(F[s>>2]=o,n&&f)Zr(a,s+4,o+1);else if(f)for(var d=0;d<o;++d){var g=a.charCodeAt(d);g>255&&(U(s),A("String has UTF-16 code units that do not fit in 8 bits")),y[s+4+d]=g}else for(var d=0;d<o;++d)y[s+4+d]=a[d];return t!==null&&t.push(U,s),s},argPackAdvance:8,readValueFromPointer:Y,destructorFunction:function(t){U(t)}})}function Xe(r,e,n){n=b(n);var t,a,u,f,o;e===2?(t=ne,a=te,f=ie,u=function(){return G},o=1):e===4&&(t=oe,a=ae,f=ue,u=function(){return F},o=2),R(r,{name:n,fromWireType:function(s){for(var d=F[s>>2],g=u(),h,D=s+4,C=0;C<=d;++C){var S=s+4+C*e;if(C==d||g[S>>o]==0){var I=S-D,H=t(D,I);h===void 0?h=H:(h+="\0",h+=H),D=S+e}}return U(s),h},toWireType:function(s,d){typeof d!="string"&&A("Cannot pass non-string to C++ string type "+n);var g=f(d),h=gr(4+g+e);return F[h>>2]=g>>o,a(d,h+4,g+e),s!==null&&s.push(U,h),h},argPackAdvance:8,readValueFromPointer:Y,destructorFunction:function(s){U(s)}})}function Ye(r,e,n,t,a,u){X[r]={name:b(e),rawConstructor:B(n,t),rawDestructor:B(a,u),fields:[]}}function $e(r,e,n,t,a,u,f,o,s,d){X[r].fields.push({fieldName:b(e),getterReturnType:n,getter:B(t,a),getterContext:u,setterArgumentType:f,setter:B(o,s),setterContext:d})}function Ke(r,e){e=b(e),R(r,{isVoid:!0,name:e,argPackAdvance:0,fromWireType:function(){},toWireType:function(n,t){}})}var Ze={};function rn(r){var e=Ze[r];return e===void 0?b(r):e}function Lr(){return typeof globalThis=="object"?globalThis:function(){return Function}()("return this")()}function en(r){return r===0?K(Lr()):(r=rn(r),K(Lr()[r]))}function nn(r){r>4&&(T[r].refcount+=1)}function tn(r,e){var n=k[r];return n===void 0&&A(e+" has unknown type "+qr(r)),n}function on(r){for(var e="",n=0;n<r;++n)e+=(n!==0?", ":"")+"arg"+n;for(var t="return function emval_allocator_"+r+`(constructor, argTypes, args) {
|
|
18
|
+
`,n=0;n<r;++n)t+="var argType"+n+" = requireRegisteredType(Module['HEAP32'][(argTypes >>> 2) + "+n+'], "parameter '+n+`");
|
|
19
|
+
var arg`+n+" = argType"+n+`.readValueFromPointer(args);
|
|
20
|
+
args += argType`+n+`['argPackAdvance'];
|
|
21
|
+
`;return t+="var obj = new constructor("+e+`);
|
|
22
|
+
return __emval_register(obj);
|
|
23
|
+
}
|
|
24
|
+
`,new Function("requireRegisteredType","Module","__emval_register",t)(tn,i,K)}var Vr={};function an(r){return r||A("Cannot use deleted val. handle = "+r),T[r].value}function un(r,e,n,t){r=an(r);var a=Vr[e];return a||(a=on(e),Vr[e]=a),a(r,n,t)}function fn(){Q()}function cn(r,e,n){y.copyWithin(r,e,e+n)}function sn(r){try{return J.grow(r-ur.byteLength+65535>>>16),Tr(J.buffer),1}catch{}}function ln(r){var e=y.length;r=r>>>0;var n=2147483648;if(r>n)return!1;for(var t=1;t<=4;t*=2){var a=e*(1+.2/t);a=Math.min(a,r+100663296);var u=Math.min(n,ce(Math.max(r,a),65536)),f=sn(u);if(f)return!0}return!1}var xr={};function dn(){return or||"./this.program"}function N(){if(!N.strings){var r=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:r,_:dn()};for(var n in xr)e[n]=xr[n];var t=[];for(var n in e)t.push(n+"="+e[n]);N.strings=t}return N.strings}var Z={mappings:{},buffers:[null,[],[]],printChar:function(r,e){var n=Z.buffers[r];e===0||e===10?((r===1?Yr:O)($r(n,0)),n.length=0):n.push(e)},varargs:void 0,get:function(){Z.varargs+=4;var r=w[Z.varargs-4>>2];return r},getStr:function(r){var e=wr(r);return e},get64:function(r,e){return r}};function gn(r,e){var n=0;return N().forEach(function(t,a){var u=e+n;w[r+a*4>>2]=u,fe(t,u),n+=t.length+1}),0}function vn(r,e){var n=N();w[r>>2]=n.length;var t=0;return n.forEach(function(a){t+=a.length+1}),w[e>>2]=t,0}function hn(r){An(r)}function pn(r){return 0}function _n(r,e,n,t,a){}function yn(r,e,n,t){for(var a=0,u=0;u<n;u++){for(var f=w[e+u*8>>2],o=w[e+(u*8+4)>>2],s=0;s<o;s++)Z.printChar(r,y[f+s]);a+=o}return w[t>>2]=a,0}function mn(r){}Mr=i.InternalError=cr(Error,"InternalError"),Pe(),Or=i.BindingError=cr(Error,"BindingError"),Se(),Hr=i.UnboundTypeError=cr(Error,"UnboundTypeError");var wn={B:be,l:Ee,p:Ce,y:Fe,x:We,i:ke,f:Be,c:Je,b:Ge,j:Qe,e:Xe,m:Ye,a:$e,z:Ke,g:jr,u:en,k:nn,n:un,h:fn,r:cn,d:ln,s:gn,t:vn,A:hn,w:pn,o:_n,v:yn,q:mn};we(),i.___wasm_call_ctors=function(){return(i.___wasm_call_ctors=i.asm.D).apply(null,arguments)};var gr=i._malloc=function(){return(gr=i._malloc=i.asm.E).apply(null,arguments)},U=i._free=function(){return(U=i._free=i.asm.F).apply(null,arguments)},zr=i.___getTypeName=function(){return(zr=i.___getTypeName=i.asm.G).apply(null,arguments)};i.___embind_register_native_and_builtin_types=function(){return(i.___embind_register_native_and_builtin_types=i.asm.H).apply(null,arguments)},i.dynCall_jiji=function(){return(i.dynCall_jiji=i.asm.J).apply(null,arguments)};var rr;function bn(r){this.name="ExitStatus",this.message="Program terminated with exit("+r+")",this.status=r}z=function r(){rr||vr(),rr||(z=r)};function vr(r){if(M>0||(se(),M>0))return;function e(){rr||(rr=!0,i.calledRun=!0,!yr&&(le(),v(i),i.onRuntimeInitialized&&i.onRuntimeInitialized(),de()))}i.setStatus?(i.setStatus("Running..."),setTimeout(function(){setTimeout(function(){i.setStatus("")},1),e()},1)):e()}i.run=vr;function An(r,e){W(r,new bn(r))}if(i.preInit)for(typeof i.preInit=="function"&&(i.preInit=[i.preInit]);i.preInit.length>0;)i.preInit.pop()();return vr(),i.ready}}();const er=self,nr=new Map;async function Gr(c,l){return nr.has(c)||nr.set(c,await l()),nr.get(c)}async function tr(c,l,i){const v=new OffscreenCanvas(c.width,c.height);return v.getContext("2d").putImageData(c,0,0),v.convertToBlob({type:l,quality:i})}async function ir(c){return new Uint8Array(await c.arrayBuffer())}function pr(c){return createImageBitmap(c).then(l=>{const v=new OffscreenCanvas(l.width,l.height).getContext("2d");return v.drawImage(l,0,0),v.getImageData(0,0,l.width,l.height)})}const _r={async avifDecode(c){return pr(c)},async jxlDecode(c){throw new Error("JXL decode 需要 WASM 解码器,尚未实现")},async qoiDecode(c){throw new Error("QOI decode 需要 WASM 解码器,尚未实现")},async webpDecode(c){return pr(c)},async wp2Decode(c){throw new Error("WebP2 decode 需要 WASM 解码器,尚未实现")},async avifEncode(c,l){const i=await tr(c,"image/avif");return ir(i)},async jxlEncode(c,l){throw new Error("JXL encode 需要 WASM 编码器,尚未实现")},async mozjpegEncode(c,l){return(await Gr("mozjpeg_enc",async()=>Nr(Jr,{locateFile:v=>v==="mozjpeg_enc.wasm"?"../codecs/mozjpeg/enc/mozjpeg_enc.wasm":v}))).encode(c.data,c.width,c.height,{quality:l.quality??75,baseline:l.baseline??!1,arithmetic:l.arithmetic??!1,progressive:l.progressive??!0,optimize_coding:l.optimize_coding??!0,smoothing:l.smoothing??0,color_space:l.color_space??3,quant_table:l.quant_table??3,trellis_multipass:l.trellis_multipass??!1,trellis_opt_zero:l.trellis_opt_zero??!1,trellis_opt_table:l.trellis_opt_table??!1,trellis_loops:l.trellis_loops??1,auto_subsample:l.auto_subsample??!0,chroma_subsample:l.chroma_subsample??2,separate_chroma_quality:l.separate_chroma_quality??!1,chroma_quality:l.chroma_quality??75})},async oxipngEncode(c,l){const i=await tr(c,"image/png");return ir(i)},async qoiEncode(c,l){throw new Error("QOI encode 需要 WASM 编码器,尚未实现")},async webpEncode(c,l){const i=l.quality!=null?l.quality/100:.75,v=await tr(c,"image/webp",i);return ir(v)},async wp2Encode(c,l){throw new Error("WebP2 encode 需要 WASM 编码器,尚未实现")},async rotate(c,l){const i=(l.rotate||0)%360*(Math.PI/180);if(i===0)return c;const v=Math.abs(Math.sin(i)),_=Math.abs(Math.cos(i)),p=Math.round(c.width*_+c.height*v),m=Math.round(c.width*v+c.height*_),W=new OffscreenCanvas(p,m).getContext("2d");return W.translate(p/2,m/2),W.rotate(i),W.drawImage(await createImageBitmap(new ImageData(c.data,c.width,c.height)),-c.width/2,-c.height/2),W.getImageData(0,0,p,m)},async quantize(c,l){const i=l.numColors||256,v=Math.floor(256/Math.max(1,Math.min(i,256))),_=new Uint8ClampedArray(c.data);for(let p=0;p<_.length;p+=4)_[p]=Math.floor(_[p]/v)*v,_[p+1]=Math.floor(_[p+1]/v)*v,_[p+2]=Math.floor(_[p+2]/v)*v;return new ImageData(_,c.width,c.height)},async resize(c,l){const i=l.width||c.width,v=l.height||c.height;if(i===c.width&&v===c.height)return c;const p=new OffscreenCanvas(i,v).getContext("2d");p.imageSmoothingEnabled=!0,p.imageSmoothingQuality="high";const m=await createImageBitmap(new ImageData(c.data,c.width,c.height));return p.drawImage(m,0,0,i,v),p.getImageData(0,0,i,v)}};er.addEventListener("message",async c=>{const{id:l,method:i,args:v}=c.data;console.log("[Worker] received message:",i,v);try{const _=_r[i];if(!_)throw new Error(`Unknown method: ${i}`);const p=await _.apply(_r,v);console.log("[Worker] completed:",i,p),er.postMessage({id:l,result:p,error:null})}catch(_){console.error("[Worker] error:",i,_),er.postMessage({id:l,result:null,error:_ instanceof Error?_.message:String(_)})}})})();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ref as y, onUnmounted as Y, computed as
|
|
2
|
-
const
|
|
1
|
+
import { ref as y, onUnmounted as Y, computed as G, defineComponent as Z, openBlock as z, createElementBlock as k, createElementVNode as E, withModifiers as J, renderSlot as S, toDisplayString as D, unref as v, createCommentVNode as C, withDirectives as ee, isRef as te, Fragment as oe, renderList as re, vModelSelect as ne, createTextVNode as se } from "vue";
|
|
2
|
+
const j = {
|
|
3
3
|
mozJPEG: {
|
|
4
4
|
label: "MozJPEG",
|
|
5
5
|
mimeType: "image/jpeg",
|
|
@@ -124,14 +124,14 @@ const G = {
|
|
|
124
124
|
wp2: {
|
|
125
125
|
quality: 75
|
|
126
126
|
}
|
|
127
|
-
}, ae = Object.keys(
|
|
128
|
-
async function
|
|
127
|
+
}, ae = Object.keys(j);
|
|
128
|
+
async function H(r) {
|
|
129
129
|
const o = await createImageBitmap(r), n = document.createElement("canvas");
|
|
130
130
|
n.width = o.width, n.height = o.height;
|
|
131
131
|
const t = n.getContext("2d");
|
|
132
132
|
return t.drawImage(o, 0, 0), t.getImageData(0, 0, n.width, n.height);
|
|
133
133
|
}
|
|
134
|
-
async function
|
|
134
|
+
async function A(r, o, n) {
|
|
135
135
|
const t = document.createElement("canvas");
|
|
136
136
|
return t.width = r.width, t.height = r.height, t.getContext("2d").putImageData(r, 0, 0), new Promise((s) => {
|
|
137
137
|
t.toBlob(
|
|
@@ -159,7 +159,7 @@ function le(r) {
|
|
|
159
159
|
n.onload = () => o(!0), n.onerror = () => o(!1), n.src = `data:${r};base64,`;
|
|
160
160
|
});
|
|
161
161
|
}
|
|
162
|
-
function
|
|
162
|
+
function Q(r, o, n) {
|
|
163
163
|
return new File([r], o, { type: n });
|
|
164
164
|
}
|
|
165
165
|
function $(r, o = 2) {
|
|
@@ -230,10 +230,9 @@ function pe() {
|
|
|
230
230
|
o.value = !0, t = new Worker(
|
|
231
231
|
new URL(
|
|
232
232
|
/* @vite-ignore */
|
|
233
|
-
"
|
|
233
|
+
"" + new URL("assets/imageWorker-B_HCdCy9.js", import.meta.url).href,
|
|
234
234
|
import.meta.url
|
|
235
|
-
)
|
|
236
|
-
{ type: "module" }
|
|
235
|
+
)
|
|
237
236
|
), r.value = !0, n.value = null;
|
|
238
237
|
} catch (b) {
|
|
239
238
|
n.value = b instanceof Error ? b : new Error("Failed to start worker"), console.error("Worker start failed:", b);
|
|
@@ -257,11 +256,11 @@ function pe() {
|
|
|
257
256
|
async function h(b, O) {
|
|
258
257
|
if (b.aborted)
|
|
259
258
|
throw new DOMException("AbortError", "AbortError");
|
|
260
|
-
return clearTimeout(e), new Promise((
|
|
259
|
+
return clearTimeout(e), new Promise((I, P) => {
|
|
261
260
|
const T = () => {
|
|
262
261
|
a(), P(new DOMException("AbortError", "AbortError"));
|
|
263
262
|
};
|
|
264
|
-
b.addEventListener("abort", T), O().then(
|
|
263
|
+
b.addEventListener("abort", T), O().then(I).catch(P).finally(() => {
|
|
265
264
|
b.removeEventListener("abort", T), p();
|
|
266
265
|
});
|
|
267
266
|
});
|
|
@@ -279,7 +278,7 @@ function pe() {
|
|
|
279
278
|
};
|
|
280
279
|
}
|
|
281
280
|
function me() {
|
|
282
|
-
const r = y(!1), o = y(0), n = y(null), t = y(null), e = y(null), { getWorkerApi: s, executeTask: a } = pe(), p =
|
|
281
|
+
const r = y(!1), o = y(0), n = y(null), t = y(null), e = y(null), { getWorkerApi: s, executeTask: a } = pe(), p = G(() => r.value && !!e.value);
|
|
283
282
|
async function u(f, i) {
|
|
284
283
|
const l = await ie(i), d = await le(l), w = await s();
|
|
285
284
|
if (!d) {
|
|
@@ -294,7 +293,7 @@ function me() {
|
|
|
294
293
|
if (l === "image/qoi")
|
|
295
294
|
return a(f, () => w.qoiDecode(i));
|
|
296
295
|
}
|
|
297
|
-
return
|
|
296
|
+
return H(i);
|
|
298
297
|
}
|
|
299
298
|
async function h(f, i, l) {
|
|
300
299
|
if (l === 0) return i;
|
|
@@ -305,7 +304,7 @@ function me() {
|
|
|
305
304
|
);
|
|
306
305
|
}
|
|
307
306
|
async function b(f, i, l) {
|
|
308
|
-
var g,
|
|
307
|
+
var g, _;
|
|
309
308
|
let d = i;
|
|
310
309
|
const w = await s();
|
|
311
310
|
return (g = l.resize) != null && g.enabled && (d = await a(
|
|
@@ -318,7 +317,7 @@ function me() {
|
|
|
318
317
|
premultiply: !0,
|
|
319
318
|
linearRGB: !0
|
|
320
319
|
})
|
|
321
|
-
)), (
|
|
320
|
+
)), (_ = l.quantize) != null && _.enabled && (d = await a(
|
|
322
321
|
f,
|
|
323
322
|
() => w.quantize(d, {
|
|
324
323
|
numColors: l.quantize.numColors || 256,
|
|
@@ -329,16 +328,16 @@ function me() {
|
|
|
329
328
|
async function O(f, i, l) {
|
|
330
329
|
const d = await s(), w = l.encoder;
|
|
331
330
|
if (w === "browserJPEG")
|
|
332
|
-
return (await
|
|
331
|
+
return (await A(
|
|
333
332
|
i,
|
|
334
333
|
"image/jpeg",
|
|
335
334
|
l.encoderOptions.quality
|
|
336
335
|
)).arrayBuffer();
|
|
337
336
|
if (w === "browserPNG")
|
|
338
|
-
return (await
|
|
337
|
+
return (await A(i, "image/png")).arrayBuffer();
|
|
339
338
|
if (w === "browserGIF")
|
|
340
339
|
throw new Error("Browser GIF encoding not supported directly");
|
|
341
|
-
const
|
|
340
|
+
const _ = {
|
|
342
341
|
mozJPEG: d.mozjpegEncode,
|
|
343
342
|
webP: d.webpEncode,
|
|
344
343
|
avif: d.avifEncode,
|
|
@@ -347,14 +346,14 @@ function me() {
|
|
|
347
346
|
qoi: d.qoiEncode,
|
|
348
347
|
wp2: d.wp2Encode
|
|
349
348
|
}[w];
|
|
350
|
-
if (!
|
|
349
|
+
if (!_)
|
|
351
350
|
throw new Error(`Unknown encoder: ${w}`);
|
|
352
351
|
return (await a(
|
|
353
352
|
f,
|
|
354
|
-
() =>
|
|
353
|
+
() => _.call(d, i, l.encoderOptions)
|
|
355
354
|
)).buffer;
|
|
356
355
|
}
|
|
357
|
-
async function
|
|
356
|
+
async function I(f, i) {
|
|
358
357
|
var w;
|
|
359
358
|
e.value = new AbortController();
|
|
360
359
|
const l = e.value.signal;
|
|
@@ -369,30 +368,30 @@ function me() {
|
|
|
369
368
|
width: 0,
|
|
370
369
|
height: 0,
|
|
371
370
|
blobUrl: V(f)
|
|
372
|
-
},
|
|
373
|
-
g.width =
|
|
371
|
+
}, _ = await u(l, f);
|
|
372
|
+
g.width = _.width, g.height = _.height, o.value = 25;
|
|
374
373
|
const U = await h(
|
|
375
374
|
l,
|
|
376
|
-
|
|
375
|
+
_,
|
|
377
376
|
i.rotate || 0
|
|
378
377
|
);
|
|
379
378
|
o.value = 35;
|
|
380
|
-
const
|
|
379
|
+
const R = await b(l, U, i);
|
|
381
380
|
o.value = 50;
|
|
382
|
-
const F = await O(l,
|
|
381
|
+
const F = await O(l, R, i);
|
|
383
382
|
o.value = 80;
|
|
384
|
-
const
|
|
383
|
+
const q = j[i.encoder], B = X(
|
|
385
384
|
f.name,
|
|
386
|
-
(
|
|
387
|
-
), L =
|
|
385
|
+
(q == null ? void 0 : q.extension) || "bin"
|
|
386
|
+
), L = Q(
|
|
388
387
|
F,
|
|
389
|
-
|
|
390
|
-
(
|
|
388
|
+
B,
|
|
389
|
+
(q == null ? void 0 : q.mimeType) || "application/octet-stream"
|
|
391
390
|
), M = {
|
|
392
391
|
file: L,
|
|
393
392
|
size: L.size,
|
|
394
|
-
width:
|
|
395
|
-
height:
|
|
393
|
+
width: R.width,
|
|
394
|
+
height: R.height,
|
|
396
395
|
blobUrl: V(L)
|
|
397
396
|
}, m = {
|
|
398
397
|
original: g,
|
|
@@ -406,8 +405,8 @@ function me() {
|
|
|
406
405
|
} catch (g) {
|
|
407
406
|
if (g instanceof DOMException && g.name === "AbortError")
|
|
408
407
|
throw n.value = "已取消", g;
|
|
409
|
-
const
|
|
410
|
-
throw n.value =
|
|
408
|
+
const _ = g instanceof Error ? g.message : "压缩失败";
|
|
409
|
+
throw n.value = _, console.error("Compression error:", g), g;
|
|
411
410
|
} finally {
|
|
412
411
|
r.value = !1, e.value = null;
|
|
413
412
|
}
|
|
@@ -421,7 +420,7 @@ function me() {
|
|
|
421
420
|
i.href = f.blobUrl, i.download = f.file.name, document.body.appendChild(i), i.click(), document.body.removeChild(i);
|
|
422
421
|
}
|
|
423
422
|
return {
|
|
424
|
-
compress:
|
|
423
|
+
compress: I,
|
|
425
424
|
cancel: P,
|
|
426
425
|
downloadResult: T,
|
|
427
426
|
isCompressing: r,
|
|
@@ -432,14 +431,14 @@ function me() {
|
|
|
432
431
|
};
|
|
433
432
|
}
|
|
434
433
|
function fe() {
|
|
435
|
-
const r = y("mozJPEG"), o = y({}), n =
|
|
434
|
+
const r = y("mozJPEG"), o = y({}), n = G(() => j[r.value]), t = G(
|
|
436
435
|
() => N[r.value]
|
|
437
|
-
), e =
|
|
436
|
+
), e = G(
|
|
438
437
|
() => ae.map((u) => ({
|
|
439
438
|
type: u,
|
|
440
|
-
label:
|
|
441
|
-
mimeType:
|
|
442
|
-
extension:
|
|
439
|
+
label: j[u].label,
|
|
440
|
+
mimeType: j[u].mimeType,
|
|
441
|
+
extension: j[u].extension
|
|
443
442
|
}))
|
|
444
443
|
);
|
|
445
444
|
function s(u) {
|
|
@@ -471,7 +470,7 @@ const ve = { class: "image-compressor" }, we = {
|
|
|
471
470
|
}, ge = { class: "preview-item" }, be = ["src"], Ee = { class: "preview-item" }, he = ["src"], ye = {
|
|
472
471
|
key: 1,
|
|
473
472
|
class: "compressing"
|
|
474
|
-
},
|
|
473
|
+
}, _e = ["value"], xe = { key: 2 }, ze = {
|
|
475
474
|
key: 1,
|
|
476
475
|
class: "encoder-settings"
|
|
477
476
|
}, ke = ["value"], Oe = {
|
|
@@ -480,10 +479,10 @@ const ve = { class: "image-compressor" }, we = {
|
|
|
480
479
|
}, Pe = ["value"], Te = {
|
|
481
480
|
key: 2,
|
|
482
481
|
class: "actions"
|
|
483
|
-
}, De = ["disabled"],
|
|
482
|
+
}, De = ["disabled"], Ce = {
|
|
484
483
|
key: 3,
|
|
485
484
|
class: "error"
|
|
486
|
-
},
|
|
485
|
+
}, Ie = /* @__PURE__ */ Z({
|
|
487
486
|
__name: "ImageCompressor",
|
|
488
487
|
props: {
|
|
489
488
|
defaultEncoder: {},
|
|
@@ -496,7 +495,7 @@ const ve = { class: "image-compressor" }, we = {
|
|
|
496
495
|
cancel: h,
|
|
497
496
|
downloadResult: b,
|
|
498
497
|
isCompressing: O,
|
|
499
|
-
progress:
|
|
498
|
+
progress: I,
|
|
500
499
|
error: P,
|
|
501
500
|
result: T,
|
|
502
501
|
canCancel: f
|
|
@@ -508,22 +507,22 @@ const ve = { class: "image-compressor" }, we = {
|
|
|
508
507
|
updateOption: g
|
|
509
508
|
} = fe();
|
|
510
509
|
n.defaultEncoder && w(n.defaultEncoder), n.defaultOptions && Object.entries(n.defaultOptions).forEach(([m, c]) => g(m, c));
|
|
511
|
-
const
|
|
510
|
+
const _ = G(
|
|
512
511
|
() => s.value ? $(s.value.size) : ""
|
|
513
|
-
), U =
|
|
512
|
+
), U = G(
|
|
514
513
|
() => T.value ? $(T.value.compressed.size) : ""
|
|
515
|
-
),
|
|
514
|
+
), R = G(
|
|
516
515
|
() => ["mozJPEG", "webP", "jxl", "browserJPEG", "wp2"].includes(i.value)
|
|
517
516
|
);
|
|
518
517
|
function F(m) {
|
|
519
518
|
const c = m.target;
|
|
520
|
-
c.files && c.files[0] &&
|
|
519
|
+
c.files && c.files[0] && B(c.files[0]);
|
|
521
520
|
}
|
|
522
|
-
function
|
|
521
|
+
function q(m) {
|
|
523
522
|
var c;
|
|
524
|
-
(c = m.dataTransfer) != null && c.files[0] &&
|
|
523
|
+
(c = m.dataTransfer) != null && c.files[0] && B(m.dataTransfer.files[0]);
|
|
525
524
|
}
|
|
526
|
-
function
|
|
525
|
+
function B(m) {
|
|
527
526
|
m.type.startsWith("image/") && (a.value && URL.revokeObjectURL(a.value), p.value && (URL.revokeObjectURL(p.value), p.value = ""), s.value = m, a.value = URL.createObjectURL(m));
|
|
528
527
|
}
|
|
529
528
|
function L() {
|
|
@@ -548,7 +547,7 @@ const ve = { class: "image-compressor" }, we = {
|
|
|
548
547
|
return (m, c) => (z(), k("div", ve, [
|
|
549
548
|
E("div", {
|
|
550
549
|
class: "upload-zone",
|
|
551
|
-
onDrop: J(
|
|
550
|
+
onDrop: J(q, ["prevent"]),
|
|
552
551
|
onDragover: c[1] || (c[1] = J(() => {
|
|
553
552
|
}, ["prevent"]))
|
|
554
553
|
}, [
|
|
@@ -562,7 +561,7 @@ const ve = { class: "image-compressor" }, we = {
|
|
|
562
561
|
}, null, 544),
|
|
563
562
|
E("div", {
|
|
564
563
|
class: "upload-prompt",
|
|
565
|
-
onClick: c[0] || (c[0] = (
|
|
564
|
+
onClick: c[0] || (c[0] = (x) => {
|
|
566
565
|
var W;
|
|
567
566
|
return (W = e.value) == null ? void 0 : W.click();
|
|
568
567
|
})
|
|
@@ -579,7 +578,7 @@ const ve = { class: "image-compressor" }, we = {
|
|
|
579
578
|
src: a.value,
|
|
580
579
|
alt: "Original"
|
|
581
580
|
}, null, 8, be),
|
|
582
|
-
E("p", null, D(
|
|
581
|
+
E("p", null, D(_.value), 1)
|
|
583
582
|
]),
|
|
584
583
|
E("div", Ee, [
|
|
585
584
|
c[8] || (c[8] = E("h4", null, "压缩后", -1)),
|
|
@@ -589,28 +588,28 @@ const ve = { class: "image-compressor" }, we = {
|
|
|
589
588
|
alt: "Compressed"
|
|
590
589
|
}, null, 8, he)) : v(O) ? (z(), k("div", ye, [
|
|
591
590
|
E("progress", {
|
|
592
|
-
value: v(
|
|
591
|
+
value: v(I),
|
|
593
592
|
max: "100"
|
|
594
|
-
}, null, 8,
|
|
595
|
-
E("p", null, "压缩中... " + D(v(
|
|
596
|
-
])) :
|
|
597
|
-
U.value ? (z(), k("p",
|
|
593
|
+
}, null, 8, _e),
|
|
594
|
+
E("p", null, "压缩中... " + D(v(I)) + "%", 1)
|
|
595
|
+
])) : C("", !0),
|
|
596
|
+
U.value ? (z(), k("p", xe, D(U.value), 1)) : C("", !0)
|
|
598
597
|
])
|
|
599
|
-
])) :
|
|
598
|
+
])) : C("", !0),
|
|
600
599
|
a.value ? (z(), k("div", ze, [
|
|
601
600
|
c[9] || (c[9] = E("label", null, "编码器:", -1)),
|
|
602
601
|
ee(E("select", {
|
|
603
|
-
"onUpdate:modelValue": c[2] || (c[2] = (
|
|
602
|
+
"onUpdate:modelValue": c[2] || (c[2] = (x) => te(i) ? i.value = x : null),
|
|
604
603
|
onChange: L
|
|
605
604
|
}, [
|
|
606
|
-
(z(!0), k(oe, null, re(v(d), (
|
|
607
|
-
key:
|
|
608
|
-
value:
|
|
609
|
-
}, D(
|
|
605
|
+
(z(!0), k(oe, null, re(v(d), (x) => (z(), k("option", {
|
|
606
|
+
key: x.type,
|
|
607
|
+
value: x.type
|
|
608
|
+
}, D(x.label) + " (" + D(x.extension) + ") ", 9, ke))), 128))
|
|
610
609
|
], 544), [
|
|
611
610
|
[ne, v(i)]
|
|
612
611
|
]),
|
|
613
|
-
|
|
612
|
+
R.value ? (z(), k("div", Oe, [
|
|
614
613
|
E("label", null, [
|
|
615
614
|
se(" 质量: " + D(v(l).quality ?? 75) + " ", 1),
|
|
616
615
|
E("input", {
|
|
@@ -618,15 +617,15 @@ const ve = { class: "image-compressor" }, we = {
|
|
|
618
617
|
min: "0",
|
|
619
618
|
max: "100",
|
|
620
619
|
value: v(l).quality ?? 75,
|
|
621
|
-
onInput: c[3] || (c[3] = (
|
|
620
|
+
onInput: c[3] || (c[3] = (x) => v(g)("quality", Number(x.target.value)))
|
|
622
621
|
}, null, 40, Pe)
|
|
623
622
|
])
|
|
624
|
-
])) :
|
|
623
|
+
])) : C("", !0),
|
|
625
624
|
S(m.$slots, "encoder-settings", {
|
|
626
625
|
encoder: v(i),
|
|
627
626
|
options: v(l)
|
|
628
627
|
}, void 0, !0)
|
|
629
|
-
])) :
|
|
628
|
+
])) : C("", !0),
|
|
630
629
|
a.value ? (z(), k("div", Te, [
|
|
631
630
|
E("button", {
|
|
632
631
|
onClick: M,
|
|
@@ -636,31 +635,31 @@ const ve = { class: "image-compressor" }, we = {
|
|
|
636
635
|
v(f) ? (z(), k("button", {
|
|
637
636
|
key: 0,
|
|
638
637
|
onClick: c[4] || (c[4] = //@ts-ignore
|
|
639
|
-
(...
|
|
638
|
+
(...x) => v(h) && v(h)(...x)),
|
|
640
639
|
class: "btn-secondary"
|
|
641
|
-
}, " 取消 ")) :
|
|
640
|
+
}, " 取消 ")) : C("", !0),
|
|
642
641
|
v(T) ? (z(), k("button", {
|
|
643
642
|
key: 1,
|
|
644
643
|
onClick: c[5] || (c[5] = //@ts-ignore
|
|
645
|
-
(...
|
|
644
|
+
(...x) => v(b) && v(b)(...x)),
|
|
646
645
|
class: "btn-success"
|
|
647
|
-
}, " 下载 (节省 " + D(v(T).savingsPercent) + "%) ", 1)) :
|
|
648
|
-
])) :
|
|
649
|
-
v(P) ? (z(), k("div",
|
|
646
|
+
}, " 下载 (节省 " + D(v(T).savingsPercent) + "%) ", 1)) : C("", !0)
|
|
647
|
+
])) : C("", !0),
|
|
648
|
+
v(P) ? (z(), k("div", Ce, D(v(P)), 1)) : C("", !0)
|
|
650
649
|
]));
|
|
651
650
|
}
|
|
652
|
-
}),
|
|
651
|
+
}), qe = (r, o) => {
|
|
653
652
|
const n = r.__vccOpts || r;
|
|
654
653
|
for (const [t, e] of o)
|
|
655
654
|
n[t] = e;
|
|
656
655
|
return n;
|
|
657
|
-
}, Me = /* @__PURE__ */
|
|
656
|
+
}, Me = /* @__PURE__ */ qe(Ie, [["__scopeId", "data-v-d7e6eec9"]]), Be = [
|
|
658
657
|
{ value: "lanczos3", label: "Lanczos3" },
|
|
659
658
|
{ value: "catrom", label: "Catrom" },
|
|
660
659
|
{ value: "mitchell", label: "Mitchell" },
|
|
661
660
|
{ value: "triangle", label: "Triangle" },
|
|
662
661
|
{ value: "vector", label: "Vector" }
|
|
663
|
-
],
|
|
662
|
+
], Ae = [
|
|
664
663
|
{ value: "stretch", label: "拉伸" },
|
|
665
664
|
{ value: "contain", label: "适应" }
|
|
666
665
|
], Fe = [
|
|
@@ -668,7 +667,7 @@ const ve = { class: "image-compressor" }, we = {
|
|
|
668
667
|
{ value: 90, label: "顺时针 90°" },
|
|
669
668
|
{ value: 180, label: "旋转 180°" },
|
|
670
669
|
{ value: 270, label: "逆时针 90°" }
|
|
671
|
-
],
|
|
670
|
+
], Re = {
|
|
672
671
|
mozJPEG: "mozjpegEncode",
|
|
673
672
|
webP: "webpEncode",
|
|
674
673
|
avif: "avifEncode",
|
|
@@ -677,26 +676,25 @@ const ve = { class: "image-compressor" }, we = {
|
|
|
677
676
|
qoi: "qoiEncode",
|
|
678
677
|
wp2: "wp2Encode"
|
|
679
678
|
};
|
|
680
|
-
function
|
|
679
|
+
function je() {
|
|
681
680
|
return new Worker(
|
|
682
681
|
new URL(
|
|
683
682
|
/* @vite-ignore */
|
|
684
|
-
"
|
|
683
|
+
"" + new URL("assets/imageWorker-B_HCdCy9.js", import.meta.url).href,
|
|
685
684
|
import.meta.url
|
|
686
|
-
)
|
|
687
|
-
{ type: "module" }
|
|
685
|
+
)
|
|
688
686
|
);
|
|
689
687
|
}
|
|
690
|
-
function
|
|
688
|
+
function Ge(r, o, n, t) {
|
|
691
689
|
return new Promise((e, s) => {
|
|
692
|
-
const a =
|
|
690
|
+
const a = je();
|
|
693
691
|
let p = !1;
|
|
694
692
|
function u() {
|
|
695
693
|
p || (p = !0, a.terminate());
|
|
696
694
|
}
|
|
697
695
|
a.addEventListener("message", (O) => {
|
|
698
|
-
const { result:
|
|
699
|
-
u(), P ? s(new Error(P)) : e(
|
|
696
|
+
const { result: I, error: P } = O.data;
|
|
697
|
+
u(), P ? s(new Error(P)) : e(I.buffer);
|
|
700
698
|
}), a.addEventListener("error", (O) => {
|
|
701
699
|
u(), s(O.error || O);
|
|
702
700
|
});
|
|
@@ -704,7 +702,7 @@ function Re(r, o, n, t) {
|
|
|
704
702
|
u(), s(new DOMException("AbortError", "AbortError"));
|
|
705
703
|
};
|
|
706
704
|
t && t.addEventListener("abort", h, { once: !0 });
|
|
707
|
-
const b =
|
|
705
|
+
const b = Re[r];
|
|
708
706
|
if (!b) {
|
|
709
707
|
u(), s(new Error(`Unknown encoder: ${r}`));
|
|
710
708
|
return;
|
|
@@ -719,22 +717,22 @@ async function Ne(r, o = {}) {
|
|
|
719
717
|
const t = o.encoder || "mozJPEG", e = {
|
|
720
718
|
...N[t],
|
|
721
719
|
...o.encoderOptions
|
|
722
|
-
}, s =
|
|
720
|
+
}, s = j[t], a = await H(r);
|
|
723
721
|
if (n != null && n.aborted)
|
|
724
722
|
throw new DOMException("AbortError", "AbortError");
|
|
725
723
|
let p;
|
|
726
724
|
if (t === "browserJPEG")
|
|
727
|
-
p = await (await
|
|
725
|
+
p = await (await A(
|
|
728
726
|
a,
|
|
729
727
|
"image/jpeg",
|
|
730
728
|
e.quality
|
|
731
729
|
)).arrayBuffer();
|
|
732
730
|
else if (t === "browserPNG")
|
|
733
|
-
p = await (await
|
|
731
|
+
p = await (await A(a, "image/png")).arrayBuffer();
|
|
734
732
|
else {
|
|
735
733
|
if (t === "browserGIF")
|
|
736
734
|
throw new Error("Browser GIF encoding not supported directly");
|
|
737
|
-
p = await
|
|
735
|
+
p = await Ge(
|
|
738
736
|
t,
|
|
739
737
|
a,
|
|
740
738
|
e,
|
|
@@ -743,7 +741,7 @@ async function Ne(r, o = {}) {
|
|
|
743
741
|
}
|
|
744
742
|
if (n != null && n.aborted)
|
|
745
743
|
throw new DOMException("AbortError", "AbortError");
|
|
746
|
-
const u = X(r.name, s.extension), h =
|
|
744
|
+
const u = X(r.name, s.extension), h = Q(
|
|
747
745
|
p,
|
|
748
746
|
u,
|
|
749
747
|
s.mimeType
|
|
@@ -763,13 +761,13 @@ async function Ne(r, o = {}) {
|
|
|
763
761
|
export {
|
|
764
762
|
N as DEFAULT_ENCODER_OPTIONS,
|
|
765
763
|
ae as ENCODER_LIST,
|
|
766
|
-
|
|
767
|
-
|
|
764
|
+
j as ENCODER_REGISTRY,
|
|
765
|
+
Ae as FIT_METHODS,
|
|
768
766
|
Me as ImageCompressor,
|
|
769
|
-
|
|
767
|
+
Be as RESIZE_METHODS,
|
|
770
768
|
Fe as ROTATE_OPTIONS,
|
|
771
|
-
|
|
772
|
-
|
|
769
|
+
Q as arrayBufferToFile,
|
|
770
|
+
H as blobToImageData,
|
|
773
771
|
K as calculateSavings,
|
|
774
772
|
le as canDecodeImageType,
|
|
775
773
|
Ne as compressFile,
|
|
@@ -777,7 +775,7 @@ export {
|
|
|
777
775
|
$ as formatBytes,
|
|
778
776
|
X as generateCompressedFilename,
|
|
779
777
|
Le as getImageDimensions,
|
|
780
|
-
|
|
778
|
+
A as imageDataToBlob,
|
|
781
779
|
ce as revokeBlobUrl,
|
|
782
780
|
ie as sniffMimeType,
|
|
783
781
|
me as useCompression,
|