Deno compile
This commit is contained in:
+21
-3
@@ -26,11 +26,28 @@ try {
|
||||
console.error(`No sound: ${(e as Error).message}`);
|
||||
}
|
||||
|
||||
const app = desktop_app((message) => {
|
||||
// the app can't go on. it says why in a message box, a packaged app has no terminal to read it in
|
||||
function fail(message: string) {
|
||||
console.error(message);
|
||||
game_window.show_error("bworld", `The singleplayer world stopped: ${message}`);
|
||||
game_window.set_grabbed(false);
|
||||
game_window.show_error("bworld", message);
|
||||
audio?.close();
|
||||
game_window.close();
|
||||
Deno.exit(1);
|
||||
}
|
||||
|
||||
// an error nothing caught, even a throw while starting, ends the app through fail. ending deno with it instead unloads
|
||||
// openal while its thread still plays, which crashes before the error is printed
|
||||
addEventListener("error", (event) => {
|
||||
event.preventDefault();
|
||||
fail(String(event.error?.stack ?? event.message));
|
||||
});
|
||||
addEventListener("unhandledrejection", (event) => {
|
||||
event.preventDefault();
|
||||
fail(String(event.reason?.stack ?? event.reason));
|
||||
});
|
||||
|
||||
const app = desktop_app((message) => fail(`The singleplayer world stopped: ${message}`));
|
||||
|
||||
const server = Deno.serve(
|
||||
{ hostname: "127.0.0.1", port: 0, onListen() {} },
|
||||
@@ -65,7 +82,8 @@ async function start_client(page: URL) {
|
||||
});
|
||||
worker.onmessage = (event: MessageEvent<ClientMessage>) => handle(event.data);
|
||||
worker.onerror = (event) => {
|
||||
console.error(`The client stopped: ${event.message}`);
|
||||
event.preventDefault();
|
||||
fail(`The client stopped: ${event.message}`);
|
||||
};
|
||||
client = worker;
|
||||
send({
|
||||
|
||||
Reference in New Issue
Block a user