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 initSettings from "@core/ui/settings";
|
2024-07-20 11:23:00 +08:00
|
|
|
import { initVendettaObject } from "@core/vendetta/api";
|
|
|
|
|
import { VdPluginManager } from "@core/vendetta/plugins";
|
2024-03-11 15:04:11 +08:00
|
|
|
import { patchCommands } from "@lib/api/commands";
|
2024-07-30 07:20:22 +08:00
|
|
|
import { patchLogHook } from "@lib/api/debug";
|
2024-03-11 15:04:11 +08:00
|
|
|
import { injectFluxInterceptor } from "@lib/api/flux";
|
2024-04-16 01:15:03 +08:00
|
|
|
import { removeFile, writeFile } from "@lib/api/native/fs";
|
2024-04-15 22:56:08 +08:00
|
|
|
import { isPyonLoader, isThemeSupported } from "@lib/api/native/loader";
|
|
|
|
|
import { FileManager } from "@lib/api/native/modules";
|
2024-07-30 00:18:01 +08:00
|
|
|
import { updateFonts } from "@lib/fonts";
|
2024-09-03 16:03:07 +08:00
|
|
|
import { initPlugins } from "@lib/plugins";
|
2024-07-30 00:18:01 +08:00
|
|
|
import { initThemes, patchChatBackground } from "@lib/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";
|
|
|
|
|
|
2023-03-16 00:36:12 +08:00
|
|
|
export default async () => {
|
2024-02-29 20:07:55 +08:00
|
|
|
// Themes
|
|
|
|
|
if (isThemeSupported()) {
|
|
|
|
|
try {
|
2024-04-16 01:15:03 +08:00
|
|
|
if (isPyonLoader()) {
|
|
|
|
|
if (FileManager.removeFile != null) {
|
|
|
|
|
removeFile("vendetta_theme.json", "");
|
|
|
|
|
} else {
|
|
|
|
|
writeFile("vendetta_theme.json", "null", "");
|
|
|
|
|
}
|
2024-04-15 22:56:08 +08:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-16 00:36:12 +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 16:39:51 +08:00
|
|
|
initVendettaObject(),
|
2024-03-09 07:43:04 +08:00
|
|
|
initFetchI18nStrings(),
|
2024-03-08 01:06:25 +08:00
|
|
|
initSettings(),
|
2023-03-16 00:36:12 +08:00
|
|
|
initFixes(),
|
2024-09-03 16:03:07 +08:00
|
|
|
initSafeMode()
|
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
|
|
|
|
2023-03-16 00:36:12 +08:00
|
|
|
// Assign window object
|
2024-03-11 15:04:11 +08:00
|
|
|
window.bunny = lib;
|
2023-01-01 21:10:09 +00:00
|
|
|
|
2024-07-20 11:23:00 +08:00
|
|
|
// Once done, load Vendetta plugins
|
|
|
|
|
VdPluginManager.initPlugins()
|
2024-06-25 02:28:04 +08:00
|
|
|
.then(u => lib.unload.push(u))
|
2024-07-20 11:23:00 +08:00
|
|
|
.catch(() => alert("Failed to initialize Vendetta plugins"));
|
2023-02-04 02:30:46 +00:00
|
|
|
|
2024-07-22 00:17:17 +08:00
|
|
|
initPlugins();
|
|
|
|
|
|
2024-05-18 02:55:20 +08:00
|
|
|
// Update the fonts
|
|
|
|
|
updateFonts();
|
|
|
|
|
|
2023-03-16 00:36:12 +08:00
|
|
|
// We good :)
|
2024-03-01 14:25:43 +08:00
|
|
|
logger.log("Bunny is ready!");
|
2024-03-06 01:57:59 +08:00
|
|
|
};
|