fix: move initial wasm into app

pull/2886/head
Steven 1 year ago
parent 79227021f5
commit 554f93eccc

@ -18,12 +18,6 @@
}
</script>
<script src="wasm_exec.js"></script>
<script>
const go = new Go();
WebAssembly.instantiateStreaming(fetch("gomark.wasm"), go.importObject).then((result) => {
go.run(result.instance);
});
</script>
</head>
<body>
<div id="root"></div>

@ -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(() => {

@ -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<void>;
}
declare global {
interface Window {
Go: typeof Go;
parse: (content: string) => Node[];
restore: (input: Node[]) => string;
}

Loading…
Cancel
Save