feat(web/wasm): use simd128 if available

Signed-off-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
Xe Iaso
2025-09-28 04:03:30 +00:00
parent cf931cc0a5
commit 097c9e9586
3 changed files with 18 additions and 5 deletions

View File

@@ -1,4 +1,5 @@
import { u } from "../../lib/xeact";
import { simd } from "wasm-feature-detect";
type ProgressCallback = (nonce: number) => void;
@@ -22,9 +23,13 @@ export default function process(
console.debug(options);
const { basePrefix, version, algorithm } = options;
let wasmFeatures = "baseline";
return new Promise(async (resolve, reject) => {
let wasmFeatures = "baseline";
if (await simd()) {
wasmFeatures = "simd128";
}
const module = await fetch(u(`${basePrefix}/.within.website/x/cmd/anubis/static/wasm/${wasmFeatures}/${algorithm}.wasm?cacheBuster=${version}`))
.then(x => WebAssembly.compileStreaming(x));