From 47b1642156f15642b853d8cb77f1dbe8d785166b Mon Sep 17 00:00:00 2001 From: Jeff Emmett Date: Mon, 9 Mar 2026 20:56:30 -0700 Subject: [PATCH] fix: TDZ error from panX/panY/scale declared after await, add HTML no-cache Root cause: scale/panX/panY were declared with let at line 5014, but event handlers referencing them were registered before line 2771. Since the module has top-level awaits (offlineStore.open, sync.initFromCache), execution yields and events can fire before the let declarations, causing "Cannot access variable before initialization" TDZ errors. Fix: hoist scale/panX/panY declarations to before any await statements. Also add Cache-Control: no-cache for HTML files and immutable for Vite content-hashed assets to prevent stale bundle caching. Co-Authored-By: Claude Opus 4.6 --- website/canvas.html | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/website/canvas.html b/website/canvas.html index 4b71c1c..f4a3b5b 100644 --- a/website/canvas.html +++ b/website/canvas.html @@ -2340,6 +2340,14 @@ FolkRApp.define(); FolkFeed.define(); + // Zoom and pan state — declared early to avoid TDZ errors + // (event handlers reference these before awaits yield execution) + let scale = 1; + let panX = 0; + let panY = 0; + const minScale = 0.05; + const maxScale = 20; + // Get community info from URL // Supports path-based slugs: cca.rspace.online/campaign/demo → slug "campaign-demo" const hostname = window.location.hostname; @@ -5010,13 +5018,6 @@ if (memoryPanel.classList.contains("open")) renderMemoryPanel(); }); - // Zoom and pan controls - let scale = 1; - let panX = 0; - let panY = 0; - const minScale = 0.05; - const maxScale = 20; - function updateCanvasTransform() { // Transform only the content layer — canvas viewport stays fixed canvasContent.style.transform = `translate(${panX}px, ${panY}px) scale(${scale})`;