react-native-compressor 1.6.3 → 1.7.0

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 (181) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +15 -11
  3. package/android/build.gradle +95 -42
  4. package/android/gradle.properties +5 -0
  5. package/android/src/main/AndroidManifest.xml +0 -1
  6. package/android/src/main/AndroidManifestNew.xml +2 -0
  7. package/android/src/main/java/com/reactnativecompressor/CompressorModule.java +88 -33
  8. package/android/src/main/java/com/reactnativecompressor/CompressorPackage.java +47 -19
  9. package/android/src/main/java/com/reactnativecompressor/Image/utils/ImageCompressorOptions.java +1 -1
  10. package/android/src/main/java/com/reactnativecompressor/Utils/Utils.java +1 -1
  11. package/android/src/main/java/com/reactnativecompressor/Video/VideoCompressorHelper.java +7 -4
  12. package/android/src/main/java/com/reactnativecompressor/Video/VideoModule.java +8 -6
  13. package/android/src/newarch/CompressorSpec.java +9 -0
  14. package/android/src/newarch/VideoCompressorSpec.java +9 -0
  15. package/android/src/oldarch/CompressorSpec.java +28 -0
  16. package/android/src/oldarch/VideoCompressorSpec.java +26 -0
  17. package/ios/Compressor.h +7 -0
  18. package/ios/Compressor.mm +395 -0
  19. package/ios/Compressor.xcodeproj/project.pbxproj +6 -36
  20. package/ios/Video/VideoCompressor.swift +2 -2
  21. package/lib/commonjs/Audio/index.js +13 -14
  22. package/lib/commonjs/Audio/index.js.map +1 -1
  23. package/lib/commonjs/Image/index.js +2 -5
  24. package/lib/commonjs/Image/index.js.map +1 -1
  25. package/lib/commonjs/Main.js +29 -0
  26. package/lib/commonjs/Main.js.map +1 -0
  27. package/lib/commonjs/Spec/NativeCompressor.js +10 -0
  28. package/lib/commonjs/Spec/NativeCompressor.js.map +1 -0
  29. package/lib/commonjs/Spec/NativeVideoCompressor.js +10 -0
  30. package/lib/commonjs/Spec/NativeVideoCompressor.js.map +1 -0
  31. package/lib/commonjs/Video/index.js +3 -24
  32. package/lib/commonjs/Video/index.js.map +1 -1
  33. package/lib/commonjs/expo-plugin/compressor.js +1 -4
  34. package/lib/commonjs/expo-plugin/compressor.js.map +1 -1
  35. package/lib/commonjs/index.js +21 -28
  36. package/lib/commonjs/index.js.map +1 -1
  37. package/lib/commonjs/utils/index.js +32 -51
  38. package/lib/commonjs/utils/index.js.map +1 -1
  39. package/lib/module/Audio/index.js +13 -11
  40. package/lib/module/Audio/index.js.map +1 -1
  41. package/lib/module/Image/index.js +2 -3
  42. package/lib/module/Image/index.js.map +1 -1
  43. package/lib/module/Main.js +22 -0
  44. package/lib/module/Main.js.map +1 -0
  45. package/lib/module/Spec/NativeCompressor.js +3 -0
  46. package/lib/module/Spec/NativeCompressor.js.map +1 -0
  47. package/lib/module/Spec/NativeVideoCompressor.js +3 -0
  48. package/lib/module/Spec/NativeVideoCompressor.js.map +1 -0
  49. package/lib/module/Video/index.js +4 -18
  50. package/lib/module/Video/index.js.map +1 -1
  51. package/lib/module/expo-plugin/compressor.js +1 -3
  52. package/lib/module/expo-plugin/compressor.js.map +1 -1
  53. package/lib/module/index.js +8 -5
  54. package/lib/module/index.js.map +1 -1
  55. package/lib/module/utils/index.js +26 -34
  56. package/lib/module/utils/index.js.map +1 -1
  57. package/lib/typescript/Audio/index.d.ts +2 -1
  58. package/lib/typescript/Audio/index.d.ts.map +1 -0
  59. package/lib/typescript/Image/index.d.ts +7 -6
  60. package/lib/typescript/Image/index.d.ts.map +1 -0
  61. package/lib/typescript/Main.d.ts +4 -0
  62. package/lib/typescript/Main.d.ts.map +1 -0
  63. package/lib/typescript/Spec/NativeCompressor.d.ts +12 -0
  64. package/lib/typescript/Spec/NativeCompressor.d.ts.map +1 -0
  65. package/lib/typescript/Spec/NativeVideoCompressor.d.ts +13 -0
  66. package/lib/typescript/Spec/NativeVideoCompressor.d.ts.map +1 -0
  67. package/lib/typescript/Video/index.d.ts +4 -3
  68. package/lib/typescript/Video/index.d.ts.map +1 -0
  69. package/lib/typescript/expo-plugin/compressor.d.ts +2 -3
  70. package/lib/typescript/expo-plugin/compressor.d.ts.map +1 -0
  71. package/lib/typescript/index.d.ts +7 -3
  72. package/lib/typescript/index.d.ts.map +1 -0
  73. package/lib/typescript/utils/index.d.ts +6 -4
  74. package/lib/typescript/utils/index.d.ts.map +1 -0
  75. package/package.json +59 -37
  76. package/react-native-compressor.podspec +24 -1
  77. package/src/Audio/index.tsx +6 -4
  78. package/src/Image/index.tsx +2 -2
  79. package/src/Main.tsx +41 -0
  80. package/src/Spec/NativeCompressor.ts +13 -0
  81. package/src/Spec/NativeVideoCompressor.ts +14 -0
  82. package/src/Video/index.tsx +5 -10
  83. package/src/expo-plugin/compressor.ts +2 -1
  84. package/src/index.tsx +7 -2
  85. package/src/utils/index.tsx +11 -5
  86. package/android/.gradle/6.9/executionHistory/executionHistory.lock +0 -0
  87. package/android/.gradle/6.9/fileChanges/last-build.bin +0 -0
  88. package/android/.gradle/6.9/fileHashes/fileHashes.bin +0 -0
  89. package/android/.gradle/6.9/fileHashes/fileHashes.lock +0 -0
  90. package/android/.gradle/6.9/gc.properties +0 -0
  91. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  92. package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
  93. package/android/.gradle/checksums/checksums.lock +0 -0
  94. package/android/.gradle/checksums/md5-checksums.bin +0 -0
  95. package/android/.gradle/checksums/sha1-checksums.bin +0 -0
  96. package/android/.gradle/vcs-1/gc.properties +0 -0
  97. package/android/.idea/caches/build_file_checksums.ser +0 -0
  98. package/android/.idea/compiler.xml +0 -6
  99. package/android/.idea/gradle.xml +0 -20
  100. package/android/.idea/jarRepositories.xml +0 -45
  101. package/android/.idea/libraries/Gradle__androidx_annotation_annotation_1_1_0.xml +0 -13
  102. package/android/.idea/libraries/Gradle__androidx_appcompat_appcompat_1_0_2_aar.xml +0 -24
  103. package/android/.idea/libraries/Gradle__androidx_arch_core_core_common_2_0_0.xml +0 -11
  104. package/android/.idea/libraries/Gradle__androidx_arch_core_core_runtime_2_0_0_aar.xml +0 -19
  105. package/android/.idea/libraries/Gradle__androidx_asynclayoutinflater_asynclayoutinflater_1_0_0_aar.xml +0 -19
  106. package/android/.idea/libraries/Gradle__androidx_autofill_autofill_1_1_0_aar.xml +0 -16
  107. package/android/.idea/libraries/Gradle__androidx_collection_collection_1_0_0.xml +0 -11
  108. package/android/.idea/libraries/Gradle__androidx_coordinatorlayout_coordinatorlayout_1_0_0_aar.xml +0 -24
  109. package/android/.idea/libraries/Gradle__androidx_core_core_1_1_0_aar.xml +0 -16
  110. package/android/.idea/libraries/Gradle__androidx_cursoradapter_cursoradapter_1_0_0_aar.xml +0 -19
  111. package/android/.idea/libraries/Gradle__androidx_customview_customview_1_0_0_aar.xml +0 -19
  112. package/android/.idea/libraries/Gradle__androidx_documentfile_documentfile_1_0_0_aar.xml +0 -19
  113. package/android/.idea/libraries/Gradle__androidx_drawerlayout_drawerlayout_1_0_0_aar.xml +0 -24
  114. package/android/.idea/libraries/Gradle__androidx_fragment_fragment_1_0_0_aar.xml +0 -24
  115. package/android/.idea/libraries/Gradle__androidx_interpolator_interpolator_1_0_0_aar.xml +0 -19
  116. package/android/.idea/libraries/Gradle__androidx_legacy_legacy_support_core_ui_1_0_0_aar.xml +0 -19
  117. package/android/.idea/libraries/Gradle__androidx_legacy_legacy_support_core_utils_1_0_0_aar.xml +0 -19
  118. package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_common_2_0_0.xml +0 -11
  119. package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_2_0_0_aar.xml +0 -19
  120. package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_core_2_0_0_aar.xml +0 -19
  121. package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_runtime_2_0_0_aar.xml +0 -19
  122. package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_2_0_0_aar.xml +0 -19
  123. package/android/.idea/libraries/Gradle__androidx_loader_loader_1_0_0_aar.xml +0 -19
  124. package/android/.idea/libraries/Gradle__androidx_localbroadcastmanager_localbroadcastmanager_1_0_0_aar.xml +0 -19
  125. package/android/.idea/libraries/Gradle__androidx_print_print_1_0_0_aar.xml +0 -24
  126. package/android/.idea/libraries/Gradle__androidx_slidingpanelayout_slidingpanelayout_1_0_0_aar.xml +0 -19
  127. package/android/.idea/libraries/Gradle__androidx_swiperefreshlayout_swiperefreshlayout_1_0_0_aar.xml +0 -24
  128. package/android/.idea/libraries/Gradle__androidx_vectordrawable_vectordrawable_1_0_1_aar.xml +0 -19
  129. package/android/.idea/libraries/Gradle__androidx_vectordrawable_vectordrawable_animated_1_0_0_aar.xml +0 -19
  130. package/android/.idea/libraries/Gradle__androidx_versionedparcelable_versionedparcelable_1_1_0_aar.xml +0 -13
  131. package/android/.idea/libraries/Gradle__androidx_viewpager_viewpager_1_0_0_aar.xml +0 -19
  132. package/android/.idea/libraries/Gradle__com_facebook_fbjni_fbjni_java_only_0_2_2.xml +0 -13
  133. package/android/.idea/libraries/Gradle__com_facebook_fresco_drawee_2_5_0_aar.xml +0 -15
  134. package/android/.idea/libraries/Gradle__com_facebook_fresco_fbcore_2_5_0_aar.xml +0 -18
  135. package/android/.idea/libraries/Gradle__com_facebook_fresco_fresco_2_5_0_aar.xml +0 -18
  136. package/android/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_2_5_0_aar.xml +0 -18
  137. package/android/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_base_2_5_0_aar.xml +0 -18
  138. package/android/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_native_2_5_0_aar.xml +0 -15
  139. package/android/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_okhttp3_2_5_0_aar.xml +0 -15
  140. package/android/.idea/libraries/Gradle__com_facebook_fresco_memory_type_ashmem_2_5_0_aar.xml +0 -15
  141. package/android/.idea/libraries/Gradle__com_facebook_fresco_memory_type_java_2_5_0_aar.xml +0 -15
  142. package/android/.idea/libraries/Gradle__com_facebook_fresco_memory_type_native_2_5_0_aar.xml +0 -15
  143. package/android/.idea/libraries/Gradle__com_facebook_fresco_nativeimagefilters_2_5_0_aar.xml +0 -15
  144. package/android/.idea/libraries/Gradle__com_facebook_fresco_nativeimagetranscoder_2_5_0_aar.xml +0 -15
  145. package/android/.idea/libraries/Gradle__com_facebook_fresco_ui_common_2_5_0_aar.xml +0 -15
  146. package/android/.idea/libraries/Gradle__com_facebook_infer_annotation_infer_annotation_0_18_0.xml +0 -13
  147. package/android/.idea/libraries/Gradle__com_facebook_react_react_native_0_66_1_aar.xml +0 -14
  148. package/android/.idea/libraries/Gradle__com_facebook_soloader_annotation_0_10_1.xml +0 -13
  149. package/android/.idea/libraries/Gradle__com_facebook_soloader_nativeloader_0_10_1.xml +0 -13
  150. package/android/.idea/libraries/Gradle__com_facebook_soloader_soloader_0_10_1_aar.xml +0 -15
  151. package/android/.idea/libraries/Gradle__com_facebook_yoga_proguard_annotations_1_19_0.xml +0 -13
  152. package/android/.idea/libraries/Gradle__com_google_code_findbugs_jsr305_3_0_2.xml +0 -13
  153. package/android/.idea/libraries/Gradle__com_googlecode_mp4parser_isoparser_1_0_6.xml +0 -13
  154. package/android/.idea/libraries/Gradle__com_squareup_okhttp3_okhttp_4_9_1.xml +0 -13
  155. package/android/.idea/libraries/Gradle__com_squareup_okhttp3_okhttp_urlconnection_4_9_1.xml +0 -13
  156. package/android/.idea/libraries/Gradle__com_squareup_okio_okio_2_9_0.xml +0 -13
  157. package/android/.idea/libraries/Gradle__io_github_lizhangqu_coreprogress_1_0_2_aar.xml +0 -18
  158. package/android/.idea/libraries/Gradle__javax_inject_javax_inject_1.xml +0 -13
  159. package/android/.idea/libraries/Gradle__org_aspectj_aspectjrt_1_8_2.xml +0 -13
  160. package/android/.idea/libraries/Gradle__org_jetbrains_annotations_13_0.xml +0 -13
  161. package/android/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_annotations_jvm_1_3_72.xml +0 -13
  162. package/android/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_4_10.xml +0 -13
  163. package/android/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_common_1_4_10.xml +0 -13
  164. package/android/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_jdk7_1_4_10.xml +0 -13
  165. package/android/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_jdk8_1_4_10.xml +0 -13
  166. package/android/.idea/libraries/Gradle__org_jetbrains_kotlinx_kotlinx_coroutines_android_1_4_0.xml +0 -13
  167. package/android/.idea/libraries/Gradle__org_jetbrains_kotlinx_kotlinx_coroutines_core_jvm_1_4_0.xml +0 -13
  168. package/android/.idea/misc.xml +0 -9
  169. package/android/.idea/modules/android.iml +0 -138
  170. package/android/.idea/modules.xml +0 -8
  171. package/android/.idea/vcs.xml +0 -6
  172. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  173. package/android/gradle/wrapper/gradle-wrapper.properties +0 -5
  174. package/android/gradlew +0 -183
  175. package/android/gradlew.bat +0 -100
  176. package/android/local.properties +0 -8
  177. package/ios/Compressor.m +0 -351
  178. package/ios/Compressor.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  179. package/ios/Compressor.xcodeproj/project.xcworkspace/xcuserdata/apple.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  180. package/ios/Compressor.xcodeproj/xcshareddata/xcschemes/Compressor.xcscheme +0 -67
  181. package/ios/Compressor.xcodeproj/xcuserdata/apple.xcuserdatad/xcschemes/xcschememanagement.plist +0 -22
@@ -0,0 +1,13 @@
1
+ import type { TurboModule } from 'react-native';
2
+ export interface Spec extends TurboModule {
3
+ compress(fileUrl: string, optionMap: Object): Promise<string>;
4
+ cancelCompression(uuid: string): void;
5
+ upload(fileUrl: string, options: Object): Promise<string>;
6
+ activateBackgroundTask(options: Object): Promise<string>;
7
+ deactivateBackgroundTask(options: Object): Promise<string>;
8
+ addListener(eventName: string): void;
9
+ removeListeners(count: number): void;
10
+ }
11
+ declare const _default: Spec;
12
+ export default _default;
13
+ //# sourceMappingURL=NativeVideoCompressor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NativeVideoCompressor.d.ts","sourceRoot":"","sources":["../../../src/Spec/NativeVideoCompressor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC9D,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC1D,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACzD,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC3D,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtC;;AAED,wBAAyE"}
@@ -3,8 +3,8 @@ export declare enum FileSystemUploadType {
3
3
  MULTIPART = 1
4
4
  }
5
5
  export declare type FileSystemAcceptedUploadHttpMethod = 'POST' | 'PUT' | 'PATCH';
6
- export declare type compressionMethod = 'auto' | 'manual';
7
- declare type videoCompresssionType = {
6
+ export type compressionMethod = 'auto' | 'manual';
7
+ type videoCompresssionType = {
8
8
  bitrate?: number;
9
9
  maxSize?: number;
10
10
  compressionMethod?: compressionMethod;
@@ -32,7 +32,7 @@ export declare type FileSystemUploadOptions = ({
32
32
  httpMethod?: FileSystemAcceptedUploadHttpMethod;
33
33
  sessionType?: FileSystemSessionType;
34
34
  };
35
- export declare type VideoCompressorType = {
35
+ export type VideoCompressorType = {
36
36
  compress(fileUrl: string, options?: videoCompresssionType, onProgress?: (progress: number) => void): Promise<string>;
37
37
  cancelCompression(cancellationId: string): void;
38
38
  backgroundUpload(url: string, fileUrl: string, options: FileSystemUploadOptions, onProgress?: (writtem: number, total: number) => void): Promise<any>;
@@ -43,3 +43,4 @@ export declare const backgroundUpload: (url: string, fileUrl: string, options: F
43
43
  export declare const cancelCompression: (cancellationId: string) => any;
44
44
  declare const Video: VideoCompressorType;
45
45
  export default Video;
46
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Video/index.tsx"],"names":[],"mappings":"AAKA,MAAM,CAAC,OAAO,MAAM,oBAAoB;IACtC,cAAc,IAAI;IAClB,SAAS,IAAI;CACd;AAED,MAAM,CAAC,OAAO,MAAM,kCAAkC,GAClD,MAAM,GACN,KAAK,GACL,OAAO,CAAC;AACZ,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,QAAQ,CAAC;AAClD,KAAK,qBAAqB,GAAG;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,0BAA0B,CAAC,EAAE,MAAM,CAAC;IACpC,iBAAiB,CAAC,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,IAAI,CAAC;CACtD,CAAC;AAEF,MAAM,CAAC,OAAO,MAAM,qBAAqB;IACvC,UAAU,IAAI;IACd,UAAU,IAAI;CACf;AAED,MAAM,CAAC,OAAO,MAAM,YAAY,GAAG;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,CAAC,OAAO,MAAM,uBAAuB,GAAG,CAC1C;IACE,UAAU,CAAC,EAAE,oBAAoB,CAAC,cAAc,CAAC;CAClD,GACD;IACE,UAAU,EAAE,oBAAoB,CAAC,SAAS,CAAC;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACrC,CACJ,GAAG;IACF,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,UAAU,CAAC,EAAE,kCAAkC,CAAC;IAChD,WAAW,CAAC,EAAE,qBAAqB,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CACN,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,qBAAqB,EAC/B,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,GACtC,OAAO,CAAC,MAAM,CAAC,CAAC;IACnB,iBAAiB,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAChD,gBAAgB,CACd,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,uBAAuB,EAChC,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,GACpD,OAAO,CAAC,GAAG,CAAC,CAAC;IAChB,sBAAsB,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IACtE,wBAAwB,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC;CAC1C,CAAC;AAMF,eAAO,MAAM,gBAAgB,QACtB,MAAM,WACF,MAAM,WACN,uBAAuB,0BACT,MAAM,SAAS,MAAM,KAAK,IAAI,kBACpD,QAAQ,GAAG,CA8Bb,CAAC;AAEF,eAAO,MAAM,iBAAiB,mBAAoB,MAAM,QAEvD,CAAC;AAEF,QAAA,MAAM,KAAK,EAAE,mBA6EW,CAAC;AAEzB,eAAe,KAAK,CAAC"}
@@ -1,4 +1,3 @@
1
- import { ConfigPlugin } from '@expo/config-plugins';
2
- declare type Props = {};
3
- declare const _default: ConfigPlugin<Props>;
1
+ declare const _default: any;
4
2
  export default _default;
3
+ //# sourceMappingURL=compressor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compressor.d.ts","sourceRoot":"","sources":["../../../src/expo-plugin/compressor.ts"],"names":[],"mappings":";AAQA,wBAA0E"}
@@ -1,8 +1,10 @@
1
- import Video, { VideoCompressorType, backgroundUpload } from './Video';
1
+ import Video, { backgroundUpload } from './Video';
2
+ import type { VideoCompressorType } from './Video';
2
3
  import Audio from './Audio';
3
4
  import Image from './Image';
4
- import { getDetails, uuidv4, generateFilePath, getRealPath, getVideoMetaData } from './utils';
5
- export { Video, Audio, Image, backgroundUpload, VideoCompressorType, getDetails, uuidv4, generateFilePath, getRealPath, getVideoMetaData, };
5
+ import { getDetails, uuidv4, generateFilePath, getRealPath, getVideoMetaData, getFileSize } from './utils';
6
+ export { Video, Audio, Image, backgroundUpload, getDetails, uuidv4, generateFilePath, getRealPath, getVideoMetaData, getFileSize, };
7
+ export type { VideoCompressorType };
6
8
  declare const _default: {
7
9
  Video: VideoCompressorType;
8
10
  Audio: import("./utils").AudioType;
@@ -15,5 +17,7 @@ declare const _default: {
15
17
  generateFilePath: any;
16
18
  getRealPath: any;
17
19
  getVideoMetaData: any;
20
+ getFileSize: (filePath: string) => Promise<string>;
18
21
  };
19
22
  export default _default;
23
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,EACL,UAAU,EACV,MAAM,EACN,gBAAgB,EAChB,WAAW,EACX,gBAAgB,EAChB,WAAW,EACZ,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,gBAAgB,EAGhB,UAAU,EACV,MAAM,EACN,gBAAgB,EAChB,WAAW,EACX,gBAAgB,EAChB,WAAW,GACZ,CAAC;AACF,YAAY,EAAE,mBAAmB,EAAE,CAAC;;;;;;;;;;;;;;;AACpC,wBAWE"}
@@ -1,17 +1,17 @@
1
1
  export declare const AUDIO_BITRATE: number[];
2
- declare type qualityType = 'low' | 'medium' | 'high';
3
- declare type audioCompresssionType = {
2
+ type qualityType = 'low' | 'medium' | 'high';
3
+ type audioCompresssionType = {
4
4
  bitrate?: number;
5
5
  quality: qualityType;
6
6
  outputFilePath?: string | undefined | null;
7
7
  };
8
- export declare type defaultResultType = {
8
+ export type defaultResultType = {
9
9
  outputFilePath: string | undefined | null;
10
10
  isCorrect: boolean;
11
11
  message: string;
12
12
  };
13
13
  export declare const DEFAULT_COMPRESS_AUDIO_OPTIONS: audioCompresssionType;
14
- export declare type AudioType = {
14
+ export type AudioType = {
15
15
  compress(value: string, options?: audioCompresssionType): Promise<string>;
16
16
  };
17
17
  export declare const generateFilePath: any;
@@ -19,5 +19,7 @@ export declare const getRealPath: any;
19
19
  export declare const getVideoMetaData: any;
20
20
  export declare const getDetails: (mediaFullPath: string, extesnion?: 'mp3' | 'mp4') => Promise<any | null>;
21
21
  export declare const checkUrlAndOptions: (url: string, options: audioCompresssionType) => Promise<defaultResultType>;
22
+ export declare const getFileSize: (filePath: string) => Promise<string>;
22
23
  export declare const uuidv4: () => string;
23
24
  export {};
25
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,aAAa,UAAmC,CAAC;AAC9D,KAAK,WAAW,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AAM7C,KAAK,qBAAqB,GAAG;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,WAAW,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;CAC5C,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,cAAc,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;IAC1C,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,8BAA8B,EAAE,qBAI5C,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC3E,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,GAM9B,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,GAKzB,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,GAE9B,CAAC;AA2CF,eAAO,MAAM,UAAU,kBACN,MAAM,cACV,KAAK,GAAG,KAAK,KACvB,QAAQ,GAAG,GAAG,IAAI,CA6BpB,CAAC;AAEF,eAAO,MAAM,kBAAkB,QACxB,MAAM,WACF,qBAAqB,KAC7B,QAAQ,iBAAiB,CAsC3B,CAAC;AAEF,eAAO,MAAM,WAAW,aAAoB,MAAM,KAAG,QAAQ,MAAM,CAElE,CAAC;AAEF,eAAO,MAAM,MAAM,cAclB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-compressor",
3
- "version": "1.6.3",
3
+ "version": "1.7.0",
4
4
  "description": "This library compress image, video and audio",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -14,23 +14,30 @@
14
14
  "ios",
15
15
  "cpp",
16
16
  "app.plugin.js",
17
- "react-native-compressor.podspec",
17
+ "*.podspec",
18
18
  "!lib/typescript/example",
19
- "!android/build",
20
19
  "!ios/build",
20
+ "!android/build",
21
+ "!android/gradle",
22
+ "!android/gradlew",
23
+ "!android/gradlew.bat",
24
+ "!android/local.properties",
21
25
  "!**/__tests__",
22
26
  "!**/__fixtures__",
23
- "!**/__mocks__"
27
+ "!**/__mocks__",
28
+ "!**/.*"
24
29
  ],
25
30
  "scripts": {
26
31
  "test": "jest",
27
- "typescript": "tsc --noEmit",
32
+ "typecheck": "tsc --noEmit",
28
33
  "lint": "eslint \"**/*.{js,ts,tsx}\"",
29
- "prepare": "bob build",
34
+ "prepack": "bob build",
30
35
  "release": "release-it",
31
36
  "example": "yarn --cwd example",
32
- "pods": "cd example && pod-install --quiet",
33
- "bootstrap": "yarn example && yarn && yarn pods"
37
+ "build:android": "cd example/android && ./gradlew assembleDebug --no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a",
38
+ "build:ios": "cd example/ios && xcodebuild -workspace CompressorExample.xcworkspace -scheme CompressorExample -configuration Debug -sdk iphonesimulator CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ GCC_OPTIMIZATION_LEVEL=0 GCC_PRECOMPILE_PREFIX_HEADER=YES ASSETCATALOG_COMPILER_OPTIMIZATION=time DEBUG_INFORMATION_FORMAT=dwarf COMPILER_INDEX_STORE_ENABLE=NO",
39
+ "bootstrap": "yarn example && yarn install && yarn example pods-newarch",
40
+ "clean": "del-cli android/build example/android/build example/android/app/build example/ios/build"
34
41
  },
35
42
  "keywords": [
36
43
  "react-native",
@@ -48,43 +55,50 @@
48
55
  "react-native-compressor",
49
56
  "compress-audio"
50
57
  ],
51
- "repository": "https://github.com/Shobbak/react-native-compressor",
52
- "author": "shobbak <github@onshobbak.com> (https://github.com/Shobbak)",
58
+ "repository": "https://github.com/numandev1/react-native-compressor",
59
+ "author": "numandev1 <muhammadnuman70@gmail.com> (https://github.com/numandev1)",
53
60
  "license": "MIT",
54
61
  "bugs": {
55
- "url": "https://github.com/Shobbak/react-native-compressor/issues"
62
+ "url": "https://github.com/numandev1/react-native-compressor/issues"
56
63
  },
57
- "homepage": "https://github.com/Shobbak/react-native-compressor#readme",
64
+ "homepage": "https://github.com/numandev1/react-native-compressor#readme",
58
65
  "publishConfig": {
59
66
  "registry": "https://registry.npmjs.org/"
60
67
  },
61
68
  "devDependencies": {
62
- "@commitlint/config-conventional": "^11.0.0",
63
- "@expo/config-plugins": "^4.0.14",
64
- "@jamesacarr/eslint-formatter-github-actions": "^0.1.0",
65
- "@react-native-community/eslint-config": "^2.0.0",
66
- "@release-it/conventional-changelog": "^2.0.0",
67
- "@types/jest": "^26.0.0",
68
- "@types/react": "^17.0.8",
69
- "@types/react-native": "^0.64.7",
70
- "commitlint": "^11.0.0",
71
- "eslint": "^7.2.0",
72
- "eslint-config-prettier": "^7.0.0",
73
- "eslint-plugin-prettier": "^3.1.3",
74
- "husky": "^4.2.5",
75
- "jest": "^26.0.1",
69
+ "@commitlint/config-conventional": "^17.0.2",
70
+ "@evilmartians/lefthook": "^1.2.2",
71
+ "@react-native-community/eslint-config": "^3.0.2",
72
+ "@release-it/conventional-changelog": "^5.0.0",
73
+ "@types/jest": "^28.1.2",
74
+ "@types/react": "~17.0.21",
75
+ "@types/react-native": "0.70.0",
76
+ "commitlint": "^17.0.2",
77
+ "del-cli": "^5.0.0",
78
+ "eslint": "^8.4.1",
79
+ "eslint-config-prettier": "^8.5.0",
80
+ "eslint-plugin-prettier": "^4.0.0",
81
+ "jest": "^28.1.1",
76
82
  "pod-install": "^0.1.0",
77
83
  "prettier": "^2.0.5",
78
- "react": "^17.0.2",
79
- "react-native": "^0.66.1",
80
- "react-native-builder-bob": "^0.18.0",
81
- "release-it": "^14.2.2",
82
- "typescript": "^4.1.3"
84
+ "react": "18.2.0",
85
+ "react-native": "0.72.4",
86
+ "react-native-builder-bob": "^0.20.0",
87
+ "release-it": "^15.0.0",
88
+ "turbo": "^1.10.7",
89
+ "typescript": "^5.0.2"
90
+ },
91
+ "resolutions": {
92
+ "@types/react": "17.0.21"
83
93
  },
84
94
  "peerDependencies": {
85
95
  "react": "*",
86
96
  "react-native": "*"
87
97
  },
98
+ "engines": {
99
+ "node": ">= 16.0.0"
100
+ },
101
+ "packageManager": "^yarn@1.22.15",
88
102
  "jest": {
89
103
  "preset": "react-native",
90
104
  "modulePathIgnorePatterns": [
@@ -92,12 +106,6 @@
92
106
  "<rootDir>/lib/"
93
107
  ]
94
108
  },
95
- "husky": {
96
- "hooks": {
97
- "commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
98
- "pre-commit": "yarn lint && yarn typescript"
99
- }
100
- },
101
109
  "commitlint": {
102
110
  "extends": [
103
111
  "@commitlint/config-conventional"
@@ -163,5 +171,19 @@
163
171
  }
164
172
  ]
165
173
  ]
174
+ },
175
+ "codegenConfig": {
176
+ "libraries": [
177
+ {
178
+ "name": "RNCompressorSpec",
179
+ "type": "modules",
180
+ "jsSrcsDir": "src"
181
+ },
182
+ {
183
+ "name": "RNVideoCompressorSpec",
184
+ "type": "modules",
185
+ "jsSrcsDir": "src"
186
+ }
187
+ ]
166
188
  }
167
189
  }
@@ -1,6 +1,7 @@
1
1
  require "json"
2
2
 
3
3
  package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+ folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
4
5
 
5
6
  Pod::Spec.new do |s|
6
7
  s.name = "react-native-compressor"
@@ -11,10 +12,32 @@ Pod::Spec.new do |s|
11
12
  s.authors = package["author"]
12
13
 
13
14
  s.platforms = { :ios => "11.0" }
14
- s.source = { :git => "https://github.com/Shobbak/react-native-compressor.git", :tag => "#{s.version}" }
15
+ s.source = { :git => "https://github.com/numandev1/react-native-compressor.git", :tag => "#{s.version}" }
15
16
 
16
17
  s.source_files = "ios/**/*.{h,m,mm,swift}"
17
18
 
18
19
  s.dependency "React-Core"
19
20
  s.dependency "NextLevelSessionExporter"
21
+ # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
22
+ # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
23
+ if respond_to?(:install_modules_dependencies, true)
24
+ install_modules_dependencies(s)
25
+ else
26
+ s.dependency "React-Core"
27
+
28
+ # Don't install the dependencies when we run `pod install` in the old architecture.
29
+ if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
30
+ s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
31
+ s.pod_target_xcconfig = {
32
+ "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
33
+ "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
34
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
35
+ }
36
+ s.dependency "React-Codegen"
37
+ s.dependency "RCT-Folly"
38
+ s.dependency "RCTRequired"
39
+ s.dependency "RCTTypeSafety"
40
+ s.dependency "ReactCommon/turbomodule/core"
41
+ end
42
+ end
20
43
  end
@@ -1,12 +1,12 @@
1
- import { NativeModules } from 'react-native';
1
+ import { Compressor } from '../Main';
2
+
2
3
  import {
3
4
  AUDIO_BITRATE,
4
- AudioType,
5
5
  DEFAULT_COMPRESS_AUDIO_OPTIONS,
6
- defaultResultType,
7
6
  checkUrlAndOptions,
8
7
  } from '../utils';
9
- const NativeAudio = NativeModules.Compressor;
8
+ import type { AudioType, defaultResultType } from '../utils';
9
+ const NativeAudio = Compressor;
10
10
 
11
11
  const Audio: AudioType = {
12
12
  compress: async (url, options = DEFAULT_COMPRESS_AUDIO_OPTIONS) => {
@@ -31,6 +31,7 @@ const Audio: AudioType = {
31
31
  // Check and return the appropriate bitrate according to quality expected
32
32
  for (let i = 0; i < AUDIO_BITRATE.length; i++) {
33
33
  // Check a particular bitrate to return its nearest lower according to quality
34
+ //@ts-ignore
34
35
  if (mediaDetails.bitrate > AUDIO_BITRATE[i]) {
35
36
  if (i + 2 < AUDIO_BITRATE.length) {
36
37
  if (options.quality === 'low') bitrate = AUDIO_BITRATE[i + 2];
@@ -46,6 +47,7 @@ const Audio: AudioType = {
46
47
 
47
48
  // Check if the matching bitrate is the last in the array
48
49
  if (
50
+ //@ts-ignore
49
51
  mediaDetails.bitrate <= AUDIO_BITRATE[AUDIO_BITRATE.length - 1]
50
52
  ) {
51
53
  bitrate = AUDIO_BITRATE[AUDIO_BITRATE.length - 1];
@@ -1,4 +1,4 @@
1
- import { NativeModules } from 'react-native';
1
+ import { Compressor } from '../Main';
2
2
  const base64UrlRegex = /^data:image\/.*;(?:charset=.{3,5};)?base64,/;
3
3
 
4
4
  export type InputType = 'base64' | 'uri';
@@ -40,7 +40,7 @@ export type CompressorOptions = {
40
40
  returnableOutputType?: ReturnableOutputType;
41
41
  };
42
42
 
43
- const NativeImage = NativeModules.Compressor;
43
+ const NativeImage = Compressor;
44
44
 
45
45
  type ImageType = {
46
46
  compress(value: string, options?: CompressorOptions): Promise<string>;
package/src/Main.tsx ADDED
@@ -0,0 +1,41 @@
1
+ import { NativeModules, Platform } from 'react-native';
2
+
3
+ const LINKING_ERROR =
4
+ `The package 'react-native-compressor' doesn't seem to be linked. Make sure: \n\n` +
5
+ Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
6
+ '- You rebuilt the app after installing the package\n' +
7
+ '- You are not using Expo Go\n';
8
+
9
+ // @ts-expect-error
10
+ const isTurboModuleEnabled = global.__turboModuleProxy != null;
11
+
12
+ const CompressorModule = isTurboModuleEnabled
13
+ ? require('./Spec/NativeCompressor').default
14
+ : NativeModules.Compressor;
15
+ const VideoCompressorModule = isTurboModuleEnabled
16
+ ? require('./Spec/NativeVideoCompressor').default
17
+ : NativeModules.VideoCompressor;
18
+
19
+ const Compressor = CompressorModule
20
+ ? CompressorModule
21
+ : new Proxy(
22
+ {},
23
+ {
24
+ get() {
25
+ throw new Error(LINKING_ERROR);
26
+ },
27
+ }
28
+ );
29
+
30
+ const VideoCompressor = VideoCompressorModule
31
+ ? VideoCompressorModule
32
+ : new Proxy(
33
+ {},
34
+ {
35
+ get() {
36
+ throw new Error(LINKING_ERROR);
37
+ },
38
+ }
39
+ );
40
+
41
+ export { Compressor, VideoCompressor };
@@ -0,0 +1,13 @@
1
+ import type { TurboModule } from 'react-native';
2
+ import { TurboModuleRegistry } from 'react-native';
3
+
4
+ export interface Spec extends TurboModule {
5
+ image_compress(imagePath: string, optionMap: Object): Promise<string>;
6
+ compress_audio(fileUrl: string, optionMap: Object): Promise<string>;
7
+ generateFilePath(extension: string): Promise<string>;
8
+ getRealPath(path: string, type: string): Promise<string>;
9
+ getVideoMetaData(filePath: string): Promise<string>;
10
+ getFileSize(filePath: string): Promise<string>;
11
+ }
12
+
13
+ export default TurboModuleRegistry.getEnforcing<Spec>('Compressor');
@@ -0,0 +1,14 @@
1
+ import type { TurboModule } from 'react-native';
2
+ import { TurboModuleRegistry } from 'react-native';
3
+
4
+ export interface Spec extends TurboModule {
5
+ compress(fileUrl: string, optionMap: Object): Promise<string>;
6
+ cancelCompression(uuid: string): void;
7
+ upload(fileUrl: string, options: Object): Promise<string>;
8
+ activateBackgroundTask(options: Object): Promise<string>;
9
+ deactivateBackgroundTask(options: Object): Promise<string>;
10
+ addListener(eventName: string): void;
11
+ removeListeners(count: number): void;
12
+ }
13
+
14
+ export default TurboModuleRegistry.getEnforcing<Spec>('VideoCompressor');
@@ -1,9 +1,6 @@
1
- import {
2
- NativeModules,
3
- NativeEventEmitter,
4
- Platform,
5
- NativeEventSubscription,
6
- } from 'react-native';
1
+ import { NativeEventEmitter, Platform } from 'react-native';
2
+ import type { NativeEventSubscription } from 'react-native';
3
+ import { VideoCompressor } from '../Main';
7
4
  import { uuidv4 } from '../utils';
8
5
 
9
6
  export declare enum FileSystemUploadType {
@@ -68,11 +65,9 @@ export type VideoCompressorType = {
68
65
  deactivateBackgroundTask(): Promise<any>;
69
66
  };
70
67
 
71
- const VideoCompressEventEmitter = new NativeEventEmitter(
72
- NativeModules.VideoCompressor
73
- );
68
+ const VideoCompressEventEmitter = new NativeEventEmitter(VideoCompressor);
74
69
 
75
- const NativeVideoCompressor = NativeModules.VideoCompressor;
70
+ const NativeVideoCompressor = VideoCompressor;
76
71
 
77
72
  export const backgroundUpload = async (
78
73
  url: string,
@@ -1,8 +1,9 @@
1
+ //@ts-ignore
1
2
  import { ConfigPlugin, createRunOncePlugin } from '@expo/config-plugins';
2
3
  const pkg = require('../../../package.json');
3
4
 
4
5
  type Props = {};
5
6
 
6
- const withCompressor: ConfigPlugin<Props> = (config) => config;
7
+ const withCompressor: ConfigPlugin<Props> = (config:any) => config;
7
8
 
8
9
  export default createRunOncePlugin(withCompressor, pkg.name, pkg.version);
package/src/index.tsx CHANGED
@@ -1,4 +1,5 @@
1
- import Video, { VideoCompressorType, backgroundUpload } from './Video';
1
+ import Video, { backgroundUpload } from './Video';
2
+ import type { VideoCompressorType } from './Video';
2
3
  import Audio from './Audio';
3
4
  import Image from './Image';
4
5
  import {
@@ -7,6 +8,7 @@ import {
7
8
  generateFilePath,
8
9
  getRealPath,
9
10
  getVideoMetaData,
11
+ getFileSize,
10
12
  } from './utils';
11
13
 
12
14
  export {
@@ -15,13 +17,15 @@ export {
15
17
  Image,
16
18
  backgroundUpload,
17
19
  //type
18
- VideoCompressorType,
20
+
19
21
  getDetails,
20
22
  uuidv4,
21
23
  generateFilePath,
22
24
  getRealPath,
23
25
  getVideoMetaData,
26
+ getFileSize,
24
27
  };
28
+ export type { VideoCompressorType };
25
29
  export default {
26
30
  Video,
27
31
  Audio,
@@ -32,4 +36,5 @@ export default {
32
36
  generateFilePath,
33
37
  getRealPath,
34
38
  getVideoMetaData,
39
+ getFileSize,
35
40
  };
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable no-bitwise */
2
- import { NativeModules } from 'react-native';
3
- const { Compressor } = NativeModules;
2
+ import { Compressor } from '../Main';
3
+
4
4
  export const AUDIO_BITRATE = [256, 192, 160, 128, 96, 64, 32];
5
5
  type qualityType = 'low' | 'medium' | 'high';
6
6
  const INCORRECT_INPUT_PATH = 'Incorrect input path. Please provide a valid one';
@@ -76,8 +76,8 @@ const isFileNameError = (filename: string) => {
76
76
  };
77
77
 
78
78
  const getFilename = (path: string | null) => {
79
- const fullFilename = getFullFilename(path);
80
- if (!isFileNameError(fullFilename)) {
79
+ const fullFilename: string | undefined = getFullFilename(path);
80
+ if (fullFilename && !isFileNameError(fullFilename)) {
81
81
  const array = fullFilename.split('.');
82
82
  return array.length > 1 ? array.slice(0, -1).join('') : array.join('');
83
83
  }
@@ -85,7 +85,9 @@ const getFilename = (path: string | null) => {
85
85
  };
86
86
 
87
87
  const isRemoteMedia = (path: string | null) => {
88
- return typeof path === 'string' ? path.split(':/')[0].includes('http') : null;
88
+ return typeof path === 'string'
89
+ ? path?.split(':/')?.[0]?.includes('http')
90
+ : null;
89
91
  };
90
92
 
91
93
  export const getDetails = (
@@ -165,6 +167,10 @@ export const checkUrlAndOptions = async (
165
167
  }
166
168
  };
167
169
 
170
+ export const getFileSize = async (filePath: string): Promise<string> => {
171
+ return Compressor.getFileSize(filePath);
172
+ };
173
+
168
174
  export const uuidv4 = () => {
169
175
  return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
170
176
  const r =
File without changes
@@ -1,2 +0,0 @@
1
- #Thu Jan 27 18:54:59 PKT 2022
2
- gradle.version=6.9
File without changes
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="CompilerConfiguration">
4
- <bytecodeTargetLevel target="1.8" />
5
- </component>
6
- </project>
@@ -1,20 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="GradleMigrationSettings" migrationVersion="1" />
4
- <component name="GradleSettings">
5
- <option name="linkedExternalProjectsSettings">
6
- <GradleProjectSettings>
7
- <option name="testRunner" value="GRADLE" />
8
- <option name="distributionType" value="DEFAULT_WRAPPED" />
9
- <option name="externalProjectPath" value="$PROJECT_DIR$" />
10
- <option name="gradleJvm" value="1.8" />
11
- <option name="modules">
12
- <set>
13
- <option value="$PROJECT_DIR$" />
14
- </set>
15
- </option>
16
- <option name="resolveModulePerSourceSet" value="false" />
17
- </GradleProjectSettings>
18
- </option>
19
- </component>
20
- </project>