MCPcopy
hub / github.com/ZHO-ZHO-ZHO/Nano-Bananary / App

Function App

App.tsx:20–575  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

18type ActiveTool = 'mask' | 'none';
19
20const App: React.FC = () => {
21 const { t } = useTranslation();
22 const [transformations, setTransformations] = useState<Transformation[]>(() => {
23 try {
24 const savedOrder = localStorage.getItem('transformationOrder');
25 if (savedOrder) {
26 const orderedKeys = JSON.parse(savedOrder) as string[];
27 const transformationMap = new Map(TRANSFORMATIONS.map(t => [t.key, t]));
28
29 const orderedTransformations = orderedKeys
30 .map(key => transformationMap.get(key))
31 .filter((t): t is Transformation => !!t);
32
33 const savedKeysSet = new Set(orderedKeys);
34 const newTransformations = TRANSFORMATIONS.filter(t => !savedKeysSet.has(t.key));
35
36 return [...orderedTransformations, ...newTransformations];
37 }
38 } catch (e) {
39 console.error("Failed to load or parse transformation order from localStorage", e);
40 }
41 return TRANSFORMATIONS;
42 });
43
44 const [selectedTransformation, setSelectedTransformation] = useState<Transformation | null>(null);
45 const [primaryImageUrl, setPrimaryImageUrl] = useState<string | null>(null);
46 const [primaryFile, setPrimaryFile] = useState<File | null>(null);
47 const [secondaryImageUrl, setSecondaryImageUrl] = useState<string | null>(null);
48 const [secondaryFile, setSecondaryFile] = useState<File | null>(null);
49 const [generatedContent, setGeneratedContent] = useState<GeneratedContent | null>(null);
50 const [isLoading, setIsLoading] = useState<boolean>(false);
51 const [loadingMessage, setLoadingMessage] = useState<string>('');
52 const [error, setError] = useState<string | null>(null);
53 const [maskDataUrl, setMaskDataUrl] = useState<string | null>(null);
54 const [previewImageUrl, setPreviewImageUrl] = useState<string | null>(null);
55 const [customPrompt, setCustomPrompt] = useState<string>('');
56 const [aspectRatio, setAspectRatio] = useState<'16:9' | '9:16'>('16:9');
57 const [activeTool, setActiveTool] = useState<ActiveTool>('none');
58 const [history, setHistory] = useState<GeneratedContent[]>([]);
59 const [isHistoryPanelOpen, setIsHistoryPanelOpen] = useState<boolean>(false);
60 const [activeCategory, setActiveCategory] = useState<Transformation | null>(null);
61
62 useEffect(() => {
63 try {
64 const orderToSave = transformations.map(t => t.key);
65 localStorage.setItem('transformationOrder', JSON.stringify(orderToSave));
66 } catch (e) {
67 console.error("Failed to save transformation order to localStorage", e);
68 }
69 }, [transformations]);
70
71 // Cleanup blob URLs on unmount or when dependencies change
72 useEffect(() => {
73 return () => {
74 history.forEach(item => {
75 if (item.videoUrl) {
76 URL.revokeObjectURL(item.videoUrl);
77 }

Callers

nothing calls this directly

Calls 9

useTranslationFunction · 0.90
generateVideoFunction · 0.90
editImageFunction · 0.90
loadImageFunction · 0.90
resizeImageToMatchFunction · 0.90
embedWatermarkFunction · 0.90
dataUrlToFileFunction · 0.90
tFunction · 0.85
renderInputUIFunction · 0.85

Tested by

no test coverage detected