react-native-compressor 1.11.0 → 1.13.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.
@@ -58,7 +58,7 @@ class AudioHelper {
58
58
  var destinationBitrate = originalBitrate
59
59
  Utils.addLog("source bitrate: $originalBitrate")
60
60
 
61
- when (quality.toLowerCase()) {
61
+ when (quality.lowercase()) {
62
62
  "low" -> destinationBitrate = maxOf(64, (originalBitrate * 0.3).toInt())
63
63
  "medium" -> destinationBitrate = (originalBitrate * 0.5).toInt()
64
64
  "high" -> destinationBitrate = minOf(320, (originalBitrate * 0.7).toInt())
@@ -161,7 +161,7 @@ class Uploader(private val reactContext: ReactApplicationContext) {
161
161
  if (mimeType == null) {
162
162
  val fileExtension = MimeTypeMap.getFileExtensionFromUrl(fileUri.toString())
163
163
  if (fileExtension != null) {
164
- return MimeTypeMap.getSingleton().getMimeTypeFromExtension(fileExtension.toLowerCase())
164
+ return MimeTypeMap.getSingleton().getMimeTypeFromExtension(fileExtension.lowercase())
165
165
  }
166
166
  }
167
167
 
@@ -7,10 +7,6 @@
7
7
 
8
8
 
9
9
  import AVFoundation
10
-
11
-
12
-
13
- let AlAsset_Library_Scheme = "assets-library"
14
10
  class AudioMain{
15
11
  static func compress_audio(_ fileUrl: String, optionMap: NSDictionary, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
16
12
  do {
@@ -366,18 +366,10 @@ class ImageCompressor {
366
366
  var size = CGSize.zero
367
367
  var scale: CGFloat = 1
368
368
  var resizeMode = RCTResizeMode.contain
369
- var assetID = ""
370
- var results: PHFetchResult<PHAsset>?
369
+ let assetID = imagePath.replacingOccurrences(of: "ph://", with: "")
370
+ let results = PHAsset.fetchAssets(withLocalIdentifiers: [assetID], options: nil)
371
371
 
372
- if imageURL?.scheme?.caseInsensitiveCompare("assets-library") == .orderedSame {
373
- assetID = imageURL?.absoluteString ?? ""
374
- results = PHAsset.fetchAssets(withALAssetURLs: [imageURL!], options: nil)
375
- } else {
376
- assetID = imagePath.replacingOccurrences(of: "ph://", with: "")
377
- results = PHAsset.fetchAssets(withLocalIdentifiers: [assetID], options: nil)
378
- }
379
-
380
- guard let asset = results?.firstObject else {
372
+ guard let asset = results.firstObject else {
381
373
  return
382
374
  }
383
375
 
@@ -17,10 +17,7 @@ class Utils {
17
17
  }
18
18
 
19
19
  static func makeValidUri(filePath: String) -> String {
20
- let fileWithUrl = URL(fileURLWithPath: filePath)
21
- let absoluteUrl = fileWithUrl.deletingLastPathComponent()
22
- let fileUrl = "file://\(absoluteUrl.path)/\(fileWithUrl.lastPathComponent)"
23
- return fileUrl;
20
+ return (filePath.starts(with: "file://") ? URL(string: filePath)! : URL(fileURLWithPath: filePath)).absoluteURL.absoluteString
24
21
  }
25
22
 
26
23
  static func getFileSize(from urlString: String, completion: @escaping (NSNumber?, Error?) -> Void) {
@@ -1,5 +1,4 @@
1
1
  import Foundation
2
- import AssetsLibrary
3
2
  import AVFoundation
4
3
  import Photos
5
4
  import MobileCoreServices
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-compressor",
3
- "version": "1.11.0",
3
+ "version": "1.13.0",
4
4
  "description": "Compress Image, Video, and Audio same like Whatsapp & Auto/Manual Compression | Background Upload | Download File | Create Video Thumbnail",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",