diff --git a/tabby-serial/src/components/serialTab.component.ts b/tabby-serial/src/components/serialTab.component.ts index 3e332f81..cc11189b 100644 --- a/tabby-serial/src/components/serialTab.component.ts +++ b/tabby-serial/src/components/serialTab.component.ts @@ -4,7 +4,7 @@ import colors from 'ansi-colors' import { Component, Injector } from '@angular/core' import { first } from 'rxjs' import { GetRecoveryTokenOptions, Platform, SelectorService } from 'tabby-core' -import { BaseTerminalTabComponent, Reconnectable } from 'tabby-terminal' +import { BaseTerminalTabComponent, ConnectableTerminalTabComponent, Reconnectable } from 'tabby-terminal' import { SerialSession, BAUD_RATES, SerialProfile } from '../api' /** @hidden */ @@ -14,7 +14,7 @@ import { SerialSession, BAUD_RATES, SerialProfile } from '../api' styleUrls: ['./serialTab.component.scss', ...BaseTerminalTabComponent.styles], animations: BaseTerminalTabComponent.animations, }) -export class SerialTabComponent extends BaseTerminalTabComponent implements Reconnectable { +export class SerialTabComponent extends ConnectableTerminalTabComponent implements Reconnectable { session: SerialSession|null = null Platform = Platform diff --git a/tabby-ssh/src/components/sshTab.component.ts b/tabby-ssh/src/components/sshTab.component.ts index 97bc2da5..a5be1bc2 100644 --- a/tabby-ssh/src/components/sshTab.component.ts +++ b/tabby-ssh/src/components/sshTab.component.ts @@ -4,7 +4,7 @@ import { Component, Injector, HostListener } from '@angular/core' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { first } from 'rxjs' import { GetRecoveryTokenOptions, Platform, ProfilesService, RecoveryToken } from 'tabby-core' -import { BaseTerminalTabComponent, Reconnectable } from 'tabby-terminal' +import { BaseTerminalTabComponent, ConnectableTerminalTabComponent, Reconnectable } from 'tabby-terminal' import { SSHService } from '../services/ssh.service' import { KeyboardInteractivePrompt, SSHSession } from '../session/ssh' import { SSHPortForwardingModalComponent } from './sshPortForwardingModal.component' @@ -22,7 +22,7 @@ import { SSHMultiplexerService } from '../services/sshMultiplexer.service' ], animations: BaseTerminalTabComponent.animations, }) -export class SSHTabComponent extends BaseTerminalTabComponent implements Reconnectable { +export class SSHTabComponent extends ConnectableTerminalTabComponent implements Reconnectable { Platform = Platform sshSession: SSHSession|null = null session: SSHShellSession|null = null @@ -30,7 +30,6 @@ export class SSHTabComponent extends BaseTerminalTabComponent implem sftpPath = '/' enableToolbar = true activeKIPrompt: KeyboardInteractivePrompt|null = null - private reconnectOffered = false constructor ( injector: Injector, diff --git a/tabby-telnet/src/components/telnetTab.component.ts b/tabby-telnet/src/components/telnetTab.component.ts index d3ae2cf4..1cced0dd 100644 --- a/tabby-telnet/src/components/telnetTab.component.ts +++ b/tabby-telnet/src/components/telnetTab.component.ts @@ -3,7 +3,7 @@ import colors from 'ansi-colors' import { Component, Injector } from '@angular/core' import { first } from 'rxjs' import { GetRecoveryTokenOptions, Platform, RecoveryToken } from 'tabby-core' -import { BaseTerminalTabComponent, Reconnectable } from 'tabby-terminal' +import { BaseTerminalTabComponent, ConnectableTerminalTabComponent, Reconnectable } from 'tabby-terminal' import { TelnetProfile, TelnetSession } from '../session' @@ -14,10 +14,9 @@ import { TelnetProfile, TelnetSession } from '../session' styleUrls: ['./telnetTab.component.scss', ...BaseTerminalTabComponent.styles], animations: BaseTerminalTabComponent.animations, }) -export class TelnetTabComponent extends BaseTerminalTabComponent implements Reconnectable { +export class TelnetTabComponent extends ConnectableTerminalTabComponent implements Reconnectable { Platform = Platform session: TelnetSession|null = null - private reconnectOffered = false // eslint-disable-next-line @typescript-eslint/no-useless-constructor constructor ( diff --git a/tabby-terminal/src/api/connectableTerminalTab.component.ts b/tabby-terminal/src/api/connectableTerminalTab.component.ts new file mode 100644 index 00000000..6eacb3f8 --- /dev/null +++ b/tabby-terminal/src/api/connectableTerminalTab.component.ts @@ -0,0 +1,26 @@ +import { Injector, Component } from '@angular/core' + +import { BaseTerminalProfile } from './interfaces' +import { BaseTerminalTabComponent } from './baseTerminalTab.component' + +/** + * A class to base your custom connectable terminal tabs on + */ +@Component({ template: '' }) +export abstract class ConnectableTerminalTabComponent

extends BaseTerminalTabComponent

{ + + protected reconnectOffered = false + + constructor (protected injector: Injector) { + super(injector) + } + + abstract initializeSession (): Promise + + async reconnect (): Promise { + this.session?.destroy() + await this.initializeSession() + this.session?.releaseInitialDataBuffer() + } + +} diff --git a/tabby-terminal/src/index.ts b/tabby-terminal/src/index.ts index f41b5007..9c00c0ef 100644 --- a/tabby-terminal/src/index.ts +++ b/tabby-terminal/src/index.ts @@ -90,6 +90,7 @@ export default class TerminalModule { } // eslint-disable-line @typescript-eslin export { TerminalDecorator, TerminalContextMenuItemProvider, TerminalColorSchemeProvider } export { Frontend, XTermFrontend, XTermWebGLFrontend } export { BaseTerminalTabComponent } from './api/baseTerminalTab.component' +export { ConnectableTerminalTabComponent } from './api/connectableTerminalTab.component' export * from './api/interfaces' export * from './middleware/streamProcessing' export * from './middleware/loginScriptProcessing'