karl/view/src/main.ts

21 lines
478 B
TypeScript
Executable File

import App from './App.svelte';
const app = new App({
target: document.body
});
//@ts-ignore
if (IS_DEV) {
let ws, int;
const connect = () => {
if (ws) ws.close();
//@ts-ignore
ws = new WebSocket("ws://localhost:" + PORT + "/ws")
ws.onclose = () => !int && (int = setInterval(connect, 1000))
ws.onopen = () => { clearInterval(int); (int = false); console.log("dev ws open") };
ws.onmessage = () => window.location.reload();
}
connect();
}
export default app;