Skip to content

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

feat: enhance loading component animation, adjust video editor prefetching, and optimize package imports for improved performance

CristianOlivera1cd737aac178b
diff --git a/app/[locale]/(editor)/editor/loading.tsx b/app/[locale]/(editor)/editor/loading.tsx
index 7bfea02..eca5033 100644
--- a/app/[locale]/(editor)/editor/loading.tsx
+++ b/app/[locale]/(editor)/editor/loading.tsx
@@ -1,16 +1,13 @@
export default function Loading() {
return (
- <div className="fixed inset-0 z-50 flex items-center justify-center bg-[#020202]/50 backdrop-blur-2xl animate-fade-in">
-
+ <div className="fixed inset-0 z-50 flex items-center justify-center bg-[#020202]/50 backdrop-blur-2xl animate-in fade-in duration-300">
<div className="absolute inset-0 overflow-hidden pointer-events-none z-0 opacity-30 select-none">
<div className="absolute -top-1/4 -left-1/4 size-[600px] rounded-full bg-gradient-to-br from-cyan-600/30 to-emerald-700/0 blur-[120px]" />
<div className="absolute -bottom-1/4 -right-1/4 size-[700px] rounded-full bg-gradient-to-tl from-indigo-700/25 to-purple-700/0 blur-[120px]" />
</div>
<div className="relative flex items-center justify-center z-10 scale-95 animate-[pulse_6s_ease-in-out_infinite]">
-
<div className="absolute size-36 rounded-full bg-cyan-700/10 blur-xl pointer-events-none" />
-
<img
src="/svg/logo-openvid.svg"
alt="Cargando Openvid..."
diff --git a/app/[locale]/(editor)/editor/page.tsx b/app/[locale]/(editor)/editor/page.tsx
index 7f0a4ab..5192cd1 100644
--- a/app/[locale]/(editor)/editor/page.tsx
+++ b/app/[locale]/(editor)/editor/page.tsx
@@ -213,7 +213,7 @@ export default function Editor() {
const muteOriginalAudioRef = useRef<boolean>(false);
const lastTimeUpdateRef = useRef(0);
- const REACT_TIME_UPDATE_INTERVAL_MS = 33;
+ const REACT_TIME_UPDATE_INTERVAL_MS = 50;
// Computed: which dimensions to use for the canvas
const customAspectRatio = useMemo(() => {
diff --git a/app/components/ui/editor/VideoCanvas.tsx b/app/components/ui/editor/VideoCanvas.tsx
index 945617a..e9edd63 100644
--- a/app/components/ui/editor/VideoCanvas.tsx
+++ b/app/components/ui/editor/VideoCanvas.tsx
@@ -1,6 +1,6 @@
"use client";
-import { useRef, useEffect, useImperativeHandle, useMemo, useState, useCallback, memo } from "react";
+import { useRef, useEffect, useImperativeHandle, useMemo, useState, useCallback, memo, lazy, Suspense } from "react";
import type * as THREE from "three";
import type { VideoCanvasHandle, VideoCanvasProps, VideoThumbnail } from "@/types";
import type { ImageElement } from "@/types/canvas-elements.types";
@@ -33,12 +33,15 @@ import { drawMaskedImage } from "@/lib/masked-image-draw.utils";
import { drawMockupAndMedia, type MockupDrawContext } from "@/lib/mockup-media-draw.utils";
import { drawPhone3DCompositeWithZoom, type Phone3DCompositeContext } from "@/lib/phone3d-composite-draw.utils";
import { buildMockupMotionCss, MockupMotionTransform, REST_MOCKUP_MOTION, sampleCombinedMockupMotion, sampleCombined3DMotion, REST_MOCKUP_3D_MOTION, Mockup3DMotionTransform, MOTION_PRESET_3D_IDS } from "@/lib/mockup-motion";
-import { Mockup3DFrame } from "./mockups-3d/Mockup3DFrame";
import { filterVisibleElements } from "@/lib/canvas-elements-timeline.utils";
import { ZoomPointOverlay, ZOOM_POINT_VISUAL_SCALE } from "@/components/ui/ZoomPointOverlay";
export type { VideoCanvasHandle, VideoCanvasProps };
+const Mockup3DFrame = lazy(() =>
+ import("./mockups-3d/Mockup3DFrame").then(mod => ({ default: mod.Mockup3DFrame }))
+);
+
function VideoCanvasInner({
activeTool,
mediaType = "video",
@@ -2521,6 +2524,16 @@ function VideoCanvasInner({
<div className="w-6 h-6 border-2 border-border border-t-foreground/60 rounded-full animate-spin" />
</div>
) : (
+ <Suspense
+ fallback={
+ <div
+ style={{ width: PHONE_W, height: PHONE_H }}
+ className="flex items-center justify-center"
+ >
+ <div className="w-6 h-6 border-2 border-border border-t-foreground/60 rounded-full animate-spin" />
+ </div>
+ }
+ >
<Mockup3DFrame
device={imagePhoneDevice}
rootRef={imagePhoneRootRef}
@@ -2548,6 +2561,7 @@ function VideoCanvasInner({
onSelectChange={(value) => setIsVideoSelected(value)}
motionTransform={mockup3DMotionPreview}
/>
+ </Suspense>
)}
</div>
</div>
diff --git a/app/components/ui/home/Hero.tsx b/app/components/ui/home/Hero.tsx
index c7b4d0b..0ab411d 100644
--- a/app/components/ui/home/Hero.tsx
+++ b/app/components/ui/home/Hero.tsx
@@ -21,6 +21,12 @@ export default function Hero({ onVideoUpload, onPhotoUpload }: HeroProps) {
const videoInputRef = useRef<HTMLInputElement>(null);
const [isDraggingVideo, setIsDraggingVideo] = useState(false);
const [isUploadingVideo, setIsUploadingVideo] = useState(false);
+ const prefetchVideoEditor = useCallback(() => {
+ router.prefetch("/editor?mode=video");
+ }, [router]);
+ const prefetchPhotoEditor = useCallback(() => {
+ router.prefetch("/editor?mode=photo");
+ }, [router]);
const handleVideoFile = useCallback(
async (file: File) => {
@@ -180,7 +186,7 @@ export default function Hero({ onVideoUpload, onPhotoUpload }: HeroProps) {
<div className="absolute inset-0 rounded-2xl bg-blue-500/5 blur-sm pointer-events-none" />
)}
</div>
- <Link href="/editor?mode=video" className="text-[15px] text-white/70 hover:text-white/80 transition-colors underline decoration-white/30 underline-offset-4">
+ <Link href="/editor?mode=video" onMouseEnter={prefetchVideoEditor} className="text-[15px] text-white/70 hover:text-white/80 transition-colors underline decoration-white/30 underline-offset-4">
{t("goToVideoEditor")}
</Link>
<input
@@ -232,7 +238,7 @@ export default function Hero({ onVideoUpload, onPhotoUpload }: HeroProps) {
<div className="absolute inset-0 rounded-2xl bg-red-500/5 blur-sm pointer-events-none" />
)}
</div>
- <Link href="/editor?mode=photo" className="text-[15px] text-white/70 hover:text-white/80 transition-colors underline decoration-white/30 underline-offset-4">
+ <Link href="/editor?mode=photo" onMouseEnter={prefetchPhotoEditor} className="text-[15px] text-white/70 hover:text-white/80 transition-colors underline decoration-white/30 underline-offset-4">
{t("goToPhotoEditor")}
</Link>
<input
diff --git a/next.config.ts b/next.config.ts
index 642f205..3c79f2d 100644
--- a/next.config.ts
+++ b/next.config.ts
@@ -17,6 +17,23 @@ const securityHeaders = [
const nextConfig: NextConfig = {
poweredByHeader: false,
compress: true,
+ experimental: {
+ optimizePackageImports: [
+ "lucide-react",
+ "@iconify/react",
+ "framer-motion",
+ "gsap",
+ "three",
+ "@react-three/fiber",
+ "@react-three/drei",
+ "radix-ui",
+ "@radix-ui/react-dialog",
+ "@radix-ui/react-dropdown-menu",
+ "mediabunny",
+ "html-to-image",
+ "lenis",
+ ],
+ },
images: {
formats: ["image/avif", "image/webp"],
remotePatterns: [