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
package/src/icons.tsx ADDED
@@ -0,0 +1,788 @@
1
+ /**
2
+ * Centralized, dependency-free icon system for the camera plugin.
3
+ *
4
+ * This module provides a complete icon abstraction that:
5
+ * - Requires NO external icon libraries (no react-native-vector-icons, @expo/vector-icons, etc.)
6
+ * - Allows complete customization via a central registry
7
+ * - Provides built-in defaults using React Native primitives only
8
+ * - Supports dynamic icon substitution at runtime
9
+ * - Integrates with the plugin's configuration system
10
+ *
11
+ * Usage:
12
+ * ```tsx
13
+ * // Use hook in components
14
+ * const Icon = useIconComponent('close');
15
+ * <Icon size={24} color="#FFFFFF" />
16
+ *
17
+ * // Or get the registry to render any icon
18
+ * const icons = useIconRegistry();
19
+ * const CloseIcon = icons.get('close');
20
+ * ```
21
+ */
22
+
23
+ import React, {
24
+ createContext,
25
+ useContext,
26
+ useMemo,
27
+ useState,
28
+ useEffect,
29
+ useSyncExternalStore,
30
+ type ReactNode,
31
+ type FC,
32
+ } from 'react';
33
+ import { View, Text } from 'react-native';
34
+ import type { ColorValue, TextStyle } from 'react-native';
35
+
36
+ // ============================================================================
37
+ // Centralized icon defaults (single source of truth)
38
+ // ============================================================================
39
+
40
+ /** Default edge length (dp) for icons when a caller omits `size`. */
41
+ export const DEFAULT_ICON_SIZE = 24;
42
+
43
+ /** Default color for icons when a caller omits `color`. */
44
+ export const DEFAULT_ICON_COLOR = '#000000';
45
+
46
+ /** Default stroke width (dp) for outline-style icons. */
47
+ export const DEFAULT_ICON_STROKE_WIDTH = 2;
48
+
49
+ /** Color rendered by the fallback icon when a registry entry is missing. */
50
+ export const DEFAULT_FALLBACK_ICON_COLOR = '#999';
51
+
52
+ /** Font weight used by the fallback icon's glyph. */
53
+ export const DEFAULT_FALLBACK_ICON_WEIGHT: TextStyle['fontWeight'] = 'bold';
54
+
55
+ /**
56
+ * Props that every icon component must accept.
57
+ * All icons receive at least these standardized props for consistency.
58
+ */
59
+ export interface IconProps {
60
+ /** Size in dp (icons are square by default) */
61
+ size?: number;
62
+ /** Icon color (CSS color string or React Native color) */
63
+ color?: ColorValue;
64
+ /** Optional stroke width for outline-style icons */
65
+ strokeWidth?: number;
66
+ /** Optional additional styling */
67
+ style?: any;
68
+ /** Optional animation progress for morphing icons like PlusCloseIcon (0 = +, 1 = ×) */
69
+ progress?: any;
70
+ /** Direction for directional icons like seek skip rings ('back' | 'forward') */
71
+ direction?: 'back' | 'forward';
72
+ /** Optional label string for icons that display text (e.g. seek delta '10') */
73
+ label?: string;
74
+ [key: string]: any;
75
+ }
76
+
77
+ /**
78
+ * A React component that renders an icon.
79
+ * Must accept IconProps and render a visual icon representation.
80
+ */
81
+ export type IconComponent = FC<IconProps>;
82
+
83
+ /**
84
+ * All icon keys used throughout the plugin.
85
+ * Each key maps to one icon that can be customized or replaced.
86
+ */
87
+ export type CameraIconKey =
88
+ // Common controls
89
+ | 'close'
90
+ | 'back'
91
+ | 'done'
92
+ | 'cancel'
93
+ // Camera controls
94
+ | 'camera'
95
+ | 'video'
96
+ | 'photo'
97
+ | 'flip'
98
+ | 'flash_on'
99
+ | 'flash_off'
100
+ | 'flash_auto'
101
+ | 'gallery'
102
+ | 'photo_mode'
103
+ | 'video_mode'
104
+ // Editor tools
105
+ | 'crop'
106
+ | 'rotate'
107
+ | 'filter'
108
+ | 'sticker'
109
+ | 'emoji'
110
+ | 'text'
111
+ | 'draw'
112
+ | 'undo'
113
+ | 'redo'
114
+ | 'delete'
115
+ | 'trash'
116
+ // Media & playback
117
+ | 'play'
118
+ | 'pause'
119
+ | 'stop'
120
+ | 'download'
121
+ | 'share'
122
+ | 'send'
123
+ | 'more'
124
+ // Document & audio
125
+ | 'document'
126
+ | 'audio'
127
+ // States & indicators
128
+ | 'lock'
129
+ | 'lock_open'
130
+ | 'chevron_up'
131
+ | 'chevron_right'
132
+ | 'check'
133
+ | 'volume_on'
134
+ | 'volume_off'
135
+ | 'mute'
136
+ | 'warning'
137
+ // Media operations
138
+ | 'trim'
139
+ | 'cover'
140
+ | 'compress'
141
+ | 'export'
142
+ | 'upload'
143
+ // Recording & audio
144
+ | 'mic'
145
+ | 'record'
146
+ | 'browse_audio'
147
+ | 'image_video'
148
+ // Additional
149
+ | 'plus'
150
+ | 'minus'
151
+ // Interactive & inline icons
152
+ | 'plus_close'
153
+ | 'circular_seek'
154
+ | 'view_details'
155
+ | 'info';
156
+
157
+ /**
158
+ * Registry mapping icon keys to React components.
159
+ * Immutable; use setIconRegistry() to replace the entire registry or
160
+ * use overrides in the plugin configuration for targeted changes.
161
+ */
162
+ export type IconRegistry = Map<CameraIconKey, IconComponent>;
163
+
164
+ /**
165
+ * Per-icon customization options.
166
+ * Allows apps to override specific icons or apply global tint colors.
167
+ */
168
+ export interface IconOverride {
169
+ /** Custom component to use instead of the default */
170
+ component?: IconComponent;
171
+ /** Tint color applied to built-in icons (not custom components) */
172
+ tintColor?: string;
173
+ /** Default size for this icon (can be overridden at render time) */
174
+ size?: number;
175
+ }
176
+
177
+ /**
178
+ * Icon registry configuration for the React-component icon system.
179
+ *
180
+ * NOTE: distinct from the NATIVE `CameraIconConfig` in `src/types.ts`, which
181
+ * configures the native camera Activity's Android vector drawables (tint / size
182
+ * / `resourceName`). This type configures the RN-side registry of React
183
+ * components. They are two independent layers — see the header docs.
184
+ */
185
+ export interface CameraIconRegistryConfig {
186
+ /** Complete custom registry. If provided, replaces the default entirely. */
187
+ registry?: IconRegistry;
188
+ /** Per-icon overrides. Merged with the current registry. */
189
+ overrides?: Partial<Record<CameraIconKey, IconOverride>>;
190
+ /** Global tint color applied to all built-in icons */
191
+ tintColor?: string;
192
+ /** Default size for all icons */
193
+ defaultSize?: number;
194
+ /** Default color for icons when a call site omits `color`. */
195
+ defaultColor?: string;
196
+ /** Default stroke width (dp) for outline-style icons. */
197
+ defaultStrokeWidth?: number;
198
+ }
199
+
200
+ /** Internal: effective icon configuration after merging */
201
+ interface ResolvedIconConfig {
202
+ registry: IconRegistry;
203
+ overrides: Partial<Record<CameraIconKey, IconOverride>>;
204
+ tintColor?: string;
205
+ defaultSize: number;
206
+ defaultColor?: string;
207
+ defaultStrokeWidth?: number;
208
+ }
209
+
210
+ export type { ResolvedIconConfig };
211
+
212
+ // ============================================================================
213
+ // Global registry store
214
+ // ============================================================================
215
+
216
+ /**
217
+ * Process-wide icon configuration, set from the centralized icon config
218
+ * (`setCameraIcons()` in `src/config.ts`).
219
+ *
220
+ * This exists so a host app can customize icons with ONE call at startup and
221
+ * have it reach every render path — including `<RenderIcon />` used without a
222
+ * `CameraIconProvider`, and `<CameraIconProvider>` mounted with no `config`
223
+ * prop. Provider-supplied config still layers on top; see
224
+ * {@link resolveIconConfigOverGlobal}.
225
+ *
226
+ * Kept here rather than in `iconConfig.tsx` to keep the import graph
227
+ * one-directional: `config.ts` → `iconConfig.tsx` → `icons.tsx`.
228
+ */
229
+ let globalResolvedIconConfig: ResolvedIconConfig = resolveIconConfig();
230
+
231
+ const globalIconConfigListeners = new Set<() => void>();
232
+
233
+ /**
234
+ * Replace the process-wide icon configuration and notify every subscriber.
235
+ * Passing `undefined` restores the shipped defaults.
236
+ */
237
+ export function setGlobalIconRegistryConfig(
238
+ config?: CameraIconRegistryConfig
239
+ ): void {
240
+ globalResolvedIconConfig = resolveIconConfig(config);
241
+ globalIconConfigListeners.forEach((listener) => listener());
242
+ }
243
+
244
+ /**
245
+ * The current process-wide resolved icon configuration. Reference-stable
246
+ * between {@link setGlobalIconRegistryConfig} calls, so it is safe to use as a
247
+ * `useSyncExternalStore` snapshot.
248
+ */
249
+ export function getGlobalIconRegistryConfig(): ResolvedIconConfig {
250
+ return globalResolvedIconConfig;
251
+ }
252
+
253
+ /** Subscribe to process-wide icon configuration changes. */
254
+ export function subscribeToGlobalIconRegistryConfig(
255
+ listener: () => void
256
+ ): () => void {
257
+ globalIconConfigListeners.add(listener);
258
+ return () => {
259
+ globalIconConfigListeners.delete(listener);
260
+ };
261
+ }
262
+
263
+ /**
264
+ * Resolve a config with the global configuration as its base, so both compose:
265
+ * a provider's own registry/tint/size wins where it is set, and the centralized
266
+ * per-icon `overrides` — the artwork a host asked for by name — survive
267
+ * underneath it. Per-icon overrides merge key-wise with the provider's winning,
268
+ * since a locally-scoped provider is the more specific instruction.
269
+ */
270
+ function resolveIconConfigOverGlobal(
271
+ config: CameraIconRegistryConfig | undefined,
272
+ base: ResolvedIconConfig
273
+ ): ResolvedIconConfig {
274
+ if (!config) {
275
+ return base;
276
+ }
277
+ return {
278
+ registry: config.registry ?? base.registry,
279
+ overrides: { ...base.overrides, ...(config.overrides ?? {}) },
280
+ tintColor: config.tintColor ?? base.tintColor,
281
+ defaultSize: config.defaultSize ?? base.defaultSize,
282
+ defaultColor: config.defaultColor ?? base.defaultColor,
283
+ defaultStrokeWidth: config.defaultStrokeWidth ?? base.defaultStrokeWidth,
284
+ };
285
+ }
286
+
287
+ // ============================================================================
288
+ // Context & Provider
289
+ // ============================================================================
290
+
291
+ type CameraIconContextValue = {
292
+ config: ResolvedIconConfig;
293
+ updateConfig: (config: CameraIconRegistryConfig) => void;
294
+ getComponent: (key: CameraIconKey) => IconComponent | undefined;
295
+ };
296
+
297
+ const CameraIconContext = createContext<CameraIconContextValue | null>(null);
298
+
299
+ export interface CameraIconProviderProps {
300
+ children: ReactNode;
301
+ config?: CameraIconRegistryConfig;
302
+ }
303
+
304
+ /**
305
+ * Provider component that manages the icon registry and configuration.
306
+ * Wrap your app with this to customize icons throughout the plugin.
307
+ *
308
+ * ```tsx
309
+ * <CameraIconProvider config={{ tintColor: '#FF0000' }}>
310
+ * <App />
311
+ * </CameraIconProvider>
312
+ * ```
313
+ */
314
+ export const CameraIconProvider: FC<CameraIconProviderProps> = ({
315
+ children,
316
+ config: initialConfig,
317
+ }) => {
318
+ // The centralized configuration is the base layer; this provider's own
319
+ // `config` prop layers over it.
320
+ const globalConfig = useSyncExternalStore(
321
+ subscribeToGlobalIconRegistryConfig,
322
+ getGlobalIconRegistryConfig,
323
+ getGlobalIconRegistryConfig
324
+ );
325
+
326
+ const [localConfig, setLocalConfig] = useState<
327
+ CameraIconRegistryConfig | undefined
328
+ >(initialConfig);
329
+
330
+ // Keep the local config in sync when the `config` prop changes after mount.
331
+ // Without this, updates to the provider's config prop would be ignored (the
332
+ // useState initializer only runs once).
333
+ useEffect(() => {
334
+ setLocalConfig(initialConfig);
335
+ }, [initialConfig]);
336
+
337
+ const resolvedConfig = useMemo(
338
+ () => resolveIconConfigOverGlobal(localConfig, globalConfig),
339
+ [localConfig, globalConfig]
340
+ );
341
+
342
+ const handleUpdateConfig = (config: CameraIconRegistryConfig) => {
343
+ setLocalConfig(config);
344
+ };
345
+
346
+ const getComponent = (key: CameraIconKey): IconComponent | undefined => {
347
+ const override = resolvedConfig.overrides[key];
348
+ if (override?.component) {
349
+ return override.component;
350
+ }
351
+ return resolvedConfig.registry.get(key);
352
+ };
353
+
354
+ const value: CameraIconContextValue = useMemo(
355
+ () => ({
356
+ config: resolvedConfig,
357
+ updateConfig: handleUpdateConfig,
358
+ getComponent,
359
+ }),
360
+ [resolvedConfig]
361
+ );
362
+
363
+ return (
364
+ <CameraIconContext.Provider value={value}>
365
+ {children}
366
+ </CameraIconContext.Provider>
367
+ );
368
+ };
369
+
370
+ // ============================================================================
371
+ // Hooks
372
+ // ============================================================================
373
+
374
+ /**
375
+ * The effective config for the calling component: the nearest
376
+ * `CameraIconProvider`'s config when one is mounted, otherwise the centralized
377
+ * configuration set by `setCameraIcons()` (or the shipped defaults).
378
+ *
379
+ * Every hook below funnels through this so icons resolve identically with or
380
+ * without a provider, and so a `setCameraIcons()` call re-renders subscribers.
381
+ */
382
+ function useEffectiveIconConfig(): ResolvedIconConfig {
383
+ const context = useContext(CameraIconContext);
384
+ const globalConfig = useSyncExternalStore(
385
+ subscribeToGlobalIconRegistryConfig,
386
+ getGlobalIconRegistryConfig,
387
+ getGlobalIconRegistryConfig
388
+ );
389
+ return context?.config ?? globalConfig;
390
+ }
391
+
392
+ function componentFor(
393
+ config: ResolvedIconConfig,
394
+ key: CameraIconKey
395
+ ): IconComponent | undefined {
396
+ return config.overrides[key]?.component ?? config.registry.get(key);
397
+ }
398
+
399
+ /**
400
+ * Get the current icon configuration and registry.
401
+ * Use this to access the raw registry or override configuration.
402
+ */
403
+ export function useIconRegistry(): IconRegistry {
404
+ return useEffectiveIconConfig().registry;
405
+ }
406
+
407
+ /**
408
+ * Get a single icon component by key.
409
+ * Returns the component directly, or a fallback if not found.
410
+ *
411
+ * ```tsx
412
+ * const Icon = useIcon('close');
413
+ * return <Icon size={24} color="#FFF" />;
414
+ * ```
415
+ */
416
+ export function useIcon(key: CameraIconKey): IconComponent {
417
+ const config = useEffectiveIconConfig();
418
+ const component = componentFor(config, key);
419
+ if (!component) {
420
+ console.warn(`Icon "${key}" not found in registry, using fallback`);
421
+ return DefaultFallbackIcon;
422
+ }
423
+
424
+ return component;
425
+ }
426
+
427
+ /**
428
+ * Get a rendered icon component with preset props.
429
+ * This is the most convenient way to render icons in most cases.
430
+ *
431
+ * ```tsx
432
+ * return <RenderIcon name="close" size={24} color="#FFF" />;
433
+ * ```
434
+ */
435
+ export function useRenderIcon(): (
436
+ name: CameraIconKey,
437
+ props?: IconProps
438
+ ) => React.ReactElement {
439
+ const config = useEffectiveIconConfig();
440
+
441
+ return (name: CameraIconKey, props?: IconProps) => {
442
+ const Component = componentFor(config, name);
443
+ if (!Component) {
444
+ console.warn(`Icon "${name}" not found in registry`);
445
+ return <DefaultFallbackIcon {...props} />;
446
+ }
447
+
448
+ // Apply config defaults and overrides
449
+ const override = config.overrides[name];
450
+ const finalSize = props?.size ?? override?.size ?? config.defaultSize;
451
+ const finalColor =
452
+ props?.color ??
453
+ override?.tintColor ??
454
+ config.tintColor ??
455
+ config.defaultColor ??
456
+ DEFAULT_ICON_COLOR;
457
+ const finalStrokeWidth =
458
+ props?.strokeWidth ??
459
+ config.defaultStrokeWidth ??
460
+ DEFAULT_ICON_STROKE_WIDTH;
461
+
462
+ return (
463
+ <Component
464
+ {...props}
465
+ size={finalSize}
466
+ color={finalColor}
467
+ strokeWidth={finalStrokeWidth}
468
+ />
469
+ );
470
+ };
471
+ }
472
+
473
+ /**
474
+ * Get the current icon registry configuration as a hook.
475
+ * Useful for accessing tint colors, default sizes, and overrides.
476
+ */
477
+ export function useIconConfig(): ResolvedIconConfig {
478
+ return useEffectiveIconConfig();
479
+ }
480
+
481
+ /**
482
+ * Standalone icon component that reads from the icon registry.
483
+ * Works both inside and outside CameraIconProvider — with no provider it reads
484
+ * the centralized configuration set by `setCameraIcons()`, falling back to the
485
+ * built-in default icons.
486
+ *
487
+ * ```tsx
488
+ * <RenderIcon name="close" size={24} color="#FFF" />
489
+ * ```
490
+ */
491
+ export const RenderIcon: FC<IconProps & { name: CameraIconKey }> = ({ name, ...props }) => {
492
+ const context = useContext(CameraIconContext);
493
+ // Subscribed unconditionally so the hook order stays stable whether or not a
494
+ // provider is mounted above this icon.
495
+ const globalConfig = useSyncExternalStore(
496
+ subscribeToGlobalIconRegistryConfig,
497
+ getGlobalIconRegistryConfig,
498
+ getGlobalIconRegistryConfig
499
+ );
500
+
501
+ let Component: IconComponent | undefined;
502
+ let resolved: ResolvedIconConfig;
503
+
504
+ if (context) {
505
+ resolved = context.config;
506
+ Component = context.getComponent(name);
507
+ } else {
508
+ // No provider — read the centralized config (defaults when unset).
509
+ resolved = globalConfig;
510
+ Component = resolved.overrides[name]?.component ?? resolved.registry.get(name);
511
+ }
512
+
513
+ if (!Component) {
514
+ return <DefaultFallbackIcon {...props} />;
515
+ }
516
+
517
+ // Merge config defaults + overrides; explicit props always win.
518
+ const override = resolved.overrides[name];
519
+ const finalSize = props.size ?? override?.size ?? resolved.defaultSize;
520
+ const finalColor =
521
+ props.color ??
522
+ override?.tintColor ??
523
+ resolved.tintColor ??
524
+ resolved.defaultColor ??
525
+ DEFAULT_ICON_COLOR;
526
+ const finalStrokeWidth =
527
+ props.strokeWidth ?? resolved.defaultStrokeWidth ?? DEFAULT_ICON_STROKE_WIDTH;
528
+
529
+ return (
530
+ <Component
531
+ {...props}
532
+ size={finalSize}
533
+ color={finalColor}
534
+ strokeWidth={finalStrokeWidth}
535
+ />
536
+ );
537
+ };
538
+
539
+ /**
540
+ * Get an icon component by key without requiring a React context.
541
+ * Reads the centralized configuration set by `setCameraIcons()` and falls back
542
+ * to the built-in default icons.
543
+ * Useful in non-component code or when the provider is not available.
544
+ */
545
+ export function getIconComponent(key: CameraIconKey): IconComponent {
546
+ const resolved = getGlobalIconRegistryConfig();
547
+ return (
548
+ resolved.overrides[key]?.component ??
549
+ resolved.registry.get(key) ??
550
+ DefaultFallbackIcon
551
+ );
552
+ }
553
+
554
+ // ============================================================================
555
+ // Configuration Management
556
+ // ============================================================================
557
+
558
+ /**
559
+ * Create or update the global icon configuration.
560
+ * This is called by the plugin's main configure() function.
561
+ */
562
+ export function resolveIconConfig(
563
+ config?: CameraIconRegistryConfig
564
+ ): ResolvedIconConfig {
565
+ return {
566
+ registry: config?.registry ?? createDefaultIconRegistry(),
567
+ overrides: config?.overrides ?? {},
568
+ tintColor: config?.tintColor,
569
+ defaultSize: config?.defaultSize ?? DEFAULT_ICON_SIZE,
570
+ defaultColor: config?.defaultColor ?? DEFAULT_ICON_COLOR,
571
+ defaultStrokeWidth:
572
+ config?.defaultStrokeWidth ?? DEFAULT_ICON_STROKE_WIDTH,
573
+ };
574
+ }
575
+
576
+ /**
577
+ * Merge icon configurations together.
578
+ * Used by the plugin's configuration system to compose icon customizations.
579
+ */
580
+ export function mergeIconConfigs(
581
+ base: CameraIconRegistryConfig,
582
+ override?: Partial<CameraIconRegistryConfig>
583
+ ): CameraIconRegistryConfig {
584
+ if (!override) {
585
+ return base;
586
+ }
587
+
588
+ return {
589
+ registry: override.registry ?? base.registry,
590
+ tintColor: override.tintColor ?? base.tintColor,
591
+ defaultSize: override.defaultSize ?? base.defaultSize,
592
+ defaultColor: override.defaultColor ?? base.defaultColor,
593
+ defaultStrokeWidth:
594
+ override.defaultStrokeWidth ?? base.defaultStrokeWidth,
595
+ overrides: {
596
+ ...(base.overrides ?? {}),
597
+ ...(override.overrides ?? {}),
598
+ },
599
+ };
600
+ }
601
+
602
+ // ============================================================================
603
+ // Default Icon Registry
604
+ // ============================================================================
605
+
606
+ /**
607
+ * Create the default icon registry with built-in icons.
608
+ * These are defined in defaultIcons.tsx and require no external dependencies.
609
+ *
610
+ * Returns a FRESH Map on every call so a consumer that mutates the returned
611
+ * registry cannot corrupt the defaults process-wide.
612
+ */
613
+ export function createDefaultIconRegistry(): IconRegistry {
614
+ // Lazy-import defaults to avoid circular dependencies
615
+ // Actual default icons are defined in defaultIcons.tsx
616
+ const {
617
+ CloseIcon,
618
+ BackIcon,
619
+ DoneIcon,
620
+ CancelIcon,
621
+ CameraIcon,
622
+ VideoIcon,
623
+ PhotoIcon,
624
+ PhotoModeIcon,
625
+ VideoModeIcon,
626
+ FlipIcon,
627
+ FlashOnIcon,
628
+ FlashOffIcon,
629
+ FlashAutoIcon,
630
+ GalleryIcon,
631
+ CropIcon,
632
+ RotateIcon,
633
+ FilterIcon,
634
+ StickerIcon,
635
+ EmojiIcon,
636
+ TextIcon,
637
+ DrawIcon,
638
+ UndoIcon,
639
+ RedoIcon,
640
+ DeleteIcon,
641
+ PlayIcon,
642
+ PauseIcon,
643
+ StopIcon,
644
+ DownloadIcon,
645
+ ShareIcon,
646
+ SendIcon,
647
+ MoreIcon,
648
+ DocumentIcon,
649
+ AudioIcon,
650
+ LockIcon,
651
+ LockOpenIcon,
652
+ ChevronUpIcon,
653
+ ChevronRightIcon,
654
+ CheckIcon,
655
+ VolumeOnIcon,
656
+ VolumeOffIcon,
657
+ MuteIcon,
658
+ WarningIcon,
659
+ TrimIcon,
660
+ CoverIcon,
661
+ CompressIcon,
662
+ ExportIcon,
663
+ UploadIcon,
664
+ MicIcon,
665
+ RecordIcon,
666
+ BrowseAudioIcon,
667
+ ImageVideoIcon,
668
+ PlusIcon,
669
+ MinusIcon,
670
+ PlusCloseIcon,
671
+ CircularSeekIcon,
672
+ ViewDetailsIcon,
673
+ InfoIcon,
674
+ } = require('./defaultIcons');
675
+
676
+ const registry = new Map<CameraIconKey, IconComponent>([
677
+ ['close', CloseIcon],
678
+ ['back', BackIcon],
679
+ ['done', DoneIcon],
680
+ ['cancel', CancelIcon],
681
+ ['camera', CameraIcon],
682
+ ['video', VideoIcon],
683
+ ['photo', PhotoIcon],
684
+ ['photo_mode', PhotoModeIcon],
685
+ ['video_mode', VideoModeIcon],
686
+ ['flip', FlipIcon],
687
+ ['flash_on', FlashOnIcon],
688
+ ['flash_off', FlashOffIcon],
689
+ ['flash_auto', FlashAutoIcon],
690
+ ['gallery', GalleryIcon],
691
+ ['crop', CropIcon],
692
+ ['rotate', RotateIcon],
693
+ ['filter', FilterIcon],
694
+ ['sticker', StickerIcon],
695
+ ['emoji', EmojiIcon],
696
+ ['text', TextIcon],
697
+ ['draw', DrawIcon],
698
+ ['undo', UndoIcon],
699
+ ['redo', RedoIcon],
700
+ ['delete', DeleteIcon],
701
+ ['trash', DeleteIcon],
702
+ ['play', PlayIcon],
703
+ ['pause', PauseIcon],
704
+ ['stop', StopIcon],
705
+ ['download', DownloadIcon],
706
+ ['share', ShareIcon],
707
+ ['send', SendIcon],
708
+ ['more', MoreIcon],
709
+ ['document', DocumentIcon],
710
+ ['audio', AudioIcon],
711
+ ['lock', LockIcon],
712
+ ['lock_open', LockOpenIcon],
713
+ ['chevron_up', ChevronUpIcon],
714
+ ['chevron_right', ChevronRightIcon],
715
+ ['check', CheckIcon],
716
+ ['volume_on', VolumeOnIcon],
717
+ ['volume_off', VolumeOffIcon],
718
+ ['mute', MuteIcon],
719
+ ['warning', WarningIcon],
720
+ ['trim', TrimIcon],
721
+ ['cover', CoverIcon],
722
+ ['compress', CompressIcon],
723
+ ['export', ExportIcon],
724
+ ['upload', UploadIcon],
725
+ ['mic', MicIcon],
726
+ ['record', RecordIcon],
727
+ ['browse_audio', BrowseAudioIcon],
728
+ ['image_video', ImageVideoIcon],
729
+ ['plus', PlusIcon],
730
+ ['minus', MinusIcon],
731
+ ['plus_close', PlusCloseIcon],
732
+ ['circular_seek', CircularSeekIcon],
733
+ ['view_details', ViewDetailsIcon],
734
+ ['info', InfoIcon ?? ViewDetailsIcon],
735
+ ]);
736
+
737
+ return registry;
738
+ }
739
+
740
+ // ============================================================================
741
+ // Fallback Icon
742
+ // ============================================================================
743
+
744
+ /**
745
+ * Simple fallback icon for missing icons.
746
+ * Just renders a simple circle to indicate an icon should be here.
747
+ */
748
+ const DefaultFallbackIcon: IconComponent = ({
749
+ size = DEFAULT_ICON_SIZE,
750
+ color = DEFAULT_FALLBACK_ICON_COLOR,
751
+ strokeWidth = DEFAULT_ICON_STROKE_WIDTH,
752
+ }) => {
753
+ return (
754
+ <View
755
+ style={{
756
+ width: size,
757
+ height: size,
758
+ borderRadius: size / 2,
759
+ borderWidth: strokeWidth,
760
+ borderColor: color as string,
761
+ alignItems: 'center',
762
+ justifyContent: 'center',
763
+ }}
764
+ >
765
+ <Text
766
+ style={{
767
+ fontSize: size * 0.5,
768
+ color: color as string,
769
+ fontWeight: DEFAULT_FALLBACK_ICON_WEIGHT,
770
+ }}
771
+ >
772
+ ?
773
+ </Text>
774
+ </View>
775
+ );
776
+ };
777
+
778
+ export { DefaultFallbackIcon };
779
+
780
+ // ============================================================================
781
+ // Export Default Configuration
782
+ // ============================================================================
783
+
784
+ export const DEFAULT_ICON_REGISTRY_CONFIG: CameraIconRegistryConfig = {
785
+ registry: createDefaultIconRegistry(),
786
+ overrides: {},
787
+ defaultSize: 24,
788
+ };