26 lines
1.1 KiB
TypeScript
26 lines
1.1 KiB
TypeScript
// file: crates/apps/game-reflex-poc-tauri/frontend/ts/main.ts
|
|
// version: 1
|
|
|
|
import { getRuntimeLabel, notifyFrontendReady } from "./bridge";
|
|
import { startGame } from "./game";
|
|
import { initializeTracing, tracingError, tracingInfo } from "./logging";
|
|
|
|
async function main(): Promise<void> {
|
|
await initializeTracing();
|
|
const canvas = document.querySelector<HTMLCanvasElement>("#game");
|
|
const score = document.querySelector<HTMLOutputElement>("#score");
|
|
const runtime = document.querySelector<HTMLOutputElement>("#runtime");
|
|
if (canvas === null || score === null || runtime === null) {
|
|
throw new Error("Reflex Tauri frontend DOM is incomplete");
|
|
}
|
|
runtime.value = await getRuntimeLabel();
|
|
await startGame(canvas, score);
|
|
await notifyFrontendReady();
|
|
await tracingInfo("Reflex Tauri frontend started");
|
|
}
|
|
|
|
void main().catch(async caughtError => {
|
|
const message = caughtError instanceof Error ? caughtError.stack ?? caughtError.message : String(caughtError);
|
|
await tracingError(`Reflex Tauri frontend startup failed: ${message}`);
|
|
});
|