diff --git a/CHANGELOG.md b/CHANGELOG.md index f1438688..ed4eb68a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ ### 🎉 New features - Add support for launching Expo updates. ([#134](https://github.com/expo/orbit/pull/134), [#137](https://github.com/expo/orbit/pull/137), [#138](https://github.com/expo/orbit/pull/138), [#144](https://github.com/expo/orbit/pull/144), [#148](https://github.com/expo/orbit/pull/148) by [@gabrieldonadel](https://github.com/gabrieldonadel)) -- Add experimental support for Windows and Linux. ([#152](https://github.com/expo/orbit/pull/152), [#157](https://github.com/expo/orbit/pull/157), [#158](https://github.com/expo/orbit/pull/158), [#160](https://github.com/expo/orbit/pull/160), [#161](https://github.com/expo/orbit/pull/161), [#165](https://github.com/expo/orbit/pull/165), [#170](https://github.com/expo/orbit/pull/170), [#171](https://github.com/expo/orbit/pull/171), [#172](https://github.com/expo/orbit/pull/172), [#173](https://github.com/expo/orbit/pull/173), [#174](https://github.com/expo/orbit/pull/174), [#175](https://github.com/expo/orbit/pull/175), [#177](https://github.com/expo/orbit/pull/177), [#178](https://github.com/expo/orbit/pull/178), [#180](https://github.com/expo/orbit/pull/180), [#181](https://github.com/expo/orbit/pull/181), [#182](https://github.com/expo/orbit/pull/182) by [@gabrieldonadel](https://github.com/gabrieldonadel)) +- Add experimental support for Windows and Linux. ([#152](https://github.com/expo/orbit/pull/152), [#157](https://github.com/expo/orbit/pull/157), [#158](https://github.com/expo/orbit/pull/158), [#160](https://github.com/expo/orbit/pull/160), [#161](https://github.com/expo/orbit/pull/161), [#165](https://github.com/expo/orbit/pull/165), [#170](https://github.com/expo/orbit/pull/170), [#171](https://github.com/expo/orbit/pull/171), [#172](https://github.com/expo/orbit/pull/172), [#173](https://github.com/expo/orbit/pull/173), [#174](https://github.com/expo/orbit/pull/174), [#175](https://github.com/expo/orbit/pull/175), [#177](https://github.com/expo/orbit/pull/177), [#178](https://github.com/expo/orbit/pull/178), [#180](https://github.com/expo/orbit/pull/180), [#181](https://github.com/expo/orbit/pull/181), [#182](https://github.com/expo/orbit/pull/182), [#185](https://github.com/expo/orbit/pull/185) by [@gabrieldonadel](https://github.com/gabrieldonadel)) - Migrate Sparkle to Expo Modules. ([#184](https://github.com/expo/orbit/pull/184) by [@gabrieldonadel](https://github.com/gabrieldonadel)) ### 🐛 Bug fixes diff --git a/apps/menu-bar/electron/assets/images/tray/icon-dark.ico b/apps/menu-bar/electron/assets/images/tray/icon-dark.ico new file mode 100644 index 00000000..c32825b9 Binary files /dev/null and b/apps/menu-bar/electron/assets/images/tray/icon-dark.ico differ diff --git a/apps/menu-bar/electron/assets/images/tray/icon-light.ico b/apps/menu-bar/electron/assets/images/tray/icon-light.ico new file mode 100644 index 00000000..e6d1f6b0 Binary files /dev/null and b/apps/menu-bar/electron/assets/images/tray/icon-light.ico differ diff --git a/apps/menu-bar/electron/forge.config.ts b/apps/menu-bar/electron/forge.config.ts index cecb7238..b0b2bebc 100644 --- a/apps/menu-bar/electron/forge.config.ts +++ b/apps/menu-bar/electron/forge.config.ts @@ -16,6 +16,8 @@ const config: ForgeConfig = { authors: 'Expo', description: 'Accelerate your development workflow with one-click build launches and simulator management from your menu bar', + iconUrl: + 'https://raw.githubusercontent.com/expo/orbit/main/apps/menu-bar/electron/assets/images/icon-windows.ico', }), new MakerZIP({}, ['darwin']), new MakerRpm({}), diff --git a/apps/menu-bar/electron/modules/AutoResizerRootViewManager/main.ts b/apps/menu-bar/electron/modules/AutoResizerRootViewManager/main.ts index 1c910181..52f1942f 100644 --- a/apps/menu-bar/electron/modules/AutoResizerRootViewManager/main.ts +++ b/apps/menu-bar/electron/modules/AutoResizerRootViewManager/main.ts @@ -1,9 +1,22 @@ -import { BrowserWindow } from 'electron'; +import { BrowserWindow, screen } from 'electron'; async function setPopoverSize(width: number, height: number, event: Electron.IpcMainInvokeEvent) { for (const window of BrowserWindow.getAllWindows()) { if (event.sender === window.webContents) { - window.setSize(width, height, true); + const [oldX, oldY] = window.getPosition(); + const [oldWidth, oldHeight] = window.getSize(); + + const display = screen.getDisplayNearestPoint({ x: oldX, y: oldY }); + + window.setBounds( + { + width, + height, + x: oldX + oldWidth - width, + y: display.size.height / 2 > oldY ? oldY : oldY + oldHeight - height, + }, + true + ); } } } diff --git a/apps/menu-bar/electron/package.json b/apps/menu-bar/electron/package.json index 0f2c5799..bdef6b51 100644 --- a/apps/menu-bar/electron/package.json +++ b/apps/menu-bar/electron/package.json @@ -36,6 +36,7 @@ "electron-squirrel-startup": "^1.0.0", "electron-store": "^8.1.0", "express": "^4.18.2", - "react-native-electron-modules": "../../../packages/react-native-electron-modules" + "react-native-electron-modules": "../../../packages/react-native-electron-modules", + "uuid": "9.0.0" } } diff --git a/apps/menu-bar/electron/src/TrayGenerator.ts b/apps/menu-bar/electron/src/TrayGenerator.ts index a4ae395a..7a20df7e 100644 --- a/apps/menu-bar/electron/src/TrayGenerator.ts +++ b/apps/menu-bar/electron/src/TrayGenerator.ts @@ -6,6 +6,7 @@ import { MenuItemConstructorOptions, ipcMain, app, + nativeTheme, } from 'electron'; import path from 'path'; @@ -63,8 +64,10 @@ export default class TrayGenerator { this.tray?.popUpContextMenu(Menu.buildFromTemplate(menu)); }; createTray = () => { - // eslint-disable-next-line no-undef - this.tray = new Tray(path.join(__dirname, '../../assets/images/tray/icon.png')); + this.tray = new Tray(getIconPath()); + nativeTheme.addListener('updated', () => { + this.tray?.setImage(getIconPath()); + }); this.tray.setIgnoreDoubleClickEvents(true); this.tray.on('click', this.toggleWindow); @@ -98,3 +101,18 @@ export default class TrayGenerator { }; } module.exports = TrayGenerator; + +const getIconPath = () => { + const iconName = getIconName(); + return path.join(__dirname, `../../assets/images/tray/${iconName}`); +}; + +const getIconName = () => { + if (process.platform === 'darwin') { + return 'icon.png'; + } + + return `icon-${nativeTheme.shouldUseDarkColors ? 'dark' : 'light'}.${ + process.platform === 'win32' ? 'ico' : 'png' + }`; +}; diff --git a/apps/menu-bar/electron/vite.cli.config.ts b/apps/menu-bar/electron/vite.cli.config.ts index 1e7f06ab..75b2bd51 100644 --- a/apps/menu-bar/electron/vite.cli.config.ts +++ b/apps/menu-bar/electron/vite.cli.config.ts @@ -2,11 +2,17 @@ import { defineConfig } from 'vite'; // https://vitejs.dev/config export default defineConfig({ + resolve: { + browserField: false, + }, build: { outDir: './.vite/build/cli', commonjsOptions: { include: [/common-types/, /eas-shared/, /node_modules/], }, + rollupOptions: { + external: ['uuid'], + }, }, optimizeDeps: { include: ['common-types', 'eas-shared'], diff --git a/apps/menu-bar/electron/yarn.lock b/apps/menu-bar/electron/yarn.lock index 029dfc7e..b8894ab9 100644 --- a/apps/menu-bar/electron/yarn.lock +++ b/apps/menu-bar/electron/yarn.lock @@ -4847,6 +4847,11 @@ utils-merge@1.0.1: resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" integrity sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA== +uuid@9.0.0: + version "9.0.0" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-9.0.0.tgz#592f550650024a38ceb0c562f2f6aa435761efb5" + integrity sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg== + v8-compile-cache-lib@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz#6336e8d71965cb3d35a1bbb7868445a7c05264bf"