GoonCord/src/lib/preinit.ts

25 lines
772 B
TypeScript
Raw Normal View History

2023-01-16 22:52:23 +00:00
// Hoist required modules
// This used to be in filters.ts, but things became convoluted
import { initThemes } from "@lib/themes";
2023-01-16 22:52:23 +00:00
// Early find logic
2023-02-14 18:28:27 +00:00
const basicFind = (prop: string) => Object.values(window.modules).find(m => m?.publicModule.exports?.[prop])?.publicModule?.exports;
2023-01-16 22:52:23 +00:00
// Hoist React on window
2023-02-26 22:56:36 +00:00
window.React = basicFind("createElement") as typeof import("react");
2023-01-16 22:52:23 +00:00
// Export ReactNative
2023-02-26 22:56:36 +00:00
export const ReactNative = basicFind("AppRegistry") as typeof import("react-native");
2023-01-16 22:52:23 +00:00
// Export chroma.js
export const chroma = basicFind("brewer") as typeof import("chroma-js");
// Themes
if (window.__vendetta_loader?.features.themes) {
try {
initThemes();
} catch (e) {
console.error("[Vendetta] Failed to initialize themes...", e);
}
}