Compare commits
22 Commits
latest-was
...
hotfix-avi
Author | SHA1 | Date | |
---|---|---|---|
ecc864120e | |||
89d5d8063d | |||
2e8dd1e247 | |||
fc2e658feb | |||
43233e2c55 | |||
2467d0046e | |||
c58c4beb1a | |||
37d778e4da | |||
8f24c9b5ce | |||
9d3401762e | |||
a783de618d | |||
659d2b8277 | |||
934ab9065a | |||
029c2ebb83 | |||
dc40f84a65 | |||
2c0dd363d4 | |||
e6916575b7 | |||
1c7486056d | |||
8e8b75684d | |||
92ade727aa | |||
6117c9dd26 | |||
a3be343959 |
@ -1,13 +1,16 @@
|
||||
CODEC_URL = https://github.com/AOMediaCodec/libavif/archive/31d7c6d1e32cf467ac24fb8c7a76c4902a4c00db.tar.gz
|
||||
CODEC_PACKAGE = node_modules/libavif.tar.gz
|
||||
|
||||
LIBAOM_URL = https://aomedia.googlesource.com/aom/+archive/v2.0.0.tar.gz
|
||||
LIBAOM_URL = https://aomedia.googlesource.com/aom/+archive/4a8e276e3e0ef3c76083f3975d5caa85bc9593ce.tar.gz
|
||||
LIBAOM_PACKAGE = node_modules/libaom.tar.gz
|
||||
|
||||
export CODEC_DIR = node_modules/libavif
|
||||
export BUILD_DIR = node_modules/build
|
||||
export LIBAOM_DIR = node_modules/libaom
|
||||
|
||||
export CFLAGS += -g
|
||||
export CXXFLAGS += -g
|
||||
|
||||
OUT_ENC_JS = enc/avif_enc.js
|
||||
OUT_NODE_ENC_JS = enc/avif_node_enc.js
|
||||
OUT_ENC_MT_JS = enc/avif_enc_mt.js
|
||||
@ -50,7 +53,7 @@ $(OUT_ENC_MT_JS): $(OUT_ENC_CPP) $(CODEC_DIR)/CMakeLists.txt $(LIBAOM_DIR)/CMake
|
||||
" \
|
||||
ENVIRONMENT=$(ENVIRONMENT) \
|
||||
LIBAVIF_FLAGS="-DAVIF_CODEC_AOM_DECODE=0" \
|
||||
OUT_FLAGS="-pthread"
|
||||
OUT_FLAGS="-pthread -s PROXY_TO_PTHREAD=1 -g"
|
||||
|
||||
$(OUT_NODE_DEC_JS): ENVIRONMENT=node
|
||||
$(OUT_NODE_DEC_JS) $(OUT_DEC_JS): $(OUT_DEC_CPP) $(CODEC_DIR)/CMakeLists.txt $(LIBAOM_DIR)/CMakeLists.txt
|
||||
|
2845
codecs/avif/dec/avif_dec.js
generated
2845
codecs/avif/dec/avif_dec.js
generated
File diff suppressed because it is too large
Load Diff
BIN
codecs/avif/dec/avif_dec.wasm
Normal file → Executable file
BIN
codecs/avif/dec/avif_dec.wasm
Normal file → Executable file
Binary file not shown.
2834
codecs/avif/dec/avif_node_dec.js
generated
2834
codecs/avif/dec/avif_node_dec.js
generated
File diff suppressed because it is too large
Load Diff
Binary file not shown.
3064
codecs/avif/enc/avif_enc.js
generated
3064
codecs/avif/enc/avif_enc.js
generated
File diff suppressed because it is too large
Load Diff
BIN
codecs/avif/enc/avif_enc.wasm
Normal file → Executable file
BIN
codecs/avif/enc/avif_enc.wasm
Normal file → Executable file
Binary file not shown.
4073
codecs/avif/enc/avif_enc_mt.js
generated
4073
codecs/avif/enc/avif_enc_mt.js
generated
File diff suppressed because it is too large
Load Diff
BIN
codecs/avif/enc/avif_enc_mt.wasm
Normal file → Executable file
BIN
codecs/avif/enc/avif_enc_mt.wasm
Normal file → Executable file
Binary file not shown.
145
codecs/avif/enc/avif_enc_mt.worker.js
generated
145
codecs/avif/enc/avif_enc_mt.worker.js
generated
@ -1 +1,144 @@
|
||||
var threadInfoStruct=0;var selfThreadId=0;var parentThreadId=0;var initializedJS=false;var Module={};function threadPrintErr(){var text=Array.prototype.slice.call(arguments).join(" ");console.error(text)}function threadAlert(){var text=Array.prototype.slice.call(arguments).join(" ");postMessage({cmd:"alert",text:text,threadId:selfThreadId})}var err=threadPrintErr;this.alert=threadAlert;Module["instantiateWasm"]=function(info,receiveInstance){var instance=new WebAssembly.Instance(Module["wasmModule"],info);Module["wasmModule"]=null;receiveInstance(instance);return instance.exports};this.onmessage=function(e){try{if(e.data.cmd==="load"){Module["wasmModule"]=e.data.wasmModule;Module["wasmMemory"]=e.data.wasmMemory;Module["buffer"]=Module["wasmMemory"].buffer;Module["ENVIRONMENT_IS_PTHREAD"]=true;import(e.data.urlOrBlob).then(function(avif_enc_mt){return avif_enc_mt.default(Module)}).then(function(instance){Module=instance;postMessage({"cmd":"loaded"})})}else if(e.data.cmd==="objectTransfer"){Module["PThread"].receiveObjectTransfer(e.data)}else if(e.data.cmd==="run"){Module["__performance_now_clock_drift"]=performance.now()-e.data.time;threadInfoStruct=e.data.threadInfoStruct;Module["registerPthreadPtr"](threadInfoStruct,/*isMainBrowserThread=*/0,/*isMainRuntimeThread=*/0);selfThreadId=e.data.selfThreadId;parentThreadId=e.data.parentThreadId;var max=e.data.stackBase;var top=e.data.stackBase+e.data.stackSize;Module["establishStackSpace"](top,max);Module["_emscripten_tls_init"]();Module["PThread"].receiveObjectTransfer(e.data);Module["PThread"].setThreadStatus(Module["_pthread_self"](),1);if(!initializedJS){Module["___embind_register_native_and_builtin_types"]();initializedJS=true}try{var result=Module["dynCall"]("ii",e.data.start_routine,[e.data.arg]);if(!Module["getNoExitRuntime"]())Module["PThread"].threadExit(result)}catch(ex){if(ex==="Canceled!"){Module["PThread"].threadCancel()}else if(ex!="unwind"){Atomics.store(Module["HEAPU32"],(threadInfoStruct+4)>>/*C_STRUCTS.pthread.threadExitCode*/2,(ex instanceof Module["ExitStatus"])?ex.status:-2);/*A custom entry specific to Emscripten denoting that the thread crashed.*/Atomics.store(Module["HEAPU32"],(threadInfoStruct+0)>>/*C_STRUCTS.pthread.threadStatus*/2,1);Module["_emscripten_futex_wake"](threadInfoStruct+0,/*C_STRUCTS.pthread.threadStatus*/2147483647);if(!(ex instanceof Module["ExitStatus"]))throw ex}}}else if(e.data.cmd==="cancel"){if(threadInfoStruct){Module["PThread"].threadCancel()}}else if(e.data.target==="setimmediate"){}else if(e.data.cmd==="processThreadQueue"){if(threadInfoStruct){Module["_emscripten_current_thread_process_queued_calls"]()}}else{err("worker.js received unknown command "+e.data.cmd);err(e.data)}}catch(ex){err("worker.js onmessage() captured an uncaught exception: "+ex);if(ex&&ex.stack)err(ex.stack);throw ex}};
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2015 The Emscripten Authors
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
// Pthread Web Worker startup routine:
|
||||
// This is the entry point file that is loaded first by each Web Worker
|
||||
// that executes pthreads on the Emscripten application.
|
||||
|
||||
// Thread-local:
|
||||
var threadInfoStruct = 0; // Info area for this thread in Emscripten HEAP (shared). If zero, this worker is not currently hosting an executing pthread.
|
||||
var selfThreadId = 0; // The ID of this thread. 0 if not hosting a pthread.
|
||||
var parentThreadId = 0; // The ID of the parent pthread that launched this thread.
|
||||
var initializedJS = false; // Guard variable for one-time init of the JS state (currently only embind types registration)
|
||||
|
||||
var Module = {};
|
||||
|
||||
function threadPrintErr() {
|
||||
var text = Array.prototype.slice.call(arguments).join(' ');
|
||||
console.error(text);
|
||||
}
|
||||
function threadAlert() {
|
||||
var text = Array.prototype.slice.call(arguments).join(' ');
|
||||
postMessage({cmd: 'alert', text: text, threadId: selfThreadId});
|
||||
}
|
||||
var err = threadPrintErr;
|
||||
this.alert = threadAlert;
|
||||
|
||||
Module['instantiateWasm'] = function(info, receiveInstance) {
|
||||
// Instantiate from the module posted from the main thread.
|
||||
// We can just use sync instantiation in the worker.
|
||||
var instance = new WebAssembly.Instance(Module['wasmModule'], info);
|
||||
// We don't need the module anymore; new threads will be spawned from the main thread.
|
||||
Module['wasmModule'] = null;
|
||||
receiveInstance(instance); // The second 'module' parameter is intentionally null here, we don't need to keep a ref to the Module object from here.
|
||||
return instance.exports;
|
||||
};
|
||||
|
||||
this.onmessage = function(e) {
|
||||
try {
|
||||
if (e.data.cmd === 'load') { // Preload command that is called once per worker to parse and load the Emscripten code.
|
||||
|
||||
// Module and memory were sent from main thread
|
||||
Module['wasmModule'] = e.data.wasmModule;
|
||||
|
||||
Module['wasmMemory'] = e.data.wasmMemory;
|
||||
|
||||
Module['buffer'] = Module['wasmMemory'].buffer;
|
||||
|
||||
Module['ENVIRONMENT_IS_PTHREAD'] = true;
|
||||
|
||||
import(e.data.urlOrBlob).then(function(avif_enc_mt) {
|
||||
return avif_enc_mt.default(Module);
|
||||
}).then(function(instance) {
|
||||
Module = instance;
|
||||
postMessage({ 'cmd': 'loaded' });
|
||||
});
|
||||
} else if (e.data.cmd === 'objectTransfer') {
|
||||
Module['PThread'].receiveObjectTransfer(e.data);
|
||||
} else if (e.data.cmd === 'run') {
|
||||
// This worker was idle, and now should start executing its pthread entry
|
||||
// point.
|
||||
// performance.now() is specced to return a wallclock time in msecs since
|
||||
// that Web Worker/main thread launched. However for pthreads this can
|
||||
// cause subtle problems in emscripten_get_now() as this essentially
|
||||
// would measure time from pthread_create(), meaning that the clocks
|
||||
// between each threads would be wildly out of sync. Therefore sync all
|
||||
// pthreads to the clock on the main browser thread, so that different
|
||||
// threads see a somewhat coherent clock across each of them
|
||||
// (+/- 0.1msecs in testing).
|
||||
Module['__performance_now_clock_drift'] = performance.now() - e.data.time;
|
||||
threadInfoStruct = e.data.threadInfoStruct;
|
||||
|
||||
// Pass the thread address inside the asm.js scope to store it for fast access that avoids the need for a FFI out.
|
||||
Module['registerPthreadPtr'](threadInfoStruct, /*isMainBrowserThread=*/0, /*isMainRuntimeThread=*/0);
|
||||
|
||||
selfThreadId = e.data.selfThreadId;
|
||||
parentThreadId = e.data.parentThreadId;
|
||||
// Establish the stack frame for this thread in global scope
|
||||
// The stack grows downwards
|
||||
var max = e.data.stackBase;
|
||||
var top = e.data.stackBase + e.data.stackSize;
|
||||
// Also call inside JS module to set up the stack frame for this pthread in JS module scope
|
||||
Module['establishStackSpace'](top, max);
|
||||
Module['_emscripten_tls_init']();
|
||||
|
||||
Module['PThread'].receiveObjectTransfer(e.data);
|
||||
Module['PThread'].setThreadStatus(Module['_pthread_self'](), 1/*EM_THREAD_STATUS_RUNNING*/);
|
||||
|
||||
// Embind must initialize itself on all threads, as it generates support JS.
|
||||
// We only do this once per worker since they get reused
|
||||
if (!initializedJS) {
|
||||
Module['___embind_register_native_and_builtin_types']();
|
||||
initializedJS = true;
|
||||
}
|
||||
|
||||
try {
|
||||
// pthread entry points are always of signature 'void *ThreadMain(void *arg)'
|
||||
// Native codebases sometimes spawn threads with other thread entry point signatures,
|
||||
// such as void ThreadMain(void *arg), void *ThreadMain(), or void ThreadMain().
|
||||
// That is not acceptable per C/C++ specification, but x86 compiler ABI extensions
|
||||
// enable that to work. If you find the following line to crash, either change the signature
|
||||
// to "proper" void *ThreadMain(void *arg) form, or try linking with the Emscripten linker
|
||||
// flag -s EMULATE_FUNCTION_POINTER_CASTS=1 to add in emulation for this x86 ABI extension.
|
||||
var result = Module['dynCall']('ii', e.data.start_routine, [e.data.arg]);
|
||||
|
||||
// The thread might have finished without calling pthread_exit(). If so, then perform the exit operation ourselves.
|
||||
// (This is a no-op if explicit pthread_exit() had been called prior.)
|
||||
if (!Module['getNoExitRuntime']())
|
||||
Module['PThread'].threadExit(result);
|
||||
} catch(ex) {
|
||||
if (ex === 'Canceled!') {
|
||||
Module['PThread'].threadCancel();
|
||||
} else if (ex != 'unwind') {
|
||||
Atomics.store(Module['HEAPU32'], (threadInfoStruct + 4 /*C_STRUCTS.pthread.threadExitCode*/ ) >> 2, (ex instanceof Module['ExitStatus']) ? ex.status : -2 /*A custom entry specific to Emscripten denoting that the thread crashed.*/);
|
||||
|
||||
Atomics.store(Module['HEAPU32'], (threadInfoStruct + 0 /*C_STRUCTS.pthread.threadStatus*/ ) >> 2, 1); // Mark the thread as no longer running.
|
||||
Module['_emscripten_futex_wake'](threadInfoStruct + 0 /*C_STRUCTS.pthread.threadStatus*/, 0x7FFFFFFF/*INT_MAX*/); // Wake all threads waiting on this thread to finish.
|
||||
if (!(ex instanceof Module['ExitStatus'])) throw ex;
|
||||
}
|
||||
}
|
||||
} else if (e.data.cmd === 'cancel') { // Main thread is asking for a pthread_cancel() on this thread.
|
||||
if (threadInfoStruct) {
|
||||
Module['PThread'].threadCancel();
|
||||
}
|
||||
} else if (e.data.target === 'setimmediate') {
|
||||
// no-op
|
||||
} else if (e.data.cmd === 'processThreadQueue') {
|
||||
if (threadInfoStruct) { // If this thread is actually running?
|
||||
Module['_emscripten_current_thread_process_queued_calls']();
|
||||
}
|
||||
} else {
|
||||
err('worker.js received unknown command ' + e.data.cmd);
|
||||
err(e.data);
|
||||
}
|
||||
} catch(ex) {
|
||||
err('worker.js onmessage() captured an uncaught exception: ' + ex);
|
||||
if (ex && ex.stack) err(ex.stack);
|
||||
throw ex;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
3054
codecs/avif/enc/avif_node_enc.js
generated
3054
codecs/avif/enc/avif_node_enc.js
generated
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -32,7 +32,6 @@ $(OUT_JS): $(OUT_CPP) $(LIBAOM_OUT) $(CODEC_OUT)
|
||||
$(LDFLAGS) \
|
||||
$(OUT_FLAGS) \
|
||||
--bind \
|
||||
--closure 1 \
|
||||
-s ALLOW_MEMORY_GROWTH=1 \
|
||||
-s MODULARIZE=1 \
|
||||
-s TEXTDECODER=2 \
|
||||
@ -44,7 +43,7 @@ $(OUT_JS): $(OUT_CPP) $(LIBAOM_OUT) $(CODEC_OUT)
|
||||
|
||||
$(CODEC_OUT): $(CODEC_DIR)/CMakeLists.txt $(LIBAOM_OUT)
|
||||
emcmake cmake \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
|
||||
-DBUILD_SHARED_LIBS=0 \
|
||||
-DAVIF_CODEC_AOM=1 \
|
||||
-DAOM_LIBRARY=$(LIBAOM_OUT) \
|
||||
@ -56,7 +55,7 @@ $(CODEC_OUT): $(CODEC_DIR)/CMakeLists.txt $(LIBAOM_OUT)
|
||||
|
||||
$(LIBAOM_OUT): $(LIBAOM_DIR)/CMakeLists.txt
|
||||
emcmake cmake \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
|
||||
-DENABLE_CCACHE=0 \
|
||||
-DAOM_TARGET_CPU=generic \
|
||||
-DENABLE_DOCS=0 \
|
||||
|
177
codecs/hqx/Cargo.lock
generated
177
codecs/hqx/Cargo.lock
generated
@ -4,286 +4,283 @@
|
||||
name = "bumpalo"
|
||||
version = "3.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2e8c087f005730276d1096a652e92a8bacee2e2472bcc9715a74d2bec38b5820"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
||||
|
||||
[[package]]
|
||||
name = "console_error_panic_hook"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b8d976903543e0c48546a91908f21588a680a8c8f984df9a5d69feccb2b2a211"
|
||||
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)",
|
||||
"cfg-if",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures"
|
||||
version = "0.1.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef"
|
||||
|
||||
[[package]]
|
||||
name = "hqx"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/CryZe/wasmboy-rs?tag=v0.1.2#5f19cda24191ccc7c0c4920b6b246b4e242f377c"
|
||||
source = "git+https://github.com/CryZe/wasmboy-rs?tag=v0.1.3#d7cbae67906796928c8e451b186f3c653924beb8"
|
||||
dependencies = [
|
||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.42"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "52732a3d3ad72c58ad2dc70624f9c17b46ecd0943b9a4f1ee37c4c18c5d983e2"
|
||||
dependencies = [
|
||||
"wasm-bindgen 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[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.73"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bd7d4bd64732af4bf3a67f367c27df8520ad7e230c5817b8ff485864d80242b9"
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b"
|
||||
dependencies = [
|
||||
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memory_units"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "0.4.30"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"
|
||||
dependencies = [
|
||||
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-xid 0.1.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "04f5f085b5d71e2188cb8271e5da0161ad52c3f227a661a3c135fdf28e258b12"
|
||||
dependencies = [
|
||||
"unicode-xid 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-xid 0.2.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "0.6.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1"
|
||||
dependencies = [
|
||||
"proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"proc-macro2 0.4.30",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"proc-macro2 1.0.19",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "scoped-tls"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2"
|
||||
|
||||
[[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)",
|
||||
"cfg-if",
|
||||
"console_error_panic_hook",
|
||||
"hqx",
|
||||
"wasm-bindgen",
|
||||
"wasm-bindgen-test",
|
||||
"wee_alloc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.35"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fb7f4c519df8c117855e19dd8cc851e89eb746fe7a73f0157e0d95fdec5369b0"
|
||||
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)",
|
||||
"proc-macro2 1.0.19",
|
||||
"quote 1.0.7",
|
||||
"unicode-xid 0.2.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-xid"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
|
||||
|
||||
[[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.65"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f3edbcc9536ab7eababcc6d2374a0b7bfe13a2b6d562c5e07f370456b1a8f33d"
|
||||
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)",
|
||||
"cfg-if",
|
||||
"wasm-bindgen-macro",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-backend"
|
||||
version = "0.2.65"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "89ed2fb8c84bfad20ea66b26a3743f3e7ba8735a69fe7d95118c33ec8fc1244d"
|
||||
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)",
|
||||
"bumpalo",
|
||||
"lazy_static",
|
||||
"log",
|
||||
"proc-macro2 1.0.19",
|
||||
"quote 1.0.7",
|
||||
"syn",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-futures"
|
||||
version = "0.3.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "83420b37346c311b9ed822af41ec2e82839bfe99867ec6c54e2da43b7538771c"
|
||||
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)",
|
||||
"cfg-if",
|
||||
"futures",
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
"web-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro"
|
||||
version = "0.2.65"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eb071268b031a64d92fc6cf691715ca5a40950694d8f683c5bb43db7c730929e"
|
||||
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)",
|
||||
"quote 1.0.7",
|
||||
"wasm-bindgen-macro-support",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro-support"
|
||||
version = "0.2.65"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf592c807080719d1ff2f245a687cbadb3ed28b2077ed7084b47aba8b691f2c6"
|
||||
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)",
|
||||
"proc-macro2 1.0.19",
|
||||
"quote 1.0.7",
|
||||
"syn",
|
||||
"wasm-bindgen-backend",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-shared"
|
||||
version = "0.2.65"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72b6c0220ded549d63860c78c38f3bcc558d1ca3f4efa74942c536ddbbb55e87"
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-test"
|
||||
version = "0.2.50"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a2d9693b63a742d481c7f80587e057920e568317b2806988c59cd71618bc26c1"
|
||||
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)",
|
||||
"console_error_panic_hook",
|
||||
"futures",
|
||||
"js-sys",
|
||||
"scoped-tls",
|
||||
"wasm-bindgen",
|
||||
"wasm-bindgen-futures",
|
||||
"wasm-bindgen-test-macro",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-test-macro"
|
||||
version = "0.2.50"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0789dac148a8840bbcf9efe13905463b733fa96543bfbf263790535c11af7ba5"
|
||||
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)",
|
||||
"proc-macro2 0.4.30",
|
||||
"quote 0.6.13",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "web-sys"
|
||||
version = "0.3.42"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8be2398f326b7ba09815d0b403095f34dd708579220d099caae89be0b32137b2"
|
||||
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)",
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wee_alloc"
|
||||
version = "0.4.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dbb3b5a6b2bb17cb6ad44a2e68a43e8d2722c997da10e928665c72ec6c0a0b8e"
|
||||
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)",
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"memory_units",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||
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)",
|
||||
"winapi-i686-pc-windows-gnu",
|
||||
"winapi-x86_64-pc-windows-gnu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[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"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
@ -13,7 +13,7 @@ default = ["console_error_panic_hook", "wee_alloc"]
|
||||
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"}
|
||||
hqx = {git = "https://github.com/CryZe/wasmboy-rs", tag="v0.1.3"}
|
||||
|
||||
# The `console_error_panic_hook` crate provides better debugging of panics by
|
||||
# logging them with `console.error`. This is great for development, but requires
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hqx",
|
||||
"scripts": {
|
||||
"build": "RUST_IMG=rust:1.40 ../build-rust.sh"
|
||||
"build": "../build-rust.sh"
|
||||
}
|
||||
}
|
||||
|
28
codecs/hqx/pkg/squooshhqx.d.ts
generated
vendored
28
codecs/hqx/pkg/squooshhqx.d.ts
generated
vendored
@ -7,30 +7,14 @@
|
||||
* @param {number} factor
|
||||
* @returns {Uint32Array}
|
||||
*/
|
||||
export function resize(
|
||||
input_image: Uint32Array,
|
||||
input_width: number,
|
||||
input_height: number,
|
||||
factor: number,
|
||||
): Uint32Array;
|
||||
export function resize(input_image: Uint32Array, input_width: number, input_height: number, factor: number): Uint32Array;
|
||||
|
||||
export type InitInput =
|
||||
| RequestInfo
|
||||
| URL
|
||||
| Response
|
||||
| BufferSource
|
||||
| WebAssembly.Module;
|
||||
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
||||
|
||||
export interface InitOutput {
|
||||
readonly memory: WebAssembly.Memory;
|
||||
readonly resize: (
|
||||
a: number,
|
||||
b: number,
|
||||
c: number,
|
||||
d: number,
|
||||
e: number,
|
||||
f: number,
|
||||
) => void;
|
||||
readonly resize: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
||||
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
||||
readonly __wbindgen_malloc: (a: number) => number;
|
||||
readonly __wbindgen_free: (a: number, b: number) => void;
|
||||
}
|
||||
@ -43,6 +27,4 @@ export interface InitOutput {
|
||||
*
|
||||
* @returns {Promise<InitOutput>}
|
||||
*/
|
||||
export default function init(
|
||||
module_or_path?: InitInput | Promise<InitInput>,
|
||||
): Promise<InitOutput>;
|
||||
export default function init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;
|
||||
|
43
codecs/hqx/pkg/squooshhqx.js
generated
43
codecs/hqx/pkg/squooshhqx.js
generated
@ -1,11 +1,9 @@
|
||||
|
||||
let wasm;
|
||||
|
||||
let cachegetUint32Memory0 = null;
|
||||
function getUint32Memory0() {
|
||||
if (
|
||||
cachegetUint32Memory0 === null ||
|
||||
cachegetUint32Memory0.buffer !== wasm.memory.buffer
|
||||
) {
|
||||
if (cachegetUint32Memory0 === null || cachegetUint32Memory0.buffer !== wasm.memory.buffer) {
|
||||
cachegetUint32Memory0 = new Uint32Array(wasm.memory.buffer);
|
||||
}
|
||||
return cachegetUint32Memory0;
|
||||
@ -22,10 +20,7 @@ function passArray32ToWasm0(arg, malloc) {
|
||||
|
||||
let cachegetInt32Memory0 = null;
|
||||
function getInt32Memory0() {
|
||||
if (
|
||||
cachegetInt32Memory0 === null ||
|
||||
cachegetInt32Memory0.buffer !== wasm.memory.buffer
|
||||
) {
|
||||
if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) {
|
||||
cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
||||
}
|
||||
return cachegetInt32Memory0;
|
||||
@ -42,27 +37,32 @@ function getArrayU32FromWasm0(ptr, len) {
|
||||
* @returns {Uint32Array}
|
||||
*/
|
||||
export function resize(input_image, input_width, input_height, factor) {
|
||||
try {
|
||||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
||||
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];
|
||||
wasm.resize(retptr, ptr0, len0, input_width, input_height, factor);
|
||||
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
||||
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
||||
var v1 = getArrayU32FromWasm0(r0, r1).slice();
|
||||
wasm.__wbindgen_free(r0, r1 * 4);
|
||||
return v1;
|
||||
} finally {
|
||||
wasm.__wbindgen_add_to_stack_pointer(16);
|
||||
}
|
||||
}
|
||||
|
||||
async function load(module, imports) {
|
||||
if (typeof Response === 'function' && module instanceof Response) {
|
||||
|
||||
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
||||
try {
|
||||
return await WebAssembly.instantiateStreaming(module, imports);
|
||||
|
||||
} catch (e) {
|
||||
if (module.headers.get('Content-Type') != 'application/wasm') {
|
||||
console.warn(
|
||||
'`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n',
|
||||
e,
|
||||
);
|
||||
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
||||
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
@ -71,11 +71,14 @@ async function load(module, imports) {
|
||||
|
||||
const bytes = await module.arrayBuffer();
|
||||
return await WebAssembly.instantiate(bytes, imports);
|
||||
|
||||
} else {
|
||||
|
||||
const instance = await WebAssembly.instantiate(module, imports);
|
||||
|
||||
if (instance instanceof WebAssembly.Instance) {
|
||||
return { instance, module };
|
||||
|
||||
} else {
|
||||
return instance;
|
||||
}
|
||||
@ -84,15 +87,12 @@ async function load(module, imports) {
|
||||
|
||||
async function init(input) {
|
||||
if (typeof input === 'undefined') {
|
||||
input = import.meta.url.replace(/\.js$/, '_bg.wasm');
|
||||
input = new URL('squooshhqx_bg.wasm', import.meta.url);
|
||||
}
|
||||
const imports = {};
|
||||
|
||||
if (
|
||||
typeof input === 'string' ||
|
||||
(typeof Request === 'function' && input instanceof Request) ||
|
||||
(typeof URL === 'function' && input instanceof URL)
|
||||
) {
|
||||
|
||||
if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
|
||||
input = fetch(input);
|
||||
}
|
||||
|
||||
@ -105,3 +105,4 @@ async function init(input) {
|
||||
}
|
||||
|
||||
export default init;
|
||||
|
||||
|
6
codecs/hqx/pkg/squooshhqx_bg.d.ts
generated
vendored
6
codecs/hqx/pkg/squooshhqx_bg.d.ts
generated
vendored
@ -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;
|
Binary file not shown.
@ -8,7 +8,7 @@ ENVIRONMENT = worker
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
all: $(OUT_JS) $(OUT_NODE_JS)
|
||||
all: $(OUT_JS)
|
||||
|
||||
imagequant_node.js: ENVIRONMENT=node
|
||||
$(OUT_JS): $(CODEC_OUT)
|
||||
@ -27,21 +27,6 @@ $(OUT_JS): $(CODEC_OUT)
|
||||
$+ \
|
||||
imagequant.cpp
|
||||
|
||||
$(CXX) \
|
||||
-I $(CODEC_DIR) \
|
||||
${CXXFLAGS} \
|
||||
${LDFLAGS} \
|
||||
--bind \
|
||||
--closure 1 \
|
||||
-s ALLOW_MEMORY_GROWTH=1 \
|
||||
-s MODULARIZE=1 \
|
||||
-s TEXTDECODER=2 \
|
||||
-s ENVIRONMENT='node' \
|
||||
-s EXPORT_ES6=1 \
|
||||
-o $@ \
|
||||
$+ \
|
||||
imagequant.cpp
|
||||
|
||||
$(CODEC_OUT): $(CODEC_DIR)/config.mk
|
||||
$(MAKE) -C $(CODEC_DIR) $(CODEC_OUT_RELATIVE)
|
||||
|
||||
|
81
codecs/imagequant/imagequant.js
generated
81
codecs/imagequant/imagequant.js
generated
@ -7,46 +7,47 @@ function(Module) {
|
||||
Module = Module || {};
|
||||
|
||||
|
||||
var e;e||(e=typeof Module !== 'undefined' ? Module : {});var aa,r;e.ready=new Promise(function(a,b){aa=a;r=b});var t={},u;for(u in e)e.hasOwnProperty(u)&&(t[u]=e[u]);var v="",ba,ca,da,ea;v=__dirname+"/";ba=function(a){da||(da=require("fs"));ea||(ea=require("path"));a=ea.normalize(a);return da.readFileSync(a,null)};ca=function(a){a=ba(a);a.buffer||(a=new Uint8Array(a));a.buffer||w("Assertion failed: undefined");return a};1<process.argv.length&&process.argv[1].replace(/\\/g,"/");process.argv.slice(2);
|
||||
process.on("uncaughtException",function(a){throw a;});process.on("unhandledRejection",w);e.inspect=function(){return"[Emscripten Module object]"};var fa=e.print||console.log.bind(console),y=e.printErr||console.warn.bind(console);for(u in t)t.hasOwnProperty(u)&&(e[u]=t[u]);t=null;var z;e.wasmBinary&&(z=e.wasmBinary);var noExitRuntime;e.noExitRuntime&&(noExitRuntime=e.noExitRuntime);"object"!==typeof WebAssembly&&w("no native wasm support detected");var A,ha=!1,ia=new TextDecoder("utf8");
|
||||
function ja(a,b,c){var d=C;if(0<c){c=b+c-1;for(var f=0;f<a.length;++f){var g=a.charCodeAt(f);if(55296<=g&&57343>=g){var l=a.charCodeAt(++f);g=65536+((g&1023)<<10)|l&1023}if(127>=g){if(b>=c)break;d[b++]=g}else{if(2047>=g){if(b+1>=c)break;d[b++]=192|g>>6}else{if(65535>=g){if(b+2>=c)break;d[b++]=224|g>>12}else{if(b+3>=c)break;d[b++]=240|g>>18;d[b++]=128|g>>12&63}d[b++]=128|g>>6&63}d[b++]=128|g&63}}d[b]=0}}var ka=new TextDecoder("utf-16le");
|
||||
function la(a,b){var c=a>>1;for(b=c+b/2;!(c>=b)&&D[c];)++c;return ka.decode(C.subarray(a,c<<1))}function ma(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)E[b>>1]=a.charCodeAt(f),b+=2;E[b>>1]=0;return b-d}function na(a){return 2*a.length}function oa(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 pa(a,b,c){void 0===c&&(c=2147483647);if(4>c)return 0;var d=b;c=d+c-4;for(var f=0;f<a.length;++f){var g=a.charCodeAt(f);if(55296<=g&&57343>=g){var l=a.charCodeAt(++f);g=65536+((g&1023)<<10)|l&1023}F[b>>2]=g;b+=4;if(b+4>c)break}F[b>>2]=0;return b-d}function qa(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,ra,C,E,D,F,I,sa,ta;
|
||||
function ua(a){G=a;e.HEAP8=ra=new Int8Array(a);e.HEAP16=E=new Int16Array(a);e.HEAP32=F=new Int32Array(a);e.HEAPU8=C=new Uint8Array(a);e.HEAPU16=D=new Uint16Array(a);e.HEAPU32=I=new Uint32Array(a);e.HEAPF32=sa=new Float32Array(a);e.HEAPF64=ta=new Float64Array(a)}var va=e.INITIAL_MEMORY||16777216;e.wasmMemory?A=e.wasmMemory:A=new WebAssembly.Memory({initial:va/65536,maximum:32768});A&&(G=A.buffer);va=G.byteLength;ua(G);var J,wa=[],xa=[],ya=[],za=[];
|
||||
function Aa(){var a=e.preRun.shift();wa.unshift(a)}var K=0,Ba=null,M=null;e.preloadedImages={};e.preloadedAudios={};function w(a){if(e.onAbort)e.onAbort(a);y(a);ha=!0;a=new WebAssembly.RuntimeError("abort("+a+"). Build with -s ASSERTIONS=1 for more info.");r(a);throw a;}function Ca(){var a=N;return String.prototype.startsWith?a.startsWith("data:application/octet-stream;base64,"):0===a.indexOf("data:application/octet-stream;base64,")}var N="imagequant.wasm";
|
||||
if(!Ca()){var Da=N;N=e.locateFile?e.locateFile(Da,v):v+Da}function Ea(){try{if(z)return new Uint8Array(z);if(ca)return ca(N);throw"both async and sync fetching of the wasm failed";}catch(a){w(a)}}function O(a){for(;0<a.length;){var b=a.shift();if("function"==typeof b)b(e);else{var c=b.J;"number"===typeof c?void 0===b.G?J.get(c)():J.get(c)(b.G):c(void 0===b.G?null:b.G)}}}
|
||||
function Fa(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 Ga=void 0;function P(a){for(var b="";C[a];)b+=Ga[C[a++]];return b}var Q={},R={},S={};function Ha(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 Ia(a,b){a=Ha(a);return(new Function("body","return function "+a+'() {\n "use strict"; return body.apply(this, arguments);\n};\n'))(b)}function Ja(a){var b=Error,c=Ia(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 Ka=void 0;function T(a){throw new Ka(a);}var La=void 0;function Ma(a,b){function c(h){h=b(h);if(h.length!==d.length)throw new La("Mismatched type converter count");for(var k=0;k<d.length;++k)U(d[k],h[k])}var d=[];d.forEach(function(h){S[h]=a});var f=Array(a.length),g=[],l=0;a.forEach(function(h,k){R.hasOwnProperty(h)?f[k]=R[h]:(g.push(h),Q.hasOwnProperty(h)||(Q[h]=[]),Q[h].push(function(){f[k]=R[h];++l;l===g.length&&c(f)}))});0===g.length&&c(f)}
|
||||
function U(a,b,c){c=c||{};if(!("argPackAdvance"in b))throw new TypeError("registerType registeredInstance requires argPackAdvance");var d=b.name;a||T('type "'+d+'" must have a positive integer typeid pointer');if(R.hasOwnProperty(a)){if(c.K)return;T("Cannot register type '"+d+"' twice")}R[a]=b;delete S[a];Q.hasOwnProperty(a)&&(b=Q[a],delete Q[a],b.forEach(function(f){f()}))}var Pa=[],V=[{},{value:void 0},{value:null},{value:!0},{value:!1}];
|
||||
function Qa(a){4<a&&0===--V[a].H&&(V[a]=void 0,Pa.push(a))}function W(a){switch(a){case void 0:return 1;case null:return 2;case !0:return 3;case !1:return 4;default:var b=Pa.length?Pa.pop():V.length;V[b]={H:1,value:a};return b}}function Ra(a){return this.fromWireType(I[a>>2])}function Sa(a){if(null===a)return"null";var b=typeof a;return"object"===b||"array"===b||"function"===b?a.toString():""+a}
|
||||
function Ta(a,b){switch(b){case 2:return function(c){return this.fromWireType(sa[c>>2])};case 3:return function(c){return this.fromWireType(ta[c>>3])};default:throw new TypeError("Unknown float type: "+a);}}function Ua(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=Ia(b.name||"unknownFunctionName",function(){});c.prototype=b.prototype;c=new c;a=b.apply(c,a);return a instanceof Object?a:c}
|
||||
function Va(a){for(;a.length;){var b=a.pop();a.pop()(b)}}function Wa(a,b){var c=e;if(void 0===c[a].D){var d=c[a];c[a]=function(){c[a].D.hasOwnProperty(arguments.length)||T("Function '"+b+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+c[a].D+")!");return c[a].D[arguments.length].apply(this,arguments)};c[a].D=[];c[a].D[d.I]=d}}
|
||||
function Xa(a,b,c){e.hasOwnProperty(a)?((void 0===c||void 0!==e[a].D&&void 0!==e[a].D[c])&&T("Cannot register public name '"+a+"' twice"),Wa(a,a),e.hasOwnProperty(c)&&T("Cannot register multiple overloads of a function with the same number of arguments ("+c+")!"),e[a].D[c]=b):(e[a]=b,void 0!==c&&(e[a].M=c))}function Ya(a,b){for(var c=[],d=0;d<a;d++)c.push(F[(b>>2)+d]);return c}
|
||||
function Za(a,b){0<=a.indexOf("j")||w("Assertion failed: getDynCaller should only be called with i64 sigs");var c=[];return function(){c.length=arguments.length;for(var d=0;d<arguments.length;d++)c[d]=arguments[d];var f;-1!=a.indexOf("j")?f=c&&c.length?e["dynCall_"+a].apply(null,[b].concat(c)):e["dynCall_"+a].call(null,b):f=J.get(b).apply(null,c);return f}}
|
||||
function $a(a,b){a=P(a);var c=-1!=a.indexOf("j")?Za(a,b):J.get(b);"function"!==typeof c&&T("unknown function pointer with signature "+a+": "+b);return c}var ab=void 0;function bb(a){a=cb(a);var b=P(a);X(a);return b}function db(a,b){function c(g){f[g]||R[g]||(S[g]?S[g].forEach(c):(d.push(g),f[g]=!0))}var d=[],f={};b.forEach(c);throw new ab(a+": "+d.map(bb).join([", "]));}
|
||||
function eb(a,b,c){switch(b){case 0:return c?function(d){return ra[d]}:function(d){return C[d]};case 1:return c?function(d){return E[d>>1]}:function(d){return D[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 fb={};function gb(){return"object"===typeof globalThis?globalThis:Function("return this")()}function hb(a,b){var c=R[a];void 0===c&&T(b+" has unknown type "+bb(a));return c}
|
||||
for(var ib={},jb=[null,[],[]],kb=Array(256),Y=0;256>Y;++Y)kb[Y]=String.fromCharCode(Y);Ga=kb;Ka=e.BindingError=Ja("BindingError");La=e.InternalError=Ja("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};ab=e.UnboundTypeError=Ja("UnboundTypeError");xa.push({J:function(){lb()}});
|
||||
var nb={o:function(){},p:function(a,b,c,d,f){var g=Fa(c);b=P(b);U(a,{name:b,fromWireType:function(l){return!!l},toWireType:function(l,h){return h?d:f},argPackAdvance:8,readValueFromPointer:function(l){if(1===c)var h=ra;else if(2===c)h=E;else if(4===c)h=F;else throw new TypeError("Unknown boolean type size: "+b);return this.fromWireType(h[l>>g])},F:null})},v:function(a,b){b=P(b);U(a,{name:b,fromWireType:function(c){var d=V[c].value;Qa(c);return d},toWireType:function(c,d){return W(d)},argPackAdvance:8,
|
||||
readValueFromPointer:Ra,F:null})},n:function(a,b,c){c=Fa(c);b=P(b);U(a,{name:b,fromWireType:function(d){return d},toWireType:function(d,f){if("number"!==typeof f&&"boolean"!==typeof f)throw new TypeError('Cannot convert "'+Sa(f)+'" to '+this.name);return f},argPackAdvance:8,readValueFromPointer:Ta(b,c),F:null})},e:function(a,b,c,d,f,g){var l=Ya(b,c);a=P(a);f=$a(d,f);Xa(a,function(){db("Cannot call "+a+" due to unbound types",l)},b-1);Ma(l,function(h){var k=[h[0],null].concat(h.slice(1)),m=h=a,n=f,
|
||||
p=k.length;2>p&&T("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var x=null!==k[1]&&!1,B=!1,q=1;q<k.length;++q)if(null!==k[q]&&void 0===k[q].F){B=!0;break}var Na="void"!==k[0].name,H="",L="";for(q=0;q<p-2;++q)H+=(0!==q?", ":"")+"arg"+q,L+=(0!==q?", ":"")+"arg"+q+"Wired";m="return function "+Ha(m)+"("+H+") {\nif (arguments.length !== "+(p-2)+") {\nthrowBindingError('function "+m+" called with ' + arguments.length + ' arguments, expected "+(p-2)+" args!');\n}\n";
|
||||
B&&(m+="var destructors = [];\n");var Oa=B?"destructors":"null";H="throwBindingError invoker fn runDestructors retType classParam".split(" ");n=[T,n,g,Va,k[0],k[1]];x&&(m+="var thisWired = classParam.toWireType("+Oa+", this);\n");for(q=0;q<p-2;++q)m+="var arg"+q+"Wired = argType"+q+".toWireType("+Oa+", arg"+q+"); // "+k[q+2].name+"\n",H.push("argType"+q),n.push(k[q+2]);x&&(L="thisWired"+(0<L.length?", ":"")+L);m+=(Na?"var rv = ":"")+"invoker(fn"+(0<L.length?", ":"")+L+");\n";if(B)m+="runDestructors(destructors);\n";
|
||||
else for(q=x?1:2;q<k.length;++q)p=1===q?"thisWired":"arg"+(q-2)+"Wired",null!==k[q].F&&(m+=p+"_dtor("+p+"); // "+k[q].name+"\n",H.push(p+"_dtor"),n.push(k[q].F));Na&&(m+="var ret = retType.fromWireType(rv);\nreturn ret;\n");H.push(m+"}\n");k=Ua(H).apply(null,n);q=b-1;if(!e.hasOwnProperty(h))throw new La("Replacing nonexistant public symbol");void 0!==e[h].D&&void 0!==q?e[h].D[q]=k:(e[h]=k,e[h].I=q);return[]})},c:function(a,b,c,d,f){function g(m){return m}b=P(b);-1===f&&(f=4294967295);var l=Fa(c);
|
||||
if(0===d){var h=32-8*c;g=function(m){return m<<h>>>h}}var k=-1!=b.indexOf("unsigned");U(a,{name:b,fromWireType:g,toWireType:function(m,n){if("number"!==typeof n&&"boolean"!==typeof n)throw new TypeError('Cannot convert "'+Sa(n)+'" to '+this.name);if(n<d||n>f)throw new TypeError('Passing a number "'+Sa(n)+'" from JS side to C/C++ side to an argument of type "'+b+'", which is outside the valid range ['+d+", "+f+"]!");return k?n>>>0:n|0},argPackAdvance:8,readValueFromPointer:eb(b,l,0!==d),F:null})},
|
||||
b:function(a,b,c){function d(g){g>>=2;var l=I;return new f(G,l[g+1],l[g])}var f=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][b];c=P(c);U(a,{name:c,fromWireType:d,argPackAdvance:8,readValueFromPointer:d},{K:!0})},i:function(a,b){b=P(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,l=0;l<=f;++l){var h=d+4+l;if(l==f||0==C[h]){if(g){for(var k=g+(h-g),m=g;!(m>=k)&&C[m];)++m;g=ia.decode(C.subarray(g,m))}else g=
|
||||
"";if(void 0===n)var n=g;else n+=String.fromCharCode(0),n+=g;g=h+1}}else{n=Array(f);for(l=0;l<f;++l)n[l]=String.fromCharCode(C[d+4+l]);n=n.join("")}X(d);return n},toWireType:function(d,f){f instanceof ArrayBuffer&&(f=new Uint8Array(f));var g="string"===typeof f;g||f instanceof Uint8Array||f instanceof Uint8ClampedArray||f instanceof Int8Array||T("Cannot pass non-string to std::string");var l=(c&&g?function(){for(var m=0,n=0;n<f.length;++n){var p=f.charCodeAt(n);55296<=p&&57343>=p&&(p=65536+((p&1023)<<
|
||||
10)|f.charCodeAt(++n)&1023);127>=p?++m:m=2047>=p?m+2:65535>=p?m+3:m+4}return m}:function(){return f.length})(),h=mb(4+l+1);I[h>>2]=l;if(c&&g)ja(f,h+4,l+1);else if(g)for(g=0;g<l;++g){var k=f.charCodeAt(g);255<k&&(X(h),T("String has UTF-16 code units that do not fit in 8 bits"));C[h+4+g]=k}else for(g=0;g<l;++g)C[h+4+g]=f[g];null!==d&&d.push(X,h);return h},argPackAdvance:8,readValueFromPointer:Ra,F:function(d){X(d)}})},g:function(a,b,c){c=P(c);if(2===b){var d=la;var f=ma;var g=na;var l=function(){return D};
|
||||
var h=1}else 4===b&&(d=oa,f=pa,g=qa,l=function(){return I},h=2);U(a,{name:c,fromWireType:function(k){for(var m=I[k>>2],n=l(),p,x=k+4,B=0;B<=m;++B){var q=k+4+B*b;if(B==m||0==n[q>>h])x=d(x,q-x),void 0===p?p=x:(p+=String.fromCharCode(0),p+=x),x=q+b}X(k);return p},toWireType:function(k,m){"string"!==typeof m&&T("Cannot pass non-string to C++ string type "+c);var n=g(m),p=mb(4+n+b);I[p>>2]=n>>h;f(m,p+4,n+b);null!==k&&k.push(X,p);return p},argPackAdvance:8,readValueFromPointer:Ra,F:function(k){X(k)}})},
|
||||
q:function(a,b){b=P(b);U(a,{L:!0,name:b,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},f:Qa,l:function(a){if(0===a)return W(gb());var b=fb[a];a=void 0===b?P(a):b;return W(gb()[a])},j:function(a){4<a&&(V[a].H+=1)},k:function(a,b,c,d){a||T("Cannot use deleted val. handle = "+a);a=V[a].value;var f=ib[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")))(hb,e,W);ib[b]=f}return f(a,c,d)},h:function(){w()},t:function(a,b,c){C.copyWithin(a,b,b+c)},d: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);ua(A.buffer);var f=1;break a}catch(g){}f=void 0}if(f)return!0}return!1},u:function(){return 0},r:function(){},m:function(a,b,c,d){for(var f=0,g=0;g<c;g++){for(var l=F[b+8*g>>2],h=F[b+(8*g+4)>>2],k=0;k<h;k++){var m=C[l+k],n=jb[a];if(0===m||10===m){m=1===a?fa:y;var p;for(p=0;n[p]&&!(NaN<=p);)++p;p=ia.decode(n.subarray?n.subarray(0,p):new Uint8Array(n.slice(0,p)));m(p);n.length=0}else n.push(m)}f+=h}F[d>>
|
||||
2]=f;return 0},a:A,s:function(){}};
|
||||
(function(){function a(f){e.asm=f.exports;J=e.asm.w;K--;e.monitorRunDependencies&&e.monitorRunDependencies(K);0==K&&(null!==Ba&&(clearInterval(Ba),Ba=null),M&&(f=M,M=null,f()))}function b(f){a(f.instance)}function c(f){return Promise.resolve().then(Ea).then(function(g){return WebAssembly.instantiate(g,d)}).then(f,function(g){y("failed to asynchronously prepare wasm: "+g);w(g)})}var d={a:nb};K++;e.monitorRunDependencies&&e.monitorRunDependencies(K);if(e.instantiateWasm)try{return e.instantiateWasm(d,a)}catch(f){return y("Module.instantiateWasm callback failed with error: "+
|
||||
f),!1}(function(){return z||"function"!==typeof WebAssembly.instantiateStreaming||Ca()||"function"!==typeof fetch?c(b):fetch(N,{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)})})})().catch(r);return{}})();
|
||||
var lb=e.___wasm_call_ctors=function(){return(lb=e.___wasm_call_ctors=e.asm.x).apply(null,arguments)},mb=e._malloc=function(){return(mb=e._malloc=e.asm.y).apply(null,arguments)},X=e._free=function(){return(X=e._free=e.asm.z).apply(null,arguments)},cb=e.___getTypeName=function(){return(cb=e.___getTypeName=e.asm.A).apply(null,arguments)};e.___embind_register_native_and_builtin_types=function(){return(e.___embind_register_native_and_builtin_types=e.asm.B).apply(null,arguments)};
|
||||
e.dynCall_jiji=function(){return(e.dynCall_jiji=e.asm.C).apply(null,arguments)};var Z;M=function ob(){Z||pb();Z||(M=ob)};
|
||||
function pb(){function a(){if(!Z&&(Z=!0,e.calledRun=!0,!ha)){O(xa);O(ya);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();za.unshift(b)}O(za)}}if(!(0<K)){if(e.preRun)for("function"==typeof e.preRun&&(e.preRun=[e.preRun]);e.preRun.length;)Aa();O(wa);0<K||(e.setStatus?(e.setStatus("Running..."),setTimeout(function(){setTimeout(function(){e.setStatus("")},1);a()},1)):a())}}
|
||||
e.run=pb;if(e.preInit)for("function"==typeof e.preInit&&(e.preInit=[e.preInit]);0<e.preInit.length;)e.preInit.pop()();noExitRuntime=!0;pb();
|
||||
var e;e||(e=typeof Module !== 'undefined' ? Module : {});var aa,r;e.ready=new Promise(function(a,b){aa=a;r=b});var t={},u;for(u in e)e.hasOwnProperty(u)&&(t[u]=e[u]);var v="",ba;v=self.location.href;_scriptDir&&(v=_scriptDir);0!==v.indexOf("blob:")?v=v.substr(0,v.lastIndexOf("/")+1):v="";ba=function(a){var b=new XMLHttpRequest;b.open("GET",a,!1);b.responseType="arraybuffer";b.send(null);return new Uint8Array(b.response)};var ca=e.print||console.log.bind(console),w=e.printErr||console.warn.bind(console);
|
||||
for(u in t)t.hasOwnProperty(u)&&(e[u]=t[u]);t=null;var y;e.wasmBinary&&(y=e.wasmBinary);var noExitRuntime;e.noExitRuntime&&(noExitRuntime=e.noExitRuntime);"object"!==typeof WebAssembly&&z("no native wasm support detected");var A,da=!1,ea=new TextDecoder("utf8");
|
||||
function fa(a,b,c){var d=B;if(0<c){c=b+c-1;for(var f=0;f<a.length;++f){var g=a.charCodeAt(f);if(55296<=g&&57343>=g){var l=a.charCodeAt(++f);g=65536+((g&1023)<<10)|l&1023}if(127>=g){if(b>=c)break;d[b++]=g}else{if(2047>=g){if(b+1>=c)break;d[b++]=192|g>>6}else{if(65535>=g){if(b+2>=c)break;d[b++]=224|g>>12}else{if(b+3>=c)break;d[b++]=240|g>>18;d[b++]=128|g>>12&63}d[b++]=128|g>>6&63}d[b++]=128|g&63}}d[b]=0}}var ha=new TextDecoder("utf-16le");
|
||||
function ia(a,b){var c=a>>1;for(b=c+b/2;!(c>=b)&&D[c];)++c;return ha.decode(B.subarray(a,c<<1))}function ja(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)E[b>>1]=a.charCodeAt(f),b+=2;E[b>>1]=0;return b-d}function ka(a){return 2*a.length}function la(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 ma(a,b,c){void 0===c&&(c=2147483647);if(4>c)return 0;var d=b;c=d+c-4;for(var f=0;f<a.length;++f){var g=a.charCodeAt(f);if(55296<=g&&57343>=g){var l=a.charCodeAt(++f);g=65536+((g&1023)<<10)|l&1023}F[b>>2]=g;b+=4;if(b+4>c)break}F[b>>2]=0;return b-d}function na(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,oa,B,E,D,F,H,pa,qa;
|
||||
function ra(a){G=a;e.HEAP8=oa=new Int8Array(a);e.HEAP16=E=new Int16Array(a);e.HEAP32=F=new Int32Array(a);e.HEAPU8=B=new Uint8Array(a);e.HEAPU16=D=new Uint16Array(a);e.HEAPU32=H=new Uint32Array(a);e.HEAPF32=pa=new Float32Array(a);e.HEAPF64=qa=new Float64Array(a)}var sa=e.INITIAL_MEMORY||16777216;e.wasmMemory?A=e.wasmMemory:A=new WebAssembly.Memory({initial:sa/65536,maximum:32768});A&&(G=A.buffer);sa=G.byteLength;ra(G);var J,ta=[],ua=[],va=[],wa=[];
|
||||
function xa(){var a=e.preRun.shift();ta.unshift(a)}var K=0,ya=null,L=null;e.preloadedImages={};e.preloadedAudios={};function z(a){if(e.onAbort)e.onAbort(a);w(a);da=!0;a=new WebAssembly.RuntimeError("abort("+a+"). Build with -s ASSERTIONS=1 for more info.");r(a);throw a;}function za(){var a=N;return String.prototype.startsWith?a.startsWith("data:application/octet-stream;base64,"):0===a.indexOf("data:application/octet-stream;base64,")}var N="imagequant.wasm";
|
||||
if(!za()){var Aa=N;N=e.locateFile?e.locateFile(Aa,v):v+Aa}function Ba(){try{if(y)return new Uint8Array(y);if(ba)return ba(N);throw"both async and sync fetching of the wasm failed";}catch(a){z(a)}}function Ca(){return y||"function"!==typeof fetch?Promise.resolve().then(Ba):fetch(N,{credentials:"same-origin"}).then(function(a){if(!a.ok)throw"failed to load wasm binary file at '"+N+"'";return a.arrayBuffer()}).catch(function(){return Ba()})}
|
||||
function O(a){for(;0<a.length;){var b=a.shift();if("function"==typeof b)b(e);else{var c=b.J;"number"===typeof c?void 0===b.G?J.get(c)():J.get(c)(b.G):c(void 0===b.G?null:b.G)}}}function Da(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 Ea=void 0;function P(a){for(var b="";B[a];)b+=Ea[B[a++]];return b}var Q={},R={},S={};
|
||||
function Fa(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 Ga(a,b){a=Fa(a);return(new Function("body","return function "+a+'() {\n "use strict"; return body.apply(this, arguments);\n};\n'))(b)}
|
||||
function Ha(a){var b=Error,c=Ga(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 Ia=void 0;function T(a){throw new Ia(a);}var Ja=void 0;
|
||||
function Ka(a,b){function c(h){h=b(h);if(h.length!==d.length)throw new Ja("Mismatched type converter count");for(var p=0;p<d.length;++p)U(d[p],h[p])}var d=[];d.forEach(function(h){S[h]=a});var f=Array(a.length),g=[],l=0;a.forEach(function(h,p){R.hasOwnProperty(h)?f[p]=R[h]:(g.push(h),Q.hasOwnProperty(h)||(Q[h]=[]),Q[h].push(function(){f[p]=R[h];++l;l===g.length&&c(f)}))});0===g.length&&c(f)}
|
||||
function U(a,b,c){c=c||{};if(!("argPackAdvance"in b))throw new TypeError("registerType registeredInstance requires argPackAdvance");var d=b.name;a||T('type "'+d+'" must have a positive integer typeid pointer');if(R.hasOwnProperty(a)){if(c.K)return;T("Cannot register type '"+d+"' twice")}R[a]=b;delete S[a];Q.hasOwnProperty(a)&&(b=Q[a],delete Q[a],b.forEach(function(f){f()}))}var Na=[],V=[{},{value:void 0},{value:null},{value:!0},{value:!1}];
|
||||
function Oa(a){4<a&&0===--V[a].H&&(V[a]=void 0,Na.push(a))}function W(a){switch(a){case void 0:return 1;case null:return 2;case !0:return 3;case !1:return 4;default:var b=Na.length?Na.pop():V.length;V[b]={H:1,value:a};return b}}function Pa(a){return this.fromWireType(H[a>>2])}function Qa(a){if(null===a)return"null";var b=typeof a;return"object"===b||"array"===b||"function"===b?a.toString():""+a}
|
||||
function Ra(a,b){switch(b){case 2:return function(c){return this.fromWireType(pa[c>>2])};case 3:return function(c){return this.fromWireType(qa[c>>3])};default:throw new TypeError("Unknown float type: "+a);}}function Sa(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=Ga(b.name||"unknownFunctionName",function(){});c.prototype=b.prototype;c=new c;a=b.apply(c,a);return a instanceof Object?a:c}
|
||||
function Ta(a){for(;a.length;){var b=a.pop();a.pop()(b)}}function Ua(a,b){var c=e;if(void 0===c[a].D){var d=c[a];c[a]=function(){c[a].D.hasOwnProperty(arguments.length)||T("Function '"+b+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+c[a].D+")!");return c[a].D[arguments.length].apply(this,arguments)};c[a].D=[];c[a].D[d.I]=d}}
|
||||
function Va(a,b,c){e.hasOwnProperty(a)?((void 0===c||void 0!==e[a].D&&void 0!==e[a].D[c])&&T("Cannot register public name '"+a+"' twice"),Ua(a,a),e.hasOwnProperty(c)&&T("Cannot register multiple overloads of a function with the same number of arguments ("+c+")!"),e[a].D[c]=b):(e[a]=b,void 0!==c&&(e[a].M=c))}function Wa(a,b){for(var c=[],d=0;d<a;d++)c.push(F[(b>>2)+d]);return c}
|
||||
function Xa(a,b){0<=a.indexOf("j")||z("Assertion failed: getDynCaller should only be called with i64 sigs");var c=[];return function(){c.length=arguments.length;for(var d=0;d<arguments.length;d++)c[d]=arguments[d];var f;-1!=a.indexOf("j")?f=c&&c.length?e["dynCall_"+a].apply(null,[b].concat(c)):e["dynCall_"+a].call(null,b):f=J.get(b).apply(null,c);return f}}
|
||||
function Ya(a,b){a=P(a);var c=-1!=a.indexOf("j")?Xa(a,b):J.get(b);"function"!==typeof c&&T("unknown function pointer with signature "+a+": "+b);return c}var Za=void 0;function $a(a){a=ab(a);var b=P(a);X(a);return b}function bb(a,b){function c(g){f[g]||R[g]||(S[g]?S[g].forEach(c):(d.push(g),f[g]=!0))}var d=[],f={};b.forEach(c);throw new Za(a+": "+d.map($a).join([", "]));}
|
||||
function cb(a,b,c){switch(b){case 0:return c?function(d){return oa[d]}:function(d){return B[d]};case 1:return c?function(d){return E[d>>1]}:function(d){return D[d>>1]};case 2:return c?function(d){return F[d>>2]}:function(d){return H[d>>2]};default:throw new TypeError("Unknown integer type: "+a);}}var db={};function eb(){return"object"===typeof globalThis?globalThis:Function("return this")()}function fb(a,b){var c=R[a];void 0===c&&T(b+" has unknown type "+$a(a));return c}
|
||||
for(var gb={},hb=[null,[],[]],ib=Array(256),Y=0;256>Y;++Y)ib[Y]=String.fromCharCode(Y);Ea=ib;Ia=e.BindingError=Ha("BindingError");Ja=e.InternalError=Ha("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};Za=e.UnboundTypeError=Ha("UnboundTypeError");ua.push({J:function(){jb()}});
|
||||
var lb={o:function(){},p:function(a,b,c,d,f){var g=Da(c);b=P(b);U(a,{name:b,fromWireType:function(l){return!!l},toWireType:function(l,h){return h?d:f},argPackAdvance:8,readValueFromPointer:function(l){if(1===c)var h=oa;else if(2===c)h=E;else if(4===c)h=F;else throw new TypeError("Unknown boolean type size: "+b);return this.fromWireType(h[l>>g])},F:null})},v:function(a,b){b=P(b);U(a,{name:b,fromWireType:function(c){var d=V[c].value;Oa(c);return d},toWireType:function(c,d){return W(d)},argPackAdvance:8,
|
||||
readValueFromPointer:Pa,F:null})},n:function(a,b,c){c=Da(c);b=P(b);U(a,{name:b,fromWireType:function(d){return d},toWireType:function(d,f){if("number"!==typeof f&&"boolean"!==typeof f)throw new TypeError('Cannot convert "'+Qa(f)+'" to '+this.name);return f},argPackAdvance:8,readValueFromPointer:Ra(b,c),F:null})},e:function(a,b,c,d,f,g){var l=Wa(b,c);a=P(a);f=Ya(d,f);Va(a,function(){bb("Cannot call "+a+" due to unbound types",l)},b-1);Ka(l,function(h){var p=a,k=a;h=[h[0],null].concat(h.slice(1));var m=
|
||||
f,q=h.length;2>q&&T("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var x=null!==h[1]&&!1,C=!1,n=1;n<h.length;++n)if(null!==h[n]&&void 0===h[n].F){C=!0;break}var La="void"!==h[0].name,I="",M="";for(n=0;n<q-2;++n)I+=(0!==n?", ":"")+"arg"+n,M+=(0!==n?", ":"")+"arg"+n+"Wired";k="return function "+Fa(k)+"("+I+") {\nif (arguments.length !== "+(q-2)+") {\nthrowBindingError('function "+k+" called with ' + arguments.length + ' arguments, expected "+(q-2)+" args!');\n}\n";
|
||||
C&&(k+="var destructors = [];\n");var Ma=C?"destructors":"null";I="throwBindingError invoker fn runDestructors retType classParam".split(" ");m=[T,m,g,Ta,h[0],h[1]];x&&(k+="var thisWired = classParam.toWireType("+Ma+", this);\n");for(n=0;n<q-2;++n)k+="var arg"+n+"Wired = argType"+n+".toWireType("+Ma+", arg"+n+"); // "+h[n+2].name+"\n",I.push("argType"+n),m.push(h[n+2]);x&&(M="thisWired"+(0<M.length?", ":"")+M);k+=(La?"var rv = ":"")+"invoker(fn"+(0<M.length?", ":"")+M+");\n";if(C)k+="runDestructors(destructors);\n";
|
||||
else for(n=x?1:2;n<h.length;++n)q=1===n?"thisWired":"arg"+(n-2)+"Wired",null!==h[n].F&&(k+=q+"_dtor("+q+"); // "+h[n].name+"\n",I.push(q+"_dtor"),m.push(h[n].F));La&&(k+="var ret = retType.fromWireType(rv);\nreturn ret;\n");I.push(k+"}\n");h=Sa(I).apply(null,m);n=b-1;if(!e.hasOwnProperty(p))throw new Ja("Replacing nonexistant public symbol");void 0!==e[p].D&&void 0!==n?e[p].D[n]=h:(e[p]=h,e[p].I=n);return[]})},c:function(a,b,c,d,f){function g(k){return k}b=P(b);-1===f&&(f=4294967295);var l=Da(c);
|
||||
if(0===d){var h=32-8*c;g=function(k){return k<<h>>>h}}var p=-1!=b.indexOf("unsigned");U(a,{name:b,fromWireType:g,toWireType:function(k,m){if("number"!==typeof m&&"boolean"!==typeof m)throw new TypeError('Cannot convert "'+Qa(m)+'" to '+this.name);if(m<d||m>f)throw new TypeError('Passing a number "'+Qa(m)+'" from JS side to C/C++ side to an argument of type "'+b+'", which is outside the valid range ['+d+", "+f+"]!");return p?m>>>0:m|0},argPackAdvance:8,readValueFromPointer:cb(b,l,0!==d),F:null})},
|
||||
b:function(a,b,c){function d(g){g>>=2;var l=H;return new f(G,l[g+1],l[g])}var f=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][b];c=P(c);U(a,{name:c,fromWireType:d,argPackAdvance:8,readValueFromPointer:d},{K:!0})},i:function(a,b){b=P(b);var c="std::string"===b;U(a,{name:b,fromWireType:function(d){var f=H[d>>2];if(c)for(var g=d+4,l=0;l<=f;++l){var h=d+4+l;if(l==f||0==B[h]){if(g){for(var p=g+(h-g),k=g;!(k>=p)&&B[k];)++k;g=ea.decode(B.subarray(g,k))}else 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(B[d+4+l]);m=m.join("")}X(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 l=(c&&g?function(){for(var k=0,m=0;m<f.length;++m){var q=f.charCodeAt(m);55296<=q&&57343>=q&&(q=65536+((q&1023)<<
|
||||
10)|f.charCodeAt(++m)&1023);127>=q?++k:k=2047>=q?k+2:65535>=q?k+3:k+4}return k}:function(){return f.length})(),h=kb(4+l+1);H[h>>2]=l;if(c&&g)fa(f,h+4,l+1);else if(g)for(g=0;g<l;++g){var p=f.charCodeAt(g);255<p&&(X(h),T("String has UTF-16 code units that do not fit in 8 bits"));B[h+4+g]=p}else for(g=0;g<l;++g)B[h+4+g]=f[g];null!==d&&d.push(X,h);return h},argPackAdvance:8,readValueFromPointer:Pa,F:function(d){X(d)}})},g:function(a,b,c){c=P(c);if(2===b){var d=ia;var f=ja;var g=ka;var l=function(){return D};
|
||||
var h=1}else 4===b&&(d=la,f=ma,g=na,l=function(){return H},h=2);U(a,{name:c,fromWireType:function(p){for(var k=H[p>>2],m=l(),q,x=p+4,C=0;C<=k;++C){var n=p+4+C*b;if(C==k||0==m[n>>h])x=d(x,n-x),void 0===q?q=x:(q+=String.fromCharCode(0),q+=x),x=n+b}X(p);return q},toWireType:function(p,k){"string"!==typeof k&&T("Cannot pass non-string to C++ string type "+c);var m=g(k),q=kb(4+m+b);H[q>>2]=m>>h;f(k,q+4,m+b);null!==p&&p.push(X,q);return q},argPackAdvance:8,readValueFromPointer:Pa,F:function(p){X(p)}})},
|
||||
q:function(a,b){b=P(b);U(a,{L:!0,name:b,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},f:Oa,l:function(a){if(0===a)return W(eb());var b=db[a];a=void 0===b?P(a):b;return W(eb()[a])},j:function(a){4<a&&(V[a].H+=1)},k:function(a,b,c,d){a||T("Cannot use deleted val. handle = "+a);a=V[a].value;var f=gb[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")))(fb,e,W);gb[b]=f}return f(a,c,d)},h:function(){z()},t:function(a,b,c){B.copyWithin(a,b,b+c)},d: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{A.grow(Math.min(2147483648,d)-G.byteLength+65535>>>16);ra(A.buffer);var f=1;break a}catch(g){}f=void 0}if(f)return!0}return!1},u:function(){return 0},r:function(){},m:function(a,b,c,d){for(var f=0,g=0;g<c;g++){for(var l=F[b+8*g>>2],h=F[b+(8*g+4)>>2],p=0;p<h;p++){var k=B[l+p],m=hb[a];if(0===k||10===k){for(k=0;m[k]&&!(NaN<=k);)++k;k=ea.decode(m.subarray?m.subarray(0,k):new Uint8Array(m.slice(0,k)));(1===a?ca:w)(k);m.length=0}else m.push(k)}f+=h}F[d>>2]=f;return 0},
|
||||
a:A,s:function(){}};
|
||||
(function(){function a(f){e.asm=f.exports;J=e.asm.w;K--;e.monitorRunDependencies&&e.monitorRunDependencies(K);0==K&&(null!==ya&&(clearInterval(ya),ya=null),L&&(f=L,L=null,f()))}function b(f){a(f.instance)}function c(f){return Ca().then(function(g){return WebAssembly.instantiate(g,d)}).then(f,function(g){w("failed to asynchronously prepare wasm: "+g);z(g)})}var d={a:lb};K++;e.monitorRunDependencies&&e.monitorRunDependencies(K);if(e.instantiateWasm)try{return e.instantiateWasm(d,a)}catch(f){return w("Module.instantiateWasm callback failed with error: "+
|
||||
f),!1}(function(){return y||"function"!==typeof WebAssembly.instantiateStreaming||za()||"function"!==typeof fetch?c(b):fetch(N,{credentials:"same-origin"}).then(function(f){return WebAssembly.instantiateStreaming(f,d).then(b,function(g){w("wasm streaming compile failed: "+g);w("falling back to ArrayBuffer instantiation");return c(b)})})})().catch(r);return{}})();
|
||||
var jb=e.___wasm_call_ctors=function(){return(jb=e.___wasm_call_ctors=e.asm.x).apply(null,arguments)},kb=e._malloc=function(){return(kb=e._malloc=e.asm.y).apply(null,arguments)},X=e._free=function(){return(X=e._free=e.asm.z).apply(null,arguments)},ab=e.___getTypeName=function(){return(ab=e.___getTypeName=e.asm.A).apply(null,arguments)};e.___embind_register_native_and_builtin_types=function(){return(e.___embind_register_native_and_builtin_types=e.asm.B).apply(null,arguments)};
|
||||
e.dynCall_jiji=function(){return(e.dynCall_jiji=e.asm.C).apply(null,arguments)};var Z;L=function mb(){Z||nb();Z||(L=mb)};
|
||||
function nb(){function a(){if(!Z&&(Z=!0,e.calledRun=!0,!da)){O(ua);O(va);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();wa.unshift(b)}O(wa)}}if(!(0<K)){if(e.preRun)for("function"==typeof e.preRun&&(e.preRun=[e.preRun]);e.preRun.length;)xa();O(ta);0<K||(e.setStatus?(e.setStatus("Running..."),setTimeout(function(){setTimeout(function(){e.setStatus("")},1);a()},1)):a())}}
|
||||
e.run=nb;if(e.preInit)for("function"==typeof e.preInit&&(e.preInit=[e.preInit]);0<e.preInit.length;)e.preInit.pop()();noExitRuntime=!0;nb();
|
||||
|
||||
|
||||
return Module.ready
|
||||
|
@ -1,5 +1,5 @@
|
||||
CODEC_URL = https://gitlab.com/wg1/jpeg-xl.git
|
||||
CODEC_VERSION = v0.2
|
||||
CODEC_VERSION = 5175d11717f3c48cf506a2c0e0afb070392ae296
|
||||
CODEC_DIR = node_modules/jxl
|
||||
CODEC_BUILD_ROOT := $(CODEC_DIR)/build
|
||||
CODEC_MT_BUILD_DIR := $(CODEC_BUILD_ROOT)/mt
|
||||
|
@ -52,13 +52,14 @@ val decode(std::string data) {
|
||||
|
||||
auto next_in = (const uint8_t*)data.c_str();
|
||||
auto avail_in = data.size();
|
||||
EXPECT_EQ(JXL_DEC_BASIC_INFO, JxlDecoderProcessInput(dec.get(), &next_in, &avail_in));
|
||||
JxlDecoderSetInput(dec.get(), next_in, avail_in);
|
||||
EXPECT_EQ(JXL_DEC_BASIC_INFO, JxlDecoderProcessInput(dec.get()));
|
||||
JxlBasicInfo info;
|
||||
EXPECT_EQ(JXL_DEC_SUCCESS, JxlDecoderGetBasicInfo(dec.get(), &info));
|
||||
size_t pixel_count = info.xsize * info.ysize;
|
||||
size_t component_count = pixel_count * COMPONENTS_PER_PIXEL;
|
||||
|
||||
EXPECT_EQ(JXL_DEC_COLOR_ENCODING, JxlDecoderProcessInput(dec.get(), &next_in, &avail_in));
|
||||
EXPECT_EQ(JXL_DEC_COLOR_ENCODING, JxlDecoderProcessInput(dec.get()));
|
||||
static const JxlPixelFormat format = {COMPONENTS_PER_PIXEL, JXL_TYPE_FLOAT, JXL_LITTLE_ENDIAN, 0};
|
||||
size_t icc_size;
|
||||
EXPECT_EQ(JXL_DEC_SUCCESS, JxlDecoderGetICCProfileSize(dec.get(), &format,
|
||||
@ -68,11 +69,15 @@ val decode(std::string data) {
|
||||
JxlDecoderGetColorAsICCProfile(dec.get(), &format, JXL_COLOR_PROFILE_TARGET_DATA,
|
||||
icc_profile.data(), icc_profile.size()));
|
||||
|
||||
EXPECT_EQ(JXL_DEC_NEED_IMAGE_OUT_BUFFER, JxlDecoderProcessInput(dec.get()));
|
||||
size_t buffer_size;
|
||||
EXPECT_EQ(JXL_DEC_SUCCESS, JxlDecoderImageOutBufferSize(dec.get(), &format, &buffer_size));
|
||||
EXPECT_EQ(buffer_size, component_count * sizeof(float));
|
||||
|
||||
auto float_pixels = std::make_unique<float[]>(component_count);
|
||||
EXPECT_EQ(JXL_DEC_NEED_IMAGE_OUT_BUFFER, JxlDecoderProcessInput(dec.get(), &next_in, &avail_in));
|
||||
EXPECT_EQ(JXL_DEC_SUCCESS, JxlDecoderSetImageOutBuffer(dec.get(), &format, float_pixels.get(),
|
||||
component_count * sizeof(float)));
|
||||
EXPECT_EQ(JXL_DEC_FULL_IMAGE, JxlDecoderProcessInput(dec.get(), &next_in, &avail_in));
|
||||
EXPECT_EQ(JXL_DEC_FULL_IMAGE, JxlDecoderProcessInput(dec.get()));
|
||||
|
||||
auto byte_pixels = std::make_unique<uint8_t[]>(component_count);
|
||||
// Convert to sRGB.
|
||||
|
Binary file not shown.
Binary file not shown.
@ -42,17 +42,6 @@ val encode(std::string image, int width, int height, JXLOptions options) {
|
||||
cparams.options.predictor = jxl::Predictor::Zero;
|
||||
}
|
||||
|
||||
// Reduce memory usage of tree learning for lossless data.
|
||||
// TODO(veluca93): this is a mitigation for excessive memory usage in the JXL encoder.
|
||||
float megapixels = width * height * 0.000001;
|
||||
if (megapixels > 8) {
|
||||
cparams.options.nb_repeats = 0.1;
|
||||
} else if (megapixels > 4) {
|
||||
cparams.options.nb_repeats = 0.3;
|
||||
} else {
|
||||
// default is OK.
|
||||
}
|
||||
|
||||
float quality = options.quality;
|
||||
|
||||
// Quality settings roughly match libjpeg qualities.
|
||||
@ -102,7 +91,7 @@ val encode(std::string image, int width, int height, JXLOptions options) {
|
||||
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_sample=*/8, JXL_LITTLE_ENDIAN,
|
||||
/*alpha_is_premultiplied=*/false, /*bits_per_sample=*/8, /*endiannes=*/JXL_LITTLE_ENDIAN,
|
||||
/*flipped_y=*/false, pool_ptr, main);
|
||||
|
||||
if (!result) {
|
||||
|
Binary file not shown.
23
codecs/jxl/enc/jxl_enc_mt.js
generated
23
codecs/jxl/enc/jxl_enc_mt.js
generated
@ -17,7 +17,7 @@ function Da(a){return 2*a.length}function Ea(a,b){for(var c=0,d="";!(c>=b/4);){v
|
||||
function Ga(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}function Ha(a,b){e().set(a,b)}var n,aa,ba,ca,fa,ha,ia,ka,ma;function u(a){n=a;D.HEAP8=aa=new Int8Array(a);D.HEAP16=ca=new Int16Array(a);D.HEAP32=ha=new Int32Array(a);D.HEAPU8=ba=new Uint8Array(a);D.HEAPU16=fa=new Uint16Array(a);D.HEAPU32=ia=new Uint32Array(a);D.HEAPF32=ka=new Float32Array(a);D.HEAPF64=ma=new Float64Array(a)}var Ia=D.INITIAL_MEMORY||16777216;
|
||||
if(G)m=D.wasmMemory,n=D.buffer;else if(D.wasmMemory)m=D.wasmMemory;else if(m=new WebAssembly.Memory({initial:Ia/65536,maximum:32768,shared:!0}),!(m.buffer instanceof SharedArrayBuffer))throw J("requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag"),Error("bad memory");m&&(n=m.buffer);Ia=n.byteLength;u(n);var M,Ja=[],Ka=[],La=[],Ma=[];
|
||||
function Na(){var a=D.preRun.shift();Ja.unshift(a)}var N=0,Oa=null,Pa=null;D.preloadedImages={};D.preloadedAudios={};function K(a){if(D.onAbort)D.onAbort(a);G&&console.error("Pthread aborting at "+Error().stack);J(a);va=!0;a=new WebAssembly.RuntimeError("abort("+a+"). Build with -s ASSERTIONS=1 for more info.");oa(a);throw a;}function Qa(){var a=O;return String.prototype.startsWith?a.startsWith("data:application/octet-stream;base64,"):0===a.indexOf("data:application/octet-stream;base64,")}var O="jxl_enc_mt.wasm";
|
||||
Qa()||(O=qa(O));function Ra(){try{if(ta)return new Uint8Array(ta);if(ra)return ra(O);throw"both async and sync fetching of the wasm failed";}catch(a){K(a)}}function Sa(){return ta||"function"!==typeof fetch?Promise.resolve().then(Ra):fetch(O,{credentials:"same-origin"}).then(function(a){if(!a.ok)throw"failed to load wasm binary file at '"+O+"'";return a.arrayBuffer()}).catch(function(){return Ra()})}var Ua={60853:function(a,b){setTimeout(function(){Ta(a,b)},0)},60931:function(){throw"Canceled!";}};
|
||||
Qa()||(O=qa(O));function Ra(){try{if(ta)return new Uint8Array(ta);if(ra)return ra(O);throw"both async and sync fetching of the wasm failed";}catch(a){K(a)}}function Sa(){return ta||"function"!==typeof fetch?Promise.resolve().then(Ra):fetch(O,{credentials:"same-origin"}).then(function(a){if(!a.ok)throw"failed to load wasm binary file at '"+O+"'";return a.arrayBuffer()}).catch(function(){return Ra()})}var Ua={60805:function(a,b){setTimeout(function(){Ta(a,b)},0)},60883:function(){throw"Canceled!";}};
|
||||
function Va(a){for(;0<a.length;){var b=a.shift();if("function"==typeof b)b(D);else{var c=b.Bb;"number"===typeof c?void 0===b.Va?M.get(c)():M.get(c)(b.Va):c(void 0===b.Va?null:b.Va)}}}function Wa(a,b,c){var d;-1!=a.indexOf("j")?d=c&&c.length?D["dynCall_"+a].apply(null,[b].concat(c)):D["dynCall_"+a].call(null,b):d=M.get(b).apply(null,c);return d}D.dynCall=Wa;var P=0,Xa=0,Ya=0;function Za(a,b,c){P=a|0;Ya=b|0;Xa=c|0}D.registerPthreadPtr=Za;
|
||||
function $a(a,b){if(0>=a||a>e().length||a&1||0>b)return-28;if(0==b)return 0;2147483647<=b&&(b=Infinity);var c=Atomics.load(A(),Q.rb>>2),d=0;if(c==a&&Atomics.compareExchange(A(),Q.rb>>2,c,0)==c&&(--b,d=1,0>=b))return 1;a=Atomics.notify(A(),a>>2,b);if(0<=a)return a+d;throw"Atomics.notify returned an unexpected value "+a;}D._emscripten_futex_wake=$a;
|
||||
function ab(a){if(G)throw"Internal Error! cleanupThread() can only ever be called from main application thread!";if(!a)throw"Internal Error! Null pthread_ptr in cleanupThread!";A()[a+12>>2]=0;(a=Q.Oa[a])&&Q.bb(a.worker)}
|
||||
@ -89,16 +89,17 @@ t,wa(0<g));r=R(232);for(w=0;58>w;++w)C()[(r>>2)+w]=0;A()[a>>2]=r;A()[r+12>>2]=r;
|
||||
(function(){function a(f,g){D.asm=f.exports;M=D.asm.Y;ua=g;if(!G){var l=Q.Ma.length;Q.Ma.forEach(function(k){Q.qb(k,function(){if(!--l&&(N--,D.monitorRunDependencies&&D.monitorRunDependencies(N),0==N&&(null!==Oa&&(clearInterval(Oa),Oa=null),Pa))){var q=Pa;Pa=null;q()}})})}}function b(f){a(f.instance,f.module)}function c(f){return Sa().then(function(g){return WebAssembly.instantiate(g,d)}).then(f,function(g){J("failed to asynchronously prepare wasm: "+g);K(g)})}var d={a:Gc};G||(wa(!G,"addRunDependency cannot be used in a pthread worker"),
|
||||
N++,D.monitorRunDependencies&&D.monitorRunDependencies(N));if(D.instantiateWasm)try{return D.instantiateWasm(d,a)}catch(f){return J("Module.instantiateWasm callback failed with error: "+f),!1}(function(){return ta||"function"!==typeof WebAssembly.instantiateStreaming||Qa()||"function"!==typeof fetch?c(b):fetch(O,{credentials:"same-origin"}).then(function(f){return WebAssembly.instantiateStreaming(f,d).then(b,function(g){J("wasm streaming compile failed: "+g);J("falling back to ArrayBuffer instantiation");
|
||||
return c(b)})})})().catch(oa);return{}})();var Dc=D.___wasm_call_ctors=function(){return(Dc=D.___wasm_call_ctors=D.asm.Z).apply(null,arguments)},R=D._malloc=function(){return(R=D._malloc=D.asm._).apply(null,arguments)},S=D._free=function(){return(S=D._free=D.asm.$).apply(null,arguments)},zc=D.___errno_location=function(){return(zc=D.___errno_location=D.asm.aa).apply(null,arguments)},Kb=D.___getTypeName=function(){return(Kb=D.___getTypeName=D.asm.ba).apply(null,arguments)};
|
||||
D.___embind_register_native_and_builtin_types=function(){return(D.___embind_register_native_and_builtin_types=D.asm.ca).apply(null,arguments)};var oc=D._emscripten_get_global_libc=function(){return(oc=D._emscripten_get_global_libc=D.asm.da).apply(null,arguments)};D.___em_js__initPthreadsJS=function(){return(D.___em_js__initPthreadsJS=D.asm.ea).apply(null,arguments)};
|
||||
var Sb=D.stackSave=function(){return(Sb=D.stackSave=D.asm.fa).apply(null,arguments)},gb=D.stackRestore=function(){return(gb=D.stackRestore=D.asm.ga).apply(null,arguments)},Tb=D.stackAlloc=function(){return(Tb=D.stackAlloc=D.asm.ha).apply(null,arguments)},Fc=D._memalign=function(){return(Fc=D._memalign=D.asm.ia).apply(null,arguments)};D._emscripten_main_browser_thread_id=function(){return(D._emscripten_main_browser_thread_id=D.asm.ja).apply(null,arguments)};
|
||||
var db=D.___pthread_tsd_run_dtors=function(){return(db=D.___pthread_tsd_run_dtors=D.asm.ka).apply(null,arguments)},eb=D._emscripten_main_thread_process_queued_calls=function(){return(eb=D._emscripten_main_thread_process_queued_calls=D.asm.la).apply(null,arguments)};D._emscripten_current_thread_process_queued_calls=function(){return(D._emscripten_current_thread_process_queued_calls=D.asm.ma).apply(null,arguments)};
|
||||
var bb=D._emscripten_register_main_browser_thread_id=function(){return(bb=D._emscripten_register_main_browser_thread_id=D.asm.na).apply(null,arguments)},Ta=D._do_emscripten_dispatch_to_thread=function(){return(Ta=D._do_emscripten_dispatch_to_thread=D.asm.oa).apply(null,arguments)};D._emscripten_async_run_in_main_thread=function(){return(D._emscripten_async_run_in_main_thread=D.asm.pa).apply(null,arguments)};
|
||||
D._emscripten_sync_run_in_main_thread=function(){return(D._emscripten_sync_run_in_main_thread=D.asm.qa).apply(null,arguments)};D._emscripten_sync_run_in_main_thread_0=function(){return(D._emscripten_sync_run_in_main_thread_0=D.asm.ra).apply(null,arguments)};D._emscripten_sync_run_in_main_thread_1=function(){return(D._emscripten_sync_run_in_main_thread_1=D.asm.sa).apply(null,arguments)};
|
||||
D._emscripten_sync_run_in_main_thread_2=function(){return(D._emscripten_sync_run_in_main_thread_2=D.asm.ta).apply(null,arguments)};D._emscripten_sync_run_in_main_thread_xprintf_varargs=function(){return(D._emscripten_sync_run_in_main_thread_xprintf_varargs=D.asm.ua).apply(null,arguments)};D._emscripten_sync_run_in_main_thread_3=function(){return(D._emscripten_sync_run_in_main_thread_3=D.asm.va).apply(null,arguments)};
|
||||
var Ec=D._emscripten_sync_run_in_main_thread_4=function(){return(Ec=D._emscripten_sync_run_in_main_thread_4=D.asm.wa).apply(null,arguments)};D._emscripten_sync_run_in_main_thread_5=function(){return(D._emscripten_sync_run_in_main_thread_5=D.asm.xa).apply(null,arguments)};D._emscripten_sync_run_in_main_thread_6=function(){return(D._emscripten_sync_run_in_main_thread_6=D.asm.ya).apply(null,arguments)};
|
||||
D._emscripten_sync_run_in_main_thread_7=function(){return(D._emscripten_sync_run_in_main_thread_7=D.asm.za).apply(null,arguments)};var Ub=D._emscripten_run_in_main_runtime_thread_js=function(){return(Ub=D._emscripten_run_in_main_runtime_thread_js=D.asm.Aa).apply(null,arguments)},$b=D.__emscripten_call_on_thread=function(){return($b=D.__emscripten_call_on_thread=D.asm.Ba).apply(null,arguments)};D._emscripten_tls_init=function(){return(D._emscripten_tls_init=D.asm.Ca).apply(null,arguments)};
|
||||
D.dynCall_viijii=function(){return(D.dynCall_viijii=D.asm.Da).apply(null,arguments)};D.dynCall_iiji=function(){return(D.dynCall_iiji=D.asm.Ea).apply(null,arguments)};D.dynCall_jiji=function(){return(D.dynCall_jiji=D.asm.Fa).apply(null,arguments)};D.dynCall_iiiiiijj=function(){return(D.dynCall_iiiiiijj=D.asm.Ga).apply(null,arguments)};D.dynCall_iiiiij=function(){return(D.dynCall_iiiiij=D.asm.Ha).apply(null,arguments)};D.dynCall_iiiiijj=function(){return(D.dynCall_iiiiijj=D.asm.Ia).apply(null,arguments)};
|
||||
var cb=D._main_thread_futex=3060568;D.PThread=Q;D.PThread=Q;D._pthread_self=pc;D.wasmMemory=m;D.ExitStatus=Hc;var Ic;function Hc(a){this.name="ExitStatus";this.message="Program terminated with exit("+a+")";this.status=a}Pa=function Jc(){Ic||Kc();Ic||(Pa=Jc)};
|
||||
D.___embind_register_native_and_builtin_types=function(){return(D.___embind_register_native_and_builtin_types=D.asm.ca).apply(null,arguments)};D.___em_js__initPthreadsJS=function(){return(D.___em_js__initPthreadsJS=D.asm.da).apply(null,arguments)};
|
||||
var oc=D._emscripten_get_global_libc=function(){return(oc=D._emscripten_get_global_libc=D.asm.ea).apply(null,arguments)},Sb=D.stackSave=function(){return(Sb=D.stackSave=D.asm.fa).apply(null,arguments)},gb=D.stackRestore=function(){return(gb=D.stackRestore=D.asm.ga).apply(null,arguments)},Tb=D.stackAlloc=function(){return(Tb=D.stackAlloc=D.asm.ha).apply(null,arguments)},Fc=D._memalign=function(){return(Fc=D._memalign=D.asm.ia).apply(null,arguments)};
|
||||
D._emscripten_main_browser_thread_id=function(){return(D._emscripten_main_browser_thread_id=D.asm.ja).apply(null,arguments)};var db=D.___pthread_tsd_run_dtors=function(){return(db=D.___pthread_tsd_run_dtors=D.asm.ka).apply(null,arguments)},eb=D._emscripten_main_thread_process_queued_calls=function(){return(eb=D._emscripten_main_thread_process_queued_calls=D.asm.la).apply(null,arguments)};
|
||||
D._emscripten_current_thread_process_queued_calls=function(){return(D._emscripten_current_thread_process_queued_calls=D.asm.ma).apply(null,arguments)};var bb=D._emscripten_register_main_browser_thread_id=function(){return(bb=D._emscripten_register_main_browser_thread_id=D.asm.na).apply(null,arguments)},Ta=D._do_emscripten_dispatch_to_thread=function(){return(Ta=D._do_emscripten_dispatch_to_thread=D.asm.oa).apply(null,arguments)};
|
||||
D._emscripten_async_run_in_main_thread=function(){return(D._emscripten_async_run_in_main_thread=D.asm.pa).apply(null,arguments)};D._emscripten_sync_run_in_main_thread=function(){return(D._emscripten_sync_run_in_main_thread=D.asm.qa).apply(null,arguments)};D._emscripten_sync_run_in_main_thread_0=function(){return(D._emscripten_sync_run_in_main_thread_0=D.asm.ra).apply(null,arguments)};
|
||||
D._emscripten_sync_run_in_main_thread_1=function(){return(D._emscripten_sync_run_in_main_thread_1=D.asm.sa).apply(null,arguments)};D._emscripten_sync_run_in_main_thread_2=function(){return(D._emscripten_sync_run_in_main_thread_2=D.asm.ta).apply(null,arguments)};D._emscripten_sync_run_in_main_thread_xprintf_varargs=function(){return(D._emscripten_sync_run_in_main_thread_xprintf_varargs=D.asm.ua).apply(null,arguments)};
|
||||
D._emscripten_sync_run_in_main_thread_3=function(){return(D._emscripten_sync_run_in_main_thread_3=D.asm.va).apply(null,arguments)};var Ec=D._emscripten_sync_run_in_main_thread_4=function(){return(Ec=D._emscripten_sync_run_in_main_thread_4=D.asm.wa).apply(null,arguments)};D._emscripten_sync_run_in_main_thread_5=function(){return(D._emscripten_sync_run_in_main_thread_5=D.asm.xa).apply(null,arguments)};
|
||||
D._emscripten_sync_run_in_main_thread_6=function(){return(D._emscripten_sync_run_in_main_thread_6=D.asm.ya).apply(null,arguments)};D._emscripten_sync_run_in_main_thread_7=function(){return(D._emscripten_sync_run_in_main_thread_7=D.asm.za).apply(null,arguments)};
|
||||
var Ub=D._emscripten_run_in_main_runtime_thread_js=function(){return(Ub=D._emscripten_run_in_main_runtime_thread_js=D.asm.Aa).apply(null,arguments)},$b=D.__emscripten_call_on_thread=function(){return($b=D.__emscripten_call_on_thread=D.asm.Ba).apply(null,arguments)};D._emscripten_tls_init=function(){return(D._emscripten_tls_init=D.asm.Ca).apply(null,arguments)};D.dynCall_viijii=function(){return(D.dynCall_viijii=D.asm.Da).apply(null,arguments)};
|
||||
D.dynCall_iiji=function(){return(D.dynCall_iiji=D.asm.Ea).apply(null,arguments)};D.dynCall_jiji=function(){return(D.dynCall_jiji=D.asm.Fa).apply(null,arguments)};D.dynCall_iiiiiijj=function(){return(D.dynCall_iiiiiijj=D.asm.Ga).apply(null,arguments)};D.dynCall_iiiiij=function(){return(D.dynCall_iiiiij=D.asm.Ha).apply(null,arguments)};D.dynCall_iiiiijj=function(){return(D.dynCall_iiiiijj=D.asm.Ia).apply(null,arguments)};var cb=D._main_thread_futex=4639544;D.PThread=Q;D.PThread=Q;D._pthread_self=pc;
|
||||
D.wasmMemory=m;D.ExitStatus=Hc;var Ic;function Hc(a){this.name="ExitStatus";this.message="Program terminated with exit("+a+")";this.status=a}Pa=function Jc(){Ic||Kc();Ic||(Pa=Jc)};
|
||||
function Kc(){function a(){if(!Ic&&(Ic=!0,D.calledRun=!0,!va)){Va(Ka);G||Va(La);na(D);if(D.onRuntimeInitialized)D.onRuntimeInitialized();if(!G){if(D.postRun)for("function"==typeof D.postRun&&(D.postRun=[D.postRun]);D.postRun.length;){var b=D.postRun.shift();Ma.unshift(b)}Va(Ma)}}}if(!(0<N)){if(!G){if(D.preRun)for("function"==typeof D.preRun&&(D.preRun=[D.preRun]);D.preRun.length;)Na();Va(Ja)}0<N||(D.setStatus?(D.setStatus("Running..."),setTimeout(function(){setTimeout(function(){D.setStatus("")},
|
||||
1);a()},1)):a())}}D.run=Kc;if(D.preInit)for("function"==typeof D.preInit&&(D.preInit=[D.preInit]);0<D.preInit.length;)D.preInit.pop()();G||(noExitRuntime=!0);G?Q.Lb():Kc();
|
||||
|
||||
|
Binary file not shown.
21
codecs/jxl/enc/jxl_enc_mt_simd.js
generated
21
codecs/jxl/enc/jxl_enc_mt_simd.js
generated
@ -90,16 +90,17 @@ t,wa(0<g));r=R(232);for(w=0;58>w;++w)C()[(r>>2)+w]=0;A()[a>>2]=r;A()[r+12>>2]=r;
|
||||
(function(){function a(f,g){D.asm=f.exports;M=D.asm.Y;ua=g;if(!G){var l=Q.Ma.length;Q.Ma.forEach(function(k){Q.qb(k,function(){if(!--l&&(N--,D.monitorRunDependencies&&D.monitorRunDependencies(N),0==N&&(null!==Oa&&(clearInterval(Oa),Oa=null),Pa))){var q=Pa;Pa=null;q()}})})}}function b(f){a(f.instance,f.module)}function c(f){return Sa().then(function(g){return WebAssembly.instantiate(g,d)}).then(f,function(g){J("failed to asynchronously prepare wasm: "+g);K(g)})}var d={a:Gc};G||(wa(!G,"addRunDependency cannot be used in a pthread worker"),
|
||||
N++,D.monitorRunDependencies&&D.monitorRunDependencies(N));if(D.instantiateWasm)try{return D.instantiateWasm(d,a)}catch(f){return J("Module.instantiateWasm callback failed with error: "+f),!1}(function(){return ta||"function"!==typeof WebAssembly.instantiateStreaming||Qa()||"function"!==typeof fetch?c(b):fetch(O,{credentials:"same-origin"}).then(function(f){return WebAssembly.instantiateStreaming(f,d).then(b,function(g){J("wasm streaming compile failed: "+g);J("falling back to ArrayBuffer instantiation");
|
||||
return c(b)})})})().catch(oa);return{}})();var Dc=D.___wasm_call_ctors=function(){return(Dc=D.___wasm_call_ctors=D.asm.Z).apply(null,arguments)},R=D._malloc=function(){return(R=D._malloc=D.asm._).apply(null,arguments)},S=D._free=function(){return(S=D._free=D.asm.$).apply(null,arguments)},zc=D.___errno_location=function(){return(zc=D.___errno_location=D.asm.aa).apply(null,arguments)},Kb=D.___getTypeName=function(){return(Kb=D.___getTypeName=D.asm.ba).apply(null,arguments)};
|
||||
D.___embind_register_native_and_builtin_types=function(){return(D.___embind_register_native_and_builtin_types=D.asm.ca).apply(null,arguments)};var oc=D._emscripten_get_global_libc=function(){return(oc=D._emscripten_get_global_libc=D.asm.da).apply(null,arguments)};D.___em_js__initPthreadsJS=function(){return(D.___em_js__initPthreadsJS=D.asm.ea).apply(null,arguments)};
|
||||
var Sb=D.stackSave=function(){return(Sb=D.stackSave=D.asm.fa).apply(null,arguments)},gb=D.stackRestore=function(){return(gb=D.stackRestore=D.asm.ga).apply(null,arguments)},Tb=D.stackAlloc=function(){return(Tb=D.stackAlloc=D.asm.ha).apply(null,arguments)},Fc=D._memalign=function(){return(Fc=D._memalign=D.asm.ia).apply(null,arguments)};D._emscripten_main_browser_thread_id=function(){return(D._emscripten_main_browser_thread_id=D.asm.ja).apply(null,arguments)};
|
||||
var db=D.___pthread_tsd_run_dtors=function(){return(db=D.___pthread_tsd_run_dtors=D.asm.ka).apply(null,arguments)},eb=D._emscripten_main_thread_process_queued_calls=function(){return(eb=D._emscripten_main_thread_process_queued_calls=D.asm.la).apply(null,arguments)};D._emscripten_current_thread_process_queued_calls=function(){return(D._emscripten_current_thread_process_queued_calls=D.asm.ma).apply(null,arguments)};
|
||||
var bb=D._emscripten_register_main_browser_thread_id=function(){return(bb=D._emscripten_register_main_browser_thread_id=D.asm.na).apply(null,arguments)},Ta=D._do_emscripten_dispatch_to_thread=function(){return(Ta=D._do_emscripten_dispatch_to_thread=D.asm.oa).apply(null,arguments)};D._emscripten_async_run_in_main_thread=function(){return(D._emscripten_async_run_in_main_thread=D.asm.pa).apply(null,arguments)};
|
||||
D._emscripten_sync_run_in_main_thread=function(){return(D._emscripten_sync_run_in_main_thread=D.asm.qa).apply(null,arguments)};D._emscripten_sync_run_in_main_thread_0=function(){return(D._emscripten_sync_run_in_main_thread_0=D.asm.ra).apply(null,arguments)};D._emscripten_sync_run_in_main_thread_1=function(){return(D._emscripten_sync_run_in_main_thread_1=D.asm.sa).apply(null,arguments)};
|
||||
D._emscripten_sync_run_in_main_thread_2=function(){return(D._emscripten_sync_run_in_main_thread_2=D.asm.ta).apply(null,arguments)};D._emscripten_sync_run_in_main_thread_xprintf_varargs=function(){return(D._emscripten_sync_run_in_main_thread_xprintf_varargs=D.asm.ua).apply(null,arguments)};D._emscripten_sync_run_in_main_thread_3=function(){return(D._emscripten_sync_run_in_main_thread_3=D.asm.va).apply(null,arguments)};
|
||||
var Ec=D._emscripten_sync_run_in_main_thread_4=function(){return(Ec=D._emscripten_sync_run_in_main_thread_4=D.asm.wa).apply(null,arguments)};D._emscripten_sync_run_in_main_thread_5=function(){return(D._emscripten_sync_run_in_main_thread_5=D.asm.xa).apply(null,arguments)};D._emscripten_sync_run_in_main_thread_6=function(){return(D._emscripten_sync_run_in_main_thread_6=D.asm.ya).apply(null,arguments)};
|
||||
D._emscripten_sync_run_in_main_thread_7=function(){return(D._emscripten_sync_run_in_main_thread_7=D.asm.za).apply(null,arguments)};var Ub=D._emscripten_run_in_main_runtime_thread_js=function(){return(Ub=D._emscripten_run_in_main_runtime_thread_js=D.asm.Aa).apply(null,arguments)},$b=D.__emscripten_call_on_thread=function(){return($b=D.__emscripten_call_on_thread=D.asm.Ba).apply(null,arguments)};D._emscripten_tls_init=function(){return(D._emscripten_tls_init=D.asm.Ca).apply(null,arguments)};
|
||||
D.dynCall_viijii=function(){return(D.dynCall_viijii=D.asm.Da).apply(null,arguments)};D.dynCall_iiji=function(){return(D.dynCall_iiji=D.asm.Ea).apply(null,arguments)};D.dynCall_jiji=function(){return(D.dynCall_jiji=D.asm.Fa).apply(null,arguments)};D.dynCall_iiiiiijj=function(){return(D.dynCall_iiiiiijj=D.asm.Ga).apply(null,arguments)};D.dynCall_iiiiij=function(){return(D.dynCall_iiiiij=D.asm.Ha).apply(null,arguments)};D.dynCall_iiiiijj=function(){return(D.dynCall_iiiiijj=D.asm.Ia).apply(null,arguments)};
|
||||
var cb=D._main_thread_futex=3060648;D.PThread=Q;D.PThread=Q;D._pthread_self=pc;D.wasmMemory=m;D.ExitStatus=Hc;var Ic;function Hc(a){this.name="ExitStatus";this.message="Program terminated with exit("+a+")";this.status=a}Pa=function Jc(){Ic||Kc();Ic||(Pa=Jc)};
|
||||
D.___embind_register_native_and_builtin_types=function(){return(D.___embind_register_native_and_builtin_types=D.asm.ca).apply(null,arguments)};D.___em_js__initPthreadsJS=function(){return(D.___em_js__initPthreadsJS=D.asm.da).apply(null,arguments)};
|
||||
var oc=D._emscripten_get_global_libc=function(){return(oc=D._emscripten_get_global_libc=D.asm.ea).apply(null,arguments)},Sb=D.stackSave=function(){return(Sb=D.stackSave=D.asm.fa).apply(null,arguments)},gb=D.stackRestore=function(){return(gb=D.stackRestore=D.asm.ga).apply(null,arguments)},Tb=D.stackAlloc=function(){return(Tb=D.stackAlloc=D.asm.ha).apply(null,arguments)},Fc=D._memalign=function(){return(Fc=D._memalign=D.asm.ia).apply(null,arguments)};
|
||||
D._emscripten_main_browser_thread_id=function(){return(D._emscripten_main_browser_thread_id=D.asm.ja).apply(null,arguments)};var db=D.___pthread_tsd_run_dtors=function(){return(db=D.___pthread_tsd_run_dtors=D.asm.ka).apply(null,arguments)},eb=D._emscripten_main_thread_process_queued_calls=function(){return(eb=D._emscripten_main_thread_process_queued_calls=D.asm.la).apply(null,arguments)};
|
||||
D._emscripten_current_thread_process_queued_calls=function(){return(D._emscripten_current_thread_process_queued_calls=D.asm.ma).apply(null,arguments)};var bb=D._emscripten_register_main_browser_thread_id=function(){return(bb=D._emscripten_register_main_browser_thread_id=D.asm.na).apply(null,arguments)},Ta=D._do_emscripten_dispatch_to_thread=function(){return(Ta=D._do_emscripten_dispatch_to_thread=D.asm.oa).apply(null,arguments)};
|
||||
D._emscripten_async_run_in_main_thread=function(){return(D._emscripten_async_run_in_main_thread=D.asm.pa).apply(null,arguments)};D._emscripten_sync_run_in_main_thread=function(){return(D._emscripten_sync_run_in_main_thread=D.asm.qa).apply(null,arguments)};D._emscripten_sync_run_in_main_thread_0=function(){return(D._emscripten_sync_run_in_main_thread_0=D.asm.ra).apply(null,arguments)};
|
||||
D._emscripten_sync_run_in_main_thread_1=function(){return(D._emscripten_sync_run_in_main_thread_1=D.asm.sa).apply(null,arguments)};D._emscripten_sync_run_in_main_thread_2=function(){return(D._emscripten_sync_run_in_main_thread_2=D.asm.ta).apply(null,arguments)};D._emscripten_sync_run_in_main_thread_xprintf_varargs=function(){return(D._emscripten_sync_run_in_main_thread_xprintf_varargs=D.asm.ua).apply(null,arguments)};
|
||||
D._emscripten_sync_run_in_main_thread_3=function(){return(D._emscripten_sync_run_in_main_thread_3=D.asm.va).apply(null,arguments)};var Ec=D._emscripten_sync_run_in_main_thread_4=function(){return(Ec=D._emscripten_sync_run_in_main_thread_4=D.asm.wa).apply(null,arguments)};D._emscripten_sync_run_in_main_thread_5=function(){return(D._emscripten_sync_run_in_main_thread_5=D.asm.xa).apply(null,arguments)};
|
||||
D._emscripten_sync_run_in_main_thread_6=function(){return(D._emscripten_sync_run_in_main_thread_6=D.asm.ya).apply(null,arguments)};D._emscripten_sync_run_in_main_thread_7=function(){return(D._emscripten_sync_run_in_main_thread_7=D.asm.za).apply(null,arguments)};
|
||||
var Ub=D._emscripten_run_in_main_runtime_thread_js=function(){return(Ub=D._emscripten_run_in_main_runtime_thread_js=D.asm.Aa).apply(null,arguments)},$b=D.__emscripten_call_on_thread=function(){return($b=D.__emscripten_call_on_thread=D.asm.Ba).apply(null,arguments)};D._emscripten_tls_init=function(){return(D._emscripten_tls_init=D.asm.Ca).apply(null,arguments)};D.dynCall_viijii=function(){return(D.dynCall_viijii=D.asm.Da).apply(null,arguments)};
|
||||
D.dynCall_iiji=function(){return(D.dynCall_iiji=D.asm.Ea).apply(null,arguments)};D.dynCall_jiji=function(){return(D.dynCall_jiji=D.asm.Fa).apply(null,arguments)};D.dynCall_iiiiiijj=function(){return(D.dynCall_iiiiiijj=D.asm.Ga).apply(null,arguments)};D.dynCall_iiiiij=function(){return(D.dynCall_iiiiij=D.asm.Ha).apply(null,arguments)};D.dynCall_iiiiijj=function(){return(D.dynCall_iiiiijj=D.asm.Ia).apply(null,arguments)};var cb=D._main_thread_futex=4639672;D.PThread=Q;D.PThread=Q;D._pthread_self=pc;
|
||||
D.wasmMemory=m;D.ExitStatus=Hc;var Ic;function Hc(a){this.name="ExitStatus";this.message="Program terminated with exit("+a+")";this.status=a}Pa=function Jc(){Ic||Kc();Ic||(Pa=Jc)};
|
||||
function Kc(){function a(){if(!Ic&&(Ic=!0,D.calledRun=!0,!va)){Va(Ka);G||Va(La);na(D);if(D.onRuntimeInitialized)D.onRuntimeInitialized();if(!G){if(D.postRun)for("function"==typeof D.postRun&&(D.postRun=[D.postRun]);D.postRun.length;){var b=D.postRun.shift();Ma.unshift(b)}Va(Ma)}}}if(!(0<N)){if(!G){if(D.preRun)for("function"==typeof D.preRun&&(D.preRun=[D.preRun]);D.preRun.length;)Na();Va(Ja)}0<N||(D.setStatus?(D.setStatus("Running..."),setTimeout(function(){setTimeout(function(){D.setStatus("")},
|
||||
1);a()},1)):a())}}D.run=Kc;if(D.preInit)for("function"==typeof D.preInit&&(D.preInit=[D.preInit]);0<D.preInit.length;)D.preInit.pop()();G||(noExitRuntime=!0);G?Q.Lb():Kc();
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
2
codecs/png/pkg/squoosh_png.d.ts
generated
vendored
2
codecs/png/pkg/squoosh_png.d.ts
generated
vendored
@ -20,6 +20,7 @@ export interface InitOutput {
|
||||
readonly encode: (a: number, b: number, c: number, d: number, e: number) => void;
|
||||
readonly decode: (a: number, b: number) => number;
|
||||
readonly __wbindgen_free: (a: number, b: number) => void;
|
||||
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
||||
readonly __wbindgen_malloc: (a: number) => number;
|
||||
}
|
||||
|
||||
@ -32,4 +33,3 @@ export interface InitOutput {
|
||||
* @returns {Promise<InitOutput>}
|
||||
*/
|
||||
export default function init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;
|
||||
|
7
codecs/png/pkg/squoosh_png.js
generated
7
codecs/png/pkg/squoosh_png.js
generated
@ -64,8 +64,7 @@ function getArrayU8FromWasm0(ptr, len) {
|
||||
*/
|
||||
export function encode(data, width, height) {
|
||||
try {
|
||||
const retptr = wasm.__wbindgen_export_1.value - 16;
|
||||
wasm.__wbindgen_export_1.value = retptr;
|
||||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
||||
var ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
||||
var len0 = WASM_VECTOR_LEN;
|
||||
wasm.encode(retptr, ptr0, len0, width, height);
|
||||
@ -75,7 +74,7 @@ export function encode(data, width, height) {
|
||||
wasm.__wbindgen_free(r0, r1 * 1);
|
||||
return v1;
|
||||
} finally {
|
||||
wasm.__wbindgen_export_1.value += 16;
|
||||
wasm.__wbindgen_add_to_stack_pointer(16);
|
||||
}
|
||||
}
|
||||
|
||||
@ -138,7 +137,7 @@ async function load(module, imports) {
|
||||
|
||||
async function init(input) {
|
||||
if (typeof input === 'undefined') {
|
||||
input = import.meta.url.replace(/\.js$/, '_bg.wasm');
|
||||
input = new URL('squoosh_png_bg.wasm', import.meta.url);
|
||||
}
|
||||
const imports = {};
|
||||
imports.wbg = {};
|
||||
|
Binary file not shown.
1
codecs/png/pkg/squoosh_png_bg.wasm.d.ts
generated
vendored
1
codecs/png/pkg/squoosh_png_bg.wasm.d.ts
generated
vendored
@ -4,4 +4,5 @@ export const memory: WebAssembly.Memory;
|
||||
export function encode(a: number, b: number, c: number, d: number, e: number): void;
|
||||
export function decode(a: number, b: number): number;
|
||||
export function __wbindgen_free(a: number, b: number): void;
|
||||
export function __wbindgen_add_to_stack_pointer(a: number): number;
|
||||
export function __wbindgen_malloc(a: number): number;
|
||||
|
2
codecs/resize/pkg/squoosh_resize.d.ts
generated
vendored
2
codecs/resize/pkg/squoosh_resize.d.ts
generated
vendored
@ -18,6 +18,7 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
|
||||
export interface InitOutput {
|
||||
readonly memory: WebAssembly.Memory;
|
||||
readonly resize: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void;
|
||||
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
||||
readonly __wbindgen_malloc: (a: number) => number;
|
||||
readonly __wbindgen_free: (a: number, b: number) => void;
|
||||
}
|
||||
@ -31,4 +32,3 @@ export interface InitOutput {
|
||||
* @returns {Promise<InitOutput>}
|
||||
*/
|
||||
export default function init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;
|
||||
|
13
codecs/resize/pkg/squoosh_resize.js
generated
13
codecs/resize/pkg/squoosh_resize.js
generated
@ -41,14 +41,19 @@ function getArrayU8FromWasm0(ptr, len) {
|
||||
* @returns {Uint8Array}
|
||||
*/
|
||||
export function resize(input_image, input_width, input_height, output_width, output_height, typ_idx, premultiply, color_space_conversion) {
|
||||
try {
|
||||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
||||
var ptr0 = passArray8ToWasm0(input_image, wasm.__wbindgen_malloc);
|
||||
var len0 = WASM_VECTOR_LEN;
|
||||
wasm.resize(8, ptr0, len0, input_width, input_height, output_width, output_height, typ_idx, premultiply, color_space_conversion);
|
||||
var r0 = getInt32Memory0()[8 / 4 + 0];
|
||||
var r1 = getInt32Memory0()[8 / 4 + 1];
|
||||
wasm.resize(retptr, ptr0, len0, input_width, input_height, output_width, output_height, typ_idx, premultiply, color_space_conversion);
|
||||
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
||||
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
||||
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
||||
wasm.__wbindgen_free(r0, r1 * 1);
|
||||
return v1;
|
||||
} finally {
|
||||
wasm.__wbindgen_add_to_stack_pointer(16);
|
||||
}
|
||||
}
|
||||
|
||||
async function load(module, imports) {
|
||||
@ -86,7 +91,7 @@ async function load(module, imports) {
|
||||
|
||||
async function init(input) {
|
||||
if (typeof input === 'undefined') {
|
||||
input = import.meta.url.replace(/\.js$/, '_bg.wasm');
|
||||
input = new URL('squoosh_resize_bg.wasm', import.meta.url);
|
||||
}
|
||||
const imports = {};
|
||||
|
||||
|
6
codecs/resize/pkg/squoosh_resize_bg.d.ts
generated
vendored
6
codecs/resize/pkg/squoosh_resize_bg.d.ts
generated
vendored
@ -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, g: number, h: number, i: number, j: number): void;
|
||||
export function __wbindgen_malloc(a: number): number;
|
||||
export function __wbindgen_free(a: number, b: number): void;
|
Binary file not shown.
@ -7,7 +7,7 @@ using namespace butteraugli;
|
||||
|
||||
// Turns an interleaved RGBA buffer into 4 planes for each color channel
|
||||
void planarize(std::vector<ImageF>& img,
|
||||
const char* rgba,
|
||||
const uint8_t* rgba,
|
||||
int width,
|
||||
int height,
|
||||
float gamma = 2.2) {
|
||||
@ -22,10 +22,10 @@ void planarize(std::vector<ImageF>& img,
|
||||
float* const row_b = img[2].Row(y);
|
||||
float* const row_a = img[3].Row(y);
|
||||
for (int x = 0; x < width; x++) {
|
||||
row_r[x] = 255.0 * pow(rgba[y * width * 4 + x * 4 + 0] / 255.0, gamma);
|
||||
row_g[x] = 255.0 * pow(rgba[y * width * 4 + x * 4 + 1] / 255.0, gamma);
|
||||
row_b[x] = 255.0 * pow(rgba[y * width * 4 + x * 4 + 2] / 255.0, gamma);
|
||||
row_a[x] = 255.0 * pow(rgba[y * width * 4 + x * 4 + 3] / 255.0, gamma);
|
||||
row_r[x] = 255.0 * pow(rgba[(y * width + x) * 4 + 0] / 255.0, gamma);
|
||||
row_g[x] = 255.0 * pow(rgba[(y * width + x) * 4 + 1] / 255.0, gamma);
|
||||
row_b[x] = 255.0 * pow(rgba[(y * width + x) * 4 + 2] / 255.0, gamma);
|
||||
row_a[x] = 255.0 * pow(rgba[(y * width + x) * 4 + 3] / 255.0, gamma);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -37,14 +37,14 @@ class VisDiff {
|
||||
|
||||
public:
|
||||
VisDiff(std::string ref_img, int width, int height) {
|
||||
planarize(this->ref_img, ref_img.c_str(), width, height);
|
||||
planarize(this->ref_img, (uint8_t*)ref_img.c_str(), width, height);
|
||||
this->width = width;
|
||||
this->height = height;
|
||||
}
|
||||
|
||||
double distance(std::string other_img) {
|
||||
std::vector<ImageF> img;
|
||||
planarize(img, other_img.c_str(), width, height);
|
||||
planarize(img, (uint8_t*)other_img.c_str(), width, height);
|
||||
|
||||
ImageF diffmap;
|
||||
double diffvalue;
|
||||
|
12
codecs/visdif/visdif.js
generated
12
codecs/visdif/visdif.js
generated
@ -1,7 +1,7 @@
|
||||
|
||||
var visdif = (function() {
|
||||
var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
|
||||
if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename;
|
||||
var _scriptDir = import.meta.url;
|
||||
|
||||
return (
|
||||
function(visdif) {
|
||||
visdif = visdif || {};
|
||||
@ -71,10 +71,4 @@ f.run=Wb;if(f.preInit)for("function"==typeof f.preInit&&(f.preInit=[f.preInit]);
|
||||
}
|
||||
);
|
||||
})();
|
||||
if (typeof exports === 'object' && typeof module === 'object')
|
||||
module.exports = visdif;
|
||||
else if (typeof define === 'function' && define['amd'])
|
||||
define([], function() { return visdif; });
|
||||
else if (typeof exports === 'object')
|
||||
exports["visdif"] = visdif;
|
||||
|
||||
export default visdif;
|
BIN
codecs/visdif/visdif.wasm
Normal file → Executable file
BIN
codecs/visdif/visdif.wasm
Normal file → Executable file
Binary file not shown.
@ -12,9 +12,11 @@
|
||||
*/
|
||||
import { promises as fs } from 'fs';
|
||||
import { basename } from 'path';
|
||||
import { imageSize } from 'image-size';
|
||||
|
||||
const defaultOpts = {
|
||||
prefix: 'url',
|
||||
imagePrefix: 'img-url',
|
||||
};
|
||||
|
||||
export default function urlPlugin(opts) {
|
||||
@ -24,6 +26,7 @@ export default function urlPlugin(opts) {
|
||||
let assetIdToSourceBuffer;
|
||||
|
||||
const prefix = opts.prefix + ':';
|
||||
const imagePrefix = opts.imagePrefix + ':';
|
||||
return {
|
||||
name: 'url-plugin',
|
||||
buildStart() {
|
||||
@ -48,28 +51,49 @@ export default function urlPlugin(opts) {
|
||||
return combinedBuffer;
|
||||
},
|
||||
async resolveId(id, importer) {
|
||||
if (!id.startsWith(prefix)) return;
|
||||
const realId = id.slice(prefix.length);
|
||||
const idPrefix = [prefix, imagePrefix].find((prefix) =>
|
||||
id.startsWith(prefix),
|
||||
);
|
||||
if (!idPrefix) return;
|
||||
|
||||
const realId = id.slice(idPrefix.length);
|
||||
const resolveResult = await this.resolve(realId, importer);
|
||||
|
||||
if (!resolveResult) {
|
||||
throw Error(`Cannot find ${realId}`);
|
||||
}
|
||||
// Add an additional .js to the end so it ends up with .js at the end in the _virtual folder.
|
||||
return prefix + resolveResult.id + '.js';
|
||||
return idPrefix + resolveResult.id + '.js';
|
||||
},
|
||||
async load(id) {
|
||||
if (!id.startsWith(prefix)) return;
|
||||
const realId = id.slice(prefix.length, -'.js'.length);
|
||||
const idPrefix = [prefix, imagePrefix].find((prefix) =>
|
||||
id.startsWith(prefix),
|
||||
);
|
||||
if (!idPrefix) return;
|
||||
|
||||
const realId = id.slice(idPrefix.length, -'.js'.length);
|
||||
const source = await fs.readFile(realId);
|
||||
assetIdToSourceBuffer.set(id, source);
|
||||
this.addWatchFile(realId);
|
||||
|
||||
return `export default import.meta.ROLLUP_FILE_URL_${this.emitFile({
|
||||
let imgSizeExport = '';
|
||||
|
||||
if (idPrefix === imagePrefix) {
|
||||
const imgInfo = imageSize(source);
|
||||
imgSizeExport = [
|
||||
`export const width = ${JSON.stringify(imgInfo.width)};`,
|
||||
`export const height = ${JSON.stringify(imgInfo.height)};`,
|
||||
].join('\n');
|
||||
}
|
||||
|
||||
return [
|
||||
`export default import.meta.ROLLUP_FILE_URL_${this.emitFile({
|
||||
type: 'asset',
|
||||
source,
|
||||
name: basename(realId),
|
||||
})}`;
|
||||
})};`,
|
||||
imgSizeExport,
|
||||
].join('\n');
|
||||
},
|
||||
};
|
||||
}
|
||||
|
7
missing-types.d.ts
vendored
7
missing-types.d.ts
vendored
@ -22,6 +22,13 @@ declare module 'url:*' {
|
||||
export default value;
|
||||
}
|
||||
|
||||
declare module 'img-url:*' {
|
||||
const value: string;
|
||||
export default value;
|
||||
export const width: number;
|
||||
export const height: number;
|
||||
}
|
||||
|
||||
declare module 'omt:*' {
|
||||
const value: string;
|
||||
export default value;
|
||||
|
99
package-lock.json
generated
99
package-lock.json
generated
@ -109,9 +109,9 @@
|
||||
}
|
||||
},
|
||||
"@rollup/plugin-commonjs": {
|
||||
"version": "15.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-15.1.0.tgz",
|
||||
"integrity": "sha512-xCQqz4z/o0h2syQ7d9LskIMvBSH4PX5PjYdpSSvgS+pQik3WahkQVNWg3D8XJeYjZoVWnIUQYDghuEMRGrmQYQ==",
|
||||
"version": "17.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-17.0.0.tgz",
|
||||
"integrity": "sha512-/omBIJG1nHQc+bgkYDuLpb/V08QyutP9amOrJRUSlYJZP+b/68gM//D8sxJe3Yry2QnYIr3QjR3x4AlxJEN3GA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@rollup/pluginutils": "^3.1.0",
|
||||
@ -124,17 +124,17 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"estree-walker": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.1.tgz",
|
||||
"integrity": "sha512-tF0hv+Yi2Ot1cwj9eYHtxC0jB9bmjacjQs6ZBTj82H8JwUywFuc+7E83NWfNMwHXZc11mjfFcVXPe9gEP4B8dg==",
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz",
|
||||
"integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"@rollup/plugin-node-resolve": {
|
||||
"version": "9.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-9.0.0.tgz",
|
||||
"integrity": "sha512-gPz+utFHLRrd41WMP13Jq5mqqzHL3OXrfj3/MkSyB6UBIcuNt9j60GCbarzMzdf1VHFpOxfQh/ez7wyadLMqkg==",
|
||||
"version": "11.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-11.1.0.tgz",
|
||||
"integrity": "sha512-ouBBppRdWJKCllDXGzJ7ZIkYbaq+5TmyP0smt1vdJCFfoZhLi31vhpmjLhyo8lreHf4RoeSNllaWrvSqHpHRog==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@rollup/pluginutils": "^3.1.0",
|
||||
@ -142,7 +142,19 @@
|
||||
"builtin-modules": "^3.1.0",
|
||||
"deepmerge": "^4.2.2",
|
||||
"is-module": "^1.0.0",
|
||||
"resolve": "^1.17.0"
|
||||
"resolve": "^1.19.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"resolve": {
|
||||
"version": "1.19.0",
|
||||
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.19.0.tgz",
|
||||
"integrity": "sha512-rArEXAgsBG4UgRGcynxWIWKFvh/XZCcS8UJdHhwy91zwAvCZIbcs+vAbflgBnNjYMs/i/i+/Ux6IZhML1yPvxg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"is-core-module": "^2.1.0",
|
||||
"path-parse": "^1.0.6"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@rollup/plugin-replace": {
|
||||
@ -204,6 +216,12 @@
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"@types/mime-types": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/mime-types/-/mime-types-2.1.0.tgz",
|
||||
"integrity": "sha1-nKUs2jY/aZxpRmwqbM2q2RPqenM=",
|
||||
"dev": true
|
||||
},
|
||||
"@types/minimatch": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.3.tgz",
|
||||
@ -541,9 +559,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"builtin-modules": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.1.0.tgz",
|
||||
"integrity": "sha512-k0KL0aWZuBt2lrxrcASWDfwOLMnodeQjodT/1SxEQAXsHANgo6ZC/VEaSEHCXt7aSTZ4/4H5LKa+tBXmW7Vtvw==",
|
||||
"version": "3.2.0",
|
||||
"resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.2.0.tgz",
|
||||
"integrity": "sha512-lGzLKcioL90C7wMczpkY0n/oART3MbBa8R9OFGE1rJxoVI86u4WAGfEk8Wjv10eKSyTHVGkSo3bvBylCEtk7LA==",
|
||||
"dev": true
|
||||
},
|
||||
"bytes": {
|
||||
@ -2071,6 +2089,15 @@
|
||||
"integrity": "sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw==",
|
||||
"dev": true
|
||||
},
|
||||
"image-size": {
|
||||
"version": "0.9.3",
|
||||
"resolved": "https://registry.npmjs.org/image-size/-/image-size-0.9.3.tgz",
|
||||
"integrity": "sha512-5SakFa79uhUVSjKeQE30GVzzLJ0QNzB53+I+/VD1vIesD6GP6uatWIlgU0uisFNLt1u0d6kBydp7yfk+lLJhLQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"queue": "6.0.1"
|
||||
}
|
||||
},
|
||||
"import-fresh": {
|
||||
"version": "3.2.1",
|
||||
"resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.2.1.tgz",
|
||||
@ -2147,6 +2174,15 @@
|
||||
"rgba-regex": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"is-core-module": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.2.0.tgz",
|
||||
"integrity": "sha512-XRAfAdyyY5F5cOXn7hYQDqh2Xmii+DEfIcQGxK/uNwMHhIkPWO0g8msXcbzLe+MpGoR951MlqM/2iIlU4vKDdQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"has": "^1.0.3"
|
||||
}
|
||||
},
|
||||
"is-date-object": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.2.tgz",
|
||||
@ -2551,12 +2587,20 @@
|
||||
"dev": true
|
||||
},
|
||||
"mime-types": {
|
||||
"version": "2.1.27",
|
||||
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.27.tgz",
|
||||
"integrity": "sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w==",
|
||||
"version": "2.1.28",
|
||||
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.28.tgz",
|
||||
"integrity": "sha512-0TO2yJ5YHYr7M2zzT7gDU1tbwHxEUWBCLt0lscSNpcdAfFyJOVEpRYNS7EXVcTLNj/25QO8gulHC5JtTzSE2UQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"mime-db": "1.44.0"
|
||||
"mime-db": "1.45.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"mime-db": {
|
||||
"version": "1.45.0",
|
||||
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.45.0.tgz",
|
||||
"integrity": "sha512-CkqLUxUk15hofLoLyljJSrukZi8mAtgd+yE5uO4tqRZsdsAJKv0O+rFMhVDRJgozy+yG6md5KwuXhD4ocIoP+w==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"mimic-fn": {
|
||||
@ -6090,6 +6134,15 @@
|
||||
"integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=",
|
||||
"dev": true
|
||||
},
|
||||
"queue": {
|
||||
"version": "6.0.1",
|
||||
"resolved": "https://registry.npmjs.org/queue/-/queue-6.0.1.tgz",
|
||||
"integrity": "sha512-AJBQabRCCNr9ANq8v77RJEv73DPbn55cdTb+Giq4X0AVnNVZvMHlYp7XlQiN+1npCZj1DuSmaA2hYVUUDgxFDg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"inherits": "~2.0.3"
|
||||
}
|
||||
},
|
||||
"randombytes": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz",
|
||||
@ -6211,9 +6264,9 @@
|
||||
}
|
||||
},
|
||||
"rollup": {
|
||||
"version": "2.33.1",
|
||||
"resolved": "https://registry.npmjs.org/rollup/-/rollup-2.33.1.tgz",
|
||||
"integrity": "sha512-uY4O/IoL9oNW8MMcbA5hcOaz6tZTMIh7qJHx/tzIJm+n1wLoY38BLn6fuy7DhR57oNFLMbDQtDeJoFURt5933w==",
|
||||
"version": "2.38.0",
|
||||
"resolved": "https://registry.npmjs.org/rollup/-/rollup-2.38.0.tgz",
|
||||
"integrity": "sha512-ay9zDiNitZK/LNE/EM2+v5CZ7drkB2xyDljvb1fQJCGnq43ZWRkhxN145oV8GmoW1YNi4sA/1Jdkr2LfawJoXw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"fsevents": "~2.1.2"
|
||||
@ -6930,9 +6983,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"typescript": {
|
||||
"version": "4.0.5",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.0.5.tgz",
|
||||
"integrity": "sha512-ywmr/VrTVCmNTJ6iV2LwIrfG1P+lv6luD8sUJs+2eI9NLGigaN+nUQc13iHqisq7bra9lnmUSYqbJvegraBOPQ==",
|
||||
"version": "4.1.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.1.3.tgz",
|
||||
"integrity": "sha512-B3ZIOf1IKeH2ixgHhj6la6xdwR9QrLC5d1VKeCSY4tvkqhF2eqd9O7txNlS0PO3GrBAFIdr3L1ndNwteUbZLYg==",
|
||||
"dev": true
|
||||
},
|
||||
"uniq": {
|
||||
|
12
package.json
12
package.json
@ -11,11 +11,12 @@
|
||||
"serve": "serve --config ../../../serve.json .tmp/build/static"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-commonjs": "^15.1.0",
|
||||
"@rollup/plugin-node-resolve": "^9.0.0",
|
||||
"@rollup/plugin-commonjs": "^17.0.0",
|
||||
"@rollup/plugin-node-resolve": "^11.1.0",
|
||||
"@rollup/plugin-replace": "^2.3.4",
|
||||
"@surma/rollup-plugin-off-main-thread": "^1.4.2",
|
||||
"@types/dedent": "^0.7.0",
|
||||
"@types/mime-types": "^2.1.0",
|
||||
"@types/node": "^14.14.7",
|
||||
"comlink": "^4.3.0",
|
||||
"cssnano": "^4.1.10",
|
||||
@ -24,10 +25,11 @@
|
||||
"file-drop-element": "^1.0.1",
|
||||
"husky": "^4.3.0",
|
||||
"idb-keyval": "^3.2.0",
|
||||
"image-size": "^0.9.3",
|
||||
"linkstate": "^2.0.0",
|
||||
"lint-staged": "^10.5.1",
|
||||
"lodash.camelcase": "^4.3.0",
|
||||
"mime-types": "^2.1.27",
|
||||
"mime-types": "^2.1.28",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"pointer-tracker": "^2.4.0",
|
||||
"postcss": "^7.0.35",
|
||||
@ -38,10 +40,10 @@
|
||||
"preact": "^10.5.5",
|
||||
"preact-render-to-string": "^5.1.11",
|
||||
"prettier": "^2.1.2",
|
||||
"rollup": "^2.33.1",
|
||||
"rollup": "^2.38.0",
|
||||
"rollup-plugin-terser": "^7.0.2",
|
||||
"serve": "^11.3.2",
|
||||
"typescript": "^4.0.5",
|
||||
"typescript": "^4.1.3",
|
||||
"which": "^2.0.2"
|
||||
},
|
||||
"husky": {
|
||||
|
@ -80,7 +80,7 @@ async function decodeImage(url: string): Promise<HTMLImageElement> {
|
||||
const img = new Image();
|
||||
img.decoding = 'async';
|
||||
img.src = url;
|
||||
const loaded = new Promise((resolve, reject) => {
|
||||
const loaded = new Promise<void>((resolve, reject) => {
|
||||
img.onload = () => resolve();
|
||||
img.onerror = () => reject(Error('Image loading error'));
|
||||
});
|
||||
|
@ -86,7 +86,7 @@ export default class SnackBarElement extends HTMLEl {
|
||||
|
||||
// Transition the snack away.
|
||||
el.setAttribute('aria-hidden', 'true');
|
||||
await new Promise((resolve) => {
|
||||
await new Promise<void>((resolve) => {
|
||||
el.addEventListener('animationend', () => resolve());
|
||||
});
|
||||
el.remove();
|
||||
|
BIN
src/static-build/assets/screenshot1.png
Normal file
BIN
src/static-build/assets/screenshot1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 26 KiB |
BIN
src/static-build/assets/screenshot2.jpg
Normal file
BIN
src/static-build/assets/screenshot2.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 34 KiB |
BIN
src/static-build/assets/screenshot3.jpg
Normal file
BIN
src/static-build/assets/screenshot3.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 36 KiB |
@ -14,9 +14,16 @@ import { h } from 'preact';
|
||||
|
||||
import { renderPage, writeFiles } from './utils';
|
||||
import IndexPage from './pages/index';
|
||||
import iconLargeMaskable from 'url:static-build/assets/icon-large-maskable.png';
|
||||
import iconLarge from 'url:static-build/assets/icon-large.png';
|
||||
import * as iconLargeMaskable from 'img-url:static-build/assets/icon-large-maskable.png';
|
||||
import * as iconLarge from 'img-url:static-build/assets/icon-large.png';
|
||||
import * as screenshot1 from 'img-url:static-build/assets/screenshot1.png';
|
||||
import * as screenshot2 from 'img-url:static-build/assets/screenshot2.jpg';
|
||||
import * as screenshot3 from 'img-url:static-build/assets/screenshot3.jpg';
|
||||
import dedent from 'dedent';
|
||||
import { lookup as lookupMime } from 'mime-types';
|
||||
|
||||
const manifestSize = ({ width, height }: { width: number; height: number }) =>
|
||||
`${width}x${height}`;
|
||||
|
||||
// Set by Netlify
|
||||
const branch = process.env.BRANCH;
|
||||
@ -49,17 +56,38 @@ const toOutput: Output = {
|
||||
theme_color: '#ff3385',
|
||||
icons: [
|
||||
{
|
||||
src: iconLarge,
|
||||
type: 'image/png',
|
||||
sizes: '1024x1024',
|
||||
src: iconLarge.default,
|
||||
type: lookupMime(iconLarge.default),
|
||||
sizes: manifestSize(iconLarge),
|
||||
},
|
||||
{
|
||||
src: iconLargeMaskable,
|
||||
type: 'image/png',
|
||||
sizes: '1024x1024',
|
||||
src: iconLargeMaskable.default,
|
||||
type: lookupMime(iconLargeMaskable.default),
|
||||
sizes: manifestSize(iconLargeMaskable),
|
||||
purpose: 'maskable',
|
||||
},
|
||||
],
|
||||
description:
|
||||
'Compress and compare images with different codecs, right in your browser.',
|
||||
lang: 'en',
|
||||
categories: ['photo', 'productivity', 'utilities'],
|
||||
screenshots: [
|
||||
{
|
||||
src: screenshot1.default,
|
||||
type: lookupMime(screenshot1.default),
|
||||
sizes: manifestSize(screenshot1),
|
||||
},
|
||||
{
|
||||
src: screenshot2.default,
|
||||
type: lookupMime(screenshot2.default),
|
||||
sizes: manifestSize(screenshot2),
|
||||
},
|
||||
{
|
||||
src: screenshot3.default,
|
||||
type: lookupMime(screenshot3.default),
|
||||
sizes: manifestSize(screenshot3),
|
||||
},
|
||||
],
|
||||
share_target: {
|
||||
action: '/?utm_medium=PWA&utm_source=share-target&share-target',
|
||||
method: 'POST',
|
||||
@ -78,8 +106,9 @@ const toOutput: Output = {
|
||||
/*
|
||||
Cache-Control: no-cache
|
||||
|
||||
/c/*
|
||||
Cache-Control: max-age=31536000
|
||||
# I don't think Rollup is cache-busting files correctly.
|
||||
#/c/*
|
||||
# Cache-Control: max-age=31536000
|
||||
|
||||
# COOP+COEP for WebAssembly threads.
|
||||
/*
|
||||
|
@ -84,14 +84,19 @@ export function cleanupCache(
|
||||
);
|
||||
}
|
||||
|
||||
function urlsToRequests(urls: string[]): Request[] {
|
||||
// Using no-cache, as our hashing aren't updating properly right now.
|
||||
return urls.map((url) => new Request(url, { cache: 'no-cache' }));
|
||||
}
|
||||
|
||||
export async function cacheBasics(cacheName: string) {
|
||||
const cache = await caches.open(cacheName);
|
||||
return cache.addAll(initial);
|
||||
return cache.addAll(urlsToRequests(initial));
|
||||
}
|
||||
|
||||
export async function cacheAdditionalProcessors(cacheName: string) {
|
||||
const cache = await caches.open(cacheName);
|
||||
return cache.addAll(await theRest);
|
||||
return cache.addAll(urlsToRequests(await theRest));
|
||||
}
|
||||
|
||||
const nextMessageResolveMap = new Map<string, (() => void)[]>();
|
||||
|
Reference in New Issue
Block a user