0.1.0-1-alpha.2-fix.3
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// file: crates/apps/game-reflex-poc-tauri/frontend/ts/main.ts
|
||||
// version: 1
|
||||
// version: 2
|
||||
|
||||
import { getRuntimeLabel, notifyFrontendReady } from "./bridge";
|
||||
import { closeMainWindow, getRuntimeLabel, notifyFrontendReady } from "./bridge";
|
||||
import { startGame } from "./game";
|
||||
import { initializeTracing, tracingError, tracingInfo } from "./logging";
|
||||
|
||||
@@ -14,12 +14,23 @@ async function main(): Promise<void> {
|
||||
throw new Error("Reflex Tauri frontend DOM is incomplete");
|
||||
}
|
||||
runtime.value = await getRuntimeLabel();
|
||||
await startGame(canvas, score);
|
||||
const game = await startGame(canvas, score);
|
||||
window.addEventListener("keydown", event => {
|
||||
if (event.key !== "Escape" || event.repeat) {
|
||||
return;
|
||||
}
|
||||
event.preventDefault();
|
||||
const shouldExit = game.quit_requested_escape();
|
||||
tracingInfo(`quit requested source=escape decision=${shouldExit ? "exit" : "continue"}`);
|
||||
if (shouldExit) {
|
||||
void closeMainWindow().catch(caughtError => tracingError("Tauri close command failed", caughtError));
|
||||
}
|
||||
});
|
||||
await notifyFrontendReady();
|
||||
await tracingInfo("Reflex Tauri frontend started");
|
||||
tracingInfo("Reflex Tauri frontend started");
|
||||
}
|
||||
|
||||
void main().catch(async caughtError => {
|
||||
void main().catch(caughtError => {
|
||||
const message = caughtError instanceof Error ? caughtError.stack ?? caughtError.message : String(caughtError);
|
||||
await tracingError(`Reflex Tauri frontend startup failed: ${message}`);
|
||||
tracingError(`Reflex Tauri frontend startup failed: ${message}`);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user