From 35ca7015c859d4961f845bb44460a5e8fae086e8 Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Sun, 19 Mar 2023 12:39:31 +0100 Subject: [PATCH] moved electron-specific parts of tabby-local into tabby-electron --- tabby-core/src/api/platform.ts | 1 + tabby-electron/package.json | 6 ++- .../src/icons/alma.svg | 0 .../src/icons/alpine.svg | 0 .../src/icons/clink.svg | 0 .../src/icons/cmd.svg | 0 .../src/icons/cmder-powershell.svg | 0 .../src/icons/cmder.svg | 0 .../src/icons/cygwin.svg | 0 .../src/icons/debian.svg | 0 .../src/icons/docker.svg | 0 .../src/icons/git-bash.svg | 0 .../src/icons/kali.svg | 0 .../src/icons/linux.svg | 0 .../src/icons/msys2.svg | 0 .../src/icons/open-euler.svg | 0 .../src/icons/oracle-linux.svg | 0 .../src/icons/powershell-core.svg | 0 .../src/icons/powershell.svg | 0 .../src/icons/suse.svg | 0 .../src/icons/ubuntu.svg | 0 .../src/icons/vs2017.svg | 0 .../src/icons/vs2019.svg | 0 .../src/icons/vs2022.svg | 0 tabby-electron/src/index.ts | 43 +++++++++++++++++++ .../src/services/dockMenu.service.ts | 2 +- .../src/services/platform.service.ts | 9 ++++ .../src/services/uac.service.ts | 16 +++---- .../src/shells/cmder.ts | 2 +- .../src/shells/cygwin32.ts | 2 +- .../src/shells/cygwin64.ts | 2 +- .../src/shells/gitBash.ts | 2 +- .../src/shells/linuxDefault.ts | 2 +- .../src/shells/macDefault.ts | 2 +- .../src/shells/msys2.ts | 2 +- .../src/shells/posix.ts | 2 +- .../src/shells/powershellCore.ts | 2 +- .../src/shells/vs.ts | 2 +- .../src/shells/winDefault.ts | 2 +- .../src/shells/windowsBase.ts | 2 +- .../src/shells/windowsStock.ts | 4 +- .../src/shells/wsl.ts | 2 +- tabby-electron/yarn.lock | 12 ++++++ tabby-local/package.json | 1 - tabby-local/src/api.ts | 6 +++ .../localProfileSettings.component.pug | 2 +- .../localProfileSettings.component.ts | 24 +++-------- .../src/components/terminalTab.component.ts | 9 ++-- tabby-local/src/index.ts | 42 ------------------ tabby-local/src/tabContextMenu.ts | 11 +++-- tabby-local/yarn.lock | 12 ------ tabby-web/src/platform.ts | 4 ++ 52 files changed, 120 insertions(+), 110 deletions(-) rename {tabby-local => tabby-electron}/src/icons/alma.svg (100%) rename {tabby-local => tabby-electron}/src/icons/alpine.svg (100%) rename {tabby-local => tabby-electron}/src/icons/clink.svg (100%) rename {tabby-local => tabby-electron}/src/icons/cmd.svg (100%) rename {tabby-local => tabby-electron}/src/icons/cmder-powershell.svg (100%) rename {tabby-local => tabby-electron}/src/icons/cmder.svg (100%) rename {tabby-local => tabby-electron}/src/icons/cygwin.svg (100%) rename {tabby-local => tabby-electron}/src/icons/debian.svg (100%) rename {tabby-local => tabby-electron}/src/icons/docker.svg (100%) rename {tabby-local => tabby-electron}/src/icons/git-bash.svg (100%) rename {tabby-local => tabby-electron}/src/icons/kali.svg (100%) rename {tabby-local => tabby-electron}/src/icons/linux.svg (100%) rename {tabby-local => tabby-electron}/src/icons/msys2.svg (100%) rename {tabby-local => tabby-electron}/src/icons/open-euler.svg (100%) rename {tabby-local => tabby-electron}/src/icons/oracle-linux.svg (100%) rename {tabby-local => tabby-electron}/src/icons/powershell-core.svg (100%) rename {tabby-local => tabby-electron}/src/icons/powershell.svg (100%) rename {tabby-local => tabby-electron}/src/icons/suse.svg (100%) rename {tabby-local => tabby-electron}/src/icons/ubuntu.svg (100%) rename {tabby-local => tabby-electron}/src/icons/vs2017.svg (100%) rename {tabby-local => tabby-electron}/src/icons/vs2019.svg (100%) rename {tabby-local => tabby-electron}/src/icons/vs2022.svg (100%) rename {tabby-local => tabby-electron}/src/services/dockMenu.service.ts (98%) rename {tabby-local => tabby-electron}/src/services/uac.service.ts (82%) rename {tabby-local => tabby-electron}/src/shells/cmder.ts (96%) rename {tabby-local => tabby-electron}/src/shells/cygwin32.ts (95%) rename {tabby-local => tabby-electron}/src/shells/cygwin64.ts (95%) rename {tabby-local => tabby-electron}/src/shells/gitBash.ts (97%) rename {tabby-local => tabby-electron}/src/shells/linuxDefault.ts (96%) rename {tabby-local => tabby-electron}/src/shells/macDefault.ts (96%) rename {tabby-local => tabby-electron}/src/shells/msys2.ts (96%) rename {tabby-local => tabby-electron}/src/shells/posix.ts (95%) rename {tabby-local => tabby-electron}/src/shells/powershellCore.ts (97%) rename {tabby-local => tabby-electron}/src/shells/vs.ts (98%) rename {tabby-local => tabby-electron}/src/shells/winDefault.ts (96%) rename {tabby-local => tabby-electron}/src/shells/windowsBase.ts (92%) rename {tabby-local => tabby-electron}/src/shells/windowsStock.ts (96%) rename {tabby-local => tabby-electron}/src/shells/wsl.ts (98%) diff --git a/tabby-core/src/api/platform.ts b/tabby-core/src/api/platform.ts index 73b081ba..63bf00e6 100644 --- a/tabby-core/src/api/platform.ts +++ b/tabby-core/src/api/platform.ts @@ -176,6 +176,7 @@ export abstract class PlatformService { abstract setErrorHandler (handler: (_: any) => void): void abstract popupContextMenu (menu: MenuItemOptions[], event?: MouseEvent): void abstract showMessageBox (options: MessageBoxOptions): Promise + abstract pickDirectory (): Promise abstract quit (): void } diff --git a/tabby-electron/package.json b/tabby-electron/package.json index 90ffdcea..a2a6f57b 100644 --- a/tabby-electron/package.json +++ b/tabby-electron/package.json @@ -16,8 +16,12 @@ ], "author": "Eugene Pankov", "license": "MIT", + "dependencies": { + "hasbin": "^1.2.3" + }, "peerDependencies": { - "@angular/core": "^9.1.9" + "@angular/core": "^9.1.9", + "tabby-local": "*" }, "devDependencies": { "electron-promise-ipc": "^2.2.4", diff --git a/tabby-local/src/icons/alma.svg b/tabby-electron/src/icons/alma.svg similarity index 100% rename from tabby-local/src/icons/alma.svg rename to tabby-electron/src/icons/alma.svg diff --git a/tabby-local/src/icons/alpine.svg b/tabby-electron/src/icons/alpine.svg similarity index 100% rename from tabby-local/src/icons/alpine.svg rename to tabby-electron/src/icons/alpine.svg diff --git a/tabby-local/src/icons/clink.svg b/tabby-electron/src/icons/clink.svg similarity index 100% rename from tabby-local/src/icons/clink.svg rename to tabby-electron/src/icons/clink.svg diff --git a/tabby-local/src/icons/cmd.svg b/tabby-electron/src/icons/cmd.svg similarity index 100% rename from tabby-local/src/icons/cmd.svg rename to tabby-electron/src/icons/cmd.svg diff --git a/tabby-local/src/icons/cmder-powershell.svg b/tabby-electron/src/icons/cmder-powershell.svg similarity index 100% rename from tabby-local/src/icons/cmder-powershell.svg rename to tabby-electron/src/icons/cmder-powershell.svg diff --git a/tabby-local/src/icons/cmder.svg b/tabby-electron/src/icons/cmder.svg similarity index 100% rename from tabby-local/src/icons/cmder.svg rename to tabby-electron/src/icons/cmder.svg diff --git a/tabby-local/src/icons/cygwin.svg b/tabby-electron/src/icons/cygwin.svg similarity index 100% rename from tabby-local/src/icons/cygwin.svg rename to tabby-electron/src/icons/cygwin.svg diff --git a/tabby-local/src/icons/debian.svg b/tabby-electron/src/icons/debian.svg similarity index 100% rename from tabby-local/src/icons/debian.svg rename to tabby-electron/src/icons/debian.svg diff --git a/tabby-local/src/icons/docker.svg b/tabby-electron/src/icons/docker.svg similarity index 100% rename from tabby-local/src/icons/docker.svg rename to tabby-electron/src/icons/docker.svg diff --git a/tabby-local/src/icons/git-bash.svg b/tabby-electron/src/icons/git-bash.svg similarity index 100% rename from tabby-local/src/icons/git-bash.svg rename to tabby-electron/src/icons/git-bash.svg diff --git a/tabby-local/src/icons/kali.svg b/tabby-electron/src/icons/kali.svg similarity index 100% rename from tabby-local/src/icons/kali.svg rename to tabby-electron/src/icons/kali.svg diff --git a/tabby-local/src/icons/linux.svg b/tabby-electron/src/icons/linux.svg similarity index 100% rename from tabby-local/src/icons/linux.svg rename to tabby-electron/src/icons/linux.svg diff --git a/tabby-local/src/icons/msys2.svg b/tabby-electron/src/icons/msys2.svg similarity index 100% rename from tabby-local/src/icons/msys2.svg rename to tabby-electron/src/icons/msys2.svg diff --git a/tabby-local/src/icons/open-euler.svg b/tabby-electron/src/icons/open-euler.svg similarity index 100% rename from tabby-local/src/icons/open-euler.svg rename to tabby-electron/src/icons/open-euler.svg diff --git a/tabby-local/src/icons/oracle-linux.svg b/tabby-electron/src/icons/oracle-linux.svg similarity index 100% rename from tabby-local/src/icons/oracle-linux.svg rename to tabby-electron/src/icons/oracle-linux.svg diff --git a/tabby-local/src/icons/powershell-core.svg b/tabby-electron/src/icons/powershell-core.svg similarity index 100% rename from tabby-local/src/icons/powershell-core.svg rename to tabby-electron/src/icons/powershell-core.svg diff --git a/tabby-local/src/icons/powershell.svg b/tabby-electron/src/icons/powershell.svg similarity index 100% rename from tabby-local/src/icons/powershell.svg rename to tabby-electron/src/icons/powershell.svg diff --git a/tabby-local/src/icons/suse.svg b/tabby-electron/src/icons/suse.svg similarity index 100% rename from tabby-local/src/icons/suse.svg rename to tabby-electron/src/icons/suse.svg diff --git a/tabby-local/src/icons/ubuntu.svg b/tabby-electron/src/icons/ubuntu.svg similarity index 100% rename from tabby-local/src/icons/ubuntu.svg rename to tabby-electron/src/icons/ubuntu.svg diff --git a/tabby-local/src/icons/vs2017.svg b/tabby-electron/src/icons/vs2017.svg similarity index 100% rename from tabby-local/src/icons/vs2017.svg rename to tabby-electron/src/icons/vs2017.svg diff --git a/tabby-local/src/icons/vs2019.svg b/tabby-electron/src/icons/vs2019.svg similarity index 100% rename from tabby-local/src/icons/vs2019.svg rename to tabby-electron/src/icons/vs2019.svg diff --git a/tabby-local/src/icons/vs2022.svg b/tabby-electron/src/icons/vs2022.svg similarity index 100% rename from tabby-local/src/icons/vs2022.svg rename to tabby-electron/src/icons/vs2022.svg diff --git a/tabby-electron/src/index.ts b/tabby-electron/src/index.ts index 09bddc44..605f0834 100644 --- a/tabby-electron/src/index.ts +++ b/tabby-electron/src/index.ts @@ -2,6 +2,7 @@ import { NgModule } from '@angular/core' import { PlatformService, LogService, UpdaterService, DockingService, HostAppService, ThemesService, Platform, AppService, ConfigService, WIN_BUILD_FLUENT_BG_SUPPORTED, isWindowsBuild, HostWindowService, HotkeyProvider, ConfigProvider, FileProvider } from 'tabby-core' import { TerminalColorSchemeProvider } from 'tabby-terminal' import { SFTPContextMenuItemProvider, SSHProfileImporter, AutoPrivateKeyLocator } from 'tabby-ssh' +import { ShellProvider, UACService } from 'tabby-local' import { auditTime } from 'rxjs' import { HyperColorSchemes } from './colorSchemes' @@ -14,10 +15,26 @@ import { ElectronHostWindow } from './services/hostWindow.service' import { ElectronFileProvider } from './services/fileProvider.service' import { ElectronHostAppService } from './services/hostApp.service' import { ElectronService } from './services/electron.service' +import { DockMenuService } from './services/dockMenu.service' import { ElectronHotkeyProvider } from './hotkeys' import { ElectronConfigProvider } from './config' import { EditSFTPContextMenu } from './sftpContextMenu' import { OpenSSHImporter, PrivateKeyLocator, StaticFileImporter } from './sshImporters' +import { ElectronUACService } from './services/uac.service' + +import { CmderShellProvider } from './shells/cmder' +import { Cygwin32ShellProvider } from './shells/cygwin32' +import { Cygwin64ShellProvider } from './shells/cygwin64' +import { GitBashShellProvider } from './shells/gitBash' +import { LinuxDefaultShellProvider } from './shells/linuxDefault' +import { MacOSDefaultShellProvider } from './shells/macDefault' +import { MSYS2ShellProvider } from './shells/msys2' +import { POSIXShellsProvider } from './shells/posix' +import { PowerShellCoreShellProvider } from './shells/powershellCore' +import { WindowsDefaultShellProvider } from './shells/winDefault' +import { WindowsStockShellsProvider } from './shells/windowsStock' +import { WSLShellProvider } from './shells/wsl' +import { VSDevToolsProvider } from './shells/vs' @NgModule({ providers: [ @@ -35,6 +52,27 @@ import { OpenSSHImporter, PrivateKeyLocator, StaticFileImporter } from './sshImp { provide: SSHProfileImporter, useExisting: OpenSSHImporter, multi: true }, { provide: SSHProfileImporter, useExisting: StaticFileImporter, multi: true }, { provide: AutoPrivateKeyLocator, useExisting: PrivateKeyLocator, multi: true }, + + { provide: ShellProvider, useClass: WindowsDefaultShellProvider, multi: true }, + { provide: ShellProvider, useClass: MacOSDefaultShellProvider, multi: true }, + { provide: ShellProvider, useClass: LinuxDefaultShellProvider, multi: true }, + { provide: ShellProvider, useClass: WindowsStockShellsProvider, multi: true }, + { provide: ShellProvider, useClass: PowerShellCoreShellProvider, multi: true }, + { provide: ShellProvider, useClass: CmderShellProvider, multi: true }, + { provide: ShellProvider, useClass: Cygwin32ShellProvider, multi: true }, + { provide: ShellProvider, useClass: Cygwin64ShellProvider, multi: true }, + { provide: ShellProvider, useClass: GitBashShellProvider, multi: true }, + { provide: ShellProvider, useClass: POSIXShellsProvider, multi: true }, + { provide: ShellProvider, useClass: MSYS2ShellProvider, multi: true }, + { provide: ShellProvider, useClass: WSLShellProvider, multi: true }, + { provide: ShellProvider, useClass: VSDevToolsProvider, multi: true }, + + { provide: UACService, useClass: ElectronUACService }, + + // For WindowsDefaultShellProvider + PowerShellCoreShellProvider, + WSLShellProvider, + WindowsStockShellsProvider, ], }) export default class ElectronModule { @@ -47,6 +85,7 @@ export default class ElectronModule { docking: DockingService, themeService: ThemesService, app: AppService, + dockMenu: DockMenuService, ) { config.ready$.toPromise().then(() => { touchbar.update() @@ -87,6 +126,10 @@ export default class ElectronModule { }) config.changed$.subscribe(() => this.updateVibrancy()) + + config.ready$.toPromise().then(() => { + dockMenu.update() + }) } private registerGlobalHotkey () { diff --git a/tabby-local/src/services/dockMenu.service.ts b/tabby-electron/src/services/dockMenu.service.ts similarity index 98% rename from tabby-local/src/services/dockMenu.service.ts rename to tabby-electron/src/services/dockMenu.service.ts index 25c376a5..830d70af 100644 --- a/tabby-local/src/services/dockMenu.service.ts +++ b/tabby-electron/src/services/dockMenu.service.ts @@ -1,6 +1,6 @@ import { NgZone, Injectable } from '@angular/core' import { ConfigService, HostAppService, Platform, ProfilesService, TranslateService } from 'tabby-core' -import { ElectronService } from 'tabby-electron' +import { ElectronService } from './electron.service' /** @hidden */ @Injectable({ providedIn: 'root' }) diff --git a/tabby-electron/src/services/platform.service.ts b/tabby-electron/src/services/platform.service.ts index 7f655fb1..d6243c79 100644 --- a/tabby-electron/src/services/platform.service.ts +++ b/tabby-electron/src/services/platform.service.ts @@ -234,6 +234,15 @@ export class ElectronPlatformService extends PlatformService { handler(err) }) } + + async pickDirectory (): Promise { + return (await this.electron.dialog.showOpenDialog( + this.hostWindow.getWindow(), + { + properties: ['openDirectory', 'showHiddenFiles'], + }, + )).filePaths[0] + } } class ElectronFileUpload extends FileUpload { diff --git a/tabby-local/src/services/uac.service.ts b/tabby-electron/src/services/uac.service.ts similarity index 82% rename from tabby-local/src/services/uac.service.ts rename to tabby-electron/src/services/uac.service.ts index 98844693..e73713c2 100644 --- a/tabby-local/src/services/uac.service.ts +++ b/tabby-electron/src/services/uac.service.ts @@ -1,17 +1,16 @@ -import * as path from 'path' import { Injectable } from '@angular/core' +import * as path from 'path' import { WIN_BUILD_CONPTY_SUPPORTED, isWindowsBuild } from 'tabby-core' -import { ElectronService } from 'tabby-electron' -import { SessionOptions } from '../api' +import { SessionOptions, UACService } from 'tabby-local' +import { ElectronService } from './electron.service' /** @hidden */ -@Injectable({ providedIn: 'root' }) -export class UACService { - isAvailable = false - - private constructor ( +@Injectable() +export class ElectronUACService extends UACService { + constructor ( private electron: ElectronService, ) { + super() this.isAvailable = isWindowsBuild(WIN_BUILD_CONPTY_SUPPORTED) } @@ -37,5 +36,4 @@ export class UACService { options.command = helperPath return options } - } diff --git a/tabby-local/src/shells/cmder.ts b/tabby-electron/src/shells/cmder.ts similarity index 96% rename from tabby-local/src/shells/cmder.ts rename to tabby-electron/src/shells/cmder.ts index fb3d8eb3..0c97164d 100644 --- a/tabby-local/src/shells/cmder.ts +++ b/tabby-electron/src/shells/cmder.ts @@ -2,7 +2,7 @@ import * as path from 'path' import { Injectable } from '@angular/core' import { HostAppService, Platform } from 'tabby-core' -import { ShellProvider, Shell } from '../api' +import { ShellProvider, Shell } from 'tabby-local' /** @hidden */ @Injectable() diff --git a/tabby-local/src/shells/cygwin32.ts b/tabby-electron/src/shells/cygwin32.ts similarity index 95% rename from tabby-local/src/shells/cygwin32.ts rename to tabby-electron/src/shells/cygwin32.ts index f7c7874e..f77b0003 100644 --- a/tabby-local/src/shells/cygwin32.ts +++ b/tabby-electron/src/shells/cygwin32.ts @@ -2,7 +2,7 @@ import * as path from 'path' import { Injectable } from '@angular/core' import { HostAppService, Platform } from 'tabby-core' -import { ShellProvider, Shell } from '../api' +import { ShellProvider, Shell } from 'tabby-local' /* eslint-disable block-scoped-var */ diff --git a/tabby-local/src/shells/cygwin64.ts b/tabby-electron/src/shells/cygwin64.ts similarity index 95% rename from tabby-local/src/shells/cygwin64.ts rename to tabby-electron/src/shells/cygwin64.ts index b6a44668..4e3118fc 100644 --- a/tabby-local/src/shells/cygwin64.ts +++ b/tabby-electron/src/shells/cygwin64.ts @@ -2,7 +2,7 @@ import * as path from 'path' import { Injectable } from '@angular/core' import { HostAppService, Platform } from 'tabby-core' -import { ShellProvider, Shell } from '../api' +import { ShellProvider, Shell } from 'tabby-local' /* eslint-disable block-scoped-var */ diff --git a/tabby-local/src/shells/gitBash.ts b/tabby-electron/src/shells/gitBash.ts similarity index 97% rename from tabby-local/src/shells/gitBash.ts rename to tabby-electron/src/shells/gitBash.ts index 2b3a9a82..19b480f9 100644 --- a/tabby-local/src/shells/gitBash.ts +++ b/tabby-electron/src/shells/gitBash.ts @@ -2,7 +2,7 @@ import * as path from 'path' import { Injectable } from '@angular/core' import { Platform, ConfigService, HostAppService } from 'tabby-core' -import { Shell } from '../api' +import { Shell } from 'tabby-local' import { WindowsBaseShellProvider } from './windowsBase' /* eslint-disable block-scoped-var */ diff --git a/tabby-local/src/shells/linuxDefault.ts b/tabby-electron/src/shells/linuxDefault.ts similarity index 96% rename from tabby-local/src/shells/linuxDefault.ts rename to tabby-electron/src/shells/linuxDefault.ts index 996fd497..8c8a419a 100644 --- a/tabby-local/src/shells/linuxDefault.ts +++ b/tabby-electron/src/shells/linuxDefault.ts @@ -2,7 +2,7 @@ import * as fs from 'mz/fs' import { Injectable } from '@angular/core' import { HostAppService, Platform, LogService, Logger, TranslateService } from 'tabby-core' -import { ShellProvider, Shell } from '../api' +import { ShellProvider, Shell } from 'tabby-local' /** @hidden */ @Injectable() diff --git a/tabby-local/src/shells/macDefault.ts b/tabby-electron/src/shells/macDefault.ts similarity index 96% rename from tabby-local/src/shells/macDefault.ts rename to tabby-electron/src/shells/macDefault.ts index e4f4e8e9..32dcc462 100644 --- a/tabby-local/src/shells/macDefault.ts +++ b/tabby-electron/src/shells/macDefault.ts @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core' import promiseIpc, { RendererProcessType } from 'electron-promise-ipc' import { HostAppService, Platform, TranslateService } from 'tabby-core' -import { ShellProvider, Shell } from '../api' +import { ShellProvider, Shell } from 'tabby-local' /** @hidden */ @Injectable() diff --git a/tabby-local/src/shells/msys2.ts b/tabby-electron/src/shells/msys2.ts similarity index 96% rename from tabby-local/src/shells/msys2.ts rename to tabby-electron/src/shells/msys2.ts index c205babf..3475b377 100644 --- a/tabby-local/src/shells/msys2.ts +++ b/tabby-electron/src/shells/msys2.ts @@ -3,7 +3,7 @@ import * as path from 'path' import { Injectable } from '@angular/core' import { HostAppService, Platform } from 'tabby-core' -import { ShellProvider, Shell } from '../api' +import { ShellProvider, Shell } from 'tabby-local' /** @hidden */ @Injectable() diff --git a/tabby-local/src/shells/posix.ts b/tabby-electron/src/shells/posix.ts similarity index 95% rename from tabby-local/src/shells/posix.ts rename to tabby-electron/src/shells/posix.ts index 4e79d7fe..6707ac88 100644 --- a/tabby-local/src/shells/posix.ts +++ b/tabby-electron/src/shells/posix.ts @@ -3,7 +3,7 @@ import slugify from 'slugify' import { Injectable } from '@angular/core' import { HostAppService, Platform } from 'tabby-core' -import { ShellProvider, Shell } from '../api' +import { ShellProvider, Shell } from 'tabby-local' /** @hidden */ @Injectable() diff --git a/tabby-local/src/shells/powershellCore.ts b/tabby-electron/src/shells/powershellCore.ts similarity index 97% rename from tabby-local/src/shells/powershellCore.ts rename to tabby-electron/src/shells/powershellCore.ts index ba2fecdb..2792fd10 100644 --- a/tabby-local/src/shells/powershellCore.ts +++ b/tabby-electron/src/shells/powershellCore.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core' import { HostAppService, ConfigService, Platform } from 'tabby-core' -import { Shell } from '../api' +import { Shell } from 'tabby-local' import { WindowsBaseShellProvider } from './windowsBase' /* eslint-disable block-scoped-var */ diff --git a/tabby-local/src/shells/vs.ts b/tabby-electron/src/shells/vs.ts similarity index 98% rename from tabby-local/src/shells/vs.ts rename to tabby-electron/src/shells/vs.ts index d0a399ad..045c61d1 100644 --- a/tabby-local/src/shells/vs.ts +++ b/tabby-electron/src/shells/vs.ts @@ -3,7 +3,7 @@ import * as fs from 'fs/promises' import { Injectable } from '@angular/core' import { HostAppService, Platform } from 'tabby-core' -import { ShellProvider, Shell } from '../api' +import { ShellProvider, Shell } from 'tabby-local' /* eslint-disable quote-props */ const vsIconMap: Record = { diff --git a/tabby-local/src/shells/winDefault.ts b/tabby-electron/src/shells/winDefault.ts similarity index 96% rename from tabby-local/src/shells/winDefault.ts rename to tabby-electron/src/shells/winDefault.ts index 4583e041..854b9a3f 100644 --- a/tabby-local/src/shells/winDefault.ts +++ b/tabby-electron/src/shells/winDefault.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core' import { HostAppService, Platform, TranslateService } from 'tabby-core' -import { ShellProvider, Shell } from '../api' +import { ShellProvider, Shell } from 'tabby-local' import { WSLShellProvider } from './wsl' import { PowerShellCoreShellProvider } from './powershellCore' diff --git a/tabby-local/src/shells/windowsBase.ts b/tabby-electron/src/shells/windowsBase.ts similarity index 92% rename from tabby-local/src/shells/windowsBase.ts rename to tabby-electron/src/shells/windowsBase.ts index 82c000e4..cd0912bc 100644 --- a/tabby-local/src/shells/windowsBase.ts +++ b/tabby-electron/src/shells/windowsBase.ts @@ -1,6 +1,6 @@ import { ConfigService, HostAppService } from 'tabby-core' -import { ShellProvider } from '../api' +import { ShellProvider } from 'tabby-local' export abstract class WindowsBaseShellProvider extends ShellProvider { constructor ( diff --git a/tabby-local/src/shells/windowsStock.ts b/tabby-electron/src/shells/windowsStock.ts similarity index 96% rename from tabby-local/src/shells/windowsStock.ts rename to tabby-electron/src/shells/windowsStock.ts index d7010c3e..836efbdb 100644 --- a/tabby-local/src/shells/windowsStock.ts +++ b/tabby-electron/src/shells/windowsStock.ts @@ -3,9 +3,9 @@ import * as fs from 'fs/promises' import hasbin from 'hasbin' import { Injectable } from '@angular/core' import { HostAppService, Platform, ConfigService } from 'tabby-core' -import { ElectronService } from 'tabby-electron' +import { ElectronService } from '../services/electron.service' -import { Shell } from '../api' +import { Shell } from 'tabby-local' import { WindowsBaseShellProvider } from './windowsBase' /** @hidden */ diff --git a/tabby-local/src/shells/wsl.ts b/tabby-electron/src/shells/wsl.ts similarity index 98% rename from tabby-local/src/shells/wsl.ts rename to tabby-electron/src/shells/wsl.ts index 4dfb0aca..67811a4d 100644 --- a/tabby-local/src/shells/wsl.ts +++ b/tabby-electron/src/shells/wsl.ts @@ -4,7 +4,7 @@ import slugify from 'slugify' import { Injectable } from '@angular/core' import { HostAppService, Platform, isWindowsBuild, WIN_BUILD_WSL_EXE_DISTRO_FLAG } from 'tabby-core' -import { ShellProvider, Shell } from '../api' +import { ShellProvider, Shell } from 'tabby-local' /* eslint-disable block-scoped-var */ diff --git a/tabby-electron/yarn.lock b/tabby-electron/yarn.lock index c2d6611f..261aae14 100644 --- a/tabby-electron/yarn.lock +++ b/tabby-electron/yarn.lock @@ -21,6 +21,11 @@ async@^3.2.3: resolved "https://registry.yarnpkg.com/async/-/async-3.2.3.tgz#ac53dafd3f4720ee9e8a160628f18ea91df196c9" integrity sha512-spZRyzKL5l5BZQrr/6m/SqFdBN0q3OCI0f9rjfBzCMBIP4p75P620rR3gTmaksNOhmzgdxcaxdNfMy6anrbM0g== +async@~1.5: + version "1.5.2" + resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a" + integrity sha512-nSVgobk4rv61R9PUSDtYt7mPVB2olxNR5RWJcAsH676/ef11bUZwvu7+RGYrYauVdDPcO519v68wRhXQtxsV9w== + balanced-match@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" @@ -199,6 +204,13 @@ has@^1.0.3: dependencies: function-bind "^1.1.1" +hasbin@^1.2.3: + version "1.2.3" + resolved "https://registry.yarnpkg.com/hasbin/-/hasbin-1.2.3.tgz#78c5926893c80215c2b568ae1fd3fcab7a2696b0" + integrity sha512-CCd8e/w2w28G8DyZvKgiHnQJ/5XXDz6qiUHnthvtag/6T5acUeN5lqq+HMoBqcmgWueWDhiCplrw0Kb1zDACRg== + dependencies: + async "~1.5" + inflight@^1.0.4: version "1.0.6" resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" diff --git a/tabby-local/package.json b/tabby-local/package.json index 845a9fac..4816ab07 100644 --- a/tabby-local/package.json +++ b/tabby-local/package.json @@ -19,7 +19,6 @@ "devDependencies": { "ansi-colors": "^4.1.1", "dataurl": "0.1.0", - "hasbin": "^1.2.3", "ps-node": "^0.1.6", "runes": "^0.4.2" }, diff --git a/tabby-local/src/api.ts b/tabby-local/src/api.ts index 6d6eef59..9e022783 100644 --- a/tabby-local/src/api.ts +++ b/tabby-local/src/api.ts @@ -53,3 +53,9 @@ export interface ChildProcess { ppid: number command: string } + +export abstract class UACService { + isAvailable = false + + abstract patchSessionOptionsForUAC (sessionOptions: SessionOptions): SessionOptions +} diff --git a/tabby-local/src/components/localProfileSettings.component.pug b/tabby-local/src/components/localProfileSettings.component.pug index 5303928e..63d2692d 100644 --- a/tabby-local/src/components/localProfileSettings.component.pug +++ b/tabby-local/src/components/localProfileSettings.component.pug @@ -1,6 +1,6 @@ command-line-editor([model]='profile.options') -.form-line(*ngIf='uac.isAvailable') +.form-line(*ngIf='uac?.isAvailable') .header .title(translate) Run as administrator toggle( diff --git a/tabby-local/src/components/localProfileSettings.component.ts b/tabby-local/src/components/localProfileSettings.component.ts index fbb7a9a3..a79973f1 100644 --- a/tabby-local/src/components/localProfileSettings.component.ts +++ b/tabby-local/src/components/localProfileSettings.component.ts @@ -1,9 +1,7 @@ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ -import { Component } from '@angular/core' -import { UACService } from '../services/uac.service' -import { LocalProfile } from '../api' -import { ElectronHostWindow, ElectronService } from 'tabby-electron' -import { ProfileSettingsComponent } from 'tabby-core' +import { Component, Inject, Optional } from '@angular/core' +import { LocalProfile, UACService } from '../api' +import { PlatformService, ProfileSettingsComponent } from 'tabby-core' /** @hidden */ @@ -14,9 +12,8 @@ export class LocalProfileSettingsComponent implements ProfileSettingsComponent // eslint-disable-next-line @typescript-eslint/no-useless-constructor constructor ( injector: Injector, - private uac: UACService, + @Optional() @Inject(UACService) private uac: UACService|undefined, ) { super(injector) } @@ -57,7 +56,7 @@ export class TerminalTabComponent extends BaseTerminalTabComponent } initializeSession (columns: number, rows: number): void { - if (this.profile.options.runAsAdministrator && this.uac.isAvailable) { + if (this.profile.options.runAsAdministrator && this.uac?.isAvailable) { this.profile = { ...this.profile, options: this.uac.patchSessionOptionsForUAC(this.profile.options), diff --git a/tabby-local/src/index.ts b/tabby-local/src/index.ts index 02eb807f..f8effc5e 100644 --- a/tabby-local/src/index.ts +++ b/tabby-local/src/index.ts @@ -6,7 +6,6 @@ import { ToastrModule } from 'ngx-toastr' import TabbyCorePlugin, { HostAppService, ToolbarButtonProvider, TabRecoveryProvider, ConfigProvider, HotkeysService, HotkeyProvider, TabContextMenuItemProvider, CLIHandler, ConfigService, ProfileProvider } from 'tabby-core' import TabbyTerminalModule from 'tabby-terminal' -import TabbyElectronPlugin from 'tabby-electron' import { SettingsTabProvider } from 'tabby-settings' import { TerminalTabComponent } from './components/terminalTab.component' @@ -16,30 +15,14 @@ import { LocalProfileSettingsComponent } from './components/localProfileSettings import { CommandLineEditorComponent } from './components/commandLineEditor.component' import { TerminalService } from './services/terminal.service' -import { DockMenuService } from './services/dockMenu.service' import { ButtonProvider } from './buttonProvider' import { RecoveryProvider } from './recoveryProvider' -import { ShellProvider } from './api' import { ShellSettingsTabProvider } from './settings' import { TerminalConfigProvider } from './config' import { LocalTerminalHotkeyProvider } from './hotkeys' import { NewTabContextMenu, SaveAsProfileContextMenu } from './tabContextMenu' -import { CmderShellProvider } from './shells/cmder' -import { Cygwin32ShellProvider } from './shells/cygwin32' -import { Cygwin64ShellProvider } from './shells/cygwin64' -import { GitBashShellProvider } from './shells/gitBash' -import { LinuxDefaultShellProvider } from './shells/linuxDefault' -import { MacOSDefaultShellProvider } from './shells/macDefault' -import { MSYS2ShellProvider } from './shells/msys2' -import { POSIXShellsProvider } from './shells/posix' -import { PowerShellCoreShellProvider } from './shells/powershellCore' -import { WindowsDefaultShellProvider } from './shells/winDefault' -import { WindowsStockShellsProvider } from './shells/windowsStock' -import { WSLShellProvider } from './shells/wsl' -import { VSDevToolsProvider } from './shells/vs' - import { AutoOpenTabCLIHandler, OpenPathCLIHandler, TerminalCLIHandler } from './cli' import { LocalProfilesService } from './profiles' @@ -51,7 +34,6 @@ import { LocalProfilesService } from './profiles' NgbModule, ToastrModule, TabbyCorePlugin, - TabbyElectronPlugin, TabbyTerminalModule, ], providers: [ @@ -62,20 +44,6 @@ import { LocalProfilesService } from './profiles' { provide: ConfigProvider, useClass: TerminalConfigProvider, multi: true }, { provide: HotkeyProvider, useClass: LocalTerminalHotkeyProvider, multi: true }, - { provide: ShellProvider, useClass: WindowsDefaultShellProvider, multi: true }, - { provide: ShellProvider, useClass: MacOSDefaultShellProvider, multi: true }, - { provide: ShellProvider, useClass: LinuxDefaultShellProvider, multi: true }, - { provide: ShellProvider, useClass: WindowsStockShellsProvider, multi: true }, - { provide: ShellProvider, useClass: PowerShellCoreShellProvider, multi: true }, - { provide: ShellProvider, useClass: CmderShellProvider, multi: true }, - { provide: ShellProvider, useClass: Cygwin32ShellProvider, multi: true }, - { provide: ShellProvider, useClass: Cygwin64ShellProvider, multi: true }, - { provide: ShellProvider, useClass: GitBashShellProvider, multi: true }, - { provide: ShellProvider, useClass: POSIXShellsProvider, multi: true }, - { provide: ShellProvider, useClass: MSYS2ShellProvider, multi: true }, - { provide: ShellProvider, useClass: WSLShellProvider, multi: true }, - { provide: ShellProvider, useClass: VSDevToolsProvider, multi: true }, - { provide: ProfileProvider, useClass: LocalProfilesService, multi: true }, { provide: TabContextMenuItemProvider, useClass: NewTabContextMenu, multi: true }, @@ -84,11 +52,6 @@ import { LocalProfilesService } from './profiles' { provide: CLIHandler, useClass: TerminalCLIHandler, multi: true }, { provide: CLIHandler, useClass: OpenPathCLIHandler, multi: true }, { provide: CLIHandler, useClass: AutoOpenTabCLIHandler, multi: true }, - - // For WindowsDefaultShellProvider - PowerShellCoreShellProvider, - WSLShellProvider, - WindowsStockShellsProvider, ], declarations: [ TerminalTabComponent, @@ -108,7 +71,6 @@ export default class LocalTerminalModule { // eslint-disable-line @typescript-es hotkeys: HotkeysService, terminal: TerminalService, hostApp: HostAppService, - dockMenu: DockMenuService, config: ConfigService, ) { hotkeys.hotkey$.subscribe(async (hotkey) => { @@ -119,10 +81,6 @@ export default class LocalTerminalModule { // eslint-disable-line @typescript-es hostApp.newWindow() } }) - - config.ready$.toPromise().then(() => { - dockMenu.update() - }) } } diff --git a/tabby-local/src/tabContextMenu.ts b/tabby-local/src/tabContextMenu.ts index 0cbec51a..1671e652 100644 --- a/tabby-local/src/tabContextMenu.ts +++ b/tabby-local/src/tabContextMenu.ts @@ -1,10 +1,9 @@ -import { Injectable } from '@angular/core' +import { Inject, Injectable, Optional } from '@angular/core' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { ConfigService, BaseTabComponent, TabContextMenuItemProvider, NotificationsService, MenuItemOptions, ProfilesService, PromptModalComponent, TranslateService } from 'tabby-core' import { TerminalTabComponent } from './components/terminalTab.component' -import { UACService } from './services/uac.service' import { TerminalService } from './services/terminal.service' -import { LocalProfile } from './api' +import { LocalProfile, UACService } from './api' /** @hidden */ @Injectable() @@ -64,7 +63,7 @@ export class NewTabContextMenu extends TabContextMenuItemProvider { public config: ConfigService, private profilesService: ProfilesService, private terminalService: TerminalService, - private uac: UACService, + @Optional() @Inject(UACService) private uac: UACService|undefined, private translate: TranslateService, ) { super() @@ -99,7 +98,7 @@ export class NewTabContextMenu extends TabContextMenuItemProvider { }, ] - if (this.uac.isAvailable) { + if (this.uac?.isAvailable) { items.push({ label: this.translate.instant('New admin tab'), submenu: profiles.map(profile => ({ @@ -117,7 +116,7 @@ export class NewTabContextMenu extends TabContextMenuItemProvider { }) } - if (tab instanceof TerminalTabComponent && tabHeader && this.uac.isAvailable) { + if (tab instanceof TerminalTabComponent && tabHeader && this.uac?.isAvailable) { const terminalTab = tab items.push({ label: this.translate.instant('Duplicate as administrator'), diff --git a/tabby-local/yarn.lock b/tabby-local/yarn.lock index 67cf037e..6340c69f 100644 --- a/tabby-local/yarn.lock +++ b/tabby-local/yarn.lock @@ -7,11 +7,6 @@ ansi-colors@^4.1.1: resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.1.tgz#cbb9ae256bf750af1eab344f229aa27fe94ba348" integrity sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA== -async@~1.5: - version "1.5.2" - resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a" - integrity sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo= - connected-domain@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/connected-domain/-/connected-domain-1.0.0.tgz#bfe77238c74be453a79f0cb6058deeb4f2358e93" @@ -22,13 +17,6 @@ dataurl@0.1.0: resolved "https://registry.yarnpkg.com/dataurl/-/dataurl-0.1.0.tgz#1f4734feddec05ffe445747978d86759c4b33199" integrity sha1-H0c0/t3sBf/kRXR5eNhnWcSzMZk= -hasbin@^1.2.3: - version "1.2.3" - resolved "https://registry.yarnpkg.com/hasbin/-/hasbin-1.2.3.tgz#78c5926893c80215c2b568ae1fd3fcab7a2696b0" - integrity sha1-eMWSaJPIAhXCtWiuH9P8q3omlrA= - dependencies: - async "~1.5" - ps-node@^0.1.6: version "0.1.6" resolved "https://registry.yarnpkg.com/ps-node/-/ps-node-0.1.6.tgz#9af67a99d7b1d0132e51a503099d38a8d2ace2c3" diff --git a/tabby-web/src/platform.ts b/tabby-web/src/platform.ts index 074d66e2..035e2b6b 100644 --- a/tabby-web/src/platform.ts +++ b/tabby-web/src/platform.ts @@ -138,6 +138,10 @@ export class WebPlatformService extends PlatformService { setErrorHandler (handler: (_: any) => void): void { window.addEventListener('error', handler) } + + async pickDirectory (): Promise { + throw new Error('Unsupported') + } } class HTMLFileDownload extends FileDownload {