refactor: scope voice library

This commit is contained in:
mARTin-B78 2026-09-04 13:19:52 +02:00
parent 1b7d6b2346
commit e5bd2a149f
6 changed files with 37 additions and 10 deletions

View File

@ -8,6 +8,8 @@ Follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) · versioned wi
## [Unreleased] ## [Unreleased]
### Changed ### Changed
- **Voice-library namespace migration.** Voice loading, rendering, benchmarking, and add/import workflows now use a
private scope with live compatibility accessors and a `window.TTVC.voiceLibrary` API.
- **Generation namespace migration.** WAV merging, chunked TTS, history, playlist, effects, and refinement helpers now - **Generation namespace migration.** WAV merging, chunked TTS, history, playlist, effects, and refinement helpers now
use a private scope with explicit compatibility exports and a `window.TTVC.generation` API. use a private scope with explicit compatibility exports and a `window.TTVC.generation` API.
- **STT namespace migration.** STT backend selection, microphone recording, voice loading, and STT-to-TTS helpers now - **STT namespace migration.** STT backend selection, microphone recording, voice loading, and STT-to-TTS helpers now

View File

@ -126,7 +126,8 @@ architecture change: the larger Audiobook/Rehearser/style split.
- [x] Extract Rehearser stage display and cast-sidebar controls into `rehearser-stage.js`. - [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/Reader/Rehearser - [ ] Replace broad globals with namespaces such as `window.TTVC.audiobook`; pure leaves, Audiobook/Reader/Rehearser
feature modules, Studio, and character-library persistence now use private scopes with explicit compatibility exports. feature modules, Studio, and character-library persistence now use private scopes with explicit compatibility exports.
Remaining utility and legacy library UI modules still require the same responsibility-by-responsibility migration. Voice-library loading, rendering, benchmarking, and import workflows are now scoped; remaining utility and legacy
library UI 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; - [x] Generate the feature-module list for `loader.js` and `scripts/minify.mjs` from one shared manifest;
larger responsibility splits remain. larger responsibility splits remain.
- [x] Add a dependency-free frontend syntax and top-level declaration collision gate (`npm run check:frontend`); - [x] Add a dependency-free frontend syntax and top-level declaration collision gate (`npm run check:frontend`);

View File

@ -1 +1 @@
1.24.84 1.24.85

View File

@ -74,6 +74,7 @@ Done incrementally as global-scope ordered files (no ES-module change needed)
- ✅ AI-backend section interactions and snippet initialization use a private scope with an explicit namespace API. - ✅ AI-backend section interactions and snippet initialization use a private scope with an explicit namespace API.
- ✅ STT backend, recording, voice-loading, and STT-to-TTS helpers use a private scope with live compatibility accessors. - ✅ STT backend, recording, voice-loading, and STT-to-TTS helpers use a private scope with live compatibility accessors.
- ✅ Generation audio/history/playlist helpers use a private scope with explicit compatibility exports and a namespace API. - ✅ Generation audio/history/playlist helpers use a private scope with explicit compatibility exports and a namespace API.
- ✅ Voice-library loading, rendering, benchmarking, and import workflows use a private scope with live compatibility exports.
- ✅ `static/css/resource-diagnostics.css` — isolated Performance/resource diagnostic panel styles. - ✅ `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/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. - ✅ `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="format-detection" content="telephone=no">
<meta name="color-scheme" content="light dark"> <meta name="color-scheme" content="light dark">
<meta name="theme-color" content="#2563EB"> <meta name="theme-color" content="#2563EB">
<meta name="app-version" content="1.24.84"> <meta name="app-version" content="1.24.85">
<link rel="manifest" href="/manifest.webmanifest"> <link rel="manifest" href="/manifest.webmanifest">
<link rel="icon" href="/static/icon.svg" type="image/svg+xml"> <link rel="icon" href="/static/icon.svg" type="image/svg+xml">
<link rel="apple-touch-icon" href="/static/icon.svg"> <link rel="apple-touch-icon" href="/static/icon.svg">
@ -27,12 +27,12 @@
<!-- ── Core styles (local — no CDN dependency for first paint) ────────── --> <!-- ── Core styles (local — no CDN dependency for first paint) ────────── -->
<link rel="stylesheet" href="/static/vendor/mdi/materialdesignicons.min.css"> <link rel="stylesheet" href="/static/vendor/mdi/materialdesignicons.min.css">
<link rel="stylesheet" href="/static/style.css?v=1.24.84"> <link rel="stylesheet" href="/static/style.css?v=1.24.85">
<link rel="stylesheet" href="/static/css/resource-diagnostics.css?v=1.24.84"> <link rel="stylesheet" href="/static/css/resource-diagnostics.css?v=1.24.85">
<link rel="stylesheet" href="/static/css/background-jobs.css?v=1.24.84"> <link rel="stylesheet" href="/static/css/background-jobs.css?v=1.24.85">
<link rel="stylesheet" href="/static/css/voice-design.css?v=1.24.84"> <link rel="stylesheet" href="/static/css/voice-design.css?v=1.24.85">
<link rel="stylesheet" href="/static/css/rehearser.css?v=1.24.84"> <link rel="stylesheet" href="/static/css/rehearser.css?v=1.24.85">
<link rel="stylesheet" href="/static/css/audiobook.css?v=1.24.84"> <link rel="stylesheet" href="/static/css/audiobook.css?v=1.24.85">
<!-- ── Flag icons — non-blocking (loaded async, icons appear after JS) ── --> <!-- ── Flag icons — non-blocking (loaded async, icons appear after JS) ── -->
@ -397,7 +397,7 @@ window.toggleNavTree = function(treeId, chevronId) {
</script> </script>
<!-- loader.js: fetches sections → loads JS modules → removes skeleton --> <!-- loader.js: fetches sections → loads JS modules → removes skeleton -->
<script src="/static/loader.js?v=1.24.84"></script> <script src="/static/loader.js?v=1.24.85"></script>
</body> </body>
</html> </html>

View File

@ -1,5 +1,7 @@
// ── Save voice ──────────────────────────────────────────────────────────── // ── Save voice ────────────────────────────────────────────────────────────
(function (root) {
$('save-btn').addEventListener('click', async () => { $('save-btn').addEventListener('click', async () => {
const id = trimmedFileId||designedFileId||currentFileId; const id = trimmedFileId||designedFileId||currentFileId;
if (!id) { toast('No audio ready','error'); return; } if (!id) { toast('No audio ready','error'); return; }
@ -3747,3 +3749,24 @@ async function _bulkSetEnabled(ids, enabled) {
} }
return done; return done;
} }
// Keep the mature voice-library integration surface compatible while placing
// implementation state and helpers behind one explicit module scope.
Object.assign(root, {
_vlCacheClear, loadVoiceLibrary, mergeBenchmarkResults, loadLibraryVoiceAudio,
renderVoiceList, runVoiceBenchmark, runVoiceBenchmarkBatch, activeBenchmarkVoices,
benchmarkTargetVoices, openSavedLibraryVoice, suggestLibVoiceId, uploadLibAddFile,
transcribeLibAddCurrent, voiceFileUrl, saveMeta, deleteVoiceGroup, libAddState,
});
Object.defineProperty(root, '_voices', { configurable: true, get: () => _voices, set: v => { _voices = v; } });
root.TTVC = root.TTVC || {};
root.TTVC.voiceLibrary = root.TTVC.voiceLibrary || {};
Object.assign(root.TTVC.voiceLibrary, {
get voices() { return _voices; },
load: loadVoiceLibrary,
render: renderVoiceList,
audio: { load: loadLibraryVoiceAudio, url: voiceFileUrl },
benchmarks: { run: runVoiceBenchmark, runBatch: runVoiceBenchmarkBatch },
saveMeta,
});
})(window);