Skip to content

Create professional demos and 3D mockups in seconds, directly in your browser

feat: add new types and interfaces for image masking, audio management, and editor modes

CristianOlivera19f10fcc981f9
diff --git a/types/ImageMask.types.ts b/types/ImageMask.types.ts
new file mode 100644
index 0000000..9d94474
--- /dev/null
+++ b/types/ImageMask.types.ts
@@ -0,0 +1,74 @@
+import { ImageMaskConfig } from "./photo.types";
+
+export interface ImageMaskEditorProps {
+ maskConfig: ImageMaskConfig;
+ onMaskConfigChange: (config: ImageMaskConfig) => void;
+ canvasImageUrl?: string | null;
+}
+
+export interface MaskPreset {
+ id: string;
+ label: string;
+ icon: string;
+ config: Partial<ImageMaskConfig>;
+}
+
+export const MASK_PRESETS: MaskPreset[] = [
+ {
+ id: "none",
+ label: "Sin máscara",
+ icon: "mdi:image-outline",
+ config: { enabled: false },
+ },
+ {
+ id: "fade-top",
+ label: "Fade Top",
+ icon: "mdi:arrow-down-thin",
+ config: {
+ enabled: true,
+ top: { from: 0, to: 30 },
+ },
+ },
+ {
+ id: "fade-bottom",
+ label: "Fade Bottom",
+ icon: "mdi:arrow-up-thin",
+ config: {
+ enabled: true,
+ bottom: { from: 0, to: 30 },
+ },
+ },
+ {
+ id: "fade-sides",
+ label: "Fade Sides",
+ icon: "mdi:arrow-expand-horizontal",
+ config: {
+ enabled: true,
+ left: { from: 0, to: 20 },
+ right: { from: 0, to: 20 },
+ },
+ },
+ {
+ id: "vignette",
+ label: "Vignette",
+ icon: "mdi:circle-outline",
+ config: {
+ enabled: true,
+ top: { from: 0, to: 25 },
+ bottom: { from: 0, to: 25 },
+ left: { from: 0, to: 25 },
+ right: { from: 0, to: 25 },
+ },
+ },
+ {
+ id: "angle-45",
+ label: "Diagonal 45°",
+ icon: "mdi:slash-forward",
+ config: {
+ enabled: true,
+ angle: 45,
+ angleFrom: 60,
+ angleTo: 90,
+ },
+ },
+];
\ No newline at end of file
diff --git a/types/audio.types.ts b/types/audio.types.ts
index 6120c3e..cc51f4e 100644
--- a/types/audio.types.ts
+++ b/types/audio.types.ts
@@ -31,7 +31,7 @@ export const DEFAULT_AUDIO_CONFIG: AudioConfig = {
};
export const SUPPORTED_AUDIO_FORMATS = [
- 'audio/mpeg', // MP3
+ 'audio/mpeg',
'audio/mp3',
'audio/wav',
'audio/wave',
@@ -53,3 +53,33 @@ export const SUPPORTED_AUDIO_EXTENSIONS = [
export const MAX_AUDIO_FILE_SIZE = 50 * 1024 * 1024;
export const MAX_AUDIO_TRACKS = 5;
+
+export interface AudioMenuProps {
+ audioTracks: AudioTrack[];
+ uploadedAudios: UploadedAudio[];
+ muteOriginalAudio: boolean;
+ masterVolume: number;
+ videoDuration: number;
+ onAudioUpload: (file: File) => void;
+ onUpdateAudioTrack: (trackId: string, updates: Partial<AudioTrack>) => void;
+ onDeleteAudioTrack: (trackId: string) => void;
+ onToggleMuteOriginalAudio: () => void;
+ onMasterVolumeChange: (volume: number) => void;
+}
+
+export const MIN_FRAGMENT_DURATION = 0.1;
+export const MIN_VISUAL_WIDTH_PX = 50;
+
+export interface AudioFragmentTrackItemProps {
+ track: AudioTrack;
+ audio: UploadedAudio | undefined;
+ isSelected: boolean;
+ contentWidth: number;
+ videoDuration: number;
+ otherTracks: AudioTrack[];
+ onSelect: () => void;
+ onUpdate: (updates: Partial<AudioTrack>) => void;
+ onDragStateChange?: (isDragging: boolean) => void;
+ onMouseEnter?: () => void;
+ onMouseLeave?: () => void;
+}
diff --git a/types/control-panel.types.ts b/types/control-panel.types.ts
index b97477f..120ad56 100644
--- a/types/control-panel.types.ts
+++ b/types/control-panel.types.ts
@@ -6,6 +6,7 @@ import type { CanvasElement } from "./canvas-elements.types";
import type { UploadedAudio, AudioTrack } from "./audio.types";
import type { CursorConfig, CursorRecordingData } from "./cursor.types";
import type { CameraConfig } from "./camera.types";
+import type { ImageProjectPreview } from "./image-project.types";
export interface ControlPanelProps {
activeTool: Tool;
@@ -79,4 +80,12 @@ export interface ControlPanelProps {
cameraUrl?: string | null;
cameraConfig?: CameraConfig | null;
onCameraConfigChange?: (partial: Partial<CameraConfig>) => void;
+ // History/Image projects props
+ imageProjects?: ImageProjectPreview[];
+ currentImageProjectId?: string | null;
+ isLoadingProjects?: boolean;
+ onSelectImageProject?: (projectId: string) => void;
+ onAddImageToCanvas?: (projectId: string) => void;
+ onDeleteImageProject?: (projectId: string) => void;
+ onUploadImageToHistory?: (file: File) => void;
}
diff --git a/types/editor-mode.types.ts b/types/editor-mode.types.ts
new file mode 100644
index 0000000..8186b4b
--- /dev/null
+++ b/types/editor-mode.types.ts
@@ -0,0 +1,57 @@
+export type EditorMode = "video" | "photo";
+
+export interface EditorModeConfig {
+ mode: EditorMode;
+ // Features available in each mode
+ features: {
+ timeline: boolean;
+ playerControls: boolean;
+ videoClips: boolean;
+ audioTracks: boolean;
+ zoomFragments: boolean;
+ camera: boolean;
+ cursor: boolean;
+ mockups: boolean;
+ background: boolean;
+ elements: boolean;
+ export: boolean;
+ };
+}
+
+export const VIDEO_MODE_CONFIG: EditorModeConfig = {
+ mode: "video",
+ features: {
+ timeline: true,
+ playerControls: true,
+ videoClips: true,
+ audioTracks: true,
+ zoomFragments: true,
+ camera: true,
+ cursor: true,
+ mockups: true,
+ background: true,
+ elements: true,
+ export: true,
+ },
+};
+
+export const PHOTO_MODE_CONFIG: EditorModeConfig = {
+ mode: "photo",
+ features: {
+ timeline: false,
+ playerControls: false,
+ videoClips: false,
+ audioTracks: false,
+ zoomFragments: false,
+ camera: false,
+ cursor: false,
+ mockups: true,
+ background: true,
+ elements: true,
+ export: true,
+ },
+};
+
+export function getEditorModeConfig(mode: EditorMode): EditorModeConfig {
+ return mode === "video" ? VIDEO_MODE_CONFIG : PHOTO_MODE_CONFIG;
+}
diff --git a/types/editor-state.types.ts b/types/editor-state.types.ts
index d097d9a..a56de40 100644
--- a/types/editor-state.types.ts
+++ b/types/editor-state.types.ts
@@ -3,6 +3,13 @@ import type { TrimRange } from "@/types/timeline.types";
import type { MockupConfig } from "@/types/mockup.types";
import type { CanvasElement } from "@/types/canvas-elements.types";
import type { CameraConfig } from "@/types/camera.types";
+import type { Preview3DConfig, ImageMaskConfig } from "@/types/photo.types";
+
+export interface VideoTransform {
+ rotation: number;
+ translateX: number;
+ translateY: number;
+}
export interface EditorState {
backgroundTab: BackgroundTab;
@@ -31,6 +38,12 @@ export interface EditorState {
masterVolume: number;
cameraConfig: CameraConfig | null;
+
+ // Photo mode specific states
+ videoTransform: VideoTransform;
+ imageTransform: Preview3DConfig;
+ apply3DToBackground: boolean;
+ imageMaskConfig: ImageMaskConfig;
}
export function createInitialEditorState(overrides?: Partial<EditorState>): EditorState {
@@ -62,6 +75,25 @@ export function createInitialEditorState(overrides?: Partial<EditorState>): Edit
muteOriginalAudio: false,
masterVolume: 1,
cameraConfig: null,
+ videoTransform: {
+ rotation: 0,
+ translateX: 0,
+ translateY: 0,
+ },
+ imageTransform: {
+ id: "front",
+ label: "Front",
+ rotateX: 0,
+ rotateY: 0,
+ rotateZ: 0,
+ translateY: 0,
+ scale: 0.9,
+ perspective: 600,
+ },
+ apply3DToBackground: false,
+ imageMaskConfig: {
+ enabled: false,
+ },
...overrides,
};
}
diff --git a/types/editor.types.ts b/types/editor.types.ts
index 36981ae..c6e759e 100644
--- a/types/editor.types.ts
+++ b/types/editor.types.ts
@@ -2,7 +2,7 @@ import type { ZoomFragment } from "./zoom.types";
import type { CanvasElement } from "./canvas-elements.types";
import type { CursorConfig, CursorRecordingData } from "./cursor.types";
-export type Tool = "screenshot" | "elements" | "audio" | "zoom" | "mockup" | "cursor" | "videos" | "camera";
+export type Tool = "screenshot" | "elements" | "audio" | "zoom" | "mockup" | "cursor" | "videos" | "camera" | "history";
export type BackgroundTab = "wallpaper" | "image" | "color";
@@ -44,6 +44,7 @@ export interface EditorState {
export interface VideoCanvasHandle {
getExportCanvas: () => HTMLCanvasElement | null;
drawFrame: () => Promise<void>;
+ getPreviewContainer: () => HTMLDivElement | null;
}
/** Thumbnail data for scrubbing preview */
@@ -53,7 +54,27 @@ export interface VideoThumbnail {
quality?: "low" | "high";
}
+export type MediaType = "video" | "image";
+
export interface VideoCanvasProps {
+ // Media type - determines if we're editing video or image
+ mediaType?: MediaType;
+ // Image-specific props
+ imageUrl?: string | null;
+ imageRef?: React.RefObject<HTMLImageElement | null>;
+ imageTransform?: {
+ id: string;
+ label: string;
+ rotateX: number;
+ rotateY: number;
+ rotateZ: number;
+ translateY: number;
+ scale: number;
+ perspective?: number;
+ };
+ apply3DToBackground?: boolean;
+ imageMaskConfig?: import("@/types/photo.types").ImageMaskConfig;
+ // Video-specific props
videoRef: React.RefObject<HTMLVideoElement | null>;
videoUrl: string | null;
padding: number;
@@ -83,6 +104,8 @@ export interface VideoCanvasProps {
mockupConfig?: import("./mockup.types").MockupConfig;
// Video upload props
onVideoUpload?: (file: File) => void;
+ onImageUpload?: (file: File) => void;
+ onImageDrop?: (files: FileList | File[]) => void;
isUploading?: boolean;
// Transform props
videoTransform?: VideoTransform;
diff --git a/types/image-project.types.ts b/types/image-project.types.ts
new file mode 100644
index 0000000..b0e400f
--- /dev/null
+++ b/types/image-project.types.ts
@@ -0,0 +1,130 @@
+import type { BackgroundTab, BackgroundColorConfig, AspectRatio, CropArea } from "@/types";
+import type { MockupConfig } from "@/types/mockup.types";
+import { CanvasElement } from "./canvas-elements.types";
+import type { Preview3DConfig, ImageMaskConfig } from "./photo.types";
+
+export interface ImageProject {
+ id: string;
+ imageBlob: Blob;
+ imageDataUrl: string;
+ imageName: string;
+ imageWidth: number;
+ imageHeight: number;
+ thumbnailDataUrl: string;
+
+ backgroundTab: BackgroundTab;
+ selectedWallpaper: number;
+ backgroundBlur: number;
+ selectedImageUrl: string;
+ backgroundColorConfig: BackgroundColorConfig | null;
+
+ padding: number;
+ roundedCorners: number;
+ shadows: number;
+
+ aspectRatio: AspectRatio;
+ customDimensions: { width: number; height: number } | null;
+ cropArea: CropArea | undefined;
+
+ mockupId: string;
+ mockupConfig: MockupConfig;
+
+ canvasElements: CanvasElement[];
+
+ imageTransform: {
+ rotation: number;
+ translateX: number;
+ translateY: number;
+ };
+
+ imagePreview3D: Preview3DConfig;
+ apply3DToBackground: boolean;
+ imageMaskConfig: ImageMaskConfig;
+
+ createdAt: number;
+}
+
+export interface ImageProjectPreview {
+ id: string;
+ imageName: string;
+ thumbnailDataUrl: string;
+ createdAt: number;
+}
+
+export type ImageExportFormat = "png" | "jpeg" | "webp" | "avif";
+
+export interface ImageExportSettings {
+ format: ImageExportFormat;
+ quality: number;
+ width: number;
+ height: number;
+ label: string;
+ description: string;
+}
+
+export const IMAGE_EXPORT_PRESETS: Record<string, ImageExportSettings> = {
+ "png-max": {
+ format: "png",
+ quality: 1,
+ width: 0,
+ height: 0,
+ label: "PNG Original",
+ description: "Lossless, best quality"
+ },
+ "png-4k": {
+ format: "png",
+ quality: 1,
+ width: 3840,
+ height: 2160,
+ label: "PNG 4K",
+ description: "3840 × 2160"
+ },
+ "png-2k": {
+ format: "png",
+ quality: 1,
+ width: 2560,
+ height: 1440,
+ label: "PNG 2K",
+ description: "2560 × 1440"
+ },
+ "png-1080p": {
+ format: "png",
+ quality: 1,
+ width: 1920,
+ height: 1080,
+ label: "PNG 1080p",
+ description: "1920 × 1080"
+ },
+ "jpeg-max": {
+ format: "jpeg",
+ quality: 0.95,
+ width: 0,
+ height: 0,
+ label: "JPEG High",
+ description: "95% quality, smaller file"
+ },
+ "jpeg-medium": {
+ format: "jpeg",
+ quality: 0.8,
+ width: 1920,
+ height: 1080,
+ label: "JPEG Medium",
+ description: "80% quality, optimized"
+ },
+ "webp-max": {
+ format: "webp",
+ quality: 0.95,
+ width: 0,
+ height: 0,
+ label: "WebP High",
+ description: "Best compression ratio"
+ },
+ "webp-medium": {
+ format: "webp",
+ quality: 0.8,
+ width: 1920,
+ height: 1080,
+ label: "WebP Medium",
+ description: "Optimized for web"
+ }
+};
diff --git a/types/index.ts b/types/index.ts
index 92f0a43..d56c4a6 100644
--- a/types/index.ts
+++ b/types/index.ts
@@ -6,4 +6,5 @@ export * from './zoom.types';
export * from './mockup.types';
export * from './audio.types';
export * from './cursor.types';
-export * from './camera.types';
\ No newline at end of file
+export * from './camera.types';
+export * from './image-project.types';
\ No newline at end of file
diff --git a/types/photo.types.ts b/types/photo.types.ts
new file mode 100644
index 0000000..a04b22b
--- /dev/null
+++ b/types/photo.types.ts
@@ -0,0 +1,68 @@
+import { AspectRatio } from "./editor.types";
+
+export interface Preview3DConfig {
+ id: string;
+ label: string;
+ rotateX: number;
+ rotateY: number;
+ rotateZ: number;
+ translateY: number;
+ scale: number;
+ perspective?: number;
+}
+
+// Configuraciones 3D estáticas e inmutables para los previews
+// Estas configuraciones NUNCA deben cambiar, independientemente del estado del canvas
+export const PREVIEW_CONFIGS: readonly Preview3DConfig[] = Object.freeze([
+ Object.freeze({ id: "front", label: "Front", rotateX: 0, rotateY: 0, rotateZ: 0, translateY: 0, scale: 0.9, perspective: 600 }),
+ Object.freeze({ id: "tilt-up", label: "Tilt Up", rotateX: 15, rotateY: 0, rotateZ: 0, translateY: -2, scale: 0.88, perspective: 500 }),
+ Object.freeze({ id: "top-left-angle", label: "Top Left Angle", rotateX: 18, rotateY: 25, rotateZ: -15, translateY: -10, scale: 0.95, perspective: 500 }),
+ Object.freeze({ id: "top-right-angle", label: "Top Right Angle", rotateX: 18, rotateY: -22, rotateZ: 15, translateY: 5, scale: 0.95, perspective: 500 }),
+]);
+
+// Configuración estática para previews de mask (siempre en posición frontal)
+export const PREVIEW_FRONT_CONFIG: Readonly<Preview3DConfig> = Object.freeze({
+ id: "front",
+ label: "Front",
+ rotateX: 0,
+ rotateY: 0,
+ rotateZ: 0,
+ translateY: 0,
+ scale: 0.9,
+ perspective: 600,
+});
+
+export interface ImageMaskConfig {
+ enabled: boolean;
+ top?: { from: number; to?: number };
+ right?: { from: number; to?: number };
+ bottom?: { from: number; to?: number };
+ left?: { from: number; to?: number };
+ angle?: number;
+ angleFrom?: number;
+ angleTo?: number;
+}
+
+export const DEFAULT_MASK_CONFIG: ImageMaskConfig = {
+ enabled: false,
+};
+
+export interface PhotoEditorPlaceholderProps {
+ className?: string;
+ canvasImageUrl?: string | null;
+ /** Raw uploaded image URL (no canvas effects). Used as static reference in preview cards. */
+ staticImageUrl?: string | null;
+ onSelectPreview?: (config: Preview3DConfig) => void;
+ selectedPreviewId?: string;
+ aspectRatio?: AspectRatio;
+ onAspectRatioChange?: (ratio: AspectRatio) => void;
+ customAspectRatio?: { width: number; height: number } | null;
+ onCustomAspectRatioChange?: (dimensions: { width: number; height: number }) => void;
+ onOpenCropper?: () => void;
+ apply3DToBackground?: boolean;
+ onToggle3DBackground?: (value: boolean) => void;
+ imageMaskConfig?: ImageMaskConfig;
+ onImageMaskConfigChange?: (config: ImageMaskConfig) => void;
+ imageTransform?: Preview3DConfig;
+ onReset?: () => void;
+}
\ No newline at end of file
diff --git a/types/player-control.types.ts b/types/player-control.types.ts
index 6e996d0..133bd0d 100644
--- a/types/player-control.types.ts
+++ b/types/player-control.types.ts
@@ -16,4 +16,8 @@ export interface PlayerControlsProps {
onCustomAspectRatioChange?: (dimensions: { width: number; height: number }) => void;
onOpenCropper: () => void;
onZoomChange: (zoom: number) => void;
-}
\ No newline at end of file
+}
+
+export const MIN_ZOOM = 1;
+export const MAX_ZOOM = 10;
+export const ZOOM_STEP = 1;
\ No newline at end of file
diff --git a/types/video.types.ts b/types/video.types.ts
index 1ad45e3..69ab13b 100644
--- a/types/video.types.ts
+++ b/types/video.types.ts
@@ -1,3 +1,4 @@
+import { CropArea } from "./editor.types";
import type { VideoTrackClip } from "./video-track.types";
export type ExportQuality = "4k" | "2k" | "1080p" | "720p" | "480p" | "gif" | "webm-alpha";
@@ -54,3 +55,19 @@ export interface VideoLoadResult {
duration: number;
url: string;
}
+
+export interface VideoCropperModalProps {
+ isOpen: boolean;
+ onClose: () => void;
+ videoUrl: string | null;
+ onCropApply: (crop: CropArea) => void;
+ initialCrop?: CropArea;
+}
+export const CROP_ASPECT_RATIOS = [
+ { label: "Libre", value: null },
+ { label: "16:9", value: 16 / 9 },
+ { label: "9:16", value: 9 / 16 },
+ { label: "1:1", value: 1 },
+ { label: "4:3", value: 4 / 3 },
+ { label: "3:4", value: 3 / 4 },
+] as const;
\ No newline at end of file