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

@@ -10,7 +10,9 @@ import {
FileBackupsMapping,
FileBackupReadToken,
FileBackupReadChunkResponse,
HomeServerManagerInterface,
PlaintextBackupsMapping,
DirectoryManagerInterface,
} from '@web/Application/Device/DesktopSnjsExports'
import { app, BrowserWindow } from 'electron'
import { KeychainInterface } from '../Keychain/KeychainInterface'
@@ -34,6 +36,8 @@ export class RemoteBridge implements CrossProcessBridge {
private menus: MenuManagerInterface,
private fileBackups: FileBackupsDevice,
private media: MediaManagerInterface,
private homeServerManager: HomeServerManagerInterface,
private directoryManager: DirectoryManagerInterface,
) {}
get exposableValue(): CrossProcessBridge {
@@ -63,6 +67,8 @@ export class RemoteBridge implements CrossProcessBridge {
getFileBackupReadToken: this.getFileBackupReadToken.bind(this),
readNextChunk: this.readNextChunk.bind(this),
askForMediaAccess: this.askForMediaAccess.bind(this),
startHomeServer: this.startHomeServer.bind(this),
stopHomeServer: this.stopHomeServer.bind(this),
wasLegacyTextBackupsExplicitlyDisabled: this.wasLegacyTextBackupsExplicitlyDisabled.bind(this),
getLegacyTextBackupsLocation: this.getLegacyTextBackupsLocation.bind(this),
saveTextBackupData: this.saveTextBackupData.bind(this),
@@ -70,6 +76,7 @@ export class RemoteBridge implements CrossProcessBridge {
openLocation: this.openLocation.bind(this),
presentDirectoryPickerForLocationChangeAndTransferOld:
this.presentDirectoryPickerForLocationChangeAndTransferOld.bind(this),
getDirectoryManagerLastErrorMessage: this.getDirectoryManagerLastErrorMessage.bind(this),
getPlaintextBackupsMappingFile: this.getPlaintextBackupsMappingFile.bind(this),
persistPlaintextBackupsMappingFile: this.persistPlaintextBackupsMappingFile.bind(this),
getTextBackupsCount: this.getTextBackupsCount.bind(this),
@@ -77,6 +84,14 @@ export class RemoteBridge implements CrossProcessBridge {
getUserDocumentsDirectory: this.getUserDocumentsDirectory.bind(this),
monitorPlaintextBackupsLocationForChanges: this.monitorPlaintextBackupsLocationForChanges.bind(this),
joinPaths: this.joinPaths.bind(this),
setHomeServerConfiguration: this.setHomeServerConfiguration.bind(this),
getHomeServerConfiguration: this.getHomeServerConfiguration.bind(this),
setHomeServerDataLocation: this.setHomeServerDataLocation.bind(this),
activatePremiumFeatures: this.activatePremiumFeatures.bind(this),
isHomeServerRunning: this.isHomeServerRunning.bind(this),
getHomeServerLogs: this.getHomeServerLogs.bind(this),
getHomeServerUrl: this.getHomeServerUrl.bind(this),
getHomeServerLastErrorMessage: this.getHomeServerLastErrorMessage.bind(this),
}
}
@@ -201,15 +216,19 @@ export class RemoteBridge implements CrossProcessBridge {
return this.fileBackups.savePlaintextNoteBackup(location, uuid, name, tags, data)
}
openLocation(path: string): Promise<void> {
return this.fileBackups.openLocation(path)
async openLocation(path: string): Promise<void> {
return this.directoryManager.openLocation(path)
}
presentDirectoryPickerForLocationChangeAndTransferOld(
async presentDirectoryPickerForLocationChangeAndTransferOld(
appendPath: string,
oldLocation?: string | undefined,
): Promise<string | undefined> {
return this.fileBackups.presentDirectoryPickerForLocationChangeAndTransferOld(appendPath, oldLocation)
return this.directoryManager.presentDirectoryPickerForLocationChangeAndTransferOld(appendPath, oldLocation)
}
async getDirectoryManagerLastErrorMessage(): Promise<string | undefined> {
return this.directoryManager.getDirectoryManagerLastErrorMessage()
}
getPlaintextBackupsMappingFile(location: string): Promise<PlaintextBackupsMapping> {
@@ -243,4 +262,44 @@ export class RemoteBridge implements CrossProcessBridge {
askForMediaAccess(type: 'camera' | 'microphone'): Promise<boolean> {
return this.media.askForMediaAccess(type)
}
async startHomeServer(): Promise<string | undefined> {
return this.homeServerManager.startHomeServer()
}
async stopHomeServer(): Promise<string | undefined> {
return this.homeServerManager.stopHomeServer()
}
async setHomeServerConfiguration(configurationJSONString: string): Promise<void> {
return this.homeServerManager.setHomeServerConfiguration(configurationJSONString)
}
async getHomeServerConfiguration(): Promise<string | undefined> {
return this.homeServerManager.getHomeServerConfiguration()
}
async setHomeServerDataLocation(location: string): Promise<void> {
return this.homeServerManager.setHomeServerDataLocation(location)
}
async activatePremiumFeatures(username: string): Promise<string | undefined> {
return this.homeServerManager.activatePremiumFeatures(username)
}
async isHomeServerRunning(): Promise<boolean> {
return this.homeServerManager.isHomeServerRunning()
}
async getHomeServerLogs(): Promise<string[]> {
return this.homeServerManager.getHomeServerLogs()
}
async getHomeServerUrl(): Promise<string | undefined> {
return this.homeServerManager.getHomeServerUrl()
}
async getHomeServerLastErrorMessage(): Promise<string | undefined> {
return this.homeServerManager.getHomeServerLastErrorMessage()
}
}