diff --git a/CHANGELOG.md b/CHANGELOG.md index 61bc77e..ad21316 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 +- **Rehearser playback namespace migration.** WebAudio transport, decoded-buffer caching, line-audio caching, and batch + synthesis now use a private implementation scope with explicit compatibility exports and a tested namespace API. - **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 diff --git a/TODO.md b/TODO.md index 7d18429..a6d7d32 100644 --- a/TODO.md +++ b/TODO.md @@ -124,8 +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 leaf modules now use private scopes - with explicit compatibility exports, while stateful modules continue the responsibility-by-responsibility migration. +- [ ] 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. - [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 a06c28e..74eb4d2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.24.58 +1.24.59 diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 344b028..7b94c94 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -49,6 +49,7 @@ Done incrementally as global-scope ordered files (no ES-module change needed) - ✅ `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. +- ✅ Rehearser playback uses a private scope with explicit transport/cache compatibility exports and a namespace-tested API. - ✅ `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 44f5d90..e58b2cd 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/rehearser-playback.js b/static/js/rehearser-playback.js index 542c084..44d671e 100644 --- a/static/js/rehearser-playback.js +++ b/static/js/rehearser-playback.js @@ -1,6 +1,8 @@ // Rehearser playback, transport, and persistent line-audio cache. // Loaded before rehearser.js; handlers resolve shared state and helpers at call time. +(function (root) { + // ── WebAudio pre-decode (eliminates 2-3s silence between lines) ───────────── let _rehPlayCtx = null; @@ -693,9 +695,33 @@ $('reh-tb-clean-cache')?.addEventListener('click', async () => { }); -window.TTVC = window.TTVC || {}; -window.TTVC.rehearser = window.TTVC.rehearser || {}; -Object.assign(window.TTVC.rehearser, { +// Keep the classic-script integration surface available while the implementation +// itself stays private to this module. New code should use TTVC.rehearser.playback. +Object.assign(root, { + rehPlayCtx, + rehDecodedBuffers, + preDecodeBlob, + computeWordTimings, + stopAudioSource, + playPreDecoded, + startPlay, + pausePlay, + stopPlay, + playNextLine, + highlightCurrentLine, + updatePlayBtn, + _lineAudioCacheKey, + _lineAudioBookName, + _lineAudioCacheGet, + _lineAudioCachePut, + _lineAudioSyncDots, + synthAll, + _updateStaleBatchBtn, +}); + +root.TTVC = root.TTVC || {}; +root.TTVC.rehearser = root.TTVC.rehearser || {}; +Object.assign(root.TTVC.rehearser, { playback: { start: startPlay, pause: pausePlay, @@ -705,3 +731,4 @@ Object.assign(window.TTVC.rehearser, { syncCacheDots: _lineAudioSyncDots, }, }); +})(window);