From 10a2cb287fe31f51a061f111afaf51346b7060c2 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 13 Jul 2026 03:21:01 +0000 Subject: [PATCH 1/2] Extract Quantosaurus class + event bus; drive existing UI through it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduce js/quantosaurus.js: an EventTarget-based app core that owns the shared state object (images, forest, tools, camera) and attaches to a board element. Every state change now flows out as a CustomEvent (imageadded, labelschanged, trainingstart/complete, statscomputed, dirtychange, etc.), so chrome subscribes instead of being hard-wired — the groundwork for embedding the board without the sidebar. - images.js/training.js stop importing ui.js and reach into document by id; they read state.board/state.brushSize and dispatch via state.events (optional-chained so the CPU unit tests stay Node-importable). - Brush size becomes real instance state instead of being read off the slider DOM inside the paint handlers. - ui.js gains bindChrome(q), a pure event subscriber reproducing today's sidebar rows, status line, save indicator, and count badges unchanged. - index.html's inline script becomes a consumer of the class; the File System Access .ilp save stays in the shell and calls q.markSaved(). - Consolidate the two duplicate class-rename onblur handlers into one path through q.setClassName (the old second copy dropped saveSettings). - config.js: add BRUSH_SIZE_* constants + pure clampBrushSize, covered by config.test.mjs. No visual or behavioral change; verified in a headless browser (load, paint, train, counts, brush hotkeys, recolor, rename+persist, contrast, delete) with zero console errors. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01VobFMvLSfYoBDLD1tAANma --- index.html | 281 +++++++++++++---------------------- js/config.js | 20 +++ js/config.test.mjs | 35 ++++- js/images.js | 117 ++++++++------- js/quantosaurus.js | 362 +++++++++++++++++++++++++++++++++++++++++++++ js/training.js | 41 +++-- js/ui.js | 76 ++++++++++ 7 files changed, 686 insertions(+), 246 deletions(-) create mode 100644 js/quantosaurus.js diff --git a/index.html b/index.html index 824f46b..c1abcb9 100644 --- a/index.html +++ b/index.html @@ -231,79 +231,37 @@

Frequently Asked Questions