refactor: scope rehearser playback

This commit is contained in:
mARTin-B78 2026-09-04 12:29:19 +02:00
parent cc4fc4ae2e
commit a202230654
6 changed files with 45 additions and 14 deletions

View File

@ -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

View File

@ -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`);

View File

@ -1 +1 @@
1.24.58
1.24.59

View File

@ -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.

View File

@ -10,7 +10,7 @@
<meta name="format-detection" content="telephone=no">
<meta name="color-scheme" content="light dark">
<meta name="theme-color" content="#2563EB">
<meta name="app-version" content="1.24.58">
<meta name="app-version" content="1.24.59">
<link rel="manifest" href="/manifest.webmanifest">
<link rel="icon" href="/static/icon.svg" type="image/svg+xml">
<link rel="apple-touch-icon" href="/static/icon.svg">
@ -27,12 +27,12 @@
<!-- ── Core styles (local — no CDN dependency for first paint) ────────── -->
<link rel="stylesheet" href="/static/vendor/mdi/materialdesignicons.min.css">
<link rel="stylesheet" href="/static/style.css?v=1.24.58">
<link rel="stylesheet" href="/static/css/resource-diagnostics.css?v=1.24.58">
<link rel="stylesheet" href="/static/css/background-jobs.css?v=1.24.58">
<link rel="stylesheet" href="/static/css/voice-design.css?v=1.24.58">
<link rel="stylesheet" href="/static/css/rehearser.css?v=1.24.58">
<link rel="stylesheet" href="/static/css/audiobook.css?v=1.24.58">
<link rel="stylesheet" href="/static/style.css?v=1.24.59">
<link rel="stylesheet" href="/static/css/resource-diagnostics.css?v=1.24.59">
<link rel="stylesheet" href="/static/css/background-jobs.css?v=1.24.59">
<link rel="stylesheet" href="/static/css/voice-design.css?v=1.24.59">
<link rel="stylesheet" href="/static/css/rehearser.css?v=1.24.59">
<link rel="stylesheet" href="/static/css/audiobook.css?v=1.24.59">
<!-- ── Flag icons — non-blocking (loaded async, icons appear after JS) ── -->
@ -397,7 +397,7 @@ window.toggleNavTree = function(treeId, chevronId) {
</script>
<!-- loader.js: fetches sections → loads JS modules → removes skeleton -->
<script src="/static/loader.js?v=1.24.58"></script>
<script src="/static/loader.js?v=1.24.59"></script>
</body>
</html>

View File

@ -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);