OpenReel Video - Professional browser-based video editor. Open source CapCut alternative. 100% browser-based, no installation, no cloud uploads, no watermarks.
TypeScript
feat(image): add context menus, improve layer grouping, and drag selection
Augustus Otu8bced1edeae6
diff --git a/apps/image/package.json b/apps/image/package.jsonindex 98be759e..39b39e3f 100644--- a/apps/image/package.json+++ b/apps/image/package.json@@ -16,6 +16,7 @@"clean": "rm -rf dist node_modules/.vite"},"dependencies": {+ "@imgly/background-removal": "^1.7.0","@openreel/ui": "workspace:*","@radix-ui/react-context-menu": "^2.2.16","@radix-ui/react-dialog": "^1.1.15",diff --git a/apps/image/src/components/editor/ExportDialog.tsx b/apps/image/src/components/editor/ExportDialog.tsxindex 436935a6..50f36d23 100644--- a/apps/image/src/components/editor/ExportDialog.tsx+++ b/apps/image/src/components/editor/ExportDialog.tsx@@ -1,5 +1,5 @@import { useState, useMemo, useEffect } from 'react';-import { Download, FileImage, Loader2, Link2, Link2Off, Printer } from 'lucide-react';+import { Download, FileImage, Loader2, Link2, Link2Off, Printer, Instagram, Youtube, Twitter, Linkedin, Facebook, Image } from 'lucide-react';import { Dialog, DialogFooter } from '../ui/Dialog';import { useProjectStore } from '../../stores/project-store';import { useUIStore } from '../../stores/ui-store';@@ -53,6 +53,91 @@ const DPI_OPTIONS = [{ value: 600, label: '600 DPI', description: 'High quality' },];+type PlatformPreset = {+ id: string;+ name: string;+ icon: React.ElementType;+ format: ExportFormat;+ quality: ExportQuality;+ maxFileSize?: string;+ recommendedSize?: { width: number; height: number };+ description: string;+};++const PLATFORM_PRESETS: PlatformPreset[] = [+ {+ id: 'instagram-post',+ name: 'Instagram Post',+ icon: Instagram,+ format: 'jpg',+ quality: 'high',+ recommendedSize: { width: 1080, height: 1080 },+ description: 'Square post, max 30MB',+ },+ {+ id: 'instagram-story',+ name: 'Instagram Story',+ icon: Instagram,+ format: 'jpg',+ quality: 'high',+ recommendedSize: { width: 1080, height: 1920 },+ description: '9:16 vertical',+ },+ {+ id: 'youtube-thumbnail',+ name: 'YouTube Thumbnail',+ icon: Youtube,+ format: 'jpg',+ quality: 'high',+ maxFileSize: '2MB',+ recommendedSize: { width: 1280, height: 720 },+ description: '16:9, under 2MB',+ },+ {+ id: 'twitter-post',+ name: 'Twitter/X Post',+ icon: Twitter,+ format: 'png',+ quality: 'high',+ recommendedSize: { width: 1200, height: 675 },+ description: '16:9 landscape',+ },+ {+ id: 'facebook-post',+ name: 'Facebook Post',+ icon: Facebook,+ format: 'jpg',+ quality: 'high',+ recommendedSize: { width: 1200, height: 630 },+ description: '1.91:1 ratio',+ },+ {+ id: 'linkedin-post',+ name: 'LinkedIn Post',+ icon: Linkedin,+ format: 'png',+ quality: 'high',+ recommendedSize: { width: 1200, height: 627 },+ description: 'Professional feed',+ },+ {+ id: 'web-optimized',+ name: 'Web Optimized',+ icon: Image,+ format: 'webp',+ quality: 'medium',+ description: 'Smallest file size',+ },+ {+ id: 'print-ready',+ name: 'Print Ready',+ icon: Printer,+ format: 'png',+ quality: 'max',+ description: 'Highest quality PNG',+ },+];+type SizeMode = 'scale' | 'custom' | 'dpi';export function ExportDialog({ open, onClose }: ExportDialogProps) {@@ -63,6 +148,7 @@ export function ExportDialog({ open, onClose }: ExportDialogProps) {const [quality, setQuality] = useState<ExportQuality>('high');const [scale, setScale] = useState(1);const [sizeMode, setSizeMode] = useState<SizeMode>('scale');+ const [selectedPreset, setSelectedPreset] = useState<string | null>(null);const [customWidth, setCustomWidth] = useState(0);const [customHeight, setCustomHeight] = useState(0);const [dpi, setDpi] = useState(72);@@ -122,6 +208,35 @@ export function ExportDialog({ open, onClose }: ExportDialogProps) {}};+ const handlePresetSelect = (preset: PlatformPreset) => {+ setSelectedPreset(preset.id);+ setFormat(preset.format);+ setQuality(preset.quality);++ if (preset.recommendedSize && artboard) {+ const artboardRatio = artboard.size.width / artboard.size.height;+ const presetRatio = preset.recommendedSize.width / preset.recommendedSize.height;+ const ratioMatch = Math.abs(artboardRatio - presetRatio) < 0.1;++ if (ratioMatch) {+ const targetScale = preset.recommendedSize.width / artboard.size.width;+ if (targetScale <= 4 && targetScale >= 0.5) {+ setScale(targetScale);+ setSizeMode('scale');+ } else {+ setSizeMode('custom');+ setCustomWidth(preset.recommendedSize.width);+ setCustomHeight(preset.recommendedSize.height);+ setLockAspectRatio(false);+ }+ }+ }+ };++ const clearPreset = () => {+ setSelectedPreset(null);+ };+const printDimensions = useMemo(() => {if (!dimensions) return null;const inches = {@@ -199,6 +314,43 @@ export function ExportDialog({ open, onClose }: ExportDialogProps) {maxWidth="md"><div className="space-y-6">+ <div>+ <div className="flex items-center justify-between mb-3">+ <label className="text-xs font-medium text-muted-foreground uppercase tracking-wide">+ Quick Presets+ </label>+ {selectedPreset && (+ <button+ onClick={clearPreset}+ className="text-[10px] text-muted-foreground hover:text-foreground transition-colors"+ >+ Clear+ </button>+ )}+ </div>+ <div className="grid grid-cols-4 gap-2">+ {PLATFORM_PRESETS.map((preset) => {+ const Icon = preset.icon;+ const isSelected = selectedPreset === preset.id;+ return (+ <button+ key={preset.id}+ onClick={() => handlePresetSelect(preset)}+ className={`p-2 rounded-lg border text-center transition-all ${+ isSelected+ ? 'border-primary bg-primary/5 ring-1 ring-primary'+ : 'border-border hover:border-muted-foreground/50 hover:bg-secondary/50'+ }`}+ >+ <Icon size={16} className={`mx-auto mb-1 ${isSelected ? 'text-primary' : 'text-muted-foreground'}`} />+ <span className="block text-[10px] font-medium truncate">{preset.name}</span>+ <span className="block text-[8px] text-muted-foreground truncate">{preset.description}</span>+ </button>+ );+ })}+ </div>+ </div>+<div><label className="block text-xs font-medium text-muted-foreground uppercase tracking-wide mb-3">Formatdiff --git a/apps/image/src/components/editor/canvas/Canvas.tsx b/apps/image/src/components/editor/canvas/Canvas.tsxindex c881ddda..4b365ca4 100644--- a/apps/image/src/components/editor/canvas/Canvas.tsx+++ b/apps/image/src/components/editor/canvas/Canvas.tsx@@ -1,21 +1,91 @@import { useEffect, useRef, useCallback, useState } from 'react';import { useProjectStore } from '../../../stores/project-store';import { useUIStore } from '../../../stores/ui-store';-import { useCanvasStore } from '../../../stores/canvas-store';+import { useCanvasStore, type ResizeHandle } from '../../../stores/canvas-store';import { calculateSnap } from '../../../utils/snapping';-import type { Layer, ImageLayer, TextLayer, ShapeLayer } from '../../../types/project';+import type { Layer, ImageLayer, TextLayer, ShapeLayer, GroupLayer } from '../../../types/project';import { Rulers } from './Rulers';+import { ContextMenu, type ContextMenuPosition, type ContextMenuType } from './ContextMenu';const RULER_SIZE = 20;+const HANDLE_SIZE = 8;+const ROTATION_HANDLE_DISTANCE = 24;++const imageCache = new Map<string, HTMLImageElement>();+let renderCallback: (() => void) | null = null;++function getCachedImage(src: string): HTMLImageElement | null {+ if (!src) return null;++ const cached = imageCache.get(src);+ if (cached && cached.complete && cached.naturalWidth > 0) {+ return cached;+ }++ if (!cached) {+ const img = new window.Image();+ img.src = src;+ imageCache.set(src, img);++ if (!img.complete) {+ img.onload = () => {+ if (renderCallback) {+ renderCallback();+ }+ };+ }+ }++ const img = imageCache.get(src);+ if (img && img.complete && img.naturalWidth > 0) {+ return img;+ }++ return null;+}export function Canvas() {const containerRef = useRef<HTMLDivElement>(null);const canvasRef = useRef<HTMLCanvasElement>(null);const [containerSize, setContainerSize] = useState({ width: 0, height: 0 });- const { project, selectedLayerIds, selectedArtboardId, updateLayerTransform, selectLayer, selectLayers, deselectAllLayers, addPathLayer } = useProjectStore();- const { zoom, panX, panY, setPan, activeTool, showGrid, showRulers, gridSize, crop, snapToObjects, snapToGuides, snapToGrid, penSettings, drawing, startDrawing, addDrawingPoint, finishDrawing } = useUIStore();- const { setCanvasRef, setContainerRef, startDrag, updateDrag, endDrag, isDragging, dragMode, dragCurrentX, dragCurrentY, guides, smartGuides, setSmartGuides, clearSmartGuides, isMarqueeSelecting, marqueeRect, startMarqueeSelect, updateMarqueeSelect, endMarqueeSelect } = useCanvasStore();+ const {+ project,+ selectedLayerIds,+ selectedArtboardId,+ updateLayerTransform,+ updateLayer,+ selectLayer,+ selectLayers,+ deselectAllLayers,+ addPathLayer,+ addTextLayer,+ addShapeLayer,+ removeLayer,+ duplicateLayer,+ copyLayers,+ cutLayers,+ pasteLayers,+ copiedLayers,+ copyLayerStyle,+ pasteLayerStyle,+ copiedStyle,+ moveLayerToTop,+ moveLayerUp,+ moveLayerDown,+ moveLayerToBottom,+ groupLayers,+ ungroupLayers,+ } = useProjectStore();+ const { zoom, panX, panY, setPan, setZoom, activeTool, showGrid, showRulers, toggleGrid, toggleRulers, gridSize, crop, snapToObjects, snapToGuides, snapToGrid, penSettings, drawing, startDrawing, addDrawingPoint, finishDrawing } = useUIStore();+ const { setCanvasRef, setContainerRef, startDrag, updateDrag, endDrag, isDragging, dragMode, dragStartX, dragStartY, dragCurrentX, dragCurrentY, guides, smartGuides, setSmartGuides, clearSmartGuides, isMarqueeSelecting, marqueeRect, startMarqueeSelect, updateMarqueeSelect, endMarqueeSelect, activeResizeHandle, setActiveResizeHandle } = useCanvasStore();+ const [cursorStyle, setCursorStyle] = useState('default');+ const initialTransformRef = useRef<{ x: number; y: number; width: number; height: number; rotation: number } | null>(null);++ const [contextMenu, setContextMenu] = useState<{+ position: ContextMenuPosition;+ type: ContextMenuType;+ } | null>(null);const artboard = project?.artboards.find((a) => a.id === selectedArtboardId);@@ -90,7 +160,7 @@ export function Canvas() {sortedLayerIds.forEach((layerId) => {const layer = project.layers[layerId];if (!layer || !layer.visible) return;- renderLayer(ctx, layer, project);+ renderLayerWithChildren(ctx, layer, project);});ctx.restore();@@ -101,15 +171,16 @@ export function Canvas() {const { x, y, width, height, rotation } = layer.transform;ctx.save();- ctx.translate(artboardX + x * zoom, artboardY + y * zoom);+ ctx.translate(artboardX + (x + width / 2) * zoom, artboardY + (y + height / 2) * zoom);ctx.rotate((rotation * Math.PI) / 180);+ ctx.translate(-(width / 2) * zoom, -(height / 2) * zoom);ctx.strokeStyle = '#22c55e';ctx.lineWidth = 2;ctx.setLineDash([]);ctx.strokeRect(0, 0, width * zoom, height * zoom);- const handleSize = 8;+ const handleSize = HANDLE_SIZE;ctx.fillStyle = '#ffffff';ctx.strokeStyle = '#22c55e';ctx.lineWidth = 2;@@ -130,6 +201,21 @@ export function Canvas() {ctx.strokeRect(h.x - handleSize / 2, h.y - handleSize / 2, handleSize, handleSize);});+ ctx.beginPath();+ ctx.moveTo(width * zoom / 2, 0);+ ctx.lineTo(width * zoom / 2, -ROTATION_HANDLE_DISTANCE);+ ctx.strokeStyle = '#22c55e';+ ctx.lineWidth = 2;+ ctx.stroke();++ ctx.beginPath();+ ctx.arc(width * zoom / 2, -ROTATION_HANDLE_DISTANCE, 6, 0, Math.PI * 2);+ ctx.fillStyle = '#ffffff';+ ctx.fill();+ ctx.strokeStyle = '#22c55e';+ ctx.lineWidth = 2;+ ctx.stroke();+ctx.restore();});@@ -283,6 +369,13 @@ export function Canvas() {render();}, [render]);+ useEffect(() => {+ renderCallback = render;+ return () => {+ renderCallback = null;+ };+ }, [render]);+useEffect(() => {const handleResize = () => {render();@@ -343,11 +436,90 @@ export function Canvas() {[artboard, project]);+ const getHandleAtPoint = useCallback(+ (canvasX: number, canvasY: number): { handle: ResizeHandle | 'rotate'; layerId: string } | null => {+ if (!artboard || !project || selectedLayerIds.length !== 1) return null;++ const canvas = canvasRef.current;+ if (!canvas) return null;++ const layerId = selectedLayerIds[0];+ const layer = project.layers[layerId];+ if (!layer) return null;++ const { x, y, width, height, rotation } = layer.transform;++ const centerX = canvas.width / 2 + panX;+ const centerY = canvas.height / 2 + panY;+ const artboardX = centerX - (artboard.size.width * zoom) / 2;+ const artboardY = centerY - (artboard.size.height * zoom) / 2;++ const layerCenterX = artboardX + (x + width / 2) * zoom;+ const layerCenterY = artboardY + (y + height / 2) * zoom;++ const rad = -(rotation * Math.PI) / 180;+ const dx = canvasX - layerCenterX;+ const dy = canvasY - layerCenterY;+ const localX = dx * Math.cos(rad) - dy * Math.sin(rad);+ const localY = dx * Math.sin(rad) + dy * Math.cos(rad);++ const halfW = (width * zoom) / 2;+ const halfH = (height * zoom) / 2;+ const threshold = HANDLE_SIZE + 4;++ const rotHandleY = -halfH - ROTATION_HANDLE_DISTANCE;+ if (Math.abs(localX) < threshold && Math.abs(localY - rotHandleY) < threshold) {+ return { handle: 'rotate', layerId };+ }++ const handlePositions: { handle: ResizeHandle; x: number; y: number }[] = [+ { handle: 'nw', x: -halfW, y: -halfH },+ { handle: 'n', x: 0, y: -halfH },+ { handle: 'ne', x: halfW, y: -halfH },+ { handle: 'e', x: halfW, y: 0 },+ { handle: 'se', x: halfW, y: halfH },+ { handle: 's', x: 0, y: halfH },+ { handle: 'sw', x: -halfW, y: halfH },+ { handle: 'w', x: -halfW, y: 0 },+ ];++ for (const pos of handlePositions) {+ if (Math.abs(localX - pos.x) < threshold && Math.abs(localY - pos.y) < threshold) {+ return { handle: pos.handle, layerId };+ }+ }++ return null;+ },+ [artboard, project, selectedLayerIds, zoom, panX, panY]+ );++ const getCursorForHandle = (handle: ResizeHandle | 'rotate' | null): string => {+ if (!handle) return 'default';+ if (handle === 'rotate') return 'crosshair';++ const cursors: Record<ResizeHandle, string> = {+ 'nw': 'nwse-resize',+ 'n': 'ns-resize',+ 'ne': 'nesw-resize',+ 'e': 'ew-resize',+ 'se': 'nwse-resize',+ 's': 'ns-resize',+ 'sw': 'nesw-resize',+ 'w': 'ew-resize',+ };++ return cursors[handle] || 'default';+ };+const handleMouseDown = useCallback((e: React.MouseEvent) => {const canvas = canvasRef.current;if (!canvas) return;+ const rect = canvas.getBoundingClientRect();+ const canvasX = e.clientX - rect.left;+ const canvasY = e.clientY - rect.top;const { x, y } = screenToCanvas(e.clientX, e.clientY);if (activeTool === 'hand' || e.button === 1) {@@ -361,6 +533,27 @@ export function Canvas() {}if (activeTool === 'select') {+ const handleHit = getHandleAtPoint(canvasX, canvasY);+ if (handleHit) {+ const layer = project?.layers[handleHit.layerId];+ if (layer) {+ initialTransformRef.current = {+ x: layer.transform.x,+ y: layer.transform.y,+ width: layer.transform.width,+ height: layer.transform.height,+ rotation: layer.transform.rotation,+ };+ if (handleHit.handle === 'rotate') {+ startDrag('rotate', e.clientX, e.clientY);+ } else {+ setActiveResizeHandle(handleHit.handle);+ startDrag('resize', e.clientX, e.clientY);+ }+ return;+ }+ }+const layerId = findLayerAtPoint(x, y);if (layerId) {if (e.shiftKey) {@@ -376,11 +569,13 @@ export function Canvas() {}}},- [activeTool, screenToCanvas, findLayerAtPoint, selectLayer, deselectAllLayers, startDrag, selectedLayerIds, startDrawing, startMarqueeSelect]+ [activeTool, screenToCanvas, findLayerAtPoint, selectLayer, deselectAllLayers, startDrag, selectedLayerIds, startDrawing, startMarqueeSelect, getHandleAtPoint, project, setActiveResizeHandle]);const handleMouseMove = useCallback((e: React.MouseEvent) => {+ const canvas = canvasRef.current;+if (drawing.isDrawing) {const { x, y } = screenToCanvas(e.clientX, e.clientY);addDrawingPoint({ x, y });@@ -388,6 +583,15 @@ export function Canvas() {return;}+ if (!isDragging && canvas && activeTool === 'select' && selectedLayerIds.length === 1) {+ const rect = canvas.getBoundingClientRect();+ const canvasX = e.clientX - rect.left;+ const canvasY = e.clientY - rect.top;+ const handleHit = getHandleAtPoint(canvasX, canvasY);+ const newCursor = getCursorForHandle(handleHit?.handle ?? null);+ setCursorStyle(newCursor);+ }+if (!isDragging) return;updateDrag(e.clientX, e.clientY);@@ -403,6 +607,153 @@ export function Canvas() {const dx = e.clientX - dragCurrentX;const dy = e.clientY - dragCurrentY;setPan(panX + dx, panY + dy);+ } else if (dragMode === 'rotate' && selectedLayerIds.length === 1 && artboard && canvas && initialTransformRef.current) {+ const layerId = selectedLayerIds[0];+ const layer = project?.layers[layerId];+ if (layer) {+ const centerX = canvas.width / 2 + panX;+ const centerY = canvas.height / 2 + panY;+ const artboardX = centerX - (artboard.size.width * zoom) / 2;+ const artboardY = centerY - (artboard.size.height * zoom) / 2;++ const layerCenterX = artboardX + (initialTransformRef.current.x + initialTransformRef.current.width / 2) * zoom;+ const layerCenterY = artboardY + (initialTransformRef.current.y + initialTransformRef.current.height / 2) * zoom;++ const rect = canvas.getBoundingClientRect();+ const startDx = dragStartX - rect.left - layerCenterX;+ const startDy = dragStartY - rect.top - layerCenterY;+ const currentDx = e.clientX - rect.left - layerCenterX;+ const currentDy = e.clientY - rect.top - layerCenterY;++ const startAngle = Math.atan2(startDy, startDx);+ const currentAngle = Math.atan2(currentDy, currentDx);+ let deltaAngle = (currentAngle - startAngle) * (180 / Math.PI);++ let newRotation = initialTransformRef.current.rotation + deltaAngle;++ if (e.shiftKey) {+ newRotation = Math.round(newRotation / 15) * 15;+ }++ while (newRotation > 360) newRotation -= 360;+ while (newRotation < 0) newRotation += 360;++ updateLayerTransform(layerId, { rotation: newRotation });+ }+ } else if (dragMode === 'resize' && selectedLayerIds.length === 1 && activeResizeHandle && initialTransformRef.current) {+ const layerId = selectedLayerIds[0];+ const layer = project?.layers[layerId];+ if (layer) {+ const dx = (e.clientX - dragStartX) / zoom;+ const dy = (e.clientY - dragStartY) / zoom;++ const init = initialTransformRef.current;+ let newX = init.x;+ let newY = init.y;+ let newWidth = init.width;+ let newHeight = init.height;++ const maintainAspect = e.shiftKey;+ const aspectRatio = init.width / init.height;++ switch (activeResizeHandle) {+ case 'nw':+ newX = init.x + dx;+ newY = init.y + dy;+ newWidth = init.width - dx;+ newHeight = init.height - dy;+ if (maintainAspect) {+ const delta = Math.max(-dx, -dy);+ newWidth = init.width + delta;+ newHeight = newWidth / aspectRatio;+ newX = init.x + init.width - newWidth;+ newY = init.y + init.height - newHeight;+ }+ break;+ case 'n':+ newY = init.y + dy;+ newHeight = init.height - dy;+ if (maintainAspect) {+ newWidth = newHeight * aspectRatio;+ newX = init.x + (init.width - newWidth) / 2;+ }+ break;+ case 'ne':+ newY = init.y + dy;+ newWidth = init.width + dx;+ newHeight = init.height - dy;+ if (maintainAspect) {+ const delta = Math.max(dx, -dy);+ newWidth = init.width + delta;+ newHeight = newWidth / aspectRatio;+ newY = init.y + init.height - newHeight;+ }+ break;+ case 'e':+ newWidth = init.width + dx;+ if (maintainAspect) {+ newHeight = newWidth / aspectRatio;+ newY = init.y + (init.height - newHeight) / 2;+ }+ break;+ case 'se':+ newWidth = init.width + dx;+ newHeight = init.height + dy;+ if (maintainAspect) {+ const delta = Math.max(dx, dy);+ newWidth = init.width + delta;+ newHeight = newWidth / aspectRatio;+ }+ break;+ case 's':+ newHeight = init.height + dy;+ if (maintainAspect) {+ newWidth = newHeight * aspectRatio;+ newX = init.x + (init.width - newWidth) / 2;+ }+ break;+ case 'sw':+ newX = init.x + dx;+ newWidth = init.width - dx;+ newHeight = init.height + dy;+ if (maintainAspect) {+ const delta = Math.max(-dx, dy);+ newWidth = init.width + delta;+ newHeight = newWidth / aspectRatio;+ newX = init.x + init.width - newWidth;+ }+ break;+ case 'w':+ newX = init.x + dx;+ newWidth = init.width - dx;+ if (maintainAspect) {+ newHeight = newWidth / aspectRatio;+ newY = init.y + (init.height - newHeight) / 2;+ }+ break;+ }++ const minSize = 10;+ if (newWidth < minSize) {+ if (activeResizeHandle.includes('w')) {+ newX = init.x + init.width - minSize;+ }+ newWidth = minSize;+ }+ if (newHeight < minSize) {+ if (activeResizeHandle.includes('n')) {+ newY = init.y + init.height - minSize;+ }+ newHeight = minSize;+ }++ updateLayerTransform(layerId, {+ x: newX,+ y: newY,+ width: newWidth,+ height: newHeight,+ });+ }} else if (dragMode === 'move' && selectedLayerIds.length > 0 && artboard) {const dx = (e.clientX - dragCurrentX) / zoom;const dy = (e.clientY - dragCurrentY) / zoom;@@ -443,7 +794,7 @@ export function Canvas() {}}},- [isDragging, dragMode, dragCurrentX, dragCurrentY, panX, panY, setPan, zoom, selectedLayerIds, project, updateLayerTransform, updateDrag, artboard, guides, snapToObjects, snapToGuides, snapToGrid, gridSize, setSmartGuides, drawing.isDrawing, screenToCanvas, addDrawingPoint, render, updateMarqueeSelect]+ [isDragging, dragMode, dragCurrentX, dragCurrentY, dragStartX, dragStartY, panX, panY, setPan, zoom, selectedLayerIds, project, updateLayerTransform, updateDrag, artboard, guides, snapToObjects, snapToGuides, snapToGrid, gridSize, setSmartGuides, drawing.isDrawing, screenToCanvas, addDrawingPoint, render, updateMarqueeSelect, activeResizeHandle, activeTool, getHandleAtPoint]);const findLayersInRect = useCallback(@@ -500,9 +851,180 @@ export function Canvas() {return;}+ initialTransformRef.current = null;+ setActiveResizeHandle(null);endDrag();clearSmartGuides();- }, [endDrag, clearSmartGuides, drawing.isDrawing, finishDrawing, addPathLayer, penSettings, render, dragMode, endMarqueeSelect, findLayersInRect, selectLayers]);+ }, [endDrag, clearSmartGuides, drawing.isDrawing, finishDrawing, addPathLayer, penSettings, render, dragMode, endMarqueeSelect, findLayersInRect, selectLayers, setActiveResizeHandle]);++ const handleContextMenu = useCallback(+ (e: React.MouseEvent) => {+ e.preventDefault();+ const { x, y } = screenToCanvas(e.clientX, e.clientY);+ const layerId = findLayerAtPoint(x, y);++ let menuType: ContextMenuType = 'canvas';++ if (layerId) {+ if (!selectedLayerIds.includes(layerId)) {+ selectLayer(layerId);+ }++ if (selectedLayerIds.length > 1 || (selectedLayerIds.length === 1 && selectedLayerIds[0] !== layerId)) {+ const count = selectedLayerIds.includes(layerId) ? selectedLayerIds.length : 1;+ if (count > 1) {+ menuType = 'multi-layer';+ } else {+ const layer = project?.layers[layerId];+ menuType = layer?.type === 'group' ? 'group' : 'layer';+ }+ } else {+ const layer = project?.layers[layerId];+ menuType = layer?.type === 'group' ? 'group' : 'layer';+ }+ } else if (selectedLayerIds.length > 1) {+ menuType = 'multi-layer';+ } else if (selectedLayerIds.length === 1) {+ const layer = project?.layers[selectedLayerIds[0]];+ menuType = layer?.type === 'group' ? 'group' : 'layer';+ }++ setContextMenu({+ position: { x: e.clientX, y: e.clientY },+ type: menuType,+ });+ },+ [screenToCanvas, findLayerAtPoint, selectedLayerIds, selectLayer, project]+ );++ const closeContextMenu = useCallback(() => {+ setContextMenu(null);+ }, []);++ const handleFlipHorizontal = useCallback(() => {+ selectedLayerIds.forEach((id) => {+ const layer = project?.layers[id];+ if (layer) {+ updateLayer(id, { flipHorizontal: !layer.flipHorizontal });+ }+ });+ }, [selectedLayerIds, project, updateLayer]);++ const handleFlipVertical = useCallback(() => {+ selectedLayerIds.forEach((id) => {+ const layer = project?.layers[id];+ if (layer) {+ updateLayer(id, { flipVertical: !layer.flipVertical });+ }+ });+ }, [selectedLayerIds, project, updateLayer]);++ const handleResetTransform = useCallback(() => {+ selectedLayerIds.forEach((id) => {+ updateLayerTransform(id, {+ rotation: 0,+ scaleX: 1,+ scaleY: 1,+ skewX: 0,+ skewY: 0,+ });+ updateLayer(id, { flipHorizontal: false, flipVertical: false });+ });+ }, [selectedLayerIds, updateLayerTransform, updateLayer]);++ const handleToggleVisibility = useCallback(() => {+ selectedLayerIds.forEach((id) => {+ const layer = project?.layers[id];+ if (layer) {+ updateLayer(id, { visible: !layer.visible });+ }+ });+ }, [selectedLayerIds, project, updateLayer]);++ const handleToggleLock = useCallback(() => {+ selectedLayerIds.forEach((id) => {+ const layer = project?.layers[id];+ if (layer) {+ updateLayer(id, { locked: !layer.locked });+ }+ });+ }, [selectedLayerIds, project, updateLayer]);++ const handleSelectAll = useCallback(() => {+ if (artboard) {+ selectLayers(artboard.layerIds);+ }+ }, [artboard, selectLayers]);++ const handleZoomFit = useCallback(() => {+ if (artboard && containerRef.current) {+ const containerWidth = containerRef.current.clientWidth;+ const containerHeight = containerRef.current.clientHeight;+ const scaleX = (containerWidth - 100) / artboard.size.width;+ const scaleY = (containerHeight - 100) / artboard.size.height;+ const newZoom = Math.min(scaleX, scaleY, 1);+ setZoom(newZoom);+ setPan(0, 0);+ }+ }, [artboard, setZoom, setPan]);++ const handleAlignLeft = useCallback(() => {+ if (selectedLayerIds.length < 2 || !project) return;+ const layers = selectedLayerIds.map((id) => project.layers[id]).filter(Boolean);+ const minX = Math.min(...layers.map((l) => l.transform.x));+ layers.forEach((layer) => {+ updateLayerTransform(layer.id, { x: minX });+ });+ }, [selectedLayerIds, project, updateLayerTransform]);++ const handleAlignCenter = useCallback(() => {+ if (selectedLayerIds.length < 2 || !project) return;+ const layers = selectedLayerIds.map((id) => project.layers[id]).filter(Boolean);+ const centers = layers.map((l) => l.transform.x + l.transform.width / 2);+ const avgCenter = centers.reduce((a, b) => a + b, 0) / centers.length;+ layers.forEach((layer) => {+ updateLayerTransform(layer.id, { x: avgCenter - layer.transform.width / 2 });+ });+ }, [selectedLayerIds, project, updateLayerTransform]);++ const handleAlignRight = useCallback(() => {+ if (selectedLayerIds.length < 2 || !project) return;+ const layers = selectedLayerIds.map((id) => project.layers[id]).filter(Boolean);+ const maxRight = Math.max(...layers.map((l) => l.transform.x + l.transform.width));+ layers.forEach((layer) => {+ updateLayerTransform(layer.id, { x: maxRight - layer.transform.width });+ });+ }, [selectedLayerIds, project, updateLayerTransform]);++ const handleAlignTop = useCallback(() => {+ if (selectedLayerIds.length < 2 || !project) return;+ const layers = selectedLayerIds.map((id) => project.layers[id]).filter(Boolean);+ const minY = Math.min(...layers.map((l) => l.transform.y));+ layers.forEach((layer) => {+ updateLayerTransform(layer.id, { y: minY });+ });+ }, [selectedLayerIds, project, updateLayerTransform]);++ const handleAlignMiddle = useCallback(() => {+ if (selectedLayerIds.length < 2 || !project) return;+ const layers = selectedLayerIds.map((id) => project.layers[id]).filter(Boolean);+ const middles = layers.map((l) => l.transform.y + l.transform.height / 2);+ const avgMiddle = middles.reduce((a, b) => a + b, 0) / middles.length;+ layers.forEach((layer) => {+ updateLayerTransform(layer.id, { y: avgMiddle - layer.transform.height / 2 });+ });+ }, [selectedLayerIds, project, updateLayerTransform]);++ const handleAlignBottom = useCallback(() => {+ if (selectedLayerIds.length < 2 || !project) return;+ const layers = selectedLayerIds.map((id) => project.layers[id]).filter(Boolean);+ const maxBottom = Math.max(...layers.map((l) => l.transform.y + l.transform.height));+ layers.forEach((layer) => {+ updateLayerTransform(layer.id, { y: maxBottom - layer.transform.height });+ });+ }, [selectedLayerIds, project, updateLayerTransform]);++ const selectedLayer = selectedLayerIds.length === 1 ? project?.layers[selectedLayerIds[0]] : null;const handleWheel = useCallback((e: React.WheelEvent) => {@@ -517,13 +1039,17 @@ export function Canvas() {[zoom, panX, panY, setPan]);+ const effectiveCursor = activeTool === 'hand'+ ? 'grab'+ : activeTool === 'select'+ ? (cursorStyle !== 'default' ? cursorStyle : 'default')+ : 'crosshair';+return (<divref={containerRef}- className="flex-1 overflow-hidden cursor-crosshair relative"- style={{- cursor: activeTool === 'hand' ? 'grab' : activeTool === 'select' ? 'default' : 'crosshair',- }}+ className="flex-1 overflow-hidden relative"+ style={{ cursor: effectiveCursor }}>{showRulers && (<Rulers@@ -538,6 +1064,7 @@ export function Canvas() {onMouseUp={handleMouseUp}onMouseLeave={handleMouseUp}onWheel={handleWheel}+ onContextMenu={handleContextMenu}className="absolute"style={{top: showRulers ? RULER_SIZE : 0,@@ -546,6 +1073,53 @@ export function Canvas() {height: showRulers ? `calc(100% - ${RULER_SIZE}px)` : '100%',}}/>++ {contextMenu && (+ <ContextMenu+ position={contextMenu.position}+ type={contextMenu.type}+ onClose={closeContextMenu}+ onCut={cutLayers}+ onCopy={copyLayers}+ onPaste={pasteLayers}+ onDuplicate={() => selectedLayerIds.forEach((id) => duplicateLayer(id))}+ onDelete={() => selectedLayerIds.forEach((id) => removeLayer(id))}+ onSelectAll={handleSelectAll}+ onToggleVisibility={handleToggleVisibility}+ onToggleLock={handleToggleLock}+ onBringToFront={() => selectedLayerIds.forEach((id) => moveLayerToTop(id))}+ onBringForward={() => selectedLayerIds.forEach((id) => moveLayerUp(id))}+ onSendBackward={() => selectedLayerIds.forEach((id) => moveLayerDown(id))}+ onSendToBack={() => selectedLayerIds.forEach((id) => moveLayerToBottom(id))}+ onGroup={() => groupLayers(selectedLayerIds)}+ onUngroup={() => selectedLayerIds.length === 1 && ungroupLayers(selectedLayerIds[0])}+ onFlipHorizontal={handleFlipHorizontal}+ onFlipVertical={handleFlipVertical}+ onResetTransform={handleResetTransform}+ onCopyStyle={copyLayerStyle}+ onPasteStyle={pasteLayerStyle}+ onAddText={() => addTextLayer('New Text')}+ onAddShape={addShapeLayer}+ onToggleGrid={toggleGrid}+ onToggleRulers={toggleRulers}+ onZoomIn={() => setZoom(zoom * 1.2)}+ onZoomOut={() => setZoom(zoom / 1.2)}+ onZoomFit={handleZoomFit}+ onAlignLeft={handleAlignLeft}+ onAlignCenter={handleAlignCenter}+ onAlignRight={handleAlignRight}+ onAlignTop={handleAlignTop}+ onAlignMiddle={handleAlignMiddle}+ onAlignBottom={handleAlignBottom}+ isVisible={selectedLayer?.visible ?? true}+ isLocked={selectedLayer?.locked ?? false}+ showGrid={showGrid}+ showRulers={showRulers}+ hasClipboard={copiedLayers.length > 0}+ hasStyleClipboard={copiedStyle !== null}+ selectedCount={selectedLayerIds.length}+ />+ )}</div>);}@@ -565,10 +1139,41 @@ const BLEND_MODE_MAP: Record<string, GlobalCompositeOperation> = {'exclusion': 'exclusion',};+function renderLayerWithChildren(+ ctx: CanvasRenderingContext2D,+ layer: Layer,+ project: { layers: Record<string, Layer>; assets: Record<string, { dataUrl?: string; blobUrl?: string }> }+) {+ if (layer.type === 'group') {+ const group = layer as GroupLayer;+ if (!group.visible) return;++ const { transform } = group;+ ctx.save();++ ctx.translate(transform.x, transform.y);+ ctx.rotate((transform.rotation * Math.PI) / 180);+ ctx.scale(transform.scaleX, transform.scaleY);+ ctx.globalAlpha *= transform.opacity;++ const sortedChildIds = [...group.childIds].reverse();+ sortedChildIds.forEach((childId) => {+ const child = project.layers[childId];+ if (child && child.visible) {+ renderLayer(ctx, child, project);+ }+ });++ ctx.restore();+ } else {+ renderLayer(ctx, layer, project);+ }+}+function renderLayer(ctx: CanvasRenderingContext2D,layer: Layer,- project: { assets: Record<string, { dataUrl?: string; blobUrl?: string }> }+ project: { layers?: Record<string, Layer>; assets: Record<string, { dataUrl?: string; blobUrl?: string }> }) {const { transform } = layer;const shadow = layer.shadow ?? { enabled: false, color: 'rgba(0, 0, 0, 0.5)', blur: 10, offsetX: 0, offsetY: 4 };@@ -746,6 +1351,20 @@ function renderImageLayer(return;}+ const src = asset.dataUrl ?? asset.blobUrl ?? '';+ const img = getCachedImage(src);++ if (!img) {+ ctx.fillStyle = '#27272a';+ ctx.fillRect(0, 0, layer.transform.width, layer.transform.height);+ ctx.fillStyle = '#71717a';+ ctx.font = '12px sans-serif';+ ctx.textAlign = 'center';+ ctx.textBaseline = 'middle';+ ctx.fillText('Loading...', layer.transform.width / 2, layer.transform.height / 2);+ return;+ }+const flipH = layer.flipHorizontal ?? false;const flipV = layer.flipVertical ?? false;@@ -758,21 +1377,46 @@ function renderImageLayer(ctx.scale(flipH ? -1 : 1, flipV ? -1 : 1);}- const img = new window.Image();- img.src = asset.dataUrl ?? asset.blobUrl ?? '';- if (img.complete) {+ {const { filters } = layer;const filterParts: string[] = [];- if (filters.brightness !== 100) {- filterParts.push(`brightness(${filters.brightness}%)`);+ let effectiveBrightness = filters.brightness;+ if (filters.exposure !== 0) {+ effectiveBrightness = effectiveBrightness * (1 + filters.exposure / 100);}- if (filters.contrast !== 100) {- filterParts.push(`contrast(${filters.contrast}%)`);+ if (filters.highlights > 0) {+ effectiveBrightness = effectiveBrightness * (1 + filters.highlights / 200);}- if (filters.saturation !== 100) {- filterParts.push(`saturate(${filters.saturation}%)`);+ if (filters.shadows > 0) {+ effectiveBrightness = effectiveBrightness * (1 + filters.shadows / 300);}+ if (effectiveBrightness !== 100) {+ filterParts.push(`brightness(${Math.round(effectiveBrightness)}%)`);+ }++ let effectiveContrast = filters.contrast;+ if (filters.clarity !== 0) {+ effectiveContrast = effectiveContrast * (1 + filters.clarity / 150);+ }+ if (filters.highlights < 0) {+ effectiveContrast = effectiveContrast * (1 + filters.highlights / 400);+ }+ if (filters.shadows < 0) {+ effectiveContrast = effectiveContrast * (1 + filters.shadows / 400);+ }+ if (effectiveContrast !== 100) {+ filterParts.push(`contrast(${Math.round(effectiveContrast)}%)`);+ }++ let effectiveSaturation = filters.saturation;+ if (filters.vibrance !== 0) {+ effectiveSaturation = effectiveSaturation * (1 + filters.vibrance / 150);+ }+ if (effectiveSaturation !== 100) {+ filterParts.push(`saturate(${Math.round(effectiveSaturation)}%)`);+ }+if (filters.hue !== 0) {filterParts.push(`hue-rotate(${filters.hue}deg)`);}diff --git a/apps/image/src/components/editor/canvas/ContextMenu.tsx b/apps/image/src/components/editor/canvas/ContextMenu.tsxnew file mode 100644index 00000000..ee4df9d7--- /dev/null+++ b/apps/image/src/components/editor/canvas/ContextMenu.tsx@@ -0,0 +1,363 @@+import { useEffect, useRef } from 'react';+import {+ Copy,+ Clipboard,+ Scissors,+ Trash2,+ Eye,+ EyeOff,+ Lock,+ Unlock,+ ArrowUpToLine,+ ArrowDownToLine,+ ChevronUp,+ ChevronDown,+ FlipHorizontal,+ FlipVertical,+ RotateCcw,+ FolderPlus,+ FolderOpen,+ Type,+ Square,+ Circle,+ Triangle,+ Star,+ Hexagon,+ Minus,+ Grid3X3,+ Ruler,+ ZoomIn,+ ZoomOut,+ Maximize,+ AlignLeft,+ AlignCenter,+ AlignRight,+ AlignStartVertical,+ AlignCenterVertical,+ AlignEndVertical,+ Paintbrush,+ MousePointer,+} from 'lucide-react';++export interface ContextMenuPosition {+ x: number;+ y: number;+}++export type ContextMenuType = 'layer' | 'multi-layer' | 'canvas' | 'group';++interface MenuItem {+ label: string;+ icon?: React.ReactNode;+ shortcut?: string;+ action: () => void;+ disabled?: boolean;+ divider?: boolean;+ submenu?: MenuItem[];+}++interface ContextMenuProps {+ position: ContextMenuPosition;+ type: ContextMenuType;+ onClose: () => void;+ onCut: () => void;+ onCopy: () => void;+ onPaste: () => void;+ onDuplicate: () => void;+ onDelete: () => void;+ onSelectAll: () => void;+ onToggleVisibility: () => void;+ onToggleLock: () => void;+ onBringToFront: () => void;+ onBringForward: () => void;+ onSendBackward: () => void;+ onSendToBack: () => void;+ onGroup: () => void;+ onUngroup: () => void;+ onFlipHorizontal: () => void;+ onFlipVertical: () => void;+ onResetTransform: () => void;+ onCopyStyle: () => void;+ onPasteStyle: () => void;+ onAddText: () => void;+ onAddShape: (type: 'rectangle' | 'ellipse' | 'triangle' | 'star' | 'polygon' | 'line') => void;+ onToggleGrid: () => void;+ onToggleRulers: () => void;+ onZoomIn: () => void;+ onZoomOut: () => void;+ onZoomFit: () => void;+ onAlignLeft: () => void;+ onAlignCenter: () => void;+ onAlignRight: () => void;+ onAlignTop: () => void;+ onAlignMiddle: () => void;+ onAlignBottom: () => void;+ isVisible: boolean;+ isLocked: boolean;+ showGrid: boolean;+ showRulers: boolean;+ hasClipboard: boolean;+ hasStyleClipboard: boolean;+ selectedCount: number;+}++export function ContextMenu({+ position,+ type,+ onClose,+ onCut,+ onCopy,+ onPaste,+ onDuplicate,+ onDelete,+ onSelectAll,+ onToggleVisibility,+ onToggleLock,+ onBringToFront,+ onBringForward,+ onSendBackward,+ onSendToBack,+ onGroup,+ onUngroup,+ onFlipHorizontal,+ onFlipVertical,+ onResetTransform,+ onCopyStyle,+ onPasteStyle,+ onAddText,+ onAddShape,+ onToggleGrid,+ onToggleRulers,+ onZoomIn,+ onZoomOut,+ onZoomFit,+ onAlignLeft,+ onAlignCenter,+ onAlignRight,+ onAlignTop,+ onAlignMiddle,+ onAlignBottom,+ isVisible,+ isLocked,+ showGrid,+ showRulers,+ hasClipboard,+ hasStyleClipboard,+ selectedCount,+}: ContextMenuProps) {+ const menuRef = useRef<HTMLDivElement>(null);++ useEffect(() => {+ const handleClickOutside = (e: MouseEvent) => {+ if (menuRef.current && !menuRef.current.contains(e.target as Node)) {+ onClose();+ }+ };++ const handleEscape = (e: KeyboardEvent) => {+ if (e.key === 'Escape') {+ onClose();+ }+ };++ document.addEventListener('mousedown', handleClickOutside);+ document.addEventListener('keydown', handleEscape);+ return () => {+ document.removeEventListener('mousedown', handleClickOutside);+ document.removeEventListener('keydown', handleEscape);+ };+ }, [onClose]);++ useEffect(() => {+ if (menuRef.current) {+ const rect = menuRef.current.getBoundingClientRect();+ const viewportWidth = window.innerWidth;+ const viewportHeight = window.innerHeight;++ let adjustedX = position.x;+ let adjustedY = position.y;++ if (position.x + rect.width > viewportWidth) {+ adjustedX = viewportWidth - rect.width - 8;+ }+ if (position.y + rect.height > viewportHeight) {+ adjustedY = viewportHeight - rect.height - 8;+ }++ menuRef.current.style.left = `${adjustedX}px`;+ menuRef.current.style.top = `${adjustedY}px`;+ }+ }, [position]);++ const getMenuItems = (): MenuItem[] => {+ if (type === 'canvas') {+ return [+ { label: 'Paste', icon: <Clipboard size={14} />, shortcut: '⌘V', action: onPaste, disabled: !hasClipboard },+ { label: 'Paste Style', icon: <Paintbrush size={14} />, shortcut: '⌘⇧V', action: onPasteStyle, disabled: !hasStyleClipboard },+ { label: '', action: () => {}, divider: true },+ { label: 'Select All', icon: <MousePointer size={14} />, shortcut: '⌘A', action: onSelectAll },+ { label: '', action: () => {}, divider: true },+ { label: 'Add Text', icon: <Type size={14} />, shortcut: 'T', action: onAddText },+ {+ label: 'Add Shape',+ icon: <Square size={14} />,+ action: () => {},+ submenu: [+ { label: 'Rectangle', icon: <Square size={14} />, action: () => onAddShape('rectangle') },+ { label: 'Ellipse', icon: <Circle size={14} />, action: () => onAddShape('ellipse') },+ { label: 'Triangle', icon: <Triangle size={14} />, action: () => onAddShape('triangle') },+ { label: 'Star', icon: <Star size={14} />, action: () => onAddShape('star') },+ { label: 'Polygon', icon: <Hexagon size={14} />, action: () => onAddShape('polygon') },+ { label: 'Line', icon: <Minus size={14} />, action: () => onAddShape('line') },+ ],+ },+ { label: '', action: () => {}, divider: true },+ { label: showGrid ? 'Hide Grid' : 'Show Grid', icon: <Grid3X3 size={14} />, shortcut: "⌘'", action: onToggleGrid },+ { label: showRulers ? 'Hide Rulers' : 'Show Rulers', icon: <Ruler size={14} />, shortcut: '⌘R', action: onToggleRulers },+ { label: '', action: () => {}, divider: true },+ { label: 'Zoom In', icon: <ZoomIn size={14} />, shortcut: '⌘+', action: onZoomIn },+ { label: 'Zoom Out', icon: <ZoomOut size={14} />, shortcut: '⌘-', action: onZoomOut },+ { label: 'Zoom to Fit', icon: <Maximize size={14} />, shortcut: '⌘0', action: onZoomFit },+ ];+ }++ if (type === 'multi-layer') {+ return [+ { label: 'Cut', icon: <Scissors size={14} />, shortcut: '⌘X', action: onCut },+ { label: 'Copy', icon: <Copy size={14} />, shortcut: '⌘C', action: onCopy },+ { label: 'Paste', icon: <Clipboard size={14} />, shortcut: '⌘V', action: onPaste, disabled: !hasClipboard },+ { label: 'Duplicate', icon: <Copy size={14} />, shortcut: '⌘D', action: onDuplicate },+ { label: 'Delete', icon: <Trash2 size={14} />, shortcut: '⌫', action: onDelete },+ { label: '', action: () => {}, divider: true },+ { label: `Group ${selectedCount} Layers`, icon: <FolderPlus size={14} />, shortcut: '⌘G', action: onGroup },+ { label: '', action: () => {}, divider: true },+ {+ label: 'Align',+ icon: <AlignLeft size={14} />,+ action: () => {},+ submenu: [+ { label: 'Align Left', icon: <AlignLeft size={14} />, action: onAlignLeft },+ { label: 'Align Center', icon: <AlignCenter size={14} />, action: onAlignCenter },+ { label: 'Align Right', icon: <AlignRight size={14} />, action: onAlignRight },+ { label: '', action: () => {}, divider: true },+ { label: 'Align Top', icon: <AlignStartVertical size={14} />, action: onAlignTop },+ { label: 'Align Middle', icon: <AlignCenterVertical size={14} />, action: onAlignMiddle },+ { label: 'Align Bottom', icon: <AlignEndVertical size={14} />, action: onAlignBottom },+ ],+ },+ { label: '', action: () => {}, divider: true },+ { label: 'Bring to Front', icon: <ArrowUpToLine size={14} />, shortcut: '⌘⇧]', action: onBringToFront },+ { label: 'Send to Back', icon: <ArrowDownToLine size={14} />, shortcut: '⌘⇧[', action: onSendToBack },+ ];+ }++ if (type === 'group') {+ return [+ { label: 'Cut', icon: <Scissors size={14} />, shortcut: '⌘X', action: onCut },+ { label: 'Copy', icon: <Copy size={14} />, shortcut: '⌘C', action: onCopy },+ { label: 'Paste', icon: <Clipboard size={14} />, shortcut: '⌘V', action: onPaste, disabled: !hasClipboard },+ { label: 'Duplicate', icon: <Copy size={14} />, shortcut: '⌘D', action: onDuplicate },+ { label: 'Delete', icon: <Trash2 size={14} />, shortcut: '⌫', action: onDelete },+ { label: '', action: () => {}, divider: true },+ { label: 'Ungroup', icon: <FolderOpen size={14} />, shortcut: '⌘⇧G', action: onUngroup },+ { label: '', action: () => {}, divider: true },+ { label: isVisible ? 'Hide' : 'Show', icon: isVisible ? <EyeOff size={14} /> : <Eye size={14} />, shortcut: '⌘⇧H', action: onToggleVisibility },+ { label: isLocked ? 'Unlock' : 'Lock', icon: isLocked ? <Unlock size={14} /> : <Lock size={14} />, shortcut: '⌘⇧L', action: onToggleLock },+ { label: '', action: () => {}, divider: true },+ { label: 'Bring to Front', icon: <ArrowUpToLine size={14} />, shortcut: '⌘⇧]', action: onBringToFront },+ { label: 'Bring Forward', icon: <ChevronUp size={14} />, shortcut: '⌘]', action: onBringForward },+ { label: 'Send Backward', icon: <ChevronDown size={14} />, shortcut: '⌘[', action: onSendBackward },+ { label: 'Send to Back', icon: <ArrowDownToLine size={14} />, shortcut: '⌘⇧[', action: onSendToBack },+ { label: '', action: () => {}, divider: true },+ { label: 'Flip Horizontal', icon: <FlipHorizontal size={14} />, action: onFlipHorizontal },+ { label: 'Flip Vertical', icon: <FlipVertical size={14} />, action: onFlipVertical },+ { label: 'Reset Transform', icon: <RotateCcw size={14} />, action: onResetTransform },+ ];+ }++ return [+ { label: 'Cut', icon: <Scissors size={14} />, shortcut: '⌘X', action: onCut },+ { label: 'Copy', icon: <Copy size={14} />, shortcut: '⌘C', action: onCopy },+ { label: 'Paste', icon: <Clipboard size={14} />, shortcut: '⌘V', action: onPaste, disabled: !hasClipboard },+ { label: 'Duplicate', icon: <Copy size={14} />, shortcut: '⌘D', action: onDuplicate },+ { label: 'Delete', icon: <Trash2 size={14} />, shortcut: '⌫', action: onDelete },+ { label: '', action: () => {}, divider: true },+ { label: 'Copy Style', icon: <Paintbrush size={14} />, shortcut: '⌘⌥C', action: onCopyStyle },+ { label: 'Paste Style', icon: <Paintbrush size={14} />, shortcut: '⌘⌥V', action: onPasteStyle, disabled: !hasStyleClipboard },+ { label: '', action: () => {}, divider: true },+ { label: isVisible ? 'Hide' : 'Show', icon: isVisible ? <EyeOff size={14} /> : <Eye size={14} />, shortcut: '⌘⇧H', action: onToggleVisibility },+ { label: isLocked ? 'Unlock' : 'Lock', icon: isLocked ? <Unlock size={14} /> : <Lock size={14} />, shortcut: '⌘⇧L', action: onToggleLock },+ { label: '', action: () => {}, divider: true },+ { label: 'Bring to Front', icon: <ArrowUpToLine size={14} />, shortcut: '⌘⇧]', action: onBringToFront },+ { label: 'Bring Forward', icon: <ChevronUp size={14} />, shortcut: '⌘]', action: onBringForward },+ { label: 'Send Backward', icon: <ChevronDown size={14} />, shortcut: '⌘[', action: onSendBackward },+ { label: 'Send to Back', icon: <ArrowDownToLine size={14} />, shortcut: '⌘⇧[', action: onSendToBack },+ { label: '', action: () => {}, divider: true },+ { label: 'Flip Horizontal', icon: <FlipHorizontal size={14} />, action: onFlipHorizontal },+ { label: 'Flip Vertical', icon: <FlipVertical size={14} />, action: onFlipVertical },+ { label: 'Reset Transform', icon: <RotateCcw size={14} />, action: onResetTransform },+ ];+ };++ const renderMenuItem = (item: MenuItem, index: number) => {+ if (item.divider) {+ return <div key={index} className="h-px bg-border my-1" />;+ }++ if (item.submenu) {+ return (+ <div key={index} className="relative group/submenu">+ <button+ className="w-full flex items-center gap-2 px-3 py-1.5 text-xs text-foreground hover:bg-accent rounded-sm transition-colors"+ >+ {item.icon && <span className="text-muted-foreground">{item.icon}</span>}+ <span className="flex-1 text-left">{item.label}</span>+ <ChevronUp size={12} className="text-muted-foreground rotate-90" />+ </button>+ <div className="absolute left-full top-0 ml-1 hidden group-hover/submenu:block">+ <div className="bg-popover border border-border rounded-lg shadow-lg py-1 min-w-[160px]">+ {item.submenu.map((subItem, subIndex) => renderMenuItem(subItem, subIndex))}+ </div>+ </div>+ </div>+ );+ }++ return (+ <button+ key={index}+ onClick={() => {+ if (!item.disabled) {+ item.action();+ onClose();+ }+ }}+ disabled={item.disabled}+ className={`w-full flex items-center gap-2 px-3 py-1.5 text-xs rounded-sm transition-colors ${+ item.disabled+ ? 'text-muted-foreground/50 cursor-not-allowed'+ : 'text-foreground hover:bg-accent'+ }`}+ >+ {item.icon && <span className={item.disabled ? 'text-muted-foreground/50' : 'text-muted-foreground'}>{item.icon}</span>}+ <span className="flex-1 text-left">{item.label}</span>+ {item.shortcut && (+ <span className="text-[10px] text-muted-foreground font-mono">{item.shortcut}</span>+ )}+ </button>+ );+ };++ const menuItems = getMenuItems();++ return (+ <div+ ref={menuRef}+ className="fixed z-50 bg-popover border border-border rounded-lg shadow-xl py-1 min-w-[200px] animate-in fade-in-0 zoom-in-95 duration-100"+ style={{ left: position.x, top: position.y }}+ onContextMenu={(e) => e.preventDefault()}+ >+ {menuItems.map((item, index) => renderMenuItem(item, index))}+ </div>+ );+}diff --git a/apps/image/src/components/editor/inspector/BackgroundRemovalSection.tsx b/apps/image/src/components/editor/inspector/BackgroundRemovalSection.tsxindex 0284efa1..28daff20 100644--- a/apps/image/src/components/editor/inspector/BackgroundRemovalSection.tsx+++ b/apps/image/src/components/editor/inspector/BackgroundRemovalSection.tsx@@ -18,8 +18,6 @@ export function BackgroundRemovalSection({ layer }: Props) {const [isProcessing, setIsProcessing] = useState(false);const [progress, setProgress] = useState(0);const [mode, setMode] = useState<BackgroundMode>('transparent');- const [threshold, setThreshold] = useState(DEFAULT_OPTIONS.threshold);- const [edgeBlur, setEdgeBlur] = useState(DEFAULT_OPTIONS.edgeBlur);const [backgroundColor, setBackgroundColor] = useState(DEFAULT_OPTIONS.backgroundColor!);const [blurAmount, setBlurAmount] = useState(DEFAULT_OPTIONS.blurAmount!);@@ -39,8 +37,6 @@ export function BackgroundRemovalSection({ layer }: Props) {imageUrl,{mode,- threshold,- edgeBlur,backgroundColor,blurAmount,},@@ -129,34 +125,6 @@ export function BackgroundRemovalSection({ layer }: Props) {</div>)}- <div>- <div className="flex items-center justify-between mb-1.5">- <label className="text-[10px] text-muted-foreground">Sensitivity</label>- <span className="text-[10px] text-muted-foreground">{Math.round(threshold * 100)}%</span>- </div>- <Slider- value={[threshold * 100]}- onValueChange={([v]) => setThreshold(v / 100)}- min={10}- max={90}- step={5}- />- </div>-- <div>- <div className="flex items-center justify-between mb-1.5">- <label className="text-[10px] text-muted-foreground">Edge Smoothing</label>- <span className="text-[10px] text-muted-foreground">{edgeBlur}px</span>- </div>- <Slider- value={[edgeBlur]}- onValueChange={([v]) => setEdgeBlur(v)}- min={0}- max={10}- step={1}- />- </div>-{isProcessing && (<div className="space-y-1.5"><div className="h-1.5 bg-muted rounded-full overflow-hidden">@@ -166,7 +134,10 @@ export function BackgroundRemovalSection({ layer }: Props) {/></div><p className="text-[10px] text-muted-foreground text-center">- Processing... {Math.round(progress)}%+ {progress < 15 ? 'Loading AI model...' :+ progress < 90 ? 'Analyzing image...' :+ 'Finalizing...'}+ {' '}{Math.round(progress)}%</p></div>)}@@ -190,7 +161,7 @@ export function BackgroundRemovalSection({ layer }: Props) {</button><p className="text-[9px] text-muted-foreground text-center">- Works best with solid color backgrounds+ AI-powered background removal for any image</p></div></div>diff --git a/apps/image/src/components/editor/inspector/FilterPresetsSection.tsx b/apps/image/src/components/editor/inspector/FilterPresetsSection.tsxindex 211f991f..20818344 100644--- a/apps/image/src/components/editor/inspector/FilterPresetsSection.tsx+++ b/apps/image/src/components/editor/inspector/FilterPresetsSection.tsx@@ -20,97 +20,97 @@ const FILTER_PRESETS: FilterPreset[] = [id: 'original',name: 'Original',category: 'basic',- filters: { brightness: 100, contrast: 100, saturation: 100, hue: 0, blur: 0, blurType: 'gaussian', blurAngle: 0, sharpen: 0, vignette: 0, grain: 0, sepia: 0, invert: 0 },+ filters: { brightness: 100, contrast: 100, saturation: 100, hue: 0, exposure: 0, vibrance: 0, highlights: 0, shadows: 0, clarity: 0, blur: 0, blurType: 'gaussian', blurAngle: 0, sharpen: 0, vignette: 0, grain: 0, sepia: 0, invert: 0 },},{id: 'vivid',name: 'Vivid',category: 'basic',- filters: { brightness: 105, contrast: 115, saturation: 130, hue: 0, blur: 0, blurType: 'gaussian', blurAngle: 0, sharpen: 10, vignette: 0, grain: 0, sepia: 0, invert: 0 },+ filters: { brightness: 105, contrast: 115, saturation: 130, hue: 0, exposure: 0, vibrance: 30, highlights: 0, shadows: 0, clarity: 10, blur: 0, blurType: 'gaussian', blurAngle: 0, sharpen: 10, vignette: 0, grain: 0, sepia: 0, invert: 0 },},{id: 'warm',name: 'Warm',category: 'mood',- filters: { brightness: 105, contrast: 105, saturation: 110, hue: 15, blur: 0, blurType: 'gaussian', blurAngle: 0, sharpen: 0, vignette: 0, grain: 0, sepia: 0, invert: 0 },+ filters: { brightness: 105, contrast: 105, saturation: 110, hue: 15, exposure: 5, vibrance: 15, highlights: 0, shadows: 10, clarity: 0, blur: 0, blurType: 'gaussian', blurAngle: 0, sharpen: 0, vignette: 0, grain: 0, sepia: 0, invert: 0 },},{id: 'cool',name: 'Cool',category: 'mood',- filters: { brightness: 100, contrast: 105, saturation: 95, hue: -15, blur: 0, blurType: 'gaussian', blurAngle: 0, sharpen: 0, vignette: 0, grain: 0, sepia: 0, invert: 0 },+ filters: { brightness: 100, contrast: 105, saturation: 95, hue: -15, exposure: 0, vibrance: 0, highlights: 5, shadows: 0, clarity: 5, blur: 0, blurType: 'gaussian', blurAngle: 0, sharpen: 0, vignette: 0, grain: 0, sepia: 0, invert: 0 },},{id: 'bw',name: 'B&W',category: 'basic',- filters: { brightness: 105, contrast: 115, saturation: 0, hue: 0, blur: 0, blurType: 'gaussian', blurAngle: 0, sharpen: 5, vignette: 20, grain: 5, sepia: 0, invert: 0 },+ filters: { brightness: 105, contrast: 115, saturation: 0, hue: 0, exposure: 0, vibrance: 0, highlights: 0, shadows: 0, clarity: 15, blur: 0, blurType: 'gaussian', blurAngle: 0, sharpen: 5, vignette: 20, grain: 5, sepia: 0, invert: 0 },},{id: 'vintage',name: 'Vintage',category: 'vintage',- filters: { brightness: 95, contrast: 90, saturation: 75, hue: 20, blur: 0, blurType: 'gaussian', blurAngle: 0, sharpen: 0, vignette: 30, grain: 15, sepia: 20, invert: 0 },+ filters: { brightness: 95, contrast: 90, saturation: 75, hue: 20, exposure: -5, vibrance: -10, highlights: -10, shadows: 15, clarity: 0, blur: 0, blurType: 'gaussian', blurAngle: 0, sharpen: 0, vignette: 30, grain: 15, sepia: 20, invert: 0 },},{id: 'fade',name: 'Fade',category: 'vintage',- filters: { brightness: 110, contrast: 85, saturation: 80, hue: 0, blur: 0, blurType: 'gaussian', blurAngle: 0, sharpen: 0, vignette: 15, grain: 0, sepia: 0, invert: 0 },+ filters: { brightness: 110, contrast: 85, saturation: 80, hue: 0, exposure: 5, vibrance: -5, highlights: 10, shadows: 20, clarity: -10, blur: 0, blurType: 'gaussian', blurAngle: 0, sharpen: 0, vignette: 15, grain: 0, sepia: 0, invert: 0 },},{id: 'dramatic',name: 'Dramatic',category: 'cinematic',- filters: { brightness: 95, contrast: 130, saturation: 90, hue: 0, blur: 0, blurType: 'gaussian', blurAngle: 0, sharpen: 15, vignette: 25, grain: 0, sepia: 0, invert: 0 },+ filters: { brightness: 95, contrast: 130, saturation: 90, hue: 0, exposure: -5, vibrance: 10, highlights: -15, shadows: -10, clarity: 25, blur: 0, blurType: 'gaussian', blurAngle: 0, sharpen: 15, vignette: 25, grain: 0, sepia: 0, invert: 0 },},{id: 'moody',name: 'Moody',category: 'mood',- filters: { brightness: 90, contrast: 110, saturation: 85, hue: -10, blur: 0, blurType: 'gaussian', blurAngle: 0, sharpen: 5, vignette: 35, grain: 5, sepia: 0, invert: 0 },+ filters: { brightness: 90, contrast: 110, saturation: 85, hue: -10, exposure: -10, vibrance: 0, highlights: -20, shadows: 5, clarity: 10, blur: 0, blurType: 'gaussian', blurAngle: 0, sharpen: 5, vignette: 35, grain: 5, sepia: 0, invert: 0 },},{id: 'bright',name: 'Bright',category: 'basic',- filters: { brightness: 120, contrast: 105, saturation: 105, hue: 0, blur: 0, blurType: 'gaussian', blurAngle: 0, sharpen: 0, vignette: 0, grain: 0, sepia: 0, invert: 0 },+ filters: { brightness: 120, contrast: 105, saturation: 105, hue: 0, exposure: 15, vibrance: 10, highlights: 10, shadows: 20, clarity: 0, blur: 0, blurType: 'gaussian', blurAngle: 0, sharpen: 0, vignette: 0, grain: 0, sepia: 0, invert: 0 },},{id: 'sepia',name: 'Sepia',category: 'vintage',- filters: { brightness: 105, contrast: 95, saturation: 40, hue: 35, blur: 0, blurType: 'gaussian', blurAngle: 0, sharpen: 0, vignette: 20, grain: 10, sepia: 50, invert: 0 },+ filters: { brightness: 105, contrast: 95, saturation: 40, hue: 35, exposure: 0, vibrance: -20, highlights: 0, shadows: 10, clarity: 0, blur: 0, blurType: 'gaussian', blurAngle: 0, sharpen: 0, vignette: 20, grain: 10, sepia: 50, invert: 0 },},{id: 'cinematic',name: 'Cinematic',category: 'cinematic',- filters: { brightness: 95, contrast: 115, saturation: 95, hue: -5, blur: 0, blurType: 'gaussian', blurAngle: 0, sharpen: 10, vignette: 20, grain: 3, sepia: 0, invert: 0 },+ filters: { brightness: 95, contrast: 115, saturation: 95, hue: -5, exposure: 0, vibrance: 5, highlights: -10, shadows: 5, clarity: 15, blur: 0, blurType: 'gaussian', blurAngle: 0, sharpen: 10, vignette: 20, grain: 3, sepia: 0, invert: 0 },},{id: 'pop',name: 'Pop',category: 'mood',- filters: { brightness: 110, contrast: 120, saturation: 140, hue: 5, blur: 0, blurType: 'gaussian', blurAngle: 0, sharpen: 5, vignette: 0, grain: 0, sepia: 0, invert: 0 },+ filters: { brightness: 110, contrast: 120, saturation: 140, hue: 5, exposure: 5, vibrance: 40, highlights: 5, shadows: 0, clarity: 10, blur: 0, blurType: 'gaussian', blurAngle: 0, sharpen: 5, vignette: 0, grain: 0, sepia: 0, invert: 0 },},{id: 'matte',name: 'Matte',category: 'cinematic',- filters: { brightness: 105, contrast: 85, saturation: 90, hue: 0, blur: 0, blurType: 'gaussian', blurAngle: 0, sharpen: 0, vignette: 10, grain: 0, sepia: 0, invert: 0 },+ filters: { brightness: 105, contrast: 85, saturation: 90, hue: 0, exposure: 0, vibrance: -5, highlights: 5, shadows: 15, clarity: -5, blur: 0, blurType: 'gaussian', blurAngle: 0, sharpen: 0, vignette: 10, grain: 0, sepia: 0, invert: 0 },},{id: 'retro',name: 'Retro',category: 'vintage',- filters: { brightness: 100, contrast: 95, saturation: 70, hue: 25, blur: 0, blurType: 'gaussian', blurAngle: 0, sharpen: 0, vignette: 25, grain: 20, sepia: 15, invert: 0 },+ filters: { brightness: 100, contrast: 95, saturation: 70, hue: 25, exposure: -5, vibrance: -15, highlights: -5, shadows: 10, clarity: 0, blur: 0, blurType: 'gaussian', blurAngle: 0, sharpen: 0, vignette: 25, grain: 20, sepia: 15, invert: 0 },},{id: 'punch',name: 'Punch',category: 'basic',- filters: { brightness: 100, contrast: 125, saturation: 115, hue: 0, blur: 0, blurType: 'gaussian', blurAngle: 0, sharpen: 20, vignette: 0, grain: 0, sepia: 0, invert: 0 },+ filters: { brightness: 100, contrast: 125, saturation: 115, hue: 0, exposure: 0, vibrance: 20, highlights: 0, shadows: -10, clarity: 20, blur: 0, blurType: 'gaussian', blurAngle: 0, sharpen: 20, vignette: 0, grain: 0, sepia: 0, invert: 0 },},];@@ -120,6 +120,11 @@ function filtersMatch(a: Filter, b: Filter): boolean {a.contrast === b.contrast &&a.saturation === b.saturation &&a.hue === b.hue &&+ a.exposure === b.exposure &&+ a.vibrance === b.vibrance &&+ a.highlights === b.highlights &&+ a.shadows === b.shadows &&+ a.clarity === b.clarity &&a.blur === b.blur &&a.blurType === b.blurType &&a.blurAngle === b.blurAngle &&@@ -138,6 +143,11 @@ function interpolateFilters(target: Filter, intensity: number): Filter {contrast: Math.round(lerp(100, target.contrast)),saturation: Math.round(lerp(100, target.saturation)),hue: Math.round(lerp(0, target.hue)),+ exposure: Math.round(lerp(0, target.exposure)),+ vibrance: Math.round(lerp(0, target.vibrance)),+ highlights: Math.round(lerp(0, target.highlights)),+ shadows: Math.round(lerp(0, target.shadows)),+ clarity: Math.round(lerp(0, target.clarity)),blur: Math.round(lerp(0, target.blur)),blurType: target.blurType,blurAngle: Math.round(lerp(0, target.blurAngle)),diff --git a/apps/image/src/components/editor/inspector/ImageAdjustmentsSection.tsx b/apps/image/src/components/editor/inspector/ImageAdjustmentsSection.tsxindex 5559c4d5..b33f7866 100644--- a/apps/image/src/components/editor/inspector/ImageAdjustmentsSection.tsx+++ b/apps/image/src/components/editor/inspector/ImageAdjustmentsSection.tsx@@ -1,6 +1,6 @@import { useProjectStore } from '../../../stores/project-store';import type { ImageLayer, Filter, BlurType } from '../../../types/project';-import { Sun, Contrast, Palette, Thermometer, Focus, Sparkles, CircleDot, Scan, Film, Minus, Move, Target } from 'lucide-react';+import { Sun, Contrast, Palette, Thermometer, Focus, Sparkles, CircleDot, Scan, Film, Minus, Move, Target, SunMedium, Vibrate, Sunrise, SunDim, Aperture } from 'lucide-react';interface Props {layer: ImageLayer;@@ -90,6 +90,11 @@ export function ImageAdjustmentsSection({ layer }: Props) {contrast: 100,saturation: 100,hue: 0,+ exposure: 0,+ vibrance: 0,+ highlights: 0,+ shadows: 0,+ clarity: 0,blur: 0,blurType: 'gaussian',blurAngle: 0,@@ -107,6 +112,11 @@ export function ImageAdjustmentsSection({ layer }: Props) {layer.filters.contrast !== 100 ||layer.filters.saturation !== 100 ||layer.filters.hue !== 0 ||+ layer.filters.exposure !== 0 ||+ layer.filters.vibrance !== 0 ||+ layer.filters.highlights !== 0 ||+ layer.filters.shadows !== 0 ||+ layer.filters.clarity !== 0 ||layer.filters.blur !== 0 ||layer.filters.sharpen !== 0 ||layer.filters.vignette !== 0 ||@@ -175,6 +185,56 @@ export function ImageAdjustmentsSection({ layer }: Props) {unit="°"/>+ <AdjustmentSlider+ icon={<SunMedium size={12} />}+ label="Exposure"+ value={layer.filters.exposure}+ min={-100}+ max={100}+ defaultValue={0}+ onChange={(v) => handleFilterChange('exposure', v)}+ />++ <AdjustmentSlider+ icon={<Vibrate size={12} />}+ label="Vibrance"+ value={layer.filters.vibrance}+ min={-100}+ max={100}+ defaultValue={0}+ onChange={(v) => handleFilterChange('vibrance', v)}+ />++ <AdjustmentSlider+ icon={<Sunrise size={12} />}+ label="Highlights"+ value={layer.filters.highlights}+ min={-100}+ max={100}+ defaultValue={0}+ onChange={(v) => handleFilterChange('highlights', v)}+ />++ <AdjustmentSlider+ icon={<SunDim size={12} />}+ label="Shadows"+ value={layer.filters.shadows}+ min={-100}+ max={100}+ defaultValue={0}+ onChange={(v) => handleFilterChange('shadows', v)}+ />++ <AdjustmentSlider+ icon={<Aperture size={12} />}+ label="Clarity"+ value={layer.filters.clarity}+ min={-100}+ max={100}+ defaultValue={0}+ onChange={(v) => handleFilterChange('clarity', v)}+ />+<AdjustmentSlidericon={<Focus size={12} />}label="Blur"diff --git a/apps/image/src/components/editor/panels/LeftPanel.tsx b/apps/image/src/components/editor/panels/LeftPanel.tsxindex 9f47de78..7cfbe4b8 100644--- a/apps/image/src/components/editor/panels/LeftPanel.tsx+++ b/apps/image/src/components/editor/panels/LeftPanel.tsx@@ -1,4 +1,4 @@-import { useState } from 'react';+import { useState, useRef, useEffect } from 'react';import {Layers,Image,@@ -9,6 +9,8 @@ import {Search,Plus,Folder,+ FolderPlus,+ FolderOpen,Sparkles,Star,Heart,@@ -24,6 +26,11 @@ import {ArrowUp,ArrowDown,ArrowLeft,+ ArrowUpToLine,+ ArrowDownToLine,+ ChevronUp,+ ChevronDown,+ ChevronRight,Check,X,AlertCircle,@@ -45,9 +52,207 @@ import {Award,Gift,Coffee,+ Eye,+ EyeOff,+ Lock,+ Unlock,+ Trash2,+ Copy,} from 'lucide-react';import { useUIStore, Panel } from '../../../stores/ui-store';import { useProjectStore } from '../../../stores/project-store';+import type { Layer, GroupLayer, Project } from '../../../types/project';++interface LayerItemProps {+ layer: Layer;+ depth: number;+ project: Project | null;+ selectedLayerIds: string[];+ editingLayerId: string | null;+ editingName: string;+ isDragSelecting: boolean;+ onLayerClick: (layerId: string, e: React.MouseEvent) => void;+ onLayerMouseDown: (layerId: string, e: React.MouseEvent) => void;+ onLayerMouseEnter: (layerId: string) => void;+ onStartRename: (layer: { id: string; name: string }) => void;+ onFinishRename: () => void;+ onEditingNameChange: (name: string) => void;+ onCancelRename: () => void;+ updateLayer: (id: string, updates: Partial<Layer>) => void;+ removeLayer: (id: string) => void;+ getLayerIcon: (type: string) => React.ReactNode;+}++function LayerItem({+ layer,+ depth,+ project,+ selectedLayerIds,+ editingLayerId,+ editingName,+ isDragSelecting,+ onLayerClick,+ onLayerMouseDown,+ onLayerMouseEnter,+ onStartRename,+ onFinishRename,+ onEditingNameChange,+ onCancelRename,+ updateLayer,+ removeLayer,+ getLayerIcon,+}: LayerItemProps) {+ const isSelected = selectedLayerIds.includes(layer.id);+ const isEditing = editingLayerId === layer.id;+ const isGroup = layer.type === 'group';+ const group = isGroup ? (layer as GroupLayer) : null;+ const isExpanded = group?.expanded ?? false;++ const toggleExpanded = (e: React.MouseEvent) => {+ e.stopPropagation();+ if (group) {+ updateLayer(layer.id, { expanded: !isExpanded } as Partial<Layer>);+ }+ };++ const toggleVisibility = (e: React.MouseEvent) => {+ e.stopPropagation();+ updateLayer(layer.id, { visible: !layer.visible });+ };++ const toggleLock = (e: React.MouseEvent) => {+ e.stopPropagation();+ updateLayer(layer.id, { locked: !layer.locked });+ };++ const handleDelete = (e: React.MouseEvent) => {+ e.stopPropagation();+ removeLayer(layer.id);+ };++ const handleDoubleClick = (e: React.MouseEvent) => {+ e.stopPropagation();+ onStartRename(layer);+ };++ const handleKeyDown = (e: React.KeyboardEvent) => {+ if (e.key === 'Enter') {+ onFinishRename();+ } else if (e.key === 'Escape') {+ onCancelRename();+ }+ };++ return (+ <>+ <div+ onClick={(e) => onLayerClick(layer.id, e)}+ onMouseDown={(e) => onLayerMouseDown(layer.id, e)}+ onMouseEnter={() => isDragSelecting && onLayerMouseEnter(layer.id)}+ onDoubleClick={handleDoubleClick}+ className={`group flex items-center gap-1.5 px-2 py-1.5 mx-1 rounded-md cursor-pointer transition-colors select-none ${+ isSelected+ ? 'bg-primary/20 text-foreground'+ : 'text-muted-foreground hover:bg-accent hover:text-foreground'+ } ${layer.locked ? 'opacity-60' : ''}`}+ style={{ paddingLeft: `${8 + depth * 16}px` }}+ >+ {isGroup && (+ <button+ onClick={toggleExpanded}+ className="p-0.5 rounded hover:bg-accent/50 transition-colors"+ >+ {isExpanded ? (+ <ChevronDown size={12} />+ ) : (+ <ChevronRight size={12} />+ )}+ </button>+ )}++ <span className={`flex-shrink-0 ${isSelected ? 'text-primary' : ''}`}>+ {isGroup ? (+ isExpanded ? <FolderOpen size={14} /> : <Folder size={14} />+ ) : (+ getLayerIcon(layer.type)+ )}+ </span>++ {isEditing ? (+ <input+ type="text"+ value={editingName}+ onChange={(e) => onEditingNameChange(e.target.value)}+ onBlur={onFinishRename}+ onKeyDown={handleKeyDown}+ autoFocus+ className="flex-1 min-w-0 px-1 py-0.5 text-xs bg-background border border-input rounded focus:outline-none focus:ring-1 focus:ring-primary"+ onClick={(e) => e.stopPropagation()}+ />+ ) : (+ <span className="flex-1 min-w-0 text-xs truncate">+ {layer.name}+ </span>+ )}++ <div className="flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity">+ <button+ onClick={toggleVisibility}+ className="p-1 rounded hover:bg-accent/50 transition-colors"+ title={layer.visible ? 'Hide' : 'Show'}+ >+ {layer.visible ? <Eye size={12} /> : <EyeOff size={12} />}+ </button>+ <button+ onClick={toggleLock}+ className="p-1 rounded hover:bg-accent/50 transition-colors"+ title={layer.locked ? 'Unlock' : 'Lock'}+ >+ {layer.locked ? <Lock size={12} /> : <Unlock size={12} />}+ </button>+ <button+ onClick={handleDelete}+ className="p-1 rounded hover:bg-destructive/20 text-muted-foreground hover:text-destructive transition-colors"+ title="Delete"+ >+ <Trash2 size={12} />+ </button>+ </div>+ </div>++ {isGroup && isExpanded && group && project && (+ <div>+ {group.childIds.map((childId) => {+ const childLayer = project.layers[childId];+ if (!childLayer) return null;+ return (+ <LayerItem+ key={childId}+ layer={childLayer}+ depth={depth + 1}+ project={project}+ selectedLayerIds={selectedLayerIds}+ editingLayerId={editingLayerId}+ editingName={editingName}+ isDragSelecting={isDragSelecting}+ onLayerClick={onLayerClick}+ onLayerMouseDown={onLayerMouseDown}+ onLayerMouseEnter={onLayerMouseEnter}+ onStartRename={onStartRename}+ onFinishRename={onFinishRename}+ onEditingNameChange={onEditingNameChange}+ onCancelRename={onCancelRename}+ updateLayer={updateLayer}+ removeLayer={removeLayer}+ getLayerIcon={getLayerIcon}+ />+ );+ })}+ </div>+ )}+ </>+ );+}import {TEMPLATE_CATEGORIES,getTemplatesByCategory,@@ -106,33 +311,279 @@ export function LeftPanel() {}function LayersPanel() {+ const {+ project,+ selectedLayerIds,+ selectedArtboardId,+ selectLayer,+ selectLayers,+ updateLayer,+ removeLayer,+ duplicateLayer,+ moveLayerUp,+ moveLayerDown,+ moveLayerToTop,+ moveLayerToBottom,+ groupLayers,+ ungroupLayers,+ } = useProjectStore();++ const [searchQuery, setSearchQuery] = useState('');+ const [editingLayerId, setEditingLayerId] = useState<string | null>(null);+ const [editingName, setEditingName] = useState('');+ const [isDragSelecting, setIsDragSelecting] = useState(false);+ const dragSelectIds = useRef<Set<string>>(new Set());++ const artboard = project?.artboards.find((a) => a.id === selectedArtboardId);+ const layers = artboard?.layerIds.map((id) => project?.layers[id]).filter(Boolean) ?? [];++ const filteredLayers = searchQuery+ ? layers.filter((layer) =>+ layer && layer.name.toLowerCase().includes(searchQuery.toLowerCase())+ )+ : layers;++ const handleStartRename = (layer: { id: string; name: string }) => {+ setEditingLayerId(layer.id);+ setEditingName(layer.name);+ };++ const handleFinishRename = () => {+ if (editingLayerId && editingName.trim()) {+ updateLayer(editingLayerId, { name: editingName.trim() });+ }+ setEditingLayerId(null);+ setEditingName('');+ };++ useEffect(() => {+ const handleMouseUp = () => {+ if (isDragSelecting) {+ setIsDragSelecting(false);+ if (dragSelectIds.current.size > 0) {+ selectLayers(Array.from(dragSelectIds.current));+ }+ dragSelectIds.current.clear();+ }+ };++ document.addEventListener('mouseup', handleMouseUp);+ return () => document.removeEventListener('mouseup', handleMouseUp);+ }, [isDragSelecting, selectLayers]);++ const handleLayerMouseDown = (layerId: string, e: React.MouseEvent) => {+ if (e.button !== 0) return;+ if (e.shiftKey || e.metaKey || e.ctrlKey) return;++ setIsDragSelecting(true);+ dragSelectIds.current.clear();+ dragSelectIds.current.add(layerId);+ selectLayers([layerId]);+ };++ const handleLayerMouseEnter = (layerId: string) => {+ if (isDragSelecting) {+ dragSelectIds.current.add(layerId);+ selectLayers(Array.from(dragSelectIds.current));+ }+ };++ const handleLayerClick = (layerId: string, e: React.MouseEvent) => {+ if (isDragSelecting) return;++ if (e.shiftKey && selectedLayerIds.length > 0) {+ const layerIds = layers.map(l => l?.id).filter(Boolean) as string[];+ const lastSelectedIndex = layerIds.indexOf(selectedLayerIds[selectedLayerIds.length - 1]);+ const clickedIndex = layerIds.indexOf(layerId);+ const start = Math.min(lastSelectedIndex, clickedIndex);+ const end = Math.max(lastSelectedIndex, clickedIndex);+ const rangeIds = layerIds.slice(start, end + 1);+ selectLayers([...new Set([...selectedLayerIds, ...rangeIds])]);+ } else if (e.metaKey || e.ctrlKey) {+ if (selectedLayerIds.includes(layerId)) {+ selectLayers(selectedLayerIds.filter(id => id !== layerId));+ } else {+ selectLayers([...selectedLayerIds, layerId]);+ }+ } else {+ selectLayer(layerId);+ }+ };++ const getLayerIcon = (type: string) => {+ switch (type) {+ case 'image': return <Image size={14} />;+ case 'text': return <Type size={14} />;+ case 'shape': return <Shapes size={14} />;+ case 'group': return <Folder size={14} />;+ default: return <Layers size={14} />;+ }+ };++ const selectedLayer = selectedLayerIds.length === 1 ? project?.layers[selectedLayerIds[0]] : null;+return (- <div className="p-3">- <div className="flex items-center justify-between mb-3">- <h3 className="text-sm font-medium text-foreground">Layers</h3>- <button className="p-1.5 rounded-md text-muted-foreground hover:text-foreground hover:bg-accent">- <Plus size={16} />- </button>+ <div className="h-full flex flex-col">+ <div className="p-3 border-b border-border">+ <div className="relative">+ <Search size={14} className="absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground" />+ <input+ type="text"+ placeholder="Search layers..."+ value={searchQuery}+ onChange={(e) => setSearchQuery(e.target.value)}+ className="w-full pl-8 pr-3 py-2 text-xs bg-background border border-input rounded-lg focus:outline-none focus:ring-2 focus:ring-primary/20"+ />+ </div>+ </div>++ <div className="flex-1 overflow-y-auto">+ {filteredLayers.length === 0 ? (+ <div className="flex flex-col items-center justify-center h-full text-center p-4">+ <Layers size={32} className="text-muted-foreground/50 mb-2" />+ <p className="text-xs text-muted-foreground">No layers yet</p>+ <p className="text-[10px] text-muted-foreground mt-1">+ Add text, shapes, or images+ </p>+ </div>+ ) : (+ <div className="py-1">+ {filteredLayers.map((layer) => {+ if (!layer) return null;+ return (+ <LayerItem+ key={layer.id}+ layer={layer}+ depth={0}+ project={project}+ selectedLayerIds={selectedLayerIds}+ editingLayerId={editingLayerId}+ editingName={editingName}+ isDragSelecting={isDragSelecting}+ onLayerClick={handleLayerClick}+ onLayerMouseDown={handleLayerMouseDown}+ onLayerMouseEnter={handleLayerMouseEnter}+ onStartRename={handleStartRename}+ onFinishRename={handleFinishRename}+ onEditingNameChange={setEditingName}+ onCancelRename={() => { setEditingLayerId(null); setEditingName(''); }}+ updateLayer={updateLayer}+ removeLayer={removeLayer}+ getLayerIcon={getLayerIcon}+ />+ );+ })}+ </div>+ )}</div>- <p className="text-xs text-muted-foreground">- Layers appear here when you add elements to the canvas.- </p>++ {selectedLayerIds.length > 0 && (+ <div className="p-2 border-t border-border space-y-2">+ {selectedLayerIds.length > 1 && (+ <button+ onClick={() => groupLayers(selectedLayerIds)}+ className="w-full flex items-center justify-center gap-1.5 px-3 py-2 rounded-md bg-primary text-primary-foreground text-xs font-medium hover:bg-primary/90"+ >+ <FolderPlus size={14} />+ Group {selectedLayerIds.length} Layers+ </button>+ )}++ {selectedLayerIds.length === 1 && selectedLayer?.type === 'group' && (+ <button+ onClick={() => ungroupLayers(selectedLayerIds[0])}+ className="w-full flex items-center justify-center gap-1.5 px-3 py-1.5 rounded-md bg-secondary text-secondary-foreground text-xs font-medium hover:bg-secondary/80"+ >+ <FolderOpen size={14} />+ Ungroup+ </button>+ )}++ {selectedLayerIds.length === 1 && (+ <>+ <div className="flex items-center justify-between gap-1">+ <span className="text-[10px] text-muted-foreground">Order</span>+ <div className="flex items-center gap-0.5">+ <button+ onClick={() => moveLayerToTop(selectedLayerIds[0])}+ className="p-1.5 rounded hover:bg-accent text-muted-foreground hover:text-foreground"+ title="Bring to Front"+ >+ <ArrowUpToLine size={14} />+ </button>+ <button+ onClick={() => moveLayerUp(selectedLayerIds[0])}+ className="p-1.5 rounded hover:bg-accent text-muted-foreground hover:text-foreground"+ title="Bring Forward"+ >+ <ChevronUp size={14} />+ </button>+ <button+ onClick={() => moveLayerDown(selectedLayerIds[0])}+ className="p-1.5 rounded hover:bg-accent text-muted-foreground hover:text-foreground"+ title="Send Backward"+ >+ <ChevronDown size={14} />+ </button>+ <button+ onClick={() => moveLayerToBottom(selectedLayerIds[0])}+ className="p-1.5 rounded hover:bg-accent text-muted-foreground hover:text-foreground"+ title="Send to Back"+ >+ <ArrowDownToLine size={14} />+ </button>+ </div>+ </div>++ <div className="flex items-center gap-1">+ <button+ onClick={() => duplicateLayer(selectedLayerIds[0])}+ className="flex-1 flex items-center justify-center gap-1 px-2 py-1.5 rounded-md bg-secondary text-secondary-foreground text-[10px] font-medium hover:bg-secondary/80"+ >+ <Copy size={12} />+ Duplicate+ </button>+ <button+ onClick={() => removeLayer(selectedLayerIds[0])}+ className="flex-1 flex items-center justify-center gap-1 px-2 py-1.5 rounded-md bg-destructive/10 text-destructive text-[10px] font-medium hover:bg-destructive/20"+ >+ <Trash2 size={12} />+ Delete+ </button>+ </div>+ </>+ )}+ </div>+ )}</div>);}function AssetsPanel() {- const { project } = useProjectStore();+ const { project, addImageLayer } = useProjectStore();+ const [searchQuery, setSearchQuery] = useState('');const assets = project ? Object.values(project.assets) : [];+ const filteredAssets = searchQuery+ ? assets.filter((asset) =>+ asset.name.toLowerCase().includes(searchQuery.toLowerCase())+ )+ : assets;++ const handleAddToCanvas = (asset: typeof assets[0]) => {+ addImageLayer(asset.id);+ };+return (- <div className="p-3">+ <div className="p-3 h-full overflow-y-auto"><div className="mb-3"><div className="relative"><Search size={16} className="absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground" /><inputtype="text"placeholder="Search assets..."+ value={searchQuery}+ onChange={(e) => setSearchQuery(e.target.value)}className="w-full pl-9 pr-3 py-2 text-sm bg-background border border-input rounded-lg focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary"/></div>@@ -144,18 +595,34 @@ function AssetsPanel() {<p className="text-xs text-muted-foreground">No assets yet</p><p className="text-xs text-muted-foreground mt-1">Upload images to use in your design</p></div>+ ) : filteredAssets.length === 0 ? (+ <div className="text-center py-8">+ <Search size={32} className="mx-auto text-muted-foreground mb-2" />+ <p className="text-xs text-muted-foreground">No matching assets</p>+ </div>) : (<div className="grid grid-cols-2 gap-2">- {assets.map((asset) => (+ {filteredAssets.map((asset) => (<buttonkey={asset.id}- className="aspect-square rounded-lg bg-muted overflow-hidden hover:ring-2 hover:ring-primary transition-all"+ onClick={() => handleAddToCanvas(asset)}+ className="group relative aspect-square rounded-lg bg-muted overflow-hidden hover:ring-2 hover:ring-primary transition-all"+ title={`Add "${asset.name}" to canvas`}><imgsrc={asset.thumbnailUrl}alt={asset.name}className="w-full h-full object-cover"/>+ <div className="absolute inset-0 bg-black/0 group-hover:bg-black/40 transition-colors flex items-center justify-center">+ <Plus+ size={24}+ className="text-white opacity-0 group-hover:opacity-100 transition-opacity"+ />+ </div>+ <div className="absolute bottom-0 left-0 right-0 p-1.5 bg-gradient-to-t from-black/60 to-transparent">+ <p className="text-[9px] text-white truncate">{asset.name}</p>+ </div></button>))}</div>@@ -490,8 +957,9 @@ function ElementsPanel() {}function UploadsPanel() {- const { addAsset } = useProjectStore();+ const { project, addAsset, addImageLayer } = useProjectStore();const [isDragging, setIsDragging] = useState(false);+ const assets = project ? Object.values(project.assets) : [];const handleDrop = async (e: React.DragEvent) => {e.preventDefault();@@ -551,8 +1019,12 @@ function UploadsPanel() {});};+ const handleAddToCanvas = (assetId: string) => {+ addImageLayer(assetId);+ };+return (- <div className="p-3">+ <div className="p-3 h-full overflow-y-auto"><h3 className="text-sm font-medium text-foreground mb-3">Upload Files</h3><div@@ -562,20 +1034,17 @@ function UploadsPanel() {}}onDragLeave={() => setIsDragging(false)}onDrop={handleDrop}- className={`border-2 border-dashed rounded-xl p-6 text-center transition-all ${+ className={`border-2 border-dashed rounded-xl p-4 text-center transition-all ${isDragging? 'border-primary bg-primary/10': 'border-border hover:border-muted-foreground'}`}>- <Upload size={32} className="mx-auto text-muted-foreground mb-3" />- <p className="text-sm text-foreground mb-1">- Drag & drop files here+ <Upload size={24} className="mx-auto text-muted-foreground mb-2" />+ <p className="text-xs text-foreground mb-1">+ Drag & drop or click to browse</p>- <p className="text-xs text-muted-foreground mb-3">- or click to browse- </p>- <label className="inline-block px-4 py-2 bg-primary text-primary-foreground rounded-lg text-sm font-medium cursor-pointer hover:bg-primary/90 transition-colors">+ <label className="inline-block px-3 py-1.5 bg-primary text-primary-foreground rounded-lg text-xs font-medium cursor-pointer hover:bg-primary/90 transition-colors">Browse Files<inputtype="file"@@ -585,11 +1054,40 @@ function UploadsPanel() {className="hidden"/></label>+ <p className="text-[10px] text-muted-foreground mt-2">+ PNG, JPG, SVG, WebP+ </p></div>- <p className="text-xs text-muted-foreground mt-3 text-center">- Supports PNG, JPG, SVG, WebP- </p>+ {assets.length > 0 && (+ <div className="mt-4">+ <h4 className="text-xs font-medium text-muted-foreground uppercase tracking-wide mb-2">+ Your Uploads ({assets.length})+ </h4>+ <div className="grid grid-cols-3 gap-1.5">+ {assets.map((asset) => (+ <button+ key={asset.id}+ onClick={() => handleAddToCanvas(asset.id)}+ className="group relative aspect-square rounded-md bg-muted overflow-hidden hover:ring-2 hover:ring-primary transition-all"+ title={`Add "${asset.name}" to canvas`}+ >+ <img+ src={asset.thumbnailUrl}+ alt={asset.name}+ className="w-full h-full object-cover"+ />+ <div className="absolute inset-0 bg-black/0 group-hover:bg-black/40 transition-colors flex items-center justify-center">+ <Plus+ size={16}+ className="text-white opacity-0 group-hover:opacity-100 transition-opacity"+ />+ </div>+ </button>+ ))}+ </div>+ </div>+ )}</div>);}diff --git a/apps/image/src/services/background-removal-service.ts b/apps/image/src/services/background-removal-service.tsindex 822191c0..86f0b0e2 100644--- a/apps/image/src/services/background-removal-service.ts+++ b/apps/image/src/services/background-removal-service.ts@@ -1,37 +1,26 @@-export type BackgroundMode = 'transparent' | 'color' | 'blur';+import { removeBackground, Config } from '@imgly/background-removal';-export interface BackgroundRemovalResult {- imageData: ImageData;- mask: ImageData;-}+export type BackgroundMode = 'transparent' | 'color' | 'blur';export interface BackgroundRemovalOptions {- threshold: number;- edgeBlur: number;mode: BackgroundMode;backgroundColor?: string;blurAmount?: number;}export const DEFAULT_OPTIONS: BackgroundRemovalOptions = {- threshold: 0.5,- edgeBlur: 2,mode: 'transparent',backgroundColor: '#ffffff',- blurAmount: 10,+ blurAmount: 15,};export class BackgroundRemovalService {private canvas: HTMLCanvasElement;private ctx: CanvasRenderingContext2D;- private workCanvas: HTMLCanvasElement;- private workCtx: CanvasRenderingContext2D;constructor() {this.canvas = document.createElement('canvas');this.ctx = this.canvas.getContext('2d', { willReadFrequently: true })!;- this.workCanvas = document.createElement('canvas');- this.workCtx = this.workCanvas.getContext('2d', { willReadFrequently: true })!;}async removeBackground(@@ -41,241 +30,92 @@ export class BackgroundRemovalService {): Promise<string> {const opts = { ...DEFAULT_OPTIONS, ...options };- onProgress?.(10);+ onProgress?.(5);- let img: HTMLImageElement | ImageBitmap;+ let imageBlob: Blob;if (typeof imageSource === 'string') {- img = await this.loadImage(imageSource);+ if (imageSource.startsWith('data:')) {+ const response = await fetch(imageSource);+ imageBlob = await response.blob();+ } else {+ const response = await fetch(imageSource);+ imageBlob = await response.blob();+ }} else {- img = imageSource;+ this.canvas.width = imageSource.width;+ this.canvas.height = imageSource.height;+ this.ctx.drawImage(imageSource, 0, 0);+ imageBlob = await new Promise<Blob>((resolve) => {+ this.canvas.toBlob((blob) => resolve(blob!), 'image/png');+ });}- const width = img.width;- const height = img.height;-- this.canvas.width = width;- this.canvas.height = height;- this.workCanvas.width = width;- this.workCanvas.height = height;-- this.ctx.drawImage(img, 0, 0);- const imageData = this.ctx.getImageData(0, 0, width, height);-- onProgress?.(30);+ onProgress?.(10);- const mask = this.generateMask(imageData, opts.threshold);+ const config: Config = {+ progress: (_key, current, total) => {+ const baseProgress = 10;+ const progressRange = 80;+ const segmentProgress = (current / total) * progressRange;+ onProgress?.(Math.round(baseProgress + segmentProgress));+ },+ output: {+ format: 'image/png',+ quality: 1,+ },+ };++ const resultBlob = await removeBackground(imageBlob, config);- onProgress?.(50);+ onProgress?.(90);- if (opts.edgeBlur > 0) {- this.applyGaussianBlur(mask, opts.edgeBlur);+ if (opts.mode === 'transparent') {+ const dataUrl = await this.blobToDataUrl(resultBlob);+ onProgress?.(100);+ return dataUrl;}- onProgress?.(70);-- const result = this.applyMask(imageData, mask, opts);-- onProgress?.(90);-- this.ctx.putImageData(result, 0, 0);+ const maskedImg = await this.loadImageFromBlob(resultBlob);+ const originalImg = await this.loadImageFromBlob(imageBlob);++ this.canvas.width = originalImg.width;+ this.canvas.height = originalImg.height;++ if (opts.mode === 'color' && opts.backgroundColor) {+ this.ctx.fillStyle = opts.backgroundColor;+ this.ctx.fillRect(0, 0, this.canvas.width, this.canvas.height);+ this.ctx.drawImage(maskedImg, 0, 0);+ } else if (opts.mode === 'blur' && opts.blurAmount) {+ this.ctx.filter = `blur(${opts.blurAmount}px)`;+ this.ctx.drawImage(originalImg, 0, 0);+ this.ctx.filter = 'none';+ this.ctx.drawImage(maskedImg, 0, 0);+ }onProgress?.(100);return this.canvas.toDataURL('image/png');}- private async loadImage(src: string): Promise<HTMLImageElement> {+ private async loadImageFromBlob(blob: Blob): Promise<HTMLImageElement> {return new Promise((resolve, reject) => {const img = new Image();- img.crossOrigin = 'anonymous';- img.onload = () => resolve(img);+ img.onload = () => {+ URL.revokeObjectURL(img.src);+ resolve(img);+ };img.onerror = reject;- img.src = src;+ img.src = URL.createObjectURL(blob);});}- private generateMask(imageData: ImageData, threshold: number): ImageData {- const { data, width, height } = imageData;- const mask = new ImageData(width, height);-- const edgeColors = this.detectEdgeColors(data, width, height);-- for (let i = 0; i < data.length; i += 4) {- const r = data[i];- const g = data[i + 1];- const b = data[i + 2];-- let isForeground = true;-- for (const edgeColor of edgeColors) {- const distance = this.colorDistance(r, g, b, edgeColor.r, edgeColor.g, edgeColor.b);- if (distance < threshold * 255 * 3) {- isForeground = false;- break;- }- }-- const alpha = isForeground ? 255 : 0;- mask.data[i] = alpha;- mask.data[i + 1] = alpha;- mask.data[i + 2] = alpha;- mask.data[i + 3] = 255;- }-- return this.refineMask(mask, 2);- }-- private detectEdgeColors(data: Uint8ClampedArray, width: number, height: number): { r: number; g: number; b: number }[] {- const samples: { r: number; g: number; b: number }[] = [];- const sampleSize = 10;-- for (let x = 0; x < width; x += Math.floor(width / sampleSize)) {- const topIdx = x * 4;- samples.push({ r: data[topIdx], g: data[topIdx + 1], b: data[topIdx + 2] });-- const bottomIdx = ((height - 1) * width + x) * 4;- samples.push({ r: data[bottomIdx], g: data[bottomIdx + 1], b: data[bottomIdx + 2] });- }-- for (let y = 0; y < height; y += Math.floor(height / sampleSize)) {- const leftIdx = y * width * 4;- samples.push({ r: data[leftIdx], g: data[leftIdx + 1], b: data[leftIdx + 2] });-- const rightIdx = (y * width + width - 1) * 4;- samples.push({ r: data[rightIdx], g: data[rightIdx + 1], b: data[rightIdx + 2] });- }-- const colorCounts = new Map<string, { count: number; r: number; g: number; b: number }>();- for (const sample of samples) {- const quantized = {- r: Math.round(sample.r / 16) * 16,- g: Math.round(sample.g / 16) * 16,- b: Math.round(sample.b / 16) * 16,- };- const key = `${quantized.r},${quantized.g},${quantized.b}`;- const existing = colorCounts.get(key);- if (existing) {- existing.count++;- } else {- colorCounts.set(key, { count: 1, ...quantized });- }- }-- return Array.from(colorCounts.values())- .sort((a, b) => b.count - a.count)- .slice(0, 3)- .map(({ r, g, b }) => ({ r, g, b }));- }-- private colorDistance(r1: number, g1: number, b1: number, r2: number, g2: number, b2: number): number {- return Math.abs(r1 - r2) + Math.abs(g1 - g2) + Math.abs(b1 - b2);- }-- private refineMask(mask: ImageData, iterations: number): ImageData {- const { width, height } = mask;- const result = new ImageData(new Uint8ClampedArray(mask.data), width, height);-- for (let iter = 0; iter < iterations; iter++) {- const temp = new Uint8ClampedArray(result.data);-- for (let y = 1; y < height - 1; y++) {- for (let x = 1; x < width - 1; x++) {- const idx = (y * width + x) * 4;-- let sum = 0;- let count = 0;-- for (let dy = -1; dy <= 1; dy++) {- for (let dx = -1; dx <= 1; dx++) {- const nIdx = ((y + dy) * width + (x + dx)) * 4;- sum += temp[nIdx];- count++;- }- }-- const avg = sum / count;- result.data[idx] = avg > 127 ? 255 : 0;- result.data[idx + 1] = result.data[idx];- result.data[idx + 2] = result.data[idx];- }- }- }-- return result;- }-- private applyGaussianBlur(mask: ImageData, radius: number): void {- const { data, width, height } = mask;- const temp = new Uint8ClampedArray(data);-- for (let y = radius; y < height - radius; y++) {- for (let x = radius; x < width - radius; x++) {- const idx = (y * width + x) * 4;-- let sum = 0;- let weightSum = 0;-- for (let dy = -radius; dy <= radius; dy++) {- for (let dx = -radius; dx <= radius; dx++) {- const nIdx = ((y + dy) * width + (x + dx)) * 4;- const distance = Math.sqrt(dx * dx + dy * dy);- const weight = Math.exp(-(distance * distance) / (2 * radius * radius));- sum += temp[nIdx] * weight;- weightSum += weight;- }- }-- data[idx] = sum / weightSum;- data[idx + 1] = data[idx];- data[idx + 2] = data[idx];- }- }- }-- private applyMask(imageData: ImageData, mask: ImageData, options: BackgroundRemovalOptions): ImageData {- const { width, height } = imageData;- const result = new ImageData(new Uint8ClampedArray(imageData.data), width, height);-- if (options.mode === 'transparent') {- for (let i = 0; i < mask.data.length; i += 4) {- result.data[i + 3] = mask.data[i];- }- } else if (options.mode === 'color' && options.backgroundColor) {- const bgColor = this.hexToRgb(options.backgroundColor);- for (let i = 0; i < mask.data.length; i += 4) {- const alpha = mask.data[i] / 255;- result.data[i] = result.data[i] * alpha + bgColor.r * (1 - alpha);- result.data[i + 1] = result.data[i + 1] * alpha + bgColor.g * (1 - alpha);- result.data[i + 2] = result.data[i + 2] * alpha + bgColor.b * (1 - alpha);- result.data[i + 3] = 255;- }- } else if (options.mode === 'blur' && options.blurAmount) {- this.workCtx.filter = `blur(${options.blurAmount}px)`;- this.workCtx.drawImage(this.canvas, 0, 0);- this.workCtx.filter = 'none';- const blurredData = this.workCtx.getImageData(0, 0, width, height);-- for (let i = 0; i < mask.data.length; i += 4) {- const alpha = mask.data[i] / 255;- result.data[i] = result.data[i] * alpha + blurredData.data[i] * (1 - alpha);- result.data[i + 1] = result.data[i + 1] * alpha + blurredData.data[i + 1] * (1 - alpha);- result.data[i + 2] = result.data[i + 2] * alpha + blurredData.data[i + 2] * (1 - alpha);- result.data[i + 3] = 255;- }- }-- return result;- }-- private hexToRgb(hex: string): { r: number; g: number; b: number } {- const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);- return result- ? {- r: parseInt(result[1], 16),- g: parseInt(result[2], 16),- b: parseInt(result[3], 16),- }- : { r: 255, g: 255, b: 255 };+ private async blobToDataUrl(blob: Blob): Promise<string> {+ return new Promise((resolve, reject) => {+ const reader = new FileReader();+ reader.onloadend = () => resolve(reader.result as string);+ reader.onerror = reject;+ reader.readAsDataURL(blob);+ });}}diff --git a/apps/image/src/services/export-service.ts b/apps/image/src/services/export-service.tsindex 629fc522..5b369178 100644--- a/apps/image/src/services/export-service.ts+++ b/apps/image/src/services/export-service.ts@@ -1,4 +1,4 @@-import type { Project, Artboard, Layer, ImageLayer, TextLayer, ShapeLayer } from '../types/project';+import type { Project, Artboard, Layer, ImageLayer, TextLayer, ShapeLayer, Filter } from '../types/project';export type ExportFormat = 'png' | 'jpg' | 'webp' | 'svg' | 'pdf';export type ExportQuality = 'low' | 'medium' | 'high' | 'max';@@ -18,6 +18,21 @@ const QUALITY_MAP: Record<ExportQuality, number> = {max: 1.0,};+const BLEND_MODE_MAP: Record<string, GlobalCompositeOperation> = {+ 'normal': 'source-over',+ 'multiply': 'multiply',+ 'screen': 'screen',+ 'overlay': 'overlay',+ 'darken': 'darken',+ 'lighten': 'lighten',+ 'color-dodge': 'color-dodge',+ 'color-burn': 'color-burn',+ 'hard-light': 'hard-light',+ 'soft-light': 'soft-light',+ 'difference': 'difference',+ 'exclusion': 'exclusion',+};+export async function exportProject(project: Project,options: ExportOptions,@@ -105,13 +120,64 @@ async function renderLayerToContext(project: Project): Promise<void> {const { transform } = layer;+ const shadow = layer.shadow ?? { enabled: false, color: 'rgba(0, 0, 0, 0.5)', blur: 10, offsetX: 0, offsetY: 4 };+ const innerShadow = layer.innerShadow ?? { enabled: false, color: 'rgba(0, 0, 0, 0.5)', blur: 10, offsetX: 2, offsetY: 2 };+ const glow = layer.glow ?? { enabled: false, color: '#ffffff', blur: 20, intensity: 1 };+ const blendMode = layer.blendMode?.mode ?? 'normal';ctx.save();ctx.translate(transform.x, transform.y);ctx.rotate((transform.rotation * Math.PI) / 180);ctx.scale(transform.scaleX, transform.scaleY);++ const skewX = transform.skewX ?? 0;+ const skewY = transform.skewY ?? 0;+ if (skewX !== 0 || skewY !== 0) {+ ctx.transform(1, Math.tan(skewY * Math.PI / 180), Math.tan(skewX * Math.PI / 180), 1, 0, 0);+ }+ctx.globalAlpha = transform.opacity;+ ctx.globalCompositeOperation = BLEND_MODE_MAP[blendMode] ?? 'source-over';++ if (glow.enabled && glow.blur > 0) {+ ctx.save();+ ctx.shadowColor = glow.color;+ ctx.shadowBlur = glow.blur * (glow.intensity ?? 1);+ ctx.shadowOffsetX = 0;+ ctx.shadowOffsetY = 0;++ for (let i = 0; i < 3; i++) {+ await renderLayerContent(ctx, layer, project);+ }+ ctx.restore();+ }++ if (shadow.enabled) {+ ctx.shadowColor = shadow.color;+ ctx.shadowBlur = shadow.blur;+ ctx.shadowOffsetX = shadow.offsetX;+ ctx.shadowOffsetY = shadow.offsetY;+ }++ await renderLayerContent(ctx, layer, project);++ ctx.shadowColor = 'transparent';+ ctx.shadowBlur = 0;+ ctx.shadowOffsetX = 0;+ ctx.shadowOffsetY = 0;++ if (innerShadow.enabled && innerShadow.blur > 0) {+ renderInnerShadow(ctx, layer, innerShadow);+ }++ ctx.restore();+}+async function renderLayerContent(+ ctx: CanvasRenderingContext2D,+ layer: Layer,+ project: Project+): Promise<void> {switch (layer.type) {case 'image':await renderImageLayerToContext(ctx, layer as ImageLayer, project);@@ -123,10 +189,152 @@ async function renderLayerToContext(renderShapeLayerToContext(ctx, layer as ShapeLayer);break;}+}++function renderInnerShadow(+ ctx: CanvasRenderingContext2D,+ layer: Layer,+ innerShadow: { color: string; blur: number; offsetX: number; offsetY: number }+): void {+ const { width, height } = layer.transform;++ ctx.save();+ ctx.beginPath();+ ctx.rect(0, 0, width, height);+ ctx.clip();++ ctx.shadowColor = innerShadow.color;+ ctx.shadowBlur = innerShadow.blur;+ ctx.shadowOffsetX = innerShadow.offsetX;+ ctx.shadowOffsetY = innerShadow.offsetY;++ ctx.fillStyle = 'rgba(0, 0, 0, 1)';+ ctx.globalCompositeOperation = 'source-atop';++ const spread = innerShadow.blur + Math.max(Math.abs(innerShadow.offsetX), Math.abs(innerShadow.offsetY)) + 50;++ ctx.beginPath();+ ctx.moveTo(-spread, -spread);+ ctx.lineTo(width + spread, -spread);+ ctx.lineTo(width + spread, height + spread);+ ctx.lineTo(-spread, height + spread);+ ctx.closePath();++ ctx.moveTo(0, 0);+ ctx.lineTo(0, height);+ ctx.lineTo(width, height);+ ctx.lineTo(width, 0);+ ctx.closePath();++ ctx.fill('evenodd');ctx.restore();}+function applyFilters(ctx: CanvasRenderingContext2D, filters: Filter): void {+ const filterParts: string[] = [];++ let effectiveBrightness = filters.brightness;+ if (filters.exposure !== 0) {+ effectiveBrightness = effectiveBrightness * (1 + filters.exposure / 100);+ }+ if (filters.highlights > 0) {+ effectiveBrightness = effectiveBrightness * (1 + filters.highlights / 200);+ }+ if (filters.shadows > 0) {+ effectiveBrightness = effectiveBrightness * (1 + filters.shadows / 300);+ }+ if (effectiveBrightness !== 100) {+ filterParts.push(`brightness(${Math.round(effectiveBrightness)}%)`);+ }++ let effectiveContrast = filters.contrast;+ if (filters.clarity !== 0) {+ effectiveContrast = effectiveContrast * (1 + filters.clarity / 150);+ }+ if (filters.highlights < 0) {+ effectiveContrast = effectiveContrast * (1 + filters.highlights / 400);+ }+ if (filters.shadows < 0) {+ effectiveContrast = effectiveContrast * (1 + filters.shadows / 400);+ }+ if (effectiveContrast !== 100) {+ filterParts.push(`contrast(${Math.round(effectiveContrast)}%)`);+ }++ let effectiveSaturation = filters.saturation;+ if (filters.vibrance !== 0) {+ effectiveSaturation = effectiveSaturation * (1 + filters.vibrance / 150);+ }+ if (effectiveSaturation !== 100) {+ filterParts.push(`saturate(${Math.round(effectiveSaturation)}%)`);+ }++ if (filters.hue !== 0) {+ filterParts.push(`hue-rotate(${filters.hue}deg)`);+ }+ if (filters.sepia > 0) {+ filterParts.push(`sepia(${filters.sepia}%)`);+ }+ if (filters.invert > 0) {+ filterParts.push(`invert(${filters.invert}%)`);+ }+ if (filters.blur > 0 && filters.blurType === 'gaussian') {+ filterParts.push(`blur(${filters.blur}px)`);+ }++ if (filterParts.length > 0) {+ ctx.filter = filterParts.join(' ');+ }+}++function applyMotionBlur(+ ctx: CanvasRenderingContext2D,+ img: HTMLImageElement,+ width: number,+ height: number,+ amount: number,+ angle: number+): void {+ const steps = Math.min(Math.ceil(amount / 2), 20);+ const radians = (angle * Math.PI) / 180;+ const dx = Math.cos(radians) * (amount / steps);+ const dy = Math.sin(radians) * (amount / steps);++ for (let i = -steps; i <= steps; i++) {+ const alpha = 1 / (Math.abs(i) + 1);+ ctx.globalAlpha = alpha / (steps * 2);+ ctx.drawImage(img, i * dx, i * dy, width, height);+ }+ ctx.globalAlpha = 1;+}++function applyRadialBlur(+ ctx: CanvasRenderingContext2D,+ img: HTMLImageElement,+ width: number,+ height: number,+ amount: number+): void {+ const steps = Math.min(Math.ceil(amount / 2), 15);+ const centerX = width / 2;+ const centerY = height / 2;++ for (let i = 0; i < steps; i++) {+ const scale = 1 + (i * amount) / (steps * 100);+ const alpha = 1 / (i + 1);+ ctx.globalAlpha = alpha / steps;++ ctx.save();+ ctx.translate(centerX, centerY);+ ctx.scale(scale, scale);+ ctx.translate(-centerX, -centerY);+ ctx.drawImage(img, 0, 0, width, height);+ ctx.restore();+ }+ ctx.globalAlpha = 1;+}+async function renderImageLayerToContext(ctx: CanvasRenderingContext2D,layer: ImageLayer,@@ -135,23 +343,61 @@ async function renderImageLayerToContext(const asset = project.assets[layer.sourceId];if (!asset) return;+ const flipH = layer.flipHorizontal ?? false;+ const flipV = layer.flipVertical ?? false;++ if (flipH || flipV) {+ ctx.save();+ ctx.translate(+ flipH ? layer.transform.width : 0,+ flipV ? layer.transform.height : 0+ );+ ctx.scale(flipH ? -1 : 1, flipV ? -1 : 1);+ }+const img = new Image();img.crossOrigin = 'anonymous';await new Promise<void>((resolve) => {img.onload = () => {- ctx.drawImage(img, 0, 0, layer.transform.width, layer.transform.height);+ const { filters } = layer;++ applyFilters(ctx, filters);++ if (filters.blur > 0 && filters.blurType === 'motion') {+ applyMotionBlur(ctx, img, layer.transform.width, layer.transform.height, filters.blur, filters.blurAngle);+ } else if (filters.blur > 0 && filters.blurType === 'radial') {+ applyRadialBlur(ctx, img, layer.transform.width, layer.transform.height, filters.blur);+ } else {+ ctx.drawImage(img, 0, 0, layer.transform.width, layer.transform.height);+ }++ ctx.filter = 'none';resolve();};img.onerror = () => resolve();img.src = asset.dataUrl ?? asset.blobUrl ?? '';});++ if (flipH || flipV) {+ ctx.restore();+ }}function renderTextLayerToContext(ctx: CanvasRenderingContext2D, layer: TextLayer): void {const { style, content, transform } = layer;+ const flipH = layer.flipHorizontal ?? false;+ const flipV = layer.flipVertical ?? false;++ if (flipH || flipV) {+ ctx.save();+ ctx.translate(+ flipH ? transform.width : 0,+ flipV ? transform.height : 0+ );+ ctx.scale(flipH ? -1 : 1, flipV ? -1 : 1);+ }- ctx.fillStyle = style.color;ctx.font = `${style.fontStyle} ${style.fontWeight} ${style.fontSize}px ${style.fontFamily}`;ctx.textAlign = style.textAlign as CanvasTextAlign;ctx.textBaseline = 'top';@@ -163,34 +409,165 @@ function renderTextLayerToContext(ctx: CanvasRenderingContext2D, layer: TextLayeif (style.textAlign === 'center') textX = transform.width / 2;else if (style.textAlign === 'right') textX = transform.width;+ if (style.backgroundColor) {+ const padding = style.backgroundPadding ?? 8;+ const radius = style.backgroundRadius ?? 4;+ const textWidth = Math.max(...lines.map((line) => ctx.measureText(line).width));+ const textHeight = lines.length * lineHeight;++ let bgX = -padding;+ if (style.textAlign === 'center') bgX = (transform.width - textWidth) / 2 - padding;+ else if (style.textAlign === 'right') bgX = transform.width - textWidth - padding;++ ctx.fillStyle = style.backgroundColor;+ ctx.beginPath();+ const bgW = textWidth + padding * 2;+ const bgH = textHeight + padding * 2;+ const bgY = -padding;+ const r = Math.min(radius, bgW / 2, bgH / 2);+ ctx.moveTo(bgX + r, bgY);+ ctx.lineTo(bgX + bgW - r, bgY);+ ctx.quadraticCurveTo(bgX + bgW, bgY, bgX + bgW, bgY + r);+ ctx.lineTo(bgX + bgW, bgY + bgH - r);+ ctx.quadraticCurveTo(bgX + bgW, bgY + bgH, bgX + bgW - r, bgY + bgH);+ ctx.lineTo(bgX + r, bgY + bgH);+ ctx.quadraticCurveTo(bgX, bgY + bgH, bgX, bgY + bgH - r);+ ctx.lineTo(bgX, bgY + r);+ ctx.quadraticCurveTo(bgX, bgY, bgX + r, bgY);+ ctx.closePath();+ ctx.fill();+ }++ let fillStyle: string | CanvasGradient = style.color;+ if (style.fillType === 'gradient' && style.gradient && lines.length > 0) {+ const lineWidths = lines.map((line) => ctx.measureText(line).width);+ const textWidth = lineWidths.length > 0 ? Math.max(...lineWidths) : 0;+ const textHeight = lines.length * lineHeight;++ if (textWidth > 0 && textHeight > 0) {+ let gradientStartX = 0;+ if (style.textAlign === 'center') gradientStartX = (transform.width - textWidth) / 2;+ else if (style.textAlign === 'right') gradientStartX = transform.width - textWidth;++ if (style.gradient.type === 'linear') {+ const angleRad = (style.gradient.angle * Math.PI) / 180;+ const cos = Math.cos(angleRad);+ const sin = Math.sin(angleRad);+ const halfWidth = textWidth / 2;+ const halfHeight = textHeight / 2;+ const len = Math.abs(halfWidth * cos) + Math.abs(halfHeight * sin);++ const centerX = gradientStartX + halfWidth;+ const centerY = halfHeight;+ const gradient = ctx.createLinearGradient(+ centerX - len * cos,+ centerY - len * sin,+ centerX + len * cos,+ centerY + len * sin+ );+ style.gradient.stops.forEach((stop) => {+ gradient.addColorStop(stop.offset, stop.color);+ });+ fillStyle = gradient;+ } else {+ const centerX = gradientStartX + textWidth / 2;+ const centerY = textHeight / 2;+ const radius = Math.max(textWidth, textHeight) / 2;+ const gradient = ctx.createRadialGradient(centerX, centerY, 0, centerX, centerY, radius);+ style.gradient.stops.forEach((stop) => {+ gradient.addColorStop(stop.offset, stop.color);+ });+ fillStyle = gradient;+ }+ }+ }++ const textShadow = style.textShadow;+ if (textShadow?.enabled) {+ ctx.shadowColor = textShadow.color ?? 'rgba(0, 0, 0, 0.5)';+ ctx.shadowBlur = textShadow.blur ?? 4;+ ctx.shadowOffsetX = textShadow.offsetX ?? 0;+ ctx.shadowOffsetY = textShadow.offsetY ?? 2;+ }+lines.forEach((line, i) => {- ctx.fillText(line, textX, i * lineHeight);+ const y = i * lineHeight;++ if (style.strokeColor && (style.strokeWidth ?? 0) > 0) {+ ctx.strokeStyle = style.strokeColor;+ ctx.lineWidth = style.strokeWidth ?? 1;+ ctx.lineJoin = 'round';+ ctx.miterLimit = 2;+ ctx.strokeText(line, textX, y);+ }++ ctx.fillStyle = fillStyle;+ ctx.fillText(line, textX, y);});++ if (textShadow?.enabled) {+ ctx.shadowColor = 'transparent';+ ctx.shadowBlur = 0;+ ctx.shadowOffsetX = 0;+ ctx.shadowOffsetY = 0;+ }++ if (flipH || flipV) {+ ctx.restore();+ }}function renderShapeLayerToContext(ctx: CanvasRenderingContext2D, layer: ShapeLayer): void {const { shapeType, shapeStyle, transform } = layer;const { width, height } = transform;+ const flipH = layer.flipHorizontal ?? false;+ const flipV = layer.flipVertical ?? false;++ if (flipH || flipV) {+ ctx.save();+ ctx.translate(+ flipH ? width : 0,+ flipV ? height : 0+ );+ ctx.scale(flipH ? -1 : 1, flipV ? -1 : 1);+ }ctx.beginPath();switch (shapeType) {- case 'rectangle':- if (shapeStyle.cornerRadius > 0) {+ case 'rectangle': {+ let tl = 0, tr = 0, br = 0, bl = 0;++ if (shapeStyle.individualCorners && shapeStyle.corners) {+ tl = Math.min(shapeStyle.corners.topLeft, width / 2, height / 2);+ tr = Math.min(shapeStyle.corners.topRight, width / 2, height / 2);+ br = Math.min(shapeStyle.corners.bottomRight, width / 2, height / 2);+ bl = Math.min(shapeStyle.corners.bottomLeft, width / 2, height / 2);+ } else if (shapeStyle.cornerRadius > 0) {const r = Math.min(shapeStyle.cornerRadius, width / 2, height / 2);- ctx.moveTo(r, 0);- ctx.lineTo(width - r, 0);- ctx.quadraticCurveTo(width, 0, width, r);- ctx.lineTo(width, height - r);- ctx.quadraticCurveTo(width, height, width - r, height);- ctx.lineTo(r, height);- ctx.quadraticCurveTo(0, height, 0, height - r);- ctx.lineTo(0, r);- ctx.quadraticCurveTo(0, 0, r, 0);+ tl = tr = br = bl = r;+ }++ if (tl > 0 || tr > 0 || br > 0 || bl > 0) {+ ctx.moveTo(tl, 0);+ ctx.lineTo(width - tr, 0);+ if (tr > 0) ctx.quadraticCurveTo(width, 0, width, tr);+ else ctx.lineTo(width, 0);+ ctx.lineTo(width, height - br);+ if (br > 0) ctx.quadraticCurveTo(width, height, width - br, height);+ else ctx.lineTo(width, height);+ ctx.lineTo(bl, height);+ if (bl > 0) ctx.quadraticCurveTo(0, height, 0, height - bl);+ else ctx.lineTo(0, height);+ ctx.lineTo(0, tl);+ if (tl > 0) ctx.quadraticCurveTo(0, 0, tl, 0);+ else ctx.lineTo(0, 0);+ ctx.closePath();} else {ctx.rect(0, 0, width, height);}break;+ }case 'ellipse':ctx.ellipse(width / 2, height / 2, width / 2, height / 2, 0, 0, Math.PI * 2);@@ -203,12 +580,29 @@ function renderShapeLayerToContext(ctx: CanvasRenderingContext2D, layer: ShapeLactx.closePath();break;+ case 'polygon': {+ const cx = width / 2;+ const cy = height / 2;+ const radius = Math.min(width, height) / 2;+ const sides = layer.sides ?? 6;+ for (let i = 0; i < sides; i++) {+ const angle = (i * 2 * Math.PI) / sides - Math.PI / 2;+ const px = cx + radius * Math.cos(angle);+ const py = cy + radius * Math.sin(angle);+ if (i === 0) ctx.moveTo(px, py);+ else ctx.lineTo(px, py);+ }+ ctx.closePath();+ break;+ }+case 'star': {const cx = width / 2;const cy = height / 2;const outerRadius = Math.min(width, height) / 2;- const innerRadius = outerRadius * 0.4;- const points = 5;+ const innerRatio = layer.innerRadius ?? 0.4;+ const innerRadius = outerRadius * innerRatio;+ const points = layer.sides ?? 5;for (let i = 0; i < points * 2; i++) {const radius = i % 2 === 0 ? outerRadius : innerRadius;const angle = (i * Math.PI) / points - Math.PI / 2;@@ -226,14 +620,88 @@ function renderShapeLayerToContext(ctx: CanvasRenderingContext2D, layer: ShapeLactx.lineTo(width, height / 2);break;+ case 'arrow': {+ const arrowHeadSize = Math.min(width, height) * 0.3;+ ctx.moveTo(0, height / 2);+ ctx.lineTo(width - arrowHeadSize, height / 2);+ ctx.moveTo(width, height / 2);+ ctx.lineTo(width - arrowHeadSize, height / 2 - arrowHeadSize / 2);+ ctx.moveTo(width, height / 2);+ ctx.lineTo(width - arrowHeadSize, height / 2 + arrowHeadSize / 2);+ break;+ }++ case 'path':+ if (layer.points && layer.points.length > 1) {+ ctx.moveTo(layer.points[0].x, layer.points[0].y);+ for (let i = 1; i < layer.points.length; i++) {+ ctx.lineTo(layer.points[i].x, layer.points[i].y);+ }+ ctx.lineCap = 'round';+ ctx.lineJoin = 'round';+ }+ break;+default:ctx.rect(0, 0, width, height);}- if (shapeStyle.fill) {- ctx.fillStyle = shapeStyle.fill;+ const fillType = shapeStyle.fillType ?? 'solid';+ const hasFill = fillType === 'solid' ? !!shapeStyle.fill : fillType === 'gradient' ? !!shapeStyle.gradient : fillType === 'noise' ? !!shapeStyle.noise : false;++ if (hasFill) {ctx.globalAlpha *= shapeStyle.fillOpacity;- ctx.fill();++ if (fillType === 'noise' && shapeStyle.noise) {+ ctx.fillStyle = shapeStyle.noise.baseColor;+ ctx.fill();++ ctx.save();+ ctx.clip();++ const { noise } = shapeStyle;+ const noiseSize = noise.size;+ const density = noise.density;++ ctx.fillStyle = noise.noiseColor;+ for (let y = 0; y < height; y += noiseSize) {+ for (let x = 0; x < width; x += noiseSize) {+ if (Math.random() < density) {+ ctx.fillRect(x, y, noiseSize, noiseSize);+ }+ }+ }++ ctx.restore();+ } else if (fillType === 'gradient' && shapeStyle.gradient) {+ let gradient: CanvasGradient;+ if (shapeStyle.gradient.type === 'linear') {+ const angleRad = (shapeStyle.gradient.angle * Math.PI) / 180;+ const cos = Math.cos(angleRad);+ const sin = Math.sin(angleRad);+ const halfW = width / 2;+ const halfH = height / 2;+ const len = Math.abs(halfW * cos) + Math.abs(halfH * sin);+ gradient = ctx.createLinearGradient(+ halfW - len * cos,+ halfH - len * sin,+ halfW + len * cos,+ halfH + len * sin+ );+ } else {+ const radius = Math.max(width, height) / 2;+ gradient = ctx.createRadialGradient(width / 2, height / 2, 0, width / 2, height / 2, radius);+ }+ shapeStyle.gradient.stops.forEach((stop) => {+ gradient.addColorStop(stop.offset, stop.color);+ });+ ctx.fillStyle = gradient;+ ctx.fill();+ } else if (shapeStyle.fill) {+ ctx.fillStyle = shapeStyle.fill;+ ctx.fill();+ }+ctx.globalAlpha /= shapeStyle.fillOpacity;}@@ -241,7 +709,32 @@ function renderShapeLayerToContext(ctx: CanvasRenderingContext2D, layer: ShapeLactx.strokeStyle = shapeStyle.stroke;ctx.lineWidth = shapeStyle.strokeWidth;ctx.globalAlpha *= shapeStyle.strokeOpacity;++ const sw = shapeStyle.strokeWidth;+ switch (shapeStyle.strokeDash ?? 'solid') {+ case 'dashed':+ ctx.setLineDash([sw * 3, sw * 2]);+ break;+ case 'dotted':+ ctx.setLineDash([sw, sw * 2]);+ ctx.lineCap = 'round';+ break;+ case 'dash-dot':+ ctx.setLineDash([sw * 4, sw * 2, sw, sw * 2]);+ break;+ case 'long-dash':+ ctx.setLineDash([sw * 6, sw * 3]);+ break;+ default:+ ctx.setLineDash([]);+ }+ctx.stroke();+ ctx.setLineDash([]);+ }++ if (flipH || flipV) {+ ctx.restore();}}diff --git a/apps/image/src/stores/project-store.ts b/apps/image/src/stores/project-store.tsindex 4023cccc..06ce6f88 100644--- a/apps/image/src/stores/project-store.ts+++ b/apps/image/src/stores/project-store.ts@@ -406,13 +406,45 @@ export const useProjectStore = create<ProjectState & ProjectActions>()(if (state.project && state.selectedArtboardId) {const artboard = state.project.artboards.find((a) => a.id === state.selectedArtboardId);if (artboard && childIds.length > 0) {+ let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;+ childIds.forEach((childId) => {+ const child = state.project!.layers[childId];+ if (child) {+ const { x, y, width, height } = child.transform;+ minX = Math.min(minX, x);+ minY = Math.min(minY, y);+ maxX = Math.max(maxX, x + width);+ maxY = Math.max(maxY, y + height);+ }+ });++ const groupX = minX;+ const groupY = minY;+ const groupWidth = maxX - minX;+ const groupHeight = maxY - minY;++ childIds.forEach((childId) => {+ const child = state.project!.layers[childId];+ if (child) {+ child.transform.x -= groupX;+ child.transform.y -= groupY;+ child.parentId = id;+ }+ });+const layer: GroupLayer = {id,name: 'Group',type: 'group',visible: true,locked: false,- transform: DEFAULT_TRANSFORM,+ transform: {+ ...DEFAULT_TRANSFORM,+ x: groupX,+ y: groupY,+ width: groupWidth,+ height: groupHeight,+ },blendMode: DEFAULT_BLEND_MODE,shadow: DEFAULT_SHADOW,innerShadow: DEFAULT_INNER_SHADOW,@@ -425,12 +457,7 @@ export const useProjectStore = create<ProjectState & ProjectActions>()(childIds,expanded: true,};- childIds.forEach((childId) => {- const child = state.project!.layers[childId];- if (child) {- child.parentId = id;- }- });+state.project.layers[id] = layer;const firstChildIndex = artboard.layerIds.findIndex((lid) => childIds.includes(lid));artboard.layerIds = artboard.layerIds.filter((lid) => !childIds.includes(lid));@@ -692,9 +719,12 @@ export const useProjectStore = create<ProjectState & ProjectActions>()(const artboard = state.project.artboards.find((a) => a.id === state.selectedArtboardId);if (artboard) {const groupIndex = artboard.layerIds.indexOf(groupId);+ const { x: groupX, y: groupY } = group.transform;group.childIds.forEach((childId) => {const child = state.project!.layers[childId];if (child) {+ child.transform.x += groupX;+ child.transform.y += groupY;child.parentId = null;}});diff --git a/apps/image/src/types/project.ts b/apps/image/src/types/project.tsindex 9dffe8ab..f9e54449 100644--- a/apps/image/src/types/project.ts+++ b/apps/image/src/types/project.ts@@ -54,6 +54,11 @@ export interface Filter {contrast: number;saturation: number;hue: number;+ exposure: number;+ vibrance: number;+ highlights: number;+ shadows: number;+ clarity: number;blur: number;blurType: BlurType;blurAngle: number;@@ -299,6 +304,11 @@ export const DEFAULT_FILTER: Filter = {contrast: 100,saturation: 100,hue: 0,+ exposure: 0,+ vibrance: 0,+ highlights: 0,+ shadows: 0,+ clarity: 0,blur: 0,blurType: 'gaussian',blurAngle: 0,diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 190b9dd1..6705b86d 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -36,6 +36,9 @@ importers:apps/image:dependencies:+ '@imgly/background-removal':+ specifier: ^1.7.0+ version: 1.7.0([email protected])'@openreel/ui':specifier: workspace:*version: link:../../packages/ui@@ -1074,6 +1077,11 @@ packages:cpu: [x64]os: [win32]+ '@imgly/[email protected]':+ resolution: {integrity: sha512-/1ZryrMYg2ckIvJKoTu5Np50JfYMVffDMlVmppw/BdbN3pBTN7e6stI5/7E/LVh9DDzz6J588s7sWqul3fy5wA==}+ peerDependencies:+ onnxruntime-web: 1.21.0+'@jest/[email protected]':resolution: {integrity: sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==}engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}@@ -1109,6 +1117,36 @@ packages:resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==}engines: {node: '>= 8'}+ '@protobufjs/[email protected]':+ resolution: {integrity: sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ==}++ '@protobufjs/[email protected]':+ resolution: {integrity: sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg==}++ '@protobufjs/[email protected]':+ resolution: {integrity: sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg==}++ '@protobufjs/[email protected]':+ resolution: {integrity: sha512-j9ednRT81vYJ9OfVuXG6ERSTdEL1xVsNgqpkxMsbIabzSo3goCjDIveeGv5d03om39ML71RdmrGNjG5SReBP/Q==}++ '@protobufjs/[email protected]':+ resolution: {integrity: sha512-lljVXpqXebpsijW71PZaCYeIcE5on1w5DlQy5WH6GLbFryLUrBD4932W/E2BSpfRJWseIL4v/KPgBFxDOIdKpQ==}++ '@protobufjs/[email protected]':+ resolution: {integrity: sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ==}++ '@protobufjs/[email protected]':+ resolution: {integrity: sha512-kdSefcPdruJiFMVSbn801t4vFK7KB/5gd2fYvrxhuJYg8ILrmn9SKSX2tZdV6V+ksulWqS7aXjBcRXl3wHoD9Q==}++ '@protobufjs/[email protected]':+ resolution: {integrity: sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA==}++ '@protobufjs/[email protected]':+ resolution: {integrity: sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw==}++ '@protobufjs/[email protected]':+ resolution: {integrity: sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==}+'@radix-ui/[email protected]':resolution: {integrity: sha512-MkKCwxlXTgz6CFoJx3pCwn07GKp36+aZyu/u2Ln2VrA5DcdyCZkASEDBTd8x5whTQQL5CiYf4prXKLcgQdv29g==}@@ -2371,6 +2409,9 @@ packages:resolution: {integrity: sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==}engines: {node: '>=16'}+ resolution: {integrity: sha512-MI1qs7Lo4Syw0EOzUl0xjs2lsoeqFku44KpngfIduHBYvzm8h2+7K8YMQh1JtVVVrUvhLpNwqVi4DERegUJhPQ==}+resolution: {integrity: sha512-GX+ysw4PBCz0PzosHDepZGANEuFCMLrnRTiEy9McGjmkCQYwRq4A/X786G/fjM/+OjsWSU1ZrY5qyARZmO/uwg==}@@ -2456,6 +2497,9 @@ packages:resolution: {integrity: sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==}engines: {node: '>= 0.4'}+ resolution: {integrity: sha512-Y8T4vYhEfwJOTbouREvG+3XDsjr8E3kIr7uf+JZ0BYloFsttiHU0WfvANVsR7TxNUJa/WpCnw/Ino/p+DeBhBQ==}+resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==}engines: {node: '>=8'}@@ -2540,6 +2584,9 @@ packages:resolution: {integrity: sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==}engines: {node: '>=8'}+ resolution: {integrity: sha512-pZ2xT+LOHckCatGQ3DcG/a+QuEqvoxqkiL7tvE8nn3uuu+f6i1TtpB5/FtWFbxUuVr5PZCx8KskuGatbJDXOWA==}+resolution: {integrity: sha512-FWyyY60MeTNyeSRpkM2Iry0G9hpr7/9kD40mD/cGQEuilcZYS4okz8SN2Q6rLCJ8gbCt6fN+rC+6tMGS99LaxQ==}@@ -2553,6 +2600,9 @@ packages:resolution: {integrity: sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==}engines: {node: '>=8'}+ resolution: {integrity: sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==}+resolution: {integrity: sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w==}engines: {node: '>= 0.4'}@@ -2649,6 +2699,9 @@ packages:resolution: {integrity: sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==}engines: {node: '>=10'}+ resolution: {integrity: sha512-kVI48u3PZr38HdYz98UmfPnXl2DXrpdctLrFLCd3kOx1xUkOmpFPx7gCWWM5MPkL/fD8zb+Ph0QzjGFs4+hHWg==}+resolution: {integrity: sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==}@@ -2767,6 +2820,9 @@ packages:resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==}+ resolution: {integrity: sha512-B4JHA4vdyZU30ELBw3g7/p9bZupyew5a7tX1Y/gGeF2hafrPaQZhgrGQfsvgfYbgdFZjYwuEcnaobeM/WMW+HQ==}+resolution: {integrity: sha512-nmh3lCkYZ3grZvqcCH+fjmQ7X+H0OeZgP40OierEaAptX4XofMh5kwNbWh7lBduUzCcV/8kZ+NDLCwm2iorIlA==}@@ -2800,6 +2856,12 @@ packages:resolution: {integrity: sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==}engines: {node: '>=12'}+ resolution: {integrity: sha512-Q632iLLrtCAVOTO65dh2+mNbQir/QNTVBG3h/QdZBpns7mZ0RYbLRBgGABPbpU9351AgYy7SJf1WaeVwMrBFPQ==}++ resolution: {integrity: sha512-adzOe+7uI7lKz6pQNbAsLMQd2Fq5Jhmoxd8LZjJr8m3KvbFyiYyRxRiC57/XXD+jb18voppjeGAjoZmskXG+7A==}+resolution: {integrity: sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==}engines: {node: '>= 0.8.0'}@@ -2875,6 +2937,9 @@ packages:resolution: {integrity: sha512-/Jm5M4RvtBFVkKWRu2BLUTNP8/M2a+UwuAX+ae4770q1qVGtfjG+WTCupoZixokjmHiry8uI+dlY8KXYV5HVVQ==}+ resolution: {integrity: sha512-fnWVljUchTro6RiCFvCXBbNhJc2NijN7oIQxbwsyL0buWJPG85v81ehlHI9fXrJsMNgTofEoWIQeClKpgxFLrg==}+resolution: {integrity: sha512-hpr+J05B2FVYUAXHeK1YyI267J/dDDhMU6B6civm8hSY1jYJnBXxzKDKDswzJmtLHryrjhnDjqqp/49t8FALew==}engines: {node: '>=14.0.0'}@@ -2944,6 +3009,10 @@ packages:resolution: {integrity: sha512-TwEZ+X+yCJmYfL7TPUOcvBZ4QfoT5YenQiJuX//0th53DE6w0xxLEtfK3iyryQFddXuvkIk51EEgrJQ0WJkOmQ==}+ resolution: {integrity: sha512-CvexbZtbov6jW2eXAvLukXjXUW1TzFaivC46BpWc/3BpcCysb5Vffu+B3XHMm8lVEuy2Mm4XGex8hBSg1yapPg==}+ engines: {node: '>=12.0.0'}+resolution: {integrity: sha512-JZd3gMVBAVQkSs6HdNZo9Sdo0LNcQeMNP3CozBJb3JYC/QUYZTnKxP+f8oWRX4rHP5EurWxqAHTSwUCjlNKa1w==}@@ -3469,6 +3538,9 @@ packages:resolution: {integrity: sha512-EjIevzuJRiRPbVH4mGc8nApb/lVLKVpmUhAaR5R5doKGfAnGJ6Gr3CViAVjP+4FWSxCsybeWQdcgCtbX+7oZug==}+ resolution: {integrity: sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==}+resolution: {integrity: sha512-k7Nwx6vuWx1IJ9Bjuf4Zt1PEllcwe7cls3VNzm4CQ1/hgtFUK2bRNG3rvnpPUhFjmqJKAKtjV576KnUkHocg/g==}@@ -3981,6 +4053,13 @@ snapshots:'@img/[email protected]':optional: true+ '@imgly/[email protected]([email protected])':+ dependencies:+ lodash-es: 4.17.23+ ndarray: 1.0.19+ onnxruntime-web: 1.21.0+ zod: 3.25.76+'@jest/[email protected]':dependencies:'@sinclair/typebox': 0.27.8@@ -4021,6 +4100,29 @@ snapshots:'@nodelib/fs.scandir': 2.1.5fastq: 1.19.1+ '@protobufjs/[email protected]': {}++ '@protobufjs/[email protected]': {}++ '@protobufjs/[email protected]': {}++ '@protobufjs/[email protected]': {}++ '@protobufjs/[email protected]':+ dependencies:+ '@protobufjs/aspromise': 1.1.2+ '@protobufjs/inquire': 1.1.0++ '@protobufjs/[email protected]': {}++ '@protobufjs/[email protected]': {}++ '@protobufjs/[email protected]': {}++ '@protobufjs/[email protected]': {}++ '@protobufjs/[email protected]': {}+'@radix-ui/[email protected]': {}'@radix-ui/[email protected]': {}@@ -4694,7 +4796,6 @@ snapshots:'@types/[email protected]':dependencies:undici-types: 6.21.0- optional: true'@types/[email protected]': {}@@ -5357,6 +5458,8 @@ snapshots:flatted: 3.3.3keyv: 4.5.4+ [email protected]: {}+@@ -5432,6 +5535,8 @@ snapshots:+ [email protected]: {}+@@ -5509,6 +5614,8 @@ snapshots:+ [email protected]: {}+@@ -5523,6 +5630,8 @@ snapshots:dependencies:binary-extensions: 2.3.0+ [email protected]: {}+dependencies:hasown: 2.0.2@@ -5615,6 +5724,8 @@ snapshots:dependencies:p-locate: 5.0.0+ [email protected]: {}+@@ -5734,6 +5845,11 @@ snapshots:+ dependencies:+ iota-array: 1.0.0+ is-buffer: 1.1.6+@@ -5756,6 +5872,17 @@ snapshots:dependencies:mimic-fn: 4.0.0+ [email protected]: {}++ dependencies:+ flatbuffers: 25.9.23+ guid-typescript: 1.0.9+ long: 5.3.2+ onnxruntime-common: 1.21.0+ platform: 1.3.6+ protobufjs: 7.5.4+dependencies:deep-is: 0.1.4@@ -5827,6 +5954,8 @@ snapshots:mlly: 1.8.0pathe: 2.0.3+ [email protected]: {}+dependencies:postcss: 8.5.6@@ -5884,6 +6013,21 @@ snapshots:+ dependencies:+ '@protobufjs/aspromise': 1.1.2+ '@protobufjs/base64': 1.1.2+ '@protobufjs/codegen': 2.0.4+ '@protobufjs/eventemitter': 1.1.0+ '@protobufjs/fetch': 1.1.0+ '@protobufjs/float': 1.0.2+ '@protobufjs/inquire': 1.1.0+ '@protobufjs/path': 1.1.2+ '@protobufjs/pool': 1.1.0+ '@protobufjs/utf8': 1.1.0+ '@types/node': 22.19.6+ long: 5.3.2+dependencies:punycode: 2.3.1@@ -6224,8 +6368,7 @@ snapshots:- optional: true+ [email protected]: {}dependencies:@@ -6423,6 +6566,8 @@ snapshots:+ [email protected]: {}+