feat(desktop): bundled renderer, modules and instance accounts (#3254)

This commit is contained in:
Hampus authored and GitHub committed 2026-10-07 16:48:07 +02:00
1 parent c748c8af4e
commit 7c5fa2180a
1275 files changed
+215074 -81246

No files matched your search

+36 -1
View File
@@ -38,6 +38,7 @@ const DESKTOP_ACTIONS = [
},
] as const;
const HICOLOR_ICON_SIZES = [16, 24, 32, 48, 64, 128, 256, 512] as const;
const PROTOCOL_REGISTRATION_TIMEOUT_MS = 5000;
function getXdgDataHome(): string {
const override = process.env.XDG_DATA_HOME;
@@ -204,7 +205,16 @@ function runUpdateDesktopDatabase(applicationsDir: string): void {
});
}
function registerProtocolClient(): void {
function isDefaultProtocolClient(): boolean {
try {
return app.isDefaultProtocolClient(APP_PROTOCOL);
} catch (error) {
logger.debug('Failed to read the protocol client registration', {error});
return false;
}
}
function registerProtocolClientInProcess(): void {
try {
app.setAsDefaultProtocolClient(APP_PROTOCOL);
} catch (error) {
@@ -212,6 +222,27 @@ function registerProtocolClient(): void {
}
}
function registerProtocolClient(): void {
if (isDefaultProtocolClient()) return;
const desktopName = process.env.CHROME_DESKTOP;
if (!desktopName) {
logger.debug('Skipping protocol client registration because the desktop name is not set');
return;
}
child_process.execFile(
'xdg-mime',
['default', desktopName, `x-scheme-handler/${APP_PROTOCOL}`],
{timeout: PROTOCOL_REGISTRATION_TIMEOUT_MS},
(error) => {
if (!error) return;
logger.debug('xdg-mime could not register the protocol client, registering in process', {
message: error.message,
});
registerProtocolClientInProcess();
},
);
}
function removeFile(filePath: string, reason: string): boolean {
try {
fs.unlinkSync(filePath);
@@ -281,6 +312,10 @@ function desktopEntryResolves(): boolean {
export function ensureLinuxDesktopEntry(): boolean {
if (process.platform !== 'linux') return false;
if (!app.isPackaged) {
logger.debug('Skipping .desktop entry management for an unpackaged run');
return false;
}
if (isFlatpakRuntime()) {
logger.debug('Skipping .desktop entry creation in Flatpak; package export owns launcher/protocol integration');
registerProtocolClient();