@gondola-lyrics/kit 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/dist/formats.d.ts +41 -15
- package/dist/formats.js +925 -337
- package/dist/formats.js.map +1 -1
- package/dist/generator.d.ts +42 -2
- package/dist/generator.js +1 -1
- package/dist/index.d.ts +208 -7
- package/dist/index.js +3 -1
- package/dist/parser.d.ts +169 -6
- package/dist/parser.js +3 -1
- package/dist/transforms.d.ts +170 -1
- package/dist/transforms.js +1048 -0
- package/dist/transforms.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transforms.js","names":[],"sources":["../src/utils/array.ts","../src/transforms/background/utils.ts","../src/transforms/background/brackets.ts","../src/transforms/background/extract.ts","../src/transforms/emphasis/index.ts","../src/transforms/instrumental/index.ts","../src/transforms/space/constants.ts","../src/transforms/space/rules.ts","../src/transforms/space/insert.ts"],"sourcesContent":["/**\n * Preserves the input array when every element keeps its identity, so unchanged parent nodes can also be reused.\n *\n * The callback must leave inputs untouched and return the original element when unchanged.\n */\nexport const mapShared = <T>(items: T[], transform: (item: T) => T): T[] => {\n let result = items\n for (const [index, item] of items.entries()) {\n const transformed = transform(item)\n if (transformed !== item) {\n if (result === items) {\n result = [...items]\n }\n result[index] = transformed\n }\n }\n return result\n}\n","import type { runtime } from '@gondola-lyrics/model'\n\nimport { WordType, makeTimeRange } from '@gondola-lyrics/model/runtime'\n\nconst OPEN_BRACKETS = new Set(['(', '('])\nconst CLOSE_BRACKETS = new Set([')', ')'])\n\nexport const isOpenBracket = (char: string) => {\n return OPEN_BRACKETS.has(char)\n}\n\nexport const isCloseBracket = (char: string) => {\n return CLOSE_BRACKETS.has(char)\n}\n\nexport const isNormalWord = (word: runtime.Word) => {\n return word.type === WordType.NORMAL\n}\n\n/**\n * Content carries plain text or words, never both, so exactly one of the two is read.\n */\nexport const readLineText = (line: runtime.Line) => {\n return line.content?.text ?? (line.content?.words ?? []).map((word) => word.text).join('')\n}\n\nexport const readTimeRange = (line: runtime.Line) => {\n return line.time ? makeTimeRange({ start: line.time.start, end: line.time.end }) : undefined\n}\n","import type { runtime } from '@gondola-lyrics/model'\n\nimport { WordType, makeLineContentText, makeLineContentWords } from '@gondola-lyrics/model/runtime'\n\nimport { mapShared } from '@root/utils'\n\nimport { isCloseBracket, isNormalWord, isOpenBracket } from './utils'\n\n/**\n * Removes one leading bracket from the first sung word and one trailing bracket from the last, so an inner pair stays as written.\n *\n * Space words at the same edge go with the bracket, and a word left with no text goes too, since a sung word must carry something.\n */\nconst stripWordEdges = (words: runtime.Word[]): runtime.Word[] => {\n const firstIndex = words.findIndex(isNormalWord)\n const first = words[firstIndex]\n const last = words[words.findLastIndex(isNormalWord)]\n const stripStart = first ? isOpenBracket(first.text.charAt(0)) : false\n const stripEnd = last ? isCloseBracket(last.text.charAt(last.text.length - 1)) : false\n if (!stripStart && !stripEnd) {\n return words\n }\n\n const result = [...words]\n if (stripStart && first) {\n const text = first.text.slice(1)\n if (text) {\n result[firstIndex] = { ...first, text }\n } else {\n result.splice(firstIndex, 1)\n }\n while (result[0]?.type === WordType.SPACE) {\n result.shift()\n }\n }\n\n // The end is resolved again, since stripping the start may have removed the word it referred to.\n const endIndex = result.findLastIndex(isNormalWord)\n const end = result[endIndex]\n if (stripEnd && end) {\n const text = end.text.slice(0, -1)\n if (text) {\n result[endIndex] = { ...end, text }\n } else {\n result.splice(endIndex, 1)\n }\n while (result.at(-1)?.type === WordType.SPACE) {\n result.pop()\n }\n }\n\n return result\n}\n\n/**\n * Plain text is read literally, so a source that padded it with spaces keeps them; only word content\n * treats space words as the structural separators they are.\n */\nconst stripContentBrackets = (content: runtime.LineContent | undefined): runtime.LineContent | undefined => {\n if (!content) {\n return content\n }\n\n if (!content.words.length) {\n const text = content.text\n if (!text) {\n return content\n }\n const start = isOpenBracket(text.charAt(0)) ? 1 : 0\n const end = isCloseBracket(text.charAt(text.length - 1)) ? -1 : 0\n if (!start && !end) {\n return content\n }\n const stripped = text.slice(start, end === 0 ? undefined : end)\n return stripped ? makeLineContentText(stripped) : undefined\n }\n\n const words = stripWordEdges(content.words)\n if (words === content.words) {\n return content\n }\n return words.length ? makeLineContentWords(words) : undefined\n}\n\nconst stripLineBackgrounds = (line: runtime.Line): runtime.Line => {\n if (!line.backgrounds.length) {\n return line\n }\n\n let changed = false\n const kept: runtime.LineBackground[] = []\n for (const background of line.backgrounds) {\n const content = stripContentBrackets(background.content)\n if (content === background.content) {\n kept.push(background)\n continue\n }\n changed = true\n if (content) {\n kept.push({ ...background, content })\n }\n }\n return changed ? { ...line, backgrounds: kept } : line\n}\n\n/**\n * Removes the brackets some sources wrap around background vocals.\n *\n * One layer is removed from each edge of every background line, leaving a nested pair as `(x)`.\n * A line left with no content is dropped, since a background line must carry something.\n *\n * @returns The input when unchanged, or a new lyric sharing all unchanged nodes.\n */\nexport const stripBackgroundBrackets = (lyric: runtime.Lyric): runtime.Lyric => {\n const lines = mapShared(lyric.lines, stripLineBackgrounds)\n return lines === lyric.lines ? lyric : { ...lyric, lines }\n}\n","import type { runtime } from '@gondola-lyrics/model'\n\nimport {\n LineType,\n Timing,\n deriveLanguageUsages,\n makeLineAnnotation,\n makeLineAnnotationRoman,\n makeLineAnnotationTranslation,\n makeLineBackground,\n makeLineContentText,\n makeLineContentWords,\n makeTimeRange,\n} from '@gondola-lyrics/model/runtime'\n\nimport { isCloseBracket, isNormalWord, isOpenBracket, readLineText, readTimeRange } from './utils'\n\nexport interface ExtractBackgroundLinesOptions {\n /**\n * Turn a line holding nothing but brackets into a background line of the line before it.\n *\n * @default true\n */\n fullLine?: boolean\n /**\n * Pull the bracketed runs inside a line out into background lines of that same line.\n *\n * @default true\n */\n inLine?: boolean\n /**\n * Join a bracket opened on one line and closed on a later one, attaching it to the line before them.\n *\n * @default true\n */\n crossLine?: boolean\n}\n\ninterface TextRun {\n text: string\n start: number\n end: number\n}\n\n/**\n * An unclosed bracket never became a run, so its text returns to the line it came from.\n * An empty pair yields no run, since a background line must carry text.\n */\nconst splitText = (text: string) => {\n const chars = [...text]\n let main = ''\n let current = ''\n let opened = ''\n let openedAt = 0\n let depth = 0\n const runs: TextRun[] = []\n\n for (const [index, char] of chars.entries()) {\n if (isOpenBracket(char)) {\n if (depth) {\n current += char\n } else {\n opened = char\n openedAt = index\n }\n depth += 1\n } else if (isCloseBracket(char)) {\n if (depth === 0) {\n main += char\n continue\n }\n depth -= 1\n if (depth) {\n current += char\n } else {\n runs.push({ text: current, start: openedAt + 1, end: index })\n current = ''\n }\n } else if (depth) {\n current += char\n } else {\n main += char\n }\n }\n\n if (depth) {\n main += opened + current\n }\n // A removed run leaves the separators that framed it behind, so they collapse rather than double.\n return {\n main: main.trim().replaceAll(/\\s{2,}/gu, ' '),\n runs: runs.filter((run) => {\n return run.text.trim() !== ''\n }),\n length: chars.length,\n }\n}\n/**\n * A word straddling a bracket is cut into pieces sharing its time, since the source gave no finer boundary.\n * An unclosed bracket never became a run, so its text returns to the line it came from.\n * An empty pair yields no run, since a background line must carry text.\n */\nconst splitWords = (words: runtime.Word[]) => {\n const main: runtime.Word[] = []\n const runs: runtime.Word[][] = []\n let current: runtime.Word[] = []\n let opened: runtime.Word | undefined\n let depth = 0\n\n for (const word of words) {\n if (!isNormalWord(word)) {\n const target = depth ? current : main\n target.push(word)\n continue\n }\n\n let buffer = ''\n for (const char of word.text) {\n if (isOpenBracket(char)) {\n if (depth) {\n buffer += char\n } else {\n if (buffer) {\n main.push({ ...word, text: buffer })\n buffer = ''\n }\n opened = { ...word, text: char }\n }\n depth += 1\n } else if (isCloseBracket(char)) {\n if (depth === 0) {\n buffer += char\n continue\n }\n depth -= 1\n if (depth) {\n buffer += char\n } else {\n if (buffer) {\n current.push({ ...word, text: buffer })\n buffer = ''\n }\n if (current.length) {\n runs.push(current)\n current = []\n }\n }\n } else {\n buffer += char\n }\n }\n\n if (buffer) {\n const target = depth ? current : main\n target.push({ ...word, text: buffer })\n }\n }\n\n if (depth) {\n if (opened) {\n main.push(opened)\n }\n main.push(...current)\n }\n return {\n main,\n runs: runs.filter((run) => {\n return run.some((word) => {\n return word.text.trim() !== ''\n })\n }),\n }\n}\n\nconst mapSpan = (range: runtime.TimeRange, length: number, run: TextRun) => {\n if (range.end === undefined || length === 0) {\n return makeTimeRange({ start: range.start, end: range.end })\n }\n const span = range.end - range.start\n const start = range.start + Math.round((span * run.start) / length)\n const end = range.start + Math.round((span * run.end) / length)\n return makeTimeRange({ start, end: Math.max(start, end) })\n}\n\n/**\n * Falls back to the line's own range when no word carries a time, so a run still gets a range.\n */\nconst readWordRange = (words: runtime.Word[], fallback: runtime.TimeRange) => {\n const timed = words.filter((word) => {\n return isNormalWord(word) && word.time !== undefined\n })\n const first = timed[0]?.time\n const last = timed.at(-1)?.time\n if (!first || !last) {\n return fallback\n }\n return makeTimeRange({ start: first.start, end: last.end })\n}\n\n/**\n * A background may start before its line but not finish after it, so the line grows to the furthest stated end.\n */\nconst attach = (line: runtime.Line, backgrounds: runtime.LineBackground[]) => {\n const merged = [...line.backgrounds, ...backgrounds]\n merged.sort((left, right) => {\n const leftStart = left.time?.start ?? 0\n const rightStart = right.time?.start ?? 0\n return leftStart === rightStart ? (left.time?.end ?? 0) - (right.time?.end ?? 0) : leftStart - rightStart\n })\n\n let end = line.time?.end\n for (const background of merged) {\n const backgroundEnd = background.time?.end\n if (backgroundEnd !== undefined && (end === undefined || backgroundEnd > end)) {\n end = backgroundEnd\n }\n }\n if (!line.time || end === line.time.end) {\n return { ...line, backgrounds: merged }\n }\n return { ...line, time: makeTimeRange({ start: line.time.start, end }), backgrounds: merged }\n}\n\n/**\n * A closed line cannot hold an open background, so it stops where the line does.\n * On the last line the timeline itself ends unknown, so an open background leaves the line open too.\n */\nconst boundOpenBackgrounds = (lines: runtime.Line[]) => {\n const last = lines.length - 1\n return lines.map((line, index) => {\n const open = line.backgrounds.filter((background) => {\n return background.time !== undefined && background.time.end === undefined\n })\n if (!open.length) {\n return line\n }\n if (index === last) {\n return line.time ? { ...line, time: makeTimeRange({ start: line.time.start }) } : line\n }\n if (!line.time || line.time.end === undefined) {\n return line\n }\n const end = line.time.end\n return {\n ...line,\n backgrounds: line.backgrounds.map((background) => {\n const time = background.time\n if (!time || time.end !== undefined) {\n return background\n }\n return { ...background, time: makeTimeRange({ start: time.start, end: Math.max(time.start, end) }) }\n }),\n }\n })\n}\n\n/**\n * Words are kept only where the caller says the lyric is word-timed, since the other timings forbid them.\n */\nconst makeBackground = (line: runtime.Line, words: runtime.Word[], text: string, time: runtime.TimeRange | undefined, wordLevel: boolean) => {\n return makeLineBackground({\n time,\n agents: [...line.agents],\n languages: [...line.languages],\n content: wordLevel && words.length ? makeLineContentWords(words) : makeLineContentText(text),\n })\n}\n\nconst readBackgrounds = (line: runtime.Line, wordLevel: boolean) => {\n const content = line.content\n if (!content) {\n return []\n }\n\n const range = line.time\n if (wordLevel && content.words.length) {\n return splitWords(content.words).runs.map((words) => {\n const time = range ? readWordRange(words, range) : undefined\n return makeBackground(line, words, words.map((word) => word.text).join(''), time, wordLevel)\n })\n }\n\n const text = content.text ?? content.words.map((word) => word.text).join('')\n if (!text) {\n return []\n }\n const { runs, length } = splitText(text)\n return runs.map((run) => {\n return makeBackground(line, [], run.text, range ? mapSpan(range, length, run) : undefined, false)\n })\n}\n\n/**\n * An entry without brackets stays on the line, since only the bracketed part describes a background.\n * The line's annotation is rebuilt rather than edited, so the input lyric stays untouched.\n */\nconst splitAnnotation = (annotation: runtime.LineAnnotation | undefined, backgrounds: runtime.LineBackground[]) => {\n if (!annotation || !backgrounds.length) {\n return annotation\n }\n\n const move = <Item extends runtime.LineAnnotationRoman | runtime.LineAnnotationTranslation>(\n items: Item[],\n rebuild: (item: Item, text: string) => Item,\n push: (background: runtime.LineBackground, text: string, language: string | undefined) => void,\n ) => {\n return items.map((item) => {\n const { main, runs } = splitText(item.text)\n if (!runs.length) {\n return item\n }\n for (const [index, run] of runs.entries()) {\n const background = backgrounds[index]\n if (background) {\n push(background, run.text, item.language)\n }\n }\n return rebuild(item, main)\n })\n }\n\n const romans = move(\n annotation.romans,\n (item, text) => makeLineAnnotationRoman({ ...item, text }),\n (background, text, language) => {\n background.annotation ??= makeLineAnnotation()\n background.annotation.romans.push(makeLineAnnotationRoman({ text, language }))\n },\n )\n const translations = move(\n annotation.translations,\n (item, text) => makeLineAnnotationTranslation({ ...item, text }),\n (background, text, language) => {\n background.annotation ??= makeLineAnnotation()\n background.annotation.translations.push(makeLineAnnotationTranslation({ text, language }))\n },\n )\n return makeLineAnnotation({ ...annotation, romans, translations })\n}\n\n/**\n * Words survive only where the lyric is word-timed, since the other timings forbid them.\n */\nconst toBackground = (line: runtime.Line, time: runtime.TimeRange | undefined, wordLevel: boolean) => {\n const content = line.content\n if (!content) {\n return undefined\n }\n const text = content.text ?? content.words.map((word) => word.text).join('')\n if (!text) {\n return undefined\n }\n return makeLineBackground({\n time,\n agents: [...line.agents],\n languages: [...line.languages],\n content: wordLevel && content.words.length ? content : makeLineContentText(text),\n annotation: line.annotation,\n })\n}\n\nconst isBracketOnlyLine = (line: runtime.Line | undefined) => {\n if (!line || line.type !== LineType.NORMAL) {\n return false\n }\n const { main, runs } = splitText(readLineText(line))\n return runs.length > 0 && !main\n}\n\n/**\n * A line that held nothing but brackets has no text of its own to sing, so it cannot be the one a background accompanies.\n */\nconst findParentIndex = (lines: runtime.Line[]) => {\n for (let index = lines.length - 1; index >= 0; index--) {\n const line = lines[index]\n if (line?.type === LineType.NORMAL && !isBracketOnlyLine(line)) {\n return index\n }\n }\n return -1\n}\n\n/**\n * Both source lines go, since neither holds anything left to sing, and the joined range spans both.\n */\nconst joinCrossLine = (lines: runtime.Line[], wordLevel: boolean) => {\n const result: runtime.Line[] = []\n let changed = false\n let skip = false\n\n for (const [index, line] of lines.entries()) {\n if (skip) {\n skip = false\n continue\n }\n\n const next = lines[index + 1]\n const parentIndex = findParentIndex(result)\n if (line.type === LineType.NORMAL && next?.type === LineType.NORMAL && parentIndex !== -1) {\n const opened = splitText(readLineText(line))\n const closed = splitText(readLineText(next))\n const opens = opened.runs.length === 0 && isOpenBracket(opened.main.charAt(0))\n const closes = closed.runs.length === 0 && isCloseBracket(closed.main.charAt(closed.main.length - 1))\n if (opens && closes) {\n const start = line.time?.start\n const end = next.time?.end ?? next.time?.start\n const background = toBackground(\n { ...line, content: makeLineContentText(opened.main.slice(1) + closed.main.slice(0, -1)) },\n start === undefined ? undefined : makeTimeRange({ start, end }),\n wordLevel,\n )\n if (background) {\n result[parentIndex] = attach(result[parentIndex]!, [background])\n changed = true\n skip = true\n continue\n }\n }\n }\n result.push(line)\n }\n\n return { lines: result, changed }\n}\n\nconst stripRuns = (content: runtime.LineContent): runtime.LineContent | undefined => {\n if (content.words.length) {\n const { main } = splitWords(content.words)\n return main.length ? makeLineContentWords(main) : undefined\n }\n const { main } = splitText(content.text ?? '')\n return main ? makeLineContentText(main) : undefined\n}\n\n/**\n * Pulls bracketed background vocals out of the sung lines and attaches them to the line they accompany.\n *\n * A line holding nothing but brackets becomes a background of the line before it and is removed.\n * A bracket opened on one line and closed on a later one joins the line before the opening, and both source lines go.\n * Text outside brackets stays on its line, and a line left with none keeps its place.\n *\n * @returns The input when unchanged, or a new lyric sharing all unchanged nodes.\n */\nexport const extractBackgroundLines = (lyric: runtime.Lyric, options: ExtractBackgroundLinesOptions = {}): runtime.Lyric => {\n const fullLine = options.fullLine ?? true\n const inLine = options.inLine ?? true\n const crossLine = options.crossLine ?? true\n if (!lyric.lines.length) {\n return lyric\n }\n\n const wordLevel = lyric.timing === Timing.WORD\n const joined = crossLine ? joinCrossLine(lyric.lines, wordLevel) : { lines: lyric.lines, changed: false }\n const result: runtime.Line[] = []\n let changed = joined.changed\n\n for (const line of joined.lines) {\n if (line.type !== LineType.NORMAL || !line.content) {\n result.push(line)\n continue\n }\n\n const parentIndex = findParentIndex(result)\n\n if (fullLine && parentIndex !== -1) {\n const { main, runs } = splitText(readLineText(line))\n if (runs.length && !main) {\n // Every run becomes a background of its own, so a line of two pairs keeps both.\n const backgrounds = runs.map((run) => {\n return makeBackground(line, [], run.text, readTimeRange(line), false)\n })\n result[parentIndex] = attach(result[parentIndex]!, backgrounds)\n changed = true\n continue\n }\n }\n\n const backgrounds = inLine ? readBackgrounds(line, wordLevel) : []\n if (!backgrounds.length) {\n result.push(line)\n continue\n }\n\n const nextContent = stripRuns(line.content)\n\n // A line left with nothing to sing only leaves when fullLine owns that case, so inLine keeps it here.\n if (!nextContent) {\n result.push(line)\n continue\n }\n\n const extracted: runtime.Line = {\n ...line,\n content: nextContent,\n annotation: splitAnnotation(line.annotation, backgrounds),\n }\n result.push(attach(extracted, backgrounds))\n changed = true\n }\n\n if (!changed) {\n return lyric\n }\n const lines = boundOpenBackgrounds(result)\n return { ...lyric, lines, languages: deriveLanguageUsages(lines) }\n}\n","import type { runtime } from '@gondola-lyrics/model'\n\nimport { LineType, WordType, makeWordEmphasis, validateTimeRange } from '@gondola-lyrics/model/runtime'\n\nimport { mapShared } from '@root/utils'\n\nexport interface DeriveWordEmphasisOptions {\n /**\n * Word duration must strictly exceed this threshold, expressed as a non-negative safe integer in milliseconds.\n *\n * @default 3000\n */\n durationThreshold?: number\n}\n\nconst deriveContentEmphasis = (content: runtime.LineContent | undefined, durationThreshold: number): runtime.LineContent | undefined => {\n if (content === undefined) {\n return content\n }\n\n const words = mapShared(content.words, (word) => {\n if (word.type !== WordType.NORMAL || word.emphasis?.derived === false) {\n return word\n }\n\n const time = word.time\n const emphasized =\n time !== undefined && time.end !== undefined && validateTimeRange(time).length === 0 && time.end - time.start > durationThreshold\n\n if (emphasized) {\n if (word.emphasis?.value === true) {\n return word\n }\n return { ...word, emphasis: makeWordEmphasis({ value: true, derived: true }) }\n }\n if (word.emphasis === undefined) {\n return word\n }\n return { ...word, emphasis: undefined }\n })\n\n return words === content.words ? content : { ...content, words }\n}\n\n/**\n * Derives emphasis for normal words in lead and background vocals using complete, valid word ranges.\n * The stored word duration must strictly exceed durationThreshold; metadata offset and duration have no effect.\n *\n * Source emphasis, including an explicit false, is preserved; derived emphasis is cleared when a word no longer qualifies.\n *\n * @returns The input when unchanged, or a new lyric sharing all unchanged nodes.\n *\n * @throws {RangeError} If durationThreshold is not a non-negative safe integer in milliseconds.\n */\nexport const deriveWordEmphasis = (lyric: runtime.Lyric, options: DeriveWordEmphasisOptions = {}): runtime.Lyric => {\n const durationThreshold = options.durationThreshold ?? 3000\n if (!Number.isSafeInteger(durationThreshold) || durationThreshold < 0) {\n throw new RangeError('durationThreshold must be a non-negative safe integer in milliseconds')\n }\n\n const lines = mapShared(lyric.lines, (line) => {\n if (line.type !== LineType.NORMAL) {\n return line\n }\n\n const content = deriveContentEmphasis(line.content, durationThreshold)\n const backgrounds = mapShared(line.backgrounds, (background) => {\n const content = deriveContentEmphasis(background.content, durationThreshold)\n return content === background.content ? background : { ...background, content }\n })\n\n return content === line.content && backgrounds === line.backgrounds ? line : { ...line, content, backgrounds }\n })\n\n return lines === lyric.lines ? lyric : { ...lyric, lines }\n}\n","import type { runtime } from '@gondola-lyrics/model'\n\nimport { LineType, Timing, makeLineInstrumental, makeTimeRange, validateTimeRange } from '@gondola-lyrics/model/runtime'\n\nexport interface InsertInstrumentalLinesOptions {\n /**\n * Minimum gap duration in milliseconds, including an outro.\n *\n * @default 10000\n */\n minDuration?: number\n /**\n * Minimum gap duration before the first vocal in milliseconds.\n *\n * @default 5000\n */\n minIntroDuration?: number\n /**\n * Outro boundary in milliseconds, measured on the same timeline as line ranges.\n * An omitted boundary leaves the outro unknown.\n */\n endTime?: number\n}\n\nconst MAX_TIME = 2 ** 31 - 1\n\nconst readMinimum = (value: number | undefined, fallback: number, name: string): number => {\n const minimum = value ?? fallback\n if (!Number.isSafeInteger(minimum) || minimum < 0) {\n throw new RangeError(`${name} must be a non-negative safe integer in milliseconds`)\n }\n return minimum\n}\n\nconst readEndTime = (value: number | undefined): number | undefined => {\n if (value !== undefined && (!Number.isInteger(value) || value < 0 || value > MAX_TIME)) {\n throw new RangeError(`endTime must be a non-negative integer in milliseconds no greater than ${MAX_TIME}`)\n }\n return value\n}\n\nconst compareTimeRanges = (left: runtime.TimeRange | undefined, right: runtime.TimeRange | undefined): number => {\n const leftStart = left?.start ?? Infinity\n const rightStart = right?.start ?? Infinity\n if (leftStart !== rightStart) {\n return leftStart - rightStart\n }\n\n const leftEnd = left?.end ?? Infinity\n const rightEnd = right?.end ?? Infinity\n return leftEnd === rightEnd ? 0 : leftEnd - rightEnd\n}\n\nconst readOccupiedTimeline = (lyric: runtime.Lyric) => {\n const ranges: runtime.TimeRange[] = []\n let firstSungStart = Infinity\n\n const append = (time: runtime.TimeRange | undefined, sung: boolean): boolean => {\n if (time === undefined || validateTimeRange(time).length > 0) {\n return false\n }\n\n // An empty half-open range cannot divide an uncovered gap.\n if (time.end === time.start) {\n return true\n }\n ranges.push(time)\n if (sung) {\n firstSungStart = Math.min(firstSungStart, time.start)\n }\n return true\n }\n\n for (const line of lyric.lines) {\n if (!append(line.time, line.type === LineType.NORMAL)) {\n return undefined\n }\n for (const background of line.backgrounds) {\n if (!append(background.time, true)) {\n return undefined\n }\n }\n }\n\n ranges.sort(compareTimeRanges)\n return { ranges, firstSungStart }\n}\n\nconst compareLineTimes = (left: runtime.Line, right: runtime.Line): number => {\n return compareTimeRanges(left.time, right.time)\n}\n\nconst mergeLines = (lines: runtime.Line[], inserted: runtime.Line[]): runtime.Line[] => {\n let source = lines\n for (const [index, line] of lines.entries()) {\n const previous = lines[index - 1]\n if (previous !== undefined && compareLineTimes(previous, line) > 0) {\n source = [...lines].sort(compareLineTimes)\n break\n }\n }\n\n const merged: runtime.Line[] = []\n let nextIndex = 0\n for (const line of source) {\n let next = inserted[nextIndex]\n while (next !== undefined && compareLineTimes(next, line) < 0) {\n merged.push(next)\n nextIndex += 1\n next = inserted[nextIndex]\n }\n merged.push(line)\n }\n merged.push(...inserted.slice(nextIndex))\n return merged\n}\n\n/**\n * Inserts derived instrumental lines into uncovered gaps on the stored timeline, starting at zero.\n * Existing lines and background vocals occupy their full ranges; an unknown end blocks later gaps.\n *\n * An outro requires an explicit endTime; metadata duration and offset do not affect insertion.\n *\n * @returns The input when unchanged, or a new lyric and lines array sharing existing nodes.\n */\nexport const insertInstrumentalLines = (lyric: runtime.Lyric, options: InsertInstrumentalLinesOptions = {}): runtime.Lyric => {\n const minDuration = readMinimum(options.minDuration, 10000, 'minDuration')\n const minIntroDuration = readMinimum(options.minIntroDuration, 5000, 'minIntroDuration')\n const endTime = readEndTime(options.endTime)\n if ((lyric.timing !== Timing.LINE && lyric.timing !== Timing.WORD) || lyric.lines.length === 0) {\n return lyric\n }\n\n const occupied = readOccupiedTimeline(lyric)\n if (!occupied || occupied.firstSungStart === Infinity) {\n return lyric\n }\n\n const inserted: runtime.Line[] = []\n let coveredEnd = 0\n\n const appendGap = (end: number, minimum: number): void => {\n const duration = end - coveredEnd\n if (duration > 0 && duration >= minimum) {\n inserted.push(makeLineInstrumental({ time: makeTimeRange({ start: coveredEnd, end }) }))\n }\n }\n\n for (const range of occupied.ranges) {\n appendGap(range.start, range.start <= occupied.firstSungStart ? minIntroDuration : minDuration)\n // An unknown end gives no evidence of a later gap, so it occupies the rest of the timeline.\n coveredEnd = Math.max(coveredEnd, range.end ?? Infinity)\n if (coveredEnd === Infinity) {\n break\n }\n }\n\n if (endTime !== undefined) {\n appendGap(endTime, minDuration)\n }\n\n if (inserted.length === 0) {\n return lyric\n }\n return { ...lyric, lines: mergeLines(lyric.lines, inserted) }\n}\n","/**\n * Groups of characters a source may write without a space where one belongs.\n */\nexport const InsertSpacesRules = {\n /**\n * A CJK character touching a Latin letter, as in `ABC中文`.\n */\n CJK_ENGLISH: 'cjkEnglish',\n /**\n * A CJK character touching a digit, as in `2026年`.\n */\n CJK_NUMBER: 'cjkNumber',\n /**\n * A comma, semicolon, exclamation mark, question mark or colon touching a character, as in `a,b`; a clock time or thousands separator such as `10:30` stays as written.\n */\n PUNCTUATION: 'punctuation',\n /**\n * A quotation mark touching a neighbouring character.\n */\n QUOTE: 'quote',\n /**\n * A bracket touching the character outside it.\n */\n BRACKET_OUTSIDE: 'bracketOutside',\n /**\n * A plus, equals or ampersand touching a character, as in `a+b`; a compound operator such as `a+=b` stays as written.\n */\n MATH_OPERATOR: 'mathOperator',\n /**\n * A hyphen touching a CJK character, as in `中-文`; a compound word such as `well-known` stays as written.\n */\n HYPHEN: 'hyphen',\n /**\n * A slash touching a character, as in `and/or`; a fraction such as `1/2` stays as written.\n */\n SLASH: 'slash',\n /**\n * Runs of two or more spaces, collapsed to one.\n */\n COMPRESS_SPACES: 'compressSpaces',\n /**\n * Spaces just inside a bracket or quotation mark, removed.\n */\n TRIM_INSIDE_SYMBOLS: 'trimInsideSymbols',\n} as const\n\nexport type InsertSpacesRule = (typeof InsertSpacesRules)[keyof typeof InsertSpacesRules]\n\nexport const INSERT_SPACES_RULES = Object.values(InsertSpacesRules) as InsertSpacesRule[]\n","import type { InsertSpacesRule } from './constants'\n\nimport { INSERT_SPACES_RULES, InsertSpacesRules } from './constants'\n\n// Kana, CJK extensions, unified ideographs and compatibility ideographs.\nconst CJK_RANGE = '\\u3040-\\u30ff\\u3400-\\u4dbf\\u4e00-\\u9fff\\uf900-\\ufaff'\nconst LATIN_RANGE = 'A-Za-z'\nconst DIGIT_RANGE = '0-9'\nconst SYMBOL_RANGE = '!@#$%^&+\\\\-=/|<>'\nconst WORD_RANGE = `${LATIN_RANGE}${DIGIT_RANGE}${CJK_RANGE}`\nconst ALL_RANGE = `${WORD_RANGE}${SYMBOL_RANGE}`\n\nconst CJK_LATIN = new RegExp(`([${CJK_RANGE}])([${LATIN_RANGE}])`, 'gu')\nconst LATIN_CJK = new RegExp(`([${LATIN_RANGE}])([${CJK_RANGE}])`, 'gu')\nconst CJK_DIGIT = new RegExp(`([${CJK_RANGE}])([${DIGIT_RANGE}])`, 'gu')\nconst DIGIT_CJK = new RegExp(`([${DIGIT_RANGE}])([${CJK_RANGE}])`, 'gu')\n\nconst PUNCTUATION = new RegExp(`([${ALL_RANGE}])([!;,\\\\?:])(?=[${ALL_RANGE}])`, 'gu')\nconst QUOTE_BEFORE = new RegExp(`([${CJK_RANGE}${LATIN_RANGE}${DIGIT_RANGE}])([\"\\`“‘])`, 'gu')\nconst QUOTE_AFTER = new RegExp(`([\"”’])([${CJK_RANGE}${LATIN_RANGE}${DIGIT_RANGE}])`, 'gu')\nconst BRACKET_BEFORE = new RegExp(`([${WORD_RANGE}])([\\\\[({<])`, 'gu')\nconst BRACKET_AFTER = new RegExp(`([\\\\])}>])([${WORD_RANGE}])`, 'gu')\nconst MATH_OPERATOR = new RegExp(`([${ALL_RANGE}])([+=&])(?=[${ALL_RANGE}])`, 'gu')\nconst HYPHEN = new RegExp(`(?<=[${WORD_RANGE}])-(?=[${WORD_RANGE}])`, 'gu')\nconst SLASH = new RegExp(`([${WORD_RANGE}])(/)(?=[${WORD_RANGE}])`, 'gu')\nconst TRIM_INSIDE_SYMBOLS = new RegExp('([<[{\"“‘(])\\\\s*([^<>[\\\\]{}()\"“‘”’]*?)\\\\s*([>\\\\]}\"”’)])', 'gu')\nconst REPEATED_SPACES = / {2,}/gu\n\n// A run of two or more marks belongs together: `a--b`, `a//b`, `a...b`, `a::b` and `a+=b` stay as written.\nconst REPEATED_MARKS = /[!;,\\\\?:+\\-=/&]{2,}/gu\n\n// A control character stands in for a held run, since lyric text never carries one and no rule's character class covers it.\nconst PLACEHOLDER = /\\u0001(\\d+)\\u0001/gu\n\nconst isDigit = (char: string | undefined) => {\n return char !== undefined && char >= '0' && char <= '9'\n}\n\nconst isLatin = (char: string | undefined) => {\n return char !== undefined && ((char >= 'A' && char <= 'Z') || (char >= 'a' && char <= 'z'))\n}\n\n/**\n * A comma or colon between two digits belongs to one number or clock time, so it stays tight.\n */\nconst applyPunctuation = (text: string) => {\n return text.replace(PUNCTUATION, (match, before: string, mark: string, offset: number, source: string) => {\n if ((mark === ',' || mark === ':') && isDigit(before) && isDigit(source[offset + match.length])) {\n return match\n }\n return `${before}${mark} `\n })\n}\n\n/**\n * A hyphen between two digits is a date, range or phone number, and one between two Latin letters joins a compound word.\n *\n * An edge hyphen is left alone, since it reads as a sign or a list marker rather than a dash.\n */\nconst applyHyphen = (text: string) => {\n return text.replace(HYPHEN, (match, offset: number, source: string) => {\n const left = source[offset - 1]\n const right = source[offset + 1]\n return (isDigit(left) && isDigit(right)) || (isLatin(left) && isLatin(right)) ? match : ' - '\n })\n}\n\n/**\n * A slash between two digits is a fraction or date, so it stays tight.\n */\nconst applySlash = (text: string) => {\n return text.replace(SLASH, (match, before: string, slash: string, offset: number, source: string) => {\n return isDigit(before) && isDigit(source[offset + match.length]) ? match : `${before} ${slash} `\n })\n}\n\n/**\n * Trims the spaces just inside a bracket or quotation mark, without touching a nested pair inside it.\n */\nconst applyTrimInsideSymbols = (text: string) => {\n return text.replace(TRIM_INSIDE_SYMBOLS, (match, left: string, inner: string, right: string) => {\n return `${left}${inner.trim()}${right}`\n })\n}\n\nconst APPLIERS: Record<InsertSpacesRule, (text: string) => string> = {\n [InsertSpacesRules.CJK_ENGLISH]: (text) => {\n return text.replace(CJK_LATIN, '$1 $2').replace(LATIN_CJK, '$1 $2')\n },\n [InsertSpacesRules.CJK_NUMBER]: (text) => {\n return text.replace(CJK_DIGIT, '$1 $2').replace(DIGIT_CJK, '$1 $2')\n },\n [InsertSpacesRules.PUNCTUATION]: applyPunctuation,\n [InsertSpacesRules.QUOTE]: (text) => {\n return text.replace(QUOTE_BEFORE, '$1 $2').replace(QUOTE_AFTER, '$1 $2')\n },\n [InsertSpacesRules.BRACKET_OUTSIDE]: (text) => {\n return text.replace(BRACKET_BEFORE, '$1 $2').replace(BRACKET_AFTER, '$1 $2')\n },\n [InsertSpacesRules.MATH_OPERATOR]: (text) => {\n return text.replace(MATH_OPERATOR, '$1 $2 ')\n },\n [InsertSpacesRules.HYPHEN]: applyHyphen,\n [InsertSpacesRules.SLASH]: applySlash,\n [InsertSpacesRules.COMPRESS_SPACES]: (text) => {\n return text.replace(REPEATED_SPACES, ' ')\n },\n [InsertSpacesRules.TRIM_INSIDE_SYMBOLS]: applyTrimInsideSymbols,\n}\n\n// Order matters: separating marks first, then tidying the spaces they may have doubled.\nconst APPLY_ORDER: InsertSpacesRule[] = [\n InsertSpacesRules.CJK_ENGLISH,\n InsertSpacesRules.CJK_NUMBER,\n InsertSpacesRules.PUNCTUATION,\n InsertSpacesRules.QUOTE,\n InsertSpacesRules.BRACKET_OUTSIDE,\n InsertSpacesRules.MATH_OPERATOR,\n InsertSpacesRules.HYPHEN,\n InsertSpacesRules.SLASH,\n InsertSpacesRules.TRIM_INSIDE_SYMBOLS,\n InsertSpacesRules.COMPRESS_SPACES,\n]\n\n/**\n * Falls back to every rule only when no list was given, so an explicit empty list means \"apply nothing\".\n */\nexport const resolveRules = (rules: InsertSpacesRule[] | undefined) => {\n return new Set(rules ?? INSERT_SPACES_RULES)\n}\n\n/**\n * Applies the selected rules to one text, returning it trimmed.\n *\n * Repeated marks are held aside first, so a rule that widens a single mark never splits a run that belongs together.\n */\nexport const insertSpaces = (text: string, rules: Set<InsertSpacesRule>) => {\n if (!text.trim()) {\n return text\n }\n\n const held: string[] = []\n const guarded = text.replace(REPEATED_MARKS, (match) => {\n held.push(match)\n return `\\u0001${held.length - 1}\\u0001`\n })\n\n let result = guarded\n for (const rule of APPLY_ORDER) {\n if (rules.has(rule)) {\n result = APPLIERS[rule](result)\n }\n }\n return result\n .replace(PLACEHOLDER, (match, index: string) => {\n return held[Number(index)] ?? match\n })\n .trim()\n}\n","import type { runtime } from '@gondola-lyrics/model'\nimport type { InsertSpacesRule } from './constants'\n\nimport {\n LineType,\n makeLineAnnotationRoman,\n makeLineAnnotationTranslation,\n makeLineContentText,\n makeLineContentWords,\n makeWordSpace,\n} from '@gondola-lyrics/model/runtime'\n\nimport { mapShared } from '@root/utils'\n\nimport { isNormalWord } from '../background/utils'\nimport { insertSpaces, resolveRules } from './rules'\n\nexport interface InsertSpacesOptions {\n /**\n * Rules to apply; omitting the list applies all of them.\n */\n rules?: InsertSpacesRule[]\n /**\n * Rewrite the translation and romanization tracks too.\n *\n * @default true\n */\n annotations?: boolean\n}\n\n/**\n * Maps the rewritten text back onto the original words.\n *\n * Every non-space character of the original survives in order, so walking both strings keeps each word's time,\n * language and annotation while the inserted spaces become their own words.\n * A word whose characters stay adjacent in the rewrite is kept whole, so only a word the space actually cuts is split.\n */\nconst alignWords = (words: runtime.Word[], text: string) => {\n const source = words.filter(isNormalWord)\n const result: runtime.Word[] = []\n let cursor = 0\n\n const takeSpaces = () => {\n let spaces = ''\n while (text[cursor] === ' ') {\n spaces += ' '\n cursor += 1\n }\n return spaces\n }\n\n for (const word of source) {\n const spaces = takeSpaces()\n if (spaces) {\n result.push(makeWordSpace({ text: spaces }))\n }\n\n // A word the rewrite left intact keeps its identity, including any annotation and emphasis.\n if (text.startsWith(word.text, cursor)) {\n result.push(word)\n cursor += word.text.length\n continue\n }\n\n // The rewrite split this word, so each piece carries the slice it stands for.\n let remaining = word.text\n while (remaining) {\n let taken = 0\n while (taken < remaining.length && text[cursor + taken] === remaining[taken]) {\n taken += 1\n }\n if (taken === 0) {\n return undefined\n }\n result.push({ ...word, text: remaining.slice(0, taken) })\n cursor += taken\n remaining = remaining.slice(taken)\n if (!remaining) {\n break\n }\n const split = takeSpaces()\n if (!split) {\n // Nothing separates the pieces, so the rewrite changed more than spacing.\n return undefined\n }\n result.push(makeWordSpace({ text: split }))\n }\n }\n\n const tail = takeSpaces()\n if (tail) {\n result.push(makeWordSpace({ text: tail }))\n }\n\n // A leftover character means the rewrite changed something other than spacing, so the caller keeps the original words.\n if (cursor !== text.length) {\n return undefined\n }\n return result\n}\n\n/**\n * Applies the rules to a word-level content, keeping it unchanged when the alignment fails.\n */\nconst applyToWords = (content: runtime.LineContent, rules: Set<InsertSpacesRule>) => {\n const text = content.words.map((word) => word.text).join('')\n const rewritten = insertSpaces(text, rules)\n if (rewritten === text) {\n return content\n }\n\n const words = alignWords(content.words, rewritten)\n if (!words) {\n return content\n }\n return words.length ? makeLineContentWords(words) : undefined\n}\n\n/**\n * Applies the rules to a plain-text content, dropping a line the rules would leave empty.\n */\nconst applyToText = (content: runtime.LineContent, rules: Set<InsertSpacesRule>) => {\n const text = content.text ?? ''\n const rewritten = insertSpaces(text, rules)\n if (rewritten === text) {\n return content\n }\n return rewritten ? makeLineContentText(rewritten) : undefined\n}\n\n/**\n * Applies the rules to one content by the shape it carries.\n */\nconst applyToContent = (content: runtime.LineContent | undefined, rules: Set<InsertSpacesRule>) => {\n if (!content) {\n return content\n }\n return content.words.length ? applyToWords(content, rules) : applyToText(content, rules)\n}\n\n/**\n * Applies the rules to the line annotation, keeping the entries they leave untouched.\n */\nconst applyToAnnotation = (annotation: runtime.LineAnnotation | undefined, rules: Set<InsertSpacesRule>) => {\n if (!annotation) {\n return annotation\n }\n\n let changed = false\n const romans = annotation.romans.map((item) => {\n const text = insertSpaces(item.text, rules)\n if (text === item.text) {\n return item\n }\n changed = true\n return makeLineAnnotationRoman({ ...item, text })\n })\n const translations = annotation.translations.map((item) => {\n const text = insertSpaces(item.text, rules)\n if (text === item.text) {\n return item\n }\n changed = true\n return makeLineAnnotationTranslation({ ...item, text })\n })\n return changed ? { ...annotation, romans, translations } : annotation\n}\n\n/**\n * Inserts the spaces a source left out, so CJK text set against Latin letters, digits or punctuation reads evenly.\n *\n * A word-level line keeps every word's time and annotation: an inserted space becomes its own space word,\n * and a word the rules split yields one word per character, all sharing the original range.\n * A plain-text line and the annotation tracks are rewritten as whole strings.\n *\n * @returns The input when unchanged, or a new lyric sharing all unchanged nodes.\n */\nexport const insertSpacesInLines = (lyric: runtime.Lyric, options: InsertSpacesOptions = {}): runtime.Lyric => {\n const rules = resolveRules(options.rules)\n const annotations = options.annotations ?? true\n\n const applyToBackground = (background: runtime.LineBackground): runtime.LineBackground => {\n const content = applyToContent(background.content, rules)\n const annotation = annotations ? applyToAnnotation(background.annotation, rules) : background.annotation\n if (content === background.content && annotation === background.annotation) {\n return background\n }\n return { ...background, content, annotation }\n }\n\n const lines = mapShared(lyric.lines, (line) => {\n if (line.type !== LineType.NORMAL) {\n return line\n }\n\n const content = applyToContent(line.content, rules)\n const annotation = annotations ? applyToAnnotation(line.annotation, rules) : line.annotation\n const backgrounds = mapShared(line.backgrounds, applyToBackground)\n if (content === line.content && annotation === line.annotation && backgrounds === line.backgrounds) {\n return line\n }\n return { ...line, content, annotation, backgrounds }\n })\n\n return lines === lyric.lines ? lyric : { ...lyric, lines }\n}\n\nexport type { InsertSpacesRule } from './constants'\n\nexport { InsertSpacesRules } from './constants'\n"],"mappings":";;;;;;;AAKA,IAAa,aAAgB,OAAY,cAAmC;CAC1E,IAAI,SAAS;CACb,KAAK,MAAM,CAAC,OAAO,SAAS,MAAM,QAAQ,GAAG;EAC3C,MAAM,cAAc,UAAU,IAAI;EAClC,IAAI,gBAAgB,MAAM;GACxB,IAAI,WAAW,OACb,SAAS,CAAC,GAAG,KAAK;GAEpB,OAAO,SAAS;EAClB;CACF;CACA,OAAO;AACT;;;ACbA,IAAM,gCAAgB,IAAI,IAAI,CAAC,KAAK,GAAG,CAAC;AACxC,IAAM,iCAAiB,IAAI,IAAI,CAAC,KAAK,GAAG,CAAC;AAEzC,IAAa,iBAAiB,SAAiB;CAC7C,OAAO,cAAc,IAAI,IAAI;AAC/B;AAEA,IAAa,kBAAkB,SAAiB;CAC9C,OAAO,eAAe,IAAI,IAAI;AAChC;AAEA,IAAa,gBAAgB,SAAuB;CAClD,OAAO,KAAK,SAAS,SAAS;AAChC;;;;AAKA,IAAa,gBAAgB,SAAuB;CAClD,OAAO,KAAK,SAAS,SAAS,KAAK,SAAS,SAAS,CAAC,EAAA,CAAG,KAAK,SAAS,KAAK,IAAI,CAAC,CAAC,KAAK,EAAE;AAC3F;AAEA,IAAa,iBAAiB,SAAuB;CACnD,OAAO,KAAK,OAAO,cAAc;EAAE,OAAO,KAAK,KAAK;EAAO,KAAK,KAA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