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

9
package-lock.json generated
View File

@@ -10,7 +10,8 @@
"license": "ISC",
"dependencies": {
"@aws-crypto/sha256-js": "^5.2.0",
"preact": "^10.27.2"
"preact": "^10.27.2",
"wasm-feature-detect": "^1.8.0"
},
"devDependencies": {
"cssnano": "^7.1.1",
@@ -2685,6 +2686,12 @@
"dev": true,
"license": "MIT"
},
"node_modules/wasm-feature-detect": {
"version": "1.8.0",
"resolved": "https://registry.npmjs.org/wasm-feature-detect/-/wasm-feature-detect-1.8.0.tgz",
"integrity": "sha512-zksaLKM2fVlnB5jQQDqKXXwYHLQUVH9es+5TOOHwGOVJOCeRBCiPjwSg+3tN2AdTCzjgli4jijCH290kXb/zWQ==",
"license": "Apache-2.0"
},
"node_modules/wrap-ansi": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz",

View File

@@ -33,6 +33,7 @@
},
"dependencies": {
"@aws-crypto/sha256-js": "^5.2.0",
"preact": "^10.27.2"
"preact": "^10.27.2",
"wasm-feature-detect": "^1.8.0"
}
}
}

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));