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.
Files changed (506) hide show
  1. package/CustomCamera.podspec +20 -0
  2. package/LICENSE +20 -0
  3. package/README.md +833 -0
  4. package/android/build.gradle +135 -0
  5. package/android/consumer-rules.pro +47 -0
  6. package/android/src/main/AndroidManifest.xml +72 -0
  7. package/android/src/main/java/android/print/PdfPrint.java +51 -0
  8. package/android/src/main/java/com/customcamera/AnimatedImageViewManager.kt +199 -0
  9. package/android/src/main/java/com/customcamera/AudioPlayerView.kt +322 -0
  10. package/android/src/main/java/com/customcamera/AudioRecorder.kt +506 -0
  11. package/android/src/main/java/com/customcamera/BarcodeScannerActivity.kt +361 -0
  12. package/android/src/main/java/com/customcamera/BlurBackgroundView.kt +199 -0
  13. package/android/src/main/java/com/customcamera/CacheCleanupManager.kt +386 -0
  14. package/android/src/main/java/com/customcamera/CameraAspectRatioMode.kt +77 -0
  15. package/android/src/main/java/com/customcamera/CameraAsset.kt +211 -0
  16. package/android/src/main/java/com/customcamera/CameraTheme.kt +479 -0
  17. package/android/src/main/java/com/customcamera/CompressionCacheStore.kt +504 -0
  18. package/android/src/main/java/com/customcamera/CompressionFileNameUtils.kt +7 -0
  19. package/android/src/main/java/com/customcamera/CompressionProfile.kt +195 -0
  20. package/android/src/main/java/com/customcamera/CustomCameraActivity.kt +7291 -0
  21. package/android/src/main/java/com/customcamera/CustomCameraFileProvider.kt +9 -0
  22. package/android/src/main/java/com/customcamera/CustomCameraModule.kt +2479 -0
  23. package/android/src/main/java/com/customcamera/CustomCameraPackage.kt +53 -0
  24. package/android/src/main/java/com/customcamera/DisplayUtils.kt +9 -0
  25. package/android/src/main/java/com/customcamera/DocumentPreviewView.kt +846 -0
  26. package/android/src/main/java/com/customcamera/DrawingView.kt +214 -0
  27. package/android/src/main/java/com/customcamera/EmojiPickerData.kt +228 -0
  28. package/android/src/main/java/com/customcamera/FilterStripAdapter.kt +158 -0
  29. package/android/src/main/java/com/customcamera/GifSupport.kt +215 -0
  30. package/android/src/main/java/com/customcamera/GlobalAudioPlayer.kt +320 -0
  31. package/android/src/main/java/com/customcamera/ImageExporter.kt +1394 -0
  32. package/android/src/main/java/com/customcamera/ImageFormatSupport.kt +163 -0
  33. package/android/src/main/java/com/customcamera/Localization.kt +206 -0
  34. package/android/src/main/java/com/customcamera/MediaAdapters.kt +758 -0
  35. package/android/src/main/java/com/customcamera/MediaCacheManager.kt +782 -0
  36. package/android/src/main/java/com/customcamera/MediaExportFormats.kt +201 -0
  37. package/android/src/main/java/com/customcamera/MediaFileIo.kt +310 -0
  38. package/android/src/main/java/com/customcamera/MediaMetadataStore.kt +494 -0
  39. package/android/src/main/java/com/customcamera/MediaPreviewEditor.kt +14865 -0
  40. package/android/src/main/java/com/customcamera/MediaPublisher.kt +423 -0
  41. package/android/src/main/java/com/customcamera/MediaStorageWorkflow.kt +722 -0
  42. package/android/src/main/java/com/customcamera/MediaStoreRepository.kt +378 -0
  43. package/android/src/main/java/com/customcamera/MediaThumbnailView.kt +286 -0
  44. package/android/src/main/java/com/customcamera/MediaUtils.kt +37 -0
  45. package/android/src/main/java/com/customcamera/NativeVideoViewManager.kt +845 -0
  46. package/android/src/main/java/com/customcamera/OfficeDocumentConverter.kt +2791 -0
  47. package/android/src/main/java/com/customcamera/PendingCaptureCrops.kt +88 -0
  48. package/android/src/main/java/com/customcamera/PowerPointPreview.kt +4077 -0
  49. package/android/src/main/java/com/customcamera/RecentPickerStore.kt +74 -0
  50. package/android/src/main/java/com/customcamera/SecureFileEraser.kt +411 -0
  51. package/android/src/main/java/com/customcamera/SecureKeyModule.kt +88 -0
  52. package/android/src/main/java/com/customcamera/SecureMediaDeleter.kt +493 -0
  53. package/android/src/main/java/com/customcamera/StickerPickerData.kt +107 -0
  54. package/android/src/main/java/com/customcamera/SvgDrawable.kt +175 -0
  55. package/android/src/main/java/com/customcamera/SvgIconViewManager.kt +77 -0
  56. package/android/src/main/java/com/customcamera/TextEntryController.kt +553 -0
  57. package/android/src/main/java/com/customcamera/ThumbnailLoader.kt +455 -0
  58. package/android/src/main/java/com/customcamera/UploadService.kt +909 -0
  59. package/android/src/main/java/com/customcamera/VideoEditUtils.kt +210 -0
  60. package/android/src/main/java/com/customcamera/VideoRotationTranscoder.kt +1992 -0
  61. package/android/src/main/java/com/customcamera/gif/AnimatedGifEncoder.kt +473 -0
  62. package/android/src/main/java/com/customcamera/gif/GifDecoder.kt +690 -0
  63. package/android/src/main/java/com/customcamera/gif/GifFramesDrawable.kt +160 -0
  64. package/android/src/main/java/com/customcamera/gif/GifHttp.kt +112 -0
  65. package/android/src/main/java/com/customcamera/gif/GifImageLoader.kt +186 -0
  66. package/android/src/main/java/com/customcamera/gif/GifModels.kt +74 -0
  67. package/android/src/main/java/com/customcamera/gif/GifProvider.kt +49 -0
  68. package/android/src/main/java/com/customcamera/gif/GifProviders.kt +27 -0
  69. package/android/src/main/java/com/customcamera/gif/GifRepository.kt +124 -0
  70. package/android/src/main/java/com/customcamera/gif/GifSafety.kt +33 -0
  71. package/android/src/main/java/com/customcamera/gif/GiphyGifProvider.kt +146 -0
  72. package/android/src/main/java/com/customcamera/gif/LZWEncoder.kt +258 -0
  73. package/android/src/main/java/com/customcamera/gif/NeuQuant.kt +435 -0
  74. package/android/src/main/java/com/customcamera/gif/TenorGifProvider.kt +147 -0
  75. package/android/src/main/res/drawable/bg_brush_selected.xml +5 -0
  76. package/android/src/main/res/drawable/bg_color_swatch.xml +5 -0
  77. package/android/src/main/res/drawable/bg_editor_toolbar.xml +6 -0
  78. package/android/src/main/res/drawable/bg_icon_circle.xml +5 -0
  79. package/android/src/main/res/drawable/bg_icon_circle_light.xml +5 -0
  80. package/android/src/main/res/drawable/bg_mode_tab_active.xml +6 -0
  81. package/android/src/main/res/drawable/bg_pill.xml +6 -0
  82. package/android/src/main/res/drawable/bg_recording_dot.xml +6 -0
  83. package/android/src/main/res/drawable/bg_selection_badge.xml +8 -0
  84. package/android/src/main/res/drawable/bg_send_button.xml +5 -0
  85. package/android/src/main/res/drawable/bg_shutter_inner.xml +5 -0
  86. package/android/src/main/res/drawable/bg_shutter_recording.xml +6 -0
  87. package/android/src/main/res/drawable/bg_shutter_ring.xml +8 -0
  88. package/android/src/main/res/drawable/bg_shutter_video_idle.xml +5 -0
  89. package/android/src/main/res/drawable/bg_thumbnail.xml +9 -0
  90. package/android/src/main/res/drawable/ic_aspect_ratio.xml +17 -0
  91. package/android/src/main/res/drawable/ic_audio.xml +10 -0
  92. package/android/src/main/res/drawable/ic_back.xml +10 -0
  93. package/android/src/main/res/drawable/ic_brush_medium.xml +12 -0
  94. package/android/src/main/res/drawable/ic_brush_thick.xml +12 -0
  95. package/android/src/main/res/drawable/ic_brush_thin.xml +12 -0
  96. package/android/src/main/res/drawable/ic_check.xml +17 -0
  97. package/android/src/main/res/drawable/ic_chevron_down.xml +10 -0
  98. package/android/src/main/res/drawable/ic_chevron_up.xml +13 -0
  99. package/android/src/main/res/drawable/ic_clear_drawing.xml +10 -0
  100. package/android/src/main/res/drawable/ic_close.xml +10 -0
  101. package/android/src/main/res/drawable/ic_cover.xml +9 -0
  102. package/android/src/main/res/drawable/ic_crop.xml +10 -0
  103. package/android/src/main/res/drawable/ic_delete.xml +9 -0
  104. package/android/src/main/res/drawable/ic_document.xml +10 -0
  105. package/android/src/main/res/drawable/ic_done.xml +10 -0
  106. package/android/src/main/res/drawable/ic_download.xml +10 -0
  107. package/android/src/main/res/drawable/ic_emoji.xml +10 -0
  108. package/android/src/main/res/drawable/ic_filter.xml +10 -0
  109. package/android/src/main/res/drawable/ic_flash_auto.xml +7 -0
  110. package/android/src/main/res/drawable/ic_flash_off.xml +23 -0
  111. package/android/src/main/res/drawable/ic_flash_on.xml +16 -0
  112. package/android/src/main/res/drawable/ic_flip.xml +15 -0
  113. package/android/src/main/res/drawable/ic_gallery.xml +10 -0
  114. package/android/src/main/res/drawable/ic_gif.xml +24 -0
  115. package/android/src/main/res/drawable/ic_lock.xml +19 -0
  116. package/android/src/main/res/drawable/ic_lock_open.xml +22 -0
  117. package/android/src/main/res/drawable/ic_marker.xml +10 -0
  118. package/android/src/main/res/drawable/ic_more_vert.xml +18 -0
  119. package/android/src/main/res/drawable/ic_overlay_close.xml +19 -0
  120. package/android/src/main/res/drawable/ic_overlay_resize.xml +18 -0
  121. package/android/src/main/res/drawable/ic_pause.xml +10 -0
  122. package/android/src/main/res/drawable/ic_photo_mode.xml +10 -0
  123. package/android/src/main/res/drawable/ic_play.xml +10 -0
  124. package/android/src/main/res/drawable/ic_redo.xml +10 -0
  125. package/android/src/main/res/drawable/ic_rotate.xml +9 -0
  126. package/android/src/main/res/drawable/ic_send.xml +10 -0
  127. package/android/src/main/res/drawable/ic_share.xml +10 -0
  128. package/android/src/main/res/drawable/ic_stat_upload.xml +10 -0
  129. package/android/src/main/res/drawable/ic_sticker.xml +24 -0
  130. package/android/src/main/res/drawable/ic_text.xml +10 -0
  131. package/android/src/main/res/drawable/ic_text_align_center.xml +11 -0
  132. package/android/src/main/res/drawable/ic_text_align_left.xml +11 -0
  133. package/android/src/main/res/drawable/ic_text_align_right.xml +11 -0
  134. package/android/src/main/res/drawable/ic_text_bg.xml +11 -0
  135. package/android/src/main/res/drawable/ic_trim.xml +23 -0
  136. package/android/src/main/res/drawable/ic_undo.xml +10 -0
  137. package/android/src/main/res/drawable/ic_video_mode.xml +10 -0
  138. package/android/src/main/res/drawable/ic_video_note.xml +13 -0
  139. package/android/src/main/res/drawable/ic_volume_off.xml +9 -0
  140. package/android/src/main/res/drawable/ic_volume_on.xml +9 -0
  141. package/android/src/main/res/drawable/sticker_heart.xml +9 -0
  142. package/android/src/main/res/drawable/sticker_smile.xml +9 -0
  143. package/android/src/main/res/drawable/sticker_star.xml +9 -0
  144. package/android/src/main/res/drawable/sticker_thumbsup.xml +9 -0
  145. package/android/src/main/res/values/colors.xml +34 -0
  146. package/android/src/main/res/values/ids.xml +15 -0
  147. package/android/src/main/res/values/strings.xml +15 -0
  148. package/android/src/main/res/values/styles.xml +20 -0
  149. package/android/src/main/res/xml/file_paths.xml +34 -0
  150. package/ios/CustomCamera.h +5 -0
  151. package/ios/CustomCamera.mm +214 -0
  152. package/lib/module/AudioPlayerContext.js +233 -0
  153. package/lib/module/AudioPlayerContext.js.map +1 -0
  154. package/lib/module/CameraPreview.js +304 -0
  155. package/lib/module/CameraPreview.js.map +1 -0
  156. package/lib/module/NativeAnimatedImageView.js +41 -0
  157. package/lib/module/NativeAnimatedImageView.js.map +1 -0
  158. package/lib/module/NativeAudioPlayerView.js +33 -0
  159. package/lib/module/NativeAudioPlayerView.js.map +1 -0
  160. package/lib/module/NativeBlurView.js +35 -0
  161. package/lib/module/NativeBlurView.js.map +1 -0
  162. package/lib/module/NativeCustomCamera.js +128 -0
  163. package/lib/module/NativeCustomCamera.js.map +1 -0
  164. package/lib/module/NativeCustomCamera.web.js +143 -0
  165. package/lib/module/NativeCustomCamera.web.js.map +1 -0
  166. package/lib/module/NativeCustomVideoView.js +5 -0
  167. package/lib/module/NativeCustomVideoView.js.map +1 -0
  168. package/lib/module/NativeDocumentPreviewView.js +156 -0
  169. package/lib/module/NativeDocumentPreviewView.js.map +1 -0
  170. package/lib/module/NativeMediaThumbnailView.js +110 -0
  171. package/lib/module/NativeMediaThumbnailView.js.map +1 -0
  172. package/lib/module/NativeSvgIcon.js +32 -0
  173. package/lib/module/NativeSvgIcon.js.map +1 -0
  174. package/lib/module/ResponsivePreviewContainer.js +171 -0
  175. package/lib/module/ResponsivePreviewContainer.js.map +1 -0
  176. package/lib/module/accessibility.js +61 -0
  177. package/lib/module/accessibility.js.map +1 -0
  178. package/lib/module/config.js +352 -0
  179. package/lib/module/config.js.map +1 -0
  180. package/lib/module/cpuOptimization.js +296 -0
  181. package/lib/module/cpuOptimization.js.map +1 -0
  182. package/lib/module/db/DatabaseManager.js +191 -0
  183. package/lib/module/db/DatabaseManager.js.map +1 -0
  184. package/lib/module/db/MediaMapper.js +284 -0
  185. package/lib/module/db/MediaMapper.js.map +1 -0
  186. package/lib/module/db/MediaRepository.js +242 -0
  187. package/lib/module/db/MediaRepository.js.map +1 -0
  188. package/lib/module/db/index.js +41 -0
  189. package/lib/module/db/index.js.map +1 -0
  190. package/lib/module/db/migrations.js +180 -0
  191. package/lib/module/db/migrations.js.map +1 -0
  192. package/lib/module/db/react-native-sqlcipher.d.js +2 -0
  193. package/lib/module/db/react-native-sqlcipher.d.js.map +1 -0
  194. package/lib/module/db/secureKey.js +87 -0
  195. package/lib/module/db/secureKey.js.map +1 -0
  196. package/lib/module/db/types.js +57 -0
  197. package/lib/module/db/types.js.map +1 -0
  198. package/lib/module/db/useMediaDatabase.js +123 -0
  199. package/lib/module/db/useMediaDatabase.js.map +1 -0
  200. package/lib/module/defaultIcons.js +2259 -0
  201. package/lib/module/defaultIcons.js.map +1 -0
  202. package/lib/module/deviceCapabilities.js +408 -0
  203. package/lib/module/deviceCapabilities.js.map +1 -0
  204. package/lib/module/errors.js +267 -0
  205. package/lib/module/errors.js.map +1 -0
  206. package/lib/module/iconConfig.js +796 -0
  207. package/lib/module/iconConfig.js.map +1 -0
  208. package/lib/module/icons.js +514 -0
  209. package/lib/module/icons.js.map +1 -0
  210. package/lib/module/index.js +251 -0
  211. package/lib/module/index.js.map +1 -0
  212. package/lib/module/jest-globals.d.js +2 -0
  213. package/lib/module/jest-globals.d.js.map +1 -0
  214. package/lib/module/library/MediaLibrary.js +107 -0
  215. package/lib/module/library/MediaLibrary.js.map +1 -0
  216. package/lib/module/library/MediaLibraryScreen.js +2597 -0
  217. package/lib/module/library/MediaLibraryScreen.js.map +1 -0
  218. package/lib/module/library/components/AudioPreview.js +74 -0
  219. package/lib/module/library/components/AudioPreview.js.map +1 -0
  220. package/lib/module/library/components/DocumentPreview.js +331 -0
  221. package/lib/module/library/components/DocumentPreview.js.map +1 -0
  222. package/lib/module/library/components/ExpandableFab.js +343 -0
  223. package/lib/module/library/components/ExpandableFab.js.map +1 -0
  224. package/lib/module/library/components/FileTiles.js +251 -0
  225. package/lib/module/library/components/FileTiles.js.map +1 -0
  226. package/lib/module/library/components/ImagePreview.js +70 -0
  227. package/lib/module/library/components/ImagePreview.js.map +1 -0
  228. package/lib/module/library/components/MediaMetadataHeader.js +175 -0
  229. package/lib/module/library/components/MediaMetadataHeader.js.map +1 -0
  230. package/lib/module/library/components/RecordAudioScreen.js +816 -0
  231. package/lib/module/library/components/RecordAudioScreen.js.map +1 -0
  232. package/lib/module/library/components/VideoPreview.js +453 -0
  233. package/lib/module/library/components/VideoPreview.js.map +1 -0
  234. package/lib/module/library/components/ViewerCounter.js +55 -0
  235. package/lib/module/library/components/ViewerCounter.js.map +1 -0
  236. package/lib/module/library/compressionEstimate.js +507 -0
  237. package/lib/module/library/compressionEstimate.js.map +1 -0
  238. package/lib/module/library/fileMetadata.js +196 -0
  239. package/lib/module/library/fileMetadata.js.map +1 -0
  240. package/lib/module/library/index.js +42 -0
  241. package/lib/module/library/index.js.map +1 -0
  242. package/lib/module/library/libraryIconRegistry.js +69 -0
  243. package/lib/module/library/libraryIconRegistry.js.map +1 -0
  244. package/lib/module/library/libraryIcons.js +858 -0
  245. package/lib/module/library/libraryIcons.js.map +1 -0
  246. package/lib/module/library/localizedFormat.js +181 -0
  247. package/lib/module/library/localizedFormat.js.map +1 -0
  248. package/lib/module/library/palette.js +225 -0
  249. package/lib/module/library/palette.js.map +1 -0
  250. package/lib/module/library/responsive.js +53 -0
  251. package/lib/module/library/responsive.js.map +1 -0
  252. package/lib/module/locales.js +416 -0
  253. package/lib/module/locales.js.map +1 -0
  254. package/lib/module/localization.js +1064 -0
  255. package/lib/module/localization.js.map +1 -0
  256. package/lib/module/logger.js +20 -0
  257. package/lib/module/logger.js.map +1 -0
  258. package/lib/module/lowMemoryCache.js +206 -0
  259. package/lib/module/lowMemoryCache.js.map +1 -0
  260. package/lib/module/mediaHistory.js +33 -0
  261. package/lib/module/mediaHistory.js.map +1 -0
  262. package/lib/module/mediaStorageService.js +402 -0
  263. package/lib/module/mediaStorageService.js.map +1 -0
  264. package/lib/module/memory.js +79 -0
  265. package/lib/module/memory.js.map +1 -0
  266. package/lib/module/nativeActions.js +307 -0
  267. package/lib/module/nativeActions.js.map +1 -0
  268. package/lib/module/nativeComponentSupport.js +61 -0
  269. package/lib/module/nativeComponentSupport.js.map +1 -0
  270. package/lib/module/networkPerformance.js +24 -0
  271. package/lib/module/networkPerformance.js.map +1 -0
  272. package/lib/module/package.json +1 -0
  273. package/lib/module/performance.js +104 -0
  274. package/lib/module/performance.js.map +1 -0
  275. package/lib/module/performanceMonitor.js +155 -0
  276. package/lib/module/performanceMonitor.js.map +1 -0
  277. package/lib/module/permissions.js +370 -0
  278. package/lib/module/permissions.js.map +1 -0
  279. package/lib/module/rendering.js +40 -0
  280. package/lib/module/rendering.js.map +1 -0
  281. package/lib/module/security.js +18 -0
  282. package/lib/module/security.js.map +1 -0
  283. package/lib/module/state.js +266 -0
  284. package/lib/module/state.js.map +1 -0
  285. package/lib/module/storage.js +400 -0
  286. package/lib/module/storage.js.map +1 -0
  287. package/lib/module/theme.js +390 -0
  288. package/lib/module/theme.js.map +1 -0
  289. package/lib/module/types.js +4 -0
  290. package/lib/module/types.js.map +1 -0
  291. package/lib/module/utils.js +115 -0
  292. package/lib/module/utils.js.map +1 -0
  293. package/lib/module/validation.js +288 -0
  294. package/lib/module/validation.js.map +1 -0
  295. package/lib/typescript/package.json +1 -0
  296. package/lib/typescript/src/AudioPlayerContext.d.ts +27 -0
  297. package/lib/typescript/src/AudioPlayerContext.d.ts.map +1 -0
  298. package/lib/typescript/src/CameraPreview.d.ts +13 -0
  299. package/lib/typescript/src/CameraPreview.d.ts.map +1 -0
  300. package/lib/typescript/src/NativeAnimatedImageView.d.ts +33 -0
  301. package/lib/typescript/src/NativeAnimatedImageView.d.ts.map +1 -0
  302. package/lib/typescript/src/NativeAudioPlayerView.d.ts +12 -0
  303. package/lib/typescript/src/NativeAudioPlayerView.d.ts.map +1 -0
  304. package/lib/typescript/src/NativeBlurView.d.ts +12 -0
  305. package/lib/typescript/src/NativeBlurView.d.ts.map +1 -0
  306. package/lib/typescript/src/NativeCustomCamera.d.ts +167 -0
  307. package/lib/typescript/src/NativeCustomCamera.d.ts.map +1 -0
  308. package/lib/typescript/src/NativeCustomCamera.web.d.ts +47 -0
  309. package/lib/typescript/src/NativeCustomCamera.web.d.ts.map +1 -0
  310. package/lib/typescript/src/NativeCustomVideoView.d.ts +30 -0
  311. package/lib/typescript/src/NativeCustomVideoView.d.ts.map +1 -0
  312. package/lib/typescript/src/NativeDocumentPreviewView.d.ts +48 -0
  313. package/lib/typescript/src/NativeDocumentPreviewView.d.ts.map +1 -0
  314. package/lib/typescript/src/NativeMediaThumbnailView.d.ts +54 -0
  315. package/lib/typescript/src/NativeMediaThumbnailView.d.ts.map +1 -0
  316. package/lib/typescript/src/NativeSvgIcon.d.ts +25 -0
  317. package/lib/typescript/src/NativeSvgIcon.d.ts.map +1 -0
  318. package/lib/typescript/src/ResponsivePreviewContainer.d.ts +92 -0
  319. package/lib/typescript/src/ResponsivePreviewContainer.d.ts.map +1 -0
  320. package/lib/typescript/src/accessibility.d.ts +20 -0
  321. package/lib/typescript/src/accessibility.d.ts.map +1 -0
  322. package/lib/typescript/src/config.d.ts +145 -0
  323. package/lib/typescript/src/config.d.ts.map +1 -0
  324. package/lib/typescript/src/cpuOptimization.d.ts +63 -0
  325. package/lib/typescript/src/cpuOptimization.d.ts.map +1 -0
  326. package/lib/typescript/src/db/DatabaseManager.d.ts +48 -0
  327. package/lib/typescript/src/db/DatabaseManager.d.ts.map +1 -0
  328. package/lib/typescript/src/db/MediaMapper.d.ts +77 -0
  329. package/lib/typescript/src/db/MediaMapper.d.ts.map +1 -0
  330. package/lib/typescript/src/db/MediaRepository.d.ts +66 -0
  331. package/lib/typescript/src/db/MediaRepository.d.ts.map +1 -0
  332. package/lib/typescript/src/db/index.d.ts +23 -0
  333. package/lib/typescript/src/db/index.d.ts.map +1 -0
  334. package/lib/typescript/src/db/migrations.d.ts +31 -0
  335. package/lib/typescript/src/db/migrations.d.ts.map +1 -0
  336. package/lib/typescript/src/db/secureKey.d.ts +10 -0
  337. package/lib/typescript/src/db/secureKey.d.ts.map +1 -0
  338. package/lib/typescript/src/db/types.d.ts +115 -0
  339. package/lib/typescript/src/db/types.d.ts.map +1 -0
  340. package/lib/typescript/src/db/useMediaDatabase.d.ts +41 -0
  341. package/lib/typescript/src/db/useMediaDatabase.d.ts.map +1 -0
  342. package/lib/typescript/src/defaultIcons.d.ts +139 -0
  343. package/lib/typescript/src/defaultIcons.d.ts.map +1 -0
  344. package/lib/typescript/src/deviceCapabilities.d.ts +92 -0
  345. package/lib/typescript/src/deviceCapabilities.d.ts.map +1 -0
  346. package/lib/typescript/src/errors.d.ts +95 -0
  347. package/lib/typescript/src/errors.d.ts.map +1 -0
  348. package/lib/typescript/src/iconConfig.d.ts +176 -0
  349. package/lib/typescript/src/iconConfig.d.ts.map +1 -0
  350. package/lib/typescript/src/icons.d.ts +217 -0
  351. package/lib/typescript/src/icons.d.ts.map +1 -0
  352. package/lib/typescript/src/index.d.ts +104 -0
  353. package/lib/typescript/src/index.d.ts.map +1 -0
  354. package/lib/typescript/src/library/MediaLibrary.d.ts +57 -0
  355. package/lib/typescript/src/library/MediaLibrary.d.ts.map +1 -0
  356. package/lib/typescript/src/library/MediaLibraryScreen.d.ts +51 -0
  357. package/lib/typescript/src/library/MediaLibraryScreen.d.ts.map +1 -0
  358. package/lib/typescript/src/library/components/AudioPreview.d.ts +6 -0
  359. package/lib/typescript/src/library/components/AudioPreview.d.ts.map +1 -0
  360. package/lib/typescript/src/library/components/DocumentPreview.d.ts +10 -0
  361. package/lib/typescript/src/library/components/DocumentPreview.d.ts.map +1 -0
  362. package/lib/typescript/src/library/components/ExpandableFab.d.ts +39 -0
  363. package/lib/typescript/src/library/components/ExpandableFab.d.ts.map +1 -0
  364. package/lib/typescript/src/library/components/FileTiles.d.ts +8 -0
  365. package/lib/typescript/src/library/components/FileTiles.d.ts.map +1 -0
  366. package/lib/typescript/src/library/components/ImagePreview.d.ts +5 -0
  367. package/lib/typescript/src/library/components/ImagePreview.d.ts.map +1 -0
  368. package/lib/typescript/src/library/components/MediaMetadataHeader.d.ts +16 -0
  369. package/lib/typescript/src/library/components/MediaMetadataHeader.d.ts.map +1 -0
  370. package/lib/typescript/src/library/components/RecordAudioScreen.d.ts +8 -0
  371. package/lib/typescript/src/library/components/RecordAudioScreen.d.ts.map +1 -0
  372. package/lib/typescript/src/library/components/VideoPreview.d.ts +20 -0
  373. package/lib/typescript/src/library/components/VideoPreview.d.ts.map +1 -0
  374. package/lib/typescript/src/library/components/ViewerCounter.d.ts +13 -0
  375. package/lib/typescript/src/library/components/ViewerCounter.d.ts.map +1 -0
  376. package/lib/typescript/src/library/compressionEstimate.d.ts +313 -0
  377. package/lib/typescript/src/library/compressionEstimate.d.ts.map +1 -0
  378. package/lib/typescript/src/library/fileMetadata.d.ts +33 -0
  379. package/lib/typescript/src/library/fileMetadata.d.ts.map +1 -0
  380. package/lib/typescript/src/library/index.d.ts +40 -0
  381. package/lib/typescript/src/library/index.d.ts.map +1 -0
  382. package/lib/typescript/src/library/libraryIconRegistry.d.ts +35 -0
  383. package/lib/typescript/src/library/libraryIconRegistry.d.ts.map +1 -0
  384. package/lib/typescript/src/library/libraryIcons.d.ts +85 -0
  385. package/lib/typescript/src/library/libraryIcons.d.ts.map +1 -0
  386. package/lib/typescript/src/library/localizedFormat.d.ts +49 -0
  387. package/lib/typescript/src/library/localizedFormat.d.ts.map +1 -0
  388. package/lib/typescript/src/library/palette.d.ts +104 -0
  389. package/lib/typescript/src/library/palette.d.ts.map +1 -0
  390. package/lib/typescript/src/library/responsive.d.ts +15 -0
  391. package/lib/typescript/src/library/responsive.d.ts.map +1 -0
  392. package/lib/typescript/src/locales.d.ts +103 -0
  393. package/lib/typescript/src/locales.d.ts.map +1 -0
  394. package/lib/typescript/src/localization.d.ts +1051 -0
  395. package/lib/typescript/src/localization.d.ts.map +1 -0
  396. package/lib/typescript/src/logger.d.ts +4 -0
  397. package/lib/typescript/src/logger.d.ts.map +1 -0
  398. package/lib/typescript/src/lowMemoryCache.d.ts +64 -0
  399. package/lib/typescript/src/lowMemoryCache.d.ts.map +1 -0
  400. package/lib/typescript/src/mediaHistory.d.ts +3 -0
  401. package/lib/typescript/src/mediaHistory.d.ts.map +1 -0
  402. package/lib/typescript/src/mediaStorageService.d.ts +155 -0
  403. package/lib/typescript/src/mediaStorageService.d.ts.map +1 -0
  404. package/lib/typescript/src/memory.d.ts +21 -0
  405. package/lib/typescript/src/memory.d.ts.map +1 -0
  406. package/lib/typescript/src/nativeActions.d.ts +174 -0
  407. package/lib/typescript/src/nativeActions.d.ts.map +1 -0
  408. package/lib/typescript/src/nativeComponentSupport.d.ts +30 -0
  409. package/lib/typescript/src/nativeComponentSupport.d.ts.map +1 -0
  410. package/lib/typescript/src/networkPerformance.d.ts +12 -0
  411. package/lib/typescript/src/networkPerformance.d.ts.map +1 -0
  412. package/lib/typescript/src/performance.d.ts +32 -0
  413. package/lib/typescript/src/performance.d.ts.map +1 -0
  414. package/lib/typescript/src/performanceMonitor.d.ts +45 -0
  415. package/lib/typescript/src/performanceMonitor.d.ts.map +1 -0
  416. package/lib/typescript/src/permissions.d.ts +132 -0
  417. package/lib/typescript/src/permissions.d.ts.map +1 -0
  418. package/lib/typescript/src/rendering.d.ts +9 -0
  419. package/lib/typescript/src/rendering.d.ts.map +1 -0
  420. package/lib/typescript/src/security.d.ts +6 -0
  421. package/lib/typescript/src/security.d.ts.map +1 -0
  422. package/lib/typescript/src/state.d.ts +102 -0
  423. package/lib/typescript/src/state.d.ts.map +1 -0
  424. package/lib/typescript/src/storage.d.ts +117 -0
  425. package/lib/typescript/src/storage.d.ts.map +1 -0
  426. package/lib/typescript/src/theme.d.ts +15 -0
  427. package/lib/typescript/src/theme.d.ts.map +1 -0
  428. package/lib/typescript/src/types.d.ts +802 -0
  429. package/lib/typescript/src/types.d.ts.map +1 -0
  430. package/lib/typescript/src/utils.d.ts +50 -0
  431. package/lib/typescript/src/utils.d.ts.map +1 -0
  432. package/lib/typescript/src/validation.d.ts +52 -0
  433. package/lib/typescript/src/validation.d.ts.map +1 -0
  434. package/package.json +204 -0
  435. package/react-native.config.js +17 -0
  436. package/src/AudioPlayerContext.tsx +220 -0
  437. package/src/CameraPreview.tsx +352 -0
  438. package/src/NativeAnimatedImageView.tsx +71 -0
  439. package/src/NativeAudioPlayerView.tsx +39 -0
  440. package/src/NativeBlurView.tsx +40 -0
  441. package/src/NativeCustomCamera.ts +305 -0
  442. package/src/NativeCustomCamera.web.ts +192 -0
  443. package/src/NativeCustomVideoView.ts +30 -0
  444. package/src/NativeDocumentPreviewView.tsx +196 -0
  445. package/src/NativeMediaThumbnailView.tsx +167 -0
  446. package/src/NativeSvgIcon.tsx +46 -0
  447. package/src/ResponsivePreviewContainer.tsx +227 -0
  448. package/src/accessibility.ts +80 -0
  449. package/src/config.ts +406 -0
  450. package/src/cpuOptimization.ts +365 -0
  451. package/src/db/DatabaseManager.ts +212 -0
  452. package/src/db/MediaMapper.ts +377 -0
  453. package/src/db/MediaRepository.ts +313 -0
  454. package/src/db/index.ts +73 -0
  455. package/src/db/migrations.ts +222 -0
  456. package/src/db/react-native-sqlcipher.d.ts +76 -0
  457. package/src/db/secureKey.ts +100 -0
  458. package/src/db/types.ts +123 -0
  459. package/src/db/useMediaDatabase.ts +191 -0
  460. package/src/defaultIcons.tsx +2390 -0
  461. package/src/deviceCapabilities.ts +438 -0
  462. package/src/errors.ts +350 -0
  463. package/src/iconConfig.tsx +962 -0
  464. package/src/icons.tsx +788 -0
  465. package/src/index.tsx +763 -0
  466. package/src/jest-globals.d.ts +9 -0
  467. package/src/library/MediaLibrary.tsx +141 -0
  468. package/src/library/MediaLibraryScreen.tsx +3003 -0
  469. package/src/library/components/AudioPreview.tsx +73 -0
  470. package/src/library/components/DocumentPreview.tsx +361 -0
  471. package/src/library/components/ExpandableFab.tsx +342 -0
  472. package/src/library/components/FileTiles.tsx +252 -0
  473. package/src/library/components/ImagePreview.tsx +72 -0
  474. package/src/library/components/MediaMetadataHeader.tsx +208 -0
  475. package/src/library/components/RecordAudioScreen.tsx +845 -0
  476. package/src/library/components/VideoPreview.tsx +478 -0
  477. package/src/library/components/ViewerCounter.tsx +71 -0
  478. package/src/library/compressionEstimate.ts +662 -0
  479. package/src/library/fileMetadata.ts +212 -0
  480. package/src/library/index.ts +66 -0
  481. package/src/library/libraryIconRegistry.tsx +86 -0
  482. package/src/library/libraryIcons.tsx +928 -0
  483. package/src/library/localizedFormat.ts +207 -0
  484. package/src/library/palette.ts +281 -0
  485. package/src/library/responsive.ts +49 -0
  486. package/src/locales.ts +381 -0
  487. package/src/localization.ts +1947 -0
  488. package/src/logger.ts +20 -0
  489. package/src/lowMemoryCache.ts +218 -0
  490. package/src/mediaHistory.ts +42 -0
  491. package/src/mediaStorageService.ts +546 -0
  492. package/src/memory.ts +102 -0
  493. package/src/nativeActions.ts +422 -0
  494. package/src/nativeComponentSupport.ts +60 -0
  495. package/src/networkPerformance.ts +30 -0
  496. package/src/performance.ts +137 -0
  497. package/src/performanceMonitor.ts +219 -0
  498. package/src/permissions.ts +403 -0
  499. package/src/rendering.ts +47 -0
  500. package/src/security.ts +19 -0
  501. package/src/state.ts +333 -0
  502. package/src/storage.ts +453 -0
  503. package/src/theme.tsx +467 -0
  504. package/src/types.ts +946 -0
  505. package/src/utils.ts +177 -0
  506. package/src/validation.ts +372 -0
@@ -0,0 +1,196 @@
1
+ import type { ComponentType, FC } from 'react';
2
+ import {
3
+ Platform,
4
+ requireNativeComponent,
5
+ View,
6
+ type NativeSyntheticEvent,
7
+ type ViewProps,
8
+ } from 'react-native';
9
+
10
+ /**
11
+ * The renderer families the native in-app document preview supports, all built on standard
12
+ * Android framework APIs (no third-party preview library):
13
+ * - `pdf` → PdfRenderer pages in a scrolling list (lazy, memory-bounded rasterization)
14
+ * - `text` → plain text in a scrollable native TextView
15
+ * - `code` → structured text (JSON/XML/…) — same renderer with a monospace face
16
+ * - `html` → a locked-down WebView (no JavaScript, no network, navigation blocked)
17
+ * - `image` → image-based documents (scans/photos exported as documents), down-sampled decode
18
+ * - `ppt`/`pptx` → dedicated PowerPoint extractors + Canvas slide viewer
19
+ * - `docx`/`xlsx`/`odt`/`ods`/`rtf`/`csv`/`epub` → native format parsers (OOXML/ODF
20
+ * zip+XML structure, RTF control words, CSV records, EPUB spine) that reproduce the
21
+ * ORIGINAL geometry — true page size/margins, authored column widths/row heights/merges,
22
+ * fonts/sizes/colors/spacing, embedded images — rendered by the same locked WebView engine.
23
+ */
24
+ export type DocumentPreviewKind =
25
+ | 'pdf'
26
+ | 'text'
27
+ | 'code'
28
+ | 'html'
29
+ | 'image'
30
+ | 'ppt'
31
+ | 'docx'
32
+ | 'xlsx'
33
+ | 'pptx'
34
+ | 'odt'
35
+ | 'ods'
36
+ | 'rtf'
37
+ | 'csv'
38
+ | 'epub';
39
+
40
+ export interface NativeDocumentPreviewViewProps extends ViewProps {
41
+ /** Document source uri (content:// or file://). */
42
+ src?: string;
43
+ /** Which native renderer to use — see {@link getDocumentPreviewKind}. */
44
+ kind?: DocumentPreviewKind;
45
+ /**
46
+ * False while the document's page is off-screen in a paging viewer — pauses expensive work
47
+ * (PDF page rasterization) exactly like the audio/video cells' `active` gate.
48
+ */
49
+ active?: boolean;
50
+ /** Fired when the document is ready. `pageCount` is > 0 for PDFs, 0 otherwise. */
51
+ onPreviewLoad?: (event: NativeSyntheticEvent<{ pageCount: number }>) => void;
52
+ /** Fired when the file can't be rendered — callers should fall back to an info card. */
53
+ onPreviewError?: (event: NativeSyntheticEvent<{ message: string }>) => void;
54
+ }
55
+
56
+ // Extension → renderer family. Formats without a parser here (binary-era DOC/PPT/XLS, Apple
57
+ // PAGES, archives, …) return null and get the informational card.
58
+ const EXTENSION_KINDS: Record<string, DocumentPreviewKind> = {
59
+ pdf: 'pdf',
60
+ txt: 'text',
61
+ log: 'text',
62
+ text: 'text',
63
+ md: 'text',
64
+ json: 'code',
65
+ xml: 'code',
66
+ tsv: 'code',
67
+ yaml: 'code',
68
+ yml: 'code',
69
+ html: 'html',
70
+ htm: 'html',
71
+ xhtml: 'html',
72
+ jpg: 'image',
73
+ jpeg: 'image',
74
+ png: 'image',
75
+ gif: 'image',
76
+ webp: 'image',
77
+ bmp: 'image',
78
+ heic: 'image',
79
+ heif: 'image',
80
+ hif: 'image',
81
+ avif: 'image',
82
+ avifs: 'image',
83
+ // Native office-format parsers — original layout geometry preserved.
84
+ docx: 'docx',
85
+ xlsx: 'xlsx',
86
+ ppt: 'ppt',
87
+ pptx: 'pptx',
88
+ pps: 'ppt',
89
+ ppsx: 'pptx',
90
+ pot: 'ppt',
91
+ potx: 'pptx',
92
+ // Macro-enabled variants are ordinary PresentationML zips. Without these the extension lookup
93
+ // misses and SAF providers frequently report application/octet-stream, so the MIME fallback
94
+ // can't rescue them either.
95
+ pptm: 'pptx',
96
+ ppsm: 'pptx',
97
+ potm: 'pptx',
98
+ odt: 'odt',
99
+ ods: 'ods',
100
+ rtf: 'rtf',
101
+ csv: 'csv',
102
+ epub: 'epub',
103
+ };
104
+
105
+ // MIME type → renderer family, used when the file name carries no useful extension.
106
+ const MIME_KINDS: Record<string, DocumentPreviewKind> = {
107
+ 'application/pdf': 'pdf',
108
+ 'application/json': 'code',
109
+ 'application/xml': 'code',
110
+ 'text/xml': 'code',
111
+ 'text/csv': 'csv',
112
+ 'text/comma-separated-values': 'csv',
113
+ 'text/html': 'html',
114
+ 'application/xhtml+xml': 'html',
115
+ 'application/vnd.openxmlformats-officedocument.wordprocessingml.document':
116
+ 'docx',
117
+ 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet':
118
+ 'xlsx',
119
+ 'application/vnd.ms-powerpoint': 'ppt',
120
+ 'application/vnd.openxmlformats-officedocument.presentationml.presentation':
121
+ 'pptx',
122
+ 'application/vnd.openxmlformats-officedocument.presentationml.slideshow':
123
+ 'pptx',
124
+ 'application/vnd.openxmlformats-officedocument.presentationml.template':
125
+ 'pptx',
126
+ 'application/powerpoint': 'ppt',
127
+ 'application/mspowerpoint': 'ppt',
128
+ 'application/x-mspowerpoint': 'ppt',
129
+ 'application/x-powerpoint': 'ppt',
130
+ 'application/vnd.ms-powerpoint.presentation.macroenabled.12': 'pptx',
131
+ 'application/vnd.ms-powerpoint.slideshow.macroenabled.12': 'pptx',
132
+ 'application/vnd.oasis.opendocument.text': 'odt',
133
+ 'application/vnd.oasis.opendocument.spreadsheet': 'ods',
134
+ 'application/rtf': 'rtf',
135
+ 'text/rtf': 'rtf',
136
+ 'application/epub+zip': 'epub',
137
+ };
138
+
139
+ /**
140
+ * Maps a document's file name / MIME type to the native renderer able to preview it in-app,
141
+ * or `null` when no parser exists for the format (binary-era DOC/XLS, Apple PAGES,
142
+ * archives, …) — those should show an informational card instead. The extension wins over the
143
+ * MIME type because SAF providers frequently report generic types (application/octet-stream)
144
+ * for files whose names identify them precisely.
145
+ */
146
+ export function getDocumentPreviewKind(
147
+ fileName?: string,
148
+ mimeType?: string
149
+ ): DocumentPreviewKind | null {
150
+ if (fileName) {
151
+ const dot = fileName.lastIndexOf('.');
152
+ if (dot >= 0 && dot < fileName.length - 1) {
153
+ const kind = EXTENSION_KINDS[fileName.slice(dot + 1).toLowerCase()];
154
+ if (kind) return kind;
155
+ }
156
+ }
157
+ if (mimeType) {
158
+ const normalized = mimeType.toLowerCase();
159
+ const direct = MIME_KINDS[normalized];
160
+ if (direct) return direct;
161
+ if (normalized.startsWith('text/')) return 'text';
162
+ if (normalized.startsWith('image/')) return 'image';
163
+ }
164
+ return null;
165
+ }
166
+
167
+ // Native (Android) in-app document preview — PdfRenderer / TextView / locked-down WebView /
168
+ // down-sampled image decode, all standard framework APIs. Resolved lazily and platform-guarded
169
+ // so non-Android targets (or an app without the native view registered) fall back to a plain
170
+ // view, exactly like NativeAudioPlayerView.
171
+ let NativeDocumentComponent: ComponentType<NativeDocumentPreviewViewProps> | null =
172
+ null;
173
+ if (Platform.OS === 'android') {
174
+ try {
175
+ NativeDocumentComponent =
176
+ requireNativeComponent<NativeDocumentPreviewViewProps>(
177
+ 'CustomDocumentPreview'
178
+ );
179
+ } catch {
180
+ NativeDocumentComponent = null;
181
+ }
182
+ }
183
+
184
+ /** True when the native in-app preview is available on this platform/build. */
185
+ export const isNativeDocumentPreviewAvailable = (): boolean =>
186
+ NativeDocumentComponent !== null;
187
+
188
+ export const NativeDocumentPreviewView: FC<NativeDocumentPreviewViewProps> = (
189
+ props
190
+ ) => {
191
+ if (NativeDocumentComponent) {
192
+ return <NativeDocumentComponent {...props} />;
193
+ }
194
+ const { src, kind, active, onPreviewLoad, onPreviewError, ...rest } = props;
195
+ return <View {...rest} />;
196
+ };
@@ -0,0 +1,167 @@
1
+ import type { FC } from 'react';
2
+ import {
3
+ Image,
4
+ View,
5
+ type ImageStyle,
6
+ type StyleProp,
7
+ type ViewProps,
8
+ type ViewStyle,
9
+ } from 'react-native';
10
+ import type { CameraAsset } from './types';
11
+ import {
12
+ resolveNativeComponent,
13
+ toImageSourceUri,
14
+ } from './nativeComponentSupport';
15
+ import { NativeAnimatedImageView } from './NativeAnimatedImageView';
16
+ import { isGifAsset, requiresNativeImageDecoder } from './utils';
17
+
18
+ export interface NativeMediaThumbnailViewProps
19
+ extends Omit<ViewProps, 'style'> {
20
+ /** The media's own URI (`content://`, `file://` or a plain path). */
21
+ src?: string;
22
+ /**
23
+ * `video` extracts a frame; anything else is decoded as a still. Both the JS (`photo`) and
24
+ * database (`image`) spellings mean the same thing.
25
+ */
26
+ mediaType?: CameraAsset['type'] | 'image';
27
+ /** Cached copy of the file, read in preference to the URI while it exists on disk. */
28
+ cachePath?: string;
29
+ /** A video's user-selected cover frame; overrides frame extraction when present. */
30
+ coverUri?: string;
31
+ /** Format hints — decide decodability (HEIF/AVIF) and alpha handling. */
32
+ mimeType?: string;
33
+ fileName?: string;
34
+ /** How the frame is scaled into the tile. Defaults to `cover`. */
35
+ resizeMode?: 'contain' | 'cover';
36
+ /**
37
+ * Decode target in pixels. Defaults to the tile's own measured size, which is what a list
38
+ * row wants — set it only to force a sharper (or cheaper) bitmap.
39
+ */
40
+ thumbnailSize?: number;
41
+ /**
42
+ * Typed as an image style rather than a view style: the native view and the `<Image>`
43
+ * fallback both render image content.
44
+ */
45
+ style?: StyleProp<ImageStyle>;
46
+ }
47
+
48
+ // Native thumbnail view (Android). A JS <Image> cannot produce a thumbnail for a video at all —
49
+ // there is no frame to read without an extractor — and needs platform decoders for HEIF/AVIF, so
50
+ // list rows for those were left blank. The native view runs the library's own ThumbnailLoader
51
+ // (cover frame → extracted video frame → resolver thumbnail → downsampled decode, LRU cached).
52
+ const NativeMediaThumbnailComponent =
53
+ resolveNativeComponent<NativeMediaThumbnailViewProps>('CustomMediaThumbnail');
54
+
55
+ /** True when native thumbnail decoding is available on this platform/build. */
56
+ export const isNativeMediaThumbnailAvailable = (): boolean =>
57
+ NativeMediaThumbnailComponent !== null;
58
+
59
+ /**
60
+ * The best thumbnail JS alone can draw for this media.
61
+ *
62
+ * Reached whenever the native view is not in the binary — a host app built before it existed,
63
+ * or a non-Android target. A still image is fully renderable here: `<Image>` decodes JPEG, PNG,
64
+ * WebP, GIF and BMP, and {@link NativeAnimatedImageView} covers the containers Fresco cannot
65
+ * (HEIF/AVIF) plus animated GIFs, held on a single frame because a list tile wants a still.
66
+ *
67
+ * A video is the one case JS genuinely cannot serve: without a cover frame there is nothing to
68
+ * decode, so the tile holds its space instead of pointing an `<Image>` at an MP4 and logging a
69
+ * Fresco failure for every row on screen.
70
+ */
71
+ const MediaThumbnailFallback: FC<NativeMediaThumbnailViewProps> = (props) => {
72
+ const source = props.coverUri ?? props.src;
73
+ const uri = toImageSourceUri(source);
74
+ const isVideoWithoutCover =
75
+ props.mediaType === 'video' && !props.coverUri;
76
+
77
+ if (!uri || isVideoWithoutCover) {
78
+ // Size/rounding live on the style either component receives.
79
+ return (
80
+ <View
81
+ style={props.style as StyleProp<ViewStyle>}
82
+ testID={props.testID}
83
+ />
84
+ );
85
+ }
86
+
87
+ const descriptor = {
88
+ mimeType: props.mimeType,
89
+ fileName: props.fileName,
90
+ uri: source,
91
+ };
92
+
93
+ if (isGifAsset(descriptor) || requiresNativeImageDecoder(descriptor)) {
94
+ return (
95
+ <NativeAnimatedImageView
96
+ src={uri}
97
+ style={props.style}
98
+ testID={props.testID}
99
+ resizeMode={props.resizeMode ?? 'cover'}
100
+ // A tile is a still: decode the frame, never animate it behind a scrolling list.
101
+ active={false}
102
+ />
103
+ );
104
+ }
105
+
106
+ return (
107
+ <Image
108
+ style={props.style}
109
+ testID={props.testID}
110
+ source={{ uri }}
111
+ resizeMode={props.resizeMode ?? 'cover'}
112
+ // Decode to the tile's size rather than the file's full resolution: a 12MP still decoded
113
+ // whole is ~48MB of bitmap for a ~56px row. No-op on iOS.
114
+ resizeMethod="resize"
115
+ />
116
+ );
117
+ };
118
+
119
+ /**
120
+ * Renders a media file's own thumbnail — an extracted frame for a video, the decoded image for
121
+ * a still — through the native decoder where the build has it and through
122
+ * {@link MediaThumbnailFallback} where it does not. Either way the underlying file is only ever
123
+ * read.
124
+ */
125
+ export const NativeMediaThumbnailView: FC<NativeMediaThumbnailViewProps> = (
126
+ props
127
+ ) => {
128
+ if (NativeMediaThumbnailComponent) {
129
+ return <NativeMediaThumbnailComponent {...props} />;
130
+ }
131
+ return <MediaThumbnailFallback {...props} />;
132
+ };
133
+
134
+ export interface MediaThumbnailProps {
135
+ /** The asset to render a thumbnail for. */
136
+ asset: CameraAsset;
137
+ style?: StyleProp<ImageStyle>;
138
+ resizeMode?: 'contain' | 'cover';
139
+ thumbnailSize?: number;
140
+ testID?: string;
141
+ }
142
+
143
+ /**
144
+ * Convenience wrapper that feeds a whole {@link CameraAsset} to {@link NativeMediaThumbnailView},
145
+ * so a list row does not have to know which of the asset's fields drive the decode.
146
+ */
147
+ export const MediaThumbnail: FC<MediaThumbnailProps> = ({
148
+ asset,
149
+ style,
150
+ resizeMode = 'cover',
151
+ thumbnailSize,
152
+ testID,
153
+ }) => (
154
+ <NativeMediaThumbnailView
155
+ // documentUri is the published copy; uri is where the file actually is for a capture.
156
+ src={asset.uri || asset.documentUri}
157
+ mediaType={asset.type}
158
+ cachePath={asset.cachePath}
159
+ coverUri={asset.coverUri}
160
+ mimeType={asset.mimeType}
161
+ fileName={asset.fileName}
162
+ style={style}
163
+ resizeMode={resizeMode}
164
+ thumbnailSize={thumbnailSize}
165
+ testID={testID}
166
+ />
167
+ );
@@ -0,0 +1,46 @@
1
+ import type { FC, ReactElement } from 'react';
2
+ import type {
3
+ ColorValue,
4
+ StyleProp,
5
+ ViewProps,
6
+ ViewStyle,
7
+ } from 'react-native';
8
+ import { resolveNativeComponent } from './nativeComponentSupport';
9
+
10
+ export interface NativeSvgIconProps extends Omit<ViewProps, 'style'> {
11
+ /** Inline SVG markup to draw. */
12
+ svg: string;
13
+ /**
14
+ * Optional tint. Recolours `currentColor` (and any un-parseable colour) in the
15
+ * markup; explicit colours in the SVG are left untouched.
16
+ */
17
+ tintColor?: ColorValue;
18
+ style?: StyleProp<ViewStyle>;
19
+ }
20
+
21
+ // Native SVG icon view (Android). ReactNative's own <Image> cannot decode an
22
+ // `<svg>` data URI on Android (Fresco ships no SVG decoder), so inline-`svg`
23
+ // icon customizations are drawn by the library's own bundled SvgDrawable parser
24
+ // through this view — no react-native-svg, no third-party dependency.
25
+ const NativeSvgIconComponent =
26
+ resolveNativeComponent<NativeSvgIconProps>('CameraSvgIcon');
27
+
28
+ /** True when the bundled native SVG renderer is available on this platform/build. */
29
+ export const isNativeSvgIconAvailable = (): boolean =>
30
+ NativeSvgIconComponent !== null;
31
+
32
+ /**
33
+ * Draws inline SVG markup with the bundled native renderer when it is available,
34
+ * and otherwise renders [fallback] — the plugin's built-in default icon. This is
35
+ * how an inline-`svg` customization stays safe on a platform with no native half
36
+ * (iOS/web) or against an older linked binary: it silently shows the default
37
+ * artwork rather than a blank box.
38
+ */
39
+ export const NativeSvgIcon: FC<
40
+ NativeSvgIconProps & { fallback: ReactElement }
41
+ > = ({ fallback, ...props }) => {
42
+ if (NativeSvgIconComponent) {
43
+ return <NativeSvgIconComponent {...props} />;
44
+ }
45
+ return fallback;
46
+ };
@@ -0,0 +1,227 @@
1
+ import React, { useMemo, useEffect, useState } from 'react';
2
+ import {
3
+ View,
4
+ StyleSheet,
5
+ Dimensions,
6
+ type DisplayMetrics,
7
+ } from 'react-native';
8
+ import { useCameraTheme } from './theme';
9
+
10
+ // ─────────────────────────────────────────────────────────────────────────────
11
+ // Single source of truth for WhatsApp-like camera preview dimensions.
12
+ // Aspect ratio ≈ 720:1165 (≈ 9:14.6 ≈ 0.618) – matches WhatsApp's camera preview.
13
+ // ─────────────────────────────────────────────────────────────────────────────
14
+
15
+ /** WhatsApp-like camera preview aspect ratio (720:1165 ≈ 9:14.6 ≈ 0.618) */
16
+ export const WHATSAPP_ASPECT_RATIO = 720 / 1165;
17
+
18
+ /**
19
+ * Portrait 9:16 aspect ratio used for the media editing / preview canvas.
20
+ *
21
+ * After capture the user is taken to the editing preview, which always presents
22
+ * a portrait (9:16) canvas regardless of the captured media's own orientation.
23
+ * A landscape photo is scaled and centered (letterboxed) inside this canvas with
24
+ * its aspect ratio preserved — no rotation, stretching, distortion, or cropping.
25
+ * This single constant is the source of truth for that canvas so the on-screen
26
+ * preview matches the final exported / sent image exactly.
27
+ */
28
+ export const PORTRAIT_PREVIEW_ASPECT_RATIO = 9 / 16;
29
+
30
+ /**
31
+ * Responsive preview geometry — the single source of truth. Every value is
32
+ * also exposed through `theme.components.responsivePreviewContainer` so host
33
+ * apps can re-tune them without touching this file.
34
+ */
35
+ export interface PreviewDimensionConfig {
36
+ /** Fraction of screen width used for the preview container. */
37
+ widthRatio: number;
38
+ /** Maximum preview width in logical pixels (matches WhatsApp on tablets). */
39
+ maxWidth: number;
40
+ /** Maximum fraction of screen height the preview may occupy. */
41
+ maxHeightRatio: number;
42
+ }
43
+
44
+ /** Default geometry — the stock, WhatsApp-like responsive sizing. */
45
+ export const DEFAULT_PREVIEW_DIMENSION_CONFIG: PreviewDimensionConfig = {
46
+ widthRatio: 0.96,
47
+ maxWidth: 720,
48
+ maxHeightRatio: 0.92,
49
+ };
50
+
51
+ // ── Pure calculation helpers (no React dependency) ───────────────────────────
52
+
53
+ /** Compute preview dimensions from raw screen values */
54
+ export function calcPreviewDimensions(
55
+ screenW: number,
56
+ screenH: number,
57
+ config: PreviewDimensionConfig = DEFAULT_PREVIEW_DIMENSION_CONFIG
58
+ ) {
59
+ const width = Math.min(screenW * config.widthRatio, config.maxWidth);
60
+ const height = Math.min(
61
+ screenH * config.maxHeightRatio,
62
+ width / WHATSAPP_ASPECT_RATIO
63
+ );
64
+ return { width, height, aspectRatio: WHATSAPP_ASPECT_RATIO };
65
+ }
66
+
67
+ /**
68
+ * Compute portrait 9:16 canvas dimensions from raw screen values.
69
+ *
70
+ * The canvas is fitted (contain) inside the available screen area so the whole
71
+ * 9:16 frame is always visible: it takes the largest 9:16 box that fits within
72
+ * both the width and height budget. The returned dimensions therefore always
73
+ * satisfy `width / height === PORTRAIT_PREVIEW_ASPECT_RATIO`, guaranteeing that
74
+ * the preview shown on screen is the exact same shape as the exported/sent image.
75
+ */
76
+ export function calcPortraitPreviewDimensions(
77
+ screenW: number,
78
+ screenH: number,
79
+ config: PreviewDimensionConfig = DEFAULT_PREVIEW_DIMENSION_CONFIG
80
+ ) {
81
+ // Start from the width budget, then clamp by the height budget so the fixed
82
+ // 9:16 ratio is preserved no matter the screen orientation.
83
+ let width = Math.min(screenW * config.widthRatio, config.maxWidth);
84
+ let height = width / PORTRAIT_PREVIEW_ASPECT_RATIO;
85
+
86
+ const maxHeight = screenH * config.maxHeightRatio;
87
+ if (height > maxHeight) {
88
+ height = maxHeight;
89
+ width = height * PORTRAIT_PREVIEW_ASPECT_RATIO;
90
+ }
91
+
92
+ return { width, height, aspectRatio: PORTRAIT_PREVIEW_ASPECT_RATIO };
93
+ }
94
+
95
+ // ── Static exports (computed once at import-time for lightweight consumers) ─
96
+
97
+ const _initial = Dimensions.get('window');
98
+ export const PREVIEW_WIDTH = calcPreviewDimensions(
99
+ _initial.width,
100
+ _initial.height
101
+ ).width;
102
+ export const PREVIEW_HEIGHT = calcPreviewDimensions(
103
+ _initial.width,
104
+ _initial.height
105
+ ).height;
106
+
107
+ // ── Reactive hook (recomputes on orientation / dimension changes) ─────────────
108
+
109
+ /**
110
+ * Returns responsive preview dimensions that update on screen size changes.
111
+ * Use this inside components instead of the static PREVIEW_WIDTH/PREVIEW_HEIGHT
112
+ * exports to ensure correctness after rotation or window resize.
113
+ */
114
+ export function usePreviewDimensions(
115
+ config: PreviewDimensionConfig = DEFAULT_PREVIEW_DIMENSION_CONFIG
116
+ ) {
117
+ const [dims, setDims] = useState(() => Dimensions.get('window'));
118
+
119
+ useEffect(() => {
120
+ const sub = Dimensions.addEventListener(
121
+ 'change',
122
+ ({ window }: { window: DisplayMetrics }) => {
123
+ setDims(window);
124
+ }
125
+ );
126
+ return () => sub.remove();
127
+ }, []);
128
+
129
+ return useMemo(
130
+ () => calcPreviewDimensions(dims.width, dims.height, config),
131
+ [dims, config]
132
+ );
133
+ }
134
+
135
+ /**
136
+ * Returns responsive portrait 9:16 canvas dimensions that update on screen size
137
+ * changes. Use this for the editing / preview canvas so a captured landscape
138
+ * image is scaled and centered inside a fixed portrait frame, and the preview
139
+ * matches the final exported / sent image exactly.
140
+ */
141
+ export function usePortraitPreviewDimensions(
142
+ config: PreviewDimensionConfig = DEFAULT_PREVIEW_DIMENSION_CONFIG
143
+ ) {
144
+ const [dims, setDims] = useState(() => Dimensions.get('window'));
145
+
146
+ useEffect(() => {
147
+ const sub = Dimensions.addEventListener(
148
+ 'change',
149
+ ({ window }: { window: DisplayMetrics }) => {
150
+ setDims(window);
151
+ }
152
+ );
153
+ return () => sub.remove();
154
+ }, []);
155
+
156
+ return useMemo(
157
+ () => calcPortraitPreviewDimensions(dims.width, dims.height, config),
158
+ [dims, config]
159
+ );
160
+ }
161
+
162
+ // ── Component ────────────────────────────────────────────────────────────────
163
+
164
+ interface ResponsivePreviewContainerProps {
165
+ children: React.ReactNode;
166
+ /** Optional extra styles merged after the container styles */
167
+ style?: any;
168
+ /** Explicit width to use instead of calculated width */
169
+ width?: number;
170
+ /** Explicit height to use instead of calculated height */
171
+ height?: number;
172
+ }
173
+
174
+ /**
175
+ * A fixed-aspect-ratio container that matches WhatsApp's camera preview area.
176
+ *
177
+ * Usage:
178
+ * <ResponsivePreviewContainer>
179
+ * <Image source={…} style={{ width: '100%', height: '100%', resizeMode: 'contain' }} />
180
+ * </ResponsivePreviewContainer>
181
+ */
182
+ export const ResponsivePreviewContainer: React.FC<
183
+ ResponsivePreviewContainerProps
184
+ > = ({ children, style, width: explicitWidth, height: explicitHeight }) => {
185
+ // React hooks must be called unconditionally, so we still call it,
186
+ // but explicit dimensions (when provided) take precedence below.
187
+ const theme = useCameraTheme();
188
+ const rpcTheme = theme.components.responsivePreviewContainer;
189
+ const previewConfig = useMemo(
190
+ () => ({
191
+ widthRatio: rpcTheme.widthRatio,
192
+ maxWidth: rpcTheme.maxWidth,
193
+ maxHeightRatio: rpcTheme.maxHeightRatio,
194
+ }),
195
+ [rpcTheme.widthRatio, rpcTheme.maxWidth, rpcTheme.maxHeightRatio]
196
+ );
197
+ const dims = usePreviewDimensions(previewConfig);
198
+
199
+ const finalWidth = explicitWidth ?? dims.width;
200
+ const finalHeight = explicitHeight ?? dims.height;
201
+
202
+ return (
203
+ <View
204
+ style={[
205
+ styles.container,
206
+ {
207
+ width: finalWidth,
208
+ height: finalHeight,
209
+ borderRadius: theme.components.responsivePreviewContainer.borderRadius,
210
+ backgroundColor: theme.components.responsivePreviewContainer.background,
211
+ },
212
+ style,
213
+ ]}
214
+ >
215
+ {children}
216
+ </View>
217
+ );
218
+ };
219
+
220
+ const styles = StyleSheet.create({
221
+ container: {
222
+ overflow: 'hidden',
223
+ alignSelf: 'center',
224
+ justifyContent: 'center',
225
+ alignItems: 'center',
226
+ },
227
+ });