react-native-blob-util 0.16.3 → 0.17.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/.eslintrc.js +29 -3
- package/Migration.md +41 -0
- package/README.md +13 -6
- package/android/build.gradle +19 -1
- package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilBody.java +6 -6
- package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilFS.java +12 -8
- package/android/src/main/java/com/ReactNativeBlobUtil/{ReactNativeBlobUtil.java → ReactNativeBlobUtilImpl.java} +19 -78
- package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilMediaCollection.java +5 -5
- package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilPackage.java +31 -21
- package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilReq.java +25 -23
- package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilStream.java +6 -6
- package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilUtils.java +2 -2
- package/android/src/main/java/com/ReactNativeBlobUtil/Utils/MimeType.java +1 -1
- package/android/src/newarch/java/com/ReactNativeBlobUtil/ReactNativeBlobUtil.java +281 -0
- package/android/src/oldarch/java/com/ReactNativeBlobUtil/ReactNativeBlobUtil.java +242 -0
- package/android.js +2 -3
- package/class/ReactNativeBlobUtilFile.js +1 -13
- package/class/ReactNativeBlobUtilReadStream.js +1 -2
- package/class/ReactNativeBlobUtilSession.js +1 -2
- package/class/ReactNativeBlobUtilWriteStream.js +1 -3
- package/codegenSpecs/NativeBlobUtils.js +77 -0
- package/fetch.js +2 -2
- package/fs.js +15 -22
- package/index.js +2 -2
- package/ios/ReactNativeBlobUtil/ReactNativeBlobUtil.h +10 -1
- package/ios/ReactNativeBlobUtil/{ReactNativeBlobUtil.m → ReactNativeBlobUtil.mm} +334 -41
- package/ios/{ReactNativeBlobUtilConst.m → ReactNativeBlobUtilConst.mm} +0 -0
- package/ios/ReactNativeBlobUtilFS.h +5 -5
- package/ios/{ReactNativeBlobUtilFS.m → ReactNativeBlobUtilFS.mm} +32 -26
- package/ios/{ReactNativeBlobUtilFileTransformer.m → ReactNativeBlobUtilFileTransformer.mm} +0 -0
- package/ios/ReactNativeBlobUtilNetwork.h +2 -2
- package/ios/{ReactNativeBlobUtilNetwork.m → ReactNativeBlobUtilNetwork.mm} +15 -17
- package/ios/{ReactNativeBlobUtilProgress.m → ReactNativeBlobUtilProgress.mm} +4 -4
- package/ios/{ReactNativeBlobUtilReqBuilder.m → ReactNativeBlobUtilReqBuilder.mm} +4 -4
- package/ios/ReactNativeBlobUtilRequest.h +4 -2
- package/ios/{ReactNativeBlobUtilRequest.m → ReactNativeBlobUtilRequest.mm} +16 -11
- package/ios.js +2 -3
- package/mediacollection.js +2 -4
- package/package.json +7 -2
- package/react-native-blob-util.podspec +21 -1
- package/examples/ReactNativeBlobUtil/.buckconfig +0 -6
- package/examples/ReactNativeBlobUtil/.eslintrc.js +0 -4
- package/examples/ReactNativeBlobUtil/.prettierrc.js +0 -6
- package/examples/ReactNativeBlobUtil/App.js +0 -698
- package/examples/ReactNativeBlobUtil/index.js +0 -9
- package/examples/ReactNativeBlobUtil/metro.config.js +0 -27
- package/examples/ReactNativeBlobUtil/package.json +0 -31
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/App.cpp +0 -80
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/App.h +0 -20
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/App.idl +0 -3
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/App.xaml +0 -10
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/Assets/LockScreenLogo.scale-200.png +0 -0
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/Assets/SplashScreen.scale-200.png +0 -0
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/Assets/Square150x150Logo.scale-200.png +0 -0
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/Assets/Square44x44Logo.scale-200.png +0 -0
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/Assets/Square44x44Logo.targetsize-24_altform-unplated.png +0 -0
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/Assets/StoreLogo.png +0 -0
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/Assets/Wide310x150Logo.scale-200.png +0 -0
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/AutolinkedNativeModules.g.cpp +0 -18
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/AutolinkedNativeModules.g.h +0 -10
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/AutolinkedNativeModules.g.targets +0 -11
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/MainPage.cpp +0 -24
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/MainPage.h +0 -21
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/MainPage.idl +0 -8
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/MainPage.xaml +0 -16
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/Package.appxmanifest +0 -50
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/PropertySheet.props +0 -16
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/ReactNativeBlobUtilWin.vcxproj +0 -196
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/ReactNativeBlobUtilWin.vcxproj.filters +0 -65
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/ReactNativeBlobUtilWin_TemporaryKey.pfx +0 -0
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/ReactPackageProvider.cpp +0 -18
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/ReactPackageProvider.h +0 -15
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/packages.config +0 -5
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/pch.cpp +0 -1
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/pch.h +0 -26
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin.sln +0 -207
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import type { TurboModule } from 'react-native/Libraries/TurboModule/RCTExport';
|
|
3
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
4
|
+
|
|
5
|
+
export interface Spec extends TurboModule {
|
|
6
|
+
+getConstants: () => {|
|
|
7
|
+
CacheDir: string,
|
|
8
|
+
DocumentDir: string,
|
|
9
|
+
DownloadDir: string,
|
|
10
|
+
LibraryDir: string,
|
|
11
|
+
MainBundleDir: string,
|
|
12
|
+
MovieDir: string,
|
|
13
|
+
MusicDir: string,
|
|
14
|
+
PictureDir: string,
|
|
15
|
+
ApplicationSupportDir: string,
|
|
16
|
+
// Android Only Constants
|
|
17
|
+
RingtoneDir: string,
|
|
18
|
+
SDCardDir: string,
|
|
19
|
+
SDCardApplicationDir: string,
|
|
20
|
+
DCIMDir: string,
|
|
21
|
+
|};
|
|
22
|
+
|
|
23
|
+
+fetchBlobForm: (options: Object, taskId: string, method: string, url: string, headers: Object, form: Array<any>, callback: (value: Array<any>) => void) => void;
|
|
24
|
+
+fetchBlob: (options: Object, taskId: string, method: string, url: string, headers: Object, body: string, callback: (value: Array<any>) => void) => void;
|
|
25
|
+
+createFile: (path: string, data: string, encoding: string) => Promise<void>;
|
|
26
|
+
+createFileASCII: (path: string, data: Array<any>) => Promise<void>;
|
|
27
|
+
+pathForAppGroup: (groupName: string) => Promise<string>;
|
|
28
|
+
+syncPathAppGroup: (groupName: string) => string;
|
|
29
|
+
+exists: (path: string, callback: (value: Array<boolean>) => void) => void;
|
|
30
|
+
+writeFile: (path: string, encoding: string, data: string, transformFile: boolean, append: boolean) => Promise<number>;
|
|
31
|
+
+writeFileArray: (path: string, data: Array<any>, append: boolean) => Promise<number>;
|
|
32
|
+
+writeStream: (path: string, withEncoding: string, appendData: boolean, callback: (value: Array<any>) => void) => void;
|
|
33
|
+
+writeArrayChunk: (streamId: string, withArray: Array<any>, callback: (value: Array<any>) => void) => void;
|
|
34
|
+
+writeChunk: (streamId: string, withData: string, callback: (value: Array<any>) => void) => void;
|
|
35
|
+
+closeStream: (streamId: string, callback: (value: Array<any>) => void) => void;
|
|
36
|
+
+unlink: (path: string, callback: (value: Array<any>) => void) => void;
|
|
37
|
+
+removeSession: (paths: Array<any>, callback: (value: Array<any>) => void) => void;
|
|
38
|
+
+ls: (path: string) => Promise<Array<any>>;
|
|
39
|
+
+stat: (target: string, callback: (value: Array<any>) => void) => void;
|
|
40
|
+
+lstat: (path: string, callback: (value: Array<any>) => void) => void;
|
|
41
|
+
+cp: (src: string, dest: string, callback: (value: Array<any>) => void) => void;
|
|
42
|
+
+mv: (path: string, dest: string, callback: (value: Array<any>) => void) => void;
|
|
43
|
+
+mkdir: (path: string) => Promise<boolean>;
|
|
44
|
+
+readFile: (path: string, encoding: string, transformFile: boolean) => Promise<Array<any>>;
|
|
45
|
+
+hash: (path: string, algorithm: string) => Promise<string>;
|
|
46
|
+
+readStream: (path: string, encoding: string, bufferSize: number, tick: number, streamId: string) => void;
|
|
47
|
+
+getEnvironmentDirs: (callback: (value: Array<any>) => void) => void;
|
|
48
|
+
+cancelRequest: (taskId: string, callback: (value: Array<any>) => void) => void;
|
|
49
|
+
+enableProgressReport: (taskId: string, interval: number, count: number) => void;
|
|
50
|
+
+enableUploadProgressReport: (taskId: string, interval: number, count: number) => void;
|
|
51
|
+
+slice: (src: string, dest: string, start: number, end: number) => Promise<string>;
|
|
52
|
+
+presentOptionsMenu: (uri: string, scheme: string) => Promise<Array<any>>;
|
|
53
|
+
+presentOpenInMenu: (uri: string, scheme: string) => Promise<Array<any>>;
|
|
54
|
+
+presentPreview: (uri: string, scheme: string) => Promise<Array<any>>;
|
|
55
|
+
+excludeFromBackupKey: (url: string) => Promise<Array<any>>;
|
|
56
|
+
+df: (callback: (value: Array<any>) => void) => void;
|
|
57
|
+
+emitExpiredEvent: (callback: (value: string) => void) => void; // The callback is not really used here
|
|
58
|
+
// Android Only APIs
|
|
59
|
+
+actionViewIntent: (path: string, mime: string, chooserTitle: string) => Promise<void>;
|
|
60
|
+
+addCompleteDownload: (config: Object) => Promise<void>;
|
|
61
|
+
+copyToInternal: (contentUri: string, destpath: string) => Promise<string>;
|
|
62
|
+
+copyToMediaStore: (filedata: Object, mt: string, path: string) => Promise<string>;
|
|
63
|
+
+createMediaFile: (filedata: Object, mt: string) => Promise<string>;
|
|
64
|
+
+getBlob: (contentUri: string, encoding: string) => Promise<Array<any>>;
|
|
65
|
+
+getContentIntent: (mime: string) => Promise<string>;
|
|
66
|
+
+getSDCardDir: () => Promise<string>;
|
|
67
|
+
+getSDCardApplicationDir: () => Promise<string>;
|
|
68
|
+
+scanFile: (pairs: Array<any>, callback: (value: Array<any>) => void) => void;
|
|
69
|
+
+writeToMediaFile: (fileUri: string, path: string, transformFile: boolean) => Promise<string>;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export default (TurboModuleRegistry.get<Spec>(
|
|
73
|
+
'ReactNativeBlobUtil'
|
|
74
|
+
): ?Spec);
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
package/fetch.js
CHANGED
|
@@ -2,11 +2,11 @@ import {ReactNativeBlobUtilConfig} from "./types";
|
|
|
2
2
|
import URIUtil from "./utils/uri";
|
|
3
3
|
import fs from "./fs";
|
|
4
4
|
import getUUID from "./utils/uuid";
|
|
5
|
-
import {DeviceEventEmitter
|
|
5
|
+
import {DeviceEventEmitter} from "react-native";
|
|
6
6
|
import {FetchBlobResponse} from "./class/ReactNativeBlobUtilBlobResponse";
|
|
7
|
+
import ReactNativeBlobUtil from "./codegenSpecs/NativeBlobUtils";
|
|
7
8
|
|
|
8
9
|
const emitter = DeviceEventEmitter;
|
|
9
|
-
const ReactNativeBlobUtil = NativeModules.ReactNativeBlobUtil;
|
|
10
10
|
|
|
11
11
|
// register message channel event handler.
|
|
12
12
|
emitter.addListener("ReactNativeBlobUtilMessage", (e) => {
|
package/fs.js
CHANGED
|
@@ -4,35 +4,28 @@
|
|
|
4
4
|
|
|
5
5
|
// import type {ReactNativeBlobUtilConfig, ReactNativeBlobUtilNative, ReactNativeBlobUtilStream} from './types'
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import {Platform} from 'react-native';
|
|
8
8
|
import ReactNativeBlobUtilSession from './class/ReactNativeBlobUtilSession';
|
|
9
9
|
import ReactNativeBlobUtilWriteStream from './class/ReactNativeBlobUtilWriteStream';
|
|
10
10
|
import ReactNativeBlobUtilReadStream from './class/ReactNativeBlobUtilReadStream';
|
|
11
11
|
import ReactNativeBlobUtilFile from './class/ReactNativeBlobUtilFile';
|
|
12
|
+
import ReactNativeBlobUtil from './codegenSpecs/NativeBlobUtils';
|
|
12
13
|
|
|
13
|
-
const
|
|
14
|
+
const constants = ReactNativeBlobUtil.getConstants();
|
|
14
15
|
|
|
15
16
|
const dirs = {
|
|
16
|
-
DocumentDir:
|
|
17
|
-
CacheDir:
|
|
18
|
-
PictureDir:
|
|
19
|
-
MusicDir:
|
|
20
|
-
MovieDir:
|
|
21
|
-
DownloadDir:
|
|
22
|
-
DCIMDir:
|
|
23
|
-
SDCardDir:
|
|
24
|
-
SDCardApplicationDir:
|
|
25
|
-
MainBundleDir:
|
|
26
|
-
LibraryDir:
|
|
27
|
-
ApplicationSupportDir:
|
|
28
|
-
|
|
29
|
-
LegacyPictureDir: ReactNativeBlobUtil.LegacyPictureDir,
|
|
30
|
-
LegacyMusicDir: ReactNativeBlobUtil.LegacyMusicDir,
|
|
31
|
-
LegacyMovieDir: ReactNativeBlobUtil.LegacyMovieDir,
|
|
32
|
-
LegacyDownloadDir: ReactNativeBlobUtil.LegacyDownloadDir,
|
|
33
|
-
LegacyDCIMDir: ReactNativeBlobUtil.LegacyDCIMDir,
|
|
34
|
-
LegacySDCardDir: ReactNativeBlobUtil.LegacySDCardDir, // Depracated
|
|
35
|
-
|
|
17
|
+
DocumentDir: constants.DocumentDir,
|
|
18
|
+
CacheDir: constants.CacheDir,
|
|
19
|
+
PictureDir: constants.PictureDir,
|
|
20
|
+
MusicDir: constants.MusicDir,
|
|
21
|
+
MovieDir: constants.MovieDir,
|
|
22
|
+
DownloadDir: constants.DownloadDir,
|
|
23
|
+
DCIMDir: constants.DCIMDir,
|
|
24
|
+
SDCardDir: constants.SDCardDir, // Depracated
|
|
25
|
+
SDCardApplicationDir: constants.SDCardApplicationDir, // Deprecated
|
|
26
|
+
MainBundleDir: constants.MainBundleDir,
|
|
27
|
+
LibraryDir: constants.LibraryDir,
|
|
28
|
+
ApplicationSupportDir: constants.ApplicationSupportDir,
|
|
36
29
|
};
|
|
37
30
|
|
|
38
31
|
function addCode(code: string, error: Error): Error {
|
package/index.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
// Use of this source code is governed by a MIT-style license that can be
|
|
3
3
|
// found in the LICENSE file.
|
|
4
4
|
|
|
5
|
-
import {AppState, DeviceEventEmitter,
|
|
5
|
+
import {AppState, DeviceEventEmitter, Platform,} from 'react-native';
|
|
6
|
+
import ReactNativeBlobUtil from './codegenSpecs/NativeBlobUtils';
|
|
6
7
|
|
|
7
8
|
//import StatefulPromise from './class/StatefulPromise.js'
|
|
8
9
|
import fs from './fs';
|
|
@@ -33,7 +34,6 @@ const {
|
|
|
33
34
|
|
|
34
35
|
const Blob = polyfill.Blob;
|
|
35
36
|
const emitter = DeviceEventEmitter;
|
|
36
|
-
const ReactNativeBlobUtil = NativeModules.ReactNativeBlobUtil;
|
|
37
37
|
const wrap = URIUtil.wrap;
|
|
38
38
|
|
|
39
39
|
// when app resumes, check if there's any expired network task and trigger
|
|
@@ -28,6 +28,10 @@
|
|
|
28
28
|
|
|
29
29
|
#import <UIKit/UIKit.h>
|
|
30
30
|
|
|
31
|
+
#if RCT_NEW_ARCH_ENABLED
|
|
32
|
+
#import <React-Codegen/ReactNativeBlobUtilSpec/ReactNativeBlobUtilSpec.h>
|
|
33
|
+
#endif
|
|
34
|
+
|
|
31
35
|
|
|
32
36
|
@interface ReactNativeBlobUtil : NSObject <RCTBridgeModule, UIDocumentInteractionControllerDelegate> {
|
|
33
37
|
|
|
@@ -38,8 +42,13 @@
|
|
|
38
42
|
@property (nonatomic) NSString * filePathPrefix;
|
|
39
43
|
@property (retain) UIDocumentInteractionController * documentController;
|
|
40
44
|
|
|
41
|
-
+ (
|
|
45
|
+
+ (RCTEventDispatcher *)getRCTEventDispatcher;
|
|
42
46
|
|
|
43
47
|
@end
|
|
44
48
|
|
|
49
|
+
#if RCT_NEW_ARCH_ENABLED
|
|
50
|
+
@interface ReactNativeBlobUtil () <NativeBlobUtilsSpec>
|
|
51
|
+
@end
|
|
52
|
+
#endif
|
|
53
|
+
|
|
45
54
|
#endif /* ReactNativeBlobUtil_h */
|