From ce1576fbd6759addba67f4acc1ea5d859c34fc57 Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Wed, 29 Jul 2026 16:13:55 +0000 Subject: [PATCH] remove global usage for wasm --- WFA-JS | 2 +- web/modules/wfa.js | 2 +- web/scripts/index.js | 8 +++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/WFA-JS b/WFA-JS index f8f8636..f53f344 160000 --- a/WFA-JS +++ b/WFA-JS @@ -1 +1 @@ -Subproject commit f8f8636cc3f00e3fa0c379b490b7df05b9df3d2c +Subproject commit f53f344fb35dc118d55a2135123ddf64801d0cd3 diff --git a/web/modules/wfa.js b/web/modules/wfa.js index f99b95d..67bae2c 100644 --- a/web/modules/wfa.js +++ b/web/modules/wfa.js @@ -560,7 +560,7 @@ export default function init (path) { const wasm = obj.instance; global.wfa = wasm go.run(wasm); - res() + res(wasm) } if ('instantiateStreaming' in WebAssembly) { WebAssembly.instantiateStreaming(fetch(path), go.importObject).then(function (obj) { diff --git a/web/scripts/index.js b/web/scripts/index.js index 2c58403..a989c11 100644 --- a/web/scripts/index.js +++ b/web/scripts/index.js @@ -5,10 +5,12 @@ import wfaInit from "../modules/wfa.js"; window.addEventListener("DOMContentLoaded", init); +var wfa; + async function init () { setAppearance(); - wfaInit("modules/wfa.wasm"); + wfa = await wfaInit("modules/wfa.wasm"); initInstances(); document.querySelector("#instance-add").addEventListener("click", handleInstanceAddButton); @@ -272,8 +274,8 @@ function sortInstances () { }; criteria = (item, query) => { // lower is better - const { score, CIGAR } = global.wfa.wfAlign(query, item, penalties, true); - const alignment = global.wfa.DecodeCIGAR(CIGAR); + const { score, CIGAR } = wfa.wfAlign(query, item, penalties, true); + const alignment = wfa.DecodeCIGAR(CIGAR); return { score: score / item.length, alignment }; }; }