[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());
|
||||||
|
}
|
||||||
|
})();
|
39
src/index.ts
39
src/index.ts
|
@ -7,29 +7,22 @@ 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!");
|
// Load everything in parallel
|
||||||
|
const unloads = await Promise.all([
|
||||||
|
patchLogHook(),
|
||||||
|
patchAssets(),
|
||||||
|
patchCommands(),
|
||||||
|
initFixes(),
|
||||||
|
initSettings(),
|
||||||
|
]);
|
||||||
|
|
||||||
(async () => {
|
// Assign window object
|
||||||
try {
|
window.vendetta = await windowObject(unloads);
|
||||||
// Load everything in parallel
|
|
||||||
const unloads = await Promise.all([
|
|
||||||
patchLogHook(),
|
|
||||||
patchAssets(),
|
|
||||||
patchCommands(),
|
|
||||||
initFixes(),
|
|
||||||
initSettings(),
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Assign window object
|
// Once done, load plugins
|
||||||
window.vendetta = await windowObject(unloads);
|
unloads.push(await initPlugins());
|
||||||
|
|
||||||
// Once done, load plugins
|
// We good :)
|
||||||
unloads.push(await initPlugins());
|
logger.log("Vendetta is ready!");
|
||||||
|
}
|
||||||
// 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