Skip to content

Commit

Permalink
upgraded to electron 29
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugeny committed Aug 3, 2024
1 parent f523b11 commit 3f0b78e
Show file tree
Hide file tree
Showing 13 changed files with 145 additions and 122 deletions.
2 changes: 2 additions & 0 deletions app/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ try {
app.exit(1)
}

process.mainModule = module

const application = new Application(configStore)

ipcMain.on('app:new-window', () => {
Expand Down
107 changes: 59 additions & 48 deletions app/lib/window.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as glasstron from 'glasstron'

import { autoUpdater } from 'electron-updater'
import { Subject, Observable, debounceTime } from 'rxjs'
import { BrowserWindow, app, ipcMain, Rectangle, Menu, screen, BrowserWindowConstructorOptions, TouchBar, nativeImage, WebContents } from 'electron'
import ElectronConfig = require('electron-config')
Expand Down Expand Up @@ -159,6 +159,7 @@ export class Window {
}

this.setupWindowManagement()
this.setupUpdater()

this.ready = new Promise(resolve => {
const listener = event => {
Expand Down Expand Up @@ -346,11 +347,8 @@ export class Window {
this.send('host:window-focused')
})

ipcMain.on('ready', event => {
if (!this.window || event.sender !== this.window.webContents) {
return
}
this.window.webContents.send('start', {
this.on('ready', () => {
this.window?.webContents.send('start', {
config: this.configStore,
executable: app.getPath('exe'),
windowID: this.window.id,
Expand All @@ -359,42 +357,26 @@ export class Window {
})
})

ipcMain.on('window-minimize', event => {
if (!this.window || event.sender !== this.window.webContents) {
return
}
this.window.minimize()
this.on('window-minimize', () => {
this.window?.minimize()
})

ipcMain.on('window-set-bounds', (event, bounds) => {
if (!this.window || event.sender !== this.window.webContents) {
return
}
this.window.setBounds(bounds)
this.on('window-set-bounds', (_, bounds) => {
this.window?.setBounds(bounds)
})

ipcMain.on('window-set-always-on-top', (event, flag) => {
if (!this.window || event.sender !== this.window.webContents) {
return
}
this.window.setAlwaysOnTop(flag)
this.on('window-set-always-on-top', (_, flag) => {
this.window?.setAlwaysOnTop(flag)
})

ipcMain.on('window-set-vibrancy', (event, enabled, type) => {
if (!this.window || event.sender !== this.window.webContents) {
return
}
this.on('window-set-vibrancy', (_, enabled, type) => {
this.setVibrancy(enabled, type)
})

ipcMain.on('window-set-window-controls-color', (event, theme) => {
if (!this.window || event.sender !== this.window.webContents) {
return
}

this.on('window-set-window-controls-color', (_, theme) => {
if (process.platform === 'win32') {
const symbolColor: string = theme.foreground
this.window.setTitleBarOverlay(
this.window?.setTitleBarOverlay(
{
symbolColor: symbolColor,
height: 32,
Expand All @@ -403,32 +385,23 @@ export class Window {
}
})

ipcMain.on('window-set-title', (event, title) => {
if (!this.window || event.sender !== this.window.webContents) {
return
}
this.window.setTitle(title)
this.on('window-set-title', (_, title) => {
this.window?.setTitle(title)
})

ipcMain.on('window-bring-to-front', event => {
if (!this.window || event.sender !== this.window.webContents) {
return
}
if (this.window.isMinimized()) {
this.on('window-bring-to-front', () => {
if (this.window?.isMinimized()) {
this.window.restore()
}
this.present()
})

ipcMain.on('window-close', event => {
if (!this.window || event.sender !== this.window.webContents) {
return
}
this.on('window-close', () => {
this.closing = true
this.window.close()
})

ipcMain.on('window-set-touch-bar', (_event, segments, selectedIndex) => {
this.on('window-set-touch-bar', (_, segments, selectedIndex) => {
this.touchBarControl.segments = segments.map(s => ({
label: s.label,
icon: s.hasActivity ? activityIcon : undefined,
Expand Down Expand Up @@ -468,8 +441,46 @@ export class Window {
this.window.setOpacity(opacity)
})

ipcMain.on('window-set-progress-bar', (_event, value) => {
this.window.setProgressBar(value, { mode: value < 0 ? 'none' : 'normal' })
this.on('window-set-progress-bar', (_, value) => {
this.window?.setProgressBar(value, { mode: value < 0 ? 'none' : 'normal' })
})
}

on (event: string, listener: (...args: any[]) => void): void {
ipcMain.on(event, (e, ...args) => {
if (!this.window || e.sender !== this.window.webContents) {
return
}
listener(e, ...args)
})
}

private setupUpdater () {
autoUpdater.autoDownload = true
autoUpdater.autoInstallOnAppQuit = true

autoUpdater.on('update-available', () => {
this.send('updater:update-available')
})

autoUpdater.on('update-not-available', () => {
this.send('updater:update-not-available')
})

autoUpdater.on('error', err => {
this.send('updater:error', err)
})

autoUpdater.on('update-downloaded', () => {
this.send('updater:update-downloaded')
})

this.on('updater:check-for-updates', () => {
autoUpdater.checkForUpdates()
})

this.on('updater:quit-and-install', () => {
autoUpdater.quitAndInstall()
})
}

Expand Down
7 changes: 3 additions & 4 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"watch": "webpack --progress --color --watch"
},
"dependencies": {
"@electron/remote": "2.0.10",
"@electron/remote": "^2",
"node-pty": "^1.0",
"any-promise": "^1.3.0",
"electron-config": "2.0.0",
Expand Down Expand Up @@ -63,8 +63,7 @@
"tabby-terminal": "*"
},
"resolutions": {
"*/node-abi": "^2.20.0",
"node-gyp": "^10.0.0",
"nan": "github:jkleinsc/nan#remove_accessor_signature"
"*/node-abi": "^3",
"node-gyp": "^10.0.0"
}
}
1 change: 1 addition & 0 deletions app/webpack.config.main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const config = {
'electron-config': 'commonjs electron-config',
'electron-debug': 'commonjs electron-debug',
'electron-promise-ipc': 'commonjs electron-promise-ipc',
'electron-updater': 'commonjs electron-updater',
fs: 'commonjs fs',
glasstron: 'commonjs glasstron',
mz: 'commonjs mz',
Expand Down
28 changes: 16 additions & 12 deletions app/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# yarn lockfile v1


"@electron/remote@2.0.10":
version "2.0.10"
resolved "https://registry.yarnpkg.com/@electron/remote/-/remote-2.0.10.tgz#133e2f607b1861ac249bd78b5abd1e961feed713"
integrity sha512-3SFKKaQXcyWgwmibud+UqJl/XlHOgLcI3fwtB9pNelPSJAcTxocOJrF6FaxBIQaj1+R05Di6xuAswZpXAW7xhA==
"@electron/remote@^2":
version "2.1.2"
resolved "https://registry.yarnpkg.com/@electron/remote/-/remote-2.1.2.tgz#52a97c8faa5b769155b649ef262f2f8c851776e6"
integrity sha512-EPwNx+nhdrTBxyCqXt/pftoQg/ybtWDW3DUWHafejvnB1ZGGfMpv6e15D8KeempocjXe78T7WreyGGb3mlZxdA==

"@iarna/cli@^1.2.0":
version "1.2.0"
Expand Down Expand Up @@ -2577,9 +2577,10 @@ mz@^2.7.0:
object-assign "^4.0.1"
thenify-all "^1.0.0"

nan@^2.17.0, "nan@github:jkleinsc/nan#remove_accessor_signature":
version "2.16.0"
resolved "https://codeload.github.com/jkleinsc/nan/tar.gz/6a2f95a6a2209d8aa7542fb18099fd808a802059"
nan@^2.17.0:
version "2.20.0"
resolved "https://registry.yarnpkg.com/nan/-/nan-2.20.0.tgz#08c5ea813dd54ed16e5bd6505bf42af4f7838ca3"
integrity sha512-bk3gXBZDGILuuo/6sKtr0DQmSThYHLtNCdSdXk9YkxD/jK6X2vmCyyXBBxyqZ4XcnzTyYEAThfX3DCEnLf6igw==

napi-build-utils@^1.0.1:
version "1.0.2"
Expand Down Expand Up @@ -2610,12 +2611,12 @@ nice-try@^1.0.4:
resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366"
integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==

node-abi@^2.20.0:
version "2.30.1"
resolved "https://registry.yarnpkg.com/node-abi/-/node-abi-2.30.1.tgz#c437d4b1fe0e285aaf290d45b45d4d7afedac4cf"
integrity sha512-/2D0wOQPgaUWzVSVgRMx+trKJRC2UG4SUc4oCJoXx9Uxjtp0Vy3/kt7zcbxHF8+Z/pK3UloLWzBISg72brfy1w==
node-abi@^3:
version "3.65.0"
resolved "https://registry.yarnpkg.com/node-abi/-/node-abi-3.65.0.tgz#ca92d559388e1e9cab1680a18c1a18757cdac9d3"
integrity sha512-ThjYBfoDNr08AWx6hGaRbfPwxKV9kVzAzOzlLKbk2CuqXE2xnCh+cbAGnwM3t8Lq4v9rUB7VfondlkBckcJrVA==
dependencies:
semver "^5.4.1"
semver "^7.3.5"

node-abi@^3.3.0:
version "3.8.0"
Expand Down Expand Up @@ -3909,6 +3910,7 @@ strict-uri-encode@^2.0.0:
integrity sha1-ucczDHBChi9rFC3CdLvMWGbONUY=

"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
name string-width-cjs
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand Down Expand Up @@ -3986,6 +3988,7 @@ stringify-package@^1.0.0, stringify-package@^1.0.1:
integrity sha512-sa4DUQsYciMP1xhKWGuFM04fB0LG/9DlluZoSVywUMRNvzid6XucHK0/90xGxRoHrAaROrcHK1aPKaijCtSrhg==

"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.1:
name strip-ansi-cjs
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
Expand Down Expand Up @@ -4432,6 +4435,7 @@ worker-farm@^1.6.0, worker-farm@^1.7.0:
errno "~0.1.7"

"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
name wrap-ansi-cjs
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"cross-env": "7.0.3",
"css-loader": "^6.7.3",
"deep-equal": "2.0.5",
"electron": "^27.0.4",
"electron": "^29",
"electron-builder": "^24.6.4",
"electron-download": "^4.1.1",
"electron-installer-snap": "^5.1.0",
Expand All @@ -55,7 +55,7 @@
"lru-cache": "^6.0.0",
"macos-release": "^3.1.0",
"ngx-toastr": "^16.0.2",
"node-abi": "^3.51.0",
"node-abi": "^3.65.0",
"npmlog": "6.0.2",
"npx": "^10.2.2",
"patch-package": "^6.4.7",
Expand Down
File renamed without changes.
2 changes: 0 additions & 2 deletions tabby-electron/src/services/electron.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export class ElectronService {
clipboard: Clipboard
globalShortcut: GlobalShortcut
screen: Screen
remote = remote
process: any
autoUpdater: AutoUpdater
powerSaveBlocker: PowerSaveBlocker
Expand Down Expand Up @@ -44,7 +43,6 @@ export class ElectronService {
this.BrowserWindow = remote.BrowserWindow
this.Menu = remote.Menu
this.MenuItem = remote.MenuItem
this.MenuItem = remote.MenuItem
this.nativeTheme = remote.nativeTheme
}
}
Loading

0 comments on commit 3f0b78e

Please sign in to comment.