diff --git a/app/lib/app.ts b/app/lib/app.ts index c8b0652f70844e6bf4dd0cb8e4d5c0fcf38bbcf3..5dfa8bcb42ce1b0da05d3c97efd8a4e913434d54 100644 --- a/app/lib/app.ts +++ b/app/lib/app.ts @@ -31,7 +31,7 @@ export class Application { } } - init () { + init (): void { electron.screen.on('display-metrics-changed', () => this.broadcast('host:display-metrics-changed')) } @@ -52,20 +52,20 @@ export class Application { return window } - broadcast (event, ...args) { - for (let window of this.windows) { + broadcast (event: string, ...args): void { + for (const window of this.windows) { window.send(event, ...args) } } - async send (event, ...args) { + async send (event: string, ...args): void { if (!this.hasWindows()) { await this.newWindow() } this.windows.filter(w => !w.isDestroyed())[0].send(event, ...args) } - enableTray () { + enableTray (): void { if (this.tray) { return } @@ -90,18 +90,18 @@ export class Application { this.tray.setToolTip(`Terminus ${app.getVersion()}`) } - disableTray () { + disableTray (): void { if (this.tray) { this.tray.destroy() this.tray = null } } - hasWindows () { + hasWindows (): bool { return !!this.windows.length } - focus () { + focus (): void { for (let window of this.windows) { window.show() } diff --git a/app/lib/cli.ts b/app/lib/cli.ts index 856d3ccfcc91dcfb04cbfb082c24a9319914067c..66290f70ffc2fb7fb49a90d7ba35b4112d38970f 100644 --- a/app/lib/cli.ts +++ b/app/lib/cli.ts @@ -1,6 +1,6 @@ import { app } from 'electron' -export function parseArgs (argv, cwd) { +export function parseArgs (argv: string[], cwd: string): any { if (argv[0].includes('node')) { argv = argv.slice(1) } diff --git a/app/lib/window.ts b/app/lib/window.ts index cce91fa2eadc5b2de983cbd4c390609800c19007..1aee9bbc74d4d187aa9f3494f47af04e38afaf47 100644 --- a/app/lib/window.ts +++ b/app/lib/window.ts @@ -119,7 +119,7 @@ export class Window { }) } - setVibrancy (enabled: boolean, type?: string) { + setVibrancy (enabled: boolean, type?: string): void { this.lastVibrancy = { enabled, type } if (process.platform === 'win32') { if (parseFloat(os.release()) >= 10) { @@ -140,22 +140,22 @@ export class Window { } } - show () { + show (): void { this.window.show() } - focus () { + focus (): void { this.window.focus() } - send (event, ...args) { + send (event: string, ...args): void { if (!this.window) { return } this.window.webContents.send(event, ...args) } - isDestroyed () { + isDestroyed (): void { return !this.window || this.window.isDestroyed() } diff --git a/app/src/app.module.ts b/app/src/app.module.ts index cf90fd85c03baf261e1682a532707533af2c768e..d02296de2e935059542dade00672f6fc15cb091a 100644 --- a/app/src/app.module.ts +++ b/app/src/app.module.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import { NgModule } from '@angular/core' import { BrowserModule } from '@angular/platform-browser' import { NgbModule } from '@ng-bootstrap/ng-bootstrap' diff --git a/terminus-core/src/api/index.ts b/terminus-core/src/api/index.ts index 1c861070d34c98b01c6a727351931e38468cc66d..7a5286f5141c4ebfec6f753eaec457f5eab00bdd 100644 --- a/terminus-core/src/api/index.ts +++ b/terminus-core/src/api/index.ts @@ -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' diff --git a/terminus-core/src/api/tabRecovery.ts b/terminus-core/src/api/tabRecovery.ts index b1d1268fca050583c8c42dd2725a5019e428d565..a64b4563dcb0abf8b135dabfb5d438044e30681c 100644 --- a/terminus-core/src/api/tabRecovery.ts +++ b/terminus-core/src/api/tabRecovery.ts @@ -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 + abstract async recover (recoveryToken: RecoveryToken): Promise } diff --git a/terminus-core/src/components/appRoot.component.ts b/terminus-core/src/components/appRoot.component.ts index 80a8f91cb40e3182b16d5043ada29c9103287991..dedf3181eddc451adc278ccc7951736183732247 100644 --- a/terminus-core/src/components/appRoot.component.ts +++ b/terminus-core/src/components/appRoot.component.ts @@ -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' diff --git a/terminus-core/src/components/baseTab.component.ts b/terminus-core/src/components/baseTab.component.ts index eac2709642032c73a0fd1f6a4c9b976f295d481c..436f5e6719e325af2e3e6b446642b82a25e095ea 100644 --- a/terminus-core/src/components/baseTab.component.ts +++ b/terminus-core/src/components/baseTab.component.ts @@ -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 { + async getRecoveryToken (): Promise { return null } @@ -136,11 +137,11 @@ export abstract class BaseTabComponent { return true } - emitFocused () { + emitFocused (): void { this.focused.next() } - emitBlurred () { + emitBlurred (): void { this.blurred.next() } diff --git a/terminus-core/src/components/checkbox.component.ts b/terminus-core/src/components/checkbox.component.ts index 60731cc771d5a9e63a3be82e8a296afdd8ae3757..cb8b30c6a6cb72e2aa69938ff5e4aa7d4b0c450d 100644 --- a/terminus-core/src/components/checkbox.component.ts +++ b/terminus-core/src/components/checkbox.component.ts @@ -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' diff --git a/terminus-core/src/components/renameTabModal.component.ts b/terminus-core/src/components/renameTabModal.component.ts index e8e105b32c43c1b6e9a4eb4ceb7a384ec3c06e24..25b54d5c0a530d71467e50f1f921fd4de0d07358 100644 --- a/terminus-core/src/components/renameTabModal.component.ts +++ b/terminus-core/src/components/renameTabModal.component.ts @@ -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' diff --git a/terminus-core/src/components/safeModeModal.component.ts b/terminus-core/src/components/safeModeModal.component.ts index a2dd39c0d38514e13f15fa61c18596fde685a8a5..9c3e344b73145e5f4238bcc74e607ca49ca111c7 100644 --- a/terminus-core/src/components/safeModeModal.component.ts +++ b/terminus-core/src/components/safeModeModal.component.ts @@ -14,7 +14,7 @@ export class SafeModeModalComponent { this.error = window['safeModeReason'] } - close () { + close (): void { this.modalInstance.dismiss() } } diff --git a/terminus-core/src/components/selectorModal.component.ts b/terminus-core/src/components/selectorModal.component.ts index af39fccc2f079415fc0f8dbd12c2ea88bb86cc5c..1c19f2f729418a8f90193d4d5537f06f347222ad 100644 --- a/terminus-core/src/components/selectorModal.component.ts +++ b/terminus-core/src/components/selectorModal.component.ts @@ -17,11 +17,11 @@ export class SelectorModalComponent { 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 { } } - onFilterEnter () { + onFilterEnter (): void { if (this.filteredOptions.length === 1) { this.selectOption(this.filteredOptions[0]) } } - selectOption (option: SelectorOption) { + selectOption (option: SelectorOption): void { this.modalInstance.close(option.result) } - close () { + close (): void { this.modalInstance.dismiss() } } diff --git a/terminus-core/src/components/splitTab.component.ts b/terminus-core/src/components/splitTab.component.ts index fbbbc096414e698dcf9be04366739c6500d5e35d..0624ae3a1134bc6232f45f7fb9dc92f113163037 100644 --- a/terminus-core/src/components/splitTab.component.ts +++ b/terminus-core/src/components/splitTab.component.ts @@ -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 { 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 { 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 { 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 { 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 { + async recover (recoveryToken: RecoveryToken): Promise { if (recoveryToken && recoveryToken.type === 'app:split-tab') { return { type: SplitTabComponent, diff --git a/terminus-core/src/components/splitTabSpanner.component.ts b/terminus-core/src/components/splitTabSpanner.component.ts index e06ce5d403c76416da692cfc917d4d39d30bdcc0..500e3a464698796a2394c19db633f2f696f71567 100644 --- a/terminus-core/src/components/splitTabSpanner.component.ts +++ b/terminus-core/src/components/splitTabSpanner.component.ts @@ -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' diff --git a/terminus-core/src/components/tabBody.component.ts b/terminus-core/src/components/tabBody.component.ts index 0735ec4d712a99bf897a46cd546c8d88da276e6f..aa50521e62724226ed00a6442a4131b44fae7fbb 100644 --- a/terminus-core/src/components/tabBody.component.ts +++ b/terminus-core/src/components/tabBody.component.ts @@ -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' diff --git a/terminus-core/src/components/tabHeader.component.ts b/terminus-core/src/components/tabHeader.component.ts index 4db33bfc01a2db76fd59a71302ce8259c351926f..b617149dea9b099e9842b7920d28c3efe0abca59 100644 --- a/terminus-core/src/components/tabHeader.component.ts +++ b/terminus-core/src/components/tabHeader.component.ts @@ -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' diff --git a/terminus-core/src/components/welcomeTab.component.ts b/terminus-core/src/components/welcomeTab.component.ts index c5186952a8ee5897fbc2c9d5ab9d32d77a84c69a..b6a65753390baf15771c9670b1a37491bf2bb394 100644 --- a/terminus-core/src/components/welcomeTab.component.ts +++ b/terminus-core/src/components/welcomeTab.component.ts @@ -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' diff --git a/terminus-core/src/components/windowControls.component.ts b/terminus-core/src/components/windowControls.component.ts index 48875ffdd0ab3ea1fe663022fce9e29c51cf9fd3..4cfbc1c0a1ae94d5cea1d005f4c3ca98db733a3f 100644 --- a/terminus-core/src/components/windowControls.component.ts +++ b/terminus-core/src/components/windowControls.component.ts @@ -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' diff --git a/terminus-core/src/directives/autofocus.directive.ts b/terminus-core/src/directives/autofocus.directive.ts index 26849b8ca1d69d4d46757e7f0076f608a2791371..6201e21730e508c0751b845f4ab816ca9dabc9c8 100644 --- a/terminus-core/src/directives/autofocus.directive.ts +++ b/terminus-core/src/directives/autofocus.directive.ts @@ -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() diff --git a/terminus-core/src/directives/fastHtmlBind.directive.ts b/terminus-core/src/directives/fastHtmlBind.directive.ts index 16bf8c3b7dcfcd32577dbb0dde18842f56fb6552..83dd864e07d1ec0a7823bf185b729575ea985dcf 100644 --- a/terminus-core/src/directives/fastHtmlBind.directive.ts +++ b/terminus-core/src/directives/fastHtmlBind.directive.ts @@ -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 || '' } } diff --git a/terminus-core/src/services/app.service.ts b/terminus-core/src/services/app.service.ts index 433fb911334b03fec488e07e3f9981cd26044e18..07164f79e82a3726edacd072e045b3f931ef4242 100644 --- a/terminus-core/src/services/app.service.ts +++ b/terminus-core/src/services/app.service.ts @@ -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): 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): 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 { 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) } diff --git a/terminus-core/src/services/config.service.ts b/terminus-core/src/services/config.service.ts index 7a9c7a704ea10a62ca3ed0a8b7f453e032f09815..f1f66cc7a21b066fb0bd43f01082ed25c68a0d38 100644 --- a/terminus-core/src/services/config.service.ts +++ b/terminus-core/src/services/config.service.ts @@ -20,7 +20,7 @@ function isNonStructuralObjectMember (v): boolean { /** @hidden */ export class ConfigProxy { - constructor (real: any, defaults: any) { + constructor (real: Record, defaults: Record) { 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 { const cleanup = o => { if (o instanceof Array) { return o.map(cleanup) diff --git a/terminus-core/src/services/docking.service.ts b/terminus-core/src/services/docking.service.ts index 9d4a619f9ac6fe8715896438cb9810be9befe71d..d52593a1e57038687b93d75103840fe8531133de 100644 --- a/terminus-core/src/services/docking.service.ts +++ b/terminus-core/src/services/docking.service.ts @@ -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}`, } diff --git a/terminus-core/src/services/electron.service.ts b/terminus-core/src/services/electron.service.ts index 09a177c4c28f5d507d01952fd76610f99849d22d..de46211fc4690aa9a9f67b344edc6cdbb8e1479e 100644 --- a/terminus-core/src/services/electron.service.ts +++ b/terminus-core/src/services/electron.service.ts @@ -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:') } diff --git a/terminus-core/src/services/homeBase.service.ts b/terminus-core/src/services/homeBase.service.ts index f04beed1752287c8a815c21acbf32a81c9bbb9b9..6e6bd8b5c659bb3b1b48b046391394e6d59458f0 100644 --- a/terminus-core/src/services/homeBase.service.ts +++ b/terminus-core/src/services/homeBase.service.ts @@ -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 { return { distinct_id: window.localStorage.analyticsUserID, // eslint-disable-line @typescript-eslint/camelcase platform: process.platform, diff --git a/terminus-core/src/services/hostApp.service.ts b/terminus-core/src/services/hostApp.service.ts index 22eb3c6060b1ad33cf60dd45cd09a327535a8d33..cce76e9a97b370be9cb0d5e30ed490bddc6ecfb7 100644 --- a/terminus-core/src/services/hostApp.service.ts +++ b/terminus-core/src/services/hostApp.service.ts @@ -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() } diff --git a/terminus-core/src/services/hotkeys.service.ts b/terminus-core/src/services/hotkeys.service.ts index 75ecc8961af62b38e4e71908a3487305fec5f58b..3dd9bb9927211c32ecbb1d075106c888c7253df6 100644 --- a/terminus-core/src/services/hotkeys.service.ts +++ b/terminus-core/src/services/hotkeys.service.ts @@ -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 } diff --git a/terminus-core/src/services/log.service.ts b/terminus-core/src/services/log.service.ts index 5879935d79e96cae1be4be9ac6cdbcc3c7713c77..aacc10de06490454e529cb96b74249a9c1705fef 100644 --- a/terminus-core/src/services/log.service.ts +++ b/terminus-core/src/services/log.service.ts @@ -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) diff --git a/terminus-core/src/services/shellIntegration.service.ts b/terminus-core/src/services/shellIntegration.service.ts index f2fd1ff638a78e58cb17f0c0f5aa947cf54f45b5..a9b78da042ce70b0f0211d09bca18109e2dd371d 100644 --- a/terminus-core/src/services/shellIntegration.service.ts +++ b/terminus-core/src/services/shellIntegration.service.ts @@ -58,7 +58,7 @@ export class ShellIntegrationService { return true } - async install () { + async install (): Promise { 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 { if (this.hostApp.platform === Platform.macOS) { for (const wf of this.automatorWorkflows) { await exec(`rm -rf "${this.automatorWorkflowsDestination}/${wf}"`) diff --git a/terminus-core/src/services/tabRecovery.service.ts b/terminus-core/src/services/tabRecovery.service.ts index bf9161a476129a062b6a14a4943a79bf7adb89b1..9cf30f2e697ffa11d265b8c4a4de535d56f3ff58 100644 --- a/terminus-core/src/services/tabRecovery.service.ts +++ b/terminus-core/src/services/tabRecovery.service.ts @@ -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 { 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 { + async recoverTab (token: RecoveryToken): Promise { for (const provider of this.config.enabledServices(this.tabRecoveryProviders)) { try { const tab = await provider.recover(token) diff --git a/terminus-core/src/services/tabs.service.ts b/terminus-core/src/services/tabs.service.ts index 992dafe8298e7877d22b596ff7b8a63862c3e0e7..28c8ff5f4f17612de6ecb7bc65acaa3840735747 100644 --- a/terminus-core/src/services/tabs.service.ts +++ b/terminus-core/src/services/tabs.service.ts @@ -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): BaseTabComponent { const componentFactory = this.componentFactoryResolver.resolveComponentFactory(type) const componentRef = componentFactory.create(this.injector) const tab = componentRef.instance diff --git a/terminus-core/src/services/touchbar.service.ts b/terminus-core/src/services/touchbar.service.ts index f96c8e71d4724cc17a8282d5d58b9cb570a4ca10..c84319667c60cc57ef1dc55406f024c2e1002210 100644 --- a/terminus-core/src/services/touchbar.service.ts +++ b/terminus-core/src/services/touchbar.service.ts @@ -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 } diff --git a/terminus-core/src/services/updater.service.ts b/terminus-core/src/services/updater.service.ts index 3b665e905256a88b760330be59ca318119a49f94..05febfc8de30c6eeada310eb1726fb4e94a28dfc 100644 --- a/terminus-core/src/services/updater.service.ts +++ b/terminus-core/src/services/updater.service.ts @@ -80,7 +80,7 @@ export class UpdaterService { return this.downloaded } - async update () { + async update (): Promise { if (!this.electronUpdaterAvailable) { this.electron.shell.openExternal(this.updateURL) } else { diff --git a/terminus-core/src/tabContextMenu.ts b/terminus-core/src/tabContextMenu.ts index 5c555d663b4e3e7d6465213d45cf79fc06b3cc44..f03b1b68693c1905eae63f140b0e908e5134fef6 100644 --- a/terminus-core/src/tabContextMenu.ts +++ b/terminus-core/src/tabContextMenu.ts @@ -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' diff --git a/terminus-core/src/utils.ts b/terminus-core/src/utils.ts index 4bb38451a1e27e29c9b5cc00a41311fb73c19c86..4dfa171f7190e2ded745f450af17a18d97a39989 100644 --- a/terminus-core/src/utils.ts +++ b/terminus-core/src/utils.ts @@ -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) { diff --git a/terminus-plugin-manager/src/components/pluginsSettingsTab.component.ts b/terminus-plugin-manager/src/components/pluginsSettingsTab.component.ts index d3680ba74348b1166c8cbaac301b6714d98c5819..72c0271f926cd283c0983e0ce091562bc2669383 100644 --- a/terminus-plugin-manager/src/components/pluginsSettingsTab.component.ts +++ b/terminus-plugin-manager/src/components/pluginsSettingsTab.component.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import { BehaviorSubject, Observable } from 'rxjs' import { debounceTime, distinctUntilChanged, first, tap, flatMap, map } from 'rxjs/operators' import semverGt from 'semver/functions/gt' diff --git a/terminus-plugin-manager/src/services/pluginManager.service.ts b/terminus-plugin-manager/src/services/pluginManager.service.ts index d501200af3188c2af1819b3be658e307a78d06e2..18cb683de12a8afc7a7aa68ca0a9d1b97955b1ea 100644 --- a/terminus-plugin-manager/src/services/pluginManager.service.ts +++ b/terminus-plugin-manager/src/services/pluginManager.service.ts @@ -40,7 +40,7 @@ export class PluginManagerService { this.logger = log.create('pluginManager') } - async getNPM () { + async getNPM (): Promise { if (!this.npm) { if (!this.npmReady) { this.npmReady = new Promise(resolve => { @@ -83,7 +83,7 @@ export class PluginManagerService { ) } - async installPlugin (plugin: PluginInfo) { + async installPlugin (plugin: PluginInfo): Promise { (await this.getNPM()).commands.install([`${plugin.packageName}@${plugin.version}`], err => { if (err) { this.logger.error(err) @@ -93,7 +93,7 @@ export class PluginManagerService { }) } - async uninstallPlugin (plugin: PluginInfo) { + async uninstallPlugin (plugin: PluginInfo): Promise { (await this.getNPM()).commands.remove([plugin.packageName], err => { if (err) { this.logger.error(err) diff --git a/terminus-serial/src/api.ts b/terminus-serial/src/api.ts index 6930c44d54b77b65e38c987751a71cb31cbacf2f..eb46195115d2d5b781720396d6fa79a55fb42c27 100644 --- a/terminus-serial/src/api.ts +++ b/terminus-serial/src/api.ts @@ -47,7 +47,7 @@ export class SerialSession extends BaseSession { this.scripts = connection.scripts || [] } - async start () { + async start (): Promise { this.open = true this.serial.on('data', data => { @@ -105,12 +105,7 @@ export class SerialSession extends BaseSession { this.executeUnconditionalScripts() } - emitServiceMessage (msg: string) { - this.serviceMessage.next(msg) - this.logger.info(msg) - } - - write (data) { + write (data: string): void { if (this.serial) { this.serial.write(data) } @@ -121,11 +116,10 @@ export class SerialSession extends BaseSession { await super.destroy() } - resize (_, _1) { - console.log('resize') - } + // eslint-disable-next-line @typescript-eslint/no-empty-function, @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-empty-function + resize (_, __) { } - kill (_?: string) { + kill (_?: string): void { this.serial.close() } diff --git a/terminus-serial/src/buttonProvider.ts b/terminus-serial/src/buttonProvider.ts index 4dc4235aab81fbb007b50c84deaaeff00f0a0986..303a85035a09d271cd3fb8e99b9f91c9e776fbec 100644 --- a/terminus-serial/src/buttonProvider.ts +++ b/terminus-serial/src/buttonProvider.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import { Injectable } from '@angular/core' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { HotkeysService, ToolbarButtonProvider, ToolbarButton } from 'terminus-core' diff --git a/terminus-serial/src/components/editConnectionModal.component.ts b/terminus-serial/src/components/editConnectionModal.component.ts index 236660be78a512f8a3eaa4c2b7633f1b6fbfb78f..9c8270b950bfe0f1b81427c176290edec457ed7d 100644 --- a/terminus-serial/src/components/editConnectionModal.component.ts +++ b/terminus-serial/src/components/editConnectionModal.component.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import { Component } from '@angular/core' import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap' import { map } from 'rxjs/operators' diff --git a/terminus-serial/src/components/promptModal.component.pug b/terminus-serial/src/components/promptModal.component.pug deleted file mode 100644 index ddcfaf3f7870b91197127ff611dc331a464b871e..0000000000000000000000000000000000000000 --- a/terminus-serial/src/components/promptModal.component.pug +++ /dev/null @@ -1,14 +0,0 @@ -.modal-body - input.form-control( - [type]='"text"', - autofocus, - [(ngModel)]='value', - #input, - [placeholder]='prompt', - (keyup.enter)='ok()', - (keyup.esc)='cancel()', - ) - .d-flex.align-items-start.mt-2 - button.btn.btn-primary.ml-auto( - (click)='ok()', - ) Enter diff --git a/terminus-serial/src/components/promptModal.component.ts b/terminus-serial/src/components/promptModal.component.ts deleted file mode 100644 index ee6484324f016799d720b82214d686e6872be2be..0000000000000000000000000000000000000000 --- a/terminus-serial/src/components/promptModal.component.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { Component, Input, ViewChild, ElementRef } from '@angular/core' -import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap' - -/** @hidden */ -@Component({ - template: require('./promptModal.component.pug'), -}) -export class PromptModalComponent { - @Input() value: string - @ViewChild('input') input: ElementRef - - constructor ( - private modalInstance: NgbActiveModal, - ) { } - - ngOnInit () { - setTimeout(() => { - this.input.nativeElement.focus() - }) - } - - ok () { - this.modalInstance.close({ - value: this.value, - }) - } - - cancel () { - this.modalInstance.close(null) - } -} diff --git a/terminus-serial/src/components/serialModal.component.ts b/terminus-serial/src/components/serialModal.component.ts index 97dfb297681e7e5f1144c4aef867944d065ff3c9..ad46c4b21fc71fa60c004ed02809adf13f7bbe35 100644 --- a/terminus-serial/src/components/serialModal.component.ts +++ b/terminus-serial/src/components/serialModal.component.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import { Component, NgZone } from '@angular/core' import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap' import { ToastrService } from 'ngx-toastr' diff --git a/terminus-serial/src/components/serialSettingsTab.component.ts b/terminus-serial/src/components/serialSettingsTab.component.ts index 93fcacbd8c0b1ef37e412c0f39d48e360f3866e6..41dc137bdb6667c12b2bdecb0dcd2fff3504d626 100644 --- a/terminus-serial/src/components/serialSettingsTab.component.ts +++ b/terminus-serial/src/components/serialSettingsTab.component.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import { Component } from '@angular/core' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { ConfigService, ElectronService, HostAppService } from 'terminus-core' diff --git a/terminus-serial/src/components/serialTab.component.ts b/terminus-serial/src/components/serialTab.component.ts index cea6e1bc2aa3d1366f8da628426c16c067641651..105ec98bbb9f159f8eb290fa8972866b95a22f1e 100644 --- a/terminus-serial/src/components/serialTab.component.ts +++ b/terminus-serial/src/components/serialTab.component.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import colors from 'ansi-colors' import { Spinner } from 'cli-spinner' import { Component, Injector } from '@angular/core' diff --git a/terminus-serial/src/recoveryProvider.ts b/terminus-serial/src/recoveryProvider.ts index b0fdb87a9c55d95d93469fe5610307d025f29c83..42ed3c7771b7d920939a01f122276f96b63b89b3 100644 --- a/terminus-serial/src/recoveryProvider.ts +++ b/terminus-serial/src/recoveryProvider.ts @@ -1,18 +1,18 @@ import { Injectable } from '@angular/core' -import { TabRecoveryProvider, RecoveredTab } from 'terminus-core' +import { TabRecoveryProvider, RecoveredTab, RecoveryToken } from 'terminus-core' import { SerialTabComponent } from './components/serialTab.component' /** @hidden */ @Injectable() export class RecoveryProvider extends TabRecoveryProvider { - async recover (recoveryToken: any): Promise { + async recover (recoveryToken: RecoveryToken): Promise { if (recoveryToken?.type === 'app:serial-tab') { return { type: SerialTabComponent, options: { - connection: recoveryToken.connection, - savedState: recoveryToken.savedState, + connection: recoveryToken['connection'], + savedState: recoveryToken['savedState'], }, } } diff --git a/terminus-settings/src/buttonProvider.ts b/terminus-settings/src/buttonProvider.ts index b034214c93dc1aa28747bada6161863462a1ffbe..c3e00a1f79c2290360790a675e3e121065600386 100644 --- a/terminus-settings/src/buttonProvider.ts +++ b/terminus-settings/src/buttonProvider.ts @@ -27,7 +27,7 @@ export class ButtonProvider extends ToolbarButtonProvider { title: 'Settings', touchBarNSImage: 'NSTouchBarComposeTemplate', weight: 10, - click: () => this.open(), + click: (): void => this.open(), }] } diff --git a/terminus-settings/src/components/hotkeyInputModal.component.ts b/terminus-settings/src/components/hotkeyInputModal.component.ts index abd1017466a43e43013fbac6b56ac426d01f44d8..cb1455799e4250db17fe6776dbce6906d9937c85 100644 --- a/terminus-settings/src/components/hotkeyInputModal.component.ts +++ b/terminus-settings/src/components/hotkeyInputModal.component.ts @@ -61,7 +61,7 @@ export class HotkeyInputModalComponent { return keys.split('+').map((x) => x.trim()) } - ngOnInit () { + ngOnInit (): void { this.keyTimeoutInterval = window.setInterval(() => { if (!this.lastKeyEvent) { return @@ -74,14 +74,14 @@ export class HotkeyInputModalComponent { this.hotkeys.disable() } - ngOnDestroy () { + ngOnDestroy (): void { this.keySubscription.unsubscribe() this.hotkeys.clearCurrentKeystrokes() this.hotkeys.enable() clearInterval(this.keyTimeoutInterval!) } - close () { + close (): void { this.modalInstance.dismiss() } } diff --git a/terminus-settings/src/components/multiHotkeyInput.component.ts b/terminus-settings/src/components/multiHotkeyInput.component.ts index 78f444efe1ba2620ded3445ecf81f87e45f52486..6be3f56d9ad244327d14bf6a8af6f15a88de4871 100644 --- a/terminus-settings/src/components/multiHotkeyInput.component.ts +++ b/terminus-settings/src/components/multiHotkeyInput.component.ts @@ -17,7 +17,7 @@ export class MultiHotkeyInputComponent { private ngbModal: NgbModal, ) { } - ngOnInit () { + ngOnInit (): void { if (!this.model) { this.model = [] } @@ -27,7 +27,7 @@ export class MultiHotkeyInputComponent { this.model = this.model.map(item => typeof item === 'string' ? [item] : item) } - editItem (item) { + editItem (item: string[]): void { this.ngbModal.open(HotkeyInputModalComponent).result.then((value: string[]) => { this.model[this.model.findIndex(x => x === item)] = value this.model = this.model.slice() @@ -35,14 +35,14 @@ export class MultiHotkeyInputComponent { }) } - addItem () { + addItem (): void { this.ngbModal.open(HotkeyInputModalComponent).result.then((value: string[]) => { this.model = this.model.concat([value]) this.modelChange.emit(this.model) }) } - removeItem (item) { + removeItem (item: string[]): void { this.model = this.model.filter(x => x !== item) this.modelChange.emit(this.model) } diff --git a/terminus-settings/src/components/settingsTab.component.ts b/terminus-settings/src/components/settingsTab.component.ts index bc4b90e0dba101c63310bc716340c577d74325b2..1537fd1baf96e8c6a4e9711673ab63946e4449fa 100644 --- a/terminus-settings/src/components/settingsTab.component.ts +++ b/terminus-settings/src/components/settingsTab.component.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import * as yaml from 'js-yaml' import { Subscription } from 'rxjs' import { Component, Inject, Input, HostBinding, NgZone } from '@angular/core' diff --git a/terminus-settings/src/components/settingsTabBody.component.ts b/terminus-settings/src/components/settingsTabBody.component.ts index 9202faf73a32a10d3ee570607a790e8dbdc407a4..cb87417d34f39b94156dc081799b6a26059ec8d4 100644 --- a/terminus-settings/src/components/settingsTabBody.component.ts +++ b/terminus-settings/src/components/settingsTabBody.component.ts @@ -13,7 +13,7 @@ export class SettingsTabBodyComponent { constructor (private componentFactoryResolver: ComponentFactoryResolver) { } - ngAfterViewInit () { + ngAfterViewInit (): void { // run after the change detection finishes setImmediate(() => { this.component = this.placeholder.createComponent( diff --git a/terminus-ssh/src/api.ts b/terminus-ssh/src/api.ts index 3cdf4613394c347a271de8d31b971c583136f47b..4f0f12d4f8e02cb3c45ab0a102fd5e99ecdeef30 100644 --- a/terminus-ssh/src/api.ts +++ b/terminus-ssh/src/api.ts @@ -60,11 +60,11 @@ export class ForwardedPort { }) } - stopLocalListener () { + stopLocalListener (): void { this.listener.close() } - toString () { + toString (): string { if (this.type === PortForwardType.Local) { return `(local) ${this.host}:${this.port} → (remote) ${this.targetAddress}:${this.targetPort}` } else { @@ -88,7 +88,7 @@ export class SSHSession extends BaseSession { this.scripts = connection.scripts || [] } - async start () { + async start (): Promise { this.open = true try { @@ -217,12 +217,12 @@ export class SSHSession extends BaseSession { this.executeUnconditionalScripts() } - emitServiceMessage (msg: string) { + emitServiceMessage (msg: string): void { this.serviceMessage.next(msg) this.logger.info(msg) } - async addPortForward (fw: ForwardedPort) { + async addPortForward (fw: ForwardedPort): Promise { if (fw.type === PortForwardType.Local) { await fw.startLocalListener((socket: Socket) => { this.logger.info(`New connection on ${fw}`) @@ -270,7 +270,7 @@ export class SSHSession extends BaseSession { } } - async removePortForward (fw: ForwardedPort) { + async removePortForward (fw: ForwardedPort): Promise { if (fw.type === PortForwardType.Local) { fw.stopLocalListener() this.forwardedPorts = this.forwardedPorts.filter(x => x !== fw) @@ -282,19 +282,19 @@ export class SSHSession extends BaseSession { this.emitServiceMessage(`Stopped forwarding ${fw}`) } - resize (columns, rows) { + resize (columns: number, rows: number): void { if (this.shell) { this.shell.setWindow(rows, columns, rows, columns) } } - write (data) { + write (data: string): void { if (this.shell) { this.shell.write(data) } } - kill (signal?: string) { + kill (signal?: string): void { if (this.shell) { this.shell.signal(signal || 'TERM') } diff --git a/terminus-ssh/src/buttonProvider.ts b/terminus-ssh/src/buttonProvider.ts index 46d451f56724645194cd061ce31ca7220455629a..2cdf5084231627d9f09507d40efed44c2bee0886 100644 --- a/terminus-ssh/src/buttonProvider.ts +++ b/terminus-ssh/src/buttonProvider.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import { Injectable } from '@angular/core' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { HotkeysService, ToolbarButtonProvider, ToolbarButton } from 'terminus-core' diff --git a/terminus-ssh/src/components/editConnectionModal.component.ts b/terminus-ssh/src/components/editConnectionModal.component.ts index 0a56dbe5b3e6c221ab55cbd4fc5b59d82d821de0..821650abe9da7727a3ead71612edfa4c6bad0a7e 100644 --- a/terminus-ssh/src/components/editConnectionModal.component.ts +++ b/terminus-ssh/src/components/editConnectionModal.component.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import { Component } from '@angular/core' import { NgbModal, NgbActiveModal } from '@ng-bootstrap/ng-bootstrap' import { ElectronService, HostAppService } from 'terminus-core' diff --git a/terminus-ssh/src/components/promptModal.component.ts b/terminus-ssh/src/components/promptModal.component.ts index 262e0573217b964b3c0fe26dca7060562ff48b8e..7b23e3ea4b5c9ab474b629895f7e1f07aa006ed3 100644 --- a/terminus-ssh/src/components/promptModal.component.ts +++ b/terminus-ssh/src/components/promptModal.component.ts @@ -16,20 +16,20 @@ export class PromptModalComponent { private modalInstance: NgbActiveModal, ) { } - ngOnInit () { + ngOnInit (): void { setTimeout(() => { this.input.nativeElement.focus() }) } - ok () { + ok (): void { this.modalInstance.close({ value: this.value, remember: this.remember, }) } - cancel () { + cancel (): void { this.modalInstance.close(null) } } diff --git a/terminus-ssh/src/components/sshModal.component.ts b/terminus-ssh/src/components/sshModal.component.ts index d519ce71889eefe803b3e7b93d7e52dfbed458ca..388e982fe1fc9375e44c3e5ac1db586ae40bd3db 100644 --- a/terminus-ssh/src/components/sshModal.component.ts +++ b/terminus-ssh/src/components/sshModal.component.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import { Component, NgZone } from '@angular/core' import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap' import { ToastrService } from 'ngx-toastr' diff --git a/terminus-ssh/src/components/sshPortForwardingModal.component.ts b/terminus-ssh/src/components/sshPortForwardingModal.component.ts index b31cc58f9c356955b5c462d2ebee93be45ea0018..e44fc85343996c5d86541724c61b8ff7fe029c98 100644 --- a/terminus-ssh/src/components/sshPortForwardingModal.component.ts +++ b/terminus-ssh/src/components/sshPortForwardingModal.component.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import { Component, Input } from '@angular/core' import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap' import { ForwardedPort, PortForwardType, SSHSession } from '../api' diff --git a/terminus-ssh/src/components/sshSettingsTab.component.ts b/terminus-ssh/src/components/sshSettingsTab.component.ts index 9ca7c8c065a29bd97b918c21240942454341fc76..ba3010e8d65edc8192b976f0f7abd9a158a99f9b 100644 --- a/terminus-ssh/src/components/sshSettingsTab.component.ts +++ b/terminus-ssh/src/components/sshSettingsTab.component.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import { Component } from '@angular/core' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { ConfigService, ElectronService, HostAppService } from 'terminus-core' diff --git a/terminus-ssh/src/components/sshTab.component.ts b/terminus-ssh/src/components/sshTab.component.ts index 2429e1623f96ca29cf16cbd20ef615ade34d4942..3cc6f6e0e52f6e85d7eca0ec7c4069e9bda70c93 100644 --- a/terminus-ssh/src/components/sshTab.component.ts +++ b/terminus-ssh/src/components/sshTab.component.ts @@ -3,6 +3,7 @@ import { Spinner } from 'cli-spinner' import { Component, Injector } from '@angular/core' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { first } from 'rxjs/operators' +import { RecoveryToken } from 'terminus-core' import { BaseTerminalTabComponent } from 'terminus-terminal' import { SSHService } from '../services/ssh.service' import { SSHConnection, SSHSession } from '../api' @@ -29,7 +30,7 @@ export class SSHTabComponent extends BaseTerminalTabComponent { super(injector) } - ngOnInit () { + ngOnInit (): void { this.logger = this.log.create('terminalTab') this.homeEndSubscription = this.hotkeys.matchedHotkey.subscribe(hotkey => { @@ -57,7 +58,7 @@ export class SSHTabComponent extends BaseTerminalTabComponent { }) } - async initializeSession () { + async initializeSession (): void { if (!this.connection) { this.logger.error('No SSH connection info supplied') return @@ -96,7 +97,7 @@ export class SSHTabComponent extends BaseTerminalTabComponent { this.session.resize(this.size.columns, this.size.rows) } - async getRecoveryToken (): Promise { + async getRecoveryToken (): Promise { return { type: 'app:ssh-tab', connection: this.connection, @@ -104,16 +105,16 @@ export class SSHTabComponent extends BaseTerminalTabComponent { } } - showPortForwarding () { + showPortForwarding (): void { const modal = this.ngbModal.open(SSHPortForwardingModalComponent).componentInstance as SSHPortForwardingModalComponent modal.session = this.session } - reconnect () { + reconnect (): void { this.initializeSession() } - ngOnDestroy () { + ngOnDestroy (): void { this.homeEndSubscription.unsubscribe() super.ngOnDestroy() } diff --git a/terminus-ssh/src/recoveryProvider.ts b/terminus-ssh/src/recoveryProvider.ts index 1f65b9f633c726fe2c87a35db2d6925b8a789d3e..612105fc113e0c3c935fcb6c0fc8bccace5ad295 100644 --- a/terminus-ssh/src/recoveryProvider.ts +++ b/terminus-ssh/src/recoveryProvider.ts @@ -1,18 +1,18 @@ import { Injectable } from '@angular/core' -import { TabRecoveryProvider, RecoveredTab } from 'terminus-core' +import { TabRecoveryProvider, RecoveredTab, RecoveryToken } from 'terminus-core' import { SSHTabComponent } from './components/sshTab.component' /** @hidden */ @Injectable() export class RecoveryProvider extends TabRecoveryProvider { - async recover (recoveryToken: any): Promise { - if (recoveryToken && recoveryToken.type === 'app:ssh-tab') { + async recover (recoveryToken: RecoveryToken): Promise { + if (recoveryToken?.type === 'app:ssh-tab') { return { type: SSHTabComponent, options: { - connection: recoveryToken.connection, - savedState: recoveryToken.savedState, + connection: recoveryToken['connection'], + savedState: recoveryToken['savedState'], }, } } diff --git a/terminus-terminal/src/api/baseTerminalTab.component.ts b/terminus-terminal/src/api/baseTerminalTab.component.ts index a566073bc7372e7f0af2131682ee3c84e2a18630..a3c944b38d43518a30b3cd7fe1155255d48b3d57 100644 --- a/terminus-terminal/src/api/baseTerminalTab.component.ts +++ b/terminus-terminal/src/api/baseTerminalTab.component.ts @@ -174,7 +174,7 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit } /** @hidden */ - ngOnInit () { + ngOnInit (): void { this.focused$.subscribe(() => { this.configure() this.frontend.focus() @@ -259,7 +259,7 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit /** * Feeds input into the active session */ - sendInput (data: string|Buffer) { + sendInput (data: string|Buffer): void { if (!(data instanceof Buffer)) { data = Buffer.from(data, 'utf-8') } @@ -272,7 +272,7 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit /** * Feeds input into the terminal frontend */ - write (data: string) { + write (data: string): void { const percentageMatch = /(^|[^\d])(\d+(\.\d+)?)%([^\d]|$)/.exec(data) if (percentageMatch) { const percentage = percentageMatch[3] ? parseFloat(percentageMatch[2]) : parseInt(percentageMatch[2]) @@ -286,7 +286,7 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit this.frontend.write(data) } - paste () { + paste (): void { let data = this.electron.clipboard.readText() as string if (this.config.store.terminal.bracketedPaste) { data = '\x1b[200~' + data + '\x1b[201~' @@ -318,23 +318,23 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit } } - zoomIn () { + zoomIn (): void { this.zoom++ this.frontend.setZoom(this.zoom) } - zoomOut () { + zoomOut (): void { this.zoom-- this.frontend.setZoom(this.zoom) } - resetZoom () { + resetZoom (): void { this.zoom = 0 this.frontend.setZoom(this.zoom) } /** @hidden */ - ngOnDestroy () { + ngOnDestroy (): void { this.frontend.detach(this.content.nativeElement) this.detachTermContainerHandlers() this.config.enabledServices(this.decorators).forEach(decorator => { @@ -351,21 +351,21 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit this.output.complete() } - async destroy () { + async destroy (): Promise { super.destroy() if (this.session && this.session.open) { await this.session.destroy() } } - protected detachTermContainerHandlers () { + protected detachTermContainerHandlers (): void { for (const subscription of this.termContainerSubscriptions) { subscription.unsubscribe() } this.termContainerSubscriptions = [] } - protected attachTermContainerHandlers () { + protected attachTermContainerHandlers (): void { this.detachTermContainerHandlers() const maybeConfigure = () => { @@ -437,7 +437,7 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit ] } - protected attachSessionHandlers () { + protected attachSessionHandlers (): void { // this.session.output$.bufferTime(10).subscribe((datas) => { this.session.output$.subscribe(data => { if (this.enablePassthrough) { diff --git a/terminus-terminal/src/api/decorator.ts b/terminus-terminal/src/api/decorator.ts index 1c3db15ef3f2d087cc130dd17f9b344ac072a1e5..3d4ee63a410369d7579f0347f14d5b3e3f5e7619 100644 --- a/terminus-terminal/src/api/decorator.ts +++ b/terminus-terminal/src/api/decorator.ts @@ -26,7 +26,7 @@ export abstract class TerminalDecorator { /** * Automatically cancel @subscription once detached from @terminal */ - protected subscribeUntilDetached (terminal: BaseTerminalTabComponent, subscription: Subscription) { + protected subscribeUntilDetached (terminal: BaseTerminalTabComponent, subscription: Subscription): void { if (!this.smartSubscriptions.has(terminal)) { this.smartSubscriptions.set(terminal, []) } diff --git a/terminus-terminal/src/buttonProvider.ts b/terminus-terminal/src/buttonProvider.ts index 13132d3a53748a2718aff8dac8537a5b812d1b20..68ab3ab944b79bfcc7e8cb4be1de4c5b73090f86 100644 --- a/terminus-terminal/src/buttonProvider.ts +++ b/terminus-terminal/src/buttonProvider.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import * as fs from 'mz/fs' import { Injectable } from '@angular/core' import { ToolbarButtonProvider, ToolbarButton, ElectronService } from 'terminus-core' diff --git a/terminus-terminal/src/components/appearanceSettingsTab.component.ts b/terminus-terminal/src/components/appearanceSettingsTab.component.ts index 6b47cd451cef7e29d80478d859f0b6cd4a813f5d..4b4cd9963c1f18463adab47f3b54b86c72a15677 100644 --- a/terminus-terminal/src/components/appearanceSettingsTab.component.ts +++ b/terminus-terminal/src/components/appearanceSettingsTab.component.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import { Observable } from 'rxjs' import { debounceTime, distinctUntilChanged, map } from 'rxjs/operators' import { exec } from 'mz/child_process' diff --git a/terminus-terminal/src/components/colorPicker.component.ts b/terminus-terminal/src/components/colorPicker.component.ts index c8c7db0cb54dfe9a450ac49f33707e10f9875376..701e8c8b7256f66996c34c43f96dc77add489f5b 100644 --- a/terminus-terminal/src/components/colorPicker.component.ts +++ b/terminus-terminal/src/components/colorPicker.component.ts @@ -15,7 +15,7 @@ export class ColorPickerComponent { @ViewChild('input') input isOpen: boolean - open () { + open (): void { setImmediate(() => { this.popover.open() setImmediate(() => { @@ -25,7 +25,7 @@ export class ColorPickerComponent { }) } - @HostListener('document:click', ['$event']) onOutsideClick ($event) { + @HostListener('document:click', ['$event']) onOutsideClick ($event: MouseEvent): void { if (!this.isOpen) { return } @@ -40,7 +40,7 @@ export class ColorPickerComponent { } } - onChange () { + onChange (): void { this.modelChange.emit(this.model) } } diff --git a/terminus-terminal/src/components/editProfileModal.component.ts b/terminus-terminal/src/components/editProfileModal.component.ts index f395772f73e29b35e7dbfe5a0ed24f717c86fe47..f3c64ec4eaf507bf369931517e42f0979e91c29d 100644 --- a/terminus-terminal/src/components/editProfileModal.component.ts +++ b/terminus-terminal/src/components/editProfileModal.component.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import { Component } from '@angular/core' import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap' import { UACService } from '../services/uac.service' diff --git a/terminus-terminal/src/components/environmentEditor.component.ts b/terminus-terminal/src/components/environmentEditor.component.ts index 1393b9259342975a3920582eabadaaca9d51c266..a6c24178de3fa82e5ff3ea5463967e12af73fb43 100644 --- a/terminus-terminal/src/components/environmentEditor.component.ts +++ b/terminus-terminal/src/components/environmentEditor.component.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import { Component, Output, Input } from '@angular/core' import { Subject } from 'rxjs' diff --git a/terminus-terminal/src/components/searchPanel.component.ts b/terminus-terminal/src/components/searchPanel.component.ts index 609092cdd8125b8625dcc5364bdc1599fbab22b4..f07cdd613e9e953edc81087e8a4dd9f300b93f0f 100644 --- a/terminus-terminal/src/components/searchPanel.component.ts +++ b/terminus-terminal/src/components/searchPanel.component.ts @@ -21,19 +21,19 @@ export class SearchPanelComponent { private toastr: ToastrService, ) { } - onQueryChange () { + onQueryChange (): void { this.notFound = false this.findNext(true) } - findNext (incremental = false) { + findNext (incremental = false): void { if (!this.frontend.findNext(this.query, { ...this.options, incremental: incremental || undefined })) { this.notFound = true this.toastr.error('Not found') } } - findPrevious () { + findPrevious (): void { if (!this.frontend.findPrevious(this.query, this.options)) { this.notFound = true this.toastr.error('Not found') diff --git a/terminus-terminal/src/components/shellSettingsTab.component.ts b/terminus-terminal/src/components/shellSettingsTab.component.ts index b567fe42adca789af2b05f43c50d1c9b44a7a008..e7eb04a41c59a024111b87b1742d6bd47ace259d 100644 --- a/terminus-terminal/src/components/shellSettingsTab.component.ts +++ b/terminus-terminal/src/components/shellSettingsTab.component.ts @@ -37,19 +37,19 @@ export class ShellSettingsTabComponent { this.isConPTYStable = isWindowsBuild(WIN_BUILD_CONPTY_STABLE) } - async ngOnInit () { + async ngOnInit (): void { this.shells = await this.terminalService.shells$.toPromise() } - ngOnDestroy () { + ngOnDestroy (): void { this.configSubscription.unsubscribe() } - async reload () { + async reload (): void { this.profiles = await this.terminalService.getProfiles(true) } - pickWorkingDirectory () { + pickWorkingDirectory (): void { const shell = this.shells.find(x => x.id === this.config.store.terminal.shell) if (!shell) { return @@ -66,7 +66,7 @@ export class ShellSettingsTabComponent { } } - newProfile (shell: Shell) { + newProfile (shell: Shell): void { const profile: Profile = { name: shell.name || '', sessionOptions: this.terminalService.optionsFromShell(shell), @@ -76,7 +76,7 @@ export class ShellSettingsTabComponent { this.reload() } - editProfile (profile: Profile) { + editProfile (profile: Profile): void { const modal = this.ngbModal.open(EditProfileModalComponent) modal.componentInstance.profile = Object.assign({}, profile) modal.result.then(result => { @@ -85,7 +85,7 @@ export class ShellSettingsTabComponent { }) } - deleteProfile (profile: Profile) { + deleteProfile (profile: Profile): void { this.config.store.terminal.profiles = this.config.store.terminal.profiles.filter(x => x !== profile) this.config.save() this.reload() diff --git a/terminus-terminal/src/components/terminalSettingsTab.component.ts b/terminus-terminal/src/components/terminalSettingsTab.component.ts index ed57fb6dfff095eaf6ba7800e9c2dca39c6763a3..4995bcf488797a355149e43fc80f05d3763913b0 100644 --- a/terminus-terminal/src/components/terminalSettingsTab.component.ts +++ b/terminus-terminal/src/components/terminalSettingsTab.component.ts @@ -13,7 +13,7 @@ export class TerminalSettingsTabComponent { private terminal: TerminalService, ) { } - openWSLVolumeMixer () { + openWSLVolumeMixer (): void { this.electron.shell.openItem('sndvol.exe') this.terminal.openTab({ name: '', diff --git a/terminus-terminal/src/components/terminalTab.component.ts b/terminus-terminal/src/components/terminalTab.component.ts index 6a3bc300c439f7e9c472b8466ae0b4effd5bbbbe..9234bce3aef48bb6944700a8f791ff82238b9016 100644 --- a/terminus-terminal/src/components/terminalTab.component.ts +++ b/terminus-terminal/src/components/terminalTab.component.ts @@ -24,7 +24,7 @@ export class TerminalTabComponent extends BaseTerminalTabComponent { super(injector) } - ngOnInit () { + ngOnInit (): void { this.logger = this.log.create('terminalTab') this.session = new Session(this.config) @@ -51,7 +51,7 @@ export class TerminalTabComponent extends BaseTerminalTabComponent { super.ngOnInit() } - initializeSession (columns: number, rows: number) { + initializeSession (columns: number, rows: number): void { this.sessions.addSession( this.session, Object.assign({}, this.sessionOptions, { @@ -101,7 +101,7 @@ export class TerminalTabComponent extends BaseTerminalTabComponent { )).response === 1 } - ngOnDestroy () { + ngOnDestroy (): void { this.homeEndSubscription.unsubscribe() super.ngOnDestroy() this.session.destroy() diff --git a/terminus-terminal/src/features/debug.ts b/terminus-terminal/src/features/debug.ts index b74221222177422506cea6151a1bf4cd967a61df..967cde0885a1eccd9a5788d566ad31a3f9465e4f 100644 --- a/terminus-terminal/src/features/debug.ts +++ b/terminus-terminal/src/features/debug.ts @@ -61,7 +61,7 @@ export class DebugDecorator extends TerminalDecorator { }) } - async loadFile (): Promise { + private async loadFile (): Promise { const result = await this.electron.dialog.showOpenDialog( this.hostApp.getWindow(), { @@ -75,7 +75,7 @@ export class DebugDecorator extends TerminalDecorator { return null } - async saveFile (content: string, name: string) { + private async saveFile (content: string, name: string) { const result = await this.electron.dialog.showSaveDialog( this.hostApp.getWindow(), { @@ -87,21 +87,21 @@ export class DebugDecorator extends TerminalDecorator { } } - doSaveState (terminal: TerminalTabComponent) { + private doSaveState (terminal: TerminalTabComponent) { this.saveFile(terminal.frontend.saveState(), 'state.txt') } - async doCopyState (terminal: TerminalTabComponent) { + private async doCopyState (terminal: TerminalTabComponent) { const data = '```' + JSON.stringify(terminal.frontend.saveState()) + '```' this.electron.clipboard.writeText(data) } - async doLoadState (terminal: TerminalTabComponent) { + private async doLoadState (terminal: TerminalTabComponent) { const data = await this.loadFile() terminal.frontend.restoreState(data) } - async doPasteState (terminal: TerminalTabComponent) { + private async doPasteState (terminal: TerminalTabComponent) { let data = this.electron.clipboard.readText() if (data) { if (data.startsWith('`')) { @@ -111,23 +111,23 @@ export class DebugDecorator extends TerminalDecorator { } } - doSaveOutput (buffer: string) { + private doSaveOutput (buffer: string) { this.saveFile(buffer, 'output.txt') } - async doCopyOutput (buffer: string) { + private async doCopyOutput (buffer: string) { const data = '```' + JSON.stringify(buffer) + '```' this.electron.clipboard.writeText(data) } - async doLoadOutput (terminal: TerminalTabComponent) { + private async doLoadOutput (terminal: TerminalTabComponent) { const data = await this.loadFile() if (data) { terminal.frontend.write(data) } } - async doPasteOutput (terminal: TerminalTabComponent) { + private async doPasteOutput (terminal: TerminalTabComponent) { let data = this.electron.clipboard.readText() if (data) { if (data.startsWith('`')) { diff --git a/terminus-terminal/src/features/pathDrop.ts b/terminus-terminal/src/features/pathDrop.ts index e3d4b3a30c6b4633beefc2d01b9cc4206941892e..38d2eb9dfd38ff737e50b3202760ce711c155f18 100644 --- a/terminus-terminal/src/features/pathDrop.ts +++ b/terminus-terminal/src/features/pathDrop.ts @@ -19,7 +19,7 @@ export class PathDropDecorator extends TerminalDecorator { }) } - injectPath (terminal: TerminalTabComponent, path: string) { + private injectPath (terminal: TerminalTabComponent, path: string) { if (path.includes(' ')) { path = `"${path}"` } diff --git a/terminus-terminal/src/features/zmodem.ts b/terminus-terminal/src/features/zmodem.ts index 3c79d4a03c562ea46bf6e2839fc7d22e46cbba13..b0b7883529bbef389195c3feb246c927f41f9306 100644 --- a/terminus-terminal/src/features/zmodem.ts +++ b/terminus-terminal/src/features/zmodem.ts @@ -68,7 +68,7 @@ export class ZModemDecorator extends TerminalDecorator { }) } - async process (terminal, detection) { + private async process (terminal, detection): Promise { this.showMessage(terminal, colors.bgBlue.black(' ZMODEM ') + ' Session started') this.showMessage(terminal, '------------------------') diff --git a/terminus-terminal/src/frontends/frontend.ts b/terminus-terminal/src/frontends/frontend.ts index 0b09375110fbb15bec651873d7353e7cb437c7cc..b6745bea6f3fc742af430939248d7fc526bbba34 100644 --- a/terminus-terminal/src/frontends/frontend.ts +++ b/terminus-terminal/src/frontends/frontend.ts @@ -76,5 +76,5 @@ export abstract class Frontend { abstract findPrevious (term: string, searchOptions?: SearchOptions): boolean abstract saveState (): any - abstract restoreState (state: any): void + abstract restoreState (state: string): void } diff --git a/terminus-terminal/src/frontends/htermFrontend.ts b/terminus-terminal/src/frontends/htermFrontend.ts index 3aa3f6df18556ecfdcb5f0c6ac13441fe27c9c42..082b2086fae4625cf88e0bc7f9c13f7d6e5ec2bf 100644 --- a/terminus-terminal/src/frontends/htermFrontend.ts +++ b/terminus-terminal/src/frontends/htermFrontend.ts @@ -13,7 +13,7 @@ export class HTermFrontend extends Frontend { private configuredBackgroundColor = 'transparent' private zoom = 0 - attach (host: HTMLElement) { + attach (host: HTMLElement): void { if (!this.initialized) { this.init() this.initialized = true @@ -29,15 +29,15 @@ export class HTermFrontend extends Frontend { return this.term.getSelectionText() } - copySelection () { + copySelection (): void { this.term.copySelectionToClipboard() } - clearSelection () { + clearSelection (): void { this.term.getDocument().getSelection().removeAllRanges() } - focus () { + focus (): void { setTimeout(() => { this.term.scrollPort_.resize() this.term.scrollPort_.focus() @@ -168,7 +168,7 @@ export class HTermFrontend extends Frontend { saveState (): any { } // eslint-disable-next-line @typescript-eslint/no-empty-function - restoreState (_state: any): void { } + restoreState (_state: string): void { } private setFontSize () { const size = this.configuredFontSize * Math.pow(1.1, this.zoom) @@ -262,7 +262,7 @@ export class HTermFrontend extends Frontend { // Drop whitespace at the end of selection const range = selection.getRangeAt(0) if (range.endOffset > 0 && range.endContainer.nodeType === 3 && range.endContainer.textContent !== '') { - while (/[\s\S]+\s$/.test(range.endContainer.textContent.substr(0,range.endOffset))) { + while (/[\s\S]+\s$/.test(range.endContainer.textContent.substr(0, range.endOffset))) { range.setEnd(range.endContainer, range.endOffset - 1) } } diff --git a/terminus-terminal/src/frontends/xtermFrontend.ts b/terminus-terminal/src/frontends/xtermFrontend.ts index 453a933b2d277e10eb045dac2cbfe09733a0dd82..fc90dddc7eed0d9ba3f23e21f41770230af3a1ba 100644 --- a/terminus-terminal/src/frontends/xtermFrontend.ts +++ b/terminus-terminal/src/frontends/xtermFrontend.ts @@ -259,7 +259,7 @@ export class XTermFrontend extends Frontend { return this.serializeAddon.serialize(1000) } - restoreState (state: any): void { + restoreState (state: string): void { this.xterm.write(state) } diff --git a/terminus-terminal/src/recoveryProvider.ts b/terminus-terminal/src/recoveryProvider.ts index 248d01b38a181dd494ff7fcdac2dd562b50157cc..fc6b839a70c23df450bf72e8cc3173794ec31692 100644 --- a/terminus-terminal/src/recoveryProvider.ts +++ b/terminus-terminal/src/recoveryProvider.ts @@ -1,18 +1,18 @@ import { Injectable } from '@angular/core' -import { TabRecoveryProvider, RecoveredTab } from 'terminus-core' +import { TabRecoveryProvider, RecoveredTab, RecoveryToken } from 'terminus-core' import { TerminalTabComponent } from './components/terminalTab.component' /** @hidden */ @Injectable() export class RecoveryProvider extends TabRecoveryProvider { - async recover (recoveryToken: any): Promise { - if (recoveryToken && recoveryToken.type === 'app:terminal-tab') { + async recover (recoveryToken: RecoveryToken): Promise { + if (recoveryToken?.type === 'app:terminal-tab') { return { type: TerminalTabComponent, options: { - sessionOptions: recoveryToken.sessionOptions, - savedState: recoveryToken.savedState, + sessionOptions: recoveryToken['sessionOptions'], + savedState: recoveryToken['savedState'], }, } } diff --git a/terminus-terminal/src/services/dockMenu.service.ts b/terminus-terminal/src/services/dockMenu.service.ts index 38b26374840cc586894b2a8c39f3dbc06b1b02c6..ae3890422c667e776f19797a31b8e4d6400323bb 100644 --- a/terminus-terminal/src/services/dockMenu.service.ts +++ b/terminus-terminal/src/services/dockMenu.service.ts @@ -17,7 +17,7 @@ export class DockMenuService { config.changed$.subscribe(() => this.update()) } - update () { + update (): void { if (this.hostApp.platform === Platform.Windows) { this.electron.app.setJumpList(this.config.store.terminal.profiles.length ? [{ type: 'custom', diff --git a/terminus-terminal/src/services/sessions.service.ts b/terminus-terminal/src/services/sessions.service.ts index 54ea366aa2cc478aee56b658327b5edcad11a9a7..844a9f7115de32865c7bda03fd77b3b9454eb9c1 100644 --- a/terminus-terminal/src/services/sessions.service.ts +++ b/terminus-terminal/src/services/sessions.service.ts @@ -52,7 +52,7 @@ export abstract class BaseSession { get closed$ (): Observable { return this.closed } get destroyed$ (): Observable { return this.destroyed } - emitOutput (data: Buffer) { + emitOutput (data: Buffer): void { if (!this.initialDataBufferReleased) { this.initialDataBuffer = Buffer.concat([this.initialDataBuffer, data]) } else { @@ -61,7 +61,7 @@ export abstract class BaseSession { } } - releaseInitialDataBuffer () { + releaseInitialDataBuffer (): void { this.initialDataBufferReleased = true this.output.next(this.initialDataBuffer.toString()) this.binaryOutput.next(this.initialDataBuffer) @@ -99,7 +99,7 @@ export class Session extends BaseSession { super() } - start (options: SessionOptions) { + start (options: SessionOptions): void { this.name = options.name || '' const env = { @@ -182,31 +182,13 @@ export class Session extends BaseSession { this.pauseAfterExit = options.pauseAfterExit || false } - processOSC1337 (data: Buffer) { - if (data.includes(OSC1337Prefix)) { - const preData = data.subarray(0, data.indexOf(OSC1337Prefix)) - let params = data.subarray(data.indexOf(OSC1337Prefix) + OSC1337Prefix.length) - const postData = params.subarray(params.indexOf(OSC1337Suffix) + OSC1337Suffix.length) - const paramString = params.subarray(0, params.indexOf(OSC1337Suffix)).toString() - - if (paramString.startsWith('CurrentDir=')) { - this.reportedCWD = paramString.split('=')[1] - if (this.reportedCWD.startsWith('~')) { - this.reportedCWD = os.homedir() + this.reportedCWD.substring(1) - } - data = Buffer.concat([preData, postData]) - } - } - return data - } - - resize (columns, rows) { + resize (columns: number, rows: number): void { if (this.pty._writable) { this.pty.resize(columns, rows) } } - write (data: Buffer) { + write (data: Buffer): void { if (this.open) { if (this.pty._writable) { this.pty.write(data) @@ -216,7 +198,7 @@ export class Session extends BaseSession { } } - kill (signal?: string) { + kill (signal?: string): void { this.pty.kill(signal) } @@ -323,6 +305,24 @@ export class Session extends BaseSession { this.guessedCWD = match[0] } } + + private processOSC1337 (data: Buffer) { + if (data.includes(OSC1337Prefix)) { + const preData = data.subarray(0, data.indexOf(OSC1337Prefix)) + let params = data.subarray(data.indexOf(OSC1337Prefix) + OSC1337Prefix.length) + const postData = params.subarray(params.indexOf(OSC1337Suffix) + OSC1337Suffix.length) + const paramString = params.subarray(0, params.indexOf(OSC1337Suffix)).toString() + + if (paramString.startsWith('CurrentDir=')) { + this.reportedCWD = paramString.split('=')[1] + if (this.reportedCWD.startsWith('~')) { + this.reportedCWD = os.homedir() + this.reportedCWD.substring(1) + } + data = Buffer.concat([preData, postData]) + } + } + return data + } } /** @hidden */ @@ -339,7 +339,7 @@ export class SessionsService { this.logger = log.create('sessions') } - addSession (session: BaseSession, options: SessionOptions) { + addSession (session: BaseSession, options: SessionOptions): BaseSession { this.lastID++ options.name = `session-${this.lastID}` session.start(options) diff --git a/terminus-terminal/src/tabContextMenu.ts b/terminus-terminal/src/tabContextMenu.ts index 52d24c9dcd3fe32e31f31f72d01d68b753ed0329..adc199d3de322770cae243e24fb2260d0eceae4b 100644 --- a/terminus-terminal/src/tabContextMenu.ts +++ b/terminus-terminal/src/tabContextMenu.ts @@ -137,7 +137,7 @@ export class CopyPasteContextMenu extends TabContextMenuItemProvider { return [ { label: 'Copy', - click: () => { + click: (): void => { this.zone.run(() => { setTimeout(() => { (tab as BaseTerminalTabComponent).frontend.copySelection() @@ -148,7 +148,7 @@ export class CopyPasteContextMenu extends TabContextMenuItemProvider { }, { label: 'Paste', - click: () => { + click: (): void => { this.zone.run(() => (tab as BaseTerminalTabComponent).paste()) }, },