(initOpts: BuilderInitOpts)
| 224 | } |
| 225 | |
| 226 | async function initBuilder(initOpts: BuilderInitOpts) { |
| 227 | getApi().sendLog("Init Builder " + JSON.stringify(initOpts)); |
| 228 | const globalInitOpts: GlobalInitOptions = { |
| 229 | clientId: initOpts.clientId, |
| 230 | windowId: initOpts.windowId, |
| 231 | platform, |
| 232 | environment: "renderer", |
| 233 | builderId: initOpts.builderId, |
| 234 | }; |
| 235 | console.log("Tsunami Builder Init", globalInitOpts); |
| 236 | await GlobalModel.getInstance().initialize(globalInitOpts); |
| 237 | initGlobal(globalInitOpts); |
| 238 | (window as any).globalAtoms = atoms; |
| 239 | |
| 240 | const globalWS = initWshrpc(makeBuilderRouteId(initOpts.builderId)); |
| 241 | (window as any).globalWS = globalWS; |
| 242 | (window as any).TabRpcClient = TabRpcClient; |
| 243 | await loadConnStatus(); |
| 244 | |
| 245 | let appIdToUse: string = null; |
| 246 | try { |
| 247 | const oref = WOS.makeORef("builder", initOpts.builderId); |
| 248 | const rtInfo = await RpcApi.GetRTInfoCommand(TabRpcClient, { oref }); |
| 249 | if (rtInfo && rtInfo["builder:appid"]) { |
| 250 | appIdToUse = rtInfo["builder:appid"]; |
| 251 | } |
| 252 | } catch (e) { |
| 253 | console.log("Could not load saved builder appId from rtinfo:", e); |
| 254 | } |
| 255 | |
| 256 | document.title = appIdToUse ? `WaveApp Builder (${appIdToUse})` : "WaveApp Builder"; |
| 257 | |
| 258 | globalStore.set(atoms.builderAppId, appIdToUse); |
| 259 | |
| 260 | const _client = await WOS.loadAndPinWaveObject<Client>(WOS.makeORef("client", initOpts.clientId)); |
| 261 | |
| 262 | registerBuilderGlobalKeys(); |
| 263 | registerElectronReinjectKeyHandler(); |
| 264 | await loadMonaco(); |
| 265 | const fullConfig = await RpcApi.GetFullConfigCommand(TabRpcClient); |
| 266 | console.log("fullconfig", fullConfig); |
| 267 | globalStore.set(atoms.fullConfigAtom, fullConfig); |
| 268 | const waveaiModeConfig = await RpcApi.GetWaveAIModeConfigCommand(TabRpcClient); |
| 269 | globalStore.set(atoms.waveaiModeConfigAtom, waveaiModeConfig.configs); |
| 270 | |
| 271 | console.log("Tsunami Builder First Render"); |
| 272 | let firstRenderResolveFn: () => void = null; |
| 273 | const firstRenderPromise = new Promise<void>((resolve) => { |
| 274 | firstRenderResolveFn = resolve; |
| 275 | }); |
| 276 | const reactElem = createElement(BuilderApp, { initOpts, onFirstRender: firstRenderResolveFn }, null); |
| 277 | const elem = document.getElementById("main"); |
| 278 | const root = createRoot(elem); |
| 279 | root.render(reactElem); |
| 280 | await firstRenderPromise; |
| 281 | console.log("Tsunami Builder First Render Done"); |
| 282 | } |
no test coverage detected