diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b6f78d..09b8245 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ Follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) · versioned wi ## [Unreleased] ### Changed +- **Reader namespace migration.** PDF/TXT document state, playback, search, synthesis, and library APIs now use a + private implementation scope with explicit compatibility exports and a tested `window.TTVC.reader` surface. - **Audiobook parser compatibility boundary.** Speech-heuristic constants consumed by the scoped Audiobook core are now exported explicitly, preventing load-order regressions while preserving the parser namespace. - **Audiobook core namespace migration.** Reader-side audiobook state, attribution helpers, quote controls, and Rehearser diff --git a/TODO.md b/TODO.md index a6d7d32..c5adda5 100644 --- a/TODO.md +++ b/TODO.md @@ -124,9 +124,9 @@ architecture change: the larger Audiobook/Rehearser/style split. voice design, I/O, library, stage, and recording blocks plus Audiobook casting, preview, export, and feature styles are isolated. Core Reader state and compatibility event wiring remain ordered in the legacy entry points. - [x] Extract Rehearser stage display and cast-sidebar controls into `rehearser-stage.js`. -- [ ] Replace broad globals with namespaces such as `window.TTVC.audiobook`; pure leaves, Audiobook state modules, and - Rehearser playback now use private scopes with explicit compatibility exports. Remaining Rehearser state modules still - require the same responsibility-by-responsibility migration. +- [ ] Replace broad globals with namespaces such as `window.TTVC.audiobook`; pure leaves, Audiobook state/core modules, + Reader, and Rehearser state modules now use private scopes with explicit compatibility exports. Remaining utility and + library modules still require the same responsibility-by-responsibility migration. - [x] Generate the feature-module list for `loader.js` and `scripts/minify.mjs` from one shared manifest; larger responsibility splits remain. - [x] Add a dependency-free frontend syntax and top-level declaration collision gate (`npm run check:frontend`); diff --git a/VERSION b/VERSION index e17883e..98a131b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.24.64 +1.24.65 diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 2efaf6b..8767bf0 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -54,6 +54,7 @@ Done incrementally as global-scope ordered files (no ES-module change needed) - ✅ Rehearser recording uses a private scope with explicit microphone/overlay compatibility exports. - ✅ Rehearser core uses a private scope with explicit state, pagination, and cast-management compatibility exports. - ✅ Audiobook core uses a private scope with explicit reader-side state and handoff compatibility exports. +- ✅ Reader uses a private scope with explicit document, playback, and search compatibility exports. - ✅ `static/css/resource-diagnostics.css` — isolated Performance/resource diagnostic panel styles. - ✅ `static/css/background-jobs.css` — isolated background-job history and retry-panel styles. - ✅ `static/css/voice-design.css` — isolated Voice Design form, samples, and preview-match styles. diff --git a/static/index.html b/static/index.html index 9cec7f6..9435383 100644 --- a/static/index.html +++ b/static/index.html @@ -10,7 +10,7 @@ - + @@ -27,12 +27,12 @@ - - - - - - + + + + + + @@ -397,7 +397,7 @@ window.toggleNavTree = function(treeId, chevronId) { - + diff --git a/static/js/reader.js b/static/js/reader.js index 58c28bf..6273946 100644 --- a/static/js/reader.js +++ b/static/js/reader.js @@ -1,4 +1,6 @@ // ── Read Aloud — PDF/TXT document reader with live word highlighting ──────── + +(function (root) { // // Imports a PDF (rendered to canvas via pdf.js with a highlight overlay on the // real text) or a plain-text file, then reads it sentence-by-sentence with a @@ -2226,3 +2228,58 @@ function _readerEnsureImportVisible() { card.classList.remove('card-col-closed'); } } + +// Preserve the existing classic-script integration surface while keeping Reader +// state and implementation details inside one explicit module scope. +Object.assign(root, { + readerState, READER_RESUME_KEY, READER_FMT, READER_BUF_WINDOW, READER_CANVAS_MARGIN, + READER_IMPORT_YIELD_EVERY, READER_PDF_INITIAL_PAGES, READER_PDF_INITIAL_MAX_WITHOUT_TEXT, + READER_OCR_LANGS, READER_OCR_MIN_GAP_RATIO, READER_OCR_MIN_GAP_PX, READER_OCR_RENDER_SCALE, + READER_OCR_MIN_CONFIDENCE, readerCtx, readerYield, readerFetchVoices, readerUpdateBackendHint, + readerTitleFromText, readerUpdateToolbarVisibility, readerFinishLoadedDocument, readerImportFile, + readerImportPastedText, readerResetDoc, READER_NO_LEADING_SPACE_RE, readerBuildSentences, + readerGroupUnits, readerMarkParagraphBreaks, loadTesseract, readerGetOcrWorker, _readerTimeout, + _readerOcrAttempt, readerOcrPageHeading, readerLoadPdfSkeleton, readerExtractPdfText, + readerLoadPdf, readerShowParseProgress, readerComputeScale, readerApplyZoom, readerSetupLazyRaster, + readerRenderVisible, readerIsPageNearView, readerEvictCanvases, READER_MAX_CANVAS_PIXELS, + READER_MAX_CANVAS_SIDE, readerRenderPage, readerLoadText, readerSentBBox, readerBuildUnitIndex, + readerCreatePageStatus, readerEffectiveStatus, readerSetStatus, readerPaintStatus, _readerWordBox, + readerEnsureBox, readerClearHighlights, readerEnsureVisible, readerHighlightSentence, + readerHighlightWord, readerSetSelecting, readerSelHint, readerPickSentence, readerClearSelection, + readerSelRange, readerPaintSelection, readerScopeIndices, readerUpdateScopeLabel, + _readerTextForSynth, readerSynthIndices, readerSynthAll, readerSafeName, readerPad, readerPageOf, + readerDownload, _readerDelay, readerExport, readerRechunk, readerGenParams, readerComputeGain, + readerFetchServerAudio, readerGetBuffer, readerEvictBuffers, readerPrefetch, readerClearReading, + readerPlayCurrent, readerStopSource, readerStopPlayback, readerPlay, readerPause, readerJumpTo, + readerUpdatePlayBtn, readerUpdateProgress, readerSaveResume, readerLoadResume, READER_API, + readerSyntheticCount, readerSaveLibrary, readerPersistProgress, readerDeleteLibraryDoc, + readerOpenLibraryDoc, readerSetSelectValue, readerRenderLibrary, _readerSearchTerm, + _readerSearchHits, _readerSearchCurrent, _readerSearchTimer, READER_SEARCH_MAX_HITS, + readerSearchTextMap, readerFindSearchGroups, readerRemoveSearchHighlights, readerSetSearchStatus, + readerClearSearch, readerCollectSearchHits, readerPaintSearchHighlights, readerUpdateSearchStatus, + readerJumpToSearchHit, readerSearchApply, readerSearchStep, _readerEnsureImportVisible, +}); +root.TTVC = root.TTVC || {}; +root.TTVC.reader = root.TTVC.reader || {}; +Object.assign(root.TTVC.reader, { + state: readerState, + document: { + loadText: readerLoadText, + loadPdf: readerLoadPdf, + reset: readerResetDoc, + saveLibrary: readerSaveLibrary, + openLibrary: readerOpenLibraryDoc, + }, + playback: { + play: readerPlay, + pause: readerPause, + stop: readerStopPlayback, + jumpTo: readerJumpTo, + }, + search: { + apply: readerSearchApply, + clear: readerClearSearch, + step: readerSearchStep, + }, +}); +})(window);