[Global] Code cleanup pass
This commit is contained in:
parent
69c2544b99
commit
7d36903b2c
19 changed files with 47 additions and 73 deletions
|
@ -7,19 +7,16 @@ import logger from "@lib/logger";
|
|||
export let socket: WebSocket;
|
||||
|
||||
export function connectToDebugger(url: string) {
|
||||
if (socket !== undefined && socket.readyState !== WebSocket.CLOSED) {
|
||||
socket.close();
|
||||
}
|
||||
if (socket !== undefined && socket.readyState !== WebSocket.CLOSED) socket.close();
|
||||
|
||||
if (url === "") {
|
||||
if (!url) {
|
||||
showToast("Invalid debugger URL!", getAssetIDByName("Small"));
|
||||
return;
|
||||
}
|
||||
|
||||
socket = new WebSocket(`ws://${url}`);
|
||||
|
||||
|
||||
socket.addEventListener("open", () => showToast("Connected to debugger.", getAssetIDByName("Check")));
|
||||
|
||||
socket.addEventListener("message", (message: any) => {
|
||||
try {
|
||||
(0, eval)(message.data);
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { Emitter, EmitterEvent, EmitterListener, EmitterListenerData, EmitterListeners } from "@types";
|
||||
|
||||
export const Events = Object.freeze({
|
||||
GET: "GET",
|
||||
SET: "SET",
|
||||
DEL: "DEL",
|
||||
});
|
||||
export enum Events {
|
||||
GET = "GET",
|
||||
SET = "SET",
|
||||
DEL = "DEL",
|
||||
};
|
||||
|
||||
export default function createEmitter(): Emitter {
|
||||
return {
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
const basicFind = (prop: string) => Object.values(window.modules).find(m => m?.publicModule.exports?.[prop])?.publicModule?.exports;
|
||||
|
||||
// Hoist React on window
|
||||
window.React = basicFind("createElement") as typeof import("react");;
|
||||
window.React = basicFind("createElement") as typeof import("react");
|
||||
|
||||
// Export ReactNative
|
||||
export const ReactNative = basicFind("Text") as typeof import("react-native");
|
||||
export const ReactNative = basicFind("AppRegistry") as typeof import("react-native");
|
||||
|
||||
// Export Discord's constants
|
||||
export const constants = basicFind("AbortCodes");
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { createFileBackend, createMMKVBackend, createStorage, wrapSync } from "@lib/storage";
|
||||
import { LoaderConfig, Settings } from "@types";
|
||||
import { createFileBackend, createMMKVBackend, createStorage, wrapSync } from "@lib/storage";
|
||||
|
||||
export default wrapSync(createStorage<Settings>(createMMKVBackend("VENDETTA_SETTINGS")));
|
||||
export const loaderConfig = wrapSync(createStorage<LoaderConfig>(createFileBackend("vendetta_loader.json")));
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import { clipboard } from "@metro/common";
|
||||
|
||||
// TODO: Remove/deprecate this, the clipboard module works the same way.
|
||||
|
||||
export default function copyText(content: string) {
|
||||
try {
|
||||
clipboard.setString(content);
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
// https://stackoverflow.com/a/68339174
|
||||
|
||||
export default function unfreeze(obj: object) {
|
||||
if (Object.isFrozen(obj)) {
|
||||
return Object.assign({}, obj);
|
||||
}
|
||||
if (Object.isFrozen(obj)) return Object.assign({}, obj);
|
||||
return obj;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue