Skip to content

Deduplicate Syllable and Line lyrics applyers into shared pipeline - #343

Open
zzleep wants to merge 1 commit into
Spikerko:developmentfrom
zzleep:refactor/synced-applyer-dedup
Open

Deduplicate Syllable and Line lyrics applyers into shared pipeline#343
zzleep wants to merge 1 commit into
Spikerko:developmentfrom
zzleep:refactor/synced-applyer-dedup

Conversation

@zzleep

@zzleep zzleep commented Aug 7, 2026

Copy link
Copy Markdown

Summary

ApplySyllableLyrics (Syllable.ts, 566 lines) and ApplyLineLyrics (Line.ts, 334 lines) were ~80% structurally identical: container setup, RTL/duet detection, musical interlude dots, line-end-time computation, credits/provider application, SimpleBar/virtualizer wiring, and styling all existed twice with only minor differences (lines array, SetWordArray* hook, end-time store flag, word-building).

This PR extracts the shared pipeline into a new Synced/Base.ts and parameterizes the differences through a small SyncedApplyMode config:

  • Synced/Base.ts (new, ~290 lines) — ApplySyncedLyrics, CreateMusicalLine (unified leading + gap interlude builder), PushSyncedWord, shared types
  • Syllable.ts — 566 → ~260 lines; keeps all word-level logic: letter emphasis (Emphasize), word grouping, background lines
  • Line.ts — 334 → ~46 lines; just its types, the textContent builder, and mode config

Net −591 lines (+508/−807 across 3 files).

Behavior preserved (verified line-by-line)

  • $minimalLyricsMode (Syllable) vs $simpleLyricsMode (Line) end-time extension stays separate
  • SetWordArrayInCurentLine / SetWordArrayInCurentLine_LINE_SYNCED called at the exact same points — critical because Emphasize reads the global CurrentLineLyricsObject; LINE_SYNCED regular lines still get no word array
  • Musical-dot timing math identical (leading and gap cases unify to the same formula with lineStartTime = 0)
  • BG-word class asymmetry preserved (bg-word only on non-letter background words), BGWord: true pushes intact
  • Target lines array resolved after ClearLyricsContentArrays (which swaps in fresh arrays)
  • The two previously unguarded dot pushes in Line.ts are now guarded — behaviorally identical since Syllables.Lead is always initialized before them
  • Public APIs (ApplySyllableLyrics, ApplyLineLyrics) unchanged; no other files touched

Verification

  • bun run build — 198 modules, success (production + dev watcher)
  • bun run lint — no new warnings
  • oxfmt --check — clean
  • tsc --noEmit — identical set of pre-existing errors before/after, none in the touched files

@greptile-apps

greptile-apps Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR consolidates the duplicated line-synced and syllable-synced rendering flows into a configurable shared pipeline while retaining each mode's word-building and timing behavior.

  • Adds shared container setup, interlude generation, metadata registration, virtualization, credits, and styling in Synced/Base.ts.
  • Reduces Line.ts to its line-specific content builder and mode configuration.
  • Keeps syllable emphasis, grouping, background-line construction, and word metadata handling in Syllable.ts.

Confidence Score: 5/5

The PR appears safe to merge, with no concrete regressions identified in the refactored synced-lyrics pipeline.

The shared pipeline preserves metadata and DOM ordering, mode-specific end-time handling, current-line initialization, interlude timing, and virtualizer inputs across both synced lyric modes.

Important Files Changed

Filename Overview
src/utils/Lyrics/Applyer/Synced/Base.ts Introduces the common synced-lyrics lifecycle and interlude pipeline while resolving target metadata arrays after state clearing.
src/utils/Lyrics/Applyer/Synced/Line.ts Replaces the duplicated line renderer with a small mode configuration preserving line text, RTL, and end-time behavior.
src/utils/Lyrics/Applyer/Synced/Syllable.ts Retains syllable-specific emphasis, grouping, background lines, and metadata registration through extracted synchronous builders.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[ApplyLineLyrics] --> C[ApplySyncedLyrics]
  B[ApplySyllableLyrics] --> C
  LM[Line mode configuration] --> C
  SM[Syllable mode configuration] --> C
  C --> D[Clear state and create container]
  D --> E[Build regular lines]
  E --> F[Mode-specific content builder]
  E --> G[Create shared musical interludes]
  F --> H[Line metadata and DOM elements]
  G --> H
  H --> I[Apply credits and provider]
  I --> J[Mount SimpleBar and virtualizer]
  J --> K[Emit applied event]
Loading

Reviews (1): Last reviewed commit: "Deduplicate Syllable and Line lyrics app..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant