Initial commit

Photo-based book cataloger with AI identification.
Room → Cabinet → Shelf → Book hierarchy; FastAPI + SQLite backend;
vanilla JS SPA; OpenAI-compatible plugin system for boundary
detection, text recognition, and archive search.
This commit is contained in:
night
2026-03-09 14:11:11 +03:00
commit f29678ebf1
64 changed files with 8605 additions and 0 deletions

41
static/js/state.js Normal file
View File

@@ -0,0 +1,41 @@
/*
* state.js
* All mutable application state — loaded first so every other module
* can read and write these globals without forward-reference issues.
*
* Provides:
* S — main UI state (tree data, selection, loading flags)
* _plugins — plugin manifest populated from GET /api/config
* _batchState — current batch-processing progress
* _batchPollTimer — setInterval handle for batch polling
* _bnd — live boundary-canvas state (written by canvas-boundary.js,
* read by detail-render.js)
* _photoQueue — photo queue session state (written by photo.js,
* read by events.js)
*/
// ── Main UI state ───────────────────────────────────────────────────────────
let S = {
tree: null,
expanded: new Set(),
selected: null, // {type:'cabinet'|'shelf'|'book', id}
_photoTarget: null, // {type, id}
_loading: {}, // {`${pluginId}:${entityId}`: true}
_cropMode: null, // {type, id} while crop UI is active
};
// ── Plugin registry ─────────────────────────────────────────────────────────
let _plugins = []; // populated from GET /api/config
// ── Batch processing state ──────────────────────────────────────────────────
let _batchState = {running: false, total: 0, done: 0, errors: 0, current: ''};
let _batchPollTimer = null;
// ── Boundary canvas live state ───────────────────────────────────────────────
// Owned by canvas-boundary.js; declared here so detail-render.js can read it
// without a circular load dependency.
let _bnd = null; // {wrap,img,canvas,axis,boundaries[],pluginResults{},selectedPlugin,segments[],nodeId,nodeType}
// ── Photo queue session state ────────────────────────────────────────────────
// Owned by photo.js; declared here so events.js can read/write it.
let _photoQueue = null; // {books:[...], index:0, processing:false}