2024-05-10 05:24:24 +02:00
|
|
|
// Copyright 2024, Command Line Inc.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2024-08-30 01:06:15 +02:00
|
|
|
import {
|
|
|
|
registerControlShiftStateUpdateHandler,
|
|
|
|
registerElectronReinjectKeyHandler,
|
|
|
|
registerGlobalKeys,
|
|
|
|
} from "@/app/store/keymodel";
|
2024-07-18 00:24:43 +02:00
|
|
|
import { WshServer } from "@/app/store/wshserver";
|
2024-08-24 03:12:40 +02:00
|
|
|
import {
|
|
|
|
atoms,
|
|
|
|
countersClear,
|
|
|
|
countersPrint,
|
|
|
|
getApi,
|
|
|
|
globalStore,
|
|
|
|
globalWS,
|
|
|
|
initGlobal,
|
|
|
|
initWS,
|
|
|
|
loadConnStatus,
|
|
|
|
subscribeToConnEvents,
|
|
|
|
} 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-06-21 21:32:38 +02:00
|
|
|
import * as keyutil from "@/util/keyutil";
|
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
|
|
|
|
2024-07-19 22:44:32 +02:00
|
|
|
const platform = getApi().getPlatform();
|
2024-05-24 23:08:24 +02:00
|
|
|
const urlParams = new URLSearchParams(window.location.search);
|
2024-07-18 03:42:49 +02:00
|
|
|
const windowId = urlParams.get("windowid");
|
|
|
|
const 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-07-19 22:44:32 +02:00
|
|
|
initGlobal({ clientId, windowId, platform, environment: "renderer" });
|
|
|
|
|
2024-07-09 08:13:12 +02:00
|
|
|
keyutil.setKeyUtilPlatform(platform);
|
2024-06-21 21:32:38 +02:00
|
|
|
|
2024-06-12 02:42:10 +02:00
|
|
|
loadFonts();
|
|
|
|
(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-07-26 22:30:11 +02:00
|
|
|
(window as any).globalAtoms = atoms;
|
2024-07-18 00:24:43 +02:00
|
|
|
(window as any).WshServer = WshServer;
|
2024-07-22 22:33:10 +02:00
|
|
|
(window as any).isFullScreen = false;
|
2024-08-22 00:49:23 +02:00
|
|
|
(window as any).countersPrint = countersPrint;
|
|
|
|
(window as any).countersClear = countersClear;
|
2024-05-28 21:18:26 +02:00
|
|
|
|
2024-06-20 04:10:53 +02:00
|
|
|
document.title = `The Next Wave (${windowId.substring(0, 8)})`;
|
|
|
|
|
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-25 23:56:37 +02:00
|
|
|
const initialTab = await WOS.loadAndPinWaveObject<Tab>(WOS.makeORef("tab", waveWindow.activetabid));
|
2024-08-15 03:40:41 +02:00
|
|
|
await WOS.loadAndPinWaveObject<LayoutState>(WOS.makeORef("layout", initialTab.layoutstate));
|
2024-06-25 23:56:37 +02:00
|
|
|
initWS();
|
2024-08-24 03:12:40 +02:00
|
|
|
await loadConnStatus();
|
|
|
|
subscribeToConnEvents();
|
2024-08-30 01:06:15 +02:00
|
|
|
registerGlobalKeys();
|
|
|
|
registerElectronReinjectKeyHandler();
|
|
|
|
registerControlShiftStateUpdateHandler();
|
2024-08-28 03:49:49 +02:00
|
|
|
const fullConfig = await services.FileService.GetFullConfig();
|
|
|
|
console.log("fullconfig", fullConfig);
|
|
|
|
globalStore.set(atoms.fullConfigAtom, fullConfig);
|
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);
|
|
|
|
});
|
|
|
|
});
|