0.1.0-1-alpha.2-fix.2
This commit is contained in:
25
crates/apps/game-reflex-poc-tauri/frontend/ts/main.ts
Normal file
25
crates/apps/game-reflex-poc-tauri/frontend/ts/main.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
// 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}`);
|
||||
});
|
||||
Reference in New Issue
Block a user