@umituz/react-native-design-system 4.23.100 → 4.23.102
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/media/index.ts +26 -22
- package/src/media/infrastructure/utils/media-collection-utils.ts +4 -2
- package/src/molecules/navigation/utils/AppNavigation.ts +3 -3
- package/src/storage/infrastructure/adapters/StorageService.ts +3 -3
- package/src/storage/infrastructure/repositories/BaseStorageOperations.ts +9 -9
- package/src/storage/presentation/hooks/CacheStorageOperations.ts +3 -3
- package/src/storage/presentation/hooks/useStore.ts +0 -1
- package/src/media/domain/entities/CardMultimedia.types.README.md +0 -129
- package/src/media/domain/entities/Media.README.md +0 -80
- package/src/media/domain/entities/MultimediaFlashcardTypes.README.md +0 -144
- package/src/media/domain/entities/MultimediaFlashcardTypes.ts +0 -120
- package/src/media/domain/utils/MediaUtils.README.md +0 -178
- package/src/media/index.ts.README.md +0 -191
- 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/MediaGenerationService.ts +0 -80
- package/src/media/infrastructure/services/MediaOptimizerService.README.md +0 -145
- package/src/media/infrastructure/services/MediaOptimizerService.ts +0 -32
- package/src/media/infrastructure/services/MediaPickerService.README.md +0 -106
- package/src/media/infrastructure/services/MediaPickerService.ts +0 -157
- package/src/media/infrastructure/services/MediaSaveService.README.md +0 -120
- package/src/media/infrastructure/services/MediaSaveService.ts +0 -97
- package/src/media/infrastructure/services/MediaUploadService.README.md +0 -135
- package/src/media/infrastructure/services/MediaUploadService.ts +0 -60
- package/src/media/infrastructure/services/MediaValidationService.README.md +0 -135
- package/src/media/infrastructure/services/MediaValidationService.ts +0 -61
- package/src/media/infrastructure/services/MultimediaFlashcardService.README.md +0 -142
- package/src/media/infrastructure/services/MultimediaFlashcardService.ts +0 -96
- 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/multimedia.types.ts +0 -53
- package/src/media/presentation/hooks/useCardMediaGeneration.ts +0 -20
- package/src/media/presentation/hooks/useCardMediaUpload.ts +0 -84
- package/src/media/presentation/hooks/useCardMediaValidation.ts +0 -104
- package/src/media/presentation/hooks/useCardMultimediaFlashcard.README.md +0 -158
- package/src/media/presentation/hooks/useCardMultimediaFlashcard.ts +0 -102
- package/src/media/presentation/hooks/useMedia.README.md +0 -94
- package/src/media/presentation/hooks/useMedia.ts +0 -190
- package/src/media/presentation/hooks/useMediaGeneration.README.md +0 -118
- package/src/media/presentation/hooks/useMediaGeneration.ts +0 -18
- package/src/media/presentation/hooks/useMediaUpload.README.md +0 -108
- package/src/media/presentation/hooks/useMediaUpload.ts +0 -84
- package/src/media/presentation/hooks/useMediaValidation.README.md +0 -134
- package/src/media/presentation/hooks/useMediaValidation.ts +0 -93
- package/src/media/presentation/hooks/useMultimediaFlashcard.README.md +0 -141
- package/src/media/presentation/hooks/useMultimediaFlashcard.ts +0 -101
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Multimedia Flashcard Types
|
|
3
|
-
* Extended media types for flashcard support
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
export type MediaType = "image" | "audio" | "video";
|
|
7
|
-
export type MediaPosition = "front" | "back" | "both";
|
|
8
|
-
|
|
9
|
-
export interface MediaAttachment {
|
|
10
|
-
id: string;
|
|
11
|
-
type: MediaType;
|
|
12
|
-
position: MediaPosition;
|
|
13
|
-
url: string;
|
|
14
|
-
localPath?: string;
|
|
15
|
-
filename: string;
|
|
16
|
-
fileSize: number;
|
|
17
|
-
mimeType: string;
|
|
18
|
-
duration?: number; // For audio/video in seconds
|
|
19
|
-
thumbnailUrl?: string; // For videos
|
|
20
|
-
caption?: string;
|
|
21
|
-
isDownloaded: boolean;
|
|
22
|
-
createdAt: string;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface MultimediaFlashcard {
|
|
26
|
-
id: string;
|
|
27
|
-
front: string;
|
|
28
|
-
back: string;
|
|
29
|
-
difficulty: "easy" | "medium" | "hard";
|
|
30
|
-
tags: string[];
|
|
31
|
-
createdAt?: string;
|
|
32
|
-
updatedAt?: string;
|
|
33
|
-
// Extended properties for multimedia support
|
|
34
|
-
media: MediaAttachment[];
|
|
35
|
-
hasMedia: boolean; // Computed property
|
|
36
|
-
mediaType: MediaType[]; // Array of media types present
|
|
37
|
-
isDownloaded: boolean; // All media downloaded?
|
|
38
|
-
estimatedSize: number; // Total size in bytes
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export interface MediaGenerationRequest {
|
|
42
|
-
type: "text_to_image" | "text_to_audio" | "image_search";
|
|
43
|
-
input: {
|
|
44
|
-
text?: string;
|
|
45
|
-
prompt?: string;
|
|
46
|
-
language?: string;
|
|
47
|
-
voice?: "male" | "female" | "neutral";
|
|
48
|
-
style?: "realistic" | "cartoon" | "artistic";
|
|
49
|
-
};
|
|
50
|
-
options: {
|
|
51
|
-
maxResults?: number;
|
|
52
|
-
quality?: "low" | "medium" | "high";
|
|
53
|
-
format?: "jpeg" | "png" | "mp3" | "wav";
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export interface MediaGenerationResult {
|
|
58
|
-
success: boolean;
|
|
59
|
-
attachments: MediaAttachment[];
|
|
60
|
-
creditsUsed: number;
|
|
61
|
-
processingTime: number;
|
|
62
|
-
error?: string;
|
|
63
|
-
requestId: string;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export interface MediaUploadProgress {
|
|
67
|
-
fileId: string;
|
|
68
|
-
progress: number; // 0-100
|
|
69
|
-
status: "uploading" | "processing" | "completed" | "error";
|
|
70
|
-
error?: string;
|
|
71
|
-
url?: string;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export interface MediaCompressionOptions {
|
|
75
|
-
quality: number; // 0.1 - 1.0
|
|
76
|
-
maxWidth?: number;
|
|
77
|
-
maxHeight?: number;
|
|
78
|
-
maxFileSize?: number; // bytes
|
|
79
|
-
format?: "jpeg" | "png" | "webp";
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export interface MediaFile {
|
|
83
|
-
name: string;
|
|
84
|
-
type: string;
|
|
85
|
-
size: number;
|
|
86
|
-
uri?: string;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export interface CreateMultimediaCardData {
|
|
90
|
-
front: string;
|
|
91
|
-
back: string;
|
|
92
|
-
difficulty?: "easy" | "medium" | "hard";
|
|
93
|
-
tags?: string[];
|
|
94
|
-
media?: MediaAttachment[];
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export interface MediaValidation {
|
|
98
|
-
isValid: boolean;
|
|
99
|
-
errors: string[];
|
|
100
|
-
warnings: string[];
|
|
101
|
-
recommendations: string[];
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export interface MultimediaFlashcardService {
|
|
105
|
-
uploadMedia(
|
|
106
|
-
file: MediaFile,
|
|
107
|
-
options?: MediaCompressionOptions,
|
|
108
|
-
): Promise<MediaAttachment>;
|
|
109
|
-
generateMedia(
|
|
110
|
-
request: MediaGenerationRequest,
|
|
111
|
-
): Promise<MediaGenerationResult>;
|
|
112
|
-
validateMedia(file: MediaFile): Promise<MediaValidation>;
|
|
113
|
-
optimizeMedia(
|
|
114
|
-
attachment: MediaAttachment,
|
|
115
|
-
options: MediaCompressionOptions,
|
|
116
|
-
): Promise<MediaAttachment>;
|
|
117
|
-
deleteMedia(attachmentId: string): Promise<void>;
|
|
118
|
-
getMediaUrl(attachmentId: string): Promise<string>;
|
|
119
|
-
downloadMedia(attachmentId: string): Promise<string>; // Returns local path
|
|
120
|
-
}
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
# MediaUtils
|
|
2
|
-
|
|
3
|
-
## Purpose
|
|
4
|
-
Utility class containing helper functions for media operations, validation, and calculations. Provides static methods for file type detection, dimension calculations, format conversions, and media validation.
|
|
5
|
-
|
|
6
|
-
## File Location
|
|
7
|
-
`src/domain/utils/MediaUtils.ts`
|
|
8
|
-
|
|
9
|
-
## Strategy
|
|
10
|
-
- Provide framework-agnostic utility functions for media operations
|
|
11
|
-
- Enable consistent media type detection and validation
|
|
12
|
-
- Support dimension calculations and scaling operations
|
|
13
|
-
- Facilitate format conversions and MIME type mappings
|
|
14
|
-
- Maintain aspect ratio preservation during transformations
|
|
15
|
-
- Validate media constraints (dimensions, file types, sizes)
|
|
16
|
-
- Provide helper functions for common media operations
|
|
17
|
-
|
|
18
|
-
## Forbidden
|
|
19
|
-
- **DO NOT** import external libraries (expo-image-picker, react-native) in utility functions
|
|
20
|
-
- **DO NOT** include business logic or application-specific rules
|
|
21
|
-
- **DO NOT** create instance methods - all methods must be static
|
|
22
|
-
- **DO NOT** store state or maintain mutable properties
|
|
23
|
-
- **DO NOT** make network calls or async operations in utility methods
|
|
24
|
-
- **DO NOT** hardcode platform-specific behavior
|
|
25
|
-
- **DO NOT** include UI-related logic or formatting for display
|
|
26
|
-
- **DO NOT** modify input parameters - always return new objects/values
|
|
27
|
-
- **DO NOT** throw exceptions for validation failures - return boolean results
|
|
28
|
-
- **DO NOT** assume specific file systems or storage mechanisms
|
|
29
|
-
|
|
30
|
-
## Rules
|
|
31
|
-
1. All methods must be static and stateless
|
|
32
|
-
2. All methods must be synchronous and pure functions
|
|
33
|
-
3. Input validation must not throw exceptions
|
|
34
|
-
4. Dimension calculations must preserve aspect ratios
|
|
35
|
-
5. MIME type mappings must use standard MIME types
|
|
36
|
-
6. Maximum dimension limit is 8192x8192 pixels
|
|
37
|
-
7. Minimum dimension limit is 1x1 pixels
|
|
38
|
-
8. File type detection must use extension checking
|
|
39
|
-
9. Scale calculations must return integer values
|
|
40
|
-
10. Aspect ratio must be calculated as width/height
|
|
41
|
-
11. Unknown MIME types must map to MediaType.ALL
|
|
42
|
-
12. Format validation must use supported format lists
|
|
43
|
-
13. All methods must handle edge cases (zero, negative values)
|
|
44
|
-
14. Return types must be consistent (boolean for validation, numbers for calculations)
|
|
45
|
-
|
|
46
|
-
## AI Agent Guidelines
|
|
47
|
-
|
|
48
|
-
When working with MediaUtils:
|
|
49
|
-
|
|
50
|
-
1. **Static Usage**: Always call methods on the class, never create instances
|
|
51
|
-
2. **Type Detection**: Use isImage() and isVideo() before processing files
|
|
52
|
-
3. **Validation**: Always validate dimensions before scaling operations
|
|
53
|
-
4. **Aspect Ratios**: Preserve aspect ratios when calculating scaled dimensions
|
|
54
|
-
5. **MIME Types**: Use getImageMimeType() for format-to-MIME conversion
|
|
55
|
-
6. **Media Type Parsing**: Use parseMediaType() to convert MIME to MediaType enum
|
|
56
|
-
7. **Error Handling**: Check boolean return values for validation failures
|
|
57
|
-
8. **Edge Cases**: Handle zero and negative dimensions appropriately
|
|
58
|
-
9. **Performance**: Utility methods are lightweight and can be called frequently
|
|
59
|
-
|
|
60
|
-
### Key Methods Reference
|
|
61
|
-
|
|
62
|
-
- **isImage(uri: string)**: boolean - Check if file is an image by extension
|
|
63
|
-
- **isVideo(uri: string)**: boolean - Check if file is a video by extension
|
|
64
|
-
- **getImageMimeType(format: ImageFormat)**: string - Get MIME type for image format
|
|
65
|
-
- **calculateAspectRatio(width, height)**: number - Calculate width/height ratio
|
|
66
|
-
- **getScaledDimensions(width, height, maxWidth, maxHeight)**: object - Calculate scaled dimensions preserving aspect ratio
|
|
67
|
-
- **isValidDimensions(width, height)**: boolean - Validate dimensions are within allowed range
|
|
68
|
-
- **parseMediaType(mimeType: string)**: MediaType - Convert MIME type to MediaType enum
|
|
69
|
-
|
|
70
|
-
### Method Usage Guidelines
|
|
71
|
-
|
|
72
|
-
**File Type Detection:**
|
|
73
|
-
1. Use isImage() to validate image files before processing
|
|
74
|
-
2. Use isVideo() to validate video files before processing
|
|
75
|
-
3. Both methods check file extensions (jpg, png, mp4, mov, etc.)
|
|
76
|
-
4. Returns false for unknown or unsupported formats
|
|
77
|
-
|
|
78
|
-
**Dimension Calculations:**
|
|
79
|
-
1. Always validate dimensions with isValidDimensions() before processing
|
|
80
|
-
2. Use calculateAspectRatio() to understand image proportions
|
|
81
|
-
3. Use getScaledDimensions() to resize while preserving aspect ratio
|
|
82
|
-
4. Scaled dimensions will never exceed maxWidth or maxHeight
|
|
83
|
-
5. Aspect ratio is maintained even when only one dimension exceeds limits
|
|
84
|
-
|
|
85
|
-
**Format Conversions:**
|
|
86
|
-
1. Use getImageMimeType() to get standard MIME type from format enum
|
|
87
|
-
2. Use parseMediaType() to convert MIME strings to MediaType enum
|
|
88
|
-
3. Unknown MIME types return MediaType.ALL
|
|
89
|
-
4. MIME type mappings are constant and cannot be modified
|
|
90
|
-
|
|
91
|
-
### Validation Rules
|
|
92
|
-
|
|
93
|
-
1. **isValidDimensions**:
|
|
94
|
-
- Width and height must be positive integers
|
|
95
|
-
- Maximum allowed dimension is 8192 pixels
|
|
96
|
-
- Minimum allowed dimension is 1 pixel
|
|
97
|
-
- Returns false for zero or negative values
|
|
98
|
-
- Returns false for values exceeding 8192
|
|
99
|
-
|
|
100
|
-
2. **Aspect Ratio Calculations**:
|
|
101
|
-
- Must preserve original ratio in scaled dimensions
|
|
102
|
-
- Calculated as width divided by height
|
|
103
|
-
- Square images (1:1) return ratio of 1.0
|
|
104
|
-
- Widescreen (16:9) returns ratio of approximately 1.78
|
|
105
|
-
- Portrait (9:16) returns ratio of approximately 0.56
|
|
106
|
-
|
|
107
|
-
3. **Scaling Operations**:
|
|
108
|
-
- Input dimensions can be any positive integers
|
|
109
|
-
- Output dimensions never exceed maxWidth or maxHeight
|
|
110
|
-
- Aspect ratio is always preserved
|
|
111
|
-
- Returns integer dimensions (not floating point)
|
|
112
|
-
- If both dimensions are within limits, returns original dimensions
|
|
113
|
-
- If only one dimension exceeds limit, scales proportionally
|
|
114
|
-
|
|
115
|
-
### MIME Type Handling
|
|
116
|
-
|
|
117
|
-
**Supported Image MIME Types:**
|
|
118
|
-
- PNG: "image/png"
|
|
119
|
-
- JPEG: "image/jpeg"
|
|
120
|
-
- WEBP: "image/webp"
|
|
121
|
-
|
|
122
|
-
**MediaType Mapping:**
|
|
123
|
-
- "image/*" formats return MediaType.IMAGE
|
|
124
|
-
- "video/*" formats return MediaType.VIDEO
|
|
125
|
-
- Unknown formats return MediaType.ALL
|
|
126
|
-
- Mapping is based on MIME type prefix
|
|
127
|
-
|
|
128
|
-
### Constants Reference
|
|
129
|
-
|
|
130
|
-
- **IMAGE_MIME_TYPES**: Readonly object mapping image formats to MIME types
|
|
131
|
-
- Keys: "png", "jpeg", "webp"
|
|
132
|
-
- Values: Standard MIME type strings
|
|
133
|
-
- Used by getImageMimeType() method
|
|
134
|
-
|
|
135
|
-
### Common Use Cases
|
|
136
|
-
|
|
137
|
-
**Image Validation Pipeline:**
|
|
138
|
-
1. Check file type with isImage()
|
|
139
|
-
2. Validate dimensions with isValidDimensions()
|
|
140
|
-
3. Calculate aspect ratio with calculateAspectRatio()
|
|
141
|
-
4. Get MIME type with getImageMimeType()
|
|
142
|
-
5. Scale if needed with getScaledDimensions()
|
|
143
|
-
|
|
144
|
-
**Video Validation Pipeline:**
|
|
145
|
-
1. Check file type with isVideo()
|
|
146
|
-
2. Validate dimensions with isValidDimensions()
|
|
147
|
-
3. Parse media type with parseMediaType()
|
|
148
|
-
4. Scale if needed with getScaledDimensions()
|
|
149
|
-
|
|
150
|
-
**Format Conversion:**
|
|
151
|
-
1. Convert format enum to MIME type using getImageMimeType()
|
|
152
|
-
2. Convert MIME type to MediaType using parseMediaType()
|
|
153
|
-
3. Use MediaType for filtering and type checking
|
|
154
|
-
|
|
155
|
-
### Edge Case Handling
|
|
156
|
-
|
|
157
|
-
1. **Zero dimensions**: isValidDimensions() returns false
|
|
158
|
-
2. **Negative dimensions**: isValidDimensions() returns false
|
|
159
|
-
3. **Oversized dimensions**: isValidDimensions() returns false if > 8192
|
|
160
|
-
4. **Unknown file extensions**: isImage() and isVideo() return false
|
|
161
|
-
5. **Unknown MIME types**: parseMediaType() returns MediaType.ALL
|
|
162
|
-
6. **Equal aspect ratios**: getScaledDimensions() returns original if within limits
|
|
163
|
-
|
|
164
|
-
### Performance Considerations
|
|
165
|
-
|
|
166
|
-
1. All methods are synchronous and execute in O(1) time
|
|
167
|
-
2. No network calls or I/O operations
|
|
168
|
-
3. No side effects or state mutations
|
|
169
|
-
4. Safe to call frequently in loops or render cycles
|
|
170
|
-
5. No memory allocation beyond return values
|
|
171
|
-
|
|
172
|
-
## Dependencies
|
|
173
|
-
|
|
174
|
-
- No external dependencies
|
|
175
|
-
- References ImageFormat enum from domain types
|
|
176
|
-
- References MediaType enum from domain types
|
|
177
|
-
- Pure utility functions with no side effects
|
|
178
|
-
- Can be used by any layer without additional dependencies
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
# @umituz/react-native-media - Main Export
|
|
2
|
-
|
|
3
|
-
## Purpose
|
|
4
|
-
Main entry point for the library. Exports all services, hooks, types, and utilities for media management in React Native applications.
|
|
5
|
-
|
|
6
|
-
## File Location
|
|
7
|
-
`src/index.ts`
|
|
8
|
-
|
|
9
|
-
## Strategy
|
|
10
|
-
- Provide a single import point for all library functionality
|
|
11
|
-
- Organize exports by category (services, hooks, types, utils)
|
|
12
|
-
- Enable tree-shaking by using named exports
|
|
13
|
-
- Maintain clear separation between general media and card-specific features
|
|
14
|
-
- Support both individual imports and bulk imports
|
|
15
|
-
|
|
16
|
-
## Forbidden
|
|
17
|
-
- **DO NOT** add default exports - only named exports
|
|
18
|
-
- **DO NOT** re-export external dependencies directly
|
|
19
|
-
- **DO NOT** create circular import dependencies
|
|
20
|
-
- **DO NOT** mix categories in export groups
|
|
21
|
-
- **DO NOT** export internal implementation details
|
|
22
|
-
- **DO NOT** use wildcard exports from sub-modules
|
|
23
|
-
- **DO NOT** change export names once published
|
|
24
|
-
|
|
25
|
-
## Rules
|
|
26
|
-
1. All public exports must be re-exported from this file
|
|
27
|
-
2. Exports must be organized by category (services, hooks, types, utils)
|
|
28
|
-
3. Each category must be clearly commented
|
|
29
|
-
4. General media features must be separate from card-specific features
|
|
30
|
-
5. Type exports must use `export type` for tree-shaking
|
|
31
|
-
6. Service exports must be singleton instances or static classes
|
|
32
|
-
7. Hook exports must be named with `use` prefix
|
|
33
|
-
8. All exports must have TypeScript types
|
|
34
|
-
9. Breaking changes require major version bump
|
|
35
|
-
10. All exports must be documented in their respective README files
|
|
36
|
-
|
|
37
|
-
## AI Agent Guidelines
|
|
38
|
-
|
|
39
|
-
### Import Strategy
|
|
40
|
-
|
|
41
|
-
When working with this library:
|
|
42
|
-
|
|
43
|
-
1. **Single Entry Point**: All imports should come from `@umituz/react-native-media`
|
|
44
|
-
2. **Specific Imports**: Import only what you need for better tree-shaking
|
|
45
|
-
3. **Type Imports**: Use `import type` for type-only imports
|
|
46
|
-
4. **Category Awareness**: Understand the difference between general and card-specific features
|
|
47
|
-
|
|
48
|
-
### Export Categories
|
|
49
|
-
|
|
50
|
-
#### Services (Infrastructure Layer)
|
|
51
|
-
All services follow singleton pattern:
|
|
52
|
-
- `MediaPickerService` - Image/video selection from camera and gallery
|
|
53
|
-
- `MediaSaveService` - Saving media to device gallery
|
|
54
|
-
- `MediaUploadService` - Upload/download media and URL management
|
|
55
|
-
- `MediaGenerationService` - AI-powered text-to-image and text-to-audio
|
|
56
|
-
- `MediaValidationService` - File validation before upload
|
|
57
|
-
- `MediaOptimizerService` - Compression and optimization
|
|
58
|
-
- `CardMultimediaService` - Card-specific media operations
|
|
59
|
-
- `CardMediaGenerationService` - Card AI generation with image search
|
|
60
|
-
- `CardMediaUploadService` - Card upload with position support
|
|
61
|
-
- `CardMediaValidationService` - Card validation with stricter rules
|
|
62
|
-
- `CardMediaOptimizerService` - Card optimization
|
|
63
|
-
- `MultimediaFlashcardService` - Main flashcard service
|
|
64
|
-
- `CardMultimediaFlashcardService` - Main card flashcard service
|
|
65
|
-
|
|
66
|
-
#### Hooks (Presentation Layer)
|
|
67
|
-
All hooks are named with `use` prefix:
|
|
68
|
-
|
|
69
|
-
**General Media Hooks:**
|
|
70
|
-
- `useMedia` - Core media selection and camera
|
|
71
|
-
- `useMediaUpload` - Upload with progress tracking
|
|
72
|
-
- `useMediaGeneration` - AI generation
|
|
73
|
-
- `useMediaValidation` - Pre-upload validation
|
|
74
|
-
- `useMultimediaFlashcard` - Flashcard creation
|
|
75
|
-
|
|
76
|
-
**Card-Specific Hooks:**
|
|
77
|
-
- `useCardMultimediaFlashcard` - Card flashcard management
|
|
78
|
-
- `useCardMediaGeneration` - Card AI generation
|
|
79
|
-
- `useCardMediaUpload` - Card upload with position
|
|
80
|
-
- `useCardMediaValidation` - Card validation
|
|
81
|
-
|
|
82
|
-
#### Types (Domain Layer)
|
|
83
|
-
Organized by functionality:
|
|
84
|
-
|
|
85
|
-
**Basic Types:**
|
|
86
|
-
- `MediaType` - Media type enum (IMAGE, VIDEO, ALL)
|
|
87
|
-
- `ImageFormat` - Format enum (JPEG, PNG, WEBP)
|
|
88
|
-
- `MediaQuality` - Quality enum (LOW, MEDIUM, HIGH)
|
|
89
|
-
- `MediaLibraryPermission` - Permission states
|
|
90
|
-
- `MediaAsset` - Media file properties
|
|
91
|
-
- `MediaPickerResult` - Picker return type
|
|
92
|
-
- `MediaPickerOptions` - Picker configuration
|
|
93
|
-
- `CameraOptions` - Camera configuration
|
|
94
|
-
|
|
95
|
-
**Card Types:**
|
|
96
|
-
- `CardMediaType` - Card media types
|
|
97
|
-
- `CardMediaPosition` - Position (FRONT, BACK, BOTH)
|
|
98
|
-
- `CardMediaAttachment` - Card media with position
|
|
99
|
-
- `CardMultimediaFlashcard` - Card entity
|
|
100
|
-
- `CardMediaGenerationRequest` - Generation request
|
|
101
|
-
- `CardMediaGenerationResult` - Generation result
|
|
102
|
-
- `CardMediaUploadProgress` - Upload progress
|
|
103
|
-
- `CardMediaCompressionOptions` - Compression options
|
|
104
|
-
- `CardMediaValidation` - Validation result
|
|
105
|
-
|
|
106
|
-
**Flashcard Types:**
|
|
107
|
-
- `MediaAttachment` - General media attachment
|
|
108
|
-
- `MultimediaFlashcard` - Flashcard entity
|
|
109
|
-
- `MediaGenerationRequest` - Generation request
|
|
110
|
-
- `MediaGenerationResult` - Generation result
|
|
111
|
-
|
|
112
|
-
#### Utils (Domain & Infrastructure)
|
|
113
|
-
Utility functions and helpers:
|
|
114
|
-
|
|
115
|
-
**Domain Utils:**
|
|
116
|
-
- `MediaUtils` - Core media utilities
|
|
117
|
-
|
|
118
|
-
**Infrastructure Utils:**
|
|
119
|
-
- Helper functions for media operations
|
|
120
|
-
- Mapper functions for type conversions
|
|
121
|
-
|
|
122
|
-
### Module Selection Guidelines
|
|
123
|
-
|
|
124
|
-
#### Use General Media Features When:
|
|
125
|
-
- Working with standard media operations
|
|
126
|
-
- No card/flashcard requirements
|
|
127
|
-
- Need basic upload/download/validation
|
|
128
|
-
- Building general-purpose media features
|
|
129
|
-
|
|
130
|
-
#### Use Card-Specific Features When:
|
|
131
|
-
- Building flashcard applications
|
|
132
|
-
- Need position-based media (front/back)
|
|
133
|
-
- Working with card entities
|
|
134
|
-
- Need card-specific validation rules
|
|
135
|
-
- Using card generation or upload services
|
|
136
|
-
|
|
137
|
-
### Dependency Rules
|
|
138
|
-
|
|
139
|
-
1. **Services** can be used independently or through hooks
|
|
140
|
-
2. **Hooks** wrap services and provide React state management
|
|
141
|
-
3. **Types** are used by both services and hooks
|
|
142
|
-
4. **Utils** provide helper functions used across layers
|
|
143
|
-
|
|
144
|
-
### Common Import Patterns
|
|
145
|
-
|
|
146
|
-
**Service-only usage:**
|
|
147
|
-
- Import service classes directly
|
|
148
|
-
- Use for non-React code or direct service access
|
|
149
|
-
- Services follow singleton pattern
|
|
150
|
-
|
|
151
|
-
**Hook usage (recommended for React components):**
|
|
152
|
-
- Import hooks for React components
|
|
153
|
-
- Hooks provide state management
|
|
154
|
-
- Hooks wrap services with React integration
|
|
155
|
-
|
|
156
|
-
**Type imports:**
|
|
157
|
-
- Use `import type` for type-only imports
|
|
158
|
-
- Enables tree-shaking
|
|
159
|
-
- Better IDE support
|
|
160
|
-
|
|
161
|
-
**Combined imports:**
|
|
162
|
-
- Mix services, hooks, and types as needed
|
|
163
|
-
- All imports from single entry point
|
|
164
|
-
- Named exports only
|
|
165
|
-
|
|
166
|
-
## File Structure Reference
|
|
167
|
-
|
|
168
|
-
The library follows Clean Architecture with three main layers:
|
|
169
|
-
|
|
170
|
-
**Domain Layer** (`src/domain/`)
|
|
171
|
-
- `entities/` - Core type definitions and interfaces
|
|
172
|
-
- `utils/` - Domain utility functions
|
|
173
|
-
|
|
174
|
-
**Infrastructure Layer** (`src/infrastructure/`)
|
|
175
|
-
- `services/` - Service implementations with external integrations
|
|
176
|
-
- `utils/` - Helper functions and mappers
|
|
177
|
-
|
|
178
|
-
**Presentation Layer** (`src/presentation/`)
|
|
179
|
-
- `hooks/` - React hooks for UI integration
|
|
180
|
-
|
|
181
|
-
**Main Export** (`src/index.ts`)
|
|
182
|
-
- Single entry point for all exports
|
|
183
|
-
- Organized by category
|
|
184
|
-
- This file
|
|
185
|
-
|
|
186
|
-
## Dependencies
|
|
187
|
-
|
|
188
|
-
- Exports all domain entities and types
|
|
189
|
-
- Exports all infrastructure services
|
|
190
|
-
- Exports all presentation hooks
|
|
191
|
-
- Re-exports utilities from domain and infrastructure layers
|
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
# CardMultimediaService
|
|
2
|
-
|
|
3
|
-
## Purpose
|
|
4
|
-
Central service for managing all media operations in card-based applications, combining upload, generation, validation, and optimization capabilities through a singleton instance with card-specific media support.
|
|
5
|
-
|
|
6
|
-
## File Location
|
|
7
|
-
`/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-media/src/infrastructure/services/CardMultimediaService`
|
|
8
|
-
|
|
9
|
-
## Strategy
|
|
10
|
-
- Provide unified interface for all card media operations
|
|
11
|
-
- Coordinate upload, generation, validation, and optimization services
|
|
12
|
-
- Maintain singleton pattern for resource efficiency
|
|
13
|
-
- Support card-specific media requirements (front/back/both positions)
|
|
14
|
-
- Simplify media management for card applications
|
|
15
|
-
- Enable batch operations for card sets
|
|
16
|
-
- Provide consistent API across all media operations
|
|
17
|
-
- Handle card-specific metadata and associations
|
|
18
|
-
|
|
19
|
-
## Forbidden
|
|
20
|
-
- **DO NOT** create multiple service instances (use singleton only)
|
|
21
|
-
- **DO NOT** call media operations without validation
|
|
22
|
-
- **DO NOT** assume AI generation is always available
|
|
23
|
-
- **DO NOT** ignore optimization recommendations
|
|
24
|
-
- **DO NOT** bypass singleton pattern with direct service instantiation
|
|
25
|
-
- **DO NOT** proceed without error handling for any operation
|
|
26
|
-
- **DO NOT** mix card media with non-card media types
|
|
27
|
-
- **DO NOT** assume all operations will succeed
|
|
28
|
-
- **DO NOT** ignore card-specific position requirements
|
|
29
|
-
|
|
30
|
-
## Rules
|
|
31
|
-
1. MUST use getInstance() to retrieve service instance
|
|
32
|
-
2. MUST NOT create new instances with constructor
|
|
33
|
-
3. MUST maintain single instance across application lifecycle
|
|
34
|
-
4. MUST validate media before upload operations
|
|
35
|
-
5. MUST support CardMediaAttachment and CardMediaPosition types
|
|
36
|
-
6. MUST handle position attribute (front/back/both) correctly
|
|
37
|
-
7. MUST handle all operation failures gracefully
|
|
38
|
-
8. MUST provide consistent interface through all methods
|
|
39
|
-
9. MUST initialize all sub-services on first use
|
|
40
|
-
10. MUST coordinate between sub-services for complex operations
|
|
41
|
-
11. MUST handle asynchronous operations properly
|
|
42
|
-
12. MUST return appropriate error messages for failures
|
|
43
|
-
13. MUST support card-specific media constraints
|
|
44
|
-
|
|
45
|
-
## AI Agent Guidelines
|
|
46
|
-
|
|
47
|
-
When working with CardMultimediaService:
|
|
48
|
-
|
|
49
|
-
1. **Singleton Pattern**: Always use getInstance(), never constructor
|
|
50
|
-
2. **Validation First**: Validate before upload or generation
|
|
51
|
-
3. **Position Awareness**: Always consider card position (front/back/both)
|
|
52
|
-
4. **Operation Flow**: Follow validate -> upload/generate -> optimize -> store
|
|
53
|
-
5. **Error Handling**: Handle errors at each step appropriately
|
|
54
|
-
6. **Resource Management**: Rely on singleton for efficient resource use
|
|
55
|
-
7. **Type Safety**: Use CardMediaAttachment and CardMediaPosition types
|
|
56
|
-
8. **Card Context**: Maintain card-specific context throughout operations
|
|
57
|
-
|
|
58
|
-
### Card Creation Workflow
|
|
59
|
-
|
|
60
|
-
- **Step 1 - Get Instance**: `CardMultimediaService.getInstance()`
|
|
61
|
-
- **Step 2 - Select File**: Pick file from device or camera
|
|
62
|
-
- **Step 3 - Validate**: Run validation, check results
|
|
63
|
-
- **Step 4 - Upload**: Upload if validation passes
|
|
64
|
-
- **Step 5 - Set Position**: Assign position (front/back/both)
|
|
65
|
-
- **Step 6 - Optimize** (Optional): Optimize if file is large
|
|
66
|
-
- **Step 7 - Store**: Save attachment with card data
|
|
67
|
-
- **Step 8 - Handle Errors**: Provide feedback at each step
|
|
68
|
-
|
|
69
|
-
### Media Upload with Position
|
|
70
|
-
|
|
71
|
-
- Use for user-selected media on card sides
|
|
72
|
-
- Always validate before uploading
|
|
73
|
-
- Set position based on card side (front/back/both)
|
|
74
|
-
- Consider compression for large files
|
|
75
|
-
- Store returned attachment with card
|
|
76
|
-
- Handle upload failures with user feedback
|
|
77
|
-
|
|
78
|
-
### AI Content Generation for Cards
|
|
79
|
-
|
|
80
|
-
- Use for text-to-image or text-to-audio generation
|
|
81
|
-
- Validate prompts before generation
|
|
82
|
-
- Check credit/balance availability
|
|
83
|
-
- Set position based on use case (front for questions, back for answers)
|
|
84
|
-
- Handle generation failures gracefully
|
|
85
|
-
- Store successful attachments with card
|
|
86
|
-
|
|
87
|
-
### Position Management
|
|
88
|
-
|
|
89
|
-
- **Front**: Media displayed on card front side
|
|
90
|
-
- Typically contains questions or prompts
|
|
91
|
-
- Often uses text-to-image generation
|
|
92
|
-
- May require higher quality
|
|
93
|
-
|
|
94
|
-
- **Back**: Media displayed on card back side
|
|
95
|
-
- Typically contains answers or explanations
|
|
96
|
-
- Often uses text-to-audio generation
|
|
97
|
-
- Can be more compressed
|
|
98
|
-
|
|
99
|
-
- **Both**: Media used on both sides
|
|
100
|
-
- Shared content between sides
|
|
101
|
-
- Less common but supported
|
|
102
|
-
- Maintain consistency across sides
|
|
103
|
-
|
|
104
|
-
### Media Optimization for Cards
|
|
105
|
-
|
|
106
|
-
- Use when file size impacts performance
|
|
107
|
-
- Choose quality level based on position (front = higher, back = lower)
|
|
108
|
-
- Consider card importance and frequency of use
|
|
109
|
-
- Calculate expected size reduction
|
|
110
|
-
- Preserve position through optimization
|
|
111
|
-
- Update card with optimized media
|
|
112
|
-
|
|
113
|
-
### Media Deletion for Cards
|
|
114
|
-
|
|
115
|
-
- Verify media ownership before deletion
|
|
116
|
-
- Check card associations and dependencies
|
|
117
|
-
- Confirm deletion with user if needed
|
|
118
|
-
- Delete from all storage locations
|
|
119
|
-
- Update card references
|
|
120
|
-
- Handle missing files gracefully
|
|
121
|
-
|
|
122
|
-
### Batch Operations for Card Sets
|
|
123
|
-
|
|
124
|
-
- For multiple cards, use same service instance
|
|
125
|
-
- Process uploads/generations in sequence
|
|
126
|
-
- Collect results before saving
|
|
127
|
-
- Handle partial failures appropriately
|
|
128
|
-
- Consider parallel operations for independent media
|
|
129
|
-
- Track progress for user feedback
|
|
130
|
-
- Maintain position consistency across cards
|
|
131
|
-
|
|
132
|
-
### Error Handling Patterns
|
|
133
|
-
|
|
134
|
-
- **Validation Errors**: Show to user, block upload
|
|
135
|
-
- **Upload Errors**: Retry or allow alternative file
|
|
136
|
-
- **Generation Errors**: Check credits, try different prompt
|
|
137
|
-
- **Optimization Errors**: Continue with original media
|
|
138
|
-
- **Deletion Errors**: Log error, notify user
|
|
139
|
-
- **Position Errors**: Validate position before operations
|
|
140
|
-
- **Network Errors**: Show connection message, allow retry
|
|
141
|
-
|
|
142
|
-
### Card-Specific Considerations
|
|
143
|
-
|
|
144
|
-
- **Front Media**: Often focal point, prioritize quality
|
|
145
|
-
- **Back Media**: Secondary content, can be more compressed
|
|
146
|
-
- **Both Position**: Ensure quality works for both sides
|
|
147
|
-
- **Multiple Media**: Support multiple attachments per card
|
|
148
|
-
- **Position Validation**: Validate media type compatibility with position
|
|
149
|
-
- **Card Associations**: Maintain references between media and cards
|
|
150
|
-
|
|
151
|
-
### Service Coordination
|
|
152
|
-
|
|
153
|
-
The service automatically coordinates:
|
|
154
|
-
- CardMediaUploadService handles file uploads
|
|
155
|
-
- CardMediaGenerationService handles AI generation
|
|
156
|
-
- CardMediaValidationService checks file validity
|
|
157
|
-
- CardMediaOptimizerService handles compression
|
|
158
|
-
- All services work together with card-specific requirements
|
|
159
|
-
|
|
160
|
-
### Performance Considerations
|
|
161
|
-
|
|
162
|
-
- Singleton reduces memory footprint
|
|
163
|
-
- Single instance maintains state efficiently
|
|
164
|
-
- Sub-services initialized once
|
|
165
|
-
- All operations are asynchronous
|
|
166
|
-
- Consider lazy loading for large card sets
|
|
167
|
-
- Cache media URLs when possible
|
|
168
|
-
- Optimize media based on card usage patterns
|
|
169
|
-
|
|
170
|
-
## Dependencies
|
|
171
|
-
- CardMediaUploadService for upload operations
|
|
172
|
-
- CardMediaGenerationService for AI generation (including image-search)
|
|
173
|
-
- CardMediaValidationService for validation
|
|
174
|
-
- CardMediaOptimizerService for optimization
|
|
175
|
-
- CardMediaAttachment type from domain layer
|
|
176
|
-
- CardMediaPosition type for card-side placement
|