feat: New one-click Home Server, now in Labs. Launch your own self-hosted server instance with just 1 click from the Preferences window. (#2341)

This commit is contained in:
Mo
2023-07-03 08:30:48 -05:00
committed by GitHub
parent d79e7b14b1
commit 96f42643a9
367 changed files with 5895 additions and 570 deletions

View File

@@ -1,7 +1,11 @@
import { FileBackupsDevice } from '@web/Application/Device/DesktopSnjsExports'
import {
DirectoryManagerInterface,
FileBackupsDevice,
HomeServerManagerInterface,
} from '@web/Application/Device/DesktopSnjsExports'
import { Component } from '../Main/Packages/PackageManagerInterface'
export interface CrossProcessBridge extends FileBackupsDevice {
export interface CrossProcessBridge extends FileBackupsDevice, DirectoryManagerInterface, HomeServerManagerInterface {
get extServerHost(): string
get useNativeKeychain(): boolean
get rendererPath(): string

View File

@@ -25,6 +25,46 @@ export class DesktopDevice extends WebOrDesktopDevice implements DesktopDeviceIn
super(appVersion)
}
async getHomeServerUrl(): Promise<string | undefined> {
return this.remoteBridge.getHomeServerUrl()
}
async getHomeServerLastErrorMessage(): Promise<string | undefined> {
return this.remoteBridge.getHomeServerLastErrorMessage()
}
async isHomeServerRunning(): Promise<boolean> {
return this.remoteBridge.isHomeServerRunning()
}
async activatePremiumFeatures(username: string): Promise<string | undefined> {
return this.remoteBridge.activatePremiumFeatures(username)
}
async setHomeServerConfiguration(configurationJSONString: string): Promise<void> {
return this.remoteBridge.setHomeServerConfiguration(configurationJSONString)
}
async getHomeServerConfiguration(): Promise<string | undefined> {
return this.remoteBridge.getHomeServerConfiguration()
}
async setHomeServerDataLocation(location: string): Promise<void> {
return this.remoteBridge.setHomeServerDataLocation(location)
}
startHomeServer(): Promise<string | undefined> {
return this.remoteBridge.startHomeServer()
}
stopHomeServer(): Promise<string | undefined> {
return this.remoteBridge.stopHomeServer()
}
getHomeServerLogs(): Promise<string[]> {
return this.remoteBridge.getHomeServerLogs()
}
openLocation(path: string): Promise<void> {
return this.remoteBridge.openLocation(path)
}
@@ -36,6 +76,10 @@ export class DesktopDevice extends WebOrDesktopDevice implements DesktopDeviceIn
return this.remoteBridge.presentDirectoryPickerForLocationChangeAndTransferOld(appendPath, oldLocation)
}
getDirectoryManagerLastErrorMessage(): Promise<string | undefined> {
return this.remoteBridge.getDirectoryManagerLastErrorMessage()
}
getFilesBackupsMappingFile(location: string): Promise<FileBackupsMapping> {
return this.remoteBridge.getFilesBackupsMappingFile(location)
}

View File

@@ -19,6 +19,9 @@ process.once('loaded', function () {
setInstallComponentCompleteHandler: (handler: MainEventHandler) =>
ipcRenderer.on(MessageToWebApp.InstallComponentComplete, handler),
setHomeServerStartedHandler: (handler: MainEventHandler) =>
ipcRenderer.on(MessageToWebApp.HomeServerStarted, handler),
}
contextBridge.exposeInMainWorld('electronMainEvents', mainEvents)

View File

@@ -54,6 +54,12 @@ window.onload = () => {
void loadAndStartApplication()
}
window.onunload = () => {
if (window.device) {
void window.device.stopHomeServer()
}
}
/** @returns whether the keychain structure is up to date or not */
async function migrateKeychain(remoteBridge: CrossProcessBridge): Promise<boolean> {
if (!remoteBridge.useNativeKeychain) {
@@ -151,3 +157,7 @@ window.electronMainEvents.setInstallComponentCompleteHandler((_: IpcRendererEven
window.electronMainEvents.setWatchedDirectoriesChangeHandler((_: IpcRendererEvent, changes: unknown) => {
void window.webClient.handleWatchedDirectoriesChanges(changes as DesktopWatchedDirectoriesChanges)
})
window.electronMainEvents.setHomeServerStartedHandler((_: IpcRendererEvent, serverUrl: unknown) => {
void window.webClient.handleHomeServerStarted(serverUrl as string)
})