2023-01-16 22:52:23 +00:00
|
|
|
// Hoist required modules
|
2024-02-23 00:33:40 +08:00
|
|
|
|
|
|
|
|
import { isThemeSupported } from "./loader";
|
|
|
|
|
|
2023-01-16 22:52:23 +00:00
|
|
|
// This used to be in filters.ts, but things became convoluted
|
2023-08-28 08:36:19 +08:00
|
|
|
const basicFind = (filter: (m: any) => any | string) => {
|
|
|
|
|
for (const key in window.modules) {
|
|
|
|
|
const exp = window.modules[key]?.publicModule.exports;
|
|
|
|
|
if (exp && filter(exp)) return exp;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-16 22:52:23 +00:00
|
|
|
// Hoist React on window
|
2023-08-28 08:36:19 +08:00
|
|
|
window.React = basicFind(m => m.createElement) as typeof import("react");
|
2023-01-16 22:52:23 +00:00
|
|
|
|
|
|
|
|
// Export ReactNative
|
2023-08-28 08:36:19 +08:00
|
|
|
export const ReactNative = basicFind(m => m.AppRegistry) as typeof import("react-native");
|
2023-01-16 22:52:23 +00:00
|
|
|
|
2023-03-23 05:02:53 +08:00
|
|
|
// Export chroma.js
|
2023-08-28 08:36:19 +08:00
|
|
|
export const chroma = basicFind(m => m.brewer) as typeof import("chroma-js");
|
2023-03-23 05:02:53 +08:00
|
|
|
|
2023-03-17 21:58:37 +00:00
|
|
|
// Themes
|
2024-02-23 00:33:40 +08:00
|
|
|
if (isThemeSupported()) {
|
2023-03-17 21:58:37 +00:00
|
|
|
try {
|
2024-02-11 22:44:16 +08:00
|
|
|
require("@lib/themes").initThemes();
|
2023-03-17 21:58:37 +00:00
|
|
|
} catch (e) {
|
|
|
|
|
console.error("[Vendetta] Failed to initialize themes...", e);
|
|
|
|
|
}
|
|
|
|
|
}
|