feat: implement application icon support for macOS

- Removed package.json and code signature files from the macOS app bundle.
- Added support for setting application icons via base64 encoded PNG strings.
- Enhanced the main application logic to detect and apply icons from various locations.
- Updated the Electron app and browser window classes to handle icon setting.
- Introduced new methods for decoding PNG icons and applying them to the application and window.
- Updated Cargo.toml to include the cocoa dependency for macOS.
This commit is contained in:
miles committed 2026-07-31 04:07:23 -05:00
1 parent a7b6f9a072
commit da521a33a0
37 files changed
+513 -5076

No files matched your search

+19 -1
View File
@@ -8,6 +8,7 @@ const { EventEmitter } = require('events');
const path = require('path');
const { bridge, isNative } = require('./native-bridge');
const { app } = require('./app');
const NativeImage = require('./native-image');
class WebContents extends EventEmitter {
constructor(id) {
@@ -219,6 +220,7 @@ class BrowserWindow extends EventEmitter {
resizable: this._options.resizable,
alwaysOnTop: this._options.alwaysOnTop,
fullscreen: this._options.fullscreen,
icon: this._iconToBase64Png(this._options.icon),
});
}
@@ -232,6 +234,23 @@ class BrowserWindow extends EventEmitter {
}
}
_iconToBase64Png(icon) {
if (!icon) return null;
try {
let img = icon;
if (typeof icon === 'string') {
img = NativeImage.createFromPath(icon);
}
if (img && typeof img.toPNG === 'function' && !img.isEmpty()) {
const png = img.toPNG();
if (png && png.length > 0) return png.toString('base64');
}
} catch (e) {
// Ignore invalid icon
}
return null;
}
static fromWebContents(webContents) {
for (const win of BrowserWindow._windows.values()) {
if (win.webContents && win.webContents.id === webContents.id) return win;
@@ -270,7 +289,6 @@ class BrowserWindow extends EventEmitter {
if (isNative) bridge.showWindow(this.id);
this.emit('show');
}
hide() {
if (this._isDestroyed) return;
this._isVisible = false;