@umituz/react-native-design-system 4.23.97 → 4.23.100

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.
Files changed (35) hide show
  1. package/package.json +1 -1
  2. package/src/atoms/button/AtomicButton.tsx +7 -0
  3. package/src/atoms/button/types/index.ts +4 -0
  4. package/src/atoms/input/hooks/useInputState.ts +3 -7
  5. package/src/haptics/infrastructure/services/HapticService.ts +1 -1
  6. package/src/media/infrastructure/hooks/useGenericMediaGeneration.ts +170 -0
  7. package/src/media/presentation/hooks/useCardMediaGeneration.ts +9 -113
  8. package/src/media/presentation/hooks/useCardMediaUpload.ts +5 -5
  9. package/src/media/presentation/hooks/useCardMediaValidation.ts +4 -1
  10. package/src/media/presentation/hooks/useMediaGeneration.ts +4 -87
  11. package/src/molecules/navigation/components/NavigationHeader.tsx +3 -3
  12. package/src/offline/index.ts +1 -0
  13. package/src/offline/infrastructure/storage/OfflineConfigStore.ts +34 -0
  14. package/src/offline/presentation/hooks/useOffline.ts +8 -4
  15. package/src/storage/domain/utils/devUtils.ts +0 -24
  16. package/src/storage/index.ts +1 -1
  17. package/src/storage/infrastructure/adapters/StorageService.ts +2 -7
  18. package/src/storage/infrastructure/repositories/BaseStorageOperations.ts +0 -3
  19. package/src/storage/presentation/hooks/CacheStorageOperations.ts +2 -8
  20. package/src/storage/presentation/hooks/useStore.ts +14 -5
  21. package/src/utilities/sharing/presentation/hooks/useSharing.ts +3 -3
  22. package/src/layouts/ScreenLayout/ScreenLayout.example.tsx +0 -92
  23. package/src/media/domain/entities/CardMultimedia.types.ts +0 -120
  24. package/src/media/infrastructure/services/CardMediaGenerationService.README.md +0 -99
  25. package/src/media/infrastructure/services/CardMediaGenerationService.ts +0 -101
  26. package/src/media/infrastructure/services/CardMediaOptimizerService.README.md +0 -167
  27. package/src/media/infrastructure/services/CardMediaOptimizerService.ts +0 -36
  28. package/src/media/infrastructure/services/CardMediaUploadService.README.md +0 -123
  29. package/src/media/infrastructure/services/CardMediaUploadService.ts +0 -62
  30. package/src/media/infrastructure/services/CardMediaValidationService.README.md +0 -134
  31. package/src/media/infrastructure/services/CardMediaValidationService.ts +0 -81
  32. package/src/media/presentation/hooks/useCardMediaGeneration.README.md +0 -164
  33. package/src/media/presentation/hooks/useCardMediaUpload.README.md +0 -153
  34. package/src/media/presentation/hooks/useCardMediaValidation.README.md +0 -176
  35. package/src/storage/domain/utils/__tests__/devUtils.test.ts +0 -97
@@ -1,167 +0,0 @@
1
- # CardMediaOptimizerService
2
-
3
- ## Purpose
4
- Service that optimizes and compresses flashcard media files to reduce size while maintaining acceptable quality, and manages media deletion operations.
5
-
6
- ## File Location
7
- `/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-media/src/infrastructure/services/CardMediaOptimizerService`
8
-
9
- ## Strategy
10
- - Optimize media files by reducing file size with quality settings
11
- - Support dimension resizing (maxWidth, maxHeight)
12
- - Provide multiple quality levels for different use cases
13
- - Generate new optimized versions while preserving originals
14
- - Delete media from server and local storage
15
- - Return optimized media with updated file size and URL
16
- - Maintain card media position through optimization
17
- - Calculate size reduction percentages
18
-
19
- ## Forbidden
20
- - **DO NOT** optimize below usable quality (quality < 0.3)
21
- - **DO NOT** modify original media files
22
- - **DO NOT** delete media without verifying ownership
23
- - **DO NOT** assume optimization will always succeed
24
- - **DO NOT** use negative or invalid quality values
25
- - **DO NOT** set dimensions to zero or negative values
26
- - **DO NOT** delete media without user confirmation
27
- - **DO NOT** bypass optimization error handling
28
-
29
- ## Rules
30
- 1. Quality value must be between 0-1 (0 = worst, 1 = best)
31
- 2. Max dimensions must be positive integers if specified
32
- 3. Original media is always preserved, never modified
33
- 4. Optimized media receives new URL with ?optimized=true parameter
34
- 5. File size is approximately calculated as: original * quality
35
- 6. Position attribute is preserved through optimization
36
- 7. All other attachment properties remain unchanged
37
- 8. Optimization must maintain aspect ratio when resizing
38
- 9. Delete operation is permanent and irreversible
39
- 10. Optimized size calculation is simulated (not actual compression)
40
- 11. Quality levels: high (0.9-1.0), medium (0.7-0.8), low (0.5-0.6)
41
-
42
- ## AI Agent Guidelines
43
-
44
- When working with CardMediaOptimizerService:
45
-
46
- 1. **Quality Selection**: Choose appropriate quality for use case
47
- 2. **Size Calculation**: Estimate size reduction before optimization
48
- 3. **Original Preservation**: Always keep original media intact
49
- 4. **Error Handling**: Handle optimization failures gracefully
50
- 5. **Position Maintenance**: Preserve position through all operations
51
- 6. **Delete Confirmation**: Always verify before deletion
52
- 7. **Batch Operations**: Consider batch optimization for multiple files
53
-
54
- ### Quality Level Guidelines
55
-
56
- - **High Quality (0.9-1.0)**:
57
- - Use for: Card front images, important visuals
58
- - Size reduction: 10-20%
59
- - When to use: High quality requirements, focal content
60
-
61
- - **Medium Quality (0.7-0.8)** - RECOMMENDED:
62
- - Use for: General card media, back images
63
- - Size reduction: 30-50%
64
- - When to use: Balance of quality and size, most cases
65
-
66
- - **Low Quality (0.5-0.6)**:
67
- - Use for: Thumbnails, previews, non-critical content
68
- - Size reduction: 50-70%
69
- - When to use: Previews, placeholders, bandwidth-constrained
70
-
71
- - **Very Low Quality (0.3-0.4)**:
72
- - Use for: Low-quality previews only
73
- - Size reduction: 70-80%
74
- - When to use: Extreme bandwidth constraints
75
-
76
- ### Dimension Guidelines
77
-
78
- - **Full Resolution**: No max dimensions specified
79
- - Use when: Quality is critical, storage is abundant
80
-
81
- - **1920x1080** - RECOMMENDED:
82
- - Use for: General card media, good balance
83
- - Suitable for: Most modern displays
84
-
85
- - **1280x720**:
86
- - Use for: Smaller cards, bandwidth optimization
87
- - Suitable for: Mobile devices, previews
88
-
89
- - **Lower than 1280x720**:
90
- - Use for: Thumbnails, very small cards
91
- - Consider: May appear pixelated on large screens
92
-
93
- ### Card-Specific Optimization
94
-
95
- - **Front Side Media**:
96
- - Use higher quality (0.8-0.9)
97
- - Full or near-full resolution
98
- - This is the focal point of the card
99
-
100
- - **Back Side Media**:
101
- - Use medium quality (0.7)
102
- - Moderate resolution (1280x720 or 1920x1080)
103
- - Secondary content can be more compressed
104
-
105
- - **Audio Files**:
106
- - This service is designed for image optimization only
107
- - Audio optimization requires different approach (bitrate)
108
-
109
- ### Deletion Guidelines
110
-
111
- - **Before Delete**:
112
- - Verify media ownership
113
- - Check card associations
114
- - Confirm with user if applicable
115
- - Consider soft delete option
116
-
117
- - **During Delete**:
118
- - Remove from server storage
119
- - Remove from local storage
120
- - Update card references
121
- - Handle missing files gracefully
122
-
123
- - **After Delete**:
124
- - Update database references
125
- - Clean up orphaned files
126
- - Cannot be undone (permanent)
127
-
128
- ### Optimization Workflow
129
-
130
- 1. Start with original media attachment
131
- 2. Determine target quality and dimensions
132
- 3. Calculate expected size reduction
133
- 4. Run optimization operation
134
- 5. Receive optimized attachment with new URL
135
- 6. Replace or keep both versions
136
- 7. Update card media references
137
-
138
- ### Error Handling
139
-
140
- - **Optimization Failures**:
141
- - Return original media unchanged
142
- - Log error for debugging
143
- - Continue with original if appropriate
144
-
145
- - **Invalid Parameters**:
146
- - Quality outside 0-1 range
147
- - Negative or zero dimensions
148
- - Must reject with clear error
149
-
150
- - **Delete Failures**:
151
- - Media not found
152
- - Permission denied
153
- - Handle gracefully, log error
154
-
155
- ### Performance Considerations
156
-
157
- - Optimization is simulated (size * quality calculation)
158
- - In production, integrate actual optimization API
159
- - Consider lazy optimization (optimize on demand)
160
- - Batch optimization for multiple files
161
- - Cache optimized versions when possible
162
-
163
- ## Dependencies
164
- - CardMediaAttachment type from domain layer
165
- - CardMediaCompressionOptions type for optimization settings
166
- - Optimization API endpoints (simulated in development)
167
- - Storage access for deletion operations
@@ -1,36 +0,0 @@
1
- /**
2
- * Card Media Optimizer Service
3
- * Handles media optimization and deletion
4
- */
5
-
6
- declare var __DEV__: boolean;
7
-
8
- import type {
9
- CardMediaAttachment,
10
- CardMediaCompressionOptions,
11
- } from "../../domain/entities/CardMultimedia.types";
12
-
13
- export class CardMediaOptimizerService {
14
- /**
15
- * Optimize media file
16
- */
17
- async optimizeMedia(
18
- attachment: CardMediaAttachment,
19
- options: CardMediaCompressionOptions,
20
- ): Promise<CardMediaAttachment> {
21
- return {
22
- ...attachment,
23
- fileSize: Math.floor(attachment.fileSize * options.quality),
24
- url: `${attachment.url}?optimized=true`,
25
- };
26
- }
27
-
28
- /**
29
- * Delete media attachment
30
- */
31
- async deleteMedia(attachmentId: string): Promise<void> {
32
- if (__DEV__) {
33
- console.log(`[DesignSystem] CardMediaOptimizerService: Deleting media ${attachmentId}`);
34
- }
35
- }
36
- }
@@ -1,123 +0,0 @@
1
- # CardMediaUploadService
2
-
3
- ## Purpose
4
- Service that handles media file upload, download, and URL management for flashcard applications, with support for compression and automatic thumbnail generation.
5
-
6
- ## File Location
7
- `/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-media/src/infrastructure/services/CardMediaUploadService`
8
-
9
- ## Strategy
10
- - Upload media files to server storage with unique identifiers
11
- - Support compression options during upload (quality, dimensions, format)
12
- - Generate thumbnails automatically for uploaded media
13
- - Download media from server to local storage
14
- - Retrieve and manage media URLs
15
- - Calculate duration for audio/video files
16
- - Return card-compatible media attachments with position support
17
- - Handle all media types (image, video, audio) with automatic type detection
18
-
19
- ## Forbidden
20
- - **DO NOT** upload files without validation
21
- - **DO NOT** bypass file size limits
22
- - **DO NOT** upload unsupported file types
23
- - **DO NOT** ignore upload failures
24
- - **DO NOT** assume all uploads will succeed
25
- - **DO NOT** overwrite existing media without verification
26
- - **DO NOT** proceed without error handling for network issues
27
- - **DO NOT** download media without checking URL validity
28
-
29
- ## Rules
30
- 1. All uploads must include valid file metadata (name, type, size, uri)
31
- 2. Compression options are optional but recommended for large files
32
- 3. Quality must be between 0-1 when specified
33
- 4. Max dimensions must be positive integers when specified
34
- 5. Supported formats are jpeg and png for compression
35
- 6. All attachments receive unique IDs automatically
36
- 7. Position defaults to 'both' for uploaded media
37
- 8. isDownloaded defaults to true for uploads
38
- 9. Thumbnails are generated automatically for visual content
39
- 10. Audio/video duration is calculated automatically
40
- 11. File type is determined automatically from MIME type
41
- 12. Upload operations must handle network failures gracefully
42
- 13. Download operations must validate URL before processing
43
-
44
- ## AI Agent Guidelines
45
-
46
- When working with CardMediaUploadService:
47
-
48
- 1. **Pre-upload Validation**: Always validate files before upload attempts
49
- 2. **Compression Strategy**: Apply compression for files larger than 5MB
50
- 3. **Type Detection**: Rely on automatic type detection from MIME type
51
- 4. **Error Handling**: Handle network timeouts and connection failures
52
- 5. **Position Assignment**: Set correct position (front/back/both) for card use
53
- 6. **Thumbnail Usage**: Use thumbnails for previews to save bandwidth
54
- 7. **Duration Handling**: Use calculated duration for audio/video scheduling
55
-
56
- ### Upload Guidelines
57
-
58
- - **Before Upload**:
59
- - Validate file size and type
60
- - Consider compression for large files
61
- - Check network connectivity
62
- - Prepare error handling
63
-
64
- - **During Upload**:
65
- - Monitor for failures
66
- - Handle network errors
67
- - Store attachment information
68
- - Track upload progress
69
-
70
- - **After Upload**:
71
- - Verify upload success
72
- - Store attachment ID and URL
73
- - Set position for card use
74
- - Consider optimization if needed
75
-
76
- ### Compression Options
77
-
78
- - **Quality**: 0.9 (high), 0.7 (medium/recommended), 0.5 (low)
79
- - **Max Dimensions**: 1920x1080 (recommended), 1280x720 (smaller)
80
- - **Format**: jpeg (smaller size), png (better quality)
81
- - Apply compression when file size > 5MB for images
82
- - Use quality 0.7 for balance of size and quality
83
-
84
- ### Media Type Detection
85
-
86
- - **Image**: MIME types starting with 'image/'
87
- - Supported: image/jpeg, image/png, image/webp
88
- - **Audio**: MIME types starting with 'audio/'
89
- - Supported: audio/mp3, audio/wav, audio/m4a
90
- - **Video**: MIME types starting with 'video/'
91
- - Supported: video/mp4, video/mov
92
-
93
- ### Download Guidelines
94
-
95
- - Validate media URL before download
96
- - Handle missing files gracefully
97
- - Use local path for offline access
98
- - Check isDownloaded status before re-downloading
99
- - Manage local storage space
100
-
101
- ### Error Handling Patterns
102
-
103
- - Handle network errors: timeout, connection refused
104
- - Handle file errors: invalid format, corrupted file
105
- - Handle server errors: 500, 503, insufficient storage
106
- - Handle validation errors: size exceeded, unsupported type
107
- - Always provide fallback behavior for failed uploads
108
-
109
- ### Performance Considerations
110
-
111
- - Upload operations are simulated (2 seconds delay)
112
- - Compress before upload to reduce transfer time
113
- - Use thumbnails for previews instead of full media
114
- - Batch uploads when possible for multiple files
115
- - Consider lazy loading for card media
116
-
117
- ## Dependencies
118
- - CardMediaAttachment type from domain layer
119
- - CardMediaCompressionOptions type for compression settings
120
- - getCardMediaType helper for type detection
121
- - getMediaDuration helper for duration calculation
122
- - generateThumbnail helper for thumbnail creation
123
- - Upload API endpoints (simulated in development)
@@ -1,62 +0,0 @@
1
- /**
2
- * Card Media Upload Service
3
- * Handles media upload, download, and URL operations
4
- */
5
-
6
- import type {
7
- CardMediaAttachment,
8
- CardMediaCompressionOptions,
9
- CardMediaFile,
10
- } from "../../domain/entities/CardMultimedia.types";
11
- import { generateThumbnail, getMediaDuration } from "../utils/file-media-utils";
12
- import { getMediaTypeFromMime } from "../utils/mime-type-detector";
13
-
14
- export class CardMediaUploadService {
15
- /**
16
- * Upload media file with optional compression
17
- */
18
- async uploadMedia(
19
- file: CardMediaFile,
20
- _options?: CardMediaCompressionOptions,
21
- ): Promise<CardMediaAttachment> {
22
- try {
23
- // Simulate upload process
24
- await new Promise((resolve) => setTimeout(resolve, 2000));
25
-
26
- const attachment: CardMediaAttachment = {
27
- id: `card_media_${Date.now()}`,
28
- type: getMediaTypeFromMime(file.type),
29
- position: "both",
30
- url: `https://storage.example.com/media/${Date.now()}_${file.name}`,
31
- filename: file.name,
32
- fileSize: file.size || 100000,
33
- mimeType: file.type,
34
- duration: await getMediaDuration(file),
35
- thumbnailUrl: generateThumbnail(file),
36
- caption: "",
37
- isDownloaded: true,
38
- createdAt: new Date().toISOString(),
39
- };
40
-
41
- return attachment;
42
- } catch (error) {
43
- throw new Error(`Failed to upload media: ${error}`);
44
- }
45
- }
46
-
47
- /**
48
- * Get media URL
49
- */
50
- async getMediaUrl(attachmentId: string): Promise<string> {
51
- return `https://storage.example.com/media/${attachmentId}`;
52
- }
53
-
54
- /**
55
- * Download media to local storage
56
- */
57
- async downloadMedia(attachmentId: string): Promise<string> {
58
- if (__DEV__) {
59
- }
60
- return `/local/storage/${attachmentId}`;
61
- }
62
- }
@@ -1,134 +0,0 @@
1
- # CardMediaValidationService
2
-
3
- ## Purpose
4
- Service that validates flashcard media files before upload, checking file size, type, and media-specific properties with detailed error, warning, and recommendation reporting.
5
-
6
- ## File Location
7
- `/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-media/src/infrastructure/services/CardMediaValidationService`
8
-
9
- ## Strategy
10
- - Validate media files before upload operations
11
- - Check file size against maximum limits (50 MB hard limit)
12
- - Validate file type compatibility (image, audio, video)
13
- - Provide media-specific warnings (large images, long videos)
14
- - Generate actionable recommendations for optimization
15
- - Return structured validation results with errors, warnings, and recommendations
16
- - Support asynchronous validation operations
17
- - Format file sizes in human-readable format
18
-
19
- ## Forbidden
20
- - **DO NOT** upload files with validation errors
21
- - **DO NOT** ignore validation warnings about performance impact
22
- - **DO NOT** bypass validation for any media upload
23
- - **DO NOT** allow unsupported file types
24
- - **DO NOT** proceed when file size exceeds maximum
25
- - **DO NOT** suppress error messages
26
- - **DO NOT** assume all validations will pass
27
- - **DO NOT** skip validation for "trusted" sources
28
-
29
- ## Rules
30
- 1. Maximum file size is 50 MB (hard error)
31
- 2. Large file warning is triggered at 10 MB+
32
- 3. Very large image warning is triggered at 5 MB+
33
- 4. Long audio/video warning is triggered at 5 minutes (300 seconds)
34
- 5. Supported image types: image/jpeg, image/png, image/webp
35
- 6. Supported audio types: audio/mp3, audio/wav, audio/m4a
36
- 7. Supported video types: video/mp4, video/mov
37
- 8. Unsupported file types must return error
38
- 9. Validation must be asynchronous operation
39
- 10. Warnings must not block upload but inform user
40
- 11. Recommendations must provide actionable improvement steps
41
- 12. File size must be checked in bytes
42
- 13. Validation result must include isValid boolean flag
43
-
44
- ## AI Agent Guidelines
45
-
46
- When working with CardMediaValidationService:
47
-
48
- 1. **Always Validate**: Never upload without validation first
49
- 2. **Check isValid**: Block upload if isValid is false
50
- 3. **Handle Errors**: Show error messages to user and prevent upload
51
- 4. **Show Warnings**: Display warnings but allow user to proceed
52
- 5. **Provide Recommendations**: Show optimization suggestions
53
- 6. **Media-Specific Checks**: Apply different rules for each media type
54
- 7. **User Communication**: Present validation results clearly
55
-
56
- ### Validation Workflow
57
-
58
- - **Step 1 - Validate**: Run validation before any upload
59
- - **Step 2 - Check Errors**: If errors exist, show and stop
60
- - **Step 3 - Show Warnings**: Display warnings, ask user to confirm
61
- - **Step 4 - Show Recommendations**: Present optimization suggestions
62
- - **Step 5 - Proceed or Stop**: Allow upload if valid, stop if invalid
63
-
64
- ### Error Handling
65
-
66
- - **File Size Errors**:
67
- - "File size (X MB) exceeds maximum allowed size (50 MB)"
68
- - Must prevent upload operation
69
- - User must reduce file size
70
-
71
- - **File Type Errors**:
72
- - "Unsupported file type: [type]"
73
- - Must prevent upload operation
74
- - User must convert to supported format
75
-
76
- ### Warning Handling
77
-
78
- - **Large File Warning** (10+ MB):
79
- - "Large file size may impact performance"
80
- - Allow upload with user confirmation
81
- - Recommend compression
82
-
83
- - **Large Image Warning** (5+ MB):
84
- - "Very large image may cause performance issues"
85
- - Allow upload with user confirmation
86
- - Recommend resizing to under 5 MB
87
-
88
- - **Long Content Warning** (5+ minutes):
89
- - "Long audio/video files may impact app performance"
90
- - Allow upload with user confirmation
91
- - Recommend trimming to under 5 minutes
92
-
93
- ### Recommendation Patterns
94
-
95
- - **For Large Files**: "Consider compressing file"
96
- - **For Large Images**: "Consider resizing image to under 5MB"
97
- - **For Long Content**: "Consider trimming to under 5 minutes"
98
- - **For Format**: Recommend MP3 for audio, MP4 for video
99
- - **For Resolution**: Recommend 1920x1080 or smaller
100
-
101
- ### Media-Specific Validation
102
-
103
- - **Images**:
104
- - Check MIME type against supported formats
105
- - Warn if size > 5 MB
106
- - Recommend JPEG for better compression
107
- - Consider resolution checks (optional)
108
-
109
- - **Audio**:
110
- - Check MIME type against supported formats
111
- - Warn if duration > 5 minutes
112
- - Recommend MP3 format
113
- - Consider bitrate checks (optional)
114
-
115
- - **Video**:
116
- - Check MIME type against supported formats
117
- - Warn if duration > 5 minutes
118
- - Recommend MP4 format
119
- - Consider resolution checks (optional)
120
-
121
- ### User Communication
122
-
123
- - Display errors prominently (block upload)
124
- - Show warnings with clear impact explanation
125
- - Present recommendations as actionable steps
126
- - Allow user to decide on warnings
127
- - Format file sizes in MB/KB for readability
128
- - Group messages by severity (errors, warnings, recommendations)
129
-
130
- ## Dependencies
131
- - CardMediaValidation type for validation results
132
- - File size constants for limits
133
- - MIME type validation utilities
134
- - Media type detection helpers
@@ -1,81 +0,0 @@
1
- /**
2
- * Card Media Validation Service
3
- * Handles media file validation before upload
4
- */
5
-
6
- import { formatFileSize } from "../utils/media-collection-utils";
7
- import { getMediaDuration } from "../utils/file-media-utils";
8
- import type { CardMediaValidation, CardMediaFile } from "../../domain/entities/CardMultimedia.types";
9
-
10
- export class CardMediaValidationService {
11
- /**
12
- * Validate media file before upload
13
- */
14
- async validateMedia(file: CardMediaFile): Promise<CardMediaValidation> {
15
- try {
16
- const errors: string[] = [];
17
- const warnings: string[] = [];
18
- const recommendations: string[] = [];
19
-
20
- // File size validation
21
- const maxSize = 50 * 1024 * 1024; // 50MB
22
- if (file.size > maxSize) {
23
- errors.push(
24
- `File size (${formatFileSize(file.size)}) exceeds maximum allowed size (${formatFileSize(maxSize)})`,
25
- );
26
- } else if (file.size > 10 * 1024 * 1024) {
27
- // 10MB
28
- warnings.push(`Large file size may impact performance`);
29
- recommendations.push("Consider compressing file");
30
- }
31
-
32
- // File type validation
33
- const supportedTypes = [
34
- "image/jpeg",
35
- "image/png",
36
- "image/webp",
37
- "audio/mp3",
38
- "audio/wav",
39
- "audio/m4a",
40
- "video/mp4",
41
- "video/mov",
42
- ];
43
-
44
- if (!supportedTypes.includes(file.type)) {
45
- errors.push(`Unsupported file type: ${file.type}`);
46
- }
47
-
48
- // Media-specific validations
49
- if (file.type.startsWith("image/")) {
50
- if (file.size > 5 * 1024 * 1024) {
51
- // 5MB for images
52
- warnings.push("Very large image may cause performance issues");
53
- recommendations.push("Consider resizing image to under 5MB");
54
- }
55
- }
56
-
57
- if (file.type.startsWith("audio/") || file.type.startsWith("video/")) {
58
- const duration = await getMediaDuration(file);
59
- if (duration && duration > 300) {
60
- // 5 minutes
61
- warnings.push("Long audio/video files may impact app performance");
62
- recommendations.push("Consider trimming to under 5 minutes");
63
- }
64
- }
65
-
66
- return {
67
- isValid: errors.length === 0,
68
- errors,
69
- warnings,
70
- recommendations,
71
- };
72
- } catch (error) {
73
- return {
74
- isValid: false,
75
- errors: [error instanceof Error ? error.message : "Validation failed"],
76
- warnings: [],
77
- recommendations: [],
78
- };
79
- }
80
- }
81
- }