diff --git a/js/borg-stmf/dist/stmf.wasm b/js/borg-stmf/dist/stmf.wasm index 00297c3..ef3469c 100755 Binary files a/js/borg-stmf/dist/stmf.wasm and b/js/borg-stmf/dist/stmf.wasm differ diff --git a/js/borg-stmf/src/index.ts b/js/borg-stmf/src/index.ts index 8c4078e..712dd7e 100644 --- a/js/borg-stmf/src/index.ts +++ b/js/borg-stmf/src/index.ts @@ -306,13 +306,26 @@ export class BorgSTMF { } private async waitForWasm(timeout = 5000): Promise { - const start = Date.now(); - while (!window.BorgSTMF?.ready) { - if (Date.now() - start > timeout) { - throw new Error('Timeout waiting for WASM module to initialize'); - } - await new Promise((resolve) => setTimeout(resolve, 50)); + if (window.BorgSTMF?.ready) { + return; } + + return new Promise((resolve, reject) => { + let timeoutId: number; + + const onReady = () => { + window.clearTimeout(timeoutId); + document.removeEventListener('borgstmf:ready', onReady); + resolve(); + }; + + timeoutId = window.setTimeout(() => { + document.removeEventListener('borgstmf:ready', onReady); + reject(new Error('Timeout waiting for WASM module to initialize')); + }, timeout); + + document.addEventListener('borgstmf:ready', onReady, { once: true }); + }); } private async loadScript(src: string): Promise { diff --git a/js/borg-stmf/stmf.wasm b/js/borg-stmf/stmf.wasm index 7862a10..ef3469c 100755 Binary files a/js/borg-stmf/stmf.wasm and b/js/borg-stmf/stmf.wasm differ diff --git a/pkg/player/assets.go b/pkg/player/assets.go index 9196f35..cde0c60 100644 --- a/pkg/player/assets.go +++ b/pkg/player/assets.go @@ -8,10 +8,7 @@ import ( // Assets embeds all frontend files for the media player // These are served both by Wails (memory) and HTTP (fallback) // -//go:embed frontend/index.html -//go:embed frontend/wasm_exec.js -//go:embed frontend/stmf.wasm -//go:embed frontend/demo-track.smsg +//go:embed frontend var assets embed.FS // Assets returns the embedded filesystem with frontend/ prefix stripped