internal: move home server into internal flag
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user