Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix(desktop): use native AppKit sidebar material on macOS (#21854)

Innei661512bf126f
diff --git a/apps/desktop/package.json b/apps/desktop/package.json
index 18a46c91ea3..a549bd1d141 100644
--- a/apps/desktop/package.json
+++ b/apps/desktop/package.json
@@ -78,6 +78,7 @@
"@lobechat/electron-client-ipc": "workspace:*",
"@lobechat/electron-mac-notifications": "workspace:*",
"@lobechat/electron-mac-permission-guide": "workspace:*",
+ "@lobechat/electron-mac-sidebar-glass": "workspace:*",
"@lobechat/electron-server-ipc": "workspace:*",
"@lobechat/file-loaders": "workspace:*",
"@lobechat/heterogeneous-agents": "workspace:*",
diff --git a/apps/desktop/pnpm-lock.yaml b/apps/desktop/pnpm-lock.yaml
index 083e2ce704a..e643a432d4f 100644
--- a/apps/desktop/pnpm-lock.yaml
+++ b/apps/desktop/pnpm-lock.yaml
@@ -91,6 +91,9 @@ importers:
'@lobechat/electron-mac-permission-guide':
specifier: workspace:*
version: link:../../packages/electron-mac-permission-guide
+ '@lobechat/electron-mac-sidebar-glass':
+ specifier: workspace:*
+ version: link:../../packages/electron-mac-sidebar-glass
'@lobechat/electron-server-ipc':
specifier: workspace:*
version: link:../../packages/electron-server-ipc
@@ -446,6 +449,19 @@ importers:
specifier: ^12.4.0
version: 12.4.0
+ ../../packages/electron-mac-sidebar-glass:
+ dependencies:
+ '@lobechat/napi-loader':
+ specifier: workspace:*
+ version: link:../napi-loader
+ devDependencies:
+ node-addon-api:
+ specifier: ^8.5.0
+ version: 8.9.2
+ node-gyp:
+ specifier: ^12.4.0
+ version: 12.4.0
+
../../packages/electron-server-ipc:
dependencies:
debug:
diff --git a/apps/desktop/pnpm-workspace.yaml b/apps/desktop/pnpm-workspace.yaml
index 85356e7a50a..7f5d1a6d157 100644
--- a/apps/desktop/pnpm-workspace.yaml
+++ b/apps/desktop/pnpm-workspace.yaml
@@ -11,6 +11,7 @@ packages:
- '../../packages/electron-client-ipc'
- '../../packages/electron-mac-notifications'
- '../../packages/electron-mac-permission-guide'
+ - '../../packages/electron-mac-sidebar-glass'
- '../../packages/napi-loader'
- '../../packages/file-loaders'
- '../../packages/html-artifact'
diff --git a/apps/desktop/src/main/__mocks__/setup.ts b/apps/desktop/src/main/__mocks__/setup.ts
index 8956e9d2f4a..a74151a4e8c 100644
--- a/apps/desktop/src/main/__mocks__/setup.ts
+++ b/apps/desktop/src/main/__mocks__/setup.ts
@@ -6,6 +6,11 @@ import { vi } from 'vitest';
// Mock node-mac-permissions before any imports
vi.mock('node-mac-permissions', () => import('./node-mac-permissions'));
+vi.mock('@lobechat/electron-mac-sidebar-glass', () => ({
+ isSupported: () => false,
+ setWindowGlass: vi.fn(() => false),
+}));
+
// Default electron mock: gives every suite a ready `app` (paths + readiness)
// so modules with import-time electron access (e.g. `@/const/dir`) load safely
// without per-suite stubbing. A test's own `vi.mock('electron', …)` overrides
diff --git a/apps/desktop/src/main/core/browser/WindowThemeManager.macGlass.test.ts b/apps/desktop/src/main/core/browser/WindowThemeManager.macGlass.test.ts
new file mode 100644
index 00000000000..b9d57bc6c72
--- /dev/null
+++ b/apps/desktop/src/main/core/browser/WindowThemeManager.macGlass.test.ts
@@ -0,0 +1,130 @@
+import type { BrowserWindow } from 'electron';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+
+import { WindowThemeManager } from './WindowThemeManager';
+
+const { glass, material, theme, window } = vi.hoisted(() => ({
+ glass: { isSupported: vi.fn(), setWindowGlass: vi.fn() },
+ material: { background: '' },
+ theme: {
+ off: vi.fn(),
+ on: vi.fn(),
+ shouldUseDarkColors: false,
+ themeSource: 'system' as string,
+ },
+ window: {
+ getNativeWindowHandle: vi.fn(() => Buffer.alloc(8)),
+ isDestroyed: vi.fn(() => false),
+ isFullScreen: vi.fn(() => false),
+ setBackgroundColor: vi.fn(),
+ setVibrancy: vi.fn(),
+ },
+}));
+
+vi.mock('@lobechat/electron-mac-sidebar-glass', () => glass);
+vi.mock('electron', () => ({ nativeTheme: theme }));
+vi.mock('@/const/dir', () => ({ buildDir: '/mock/build' }));
+vi.mock('@/const/env', () => ({ isDev: false, isLinux: false, isMac: true, isWindows: false }));
+
+describe('macOS window glass lifecycle', () => {
+ let manager: WindowThemeManager;
+ const browserWindow = window as unknown as BrowserWindow;
+
+ beforeEach(() => {
+ vi.clearAllMocks();
+ vi.useFakeTimers();
+ glass.isSupported.mockReturnValue(true);
+ glass.setWindowGlass.mockImplementation((_handle, enabled) => {
+ material.background = enabled ? 'sidebar' : '';
+ return true;
+ });
+ window.setBackgroundColor.mockImplementation((color) => {
+ material.background = color;
+ });
+ window.isDestroyed.mockReturnValue(false);
+ window.isFullScreen.mockReturnValue(false);
+ theme.shouldUseDarkColors = false;
+ theme.themeSource = 'system';
+ manager = new WindowThemeManager('glass-test');
+ });
+
+ afterEach(() => {
+ manager.cleanup();
+ vi.useRealTimers();
+ });
+
+ it('installs the material when the native window attaches, without a renderer', () => {
+ manager.attach(browserWindow);
+
+ expect(glass.setWindowGlass).toHaveBeenCalledWith(window.getNativeWindowHandle(), true, false);
+ expect(window.setVibrancy).toHaveBeenLastCalledWith(null);
+ expect(material.background).toBe('sidebar');
+ });
+
+ it('updates the material to the explicit app appearance', () => {
+ manager.attach(browserWindow);
+ theme.themeSource = 'dark';
+ manager.handleAppThemeChange();
+ vi.runAllTimers();
+
+ expect(glass.setWindowGlass).toHaveBeenLastCalledWith(
+ window.getNativeWindowHandle(),
+ true,
+ true,
+ );
+ });
+
+ it('removes glass in fullscreen and reinstalls it when leaving', () => {
+ manager.attach(browserWindow);
+ manager.handleFullscreenChange(true);
+
+ expect(glass.setWindowGlass).toHaveBeenLastCalledWith(
+ window.getNativeWindowHandle(),
+ false,
+ false,
+ );
+ expect(window.setBackgroundColor).toHaveBeenLastCalledWith('#f8f8f8');
+
+ manager.handleFullscreenChange(false);
+
+ expect(glass.setWindowGlass).toHaveBeenLastCalledWith(
+ window.getNativeWindowHandle(),
+ true,
+ false,
+ );
+ expect(window.setBackgroundColor).toHaveBeenLastCalledWith('#00000000');
+ expect(window.setVibrancy).toHaveBeenLastCalledWith(null);
+ expect(material.background).toBe('sidebar');
+ });
+
+ it('keeps Electron sidebar vibrancy when native glass is unavailable', () => {
+ glass.isSupported.mockReturnValue(false);
+ manager.attach(browserWindow);
+
+ expect(glass.setWindowGlass).not.toHaveBeenCalled();
+ expect(window.setVibrancy).toHaveBeenLastCalledWith('sidebar');
+ });
+
+ it('restores Electron sidebar vibrancy when native installation fails', () => {
+ glass.setWindowGlass.mockReturnValue(false);
+ manager.attach(browserWindow);
+
+ expect(window.setVibrancy).toHaveBeenLastCalledWith('sidebar');
+ });
+
+ it('releases the native material and ignores queued updates after cleanup', () => {
+ manager.attach(browserWindow);
+ manager.handleAppThemeChange();
+ manager.cleanup();
+ expect(glass.setWindowGlass).toHaveBeenLastCalledWith(
+ window.getNativeWindowHandle(),
+ false,
+ false,
+ );
+ glass.setWindowGlass.mockClear();
+ vi.runAllTimers();
+
+ expect(glass.setWindowGlass).not.toHaveBeenCalled();
+ expect(theme.off).toHaveBeenCalled();
+ });
+});
diff --git a/apps/desktop/src/main/core/browser/WindowThemeManager.ts b/apps/desktop/src/main/core/browser/WindowThemeManager.ts
index eea25bc0712..6bd1362fc25 100644
--- a/apps/desktop/src/main/core/browser/WindowThemeManager.ts
+++ b/apps/desktop/src/main/core/browser/WindowThemeManager.ts
@@ -1,6 +1,10 @@
import path from 'node:path';
import { TITLE_BAR_HEIGHT } from '@lobechat/desktop-bridge';
+import {
+ isSupported as isGlassSupported,
+ setWindowGlass,
+} from '@lobechat/electron-mac-sidebar-glass';
import { type BrowserWindow, type BrowserWindowConstructorOptions, nativeTheme } from 'electron';
import { buildDir } from '@/const/dir';
@@ -18,6 +22,7 @@ import {
const logger = createLogger('core:WindowThemeManager');
const MACOS_VIBRANCY = 'sidebar';
+// lobe-design-ignore LOBE-RAW-COLOR: Electron native colors cannot resolve CSS variables.
const MACOS_TRANSPARENT_BACKGROUND = '#00000000';
interface WindowsThemeConfig {
@@ -43,6 +48,7 @@ export class WindowThemeManager {
private readonly identifier: string;
private browserWindow?: BrowserWindow;
private listenerSetup = false;
+ private nativeGlassActive = false;
private boundHandleThemeChange: () => void;
constructor(identifier: string) {
@@ -52,6 +58,7 @@ export class WindowThemeManager {
private getWindowsTitleBarOverlay(isDarkMode: boolean): WindowsThemeConfig['titleBarOverlay'] {
return {
+ // lobe-design-ignore LOBE-RAW-COLOR: Electron native colors cannot resolve CSS variables.
color: '#00000000',
// Reduce 2px to prevent blocking the container border edge
height: TITLE_BAR_HEIGHT - 2,
@@ -74,6 +81,7 @@ export class WindowThemeManager {
* Cleanup theme listener when window is destroyed
*/
cleanup(): void {
+ this.removeMacGlass();
if (this.listenerSetup) {
nativeTheme.off('updated', this.boundHandleThemeChange);
this.listenerSetup = false;
@@ -178,28 +186,49 @@ export class WindowThemeManager {
}
/**
- * Electron does not re-evaluate the macOS NSVisualEffectView when the theme changes at
- * runtime, so the vibrancy keeps the previous appearance (dark sidebar over a light UI)
- * until the window is recreated. Toggling it forces AppKit to rebuild the effect view.
+ * Replace the window material in place; transparent renderer regions expose it.
+ * Keep Electron's sidebar vibrancy as the fallback for older systems or addon failure.
*/
private refreshMacVibrancy(): void {
if (!this.browserWindow) return;
this.browserWindow.setVibrancy(null);
+ if (isGlassSupported()) {
+ const applied = setWindowGlass(
+ this.browserWindow.getNativeWindowHandle(),
+ true,
+ this.resolveIsDarkMode(),
+ );
+ if (applied) {
+ this.nativeGlassActive = true;
+ return;
+ }
+ this.removeMacGlass();
+ logger.warn(`[${this.identifier}] Native glass unavailable; using sidebar vibrancy.`);
+ }
+
this.browserWindow.setVibrancy(MACOS_VIBRANCY);
}
+ private removeMacGlass(): void {
+ if (this.nativeGlassActive && this.browserWindow && !this.browserWindow.isDestroyed()) {
+ setWindowGlass(this.browserWindow.getNativeWindowHandle(), false, false);
+ }
+ this.nativeGlassActive = false;
+ }
+
private applyMacFullscreenChrome(isFullScreen: boolean): void {
if (!this.browserWindow) return;
if (isFullScreen) {
+ this.removeMacGlass();
this.browserWindow.setBackgroundColor(this.opaqueBackground());
this.browserWindow.setVibrancy(null);
return;
}
- this.browserWindow.setVibrancy(MACOS_VIBRANCY);
this.browserWindow.setBackgroundColor(MACOS_TRANSPARENT_BACKGROUND);
+ this.refreshMacVibrancy();
}
// ==================== Visual Effects ====================
@@ -230,8 +259,6 @@ export class WindowThemeManager {
} else if (isLinux) {
this.applyLinuxVisualEffects();
} else if (isMac) {
- // macOS keeps the native vibrancy (and the traffic-light/title bar area) on the
- // appearance it was created with, so it has to be rebuilt on every theme change.
if (this.browserWindow.isFullScreen()) {
this.applyMacFullscreenChrome(true);
} else {
diff --git a/packages/electron-mac-sidebar-glass/.gitignore b/packages/electron-mac-sidebar-glass/.gitignore
new file mode 100644
index 00000000000..567609b1234
--- /dev/null
+++ b/packages/electron-mac-sidebar-glass/.gitignore
@@ -0,0 +1 @@
+build/
diff --git a/packages/electron-mac-sidebar-glass/README.md b/packages/electron-mac-sidebar-glass/README.md
new file mode 100644
index 00000000000..7351717bda0
--- /dev/null
+++ b/packages/electron-mac-sidebar-glass/README.md
@@ -0,0 +1,30 @@
+# Electron macOS window glass
+
+Main-process adapter for AppKit's sidebar material (macOS 26+). A native
+`NSSplitViewController` with one sidebar item supplies the system glass. The material
+fills the native window beneath Electron web contents. Existing transparent
+renderer regions reveal it; opaque content remains opaque.
+
+`WindowThemeManager` installs the material when the window attaches, updates
+its appearance, removes it for fullscreen, and reinstalls it when leaving
+fullscreen. Older systems and addon failures retain Electron sidebar vibrancy.
+
+| API | Purpose |
+| --------------------------------------------------- | ---------------------------------------------- |
+| `isSupported()` | Check addon and system glass availability |
+| `setWindowGlass(nativeWindowHandle, enabled, dark)` | Enable, update, or release the window material |
+
+Pass `BrowserWindow.getNativeWindowHandle()` on the main thread. AppKit owns
+resizing and releases the material with the window. No renderer hooks, IPC,
+sidebar measurements, custom opacity, or CSS injection are required. The native
+window uses AppKit's standard `windowBackgroundColor` and opaque backing, rather
+than clearing it and compensating with a translucent overlay. Sidebar glass and
+window color both follow the selected appearance.
+
+Electron's `vibrancy: 'sidebar'` is the older `NSVisualEffectView` material.
+AppKit owns the new sidebar glass through `NSSplitViewController`. This controller
+only supplies the background; Electron keeps its existing content hierarchy and
+the renderer keeps its sidebar layout.
+
+Build with `pnpm --filter @lobechat/electron-mac-sidebar-glass build:native`
+from `apps/desktop`. The existing native dependency discovery handles packaging.
diff --git a/packages/electron-mac-sidebar-glass/binding.gyp b/packages/electron-mac-sidebar-glass/binding.gyp
new file mode 100644
index 00000000000..0cadeb0b160
--- /dev/null
+++ b/packages/electron-mac-sidebar-glass/binding.gyp
@@ -0,0 +1,23 @@
+{
+ "targets": [
+ {
+ "target_name": "lobehub_mac_sidebar_glass",
+ "sources": ["native/addon.mm"],
+ "include_dirs": ["<!@(node -p \"require('node-addon-api').include\")"],
+ "dependencies": ["<!(node -p \"require('node-addon-api').gyp\")"],
+ "defines": ["NAPI_DISABLE_CPP_EXCEPTIONS"],
+ "conditions": [
+ [
+ "OS=='mac'",
+ {
+ "xcode_settings": {
+ "OTHER_CPLUSPLUSFLAGS": ["-fobjc-arc", "-std=c++17"],
+ "OTHER_LDFLAGS": ["-framework Foundation", "-framework AppKit", "-framework QuartzCore"],
+ "MACOSX_DEPLOYMENT_TARGET": "12.0"
+ }
+ }
+ ]
+ ]
+ }
+ ]
+}
diff --git a/packages/electron-mac-sidebar-glass/index.d.ts b/packages/electron-mac-sidebar-glass/index.d.ts
new file mode 100644
index 00000000000..e5333409f47
--- /dev/null
+++ b/packages/electron-mac-sidebar-glass/index.d.ts
@@ -0,0 +1,16 @@
+/// <reference types="node" />
+
+/** Whether the native addon and AppKit Liquid Glass are available (macOS 26+). */
+export declare function isSupported(): boolean;
+
+/**
+ * Set the window background material beneath its web contents.
+ * Uses BrowserWindow.getNativeWindowHandle(); call only on Electron's main thread.
+ * Disabling releases the material. Window destruction also releases it automatically.
+ * Returns false on failure so the caller can retain Electron sidebar vibrancy.
+ */
+export declare function setWindowGlass(
+ nativeWindowHandle: Buffer,
+ enabled: boolean,
+ dark: boolean,
+): boolean;
diff --git a/packages/electron-mac-sidebar-glass/index.js b/packages/electron-mac-sidebar-glass/index.js
new file mode 100644
index 00000000000..53f49341cf8
--- /dev/null
+++ b/packages/electron-mac-sidebar-glass/index.js
@@ -0,0 +1,23 @@
+/* eslint-disable @typescript-eslint/no-require-imports */
+'use strict';
+
+const { loadNativeBinding } = require('@lobechat/napi-loader');
+
+const binding =
+ process.platform === 'darwin' && process.type !== 'renderer'
+ ? loadNativeBinding({ dirname: __dirname, packageName: require('./package.json').name })
+ : null;
+
+const isSupported = () => binding?.isSupported() === true;
+
+const setWindowGlass = (nativeWindowHandle, enabled, dark) => {
+ if (!binding) return false;
+ try {
+ return binding.setWindowGlass(nativeWindowHandle, enabled, dark) === true;
+ } catch (error) {
+ console.error('[electron-mac-sidebar-glass] Failed to update window material:', error);
+ return false;
+ }
+};
+
+module.exports = { isSupported, setWindowGlass };
diff --git a/packages/electron-mac-sidebar-glass/native/addon.mm b/packages/electron-mac-sidebar-glass/native/addon.mm
new file mode 100644
index 00000000000..66d9bc78b83
--- /dev/null
+++ b/packages/electron-mac-sidebar-glass/native/addon.mm
@@ -0,0 +1,100 @@
+#import <AppKit/AppKit.h>
+#import <objc/runtime.h>
+
+#include <cstring>
+#include <napi.h>
+
+// The window owns the material. No renderer lifecycle, global registry, or observers.
+static char kWindowGlassKey;
+
+@interface LobeWindowGlass : NSView
+@property(nonatomic, strong) NSSplitViewController *sidebarController;
+@end
+
+@implementation LobeWindowGlass
+- (instancetype)initWithFrame:(NSRect)frame {
+ self = [super initWithFrame:frame];
+ if (!self) return nil;
+
+ NSViewController *sidebar = [[NSViewController alloc] init];
+ sidebar.view = [[NSView alloc] initWithFrame:self.bounds];
+ NSSplitViewItem *item = [NSSplitViewItem sidebarWithViewController:sidebar];
+ item.canCollapse = NO;
+ item.minimumThickness = NSSplitViewItemUnspecifiedDimension;
+ item.maximumThickness = NSSplitViewItemUnspecifiedDimension;
+
+ self.sidebarController = [[NSSplitViewController alloc] init];
+ [self.sidebarController addSplitViewItem:item];
+ NSView *material = self.sidebarController.view;
+ material.frame = self.bounds;
+ material.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
+ [self addSubview:material];
+ return self;
+}
+
+- (NSView *)hitTest:(NSPoint)point {
+ return nil;
+}
+@end
+
+static Napi::Value IsSupported(const Napi::CallbackInfo &info) {
+ return Napi::Boolean::New(info.Env(), NSClassFromString(@"NSGlassEffectView") != Nil);
+}
+
+static Napi::Value SetWindowGlass(const Napi::CallbackInfo &info) {
+ Napi::Env env = info.Env();
+ if (info.Length() != 3 || !info[0].IsBuffer() || !info[1].IsBoolean() ||
+ !info[2].IsBoolean() || ![NSThread isMainThread]) {
+ return Napi::Boolean::New(env, false);
+ }
+
+ auto handle = info[0].As<Napi::Buffer<uint8_t>>();
+ if (handle.Length() != sizeof(NSView *)) return Napi::Boolean::New(env, false);
+
+ void *pointer = nullptr;
+ std::memcpy(&pointer, handle.Data(), sizeof(pointer));
+ // Electron's getNativeWindowHandle() returns an NSView pointer on macOS.
+ NSView *electronView = (__bridge NSView *)pointer;
+ NSWindow *window = electronView.window;
+ NSView *contentView = window.contentView;
+ if (!contentView) return Napi::Boolean::New(env, false);
+
+ @try {
+ LobeWindowGlass *glass = objc_getAssociatedObject(contentView, &kWindowGlassKey);
+ if (!info[1].As<Napi::Boolean>().Value()) {
+ [glass removeFromSuperview];
+ objc_setAssociatedObject(contentView, &kWindowGlassKey, nil, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+ return Napi::Boolean::New(env, true);
+ }
+
+ if (!NSClassFromString(@"NSGlassEffectView")) return Napi::Boolean::New(env, false);
+
+ if (!glass) {
+ glass = [[LobeWindowGlass alloc] initWithFrame:contentView.bounds];
+ glass.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
+ [contentView addSubview:glass positioned:NSWindowBelow relativeTo:nil];
+ objc_setAssociatedObject(contentView, &kWindowGlassKey, glass, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+ }
+
+ glass.appearance = [NSAppearance appearanceNamed:info[2].As<Napi::Boolean>().Value()
+ ? NSAppearanceNameDarkAqua : NSAppearanceNameAqua];
+ [glass.appearance performAsCurrentDrawingAppearance:^{
+ // Match a standard AppKit sidebar window, rather than exposing the desktop
+ // through a cleared Electron window and compensating with a custom alpha.
+ window.backgroundColor = NSColor.windowBackgroundColor;
+ }];
+ window.opaque = YES;
+ return Napi::Boolean::New(env, true);
+ } @catch (NSException *exception) {
+ NSLog(@"[electron-mac-sidebar-glass] Failed to update window material: %@", exception);
+ return Napi::Boolean::New(env, false);
+ }
+}
+
+static Napi::Object Init(Napi::Env env, Napi::Object exports) {
+ exports.Set("isSupported", Napi::Function::New(env, IsSupported));
+ exports.Set("setWindowGlass", Napi::Function::New(env, SetWindowGlass));
+ return exports;
+}
+
+NODE_API_MODULE(lobehub_mac_sidebar_glass, Init)
diff --git a/packages/electron-mac-sidebar-glass/package.json b/packages/electron-mac-sidebar-glass/package.json
new file mode 100644
index 00000000000..77e5e78fb07
--- /dev/null
+++ b/packages/electron-mac-sidebar-glass/package.json
@@ -0,0 +1,23 @@
+{
+ "name": "@lobechat/electron-mac-sidebar-glass",
+ "version": "1.0.0",
+ "private": true,
+ "main": "index.js",
+ "types": "index.d.ts",
+ "scripts": {
+ "build:native": "node scripts/build-native.mjs",
+ "install": "node scripts/build-native.mjs"
+ },
+ "dependencies": {
+ "@lobechat/napi-loader": "workspace:*"
+ },
+ "devDependencies": {
+ "node-addon-api": "^8.5.0",
+ "node-gyp": "^11.4.2"
+ },
+ "lobechat": {
+ "nativeAddonPlatforms": [
+ "darwin"
+ ]
+ }
+}
diff --git a/packages/electron-mac-sidebar-glass/scripts/build-native.mjs b/packages/electron-mac-sidebar-glass/scripts/build-native.mjs
new file mode 100644
index 00000000000..5af665dc294
--- /dev/null
+++ b/packages/electron-mac-sidebar-glass/scripts/build-native.mjs
@@ -0,0 +1,24 @@
+import { execFile } from 'node:child_process';
+import { createRequire } from 'node:module';
+import path from 'node:path';
+import { fileURLToPath } from 'node:url';
+import { promisify } from 'node:util';
+
+const execFileAsync = promisify(execFile);
+
+if (process.platform !== 'darwin') {
+ console.info('[electron-mac-sidebar-glass] non-darwin platform, skipping native build');
+ process.exit(0);
+}
+
+const packageRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
+const require = createRequire(import.meta.url);
+const nodeGyp = require.resolve('node-gyp/bin/node-gyp.js');
+
+const { stdout, stderr } = await execFileAsync(process.execPath, [nodeGyp, 'rebuild'], {
+ cwd: packageRoot,
+ maxBuffer: 16 * 1024 * 1024,
+});
+if (stdout) console.info(stdout);
+if (stderr) console.info(stderr);
+console.info('[electron-mac-sidebar-glass] native build completed');