internal: move home server into internal flag
This commit is contained in:
@@ -28,6 +28,7 @@ export function initializeApplication(args: { app: Electron.App; ipcMain: Electr
|
||||
|
||||
if (isDev()) {
|
||||
/** Expose the app's state as a global variable. Useful for debugging */
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
;(global as any).appState = state
|
||||
|
||||
setTimeout(() => {
|
||||
@@ -124,7 +125,6 @@ async function finishApplicationInitialization({ app, shell, state }: { app: App
|
||||
})
|
||||
|
||||
if (state.isRunningVersionForFirstTime()) {
|
||||
console.log('Clearing window cache')
|
||||
await windowState.window.webContents.session.clearCache()
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
HomeServerManagerInterface,
|
||||
HomeServerEnvironmentConfiguration,
|
||||
} from '@web/Application/Device/DesktopSnjsExports'
|
||||
import { HomeServer, HomeServerInterface } from '@standardnotes/home-server'
|
||||
import { HomeServerInterface } from '@standardnotes/home-server'
|
||||
|
||||
import { WebContents } from 'electron'
|
||||
import { MessageToWebApp } from '../../Shared/IpcMessages'
|
||||
@@ -127,7 +127,7 @@ export class HomeServerManager implements HomeServerManagerInterface {
|
||||
}
|
||||
|
||||
async startHomeServer(): Promise<string | undefined> {
|
||||
this.doNotInstantiateHomeServerOnWindowsUntilItIsSupported()
|
||||
await this.lazyLoadHomeServerOnApplicablePlatforms()
|
||||
|
||||
if (!this.homeServer) {
|
||||
return
|
||||
@@ -265,9 +265,17 @@ export class HomeServerManager implements HomeServerManagerInterface {
|
||||
return configuration
|
||||
}
|
||||
|
||||
private doNotInstantiateHomeServerOnWindowsUntilItIsSupported(): void {
|
||||
if (!isWindows() && !this.homeServer) {
|
||||
this.homeServer = new HomeServer()
|
||||
private async lazyLoadHomeServerOnApplicablePlatforms(): Promise<void> {
|
||||
if (isWindows()) {
|
||||
return
|
||||
}
|
||||
|
||||
if (this.homeServer) {
|
||||
return
|
||||
}
|
||||
|
||||
const { HomeServer } = await import('@standardnotes/home-server')
|
||||
|
||||
this.homeServer = new HomeServer()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ export async function createWindowState({
|
||||
const services = await createWindowServices(window, appState, appLocale)
|
||||
|
||||
require('@electron/remote/main').enable(window.webContents)
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
;(global as any).RemoteBridge = new RemoteBridge(
|
||||
window,
|
||||
Keychain,
|
||||
|
||||
@@ -22,6 +22,8 @@ process.once('loaded', function () {
|
||||
|
||||
setHomeServerStartedHandler: (handler: MainEventHandler) =>
|
||||
ipcRenderer.on(MessageToWebApp.HomeServerStarted, handler),
|
||||
|
||||
setConsoleLogHandler: (handler: MainEventHandler) => ipcRenderer.on(MessageToWebApp.ConsoleLog, handler),
|
||||
}
|
||||
|
||||
contextBridge.exposeInMainWorld('electronMainEvents', mainEvents)
|
||||
|
||||
@@ -150,8 +150,13 @@ window.electronMainEvents.setWindowFocusedHandler(() => {
|
||||
window.webClient.windowGainedFocus()
|
||||
})
|
||||
|
||||
window.electronMainEvents.setInstallComponentCompleteHandler((_: IpcRendererEvent, data: any) => {
|
||||
void window.webClient.onComponentInstallationComplete(data.component, undefined)
|
||||
window.electronMainEvents.setConsoleLogHandler((_: IpcRendererEvent, message: unknown) => {
|
||||
window.webClient.consoleLog(message as string)
|
||||
})
|
||||
|
||||
window.electronMainEvents.setInstallComponentCompleteHandler((_: IpcRendererEvent, data: unknown) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
void window.webClient.onComponentInstallationComplete((data as any).component, undefined)
|
||||
})
|
||||
|
||||
window.electronMainEvents.setWatchedDirectoriesChangeHandler((_: IpcRendererEvent, changes: unknown) => {
|
||||
|
||||
@@ -9,4 +9,5 @@ export interface ElectronMainEvents {
|
||||
setInstallComponentCompleteHandler(handler: MainEventHandler): void
|
||||
setWatchedDirectoriesChangeHandler(handler: MainEventHandler): void
|
||||
setHomeServerStartedHandler(handler: MainEventHandler): void
|
||||
setConsoleLogHandler(handler: MainEventHandler): void
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ export enum MessageToWebApp {
|
||||
InstallComponentComplete = 'install-component-complete',
|
||||
WatchedDirectoriesChanges = 'watched-directories-changes',
|
||||
HomeServerStarted = 'home-server-started',
|
||||
ConsoleLog = 'console-log',
|
||||
}
|
||||
|
||||
export enum MessageToMainProcess {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"compilerOptions": {
|
||||
"target": "ES2019",
|
||||
"moduleResolution": "node",
|
||||
"module": "es2020",
|
||||
"types": ["node"],
|
||||
"allowJs": true,
|
||||
"noEmit": false,
|
||||
|
||||
Reference in New Issue
Block a user