@umituz/react-native-ai-generation-content 1.17.229 → 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/LICENSE +21 -0
- package/README.md +346 -0
- package/package.json +1 -3
- package/src/domain/README.md +503 -0
- package/src/domains/content-moderation/README.md +363 -0
- package/src/domains/creations/README.md +394 -0
- package/src/domains/face-detection/README.md +395 -0
- package/src/domains/prompts/README.md +387 -0
- package/src/features/ai-hug/README.md +276 -0
- package/src/features/ai-kiss/README.md +276 -0
- package/src/features/anime-selfie/README.md +325 -0
- package/src/features/audio-generation/README.md +370 -0
- package/src/features/colorization/README.md +289 -0
- package/src/features/couple-future/README.md +270 -0
- package/src/features/face-swap/README.md +431 -0
- package/src/features/future-prediction/README.md +281 -0
- package/src/features/hd-touch-up/README.md +309 -0
- package/src/features/image-captioning/README.md +361 -0
- package/src/features/image-to-image/README.md +418 -0
- package/src/features/image-to-video/README.md +369 -0
- package/src/features/inpainting/README.md +302 -0
- package/src/features/meme-generator/README.md +327 -0
- package/src/features/photo-restoration/README.md +286 -0
- package/src/features/remove-background/README.md +292 -0
- package/src/features/remove-object/README.md +352 -0
- package/src/features/replace-background/README.md +288 -0
- package/src/features/script-generator/README.md +362 -0
- package/src/features/shared/README.md +280 -0
- package/src/features/sketch-to-image/README.md +296 -0
- package/src/features/style-transfer/README.md +301 -0
- package/src/features/text-to-image/README.md +394 -0
- package/src/features/text-to-video/README.md +245 -0
- package/src/features/text-to-voice/README.md +335 -0
- package/src/features/upscaling/README.md +247 -0
- package/src/infrastructure/config/README.md +310 -0
- package/src/infrastructure/middleware/README.md +378 -0
- package/src/infrastructure/orchestration/README.md +362 -0
- package/src/infrastructure/services/README.md +382 -0
- package/src/infrastructure/utils/README.md +523 -0
- package/src/infrastructure/wrappers/README.md +336 -0
- package/src/presentation/components/README.md +535 -0
- package/src/presentation/components/result/ResultStoryCard.tsx +1 -6
- package/src/presentation/hooks/README.md +380 -0
- package/src/presentation/layouts/README.md +374 -0
- package/src/presentation/screens/README.md +430 -0
- package/src/presentation/types/result-config.types.ts +3 -3
- package/src/presentation/layouts/types/.npmignore.tmp +0 -0
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
# Style Transfer
|
|
2
|
+
|
|
3
|
+
Apply artistic styles to images using AI.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Transform photos into artwork
|
|
8
|
+
- Multiple artistic styles (painting, sketch, watercolor, etc.)
|
|
9
|
+
- Customizable style intensity
|
|
10
|
+
- Preserve image content while changing style
|
|
11
|
+
- High-quality artistic output
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
This feature is part of `@umituz/react-native-ai-generation-content`.
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install @umituz/react-native-ai-generation-content
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Basic Usage
|
|
22
|
+
|
|
23
|
+
### Using the Hook
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
import { useStyleTransferFeature } from '@umituz/react-native-ai-generation-content';
|
|
27
|
+
import * as ImagePicker from 'react-native-image-picker';
|
|
28
|
+
|
|
29
|
+
function StyleTransferScreen() {
|
|
30
|
+
const [image, setImage] = useState<string | null>(null);
|
|
31
|
+
|
|
32
|
+
const feature = useStyleTransferFeature({
|
|
33
|
+
config: {
|
|
34
|
+
style: 'oil-painting',
|
|
35
|
+
intensity: 0.8,
|
|
36
|
+
onProcessingStart: () => console.log('Applying style...'),
|
|
37
|
+
onProcessingComplete: (result) => console.log('Complete:', result),
|
|
38
|
+
onError: (error) => console.error('Error:', error),
|
|
39
|
+
},
|
|
40
|
+
onSelectImage: async () => {
|
|
41
|
+
const result = await ImagePicker.launchImageLibrary({ mediaType: 'photo' });
|
|
42
|
+
if (result.assets && result.assets[0].uri) {
|
|
43
|
+
const base64 = await convertToBase64(result.assets[0].uri);
|
|
44
|
+
setImage(base64);
|
|
45
|
+
return base64;
|
|
46
|
+
}
|
|
47
|
+
return null;
|
|
48
|
+
},
|
|
49
|
+
onSaveResult: async (imageUrl) => {
|
|
50
|
+
await saveToGallery(imageUrl);
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<View>
|
|
56
|
+
<PhotoUploadCard
|
|
57
|
+
image={image}
|
|
58
|
+
onSelectImage={feature.selectImage}
|
|
59
|
+
title="Select Image to Style"
|
|
60
|
+
/>
|
|
61
|
+
|
|
62
|
+
<StyleSelector
|
|
63
|
+
selectedStyle={feature.state.style}
|
|
64
|
+
onSelectStyle={feature.setStyle}
|
|
65
|
+
/>
|
|
66
|
+
|
|
67
|
+
<IntensitySlider
|
|
68
|
+
value={feature.state.intensity}
|
|
69
|
+
onChange={feature.setIntensity}
|
|
70
|
+
/>
|
|
71
|
+
|
|
72
|
+
<Button
|
|
73
|
+
title="Apply Style"
|
|
74
|
+
onPress={feature.process}
|
|
75
|
+
disabled={!feature.isReady || feature.state.isProcessing}
|
|
76
|
+
/>
|
|
77
|
+
|
|
78
|
+
{feature.state.isProcessing && (
|
|
79
|
+
<ActivityIndicator />
|
|
80
|
+
)}
|
|
81
|
+
|
|
82
|
+
{feature.state.result && (
|
|
83
|
+
<ResultDisplay
|
|
84
|
+
originalImage={image}
|
|
85
|
+
resultImage={feature.state.result.imageUrl}
|
|
86
|
+
onSave={() => feature.saveResult()}
|
|
87
|
+
/>
|
|
88
|
+
)}
|
|
89
|
+
</View>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Using the Unified AI Feature Screen
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
import { AIFeatureScreen } from '@umituz/react-native-ai-generation-content';
|
|
98
|
+
|
|
99
|
+
function App() {
|
|
100
|
+
return (
|
|
101
|
+
<AIFeatureScreen
|
|
102
|
+
featureId="style-transfer"
|
|
103
|
+
userId="user-123"
|
|
104
|
+
/>
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Configuration Options
|
|
110
|
+
|
|
111
|
+
### Feature Config
|
|
112
|
+
|
|
113
|
+
```tsx
|
|
114
|
+
interface StyleTransferFeatureConfig {
|
|
115
|
+
style?: 'oil-painting' | 'watercolor' | 'sketch' | 'anime' | 'impressionist';
|
|
116
|
+
intensity?: number; // 0.0 - 1.0 (default: 0.8)
|
|
117
|
+
onProcessingStart?: () => void;
|
|
118
|
+
onProcessingComplete?: (result: StyleTransferResult) => void;
|
|
119
|
+
onError?: (error: string) => void;
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Processing Options
|
|
124
|
+
|
|
125
|
+
```tsx
|
|
126
|
+
interface StyleTransferOptions {
|
|
127
|
+
style: string; // Style ID
|
|
128
|
+
intensity: number; // How strong the style is (0.0 - 1.0)
|
|
129
|
+
preserveDetails?: boolean; // Maintain original details (default: true)
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Available Styles
|
|
134
|
+
|
|
135
|
+
### Oil Painting
|
|
136
|
+
|
|
137
|
+
Classic oil painting style:
|
|
138
|
+
|
|
139
|
+
```tsx
|
|
140
|
+
const result = await feature.process({
|
|
141
|
+
style: 'oil-painting',
|
|
142
|
+
intensity: 0.8,
|
|
143
|
+
preserveDetails: true,
|
|
144
|
+
});
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Watercolor
|
|
148
|
+
|
|
149
|
+
Soft watercolor painting style:
|
|
150
|
+
|
|
151
|
+
```tsx
|
|
152
|
+
const result = await feature.process({
|
|
153
|
+
style: 'watercolor',
|
|
154
|
+
intensity: 0.7,
|
|
155
|
+
});
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Sketch
|
|
159
|
+
|
|
160
|
+
Pencil sketch style:
|
|
161
|
+
|
|
162
|
+
```tsx
|
|
163
|
+
const result = await feature.process({
|
|
164
|
+
style: 'sketch',
|
|
165
|
+
intensity: 0.9,
|
|
166
|
+
});
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Anime
|
|
170
|
+
|
|
171
|
+
Anime/manga style:
|
|
172
|
+
|
|
173
|
+
```tsx
|
|
174
|
+
const result = await feature.process({
|
|
175
|
+
style: 'anime',
|
|
176
|
+
intensity: 0.8,
|
|
177
|
+
});
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Impressionist
|
|
181
|
+
|
|
182
|
+
Impressionist painting style:
|
|
183
|
+
|
|
184
|
+
```tsx
|
|
185
|
+
const result = await feature.process({
|
|
186
|
+
style: 'impressionist',
|
|
187
|
+
intensity: 0.7,
|
|
188
|
+
});
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Usage Flow
|
|
192
|
+
|
|
193
|
+
1. Select **Image** - Choose an image to transform
|
|
194
|
+
2. Choose **Style** - Select the artistic style
|
|
195
|
+
3. Adjust **Intensity** - Control style strength
|
|
196
|
+
4. Tap **Apply** - Start the style transfer
|
|
197
|
+
5. View Result - See the styled image
|
|
198
|
+
6. Save or Share - Save or share the result
|
|
199
|
+
|
|
200
|
+
## Component Examples
|
|
201
|
+
|
|
202
|
+
### Style Selector
|
|
203
|
+
|
|
204
|
+
```tsx
|
|
205
|
+
import { StylePresetsGrid } from '@umituz/react-native-ai-generation-content';
|
|
206
|
+
|
|
207
|
+
const styles = [
|
|
208
|
+
{ id: 'oil-painting', name: 'Oil Painting', preview: '...' },
|
|
209
|
+
{ id: 'watercolor', name: 'Watercolor', preview: '...' },
|
|
210
|
+
{ id: 'sketch', name: 'Sketch', preview: '...' },
|
|
211
|
+
{ id: 'anime', name: 'Anime', preview: '...' },
|
|
212
|
+
{ id: 'impressionist', name: 'Impressionist', preview: '...' },
|
|
213
|
+
];
|
|
214
|
+
|
|
215
|
+
<StylePresetsGrid
|
|
216
|
+
styles={styles}
|
|
217
|
+
selectedStyle={selectedStyle}
|
|
218
|
+
onSelectStyle={setSelectedStyle}
|
|
219
|
+
/>
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### Intensity Slider
|
|
223
|
+
|
|
224
|
+
```tsx
|
|
225
|
+
import { Slider } from 'react-native';
|
|
226
|
+
|
|
227
|
+
<Slider
|
|
228
|
+
minimumValue={0}
|
|
229
|
+
maximumValue={1}
|
|
230
|
+
step={0.1}
|
|
231
|
+
value={intensity}
|
|
232
|
+
onValueChange={setIntensity}
|
|
233
|
+
/>
|
|
234
|
+
|
|
235
|
+
<Text>Style Intensity: {Math.round(intensity * 100)}%</Text>
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### Before/After Comparison
|
|
239
|
+
|
|
240
|
+
```tsx
|
|
241
|
+
import { ResultDisplay } from '@umituz/react-native-ai-generation-content';
|
|
242
|
+
|
|
243
|
+
{feature.state.result && image && (
|
|
244
|
+
<ResultDisplay
|
|
245
|
+
originalImage={image}
|
|
246
|
+
resultImage={feature.state.result.imageUrl}
|
|
247
|
+
onSave={() => feature.saveResult()}
|
|
248
|
+
onShare={() => shareImage(feature.state.result.imageUrl)}
|
|
249
|
+
/>
|
|
250
|
+
)}
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
## Use Cases
|
|
254
|
+
|
|
255
|
+
### Art Creation
|
|
256
|
+
|
|
257
|
+
```tsx
|
|
258
|
+
// Create artwork from photos
|
|
259
|
+
const result = await feature.process({
|
|
260
|
+
style: 'oil-painting',
|
|
261
|
+
intensity: 0.9,
|
|
262
|
+
});
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### Social Media
|
|
266
|
+
|
|
267
|
+
```tsx
|
|
268
|
+
// Create stylized content
|
|
269
|
+
const result = await feature.process({
|
|
270
|
+
style: 'sketch',
|
|
271
|
+
intensity: 0.8,
|
|
272
|
+
});
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
### Photo Effects
|
|
276
|
+
|
|
277
|
+
```tsx
|
|
278
|
+
// Add artistic effects to photos
|
|
279
|
+
const result = await feature.process({
|
|
280
|
+
style: 'watercolor',
|
|
281
|
+
intensity: 0.7,
|
|
282
|
+
});
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
## Best Practices
|
|
286
|
+
|
|
287
|
+
1. **Style Selection**: Match style to image content for best results
|
|
288
|
+
2. **Intensity**: Start with 0.7-0.8 for balanced results
|
|
289
|
+
3. **Image Quality**: High-quality images produce better artwork
|
|
290
|
+
4. **Preserve Details**: Enable for photos with important details
|
|
291
|
+
5. **Experiment**: Try different styles to find the best match
|
|
292
|
+
|
|
293
|
+
## Related Features
|
|
294
|
+
|
|
295
|
+
- [Anime Selfie](../anime-selfie) - Convert photos to anime style
|
|
296
|
+
- [Image to Image](../image-to-image) - Transform images with AI
|
|
297
|
+
- [Text to Image](../text-to-image) - Generate artwork from text
|
|
298
|
+
|
|
299
|
+
## License
|
|
300
|
+
|
|
301
|
+
MIT
|
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
# Text to Image Feature
|
|
2
|
+
|
|
3
|
+
Generate images from text prompts using AI models.
|
|
4
|
+
|
|
5
|
+
## 📍 Import Path
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { useTextToImageFeature } from '@umituz/react-native-ai-generation-content';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
**Location**: `src/features/text-to-image/`
|
|
12
|
+
|
|
13
|
+
## 🎯 Feature Purpose
|
|
14
|
+
|
|
15
|
+
Convert natural language text descriptions into AI-generated images. Supports various aspect ratios, styles, and quality settings.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## 📋 Usage Strategy
|
|
20
|
+
|
|
21
|
+
### When to Use This Feature
|
|
22
|
+
|
|
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
|
|
30
|
+
|
|
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)
|
|
36
|
+
|
|
37
|
+
### Implementation Strategy
|
|
38
|
+
|
|
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
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## ⚠️ Critical Rules (MUST FOLLOW)
|
|
48
|
+
|
|
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)
|
|
55
|
+
|
|
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
|
|
129
|
+
|
|
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
|
|
172
|
+
|
|
173
|
+
Use this checklist when generating code:
|
|
174
|
+
|
|
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
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## 🛠️ Configuration Strategy
|
|
191
|
+
|
|
192
|
+
### Essential Configuration
|
|
193
|
+
|
|
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
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
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
|
|
228
|
+
|
|
229
|
+
### Feature States
|
|
230
|
+
|
|
231
|
+
**isReady**: boolean
|
|
232
|
+
- Feature initialized and ready to use
|
|
233
|
+
- Check before enabling generate button
|
|
234
|
+
|
|
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
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
---
|
|
255
|
+
|
|
256
|
+
## 🔐 Security Considerations
|
|
257
|
+
|
|
258
|
+
### Content Moderation
|
|
259
|
+
|
|
260
|
+
- **MUST** implement prompt content filtering
|
|
261
|
+
- **MUST** check for inappropriate content
|
|
262
|
+
- **MUST** block harmful or illegal prompts
|
|
263
|
+
- **MUST** log moderation actions
|
|
264
|
+
|
|
265
|
+
### API Security
|
|
266
|
+
|
|
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
|
|
271
|
+
|
|
272
|
+
### Data Privacy
|
|
273
|
+
|
|
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
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
## 🎨 Best Practices
|
|
282
|
+
|
|
283
|
+
### Prompt Engineering
|
|
284
|
+
|
|
285
|
+
1. **Be Specific**
|
|
286
|
+
- Good: "A majestic lion standing on a rock at sunset, detailed fur, dramatic lighting"
|
|
287
|
+
- Bad: "A lion"
|
|
288
|
+
|
|
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`
|
|
377
|
+
|
|
378
|
+
---
|
|
379
|
+
|
|
380
|
+
**Last Updated**: 2025-01-08
|
|
381
|
+
**Version**: 2.0.0 (Strategy-based Documentation)
|
|
382
|
+
|
|
383
|
+
---
|
|
384
|
+
|
|
385
|
+
## 📝 Changelog
|
|
386
|
+
|
|
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
|
|
392
|
+
|
|
393
|
+
### v1.0.0 - Initial Release
|
|
394
|
+
- Initial feature documentation
|