[Init] Implement error dialog for failed mod loading (#37)
* [Main] Implement error dialog for failed mod loading * [Main] Initialize Vendetta from entry.js
This commit is contained in:
parent
388b306e88
commit
7dc0b1286a
3 changed files with 38 additions and 25 deletions
|
@ -13,7 +13,7 @@ const commit = (await exec("git rev-parse HEAD")).stdout.trim().substring(0, 7)
|
|||
|
||||
try {
|
||||
await build({
|
||||
entryPoints: ["./src/index.ts"],
|
||||
entryPoints: ["./entry.js"],
|
||||
outfile: "./dist/vendetta.js",
|
||||
minify: true,
|
||||
bundle: true,
|
||||
|
@ -46,10 +46,12 @@ try {
|
|||
define: {
|
||||
__vendettaVersion: `"${commit}"`,
|
||||
},
|
||||
footer: {
|
||||
js: "//# sourceURL=Vendetta",
|
||||
},
|
||||
legalComments: "none",
|
||||
});
|
||||
|
||||
await fs.appendFile("./dist/vendetta.js", "//# sourceURL=Vendetta");
|
||||
console.log("Build successful!");
|
||||
} catch (e) {
|
||||
console.error("Build failed...", e);
|
||||
|
|
18
entry.js
Normal file
18
entry.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
// This logs in the native logging implementation, e.g. logcat
|
||||
console.log("Hello from Vendetta!");
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
await (await import("./src/index.ts")).default();
|
||||
} catch (ex) {
|
||||
const dialog = [
|
||||
"Failed to load Vendetta!\n",
|
||||
`Build Number: ${nativeModuleProxy.InfoDictionaryManager.Build}`,
|
||||
`Vendetta: ${__vendettaVersion}`,
|
||||
ex?.stack || ex.toString(),
|
||||
].join("\n");
|
||||
|
||||
alert(dialog);
|
||||
console.error(ex?.stack || ex.toString());
|
||||
}
|
||||
})();
|
|
@ -7,11 +7,7 @@ import initFixes from "@lib/fixes";
|
|||
import logger from "@lib/logger";
|
||||
import windowObject from "@lib/windowObject";
|
||||
|
||||
// This logs in the native logging implementation, e.g. logcat
|
||||
console.log("Hello from Vendetta!");
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
export default async () => {
|
||||
// Load everything in parallel
|
||||
const unloads = await Promise.all([
|
||||
patchLogHook(),
|
||||
|
@ -29,7 +25,4 @@ console.log("Hello from Vendetta!");
|
|||
|
||||
// We good :)
|
||||
logger.log("Vendetta is ready!");
|
||||
} catch (e: any) {
|
||||
alert(`Vendetta failed to initialize... ${e.stack || e.toString()}`);
|
||||
}
|
||||
})();
|
Loading…
Reference in a new issue