react-native-ensys-camera-x 1.0.7
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/CustomCamera.podspec +20 -0
- package/LICENSE +20 -0
- package/README.md +833 -0
- package/android/build.gradle +135 -0
- package/android/consumer-rules.pro +47 -0
- package/android/src/main/AndroidManifest.xml +72 -0
- package/android/src/main/java/android/print/PdfPrint.java +51 -0
- package/android/src/main/java/com/customcamera/AnimatedImageViewManager.kt +199 -0
- package/android/src/main/java/com/customcamera/AudioPlayerView.kt +322 -0
- package/android/src/main/java/com/customcamera/AudioRecorder.kt +506 -0
- package/android/src/main/java/com/customcamera/BarcodeScannerActivity.kt +361 -0
- package/android/src/main/java/com/customcamera/BlurBackgroundView.kt +199 -0
- package/android/src/main/java/com/customcamera/CacheCleanupManager.kt +386 -0
- package/android/src/main/java/com/customcamera/CameraAspectRatioMode.kt +77 -0
- package/android/src/main/java/com/customcamera/CameraAsset.kt +211 -0
- package/android/src/main/java/com/customcamera/CameraTheme.kt +479 -0
- package/android/src/main/java/com/customcamera/CompressionCacheStore.kt +504 -0
- package/android/src/main/java/com/customcamera/CompressionFileNameUtils.kt +7 -0
- package/android/src/main/java/com/customcamera/CompressionProfile.kt +195 -0
- package/android/src/main/java/com/customcamera/CustomCameraActivity.kt +7291 -0
- package/android/src/main/java/com/customcamera/CustomCameraFileProvider.kt +9 -0
- package/android/src/main/java/com/customcamera/CustomCameraModule.kt +2479 -0
- package/android/src/main/java/com/customcamera/CustomCameraPackage.kt +53 -0
- package/android/src/main/java/com/customcamera/DisplayUtils.kt +9 -0
- package/android/src/main/java/com/customcamera/DocumentPreviewView.kt +846 -0
- package/android/src/main/java/com/customcamera/DrawingView.kt +214 -0
- package/android/src/main/java/com/customcamera/EmojiPickerData.kt +228 -0
- package/android/src/main/java/com/customcamera/FilterStripAdapter.kt +158 -0
- package/android/src/main/java/com/customcamera/GifSupport.kt +215 -0
- package/android/src/main/java/com/customcamera/GlobalAudioPlayer.kt +320 -0
- package/android/src/main/java/com/customcamera/ImageExporter.kt +1394 -0
- package/android/src/main/java/com/customcamera/ImageFormatSupport.kt +163 -0
- package/android/src/main/java/com/customcamera/Localization.kt +206 -0
- package/android/src/main/java/com/customcamera/MediaAdapters.kt +758 -0
- package/android/src/main/java/com/customcamera/MediaCacheManager.kt +782 -0
- package/android/src/main/java/com/customcamera/MediaExportFormats.kt +201 -0
- package/android/src/main/java/com/customcamera/MediaFileIo.kt +310 -0
- package/android/src/main/java/com/customcamera/MediaMetadataStore.kt +494 -0
- package/android/src/main/java/com/customcamera/MediaPreviewEditor.kt +14865 -0
- package/android/src/main/java/com/customcamera/MediaPublisher.kt +423 -0
- package/android/src/main/java/com/customcamera/MediaStorageWorkflow.kt +722 -0
- package/android/src/main/java/com/customcamera/MediaStoreRepository.kt +378 -0
- package/android/src/main/java/com/customcamera/MediaThumbnailView.kt +286 -0
- package/android/src/main/java/com/customcamera/MediaUtils.kt +37 -0
- package/android/src/main/java/com/customcamera/NativeVideoViewManager.kt +845 -0
- package/android/src/main/java/com/customcamera/OfficeDocumentConverter.kt +2791 -0
- package/android/src/main/java/com/customcamera/PendingCaptureCrops.kt +88 -0
- package/android/src/main/java/com/customcamera/PowerPointPreview.kt +4077 -0
- package/android/src/main/java/com/customcamera/RecentPickerStore.kt +74 -0
- package/android/src/main/java/com/customcamera/SecureFileEraser.kt +411 -0
- package/android/src/main/java/com/customcamera/SecureKeyModule.kt +88 -0
- package/android/src/main/java/com/customcamera/SecureMediaDeleter.kt +493 -0
- package/android/src/main/java/com/customcamera/StickerPickerData.kt +107 -0
- package/android/src/main/java/com/customcamera/SvgDrawable.kt +175 -0
- package/android/src/main/java/com/customcamera/SvgIconViewManager.kt +77 -0
- package/android/src/main/java/com/customcamera/TextEntryController.kt +553 -0
- package/android/src/main/java/com/customcamera/ThumbnailLoader.kt +455 -0
- package/android/src/main/java/com/customcamera/UploadService.kt +909 -0
- package/android/src/main/java/com/customcamera/VideoEditUtils.kt +210 -0
- package/android/src/main/java/com/customcamera/VideoRotationTranscoder.kt +1992 -0
- package/android/src/main/java/com/customcamera/gif/AnimatedGifEncoder.kt +473 -0
- package/android/src/main/java/com/customcamera/gif/GifDecoder.kt +690 -0
- package/android/src/main/java/com/customcamera/gif/GifFramesDrawable.kt +160 -0
- package/android/src/main/java/com/customcamera/gif/GifHttp.kt +112 -0
- package/android/src/main/java/com/customcamera/gif/GifImageLoader.kt +186 -0
- package/android/src/main/java/com/customcamera/gif/GifModels.kt +74 -0
- package/android/src/main/java/com/customcamera/gif/GifProvider.kt +49 -0
- package/android/src/main/java/com/customcamera/gif/GifProviders.kt +27 -0
- package/android/src/main/java/com/customcamera/gif/GifRepository.kt +124 -0
- package/android/src/main/java/com/customcamera/gif/GifSafety.kt +33 -0
- package/android/src/main/java/com/customcamera/gif/GiphyGifProvider.kt +146 -0
- package/android/src/main/java/com/customcamera/gif/LZWEncoder.kt +258 -0
- package/android/src/main/java/com/customcamera/gif/NeuQuant.kt +435 -0
- package/android/src/main/java/com/customcamera/gif/TenorGifProvider.kt +147 -0
- package/android/src/main/res/drawable/bg_brush_selected.xml +5 -0
- package/android/src/main/res/drawable/bg_color_swatch.xml +5 -0
- package/android/src/main/res/drawable/bg_editor_toolbar.xml +6 -0
- package/android/src/main/res/drawable/bg_icon_circle.xml +5 -0
- package/android/src/main/res/drawable/bg_icon_circle_light.xml +5 -0
- package/android/src/main/res/drawable/bg_mode_tab_active.xml +6 -0
- package/android/src/main/res/drawable/bg_pill.xml +6 -0
- package/android/src/main/res/drawable/bg_recording_dot.xml +6 -0
- package/android/src/main/res/drawable/bg_selection_badge.xml +8 -0
- package/android/src/main/res/drawable/bg_send_button.xml +5 -0
- package/android/src/main/res/drawable/bg_shutter_inner.xml +5 -0
- package/android/src/main/res/drawable/bg_shutter_recording.xml +6 -0
- package/android/src/main/res/drawable/bg_shutter_ring.xml +8 -0
- package/android/src/main/res/drawable/bg_shutter_video_idle.xml +5 -0
- package/android/src/main/res/drawable/bg_thumbnail.xml +9 -0
- package/android/src/main/res/drawable/ic_aspect_ratio.xml +17 -0
- package/android/src/main/res/drawable/ic_audio.xml +10 -0
- package/android/src/main/res/drawable/ic_back.xml +10 -0
- package/android/src/main/res/drawable/ic_brush_medium.xml +12 -0
- package/android/src/main/res/drawable/ic_brush_thick.xml +12 -0
- package/android/src/main/res/drawable/ic_brush_thin.xml +12 -0
- package/android/src/main/res/drawable/ic_check.xml +17 -0
- package/android/src/main/res/drawable/ic_chevron_down.xml +10 -0
- package/android/src/main/res/drawable/ic_chevron_up.xml +13 -0
- package/android/src/main/res/drawable/ic_clear_drawing.xml +10 -0
- package/android/src/main/res/drawable/ic_close.xml +10 -0
- package/android/src/main/res/drawable/ic_cover.xml +9 -0
- package/android/src/main/res/drawable/ic_crop.xml +10 -0
- package/android/src/main/res/drawable/ic_delete.xml +9 -0
- package/android/src/main/res/drawable/ic_document.xml +10 -0
- package/android/src/main/res/drawable/ic_done.xml +10 -0
- package/android/src/main/res/drawable/ic_download.xml +10 -0
- package/android/src/main/res/drawable/ic_emoji.xml +10 -0
- package/android/src/main/res/drawable/ic_filter.xml +10 -0
- package/android/src/main/res/drawable/ic_flash_auto.xml +7 -0
- package/android/src/main/res/drawable/ic_flash_off.xml +23 -0
- package/android/src/main/res/drawable/ic_flash_on.xml +16 -0
- package/android/src/main/res/drawable/ic_flip.xml +15 -0
- package/android/src/main/res/drawable/ic_gallery.xml +10 -0
- package/android/src/main/res/drawable/ic_gif.xml +24 -0
- package/android/src/main/res/drawable/ic_lock.xml +19 -0
- package/android/src/main/res/drawable/ic_lock_open.xml +22 -0
- package/android/src/main/res/drawable/ic_marker.xml +10 -0
- package/android/src/main/res/drawable/ic_more_vert.xml +18 -0
- package/android/src/main/res/drawable/ic_overlay_close.xml +19 -0
- package/android/src/main/res/drawable/ic_overlay_resize.xml +18 -0
- package/android/src/main/res/drawable/ic_pause.xml +10 -0
- package/android/src/main/res/drawable/ic_photo_mode.xml +10 -0
- package/android/src/main/res/drawable/ic_play.xml +10 -0
- package/android/src/main/res/drawable/ic_redo.xml +10 -0
- package/android/src/main/res/drawable/ic_rotate.xml +9 -0
- package/android/src/main/res/drawable/ic_send.xml +10 -0
- package/android/src/main/res/drawable/ic_share.xml +10 -0
- package/android/src/main/res/drawable/ic_stat_upload.xml +10 -0
- package/android/src/main/res/drawable/ic_sticker.xml +24 -0
- package/android/src/main/res/drawable/ic_text.xml +10 -0
- package/android/src/main/res/drawable/ic_text_align_center.xml +11 -0
- package/android/src/main/res/drawable/ic_text_align_left.xml +11 -0
- package/android/src/main/res/drawable/ic_text_align_right.xml +11 -0
- package/android/src/main/res/drawable/ic_text_bg.xml +11 -0
- package/android/src/main/res/drawable/ic_trim.xml +23 -0
- package/android/src/main/res/drawable/ic_undo.xml +10 -0
- package/android/src/main/res/drawable/ic_video_mode.xml +10 -0
- package/android/src/main/res/drawable/ic_video_note.xml +13 -0
- package/android/src/main/res/drawable/ic_volume_off.xml +9 -0
- package/android/src/main/res/drawable/ic_volume_on.xml +9 -0
- package/android/src/main/res/drawable/sticker_heart.xml +9 -0
- package/android/src/main/res/drawable/sticker_smile.xml +9 -0
- package/android/src/main/res/drawable/sticker_star.xml +9 -0
- package/android/src/main/res/drawable/sticker_thumbsup.xml +9 -0
- package/android/src/main/res/values/colors.xml +34 -0
- package/android/src/main/res/values/ids.xml +15 -0
- package/android/src/main/res/values/strings.xml +15 -0
- package/android/src/main/res/values/styles.xml +20 -0
- package/android/src/main/res/xml/file_paths.xml +34 -0
- package/ios/CustomCamera.h +5 -0
- package/ios/CustomCamera.mm +214 -0
- package/lib/module/AudioPlayerContext.js +233 -0
- package/lib/module/AudioPlayerContext.js.map +1 -0
- package/lib/module/CameraPreview.js +304 -0
- package/lib/module/CameraPreview.js.map +1 -0
- package/lib/module/NativeAnimatedImageView.js +41 -0
- package/lib/module/NativeAnimatedImageView.js.map +1 -0
- package/lib/module/NativeAudioPlayerView.js +33 -0
- package/lib/module/NativeAudioPlayerView.js.map +1 -0
- package/lib/module/NativeBlurView.js +35 -0
- package/lib/module/NativeBlurView.js.map +1 -0
- package/lib/module/NativeCustomCamera.js +128 -0
- package/lib/module/NativeCustomCamera.js.map +1 -0
- package/lib/module/NativeCustomCamera.web.js +143 -0
- package/lib/module/NativeCustomCamera.web.js.map +1 -0
- package/lib/module/NativeCustomVideoView.js +5 -0
- package/lib/module/NativeCustomVideoView.js.map +1 -0
- package/lib/module/NativeDocumentPreviewView.js +156 -0
- package/lib/module/NativeDocumentPreviewView.js.map +1 -0
- package/lib/module/NativeMediaThumbnailView.js +110 -0
- package/lib/module/NativeMediaThumbnailView.js.map +1 -0
- package/lib/module/NativeSvgIcon.js +32 -0
- package/lib/module/NativeSvgIcon.js.map +1 -0
- package/lib/module/ResponsivePreviewContainer.js +171 -0
- package/lib/module/ResponsivePreviewContainer.js.map +1 -0
- package/lib/module/accessibility.js +61 -0
- package/lib/module/accessibility.js.map +1 -0
- package/lib/module/config.js +352 -0
- package/lib/module/config.js.map +1 -0
- package/lib/module/cpuOptimization.js +296 -0
- package/lib/module/cpuOptimization.js.map +1 -0
- package/lib/module/db/DatabaseManager.js +191 -0
- package/lib/module/db/DatabaseManager.js.map +1 -0
- package/lib/module/db/MediaMapper.js +284 -0
- package/lib/module/db/MediaMapper.js.map +1 -0
- package/lib/module/db/MediaRepository.js +242 -0
- package/lib/module/db/MediaRepository.js.map +1 -0
- package/lib/module/db/index.js +41 -0
- package/lib/module/db/index.js.map +1 -0
- package/lib/module/db/migrations.js +180 -0
- package/lib/module/db/migrations.js.map +1 -0
- package/lib/module/db/react-native-sqlcipher.d.js +2 -0
- package/lib/module/db/react-native-sqlcipher.d.js.map +1 -0
- package/lib/module/db/secureKey.js +87 -0
- package/lib/module/db/secureKey.js.map +1 -0
- package/lib/module/db/types.js +57 -0
- package/lib/module/db/types.js.map +1 -0
- package/lib/module/db/useMediaDatabase.js +123 -0
- package/lib/module/db/useMediaDatabase.js.map +1 -0
- package/lib/module/defaultIcons.js +2259 -0
- package/lib/module/defaultIcons.js.map +1 -0
- package/lib/module/deviceCapabilities.js +408 -0
- package/lib/module/deviceCapabilities.js.map +1 -0
- package/lib/module/errors.js +267 -0
- package/lib/module/errors.js.map +1 -0
- package/lib/module/iconConfig.js +796 -0
- package/lib/module/iconConfig.js.map +1 -0
- package/lib/module/icons.js +514 -0
- package/lib/module/icons.js.map +1 -0
- package/lib/module/index.js +251 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/jest-globals.d.js +2 -0
- package/lib/module/jest-globals.d.js.map +1 -0
- package/lib/module/library/MediaLibrary.js +107 -0
- package/lib/module/library/MediaLibrary.js.map +1 -0
- package/lib/module/library/MediaLibraryScreen.js +2597 -0
- package/lib/module/library/MediaLibraryScreen.js.map +1 -0
- package/lib/module/library/components/AudioPreview.js +74 -0
- package/lib/module/library/components/AudioPreview.js.map +1 -0
- package/lib/module/library/components/DocumentPreview.js +331 -0
- package/lib/module/library/components/DocumentPreview.js.map +1 -0
- package/lib/module/library/components/ExpandableFab.js +343 -0
- package/lib/module/library/components/ExpandableFab.js.map +1 -0
- package/lib/module/library/components/FileTiles.js +251 -0
- package/lib/module/library/components/FileTiles.js.map +1 -0
- package/lib/module/library/components/ImagePreview.js +70 -0
- package/lib/module/library/components/ImagePreview.js.map +1 -0
- package/lib/module/library/components/MediaMetadataHeader.js +175 -0
- package/lib/module/library/components/MediaMetadataHeader.js.map +1 -0
- package/lib/module/library/components/RecordAudioScreen.js +816 -0
- package/lib/module/library/components/RecordAudioScreen.js.map +1 -0
- package/lib/module/library/components/VideoPreview.js +453 -0
- package/lib/module/library/components/VideoPreview.js.map +1 -0
- package/lib/module/library/components/ViewerCounter.js +55 -0
- package/lib/module/library/components/ViewerCounter.js.map +1 -0
- package/lib/module/library/compressionEstimate.js +507 -0
- package/lib/module/library/compressionEstimate.js.map +1 -0
- package/lib/module/library/fileMetadata.js +196 -0
- package/lib/module/library/fileMetadata.js.map +1 -0
- package/lib/module/library/index.js +42 -0
- package/lib/module/library/index.js.map +1 -0
- package/lib/module/library/libraryIconRegistry.js +69 -0
- package/lib/module/library/libraryIconRegistry.js.map +1 -0
- package/lib/module/library/libraryIcons.js +858 -0
- package/lib/module/library/libraryIcons.js.map +1 -0
- package/lib/module/library/localizedFormat.js +181 -0
- package/lib/module/library/localizedFormat.js.map +1 -0
- package/lib/module/library/palette.js +225 -0
- package/lib/module/library/palette.js.map +1 -0
- package/lib/module/library/responsive.js +53 -0
- package/lib/module/library/responsive.js.map +1 -0
- package/lib/module/locales.js +416 -0
- package/lib/module/locales.js.map +1 -0
- package/lib/module/localization.js +1064 -0
- package/lib/module/localization.js.map +1 -0
- package/lib/module/logger.js +20 -0
- package/lib/module/logger.js.map +1 -0
- package/lib/module/lowMemoryCache.js +206 -0
- package/lib/module/lowMemoryCache.js.map +1 -0
- package/lib/module/mediaHistory.js +33 -0
- package/lib/module/mediaHistory.js.map +1 -0
- package/lib/module/mediaStorageService.js +402 -0
- package/lib/module/mediaStorageService.js.map +1 -0
- package/lib/module/memory.js +79 -0
- package/lib/module/memory.js.map +1 -0
- package/lib/module/nativeActions.js +307 -0
- package/lib/module/nativeActions.js.map +1 -0
- package/lib/module/nativeComponentSupport.js +61 -0
- package/lib/module/nativeComponentSupport.js.map +1 -0
- package/lib/module/networkPerformance.js +24 -0
- package/lib/module/networkPerformance.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/performance.js +104 -0
- package/lib/module/performance.js.map +1 -0
- package/lib/module/performanceMonitor.js +155 -0
- package/lib/module/performanceMonitor.js.map +1 -0
- package/lib/module/permissions.js +370 -0
- package/lib/module/permissions.js.map +1 -0
- package/lib/module/rendering.js +40 -0
- package/lib/module/rendering.js.map +1 -0
- package/lib/module/security.js +18 -0
- package/lib/module/security.js.map +1 -0
- package/lib/module/state.js +266 -0
- package/lib/module/state.js.map +1 -0
- package/lib/module/storage.js +400 -0
- package/lib/module/storage.js.map +1 -0
- package/lib/module/theme.js +390 -0
- package/lib/module/theme.js.map +1 -0
- package/lib/module/types.js +4 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/utils.js +115 -0
- package/lib/module/utils.js.map +1 -0
- package/lib/module/validation.js +288 -0
- package/lib/module/validation.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/AudioPlayerContext.d.ts +27 -0
- package/lib/typescript/src/AudioPlayerContext.d.ts.map +1 -0
- package/lib/typescript/src/CameraPreview.d.ts +13 -0
- package/lib/typescript/src/CameraPreview.d.ts.map +1 -0
- package/lib/typescript/src/NativeAnimatedImageView.d.ts +33 -0
- package/lib/typescript/src/NativeAnimatedImageView.d.ts.map +1 -0
- package/lib/typescript/src/NativeAudioPlayerView.d.ts +12 -0
- package/lib/typescript/src/NativeAudioPlayerView.d.ts.map +1 -0
- package/lib/typescript/src/NativeBlurView.d.ts +12 -0
- package/lib/typescript/src/NativeBlurView.d.ts.map +1 -0
- package/lib/typescript/src/NativeCustomCamera.d.ts +167 -0
- package/lib/typescript/src/NativeCustomCamera.d.ts.map +1 -0
- package/lib/typescript/src/NativeCustomCamera.web.d.ts +47 -0
- package/lib/typescript/src/NativeCustomCamera.web.d.ts.map +1 -0
- package/lib/typescript/src/NativeCustomVideoView.d.ts +30 -0
- package/lib/typescript/src/NativeCustomVideoView.d.ts.map +1 -0
- package/lib/typescript/src/NativeDocumentPreviewView.d.ts +48 -0
- package/lib/typescript/src/NativeDocumentPreviewView.d.ts.map +1 -0
- package/lib/typescript/src/NativeMediaThumbnailView.d.ts +54 -0
- package/lib/typescript/src/NativeMediaThumbnailView.d.ts.map +1 -0
- package/lib/typescript/src/NativeSvgIcon.d.ts +25 -0
- package/lib/typescript/src/NativeSvgIcon.d.ts.map +1 -0
- package/lib/typescript/src/ResponsivePreviewContainer.d.ts +92 -0
- package/lib/typescript/src/ResponsivePreviewContainer.d.ts.map +1 -0
- package/lib/typescript/src/accessibility.d.ts +20 -0
- package/lib/typescript/src/accessibility.d.ts.map +1 -0
- package/lib/typescript/src/config.d.ts +145 -0
- package/lib/typescript/src/config.d.ts.map +1 -0
- package/lib/typescript/src/cpuOptimization.d.ts +63 -0
- package/lib/typescript/src/cpuOptimization.d.ts.map +1 -0
- package/lib/typescript/src/db/DatabaseManager.d.ts +48 -0
- package/lib/typescript/src/db/DatabaseManager.d.ts.map +1 -0
- package/lib/typescript/src/db/MediaMapper.d.ts +77 -0
- package/lib/typescript/src/db/MediaMapper.d.ts.map +1 -0
- package/lib/typescript/src/db/MediaRepository.d.ts +66 -0
- package/lib/typescript/src/db/MediaRepository.d.ts.map +1 -0
- package/lib/typescript/src/db/index.d.ts +23 -0
- package/lib/typescript/src/db/index.d.ts.map +1 -0
- package/lib/typescript/src/db/migrations.d.ts +31 -0
- package/lib/typescript/src/db/migrations.d.ts.map +1 -0
- package/lib/typescript/src/db/secureKey.d.ts +10 -0
- package/lib/typescript/src/db/secureKey.d.ts.map +1 -0
- package/lib/typescript/src/db/types.d.ts +115 -0
- package/lib/typescript/src/db/types.d.ts.map +1 -0
- package/lib/typescript/src/db/useMediaDatabase.d.ts +41 -0
- package/lib/typescript/src/db/useMediaDatabase.d.ts.map +1 -0
- package/lib/typescript/src/defaultIcons.d.ts +139 -0
- package/lib/typescript/src/defaultIcons.d.ts.map +1 -0
- package/lib/typescript/src/deviceCapabilities.d.ts +92 -0
- package/lib/typescript/src/deviceCapabilities.d.ts.map +1 -0
- package/lib/typescript/src/errors.d.ts +95 -0
- package/lib/typescript/src/errors.d.ts.map +1 -0
- package/lib/typescript/src/iconConfig.d.ts +176 -0
- package/lib/typescript/src/iconConfig.d.ts.map +1 -0
- package/lib/typescript/src/icons.d.ts +217 -0
- package/lib/typescript/src/icons.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +104 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/library/MediaLibrary.d.ts +57 -0
- package/lib/typescript/src/library/MediaLibrary.d.ts.map +1 -0
- package/lib/typescript/src/library/MediaLibraryScreen.d.ts +51 -0
- package/lib/typescript/src/library/MediaLibraryScreen.d.ts.map +1 -0
- package/lib/typescript/src/library/components/AudioPreview.d.ts +6 -0
- package/lib/typescript/src/library/components/AudioPreview.d.ts.map +1 -0
- package/lib/typescript/src/library/components/DocumentPreview.d.ts +10 -0
- package/lib/typescript/src/library/components/DocumentPreview.d.ts.map +1 -0
- package/lib/typescript/src/library/components/ExpandableFab.d.ts +39 -0
- package/lib/typescript/src/library/components/ExpandableFab.d.ts.map +1 -0
- package/lib/typescript/src/library/components/FileTiles.d.ts +8 -0
- package/lib/typescript/src/library/components/FileTiles.d.ts.map +1 -0
- package/lib/typescript/src/library/components/ImagePreview.d.ts +5 -0
- package/lib/typescript/src/library/components/ImagePreview.d.ts.map +1 -0
- package/lib/typescript/src/library/components/MediaMetadataHeader.d.ts +16 -0
- package/lib/typescript/src/library/components/MediaMetadataHeader.d.ts.map +1 -0
- package/lib/typescript/src/library/components/RecordAudioScreen.d.ts +8 -0
- package/lib/typescript/src/library/components/RecordAudioScreen.d.ts.map +1 -0
- package/lib/typescript/src/library/components/VideoPreview.d.ts +20 -0
- package/lib/typescript/src/library/components/VideoPreview.d.ts.map +1 -0
- package/lib/typescript/src/library/components/ViewerCounter.d.ts +13 -0
- package/lib/typescript/src/library/components/ViewerCounter.d.ts.map +1 -0
- package/lib/typescript/src/library/compressionEstimate.d.ts +313 -0
- package/lib/typescript/src/library/compressionEstimate.d.ts.map +1 -0
- package/lib/typescript/src/library/fileMetadata.d.ts +33 -0
- package/lib/typescript/src/library/fileMetadata.d.ts.map +1 -0
- package/lib/typescript/src/library/index.d.ts +40 -0
- package/lib/typescript/src/library/index.d.ts.map +1 -0
- package/lib/typescript/src/library/libraryIconRegistry.d.ts +35 -0
- package/lib/typescript/src/library/libraryIconRegistry.d.ts.map +1 -0
- package/lib/typescript/src/library/libraryIcons.d.ts +85 -0
- package/lib/typescript/src/library/libraryIcons.d.ts.map +1 -0
- package/lib/typescript/src/library/localizedFormat.d.ts +49 -0
- package/lib/typescript/src/library/localizedFormat.d.ts.map +1 -0
- package/lib/typescript/src/library/palette.d.ts +104 -0
- package/lib/typescript/src/library/palette.d.ts.map +1 -0
- package/lib/typescript/src/library/responsive.d.ts +15 -0
- package/lib/typescript/src/library/responsive.d.ts.map +1 -0
- package/lib/typescript/src/locales.d.ts +103 -0
- package/lib/typescript/src/locales.d.ts.map +1 -0
- package/lib/typescript/src/localization.d.ts +1051 -0
- package/lib/typescript/src/localization.d.ts.map +1 -0
- package/lib/typescript/src/logger.d.ts +4 -0
- package/lib/typescript/src/logger.d.ts.map +1 -0
- package/lib/typescript/src/lowMemoryCache.d.ts +64 -0
- package/lib/typescript/src/lowMemoryCache.d.ts.map +1 -0
- package/lib/typescript/src/mediaHistory.d.ts +3 -0
- package/lib/typescript/src/mediaHistory.d.ts.map +1 -0
- package/lib/typescript/src/mediaStorageService.d.ts +155 -0
- package/lib/typescript/src/mediaStorageService.d.ts.map +1 -0
- package/lib/typescript/src/memory.d.ts +21 -0
- package/lib/typescript/src/memory.d.ts.map +1 -0
- package/lib/typescript/src/nativeActions.d.ts +174 -0
- package/lib/typescript/src/nativeActions.d.ts.map +1 -0
- package/lib/typescript/src/nativeComponentSupport.d.ts +30 -0
- package/lib/typescript/src/nativeComponentSupport.d.ts.map +1 -0
- package/lib/typescript/src/networkPerformance.d.ts +12 -0
- package/lib/typescript/src/networkPerformance.d.ts.map +1 -0
- package/lib/typescript/src/performance.d.ts +32 -0
- package/lib/typescript/src/performance.d.ts.map +1 -0
- package/lib/typescript/src/performanceMonitor.d.ts +45 -0
- package/lib/typescript/src/performanceMonitor.d.ts.map +1 -0
- package/lib/typescript/src/permissions.d.ts +132 -0
- package/lib/typescript/src/permissions.d.ts.map +1 -0
- package/lib/typescript/src/rendering.d.ts +9 -0
- package/lib/typescript/src/rendering.d.ts.map +1 -0
- package/lib/typescript/src/security.d.ts +6 -0
- package/lib/typescript/src/security.d.ts.map +1 -0
- package/lib/typescript/src/state.d.ts +102 -0
- package/lib/typescript/src/state.d.ts.map +1 -0
- package/lib/typescript/src/storage.d.ts +117 -0
- package/lib/typescript/src/storage.d.ts.map +1 -0
- package/lib/typescript/src/theme.d.ts +15 -0
- package/lib/typescript/src/theme.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +802 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/lib/typescript/src/utils.d.ts +50 -0
- package/lib/typescript/src/utils.d.ts.map +1 -0
- package/lib/typescript/src/validation.d.ts +52 -0
- package/lib/typescript/src/validation.d.ts.map +1 -0
- package/package.json +204 -0
- package/react-native.config.js +17 -0
- package/src/AudioPlayerContext.tsx +220 -0
- package/src/CameraPreview.tsx +352 -0
- package/src/NativeAnimatedImageView.tsx +71 -0
- package/src/NativeAudioPlayerView.tsx +39 -0
- package/src/NativeBlurView.tsx +40 -0
- package/src/NativeCustomCamera.ts +305 -0
- package/src/NativeCustomCamera.web.ts +192 -0
- package/src/NativeCustomVideoView.ts +30 -0
- package/src/NativeDocumentPreviewView.tsx +196 -0
- package/src/NativeMediaThumbnailView.tsx +167 -0
- package/src/NativeSvgIcon.tsx +46 -0
- package/src/ResponsivePreviewContainer.tsx +227 -0
- package/src/accessibility.ts +80 -0
- package/src/config.ts +406 -0
- package/src/cpuOptimization.ts +365 -0
- package/src/db/DatabaseManager.ts +212 -0
- package/src/db/MediaMapper.ts +377 -0
- package/src/db/MediaRepository.ts +313 -0
- package/src/db/index.ts +73 -0
- package/src/db/migrations.ts +222 -0
- package/src/db/react-native-sqlcipher.d.ts +76 -0
- package/src/db/secureKey.ts +100 -0
- package/src/db/types.ts +123 -0
- package/src/db/useMediaDatabase.ts +191 -0
- package/src/defaultIcons.tsx +2390 -0
- package/src/deviceCapabilities.ts +438 -0
- package/src/errors.ts +350 -0
- package/src/iconConfig.tsx +962 -0
- package/src/icons.tsx +788 -0
- package/src/index.tsx +763 -0
- package/src/jest-globals.d.ts +9 -0
- package/src/library/MediaLibrary.tsx +141 -0
- package/src/library/MediaLibraryScreen.tsx +3003 -0
- package/src/library/components/AudioPreview.tsx +73 -0
- package/src/library/components/DocumentPreview.tsx +361 -0
- package/src/library/components/ExpandableFab.tsx +342 -0
- package/src/library/components/FileTiles.tsx +252 -0
- package/src/library/components/ImagePreview.tsx +72 -0
- package/src/library/components/MediaMetadataHeader.tsx +208 -0
- package/src/library/components/RecordAudioScreen.tsx +845 -0
- package/src/library/components/VideoPreview.tsx +478 -0
- package/src/library/components/ViewerCounter.tsx +71 -0
- package/src/library/compressionEstimate.ts +662 -0
- package/src/library/fileMetadata.ts +212 -0
- package/src/library/index.ts +66 -0
- package/src/library/libraryIconRegistry.tsx +86 -0
- package/src/library/libraryIcons.tsx +928 -0
- package/src/library/localizedFormat.ts +207 -0
- package/src/library/palette.ts +281 -0
- package/src/library/responsive.ts +49 -0
- package/src/locales.ts +381 -0
- package/src/localization.ts +1947 -0
- package/src/logger.ts +20 -0
- package/src/lowMemoryCache.ts +218 -0
- package/src/mediaHistory.ts +42 -0
- package/src/mediaStorageService.ts +546 -0
- package/src/memory.ts +102 -0
- package/src/nativeActions.ts +422 -0
- package/src/nativeComponentSupport.ts +60 -0
- package/src/networkPerformance.ts +30 -0
- package/src/performance.ts +137 -0
- package/src/performanceMonitor.ts +219 -0
- package/src/permissions.ts +403 -0
- package/src/rendering.ts +47 -0
- package/src/security.ts +19 -0
- package/src/state.ts +333 -0
- package/src/storage.ts +453 -0
- package/src/theme.tsx +467 -0
- package/src/types.ts +946 -0
- package/src/utils.ts +177 -0
- package/src/validation.ts +372 -0
package/src/storage.ts
ADDED
|
@@ -0,0 +1,453 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Media Storage Module - Bridges React Native with native media storage workflow
|
|
3
|
+
*
|
|
4
|
+
* Provides a complete API for managing media lifecycle:
|
|
5
|
+
* 1. Capture/select media -> stored in cache
|
|
6
|
+
* 2. User sends/publishes -> moved to documents
|
|
7
|
+
* 3. Persistent metadata tracking
|
|
8
|
+
* 4. Automatic cleanup and duplicate detection
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { NativeModules } from 'react-native';
|
|
12
|
+
import type {
|
|
13
|
+
StoredMediaMetadata,
|
|
14
|
+
MediaPublishResult,
|
|
15
|
+
CleanupResult,
|
|
16
|
+
StorageStats,
|
|
17
|
+
MediaStorageLocation,
|
|
18
|
+
} from './types';
|
|
19
|
+
|
|
20
|
+
const { CustomCamera } = NativeModules;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Media Storage Manager - High-level API for media storage operations
|
|
24
|
+
*/
|
|
25
|
+
class MediaStorageManager {
|
|
26
|
+
private initialized = false;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Initialize the media storage workflow
|
|
30
|
+
* Call this once when the app starts
|
|
31
|
+
*/
|
|
32
|
+
async initialize(): Promise<{ success: boolean; message?: string }> {
|
|
33
|
+
try {
|
|
34
|
+
if (this.initialized) {
|
|
35
|
+
return { success: true };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const result = await CustomCamera.initializeMediaStorage();
|
|
39
|
+
this.initialized = result.success;
|
|
40
|
+
return result;
|
|
41
|
+
} catch (error) {
|
|
42
|
+
console.error('[MediaStorage] Initialization failed', error);
|
|
43
|
+
throw new Error(`Failed to initialize media storage: ${error}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Publish media from cache to document directory
|
|
49
|
+
* Moves file if moveMode=true, copies if false
|
|
50
|
+
*/
|
|
51
|
+
async publishMedia(
|
|
52
|
+
mediaId: string,
|
|
53
|
+
options?: {
|
|
54
|
+
moveMode?: boolean; // true = move, false = copy (default: true)
|
|
55
|
+
}
|
|
56
|
+
): Promise<MediaPublishResult> {
|
|
57
|
+
try {
|
|
58
|
+
const moveMode = options?.moveMode ?? true;
|
|
59
|
+
const result = await CustomCamera.publishMedia(mediaId, moveMode);
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
success: result.success,
|
|
63
|
+
mediaId: result.mediaId,
|
|
64
|
+
sourceLocation: 'cache',
|
|
65
|
+
targetLocation: 'document',
|
|
66
|
+
sourceUri: '',
|
|
67
|
+
targetUri: result.targetUri,
|
|
68
|
+
fileHash: result.fileHash,
|
|
69
|
+
movedAt: Date.now(),
|
|
70
|
+
error: result.error
|
|
71
|
+
? { code: 'PUBLISH_ERROR', message: result.error }
|
|
72
|
+
: undefined,
|
|
73
|
+
};
|
|
74
|
+
} catch (error) {
|
|
75
|
+
console.error('[MediaStorage] Publish failed', error);
|
|
76
|
+
return {
|
|
77
|
+
success: false,
|
|
78
|
+
mediaId,
|
|
79
|
+
sourceLocation: 'cache',
|
|
80
|
+
targetLocation: 'document',
|
|
81
|
+
sourceUri: '',
|
|
82
|
+
movedAt: Date.now(),
|
|
83
|
+
error: {
|
|
84
|
+
code: 'PUBLISH_ERROR',
|
|
85
|
+
message: error instanceof Error ? error.message : 'Unknown error',
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Publish multiple media files in batch
|
|
93
|
+
*/
|
|
94
|
+
async publishBatch(
|
|
95
|
+
mediaIds: string[],
|
|
96
|
+
options?: {
|
|
97
|
+
moveMode?: boolean;
|
|
98
|
+
}
|
|
99
|
+
): Promise<{
|
|
100
|
+
totalCount: number;
|
|
101
|
+
successCount: number;
|
|
102
|
+
failureCount: number;
|
|
103
|
+
results: MediaPublishResult[];
|
|
104
|
+
}> {
|
|
105
|
+
try {
|
|
106
|
+
const moveMode = options?.moveMode ?? true;
|
|
107
|
+
const result = await CustomCamera.publishBatch(mediaIds, moveMode);
|
|
108
|
+
|
|
109
|
+
return {
|
|
110
|
+
totalCount: result.totalCount,
|
|
111
|
+
successCount: result.successCount,
|
|
112
|
+
failureCount: result.failureCount,
|
|
113
|
+
results: mediaIds.map((id) => ({
|
|
114
|
+
success: id in (result.results || {}),
|
|
115
|
+
mediaId: id,
|
|
116
|
+
sourceLocation: 'cache',
|
|
117
|
+
targetLocation: 'document',
|
|
118
|
+
sourceUri: '',
|
|
119
|
+
movedAt: Date.now(),
|
|
120
|
+
})),
|
|
121
|
+
};
|
|
122
|
+
} catch (error) {
|
|
123
|
+
console.error('[MediaStorage] Batch publish failed', error);
|
|
124
|
+
throw new Error(`Failed to publish batch: ${error}`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Get all cached media (not yet published)
|
|
130
|
+
*/
|
|
131
|
+
async getCachedMedia(): Promise<StoredMediaMetadata[]> {
|
|
132
|
+
try {
|
|
133
|
+
const result = await CustomCamera.getCachedMedia();
|
|
134
|
+
return result.map((item: any) => ({
|
|
135
|
+
id: item.id,
|
|
136
|
+
fileName: item.fileName,
|
|
137
|
+
uri: item.cachePath || '',
|
|
138
|
+
type: item.fileType === 'video' ? 'video' : 'photo',
|
|
139
|
+
size: item.fileSize,
|
|
140
|
+
width: item.width,
|
|
141
|
+
height: item.height,
|
|
142
|
+
duration: item.duration,
|
|
143
|
+
dateTaken: item.cacheCreatedAt,
|
|
144
|
+
storageLocation: 'cache' as MediaStorageLocation,
|
|
145
|
+
storageStatus: 'cached',
|
|
146
|
+
cacheCreatedAt: item.cacheCreatedAt,
|
|
147
|
+
cacheLastModified: item.cacheLastModified,
|
|
148
|
+
isEdited: false,
|
|
149
|
+
}));
|
|
150
|
+
} catch (error) {
|
|
151
|
+
console.error('[MediaStorage] Get cached media failed', error);
|
|
152
|
+
return [];
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Get all published media
|
|
158
|
+
*/
|
|
159
|
+
async getPublishedMedia(): Promise<StoredMediaMetadata[]> {
|
|
160
|
+
try {
|
|
161
|
+
const result = await CustomCamera.getPublishedMedia();
|
|
162
|
+
return result.map((item: any) => ({
|
|
163
|
+
id: item.id,
|
|
164
|
+
fileName: item.fileName,
|
|
165
|
+
uri: item.documentUri || '',
|
|
166
|
+
type: item.fileType === 'video' ? 'video' : 'photo',
|
|
167
|
+
size: item.fileSize,
|
|
168
|
+
width: item.width,
|
|
169
|
+
height: item.height,
|
|
170
|
+
duration: item.duration,
|
|
171
|
+
dateTaken: item.publishedAt,
|
|
172
|
+
documentUri: item.documentUri,
|
|
173
|
+
storageLocation: 'document' as MediaStorageLocation,
|
|
174
|
+
storageStatus: 'published',
|
|
175
|
+
cacheCreatedAt: item.cacheCreatedAt,
|
|
176
|
+
cacheLastModified: item.cacheLastModified,
|
|
177
|
+
publishedAt: item.publishedAt,
|
|
178
|
+
isEdited: false,
|
|
179
|
+
}));
|
|
180
|
+
} catch (error) {
|
|
181
|
+
console.error('[MediaStorage] Get published media failed', error);
|
|
182
|
+
return [];
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Get storage statistics
|
|
188
|
+
*/
|
|
189
|
+
async getStorageStats(): Promise<StorageStats> {
|
|
190
|
+
try {
|
|
191
|
+
const stats = await CustomCamera.getStorageStats();
|
|
192
|
+
return {
|
|
193
|
+
cacheUsedMB: stats.cacheUsedMB || 0,
|
|
194
|
+
documentUsedMB: stats.documentUsedMB || 0,
|
|
195
|
+
totalAvailableMB: stats.totalAvailableMB || 0,
|
|
196
|
+
cachedItemsCount: stats.cachedItemsCount || 0,
|
|
197
|
+
publishedItemsCount: stats.publishedItemsCount || 0,
|
|
198
|
+
duplicateItemsCount: stats.duplicateItemsCount || 0,
|
|
199
|
+
oldestCacheItemAge: stats.oldestCacheItemAge || 0,
|
|
200
|
+
newestCacheItemAge: stats.newestCacheItemAge || 0,
|
|
201
|
+
};
|
|
202
|
+
} catch (error) {
|
|
203
|
+
console.error('[MediaStorage] Get storage stats failed', error);
|
|
204
|
+
return {
|
|
205
|
+
cacheUsedMB: 0,
|
|
206
|
+
documentUsedMB: 0,
|
|
207
|
+
totalAvailableMB: 0,
|
|
208
|
+
cachedItemsCount: 0,
|
|
209
|
+
publishedItemsCount: 0,
|
|
210
|
+
duplicateItemsCount: 0,
|
|
211
|
+
oldestCacheItemAge: 0,
|
|
212
|
+
newestCacheItemAge: 0,
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Cleanup old cache files
|
|
219
|
+
*/
|
|
220
|
+
async cleanupOldCache(olderThanDays: number = 7): Promise<CleanupResult> {
|
|
221
|
+
try {
|
|
222
|
+
const result = await CustomCamera.cleanupOldCache(olderThanDays);
|
|
223
|
+
return {
|
|
224
|
+
success: result.success,
|
|
225
|
+
filesRemoved: result.filesRemoved,
|
|
226
|
+
spaceFreedMB: result.spaceFreedMB,
|
|
227
|
+
erroredFiles: [],
|
|
228
|
+
timestamp: Date.now(),
|
|
229
|
+
};
|
|
230
|
+
} catch (error) {
|
|
231
|
+
console.error('[MediaStorage] Cleanup failed', error);
|
|
232
|
+
return {
|
|
233
|
+
success: false,
|
|
234
|
+
filesRemoved: 0,
|
|
235
|
+
spaceFreedMB: 0,
|
|
236
|
+
erroredFiles: [],
|
|
237
|
+
timestamp: Date.now(),
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Delete a specific media
|
|
244
|
+
*/
|
|
245
|
+
async deleteMedia(mediaId: string): Promise<boolean> {
|
|
246
|
+
try {
|
|
247
|
+
return await CustomCamera.deleteStoredMedia(mediaId);
|
|
248
|
+
} catch (error) {
|
|
249
|
+
console.error('[MediaStorage] Delete media failed', error);
|
|
250
|
+
return false;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Get failed transfers that can be retried
|
|
256
|
+
*/
|
|
257
|
+
async getFailedTransfers(): Promise<
|
|
258
|
+
Array<{
|
|
259
|
+
mediaId: string;
|
|
260
|
+
error: string;
|
|
261
|
+
retryCount: number;
|
|
262
|
+
}>
|
|
263
|
+
> {
|
|
264
|
+
try {
|
|
265
|
+
const result = await CustomCamera.getFailedTransfers();
|
|
266
|
+
return result || [];
|
|
267
|
+
} catch (error) {
|
|
268
|
+
console.error('[MediaStorage] Get failed transfers failed', error);
|
|
269
|
+
return [];
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Retry failed transfers
|
|
275
|
+
*/
|
|
276
|
+
async retryFailedTransfers(): Promise<MediaPublishResult[]> {
|
|
277
|
+
try {
|
|
278
|
+
const result = await CustomCamera.retryFailedTransfers();
|
|
279
|
+
return result.map((item: any) => ({
|
|
280
|
+
success: item.success,
|
|
281
|
+
mediaId: item.mediaId,
|
|
282
|
+
sourceLocation: 'cache' as MediaStorageLocation,
|
|
283
|
+
targetLocation: 'document' as MediaStorageLocation,
|
|
284
|
+
sourceUri: '',
|
|
285
|
+
targetUri: item.targetUri,
|
|
286
|
+
movedAt: Date.now(),
|
|
287
|
+
error: item.error
|
|
288
|
+
? { code: 'RETRY_ERROR', message: item.error }
|
|
289
|
+
: undefined,
|
|
290
|
+
}));
|
|
291
|
+
} catch (error) {
|
|
292
|
+
console.error('[MediaStorage] Retry failed transfers failed', error);
|
|
293
|
+
return [];
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Get media cache size in MB
|
|
299
|
+
*/
|
|
300
|
+
async getCacheSizeMB(): Promise<number> {
|
|
301
|
+
try {
|
|
302
|
+
const stats = await this.getStorageStats();
|
|
303
|
+
return stats.cacheUsedMB;
|
|
304
|
+
} catch (error) {
|
|
305
|
+
console.error('[MediaStorage] Get cache size failed', error);
|
|
306
|
+
return 0;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Check if cache is almost full
|
|
312
|
+
*/
|
|
313
|
+
async isCacheAlmostFull(threshold: number = 80): Promise<boolean> {
|
|
314
|
+
try {
|
|
315
|
+
const stats = await this.getStorageStats();
|
|
316
|
+
const percentageUsed =
|
|
317
|
+
(stats.cacheUsedMB / (stats.cacheUsedMB + stats.totalAvailableMB)) *
|
|
318
|
+
100;
|
|
319
|
+
return percentageUsed > threshold;
|
|
320
|
+
} catch (error) {
|
|
321
|
+
console.error('[MediaStorage] Check cache full failed', error);
|
|
322
|
+
return false;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Request cleanup if cache exceeds threshold
|
|
328
|
+
*/
|
|
329
|
+
async requestCleanupIfNeeded(maxCacheMB: number = 400): Promise<boolean> {
|
|
330
|
+
try {
|
|
331
|
+
const cacheSize = await this.getCacheSizeMB();
|
|
332
|
+
if (cacheSize > maxCacheMB) {
|
|
333
|
+
const daysOld = Math.ceil((cacheSize - maxCacheMB) / 10);
|
|
334
|
+
const result = await this.cleanupOldCache(Math.max(1, daysOld));
|
|
335
|
+
return result.success;
|
|
336
|
+
}
|
|
337
|
+
return true;
|
|
338
|
+
} catch (error) {
|
|
339
|
+
console.error('[MediaStorage] Request cleanup failed', error);
|
|
340
|
+
return false;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Get a summary of storage status
|
|
346
|
+
*/
|
|
347
|
+
async getStorageSummary(): Promise<{
|
|
348
|
+
totalCached: number;
|
|
349
|
+
totalPublished: number;
|
|
350
|
+
cacheUsageMB: number;
|
|
351
|
+
cachePercentageFull: number;
|
|
352
|
+
needsCleanup: boolean;
|
|
353
|
+
duplicatesCount: number;
|
|
354
|
+
}> {
|
|
355
|
+
try {
|
|
356
|
+
const stats = await this.getStorageStats();
|
|
357
|
+
const percentageFull =
|
|
358
|
+
(stats.cacheUsedMB / (stats.cacheUsedMB + stats.totalAvailableMB)) *
|
|
359
|
+
100;
|
|
360
|
+
|
|
361
|
+
return {
|
|
362
|
+
totalCached: stats.cachedItemsCount,
|
|
363
|
+
totalPublished: stats.publishedItemsCount,
|
|
364
|
+
cacheUsageMB: Math.round(stats.cacheUsedMB),
|
|
365
|
+
cachePercentageFull: Math.round(percentageFull),
|
|
366
|
+
needsCleanup: percentageFull > 75,
|
|
367
|
+
duplicatesCount: stats.duplicateItemsCount,
|
|
368
|
+
};
|
|
369
|
+
} catch (error) {
|
|
370
|
+
console.error('[MediaStorage] Get storage summary failed', error);
|
|
371
|
+
return {
|
|
372
|
+
totalCached: 0,
|
|
373
|
+
totalPublished: 0,
|
|
374
|
+
cacheUsageMB: 0,
|
|
375
|
+
cachePercentageFull: 0,
|
|
376
|
+
needsCleanup: false,
|
|
377
|
+
duplicatesCount: 0,
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
// Singleton instance
|
|
384
|
+
let instance: MediaStorageManager | null = null;
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Get the media storage manager instance
|
|
388
|
+
*/
|
|
389
|
+
export function getMediaStorageManager(): MediaStorageManager {
|
|
390
|
+
if (!instance) {
|
|
391
|
+
instance = new MediaStorageManager();
|
|
392
|
+
}
|
|
393
|
+
return instance;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Quick access functions for common operations
|
|
398
|
+
*/
|
|
399
|
+
|
|
400
|
+
export async function initializeMediaStorage(): Promise<void> {
|
|
401
|
+
const manager = getMediaStorageManager();
|
|
402
|
+
const result = await manager.initialize();
|
|
403
|
+
if (!result.success) {
|
|
404
|
+
throw new Error(result.message || 'Failed to initialize media storage');
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
export async function publishCachedMedia(
|
|
409
|
+
mediaId: string,
|
|
410
|
+
moveMode = true
|
|
411
|
+
): Promise<MediaPublishResult> {
|
|
412
|
+
const manager = getMediaStorageManager();
|
|
413
|
+
const result = await manager.publishMedia(mediaId, { moveMode });
|
|
414
|
+
if (!result.success) {
|
|
415
|
+
throw new Error(result.error?.message || 'Failed to publish media');
|
|
416
|
+
}
|
|
417
|
+
return result;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
export async function getCacheInfo(): Promise<{
|
|
421
|
+
items: number;
|
|
422
|
+
sizeMB: number;
|
|
423
|
+
percentageFull: number;
|
|
424
|
+
}> {
|
|
425
|
+
const manager = getMediaStorageManager();
|
|
426
|
+
const [cached, stats] = await Promise.all([
|
|
427
|
+
manager.getCachedMedia(),
|
|
428
|
+
manager.getStorageStats(),
|
|
429
|
+
]);
|
|
430
|
+
|
|
431
|
+
const percentageFull =
|
|
432
|
+
(stats.cacheUsedMB / (stats.cacheUsedMB + stats.totalAvailableMB)) * 100;
|
|
433
|
+
|
|
434
|
+
return {
|
|
435
|
+
items: cached.length,
|
|
436
|
+
sizeMB: Math.round(stats.cacheUsedMB),
|
|
437
|
+
percentageFull: Math.round(percentageFull),
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
export async function cleanupExpiredCache(): Promise<{
|
|
442
|
+
filesRemoved: number;
|
|
443
|
+
spaceFreedMB: number;
|
|
444
|
+
}> {
|
|
445
|
+
const manager = getMediaStorageManager();
|
|
446
|
+
const result = await manager.cleanupOldCache(7);
|
|
447
|
+
return {
|
|
448
|
+
filesRemoved: result.filesRemoved,
|
|
449
|
+
spaceFreedMB: Math.round(result.spaceFreedMB),
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
export { MediaStorageManager };
|