2023-02-04 02:30:46 +00:00
|
|
|
import { VendettaObject } from "@types";
|
|
|
|
|
import patcher from "@lib/patcher";
|
|
|
|
|
import logger from "@lib/logger";
|
2023-02-06 08:48:55 +01:00
|
|
|
import settings, { loaderConfig } from "@lib/settings";
|
2023-02-04 02:30:46 +00:00
|
|
|
import * as constants from "@lib/constants";
|
|
|
|
|
import * as debug from "@lib/debug";
|
|
|
|
|
import * as plugins from "@lib/plugins";
|
|
|
|
|
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 assets from "@ui/assets";
|
2023-02-04 17:05:47 +00:00
|
|
|
import * as utils from "@utils";
|
2023-02-04 02:30:46 +00:00
|
|
|
|
|
|
|
|
function without<T extends Record<string, any>>(object: T, ...keys: string[]) {
|
|
|
|
|
const cloned = { ...object };
|
|
|
|
|
keys.forEach((k) => delete cloned[k]);
|
|
|
|
|
return cloned;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// I wish Hermes let me do async arrow functions
|
|
|
|
|
export default async function windowObject(unloads: any[]): Promise<VendettaObject> {
|
|
|
|
|
return {
|
|
|
|
|
patcher: without(patcher, "unpatchAll"),
|
|
|
|
|
metro: { ...metro, common: { ...common } },
|
2023-02-04 17:05:47 +00:00
|
|
|
constants,
|
|
|
|
|
utils,
|
2023-02-04 02:30:46 +00:00
|
|
|
debug: without(debug, "versionHash", "patchLogHook"),
|
|
|
|
|
ui: {
|
|
|
|
|
components,
|
|
|
|
|
toasts,
|
|
|
|
|
assets,
|
|
|
|
|
},
|
|
|
|
|
plugins: without(plugins, "initPlugins"),
|
|
|
|
|
commands: without(commands, "patchCommands"),
|
|
|
|
|
storage,
|
|
|
|
|
settings,
|
2023-02-06 08:48:55 +01:00
|
|
|
loader: {
|
|
|
|
|
identity: window.__vendetta_loader,
|
|
|
|
|
config: loaderConfig,
|
|
|
|
|
},
|
2023-02-04 02:30:46 +00:00
|
|
|
logger,
|
|
|
|
|
version: debug.versionHash,
|
|
|
|
|
unload: () => {
|
|
|
|
|
unloads.filter(i => typeof i === "function").forEach(p => p());
|
|
|
|
|
// @ts-expect-error explode
|
|
|
|
|
delete window.vendetta;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-02-06 08:48:55 +01:00
|
|
|
}
|