Add debug console logs to find startup issues
This commit is contained in:
55
src/main.ts
55
src/main.ts
@@ -1,5 +1,7 @@
|
||||
import "./styles.css";
|
||||
|
||||
console.log("[DEBUG] Starting main.ts import...");
|
||||
|
||||
import {
|
||||
ROOT_SHIFT_COST,
|
||||
ROUND_ANIMATION_BONUS_MS,
|
||||
@@ -52,16 +54,22 @@ import type {
|
||||
import { keyFor, parseKey, tint, wait } from "./utils";
|
||||
|
||||
const app = document.querySelector("#app");
|
||||
console.log("[DEBUG] App element found:", app);
|
||||
|
||||
if (!(app instanceof HTMLElement)) {
|
||||
console.error("[DEBUG] #app container not found or not HTMLElement");
|
||||
throw new Error("#app container not found");
|
||||
}
|
||||
|
||||
console.log("[DEBUG] Initializing state...");
|
||||
let roundAnimationToken = 0;
|
||||
let setup: SetupState = createSetupState();
|
||||
console.log("[DEBUG] Setup created:", setup);
|
||||
let state: GameState = createInitialState(setup);
|
||||
console.log("[DEBUG] Initial state created:", state);
|
||||
let isNewGameModalOpen = false;
|
||||
let previousScoreSnapshot: ScoreSnapshot[] | null = null;
|
||||
console.log("[DEBUG] State initialized, proceeding to render...");
|
||||
|
||||
function rebuildSetup(overrides: Partial<SetupState> = {}) {
|
||||
setup = createSetupState(
|
||||
@@ -1422,24 +1430,35 @@ function attachEvents() {
|
||||
}
|
||||
|
||||
function render() {
|
||||
const playerCount = state.players.length;
|
||||
app.innerHTML = `
|
||||
<main class="layout" style="--player-count: ${playerCount}">
|
||||
<section class="game-area">
|
||||
${renderBoard()}
|
||||
</section>
|
||||
${renderSidebar()}
|
||||
<footer class="scoreboard">
|
||||
${renderScoreboard()}
|
||||
</footer>
|
||||
</main>
|
||||
${renderNewGameModal()}
|
||||
${renderInitiativeModal()}
|
||||
${renderWeatherDraftModal()}
|
||||
`;
|
||||
|
||||
attachEvents();
|
||||
previousScoreSnapshot = getScoreSnapshot();
|
||||
console.log("[DEBUG] render() called, playerCount:", state?.players?.length);
|
||||
try {
|
||||
const playerCount = state.players.length;
|
||||
console.log("[DEBUG] Building HTML...");
|
||||
app.innerHTML = `
|
||||
<main class="layout" style="--player-count: ${playerCount}">
|
||||
<section class="game-area">
|
||||
${renderBoard()}
|
||||
</section>
|
||||
${renderSidebar()}
|
||||
<footer class="scoreboard">
|
||||
${renderScoreboard()}
|
||||
</footer>
|
||||
</main>
|
||||
${renderNewGameModal()}
|
||||
${renderInitiativeModal()}
|
||||
${renderWeatherDraftModal()}
|
||||
`;
|
||||
console.log("[DEBUG] HTML rendered, attaching events...");
|
||||
attachEvents();
|
||||
console.log("[DEBUG] Events attached, getting score snapshot...");
|
||||
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();
|
||||
console.log("[DEBUG] render() executed");
|
||||
|
||||
Reference in New Issue
Block a user