diff --git a/web/index.html b/web/index.html index 672efe58..022137fa 100644 --- a/web/index.html +++ b/web/index.html @@ -18,12 +18,6 @@ } -
diff --git a/web/src/App.tsx b/web/src/App.tsx index 991dbb61..56242ce2 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -26,16 +26,20 @@ const App = () => { }, [systemStatus.host]); useEffect(() => { + const initialGoWASMExec = async () => { + const go = new window.Go(); + const result = await WebAssembly.instantiateStreaming(fetch("/gomark.wasm"), go.importObject); + go.run(result.instance); + }; const initialState = async () => { try { await userStore.fetchCurrentUser(); } catch (error) { // Do nothing. } - setLoading(false); }; - initialState(); + Promise.all([initialGoWASMExec(), initialState()]).then(() => setLoading(false)); }, []); useEffect(() => { diff --git a/web/src/types/global.d.ts b/web/src/types/global.d.ts index a7b2612e..dd6c6dac 100644 --- a/web/src/types/global.d.ts +++ b/web/src/types/global.d.ts @@ -1,7 +1,18 @@ import { Node } from "./node"; +declare class Go { + argv: string[]; + env: { [envKey: string]: string }; + exit: (code: number) => void; + importObject: WebAssembly.Imports; + exited: boolean; + mem: DataView; + run(instance: WebAssembly.Instance): Promise; +} + declare global { interface Window { + Go: typeof Go; parse: (content: string) => Node[]; restore: (input: Node[]) => string; }