summaryrefslogtreecommitdiff
path: root/apps/web/src/types
diff options
context:
space:
mode:
authorHyteq <DerpsDer.es@gmail.com>2025-07-20 10:48:40 +0300
committerHyteq <DerpsDer.es@gmail.com>2025-07-20 10:48:40 +0300
commiteab8ec3ba81b86fdd4ade920d999c28fb34785b1 (patch)
tree619fc6930f50fa36d6f1f94ee81fb8bf6d4bedef /apps/web/src/types
parentd040ca53cb4029c9c58bd7e6b6dfd1eed2694b31 (diff)
downloadopencut-eab8ec3ba81b86fdd4ade920d999c28fb34785b1.tar.gz
format, cleanup, deps
Diffstat (limited to 'apps/web/src/types')
-rw-r--r--apps/web/src/types/editor.ts24
-rw-r--r--apps/web/src/types/playback.ts32
-rw-r--r--apps/web/src/types/project.ts20
-rw-r--r--apps/web/src/types/timeline.ts200
4 files changed, 138 insertions, 138 deletions
diff --git a/apps/web/src/types/editor.ts b/apps/web/src/types/editor.ts
index dce7ac50..d09e1912 100644
--- a/apps/web/src/types/editor.ts
+++ b/apps/web/src/types/editor.ts
@@ -1,12 +1,12 @@
-export type BackgroundType = "blur" | "mirror" | "color";
-
-export interface CanvasSize {
- width: number;
- height: number;
-}
-
-export interface CanvasPreset {
- name: string;
- width: number;
- height: number;
-}
+export type BackgroundType = "blur" | "mirror" | "color";
+
+export interface CanvasSize {
+ width: number;
+ height: number;
+}
+
+export interface CanvasPreset {
+ name: string;
+ width: number;
+ height: number;
+}
diff --git a/apps/web/src/types/playback.ts b/apps/web/src/types/playback.ts
index 8758ea03..18c1e099 100644
--- a/apps/web/src/types/playback.ts
+++ b/apps/web/src/types/playback.ts
@@ -1,21 +1,21 @@
export interface PlaybackState {
- isPlaying: boolean;
- currentTime: number;
- duration: number;
- volume: number;
- speed: number;
- muted: boolean;
- previousVolume?: number;
+ isPlaying: boolean;
+ currentTime: number;
+ duration: number;
+ volume: number;
+ speed: number;
+ muted: boolean;
+ previousVolume?: number;
}
export interface PlaybackControls {
- play: () => void;
- pause: () => void;
- seek: (time: number) => void;
- setVolume: (volume: number) => void;
- setSpeed: (speed: number) => void;
- toggle: () => void;
- mute: () => void;
- unmute: () => void;
- toggleMute: () => void;
+ play: () => void;
+ pause: () => void;
+ seek: (time: number) => void;
+ setVolume: (volume: number) => void;
+ setSpeed: (speed: number) => void;
+ toggle: () => void;
+ mute: () => void;
+ unmute: () => void;
+ toggleMute: () => void;
}
diff --git a/apps/web/src/types/project.ts b/apps/web/src/types/project.ts
index 58d37b03..b3ab1332 100644
--- a/apps/web/src/types/project.ts
+++ b/apps/web/src/types/project.ts
@@ -1,12 +1,12 @@
export interface TProject {
- id: string;
- name: string;
- thumbnail: string;
- createdAt: Date;
- updatedAt: Date;
- mediaItems?: string[];
- backgroundColor?: string;
- backgroundType?: "color" | "blur";
- blurIntensity?: number; // in pixels (4, 8, 18)
- fps?: number;
+ id: string;
+ name: string;
+ thumbnail: string;
+ createdAt: Date;
+ updatedAt: Date;
+ mediaItems?: string[];
+ backgroundColor?: string;
+ backgroundType?: "color" | "blur";
+ blurIntensity?: number; // in pixels (4, 8, 18)
+ fps?: number;
}
diff --git a/apps/web/src/types/timeline.ts b/apps/web/src/types/timeline.ts
index 146205c4..6d4f9c0d 100644
--- a/apps/web/src/types/timeline.ts
+++ b/apps/web/src/types/timeline.ts
@@ -6,36 +6,36 @@ export type TrackType = "media" | "text" | "audio";
// Base element properties
interface BaseTimelineElement {
- id: string;
- name: string;
- duration: number;
- startTime: number;
- trimStart: number;
- trimEnd: number;
+ id: string;
+ name: string;
+ duration: number;
+ startTime: number;
+ trimStart: number;
+ trimEnd: number;
}
// Media element that references MediaStore
export interface MediaElement extends BaseTimelineElement {
- type: "media";
- mediaId: string;
+ type: "media";
+ mediaId: string;
}
// Text element with embedded text data
export interface TextElement extends BaseTimelineElement {
- type: "text";
- content: string;
- fontSize: number;
- fontFamily: string;
- color: string;
- backgroundColor: string;
- textAlign: "left" | "center" | "right";
- fontWeight: "normal" | "bold";
- fontStyle: "normal" | "italic";
- textDecoration: "none" | "underline" | "line-through";
- x: number; // Position relative to canvas center
- y: number; // Position relative to canvas center
- rotation: number; // in degrees
- opacity: number; // 0-1
+ type: "text";
+ content: string;
+ fontSize: number;
+ fontFamily: string;
+ color: string;
+ backgroundColor: string;
+ textAlign: "left" | "center" | "right";
+ fontWeight: "normal" | "bold";
+ fontStyle: "normal" | "italic";
+ textDecoration: "none" | "underline" | "line-through";
+ x: number; // Position relative to canvas center
+ y: number; // Position relative to canvas center
+ rotation: number; // in degrees
+ opacity: number; // 0-1
}
// Typed timeline elements
@@ -47,131 +47,131 @@ export type CreateTextElement = Omit<TextElement, "id">;
export type CreateTimelineElement = CreateMediaElement | CreateTextElement;
export interface TimelineElementProps {
- element: TimelineElement;
- track: TimelineTrack;
- zoomLevel: number;
- isSelected: boolean;
- onElementMouseDown: (e: React.MouseEvent, element: TimelineElement) => void;
- onElementClick: (e: React.MouseEvent, element: TimelineElement) => void;
+ element: TimelineElement;
+ track: TimelineTrack;
+ zoomLevel: number;
+ isSelected: boolean;
+ onElementMouseDown: (e: React.MouseEvent, element: TimelineElement) => void;
+ onElementClick: (e: React.MouseEvent, element: TimelineElement) => void;
}
export interface ResizeState {
- elementId: string;
- side: "left" | "right";
- startX: number;
- initialTrimStart: number;
- initialTrimEnd: number;
+ elementId: string;
+ side: "left" | "right";
+ startX: number;
+ initialTrimStart: number;
+ initialTrimEnd: number;
}
// Drag data types for type-safe drag and drop
export interface MediaItemDragData {
- id: string;
- type: MediaType;
- name: string;
+ id: string;
+ type: MediaType;
+ name: string;
}
export interface TextItemDragData {
- id: string;
- type: "text";
- name: string;
- content: string;
+ id: string;
+ type: "text";
+ name: string;
+ content: string;
}
export type DragData = MediaItemDragData | TextItemDragData;
export interface TimelineTrack {
- id: string;
- name: string;
- type: TrackType;
- elements: TimelineElement[];
- muted?: boolean;
- isMain?: boolean;
+ id: string;
+ name: string;
+ type: TrackType;
+ elements: TimelineElement[];
+ muted?: boolean;
+ isMain?: boolean;
}
export function sortTracksByOrder(tracks: TimelineTrack[]): TimelineTrack[] {
- return [...tracks].sort((a, b) => {
- // Audio tracks always go to bottom
- if (a.type === "audio" && b.type !== "audio") return 1;
- if (b.type === "audio" && a.type !== "audio") return -1;
+ return [...tracks].sort((a, b) => {
+ // Audio tracks always go to bottom
+ if (a.type === "audio" && b.type !== "audio") return 1;
+ if (b.type === "audio" && a.type !== "audio") return -1;
- // Main track goes above audio but below other tracks
- if (a.isMain && !b.isMain && b.type !== "audio") return 1;
- if (b.isMain && !a.isMain && a.type !== "audio") return -1;
+ // Main track goes above audio but below other tracks
+ if (a.isMain && !b.isMain && b.type !== "audio") return 1;
+ if (b.isMain && !a.isMain && a.type !== "audio") return -1;
- // Within same category, maintain creation order
- return 0;
- });
+ // Within same category, maintain creation order
+ return 0;
+ });
}
export function getMainTrack(tracks: TimelineTrack[]): TimelineTrack | null {
- return tracks.find((track) => track.isMain) || null;
+ return tracks.find((track) => track.isMain) || null;
}
export function ensureMainTrack(tracks: TimelineTrack[]): TimelineTrack[] {
- const hasMainTrack = tracks.some((track) => track.isMain);
+ const hasMainTrack = tracks.some((track) => track.isMain);
- if (!hasMainTrack) {
- // Create main track if it doesn't exist
- const mainTrack: TimelineTrack = {
- id: generateUUID(),
- name: "Main Track",
- type: "media",
- elements: [],
- muted: false,
- isMain: true,
- };
- return [mainTrack, ...tracks];
- }
+ if (!hasMainTrack) {
+ // Create main track if it doesn't exist
+ const mainTrack: TimelineTrack = {
+ id: generateUUID(),
+ name: "Main Track",
+ type: "media",
+ elements: [],
+ muted: false,
+ isMain: true,
+ };
+ return [mainTrack, ...tracks];
+ }
- return tracks;
+ return tracks;
}
// Timeline validation utilities
export function canElementGoOnTrack(
- elementType: "text" | "media",
- trackType: TrackType
+ elementType: "text" | "media",
+ trackType: TrackType,
): boolean {
- if (elementType === "text") {
- return trackType === "text";
- } else if (elementType === "media") {
- return trackType === "media" || trackType === "audio";
- }
- return false;
+ if (elementType === "text") {
+ return trackType === "text";
+ } else if (elementType === "media") {
+ return trackType === "media" || trackType === "audio";
+ }
+ return false;
}
export function validateElementTrackCompatibility(
- element: { type: "text" | "media" },
- track: { type: TrackType }
+ element: { type: "text" | "media" },
+ track: { type: TrackType },
): { isValid: boolean; errorMessage?: string } {
- const isValid = canElementGoOnTrack(element.type, track.type);
+ const isValid = canElementGoOnTrack(element.type, track.type);
- if (!isValid) {
- const errorMessage =
- element.type === "text"
- ? "Text elements can only be placed on text tracks"
- : "Media elements can only be placed on media or audio tracks";
+ if (!isValid) {
+ const errorMessage =
+ element.type === "text"
+ ? "Text elements can only be placed on text tracks"
+ : "Media elements can only be placed on media or audio tracks";
- return { isValid: false, errorMessage };
- }
+ return { isValid: false, errorMessage };
+ }
- return { isValid: true };
+ return { isValid: true };
}
export interface TimelineTick {
- left: number;
- label?: string;
- isMajor?: boolean;
+ left: number;
+ label?: string;
+ isMajor?: boolean;
}
export interface TimelineCanvasRulerWrapperProps {
- children: ReactNode;
- onMouseDown?: (e: React.MouseEvent<HTMLDivElement>) => void;
- className?: string;
+ children: ReactNode;
+ onMouseDown?: (e: React.MouseEvent<HTMLDivElement>) => void;
+ className?: string;
}
export interface TimelineCanvasRulerProps {
- zoomLevel: number;
- duration: number;
- width: number;
- height?: number;
+ zoomLevel: number;
+ duration: number;
+ width: number;
+ height?: number;
}