2 lines
19 KiB
JavaScript
2 lines
19 KiB
JavaScript
|
var Module=function(n){var r,t,e,o,a,i,u,f,c,s,l,v,p,d,h,g,m,y,$,w,_,n=void 0!==(n=n||{})?n:{};n.ready=new Promise(function(n,e){r=n,t=e});var b={};for(e in n)n.hasOwnProperty(e)&&(b[e]=n[e]);var T=[],P="./this.program",A=function(n,r){throw r},C="";C=0!==(C=self.location.href).indexOf("blob:")?C.substr(0,C.lastIndexOf("/")+1):"",o=function(n){var r=new XMLHttpRequest;return r.open("GET",n,!1),r.send(null),r.responseText},i=function(n){var r=new XMLHttpRequest;return r.open("GET",n,!1),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)},a=function(n,r,t){var e=new XMLHttpRequest;e.open("GET",n,!0),e.responseType="arraybuffer",e.onload=function(){if(200==e.status||0==e.status&&e.response){r(e.response);return}t()},e.onerror=t,e.send(null)},u=function(n){document.title=n};var k=n.print||console.log.bind(console),E=n.printErr||console.warn.bind(console);for(e in b)b.hasOwnProperty(e)&&(n[e]=b[e]);b=null,n.arguments&&(T=n.arguments),n.thisProgram&&(P=n.thisProgram),n.quit&&(A=n.quit);var W=0,R=function(n){W=n};n.wasmBinary&&(f=n.wasmBinary),n.noExitRuntime,"object"!=typeof WebAssembly&&Q("no native wasm support detected");var F=!1,j=new TextDecoder("utf8");function I(n,r){if(!n)return"";for(var t=n+r,e=n;!(e>=t)&&p[e];)++e;return j.decode(p.subarray(n,e))}var S=new TextDecoder("utf-16le");function O(n,r){for(var t=n,e=t>>1,o=e+r/2;!(e>=o)&&h[e];)++e;return t=e<<1,S.decode(p.subarray(n,t))}function x(n,r,t){if(void 0===t&&(t=2147483647),t<2)return 0;for(var e=r,o=(t-=2)<2*n.length?t/2:n.length,a=0;a<o;++a){var i=n.charCodeAt(a);d[r>>1]=i,r+=2}return d[r>>1]=0,r-e}function B(n){return 2*n.length}function U(n,r){for(var t=0,e="";!(t>=r/4);){var o=g[n+4*t>>2];if(0==o)break;if(++t,o>=65536){var a=o-65536;e+=String.fromCharCode(55296|a>>10,56320|1023&a)}else e+=String.fromCharCode(o)}return e}function D(n,r,t){if(void 0===t&&(t=2147483647),t<4)return 0;for(var e=r,o=e+t-4,a=0;a<n.length;++a){var i=n.charCodeAt(a);if(i>=55296&&i<=57343&&(i=65536+((1023&i)<<10)|1023&n.charCodeAt(++a)),g[r>>2]=i,(r+=4)+4>o)break}return g[r>>2]=0,r-e}function H(n){for(var r=0,t=0;t<n.length;++t){var e=n.charCodeAt(t);e>=55296&&e<=57343&&++t,r+=4}return r}function M(n,r){return n%r>0&&(n+=r-n%r),n}function V(r){l=r,n.HEAP8=v=new Int8Array(r),n.HEAP16=d=new Int16Array(r),n.HEAP32=g=new Int32Array(r),n.HEAPU8=p=new Uint8Array(r),n.HEAPU16=h=new Uint16Array(r),n.HEAPU32=m=new Uint32Array(r),n.HEAPF32=y=new Float32Array(r),n.HEAPF64=$=new Float64Array(r)}n.INITIAL_MEMORY;var z=[],q=[],N=[],G=!1;function L(n){z.unshift(n)}function J(n){N.unshift(n)}var Y=0,Z=null,K=null;function Q(r){n.onAbort&&n.onAbort(r),E(r+=""),F=!0,s=1,r="abort("+r+"). Build with -s ASSERTIONS=1 for more info.";var e=new WebAssembly.RuntimeError(r);throw t(e),e}function X(n){return n.startsWith("data:application/octet-stream;base64,")}if(n.preloadedImages={},n.preloadedAudios={},n.locateFile){var nn,nr="jxl_dec.wasm";!X(nr)&&(nr=(nn=nr,n.locateFile?n.locateFile(nn,C):C+nn))}else var nr="jxl_dec.wasm";function nt(n){try{if(n==nr&&f)return new Uint8Array(f);if(i)return i(n);throw"both async and sync fetching of the wasm failed"}catch(r){Q(r)}}function ne(r){for(;r.length>0;){var t=r.shift();if("function"==typeof t){t(n);continue}var e=t.func;"number"==typeof e?void 0===t.arg?w.get(e)():w.get(e)(t.arg):e(void 0===t.arg?null:t.arg)}}function no(n){switch(n){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw TypeError("Unknown type size: "+n)}}var na=void 0;function ni(n){for(var r="",t=n;p[t];)r+=na[p[t++]];return r}var nu={},nf={},nc={};function ns(n){if(void 0===n)return"_unknown";var r=(n=n.replace(/[^a-zA-Z0-9_]/g,"$")).charCodeAt(0);return r>=48&&r<=57?"_"+n:n}function nl(n,r){return Function("body","return function "+(n=ns(n))+'() {\n "use strict"; return body.apply(this, arguments);\n};\n')(r)}function nv(n,r){var t=nl(r,function(n){this.name=r,this.message=n;var t=Error(n).stack;void 0!==t&&(this.stack=this.toString()+"\n"+t.replace(/^Error(:[^\n]*)?\n/,""))});return t.prototype=Object.create(n.prototype),t.prototype.constructor=
|
||
|
addEventListener("message",async a=>{if(a.data.image){let s=performance.now(),t=(await Module({noInitialRun:!0})).decode(a.data.image);if(!t)throw"Error decoding "+a.data.jxlSrc;console.log("Finished decoding",a.data.jxlSrc,"in",performance.now()-s,"ms");postMessage({imgData:t})}else if(a.data.canvas){a.data.canvas.getContext("2d").putImageData(a.data.imgData,0,0);let e=await a.data.canvas.convertToBlob({type:"image/"+a.data.imageType});postMessage({blob:e,url:URL.createObjectURL(e)})}});
|