mirror of
https://github.com/Eugeny/tabby.git
synced 2025-06-26 06:19:53 +00:00
26 lines
887 B
TypeScript
26 lines
887 B
TypeScript
import { Injectable } from '@angular/core'
|
|
import { ConfigService } from 'terminus-core'
|
|
import { Frontend } from '../frontends/frontend'
|
|
import { HTermFrontend } from '../frontends/htermFrontend'
|
|
import { XTermFrontend } from '../frontends/xtermFrontend'
|
|
import { BaseSession } from '../services/sessions.service'
|
|
|
|
@Injectable({ providedIn: 'root' })
|
|
export class TerminalFrontendService {
|
|
private containers = new WeakMap<BaseSession, Frontend>()
|
|
|
|
constructor (private config: ConfigService) { }
|
|
|
|
getFrontend (session: BaseSession): Frontend {
|
|
if (!this.containers.has(session)) {
|
|
this.containers.set(
|
|
session,
|
|
(this.config.store.terminal.frontend === 'xterm')
|
|
? new XTermFrontend()
|
|
: new HTermFrontend()
|
|
)
|
|
}
|
|
return this.containers.get(session)
|
|
}
|
|
}
|