mirror of
https://github.com/lbr77/SideImpactor.git
synced 2026-05-06 11:14:01 -04:00
init
This commit is contained in:
26
frontend/src/anisette-libcurl-init.ts
Normal file
26
frontend/src/anisette-libcurl-init.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
// @ts-ignore
|
||||
import { libcurl } from "../public/anisette/libcurl_full.mjs"
|
||||
|
||||
let initialized = false
|
||||
let initPromise: Promise<void> | null = null
|
||||
|
||||
export async function initLibcurl(): Promise<void> {
|
||||
if (initialized) {
|
||||
return
|
||||
}
|
||||
if (initPromise) {
|
||||
return initPromise
|
||||
}
|
||||
|
||||
initPromise = (async () => {
|
||||
const wsProto = location.protocol === "https:" ? "wss:" : "ws:"
|
||||
const wsUrl = `${wsProto}//${location.host}/wisp/`
|
||||
libcurl.set_websocket(wsUrl)
|
||||
await libcurl.load_wasm()
|
||||
initialized = true
|
||||
})()
|
||||
|
||||
return initPromise
|
||||
}
|
||||
|
||||
export { libcurl }
|
||||
Reference in New Issue
Block a user