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

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.
Files changed (38) hide show
  1. package/README.md +236 -261
  2. package/package.json +2 -2
  3. package/src/domains/content-moderation/README.md +239 -296
  4. package/src/domains/creations/README.md +242 -325
  5. package/src/domains/face-detection/README.md +228 -307
  6. package/src/domains/prompts/README.md +242 -312
  7. package/src/domains/result-preview/index.ts +8 -0
  8. package/src/domains/result-preview/presentation/components/ResultActionBar.tsx +74 -0
  9. package/src/domains/result-preview/presentation/components/ResultImageCard.tsx +64 -0
  10. package/src/domains/result-preview/presentation/components/ResultPreviewScreen.tsx +101 -0
  11. package/src/domains/result-preview/presentation/components/index.ts +7 -0
  12. package/src/domains/result-preview/presentation/hooks/index.ts +5 -0
  13. package/src/domains/result-preview/presentation/hooks/useResultActions.ts +148 -0
  14. package/src/domains/result-preview/presentation/types/index.ts +5 -0
  15. package/src/domains/result-preview/presentation/types/result-preview.types.ts +146 -0
  16. package/src/features/ai-hug/README.md +381 -219
  17. package/src/features/ai-kiss/README.md +388 -219
  18. package/src/features/anime-selfie/README.md +327 -256
  19. package/src/features/audio-generation/README.md +352 -309
  20. package/src/features/colorization/README.md +332 -228
  21. package/src/features/couple-future/README.md +387 -212
  22. package/src/features/future-prediction/README.md +391 -221
  23. package/src/features/hd-touch-up/README.md +339 -252
  24. package/src/features/image-captioning/README.md +359 -299
  25. package/src/features/image-to-image/README.md +398 -357
  26. package/src/features/image-to-video/README.md +337 -292
  27. package/src/features/inpainting/README.md +348 -244
  28. package/src/features/meme-generator/README.md +350 -269
  29. package/src/features/remove-background/README.md +335 -234
  30. package/src/features/remove-object/README.md +341 -288
  31. package/src/features/replace-background/README.md +353 -236
  32. package/src/features/script-generator/README.md +358 -287
  33. package/src/features/shared/README.md +254 -223
  34. package/src/features/sketch-to-image/README.md +331 -234
  35. package/src/features/style-transfer/README.md +336 -237
  36. package/src/features/text-to-video/README.md +360 -193
  37. package/src/features/text-to-voice/README.md +382 -272
  38. package/src/index.ts +3 -0
@@ -2,44 +2,227 @@
2
2
 
3
3
  Common functionality and utilities shared across multiple AI features.
4
4
 
5
- ## Overview
5
+ ## 📍 Import Path
6
+
7
+ ```typescript
8
+ import {
9
+ useDualImageVideoProcessing,
10
+ DualImagePicker,
11
+ DualVideoPicker
12
+ } from '@umituz/react-native-ai-generation-content';
13
+ ```
14
+
15
+ **Location**: `src/features/shared/`
16
+
17
+ ## 🎯 Shared Purpose
18
+
19
+ Provide reusable components, hooks, and utilities for common AI feature patterns. Focus on dual image/video processing for features requiring two inputs, with shared state management, validation, and error handling.
20
+
21
+ ---
22
+
23
+ ## 📋 Usage Strategy
24
+
25
+ ### When to Use Shared Features
26
+
27
+ ✅ **Use Cases:**
28
+ - Features requiring two images/videos
29
+ - Common state management patterns
30
+ - Shared validation logic
31
+ - Reusable UI components
32
+ - Dual input processing
33
+
34
+ ❌ **When NOT to Use:**
35
+ - Single input features (use feature-specific hooks)
36
+ - Complex custom logic (build custom solution)
37
+ - Feature-specific requirements
38
+
39
+ ### Implementation Strategy
40
+
41
+ 1. **Identify common patterns** across features
42
+ 2. **Use shared hooks** for dual processing
43
+ 3. **Implement validation** consistently
44
+ 4. **Handle errors** uniformly
45
+ 5. **Track progress** with shared UI
46
+ 6. **Reset states** properly
47
+ 7. **Customize** when needed
48
+
49
+ ---
50
+
51
+ ## ⚠️ Critical Rules (MUST FOLLOW)
52
+
53
+ ### 1. Dual Processing
54
+ - **MUST** validate both inputs before processing
55
+ - **MUST** handle missing inputs gracefully
56
+ - **MUST** provide clear input labels
57
+ - **MUST** implement input selection
58
+ - **MUST** check `isReady` before processing
59
+
60
+ ### 2. State Management
61
+ - **MUST** track both inputs independently
62
+ - **MUST** handle processing state
63
+ - **MUST** track progress percentage
64
+ - **MUST** display errors clearly
65
+ - **MUST** reset state properly
66
+
67
+ ### 3. Validation
68
+ - **MUST** validate input types
69
+ - **MUST** check file sizes
70
+ - **MUST** verify input quality
71
+ - **MUST** provide validation feedback
72
+ - **MUST** prevent invalid operations
73
+
74
+ ### 4. User Experience
75
+ - **MUST** provide clear UI labels
76
+ - **MUST** show progress indicators
77
+ - **MUST** handle long operations
78
+ - **MUST** allow cancellation
79
+ - **MUST** confirm before processing
80
+
81
+ ### 5. Error Handling
82
+ - **MUST** handle processing errors
83
+ - **MUST** provide user-friendly messages
84
+ - **MUST** offer retry options
85
+ - **MUST** log errors appropriately
86
+ - **MUST** recover gracefully
87
+
88
+ ---
89
+
90
+ ## 🚫 Prohibitions (MUST AVOID)
91
+
92
+ ### Strictly Forbidden
93
+
94
+ ❌ **NEVER** do the following:
95
+
96
+ 1. **No Missing Validation**
97
+ - Always validate both inputs
98
+ - Never process without checking
99
+ - Provide clear validation messages
6
100
 
7
- This directory contains shared components, hooks, and utilities used by multiple features. It provides reusable implementations for common patterns like dual image/video processing.
101
+ 2. **No Confusing UI**
102
+ - Always label inputs clearly
103
+ - Never mix up source/target
104
+ - Show which input is which
8
105
 
9
- ## Features
106
+ 3. **No Silent Failures**
107
+ - Always explain what went wrong
108
+ - Never fail silently
109
+ - Provide actionable guidance
10
110
 
11
- - **Dual Image/Video Processing**: Shared logic for features that require two inputs
12
- - **Common Hooks**: Reusable hooks for similar feature patterns
13
- - **Type Definitions**: Shared TypeScript types and interfaces
14
- - **Utilities**: Common helper functions
111
+ 4. **No Blocking Operations**
112
+ - Never block main thread
113
+ - Always show progress
114
+ - Allow cancellation
15
115
 
16
- ## Installation
116
+ 5. **No State Leaks**
117
+ - Always cleanup properly
118
+ - Reset state when done
119
+ - Clear temporary data
17
120
 
18
- This is part of `@umituz/react-native-ai-generation-content`.
121
+ 6. **No Missing Context**
122
+ - Always explain what's happening
123
+ - Show current operation
124
+ - Provide progress feedback
125
+
126
+ 7. **No Partial Processing**
127
+ - Always complete or fail cleanly
128
+ - Never leave partial state
129
+ - Handle cancellation properly
130
+
131
+ ---
19
132
 
20
- ```bash
21
- npm install @umituz/react-native-ai-generation-content
133
+ ## 🤖 AI Agent Directions
134
+
135
+ ### For AI Code Generation Tools
136
+
137
+ #### Prompt Template for AI Agents
138
+
139
+ ```
140
+ You are implementing dual image/video processing using @umituz/react-native-ai-generation-content.
141
+
142
+ REQUIREMENTS:
143
+ 1. Import shared processing hooks
144
+ 2. Implement dual input selection
145
+ 3. Validate both inputs
146
+ 4. Handle processing state
147
+ 5. Show progress indicators
148
+ 6. Handle errors gracefully
149
+ 7. Implement confirmation dialog
150
+ 8. Reset state properly
151
+
152
+ CRITICAL RULES:
153
+ - MUST validate both inputs before processing
154
+ - MUST provide clear UI labels
155
+ - MUST handle missing inputs
156
+ - MUST show progress during processing
157
+ - MUST implement error handling
158
+ - MUST allow user cancellation
159
+
160
+ SHARED HOOKS:
161
+ - useDualImageVideoProcessing: Main dual processing hook
162
+ - DualImagePicker: Image selection component
163
+ - DualVideoPicker: Video selection component
164
+
165
+ CONFIGURATION:
166
+ - featureType: 'face-swap' | 'ai-hug' | 'ai-kiss' | etc.
167
+ - inputType: 'image' | 'video'
168
+ - defaultOptions: Feature-specific options
169
+ - onProcessingStart: Callback when processing starts
170
+ - onProcessingComplete: Callback when processing completes
171
+ - onError: Error callback
172
+
173
+ STATE MANAGEMENT:
174
+ - sourceImageOrVideo: First input
175
+ - targetImageOrVideo: Second input
176
+ - isProcessing: Processing state
177
+ - progress: Progress percentage (0-100)
178
+ - error: Error message if failed
179
+ - result: Processing result
180
+ - isReady: Both inputs provided and valid
181
+
182
+ VALIDATION:
183
+ - Check both inputs provided
184
+ - Verify input types match
185
+ - Validate file sizes
186
+ - Check input quality
187
+ - Provide clear feedback
188
+
189
+ STRICTLY FORBIDDEN:
190
+ - No missing validation
191
+ - No confusing UI
192
+ - No silent failures
193
+ - No blocking operations
194
+ - No state leaks
195
+ - No missing context
196
+ - No partial processing
197
+
198
+ QUALITY CHECKLIST:
199
+ - [ ] Both inputs validated
200
+ - [ ] Clear UI labels
201
+ - [ ] Progress tracking
202
+ - [ ] Error handling
203
+ - [ ] Confirmation dialog
204
+ - [ ] State reset
205
+ - [ ] Cancellation support
206
+ - [ ] User feedback
207
+ - [ ] Clean state management
208
+ - [ ] Proper cleanup
22
209
  ```
23
210
 
24
- ## Dual Image/Video Processing
211
+ ---
25
212
 
26
- Many AI features require two images or videos as input (e.g., face swap, AI hug, AI kiss). The dual image/video processing module provides a shared implementation for these features.
213
+ ## 🛠️ Configuration Strategy
27
214
 
28
- ### Data Types
215
+ ### Dual Processing Types
29
216
 
30
- #### DualImageVideoProcessingStartData
217
+ ```typescript
218
+ type DualInputType = 'image' | 'video';
31
219
 
32
- ```tsx
33
220
  interface DualImageVideoProcessingStartData {
34
- sourceImageOrVideo: string; // Base64 of source image/video
35
- targetImageOrVideo: string; // Base64 of target image/video
221
+ sourceImageOrVideo: string; // Base64
222
+ targetImageOrVideo: string; // Base64
36
223
  options?: Record<string, any>;
37
224
  }
38
- ```
39
-
40
- #### DualImageVideoResult
41
225
 
42
- ```tsx
43
226
  interface DualImageVideoResult {
44
227
  success: boolean;
45
228
  result?: {
@@ -52,12 +235,12 @@ interface DualImageVideoResult {
52
235
  }
53
236
  ```
54
237
 
55
- #### DualImageVideoFeatureConfig
238
+ ### Feature Config
56
239
 
57
- ```tsx
240
+ ```typescript
58
241
  interface DualImageVideoFeatureConfig {
59
- featureType: string; // e.g., 'face-swap', 'ai-hug', 'ai-kiss'
60
- inputType: 'image' | 'video';
242
+ featureType: string;
243
+ inputType: DualInputType;
61
244
  defaultOptions?: Record<string, any>;
62
245
  onProcessingStart?: () => void;
63
246
  onProcessingComplete?: (result: DualImageVideoResult) => void;
@@ -65,216 +248,64 @@ interface DualImageVideoFeatureConfig {
65
248
  }
66
249
  ```
67
250
 
68
- ## Usage Example
69
-
70
- ### Using Dual Image/Video Processing
71
-
72
- ```tsx
73
- import { useDualImageVideoProcessing } from '@umituz/react-native-ai-generation-content';
74
-
75
- function FaceSwapScreen() {
76
- const [sourceImage, setSourceImage] = useState<string | null>(null);
77
- const [targetImage, setTargetImage] = useState<string | null>(null);
78
-
79
- const {
80
- state,
81
- selectSourceImage,
82
- selectTargetImage,
83
- process,
84
- reset,
85
- isReady,
86
- } = useDualImageVideoProcessing({
87
- config: {
88
- featureType: 'face-swap',
89
- inputType: 'image',
90
- defaultOptions: {
91
- enhanceFace: true,
92
- matchSkinTone: true,
93
- },
94
- onProcessingStart: () => console.log('Starting face swap...'),
95
- onProcessingComplete: (result) => console.log('Complete:', result),
96
- onError: (error) => console.error('Error:', error),
97
- },
98
- onSelectSourceImage: async () => {
99
- // Select source image
100
- const result = await ImagePicker.launchImageLibrary({ mediaType: 'photo' });
101
- if (result.assets && result.assets[0].uri) {
102
- const base64 = await convertToBase64(result.assets[0].uri);
103
- setSourceImage(base64);
104
- return base64;
105
- }
106
- return null;
107
- },
108
- onSelectTargetImage: async () => {
109
- // Select target image
110
- const result = await ImagePicker.launchImageLibrary({ mediaType: 'photo' });
111
- if (result.assets && result.assets[0].uri) {
112
- const base64 = await convertToBase64(result.assets[0].uri);
113
- setTargetImage(base64);
114
- return base64;
115
- }
116
- return null;
117
- },
118
- });
119
-
120
- return (
121
- <View>
122
- <DualImagePicker
123
- sourceImage={sourceImage}
124
- targetImage={targetImage}
125
- onSelectSourceImage={selectSourceImage}
126
- onSelectTargetImage={selectTargetImage}
127
- />
128
-
129
- <Button
130
- title="Process"
131
- onPress={process}
132
- disabled={!isReady || state.isProcessing}
133
- />
134
-
135
- {state.isProcessing && <ActivityIndicator />}
136
-
137
- {state.result && (
138
- <Image source={{ uri: state.result.result?.imageUrl }} />
139
- )}
140
-
141
- {state.error && <Text>Error: {state.error}</Text>}
142
- </View>
143
- );
144
- }
145
- ```
146
-
147
- ## State Management
148
-
149
- ### Processing State
150
-
151
- ```tsx
152
- interface DualImageVideoState {
153
- sourceImageOrVideo: string | null;
154
- targetImageOrVideo: string | null;
155
- result: DualImageVideoResult | null;
156
- isProcessing: boolean;
157
- progress: number;
158
- error: string | null;
159
- }
160
- ```
161
-
162
- ## Features Using Dual Image/Video Processing
163
-
164
- - **Face Swap**: Swap faces between two images
165
- - **AI Hug**: Generate hug images from two photos
166
- - **AI Kiss**: Generate kiss images from two photos
167
- - **Couple Future**: Generate future predictions for couples
251
+ ---
168
252
 
169
- ## Helper Components
253
+ ## 📊 Features Using Shared
170
254
 
171
- ### DualImagePicker
255
+ ### Dual Image Features
256
+ - **Face Swap**: Swap faces between images
257
+ - **AI Hug**: Generate hug images
258
+ - **AI Kiss**: Generate kiss images
259
+ - **Couple Future**: Future predictions
172
260
 
173
- ```tsx
174
- import { DualImagePicker } from '@umituz/react-native-ai-generation-content';
261
+ ### Shared Components
262
+ - `DualImagePicker` - Image selection UI
263
+ - `DualVideoPicker` - Video selection UI
264
+ - `DualImageVideoState` - State management
175
265
 
176
- <DualImagePicker
177
- sourceImage={sourceImage}
178
- targetImage={targetImage}
179
- onSelectSourceImage={handleSelectSource}
180
- onSelectTargetImage={handleSelectTarget}
181
- sourceLabel="First Image"
182
- targetLabel="Second Image"
183
- />
184
- ```
185
-
186
- ### DualVideoPicker
266
+ ---
187
267
 
188
- ```tsx
189
- import { DualVideoPicker } from '@umituz/react-native-ai-generation-content';
268
+ ## 🎨 Best Practices
190
269
 
191
- <DualVideoPicker
192
- sourceVideo={sourceVideo}
193
- targetVideo={targetVideo}
194
- onSelectSourceVideo={handleSelectSource}
195
- onSelectTargetVideo={handleSelectTarget}
196
- sourceLabel="First Video"
197
- targetLabel="Second Video"
198
- />
199
- ```
200
-
201
- ## Advanced Usage
202
-
203
- ### Custom Processing Logic
204
-
205
- ```tsx
206
- import { useDualImageVideoProcessing } from '@umituz/react-native-ai-generation-content';
207
-
208
- const { process } = useDualImageVideoProcessing({
209
- config: {
210
- featureType: 'my-custom-feature',
211
- inputType: 'image',
212
- },
213
- // ... other props
214
- customProcess: async (source, target, options) => {
215
- // Custom processing logic
216
- const result = await myCustomProcessingFunction(source, target, options);
217
- return result;
218
- },
219
- });
220
- ```
270
+ ### Input Labeling
271
+ - "First Image/Video" vs "Second Image/Video"
272
+ - "Source" vs "Target" for swap features
273
+ - "Person 1" vs "Person 2" for couple features
274
+ - Always show which is which
221
275
 
222
276
  ### Validation
277
+ - Check both inputs present
278
+ - Validate file types
279
+ - Check file sizes
280
+ - Verify quality
281
+ - Provide clear feedback
223
282
 
224
- ```tsx
225
- const { validate } = useDualImageVideoProcessing({
226
- // ... config
227
- validateInput: (source, target) => {
228
- if (!source || !target) {
229
- throw new Error('Both images are required');
230
- }
231
- if (source.size > MAX_SIZE) {
232
- throw new Error('Source image is too large');
233
- }
234
- if (target.size > MAX_SIZE) {
235
- throw new Error('Target image is too large');
236
- }
237
- return true;
238
- },
239
- });
240
- ```
283
+ ### User Experience
284
+ - Show input previews
285
+ - Display progress clearly
286
+ - Confirm before processing
287
+ - Allow cancellation
288
+ - Explain errors clearly
241
289
 
242
- ### Before Process Hook
243
-
244
- ```tsx
245
- const { process } = useDualImageVideoProcessing({
246
- // ... config
247
- onBeforeProcess: async (source, target) => {
248
- // Show confirmation dialog
249
- return new Promise((resolve) => {
250
- Alert.alert(
251
- 'Confirm',
252
- 'Do you want to proceed?',
253
- [
254
- { text: 'Cancel', onPress: () => resolve(false) },
255
- { text: 'OK', onPress: () => resolve(true) },
256
- ]
257
- );
258
- });
259
- },
260
- });
261
- ```
290
+ ---
291
+
292
+ ## 🐛 Common Pitfalls
262
293
 
263
- ## Best Practices
294
+ **Mixed up inputs**: Clear labels, visual indicators
295
+ ❌ **Missing validation**: Always check both inputs
296
+ ❌ **No feedback**: Show progress, errors clearly
297
+ ❌ **State issues**: Proper cleanup and reset
264
298
 
265
- 1. **Input Validation**: Always validate inputs before processing
266
- 2. **Error Handling**: Handle errors gracefully and show user-friendly messages
267
- 3. **Progress Tracking**: Show progress to users during processing
268
- 4. **Confirmation**: Use confirmation dialogs for destructive operations
269
- 5. **State Reset**: Reset state after successful operations
299
+ ---
270
300
 
271
- ## Related Features
301
+ ## 📚 Related Features
272
302
 
273
- - [Face Swap](../face-swap) - Swap faces between images
274
- - [AI Hug](../ai-hug) - Generate AI hug images
275
- - [AI Kiss](../ai-kiss) - Generate AI kiss images
276
- - [Couple Future](../couple-future) - Generate future couple predictions
303
+ - [Face Swap](../face-swap) - Uses dual image processing
304
+ - [AI Hug](../ai-hug) - Uses dual image processing
305
+ - [AI Kiss](../ai-kiss) - Uses dual image processing
306
+ - [Couple Future](../couple-future) - Uses dual image processing
277
307
 
278
- ## License
308
+ ---
279
309
 
280
- MIT
310
+ **Last Updated**: 2025-01-08
311
+ **Version**: 2.0.0 (Strategy-based Documentation)