@umituz/react-native-design-system 2.8.8 → 2.8.9

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 (65) hide show
  1. package/package.json +6 -1
  2. package/src/exports/media.ts +1 -0
  3. package/src/index.ts +5 -0
  4. package/src/media/domain/entities/CardMultimedia.types.README.md +129 -0
  5. package/src/media/domain/entities/CardMultimedia.types.ts +105 -0
  6. package/src/media/domain/entities/Media.README.md +80 -0
  7. package/src/media/domain/entities/Media.ts +139 -0
  8. package/src/media/domain/entities/MultimediaFlashcardTypes.README.md +144 -0
  9. package/src/media/domain/entities/MultimediaFlashcardTypes.ts +105 -0
  10. package/src/media/domain/utils/MediaUtils.README.md +178 -0
  11. package/src/media/domain/utils/MediaUtils.ts +82 -0
  12. package/src/media/index.ts +70 -0
  13. package/src/media/index.ts.README.md +191 -0
  14. package/src/media/infrastructure/services/CardMediaGenerationService.README.md +99 -0
  15. package/src/media/infrastructure/services/CardMediaGenerationService.ts +101 -0
  16. package/src/media/infrastructure/services/CardMediaOptimizerService.README.md +167 -0
  17. package/src/media/infrastructure/services/CardMediaOptimizerService.ts +36 -0
  18. package/src/media/infrastructure/services/CardMediaUploadService.README.md +123 -0
  19. package/src/media/infrastructure/services/CardMediaUploadService.ts +67 -0
  20. package/src/media/infrastructure/services/CardMediaValidationService.README.md +134 -0
  21. package/src/media/infrastructure/services/CardMediaValidationService.ts +81 -0
  22. package/src/media/infrastructure/services/CardMultimediaService.README.md +176 -0
  23. package/src/media/infrastructure/services/CardMultimediaService.ts +97 -0
  24. package/src/media/infrastructure/services/MediaGenerationService.README.md +142 -0
  25. package/src/media/infrastructure/services/MediaGenerationService.ts +80 -0
  26. package/src/media/infrastructure/services/MediaOptimizerService.README.md +145 -0
  27. package/src/media/infrastructure/services/MediaOptimizerService.ts +32 -0
  28. package/src/media/infrastructure/services/MediaPickerService.README.md +106 -0
  29. package/src/media/infrastructure/services/MediaPickerService.ts +173 -0
  30. package/src/media/infrastructure/services/MediaSaveService.README.md +120 -0
  31. package/src/media/infrastructure/services/MediaSaveService.ts +154 -0
  32. package/src/media/infrastructure/services/MediaUploadService.README.md +135 -0
  33. package/src/media/infrastructure/services/MediaUploadService.ts +62 -0
  34. package/src/media/infrastructure/services/MediaValidationService.README.md +135 -0
  35. package/src/media/infrastructure/services/MediaValidationService.ts +61 -0
  36. package/src/media/infrastructure/services/MultimediaFlashcardService.README.md +142 -0
  37. package/src/media/infrastructure/services/MultimediaFlashcardService.ts +95 -0
  38. package/src/media/infrastructure/utils/mediaHelpers.README.md +96 -0
  39. package/src/media/infrastructure/utils/mediaHelpers.ts +82 -0
  40. package/src/media/infrastructure/utils/mediaPickerMappers.README.md +129 -0
  41. package/src/media/infrastructure/utils/mediaPickerMappers.ts +76 -0
  42. package/src/media/presentation/hooks/card-multimedia.types.README.md +177 -0
  43. package/src/media/presentation/hooks/card-multimedia.types.ts +51 -0
  44. package/src/media/presentation/hooks/multimedia.types.README.md +201 -0
  45. package/src/media/presentation/hooks/multimedia.types.ts +51 -0
  46. package/src/media/presentation/hooks/useCardMediaGeneration.README.md +164 -0
  47. package/src/media/presentation/hooks/useCardMediaGeneration.ts +124 -0
  48. package/src/media/presentation/hooks/useCardMediaUpload.README.md +153 -0
  49. package/src/media/presentation/hooks/useCardMediaUpload.ts +86 -0
  50. package/src/media/presentation/hooks/useCardMediaValidation.README.md +176 -0
  51. package/src/media/presentation/hooks/useCardMediaValidation.ts +101 -0
  52. package/src/media/presentation/hooks/useCardMultimediaFlashcard.README.md +158 -0
  53. package/src/media/presentation/hooks/useCardMultimediaFlashcard.ts +104 -0
  54. package/src/media/presentation/hooks/useMedia.README.md +94 -0
  55. package/src/media/presentation/hooks/useMedia.ts +186 -0
  56. package/src/media/presentation/hooks/useMediaGeneration.README.md +118 -0
  57. package/src/media/presentation/hooks/useMediaGeneration.ts +101 -0
  58. package/src/media/presentation/hooks/useMediaUpload.README.md +108 -0
  59. package/src/media/presentation/hooks/useMediaUpload.ts +86 -0
  60. package/src/media/presentation/hooks/useMediaValidation.README.md +134 -0
  61. package/src/media/presentation/hooks/useMediaValidation.ts +93 -0
  62. package/src/media/presentation/hooks/useMultimediaFlashcard.README.md +141 -0
  63. package/src/media/presentation/hooks/useMultimediaFlashcard.ts +103 -0
  64. package/src/storage/infrastructure/repositories/__tests__/AsyncStorageRepository.test.ts +1 -1
  65. package/src/storage/infrastructure/repositories/__tests__/BaseStorageOperations.test.ts +1 -1
@@ -0,0 +1,105 @@
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 MediaValidation {
83
+ isValid: boolean;
84
+ errors: string[];
85
+ warnings: string[];
86
+ recommendations: string[];
87
+ }
88
+
89
+ export interface MultimediaFlashcardService {
90
+ uploadMedia(
91
+ file: any,
92
+ options?: MediaCompressionOptions,
93
+ ): Promise<MediaAttachment>;
94
+ generateMedia(
95
+ request: MediaGenerationRequest,
96
+ ): Promise<MediaGenerationResult>;
97
+ validateMedia(file: any): Promise<MediaValidation>;
98
+ optimizeMedia(
99
+ attachment: MediaAttachment,
100
+ options: MediaCompressionOptions,
101
+ ): Promise<MediaAttachment>;
102
+ deleteMedia(attachmentId: string): Promise<void>;
103
+ getMediaUrl(attachmentId: string): Promise<string>;
104
+ downloadMedia(attachmentId: string): Promise<string>; // Returns local path
105
+ }
@@ -0,0 +1,178 @@
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
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Media Utilities
3
+ * Utility functions for media operations
4
+ */
5
+
6
+ import { ImageFormat, MEDIA_CONSTANTS, MediaType } from "../entities/Media";
7
+
8
+ /**
9
+ * Image MIME type mappings
10
+ */
11
+ export const IMAGE_MIME_TYPES = {
12
+ [ImageFormat.PNG]: "image/png",
13
+ [ImageFormat.JPEG]: "image/jpeg",
14
+ [ImageFormat.WEBP]: "image/webp",
15
+ } as const;
16
+
17
+ /**
18
+ * Media utility class
19
+ */
20
+ export class MediaUtils {
21
+ static isImage(uri: string): boolean {
22
+ const extension = uri.split(".").pop()?.toLowerCase();
23
+ return MEDIA_CONSTANTS.SUPPORTED_IMAGE_FORMATS.some(
24
+ (format) => format.replace(".", "") === extension
25
+ );
26
+ }
27
+
28
+ static isVideo(uri: string): boolean {
29
+ const extension = uri.split(".").pop()?.toLowerCase();
30
+ return MEDIA_CONSTANTS.SUPPORTED_VIDEO_FORMATS.some(
31
+ (format) => format.replace(".", "") === extension
32
+ );
33
+ }
34
+
35
+ static getImageMimeType(format: ImageFormat): string {
36
+ return IMAGE_MIME_TYPES[format];
37
+ }
38
+
39
+ static calculateAspectRatio(width: number, height: number): number {
40
+ return width / height;
41
+ }
42
+
43
+ static getScaledDimensions(
44
+ originalWidth: number,
45
+ originalHeight: number,
46
+ maxWidth: number,
47
+ maxHeight: number
48
+ ): { width: number; height: number } {
49
+ const aspectRatio = MediaUtils.calculateAspectRatio(
50
+ originalWidth,
51
+ originalHeight
52
+ );
53
+
54
+ let width = originalWidth;
55
+ let height = originalHeight;
56
+
57
+ if (width > maxWidth) {
58
+ width = maxWidth;
59
+ height = width / aspectRatio;
60
+ }
61
+
62
+ if (height > maxHeight) {
63
+ height = maxHeight;
64
+ width = height * aspectRatio;
65
+ }
66
+
67
+ return {
68
+ width: Math.round(width),
69
+ height: Math.round(height),
70
+ };
71
+ }
72
+
73
+ static isValidDimensions(width: number, height: number): boolean {
74
+ return width > 0 && height > 0 && width <= 8192 && height <= 8192;
75
+ }
76
+
77
+ static parseMediaType(mimeType: string): MediaType {
78
+ if (mimeType.startsWith("image/")) return MediaType.IMAGE;
79
+ if (mimeType.startsWith("video/")) return MediaType.VIDEO;
80
+ return MediaType.ALL;
81
+ }
82
+ }
@@ -0,0 +1,70 @@
1
+ /**
2
+ * @umituz/react-native-media - Enhanced Public API
3
+ *
4
+ * Media picking capabilities for React Native apps
5
+ * Includes multimedia flashcard support
6
+ *
7
+ * Usage:
8
+ * import {
9
+ * useMedia,
10
+ * useMultimediaFlashcard,
11
+ * MultimediaFlashcardService,
12
+ * type MediaAttachment,
13
+ * type MultimediaFlashcard,
14
+ * } from '@umituz/react-native-media';
15
+ */
16
+
17
+ // Domain Layer - Original Media Entities
18
+ export {
19
+ MediaType,
20
+ ImageFormat as MediaImageFormat,
21
+ MediaQuality,
22
+ MediaLibraryPermission,
23
+ MEDIA_CONSTANTS,
24
+ } from "./domain/entities/Media";
25
+
26
+ export { IMAGE_MIME_TYPES as MEDIA_IMAGE_MIME_TYPES, MediaUtils } from "./domain/utils/MediaUtils";
27
+
28
+ export type {
29
+ MediaAsset,
30
+ MediaPickerResult,
31
+ MediaPickerOptions,
32
+ CameraOptions,
33
+ ImageDimensions as MediaImageDimensions,
34
+ ImageManipulationActions,
35
+ ImageSaveOptions as MediaImageSaveOptions,
36
+ } from "./domain/entities/Media";
37
+
38
+ // Infrastructure Layer - Original Media Services
39
+ export { MediaPickerService } from "./infrastructure/services/MediaPickerService";
40
+ export { MediaSaveService } from "./infrastructure/services/MediaSaveService";
41
+ export type { SaveResult, SaveOptions } from "./infrastructure/services/MediaSaveService";
42
+
43
+ // Presentation Layer - Original Media Hooks
44
+ export { useMedia } from "./presentation/hooks/useMedia";
45
+
46
+ // Multimedia Flashcard Support
47
+ export type {
48
+ CardMediaType,
49
+ CardMediaPosition,
50
+ CardMediaAttachment,
51
+ CardMultimediaFlashcard,
52
+ CardMediaGenerationRequest,
53
+ CardMediaGenerationResult,
54
+ CardMediaUploadProgress,
55
+ CardMediaCompressionOptions,
56
+ CardMediaValidation,
57
+ } from "./domain/entities/CardMultimedia.types";
58
+
59
+ export { CardMultimediaFlashcardService } from "./infrastructure/services/CardMultimediaService";
60
+
61
+ export {
62
+ useCardMediaUpload,
63
+ useCardMediaGeneration,
64
+ useCardMediaValidation,
65
+ useCardMultimediaFlashcard,
66
+ type UseCardMediaUploadResult,
67
+ type UseCardMediaGenerationResult,
68
+ type UseCardMediaValidationResult,
69
+ type UseCardMultimediaFlashcardResult,
70
+ } from "./presentation/hooks/useCardMultimediaFlashcard";
@@ -0,0 +1,191 @@
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