electron 11 cleanup

This commit is contained in:
Eugene Pankov
2020-12-24 14:03:14 +01:00
parent e87f6e7af0
commit 0ca971a289
87 changed files with 9169 additions and 8285 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "terminus-terminal",
"version": "1.0.104-nightly.0",
"version": "1.0.123-nightly.0",
"description": "Terminus' terminal emulation core",
"keywords": [
"terminus-builtin-plugin"

View File

@@ -1,3 +1,4 @@
import type { MenuItemConstructorOptions } from 'electron'
import { Observable, Subject, Subscription } from 'rxjs'
import { first } from 'rxjs/operators'
import { ToastrService } from 'ngx-toastr'
@@ -16,14 +17,14 @@ import { TerminalDecorator } from './decorator'
/** @hidden */
export interface ToastrServiceProxy {
info (_: string)
info: (_: string) => void
}
/**
* A class to base your custom terminal tabs on
*/
export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit, OnDestroy {
static template = require<string>('../components/baseTerminalTab.component.pug')
static styles = [require<string>('../components/terminalTab.component.scss')]
static template: string = require<string>('../components/baseTerminalTab.component.pug')
static styles: string[] = [require<string>('../components/terminalTab.component.scss')]
static animations: AnimationTriggerMetadata[] = [trigger('slideInOut', [
transition(':enter', [
style({ transform: 'translateY(-25%)' }),
@@ -277,8 +278,8 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
})
}
async buildContextMenu (): Promise<Electron.MenuItemConstructorOptions[]> {
let items: Electron.MenuItemConstructorOptions[] = []
async buildContextMenu (): Promise<MenuItemConstructorOptions[]> {
let items: MenuItemConstructorOptions[] = []
for (const section of await Promise.all(this.contextMenuProviders.map(x => x.getItems(this)))) {
items = items.concat(section)
items.push({ type: 'separator' })
@@ -435,7 +436,7 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
async destroy (): Promise<void> {
super.destroy()
if (this.session && this.session.open) {
if (this.session?.open) {
await this.session.destroy()
}
}
@@ -512,7 +513,7 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
this.logger.debug(`Resizing to ${columns}x${rows}`)
this.size = { columns, rows }
this.zone.run(() => {
if (this.session && this.session.open) {
if (this.session?.open) {
this.session.resize(columns, rows)
}
})

View File

@@ -1,3 +1,4 @@
import type { MenuItemConstructorOptions } from 'electron'
import { BaseTerminalTabComponent } from './baseTerminalTab.component'
/**
@@ -7,5 +8,5 @@ import { BaseTerminalTabComponent } from './baseTerminalTab.component'
export abstract class TerminalContextMenuItemProvider {
weight: number
abstract async getItems (tab: BaseTerminalTabComponent): Promise<Electron.MenuItemConstructorOptions[]>
abstract async getItems (tab: BaseTerminalTabComponent): Promise<MenuItemConstructorOptions[]>
}

View File

@@ -8,7 +8,7 @@ export interface SessionOptions {
command: string
args: string[]
cwd?: string
env?: {[id: string]: string}
env?: Record<string, string>
width?: number
height?: number
pauseAfterExit?: boolean

View File

@@ -20,10 +20,10 @@ export class HyperColorSchemes extends TerminalColorSchemeProvider {
try {
const module = (global as any).require(path.join(pluginsPath, plugin))
if (module.decorateConfig) {
let config: any
let config: any = {}
try {
config = module.decorateConfig({})
} catch (error) {
} catch {
console.warn('Could not load Hyper theme:', plugin)
return
}

View File

@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/camelcase */
import colors from 'ansi-colors'
import * as ZModem from 'zmodem.js'
import * as fs from 'fs'

View File

@@ -99,16 +99,16 @@ export class XTermFrontend extends Frontend {
this.resizeHandler = () => {
try {
if (this.xterm.element && getComputedStyle(this.xterm.element).getPropertyValue('height') !== 'auto') {
let t = window.getComputedStyle(this.xterm.element.parentElement!)
let r = parseInt(t.getPropertyValue('height'))
let n = Math.max(0, parseInt(t.getPropertyValue('width')))
let o = window.getComputedStyle(this.xterm.element)
let i = r - (parseInt(o.getPropertyValue('padding-top')) + parseInt(o.getPropertyValue('padding-bottom')))
let l = n - (parseInt(o.getPropertyValue('padding-right')) + parseInt(o.getPropertyValue('padding-left'))) - this.xtermCore.viewport.scrollBarWidth
let actualCellWidth = this.xtermCore._renderService.dimensions.actualCellWidth || 9
let actualCellHeight = this.xtermCore._renderService.dimensions.actualCellHeight || 17
let cols = Math.floor(l / actualCellWidth)
let rows = Math.floor(i / actualCellHeight)
const t = window.getComputedStyle(this.xterm.element.parentElement!)
const r = parseInt(t.getPropertyValue('height'))
const n = Math.max(0, parseInt(t.getPropertyValue('width')))
const o = window.getComputedStyle(this.xterm.element)
const i = r - (parseInt(o.getPropertyValue('padding-top')) + parseInt(o.getPropertyValue('padding-bottom')))
const l = n - (parseInt(o.getPropertyValue('padding-right')) + parseInt(o.getPropertyValue('padding-left'))) - this.xtermCore.viewport.scrollBarWidth
const actualCellWidth = this.xtermCore._renderService.dimensions.actualCellWidth || 9
const actualCellHeight = this.xtermCore._renderService.dimensions.actualCellHeight || 17
const cols = Math.floor(l / actualCellWidth)
const rows = Math.floor(i / actualCellHeight)
if (!isNaN(cols) && !isNaN(rows)) {
this.xterm.resize(cols, rows)

View File

@@ -171,7 +171,7 @@ export default class TerminalModule { // eslint-disable-line @typescript-eslint/
argv = argv.slice(1)
}
if(require('yargs').parse(argv.slice(1))._[0] !== 'open'){
if (require('yargs').parse(argv.slice(1))._[0] !== 'open'){
app.ready$.subscribe(() => {
terminal.openTab()
})

View File

@@ -267,7 +267,7 @@ export class Session extends BaseSession {
return null
}
if (process.platform === 'darwin') {
let lines: string[]
let lines: string[] = []
try {
lines = (await exec(`lsof -p ${this.truePID} -Fn`))[0].toString().split('\n')
} catch (e) {
@@ -312,7 +312,7 @@ export class Session extends BaseSession {
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 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()

View File

@@ -1,3 +1,4 @@
import { MenuItemConstructorOptions } from 'electron'
import { Injectable, NgZone, Optional, Inject } from '@angular/core'
import { ToastrService } from 'ngx-toastr'
import { ConfigService, BaseTabComponent, TabContextMenuItemProvider, TabHeaderComponent, SplitTabComponent } from 'terminus-core'
@@ -18,11 +19,11 @@ export class SaveAsProfileContextMenu extends TabContextMenuItemProvider {
super()
}
async getItems (tab: BaseTabComponent, _tabHeader?: TabHeaderComponent): Promise<Electron.MenuItemConstructorOptions[]> {
async getItems (tab: BaseTabComponent, _tabHeader?: TabHeaderComponent): Promise<MenuItemConstructorOptions[]> {
if (!(tab instanceof TerminalTabComponent)) {
return []
}
const items: Electron.MenuItemConstructorOptions[] = [
const items: MenuItemConstructorOptions[] = [
{
label: 'Save as profile',
click: () => this.zone.run(async () => {
@@ -61,10 +62,10 @@ export class NewTabContextMenu extends TabContextMenuItemProvider {
super()
}
async getItems (tab: BaseTabComponent, tabHeader?: TabHeaderComponent): Promise<Electron.MenuItemConstructorOptions[]> {
async getItems (tab: BaseTabComponent, tabHeader?: TabHeaderComponent): Promise<MenuItemConstructorOptions[]> {
const profiles = await this.terminalService.getProfiles()
const items: Electron.MenuItemConstructorOptions[] = [
const items: MenuItemConstructorOptions[] = [
{
label: 'New terminal',
click: () => this.zone.run(() => {
@@ -138,7 +139,7 @@ export class CopyPasteContextMenu extends TabContextMenuItemProvider {
super()
}
async getItems (tab: BaseTabComponent, tabHeader?: TabHeaderComponent): Promise<Electron.MenuItemConstructorOptions[]> {
async getItems (tab: BaseTabComponent, tabHeader?: TabHeaderComponent): Promise<MenuItemConstructorOptions[]> {
if (tabHeader) {
return []
}
@@ -178,12 +179,12 @@ export class LegacyContextMenu extends TabContextMenuItemProvider {
super()
}
async getItems (tab: BaseTabComponent, _tabHeader?: TabHeaderComponent): Promise<Electron.MenuItemConstructorOptions[]> {
async getItems (tab: BaseTabComponent, _tabHeader?: TabHeaderComponent): Promise<MenuItemConstructorOptions[]> {
if (!this.contextMenuProviders) {
return []
}
if (tab instanceof BaseTerminalTabComponent) {
let items: Electron.MenuItemConstructorOptions[] = []
let items: MenuItemConstructorOptions[] = []
for (const p of this.contextMenuProviders) {
items = items.concat(await p.getItems(tab))
}