mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-12 00:37:19 +00:00
Few notes: - Lots of deprecated SIMD intrinsic warnings & errors in JPEG-XL -> Highway; had to suppress erorrs to make project build. - Moved couple of common link flags to cpp.Dockerfile (note: can't move `EXPORT_ES6` otherwise `configure` will fail). - MODULARIZE=1 is no longer necessary and implied by EXPORT_ES6. - EXPORT_NAME=... is no longer necessary in EXPORT_ES6. - Changed visdif to also use EXPORT_ES6 and ENVIRONMENT=node instead of generic JS.
55 lines
16 KiB
JavaScript
Generated
55 lines
16 KiB
JavaScript
Generated
|
|
var Module = (function() {
|
|
var _scriptDir = import.meta.url;
|
|
|
|
return (
|
|
function(Module) {
|
|
Module = Module || {};
|
|
|
|
|
|
var e;e||(e=typeof Module !== 'undefined' ? Module : {});var aa,r;e.ready=new Promise(function(a,b){aa=a;r=b});var t={},u;for(u in e)e.hasOwnProperty(u)&&(t[u]=e[u]);var ba,v,x,y;ba=function(a){x||(x=require("fs"));y||(y=require("path"));a=y.normalize(a);return x.readFileSync(a,null)};v=function(a){a=ba(a);a.buffer||(a=new Uint8Array(a));a.buffer||z("Assertion failed: undefined");return a};1<process.argv.length&&process.argv[1].replace(/\\/g,"/");process.argv.slice(2);
|
|
process.on("uncaughtException",function(a){throw a;});process.on("unhandledRejection",z);e.inspect=function(){return"[Emscripten Module object]"};e.print||console.log.bind(console);var B=e.printErr||console.warn.bind(console);for(u in t)t.hasOwnProperty(u)&&(e[u]=t[u]);t=null;var C;e.wasmBinary&&(C=e.wasmBinary);var noExitRuntime=e.noExitRuntime||!0;"object"!==typeof WebAssembly&&z("no native wasm support detected");var D,ca=!1,da=new TextDecoder("utf8");
|
|
function ea(a,b,c){var d=E;if(0<c){c=b+c-1;for(var f=0;f<a.length;++f){var g=a.charCodeAt(f);if(55296<=g&&57343>=g){var l=a.charCodeAt(++f);g=65536+((g&1023)<<10)|l&1023}if(127>=g){if(b>=c)break;d[b++]=g}else{if(2047>=g){if(b+1>=c)break;d[b++]=192|g>>6}else{if(65535>=g){if(b+2>=c)break;d[b++]=224|g>>12}else{if(b+3>=c)break;d[b++]=240|g>>18;d[b++]=128|g>>12&63}d[b++]=128|g>>6&63}d[b++]=128|g&63}}d[b]=0}}var fa=new TextDecoder("utf-16le");
|
|
function ha(a,b){var c=a>>1;for(b=c+b/2;!(c>=b)&&G[c];)++c;return fa.decode(E.subarray(a,c<<1))}function ia(a,b,c){void 0===c&&(c=2147483647);if(2>c)return 0;c-=2;var d=b;c=c<2*a.length?c/2:a.length;for(var f=0;f<c;++f)H[b>>1]=a.charCodeAt(f),b+=2;H[b>>1]=0;return b-d}function ja(a){return 2*a.length}function ka(a,b){for(var c=0,d="";!(c>=b/4);){var f=J[a+4*c>>2];if(0==f)break;++c;65536<=f?(f-=65536,d+=String.fromCharCode(55296|f>>10,56320|f&1023)):d+=String.fromCharCode(f)}return d}
|
|
function la(a,b,c){void 0===c&&(c=2147483647);if(4>c)return 0;var d=b;c=d+c-4;for(var f=0;f<a.length;++f){var g=a.charCodeAt(f);if(55296<=g&&57343>=g){var l=a.charCodeAt(++f);g=65536+((g&1023)<<10)|l&1023}J[b>>2]=g;b+=4;if(b+4>c)break}J[b>>2]=0;return b-d}function ma(a){for(var b=0,c=0;c<a.length;++c){var d=a.charCodeAt(c);55296<=d&&57343>=d&&++c;b+=4}return b}var na,oa,E,H,G,J,K,pa,qa;
|
|
function ra(){var a=D.buffer;na=a;e.HEAP8=oa=new Int8Array(a);e.HEAP16=H=new Int16Array(a);e.HEAP32=J=new Int32Array(a);e.HEAPU8=E=new Uint8Array(a);e.HEAPU16=G=new Uint16Array(a);e.HEAPU32=K=new Uint32Array(a);e.HEAPF32=pa=new Float32Array(a);e.HEAPF64=qa=new Float64Array(a)}var L,sa=[],ta=[],ua=[];function va(){var a=e.preRun.shift();sa.unshift(a)}var M=0,wa=null,N=null;e.preloadedImages={};e.preloadedAudios={};
|
|
function z(a){if(e.onAbort)e.onAbort(a);B(a);ca=!0;a=new WebAssembly.RuntimeError("abort("+a+"). Build with -s ASSERTIONS=1 for more info.");r(a);throw a;}var O=(new URL("webp_node_dec.wasm",import.meta.url)).toString();function xa(){return Promise.resolve().then(function(){a:{try{if(O==O&&C){var a=new Uint8Array(C);break a}if(v){a=v(O);break a}throw"both async and sync fetching of the wasm failed";}catch(b){z(b)}a=void 0}return a})}
|
|
function ya(a){for(;0<a.length;){var b=a.shift();if("function"==typeof b)b(e);else{var c=b.H;"number"===typeof c?void 0===b.C?L.get(c)():L.get(c)(b.C):c(void 0===b.C?null:b.C)}}}function za(a){switch(a){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+a);}}var Aa=void 0;function P(a){for(var b="";E[a];)b+=Aa[E[a++]];return b}var Q={},R={},S={};
|
|
function Ba(a){if(void 0===a)return"_unknown";a=a.replace(/[^a-zA-Z0-9_]/g,"$");var b=a.charCodeAt(0);return 48<=b&&57>=b?"_"+a:a}function Ca(a,b){a=Ba(a);return(new Function("body","return function "+a+'() {\n "use strict"; return body.apply(this, arguments);\n};\n'))(b)}
|
|
function Da(a){var b=Error,c=Ca(a,function(d){this.name=a;this.message=d;d=Error(d).stack;void 0!==d&&(this.stack=this.toString()+"\n"+d.replace(/^Error(:[^\n]*)?\n/,""))});c.prototype=Object.create(b.prototype);c.prototype.constructor=c;c.prototype.toString=function(){return void 0===this.message?this.name:this.name+": "+this.message};return c}var Ea=void 0;function T(a){throw new Ea(a);}var Fa=void 0;
|
|
function Ga(a,b){function c(h){h=b(h);if(h.length!==d.length)throw new Fa("Mismatched type converter count");for(var k=0;k<d.length;++k)U(d[k],h[k])}var d=[];d.forEach(function(h){S[h]=a});var f=Array(a.length),g=[],l=0;a.forEach(function(h,k){R.hasOwnProperty(h)?f[k]=R[h]:(g.push(h),Q.hasOwnProperty(h)||(Q[h]=[]),Q[h].push(function(){f[k]=R[h];++l;l===g.length&&c(f)}))});0===g.length&&c(f)}
|
|
function U(a,b,c){c=c||{};if(!("argPackAdvance"in b))throw new TypeError("registerType registeredInstance requires argPackAdvance");var d=b.name;a||T('type "'+d+'" must have a positive integer typeid pointer');if(R.hasOwnProperty(a)){if(c.G)return;T("Cannot register type '"+d+"' twice")}R[a]=b;delete S[a];Q.hasOwnProperty(a)&&(b=Q[a],delete Q[a],b.forEach(function(f){f()}))}var Ja=[],V=[{},{value:void 0},{value:null},{value:!0},{value:!1}];
|
|
function Ka(a){4<a&&0===--V[a].D&&(V[a]=void 0,Ja.push(a))}function W(a){switch(a){case void 0:return 1;case null:return 2;case !0:return 3;case !1:return 4;default:var b=Ja.length?Ja.pop():V.length;V[b]={D:1,value:a};return b}}function La(a){return this.fromWireType(K[a>>2])}function Ma(a){if(null===a)return"null";var b=typeof a;return"object"===b||"array"===b||"function"===b?a.toString():""+a}
|
|
function Na(a,b){switch(b){case 2:return function(c){return this.fromWireType(pa[c>>2])};case 3:return function(c){return this.fromWireType(qa[c>>3])};default:throw new TypeError("Unknown float type: "+a);}}function Oa(a){var b=Function;if(!(b instanceof Function))throw new TypeError("new_ called with constructor type "+typeof b+" which is not a function");var c=Ca(b.name||"unknownFunctionName",function(){});c.prototype=b.prototype;c=new c;a=b.apply(c,a);return a instanceof Object?a:c}
|
|
function Pa(a){for(;a.length;){var b=a.pop();a.pop()(b)}}function Qa(a,b){var c=e;if(void 0===c[a].A){var d=c[a];c[a]=function(){c[a].A.hasOwnProperty(arguments.length)||T("Function '"+b+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+c[a].A+")!");return c[a].A[arguments.length].apply(this,arguments)};c[a].A=[];c[a].A[d.F]=d}}
|
|
function Ra(a,b,c){e.hasOwnProperty(a)?((void 0===c||void 0!==e[a].A&&void 0!==e[a].A[c])&&T("Cannot register public name '"+a+"' twice"),Qa(a,a),e.hasOwnProperty(c)&&T("Cannot register multiple overloads of a function with the same number of arguments ("+c+")!"),e[a].A[c]=b):(e[a]=b,void 0!==c&&(e[a].J=c))}function Sa(a,b){for(var c=[],d=0;d<a;d++)c.push(J[(b>>2)+d]);return c}
|
|
function Ta(a,b){var c=[];return function(){c.length=arguments.length;for(var d=0;d<arguments.length;d++)c[d]=arguments[d];a.includes("j")?(d=e["dynCall_"+a],d=c&&c.length?d.apply(null,[b].concat(c)):d.call(null,b)):d=L.get(b).apply(null,c);return d}}function Ua(a,b){a=P(a);var c=a.includes("j")?Ta(a,b):L.get(b);"function"!==typeof c&&T("unknown function pointer with signature "+a+": "+b);return c}var Va=void 0;function Wa(a){a=Xa(a);var b=P(a);X(a);return b}
|
|
function Ya(a,b){function c(g){f[g]||R[g]||(S[g]?S[g].forEach(c):(d.push(g),f[g]=!0))}var d=[],f={};b.forEach(c);throw new Va(a+": "+d.map(Wa).join([", "]));}function Za(a,b,c){switch(b){case 0:return c?function(d){return oa[d]}:function(d){return E[d]};case 1:return c?function(d){return H[d>>1]}:function(d){return G[d>>1]};case 2:return c?function(d){return J[d>>2]}:function(d){return K[d>>2]};default:throw new TypeError("Unknown integer type: "+a);}}var $a={};
|
|
function ab(){return"object"===typeof globalThis?globalThis:Function("return this")()}function bb(a,b){var c=R[a];void 0===c&&T(b+" has unknown type "+Wa(a));return c}for(var cb={},db=Array(256),Y=0;256>Y;++Y)db[Y]=String.fromCharCode(Y);Aa=db;Ea=e.BindingError=Da("BindingError");Fa=e.InternalError=Da("InternalError");e.count_emval_handles=function(){for(var a=0,b=5;b<V.length;++b)void 0!==V[b]&&++a;return a};e.get_first_emval=function(){for(var a=5;a<V.length;++a)if(void 0!==V[a])return V[a];return null};
|
|
Va=e.UnboundTypeError=Da("UnboundTypeError");
|
|
var fb={e:function(){},p:function(){},n:function(a,b,c,d,f){var g=za(c);b=P(b);U(a,{name:b,fromWireType:function(l){return!!l},toWireType:function(l,h){return h?d:f},argPackAdvance:8,readValueFromPointer:function(l){if(1===c)var h=oa;else if(2===c)h=H;else if(4===c)h=J;else throw new TypeError("Unknown boolean type size: "+b);return this.fromWireType(h[l>>g])},B:null})},r:function(a,b){b=P(b);U(a,{name:b,fromWireType:function(c){var d=V[c].value;Ka(c);return d},toWireType:function(c,d){return W(d)},
|
|
argPackAdvance:8,readValueFromPointer:La,B:null})},m:function(a,b,c){c=za(c);b=P(b);U(a,{name:b,fromWireType:function(d){return d},toWireType:function(d,f){if("number"!==typeof f&&"boolean"!==typeof f)throw new TypeError('Cannot convert "'+Ma(f)+'" to '+this.name);return f},argPackAdvance:8,readValueFromPointer:Na(b,c),B:null})},i:function(a,b,c,d,f,g){var l=Sa(b,c);a=P(a);f=Ua(d,f);Ra(a,function(){Ya("Cannot call "+a+" due to unbound types",l)},b-1);Ga(l,function(h){var k=[h[0],null].concat(h.slice(1)),
|
|
n=h=a,p=f,q=k.length;2>q&&T("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var w=null!==k[1]&&!1,A=!1,m=1;m<k.length;++m)if(null!==k[m]&&void 0===k[m].B){A=!0;break}var Ha="void"!==k[0].name,F="",I="";for(m=0;m<q-2;++m)F+=(0!==m?", ":"")+"arg"+m,I+=(0!==m?", ":"")+"arg"+m+"Wired";n="return function "+Ba(n)+"("+F+") {\nif (arguments.length !== "+(q-2)+") {\nthrowBindingError('function "+n+" called with ' + arguments.length + ' arguments, expected "+(q-2)+" args!');\n}\n";
|
|
A&&(n+="var destructors = [];\n");var Ia=A?"destructors":"null";F="throwBindingError invoker fn runDestructors retType classParam".split(" ");p=[T,p,g,Pa,k[0],k[1]];w&&(n+="var thisWired = classParam.toWireType("+Ia+", this);\n");for(m=0;m<q-2;++m)n+="var arg"+m+"Wired = argType"+m+".toWireType("+Ia+", arg"+m+"); // "+k[m+2].name+"\n",F.push("argType"+m),p.push(k[m+2]);w&&(I="thisWired"+(0<I.length?", ":"")+I);n+=(Ha?"var rv = ":"")+"invoker(fn"+(0<I.length?", ":"")+I+");\n";if(A)n+="runDestructors(destructors);\n";
|
|
else for(m=w?1:2;m<k.length;++m)q=1===m?"thisWired":"arg"+(m-2)+"Wired",null!==k[m].B&&(n+=q+"_dtor("+q+"); // "+k[m].name+"\n",F.push(q+"_dtor"),p.push(k[m].B));Ha&&(n+="var ret = retType.fromWireType(rv);\nreturn ret;\n");F.push(n+"}\n");k=Oa(F).apply(null,p);m=b-1;if(!e.hasOwnProperty(h))throw new Fa("Replacing nonexistant public symbol");void 0!==e[h].A&&void 0!==m?e[h].A[m]=k:(e[h]=k,e[h].F=m);return[]})},b:function(a,b,c,d,f){function g(n){return n}b=P(b);-1===f&&(f=4294967295);var l=za(c);
|
|
if(0===d){var h=32-8*c;g=function(n){return n<<h>>>h}}var k=b.includes("unsigned");U(a,{name:b,fromWireType:g,toWireType:function(n,p){if("number"!==typeof p&&"boolean"!==typeof p)throw new TypeError('Cannot convert "'+Ma(p)+'" to '+this.name);if(p<d||p>f)throw new TypeError('Passing a number "'+Ma(p)+'" from JS side to C/C++ side to an argument of type "'+b+'", which is outside the valid range ['+d+", "+f+"]!");return k?p>>>0:p|0},argPackAdvance:8,readValueFromPointer:Za(b,l,0!==d),B:null})},a:function(a,
|
|
b,c){function d(g){g>>=2;var l=K;return new f(na,l[g+1],l[g])}var f=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][b];c=P(c);U(a,{name:c,fromWireType:d,argPackAdvance:8,readValueFromPointer:d},{G:!0})},h:function(a,b){b=P(b);var c="std::string"===b;U(a,{name:b,fromWireType:function(d){var f=K[d>>2];if(c)for(var g=d+4,l=0;l<=f;++l){var h=d+4+l;if(l==f||0==E[h]){if(g){for(var k=g+(h-g),n=g;!(n>=k)&&E[n];)++n;g=da.decode(E.subarray(g,n))}else g="";if(void 0===
|
|
p)var p=g;else p+=String.fromCharCode(0),p+=g;g=h+1}}else{p=Array(f);for(l=0;l<f;++l)p[l]=String.fromCharCode(E[d+4+l]);p=p.join("")}X(d);return p},toWireType:function(d,f){f instanceof ArrayBuffer&&(f=new Uint8Array(f));var g="string"===typeof f;g||f instanceof Uint8Array||f instanceof Uint8ClampedArray||f instanceof Int8Array||T("Cannot pass non-string to std::string");var l=(c&&g?function(){for(var n=0,p=0;p<f.length;++p){var q=f.charCodeAt(p);55296<=q&&57343>=q&&(q=65536+((q&1023)<<10)|f.charCodeAt(++p)&
|
|
1023);127>=q?++n:n=2047>=q?n+2:65535>=q?n+3:n+4}return n}:function(){return f.length})(),h=eb(4+l+1);K[h>>2]=l;if(c&&g)ea(f,h+4,l+1);else if(g)for(g=0;g<l;++g){var k=f.charCodeAt(g);255<k&&(X(h),T("String has UTF-16 code units that do not fit in 8 bits"));E[h+4+g]=k}else for(g=0;g<l;++g)E[h+4+g]=f[g];null!==d&&d.push(X,h);return h},argPackAdvance:8,readValueFromPointer:La,B:function(d){X(d)}})},f:function(a,b,c){c=P(c);if(2===b){var d=ha;var f=ia;var g=ja;var l=function(){return G};var h=1}else 4===
|
|
b&&(d=ka,f=la,g=ma,l=function(){return K},h=2);U(a,{name:c,fromWireType:function(k){for(var n=K[k>>2],p=l(),q,w=k+4,A=0;A<=n;++A){var m=k+4+A*b;if(A==n||0==p[m>>h])w=d(w,m-w),void 0===q?q=w:(q+=String.fromCharCode(0),q+=w),w=m+b}X(k);return q},toWireType:function(k,n){"string"!==typeof n&&T("Cannot pass non-string to C++ string type "+c);var p=g(n),q=eb(4+p+b);K[q>>2]=p>>h;f(n,q+4,p+b);null!==k&&k.push(X,q);return q},argPackAdvance:8,readValueFromPointer:La,B:function(k){X(k)}})},o:function(a,b){b=
|
|
P(b);U(a,{I:!0,name:b,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},c:Ka,d:function(a){if(0===a)return W(ab());var b=$a[a];a=void 0===b?P(a):b;return W(ab()[a])},j:function(a){4<a&&(V[a].D+=1)},k:function(a,b,c,d){a||T("Cannot use deleted val. handle = "+a);a=V[a].value;var f=cb[b];if(!f){f="";for(var g=0;g<b;++g)f+=(0!==g?", ":"")+"arg"+g;var l="return function emval_allocator_"+b+"(constructor, argTypes, args) {\n";for(g=0;g<b;++g)l+="var argType"+g+" = requireRegisteredType(Module['HEAP32'][(argTypes >>> 2) + "+
|
|
g+'], "parameter '+g+'");\nvar arg'+g+" = argType"+g+".readValueFromPointer(args);\nargs += argType"+g+"['argPackAdvance'];\n";f=(new Function("requireRegisteredType","Module","__emval_register",l+("var obj = new constructor("+f+");\nreturn __emval_register(obj);\n}\n")))(bb,e,W);cb[b]=f}return f(a,c,d)},l:function(){z()},q:function(a,b,c){E.copyWithin(a,b,b+c)},g:function(a){var b=E.length;a>>>=0;if(2147483648<a)return!1;for(var c=1;4>=c;c*=2){var d=b*(1+.2/c);d=Math.min(d,a+100663296);d=Math.max(a,
|
|
d);0<d%65536&&(d+=65536-d%65536);a:{try{D.grow(Math.min(2147483648,d)-na.byteLength+65535>>>16);ra();var f=1;break a}catch(g){}f=void 0}if(f)return!0}return!1}};
|
|
(function(){function a(f){e.asm=f.exports;D=e.asm.s;ra();L=e.asm.y;ta.unshift(e.asm.t);M--;e.monitorRunDependencies&&e.monitorRunDependencies(M);0==M&&(null!==wa&&(clearInterval(wa),wa=null),N&&(f=N,N=null,f()))}function b(f){a(f.instance)}function c(f){return xa().then(function(g){return WebAssembly.instantiate(g,d)}).then(f,function(g){B("failed to asynchronously prepare wasm: "+g);z(g)})}var d={a:fb};M++;e.monitorRunDependencies&&e.monitorRunDependencies(M);if(e.instantiateWasm)try{return e.instantiateWasm(d,
|
|
a)}catch(f){return B("Module.instantiateWasm callback failed with error: "+f),!1}(function(){return C||"function"!==typeof WebAssembly.instantiateStreaming||O.startsWith("data:application/octet-stream;base64,")||"function"!==typeof fetch?c(b):fetch(O,{credentials:"same-origin"}).then(function(f){return WebAssembly.instantiateStreaming(f,d).then(b,function(g){B("wasm streaming compile failed: "+g);B("falling back to ArrayBuffer instantiation");return c(b)})})})().catch(r);return{}})();
|
|
e.___wasm_call_ctors=function(){return(e.___wasm_call_ctors=e.asm.t).apply(null,arguments)};var eb=e._malloc=function(){return(eb=e._malloc=e.asm.u).apply(null,arguments)},X=e._free=function(){return(X=e._free=e.asm.v).apply(null,arguments)},Xa=e.___getTypeName=function(){return(Xa=e.___getTypeName=e.asm.w).apply(null,arguments)};e.___embind_register_native_and_builtin_types=function(){return(e.___embind_register_native_and_builtin_types=e.asm.x).apply(null,arguments)};var Z;
|
|
N=function gb(){Z||hb();Z||(N=gb)};
|
|
function hb(){function a(){if(!Z&&(Z=!0,e.calledRun=!0,!ca)){ya(ta);aa(e);if(e.onRuntimeInitialized)e.onRuntimeInitialized();if(e.postRun)for("function"==typeof e.postRun&&(e.postRun=[e.postRun]);e.postRun.length;){var b=e.postRun.shift();ua.unshift(b)}ya(ua)}}if(!(0<M)){if(e.preRun)for("function"==typeof e.preRun&&(e.preRun=[e.preRun]);e.preRun.length;)va();ya(sa);0<M||(e.setStatus?(e.setStatus("Running..."),setTimeout(function(){setTimeout(function(){e.setStatus("")},1);a()},1)):a())}}e.run=hb;
|
|
if(e.preInit)for("function"==typeof e.preInit&&(e.preInit=[e.preInit]);0<e.preInit.length;)e.preInit.pop()();hb();
|
|
|
|
|
|
return Module.ready
|
|
}
|
|
);
|
|
})();
|
|
export default Module; |