From 88e4f357a4f726737deb7f5385e7ca8d7e4f166c Mon Sep 17 00:00:00 2001 From: Beef Date: Tue, 25 Oct 2022 23:50:18 +0100 Subject: [PATCH] [Init] Async-ify, for future use --- src/index.ts | 51 ++++++++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/src/index.ts b/src/index.ts index 3e2cb61..d84b1a4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,30 +8,35 @@ import initSettings from "@ui/settings"; import { patchLogHook } from "@lib/debug"; console.log("Hello from Vendetta!"); -let erroredOnLoad = false; -try { - initSettings(); - patchAssets(); - patchLogHook(); +async function init() { + let erroredOnLoad = false; - window.vendetta = { - patcher: patcher, - metro: { ...metro, common: common }, - logger: logger, - ui: { - assets: { - all: all, - find: find, - getAssetByID: getAssetByID, - getAssetByName: getAssetByName, - getAssetIDByName: getAssetIDByName, + try { + initSettings(); + patchAssets(); + patchLogHook(); + + window.vendetta = { + patcher: patcher, + metro: { ...metro, common: common }, + logger: logger, + ui: { + assets: { + all: all, + find: find, + getAssetByID: getAssetByID, + getAssetByName: getAssetByName, + getAssetIDByName: getAssetIDByName, + }, }, - }, - }; -} catch (e: Error | any) { - erroredOnLoad = true; - alert(`Vendetta failed to initialize...\n${e.stack || e.toString()}`); -} + }; + } catch (e: Error | any) { + erroredOnLoad = true; + alert(`Vendetta failed to initialize...\n${e.stack || e.toString()}`); + } + + if (!erroredOnLoad) logger.log("Vendetta is ready!"); +}; -if (!erroredOnLoad) logger.log("Vendetta is ready!"); \ No newline at end of file +init(); \ No newline at end of file