From 119060a43b9a42db2484259b85dd2f2a36921ad0 Mon Sep 17 00:00:00 2001 From: Beef Date: Sat, 4 Feb 2023 17:05:47 +0000 Subject: [PATCH] [Utils] Reorganise --- src/def.d.ts | 1 + src/lib/utils/index.ts | 6 ++++++ src/lib/windowObject.ts | 14 +++----------- tsconfig.json | 3 ++- 4 files changed, 12 insertions(+), 12 deletions(-) create mode 100644 src/lib/utils/index.ts diff --git a/src/def.d.ts b/src/def.d.ts index 68fb37a..1add166 100644 --- a/src/def.d.ts +++ b/src/def.d.ts @@ -235,6 +235,7 @@ interface VendettaObject { copyText: (content: string) => void; findInReactTree: (tree: { [key: string]: any }, filter: SearchFilter) => void; findInTree: (tree: { [key: string]: any }, filter: SearchFilter, options: FindInTreeOptions) => any; + safeFetch: (input: RequestInfo, options: RequestInit) => Promise; unfreeze: (obj: object) => object; }; debug: { diff --git a/src/lib/utils/index.ts b/src/lib/utils/index.ts new file mode 100644 index 0000000..abb4ad9 --- /dev/null +++ b/src/lib/utils/index.ts @@ -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"; \ No newline at end of file diff --git a/src/lib/windowObject.ts b/src/lib/windowObject.ts index 4a4870f..42c6b76 100644 --- a/src/lib/windowObject.ts +++ b/src/lib/windowObject.ts @@ -2,10 +2,6 @@ import { VendettaObject } from "@types"; import patcher from "@lib/patcher"; import logger from "@lib/logger"; 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 debug from "@lib/debug"; import * as plugins from "@lib/plugins"; @@ -16,6 +12,7 @@ import * as common from "@metro/common"; import * as components from "@ui/components"; import * as toasts from "@ui/toasts"; import * as assets from "@ui/assets"; +import * as utils from "@utils"; function without>(object: T, ...keys: string[]) { const cloned = { ...object }; @@ -28,13 +25,8 @@ export default async function windowObject(unloads: any[]): Promise