From f085362774f03c6222f50d1a74da046cdb89d9a4 Mon Sep 17 00:00:00 2001 From: dragonwocky Date: Wed, 24 Jan 2024 13:21:09 +1100 Subject: [PATCH] fix(menu): hide titlebar extension if in browser --- src/common/system.js | 6 +++++- src/extensions/titlebar/mod.json | 2 +- src/init.js | 19 ++++++------------- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/common/system.js b/src/common/system.js index 409c9a0..e702efb 100644 --- a/src/common/system.js +++ b/src/common/system.js @@ -7,7 +7,10 @@ "use strict"; 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' // and 'chromium' (inc. chromium-based browsers like edge and brave) @@ -158,4 +161,5 @@ Object.assign((globalThis.__enhancerApi ??= {}), { readJson, initDatabase, reloadApp, + whenReady: (callback) => whenReady.then(callback), }); diff --git a/src/extensions/titlebar/mod.json b/src/extensions/titlebar/mod.json index b94047f..9f09bbe 100644 --- a/src/extensions/titlebar/mod.json +++ b/src/extensions/titlebar/mod.json @@ -2,7 +2,7 @@ "id": "a5658d03-21c6-4088-bade-fa4780459133", "name": "Titlebar", "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.", "thumbnail": "integrated-titlebar.jpg", "tags": ["extension", "layout"], diff --git a/src/init.js b/src/init.js index 3688b8b..3efac25 100644 --- a/src/init.js +++ b/src/init.js @@ -6,19 +6,12 @@ "use strict"; -globalThis.__enhancerApi ??= {}; -const whenReady = new Promise((res, rej) => { - globalThis.__enhancerApi.__isReady = res; - }), - isElectron = () => { - try { - return typeof module !== "undefined"; - } catch {} - return false; - }; -Object.assign((globalThis.__enhancerApi ??= {}), { - whenReady: (callback) => whenReady.then(callback), -}); +const isElectron = () => { + try { + return typeof module !== "undefined"; + } catch {} + return false; +}; if (isElectron()) { require("./common/system.js");