GoonCord/src/lib/windowObject.ts
Beef 85a83e4873
[Themes] Implement (#34)
* [Themes] Initial work

* [Themes] Read from __vendetta_themes and early UI (#36)

* [Themes] Read from `__vendetta_themes`

* [Themes] Save as JSON and native theming

* [Themes] Basic UI

* [Themes] Merge processed theme data

* [Themes] Import ReactNative from `@lib/preinit`, oraganize imports

* [Themes] Some minor cleanup

* [Themes] UI overhaul

* [Themes] Minor adjustments

* [Themes] Implement updates, make UI reactive-ish

* [Themes] Move to new format

* [Themes > UI] Last-minute ThemeCard changes

* [Themes] Properly support AMOLED

---------

Co-authored-by: Amsyar Rasyiq <82711525+amsyarasyiq@users.noreply.github.com>
2023-03-17 21:58:37 +00:00

55 lines
1.7 KiB
TypeScript

import { VendettaObject } from "@types";
import patcher from "@lib/patcher";
import logger from "@lib/logger";
import settings, { loaderConfig } from "@lib/settings";
import * as constants from "@lib/constants";
import * as debug from "@lib/debug";
import * as plugins from "@lib/plugins";
import * as themes from "@lib/themes";
import * as commands from "@lib/commands";
import * as storage from "@lib/storage";
import * as metro from "@metro/filters";
import * as common from "@metro/common";
import * as components from "@ui/components";
import * as toasts from "@ui/toasts";
import * as alerts from "@ui/alerts";
import * as assets from "@ui/assets";
import * as color from "@ui/color";
import * as utils from "@utils";
function without<T extends Record<string, any>>(object: T, ...keys: string[]) {
const cloned = { ...object };
keys.forEach((k) => delete cloned[k]);
return cloned;
}
export default async (unloads: any[]): Promise<VendettaObject> => ({
patcher: without(patcher, "unpatchAll"),
metro: { ...metro, common: { ...common } },
constants,
utils,
debug: without(debug, "versionHash", "patchLogHook"),
ui: {
components,
toasts,
alerts,
assets,
...color,
},
plugins: without(plugins, "initPlugins"),
themes: without(themes, "initThemes"),
commands: without(commands, "patchCommands"),
storage,
settings,
loader: {
identity: window.__vendetta_loader,
config: loaderConfig,
},
logger,
version: debug.versionHash,
unload: () => {
unloads.filter(i => typeof i === "function").forEach(p => p());
// @ts-expect-error explode
delete window.vendetta;
}
});