2022-06-07 14:24:22 -07:00
|
|
|
// Copyright (c) 2022 Tailscale Inc & AUTHORS All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
import "./wasm_exec"
|
|
|
|
import wasmUrl from "./main.wasm"
|
|
|
|
import { sessionStateStorage } from "./js-state-store"
|
2022-08-04 14:18:47 -07:00
|
|
|
import { renderApp } from "./app"
|
2022-06-07 14:24:22 -07:00
|
|
|
|
2022-08-04 14:18:47 -07:00
|
|
|
async function main() {
|
|
|
|
const app = await renderApp()
|
|
|
|
const go = new Go()
|
|
|
|
const wasmInstance = await WebAssembly.instantiateStreaming(
|
|
|
|
fetch(`./dist/${wasmUrl}`),
|
|
|
|
go.importObject
|
|
|
|
)
|
2022-07-27 15:11:17 -07:00
|
|
|
// The Go process should never exit, if it does then it's an unhandled panic.
|
2022-08-04 14:18:47 -07:00
|
|
|
go.run(wasmInstance.instance).then(() =>
|
|
|
|
app.handleGoPanic("Unexpected shutdown")
|
|
|
|
)
|
2022-06-07 14:24:22 -07:00
|
|
|
const ipn = newIPN({
|
|
|
|
// Persist IPN state in sessionStorage in development, so that we don't need
|
|
|
|
// to re-authorize every time we reload the page.
|
|
|
|
stateStorage: DEBUG ? sessionStateStorage : undefined,
|
|
|
|
})
|
2022-08-04 14:18:47 -07:00
|
|
|
app.runWithIPN(ipn)
|
2022-07-27 15:11:17 -07:00
|
|
|
}
|
|
|
|
|
2022-08-04 14:18:47 -07:00
|
|
|
main()
|