// SPDX-License-Identifier: AGPL-3.0-only // Ported from Folia (https://github.com/chthollyphile/folia-major, v0.8.2), src/types.ts and // src/utils/lyrics/renderHints.ts: the lyric and theme shapes the lyric styles read. See ./README.md. export type LineTimingClass = 'normal' | 'short' | 'micro'; export type LineTransitionMode = 'normal' | 'fast' | 'none'; export type WordRevealMode = 'normal' | 'fast' | 'instant'; export interface LineRenderHints { rawDuration: number; timingClass: LineTimingClass; renderEndTime: number; lineTransitionMode: LineTransitionMode; wordRevealMode: WordRevealMode; } export interface Word { text: string; /** Seconds. */ startTime: number; /** Seconds. */ endTime: number; } export interface Line { words: Word[]; startTime: number; endTime: number; fullText: string; translation?: string; renderHints?: LineRenderHints; isChorus?: boolean; } export interface Theme { name: string; backgroundColor: string; primaryColor: string; accentColor: string; secondaryColor: string; /** A CSS font-family list; Folia resolves one from fontStyle, here the host page gives its own. */ fontStack: string; fontWeight?: number; /** The heaviest weight the host's typeface has; a style's own weight is held to it. Not in Folia. */ maxFontWeight?: number; animationIntensity: 'calm' | 'normal' | 'chaotic'; wordColors?: { word: string; color: string }[]; } /** The settings of the lyric styles, as Folia's own settings window has them, with Folia's defaults. */ export interface StageTunings { classic: { enableWordRotation: boolean; breathingFloatMultiplier: number; wordSpacing: number }; cadenza: { fontScale: number; widthRatio: number; motionAmount: number; glowIntensity: number }; partita: { showGuideLines: boolean; useSemanticLayout: boolean; staggerMin: number; staggerMax: number }; tilt: { splitProbability: number; tiltStyleProbability: number; colorScheme: 'default' | 'swap' | 'accentAll' | 'primaryAll' }; } export const DEFAULT_TUNINGS: StageTunings = { classic: { enableWordRotation: true, breathingFloatMultiplier: 1, wordSpacing: 0.7 }, cadenza: { fontScale: 1.12, widthRatio: 0.72, motionAmount: 1, glowIntensity: 1 }, partita: { showGuideLines: true, useSemanticLayout: true, staggerMin: 20, staggerMax: 100 }, tilt: { splitProbability: 0.75, tiltStyleProbability: 0.35, colorScheme: 'default' }, }; /** The colours and motion a look may set for one side (day or night); what it leaves out stays the host's. */ export type ThemeOverride = Partial>; /** * A look for the stage: what a Folia config code carries of the things this port draws (./appearance.ts reads * and writes the codes). Everything is optional; what is left out is the host's theme and Folia's defaults. */ export interface Appearance { theme?: { light?: ThemeOverride; dark?: ThemeOverride }; /** The lyric style, by Folia's id. */ style?: string; tunings?: { [K in keyof StageTunings]?: Partial }; /** Lyric size, 1 for the style's own. */ fontScale?: number; fontWeight?: number; /** Font families put before the host's own. */ fontFamilies?: string[]; hideShapes?: boolean; hideVignette?: boolean; /** The whole lyric layer's opacity. */ opacity?: number; subtitle?: { hidden?: boolean; opacity?: number; background?: boolean; blur?: boolean; scale?: number }; } /** What the music sounds like now, on Folia's scale: every level 0..255. */ export interface AudioLevels { power: number; bass: number; lowMid: number; mid: number; vocal: number; treble: number; } /** A style's weight for its lyrics: the theme's own when it names one (as in Folia), else the style's, held to what the typeface has. */ export const resolveThemeFontWeight = (theme: Pick, fallback: number) => ( theme.fontWeight ?? Math.min(fallback, theme.maxFontWeight ?? 900) ); export const SILENT_AUDIO: AudioLevels = { power: 0, bass: 0, lowMid: 0, mid: 0, vocal: 0, treble: 0 };