Mashi is a Javascript+WASM compressor for use in 64k intros.
The compression engine is based on Squishy by Ferris/Logicoma. Specific WASM context models have been added to improve the compression ratio of WASM payloads.
However, Mashi can also be used for JS-only productions.
If you just have an intro.js:
mashi pack intro.js out.html
if you have an intro.js which should receive the bytes in intro.wasm as an argument:
mashi pack intro.js --wasm intro.wasm out.html
The resulting out.html can be opened in a browser (with local file access enabled) and will automatically invoke
your Javascript code, passing in the decompressed WASM binary as a parameter. You can then instantiate the WASM module
from your code and off you go.
Please note that if you're opening this file locally, your browser probably will block the loader and you will need to start your browser with a special flag. For Chrome you will need to pass in the --allow-file-access-from-files command line flag, or you can host the resulting out.html in a simple web server instead.
This is a very early release, so beware. Having said that, all files in the official WebAssembly Test Suite can be successfully compressed and decompressed without Mashi eating any bytes.
Browsers other than Chrome and FireFox are untested, currently. Feel free to test and report back!
The decompression stub is written in pure WASM and takes about 2.5k.
- Install a nightly toolchain, since the build process requires access to unstable features.
- Install the
binaryentoolset (specificallywasm-opt) andbun. - Do your worst!
- Run all unit and integration tests (enable Cargo feature
manual-tests) to check for any regressions - Profit / bask in glory