[Utils] Reorganise
This commit is contained in:
parent
2a50814721
commit
119060a43b
4 changed files with 12 additions and 12 deletions
1
src/def.d.ts
vendored
1
src/def.d.ts
vendored
|
@ -235,6 +235,7 @@ interface VendettaObject {
|
||||||
copyText: (content: string) => void;
|
copyText: (content: string) => void;
|
||||||
findInReactTree: (tree: { [key: string]: any }, filter: SearchFilter) => void;
|
findInReactTree: (tree: { [key: string]: any }, filter: SearchFilter) => void;
|
||||||
findInTree: (tree: { [key: string]: any }, filter: SearchFilter, options: FindInTreeOptions) => any;
|
findInTree: (tree: { [key: string]: any }, filter: SearchFilter, options: FindInTreeOptions) => any;
|
||||||
|
safeFetch: (input: RequestInfo, options: RequestInit) => Promise<Response>;
|
||||||
unfreeze: (obj: object) => object;
|
unfreeze: (obj: object) => object;
|
||||||
};
|
};
|
||||||
debug: {
|
debug: {
|
||||||
|
|
6
src/lib/utils/index.ts
Normal file
6
src/lib/utils/index.ts
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
// Makes mass-importing utils cleaner, chosen over moving utils to one file
|
||||||
|
export { default as copyText } from "@utils/copyText";
|
||||||
|
export { default as findInReactTree } from "@utils/findInReactTree";
|
||||||
|
export { default as findInTree } from "@utils/findInTree";
|
||||||
|
export { default as safeFetch } from "@utils/safeFetch";
|
||||||
|
export { default as unfreeze } from "@utils/unfreeze";
|
|
@ -2,10 +2,6 @@ import { VendettaObject } from "@types";
|
||||||
import patcher from "@lib/patcher";
|
import patcher from "@lib/patcher";
|
||||||
import logger from "@lib/logger";
|
import logger from "@lib/logger";
|
||||||
import settings from "@lib/settings";
|
import settings from "@lib/settings";
|
||||||
import copyText from "@utils/copyText";
|
|
||||||
import findInReactTree from "@utils/findInReactTree";
|
|
||||||
import findInTree from "@utils/findInTree";
|
|
||||||
import unfreeze from "@utils/unfreeze";
|
|
||||||
import * as constants from "@lib/constants";
|
import * as constants from "@lib/constants";
|
||||||
import * as debug from "@lib/debug";
|
import * as debug from "@lib/debug";
|
||||||
import * as plugins from "@lib/plugins";
|
import * as plugins from "@lib/plugins";
|
||||||
|
@ -16,6 +12,7 @@ import * as common from "@metro/common";
|
||||||
import * as components from "@ui/components";
|
import * as components from "@ui/components";
|
||||||
import * as toasts from "@ui/toasts";
|
import * as toasts from "@ui/toasts";
|
||||||
import * as assets from "@ui/assets";
|
import * as assets from "@ui/assets";
|
||||||
|
import * as utils from "@utils";
|
||||||
|
|
||||||
function without<T extends Record<string, any>>(object: T, ...keys: string[]) {
|
function without<T extends Record<string, any>>(object: T, ...keys: string[]) {
|
||||||
const cloned = { ...object };
|
const cloned = { ...object };
|
||||||
|
@ -28,13 +25,8 @@ export default async function windowObject(unloads: any[]): Promise<VendettaObje
|
||||||
return {
|
return {
|
||||||
patcher: without(patcher, "unpatchAll"),
|
patcher: without(patcher, "unpatchAll"),
|
||||||
metro: { ...metro, common: { ...common } },
|
metro: { ...metro, common: { ...common } },
|
||||||
constants: { ...constants },
|
constants,
|
||||||
utils: {
|
utils,
|
||||||
copyText,
|
|
||||||
findInReactTree,
|
|
||||||
findInTree,
|
|
||||||
unfreeze,
|
|
||||||
},
|
|
||||||
debug: without(debug, "versionHash", "patchLogHook"),
|
debug: without(debug, "versionHash", "patchLogHook"),
|
||||||
ui: {
|
ui: {
|
||||||
components,
|
components,
|
||||||
|
|
|
@ -16,8 +16,9 @@
|
||||||
"@/*": ["src/*"],
|
"@/*": ["src/*"],
|
||||||
"@types": ["src/def.d.ts"],
|
"@types": ["src/def.d.ts"],
|
||||||
"@lib/*": ["src/lib/*"],
|
"@lib/*": ["src/lib/*"],
|
||||||
"@metro/*": ["src/lib/metro/*"],
|
"@utils": ["src/lib/utils/index.ts"],
|
||||||
"@utils/*": ["src/lib/utils/*"],
|
"@utils/*": ["src/lib/utils/*"],
|
||||||
|
"@metro/*": ["src/lib/metro/*"],
|
||||||
"@ui/*": ["src/ui/*"]
|
"@ui/*": ["src/ui/*"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue