mirror of
https://github.com/Eugeny/tabby.git
synced 2025-07-20 02:18:01 +00:00
electron 11 cleanup
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
import { app, ipcMain, Menu, Tray, shell, globalShortcut } from 'electron'
|
||||
// eslint-disable-next-line no-duplicate-imports
|
||||
import * as electron from 'electron'
|
||||
import { app, ipcMain, Menu, Tray, shell, screen, globalShortcut, MenuItemConstructorOptions } from 'electron'
|
||||
import { loadConfig } from './config'
|
||||
import { Window, WindowOptions } from './window'
|
||||
|
||||
@@ -15,7 +13,7 @@ export class Application {
|
||||
|
||||
ipcMain.on('app:register-global-hotkey', (_event, specs) => {
|
||||
globalShortcut.unregisterAll()
|
||||
for (let spec of specs) {
|
||||
for (const spec of specs) {
|
||||
globalShortcut.register(spec, () => {
|
||||
this.onGlobalHotkey()
|
||||
})
|
||||
@@ -41,11 +39,13 @@ export class Application {
|
||||
}
|
||||
|
||||
init (): void {
|
||||
electron.screen.on('display-metrics-changed', () => this.broadcast('host:display-metrics-changed'))
|
||||
screen.on('display-metrics-changed', () => this.broadcast('host:display-metrics-changed'))
|
||||
screen.on('display-added', () => this.broadcast('host:displays-changed'))
|
||||
screen.on('display-removed', () => this.broadcast('host:displays-changed'))
|
||||
}
|
||||
|
||||
async newWindow (options?: WindowOptions): Promise<Window> {
|
||||
let window = new Window(options)
|
||||
const window = new Window(options)
|
||||
this.windows.push(window)
|
||||
window.visible$.subscribe(visible => {
|
||||
if (visible) {
|
||||
@@ -66,29 +66,29 @@ export class Application {
|
||||
|
||||
onGlobalHotkey (): void {
|
||||
if (this.windows.some(x => x.isFocused())) {
|
||||
for (let window of this.windows) {
|
||||
for (const window of this.windows) {
|
||||
window.hide()
|
||||
}
|
||||
} else {
|
||||
for (let window of this.windows) {
|
||||
for (const window of this.windows) {
|
||||
window.present()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
presentAllWindows (): void {
|
||||
for (let window of this.windows) {
|
||||
for (const window of this.windows) {
|
||||
window.present()
|
||||
}
|
||||
}
|
||||
|
||||
broadcast (event: string, ...args): void {
|
||||
broadcast (event: string, ...args: any[]): void {
|
||||
for (const window of this.windows) {
|
||||
window.send(event, ...args)
|
||||
}
|
||||
}
|
||||
|
||||
async send (event: string, ...args): Promise<void> {
|
||||
async send (event: string, ...args: any[]): Promise<void> {
|
||||
if (!this.hasWindows()) {
|
||||
await this.newWindow()
|
||||
}
|
||||
@@ -132,7 +132,7 @@ export class Application {
|
||||
}
|
||||
|
||||
focus (): void {
|
||||
for (let window of this.windows) {
|
||||
for (const window of this.windows) {
|
||||
window.show()
|
||||
}
|
||||
}
|
||||
@@ -143,7 +143,7 @@ export class Application {
|
||||
}
|
||||
|
||||
private setupMenu () {
|
||||
let template: Electron.MenuItemConstructorOptions[] = [
|
||||
const template: MenuItemConstructorOptions[] = [
|
||||
{
|
||||
label: 'Application',
|
||||
submenu: [
|
||||
|
@@ -4,7 +4,7 @@ import * as yaml from 'js-yaml'
|
||||
import { app } from 'electron'
|
||||
|
||||
export function loadConfig (): any {
|
||||
let configPath = path.join(app.getPath('userData'), 'config.yaml')
|
||||
const configPath = path.join(app.getPath('userData'), 'config.yaml')
|
||||
if (fs.existsSync(configPath)) {
|
||||
return yaml.safeLoad(fs.readFileSync(configPath, 'utf8'))
|
||||
} else {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import * as createLRU from 'lru-cache'
|
||||
import * as LRU from 'lru-cache'
|
||||
import * as fs from 'fs'
|
||||
const lru = new createLRU({ max: 256, maxAge: 250 })
|
||||
const lru = new LRU({ max: 256, maxAge: 250 })
|
||||
const origLstat = fs.realpathSync.bind(fs)
|
||||
|
||||
// NB: The biggest offender of thrashing realpathSync is the node module system
|
||||
|
@@ -9,7 +9,7 @@ try {
|
||||
}
|
||||
|
||||
if (null != appPath) {
|
||||
if(fs.existsSync(path.join(appPath, 'terminus-data'))) {
|
||||
if (fs.existsSync(path.join(appPath, 'terminus-data'))) {
|
||||
fs.renameSync(path.join(appPath, 'terminus-data'), path.join(appPath, 'data'))
|
||||
}
|
||||
const portableData = path.join(appPath, 'data')
|
||||
|
@@ -3,7 +3,7 @@ import * as isDev from 'electron-is-dev'
|
||||
|
||||
|
||||
const SENTRY_DSN = 'https://4717a0a7ee0b4429bd3a0f06c3d7eec3@sentry.io/181876'
|
||||
let release
|
||||
let release = null
|
||||
try {
|
||||
release = require('electron').app.getVersion()
|
||||
} catch {
|
||||
|
@@ -5,7 +5,7 @@ if (process.platform === 'win32' || process.platform === 'linux') {
|
||||
|
||||
import { Subject, Observable } from 'rxjs'
|
||||
import { debounceTime } from 'rxjs/operators'
|
||||
import { BrowserWindow, app, ipcMain, Rectangle, Menu, screen } from 'electron'
|
||||
import { BrowserWindow, app, ipcMain, Rectangle, Menu, screen, BrowserWindowConstructorOptions } from 'electron'
|
||||
import ElectronConfig = require('electron-config')
|
||||
import * as os from 'os'
|
||||
import * as path from 'path'
|
||||
@@ -13,7 +13,7 @@ import * as path from 'path'
|
||||
import { parseArgs } from './cli'
|
||||
import { loadConfig } from './config'
|
||||
|
||||
let DwmEnableBlurBehindWindow: any
|
||||
let DwmEnableBlurBehindWindow: any = null
|
||||
if (process.platform === 'win32') {
|
||||
DwmEnableBlurBehindWindow = require('windows-blurbehind').DwmEnableBlurBehindWindow
|
||||
}
|
||||
@@ -45,13 +45,13 @@ export class Window {
|
||||
this.windowConfig = new ElectronConfig({ name: 'window' })
|
||||
this.windowBounds = this.windowConfig.get('windowBoundaries')
|
||||
|
||||
let maximized = this.windowConfig.get('maximized')
|
||||
let bwOptions: Electron.BrowserWindowConstructorOptions = {
|
||||
const maximized = this.windowConfig.get('maximized')
|
||||
const bwOptions: BrowserWindowConstructorOptions = {
|
||||
width: 800,
|
||||
height: 600,
|
||||
title: 'Terminus',
|
||||
minWidth: 400,
|
||||
minHeight: 300,
|
||||
minHeight: 300,
|
||||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
preload: path.join(__dirname, 'sentry.js'),
|
||||
@@ -139,7 +139,7 @@ export class Window {
|
||||
} else {
|
||||
DwmEnableBlurBehindWindow(this.window, enabled)
|
||||
}
|
||||
} else if (process.platform ==='linux') {
|
||||
} else if (process.platform === 'linux') {
|
||||
glasstron.update(this.window, {
|
||||
linux: { requestBlur: enabled },
|
||||
})
|
||||
@@ -158,7 +158,7 @@ export class Window {
|
||||
this.window.focus()
|
||||
}
|
||||
|
||||
send (event: string, ...args): void {
|
||||
send (event: string, ...args: any[]): void {
|
||||
if (!this.window) {
|
||||
return
|
||||
}
|
||||
@@ -225,7 +225,7 @@ export class Window {
|
||||
this.visible.next(false)
|
||||
})
|
||||
|
||||
let moveSubscription = new Observable<void>(observer => {
|
||||
const moveSubscription = new Observable<void>(observer => {
|
||||
this.window.on('move', () => observer.next())
|
||||
}).pipe(debounceTime(250)).subscribe(() => {
|
||||
this.send('host:window-moved')
|
||||
|
@@ -21,8 +21,7 @@
|
||||
"@angular/platform-browser": "^9.1.9",
|
||||
"@angular/platform-browser-dynamic": "^9.1.9",
|
||||
"@ng-bootstrap/ng-bootstrap": "^6.1.0",
|
||||
"@terminus-term/node-pty": "0.10.0-beta9",
|
||||
"devtron": "1.4.0",
|
||||
"@terminus-term/node-pty": "0.10.0-beta10",
|
||||
"electron-config": "2.0.0",
|
||||
"electron-debug": "^3.0.1",
|
||||
"electron-is-dev": "1.1.0",
|
||||
@@ -30,18 +29,12 @@
|
||||
"glasstron": "AryToNeX/Glasstron#dependabot/npm_and_yarn/electron-11.1.0",
|
||||
"js-yaml": "3.14.0",
|
||||
"keytar": "^7.2.0",
|
||||
"macos-native-processlist": "^2.0.0",
|
||||
"mz": "^2.7.0",
|
||||
"ngx-toastr": "^12.0.1",
|
||||
"node-gyp": "^7.1.2",
|
||||
"npm": "7.0.15",
|
||||
"path": "0.12.7",
|
||||
"rxjs": "^6.5.5",
|
||||
"rxjs-compat": "^6.6.0",
|
||||
"serialport": "^9.0.4",
|
||||
"windows-blurbehind": "^1.0.1",
|
||||
"windows-native-registry": "^3.0.0",
|
||||
"windows-process-tree": "^0.2.4",
|
||||
"yargs": "^15.4.1",
|
||||
"zone.js": "^0.11.3"
|
||||
},
|
||||
@@ -55,15 +48,15 @@
|
||||
"devDependencies": {
|
||||
"@types/mz": "0.0.32",
|
||||
"@types/node": "14.14.14",
|
||||
"node-abi": "github:lgeiger/node-abi"
|
||||
"node-abi": "2.19.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"terminus-core": "*",
|
||||
"terminus-settings": "*",
|
||||
"terminus-serial": "*",
|
||||
"terminus-plugin-manager": "*",
|
||||
"terminus-community-color-schemes": "*",
|
||||
"terminus-core": "*",
|
||||
"terminus-plugin-manager": "*",
|
||||
"terminus-serial": "*",
|
||||
"terminus-settings": "*",
|
||||
"terminus-ssh": "*",
|
||||
"terminus-terminal": "*"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -83,7 +83,7 @@ const originalRequire = (global as any).require
|
||||
if (cachedBuiltinModules[query]) {
|
||||
return cachedBuiltinModules[query]
|
||||
}
|
||||
return originalRequire.apply(this, arguments)
|
||||
return originalRequire.apply(this, [query])
|
||||
}
|
||||
|
||||
const originalModuleRequire = nodeModule.prototype.require
|
||||
|
@@ -266,12 +266,12 @@
|
||||
dependencies:
|
||||
debug "^4.1.1"
|
||||
|
||||
"@terminus-term/node-pty@0.10.0-beta9":
|
||||
version "0.10.0-beta9"
|
||||
resolved "https://registry.npmjs.org/@terminus-term/node-pty/-/node-pty-0.10.0-beta9.tgz"
|
||||
integrity sha512-wnttx12b9gxP9CPB9uqBMQx/Vp4EboUDGOY3xRP0Nvhec6pSF2qFZD6bwMbNzFIopbaohluEYcbEul0jTQcdeQ==
|
||||
"@terminus-term/node-pty@0.10.0-beta10":
|
||||
version "0.10.0-beta10"
|
||||
resolved "https://registry.yarnpkg.com/@terminus-term/node-pty/-/node-pty-0.10.0-beta10.tgz#de9dade3d7549d44b0906ec0d0b9e1bb411f1f21"
|
||||
integrity sha512-j9RJk7sD/es4vR6+AR5M/p3SicVxY6kZEeE0UQKhHNcaAla90/mcGeBNicAWPaAkjO1uQZVbYh5cJMMu5unQgA==
|
||||
dependencies:
|
||||
nan "^2.13.2"
|
||||
nan "^2.14.0"
|
||||
|
||||
"@tootallnate/once@1":
|
||||
version "1.1.2"
|
||||
@@ -295,11 +295,6 @@ abbrev@1, abbrev@~1.1.1:
|
||||
resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz"
|
||||
integrity sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==
|
||||
|
||||
accessibility-developer-tools@^2.11.0:
|
||||
version "2.12.0"
|
||||
resolved "https://registry.npmjs.org/accessibility-developer-tools/-/accessibility-developer-tools-2.12.0.tgz"
|
||||
integrity sha1-PaDM6dbsY3OWS4TzXbfPw996tRQ=
|
||||
|
||||
agent-base@6:
|
||||
version "6.0.2"
|
||||
resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-6.0.2.tgz"
|
||||
@@ -738,15 +733,6 @@ detect-libc@^1.0.3:
|
||||
resolved "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz"
|
||||
integrity sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=
|
||||
|
||||
devtron@1.4.0:
|
||||
version "1.4.0"
|
||||
resolved "https://registry.npmjs.org/devtron/-/devtron-1.4.0.tgz"
|
||||
integrity sha1-tedIvW6Vu+cL/MaKrm/mlhGUQeE=
|
||||
dependencies:
|
||||
accessibility-developer-tools "^2.11.0"
|
||||
highlight.js "^9.3.0"
|
||||
humanize-plus "^1.8.1"
|
||||
|
||||
dezalgo@^1.0.0:
|
||||
version "1.0.3"
|
||||
resolved "https://registry.yarnpkg.com/dezalgo/-/dezalgo-1.0.3.tgz"
|
||||
@@ -1022,11 +1008,6 @@ has@^1.0.3:
|
||||
dependencies:
|
||||
function-bind "^1.1.1"
|
||||
|
||||
highlight.js@^9.3.0:
|
||||
version "9.18.5"
|
||||
resolved "https://registry.npmjs.org/highlight.js/-/highlight.js-9.18.5.tgz"
|
||||
integrity sha512-a5bFyofd/BHCX52/8i8uJkjr9DYwXIPnM/plwI6W7ezItLGqzt7X2G2nXuYSfsIJdkwwj/g9DG1LkcGJI/dDoA==
|
||||
|
||||
hosted-git-info@^3.0.6:
|
||||
version "3.0.7"
|
||||
resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-3.0.7.tgz"
|
||||
@@ -1072,11 +1053,6 @@ humanize-ms@^1.2.1:
|
||||
dependencies:
|
||||
ms "^2.0.0"
|
||||
|
||||
humanize-plus@^1.8.1:
|
||||
version "1.8.2"
|
||||
resolved "https://registry.npmjs.org/humanize-plus/-/humanize-plus-1.8.2.tgz"
|
||||
integrity sha1-pls0RZrWNnrbs3B6gqPJ+RYWcDA=
|
||||
|
||||
iconv-lite@^0.6.2:
|
||||
version "0.6.2"
|
||||
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.6.2.tgz"
|
||||
@@ -1585,9 +1561,9 @@ mz@^2.7.0:
|
||||
object-assign "^4.0.1"
|
||||
thenify-all "^1.0.0"
|
||||
|
||||
nan@^2.13.2, nan@^2.14.2:
|
||||
nan@^2.13.2, nan@^2.14.0, nan@^2.14.2:
|
||||
version "2.14.2"
|
||||
resolved "https://registry.npmjs.org/nan/-/nan-2.14.2.tgz"
|
||||
resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.2.tgz#f5376400695168f4cc694ac9393d0c9585eeea19"
|
||||
integrity sha512-M2ufzIiINKCuDfBSAUr1vWQ+vuVcA9kqx8JJUsbQi6yf1uGRyb7HfpdfUr5qLXf3B/t8dPvcjhKMmlfnP47EzQ==
|
||||
|
||||
napi-build-utils@^1.0.1:
|
||||
@@ -1602,19 +1578,13 @@ ngx-toastr@^12.0.1:
|
||||
dependencies:
|
||||
tslib "^1.10.0"
|
||||
|
||||
node-abi@^2.7.0:
|
||||
node-abi@2.19.3, node-abi@^2.7.0:
|
||||
version "2.19.3"
|
||||
resolved "https://registry.npmjs.org/node-abi/-/node-abi-2.19.3.tgz"
|
||||
integrity sha512-9xZrlyfvKhWme2EXFKQhZRp1yNWT/uI1luYPr3sFl+H4keYY4xR+1jO7mvTTijIsHf1M+QDe9uWuKeEpLInIlg==
|
||||
dependencies:
|
||||
semver "^5.4.1"
|
||||
|
||||
"node-abi@github:lgeiger/node-abi":
|
||||
version "0.0.0-development"
|
||||
resolved "https://codeload.github.com/lgeiger/node-abi/tar.gz/d7a3f00c93cb16b5f4fbb3ae8c106e798cc52042"
|
||||
dependencies:
|
||||
semver "^5.4.1"
|
||||
|
||||
node-addon-api@3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.npmjs.org/node-addon-api/-/node-addon-api-3.0.0.tgz"
|
||||
|
Reference in New Issue
Block a user