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:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user