2022-12-01 13:07:23 +01:00
|
|
|
import appContext from "./components/app_context.js";
|
2018-12-29 10:04:59 +01:00
|
|
|
import utils from './services/utils.js';
|
|
|
|
import noteTooltipService from './services/note_tooltip.js';
|
2020-04-12 14:22:51 +02:00
|
|
|
import bundleService from "./services/bundle.js";
|
2024-07-27 12:05:24 +03:00
|
|
|
import toastService from "./services/toast.js";
|
2018-12-29 10:04:59 +01:00
|
|
|
import noteAutocompleteService from './services/note_autocomplete.js';
|
2019-01-09 22:08:24 +01:00
|
|
|
import macInit from './services/mac_init.js';
|
2023-05-07 10:43:51 +02:00
|
|
|
import electronContextMenu from "./menus/electron_context_menu.js";
|
2020-04-12 14:22:51 +02:00
|
|
|
import glob from "./services/glob.js";
|
2024-07-27 12:10:59 +03:00
|
|
|
import { t } from "./services/i18n.js";
|
2024-12-01 18:18:53 +02:00
|
|
|
import options from "./services/options.js";
|
2020-04-12 14:22:51 +02:00
|
|
|
|
2024-10-24 20:55:21 +03:00
|
|
|
await appContext.earlyInit();
|
|
|
|
|
2024-08-11 08:12:01 +03:00
|
|
|
bundleService.getWidgetBundlesByParent().then(async widgetBundles => {
|
|
|
|
// A dynamic import is required for layouts since they initialize components which require translations.
|
|
|
|
const DesktopLayout = (await import("./layouts/desktop_layout.js")).default;
|
|
|
|
|
2024-07-27 12:05:24 +03:00
|
|
|
appContext.setLayout(new DesktopLayout(widgetBundles));
|
|
|
|
appContext.start()
|
|
|
|
.catch((e) => {
|
|
|
|
toastService.showPersistent({
|
2024-07-27 12:10:59 +03:00
|
|
|
title: t("toast.critical-error.title"),
|
2024-07-27 12:05:24 +03:00
|
|
|
icon: "alert",
|
2024-07-27 12:10:59 +03:00
|
|
|
message: t("toast.critical-error.message", { message: e.message }),
|
2024-07-27 12:05:24 +03:00
|
|
|
});
|
|
|
|
console.error("Critical error occured", e);
|
|
|
|
});
|
2022-11-22 23:53:08 +01:00
|
|
|
});
|
|
|
|
|
2020-04-12 14:22:51 +02:00
|
|
|
glob.setupGlobs();
|
2018-03-24 11:18:46 -04:00
|
|
|
|
2018-03-26 22:29:14 -04:00
|
|
|
if (utils.isElectron()) {
|
2024-12-01 02:18:35 +02:00
|
|
|
initOnElectron();
|
2018-03-26 22:29:14 -04:00
|
|
|
}
|
2018-03-25 22:37:02 -04:00
|
|
|
|
2020-02-14 20:18:09 +01:00
|
|
|
macInit.init();
|
2019-01-25 22:18:34 +01:00
|
|
|
|
2018-12-22 20:57:09 +01:00
|
|
|
noteTooltipService.setupGlobalTooltip();
|
2018-03-26 22:29:14 -04:00
|
|
|
|
2020-02-28 22:07:08 +01:00
|
|
|
noteAutocompleteService.init();
|
|
|
|
|
|
|
|
if (utils.isElectron()) {
|
2023-05-07 10:43:51 +02:00
|
|
|
electronContextMenu.setupContextMenu();
|
2020-05-11 20:08:55 +02:00
|
|
|
}
|
2024-12-01 02:18:35 +02:00
|
|
|
|
|
|
|
function initOnElectron() {
|
|
|
|
const electron = utils.dynamicRequire('electron');
|
|
|
|
electron.ipcRenderer.on('globalShortcut', async (event, actionName) => appContext.triggerCommand(actionName));
|
|
|
|
|
2024-12-01 18:18:53 +02:00
|
|
|
if (options.get("nativeTitleBarVisible") !== "true") {
|
|
|
|
initTitleBarButtons();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function initTitleBarButtons() {
|
|
|
|
function applyTitleBarOverlaySettings() {
|
|
|
|
const electronRemote = utils.dynamicRequire("@electron/remote");
|
|
|
|
const currentWindow = electronRemote.getCurrentWindow();
|
|
|
|
const documentStyle = window.getComputedStyle(document.documentElement);
|
|
|
|
const color = documentStyle.getPropertyValue("--native-titlebar-background");
|
|
|
|
const symbolColor = documentStyle.getPropertyValue("--native-titlebar-foreground");
|
|
|
|
currentWindow.setTitleBarOverlay({ color, symbolColor });
|
|
|
|
}
|
|
|
|
|
2024-12-01 02:18:35 +02:00
|
|
|
// Update the native title bar buttons.
|
2024-12-01 17:59:55 +02:00
|
|
|
applyTitleBarOverlaySettings();
|
2024-12-01 18:18:53 +02:00
|
|
|
|
2024-12-01 17:59:55 +02:00
|
|
|
// Register for changes to the native title bar colors.
|
|
|
|
window.matchMedia("(prefers-color-scheme: dark)")
|
|
|
|
.addEventListener("change", applyTitleBarOverlaySettings);
|
|
|
|
}
|