GoonCord/src/index.ts
Gabriel.W.Jackson 0a61404132
feat: Rebrand to Revenge (#51)
Co-authored-by: PalmDevs <git@palmdevs.me>
Co-authored-by: Palm <contact@palmdevs.me>
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
2024-10-19 20:54:15 +07:00

72 lines
2.1 KiB
TypeScript

import initFixes from "@core/fixes";
import { initFetchI18nStrings } from "@core/i18n";
import initSettings from "@core/ui/settings";
import { initVendettaObject } from "@core/vendetta/api";
import { VdPluginManager } from "@core/vendetta/plugins";
import { updateFonts } from "@lib/addons/fonts";
import { initPlugins, updatePlugins } from "@lib/addons/plugins";
import { initThemes, patchChatBackground } from "@lib/addons/themes";
import { patchCommands } from "@lib/api/commands";
import { patchLogHook } from "@lib/api/debug";
import { injectFluxInterceptor } from "@lib/api/flux";
import { writeFile } from "@lib/api/native/fs";
import { isPyonLoader, isThemeSupported } from "@lib/api/native/loader";
import { patchJsx } from "@lib/api/react/jsx";
import { logger } from "@lib/utils/logger";
import initSafeMode from "@ui/safeMode";
import { patchSettings } from "@ui/settings";
import * as lib from "./lib";
function maybeLoadThemes() {
if (!isThemeSupported()) return;
try {
if (isPyonLoader()) {
writeFile("../vendetta_theme.json", "null");
}
initThemes();
} catch (e) {
console.error("Failed to initialize themes", e);
}
}
export default async () => {
maybeLoadThemes();
// Load everything in parallel
await Promise.all([
injectFluxInterceptor(),
patchSettings(),
patchLogHook(),
patchCommands(),
patchChatBackground(),
patchJsx(),
initVendettaObject(),
initFetchI18nStrings(),
initSettings(),
initFixes(),
initSafeMode(),
updatePlugins()
]).then(
// Push them all to unloader
u => u.forEach(f => f && lib.unload.push(f))
);
// Assign window object
window.bunny = lib;
// Once done, load Vendetta plugins
VdPluginManager.initPlugins()
.then(u => lib.unload.push(u))
.catch(() => alert("Failed to initialize Vendetta plugins"));
// And then, load Bunny plugins
initPlugins();
// Update the fonts
updateFonts();
// We good :)
logger.log("Revenge is ready!");
};