Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

fix: move initial wasm into app

Steven554f93eccc02
diff --git a/web/index.html b/web/index.html
index 672efe58a..022137faf 100644
--- a/web/index.html
+++ b/web/index.html
@@ -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>
diff --git a/web/src/App.tsx b/web/src/App.tsx
index 991dbb613..56242ce26 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 a7b2612e5..dd6c6dacc 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<void>;
+}
+
declare global {
interface Window {
+ Go: typeof Go;
parse: (content: string) => Node[];
restore: (input: Node[]) => string;
}