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,266 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* State management utilities for camera operations
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { CameraError, ERROR_CODES, getUserFriendlyErrorMessage } from "./errors.js";
|
|
8
|
+
import { LocalizationManager } from "./localization.js";
|
|
9
|
+
import { devError } from "./logger.js";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Operation status types
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Operation result interface
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Create initial operation state
|
|
21
|
+
*/
|
|
22
|
+
export function createInitialOperationState() {
|
|
23
|
+
return {
|
|
24
|
+
status: 'idle',
|
|
25
|
+
timestamp: Date.now()
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Create loading state
|
|
31
|
+
*/
|
|
32
|
+
export function createLoadingState(progress) {
|
|
33
|
+
return {
|
|
34
|
+
status: 'loading',
|
|
35
|
+
progress: progress !== undefined ? Math.min(100, Math.max(0, progress)) : 0,
|
|
36
|
+
timestamp: Date.now()
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Create success state
|
|
42
|
+
*/
|
|
43
|
+
export function createSuccessState(data) {
|
|
44
|
+
return {
|
|
45
|
+
status: 'success',
|
|
46
|
+
data,
|
|
47
|
+
timestamp: Date.now()
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Create error state
|
|
53
|
+
*/
|
|
54
|
+
export function createErrorState(error) {
|
|
55
|
+
let cameraError;
|
|
56
|
+
if (error instanceof CameraError) {
|
|
57
|
+
cameraError = error;
|
|
58
|
+
} else if (error instanceof Error) {
|
|
59
|
+
cameraError = new CameraError(error.message, ERROR_CODES.UNKNOWN, {
|
|
60
|
+
originalError: error,
|
|
61
|
+
stack: error.stack
|
|
62
|
+
});
|
|
63
|
+
} else {
|
|
64
|
+
cameraError = new CameraError(String(error), ERROR_CODES.UNKNOWN);
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
status: 'error',
|
|
68
|
+
error: cameraError,
|
|
69
|
+
timestamp: Date.now()
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Create cancelled state
|
|
75
|
+
*/
|
|
76
|
+
export function createCancelledState() {
|
|
77
|
+
return {
|
|
78
|
+
status: 'cancelled',
|
|
79
|
+
timestamp: Date.now()
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Check if operation is in progress
|
|
85
|
+
*/
|
|
86
|
+
export function isOperationInProgress(result) {
|
|
87
|
+
return result.status === 'loading';
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Check if operation was successful
|
|
92
|
+
*/
|
|
93
|
+
export function isOperationSuccessful(result) {
|
|
94
|
+
return result.status === 'success' && result.data !== undefined;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Check if operation failed
|
|
99
|
+
*/
|
|
100
|
+
export function isOperationFailed(result) {
|
|
101
|
+
return result.status === 'error' && result.error !== undefined;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Check if operation was cancelled
|
|
106
|
+
*/
|
|
107
|
+
export function isOperationCancelled(result) {
|
|
108
|
+
return result.status === 'cancelled';
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Get user-friendly status message
|
|
113
|
+
*/
|
|
114
|
+
export function getStatusMessage(result) {
|
|
115
|
+
switch (result.status) {
|
|
116
|
+
case 'idle':
|
|
117
|
+
return LocalizationManager.getString('statusReady');
|
|
118
|
+
case 'loading':
|
|
119
|
+
return result.progress !== undefined ? LocalizationManager.getString('statusProcessingWithProgress', result.progress) : LocalizationManager.getString('statusProcessing');
|
|
120
|
+
case 'success':
|
|
121
|
+
return LocalizationManager.getString('statusSuccess');
|
|
122
|
+
case 'error':
|
|
123
|
+
return result.error ? getUserFriendlyErrorMessage(result.error) : LocalizationManager.getString('errorUnknown');
|
|
124
|
+
case 'cancelled':
|
|
125
|
+
return LocalizationManager.getString('errorOperationCancelled');
|
|
126
|
+
default:
|
|
127
|
+
return LocalizationManager.getString('statusUnknown');
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Operation queue management
|
|
133
|
+
*/
|
|
134
|
+
export class OperationQueue {
|
|
135
|
+
queue = [];
|
|
136
|
+
isProcessing = false;
|
|
137
|
+
maxConcurrent = 1;
|
|
138
|
+
generation = 0;
|
|
139
|
+
constructor(maxConcurrent = 1) {
|
|
140
|
+
this.maxConcurrent = Math.max(1, maxConcurrent);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Add operation to queue
|
|
145
|
+
*/
|
|
146
|
+
enqueue(operation) {
|
|
147
|
+
const generation = this.generation;
|
|
148
|
+
return new Promise((resolve, reject) => {
|
|
149
|
+
this.queue.push(async () => {
|
|
150
|
+
if (generation !== this.generation) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
try {
|
|
154
|
+
await operation();
|
|
155
|
+
resolve();
|
|
156
|
+
} catch (error) {
|
|
157
|
+
reject(error);
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
setTimeout(() => {
|
|
161
|
+
this.processQueue();
|
|
162
|
+
}, 0);
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Process queue
|
|
168
|
+
*/
|
|
169
|
+
async processQueue() {
|
|
170
|
+
if (this.isProcessing || this.queue.length === 0) return;
|
|
171
|
+
const generation = this.generation;
|
|
172
|
+
this.isProcessing = true;
|
|
173
|
+
|
|
174
|
+
// Process up to maxConcurrent operations
|
|
175
|
+
const operationsToProcess = this.queue.splice(0, this.maxConcurrent);
|
|
176
|
+
try {
|
|
177
|
+
await Promise.all(operationsToProcess.map(op => op()));
|
|
178
|
+
} catch (error) {
|
|
179
|
+
devError('Operation queue error:', error);
|
|
180
|
+
} finally {
|
|
181
|
+
if (generation !== this.generation) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
this.isProcessing = false;
|
|
185
|
+
// Process remaining queue
|
|
186
|
+
if (this.queue.length > 0) {
|
|
187
|
+
this.processQueue();
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Clear queue
|
|
194
|
+
*/
|
|
195
|
+
clear() {
|
|
196
|
+
this.generation += 1;
|
|
197
|
+
this.queue = [];
|
|
198
|
+
this.isProcessing = false;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Get queue size
|
|
203
|
+
*/
|
|
204
|
+
size() {
|
|
205
|
+
return this.queue.length;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Check if queue is processing
|
|
210
|
+
*/
|
|
211
|
+
isProcessingQueue() {
|
|
212
|
+
return this.isProcessing;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Batch operation helper
|
|
218
|
+
*/
|
|
219
|
+
export async function processInBatches(items, batchSize, processor, onProgress) {
|
|
220
|
+
const results = [];
|
|
221
|
+
const totalItems = items.length;
|
|
222
|
+
for (let i = 0; i < totalItems; i += batchSize) {
|
|
223
|
+
const batch = items.slice(i, i + batchSize);
|
|
224
|
+
const batchResults = await Promise.all(batch.map((item, batchIndex) => processor(item, i / batchSize, i + batchIndex)));
|
|
225
|
+
results.push(...batchResults);
|
|
226
|
+
if (onProgress) {
|
|
227
|
+
const progress = Math.min(100, Math.round((i + batch.length) / totalItems * 100));
|
|
228
|
+
onProgress(progress, i + batch.length, totalItems);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return results;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Retry operation with exponential backoff
|
|
236
|
+
*/
|
|
237
|
+
export async function retryWithBackoff(operation, maxRetries = 3, initialDelay = 100, backoffFactor = 2) {
|
|
238
|
+
let lastError;
|
|
239
|
+
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
240
|
+
try {
|
|
241
|
+
return await operation();
|
|
242
|
+
} catch (error) {
|
|
243
|
+
lastError = error;
|
|
244
|
+
if (attempt < maxRetries) {
|
|
245
|
+
const delay = initialDelay * Math.pow(backoffFactor, attempt - 1);
|
|
246
|
+
await new Promise(resolve => setTimeout(resolve, delay));
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
throw lastError;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Timeout wrapper for operations
|
|
255
|
+
*/
|
|
256
|
+
export function withTimeout(operation, timeoutMs, timeoutMessage = LocalizationManager.getString('operationTimedOut', 'Operation timed out')) {
|
|
257
|
+
return Promise.race([operation(), new Promise((_, reject) => setTimeout(() => {
|
|
258
|
+
reject(new CameraError(timeoutMessage, ERROR_CODES.OPERATION_FAILED, {
|
|
259
|
+
timeout: timeoutMs
|
|
260
|
+
}));
|
|
261
|
+
}, timeoutMs))]);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// Re-export error handling function
|
|
265
|
+
export { getUserFriendlyErrorMessage } from "./errors.js";
|
|
266
|
+
//# sourceMappingURL=state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["CameraError","ERROR_CODES","getUserFriendlyErrorMessage","LocalizationManager","devError","createInitialOperationState","status","timestamp","Date","now","createLoadingState","progress","undefined","Math","min","max","createSuccessState","data","createErrorState","error","cameraError","Error","message","UNKNOWN","originalError","stack","String","createCancelledState","isOperationInProgress","result","isOperationSuccessful","isOperationFailed","isOperationCancelled","getStatusMessage","getString","OperationQueue","queue","isProcessing","maxConcurrent","generation","constructor","enqueue","operation","Promise","resolve","reject","push","setTimeout","processQueue","length","operationsToProcess","splice","all","map","op","clear","size","isProcessingQueue","processInBatches","items","batchSize","processor","onProgress","results","totalItems","i","batch","slice","batchResults","item","batchIndex","round","retryWithBackoff","maxRetries","initialDelay","backoffFactor","lastError","attempt","delay","pow","withTimeout","timeoutMs","timeoutMessage","race","_","OPERATION_FAILED","timeout"],"sourceRoot":"..\\..\\src","sources":["state.ts"],"mappings":";;AAAA;AACA;AACA;;AAEA,SACEA,WAAW,EACXC,WAAW,EACXC,2BAA2B,QACtB,aAAU;AACjB,SAASC,mBAAmB,QAAQ,mBAAgB;AACpD,SAASC,QAAQ,QAAQ,aAAU;;AAEnC;AACA;AACA;;AAQA;AACA;AACA;;AASA;AACA;AACA;AACA,OAAO,SAASC,2BAA2BA,CAAA,EAA0B;EACnE,OAAO;IACLC,MAAM,EAAE,MAAM;IACdC,SAAS,EAAEC,IAAI,CAACC,GAAG,CAAC;EACtB,CAAC;AACH;;AAEA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAAIC,QAAiB,EAAsB;EAC3E,OAAO;IACLL,MAAM,EAAE,SAAS;IACjBK,QAAQ,EAAEA,QAAQ,KAAKC,SAAS,GAAGC,IAAI,CAACC,GAAG,CAAC,GAAG,EAAED,IAAI,CAACE,GAAG,CAAC,CAAC,EAAEJ,QAAQ,CAAC,CAAC,GAAG,CAAC;IAC3EJ,SAAS,EAAEC,IAAI,CAACC,GAAG,CAAC;EACtB,CAAC;AACH;;AAEA;AACA;AACA;AACA,OAAO,SAASO,kBAAkBA,CAAIC,IAAO,EAAsB;EACjE,OAAO;IACLX,MAAM,EAAE,SAAS;IACjBW,IAAI;IACJV,SAAS,EAAEC,IAAI,CAACC,GAAG,CAAC;EACtB,CAAC;AACH;;AAEA;AACA;AACA;AACA,OAAO,SAASS,gBAAgBA,CAC9BC,KAAmC,EACf;EACpB,IAAIC,WAAwB;EAE5B,IAAID,KAAK,YAAYnB,WAAW,EAAE;IAChCoB,WAAW,GAAGD,KAAK;EACrB,CAAC,MAAM,IAAIA,KAAK,YAAYE,KAAK,EAAE;IACjCD,WAAW,GAAG,IAAIpB,WAAW,CAACmB,KAAK,CAACG,OAAO,EAAErB,WAAW,CAACsB,OAAO,EAAE;MAChEC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;IAC1B,CAAC,CAAC,OAAOvB,KAAK,EAAE;MACdyD,SAAS,GAAGzD,KAAK;MAEjB,IAAI0D,OAAO,GAAGJ,UAAU,EAAE;QACxB,MAAMK,KAAK,GAAGJ,YAAY,GAAG7D,IAAI,CAACkE,GAAG,CAACJ,aAAa,EAAEE,OAAO,GAAG,CAAC,CAAC;QACjE,MAAM,IAAIlC,OAAO,CAAEC,OAAO,IAAKG,UAAU,CAACH,OAAO,EAAEkC,KAAK,CAAC,CAAC;MAC5D;IACF;EACF;EAEA,MAAMF,SAAS;AACjB;;AAEA;AACA;AACA;AACA,OAAO,SAASI,WAAWA,CACzBtC,SAA2B,EAC3BuC,SAAiB,EACjBC,cAAsB,GAAG/E,mBAAmB,CAAC+B,SAAS,CACpD,mBAAmB,EACnB,qBACF,CAAC,EACW;EACZ,OAAOS,OAAO,CAACwC,IAAI,CAAC,CAClBzC,SAAS,CAAC,CAAC,EACX,IAAIC,OAAO,CAAI,CAACyC,CAAC,EAAEvC,MAAM,KACvBE,UAAU,CAAC,MAAM;IACfF,MAAM,CACJ,IAAI7C,WAAW,CAACkF,cAAc,EAAEjF,WAAW,CAACoF,gBAAgB,EAAE;MAC5DC,OAAO,EAAEL;IACX,CAAC,CACH,CAAC;EACH,CAAC,EAAEA,SAAS,CACd,CAAC,CACF,CAAC;AACJ;;AAEA;AACA,SAAS/E,2BAA2B,QAAQ,aAAU","ignoreList":[]}
|
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Media Storage Module - Bridges React Native with native media storage workflow
|
|
5
|
+
*
|
|
6
|
+
* Provides a complete API for managing media lifecycle:
|
|
7
|
+
* 1. Capture/select media -> stored in cache
|
|
8
|
+
* 2. User sends/publishes -> moved to documents
|
|
9
|
+
* 3. Persistent metadata tracking
|
|
10
|
+
* 4. Automatic cleanup and duplicate detection
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { NativeModules } from 'react-native';
|
|
14
|
+
const {
|
|
15
|
+
CustomCamera
|
|
16
|
+
} = NativeModules;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Media Storage Manager - High-level API for media storage operations
|
|
20
|
+
*/
|
|
21
|
+
class MediaStorageManager {
|
|
22
|
+
initialized = false;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Initialize the media storage workflow
|
|
26
|
+
* Call this once when the app starts
|
|
27
|
+
*/
|
|
28
|
+
async initialize() {
|
|
29
|
+
try {
|
|
30
|
+
if (this.initialized) {
|
|
31
|
+
return {
|
|
32
|
+
success: true
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
const result = await CustomCamera.initializeMediaStorage();
|
|
36
|
+
this.initialized = result.success;
|
|
37
|
+
return result;
|
|
38
|
+
} catch (error) {
|
|
39
|
+
console.error('[MediaStorage] Initialization failed', error);
|
|
40
|
+
throw new Error(`Failed to initialize media storage: ${error}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Publish media from cache to document directory
|
|
46
|
+
* Moves file if moveMode=true, copies if false
|
|
47
|
+
*/
|
|
48
|
+
async publishMedia(mediaId, options) {
|
|
49
|
+
try {
|
|
50
|
+
const moveMode = options?.moveMode ?? true;
|
|
51
|
+
const result = await CustomCamera.publishMedia(mediaId, moveMode);
|
|
52
|
+
return {
|
|
53
|
+
success: result.success,
|
|
54
|
+
mediaId: result.mediaId,
|
|
55
|
+
sourceLocation: 'cache',
|
|
56
|
+
targetLocation: 'document',
|
|
57
|
+
sourceUri: '',
|
|
58
|
+
targetUri: result.targetUri,
|
|
59
|
+
fileHash: result.fileHash,
|
|
60
|
+
movedAt: Date.now(),
|
|
61
|
+
error: result.error ? {
|
|
62
|
+
code: 'PUBLISH_ERROR',
|
|
63
|
+
message: result.error
|
|
64
|
+
} : undefined
|
|
65
|
+
};
|
|
66
|
+
} catch (error) {
|
|
67
|
+
console.error('[MediaStorage] Publish failed', error);
|
|
68
|
+
return {
|
|
69
|
+
success: false,
|
|
70
|
+
mediaId,
|
|
71
|
+
sourceLocation: 'cache',
|
|
72
|
+
targetLocation: 'document',
|
|
73
|
+
sourceUri: '',
|
|
74
|
+
movedAt: Date.now(),
|
|
75
|
+
error: {
|
|
76
|
+
code: 'PUBLISH_ERROR',
|
|
77
|
+
message: error instanceof Error ? error.message : 'Unknown error'
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Publish multiple media files in batch
|
|
85
|
+
*/
|
|
86
|
+
async publishBatch(mediaIds, options) {
|
|
87
|
+
try {
|
|
88
|
+
const moveMode = options?.moveMode ?? true;
|
|
89
|
+
const result = await CustomCamera.publishBatch(mediaIds, moveMode);
|
|
90
|
+
return {
|
|
91
|
+
totalCount: result.totalCount,
|
|
92
|
+
successCount: result.successCount,
|
|
93
|
+
failureCount: result.failureCount,
|
|
94
|
+
results: mediaIds.map(id => ({
|
|
95
|
+
success: id in (result.results || {}),
|
|
96
|
+
mediaId: id,
|
|
97
|
+
sourceLocation: 'cache',
|
|
98
|
+
targetLocation: 'document',
|
|
99
|
+
sourceUri: '',
|
|
100
|
+
movedAt: Date.now()
|
|
101
|
+
}))
|
|
102
|
+
};
|
|
103
|
+
} catch (error) {
|
|
104
|
+
console.error('[MediaStorage] Batch publish failed', error);
|
|
105
|
+
throw new Error(`Failed to publish batch: ${error}`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Get all cached media (not yet published)
|
|
111
|
+
*/
|
|
112
|
+
async getCachedMedia() {
|
|
113
|
+
try {
|
|
114
|
+
const result = await CustomCamera.getCachedMedia();
|
|
115
|
+
return result.map(item => ({
|
|
116
|
+
id: item.id,
|
|
117
|
+
fileName: item.fileName,
|
|
118
|
+
uri: item.cachePath || '',
|
|
119
|
+
type: item.fileType === 'video' ? 'video' : 'photo',
|
|
120
|
+
size: item.fileSize,
|
|
121
|
+
width: item.width,
|
|
122
|
+
height: item.height,
|
|
123
|
+
duration: item.duration,
|
|
124
|
+
dateTaken: item.cacheCreatedAt,
|
|
125
|
+
storageLocation: 'cache',
|
|
126
|
+
storageStatus: 'cached',
|
|
127
|
+
cacheCreatedAt: item.cacheCreatedAt,
|
|
128
|
+
cacheLastModified: item.cacheLastModified,
|
|
129
|
+
isEdited: false
|
|
130
|
+
}));
|
|
131
|
+
} catch (error) {
|
|
132
|
+
console.error('[MediaStorage] Get cached media failed', error);
|
|
133
|
+
return [];
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Get all published media
|
|
139
|
+
*/
|
|
140
|
+
async getPublishedMedia() {
|
|
141
|
+
try {
|
|
142
|
+
const result = await CustomCamera.getPublishedMedia();
|
|
143
|
+
return result.map(item => ({
|
|
144
|
+
id: item.id,
|
|
145
|
+
fileName: item.fileName,
|
|
146
|
+
uri: item.documentUri || '',
|
|
147
|
+
type: item.fileType === 'video' ? 'video' : 'photo',
|
|
148
|
+
size: item.fileSize,
|
|
149
|
+
width: item.width,
|
|
150
|
+
height: item.height,
|
|
151
|
+
duration: item.duration,
|
|
152
|
+
dateTaken: item.publishedAt,
|
|
153
|
+
documentUri: item.documentUri,
|
|
154
|
+
storageLocation: 'document',
|
|
155
|
+
storageStatus: 'published',
|
|
156
|
+
cacheCreatedAt: item.cacheCreatedAt,
|
|
157
|
+
cacheLastModified: item.cacheLastModified,
|
|
158
|
+
publishedAt: item.publishedAt,
|
|
159
|
+
isEdited: false
|
|
160
|
+
}));
|
|
161
|
+
} catch (error) {
|
|
162
|
+
console.error('[MediaStorage] Get published media failed', error);
|
|
163
|
+
return [];
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Get storage statistics
|
|
169
|
+
*/
|
|
170
|
+
async getStorageStats() {
|
|
171
|
+
try {
|
|
172
|
+
const stats = await CustomCamera.getStorageStats();
|
|
173
|
+
return {
|
|
174
|
+
cacheUsedMB: stats.cacheUsedMB || 0,
|
|
175
|
+
documentUsedMB: stats.documentUsedMB || 0,
|
|
176
|
+
totalAvailableMB: stats.totalAvailableMB || 0,
|
|
177
|
+
cachedItemsCount: stats.cachedItemsCount || 0,
|
|
178
|
+
publishedItemsCount: stats.publishedItemsCount || 0,
|
|
179
|
+
duplicateItemsCount: stats.duplicateItemsCount || 0,
|
|
180
|
+
oldestCacheItemAge: stats.oldestCacheItemAge || 0,
|
|
181
|
+
newestCacheItemAge: stats.newestCacheItemAge || 0
|
|
182
|
+
};
|
|
183
|
+
} catch (error) {
|
|
184
|
+
console.error('[MediaStorage] Get storage stats failed', error);
|
|
185
|
+
return {
|
|
186
|
+
cacheUsedMB: 0,
|
|
187
|
+
documentUsedMB: 0,
|
|
188
|
+
totalAvailableMB: 0,
|
|
189
|
+
cachedItemsCount: 0,
|
|
190
|
+
publishedItemsCount: 0,
|
|
191
|
+
duplicateItemsCount: 0,
|
|
192
|
+
oldestCacheItemAge: 0,
|
|
193
|
+
newestCacheItemAge: 0
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Cleanup old cache files
|
|
200
|
+
*/
|
|
201
|
+
async cleanupOldCache(olderThanDays = 7) {
|
|
202
|
+
try {
|
|
203
|
+
const result = await CustomCamera.cleanupOldCache(olderThanDays);
|
|
204
|
+
return {
|
|
205
|
+
success: result.success,
|
|
206
|
+
filesRemoved: result.filesRemoved,
|
|
207
|
+
spaceFreedMB: result.spaceFreedMB,
|
|
208
|
+
erroredFiles: [],
|
|
209
|
+
timestamp: Date.now()
|
|
210
|
+
};
|
|
211
|
+
} catch (error) {
|
|
212
|
+
console.error('[MediaStorage] Cleanup failed', error);
|
|
213
|
+
return {
|
|
214
|
+
success: false,
|
|
215
|
+
filesRemoved: 0,
|
|
216
|
+
spaceFreedMB: 0,
|
|
217
|
+
erroredFiles: [],
|
|
218
|
+
timestamp: Date.now()
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Delete a specific media
|
|
225
|
+
*/
|
|
226
|
+
async deleteMedia(mediaId) {
|
|
227
|
+
try {
|
|
228
|
+
return await CustomCamera.deleteStoredMedia(mediaId);
|
|
229
|
+
} catch (error) {
|
|
230
|
+
console.error('[MediaStorage] Delete media failed', error);
|
|
231
|
+
return false;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Get failed transfers that can be retried
|
|
237
|
+
*/
|
|
238
|
+
async getFailedTransfers() {
|
|
239
|
+
try {
|
|
240
|
+
const result = await CustomCamera.getFailedTransfers();
|
|
241
|
+
return result || [];
|
|
242
|
+
} catch (error) {
|
|
243
|
+
console.error('[MediaStorage] Get failed transfers failed', error);
|
|
244
|
+
return [];
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Retry failed transfers
|
|
250
|
+
*/
|
|
251
|
+
async retryFailedTransfers() {
|
|
252
|
+
try {
|
|
253
|
+
const result = await CustomCamera.retryFailedTransfers();
|
|
254
|
+
return result.map(item => ({
|
|
255
|
+
success: item.success,
|
|
256
|
+
mediaId: item.mediaId,
|
|
257
|
+
sourceLocation: 'cache',
|
|
258
|
+
targetLocation: 'document',
|
|
259
|
+
sourceUri: '',
|
|
260
|
+
targetUri: item.targetUri,
|
|
261
|
+
movedAt: Date.now(),
|
|
262
|
+
error: item.error ? {
|
|
263
|
+
code: 'RETRY_ERROR',
|
|
264
|
+
message: item.error
|
|
265
|
+
} : undefined
|
|
266
|
+
}));
|
|
267
|
+
} catch (error) {
|
|
268
|
+
console.error('[MediaStorage] Retry failed transfers failed', error);
|
|
269
|
+
return [];
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Get media cache size in MB
|
|
275
|
+
*/
|
|
276
|
+
async getCacheSizeMB() {
|
|
277
|
+
try {
|
|
278
|
+
const stats = await this.getStorageStats();
|
|
279
|
+
return stats.cacheUsedMB;
|
|
280
|
+
} catch (error) {
|
|
281
|
+
console.error('[MediaStorage] Get cache size failed', error);
|
|
282
|
+
return 0;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Check if cache is almost full
|
|
288
|
+
*/
|
|
289
|
+
async isCacheAlmostFull(threshold = 80) {
|
|
290
|
+
try {
|
|
291
|
+
const stats = await this.getStorageStats();
|
|
292
|
+
const percentageUsed = stats.cacheUsedMB / (stats.cacheUsedMB + stats.totalAvailableMB) * 100;
|
|
293
|
+
return percentageUsed > threshold;
|
|
294
|
+
} catch (error) {
|
|
295
|
+
console.error('[MediaStorage] Check cache full failed', error);
|
|
296
|
+
return false;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Request cleanup if cache exceeds threshold
|
|
302
|
+
*/
|
|
303
|
+
async requestCleanupIfNeeded(maxCacheMB = 400) {
|
|
304
|
+
try {
|
|
305
|
+
const cacheSize = await this.getCacheSizeMB();
|
|
306
|
+
if (cacheSize > maxCacheMB) {
|
|
307
|
+
const daysOld = Math.ceil((cacheSize - maxCacheMB) / 10);
|
|
308
|
+
const result = await this.cleanupOldCache(Math.max(1, daysOld));
|
|
309
|
+
return result.success;
|
|
310
|
+
}
|
|
311
|
+
return true;
|
|
312
|
+
} catch (error) {
|
|
313
|
+
console.error('[MediaStorage] Request cleanup failed', error);
|
|
314
|
+
return false;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Get a summary of storage status
|
|
320
|
+
*/
|
|
321
|
+
async getStorageSummary() {
|
|
322
|
+
try {
|
|
323
|
+
const stats = await this.getStorageStats();
|
|
324
|
+
const percentageFull = stats.cacheUsedMB / (stats.cacheUsedMB + stats.totalAvailableMB) * 100;
|
|
325
|
+
return {
|
|
326
|
+
totalCached: stats.cachedItemsCount,
|
|
327
|
+
totalPublished: stats.publishedItemsCount,
|
|
328
|
+
cacheUsageMB: Math.round(stats.cacheUsedMB),
|
|
329
|
+
cachePercentageFull: Math.round(percentageFull),
|
|
330
|
+
needsCleanup: percentageFull > 75,
|
|
331
|
+
duplicatesCount: stats.duplicateItemsCount
|
|
332
|
+
};
|
|
333
|
+
} catch (error) {
|
|
334
|
+
console.error('[MediaStorage] Get storage summary failed', error);
|
|
335
|
+
return {
|
|
336
|
+
totalCached: 0,
|
|
337
|
+
totalPublished: 0,
|
|
338
|
+
cacheUsageMB: 0,
|
|
339
|
+
cachePercentageFull: 0,
|
|
340
|
+
needsCleanup: false,
|
|
341
|
+
duplicatesCount: 0
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
// Singleton instance
|
|
348
|
+
let instance = null;
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Get the media storage manager instance
|
|
352
|
+
*/
|
|
353
|
+
export function getMediaStorageManager() {
|
|
354
|
+
if (!instance) {
|
|
355
|
+
instance = new MediaStorageManager();
|
|
356
|
+
}
|
|
357
|
+
return instance;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Quick access functions for common operations
|
|
362
|
+
*/
|
|
363
|
+
|
|
364
|
+
export async function initializeMediaStorage() {
|
|
365
|
+
const manager = getMediaStorageManager();
|
|
366
|
+
const result = await manager.initialize();
|
|
367
|
+
if (!result.success) {
|
|
368
|
+
throw new Error(result.message || 'Failed to initialize media storage');
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
export async function publishCachedMedia(mediaId, moveMode = true) {
|
|
372
|
+
const manager = getMediaStorageManager();
|
|
373
|
+
const result = await manager.publishMedia(mediaId, {
|
|
374
|
+
moveMode
|
|
375
|
+
});
|
|
376
|
+
if (!result.success) {
|
|
377
|
+
throw new Error(result.error?.message || 'Failed to publish media');
|
|
378
|
+
}
|
|
379
|
+
return result;
|
|
380
|
+
}
|
|
381
|
+
export async function getCacheInfo() {
|
|
382
|
+
const manager = getMediaStorageManager();
|
|
383
|
+
const [cached, stats] = await Promise.all([manager.getCachedMedia(), manager.getStorageStats()]);
|
|
384
|
+
const percentageFull = stats.cacheUsedMB / (stats.cacheUsedMB + stats.totalAvailableMB) * 100;
|
|
385
|
+
return {
|
|
386
|
+
items: cached.length,
|
|
387
|
+
sizeMB: Math.round(stats.cacheUsedMB),
|
|
388
|
+
percentageFull: Math.round(percentageFull)
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
export async function cleanupExpiredCache() {
|
|
392
|
+
const manager = getMediaStorageManager();
|
|
393
|
+
const result = await manager.cleanupOldCache(7);
|
|
394
|
+
return {
|
|
395
|
+
filesRemoved: result.filesRemoved,
|
|
396
|
+
spaceFreedMB: Math.round(result.spaceFreedMB)
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
export { MediaStorageManager };
|
|
400
|
+
//# sourceMappingURL=storage.js.map
|