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";
|
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-04-03 07:40:35 +08:00
|
|
|
import { patchLogHook } from "@lib/debug";
|
2024-05-18 02:55:20 +08:00
|
|
|
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";
|
|
|
|
|
|
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 15:36:33 +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(),
|
2023-04-13 18:42:14 +00:00
|
|
|
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
|
|
|
|
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
|
|
|
|
2023-03-16 00:36:12 +08:00
|
|
|
// Once done, load plugins
|
2024-05-20 15:36:33 +08:00
|
|
|
// lib.unload.push(await initPlugins());
|
2023-02-04 02:30:46 +00:00
|
|
|
|
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
|
|
|
};
|