GoonCord/src/index.ts

66 lines
2 KiB
TypeScript
Raw Normal View History

2024-03-06 01:57:59 +08:00
import initFixes from "@core/fixes";
2024-03-09 07:43:04 +08:00
import { initFetchI18nStrings } from "@core/i18n";
2024-03-06 01:57:59 +08:00
import { initCorePlugins } from "@core/plugins";
import initSettings from "@core/ui/settings";
2024-03-11 15:04:11 +08:00
import { patchCommands } from "@lib/api/commands";
import { injectFluxInterceptor } from "@lib/api/flux";
import { removeFile, writeFile } from "@lib/api/native/fs";
import { isPyonLoader, isThemeSupported } from "@lib/api/native/loader";
import { FileManager } from "@lib/api/native/modules";
import { patchLogHook } from "@lib/debug";
import { updateFonts } from "@lib/managers/fonts";
2024-03-11 15:04:11 +08:00
import { initThemes, patchChatBackground } from "@lib/managers/themes";
2024-03-07 12:35:07 +08:00
import { logger } from "@lib/utils/logger";
2024-03-06 01:57:59 +08:00
import initSafeMode from "@ui/safeMode";
2024-05-20 15:36:33 +08:00
import { patchSettings } from "@ui/settings";
2022-10-18 23:04:55 +01:00
2024-03-11 15:04:11 +08:00
import * as lib from "./lib";
export default async () => {
2024-02-29 20:07:55 +08:00
// Themes
if (isThemeSupported()) {
try {
if (isPyonLoader()) {
if (FileManager.removeFile != null) {
removeFile("vendetta_theme.json", "");
} else {
writeFile("vendetta_theme.json", "null", "");
}
}
2024-03-11 15:04:11 +08:00
initThemes();
2024-02-29 20:07:55 +08:00
} catch (e) {
2024-03-01 14:25:43 +08:00
console.error("[Bunny] Failed to initialize themes...", e);
2024-02-29 20:07:55 +08:00
}
}
// Load everything in parallel
2024-03-11 15:04:11 +08:00
await Promise.all([
injectFluxInterceptor(),
patchSettings(),
patchLogHook(),
patchCommands(),
patchChatBackground(),
2024-05-20 15:36:33 +08:00
// initVendettaObject(),
2024-03-09 07:43:04 +08:00
initFetchI18nStrings(),
2024-03-08 01:06:25 +08:00
initSettings(),
initFixes(),
initSafeMode(),
2024-02-28 17:59:47 +08:00
initCorePlugins(),
2024-03-11 15:04:11 +08:00
]).then(
// Push them all to unloader
u => u.forEach(f => f && lib.unload.push(f))
);
2022-10-18 23:04:55 +01:00
// Assign window object
2024-03-11 15:04:11 +08:00
window.bunny = lib;
// Once done, load plugins
2024-05-20 15:36:33 +08:00
// lib.unload.push(await initPlugins());
// Update the fonts
updateFonts();
// We good :)
2024-03-01 14:25:43 +08:00
logger.log("Bunny is ready!");
2024-03-06 01:57:59 +08:00
};