Compare commits
2 commits
main
...
perf-optim
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5fcb3a2706 | ||
|
|
269b3d6ac0 |
4 changed files with 20 additions and 10 deletions
BIN
js/borg-stmf/dist/stmf.wasm
vendored
BIN
js/borg-stmf/dist/stmf.wasm
vendored
Binary file not shown.
|
|
@ -306,13 +306,26 @@ export class BorgSTMF {
|
||||||
}
|
}
|
||||||
|
|
||||||
private async waitForWasm(timeout = 5000): Promise<void> {
|
private async waitForWasm(timeout = 5000): Promise<void> {
|
||||||
const start = Date.now();
|
if (window.BorgSTMF?.ready) {
|
||||||
while (!window.BorgSTMF?.ready) {
|
return;
|
||||||
if (Date.now() - start > timeout) {
|
|
||||||
throw new Error('Timeout waiting for WASM module to initialize');
|
|
||||||
}
|
|
||||||
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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<void> {
|
private async loadScript(src: string): Promise<void> {
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -8,10 +8,7 @@ import (
|
||||||
// Assets embeds all frontend files for the media player
|
// Assets embeds all frontend files for the media player
|
||||||
// These are served both by Wails (memory) and HTTP (fallback)
|
// These are served both by Wails (memory) and HTTP (fallback)
|
||||||
//
|
//
|
||||||
//go:embed frontend/index.html
|
//go:embed frontend
|
||||||
//go:embed frontend/wasm_exec.js
|
|
||||||
//go:embed frontend/stmf.wasm
|
|
||||||
//go:embed frontend/demo-track.smsg
|
|
||||||
var assets embed.FS
|
var assets embed.FS
|
||||||
|
|
||||||
// Assets returns the embedded filesystem with frontend/ prefix stripped
|
// Assets returns the embedded filesystem with frontend/ prefix stripped
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue