diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b7a95cf05..f27870705 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -42,7 +42,7 @@ jobs: - name: Clean up obsolete files run: | - rm -rf dist/extension* Vencord.user.css + rm -rf dist/extension* Vencord.user.css vencordDesktopRenderer.css vencordDesktopRenderer.css.map - name: Get some values needed for the release id: release_values diff --git a/scripts/build/build.mjs b/scripts/build/build.mjs index 70a05cf9d..a4b06f536 100755 --- a/scripts/build/build.mjs +++ b/scripts/build/build.mjs @@ -48,6 +48,7 @@ const sourceMapFooter = s => watch ? "" : `//# sourceMappingURL=vencord://${s}.j const sourcemap = watch ? "inline" : "external"; await Promise.all([ + // common preload esbuild.build({ ...nodeCommonOpts, entryPoints: ["src/preload.ts"], @@ -55,12 +56,19 @@ await Promise.all([ footer: { js: "//# sourceURL=VencordPreload\n" + sourceMapFooter("preload") }, sourcemap, }), + + // Discord Desktop main & renderer esbuild.build({ ...nodeCommonOpts, - entryPoints: ["src/patcher.ts"], + entryPoints: ["src/main/index.ts"], outfile: "dist/patcher.js", footer: { js: "//# sourceURL=VencordPatcher\n" + sourceMapFooter("patcher") }, sourcemap, + define: { + ...defines, + IS_DISCORD_DESKTOP: true, + IS_VENCORD_DESKTOP: false + } }), esbuild.build({ ...commonOpts, @@ -77,7 +85,43 @@ await Promise.all([ ], define: { ...defines, - IS_WEB: false + IS_WEB: false, + IS_DISCORD_DESKTOP: true, + IS_VENCORD_DESKTOP: false + } + }), + + // Vencord Desktop main & renderer + esbuild.build({ + ...nodeCommonOpts, + entryPoints: ["src/main/index.ts"], + outfile: "dist/vencordDesktopMain.js", + footer: { js: "//# sourceURL=VencordDesktopMain\n" + sourceMapFooter("vencordDesktopMain") }, + sourcemap, + define: { + ...defines, + IS_DISCORD_DESKTOP: false, + IS_VENCORD_DESKTOP: true + } + }), + esbuild.build({ + ...commonOpts, + entryPoints: ["src/Vencord.ts"], + outfile: "dist/vencordDesktopRenderer.js", + format: "iife", + target: ["esnext"], + footer: { js: "//# sourceURL=VencordDesktopRenderer\n" + sourceMapFooter("vencordDesktopRenderer") }, + globalName: "Vencord", + sourcemap, + plugins: [ + globPlugins, + ...commonOpts.plugins + ], + define: { + ...defines, + IS_WEB: false, + IS_DISCORD_DESKTOP: false, + IS_VENCORD_DESKTOP: true } }), ]).catch(err => { diff --git a/src/Vencord.ts b/src/Vencord.ts index 00f8a58c0..73b53e844 100644 --- a/src/Vencord.ts +++ b/src/Vencord.ts @@ -30,7 +30,7 @@ import "./webpack/patchWebpack"; import { showNotification } from "./api/Notifications"; import { PlainSettings, Settings } from "./api/settings"; import { patches, PMLogger, startAllPlugins } from "./plugins"; -import { checkForUpdates, rebuild, update, UpdateLogger } from "./utils/updater"; +import { checkForUpdates, rebuild, update,UpdateLogger } from "./utils/updater"; import { onceReady } from "./webpack"; import { SettingsRouter } from "./webpack/common"; @@ -56,8 +56,12 @@ async function init() { permanent: true, noPersist: true, onClick() { - if (needsFullRestart) - window.DiscordNative.app.relaunch(); + if (needsFullRestart) { + if (IS_DISCORD_DESKTOP) + window.DiscordNative.app.relaunch(); + else + window.VencordDesktop.app.relaunch(); + } else location.reload(); } @@ -96,7 +100,7 @@ async function init() { init(); -if (!IS_WEB && Settings.winNativeTitleBar && navigator.platform.toLowerCase().startsWith("win")) { +if (IS_DISCORD_DESKTOP && Settings.winNativeTitleBar && navigator.platform.toLowerCase().startsWith("win")) { document.addEventListener("DOMContentLoaded", () => { document.head.append(Object.assign(document.createElement("style"), { id: "vencord-native-titlebar-style", diff --git a/src/components/VencordSettings/Updater.tsx b/src/components/VencordSettings/Updater.tsx index 3c3eb91b3..15a8c87a3 100644 --- a/src/components/VencordSettings/Updater.tsx +++ b/src/components/VencordSettings/Updater.tsx @@ -24,6 +24,7 @@ import { handleComponentFailed } from "@components/handleComponentFailed"; import { Link } from "@components/Link"; import { Margins } from "@utils/margins"; import { classes, useAwaiter } from "@utils/misc"; +import { relaunch } from "@utils/native"; import { changes, checkForUpdates, getRepo, isNewer, rebuild, update, updateError, UpdateLogger } from "@utils/updater"; import { Alerts, Button, Card, Forms, Parser, React, Switch, Toasts } from "@webpack/common"; @@ -133,7 +134,7 @@ function Updatable(props: CommonProps) { cancelText: "Not now!", onConfirm() { if (needFullRestart) - window.DiscordNative.app.relaunch(); + relaunch(); else location.reload(); r(); diff --git a/src/components/VencordSettings/VencordTab.tsx b/src/components/VencordSettings/VencordTab.tsx index 7113421a6..8b8696843 100644 --- a/src/components/VencordSettings/VencordTab.tsx +++ b/src/components/VencordSettings/VencordTab.tsx @@ -26,6 +26,7 @@ import { ErrorCard } from "@components/ErrorCard"; import IpcEvents from "@utils/IpcEvents"; import { Margins } from "@utils/margins"; import { identity, useAwaiter } from "@utils/misc"; +import { relaunch } from "@utils/native"; import { Button, Card, Forms, React, Select, Slider, Switch } from "@webpack/common"; const cl = classNameFactory("vc-settings-"); @@ -100,7 +101,7 @@ function VencordSettings() { ) : ( @@ -111,6 +112,7 @@ function VencordSettings() { Open QuickCSS File