Compare commits

..

1 Commits

Author SHA1 Message Date
Jake Archibald
008bae62da Splitting PointerTracker into its own project 2018-11-06 14:18:53 +00:00
248 changed files with 12112 additions and 15053 deletions

13
.babelrc Normal file
View File

@@ -0,0 +1,13 @@
{
"plugins": [
"transform-class-properties",
"transform-react-constant-elements",
"transform-react-remove-prop-types",
[
"transform-react-jsx",
{
"pragma": "h"
}
]
]
}

View File

@@ -1,2 +0,0 @@
BasedOnStyle: Chromium
ColumnLimit: 100

View File

@@ -1,36 +0,0 @@
---
name: Bug report
about: Something is not working as expected
labels:
---
**Before you start**
Please take a look at the [FAQ](https://github.com/GoogleChromeLabs/squoosh/wiki/FAQ) as well as the already opened issues! If nothing fits your problem, go ahead and fill out the following template:
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Version:**
- OS w/ version: [e.g. iOS 12]
- Browser w/ version [e.g. Chrome 70]
- Node version: [e.g. 10.11.0]
- npm version: [e.g. 6.4.1]
**Is your issue related to the quality of image compression?**
Please attach original and output images (you can drag & drop to attach).
- Original image
- Output image from Squoosh
**Additional context, screenshots, screencasts**
Add any other context about the problem here.

View File

@@ -1,18 +0,0 @@
---
name: Feature request
about: Suggest an idea for this project
labels:
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Does other service/app have this feature?**
Add any service you know/use that has this feature (We want to know for research)
**Additional context**
Add any other context or screenshots about the feature request here.

1
.nvmrc
View File

@@ -1 +0,0 @@
10.16.2

View File

@@ -1,7 +1,5 @@
language: node_js
node_js:
- node
cache: npm
script: npm run build
after_success: npm run sizereport
os:
- linux
- windows
script: npm run build || npm run build # scss ts definitions need to be generated before an actual build

View File

@@ -1,32 +1,5 @@
# [Squoosh]!
# Squoosh!
[Squoosh] is an image compression web app that allows you to dive into the advanced options provided
by various image compressors.
Squoosh will be an image compression web app that allows you to dive into the
advanced options provided by various image compressors.
# Privacy
Google Analytics is used to record the following:
* [Basic visit data](https://support.google.com/analytics/answer/6004245?ref_topic=2919631).
* Before and after image size once an image is downloaded. These values are rounded to the nearest
kilobyte.
* If install is available, when Squoosh is installed, and what method was used to install Squoosh.
Image compression is handled locally; no additional data is sent to the server.
# Building locally
Clone the repo, and:
```sh
npm install
npm run build
```
You can run the development server with:
```sh
npm start
```
[Squoosh]: https://squoosh.app

View File

@@ -1,18 +0,0 @@
# Long-term cache by default.
/*
Cache-Control: max-age=31536000
# And here are the exceptions:
/
Cache-Control: no-cache
/serviceworker.js
Cache-Control: no-cache
/manifest.json
Cache-Control: must-revalidate, max-age=3600
# URLs in /assets do not include a hash and are mutable.
# But it isn't a big deal if the user gets an old version.
/assets/*
Cache-Control: must-revalidate, max-age=3600

View File

@@ -1,2 +0,0 @@
/index.html / 301
/* /index.html 301

View File

@@ -11,6 +11,6 @@ $ npm install
$ npm run build
```
This will build two files: `<codec name>_<enc or dec>.js` and `<codec name>_<enc or dec>.wasm`. It will most likely be necessary to set [`Module["locateFile"]`](https://kripken.github.io/emscripten-site/docs/api_reference/module.html#affecting-execution) to successfully load the `.wasm` file. When the `.js` file is loaded, a global `<codec name>_<enc or dec>` is created with the same API as an [Emscripten `Module`](https://kripken.github.io/emscripten-site/docs/api_reference/module.html).
This will build two files: `<codec name>_<enc or dec>.js` and `<codec name>_<enc or dec>.wasm`. It will most likely be necessary to set [`Module["locateFile"]`](https://kripken.github.io/emscripten-site/docs/api_reference/module.html#affecting-execution) to sucessfully load the `.wasm` file. When the `.js` file is loaded, a global `<codec name>_<enc or dec>` is created with the same API as an [Emscripten `Module`](https://kripken.github.io/emscripten-site/docs/api_reference/module.html).
Each codec will document its API in its README.

View File

@@ -1,76 +0,0 @@
CODEC_URL = https://github.com/AOMediaCodec/libavif/archive/v0.8.0.tar.gz
CODEC_DIR = node_modules/libavif
CODEC_BUILD_DIR := $(CODEC_DIR)/build
CODEC_OUT := $(CODEC_BUILD_DIR)/libavif.a
LIBAOM_URL = https://aomedia.googlesource.com/aom/+archive/v2.0.0.tar.gz
LIBAOM_DIR := $(CODEC_DIR)/ext/aom
LIBAOM_BUILD_DIR := $(LIBAOM_DIR)/build.libavif
LIBAOM_OUT := $(LIBAOM_BUILD_DIR)/libaom.a
OUT_JS = enc/avif_enc.js dec/avif_dec.js
OUT_WASM = $(OUT_JS:.js=.wasm)
.PHONY: all clean
all: $(OUT_JS)
%.js: %.cpp $(LIBAOM_OUT) $(CODEC_OUT)
$(CXX) \
-I $(CODEC_DIR)/include \
${CXXFLAGS} \
${LDFLAGS} \
--bind \
--closure 1 \
-s ALLOW_MEMORY_GROWTH=1 \
-s MODULARIZE=1 \
-s 'EXPORT_NAME="$(basename $(@F))"' \
-o $@ \
$+
$(CODEC_OUT): $(CODEC_DIR)/CMakeLists.txt $(LIBAOM_OUT)
mkdir -p $(CODEC_BUILD_DIR)
cd $(CODEC_BUILD_DIR) && \
emcmake cmake \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=0 \
-DAVIF_CODEC_AOM=1 \
-DAVIF_LOCAL_AOM=1 \
../ && \
$(MAKE)
$(LIBAOM_OUT): $(LIBAOM_DIR)/CMakeLists.txt
mkdir -p $(LIBAOM_BUILD_DIR)
cd $(LIBAOM_BUILD_DIR) && \
emcmake cmake \
-DCMAKE_BUILD_TYPE=Release \
-DENABLE_CCACHE=0 \
-DAOM_TARGET_CPU=generic \
-DENABLE_DOCS=0 \
-DENABLE_TESTS=0 \
-DENABLE_EXAMPLES=0 \
-DENABLE_TOOLS=0 \
-DCONFIG_ACCOUNTING=1 \
-DCONFIG_INSPECTION=0 \
-DCONFIG_MULTITHREAD=0 \
-DCONFIG_RUNTIME_CPU_DETECT=0 \
-DCONFIG_WEBM_IO=0 \
../ && \
$(MAKE)
$(CODEC_DIR)/CMakeLists.txt: $(CODEC_DIR)
$(LIBAOM_DIR)/CMakeLists.txt: $(LIBAOM_DIR)
$(CODEC_DIR):
mkdir -p $@
curl -sL $(CODEC_URL) | tar xz --strip 1 -C $@
$(LIBAOM_DIR):
mkdir -p $@
curl -sL $(LIBAOM_URL) | tar xz -C $@
clean:
$(RM) $(OUT_JS) $(OUT_WASM)
$(MAKE) -C $(CODEC_BUILD_DIR) clean
$(MAKE) -C $(LIBAOM_BUILD_DIR) clean

View File

@@ -1,14 +0,0 @@
# AVIF decoder
- Source: <https://github.com/AOMediaCodec/libavif>
- Version: v0.5.4
## Example
See `example.html`
## API
### `RawImage decode(std::string buffer)`
Decodes the given avif buffer into raw RGBA. `RawImage` is a class with 3 fields: `buffer`, `width`, and `height`.

View File

@@ -1,50 +0,0 @@
#include <emscripten/bind.h>
#include <emscripten/val.h>
#include "avif/avif.h"
using namespace emscripten;
thread_local const val Uint8ClampedArray = val::global("Uint8ClampedArray");
thread_local const val ImageData = val::global("ImageData");
val decode(std::string avifimage) {
// point raw.data and raw.size to the contents of an .avif(s)
avifROData raw = {
.data = (uint8_t*)avifimage.c_str(),
.size = avifimage.length()
};
avifImage* image = avifImageCreateEmpty();
avifDecoder* decoder = avifDecoderCreate();
avifResult decodeResult = avifDecoderRead(decoder, image, &raw);
// image is an independent copy of decoded data, decoder may be destroyed here
avifDecoderDestroy(decoder);
val result = val::null();
if (decodeResult == AVIF_RESULT_OK) {
// Convert to interleaved RGB(A)/BGR(A) using a libavif-allocated buffer.
avifRGBImage rgb;
avifRGBImageSetDefaults(&rgb, image); // Defaults to AVIF_RGB_FORMAT_RGBA which is what we want.
rgb.depth = 8; // Does not need to match image->depth. We always want 8-bit pixels.
avifRGBImageAllocatePixels(&rgb);
avifImageYUVToRGB(image, &rgb);
// We want to create a *copy* of the decoded data to be owned by the JavaScript side.
// For that, we perform `new Uint8Array(wasmMemBuffer, wasmPtr, wasmSize).slice()`:
result = ImageData.new_(Uint8ClampedArray.new_(typed_memory_view(rgb.rowBytes * rgb.height, rgb.pixels)), rgb.width, rgb.height);
// Now we can safely free the RGB pixels:
avifRGBImageFreePixels(&rgb);
}
// Image has been converted to RGB, we don't need the original anymore.
avifImageDestroy(image);
return result;
}
EMSCRIPTEN_BINDINGS(my_module) {
function("decode", &decode);
}

View File

@@ -1,6 +0,0 @@
interface AVIFModule extends EmscriptenWasm.Module {
decode(data: BufferSource): ImageData | null;
}
export default function(opts: EmscriptenWasm.ModuleOpts): AVIFModule;

View File

@@ -1,111 +0,0 @@
var avif_dec = (function() {
var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename;
return (
function(avif_dec) {
avif_dec = avif_dec || {};
var e;e||(e=typeof avif_dec !== 'undefined' ? avif_dec : {});var aa,ba;e.ready=new Promise(function(a,b){aa=a;ba=b});var ca={},l;for(l in e)e.hasOwnProperty(l)&&(ca[l]=e[l]);var ea=!1,q=!1,fa=!1,ha=!1;ea="object"===typeof window;q="function"===typeof importScripts;fa="object"===typeof process&&"object"===typeof process.versions&&"string"===typeof process.versions.node;ha=!ea&&!fa&&!q;var u="",ia,ja,ka,la;
if(fa)u=q?require("path").dirname(u)+"/":__dirname+"/",ia=function(a,b){ka||(ka=require("fs"));la||(la=require("path"));a=la.normalize(a);return ka.readFileSync(a,b?null:"utf8")},ja=function(a){a=ia(a,!0);a.buffer||(a=new Uint8Array(a));assert(a.buffer);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",w),e.inspect=function(){return"[Emscripten Module object]"};else if(ha)"undefined"!=
typeof read&&(ia=function(a){return read(a)}),ja=function(a){if("function"===typeof readbuffer)return new Uint8Array(readbuffer(a));a=read(a,"binary");assert("object"===typeof a);return a},"undefined"!==typeof print&&("undefined"===typeof console&&(console={}),console.log=print,console.warn=console.error="undefined"!==typeof printErr?printErr:print);else if(ea||q)q?u=self.location.href:document.currentScript&&(u=document.currentScript.src),_scriptDir&&(u=_scriptDir),0!==u.indexOf("blob:")?u=u.substr(0,
u.lastIndexOf("/")+1):u="",ia=function(a){var b=new XMLHttpRequest;b.open("GET",a,!1);b.send(null);return b.responseText},q&&(ja=function(a){var b=new XMLHttpRequest;b.open("GET",a,!1);b.responseType="arraybuffer";b.send(null);return new Uint8Array(b.response)});var ma=e.print||console.log.bind(console),y=e.printErr||console.warn.bind(console);for(l in ca)ca.hasOwnProperty(l)&&(e[l]=ca[l]);ca=null;var na=0,oa;e.wasmBinary&&(oa=e.wasmBinary);var noExitRuntime;e.noExitRuntime&&(noExitRuntime=e.noExitRuntime);
"object"!==typeof WebAssembly&&w("no native wasm support detected");var z,pa=new WebAssembly.Table({initial:2113,maximum:2113,element:"anyfunc"}),qa=!1;function assert(a,b){a||w("Assertion failed: "+b)}var ra="undefined"!==typeof TextDecoder?new TextDecoder("utf8"):void 0;
function A(a,b,c){var d=b+c;for(c=b;a[c]&&!(c>=d);)++c;if(16<c-b&&a.subarray&&ra)return ra.decode(a.subarray(b,c));for(d="";b<c;){var f=a[b++];if(f&128){var g=a[b++]&63;if(192==(f&224))d+=String.fromCharCode((f&31)<<6|g);else{var h=a[b++]&63;f=224==(f&240)?(f&15)<<12|g<<6|h:(f&7)<<18|g<<12|h<<6|a[b++]&63;65536>f?d+=String.fromCharCode(f):(f-=65536,d+=String.fromCharCode(55296|f>>10,56320|f&1023))}}else d+=String.fromCharCode(f)}return d}
function sa(a,b,c,d){if(!(0<d))return 0;var f=c;d=c+d-1;for(var g=0;g<a.length;++g){var h=a.charCodeAt(g);if(55296<=h&&57343>=h){var k=a.charCodeAt(++g);h=65536+((h&1023)<<10)|k&1023}if(127>=h){if(c>=d)break;b[c++]=h}else{if(2047>=h){if(c+1>=d)break;b[c++]=192|h>>6}else{if(65535>=h){if(c+2>=d)break;b[c++]=224|h>>12}else{if(c+3>=d)break;b[c++]=240|h>>18;b[c++]=128|h>>12&63}b[c++]=128|h>>6&63}b[c++]=128|h&63}}b[c]=0;return c-f}
function ta(a){for(var b=0,c=0;c<a.length;++c){var d=a.charCodeAt(c);55296<=d&&57343>=d&&(d=65536+((d&1023)<<10)|a.charCodeAt(++c)&1023);127>=d?++b:b=2047>=d?b+2:65535>=d?b+3:b+4}return b}var ua="undefined"!==typeof TextDecoder?new TextDecoder("utf-16le"):void 0;function va(a,b){var c=a>>1;for(var d=c+b/2;!(c>=d)&&wa[c];)++c;c<<=1;if(32<c-a&&ua)return ua.decode(B.subarray(a,c));c=0;for(d="";;){var f=C[a+2*c>>1];if(0==f||c==b/2)return d;++c;d+=String.fromCharCode(f)}}
function xa(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)C[b>>1]=a.charCodeAt(f),b+=2;C[b>>1]=0;return b-d}function ya(a){return 2*a.length}function za(a,b){for(var c=0,d="";!(c>=b/4);){var f=D[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 Aa(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 h=a.charCodeAt(++f);g=65536+((g&1023)<<10)|h&1023}D[b>>2]=g;b+=4;if(b+4>c)break}D[b>>2]=0;return b-d}function Ba(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 E,F,B,C,wa,D,I,Ca,Da;
function Ea(a){E=a;e.HEAP8=F=new Int8Array(a);e.HEAP16=C=new Int16Array(a);e.HEAP32=D=new Int32Array(a);e.HEAPU8=B=new Uint8Array(a);e.HEAPU16=wa=new Uint16Array(a);e.HEAPU32=I=new Uint32Array(a);e.HEAPF32=Ca=new Float32Array(a);e.HEAPF64=Da=new Float64Array(a)}var Fa=e.INITIAL_MEMORY||16777216;e.wasmMemory?z=e.wasmMemory:z=new WebAssembly.Memory({initial:Fa/65536,maximum:32768});z&&(E=z.buffer);Fa=E.byteLength;Ea(E);D[224044]=6139216;
function Ga(a){for(;0<a.length;){var b=a.shift();if("function"==typeof b)b(e);else{var c=b.ob;"number"===typeof c?void 0===b.Ya?e.dynCall_v(c):e.dynCall_vi(c,b.Ya):c(void 0===b.Ya?null:b.Ya)}}}var Ha=[],Ia=[],Ja=[],Ka=[];function La(){var a=e.preRun.shift();Ha.unshift(a)}var Ma=Math.abs,Na=Math.ceil,Oa=Math.floor,Pa=Math.min,J=0,Qa=null,Ra=null;e.preloadedImages={};e.preloadedAudios={};
function w(a){if(e.onAbort)e.onAbort(a);y(a);qa=!0;a=new WebAssembly.RuntimeError("abort("+a+"). Build with -s ASSERTIONS=1 for more info.");ba(a);throw a;}function Sa(a){var b=K;return String.prototype.startsWith?b.startsWith(a):0===b.indexOf(a)}function Ta(){return Sa("data:application/octet-stream;base64,")}var K="avif_dec.wasm";if(!Ta()){var Ua=K;K=e.locateFile?e.locateFile(Ua,u):u+Ua}
function Va(){try{if(oa)return new Uint8Array(oa);if(ja)return ja(K);throw"both async and sync fetching of the wasm failed";}catch(a){w(a)}}function Wa(){return oa||!ea&&!q||"function"!==typeof fetch||Sa("file://")?new Promise(function(a){a(Va())}):fetch(K,{credentials:"same-origin"}).then(function(a){if(!a.ok)throw"failed to load wasm binary file at '"+K+"'";return a.arrayBuffer()}).catch(function(){return Va()})}var L,Xa;Ia.push({ob:function(){Ya()}});function Za(){return 0<Za.Va}
function $a(a,b){for(var c=0,d=a.length-1;0<=d;d--){var f=a[d];"."===f?a.splice(d,1):".."===f?(a.splice(d,1),c++):c&&(a.splice(d,1),c--)}if(b)for(;c;c--)a.unshift("..");return a}function ab(a){var b="/"===a.charAt(0),c="/"===a.substr(-1);(a=$a(a.split("/").filter(function(d){return!!d}),!b).join("/"))||b||(a=".");a&&c&&(a+="/");return(b?"/":"")+a}
function bb(a){var b=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(a).slice(1);a=b[0];b=b[1];if(!a&&!b)return".";b&&(b=b.substr(0,b.length-1));return a+b}function cb(a){if("/"===a)return"/";var b=a.lastIndexOf("/");return-1===b?a:a.substr(b+1)}
function db(){for(var a="",b=!1,c=arguments.length-1;-1<=c&&!b;c--){b=0<=c?arguments[c]:"/";if("string"!==typeof b)throw new TypeError("Arguments to path.resolve must be strings");if(!b)return"";a=b+"/"+a;b="/"===b.charAt(0)}a=$a(a.split("/").filter(function(d){return!!d}),!b).join("/");return(b?"/":"")+a||"."}var eb=[];function fb(a,b){eb[a]={input:[],output:[],Ua:b};gb(a,hb)}
var hb={open:function(a){var b=eb[a.node.rdev];if(!b)throw new M(43);a.tty=b;a.seekable=!1},close:function(a){a.tty.Ua.flush(a.tty)},flush:function(a){a.tty.Ua.flush(a.tty)},read:function(a,b,c,d){if(!a.tty||!a.tty.Ua.ib)throw new M(60);for(var f=0,g=0;g<d;g++){try{var h=a.tty.Ua.ib(a.tty)}catch(k){throw new M(29);}if(void 0===h&&0===f)throw new M(6);if(null===h||void 0===h)break;f++;b[c+g]=h}f&&(a.node.timestamp=Date.now());return f},write:function(a,b,c,d){if(!a.tty||!a.tty.Ua.$a)throw new M(60);
try{for(var f=0;f<d;f++)a.tty.Ua.$a(a.tty,b[c+f])}catch(g){throw new M(29);}d&&(a.node.timestamp=Date.now());return f}},ib={ib:function(a){if(!a.input.length){var b=null;if(fa){var c=Buffer.Va?Buffer.Va(256):new Buffer(256),d=0;try{d=ka.readSync(process.stdin.fd,c,0,256,null)}catch(f){if(-1!=f.toString().indexOf("EOF"))d=0;else throw f;}0<d?b=c.slice(0,d).toString("utf-8"):b=null}else"undefined"!=typeof window&&"function"==typeof window.prompt?(b=window.prompt("Input: "),null!==b&&(b+="\n")):"function"==
typeof readline&&(b=readline(),null!==b&&(b+="\n"));if(!b)return null;c=Array(ta(b)+1);b=sa(b,c,0,c.length);c.length=b;a.input=c}return a.input.shift()},$a:function(a,b){null===b||10===b?(ma(A(a.output,0)),a.output=[]):0!=b&&a.output.push(b)},flush:function(a){a.output&&0<a.output.length&&(ma(A(a.output,0)),a.output=[])}},jb={$a:function(a,b){null===b||10===b?(y(A(a.output,0)),a.output=[]):0!=b&&a.output.push(b)},flush:function(a){a.output&&0<a.output.length&&(y(A(a.output,0)),a.output=[])}},N={Ma:null,
Pa:function(){return N.createNode(null,"/",16895,0)},createNode:function(a,b,c,d){if(24576===(c&61440)||4096===(c&61440))throw new M(63);N.Ma||(N.Ma={dir:{node:{Ra:N.Ja.Ra,Oa:N.Ja.Oa,lookup:N.Ja.lookup,Wa:N.Ja.Wa,rename:N.Ja.rename,unlink:N.Ja.unlink,rmdir:N.Ja.rmdir,readdir:N.Ja.readdir,symlink:N.Ja.symlink},stream:{Ta:N.Ka.Ta}},file:{node:{Ra:N.Ja.Ra,Oa:N.Ja.Oa},stream:{Ta:N.Ka.Ta,read:N.Ka.read,write:N.Ka.write,cb:N.Ka.cb,jb:N.Ka.jb,lb:N.Ka.lb}},link:{node:{Ra:N.Ja.Ra,Oa:N.Ja.Oa,readlink:N.Ja.readlink},
stream:{}},eb:{node:{Ra:N.Ja.Ra,Oa:N.Ja.Oa},stream:kb}});c=lb(a,b,c,d);16384===(c.mode&61440)?(c.Ja=N.Ma.dir.node,c.Ka=N.Ma.dir.stream,c.Ia={}):32768===(c.mode&61440)?(c.Ja=N.Ma.file.node,c.Ka=N.Ma.file.stream,c.La=0,c.Ia=null):40960===(c.mode&61440)?(c.Ja=N.Ma.link.node,c.Ka=N.Ma.link.stream):8192===(c.mode&61440)&&(c.Ja=N.Ma.eb.node,c.Ka=N.Ma.eb.stream);c.timestamp=Date.now();a&&(a.Ia[b]=c);return c},xb:function(a){if(a.Ia&&a.Ia.subarray){for(var b=[],c=0;c<a.La;++c)b.push(a.Ia[c]);return b}return a.Ia},
yb:function(a){return a.Ia?a.Ia.subarray?a.Ia.subarray(0,a.La):new Uint8Array(a.Ia):new Uint8Array(0)},fb:function(a,b){var c=a.Ia?a.Ia.length:0;c>=b||(b=Math.max(b,c*(1048576>c?2:1.125)>>>0),0!=c&&(b=Math.max(b,256)),c=a.Ia,a.Ia=new Uint8Array(b),0<a.La&&a.Ia.set(c.subarray(0,a.La),0))},tb:function(a,b){if(a.La!=b)if(0==b)a.Ia=null,a.La=0;else{if(!a.Ia||a.Ia.subarray){var c=a.Ia;a.Ia=new Uint8Array(b);c&&a.Ia.set(c.subarray(0,Math.min(b,a.La)))}else if(a.Ia||(a.Ia=[]),a.Ia.length>b)a.Ia.length=b;
else for(;a.Ia.length<b;)a.Ia.push(0);a.La=b}},Ja:{Ra:function(a){var b={};b.dev=8192===(a.mode&61440)?a.id:1;b.ino=a.id;b.mode=a.mode;b.nlink=1;b.uid=0;b.gid=0;b.rdev=a.rdev;16384===(a.mode&61440)?b.size=4096:32768===(a.mode&61440)?b.size=a.La:40960===(a.mode&61440)?b.size=a.link.length:b.size=0;b.atime=new Date(a.timestamp);b.mtime=new Date(a.timestamp);b.ctime=new Date(a.timestamp);b.nb=4096;b.blocks=Math.ceil(b.size/b.nb);return b},Oa:function(a,b){void 0!==b.mode&&(a.mode=b.mode);void 0!==b.timestamp&&
(a.timestamp=b.timestamp);void 0!==b.size&&N.tb(a,b.size)},lookup:function(){throw mb[44];},Wa:function(a,b,c,d){return N.createNode(a,b,c,d)},rename:function(a,b,c){if(16384===(a.mode&61440)){try{var d=nb(b,c)}catch(g){}if(d)for(var f in d.Ia)throw new M(55);}delete a.parent.Ia[a.name];a.name=c;b.Ia[c]=a;a.parent=b},unlink:function(a,b){delete a.Ia[b]},rmdir:function(a,b){var c=nb(a,b),d;for(d in c.Ia)throw new M(55);delete a.Ia[b]},readdir:function(a){var b=[".",".."],c;for(c in a.Ia)a.Ia.hasOwnProperty(c)&&
b.push(c);return b},symlink:function(a,b,c){a=N.createNode(a,b,41471,0);a.link=c;return a},readlink:function(a){if(40960!==(a.mode&61440))throw new M(28);return a.link}},Ka:{read:function(a,b,c,d,f){var g=a.node.Ia;if(f>=a.node.La)return 0;a=Math.min(a.node.La-f,d);if(8<a&&g.subarray)b.set(g.subarray(f,f+a),c);else for(d=0;d<a;d++)b[c+d]=g[f+d];return a},write:function(a,b,c,d,f,g){b.buffer===F.buffer&&(g=!1);if(!d)return 0;a=a.node;a.timestamp=Date.now();if(b.subarray&&(!a.Ia||a.Ia.subarray)){if(g)return a.Ia=
b.subarray(c,c+d),a.La=d;if(0===a.La&&0===f)return a.Ia=b.slice(c,c+d),a.La=d;if(f+d<=a.La)return a.Ia.set(b.subarray(c,c+d),f),d}N.fb(a,f+d);if(a.Ia.subarray&&b.subarray)a.Ia.set(b.subarray(c,c+d),f);else for(g=0;g<d;g++)a.Ia[f+g]=b[c+g];a.La=Math.max(a.La,f+d);return d},Ta:function(a,b,c){1===c?b+=a.position:2===c&&32768===(a.node.mode&61440)&&(b+=a.node.La);if(0>b)throw new M(28);return b},cb:function(a,b,c){N.fb(a.node,b+c);a.node.La=Math.max(a.node.La,b+c)},jb:function(a,b,c,d,f,g){assert(0===
b);if(32768!==(a.node.mode&61440))throw new M(43);a=a.node.Ia;if(g&2||a.buffer!==E){if(0<d||d+c<a.length)a.subarray?a=a.subarray(d,d+c):a=Array.prototype.slice.call(a,d,d+c);d=!0;g=16384*Math.ceil(c/16384);for(b=ob(g);c<g;)F[b+c++]=0;c=b;if(!c)throw new M(48);F.set(a,c)}else d=!1,c=a.byteOffset;return{Cb:c,wb:d}},lb:function(a,b,c,d,f){if(32768!==(a.node.mode&61440))throw new M(43);if(f&2)return 0;N.Ka.write(a,b,0,d,c,!1);return 0}}},pb=null,qb={},rb=[],sb=1,tb=null,ub=!0,vb={},M=null,mb={};
function O(a,b){a=db("/",a);b=b||{};if(!a)return{path:"",node:null};var c={hb:!0,ab:0},d;for(d in c)void 0===b[d]&&(b[d]=c[d]);if(8<b.ab)throw new M(32);a=$a(a.split("/").filter(function(h){return!!h}),!1);var f=pb;c="/";for(d=0;d<a.length;d++){var g=d===a.length-1;if(g&&b.parent)break;f=nb(f,a[d]);c=ab(c+"/"+a[d]);f.Xa&&(!g||g&&b.hb)&&(f=f.Xa.root);if(!g||b.gb)for(g=0;40960===(f.mode&61440);)if(f=wb(c),c=db(bb(c),f),f=O(c,{ab:b.ab}).node,40<g++)throw new M(32);}return{path:c,node:f}}
function xb(a){for(var b;;){if(a===a.parent)return a=a.Pa.kb,b?"/"!==a[a.length-1]?a+"/"+b:a+b:a;b=b?a.name+"/"+b:a.name;a=a.parent}}function yb(a,b){for(var c=0,d=0;d<b.length;d++)c=(c<<5)-c+b.charCodeAt(d)|0;return(a+c>>>0)%tb.length}function nb(a,b){var c;if(c=(c=zb(a,"x"))?c:a.Ja.lookup?0:2)throw new M(c,a);for(c=tb[yb(a.id,b)];c;c=c.sb){var d=c.name;if(c.parent.id===a.id&&d===b)return c}return a.Ja.lookup(a,b)}
function lb(a,b,c,d){a=new Ab(a,b,c,d);b=yb(a.parent.id,a.name);a.sb=tb[b];return tb[b]=a}var Bb={r:0,rs:1052672,"r+":2,w:577,wx:705,xw:705,"w+":578,"wx+":706,"xw+":706,a:1089,ax:1217,xa:1217,"a+":1090,"ax+":1218,"xa+":1218};function Cb(a){var b=["r","w","rw"][a&3];a&512&&(b+="w");return b}function zb(a,b){if(ub)return 0;if(-1===b.indexOf("r")||a.mode&292){if(-1!==b.indexOf("w")&&!(a.mode&146)||-1!==b.indexOf("x")&&!(a.mode&73))return 2}else return 2;return 0}
function Db(a,b){try{return nb(a,b),20}catch(c){}return zb(a,"wx")}function Eb(a){var b=4096;for(a=a||0;a<=b;a++)if(!rb[a])return a;throw new M(33);}function Fb(a,b){Gb||(Gb=function(){},Gb.prototype={});var c=new Gb,d;for(d in a)c[d]=a[d];a=c;b=Eb(b);a.fd=b;return rb[b]=a}var kb={open:function(a){a.Ka=qb[a.node.rdev].Ka;a.Ka.open&&a.Ka.open(a)},Ta:function(){throw new M(70);}};function gb(a,b){qb[a]={Ka:b}}
function Hb(a,b){var c="/"===b,d=!b;if(c&&pb)throw new M(10);if(!c&&!d){var f=O(b,{hb:!1});b=f.path;f=f.node;if(f.Xa)throw new M(10);if(16384!==(f.mode&61440))throw new M(54);}b={type:a,Bb:{},kb:b,rb:[]};a=a.Pa(b);a.Pa=b;b.root=a;c?pb=a:f&&(f.Xa=b,f.Pa&&f.Pa.rb.push(b))}function Ib(a,b,c){var d=O(a,{parent:!0}).node;a=cb(a);if(!a||"."===a||".."===a)throw new M(28);var f=Db(d,a);if(f)throw new M(f);if(!d.Ja.Wa)throw new M(63);return d.Ja.Wa(d,a,b,c)}function P(a){Ib(a,16895,0)}
function Jb(a,b,c){"undefined"===typeof c&&(c=b,b=438);Ib(a,b|8192,c)}function Kb(a,b){if(!db(a))throw new M(44);var c=O(b,{parent:!0}).node;if(!c)throw new M(44);b=cb(b);var d=Db(c,b);if(d)throw new M(d);if(!c.Ja.symlink)throw new M(63);c.Ja.symlink(c,b,a)}function wb(a){a=O(a).node;if(!a)throw new M(44);if(!a.Ja.readlink)throw new M(28);return db(xb(a.parent),a.Ja.readlink(a))}
function Lb(a,b,c,d){if(""===a)throw new M(44);if("string"===typeof b){var f=Bb[b];if("undefined"===typeof f)throw Error("Unknown file open mode: "+b);b=f}c=b&64?("undefined"===typeof c?438:c)&4095|32768:0;if("object"===typeof a)var g=a;else{a=ab(a);try{g=O(a,{gb:!(b&131072)}).node}catch(k){}}f=!1;if(b&64)if(g){if(b&128)throw new M(20);}else g=Ib(a,c,0),f=!0;if(!g)throw new M(44);8192===(g.mode&61440)&&(b&=-513);if(b&65536&&16384!==(g.mode&61440))throw new M(54);if(!f&&(c=g?40960===(g.mode&61440)?
32:16384===(g.mode&61440)&&("r"!==Cb(b)||b&512)?31:zb(g,Cb(b)):44))throw new M(c);if(b&512){c=g;var h;"string"===typeof c?h=O(c,{gb:!0}).node:h=c;if(!h.Ja.Oa)throw new M(63);if(16384===(h.mode&61440))throw new M(31);if(32768!==(h.mode&61440))throw new M(28);if(c=zb(h,"w"))throw new M(c);h.Ja.Oa(h,{size:0,timestamp:Date.now()})}b&=-131713;d=Fb({node:g,path:xb(g),flags:b,seekable:!0,position:0,Ka:g.Ka,vb:[],error:!1},d);d.Ka.open&&d.Ka.open(d);!e.logReadFiles||b&1||(Mb||(Mb={}),a in Mb||(Mb[a]=1,y("FS.trackingDelegate error on read file: "+
a)));try{vb.onOpenFile&&(g=0,1!==(b&2097155)&&(g|=1),0!==(b&2097155)&&(g|=2),vb.onOpenFile(a,g))}catch(k){y("FS.trackingDelegate['onOpenFile']('"+a+"', flags) threw an exception: "+k.message)}return d}function Nb(a,b,c){if(null===a.fd)throw new M(8);if(!a.seekable||!a.Ka.Ta)throw new M(70);if(0!=c&&1!=c&&2!=c)throw new M(28);a.position=a.Ka.Ta(a,b,c);a.vb=[]}
function Ob(){M||(M=function(a,b){this.node=b;this.ub=function(c){this.Sa=c};this.ub(a);this.message="FS error"},M.prototype=Error(),M.prototype.constructor=M,[44].forEach(function(a){mb[a]=new M(a);mb[a].stack="<generic error, no stack>"}))}var Pb;function Qb(a,b){var c=0;a&&(c|=365);b&&(c|=146);return c}
function Rb(a,b,c){a=ab("/dev/"+a);var d=Qb(!!b,!!c);Sb||(Sb=64);var f=Sb++<<8|0;gb(f,{open:function(g){g.seekable=!1},close:function(){c&&c.buffer&&c.buffer.length&&c(10)},read:function(g,h,k,m){for(var n=0,r=0;r<m;r++){try{var t=b()}catch(v){throw new M(29);}if(void 0===t&&0===n)throw new M(6);if(null===t||void 0===t)break;n++;h[k+r]=t}n&&(g.node.timestamp=Date.now());return n},write:function(g,h,k,m){for(var n=0;n<m;n++)try{c(h[k+n])}catch(r){throw new M(29);}m&&(g.node.timestamp=Date.now());return n}});
Jb(a,d,f)}var Sb,Q={},Gb,Mb,Tb=void 0;function Ub(){Tb+=4;return D[Tb-4>>2]}function Vb(a){a=rb[a];if(!a)throw new M(8);return a}function Wb(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 Yb=void 0;function R(a){for(var b="";B[a];)b+=Yb[B[a++]];return b}var Zb={},S={},$b={};function ac(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 bc(a,b){a=ac(a);return(new Function("body","return function "+a+'() {\n "use strict"; return body.apply(this, arguments);\n};\n'))(b)}function cc(a){var b=Error,c=bc(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 dc=void 0;function T(a){throw new dc(a);}var ec=void 0;function fc(a,b){function c(k){k=b(k);if(k.length!==d.length)throw new ec("Mismatched type converter count");for(var m=0;m<d.length;++m)U(d[m],k[m])}var d=[];d.forEach(function(k){$b[k]=a});var f=Array(a.length),g=[],h=0;a.forEach(function(k,m){S.hasOwnProperty(k)?f[m]=S[k]:(g.push(k),Zb.hasOwnProperty(k)||(Zb[k]=[]),Zb[k].push(function(){f[m]=S[k];++h;h===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(S.hasOwnProperty(a)){if(c.pb)return;T("Cannot register type '"+d+"' twice")}S[a]=b;delete $b[a];Zb.hasOwnProperty(a)&&(b=Zb[a],delete Zb[a],b.forEach(function(f){f()}))}var hc=[],V=[{},{value:void 0},{value:null},{value:!0},{value:!1}];
function ic(a){4<a&&0===--V[a].bb&&(V[a]=void 0,hc.push(a))}function jc(a){switch(a){case void 0:return 1;case null:return 2;case !0:return 3;case !1:return 4;default:var b=hc.length?hc.pop():V.length;V[b]={bb:1,value:a};return b}}function kc(a){return this.fromWireType(I[a>>2])}function lc(a){if(null===a)return"null";var b=typeof a;return"object"===b||"array"===b||"function"===b?a.toString():""+a}
function mc(a,b){switch(b){case 2:return function(c){return this.fromWireType(Ca[c>>2])};case 3:return function(c){return this.fromWireType(Da[c>>3])};default:throw new TypeError("Unknown float type: "+a);}}function nc(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=bc(b.name||"unknownFunctionName",function(){});c.prototype=b.prototype;c=new c;a=b.apply(c,a);return a instanceof Object?a:c}
function oc(a){for(;a.length;){var b=a.pop();a.pop()(b)}}function pc(a,b){var c=e;if(void 0===c[a].Na){var d=c[a];c[a]=function(){c[a].Na.hasOwnProperty(arguments.length)||T("Function '"+b+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+c[a].Na+")!");return c[a].Na[arguments.length].apply(this,arguments)};c[a].Na=[];c[a].Na[d.mb]=d}}
function qc(a,b,c){e.hasOwnProperty(a)?((void 0===c||void 0!==e[a].Na&&void 0!==e[a].Na[c])&&T("Cannot register public name '"+a+"' twice"),pc(a,a),e.hasOwnProperty(c)&&T("Cannot register multiple overloads of a function with the same number of arguments ("+c+")!"),e[a].Na[c]=b):(e[a]=b,void 0!==c&&(e[a].Ab=c))}function rc(a,b){for(var c=[],d=0;d<a;d++)c.push(D[(b>>2)+d]);return c}
function sc(a,b){a=R(a);var c=e["dynCall_"+a];for(var d=[],f=1;f<a.length;++f)d.push("a"+f);f="return function dynCall_"+(a+"_"+b)+"("+d.join(", ")+") {\n";f+=" return dynCall(rawFunction"+(d.length?", ":"")+d.join(", ")+");\n";c=(new Function("dynCall","rawFunction",f+"};\n"))(c,b);"function"!==typeof c&&T("unknown function pointer with signature "+a+": "+b);return c}var tc=void 0;function uc(a){a=vc(a);var b=R(a);W(a);return b}
function wc(a,b){function c(g){f[g]||S[g]||($b[g]?$b[g].forEach(c):(d.push(g),f[g]=!0))}var d=[],f={};b.forEach(c);throw new tc(a+": "+d.map(uc).join([", "]));}function xc(a,b,c){switch(b){case 0:return c?function(d){return F[d]}:function(d){return B[d]};case 1:return c?function(d){return C[d>>1]}:function(d){return wa[d>>1]};case 2:return c?function(d){return D[d>>2]}:function(d){return I[d>>2]};default:throw new TypeError("Unknown integer type: "+a);}}var yc={};
function zc(){return"object"===typeof globalThis?globalThis:Function("return this")()}function Ac(a,b){var c=S[a];void 0===c&&T(b+" has unknown type "+uc(a));return c}var Bc={};function Ab(a,b,c,d){a||(a=this);this.parent=a;this.Pa=a.Pa;this.Xa=null;this.id=sb++;this.name=b;this.mode=c;this.Ja={};this.Ka={};this.rdev=d}
Object.defineProperties(Ab.prototype,{read:{get:function(){return 365===(this.mode&365)},set:function(a){a?this.mode|=365:this.mode&=-366}},write:{get:function(){return 146===(this.mode&146)},set:function(a){a?this.mode|=146:this.mode&=-147}}});Ob();tb=Array(4096);Hb(N,"/");P("/tmp");P("/home");P("/home/web_user");
(function(){P("/dev");gb(259,{read:function(){return 0},write:function(d,f,g,h){return h}});Jb("/dev/null",259);fb(1280,ib);fb(1536,jb);Jb("/dev/tty",1280);Jb("/dev/tty1",1536);if("object"===typeof crypto&&"function"===typeof crypto.getRandomValues){var a=new Uint8Array(1);var b=function(){crypto.getRandomValues(a);return a[0]}}else if(fa)try{var c=require("crypto");b=function(){return c.randomBytes(1)[0]}}catch(d){}b||(b=function(){w("random_device")});Rb("random",b);Rb("urandom",b);P("/dev/shm");
P("/dev/shm/tmp")})();P("/proc");P("/proc/self");P("/proc/self/fd");Hb({Pa:function(){var a=lb("/proc/self","fd",16895,73);a.Ja={lookup:function(b,c){var d=rb[+c];if(!d)throw new M(8);b={parent:null,Pa:{kb:"fake"},Ja:{readlink:function(){return d.path}}};return b.parent=b}};return a}},"/proc/self/fd");for(var Cc=Array(256),Dc=0;256>Dc;++Dc)Cc[Dc]=String.fromCharCode(Dc);Yb=Cc;dc=e.BindingError=cc("BindingError");ec=e.InternalError=cc("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};tc=e.UnboundTypeError=cc("UnboundTypeError");
var Rc={A:function(a){return ob(a)},x:function(){},z:function(a){"uncaught_exception"in Za?Za.Va++:Za.Va=1;throw a;},t:function(a,b,c){Tb=c;try{var d=Vb(a);switch(b){case 0:var f=Ub();return 0>f?-28:Lb(d.path,d.flags,0,f).fd;case 1:case 2:return 0;case 3:return d.flags;case 4:return f=Ub(),d.flags|=f,0;case 12:return f=Ub(),C[f+0>>1]=2,0;case 13:case 14:return 0;case 16:case 8:return-28;case 9:return D[Ec()>>2]=28,-1;default:return-28}}catch(g){return"undefined"!==typeof Q&&g instanceof M||w(g),-g.Sa}},
M:function(a,b,c){Tb=c;try{var d=Vb(a);switch(b){case 21509:case 21505:return d.tty?0:-59;case 21510:case 21511:case 21512:case 21506:case 21507:case 21508:return d.tty?0:-59;case 21519:if(!d.tty)return-59;var f=Ub();return D[f>>2]=0;case 21520:return d.tty?-28:-59;case 21531:a=f=Ub();if(!d.Ka.qb)throw new M(59);return d.Ka.qb(d,b,a);case 21523:return d.tty?0:-59;case 21524:return d.tty?0:-59;default:w("bad ioctl syscall "+b)}}catch(g){return"undefined"!==typeof Q&&g instanceof M||w(g),-g.Sa}},N:function(a,
b,c){Tb=c;try{var d=a?A(B,a,void 0):"",f=Ub();return Lb(d,b,f).fd}catch(g){return"undefined"!==typeof Q&&g instanceof M||w(g),-g.Sa}},P:function(a,b,c,d,f){var g=Wb(c);b=R(b);U(a,{name:b,fromWireType:function(h){return!!h},toWireType:function(h,k){return k?d:f},argPackAdvance:8,readValueFromPointer:function(h){if(1===c)var k=F;else if(2===c)k=C;else if(4===c)k=D;else throw new TypeError("Unknown boolean type size: "+b);return this.fromWireType(k[h>>g])},Qa:null})},O:function(a,b){b=R(b);U(a,{name:b,
fromWireType:function(c){var d=V[c].value;ic(c);return d},toWireType:function(c,d){return jc(d)},argPackAdvance:8,readValueFromPointer:kc,Qa:null})},v:function(a,b,c){c=Wb(c);b=R(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 "'+lc(f)+'" to '+this.name);return f},argPackAdvance:8,readValueFromPointer:mc(b,c),Qa:null})},B:function(a,b,c,d,f,g){var h=rc(b,c);a=R(a);f=sc(d,f);qc(a,function(){wc("Cannot call "+
a+" due to unbound types",h)},b-1);fc(h,function(k){var m=[k[0],null].concat(k.slice(1)),n=k=a,r=f,t=m.length;2>t&&T("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var v=null!==m[1]&&!1,x=!1,p=1;p<m.length;++p)if(null!==m[p]&&void 0===m[p].Qa){x=!0;break}var G="void"!==m[0].name,H="",da="";for(p=0;p<t-2;++p)H+=(0!==p?", ":"")+"arg"+p,da+=(0!==p?", ":"")+"arg"+p+"Wired";n="return function "+ac(n)+"("+H+") {\nif (arguments.length !== "+(t-2)+") {\nthrowBindingError('function "+
n+" called with ' + arguments.length + ' arguments, expected "+(t-2)+" args!');\n}\n";x&&(n+="var destructors = [];\n");var Xb=x?"destructors":"null";H="throwBindingError invoker fn runDestructors retType classParam".split(" ");r=[T,r,g,oc,m[0],m[1]];v&&(n+="var thisWired = classParam.toWireType("+Xb+", this);\n");for(p=0;p<t-2;++p)n+="var arg"+p+"Wired = argType"+p+".toWireType("+Xb+", arg"+p+"); // "+m[p+2].name+"\n",H.push("argType"+p),r.push(m[p+2]);v&&(da="thisWired"+(0<da.length?", ":"")+da);
n+=(G?"var rv = ":"")+"invoker(fn"+(0<da.length?", ":"")+da+");\n";if(x)n+="runDestructors(destructors);\n";else for(p=v?1:2;p<m.length;++p)t=1===p?"thisWired":"arg"+(p-2)+"Wired",null!==m[p].Qa&&(n+=t+"_dtor("+t+"); // "+m[p].name+"\n",H.push(t+"_dtor"),r.push(m[p].Qa));G&&(n+="var ret = retType.fromWireType(rv);\nreturn ret;\n");H.push(n+"}\n");m=nc(H).apply(null,r);p=b-1;if(!e.hasOwnProperty(k))throw new ec("Replacing nonexistant public symbol");void 0!==e[k].Na&&void 0!==p?e[k].Na[p]=m:(e[k]=
m,e[k].mb=p);return[]})},i:function(a,b,c,d,f){function g(n){return n}b=R(b);-1===f&&(f=4294967295);var h=Wb(c);if(0===d){var k=32-8*c;g=function(n){return n<<k>>>k}}var m=-1!=b.indexOf("unsigned");U(a,{name:b,fromWireType:g,toWireType:function(n,r){if("number"!==typeof r&&"boolean"!==typeof r)throw new TypeError('Cannot convert "'+lc(r)+'" to '+this.name);if(r<d||r>f)throw new TypeError('Passing a number "'+lc(r)+'" from JS side to C/C++ side to an argument of type "'+b+'", which is outside the valid range ['+
d+", "+f+"]!");return m?r>>>0:r|0},argPackAdvance:8,readValueFromPointer:xc(b,h,0!==d),Qa:null})},f:function(a,b,c){function d(g){g>>=2;var h=I;return new f(E,h[g+1],h[g])}var f=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][b];c=R(c);U(a,{name:c,fromWireType:d,argPackAdvance:8,readValueFromPointer:d},{pb:!0})},w:function(a,b){b=R(b);var c="std::string"===b;U(a,{name:b,fromWireType:function(d){var f=I[d>>2];if(c)for(var g=d+4,h=0;h<=f;++h){var k=d+4+
h;if(h==f||0==B[k]){g=g?A(B,g,k-g):"";if(void 0===m)var m=g;else m+=String.fromCharCode(0),m+=g;g=k+1}}else{m=Array(f);for(h=0;h<f;++h)m[h]=String.fromCharCode(B[d+4+h]);m=m.join("")}W(d);return m},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 h=(c&&g?function(){return ta(f)}:function(){return f.length})(),k=ob(4+h+
1);I[k>>2]=h;if(c&&g)sa(f,B,k+4,h+1);else if(g)for(g=0;g<h;++g){var m=f.charCodeAt(g);255<m&&(W(k),T("String has UTF-16 code units that do not fit in 8 bits"));B[k+4+g]=m}else for(g=0;g<h;++g)B[k+4+g]=f[g];null!==d&&d.push(W,k);return k},argPackAdvance:8,readValueFromPointer:kc,Qa:function(d){W(d)}})},n:function(a,b,c){c=R(c);if(2===b){var d=va;var f=xa;var g=ya;var h=function(){return wa};var k=1}else 4===b&&(d=za,f=Aa,g=Ba,h=function(){return I},k=2);U(a,{name:c,fromWireType:function(m){for(var n=
I[m>>2],r=h(),t,v=m+4,x=0;x<=n;++x){var p=m+4+x*b;if(x==n||0==r[p>>k])v=d(v,p-v),void 0===t?t=v:(t+=String.fromCharCode(0),t+=v),v=p+b}W(m);return t},toWireType:function(m,n){"string"!==typeof n&&T("Cannot pass non-string to C++ string type "+c);var r=g(n),t=ob(4+r+b);I[t>>2]=r>>k;f(n,t+4,r+b);null!==m&&m.push(W,t);return t},argPackAdvance:8,readValueFromPointer:kc,Qa:function(m){W(m)}})},y:function(a,b){b=R(b);U(a,{zb:!0,name:b,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},
s:ic,Q:function(a){if(0===a)return jc(zc());var b=yc[a];a=void 0===b?R(a):b;return jc(zc()[a])},F:function(a){4<a&&(V[a].bb+=1)},q:function(a,b,c,d){a||T("Cannot use deleted val. handle = "+a);a=V[a].value;var f=Bc[b];if(!f){f="";for(var g=0;g<b;++g)f+=(0!==g?", ":"")+"arg"+g;var h="return function emval_allocator_"+b+"(constructor, argTypes, args) {\n";for(g=0;g<b;++g)h+="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",h+("var obj = new constructor("+f+");\nreturn __emval_register(obj);\n}\n")))(Ac,e,jc);Bc[b]=f}return f(a,c,d)},o:function(){w()},d:function(a,b){X(a,b||1);throw"longjmp";},K:function(a,b,c){B.copyWithin(a,b,b+c)},j:function(a){a>>>=0;var b=B.length;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(16777216,
a,d);0<d%65536&&(d+=65536-d%65536);a:{try{z.grow(Math.min(2147483648,d)-E.byteLength+65535>>>16);Ea(z.buffer);var f=1;break a}catch(g){}f=void 0}if(f)return!0}return!1},u:function(a){try{var b=Vb(a);if(null===b.fd)throw new M(8);b.Za&&(b.Za=null);try{b.Ka.close&&b.Ka.close(b)}catch(c){throw c;}finally{rb[b.fd]=null}b.fd=null;return 0}catch(c){return"undefined"!==typeof Q&&c instanceof M||w(c),c.Sa}},L:function(a,b,c,d){try{a:{for(var f=Vb(a),g=a=0;g<c;g++){var h=D[b+(8*g+4)>>2],k=f,m=D[b+8*g>>2],
n=h,r=void 0,t=F;if(0>n||0>r)throw new M(28);if(null===k.fd)throw new M(8);if(1===(k.flags&2097155))throw new M(8);if(16384===(k.node.mode&61440))throw new M(31);if(!k.Ka.read)throw new M(28);var v="undefined"!==typeof r;if(!v)r=k.position;else if(!k.seekable)throw new M(70);var x=k.Ka.read(k,t,m,n,r);v||(k.position+=x);var p=x;if(0>p){var G=-1;break a}a+=p;if(p<h)break}G=a}D[d>>2]=G;return 0}catch(H){return"undefined"!==typeof Q&&H instanceof M||w(H),H.Sa}},G:function(a,b,c,d,f){try{var g=Vb(a);
a=4294967296*c+(b>>>0);if(-9007199254740992>=a||9007199254740992<=a)return-61;Nb(g,a,d);Xa=[g.position>>>0,(L=g.position,1<=+Ma(L)?0<L?(Pa(+Oa(L/4294967296),4294967295)|0)>>>0:~~+Na((L-+(~~L>>>0))/4294967296)>>>0:0)];D[f>>2]=Xa[0];D[f+4>>2]=Xa[1];g.Za&&0===a&&0===d&&(g.Za=null);return 0}catch(h){return"undefined"!==typeof Q&&h instanceof M||w(h),h.Sa}},r:function(a,b,c,d){try{a:{for(var f=Vb(a),g=a=0;g<c;g++){var h=f,k=D[b+8*g>>2],m=D[b+(8*g+4)>>2],n=void 0,r=F;if(0>m||0>n)throw new M(28);if(null===
h.fd)throw new M(8);if(0===(h.flags&2097155))throw new M(8);if(16384===(h.node.mode&61440))throw new M(31);if(!h.Ka.write)throw new M(28);h.seekable&&h.flags&1024&&Nb(h,0,2);var t="undefined"!==typeof n;if(!t)n=h.position;else if(!h.seekable)throw new M(70);var v=h.Ka.write(h,r,k,m,n,void 0);t||(h.position+=v);try{if(h.path&&vb.onWriteToFile)vb.onWriteToFile(h.path)}catch(G){y("FS.trackingDelegate['onWriteToFile']('"+h.path+"') threw an exception: "+G.message)}var x=v;if(0>x){var p=-1;break a}a+=
x}p=a}D[d>>2]=p;return 0}catch(G){return"undefined"!==typeof Q&&G instanceof M||w(G),G.Sa}},a:function(){return na|0},m:Fc,e:Gc,I:Hc,p:Ic,H:Jc,D:Kc,C:Lc,E:Mc,J:Nc,k:Oc,l:Pc,c:Qc,memory:z,g:function(a){a=+a;return 0<=a?+Oa(a+.5):+Na(a-.5)},h:function(a){a=+a;return 0<=a?+Oa(a+.5):+Na(a-.5)},b:function(a){na=a|0},table:pa};
(function(){function a(f){e.asm=f.exports;J--;e.monitorRunDependencies&&e.monitorRunDependencies(J);0==J&&(null!==Qa&&(clearInterval(Qa),Qa=null),Ra&&(f=Ra,Ra=null,f()))}function b(f){a(f.instance)}function c(f){return Wa().then(function(g){return WebAssembly.instantiate(g,d)}).then(f,function(g){y("failed to asynchronously prepare wasm: "+g);w(g)})}var d={a:Rc};J++;e.monitorRunDependencies&&e.monitorRunDependencies(J);if(e.instantiateWasm)try{return e.instantiateWasm(d,a)}catch(f){return y("Module.instantiateWasm callback failed with error: "+
f),!1}(function(){if(oa||"function"!==typeof WebAssembly.instantiateStreaming||Ta()||Sa("file://")||"function"!==typeof fetch)return c(b);fetch(K,{credentials:"same-origin"}).then(function(f){return WebAssembly.instantiateStreaming(f,d).then(b,function(g){y("wasm streaming compile failed: "+g);y("falling back to ArrayBuffer instantiation");return c(b)})})})();return{}})();
var Ya=e.___wasm_call_ctors=function(){return(Ya=e.___wasm_call_ctors=e.asm.R).apply(null,arguments)},ob=e._malloc=function(){return(ob=e._malloc=e.asm.S).apply(null,arguments)},W=e._free=function(){return(W=e._free=e.asm.T).apply(null,arguments)},vc=e.___getTypeName=function(){return(vc=e.___getTypeName=e.asm.U).apply(null,arguments)};e.___embind_register_native_and_builtin_types=function(){return(e.___embind_register_native_and_builtin_types=e.asm.V).apply(null,arguments)};
var Ec=e.___errno_location=function(){return(Ec=e.___errno_location=e.asm.W).apply(null,arguments)},X=e._setThrew=function(){return(X=e._setThrew=e.asm.X).apply(null,arguments)},Y=e.stackSave=function(){return(Y=e.stackSave=e.asm.Y).apply(null,arguments)},Z=e.stackRestore=function(){return(Z=e.stackRestore=e.asm.Z).apply(null,arguments)},Sc=e.dynCall_v=function(){return(Sc=e.dynCall_v=e.asm._).apply(null,arguments)},Tc=e.dynCall_vi=function(){return(Tc=e.dynCall_vi=e.asm.$).apply(null,arguments)},
Uc=e.dynCall_vii=function(){return(Uc=e.dynCall_vii=e.asm.aa).apply(null,arguments)};e.dynCall_viii=function(){return(e.dynCall_viii=e.asm.ba).apply(null,arguments)};var Vc=e.dynCall_viiii=function(){return(Vc=e.dynCall_viiii=e.asm.ca).apply(null,arguments)},Wc=e.dynCall_ii=function(){return(Wc=e.dynCall_ii=e.asm.da).apply(null,arguments)},Xc=e.dynCall_iii=function(){return(Xc=e.dynCall_iii=e.asm.ea).apply(null,arguments)};e.dynCall_iiii=function(){return(e.dynCall_iiii=e.asm.fa).apply(null,arguments)};
var Yc=e.dynCall_iiiii=function(){return(Yc=e.dynCall_iiiii=e.asm.ga).apply(null,arguments)},Zc=e.dynCall_iiiiiiiii=function(){return(Zc=e.dynCall_iiiiiiiii=e.asm.ha).apply(null,arguments)},$c=e.dynCall_iiiiiiiiii=function(){return($c=e.dynCall_iiiiiiiiii=e.asm.ia).apply(null,arguments)},ad=e.dynCall_iiiijj=function(){return(ad=e.dynCall_iiiijj=e.asm.ja).apply(null,arguments)},bd=e.dynCall_ij=function(){return(bd=e.dynCall_ij=e.asm.ka).apply(null,arguments)},cd=e.dynCall_jjij=function(){return(cd=
e.dynCall_jjij=e.asm.la).apply(null,arguments)};e.dynCall_viiiiii=function(){return(e.dynCall_viiiiii=e.asm.ma).apply(null,arguments)};e.dynCall_viiiii=function(){return(e.dynCall_viiiii=e.asm.na).apply(null,arguments)};e.dynCall_viiiiiiii=function(){return(e.dynCall_viiiiiiii=e.asm.oa).apply(null,arguments)};e.dynCall_viiiiiiiiiii=function(){return(e.dynCall_viiiiiiiiiii=e.asm.pa).apply(null,arguments)};e.dynCall_viiiiiiiiiiii=function(){return(e.dynCall_viiiiiiiiiiii=e.asm.qa).apply(null,arguments)};
e.dynCall_viiiiiii=function(){return(e.dynCall_viiiiiii=e.asm.ra).apply(null,arguments)};e.dynCall_viiiiiiiii=function(){return(e.dynCall_viiiiiiiii=e.asm.sa).apply(null,arguments)};e.dynCall_iiiiii=function(){return(e.dynCall_iiiiii=e.asm.ta).apply(null,arguments)};e.dynCall_jiiiiiiiii=function(){return(e.dynCall_jiiiiiiiii=e.asm.ua).apply(null,arguments)};e.dynCall_iiiiiii=function(){return(e.dynCall_iiiiiii=e.asm.va).apply(null,arguments)};
e.dynCall_iiiiiiii=function(){return(e.dynCall_iiiiiiii=e.asm.wa).apply(null,arguments)};e.dynCall_iiiiiiiiiiii=function(){return(e.dynCall_iiiiiiiiiiii=e.asm.xa).apply(null,arguments)};e.dynCall_jiji=function(){return(e.dynCall_jiji=e.asm.ya).apply(null,arguments)};e.dynCall_iidiiii=function(){return(e.dynCall_iidiiii=e.asm.za).apply(null,arguments)};e.dynCall_i=function(){return(e.dynCall_i=e.asm.Aa).apply(null,arguments)};
e.dynCall_viiiiiiiiii=function(){return(e.dynCall_viiiiiiiiii=e.asm.Ba).apply(null,arguments)};e.dynCall_viiiiiiiiiiiii=function(){return(e.dynCall_viiiiiiiiiiiii=e.asm.Ca).apply(null,arguments)};e.dynCall_jiiiiiiii=function(){return(e.dynCall_jiiiiiiii=e.asm.Da).apply(null,arguments)};e.dynCall_ff=function(){return(e.dynCall_ff=e.asm.Ea).apply(null,arguments)};e.dynCall_jiiiiii=function(){return(e.dynCall_jiiiiii=e.asm.Fa).apply(null,arguments)};
e.dynCall_jiiiii=function(){return(e.dynCall_jiiiii=e.asm.Ga).apply(null,arguments)};e.dynCall_iiijii=function(){return(e.dynCall_iiijii=e.asm.Ha).apply(null,arguments)};function Pc(a,b,c){var d=Y();try{Uc(a,b,c)}catch(f){Z(d);if(f!==f+0&&"longjmp"!==f)throw f;X(1,0)}}function Qc(a,b,c,d,f){var g=Y();try{Vc(a,b,c,d,f)}catch(h){Z(g);if(h!==h+0&&"longjmp"!==h)throw h;X(1,0)}}function Gc(a,b,c){var d=Y();try{return Xc(a,b,c)}catch(f){Z(d);if(f!==f+0&&"longjmp"!==f)throw f;X(1,0)}}
function Oc(a,b){var c=Y();try{Tc(a,b)}catch(d){Z(c);if(d!==d+0&&"longjmp"!==d)throw d;X(1,0)}}function Nc(a){var b=Y();try{Sc(a)}catch(c){Z(b);if(c!==c+0&&"longjmp"!==c)throw c;X(1,0)}}function Fc(a,b){var c=Y();try{return Wc(a,b)}catch(d){Z(c);if(d!==d+0&&"longjmp"!==d)throw d;X(1,0)}}function Hc(a,b,c,d,f){var g=Y();try{return Yc(a,b,c,d,f)}catch(h){Z(g);if(h!==h+0&&"longjmp"!==h)throw h;X(1,0)}}
function Jc(a,b,c,d,f,g,h,k,m,n){var r=Y();try{return $c(a,b,c,d,f,g,h,k,m,n)}catch(t){Z(r);if(t!==t+0&&"longjmp"!==t)throw t;X(1,0)}}function Ic(a,b,c,d,f,g,h,k,m){var n=Y();try{return Zc(a,b,c,d,f,g,h,k,m)}catch(r){Z(n);if(r!==r+0&&"longjmp"!==r)throw r;X(1,0)}}function Mc(a,b,c,d,f,g){var h=Y();try{return cd(a,b,c,d,f,g)}catch(k){Z(h);if(k!==k+0&&"longjmp"!==k)throw k;X(1,0)}}
function Kc(a,b,c,d,f,g,h,k){var m=Y();try{return ad(a,b,c,d,f,g,h,k)}catch(n){Z(m);if(n!==n+0&&"longjmp"!==n)throw n;X(1,0)}}function Lc(a,b,c){var d=Y();try{return bd(a,b,c)}catch(f){Z(d);if(f!==f+0&&"longjmp"!==f)throw f;X(1,0)}}var dd;Ra=function ed(){dd||fd();dd||(Ra=ed)};
function fd(){function a(){if(!dd&&(dd=!0,e.calledRun=!0,!qa)){e.noFSInit||Pb||(Pb=!0,Ob(),e.stdin=e.stdin,e.stdout=e.stdout,e.stderr=e.stderr,e.stdin?Rb("stdin",e.stdin):Kb("/dev/tty","/dev/stdin"),e.stdout?Rb("stdout",null,e.stdout):Kb("/dev/tty","/dev/stdout"),e.stderr?Rb("stderr",null,e.stderr):Kb("/dev/tty1","/dev/stderr"),Lb("/dev/stdin","r"),Lb("/dev/stdout","w"),Lb("/dev/stderr","w"));Ga(Ia);ub=!1;Ga(Ja);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();Ka.unshift(b)}Ga(Ka)}}if(!(0<J)){if(e.preRun)for("function"==typeof e.preRun&&(e.preRun=[e.preRun]);e.preRun.length;)La();Ga(Ha);0<J||(e.setStatus?(e.setStatus("Running..."),setTimeout(function(){setTimeout(function(){e.setStatus("")},1);a()},1)):a())}}e.run=fd;if(e.preInit)for("function"==typeof e.preInit&&(e.preInit=[e.preInit]);0<e.preInit.length;)e.preInit.pop()();noExitRuntime=!0;fd();
return avif_dec.ready
}
);
})();
if (typeof exports === 'object' && typeof module === 'object')
module.exports = avif_dec;
else if (typeof define === 'function' && define['amd'])
define([], function() { return avif_dec; });
else if (typeof exports === 'object')
exports["avif_dec"] = avif_dec;

Binary file not shown.

View File

@@ -1,37 +0,0 @@
# AVIF encoder
- Source: <https://github.com/AOMediaCodec/libavif>
- Version: v0.5.4
## Example
Run example.js
## API
### `Uint8Array encode(std::string image_in, int image_width, int image_height, AvifOptions opts)`
Encodes the given image with given dimension to AVIF. Options looks like this:
```c++
struct AvifOptions {
// 0 = lossless
// 63 = worst quality
int minQuantizer;
int maxQuantizer;
// [0 - 6]
// Creates 2^n tiles in that dimension
int tileRowsLog2;
int tileColsLog2;
// 0 = slowest
// 10 = fastest
int speed;
// 0 = 4:2:0
// 1 = 4:2:2
// 2 = 4:4:4
int subsample;
};
```

View File

@@ -1,84 +0,0 @@
#include <emscripten/bind.h>
#include <emscripten/val.h>
#include "avif/avif.h"
using namespace emscripten;
struct AvifOptions {
// [0 - 63]
// 0 = lossless
// 63 = worst quality
int minQuantizer;
int maxQuantizer;
// [0 - 6]
// Creates 2^n tiles in that dimension
int tileRowsLog2;
int tileColsLog2;
// [0 - 10]
// 0 = slowest
// 10 = fastest
int speed;
// 0 = 4:2:0
// 1 = 4:2:2
// 2 = 4:4:4
int subsample;
};
thread_local const val Uint8Array = val::global("Uint8Array");
val encode(std::string buffer, int width, int height, AvifOptions options) {
avifRWData output = AVIF_DATA_EMPTY;
int depth = 8;
avifPixelFormat format;
switch (options.subsample) {
case 0:
format = AVIF_PIXEL_FORMAT_YUV420;
break;
case 1:
format = AVIF_PIXEL_FORMAT_YUV422;
break;
case 2:
format = AVIF_PIXEL_FORMAT_YUV444;
break;
}
avifImage* image = avifImageCreate(width, height, depth, format);
uint8_t* rgba = (uint8_t*)buffer.c_str();
avifRGBImage srcRGB;
avifRGBImageSetDefaults(&srcRGB, image);
srcRGB.pixels = rgba;
srcRGB.rowBytes = width * 4;
avifImageRGBToYUV(image, &srcRGB);
avifEncoder* encoder = avifEncoderCreate();
encoder->maxThreads = 1;
encoder->minQuantizer = options.minQuantizer;
encoder->maxQuantizer = options.maxQuantizer;
encoder->tileRowsLog2 = options.tileRowsLog2;
encoder->tileColsLog2 = options.tileColsLog2;
encoder->speed = options.speed;
avifResult encodeResult = avifEncoderWrite(encoder, image, &output);
auto js_result = val::null();
if (encodeResult == AVIF_RESULT_OK) {
js_result = Uint8Array.new_(typed_memory_view(output.size, output.data));
}
avifImageDestroy(image);
avifEncoderDestroy(encoder);
avifRWDataFree(&output);
return js_result;
}
EMSCRIPTEN_BINDINGS(my_module) {
value_object<AvifOptions>("AvifOptions")
.field("minQuantizer", &AvifOptions::minQuantizer)
.field("maxQuantizer", &AvifOptions::maxQuantizer)
.field("tileRowsLog2", &AvifOptions::tileRowsLog2)
.field("tileColsLog2", &AvifOptions::tileColsLog2)
.field("speed", &AvifOptions::speed)
.field("subsample", &AvifOptions::subsample);
function("encode", &encode);
}

View File

@@ -1,7 +0,0 @@
import { EncodeOptions } from '../../../src/codecs/avif/encoder-meta';
interface AVIFModule extends EmscriptenWasm.Module {
encode(data: BufferSource, width: number, height: number, options: EncodeOptions): Uint8Array | null;
}
export default function(opts: EmscriptenWasm.ModuleOpts): AVIFModule;

View File

@@ -1,114 +0,0 @@
var avif_enc = (function() {
var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename;
return (
function(avif_enc) {
avif_enc = avif_enc || {};
var e;e||(e=typeof avif_enc !== 'undefined' ? avif_enc : {});var aa,ba;e.ready=new Promise(function(a,b){aa=a;ba=b});var ca={},m;for(m in e)e.hasOwnProperty(m)&&(ca[m]=e[m]);var da=!1,r=!1,ea=!1,fa=!1;da="object"===typeof window;r="function"===typeof importScripts;ea="object"===typeof process&&"object"===typeof process.versions&&"string"===typeof process.versions.node;fa=!da&&!ea&&!r;var u="",ha,ia,ja,ka;
if(ea)u=r?require("path").dirname(u)+"/":__dirname+"/",ha=function(a,b){ja||(ja=require("fs"));ka||(ka=require("path"));a=ka.normalize(a);return ja.readFileSync(a,b?null:"utf8")},ia=function(a){a=ha(a,!0);a.buffer||(a=new Uint8Array(a));assert(a.buffer);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",x),e.inspect=function(){return"[Emscripten Module object]"};else if(fa)"undefined"!=
typeof read&&(ha=function(a){return read(a)}),ia=function(a){if("function"===typeof readbuffer)return new Uint8Array(readbuffer(a));a=read(a,"binary");assert("object"===typeof a);return a},"undefined"!==typeof print&&("undefined"===typeof console&&(console={}),console.log=print,console.warn=console.error="undefined"!==typeof printErr?printErr:print);else if(da||r)r?u=self.location.href:document.currentScript&&(u=document.currentScript.src),_scriptDir&&(u=_scriptDir),0!==u.indexOf("blob:")?u=u.substr(0,
u.lastIndexOf("/")+1):u="",ha=function(a){var b=new XMLHttpRequest;b.open("GET",a,!1);b.send(null);return b.responseText},r&&(ia=function(a){var b=new XMLHttpRequest;b.open("GET",a,!1);b.responseType="arraybuffer";b.send(null);return new Uint8Array(b.response)});var la=e.print||console.log.bind(console),z=e.printErr||console.warn.bind(console);for(m in ca)ca.hasOwnProperty(m)&&(e[m]=ca[m]);ca=null;var ma=0,na;e.wasmBinary&&(na=e.wasmBinary);var noExitRuntime;e.noExitRuntime&&(noExitRuntime=e.noExitRuntime);
"object"!==typeof WebAssembly&&x("no native wasm support detected");var A,oa=new WebAssembly.Table({initial:2116,maximum:2116,element:"anyfunc"}),pa=!1;function assert(a,b){a||x("Assertion failed: "+b)}var qa="undefined"!==typeof TextDecoder?new TextDecoder("utf8"):void 0;
function B(a,b,c){var d=b+c;for(c=b;a[c]&&!(c>=d);)++c;if(16<c-b&&a.subarray&&qa)return qa.decode(a.subarray(b,c));for(d="";b<c;){var f=a[b++];if(f&128){var g=a[b++]&63;if(192==(f&224))d+=String.fromCharCode((f&31)<<6|g);else{var h=a[b++]&63;f=224==(f&240)?(f&15)<<12|g<<6|h:(f&7)<<18|g<<12|h<<6|a[b++]&63;65536>f?d+=String.fromCharCode(f):(f-=65536,d+=String.fromCharCode(55296|f>>10,56320|f&1023))}}else d+=String.fromCharCode(f)}return d}
function sa(a,b,c,d){if(!(0<d))return 0;var f=c;d=c+d-1;for(var g=0;g<a.length;++g){var h=a.charCodeAt(g);if(55296<=h&&57343>=h){var k=a.charCodeAt(++g);h=65536+((h&1023)<<10)|k&1023}if(127>=h){if(c>=d)break;b[c++]=h}else{if(2047>=h){if(c+1>=d)break;b[c++]=192|h>>6}else{if(65535>=h){if(c+2>=d)break;b[c++]=224|h>>12}else{if(c+3>=d)break;b[c++]=240|h>>18;b[c++]=128|h>>12&63}b[c++]=128|h>>6&63}b[c++]=128|h&63}}b[c]=0;return c-f}
function ta(a){for(var b=0,c=0;c<a.length;++c){var d=a.charCodeAt(c);55296<=d&&57343>=d&&(d=65536+((d&1023)<<10)|a.charCodeAt(++c)&1023);127>=d?++b:b=2047>=d?b+2:65535>=d?b+3:b+4}return b}var ua="undefined"!==typeof TextDecoder?new TextDecoder("utf-16le"):void 0;function va(a,b){var c=a>>1;for(var d=c+b/2;!(c>=d)&&wa[c];)++c;c<<=1;if(32<c-a&&ua)return ua.decode(C.subarray(a,c));c=0;for(d="";;){var f=D[a+2*c>>1];if(0==f||c==b/2)return d;++c;d+=String.fromCharCode(f)}}
function xa(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)D[b>>1]=a.charCodeAt(f),b+=2;D[b>>1]=0;return b-d}function ya(a){return 2*a.length}function za(a,b){for(var c=0,d="";!(c>=b/4);){var f=F[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 Aa(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 h=a.charCodeAt(++f);g=65536+((g&1023)<<10)|h&1023}F[b>>2]=g;b+=4;if(b+4>c)break}F[b>>2]=0;return b-d}function Ba(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 G,H,C,D,wa,F,I,Ca,Da;
function Ea(a){G=a;e.HEAP8=H=new Int8Array(a);e.HEAP16=D=new Int16Array(a);e.HEAP32=F=new Int32Array(a);e.HEAPU8=C=new Uint8Array(a);e.HEAPU16=wa=new Uint16Array(a);e.HEAPU32=I=new Uint32Array(a);e.HEAPF32=Ca=new Float32Array(a);e.HEAPF64=Da=new Float64Array(a)}var Fa=e.INITIAL_MEMORY||16777216;e.wasmMemory?A=e.wasmMemory:A=new WebAssembly.Memory({initial:Fa/65536,maximum:32768});A&&(G=A.buffer);Fa=G.byteLength;Ea(G);F[224172]=6139728;
function Ga(a){for(;0<a.length;){var b=a.shift();if("function"==typeof b)b(e);else{var c=b.ub;"number"===typeof c?void 0===b.bb?e.dynCall_v(c):e.dynCall_vi(c,b.bb):c(void 0===b.bb?null:b.bb)}}}var Ha=[],Ia=[],Ja=[],Ka=[];function La(){var a=e.preRun.shift();Ha.unshift(a)}var Ma=Math.abs,Na=Math.ceil,Oa=Math.floor,Pa=Math.min,J=0,Qa=null,Ra=null;e.preloadedImages={};e.preloadedAudios={};
function x(a){if(e.onAbort)e.onAbort(a);z(a);pa=!0;a=new WebAssembly.RuntimeError("abort("+a+"). Build with -s ASSERTIONS=1 for more info.");ba(a);throw a;}function Sa(a){var b=K;return String.prototype.startsWith?b.startsWith(a):0===b.indexOf(a)}function Ta(){return Sa("data:application/octet-stream;base64,")}var K="avif_enc.wasm";if(!Ta()){var Ua=K;K=e.locateFile?e.locateFile(Ua,u):u+Ua}
function Va(){try{if(na)return new Uint8Array(na);if(ia)return ia(K);throw"both async and sync fetching of the wasm failed";}catch(a){x(a)}}function Wa(){return na||!da&&!r||"function"!==typeof fetch||Sa("file://")?new Promise(function(a){a(Va())}):fetch(K,{credentials:"same-origin"}).then(function(a){if(!a.ok)throw"failed to load wasm binary file at '"+K+"'";return a.arrayBuffer()}).catch(function(){return Va()})}var Xa,Ya;Ia.push({ub:function(){Za()}});function $a(){return 0<$a.Za}
function ab(a,b){for(var c=0,d=a.length-1;0<=d;d--){var f=a[d];"."===f?a.splice(d,1):".."===f?(a.splice(d,1),c++):c&&(a.splice(d,1),c--)}if(b)for(;c;c--)a.unshift("..");return a}function bb(a){var b="/"===a.charAt(0),c="/"===a.substr(-1);(a=ab(a.split("/").filter(function(d){return!!d}),!b).join("/"))||b||(a=".");a&&c&&(a+="/");return(b?"/":"")+a}
function cb(a){var b=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(a).slice(1);a=b[0];b=b[1];if(!a&&!b)return".";b&&(b=b.substr(0,b.length-1));return a+b}function db(a){if("/"===a)return"/";var b=a.lastIndexOf("/");return-1===b?a:a.substr(b+1)}
function eb(){for(var a="",b=!1,c=arguments.length-1;-1<=c&&!b;c--){b=0<=c?arguments[c]:"/";if("string"!==typeof b)throw new TypeError("Arguments to path.resolve must be strings");if(!b)return"";a=b+"/"+a;b="/"===b.charAt(0)}a=ab(a.split("/").filter(function(d){return!!d}),!b).join("/");return(b?"/":"")+a||"."}var fb=[];function gb(a,b){fb[a]={input:[],output:[],Ya:b};hb(a,ib)}
var ib={open:function(a){var b=fb[a.node.rdev];if(!b)throw new L(43);a.tty=b;a.seekable=!1},close:function(a){a.tty.Ya.flush(a.tty)},flush:function(a){a.tty.Ya.flush(a.tty)},read:function(a,b,c,d){if(!a.tty||!a.tty.Ya.nb)throw new L(60);for(var f=0,g=0;g<d;g++){try{var h=a.tty.Ya.nb(a.tty)}catch(k){throw new L(29);}if(void 0===h&&0===f)throw new L(6);if(null===h||void 0===h)break;f++;b[c+g]=h}f&&(a.node.timestamp=Date.now());return f},write:function(a,b,c,d){if(!a.tty||!a.tty.Ya.eb)throw new L(60);
try{for(var f=0;f<d;f++)a.tty.Ya.eb(a.tty,b[c+f])}catch(g){throw new L(29);}d&&(a.node.timestamp=Date.now());return f}},jb={nb:function(a){if(!a.input.length){var b=null;if(ea){var c=Buffer.Za?Buffer.Za(256):new Buffer(256),d=0;try{d=ja.readSync(process.stdin.fd,c,0,256,null)}catch(f){if(-1!=f.toString().indexOf("EOF"))d=0;else throw f;}0<d?b=c.slice(0,d).toString("utf-8"):b=null}else"undefined"!=typeof window&&"function"==typeof window.prompt?(b=window.prompt("Input: "),null!==b&&(b+="\n")):"function"==
typeof readline&&(b=readline(),null!==b&&(b+="\n"));if(!b)return null;c=Array(ta(b)+1);b=sa(b,c,0,c.length);c.length=b;a.input=c}return a.input.shift()},eb:function(a,b){null===b||10===b?(la(B(a.output,0)),a.output=[]):0!=b&&a.output.push(b)},flush:function(a){a.output&&0<a.output.length&&(la(B(a.output,0)),a.output=[])}},kb={eb:function(a,b){null===b||10===b?(z(B(a.output,0)),a.output=[]):0!=b&&a.output.push(b)},flush:function(a){a.output&&0<a.output.length&&(z(B(a.output,0)),a.output=[])}},M={Qa:null,
Ua:function(){return M.createNode(null,"/",16895,0)},createNode:function(a,b,c,d){if(24576===(c&61440)||4096===(c&61440))throw new L(63);M.Qa||(M.Qa={dir:{node:{Va:M.Na.Va,Sa:M.Na.Sa,lookup:M.Na.lookup,$a:M.Na.$a,rename:M.Na.rename,unlink:M.Na.unlink,rmdir:M.Na.rmdir,readdir:M.Na.readdir,symlink:M.Na.symlink},stream:{Xa:M.Oa.Xa}},file:{node:{Va:M.Na.Va,Sa:M.Na.Sa},stream:{Xa:M.Oa.Xa,read:M.Oa.read,write:M.Oa.write,hb:M.Oa.hb,ob:M.Oa.ob,qb:M.Oa.qb}},link:{node:{Va:M.Na.Va,Sa:M.Na.Sa,readlink:M.Na.readlink},
stream:{}},ib:{node:{Va:M.Na.Va,Sa:M.Na.Sa},stream:lb}});c=mb(a,b,c,d);16384===(c.mode&61440)?(c.Na=M.Qa.dir.node,c.Oa=M.Qa.dir.stream,c.Ma={}):32768===(c.mode&61440)?(c.Na=M.Qa.file.node,c.Oa=M.Qa.file.stream,c.Pa=0,c.Ma=null):40960===(c.mode&61440)?(c.Na=M.Qa.link.node,c.Oa=M.Qa.link.stream):8192===(c.mode&61440)&&(c.Na=M.Qa.ib.node,c.Oa=M.Qa.ib.stream);c.timestamp=Date.now();a&&(a.Ma[b]=c);return c},Lb:function(a){if(a.Ma&&a.Ma.subarray){for(var b=[],c=0;c<a.Pa;++c)b.push(a.Ma[c]);return b}return a.Ma},
Mb:function(a){return a.Ma?a.Ma.subarray?a.Ma.subarray(0,a.Pa):new Uint8Array(a.Ma):new Uint8Array(0)},jb:function(a,b){var c=a.Ma?a.Ma.length:0;c>=b||(b=Math.max(b,c*(1048576>c?2:1.125)>>>0),0!=c&&(b=Math.max(b,256)),c=a.Ma,a.Ma=new Uint8Array(b),0<a.Pa&&a.Ma.set(c.subarray(0,a.Pa),0))},Eb:function(a,b){if(a.Pa!=b)if(0==b)a.Ma=null,a.Pa=0;else{if(!a.Ma||a.Ma.subarray){var c=a.Ma;a.Ma=new Uint8Array(b);c&&a.Ma.set(c.subarray(0,Math.min(b,a.Pa)))}else if(a.Ma||(a.Ma=[]),a.Ma.length>b)a.Ma.length=b;
else for(;a.Ma.length<b;)a.Ma.push(0);a.Pa=b}},Na:{Va:function(a){var b={};b.dev=8192===(a.mode&61440)?a.id:1;b.ino=a.id;b.mode=a.mode;b.nlink=1;b.uid=0;b.gid=0;b.rdev=a.rdev;16384===(a.mode&61440)?b.size=4096:32768===(a.mode&61440)?b.size=a.Pa:40960===(a.mode&61440)?b.size=a.link.length:b.size=0;b.atime=new Date(a.timestamp);b.mtime=new Date(a.timestamp);b.ctime=new Date(a.timestamp);b.sb=4096;b.blocks=Math.ceil(b.size/b.sb);return b},Sa:function(a,b){void 0!==b.mode&&(a.mode=b.mode);void 0!==b.timestamp&&
(a.timestamp=b.timestamp);void 0!==b.size&&M.Eb(a,b.size)},lookup:function(){throw nb[44];},$a:function(a,b,c,d){return M.createNode(a,b,c,d)},rename:function(a,b,c){if(16384===(a.mode&61440)){try{var d=ob(b,c)}catch(g){}if(d)for(var f in d.Ma)throw new L(55);}delete a.parent.Ma[a.name];a.name=c;b.Ma[c]=a;a.parent=b},unlink:function(a,b){delete a.Ma[b]},rmdir:function(a,b){var c=ob(a,b),d;for(d in c.Ma)throw new L(55);delete a.Ma[b]},readdir:function(a){var b=[".",".."],c;for(c in a.Ma)a.Ma.hasOwnProperty(c)&&
b.push(c);return b},symlink:function(a,b,c){a=M.createNode(a,b,41471,0);a.link=c;return a},readlink:function(a){if(40960!==(a.mode&61440))throw new L(28);return a.link}},Oa:{read:function(a,b,c,d,f){var g=a.node.Ma;if(f>=a.node.Pa)return 0;a=Math.min(a.node.Pa-f,d);if(8<a&&g.subarray)b.set(g.subarray(f,f+a),c);else for(d=0;d<a;d++)b[c+d]=g[f+d];return a},write:function(a,b,c,d,f,g){b.buffer===H.buffer&&(g=!1);if(!d)return 0;a=a.node;a.timestamp=Date.now();if(b.subarray&&(!a.Ma||a.Ma.subarray)){if(g)return a.Ma=
b.subarray(c,c+d),a.Pa=d;if(0===a.Pa&&0===f)return a.Ma=b.slice(c,c+d),a.Pa=d;if(f+d<=a.Pa)return a.Ma.set(b.subarray(c,c+d),f),d}M.jb(a,f+d);if(a.Ma.subarray&&b.subarray)a.Ma.set(b.subarray(c,c+d),f);else for(g=0;g<d;g++)a.Ma[f+g]=b[c+g];a.Pa=Math.max(a.Pa,f+d);return d},Xa:function(a,b,c){1===c?b+=a.position:2===c&&32768===(a.node.mode&61440)&&(b+=a.node.Pa);if(0>b)throw new L(28);return b},hb:function(a,b,c){M.jb(a.node,b+c);a.node.Pa=Math.max(a.node.Pa,b+c)},ob:function(a,b,c,d,f,g){assert(0===
b);if(32768!==(a.node.mode&61440))throw new L(43);a=a.node.Ma;if(g&2||a.buffer!==G){if(0<d||d+c<a.length)a.subarray?a=a.subarray(d,d+c):a=Array.prototype.slice.call(a,d,d+c);d=!0;g=16384*Math.ceil(c/16384);for(b=pb(g);c<g;)H[b+c++]=0;c=b;if(!c)throw new L(48);H.set(a,c)}else d=!1,c=a.byteOffset;return{Qb:c,Kb:d}},qb:function(a,b,c,d,f){if(32768!==(a.node.mode&61440))throw new L(43);if(f&2)return 0;M.Oa.write(a,b,0,d,c,!1);return 0}}},qb=null,rb={},sb=[],tb=1,ub=null,vb=!0,wb={},L=null,nb={};
function N(a,b){a=eb("/",a);b=b||{};if(!a)return{path:"",node:null};var c={mb:!0,fb:0},d;for(d in c)void 0===b[d]&&(b[d]=c[d]);if(8<b.fb)throw new L(32);a=ab(a.split("/").filter(function(h){return!!h}),!1);var f=qb;c="/";for(d=0;d<a.length;d++){var g=d===a.length-1;if(g&&b.parent)break;f=ob(f,a[d]);c=bb(c+"/"+a[d]);f.ab&&(!g||g&&b.mb)&&(f=f.ab.root);if(!g||b.lb)for(g=0;40960===(f.mode&61440);)if(f=xb(c),c=eb(cb(c),f),f=N(c,{fb:b.fb}).node,40<g++)throw new L(32);}return{path:c,node:f}}
function yb(a){for(var b;;){if(a===a.parent)return a=a.Ua.pb,b?"/"!==a[a.length-1]?a+"/"+b:a+b:a;b=b?a.name+"/"+b:a.name;a=a.parent}}function zb(a,b){for(var c=0,d=0;d<b.length;d++)c=(c<<5)-c+b.charCodeAt(d)|0;return(a+c>>>0)%ub.length}function ob(a,b){var c;if(c=(c=Ab(a,"x"))?c:a.Na.lookup?0:2)throw new L(c,a);for(c=ub[zb(a.id,b)];c;c=c.Bb){var d=c.name;if(c.parent.id===a.id&&d===b)return c}return a.Na.lookup(a,b)}
function mb(a,b,c,d){a=new Bb(a,b,c,d);b=zb(a.parent.id,a.name);a.Bb=ub[b];return ub[b]=a}var Cb={r:0,rs:1052672,"r+":2,w:577,wx:705,xw:705,"w+":578,"wx+":706,"xw+":706,a:1089,ax:1217,xa:1217,"a+":1090,"ax+":1218,"xa+":1218};function Db(a){var b=["r","w","rw"][a&3];a&512&&(b+="w");return b}function Ab(a,b){if(vb)return 0;if(-1===b.indexOf("r")||a.mode&292){if(-1!==b.indexOf("w")&&!(a.mode&146)||-1!==b.indexOf("x")&&!(a.mode&73))return 2}else return 2;return 0}
function Eb(a,b){try{return ob(a,b),20}catch(c){}return Ab(a,"wx")}function Fb(a){var b=4096;for(a=a||0;a<=b;a++)if(!sb[a])return a;throw new L(33);}function Gb(a,b){Hb||(Hb=function(){},Hb.prototype={});var c=new Hb,d;for(d in a)c[d]=a[d];a=c;b=Fb(b);a.fd=b;return sb[b]=a}var lb={open:function(a){a.Oa=rb[a.node.rdev].Oa;a.Oa.open&&a.Oa.open(a)},Xa:function(){throw new L(70);}};function hb(a,b){rb[a]={Oa:b}}
function Ib(a,b){var c="/"===b,d=!b;if(c&&qb)throw new L(10);if(!c&&!d){var f=N(b,{mb:!1});b=f.path;f=f.node;if(f.ab)throw new L(10);if(16384!==(f.mode&61440))throw new L(54);}b={type:a,Pb:{},pb:b,Ab:[]};a=a.Ua(b);a.Ua=b;b.root=a;c?qb=a:f&&(f.ab=b,f.Ua&&f.Ua.Ab.push(b))}function Jb(a,b,c){var d=N(a,{parent:!0}).node;a=db(a);if(!a||"."===a||".."===a)throw new L(28);var f=Eb(d,a);if(f)throw new L(f);if(!d.Na.$a)throw new L(63);return d.Na.$a(d,a,b,c)}function O(a){Jb(a,16895,0)}
function Kb(a,b,c){"undefined"===typeof c&&(c=b,b=438);Jb(a,b|8192,c)}function Lb(a,b){if(!eb(a))throw new L(44);var c=N(b,{parent:!0}).node;if(!c)throw new L(44);b=db(b);var d=Eb(c,b);if(d)throw new L(d);if(!c.Na.symlink)throw new L(63);c.Na.symlink(c,b,a)}function xb(a){a=N(a).node;if(!a)throw new L(44);if(!a.Na.readlink)throw new L(28);return eb(yb(a.parent),a.Na.readlink(a))}
function Mb(a,b,c,d){if(""===a)throw new L(44);if("string"===typeof b){var f=Cb[b];if("undefined"===typeof f)throw Error("Unknown file open mode: "+b);b=f}c=b&64?("undefined"===typeof c?438:c)&4095|32768:0;if("object"===typeof a)var g=a;else{a=bb(a);try{g=N(a,{lb:!(b&131072)}).node}catch(k){}}f=!1;if(b&64)if(g){if(b&128)throw new L(20);}else g=Jb(a,c,0),f=!0;if(!g)throw new L(44);8192===(g.mode&61440)&&(b&=-513);if(b&65536&&16384!==(g.mode&61440))throw new L(54);if(!f&&(c=g?40960===(g.mode&61440)?
32:16384===(g.mode&61440)&&("r"!==Db(b)||b&512)?31:Ab(g,Db(b)):44))throw new L(c);if(b&512){c=g;var h;"string"===typeof c?h=N(c,{lb:!0}).node:h=c;if(!h.Na.Sa)throw new L(63);if(16384===(h.mode&61440))throw new L(31);if(32768!==(h.mode&61440))throw new L(28);if(c=Ab(h,"w"))throw new L(c);h.Na.Sa(h,{size:0,timestamp:Date.now()})}b&=-131713;d=Gb({node:g,path:yb(g),flags:b,seekable:!0,position:0,Oa:g.Oa,Jb:[],error:!1},d);d.Oa.open&&d.Oa.open(d);!e.logReadFiles||b&1||(Nb||(Nb={}),a in Nb||(Nb[a]=1,z("FS.trackingDelegate error on read file: "+
a)));try{wb.onOpenFile&&(g=0,1!==(b&2097155)&&(g|=1),0!==(b&2097155)&&(g|=2),wb.onOpenFile(a,g))}catch(k){z("FS.trackingDelegate['onOpenFile']('"+a+"', flags) threw an exception: "+k.message)}return d}function Ob(a,b,c){if(null===a.fd)throw new L(8);if(!a.seekable||!a.Oa.Xa)throw new L(70);if(0!=c&&1!=c&&2!=c)throw new L(28);a.position=a.Oa.Xa(a,b,c);a.Jb=[]}
function Pb(){L||(L=function(a,b){this.node=b;this.Fb=function(c){this.Wa=c};this.Fb(a);this.message="FS error"},L.prototype=Error(),L.prototype.constructor=L,[44].forEach(function(a){nb[a]=new L(a);nb[a].stack="<generic error, no stack>"}))}var Qb;function Rb(a,b){var c=0;a&&(c|=365);b&&(c|=146);return c}
function Sb(a,b,c){a=bb("/dev/"+a);var d=Rb(!!b,!!c);Tb||(Tb=64);var f=Tb++<<8|0;hb(f,{open:function(g){g.seekable=!1},close:function(){c&&c.buffer&&c.buffer.length&&c(10)},read:function(g,h,k,l){for(var n=0,p=0;p<l;p++){try{var t=b()}catch(v){throw new L(29);}if(void 0===t&&0===n)throw new L(6);if(null===t||void 0===t)break;n++;h[k+p]=t}n&&(g.node.timestamp=Date.now());return n},write:function(g,h,k,l){for(var n=0;n<l;n++)try{c(h[k+n])}catch(p){throw new L(29);}l&&(g.node.timestamp=Date.now());return n}});
Kb(a,d,f)}var Tb,Q={},Hb,Nb,Ub=void 0;function Vb(){Ub+=4;return F[Ub-4>>2]}function Wb(a){a=sb[a];if(!a)throw new L(8);return a}var Xb={};function Yb(a){for(;a.length;){var b=a.pop();a.pop()(b)}}function Zb(a){return this.fromWireType(I[a>>2])}var $b={},R={},ac={};function bc(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 cc(a,b){a=bc(a);return(new Function("body","return function "+a+'() {\n "use strict"; return body.apply(this, arguments);\n};\n'))(b)}function dc(a){var b=Error,c=cc(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 ec=void 0;function fc(a,b,c){function d(k){k=c(k);if(k.length!==a.length)throw new ec("Mismatched type converter count");for(var l=0;l<a.length;++l)S(a[l],k[l])}a.forEach(function(k){ac[k]=b});var f=Array(b.length),g=[],h=0;b.forEach(function(k,l){R.hasOwnProperty(k)?f[l]=R[k]:(g.push(k),$b.hasOwnProperty(k)||($b[k]=[]),$b[k].push(function(){f[l]=R[k];++h;h===g.length&&d(f)}))});0===g.length&&d(f)}
function hc(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 ic=void 0;function T(a){for(var b="";C[a];)b+=ic[C[a++]];return b}var jc=void 0;function U(a){throw new jc(a);}
function S(a,b,c){c=c||{};if(!("argPackAdvance"in b))throw new TypeError("registerType registeredInstance requires argPackAdvance");var d=b.name;a||U('type "'+d+'" must have a positive integer typeid pointer');if(R.hasOwnProperty(a)){if(c.yb)return;U("Cannot register type '"+d+"' twice")}R[a]=b;delete ac[a];$b.hasOwnProperty(a)&&(b=$b[a],delete $b[a],b.forEach(function(f){f()}))}var kc=[],V=[{},{value:void 0},{value:null},{value:!0},{value:!1}];
function lc(a){4<a&&0===--V[a].gb&&(V[a]=void 0,kc.push(a))}function mc(a){switch(a){case void 0:return 1;case null:return 2;case !0:return 3;case !1:return 4;default:var b=kc.length?kc.pop():V.length;V[b]={gb:1,value:a};return b}}function nc(a){if(null===a)return"null";var b=typeof a;return"object"===b||"array"===b||"function"===b?a.toString():""+a}
function oc(a,b){switch(b){case 2:return function(c){return this.fromWireType(Ca[c>>2])};case 3:return function(c){return this.fromWireType(Da[c>>3])};default:throw new TypeError("Unknown float type: "+a);}}function pc(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=cc(b.name||"unknownFunctionName",function(){});c.prototype=b.prototype;c=new c;a=b.apply(c,a);return a instanceof Object?a:c}
function qc(a,b){var c=e;if(void 0===c[a].Ra){var d=c[a];c[a]=function(){c[a].Ra.hasOwnProperty(arguments.length)||U("Function '"+b+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+c[a].Ra+")!");return c[a].Ra[arguments.length].apply(this,arguments)};c[a].Ra=[];c[a].Ra[d.rb]=d}}
function rc(a,b,c){e.hasOwnProperty(a)?((void 0===c||void 0!==e[a].Ra&&void 0!==e[a].Ra[c])&&U("Cannot register public name '"+a+"' twice"),qc(a,a),e.hasOwnProperty(c)&&U("Cannot register multiple overloads of a function with the same number of arguments ("+c+")!"),e[a].Ra[c]=b):(e[a]=b,void 0!==c&&(e[a].Ob=c))}function sc(a,b){for(var c=[],d=0;d<a;d++)c.push(F[(b>>2)+d]);return c}
function tc(a,b){a=T(a);var c=e["dynCall_"+a];for(var d=[],f=1;f<a.length;++f)d.push("a"+f);f="return function dynCall_"+(a+"_"+b)+"("+d.join(", ")+") {\n";f+=" return dynCall(rawFunction"+(d.length?", ":"")+d.join(", ")+");\n";c=(new Function("dynCall","rawFunction",f+"};\n"))(c,b);"function"!==typeof c&&U("unknown function pointer with signature "+a+": "+b);return c}var uc=void 0;function vc(a){a=wc(a);var b=T(a);W(a);return b}
function xc(a,b){function c(g){f[g]||R[g]||(ac[g]?ac[g].forEach(c):(d.push(g),f[g]=!0))}var d=[],f={};b.forEach(c);throw new uc(a+": "+d.map(vc).join([", "]));}function yc(a,b,c){switch(b){case 0:return c?function(d){return H[d]}:function(d){return C[d]};case 1:return c?function(d){return D[d>>1]}:function(d){return wa[d>>1]};case 2:return c?function(d){return F[d>>2]}:function(d){return I[d>>2]};default:throw new TypeError("Unknown integer type: "+a);}}var zc={};
function Ac(){return"object"===typeof globalThis?globalThis:Function("return this")()}function Bc(a,b){var c=R[a];void 0===c&&U(b+" has unknown type "+vc(a));return c}var Cc={};function Bb(a,b,c,d){a||(a=this);this.parent=a;this.Ua=a.Ua;this.ab=null;this.id=tb++;this.name=b;this.mode=c;this.Na={};this.Oa={};this.rdev=d}
Object.defineProperties(Bb.prototype,{read:{get:function(){return 365===(this.mode&365)},set:function(a){a?this.mode|=365:this.mode&=-366}},write:{get:function(){return 146===(this.mode&146)},set:function(a){a?this.mode|=146:this.mode&=-147}}});Pb();ub=Array(4096);Ib(M,"/");O("/tmp");O("/home");O("/home/web_user");
(function(){O("/dev");hb(259,{read:function(){return 0},write:function(d,f,g,h){return h}});Kb("/dev/null",259);gb(1280,jb);gb(1536,kb);Kb("/dev/tty",1280);Kb("/dev/tty1",1536);if("object"===typeof crypto&&"function"===typeof crypto.getRandomValues){var a=new Uint8Array(1);var b=function(){crypto.getRandomValues(a);return a[0]}}else if(ea)try{var c=require("crypto");b=function(){return c.randomBytes(1)[0]}}catch(d){}b||(b=function(){x("random_device")});Sb("random",b);Sb("urandom",b);O("/dev/shm");
O("/dev/shm/tmp")})();O("/proc");O("/proc/self");O("/proc/self/fd");Ib({Ua:function(){var a=mb("/proc/self","fd",16895,73);a.Na={lookup:function(b,c){var d=sb[+c];if(!d)throw new L(8);b={parent:null,Ua:{pb:"fake"},Na:{readlink:function(){return d.path}}};return b.parent=b}};return a}},"/proc/self/fd");ec=e.InternalError=dc("InternalError");for(var Dc=Array(256),Ec=0;256>Ec;++Ec)Dc[Ec]=String.fromCharCode(Ec);ic=Dc;jc=e.BindingError=dc("BindingError");
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};uc=e.UnboundTypeError=dc("UnboundTypeError");
var Sc={w:function(a){return pb(a)},U:function(){},S:function(a){"uncaught_exception"in $a?$a.Za++:$a.Za=1;throw a;},q:function(a,b,c){Ub=c;try{var d=Wb(a);switch(b){case 0:var f=Vb();return 0>f?-28:Mb(d.path,d.flags,0,f).fd;case 1:case 2:return 0;case 3:return d.flags;case 4:return f=Vb(),d.flags|=f,0;case 12:return f=Vb(),D[f+0>>1]=2,0;case 13:case 14:return 0;case 16:case 8:return-28;case 9:return F[Fc()>>2]=28,-1;default:return-28}}catch(g){return"undefined"!==typeof Q&&g instanceof L||x(g),-g.Wa}},
M:function(a,b,c){Ub=c;try{var d=Wb(a);switch(b){case 21509:case 21505:return d.tty?0:-59;case 21510:case 21511:case 21512:case 21506:case 21507:case 21508:return d.tty?0:-59;case 21519:if(!d.tty)return-59;var f=Vb();return F[f>>2]=0;case 21520:return d.tty?-28:-59;case 21531:a=f=Vb();if(!d.Oa.zb)throw new L(59);return d.Oa.zb(d,b,a);case 21523:return d.tty?0:-59;case 21524:return d.tty?0:-59;default:x("bad ioctl syscall "+b)}}catch(g){return"undefined"!==typeof Q&&g instanceof L||x(g),-g.Wa}},N:function(a,
b,c){Ub=c;try{var d=a?B(C,a,void 0):"",f=Vb();return Mb(d,b,f).fd}catch(g){return"undefined"!==typeof Q&&g instanceof L||x(g),-g.Wa}},A:function(a){var b=Xb[a];delete Xb[a];var c=b.Cb,d=b.Db,f=b.kb,g=f.map(function(h){return h.xb}).concat(f.map(function(h){return h.Hb}));fc([a],g,function(h){var k={};f.forEach(function(l,n){var p=h[n],t=l.vb,v=l.wb,w=h[n+f.length],q=l.Gb,E=l.Ib;k[l.tb]={read:function(y){return p.fromWireType(t(v,y))},write:function(y,P){var ra=[];q(E,y,w.toWireType(ra,P));Yb(ra)}}});
return[{name:b.name,fromWireType:function(l){var n={},p;for(p in k)n[p]=k[p].read(l);d(l);return n},toWireType:function(l,n){for(var p in k)if(!(p in n))throw new TypeError('Missing field: "'+p+'"');var t=c();for(p in k)k[p].write(t,n[p]);null!==l&&l.push(d,t);return t},argPackAdvance:8,readValueFromPointer:Zb,Ta:d}]})},P:function(a,b,c,d,f){var g=hc(c);b=T(b);S(a,{name:b,fromWireType:function(h){return!!h},toWireType:function(h,k){return k?d:f},argPackAdvance:8,readValueFromPointer:function(h){if(1===
c)var k=H;else if(2===c)k=D;else if(4===c)k=F;else throw new TypeError("Unknown boolean type size: "+b);return this.fromWireType(k[h>>g])},Ta:null})},O:function(a,b){b=T(b);S(a,{name:b,fromWireType:function(c){var d=V[c].value;lc(c);return d},toWireType:function(c,d){return mc(d)},argPackAdvance:8,readValueFromPointer:Zb,Ta:null})},t:function(a,b,c){c=hc(c);b=T(b);S(a,{name:b,fromWireType:function(d){return d},toWireType:function(d,f){if("number"!==typeof f&&"boolean"!==typeof f)throw new TypeError('Cannot convert "'+
nc(f)+'" to '+this.name);return f},argPackAdvance:8,readValueFromPointer:oc(b,c),Ta:null})},y:function(a,b,c,d,f,g){var h=sc(b,c);a=T(a);f=tc(d,f);rc(a,function(){xc("Cannot call "+a+" due to unbound types",h)},b-1);fc([],h,function(k){var l=[k[0],null].concat(k.slice(1)),n=k=a,p=f,t=l.length;2>t&&U("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var v=null!==l[1]&&!1,w=!1,q=1;q<l.length;++q)if(null!==l[q]&&void 0===l[q].Ta){w=!0;break}var E="void"!==l[0].name,
y="",P="";for(q=0;q<t-2;++q)y+=(0!==q?", ":"")+"arg"+q,P+=(0!==q?", ":"")+"arg"+q+"Wired";n="return function "+bc(n)+"("+y+") {\nif (arguments.length !== "+(t-2)+") {\nthrowBindingError('function "+n+" called with ' + arguments.length + ' arguments, expected "+(t-2)+" args!');\n}\n";w&&(n+="var destructors = [];\n");var ra=w?"destructors":"null";y="throwBindingError invoker fn runDestructors retType classParam".split(" ");p=[U,p,g,Yb,l[0],l[1]];v&&(n+="var thisWired = classParam.toWireType("+ra+", this);\n");
for(q=0;q<t-2;++q)n+="var arg"+q+"Wired = argType"+q+".toWireType("+ra+", arg"+q+"); // "+l[q+2].name+"\n",y.push("argType"+q),p.push(l[q+2]);v&&(P="thisWired"+(0<P.length?", ":"")+P);n+=(E?"var rv = ":"")+"invoker(fn"+(0<P.length?", ":"")+P+");\n";if(w)n+="runDestructors(destructors);\n";else for(q=v?1:2;q<l.length;++q)t=1===q?"thisWired":"arg"+(q-2)+"Wired",null!==l[q].Ta&&(n+=t+"_dtor("+t+"); // "+l[q].name+"\n",y.push(t+"_dtor"),p.push(l[q].Ta));E&&(n+="var ret = retType.fromWireType(rv);\nreturn ret;\n");
y.push(n+"}\n");l=pc(y).apply(null,p);q=b-1;if(!e.hasOwnProperty(k))throw new ec("Replacing nonexistant public symbol");void 0!==e[k].Ra&&void 0!==q?e[k].Ra[q]=l:(e[k]=l,e[k].rb=q);return[]})},i:function(a,b,c,d,f){function g(n){return n}b=T(b);-1===f&&(f=4294967295);var h=hc(c);if(0===d){var k=32-8*c;g=function(n){return n<<k>>>k}}var l=-1!=b.indexOf("unsigned");S(a,{name:b,fromWireType:g,toWireType:function(n,p){if("number"!==typeof p&&"boolean"!==typeof p)throw new TypeError('Cannot convert "'+
nc(p)+'" to '+this.name);if(p<d||p>f)throw new TypeError('Passing a number "'+nc(p)+'" from JS side to C/C++ side to an argument of type "'+b+'", which is outside the valid range ['+d+", "+f+"]!");return l?p>>>0:p|0},argPackAdvance:8,readValueFromPointer:yc(b,h,0!==d),Ta:null})},f:function(a,b,c){function d(g){g>>=2;var h=I;return new f(G,h[g+1],h[g])}var f=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][b];c=T(c);S(a,{name:c,fromWireType:d,argPackAdvance:8,
readValueFromPointer:d},{yb:!0})},u:function(a,b){b=T(b);var c="std::string"===b;S(a,{name:b,fromWireType:function(d){var f=I[d>>2];if(c)for(var g=d+4,h=0;h<=f;++h){var k=d+4+h;if(h==f||0==C[k]){g=g?B(C,g,k-g):"";if(void 0===l)var l=g;else l+=String.fromCharCode(0),l+=g;g=k+1}}else{l=Array(f);for(h=0;h<f;++h)l[h]=String.fromCharCode(C[d+4+h]);l=l.join("")}W(d);return l},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||U("Cannot pass non-string to std::string");var h=(c&&g?function(){return ta(f)}:function(){return f.length})(),k=pb(4+h+1);I[k>>2]=h;if(c&&g)sa(f,C,k+4,h+1);else if(g)for(g=0;g<h;++g){var l=f.charCodeAt(g);255<l&&(W(k),U("String has UTF-16 code units that do not fit in 8 bits"));C[k+4+g]=l}else for(g=0;g<h;++g)C[k+4+g]=f[g];null!==d&&d.push(W,k);return k},argPackAdvance:8,readValueFromPointer:Zb,Ta:function(d){W(d)}})},n:function(a,b,c){c=T(c);if(2===b){var d=
va;var f=xa;var g=ya;var h=function(){return wa};var k=1}else 4===b&&(d=za,f=Aa,g=Ba,h=function(){return I},k=2);S(a,{name:c,fromWireType:function(l){for(var n=I[l>>2],p=h(),t,v=l+4,w=0;w<=n;++w){var q=l+4+w*b;if(w==n||0==p[q>>k])v=d(v,q-v),void 0===t?t=v:(t+=String.fromCharCode(0),t+=v),v=q+b}W(l);return t},toWireType:function(l,n){"string"!==typeof n&&U("Cannot pass non-string to C++ string type "+c);var p=g(n),t=pb(4+p+b);I[t>>2]=p>>k;f(n,t+4,p+b);null!==l&&l.push(W,t);return t},argPackAdvance:8,
readValueFromPointer:Zb,Ta:function(l){W(l)}})},H:function(a,b,c,d,f,g){Xb[a]={name:T(b),Cb:tc(c,d),Db:tc(f,g),kb:[]}},z:function(a,b,c,d,f,g,h,k,l,n){Xb[a].kb.push({tb:T(b),xb:c,vb:tc(d,f),wb:g,Hb:h,Gb:tc(k,l),Ib:n})},Q:function(a,b){b=T(b);S(a,{Nb:!0,name:b,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},s:lc,T:function(a){if(0===a)return mc(Ac());var b=zc[a];a=void 0===b?T(a):b;return mc(Ac()[a])},x:function(a){4<a&&(V[a].gb+=1)},J:function(a,b,c,d){a||U("Cannot use deleted val. handle = "+
a);a=V[a].value;var f=Cc[b];if(!f){f="";for(var g=0;g<b;++g)f+=(0!==g?", ":"")+"arg"+g;var h="return function emval_allocator_"+b+"(constructor, argTypes, args) {\n";for(g=0;g<b;++g)h+="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",h+("var obj = new constructor("+f+");\nreturn __emval_register(obj);\n}\n")))(Bc,
e,mc);Cc[b]=f}return f(a,c,d)},v:function(){x()},d:function(a,b){X(a,b||1);throw"longjmp";},K:function(a,b,c){C.copyWithin(a,b,b+c)},j:function(a){a>>>=0;var b=C.length;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(16777216,a,d);0<d%65536&&(d+=65536-d%65536);a:{try{A.grow(Math.min(2147483648,d)-G.byteLength+65535>>>16);Ea(A.buffer);var f=1;break a}catch(g){}f=void 0}if(f)return!0}return!1},r:function(a){try{var b=Wb(a);if(null===b.fd)throw new L(8);
b.cb&&(b.cb=null);try{b.Oa.close&&b.Oa.close(b)}catch(c){throw c;}finally{sb[b.fd]=null}b.fd=null;return 0}catch(c){return"undefined"!==typeof Q&&c instanceof L||x(c),c.Wa}},L:function(a,b,c,d){try{a:{for(var f=Wb(a),g=a=0;g<c;g++){var h=F[b+(8*g+4)>>2],k=f,l=F[b+8*g>>2],n=h,p=void 0,t=H;if(0>n||0>p)throw new L(28);if(null===k.fd)throw new L(8);if(1===(k.flags&2097155))throw new L(8);if(16384===(k.node.mode&61440))throw new L(31);if(!k.Oa.read)throw new L(28);var v="undefined"!==typeof p;if(!v)p=
k.position;else if(!k.seekable)throw new L(70);var w=k.Oa.read(k,t,l,n,p);v||(k.position+=w);var q=w;if(0>q){var E=-1;break a}a+=q;if(q<h)break}E=a}F[d>>2]=E;return 0}catch(y){return"undefined"!==typeof Q&&y instanceof L||x(y),y.Wa}},E:function(a,b,c,d,f){try{var g=Wb(a);a=4294967296*c+(b>>>0);if(-9007199254740992>=a||9007199254740992<=a)return-61;Ob(g,a,d);Ya=[g.position>>>0,(Xa=g.position,1<=+Ma(Xa)?0<Xa?(Pa(+Oa(Xa/4294967296),4294967295)|0)>>>0:~~+Na((Xa-+(~~Xa>>>0))/4294967296)>>>0:0)];F[f>>2]=
Ya[0];F[f+4>>2]=Ya[1];g.cb&&0===a&&0===d&&(g.cb=null);return 0}catch(h){return"undefined"!==typeof Q&&h instanceof L||x(h),h.Wa}},p:function(a,b,c,d){try{a:{for(var f=Wb(a),g=a=0;g<c;g++){var h=f,k=F[b+8*g>>2],l=F[b+(8*g+4)>>2],n=void 0,p=H;if(0>l||0>n)throw new L(28);if(null===h.fd)throw new L(8);if(0===(h.flags&2097155))throw new L(8);if(16384===(h.node.mode&61440))throw new L(31);if(!h.Oa.write)throw new L(28);h.seekable&&h.flags&1024&&Ob(h,0,2);var t="undefined"!==typeof n;if(!t)n=h.position;
else if(!h.seekable)throw new L(70);var v=h.Oa.write(h,p,k,l,n,void 0);t||(h.position+=v);try{if(h.path&&wb.onWriteToFile)wb.onWriteToFile(h.path)}catch(E){z("FS.trackingDelegate['onWriteToFile']('"+h.path+"') threw an exception: "+E.message)}var w=v;if(0>w){var q=-1;break a}a+=w}q=a}F[d>>2]=q;return 0}catch(E){return"undefined"!==typeof Q&&E instanceof L||x(E),E.Wa}},a:function(){return ma|0},m:Gc,e:Hc,G:Ic,o:Jc,F:Kc,C:Lc,B:Mc,D:Nc,I:Oc,k:Pc,l:Qc,c:Rc,memory:A,g:function(a){a=+a;return 0<=a?+Oa(a+
.5):+Na(a-.5)},h:function(a){a=+a;return 0<=a?+Oa(a+.5):+Na(a-.5)},b:function(a){ma=a|0},table:oa,R:function(a){var b=Date.now()/1E3|0;a&&(F[a>>2]=b);return b}};
(function(){function a(f){e.asm=f.exports;J--;e.monitorRunDependencies&&e.monitorRunDependencies(J);0==J&&(null!==Qa&&(clearInterval(Qa),Qa=null),Ra&&(f=Ra,Ra=null,f()))}function b(f){a(f.instance)}function c(f){return Wa().then(function(g){return WebAssembly.instantiate(g,d)}).then(f,function(g){z("failed to asynchronously prepare wasm: "+g);x(g)})}var d={a:Sc};J++;e.monitorRunDependencies&&e.monitorRunDependencies(J);if(e.instantiateWasm)try{return e.instantiateWasm(d,a)}catch(f){return z("Module.instantiateWasm callback failed with error: "+
f),!1}(function(){if(na||"function"!==typeof WebAssembly.instantiateStreaming||Ta()||Sa("file://")||"function"!==typeof fetch)return c(b);fetch(K,{credentials:"same-origin"}).then(function(f){return WebAssembly.instantiateStreaming(f,d).then(b,function(g){z("wasm streaming compile failed: "+g);z("falling back to ArrayBuffer instantiation");return c(b)})})})();return{}})();
var Za=e.___wasm_call_ctors=function(){return(Za=e.___wasm_call_ctors=e.asm.V).apply(null,arguments)},pb=e._malloc=function(){return(pb=e._malloc=e.asm.W).apply(null,arguments)},W=e._free=function(){return(W=e._free=e.asm.X).apply(null,arguments)},wc=e.___getTypeName=function(){return(wc=e.___getTypeName=e.asm.Y).apply(null,arguments)};e.___embind_register_native_and_builtin_types=function(){return(e.___embind_register_native_and_builtin_types=e.asm.Z).apply(null,arguments)};
var Fc=e.___errno_location=function(){return(Fc=e.___errno_location=e.asm._).apply(null,arguments)},X=e._setThrew=function(){return(X=e._setThrew=e.asm.$).apply(null,arguments)},Y=e.stackSave=function(){return(Y=e.stackSave=e.asm.aa).apply(null,arguments)},Z=e.stackRestore=function(){return(Z=e.stackRestore=e.asm.ba).apply(null,arguments)},Tc=e.dynCall_v=function(){return(Tc=e.dynCall_v=e.asm.ca).apply(null,arguments)},Uc=e.dynCall_vi=function(){return(Uc=e.dynCall_vi=e.asm.da).apply(null,arguments)},
Vc=e.dynCall_vii=function(){return(Vc=e.dynCall_vii=e.asm.ea).apply(null,arguments)};e.dynCall_viii=function(){return(e.dynCall_viii=e.asm.fa).apply(null,arguments)};var Wc=e.dynCall_viiii=function(){return(Wc=e.dynCall_viiii=e.asm.ga).apply(null,arguments)},Xc=e.dynCall_ii=function(){return(Xc=e.dynCall_ii=e.asm.ha).apply(null,arguments)},Yc=e.dynCall_iii=function(){return(Yc=e.dynCall_iii=e.asm.ia).apply(null,arguments)};e.dynCall_iiii=function(){return(e.dynCall_iiii=e.asm.ja).apply(null,arguments)};
var Zc=e.dynCall_iiiii=function(){return(Zc=e.dynCall_iiiii=e.asm.ka).apply(null,arguments)},$c=e.dynCall_iiiiiiiii=function(){return($c=e.dynCall_iiiiiiiii=e.asm.la).apply(null,arguments)},ad=e.dynCall_iiiiiiiiii=function(){return(ad=e.dynCall_iiiiiiiiii=e.asm.ma).apply(null,arguments)},bd=e.dynCall_iiiijj=function(){return(bd=e.dynCall_iiiijj=e.asm.na).apply(null,arguments)},cd=e.dynCall_ij=function(){return(cd=e.dynCall_ij=e.asm.oa).apply(null,arguments)},dd=e.dynCall_jjij=function(){return(dd=
e.dynCall_jjij=e.asm.pa).apply(null,arguments)};e.dynCall_i=function(){return(e.dynCall_i=e.asm.qa).apply(null,arguments)};e.dynCall_iiiiii=function(){return(e.dynCall_iiiiii=e.asm.ra).apply(null,arguments)};e.dynCall_viiiii=function(){return(e.dynCall_viiiii=e.asm.sa).apply(null,arguments)};e.dynCall_viiiiii=function(){return(e.dynCall_viiiiii=e.asm.ta).apply(null,arguments)};e.dynCall_viiiiiiii=function(){return(e.dynCall_viiiiiiii=e.asm.ua).apply(null,arguments)};
e.dynCall_viiiiiiiiiii=function(){return(e.dynCall_viiiiiiiiiii=e.asm.va).apply(null,arguments)};e.dynCall_viiiiiiiiiiii=function(){return(e.dynCall_viiiiiiiiiiii=e.asm.wa).apply(null,arguments)};e.dynCall_viiiiiii=function(){return(e.dynCall_viiiiiii=e.asm.xa).apply(null,arguments)};e.dynCall_viiiiiiiii=function(){return(e.dynCall_viiiiiiiii=e.asm.ya).apply(null,arguments)};e.dynCall_jiiiiiiiii=function(){return(e.dynCall_jiiiiiiiii=e.asm.za).apply(null,arguments)};
e.dynCall_iiiiiii=function(){return(e.dynCall_iiiiiii=e.asm.Aa).apply(null,arguments)};e.dynCall_iiiiiiii=function(){return(e.dynCall_iiiiiiii=e.asm.Ba).apply(null,arguments)};e.dynCall_iiiiiiiiiiii=function(){return(e.dynCall_iiiiiiiiiiii=e.asm.Ca).apply(null,arguments)};e.dynCall_jiji=function(){return(e.dynCall_jiji=e.asm.Da).apply(null,arguments)};e.dynCall_iidiiii=function(){return(e.dynCall_iidiiii=e.asm.Ea).apply(null,arguments)};
e.dynCall_viiiiiiiiii=function(){return(e.dynCall_viiiiiiiiii=e.asm.Fa).apply(null,arguments)};e.dynCall_viiiiiiiiiiiii=function(){return(e.dynCall_viiiiiiiiiiiii=e.asm.Ga).apply(null,arguments)};e.dynCall_jiiiiiiii=function(){return(e.dynCall_jiiiiiiii=e.asm.Ha).apply(null,arguments)};e.dynCall_ff=function(){return(e.dynCall_ff=e.asm.Ia).apply(null,arguments)};e.dynCall_jiiiiii=function(){return(e.dynCall_jiiiiii=e.asm.Ja).apply(null,arguments)};
e.dynCall_jiiiii=function(){return(e.dynCall_jiiiii=e.asm.Ka).apply(null,arguments)};e.dynCall_iiijii=function(){return(e.dynCall_iiijii=e.asm.La).apply(null,arguments)};function Qc(a,b,c){var d=Y();try{Vc(a,b,c)}catch(f){Z(d);if(f!==f+0&&"longjmp"!==f)throw f;X(1,0)}}function Rc(a,b,c,d,f){var g=Y();try{Wc(a,b,c,d,f)}catch(h){Z(g);if(h!==h+0&&"longjmp"!==h)throw h;X(1,0)}}function Hc(a,b,c){var d=Y();try{return Yc(a,b,c)}catch(f){Z(d);if(f!==f+0&&"longjmp"!==f)throw f;X(1,0)}}
function Pc(a,b){var c=Y();try{Uc(a,b)}catch(d){Z(c);if(d!==d+0&&"longjmp"!==d)throw d;X(1,0)}}function Oc(a){var b=Y();try{Tc(a)}catch(c){Z(b);if(c!==c+0&&"longjmp"!==c)throw c;X(1,0)}}function Gc(a,b){var c=Y();try{return Xc(a,b)}catch(d){Z(c);if(d!==d+0&&"longjmp"!==d)throw d;X(1,0)}}function Ic(a,b,c,d,f){var g=Y();try{return Zc(a,b,c,d,f)}catch(h){Z(g);if(h!==h+0&&"longjmp"!==h)throw h;X(1,0)}}
function Kc(a,b,c,d,f,g,h,k,l,n){var p=Y();try{return ad(a,b,c,d,f,g,h,k,l,n)}catch(t){Z(p);if(t!==t+0&&"longjmp"!==t)throw t;X(1,0)}}function Jc(a,b,c,d,f,g,h,k,l){var n=Y();try{return $c(a,b,c,d,f,g,h,k,l)}catch(p){Z(n);if(p!==p+0&&"longjmp"!==p)throw p;X(1,0)}}function Nc(a,b,c,d,f,g){var h=Y();try{return dd(a,b,c,d,f,g)}catch(k){Z(h);if(k!==k+0&&"longjmp"!==k)throw k;X(1,0)}}
function Lc(a,b,c,d,f,g,h,k){var l=Y();try{return bd(a,b,c,d,f,g,h,k)}catch(n){Z(l);if(n!==n+0&&"longjmp"!==n)throw n;X(1,0)}}function Mc(a,b,c){var d=Y();try{return cd(a,b,c)}catch(f){Z(d);if(f!==f+0&&"longjmp"!==f)throw f;X(1,0)}}var ed;Ra=function fd(){ed||gd();ed||(Ra=fd)};
function gd(){function a(){if(!ed&&(ed=!0,e.calledRun=!0,!pa)){e.noFSInit||Qb||(Qb=!0,Pb(),e.stdin=e.stdin,e.stdout=e.stdout,e.stderr=e.stderr,e.stdin?Sb("stdin",e.stdin):Lb("/dev/tty","/dev/stdin"),e.stdout?Sb("stdout",null,e.stdout):Lb("/dev/tty","/dev/stdout"),e.stderr?Sb("stderr",null,e.stderr):Lb("/dev/tty1","/dev/stderr"),Mb("/dev/stdin","r"),Mb("/dev/stdout","w"),Mb("/dev/stderr","w"));Ga(Ia);vb=!1;Ga(Ja);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();Ka.unshift(b)}Ga(Ka)}}if(!(0<J)){if(e.preRun)for("function"==typeof e.preRun&&(e.preRun=[e.preRun]);e.preRun.length;)La();Ga(Ha);0<J||(e.setStatus?(e.setStatus("Running..."),setTimeout(function(){setTimeout(function(){e.setStatus("")},1);a()},1)):a())}}e.run=gd;if(e.preInit)for("function"==typeof e.preInit&&(e.preInit=[e.preInit]);0<e.preInit.length;)e.preInit.pop()();noExitRuntime=!0;gd();
return avif_enc.ready
}
);
})();
if (typeof exports === 'object' && typeof module === 'object')
module.exports = avif_enc;
else if (typeof define === 'function' && define['amd'])
define([], function() { return avif_enc; });
else if (typeof exports === 'object')
exports["avif_enc"] = avif_enc;

Binary file not shown.

View File

@@ -1,6 +0,0 @@
{
"name": "avif",
"scripts": {
"build": "../build-cpp.sh"
}
}

View File

@@ -1,3 +0,0 @@
#!/bin/sh -e
docker build -t squoosh-cpp - < ../cpp.Dockerfile
docker run --rm -v $PWD:/src squoosh-cpp

View File

@@ -1,4 +0,0 @@
set -e
docker build -t squoosh-rust - < ../rust.Dockerfile
docker run --rm -v $PWD:/src squoosh-rust "$@"

View File

@@ -1,9 +0,0 @@
FROM emscripten/emsdk:1.40.0
RUN apt-get update && apt-get install -qqy autoconf libtool pkg-config
ENV CFLAGS "-Os -flto"
ENV CXXFLAGS "${CFLAGS} -std=c++17"
ENV LDFLAGS "${CFLAGS}"
# Build and cache standard libraries with these flags
RUN emcc ${CXXFLAGS} --bind -xc++ /dev/null -o /dev/null
WORKDIR /src
CMD ["sh", "-c", "emmake make -j`nproc`"]

View File

@@ -1 +0,0 @@
/target

289
codecs/hqx/Cargo.lock generated
View File

@@ -1,289 +0,0 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "bumpalo"
version = "3.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "cfg-if"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "console_error_panic_hook"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "futures"
version = "0.1.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "hqx"
version = "0.1.0"
source = "git+https://github.com/CryZe/wasmboy-rs?tag=v0.1.2#5f19cda24191ccc7c0c4920b6b246b4e242f377c"
dependencies = [
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "js-sys"
version = "0.3.42"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"wasm-bindgen 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "lazy_static"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "libc"
version = "0.2.73"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "log"
version = "0.4.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "memory_units"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "proc-macro2"
version = "0.4.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "proc-macro2"
version = "1.0.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"unicode-xid 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "quote"
version = "0.6.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "quote"
version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "scoped-tls"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "squooshhqx"
version = "0.1.0"
dependencies = [
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"console_error_panic_hook 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"hqx 0.1.0 (git+https://github.com/CryZe/wasmboy-rs?tag=v0.1.2)",
"wasm-bindgen 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen-test 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
"wee_alloc 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "syn"
version = "1.0.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-xid 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "unicode-xid"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "unicode-xid"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "wasm-bindgen"
version = "0.2.65"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen-macro 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.65"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bumpalo 3.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen-shared 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wasm-bindgen-futures"
version = "0.3.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)",
"js-sys 0.3.42 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
"web-sys 0.3.42 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.65"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen-macro-support 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.65"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen-backend 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen-shared 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.65"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "wasm-bindgen-test"
version = "0.2.50"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"console_error_panic_hook 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)",
"js-sys 0.3.42 (registry+https://github.com/rust-lang/crates.io-index)",
"scoped-tls 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen-futures 0.3.27 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen-test-macro 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wasm-bindgen-test-macro"
version = "0.2.50"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "web-sys"
version = "0.3.42"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"js-sys 0.3.42 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wee_alloc"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.73 (registry+https://github.com/rust-lang/crates.io-index)",
"memory_units 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[metadata]
"checksum bumpalo 3.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2e8c087f005730276d1096a652e92a8bacee2e2472bcc9715a74d2bec38b5820"
"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
"checksum console_error_panic_hook 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d976903543e0c48546a91908f21588a680a8c8f984df9a5d69feccb2b2a211"
"checksum futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)" = "1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef"
"checksum hqx 0.1.0 (git+https://github.com/CryZe/wasmboy-rs?tag=v0.1.2)" = "<none>"
"checksum js-sys 0.3.42 (registry+https://github.com/rust-lang/crates.io-index)" = "52732a3d3ad72c58ad2dc70624f9c17b46ecd0943b9a4f1ee37c4c18c5d983e2"
"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
"checksum libc 0.2.73 (registry+https://github.com/rust-lang/crates.io-index)" = "bd7d4bd64732af4bf3a67f367c27df8520ad7e230c5817b8ff485864d80242b9"
"checksum log 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b"
"checksum memory_units 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3"
"checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"
"checksum proc-macro2 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)" = "04f5f085b5d71e2188cb8271e5da0161ad52c3f227a661a3c135fdf28e258b12"
"checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1"
"checksum quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37"
"checksum scoped-tls 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2"
"checksum syn 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)" = "fb7f4c519df8c117855e19dd8cc851e89eb746fe7a73f0157e0d95fdec5369b0"
"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
"checksum unicode-xid 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
"checksum wasm-bindgen 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)" = "f3edbcc9536ab7eababcc6d2374a0b7bfe13a2b6d562c5e07f370456b1a8f33d"
"checksum wasm-bindgen-backend 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)" = "89ed2fb8c84bfad20ea66b26a3743f3e7ba8735a69fe7d95118c33ec8fc1244d"
"checksum wasm-bindgen-futures 0.3.27 (registry+https://github.com/rust-lang/crates.io-index)" = "83420b37346c311b9ed822af41ec2e82839bfe99867ec6c54e2da43b7538771c"
"checksum wasm-bindgen-macro 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)" = "eb071268b031a64d92fc6cf691715ca5a40950694d8f683c5bb43db7c730929e"
"checksum wasm-bindgen-macro-support 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)" = "cf592c807080719d1ff2f245a687cbadb3ed28b2077ed7084b47aba8b691f2c6"
"checksum wasm-bindgen-shared 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)" = "72b6c0220ded549d63860c78c38f3bcc558d1ca3f4efa74942c536ddbbb55e87"
"checksum wasm-bindgen-test 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "a2d9693b63a742d481c7f80587e057920e568317b2806988c59cd71618bc26c1"
"checksum wasm-bindgen-test-macro 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "0789dac148a8840bbcf9efe13905463b733fa96543bfbf263790535c11af7ba5"
"checksum web-sys 0.3.42 (registry+https://github.com/rust-lang/crates.io-index)" = "8be2398f326b7ba09815d0b403095f34dd708579220d099caae89be0b32137b2"
"checksum wee_alloc 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "dbb3b5a6b2bb17cb6ad44a2e68a43e8d2722c997da10e928665c72ec6c0a0b8e"
"checksum winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"

View File

@@ -1,37 +0,0 @@
[package]
name = "squooshhqx"
version = "0.1.0"
authors = ["Surma <surma@surma.link>"]
[lib]
crate-type = ["cdylib"]
[features]
default = ["console_error_panic_hook", "wee_alloc"]
[dependencies]
cfg-if = "0.1.2"
wasm-bindgen = "0.2.38"
# lazy_static = "1.0.0"
hqx = {git = "https://github.com/CryZe/wasmboy-rs", tag="v0.1.2"}
# The `console_error_panic_hook` crate provides better debugging of panics by
# logging them with `console.error`. This is great for development, but requires
# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for
# code size when deploying.
console_error_panic_hook = { version = "0.1.1", optional = true }
# `wee_alloc` is a tiny allocator for wasm that is only ~1K in code size
# compared to the default allocator's ~10K. It is slower than the default
# allocator, however.
#
# Unfortunately, `wee_alloc` requires nightly Rust when targeting wasm for now.
wee_alloc = { version = "0.4.2", optional = true }
[dev-dependencies]
wasm-bindgen-test = "0.2"
[profile.release]
# Tell `rustc` to optimize for small code size.
opt-level = "s"
lto = true

View File

@@ -1,11 +0,0 @@
# This is intentionally an old version of Rust. Newer versions
# generate _significantly_ bigger Wasm binaries.
FROM rust:1.37
RUN rustup target add wasm32-unknown-unknown
RUN curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
RUN mkdir /opt/binaryen && \
curl -L https://github.com/WebAssembly/binaryen/releases/download/1.38.32/binaryen-1.38.32-x86-linux.tar.gz | tar -xzf - -C /opt/binaryen --strip 1
ENV PATH="/opt/binaryen:${PATH}"
WORKDIR /src

View File

@@ -1,21 +0,0 @@
#!/bin/bash
set -e
echo "============================================="
echo "Compiling wasm"
echo "============================================="
(
wasm-pack build -- --verbose --locked
rm pkg/.gitignore
)
echo "============================================="
echo "Compiling wasm done"
echo "============================================="
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "Did you update your docker image?"
echo "Run \`docker pull ubuntu\`"
echo "Run \`docker pull rust\`"
echo "Run \`docker build -t squoosh-hqx .\`"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"

View File

@@ -1,4 +0,0 @@
{
"name": "hqx",
"lockfileVersion": 1
}

View File

@@ -1,7 +0,0 @@
{
"name": "hqx",
"scripts": {
"build:image": "docker build -t squoosh-hqx - < Dockerfile",
"build": "docker run --rm -v $(pwd):/src squoosh-hqx ./build.sh"
}
}

View File

@@ -1,15 +0,0 @@
{
"name": "squooshhqx",
"collaborators": [
"Surma <surma@surma.link>"
],
"version": "0.1.0",
"files": [
"squooshhqx_bg.wasm",
"squooshhqx.js",
"squooshhqx.d.ts"
],
"module": "squooshhqx.js",
"types": "squooshhqx.d.ts",
"sideEffects": false
}

View File

@@ -1,10 +0,0 @@
/* tslint:disable */
/* eslint-disable */
/**
* @param {Uint32Array} input_image
* @param {number} input_width
* @param {number} input_height
* @param {number} factor
* @returns {Uint32Array}
*/
export function resize(input_image: Uint32Array, input_width: number, input_height: number, factor: number): Uint32Array;

View File

@@ -1,2 +0,0 @@
import * as wasm from "./squooshhqx_bg.wasm";
export * from "./squooshhqx_bg.js";

View File

@@ -1,6 +0,0 @@
/* tslint:disable */
/* eslint-disable */
export const memory: WebAssembly.Memory;
export function resize(a: number, b: number, c: number, d: number, e: number, f: number): void;
export function __wbindgen_malloc(a: number): number;
export function __wbindgen_free(a: number, b: number): void;

View File

@@ -1,48 +0,0 @@
import * as wasm from './squooshhqx_bg.wasm';
let cachegetUint32Memory0 = null;
function getUint32Memory0() {
if (cachegetUint32Memory0 === null || cachegetUint32Memory0.buffer !== wasm.memory.buffer) {
cachegetUint32Memory0 = new Uint32Array(wasm.memory.buffer);
}
return cachegetUint32Memory0;
}
let WASM_VECTOR_LEN = 0;
function passArray32ToWasm0(arg, malloc) {
const ptr = malloc(arg.length * 4);
getUint32Memory0().set(arg, ptr / 4);
WASM_VECTOR_LEN = arg.length;
return ptr;
}
let cachegetInt32Memory0 = null;
function getInt32Memory0() {
if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) {
cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer);
}
return cachegetInt32Memory0;
}
function getArrayU32FromWasm0(ptr, len) {
return getUint32Memory0().subarray(ptr / 4, ptr / 4 + len);
}
/**
* @param {Uint32Array} input_image
* @param {number} input_width
* @param {number} input_height
* @param {number} factor
* @returns {Uint32Array}
*/
export function resize(input_image, input_width, input_height, factor) {
var ptr0 = passArray32ToWasm0(input_image, wasm.__wbindgen_malloc);
var len0 = WASM_VECTOR_LEN;
wasm.resize(8, ptr0, len0, input_width, input_height, factor);
var r0 = getInt32Memory0()[8 / 4 + 0];
var r1 = getInt32Memory0()[8 / 4 + 1];
var v1 = getArrayU32FromWasm0(r0, r1).slice();
wasm.__wbindgen_free(r0, r1 * 4);
return v1;
}

Binary file not shown.

View File

@@ -1,55 +0,0 @@
extern crate cfg_if;
extern crate hqx;
extern crate wasm_bindgen;
mod utils;
use cfg_if::cfg_if;
use wasm_bindgen::prelude::*;
cfg_if! {
// When the `wee_alloc` feature is enabled, use `wee_alloc` as the global
// allocator.
if #[cfg(feature = "wee_alloc")] {
extern crate wee_alloc;
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
}
}
#[wasm_bindgen]
#[no_mangle]
pub fn resize(
input_image: Vec<u32>,
input_width: usize,
input_height: usize,
factor: usize,
) -> Vec<u32> {
let num_output_pixels = input_width * input_height * factor * factor;
let mut output_image = Vec::<u32>::with_capacity(num_output_pixels * 4);
output_image.resize(num_output_pixels, 0);
match factor {
2 => hqx::hq2x(
input_image.as_slice(),
output_image.as_mut_slice(),
input_width,
input_height,
),
3 => hqx::hq3x(
input_image.as_slice(),
output_image.as_mut_slice(),
input_width,
input_height,
),
4 => hqx::hq4x(
input_image.as_slice(),
output_image.as_mut_slice(),
input_width,
input_height,
),
_ => unreachable!(),
};
return output_image;
}

View File

@@ -1,17 +0,0 @@
use cfg_if::cfg_if;
cfg_if! {
// When the `console_error_panic_hook` feature is enabled, we can call the
// `set_panic_hook` function at least once during initialization, and then
// we will get better error messages if our code ever panics.
//
// For more details see
// https://github.com/rustwasm/console_error_panic_hook#readme
if #[cfg(feature = "console_error_panic_hook")] {
extern crate console_error_panic_hook;
pub use self::console_error_panic_hook::set_once as set_panic_hook;
} else {
#[inline]
pub fn set_panic_hook() {}
}
}

View File

@@ -1,40 +0,0 @@
CODEC_URL := https://github.com/ImageOptim/libimagequant/archive/2.12.1.tar.gz
CODEC_DIR := node_modules/libimagequant
CODEC_OUT_RELATIVE := libimagequant.a
CODEC_OUT := $(addprefix $(CODEC_DIR)/, $(CODEC_OUT_RELATIVE))
OUT_JS := imagequant.js
OUT_WASM := $(OUT_JS:.js=.wasm)
.PHONY: all clean
all: $(OUT_JS)
%.js: %.cpp $(CODEC_OUT)
$(CXX) \
-I $(CODEC_DIR) \
${CXXFLAGS} \
${LDFLAGS} \
--bind \
--closure 1 \
-s ALLOW_MEMORY_GROWTH=1 \
-s MODULARIZE=1 \
-s 'EXPORT_NAME="$(basename $(@F))"' \
-o $@ \
$+
$(CODEC_OUT): $(CODEC_DIR)/config.mk
$(MAKE) -C $(CODEC_DIR) $(CODEC_OUT_RELATIVE)
$(CODEC_DIR)/config.mk: $(CODEC_DIR)/configure
cd $(CODEC_DIR) && ./configure \
--disable-sse
$(CODEC_DIR)/configure: $(CODEC_DIR)
$(CODEC_DIR):
mkdir -p $@
curl -sL $(CODEC_URL) | tar xz --strip 1 -C $@
clean:
$(RM) $(OUT_JS) $(OUT_WASM)
$(MAKE) -C $(CODEC_DIR) clean

View File

@@ -24,3 +24,7 @@ Quantizes the given images, using at most `numColors`, a value between 2 and 256
### `RawImage zx_quantize(std::string buffer, int image_width, int image_height, float dithering)`
???
### `void free_result()`
Frees the result created by `quantize()`.

48
codecs/imagequant/build.sh Executable file
View File

@@ -0,0 +1,48 @@
#!/bin/bash
set -e
export OPTIMIZE="-Os"
export LDFLAGS="${OPTIMIZE}"
export CFLAGS="${OPTIMIZE}"
export CPPFLAGS="${OPTIMIZE}"
echo "============================================="
echo "Compiling libimagequant"
echo "============================================="
(
emcc \
--bind \
${OPTIMIZE} \
-s ALLOW_MEMORY_GROWTH=1 \
-s MODULARIZE=1 \
-s 'EXPORT_NAME="imagequant"' \
-I node_modules/libimagequant \
--std=c99 \
-c \
node_modules/libimagequant/{libimagequant,pam,mediancut,blur,mempool,kmeans,nearest}.c
)
echo "============================================="
echo "Compiling wasm module"
echo "============================================="
(
emcc \
--bind \
${OPTIMIZE} \
-s ALLOW_MEMORY_GROWTH=1 \
-s MODULARIZE=1 \
-s 'EXPORT_NAME="imagequant"' \
-I node_modules/libimagequant \
-o ./imagequant.js \
--std=c++11 *.o \
-x c++ \
imagequant.cpp
)
echo "============================================="
echo "Compiling wasm module done"
echo "============================================="
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "Did you update your docker image?"
echo "Run \`docker pull trzeci/emscripten\`"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"

View File

@@ -28,6 +28,7 @@
// const rawImage = Module.quantize(image.data, image.width, image.height, 256, 1.0);
const rawImage = Module.zx_quantize(image.data, image.width, image.height, 1.0);
console.log('done');
Module.free_result();
const imageData = new ImageData(new Uint8ClampedArray(rawImage.buffer), rawImage.width, rawImage.height);
const canvas = document.createElement('canvas');

View File

@@ -1,87 +1,95 @@
#include <emscripten/bind.h>
#include <emscripten/val.h>
#include "emscripten/bind.h"
#include "emscripten/val.h"
#include <stdlib.h>
#include <inttypes.h>
#include <limits.h>
#include <math.h>
#include <stdlib.h>
#include "libimagequant.h"
using namespace emscripten;
int version() {
return (((LIQ_VERSION / 10000) % 100) << 16) | (((LIQ_VERSION / 100) % 100) << 8) |
(((LIQ_VERSION / 1) % 100) << 0);
return (((LIQ_VERSION/10000) % 100) << 16) |
(((LIQ_VERSION/100 ) % 100) << 8) |
(((LIQ_VERSION/1 ) % 100) << 0);
}
thread_local const val Uint8ClampedArray = val::global("Uint8ClampedArray");
class RawImage {
public:
val buffer;
int width;
int height;
#define liq_ptr(T) std::unique_ptr<T, std::integral_constant<decltype(&T##_destroy), T##_destroy>>
RawImage(val b, int w, int h)
: buffer(b), width(w), height(h) {}
};
using liq_attr_ptr = liq_ptr(liq_attr);
using liq_image_ptr = liq_ptr(liq_image);
using liq_result_ptr = liq_ptr(liq_result);
liq_result_ptr liq_image_quantize(liq_image* image, liq_attr* attr) {
liq_result* res = nullptr;
liq_image_quantize(image, attr, &res);
return liq_result_ptr(res);
}
val quantize(std::string rawimage,
int image_width,
int image_height,
int num_colors,
float dithering) {
auto image_buffer = (const liq_color*)rawimage.c_str();
liq_attr *attr;
liq_image *image;
liq_result *res;
uint8_t* result;
RawImage quantize(std::string rawimage, int image_width, int image_height, int num_colors, float dithering) {
const uint8_t* image_buffer = (uint8_t*)rawimage.c_str();
int size = image_width * image_height;
liq_attr_ptr attr(liq_attr_create());
liq_image_ptr image(
liq_image_create_rgba(attr.get(), image_buffer, image_width, image_height, 0));
liq_set_max_colors(attr.get(), num_colors);
auto res = liq_image_quantize(image.get(), attr.get());
liq_set_dithering_level(res.get(), dithering);
std::vector<uint8_t> image8bit(size);
std::vector<liq_color> result(size);
liq_write_remapped_image(res.get(), image.get(), image8bit.data(), image8bit.size());
auto pal = liq_get_palette(res.get());
attr = liq_attr_create();
image = liq_image_create_rgba(attr, image_buffer, image_width, image_height, 0);
liq_set_max_colors(attr, num_colors);
liq_image_quantize(image, attr, &res);
liq_set_dithering_level(res, dithering);
uint8_t* image8bit = (uint8_t*) malloc(size);
result = (uint8_t*) malloc(size * 4);
liq_write_remapped_image(res, image, image8bit, size);
const liq_palette *pal = liq_get_palette(res);
// Turn palletted image back into an RGBA image
for (int i = 0; i < size; i++) {
result[i] = pal->entries[image8bit[i]];
for(int i = 0; i < size; i++) {
result[i * 4 + 0] = pal->entries[image8bit[i]].r;
result[i * 4 + 1] = pal->entries[image8bit[i]].g;
result[i * 4 + 2] = pal->entries[image8bit[i]].b;
result[i * 4 + 3] = pal->entries[image8bit[i]].a;
}
return Uint8ClampedArray.new_(
typed_memory_view(result.size() * sizeof(liq_color), (const uint8_t*)result.data()));
free(image8bit);
liq_result_destroy(res);
liq_image_destroy(image);
liq_attr_destroy(attr);
return {
val(typed_memory_view(image_width*image_height*4, result)),
image_width,
image_height
};
}
const liq_color zx_colors[] = {
{.r = 0, .g = 0, .b = 0, .a = 255}, // regular black
{.r = 0, .g = 0, .b = 215, .a = 255}, // regular blue
{.r = 215, .g = 0, .b = 0, .a = 255}, // regular red
{.r = 215, .g = 0, .b = 215, .a = 255}, // regular magenta
{.r = 0, .g = 215, .b = 0, .a = 255}, // regular green
{.r = 0, .g = 215, .b = 215, .a = 255}, // regular cyan
{.r = 215, .g = 215, .b = 0, .a = 255}, // regular yellow
{.r = 215, .g = 215, .b = 215, .a = 255}, // regular white
{.r = 0, .g = 0, .b = 255, .a = 255}, // bright blue
{.r = 255, .g = 0, .b = 0, .a = 255}, // bright red
{.r = 255, .g = 0, .b = 255, .a = 255}, // bright magenta
{.r = 0, .g = 255, .b = 0, .a = 255}, // bright green
{.r = 0, .g = 255, .b = 255, .a = 255}, // bright cyan
{.r = 255, .g = 255, .b = 0, .a = 255}, // bright yellow
{.r = 255, .g = 255, .b = 255, .a = 255} // bright white
{.a = 255, .r = 0, .g = 0, .b = 0}, // regular black
{.a = 255, .r = 0, .g = 0, .b = 215}, // regular blue
{.a = 255, .r = 215, .g = 0, .b = 0}, // regular red
{.a = 255, .r = 215, .g = 0, .b = 215}, // regular magenta
{.a = 255, .r = 0, .g = 215, .b = 0}, // regular green
{.a = 255, .r = 0, .g = 215, .b = 215}, // regular cyan
{.a = 255, .r = 215, .g = 215, .b = 0}, // regular yellow
{.a = 255, .r = 215, .g = 215, .b = 215}, // regular white
{.a = 255, .r = 0, .g = 0, .b = 255}, // bright blue
{.a = 255, .r = 255, .g = 0, .b = 0}, // bright red
{.a = 255, .r = 255, .g = 0, .b = 255}, // bright magenta
{.a = 255, .r = 0, .g = 255, .b = 0}, // bright green
{.a = 255, .r = 0, .g = 255, .b = 255}, // bright cyan
{.a = 255, .r = 255, .g = 255, .b = 0}, // bright yellow
{.a = 255, .r = 255, .g = 255, .b = 255} // bright white
};
uint8_t block[8 * 8 * 4];
/**
* The ZX has one bit per pixel, but can assign two colours to an 8x8 block. The
* two colours must both be 'regular' or 'bright'. Black exists as both regular
* and bright.
* The ZX has one bit per pixel, but can assign two colours to an 8x8 block. The two colours must
* both be 'regular' or 'bright'. Black exists as both regular and bright.
*/
val zx_quantize(std::string rawimage, int image_width, int image_height, float dithering) {
auto image_buffer = (const liq_color*)rawimage.c_str();
RawImage zx_quantize(std::string rawimage, int image_width, int image_height, float dithering) {
const uint8_t* image_buffer = (uint8_t*) rawimage.c_str();
int size = image_width * image_height;
liq_color block[8 * 8];
uint8_t image8bit[8 * 8];
std::vector<liq_color> result(size);
int bytes_per_pixel = 4;
result = (uint8_t*) malloc(size * bytes_per_pixel);
uint8_t* image8bit = (uint8_t*) malloc(8 * 8);
// For each 8x8 grid
for (int block_start_y = 0; block_start_y < image_height; block_start_y += 8) {
@@ -91,8 +99,7 @@ val zx_quantize(std::string rawimage, int image_width, int image_height, float d
int block_width = 8;
int block_height = 8;
// If the block hangs off the right/bottom of the image dimensions, make
// it smaller to fit.
// If the block hangs off the right/bottom of the image dimensions, make it smaller to fit.
if (block_start_y + block_height > image_height) {
block_height = image_height - block_start_y;
}
@@ -104,22 +111,26 @@ val zx_quantize(std::string rawimage, int image_width, int image_height, float d
// For each pixel in that block:
for (int y = block_start_y; y < block_start_y + block_height; y++) {
for (int x = block_start_x; x < block_start_x + block_width; x++) {
int pixel_start = (y * image_width) + x;
int pixel_start = (y * image_width * bytes_per_pixel) + (x * bytes_per_pixel);
int smallest_distance = INT_MAX;
int winning_index = -1;
// Copy pixel data for quantizing later
block[block_index++] = image_buffer[pixel_start];
block[block_index++] = image_buffer[pixel_start + 1];
block[block_index++] = image_buffer[pixel_start + 2];
block[block_index++] = image_buffer[pixel_start + 3];
// Which zx color is this pixel closest to?
for (int color_index = 0; color_index < 15; color_index++) {
liq_color color = zx_colors[color_index];
liq_color pixel = image_buffer[pixel_start];
// Using Euclidean distance. LibQuant has better methods, but it
// requires conversion to LAB, so I don't think it's worth it.
// Using Euclidean distance. LibQuant has better methods, but it requires conversion to
// LAB, so I don't think it's worth it.
int distance =
pow(color.r - pixel.r, 2) + pow(color.g - pixel.g, 2) + pow(color.b - pixel.b, 2);
pow(color.r - image_buffer[pixel_start + 0], 2) +
pow(color.g - image_buffer[pixel_start + 1], 2) +
pow(color.b - image_buffer[pixel_start + 2], 2);
if (distance < smallest_distance) {
winning_index = color_index;
@@ -140,8 +151,7 @@ val zx_quantize(std::string rawimage, int image_width, int image_height, float d
for (int color_index = 0; color_index < 15; color_index++) {
if (color_popularity[color_index] > highest_popularity) {
// Store this as the most popular pixel, and demote the current
// values:
// Store this as the most popular pixel, and demote the current values:
third_color_index = second_color_index;
third_highest_popularity = second_highest_popularity;
second_color_index = first_color_index;
@@ -159,8 +169,8 @@ val zx_quantize(std::string rawimage, int image_width, int image_height, float d
}
}
// ZX images can't mix bright and regular colours, except black which
// appears in both. Resolve any conflict:
// ZX images can't mix bright and regular colours, except black which appears in both.
// Resolve any conflict:
while (1) {
// If either colour is black, there's no conflict to resolve.
if (first_color_index != 0 && second_color_index != 0) {
@@ -173,44 +183,63 @@ val zx_quantize(std::string rawimage, int image_width, int image_height, float d
}
}
// If, during conflict resolving, we now have two of the same colour
// (because we initially selected the bright & regular version of the
// same colour), retry again with the third most popular colour.
// If, during conflict resolving, we now have two of the same colour (because we initially
// selected the bright & regular version of the same colour), retry again with the third
// most popular colour.
if (first_color_index == second_color_index) {
second_color_index = third_color_index;
} else
break;
} else break;
}
// Quantize
liq_attr_ptr attr(liq_attr_create());
liq_image_ptr image(liq_image_create_rgba(attr.get(), block, block_width, block_height, 0));
liq_set_max_colors(attr.get(), 2);
liq_image_add_fixed_color(image.get(), zx_colors[first_color_index]);
liq_image_add_fixed_color(image.get(), zx_colors[second_color_index]);
auto res = liq_image_quantize(image.get(), attr.get());
liq_set_dithering_level(res.get(), dithering);
liq_write_remapped_image(res.get(), image.get(), image8bit, size);
auto pal = liq_get_palette(res.get());
attr = liq_attr_create();
image = liq_image_create_rgba(attr, block, block_width, block_height, 0);
liq_set_max_colors(attr, 2);
liq_image_add_fixed_color(image, zx_colors[first_color_index]);
liq_image_add_fixed_color(image, zx_colors[second_color_index]);
liq_image_quantize(image, attr, &res);
liq_set_dithering_level(res, dithering);
liq_write_remapped_image(res, image, image8bit, size);
const liq_palette *pal = liq_get_palette(res);
// Turn palletted image back into an RGBA image, and write it into the
// full size result image.
for (int y = 0; y < block_height; y++) {
for (int x = 0; x < block_width; x++) {
// Turn palletted image back into an RGBA image, and write it into the full size result image.
for(int y = 0; y < block_height; y++) {
for(int x = 0; x < block_width; x++) {
int image8BitPos = y * block_width + x;
int resultStartPos = ((block_start_y + y) * image_width) + (block_start_x + x);
result[resultStartPos] = pal->entries[image8bit[image8BitPos]];
int resultStartPos = ((block_start_y + y) * bytes_per_pixel * image_width) + ((block_start_x + x) * bytes_per_pixel);
result[resultStartPos + 0] = pal->entries[image8bit[image8BitPos]].r;
result[resultStartPos + 1] = pal->entries[image8bit[image8BitPos]].g;
result[resultStartPos + 2] = pal->entries[image8bit[image8BitPos]].b;
result[resultStartPos + 3] = pal->entries[image8bit[image8BitPos]].a;
}
}
liq_result_destroy(res);
liq_image_destroy(image);
liq_attr_destroy(attr);
}
}
return Uint8ClampedArray.new_(
typed_memory_view(result.size() * sizeof(liq_color), (const uint8_t*)result.data()));
free(image8bit);
return {
val(typed_memory_view(image_width*image_height*4, result)),
image_width,
image_height
};
}
void free_result() {
free(result);
}
EMSCRIPTEN_BINDINGS(my_module) {
class_<RawImage>("RawImage")
.property("buffer", &RawImage::buffer)
.property("width", &RawImage::width)
.property("height", &RawImage::height);
function("quantize", &quantize);
function("zx_quantize", &zx_quantize);
function("version", &version);
function("free_result", &free_result);
}

View File

@@ -1,6 +1,15 @@
interface RawImage {
buffer: Uint8Array;
width: number;
height: number;
}
interface QuantizerModule extends EmscriptenWasm.Module {
quantize(data: BufferSource, width: number, height: number, numColors: number, dither: number): Uint8ClampedArray;
zx_quantize(data: BufferSource, width: number, height: number, dither: number): Uint8ClampedArray;
quantize(data: BufferSource, width: number, height: number, numColors: number, dither: number): RawImage;
zx_quantize(data: BufferSource, width: number, height: number, dither: number): RawImage;
free_result(): void;
}
export default function(opts: EmscriptenWasm.ModuleOpts): QuantizerModule;

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,13 @@
{
"name": "imagequant",
"scripts": {
"build": "../build-cpp.sh"
"install": "napa",
"build": "docker run --rm -v $(pwd):/src trzeci/emscripten ./build.sh"
},
"napa": {
"libimagequant": "ImageOptim/libimagequant#2.12.1"
},
"devDependencies": {
"napa": "^3.0.0"
}
}

View File

@@ -1 +0,0 @@
node_modules

View File

@@ -1,67 +0,0 @@
CODEC_URL = https://gitlab.com/wg1/jpeg-xl.git
CODEC_VERSION = 4d70bd58fbcb758b61446aba447fedd9177a00c9
CODEC_DIR = node_modules/jxl
CODEC_BUILD_DIR := $(CODEC_DIR)/build
CODEC_OUT := $(CODEC_BUILD_DIR)/lib/libjxl.a
OUT_JS = enc/jxl_enc.js dec/jxl_dec.js
OUT_WASM = $(OUT_JS:.js=.wasm)
.PHONY: all clean
all: $(OUT_JS)
%.js: %.cpp $(LIBAOM_OUT) $(CODEC_OUT)
$(CXX) \
-I $(CODEC_DIR) \
-I $(CODEC_DIR)/lib \
-I $(CODEC_DIR)/lib/include \
-I $(CODEC_BUILD_DIR)/lib/include \
-I $(CODEC_DIR)/third_party/highway \
-I $(CODEC_DIR)/third_party/skcms \
-I $(CODEC_DIR)/third_party/brunsli \
-I $(CODEC_DIR)/third_party/brunsli/c/include \
${CXXFLAGS} \
${LDFLAGS} \
--bind \
--closure 1 \
-s ALLOW_MEMORY_GROWTH=1 \
-s MAXIMUM_MEMORY=4GB \
-s MODULARIZE=1 \
-s 'EXPORT_NAME="$(basename $(@F))"' \
-o $@ \
$+ \
$(CODEC_BUILD_DIR)/artifacts/libbrunslienc-static.bc \
$(CODEC_BUILD_DIR)/artifacts/libbrunslicommon-static.bc \
$(CODEC_BUILD_DIR)/artifacts/libbrunslidec-static.bc \
$(CODEC_BUILD_DIR)/third_party/brotli/libbrotlidec-static.a \
$(CODEC_BUILD_DIR)/third_party/brotli/libbrotlienc-static.a \
$(CODEC_BUILD_DIR)/third_party/brotli/libbrotlicommon-static.a \
$(CODEC_BUILD_DIR)/third_party/libskcms.a \
$(CODEC_BUILD_DIR)/third_party/highway/libhwy.a
$(CODEC_OUT): $(CODEC_DIR)/CMakeLists.txt
mkdir -p $(CODEC_BUILD_DIR)
cd $(CODEC_BUILD_DIR) && \
emcmake cmake ../ && \
$(MAKE) jxl-static
$(CODEC_DIR)/CMakeLists.txt: $(CODEC_DIR)
$(CODEC_DIR):
# The JXL repository doesnt have version tags or anything yet,
# so we have to pin to a specific commit for now. This implies we
# cant use --recursive, as we will change commit after checkout (it
# seems you cant clone a specific commit directly), and it also means
# we cant use --depth 1 because we want to change commits.
# The JXL code base also relies on submodules so we cant just download
# a .tar.gz from GitLab.
mkdir -p $@
git clone $(CODEC_URL) $@
cd $@ && \
git reset --hard $(CODEC_VERSION) && \
git submodule update --init --recursive
clean:
$(RM) $(OUT_JS) $(OUT_WASM)
$(MAKE) -C $(CODEC_BUILD_DIR) clean

View File

@@ -1,82 +0,0 @@
#include <emscripten/bind.h>
#include <emscripten/val.h>
#include <jxl/decode.h>
#include "lib/jxl/color_encoding_internal.h"
#include "skcms.h"
using namespace emscripten;
thread_local const val Uint8ClampedArray = val::global("Uint8ClampedArray");
thread_local const val ImageData = val::global("ImageData");
#define EXPECT_EQ(a, b) \
if ((a) != (b)) { \
JxlDecoderDestroy(dec); \
return val::null(); \
}
val decode(std::string data) {
JxlDecoder* dec = JxlDecoderCreate(nullptr);
EXPECT_EQ(JXL_DEC_SUCCESS,
JxlDecoderSubscribeEvents(
dec, JXL_DEC_BASIC_INFO | JXL_DEC_COLOR_ENCODING | JXL_DEC_FULL_IMAGE));
auto next_in = (const uint8_t*)data.c_str();
auto avail_in = data.size();
EXPECT_EQ(JXL_DEC_BASIC_INFO, JxlDecoderProcessInput(dec, &next_in, &avail_in));
size_t buffer_size;
const JxlPixelFormat format = {4, JXL_LITTLE_ENDIAN, JXL_TYPE_FLOAT};
EXPECT_EQ(JXL_DEC_SUCCESS, JxlDecoderImageOutBufferSize(dec, &format, &buffer_size));
JxlBasicInfo info;
EXPECT_EQ(JXL_DEC_SUCCESS, JxlDecoderGetBasicInfo(dec, &info));
EXPECT_EQ(JXL_DEC_COLOR_ENCODING, JxlDecoderProcessInput(dec, &next_in, &avail_in));
size_t icc_size;
EXPECT_EQ(JXL_DEC_SUCCESS,
JxlDecoderGetICCProfileSize(dec, JXL_COLOR_PROFILE_TARGET_DATA, &icc_size));
std::vector<uint8_t> icc_profile(icc_size);
EXPECT_EQ(JXL_DEC_SUCCESS,
JxlDecoderGetColorAsICCProfile(dec, JXL_COLOR_PROFILE_TARGET_DATA, icc_profile.data(),
icc_profile.size()));
std::unique_ptr<float[]> float_pixels(new float[(buffer_size + 3) / 4]);
EXPECT_EQ(JXL_DEC_SUCCESS,
JxlDecoderSetImageOutBuffer(
dec, &format, reinterpret_cast<uint8_t*>(float_pixels.get()), buffer_size));
EXPECT_EQ(JXL_DEC_FULL_IMAGE, JxlDecoderProcessInput(dec, &next_in, &avail_in));
JxlDecoderDestroy(dec);
#undef EXPECT_EQ
#define EXPECT_TRUE(a) \
if (!(a)) { \
return val::null(); \
}
std::unique_ptr<uint8_t[]> pixels(new uint8_t[info.xsize * info.ysize * 4]);
// Convert to sRGB.
skcms_ICCProfile jxl_profile;
// If the image is encoded in its original color space, the decoded data will be in the color
// space defined by the decoded ICC profile. Otherwise, it is in Linear sRGB. TODO: the decoded
// color profile should also be Linear sRGB if !uses_original_profile.
if (info.uses_original_profile) {
EXPECT_TRUE(skcms_Parse(icc_profile.data(), icc_profile.size(), &jxl_profile));
} else {
auto s = jxl::ColorEncoding::LinearSRGB(/*gray=*/false);
EXPECT_TRUE(s.CreateICC());
EXPECT_TRUE(skcms_Parse(s.ICC().data(), s.ICC().size(), &jxl_profile));
}
EXPECT_TRUE(skcms_Transform(
float_pixels.get(), skcms_PixelFormat_RGBA_ffff,
info.alpha_premultiplied ? skcms_AlphaFormat_PremulAsEncoded : skcms_AlphaFormat_Unpremul,
&jxl_profile, pixels.get(), skcms_PixelFormat_RGBA_8888, skcms_AlphaFormat_Unpremul,
skcms_sRGB_profile(), info.xsize * info.ysize));
return ImageData.new_(
Uint8ClampedArray.new_(typed_memory_view(info.xsize * info.ysize * 4, pixels.get())),
info.xsize, info.ysize);
}
EMSCRIPTEN_BINDINGS(my_module) {
function("decode", &decode);
}

View File

@@ -1,5 +0,0 @@
interface JXLModule extends EmscriptenWasm.Module {
decode(data: BufferSource): ImageData;
}
export default function(opts: EmscriptenWasm.ModuleOpts): JXLModule;

View File

@@ -1,69 +0,0 @@
var jxl_dec = (function() {
var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename;
return (
function(jxl_dec) {
jxl_dec = jxl_dec || {};
var d;d||(d=typeof jxl_dec !== 'undefined' ? jxl_dec : {});var aa,ba;d.ready=new Promise(function(a,b){aa=a;ba=b});var r={},t;for(t in d)d.hasOwnProperty(t)&&(r[t]=d[t]);var ca="./this.program",u=!1,v=!1,da=!1,ea=!1;u="object"===typeof window;v="function"===typeof importScripts;da="object"===typeof process&&"object"===typeof process.versions&&"string"===typeof process.versions.node;ea=!u&&!da&&!v;var w="",x,z,fa,ha;
if(da)w=v?require("path").dirname(w)+"/":__dirname+"/",x=function(a,b){fa||(fa=require("fs"));ha||(ha=require("path"));a=ha.normalize(a);return fa.readFileSync(a,b?null:"utf8")},z=function(a){a=x(a,!0);a.buffer||(a=new Uint8Array(a));a.buffer||A("Assertion failed: undefined");return a},1<process.argv.length&&(ca=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),process.on("uncaughtException",function(a){throw a;}),process.on("unhandledRejection",A),d.inspect=function(){return"[Emscripten Module object]"};
else if(ea)"undefined"!=typeof read&&(x=function(a){return read(a)}),z=function(a){if("function"===typeof readbuffer)return new Uint8Array(readbuffer(a));a=read(a,"binary");"object"===typeof a||A("Assertion failed: undefined");return a},"undefined"!==typeof print&&("undefined"===typeof console&&(console={}),console.log=print,console.warn=console.error="undefined"!==typeof printErr?printErr:print);else if(u||v)v?w=self.location.href:document.currentScript&&(w=document.currentScript.src),_scriptDir&&
(w=_scriptDir),0!==w.indexOf("blob:")?w=w.substr(0,w.lastIndexOf("/")+1):w="",x=function(a){var b=new XMLHttpRequest;b.open("GET",a,!1);b.send(null);return b.responseText},v&&(z=function(a){var b=new XMLHttpRequest;b.open("GET",a,!1);b.responseType="arraybuffer";b.send(null);return new Uint8Array(b.response)});var ia=d.print||console.log.bind(console),B=d.printErr||console.warn.bind(console);for(t in r)r.hasOwnProperty(t)&&(d[t]=r[t]);r=null;d.thisProgram&&(ca=d.thisProgram);var D;
d.wasmBinary&&(D=d.wasmBinary);var noExitRuntime;d.noExitRuntime&&(noExitRuntime=d.noExitRuntime);"object"!==typeof WebAssembly&&A("no native wasm support detected");var E,ja=new WebAssembly.Table({initial:280,maximum:280,element:"anyfunc"}),ka=!1,la="undefined"!==typeof TextDecoder?new TextDecoder("utf8"):void 0;
function ma(a,b,c){b>>>=0;var e=b+c;for(c=b;a[c>>>0]&&!(c>=e);)++c;if(16<c-b&&a.subarray&&la)return la.decode(a.subarray(b>>>0,c>>>0));for(e="";b<c;){var f=a[b++>>>0];if(f&128){var g=a[b++>>>0]&63;if(192==(f&224))e+=String.fromCharCode((f&31)<<6|g);else{var l=a[b++>>>0]&63;f=224==(f&240)?(f&15)<<12|g<<6|l:(f&7)<<18|g<<12|l<<6|a[b++>>>0]&63;65536>f?e+=String.fromCharCode(f):(f-=65536,e+=String.fromCharCode(55296|f>>10,56320|f&1023))}}else e+=String.fromCharCode(f)}return e}
function na(a,b,c){var e=F;b>>>=0;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;e[b++>>>0]=g}else{if(2047>=g){if(b+1>=c)break;e[b++>>>0]=192|g>>6}else{if(65535>=g){if(b+2>=c)break;e[b++>>>0]=224|g>>12}else{if(b+3>=c)break;e[b++>>>0]=240|g>>18;e[b++>>>0]=128|g>>12&63}e[b++>>>0]=128|g>>6&63}e[b++>>>0]=128|g&63}}e[b>>>0]=0}}
var oa="undefined"!==typeof TextDecoder?new TextDecoder("utf-16le"):void 0;function pa(a,b){var c=a>>1;for(var e=c+b/2;!(c>=e)&&G[c>>>0];)++c;c<<=1;if(32<c-a&&oa)return oa.decode(F.subarray(a>>>0,c>>>0));c=0;for(e="";;){var f=H[a+2*c>>1>>>0];if(0==f||c==b/2)return e;++c;e+=String.fromCharCode(f)}}function qa(a,b,c){void 0===c&&(c=2147483647);if(2>c)return 0;c-=2;var e=b;c=c<2*a.length?c/2:a.length;for(var f=0;f<c;++f)H[b>>1>>>0]=a.charCodeAt(f),b+=2;H[b>>1>>>0]=0;return b-e}
function ra(a){return 2*a.length}function sa(a,b){for(var c=0,e="";!(c>=b/4);){var f=I[a+4*c>>2>>>0];if(0==f)break;++c;65536<=f?(f-=65536,e+=String.fromCharCode(55296|f>>10,56320|f&1023)):e+=String.fromCharCode(f)}return e}function ta(a,b,c){b>>>=0;void 0===c&&(c=2147483647);if(4>c)return 0;var e=b;c=e+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}I[b>>2>>>0]=g;b+=4;if(b+4>c)break}I[b>>2>>>0]=0;return b-e}
function ua(a){for(var b=0,c=0;c<a.length;++c){var e=a.charCodeAt(c);55296<=e&&57343>=e&&++c;b+=4}return b}var J,L,F,H,G,I,M,va,wa;function xa(a){J=a;d.HEAP8=L=new Int8Array(a);d.HEAP16=H=new Int16Array(a);d.HEAP32=I=new Int32Array(a);d.HEAPU8=F=new Uint8Array(a);d.HEAPU16=G=new Uint16Array(a);d.HEAPU32=M=new Uint32Array(a);d.HEAPF32=va=new Float32Array(a);d.HEAPF64=wa=new Float64Array(a)}var ya=d.INITIAL_MEMORY||16777216;d.wasmMemory?E=d.wasmMemory:E=new WebAssembly.Memory({initial:ya/65536,maximum:65536});
E&&(J=E.buffer);ya=J.byteLength;xa(J);I[755548]=8265232;function N(a){for(;0<a.length;){var b=a.shift();if("function"==typeof b)b(d);else{var c=b.da;"number"===typeof c?void 0===b.Z?d.dynCall_v(c):d.dynCall_vi(c,b.Z):c(void 0===b.Z?null:b.Z)}}}var za=[],Aa=[],Ba=[],Ca=[];function Da(){var a=d.preRun.shift();za.unshift(a)}var Ea=Math.ceil,Fa=Math.floor,O=0,Ga=null,Q=null;d.preloadedImages={};d.preloadedAudios={};
function A(a){if(d.onAbort)d.onAbort(a);B(a);ka=!0;a=new WebAssembly.RuntimeError("abort("+a+"). Build with -s ASSERTIONS=1 for more info.");ba(a);throw a;}function Ha(a){var b=R;return String.prototype.startsWith?b.startsWith(a):0===b.indexOf(a)}function Ia(){return Ha("data:application/octet-stream;base64,")}var R="jxl_dec.wasm";if(!Ia()){var Ja=R;R=d.locateFile?d.locateFile(Ja,w):w+Ja}
function Ka(){try{if(D)return new Uint8Array(D);if(z)return z(R);throw"both async and sync fetching of the wasm failed";}catch(a){A(a)}}function La(){return D||!u&&!v||"function"!==typeof fetch||Ha("file://")?new Promise(function(a){a(Ka())}):fetch(R,{credentials:"same-origin"}).then(function(a){if(!a.ok)throw"failed to load wasm binary file at '"+R+"'";return a.arrayBuffer()}).catch(function(){return Ka()})}Aa.push({da:function(){Ma()}});function S(){return 0<S.aa}
function Na(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 Oa=void 0;function T(a){for(var b="";F[a>>>0];)b+=Oa[F[a++>>>0]];return b}var U={},V={},Pa={};function Qa(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 Ra(a,b){a=Qa(a);return(new Function("body","return function "+a+'() {\n "use strict"; return body.apply(this, arguments);\n};\n'))(b)}function Sa(a){var b=Error,c=Ra(a,function(e){this.name=a;this.message=e;e=Error(e).stack;void 0!==e&&(this.stack=this.toString()+"\n"+e.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 Ta=void 0;function W(a){throw new Ta(a);}var Ua=void 0;function Va(a,b){function c(h){h=b(h);if(h.length!==e.length)throw new Ua("Mismatched type converter count");for(var k=0;k<e.length;++k)X(e[k],h[k])}var e=[];e.forEach(function(h){Pa[h]=a});var f=Array(a.length),g=[],l=0;a.forEach(function(h,k){V.hasOwnProperty(h)?f[k]=V[h]:(g.push(h),U.hasOwnProperty(h)||(U[h]=[]),U[h].push(function(){f[k]=V[h];++l;l===g.length&&c(f)}))});0===g.length&&c(f)}
function X(a,b,c){c=c||{};if(!("argPackAdvance"in b))throw new TypeError("registerType registeredInstance requires argPackAdvance");var e=b.name;a||W('type "'+e+'" must have a positive integer typeid pointer');if(V.hasOwnProperty(a)){if(c.ea)return;W("Cannot register type '"+e+"' twice")}V[a]=b;delete Pa[a];U.hasOwnProperty(a)&&(b=U[a],delete U[a],b.forEach(function(f){f()}))}var Wa=[],Y=[{},{value:void 0},{value:null},{value:!0},{value:!1}];
function Xa(a){4<a&&0===--Y[a].$&&(Y[a]=void 0,Wa.push(a))}function Ya(a){switch(a){case void 0:return 1;case null:return 2;case !0:return 3;case !1:return 4;default:var b=Wa.length?Wa.pop():Y.length;Y[b]={$:1,value:a};return b}}function Za(a){return this.fromWireType(M[a>>>2])}function $a(a){if(null===a)return"null";var b=typeof a;return"object"===b||"array"===b||"function"===b?a.toString():""+a}
function cb(a,b){switch(b){case 2:return function(c){return this.fromWireType(va[c>>>2])};case 3:return function(c){return this.fromWireType(wa[c>>>3])};default:throw new TypeError("Unknown float type: "+a);}}function db(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=Ra(b.name||"unknownFunctionName",function(){});c.prototype=b.prototype;c=new c;a=b.apply(c,a);return a instanceof Object?a:c}
function eb(a){for(;a.length;){var b=a.pop();a.pop()(b)}}function fb(a,b){var c=d;if(void 0===c[a].X){var e=c[a];c[a]=function(){c[a].X.hasOwnProperty(arguments.length)||W("Function '"+b+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+c[a].X+")!");return c[a].X[arguments.length].apply(this,arguments)};c[a].X=[];c[a].X[e.ba]=e}}
function gb(a,b,c){d.hasOwnProperty(a)?((void 0===c||void 0!==d[a].X&&void 0!==d[a].X[c])&&W("Cannot register public name '"+a+"' twice"),fb(a,a),d.hasOwnProperty(c)&&W("Cannot register multiple overloads of a function with the same number of arguments ("+c+")!"),d[a].X[c]=b):(d[a]=b,void 0!==c&&(d[a].ga=c))}function hb(a,b){for(var c=[],e=0;e<a;e++)c.push(I[(b>>2)+e>>>0]);return c}
function ib(a,b){a=T(a);var c=d["dynCall_"+a];for(var e=[],f=1;f<a.length;++f)e.push("a"+f);f="return function dynCall_"+(a+"_"+b)+"("+e.join(", ")+") {\n";f+=" return dynCall(rawFunction"+(e.length?", ":"")+e.join(", ")+");\n";c=(new Function("dynCall","rawFunction",f+"};\n"))(c,b);"function"!==typeof c&&W("unknown function pointer with signature "+a+": "+b);return c}var jb=void 0;function kb(a){a=lb(a);var b=T(a);Z(a);return b}
function mb(a,b){function c(g){f[g]||V[g]||(Pa[g]?Pa[g].forEach(c):(e.push(g),f[g]=!0))}var e=[],f={};b.forEach(c);throw new jb(a+": "+e.map(kb).join([", "]));}function nb(a,b,c){switch(b){case 0:return c?function(e){return L[e>>>0]}:function(e){return F[e>>>0]};case 1:return c?function(e){return H[e>>>1]}:function(e){return G[e>>>1]};case 2:return c?function(e){return I[e>>>2]}:function(e){return M[e>>>2]};default:throw new TypeError("Unknown integer type: "+a);}}var ob={};
function pb(){return"object"===typeof globalThis?globalThis:Function("return this")()}function qb(a,b){var c=V[a];void 0===c&&W(b+" has unknown type "+kb(a));return c}var rb={},sb={};function tb(){if(!ub){var a={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"===typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:ca||"./this.program"},b;for(b in sb)a[b]=sb[b];var c=[];for(b in a)c.push(b+"="+a[b]);ub=c}return ub}
for(var ub,vb=[null,[],[]],wb=Array(256),xb=0;256>xb;++xb)wb[xb]=String.fromCharCode(xb);Oa=wb;Ta=d.BindingError=Sa("BindingError");Ua=d.InternalError=Sa("InternalError");d.count_emval_handles=function(){for(var a=0,b=5;b<Y.length;++b)void 0!==Y[b]&&++a;return a};d.get_first_emval=function(){for(var a=5;a<Y.length;++a)if(void 0!==Y[a])return Y[a];return null};jb=d.UnboundTypeError=Sa("UnboundTypeError");
var zb={q:function(a){return yb(a)},l:function(){},p:function(a){"uncaught_exception"in S?S.aa++:S.aa=1;throw a;},z:function(a,b,c,e,f){var g=Na(c);b=T(b);X(a,{name:b,fromWireType:function(l){return!!l},toWireType:function(l,h){return h?e:f},argPackAdvance:8,readValueFromPointer:function(l){if(1===c)var h=L;else if(2===c)h=H;else if(4===c)h=I;else throw new TypeError("Unknown boolean type size: "+b);return this.fromWireType(h[l>>>g])},Y:null})},y:function(a,b){b=T(b);X(a,{name:b,fromWireType:function(c){var e=
Y[c].value;Xa(c);return e},toWireType:function(c,e){return Ya(e)},argPackAdvance:8,readValueFromPointer:Za,Y:null})},j:function(a,b,c){c=Na(c);b=T(b);X(a,{name:b,fromWireType:function(e){return e},toWireType:function(e,f){if("number"!==typeof f&&"boolean"!==typeof f)throw new TypeError('Cannot convert "'+$a(f)+'" to '+this.name);return f},argPackAdvance:8,readValueFromPointer:cb(b,c),Y:null})},n:function(a,b,c,e,f,g){var l=hb(b,c);a=T(a);f=ib(e,f);gb(a,function(){mb("Cannot call "+a+" due to unbound types",
l)},b-1);Va(l,function(h){var k=[h[0],null].concat(h.slice(1)),m=h=a,p=f,q=k.length;2>q&&W("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var y=null!==k[1]&&!1,C=!1,n=1;n<k.length;++n)if(null!==k[n]&&void 0===k[n].Y){C=!0;break}var ab="void"!==k[0].name,K="",P="";for(n=0;n<q-2;++n)K+=(0!==n?", ":"")+"arg"+n,P+=(0!==n?", ":"")+"arg"+n+"Wired";m="return function "+Qa(m)+"("+K+") {\nif (arguments.length !== "+(q-2)+") {\nthrowBindingError('function "+m+" called with ' + arguments.length + ' arguments, expected "+
(q-2)+" args!');\n}\n";C&&(m+="var destructors = [];\n");var bb=C?"destructors":"null";K="throwBindingError invoker fn runDestructors retType classParam".split(" ");p=[W,p,g,eb,k[0],k[1]];y&&(m+="var thisWired = classParam.toWireType("+bb+", this);\n");for(n=0;n<q-2;++n)m+="var arg"+n+"Wired = argType"+n+".toWireType("+bb+", arg"+n+"); // "+k[n+2].name+"\n",K.push("argType"+n),p.push(k[n+2]);y&&(P="thisWired"+(0<P.length?", ":"")+P);m+=(ab?"var rv = ":"")+"invoker(fn"+(0<P.length?", ":"")+P+");\n";
if(C)m+="runDestructors(destructors);\n";else for(n=y?1:2;n<k.length;++n)q=1===n?"thisWired":"arg"+(n-2)+"Wired",null!==k[n].Y&&(m+=q+"_dtor("+q+"); // "+k[n].name+"\n",K.push(q+"_dtor"),p.push(k[n].Y));ab&&(m+="var ret = retType.fromWireType(rv);\nreturn ret;\n");K.push(m+"}\n");k=db(K).apply(null,p);n=b-1;if(!d.hasOwnProperty(h))throw new Ua("Replacing nonexistant public symbol");void 0!==d[h].X&&void 0!==n?d[h].X[n]=k:(d[h]=k,d[h].ba=n);return[]})},b:function(a,b,c,e,f){function g(m){return m}
b=T(b);-1===f&&(f=4294967295);var l=Na(c);if(0===e){var h=32-8*c;g=function(m){return m<<h>>>h}}var k=-1!=b.indexOf("unsigned");X(a,{name:b,fromWireType:g,toWireType:function(m,p){if("number"!==typeof p&&"boolean"!==typeof p)throw new TypeError('Cannot convert "'+$a(p)+'" to '+this.name);if(p<e||p>f)throw new TypeError('Passing a number "'+$a(p)+'" from JS side to C/C++ side to an argument of type "'+b+'", which is outside the valid range ['+e+", "+f+"]!");return k?p>>>0:p|0},argPackAdvance:8,readValueFromPointer:nb(b,
l,0!==e),Y:null})},a:function(a,b,c){function e(g){g>>=2;var l=M;return new f(J,l[g+1>>>0],l[g>>>0])}var f=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][b];c=T(c);X(a,{name:c,fromWireType:e,argPackAdvance:8,readValueFromPointer:e},{ea:!0})},k:function(a,b){b=T(b);var c="std::string"===b;X(a,{name:b,fromWireType:function(e){var f=M[e>>>2];if(c)for(var g=e+4,l=0;l<=f;++l){var h=e+4+l;if(l==f||0==F[h>>>0]){var k=g;g=(k>>>=0)?ma(F,k,h-g):"";if(void 0===
m)var m=g;else m+=String.fromCharCode(0),m+=g;g=h+1}}else{m=Array(f);for(l=0;l<f;++l)m[l]=String.fromCharCode(F[e+4+l>>>0]);m=m.join("")}Z(e);return m},toWireType:function(e,f){f instanceof ArrayBuffer&&(f=new Uint8Array(f));var g="string"===typeof f;g||f instanceof Uint8Array||f instanceof Uint8ClampedArray||f instanceof Int8Array||W("Cannot pass non-string to std::string");var l=(c&&g?function(){for(var m=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?++m:m=2047>=q?m+2:65535>=q?m+3:m+4}return m}:function(){return f.length})(),h=yb(4+l+1);h>>>=0;M[h>>>2]=l;if(c&&g)na(f,h+4,l+1);else if(g)for(g=0;g<l;++g){var k=f.charCodeAt(g);255<k&&(Z(h),W("String has UTF-16 code units that do not fit in 8 bits"));F[h+4+g>>>0]=k}else for(g=0;g<l;++g)F[h+4+g>>>0]=f[g];null!==e&&e.push(Z,h);return h},argPackAdvance:8,readValueFromPointer:Za,Y:function(e){Z(e)}})},d:function(a,b,c){c=T(c);if(2===b){var e=pa;var f=qa;var g=ra;var l=function(){return G};
var h=1}else 4===b&&(e=sa,f=ta,g=ua,l=function(){return M},h=2);X(a,{name:c,fromWireType:function(k){for(var m=M[k>>>2],p=l(),q,y=k+4,C=0;C<=m;++C){var n=k+4+C*b;if(C==m||0==p[n>>>h])y=e(y,n-y),void 0===q?q=y:(q+=String.fromCharCode(0),q+=y),y=n+b}Z(k);return q},toWireType:function(k,m){"string"!==typeof m&&W("Cannot pass non-string to C++ string type "+c);var p=g(m),q=yb(4+p+b);q>>>=0;M[q>>>2]=p>>h;f(m,q+4,p+b);null!==k&&k.push(Z,q);return q},argPackAdvance:8,readValueFromPointer:Za,Y:function(k){Z(k)}})},
m:function(a,b){b=T(b);X(a,{fa:!0,name:b,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},w:Xa,A:function(a){if(0===a)return Ya(pb());var b=ob[a];a=void 0===b?T(a):b;return Ya(pb()[a])},o:function(a){4<a&&(Y[a].$+=1)},f:function(a,b,c,e){a||W("Cannot use deleted val. handle = "+a);a=Y[a].value;var f=rb[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")))(qb,d,Ya);rb[b]=f}return f(a,c,e)},e:function(){A()},t:function(a,b,c){F.copyWithin(a>>>0,b>>>0,b+c>>>0)},c:function(a){a>>>=0;var b=F.length;if(4294967296<a)return!1;
for(var c=1;4>=c;c*=2){var e=b*(1+.2/c);e=Math.min(e,a+100663296);e=Math.max(16777216,a,e);0<e%65536&&(e+=65536-e%65536);a:{try{E.grow(Math.min(4294967296,e)-J.byteLength+65535>>>16);xa(E.buffer);var f=1;break a}catch(g){}f=void 0}if(f)return!0}return!1},u:function(a,b){var c=0;tb().forEach(function(e,f){var g=b+c;f=I[a+4*f>>2>>>0]=g;for(g=0;g<e.length;++g)L[f++>>0>>>0]=e.charCodeAt(g);L[f>>0>>>0]=0;c+=e.length+1});return 0},v:function(a,b){var c=tb();I[a>>2>>>0]=c.length;var e=0;c.forEach(function(f){e+=
f.length+1});I[b>>2>>>0]=e;return 0},x:function(){return 0},r:function(){},h:function(a,b,c,e){for(var f=0,g=0;g<c;g++){for(var l=I[b+8*g>>2>>>0],h=I[b+(8*g+4)>>2>>>0],k=0;k<h;k++){var m=F[l+k>>>0],p=vb[a];0===m||10===m?((1===a?ia:B)(ma(p,0)),p.length=0):p.push(m)}f+=h}I[e>>2>>>0]=f;return 0},memory:E,g:function(a){a=+a;return 0<=a?+Fa(a+.5):+Ea(a-.5)},i:function(a){a=+a;return 0<=a?+Fa(a+.5):+Ea(a-.5)},s:function(){},table:ja};
(function(){function a(f){d.asm=f.exports;O--;d.monitorRunDependencies&&d.monitorRunDependencies(O);0==O&&(null!==Ga&&(clearInterval(Ga),Ga=null),Q&&(f=Q,Q=null,f()))}function b(f){a(f.instance)}function c(f){return La().then(function(g){return WebAssembly.instantiate(g,e)}).then(f,function(g){B("failed to asynchronously prepare wasm: "+g);A(g)})}var e={a:zb};O++;d.monitorRunDependencies&&d.monitorRunDependencies(O);if(d.instantiateWasm)try{return d.instantiateWasm(e,a)}catch(f){return B("Module.instantiateWasm callback failed with error: "+
f),!1}(function(){if(D||"function"!==typeof WebAssembly.instantiateStreaming||Ia()||Ha("file://")||"function"!==typeof fetch)return c(b);fetch(R,{credentials:"same-origin"}).then(function(f){return WebAssembly.instantiateStreaming(f,e).then(b,function(g){B("wasm streaming compile failed: "+g);B("falling back to ArrayBuffer instantiation");return c(b)})})})();return{}})();
var Ma=d.___wasm_call_ctors=function(){return(Ma=d.___wasm_call_ctors=d.asm.B).apply(null,arguments)},yb=d._malloc=function(){return(yb=d._malloc=d.asm.C).apply(null,arguments)},Z=d._free=function(){return(Z=d._free=d.asm.D).apply(null,arguments)},lb=d.___getTypeName=function(){return(lb=d.___getTypeName=d.asm.E).apply(null,arguments)};d.___embind_register_native_and_builtin_types=function(){return(d.___embind_register_native_and_builtin_types=d.asm.F).apply(null,arguments)};
d.dynCall_iii=function(){return(d.dynCall_iii=d.asm.G).apply(null,arguments)};d.dynCall_vii=function(){return(d.dynCall_vii=d.asm.H).apply(null,arguments)};d.dynCall_vi=function(){return(d.dynCall_vi=d.asm.I).apply(null,arguments)};d.dynCall_ii=function(){return(d.dynCall_ii=d.asm.J).apply(null,arguments)};d.dynCall_iidiiii=function(){return(d.dynCall_iidiiii=d.asm.K).apply(null,arguments)};d.dynCall_iiiiiii=function(){return(d.dynCall_iiiiiii=d.asm.L).apply(null,arguments)};
d.dynCall_viii=function(){return(d.dynCall_viii=d.asm.M).apply(null,arguments)};d.dynCall_viiii=function(){return(d.dynCall_viiii=d.asm.N).apply(null,arguments)};d.dynCall_v=function(){return(d.dynCall_v=d.asm.O).apply(null,arguments)};d.dynCall_viiiiiii=function(){return(d.dynCall_viiiiiii=d.asm.P).apply(null,arguments)};d.dynCall_viiiiii=function(){return(d.dynCall_viiiiii=d.asm.Q).apply(null,arguments)};d.dynCall_iiii=function(){return(d.dynCall_iiii=d.asm.R).apply(null,arguments)};
d.dynCall_iiiii=function(){return(d.dynCall_iiiii=d.asm.S).apply(null,arguments)};d.dynCall_iiji=function(){return(d.dynCall_iiji=d.asm.T).apply(null,arguments)};d.dynCall_iifi=function(){return(d.dynCall_iifi=d.asm.U).apply(null,arguments)};d.dynCall_jiji=function(){return(d.dynCall_jiji=d.asm.V).apply(null,arguments)};d.dynCall_viiiii=function(){return(d.dynCall_viiiii=d.asm.W).apply(null,arguments)};var Ab;Q=function Bb(){Ab||Cb();Ab||(Q=Bb)};
function Cb(){function a(){if(!Ab&&(Ab=!0,d.calledRun=!0,!ka)){N(Aa);N(Ba);aa(d);if(d.onRuntimeInitialized)d.onRuntimeInitialized();if(d.postRun)for("function"==typeof d.postRun&&(d.postRun=[d.postRun]);d.postRun.length;){var b=d.postRun.shift();Ca.unshift(b)}N(Ca)}}if(!(0<O)){if(d.preRun)for("function"==typeof d.preRun&&(d.preRun=[d.preRun]);d.preRun.length;)Da();N(za);0<O||(d.setStatus?(d.setStatus("Running..."),setTimeout(function(){setTimeout(function(){d.setStatus("")},1);a()},1)):a())}}
d.run=Cb;if(d.preInit)for("function"==typeof d.preInit&&(d.preInit=[d.preInit]);0<d.preInit.length;)d.preInit.pop()();noExitRuntime=!0;Cb();
return jxl_dec.ready
}
);
})();
if (typeof exports === 'object' && typeof module === 'object')
module.exports = jxl_dec;
else if (typeof define === 'function' && define['amd'])
define([], function() { return jxl_dec; });
else if (typeof exports === 'object')
exports["jxl_dec"] = jxl_dec;

Binary file not shown.

View File

@@ -1,60 +0,0 @@
#include <emscripten/bind.h>
#include <emscripten/val.h>
#include "lib/jxl/enc_file.h"
#include "lib/jxl/external_image.h"
using namespace emscripten;
thread_local const val Uint8Array = val::global("Uint8Array");
struct JXLOptions {
// 1 = slowest
// 7 = fastest
int speed;
float quality;
};
val encode(std::string image, int width, int height, JXLOptions options) {
jxl::CompressParams cparams;
jxl::PassesEncoderState passes_enc_state;
jxl::CodecInOut io;
jxl::PaddedBytes bytes;
jxl::ImageBundle* main = &io.Main();
cparams.speed_tier = static_cast<jxl::SpeedTier>(options.speed);
cparams.butteraugli_distance = options.quality;
io.metadata.SetAlphaBits(8);
uint8_t* inBuffer = (uint8_t*)image.c_str();
auto result = jxl::ConvertImage(
jxl::Span<const uint8_t>(reinterpret_cast<const uint8_t*>(image.data()), image.size()), width,
height, jxl::ColorEncoding::SRGB(/*is_gray=*/false), /*has_alpha=*/true,
/*alpha_is_premultiplied=*/false, /*bits_per_alpha=*/8, /*bits_per_sample=*/8,
/*big_endian=*/false, /*flipped_y=*/false, /*pool=*/nullptr, main);
if (!result) {
return val::null();
}
auto js_result = val::null();
if (EncodeFile(cparams, &io, &passes_enc_state, &bytes)) {
js_result = Uint8Array.new_(typed_memory_view(bytes.size(), bytes.data()));
}
// TODO: Any freeing that needs to be done?
//
return js_result;
}
void free_result() {}
EMSCRIPTEN_BINDINGS(my_module) {
value_object<JXLOptions>("JXLOptions")
.field("speed", &JXLOptions::speed)
.field("quality", &JXLOptions::quality);
function("encode", &encode);
}

View File

@@ -1,8 +0,0 @@
import { EncodeOptions } from '../../src/codecs/jxl/encoder-meta';
interface JXLModule extends EmscriptenWasm.Module {
encode(data: BufferSource, width: number, height: number, options: EncodeOptions): Uint8Array;
}
export default function(opts: EmscriptenWasm.ModuleOpts): JXLModule;

View File

@@ -1,117 +0,0 @@
var jxl_enc = (function() {
var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename;
return (
function(jxl_enc) {
jxl_enc = jxl_enc || {};
var f;f||(f=typeof jxl_enc !== 'undefined' ? jxl_enc : {});var aa,ba;f.ready=new Promise(function(a,b){aa=a;ba=b});var p={},t;for(t in f)f.hasOwnProperty(t)&&(p[t]=f[t]);var ca="./this.program",da=!1,w=!1,z=!1,ea=!1;da="object"===typeof window;w="function"===typeof importScripts;z="object"===typeof process&&"object"===typeof process.versions&&"string"===typeof process.versions.node;ea=!da&&!z&&!w;var A="",fa,ha,ia,ka;
if(z)A=w?require("path").dirname(A)+"/":__dirname+"/",fa=function(a,b){ia||(ia=require("fs"));ka||(ka=require("path"));a=ka.normalize(a);return ia.readFileSync(a,b?null:"utf8")},ha=function(a){a=fa(a,!0);a.buffer||(a=new Uint8Array(a));assert(a.buffer);return a},1<process.argv.length&&(ca=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),process.on("uncaughtException",function(a){throw a;}),process.on("unhandledRejection",B),f.inspect=function(){return"[Emscripten Module object]"};else if(ea)"undefined"!=
typeof read&&(fa=function(a){return read(a)}),ha=function(a){if("function"===typeof readbuffer)return new Uint8Array(readbuffer(a));a=read(a,"binary");assert("object"===typeof a);return a},"undefined"!==typeof print&&("undefined"===typeof console&&(console={}),console.log=print,console.warn=console.error="undefined"!==typeof printErr?printErr:print);else if(da||w)w?A=self.location.href:document.currentScript&&(A=document.currentScript.src),_scriptDir&&(A=_scriptDir),0!==A.indexOf("blob:")?A=A.substr(0,
A.lastIndexOf("/")+1):A="",fa=function(a){var b=new XMLHttpRequest;b.open("GET",a,!1);b.send(null);return b.responseText},w&&(ha=function(a){var b=new XMLHttpRequest;b.open("GET",a,!1);b.responseType="arraybuffer";b.send(null);return new Uint8Array(b.response)});var la=f.print||console.log.bind(console),C=f.printErr||console.warn.bind(console);for(t in p)p.hasOwnProperty(t)&&(f[t]=p[t]);p=null;f.thisProgram&&(ca=f.thisProgram);var ma;f.wasmBinary&&(ma=f.wasmBinary);var noExitRuntime;
f.noExitRuntime&&(noExitRuntime=f.noExitRuntime);"object"!==typeof WebAssembly&&B("no native wasm support detected");var D,na=new WebAssembly.Table({initial:780,maximum:780,element:"anyfunc"}),oa=!1;function assert(a,b){a||B("Assertion failed: "+b)}var pa="undefined"!==typeof TextDecoder?new TextDecoder("utf8"):void 0;
function qa(a,b,c){b>>>=0;var d=b+c;for(c=b;a[c>>>0]&&!(c>=d);)++c;if(16<c-b&&a.subarray&&pa)return pa.decode(a.subarray(b>>>0,c>>>0));for(d="";b<c;){var e=a[b++>>>0];if(e&128){var g=a[b++>>>0]&63;if(192==(e&224))d+=String.fromCharCode((e&31)<<6|g);else{var k=a[b++>>>0]&63;e=224==(e&240)?(e&15)<<12|g<<6|k:(e&7)<<18|g<<12|k<<6|a[b++>>>0]&63;65536>e?d+=String.fromCharCode(e):(e-=65536,d+=String.fromCharCode(55296|e>>10,56320|e&1023))}}else d+=String.fromCharCode(e)}return d}
function ra(a,b){return(a>>>=0)?qa(E,a,b):""}
function sa(a,b,c,d){c>>>=0;if(!(0<d))return 0;var e=c;d=c+d-1;for(var g=0;g<a.length;++g){var k=a.charCodeAt(g);if(55296<=k&&57343>=k){var m=a.charCodeAt(++g);k=65536+((k&1023)<<10)|m&1023}if(127>=k){if(c>=d)break;b[c++>>>0]=k}else{if(2047>=k){if(c+1>=d)break;b[c++>>>0]=192|k>>6}else{if(65535>=k){if(c+2>=d)break;b[c++>>>0]=224|k>>12}else{if(c+3>=d)break;b[c++>>>0]=240|k>>18;b[c++>>>0]=128|k>>12&63}b[c++>>>0]=128|k>>6&63}b[c++>>>0]=128|k&63}}b[c>>>0]=0;return c-e}
function ta(a){for(var b=0,c=0;c<a.length;++c){var d=a.charCodeAt(c);55296<=d&&57343>=d&&(d=65536+((d&1023)<<10)|a.charCodeAt(++c)&1023);127>=d?++b:b=2047>=d?b+2:65535>=d?b+3:b+4}return b}var ua="undefined"!==typeof TextDecoder?new TextDecoder("utf-16le"):void 0;function va(a,b){var c=a>>1;for(var d=c+b/2;!(c>=d)&&wa[c>>>0];)++c;c<<=1;if(32<c-a&&ua)return ua.decode(E.subarray(a>>>0,c>>>0));c=0;for(d="";;){var e=G[a+2*c>>1>>>0];if(0==e||c==b/2)return d;++c;d+=String.fromCharCode(e)}}
function xa(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 e=0;e<c;++e)G[b>>1>>>0]=a.charCodeAt(e),b+=2;G[b>>1>>>0]=0;return b-d}function ya(a){return 2*a.length}function za(a,b){for(var c=0,d="";!(c>=b/4);){var e=H[a+4*c>>2>>>0];if(0==e)break;++c;65536<=e?(e-=65536,d+=String.fromCharCode(55296|e>>10,56320|e&1023)):d+=String.fromCharCode(e)}return d}
function Aa(a,b,c){b>>>=0;void 0===c&&(c=2147483647);if(4>c)return 0;var d=b;c=d+c-4;for(var e=0;e<a.length;++e){var g=a.charCodeAt(e);if(55296<=g&&57343>=g){var k=a.charCodeAt(++e);g=65536+((g&1023)<<10)|k&1023}H[b>>2>>>0]=g;b+=4;if(b+4>c)break}H[b>>2>>>0]=0;return b-d}function Ba(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 I,J,E,G,wa,H,K,Ca,Da;
function Ea(a){I=a;f.HEAP8=J=new Int8Array(a);f.HEAP16=G=new Int16Array(a);f.HEAP32=H=new Int32Array(a);f.HEAPU8=E=new Uint8Array(a);f.HEAPU16=wa=new Uint16Array(a);f.HEAPU32=K=new Uint32Array(a);f.HEAPF32=Ca=new Float32Array(a);f.HEAPF64=Da=new Float64Array(a)}var Fa=f.INITIAL_MEMORY||16777216;f.wasmMemory?D=f.wasmMemory:D=new WebAssembly.Memory({initial:Fa/65536,maximum:65536});D&&(I=D.buffer);Fa=I.byteLength;Ea(I);H[771900]=8330640;
function Ga(a){for(;0<a.length;){var b=a.shift();if("function"==typeof b)b(f);else{var c=b.eb;"number"===typeof c?void 0===b.Ma?f.dynCall_v(c):f.dynCall_vi(c,b.Ma):c(void 0===b.Ma?null:b.Ma)}}}var Ha=[],Ia=[],Ja=[],Ka=[];function La(){var a=f.preRun.shift();Ha.unshift(a)}var Ma=Math.abs,Na=Math.ceil,Oa=Math.floor,Pa=Math.min,L=0,Qa=null,Ra=null;f.preloadedImages={};f.preloadedAudios={};
function B(a){if(f.onAbort)f.onAbort(a);C(a);oa=!0;a=new WebAssembly.RuntimeError("abort("+a+"). Build with -s ASSERTIONS=1 for more info.");ba(a);throw a;}function Sa(a){var b=M;return String.prototype.startsWith?b.startsWith(a):0===b.indexOf(a)}function Ta(){return Sa("data:application/octet-stream;base64,")}var M="jxl_enc.wasm";if(!Ta()){var Ua=M;M=f.locateFile?f.locateFile(Ua,A):A+Ua}
function Va(){try{if(ma)return new Uint8Array(ma);if(ha)return ha(M);throw"both async and sync fetching of the wasm failed";}catch(a){B(a)}}function Wa(){return ma||!da&&!w||"function"!==typeof fetch||Sa("file://")?new Promise(function(a){a(Va())}):fetch(M,{credentials:"same-origin"}).then(function(a){if(!a.ok)throw"failed to load wasm binary file at '"+M+"'";return a.arrayBuffer()}).catch(function(){return Va()})}var N,Xa;Ia.push({eb:function(){Ya()}});function Za(){return 0<Za.Ia}
function $a(a,b){for(var c=0,d=a.length-1;0<=d;d--){var e=a[d];"."===e?a.splice(d,1):".."===e?(a.splice(d,1),c++):c&&(a.splice(d,1),c--)}if(b)for(;c;c--)a.unshift("..");return a}function ab(a){var b="/"===a.charAt(0),c="/"===a.substr(-1);(a=$a(a.split("/").filter(function(d){return!!d}),!b).join("/"))||b||(a=".");a&&c&&(a+="/");return(b?"/":"")+a}
function bb(a){var b=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(a).slice(1);a=b[0];b=b[1];if(!a&&!b)return".";b&&(b=b.substr(0,b.length-1));return a+b}function cb(a){if("/"===a)return"/";var b=a.lastIndexOf("/");return-1===b?a:a.substr(b+1)}
function db(){for(var a="",b=!1,c=arguments.length-1;-1<=c&&!b;c--){b=0<=c?arguments[c]:"/";if("string"!==typeof b)throw new TypeError("Arguments to path.resolve must be strings");if(!b)return"";a=b+"/"+a;b="/"===b.charAt(0)}a=$a(a.split("/").filter(function(d){return!!d}),!b).join("/");return(b?"/":"")+a||"."}var eb=[];function fb(a,b){eb[a]={input:[],output:[],Ba:b};gb(a,hb)}
var hb={open:function(a){var b=eb[a.node.rdev];if(!b)throw new O(43);a.tty=b;a.seekable=!1},close:function(a){a.tty.Ba.flush(a.tty)},flush:function(a){a.tty.Ba.flush(a.tty)},read:function(a,b,c,d){if(!a.tty||!a.tty.Ba.Xa)throw new O(60);for(var e=0,g=0;g<d;g++){try{var k=a.tty.Ba.Xa(a.tty)}catch(m){throw new O(29);}if(void 0===k&&0===e)throw new O(6);if(null===k||void 0===k)break;e++;b[c+g]=k}e&&(a.node.timestamp=Date.now());return e},write:function(a,b,c,d){if(!a.tty||!a.tty.Ba.Oa)throw new O(60);
try{for(var e=0;e<d;e++)a.tty.Ba.Oa(a.tty,b[c+e])}catch(g){throw new O(29);}d&&(a.node.timestamp=Date.now());return e}},jb={Xa:function(a){if(!a.input.length){var b=null;if(z){var c=Buffer.Ia?Buffer.Ia(256):new Buffer(256),d=0;try{d=ia.readSync(process.stdin.fd,c,0,256,null)}catch(e){if(-1!=e.toString().indexOf("EOF"))d=0;else throw e;}0<d?b=c.slice(0,d).toString("utf-8"):b=null}else"undefined"!=typeof window&&"function"==typeof window.prompt?(b=window.prompt("Input: "),null!==b&&(b+="\n")):"function"==
typeof readline&&(b=readline(),null!==b&&(b+="\n"));if(!b)return null;a.input=ib(b,!0)}return a.input.shift()},Oa:function(a,b){null===b||10===b?(la(qa(a.output,0)),a.output=[]):0!=b&&a.output.push(b)},flush:function(a){a.output&&0<a.output.length&&(la(qa(a.output,0)),a.output=[])}},kb={Oa:function(a,b){null===b||10===b?(C(qa(a.output,0)),a.output=[]):0!=b&&a.output.push(b)},flush:function(a){a.output&&0<a.output.length&&(C(qa(a.output,0)),a.output=[])}},P={ta:null,ya:function(){return P.createNode(null,
"/",16895,0)},createNode:function(a,b,c,d){if(24576===(c&61440)||4096===(c&61440))throw new O(63);P.ta||(P.ta={dir:{node:{za:P.pa.za,va:P.pa.va,lookup:P.pa.lookup,Fa:P.pa.Fa,rename:P.pa.rename,unlink:P.pa.unlink,rmdir:P.pa.rmdir,readdir:P.pa.readdir,symlink:P.pa.symlink},stream:{Aa:P.qa.Aa}},file:{node:{za:P.pa.za,va:P.pa.va},stream:{Aa:P.qa.Aa,read:P.qa.read,write:P.qa.write,Ra:P.qa.Ra,Ya:P.qa.Ya,Ha:P.qa.Ha}},link:{node:{za:P.pa.za,va:P.pa.va,readlink:P.pa.readlink},stream:{}},Sa:{node:{za:P.pa.za,
va:P.pa.va},stream:lb}});c=mb(a,b,c,d);16384===(c.mode&61440)?(c.pa=P.ta.dir.node,c.qa=P.ta.dir.stream,c.oa={}):32768===(c.mode&61440)?(c.pa=P.ta.file.node,c.qa=P.ta.file.stream,c.ra=0,c.oa=null):40960===(c.mode&61440)?(c.pa=P.ta.link.node,c.qa=P.ta.link.stream):8192===(c.mode&61440)&&(c.pa=P.ta.Sa.node,c.qa=P.ta.Sa.stream);c.timestamp=Date.now();a&&(a.oa[b]=c);return c},xb:function(a){if(a.oa&&a.oa.subarray){for(var b=[],c=0;c<a.ra;++c)b.push(a.oa[c]);return b}return a.oa},yb:function(a){return a.oa?
a.oa.subarray?a.oa.subarray(0,a.ra):new Uint8Array(a.oa):new Uint8Array(0)},Ta:function(a,b){b>>>=0;var c=a.oa?a.oa.length:0;c>=b||(b=Math.max(b,c*(1048576>c?2:1.125)>>>0),0!=c&&(b=Math.max(b,256)),c=a.oa,a.oa=new Uint8Array(b),0<a.ra&&a.oa.set(c.subarray(0,a.ra),0))},nb:function(a,b){b>>>=0;if(a.ra!=b)if(0==b)a.oa=null,a.ra=0;else{if(!a.oa||a.oa.subarray){var c=a.oa;a.oa=new Uint8Array(b);c&&a.oa.set(c.subarray(0,Math.min(b,a.ra)))}else if(a.oa||(a.oa=[]),a.oa.length>b)a.oa.length=b;else for(;a.oa.length<
b;)a.oa.push(0);a.ra=b}},pa:{za:function(a){var b={};b.dev=8192===(a.mode&61440)?a.id:1;b.ino=a.id;b.mode=a.mode;b.nlink=1;b.uid=0;b.gid=0;b.rdev=a.rdev;16384===(a.mode&61440)?b.size=4096:32768===(a.mode&61440)?b.size=a.ra:40960===(a.mode&61440)?b.size=a.link.length:b.size=0;b.atime=new Date(a.timestamp);b.mtime=new Date(a.timestamp);b.ctime=new Date(a.timestamp);b.bb=4096;b.blocks=Math.ceil(b.size/b.bb);return b},va:function(a,b){void 0!==b.mode&&(a.mode=b.mode);void 0!==b.timestamp&&(a.timestamp=
b.timestamp);void 0!==b.size&&P.nb(a,b.size)},lookup:function(){throw nb[44];},Fa:function(a,b,c,d){return P.createNode(a,b,c,d)},rename:function(a,b,c){if(16384===(a.mode&61440)){try{var d=ob(b,c)}catch(g){}if(d)for(var e in d.oa)throw new O(55);}delete a.parent.oa[a.name];a.name=c;b.oa[c]=a;a.parent=b},unlink:function(a,b){delete a.oa[b]},rmdir:function(a,b){var c=ob(a,b),d;for(d in c.oa)throw new O(55);delete a.oa[b]},readdir:function(a){var b=[".",".."],c;for(c in a.oa)a.oa.hasOwnProperty(c)&&
b.push(c);return b},symlink:function(a,b,c){a=P.createNode(a,b,41471,0);a.link=c;return a},readlink:function(a){if(40960!==(a.mode&61440))throw new O(28);return a.link}},qa:{read:function(a,b,c,d,e){var g=a.node.oa;if(e>=a.node.ra)return 0;a=Math.min(a.node.ra-e,d);if(8<a&&g.subarray)b.set(g.subarray(e,e+a),c);else for(d=0;d<a;d++)b[c+d]=g[e+d];return a},write:function(a,b,c,d,e,g){b.buffer===J.buffer&&(g=!1);if(!d)return 0;a=a.node;a.timestamp=Date.now();if(b.subarray&&(!a.oa||a.oa.subarray)){if(g)return a.oa=
b.subarray(c,c+d),a.ra=d;if(0===a.ra&&0===e)return a.oa=b.slice(c,c+d),a.ra=d;if(e+d<=a.ra)return a.oa.set(b.subarray(c,c+d),e),d}P.Ta(a,e+d);if(a.oa.subarray&&b.subarray)a.oa.set(b.subarray(c,c+d),e);else for(g=0;g<d;g++)a.oa[e+g]=b[c+g];a.ra=Math.max(a.ra,e+d);return d},Aa:function(a,b,c){1===c?b+=a.position:2===c&&32768===(a.node.mode&61440)&&(b+=a.node.ra);if(0>b)throw new O(28);return b},Ra:function(a,b,c){P.Ta(a.node,b+c);a.node.ra=Math.max(a.node.ra,b+c)},Ya:function(a,b,c,d,e,g){assert(0===
b);if(32768!==(a.node.mode&61440))throw new O(43);a=a.node.oa;if(g&2||a.buffer!==I){if(0<d||d+c<a.length)a.subarray?a=a.subarray(d,d+c):a=Array.prototype.slice.call(a,d,d+c);d=!0;g=16384*Math.ceil(c/16384);for(b=pb(g);c<g;)J[b+c++>>>0]=0;c=b;if(!c)throw new O(48);c>>>=0;J.set(a,c>>>0)}else d=!1,c=a.byteOffset;return{Fb:c,$a:d}},Ha:function(a,b,c,d,e){if(32768!==(a.node.mode&61440))throw new O(43);if(e&2)return 0;P.qa.write(a,b,0,d,c,!1);return 0}}},qb=null,rb={},Q=[],sb=1,tb=null,ub=!0,vb={},O=null,
nb={};function R(a,b){a=db("/",a);b=b||{};if(!a)return{path:"",node:null};var c={Wa:!0,Pa:0},d;for(d in c)void 0===b[d]&&(b[d]=c[d]);if(8<b.Pa)throw new O(32);a=$a(a.split("/").filter(function(k){return!!k}),!1);var e=qb;c="/";for(d=0;d<a.length;d++){var g=d===a.length-1;if(g&&b.parent)break;e=ob(e,a[d]);c=ab(c+"/"+a[d]);e.Ga&&(!g||g&&b.Wa)&&(e=e.Ga.root);if(!g||b.Va)for(g=0;40960===(e.mode&61440);)if(e=wb(c),c=db(bb(c),e),e=R(c,{Pa:b.Pa}).node,40<g++)throw new O(32);}return{path:c,node:e}}
function xb(a){for(var b;;){if(a===a.parent)return a=a.ya.Za,b?"/"!==a[a.length-1]?a+"/"+b:a+b:a;b=b?a.name+"/"+b:a.name;a=a.parent}}function yb(a,b){for(var c=0,d=0;d<b.length;d++)c=(c<<5)-c+b.charCodeAt(d)|0;return(a+c>>>0)%tb.length}function ob(a,b){var c;if(c=(c=zb(a,"x"))?c:a.pa.lookup?0:2)throw new O(c,a);for(c=tb[yb(a.id,b)];c;c=c.kb){var d=c.name;if(c.parent.id===a.id&&d===b)return c}return a.pa.lookup(a,b)}
function mb(a,b,c,d){a=new Ab(a,b,c,d);b=yb(a.parent.id,a.name);a.kb=tb[b];return tb[b]=a}var Bb={r:0,rs:1052672,"r+":2,w:577,wx:705,xw:705,"w+":578,"wx+":706,"xw+":706,a:1089,ax:1217,xa:1217,"a+":1090,"ax+":1218,"xa+":1218};function Cb(a){var b=["r","w","rw"][a&3];a&512&&(b+="w");return b}function zb(a,b){if(ub)return 0;if(-1===b.indexOf("r")||a.mode&292){if(-1!==b.indexOf("w")&&!(a.mode&146)||-1!==b.indexOf("x")&&!(a.mode&73))return 2}else return 2;return 0}
function Db(a,b){try{return ob(a,b),20}catch(c){}return zb(a,"wx")}function Eb(){var a=4096;for(var b=0;b<=a;b++)if(!Q[b])return b;throw new O(33);}function Fb(a){Gb||(Gb=function(){},Gb.prototype={});var b=new Gb,c;for(c in a)b[c]=a[c];a=b;b=Eb();a.fd=b;return Q[b]=a}var lb={open:function(a){a.qa=rb[a.node.rdev].qa;a.qa.open&&a.qa.open(a)},Aa:function(){throw new O(70);}};function gb(a,b){rb[a]={qa:b}}
function Hb(a,b){var c="/"===b,d=!b;if(c&&qb)throw new O(10);if(!c&&!d){var e=R(b,{Wa:!1});b=e.path;e=e.node;if(e.Ga)throw new O(10);if(16384!==(e.mode&61440))throw new O(54);}b={type:a,Db:{},Za:b,jb:[]};a=a.ya(b);a.ya=b;b.root=a;c?qb=a:e&&(e.Ga=b,e.ya&&e.ya.jb.push(b))}function Ib(a,b,c){var d=R(a,{parent:!0}).node;a=cb(a);if(!a||"."===a||".."===a)throw new O(28);var e=Db(d,a);if(e)throw new O(e);if(!d.pa.Fa)throw new O(63);return d.pa.Fa(d,a,b,c)}function S(a){Ib(a,16895,0)}
function Jb(a,b,c){"undefined"===typeof c&&(c=b,b=438);Ib(a,b|8192,c)}function Kb(a,b){if(!db(a))throw new O(44);var c=R(b,{parent:!0}).node;if(!c)throw new O(44);b=cb(b);var d=Db(c,b);if(d)throw new O(d);if(!c.pa.symlink)throw new O(63);c.pa.symlink(c,b,a)}function wb(a){a=R(a).node;if(!a)throw new O(44);if(!a.pa.readlink)throw new O(28);return db(xb(a.parent),a.pa.readlink(a))}
function Lb(a,b){if(""===a)throw new O(44);if("string"===typeof b){var c=Bb[b];if("undefined"===typeof c)throw Error("Unknown file open mode: "+b);b=c}var d=b&64?("undefined"===typeof d?438:d)&4095|32768:0;if("object"===typeof a)var e=a;else{a=ab(a);try{e=R(a,{Va:!(b&131072)}).node}catch(k){}}c=!1;if(b&64)if(e){if(b&128)throw new O(20);}else e=Ib(a,d,0),c=!0;if(!e)throw new O(44);8192===(e.mode&61440)&&(b&=-513);if(b&65536&&16384!==(e.mode&61440))throw new O(54);if(!c&&(d=e?40960===(e.mode&61440)?
32:16384===(e.mode&61440)&&("r"!==Cb(b)||b&512)?31:zb(e,Cb(b)):44))throw new O(d);if(b&512){d=e;var g;"string"===typeof d?g=R(d,{Va:!0}).node:g=d;if(!g.pa.va)throw new O(63);if(16384===(g.mode&61440))throw new O(31);if(32768!==(g.mode&61440))throw new O(28);if(d=zb(g,"w"))throw new O(d);g.pa.va(g,{size:0,timestamp:Date.now()})}b&=-131713;e=Fb({node:e,path:xb(e),flags:b,seekable:!0,position:0,qa:e.qa,wb:[],error:!1});e.qa.open&&e.qa.open(e);!f.logReadFiles||b&1||(Mb||(Mb={}),a in Mb||(Mb[a]=1,C("FS.trackingDelegate error on read file: "+
a)));try{vb.onOpenFile&&(e=0,1!==(b&2097155)&&(e|=1),0!==(b&2097155)&&(e|=2),vb.onOpenFile(a,e))}catch(k){C("FS.trackingDelegate['onOpenFile']('"+a+"', flags) threw an exception: "+k.message)}}function Nb(a,b,c){if(null===a.fd)throw new O(8);if(!a.seekable||!a.qa.Aa)throw new O(70);if(0!=c&&1!=c&&2!=c)throw new O(28);a.position=a.qa.Aa(a,b,c);a.wb=[]}
function Ob(){O||(O=function(a,b){this.node=b;this.ob=function(c){this.Ea=c};this.ob(a);this.message="FS error"},O.prototype=Error(),O.prototype.constructor=O,[44].forEach(function(a){nb[a]=new O(a);nb[a].stack="<generic error, no stack>"}))}var Pb;function Qb(a,b){var c=0;a&&(c|=365);b&&(c|=146);return c}
function Rb(a,b,c){a=ab("/dev/"+a);var d=Qb(!!b,!!c);Sb||(Sb=64);var e=Sb++<<8|0;gb(e,{open:function(g){g.seekable=!1},close:function(){c&&c.buffer&&c.buffer.length&&c(10)},read:function(g,k,m,l){for(var q=0,r=0;r<l;r++){try{var u=b()}catch(x){throw new O(29);}if(void 0===u&&0===q)throw new O(6);if(null===u||void 0===u)break;q++;k[m+r]=u}q&&(g.node.timestamp=Date.now());return q},write:function(g,k,m,l){for(var q=0;q<l;q++)try{c(k[m+q])}catch(r){throw new O(29);}l&&(g.node.timestamp=Date.now());return q}});
Jb(a,d,e)}var Sb,Tb={},Gb,Mb,Ub={};function Vb(a){a=Q[a];if(!a)throw new O(8);return a}var Wb={};function Xb(a){for(;a.length;){var b=a.pop();a.pop()(b)}}function Yb(a){return this.fromWireType(K[a>>>2])}var T={},U={},Zb={};function $b(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 ac(a,b){a=$b(a);return(new Function("body","return function "+a+'() {\n "use strict"; return body.apply(this, arguments);\n};\n'))(b)}function bc(a){var b=Error,c=ac(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 cc=void 0;function dc(a,b,c){function d(m){m=c(m);if(m.length!==a.length)throw new cc("Mismatched type converter count");for(var l=0;l<a.length;++l)V(a[l],m[l])}a.forEach(function(m){Zb[m]=b});var e=Array(b.length),g=[],k=0;b.forEach(function(m,l){U.hasOwnProperty(m)?e[l]=U[m]:(g.push(m),T.hasOwnProperty(m)||(T[m]=[]),T[m].push(function(){e[l]=U[m];++k;k===g.length&&d(e)}))});0===g.length&&d(e)}
function ec(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 fc=void 0;function W(a){for(var b="";E[a>>>0];)b+=fc[E[a++>>>0]];return b}var hc=void 0;function X(a){throw new hc(a);}
function V(a,b,c){c=c||{};if(!("argPackAdvance"in b))throw new TypeError("registerType registeredInstance requires argPackAdvance");var d=b.name;a||X('type "'+d+'" must have a positive integer typeid pointer');if(U.hasOwnProperty(a)){if(c.ib)return;X("Cannot register type '"+d+"' twice")}U[a]=b;delete Zb[a];T.hasOwnProperty(a)&&(b=T[a],delete T[a],b.forEach(function(e){e()}))}var ic=[],Y=[{},{value:void 0},{value:null},{value:!0},{value:!1}];
function jc(a){4<a&&0===--Y[a].Qa&&(Y[a]=void 0,ic.push(a))}function kc(a){switch(a){case void 0:return 1;case null:return 2;case !0:return 3;case !1:return 4;default:var b=ic.length?ic.pop():Y.length;Y[b]={Qa:1,value:a};return b}}function lc(a){if(null===a)return"null";var b=typeof a;return"object"===b||"array"===b||"function"===b?a.toString():""+a}
function mc(a,b){switch(b){case 2:return function(c){return this.fromWireType(Ca[c>>>2])};case 3:return function(c){return this.fromWireType(Da[c>>>3])};default:throw new TypeError("Unknown float type: "+a);}}function nc(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=ac(b.name||"unknownFunctionName",function(){});c.prototype=b.prototype;c=new c;a=b.apply(c,a);return a instanceof Object?a:c}
function oc(a,b){var c=f;if(void 0===c[a].ua){var d=c[a];c[a]=function(){c[a].ua.hasOwnProperty(arguments.length)||X("Function '"+b+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+c[a].ua+")!");return c[a].ua[arguments.length].apply(this,arguments)};c[a].ua=[];c[a].ua[d.ab]=d}}
function pc(a,b,c){f.hasOwnProperty(a)?((void 0===c||void 0!==f[a].ua&&void 0!==f[a].ua[c])&&X("Cannot register public name '"+a+"' twice"),oc(a,a),f.hasOwnProperty(c)&&X("Cannot register multiple overloads of a function with the same number of arguments ("+c+")!"),f[a].ua[c]=b):(f[a]=b,void 0!==c&&(f[a].Cb=c))}function qc(a,b){for(var c=[],d=0;d<a;d++)c.push(H[(b>>2)+d>>>0]);return c}
function rc(a,b){a=W(a);var c=f["dynCall_"+a];for(var d=[],e=1;e<a.length;++e)d.push("a"+e);e="return function dynCall_"+(a+"_"+b)+"("+d.join(", ")+") {\n";e+=" return dynCall(rawFunction"+(d.length?", ":"")+d.join(", ")+");\n";c=(new Function("dynCall","rawFunction",e+"};\n"))(c,b);"function"!==typeof c&&X("unknown function pointer with signature "+a+": "+b);return c}var sc=void 0;function tc(a){a=uc(a);var b=W(a);Z(a);return b}
function vc(a,b){function c(g){e[g]||U[g]||(Zb[g]?Zb[g].forEach(c):(d.push(g),e[g]=!0))}var d=[],e={};b.forEach(c);throw new sc(a+": "+d.map(tc).join([", "]));}function wc(a,b,c){switch(b){case 0:return c?function(d){return J[d>>>0]}:function(d){return E[d>>>0]};case 1:return c?function(d){return G[d>>>1]}:function(d){return wa[d>>>1]};case 2:return c?function(d){return H[d>>>2]}:function(d){return K[d>>>2]};default:throw new TypeError("Unknown integer type: "+a);}}var xc={};
function yc(){return"object"===typeof globalThis?globalThis:Function("return this")()}function zc(a,b){var c=U[a];void 0===c&&X(b+" has unknown type "+tc(a));return c}var Ac={},Bc={};function Cc(){if(!Dc){var a={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"===typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:ca||"./this.program"},b;for(b in Bc)a[b]=Bc[b];var c=[];for(b in a)c.push(b+"="+a[b]);Dc=c}return Dc}var Dc;
function Ec(a){return 0===a%4&&(0!==a%100||0===a%400)}function Fc(a,b){for(var c=0,d=0;d<=b;c+=a[d++]);return c}var Gc=[31,29,31,30,31,30,31,31,30,31,30,31],Hc=[31,28,31,30,31,30,31,31,30,31,30,31];function Ic(a,b){for(a=new Date(a.getTime());0<b;){var c=a.getMonth(),d=(Ec(a.getFullYear())?Gc:Hc)[c];if(b>d-a.getDate())b-=d-a.getDate()+1,a.setDate(1),11>c?a.setMonth(c+1):(a.setMonth(0),a.setFullYear(a.getFullYear()+1));else{a.setDate(a.getDate()+b);break}}return a}
function Jc(a,b,c,d){function e(h,n,v){for(h="number"===typeof h?h.toString():h||"";h.length<n;)h=v[0]+h;return h}function g(h,n){return e(h,n,"0")}function k(h,n){function v(F){return 0>F?-1:0<F?1:0}var y;0===(y=v(h.getFullYear()-n.getFullYear()))&&0===(y=v(h.getMonth()-n.getMonth()))&&(y=v(h.getDate()-n.getDate()));return y}function m(h){switch(h.getDay()){case 0:return new Date(h.getFullYear()-1,11,29);case 1:return h;case 2:return new Date(h.getFullYear(),0,3);case 3:return new Date(h.getFullYear(),
0,2);case 4:return new Date(h.getFullYear(),0,1);case 5:return new Date(h.getFullYear()-1,11,31);case 6:return new Date(h.getFullYear()-1,11,30)}}function l(h){h=Ic(new Date(h.sa+1900,0,1),h.La);var n=new Date(h.getFullYear()+1,0,4),v=m(new Date(h.getFullYear(),0,4));n=m(n);return 0>=k(v,h)?0>=k(n,h)?h.getFullYear()+1:h.getFullYear():h.getFullYear()-1}var q=H[d+40>>2>>>0];d={ub:H[d>>2>>>0],tb:H[d+4>>2>>>0],Ja:H[d+8>>2>>>0],Da:H[d+12>>2>>>0],Ca:H[d+16>>2>>>0],sa:H[d+20>>2>>>0],Ka:H[d+24>>2>>>0],La:H[d+
28>>2>>>0],Gb:H[d+32>>2>>>0],sb:H[d+36>>2>>>0],vb:q?ra(q):""};c=ra(c);q={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var r in q)c=c.replace(new RegExp(r,"g"),q[r]);var u=
"Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),x="January February March April May June July August September October November December".split(" ");q={"%a":function(h){return u[h.Ka].substring(0,3)},"%A":function(h){return u[h.Ka]},"%b":function(h){return x[h.Ca].substring(0,3)},"%B":function(h){return x[h.Ca]},"%C":function(h){return g((h.sa+1900)/100|0,2)},"%d":function(h){return g(h.Da,2)},"%e":function(h){return e(h.Da,2," ")},"%g":function(h){return l(h).toString().substring(2)},
"%G":function(h){return l(h)},"%H":function(h){return g(h.Ja,2)},"%I":function(h){h=h.Ja;0==h?h=12:12<h&&(h-=12);return g(h,2)},"%j":function(h){return g(h.Da+Fc(Ec(h.sa+1900)?Gc:Hc,h.Ca-1),3)},"%m":function(h){return g(h.Ca+1,2)},"%M":function(h){return g(h.tb,2)},"%n":function(){return"\n"},"%p":function(h){return 0<=h.Ja&&12>h.Ja?"AM":"PM"},"%S":function(h){return g(h.ub,2)},"%t":function(){return"\t"},"%u":function(h){return h.Ka||7},"%U":function(h){var n=new Date(h.sa+1900,0,1),v=0===n.getDay()?
n:Ic(n,7-n.getDay());h=new Date(h.sa+1900,h.Ca,h.Da);return 0>k(v,h)?g(Math.ceil((31-v.getDate()+(Fc(Ec(h.getFullYear())?Gc:Hc,h.getMonth()-1)-31)+h.getDate())/7),2):0===k(v,n)?"01":"00"},"%V":function(h){var n=new Date(h.sa+1901,0,4),v=m(new Date(h.sa+1900,0,4));n=m(n);var y=Ic(new Date(h.sa+1900,0,1),h.La);return 0>k(y,v)?"53":0>=k(n,y)?"01":g(Math.ceil((v.getFullYear()<h.sa+1900?h.La+32-v.getDate():h.La+1-v.getDate())/7),2)},"%w":function(h){return h.Ka},"%W":function(h){var n=new Date(h.sa,0,
1),v=1===n.getDay()?n:Ic(n,0===n.getDay()?1:7-n.getDay()+1);h=new Date(h.sa+1900,h.Ca,h.Da);return 0>k(v,h)?g(Math.ceil((31-v.getDate()+(Fc(Ec(h.getFullYear())?Gc:Hc,h.getMonth()-1)-31)+h.getDate())/7),2):0===k(v,n)?"01":"00"},"%y":function(h){return(h.sa+1900).toString().substring(2)},"%Y":function(h){return h.sa+1900},"%z":function(h){h=h.sb;var n=0<=h;h=Math.abs(h)/60;return(n?"+":"-")+String("0000"+(h/60*100+h%60)).slice(-4)},"%Z":function(h){return h.vb},"%%":function(){return"%"}};for(r in q)0<=
c.indexOf(r)&&(c=c.replace(new RegExp(r,"g"),q[r](d)));r=ib(c,!1);if(r.length>b)return 0;J.set(r,a>>>0);return r.length-1}function Ab(a,b,c,d){a||(a=this);this.parent=a;this.ya=a.ya;this.Ga=null;this.id=sb++;this.name=b;this.mode=c;this.pa={};this.qa={};this.rdev=d}
Object.defineProperties(Ab.prototype,{read:{get:function(){return 365===(this.mode&365)},set:function(a){a?this.mode|=365:this.mode&=-366}},write:{get:function(){return 146===(this.mode&146)},set:function(a){a?this.mode|=146:this.mode&=-147}}});Ob();tb=Array(4096);Hb(P,"/");S("/tmp");S("/home");S("/home/web_user");
(function(){S("/dev");gb(259,{read:function(){return 0},write:function(d,e,g,k){return k}});Jb("/dev/null",259);fb(1280,jb);fb(1536,kb);Jb("/dev/tty",1280);Jb("/dev/tty1",1536);if("object"===typeof crypto&&"function"===typeof crypto.getRandomValues){var a=new Uint8Array(1);var b=function(){crypto.getRandomValues(a);return a[0]}}else if(z)try{var c=require("crypto");b=function(){return c.randomBytes(1)[0]}}catch(d){}b||(b=function(){B("random_device")});Rb("random",b);Rb("urandom",b);S("/dev/shm");
S("/dev/shm/tmp")})();S("/proc");S("/proc/self");S("/proc/self/fd");Hb({ya:function(){var a=mb("/proc/self","fd",16895,73);a.pa={lookup:function(b,c){var d=Q[+c];if(!d)throw new O(8);b={parent:null,ya:{Za:"fake"},pa:{readlink:function(){return d.path}}};return b.parent=b}};return a}},"/proc/self/fd");cc=f.InternalError=bc("InternalError");for(var Kc=Array(256),Lc=0;256>Lc;++Lc)Kc[Lc]=String.fromCharCode(Lc);fc=Kc;hc=f.BindingError=bc("BindingError");
f.count_emval_handles=function(){for(var a=0,b=5;b<Y.length;++b)void 0!==Y[b]&&++a;return a};f.get_first_emval=function(){for(var a=5;a<Y.length;++a)if(void 0!==Y[a])return Y[a];return null};sc=f.UnboundTypeError=bc("UnboundTypeError");function ib(a,b){var c=Array(ta(a)+1);a=sa(a,c,0,c.length);b&&(c.length=a);return c}
var Nc={t:function(a){return pb(a)},G:function(){},q:function(a){"uncaught_exception"in Za?Za.Ia++:Za.Ia=1;throw a;},x:function(){H[Mc()>>2>>>0]=63;return-1},w:function(a,b){try{a>>>=0;if(-1===(a|0)||0===b)var c=-28;else{var d=Ub[a];if(d&&b===d.Ab){var e=Q[d.fd];if(d.Eb&2){var g=d.flags,k=d.offset,m=E.slice(a,a+b);e&&e.qa.Ha&&e.qa.Ha(e,m,k>>>0,b,g)}Ub[a]=null;d.$a&&Z(d.Bb)}c=0}return c}catch(l){return"undefined"!==typeof Tb&&l instanceof O||B(l),-l.Ea}},n:function(a){var b=Wb[a];delete Wb[a];var c=
b.lb,d=b.mb,e=b.Ua,g=e.map(function(k){return k.hb}).concat(e.map(function(k){return k.qb}));dc([a],g,function(k){var m={};e.forEach(function(l,q){var r=k[q],u=l.fb,x=l.gb,h=k[q+e.length],n=l.pb,v=l.rb;m[l.cb]={read:function(y){return r.fromWireType(u(x,y))},write:function(y,F){var ja=[];n(v,y,h.toWireType(ja,F));Xb(ja)}}});return[{name:b.name,fromWireType:function(l){var q={},r;for(r in m)q[r]=m[r].read(l);d(l);return q},toWireType:function(l,q){for(var r in m)if(!(r in q))throw new TypeError('Missing field: "'+
r+'"');var u=c();for(r in m)m[r].write(u,q[r]);null!==l&&l.push(d,u);return u},argPackAdvance:8,readValueFromPointer:Yb,wa:d}]})},C:function(a,b,c,d,e){var g=ec(c);b=W(b);V(a,{name:b,fromWireType:function(k){return!!k},toWireType:function(k,m){return m?d:e},argPackAdvance:8,readValueFromPointer:function(k){if(1===c)var m=J;else if(2===c)m=G;else if(4===c)m=H;else throw new TypeError("Unknown boolean type size: "+b);return this.fromWireType(m[k>>>g])},wa:null})},B:function(a,b){b=W(b);V(a,{name:b,
fromWireType:function(c){var d=Y[c].value;jc(c);return d},toWireType:function(c,d){return kc(d)},argPackAdvance:8,readValueFromPointer:Yb,wa:null})},j:function(a,b,c){c=ec(c);b=W(b);V(a,{name:b,fromWireType:function(d){return d},toWireType:function(d,e){if("number"!==typeof e&&"boolean"!==typeof e)throw new TypeError('Cannot convert "'+lc(e)+'" to '+this.name);return e},argPackAdvance:8,readValueFromPointer:mc(b,c),wa:null})},m:function(a,b,c,d,e,g){var k=qc(b,c);a=W(a);e=rc(d,e);pc(a,function(){vc("Cannot call "+
a+" due to unbound types",k)},b-1);dc([],k,function(m){var l=[m[0],null].concat(m.slice(1)),q=m=a,r=e,u=l.length;2>u&&X("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var x=null!==l[1]&&!1,h=!1,n=1;n<l.length;++n)if(null!==l[n]&&void 0===l[n].wa){h=!0;break}var v="void"!==l[0].name,y="",F="";for(n=0;n<u-2;++n)y+=(0!==n?", ":"")+"arg"+n,F+=(0!==n?", ":"")+"arg"+n+"Wired";q="return function "+$b(q)+"("+y+") {\nif (arguments.length !== "+(u-2)+") {\nthrowBindingError('function "+
q+" called with ' + arguments.length + ' arguments, expected "+(u-2)+" args!');\n}\n";h&&(q+="var destructors = [];\n");var ja=h?"destructors":"null";y="throwBindingError invoker fn runDestructors retType classParam".split(" ");r=[X,r,g,Xb,l[0],l[1]];x&&(q+="var thisWired = classParam.toWireType("+ja+", this);\n");for(n=0;n<u-2;++n)q+="var arg"+n+"Wired = argType"+n+".toWireType("+ja+", arg"+n+"); // "+l[n+2].name+"\n",y.push("argType"+n),r.push(l[n+2]);x&&(F="thisWired"+(0<F.length?", ":"")+F);q+=
(v?"var rv = ":"")+"invoker(fn"+(0<F.length?", ":"")+F+");\n";if(h)q+="runDestructors(destructors);\n";else for(n=x?1:2;n<l.length;++n)u=1===n?"thisWired":"arg"+(n-2)+"Wired",null!==l[n].wa&&(q+=u+"_dtor("+u+"); // "+l[n].name+"\n",y.push(u+"_dtor"),r.push(l[n].wa));v&&(q+="var ret = retType.fromWireType(rv);\nreturn ret;\n");y.push(q+"}\n");l=nc(y).apply(null,r);n=b-1;if(!f.hasOwnProperty(m))throw new cc("Replacing nonexistant public symbol");void 0!==f[m].ua&&void 0!==n?f[m].ua[n]=l:(f[m]=l,f[m].ab=
n);return[]})},b:function(a,b,c,d,e){function g(q){return q}b=W(b);-1===e&&(e=4294967295);var k=ec(c);if(0===d){var m=32-8*c;g=function(q){return q<<m>>>m}}var l=-1!=b.indexOf("unsigned");V(a,{name:b,fromWireType:g,toWireType:function(q,r){if("number"!==typeof r&&"boolean"!==typeof r)throw new TypeError('Cannot convert "'+lc(r)+'" to '+this.name);if(r<d||r>e)throw new TypeError('Passing a number "'+lc(r)+'" from JS side to C/C++ side to an argument of type "'+b+'", which is outside the valid range ['+
d+", "+e+"]!");return l?r>>>0:r|0},argPackAdvance:8,readValueFromPointer:wc(b,k,0!==d),wa:null})},a:function(a,b,c){function d(g){g>>=2;var k=K;return new e(I,k[g+1>>>0],k[g>>>0])}var e=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][b];c=W(c);V(a,{name:c,fromWireType:d,argPackAdvance:8,readValueFromPointer:d},{ib:!0})},k:function(a,b){b=W(b);var c="std::string"===b;V(a,{name:b,fromWireType:function(d){var e=K[d>>>2];if(c)for(var g=d+4,k=0;k<=e;++k){var m=
d+4+k;if(k==e||0==E[m>>>0]){g=ra(g,m-g);if(void 0===l)var l=g;else l+=String.fromCharCode(0),l+=g;g=m+1}}else{l=Array(e);for(k=0;k<e;++k)l[k]=String.fromCharCode(E[d+4+k>>>0]);l=l.join("")}Z(d);return l},toWireType:function(d,e){e instanceof ArrayBuffer&&(e=new Uint8Array(e));var g="string"===typeof e;g||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Int8Array||X("Cannot pass non-string to std::string");var k=(c&&g?function(){return ta(e)}:function(){return e.length})(),m=pb(4+
k+1);m>>>=0;K[m>>>2]=k;if(c&&g)sa(e,E,m+4,k+1);else if(g)for(g=0;g<k;++g){var l=e.charCodeAt(g);255<l&&(Z(m),X("String has UTF-16 code units that do not fit in 8 bits"));E[m+4+g>>>0]=l}else for(g=0;g<k;++g)E[m+4+g>>>0]=e[g];null!==d&&d.push(Z,m);return m},argPackAdvance:8,readValueFromPointer:Yb,wa:function(d){Z(d)}})},f:function(a,b,c){c=W(c);if(2===b){var d=va;var e=xa;var g=ya;var k=function(){return wa};var m=1}else 4===b&&(d=za,e=Aa,g=Ba,k=function(){return K},m=2);V(a,{name:c,fromWireType:function(l){for(var q=
K[l>>>2],r=k(),u,x=l+4,h=0;h<=q;++h){var n=l+4+h*b;if(h==q||0==r[n>>>m])x=d(x,n-x),void 0===u?u=x:(u+=String.fromCharCode(0),u+=x),x=n+b}Z(l);return u},toWireType:function(l,q){"string"!==typeof q&&X("Cannot pass non-string to C++ string type "+c);var r=g(q),u=pb(4+r+b);u>>>=0;K[u>>>2]=r>>m;e(q,u+4,r+b);null!==l&&l.push(Z,u);return u},argPackAdvance:8,readValueFromPointer:Yb,wa:function(l){Z(l)}})},o:function(a,b,c,d,e,g){Wb[a]={name:W(b),lb:rc(c,d),mb:rc(e,g),Ua:[]}},g:function(a,b,c,d,e,g,k,m,l,
q){Wb[a].Ua.push({cb:W(b),hb:c,fb:rc(d,e),gb:g,qb:k,pb:rc(m,l),rb:q})},D:function(a,b){b=W(b);V(a,{zb:!0,name:b,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},i:jc,F:function(a){if(0===a)return kc(yc());var b=xc[a];a=void 0===b?W(a):b;return kc(yc()[a])},E:function(a){4<a&&(Y[a].Qa+=1)},p:function(a,b,c,d){a||X("Cannot use deleted val. handle = "+a);a=Y[a].value;var e=Ac[b];if(!e){e="";for(var g=0;g<b;++g)e+=(0!==g?", ":"")+"arg"+g;var k="return function emval_allocator_"+b+
"(constructor, argTypes, args) {\n";for(g=0;g<b;++g)k+="var argType"+g+" = requireRegisteredType(Module['HEAP32'][(argTypes >>> 2) + "+g+'], "parameter '+g+'");\nvar arg'+g+" = argType"+g+".readValueFromPointer(args);\nargs += argType"+g+"['argPackAdvance'];\n";e=(new Function("requireRegisteredType","Module","__emval_register",k+("var obj = new constructor("+e+");\nreturn __emval_register(obj);\n}\n")))(zc,f,kc);Ac[b]=e}return e(a,c,d)},l:function(){B()},u:function(a,b,c){E.copyWithin(a>>>0,b>>>
0,b+c>>>0)},d:function(a){a>>>=0;var b=E.length;if(4294967296<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(16777216,a,d);0<d%65536&&(d+=65536-d%65536);a:{try{D.grow(Math.min(4294967296,d)-I.byteLength+65535>>>16);Ea(D.buffer);var e=1;break a}catch(g){}e=void 0}if(e)return!0}return!1},y:function(a,b){var c=0;Cc().forEach(function(d,e){var g=b+c;e=H[a+4*e>>2>>>0]=g;for(g=0;g<d.length;++g)J[e++>>0>>>0]=d.charCodeAt(g);J[e>>0>>>0]=0;c+=d.length+1});return 0},
z:function(a,b){var c=Cc();H[a>>2>>>0]=c.length;var d=0;c.forEach(function(e){d+=e.length+1});H[b>>2>>>0]=d;return 0},A:function(a){try{var b=Vb(a);if(null===b.fd)throw new O(8);b.Na&&(b.Na=null);try{b.qa.close&&b.qa.close(b)}catch(c){throw c;}finally{Q[b.fd]=null}b.fd=null;return 0}catch(c){return"undefined"!==typeof Tb&&c instanceof O||B(c),c.Ea}},r:function(a,b,c,d,e){try{var g=Vb(a);a=4294967296*c+(b>>>0);if(-9007199254740992>=a||9007199254740992<=a)return-61;Nb(g,a,d);Xa=[g.position>>>0,(N=g.position,
1<=+Ma(N)?0<N?(Pa(+Oa(N/4294967296),4294967295)|0)>>>0:~~+Na((N-+(~~N>>>0))/4294967296)>>>0:0)];H[e>>2>>>0]=Xa[0];H[e+4>>2>>>0]=Xa[1];g.Na&&0===a&&0===d&&(g.Na=null);return 0}catch(k){return"undefined"!==typeof Tb&&k instanceof O||B(k),k.Ea}},h:function(a,b,c,d){try{a:{for(var e=Vb(a),g=a=0;g<c;g++){var k=e,m=H[b+8*g>>2>>>0],l=H[b+(8*g+4)>>2>>>0],q=void 0,r=J;m>>>=0;if(0>l||0>q)throw new O(28);if(null===k.fd)throw new O(8);if(0===(k.flags&2097155))throw new O(8);if(16384===(k.node.mode&61440))throw new O(31);
if(!k.qa.write)throw new O(28);k.seekable&&k.flags&1024&&Nb(k,0,2);var u="undefined"!==typeof q;if(!u)q=k.position;else if(!k.seekable)throw new O(70);var x=k.qa.write(k,r,m,l,q,void 0);u||(k.position+=x);try{if(k.path&&vb.onWriteToFile)vb.onWriteToFile(k.path)}catch(v){C("FS.trackingDelegate['onWriteToFile']('"+k.path+"') threw an exception: "+v.message)}var h=x;if(0>h){var n=-1;break a}a+=h}n=a}H[d>>2>>>0]=n;return 0}catch(v){return"undefined"!==typeof Tb&&v instanceof O||B(v),v.Ea}},memory:D,e:function(a){a=
+a;return 0<=a?+Oa(a+.5):+Na(a-.5)},c:function(a){a=+a;return 0<=a?+Oa(a+.5):+Na(a-.5)},s:function(){},v:function(a,b,c,d){return Jc(a,b,c,d)},table:na};
(function(){function a(e){f.asm=e.exports;L--;f.monitorRunDependencies&&f.monitorRunDependencies(L);0==L&&(null!==Qa&&(clearInterval(Qa),Qa=null),Ra&&(e=Ra,Ra=null,e()))}function b(e){a(e.instance)}function c(e){return Wa().then(function(g){return WebAssembly.instantiate(g,d)}).then(e,function(g){C("failed to asynchronously prepare wasm: "+g);B(g)})}var d={a:Nc};L++;f.monitorRunDependencies&&f.monitorRunDependencies(L);if(f.instantiateWasm)try{return f.instantiateWasm(d,a)}catch(e){return C("Module.instantiateWasm callback failed with error: "+
e),!1}(function(){if(ma||"function"!==typeof WebAssembly.instantiateStreaming||Ta()||Sa("file://")||"function"!==typeof fetch)return c(b);fetch(M,{credentials:"same-origin"}).then(function(e){return WebAssembly.instantiateStreaming(e,d).then(b,function(g){C("wasm streaming compile failed: "+g);C("falling back to ArrayBuffer instantiation");return c(b)})})})();return{}})();
var Ya=f.___wasm_call_ctors=function(){return(Ya=f.___wasm_call_ctors=f.asm.H).apply(null,arguments)},pb=f._malloc=function(){return(pb=f._malloc=f.asm.I).apply(null,arguments)},Z=f._free=function(){return(Z=f._free=f.asm.J).apply(null,arguments)},Mc=f.___errno_location=function(){return(Mc=f.___errno_location=f.asm.K).apply(null,arguments)},uc=f.___getTypeName=function(){return(uc=f.___getTypeName=f.asm.L).apply(null,arguments)};
f.___embind_register_native_and_builtin_types=function(){return(f.___embind_register_native_and_builtin_types=f.asm.M).apply(null,arguments)};f.dynCall_i=function(){return(f.dynCall_i=f.asm.N).apply(null,arguments)};f.dynCall_vi=function(){return(f.dynCall_vi=f.asm.O).apply(null,arguments)};f.dynCall_iii=function(){return(f.dynCall_iii=f.asm.P).apply(null,arguments)};f.dynCall_viii=function(){return(f.dynCall_viii=f.asm.Q).apply(null,arguments)};
f.dynCall_fii=function(){return(f.dynCall_fii=f.asm.R).apply(null,arguments)};f.dynCall_viif=function(){return(f.dynCall_viif=f.asm.S).apply(null,arguments)};f.dynCall_iiiiii=function(){return(f.dynCall_iiiiii=f.asm.T).apply(null,arguments)};f.dynCall_viiiii=function(){return(f.dynCall_viiiii=f.asm.U).apply(null,arguments)};f.dynCall_ii=function(){return(f.dynCall_ii=f.asm.V).apply(null,arguments)};f.dynCall_iidiiii=function(){return(f.dynCall_iidiiii=f.asm.W).apply(null,arguments)};
f.dynCall_vii=function(){return(f.dynCall_vii=f.asm.X).apply(null,arguments)};f.dynCall_iiiiiii=function(){return(f.dynCall_iiiiiii=f.asm.Y).apply(null,arguments)};f.dynCall_viiii=function(){return(f.dynCall_viiii=f.asm.Z).apply(null,arguments)};f.dynCall_iiii=function(){return(f.dynCall_iiii=f.asm._).apply(null,arguments)};f.dynCall_v=function(){return(f.dynCall_v=f.asm.$).apply(null,arguments)};f.dynCall_viiiiiii=function(){return(f.dynCall_viiiiiii=f.asm.aa).apply(null,arguments)};
f.dynCall_viijii=function(){return(f.dynCall_viijii=f.asm.ba).apply(null,arguments)};f.dynCall_iiiii=function(){return(f.dynCall_iiiii=f.asm.ca).apply(null,arguments)};f.dynCall_fi=function(){return(f.dynCall_fi=f.asm.da).apply(null,arguments)};f.dynCall_viiiiii=function(){return(f.dynCall_viiiiii=f.asm.ea).apply(null,arguments)};f.dynCall_iiji=function(){return(f.dynCall_iiji=f.asm.fa).apply(null,arguments)};f.dynCall_iifi=function(){return(f.dynCall_iifi=f.asm.ga).apply(null,arguments)};
f.dynCall_jiji=function(){return(f.dynCall_jiji=f.asm.ha).apply(null,arguments)};f.dynCall_iiiiiiiii=function(){return(f.dynCall_iiiiiiiii=f.asm.ia).apply(null,arguments)};f.dynCall_iiiiiiii=function(){return(f.dynCall_iiiiiiii=f.asm.ja).apply(null,arguments)};f.dynCall_iiiiiijj=function(){return(f.dynCall_iiiiiijj=f.asm.ka).apply(null,arguments)};f.dynCall_iiiiij=function(){return(f.dynCall_iiiiij=f.asm.la).apply(null,arguments)};
f.dynCall_iiiiid=function(){return(f.dynCall_iiiiid=f.asm.ma).apply(null,arguments)};f.dynCall_iiiiijj=function(){return(f.dynCall_iiiiijj=f.asm.na).apply(null,arguments)};var Oc;Ra=function Pc(){Oc||Qc();Oc||(Ra=Pc)};
function Qc(){function a(){if(!Oc&&(Oc=!0,f.calledRun=!0,!oa)){f.noFSInit||Pb||(Pb=!0,Ob(),f.stdin=f.stdin,f.stdout=f.stdout,f.stderr=f.stderr,f.stdin?Rb("stdin",f.stdin):Kb("/dev/tty","/dev/stdin"),f.stdout?Rb("stdout",null,f.stdout):Kb("/dev/tty","/dev/stdout"),f.stderr?Rb("stderr",null,f.stderr):Kb("/dev/tty1","/dev/stderr"),Lb("/dev/stdin","r"),Lb("/dev/stdout","w"),Lb("/dev/stderr","w"));Ga(Ia);ub=!1;Ga(Ja);aa(f);if(f.onRuntimeInitialized)f.onRuntimeInitialized();if(f.postRun)for("function"==
typeof f.postRun&&(f.postRun=[f.postRun]);f.postRun.length;){var b=f.postRun.shift();Ka.unshift(b)}Ga(Ka)}}if(!(0<L)){if(f.preRun)for("function"==typeof f.preRun&&(f.preRun=[f.preRun]);f.preRun.length;)La();Ga(Ha);0<L||(f.setStatus?(f.setStatus("Running..."),setTimeout(function(){setTimeout(function(){f.setStatus("")},1);a()},1)):a())}}f.run=Qc;if(f.preInit)for("function"==typeof f.preInit&&(f.preInit=[f.preInit]);0<f.preInit.length;)f.preInit.pop()();noExitRuntime=!0;Qc();
return jxl_enc.ready
}
);
})();
if (typeof exports === 'object' && typeof module === 'object')
module.exports = jxl_enc;
else if (typeof define === 'function' && define['amd'])
define([], function() { return jxl_enc; });
else if (typeof exports === 'object')
exports["jxl_enc"] = jxl_enc;

Binary file not shown.

View File

@@ -1,6 +0,0 @@
{
"name": "jxl",
"scripts": {
"build": "../build-cpp.sh"
}
}

View File

@@ -1,52 +0,0 @@
CODEC_URL := https://github.com/mozilla/mozjpeg/archive/v3.3.1.tar.gz
CODEC_DIR := node_modules/mozjpeg
CODEC_OUT_RELATIVE := .libs/libjpeg.a rdswitch.o
CODEC_OUT := $(addprefix $(CODEC_DIR)/, $(CODEC_OUT_RELATIVE))
OUT_JS := enc/mozjpeg_enc.js dec/mozjpeg_dec.js
OUT_WASM := $(OUT_JS:.js=.wasm)
.PHONY: all clean
all: $(OUT_JS)
%.js: %.cpp $(CODEC_OUT)
$(CXX) \
-I $(CODEC_DIR) \
${CXXFLAGS} \
${LDFLAGS} \
--bind \
--closure 1 \
-s ALLOW_MEMORY_GROWTH=1 \
-s MODULARIZE=1 \
-s 'EXPORT_NAME="$(basename $(@F))"' \
-o $@ \
$+
# This one is a bit special: there is no rule for .libs/libjpeg.a
# so we use libjpeg.la which implicitly builds that one instead.
$(CODEC_DIR)/.libs/libjpeg.a: $(CODEC_DIR)/Makefile
$(MAKE) -C $(CODEC_DIR) libjpeg.la
$(CODEC_DIR)/rdswitch.o: $(CODEC_DIR)/Makefile
$(MAKE) -C $(CODEC_DIR) rdswitch.o
$(CODEC_DIR)/Makefile: $(CODEC_DIR)/configure
cd $(CODEC_DIR) && ./configure \
--disable-shared \
--without-turbojpeg \
--without-simd \
--without-arith-enc \
--without-arith-dec
$(CODEC_DIR)/configure: $(CODEC_DIR)/configure.ac
cd $(CODEC_DIR) && autoreconf -iv
$(CODEC_DIR)/configure.ac: $(CODEC_DIR)
$(CODEC_DIR):
mkdir -p $@
curl -sL $(CODEC_URL) | tar xz --strip 1 -C $@
clean:
$(RM) $(OUT_JS) $(OUT_WASM)
$(MAKE) -C $(CODEC_DIR) clean

View File

@@ -1,18 +0,0 @@
<!DOCTYPE html>
<script src="mozjpeg_dec.js"></script>
<script>
const module = mozjpeg_dec({
async onRuntimeInitialized() {
const image = await fetch("./original.jpg").then(r => r.arrayBuffer());
const result = this.decode(image);
const canvas = document.createElement("canvas");
canvas.width = result.width;
canvas.height = result.height;
// Draw image onto canvas
const ctx = canvas.getContext("2d");
ctx.putImageData(result, 0, 0);
document.body.append(canvas);
}
});
</script>

View File

@@ -1,59 +0,0 @@
#include <emscripten/bind.h>
#include <emscripten/val.h>
#include "config.h"
#include "jpeglib.h"
extern "C" {
#include "cdjpeg.h"
}
using namespace emscripten;
thread_local const val Uint8ClampedArray = val::global("Uint8ClampedArray");
thread_local const val ImageData = val::global("ImageData");
val decode(std::string image_in) {
uint8_t* image_buffer = (uint8_t*)image_in.c_str();
jpeg_decompress_struct cinfo;
jpeg_error_mgr jerr;
// Initialize the JPEG decompression object with default error handling.
cinfo.err = jpeg_std_error(&jerr);
jpeg_create_decompress(&cinfo);
jpeg_mem_src(&cinfo, image_buffer, image_in.length());
// Read file header, set default decompression parameters
jpeg_read_header(&cinfo, TRUE);
// Force RGBA decoding, even for grayscale images
cinfo.out_color_space = JCS_EXT_RGBA;
jpeg_start_decompress(&cinfo);
// Prepare output buffer
size_t output_size = cinfo.output_width * cinfo.output_height * 4;
std::vector<uint8_t> output_buffer(output_size);
auto stride = cinfo.output_width * 4;
// Process data
auto buffer_lines_available = cinfo.output_height;
while (cinfo.output_scanline < cinfo.output_height) {
uint8_t* ptr = &output_buffer[stride * cinfo.output_scanline];
auto lines_read = jpeg_read_scanlines(&cinfo, &ptr, buffer_lines_available);
buffer_lines_available -= lines_read;
}
jpeg_finish_decompress(&cinfo);
// Step 7: release JPEG compression object
auto data = Uint8ClampedArray.new_(typed_memory_view(output_buffer.size(), output_buffer.data()));
auto js_result = ImageData.new_(data, cinfo.output_width, cinfo.output_height);
// This is an important step since it will release a good deal of memory.
jpeg_destroy_decompress(&cinfo);
// And we're done!
return js_result;
}
EMSCRIPTEN_BINDINGS(my_module) {
function("decode", &decode);
}

View File

@@ -1,69 +0,0 @@
var mozjpeg_dec = (function() {
var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename;
return (
function(mozjpeg_dec) {
mozjpeg_dec = mozjpeg_dec || {};
var d;d||(d=typeof mozjpeg_dec !== 'undefined' ? mozjpeg_dec : {});var aa,ba;d.ready=new Promise(function(a,b){aa=a;ba=b});var r={},t;for(t in d)d.hasOwnProperty(t)&&(r[t]=d[t]);var ca="./this.program";function u(a,b){throw b;}var v=!1,w=!1,da=!1,ea=!1;v="object"===typeof window;w="function"===typeof importScripts;da="object"===typeof process&&"object"===typeof process.versions&&"string"===typeof process.versions.node;ea=!v&&!da&&!w;var x="",z,A,fa,ha;
if(da)x=w?require("path").dirname(x)+"/":__dirname+"/",z=function(a,b){fa||(fa=require("fs"));ha||(ha=require("path"));a=ha.normalize(a);return fa.readFileSync(a,b?null:"utf8")},A=function(a){a=z(a,!0);a.buffer||(a=new Uint8Array(a));a.buffer||B("Assertion failed: undefined");return a},1<process.argv.length&&(ca=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),process.on("uncaughtException",function(a){if(!(a instanceof ia))throw a;}),process.on("unhandledRejection",B),u=function(a){process.exit(a)},
d.inspect=function(){return"[Emscripten Module object]"};else if(ea)"undefined"!=typeof read&&(z=function(a){return read(a)}),A=function(a){if("function"===typeof readbuffer)return new Uint8Array(readbuffer(a));a=read(a,"binary");"object"===typeof a||B("Assertion failed: undefined");return a},"function"===typeof quit&&(u=function(a){quit(a)}),"undefined"!==typeof print&&("undefined"===typeof console&&(console={}),console.log=print,console.warn=console.error="undefined"!==typeof printErr?printErr:
print);else if(v||w)w?x=self.location.href:document.currentScript&&(x=document.currentScript.src),_scriptDir&&(x=_scriptDir),0!==x.indexOf("blob:")?x=x.substr(0,x.lastIndexOf("/")+1):x="",z=function(a){var b=new XMLHttpRequest;b.open("GET",a,!1);b.send(null);return b.responseText},w&&(A=function(a){var b=new XMLHttpRequest;b.open("GET",a,!1);b.responseType="arraybuffer";b.send(null);return new Uint8Array(b.response)});var ja=d.print||console.log.bind(console),D=d.printErr||console.warn.bind(console);
for(t in r)r.hasOwnProperty(t)&&(d[t]=r[t]);r=null;d.thisProgram&&(ca=d.thisProgram);d.quit&&(u=d.quit);var E;d.wasmBinary&&(E=d.wasmBinary);var noExitRuntime;d.noExitRuntime&&(noExitRuntime=d.noExitRuntime);"object"!==typeof WebAssembly&&B("no native wasm support detected");var F,ka=new WebAssembly.Table({initial:156,maximum:156,element:"anyfunc"}),la=!1,ma="undefined"!==typeof TextDecoder?new TextDecoder("utf8"):void 0;
function na(a,b,c){var e=b+c;for(c=b;a[c]&&!(c>=e);)++c;if(16<c-b&&a.subarray&&ma)return ma.decode(a.subarray(b,c));for(e="";b<c;){var f=a[b++];if(f&128){var g=a[b++]&63;if(192==(f&224))e+=String.fromCharCode((f&31)<<6|g);else{var l=a[b++]&63;f=224==(f&240)?(f&15)<<12|g<<6|l:(f&7)<<18|g<<12|l<<6|a[b++]&63;65536>f?e+=String.fromCharCode(f):(f-=65536,e+=String.fromCharCode(55296|f>>10,56320|f&1023))}}else e+=String.fromCharCode(f)}return e}
function oa(a,b,c){var e=G;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;e[b++]=g}else{if(2047>=g){if(b+1>=c)break;e[b++]=192|g>>6}else{if(65535>=g){if(b+2>=c)break;e[b++]=224|g>>12}else{if(b+3>=c)break;e[b++]=240|g>>18;e[b++]=128|g>>12&63}e[b++]=128|g>>6&63}e[b++]=128|g&63}}e[b]=0}}var pa="undefined"!==typeof TextDecoder?new TextDecoder("utf-16le"):void 0;
function qa(a,b){var c=a>>1;for(var e=c+b/2;!(c>=e)&&H[c];)++c;c<<=1;if(32<c-a&&pa)return pa.decode(G.subarray(a,c));c=0;for(e="";;){var f=I[a+2*c>>1];if(0==f||c==b/2)return e;++c;e+=String.fromCharCode(f)}}function ra(a,b,c){void 0===c&&(c=2147483647);if(2>c)return 0;c-=2;var e=b;c=c<2*a.length?c/2:a.length;for(var f=0;f<c;++f)I[b>>1]=a.charCodeAt(f),b+=2;I[b>>1]=0;return b-e}function sa(a){return 2*a.length}
function ta(a,b){for(var c=0,e="";!(c>=b/4);){var f=J[a+4*c>>2];if(0==f)break;++c;65536<=f?(f-=65536,e+=String.fromCharCode(55296|f>>10,56320|f&1023)):e+=String.fromCharCode(f)}return e}function ua(a,b,c){void 0===c&&(c=2147483647);if(4>c)return 0;var e=b;c=e+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-e}
function va(a){for(var b=0,c=0;c<a.length;++c){var e=a.charCodeAt(c);55296<=e&&57343>=e&&++c;b+=4}return b}var L,M,G,I,H,J,N,wa,xa;function ya(a){L=a;d.HEAP8=M=new Int8Array(a);d.HEAP16=I=new Int16Array(a);d.HEAP32=J=new Int32Array(a);d.HEAPU8=G=new Uint8Array(a);d.HEAPU16=H=new Uint16Array(a);d.HEAPU32=N=new Uint32Array(a);d.HEAPF32=wa=new Float32Array(a);d.HEAPF64=xa=new Float64Array(a)}var za=d.INITIAL_MEMORY||16777216;d.wasmMemory?F=d.wasmMemory:F=new WebAssembly.Memory({initial:za/65536,maximum:32768});
F&&(L=F.buffer);za=L.byteLength;ya(L);J[3104]=5255456;function O(a){for(;0<a.length;){var b=a.shift();if("function"==typeof b)b(d);else{var c=b.Y;"number"===typeof c?void 0===b.U?d.dynCall_v(c):d.dynCall_vi(c,b.U):c(void 0===b.U?null:b.U)}}}var Aa=[],Ba=[],Ca=[],Da=[];function Ea(){var a=d.preRun.shift();Aa.unshift(a)}var Q=0,Fa=null,R=null;d.preloadedImages={};d.preloadedAudios={};
function B(a){if(d.onAbort)d.onAbort(a);D(a);la=!0;a=new WebAssembly.RuntimeError("abort("+a+"). Build with -s ASSERTIONS=1 for more info.");ba(a);throw a;}function Ga(a){var b=S;return String.prototype.startsWith?b.startsWith(a):0===b.indexOf(a)}function Ha(){return Ga("data:application/octet-stream;base64,")}var S="mozjpeg_dec.wasm";if(!Ha()){var Ia=S;S=d.locateFile?d.locateFile(Ia,x):x+Ia}
function Ja(){try{if(E)return new Uint8Array(E);if(A)return A(S);throw"both async and sync fetching of the wasm failed";}catch(a){B(a)}}function Ka(){return E||!v&&!w||"function"!==typeof fetch||Ga("file://")?new Promise(function(a){a(Ja())}):fetch(S,{credentials:"same-origin"}).then(function(a){if(!a.ok)throw"failed to load wasm binary file at '"+S+"'";return a.arrayBuffer()}).catch(function(){return Ja()})}Ba.push({Y:function(){La()}});function Ma(){return 0<Ma.W}
function Na(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 Oa=void 0;function T(a){for(var b="";G[a];)b+=Oa[G[a++]];return b}var U={},V={},Pa={};function Qa(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 Ra(a,b){a=Qa(a);return(new Function("body","return function "+a+'() {\n "use strict"; return body.apply(this, arguments);\n};\n'))(b)}function Sa(a){var b=Error,c=Ra(a,function(e){this.name=a;this.message=e;e=Error(e).stack;void 0!==e&&(this.stack=this.toString()+"\n"+e.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 Ta=void 0;function W(a){throw new Ta(a);}var Ua=void 0;function Va(a,b){function c(k){k=b(k);if(k.length!==e.length)throw new Ua("Mismatched type converter count");for(var h=0;h<e.length;++h)X(e[h],k[h])}var e=[];e.forEach(function(k){Pa[k]=a});var f=Array(a.length),g=[],l=0;a.forEach(function(k,h){V.hasOwnProperty(k)?f[h]=V[k]:(g.push(k),U.hasOwnProperty(k)||(U[k]=[]),U[k].push(function(){f[h]=V[k];++l;l===g.length&&c(f)}))});0===g.length&&c(f)}
function X(a,b,c){c=c||{};if(!("argPackAdvance"in b))throw new TypeError("registerType registeredInstance requires argPackAdvance");var e=b.name;a||W('type "'+e+'" must have a positive integer typeid pointer');if(V.hasOwnProperty(a)){if(c.Z)return;W("Cannot register type '"+e+"' twice")}V[a]=b;delete Pa[a];U.hasOwnProperty(a)&&(b=U[a],delete U[a],b.forEach(function(f){f()}))}var Wa=[],Y=[{},{value:void 0},{value:null},{value:!0},{value:!1}];
function Xa(a){4<a&&0===--Y[a].V&&(Y[a]=void 0,Wa.push(a))}function Ya(a){switch(a){case void 0:return 1;case null:return 2;case !0:return 3;case !1:return 4;default:var b=Wa.length?Wa.pop():Y.length;Y[b]={V:1,value:a};return b}}function Za(a){return this.fromWireType(N[a>>2])}function $a(a){if(null===a)return"null";var b=typeof a;return"object"===b||"array"===b||"function"===b?a.toString():""+a}
function cb(a,b){switch(b){case 2:return function(c){return this.fromWireType(wa[c>>2])};case 3:return function(c){return this.fromWireType(xa[c>>3])};default:throw new TypeError("Unknown float type: "+a);}}function db(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=Ra(b.name||"unknownFunctionName",function(){});c.prototype=b.prototype;c=new c;a=b.apply(c,a);return a instanceof Object?a:c}
function eb(a){for(;a.length;){var b=a.pop();a.pop()(b)}}function fb(a,b){var c=d;if(void 0===c[a].S){var e=c[a];c[a]=function(){c[a].S.hasOwnProperty(arguments.length)||W("Function '"+b+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+c[a].S+")!");return c[a].S[arguments.length].apply(this,arguments)};c[a].S=[];c[a].S[e.X]=e}}
function gb(a,b,c){d.hasOwnProperty(a)?((void 0===c||void 0!==d[a].S&&void 0!==d[a].S[c])&&W("Cannot register public name '"+a+"' twice"),fb(a,a),d.hasOwnProperty(c)&&W("Cannot register multiple overloads of a function with the same number of arguments ("+c+")!"),d[a].S[c]=b):(d[a]=b,void 0!==c&&(d[a].aa=c))}function hb(a,b){for(var c=[],e=0;e<a;e++)c.push(J[(b>>2)+e]);return c}
function ib(a,b){a=T(a);var c=d["dynCall_"+a];for(var e=[],f=1;f<a.length;++f)e.push("a"+f);f="return function dynCall_"+(a+"_"+b)+"("+e.join(", ")+") {\n";f+=" return dynCall(rawFunction"+(e.length?", ":"")+e.join(", ")+");\n";c=(new Function("dynCall","rawFunction",f+"};\n"))(c,b);"function"!==typeof c&&W("unknown function pointer with signature "+a+": "+b);return c}var jb=void 0;function kb(a){a=lb(a);var b=T(a);Z(a);return b}
function mb(a,b){function c(g){f[g]||V[g]||(Pa[g]?Pa[g].forEach(c):(e.push(g),f[g]=!0))}var e=[],f={};b.forEach(c);throw new jb(a+": "+e.map(kb).join([", "]));}function nb(a,b,c){switch(b){case 0:return c?function(e){return M[e]}:function(e){return G[e]};case 1:return c?function(e){return I[e>>1]}:function(e){return H[e>>1]};case 2:return c?function(e){return J[e>>2]}:function(e){return N[e>>2]};default:throw new TypeError("Unknown integer type: "+a);}}var ob={};
function pb(){return"object"===typeof globalThis?globalThis:Function("return this")()}function qb(a,b){var c=V[a];void 0===c&&W(b+" has unknown type "+kb(a));return c}var rb={},sb={};function tb(){if(!ub){var a={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"===typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:ca||"./this.program"},b;for(b in sb)a[b]=sb[b];var c=[];for(b in a)c.push(b+"="+a[b]);ub=c}return ub}
for(var ub,vb=[null,[],[]],wb=Array(256),xb=0;256>xb;++xb)wb[xb]=String.fromCharCode(xb);Oa=wb;Ta=d.BindingError=Sa("BindingError");Ua=d.InternalError=Sa("InternalError");d.count_emval_handles=function(){for(var a=0,b=5;b<Y.length;++b)void 0!==Y[b]&&++a;return a};d.get_first_emval=function(){for(var a=5;a<Y.length;++a)if(void 0!==Y[a])return Y[a];return null};jb=d.UnboundTypeError=Sa("UnboundTypeError");
var zb={o:function(a){return yb(a)},i:function(){},n:function(a){"uncaught_exception"in Ma?Ma.W++:Ma.W=1;throw a;},y:function(a,b,c,e,f){var g=Na(c);b=T(b);X(a,{name:b,fromWireType:function(l){return!!l},toWireType:function(l,k){return k?e:f},argPackAdvance:8,readValueFromPointer:function(l){if(1===c)var k=M;else if(2===c)k=I;else if(4===c)k=J;else throw new TypeError("Unknown boolean type size: "+b);return this.fromWireType(k[l>>g])},T:null})},x:function(a,b){b=T(b);X(a,{name:b,fromWireType:function(c){var e=
Y[c].value;Xa(c);return e},toWireType:function(c,e){return Ya(e)},argPackAdvance:8,readValueFromPointer:Za,T:null})},g:function(a,b,c){c=Na(c);b=T(b);X(a,{name:b,fromWireType:function(e){return e},toWireType:function(e,f){if("number"!==typeof f&&"boolean"!==typeof f)throw new TypeError('Cannot convert "'+$a(f)+'" to '+this.name);return f},argPackAdvance:8,readValueFromPointer:cb(b,c),T:null})},l:function(a,b,c,e,f,g){var l=hb(b,c);a=T(a);f=ib(e,f);gb(a,function(){mb("Cannot call "+a+" due to unbound types",
l)},b-1);Va(l,function(k){var h=[k[0],null].concat(k.slice(1)),n=k=a,p=f,q=h.length;2>q&&W("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var y=null!==h[1]&&!1,C=!1,m=1;m<h.length;++m)if(null!==h[m]&&void 0===h[m].T){C=!0;break}var ab="void"!==h[0].name,K="",P="";for(m=0;m<q-2;++m)K+=(0!==m?", ":"")+"arg"+m,P+=(0!==m?", ":"")+"arg"+m+"Wired";n="return function "+Qa(n)+"("+K+") {\nif (arguments.length !== "+(q-2)+") {\nthrowBindingError('function "+n+" called with ' + arguments.length + ' arguments, expected "+
(q-2)+" args!');\n}\n";C&&(n+="var destructors = [];\n");var bb=C?"destructors":"null";K="throwBindingError invoker fn runDestructors retType classParam".split(" ");p=[W,p,g,eb,h[0],h[1]];y&&(n+="var thisWired = classParam.toWireType("+bb+", this);\n");for(m=0;m<q-2;++m)n+="var arg"+m+"Wired = argType"+m+".toWireType("+bb+", arg"+m+"); // "+h[m+2].name+"\n",K.push("argType"+m),p.push(h[m+2]);y&&(P="thisWired"+(0<P.length?", ":"")+P);n+=(ab?"var rv = ":"")+"invoker(fn"+(0<P.length?", ":"")+P+");\n";
if(C)n+="runDestructors(destructors);\n";else for(m=y?1:2;m<h.length;++m)q=1===m?"thisWired":"arg"+(m-2)+"Wired",null!==h[m].T&&(n+=q+"_dtor("+q+"); // "+h[m].name+"\n",K.push(q+"_dtor"),p.push(h[m].T));ab&&(n+="var ret = retType.fromWireType(rv);\nreturn ret;\n");K.push(n+"}\n");h=db(K).apply(null,p);m=b-1;if(!d.hasOwnProperty(k))throw new Ua("Replacing nonexistant public symbol");void 0!==d[k].S&&void 0!==m?d[k].S[m]=h:(d[k]=h,d[k].X=m);return[]})},b:function(a,b,c,e,f){function g(n){return n}b=
T(b);-1===f&&(f=4294967295);var l=Na(c);if(0===e){var k=32-8*c;g=function(n){return n<<k>>>k}}var h=-1!=b.indexOf("unsigned");X(a,{name:b,fromWireType:g,toWireType:function(n,p){if("number"!==typeof p&&"boolean"!==typeof p)throw new TypeError('Cannot convert "'+$a(p)+'" to '+this.name);if(p<e||p>f)throw new TypeError('Passing a number "'+$a(p)+'" from JS side to C/C++ side to an argument of type "'+b+'", which is outside the valid range ['+e+", "+f+"]!");return h?p>>>0:p|0},argPackAdvance:8,readValueFromPointer:nb(b,
l,0!==e),T:null})},a:function(a,b,c){function e(g){g>>=2;var l=N;return new f(L,l[g+1],l[g])}var f=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][b];c=T(c);X(a,{name:c,fromWireType:e,argPackAdvance:8,readValueFromPointer:e},{Z:!0})},h:function(a,b){b=T(b);var c="std::string"===b;X(a,{name:b,fromWireType:function(e){var f=N[e>>2];if(c)for(var g=e+4,l=0;l<=f;++l){var k=e+4+l;if(l==f||0==G[k]){g=g?na(G,g,k-g):"";if(void 0===h)var h=g;else h+=String.fromCharCode(0),
h+=g;g=k+1}}else{h=Array(f);for(l=0;l<f;++l)h[l]=String.fromCharCode(G[e+4+l]);h=h.join("")}Z(e);return h},toWireType:function(e,f){f instanceof ArrayBuffer&&(f=new Uint8Array(f));var g="string"===typeof f;g||f instanceof Uint8Array||f instanceof Uint8ClampedArray||f instanceof Int8Array||W("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})(),k=yb(4+l+1);N[k>>2]=l;if(c&&g)oa(f,k+4,l+1);else if(g)for(g=0;g<l;++g){var h=f.charCodeAt(g);255<h&&(Z(k),W("String has UTF-16 code units that do not fit in 8 bits"));G[k+4+g]=h}else for(g=0;g<l;++g)G[k+4+g]=f[g];null!==e&&e.push(Z,k);return k},argPackAdvance:8,readValueFromPointer:Za,T:function(e){Z(e)}})},d:function(a,b,c){c=T(c);if(2===b){var e=qa;var f=ra;var g=sa;var l=function(){return H};var k=1}else 4===b&&(e=ta,f=ua,g=va,l=function(){return N},
k=2);X(a,{name:c,fromWireType:function(h){for(var n=N[h>>2],p=l(),q,y=h+4,C=0;C<=n;++C){var m=h+4+C*b;if(C==n||0==p[m>>k])y=e(y,m-y),void 0===q?q=y:(q+=String.fromCharCode(0),q+=y),y=m+b}Z(h);return q},toWireType:function(h,n){"string"!==typeof n&&W("Cannot pass non-string to C++ string type "+c);var p=g(n),q=yb(4+p+b);N[q>>2]=p>>k;f(n,q+4,p+b);null!==h&&h.push(Z,q);return q},argPackAdvance:8,readValueFromPointer:Za,T:function(h){Z(h)}})},j:function(a,b){b=T(b);X(a,{$:!0,name:b,argPackAdvance:0,fromWireType:function(){},
toWireType:function(){}})},u:Xa,z:function(a){if(0===a)return Ya(pb());var b=ob[a];a=void 0===b?T(a):b;return Ya(pb()[a])},m:function(a){4<a&&(Y[a].V+=1)},e:function(a,b,c,e){a||W("Cannot use deleted val. handle = "+a);a=Y[a].value;var f=rb[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")))(qb,d,Ya);rb[b]=f}return f(a,c,e)},s:function(){B()},r:function(a,b,c){G.copyWithin(a,b,b+c)},c:function(a){a>>>=0;var b=G.length;if(2147483648<a)return!1;for(var c=1;4>=c;c*=2){var e=b*(1+.2/c);e=Math.min(e,a+100663296);e=Math.max(16777216,a,e);0<e%
65536&&(e+=65536-e%65536);a:{try{F.grow(Math.min(2147483648,e)-L.byteLength+65535>>>16);ya(F.buffer);var f=1;break a}catch(g){}f=void 0}if(f)return!0}return!1},t:function(a,b){var c=0;tb().forEach(function(e,f){var g=b+c;f=J[a+4*f>>2]=g;for(g=0;g<e.length;++g)M[f++>>0]=e.charCodeAt(g);M[f>>0]=0;c+=e.length+1});return 0},v:function(a,b){var c=tb();J[a>>2]=c.length;var e=0;c.forEach(function(f){e+=f.length+1});J[b>>2]=e;return 0},k:function(a){if(!noExitRuntime&&(la=!0,d.onExit))d.onExit(a);u(a,new ia(a))},
w:function(){return 0},p:function(){},f:function(a,b,c,e){for(var f=0,g=0;g<c;g++){for(var l=J[b+8*g>>2],k=J[b+(8*g+4)>>2],h=0;h<k;h++){var n=G[l+h],p=vb[a];0===n||10===n?((1===a?ja:D)(na(p,0)),p.length=0):p.push(n)}f+=k}J[e>>2]=f;return 0},memory:F,q:function(){},table:ka};
(function(){function a(f){d.asm=f.exports;Q--;d.monitorRunDependencies&&d.monitorRunDependencies(Q);0==Q&&(null!==Fa&&(clearInterval(Fa),Fa=null),R&&(f=R,R=null,f()))}function b(f){a(f.instance)}function c(f){return Ka().then(function(g){return WebAssembly.instantiate(g,e)}).then(f,function(g){D("failed to asynchronously prepare wasm: "+g);B(g)})}var e={a:zb};Q++;d.monitorRunDependencies&&d.monitorRunDependencies(Q);if(d.instantiateWasm)try{return d.instantiateWasm(e,a)}catch(f){return D("Module.instantiateWasm callback failed with error: "+
f),!1}(function(){if(E||"function"!==typeof WebAssembly.instantiateStreaming||Ha()||Ga("file://")||"function"!==typeof fetch)return c(b);fetch(S,{credentials:"same-origin"}).then(function(f){return WebAssembly.instantiateStreaming(f,e).then(b,function(g){D("wasm streaming compile failed: "+g);D("falling back to ArrayBuffer instantiation");return c(b)})})})();return{}})();
var La=d.___wasm_call_ctors=function(){return(La=d.___wasm_call_ctors=d.asm.A).apply(null,arguments)},yb=d._malloc=function(){return(yb=d._malloc=d.asm.B).apply(null,arguments)},Z=d._free=function(){return(Z=d._free=d.asm.C).apply(null,arguments)},lb=d.___getTypeName=function(){return(lb=d.___getTypeName=d.asm.D).apply(null,arguments)};d.___embind_register_native_and_builtin_types=function(){return(d.___embind_register_native_and_builtin_types=d.asm.E).apply(null,arguments)};
d.dynCall_iii=function(){return(d.dynCall_iii=d.asm.F).apply(null,arguments)};d.dynCall_vii=function(){return(d.dynCall_vii=d.asm.G).apply(null,arguments)};d.dynCall_vi=function(){return(d.dynCall_vi=d.asm.H).apply(null,arguments)};d.dynCall_ii=function(){return(d.dynCall_ii=d.asm.I).apply(null,arguments)};d.dynCall_iiiiii=function(){return(d.dynCall_iiiiii=d.asm.J).apply(null,arguments)};d.dynCall_iiiiiii=function(){return(d.dynCall_iiiiiii=d.asm.K).apply(null,arguments)};
d.dynCall_iiiii=function(){return(d.dynCall_iiiii=d.asm.L).apply(null,arguments)};d.dynCall_iiii=function(){return(d.dynCall_iiii=d.asm.M).apply(null,arguments)};d.dynCall_viiiii=function(){return(d.dynCall_viiiii=d.asm.N).apply(null,arguments)};d.dynCall_viiii=function(){return(d.dynCall_viiii=d.asm.O).apply(null,arguments)};d.dynCall_viiiiiii=function(){return(d.dynCall_viiiiiii=d.asm.P).apply(null,arguments)};d.dynCall_jiji=function(){return(d.dynCall_jiji=d.asm.Q).apply(null,arguments)};
d.dynCall_viiiiii=function(){return(d.dynCall_viiiiii=d.asm.R).apply(null,arguments)};var Ab;function ia(a){this.name="ExitStatus";this.message="Program terminated with exit("+a+")";this.status=a}R=function Bb(){Ab||Cb();Ab||(R=Bb)};
function Cb(){function a(){if(!Ab&&(Ab=!0,d.calledRun=!0,!la)){O(Ba);O(Ca);aa(d);if(d.onRuntimeInitialized)d.onRuntimeInitialized();if(d.postRun)for("function"==typeof d.postRun&&(d.postRun=[d.postRun]);d.postRun.length;){var b=d.postRun.shift();Da.unshift(b)}O(Da)}}if(!(0<Q)){if(d.preRun)for("function"==typeof d.preRun&&(d.preRun=[d.preRun]);d.preRun.length;)Ea();O(Aa);0<Q||(d.setStatus?(d.setStatus("Running..."),setTimeout(function(){setTimeout(function(){d.setStatus("")},1);a()},1)):a())}}
d.run=Cb;if(d.preInit)for("function"==typeof d.preInit&&(d.preInit=[d.preInit]);0<d.preInit.length;)d.preInit.pop()();noExitRuntime=!0;Cb();
return mozjpeg_dec.ready
}
);
})();
if (typeof exports === 'object' && typeof module === 'object')
module.exports = mozjpeg_dec;
else if (typeof define === 'function' && define['amd'])
define([], function() { return mozjpeg_dec; });
else if (typeof exports === 'object')
exports["mozjpeg_dec"] = mozjpeg_dec;

Binary file not shown.

View File

@@ -1,72 +0,0 @@
var mozjpeg_enc = (function() {
var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename;
return (
function(mozjpeg_enc) {
mozjpeg_enc = mozjpeg_enc || {};
var d;d||(d=typeof mozjpeg_enc !== 'undefined' ? mozjpeg_enc : {});var aa,ba;d.ready=new Promise(function(a,b){aa=a;ba=b});var r={},t;for(t in d)d.hasOwnProperty(t)&&(r[t]=d[t]);var ca="./this.program";function u(a,b){throw b;}var v=!1,w=!1,da=!1,ea=!1;v="object"===typeof window;w="function"===typeof importScripts;da="object"===typeof process&&"object"===typeof process.versions&&"string"===typeof process.versions.node;ea=!v&&!da&&!w;var x="",B,C,fa,ha;
if(da)x=w?require("path").dirname(x)+"/":__dirname+"/",B=function(a,b){fa||(fa=require("fs"));ha||(ha=require("path"));a=ha.normalize(a);return fa.readFileSync(a,b?null:"utf8")},C=function(a){a=B(a,!0);a.buffer||(a=new Uint8Array(a));a.buffer||D("Assertion failed: undefined");return a},1<process.argv.length&&(ca=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),process.on("uncaughtException",function(a){if(!(a instanceof ia))throw a;}),process.on("unhandledRejection",D),u=function(a){process.exit(a)},
d.inspect=function(){return"[Emscripten Module object]"};else if(ea)"undefined"!=typeof read&&(B=function(a){return read(a)}),C=function(a){if("function"===typeof readbuffer)return new Uint8Array(readbuffer(a));a=read(a,"binary");"object"===typeof a||D("Assertion failed: undefined");return a},"function"===typeof quit&&(u=function(a){quit(a)}),"undefined"!==typeof print&&("undefined"===typeof console&&(console={}),console.log=print,console.warn=console.error="undefined"!==typeof printErr?printErr:
print);else if(v||w)w?x=self.location.href:document.currentScript&&(x=document.currentScript.src),_scriptDir&&(x=_scriptDir),0!==x.indexOf("blob:")?x=x.substr(0,x.lastIndexOf("/")+1):x="",B=function(a){var b=new XMLHttpRequest;b.open("GET",a,!1);b.send(null);return b.responseText},w&&(C=function(a){var b=new XMLHttpRequest;b.open("GET",a,!1);b.responseType="arraybuffer";b.send(null);return new Uint8Array(b.response)});var ja=d.print||console.log.bind(console),E=d.printErr||console.warn.bind(console);
for(t in r)r.hasOwnProperty(t)&&(d[t]=r[t]);r=null;d.thisProgram&&(ca=d.thisProgram);d.quit&&(u=d.quit);var G;d.wasmBinary&&(G=d.wasmBinary);var noExitRuntime;d.noExitRuntime&&(noExitRuntime=d.noExitRuntime);"object"!==typeof WebAssembly&&D("no native wasm support detected");var H,la=new WebAssembly.Table({initial:120,maximum:120,element:"anyfunc"}),ma=!1,na="undefined"!==typeof TextDecoder?new TextDecoder("utf8"):void 0;
function oa(a,b,c){var e=b+c;for(c=b;a[c]&&!(c>=e);)++c;if(16<c-b&&a.subarray&&na)return na.decode(a.subarray(b,c));for(e="";b<c;){var f=a[b++];if(f&128){var g=a[b++]&63;if(192==(f&224))e+=String.fromCharCode((f&31)<<6|g);else{var l=a[b++]&63;f=224==(f&240)?(f&15)<<12|g<<6|l:(f&7)<<18|g<<12|l<<6|a[b++]&63;65536>f?e+=String.fromCharCode(f):(f-=65536,e+=String.fromCharCode(55296|f>>10,56320|f&1023))}}else e+=String.fromCharCode(f)}return e}
function pa(a,b,c){var e=I;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;e[b++]=g}else{if(2047>=g){if(b+1>=c)break;e[b++]=192|g>>6}else{if(65535>=g){if(b+2>=c)break;e[b++]=224|g>>12}else{if(b+3>=c)break;e[b++]=240|g>>18;e[b++]=128|g>>12&63}e[b++]=128|g>>6&63}e[b++]=128|g&63}}e[b]=0}}var qa="undefined"!==typeof TextDecoder?new TextDecoder("utf-16le"):void 0;
function ra(a,b){var c=a>>1;for(var e=c+b/2;!(c>=e)&&sa[c];)++c;c<<=1;if(32<c-a&&qa)return qa.decode(I.subarray(a,c));c=0;for(e="";;){var f=J[a+2*c>>1];if(0==f||c==b/2)return e;++c;e+=String.fromCharCode(f)}}function ta(a,b,c){void 0===c&&(c=2147483647);if(2>c)return 0;c-=2;var e=b;c=c<2*a.length?c/2:a.length;for(var f=0;f<c;++f)J[b>>1]=a.charCodeAt(f),b+=2;J[b>>1]=0;return b-e}function ua(a){return 2*a.length}
function va(a,b){for(var c=0,e="";!(c>=b/4);){var f=K[a+4*c>>2];if(0==f)break;++c;65536<=f?(f-=65536,e+=String.fromCharCode(55296|f>>10,56320|f&1023)):e+=String.fromCharCode(f)}return e}function wa(a,b,c){void 0===c&&(c=2147483647);if(4>c)return 0;var e=b;c=e+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}K[b>>2]=g;b+=4;if(b+4>c)break}K[b>>2]=0;return b-e}
function xa(a){for(var b=0,c=0;c<a.length;++c){var e=a.charCodeAt(c);55296<=e&&57343>=e&&++c;b+=4}return b}var L,M,I,J,sa,K,N,ya,za;function Aa(a){L=a;d.HEAP8=M=new Int8Array(a);d.HEAP16=J=new Int16Array(a);d.HEAP32=K=new Int32Array(a);d.HEAPU8=I=new Uint8Array(a);d.HEAPU16=sa=new Uint16Array(a);d.HEAPU32=N=new Uint32Array(a);d.HEAPF32=ya=new Float32Array(a);d.HEAPF64=za=new Float64Array(a)}var Ba=d.INITIAL_MEMORY||16777216;d.wasmMemory?H=d.wasmMemory:H=new WebAssembly.Memory({initial:Ba/65536,maximum:32768});
H&&(L=H.buffer);Ba=L.byteLength;Aa(L);K[22872]=5334528;function Ca(a){for(;0<a.length;){var b=a.shift();if("function"==typeof b)b(d);else{var c=b.ga;"number"===typeof c?void 0===b.$?d.dynCall_v(c):d.dynCall_vi(c,b.$):c(void 0===b.$?null:b.$)}}}var Da=[],Ea=[],Fa=[],Ga=[];function Ha(){var a=d.preRun.shift();Da.unshift(a)}var O=0,Ia=null,P=null;d.preloadedImages={};d.preloadedAudios={};
function D(a){if(d.onAbort)d.onAbort(a);E(a);ma=!0;a=new WebAssembly.RuntimeError("abort("+a+"). Build with -s ASSERTIONS=1 for more info.");ba(a);throw a;}function Ja(a){var b=Q;return String.prototype.startsWith?b.startsWith(a):0===b.indexOf(a)}function Ka(){return Ja("data:application/octet-stream;base64,")}var Q="mozjpeg_enc.wasm";if(!Ka()){var La=Q;Q=d.locateFile?d.locateFile(La,x):x+La}
function Ma(){try{if(G)return new Uint8Array(G);if(C)return C(Q);throw"both async and sync fetching of the wasm failed";}catch(a){D(a)}}function Na(){return G||!v&&!w||"function"!==typeof fetch||Ja("file://")?new Promise(function(a){a(Ma())}):fetch(Q,{credentials:"same-origin"}).then(function(a){if(!a.ok)throw"failed to load wasm binary file at '"+Q+"'";return a.arrayBuffer()}).catch(function(){return Ma()})}Ea.push({ga:function(){Oa()}});function Pa(){return 0<Pa.ba}var Qa={};
function Ra(a){for(;a.length;){var b=a.pop();a.pop()(b)}}function Sa(a){return this.fromWireType(N[a>>2])}var R={},S={},Ta={};function Ua(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 Va(a,b){a=Ua(a);return(new Function("body","return function "+a+'() {\n "use strict"; return body.apply(this, arguments);\n};\n'))(b)}
function Wa(a){var b=Error,c=Va(a,function(e){this.name=a;this.message=e;e=Error(e).stack;void 0!==e&&(this.stack=this.toString()+"\n"+e.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 Xa=void 0;
function Ya(a,b,c){function e(k){k=c(k);if(k.length!==a.length)throw new Xa("Mismatched type converter count");for(var h=0;h<a.length;++h)T(a[h],k[h])}a.forEach(function(k){Ta[k]=b});var f=Array(b.length),g=[],l=0;b.forEach(function(k,h){S.hasOwnProperty(k)?f[h]=S[k]:(g.push(k),R.hasOwnProperty(k)||(R[k]=[]),R[k].push(function(){f[h]=S[k];++l;l===g.length&&e(f)}))});0===g.length&&e(f)}
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 $a=void 0;function U(a){for(var b="";I[a];)b+=$a[I[a++]];return b}var ab=void 0;function V(a){throw new ab(a);}
function T(a,b,c){c=c||{};if(!("argPackAdvance"in b))throw new TypeError("registerType registeredInstance requires argPackAdvance");var e=b.name;a||V('type "'+e+'" must have a positive integer typeid pointer');if(S.hasOwnProperty(a)){if(c.ka)return;V("Cannot register type '"+e+"' twice")}S[a]=b;delete Ta[a];R.hasOwnProperty(a)&&(b=R[a],delete R[a],b.forEach(function(f){f()}))}var bb=[],X=[{},{value:void 0},{value:null},{value:!0},{value:!1}];
function cb(a){4<a&&0===--X[a].aa&&(X[a]=void 0,bb.push(a))}function db(a){switch(a){case void 0:return 1;case null:return 2;case !0:return 3;case !1:return 4;default:var b=bb.length?bb.pop():X.length;X[b]={aa:1,value:a};return b}}function eb(a){if(null===a)return"null";var b=typeof a;return"object"===b||"array"===b||"function"===b?a.toString():""+a}
function fb(a,b){switch(b){case 2:return function(c){return this.fromWireType(ya[c>>2])};case 3:return function(c){return this.fromWireType(za[c>>3])};default:throw new TypeError("Unknown float type: "+a);}}function gb(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=Va(b.name||"unknownFunctionName",function(){});c.prototype=b.prototype;c=new c;a=b.apply(c,a);return a instanceof Object?a:c}
function hb(a,b){var c=d;if(void 0===c[a].Y){var e=c[a];c[a]=function(){c[a].Y.hasOwnProperty(arguments.length)||V("Function '"+b+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+c[a].Y+")!");return c[a].Y[arguments.length].apply(this,arguments)};c[a].Y=[];c[a].Y[e.ea]=e}}
function ib(a,b,c){d.hasOwnProperty(a)?((void 0===c||void 0!==d[a].Y&&void 0!==d[a].Y[c])&&V("Cannot register public name '"+a+"' twice"),hb(a,a),d.hasOwnProperty(c)&&V("Cannot register multiple overloads of a function with the same number of arguments ("+c+")!"),d[a].Y[c]=b):(d[a]=b,void 0!==c&&(d[a].ra=c))}function jb(a,b){for(var c=[],e=0;e<a;e++)c.push(K[(b>>2)+e]);return c}
function Y(a,b){a=U(a);var c=d["dynCall_"+a];for(var e=[],f=1;f<a.length;++f)e.push("a"+f);f="return function dynCall_"+(a+"_"+b)+"("+e.join(", ")+") {\n";f+=" return dynCall(rawFunction"+(e.length?", ":"")+e.join(", ")+");\n";c=(new Function("dynCall","rawFunction",f+"};\n"))(c,b);"function"!==typeof c&&V("unknown function pointer with signature "+a+": "+b);return c}var kb=void 0;function lb(a){a=mb(a);var b=U(a);Z(a);return b}
function nb(a,b){function c(g){f[g]||S[g]||(Ta[g]?Ta[g].forEach(c):(e.push(g),f[g]=!0))}var e=[],f={};b.forEach(c);throw new kb(a+": "+e.map(lb).join([", "]));}function ob(a,b,c){switch(b){case 0:return c?function(e){return M[e]}:function(e){return I[e]};case 1:return c?function(e){return J[e>>1]}:function(e){return sa[e>>1]};case 2:return c?function(e){return K[e>>2]}:function(e){return N[e>>2]};default:throw new TypeError("Unknown integer type: "+a);}}var pb={};
function qb(){return"object"===typeof globalThis?globalThis:Function("return this")()}function rb(a,b){var c=S[a];void 0===c&&V(b+" has unknown type "+lb(a));return c}var sb={},tb={};function ub(){if(!vb){var a={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"===typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:ca||"./this.program"},b;for(b in tb)a[b]=tb[b];var c=[];for(b in a)c.push(b+"="+a[b]);vb=c}return vb}
var vb,wb=[null,[],[]];Xa=d.InternalError=Wa("InternalError");for(var xb=Array(256),yb=0;256>yb;++yb)xb[yb]=String.fromCharCode(yb);$a=xb;ab=d.BindingError=Wa("BindingError");d.count_emval_handles=function(){for(var a=0,b=5;b<X.length;++b)void 0!==X[b]&&++a;return a};d.get_first_emval=function(){for(var a=5;a<X.length;++a)if(void 0!==X[a])return X[a];return null};kb=d.UnboundTypeError=Wa("UnboundTypeError");
var Ab={i:function(a){return zb(a)},C:function(){},A:function(a){"uncaught_exception"in Pa?Pa.ba++:Pa.ba=1;throw a;},l:function(a){var b=Qa[a];delete Qa[a];var c=b.la,e=b.ma,f=b.da,g=f.map(function(l){return l.ja}).concat(f.map(function(l){return l.oa}));Ya([a],g,function(l){var k={};f.forEach(function(h,m){var n=l[m],q=h.ha,y=h.ia,z=l[m+f.length],p=h.na,ka=h.pa;k[h.fa]={read:function(A){return n.fromWireType(q(y,A))},write:function(A,F){var W=[];p(ka,A,z.toWireType(W,F));Ra(W)}}});return[{name:b.name,
fromWireType:function(h){var m={},n;for(n in k)m[n]=k[n].read(h);e(h);return m},toWireType:function(h,m){for(var n in k)if(!(n in m))throw new TypeError('Missing field: "'+n+'"');var q=c();for(n in k)k[n].write(q,m[n]);null!==h&&h.push(e,q);return q},argPackAdvance:8,readValueFromPointer:Sa,Z:e}]})},x:function(a,b,c,e,f){var g=Za(c);b=U(b);T(a,{name:b,fromWireType:function(l){return!!l},toWireType:function(l,k){return k?e:f},argPackAdvance:8,readValueFromPointer:function(l){if(1===c)var k=M;else if(2===
c)k=J;else if(4===c)k=K;else throw new TypeError("Unknown boolean type size: "+b);return this.fromWireType(k[l>>g])},Z:null})},w:function(a,b){b=U(b);T(a,{name:b,fromWireType:function(c){var e=X[c].value;cb(c);return e},toWireType:function(c,e){return db(e)},argPackAdvance:8,readValueFromPointer:Sa,Z:null})},g:function(a,b,c){c=Za(c);b=U(b);T(a,{name:b,fromWireType:function(e){return e},toWireType:function(e,f){if("number"!==typeof f&&"boolean"!==typeof f)throw new TypeError('Cannot convert "'+eb(f)+
'" to '+this.name);return f},argPackAdvance:8,readValueFromPointer:fb(b,c),Z:null})},k:function(a,b,c,e,f,g){var l=jb(b,c);a=U(a);f=Y(e,f);ib(a,function(){nb("Cannot call "+a+" due to unbound types",l)},b-1);Ya([],l,function(k){var h=[k[0],null].concat(k.slice(1)),m=k=a,n=f,q=h.length;2>q&&V("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var y=null!==h[1]&&!1,z=!1,p=1;p<h.length;++p)if(null!==h[p]&&void 0===h[p].Z){z=!0;break}var ka="void"!==h[0].name,A="",F=
"";for(p=0;p<q-2;++p)A+=(0!==p?", ":"")+"arg"+p,F+=(0!==p?", ":"")+"arg"+p+"Wired";m="return function "+Ua(m)+"("+A+") {\nif (arguments.length !== "+(q-2)+") {\nthrowBindingError('function "+m+" called with ' + arguments.length + ' arguments, expected "+(q-2)+" args!');\n}\n";z&&(m+="var destructors = [];\n");var W=z?"destructors":"null";A="throwBindingError invoker fn runDestructors retType classParam".split(" ");n=[V,n,g,Ra,h[0],h[1]];y&&(m+="var thisWired = classParam.toWireType("+W+", this);\n");
for(p=0;p<q-2;++p)m+="var arg"+p+"Wired = argType"+p+".toWireType("+W+", arg"+p+"); // "+h[p+2].name+"\n",A.push("argType"+p),n.push(h[p+2]);y&&(F="thisWired"+(0<F.length?", ":"")+F);m+=(ka?"var rv = ":"")+"invoker(fn"+(0<F.length?", ":"")+F+");\n";if(z)m+="runDestructors(destructors);\n";else for(p=y?1:2;p<h.length;++p)q=1===p?"thisWired":"arg"+(p-2)+"Wired",null!==h[p].Z&&(m+=q+"_dtor("+q+"); // "+h[p].name+"\n",A.push(q+"_dtor"),n.push(h[p].Z));ka&&(m+="var ret = retType.fromWireType(rv);\nreturn ret;\n");
A.push(m+"}\n");h=gb(A).apply(null,n);p=b-1;if(!d.hasOwnProperty(k))throw new Xa("Replacing nonexistant public symbol");void 0!==d[k].Y&&void 0!==p?d[k].Y[p]=h:(d[k]=h,d[k].ea=p);return[]})},b:function(a,b,c,e,f){function g(m){return m}b=U(b);-1===f&&(f=4294967295);var l=Za(c);if(0===e){var k=32-8*c;g=function(m){return m<<k>>>k}}var h=-1!=b.indexOf("unsigned");T(a,{name:b,fromWireType:g,toWireType:function(m,n){if("number"!==typeof n&&"boolean"!==typeof n)throw new TypeError('Cannot convert "'+eb(n)+
'" to '+this.name);if(n<e||n>f)throw new TypeError('Passing a number "'+eb(n)+'" from JS side to C/C++ side to an argument of type "'+b+'", which is outside the valid range ['+e+", "+f+"]!");return h?n>>>0:n|0},argPackAdvance:8,readValueFromPointer:ob(b,l,0!==e),Z:null})},a:function(a,b,c){function e(g){g>>=2;var l=N;return new f(L,l[g+1],l[g])}var f=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][b];c=U(c);T(a,{name:c,fromWireType:e,argPackAdvance:8,
readValueFromPointer:e},{ka:!0})},h:function(a,b){b=U(b);var c="std::string"===b;T(a,{name:b,fromWireType:function(e){var f=N[e>>2];if(c)for(var g=e+4,l=0;l<=f;++l){var k=e+4+l;if(l==f||0==I[k]){g=g?oa(I,g,k-g):"";if(void 0===h)var h=g;else h+=String.fromCharCode(0),h+=g;g=k+1}}else{h=Array(f);for(l=0;l<f;++l)h[l]=String.fromCharCode(I[e+4+l]);h=h.join("")}Z(e);return h},toWireType:function(e,f){f instanceof ArrayBuffer&&(f=new Uint8Array(f));var g="string"===typeof f;g||f instanceof Uint8Array||
f instanceof Uint8ClampedArray||f instanceof Int8Array||V("Cannot pass non-string to std::string");var l=(c&&g?function(){for(var m=0,n=0;n<f.length;++n){var q=f.charCodeAt(n);55296<=q&&57343>=q&&(q=65536+((q&1023)<<10)|f.charCodeAt(++n)&1023);127>=q?++m:m=2047>=q?m+2:65535>=q?m+3:m+4}return m}:function(){return f.length})(),k=zb(4+l+1);N[k>>2]=l;if(c&&g)pa(f,k+4,l+1);else if(g)for(g=0;g<l;++g){var h=f.charCodeAt(g);255<h&&(Z(k),V("String has UTF-16 code units that do not fit in 8 bits"));I[k+4+g]=
h}else for(g=0;g<l;++g)I[k+4+g]=f[g];null!==e&&e.push(Z,k);return k},argPackAdvance:8,readValueFromPointer:Sa,Z:function(e){Z(e)}})},d:function(a,b,c){c=U(c);if(2===b){var e=ra;var f=ta;var g=ua;var l=function(){return sa};var k=1}else 4===b&&(e=va,f=wa,g=xa,l=function(){return N},k=2);T(a,{name:c,fromWireType:function(h){for(var m=N[h>>2],n=l(),q,y=h+4,z=0;z<=m;++z){var p=h+4+z*b;if(z==m||0==n[p>>k])y=e(y,p-y),void 0===q?q=y:(q+=String.fromCharCode(0),q+=y),y=p+b}Z(h);return q},toWireType:function(h,
m){"string"!==typeof m&&V("Cannot pass non-string to C++ string type "+c);var n=g(m),q=zb(4+n+b);N[q>>2]=n>>k;f(m,q+4,n+b);null!==h&&h.push(Z,q);return q},argPackAdvance:8,readValueFromPointer:Sa,Z:function(h){Z(h)}})},m:function(a,b,c,e,f,g){Qa[a]={name:U(b),la:Y(c,e),ma:Y(f,g),da:[]}},e:function(a,b,c,e,f,g,l,k,h,m){Qa[a].da.push({fa:U(b),ja:c,ha:Y(e,f),ia:g,oa:l,na:Y(k,h),pa:m})},y:function(a,b){b=U(b);T(a,{qa:!0,name:b,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},v:cb,
B:function(a){if(0===a)return db(qb());var b=pb[a];a=void 0===b?U(a):b;return db(qb()[a])},j:function(a){4<a&&(X[a].aa+=1)},n:function(a,b,c,e){a||V("Cannot use deleted val. handle = "+a);a=X[a].value;var f=sb[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")))(rb,d,db);sb[b]=f}return f(a,c,e)},r:function(){D()},q:function(a,b,c){I.copyWithin(a,b,b+c)},c:function(a){a>>>=0;var b=I.length;if(2147483648<a)return!1;for(var c=1;4>=c;c*=2){var e=b*(1+.2/c);e=Math.min(e,a+100663296);e=Math.max(16777216,a,e);0<e%65536&&(e+=65536-e%65536);a:{try{H.grow(Math.min(2147483648,
e)-L.byteLength+65535>>>16);Aa(H.buffer);var f=1;break a}catch(g){}f=void 0}if(f)return!0}return!1},s:function(a,b){var c=0;ub().forEach(function(e,f){var g=b+c;f=K[a+4*f>>2]=g;for(g=0;g<e.length;++g)M[f++>>0]=e.charCodeAt(g);M[f>>0]=0;c+=e.length+1});return 0},t:function(a,b){var c=ub();K[a>>2]=c.length;var e=0;c.forEach(function(f){e+=f.length+1});K[b>>2]=e;return 0},z:function(a){if(!noExitRuntime&&(ma=!0,d.onExit))d.onExit(a);u(a,new ia(a))},u:function(){return 0},o:function(){},f:function(a,
b,c,e){for(var f=0,g=0;g<c;g++){for(var l=K[b+8*g>>2],k=K[b+(8*g+4)>>2],h=0;h<k;h++){var m=I[l+h],n=wb[a];0===m||10===m?((1===a?ja:E)(oa(n,0)),n.length=0):n.push(m)}f+=k}K[e>>2]=f;return 0},memory:H,p:function(){},table:la};
(function(){function a(f){d.asm=f.exports;O--;d.monitorRunDependencies&&d.monitorRunDependencies(O);0==O&&(null!==Ia&&(clearInterval(Ia),Ia=null),P&&(f=P,P=null,f()))}function b(f){a(f.instance)}function c(f){return Na().then(function(g){return WebAssembly.instantiate(g,e)}).then(f,function(g){E("failed to asynchronously prepare wasm: "+g);D(g)})}var e={a:Ab};O++;d.monitorRunDependencies&&d.monitorRunDependencies(O);if(d.instantiateWasm)try{return d.instantiateWasm(e,a)}catch(f){return E("Module.instantiateWasm callback failed with error: "+
f),!1}(function(){if(G||"function"!==typeof WebAssembly.instantiateStreaming||Ka()||Ja("file://")||"function"!==typeof fetch)return c(b);fetch(Q,{credentials:"same-origin"}).then(function(f){return WebAssembly.instantiateStreaming(f,e).then(b,function(g){E("wasm streaming compile failed: "+g);E("falling back to ArrayBuffer instantiation");return c(b)})})})();return{}})();
var Oa=d.___wasm_call_ctors=function(){return(Oa=d.___wasm_call_ctors=d.asm.D).apply(null,arguments)},Z=d._free=function(){return(Z=d._free=d.asm.E).apply(null,arguments)},zb=d._malloc=function(){return(zb=d._malloc=d.asm.F).apply(null,arguments)},mb=d.___getTypeName=function(){return(mb=d.___getTypeName=d.asm.G).apply(null,arguments)};d.___embind_register_native_and_builtin_types=function(){return(d.___embind_register_native_and_builtin_types=d.asm.H).apply(null,arguments)};
d.dynCall_i=function(){return(d.dynCall_i=d.asm.I).apply(null,arguments)};d.dynCall_vi=function(){return(d.dynCall_vi=d.asm.J).apply(null,arguments)};d.dynCall_iii=function(){return(d.dynCall_iii=d.asm.K).apply(null,arguments)};d.dynCall_viii=function(){return(d.dynCall_viii=d.asm.L).apply(null,arguments)};d.dynCall_iiiiii=function(){return(d.dynCall_iiiiii=d.asm.M).apply(null,arguments)};d.dynCall_viiiii=function(){return(d.dynCall_viiiii=d.asm.N).apply(null,arguments)};
d.dynCall_vii=function(){return(d.dynCall_vii=d.asm.O).apply(null,arguments)};d.dynCall_ii=function(){return(d.dynCall_ii=d.asm.P).apply(null,arguments)};d.dynCall_iiiiiii=function(){return(d.dynCall_iiiiiii=d.asm.Q).apply(null,arguments)};d.dynCall_iiiii=function(){return(d.dynCall_iiiii=d.asm.R).apply(null,arguments)};d.dynCall_iiii=function(){return(d.dynCall_iiii=d.asm.S).apply(null,arguments)};d.dynCall_viiiiiiii=function(){return(d.dynCall_viiiiiiii=d.asm.T).apply(null,arguments)};
d.dynCall_viiii=function(){return(d.dynCall_viiii=d.asm.U).apply(null,arguments)};d.dynCall_viiiiiii=function(){return(d.dynCall_viiiiiii=d.asm.V).apply(null,arguments)};d.dynCall_jiji=function(){return(d.dynCall_jiji=d.asm.W).apply(null,arguments)};d.dynCall_viiiiii=function(){return(d.dynCall_viiiiii=d.asm.X).apply(null,arguments)};var Bb;function ia(a){this.name="ExitStatus";this.message="Program terminated with exit("+a+")";this.status=a}P=function Cb(){Bb||Db();Bb||(P=Cb)};
function Db(){function a(){if(!Bb&&(Bb=!0,d.calledRun=!0,!ma)){Ca(Ea);Ca(Fa);aa(d);if(d.onRuntimeInitialized)d.onRuntimeInitialized();if(d.postRun)for("function"==typeof d.postRun&&(d.postRun=[d.postRun]);d.postRun.length;){var b=d.postRun.shift();Ga.unshift(b)}Ca(Ga)}}if(!(0<O)){if(d.preRun)for("function"==typeof d.preRun&&(d.preRun=[d.preRun]);d.preRun.length;)Ha();Ca(Da);0<O||(d.setStatus?(d.setStatus("Running..."),setTimeout(function(){setTimeout(function(){d.setStatus("")},1);a()},1)):a())}}
d.run=Db;if(d.preInit)for("function"==typeof d.preInit&&(d.preInit=[d.preInit]);0<d.preInit.length;)d.preInit.pop()();noExitRuntime=!0;Db();
return mozjpeg_enc.ready
}
);
})();
if (typeof exports === 'object' && typeof module === 'object')
module.exports = mozjpeg_enc;
else if (typeof define === 'function' && define['amd'])
define([], function() { return mozjpeg_enc; });
else if (typeof exports === 'object')
exports["mozjpeg_enc"] = mozjpeg_enc;

Binary file not shown.

View File

@@ -1,4 +0,0 @@
{
"name": "mozjpeg_enc",
"lockfileVersion": 1
}

View File

@@ -1,6 +0,0 @@
{
"name": "mozjpeg_enc",
"scripts": {
"build": "../build-cpp.sh"
}
}

View File

@@ -17,6 +17,10 @@ See `example.html`
Returns the version of MozJPEG as a number. va.b.c is encoded as 0x0a0b0c
### `void free_result()`
Frees the result created by `encode()`.
### `Uint8Array encode(std::string image_in, int image_width, int image_height, MozJpegOptions opts)`
Encodes the given image with given dimension to JPEG. Options looks like this:

53
codecs/mozjpeg_enc/build.sh Executable file
View File

@@ -0,0 +1,53 @@
#!/bin/bash
set -e
export OPTIMIZE="-Os"
export LDFLAGS="${OPTIMIZE}"
export CFLAGS="${OPTIMIZE}"
export CPPFLAGS="${OPTIMIZE}"
apt-get update
apt-get install -qqy autoconf libtool libpng-dev pkg-config
echo "============================================="
echo "Compiling mozjpeg"
echo "============================================="
(
cd node_modules/mozjpeg
autoreconf -fiv
emconfigure ./configure --without-simd
emmake make libjpeg.la
)
echo "============================================="
echo "Compiling mozjpeg done"
echo "============================================="
echo "============================================="
echo "Compiling wasm bindings"
echo "============================================="
(
emcc \
--bind \
${OPTIMIZE} \
-s WASM=1 \
-s ALLOW_MEMORY_GROWTH=1 \
-s MODULARIZE=1 \
-s 'EXPORT_NAME="mozjpeg_enc"' \
-I node_modules/mozjpeg \
-o ./mozjpeg_enc.js \
-Wno-deprecated-register \
-Wno-writable-strings \
node_modules/mozjpeg/rdswitch.c \
-x c++ -std=c++11 \
mozjpeg_enc.cpp \
node_modules/mozjpeg/.libs/libjpeg.a
)
echo "============================================="
echo "Compiling wasm bindings done"
echo "============================================="
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "Did you update your docker image?"
echo "Run \`docker pull trzeci/emscripten\`"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"

View File

@@ -1,14 +1,21 @@
#include <emscripten/bind.h>
#include <emscripten/val.h>
#include <stdlib.h>
#include <inttypes.h>
#include <stdio.h>
#include <setjmp.h>
#include <string.h>
#include "config.h"
#include "jpeglib.h"
extern "C" {
#include "cdjpeg.h"
}
using namespace emscripten;
// MozJPEG doesnt expose a numeric version, so I have to do some fun C macro hackery to turn it
// into a string. More details here: https://gcc.gnu.org/onlinedocs/cpp/Stringizing.html
#define xstr(s) str(s)
#define str(s) #s
struct MozJpegOptions {
int quality;
bool baseline;
@@ -28,16 +35,32 @@ struct MozJpegOptions {
int chroma_quality;
};
thread_local const val Uint8Array = val::global("Uint8Array");
int version() {
char buffer[] = xstr(MOZJPEG_VERSION);
int version = 0;
int last_index = 0;
for(int i = 0; i < strlen(buffer); i++) {
if(buffer[i] == '.') {
buffer[i] = '\0';
version = version << 8 | atoi(&buffer[last_index]);
buffer[i] = '.';
last_index = i + 1;
}
}
version = version << 8 | atoi(&buffer[last_index]);
return version;
}
uint8_t* last_result;
struct jpeg_compress_struct cinfo;
val encode(std::string image_in, int image_width, int image_height, MozJpegOptions opts) {
uint8_t* image_buffer = (uint8_t*)image_in.c_str();
uint8_t* image_buffer = (uint8_t*) image_in.c_str();
// The code below is basically the `write_JPEG_file` function from
// https://github.com/mozilla/mozjpeg/blob/master/example.c
// I just write to memory instead of a file.
/* Step 1: allocate and initialize JPEG compression object */
/* This struct contains the JPEG compression parameters and pointers to
* working space (which is allocated as needed by the JPEG library).
@@ -45,7 +68,6 @@ val encode(std::string image_in, int image_width, int image_height, MozJpegOptio
* compression/decompression processes, in existence at once. We refer
* to any one struct (and its associated working data) as a "JPEG object".
*/
jpeg_compress_struct cinfo;
/* This struct represents a JPEG error handler. It is declared separately
* because applications often want to supply a specialized error handler
* (see the second half of this file for an example). But here we just
@@ -54,7 +76,15 @@ val encode(std::string image_in, int image_width, int image_height, MozJpegOptio
* Note that this struct must live as long as the main JPEG parameter
* struct, to avoid dangling-pointer problems.
*/
jpeg_error_mgr jerr;
struct jpeg_error_mgr jerr;
/* More stuff */
JSAMPROW row_pointer[1]; /* pointer to JSAMPLE row[s] */
int row_stride; /* physical row width in image buffer */
uint8_t* output;
unsigned long size;
/* Step 1: allocate and initialize JPEG compression object */
/* We have to set up the error handler first, in case the initialization
* step fails. (Unlikely, but it could happen if you are out of memory.)
* This routine fills in the contents of struct jerr, and returns jerr's
@@ -76,8 +106,6 @@ val encode(std::string image_in, int image_width, int image_height, MozJpegOptio
// fprintf(stderr, "can't open %s\n", filename);
// exit(1);
// }
uint8_t* output = nullptr;
unsigned long size = 0;
jpeg_mem_dest(&cinfo, &output, &size);
/* Step 3: set parameters for compression */
@@ -85,17 +113,17 @@ val encode(std::string image_in, int image_width, int image_height, MozJpegOptio
/* First we supply a description of the input image.
* Four fields of the cinfo struct must be filled in:
*/
cinfo.image_width = image_width; /* image width and height, in pixels */
cinfo.image_width = image_width; /* image width and height, in pixels */
cinfo.image_height = image_height;
cinfo.input_components = 4; /* # of color components per pixel */
cinfo.in_color_space = JCS_EXT_RGBA; /* colorspace of input image */
cinfo.input_components = 4; /* # of color components per pixel */
cinfo.in_color_space = JCS_EXT_RGBA; /* colorspace of input image */
/* Now use the library's routine to set default compression parameters.
* (You must set at least cinfo.in_color_space before calling this,
* since the defaults depend on the source color space.)
*/
jpeg_set_defaults(&cinfo);
jpeg_set_colorspace(&cinfo, (J_COLOR_SPACE)opts.color_space);
jpeg_set_colorspace(&cinfo, (J_COLOR_SPACE) opts.color_space);
if (opts.quant_table != -1) {
jpeg_c_set_int_param(&cinfo, JINT_BASE_QUANT_TBL_IDX, opts.quant_table);
@@ -115,17 +143,17 @@ val encode(std::string image_in, int image_width, int image_height, MozJpegOptio
jpeg_c_set_bool_param(&cinfo, JBOOLEAN_TRELLIS_Q_OPT, opts.trellis_opt_table);
jpeg_c_set_int_param(&cinfo, JINT_TRELLIS_NUM_LOOPS, opts.trellis_loops);
// A little hacky to build a string for this, but it means we can use
// set_quality_ratings which does some useful heuristic stuff.
// A little hacky to build a string for this, but it means we can use set_quality_ratings which
// does some useful heuristic stuff.
std::string quality_str = std::to_string(opts.quality);
if (opts.separate_chroma_quality && opts.color_space == JCS_YCbCr) {
quality_str += "," + std::to_string(opts.chroma_quality);
}
char const* pqual = quality_str.c_str();
char const *pqual = quality_str.c_str();
set_quality_ratings(&cinfo, (char*)pqual, opts.baseline);
set_quality_ratings(&cinfo, (char*) pqual, opts.baseline);
if (!opts.auto_subsample && opts.color_space == JCS_YCbCr) {
cinfo.comp_info[0].h_samp_factor = opts.chroma_subsample;
@@ -153,53 +181,54 @@ val encode(std::string image_in, int image_width, int image_height, MozJpegOptio
* To keep things simple, we pass one scanline per call; you can pass
* more if you wish, though.
*/
int row_stride = image_width * 4; /* JSAMPLEs per row in image_buffer */
row_stride = image_width * 4; /* JSAMPLEs per row in image_buffer */
while (cinfo.next_scanline < cinfo.image_height) {
/* jpeg_write_scanlines expects an array of pointers to scanlines.
* Here the array is only one element long, but you could pass
* more than one scanline at a time if that's more convenient.
*/
JSAMPROW row_pointer =
&image_buffer[cinfo.next_scanline * row_stride]; /* pointer to JSAMPLE row[s] */
(void)jpeg_write_scanlines(&cinfo, &row_pointer, 1);
row_pointer[0] = & image_buffer[cinfo.next_scanline * row_stride];
(void) jpeg_write_scanlines(&cinfo, row_pointer, 1);
}
/* Step 6: Finish compression */
jpeg_finish_compress(&cinfo);
/* Step 7: release JPEG compression object */
auto js_result = Uint8Array.new_(typed_memory_view(size, output));
/* This is an important step since it will release a good deal of memory. */
jpeg_destroy_compress(&cinfo);
free(output);
last_result = output;
/* And we're done! */
return js_result;
return val(typed_memory_view(size, output));
}
void free_result() {
/* This is an important step since it will release a good deal of memory. */
jpeg_destroy_compress(&cinfo);
}
EMSCRIPTEN_BINDINGS(my_module) {
value_object<MozJpegOptions>("MozJpegOptions")
.field("quality", &MozJpegOptions::quality)
.field("baseline", &MozJpegOptions::baseline)
.field("arithmetic", &MozJpegOptions::arithmetic)
.field("progressive", &MozJpegOptions::progressive)
.field("optimize_coding", &MozJpegOptions::optimize_coding)
.field("smoothing", &MozJpegOptions::smoothing)
.field("color_space", &MozJpegOptions::color_space)
.field("quant_table", &MozJpegOptions::quant_table)
.field("trellis_multipass", &MozJpegOptions::trellis_multipass)
.field("trellis_opt_zero", &MozJpegOptions::trellis_opt_zero)
.field("trellis_opt_table", &MozJpegOptions::trellis_opt_table)
.field("trellis_loops", &MozJpegOptions::trellis_loops)
.field("chroma_subsample", &MozJpegOptions::chroma_subsample)
.field("auto_subsample", &MozJpegOptions::auto_subsample)
.field("separate_chroma_quality", &MozJpegOptions::separate_chroma_quality)
.field("chroma_quality", &MozJpegOptions::chroma_quality);
.field("quality", &MozJpegOptions::quality)
.field("baseline", &MozJpegOptions::baseline)
.field("arithmetic", &MozJpegOptions::arithmetic)
.field("progressive", &MozJpegOptions::progressive)
.field("optimize_coding", &MozJpegOptions::optimize_coding)
.field("smoothing", &MozJpegOptions::smoothing)
.field("color_space", &MozJpegOptions::color_space)
.field("quant_table", &MozJpegOptions::quant_table)
.field("trellis_multipass", &MozJpegOptions::trellis_multipass)
.field("trellis_opt_zero", &MozJpegOptions::trellis_opt_zero)
.field("trellis_opt_table", &MozJpegOptions::trellis_opt_table)
.field("trellis_loops", &MozJpegOptions::trellis_loops)
.field("chroma_subsample", &MozJpegOptions::chroma_subsample)
.field("auto_subsample", &MozJpegOptions::auto_subsample)
.field("separate_chroma_quality", &MozJpegOptions::separate_chroma_quality)
.field("chroma_quality", &MozJpegOptions::chroma_quality)
;
function("version", &version);
function("encode", &encode);
function("free_result", &free_result);
}

View File

@@ -2,6 +2,7 @@ import { EncodeOptions } from '../../src/codecs/mozjpeg/encoder-meta';
interface MozJPEGModule extends EmscriptenWasm.Module {
encode(data: BufferSource, width: number, height: number, options: EncodeOptions): Uint8Array;
free_result(): void;
}
export default function(opts: EmscriptenWasm.ModuleOpts): MozJPEGModule;

File diff suppressed because one or more lines are too long

Binary file not shown.

1147
codecs/mozjpeg_enc/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,13 @@
{
"name": "mozjpeg_enc",
"scripts": {
"install": "napa",
"build": "docker run --rm -v $(pwd):/src trzeci/emscripten ./build.sh"
},
"napa": {
"mozjpeg": "mozilla/mozjpeg#v3.3.1"
},
"devDependencies": {
"napa": "^3.0.0"
}
}

2
codecs/optipng/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
build/
*.o

26
codecs/optipng/README.md Normal file
View File

@@ -0,0 +1,26 @@
# OptiPNG
- Source: <https://sourceforge.net/project/optipng>
- Version: v0.7.7
## Dependencies
- Docker
## Example
See `example.html`
## API
### `int version()`
Returns the version of optipng as a number. va.b.c is encoded as 0x0a0b0c
### `ArrayBuffer compress(std::string buffer, {level})`;
`compress` will re-compress the given PNG image via `buffer`. `level` is a number between 0 and 7.
### `void free_result()`
Frees the result created by `compress()`.

87
codecs/optipng/build.sh Executable file
View File

@@ -0,0 +1,87 @@
#!/bin/bash
set -e
export OPTIMIZE="-Os"
export PREFIX="/src/build"
export CFLAGS="${OPTIMIZE} -I${PREFIX}/include/"
export CPPFLAGS="${OPTIMIZE} -I${PREFIX}/include/"
export LDFLAGS="${OPTIMIZE} -L${PREFIX}/lib/"
apt-get update
apt-get install -qqy autoconf libtool
echo "============================================="
echo "Compiling zlib"
echo "============================================="
test -n "$SKIP_ZLIB" || (
cd node_modules/zlib
emconfigure ./configure --prefix=${PREFIX}/
emmake make
emmake make install
)
echo "============================================="
echo "Compiling zlib done"
echo "============================================="
echo "============================================="
echo "Compiling libpng"
echo "============================================="
test -n "$SKIP_LIBPNG" || (
cd node_modules/libpng
autoreconf -i
emconfigure ./configure --with-zlib-prefix=${PREFIX}/ --prefix=${PREFIX}/
emmake make
emmake make install
)
echo "============================================="
echo "Compiling libpng done"
echo "============================================="
echo "============================================="
echo "Compiling optipng"
echo "============================================="
(
emcc \
${OPTIMIZE} \
-Wno-implicit-function-declaration \
-I ${PREFIX}/include \
-I node_modules/optipng/src/opngreduc \
-I node_modules/optipng/src/pngxtern \
-I node_modules/optipng/src/cexcept \
-I node_modules/optipng/src/gifread \
-I node_modules/optipng/src/pnmio \
-I node_modules/optipng/src/minitiff \
--std=c99 -c \
node_modules/optipng/src/opngreduc/*.c \
node_modules/optipng/src/pngxtern/*.c \
node_modules/optipng/src/gifread/*.c \
node_modules/optipng/src/minitiff/*.c \
node_modules/optipng/src/pnmio/*.c \
node_modules/optipng/src/optipng/*.c
emcc \
--bind \
${OPTIMIZE} \
-s ALLOW_MEMORY_GROWTH=1 -s MODULARIZE=1 -s 'EXPORT_NAME="optipng"' \
-I ${PREFIX}/include \
-I node_modules/optipng/src/opngreduc \
-I node_modules/optipng/src/pngxtern \
-I node_modules/optipng/src/cexcept \
-I node_modules/optipng/src/gifread \
-I node_modules/optipng/src/pnmio \
-I node_modules/optipng/src/minitiff \
-o "optipng.js" \
--std=c++11 \
optipng.cpp \
*.o \
${PREFIX}/lib/libz.so ${PREFIX}/lib/libpng.a
)
echo "============================================="
echo "Compiling optipng done"
echo "============================================="
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "Did you update your docker image?"
echo "Run \`docker pull trzeci/emscripten\`"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"

View File

@@ -0,0 +1,19 @@
<!doctype html>
<script src='optipng.js'></script>
<script>
const Module = optipng();
Module.onRuntimeInitialized = async _ => {
console.log('Version:', Module.version().toString(16));
const image = await fetch('../example_palette.png').then(r => r.arrayBuffer());
const newImage = Module.compress(image, {level: 3});
console.log('done');
Module.free_result();
console.log(`Old size: ${image.byteLength}, new size: ${newImage.byteLength} (${newImage.byteLength/image.byteLength*100}%)`);
const blobURL = URL.createObjectURL(new Blob([newImage], {type: 'image/png'}));
const img = document.createElement('img');
img.src = blobURL;
document.body.appendChild(img);
};
</script>

View File

@@ -0,0 +1,53 @@
#include "emscripten/bind.h"
#include "emscripten/val.h"
#include <stdio.h>
using namespace emscripten;
extern "C" int main(int argc, char *argv[]);
int version() {
// FIXME (@surma): Havent found a version in optipng :(
return 0;
}
struct OptiPngOpts {
int level;
};
uint8_t* result;
val compress(std::string png, OptiPngOpts opts) {
remove("input.png");
remove("output.png");
FILE* infile = fopen("input.png", "wb");
fwrite(png.c_str(), png.length(), 1, infile);
fflush(infile);
fclose(infile);
char optlevel[8];
sprintf(&optlevel[0], "-o%d", opts.level);
char* args[] = {"optipng", optlevel, "-out", "output.png", "input.png"};
main(5, args);
FILE *outfile = fopen("output.png", "rb");
fseek(outfile, 0, SEEK_END);
int fsize = ftell(outfile);
result = (uint8_t*) malloc(fsize);
fseek(outfile, 0, SEEK_SET);
fread(result, fsize, 1, outfile);
return val(typed_memory_view(fsize, result));
}
void free_result() {
free(result);
}
EMSCRIPTEN_BINDINGS(my_module) {
value_object<OptiPngOpts>("OptiPngOpts")
.field("level", &OptiPngOpts::level);
function("version", &version);
function("compress", &compress);
function("free_result", &free_result);
}

10
codecs/optipng/optipng.d.ts vendored Normal file
View File

@@ -0,0 +1,10 @@
import {EncodeOptions} from "src/codecs/optipng/encoder";
export interface OptiPngModule extends EmscriptenWasm.Module {
compress(data: BufferSource, opts: EncodeOptions): Uint8Array;
free_result(): void;
}
export default function(opts: EmscriptenWasm.ModuleOpts): OptiPngModule;

24
codecs/optipng/optipng.js Normal file

File diff suppressed because one or more lines are too long

BIN
codecs/optipng/optipng.wasm Normal file

Binary file not shown.

1457
codecs/optipng/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,22 @@
{
"name": "optipng",
"scripts": {
"install": "tar-dependency install && napa",
"build": "npm run build:wasm",
"build:wasm": "docker run --rm -v $(pwd):/src -e SKIP_ZLIB=\"${SKIP_ZLIB}\" -e SKIP_LIBPNG=\"${SKIP_LIBPNG}\" trzeci/emscripten ./build.sh"
},
"tarDependencies": {
"node_modules/optipng": {
"url": "https://netcologne.dl.sourceforge.net/project/optipng/OptiPNG/optipng-0.7.7/optipng-0.7.7.tar.gz",
"strip": 1
}
},
"napa": {
"libpng": "emscripten-ports/libpng",
"zlib": "emscripten-ports/zlib"
},
"dependencies": {
"napa": "^3.0.0",
"tar-dependency": "0.0.3"
}
}

View File

@@ -1 +0,0 @@
/target

496
codecs/oxipng/Cargo.lock generated
View File

@@ -1,496 +0,0 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "adler32"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "567b077b825e468cc974f0020d4082ee6e03132512f207ef1a02fd5d00d1f32d"
[[package]]
name = "autocfg"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d"
[[package]]
name = "bit-vec"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f0dc55f2d8a1a85650ac47858bb001b4c0dd73d79e3c455a842925e68d29cd3"
[[package]]
name = "bitflags"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
[[package]]
name = "build_const"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39092a32794787acd8525ee150305ff051b0aa6cc2abaf193924f5ab05425f39"
[[package]]
name = "bumpalo"
version = "3.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e8c087f005730276d1096a652e92a8bacee2e2472bcc9715a74d2bec38b5820"
[[package]]
name = "bytemuck"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37fa13df2292ecb479ec23aa06f4507928bef07839be9ef15281411076629431"
[[package]]
name = "byteorder"
version = "1.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
[[package]]
name = "cc"
version = "1.0.58"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9a06fb2e53271d7c279ec1efea6ab691c35a2ae67ec0d91d7acec0caf13b518"
[[package]]
name = "cfg-if"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
[[package]]
name = "cloudflare-zlib"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f5ed63a019d55bacd15cadcbcb96bf41b16281417fff393bdb55fa84255fe4b9"
dependencies = [
"cloudflare-zlib-sys",
]
[[package]]
name = "cloudflare-zlib-sys"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e195cb274a0d6ee87e718838a09baecd7cbc9f6075dac256a84cb5842739c06"
dependencies = [
"cc",
]
[[package]]
name = "crc"
version = "1.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d663548de7f5cca343f1e0a48d14dcfb0e9eb4e079ec58883b7251539fa10aeb"
dependencies = [
"build_const",
]
[[package]]
name = "crc32fast"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1"
dependencies = [
"cfg-if",
]
[[package]]
name = "crossbeam-deque"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285"
dependencies = [
"crossbeam-epoch",
"crossbeam-utils",
"maybe-uninit",
]
[[package]]
name = "crossbeam-epoch"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace"
dependencies = [
"autocfg",
"cfg-if",
"crossbeam-utils",
"lazy_static",
"maybe-uninit",
"memoffset",
"scopeguard",
]
[[package]]
name = "crossbeam-queue"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570"
dependencies = [
"cfg-if",
"crossbeam-utils",
"maybe-uninit",
]
[[package]]
name = "crossbeam-utils"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8"
dependencies = [
"autocfg",
"cfg-if",
"lazy_static",
]
[[package]]
name = "deflate"
version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73770f8e1fe7d64df17ca66ad28994a0a623ea497fa69486e14984e715c5d174"
dependencies = [
"adler32",
"byteorder",
]
[[package]]
name = "either"
version = "1.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3"
[[package]]
name = "hermit-abi"
version = "0.1.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3deed196b6e7f9e44a2ae8d94225d80302d81208b1bb673fd21fe634645c85a9"
dependencies = [
"libc",
]
[[package]]
name = "image"
version = "0.23.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2397fc43bd5648b7117aabb3c5e62d0e62c194826ec77b0b4d0c41e62744635"
dependencies = [
"bytemuck",
"byteorder",
"num-iter",
"num-rational",
"num-traits",
"png",
]
[[package]]
name = "indexmap"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c398b2b113b55809ceb9ee3e753fcbac793f1956663f3c36549c1346015c2afe"
dependencies = [
"autocfg",
"rayon",
]
[[package]]
name = "itertools"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b"
dependencies = [
"either",
]
[[package]]
name = "lazy_static"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.72"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9f8082297d534141b30c8d39e9b1773713ab50fdbe4ff30f750d063b3bfd701"
[[package]]
name = "libdeflater"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "66dca08b13369865b2f6dca1dd05f833985cbe6c12a676b04d55f78b85e80246"
dependencies = [
"cc",
]
[[package]]
name = "log"
version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7"
dependencies = [
"cfg-if",
]
[[package]]
name = "maybe-uninit"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00"
[[package]]
name = "memoffset"
version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c198b026e1bbf08a937e94c6c60f9ec4a2267f5b0d2eec9c1b21b061ce2be55f"
dependencies = [
"autocfg",
]
[[package]]
name = "miniz_oxide"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "791daaae1ed6889560f8c4359194f56648355540573244a5448a83ba1ecc7435"
dependencies = [
"adler32",
]
[[package]]
name = "num-integer"
version = "0.1.43"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d59457e662d541ba17869cf51cf177c0b5f0cbf476c66bdc90bf1edac4f875b"
dependencies = [
"autocfg",
"num-traits",
]
[[package]]
name = "num-iter"
version = "0.1.41"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a6e6b7c748f995c4c29c5f5ae0248536e04a5739927c74ec0fa564805094b9f"
dependencies = [
"autocfg",
"num-integer",
"num-traits",
]
[[package]]
name = "num-rational"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a5b4d7360f362cfb50dde8143501e6940b22f644be75a4cc90b2d81968908138"
dependencies = [
"autocfg",
"num-integer",
"num-traits",
]
[[package]]
name = "num-traits"
version = "0.2.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac267bcc07f48ee5f8935ab0d24f316fb722d7a1292e2913f0cc196b29ffd611"
dependencies = [
"autocfg",
]
[[package]]
name = "num_cpus"
version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3"
dependencies = [
"hermit-abi",
"libc",
]
[[package]]
name = "oxipng"
version = "3.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d5fd695858078338d73862ff3755f820eff0bf4f3304e4b52f22aba53463183a"
dependencies = [
"bit-vec",
"byteorder",
"cloudflare-zlib",
"crc",
"image",
"indexmap",
"itertools",
"libdeflater",
"log",
"miniz_oxide",
"rgb",
"zopfli",
]
[[package]]
name = "png"
version = "0.16.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c150bf7479fafe3dd8740dbe48cc33b2a3efb7b0fe3483aced8bbc39f6d0238d"
dependencies = [
"bitflags",
"crc32fast",
"deflate",
"miniz_oxide",
]
[[package]]
name = "proc-macro2"
version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "beae6331a816b1f65d04c45b078fd8e6c93e8071771f41b8163255bbd8d7c8fa"
dependencies = [
"unicode-xid",
]
[[package]]
name = "quote"
version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37"
dependencies = [
"proc-macro2",
]
[[package]]
name = "rayon"
version = "1.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62f02856753d04e03e26929f820d0a0a337ebe71f849801eea335d464b349080"
dependencies = [
"autocfg",
"crossbeam-deque",
"either",
"rayon-core",
]
[[package]]
name = "rayon-core"
version = "1.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e92e15d89083484e11353891f1af602cc661426deb9564c298b270c726973280"
dependencies = [
"crossbeam-deque",
"crossbeam-queue",
"crossbeam-utils",
"lazy_static",
"num_cpus",
]
[[package]]
name = "rgb"
version = "0.8.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90ef54b45ae131327a88597e2463fee4098ad6c88ba7b6af4b3987db8aad4098"
dependencies = [
"bytemuck",
]
[[package]]
name = "scopeguard"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "squoosh-oxipng"
version = "0.1.0"
dependencies = [
"log",
"oxipng",
"wasm-bindgen",
]
[[package]]
name = "syn"
version = "1.0.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "936cae2873c940d92e697597c5eee105fb570cd5689c695806f672883653349b"
dependencies = [
"proc-macro2",
"quote",
"unicode-xid",
]
[[package]]
name = "typed-arena"
version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9b2228007eba4120145f785df0f6c92ea538f5a3635a612ecf4e334c8c1446d"
[[package]]
name = "unicode-xid"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
[[package]]
name = "wasm-bindgen"
version = "0.2.64"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a634620115e4a229108b71bde263bb4220c483b3f07f5ba514ee8d15064c4c2"
dependencies = [
"cfg-if",
"wasm-bindgen-macro",
]
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.64"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e53963b583d18a5aa3aaae4b4c1cb535218246131ba22a71f05b518098571df"
dependencies = [
"bumpalo",
"lazy_static",
"log",
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.64"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fcfd5ef6eec85623b4c6e844293d4516470d8f19cd72d0d12246017eb9060b8"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
]
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.64"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9adff9ee0e94b926ca81b57f57f86d5545cdcb1d259e21ec9bdd95b901754c75"
dependencies = [
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.64"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f7b90ea6c632dd06fd765d44542e234d5e63d9bb917ecd64d79778a13bd79ae"
[[package]]
name = "zopfli"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4079b79464426ade2a1b0177fb0ce8396ba6b4084267407e333573c666073964"
dependencies = [
"adler32",
"byteorder",
"crc",
"typed-arena",
]

View File

@@ -1,18 +0,0 @@
[package]
name = "squoosh-oxipng"
version = "0.1.0"
authors = ["Ingvar Stepanyan <me@rreverser.com>"]
edition = "2018"
publish = false
[lib]
crate-type = ["cdylib"]
[dependencies]
oxipng = { version = "3.0.0", default-features = false }
wasm-bindgen = "0.2.64"
log = { version = "0.4", features = ["release_max_level_off"] }
[profile.release]
lto = true
opt-level = "s"

View File

@@ -1,12 +0,0 @@
FROM rust
RUN rustup target add wasm32-unknown-unknown
RUN curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
RUN mkdir /opt/wabt && \
curl -L https://github.com/WebAssembly/wabt/releases/download/1.0.17/wabt-1.0.17-ubuntu.tar.gz | tar -xzf - -C /opt/wabt --strip 1
RUN mkdir /opt/wasi-sdk && \
curl -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-11/wasi-sdk-11.0-linux.tar.gz | tar -xzf - -C /opt/wasi-sdk --strip 1
ENV PATH="/opt/wabt/bin:/opt/wasi-sdk/bin:${PATH}"
WORKDIR /src

View File

@@ -1,4 +0,0 @@
{
"name": "oxipng",
"lockfileVersion": 1
}

View File

@@ -1,6 +0,0 @@
{
"name": "oxipng",
"scripts": {
"build": "../build-rust.sh"
}
}

View File

@@ -1,15 +0,0 @@
{
"name": "squoosh-oxipng",
"collaborators": [
"Ingvar Stepanyan <me@rreverser.com>"
],
"version": "0.1.0",
"files": [
"squoosh_oxipng_bg.wasm",
"squoosh_oxipng.js",
"squoosh_oxipng.d.ts"
],
"module": "squoosh_oxipng.js",
"types": "squoosh_oxipng.d.ts",
"sideEffects": false
}

View File

@@ -1,8 +0,0 @@
/* tslint:disable */
/* eslint-disable */
/**
* @param {Uint8Array} data
* @param {number} level
* @returns {Uint8Array}
*/
export function optimise(data: Uint8Array, level: number): Uint8Array;

View File

@@ -1,2 +0,0 @@
import * as wasm from "./squoosh_oxipng_bg.wasm";
export * from "./squoosh_oxipng_bg.js";

View File

@@ -1,8 +0,0 @@
/* tslint:disable */
/* eslint-disable */
export const memory: WebAssembly.Memory;
export function optimise(a: number, b: number, c: number, d: number): void;
export function malloc(a: number): number;
export function free(a: number): void;
export function __wbindgen_malloc(a: number): number;
export function __wbindgen_free(a: number, b: number): void;

View File

@@ -1,60 +0,0 @@
import * as wasm from './squoosh_oxipng_bg.wasm';
const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });
cachedTextDecoder.decode();
let cachegetUint8Memory0 = null;
function getUint8Memory0() {
if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) {
cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer);
}
return cachegetUint8Memory0;
}
function getStringFromWasm0(ptr, len) {
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
}
let WASM_VECTOR_LEN = 0;
function passArray8ToWasm0(arg, malloc) {
const ptr = malloc(arg.length * 1);
getUint8Memory0().set(arg, ptr / 1);
WASM_VECTOR_LEN = arg.length;
return ptr;
}
let cachegetInt32Memory0 = null;
function getInt32Memory0() {
if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) {
cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer);
}
return cachegetInt32Memory0;
}
function getArrayU8FromWasm0(ptr, len) {
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
}
/**
* @param {Uint8Array} data
* @param {number} level
* @returns {Uint8Array}
*/
export function optimise(data, level) {
var ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
var len0 = WASM_VECTOR_LEN;
wasm.optimise(8, ptr0, len0, level);
var r0 = getInt32Memory0()[8 / 4 + 0];
var r1 = getInt32Memory0()[8 / 4 + 1];
var v1 = getArrayU8FromWasm0(r0, r1).slice();
wasm.__wbindgen_free(r0, r1 * 1);
return v1;
}
export const __wbindgen_throw = function(arg0, arg1) {
throw new Error(getStringFromWasm0(arg0, arg1));
};

Some files were not shown because too many files have changed in this diff Show More