Skip to content

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

feat: integrate AuthProvider into Editor and Home layouts, add Legal layout and pages

CristianOlivera178d4db826f2b
diff --git a/app/(auth)/login/page.tsx b/app/(auth)/login/page.tsx
index 82ea7d6..ff8f496 100644
--- a/app/(auth)/login/page.tsx
+++ b/app/(auth)/login/page.tsx
@@ -1,11 +1,82 @@
"use client";
-import "../../globals.css";
+
+import { useState } from "react";
+import { createClient } from "@/utils/supabase/client";
import { Button } from "@/components/ui/button";
import { Icon } from "@iconify/react";
import Image from "next/image";
import Link from "next/link";
+import "../../globals.css";
+
+type OAuthProvider = "google" | "github" | "twitch";
+
+interface ProviderConfig {
+ name: string;
+ icon: string;
+ provider: OAuthProvider;
+ bgClass: string;
+ iconColor?: string;
+}
+
+const providers: ProviderConfig[] = [
+ {
+ name: "Google",
+ icon: "material-icon-theme:google",
+ provider: "google",
+ bgClass: "border-white/10 bg-transparent hover:bg-white/5",
+ },
+ {
+ name: "GitHub",
+ icon: "mdi:github",
+ provider: "github",
+ bgClass: "border-white/10 bg-transparent hover:bg-white/5",
+ },
+ {
+ name: "Twitch",
+ icon: "mdi:twitch",
+ provider: "twitch",
+ bgClass: "border-white/10 bg-transparent hover:bg-white/5",
+ iconColor: "text-[#9146FF]"
+ },
+];
export default function Login() {
+ const [loading, setLoading] = useState<OAuthProvider | null>(null);
+ const [error, setError] = useState<string | null>(null);
+ const supabase = createClient();
+
+ const handleOAuthSignIn = async (provider: OAuthProvider) => {
+ try {
+ setLoading(provider);
+ setError(null);
+
+ const redirectUrl = `${window.location.origin}/auth/callback`;
+
+ const { error: signInError } = await supabase.auth.signInWithOAuth({
+ provider,
+ options: {
+ redirectTo: redirectUrl,
+ queryParams: {
+ access_type: "offline",
+ prompt: "consent",
+ },
+ },
+ });
+
+ if (signInError) {
+ throw signInError;
+ }
+ } catch (err) {
+ console.error(`Error signing in with ${provider}:`, err);
+ setError(
+ err instanceof Error
+ ? err.message
+ : "Error al iniciar sesión. Por favor, intenta de nuevo."
+ );
+ setLoading(null);
+ }
+ };
+
return (
<div className="min-h-screen w-full bg-[#030303] grid lg:grid-cols-2 text-white selection:bg-white/30">
<div className="relative flex flex-col justify-center px-8 sm:px-16 lg:px-24 xl:px-32">
@@ -31,30 +102,47 @@ export default function Login() {
Bienvenido
</h1>
<p className="text-neutral-300 text-md font-light tracking-wide">
- Inicia sesión para empezar a crear tomas cinemáticas.
+ Inicia sesión o regístrate para empezar a crear tomas cinemáticas.
</p>
</div>
<div className="space-y-4">
- <Button
- variant="outline"
- size="lg"
- className="w-full h-12 gap-3 text-white border-white/10 bg-transparent hover:bg-white/5 transition-all font-light rounded-none"
- >
- <Icon icon="logos:google-icon" width="18" />
- Continuar con Google
- </Button>
-
- <Button
- variant="outline"
- size="lg"
- className="w-full h-12 gap-3 text-white border-white/10 bg-transparent hover:bg-white/5 transition-all font-light rounded-none"
- >
- <Icon icon="mdi:github" className="text-white size-5" />
- Continuar con GitHub
- </Button>
+ {providers.map((providerConfig) => (
+ <Button
+ key={providerConfig.provider}
+ onClick={() => handleOAuthSignIn(providerConfig.provider)}
+ disabled={loading !== null}
+ variant="outline"
+ size="lg"
+ className={`w-full h-12 gap-3 text-white transition-all font-light rounded-none ${providerConfig.bgClass} disabled:opacity-50 disabled:cursor-not-allowed`}
+ >
+ {loading === providerConfig.provider ? (
+ <>
+ <Icon
+ icon="svg-spinners:ring-resize"
+ className="w-5 h-5"
+ />
+ <span>Conectando...</span>
+ </>
+ ) : (
+ <>
+ <Icon
+ icon={providerConfig.icon}
+ className={`${providerConfig.iconColor || 'text-white'} size-5`}
+ />
+ <span>Continuar con {providerConfig.name}</span>
+ </>
+ )}
+ </Button>
+ ))}
</div>
+ {error && (
+ <div className="mt-4 p-3 bg-red-500/10 border border-red-500/20 rounded">
+ <p className="text-red-400 text-sm">{error}</p>
+ </div>
+ )}
+
<p className="mt-12 text-md text-neutral-300 leading-relaxed font-light">
Al continuar, aceptas nuestros: <br />
<Link href="/terms" className="text-neutral-300 hover:text-white underline decoration-white/30 underline-offset-4 transition-colors">Términos de Servicio</Link> y{" "}
@@ -62,30 +150,38 @@ export default function Login() {
</p>
</div>
</div>
- <div className="hidden lg:block relative w-full h-full border-l border-white/10 bg-black overflow-hidden group">
- <Image
- src="https://images.unsplash.com/photo-1526512340740-9217d0159da9?fm=jpg&q=60&w=3000&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxzZWFyY2h8Mnx8dmVydGljYWx8ZW58MHx8MHx8fDA%3D"
- alt="Cinematic Shot"
- fill
- className="object-cover opacity-70 mix-blend-luminosity group-hover:mix-blend-normal transition-all duration-700 ease-in-out"
- priority
- />
-
- <div className="absolute inset-0 bg-[radial-gradient(#ffffff22_1px,transparent_1px)] [background-size:24px_24px] opacity-20 pointer-events-none"></div>
- <div className="absolute inset-0 bg-gradient-to-t from-black/80 via-black/20 to-transparent pointer-events-none"></div>
-
- <div className="absolute top-1/2 left-0 w-full h-[1px] bg-white/10 pointer-events-none"></div>
- <div className="absolute top-0 left-1/2 w-[1px] h-full bg-white/10 pointer-events-none"></div>
-
- <div className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-64 h-64 border border-white/20 pointer-events-none flex items-center justify-center">
- <div className="w-2 h-2 bg-white/50 rounded-full"></div>
+ <div className="hidden lg:block relative w-full h-full border-l border-white/10 bg-[#020203] overflow-hidden group">
+ <div className="absolute -top-[10%] -left-[10%] w-[70%] h-[70%] bg-cyan-600/20 rounded-full blur-[80px] pointer-events-none group-hover:bg-cyan-500/30 transition-colors duration-1000"></div>
+ <div className="absolute -bottom-[10%] -right-[10%] w-[60%] h-[60%] bg-purple-900/10 rounded-full blur-[80px] pointer-events-none group-hover:bg-purple-700/50 transition-colors duration-1000"></div>
+ <div className="absolute inset-0 bg-[radial-gradient(white_0.5px,transparent_0.5px)] bg-size-[40px_40px] opacity-[0.4] pointer-events-none"></div>
+ <div className="absolute inset-0 transition-transform duration-1000 ease-in-out group-hover:scale-105">
+ <img
+ src="/images/pages/banner-login.avif"
+ alt="Cinematic Shot BW"
+ className="absolute inset-0 w-full h-full object-contain mix-blend-luminosity opacity-70 transition-all duration-1000 ease-in-out [clip-path:inset(0_0_0_50%)] group-hover:opacity-0"
+ />
+ <img
+ src="/images/pages/banner-login.avif"
+ alt="Cinematic Shot Color"
+ className="absolute inset-0 w-full h-full object-contain transition-all duration-1000 ease-in-out [clip-path:inset(0_50%_0_0)] group-hover:[clip-path:inset(0_0_0_0%)]"
+ />
+ <div
+ className="absolute inset-0 pointer-events-none mix-blend-screen opacity-40 transition-opacity duration-1000"
+ style={{
+ background: 'linear-gradient(130deg, rgba(0, 210, 255, 0.4), rgba(58, 123, 213, 0.4) 41.07%, rgba(106, 17, 203, 0.4) 76.05%)',
+ maskImage: 'url(/images/metadata/banner-login.avif)',
+ maskSize: 'contain',
+ maskRepeat: 'no-repeat',
+ maskPosition: 'center'
+ }}
+ />
</div>
-
- <div className="absolute top-8 left-8 w-4 h-4 border-t border-l border-white/40 pointer-events-none"></div>
- <div className="absolute bottom-8 left-8 w-4 h-4 border-b border-l border-white/40 pointer-events-none"></div>
- <div className="absolute top-8 right-8 w-4 h-4 border-t border-r border-white/40 pointer-events-none"></div>
-
+ <div className="absolute inset-0 bg-[radial-gradient(#ffffff22_1px,transparent_1px)] bg-size-[24px_24px] opacity-20 pointer-events-none z-10"></div>
+ <div className="absolute inset-0 bg-linear-to-t from-black via-transparent to-black/60 pointer-events-none z-10"></div>
+ <div className="absolute top-1/2 left-0 w-full h-px bg-white/10 pointer-events-none z-20"></div>
+ <div className="absolute top-0 left-1/2 w-px h-full bg-white/20 group-hover:bg-transparent transition-colors duration-1000 pointer-events-none z-20"></div>
</div>
+
</div>
);
}
\ No newline at end of file
diff --git a/app/(editor)/editor/page.tsx b/app/(editor)/editor/page.tsx
index cd054e7..6a6eebe 100644
--- a/app/(editor)/editor/page.tsx
+++ b/app/(editor)/editor/page.tsx
@@ -3,26 +3,36 @@
import { useState, useRef, useEffect, useCallback, lazy, Suspense, useMemo } from "react";
import { Icon } from "@iconify/react";
import { motion, AnimatePresence } from "framer-motion";
-import { loadVideoFromIndexedDB, deleteRecordedVideo } from "@/hooks/useScreenRecording";
+import { loadVideoFromIndexedDB } from "@/hooks/useScreenRecording";
import { useVideoUpload } from "@/hooks/useVideoUpload";
import { useVideoExport } from "@/hooks/useVideoExport";
import { useVideoThumbnails } from "@/hooks/useVideoThumbnails";
+import { useUndoRedo } from "@/hooks/useUndoRedo";
import { clearAllThumbnailCache } from "@/lib/thumbnail-cache";
-import type { ExportQuality, Tool, BackgroundTab, VideoCanvasHandle, BackgroundColorConfig, AspectRatio, CropArea, ZoomFragment } from "@/types";
+import type { ExportQuality, Tool, BackgroundTab, VideoCanvasHandle, BackgroundColorConfig, AspectRatio, CropArea, ZoomFragment, AudioTrack } from "@/types";
import type { TrimRange } from "@/types/timeline.types";
import type { MockupConfig } from "@/types/mockup.types";
+import type { EditorState } from "@/types/editor-state.types";
+import { createInitialEditorState } from "@/types/editor-state.types";
import { DEFAULT_MOCKUP_CONFIG, getMockupDefaultConfig } from "@/types/mockup.types";
import type { CanvasElement } from "@/types/canvas-elements.types";
import { MOCKUPS } from "@/lib/mockup-data";
import { gradientToCss, generateDefaultZoomFragments, createZoomFragment } from "@/types";
import "../../globals.css";
import { ToolsSidebar } from "@/app/components/ui/editor/ToolsSidebar";
+import { MobileToolsMenu } from "@/app/components/ui/editor/MobileToolsMenu";
+import { MobileControlPanel } from "@/app/components/ui/editor/MobileControlPanel";
import { EditorTopBar } from "@/app/components/ui/editor/EditorTopBar";
-import { VideoCanvas, VIDEO_Z_INDEX } from "@/app/components/ui/editor/VideoCanvas";
+import { VideoCanvas } from "@/app/components/ui/editor/VideoCanvas";
import { PlayerControls } from "@/app/components/ui/editor/PlayerControls";
import { findValidFragmentPosition } from "@/app/components/ui/editor/ZoomFragmentTrackItem";
import { LoadingSpinner } from "@/app/components/ui/LoadingSpinner";
import { TimelineSkeleton } from "@/app/components/ui/Skeleton";
+import { AudioTrimModal } from "@/app/components/ui/editor/AudioTrimModal";
+import { VIDEO_Z_INDEX } from "@/lib/constants";
+import Image from "next/image";
+import Link from "next/link";
+import { TooltipAction } from "@/components/ui/tooltip-action";
// Lazy load heavy components
const ControlPanel = lazy(() => import("@/app/components/ui/editor/ControlPanel").then(mod => ({ default: mod.ControlPanel })));
@@ -30,28 +40,66 @@ const Timeline = lazy(() => import("@/app/components/ui/editor/Timeline").then(m
const ExportOverlay = lazy(() => import("@/app/components/ui/ExportOverlay").then(mod => ({ default: mod.ExportOverlay })));
const VideoCropperModal = lazy(() => import("@/app/components/ui/editor/VideoCropperModal").then(mod => ({ default: mod.VideoCropperModal })));
-
-// FUERA del componente, antes de export default:
async function detectVideoHasAudio(blob: Blob): Promise<boolean> {
try {
const url = URL.createObjectURL(blob);
- const video = document.createElement("video");
- video.src = url;
- await new Promise<void>((resolve) => {
- video.onloadedmetadata = () => resolve();
- video.onerror = () => resolve();
+
+ return new Promise<boolean>((resolve) => {
+ const audioCtx = new AudioContext();
+ const reader = new FileReader();
+
+ reader.onload = async (e) => {
+ try {
+ const arrayBuffer = e.target?.result as ArrayBuffer;
+ const audioBuffer = await audioCtx.decodeAudioData(arrayBuffer);
+
+ let hasSignal = false;
+ for (let ch = 0; ch < audioBuffer.numberOfChannels; ch++) {
+ const data = audioBuffer.getChannelData(ch);
+ for (let i = 0; i < Math.min(data.length, 10000); i++) {
+ if (Math.abs(data[i]) > 0.001) {
+ hasSignal = true;
+ break;
+ }
+ }
+ if (hasSignal) break;
+ }
+
+ await audioCtx.close();
+ URL.revokeObjectURL(url);
+ resolve(hasSignal);
+ } catch {
+ await audioCtx.close();
+ URL.revokeObjectURL(url);
+ resolve(false);
+ }
+ };
+
+ reader.onerror = () => {
+ audioCtx.close();
+ URL.revokeObjectURL(url);
+ resolve(false);
+ };
+
+ reader.readAsArrayBuffer(blob);
});
- // audioTracks es la API estándar — funciona en Chrome/Edge/Firefox
- const videoEl = video as HTMLVideoElement & { audioTracks?: { length: number } };
- const hasAudio = (videoEl.audioTracks?.length ?? 0) > 0;
- URL.revokeObjectURL(url);
- return hasAudio;
} catch {
return true; // en caso de error, asumir que tiene audio
}
}
export default function Editor() {
+ // Undo/Redo system - centralized state management
+ const {
+ state: editorState,
+ setState: setEditorState,
+ undo,
+ redo,
+ canUndo,
+ canRedo,
+ clearHistory,
+ } = useUndoRedo<EditorState>(createInitialEditorState());
+
const [activeTool, setActiveTool] = useState<Tool>("screenshot");
const [backgroundTab, setBackgroundTab] = useState<BackgroundTab>("wallpaper");
const [selectedWallpaper, setSelectedWallpaper] = useState(0);
@@ -60,6 +108,7 @@ export default function Editor() {
const [roundedCorners, setRoundedCorners] = useState(10);
const [shadows, setShadows] = useState(10);
const [isControlPanelOpen, setIsControlPanelOpen] = useState(true);
+ const [isMobileControlPanelOpen, setIsMobileControlPanelOpen] = useState(false);
// Video transform state (rotation and position)
const [videoTransform, setVideoTransform] = useState<{ rotation: number; translateX: number; translateY: number }>({
@@ -121,7 +170,7 @@ export default function Editor() {
const animationFrameRef = useRef<number | null>(null);
const justEndedRef = useRef<boolean>(false);
const wasPlayingBeforeDragRef = useRef<boolean>(false);
-
+ const isExportingRef = useRef(false);
const [scrubTime, setScrubTime] = useState<number>(0);
// Zoom fragments state
@@ -149,6 +198,13 @@ export default function Editor() {
const [masterVolume, setMasterVolume] = useState<number>(1);
const [selectedAudioTrackId, setSelectedAudioTrackId] = useState<string | null>(null);
+ // Audio trim modal state
+ const [autoTrimModalOpen, setAutoTrimModalOpen] = useState(false);
+ const [pendingAudioUpload, setPendingAudioUpload] = useState<{
+ audio: import("@/types/audio.types").UploadedAudio;
+ trackId: string;
+ } | null>(null);
+
// Audio playback refs - store HTML Audio elements for each track
const audioElementsRef = useRef<Map<string, HTMLAudioElement>>(new Map());
@@ -193,6 +249,7 @@ export default function Editor() {
// Sync audio playback with video current time
const syncAudioPlayback = useCallback((videoTime: number, playing: boolean) => {
+ if (isExportingRef.current) return;
const currentElements = audioElementsRef.current;
for (const track of audioTracks) {
@@ -201,13 +258,12 @@ export default function Editor() {
const trackStart = track.startTime;
const trackEnd = track.startTime + track.duration;
+ const trimStart = track.trimStart ?? 0; // ← añadir esto
- // Check if current video time is within this track's range
if (videoTime >= trackStart && videoTime < trackEnd) {
- // Calculate the audio element's current time relative to track start
- const audioTime = videoTime - trackStart;
+ // El tiempo dentro del archivo de audio = trimStart + offset desde el inicio del track
+ const audioTime = trimStart + (videoTime - trackStart); // ← antes era solo (videoTime - trackStart)
- // Only seek if there's a significant difference (avoid micro-seeks)
if (Math.abs(audioEl.currentTime - audioTime) > 0.1) {
audioEl.currentTime = audioTime;
}
@@ -218,7 +274,6 @@ export default function Editor() {
audioEl.pause();
}
} else {
- // Outside this track's range - pause if playing
if (!audioEl.paused) {
audioEl.pause();
}
@@ -238,6 +293,77 @@ export default function Editor() {
};
}, []);
+ // ====================
+ // Undo/Redo Sync - Bidirectional state synchronization
+ // ====================
+
+ // Sync individual states → editorState (for history tracking)
+ // Debounced to avoid creating history entries on every keystroke
+ const updateEditorStateDebounced = useRef<NodeJS.Timeout | null>(null);
+ useEffect(() => {
+ if (updateEditorStateDebounced.current) {
+ clearTimeout(updateEditorStateDebounced.current);
+ }
+ updateEditorStateDebounced.current = setTimeout(() => {
+ setEditorState({
+ backgroundTab,
+ selectedWallpaper,
+ backgroundBlur,
+ padding,
+ roundedCorners,
+ shadows,
+ selectedImageUrl,
+ backgroundColorConfig,
+ aspectRatio,
+ customDimensions,
+ cropArea,
+ trimRange,
+ zoomFragments,
+ mockupId,
+ mockupConfig,
+ canvasElements,
+ audioTracks,
+ muteOriginalAudio,
+ masterVolume,
+ });
+ }, 300);
+ return () => {
+ if (updateEditorStateDebounced.current) {
+ clearTimeout(updateEditorStateDebounced.current);
+ }
+ };
+ }, [
+ backgroundTab, selectedWallpaper, backgroundBlur, padding,
+ roundedCorners, shadows, selectedImageUrl, backgroundColorConfig,
+ aspectRatio, customDimensions, cropArea, trimRange,
+ zoomFragments, mockupId, mockupConfig, canvasElements,
+ audioTracks, muteOriginalAudio, masterVolume,
+ setEditorState
+ ]);
+
+ // Sync editorState → individual states (from undo/redo)
+ useEffect(() => {
+ setBackgroundTab(editorState.backgroundTab);
+ setSelectedWallpaper(editorState.selectedWallpaper);
+ setBackgroundBlur(editorState.backgroundBlur);
+ setPadding(editorState.padding);
+ setRoundedCorners(editorState.roundedCorners);
+ setShadows(editorState.shadows);
+ setSelectedImageUrl(editorState.selectedImageUrl);
+ setBackgroundColorConfig(editorState.backgroundColorConfig);
+ setAspectRatio(editorState.aspectRatio);
+ setCustomDimensions(editorState.customDimensions);
+ setCropArea(editorState.cropArea);
+ setTrimRange(editorState.trimRange);
+ setZoomFragments(editorState.zoomFragments);
+ setMockupId(editorState.mockupId);
+ setMockupConfig(editorState.mockupConfig);
+ setCanvasElements(editorState.canvasElements);
+ setAudioTracks(editorState.audioTracks);
+ setMuteOriginalAudio(editorState.muteOriginalAudio);
+ setMasterVolume(editorState.masterVolume);
+ }, [editorState]);
+
// Handler para cambiar el mockup
const handleMockupChange = useCallback((newMockupId: string) => {
setMockupId(newMockupId);
@@ -344,6 +470,13 @@ export default function Editor() {
// Audio handlers
const handleAudioUpload = useCallback(async (file: File) => {
try {
+ // Check max tracks limit first
+ const MAX_AUDIO_TRACKS = 5;
+ if (audioTracks.length >= MAX_AUDIO_TRACKS) {
+ alert(`Máximo ${MAX_AUDIO_TRACKS} pistas de audio permitidas.`);
+ return;
+ }
+
// Create blob URL
const url = URL.createObjectURL(file);
@@ -364,11 +497,42 @@ export default function Editor() {
};
setUploadedAudios(prev => [...prev, newAudio]);
+
+ // Automatically add to timeline
+ const lastTrackEnd = audioTracks.reduce((max, track) =>
+ Math.max(max, track.startTime + track.duration), 0);
+
+ const trackId = `track-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
+
+ // Check if audio exceeds video duration
+ if (audio.duration > videoDuration) {
+ // Show trim modal automatically
+ setPendingAudioUpload({ audio: newAudio, trackId });
+ setAutoTrimModalOpen(true);
+ } else {
+ // Add track normally
+ const newTrack: import("@/types/audio.types").AudioTrack = {
+ id: trackId,
+ audioId: newAudio.id,
+ name: newAudio.name,
+ startTime: lastTrackEnd,
+ duration: newAudio.duration,
+ volume: 1,
+ loop: false,
+ };
+
+ setAudioTracks(prev => [...prev, newTrack]);
+
+ // Auto-mute original audio when first track is added
+ if (audioTracks.length === 0) {
+ setMuteOriginalAudio(true);
+ }
+ }
} catch (error) {
console.error('Error uploading audio:', error);
alert('Error al subir el audio. Por favor intenta de nuevo.');
}
- }, []);
+ }, [audioTracks, videoDuration]);
const handleAudioDelete = useCallback((audioId: string) => {
// Remove from uploaded audios
@@ -444,6 +608,16 @@ export default function Editor() {
setMasterVolume(volume);
}, []);
+ const handleSelectAudioTrack = useCallback((trackId: string | null) => {
+ setSelectedAudioTrackId(trackId);
+ // Clear zoom fragment selection when selecting audio track
+ if (trackId) {
+ setSelectedZoomFragmentId(null);
+ // Activate audio tool in sidebar
+ setActiveTool("audio");
+ }
+ }, []);
+
// Genere Thumbnails de alta calidad y su generacion de intervalo corto para que el scrubbing se sienta instantáneo
const { getThumbnailForTime } = useVideoThumbnails(
videoUrl,
@@ -460,12 +634,16 @@ export default function Editor() {
const [videoBlob, setVideoBlob] = useState<Blob | null>(null);
const handleExport = (quality: ExportQuality) => {
+ isExportingRef.current = true;
+ for (const audioEl of audioElementsRef.current.values()) {
+ audioEl.pause();
+ }
+
exportVideo({
quality,
videoBlob: videoBlob ?? undefined,
transparentBackground: selectedWallpaper === -1,
trim: trimRange.end > trimRange.start ? { start: trimRange.start, end: trimRange.end } : undefined,
- // Audio settings
muteOriginalAudio,
audioTracks: audioTracks.map(track => {
const audio = uploadedAudios.find(a => a.id === track.audioId);
@@ -473,11 +651,13 @@ export default function Editor() {
audioUrl: audio?.url || '',
startTime: track.startTime,
duration: track.duration,
+ trimStart: track.trimStart ?? 0,
volume: track.volume,
loop: track.loop,
};
}),
masterVolume,
+ }).finally(() => {
});
};
const [videoHasAudioTrack, setVideoHasAudioTrack] = useState<boolean>(true);
@@ -490,15 +670,17 @@ export default function Editor() {
if (!hasAudio) setMuteOriginalAudio(true);
});
try {
- // Clear any existing recorded video and thumbnails
- await deleteRecordedVideo();
+ // Clear thumbnail cache only (don't delete recorded videos to avoid DB corruption)
await clearAllThumbnailCache();
} catch (error) {
- console.warn("Failed to clear previous video:", error);
+ console.warn("Failed to clear thumbnails:", error);
}
const uploadedData = await uploadVideo(file);
if (uploadedData) {
+ // Update ref to track this as the current video
+ lastLoadedVideoIdRef.current = uploadedData.videoId;
+
setVideoUrl(uploadedData.url);
setVideoId(uploadedData.videoId);
setVideoDuration(uploadedData.duration);
@@ -514,43 +696,72 @@ export default function Editor() {
// Reset playback state
setCurrentTime(0);
setIsPlaying(false);
+
+ // Clear undo/redo history when uploading a new video (longer timeout to ensure all states sync)
+ setTimeout(() => clearHistory(), 200);
}
- }, [uploadVideo]);
+ }, [uploadVideo, clearHistory]);
+
+ // Track last loaded video to detect changes
+ const lastLoadedVideoIdRef = useRef<string | null>(null);
useEffect(() => {
const loadVideo = async () => {
try {
- // Try loading recorded video first
- let videoData = await loadVideoFromIndexedDB();
-
- // If no recorded video, try loading uploaded video
- if (!videoData) {
- const uploadedData = await loadUploadedVideo();
- if (uploadedData) {
- videoData = {
- url: uploadedData.url,
- videoId: uploadedData.videoId,
- duration: uploadedData.duration,
- blob: new Blob(), // Not needed for display
- };
- setAspectRatio(uploadedData.aspectRatio);
- setVideoDimensions({ width: uploadedData.width, height: uploadedData.height });
- }
- } else if (videoData.blob && videoData.blob.size > 0) {
- setVideoBlob(videoData.blob);
- detectVideoHasAudio(videoData.blob).then(hasAudio => {
- setVideoHasAudioTrack(hasAudio);
- if (!hasAudio) setMuteOriginalAudio(true);
- });
+ // Load both videos and compare timestamps to get the most recent
+ const [uploadedData, recordedData] = await Promise.all([
+ loadUploadedVideo(),
+ loadVideoFromIndexedDB()
+ ]);
+
+ // Determine which video is more recent
+ let videoToLoad: typeof uploadedData | typeof recordedData = null;
+
+ if (uploadedData && recordedData) {
+ // Both exist - load the most recent one based on timestamp
+ videoToLoad = uploadedData.timestamp > recordedData.timestamp ? uploadedData : recordedData;
+ } else if (uploadedData) {
+ videoToLoad = uploadedData;
+ } else if (recordedData) {
+ videoToLoad = recordedData;
}
- if (videoData) {
- setVideoUrl(videoData.url);
- setVideoId(videoData.videoId);
- setVideoDuration(videoData.duration);
- setTrimRange({ start: 0, end: videoData.duration });
- const defaultFragments = generateDefaultZoomFragments(videoData.duration);
- setZoomFragments(defaultFragments);
+ // Load the selected video
+ if (videoToLoad) {
+ // Only reload if this is a different video
+ if (lastLoadedVideoIdRef.current !== videoToLoad.videoId) {
+ lastLoadedVideoIdRef.current = videoToLoad.videoId;
+
+ setVideoUrl(videoToLoad.url);
+ setVideoId(videoToLoad.videoId);
+ setVideoDuration(videoToLoad.duration);
+ setTrimRange({ start: 0, end: videoToLoad.duration });
+ const defaultFragments = generateDefaultZoomFragments(videoToLoad.duration);
+ setZoomFragments(defaultFragments);
+
+ // Set aspect ratio and dimensions for uploaded videos
+ if ('aspectRatio' in videoToLoad) {
+ setAspectRatio(videoToLoad.aspectRatio || "auto");
+ if (videoToLoad.width && videoToLoad.height) {
+ setVideoDimensions({ width: videoToLoad.width, height: videoToLoad.height });
+ }
+ }
+
+ // Set blob for recorded videos
+ if ('blob' in videoToLoad && videoToLoad.blob && videoToLoad.blob.size > 0) {
+ setVideoBlob(videoToLoad.blob);
+ detectVideoHasAudio(videoToLoad.blob).then(hasAudio => {
+ setVideoHasAudioTrack(hasAudio);
+ if (!hasAudio) setMuteOriginalAudio(true);
+ });
+ }
+
+ // Clear undo/redo history when loading a new video
+ // Use longer timeout to ensure all state updates complete first
+ setTimeout(() => {
+ clearHistory();
+ }, 200);
+ }
}
} catch (error) {
@@ -559,7 +770,17 @@ export default function Editor() {
};
loadVideo();
- }, [loadUploadedVideo]);
+
+ // Re-check when page becomes visible (user navigates back or uploads new video)
+ const handleVisibilityChange = () => {
+ if (!document.hidden) {
+ loadVideo();
+ }
+ };
+
+ document.addEventListener("visibilitychange", handleVisibilityChange);
+ return () => document.removeEventListener("visibilitychange", handleVisibilityChange);
+ }, [loadUploadedVideo, clearHistory]);
useEffect(() => {
if (uploadedImages.length > 0) {
@@ -567,13 +788,47 @@ export default function Editor() {
}
}, [uploadedImages]);
- // Mute/unmute original video audio
useEffect(() => {
if (videoRef.current) {
videoRef.current.muted = muteOriginalAudio;
}
}, [muteOriginalAudio]);
+ // Keyboard shortcuts for undo/redo
+ useEffect(() => {
+ const handleKeyDown = (e: KeyboardEvent) => {
+ // Check if any input field is focused
+ const target = e.target as HTMLElement;
+ const isInputFocused = target.tagName === 'INPUT' ||
+ target.tagName === 'TEXTAREA' ||
+ target.isContentEditable;
+
+ // Don't trigger shortcuts if typing in an input
+ if (isInputFocused) return;
+
+ // Ctrl+Z or Cmd+Z for undo
+ if ((e.ctrlKey || e.metaKey) && e.key === 'z' && !e.shiftKey) {
+ e.preventDefault();
+ if (canUndo) {
+ undo();
+ }
+ }
+
+ // Ctrl+Y or Cmd+Y for redo (Windows)
+ // Ctrl+Shift+Z or Cmd+Shift+Z for redo (Mac)
+ if (((e.ctrlKey || e.metaKey) && e.key === 'y') ||
+ ((e.ctrlKey || e.metaKey) && e.shiftKey && e.key === 'z')) {
+ e.preventDefault();
+ if (canRedo) {
+ redo();
+ }
+ }
+ };
+
+ window.addEventListener('keydown', handleKeyDown);
+ return () => window.removeEventListener('keydown', handleKeyDown);
+ }, [undo, redo, canUndo, canRedo]);
+
const togglePlayPause = useCallback(() => {
if (videoRef.current) {
if (isPlaying) {
@@ -701,17 +956,29 @@ export default function Editor() {
}
};
- const skipBackward = () => {
+ const skipBackward = useCallback(() => {
if (videoRef.current) {
- videoRef.current.currentTime = Math.max(0, videoRef.current.currentTime - 5);
+ const newTime = Math.max(trimRange.start, videoRef.current.currentTime - 5);
+ videoRef.current.currentTime = newTime;
+ setCurrentTime(newTime);
+ syncAudioPlayback(newTime, isPlaying);
}
- };
+ }, [trimRange.start, isPlaying, syncAudioPlayback]);
- const skipForward = () => {
+ const skipForward = useCallback(() => {
if (videoRef.current) {
- videoRef.current.currentTime = Math.min(videoDuration, videoRef.current.currentTime + 5);
+ const newTime = Math.min(trimRange.end, videoRef.current.currentTime + 5);
+ videoRef.current.currentTime = newTime;
+ setCurrentTime(newTime);
+ syncAudioPlayback(newTime, isPlaying);
+
+ if (newTime >= trimRange.end) {
+ videoRef.current.pause();
+ setIsPlaying(false);
+ syncAudioPlayback(newTime, false);
+ }
}
- };
+ }, [trimRange.end, isPlaying, syncAudioPlayback]);
const handleSeek = useCallback((time: number) => {
setScrubTime(time);
@@ -774,6 +1041,10 @@ export default function Editor() {
// Zoom fragment handlers
const handleSelectZoomFragment = useCallback((fragmentId: string | null) => {
setSelectedZoomFragmentId(fragmentId);
+ // Clear audio track selection when selecting zoom fragment
+ if (fragmentId) {
+ setSelectedAudioTrackId(null);
+ }
}, []);
const handleActivateZoomTool = useCallback(() => {
@@ -958,116 +1229,120 @@ export default function Editor() {
return (
<div className="flex flex-col h-screen w-full bg-[#0E0E12] text-white/60 font-sans overflow-hidden select-none">
<div className="flex flex-1 overflow-hidden">
- {/* Tools Sidebar */}
- <ToolsSidebar
- activeTool={activeTool}
- onToolChange={setActiveTool}
- onVideoUpload={handleVideoUpload}
- isUploading={isUploading}
- />
+ <div className="hidden lg:flex">
+ <ToolsSidebar
+ activeTool={activeTool}
+ onToolChange={setActiveTool}
+ onVideoUpload={handleVideoUpload}
+ isUploading={isUploading}
+ />
+ </div>
+
+ <div className="hidden lg:block">
+ <AnimatePresence mode="wait">
+ {isControlPanelOpen && (
+ <motion.div
+ key="control-panel"
+ initial={{ x: -320, opacity: 0 }}
+ animate={{ x: 0, opacity: 1 }}
+ exit={{ x: -320, opacity: 0 }}
+ transition={{ duration: 0.3, ease: "easeInOut" }}
+ >
+ <Suspense fallback={
+ <div className="w-[320px] h-screen bg-[#141417] border-r border-white/10 flex items-center justify-center">
+ <LoadingSpinner message="Cargando panel..." />
+ </div>
+ }>
+ <ControlPanel
+ activeTool={activeTool}
+ backgroundTab={backgroundTab}
+ onBackgroundTabChange={handleBackgroundTabChange}
+ selectedWallpaper={selectedWallpaper}
+ onWallpaperSelect={handleWallpaperSelect}
+ backgroundBlur={backgroundBlur}
+ onBackgroundBlurChange={setBackgroundBlur}
+ padding={padding}
+ onPaddingChange={setPadding}
+ roundedCorners={roundedCorners}
+ onRoundedCornersChange={handleRoundedCornersChange}
+ shadows={shadows}
+ onShadowsChange={setShadows}
+ uploadedImages={uploadedImages}
+ selectedImageUrl={selectedImageUrl}
+ onImageUpload={handleImageUpload}
+ onImageSelect={handleImageSelect}
+ onImageRemove={handleImageRemove}
+ backgroundColorConfig={backgroundColorConfig}
+ onBackgroundColorChange={handleBackgroundColorChange}
+ onTogglePanel={() => setIsControlPanelOpen(!isControlPanelOpen)}
+ isOpen={isControlPanelOpen}
+ // Zoom props
+ zoomFragments={zoomFragments}
+ selectedZoomFragment={selectedZoomFragment}
+ onSelectZoomFragment={handleSelectZoomFragment}
+ onAddZoomFragment={() => handleAddZoomFragment(currentTime)}
+ onUpdateZoomFragment={handleUpdateZoomFragment}
+ onDeleteZoomFragment={handleDeleteZoomFragment}
+ videoUrl={videoUrl}
+ videoThumbnail={selectedZoomFragment ? getThumbnailForTime(selectedZoomFragment.startTime)?.dataUrl ?? null : null}
+ currentTime={currentTime}
+ getThumbnailForTime={getThumbnailForTime}
+ videoDimensions={customAspectRatio}
+ // Mockup props
+ mockupId={mockupId}
+ mockupConfig={mockupConfig}
+ onMockupChange={handleMockupChange}
+ onMockupConfigChange={handleMockupConfigChange}
+ // Canvas elements props
+ onAddCanvasElement={addCanvasElement}
+ selectedCanvasElement={canvasElements.find(el => el.id === selectedElementId) || null}
+ onUpdateCanvasElement={updateCanvasElement}
+ onDeleteCanvasElement={deleteCanvasElement}
+ onBringToFront={bringToFront}
+ onSendToBack={sendToBack}
+ // Audio props
+ uploadedAudios={uploadedAudios}
+ audioTracks={audioTracks}
+ muteOriginalAudio={muteOriginalAudio}
+ masterVolume={masterVolume}
+ onAudioUpload={handleAudioUpload}
+ onAudioDelete={handleAudioDelete}
+ onAddAudioTrack={handleAddAudioTrack}
+ onUpdateAudioTrack={handleUpdateAudioTrack}
+ onDeleteAudioTrack={handleDeleteAudioTrack}
+ onToggleMuteOriginalAudio={handleToggleMuteOriginalAudio}
+ onMasterVolumeChange={handleMasterVolumeChange}
+ videoDuration={videoDuration}
+ videoHasAudioTrack={videoHasAudioTrack}
+ />
+ </Suspense>
+ </motion.div>
+ )}
+ </AnimatePresence>
+ </div>
- {/* Control Panel */}
- <AnimatePresence mode="wait">
- {isControlPanelOpen && (
- <motion.div
- key="control-panel"
- initial={{ x: -320, opacity: 0 }}
- animate={{ x: 0, opacity: 1 }}
- exit={{ x: -320, opacity: 0 }}
- transition={{ duration: 0.3, ease: "easeInOut" }}
- >
- <Suspense fallback={
- <div className="w-[320px] h-screen bg-[#141417] border-r border-white/10 flex items-center justify-center">
- <LoadingSpinner message="Cargando panel..." />
- </div>
- }>
- <ControlPanel
- activeTool={activeTool}
- backgroundTab={backgroundTab}
- onBackgroundTabChange={handleBackgroundTabChange}
- selectedWallpaper={selectedWallpaper}
- onWallpaperSelect={handleWallpaperSelect}
- backgroundBlur={backgroundBlur}
- onBackgroundBlurChange={setBackgroundBlur}
- padding={padding}
- onPaddingChange={setPadding}
- roundedCorners={roundedCorners}
- onRoundedCornersChange={handleRoundedCornersChange}
- shadows={shadows}
- onShadowsChange={setShadows}
- uploadedImages={uploadedImages}
- selectedImageUrl={selectedImageUrl}
- onImageUpload={handleImageUpload}
- onImageSelect={handleImageSelect}
- onImageRemove={handleImageRemove}
- backgroundColorConfig={backgroundColorConfig}
- onBackgroundColorChange={handleBackgroundColorChange}
- onTogglePanel={() => setIsControlPanelOpen(!isControlPanelOpen)}
- isOpen={isControlPanelOpen}
- // Zoom props
- zoomFragments={zoomFragments}
- selectedZoomFragment={selectedZoomFragment}
- onSelectZoomFragment={handleSelectZoomFragment}
- onAddZoomFragment={() => handleAddZoomFragment(currentTime)}
- onUpdateZoomFragment={handleUpdateZoomFragment}
- onDeleteZoomFragment={handleDeleteZoomFragment}
- videoUrl={videoUrl}
- videoThumbnail={selectedZoomFragment ? getThumbnailForTime(selectedZoomFragment.startTime)?.dataUrl ?? null : null}
- currentTime={currentTime}
- getThumbnailForTime={getThumbnailForTime}
- videoDimensions={customAspectRatio}
- // Mockup props
- mockupId={mockupId}
- mockupConfig={mockupConfig}
- onMockupChange={handleMockupChange}
- onMockupConfigChange={handleMockupConfigChange}
- // Canvas elements props
- onAddCanvasElement={addCanvasElement}
- selectedCanvasElement={canvasElements.find(el => el.id === selectedElementId) || null}
- onUpdateCanvasElement={updateCanvasElement}
- onDeleteCanvasElement={deleteCanvasElement}
- onBringToFront={bringToFront}
- onSendToBack={sendToBack}
- // Audio props
- uploadedAudios={uploadedAudios}
- audioTracks={audioTracks}
- muteOriginalAudio={muteOriginalAudio}
- masterVolume={masterVolume}
- onAudioUpload={handleAudioUpload}
- onAudioDelete={handleAudioDelete}
- onAddAudioTrack={handleAddAudioTrack}
- onUpdateAudioTrack={handleUpdateAudioTrack}
- onDeleteAudioTrack={handleDeleteAudioTrack}
- onToggleMuteOriginalAudio={handleToggleMuteOriginalAudio}
- onMasterVolumeChange={handleMasterVolumeChange}
- videoDuration={videoDuration}
- videoHasAudioTrack={videoHasAudioTrack}
- />
- </Suspense>
- </motion.div>
- )}
- </AnimatePresence>
-
- {/* Main Editor Area */}
<div
ref={editorAreaRef}
- className="flex-1 bg-[#09090B] flex flex-col relative overflow-hidden"
+ className="flex-1 bg-[#09090B] flex flex-col relative overflow-hidden min-w-0"
>
<AnimatePresence>
{!isControlPanelOpen && (
- <motion.button
- initial={{ x: -100, opacity: 0 }}
- animate={{ x: 0, opacity: 1 }}
- exit={{ x: -100, opacity: 0 }}
- transition={{ duration: 0.3, ease: "easeInOut", delay: 0.15 }}
- whileHover={{ scale: 1.1 }}
- whileTap={{ scale: 0.9 }}
- onClick={() => setIsControlPanelOpen(true)}
- className="absolute top-2 left-4 z-50 p-2 squircle-element bg-[#18181b] border border-white/10 text-white hover:bg-[#252529] transition-all duration-200 shadow-lg"
- title="Abrir panel de control"
- >
- <Icon icon="lucide:sidebar-open" width="20" />
- </motion.button>
+ <TooltipAction label="Abrir panel de control" side="right">
+ <motion.button
+ initial={{ x: -100, opacity: 0 }}
+ animate={{ x: 0, opacity: 1 }}
+ exit={{ x: -100, opacity: 0 }}
+ transition={{ duration: 0.3, ease: "easeInOut", delay: 0.15 }}
+ whileHover={{ scale: 1.1 }}
+ whileTap={{ scale: 0.9 }}
+ onClick={() => setIsControlPanelOpen(true)}
+ className="absolute top-2 left-4 z-50 p-2 flex items-center gap-2 squircle-element bg-[#18181b] border border-white/10 text-white hover:bg-[#252529] transition-all duration-200 shadow-lg"
+ >
+ <Link href="/" className="block sm:hidden"><Image src="/svg/logo-openvid.svg" alt="Logo" width={24} height={24} className="hover:opacity-80 transition-opacity" /></Link>
+ <Icon icon="lucide:sidebar-open" width="20" className="hidden sm:block"
+ />
+ </motion.button>
+ </TooltipAction>
)}
</AnimatePresence>
@@ -1075,9 +1350,12 @@ export default function Editor() {
onExport={handleExport}
exportProgress={exportProgress}
hasTransparentBackground={selectedWallpaper === -1}
+ onUndo={undo}
+ onRedo={redo}
+ canUndo={canUndo}
+ canRedo={canRedo}
/>
- {/* Video Canvas */}
<VideoCanvas
ref={canvasRef}
videoUrl={videoUrl}
@@ -1128,7 +1406,6 @@ export default function Editor() {
}}
/>
- {/* Player Controls */}
<PlayerControls
isPlaying={isPlaying}
currentTime={currentTime}
@@ -1170,7 +1447,7 @@ export default function Editor() {
audioTracks={audioTracks}
uploadedAudios={uploadedAudios}
selectedAudioTrackId={selectedAudioTrackId}
- onSelectAudioTrack={setSelectedAudioTrackId}
+ onSelectAudioTrack={handleSelectAudioTrack}
onUpdateAudioTrack={handleUpdateAudioTrack}
/>
</Suspense>
@@ -1178,6 +1455,74 @@ export default function Editor() {
</div>
</div>
+
+ <MobileToolsMenu
+ activeTool={activeTool}
+ onToolChange={setActiveTool}
+ onVideoUpload={handleVideoUpload}
+ isUploading={isUploading}
+ onOpenToolPanel={() => setIsMobileControlPanelOpen(true)}
+ />
+
+ <MobileControlPanel
+ isOpen={isMobileControlPanelOpen}
+ onClose={() => setIsMobileControlPanelOpen(false)}
+ activeTool={activeTool}
+ backgroundTab={backgroundTab}
+ onBackgroundTabChange={handleBackgroundTabChange}
+ selectedWallpaper={selectedWallpaper}
+ onWallpaperSelect={handleWallpaperSelect}
+ backgroundBlur={backgroundBlur}
+ onBackgroundBlurChange={setBackgroundBlur}
+ padding={padding}
+ onPaddingChange={setPadding}
+ roundedCorners={roundedCorners}
+ onRoundedCornersChange={handleRoundedCornersChange}
+ shadows={shadows}
+ onShadowsChange={setShadows}
+ uploadedImages={uploadedImages}
+ selectedImageUrl={selectedImageUrl}
+ onImageUpload={handleImageUpload}
+ onImageSelect={handleImageSelect}
+ onImageRemove={handleImageRemove}
+ backgroundColorConfig={backgroundColorConfig}
+ onBackgroundColorChange={handleBackgroundColorChange}
+ zoomFragments={zoomFragments}
+ selectedZoomFragment={selectedZoomFragment}
+ onSelectZoomFragment={handleSelectZoomFragment}
+ onAddZoomFragment={() => handleAddZoomFragment(currentTime)}
+ onUpdateZoomFragment={handleUpdateZoomFragment}
+ onDeleteZoomFragment={handleDeleteZoomFragment}
+ videoUrl={videoUrl}
+ videoThumbnail={selectedZoomFragment ? getThumbnailForTime(selectedZoomFragment.startTime)?.dataUrl ?? null : null}
+ currentTime={currentTime}
+ getThumbnailForTime={getThumbnailForTime}
+ videoDimensions={videoDimensions}
+ mockupId={mockupId}
+ mockupConfig={mockupConfig}
+ onMockupChange={handleMockupChange}
+ onMockupConfigChange={handleMockupConfigChange}
+ onAddCanvasElement={addCanvasElement}
+ selectedCanvasElement={canvasElements.find(el => el.id === selectedElementId) || null}
+ onUpdateCanvasElement={updateCanvasElement}
+ onDeleteCanvasElement={deleteCanvasElement}
+ onBringToFront={bringToFront}
+ onSendToBack={sendToBack}
+ uploadedAudios={uploadedAudios}
+ audioTracks={audioTracks}
+ muteOriginalAudio={muteOriginalAudio}
+ masterVolume={masterVolume}
+ onAudioUpload={handleAudioUpload}
+ onAudioDelete={handleAudioDelete}
+ onAddAudioTrack={handleAddAudioTrack}
+ onUpdateAudioTrack={handleUpdateAudioTrack}
+ onDeleteAudioTrack={handleDeleteAudioTrack}
+ onToggleMuteOriginalAudio={handleToggleMuteOriginalAudio}
+ onMasterVolumeChange={handleMasterVolumeChange}
+ videoDuration={videoDuration}
+ videoHasAudioTrack={videoHasAudioTrack}
+ />
+
<Suspense fallback={null}>
<ExportOverlay
exportProgress={exportProgress}
@@ -1194,6 +1539,53 @@ export default function Editor() {
initialCrop={cropArea}
/>
</Suspense>
+
+ {autoTrimModalOpen && pendingAudioUpload && (
+ <AudioTrimModal
+ key={pendingAudioUpload.audio.id}
+ isOpen={autoTrimModalOpen}
+ audioName={pendingAudioUpload.audio.name}
+ audioUrl={pendingAudioUpload.audio.url}
+ audioDuration={pendingAudioUpload.audio.duration}
+ initialTrimStart={0}
+ initialTrimEnd={Math.min(pendingAudioUpload.audio.duration, videoDuration)}
+ onConfirm={(trimStart, trimEnd) => {
+ if (pendingAudioUpload) {
+ const lastTrackEnd = audioTracks.reduce((max, track) =>
+ Math.max(max, track.startTime + track.duration), 0);
+
+ const newTrack: AudioTrack = {
+ id: pendingAudioUpload.trackId,
+ audioId: pendingAudioUpload.audio.id,
+ name: pendingAudioUpload.audio.name,
+ startTime: lastTrackEnd,
+ duration: trimEnd - trimStart,
+ trimStart: trimStart, // ← NUEVO
+ volume: 1,
+ loop: false,
+ };
+
+ setAudioTracks(prev => [...prev, newTrack]);
+
+ // Auto-mute original audio when first track is added
+ if (audioTracks.length === 0) {
+ setMuteOriginalAudio(true);
+ }
+ }
+ setAutoTrimModalOpen(false);
+ setPendingAudioUpload(null);
+ }}
+ onCancel={() => {
+ // Remove the uploaded audio if user cancels
+ if (pendingAudioUpload) {
+ setUploadedAudios(prev => prev.filter(a => a.id !== pendingAudioUpload.audio.id));
+ URL.revokeObjectURL(pendingAudioUpload.audio.url);
+ }
+ setAutoTrimModalOpen(false);
+ setPendingAudioUpload(null);
+ }}
+ />
+ )}
</div>
);
}
\ No newline at end of file
diff --git a/app/(editor)/layout.tsx b/app/(editor)/layout.tsx
index a64f4a0..1588d30 100644
--- a/app/(editor)/layout.tsx
+++ b/app/(editor)/layout.tsx
@@ -1,7 +1,13 @@
+"use client";
+
+import { AuthProvider } from "@/hooks/useAuth";
+
export default function EditorLayout({ children }: { children: React.ReactNode }) {
return (
- <div className="min-h-screen bg-neutral-950">
- {children}
- </div>
+ <AuthProvider>
+ <div className="min-h-screen bg-neutral-950">
+ {children}
+ </div>
+ </AuthProvider>
);
}
diff --git a/app/(home)/layout.tsx b/app/(home)/layout.tsx
index 47af5e0..40f949a 100644
--- a/app/(home)/layout.tsx
+++ b/app/(home)/layout.tsx
@@ -4,19 +4,22 @@ import "../globals.css";
import Header from "../components/common/Header";
import Footer from "../components/common/Footer";
import { RecordingProvider } from "@/hooks/RecordingContext";
+import { AuthProvider } from "@/hooks/useAuth";
import RecordingOverlay from "../components/ui/RecordingOverlay";
export default function HomeLayout({ children }: { children: React.ReactNode }) {
return (
- <RecordingProvider>
- <div className="flex min-h-screen flex-col text-neutral-300 bg-neutral-950">
- <Header />
- <main className="flex-1 w-full">
- {children}
- </main>
- <Footer />
- </div>
- <RecordingOverlay />
- </RecordingProvider>
+ <AuthProvider>
+ <RecordingProvider>
+ <div className="flex min-h-screen flex-col text-neutral-300 bg-neutral-950">
+ <Header />
+ <main className="flex-1 w-full">
+ {children}
+ </main>
+ <Footer />
+ </div>
+ <RecordingOverlay />
+ </RecordingProvider>
+ </AuthProvider>
);
}
diff --git a/app/(legal)/layout.tsx b/app/(legal)/layout.tsx
new file mode 100644
index 0000000..9badd7f
--- /dev/null
+++ b/app/(legal)/layout.tsx
@@ -0,0 +1,17 @@
+import { AuthProvider } from "@/hooks/useAuth";
+import Footer from "../components/common/Footer";
+import Header from "../components/common/Header";
+
+export default function LegalLayout({ children }: { children: React.ReactNode }) {
+ return (
+ <AuthProvider>
+ <div className="min-h-screen flex flex-col bg-[#09090B]">
+ <Header />
+ <div className="grow pt-24 pb-16">
+ {children}
+ </div>
+ <Footer />
+ </div>
+ </AuthProvider>
+ );
+}
diff --git a/app/(legal)/privacy/page.tsx b/app/(legal)/privacy/page.tsx
new file mode 100644
index 0000000..27b0fd7
--- /dev/null
+++ b/app/(legal)/privacy/page.tsx
@@ -0,0 +1,183 @@
+"use client";
+
+import { Icon } from "@iconify/react";
+import Link from "next/link";
+
+export default function PrivacyPage() {
+ return (
+ <div className="min-h-screen bg-[#09090B] py-16 px-4 sm:px-6 lg:px-8">
+ <div className="max-w-3xl mx-auto">
+ {/* Header */}
+ <div className="mb-12">
+ <Link
+ href="/"
+ className="inline-flex items-center text-sm text-white/50 hover:text-white mb-8 transition-colors"
+ >
+ <Icon icon="lucide:arrow-left" width="16" className="mr-2" />
+ Volver al inicio
+ </Link>
+
+ <h1 className="text-3xl md:text-4xl font-semibold text-white mb-3">
+ Política de Privacidad
+ </h1>
+ <p className="text-white/50 text-sm">
+ Última actualización: {new Date().toLocaleDateString('es-ES', { day: 'numeric', month: 'long', year: 'numeric' })}
+ </p>
+ </div>
+
+ {/* Content */}
+ <div className="space-y-10 text-white/70 leading-relaxed">
+ <section>
+ <h2 className="text-xl font-medium text-white mb-4">1. Introducción</h2>
+ <p>
+ En openvid, respetamos tu privacidad y nos comprometemos a proteger tu información personal.
+ Esta política describe cómo recopilamos, usamos y protegemos tus datos cuando utilizas nuestra plataforma.
+ </p>
+ </section>
+
+ <section>
+ <h2 className="text-xl font-medium text-white mb-4">2. Información que Recopilamos</h2>
+ <p className="mb-3">
+ Recopilamos la siguiente información cuando usas openvid:
+ </p>
+ <ul className="list-disc list-inside space-y-2 ml-2">
+ <li><strong className="text-white/80">Información de cuenta:</strong> Nombre, correo electrónico y foto de perfil (cuando usas OAuth)</li>
+ <li><strong className="text-white/80">Datos de uso:</strong> Información sobre cómo usas la aplicación y sus funciones</li>
+ <li><strong className="text-white/80">Información técnica:</strong> Tipo de navegador, dispositivo, dirección IP y cookies</li>
+ <li><strong className="text-white/80">Contenido temporal:</strong> Videos que subes para editar (procesados localmente en tu navegador)</li>
+ </ul>
+ </section>
+
+ <section>
+ <h2 className="text-xl font-medium text-white mb-4">3. Cómo Usamos tu Información</h2>
+ <p className="mb-3">
+ Utilizamos tu información para:
+ </p>
+ <ul className="list-disc list-inside space-y-2 ml-2">
+ <li>Proporcionar y mejorar los servicios de openvid</li>
+ <li>Personalizar tu experiencia de usuario</li>
+ <li>Comunicarnos contigo sobre actualizaciones y nuevas funciones</li>
+ <li>Analizar el uso de la plataforma para optimizar el rendimiento</li>
+ <li>Prevenir fraudes y proteger la seguridad de la plataforma</li>
+ </ul>
+ </section>
+
+ <section>
+ <h2 className="text-xl font-medium text-white mb-4">4. Procesamiento de Videos</h2>
+ <div className="flex items-start gap-3 p-4 bg-green-500/5 border border-green-500/20 rounded-xl mt-4">
+ <Icon icon="lucide:shield-check" className="text-green-400 shrink-0 mt-0.5" width="18" />
+ <div>
+ <p className="text-white/80 font-semibold mb-1">Privacidad Garantizada</p>
+ <p className="text-green-400/80 text-sm leading-relaxed">
+ Tus videos se procesan <span className="font-semibold text-green-300">completamente en tu navegador</span>.
+ No subimos tus videos a nuestros servidores. Todo el procesamiento ocurre localmente en tu dispositivo,
+ garantizando que tu contenido permanezca privado y seguro.
+ </p>
+ </div>
+ </div>
+ </section>
+
+ <section>
+ <h2 className="text-xl font-medium text-white mb-4">5. Cookies y Tecnologías Similares</h2>
+ <p className="mb-3">
+ Utilizamos cookies y tecnologías similares para:
+ </p>
+ <ul className="list-disc list-inside space-y-2 ml-2 mb-3">
+ <li>Mantener tu sesión activa</li>
+ <li>Recordar tus preferencias de edición</li>
+ <li>Analizar el rendimiento de la aplicación</li>
+ <li>Proporcionar funciones de autenticación</li>
+ </ul>
+ <p>
+ Puedes configurar tu navegador para rechazar cookies, pero esto puede afectar la funcionalidad de la aplicación.
+ </p>
+ </section>
+
+ <section>
+ <h2 className="text-xl font-medium text-white mb-4">6. Compartir Información</h2>
+ <p className="mb-3">
+ No vendemos ni compartimos tu información personal con terceros, excepto en los siguientes casos:
+ </p>
+ <ul className="list-disc list-inside space-y-2 ml-2">
+ <li><strong className="text-white/80">Proveedores de servicios:</strong> Como servicios de autenticación (Google OAuth)</li>
+ <li><strong className="text-white/80">Cumplimiento legal:</strong> Cuando sea requerido por ley o autoridades competentes</li>
+ <li><strong className="text-white/80">Protección de derechos:</strong> Para proteger nuestros derechos legales o los de otros usuarios</li>
+ </ul>
+ </section>
+
+ <section>
+ <h2 className="text-xl font-medium text-white mb-4">7. Seguridad de Datos</h2>
+ <p className="mb-3">
+ Implementamos medidas de seguridad técnicas y organizativas para proteger tu información contra:
+ </p>
+ <ul className="list-disc list-inside space-y-2 ml-2 mb-3">
+ <li>Acceso no autorizado</li>
+ <li>Divulgación accidental</li>
+ <li>Alteración o destrucción de datos</li>
+ </ul>
+ <p>
+ Sin embargo, ningún método de transmisión por Internet es 100% seguro, y no podemos garantizar la seguridad absoluta.
+ </p>
+ </section>
+
+ <section>
+ <h2 className="text-xl font-medium text-white mb-4">8. Tus Derechos</h2>
+ <p className="mb-3">
+ Tienes derecho a:
+ </p>
+ <ul className="list-disc list-inside space-y-2 ml-2">
+ <li><strong className="text-white/80">Acceso:</strong> Solicitar una copia de tu información personal</li>
+ <li><strong className="text-white/80">Rectificación:</strong> Corregir información inexacta o incompleta</li>
+ <li><strong className="text-white/80">Eliminación:</strong> Solicitar la eliminación de tu cuenta y datos</li>
+ <li><strong className="text-white/80">Portabilidad:</strong> Recibir tus datos en un formato estructurado</li>
+ <li><strong className="text-white/80">Oposición:</strong> Oponerte a ciertos procesamientos de tus datos</li>
+ </ul>
+ </section>
+
+ <section>
+ <h2 className="text-xl font-medium text-white mb-4">9. Retención de Datos</h2>
+ <p>
+ Conservamos tu información personal solo durante el tiempo necesario para los propósitos descritos en esta política.
+ Los videos procesados en tu navegador no se almacenan en nuestros servidores y se eliminan automáticamente al cerrar la sesión.
+ </p>
+ </section>
+
+ <section>
+ <h2 className="text-xl font-medium text-white mb-4">10. Menores de Edad</h2>
+ <p>
+ openvid no está dirigido a menores de 13 años. No recopilamos intencionalmente información de menores.
+ Si descubrimos que hemos recopilado datos de un menor sin consentimiento parental, los eliminaremos de inmediato.
+ </p>
+ </section>
+
+ <section>
+ <h2 className="text-xl font-medium text-white mb-4">11. Cambios a esta Política</h2>
+ <p>
+ Podemos actualizar esta política de privacidad periódicamente. Te notificaremos sobre cambios significativos
+ mediante un aviso en la aplicación o por correo electrónico. Te recomendamos revisar esta página regularmente.
+ </p>
+ </section>
+
+ <section>
+ <h2 className="text-xl font-medium text-white mb-4">12. Contacto</h2>
+ <p>
+ Si tienes preguntas o inquietudes sobre esta política de privacidad, o deseas ejercer tus derechos,
+ puedes contactarnos a través de los canales disponibles en la aplicación.
+ </p>
+ </section>
+ </div>
+
+ {/* Footer Info */}
+ <div className="mt-16 pt-8 border-t border-white/10">
+ <p className="text-sm text-white/50">
+ Al usar openvid, también aceptas nuestros{" "}
+ <Link href="/terms" className="text-white hover:underline transition-colors">
+ Términos de Servicio
+ </Link>
+ .
+ </p>
+ </div>
+ </div>
+ </div>
+ );
+}
\ No newline at end of file
diff --git a/app/(legal)/terms/page.tsx b/app/(legal)/terms/page.tsx
new file mode 100644
index 0000000..3a19c69
--- /dev/null
+++ b/app/(legal)/terms/page.tsx
@@ -0,0 +1,137 @@
+"use client";
+
+import { Icon } from "@iconify/react";
+import Link from "next/link";
+
+export default function TermsPage() {
+ return (
+ <div className="min-h-screen bg-[#09090B] py-16 px-4 sm:px-6 lg:px-8">
+ <div className="max-w-3xl mx-auto">
+ {/* Header */}
+ <div className="mb-12">
+ <Link
+ href="/"
+ className="inline-flex items-center text-sm text-white/50 hover:text-white mb-8 transition-colors"
+ >
+ <Icon icon="lucide:arrow-left" width="16" className="mr-2" />
+ Volver al inicio
+ </Link>
+
+ <h1 className="text-3xl md:text-4xl font-semibold text-white mb-3">
+ Términos de Servicio
+ </h1>
+ <p className="text-white/50 text-sm">
+ Última actualización: {new Date().toLocaleDateString('es-ES', { day: 'numeric', month: 'long', year: 'numeric' })}
+ </p>
+ </div>
+
+ {/* Content */}
+ <div className="space-y-10 text-white/70 leading-relaxed">
+ <section>
+ <h2 className="text-xl font-medium text-white mb-4">1. Aceptación de los Términos</h2>
+ <p>
+ Al acceder y utilizar openvid, aceptas estar legalmente vinculado por estos términos de servicio.
+ Si no estás de acuerdo con alguna parte de estos términos, no debes utilizar nuestra plataforma.
+ </p>
+ </section>
+
+ <section>
+ <h2 className="text-xl font-medium text-white mb-4">2. Descripción del Servicio</h2>
+ <p className="mb-3">
+ openvid es una aplicación web de edición de video que permite a los usuarios:
+ </p>
+ <ul className="list-disc list-inside space-y-2 ml-2">
+ <li>Subir y editar videos en el navegador.</li>
+ <li>Aplicar efectos visuales, fondos y elementos personalizados.</li>
+ <li>Exportar videos con o sin fondo transparente.</li>
+ <li>Utilizar herramientas de zoom, recorte y ajustes de audio.</li>
+ </ul>
+ </section>
+
+ <section>
+ <h2 className="text-xl font-medium text-white mb-4">3. Cuenta de Usuario</h2>
+ <p className="mb-3">
+ Para acceder a ciertas funciones, es posible que necesites crear una cuenta mediante:
+ </p>
+ <ul className="list-disc list-inside space-y-2 ml-2 mb-3">
+ <li>Autenticación con Google OAuth.</li>
+ <li>Otros métodos de autenticación disponibles.</li>
+ </ul>
+ <p>
+ Eres responsable de mantener la confidencialidad de tu cuenta.
+ </p>
+ </section>
+
+ <section>
+ <h2 className="text-xl font-medium text-white mb-4">4. Uso Aceptable</h2>
+ <p className="mb-3">
+ Al utilizar openvid, te comprometes a:
+ </p>
+ <ul className="list-disc list-inside space-y-2 ml-2">
+ <li>No subir contenido ilegal, ofensivo o que viole derechos de terceros.</li>
+ <li>No utilizar el servicio para propósitos maliciosos o fraudulentos.</li>
+ <li>No intentar acceder a sistemas o datos sin autorización.</li>
+ <li>Respetar los límites de uso y recursos del servicio.</li>
+ </ul>
+ </section>
+
+ <section>
+ <h2 className="text-xl font-medium text-white mb-4">5. Propiedad Intelectual</h2>
+ <p>
+ Tú mantienes todos los derechos sobre el contenido que subes a openvid.
+ Nosotros solo procesamos tus videos temporalmente para proporcionar el servicio de edición.
+ No almacenamos ni compartimos tu contenido sin tu consentimiento explícito.
+ </p>
+ </section>
+
+ <section>
+ <h2 className="text-xl font-medium text-white mb-4">6. Limitación de Responsabilidad</h2>
+ <p className="text-white/60">
+ openvid se proporciona &quot;tal cual&quot; sin garantías de ningún tipo. No nos hacemos responsables de:
+ </p>
+ <ul className="list-disc list-inside space-y-2 ml-2">
+ <li>Pérdida de datos o contenido.</li>
+ <li>Interrupciones del servicio.</li>
+ <li>Errores en la exportación de videos.</li>
+ <li>Incompatibilidades con navegadores o dispositivos.</li>
+ </ul>
+ </section>
+
+ <section>
+ <h2 className="text-xl font-medium text-white mb-4">7. Modificaciones del Servicio</h2>
+ <p>
+ Nos reservamos el derecho de modificar, suspender o discontinuar el servicio en cualquier momento
+ sin previo aviso. También podemos actualizar estos términos periódicamente.
+ </p>
+ </section>
+
+ <section>
+ <h2 className="text-xl font-medium text-white mb-4">8. Ley Aplicable</h2>
+ <p>
+ Estos términos se rigen por las leyes aplicables en tu jurisdicción.
+ Cualquier disputa se resolverá mediante arbitraje vinculante.
+ </p>
+ </section>
+
+ <section>
+ <h2 className="text-xl font-medium text-white mb-4">9. Contacto</h2>
+ <p>
+ Si tienes preguntas sobre estos términos, puedes contactarnos a través de los canales disponibles en la aplicación.
+ </p>
+ </section>
+ </div>
+
+ {/* Footer Info */}
+ <div className="mt-16 pt-8 border-t border-white/10">
+ <p className="text-sm text-white/50">
+ Al usar openvid, también aceptas nuestra{" "}
+ <Link href="/privacy" className="text-white hover:underline transition-colors">
+ Política de Privacidad
+ </Link>
+ .
+ </p>
+ </div>
+ </div>
+ </div>
+ );
+}
\ No newline at end of file
diff --git a/app/_not-found/page.tsx b/app/_not-found/page.tsx
deleted file mode 100644
index a7ee783..0000000
--- a/app/_not-found/page.tsx
+++ /dev/null
@@ -1,10 +0,0 @@
-export default function NotFound() {
- return (
- <div className="flex h-screen items-center justify-center bg-black">
- <div className="text-center">
- <h1 className="text-4xl font-bold text-white mb-4">404</h1>
- <p className="text-xl text-gray-400">Página no encontrada</p>
- </div>
- </div>
- );
-}
\ No newline at end of file