fix: prevent macOS backend Dock registration

Preload a backend-only JS title accessor from an unpacked macOS resource before Next starts. Preserve Windows and Linux launch arguments, and test title semantics, process scope, argument order, and resource copying.

Based on the prevention approach proposed by marchellodev in PR #47.
This commit is contained in:
amosblomqvist
2026-10-24 21:56:57 +03:00
parent c549494488
commit 480a29aaea
4 changed files with 192 additions and 1 deletions
+24
View File
@@ -0,0 +1,24 @@
/**
* Preloaded only into the packaged macOS backend, before Next starts.
*
* Next assigns process.title. In Electron's Node mode on macOS, the native
* setter checks in with Launch Services using the main app bundle, creating
* an unwanted foreground application registration. Keep title writes in JS
* instead: the native process name stays unchanged while JS can read back
* its assigned title. This deliberately does not emulate native truncation
* or every coercion detail; assignments use String(value).
*
* Explicit launch arguments (not NODE_OPTIONS) keep the full-Electron browser
* helper untouched. Node-mode fork descendants can inherit this preload.
*/
if (process.platform === "darwin" && process.env.ELECTRON_RUN_AS_NODE === "1" && process.env.LH_DESKTOP_SERVER === "1") {
let title = process.title;
Object.defineProperty(process, "title", {
configurable: true,
enumerable: true,
get: () => title,
set: (value) => {
title = String(value);
},
});
}