@umituz/react-native-ai-generation-content 1.17.230 → 1.17.231
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,234 +1,431 @@
|
|
|
1
|
-
# Face Swap
|
|
1
|
+
# Face Swap Feature
|
|
2
2
|
|
|
3
3
|
Swap faces between people in images using AI.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## 📍 Import Path
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
- High-quality output with natural results
|
|
7
|
+
```typescript
|
|
8
|
+
import { useFaceSwapFeature } from '@umituz/react-native-ai-generation-content';
|
|
9
|
+
```
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
**Location**: `src/features/face-swap/`
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
## 🎯 Feature Purpose
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
npm install @umituz/react-native-ai-generation-content
|
|
18
|
-
```
|
|
15
|
+
Swap faces between two images using AI-powered face detection and alignment. Supports multiple faces and produces natural-looking results.
|
|
19
16
|
|
|
20
|
-
|
|
17
|
+
---
|
|
21
18
|
|
|
22
|
-
|
|
19
|
+
## 📋 Usage Strategy
|
|
20
|
+
|
|
21
|
+
### When to Use This Feature
|
|
22
|
+
|
|
23
|
+
✅ **Use Cases:**
|
|
24
|
+
- Entertainment and fun face swaps
|
|
25
|
+
- Movie character transformations
|
|
26
|
+
- Historical face replacement projects
|
|
27
|
+
- Creative content and memes
|
|
28
|
+
- Social media engagement
|
|
29
|
+
|
|
30
|
+
❌ **When NOT to Use:**
|
|
31
|
+
- Identity fraud or deception
|
|
32
|
+
- Non-consensual face swapping
|
|
33
|
+
- Misleading content creation
|
|
34
|
+
- Defamatory purposes
|
|
35
|
+
|
|
36
|
+
### Implementation Strategy
|
|
37
|
+
|
|
38
|
+
1. **Require TWO images** - source and target
|
|
39
|
+
2. **Validate both images** before processing
|
|
40
|
+
3. **Show clear UI** for which face is which
|
|
41
|
+
4. **Implement confirmation dialog** before processing
|
|
42
|
+
5. **Provide preview** before saving
|
|
43
|
+
6. **Handle privacy** and consent properly
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## ⚠️ Critical Rules (MUST FOLLOW)
|
|
48
|
+
|
|
49
|
+
### 1. Image Requirements
|
|
50
|
+
- **MUST** provide TWO distinct images (source + target)
|
|
51
|
+
- **MUST** contain at least one detectable face in each image
|
|
52
|
+
- **MUST** use high-quality images (min 512x512 recommended)
|
|
53
|
+
- **MUST** ensure faces are clearly visible
|
|
54
|
+
- **MUST NOT** use images with no detectable faces
|
|
55
|
+
|
|
56
|
+
### 2. Configuration
|
|
57
|
+
- **MUST** provide valid `userId` for tracking
|
|
58
|
+
- **MUST** implement `onError` callback
|
|
59
|
+
- **MUST** implement `onSelectSourceImage` callback
|
|
60
|
+
- **MUST** implement `onSelectTargetImage` callback
|
|
61
|
+
- **MUST** handle both images being selected before processing
|
|
62
|
+
|
|
63
|
+
### 3. State Management
|
|
64
|
+
- **MUST** check `isReady` before enabling swap button
|
|
65
|
+
- **MUST** verify both images are selected
|
|
66
|
+
- **MUST** handle `isProcessing` state to prevent duplicate requests
|
|
67
|
+
- **MUST** display `error` state to users
|
|
68
|
+
- **MUST** implement proper cleanup on unmount
|
|
69
|
+
|
|
70
|
+
### 4. Performance
|
|
71
|
+
- **MUST** limit image size (<10MB each)
|
|
72
|
+
- **MUST** compress images before processing
|
|
73
|
+
- **MUST** implement loading indicators during processing
|
|
74
|
+
- **MUST** cache results locally
|
|
75
|
+
- **MUST NOT** process multiple swaps simultaneously
|
|
76
|
+
|
|
77
|
+
### 5. Ethics & Privacy
|
|
78
|
+
- **MUST** obtain consent from people whose faces are used
|
|
79
|
+
- **MUST** provide clear usage terms
|
|
80
|
+
- **MUST** implement content moderation
|
|
81
|
+
- **MUST** prevent malicious use cases
|
|
82
|
+
- **MUST** log processing for audit trail
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## 🚫 Prohibitions (MUST AVOID)
|
|
87
|
+
|
|
88
|
+
### Strictly Forbidden
|
|
89
|
+
|
|
90
|
+
❌ **NEVER** do the following:
|
|
91
|
+
|
|
92
|
+
1. **No Single Image**
|
|
93
|
+
- Always requires TWO images (source + target)
|
|
94
|
+
- Never attempt with missing image
|
|
95
|
+
|
|
96
|
+
2. **No Non-Consensual Swaps**
|
|
97
|
+
- Always obtain permission from subjects
|
|
98
|
+
- Never swap faces without consent
|
|
99
|
+
- Implement age verification for minors
|
|
100
|
+
|
|
101
|
+
3. **No Malicious Use**
|
|
102
|
+
- Never use for fraud or deception
|
|
103
|
+
- Never create misleading content
|
|
104
|
+
- Never use for harassment or bullying
|
|
105
|
+
|
|
106
|
+
4. **No Unhandled Errors**
|
|
107
|
+
- Never ignore face detection failures
|
|
108
|
+
- Always handle "no face found" errors
|
|
109
|
+
- Provide clear error messages
|
|
110
|
+
|
|
111
|
+
5. **No Memory Leaks**
|
|
112
|
+
- Never store large images in state unnecessarily
|
|
113
|
+
- Always cleanup image references on unmount
|
|
114
|
+
- Implement proper image disposal
|
|
115
|
+
|
|
116
|
+
6. **No Blocked UI**
|
|
117
|
+
- Never process without user confirmation
|
|
118
|
+
- Always show progress indicator
|
|
119
|
+
- Never block main thread with image processing
|
|
120
|
+
|
|
121
|
+
7. **No Missing Context**
|
|
122
|
+
- Never confuse which face is source/target
|
|
123
|
+
- Always provide clear UI labels
|
|
124
|
+
- Show preview before processing
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## 🤖 AI Agent Directions
|
|
129
|
+
|
|
130
|
+
### For AI Code Generation Tools
|
|
131
|
+
|
|
132
|
+
When using this feature with AI code generation tools, follow these guidelines:
|
|
133
|
+
|
|
134
|
+
#### Prompt Template for AI Agents
|
|
23
135
|
|
|
24
|
-
```tsx
|
|
25
|
-
import { useFaceSwapFeature } from '@umituz/react-native-ai-generation-content';
|
|
26
|
-
import * as ImagePicker from 'react-native-image-picker';
|
|
27
|
-
|
|
28
|
-
function FaceSwapScreen() {
|
|
29
|
-
const [sourceImage, setSourceImage] = useState<string | null>(null);
|
|
30
|
-
const [targetImage, setTargetImage] = useState<string | null>(null);
|
|
31
|
-
|
|
32
|
-
const feature = useFaceSwapFeature({
|
|
33
|
-
config: {
|
|
34
|
-
onProcessingStart: () => console.log('Starting face swap...'),
|
|
35
|
-
onProcessingComplete: (result) => console.log('Complete:', result),
|
|
36
|
-
onError: (error) => console.error('Error:', error),
|
|
37
|
-
},
|
|
38
|
-
onSelectSourceImage: async () => {
|
|
39
|
-
const result = await ImagePicker.launchImageLibrary({ mediaType: 'photo' });
|
|
40
|
-
if (result.assets && result.assets[0].uri) {
|
|
41
|
-
const base64 = await convertToBase64(result.assets[0].uri);
|
|
42
|
-
setSourceImage(base64);
|
|
43
|
-
return base64;
|
|
44
|
-
}
|
|
45
|
-
return null;
|
|
46
|
-
},
|
|
47
|
-
onSelectTargetImage: async () => {
|
|
48
|
-
const result = await ImagePicker.launchImageLibrary({ mediaType: 'photo' });
|
|
49
|
-
if (result.assets && result.assets[0].uri) {
|
|
50
|
-
const base64 = await convertToBase64(result.assets[0].uri);
|
|
51
|
-
setTargetImage(base64);
|
|
52
|
-
return base64;
|
|
53
|
-
}
|
|
54
|
-
return null;
|
|
55
|
-
},
|
|
56
|
-
onSaveImage: async (imageUrl) => {
|
|
57
|
-
// Save to gallery or download
|
|
58
|
-
await saveToGallery(imageUrl);
|
|
59
|
-
},
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
return (
|
|
63
|
-
<View>
|
|
64
|
-
<DualImagePicker
|
|
65
|
-
sourceImage={sourceImage}
|
|
66
|
-
targetImage={targetImage}
|
|
67
|
-
onSelectSourceImage={feature.selectSourceImage}
|
|
68
|
-
onSelectTargetImage={feature.selectTargetImage}
|
|
69
|
-
/>
|
|
70
|
-
|
|
71
|
-
<Button
|
|
72
|
-
title="Swap Faces"
|
|
73
|
-
onPress={feature.process}
|
|
74
|
-
disabled={!feature.isReady || feature.state.isProcessing}
|
|
75
|
-
/>
|
|
76
|
-
|
|
77
|
-
{feature.state.isProcessing && (
|
|
78
|
-
<ActivityIndicator />
|
|
79
|
-
)}
|
|
80
|
-
|
|
81
|
-
{feature.state.result && (
|
|
82
|
-
<Image source={{ uri: feature.state.result.imageUrl }} />
|
|
83
|
-
)}
|
|
84
|
-
</View>
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
136
|
```
|
|
137
|
+
You are implementing a face swap feature using @umituz/react-native-ai-generation-content.
|
|
138
|
+
|
|
139
|
+
REQUIREMENTS:
|
|
140
|
+
1. Import from: @umituz/react-native-ai-generation-content
|
|
141
|
+
2. Use the useFaceSwapFeature hook
|
|
142
|
+
3. Require TWO images (source + target)
|
|
143
|
+
4. Implement dual image selection UI
|
|
144
|
+
5. Validate both images before processing
|
|
145
|
+
6. Add confirmation dialog before swap
|
|
146
|
+
7. Handle face detection failures gracefully
|
|
147
|
+
8. Implement proper error handling
|
|
148
|
+
9. Show clear progress indicators
|
|
149
|
+
10. Implement cleanup on unmount
|
|
150
|
+
|
|
151
|
+
CRITICAL RULES:
|
|
152
|
+
- MUST obtain consent from subjects
|
|
153
|
+
- MUST validate both images before processing
|
|
154
|
+
- MUST provide clear UI for source vs target
|
|
155
|
+
- MUST handle "no face found" errors
|
|
156
|
+
- MUST prevent malicious use cases
|
|
157
|
+
- MUST implement content moderation
|
|
158
|
+
- NEVER process without user confirmation
|
|
159
|
+
|
|
160
|
+
CONFIGURATION:
|
|
161
|
+
- Provide valid userId (string)
|
|
162
|
+
- Implement onSelectSourceImage callback
|
|
163
|
+
- Implement onSelectTargetImage callback
|
|
164
|
+
- Implement onSaveImage callback
|
|
165
|
+
- Configure callbacks: onProcessingStart, onProcessingComplete, onError
|
|
166
|
+
|
|
167
|
+
OPTIONS:
|
|
168
|
+
- enhanceFace: boolean (default: true)
|
|
169
|
+
- matchSkinTone: boolean (default: true)
|
|
170
|
+
|
|
171
|
+
STRICTLY FORBIDDEN:
|
|
172
|
+
- No single image processing
|
|
173
|
+
- No non-consensual swaps
|
|
174
|
+
- No malicious use
|
|
175
|
+
- No unhandled errors
|
|
176
|
+
- No memory leaks
|
|
177
|
+
- No missing UI context
|
|
178
|
+
|
|
179
|
+
ETHICS CHECKLIST:
|
|
180
|
+
- [ ] Consent mechanism implemented
|
|
181
|
+
- [ ] Age verification for minors
|
|
182
|
+
- [ ] Content moderation in place
|
|
183
|
+
- [ ] Usage terms provided
|
|
184
|
+
- [ ] Audit trail logging
|
|
185
|
+
- [ ] Report/flag functionality
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
#### AI Implementation Checklist
|
|
189
|
+
|
|
190
|
+
Use this checklist when generating code:
|
|
191
|
+
|
|
192
|
+
- [ ] Feature imported from correct path
|
|
193
|
+
- [ ] Dual image selection implemented
|
|
194
|
+
- [ ] Source/target image labels clear
|
|
195
|
+
- [ ] Both images validated before processing
|
|
196
|
+
- [ ] Confirmation dialog added
|
|
197
|
+
- [ ] Face detection error handling
|
|
198
|
+
- [ ] Progress indicator during processing
|
|
199
|
+
- [ ] Result preview before saving
|
|
200
|
+
- [ ] Error display with user-friendly message
|
|
201
|
+
- [ ] Consent mechanism in place
|
|
202
|
+
- [ ] Cleanup on unmount
|
|
203
|
+
- [ ] Content moderation configured
|
|
204
|
+
|
|
205
|
+
---
|
|
88
206
|
|
|
89
|
-
|
|
207
|
+
## 🛠️ Configuration Strategy
|
|
90
208
|
|
|
91
|
-
|
|
92
|
-
import { AIFeatureScreen } from '@umituz/react-native-ai-generation-content';
|
|
209
|
+
### Essential Configuration
|
|
93
210
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
211
|
+
```typescript
|
|
212
|
+
// Required fields
|
|
213
|
+
{
|
|
214
|
+
userId: string // User identifier for tracking
|
|
215
|
+
onSelectSourceImage: () => Promise<string | null>
|
|
216
|
+
onSelectTargetImage: () => Promise<string | null>
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// Optional callbacks
|
|
220
|
+
{
|
|
221
|
+
onProcessingStart?: () => void
|
|
222
|
+
onProcessingComplete?: (result) => void
|
|
223
|
+
onError?: (error: string) => void
|
|
101
224
|
}
|
|
102
225
|
```
|
|
103
226
|
|
|
104
|
-
|
|
227
|
+
### Recommended Settings
|
|
228
|
+
|
|
229
|
+
1. **Image Quality**
|
|
230
|
+
- Minimum: 512x512 resolution
|
|
231
|
+
- Recommended: 1024x1024 or higher
|
|
232
|
+
- Format: JPEG or PNG
|
|
233
|
+
- Max size: 10MB per image
|
|
234
|
+
|
|
235
|
+
2. **Processing Options**
|
|
236
|
+
- enhanceFace: true (sharpen facial features)
|
|
237
|
+
- matchSkinTone: true (natural skin tone blending)
|
|
238
|
+
|
|
239
|
+
3. **Performance Settings**
|
|
240
|
+
- Compress images before upload
|
|
241
|
+
- Show progress for long operations
|
|
242
|
+
- Implement timeout (60s default)
|
|
105
243
|
|
|
106
|
-
|
|
244
|
+
---
|
|
107
245
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
246
|
+
## 📊 State Management
|
|
247
|
+
|
|
248
|
+
### Feature States
|
|
249
|
+
|
|
250
|
+
**isReady**: boolean
|
|
251
|
+
- Both images selected and validated
|
|
252
|
+
- Check before enabling swap button
|
|
253
|
+
|
|
254
|
+
**isProcessing**: boolean
|
|
255
|
+
- Face swap in progress
|
|
256
|
+
- Show loading indicator
|
|
257
|
+
- Disable all buttons
|
|
258
|
+
|
|
259
|
+
**progress**: number (0-100)
|
|
260
|
+
- Processing progress percentage
|
|
261
|
+
- Update progress bar
|
|
262
|
+
|
|
263
|
+
**error**: string | null
|
|
264
|
+
- Error message if processing failed
|
|
265
|
+
- Common errors: "No face found in source image", "No face found in target image"
|
|
266
|
+
|
|
267
|
+
**result**: {
|
|
268
|
+
imageUrl: string
|
|
269
|
+
metadata?: any
|
|
117
270
|
}
|
|
118
|
-
```
|
|
119
271
|
|
|
120
|
-
|
|
272
|
+
---
|
|
121
273
|
|
|
122
|
-
|
|
123
|
-
2. Select **Target Image** - Image containing the face to swap TO
|
|
124
|
-
3. Tap **Swap Faces** - Start the face swap process
|
|
125
|
-
4. View Result - See the face-swapped image
|
|
126
|
-
5. Save or Share - Save to gallery or share with others
|
|
274
|
+
## 🔐 Ethics & Privacy
|
|
127
275
|
|
|
128
|
-
|
|
276
|
+
### Consent Requirements
|
|
129
277
|
|
|
130
|
-
|
|
278
|
+
- **MUST** obtain explicit consent from all subjects
|
|
279
|
+
- **MUST** provide clear explanation of how faces will be used
|
|
280
|
+
- **MUST** implement age verification
|
|
281
|
+
- **MUST** allow subjects to opt-out
|
|
131
282
|
|
|
132
|
-
|
|
133
|
-
import { DualImagePicker } from '@umituz/react-native-ai-generation-content';
|
|
283
|
+
### Content Moderation
|
|
134
284
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
onSelectTargetImage={handleSelectTarget}
|
|
140
|
-
sourceLabel="Face to Use"
|
|
141
|
-
targetLabel="Face to Replace"
|
|
142
|
-
/>
|
|
143
|
-
```
|
|
285
|
+
- **MUST** filter inappropriate content
|
|
286
|
+
- **MUST** prevent malicious use cases
|
|
287
|
+
- **MUST** implement reporting mechanism
|
|
288
|
+
- **MUST** review flagged content
|
|
144
289
|
|
|
145
|
-
###
|
|
290
|
+
### Usage Guidelines
|
|
146
291
|
|
|
147
|
-
|
|
148
|
-
|
|
292
|
+
- **MUST** provide terms of service
|
|
293
|
+
- **MUST** clearly label face-swapped content
|
|
294
|
+
- **MUST** prevent deception/fraud
|
|
295
|
+
- **MUST** comply with deepfake regulations
|
|
149
296
|
|
|
150
|
-
|
|
151
|
-
<ResultImageCard
|
|
152
|
-
imageUrl={feature.state.result.imageUrl}
|
|
153
|
-
onSave={() => feature.saveResult()}
|
|
154
|
-
onShare={() => shareImage(feature.state.result.imageUrl)}
|
|
155
|
-
/>
|
|
156
|
-
)}
|
|
157
|
-
```
|
|
297
|
+
---
|
|
158
298
|
|
|
159
|
-
##
|
|
299
|
+
## 🎨 Best Practices
|
|
160
300
|
|
|
161
|
-
###
|
|
301
|
+
### Image Selection
|
|
162
302
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
defaultOptions: {
|
|
167
|
-
enhanceFace: true,
|
|
168
|
-
matchSkinTone: true,
|
|
169
|
-
},
|
|
170
|
-
},
|
|
171
|
-
// ... other props
|
|
172
|
-
});
|
|
173
|
-
```
|
|
303
|
+
1. **Face Visibility**
|
|
304
|
+
- Good: Clear, frontal face shots
|
|
305
|
+
- Bad: Occluded or profile faces
|
|
174
306
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
const feature = useFaceSwapFeature({
|
|
179
|
-
config: { ... },
|
|
180
|
-
onBeforeProcess: async () => {
|
|
181
|
-
// Show confirmation dialog
|
|
182
|
-
return new Promise((resolve) => {
|
|
183
|
-
Alert.alert(
|
|
184
|
-
'Confirm Face Swap',
|
|
185
|
-
'Do you want to proceed with face swap?',
|
|
186
|
-
[
|
|
187
|
-
{ text: 'Cancel', onPress: () => resolve(false) },
|
|
188
|
-
{ text: 'OK', onPress: () => resolve(true) },
|
|
189
|
-
]
|
|
190
|
-
);
|
|
191
|
-
});
|
|
192
|
-
},
|
|
193
|
-
// ... other props
|
|
194
|
-
});
|
|
195
|
-
```
|
|
307
|
+
2. **Lighting**
|
|
308
|
+
- Similar lighting conditions work best
|
|
309
|
+
- Front-facing well-lit photos ideal
|
|
196
310
|
|
|
197
|
-
|
|
311
|
+
3. **Image Quality**
|
|
312
|
+
- Higher resolution = better results
|
|
313
|
+
- Minimum 512x512 recommended
|
|
198
314
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
4. **Lighting**: Similar lighting conditions produce more natural results
|
|
203
|
-
5. **Multiple Faces**: The feature can handle multiple faces in one image
|
|
315
|
+
4. **Multiple Faces**
|
|
316
|
+
- Feature handles multiple faces
|
|
317
|
+
- Warn users about all faces being swapped
|
|
204
318
|
|
|
205
|
-
|
|
319
|
+
### User Experience
|
|
206
320
|
|
|
207
|
-
|
|
208
|
-
|
|
321
|
+
1. **Clear UI**
|
|
322
|
+
- Label source vs target clearly
|
|
323
|
+
- Show preview before processing
|
|
324
|
+
- Add confirmation dialog
|
|
209
325
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
}, [state.error]);
|
|
215
|
-
```
|
|
326
|
+
2. **Error Handling**
|
|
327
|
+
- Explain "no face found" errors
|
|
328
|
+
- Provide troubleshooting tips
|
|
329
|
+
- Offer retry option
|
|
216
330
|
|
|
217
|
-
|
|
331
|
+
3. **Performance**
|
|
332
|
+
- Compress images before upload
|
|
333
|
+
- Show progress for long operations
|
|
334
|
+
- Cache results for re-download
|
|
218
335
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
336
|
+
---
|
|
337
|
+
|
|
338
|
+
## 🐛 Common Pitfalls
|
|
339
|
+
|
|
340
|
+
### Face Detection Issues
|
|
341
|
+
|
|
342
|
+
❌ **Problem**: "No face found" error
|
|
343
|
+
✅ **Solution**: Ensure faces are clearly visible, well-lit, frontal
|
|
344
|
+
|
|
345
|
+
### Image Quality Issues
|
|
346
|
+
|
|
347
|
+
❌ **Problem**: Poor quality results
|
|
348
|
+
✅ **Solution**: Use higher resolution images, better lighting
|
|
349
|
+
|
|
350
|
+
### UX Confusion
|
|
351
|
+
|
|
352
|
+
❌ **Problem**: Users confused about which face is which
|
|
353
|
+
✅ **Solution**: Clear labels, visual indicators, preview
|
|
354
|
+
|
|
355
|
+
### Privacy Concerns
|
|
356
|
+
|
|
357
|
+
❌ **Problem**: Non-consensual face swapping
|
|
358
|
+
✅ **Solution**: Implement consent mechanisms, age verification
|
|
359
|
+
|
|
360
|
+
---
|
|
361
|
+
|
|
362
|
+
## 📦 Related Components
|
|
363
|
+
|
|
364
|
+
Use these components from the library:
|
|
365
|
+
|
|
366
|
+
- **DualImagePicker**: Select two images
|
|
367
|
+
- **ResultImageCard**: Display face swap result
|
|
368
|
+
- **ConfirmationDialog**: Confirm before processing
|
|
369
|
+
- **FaceDetectionOverlay**: Show detected faces
|
|
370
|
+
|
|
371
|
+
Located at: `src/presentation/components/`
|
|
372
|
+
|
|
373
|
+
---
|
|
374
|
+
|
|
375
|
+
## 🔄 Migration Strategy
|
|
376
|
+
|
|
377
|
+
If migrating from previous implementation:
|
|
378
|
+
|
|
379
|
+
1. **Update imports** to new path
|
|
380
|
+
2. **Add dual image selection** (source + target)
|
|
381
|
+
3. **Implement consent mechanism**
|
|
382
|
+
4. **Update state handling** for both images
|
|
383
|
+
5. **Add confirmation dialog**
|
|
384
|
+
6. **Test all error cases**
|
|
385
|
+
|
|
386
|
+
---
|
|
387
|
+
|
|
388
|
+
## ⚖️ Legal Considerations
|
|
389
|
+
|
|
390
|
+
### Compliance
|
|
391
|
+
|
|
392
|
+
- **Deepfake Regulations**: Comply with local laws
|
|
393
|
+
- **Privacy Laws**: GDPR, CCPA compliance
|
|
394
|
+
- **Consent Requirements**: Explicit permission needed
|
|
395
|
+
- **Age Restrictions**: Verify adult subjects
|
|
396
|
+
- **Content Labeling**: Mark as AI-generated
|
|
397
|
+
|
|
398
|
+
### Best Practices
|
|
399
|
+
|
|
400
|
+
- Provide attribution for source images
|
|
401
|
+
- Allow content reporting/flagging
|
|
402
|
+
- Implement audit trail logging
|
|
403
|
+
- Cooperate with takedown requests
|
|
404
|
+
|
|
405
|
+
---
|
|
406
|
+
|
|
407
|
+
## 📚 Additional Resources
|
|
408
|
+
|
|
409
|
+
- Main documentation: `/docs/`
|
|
410
|
+
- API reference: `/docs/api/`
|
|
411
|
+
- Examples: `/docs/examples/basic/face-swap/`
|
|
412
|
+
- Ethics guidelines: `/docs/ethics.md`
|
|
413
|
+
|
|
414
|
+
---
|
|
415
|
+
|
|
416
|
+
**Last Updated**: 2025-01-08
|
|
417
|
+
**Version**: 2.0.0 (Strategy-based Documentation)
|
|
224
418
|
|
|
225
|
-
|
|
419
|
+
---
|
|
226
420
|
|
|
227
|
-
|
|
228
|
-
- [AI Kiss](../ai-kiss) - Generate AI kiss images
|
|
229
|
-
- [Photo Restoration](../photo-restoration) - Restore old photos
|
|
230
|
-
- [Anime Selfie](../anime-selfie) - Convert photos to anime style
|
|
421
|
+
## 📝 Changelog
|
|
231
422
|
|
|
232
|
-
|
|
423
|
+
### v2.0.0 - 2025-01-08
|
|
424
|
+
- **BREAKING**: Documentation format changed to strategy-based
|
|
425
|
+
- Removed extensive code examples
|
|
426
|
+
- Added ethics and privacy guidelines
|
|
427
|
+
- Added rules, prohibitions, and AI agent directions
|
|
428
|
+
- Focus on responsible AI usage
|
|
233
429
|
|
|
234
|
-
|
|
430
|
+
### v1.0.0 - Initial Release
|
|
431
|
+
- Initial feature documentation
|
|
@@ -1,228 +1,394 @@
|
|
|
1
|
-
# Text to Image
|
|
1
|
+
# Text to Image Feature
|
|
2
2
|
|
|
3
|
-
Generate images from text prompts using AI.
|
|
3
|
+
Generate images from text prompts using AI models.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## 📍 Import Path
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
- Multiple image generation in one request
|
|
11
|
-
- Progress tracking during generation
|
|
7
|
+
```typescript
|
|
8
|
+
import { useTextToImageFeature } from '@umituz/react-native-ai-generation-content';
|
|
9
|
+
```
|
|
12
10
|
|
|
13
|
-
|
|
11
|
+
**Location**: `src/features/text-to-image/`
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
## 🎯 Feature Purpose
|
|
16
14
|
|
|
17
|
-
|
|
18
|
-
npm install @umituz/react-native-ai-generation-content
|
|
19
|
-
```
|
|
15
|
+
Convert natural language text descriptions into AI-generated images. Supports various aspect ratios, styles, and quality settings.
|
|
20
16
|
|
|
21
|
-
|
|
17
|
+
---
|
|
22
18
|
|
|
23
|
-
|
|
19
|
+
## 📋 Usage Strategy
|
|
24
20
|
|
|
25
|
-
|
|
26
|
-
import { useTextToImageFeature } from '@umituz/react-native-ai-generation-content';
|
|
21
|
+
### When to Use This Feature
|
|
27
22
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
onError: (error) => console.error('Error:', error),
|
|
36
|
-
},
|
|
37
|
-
userId: 'user-123',
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
return (
|
|
41
|
-
<View>
|
|
42
|
-
<TextInput
|
|
43
|
-
placeholder="Describe the image you want to create..."
|
|
44
|
-
onChangeText={feature.setPrompt}
|
|
45
|
-
value={feature.state.prompt}
|
|
46
|
-
/>
|
|
47
|
-
|
|
48
|
-
<Button
|
|
49
|
-
title="Generate Image"
|
|
50
|
-
onPress={() => feature.generate()}
|
|
51
|
-
disabled={!feature.isReady}
|
|
52
|
-
/>
|
|
53
|
-
|
|
54
|
-
{feature.state.isProcessing && (
|
|
55
|
-
<Text>Progress: {feature.state.progress}%</Text>
|
|
56
|
-
)}
|
|
57
|
-
|
|
58
|
-
{feature.state.imageUrl && (
|
|
59
|
-
<Image source={{ uri: feature.state.imageUrl }} />
|
|
60
|
-
)}
|
|
61
|
-
|
|
62
|
-
{feature.state.error && (
|
|
63
|
-
<Text>Error: {feature.state.error}</Text>
|
|
64
|
-
)}
|
|
65
|
-
</View>
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
```
|
|
23
|
+
✅ **Use Cases:**
|
|
24
|
+
- Generating original images from text descriptions
|
|
25
|
+
- Creating visual content for marketing materials
|
|
26
|
+
- Generating concept art and prototypes
|
|
27
|
+
- Creating social media visuals
|
|
28
|
+
- Product visualization from descriptions
|
|
29
|
+
- Storyboarding and creative planning
|
|
69
30
|
|
|
70
|
-
|
|
31
|
+
❌ **When NOT to Use:**
|
|
32
|
+
- Image manipulation of existing photos (use Image-to-Image)
|
|
33
|
+
- Photo restoration (use Photo Restoration)
|
|
34
|
+
- Style transfer on existing images (use Style Transfer)
|
|
35
|
+
- Face swapping (use Face Swap)
|
|
71
36
|
|
|
72
|
-
|
|
73
|
-
import { AIFeatureScreen } from '@umituz/react-native-ai-generation-content';
|
|
37
|
+
### Implementation Strategy
|
|
74
38
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
/>
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
```
|
|
39
|
+
1. **Use the feature hook** at component level
|
|
40
|
+
2. **Initialize with config** before first render
|
|
41
|
+
3. **Handle all states** - loading, success, error
|
|
42
|
+
4. **Implement progress tracking** for better UX
|
|
43
|
+
5. **Store generated images** for later use
|
|
84
44
|
|
|
85
|
-
|
|
45
|
+
---
|
|
86
46
|
|
|
87
|
-
|
|
47
|
+
## ⚠️ Critical Rules (MUST FOLLOW)
|
|
88
48
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
onError?: (error: string) => void;
|
|
96
|
-
buildInput?: (prompt: string, options: TextToImageOptions) => any;
|
|
97
|
-
extractResult?: (response: any) => TextToImageResult;
|
|
98
|
-
}
|
|
99
|
-
```
|
|
49
|
+
### 1. Prompt Engineering
|
|
50
|
+
- **MUST** use descriptive, specific prompts
|
|
51
|
+
- **MUST** include subject, action, and context
|
|
52
|
+
- **MUST** specify art style if important
|
|
53
|
+
- **MUST** use English for best results
|
|
54
|
+
- **MUST NOT** exceed character limits (check model limits)
|
|
100
55
|
|
|
101
|
-
###
|
|
56
|
+
### 2. Configuration
|
|
57
|
+
- **MUST** provide valid `userId` for tracking
|
|
58
|
+
- **MUST** implement `onError` callback
|
|
59
|
+
- **MUST** handle `isProcessing` state to prevent duplicate requests
|
|
60
|
+
- **MUST** validate prompts before generation
|
|
61
|
+
- **MUST NOT** call `generate()` when `isReady` is false
|
|
62
|
+
|
|
63
|
+
### 3. State Management
|
|
64
|
+
- **MUST** check `isReady` before enabling generate button
|
|
65
|
+
- **MUST** handle `isProcessing` state with loading indicators
|
|
66
|
+
- **MUST** display `error` state to users
|
|
67
|
+
- **MUST** handle `result.imageUrl` existence check
|
|
68
|
+
- **MUST** implement proper cleanup on unmount
|
|
69
|
+
|
|
70
|
+
### 4. Performance
|
|
71
|
+
- **MUST** implement debouncing for prompt inputs (>500ms)
|
|
72
|
+
- **MUST** limit concurrent requests (max 1 per user)
|
|
73
|
+
- **MUST** cache generated images locally
|
|
74
|
+
- **MUST** implement retry logic (max 3 attempts)
|
|
75
|
+
- **MUST NOT** generate multiple images simultaneously
|
|
76
|
+
|
|
77
|
+
### 5. Security & Privacy
|
|
78
|
+
- **MUST** validate and sanitize user prompts
|
|
79
|
+
- **MUST** implement content moderation
|
|
80
|
+
- **MUST** check for inappropriate content
|
|
81
|
+
- **MUST** store userId securely
|
|
82
|
+
- **MUST NOT** expose API keys in client code
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## 🚫 Prohibitions (MUST AVOID)
|
|
87
|
+
|
|
88
|
+
### Strictly Forbidden
|
|
89
|
+
|
|
90
|
+
❌ **NEVER** do the following:
|
|
91
|
+
|
|
92
|
+
1. **No Empty Prompts**
|
|
93
|
+
- Always validate prompt has meaningful content
|
|
94
|
+
- Minimum 10 characters recommended
|
|
95
|
+
|
|
96
|
+
2. **No Concurrent Generation**
|
|
97
|
+
- Never call `generate()` while `isProcessing === true`
|
|
98
|
+
- Always disable generate button during processing
|
|
99
|
+
|
|
100
|
+
3. **No Hardcoded Credentials**
|
|
101
|
+
- Never store API keys in component files
|
|
102
|
+
- Use environment variables or secure storage
|
|
103
|
+
|
|
104
|
+
4. **No Unhandled Errors**
|
|
105
|
+
- Never ignore error states
|
|
106
|
+
- Always implement error boundaries
|
|
107
|
+
|
|
108
|
+
5. **No Memory Leaks**
|
|
109
|
+
- Never forget cleanup on unmount
|
|
110
|
+
- Always cancel pending requests
|
|
111
|
+
|
|
112
|
+
6. **No Excessive Re-renders**
|
|
113
|
+
- Never pass new config objects on each render
|
|
114
|
+
- Always memoize configuration objects
|
|
115
|
+
|
|
116
|
+
7. **No Blocked Main Thread**
|
|
117
|
+
- Never perform heavy operations in render
|
|
118
|
+
- Use web workers or background tasks for processing
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## 🤖 AI Agent Directions
|
|
123
|
+
|
|
124
|
+
### For AI Code Generation Tools
|
|
125
|
+
|
|
126
|
+
When using this feature with AI code generation tools, follow these guidelines:
|
|
127
|
+
|
|
128
|
+
#### Prompt Template for AI Agents
|
|
102
129
|
|
|
103
|
-
```tsx
|
|
104
|
-
interface TextToImageOptions {
|
|
105
|
-
aspectRatio?: '1:1' | '16:9' | '9:16' | '4:3' | '3:4';
|
|
106
|
-
numberOfImages?: number; // 1-4
|
|
107
|
-
style?: 'realistic' | 'artistic' | 'anime' | '3d' | 'painting';
|
|
108
|
-
negativePrompt?: string;
|
|
109
|
-
}
|
|
110
130
|
```
|
|
131
|
+
You are implementing a text-to-image generation feature using @umituz/react-native-ai-generation-content.
|
|
132
|
+
|
|
133
|
+
REQUIREMENTS:
|
|
134
|
+
1. Import from: @umituz/react-native-ai-generation-content
|
|
135
|
+
2. Use the useTextToImageFeature hook
|
|
136
|
+
3. Implement all state handlers (loading, success, error)
|
|
137
|
+
4. Add debouncing for prompt input
|
|
138
|
+
5. Validate prompts before generation
|
|
139
|
+
6. Handle isReady and isProcessing states correctly
|
|
140
|
+
7. Implement proper error handling with user feedback
|
|
141
|
+
8. Add loading indicators during generation
|
|
142
|
+
9. Display results safely with null checks
|
|
143
|
+
10. Implement cleanup on unmount
|
|
144
|
+
|
|
145
|
+
CRITICAL RULES:
|
|
146
|
+
- NEVER call generate() when isProcessing is true
|
|
147
|
+
- ALWAYS validate prompt before calling generate()
|
|
148
|
+
- MUST handle error state with user-friendly message
|
|
149
|
+
- MUST disable generate button during processing
|
|
150
|
+
- MUST implement debouncing (500ms minimum)
|
|
151
|
+
|
|
152
|
+
CONFIGURATION:
|
|
153
|
+
- Provide valid userId (string)
|
|
154
|
+
- Set model (default: 'imagen-3')
|
|
155
|
+
- Configure callbacks: onProcessingStart, onProcessingComplete, onError
|
|
156
|
+
|
|
157
|
+
GENERATION OPTIONS:
|
|
158
|
+
- aspectRatio: '1:1' | '16:9' | '9:16' | '4:3' | '3:4'
|
|
159
|
+
- numberOfImages: 1-4
|
|
160
|
+
- style: 'realistic' | 'artistic' | 'anime' | '3d' | 'painting'
|
|
161
|
+
- negativePrompt: string (optional)
|
|
162
|
+
|
|
163
|
+
STRICTLY FORBIDDEN:
|
|
164
|
+
- No empty prompts
|
|
165
|
+
- No concurrent generation calls
|
|
166
|
+
- No hardcoded API keys
|
|
167
|
+
- No unhandled errors
|
|
168
|
+
- No memory leaks
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
#### AI Implementation Checklist
|
|
111
172
|
|
|
112
|
-
|
|
173
|
+
Use this checklist when generating code:
|
|
113
174
|
|
|
114
|
-
|
|
175
|
+
- [ ] Feature imported from correct path
|
|
176
|
+
- [ ] Hook initialized with proper config
|
|
177
|
+
- [ ] All state handlers implemented
|
|
178
|
+
- [ ] Debouncing added to input
|
|
179
|
+
- [ ] Validation before generate()
|
|
180
|
+
- [ ] Loading indicator during processing
|
|
181
|
+
- [ ] Error display with user-friendly message
|
|
182
|
+
- [ ] Button disabled when processing
|
|
183
|
+
- [ ] Cleanup on unmount
|
|
184
|
+
- [ ] Null checks on result
|
|
185
|
+
- [ ] Retry logic implemented
|
|
186
|
+
- [ ] Image caching configured
|
|
115
187
|
|
|
116
|
-
|
|
117
|
-
import { StyleSelector } from '@umituz/react-native-ai-generation-content';
|
|
188
|
+
---
|
|
118
189
|
|
|
119
|
-
|
|
120
|
-
{ id: 'realistic', name: 'Realistic', preview: '...' },
|
|
121
|
-
{ id: 'artistic', name: 'Artistic', preview: '...' },
|
|
122
|
-
{ id: 'anime', name: 'Anime', preview: '...' },
|
|
123
|
-
];
|
|
190
|
+
## 🛠️ Configuration Strategy
|
|
124
191
|
|
|
125
|
-
|
|
126
|
-
const [selectedStyle, setSelectedStyle] = useState('realistic');
|
|
192
|
+
### Essential Configuration
|
|
127
193
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
194
|
+
```typescript
|
|
195
|
+
// Required fields
|
|
196
|
+
{
|
|
197
|
+
userId: string // User identifier for tracking
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// Optional callbacks
|
|
201
|
+
{
|
|
202
|
+
onProcessingStart?: () => void
|
|
203
|
+
onProcessingComplete?: (result) => void
|
|
204
|
+
onError?: (error: string) => void
|
|
135
205
|
}
|
|
136
206
|
```
|
|
137
207
|
|
|
138
|
-
###
|
|
208
|
+
### Recommended Settings
|
|
209
|
+
|
|
210
|
+
1. **Model Selection**
|
|
211
|
+
- Default: `imagen-3`
|
|
212
|
+
- Fastest: `imagen-2-fast`
|
|
213
|
+
- Highest quality: `imagen-3`
|
|
214
|
+
|
|
215
|
+
2. **Generation Options**
|
|
216
|
+
- Aspect Ratio: Match your UI layout
|
|
217
|
+
- Number of Images: 1-2 for speed, 3-4 for variety
|
|
218
|
+
- Style: Choose based on use case
|
|
219
|
+
|
|
220
|
+
3. **Performance Settings**
|
|
221
|
+
- Enable image caching
|
|
222
|
+
- Set reasonable timeouts (30s default)
|
|
223
|
+
- Implement retry with backoff
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
## 📊 State Management
|
|
139
228
|
|
|
140
|
-
|
|
141
|
-
import { AspectRatioSelector } from '@umituz/react-native-ai-generation-content';
|
|
229
|
+
### Feature States
|
|
142
230
|
|
|
143
|
-
|
|
144
|
-
|
|
231
|
+
**isReady**: boolean
|
|
232
|
+
- Feature initialized and ready to use
|
|
233
|
+
- Check before enabling generate button
|
|
145
234
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
235
|
+
**isProcessing**: boolean
|
|
236
|
+
- Generation in progress
|
|
237
|
+
- Show loading indicator
|
|
238
|
+
- Disable generate button
|
|
239
|
+
|
|
240
|
+
**progress**: number (0-100)
|
|
241
|
+
- Generation progress percentage
|
|
242
|
+
- Update progress bar
|
|
243
|
+
|
|
244
|
+
**error**: string | null
|
|
245
|
+
- Error message if generation failed
|
|
246
|
+
- Display to user with clear message
|
|
247
|
+
|
|
248
|
+
**result**: {
|
|
249
|
+
imageUrl: string
|
|
250
|
+
imageUrls?: string[]
|
|
251
|
+
metadata?: any
|
|
152
252
|
}
|
|
153
|
-
```
|
|
154
253
|
|
|
155
|
-
|
|
254
|
+
---
|
|
156
255
|
|
|
157
|
-
|
|
256
|
+
## 🔐 Security Considerations
|
|
158
257
|
|
|
159
|
-
|
|
160
|
-
const result = await feature.generate({
|
|
161
|
-
aspectRatio: '16:9',
|
|
162
|
-
numberOfImages: 2,
|
|
163
|
-
});
|
|
164
|
-
```
|
|
258
|
+
### Content Moderation
|
|
165
259
|
|
|
166
|
-
|
|
260
|
+
- **MUST** implement prompt content filtering
|
|
261
|
+
- **MUST** check for inappropriate content
|
|
262
|
+
- **MUST** block harmful or illegal prompts
|
|
263
|
+
- **MUST** log moderation actions
|
|
167
264
|
|
|
168
|
-
|
|
169
|
-
const result = await feature.generate({
|
|
170
|
-
style: 'artistic',
|
|
171
|
-
negativePrompt: 'blurry, low quality',
|
|
172
|
-
});
|
|
173
|
-
```
|
|
265
|
+
### API Security
|
|
174
266
|
|
|
175
|
-
|
|
267
|
+
- **MUST** use environment variables for API keys
|
|
268
|
+
- **MUST** implement rate limiting
|
|
269
|
+
- **MUST** validate all user inputs
|
|
270
|
+
- **MUST** use HTTPS for all API calls
|
|
176
271
|
|
|
177
|
-
|
|
178
|
-
const result = await feature.generate({
|
|
179
|
-
numberOfImages: 4,
|
|
180
|
-
});
|
|
272
|
+
### Data Privacy
|
|
181
273
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
```
|
|
274
|
+
- **MUST** comply with data protection regulations
|
|
275
|
+
- **MUST** obtain user consent for generation
|
|
276
|
+
- **MUST** provide privacy policy
|
|
277
|
+
- **MUST** allow data deletion requests
|
|
187
278
|
|
|
188
|
-
|
|
279
|
+
---
|
|
189
280
|
|
|
190
|
-
|
|
191
|
-
const examplePrompts = [
|
|
192
|
-
'A beautiful sunset over mountains with vibrant colors',
|
|
193
|
-
'Futuristic cityscape at night with neon lights',
|
|
194
|
-
'Enchanted forest with magical glowing mushrooms',
|
|
195
|
-
'Cozy coffee shop interior on a rainy day',
|
|
196
|
-
'Dragon flying over snow-capped mountain peaks',
|
|
197
|
-
];
|
|
198
|
-
```
|
|
281
|
+
## 🎨 Best Practices
|
|
199
282
|
|
|
200
|
-
|
|
283
|
+
### Prompt Engineering
|
|
201
284
|
|
|
202
|
-
|
|
203
|
-
|
|
285
|
+
1. **Be Specific**
|
|
286
|
+
- Good: "A majestic lion standing on a rock at sunset, detailed fur, dramatic lighting"
|
|
287
|
+
- Bad: "A lion"
|
|
204
288
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
289
|
+
2. **Include Style**
|
|
290
|
+
- Specify art style, mood, atmosphere
|
|
291
|
+
- Example: "in the style of oil painting, romantic mood"
|
|
292
|
+
|
|
293
|
+
3. **Add Technical Details**
|
|
294
|
+
- Lighting, camera angle, composition
|
|
295
|
+
- Example: "golden hour lighting, wide angle shot"
|
|
296
|
+
|
|
297
|
+
4. **Use Negative Prompts**
|
|
298
|
+
- Specify what to avoid
|
|
299
|
+
- Example: "blurry, low quality, distorted"
|
|
300
|
+
|
|
301
|
+
### Performance Optimization
|
|
302
|
+
|
|
303
|
+
1. **Debounce Input**
|
|
304
|
+
- Wait 500ms after user stops typing
|
|
305
|
+
- Prevents unnecessary validations
|
|
306
|
+
|
|
307
|
+
2. **Lazy Loading**
|
|
308
|
+
- Load images on demand
|
|
309
|
+
- Use pagination for multiple results
|
|
310
|
+
|
|
311
|
+
3. **Cache Results**
|
|
312
|
+
- Store generated images locally
|
|
313
|
+
- Implement cache invalidation strategy
|
|
314
|
+
|
|
315
|
+
4. **Progressive Enhancement**
|
|
316
|
+
- Show placeholder while loading
|
|
317
|
+
- Display low-res first, then high-res
|
|
318
|
+
|
|
319
|
+
---
|
|
320
|
+
|
|
321
|
+
## 🐛 Common Pitfalls
|
|
322
|
+
|
|
323
|
+
### Memory Issues
|
|
324
|
+
|
|
325
|
+
❌ **Problem**: Storing all generated images in state
|
|
326
|
+
✅ **Solution**: Implement pagination or virtualized lists
|
|
327
|
+
|
|
328
|
+
### Performance Issues
|
|
329
|
+
|
|
330
|
+
❌ **Problem**: Re-generating on every prompt change
|
|
331
|
+
✅ **Solution**: Require explicit user action to generate
|
|
332
|
+
|
|
333
|
+
### UX Issues
|
|
334
|
+
|
|
335
|
+
❌ **Problem**: No feedback during generation
|
|
336
|
+
✅ **Solution**: Always show progress indicator
|
|
337
|
+
|
|
338
|
+
### Error Handling
|
|
339
|
+
|
|
340
|
+
❌ **Problem**: Generic error messages
|
|
341
|
+
✅ **Solution**: Provide specific, actionable error messages
|
|
342
|
+
|
|
343
|
+
---
|
|
344
|
+
|
|
345
|
+
## 📦 Related Components
|
|
346
|
+
|
|
347
|
+
Use these components from the library:
|
|
348
|
+
|
|
349
|
+
- **GenerationProgressModal**: Progress display
|
|
350
|
+
- **StyleSelector**: Style selection UI
|
|
351
|
+
- **AspectRatioSelector**: Aspect ratio picker
|
|
352
|
+
- **ImageGallery**: Display multiple results
|
|
353
|
+
- **PromptInput**: Enhanced text input
|
|
354
|
+
|
|
355
|
+
Located at: `src/presentation/components/`
|
|
356
|
+
|
|
357
|
+
---
|
|
358
|
+
|
|
359
|
+
## 🔄 Migration Strategy
|
|
360
|
+
|
|
361
|
+
If migrating from previous implementation:
|
|
362
|
+
|
|
363
|
+
1. **Update imports** to new path
|
|
364
|
+
2. **Replace old config** with new structure
|
|
365
|
+
3. **Update state handling** to match new interface
|
|
366
|
+
4. **Test all error cases**
|
|
367
|
+
5. **Update UI components** for new state structure
|
|
368
|
+
|
|
369
|
+
---
|
|
370
|
+
|
|
371
|
+
## 📚 Additional Resources
|
|
372
|
+
|
|
373
|
+
- Main documentation: `/docs/`
|
|
374
|
+
- API reference: `/docs/api/`
|
|
375
|
+
- Examples: `/docs/examples/basic/text-to-image/`
|
|
376
|
+
- Architecture: `/ARCHITECTURE.md`
|
|
211
377
|
|
|
212
|
-
|
|
378
|
+
---
|
|
213
379
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
3. **Batch Generation**: Generate multiple images to get more options
|
|
217
|
-
4. **Negative Prompts**: Use negative prompts to avoid unwanted elements
|
|
218
|
-
5. **Error Handling**: Always handle errors gracefully in production
|
|
380
|
+
**Last Updated**: 2025-01-08
|
|
381
|
+
**Version**: 2.0.0 (Strategy-based Documentation)
|
|
219
382
|
|
|
220
|
-
|
|
383
|
+
---
|
|
221
384
|
|
|
222
|
-
|
|
223
|
-
- [Image to Image](../image-to-image) - Transform images with AI
|
|
224
|
-
- [Style Transfer](../style-transfer) - Apply artistic styles to images
|
|
385
|
+
## 📝 Changelog
|
|
225
386
|
|
|
226
|
-
|
|
387
|
+
### v2.0.0 - 2025-01-08
|
|
388
|
+
- **BREAKING**: Documentation format changed to strategy-based
|
|
389
|
+
- Removed extensive code examples
|
|
390
|
+
- Added rules, prohibitions, and AI agent directions
|
|
391
|
+
- Focus on best practices and implementation guidance
|
|
227
392
|
|
|
228
|
-
|
|
393
|
+
### v1.0.0 - Initial Release
|
|
394
|
+
- Initial feature documentation
|
|
@@ -43,12 +43,7 @@ export const ResultStoryCard: React.FC<ResultStoryCardProps> = ({
|
|
|
43
43
|
...base,
|
|
44
44
|
backgroundColor: tokens.colors.primaryContainer,
|
|
45
45
|
};
|
|
46
|
-
|
|
47
|
-
return {
|
|
48
|
-
...base,
|
|
49
|
-
backgroundColor: tokens.colors.primaryContainer,
|
|
50
|
-
};
|
|
51
|
-
}
|
|
46
|
+
|
|
52
47
|
|
|
53
48
|
return {
|
|
54
49
|
...base,
|
|
@@ -34,7 +34,7 @@ export interface ResultImageConfig {
|
|
|
34
34
|
borderRadius?: number;
|
|
35
35
|
showBadge?: boolean;
|
|
36
36
|
badgePosition?: "top-left" | "top-right" | "bottom-left" | "bottom-right";
|
|
37
|
-
badgeStyle?: "dark" | "light"
|
|
37
|
+
badgeStyle?: "dark" | "light";
|
|
38
38
|
badgeIcon?: string;
|
|
39
39
|
spacing?: {
|
|
40
40
|
marginBottom?: number;
|
|
@@ -59,7 +59,7 @@ export interface ResultStoryConfig {
|
|
|
59
59
|
| "700"
|
|
60
60
|
| "800"
|
|
61
61
|
| "900";
|
|
62
|
-
borderStyle?: "outline" | "filled"
|
|
62
|
+
borderStyle?: "outline" | "filled";
|
|
63
63
|
spacing?: {
|
|
64
64
|
marginBottom?: number;
|
|
65
65
|
paddingHorizontal?: number;
|
|
@@ -149,7 +149,7 @@ export const DEFAULT_RESULT_CONFIG: ResultConfig = {
|
|
|
149
149
|
fontSize: 14,
|
|
150
150
|
fontStyle: "italic",
|
|
151
151
|
fontWeight: "500",
|
|
152
|
-
borderStyle: "
|
|
152
|
+
borderStyle: "filled",
|
|
153
153
|
spacing: {
|
|
154
154
|
marginBottom: 20,
|
|
155
155
|
paddingHorizontal: 20,
|