fix(menu): hide titlebar extension if in browser

This commit is contained in:
dragonwocky 2024-01-24 13:21:09 +11:00
parent 54594350bd
commit f085362774
Signed by: dragonwocky
GPG Key ID: 7998D08F7D7BD7A8
3 changed files with 12 additions and 15 deletions

View File

@ -7,7 +7,10 @@
"use strict"; "use strict";
const IS_ELECTRON = typeof module !== "undefined", const IS_ELECTRON = typeof module !== "undefined",
IS_RENDERER = IS_ELECTRON && process.type === "renderer"; IS_RENDERER = IS_ELECTRON && process.type === "renderer",
whenReady = new Promise((res, rej) => {
(globalThis.__enhancerApi ??= {}).__isReady = res;
});
// expected values: 'linux', 'win32', 'darwin' (== macos), 'firefox' // expected values: 'linux', 'win32', 'darwin' (== macos), 'firefox'
// and 'chromium' (inc. chromium-based browsers like edge and brave) // and 'chromium' (inc. chromium-based browsers like edge and brave)
@ -158,4 +161,5 @@ Object.assign((globalThis.__enhancerApi ??= {}), {
readJson, readJson,
initDatabase, initDatabase,
reloadApp, reloadApp,
whenReady: (callback) => whenReady.then(callback),
}); });

View File

@ -2,7 +2,7 @@
"id": "a5658d03-21c6-4088-bade-fa4780459133", "id": "a5658d03-21c6-4088-bade-fa4780459133",
"name": "Titlebar", "name": "Titlebar",
"version": "0.11.1", "version": "0.11.1",
"environments": ["linux", "win32"], "platforms": ["linux", "win32"],
"description": "Replaces the operating system's default window titlebar with buttons inset into the app.", "description": "Replaces the operating system's default window titlebar with buttons inset into the app.",
"thumbnail": "integrated-titlebar.jpg", "thumbnail": "integrated-titlebar.jpg",
"tags": ["extension", "layout"], "tags": ["extension", "layout"],

View File

@ -6,19 +6,12 @@
"use strict"; "use strict";
globalThis.__enhancerApi ??= {}; const isElectron = () => {
const whenReady = new Promise((res, rej) => { try {
globalThis.__enhancerApi.__isReady = res; return typeof module !== "undefined";
}), } catch {}
isElectron = () => { return false;
try { };
return typeof module !== "undefined";
} catch {}
return false;
};
Object.assign((globalThis.__enhancerApi ??= {}), {
whenReady: (callback) => whenReady.then(callback),
});
if (isElectron()) { if (isElectron()) {
require("./common/system.js"); require("./common/system.js");