[Cleanup] Small tidying
This commit is contained in:
parent
0fe5d30bbc
commit
715e6f9bc4
4 changed files with 11 additions and 10 deletions
|
@ -50,7 +50,7 @@ async function init() {
|
||||||
patchLogHook();
|
patchLogHook();
|
||||||
} catch (e: Error | any) {
|
} catch (e: Error | any) {
|
||||||
erroredOnLoad = true;
|
erroredOnLoad = true;
|
||||||
alert(`Vendetta failed to initialize...\n${e.stack || e.toString()}`);
|
alert(`Vendetta failed to initialize... ${e.stack || e.toString()}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!erroredOnLoad) logger.log("Vendetta is ready!");
|
if (!erroredOnLoad) logger.log("Vendetta is ready!");
|
||||||
|
|
|
@ -7,6 +7,11 @@ export const i18n = findByProps("Messages");
|
||||||
export const url = findByProps("openURL");
|
export const url = findByProps("openURL");
|
||||||
export const toasts = find(m => m.open && m.close && !m.startDrag && !m.init && !m.openReplay && !m.setAlwaysOnTop);
|
export const toasts = find(m => m.open && m.close && !m.startDrag && !m.init && !m.openReplay && !m.setAlwaysOnTop);
|
||||||
export const stylesheet = findByProps("createThemedStyleSheet");
|
export const stylesheet = findByProps("createThemedStyleSheet");
|
||||||
|
export const clipboard = findByProps("setString", "getString");
|
||||||
|
export const assets = findByProps("registerAsset");
|
||||||
|
export const navigation = findByProps("pushLazy");
|
||||||
|
export const navigationStack = findByProps("createStackNavigator");
|
||||||
|
export const NavigationNative = findByProps("NavigationContainer");
|
||||||
|
|
||||||
// React
|
// React
|
||||||
export const React = findByProps("createElement") as typeof import("react");
|
export const React = findByProps("createElement") as typeof import("react");
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
import { findByProps } from "@metro/filters";
|
import { clipboard } from "@metro/common";
|
||||||
|
|
||||||
const clipboard = findByProps("setString", "getString");
|
|
||||||
|
|
||||||
export default function copyText(content: string) {
|
export default function copyText(content: string) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -1,20 +1,18 @@
|
||||||
import { Asset, Assets } from "@types";
|
import { Asset, Assets } from "@types";
|
||||||
import { after } from "@lib/patcher";
|
import { after } from "@lib/patcher";
|
||||||
import { findByProps } from "@metro/filters";
|
import { assets } from "@metro/common";
|
||||||
|
|
||||||
const assetsModule = findByProps("registerAsset");
|
|
||||||
|
|
||||||
export const all: Assets = {};
|
export const all: Assets = {};
|
||||||
|
|
||||||
export default function patchAssets() {
|
export default function patchAssets() {
|
||||||
try {
|
try {
|
||||||
after("registerAsset", assetsModule, (args: Asset[], id: number) => {
|
after("registerAsset", assets, (args: Asset[], id: number) => {
|
||||||
const asset = args[0];
|
const asset = args[0];
|
||||||
all[asset.name] = { ...asset, id: id };
|
all[asset.name] = { ...asset, id: id };
|
||||||
});
|
});
|
||||||
|
|
||||||
for (let id = 1; ; id++) {
|
for (let id = 1; ; id++) {
|
||||||
const asset = assetsModule.getAssetByID(id);
|
const asset = assets.getAssetByID(id);
|
||||||
if (!asset) break;
|
if (!asset) break;
|
||||||
if (all[asset.name]) continue;
|
if (all[asset.name]) continue;
|
||||||
all[asset.name] = { ...asset, id: id };
|
all[asset.name] = { ...asset, id: id };
|
||||||
|
@ -24,5 +22,5 @@ export default function patchAssets() {
|
||||||
|
|
||||||
export const find = (filter: (a: any) => void): Asset | null | undefined => Object.values(all).find(filter);
|
export const find = (filter: (a: any) => void): Asset | null | undefined => Object.values(all).find(filter);
|
||||||
export const getAssetByName = (name: string): Asset => all[name];
|
export const getAssetByName = (name: string): Asset => all[name];
|
||||||
export const getAssetByID = (id: number): Asset => assetsModule.getAssetByID(id);
|
export const getAssetByID = (id: number): Asset => assets.getAssetByID(id);
|
||||||
export const getAssetIDByName = (name: string) => all[name]?.id;
|
export const getAssetIDByName = (name: string) => all[name]?.id;
|
Loading…
Reference in a new issue