@umituz/react-native-design-system 4.23.97 → 4.23.101
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 +1 -1
- package/src/atoms/AtomicInput.tsx +0 -2
- package/src/atoms/button/AtomicButton.tsx +7 -0
- package/src/atoms/button/types/index.ts +4 -0
- package/src/atoms/input/hooks/useInputState.ts +3 -7
- package/src/haptics/infrastructure/services/HapticService.ts +1 -1
- package/src/media/domain/entities/{MultimediaFlashcardTypes.ts → MediaAttachments.ts} +13 -32
- package/src/media/index.ts +24 -23
- package/src/media/{presentation/hooks/useCardMediaGeneration.ts → infrastructure/hooks/useGenericMediaGeneration.ts} +77 -31
- package/src/media/infrastructure/services/MediaGenerationService.ts +1 -1
- package/src/media/infrastructure/services/MediaOptimizerService.ts +1 -1
- package/src/media/infrastructure/services/MediaUploadService.ts +1 -1
- package/src/media/infrastructure/services/MediaValidationService.ts +1 -1
- package/src/media/infrastructure/services/MultimediaFlashcardService.ts +1 -1
- package/src/media/infrastructure/utils/PermissionManager.ts +1 -1
- package/src/media/infrastructure/utils/media-collection-utils.ts +4 -2
- package/src/media/infrastructure/utils/mediaPickerMappers.ts +1 -1
- package/src/media/presentation/hooks/multimedia.types.ts +1 -1
- package/src/media/presentation/hooks/useCardMultimediaFlashcard.ts +4 -4
- package/src/media/presentation/hooks/useMedia.ts +2 -2
- package/src/media/presentation/hooks/useMediaGeneration.ts +5 -88
- package/src/media/presentation/hooks/useMediaUpload.ts +1 -1
- package/src/media/presentation/hooks/useMediaValidation.ts +1 -1
- package/src/media/presentation/hooks/useMultimediaFlashcard.ts +1 -1
- package/src/molecules/navigation/components/NavigationHeader.tsx +3 -3
- package/src/molecules/navigation/utils/AppNavigation.ts +3 -3
- package/src/offline/index.ts +1 -0
- package/src/offline/infrastructure/storage/OfflineConfigStore.ts +34 -0
- package/src/offline/presentation/hooks/useOffline.ts +8 -4
- package/src/storage/domain/utils/devUtils.ts +0 -24
- package/src/storage/index.ts +1 -1
- package/src/storage/infrastructure/adapters/StorageService.ts +5 -10
- package/src/storage/infrastructure/repositories/BaseStorageOperations.ts +5 -8
- package/src/storage/presentation/hooks/CacheStorageOperations.ts +5 -11
- package/src/storage/presentation/hooks/useStore.ts +13 -5
- package/src/utilities/sharing/presentation/hooks/useSharing.ts +3 -3
- package/src/layouts/ScreenLayout/ScreenLayout.example.tsx +0 -92
- package/src/media/domain/entities/CardMultimedia.types.README.md +0 -129
- package/src/media/domain/entities/CardMultimedia.types.ts +0 -120
- package/src/media/domain/entities/Media.README.md +0 -80
- package/src/media/domain/entities/MultimediaFlashcardTypes.README.md +0 -144
- package/src/media/domain/utils/MediaUtils.README.md +0 -178
- package/src/media/index.ts.README.md +0 -191
- package/src/media/infrastructure/services/CardMediaGenerationService.README.md +0 -99
- package/src/media/infrastructure/services/CardMediaGenerationService.ts +0 -101
- package/src/media/infrastructure/services/CardMediaOptimizerService.README.md +0 -167
- package/src/media/infrastructure/services/CardMediaOptimizerService.ts +0 -36
- package/src/media/infrastructure/services/CardMediaUploadService.README.md +0 -123
- package/src/media/infrastructure/services/CardMediaUploadService.ts +0 -62
- package/src/media/infrastructure/services/CardMediaValidationService.README.md +0 -134
- package/src/media/infrastructure/services/CardMediaValidationService.ts +0 -81
- package/src/media/infrastructure/services/CardMultimediaService.README.md +0 -176
- package/src/media/infrastructure/services/CardMultimediaService.ts +0 -98
- package/src/media/infrastructure/services/MediaGenerationService.README.md +0 -142
- package/src/media/infrastructure/services/MediaOptimizerService.README.md +0 -145
- package/src/media/infrastructure/services/MediaPickerService.README.md +0 -106
- package/src/media/infrastructure/services/MediaSaveService.README.md +0 -120
- package/src/media/infrastructure/services/MediaUploadService.README.md +0 -135
- package/src/media/infrastructure/services/MediaValidationService.README.md +0 -135
- package/src/media/infrastructure/services/MultimediaFlashcardService.README.md +0 -142
- package/src/media/infrastructure/utils/mediaHelpers.README.md +0 -96
- package/src/media/infrastructure/utils/mediaPickerMappers.README.md +0 -129
- package/src/media/presentation/hooks/card-multimedia.types.README.md +0 -177
- package/src/media/presentation/hooks/card-multimedia.types.ts +0 -53
- package/src/media/presentation/hooks/multimedia.types.README.md +0 -201
- package/src/media/presentation/hooks/useCardMediaGeneration.README.md +0 -164
- package/src/media/presentation/hooks/useCardMediaUpload.README.md +0 -153
- package/src/media/presentation/hooks/useCardMediaUpload.ts +0 -84
- package/src/media/presentation/hooks/useCardMediaValidation.README.md +0 -176
- package/src/media/presentation/hooks/useCardMediaValidation.ts +0 -101
- package/src/media/presentation/hooks/useCardMultimediaFlashcard.README.md +0 -158
- package/src/media/presentation/hooks/useMedia.README.md +0 -94
- package/src/media/presentation/hooks/useMediaGeneration.README.md +0 -118
- package/src/media/presentation/hooks/useMediaUpload.README.md +0 -108
- package/src/media/presentation/hooks/useMediaValidation.README.md +0 -134
- package/src/media/presentation/hooks/useMultimediaFlashcard.README.md +0 -141
- package/src/storage/domain/utils/__tests__/devUtils.test.ts +0 -97
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
# useCardMediaValidation
|
|
2
|
-
|
|
3
|
-
## Purpose
|
|
4
|
-
Card-specific React hook for validating flashcard media files before upload with enhanced controls for different media types.
|
|
5
|
-
|
|
6
|
-
## File Location
|
|
7
|
-
`src/presentation/hooks/useCardMediaValidation.ts`
|
|
8
|
-
|
|
9
|
-
## Strategy
|
|
10
|
-
- Provide comprehensive validation for card media files
|
|
11
|
-
- Enhanced controls for images (5 MB warning threshold)
|
|
12
|
-
- Support audio/video duration validation
|
|
13
|
-
- Provide three-tier feedback: errors, warnings, recommendations
|
|
14
|
-
- Card-specific validation rules compared to general media
|
|
15
|
-
- Enable pre-upload validation workflow for cards
|
|
16
|
-
- Return actionable feedback with media-type specific recommendations
|
|
17
|
-
|
|
18
|
-
## Forbidden
|
|
19
|
-
- **DO NOT** upload files that fail validation (have errors)
|
|
20
|
-
- **DO NOT** ignore warnings - they indicate card performance issues
|
|
21
|
-
- **DO NOT** bypass file type validation
|
|
22
|
-
- **DO NOT** use mock validation in production
|
|
23
|
-
- **DO NOT** allow files exceeding 50 MB limit
|
|
24
|
-
- **DO NOT** modify files during validation
|
|
25
|
-
- **DO NOT** store validation results permanently
|
|
26
|
-
- **DO NOT** validate empty or missing files
|
|
27
|
-
- **DO NOT** suppress errors for user convenience
|
|
28
|
-
|
|
29
|
-
## Rules
|
|
30
|
-
1. Always validate before card media upload
|
|
31
|
-
2. Files over 50 MB must be rejected
|
|
32
|
-
3. Files over 10 MB trigger warning
|
|
33
|
-
4. Images over 5 MB trigger additional warning
|
|
34
|
-
5. Unsupported MIME types must be rejected
|
|
35
|
-
6. Validate file size, type, and format
|
|
36
|
-
7. Return errors array for blocking issues
|
|
37
|
-
8. Return warnings array for performance concerns
|
|
38
|
-
9. Return recommendations array for improvements
|
|
39
|
-
10. Clear validation state on new requests
|
|
40
|
-
|
|
41
|
-
## AI Agent Guidelines
|
|
42
|
-
|
|
43
|
-
When working with useCardMediaValidation hook:
|
|
44
|
-
|
|
45
|
-
1. **Card-Specific Rules**: Use for card media (not general media)
|
|
46
|
-
2. **Enhanced Image Control**: 5 MB threshold for images (stricter than general)
|
|
47
|
-
3. **Three-Tier Feedback**: Distinguish errors, warnings, recommendations
|
|
48
|
-
4. **Duration Control**: Check audio/video duration when available
|
|
49
|
-
5. **Pre-upload Check**: Always validate before useCardMediaUpload
|
|
50
|
-
|
|
51
|
-
### Validation Levels
|
|
52
|
-
|
|
53
|
-
**Errors** (Blocking - Must fix):
|
|
54
|
-
- File size exceeds 50 MB
|
|
55
|
-
- Unsupported file type
|
|
56
|
-
- Invalid file format
|
|
57
|
-
- Missing required properties
|
|
58
|
-
|
|
59
|
-
**Warnings** (Performance - Should fix):
|
|
60
|
-
- File size over 10 MB (general warning)
|
|
61
|
-
- Image size over 5 MB (card-specific warning)
|
|
62
|
-
- Long duration audio/video
|
|
63
|
-
- Large dimensions
|
|
64
|
-
|
|
65
|
-
**Recommendations** (Improvements - Optional):
|
|
66
|
-
- Reduce file size for card performance
|
|
67
|
-
- Use recommended formats
|
|
68
|
-
- Optimize dimensions
|
|
69
|
-
- Compress for balance
|
|
70
|
-
|
|
71
|
-
### Card-Specific vs General Validation
|
|
72
|
-
|
|
73
|
-
| Feature | useMediaValidation | useCardMediaValidation |
|
|
74
|
-
|---------|-------------------|------------------------|
|
|
75
|
-
| Max file size | 50 MB | 50 MB |
|
|
76
|
-
| General warning | 10 MB | 10 MB |
|
|
77
|
-
| Image warning | None | 5 MB (extra) |
|
|
78
|
-
| Duration check | No | Yes (5 min warning) |
|
|
79
|
-
| Type support | Same | Same |
|
|
80
|
-
|
|
81
|
-
### Supported File Types
|
|
82
|
-
|
|
83
|
-
**Images:**
|
|
84
|
-
- image/jpeg
|
|
85
|
-
- image/png
|
|
86
|
-
- image/webp
|
|
87
|
-
|
|
88
|
-
**Audio:**
|
|
89
|
-
- audio/mp3
|
|
90
|
-
- audio/wav
|
|
91
|
-
- audio/m4a
|
|
92
|
-
|
|
93
|
-
**Video:**
|
|
94
|
-
- video/mp4
|
|
95
|
-
- video/mov
|
|
96
|
-
|
|
97
|
-
### Validation Workflow
|
|
98
|
-
|
|
99
|
-
1. Receive file object (name, type, size, uri)
|
|
100
|
-
2. Check file size against limits
|
|
101
|
-
3. Validate MIME type
|
|
102
|
-
4. Apply card-specific rules (5 MB image warning)
|
|
103
|
-
5. Check duration if available
|
|
104
|
-
6. Generate errors, warnings, recommendations
|
|
105
|
-
7. Return CardMediaValidation object
|
|
106
|
-
|
|
107
|
-
### CardMediaValidation Structure
|
|
108
|
-
|
|
109
|
-
Validation result includes:
|
|
110
|
-
- isValid: Boolean (true if no errors)
|
|
111
|
-
- errors: String array (blocking issues)
|
|
112
|
-
- warnings: String array (performance concerns)
|
|
113
|
-
- recommendations: String array (improvements)
|
|
114
|
-
|
|
115
|
-
### File Size Guidelines
|
|
116
|
-
|
|
117
|
-
**Images:**
|
|
118
|
-
- Optimal: Under 2 MB
|
|
119
|
-
- Card warning: 2-5 MB
|
|
120
|
-
- Extra warning: 5-10 MB
|
|
121
|
-
- Error: Over 50 MB
|
|
122
|
-
|
|
123
|
-
**Audio:**
|
|
124
|
-
- Optimal: Under 5 MB
|
|
125
|
-
- Warning: 5-10 MB
|
|
126
|
-
- Duration warning: Over 5 minutes
|
|
127
|
-
- Error: Over 50 MB
|
|
128
|
-
|
|
129
|
-
**Video:**
|
|
130
|
-
- Optimal: Under 10 MB
|
|
131
|
-
- Warning: 10-50 MB
|
|
132
|
-
- Duration warning: Over 5 minutes
|
|
133
|
-
- Error: Over 50 MB
|
|
134
|
-
|
|
135
|
-
### Media Type Special Controls
|
|
136
|
-
|
|
137
|
-
**Image Controls:**
|
|
138
|
-
- Additional 5 MB warning threshold
|
|
139
|
-
- Dimension recommendations
|
|
140
|
-
- Format recommendations (JPEG for photos, PNG for graphics)
|
|
141
|
-
|
|
142
|
-
**Audio Controls:**
|
|
143
|
-
- Duration check (warn over 5 minutes)
|
|
144
|
-
- Format recommendation (MP3 preferred)
|
|
145
|
-
- Bitrate considerations
|
|
146
|
-
|
|
147
|
-
**Video Controls:**
|
|
148
|
-
- Duration check (warn over 5 minutes)
|
|
149
|
-
- Format recommendation (MP4 preferred)
|
|
150
|
-
- Resolution recommendations
|
|
151
|
-
|
|
152
|
-
### Integration with Card Upload Flow
|
|
153
|
-
|
|
154
|
-
Typical validation-upload workflow:
|
|
155
|
-
1. Select file from picker
|
|
156
|
-
2. Call validateMedia(file) from useCardMediaValidation
|
|
157
|
-
3. Check validation.isValid
|
|
158
|
-
4. If errors: Display and block upload
|
|
159
|
-
5. If warnings: Display and get confirmation
|
|
160
|
-
6. If recommendations: Display for reference
|
|
161
|
-
7. Proceed to useCardMediaUpload if valid or confirmed
|
|
162
|
-
|
|
163
|
-
### Best Practices
|
|
164
|
-
|
|
165
|
-
1. Always validate before card media upload
|
|
166
|
-
2. Show all three feedback levels to users
|
|
167
|
-
3. Allow users to proceed with warnings
|
|
168
|
-
4. Provide actionable recommendations
|
|
169
|
-
5. Consider card performance implications
|
|
170
|
-
6. Balance quality vs. file size
|
|
171
|
-
|
|
172
|
-
## Dependencies
|
|
173
|
-
|
|
174
|
-
- CardMediaValidationService (infrastructure layer)
|
|
175
|
-
- Domain types: CardMediaValidation, file input interfaces
|
|
176
|
-
- Media constants (card-specific size limits)
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Card Media Validation Hook
|
|
3
|
-
* Hook for validating card media files
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { useState, useCallback } from "react";
|
|
7
|
-
import { formatFileSize } from "../../infrastructure/utils/media-collection-utils";
|
|
8
|
-
import type { UseCardMediaValidationResult } from "./card-multimedia.types";
|
|
9
|
-
import type { CardMediaValidation, CardMediaFile } from "../../domain/entities/CardMultimedia.types";
|
|
10
|
-
|
|
11
|
-
export const useCardMediaValidation = (): UseCardMediaValidationResult => {
|
|
12
|
-
const [isValidating, setIsValidating] = useState(false);
|
|
13
|
-
const [validation, setValidation] =
|
|
14
|
-
useState<CardMediaValidation | null>(null);
|
|
15
|
-
const [error, setError] = useState<string | null>(null);
|
|
16
|
-
|
|
17
|
-
const validateMedia = useCallback(
|
|
18
|
-
async (file: CardMediaFile): Promise<CardMediaValidation> => {
|
|
19
|
-
try {
|
|
20
|
-
setIsValidating(true);
|
|
21
|
-
setError(null);
|
|
22
|
-
|
|
23
|
-
// Simulate validation
|
|
24
|
-
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
25
|
-
|
|
26
|
-
const errors: string[] = [];
|
|
27
|
-
const warnings: string[] = [];
|
|
28
|
-
const recommendations: string[] = [];
|
|
29
|
-
|
|
30
|
-
// File size validation
|
|
31
|
-
const maxSize = 50 * 1024 * 1024; // 50MB
|
|
32
|
-
if (file.size > maxSize) {
|
|
33
|
-
errors.push(
|
|
34
|
-
`File size (${formatFileSize(file.size)}) exceeds maximum allowed size (${formatFileSize(maxSize)})`,
|
|
35
|
-
);
|
|
36
|
-
} else if (file.size > 10 * 1024 * 1024) {
|
|
37
|
-
// 10MB
|
|
38
|
-
warnings.push(`Large file size may impact performance`);
|
|
39
|
-
recommendations.push("Consider compressing file");
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// File type validation
|
|
43
|
-
const supportedTypes = [
|
|
44
|
-
"image/jpeg",
|
|
45
|
-
"image/png",
|
|
46
|
-
"image/webp",
|
|
47
|
-
"audio/mp3",
|
|
48
|
-
"audio/wav",
|
|
49
|
-
"audio/m4a",
|
|
50
|
-
"video/mp4",
|
|
51
|
-
"video/mov",
|
|
52
|
-
];
|
|
53
|
-
|
|
54
|
-
if (!supportedTypes.includes(file.type)) {
|
|
55
|
-
errors.push(`Unsupported file type: ${file.type}`);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Media-specific validations
|
|
59
|
-
if (file.type.startsWith("image/")) {
|
|
60
|
-
if (file.size > 5 * 1024 * 1024) {
|
|
61
|
-
// 5MB for images
|
|
62
|
-
warnings.push("Very large image may cause performance issues");
|
|
63
|
-
recommendations.push("Consider resizing image to under 5MB");
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const result: CardMediaValidation = {
|
|
68
|
-
isValid: errors.length === 0,
|
|
69
|
-
errors,
|
|
70
|
-
warnings,
|
|
71
|
-
recommendations,
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
setValidation(result);
|
|
75
|
-
return result;
|
|
76
|
-
} catch (err) {
|
|
77
|
-
const errorMessage =
|
|
78
|
-
err instanceof Error ? err.message : "Validation failed";
|
|
79
|
-
setError(errorMessage);
|
|
80
|
-
setIsValidating(false);
|
|
81
|
-
|
|
82
|
-
return {
|
|
83
|
-
isValid: false,
|
|
84
|
-
errors: [errorMessage],
|
|
85
|
-
warnings: [],
|
|
86
|
-
recommendations: [],
|
|
87
|
-
};
|
|
88
|
-
} finally {
|
|
89
|
-
setIsValidating(false);
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
[],
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
return {
|
|
96
|
-
validateMedia,
|
|
97
|
-
isValidating,
|
|
98
|
-
validation,
|
|
99
|
-
error,
|
|
100
|
-
};
|
|
101
|
-
};
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
# useCardMultimediaFlashcard
|
|
2
|
-
|
|
3
|
-
## Purpose
|
|
4
|
-
Card-specific hook for creating and managing flashcards with media attachments using CardMediaAttachment types.
|
|
5
|
-
|
|
6
|
-
## File Location
|
|
7
|
-
`src/presentation/hooks/useCardMultimediaFlashcard.ts`
|
|
8
|
-
|
|
9
|
-
## Strategy
|
|
10
|
-
- Provide card-specific interface for flashcard creation with media
|
|
11
|
-
- Support CardMediaAttachment with position-aware media management
|
|
12
|
-
- Enable card-specific media operations (create, update, delete)
|
|
13
|
-
- Automatically analyze card media composition
|
|
14
|
-
- Calculate storage requirements for card media
|
|
15
|
-
- Track download status for offline card access
|
|
16
|
-
- Maintain card-specific ID prefixes and naming conventions
|
|
17
|
-
|
|
18
|
-
## Forbidden
|
|
19
|
-
- **DO NOT** create cards without required front/back content
|
|
20
|
-
- **DO NOT** add media without position assignment (front, back, both)
|
|
21
|
-
- **DO NOT** mix MediaAttachment with CardMediaAttachment types
|
|
22
|
-
- **DO NOT** use mock implementations in production
|
|
23
|
-
- **DO NOT** assume card media is downloaded without checking
|
|
24
|
-
- **DO NOT** modify card structure directly after creation
|
|
25
|
-
- **DO NOT** exceed practical media limits per card
|
|
26
|
-
- **DO NOT** bypass media size estimation
|
|
27
|
-
- **DO NOT** use incorrect ID prefixes (must use card_multimedia_)
|
|
28
|
-
|
|
29
|
-
## Rules
|
|
30
|
-
1. Always use CardMediaAttachment type (not MediaAttachment)
|
|
31
|
-
2. Always assign position (front, back, both) to each media
|
|
32
|
-
3. Use card_multimedia_ prefix for card IDs
|
|
33
|
-
4. Calculate estimatedSize from all card media
|
|
34
|
-
5. Populate mediaType array with unique types
|
|
35
|
-
6. Set hasMedia based on media array length
|
|
36
|
-
7. Check isDownloaded from all media attachments
|
|
37
|
-
8. Support empty media array for text-only cards
|
|
38
|
-
9. Return complete CardMultimediaFlashcard object
|
|
39
|
-
10. Clear processing state on completion
|
|
40
|
-
|
|
41
|
-
## AI Agent Guidelines
|
|
42
|
-
|
|
43
|
-
When working with useCardMultimediaFlashcard hook:
|
|
44
|
-
|
|
45
|
-
1. **Type Correctness**: Always use CardMediaAttachment (not MediaAttachment)
|
|
46
|
-
2. **Position Assignment**: Every media must have position (front, back, both)
|
|
47
|
-
3. **Media Upload**: Use useCardMediaUpload for proper type handling
|
|
48
|
-
4. **Card Analysis**: Leverage auto-generated hasMedia, mediaType, isDownloaded
|
|
49
|
-
5. **ID Prefixes**: Ensure card IDs use card_multimedia_ prefix
|
|
50
|
-
|
|
51
|
-
### Card Creation Workflow
|
|
52
|
-
|
|
53
|
-
1. Prepare card content (front, back, difficulty, tags)
|
|
54
|
-
2. Upload media using useCardMediaUpload (gets CardMediaAttachment)
|
|
55
|
-
3. Assign position to each media attachment
|
|
56
|
-
4. Call createCardMultimedia with data
|
|
57
|
-
5. Receive CardMultimediaFlashcard object
|
|
58
|
-
6. Store or display the completed card
|
|
59
|
-
|
|
60
|
-
### CardMultimediaFlashcard Structure
|
|
61
|
-
|
|
62
|
-
CardMultimediaFlashcard includes:
|
|
63
|
-
- id: Unique card ID (card_multimedia_ prefix)
|
|
64
|
-
- front: Front side content
|
|
65
|
-
- back: Back side content
|
|
66
|
-
- difficulty: easy/medium/hard
|
|
67
|
-
- tags: Topic tags array
|
|
68
|
-
- media: Array of CardMediaAttachment
|
|
69
|
-
- hasMedia: Boolean flag
|
|
70
|
-
- mediaType: Array of media types (image, audio, video)
|
|
71
|
-
- isDownloaded: Boolean (all media downloaded)
|
|
72
|
-
- estimatedSize: Total size in bytes
|
|
73
|
-
- createdAt: ISO timestamp
|
|
74
|
-
|
|
75
|
-
### CardMediaAttachment vs MediaAttachment
|
|
76
|
-
|
|
77
|
-
Key differences:
|
|
78
|
-
- CardMediaAttachment has position property (front, back, both)
|
|
79
|
-
- CardMediaAttachment IDs use card_media_ prefix
|
|
80
|
-
- CardMediaAttachment uses CardMediaPosition enum
|
|
81
|
-
- CardMediaAttachment uses CardMediaType enum
|
|
82
|
-
|
|
83
|
-
### Media Positioning Strategy
|
|
84
|
-
|
|
85
|
-
**front**: Media for front side of card
|
|
86
|
-
- Question images
|
|
87
|
-
- Prompt audio
|
|
88
|
-
- Instructional videos
|
|
89
|
-
|
|
90
|
-
**back**: Media for back side of card
|
|
91
|
-
- Answer images
|
|
92
|
-
- Explanation audio
|
|
93
|
-
- Solution videos
|
|
94
|
-
|
|
95
|
-
**both**: Media for both sides
|
|
96
|
-
- Background music
|
|
97
|
-
- Contextual images
|
|
98
|
-
- Reference materials
|
|
99
|
-
|
|
100
|
-
### Card Management Functions
|
|
101
|
-
|
|
102
|
-
**createCardMultimedia**: Create new card
|
|
103
|
-
- Requires front and back content
|
|
104
|
-
- Accepts CardMediaAttachment array
|
|
105
|
-
- Assigns unique card_multimedia_ ID
|
|
106
|
-
- Analyzes media composition
|
|
107
|
-
- Calculates storage requirements
|
|
108
|
-
|
|
109
|
-
**updateCardMedia**: Replace media on card
|
|
110
|
-
- Takes cardId and new media array
|
|
111
|
-
- Preserves card metadata
|
|
112
|
-
- Re-analyzes composition
|
|
113
|
-
- Updates size calculation
|
|
114
|
-
|
|
115
|
-
**deleteCardMedia**: Remove specific media
|
|
116
|
-
- Takes attachmentId (card_media_ prefix)
|
|
117
|
-
- Updates media array
|
|
118
|
-
- Recalculates size
|
|
119
|
-
- Updates analysis
|
|
120
|
-
|
|
121
|
-
### Integration with Card Hooks
|
|
122
|
-
|
|
123
|
-
Use with card-specific hooks:
|
|
124
|
-
- useCardMediaUpload: Upload with CardMediaAttachment type
|
|
125
|
-
- useCardMediaValidation: Validate with card-specific rules
|
|
126
|
-
- useCardMediaGeneration: Generate AI media for cards
|
|
127
|
-
|
|
128
|
-
### Card Media Analysis
|
|
129
|
-
|
|
130
|
-
**hasMedia**: True if media array length > 0
|
|
131
|
-
**mediaType**: Unique array ['image', 'audio', 'video'] based on media
|
|
132
|
-
**isDownloaded**: True if all media.isDownloaded are true
|
|
133
|
-
**estimatedSize**: Sum of all media.fileSize values
|
|
134
|
-
|
|
135
|
-
### Performance Guidelines
|
|
136
|
-
|
|
137
|
-
- Limit to 5-10 media items per card
|
|
138
|
-
- Warn if estimatedSize exceeds 25 MB
|
|
139
|
-
- Use position to organize media effectively
|
|
140
|
-
- Consider download status for offline usage
|
|
141
|
-
- Balance media types across card sides
|
|
142
|
-
|
|
143
|
-
### Best Practices
|
|
144
|
-
|
|
145
|
-
1. Always assign meaningful positions to media
|
|
146
|
-
2. Use tags for card organization and filtering
|
|
147
|
-
3. Set appropriate difficulty levels
|
|
148
|
-
4. Balance media between front and back
|
|
149
|
-
5. Consider offline usage patterns
|
|
150
|
-
6. Validate media before adding to cards
|
|
151
|
-
|
|
152
|
-
## Dependencies
|
|
153
|
-
|
|
154
|
-
- CardMultimediaFlashcardService (infrastructure layer)
|
|
155
|
-
- Domain types: CardMultimediaFlashcard, CardMediaAttachment
|
|
156
|
-
- useCardMediaUpload (for card-specific upload)
|
|
157
|
-
- useCardMediaValidation (for card-specific validation)
|
|
158
|
-
- useCardMediaGeneration (for card AI media)
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
# useMedia
|
|
2
|
-
|
|
3
|
-
## Purpose
|
|
4
|
-
Core React hook for media selection operations (image/video picking, camera access) in React Native applications.
|
|
5
|
-
|
|
6
|
-
## File Location
|
|
7
|
-
`src/presentation/hooks/useMedia.ts`
|
|
8
|
-
|
|
9
|
-
## Strategy
|
|
10
|
-
- Provide unified interface for media picker and camera operations
|
|
11
|
-
- Abstract expo-image-picker complexity from components
|
|
12
|
-
- Centralize permission management logic
|
|
13
|
-
- Maintain consistent state management across media operations
|
|
14
|
-
- Enable type-safe media operations with proper TypeScript interfaces
|
|
15
|
-
- Support single and multiple media selection workflows
|
|
16
|
-
- Handle loading states and error propagation
|
|
17
|
-
|
|
18
|
-
## Forbidden
|
|
19
|
-
- **DO NOT** expose expo-image-picker implementation details to consumers
|
|
20
|
-
- **DO NOT** automatically request permissions without explicit user action
|
|
21
|
-
- **DO NOT** mix camera and library picker logic in single operations
|
|
22
|
-
- **DO NOT** assume permission states - always check before operations
|
|
23
|
-
- **DO NOT** bypass error handling or loading states
|
|
24
|
-
- **DO NOT** use mock implementations in production without clear warnings
|
|
25
|
-
- **DO NOT** allow operations while previous operation is in progress
|
|
26
|
-
- **DO NOT** modify media assets after selection
|
|
27
|
-
- **DO NOT** store selected media permanently in hook state
|
|
28
|
-
|
|
29
|
-
## Rules
|
|
30
|
-
1. Always check permission status before camera/library operations
|
|
31
|
-
2. All picker operations must return MediaPickerResult with canceled flag
|
|
32
|
-
3. Loading state must be true during async operations
|
|
33
|
-
4. Error state must be cleared on new operation attempts
|
|
34
|
-
5. Permission requests must be explicit, not automatic
|
|
35
|
-
6. Selected media must be validated against type definitions
|
|
36
|
-
7. Quality parameters must be in 0-1 range
|
|
37
|
-
8. Aspect ratio must be [width, height] tuple
|
|
38
|
-
9. File size must be included when available from picker
|
|
39
|
-
10. Support both single and multiple selection based on function used
|
|
40
|
-
|
|
41
|
-
## AI Agent Guidelines
|
|
42
|
-
|
|
43
|
-
When working with useMedia hook:
|
|
44
|
-
|
|
45
|
-
1. **Permission First**: Always request/check permissions before calling picker or camera functions
|
|
46
|
-
2. **State Management**: Use isLoading to prevent duplicate operations during active calls
|
|
47
|
-
3. **Error Handling**: Always check error state and handle user cancellation (canceled: true)
|
|
48
|
-
4. **Type Safety**: Use MediaPickerOptions and CameraOptions interfaces for configuration
|
|
49
|
-
5. **Validation**: Validate returned assets before processing (check if assets array exists)
|
|
50
|
-
|
|
51
|
-
### Key Functions
|
|
52
|
-
|
|
53
|
-
- **pickImage**: Single image selection from library with optional editing
|
|
54
|
-
- **pickMultipleImages**: Multiple image selection with selection limit
|
|
55
|
-
- **pickVideo**: Video selection from library
|
|
56
|
-
- **launchCamera**: Photo capture via device camera
|
|
57
|
-
- **launchCameraForVideo**: Video recording via device camera
|
|
58
|
-
- **requestCameraPermission**: Request camera access permission
|
|
59
|
-
- **requestMediaLibraryPermission**: Request photo library access permission
|
|
60
|
-
- **getCameraPermissionStatus**: Check current camera permission state
|
|
61
|
-
- **getMediaLibraryPermissionStatus**: Check current library permission state
|
|
62
|
-
|
|
63
|
-
### Media Selection Workflow
|
|
64
|
-
|
|
65
|
-
1. Check permission status before operation
|
|
66
|
-
2. Request permission if not granted
|
|
67
|
-
3. Call appropriate picker/camera function with options
|
|
68
|
-
4. Check canceled flag before processing assets
|
|
69
|
-
5. Validate assets array exists and has items
|
|
70
|
-
6. Process first asset (or all for multiple selection)
|
|
71
|
-
|
|
72
|
-
### Quality Guidelines
|
|
73
|
-
|
|
74
|
-
- HIGH (1.0): Original quality, largest file size
|
|
75
|
-
- MEDIUM (0.7): Balanced quality and size (recommended)
|
|
76
|
-
- LOW (0.3): Smallest file size, reduced quality
|
|
77
|
-
|
|
78
|
-
### Platform Requirements
|
|
79
|
-
|
|
80
|
-
- **iOS**: Add NSCameraUsageDescription and NSPhotoLibraryUsageDescription to Info.plist
|
|
81
|
-
- **Android**: Add CAMERA and READ_EXTERNAL_STORAGE permissions to AndroidManifest.xml
|
|
82
|
-
|
|
83
|
-
### State Management
|
|
84
|
-
|
|
85
|
-
- **isLoading**: True during any async picker/camera operation
|
|
86
|
-
- **error**: String error message or null, cleared on new operations
|
|
87
|
-
- **MediaPickerResult.canceled**: True when user cancels operation
|
|
88
|
-
- **MediaPickerResult.assets**: Array of selected media or undefined
|
|
89
|
-
|
|
90
|
-
## Dependencies
|
|
91
|
-
|
|
92
|
-
- MediaPickerService (infrastructure layer)
|
|
93
|
-
- Domain types: MediaAsset, MediaPickerResult, MediaPickerOptions, CameraOptions
|
|
94
|
-
- expo-image-picker (via service layer)
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
# useMediaGeneration
|
|
2
|
-
|
|
3
|
-
## Purpose
|
|
4
|
-
React hook for AI-powered media generation (text-to-image, text-to-audio) with result tracking.
|
|
5
|
-
|
|
6
|
-
## File Location
|
|
7
|
-
`src/presentation/hooks/useMediaGeneration.ts`
|
|
8
|
-
|
|
9
|
-
## Strategy
|
|
10
|
-
- Provide unified interface for AI media generation operations
|
|
11
|
-
- Support multiple generation types (text-to-image, text-to-audio)
|
|
12
|
-
- Track generation status and progress
|
|
13
|
-
- Manage credit usage and balance tracking
|
|
14
|
-
- Handle generation errors gracefully
|
|
15
|
-
- Return structured results with metadata
|
|
16
|
-
- Support customizable generation options
|
|
17
|
-
|
|
18
|
-
## Forbidden
|
|
19
|
-
- **DO NOT** start new generation while previous is in progress
|
|
20
|
-
- **DO NOT** ignore credit costs before generation
|
|
21
|
-
- **DO NOT** mock generation process in production without API integration
|
|
22
|
-
- **DO NOT** assume generation will succeed - always check result.success
|
|
23
|
-
- **DO NOT** expose API keys or AI service implementation details
|
|
24
|
-
- **DO NOT** allow unlimited concurrent generations
|
|
25
|
-
- **DO NOT** bypass generation timeout handling
|
|
26
|
-
- **DO NOT** store large generation results permanently in hook state
|
|
27
|
-
- **DO NOT** use empty or invalid prompts for generation
|
|
28
|
-
|
|
29
|
-
## Rules
|
|
30
|
-
1. Always validate prompt text before generation
|
|
31
|
-
2. Check credit availability before generation operations
|
|
32
|
-
3. Track processing time for each generation request
|
|
33
|
-
4. Return unique requestId for each generation
|
|
34
|
-
5. Support maxResults parameter for multiple outputs
|
|
35
|
-
6. Generation state must be cleared on new operations
|
|
36
|
-
7. Include creditsUsed in result metadata
|
|
37
|
-
8. Handle both success and failure in result object
|
|
38
|
-
9. Support language and voice options for audio generation
|
|
39
|
-
10. Support style options for image generation
|
|
40
|
-
|
|
41
|
-
## AI Agent Guidelines
|
|
42
|
-
|
|
43
|
-
When working with useMediaGeneration hook:
|
|
44
|
-
|
|
45
|
-
1. **Prompt Quality**: Use descriptive, specific prompts for better results
|
|
46
|
-
2. **Credit Management**: Track credit costs and balance before operations
|
|
47
|
-
3. **Error Handling**: Always check result.success field
|
|
48
|
-
4. **Result Processing**: Validate attachments array before use
|
|
49
|
-
5. **Options**: Use appropriate options for generation type
|
|
50
|
-
|
|
51
|
-
### Generation Types
|
|
52
|
-
|
|
53
|
-
**Text-to-Image** (type: 'text_to_image')
|
|
54
|
-
- Generates images from text descriptions
|
|
55
|
-
- Credit cost: 5 per generation
|
|
56
|
-
- Default maxResults: 1
|
|
57
|
-
- Supports style customization
|
|
58
|
-
|
|
59
|
-
**Text-to-Audio** (type: 'text_to_audio')
|
|
60
|
-
- Generates audio from text (text-to-speech)
|
|
61
|
-
- Credit cost: 3 per generation
|
|
62
|
-
- Default duration: 10 seconds
|
|
63
|
-
- Supports voice, language, speed options
|
|
64
|
-
|
|
65
|
-
### Generation Workflow
|
|
66
|
-
|
|
67
|
-
1. Validate prompt text quality and length
|
|
68
|
-
2. Check available credits
|
|
69
|
-
3. Configure generation options
|
|
70
|
-
4. Call generateMedia with request
|
|
71
|
-
5. Monitor isGenerating state
|
|
72
|
-
6. Process generationResult on completion
|
|
73
|
-
7. Handle errors with user feedback
|
|
74
|
-
|
|
75
|
-
### Result Structure
|
|
76
|
-
|
|
77
|
-
GenerationResult includes:
|
|
78
|
-
- success: Boolean indicating success/failure
|
|
79
|
-
- attachments: Array of generated MediaAttachment
|
|
80
|
-
- creditsUsed: Number of credits consumed
|
|
81
|
-
- processingTime: Duration in milliseconds
|
|
82
|
-
- requestId: Unique request identifier
|
|
83
|
-
- error: Error message if failed
|
|
84
|
-
|
|
85
|
-
### Generation Options
|
|
86
|
-
|
|
87
|
-
**Image Options:**
|
|
88
|
-
- maxResults: Number of images to generate (default: 1)
|
|
89
|
-
- style: Image style preset
|
|
90
|
-
|
|
91
|
-
**Audio Options:**
|
|
92
|
-
- voice: Voice type (male/female)
|
|
93
|
-
- language: Language code (e.g., 'tr-TR', 'en-US')
|
|
94
|
-
- speed: Playback speed (default: 1.0)
|
|
95
|
-
|
|
96
|
-
### Integration Requirements
|
|
97
|
-
|
|
98
|
-
- Configure AI API endpoints
|
|
99
|
-
- Implement authentication for AI services
|
|
100
|
-
- Handle rate limiting and quotas
|
|
101
|
-
- Implement retry logic for failed generations
|
|
102
|
-
- Cache generation results when appropriate
|
|
103
|
-
- Monitor credit balance and usage
|
|
104
|
-
|
|
105
|
-
### Error Scenarios
|
|
106
|
-
|
|
107
|
-
- Insufficient credits: Check balance before generation
|
|
108
|
-
- Invalid prompt: Validate text quality and length
|
|
109
|
-
- API timeout: Implement retry with exponential backoff
|
|
110
|
-
- Content policy violations: Filter and validate prompts
|
|
111
|
-
- Service unavailable: Graceful degradation with error message
|
|
112
|
-
|
|
113
|
-
## Dependencies
|
|
114
|
-
|
|
115
|
-
- MediaGenerationService (infrastructure layer)
|
|
116
|
-
- Domain types: MediaGenerationRequest, MediaGenerationResult, MediaAttachment
|
|
117
|
-
- Credit/balance tracking system
|
|
118
|
-
- AI service APIs (text-to-image, text-to-speech)
|