From cc4fc4ae2e5b7f083f27413b37d91f0a51acdae1 Mon Sep 17 00:00:00 2001 From: mARTin-B78 Date: Fri, 4 Sep 2026 12:26:21 +0200 Subject: [PATCH] refactor: scope audiobook state modules --- CHANGELOG.md | 2 ++ VERSION | 2 +- docs/ARCHITECTURE.md | 1 + static/index.html | 16 ++++++++-------- static/js/audiobook-pipeline.js | 17 +++++++++++++---- static/js/audiobook-preview-export.js | 20 +++++++++++++++----- 6 files changed, 40 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 56c5f2c..61bc77e 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 +- **Stateful Audiobook namespace migration.** Casting/recast orchestration and preview/export now keep internal helpers + private and publish their public compatibility surface explicitly through `window.TTVC.audiobook`. - **Pure leaf namespace migration.** Rehearser parsing/training and Audiobook parsing/segmentation helpers now keep declarations private and publish explicit compatibility exports alongside their `window.TTVC` APIs. - **P1 architecture audit.** Marked the incremental frontend modularization complete: all planned Audiobook/Rehearser diff --git a/VERSION b/VERSION index df64b95..a06c28e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.24.57 +1.24.58 diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 5e238d2..344b028 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -48,6 +48,7 @@ Done incrementally as global-scope ordered files (no ES-module change needed) - ✅ `audiobook-cast.js` — cast Markdown export, legacy page-stamping migration, deterministic speaker/sentence/duplicate/alias normalization helpers, and the live cast-view renderer. - ✅ `audiobook-pipeline.js` — LLM casting, unknown-speaker recast, automatic repair, and cast-view orchestration. - ✅ `audiobook-preview-export.js` — editable cast preview, Rehearser handoff, chapter-aware export, and export browsing. +- ✅ Stateful Audiobook modules use private scopes with explicit legacy exports; their public APIs are namespace-tested. - ✅ `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 689ad4c..44f5d90 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/audiobook-pipeline.js b/static/js/audiobook-pipeline.js index 54c3dc7..06948cc 100644 --- a/static/js/audiobook-pipeline.js +++ b/static/js/audiobook-pipeline.js @@ -1,5 +1,6 @@ // Audiobook LLM casting and recast orchestration. // Loaded after cast helpers and before audiobook.js; dependencies resolve at call time. +(function (root) { // Every long-running audiobook action opens with a "already running?" guard. // They all used to `return` in silence, so clicking Recast / Verify / Export @@ -1060,9 +1061,16 @@ async function audiobookCast(overrideUrl, overrideModel, resume) { } -window.TTVC=window.TTVC||{}; -window.TTVC.audiobook=window.TTVC.audiobook||{}; -Object.assign(window.TTVC.audiobook,{ + root._abBusyGuard = _abBusyGuard; + root.audiobookRecastUnknown = audiobookRecastUnknown; + root.audiobookAutoRepairEnabled = audiobookAutoRepairEnabled; + root.audiobookAutoRepairCast = audiobookAutoRepairCast; + root.audiobookRecastUntilThreshold = audiobookRecastUntilThreshold; + root.audiobookOpenCastView = audiobookOpenCastView; + root.audiobookCast = audiobookCast; + root.TTVC=root.TTVC||{}; + root.TTVC.audiobook=root.TTVC.audiobook||{}; + Object.assign(root.TTVC.audiobook,{ startCast:audiobookCast, openCastView:audiobookOpenCastView, recastUnknown:audiobookRecastUnknown, @@ -1072,4 +1080,5 @@ Object.assign(window.TTVC.audiobook,{ openCastView:audiobookOpenCastView, autoRepair:audiobookAutoRepairCast, }, -}); + }); +})(window); diff --git a/static/js/audiobook-preview-export.js b/static/js/audiobook-preview-export.js index a5a9972..3110343 100644 --- a/static/js/audiobook-preview-export.js +++ b/static/js/audiobook-preview-export.js @@ -1,5 +1,6 @@ // Audiobook cast preview, Rehearser handoff, and chapter export UI. // Loaded after the casting pipeline and before audiobook.js; dependencies resolve at call time. +(function (root) { // ── Editable attribution preview ───────────────────────────────────────────── @@ -771,9 +772,18 @@ async function audiobookBrowseExports() { $('reh-tb-browse-exports')?.addEventListener('click', audiobookBrowseExports); -window.TTVC=window.TTVC||{}; -window.TTVC.audiobook=window.TTVC.audiobook||{}; -Object.assign(window.TTVC.audiobook,{ + root.audiobookOpenCurrentInRehearser = audiobookOpenCurrentInRehearser; + root.audiobookShowPreview = audiobookShowPreview; + root.audiobookApplyPreviewAndOpen = audiobookApplyPreviewAndOpen; + root.audiobookBuildScript = audiobookBuildScript; + root.audiobookOpenInRehearser = audiobookOpenInRehearser; + root.audiobookIsChapter = audiobookIsChapter; + root.audiobookLineVoice = audiobookLineVoice; + root.audiobookExport = audiobookExport; + root.audiobookBrowseExports = audiobookBrowseExports; + root.TTVC=root.TTVC||{}; + root.TTVC.audiobook=root.TTVC.audiobook||{}; + Object.assign(root.TTVC.audiobook,{ preview:{ show:audiobookShowPreview, apply:audiobookApplyPreviewAndOpen, @@ -783,5 +793,5 @@ Object.assign(window.TTVC.audiobook,{ export:audiobookExport, browse:audiobookBrowseExports, }, -}); - + }); +})(window);