mirror of
https://github.com/Eugeny/tabby.git
synced 2025-06-14 00:20:13 +00:00
plug some leaks
This commit is contained in:
parent
5b4a1a5581
commit
17c93aa3fc
@ -6,13 +6,12 @@ import { trigger, transition, style, animate, AnimationTriggerMetadata } from '@
|
|||||||
import { AppService, ConfigService, BaseTabComponent, HostAppService, HotkeysService, NotificationsService, Platform, LogService, Logger, TabContextMenuItemProvider, SplitTabComponent, SubscriptionContainer, MenuItemOptions, PlatformService, HostWindowService, ResettableTimeout, TranslateService } from 'tabby-core'
|
import { AppService, ConfigService, BaseTabComponent, HostAppService, HotkeysService, NotificationsService, Platform, LogService, Logger, TabContextMenuItemProvider, SplitTabComponent, SubscriptionContainer, MenuItemOptions, PlatformService, HostWindowService, ResettableTimeout, TranslateService } from 'tabby-core'
|
||||||
|
|
||||||
import { BaseSession } from '../session'
|
import { BaseSession } from '../session'
|
||||||
import { TerminalFrontendService } from '../services/terminalFrontend.service'
|
|
||||||
|
|
||||||
import { Frontend } from '../frontends/frontend'
|
import { Frontend } from '../frontends/frontend'
|
||||||
|
import { XTermFrontend, XTermWebGLFrontend } from '../frontends/xtermFrontend'
|
||||||
import { ResizeEvent } from './interfaces'
|
import { ResizeEvent } from './interfaces'
|
||||||
import { TerminalDecorator } from './decorator'
|
import { TerminalDecorator } from './decorator'
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class to base your custom terminal tabs on
|
* A class to base your custom terminal tabs on
|
||||||
*/
|
*/
|
||||||
@ -112,7 +111,6 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
|
|||||||
protected hostApp: HostAppService
|
protected hostApp: HostAppService
|
||||||
protected hotkeys: HotkeysService
|
protected hotkeys: HotkeysService
|
||||||
protected platform: PlatformService
|
protected platform: PlatformService
|
||||||
protected terminalContainersService: TerminalFrontendService
|
|
||||||
protected notifications: NotificationsService
|
protected notifications: NotificationsService
|
||||||
protected log: LogService
|
protected log: LogService
|
||||||
protected decorators: TerminalDecorator[] = []
|
protected decorators: TerminalDecorator[] = []
|
||||||
@ -181,7 +179,6 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
|
|||||||
this.hostApp = injector.get(HostAppService)
|
this.hostApp = injector.get(HostAppService)
|
||||||
this.hotkeys = injector.get(HotkeysService)
|
this.hotkeys = injector.get(HotkeysService)
|
||||||
this.platform = injector.get(PlatformService)
|
this.platform = injector.get(PlatformService)
|
||||||
this.terminalContainersService = injector.get(TerminalFrontendService)
|
|
||||||
this.notifications = injector.get(NotificationsService)
|
this.notifications = injector.get(NotificationsService)
|
||||||
this.log = injector.get(LogService)
|
this.log = injector.get(LogService)
|
||||||
this.decorators = injector.get<any>(TerminalDecorator, null, InjectFlags.Optional) as TerminalDecorator[]
|
this.decorators = injector.get<any>(TerminalDecorator, null, InjectFlags.Optional) as TerminalDecorator[]
|
||||||
@ -294,7 +291,11 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
|
|||||||
this.frontend?.focus()
|
this.frontend?.focus()
|
||||||
})
|
})
|
||||||
|
|
||||||
this.frontend = this.terminalContainersService.getFrontend(this.session)
|
const cls: new (..._) => Frontend = {
|
||||||
|
xterm: XTermFrontend,
|
||||||
|
'xterm-webgl': XTermWebGLFrontend,
|
||||||
|
}[this.config.store.terminal.frontend] ?? XTermFrontend
|
||||||
|
this.frontend = new cls(this.injector)
|
||||||
|
|
||||||
this.frontendReady$.pipe(first()).subscribe(() => {
|
this.frontendReady$.pipe(first()).subscribe(() => {
|
||||||
this.onFrontendReady()
|
this.onFrontendReady()
|
||||||
@ -555,6 +556,7 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
|
|||||||
|
|
||||||
async destroy (): Promise<void> {
|
async destroy (): Promise<void> {
|
||||||
this.frontend?.detach(this.content.nativeElement)
|
this.frontend?.detach(this.content.nativeElement)
|
||||||
|
this.frontend?.destroy()
|
||||||
this.frontend = undefined
|
this.frontend = undefined
|
||||||
this.content.nativeElement.remove()
|
this.content.nativeElement.remove()
|
||||||
this.detachTermContainerHandlers()
|
this.detachTermContainerHandlers()
|
||||||
@ -731,7 +733,6 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
|
|||||||
|
|
||||||
if (destroyOnSessionClose) {
|
if (destroyOnSessionClose) {
|
||||||
this.attachSessionHandler(this.session.closed$, () => {
|
this.attachSessionHandler(this.session.closed$, () => {
|
||||||
this.frontend?.destroy()
|
|
||||||
this.destroy()
|
this.destroy()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,6 @@ import { SearchPanelComponent } from './components/searchPanel.component'
|
|||||||
import { StreamProcessingSettingsComponent } from './components/streamProcessingSettings.component'
|
import { StreamProcessingSettingsComponent } from './components/streamProcessingSettings.component'
|
||||||
import { LoginScriptsSettingsComponent } from './components/loginScriptsSettings.component'
|
import { LoginScriptsSettingsComponent } from './components/loginScriptsSettings.component'
|
||||||
|
|
||||||
import { TerminalFrontendService } from './services/terminalFrontend.service'
|
|
||||||
|
|
||||||
import { TerminalDecorator } from './api/decorator'
|
import { TerminalDecorator } from './api/decorator'
|
||||||
import { TerminalContextMenuItemProvider } from './api/contextMenuProvider'
|
import { TerminalContextMenuItemProvider } from './api/contextMenuProvider'
|
||||||
import { TerminalColorSchemeProvider } from './api/colorSchemeProvider'
|
import { TerminalColorSchemeProvider } from './api/colorSchemeProvider'
|
||||||
@ -83,7 +81,7 @@ import { TerminalCLIHandler } from './cli'
|
|||||||
})
|
})
|
||||||
export default class TerminalModule { } // eslint-disable-line @typescript-eslint/no-extraneous-class
|
export default class TerminalModule { } // eslint-disable-line @typescript-eslint/no-extraneous-class
|
||||||
|
|
||||||
export { TerminalFrontendService, TerminalDecorator, TerminalContextMenuItemProvider, TerminalColorSchemeProvider }
|
export { TerminalDecorator, TerminalContextMenuItemProvider, TerminalColorSchemeProvider }
|
||||||
export { Frontend, XTermFrontend, XTermWebGLFrontend }
|
export { Frontend, XTermFrontend, XTermWebGLFrontend }
|
||||||
export { BaseTerminalTabComponent } from './api/baseTerminalTab.component'
|
export { BaseTerminalTabComponent } from './api/baseTerminalTab.component'
|
||||||
export * from './api/interfaces'
|
export * from './api/interfaces'
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
import { Injectable, Injector } from '@angular/core'
|
|
||||||
import { ConfigService } from 'tabby-core'
|
|
||||||
import { Frontend } from '../frontends/frontend'
|
|
||||||
import { XTermFrontend, XTermWebGLFrontend } from '../frontends/xtermFrontend'
|
|
||||||
import { BaseSession } from '../session'
|
|
||||||
|
|
||||||
@Injectable({ providedIn: 'root' })
|
|
||||||
export class TerminalFrontendService {
|
|
||||||
private containers = new WeakMap<BaseSession, Frontend>()
|
|
||||||
|
|
||||||
/** @hidden */
|
|
||||||
private constructor (
|
|
||||||
private config: ConfigService,
|
|
||||||
private injector: Injector,
|
|
||||||
) { }
|
|
||||||
|
|
||||||
getFrontend (session?: BaseSession|null): Frontend {
|
|
||||||
if (!session) {
|
|
||||||
const cls = {
|
|
||||||
xterm: XTermFrontend,
|
|
||||||
'xterm-webgl': XTermWebGLFrontend,
|
|
||||||
}[this.config.store.terminal.frontend] ?? XTermFrontend
|
|
||||||
return new cls(this.injector)
|
|
||||||
}
|
|
||||||
if (!this.containers.has(session)) {
|
|
||||||
this.containers.set(
|
|
||||||
session,
|
|
||||||
this.getFrontend(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return this.containers.get(session)!
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user