From f423a75daee1f564de9f3fdb06d7c9f9f66f8f8a Mon Sep 17 00:00:00 2001 From: Jacob Schlecht Date: Tue, 17 Mar 2026 20:34:05 -0600 Subject: [PATCH] chore: Update to electron 39 and include some fixes This commit was made without the use of generative AI. Signed-off-by: Jacob Schlecht --- package.json | 2 +- pnpm-lock.yaml | 41 +++++++++++++++++++++++++++-------------- src/native/tray.ts | 37 ++++++++++++++++++++++++++++++++++--- 3 files changed, 62 insertions(+), 18 deletions(-) diff --git a/package.json b/package.json index 94fbaf0..e9ebcb0 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "@types/electron-squirrel-startup": "^1.0.2", "@typescript-eslint/eslint-plugin": "^5.62.0", "@typescript-eslint/parser": "^5.62.0", - "electron": "38.1.2", + "electron": "^40.6.0", "eslint": "^8.57.1", "eslint-plugin-import": "^2.32.0", "json-schema-typed": "^8.0.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 567c666..56c03ed 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -85,8 +85,8 @@ importers: specifier: ^5.62.0 version: 5.62.0(eslint@8.57.1)(typescript@4.5.5) electron: - specifier: 38.1.2 - version: 38.1.2 + specifier: ^40.6.0 + version: 40.6.0 eslint: specifier: ^8.57.1 version: 8.57.1 @@ -104,7 +104,7 @@ importers: version: 4.5.5 vite: specifier: ^5.4.20 - version: 5.4.20(@types/node@24.5.2) + version: 5.4.20(@types/node@24.10.13) packages: @@ -825,6 +825,9 @@ packages: '@types/node@22.18.6': resolution: {integrity: sha512-r8uszLPpeIWbNKtvWRt/DbVi5zbqZyj1PTmhRMqBMvDnaz1QpmSKujUtJLrqGZeoM8v72MfYggDceY4K1itzWQ==} + '@types/node@24.10.13': + resolution: {integrity: sha512-oH72nZRfDv9lADUBSo104Aq7gPHpQZc4BTx38r9xf9pg5LfP6EzSyH2n7qFmmxRQXh7YlUXODcYsg6PuTDSxGg==} + '@types/node@24.5.2': resolution: {integrity: sha512-FYxk1I7wPv3K2XBaoyH2cTnocQEu8AOZ60hPbsyukMPLv5/5qr7V1i8PLHdl6Zf87I+xZXFvPCXYjiTFq+YSDQ==} @@ -1372,8 +1375,8 @@ packages: resolution: {integrity: sha512-bO3y10YikuUwUuDUQRM4KfwNkKhnpVO7IPdbsrejwN9/AABJzzTQ4GeHwyzNSrVO+tEH3/Np255a3sVZpZDjvg==} engines: {node: '>=8.0.0'} - electron@38.1.2: - resolution: {integrity: sha512-WXUcN3W8h8NTTZViA3KNX0rV2YBU0X0mEUM3ubupXTDY4QtIN7tmiqYVOKSKpR2LckTmBWGuEeY4D6xVoffwKQ==} + electron@40.6.0: + resolution: {integrity: sha512-ett8W+yOFGDuM0vhJMamYSkrbV3LoaffzJd9GfjI96zRAxyrNqUSKqBpf/WGbQCweDxX2pkUCUfrv4wwKpsFZA==} engines: {node: '>= 12.20.55'} hasBin: true @@ -1715,12 +1718,12 @@ packages: glob@7.2.3: resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==} - deprecated: Glob versions prior to v9 are no longer supported + deprecated: Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me glob@8.1.0: resolution: {integrity: sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==} engines: {node: '>=12'} - deprecated: Glob versions prior to v9 are no longer supported + deprecated: Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me global-agent@3.0.0: resolution: {integrity: sha512-PT6XReJ+D07JvGoxQMkT6qji/jVNfX/h364XHZOWeRzy64sSFr+xJ5OX7LI3b4MPQzdL4H8Y8M0xzPpsVMwA8Q==} @@ -2876,6 +2879,7 @@ packages: tar@6.2.1: resolution: {integrity: sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==} engines: {node: '>=10'} + deprecated: Old versions of tar are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me temp@0.9.4: resolution: {integrity: sha512-yYrrsWnrXMcdsnu/7YMYAofM1ktpL5By7vZhf15CrXijWWrEYZks5AXBudalfSWJLlnen/QUJUB5aoB0kqZUGA==} @@ -2983,6 +2987,9 @@ packages: undici-types@7.12.0: resolution: {integrity: sha512-goOacqME2GYyOZZfb5Lgtu+1IDmAlAEu5xnD3+xTzS10hT0vzpf0SPjkXwAw9Jm+4n/mQGDP3LO8CPbYROeBfQ==} + undici-types@7.16.0: + resolution: {integrity: sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==} + unique-filename@2.0.1: resolution: {integrity: sha512-ODWHtkkdx3IAR+veKxFV+VBkUMcN+FaqzUUd7IZzt+0zhDZFPFxhlqwPF3YQvMHx1TD0tdgYl+kuPnJ8E6ql7A==} engines: {node: ^12.13.0 || ^14.15.0 || >=16.0.0} @@ -4114,16 +4121,20 @@ snapshots: '@types/keyv@3.1.4': dependencies: - '@types/node': 24.5.2 + '@types/node': 24.10.13 '@types/mute-stream@0.0.4': dependencies: - '@types/node': 22.18.6 + '@types/node': 24.10.13 '@types/node@22.18.6': dependencies: undici-types: 6.21.0 + '@types/node@24.10.13': + dependencies: + undici-types: 7.16.0 + '@types/node@24.5.2': dependencies: undici-types: 7.12.0 @@ -4138,7 +4149,7 @@ snapshots: '@types/yauzl@2.10.3': dependencies: - '@types/node': 22.18.6 + '@types/node': 24.10.13 optional: true '@typescript-eslint/eslint-plugin@5.62.0(@typescript-eslint/parser@5.62.0(eslint@8.57.1)(typescript@4.5.5))(eslint@8.57.1)(typescript@4.5.5)': @@ -4787,10 +4798,10 @@ snapshots: - supports-color optional: true - electron@38.1.2: + electron@40.6.0: dependencies: '@electron/get': 2.0.3 - '@types/node': 22.18.6 + '@types/node': 24.10.13 extract-zip: 2.0.1 transitivePeerDependencies: - supports-color @@ -6638,6 +6649,8 @@ snapshots: undici-types@7.12.0: {} + undici-types@7.16.0: {} + unique-filename@2.0.1: dependencies: unique-slug: 3.0.0 @@ -6679,13 +6692,13 @@ snapshots: spdx-correct: 3.2.0 spdx-expression-parse: 3.0.1 - vite@5.4.20(@types/node@24.5.2): + vite@5.4.20(@types/node@24.10.13): dependencies: esbuild: 0.21.5 postcss: 8.5.6 rollup: 4.52.2 optionalDependencies: - '@types/node': 24.5.2 + '@types/node': 24.10.13 fsevents: 2.3.3 wcwidth@1.0.1: diff --git a/src/native/tray.ts b/src/native/tray.ts index 45fd6be..87a5f60 100644 --- a/src/native/tray.ts +++ b/src/native/tray.ts @@ -21,7 +21,37 @@ function createTrayIcon() { } } +// Electron 39 (wayland support) and zypak broke this old code for tray icon support. +// I don't know why, but this code is never ran in the flatpak. Code copied from +// electron/lib/browser/init.ts +function setXDGDesktop() { + // Only matters on linux + if (process.platform !== "linux") return; + // If XDG_CURRENT_DESKTOP is Unity this code has probably already run and we're not + // in a flatpak. + if (process.env.XDG_CURRENT_DESKTOP == "Unity") return; + const KNOWN_XDG_DESKTOP_VALUES = ["Pantheon", "Unity:Unity7", "pop:GNOME"]; + const currentPlatformSupportsAppIndicator = () => { + const currentDesktop = process.env.XDG_CURRENT_DESKTOP; + + if (!currentDesktop) return false; + if (KNOWN_XDG_DESKTOP_VALUES.includes(currentDesktop)) return true; + // ubuntu based or derived session (default ubuntu one, communitheme…) supports + // indicator too. + if (/ubuntu/gi.test(currentDesktop)) return true; + + return false; + }; + + // Workaround for electron/electron#5050 and electron/electron#9046 + process.env.ORIGINAL_XDG_CURRENT_DESKTOP = process.env.XDG_CURRENT_DESKTOP; + if (currentPlatformSupportsAppIndicator()) { + process.env.XDG_CURRENT_DESKTOP = "Unity"; + } +} + export function initTray() { + setXDGDesktop(); const trayIcon = createTrayIcon(); tray = new Tray(trayIcon); updateTrayMenu(); @@ -29,12 +59,13 @@ export function initTray() { tray.setImage(trayIcon); tray.on("click", () => { if (mainWindow.isVisible()) { - mainWindow.hide(); + mainWindow.hide(); } else { - mainWindow.show(); - mainWindow.focus(); + mainWindow.show(); + mainWindow.focus(); } }); + tray.setImage(trayIcon); } export function updateTrayMenu() {