()
| 372 | }); |
| 373 | |
| 374 | async function appMain() { |
| 375 | // Set disableHardwareAcceleration as early as possible, if required. |
| 376 | const launchSettings = getLaunchSettings(); |
| 377 | if (launchSettings?.["window:disablehardwareacceleration"]) { |
| 378 | console.log("disabling hardware acceleration, per launch settings"); |
| 379 | electronApp.disableHardwareAcceleration(); |
| 380 | } |
| 381 | const startTs = Date.now(); |
| 382 | const instanceLock = electronApp.requestSingleInstanceLock(); |
| 383 | if (!instanceLock) { |
| 384 | console.log("waveterm-app could not get single-instance-lock, shutting down"); |
| 385 | setUserConfirmedQuit(true); |
| 386 | electronApp.quit(); |
| 387 | return; |
| 388 | } |
| 389 | electronApp.on("second-instance", (_event, argv, workingDirectory) => { |
| 390 | console.log("second-instance event, argv:", argv, "workingDirectory:", workingDirectory); |
| 391 | fireAndForget(createNewWaveWindow); |
| 392 | }); |
| 393 | try { |
| 394 | await runWaveSrv(handleWSEvent); |
| 395 | } catch (e) { |
| 396 | console.log(e.toString()); |
| 397 | } |
| 398 | const ready = await getWaveSrvReady(); |
| 399 | console.log("wavesrv ready signal received", ready, Date.now() - startTs, "ms"); |
| 400 | await electronApp.whenReady(); |
| 401 | configureAuthKeyRequestInjection(electron.session.defaultSession); |
| 402 | initIpcHandlers(); |
| 403 | |
| 404 | await sleep(10); // wait a bit for wavesrv to be ready |
| 405 | try { |
| 406 | initElectronWshClient(); |
| 407 | initElectronWshrpc(ElectronWshClient, { authKey: AuthKey }); |
| 408 | initMenuEventSubscriptions(); |
| 409 | } catch (e) { |
| 410 | console.log("error initializing wshrpc", e); |
| 411 | } |
| 412 | const fullConfig = await RpcApi.GetFullConfigCommand(ElectronWshClient); |
| 413 | checkIfRunningUnderARM64Translation(fullConfig); |
| 414 | if (fullConfig?.settings?.["app:confirmquit"] != null) { |
| 415 | confirmQuit = fullConfig.settings["app:confirmquit"]; |
| 416 | } |
| 417 | ensureHotSpareTab(fullConfig); |
| 418 | await relaunchBrowserWindows(); |
| 419 | setTimeout(runActiveTimer, 5000); // start active timer, wait 5s just to be safe |
| 420 | setTimeout(sendDisplaysTDataEvent, 5000); |
| 421 | |
| 422 | makeAndSetAppMenu(); |
| 423 | makeDockTaskbar(); |
| 424 | await configureAutoUpdater(); |
| 425 | setGlobalIsStarting(false); |
| 426 | if (fullConfig?.settings?.["window:maxtabcachesize"] != null) { |
| 427 | setMaxTabCacheSize(fullConfig.settings["window:maxtabcachesize"]); |
| 428 | } |
| 429 | |
| 430 | electronApp.on("activate", () => { |
| 431 | const allWindows = getAllWaveWindows(); |
no test coverage detected