react-native-compressor 1.19.0 → 2.0.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.
- package/android/CMakeLists.txt +27 -0
- package/android/build.gradle +56 -58
- package/android/gradle.properties +5 -5
- package/android/src/main/AndroidManifestNew.xml +3 -0
- package/android/src/main/cpp/cpp-adapter.cpp +8 -0
- package/android/src/main/java/com/margelo/nitro/compressor/HybridCompressor.kt +213 -0
- package/android/src/main/java/com/reactnativecompressor/NitroCompressorPackage.kt +30 -0
- package/android/src/main/java/com/reactnativecompressor/NitroPromiseAdapter.kt +55 -0
- package/android/src/main/java/com/reactnativecompressor/Utils/EventEmitterHandler.kt +49 -45
- package/android/src/main/java/com/reactnativecompressor/Utils/Utils.kt +1 -1
- package/android/src/main/java/com/reactnativecompressor/Video/VideoCompressor/compressor/Compressor.kt +13 -22
- package/android/src/main/java/com/reactnativecompressor/Video/VideoCompressor/utils/CompressorUtils.kt +72 -0
- package/android/src/main/java/com/reactnativecompressor/Video/VideoCompressorHelper.kt +4 -1
- package/ios/Audio/FormatConverter/FormatConverter+Compressed.swift +1 -1
- package/ios/Audio/FormatConverter/FormatConverter+Utilities.swift +1 -1
- package/ios/Audio/FormatConverter/FormatConverter.swift +5 -3
- package/ios/HybridCompressor.swift +247 -0
- package/ios/Image/ImageCompressor.swift +8 -2
- package/ios/Utils/EventEmitterHandler.swift +56 -34
- package/ios/Video/NextLevelSessionExporter.swift +43 -8
- package/ios/Video/VideoMain.swift +17 -3
- package/lib/commonjs/Audio/index.js +1 -1
- package/lib/commonjs/Audio/index.js.map +1 -1
- package/lib/commonjs/Image/index.js +2 -22
- package/lib/commonjs/Image/index.js.map +1 -1
- package/lib/commonjs/Main.js +8 -8
- package/lib/commonjs/Main.js.map +1 -1
- package/lib/commonjs/Video/index.js +25 -65
- package/lib/commonjs/Video/index.js.map +1 -1
- package/lib/commonjs/specs/Compressor.nitro.js +6 -0
- package/lib/commonjs/specs/Compressor.nitro.js.map +1 -0
- package/lib/commonjs/utils/Downloader.js +8 -24
- package/lib/commonjs/utils/Downloader.js.map +1 -1
- package/lib/commonjs/utils/Uploader.js +3 -18
- package/lib/commonjs/utils/Uploader.js.map +1 -1
- package/lib/commonjs/utils/helpers.js +18 -1
- package/lib/commonjs/utils/helpers.js.map +1 -1
- package/lib/commonjs/utils/index.js +13 -13
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/module/Audio/index.js +2 -2
- package/lib/module/Audio/index.js.map +1 -1
- package/lib/module/Image/index.js +3 -23
- package/lib/module/Image/index.js.map +1 -1
- package/lib/module/Main.js +9 -9
- package/lib/module/Main.js.map +1 -1
- package/lib/module/Video/index.js +26 -66
- package/lib/module/Video/index.js.map +1 -1
- package/lib/module/specs/Compressor.nitro.js +4 -0
- package/lib/module/specs/Compressor.nitro.js.map +1 -0
- package/lib/module/utils/Downloader.js +10 -26
- package/lib/module/utils/Downloader.js.map +1 -1
- package/lib/module/utils/Uploader.js +5 -20
- package/lib/module/utils/Uploader.js.map +1 -1
- package/lib/module/utils/helpers.js +16 -0
- package/lib/module/utils/helpers.js.map +1 -1
- package/lib/module/utils/index.js +2 -1
- package/lib/module/utils/index.js.map +1 -1
- package/lib/typescript/src/Image/index.d.ts.map +1 -1
- package/lib/typescript/src/Main.d.ts +2 -1
- package/lib/typescript/src/Main.d.ts.map +1 -1
- package/lib/typescript/src/Video/index.d.ts +1 -1
- package/lib/typescript/src/Video/index.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/Compressor.nitro.d.ts +44 -0
- package/lib/typescript/src/specs/Compressor.nitro.d.ts.map +1 -0
- package/lib/typescript/src/utils/Downloader.d.ts.map +1 -1
- package/lib/typescript/src/utils/Uploader.d.ts.map +1 -1
- package/lib/typescript/src/utils/helpers.d.ts +7 -0
- package/lib/typescript/src/utils/helpers.d.ts.map +1 -1
- package/lib/typescript/src/utils/index.d.ts.map +1 -1
- package/nitrogen/generated/android/NitroCompressor+autolinking.cmake +81 -0
- package/nitrogen/generated/android/NitroCompressor+autolinking.gradle +27 -0
- package/nitrogen/generated/android/NitroCompressorOnLoad.cpp +60 -0
- package/nitrogen/generated/android/NitroCompressorOnLoad.hpp +34 -0
- package/nitrogen/generated/android/c++/JFunc_void.hpp +75 -0
- package/nitrogen/generated/android/c++/JFunc_void_double.hpp +75 -0
- package/nitrogen/generated/android/c++/JFunc_void_double_double.hpp +75 -0
- package/nitrogen/generated/android/c++/JHybridCompressorSpec.cpp +293 -0
- package/nitrogen/generated/android/c++/JHybridCompressorSpec.hpp +78 -0
- package/nitrogen/generated/android/c++/JVideoThumbnailResult.hpp +73 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/compressor/Func_void.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/compressor/Func_void_double.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/compressor/Func_void_double_double.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/compressor/HybridCompressorSpec.kt +141 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/compressor/NitroCompressorOnLoad.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/compressor/VideoThumbnailResult.kt +71 -0
- package/nitrogen/generated/ios/c++/HybridCompressorSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridCompressorSpecSwift.hpp +204 -0
- package/nitrogen/generated/ios/react_native_compressor+autolinking.rb +62 -0
- package/nitrogen/generated/ios/react_native_compressor-Swift-Cxx-Bridge.cpp +89 -0
- package/nitrogen/generated/ios/react_native_compressor-Swift-Cxx-Bridge.hpp +337 -0
- package/nitrogen/generated/ios/react_native_compressor-Swift-Cxx-Umbrella.hpp +51 -0
- package/nitrogen/generated/ios/react_native_compressorAutolinking.mm +33 -0
- package/nitrogen/generated/ios/react_native_compressorAutolinking.swift +26 -0
- package/nitrogen/generated/ios/swift/Func_void.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_VideoThumbnailResult.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_double.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_double_double.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__shared_ptr_AnyMap_.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__string.swift +46 -0
- package/nitrogen/generated/ios/swift/HybridCompressorSpec.swift +70 -0
- package/nitrogen/generated/ios/swift/HybridCompressorSpec_cxx.swift +493 -0
- package/nitrogen/generated/ios/swift/VideoThumbnailResult.swift +49 -0
- package/nitrogen/generated/shared/c++/HybridCompressorSpec.cpp +36 -0
- package/nitrogen/generated/shared/c++/HybridCompressorSpec.hpp +83 -0
- package/nitrogen/generated/shared/c++/VideoThumbnailResult.hpp +99 -0
- package/package.json +8 -12
- package/react-native-compressor.podspec +6 -24
- package/src/Audio/index.tsx +2 -2
- package/src/Image/index.tsx +3 -26
- package/src/Main.tsx +14 -16
- package/src/Video/index.tsx +25 -77
- package/src/specs/Compressor.nitro.ts +56 -0
- package/src/utils/Downloader.tsx +8 -27
- package/src/utils/Uploader.tsx +12 -24
- package/src/utils/helpers.ts +18 -0
- package/src/utils/index.tsx +3 -2
- package/android/src/main/java/com/reactnativecompressor/CompressorModule.kt +0 -180
- package/android/src/main/java/com/reactnativecompressor/CompressorPackage.kt +0 -34
- package/android/src/newarch/CompressorSpec.kt +0 -5
- package/android/src/oldarch/CompressorSpec.kt +0 -36
- package/ios/Compressor-Bridging-Header.h +0 -6
- package/ios/Compressor.h +0 -5
- package/ios/Compressor.mm +0 -82
- package/ios/CompressorManager.swift +0 -117
- package/lib/commonjs/Spec/NativeCompressor.js +0 -9
- package/lib/commonjs/Spec/NativeCompressor.js.map +0 -1
- package/lib/module/Spec/NativeCompressor.js +0 -5
- package/lib/module/Spec/NativeCompressor.js.map +0 -1
- package/lib/typescript/src/Spec/NativeCompressor.d.ts +0 -30
- package/lib/typescript/src/Spec/NativeCompressor.d.ts.map +0 -1
- package/src/Spec/NativeCompressor.ts +0 -41
|
@@ -13,7 +13,9 @@ public enum NextLevelSessionExporterError: Error, CustomStringConvertible {
|
|
|
13
13
|
case readingFailure
|
|
14
14
|
case writingFailure
|
|
15
15
|
case cancelled
|
|
16
|
-
|
|
16
|
+
case unsupportedVideoOutputConfiguration
|
|
17
|
+
case missingVideoTrackInOutput
|
|
18
|
+
|
|
17
19
|
public var description: String {
|
|
18
20
|
get {
|
|
19
21
|
switch self {
|
|
@@ -25,6 +27,10 @@ public enum NextLevelSessionExporterError: Error, CustomStringConvertible {
|
|
|
25
27
|
return "Writing failure"
|
|
26
28
|
case .cancelled:
|
|
27
29
|
return "Cancelled"
|
|
30
|
+
case .unsupportedVideoOutputConfiguration:
|
|
31
|
+
return "The writer rejected the video output configuration"
|
|
32
|
+
case .missingVideoTrackInOutput:
|
|
33
|
+
return "Export finished without a video track in the output"
|
|
28
34
|
}
|
|
29
35
|
}
|
|
30
36
|
}
|
|
@@ -249,7 +255,16 @@ extension NextLevelSessionExporter {
|
|
|
249
255
|
}
|
|
250
256
|
}
|
|
251
257
|
|
|
252
|
-
|
|
258
|
+
// Fail loudly when the writer rejects the video output configuration.
|
|
259
|
+
// Continuing here used to export only the audio track and still resolve
|
|
260
|
+
// as a success (issue #400).
|
|
261
|
+
guard self.setupVideoOutput(withAsset: asset) else {
|
|
262
|
+
DispatchQueue.main.async {
|
|
263
|
+
self._completionHandler?(.failure(NextLevelSessionExporterError.unsupportedVideoOutputConfiguration))
|
|
264
|
+
self._completionHandler = nil
|
|
265
|
+
}
|
|
266
|
+
return
|
|
267
|
+
}
|
|
253
268
|
if !self.stripAudio {
|
|
254
269
|
self.setupAudioOutput(withAsset: asset)
|
|
255
270
|
self.setupAudioInput()
|
|
@@ -316,11 +331,14 @@ extension NextLevelSessionExporter {
|
|
|
316
331
|
|
|
317
332
|
extension NextLevelSessionExporter {
|
|
318
333
|
|
|
319
|
-
|
|
334
|
+
/// Returns `false` when the asset has video tracks but a video writer input
|
|
335
|
+
/// could not be created — exporting would silently produce an audio-only
|
|
336
|
+
/// file (see numandev1/react-native-compressor#400).
|
|
337
|
+
private func setupVideoOutput(withAsset asset: AVAsset) -> Bool {
|
|
320
338
|
let videoTracks = asset.tracks(withMediaType: AVMediaType.video)
|
|
321
|
-
|
|
339
|
+
|
|
322
340
|
guard videoTracks.count > 0 else {
|
|
323
|
-
return
|
|
341
|
+
return true
|
|
324
342
|
}
|
|
325
343
|
|
|
326
344
|
self._videoOutput = AVAssetReaderVideoCompositionOutput(videoTracks: videoTracks, videoSettings: self.videoInputConfiguration)
|
|
@@ -344,8 +362,8 @@ extension NextLevelSessionExporter {
|
|
|
344
362
|
self._videoInput = AVAssetWriterInput(mediaType: AVMediaType.video, outputSettings: self.videoOutputConfiguration)
|
|
345
363
|
self._videoInput?.expectsMediaDataInRealTime = self.expectsMediaDataInRealTime
|
|
346
364
|
} else {
|
|
347
|
-
print("
|
|
348
|
-
return
|
|
365
|
+
print("NextLevelSessionExporter, unsupported video output configuration, failing export instead of writing an audio-only file")
|
|
366
|
+
return false
|
|
349
367
|
}
|
|
350
368
|
|
|
351
369
|
if let writer = self._writer,
|
|
@@ -367,8 +385,9 @@ extension NextLevelSessionExporter {
|
|
|
367
385
|
|
|
368
386
|
self._pixelBufferAdaptor = AVAssetWriterInputPixelBufferAdaptor(assetWriterInput: videoInput, sourcePixelBufferAttributes: pixelBufferAttrib)
|
|
369
387
|
}
|
|
388
|
+
return true
|
|
370
389
|
}
|
|
371
|
-
|
|
390
|
+
|
|
372
391
|
private func setupAudioOutput(withAsset asset: AVAsset) {
|
|
373
392
|
let audioTracks = asset.tracks(withMediaType: AVMediaType.audio)
|
|
374
393
|
var audioTracksToUse: [AVAssetTrack] = []
|
|
@@ -632,6 +651,22 @@ extension NextLevelSessionExporter {
|
|
|
632
651
|
break
|
|
633
652
|
}
|
|
634
653
|
|
|
654
|
+
// Guard against silently returning an audio-only file: when the source
|
|
655
|
+
// has a video track and a video output was configured, the exported file
|
|
656
|
+
// must contain a video track as well. A configuration the encoder rejects
|
|
657
|
+
// at write time can still end with `.completed` while the video track is
|
|
658
|
+
// dropped (issue #400) — surface that as an error instead of a success.
|
|
659
|
+
if self.videoOutputConfiguration != nil,
|
|
660
|
+
let asset = self.asset,
|
|
661
|
+
let outputURL = self.outputURL,
|
|
662
|
+
asset.tracks(withMediaType: AVMediaType.video).count > 0,
|
|
663
|
+
AVAsset(url: outputURL).tracks(withMediaType: AVMediaType.video).count == 0 {
|
|
664
|
+
try? FileManager.default.removeItem(at: outputURL)
|
|
665
|
+
self._completionHandler?(.failure(NextLevelSessionExporterError.missingVideoTrackInOutput))
|
|
666
|
+
self._completionHandler = nil
|
|
667
|
+
return
|
|
668
|
+
}
|
|
669
|
+
|
|
635
670
|
self._completionHandler?(.success(self.status))
|
|
636
671
|
self._completionHandler = nil
|
|
637
672
|
}
|
|
@@ -2,6 +2,7 @@ import Foundation
|
|
|
2
2
|
import AVFoundation
|
|
3
3
|
import Photos
|
|
4
4
|
import MobileCoreServices
|
|
5
|
+
import UIKit
|
|
5
6
|
|
|
6
7
|
struct CompressionError: Error {
|
|
7
8
|
private let message: String
|
|
@@ -320,11 +321,15 @@ class VideoCompressor {
|
|
|
320
321
|
exporter.outputURL = tmpURL
|
|
321
322
|
exporter.outputFileType = AVFileType.mp4
|
|
322
323
|
|
|
324
|
+
// NOTE: Do not add AVVideoExpectedSourceFrameRateKey or
|
|
325
|
+
// AVVideoAverageNonDroppableFrameRateKey here. They are not documented
|
|
326
|
+
// H.264 (avc1) compression properties on iOS and, while AVFoundation's
|
|
327
|
+
// `canApply(...)` check still returns true, the iOS encoder silently
|
|
328
|
+
// drops the video track, producing an audio-only MP4 that still reports
|
|
329
|
+
// success. See issue #400.
|
|
323
330
|
let compressionDict: [String: Any] = [
|
|
324
331
|
AVVideoAverageBitRateKey: bitRate,
|
|
325
332
|
AVVideoProfileLevelKey: AVVideoProfileLevelH264HighAutoLevel,
|
|
326
|
-
AVVideoExpectedSourceFrameRateKey: frameRate,
|
|
327
|
-
AVVideoAverageNonDroppableFrameRateKey: frameRate,
|
|
328
333
|
]
|
|
329
334
|
exporter.optimizeForNetworkUse = true;
|
|
330
335
|
exporter.videoOutputConfiguration = [
|
|
@@ -366,7 +371,16 @@ class VideoCompressor {
|
|
|
366
371
|
switch result {
|
|
367
372
|
case .success:
|
|
368
373
|
if let outputURL = exporter.outputURL {
|
|
369
|
-
|
|
374
|
+
// Guard against the iOS encoder silently dropping the video track
|
|
375
|
+
// and producing an audio-only file that still reports success.
|
|
376
|
+
// See issue #400.
|
|
377
|
+
let outputAsset = AVAsset(url: outputURL)
|
|
378
|
+
if outputAsset.tracks(withMediaType: AVMediaType.video).isEmpty {
|
|
379
|
+
try? FileManager.default.removeItem(at: outputURL)
|
|
380
|
+
onFailure(CompressionError(message: "Compression produced a file with no video track"))
|
|
381
|
+
} else {
|
|
382
|
+
onCompletion(outputURL)
|
|
383
|
+
}
|
|
370
384
|
} else {
|
|
371
385
|
onFailure(CompressionError(message: "Compression succeeded but output URL is unavailable"))
|
|
372
386
|
}
|
|
@@ -10,7 +10,7 @@ const NativeAudio = _Main.Compressor;
|
|
|
10
10
|
const Audio = {
|
|
11
11
|
compress: async (url, options = _utils.DEFAULT_COMPRESS_AUDIO_OPTIONS) => {
|
|
12
12
|
try {
|
|
13
|
-
return NativeAudio.compress_audio(url, options);
|
|
13
|
+
return NativeAudio.compress_audio(url, (0, _utils.toNativeOptions)(options));
|
|
14
14
|
} catch (error) {
|
|
15
15
|
throw error.message;
|
|
16
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_Main","require","_utils","NativeAudio","Compressor","Audio","compress","url","options","DEFAULT_COMPRESS_AUDIO_OPTIONS","compress_audio","error","message","_default","exports","default"],"sourceRoot":"../../../src","sources":["Audio/index.tsx"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAEA,MAAME,WAAW,GAAGC,gBAAU;AAE9B,MAAMC,KAAgB,GAAG;EACvBC,QAAQ,EAAE,MAAAA,CAAOC,GAAG,EAAEC,OAAO,GAAGC,qCAA8B,KAAK;IACjE,IAAI;MACF,OAAON,WAAW,CAACO,cAAc,CAACH,GAAG,
|
|
1
|
+
{"version":3,"names":["_Main","require","_utils","NativeAudio","Compressor","Audio","compress","url","options","DEFAULT_COMPRESS_AUDIO_OPTIONS","compress_audio","toNativeOptions","error","message","_default","exports","default"],"sourceRoot":"../../../src","sources":["Audio/index.tsx"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAEA,MAAME,WAAW,GAAGC,gBAAU;AAE9B,MAAMC,KAAgB,GAAG;EACvBC,QAAQ,EAAE,MAAAA,CAAOC,GAAG,EAAEC,OAAO,GAAGC,qCAA8B,KAAK;IACjE,IAAI;MACF,OAAON,WAAW,CAACO,cAAc,CAACH,GAAG,EAAE,IAAAI,sBAAe,EAACH,OAAO,CAAC,CAAC;IAClE,CAAC,CAAC,OAAOI,KAAU,EAAE;MACnB,MAAMA,KAAK,CAACC,OAAO;IACrB;EACF;AACF,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaX,KAAK","ignoreList":[]}
|
|
@@ -6,35 +6,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _Main = require("../Main");
|
|
8
8
|
var _utils = require("../utils");
|
|
9
|
-
var _reactNative = require("react-native");
|
|
10
9
|
const base64UrlRegex = /^data:image\/.*;(?:charset=.{3,5};)?base64,/;
|
|
11
|
-
const ImageCompressEventEmitter = new _reactNative.NativeEventEmitter(_Main.Compressor);
|
|
12
10
|
const NativeImage = _Main.Compressor;
|
|
13
11
|
const Image = {
|
|
14
12
|
compress: async (value, options = {}) => {
|
|
15
13
|
if (!value) {
|
|
16
14
|
throw new Error('Compression value is empty, please provide a value for compression.');
|
|
17
15
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (options?.downloadProgress) {
|
|
21
|
-
const uuid = (0, _utils.uuidv4)();
|
|
22
|
-
//@ts-ignore
|
|
23
|
-
options.uuid = uuid;
|
|
24
|
-
subscription = ImageCompressEventEmitter.addListener('downloadProgress', event => {
|
|
25
|
-
if (event.uuid === uuid) {
|
|
26
|
-
options.downloadProgress && options.downloadProgress(event.data.progress);
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
const cleanData = value.replace(base64UrlRegex, '');
|
|
31
|
-
return await NativeImage.image_compress(cleanData, options);
|
|
32
|
-
} finally {
|
|
33
|
-
// @ts-ignore
|
|
34
|
-
if (subscription) {
|
|
35
|
-
subscription.remove();
|
|
36
|
-
}
|
|
37
|
-
}
|
|
16
|
+
const cleanData = value.replace(base64UrlRegex, '');
|
|
17
|
+
return await NativeImage.image_compress(cleanData, (0, _utils.toNativeOptions)(options), options.downloadProgress);
|
|
38
18
|
}
|
|
39
19
|
};
|
|
40
20
|
var _default = exports.default = Image;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_Main","require","_utils","
|
|
1
|
+
{"version":3,"names":["_Main","require","_utils","base64UrlRegex","NativeImage","Compressor","Image","compress","value","options","Error","cleanData","replace","image_compress","toNativeOptions","downloadProgress","_default","exports","default"],"sourceRoot":"../../../src","sources":["Image/index.tsx"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,MAAME,cAAc,GAAG,6CAA6C;AAqDpE,MAAMC,WAAW,GAAGC,gBAAU;AAM9B,MAAMC,KAAgB,GAAG;EACvBC,QAAQ,EAAE,MAAAA,CAAOC,KAAK,EAAEC,OAAO,GAAG,CAAC,CAAC,KAAK;IACvC,IAAI,CAACD,KAAK,EAAE;MACV,MAAM,IAAIE,KAAK,CAAC,qEAAqE,CAAC;IACxF;IAEA,MAAMC,SAAS,GAAGH,KAAK,CAACI,OAAO,CAACT,cAAc,EAAE,EAAE,CAAC;IACnD,OAAO,MAAMC,WAAW,CAACS,cAAc,CAACF,SAAS,EAAE,IAAAG,sBAAe,EAACL,OAAO,CAAC,EAAEA,OAAO,CAACM,gBAAgB,CAAC;EACxG;AACF,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaZ,KAAK","ignoreList":[]}
|
package/lib/commonjs/Main.js
CHANGED
|
@@ -5,17 +5,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.Compressor = void 0;
|
|
7
7
|
var _reactNative = require("react-native");
|
|
8
|
+
var _reactNativeNitroModules = require("react-native-nitro-modules");
|
|
8
9
|
const LINKING_ERROR = `The package 'react-native-compressor' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
|
|
9
10
|
ios: "- You have run 'pod install'\n",
|
|
10
11
|
default: ''
|
|
11
|
-
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const Compressor = exports.Compressor = CompressorModule ? CompressorModule : new Proxy({}, {
|
|
17
|
-
get() {
|
|
12
|
+
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n' + '- You have installed `react-native-nitro-modules`\n';
|
|
13
|
+
const createCompressor = () => {
|
|
14
|
+
try {
|
|
15
|
+
return _reactNativeNitroModules.NitroModules.createHybridObject('Compressor');
|
|
16
|
+
} catch {
|
|
18
17
|
throw new Error(LINKING_ERROR);
|
|
19
18
|
}
|
|
20
|
-
}
|
|
19
|
+
};
|
|
20
|
+
const Compressor = exports.Compressor = createCompressor();
|
|
21
21
|
//# sourceMappingURL=Main.js.map
|
package/lib/commonjs/Main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","LINKING_ERROR","Platform","select","ios","default","
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_reactNativeNitroModules","LINKING_ERROR","Platform","select","ios","default","createCompressor","NitroModules","createHybridObject","Error","Compressor","exports"],"sourceRoot":"../../src","sources":["Main.tsx"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,wBAAA,GAAAD,OAAA;AAIA,MAAME,aAAa,GACjB,kFAAkF,GAClFC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B,GAC/B,qDAAqD;AAEvD,MAAMC,gBAAgB,GAAGA,CAAA,KAAsB;EAC7C,IAAI;IACF,OAAOC,qCAAY,CAACC,kBAAkB,CAAiB,YAAY,CAAC;EACtE,CAAC,CAAC,MAAM;IACN,MAAM,IAAIC,KAAK,CAACR,aAAa,CAAC;EAChC;AACF,CAAC;AAED,MAAMS,UAAU,GAAAC,OAAA,CAAAD,UAAA,GAAGJ,gBAAgB,CAAC,CAAC","ignoreList":[]}
|
|
@@ -4,10 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.cancelCompression = void 0;
|
|
7
|
-
var _reactNative = require("react-native");
|
|
8
7
|
var _Main = require("../Main");
|
|
9
8
|
var _utils = require("../utils");
|
|
10
|
-
const VideoCompressEventEmitter = new _reactNative.NativeEventEmitter(_Main.Compressor);
|
|
11
9
|
const NativeVideoCompressor = _Main.Compressor;
|
|
12
10
|
const cancelCompression = cancellationId => {
|
|
13
11
|
return NativeVideoCompressor.cancelCompression(cancellationId);
|
|
@@ -16,75 +14,37 @@ exports.cancelCompression = cancelCompression;
|
|
|
16
14
|
const Video = {
|
|
17
15
|
compress: async (fileUrl, options, onProgress) => {
|
|
18
16
|
const uuid = (0, _utils.uuidv4)();
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
if (options?.downloadProgress) {
|
|
30
|
-
//@ts-ignore
|
|
31
|
-
subscription2 = VideoCompressEventEmitter.addListener('downloadProgress', event => {
|
|
32
|
-
if (event.uuid === uuid) {
|
|
33
|
-
options.downloadProgress && options.downloadProgress(event.data.progress);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
const modifiedOptions = {
|
|
38
|
-
uuid
|
|
39
|
-
};
|
|
40
|
-
if (options?.progressDivider) modifiedOptions.progressDivider = options?.progressDivider;
|
|
41
|
-
if (options?.bitrate) modifiedOptions.bitrate = options?.bitrate;
|
|
42
|
-
if (options?.compressionMethod) {
|
|
43
|
-
modifiedOptions.compressionMethod = options?.compressionMethod;
|
|
44
|
-
} else {
|
|
45
|
-
modifiedOptions.compressionMethod = 'auto';
|
|
46
|
-
}
|
|
47
|
-
if (options?.maxSize) {
|
|
48
|
-
modifiedOptions.maxSize = options?.maxSize;
|
|
49
|
-
} else {
|
|
50
|
-
modifiedOptions.maxSize = 640;
|
|
51
|
-
}
|
|
52
|
-
if (options?.minimumFileSizeForCompress !== undefined) {
|
|
53
|
-
modifiedOptions.minimumFileSizeForCompress = options?.minimumFileSizeForCompress;
|
|
54
|
-
}
|
|
55
|
-
if (options?.stripAudio) {
|
|
56
|
-
modifiedOptions.stripAudio = options.stripAudio;
|
|
57
|
-
}
|
|
58
|
-
if (options?.getCancellationId) {
|
|
59
|
-
options?.getCancellationId(uuid);
|
|
60
|
-
}
|
|
61
|
-
const result = await NativeVideoCompressor.compress(fileUrl, modifiedOptions);
|
|
62
|
-
return result;
|
|
63
|
-
} finally {
|
|
64
|
-
// @ts-ignore
|
|
65
|
-
if (subscription) {
|
|
66
|
-
subscription.remove();
|
|
67
|
-
}
|
|
68
|
-
//@ts-ignore
|
|
69
|
-
if (subscription2) {
|
|
70
|
-
subscription2.remove();
|
|
71
|
-
}
|
|
17
|
+
const modifiedOptions = {
|
|
18
|
+
uuid
|
|
19
|
+
};
|
|
20
|
+
if (options?.progressDivider) modifiedOptions.progressDivider = options?.progressDivider;
|
|
21
|
+
if (options?.bitrate) modifiedOptions.bitrate = options?.bitrate;
|
|
22
|
+
if (options?.compressionMethod) {
|
|
23
|
+
modifiedOptions.compressionMethod = options?.compressionMethod;
|
|
24
|
+
} else {
|
|
25
|
+
modifiedOptions.compressionMethod = 'auto';
|
|
72
26
|
}
|
|
27
|
+
if (options?.maxSize) {
|
|
28
|
+
modifiedOptions.maxSize = options?.maxSize;
|
|
29
|
+
} else {
|
|
30
|
+
modifiedOptions.maxSize = 640;
|
|
31
|
+
}
|
|
32
|
+
if (options?.minimumFileSizeForCompress !== undefined) {
|
|
33
|
+
modifiedOptions.minimumFileSizeForCompress = options?.minimumFileSizeForCompress;
|
|
34
|
+
}
|
|
35
|
+
if (options?.stripAudio) {
|
|
36
|
+
modifiedOptions.stripAudio = options.stripAudio;
|
|
37
|
+
}
|
|
38
|
+
if (options?.getCancellationId) {
|
|
39
|
+
options?.getCancellationId(uuid);
|
|
40
|
+
}
|
|
41
|
+
return NativeVideoCompressor.compress(fileUrl, (0, _utils.toNativeOptions)(modifiedOptions), onProgress, options?.downloadProgress);
|
|
73
42
|
},
|
|
74
43
|
cancelCompression,
|
|
75
44
|
activateBackgroundTask(onExpired) {
|
|
76
|
-
|
|
77
|
-
const subscription = VideoCompressEventEmitter.addListener('backgroundTaskExpired', event => {
|
|
78
|
-
onExpired(event);
|
|
79
|
-
if (subscription) {
|
|
80
|
-
subscription.remove();
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
return NativeVideoCompressor.activateBackgroundTask({});
|
|
45
|
+
return NativeVideoCompressor.activateBackgroundTask({}, onExpired ? () => onExpired(undefined) : undefined);
|
|
85
46
|
},
|
|
86
47
|
deactivateBackgroundTask() {
|
|
87
|
-
VideoCompressEventEmitter.removeAllListeners('backgroundTaskExpired');
|
|
88
48
|
return NativeVideoCompressor.deactivateBackgroundTask({});
|
|
89
49
|
}
|
|
90
50
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_Main","require","_utils","NativeVideoCompressor","Compressor","cancelCompression","cancellationId","exports","Video","compress","fileUrl","options","onProgress","uuid","uuidv4","modifiedOptions","progressDivider","bitrate","compressionMethod","maxSize","minimumFileSizeForCompress","undefined","stripAudio","getCancellationId","toNativeOptions","downloadProgress","activateBackgroundTask","onExpired","deactivateBackgroundTask","_default","default"],"sourceRoot":"../../../src","sources":["Video/index.tsx"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AA4BA,MAAME,qBAAqB,GAAGC,gBAAU;AAEjC,MAAMC,iBAAiB,GAAIC,cAAsB,IAAK;EAC3D,OAAOH,qBAAqB,CAACE,iBAAiB,CAACC,cAAc,CAAC;AAChE,CAAC;AAACC,OAAA,CAAAF,iBAAA,GAAAA,iBAAA;AAEF,MAAMG,KAA0B,GAAG;EACjCC,QAAQ,EAAE,MAAAA,CAAOC,OAAe,EAAEC,OAA+B,EAAEC,UAAuC,KAAK;IAC7G,MAAMC,IAAI,GAAG,IAAAC,aAAM,EAAC,CAAC;IAErB,MAAMC,eAAwC,GAAG;MAAEF;IAAK,CAAC;IACzD,IAAIF,OAAO,EAAEK,eAAe,EAAED,eAAe,CAACC,eAAe,GAAGL,OAAO,EAAEK,eAAe;IACxF,IAAIL,OAAO,EAAEM,OAAO,EAAEF,eAAe,CAACE,OAAO,GAAGN,OAAO,EAAEM,OAAO;IAChE,IAAIN,OAAO,EAAEO,iBAAiB,EAAE;MAC9BH,eAAe,CAACG,iBAAiB,GAAGP,OAAO,EAAEO,iBAAiB;IAChE,CAAC,MAAM;MACLH,eAAe,CAACG,iBAAiB,GAAG,MAAM;IAC5C;IACA,IAAIP,OAAO,EAAEQ,OAAO,EAAE;MACpBJ,eAAe,CAACI,OAAO,GAAGR,OAAO,EAAEQ,OAAO;IAC5C,CAAC,MAAM;MACLJ,eAAe,CAACI,OAAO,GAAG,GAAG;IAC/B;IACA,IAAIR,OAAO,EAAES,0BAA0B,KAAKC,SAAS,EAAE;MACrDN,eAAe,CAACK,0BAA0B,GAAGT,OAAO,EAAES,0BAA0B;IAClF;IACA,IAAIT,OAAO,EAAEW,UAAU,EAAE;MACvBP,eAAe,CAACO,UAAU,GAAGX,OAAO,CAACW,UAAU;IACjD;IACA,IAAIX,OAAO,EAAEY,iBAAiB,EAAE;MAC9BZ,OAAO,EAAEY,iBAAiB,CAACV,IAAI,CAAC;IAClC;IAEA,OAAOV,qBAAqB,CAACM,QAAQ,CAACC,OAAO,EAAE,IAAAc,sBAAe,EAACT,eAAe,CAAC,EAAEH,UAAU,EAAED,OAAO,EAAEc,gBAAgB,CAAC;EACzH,CAAC;EACDpB,iBAAiB;EACjBqB,sBAAsBA,CAACC,SAAU,EAAE;IACjC,OAAOxB,qBAAqB,CAACuB,sBAAsB,CAAC,CAAC,CAAC,EAAEC,SAAS,GAAG,MAAMA,SAAS,CAACN,SAAS,CAAC,GAAGA,SAAS,CAAC;EAC7G,CAAC;EACDO,wBAAwBA,CAAA,EAAG;IACzB,OAAOzB,qBAAqB,CAACyB,wBAAwB,CAAC,CAAC,CAAC,CAAC;EAC3D;AACF,CAAwB;AAAC,IAAAC,QAAA,GAAAtB,OAAA,CAAAuB,OAAA,GAEVtB,KAAK","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["specs/Compressor.nitro.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -7,32 +7,16 @@ exports.download = void 0;
|
|
|
7
7
|
var _reactNative = require("react-native");
|
|
8
8
|
var _Main = require("../Main");
|
|
9
9
|
var _helpers = require("./helpers");
|
|
10
|
-
const CompressEventEmitter = new _reactNative.NativeEventEmitter(_Main.Compressor);
|
|
11
10
|
const download = async (fileUrl, downloadProgress, progressDivider) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (downloadProgress) {
|
|
16
|
-
subscription = CompressEventEmitter.addListener('downloadProgress', event => {
|
|
17
|
-
if (event.uuid === uuid) {
|
|
18
|
-
downloadProgress(event.data.progress);
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
if (_reactNative.Platform.OS === 'android' && fileUrl.includes('file://')) {
|
|
23
|
-
fileUrl = fileUrl.replace('file://', '');
|
|
24
|
-
}
|
|
25
|
-
const result = await _Main.Compressor.download(fileUrl, {
|
|
26
|
-
uuid,
|
|
27
|
-
progressDivider
|
|
28
|
-
});
|
|
29
|
-
return result;
|
|
30
|
-
} finally {
|
|
31
|
-
// @ts-ignore
|
|
32
|
-
if (subscription) {
|
|
33
|
-
subscription.remove();
|
|
34
|
-
}
|
|
11
|
+
const uuid = (0, _helpers.uuidv4)();
|
|
12
|
+
if (_reactNative.Platform.OS === 'android' && fileUrl.includes('file://')) {
|
|
13
|
+
fileUrl = fileUrl.replace('file://', '');
|
|
35
14
|
}
|
|
15
|
+
const result = await _Main.Compressor.download(fileUrl, (0, _helpers.toNativeOptions)({
|
|
16
|
+
uuid,
|
|
17
|
+
progressDivider
|
|
18
|
+
}), downloadProgress);
|
|
19
|
+
return result;
|
|
36
20
|
};
|
|
37
21
|
exports.download = download;
|
|
38
22
|
//# sourceMappingURL=Downloader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_Main","_helpers","
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_Main","_helpers","download","fileUrl","downloadProgress","progressDivider","uuid","uuidv4","Platform","OS","includes","replace","result","Compressor","toNativeOptions","exports"],"sourceRoot":"../../../src","sources":["utils/Downloader.tsx"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAEO,MAAMG,QAAQ,GAAG,MAAAA,CAAOC,OAAe,EAAEC,gBAA6C,EAAEC,eAAwB,KAAmB;EACxI,MAAMC,IAAI,GAAG,IAAAC,eAAM,EAAC,CAAC;EACrB,IAAIC,qBAAQ,CAACC,EAAE,KAAK,SAAS,IAAIN,OAAO,CAACO,QAAQ,CAAC,SAAS,CAAC,EAAE;IAC5DP,OAAO,GAAGA,OAAO,CAACQ,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;EAC1C;EACA,MAAMC,MAAM,GAAG,MAAMC,gBAAU,CAACX,QAAQ,CAACC,OAAO,EAAE,IAAAW,wBAAe,EAAC;IAAER,IAAI;IAAED;EAAgB,CAAC,CAAC,EAAED,gBAAgB,CAAC;EAC/G,OAAOQ,MAAM;AACf,CAAC;AAACG,OAAA,CAAAb,QAAA,GAAAA,QAAA","ignoreList":[]}
|
|
@@ -7,7 +7,6 @@ exports.cancelUpload = exports.backgroundUpload = exports.UploaderHttpMethod = e
|
|
|
7
7
|
var _reactNative = require("react-native");
|
|
8
8
|
var _Main = require("../Main");
|
|
9
9
|
var _helpers = require("./helpers");
|
|
10
|
-
const CompressEventEmitter = new _reactNative.NativeEventEmitter(_Main.Compressor);
|
|
11
10
|
let UploadType = exports.UploadType = /*#__PURE__*/function (UploadType) {
|
|
12
11
|
UploadType[UploadType["BINARY_CONTENT"] = 0] = "BINARY_CONTENT";
|
|
13
12
|
UploadType[UploadType["MULTIPART"] = 1] = "MULTIPART";
|
|
@@ -25,15 +24,7 @@ const cancelUpload = (uuid = '', shouldCancelAll = false) => {
|
|
|
25
24
|
exports.cancelUpload = cancelUpload;
|
|
26
25
|
const backgroundUpload = async (url, fileUrl, options, onProgress, abortSignal) => {
|
|
27
26
|
const uuid = (0, _helpers.uuidv4)();
|
|
28
|
-
let subscription;
|
|
29
27
|
try {
|
|
30
|
-
if (onProgress) {
|
|
31
|
-
subscription = CompressEventEmitter.addListener('uploadProgress', event => {
|
|
32
|
-
if (event.uuid === uuid) {
|
|
33
|
-
onProgress(event.data.written, event.data.total);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
28
|
if (_reactNative.Platform.OS === 'android' && fileUrl.includes('file://')) {
|
|
38
29
|
fileUrl = fileUrl.replace('file://', '');
|
|
39
30
|
}
|
|
@@ -41,20 +32,14 @@ const backgroundUpload = async (url, fileUrl, options, onProgress, abortSignal)
|
|
|
41
32
|
options?.getCancellationId(uuid);
|
|
42
33
|
}
|
|
43
34
|
abortSignal?.addEventListener('abort', () => cancelUpload(uuid));
|
|
44
|
-
const result = await _Main.Compressor.upload(fileUrl, {
|
|
35
|
+
const result = await _Main.Compressor.upload(fileUrl, (0, _helpers.toNativeOptions)({
|
|
36
|
+
...options,
|
|
45
37
|
uuid,
|
|
46
38
|
method: options.httpMethod,
|
|
47
|
-
headers: options.headers,
|
|
48
|
-
uploadType: options.uploadType,
|
|
49
|
-
...options,
|
|
50
39
|
url
|
|
51
|
-
});
|
|
40
|
+
}), onProgress);
|
|
52
41
|
return result;
|
|
53
42
|
} finally {
|
|
54
|
-
// @ts-ignore
|
|
55
|
-
if (subscription) {
|
|
56
|
-
subscription.remove();
|
|
57
|
-
}
|
|
58
43
|
abortSignal?.removeEventListener('abort', () => cancelUpload(uuid));
|
|
59
44
|
}
|
|
60
45
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_Main","_helpers","
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_Main","_helpers","UploadType","exports","UploaderHttpMethod","cancelUpload","uuid","shouldCancelAll","Compressor","backgroundUpload","url","fileUrl","options","onProgress","abortSignal","uuidv4","Platform","OS","includes","replace","getCancellationId","addEventListener","result","upload","toNativeOptions","method","httpMethod","removeEventListener"],"sourceRoot":"../../../src","sources":["utils/Uploader.tsx"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAAoD,IACxCG,UAAU,GAAAC,OAAA,CAAAD,UAAA,0BAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAA,OAAVA,UAAU;AAAA;AAAA,IAKVE,kBAAkB,GAAAD,OAAA,CAAAC,kBAAA,0BAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAA,OAAlBA,kBAAkB;AAAA;AA+BvB,MAAMC,YAAgE,GAAGA,CAACC,IAAI,GAAG,EAAE,EAAEC,eAAe,GAAG,KAAK,KAAK;EACtH,OAAOC,gBAAU,CAACH,YAAY,CAACC,IAAI,EAAEC,eAAe,CAAC;AACvD,CAAC;AAACJ,OAAA,CAAAE,YAAA,GAAAA,YAAA;AAEK,MAAMI,gBAAgB,GAAG,MAAAA,CAC9BC,GAAW,EACXC,OAAe,EACfC,OAAwB,EACxBC,UAAqD,EACrDC,WAAyB,KACR;EACjB,MAAMR,IAAI,GAAG,IAAAS,eAAM,EAAC,CAAC;EACrB,IAAI;IACF,IAAIC,qBAAQ,CAACC,EAAE,KAAK,SAAS,IAAIN,OAAO,CAACO,QAAQ,CAAC,SAAS,CAAC,EAAE;MAC5DP,OAAO,GAAGA,OAAO,CAACQ,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;IAC1C;IAEA,IAAIP,OAAO,EAAEQ,iBAAiB,EAAE;MAC9BR,OAAO,EAAEQ,iBAAiB,CAACd,IAAI,CAAC;IAClC;IAEAQ,WAAW,EAAEO,gBAAgB,CAAC,OAAO,EAAE,MAAMhB,YAAY,CAACC,IAAI,CAAC,CAAC;IAEhE,MAAMgB,MAAM,GAAG,MAAMd,gBAAU,CAACe,MAAM,CACpCZ,OAAO,EACP,IAAAa,wBAAe,EAAC;MACd,GAAGZ,OAAO;MACVN,IAAI;MACJmB,MAAM,EAAEb,OAAO,CAACc,UAAU;MAC1BhB;IACF,CAAC,CAAC,EACFG,UACF,CAAC;IACD,OAAOS,MAAM;EACf,CAAC,SAAS;IACRR,WAAW,EAAEa,mBAAmB,CAAC,OAAO,EAAE,MAAMtB,YAAY,CAACC,IAAI,CAAC,CAAC;EACrE;AACF,CAAC;AAACH,OAAA,CAAAM,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.uuidv4 = void 0;
|
|
6
|
+
exports.uuidv4 = exports.toNativeOptions = void 0;
|
|
7
7
|
const uuidv4 = () => {
|
|
8
8
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
9
9
|
const r = parseFloat('0.' + Math.random().toString().replace('0.', '') + new Date().getTime()) * 16 | 0,
|
|
@@ -12,5 +12,22 @@ const uuidv4 = () => {
|
|
|
12
12
|
return v.toString(16);
|
|
13
13
|
});
|
|
14
14
|
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Build a Nitro-safe options map. Nitro's `AnyMap` converter throws when it
|
|
18
|
+
* encounters a `undefined` or function-valued property, so we drop both —
|
|
19
|
+
* progress callbacks are passed as separate native method parameters now.
|
|
20
|
+
*/
|
|
15
21
|
exports.uuidv4 = uuidv4;
|
|
22
|
+
const toNativeOptions = options => {
|
|
23
|
+
const result = {};
|
|
24
|
+
for (const key of Object.keys(options)) {
|
|
25
|
+
const value = options[key];
|
|
26
|
+
if (value !== undefined && typeof value !== 'function') {
|
|
27
|
+
result[key] = value;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return result;
|
|
31
|
+
};
|
|
32
|
+
exports.toNativeOptions = toNativeOptions;
|
|
16
33
|
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["uuidv4","replace","c","r","parseFloat","Math","random","toString","Date","getTime","v","exports"],"sourceRoot":"../../../src","sources":["utils/helpers.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"names":["uuidv4","replace","c","r","parseFloat","Math","random","toString","Date","getTime","v","exports","toNativeOptions","options","result","key","Object","keys","value","undefined"],"sourceRoot":"../../../src","sources":["utils/helpers.ts"],"mappings":";;;;;;AAEO,MAAMA,MAAM,GAAGA,CAAA,KAAM;EAC1B,OAAO,sCAAsC,CAACC,OAAO,CAAC,OAAO,EAAE,UAAUC,CAAC,EAAE;IAC1E,MAAMC,CAAC,GAAIC,UAAU,CAAC,IAAI,GAAGC,IAAI,CAACC,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC,CAACN,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,IAAIO,IAAI,CAAC,CAAC,CAACC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,GAAI,CAAC;MACvG;MACAC,CAAC,GAAGR,CAAC,IAAI,GAAG,GAAGC,CAAC,GAAIA,CAAC,GAAG,GAAG,GAAI,GAAG;IACpC,OAAOO,CAAC,CAACH,QAAQ,CAAC,EAAE,CAAC;EACvB,CAAC,CAAC;AACJ,CAAC;;AAED;AACA;AACA;AACA;AACA;AAJAI,OAAA,CAAAX,MAAA,GAAAA,MAAA;AAKO,MAAMY,eAAe,GAAIC,OAAgC,IAAa;EAC3E,MAAMC,MAA+B,GAAG,CAAC,CAAC;EAC1C,KAAK,MAAMC,GAAG,IAAIC,MAAM,CAACC,IAAI,CAACJ,OAAO,CAAC,EAAE;IACtC,MAAMK,KAAK,GAAGL,OAAO,CAACE,GAAG,CAAC;IAC1B,IAAIG,KAAK,KAAKC,SAAS,IAAI,OAAOD,KAAK,KAAK,UAAU,EAAE;MACtDJ,MAAM,CAACC,GAAG,CAAC,GAAGG,KAAK;IACrB;EACF;EACA,OAAOJ,MAAM;AACf,CAAC;AAACH,OAAA,CAAAC,eAAA,GAAAA,eAAA","ignoreList":[]}
|
|
@@ -17,39 +17,39 @@ var _exportNames = {
|
|
|
17
17
|
exports.getVideoMetaData = exports.getRealPath = exports.getImageMetaData = exports.getFileSize = exports.getDetails = exports.generateFilePath = exports.createVideoThumbnail = exports.clearCache = exports.DEFAULT_COMPRESS_AUDIO_OPTIONS = void 0;
|
|
18
18
|
var _Main = require("../Main");
|
|
19
19
|
var _reactNative = require("react-native");
|
|
20
|
-
var
|
|
21
|
-
Object.keys(
|
|
20
|
+
var _helpers = require("./helpers");
|
|
21
|
+
Object.keys(_helpers).forEach(function (key) {
|
|
22
22
|
if (key === "default" || key === "__esModule") return;
|
|
23
23
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
24
|
-
if (key in exports && exports[key] ===
|
|
24
|
+
if (key in exports && exports[key] === _helpers[key]) return;
|
|
25
25
|
Object.defineProperty(exports, key, {
|
|
26
26
|
enumerable: true,
|
|
27
27
|
get: function () {
|
|
28
|
-
return
|
|
28
|
+
return _helpers[key];
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
31
|
});
|
|
32
|
-
var
|
|
33
|
-
Object.keys(
|
|
32
|
+
var _Downloader = require("./Downloader");
|
|
33
|
+
Object.keys(_Downloader).forEach(function (key) {
|
|
34
34
|
if (key === "default" || key === "__esModule") return;
|
|
35
35
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
36
|
-
if (key in exports && exports[key] ===
|
|
36
|
+
if (key in exports && exports[key] === _Downloader[key]) return;
|
|
37
37
|
Object.defineProperty(exports, key, {
|
|
38
38
|
enumerable: true,
|
|
39
39
|
get: function () {
|
|
40
|
-
return
|
|
40
|
+
return _Downloader[key];
|
|
41
41
|
}
|
|
42
42
|
});
|
|
43
43
|
});
|
|
44
|
-
var
|
|
45
|
-
Object.keys(
|
|
44
|
+
var _Uploader = require("./Uploader");
|
|
45
|
+
Object.keys(_Uploader).forEach(function (key) {
|
|
46
46
|
if (key === "default" || key === "__esModule") return;
|
|
47
47
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
48
|
-
if (key in exports && exports[key] ===
|
|
48
|
+
if (key in exports && exports[key] === _Uploader[key]) return;
|
|
49
49
|
Object.defineProperty(exports, key, {
|
|
50
50
|
enumerable: true,
|
|
51
51
|
get: function () {
|
|
52
|
-
return
|
|
52
|
+
return _Uploader[key];
|
|
53
53
|
}
|
|
54
54
|
});
|
|
55
55
|
});
|
|
@@ -89,7 +89,7 @@ const getImageMetaData = async path => {
|
|
|
89
89
|
};
|
|
90
90
|
exports.getImageMetaData = getImageMetaData;
|
|
91
91
|
const createVideoThumbnail = (fileUrl, options = {}) => {
|
|
92
|
-
return _Main.Compressor.createVideoThumbnail(fileUrl, options);
|
|
92
|
+
return _Main.Compressor.createVideoThumbnail(fileUrl, (0, _helpers.toNativeOptions)(options));
|
|
93
93
|
};
|
|
94
94
|
exports.createVideoThumbnail = createVideoThumbnail;
|
|
95
95
|
const clearCache = cacheDir => {
|