2024-05-10 05:24:24 +02:00
|
|
|
// Copyright 2024, Command Line Inc.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2024-06-20 08:59:41 +02:00
|
|
|
import { atoms, globalStore, globalWS, initWS } from "@/store/global";
|
2024-06-12 02:42:10 +02:00
|
|
|
import * as services from "@/store/services";
|
2024-05-28 21:12:28 +02:00
|
|
|
import * as WOS from "@/store/wos";
|
2024-05-10 05:24:24 +02:00
|
|
|
import * as React from "react";
|
|
|
|
import { createRoot } from "react-dom/client";
|
2024-05-14 06:42:25 +02:00
|
|
|
import { App } from "./app/app";
|
|
|
|
import { loadFonts } from "./util/fontutil";
|
2024-05-24 23:08:24 +02:00
|
|
|
|
|
|
|
const urlParams = new URLSearchParams(window.location.search);
|
2024-06-12 02:42:10 +02:00
|
|
|
let windowId = urlParams.get("windowid");
|
|
|
|
let clientId = urlParams.get("clientid");
|
2024-05-10 05:24:24 +02:00
|
|
|
|
2024-05-28 00:44:57 +02:00
|
|
|
console.log("Wave Starting");
|
2024-06-12 02:42:10 +02:00
|
|
|
console.log("clientid", clientId, "windowid", windowId);
|
2024-05-28 00:44:57 +02:00
|
|
|
|
2024-06-12 02:42:10 +02:00
|
|
|
loadFonts();
|
|
|
|
initWS();
|
|
|
|
(window as any).globalWS = globalWS;
|
2024-05-28 21:18:26 +02:00
|
|
|
(window as any).WOS = WOS;
|
2024-06-04 22:05:44 +02:00
|
|
|
(window as any).globalStore = globalStore;
|
2024-05-28 21:18:26 +02:00
|
|
|
|
2024-06-04 08:18:44 +02:00
|
|
|
function matchViewportSize() {
|
|
|
|
document.body.style.width = window.visualViewport.width + "px";
|
|
|
|
document.body.style.height = window.visualViewport.height + "px";
|
|
|
|
}
|
|
|
|
|
2024-06-20 04:10:53 +02:00
|
|
|
document.title = `The Next Wave (${windowId.substring(0, 8)})`;
|
|
|
|
|
2024-06-04 08:18:44 +02:00
|
|
|
matchViewportSize();
|
|
|
|
|
2024-05-24 23:08:24 +02:00
|
|
|
document.addEventListener("DOMContentLoaded", async () => {
|
2024-05-28 00:44:57 +02:00
|
|
|
console.log("DOMContentLoaded");
|
2024-06-03 22:43:50 +02:00
|
|
|
// ensures client/window/workspace are loaded into the cache before rendering
|
2024-06-12 02:42:10 +02:00
|
|
|
const client = await WOS.loadAndPinWaveObject<Client>(WOS.makeORef("client", clientId));
|
2024-05-27 22:59:58 +02:00
|
|
|
const waveWindow = await WOS.loadAndPinWaveObject<WaveWindow>(WOS.makeORef("window", windowId));
|
|
|
|
await WOS.loadAndPinWaveObject<Workspace>(WOS.makeORef("workspace", waveWindow.workspaceid));
|
2024-06-20 08:59:41 +02:00
|
|
|
globalStore.set(atoms.settingsConfigAtom, await services.FileService.GetSettingsConfig());
|
2024-06-12 02:42:10 +02:00
|
|
|
services.ObjectService.SetActiveTab(waveWindow.activetabid); // no need to wait
|
2024-06-11 22:19:29 +02:00
|
|
|
const reactElem = React.createElement(App, null, null);
|
|
|
|
const elem = document.getElementById("main");
|
|
|
|
const root = createRoot(elem);
|
2024-05-10 05:24:24 +02:00
|
|
|
document.fonts.ready.then(() => {
|
2024-05-28 00:44:57 +02:00
|
|
|
console.log("Wave First Render");
|
2024-05-10 05:24:24 +02:00
|
|
|
root.render(reactElem);
|
|
|
|
});
|
2024-06-04 08:18:44 +02:00
|
|
|
const viewport = window.visualViewport;
|
|
|
|
viewport.addEventListener("resize", matchViewportSize);
|
2024-05-10 05:24:24 +02:00
|
|
|
});
|