diff options
Diffstat (limited to 'ssh/browser/src/index.js')
| -rw-r--r-- | ssh/browser/src/index.js | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/ssh/browser/src/index.js b/ssh/browser/src/index.js index f5095f873..72003963b 100644 --- a/ssh/browser/src/index.js +++ b/ssh/browser/src/index.js @@ -4,14 +4,25 @@ import "./wasm_exec" import wasmUrl from "./main.wasm" -import { notifyState, notifyNetMap, notifyBrowseToURL } from "./notifier" +import { + notifyState, + notifyNetMap, + notifyBrowseToURL, + notifyIncomingFiles, +} from "./notifier" import { sessionStateStorage } from "./js-state-store" +import { injectFS } from "./fs" -const go = new window.Go() -WebAssembly.instantiateStreaming( - fetch(`./dist/${wasmUrl}`), - go.importObject -).then((result) => { +async function main() { + // Inject in-memory filesystem (otherwise wasm_exec.js will use a stub that + // always returns errors). + await injectFS() + + const go = new globalThis.Go() + const result = await WebAssembly.instantiateStreaming( + fetch(`./dist/${wasmUrl}`), + go.importObject + ) go.run(result.instance) const ipn = newIPN({ // Persist IPN state in sessionStorage in development, so that we don't need @@ -22,5 +33,8 @@ WebAssembly.instantiateStreaming( notifyState: notifyState.bind(null, ipn), notifyNetMap: notifyNetMap.bind(null, ipn), notifyBrowseToURL: notifyBrowseToURL.bind(null, ipn), + notifyIncomingFiles: notifyIncomingFiles.bind(null, ipn), }) -}) +} + +main() |
