From c20a8232cd66f2a7904508fd7265ae56b65ab139 Mon Sep 17 00:00:00 2001 From: Abdullah Atta Date: Sat, 18 Nov 2023 14:17:44 +0500 Subject: [PATCH] core: safe check for IS_DESKTOP_APP --- packages/core/scripts/prebuild.mjs | 5 ++++- packages/core/src/utils/templates/html/builder.js | 9 +++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/core/scripts/prebuild.mjs b/packages/core/scripts/prebuild.mjs index d54b0c60b..12327b439 100644 --- a/packages/core/scripts/prebuild.mjs +++ b/packages/core/scripts/prebuild.mjs @@ -32,7 +32,10 @@ const languagesList = await langen( path.join(ROOT_DIR, "src", "utils", "templates", "html", "languages") ); const languageIndex = `function hasRequire() { - return typeof require === "function" && !IS_DESKTOP_APP; + return ( + typeof require === "function" && + (typeof IS_DESKTOP_APP === "undefined" || !IS_DESKTOP_APP) + ); } export async function loadLanguage(language) { diff --git a/packages/core/src/utils/templates/html/builder.js b/packages/core/src/utils/templates/html/builder.js index 2990d368c..6d0e1081b 100644 --- a/packages/core/src/utils/templates/html/builder.js +++ b/packages/core/src/utils/templates/html/builder.js @@ -41,7 +41,6 @@ async function preprocessHTML(templateData) { const { content } = templateData; let html = content.replaceAll(/]*)><\/p>/gm, "

"); - console.log(html); for (const attribute in replaceableAttributes) { html = html.replaceAll(attribute, replaceableAttributes[attribute]); } @@ -60,7 +59,6 @@ async function preprocessHTML(templateData) { : await import("katex/contrib/mhchem/mhchem.js"); for (const mathBlock of mathBlocks) { const text = mathBlock.textContent; - console.log(text); mathBlock.innerHTML = katex.renderToString(text, { displayMode: true, throwOnError: false @@ -114,6 +112,9 @@ async function preprocessHTML(templateData) { export default { buildHTML }; function hasRequire() { - // eslint-disable-next-line no-undef - return typeof require === "function" && !IS_DESKTOP_APP; + return ( + typeof require === "function" && + // eslint-disable-next-line no-undef + (typeof IS_DESKTOP_APP === "undefined" || !IS_DESKTOP_APP) + ); }