Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[menu-bar][electron] Fix forge building config #185

Merged
merged 7 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file not shown.
Binary file not shown.
2 changes: 2 additions & 0 deletions apps/menu-bar/electron/forge.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({}),
Expand Down
Original file line number Diff line number Diff line change
@@ -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
);
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion apps/menu-bar/electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
22 changes: 20 additions & 2 deletions apps/menu-bar/electron/src/TrayGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
MenuItemConstructorOptions,
ipcMain,
app,
nativeTheme,
} from 'electron';
import path from 'path';

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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'
}`;
};
6 changes: 6 additions & 0 deletions apps/menu-bar/electron/vite.cli.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
5 changes: 5 additions & 0 deletions apps/menu-bar/electron/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading