[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 {
|
try {
|
||||||
await build({
|
await build({
|
||||||
entryPoints: ["./src/index.ts"],
|
entryPoints: ["./entry.js"],
|
||||||
outfile: "./dist/vendetta.js",
|
outfile: "./dist/vendetta.js",
|
||||||
minify: true,
|
minify: true,
|
||||||
bundle: true,
|
bundle: true,
|
||||||
|
@ -46,10 +46,12 @@ try {
|
||||||
define: {
|
define: {
|
||||||
__vendettaVersion: `"${commit}"`,
|
__vendettaVersion: `"${commit}"`,
|
||||||
},
|
},
|
||||||
|
footer: {
|
||||||
|
js: "//# sourceURL=Vendetta",
|
||||||
|
},
|
||||||
legalComments: "none",
|
legalComments: "none",
|
||||||
});
|
});
|
||||||
|
|
||||||
await fs.appendFile("./dist/vendetta.js", "//# sourceURL=Vendetta");
|
|
||||||
console.log("Build successful!");
|
console.log("Build successful!");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("Build failed...", 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());
|
||||||
|
}
|
||||||
|
})();
|
11
src/index.ts
11
src/index.ts
|
@ -7,11 +7,7 @@ import initFixes from "@lib/fixes";
|
||||||
import logger from "@lib/logger";
|
import logger from "@lib/logger";
|
||||||
import windowObject from "@lib/windowObject";
|
import windowObject from "@lib/windowObject";
|
||||||
|
|
||||||
// This logs in the native logging implementation, e.g. logcat
|
export default async () => {
|
||||||
console.log("Hello from Vendetta!");
|
|
||||||
|
|
||||||
(async () => {
|
|
||||||
try {
|
|
||||||
// Load everything in parallel
|
// Load everything in parallel
|
||||||
const unloads = await Promise.all([
|
const unloads = await Promise.all([
|
||||||
patchLogHook(),
|
patchLogHook(),
|
||||||
|
@ -29,7 +25,4 @@ console.log("Hello from Vendetta!");
|
||||||
|
|
||||||
// We good :)
|
// We good :)
|
||||||
logger.log("Vendetta is ready!");
|
logger.log("Vendetta is ready!");
|
||||||
} catch (e: any) {
|
}
|
||||||
alert(`Vendetta failed to initialize... ${e.stack || e.toString()}`);
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
|
|
Loading…
Reference in a new issue