feat(dialogues): support multi-cue subtitles
🔍 Lint / 🪄 Check lint (pull_request) Has been cancelled
🔍 Lint / 🎨 Check format (pull_request) Has been cancelled
🔍 Lint / 🔎 Typecheck (pull_request) Has been cancelled
📊 Quality / 🔒 Security Audit (pull_request) Has been cancelled
📊 Quality / 📋 Dependency Freshness (pull_request) Has been cancelled
📊 Quality / 📦 Bundle Size (pull_request) Has been cancelled
🔍 Lint / 🏗 Build (pull_request) Has been cancelled

This commit is contained in:
Tom Boullay
2026-05-30 04:00:25 +02:00
parent ce5dc8ada0
commit 02c1fb33d0
8 changed files with 192 additions and 53 deletions
@@ -93,13 +93,26 @@ function parseDialogueDefinition(
throw new Error(`Dialogue ${data.id} has an invalid audio path`);
}
// Support both subtitleCueIndex (legacy) and subtitleCueIndices (new)
const subtitleCueIndex = data.subtitleCueIndex;
if (
typeof subtitleCueIndex !== "number" ||
!Number.isInteger(subtitleCueIndex) ||
subtitleCueIndex < 1
) {
throw new Error(`Dialogue ${data.id} has an invalid subtitle cue index`);
const subtitleCueIndices = data.subtitleCueIndices;
const hasLegacyIndex =
typeof subtitleCueIndex === "number" &&
Number.isInteger(subtitleCueIndex) &&
subtitleCueIndex >= 1;
const hasNewIndices =
Array.isArray(subtitleCueIndices) &&
subtitleCueIndices.length > 0 &&
subtitleCueIndices.every(
(idx) => typeof idx === "number" && Number.isInteger(idx) && idx >= 1,
);
if (!hasLegacyIndex && !hasNewIndices) {
throw new Error(
`Dialogue ${data.id} must have subtitleCueIndex or subtitleCueIndices`,
);
}
const timecode = data.timecode;
@@ -111,9 +124,14 @@ function parseDialogueDefinition(
id: data.id,
voice: data.voice,
audio: data.audio,
subtitleCueIndex,
};
if (hasNewIndices) {
dialogue.subtitleCueIndices = subtitleCueIndices as number[];
} else if (hasLegacyIndex) {
dialogue.subtitleCueIndex = subtitleCueIndex;
}
if (timecode !== undefined) dialogue.timecode = timecode;
return dialogue;