This commit is contained in:
Eugene Pankov
2019-06-14 17:49:42 +02:00
parent 82e3348122
commit a5ecdeb5ea
62 changed files with 271 additions and 280 deletions

View File

@@ -91,7 +91,7 @@ export class AppRootComponent {
this.hotkeys.matchedHotkey.subscribe((hotkey) => {
if (hotkey.startsWith('tab-')) {
let index = parseInt(hotkey.split('-')[1])
const index = parseInt(hotkey.split('-')[1])
if (index <= this.app.tabs.length) {
this.app.selectTab(this.app.tabs[index - 1])
}

View File

@@ -23,7 +23,7 @@ export class CheckboxComponent implements ControlValueAccessor {
}
this.model = !this.model
for (let fx of this.changed) {
for (const fx of this.changed) {
fx(this.model)
}
}

View File

@@ -35,7 +35,7 @@ export class SplitContainer {
*/
getAllTabs () {
let r = []
for (let child of this.children) {
for (const child of this.children) {
if (child instanceof SplitContainer) {
r = r.concat(child.getAllTabs())
} else {
@@ -50,7 +50,7 @@ export class SplitContainer {
*/
normalize () {
for (let i = 0; i < this.children.length; i++) {
let child = this.children[i]
const child = this.children[i]
if (child instanceof SplitContainer) {
child.normalize()
@@ -63,7 +63,7 @@ export class SplitContainer {
} else if (child.children.length === 1) {
this.children[i] = child.children[0]
} else if (child.orientation === this.orientation) {
let ratio = this.ratios[i]
const ratio = this.ratios[i]
this.children.splice(i, 1)
this.ratios.splice(i, 1)
for (let j = 0; j < child.children.length; j++) {
@@ -76,7 +76,7 @@ export class SplitContainer {
}
let s = 0
for (let x of this.ratios) {
for (const x of this.ratios) {
s += x
}
this.ratios = this.ratios.map(x => x / s)
@@ -94,8 +94,8 @@ export class SplitContainer {
}
async serialize () {
let children = []
for (let child of this.children) {
const children = []
for (const child of this.children) {
if (child instanceof SplitContainer) {
children.push(await child.serialize())
} else {
@@ -257,7 +257,7 @@ export class SplitTabComponent extends BaseTabComponent implements OnInit, OnDes
focus (tab: BaseTabComponent) {
this.focusedTab = tab
for (let x of this.getAllTabs()) {
for (const x of this.getAllTabs()) {
if (x !== tab) {
x.emitBlurred()
}
@@ -294,7 +294,7 @@ export class SplitTabComponent extends BaseTabComponent implements OnInit, OnDes
(target.orientation === 'v' && ['l', 'r'].includes(side)) ||
(target.orientation === 'h' && ['t', 'b'].includes(side))
) {
let newContainer = new SplitContainer()
const newContainer = new SplitContainer()
newContainer.orientation = (target.orientation === 'v') ? 'h' : 'v'
newContainer.children = [relative]
newContainer.ratios = [1]
@@ -326,8 +326,8 @@ export class SplitTabComponent extends BaseTabComponent implements OnInit, OnDes
}
removeTab (tab: BaseTabComponent) {
let parent = this.getParentOf(tab)
let index = parent.children.indexOf(tab)
const parent = this.getParentOf(tab)
const index = parent.children.indexOf(tab)
parent.ratios.splice(index, 1)
parent.children.splice(index, 1)
@@ -350,7 +350,7 @@ export class SplitTabComponent extends BaseTabComponent implements OnInit, OnDes
navigate (dir: SplitDirection) {
let rel: BaseTabComponent | SplitContainer = this.focusedTab
let parent = this.getParentOf(rel)
let orientation = ['l', 'r'].includes(dir) ? 'h' : 'v'
const orientation = ['l', 'r'].includes(dir) ? 'h' : 'v'
while (parent !== this.root && parent.orientation !== orientation) {
rel = parent
@@ -361,7 +361,7 @@ export class SplitTabComponent extends BaseTabComponent implements OnInit, OnDes
return
}
let index = parent.children.indexOf(rel)
const index = parent.children.indexOf(rel)
if (['l', 't'].includes(dir)) {
if (index > 0) {
this.focusAnyIn(parent.children[index - 1])
@@ -374,7 +374,7 @@ export class SplitTabComponent extends BaseTabComponent implements OnInit, OnDes
}
async splitTab (tab: BaseTabComponent, dir: SplitDirection) {
let newTab = await this.tabsService.duplicate(tab)
const newTab = await this.tabsService.duplicate(tab)
this.addTab(newTab, tab, dir)
}
@@ -383,9 +383,9 @@ export class SplitTabComponent extends BaseTabComponent implements OnInit, OnDes
*/
getParentOf (tab: BaseTabComponent | SplitContainer, root?: SplitContainer): SplitContainer {
root = root || this.root
for (let child of root.children) {
for (const child of root.children) {
if (child instanceof SplitContainer) {
let r = this.getParentOf(tab, child)
const r = this.getParentOf(tab, child)
if (r) {
return r
}
@@ -419,7 +419,7 @@ export class SplitTabComponent extends BaseTabComponent implements OnInit, OnDes
}
private attachTabView (tab: BaseTabComponent) {
let ref = this.viewContainer.insert(tab.hostView) as EmbeddedViewRef<any>
const ref = this.viewContainer.insert(tab.hostView) as EmbeddedViewRef<any>
this.viewRefs.set(tab, ref)
ref.rootNodes[0].addEventListener('click', () => this.focus(tab))
@@ -436,7 +436,7 @@ export class SplitTabComponent extends BaseTabComponent implements OnInit, OnDes
}
private detachTabView (tab: BaseTabComponent) {
let ref = this.viewRefs.get(tab)
const ref = this.viewRefs.get(tab)
this.viewRefs.delete(tab)
this.viewContainer.remove(this.viewContainer.indexOf(ref))
}
@@ -448,8 +448,8 @@ export class SplitTabComponent extends BaseTabComponent implements OnInit, OnDes
}
private layoutInternal (root: SplitContainer, x: number, y: number, w: number, h: number) {
let size = (root.orientation === 'v') ? h : w
let sizes = root.ratios.map(x => x * size)
const size = (root.orientation === 'v') ? h : w
const sizes = root.ratios.map(x => x * size)
root.x = x
root.y = y
@@ -458,14 +458,14 @@ export class SplitTabComponent extends BaseTabComponent implements OnInit, OnDes
let offset = 0
root.children.forEach((child, i) => {
let childX = (root.orientation === 'v') ? x : (x + offset)
let childY = (root.orientation === 'v') ? (y + offset) : y
let childW = (root.orientation === 'v') ? w : sizes[i]
let childH = (root.orientation === 'v') ? sizes[i] : h
const childX = (root.orientation === 'v') ? x : (x + offset)
const childY = (root.orientation === 'v') ? (y + offset) : y
const childW = (root.orientation === 'v') ? w : sizes[i]
const childH = (root.orientation === 'v') ? sizes[i] : h
if (child instanceof SplitContainer) {
this.layoutInternal(child, childX, childY, childW, childH)
} else {
let element = this.viewRefs.get(child).rootNodes[0]
const element = this.viewRefs.get(child).rootNodes[0]
element.style.position = 'absolute'
element.style.left = `${childX}%`
element.style.top = `${childY}%`
@@ -486,19 +486,19 @@ export class SplitTabComponent extends BaseTabComponent implements OnInit, OnDes
}
private async recoverContainer (root: SplitContainer, state: any) {
let children: (SplitContainer | BaseTabComponent)[] = []
const children: (SplitContainer | BaseTabComponent)[] = []
root.orientation = state.orientation
root.ratios = state.ratios
root.children = children
for (let childState of state.children) {
for (const childState of state.children) {
if (childState.type === 'app:split-tab') {
let child = new SplitContainer()
const child = new SplitContainer()
await this.recoverContainer(child, childState)
children.push(child)
} else {
let recovered = await this.tabRecovery.recoverTab(childState)
const recovered = await this.tabRecovery.recoverTab(childState)
if (recovered) {
let tab = this.tabsService.create(recovered.type, recovered.options)
const tab = this.tabsService.create(recovered.type, recovered.options)
children.push(tab)
this.attachTabView(tab)
} else {

View File

@@ -25,13 +25,13 @@ export class SplitTabSpannerComponent {
ngAfterViewInit () {
this.element.nativeElement.addEventListener('mousedown', e => {
this.isActive = true
let start = this.isVertical ? e.pageY : e.pageX
const start = this.isVertical ? e.pageY : e.pageX
let current = start
let oldPosition = this.isVertical ? this.element.nativeElement.offsetTop : this.element.nativeElement.offsetLeft
const oldPosition = this.isVertical ? this.element.nativeElement.offsetTop : this.element.nativeElement.offsetLeft
const dragHandler = e => {
current = this.isVertical ? e.pageY : e.pageX
let newPosition = oldPosition + (current - start)
const newPosition = oldPosition + (current - start)
if (this.isVertical) {
this.element.nativeElement.style.top = `${newPosition - this.marginOffset}px`
} else {

View File

@@ -52,7 +52,7 @@ export class TabHeaderComponent {
}
showRenameTabModal (): void {
let modal = this.ngbModal.open(RenameTabModalComponent)
const modal = this.ngbModal.open(RenameTabModalComponent)
modal.componentInstance.value = this.tab.customTitle || this.tab.title
modal.result.then(result => {
this.tab.setTitle(result)
@@ -62,7 +62,7 @@ export class TabHeaderComponent {
async buildContextMenu (): Promise<Electron.MenuItemConstructorOptions[]> {
let items: Electron.MenuItemConstructorOptions[] = []
for (let section of await Promise.all(this.contextMenuProviders.map(x => x.getItems(this.tab, this)))) {
for (const section of await Promise.all(this.contextMenuProviders.map(x => x.getItems(this.tab, this)))) {
items.push({ type: 'separator' })
items = items.concat(section)
}

View File

@@ -68,7 +68,7 @@ export class AppService {
private tabsService: TabsService,
) {
this.tabRecovery.recoverTabs().then(tabs => {
for (let tab of tabs) {
for (const tab of tabs) {
this.openNewTabRaw(tab.type, tab.options)
}
@@ -98,7 +98,7 @@ export class AppService {
})
tab.destroyed$.subscribe(() => {
let newIndex = Math.max(0, this.tabs.indexOf(tab) - 1)
const newIndex = Math.max(0, this.tabs.indexOf(tab) - 1)
this.tabs = this.tabs.filter((x) => x !== tab)
if (tab === this._activeTab) {
this.selectTab(this.tabs[newIndex])
@@ -113,7 +113,7 @@ export class AppService {
* @param inputs Properties to be assigned on the new tab component instance
*/
openNewTabRaw (type: TabComponentType, inputs?: any): BaseTabComponent {
let tab = this.tabsService.create(type, inputs)
const tab = this.tabsService.create(type, inputs)
this.addTabRaw(tab)
return tab
}
@@ -123,8 +123,8 @@ export class AppService {
* @param inputs Properties to be assigned on the new tab component instance
*/
openNewTab (type: TabComponentType, inputs?: any): BaseTabComponent {
let splitTab = this.tabsService.create(SplitTabComponent) as SplitTabComponent
let tab = this.tabsService.create(type, inputs)
const splitTab = this.tabsService.create(SplitTabComponent) as SplitTabComponent
const tab = this.tabsService.create(type, inputs)
splitTab.addTab(tab, null, 'r')
this.addTabRaw(splitTab)
return tab
@@ -164,7 +164,7 @@ export class AppService {
nextTab () {
if (this.tabs.length > 1) {
let tabIndex = this.tabs.indexOf(this._activeTab)
const tabIndex = this.tabs.indexOf(this._activeTab)
if (tabIndex < this.tabs.length - 1) {
this.selectTab(this.tabs[tabIndex + 1])
} else if (this.config.store.appearance.cycleTabs) {
@@ -175,7 +175,7 @@ export class AppService {
previousTab () {
if (this.tabs.length > 1) {
let tabIndex = this.tabs.indexOf(this._activeTab)
const tabIndex = this.tabs.indexOf(this._activeTab)
if (tabIndex > 0) {
this.selectTab(this.tabs[tabIndex - 1])
} else if (this.config.store.appearance.cycleTabs) {
@@ -200,19 +200,19 @@ export class AppService {
}
async duplicateTab (tab: BaseTabComponent) {
let dup = await this.tabsService.duplicate(tab)
const dup = await this.tabsService.duplicate(tab)
if (dup) {
this.addTabRaw(dup)
}
}
async closeAllTabs () {
for (let tab of this.tabs) {
for (const tab of this.tabs) {
if (!await tab.canClose()) {
return
}
}
for (let tab of this.tabs) {
for (const tab of this.tabs) {
tab.destroy()
}
}
@@ -230,7 +230,7 @@ export class AppService {
*/
observeTabCompletion (tab: BaseTabComponent): Observable<void> {
if (!this.completionObservers.has(tab)) {
let observer = new CompletionObserver(tab)
const observer = new CompletionObserver(tab)
observer.destroyed$.subscribe(() => {
this.stopObservingTabCompletion(tab)
})

View File

@@ -21,12 +21,12 @@ function isNonStructuralObjectMember (v) {
/** @hidden */
export class ConfigProxy {
constructor (real: any, defaults: any) {
for (let key in defaults) {
for (const key in defaults) {
if (isStructuralMember(defaults[key])) {
if (!real[key]) {
real[key] = {}
}
let proxy = new ConfigProxy(real[key], defaults[key])
const proxy = new ConfigProxy(real[key], defaults[key])
Object.defineProperty(
this,
key,
@@ -177,9 +177,9 @@ export class ConfigService {
enabledServices<T> (services: T[]): T[] {
if (!this.servicesCache) {
this.servicesCache = {}
let ngModule = window['rootModule'].ngInjectorDef
for (let imp of ngModule.imports) {
let module = (imp['ngModule'] || imp)
const ngModule = window['rootModule'].ngInjectorDef
for (const imp of ngModule.imports) {
const module = (imp['ngModule'] || imp)
if (module.ngInjectorDef && module.ngInjectorDef.providers) {
this.servicesCache[module['pluginName']] = module.ngInjectorDef.providers.map(provider => {
return provider['useClass'] || provider
@@ -188,7 +188,7 @@ export class ConfigService {
}
}
return services.filter(service => {
for (let pluginName in this.servicesCache) {
for (const pluginName in this.servicesCache) {
if (this.servicesCache[pluginName].includes(service.constructor)) {
return !this.store.pluginBlacklist.includes(pluginName)
}

View File

@@ -21,7 +21,7 @@ export class DockingService {
}
dock () {
let dockSide = this.config.store.appearance.dock
const dockSide = this.config.store.appearance.dock
if (dockSide === 'off') {
this.hostApp.setAlwaysOnTop(false)
@@ -34,9 +34,9 @@ export class DockingService {
display = this.getCurrentScreen()
}
let newBounds: Bounds = { x: 0, y: 0, width: 0, height: 0 }
let fill = this.config.store.appearance.dockFill
let [minWidth, minHeight] = this.hostApp.getWindow().getMinimumSize()
const newBounds: Bounds = { x: 0, y: 0, width: 0, height: 0 }
const fill = this.config.store.appearance.dockFill
const [minWidth, minHeight] = this.hostApp.getWindow().getMinimumSize()
if (dockSide === 'left' || dockSide === 'right') {
newBounds.width = Math.max(minWidth, Math.round(fill * display.bounds.width))
@@ -80,14 +80,14 @@ export class DockingService {
}
private repositionWindow () {
let [x, y] = this.hostApp.getWindow().getPosition()
for (let screen of this.electron.screen.getAllDisplays()) {
let bounds = screen.bounds
const [x, y] = this.hostApp.getWindow().getPosition()
for (const screen of this.electron.screen.getAllDisplays()) {
const bounds = screen.bounds
if (x >= bounds.x && x <= bounds.x + bounds.width && y >= bounds.y && y <= bounds.y + bounds.height) {
return
}
}
let screen = this.electron.screen.getPrimaryDisplay()
const screen = this.electron.screen.getPrimaryDisplay()
this.hostApp.getWindow().setPosition(screen.bounds.x, screen.bounds.y)
}
}

View File

@@ -29,12 +29,12 @@ export class HomeBaseService {
reportBug () {
let body = `Version: ${this.appVersion}\n`
body += `Platform: ${os.platform()} ${os.release()}\n`
let label = {
const label = {
darwin: 'OS: macOS',
windows: 'OS: Windows',
linux: 'OS: Linux',
}[os.platform()]
let plugins = (window as any).installedPlugins.filter(x => !x.isBuiltin).map(x => x.name)
const plugins = (window as any).installedPlugins.filter(x => !x.isBuiltin).map(x => x.name)
body += `Plugins: ${plugins.join(', ') || 'none'}\n\n`
this.electron.shell.openExternal(`https://github.com/eugeny/terminus/issues/new?body=${encodeURIComponent(body)}&labels=${label}`)
}

View File

@@ -170,7 +170,7 @@ export class HostAppService {
}
toggleFullscreen () {
let window = this.getWindow()
const window = this.getWindow()
window.setFullScreen(!this.isFullScreen)
}

View File

@@ -1,6 +1,6 @@
import { Injectable, Inject, NgZone, EventEmitter } from '@angular/core'
import { IHotkeyDescription, HotkeyProvider } from '../api/hotkeyProvider'
import { NativeKeyEvent, stringifyKeySequence } from './hotkeys.util'
import { stringifyKeySequence } from './hotkeys.util'
import { ConfigService } from '../services/config.service'
import { ElectronService } from '../services/electron.service'
@@ -13,13 +13,13 @@ export interface PartialHotkeyMatch {
const KEY_TIMEOUT = 2000
interface EventBufferEntry {
event: NativeKeyEvent
event: KeyboardEvent
time: number
}
@Injectable({ providedIn: 'root' })
export class HotkeysService {
key = new EventEmitter<NativeKeyEvent>()
key = new EventEmitter<KeyboardEvent>()
matchedHotkey = new EventEmitter<string>()
globalHotkey = new EventEmitter()
private currentKeystrokes: EventBufferEntry[] = []
@@ -33,9 +33,9 @@ export class HotkeysService {
private config: ConfigService,
@Inject(HotkeyProvider) private hotkeyProviders: HotkeyProvider[],
) {
let events = ['keydown', 'keyup']
events.forEach((event) => {
document.addEventListener(event, (nativeEvent) => {
const events = ['keydown', 'keyup']
events.forEach(event => {
document.addEventListener(event, (nativeEvent: KeyboardEvent) => {
if (document.querySelectorAll('input:focus').length === 0) {
this.pushKeystroke(event, nativeEvent)
this.processKeystrokes()
@@ -58,8 +58,8 @@ export class HotkeysService {
* @param name DOM event name
* @param nativeEvent event object
*/
pushKeystroke (name, nativeEvent) {
nativeEvent.event = name
pushKeystroke (name: string, nativeEvent: KeyboardEvent) {
(nativeEvent as any).event = name
this.currentKeystrokes.push({ event: nativeEvent, time: performance.now() })
}
@@ -69,7 +69,7 @@ export class HotkeysService {
processKeystrokes () {
if (this.isEnabled()) {
this.zone.run(() => {
let matched = this.getCurrentFullyMatchedHotkey()
const matched = this.getCurrentFullyMatchedHotkey()
if (matched) {
console.log('Matched hotkey', matched)
this.matchedHotkey.emit(matched)
@@ -79,7 +79,7 @@ export class HotkeysService {
}
}
emitKeyEvent (nativeEvent) {
emitKeyEvent (nativeEvent: KeyboardEvent) {
this.zone.run(() => {
this.key.emit(nativeEvent)
})
@@ -100,7 +100,7 @@ export class HotkeysService {
if (typeof value === 'string') {
value = [value]
}
value.forEach(item => {
value.forEach((item: string | string[]) => {
item = (typeof item === 'string') ? [item] : item
try {
@@ -121,13 +121,13 @@ export class HotkeysService {
return this.getHotkeysConfigRecursive(this.config.store.hotkeys)
}
private getHotkeysConfigRecursive (branch) {
let keys = {}
for (let key in branch) {
private getHotkeysConfigRecursive (branch: any) {
const keys = {}
for (const key in branch) {
let value = branch[key]
if (value instanceof Object && !(value instanceof Array)) {
let subkeys = this.getHotkeysConfigRecursive(value)
for (let subkey in subkeys) {
const subkeys = this.getHotkeysConfigRecursive(value)
for (const subkey in subkeys) {
keys[key + '.' + subkey] = subkeys[subkey]
}
} else {
@@ -135,7 +135,7 @@ export class HotkeysService {
value = [value]
}
if (value) {
value = value.map(item => (typeof item === 'string') ? [item] : item)
value = value.map((item: string | string[]) => (typeof item === 'string') ? [item] : item)
keys[key] = value
}
}
@@ -144,15 +144,15 @@ export class HotkeysService {
}
private getCurrentFullyMatchedHotkey (): string {
let currentStrokes = this.getCurrentKeystrokes()
let config = this.getHotkeysConfig()
for (let id in config) {
for (let sequence of config[id]) {
const currentStrokes = this.getCurrentKeystrokes()
const config = this.getHotkeysConfig()
for (const id in config) {
for (const sequence of config[id]) {
if (currentStrokes.length < sequence.length) {
continue
}
if (sequence.every(
(x, index) =>
(x: string, index: number) =>
x.toLowerCase() ===
currentStrokes[currentStrokes.length - sequence.length + index].toLowerCase()
)) {
@@ -164,14 +164,14 @@ export class HotkeysService {
}
getCurrentPartiallyMatchedHotkeys (): PartialHotkeyMatch[] {
let currentStrokes = this.getCurrentKeystrokes()
let config = this.getHotkeysConfig()
let result = []
for (let id in config) {
for (let sequence of config[id]) {
const currentStrokes = this.getCurrentKeystrokes()
const config = this.getHotkeysConfig()
const result = []
for (const id in config) {
for (const sequence of config[id]) {
for (let matchLength = Math.min(currentStrokes.length, sequence.length); matchLength > 0; matchLength--) {
if (sequence.slice(0, matchLength).every(
(x, index) =>
(x: string, index: number) =>
x.toLowerCase() ===
currentStrokes[currentStrokes.length - matchLength + index].toLowerCase()
)) {

View File

@@ -10,24 +10,14 @@ export const altKeyName = {
linux: 'Alt',
}[process.platform]
export interface NativeKeyEvent {
event?: string
altKey: boolean
ctrlKey: boolean
metaKey: boolean
shiftKey: boolean
key: string
keyCode: string
}
export function stringifyKeySequence (events: NativeKeyEvent[]): string[] {
let items: string[] = []
export function stringifyKeySequence (events: KeyboardEvent[]): string[] {
const items: string[] = []
events = events.slice()
while (events.length > 0) {
let event = events.shift()
if (event.event === 'keydown') {
let itemKeys: string[] = []
const event = events.shift()
if ((event as any).event === 'keydown') {
const itemKeys: string[] = []
if (event.ctrlKey) {
itemKeys.push('Ctrl')
}
@@ -46,7 +36,7 @@ export function stringifyKeySequence (events: NativeKeyEvent[]): string[] {
continue
}
let key = (event as any).code
let key = event.code
key = key.replace('Key', '')
key = key.replace('Arrow', '')
key = key.replace('Digit', '')

View File

@@ -61,11 +61,11 @@ export class ShellIntegrationService {
async install () {
const exe = process.env.PORTABLE_EXECUTABLE_FILE || this.electron.app.getPath('exe')
if (this.hostApp.platform === Platform.macOS) {
for (let wf of this.automatorWorkflows) {
for (const wf of this.automatorWorkflows) {
await exec(`cp -r "${this.automatorWorkflowsLocation}/${wf}" "${this.automatorWorkflowsDestination}"`)
}
} else if (this.hostApp.platform === Platform.Windows) {
for (let registryKey of this.registryKeys) {
for (const registryKey of this.registryKeys) {
wnr.createRegistryKey(wnr.HK.CU, registryKey.path)
wnr.createRegistryKey(wnr.HK.CU, registryKey.path + '\\command')
wnr.setRegistryValue(wnr.HK.CU, registryKey.path, 'Icon', wnr.REG.SZ, exe)
@@ -76,11 +76,11 @@ export class ShellIntegrationService {
async remove () {
if (this.hostApp.platform === Platform.macOS) {
for (let wf of this.automatorWorkflows) {
for (const wf of this.automatorWorkflows) {
await exec(`rm -rf "${this.automatorWorkflowsDestination}/${wf}"`)
}
} else if (this.hostApp.platform === Platform.Windows) {
for (let registryKey of this.registryKeys) {
for (const registryKey of this.registryKeys) {
wnr.deleteRegistryKey(wnr.HK.CU, registryKey.path)
}
}

View File

@@ -28,9 +28,9 @@ export class TabRecoveryService {
}
async recoverTab (token: any): Promise<RecoveredTab> {
for (let provider of this.config.enabledServices(this.tabRecoveryProviders)) {
for (const provider of this.config.enabledServices(this.tabRecoveryProviders)) {
try {
let tab = await provider.recover(token)
const tab = await provider.recover(token)
if (tab) {
return tab
}
@@ -43,9 +43,9 @@ export class TabRecoveryService {
async recoverTabs (): Promise<RecoveredTab[]> {
if (window.localStorage.tabsRecovery) {
let tabs: RecoveredTab[] = []
for (let token of JSON.parse(window.localStorage.tabsRecovery)) {
let tab = await this.recoverTab(token)
const tabs: RecoveredTab[] = []
for (const token of JSON.parse(window.localStorage.tabsRecovery)) {
const tab = await this.recoverTab(token)
if (tab) {
tabs.push(tab)
}

View File

@@ -17,9 +17,9 @@ export class TabsService {
* Instantiates a tab component and assigns given inputs
*/
create (type: TabComponentType, inputs?: any): BaseTabComponent {
let componentFactory = this.componentFactoryResolver.resolveComponentFactory(type)
let componentRef = componentFactory.create(this.injector)
let tab = componentRef.instance
const componentFactory = this.componentFactoryResolver.resolveComponentFactory(type)
const componentRef = componentFactory.create(this.injector)
const tab = componentRef.instance
tab.hostView = componentRef.hostView
Object.assign(tab, inputs || {})
return tab
@@ -29,11 +29,11 @@ export class TabsService {
* Duplicates an existing tab instance (using the tab recovery system)
*/
async duplicate (tab: BaseTabComponent): Promise<BaseTabComponent> {
let token = await tab.getRecoveryToken()
const token = await tab.getRecoveryToken()
if (!token) {
return null
}
let dup = await this.tabRecovery.recoverTab(token)
const dup = await this.tabRecovery.recoverTab(token)
if (dup) {
return this.create(dup.type, dup.options)
}

View File

@@ -28,19 +28,19 @@ export class TouchbarService {
app.tabsChanged$.subscribe(() => this.updateTabs())
app.activeTabChange$.subscribe(() => this.updateTabs())
let activityIconPath = `${electron.app.getAppPath()}/assets/activity.png`
let activityIcon = this.electron.nativeImage.createFromPath(activityIconPath)
const activityIconPath = `${electron.app.getAppPath()}/assets/activity.png`
const activityIcon = this.electron.nativeImage.createFromPath(activityIconPath)
app.tabOpened$.subscribe(tab => {
tab.titleChange$.subscribe(title => {
let segment = this.tabSegments[app.tabs.indexOf(tab)]
const segment = this.tabSegments[app.tabs.indexOf(tab)]
if (segment) {
segment.label = this.shortenTitle(title)
this.tabsSegmentedControl.segments = this.tabSegments
}
})
tab.activity$.subscribe(hasActivity => {
let showIcon = this.app.activeTab !== tab && hasActivity
let segment = this.tabSegments[app.tabs.indexOf(tab)]
const showIcon = this.app.activeTab !== tab && hasActivity
const segment = this.tabSegments[app.tabs.indexOf(tab)]
if (segment) {
segment.icon = showIcon ? activityIcon : null
}
@@ -87,7 +87,7 @@ export class TouchbarService {
})
})
let touchBar = new this.electron.TouchBar({
const touchBar = new this.electron.TouchBar({
items: [
this.tabsSegmentedControl,
new this.electron.TouchBar.TouchBarSpacer({ size: 'flexible' }),

View File

@@ -49,9 +49,9 @@ export class UpdaterService {
async check (): Promise<boolean> {
if (!this.electronUpdaterAvailable) {
this.logger.debug('Checking for updates')
let response = await axios.get(UPDATES_URL)
let data = response.data
let version = data.tag_name.substring(1)
const response = await axios.get(UPDATES_URL)
const data = response.data
const version = data.tag_name.substring(1)
if (this.electron.app.getVersion() !== version) {
this.logger.info('Update available')
this.updateURL = data.html_url

View File

@@ -27,7 +27,7 @@ export class CloseContextMenu extends TabContextMenuItemProvider {
{
label: 'Close other tabs',
click: () => this.zone.run(() => {
for (let t of this.app.tabs.filter(x => x !== tab)) {
for (const t of this.app.tabs.filter(x => x !== tab)) {
this.app.closeTab(t, true)
}
})
@@ -35,7 +35,7 @@ export class CloseContextMenu extends TabContextMenuItemProvider {
{
label: 'Close tabs to the right',
click: () => this.zone.run(() => {
for (let t of this.app.tabs.slice(this.app.tabs.indexOf(tab) + 1)) {
for (const t of this.app.tabs.slice(this.app.tabs.indexOf(tab) + 1)) {
this.app.closeTab(t, true)
}
})
@@ -43,7 +43,7 @@ export class CloseContextMenu extends TabContextMenuItemProvider {
{
label: 'Close tabs to the left',
click: () => this.zone.run(() => {
for (let t of this.app.tabs.slice(0, this.app.tabs.indexOf(tab))) {
for (const t of this.app.tabs.slice(0, this.app.tabs.indexOf(tab))) {
this.app.closeTab(t, true)
}
})
@@ -111,7 +111,7 @@ export class TaskCompletionContextMenu extends TabContextMenuItemProvider {
}
async getItems (tab: BaseTabComponent): Promise<Electron.MenuItemConstructorOptions[]> {
let process = await tab.getCurrentProcess()
const process = await tab.getCurrentProcess()
if (process) {
return [
{

View File

@@ -2,6 +2,6 @@
"extends": "../tsconfig.json",
"exclude": ["node_modules", "dist"],
"compilerOptions": {
"baseUrl": "src",
"baseUrl": "src"
}
}