waveterm/frontend/wave.ts
Evan Simkowitz 205afe9998
Remove reference to old Wails binding (#50)
This is now covered by gotypes.d.ts so we don't need the Wails binding ref anymore
2024-06-13 18:31:42 -07:00

49 lines
1.8 KiB
TypeScript

// Copyright 2024, Command Line Inc.
// SPDX-License-Identifier: Apache-2.0
import { globalStore, globalWS, initWS } from "@/store/global";
import * as services from "@/store/services";
import * as WOS from "@/store/wos";
import * as React from "react";
import { createRoot } from "react-dom/client";
import { App } from "./app/app";
import { loadFonts } from "./util/fontutil";
const urlParams = new URLSearchParams(window.location.search);
let windowId = urlParams.get("windowid");
let clientId = urlParams.get("clientid");
console.log("Wave Starting");
console.log("clientid", clientId, "windowid", windowId);
loadFonts();
initWS();
(window as any).globalWS = globalWS;
(window as any).WOS = WOS;
(window as any).globalStore = globalStore;
function matchViewportSize() {
document.body.style.width = window.visualViewport.width + "px";
document.body.style.height = window.visualViewport.height + "px";
}
matchViewportSize();
document.addEventListener("DOMContentLoaded", async () => {
console.log("DOMContentLoaded");
// ensures client/window/workspace are loaded into the cache before rendering
const client = await WOS.loadAndPinWaveObject<Client>(WOS.makeORef("client", clientId));
const waveWindow = await WOS.loadAndPinWaveObject<WaveWindow>(WOS.makeORef("window", windowId));
await WOS.loadAndPinWaveObject<Workspace>(WOS.makeORef("workspace", waveWindow.workspaceid));
services.ObjectService.SetActiveTab(waveWindow.activetabid); // no need to wait
const reactElem = React.createElement(App, null, null);
const elem = document.getElementById("main");
const root = createRoot(elem);
document.fonts.ready.then(() => {
console.log("Wave First Render");
root.render(reactElem);
});
const viewport = window.visualViewport;
viewport.addEventListener("resize", matchViewportSize);
});