2024-10-21 17:37:07 +08:00
|
|
|
import patchErrorBoundary from "@core/debug/patches/patchErrorBoundary";
|
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-10-13 14:03:20 +08:00
|
|
|
import { updateFonts } from "@lib/addons/fonts";
|
|
|
|
|
import { initPlugins, updatePlugins } from "@lib/addons/plugins";
|
2024-10-21 21:35:02 +08:00
|
|
|
import { initThemes } from "@lib/addons/themes";
|
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-10-13 14:03:20 +08:00
|
|
|
import { writeFile } from "@lib/api/native/fs";
|
2024-04-15 22:56:08 +08:00
|
|
|
import { isPyonLoader, isThemeSupported } from "@lib/api/native/loader";
|
2024-10-13 14:03:20 +08:00
|
|
|
import { patchJsx } from "@lib/api/react/jsx";
|
2024-03-07 12:35:07 +08:00
|
|
|
import { logger } from "@lib/utils/logger";
|
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";
|
|
|
|
|
|
2024-10-13 14:03:20 +08:00
|
|
|
function maybeLoadThemes() {
|
|
|
|
|
if (!isThemeSupported()) return;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
if (isPyonLoader()) {
|
|
|
|
|
writeFile("../vendetta_theme.json", "null");
|
2024-02-29 20:07:55 +08:00
|
|
|
}
|
2024-10-13 14:03:20 +08:00
|
|
|
initThemes();
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error("Failed to initialize themes", e);
|
2024-02-29 20:07:55 +08:00
|
|
|
}
|
2024-10-13 14:03:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default async () => {
|
|
|
|
|
maybeLoadThemes();
|
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(),
|
2024-10-13 11:45:52 +08:00
|
|
|
patchJsx(),
|
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-10-21 17:37:07 +08:00
|
|
|
patchErrorBoundary(),
|
2024-10-13 14:03:20 +08:00
|
|
|
updatePlugins()
|
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-10-13 14:03:20 +08:00
|
|
|
// And then, load Bunny plugins
|
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
|
|
|
};
|