@umituz/react-native-ai-fal-provider 2.0.11 → 2.0.15
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 +2 -4
- package/src/domain/entities/error.types.ts +2 -0
- package/src/domain/types/provider.types.ts +1 -0
- package/src/exports/infrastructure.ts +0 -3
- package/src/exports/presentation.ts +0 -9
- package/src/index.ts +0 -3
- package/src/infrastructure/services/fal-feature-models.ts +3 -1
- package/src/infrastructure/services/fal-provider-subscription.ts +35 -13
- package/src/infrastructure/services/fal-provider.ts +6 -0
- package/src/infrastructure/services/fal-queue-operations.ts +30 -1
- package/src/infrastructure/services/fal-status-mapper.ts +2 -0
- package/src/infrastructure/services/request-store.ts +30 -2
- package/src/infrastructure/utils/cost-tracker.ts +34 -8
- package/src/infrastructure/utils/error-mapper.ts +17 -3
- package/src/infrastructure/utils/fal-storage.util.ts +3 -3
- package/src/infrastructure/utils/image-feature-builders.util.ts +10 -5
- package/src/infrastructure/utils/index.ts +7 -6
- package/src/infrastructure/utils/input-preprocessor.util.ts +1 -1
- package/src/infrastructure/utils/input-validator.util.ts +92 -0
- package/src/infrastructure/utils/type-guards.util.ts +7 -3
- package/src/infrastructure/utils/video-feature-builders.util.ts +6 -3
- package/src/infrastructure/validators/nsfw-validator.ts +62 -4
- package/src/presentation/hooks/index.ts +3 -21
- package/src/presentation/hooks/use-fal-generation.ts +5 -4
- package/src/domain/constants/default-models.constants.README.md +0 -378
- package/src/domain/constants/models/image-to-video.README.md +0 -266
- package/src/domain/constants/models/index.README.md +0 -269
- package/src/domain/constants/models/text-to-image.README.md +0 -237
- package/src/domain/constants/models/text-to-text.README.md +0 -249
- package/src/domain/constants/models/text-to-video.README.md +0 -259
- package/src/domain/constants/models/text-to-voice.README.md +0 -264
- package/src/domain/entities/error.types.README.md +0 -292
- package/src/domain/entities/fal.types.README.md +0 -460
- package/src/domain/types/index.README.md +0 -229
- package/src/domain/types/model-selection.types.README.md +0 -311
- package/src/exports/registry.ts +0 -39
- package/src/index.README.md +0 -420
- package/src/infrastructure/builders/image-feature-builder.README.md +0 -435
- package/src/infrastructure/builders/index.ts +0 -7
- package/src/infrastructure/services/fal-models-service.README.md +0 -293
- package/src/infrastructure/services/fal-provider-subscription.README.md +0 -257
- package/src/infrastructure/services/fal-provider.README.md +0 -474
- package/src/infrastructure/services/fal-status-mapper.README.md +0 -246
- package/src/infrastructure/services/nsfw-content-error.README.md +0 -215
- package/src/infrastructure/utils/base-builders.util.README.md +0 -313
- package/src/infrastructure/utils/cost-tracker-queries.ts +0 -67
- package/src/infrastructure/utils/error-categorizer.README.md +0 -395
- package/src/infrastructure/utils/error-mapper.README.md +0 -367
- package/src/infrastructure/utils/helpers.util.README.md +0 -395
- package/src/infrastructure/utils/image-feature-builders.util.README.md +0 -411
- package/src/infrastructure/utils/index.README.md +0 -338
- package/src/infrastructure/utils/job-metadata/index.README.md +0 -267
- package/src/infrastructure/utils/job-metadata/job-metadata-format.util.README.md +0 -209
- package/src/infrastructure/utils/job-metadata/job-metadata-lifecycle.util.README.md +0 -311
- package/src/infrastructure/utils/job-metadata/job-metadata-queries.util.README.md +0 -332
- package/src/infrastructure/utils/job-metadata/job-metadata.types.README.md +0 -446
- package/src/infrastructure/utils/job-metadata.README.md +0 -268
- package/src/infrastructure/utils/timing-helpers.util.ts +0 -56
- package/src/infrastructure/utils/type-guards.util.README.md +0 -371
- package/src/infrastructure/validators/index.README.md +0 -205
- package/src/infrastructure/validators/nsfw-validator.README.md +0 -309
- package/src/presentation/hooks/index.README.md +0 -224
- package/src/presentation/hooks/use-fal-generation.README.md +0 -398
- package/src/presentation/hooks/use-model-capabilities.ts +0 -99
- package/src/presentation/hooks/use-models.README.md +0 -318
- package/src/registry/global-capabilities.ts +0 -75
- package/src/registry/index.ts +0 -50
- package/src/registry/model-registry.service.ts +0 -93
- package/src/registry/model-registry.types.ts +0 -106
- package/src/registry/models/index.ts +0 -6
- package/src/registry/models/sora-2.config.ts +0 -95
|
@@ -1,309 +0,0 @@
|
|
|
1
|
-
# NSFW Content Validator
|
|
2
|
-
|
|
3
|
-
Validator for detecting NSFW (Not Safe For Work) content in AI-generated results.
|
|
4
|
-
|
|
5
|
-
**Location:** `src/infrastructure/validators/nsfw-validator.ts`
|
|
6
|
-
|
|
7
|
-
## Overview
|
|
8
|
-
|
|
9
|
-
The NSFW content validator provides content safety validation by checking AI-generated results for inappropriate content. It throws an `NSFWContentError` when NSFW concepts are detected, preventing the display or storage of policy-violating content.
|
|
10
|
-
|
|
11
|
-
## Purpose
|
|
12
|
-
|
|
13
|
-
Ensures content safety by:
|
|
14
|
-
- Validating AI generation results for NSFW concepts
|
|
15
|
-
- Throwing errors when inappropriate content is detected
|
|
16
|
-
- Preventing display of policy-violating content
|
|
17
|
-
- Supporting content policy enforcement
|
|
18
|
-
- Enabling safe content generation workflows
|
|
19
|
-
|
|
20
|
-
## Import
|
|
21
|
-
|
|
22
|
-
```typescript
|
|
23
|
-
import {
|
|
24
|
-
validateNSFWContent,
|
|
25
|
-
NSFWContentError
|
|
26
|
-
} from '@umituz/react-native-ai-fal-provider';
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
## Functions
|
|
30
|
-
|
|
31
|
-
### validateNSFWContent
|
|
32
|
-
|
|
33
|
-
Validates AI-generated content for NSFW material.
|
|
34
|
-
|
|
35
|
-
**Parameters:**
|
|
36
|
-
- `result`: AI generation result to validate (Record<string, unknown>)
|
|
37
|
-
|
|
38
|
-
**Returns:** `void` - Throws error if NSFW content detected
|
|
39
|
-
|
|
40
|
-
**Throws:** `NSFWContentError` - When NSFW content is detected
|
|
41
|
-
|
|
42
|
-
**Validation Logic:**
|
|
43
|
-
- Checks for `has_nsfw_concepts` array in result
|
|
44
|
-
- Validates array contains boolean values
|
|
45
|
-
- Throws error if any value in array is true
|
|
46
|
-
- Passes validation if no NSFW concepts detected
|
|
47
|
-
- Handles missing or malformed data gracefully
|
|
48
|
-
|
|
49
|
-
**Usage:**
|
|
50
|
-
Call this function immediately after receiving generation results from FAL API. Use in try-catch blocks to handle NSFW detection. Implement user feedback when content is rejected.
|
|
51
|
-
|
|
52
|
-
**Implementation:** See complete validation logic in `src/infrastructure/validators/nsfw-validator.ts`
|
|
53
|
-
|
|
54
|
-
**Related:**
|
|
55
|
-
- NSFW content error: `src/infrastructure/services/nsfw-content-error.ts`
|
|
56
|
-
- Error types: `src/domain/entities/error.types.ts`
|
|
57
|
-
|
|
58
|
-
## Usage Guidelines
|
|
59
|
-
|
|
60
|
-
### For Content Validation
|
|
61
|
-
|
|
62
|
-
**Validation Pattern:**
|
|
63
|
-
1. Receive generation result from FAL API
|
|
64
|
-
2. Call `validateNSFWContent()` with result
|
|
65
|
-
3. Catch `NSFWContentError` if thrown
|
|
66
|
-
4. Display error message to user
|
|
67
|
-
5. Suggest alternative prompts
|
|
68
|
-
|
|
69
|
-
**Best Practices:**
|
|
70
|
-
- Always validate before displaying content
|
|
71
|
-
- Provide clear user feedback on violations
|
|
72
|
-
- Suggest content policy compliance
|
|
73
|
-
- Track violations for abuse prevention
|
|
74
|
-
- Log detection for analytics
|
|
75
|
-
|
|
76
|
-
**Related:**
|
|
77
|
-
- useFalGeneration hook: `src/presentation/hooks/use-fal-generation.ts`
|
|
78
|
-
- Error mapper: `src/infrastructure/utils/error-mapper.ts`
|
|
79
|
-
|
|
80
|
-
### For Error Handling
|
|
81
|
-
|
|
82
|
-
**NSFW Error Handling:**
|
|
83
|
-
1. Wrap validation in try-catch block
|
|
84
|
-
2. Check for `NSFWContentError` instance
|
|
85
|
-
3. Display user-friendly error message
|
|
86
|
-
4. Suggest prompt modifications
|
|
87
|
-
5. Log violation for tracking
|
|
88
|
-
|
|
89
|
-
**User Feedback:**
|
|
90
|
-
- Clearly explain content policy violation
|
|
91
|
-
- Suggest different prompts or subjects
|
|
92
|
-
- Provide examples of appropriate content
|
|
93
|
-
- Link to full content policy
|
|
94
|
-
- Allow retry with different input
|
|
95
|
-
|
|
96
|
-
**Related:**
|
|
97
|
-
- Error types: `src/domain/entities/error.types.ts`
|
|
98
|
-
- Error categorizer: `src/infrastructure/utils/error-categorizer.ts`
|
|
99
|
-
|
|
100
|
-
### For Integration
|
|
101
|
-
|
|
102
|
-
**React Hooks Integration:**
|
|
103
|
-
1. Use with `useFalGeneration` hook
|
|
104
|
-
2. Validate in error handler or result handler
|
|
105
|
-
3. Display alerts for NSFW content
|
|
106
|
-
4. Update UI state appropriately
|
|
107
|
-
5. Track violations in state management
|
|
108
|
-
|
|
109
|
-
**Provider Integration:**
|
|
110
|
-
1. Call validation in provider methods
|
|
111
|
-
2. Intercept results before returning
|
|
112
|
-
3. Throw NSFW errors to caller
|
|
113
|
-
4. Maintain consistent error handling
|
|
114
|
-
5. Support validation toggling
|
|
115
|
-
|
|
116
|
-
**Related:**
|
|
117
|
-
- FAL provider: `src/infrastructure/services/fal-provider.ts`
|
|
118
|
-
- useFalGeneration hook: `src/presentation/hooks/use-fal-generation.ts`
|
|
119
|
-
|
|
120
|
-
### For Violation Tracking
|
|
121
|
-
|
|
122
|
-
**Tracking Strategy:**
|
|
123
|
-
1. Count violations per user or session
|
|
124
|
-
2. Implement thresholds for restrictions
|
|
125
|
-
3. Log violations for analytics
|
|
126
|
-
4. Provide user feedback on violations
|
|
127
|
-
5. Consider temporary generation restrictions
|
|
128
|
-
|
|
129
|
-
**Analytics Integration:**
|
|
130
|
-
- Track NSFW detection events
|
|
131
|
-
- Monitor violation patterns
|
|
132
|
-
- Identify problematic prompts
|
|
133
|
-
- Measure policy compliance
|
|
134
|
-
- Generate safety reports
|
|
135
|
-
|
|
136
|
-
## Best Practices
|
|
137
|
-
|
|
138
|
-
### 1. Always Validate User-Facing Content
|
|
139
|
-
|
|
140
|
-
Validate all content before display:
|
|
141
|
-
- Call validation immediately after generation
|
|
142
|
-
- Never display content before validation
|
|
143
|
-
- Validate in all environments (production, staging)
|
|
144
|
-
- Test validation with various content types
|
|
145
|
-
- Handle validation errors consistently
|
|
146
|
-
|
|
147
|
-
### 2. Provide Clear User Feedback
|
|
148
|
-
|
|
149
|
-
Communicate violations effectively:
|
|
150
|
-
- Use clear, non-judgmental language
|
|
151
|
-
- Explain what violated the policy
|
|
152
|
-
- Suggest alternative approaches
|
|
153
|
-
- Provide examples of appropriate content
|
|
154
|
-
- Link to complete content policy
|
|
155
|
-
|
|
156
|
-
### 3. Track Violations Appropriately
|
|
157
|
-
|
|
158
|
-
Monitor NSFW detection patterns:
|
|
159
|
-
- Count violations per user/session
|
|
160
|
-
- Implement threshold-based restrictions
|
|
161
|
-
- Log violations for analytics
|
|
162
|
-
- Identify abuse patterns
|
|
163
|
-
- Consider automatic restrictions
|
|
164
|
-
|
|
165
|
-
### 4. Handle Errors Gracefully
|
|
166
|
-
|
|
167
|
-
Implement robust error handling:
|
|
168
|
-
- Use try-catch blocks around validation
|
|
169
|
-
- Check for `NSFWContentError` instance
|
|
170
|
-
- Display user-friendly messages
|
|
171
|
-
- Allow retry with different prompts
|
|
172
|
-
- Maintain application stability
|
|
173
|
-
|
|
174
|
-
### 5. Respect User Context
|
|
175
|
-
|
|
176
|
-
Consider user-specific validation:
|
|
177
|
-
- Different validation for different user types
|
|
178
|
-
- Optional validation for admin users
|
|
179
|
-
- Age-appropriate validation rules
|
|
180
|
-
- Premium user validation options
|
|
181
|
-
- Context-aware validation settings
|
|
182
|
-
|
|
183
|
-
## For AI Agents
|
|
184
|
-
|
|
185
|
-
### When Using NSFW Validator
|
|
186
|
-
|
|
187
|
-
**DO:**
|
|
188
|
-
- Import from package root
|
|
189
|
-
- Validate all user-facing content
|
|
190
|
-
- Handle NSFWContentError appropriately
|
|
191
|
-
- Provide clear user feedback
|
|
192
|
-
- Track violations for analytics
|
|
193
|
-
- Suggest alternative prompts
|
|
194
|
-
- Link to content policy
|
|
195
|
-
|
|
196
|
-
**DON'T:**
|
|
197
|
-
- Skip validation for user content
|
|
198
|
-
- Display content before validating
|
|
199
|
-
- Show technical error messages
|
|
200
|
-
- Ignore violation patterns
|
|
201
|
-
- Allow retry with same prompt
|
|
202
|
-
- Hide policy details from users
|
|
203
|
-
- Forget to log violations
|
|
204
|
-
|
|
205
|
-
### When Handling Errors
|
|
206
|
-
|
|
207
|
-
**DO:**
|
|
208
|
-
- Use try-catch blocks
|
|
209
|
-
- Check for NSFWContentError instance
|
|
210
|
-
- Display user-friendly messages
|
|
211
|
-
- Suggest prompt modifications
|
|
212
|
-
- Log violations appropriately
|
|
213
|
-
- Consider user context
|
|
214
|
-
- Implement graceful degradation
|
|
215
|
-
|
|
216
|
-
**DON'T:**
|
|
217
|
-
- Let errors propagate uncaught
|
|
218
|
-
- Show technical error details
|
|
219
|
-
- Blame the user
|
|
220
|
-
- Use vague error messages
|
|
221
|
-
- Skip violation tracking
|
|
222
|
-
- Allow repeated violations
|
|
223
|
-
- Ignore user feedback
|
|
224
|
-
|
|
225
|
-
### When Integrating
|
|
226
|
-
|
|
227
|
-
**DO:**
|
|
228
|
-
- Validate in provider or hooks
|
|
229
|
-
- Implement consistent handling
|
|
230
|
-
- Support validation toggling
|
|
231
|
-
- Track violations globally
|
|
232
|
-
- Monitor detection patterns
|
|
233
|
-
- Update error handling
|
|
234
|
-
- Test with various content
|
|
235
|
-
|
|
236
|
-
**DON'T:**
|
|
237
|
-
- Validate inconsistently
|
|
238
|
-
- Skip validation in some paths
|
|
239
|
-
- Ignore violation patterns
|
|
240
|
-
- Allow validation bypass
|
|
241
|
-
- Forget user feedback
|
|
242
|
-
- Hardcode validation logic
|
|
243
|
-
- Create duplicate validators
|
|
244
|
-
|
|
245
|
-
### When Adding Validation
|
|
246
|
-
|
|
247
|
-
**For New Validation Rules:**
|
|
248
|
-
1. Review existing validation logic
|
|
249
|
-
2. Add new validators if needed
|
|
250
|
-
3. Update error types
|
|
251
|
-
4. Document validation behavior
|
|
252
|
-
5. Update this README
|
|
253
|
-
6. Test with edge cases
|
|
254
|
-
|
|
255
|
-
**For Enhanced Tracking:**
|
|
256
|
-
1. Add violation tracking
|
|
257
|
-
2. Implement threshold logic
|
|
258
|
-
3. Update analytics integration
|
|
259
|
-
4. Add user feedback mechanisms
|
|
260
|
-
5. Test tracking accuracy
|
|
261
|
-
6. Document tracking behavior
|
|
262
|
-
|
|
263
|
-
**For Custom Validation:**
|
|
264
|
-
1. Extend validator classes
|
|
265
|
-
2. Add configuration options
|
|
266
|
-
3. Support user-specific rules
|
|
267
|
-
4. Maintain backward compatibility
|
|
268
|
-
5. Update TypeScript types
|
|
269
|
-
6. Document custom behavior
|
|
270
|
-
|
|
271
|
-
## Implementation Notes
|
|
272
|
-
|
|
273
|
-
**Location:** `src/infrastructure/validators/nsfw-validator.ts`
|
|
274
|
-
|
|
275
|
-
**Dependencies:**
|
|
276
|
-
- Uses NSFWContentError from `src/infrastructure/services/nsfw-content-error.ts`
|
|
277
|
-
- No external dependencies
|
|
278
|
-
- Pure validation logic
|
|
279
|
-
|
|
280
|
-
**Validation Approach:**
|
|
281
|
-
- Checks for `has_nsfw_concepts` array
|
|
282
|
-
- Validates array contains boolean values
|
|
283
|
-
- Throws error if any value is true
|
|
284
|
-
- Handles missing or malformed data
|
|
285
|
-
- Logs detection in development mode
|
|
286
|
-
|
|
287
|
-
**Import:**
|
|
288
|
-
```typescript
|
|
289
|
-
import {
|
|
290
|
-
validateNSFWContent,
|
|
291
|
-
NSFWContentError
|
|
292
|
-
} from '@umituz/react-native-ai-fal-provider';
|
|
293
|
-
```
|
|
294
|
-
|
|
295
|
-
**Development Mode:**
|
|
296
|
-
In development mode, the validator logs when NSFW content is detected for debugging purposes.
|
|
297
|
-
|
|
298
|
-
**Related:**
|
|
299
|
-
- NSFW content error: `src/infrastructure/services/nsfw-content-error.ts`
|
|
300
|
-
- Error types: `src/domain/entities/error.types.ts`
|
|
301
|
-
- Error mapper: `src/infrastructure/utils/error-mapper.ts`
|
|
302
|
-
- FAL provider: `src/infrastructure/services/fal-provider.ts`
|
|
303
|
-
|
|
304
|
-
## Related Documentation
|
|
305
|
-
|
|
306
|
-
- [NSFW Content Error](../services/nsfw-content-error.README.md)
|
|
307
|
-
- [Error Types](../../domain/entities/error.types.README.md)
|
|
308
|
-
- [Error Mapper](../utils/error-mapper.README.md)
|
|
309
|
-
- [Error Categorizer](../utils/error-categorizer.README.md)
|
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
# React Hooks Index
|
|
2
|
-
|
|
3
|
-
Central export point for all React hooks provided by the FAL provider.
|
|
4
|
-
|
|
5
|
-
**Location:** `src/presentation/hooks/index.ts`
|
|
6
|
-
|
|
7
|
-
## Overview
|
|
8
|
-
|
|
9
|
-
The presentation hooks module exports custom React hooks that provide easy integration with FAL AI services. These hooks handle state management, error handling, loading states, and job lifecycle management.
|
|
10
|
-
|
|
11
|
-
## Purpose
|
|
12
|
-
|
|
13
|
-
Provides React integration by:
|
|
14
|
-
- Exporting generation management hook
|
|
15
|
-
- Exporting model selection hook
|
|
16
|
-
- Enabling state management
|
|
17
|
-
- Handling loading and error states
|
|
18
|
-
- Supporting React component integration
|
|
19
|
-
|
|
20
|
-
## Import
|
|
21
|
-
|
|
22
|
-
```typescript
|
|
23
|
-
import {
|
|
24
|
-
useFalGeneration,
|
|
25
|
-
useModels
|
|
26
|
-
} from '@umituz/react-native-ai-fal-provider';
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
## Exports
|
|
30
|
-
|
|
31
|
-
### useFalGeneration
|
|
32
|
-
|
|
33
|
-
Hook for managing FAL AI generation operations.
|
|
34
|
-
|
|
35
|
-
**Path:** `src/presentation/hooks/use-fal-generation.ts`
|
|
36
|
-
|
|
37
|
-
**Features:**
|
|
38
|
-
- Generation state management (loading, error, success)
|
|
39
|
-
- Automatic retry functionality
|
|
40
|
-
- Request cancellation
|
|
41
|
-
- Progress tracking
|
|
42
|
-
- Timeout handling
|
|
43
|
-
- Error categorization
|
|
44
|
-
|
|
45
|
-
### useModels
|
|
46
|
-
|
|
47
|
-
Hook for managing AI model selection and metadata.
|
|
48
|
-
|
|
49
|
-
**Path:** `src/presentation/hooks/use-models.ts`
|
|
50
|
-
|
|
51
|
-
**Features:**
|
|
52
|
-
- Model listing and filtering
|
|
53
|
-
- Dynamic credit cost calculation
|
|
54
|
-
- Model selection state
|
|
55
|
-
- Loading and error states
|
|
56
|
-
- Model refresh functionality
|
|
57
|
-
|
|
58
|
-
## Usage Guidelines
|
|
59
|
-
|
|
60
|
-
### For React Integration
|
|
61
|
-
|
|
62
|
-
**Hook Pattern:**
|
|
63
|
-
1. Import hooks from package root
|
|
64
|
-
2. Use hooks in components
|
|
65
|
-
3. Configure hook options
|
|
66
|
-
4. Use returned state and actions
|
|
67
|
-
5. Handle loading and error states
|
|
68
|
-
|
|
69
|
-
**Best Practices:**
|
|
70
|
-
- Use hooks at component level
|
|
71
|
-
- Configure appropriate timeouts
|
|
72
|
-
- Handle errors gracefully
|
|
73
|
-
- Display loading states
|
|
74
|
-
- Enable user cancellation
|
|
75
|
-
|
|
76
|
-
### For State Management
|
|
77
|
-
|
|
78
|
-
**State Pattern:**
|
|
79
|
-
1. Use hook to access state
|
|
80
|
-
2. Display loading indicators
|
|
81
|
-
3. Show error messages
|
|
82
|
-
4. Handle success states
|
|
83
|
-
5. Update UI appropriately
|
|
84
|
-
|
|
85
|
-
**Best Practices:**
|
|
86
|
-
- Check loading states before actions
|
|
87
|
-
- Display user-friendly errors
|
|
88
|
-
- Show progress feedback
|
|
89
|
-
- Handle cancellation states
|
|
90
|
-
- Update UI reactively
|
|
91
|
-
|
|
92
|
-
## Best Practices
|
|
93
|
-
|
|
94
|
-
### 1. Cleanup on Unmount
|
|
95
|
-
|
|
96
|
-
Always clean up resources:
|
|
97
|
-
- Cancel requests on unmount
|
|
98
|
-
- Clear timeouts and intervals
|
|
99
|
-
- Release controller references
|
|
100
|
-
- Prevent memory leaks
|
|
101
|
-
- Handle cleanup errors
|
|
102
|
-
|
|
103
|
-
### 2. Disable Controls During Loading
|
|
104
|
-
|
|
105
|
-
Prevent duplicate requests:
|
|
106
|
-
- Disable buttons during generation
|
|
107
|
-
- Show loading indicators
|
|
108
|
-
- Prevent form submissions
|
|
109
|
-
- Update button states
|
|
110
|
-
- Guide user experience
|
|
111
|
-
|
|
112
|
-
### 3. Handle Errors Gracefully
|
|
113
|
-
|
|
114
|
-
Display appropriate error messages:
|
|
115
|
-
- Check error types
|
|
116
|
-
- Show specific error messages
|
|
117
|
-
- Provide retry options when available
|
|
118
|
-
- Log technical details
|
|
119
|
-
- Guide users to corrections
|
|
120
|
-
|
|
121
|
-
### 4. Show Progress
|
|
122
|
-
|
|
123
|
-
Keep users informed:
|
|
124
|
-
- Display queue positions
|
|
125
|
-
- Show current status
|
|
126
|
-
- Update progress bars
|
|
127
|
-
- Provide estimated times
|
|
128
|
-
- Display generation progress
|
|
129
|
-
|
|
130
|
-
### 5. Use Type Safety
|
|
131
|
-
|
|
132
|
-
Leverage TypeScript types:
|
|
133
|
-
- Use hook result types
|
|
134
|
-
- Enable type checking
|
|
135
|
-
- Prevent type errors
|
|
136
|
-
- Enable autocomplete
|
|
137
|
-
- Maintain type safety
|
|
138
|
-
|
|
139
|
-
## For AI Agents
|
|
140
|
-
|
|
141
|
-
### When Using Hooks
|
|
142
|
-
|
|
143
|
-
**DO:**
|
|
144
|
-
- Import from package root
|
|
145
|
-
- Use hooks in components
|
|
146
|
-
- Handle loading states
|
|
147
|
-
- Display error messages
|
|
148
|
-
- Enable cancellation
|
|
149
|
-
- Configure timeouts appropriately
|
|
150
|
-
- Handle errors gracefully
|
|
151
|
-
|
|
152
|
-
**DON'T:**
|
|
153
|
-
- Import from internal paths
|
|
154
|
-
- Skip loading states
|
|
155
|
-
- Hide error information
|
|
156
|
-
- Disable cancellation
|
|
157
|
-
- Use inappropriate timeouts
|
|
158
|
-
- Forget error handling
|
|
159
|
-
- Create memory leaks
|
|
160
|
-
|
|
161
|
-
### When Managing State
|
|
162
|
-
|
|
163
|
-
**DO:**
|
|
164
|
-
- Use hook states in UI
|
|
165
|
-
- Check loading before actions
|
|
166
|
-
- Display error messages
|
|
167
|
-
- Show progress indicators
|
|
168
|
-
- Handle cancellation states
|
|
169
|
-
- Update reactively
|
|
170
|
-
- Clean up properly
|
|
171
|
-
|
|
172
|
-
**DON'T:**
|
|
173
|
-
- Ignore hook states
|
|
174
|
-
- Skip loading indicators
|
|
175
|
-
- Hide error information
|
|
176
|
-
- Block user actions
|
|
177
|
-
- Create stale UIs
|
|
178
|
-
- Forget cleanup
|
|
179
|
-
- Create race conditions
|
|
180
|
-
|
|
181
|
-
### When Configuring Hooks
|
|
182
|
-
|
|
183
|
-
**DO:**
|
|
184
|
-
- Set appropriate timeouts
|
|
185
|
-
- Configure error handlers
|
|
186
|
-
- Set up progress callbacks
|
|
187
|
-
- Handle cancellation
|
|
188
|
-
- Test configuration
|
|
189
|
-
- Monitor performance
|
|
190
|
-
- Adjust based on use case
|
|
191
|
-
|
|
192
|
-
**DON'T:**
|
|
193
|
-
- Use default timeouts only
|
|
194
|
-
- Skip error configuration
|
|
195
|
-
- Ignore progress updates
|
|
196
|
-
- Forget cancellation
|
|
197
|
-
- Use one-size-fits-all
|
|
198
|
-
- Skip testing
|
|
199
|
-
- Create poor UX
|
|
200
|
-
|
|
201
|
-
## Implementation Notes
|
|
202
|
-
|
|
203
|
-
**Location:** `src/presentation/hooks/index.ts`
|
|
204
|
-
|
|
205
|
-
**Dependencies:**
|
|
206
|
-
- Generation hook: `src/presentation/hooks/use-fal-generation.ts`
|
|
207
|
-
- Models hook: `src/presentation/hooks/use-models.ts`
|
|
208
|
-
|
|
209
|
-
**Export Categories:**
|
|
210
|
-
- Generation management hooks
|
|
211
|
-
- Model selection hooks
|
|
212
|
-
- Type definitions for hooks
|
|
213
|
-
|
|
214
|
-
**Import:**
|
|
215
|
-
```typescript
|
|
216
|
-
import {
|
|
217
|
-
useFalGeneration,
|
|
218
|
-
useModels
|
|
219
|
-
} from '@umituz/react-native-ai-fal-provider';
|
|
220
|
-
```
|
|
221
|
-
|
|
222
|
-
**Related:**
|
|
223
|
-
- useFalGeneration: `src/presentation/hooks/use-fal-generation.ts`
|
|
224
|
-
- useModels: `src/presentation/hooks/use-models.ts`
|