@umituz/react-native-ai-generation-content 1.17.230 → 1.17.232

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-ai-generation-content",
3
- "version": "1.17.230",
3
+ "version": "1.17.232",
4
4
  "description": "Provider-agnostic AI generation orchestration for React Native",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -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
- ## Features
5
+ ## 📍 Import Path
6
6
 
7
- - Swap faces between two images
8
- - Automatic face detection and alignment
9
- - Support for multiple faces in one image
10
- - High-quality output with natural results
7
+ ```typescript
8
+ import { useFaceSwapFeature } from '@umituz/react-native-ai-generation-content';
9
+ ```
11
10
 
12
- ## Installation
11
+ **Location**: `src/features/face-swap/`
13
12
 
14
- This feature is part of `@umituz/react-native-ai-generation-content`.
13
+ ## 🎯 Feature Purpose
15
14
 
16
- ```bash
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
- ## Basic Usage
17
+ ---
21
18
 
22
- ### Using the Hook
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
- ### Using the Unified AI Feature Screen
207
+ ## 🛠️ Configuration Strategy
90
208
 
91
- ```tsx
92
- import { AIFeatureScreen } from '@umituz/react-native-ai-generation-content';
209
+ ### Essential Configuration
93
210
 
94
- function App() {
95
- return (
96
- <AIFeatureScreen
97
- featureId="face-swap"
98
- userId="user-123"
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
- ## Configuration Options
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
- ### Feature Config
244
+ ---
107
245
 
108
- ```tsx
109
- interface FaceSwapFeatureConfig {
110
- defaultOptions?: {
111
- enhanceFace?: boolean; // Enhance face quality (default: true)
112
- matchSkinTone?: boolean; // Match skin tones (default: true)
113
- };
114
- onProcessingStart?: () => void;
115
- onProcessingComplete?: (result: FaceSwapResult) => void;
116
- onError?: (error: string) => void;
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
- ## Usage Flow
272
+ ---
121
273
 
122
- 1. Select **Source Image** - Image containing the face to swap FROM
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
- ## Component Examples
276
+ ### Consent Requirements
129
277
 
130
- ### Using DualImagePicker
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
- ```tsx
133
- import { DualImagePicker } from '@umituz/react-native-ai-generation-content';
283
+ ### Content Moderation
134
284
 
135
- <DualImagePicker
136
- sourceImage={sourceImage}
137
- targetImage={targetImage}
138
- onSelectSourceImage={handleSelectSource}
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
- ### Custom Result Display
290
+ ### Usage Guidelines
146
291
 
147
- ```tsx
148
- import { ResultImageCard } from '@umituz/react-native-ai-generation-content';
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
- {feature.state.result && (
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
- ## Advanced Usage
299
+ ## 🎨 Best Practices
160
300
 
161
- ### Custom Options
301
+ ### Image Selection
162
302
 
163
- ```tsx
164
- const feature = useFaceSwapFeature({
165
- config: {
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
- ### Before Process Hook
176
-
177
- ```tsx
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
- ## Best Practices
311
+ 3. **Image Quality**
312
+ - Higher resolution = better results
313
+ - Minimum 512x512 recommended
198
314
 
199
- 1. **Image Quality**: Use high-quality images for better results
200
- 2. **Face Visibility**: Ensure faces are clearly visible in both images
201
- 3. **Frontal Faces**: Front-facing photos work best
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
- ## Error Handling
319
+ ### User Experience
206
320
 
207
- ```tsx
208
- const { state, process } = useFaceSwapFeature({ ...config });
321
+ 1. **Clear UI**
322
+ - Label source vs target clearly
323
+ - Show preview before processing
324
+ - Add confirmation dialog
209
325
 
210
- useEffect(() => {
211
- if (state.error) {
212
- Alert.alert('Face Swap Failed', state.error);
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
- ## Common Use Cases
331
+ 3. **Performance**
332
+ - Compress images before upload
333
+ - Show progress for long operations
334
+ - Cache results for re-download
218
335
 
219
- - Fun face swaps between friends
220
- - Historical face replacement
221
- - Character face swaps
222
- - Celebrity face swaps
223
- - Movie character transformations
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
- ## Related Features
419
+ ---
226
420
 
227
- - [AI Hug](../ai-hug) - Generate AI hug images
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
- ## License
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
- MIT
430
+ ### v1.0.0 - Initial Release
431
+ - Initial feature documentation