(initOpts: WaveInitOpts)
| 141 | } |
| 142 | |
| 143 | async function initWave(initOpts: WaveInitOpts) { |
| 144 | getApi().sendLog("Init Wave " + JSON.stringify(initOpts)); |
| 145 | const globalInitOpts: GlobalInitOptions = { |
| 146 | tabId: initOpts.tabId, |
| 147 | clientId: initOpts.clientId, |
| 148 | windowId: initOpts.windowId, |
| 149 | platform, |
| 150 | environment: "renderer", |
| 151 | primaryTabStartup: initOpts.primaryTabStartup, |
| 152 | }; |
| 153 | console.log("Wave Init", globalInitOpts); |
| 154 | globalStore.set(activeTabIdAtom, initOpts.tabId); |
| 155 | await GlobalModel.getInstance().initialize(globalInitOpts); |
| 156 | initGlobal(globalInitOpts); |
| 157 | (window as any).globalAtoms = atoms; |
| 158 | |
| 159 | // Init WPS event handlers |
| 160 | const globalWS = initWshrpc(makeTabRouteId(initOpts.tabId)); |
| 161 | (window as any).globalWS = globalWS; |
| 162 | (window as any).TabRpcClient = TabRpcClient; |
| 163 | |
| 164 | // ensures client/window/workspace are loaded into the cache before rendering |
| 165 | try { |
| 166 | await loadConnStatus(); |
| 167 | await loadBadges(); |
| 168 | initGlobalWaveEventSubs(initOpts); |
| 169 | subscribeToConnEvents(); |
| 170 | if (isMacOS()) { |
| 171 | const macOSVersion = await RpcApi.MacOSVersionCommand(TabRpcClient); |
| 172 | setMacOSVersion(macOSVersion); |
| 173 | } |
| 174 | const [_client, waveWindow, initialTab] = await Promise.all([ |
| 175 | WOS.loadAndPinWaveObject<Client>(WOS.makeORef("client", initOpts.clientId)), |
| 176 | WOS.loadAndPinWaveObject<WaveWindow>(WOS.makeORef("window", initOpts.windowId)), |
| 177 | WOS.loadAndPinWaveObject<Tab>(WOS.makeORef("tab", initOpts.tabId)), |
| 178 | ]); |
| 179 | const [ws, _layoutState] = await Promise.all([ |
| 180 | WOS.loadAndPinWaveObject<Workspace>(WOS.makeORef("workspace", waveWindow.workspaceid)), |
| 181 | WOS.reloadWaveObject<LayoutState>(WOS.makeORef("layout", initialTab.layoutstate)), |
| 182 | ]); |
| 183 | loadAllWorkspaceTabs(ws); |
| 184 | WOS.wpsSubscribeToObject(WOS.makeORef("workspace", waveWindow.workspaceid)); |
| 185 | document.title = `Wave Terminal - ${initialTab.name}`; // TODO update with tab name change |
| 186 | } catch (e) { |
| 187 | console.error("Failed initialization error", e); |
| 188 | getApi().sendLog("Error in initialization (wave.ts, loading required objects) " + e.message + "\n" + e.stack); |
| 189 | } |
| 190 | registerGlobalKeys(); |
| 191 | registerElectronReinjectKeyHandler(); |
| 192 | registerControlShiftStateUpdateHandler(); |
| 193 | await loadMonaco(); |
| 194 | const fullConfig = await RpcApi.GetFullConfigCommand(TabRpcClient); |
| 195 | console.log("fullconfig", fullConfig); |
| 196 | globalStore.set(atoms.fullConfigAtom, fullConfig); |
| 197 | const waveaiModeConfig = await RpcApi.GetWaveAIModeConfigCommand(TabRpcClient); |
| 198 | globalStore.set(atoms.waveaiModeConfigAtom, waveaiModeConfig.configs); |
| 199 | console.log("Wave First Render"); |
| 200 | let firstRenderResolveFn: () => void = null; |
no test coverage detected