refactor(font): scaffold dualFontLayout module with shared types

This commit is contained in:
Ilia Mashkov
2026-05-30 21:48:56 +03:00
parent ddadac8686
commit c5092a488b
4 changed files with 145 additions and 0 deletions
@@ -0,0 +1,5 @@
import { describe } from 'vitest';
describe('computeLineRenderModel', () => {
// tests added in subsequent tasks
});
@@ -0,0 +1,45 @@
import type {
ComparisonChar,
ComparisonLine,
} from '../DualFontLayout/DualFontLayout';
/**
* Per-line render slice consumed by Line.svelte. The window is centered on the
* slider's split index and clamps at line boundaries.
*/
export interface LineRenderModel {
/**
* Chars before the window joined into a single string, rendered as one fontA text run.
*/
leftText: string;
/**
* Window chars — each rendered as its own Character element with crossfade slots.
*/
windowChars: Array<{
/**
* Stable key for Svelte keyed each — survives slider movement within the same line.
*/
key: string;
/**
* Grapheme cluster to render.
*/
char: string;
/**
* True once the slider has crossed this char's threshold.
*/
isPast: boolean;
}>;
/**
* Chars after the window joined into a single string, rendered as one fontB text run.
*/
rightText: string;
}
export function computeLineRenderModel(
line: ComparisonLine,
sliderPos: number,
containerWidth: number,
windowSize: number,
): LineRenderModel {
throw new Error('not implemented');
}