Pick lines on Voice-over (click; Ctrl / Cmd adds, Shift a run; Esc lets go) and click a character in the list on the left to have it read them; with none picked, the click changes who reads by default. On Voice-over the list is the cast: narrower, characters with their colours, and a click never leaves the page. Cards show who reads each line in its colour, with that character's emotions; the bundle carries [name] where the speaker changes, so generating, the cards' listen button, pushing, dragging and copying follow it, and a file voiced again from the audio gallery keeps its speakers. The character cards' Voice-over button is gone. The workflow actions move to ui_script_workflow.js and the cast helpers to ui_script_cast.js, keeping the director under 600 lines. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
22 lines
1.3 KiB
JavaScript
22 lines
1.3 KiB
JavaScript
// Run: node tests/script_cast.mjs (Voice-over's cast: picking lines, colours; no ComfyUI needed)
|
|
import assert from 'node:assert/strict';
|
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
import path from 'node:path';
|
|
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
const { pickLines, speakerColor } = await import(pathToFileURL(path.join(root, 'web/modules/ui_script_cast.js')).href);
|
|
|
|
// A click picks one line; Ctrl / ⌘ adds or takes one away; Shift picks the run from the anchor.
|
|
assert.deepEqual([...pickLines(new Set([1, 2]), 4, {})], [4]);
|
|
assert.deepEqual([...pickLines(new Set([1]), 3, { ctrlKey: true })].sort(), [1, 3]);
|
|
assert.deepEqual([...pickLines(new Set([1, 3]), 3, { metaKey: true })], [1]);
|
|
assert.deepEqual([...pickLines(new Set([5]), 2, { shiftKey: true }, 5)].sort(), [2, 3, 4, 5]);
|
|
assert.deepEqual([...pickLines(new Set(), 2, { shiftKey: true }, null)], [2]);
|
|
|
|
// A character's colour follows its place in the voice list, the same on the list and on the cards.
|
|
const groups = [{ group: 'a' }, { group: 'b' }, { group: 'c' }];
|
|
assert.notEqual(speakerColor('a', groups), speakerColor('b', groups));
|
|
assert.equal(speakerColor('b', groups), speakerColor('b', [...groups]));
|
|
assert.equal(speakerColor('gone', groups), speakerColor('a', groups));
|
|
|
|
console.log('script_cast: all checks passed');
|