@umituz/react-native-design-system 4.23.100 → 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/media/domain/entities/{MultimediaFlashcardTypes.ts → MediaAttachments.ts} +13 -32
- package/src/media/index.ts +24 -23
- 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 +1 -1
- 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/utils/AppNavigation.ts +3 -3
- package/src/storage/infrastructure/adapters/StorageService.ts +3 -3
- package/src/storage/infrastructure/repositories/BaseStorageOperations.ts +5 -5
- 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/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/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.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/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
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
# Media Types and Interfaces
|
|
2
|
-
|
|
3
|
-
## Purpose
|
|
4
|
-
Core type definitions and interfaces for media handling throughout the application.
|
|
5
|
-
|
|
6
|
-
## File Location
|
|
7
|
-
`src/domain/entities/Media.ts`
|
|
8
|
-
|
|
9
|
-
## Strategy
|
|
10
|
-
- Define the contract for media operations across all layers
|
|
11
|
-
- Provide type-safe interfaces for media assets, picker options, and operations
|
|
12
|
-
- Serve as the single source of truth for media-related types
|
|
13
|
-
- Enable compile-time validation of media operations
|
|
14
|
-
- Maintain separation between domain logic and implementation
|
|
15
|
-
|
|
16
|
-
## Forbidden
|
|
17
|
-
- **DO NOT** import external libraries (expo, react-native) in domain types
|
|
18
|
-
- **DO NOT** include implementation details in type definitions
|
|
19
|
-
- **DO NOT** add business logic to type definitions
|
|
20
|
-
- **DO NOT** create circular dependencies between types
|
|
21
|
-
- **DO NOT** export types that are not used by other layers
|
|
22
|
-
- **DO NOT** use `any` type or loose type definitions
|
|
23
|
-
- **DO NOT** modify existing types - extend them instead
|
|
24
|
-
|
|
25
|
-
## Rules
|
|
26
|
-
1. All media types must be exported from this file
|
|
27
|
-
2. Type definitions must be framework-agnostic
|
|
28
|
-
3. Enums must have explicit string values
|
|
29
|
-
4. Interfaces must extend appropriate base types
|
|
30
|
-
5. Optional fields must be clearly marked with `?`
|
|
31
|
-
6. File size fields must use bytes as unit
|
|
32
|
-
7. Dimensions must be in pixels
|
|
33
|
-
8. MIME type validation must use standard MIME types
|
|
34
|
-
9. All new properties must be added with backward compatibility in mind
|
|
35
|
-
10. Type exports must be re-exported from main index
|
|
36
|
-
|
|
37
|
-
## AI Agent Guidelines
|
|
38
|
-
|
|
39
|
-
When working with Media types:
|
|
40
|
-
|
|
41
|
-
1. **Type Import**: Always import types from `@umituz/react-native-media` domain layer
|
|
42
|
-
2. **Type Safety**: Use provided types instead of `any` or loose types
|
|
43
|
-
3. **Validation**: Validate media assets against these types before processing
|
|
44
|
-
4. **Extensibility**: Extend interfaces when adding new properties, don't modify core types
|
|
45
|
-
5. **Consistency**: Maintain naming conventions (PascalCase for types, camelCase for properties)
|
|
46
|
-
|
|
47
|
-
### Key Enums Reference
|
|
48
|
-
|
|
49
|
-
- `MediaType`: IMAGE, VIDEO, ALL - Use for media type filtering
|
|
50
|
-
- `ImageFormat`: PNG, JPEG, WEBP - Use for format specification
|
|
51
|
-
- `MediaQuality`: LOW (0.3), MEDIUM (0.7), HIGH (1.0) - Use for compression quality
|
|
52
|
-
- `MediaLibraryPermission`: GRANTED, DENIED, LIMITED - Use for permission states
|
|
53
|
-
|
|
54
|
-
### Type Usage Guidelines
|
|
55
|
-
|
|
56
|
-
1. **MediaAsset**: Primary type for all media files with uri, dimensions, type, size
|
|
57
|
-
2. **MediaPickerResult**: Return type for all picker operations with canceled flag
|
|
58
|
-
3. **MediaPickerOptions**: Configuration for library picker with mediaTypes, quality, limits
|
|
59
|
-
4. **CameraOptions**: Configuration for camera operations with quality, duration, editing
|
|
60
|
-
|
|
61
|
-
### Validation Rules
|
|
62
|
-
|
|
63
|
-
1. Check file size against `MediaAsset.fileSize` (in bytes)
|
|
64
|
-
2. Validate dimensions using `width` and `height` properties (in pixels)
|
|
65
|
-
3. Verify MIME type matches expected `MediaType`
|
|
66
|
-
4. Ensure URIs are properly formatted strings
|
|
67
|
-
5. Validate aspect ratio format as [width, height] tuple
|
|
68
|
-
|
|
69
|
-
### Constants Reference
|
|
70
|
-
|
|
71
|
-
Use `MEDIA_CONSTANTS` for:
|
|
72
|
-
- Maximum file sizes (MAX_IMAGE_SIZE, MAX_VIDEO_SIZE)
|
|
73
|
-
- Default values (DEFAULT_QUALITY, DEFAULT_FORMAT, DEFAULT_ASPECT_RATIO)
|
|
74
|
-
- Supported format lists (SUPPORTED_IMAGE_FORMATS, SUPPORTED_VIDEO_FORMATS)
|
|
75
|
-
|
|
76
|
-
## Dependencies
|
|
77
|
-
|
|
78
|
-
- No external dependencies
|
|
79
|
-
- May reference other domain types within the domain layer
|
|
80
|
-
- Must be usable by infrastructure and presentation layers without additional dependencies
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
# MultimediaFlashcard Types
|
|
2
|
-
|
|
3
|
-
## Purpose
|
|
4
|
-
Type definitions for general-purpose media operations in flashcard applications. These types define the contract for media attachment, generation, and management across various multimedia use cases.
|
|
5
|
-
|
|
6
|
-
## File Location
|
|
7
|
-
`src/domain/entities/MultimediaFlashcardTypes.ts`
|
|
8
|
-
|
|
9
|
-
## Strategy
|
|
10
|
-
- Define the contract for general multimedia operations in flashcards
|
|
11
|
-
- Provide type-safe interfaces for media attachments and generation
|
|
12
|
-
- Support AI-powered media generation for educational content
|
|
13
|
-
- Enable comprehensive media validation and optimization
|
|
14
|
-
- Maintain clear separation between general media and card-specific media types
|
|
15
|
-
- Support upload progress tracking and compression
|
|
16
|
-
- Facilitate media download management for offline learning
|
|
17
|
-
|
|
18
|
-
## Forbidden
|
|
19
|
-
- **DO NOT** use these types for card-specific operations with special requirements (use CardMultimedia types instead)
|
|
20
|
-
- **DO NOT** include UI components or presentation logic in type definitions
|
|
21
|
-
- **DO NOT** add business logic or implementation details to interfaces
|
|
22
|
-
- **DO NOT** create circular dependencies with other domain types
|
|
23
|
-
- **DO NOT** use `any` type or loose type definitions
|
|
24
|
-
- **DO NOT** modify existing type properties - extend interfaces for new features
|
|
25
|
-
- **DO NOT** assume specific storage backend or cloud provider
|
|
26
|
-
- **DO NOT** hardcode validation limits in type definitions
|
|
27
|
-
- **DO NOT** mix general multimedia types with card-specific types
|
|
28
|
-
- **DO NOT** use image_search generation type (only available in CardMultimedia)
|
|
29
|
-
|
|
30
|
-
## Rules
|
|
31
|
-
1. All multimedia types must be exported from this file
|
|
32
|
-
2. Type definitions must be framework-agnostic
|
|
33
|
-
3. Media IDs must use "media_" prefix for uniqueness
|
|
34
|
-
4. Position types must explicitly define front/back/both placement
|
|
35
|
-
5. File size fields must use bytes as unit
|
|
36
|
-
6. Duration fields must use seconds as unit
|
|
37
|
-
7. Date fields must use ISO 8601 format
|
|
38
|
-
8. All generation requests must include input validation
|
|
39
|
-
9. Compression quality must be between 0.1 and 1.0
|
|
40
|
-
10. Upload progress must be tracked from 0-100
|
|
41
|
-
11. Validation results must separate errors, warnings, and recommendations
|
|
42
|
-
12. Service interfaces must return Promises for all async operations
|
|
43
|
-
13. Media type arrays must be automatically calculated, not manually set
|
|
44
|
-
14. Download status must be tracked per attachment
|
|
45
|
-
15. Estimated size must represent total of all attachments
|
|
46
|
-
|
|
47
|
-
## AI Agent Guidelines
|
|
48
|
-
|
|
49
|
-
When working with MultimediaFlashcard types:
|
|
50
|
-
|
|
51
|
-
1. **Type Selection**: Use MediaAttachment for general-purpose media operations
|
|
52
|
-
2. **Generation Requests**: Always specify input parameters and options explicitly
|
|
53
|
-
3. **Validation**: Validate media files before upload and after generation
|
|
54
|
-
4. **Progress Tracking**: Monitor upload progress for user feedback
|
|
55
|
-
5. **Compression**: Apply compression options before upload to reduce bandwidth
|
|
56
|
-
6. **Download Management**: Check isDownloaded status before displaying media
|
|
57
|
-
7. **Position Logic**: Respect position field for front/back/both placement
|
|
58
|
-
8. **Size Estimation**: Calculate total size for all media before batch operations
|
|
59
|
-
9. **Error Handling**: Parse validation errors and warnings for user feedback
|
|
60
|
-
10. **Cost Tracking**: Monitor creditsUsed for AI generation operations
|
|
61
|
-
|
|
62
|
-
### Key Types Reference
|
|
63
|
-
|
|
64
|
-
- **MediaType**: "image" | "audio" | "video" - Media type classification
|
|
65
|
-
- **MediaPosition**: "front" | "back" | "both" - Display placement on card faces
|
|
66
|
-
- **MediaAttachment**: Core interface for individual media items with metadata
|
|
67
|
-
- **MultimediaFlashcard**: Card entity with computed media properties
|
|
68
|
-
- **MediaGenerationRequest**: Input specification for AI media generation
|
|
69
|
-
- **MediaGenerationResult**: Output with cost tracking and performance metrics
|
|
70
|
-
- **MediaUploadProgress**: Real-time upload status tracking
|
|
71
|
-
- **MediaCompressionOptions**: Quality and size optimization settings
|
|
72
|
-
- **MediaValidation**: Comprehensive validation with recommendations
|
|
73
|
-
- **MultimediaFlashcardService**: Service interface for media operations
|
|
74
|
-
|
|
75
|
-
### Type Usage Patterns
|
|
76
|
-
|
|
77
|
-
1. **MediaAttachment**: Individual media item with position, URL, and metadata
|
|
78
|
-
2. **MultimediaFlashcard**: Card with computed properties (hasMedia, mediaType, isDownloaded)
|
|
79
|
-
3. **MediaGenerationRequest**: Two generation types (text_to_image, text_to_audio) - no image_search
|
|
80
|
-
4. **MediaValidation**: Separate errors (blocking) from warnings and recommendations
|
|
81
|
-
|
|
82
|
-
### Validation Rules
|
|
83
|
-
|
|
84
|
-
1. Validate file size against upload limits before processing
|
|
85
|
-
2. Check MIME type matches MediaType
|
|
86
|
-
3. Ensure dimensions are within supported ranges
|
|
87
|
-
4. Verify URIs are properly formatted and accessible
|
|
88
|
-
5. Validate duration for audio/video files
|
|
89
|
-
6. Check compression quality is within 0.1-1.0 range
|
|
90
|
-
7. Ensure generation prompts are non-empty strings
|
|
91
|
-
8. Validate language codes for audio generation (e.g., "en-US", "es-ES")
|
|
92
|
-
|
|
93
|
-
### Service Interface Guidelines
|
|
94
|
-
|
|
95
|
-
When implementing MultimediaFlashcardService:
|
|
96
|
-
|
|
97
|
-
1. **uploadMedia**: Accept file with optional compression, return attachment with URL
|
|
98
|
-
2. **generateMedia**: Process AI generation request, track credits and timing
|
|
99
|
-
3. **validateMedia**: Return comprehensive validation with errors, warnings, recommendations
|
|
100
|
-
4. **optimizeMedia**: Apply compression to existing attachment, preserve metadata
|
|
101
|
-
5. **deleteMedia**: Remove attachment and update card associations
|
|
102
|
-
6. **getMediaUrl**: Return accessible URL for downloaded or remote media
|
|
103
|
-
7. **downloadMedia**: Fetch remote media to local storage, update isDownloaded status
|
|
104
|
-
|
|
105
|
-
### Generation Type Specifics
|
|
106
|
-
|
|
107
|
-
1. **text_to_image**: Requires prompt, style (realistic/cartoon/artistic), quality, format
|
|
108
|
-
2. **text_to_audio**: Requires text, language, voice (male/female/neutral), format
|
|
109
|
-
3. **image_search**: NOT supported in general multimedia types (use CardMultimedia instead)
|
|
110
|
-
|
|
111
|
-
### Position Logic
|
|
112
|
-
|
|
113
|
-
1. **front**: Media displayed only on card front face
|
|
114
|
-
2. **back**: Media displayed only on card back face
|
|
115
|
-
3. **both**: Media displayed on both card faces (e.g., background image)
|
|
116
|
-
|
|
117
|
-
### Download Management
|
|
118
|
-
|
|
119
|
-
1. Check isDownloaded before displaying media offline
|
|
120
|
-
2. Use localPath for offline access when available
|
|
121
|
-
3. Fall back to URL when media not downloaded
|
|
122
|
-
4. Track estimatedSize for storage management
|
|
123
|
-
5. Implement downloadMedia for offline caching
|
|
124
|
-
|
|
125
|
-
### CardMultimedia vs Multimedia Selection
|
|
126
|
-
|
|
127
|
-
Use **CardMultimedia types** when:
|
|
128
|
-
- Working with flashcard-specific features
|
|
129
|
-
- Need image_search generation capability
|
|
130
|
-
- Using card-specific ID prefixes (card_media_)
|
|
131
|
-
- Integrating with card-specific services
|
|
132
|
-
|
|
133
|
-
Use **Multimedia types** when:
|
|
134
|
-
- Building general-purpose media features
|
|
135
|
-
- Only need text_to_image and text_to_audio generation
|
|
136
|
-
- Using general media ID prefixes (media_)
|
|
137
|
-
- Building reusable media components
|
|
138
|
-
|
|
139
|
-
## Dependencies
|
|
140
|
-
|
|
141
|
-
- No external dependencies
|
|
142
|
-
- References domain types from Media.ts for base media concepts
|
|
143
|
-
- Must be usable by infrastructure and presentation layers without additional dependencies
|
|
144
|
-
- Service interfaces require async operation support
|
|
@@ -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
|