refactor: restructure files to their domains, new preview overlay system, and dep graph

This commit is contained in:
Maze Winther
2026-04-20 11:31:17 +02:00
parent 729d10592f
commit 3e89d29985
491 changed files with 3565 additions and 2372 deletions
@@ -0,0 +1,54 @@
import type { SceneTracks, TimelineElement, VideoTrack } from "@/timeline";
export const MAIN_TRACK_NAME = "Main Track";
export function getEarliestMainTrackElement({
mainTrack,
excludeElementId,
}: {
mainTrack: VideoTrack;
excludeElementId?: string;
}): TimelineElement | null {
const elements = mainTrack.elements.filter((element) => {
return !excludeElementId || element.id !== excludeElementId;
});
if (elements.length === 0) {
return null;
}
return elements.reduce((earliestElement, element) => {
return element.startTime < earliestElement.startTime
? element
: earliestElement;
});
}
export function enforceMainTrackStart({
tracks,
targetTrackId,
requestedStartTime,
excludeElementId,
}: {
tracks: SceneTracks;
targetTrackId: string;
requestedStartTime: number;
excludeElementId?: string;
}): number {
if (tracks.main.id !== targetTrackId) {
return requestedStartTime;
}
const earliestElement = getEarliestMainTrackElement({
mainTrack: tracks.main,
excludeElementId,
});
if (!earliestElement) {
return 0;
}
if (requestedStartTime <= earliestElement.startTime) {
return 0;
}
return requestedStartTime;
}