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
|
@@ -0,0 +1,546 @@
|
|
|
1
|
+
import { Platform } from 'react-native';
|
|
2
|
+
import { getMediaStorageManager } from './storage';
|
|
3
|
+
import type { CameraAsset, StoredMediaMetadata } from './types';
|
|
4
|
+
import { validateSecureUri, validateFileContentType } from './security';
|
|
5
|
+
import { MemoryManager } from './memory';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Media Storage Service - Complete media lifecycle management
|
|
9
|
+
* Handles capture -> cache -> publish workflow with automatic cleanup
|
|
10
|
+
*/
|
|
11
|
+
export class MediaStorageService {
|
|
12
|
+
private storageManager = getMediaStorageManager();
|
|
13
|
+
private memoryManager = new MemoryManager();
|
|
14
|
+
private isInitialized = false;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Initialize the media storage service
|
|
18
|
+
*/
|
|
19
|
+
async initialize(): Promise<void> {
|
|
20
|
+
if (this.isInitialized) return;
|
|
21
|
+
|
|
22
|
+
try {
|
|
23
|
+
await this.storageManager.initialize();
|
|
24
|
+
this.isInitialized = true;
|
|
25
|
+
|
|
26
|
+
// Set up periodic cleanup for low-end devices
|
|
27
|
+
if (Platform.OS === 'android') {
|
|
28
|
+
this.setupPeriodicCleanup();
|
|
29
|
+
}
|
|
30
|
+
} catch (error) {
|
|
31
|
+
console.error('[MediaStorageService] Initialization failed:', error);
|
|
32
|
+
throw new Error(`Failed to initialize media storage service: ${error}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Set up periodic cleanup for Android devices
|
|
38
|
+
*/
|
|
39
|
+
private setupPeriodicCleanup(): void {
|
|
40
|
+
// This would be implemented with native modules for background tasks
|
|
41
|
+
// For now, we'll just log the setup
|
|
42
|
+
console.log('[MediaStorageService] Periodic cleanup scheduled for Android');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Handle media capture - automatically stores in cache
|
|
47
|
+
*/
|
|
48
|
+
async handleMediaCapture(
|
|
49
|
+
mediaAssets: CameraAsset[],
|
|
50
|
+
options: {
|
|
51
|
+
autoPublish?: boolean;
|
|
52
|
+
moveMode?: boolean;
|
|
53
|
+
cleanupThresholdMB?: number;
|
|
54
|
+
} = {}
|
|
55
|
+
): Promise<{
|
|
56
|
+
success: boolean;
|
|
57
|
+
cachedAssets: CameraAsset[];
|
|
58
|
+
publishedAssets?: CameraAsset[];
|
|
59
|
+
error?: string;
|
|
60
|
+
}> {
|
|
61
|
+
try {
|
|
62
|
+
if (!this.isInitialized) {
|
|
63
|
+
await this.initialize();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const {
|
|
67
|
+
autoPublish = false,
|
|
68
|
+
moveMode = true,
|
|
69
|
+
cleanupThresholdMB = 400,
|
|
70
|
+
} = options;
|
|
71
|
+
|
|
72
|
+
// Validate all media assets
|
|
73
|
+
const validatedAssets = await this.validateMediaAssets(mediaAssets);
|
|
74
|
+
if (validatedAssets.length === 0) {
|
|
75
|
+
return {
|
|
76
|
+
success: false,
|
|
77
|
+
cachedAssets: [],
|
|
78
|
+
error: 'No valid media assets',
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Add cache metadata to assets
|
|
83
|
+
const cachedAssets = validatedAssets.map((asset) => ({
|
|
84
|
+
...asset,
|
|
85
|
+
cachePath: asset.uri, // Initially stored in cache
|
|
86
|
+
isCached: true,
|
|
87
|
+
cacheCreatedAt: Date.now(),
|
|
88
|
+
cacheLastModified: Date.now(),
|
|
89
|
+
storageLocation: 'cache' as const,
|
|
90
|
+
storageStatus: 'cached' as const,
|
|
91
|
+
}));
|
|
92
|
+
|
|
93
|
+
// Check if auto-publish is requested
|
|
94
|
+
if (autoPublish) {
|
|
95
|
+
const publishResults = await this.publishCachedMedia(
|
|
96
|
+
cachedAssets.map((asset) => asset.id),
|
|
97
|
+
{ moveMode }
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
const publishedAssets = publishResults.results
|
|
101
|
+
.filter((r) => r.success)
|
|
102
|
+
.map((result) => {
|
|
103
|
+
const originalAsset = cachedAssets.find(
|
|
104
|
+
(a) => a.id === result.mediaId
|
|
105
|
+
);
|
|
106
|
+
return originalAsset
|
|
107
|
+
? {
|
|
108
|
+
...originalAsset,
|
|
109
|
+
uri: result.targetUri || originalAsset.uri,
|
|
110
|
+
storageLocation: 'document' as const,
|
|
111
|
+
storageStatus: 'published' as const,
|
|
112
|
+
documentUri: result.targetUri,
|
|
113
|
+
publishedAt: Date.now(),
|
|
114
|
+
}
|
|
115
|
+
: originalAsset;
|
|
116
|
+
})
|
|
117
|
+
.filter(Boolean) as CameraAsset[];
|
|
118
|
+
|
|
119
|
+
return {
|
|
120
|
+
success: true,
|
|
121
|
+
cachedAssets,
|
|
122
|
+
publishedAssets,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Check if cleanup is needed
|
|
127
|
+
await this.checkAndCleanupCache(cleanupThresholdMB);
|
|
128
|
+
|
|
129
|
+
return {
|
|
130
|
+
success: true,
|
|
131
|
+
cachedAssets,
|
|
132
|
+
};
|
|
133
|
+
} catch (error) {
|
|
134
|
+
console.error(
|
|
135
|
+
'[MediaStorageService] Media capture handling failed:',
|
|
136
|
+
error
|
|
137
|
+
);
|
|
138
|
+
return {
|
|
139
|
+
success: false,
|
|
140
|
+
cachedAssets: [],
|
|
141
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Validate media assets before processing
|
|
148
|
+
*/
|
|
149
|
+
private async validateMediaAssets(
|
|
150
|
+
assets: CameraAsset[]
|
|
151
|
+
): Promise<CameraAsset[]> {
|
|
152
|
+
const validated: CameraAsset[] = [];
|
|
153
|
+
|
|
154
|
+
for (const asset of assets) {
|
|
155
|
+
try {
|
|
156
|
+
// Validate URI format
|
|
157
|
+
if (!validateSecureUri(asset.uri)) {
|
|
158
|
+
console.warn(
|
|
159
|
+
`[MediaStorageService] Invalid URI for asset ${asset.id}`
|
|
160
|
+
);
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Validate file type based on extension
|
|
165
|
+
const isValidType = asset.type === 'photo' || asset.type === 'video';
|
|
166
|
+
if (!isValidType) {
|
|
167
|
+
console.warn(
|
|
168
|
+
`[MediaStorageService] Invalid media type for asset ${asset.id}`
|
|
169
|
+
);
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// Validate file content type if available
|
|
174
|
+
if (asset.mimeType && !validateFileContentType(asset.mimeType)) {
|
|
175
|
+
console.warn(
|
|
176
|
+
`[MediaStorageService] Invalid mime type for asset ${asset.id}`
|
|
177
|
+
);
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
validated.push(asset);
|
|
182
|
+
} catch (error) {
|
|
183
|
+
console.warn(
|
|
184
|
+
`[MediaStorageService] Validation failed for asset ${asset.id}:`,
|
|
185
|
+
error
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return validated;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Publish cached media to document directory
|
|
195
|
+
*/
|
|
196
|
+
async publishCachedMedia(
|
|
197
|
+
mediaIds: string[],
|
|
198
|
+
options: {
|
|
199
|
+
moveMode?: boolean;
|
|
200
|
+
retryFailed?: boolean;
|
|
201
|
+
} = {}
|
|
202
|
+
): Promise<{
|
|
203
|
+
success: boolean;
|
|
204
|
+
results: Array<{
|
|
205
|
+
mediaId: string;
|
|
206
|
+
success: boolean;
|
|
207
|
+
targetUri?: string;
|
|
208
|
+
error?: string;
|
|
209
|
+
}>;
|
|
210
|
+
totalCount: number;
|
|
211
|
+
successCount: number;
|
|
212
|
+
failureCount: number;
|
|
213
|
+
}> {
|
|
214
|
+
try {
|
|
215
|
+
const { moveMode = true, retryFailed = true } = options;
|
|
216
|
+
|
|
217
|
+
// First try to publish the media
|
|
218
|
+
const publishResult = await this.storageManager.publishBatch(mediaIds, {
|
|
219
|
+
moveMode,
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
// If there are failures and retry is enabled, try to retry
|
|
223
|
+
let finalResults = publishResult.results;
|
|
224
|
+
if (retryFailed && publishResult.failureCount > 0) {
|
|
225
|
+
const failedMediaIds = publishResult.results
|
|
226
|
+
.filter((r) => !r.success)
|
|
227
|
+
.map((r) => r.mediaId);
|
|
228
|
+
|
|
229
|
+
if (failedMediaIds.length > 0) {
|
|
230
|
+
const retryResults = await this.storageManager.retryFailedTransfers();
|
|
231
|
+
|
|
232
|
+
// Merge retry results with original results
|
|
233
|
+
finalResults = publishResult.results.map((originalResult) => {
|
|
234
|
+
const retryResult = retryResults.find(
|
|
235
|
+
(r) => r.mediaId === originalResult.mediaId
|
|
236
|
+
);
|
|
237
|
+
return retryResult || originalResult;
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
return {
|
|
243
|
+
success: publishResult.successCount > 0,
|
|
244
|
+
results: finalResults.map((result) => ({
|
|
245
|
+
mediaId: result.mediaId,
|
|
246
|
+
success: result.success,
|
|
247
|
+
targetUri: result.targetUri,
|
|
248
|
+
error: result.error?.message,
|
|
249
|
+
})),
|
|
250
|
+
totalCount: publishResult.totalCount,
|
|
251
|
+
successCount: publishResult.successCount,
|
|
252
|
+
failureCount: publishResult.failureCount,
|
|
253
|
+
};
|
|
254
|
+
} catch (error) {
|
|
255
|
+
console.error(
|
|
256
|
+
'[MediaStorageService] Publish cached media failed:',
|
|
257
|
+
error
|
|
258
|
+
);
|
|
259
|
+
return {
|
|
260
|
+
success: false,
|
|
261
|
+
results: mediaIds.map((mediaId) => ({
|
|
262
|
+
mediaId,
|
|
263
|
+
success: false,
|
|
264
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
265
|
+
})),
|
|
266
|
+
totalCount: mediaIds.length,
|
|
267
|
+
successCount: 0,
|
|
268
|
+
failureCount: mediaIds.length,
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Check cache size and cleanup if needed
|
|
275
|
+
*/
|
|
276
|
+
async checkAndCleanupCache(thresholdMB: number = 400): Promise<{
|
|
277
|
+
cleanupPerformed: boolean;
|
|
278
|
+
filesRemoved?: number;
|
|
279
|
+
spaceFreedMB?: number;
|
|
280
|
+
}> {
|
|
281
|
+
try {
|
|
282
|
+
const stats = await this.storageManager.getStorageStats();
|
|
283
|
+
|
|
284
|
+
if (stats.cacheUsedMB > thresholdMB) {
|
|
285
|
+
console.log(
|
|
286
|
+
`[MediaStorageService] Cache exceeds threshold (${stats.cacheUsedMB}MB > ${thresholdMB}MB), cleaning up...`
|
|
287
|
+
);
|
|
288
|
+
|
|
289
|
+
const cleanupResult = await this.storageManager.cleanupOldCache(3); // Clean files older than 3 days
|
|
290
|
+
|
|
291
|
+
return {
|
|
292
|
+
cleanupPerformed: true,
|
|
293
|
+
filesRemoved: cleanupResult.filesRemoved,
|
|
294
|
+
spaceFreedMB: cleanupResult.spaceFreedMB,
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
return { cleanupPerformed: false };
|
|
299
|
+
} catch (error) {
|
|
300
|
+
console.error('[MediaStorageService] Cache cleanup check failed:', error);
|
|
301
|
+
return { cleanupPerformed: false };
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Get all cached media with enhanced metadata
|
|
307
|
+
*/
|
|
308
|
+
async getCachedMedia(): Promise<CameraAsset[]> {
|
|
309
|
+
try {
|
|
310
|
+
const cachedMedia = await this.storageManager.getCachedMedia();
|
|
311
|
+
return cachedMedia.map((media) => this.enhanceMediaMetadata(media));
|
|
312
|
+
} catch (error) {
|
|
313
|
+
console.error('[MediaStorageService] Get cached media failed:', error);
|
|
314
|
+
return [];
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Get all published media with enhanced metadata
|
|
320
|
+
*/
|
|
321
|
+
async getPublishedMedia(): Promise<CameraAsset[]> {
|
|
322
|
+
try {
|
|
323
|
+
const publishedMedia = await this.storageManager.getPublishedMedia();
|
|
324
|
+
return publishedMedia.map((media) => this.enhanceMediaMetadata(media));
|
|
325
|
+
} catch (error) {
|
|
326
|
+
console.error('[MediaStorageService] Get published media failed:', error);
|
|
327
|
+
return [];
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Enhance media metadata with additional computed properties
|
|
333
|
+
*/
|
|
334
|
+
private enhanceMediaMetadata(media: StoredMediaMetadata): CameraAsset {
|
|
335
|
+
const enhanced: CameraAsset = {
|
|
336
|
+
...media,
|
|
337
|
+
// Add computed properties
|
|
338
|
+
needsThumbnail:
|
|
339
|
+
media.type === 'video' ||
|
|
340
|
+
(media.width !== undefined && media.width > 2000),
|
|
341
|
+
// Ensure all required properties are present
|
|
342
|
+
id: media.id,
|
|
343
|
+
uri: media.uri || media.cachePath || media.documentUri || '',
|
|
344
|
+
type: media.type || 'photo',
|
|
345
|
+
fileName:
|
|
346
|
+
media.fileName ||
|
|
347
|
+
`media_${media.id}.${media.type === 'video' ? 'mp4' : 'jpg'}`,
|
|
348
|
+
dateTaken: media.dateTaken || media.cacheCreatedAt || Date.now(),
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
return enhanced;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Delete media from storage
|
|
356
|
+
*/
|
|
357
|
+
async deleteMedia(mediaId: string): Promise<boolean> {
|
|
358
|
+
try {
|
|
359
|
+
return await this.storageManager.deleteMedia(mediaId);
|
|
360
|
+
} catch (error) {
|
|
361
|
+
console.error('[MediaStorageService] Delete media failed:', error);
|
|
362
|
+
return false;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Get comprehensive storage statistics
|
|
368
|
+
*/
|
|
369
|
+
async getStorageStatistics(): Promise<{
|
|
370
|
+
cacheUsage: {
|
|
371
|
+
count: number;
|
|
372
|
+
sizeMB: number;
|
|
373
|
+
percentageFull: number;
|
|
374
|
+
};
|
|
375
|
+
documentUsage: {
|
|
376
|
+
count: number;
|
|
377
|
+
sizeMB: number;
|
|
378
|
+
};
|
|
379
|
+
totalAvailableMB: number;
|
|
380
|
+
needsCleanup: boolean;
|
|
381
|
+
duplicatesCount: number;
|
|
382
|
+
}> {
|
|
383
|
+
try {
|
|
384
|
+
const stats = await this.storageManager.getStorageStats();
|
|
385
|
+
|
|
386
|
+
const percentageFull =
|
|
387
|
+
stats.cacheUsedMB > 0 && stats.totalAvailableMB > 0
|
|
388
|
+
? Math.round(
|
|
389
|
+
(stats.cacheUsedMB /
|
|
390
|
+
(stats.cacheUsedMB + stats.totalAvailableMB)) *
|
|
391
|
+
100
|
|
392
|
+
)
|
|
393
|
+
: 0;
|
|
394
|
+
|
|
395
|
+
return {
|
|
396
|
+
cacheUsage: {
|
|
397
|
+
count: stats.cachedItemsCount,
|
|
398
|
+
sizeMB: Math.round(stats.cacheUsedMB),
|
|
399
|
+
percentageFull,
|
|
400
|
+
},
|
|
401
|
+
documentUsage: {
|
|
402
|
+
count: stats.publishedItemsCount,
|
|
403
|
+
sizeMB: Math.round(stats.documentUsedMB),
|
|
404
|
+
},
|
|
405
|
+
totalAvailableMB: Math.round(stats.totalAvailableMB),
|
|
406
|
+
needsCleanup: percentageFull > 75,
|
|
407
|
+
duplicatesCount: stats.duplicateItemsCount,
|
|
408
|
+
};
|
|
409
|
+
} catch (error) {
|
|
410
|
+
console.error(
|
|
411
|
+
'[MediaStorageService] Get storage statistics failed:',
|
|
412
|
+
error
|
|
413
|
+
);
|
|
414
|
+
return {
|
|
415
|
+
cacheUsage: { count: 0, sizeMB: 0, percentageFull: 0 },
|
|
416
|
+
documentUsage: { count: 0, sizeMB: 0 },
|
|
417
|
+
totalAvailableMB: 0,
|
|
418
|
+
needsCleanup: false,
|
|
419
|
+
duplicatesCount: 0,
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* Get failed transfer operations that can be retried
|
|
426
|
+
*/
|
|
427
|
+
async getFailedTransfers(): Promise<
|
|
428
|
+
Array<{
|
|
429
|
+
mediaId: string;
|
|
430
|
+
error: string;
|
|
431
|
+
retryCount: number;
|
|
432
|
+
originalUri?: string;
|
|
433
|
+
}>
|
|
434
|
+
> {
|
|
435
|
+
try {
|
|
436
|
+
const failed = await this.storageManager.getFailedTransfers();
|
|
437
|
+
return failed.map((f) => ({
|
|
438
|
+
mediaId: f.mediaId,
|
|
439
|
+
error: f.error,
|
|
440
|
+
retryCount: f.retryCount,
|
|
441
|
+
}));
|
|
442
|
+
} catch (error) {
|
|
443
|
+
console.error(
|
|
444
|
+
'[MediaStorageService] Get failed transfers failed:',
|
|
445
|
+
error
|
|
446
|
+
);
|
|
447
|
+
return [];
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* Clean up the service - release resources
|
|
453
|
+
*/
|
|
454
|
+
cleanup(): void {
|
|
455
|
+
this.memoryManager.clear();
|
|
456
|
+
console.log('[MediaStorageService] Service cleaned up');
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
// Singleton instance
|
|
461
|
+
let serviceInstance: MediaStorageService | null = null;
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* Get the media storage service instance
|
|
465
|
+
*/
|
|
466
|
+
export function getMediaStorageService(): MediaStorageService {
|
|
467
|
+
if (!serviceInstance) {
|
|
468
|
+
serviceInstance = new MediaStorageService();
|
|
469
|
+
}
|
|
470
|
+
return serviceInstance;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* Quick access functions for common operations
|
|
475
|
+
*/
|
|
476
|
+
export async function initializeMediaStorageService(): Promise<void> {
|
|
477
|
+
const service = getMediaStorageService();
|
|
478
|
+
await service.initialize();
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
export async function handleCapturedMedia(
|
|
482
|
+
assets: CameraAsset[],
|
|
483
|
+
options?: {
|
|
484
|
+
autoPublish?: boolean;
|
|
485
|
+
moveMode?: boolean;
|
|
486
|
+
cleanupThresholdMB?: number;
|
|
487
|
+
}
|
|
488
|
+
): Promise<{
|
|
489
|
+
success: boolean;
|
|
490
|
+
cachedAssets: CameraAsset[];
|
|
491
|
+
publishedAssets?: CameraAsset[];
|
|
492
|
+
error?: string;
|
|
493
|
+
}> {
|
|
494
|
+
const service = getMediaStorageService();
|
|
495
|
+
return service.handleMediaCapture(assets, options);
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
export async function publishAllCachedMedia(options?: {
|
|
499
|
+
moveMode?: boolean;
|
|
500
|
+
retryFailed?: boolean;
|
|
501
|
+
}): Promise<{
|
|
502
|
+
success: boolean;
|
|
503
|
+
results: Array<{
|
|
504
|
+
mediaId: string;
|
|
505
|
+
success: boolean;
|
|
506
|
+
targetUri?: string;
|
|
507
|
+
error?: string;
|
|
508
|
+
}>;
|
|
509
|
+
totalCount: number;
|
|
510
|
+
successCount: number;
|
|
511
|
+
failureCount: number;
|
|
512
|
+
}> {
|
|
513
|
+
const service = getMediaStorageService();
|
|
514
|
+
const cachedMedia = await service.getCachedMedia();
|
|
515
|
+
const mediaIds = cachedMedia.map((media) => media.id);
|
|
516
|
+
|
|
517
|
+
if (mediaIds.length === 0) {
|
|
518
|
+
return {
|
|
519
|
+
success: false,
|
|
520
|
+
results: [],
|
|
521
|
+
totalCount: 0,
|
|
522
|
+
successCount: 0,
|
|
523
|
+
failureCount: 0,
|
|
524
|
+
};
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
return service.publishCachedMedia(mediaIds, options);
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
export async function getStorageSummary(): Promise<{
|
|
531
|
+
cacheUsage: {
|
|
532
|
+
count: number;
|
|
533
|
+
sizeMB: number;
|
|
534
|
+
percentageFull: number;
|
|
535
|
+
};
|
|
536
|
+
documentUsage: {
|
|
537
|
+
count: number;
|
|
538
|
+
sizeMB: number;
|
|
539
|
+
};
|
|
540
|
+
totalAvailableMB: number;
|
|
541
|
+
needsCleanup: boolean;
|
|
542
|
+
duplicatesCount: number;
|
|
543
|
+
}> {
|
|
544
|
+
const service = getMediaStorageService();
|
|
545
|
+
return service.getStorageStatistics();
|
|
546
|
+
}
|
package/src/memory.ts
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
export class MemoryManager {
|
|
2
|
+
private readonly store = new Map<string, unknown>();
|
|
3
|
+
private readonly maxSize: number;
|
|
4
|
+
private currentSize = 0;
|
|
5
|
+
|
|
6
|
+
constructor(maxSizeMB = 50) {
|
|
7
|
+
this.maxSize = maxSizeMB * 1024 * 1024; // Convert MB to bytes
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
set(key: string, value: unknown): void {
|
|
11
|
+
// Estimate size of the value
|
|
12
|
+
const size = this.estimateSize(value);
|
|
13
|
+
|
|
14
|
+
// Check if we need to evict items to make space
|
|
15
|
+
while (this.currentSize + size > this.maxSize && this.store.size > 0) {
|
|
16
|
+
const oldestKey = this.store.keys().next().value;
|
|
17
|
+
if (oldestKey === undefined) break;
|
|
18
|
+
const oldestValue = this.store.get(oldestKey);
|
|
19
|
+
if (oldestValue !== undefined) {
|
|
20
|
+
this.currentSize -= this.estimateSize(oldestValue);
|
|
21
|
+
this.store.delete(oldestKey);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
this.store.set(key, value);
|
|
26
|
+
this.currentSize += size;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
get(key: string): unknown | undefined {
|
|
30
|
+
const value = this.store.get(key);
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
delete(key: string): void {
|
|
35
|
+
const value = this.store.get(key);
|
|
36
|
+
if (value !== undefined) {
|
|
37
|
+
this.currentSize -= this.estimateSize(value);
|
|
38
|
+
}
|
|
39
|
+
this.store.delete(key);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
clear(): void {
|
|
43
|
+
this.store.clear();
|
|
44
|
+
this.currentSize = 0;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
get size(): number {
|
|
48
|
+
return this.currentSize;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
get capacity(): number {
|
|
52
|
+
return this.maxSize;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
get usageRatio(): number {
|
|
56
|
+
return this.currentSize / this.maxSize;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
private estimateSize(value: unknown): number {
|
|
60
|
+
if (value === null || value === undefined) return 0;
|
|
61
|
+
|
|
62
|
+
if (typeof value === 'string') return value.length * 2; // Approximate string size in bytes
|
|
63
|
+
if (typeof value === 'number') return 8; // Approximate number size
|
|
64
|
+
if (typeof value === 'boolean') return 4;
|
|
65
|
+
|
|
66
|
+
if (Array.isArray(value)) {
|
|
67
|
+
return value.reduce((sum, item) => sum + this.estimateSize(item), 0);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (typeof value === 'object') {
|
|
71
|
+
return Object.values(value).reduce(
|
|
72
|
+
(sum, item) => sum + this.estimateSize(item),
|
|
73
|
+
0
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return 100; // Default size for other types
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export class WeakCache<K extends object, V> {
|
|
82
|
+
private readonly store = new WeakMap<K, V>();
|
|
83
|
+
|
|
84
|
+
set(key: K, value: V): void {
|
|
85
|
+
this.store.set(key, value);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
get(key: K): V | undefined {
|
|
89
|
+
return this.store.get(key);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export async function processMediaInChunksMemory<T>(
|
|
94
|
+
items: T[],
|
|
95
|
+
batchSize = 10,
|
|
96
|
+
processor: (chunk: T[]) => Promise<void> | void
|
|
97
|
+
): Promise<void> {
|
|
98
|
+
for (let index = 0; index < items.length; index += batchSize) {
|
|
99
|
+
const chunk = items.slice(index, index + batchSize);
|
|
100
|
+
await processor(chunk);
|
|
101
|
+
}
|
|
102
|
+
}
|