Compare commits

...

2 Commits

Author SHA1 Message Date
Surma
f4f97abf9d Testing lol 2021-08-10 08:28:12 -04:00
Surma
7c9d3d6ba6 Compile with -s MINIMAL_RUNTIME=1 2021-08-10 07:31:16 -04:00
78 changed files with 322 additions and 320 deletions

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@@ -1 +1 @@
"use strict";var Module={};var initializedJS=false;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:Module["_pthread_self"]()})}var err=threadPrintErr;self.alert=threadAlert;Module["instantiateWasm"]=function(info,receiveInstance){var instance=new WebAssembly.Instance(Module["wasmModule"],info);receiveInstance(instance);Module["wasmModule"]=null;return instance.exports};function moduleLoaded(){}self.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;(e.data.urlOrBlob?import(e.data.urlOrBlob):import("./avif_enc_mt.js")).then(function(exports){return exports.default(Module)}).then(function(instance){Module=instance;moduleLoaded()})}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;Module["__emscripten_thread_init"](e.data.threadInfoStruct,0,0);var max=e.data.stackBase;var top=e.data.stackBase+e.data.stackSize;Module["establishStackSpace"](top,max);Module["PThread"].receiveObjectTransfer(e.data);Module["PThread"].threadInit();if(!initializedJS){Module["___embind_register_native_and_builtin_types"]();initializedJS=true}try{var result=Module["invokeEntryPoint"](e.data.start_routine,e.data.arg);if(Module["keepRuntimeAlive"]()){Module["PThread"].setExitStatus(result)}else{Module["PThread"].threadExit(result)}}catch(ex){if(ex==="Canceled!"){Module["PThread"].threadCancel()}else if(ex!="unwind"){if(ex instanceof Module["ExitStatus"]){if(Module["keepRuntimeAlive"]()){}else{Module["PThread"].threadExit(ex.status)}}else{Module["PThread"].threadExit(-2);throw ex}}}}else if(e.data.cmd==="cancel"){if(Module["_pthread_self"]()){Module["PThread"].threadCancel()}}else if(e.data.target==="setimmediate"){}else if(e.data.cmd==="processThreadQueue"){if(Module["_pthread_self"]()){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}}; "use strict";var Module={};var initializedJS=false;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:Module["_pthread_self"]()})}var err=threadPrintErr;self.alert=threadAlert;function moduleLoaded(){}self.onmessage=function(e){try{if(e.data.cmd==="load"){var imports={};imports["wasm"]=e.data.wasmModule;imports["wasmMemory"]=e.data.wasmMemory;imports["buffer"]=imports["wasmMemory"].buffer;imports["ENVIRONMENT_IS_PTHREAD"]=true;(e.data.urlOrBlob?import(e.data.urlOrBlob):import("./avif_enc_mt.js")).then(function(exports){return exports.default(Module)}).then(function(instance){Module=instance;moduleLoaded()})}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;Module["__emscripten_thread_init"](e.data.threadInfoStruct,0,0);var max=e.data.stackBase;var top=e.data.stackBase+e.data.stackSize;Module["establishStackSpace"](top,max);Module["PThread"].receiveObjectTransfer(e.data);Module["PThread"].threadInit();if(!initializedJS){Module["___embind_register_native_and_builtin_types"]();initializedJS=true}try{var result=Module["invokeEntryPoint"](e.data.start_routine,e.data.arg);Module["PThread"].threadExit(result)}catch(ex){if(ex==="Canceled!"){Module["PThread"].threadCancel()}else if(ex!="unwind"){{Module["PThread"].threadExit(-2);throw ex}}}}else if(e.data.cmd==="cancel"){if(Module["_pthread_self"]()){Module["PThread"].threadCancel()}}else if(e.data.target==="setimmediate"){}else if(e.data.cmd==="processThreadQueue"){if(Module["_pthread_self"]()){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}};

View File

@@ -8,6 +8,7 @@ ENV LDFLAGS "${CFLAGS} \
-s ALLOW_MEMORY_GROWTH=1 \ -s ALLOW_MEMORY_GROWTH=1 \
-s TEXTDECODER=2 \ -s TEXTDECODER=2 \
-s NODEJS_CATCH_EXIT=0 -s NODEJS_CATCH_REJECTION=0 \ -s NODEJS_CATCH_EXIT=0 -s NODEJS_CATCH_REJECTION=0 \
-s MINIMAL_RUNTIME=1 \
" "
# Build and cache standard libraries with these flags + Embind. # Build and cache standard libraries with these flags + Embind.
RUN emcc ${CXXFLAGS} ${LDFLAGS} --bind -xc++ /dev/null -o /dev/null RUN emcc ${CXXFLAGS} ${LDFLAGS} --bind -xc++ /dev/null -o /dev/null

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@@ -1 +1 @@
"use strict";var Module={};var initializedJS=false;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:Module["_pthread_self"]()})}var err=threadPrintErr;self.alert=threadAlert;Module["instantiateWasm"]=function(info,receiveInstance){var instance=new WebAssembly.Instance(Module["wasmModule"],info);receiveInstance(instance);Module["wasmModule"]=null;return instance.exports};function moduleLoaded(){}self.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;(e.data.urlOrBlob?import(e.data.urlOrBlob):import("./jxl_enc_mt.js")).then(function(exports){return exports.default(Module)}).then(function(instance){Module=instance;moduleLoaded()})}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;Module["__emscripten_thread_init"](e.data.threadInfoStruct,0,0);var max=e.data.stackBase;var top=e.data.stackBase+e.data.stackSize;Module["establishStackSpace"](top,max);Module["PThread"].receiveObjectTransfer(e.data);Module["PThread"].threadInit();if(!initializedJS){Module["___embind_register_native_and_builtin_types"]();initializedJS=true}try{var result=Module["invokeEntryPoint"](e.data.start_routine,e.data.arg);if(Module["keepRuntimeAlive"]()){Module["PThread"].setExitStatus(result)}else{Module["PThread"].threadExit(result)}}catch(ex){if(ex==="Canceled!"){Module["PThread"].threadCancel()}else if(ex!="unwind"){if(ex instanceof Module["ExitStatus"]){if(Module["keepRuntimeAlive"]()){}else{Module["PThread"].threadExit(ex.status)}}else{Module["PThread"].threadExit(-2);throw ex}}}}else if(e.data.cmd==="cancel"){if(Module["_pthread_self"]()){Module["PThread"].threadCancel()}}else if(e.data.target==="setimmediate"){}else if(e.data.cmd==="processThreadQueue"){if(Module["_pthread_self"]()){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}}; "use strict";var Module={};var initializedJS=false;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:Module["_pthread_self"]()})}var err=threadPrintErr;self.alert=threadAlert;function moduleLoaded(){}self.onmessage=function(e){try{if(e.data.cmd==="load"){var imports={};imports["wasm"]=e.data.wasmModule;imports["wasmMemory"]=e.data.wasmMemory;imports["buffer"]=imports["wasmMemory"].buffer;imports["ENVIRONMENT_IS_PTHREAD"]=true;(e.data.urlOrBlob?import(e.data.urlOrBlob):import("./jxl_enc_mt.js")).then(function(exports){return exports.default(Module)}).then(function(instance){Module=instance;moduleLoaded()})}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;Module["__emscripten_thread_init"](e.data.threadInfoStruct,0,0);var max=e.data.stackBase;var top=e.data.stackBase+e.data.stackSize;Module["establishStackSpace"](top,max);Module["PThread"].receiveObjectTransfer(e.data);Module["PThread"].threadInit();if(!initializedJS){Module["___embind_register_native_and_builtin_types"]();initializedJS=true}try{var result=Module["invokeEntryPoint"](e.data.start_routine,e.data.arg);Module["PThread"].threadExit(result)}catch(ex){if(ex==="Canceled!"){Module["PThread"].threadCancel()}else if(ex!="unwind"){{Module["PThread"].threadExit(-2);throw ex}}}}else if(e.data.cmd==="cancel"){if(Module["_pthread_self"]()){Module["PThread"].threadCancel()}}else if(e.data.target==="setimmediate"){}else if(e.data.cmd==="processThreadQueue"){if(Module["_pthread_self"]()){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}};

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@@ -1 +1 @@
"use strict";var Module={};var initializedJS=false;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:Module["_pthread_self"]()})}var err=threadPrintErr;self.alert=threadAlert;Module["instantiateWasm"]=function(info,receiveInstance){var instance=new WebAssembly.Instance(Module["wasmModule"],info);receiveInstance(instance);Module["wasmModule"]=null;return instance.exports};function moduleLoaded(){}self.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;(e.data.urlOrBlob?import(e.data.urlOrBlob):import("./jxl_enc_mt_simd.js")).then(function(exports){return exports.default(Module)}).then(function(instance){Module=instance;moduleLoaded()})}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;Module["__emscripten_thread_init"](e.data.threadInfoStruct,0,0);var max=e.data.stackBase;var top=e.data.stackBase+e.data.stackSize;Module["establishStackSpace"](top,max);Module["PThread"].receiveObjectTransfer(e.data);Module["PThread"].threadInit();if(!initializedJS){Module["___embind_register_native_and_builtin_types"]();initializedJS=true}try{var result=Module["invokeEntryPoint"](e.data.start_routine,e.data.arg);if(Module["keepRuntimeAlive"]()){Module["PThread"].setExitStatus(result)}else{Module["PThread"].threadExit(result)}}catch(ex){if(ex==="Canceled!"){Module["PThread"].threadCancel()}else if(ex!="unwind"){if(ex instanceof Module["ExitStatus"]){if(Module["keepRuntimeAlive"]()){}else{Module["PThread"].threadExit(ex.status)}}else{Module["PThread"].threadExit(-2);throw ex}}}}else if(e.data.cmd==="cancel"){if(Module["_pthread_self"]()){Module["PThread"].threadCancel()}}else if(e.data.target==="setimmediate"){}else if(e.data.cmd==="processThreadQueue"){if(Module["_pthread_self"]()){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}}; "use strict";var Module={};var initializedJS=false;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:Module["_pthread_self"]()})}var err=threadPrintErr;self.alert=threadAlert;function moduleLoaded(){}self.onmessage=function(e){try{if(e.data.cmd==="load"){var imports={};imports["wasm"]=e.data.wasmModule;imports["wasmMemory"]=e.data.wasmMemory;imports["buffer"]=imports["wasmMemory"].buffer;imports["ENVIRONMENT_IS_PTHREAD"]=true;(e.data.urlOrBlob?import(e.data.urlOrBlob):import("./jxl_enc_mt_simd.js")).then(function(exports){return exports.default(Module)}).then(function(instance){Module=instance;moduleLoaded()})}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;Module["__emscripten_thread_init"](e.data.threadInfoStruct,0,0);var max=e.data.stackBase;var top=e.data.stackBase+e.data.stackSize;Module["establishStackSpace"](top,max);Module["PThread"].receiveObjectTransfer(e.data);Module["PThread"].threadInit();if(!initializedJS){Module["___embind_register_native_and_builtin_types"]();initializedJS=true}try{var result=Module["invokeEntryPoint"](e.data.start_routine,e.data.arg);Module["PThread"].threadExit(result)}catch(ex){if(ex==="Canceled!"){Module["PThread"].threadCancel()}else if(ex!="unwind"){{Module["PThread"].threadExit(-2);throw ex}}}}else if(e.data.cmd==="cancel"){if(Module["_pthread_self"]()){Module["PThread"].threadCancel()}}else if(e.data.target==="setimmediate"){}else if(e.data.cmd==="processThreadQueue"){if(Module["_pthread_self"]()){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}};

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@@ -1 +1 @@
"use strict";var Module={};var initializedJS=false;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:Module["_pthread_self"]()})}var err=threadPrintErr;self.alert=threadAlert;Module["instantiateWasm"]=function(info,receiveInstance){var instance=new WebAssembly.Instance(Module["wasmModule"],info);receiveInstance(instance);Module["wasmModule"]=null;return instance.exports};function moduleLoaded(){}self.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;(e.data.urlOrBlob?import(e.data.urlOrBlob):import("./wp2_enc_mt.js")).then(function(exports){return exports.default(Module)}).then(function(instance){Module=instance;moduleLoaded()})}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;Module["__emscripten_thread_init"](e.data.threadInfoStruct,0,0);var max=e.data.stackBase;var top=e.data.stackBase+e.data.stackSize;Module["establishStackSpace"](top,max);Module["PThread"].receiveObjectTransfer(e.data);Module["PThread"].threadInit();if(!initializedJS){Module["___embind_register_native_and_builtin_types"]();initializedJS=true}try{var result=Module["invokeEntryPoint"](e.data.start_routine,e.data.arg);if(Module["keepRuntimeAlive"]()){Module["PThread"].setExitStatus(result)}else{Module["PThread"].threadExit(result)}}catch(ex){if(ex==="Canceled!"){Module["PThread"].threadCancel()}else if(ex!="unwind"){if(ex instanceof Module["ExitStatus"]){if(Module["keepRuntimeAlive"]()){}else{Module["PThread"].threadExit(ex.status)}}else{Module["PThread"].threadExit(-2);throw ex}}}}else if(e.data.cmd==="cancel"){if(Module["_pthread_self"]()){Module["PThread"].threadCancel()}}else if(e.data.target==="setimmediate"){}else if(e.data.cmd==="processThreadQueue"){if(Module["_pthread_self"]()){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}}; "use strict";var Module={};var initializedJS=false;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:Module["_pthread_self"]()})}var err=threadPrintErr;self.alert=threadAlert;function moduleLoaded(){}self.onmessage=function(e){try{if(e.data.cmd==="load"){var imports={};imports["wasm"]=e.data.wasmModule;imports["wasmMemory"]=e.data.wasmMemory;imports["buffer"]=imports["wasmMemory"].buffer;imports["ENVIRONMENT_IS_PTHREAD"]=true;(e.data.urlOrBlob?import(e.data.urlOrBlob):import("./wp2_enc_mt.js")).then(function(exports){return exports.default(Module)}).then(function(instance){Module=instance;moduleLoaded()})}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;Module["__emscripten_thread_init"](e.data.threadInfoStruct,0,0);var max=e.data.stackBase;var top=e.data.stackBase+e.data.stackSize;Module["establishStackSpace"](top,max);Module["PThread"].receiveObjectTransfer(e.data);Module["PThread"].threadInit();if(!initializedJS){Module["___embind_register_native_and_builtin_types"]();initializedJS=true}try{var result=Module["invokeEntryPoint"](e.data.start_routine,e.data.arg);Module["PThread"].threadExit(result)}catch(ex){if(ex==="Canceled!"){Module["PThread"].threadCancel()}else if(ex!="unwind"){{Module["PThread"].threadExit(-2);throw ex}}}}else if(e.data.cmd==="cancel"){if(Module["_pthread_self"]()){Module["PThread"].threadCancel()}}else if(e.data.target==="setimmediate"){}else if(e.data.cmd==="processThreadQueue"){if(Module["_pthread_self"]()){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}};

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@@ -1 +1 @@
"use strict";var Module={};var initializedJS=false;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:Module["_pthread_self"]()})}var err=threadPrintErr;self.alert=threadAlert;Module["instantiateWasm"]=function(info,receiveInstance){var instance=new WebAssembly.Instance(Module["wasmModule"],info);receiveInstance(instance);Module["wasmModule"]=null;return instance.exports};function moduleLoaded(){}self.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;(e.data.urlOrBlob?import(e.data.urlOrBlob):import("./wp2_enc_mt_simd.js")).then(function(exports){return exports.default(Module)}).then(function(instance){Module=instance;moduleLoaded()})}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;Module["__emscripten_thread_init"](e.data.threadInfoStruct,0,0);var max=e.data.stackBase;var top=e.data.stackBase+e.data.stackSize;Module["establishStackSpace"](top,max);Module["PThread"].receiveObjectTransfer(e.data);Module["PThread"].threadInit();if(!initializedJS){Module["___embind_register_native_and_builtin_types"]();initializedJS=true}try{var result=Module["invokeEntryPoint"](e.data.start_routine,e.data.arg);if(Module["keepRuntimeAlive"]()){Module["PThread"].setExitStatus(result)}else{Module["PThread"].threadExit(result)}}catch(ex){if(ex==="Canceled!"){Module["PThread"].threadCancel()}else if(ex!="unwind"){if(ex instanceof Module["ExitStatus"]){if(Module["keepRuntimeAlive"]()){}else{Module["PThread"].threadExit(ex.status)}}else{Module["PThread"].threadExit(-2);throw ex}}}}else if(e.data.cmd==="cancel"){if(Module["_pthread_self"]()){Module["PThread"].threadCancel()}}else if(e.data.target==="setimmediate"){}else if(e.data.cmd==="processThreadQueue"){if(Module["_pthread_self"]()){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}}; "use strict";var Module={};var initializedJS=false;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:Module["_pthread_self"]()})}var err=threadPrintErr;self.alert=threadAlert;function moduleLoaded(){}self.onmessage=function(e){try{if(e.data.cmd==="load"){var imports={};imports["wasm"]=e.data.wasmModule;imports["wasmMemory"]=e.data.wasmMemory;imports["buffer"]=imports["wasmMemory"].buffer;imports["ENVIRONMENT_IS_PTHREAD"]=true;(e.data.urlOrBlob?import(e.data.urlOrBlob):import("./wp2_enc_mt_simd.js")).then(function(exports){return exports.default(Module)}).then(function(instance){Module=instance;moduleLoaded()})}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;Module["__emscripten_thread_init"](e.data.threadInfoStruct,0,0);var max=e.data.stackBase;var top=e.data.stackBase+e.data.stackSize;Module["establishStackSpace"](top,max);Module["PThread"].receiveObjectTransfer(e.data);Module["PThread"].threadInit();if(!initializedJS){Module["___embind_register_native_and_builtin_types"]();initializedJS=true}try{var result=Module["invokeEntryPoint"](e.data.start_routine,e.data.arg);Module["PThread"].threadExit(result)}catch(ex){if(ex==="Canceled!"){Module["PThread"].threadCancel()}else if(ex!="unwind"){{Module["PThread"].threadExit(-2);throw ex}}}}else if(e.data.cmd==="cancel"){if(Module["_pthread_self"]()){Module["PThread"].threadCancel()}}else if(e.data.target==="setimmediate"){}else if(e.data.cmd==="processThreadQueue"){if(Module["_pthread_self"]()){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}};

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@@ -20,7 +20,6 @@ const allSrcPlaceholder = 'CLIENT_BUNDLE_PLUGIN_ALL_SRC';
export function getDependencies(clientOutput, item) { export function getDependencies(clientOutput, item) {
const crawlDependencies = new Set([item.fileName]); const crawlDependencies = new Set([item.fileName]);
const referencedFiles = new Set();
for (const fileName of crawlDependencies) { for (const fileName of crawlDependencies) {
const chunk = clientOutput.find((v) => v.fileName === fileName); const chunk = clientOutput.find((v) => v.fileName === fileName);
@@ -28,24 +27,11 @@ export function getDependencies(clientOutput, item) {
for (const dep of chunk.imports) { for (const dep of chunk.imports) {
crawlDependencies.add(dep); crawlDependencies.add(dep);
} }
for (const dep of chunk.referencedFiles) {
referencedFiles.add(dep);
}
} }
// Don't add self as dependency // Don't add self as dependency
crawlDependencies.delete(item.fileName); crawlDependencies.delete(item.fileName);
// Merge referencedFiles as regular deps. They need to be in the same Set as
// some JS files might appear in both lists and need to be deduped too.
//
// Didn't do this as part of the main loop since their `chunk` can't have
// nested deps and sometimes might be missing altogether, depending on type.
for (const dep of referencedFiles) {
crawlDependencies.add(dep);
}
return [...crawlDependencies]; return [...crawlDependencies];
} }
@@ -153,9 +139,9 @@ export default function (inputOptions, outputOptions, resolveFileUrl) {
if (property.startsWith(allSrcPlaceholder)) { if (property.startsWith(allSrcPlaceholder)) {
const allModules = [ const allModules = [
clientEntry, clientEntry,
...dependencies ...dependencies.map((name) =>
.map((name) => clientOutput.find((item) => item.fileName === name)) clientOutput.find((item) => item.fileName === name),
.filter((item) => item.code), ),
]; ];
const inlineDefines = [ const inlineDefines = [

View File

@@ -17,14 +17,10 @@ const prefix = 'entry-data:';
const mainNamePlaceholder = 'ENTRY_DATA_PLUGIN_MAIN_NAME'; const mainNamePlaceholder = 'ENTRY_DATA_PLUGIN_MAIN_NAME';
const dependenciesPlaceholder = 'ENTRY_DATA_PLUGIN_DEPS'; const dependenciesPlaceholder = 'ENTRY_DATA_PLUGIN_DEPS';
const placeholderRe = /(ENTRY_DATA_PLUGIN_(?:MAIN_NAME|DEPS))(\d+)/g; const placeholderRe = /(ENTRY_DATA_PLUGIN_(?:MAIN_NAME|DEPS))(\d+)/g;
const filenamePrefix = 'static/';
/** @param {string} fileName */
export function fileNameToURL(fileName) {
return fileName.replace(/^static\//, '/');
}
export default function entryDataPlugin() { export default function entryDataPlugin() {
/** @type {number} */ /** @type {string} */
let exportCounter; let exportCounter;
/** @type {Map<number, string>} */ /** @type {Map<number, string>} */
let counterToIdMap; let counterToIdMap;
@@ -73,11 +69,15 @@ export default function entryDataPlugin() {
if (!chunk) throw Error(`Cannot find ${id}`); if (!chunk) throw Error(`Cannot find ${id}`);
if (placeholder === mainNamePlaceholder) { if (placeholder === mainNamePlaceholder) {
return JSON.stringify(fileNameToURL(chunk.fileName)); return JSON.stringify(
chunk.fileName.slice(filenamePrefix.length),
);
} }
return JSON.stringify( return JSON.stringify(
getDependencies(chunks, chunk).map((filename) => fileNameToURL(filename)), getDependencies(chunks, chunk).map((item) =>
item.slice(filenamePrefix.length),
),
); );
}, },
); );

5
missing-types.d.ts vendored
View File

@@ -44,11 +44,6 @@ declare module 'data-url:*' {
export default url; export default url;
} }
declare module 'service-worker:*' {
const url: string;
export default url;
}
declare var ga: { declare var ga: {
(...args: any[]): void; (...args: any[]): void;
q: any[]; q: any[];

12
package-lock.json generated
View File

@@ -8976,9 +8976,9 @@
} }
}, },
"@surma/rollup-plugin-off-main-thread": { "@surma/rollup-plugin-off-main-thread": {
"version": "2.2.2", "version": "2.2.1",
"resolved": "https://registry.npmjs.org/@surma/rollup-plugin-off-main-thread/-/rollup-plugin-off-main-thread-2.2.2.tgz", "resolved": "https://registry.npmjs.org/@surma/rollup-plugin-off-main-thread/-/rollup-plugin-off-main-thread-2.2.1.tgz",
"integrity": "sha512-dOD6nGZ79RmWKDRQuC7SOGXMvDkkLwBogu+epfVFMKiy2kOUtLZkb8wV/ettuMt37YJAJKYCKUmxSbZL2LkUQg==", "integrity": "sha512-7OU8wfyv18YPWVmecg2/0Jh+pm3lQbvPhIWHd1YQpoxPKPW/vsDNGBaCnMKsZbz29RjgCoXKugAjyagPncgdEw==",
"dev": true, "dev": true,
"requires": { "requires": {
"ejs": "^3.1.6", "ejs": "^3.1.6",
@@ -15980,9 +15980,9 @@
"dev": true "dev": true
}, },
"wasm-feature-detect": { "wasm-feature-detect": {
"version": "1.2.11", "version": "1.2.9",
"resolved": "https://registry.npmjs.org/wasm-feature-detect/-/wasm-feature-detect-1.2.11.tgz", "resolved": "https://registry.npmjs.org/wasm-feature-detect/-/wasm-feature-detect-1.2.9.tgz",
"integrity": "sha512-HUqwaodrQGaZgz1lZaNioIkog9tkeEJjrM3eq4aUL04whXOVDRc/o2EGb/8kV0QX411iAYWEqq7fMBmJ6dKS6w==" "integrity": "sha512-2E9/gtLVLpv2wnZDyYv8WY2dR9gHbmyv5uhZsnOcMSzqc78aGZpKQORPNcnrPwAU23nFUo7GAwKuoTAWRgsJ7Q=="
}, },
"which": { "which": {
"version": "2.0.2", "version": "2.0.2",

View File

@@ -14,7 +14,7 @@
"@rollup/plugin-commonjs": "^17.0.0", "@rollup/plugin-commonjs": "^17.0.0",
"@rollup/plugin-node-resolve": "^11.1.0", "@rollup/plugin-node-resolve": "^11.1.0",
"@rollup/plugin-replace": "^2.3.4", "@rollup/plugin-replace": "^2.3.4",
"@surma/rollup-plugin-off-main-thread": "^2.2.2", "@surma/rollup-plugin-off-main-thread": "^2.2.1",
"@types/dedent": "^0.7.0", "@types/dedent": "^0.7.0",
"@types/mime-types": "^2.1.0", "@types/mime-types": "^2.1.0",
"@types/node": "^14.14.7", "@types/node": "^14.14.7",
@@ -58,6 +58,6 @@
"*.rs": "rustfmt" "*.rs": "rustfmt"
}, },
"dependencies": { "dependencies": {
"wasm-feature-detect": "^1.2.11" "wasm-feature-detect": "^1.2.9"
} }
} }

View File

@@ -18,7 +18,6 @@ import commonjs from '@rollup/plugin-commonjs';
import { terser } from 'rollup-plugin-terser'; import { terser } from 'rollup-plugin-terser';
import OMT from '@surma/rollup-plugin-off-main-thread'; import OMT from '@surma/rollup-plugin-off-main-thread';
import replace from '@rollup/plugin-replace'; import replace from '@rollup/plugin-replace';
import { importMetaAssets } from '@web/rollup-plugin-import-meta-assets';
import simpleTS from './lib/simple-ts'; import simpleTS from './lib/simple-ts';
import clientBundlePlugin from './lib/client-bundle-plugin'; import clientBundlePlugin from './lib/client-bundle-plugin';
@@ -32,11 +31,11 @@ import featurePlugin from './lib/feature-plugin';
import initialCssPlugin from './lib/initial-css-plugin'; import initialCssPlugin from './lib/initial-css-plugin';
import serviceWorkerPlugin from './lib/sw-plugin'; import serviceWorkerPlugin from './lib/sw-plugin';
import dataURLPlugin from './lib/data-url-plugin'; import dataURLPlugin from './lib/data-url-plugin';
import entryDataPlugin, { fileNameToURL } from './lib/entry-data-plugin';
import dedent from 'dedent'; import dedent from 'dedent';
import entryDataPlugin from './lib/entry-data-plugin';
function resolveFileUrl({ fileName }) { function resolveFileUrl({ fileName }) {
return JSON.stringify(fileNameToURL(fileName)); return JSON.stringify(fileName.replace(/^static\//, '/'));
} }
function resolveImportMetaUrlInStaticBuild(property, { moduleId }) { function resolveImportMetaUrlInStaticBuild(property, { moduleId }) {
@@ -71,7 +70,7 @@ export default async function ({ watch }) {
await del('.tmp/build'); await del('.tmp/build');
const isProduction = !watch; const isProduction = !watch && !process.env.DEBUG;
const tsPluginInstance = simpleTS('.', { const tsPluginInstance = simpleTS('.', {
watch, watch,
@@ -119,7 +118,6 @@ export default async function ({ watch }) {
plugins: [ plugins: [
{ resolveFileUrl }, { resolveFileUrl },
OMT({ loader: await omtLoaderPromise }), OMT({ loader: await omtLoaderPromise }),
importMetaAssets(),
serviceWorkerPlugin({ serviceWorkerPlugin({
output: 'static/serviceworker.js', output: 'static/serviceworker.js',
}), }),

View File

@@ -19,4 +19,9 @@ interface Navigator {
declare module 'add-css:*' {} declare module 'add-css:*' {}
declare module 'service-worker:*' {
const url: string;
export default url;
}
declare module 'preact/debug' {} declare module 'preact/debug' {}

View File

@@ -11,6 +11,7 @@
* limitations under the License. * limitations under the License.
*/ */
import type { AVIFModule } from 'codecs/avif/dec/avif_dec'; import type { AVIFModule } from 'codecs/avif/dec/avif_dec';
import wasmUrl from 'url:codecs/avif/dec/avif_dec.wasm';
import { initEmscriptenModule, blobToArrayBuffer } from 'features/worker-utils'; import { initEmscriptenModule, blobToArrayBuffer } from 'features/worker-utils';
let emscriptenModule: Promise<AVIFModule>; let emscriptenModule: Promise<AVIFModule>;
@@ -18,7 +19,7 @@ let emscriptenModule: Promise<AVIFModule>;
export default async function decode(blob: Blob): Promise<ImageData> { export default async function decode(blob: Blob): Promise<ImageData> {
if (!emscriptenModule) { if (!emscriptenModule) {
const decoder = await import('codecs/avif/dec/avif_dec'); const decoder = await import('codecs/avif/dec/avif_dec');
emscriptenModule = initEmscriptenModule(decoder.default); emscriptenModule = initEmscriptenModule(decoder.default, wasmUrl);
} }
const [module, data] = await Promise.all([ const [module, data] = await Promise.all([

View File

@@ -11,13 +11,14 @@
* limitations under the License. * limitations under the License.
*/ */
import jxlDecoder, { JXLModule } from 'codecs/jxl/dec/jxl_dec'; import jxlDecoder, { JXLModule } from 'codecs/jxl/dec/jxl_dec';
import wasmUrl from 'url:codecs/jxl/dec/jxl_dec.wasm';
import { initEmscriptenModule, blobToArrayBuffer } from 'features/worker-utils'; import { initEmscriptenModule, blobToArrayBuffer } from 'features/worker-utils';
let emscriptenModule: Promise<JXLModule>; let emscriptenModule: Promise<JXLModule>;
export default async function decode(blob: Blob): Promise<ImageData> { export default async function decode(blob: Blob): Promise<ImageData> {
if (!emscriptenModule) { if (!emscriptenModule) {
emscriptenModule = initEmscriptenModule(jxlDecoder); emscriptenModule = initEmscriptenModule(jxlDecoder, wasmUrl);
} }
const [module, data] = await Promise.all([ const [module, data] = await Promise.all([

View File

@@ -11,6 +11,7 @@
* limitations under the License. * limitations under the License.
*/ */
import type { WebPModule } from 'codecs/webp/dec/webp_dec'; import type { WebPModule } from 'codecs/webp/dec/webp_dec';
import wasmUrl from 'url:codecs/webp/dec/webp_dec.wasm';
import { initEmscriptenModule, blobToArrayBuffer } from 'features/worker-utils'; import { initEmscriptenModule, blobToArrayBuffer } from 'features/worker-utils';
let emscriptenModule: Promise<WebPModule>; let emscriptenModule: Promise<WebPModule>;
@@ -18,7 +19,7 @@ let emscriptenModule: Promise<WebPModule>;
export default async function decode(blob: Blob): Promise<ImageData> { export default async function decode(blob: Blob): Promise<ImageData> {
if (!emscriptenModule) { if (!emscriptenModule) {
const decoder = await import('codecs/webp/dec/webp_dec'); const decoder = await import('codecs/webp/dec/webp_dec');
emscriptenModule = initEmscriptenModule(decoder.default); emscriptenModule = initEmscriptenModule(decoder.default, wasmUrl);
} }
const [module, data] = await Promise.all([ const [module, data] = await Promise.all([

View File

@@ -11,13 +11,14 @@
* limitations under the License. * limitations under the License.
*/ */
import wp2Decoder, { WP2Module } from 'codecs/wp2/dec/wp2_dec'; import wp2Decoder, { WP2Module } from 'codecs/wp2/dec/wp2_dec';
import wasmUrl from 'url:codecs/wp2/dec/wp2_dec.wasm';
import { initEmscriptenModule, blobToArrayBuffer } from 'features/worker-utils'; import { initEmscriptenModule, blobToArrayBuffer } from 'features/worker-utils';
let emscriptenModule: Promise<WP2Module>; let emscriptenModule: Promise<WP2Module>;
export default async function decode(blob: Blob): Promise<ImageData> { export default async function decode(blob: Blob): Promise<ImageData> {
if (!emscriptenModule) { if (!emscriptenModule) {
emscriptenModule = initEmscriptenModule(wp2Decoder); emscriptenModule = initEmscriptenModule(wp2Decoder, wasmUrl);
} }
const [module, data] = await Promise.all([ const [module, data] = await Promise.all([

View File

@@ -12,6 +12,9 @@
*/ */
import type { AVIFModule } from 'codecs/avif/enc/avif_enc'; import type { AVIFModule } from 'codecs/avif/enc/avif_enc';
import type { EncodeOptions } from '../shared/meta'; import type { EncodeOptions } from '../shared/meta';
import wasmUrlWithoutMT from 'url:codecs/avif/enc/avif_enc.wasm';
import wasmUrlWithMT from 'url:codecs/avif/enc/avif_enc_mt.wasm';
import workerUrl from 'omt:codecs/avif/enc/avif_enc_mt.worker.js';
import { initEmscriptenModule } from 'features/worker-utils'; import { initEmscriptenModule } from 'features/worker-utils';
import { threads } from 'wasm-feature-detect'; import { threads } from 'wasm-feature-detect';
@@ -20,10 +23,14 @@ let emscriptenModule: Promise<AVIFModule>;
async function init() { async function init() {
if (await threads()) { if (await threads()) {
const avifEncoder = await import('codecs/avif/enc/avif_enc_mt'); const avifEncoder = await import('codecs/avif/enc/avif_enc_mt');
return initEmscriptenModule<AVIFModule>(avifEncoder.default); return initEmscriptenModule<AVIFModule>(
avifEncoder.default,
wasmUrlWithMT,
workerUrl,
);
} }
const avifEncoder = await import('codecs/avif/enc/avif_enc.js'); const avifEncoder = await import('codecs/avif/enc/avif_enc.js');
return initEmscriptenModule(avifEncoder.default); return initEmscriptenModule(avifEncoder.default, wasmUrlWithoutMT);
} }
export default async function encode( export default async function encode(

View File

@@ -16,19 +16,31 @@ import type { EncodeOptions } from '../shared/meta';
import { initEmscriptenModule } from 'features/worker-utils'; import { initEmscriptenModule } from 'features/worker-utils';
import { threads, simd } from 'wasm-feature-detect'; import { threads, simd } from 'wasm-feature-detect';
import wasmUrl from 'url:codecs/jxl/enc/jxl_enc.wasm';
import wasmUrlWithMT from 'url:codecs/jxl/enc/jxl_enc_mt.wasm';
import workerUrl from 'omt:codecs/jxl/enc/jxl_enc_mt.worker.js';
import wasmUrlWithMTAndSIMD from 'url:codecs/jxl/enc/jxl_enc_mt_simd.wasm';
import workerUrlWithSIMD from 'omt:codecs/jxl/enc/jxl_enc_mt_simd.worker.js';
let emscriptenModule: Promise<JXLModule>; let emscriptenModule: Promise<JXLModule>;
async function init() { async function init() {
if (await threads()) { if (await threads()) {
if (await simd()) { if (await simd()) {
const jxlEncoder = await import('codecs/jxl/enc/jxl_enc_mt_simd'); const jxlEncoder = await import('codecs/jxl/enc/jxl_enc_mt_simd');
return initEmscriptenModule(jxlEncoder.default); return initEmscriptenModule(
jxlEncoder.default,
wasmUrlWithMTAndSIMD,
workerUrlWithSIMD,
);
} }
const jxlEncoder = await import('codecs/jxl/enc/jxl_enc_mt'); const jxlEncoder = await import('codecs/jxl/enc/jxl_enc_mt');
return initEmscriptenModule(jxlEncoder.default); return initEmscriptenModule(jxlEncoder.default, wasmUrlWithMT, workerUrl);
} }
const jxlEncoder = await import('codecs/jxl/enc/jxl_enc'); const jxlEncoder = await import('codecs/jxl/enc/jxl_enc');
return initEmscriptenModule(jxlEncoder.default); return initEmscriptenModule(jxlEncoder.default, wasmUrl);
} }
export default async function encode( export default async function encode(

View File

@@ -12,6 +12,7 @@
*/ */
import mozjpeg_enc, { MozJPEGModule } from 'codecs/mozjpeg/enc/mozjpeg_enc'; import mozjpeg_enc, { MozJPEGModule } from 'codecs/mozjpeg/enc/mozjpeg_enc';
import { EncodeOptions } from '../shared/meta'; import { EncodeOptions } from '../shared/meta';
import wasmUrl from 'url:codecs/mozjpeg/enc/mozjpeg_enc.wasm';
import { initEmscriptenModule } from 'features/worker-utils'; import { initEmscriptenModule } from 'features/worker-utils';
let emscriptenModule: Promise<MozJPEGModule>; let emscriptenModule: Promise<MozJPEGModule>;
@@ -21,7 +22,7 @@ export default async function encode(
options: EncodeOptions, options: EncodeOptions,
): Promise<ArrayBuffer> { ): Promise<ArrayBuffer> {
if (!emscriptenModule) { if (!emscriptenModule) {
emscriptenModule = initEmscriptenModule(mozjpeg_enc); emscriptenModule = initEmscriptenModule(mozjpeg_enc, wasmUrl);
} }
const module = await emscriptenModule; const module = await emscriptenModule;

View File

@@ -10,27 +10,30 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import initOxiWasmST, {
optimise as optimiseST,
} from 'codecs/oxipng/pkg/squoosh_oxipng';
import initOxiWasmMT, {
initThreadPool,
optimise as optimiseMT,
} from 'codecs/oxipng/pkg-parallel/squoosh_oxipng';
import oxiWasmUrlST from 'url:codecs/oxipng/pkg/squoosh_oxipng_bg.wasm';
import oxiWasmUrlMT from 'url:codecs/oxipng/pkg-parallel/squoosh_oxipng_bg.wasm';
import { EncodeOptions } from '../shared/meta'; import { EncodeOptions } from '../shared/meta';
import { threads } from 'wasm-feature-detect'; import { threads } from 'wasm-feature-detect';
async function initMT() { async function initMT() {
const { default: init, initThreadPool, optimise } = await import( await initOxiWasmMT(oxiWasmUrlMT);
'codecs/oxipng/pkg-parallel/squoosh_oxipng'
);
await init();
await initThreadPool(navigator.hardwareConcurrency); await initThreadPool(navigator.hardwareConcurrency);
return optimise; return optimiseMT;
} }
async function initST() { async function initST() {
const { default: init, optimise } = await import( await initOxiWasmST(oxiWasmUrlST);
'codecs/oxipng/pkg/squoosh_oxipng' return optimiseST;
);
await init();
return optimise;
} }
let wasmReady: ReturnType<typeof initMT | typeof initST>; let wasmReady: Promise<typeof optimiseMT | typeof optimiseST>;
export default async function encode( export default async function encode(
data: ArrayBuffer, data: ArrayBuffer,

View File

@@ -16,15 +16,18 @@ import type { EncodeOptions } from '../shared/meta';
import { initEmscriptenModule } from 'features/worker-utils'; import { initEmscriptenModule } from 'features/worker-utils';
import { simd } from 'wasm-feature-detect'; import { simd } from 'wasm-feature-detect';
import wasmUrl from 'url:codecs/webp/enc/webp_enc.wasm';
import wasmUrlWithSIMD from 'url:codecs/webp/enc/webp_enc_simd.wasm';
let emscriptenModule: Promise<WebPModule>; let emscriptenModule: Promise<WebPModule>;
async function init() { async function init() {
if (await simd()) { if (await simd()) {
const webpEncoder = await import('codecs/webp/enc/webp_enc_simd'); const webpEncoder = await import('codecs/webp/enc/webp_enc_simd');
return initEmscriptenModule(webpEncoder.default); return initEmscriptenModule(webpEncoder.default, wasmUrlWithSIMD);
} }
const webpEncoder = await import('codecs/webp/enc/webp_enc'); const webpEncoder = await import('codecs/webp/enc/webp_enc');
return initEmscriptenModule(webpEncoder.default); return initEmscriptenModule(webpEncoder.default, wasmUrl);
} }
export default async function encode( export default async function encode(

View File

@@ -16,19 +16,31 @@ import type { EncodeOptions } from '../shared/meta';
import { initEmscriptenModule } from 'features/worker-utils'; import { initEmscriptenModule } from 'features/worker-utils';
import { threads, simd } from 'wasm-feature-detect'; import { threads, simd } from 'wasm-feature-detect';
import wasmUrl from 'url:codecs/wp2/enc/wp2_enc.wasm';
import wasmUrlWithMT from 'url:codecs/wp2/enc/wp2_enc_mt.wasm';
import workerUrl from 'omt:codecs/wp2/enc/wp2_enc_mt.worker.js';
import wasmUrlWithMTAndSIMD from 'url:codecs/wp2/enc/wp2_enc_mt_simd.wasm';
import workerUrlWithSIMD from 'omt:codecs/wp2/enc/wp2_enc_mt_simd.worker.js';
let emscriptenModule: Promise<WP2Module>; let emscriptenModule: Promise<WP2Module>;
async function init() { async function init() {
if (await threads()) { if (await threads()) {
if (await simd()) { if (await simd()) {
const wp2Encoder = await import('codecs/wp2/enc/wp2_enc_mt_simd'); const wp2Encoder = await import('codecs/wp2/enc/wp2_enc_mt_simd');
return initEmscriptenModule(wp2Encoder.default); return initEmscriptenModule(
wp2Encoder.default,
wasmUrlWithMTAndSIMD,
workerUrlWithSIMD,
);
} }
const wp2Encoder = await import('codecs/wp2/enc/wp2_enc_mt'); const wp2Encoder = await import('codecs/wp2/enc/wp2_enc_mt');
return initEmscriptenModule(wp2Encoder.default); return initEmscriptenModule(wp2Encoder.default, wasmUrlWithMT, workerUrl);
} }
const wp2Encoder = await import('codecs/wp2/enc/wp2_enc'); const wp2Encoder = await import('codecs/wp2/enc/wp2_enc');
return initEmscriptenModule(wp2Encoder.default); return initEmscriptenModule(wp2Encoder.default, wasmUrl);
} }
export default async function encode( export default async function encode(

View File

@@ -11,6 +11,7 @@
* limitations under the License. * limitations under the License.
*/ */
import imagequant, { QuantizerModule } from 'codecs/imagequant/imagequant'; import imagequant, { QuantizerModule } from 'codecs/imagequant/imagequant';
import wasmUrl from 'url:codecs/imagequant/imagequant.wasm';
import { initEmscriptenModule } from 'features/worker-utils'; import { initEmscriptenModule } from 'features/worker-utils';
import { Options } from '../shared/meta'; import { Options } from '../shared/meta';
@@ -21,7 +22,7 @@ export default async function process(
opts: Options, opts: Options,
): Promise<ImageData> { ): Promise<ImageData> {
if (!emscriptenModule) { if (!emscriptenModule) {
emscriptenModule = initEmscriptenModule(imagequant); emscriptenModule = initEmscriptenModule(imagequant, wasmUrl);
} }
const module = await emscriptenModule; const module = await emscriptenModule;

View File

@@ -1,6 +1,8 @@
import type { WorkerResizeOptions } from '../shared/meta'; import type { WorkerResizeOptions } from '../shared/meta';
import { getContainOffsets } from '../shared/util'; import { getContainOffsets } from '../shared/util';
import initResizeWasm, { resize as wasmResize } from 'codecs/resize/pkg'; import initResizeWasm, { resize as wasmResize } from 'codecs/resize/pkg';
import resizeWasmUrl from 'url:codecs/resize/pkg/squoosh_resize_bg.wasm';
import hqxWasmUrl from 'url:codecs/hqx/pkg/squooshhqx_bg.wasm';
import initHqxWasm, { resize as wasmHqx } from 'codecs/hqx/pkg'; import initHqxWasm, { resize as wasmHqx } from 'codecs/hqx/pkg';
interface HqxResizeOptions extends WorkerResizeOptions { interface HqxResizeOptions extends WorkerResizeOptions {
@@ -61,7 +63,7 @@ async function hqx(
opts: HqxResizeOptions, opts: HqxResizeOptions,
): Promise<ImageData> { ): Promise<ImageData> {
if (!hqxWasmReady) { if (!hqxWasmReady) {
hqxWasmReady = initHqxWasm(); hqxWasmReady = initHqxWasm(hqxWasmUrl);
} }
await hqxWasmReady; await hqxWasmReady;
@@ -94,7 +96,7 @@ export default async function resize(
let input = data; let input = data;
if (!resizeWasmReady) { if (!resizeWasmReady) {
resizeWasmReady = initResizeWasm(); resizeWasmReady = initResizeWasm(resizeWasmUrl);
} }
if (optsIsHqxOpts(opts)) { if (optsIsHqxOpts(opts)) {

View File

@@ -10,12 +10,38 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
export function initEmscriptenModule<T extends EmscriptenWasm.Module>(
// @ts-ignore
self.asm = ''; // lol
// @ts-ignore
self.UTF32ToString = (...v) => console.log("u322s", v); //v => [...new Uint32Array(v)].map(v => String.fromCharCode(v)).join("")
// @ts-ignore
self.stringToUTF32 = (...v) => console.log("s2u32", v); //v => [...new Uint32Array(v)].map(v => String.fromCharCode(v)).join("")
// @ts-ignore
self.lengthBytesUTF32 = (...v) => console.log("lb32", v); //v => [...new Uint32Array(v)].map(v => String.fromCharCode(v)).join("")
// @ts-ignore
self.UTF16ToString = (...v) => console.log("u162s", v); //v => [...new Uint32Array(v)].map(v => String.fromCharCode(v)).join("")
// @ts-ignore
self.stringToUTF16 = (...v) => console.log("s2u16", v); //v => [...new Uint32Array(v)].map(v => String.fromCharCode(v)).join("")
// @ts-ignore
self.lengthBytesUTF16 = (...v) => console.log("lb16", v); //v => [...new Uint32Array(v)].map(v => String.fromCharCode(v)).join("")
export async function initEmscriptenModule<T extends EmscriptenWasm.Module>(
moduleFactory: EmscriptenWasm.ModuleFactory<T>, moduleFactory: EmscriptenWasm.ModuleFactory<T>,
wasmUrl: string,
workerUrl?: string,
): Promise<T> { ): Promise<T> {
return moduleFactory({ return moduleFactory({
// @ts-ignore
wasm: await fetch(wasmUrl).then(r => r.arrayBuffer()),
// Just to be safe, don't automatically invoke any wasm functions // Just to be safe, don't automatically invoke any wasm functions
noInitialRun: true, noInitialRun: true,
locateFile: (url: string) => {
// This is probably unused?
console.log("CALL TO LOCATEFILE", url);
if (url.endsWith('.wasm')) return wasmUrl;
if (url.endsWith('.worker.js')) return workerUrl!;
throw Error('Unknown url in locateFile ' + url);
},
}); });
} }

View File

@@ -7,7 +7,6 @@ import {
serveShareTarget, serveShareTarget,
} from './util'; } from './util';
import { get } from 'idb-keyval'; import { get } from 'idb-keyval';
import { shouldCacheDynamically } from './to-cache';
// Give TypeScript the correct global. // Give TypeScript the correct global.
declare var self: ServiceWorkerGlobalScope; declare var self: ServiceWorkerGlobalScope;
@@ -71,7 +70,7 @@ self.addEventListener('fetch', (event) => {
// We only care about GET from here on in. // We only care about GET from here on in.
if (event.request.method !== 'GET') return; if (event.request.method !== 'GET') return;
if (shouldCacheDynamically(url.pathname)) { if (url.pathname.startsWith('/c/demo-')) {
cacheOrNetworkAndCache(event, dynamicCache); cacheOrNetworkAndCache(event, dynamicCache);
cleanupCache(event, dynamicCache, ASSETS); cleanupCache(event, dynamicCache, ASSETS);
return; return;

View File

@@ -13,46 +13,18 @@ function subtractSets<T extends any>(set1: Set<T>, set2: Set<T>): Set<T> {
// Initial app stuff // Initial app stuff
import * as initialApp from 'entry-data:client/initial-app'; import * as initialApp from 'entry-data:client/initial-app';
import swUrl from 'service-worker:sw';
import * as compress from 'entry-data:client/lazy-app/Compress'; import * as compress from 'entry-data:client/lazy-app/Compress';
import * as swBridge from 'entry-data:client/lazy-app/sw-bridge'; import * as swBridge from 'entry-data:client/lazy-app/sw-bridge';
import * as blobAnim from 'entry-data:shared/prerendered-app/Intro/blob-anim'; import * as blobAnim from 'entry-data:shared/prerendered-app/Intro/blob-anim';
import logo from 'url:shared/prerendered-app/Intro/imgs/logo.svg';
import githubLogo from 'url:shared/prerendered-app/Intro/imgs/github-logo.svg';
import largePhotoIcon from 'url:shared/prerendered-app/Intro/imgs/demos/icon-demo-large-photo.jpg';
import artworkIcon from 'url:shared/prerendered-app/Intro/imgs/demos/icon-demo-artwork.jpg';
import deviceScreenIcon from 'url:shared/prerendered-app/Intro/imgs/demos/icon-demo-device-screen.jpg';
import logoIcon from 'url:shared/prerendered-app/Intro/imgs/demos/icon-demo-logo.png';
import logoWithText from 'url:shared/prerendered-app/Intro/imgs/logo-with-text.svg';
// The processors and codecs let initalJs = new Set([
// Simple stuff everyone gets:
import * as featuresWorker from 'entry-data:../features-worker';
// Decoders (some are feature detected)
import * as avifDec from 'entry-data:codecs/avif/dec/avif_dec';
import * as webpDec from 'entry-data:codecs/webp/dec/webp_dec';
// AVIF
import * as avifEncMt from 'entry-data:codecs/avif/enc/avif_enc_mt';
import * as avifEnc from 'entry-data:codecs/avif/enc/avif_enc';
// JXL
import * as jxlEncMtSimd from 'entry-data:codecs/jxl/enc/jxl_enc_mt_simd';
import * as jxlEncMt from 'entry-data:codecs/jxl/enc/jxl_enc_mt';
import * as jxlEnc from 'entry-data:codecs/jxl/enc/jxl_enc';
// OXI
import * as oxiMt from 'entry-data:codecs/oxipng/pkg-parallel/squoosh_oxipng';
import * as oxi from 'entry-data:codecs/oxipng/pkg/squoosh_oxipng';
// WebP
import * as webpEncSimd from 'entry-data:codecs/webp/enc/webp_enc_simd';
import * as webpEnc from 'entry-data:codecs/webp/enc/webp_enc';
// WP2
import * as wp2EncMtSimd from 'entry-data:codecs/wp2/enc/wp2_enc_mt_simd';
import * as wp2EncMt from 'entry-data:codecs/wp2/enc/wp2_enc_mt';
import * as wp2Enc from 'entry-data:codecs/wp2/enc/wp2_enc';
export function shouldCacheDynamically(url: string) {
return url.startsWith('/c/demo-');
}
let initialJs = new Set([
compress.main, compress.main,
...compress.deps, ...compress.deps,
swBridge.main, swBridge.main,
@@ -60,26 +32,77 @@ let initialJs = new Set([
blobAnim.main, blobAnim.main,
...blobAnim.deps, ...blobAnim.deps,
]); ]);
initialJs = subtractSets( // But initial app and any deps have already been inlined, so we don't need them:
initialJs, initalJs = subtractSets(
new Set([ initalJs,
initialApp.main, new Set([initialApp.main, ...initialApp.deps]),
...initialApp.deps.filter(
(item) =>
// Exclude JS deps that have been inlined:
item.endsWith('.js') ||
// As well as large image deps we want to keep dynamic:
shouldCacheDynamically(item),
),
// Exclude features Worker itself - it's referenced from the main app,
// but is meant to be cached lazily.
featuresWorker.main,
// Also exclude Service Worker itself (we're inside right now).
swUrl,
]),
); );
export const initial = ['/', ...initialJs]; export const initial = [
'/',
...initalJs,
logo,
githubLogo,
largePhotoIcon,
artworkIcon,
deviceScreenIcon,
logoIcon,
logoWithText,
];
// The processors and codecs
// Simple stuff everyone gets:
import * as featuresWorker from 'entry-data:../features-worker';
import rotateWasm from 'url:codecs/rotate/rotate.wasm';
import quantWasm from 'url:codecs/imagequant/imagequant.wasm';
import resizeWasm from 'url:codecs/resize/pkg/squoosh_resize_bg.wasm';
import hqxWasm from 'url:codecs/hqx/pkg/squooshhqx_bg.wasm';
import mozjpegWasm from 'url:codecs/mozjpeg/enc/mozjpeg_enc.wasm';
// Decoders (some are feature detected)
import * as avifDec from 'entry-data:codecs/avif/dec/avif_dec';
import avifDecWasm from 'url:codecs/avif/dec/avif_dec.wasm';
import jxlDecWasm from 'url:codecs/jxl/dec/jxl_dec.wasm';
import * as webpDec from 'entry-data:codecs/webp/dec/webp_dec';
import webpDecWasm from 'url:codecs/webp/dec/webp_dec.wasm';
import wp2DecWasm from 'url:codecs/wp2/dec/wp2_dec.wasm';
// AVIF
import * as avifEncMtWorker from 'entry-data:codecs/avif/enc/avif_enc_mt.worker.js';
import * as avifEncMt from 'entry-data:codecs/avif/enc/avif_enc_mt';
import avifEncMtWasm from 'url:codecs/avif/enc/avif_enc_mt.wasm';
import avifEncWasm from 'url:codecs/avif/enc/avif_enc.wasm';
import * as avifEnc from 'entry-data:codecs/avif/enc/avif_enc.js';
// JXL
import * as jxlEncMtSimdWorker from 'entry-data:codecs/jxl/enc/jxl_enc_mt_simd.worker.js';
import * as jxlEncMtSimd from 'entry-data:codecs/jxl/enc/jxl_enc_mt_simd';
import jxlEncMtSimdWasm from 'url:codecs/jxl/enc/jxl_enc_mt_simd.wasm';
import * as jxlEncMtWorker from 'entry-data:codecs/jxl/enc/jxl_enc_mt.worker.js';
import * as jxlEncMt from 'entry-data:codecs/jxl/enc/jxl_enc_mt';
import jxlEncMtWasm from 'url:codecs/jxl/enc/jxl_enc_mt.wasm';
import jxlEncWasm from 'url:codecs/jxl/enc/jxl_enc.wasm';
import * as jxlEnc from 'entry-data:codecs/jxl/enc/jxl_enc';
// OXI
import oxiMtWasm from 'url:codecs/oxipng/pkg-parallel/squoosh_oxipng_bg.wasm';
import oxiWasm from 'url:codecs/oxipng/pkg/squoosh_oxipng_bg.wasm';
// WebP
import * as webpEncSimd from 'entry-data:codecs/webp/enc/webp_enc_simd';
import webpEncSimdWasm from 'url:codecs/webp/enc/webp_enc_simd.wasm';
import * as webpEnc from 'entry-data:codecs/webp/enc/webp_enc';
import webpEncWasm from 'url:codecs/webp/enc/webp_enc.wasm';
// WP2
import * as wp2EncMtSimdWorker from 'entry-data:codecs/wp2/enc/wp2_enc_mt_simd.worker.js';
import * as wp2EncMtSimd from 'entry-data:codecs/wp2/enc/wp2_enc_mt_simd';
import wp2EncMtSimdWasm from 'url:codecs/wp2/enc/wp2_enc_mt_simd.wasm';
import * as wp2EncMtWorker from 'entry-data:codecs/wp2/enc/wp2_enc_mt.worker.js';
import * as wp2EncMt from 'entry-data:codecs/wp2/enc/wp2_enc_mt';
import wp2EncMtWasm from 'url:codecs/wp2/enc/wp2_enc_mt.wasm';
import * as wp2Enc from 'entry-data:codecs/wp2/enc/wp2_enc';
import wp2EncWasm from 'url:codecs/wp2/enc/wp2_enc.wasm';
export const theRest = (async () => { export const theRest = (async () => {
const [ const [
@@ -101,54 +124,88 @@ export const theRest = (async () => {
}), }),
]); ]);
const items: string[] = []; const items = [
featuresWorker.main,
...featuresWorker.deps,
rotateWasm,
quantWasm,
resizeWasm,
hqxWasm,
mozjpegWasm,
jxlDecWasm,
wp2DecWasm,
];
function addWithDeps(entry: typeof import('entry-data:*')) { if (!supportsAvif) items.push(avifDec.main, ...avifDec.deps, avifDecWasm);
items.push(entry.main, ...entry.deps); if (!supportsWebP) items.push(webpDec.main, ...webpDec.deps, webpDecWasm);
}
addWithDeps(featuresWorker);
if (!supportsAvif) addWithDeps(avifDec);
if (!supportsWebP) addWithDeps(webpDec);
// AVIF // AVIF
if (supportsThreads) { if (supportsThreads) {
addWithDeps(avifEncMt); items.push(
avifEncMtWorker.main,
...avifEncMtWorker.deps,
avifEncMt.main,
...avifEncMt.deps,
avifEncMtWasm,
);
} else { } else {
addWithDeps(avifEnc); items.push(avifEnc.main, ...avifEnc.deps, avifEncWasm);
} }
// JXL // JXL
if (supportsThreads && supportsSimd) { if (supportsThreads && supportsSimd) {
addWithDeps(jxlEncMtSimd); items.push(
jxlEncMtSimdWorker.main,
...jxlEncMtSimdWorker.deps,
jxlEncMtSimd.main,
...jxlEncMtSimd.deps,
jxlEncMtSimdWasm,
);
} else if (supportsThreads) { } else if (supportsThreads) {
addWithDeps(jxlEncMt); items.push(
jxlEncMtWorker.main,
...jxlEncMtWorker.deps,
jxlEncMt.main,
...jxlEncMt.deps,
jxlEncMtWasm,
);
} else { } else {
addWithDeps(jxlEnc); items.push(jxlEnc.main, ...jxlEnc.deps, jxlEncWasm);
} }
// OXI // OXI
if (supportsThreads) { if (supportsThreads) {
addWithDeps(oxiMt); items.push(oxiMtWasm);
} else { } else {
addWithDeps(oxi); items.push(oxiWasm);
} }
// WebP // WebP
if (supportsSimd) { if (supportsSimd) {
addWithDeps(webpEncSimd); items.push(webpEncSimd.main, ...webpEncSimd.deps, webpEncSimdWasm);
} else { } else {
addWithDeps(webpEnc); items.push(webpEnc.main, ...webpEnc.deps, webpEncWasm);
} }
// WP2 // WP2
if (supportsThreads && supportsSimd) { if (supportsThreads && supportsSimd) {
addWithDeps(wp2EncMtSimd); items.push(
wp2EncMtSimdWorker.main,
...wp2EncMtSimdWorker.deps,
wp2EncMtSimd.main,
...wp2EncMtSimd.deps,
wp2EncMtSimdWasm,
);
} else if (supportsThreads) { } else if (supportsThreads) {
addWithDeps(wp2EncMt); items.push(
wp2EncMtWorker.main,
...wp2EncMtWorker.deps,
wp2EncMt.main,
...wp2EncMt.deps,
wp2EncMtWasm,
);
} else { } else {
addWithDeps(wp2Enc); items.push(wp2Enc.main, ...wp2Enc.deps, wp2EncWasm);
} }
return [...new Set(items)]; return [...new Set(items)];