@umituz/react-native-ai-generation-content 1.17.229 → 1.17.230
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 +234 -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 +228 -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/hooks/README.md +380 -0
- package/src/presentation/layouts/README.md +374 -0
- package/src/presentation/screens/README.md +430 -0
- package/src/presentation/layouts/types/.npmignore.tmp +0 -0
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
# Upscaling
|
|
2
|
+
|
|
3
|
+
Increase image resolution while maintaining quality using AI.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Upscale images by 2x, 4x, or more
|
|
8
|
+
- Maintain image quality and details
|
|
9
|
+
- Remove noise and artifacts during upscaling
|
|
10
|
+
- Support for various image formats
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
This feature is part of `@umituz/react-native-ai-generation-content`.
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @umituz/react-native-ai-generation-content`
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Basic Usage
|
|
21
|
+
|
|
22
|
+
### Using the Hook
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
import { useUpscaleFeature } from '@umituz/react-native-ai-generation-content';
|
|
26
|
+
import * as ImagePicker from 'react-native-image-picker';
|
|
27
|
+
|
|
28
|
+
function UpscaleScreen() {
|
|
29
|
+
const [image, setImage] = useState<string | null>(null);
|
|
30
|
+
|
|
31
|
+
const feature = useUpscaleFeature({
|
|
32
|
+
config: {
|
|
33
|
+
defaultScaleFactor: 2,
|
|
34
|
+
onProcessingStart: () => console.log('Starting upscaling...'),
|
|
35
|
+
onProcessingComplete: (result) => console.log('Complete:', result),
|
|
36
|
+
onError: (error) => console.error('Error:', error),
|
|
37
|
+
},
|
|
38
|
+
onSelectImage: 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
|
+
setImage(base64);
|
|
43
|
+
return base64;
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
},
|
|
47
|
+
onSaveImage: async (imageUrl) => {
|
|
48
|
+
await saveToGallery(imageUrl);
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<View>
|
|
54
|
+
<PhotoUploadCard
|
|
55
|
+
image={image}
|
|
56
|
+
onSelectImage={feature.selectImage}
|
|
57
|
+
title="Select Image to Upscale"
|
|
58
|
+
/>
|
|
59
|
+
|
|
60
|
+
<Button
|
|
61
|
+
title="Upscale Image"
|
|
62
|
+
onPress={feature.process}
|
|
63
|
+
disabled={!feature.isReady || feature.state.isProcessing}
|
|
64
|
+
/>
|
|
65
|
+
|
|
66
|
+
{feature.state.isProcessing && (
|
|
67
|
+
<View>
|
|
68
|
+
<Text>Upscaling image...</Text>
|
|
69
|
+
<ProgressBar progress={feature.state.progress} />
|
|
70
|
+
</View>
|
|
71
|
+
)}
|
|
72
|
+
|
|
73
|
+
{feature.state.result && (
|
|
74
|
+
<Image source={{ uri: feature.state.result.imageUrl }} />
|
|
75
|
+
)}
|
|
76
|
+
</View>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Using the Unified AI Feature Screen
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
import { AIFeatureScreen } from '@umituz/react-native-ai-generation-content';
|
|
85
|
+
|
|
86
|
+
function App() {
|
|
87
|
+
return (
|
|
88
|
+
<AIFeatureScreen
|
|
89
|
+
featureId="upscaling"
|
|
90
|
+
userId="user-123"
|
|
91
|
+
/>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Configuration Options
|
|
97
|
+
|
|
98
|
+
### Feature Config
|
|
99
|
+
|
|
100
|
+
```tsx
|
|
101
|
+
interface UpscaleFeatureConfig {
|
|
102
|
+
defaultScaleFactor?: 2 | 4; // Scale factor (default: 2)
|
|
103
|
+
onProcessingStart?: () => void;
|
|
104
|
+
onProcessingComplete?: (result: UpscaleResult) => void;
|
|
105
|
+
onError?: (error: string) => void;
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Generation Options
|
|
110
|
+
|
|
111
|
+
```tsx
|
|
112
|
+
interface UpscaleOptions {
|
|
113
|
+
scaleFactor: 2 | 4;
|
|
114
|
+
enhance?: boolean; // Enhance image during upscaling
|
|
115
|
+
denoise?: boolean; // Remove noise during upscaling
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Usage Flow
|
|
120
|
+
|
|
121
|
+
1. Select **Image** - Choose an image to upscale
|
|
122
|
+
2. Choose **Scale Factor** - Select 2x or 4x upscaling
|
|
123
|
+
3. Tap **Upscale** - Start the upscaling process
|
|
124
|
+
4. View Result - See the upscaled high-resolution image
|
|
125
|
+
5. Save or Share - Save to gallery or share
|
|
126
|
+
|
|
127
|
+
## Component Examples
|
|
128
|
+
|
|
129
|
+
### Scale Factor Selector
|
|
130
|
+
|
|
131
|
+
```tsx
|
|
132
|
+
import { GridSelector } from '@umituz/react-native-ai-generation-content';
|
|
133
|
+
|
|
134
|
+
const scaleOptions = [
|
|
135
|
+
{ id: '2x', name: '2x', description: 'Double resolution' },
|
|
136
|
+
{ id: '4x', name: '4x', description: 'Quadruple resolution' },
|
|
137
|
+
];
|
|
138
|
+
|
|
139
|
+
function MyScreen() {
|
|
140
|
+
const [scaleFactor, setScaleFactor] = useState('2x');
|
|
141
|
+
|
|
142
|
+
return (
|
|
143
|
+
<GridSelector
|
|
144
|
+
options={scaleOptions}
|
|
145
|
+
selectedOption={scaleFactor}
|
|
146
|
+
onSelectOption={setScaleFactor}
|
|
147
|
+
/>
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Before/After Comparison
|
|
153
|
+
|
|
154
|
+
```tsx
|
|
155
|
+
import { ResultDisplay } from '@umituz/react-native-ai-generation-content';
|
|
156
|
+
|
|
157
|
+
{feature.state.result && originalImage && (
|
|
158
|
+
<View>
|
|
159
|
+
<Text>Before:</Text>
|
|
160
|
+
<Image source={{ uri: originalImage }} style={{ width: 200, height: 200 }} />
|
|
161
|
+
|
|
162
|
+
<Text>After (Upscaled):</Text>
|
|
163
|
+
<Image source={{ uri: feature.state.result.imageUrl }} style={{ width: 400, height: 400 }} />
|
|
164
|
+
</View>
|
|
165
|
+
)}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Advanced Usage
|
|
169
|
+
|
|
170
|
+
### Custom Scale Factor
|
|
171
|
+
|
|
172
|
+
```tsx
|
|
173
|
+
const result = await feature.process({
|
|
174
|
+
scaleFactor: 4,
|
|
175
|
+
enhance: true,
|
|
176
|
+
denoise: true,
|
|
177
|
+
});
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Progress Tracking
|
|
181
|
+
|
|
182
|
+
```tsx
|
|
183
|
+
const { state, process } = useUpscaleFeature({ ...config });
|
|
184
|
+
|
|
185
|
+
useEffect(() => {
|
|
186
|
+
if (state.isProcessing) {
|
|
187
|
+
console.log(`Upscaling progress: ${state.progress}%`);
|
|
188
|
+
}
|
|
189
|
+
}, [state.progress]);
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## Use Cases
|
|
193
|
+
|
|
194
|
+
### Enhancing Low-Resolution Photos
|
|
195
|
+
|
|
196
|
+
```tsx
|
|
197
|
+
// Upscale old photos for better quality
|
|
198
|
+
const result = await feature.process({ scaleFactor: 2 });
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Preparing Images for Print
|
|
202
|
+
|
|
203
|
+
```tsx
|
|
204
|
+
// Upscale to print-ready resolution
|
|
205
|
+
const result = await feature.process({ scaleFactor: 4 });
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### Improving Image Quality
|
|
209
|
+
|
|
210
|
+
```tsx
|
|
211
|
+
// Upscale with enhancement and denoising
|
|
212
|
+
const result = await feature.process({
|
|
213
|
+
scaleFactor: 2,
|
|
214
|
+
enhance: true,
|
|
215
|
+
denoise: true,
|
|
216
|
+
});
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
## Best Practices
|
|
220
|
+
|
|
221
|
+
1. **Start with 2x**: Try 2x first, then 4x if needed
|
|
222
|
+
2. **Image Quality**: Higher quality source images produce better results
|
|
223
|
+
3. **File Size**: Be aware that 4x upscaling significantly increases file size
|
|
224
|
+
4. **Enhancement**: Use enhancement for better detail preservation
|
|
225
|
+
5. **Testing**: Test different scale factors to find the best result
|
|
226
|
+
|
|
227
|
+
## Error Handling
|
|
228
|
+
|
|
229
|
+
```tsx
|
|
230
|
+
const { state, process } = useUpscaleFeature({ ...config });
|
|
231
|
+
|
|
232
|
+
useEffect(() => {
|
|
233
|
+
if (state.error) {
|
|
234
|
+
Alert.alert('Upscaling Failed', state.error);
|
|
235
|
+
}
|
|
236
|
+
}, [state.error]);
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
## Related Features
|
|
240
|
+
|
|
241
|
+
- [HD Touch Up](../hd-touch-up) - High-detail image enhancements
|
|
242
|
+
- [Photo Restoration](../photo-restoration) - Restore old/blurry photos
|
|
243
|
+
- [Image to Image](../image-to-image) - Transform images using AI
|
|
244
|
+
|
|
245
|
+
## License
|
|
246
|
+
|
|
247
|
+
MIT
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
# Infrastructure Config
|
|
2
|
+
|
|
3
|
+
Configuration management for the AI generation library.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The config module provides centralized configuration management for all app services including network, auth, analytics, and more.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- Centralized service configuration
|
|
12
|
+
- Dynamic configuration updates
|
|
13
|
+
- Type-safe configuration objects
|
|
14
|
+
- Environment-specific configs
|
|
15
|
+
- Service availability checks
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
### Initial Configuration
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import { configureAppServices } from '@umituz/react-native-ai-generation-content';
|
|
23
|
+
|
|
24
|
+
// Configure all services at app startup
|
|
25
|
+
configureAppServices({
|
|
26
|
+
networkService: {
|
|
27
|
+
baseUrl: 'https://api.example.com',
|
|
28
|
+
apiKey: process.env.API_KEY,
|
|
29
|
+
timeout: 30000,
|
|
30
|
+
headers: {
|
|
31
|
+
'X-Custom-Header': 'value',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
creditService: {
|
|
35
|
+
checkCredits: async (userId, cost) => {
|
|
36
|
+
const user = await fetchUserCredits(userId);
|
|
37
|
+
return user.credits >= cost;
|
|
38
|
+
},
|
|
39
|
+
deductCredits: async (userId, cost) => {
|
|
40
|
+
await updateUserCredits(userId, -cost);
|
|
41
|
+
},
|
|
42
|
+
getCredits: async (userId) => {
|
|
43
|
+
const user = await fetchUserCredits(userId);
|
|
44
|
+
return user.credits;
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
paywallService: {
|
|
48
|
+
showPaywall: async () => {
|
|
49
|
+
// Show paywall screen or modal
|
|
50
|
+
return await navigateToPaywall();
|
|
51
|
+
},
|
|
52
|
+
isPaywallDismissed: async () => {
|
|
53
|
+
// Check if user has seen paywall
|
|
54
|
+
return await AsyncStorage.getItem('paywall_dismissed');
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
authService: {
|
|
58
|
+
getCurrentUser: async () => {
|
|
59
|
+
// Get current authenticated user
|
|
60
|
+
return await Auth.currentSession();
|
|
61
|
+
},
|
|
62
|
+
getToken: async () => {
|
|
63
|
+
// Get auth token
|
|
64
|
+
return await Auth.currentAuthenticatedUser();
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
analyticsService: {
|
|
68
|
+
trackEvent: async (event, properties) => {
|
|
69
|
+
// Track analytics event
|
|
70
|
+
await Analytics.track(event, properties);
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Update Configuration
|
|
77
|
+
|
|
78
|
+
```tsx
|
|
79
|
+
import { updateAppServices } from '@umituz/react-native-ai-generation-content';
|
|
80
|
+
|
|
81
|
+
// Update specific service configuration
|
|
82
|
+
updateAppServices({
|
|
83
|
+
networkService: {
|
|
84
|
+
baseUrl: 'https://new-api.example.com',
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Check Configuration
|
|
90
|
+
|
|
91
|
+
```tsx
|
|
92
|
+
import { isAppServicesConfigured, getAppServices } from '@umituz/react-native-ai-generation-content';
|
|
93
|
+
|
|
94
|
+
if (!isAppServicesConfigured()) {
|
|
95
|
+
console.warn('App services not configured!');
|
|
96
|
+
// Handle unconfigured state
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const services = getAppServices();
|
|
100
|
+
console.log('Network base URL:', services.networkService?.baseUrl);
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Get Specific Service
|
|
104
|
+
|
|
105
|
+
```tsx
|
|
106
|
+
import {
|
|
107
|
+
getNetworkService,
|
|
108
|
+
getCreditService,
|
|
109
|
+
getPaywallService,
|
|
110
|
+
getAuthService,
|
|
111
|
+
getAnalyticsService,
|
|
112
|
+
} from '@umituz/react-native-ai-generation-content';
|
|
113
|
+
|
|
114
|
+
const networkService = getNetworkService();
|
|
115
|
+
if (networkService) {
|
|
116
|
+
console.log('API URL:', networkService.baseUrl);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const creditService = getCreditService();
|
|
120
|
+
if (creditService) {
|
|
121
|
+
const hasCredits = await creditService.checkCredits('user-123', 1);
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Reset Configuration
|
|
126
|
+
|
|
127
|
+
```tsx
|
|
128
|
+
import { resetAppServices } from '@umituz/react-native-ai-generation-content';
|
|
129
|
+
|
|
130
|
+
// Reset all services (useful for testing/logout)
|
|
131
|
+
resetAppServices();
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Configuration Types
|
|
135
|
+
|
|
136
|
+
### AppServicesConfig
|
|
137
|
+
|
|
138
|
+
```tsx
|
|
139
|
+
interface AppServicesConfig {
|
|
140
|
+
networkService?: INetworkService;
|
|
141
|
+
creditService?: ICreditService;
|
|
142
|
+
paywallService?: IPaywallService;
|
|
143
|
+
authService?: IAuthService;
|
|
144
|
+
analyticsService?: IAnalyticsService;
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### INetworkService
|
|
149
|
+
|
|
150
|
+
```tsx
|
|
151
|
+
interface INetworkService {
|
|
152
|
+
baseUrl: string;
|
|
153
|
+
apiKey?: string;
|
|
154
|
+
timeout?: number;
|
|
155
|
+
headers?: Record<string, string>;
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### ICreditService
|
|
160
|
+
|
|
161
|
+
```tsx
|
|
162
|
+
interface ICreditService {
|
|
163
|
+
checkCredits(userId: string, cost: number): Promise<boolean>;
|
|
164
|
+
deductCredits(userId: string, cost: number): Promise<void>;
|
|
165
|
+
getCredits(userId: string): Promise<number>;
|
|
166
|
+
addCredits(userId: string, amount: number): Promise<void>;
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### IPaywallService
|
|
171
|
+
|
|
172
|
+
```tsx
|
|
173
|
+
interface IPaywallService {
|
|
174
|
+
showPaywall(): Promise<boolean>;
|
|
175
|
+
isPaywallDismissed(): Promise<boolean>;
|
|
176
|
+
dismissPaywall(): Promise<void>;
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### IAuthService
|
|
181
|
+
|
|
182
|
+
```tsx
|
|
183
|
+
interface IAuthService {
|
|
184
|
+
getCurrentUser(): Promise<User | null>;
|
|
185
|
+
getToken(): Promise<string | null>;
|
|
186
|
+
isAuthenticated(): Promise<boolean>;
|
|
187
|
+
}
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### IAnalyticsService
|
|
191
|
+
|
|
192
|
+
```tsx
|
|
193
|
+
interface IAnalyticsService {
|
|
194
|
+
trackEvent(event: string, properties?: Record<string, any>): Promise<void>;
|
|
195
|
+
trackScreen(screenName: string): Promise<void>;
|
|
196
|
+
identifyUser(userId: string): Promise<void>;
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## Environment-Specific Configuration
|
|
201
|
+
|
|
202
|
+
### Development
|
|
203
|
+
|
|
204
|
+
```tsx
|
|
205
|
+
if (__DEV__) {
|
|
206
|
+
configureAppServices({
|
|
207
|
+
networkService: {
|
|
208
|
+
baseUrl: 'https://dev-api.example.com',
|
|
209
|
+
apiKey: 'dev-key',
|
|
210
|
+
},
|
|
211
|
+
// ... other services
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### Production
|
|
217
|
+
|
|
218
|
+
```tsx
|
|
219
|
+
if (!__DEV__) {
|
|
220
|
+
configureAppServices({
|
|
221
|
+
networkService: {
|
|
222
|
+
baseUrl: 'https://api.example.com',
|
|
223
|
+
apiKey: process.env.PROD_API_KEY,
|
|
224
|
+
},
|
|
225
|
+
// ... other services
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### Dynamic Environment
|
|
231
|
+
|
|
232
|
+
```tsx
|
|
233
|
+
const getEnvConfig = () => {
|
|
234
|
+
const env = process.env.NODE_ENV || 'development';
|
|
235
|
+
|
|
236
|
+
switch (env) {
|
|
237
|
+
case 'production':
|
|
238
|
+
return {
|
|
239
|
+
baseUrl: 'https://api.example.com',
|
|
240
|
+
};
|
|
241
|
+
case 'staging':
|
|
242
|
+
return {
|
|
243
|
+
baseUrl: 'https://staging-api.example.com',
|
|
244
|
+
};
|
|
245
|
+
default:
|
|
246
|
+
return {
|
|
247
|
+
baseUrl: 'https://dev-api.example.com',
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
configureAppServices({
|
|
253
|
+
networkService: getEnvConfig(),
|
|
254
|
+
});
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
## Best Practices
|
|
258
|
+
|
|
259
|
+
1. **Configure Early**: Configure services at app startup
|
|
260
|
+
2. **Type Safety**: Use proper types for all services
|
|
261
|
+
3. **Error Handling**: Handle missing services gracefully
|
|
262
|
+
4. **Environment Variables**: Use env vars for sensitive data
|
|
263
|
+
5. **Validation**: Validate configuration before use
|
|
264
|
+
|
|
265
|
+
## Error Handling
|
|
266
|
+
|
|
267
|
+
```tsx
|
|
268
|
+
import { isAppServicesConfigured } from '@umituz/react-native-ai-generation-content';
|
|
269
|
+
|
|
270
|
+
function App() {
|
|
271
|
+
useEffect(() => {
|
|
272
|
+
if (!isAppServicesConfigured()) {
|
|
273
|
+
Alert.alert(
|
|
274
|
+
'Configuration Error',
|
|
275
|
+
'App services not configured. Please contact support.'
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
}, []);
|
|
279
|
+
|
|
280
|
+
// ...
|
|
281
|
+
}
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
## Testing
|
|
285
|
+
|
|
286
|
+
```tsx
|
|
287
|
+
import { configureAppServices, resetAppServices } from '@umituz/react-native-ai-generation-content';
|
|
288
|
+
|
|
289
|
+
beforeEach(() => {
|
|
290
|
+
configureAppServices({
|
|
291
|
+
networkService: {
|
|
292
|
+
baseUrl: 'https://test-api.example.com',
|
|
293
|
+
},
|
|
294
|
+
});
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
afterEach(() => {
|
|
298
|
+
resetAppServices();
|
|
299
|
+
});
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
## Related
|
|
303
|
+
|
|
304
|
+
- [Services](../services/) - AI generation services
|
|
305
|
+
- [Middleware](../middleware/) - Request/response middleware
|
|
306
|
+
- [Utils](../utils/) - Utility functions
|
|
307
|
+
|
|
308
|
+
## License
|
|
309
|
+
|
|
310
|
+
MIT
|