Add debug console logs to find startup issues

This commit is contained in:
2026-04-09 14:07:34 -04:00
parent 6c47b3e288
commit f5ffb211cf

View File

@@ -1,5 +1,7 @@
import "./styles.css"; import "./styles.css";
console.log("[DEBUG] Starting main.ts import...");
import { import {
ROOT_SHIFT_COST, ROOT_SHIFT_COST,
ROUND_ANIMATION_BONUS_MS, ROUND_ANIMATION_BONUS_MS,
@@ -52,16 +54,22 @@ import type {
import { keyFor, parseKey, tint, wait } from "./utils"; import { keyFor, parseKey, tint, wait } from "./utils";
const app = document.querySelector("#app"); const app = document.querySelector("#app");
console.log("[DEBUG] App element found:", app);
if (!(app instanceof HTMLElement)) { if (!(app instanceof HTMLElement)) {
console.error("[DEBUG] #app container not found or not HTMLElement");
throw new Error("#app container not found"); throw new Error("#app container not found");
} }
console.log("[DEBUG] Initializing state...");
let roundAnimationToken = 0; let roundAnimationToken = 0;
let setup: SetupState = createSetupState(); let setup: SetupState = createSetupState();
console.log("[DEBUG] Setup created:", setup);
let state: GameState = createInitialState(setup); let state: GameState = createInitialState(setup);
console.log("[DEBUG] Initial state created:", state);
let isNewGameModalOpen = false; let isNewGameModalOpen = false;
let previousScoreSnapshot: ScoreSnapshot[] | null = null; let previousScoreSnapshot: ScoreSnapshot[] | null = null;
console.log("[DEBUG] State initialized, proceeding to render...");
function rebuildSetup(overrides: Partial<SetupState> = {}) { function rebuildSetup(overrides: Partial<SetupState> = {}) {
setup = createSetupState( setup = createSetupState(
@@ -1422,7 +1430,10 @@ function attachEvents() {
} }
function render() { function render() {
console.log("[DEBUG] render() called, playerCount:", state?.players?.length);
try {
const playerCount = state.players.length; const playerCount = state.players.length;
console.log("[DEBUG] Building HTML...");
app.innerHTML = ` app.innerHTML = `
<main class="layout" style="--player-count: ${playerCount}"> <main class="layout" style="--player-count: ${playerCount}">
<section class="game-area"> <section class="game-area">
@@ -1437,9 +1448,17 @@ function render() {
${renderInitiativeModal()} ${renderInitiativeModal()}
${renderWeatherDraftModal()} ${renderWeatherDraftModal()}
`; `;
console.log("[DEBUG] HTML rendered, attaching events...");
attachEvents(); attachEvents();
console.log("[DEBUG] Events attached, getting score snapshot...");
previousScoreSnapshot = getScoreSnapshot(); previousScoreSnapshot = getScoreSnapshot();
console.log("[DEBUG] Render complete!");
} catch (error) {
console.error("[DEBUG] Error in render():", error);
throw error;
}
} }
console.log("[DEBUG] About to call render()...");
render(); render();
console.log("[DEBUG] render() executed");