@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,164 +0,0 @@
1
- # useCardMediaGeneration
2
-
3
- ## Purpose
4
- Card-specific React hook for AI-powered media generation (text-to-image, text-to-audio, image-search) for flashcards.
5
-
6
- ## File Location
7
- `src/presentation/hooks/useCardMediaGeneration.ts`
8
-
9
- ## Strategy
10
- - Provide card-specific interface for AI media generation
11
- - Support text-to-image, text-to-audio, and image-search operations
12
- - Return CardMediaAttachment with position property
13
- - Track generation status and metadata
14
- - Manage credit costs for card media generation
15
- - Handle generation errors with proper feedback
16
- - Support card-specific generation options
17
-
18
- ## Forbidden
19
- - **DO NOT** start generation while previous is in progress
20
- - **DO NOT** ignore credit costs before generation
21
- - **DO NOT** mock generation in production without AI API
22
- - **DO NOT** assume generation will succeed - check result.success
23
- - **DO NOT** expose API keys or AI implementation details
24
- - **DO NOT** allow unlimited concurrent generations
25
- - **DO NOT** bypass timeout handling for long generations
26
- - **DO NOT** store large results permanently in hook state
27
- - **DO NOT** use empty or invalid prompts
28
- - **DO NOT** mix with MediaAttachment (must use CardMediaAttachment)
29
-
30
- ## Rules
31
- 1. Always validate prompt text before generation
32
- 2. Check credit availability before operations
33
- 3. Track processing time for each request
34
- 4. Return CardMediaAttachment with position property
35
- 5. Return unique requestId for tracking
36
- 6. Include creditsUsed in result metadata
37
- 7. Support maxResults for multiple outputs
38
- 8. Clear generation state on new operations
39
- 9. Handle both success and failure gracefully
40
- 10. Support language, voice, speed options for audio
41
-
42
- ## AI Agent Guidelines
43
-
44
- When working with useCardMediaGeneration hook:
45
-
46
- 1. **Type Specificity**: Use CardMediaAttachment (not MediaAttachment)
47
- 2. **Position Awareness**: Generated media has position property
48
- 3. **Prompt Quality**: Use descriptive prompts for better results
49
- 4. **Credit Tracking**: Monitor credit costs and balance
50
- 5. **Error Handling**: Always check result.success field
51
-
52
- ### Generation Types
53
-
54
- **Text-to-Image** (type: 'text_to_image')
55
- - Generates images from text descriptions
56
- - Credit cost: 5 per generation
57
- - Default maxResults: 1
58
- - Returns CardMediaAttachment with position: 'both'
59
- - Supports style customization
60
-
61
- **Text-to-Audio** (type: 'text_to_audio')
62
- - Generates audio from text (TTS)
63
- - Credit cost: 3 per generation
64
- - Default duration: 10 seconds
65
- - Returns CardMediaAttachment with position: 'back'
66
- - Supports voice, language, speed options
67
-
68
- **Image Search** (type: 'image_search')
69
- - Searches for existing images
70
- - Credit cost: 2 per search
71
- - Default maxResults: 5
72
- - Returns CardMediaAttachment with position: 'both'
73
- - Finds relevant images from database
74
-
75
- ### Generation Workflow
76
-
77
- 1. Validate prompt text quality
78
- 2. Check credit balance
79
- 3. Select generation type
80
- 4. Configure options (maxResults, voice, language, etc.)
81
- 5. Call generateMedia with request
82
- 6. Monitor isGenerating state
83
- 7. Process CardMediaGenerationResult
84
- 8. Handle success or error
85
-
86
- ### Result Structure
87
-
88
- CardMediaGenerationResult includes:
89
- - success: Boolean success/failure
90
- - attachments: Array of CardMediaAttachment (with position)
91
- - creditsUsed: Credits consumed
92
- - processingTime: Duration in milliseconds
93
- - requestId: Unique identifier
94
- - error: Error message if failed
95
-
96
- ### CardMediaAttachment Features
97
-
98
- Generated attachments include:
99
- - id: Unique ID with card_media_ prefix
100
- - type: CardMediaType (IMAGE, VIDEO, AUDIO)
101
- - position: CardMediaPosition (front, back, or both)
102
- - url: Generated media URL
103
- - filename: Generated filename
104
- - fileSize: Size in bytes
105
- - mimeType: MIME type
106
- - duration: Audio/video duration
107
- - thumbnailUrl: Thumbnail for visual media
108
- - isDownloaded: Download status
109
- - createdAt: ISO timestamp
110
-
111
- ### Generation Options
112
-
113
- **Image Options:**
114
- - maxResults: Number of images (default: 1)
115
- - style: Image style preset
116
-
117
- **Audio Options:**
118
- - voice: Voice type (male/female)
119
- - language: Language code ('tr-TR', 'en-US')
120
- - speed: Playback speed (default: 1.0)
121
-
122
- **Image Search Options:**
123
- - maxResults: Number of results (default: 5)
124
-
125
- ### Integration with Card Creation
126
-
127
- Typical workflow:
128
- 1. Generate media with useCardMediaGeneration
129
- 2. Receive CardMediaAttachment objects
130
- 3. Use in createCardMultimedia call
131
- 4. Position is automatically assigned by generation type
132
- 5. Complete card with generated media
133
-
134
- ### Credit Costs
135
-
136
- | Operation | Credits |
137
- |-----------|---------|
138
- | Text-to-Image | 5 |
139
- | Text-to-Audio | 3 |
140
- | Image Search | 2 |
141
-
142
- ### Error Scenarios
143
-
144
- - Insufficient credits: Check balance before generation
145
- - Invalid prompt: Validate text quality
146
- - API timeout: Implement retry logic
147
- - Content policy: Filter prompts appropriately
148
- - Service unavailable: Graceful error handling
149
-
150
- ### Integration Requirements
151
-
152
- - Configure AI service endpoints
153
- - Implement authentication for AI APIs
154
- - Handle rate limiting and quotas
155
- - Implement retry logic for failures
156
- - Cache results when appropriate
157
- - Monitor credit usage
158
-
159
- ## Dependencies
160
-
161
- - CardMediaGenerationService (infrastructure layer)
162
- - Domain types: CardMediaGenerationRequest, CardMediaGenerationResult, CardMediaAttachment
163
- - Credit tracking system
164
- - AI service APIs (text-to-image, TTS, image search)
@@ -1,153 +0,0 @@
1
- # useCardMediaUpload
2
-
3
- ## Purpose
4
- Card-specific React hook for uploading flashcard media files to server with progress tracking and compression support.
5
-
6
- ## File Location
7
- `src/presentation/hooks/useCardMediaUpload.ts`
8
-
9
- ## Strategy
10
- - Provide card-specific media upload interface
11
- - Support compression options for optimization
12
- - Track upload progress with percentage and status
13
- - Return CardMediaAttachment with position property
14
- - Handle upload errors gracefully
15
- - Generate thumbnails for visual media
16
- - Support various media types for cards
17
-
18
- ## Forbidden
19
- - **DO NOT** start upload while previous is in progress
20
- - **DO NOT** ignore compression options
21
- - **DO NOT** upload without validation (use useCardMediaValidation)
22
- - **DO NOT** mock upload in production without backend integration
23
- - **DO NOT** modify file during upload (compress before)
24
- - **DO NOT** assume upload will succeed
25
- - **DO NOT** use hardcoded API endpoints
26
- - **DO NOT** bypass progress tracking
27
- - **DO NOT** store upload results permanently in state
28
- - **DO NOT** use incorrect ID prefixes (must use card_media_)
29
-
30
- ## Rules
31
- 1. Always validate before uploading (use useCardMediaValidation)
32
- 2. Compression quality must be in 0-1 range
33
- 3. Dimensions must be in pixels
34
- 4. Progress updates every 10% or on status change
35
- 5. Clear upload state on error or completion
36
- 6. Return CardMediaAttachment with position property
37
- 7. Generate thumbnail URL automatically
38
- 8. Calculate duration for audio/video
39
- 9. Update progress status: uploading -> completed/error
40
- 10. Include unique fileId in progress tracking
41
-
42
- ## AI Agent Guidelines
43
-
44
- When working with useCardMediaUpload hook:
45
-
46
- 1. **Type Correctness**: Returns CardMediaAttachment (not MediaAttachment)
47
- 2. **Position Property**: Uploaded media includes position field
48
- 3. **Pre-upload Validation**: Always use useCardMediaValidation first
49
- 4. **Progress Tracking**: Monitor uploadProgress for real-time updates
50
- 5. **Compression**: Apply appropriate compression settings
51
-
52
- ### Upload Workflow
53
-
54
- 1. Validate file with useCardMediaValidation
55
- 2. Select compression options based on type and size
56
- 3. Call uploadMedia with file and options
57
- 4. Monitor uploadProgress state
58
- 5. Handle completion (success or error)
59
- 6. Process returned CardMediaAttachment
60
-
61
- ### CardMediaAttachment Structure
62
-
63
- Returned object includes:
64
- - id: Unique ID with card_media_ prefix
65
- - type: CardMediaType (IMAGE, VIDEO, AUDIO)
66
- - position: CardMediaPosition (defaults to 'both')
67
- - url: Uploaded file URL
68
- - filename: Original filename
69
- - fileSize: Size in bytes
70
- - mimeType: MIME type string
71
- - duration: Audio/video duration
72
- - thumbnailUrl: Thumbnail for visual media
73
- - caption: Optional caption text
74
- - isDownloaded: Download status
75
- - createdAt: ISO timestamp
76
-
77
- ### Compression Guidelines
78
-
79
- **High Quality** (quality: 0.9, maxWidth: 4096)
80
- - Use for detailed card images
81
- - Larger file size, best quality
82
-
83
- **Medium Quality** (quality: 0.7, maxWidth: 1920) - RECOMMENDED
84
- - Balanced quality and size
85
- - Good for most card media
86
-
87
- **Low Quality** (quality: 0.5, maxWidth: 1280)
88
- - Use for card thumbnails
89
- - Smallest size, reduced quality
90
-
91
- ### Upload Progress States
92
-
93
- - **uploading**: Upload in progress (0-99%)
94
- - **completed**: Upload finished successfully (100%)
95
- - **error**: Upload failed with error message
96
-
97
- ### CardMediaUploadProgress
98
-
99
- Progress object includes:
100
- - fileId: Unique file identifier
101
- - progress: Percentage (0-100)
102
- - status: Current state (uploading/completed/error)
103
- - url: Final URL when completed
104
-
105
- ### Integration with Card Creation
106
-
107
- Typical workflow:
108
- 1. Select or generate media
109
- 2. Validate with useCardMediaValidation
110
- 3. Upload with useCardMediaUpload
111
- 4. Receive CardMediaAttachment with position
112
- 5. Add to card media array
113
- 6. Create card with useCardMultimediaFlashcard
114
-
115
- ### Position Assignment
116
-
117
- Uploaded media gets position property:
118
- - Default: 'both' (shown on both sides)
119
- - Can be overridden: 'front' or 'back'
120
- - Used to control media display on card sides
121
-
122
- ### Multiple File Upload
123
-
124
- For multiple media files:
125
- 1. Upload files sequentially or in parallel
126
- 2. Collect CardMediaAttachment objects
127
- 3. Assign positions appropriately
128
- 4. Add to card media array
129
- 5. Track individual upload progress
130
-
131
- ### Integration Requirements
132
-
133
- - Configure API endpoint for card media upload
134
- - Implement authentication for uploads
135
- - Handle file size limits
136
- - Support retry logic for failures
137
- - Generate thumbnails automatically
138
- - Calculate media duration for audio/video
139
-
140
- ### Error Handling
141
-
142
- Common error scenarios:
143
- - File too large: Validate before upload
144
- - Unsupported type: Check MIME type
145
- - Network timeout: Implement retry with backoff
146
- - Server error: Display user-friendly message
147
- - Authentication failure: Check token validity
148
-
149
- ## Dependencies
150
-
151
- - CardMediaUploadService (infrastructure layer)
152
- - Domain types: CardMediaAttachment, CardMediaCompressionOptions, CardMediaUploadProgress
153
- - useCardMediaValidation (for pre-upload validation)
@@ -1,176 +0,0 @@
1
- # useCardMediaValidation
2
-
3
- ## Purpose
4
- Card-specific React hook for validating flashcard media files before upload with enhanced controls for different media types.
5
-
6
- ## File Location
7
- `src/presentation/hooks/useCardMediaValidation.ts`
8
-
9
- ## Strategy
10
- - Provide comprehensive validation for card media files
11
- - Enhanced controls for images (5 MB warning threshold)
12
- - Support audio/video duration validation
13
- - Provide three-tier feedback: errors, warnings, recommendations
14
- - Card-specific validation rules compared to general media
15
- - Enable pre-upload validation workflow for cards
16
- - Return actionable feedback with media-type specific recommendations
17
-
18
- ## Forbidden
19
- - **DO NOT** upload files that fail validation (have errors)
20
- - **DO NOT** ignore warnings - they indicate card performance issues
21
- - **DO NOT** bypass file type validation
22
- - **DO NOT** use mock validation in production
23
- - **DO NOT** allow files exceeding 50 MB limit
24
- - **DO NOT** modify files during validation
25
- - **DO NOT** store validation results permanently
26
- - **DO NOT** validate empty or missing files
27
- - **DO NOT** suppress errors for user convenience
28
-
29
- ## Rules
30
- 1. Always validate before card media upload
31
- 2. Files over 50 MB must be rejected
32
- 3. Files over 10 MB trigger warning
33
- 4. Images over 5 MB trigger additional warning
34
- 5. Unsupported MIME types must be rejected
35
- 6. Validate file size, type, and format
36
- 7. Return errors array for blocking issues
37
- 8. Return warnings array for performance concerns
38
- 9. Return recommendations array for improvements
39
- 10. Clear validation state on new requests
40
-
41
- ## AI Agent Guidelines
42
-
43
- When working with useCardMediaValidation hook:
44
-
45
- 1. **Card-Specific Rules**: Use for card media (not general media)
46
- 2. **Enhanced Image Control**: 5 MB threshold for images (stricter than general)
47
- 3. **Three-Tier Feedback**: Distinguish errors, warnings, recommendations
48
- 4. **Duration Control**: Check audio/video duration when available
49
- 5. **Pre-upload Check**: Always validate before useCardMediaUpload
50
-
51
- ### Validation Levels
52
-
53
- **Errors** (Blocking - Must fix):
54
- - File size exceeds 50 MB
55
- - Unsupported file type
56
- - Invalid file format
57
- - Missing required properties
58
-
59
- **Warnings** (Performance - Should fix):
60
- - File size over 10 MB (general warning)
61
- - Image size over 5 MB (card-specific warning)
62
- - Long duration audio/video
63
- - Large dimensions
64
-
65
- **Recommendations** (Improvements - Optional):
66
- - Reduce file size for card performance
67
- - Use recommended formats
68
- - Optimize dimensions
69
- - Compress for balance
70
-
71
- ### Card-Specific vs General Validation
72
-
73
- | Feature | useMediaValidation | useCardMediaValidation |
74
- |---------|-------------------|------------------------|
75
- | Max file size | 50 MB | 50 MB |
76
- | General warning | 10 MB | 10 MB |
77
- | Image warning | None | 5 MB (extra) |
78
- | Duration check | No | Yes (5 min warning) |
79
- | Type support | Same | Same |
80
-
81
- ### Supported File Types
82
-
83
- **Images:**
84
- - image/jpeg
85
- - image/png
86
- - image/webp
87
-
88
- **Audio:**
89
- - audio/mp3
90
- - audio/wav
91
- - audio/m4a
92
-
93
- **Video:**
94
- - video/mp4
95
- - video/mov
96
-
97
- ### Validation Workflow
98
-
99
- 1. Receive file object (name, type, size, uri)
100
- 2. Check file size against limits
101
- 3. Validate MIME type
102
- 4. Apply card-specific rules (5 MB image warning)
103
- 5. Check duration if available
104
- 6. Generate errors, warnings, recommendations
105
- 7. Return CardMediaValidation object
106
-
107
- ### CardMediaValidation Structure
108
-
109
- Validation result includes:
110
- - isValid: Boolean (true if no errors)
111
- - errors: String array (blocking issues)
112
- - warnings: String array (performance concerns)
113
- - recommendations: String array (improvements)
114
-
115
- ### File Size Guidelines
116
-
117
- **Images:**
118
- - Optimal: Under 2 MB
119
- - Card warning: 2-5 MB
120
- - Extra warning: 5-10 MB
121
- - Error: Over 50 MB
122
-
123
- **Audio:**
124
- - Optimal: Under 5 MB
125
- - Warning: 5-10 MB
126
- - Duration warning: Over 5 minutes
127
- - Error: Over 50 MB
128
-
129
- **Video:**
130
- - Optimal: Under 10 MB
131
- - Warning: 10-50 MB
132
- - Duration warning: Over 5 minutes
133
- - Error: Over 50 MB
134
-
135
- ### Media Type Special Controls
136
-
137
- **Image Controls:**
138
- - Additional 5 MB warning threshold
139
- - Dimension recommendations
140
- - Format recommendations (JPEG for photos, PNG for graphics)
141
-
142
- **Audio Controls:**
143
- - Duration check (warn over 5 minutes)
144
- - Format recommendation (MP3 preferred)
145
- - Bitrate considerations
146
-
147
- **Video Controls:**
148
- - Duration check (warn over 5 minutes)
149
- - Format recommendation (MP4 preferred)
150
- - Resolution recommendations
151
-
152
- ### Integration with Card Upload Flow
153
-
154
- Typical validation-upload workflow:
155
- 1. Select file from picker
156
- 2. Call validateMedia(file) from useCardMediaValidation
157
- 3. Check validation.isValid
158
- 4. If errors: Display and block upload
159
- 5. If warnings: Display and get confirmation
160
- 6. If recommendations: Display for reference
161
- 7. Proceed to useCardMediaUpload if valid or confirmed
162
-
163
- ### Best Practices
164
-
165
- 1. Always validate before card media upload
166
- 2. Show all three feedback levels to users
167
- 3. Allow users to proceed with warnings
168
- 4. Provide actionable recommendations
169
- 5. Consider card performance implications
170
- 6. Balance quality vs. file size
171
-
172
- ## Dependencies
173
-
174
- - CardMediaValidationService (infrastructure layer)
175
- - Domain types: CardMediaValidation, file input interfaces
176
- - Media constants (card-specific size limits)
@@ -1,97 +0,0 @@
1
- /**
2
- * Development Utilities Tests
3
- */
4
-
5
- import { isDev, devWarn, devError, devLog } from '../devUtils';
6
-
7
- // Mock console methods
8
- const mockConsoleWarn = jest.fn();
9
- const mockConsoleError = jest.fn();
10
- const mockConsoleLog = jest.fn();
11
-
12
- describe('Development Utilities', () => {
13
- beforeEach(() => {
14
- jest.clearAllMocks();
15
-
16
- // Mock console methods
17
- console.warn = mockConsoleWarn;
18
- console.error = mockConsoleError;
19
- console.log = mockConsoleLog;
20
- });
21
-
22
- describe('isDev', () => {
23
- it('should return true when __DEV__ is true', () => {
24
- (globalThis as any).__DEV__ = true;
25
- expect(isDev()).toBe(true);
26
- });
27
-
28
- it('should return false when __DEV__ is false', () => {
29
- (globalThis as any).__DEV__ = false;
30
- expect(isDev()).toBe(false);
31
- });
32
-
33
- it('should return false when __DEV__ is undefined', () => {
34
- delete (globalThis as any).__DEV__;
35
- expect(isDev()).toBe(false);
36
- });
37
- });
38
-
39
- describe('devWarn', () => {
40
- it('should log warning when in development mode', () => {
41
- (globalThis as any).__DEV__ = true;
42
-
43
- devWarn('Test warning', { data: 'test' });
44
-
45
- expect(mockConsoleWarn).toHaveBeenCalledWith('Test warning', { data: 'test' });
46
- });
47
-
48
- it('should not log warning when not in development mode', () => {
49
- (globalThis as any).__DEV__ = false;
50
-
51
- devWarn('Test warning', { data: 'test' });
52
-
53
- expect(mockConsoleWarn).not.toHaveBeenCalled();
54
- });
55
- });
56
-
57
- describe('devError', () => {
58
- it('should log error when in development mode', () => {
59
- (globalThis as any).__DEV__ = true;
60
-
61
- devError('Test error', new Error('test'));
62
-
63
- expect(mockConsoleError).toHaveBeenCalledWith('Test error', new Error('test'));
64
- });
65
-
66
- it('should not log error when not in development mode', () => {
67
- (globalThis as any).__DEV__ = false;
68
-
69
- devError('Test error', new Error('test'));
70
-
71
- expect(mockConsoleError).not.toHaveBeenCalled();
72
- });
73
- });
74
-
75
- describe('devLog', () => {
76
- it('should log info when in development mode', () => {
77
- (globalThis as any).__DEV__ = true;
78
-
79
- devLog('Test log', { info: 'test' });
80
-
81
- expect(mockConsoleLog).toHaveBeenCalledWith('Test log', { info: 'test' });
82
- });
83
-
84
- it('should not log info when not in development mode', () => {
85
- (globalThis as any).__DEV__ = false;
86
-
87
- devLog('Test log', { info: 'test' });
88
-
89
- expect(mockConsoleLog).not.toHaveBeenCalled();
90
- });
91
- });
92
-
93
- afterEach(() => {
94
- // Clean up __DEV__ after each test
95
- delete (globalThis as any).__DEV__;
96
- });
97
- });