Merge remote-tracking branch 'upstream/dev' into dev

This commit is contained in:
thororen1234 2025-02-12 15:43:10 -05:00
commit 67bacaf855
No known key found for this signature in database
20 changed files with 775 additions and 715 deletions

View file

@ -17,41 +17,44 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import esbuild from "esbuild";
// @ts-check
import { createPackage } from "@electron/asar";
import { readdir, writeFile } from "fs/promises";
import { dirname, join } from "path";
import { fileURLToPath } from "url";
import { BUILD_TIMESTAMP, commonOpts, exists, globPlugins, IS_DEV, IS_REPORTER, IS_COMPANION_TEST, IS_STANDALONE, IS_UPDATER_DISABLED, resolvePluginName, VERSION, watch } from "./common.mjs";
import { BUILD_TIMESTAMP, commonOpts, exists, globPlugins, IS_DEV, IS_REPORTER, IS_COMPANION_TEST, IS_STANDALONE, IS_UPDATER_DISABLED, resolvePluginName, VERSION, commonRendererPlugins, watch, buildOrWatchAll, stringifyValues } from "./common.mjs";
const defines = {
IS_STANDALONE: String(IS_STANDALONE),
IS_DEV: String(IS_DEV),
IS_REPORTER: String(IS_REPORTER),
IS_COMPANION_TEST: String(IS_COMPANION_TEST),
IS_UPDATER_DISABLED: String(IS_UPDATER_DISABLED),
IS_WEB: "false",
IS_EXTENSION: "false",
VERSION: JSON.stringify(VERSION),
BUILD_TIMESTAMP: String(BUILD_TIMESTAMP)
};
const defines = stringifyValues({
IS_STANDALONE,
IS_DEV,
IS_REPORTER,
IS_COMPANION_TEST,
IS_UPDATER_DISABLED,
IS_WEB: false,
IS_EXTENSION: false,
VERSION,
BUILD_TIMESTAMP
});
if (defines.IS_STANDALONE === "false")
if (defines.IS_STANDALONE === "false") {
// If this is a local build (not standalone), optimize
// for the specific platform we're on
defines["process.platform"] = JSON.stringify(process.platform);
}
/**
* @type {esbuild.BuildOptions}
* @type {import("esbuild").BuildOptions}
*/
const nodeCommonOpts = {
...commonOpts,
define: defines,
format: "cjs",
platform: "node",
target: ["esnext"],
external: ["electron", "original-fs", "~pluginNatives", ...commonOpts.external],
define: defines
// @ts-ignore this is never undefined
external: ["electron", "original-fs", "~pluginNatives", ...commonOpts.external]
};
const sourceMapFooter = s => watch ? "" : `//# sourceMappingURL=vencord://${s}.js.map`;
@ -105,26 +108,28 @@ const globNativesPlugin = {
}
};
await Promise.all([
/** @type {import("esbuild").BuildOptions[]} */
const buildConfigs = ([
// Discord Desktop main & renderer & preload
esbuild.build({
{
...nodeCommonOpts,
entryPoints: [join(dirname(fileURLToPath(import.meta.url)), "../../src/main/index.ts")],
outfile: "dist/desktop/patcher.js",
footer: { js: "//# sourceURL=VencordPatcher\n" + sourceMapFooter("patcher") },
sourcemap,
plugins: [
// @ts-ignore this is never undefined
...nodeCommonOpts.plugins,
globNativesPlugin
],
define: {
...defines,
IS_DISCORD_DESKTOP: "true",
IS_VESKTOP: "false",
IS_EQUIBOP: "false"
},
plugins: [
...nodeCommonOpts.plugins,
globNativesPlugin
]
}),
esbuild.build({
}
},
{
...commonOpts,
entryPoints: [join(dirname(fileURLToPath(import.meta.url)), "../../src/Vencord.ts")],
outfile: "dist/desktop/renderer.js",
@ -143,8 +148,8 @@ await Promise.all([
IS_VESKTOP: "false",
IS_EQUIBOP: "false"
}
}),
esbuild.build({
},
{
...nodeCommonOpts,
entryPoints: [join(dirname(fileURLToPath(import.meta.url)), "../../src/preload.ts")],
outfile: "dist/desktop/preload.js",
@ -156,27 +161,27 @@ await Promise.all([
IS_VESKTOP: "false",
IS_EQUIBOP: "false"
}
}),
},
// Equicord Desktop main & renderer & preload
esbuild.build({
// Vencord Desktop main & renderer & preload
{
...nodeCommonOpts,
entryPoints: [join(dirname(fileURLToPath(import.meta.url)), "../../src/main/index.ts")],
outfile: "dist/equibop/main.js",
footer: { js: "//# sourceURL=VencordMain\n" + sourceMapFooter("main") },
sourcemap,
plugins: [
...nodeCommonOpts.plugins,
globNativesPlugin
],
define: {
...defines,
IS_DISCORD_DESKTOP: "false",
IS_VESKTOP: "false",
IS_EQUIBOP: "true"
},
plugins: [
...nodeCommonOpts.plugins,
globNativesPlugin
]
}),
esbuild.build({
}
},
{
...commonOpts,
entryPoints: [join(dirname(fileURLToPath(import.meta.url)), "../../src/Vencord.ts")],
outfile: "dist/equibop/renderer.js",
@ -195,8 +200,8 @@ await Promise.all([
IS_VESKTOP: "false",
IS_EQUIBOP: "true"
}
}),
esbuild.build({
},
{
...nodeCommonOpts,
entryPoints: [join(dirname(fileURLToPath(import.meta.url)), "../../src/preload.ts")],
outfile: "dist/equibop/preload.js",
@ -208,14 +213,10 @@ await Promise.all([
IS_VESKTOP: "false",
IS_EQUIBOP: "true"
}
}),
]).catch(err => {
console.error("Build failed");
console.error(err.message);
// make ci fail
if (!commonOpts.watch)
process.exitCode = 1;
});
}
]);
await buildOrWatchAll(buildConfigs);
await Promise.all([
writeFile("dist/desktop/package.json", JSON.stringify({