This commit is contained in:
Eugene Pankov
2020-03-01 16:10:45 +01:00
parent fda4d2dcef
commit 04a0a0cc64
81 changed files with 284 additions and 295 deletions

View File

@@ -1,7 +1,7 @@
export { BaseTabComponent, BaseTabProcess } from '../components/baseTab.component'
export { TabHeaderComponent } from '../components/tabHeader.component'
export { SplitTabComponent, SplitContainer } from '../components/splitTab.component'
export { TabRecoveryProvider, RecoveredTab } from './tabRecovery'
export { TabRecoveryProvider, RecoveredTab, RecoveryToken } from './tabRecovery'
export { ToolbarButtonProvider, ToolbarButton } from './toolbarButtonProvider'
export { ConfigProvider } from './configProvider'
export { HotkeyProvider, HotkeyDescription } from './hotkeyProvider'

View File

@@ -12,6 +12,12 @@ export interface RecoveredTab {
options?: any
}
export interface RecoveryToken {
[_: string]: any
type: string
tabColor?: string|null
}
/**
* Extend to enable recovery for your custom tab.
* This works in conjunction with [[getRecoveryToken()]]
@@ -34,5 +40,5 @@ export abstract class TabRecoveryProvider {
* @returns [[RecoveredTab]] descriptor containing tab type and component inputs
* or `null` if this token is from a different tab type or is not supported
*/
abstract async recover (recoveryToken: any): Promise<RecoveredTab|null>
abstract async recover (recoveryToken: RecoveryToken): Promise<RecoveredTab|null>
}

View File

@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { Component, Inject, Input, HostListener, HostBinding } from '@angular/core'
import { trigger, style, animate, transition, state } from '@angular/animations'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'

View File

@@ -1,5 +1,6 @@
import { Observable, Subject } from 'rxjs'
import { ViewRef } from '@angular/core'
import { RecoveryToken } from '../api/tabRecovery'
/**
* Represents an active "process" inside a tab,
@@ -71,7 +72,7 @@ export abstract class BaseTabComponent {
})
}
setTitle (title: string) {
setTitle (title: string): void {
this.title = title
if (!this.customTitle) {
this.titleChange.next(title)
@@ -83,7 +84,7 @@ export abstract class BaseTabComponent {
*
* @param {type} progress: value between 0 and 1, or `null` to remove
*/
setProgress (progress: number|null) {
setProgress (progress: number|null): void {
this.progress.next(progress)
if (progress) {
if (this.progressClearTimeout) {
@@ -118,7 +119,7 @@ export abstract class BaseTabComponent {
* @return JSON serializable tab state representation
* for your [[TabRecoveryProvider]] to parse
*/
async getRecoveryToken (): Promise<any> {
async getRecoveryToken (): Promise<RecoveryToken|null> {
return null
}
@@ -136,11 +137,11 @@ export abstract class BaseTabComponent {
return true
}
emitFocused () {
emitFocused (): void {
this.focused.next()
}
emitBlurred () {
emitBlurred (): void {
this.blurred.next()
}

View File

@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { NgZone, Component, Input, HostBinding, HostListener } from '@angular/core'
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'

View File

@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { Component, Input, ElementRef, ViewChild } from '@angular/core'
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'

View File

@@ -14,7 +14,7 @@ export class SafeModeModalComponent {
this.error = window['safeModeReason']
}
close () {
close (): void {
this.modalInstance.dismiss()
}
}

View File

@@ -17,11 +17,11 @@ export class SelectorModalComponent<T> {
public modalInstance: NgbActiveModal,
) { }
ngOnInit () {
ngOnInit (): void {
this.onFilterChange()
}
onFilterChange () {
onFilterChange (): void {
const f = this.filter.trim().toLowerCase()
if (!f) {
this.filteredOptions = this.options
@@ -31,17 +31,17 @@ export class SelectorModalComponent<T> {
}
}
onFilterEnter () {
onFilterEnter (): void {
if (this.filteredOptions.length === 1) {
this.selectOption(this.filteredOptions[0])
}
}
selectOption (option: SelectorOption<T>) {
selectOption (option: SelectorOption<T>): void {
this.modalInstance.close(option.result)
}
close () {
close (): void {
this.modalInstance.dismiss()
}
}

View File

@@ -1,7 +1,7 @@
import { Observable, Subject, Subscription } from 'rxjs'
import { Component, Injectable, ViewChild, ViewContainerRef, EmbeddedViewRef, AfterViewInit, OnDestroy } from '@angular/core'
import { BaseTabComponent, BaseTabProcess } from './baseTab.component'
import { TabRecoveryProvider, RecoveredTab } from '../api/tabRecovery'
import { TabRecoveryProvider, RecoveredTab, RecoveryToken } from '../api/tabRecovery'
import { TabsService } from '../services/tabs.service'
import { HotkeysService } from '../services/hotkeys.service'
import { TabRecoveryService } from '../services/tabRecovery.service'
@@ -48,7 +48,7 @@ export class SplitContainer {
/**
* Remove unnecessarily nested child containers and renormalizes [[ratios]]
*/
normalize () {
normalize (): void {
for (let i = 0; i < this.children.length; i++) {
const child = this.children[i]
@@ -93,7 +93,7 @@ export class SplitContainer {
return s
}
async serialize () {
async serialize (): Promise<RecoveryToken> {
const children: any[] = []
for (const child of this.children) {
if (child instanceof SplitContainer) {
@@ -250,7 +250,7 @@ export class SplitTabComponent extends BaseTabComponent implements AfterViewInit
}
/** @hidden */
async ngAfterViewInit () {
async ngAfterViewInit (): Promise<void> {
if (this._recoveredState) {
await this.recoverContainer(this.root, this._recoveredState)
this.layout()
@@ -266,12 +266,12 @@ export class SplitTabComponent extends BaseTabComponent implements AfterViewInit
}
/** @hidden */
ngOnDestroy () {
ngOnDestroy (): void {
this.hotkeysSubscription.unsubscribe()
}
/** @returns Flat list of all sub-tabs */
getAllTabs () {
getAllTabs (): BaseTabComponent[] {
return this.root.getAllTabs()
}
@@ -283,7 +283,7 @@ export class SplitTabComponent extends BaseTabComponent implements AfterViewInit
return this.maximizedTab
}
focus (tab: BaseTabComponent) {
focus (tab: BaseTabComponent): void {
this.focusedTab = tab
for (const x of this.getAllTabs()) {
if (x !== tab) {
@@ -301,7 +301,7 @@ export class SplitTabComponent extends BaseTabComponent implements AfterViewInit
this.layout()
}
maximize (tab: BaseTabComponent|null) {
maximize (tab: BaseTabComponent|null): void {
this.maximizedTab = tab
this.layout()
}
@@ -309,7 +309,7 @@ export class SplitTabComponent extends BaseTabComponent implements AfterViewInit
/**
* Focuses the first available tab inside the given [[SplitContainer]]
*/
focusAnyIn (parent: BaseTabComponent | SplitContainer) {
focusAnyIn (parent: BaseTabComponent | SplitContainer): void {
if (!parent) {
return
}
@@ -323,7 +323,7 @@ export class SplitTabComponent extends BaseTabComponent implements AfterViewInit
/**
* Inserts a new `tab` to the `side` of the `relative` tab
*/
async addTab (tab: BaseTabComponent, relative: BaseTabComponent|null, side: SplitDirection) {
async addTab (tab: BaseTabComponent, relative: BaseTabComponent|null, side: SplitDirection): Promise<void> {
await this.initialized$.toPromise()
let target = (relative ? this.getParentOf(relative) : null) || this.root
@@ -364,7 +364,7 @@ export class SplitTabComponent extends BaseTabComponent implements AfterViewInit
})
}
removeTab (tab: BaseTabComponent) {
removeTab (tab: BaseTabComponent): void {
const parent = this.getParentOf(tab)
if (!parent) {
return
@@ -389,7 +389,7 @@ export class SplitTabComponent extends BaseTabComponent implements AfterViewInit
/**
* Moves focus in the given direction
*/
navigate (dir: SplitDirection) {
navigate (dir: SplitDirection): void {
let rel: BaseTabComponent | SplitContainer = this.focusedTab
let parent = this.getParentOf(rel)
if (!parent) {
@@ -422,11 +422,12 @@ export class SplitTabComponent extends BaseTabComponent implements AfterViewInit
}
}
async splitTab (tab: BaseTabComponent, dir: SplitDirection) {
async splitTab (tab: BaseTabComponent, dir: SplitDirection): Promise<BaseTabComponent|null> {
const newTab = await this.tabsService.duplicate(tab)
if (newTab) {
this.addTab(newTab, tab, dir)
}
return newTab
}
/**
@@ -464,12 +465,12 @@ export class SplitTabComponent extends BaseTabComponent implements AfterViewInit
}
/** @hidden */
onSpannerAdjusted (spanner: SplitSpannerInfo) {
onSpannerAdjusted (spanner: SplitSpannerInfo): void {
this.layout()
this.splitAdjusted.next(spanner)
}
destroy () {
destroy (): void {
super.destroy()
for (const x of this.getAllTabs()) {
x.destroy()
@@ -584,7 +585,7 @@ export class SplitTabComponent extends BaseTabComponent implements AfterViewInit
/** @hidden */
@Injectable()
export class SplitTabRecoveryProvider extends TabRecoveryProvider {
async recover (recoveryToken: any): Promise<RecoveredTab|null> {
async recover (recoveryToken: RecoveryToken): Promise<RecoveredTab|null> {
if (recoveryToken && recoveryToken.type === 'app:split-tab') {
return {
type: SplitTabComponent,

View File

@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { Component, Input, HostBinding, ElementRef, Output, EventEmitter } from '@angular/core'
import { SplitContainer } from './splitTab.component'

View File

@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { Component, Input, ViewChild, HostBinding, ViewContainerRef, OnChanges } from '@angular/core'
import { BaseTabComponent } from '../components/baseTab.component'

View File

@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { Component, Input, Optional, Inject, HostBinding, HostListener, ViewChild, ElementRef } from '@angular/core'
import { SortableComponent } from 'ng2-dnd'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'

View File

@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { Component } from '@angular/core'
import { BaseTabComponent } from './baseTab.component'
import { ConfigService } from '../services/config.service'

View File

@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { Component } from '@angular/core'
import { HostAppService } from '../services/hostApp.service'
import { AppService } from '../services/app.service'

View File

@@ -7,7 +7,7 @@ import { Directive, AfterViewInit, ElementRef } from '@angular/core'
export class AutofocusDirective implements AfterViewInit {
constructor (private el: ElementRef) { }
ngAfterViewInit () {
ngAfterViewInit (): void {
this.el.nativeElement.blur()
setTimeout(() => {
this.el.nativeElement.focus()

View File

@@ -8,7 +8,7 @@ export class FastHtmlBindDirective implements OnChanges {
@Input() fastHtmlBind: string
constructor (private el: ElementRef) { }
ngOnChanges () {
ngOnChanges (): void {
this.el.nativeElement.innerHTML = this.fastHtmlBind || ''
}
}

View File

@@ -93,7 +93,7 @@ export class AppService {
})
}
startTabStorage () {
startTabStorage (): void {
this.tabsChanged$.subscribe(() => {
this.tabRecovery.saveTabs(this.tabs)
})
@@ -102,7 +102,7 @@ export class AppService {
}, 30000)
}
addTabRaw (tab: BaseTabComponent, index: number|null = null) {
addTabRaw (tab: BaseTabComponent, index: number|null = null): void {
if (index !== null) {
this.tabs.splice(index, 0, tab)
} else {
@@ -145,7 +145,7 @@ export class AppService {
* Adds a new tab **without** wrapping it in a SplitTabComponent
* @param inputs Properties to be assigned on the new tab component instance
*/
openNewTabRaw (type: TabComponentType, inputs?: any): BaseTabComponent {
openNewTabRaw (type: TabComponentType, inputs?: Record<string, any>): BaseTabComponent {
const tab = this.tabsService.create(type, inputs)
this.addTabRaw(tab)
return tab
@@ -155,7 +155,7 @@ export class AppService {
* Adds a new tab while wrapping it in a SplitTabComponent
* @param inputs Properties to be assigned on the new tab component instance
*/
openNewTab (type: TabComponentType, inputs?: any): BaseTabComponent {
openNewTab (type: TabComponentType, inputs?: Record<string, any>): BaseTabComponent {
const splitTab = this.tabsService.create(SplitTabComponent) as SplitTabComponent
const tab = this.tabsService.create(type, inputs)
splitTab.addTab(tab, null, 'r')
@@ -163,7 +163,7 @@ export class AppService {
return tab
}
selectTab (tab: BaseTabComponent) {
selectTab (tab: BaseTabComponent): void {
if (this._activeTab === tab) {
this._activeTab.emitFocused()
return
@@ -199,14 +199,14 @@ export class AppService {
}
/** Switches between the current tab and the previously active one */
toggleLastTab () {
toggleLastTab (): void {
if (!this.lastTabIndex || this.lastTabIndex >= this.tabs.length) {
this.lastTabIndex = 0
}
this.selectTab(this.tabs[this.lastTabIndex])
}
nextTab () {
nextTab (): void {
if (this.tabs.length > 1) {
const tabIndex = this.tabs.indexOf(this._activeTab)
if (tabIndex < this.tabs.length - 1) {
@@ -217,7 +217,7 @@ export class AppService {
}
}
previousTab () {
previousTab (): void {
if (this.tabs.length > 1) {
const tabIndex = this.tabs.indexOf(this._activeTab)
if (tabIndex > 0) {
@@ -228,7 +228,7 @@ export class AppService {
}
}
moveSelectedTabLeft () {
moveSelectedTabLeft (): void {
if (this.tabs.length > 1) {
const tabIndex = this.tabs.indexOf(this._activeTab)
if (tabIndex > 0) {
@@ -239,7 +239,7 @@ export class AppService {
}
}
moveSelectedTabRight () {
moveSelectedTabRight (): void {
if (this.tabs.length > 1) {
const tabIndex = this.tabs.indexOf(this._activeTab)
if (tabIndex < this.tabs.length - 1) {
@@ -250,7 +250,7 @@ export class AppService {
}
}
swapTabs (a: BaseTabComponent, b: BaseTabComponent) {
swapTabs (a: BaseTabComponent, b: BaseTabComponent): void {
const i1 = this.tabs.indexOf(a)
const i2 = this.tabs.indexOf(b)
this.tabs[i1] = b
@@ -258,7 +258,7 @@ export class AppService {
}
/** @hidden */
emitTabsChanged () {
emitTabsChanged (): void {
this.tabsChanged.next()
}
@@ -272,11 +272,12 @@ export class AppService {
tab.destroy()
}
async duplicateTab (tab: BaseTabComponent) {
async duplicateTab (tab: BaseTabComponent): Promise<BaseTabComponent|null> {
const dup = await this.tabsService.duplicate(tab)
if (dup) {
this.addTabRaw(dup, this.tabs.indexOf(tab) + 1)
}
return dup
}
/**
@@ -295,7 +296,7 @@ export class AppService {
}
/** @hidden */
emitReady () {
emitReady (): void {
this.ready.next()
this.ready.complete()
this.hostApp.emitReady()
@@ -316,7 +317,7 @@ export class AppService {
return this.completionObservers.get(tab)!.done$
}
stopObservingTabCompletion (tab: BaseTabComponent) {
stopObservingTabCompletion (tab: BaseTabComponent): void {
this.completionObservers.delete(tab)
}

View File

@@ -20,7 +20,7 @@ function isNonStructuralObjectMember (v): boolean {
/** @hidden */
export class ConfigProxy {
constructor (real: any, defaults: any) {
constructor (real: Record<string, any>, defaults: Record<string, any>) {
for (const key in defaults) {
if (isStructuralMember(defaults[key])) {
if (!real[key]) {
@@ -71,8 +71,10 @@ export class ConfigProxy {
}
}
getValue (_key: string): any { } // eslint-disable-line @typescript-eslint/no-empty-function
setValue (_key: string, _value: any) { } // eslint-disable-line @typescript-eslint/no-empty-function
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-empty-function
getValue (_key: string): any { }
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-empty-function
setValue (_key: string, _value: any) { }
}
@Injectable({ providedIn: 'root' })
@@ -124,7 +126,7 @@ export class ConfigService {
})
}
getDefaults () {
getDefaults (): Record<string, any> {
const cleanup = o => {
if (o instanceof Array) {
return o.map(cleanup)

View File

@@ -15,7 +15,7 @@ export class DockingService {
electron.screen.on('display-metrics-changed', () => this.repositionWindow())
}
dock () {
dock (): void {
const dockSide = this.config.store.appearance.dock
if (dockSide === 'off') {
@@ -59,16 +59,17 @@ export class DockingService {
})
}
getCurrentScreen () {
getCurrentScreen (): Electron.Display {
return this.electron.screen.getDisplayNearestPoint(this.electron.screen.getCursorScreenPoint())
}
getScreens () {
getScreens (): Electron.Display[] {
const primaryDisplayID = this.electron.screen.getPrimaryDisplay().id
return this.electron.screen.getAllDisplays().sort((a, b) =>
a.bounds.x === b.bounds.x ? a.bounds.y - b.bounds.y : a.bounds.x - b.bounds.x
).map((display,index) => {
).map((display, index) => {
return {
...display,
id: display.id,
name: display.id === primaryDisplayID ? 'Primary Display' : `Display ${index +1}`,
}

View File

@@ -46,7 +46,7 @@ export class ElectronService {
/**
* Removes OS focus from Terminus' window
*/
loseFocus () {
loseFocus (): void {
if (process.platform === 'darwin') {
this.remote.Menu.sendActionToFirstResponder('hide:')
}

View File

@@ -22,11 +22,11 @@ export class HomeBaseService {
}
}
openGitHub () {
openGitHub (): void {
this.electron.shell.openExternal('https://github.com/eugeny/terminus')
}
reportBug () {
reportBug (): void {
let body = `Version: ${this.appVersion}\n`
body += `Platform: ${os.platform()} ${os.release()}\n`
const label = {
@@ -44,7 +44,7 @@ export class HomeBaseService {
this.electron.shell.openExternal(`https://github.com/eugeny/terminus/issues/new?body=${encodeURIComponent(body)}&labels=${label}`)
}
enableAnalytics () {
enableAnalytics (): void {
if (!window.localStorage.analyticsUserID) {
window.localStorage.analyticsUserID = uuidv4()
}
@@ -56,7 +56,7 @@ export class HomeBaseService {
this.mixpanel.track('launch', this.getAnalyticsProperties())
}
getAnalyticsProperties () {
getAnalyticsProperties (): Record<string, string> {
return {
distinct_id: window.localStorage.analyticsUserID, // eslint-disable-line @typescript-eslint/camelcase
platform: process.platform,

View File

@@ -178,48 +178,48 @@ export class HostAppService {
/**
* Returns the current remote [[BrowserWindow]]
*/
getWindow () {
getWindow (): Electron.BrowserWindow {
return this.electron.BrowserWindow.fromId(this.windowId)
}
newWindow () {
newWindow (): void {
this.electron.ipcRenderer.send('app:new-window')
}
toggleFullscreen () {
toggleFullscreen (): void {
const window = this.getWindow()
window.setFullScreen(!this.isFullScreen)
}
openDevTools () {
openDevTools (): void {
this.getWindow().webContents.openDevTools({ mode: 'undocked' })
}
focusWindow () {
focusWindow (): void {
this.electron.ipcRenderer.send('window-focus')
}
minimize () {
minimize (): void {
this.electron.ipcRenderer.send('window-minimize')
}
maximize () {
maximize (): void {
this.electron.ipcRenderer.send('window-maximize')
}
unmaximize () {
unmaximize (): void {
this.electron.ipcRenderer.send('window-unmaximize')
}
toggleMaximize () {
toggleMaximize (): void {
this.electron.ipcRenderer.send('window-toggle-maximize')
}
setBounds (bounds: Bounds) {
setBounds (bounds: Bounds): void {
this.electron.ipcRenderer.send('window-set-bounds', bounds)
}
setAlwaysOnTop (flag: boolean) {
setAlwaysOnTop (flag: boolean): void {
this.electron.ipcRenderer.send('window-set-always-on-top', flag)
}
@@ -228,7 +228,7 @@ export class HostAppService {
*
* @param type `null`, or `fluent` when supported (Windowd only)
*/
setVibrancy (enable: boolean, type: string|null) {
setVibrancy (enable: boolean, type: string|null): void {
if (!isWindowsBuild(WIN_BUILD_FLUENT_BG_SUPPORTED)) {
type = null
}
@@ -236,38 +236,38 @@ export class HostAppService {
this.electron.ipcRenderer.send('window-set-vibrancy', enable, type)
}
setTitle (title: string) {
setTitle (title: string): void {
this.electron.ipcRenderer.send('window-set-title', title)
}
setTouchBar (touchBar: Electron.TouchBar) {
setTouchBar (touchBar: Electron.TouchBar): void {
this.getWindow().setTouchBar(touchBar)
}
popupContextMenu (menuDefinition: Electron.MenuItemConstructorOptions[]) {
popupContextMenu (menuDefinition: Electron.MenuItemConstructorOptions[]): void {
this.electron.Menu.buildFromTemplate(menuDefinition).popup({})
}
/**
* Notifies other windows of config file changes
*/
broadcastConfigChange () {
broadcastConfigChange (): void {
this.electron.ipcRenderer.send('app:config-change')
}
emitReady () {
emitReady (): void {
this.electron.ipcRenderer.send('app:ready')
}
bringToFront () {
bringToFront (): void {
this.electron.ipcRenderer.send('window-bring-to-front')
}
closeWindow () {
closeWindow (): void {
this.electron.ipcRenderer.send('window-close')
}
relaunch () {
relaunch (): void {
if (this.isPortable) {
this.electron.app.relaunch({ execPath: process.env.PORTABLE_EXECUTABLE_FILE })
} else {
@@ -276,7 +276,7 @@ export class HostAppService {
this.electron.app.exit()
}
quit () {
quit (): void {
this.logger.info('Quitting')
this.electron.app.quit()
}

View File

@@ -70,7 +70,7 @@ export class HotkeysService {
* @param name DOM event name
* @param nativeEvent event object
*/
pushKeystroke (name: string, nativeEvent: KeyboardEvent) {
pushKeystroke (name: string, nativeEvent: KeyboardEvent): void {
(nativeEvent as any).event = name
this.currentKeystrokes.push({ event: nativeEvent, time: performance.now() })
}
@@ -78,7 +78,7 @@ export class HotkeysService {
/**
* Check the buffer for new complete keystrokes
*/
processKeystrokes () {
processKeystrokes (): void {
if (this.isEnabled()) {
this.zone.run(() => {
const matched = this.getCurrentFullyMatchedHotkey()
@@ -91,13 +91,13 @@ export class HotkeysService {
}
}
emitKeyEvent (nativeEvent: KeyboardEvent) {
emitKeyEvent (nativeEvent: KeyboardEvent): void {
this.zone.run(() => {
this.key.emit(nativeEvent)
})
}
clearCurrentKeystrokes () {
clearCurrentKeystrokes (): void {
this.currentKeystrokes = []
}
@@ -155,15 +155,15 @@ export class HotkeysService {
return this.hotkeyDescriptions.filter((x) => x.id === id)[0]
}
enable () {
enable (): void {
this.disabledLevel--
}
disable () {
disable (): void {
this.disabledLevel++
}
isEnabled () {
isEnabled (): boolean {
return this.disabledLevel === 0
}

View File

@@ -32,27 +32,27 @@ export class Logger {
private name: string,
) {}
debug (...args: any[]) {
debug (...args: any[]): void {
this.doLog('debug', ...args)
}
info (...args: any[]) {
info (...args: any[]): void {
this.doLog('info', ...args)
}
warn (...args: any[]) {
warn (...args: any[]): void {
this.doLog('warn', ...args)
}
error (...args: any[]) {
error (...args: any[]): void {
this.doLog('error', ...args)
}
log (...args: any[]) {
log (...args: any[]): void {
this.doLog('log', ...args)
}
private doLog (level: string, ...args: any[]) {
private doLog (level: string, ...args: any[]): void {
console[level](`%c[${this.name}]`, 'color: #aaa', ...args)
if (this.winstonLogger) {
this.winstonLogger[level](...args)

View File

@@ -58,7 +58,7 @@ export class ShellIntegrationService {
return true
}
async install () {
async install (): Promise<void> {
const exe: string = process.env.PORTABLE_EXECUTABLE_FILE || this.electron.app.getPath('exe')
if (this.hostApp.platform === Platform.macOS) {
for (const wf of this.automatorWorkflows) {
@@ -82,7 +82,7 @@ export class ShellIntegrationService {
}
}
async remove () {
async remove (): Promise<void> {
if (this.hostApp.platform === Platform.macOS) {
for (const wf of this.automatorWorkflows) {
await exec(`rm -rf "${this.automatorWorkflowsDestination}/${wf}"`)

View File

@@ -1,5 +1,5 @@
import { Injectable, Inject } from '@angular/core'
import { TabRecoveryProvider, RecoveredTab } from '../api/tabRecovery'
import { TabRecoveryProvider, RecoveredTab, RecoveryToken } from '../api/tabRecovery'
import { BaseTabComponent } from '../components/baseTab.component'
import { Logger, LogService } from '../services/log.service'
import { ConfigService } from '../services/config.service'
@@ -17,7 +17,7 @@ export class TabRecoveryService {
this.logger = log.create('tabRecovery')
}
async saveTabs (tabs: BaseTabComponent[]) {
async saveTabs (tabs: BaseTabComponent[]): Promise<void> {
window.localStorage.tabsRecovery = JSON.stringify(
await Promise.all(
tabs
@@ -25,7 +25,7 @@ export class TabRecoveryService {
let token = tab.getRecoveryToken()
if (token) {
token = token.then(r => {
if (r) {
if (r && tab.color) {
r.tabColor = tab.color
}
return r
@@ -38,7 +38,7 @@ export class TabRecoveryService {
)
}
async recoverTab (token: any): Promise<RecoveredTab|null> {
async recoverTab (token: RecoveryToken): Promise<RecoveredTab|null> {
for (const provider of this.config.enabledServices(this.tabRecoveryProviders)) {
try {
const tab = await provider.recover(token)

View File

@@ -17,7 +17,7 @@ export class TabsService {
/**
* Instantiates a tab component and assigns given inputs
*/
create (type: TabComponentType, inputs?: any): BaseTabComponent {
create (type: TabComponentType, inputs?: Record<string, any>): BaseTabComponent {
const componentFactory = this.componentFactoryResolver.resolveComponentFactory(type)
const componentRef = componentFactory.create(this.injector)
const tab = componentRef.instance

View File

@@ -48,7 +48,7 @@ export class TouchbarService {
})
}
updateTabs () {
updateTabs (): void {
this.tabSegments = this.app.tabs.map(tab => ({
label: this.shortenTitle(tab.title),
}))
@@ -56,7 +56,7 @@ export class TouchbarService {
this.tabsSegmentedControl.selectedIndex = this.app.tabs.indexOf(this.app.activeTab)
}
update () {
update (): void {
if (this.hostApp.platform !== Platform.macOS) {
return
}

View File

@@ -80,7 +80,7 @@ export class UpdaterService {
return this.downloaded
}
async update () {
async update (): Promise<void> {
if (!this.electronUpdaterAvailable) {
this.electron.shell.openExternal(this.updateURL)
} else {

View File

@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { Injectable, NgZone } from '@angular/core'
import { Subscription } from 'rxjs'
import { AppService } from './services/app.service'

View File

@@ -10,6 +10,7 @@ export function isWindowsBuild (build: number): boolean {
return process.platform === 'win32' && parseFloat(os.release()) >= 10 && parseInt(os.release().split('.')[2]) >= build
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export function getCSSFontFamily (config: any): string {
let fonts: string[] = config.terminal.font.split(',').map(x => x.trim().replace(/"/g, ''))
if (config.terminal.fallbackFont) {