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-core",
"version": "1.0.104-nightly.0",
"version": "1.0.123-nightly.0",
"description": "Terminus core",
"keywords": [
"terminus-builtin-plugin"
@@ -29,11 +29,10 @@
"mixpanel": "^0.10.2",
"ng2-dnd": "^5.0.2",
"ngx-perfect-scrollbar": "^8.0.0",
"readable-stream": "^2.3.7",
"readable-stream": "2.3.7",
"shell-escape": "^0.2.0",
"uuid": "^8.0.0",
"winston": "^3.3.3",
"winston-transport": "winstonjs/winston-transport"
"winston": "^3.3.3"
},
"peerDependencies": {
"@angular/animations": "^9.1.9",

View File

@@ -1,3 +1,4 @@
import type { MenuItemConstructorOptions } from 'electron'
import { BaseTabComponent } from '../components/baseTab.component'
import { TabHeaderComponent } from '../components/tabHeader.component'
@@ -7,5 +8,5 @@ import { TabHeaderComponent } from '../components/tabHeader.component'
export abstract class TabContextMenuItemProvider {
weight = 0
abstract async getItems (tab: BaseTabComponent, tabHeader?: TabHeaderComponent): Promise<Electron.MenuItemConstructorOptions[]>
abstract async getItems (tab: BaseTabComponent, tabHeader?: TabHeaderComponent): Promise<MenuItemConstructorOptions[]>
}

View File

@@ -1,4 +1,5 @@
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import type { MenuItemConstructorOptions } from 'electron'
import { Component, Input, Optional, Inject, HostBinding, HostListener, ViewChild, ElementRef } from '@angular/core'
import { SortableComponent } from 'ng2-dnd'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
@@ -13,7 +14,7 @@ import { ConfigService } from '../services/config.service'
/** @hidden */
export interface SortableComponentProxy {
setDragHandle (_: HTMLElement)
setDragHandle: (_: HTMLElement) => void
}
/** @hidden */
@@ -71,8 +72,8 @@ export class TabHeaderComponent {
}).catch(() => null)
}
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.tab, this)))) {
items.push({ type: 'separator' })
items = items.concat(section)

View File

@@ -38,7 +38,6 @@ import { CoreConfigProvider } from './config'
import { AppHotkeyProvider } from './hotkeys'
import { TaskCompletionContextMenu, CommonOptionsContextMenu, TabManagementContextMenu } from './tabContextMenu'
//import 'ngx-perfect-scrollbar/dist/lib/perfect-scrollbar.component.css'
import 'perfect-scrollbar/css/perfect-scrollbar.css'
import 'ng2-dnd/bundles/style.css'

View File

@@ -97,7 +97,7 @@ export class ConfigService {
private changed = new Subject<void>()
private _store: any
private defaults: any
private servicesCache: { [id: string]: Function[] }|null = null
private servicesCache: Record<string, Function[]>|null = null // eslint-disable-line @typescript-eslint/ban-types
get changed$ (): Observable<void> { return this.changed }
@@ -189,7 +189,7 @@ export class ConfigService {
*
* @typeparam T Base provider type
*/
enabledServices<T extends object> (services: T[]): T[] {
enabledServices<T extends object> (services: T[]): T[] { // eslint-disable-line @typescript-eslint/ban-types
if (!this.servicesCache) {
this.servicesCache = {}
const ngModule = window['rootModule'].ɵinj

View File

@@ -1,3 +1,4 @@
import type { Display } from 'electron'
import { Injectable } from '@angular/core'
import { ConfigService } from '../services/config.service'
import { ElectronService } from '../services/electron.service'
@@ -11,8 +12,8 @@ export class DockingService {
private config: ConfigService,
private hostApp: HostAppService,
) {
electron.screen.on('display-removed', () => this.repositionWindow())
electron.screen.on('display-metrics-changed', () => this.repositionWindow())
hostApp.displaysChanged$.subscribe(() => this.repositionWindow())
hostApp.displayMetricsChanged$.subscribe(() => this.repositionWindow())
}
dock (): void {
@@ -61,11 +62,11 @@ export class DockingService {
})
}
getCurrentScreen (): Electron.Display {
getCurrentScreen (): Display {
return this.electron.screen.getDisplayNearestPoint(this.electron.screen.getCursorScreenPoint())
}
getScreens (): Electron.Display[] {
getScreens (): 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
@@ -73,7 +74,7 @@ export class DockingService {
return {
...display,
id: display.id,
name: display.id === primaryDisplayID ? 'Primary Display' : `Display ${index +1}`,
name: display.id === primaryDisplayID ? 'Primary Display' : `Display ${index + 1}`,
}
})
}

View File

@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core'
import { TouchBar, BrowserWindow, Menu, MenuItem, NativeImage } from 'electron'
import { App, IpcRenderer, Shell, Dialog, Clipboard, GlobalShortcut, Screen, Remote, AutoUpdater, TouchBar, BrowserWindow, Menu, MenuItem, NativeImage, MessageBoxOptions } from 'electron'
export interface MessageBoxResponse {
response: number
@@ -8,16 +8,16 @@ export interface MessageBoxResponse {
@Injectable({ providedIn: 'root' })
export class ElectronService {
app: Electron.App
ipcRenderer: Electron.IpcRenderer
shell: Electron.Shell
dialog: Electron.Dialog
clipboard: Electron.Clipboard
globalShortcut: Electron.GlobalShortcut
app: App
ipcRenderer: IpcRenderer
shell: Shell
dialog: Dialog
clipboard: Clipboard
globalShortcut: GlobalShortcut
nativeImage: typeof NativeImage
screen: Electron.Screen
remote: Electron.Remote
autoUpdater: Electron.AutoUpdater
screen: Screen
remote: Remote
autoUpdater: AutoUpdater
TouchBar: typeof TouchBar
BrowserWindow: typeof BrowserWindow
Menu: typeof Menu
@@ -44,8 +44,8 @@ export class ElectronService {
}
async showMessageBox (
browserWindow: Electron.BrowserWindow,
options: Electron.MessageBoxOptions
browserWindow: BrowserWindow,
options: MessageBoxOptions
): Promise<MessageBoxResponse> {
return this.dialog.showMessageBox(browserWindow, options)
}

View File

@@ -58,7 +58,7 @@ export class HomeBaseService {
getAnalyticsProperties (): Record<string, string> {
return {
distinct_id: window.localStorage.analyticsUserID, // eslint-disable-line @typescript-eslint/camelcase
distinct_id: window.localStorage.analyticsUserID,
platform: process.platform,
os: os.release(),
version: this.appVersion,

View File

@@ -1,3 +1,4 @@
import type { BrowserWindow, TouchBar, MenuItemConstructorOptions } from 'electron'
import * as path from 'path'
import shellEscape from 'shell-escape'
import { Observable, Subject } from 'rxjs'
@@ -42,6 +43,7 @@ export class HostAppService {
private windowMoved = new Subject<void>()
private windowFocused = new Subject<void>()
private displayMetricsChanged = new Subject<void>()
private displaysChanged = new Subject<void>()
private logger: Logger
private windowId: number
@@ -91,6 +93,8 @@ export class HostAppService {
get displayMetricsChanged$ (): Observable<void> { return this.displayMetricsChanged }
get displaysChanged$ (): Observable<void> { return this.displaysChanged }
private constructor (
private zone: NgZone,
private electron: ElectronService,
@@ -140,6 +144,10 @@ export class HostAppService {
this.zone.run(() => this.displayMetricsChanged.next())
})
electron.ipcRenderer.on('host:displays-changed', () => {
this.zone.run(() => this.displaysChanged.next())
})
electron.ipcRenderer.on('host:second-instance', (_$event, argv: any, cwd: string) => this.zone.run(() => {
this.logger.info('Second instance', argv)
const op = argv._[0]
@@ -177,8 +185,8 @@ export class HostAppService {
/**
* Returns the current remote [[BrowserWindow]]
*/
getWindow (): Electron.BrowserWindow {
return this.electron.BrowserWindow.fromId(this.windowId)
getWindow (): BrowserWindow {
return this.electron.BrowserWindow.fromId(this.windowId)!
}
newWindow (): void {
@@ -239,11 +247,11 @@ export class HostAppService {
this.electron.ipcRenderer.send('window-set-title', title)
}
setTouchBar (touchBar: Electron.TouchBar): void {
setTouchBar (touchBar: TouchBar): void {
this.getWindow().setTouchBar(touchBar)
}
popupContextMenu (menuDefinition: Electron.MenuItemConstructorOptions[]): void {
popupContextMenu (menuDefinition: MenuItemConstructorOptions[]): void {
this.electron.Menu.buildFromTemplate(menuDefinition).popup({})
}

View File

@@ -28,7 +28,7 @@ const initializeWinston = (electron: ElectronService) => {
export class Logger {
constructor (
private winstonLogger: any,
private winstonLogger: winston.Logger,
private name: string,
) {}
@@ -62,7 +62,7 @@ export class Logger {
@Injectable({ providedIn: 'root' })
export class LogService {
private log: any
private log: winston.Logger
/** @hidden */
private constructor (electron: ElectronService) {

View File

@@ -73,10 +73,10 @@ export class ShellIntegrationService {
wnr.setRegistryValue(wnr.HK.CU, registryKey.path + '\\command', '', wnr.REG.SZ, exe + ' ' + registryKey.command)
}
if(wnr.getRegistryKey(wnr.HK.CU, 'Software\\Classes\\Directory\\Background\\shell\\Open Terminus here')) {
if (wnr.getRegistryKey(wnr.HK.CU, 'Software\\Classes\\Directory\\Background\\shell\\Open Terminus here')) {
wnr.deleteRegistryKey(wnr.HK.CU, 'Software\\Classes\\Directory\\Background\\shell\\Open Terminus here')
}
if(wnr.getRegistryKey(wnr.HK.CU, 'Software\\Classes\\*\\shell\\Paste path into Terminus')) {
if (wnr.getRegistryKey(wnr.HK.CU, 'Software\\Classes\\*\\shell\\Paste path into Terminus')) {
wnr.deleteRegistryKey(wnr.HK.CU, 'Software\\Classes\\*\\shell\\Paste path into Terminus')
}
}

View File

@@ -1,5 +1,5 @@
import { NativeImage, SegmentedControlSegment, TouchBarSegmentedControl } from 'electron'
import { Injectable, Inject, NgZone } from '@angular/core'
import { TouchBarSegmentedControl, SegmentedControlSegment } from 'electron'
import { AppService } from './app.service'
import { ConfigService } from './config.service'
import { ElectronService } from './electron.service'
@@ -12,7 +12,7 @@ export class TouchbarService {
private tabsSegmentedControl: TouchBarSegmentedControl
private buttonsSegmentedControl: TouchBarSegmentedControl
private tabSegments: SegmentedControlSegment[] = []
private nsImageCache: {[id: string]: Electron.NativeImage} = {}
private nsImageCache: {[id: string]: NativeImage} = {}
private constructor (
private app: AppService,
@@ -100,7 +100,7 @@ export class TouchbarService {
this.hostApp.setTouchBar(touchBar)
}
private getButton (button: ToolbarButton): Electron.SegmentedControlSegment {
private getButton (button: ToolbarButton): SegmentedControlSegment {
return {
label: button.touchBarNSImage ? undefined : this.shortenTitle(button.touchBarTitle || button.title),
icon: button.touchBarNSImage ? this.getCachedNSImage(button.touchBarNSImage) : undefined,

View File

@@ -1,4 +1,5 @@
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import type { MenuItemConstructorOptions } from 'electron'
import { Injectable, NgZone } from '@angular/core'
import { Subscription } from 'rxjs'
import { AppService } from './services/app.service'
@@ -19,8 +20,8 @@ export class TabManagementContextMenu extends TabContextMenuItemProvider {
super()
}
async getItems (tab: BaseTabComponent, tabHeader?: TabHeaderComponent): Promise<Electron.MenuItemConstructorOptions[]> {
let items: Electron.MenuItemConstructorOptions[] = [
async getItems (tab: BaseTabComponent, tabHeader?: TabHeaderComponent): Promise<MenuItemConstructorOptions[]> {
let items: MenuItemConstructorOptions[] = [
{
label: 'Close',
click: () => this.zone.run(() => {
@@ -75,7 +76,7 @@ export class TabManagementContextMenu extends TabContextMenuItemProvider {
click: () => this.zone.run(() => {
(tab.parent as SplitTabComponent).splitTab(tab, dir)
}),
})) as Electron.MenuItemConstructorOptions[],
})) as MenuItemConstructorOptions[],
})
}
}
@@ -105,8 +106,8 @@ export class CommonOptionsContextMenu extends TabContextMenuItemProvider {
super()
}
async getItems (tab: BaseTabComponent, tabHeader?: TabHeaderComponent): Promise<Electron.MenuItemConstructorOptions[]> {
let items: Electron.MenuItemConstructorOptions[] = []
async getItems (tab: BaseTabComponent, tabHeader?: TabHeaderComponent): Promise<MenuItemConstructorOptions[]> {
let items: MenuItemConstructorOptions[] = []
if (tabHeader) {
items = [
...items,
@@ -128,7 +129,7 @@ export class CommonOptionsContextMenu extends TabContextMenuItemProvider {
click: () => this.zone.run(() => {
tab.color = color.value
}),
})) as Electron.MenuItemConstructorOptions[],
})) as MenuItemConstructorOptions[],
},
]
}
@@ -146,9 +147,9 @@ export class TaskCompletionContextMenu extends TabContextMenuItemProvider {
super()
}
async getItems (tab: BaseTabComponent): Promise<Electron.MenuItemConstructorOptions[]> {
async getItems (tab: BaseTabComponent): Promise<MenuItemConstructorOptions[]> {
const process = await tab.getCurrentProcess()
let items: Electron.MenuItemConstructorOptions[] = []
const items: MenuItemConstructorOptions[] = []
const extTab: (BaseTabComponent & { __completionNotificationEnabled?: boolean, __outputNotificationSubscription?: Subscription|null }) = tab

View File

@@ -349,7 +349,7 @@ process-nextick-args@~2.0.0:
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2"
integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==
readable-stream@^2.3.7:
readable-stream@2.3.7, readable-stream@^2.3.7:
version "2.3.7"
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.7.tgz#1eca1cf711aef814c04f62252a36a62f6cb23b57"
integrity sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==
@@ -470,14 +470,6 @@ winston-transport@^4.4.0:
readable-stream "^2.3.7"
triple-beam "^1.2.0"
winston-transport@winstonjs/winston-transport:
version "4.4.0"
resolved "https://codeload.github.com/winstonjs/winston-transport/tar.gz/6a3bf79175288328d37c6cf4121d6b39eb68f19f"
dependencies:
logform "^2.2.0"
readable-stream "^3.4.0"
triple-beam "^1.2.0"
winston@*, winston@^3.3.3:
version "3.3.3"
resolved "https://registry.yarnpkg.com/winston/-/winston-3.3.3.tgz#ae6172042cafb29786afa3d09c8ff833ab7c9170"