react-native-ota-hot-update 1.1.1 → 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/LICENSE +1 -2
- package/README.md +20 -8
- package/android/build.gradle +32 -4
- package/android/generated/java/com/otahotupdate/NativeOtaHotUpdateSpec.java +54 -0
- package/android/generated/jni/CMakeLists.txt +36 -0
- package/android/generated/jni/RNOtaHotUpdateSpec-generated.cpp +56 -0
- package/android/generated/jni/RNOtaHotUpdateSpec.h +31 -0
- package/android/generated/jni/react/renderer/components/RNOtaHotUpdateSpec/ComponentDescriptors.cpp +22 -0
- package/android/generated/jni/react/renderer/components/RNOtaHotUpdateSpec/ComponentDescriptors.h +24 -0
- package/android/generated/jni/react/renderer/components/RNOtaHotUpdateSpec/EventEmitters.cpp +16 -0
- package/android/generated/jni/react/renderer/components/RNOtaHotUpdateSpec/EventEmitters.h +17 -0
- package/android/generated/jni/react/renderer/components/RNOtaHotUpdateSpec/Props.cpp +19 -0
- package/android/generated/jni/react/renderer/components/RNOtaHotUpdateSpec/Props.h +18 -0
- package/android/generated/jni/react/renderer/components/RNOtaHotUpdateSpec/RNOtaHotUpdateSpecJSI-generated.cpp +56 -0
- package/android/generated/jni/react/renderer/components/RNOtaHotUpdateSpec/RNOtaHotUpdateSpecJSI.h +103 -0
- package/android/generated/jni/react/renderer/components/RNOtaHotUpdateSpec/ShadowNodes.cpp +17 -0
- package/android/generated/jni/react/renderer/components/RNOtaHotUpdateSpec/ShadowNodes.h +23 -0
- package/android/generated/jni/react/renderer/components/RNOtaHotUpdateSpec/States.cpp +16 -0
- package/android/generated/jni/react/renderer/components/RNOtaHotUpdateSpec/States.h +19 -0
- package/android/gradle.properties +5 -5
- package/android/src/main/AndroidManifest.xml +1 -1
- package/android/src/main/java/com/otahotupdate/OtaHotUpdate.kt +57 -0
- package/android/src/main/java/com/otahotupdate/OtaHotUpdateModule.kt +142 -0
- package/android/src/newarch/OtaHotUpdateSpec.kt +7 -0
- package/android/src/oldarch/OtaHotUpdateSpec.kt +15 -0
- package/ios/OtaHotUpdate.h +13 -0
- package/ios/{RNhotupdate.m → OtaHotUpdate.mm} +50 -33
- package/ios/generated/RNOtaHotUpdateSpec/ComponentDescriptors.cpp +22 -0
- package/ios/generated/RNOtaHotUpdateSpec/ComponentDescriptors.h +24 -0
- package/ios/generated/RNOtaHotUpdateSpec/EventEmitters.cpp +16 -0
- package/ios/generated/RNOtaHotUpdateSpec/EventEmitters.h +17 -0
- package/ios/generated/RNOtaHotUpdateSpec/Props.cpp +19 -0
- package/ios/generated/RNOtaHotUpdateSpec/Props.h +18 -0
- package/ios/generated/RNOtaHotUpdateSpec/RCTComponentViewHelpers.h +18 -0
- package/ios/generated/RNOtaHotUpdateSpec/RNOtaHotUpdateSpec-generated.mm +67 -0
- package/ios/generated/RNOtaHotUpdateSpec/RNOtaHotUpdateSpec.h +72 -0
- package/ios/generated/RNOtaHotUpdateSpec/ShadowNodes.cpp +17 -0
- package/ios/generated/RNOtaHotUpdateSpec/ShadowNodes.h +23 -0
- package/ios/generated/RNOtaHotUpdateSpec/States.cpp +16 -0
- package/ios/generated/RNOtaHotUpdateSpec/States.h +19 -0
- package/ios/generated/RNOtaHotUpdateSpecJSI-generated.cpp +56 -0
- package/ios/generated/RNOtaHotUpdateSpecJSI.h +103 -0
- package/lib/commonjs/NativeOtaHotUpdate.js +9 -0
- package/lib/commonjs/NativeOtaHotUpdate.js.map +1 -0
- package/lib/commonjs/download.d.js +2 -0
- package/lib/commonjs/download.d.js.map +1 -0
- package/lib/commonjs/index.js +113 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/module/NativeOtaHotUpdate.js +5 -0
- package/lib/module/NativeOtaHotUpdate.js.map +1 -0
- package/lib/module/download.d.js +2 -0
- package/lib/module/download.d.js.map +1 -0
- package/lib/module/index.js +109 -0
- package/lib/module/index.js.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/NativeOtaHotUpdate.d.ts +11 -0
- package/lib/typescript/commonjs/src/NativeOtaHotUpdate.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +25 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/NativeOtaHotUpdate.d.ts +11 -0
- package/lib/typescript/module/src/NativeOtaHotUpdate.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +25 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/package.json +184 -12
- package/{rn-hotupdate.podspec → react-native-ota-hot-update.podspec} +3 -3
- package/react-native.config.js +10 -6
- package/src/NativeOtaHotUpdate.ts +12 -0
- package/src/download.d.ts +759 -689
- package/src/index.tsx +67 -40
- package/android/src/main/java/com/rnhotupdate/HotUpdateModule.java +0 -161
- package/android/src/main/java/com/rnhotupdate/OtaHotUpdate.java +0 -45
- package/ios/RNhotupdate.h +0 -12
- package/ios/RNhotupdate.xcodeproj/project.pbxproj +0 -281
- package/ios/RNhotupdate.xcworkspace/contents.xcworkspacedata +0 -7
- /package/android/src/main/java/com/{rnhotupdate → otahotupdate}/SharedPrefs.kt +0 -0
package/src/download.d.ts
CHANGED
|
@@ -1,860 +1,930 @@
|
|
|
1
|
-
|
|
2
1
|
interface DownloadManager {
|
|
3
|
-
|
|
2
|
+
fetch(
|
|
3
|
+
method: Methods,
|
|
4
|
+
url: string,
|
|
5
|
+
headers?: { [key: string]: string },
|
|
6
|
+
body?: any | null
|
|
7
|
+
): StatefulPromise<FetchBlobResponse>;
|
|
4
8
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
9
|
+
base64: { encode(input: string): string; decode(input: string): string };
|
|
10
|
+
android: AndroidApi;
|
|
11
|
+
ios: IOSApi;
|
|
8
12
|
|
|
9
|
-
|
|
13
|
+
config(options: ReactNativeBlobUtilConfig): DownloadManager;
|
|
10
14
|
|
|
11
|
-
|
|
15
|
+
session(name: string): ReactNativeBlobUtilSession;
|
|
12
16
|
|
|
13
|
-
|
|
14
|
-
|
|
17
|
+
fs: FS;
|
|
18
|
+
MediaCollection: MediaCollection;
|
|
15
19
|
|
|
16
|
-
|
|
20
|
+
wrap(path: string): string;
|
|
17
21
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
net: Net;
|
|
23
|
+
polyfill: Polyfill;
|
|
24
|
+
// this require external module https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/oboe
|
|
25
|
+
JSONStream: any;
|
|
22
26
|
}
|
|
23
27
|
|
|
24
28
|
export interface Polyfill {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
Blob: PolyfillBlob;
|
|
30
|
+
File: PolyfillFile;
|
|
31
|
+
XMLHttpRequest: PolyfillXMLHttpRequest;
|
|
32
|
+
ProgressEvent: PolyfillProgressEvent;
|
|
33
|
+
Event: PolyfillEvent;
|
|
34
|
+
FileReader: PolyfillFileReader;
|
|
35
|
+
Fetch: PolyfillFetch;
|
|
32
36
|
}
|
|
33
37
|
|
|
34
38
|
export declare class PolyfillFetch extends ReactNativeBlobUtilFetchPolyfill {
|
|
35
|
-
|
|
39
|
+
constructor(config: ReactNativeBlobUtilConfig);
|
|
36
40
|
}
|
|
37
41
|
|
|
38
42
|
export declare class ReactNativeBlobUtilFetchPolyfill {
|
|
39
|
-
|
|
43
|
+
constructor(config: ReactNativeBlobUtilConfig);
|
|
40
44
|
|
|
41
|
-
|
|
45
|
+
build(): (
|
|
46
|
+
url: string,
|
|
47
|
+
options: ReactNativeBlobUtilConfig
|
|
48
|
+
) => StatefulPromise<ReactNativeBlobUtilFetchRepsonse>;
|
|
42
49
|
}
|
|
43
50
|
|
|
44
51
|
export interface ReactNativeBlobUtilFetchRepsonse {
|
|
45
|
-
|
|
52
|
+
arrayBuffer(): Promise<any[]>;
|
|
46
53
|
|
|
47
|
-
|
|
54
|
+
blob(): Promise<PolyfillBlob>;
|
|
48
55
|
|
|
49
|
-
|
|
56
|
+
json(): Promise<any>;
|
|
50
57
|
|
|
51
|
-
|
|
58
|
+
rawResp(): Promise<FetchBlobResponse>;
|
|
52
59
|
|
|
53
|
-
|
|
60
|
+
text(): Promise<string>;
|
|
54
61
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
bodyUsed: boolean;
|
|
63
|
+
headers: any;
|
|
64
|
+
ok: boolean;
|
|
65
|
+
resp: FetchBlobResponse;
|
|
66
|
+
rnfbResp: FetchBlobResponse;
|
|
67
|
+
rnfbRespInfo: ReactNativeBlobUtilResponseInfo;
|
|
68
|
+
status: number;
|
|
69
|
+
type: string;
|
|
63
70
|
}
|
|
64
71
|
|
|
65
72
|
/**
|
|
66
73
|
* ReactNativeBlobUtil response object class.
|
|
67
74
|
*/
|
|
68
75
|
export interface FetchBlobResponse {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
76
|
+
taskId: string;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* get path of response temp file
|
|
80
|
+
* @return File path of temp file.
|
|
81
|
+
*/
|
|
82
|
+
path(): string;
|
|
83
|
+
|
|
84
|
+
type: 'base64' | 'path' | 'utf8';
|
|
85
|
+
data: any;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Convert result to javascript ReactNativeBlobUtil object.
|
|
89
|
+
* @return Return a promise resolves Blob object.
|
|
90
|
+
*/
|
|
91
|
+
blob(contentType: string, sliceSize: number): Promise<PolyfillBlob>;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Convert result to text.
|
|
95
|
+
* @return Decoded base64 string.
|
|
96
|
+
*/
|
|
97
|
+
text(): string | Promise<any>;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Convert result to JSON object.
|
|
101
|
+
* @return Parsed javascript object.
|
|
102
|
+
*/
|
|
103
|
+
json(): any;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Return BASE64 string directly.
|
|
107
|
+
* @return BASE64 string of response body.
|
|
108
|
+
*/
|
|
109
|
+
base64(): any;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Remove cahced file
|
|
113
|
+
*/
|
|
114
|
+
flush(): void;
|
|
115
|
+
|
|
116
|
+
respInfo: ReactNativeBlobUtilResponseInfo;
|
|
117
|
+
|
|
118
|
+
info(): ReactNativeBlobUtilResponseInfo;
|
|
119
|
+
|
|
120
|
+
session(name: string): ReactNativeBlobUtilSession | null;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Read file content with given encoding, if the response does not contains
|
|
124
|
+
* a file path, show warning message
|
|
125
|
+
* @param encode Encode type, should be one of `base64`, `ascrii`, `utf8`.
|
|
126
|
+
*/
|
|
127
|
+
readFile(encode: Encoding): Promise<any> | null;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Start read stream from cached file
|
|
131
|
+
* @param encode Encode type, should be one of `base64`, `ascrii`, `utf8`.
|
|
132
|
+
*/
|
|
133
|
+
readStream(encode: Encoding): ReactNativeBlobUtilStream | null;
|
|
127
134
|
}
|
|
128
135
|
|
|
129
136
|
export interface PolyfillFileReader extends EventTarget {
|
|
130
|
-
|
|
137
|
+
isRNFBPolyFill: boolean;
|
|
131
138
|
|
|
132
|
-
|
|
139
|
+
onloadstart(e: Event): void;
|
|
133
140
|
|
|
134
|
-
|
|
141
|
+
onprogress(e: Event): void;
|
|
135
142
|
|
|
136
|
-
|
|
143
|
+
onload(e: Event): void;
|
|
137
144
|
|
|
138
|
-
|
|
145
|
+
onabort(e: Event): void;
|
|
139
146
|
|
|
140
|
-
|
|
147
|
+
onerror(e: Event): void;
|
|
141
148
|
|
|
142
|
-
|
|
149
|
+
onloadend(e: Event): void;
|
|
143
150
|
|
|
144
|
-
|
|
151
|
+
abort(): void;
|
|
145
152
|
|
|
146
|
-
|
|
153
|
+
readAsArrayBuffer(b: PolyfillBlob): void;
|
|
147
154
|
|
|
148
|
-
|
|
155
|
+
readAsBinaryString(b: PolyfillBlob): void;
|
|
149
156
|
|
|
150
|
-
|
|
157
|
+
readAsText(b: PolyfillBlob, label?: string): void;
|
|
151
158
|
|
|
152
|
-
|
|
159
|
+
readAsDataURL(b: PolyfillBlob): void;
|
|
153
160
|
|
|
154
|
-
|
|
155
|
-
|
|
161
|
+
readyState: number;
|
|
162
|
+
result: number;
|
|
156
163
|
}
|
|
157
164
|
|
|
158
165
|
export declare namespace PolyfillFileReader {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
166
|
+
const EMPTY: number;
|
|
167
|
+
const LOADING: number;
|
|
168
|
+
const DONE: number;
|
|
162
169
|
}
|
|
163
170
|
|
|
164
171
|
export declare class PolyfillEvent {}
|
|
165
172
|
|
|
166
173
|
export interface PolyfillProgressEvent extends EventTarget {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
174
|
+
lengthComputable: boolean;
|
|
175
|
+
loaded: number;
|
|
176
|
+
total: number;
|
|
170
177
|
}
|
|
171
178
|
|
|
172
179
|
export declare class PolyfillBlob implements EventTarget {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
180
|
+
/**
|
|
181
|
+
* ReactNativeBlobUtil Blob polyfill, create a Blob directly from file path, BASE64
|
|
182
|
+
* encoded data, and string. The conversion is done implicitly according to
|
|
183
|
+
* given `mime`. However, the blob creation is asynchronously, to register
|
|
184
|
+
* event `onCreated` is need to ensure the Blob is creadted.
|
|
185
|
+
*
|
|
186
|
+
* @param data Content of Blob object
|
|
187
|
+
* @param cType Content type settings of Blob object, `text/plain` by default
|
|
188
|
+
* @param defer When this argument set to `true`, blob constructor will not invoke blob created event automatically.
|
|
189
|
+
*/
|
|
190
|
+
constructor(data: any, cType: any, defer: boolean);
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Since Blob content will asynchronously write to a file during creation,
|
|
194
|
+
* use this method to register an event handler for Blob initialized event.
|
|
195
|
+
* @param fn An event handler invoked when Blob created
|
|
196
|
+
* @return The Blob object instance itself
|
|
197
|
+
*/
|
|
198
|
+
onCreated(fn: () => void): PolyfillBlob;
|
|
199
|
+
|
|
200
|
+
markAsDerived(): void;
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Get file reference of the Blob object.
|
|
204
|
+
* @return Blob file reference which can be consumed by ReactNativeBlobUtil fs
|
|
205
|
+
*/
|
|
206
|
+
getReactNativeBlobUtilRef(): string;
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Create a Blob object which is sliced from current object
|
|
210
|
+
* @param start Start byte number
|
|
211
|
+
* @param end End byte number
|
|
212
|
+
* @param contentType Optional, content type of new Blob object
|
|
213
|
+
*/
|
|
214
|
+
slice(start?: number, end?: number, contentType?: string): PolyfillBlob;
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Read data of the Blob object, this is not standard method.
|
|
218
|
+
* @param encoding Read data with encoding
|
|
219
|
+
*/
|
|
220
|
+
readBlob(encoding: string): Promise<any>;
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Release the resource of the Blob object.
|
|
224
|
+
* @nonstandard
|
|
225
|
+
*/
|
|
226
|
+
close(): Promise<void>;
|
|
220
227
|
}
|
|
221
228
|
|
|
222
229
|
export declare namespace PolyfillBlob {
|
|
223
|
-
|
|
230
|
+
function clearCache(): void;
|
|
224
231
|
|
|
225
|
-
|
|
232
|
+
function build(data: any, cType: any): Promise<PolyfillBlob>;
|
|
226
233
|
|
|
227
|
-
|
|
234
|
+
function setLog(level: number): void;
|
|
228
235
|
}
|
|
229
236
|
|
|
230
237
|
export declare class PolyfillFile extends PolyfillBlob {}
|
|
231
238
|
|
|
232
|
-
export interface PolyfillXMLHttpRequest
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
239
|
+
export interface PolyfillXMLHttpRequest
|
|
240
|
+
extends PolyfillXMLHttpRequestEventTarget {
|
|
241
|
+
upload: PolyfillXMLHttpRequestEventTarget;
|
|
242
|
+
readonly UNSENT: number;
|
|
243
|
+
readonly OPENED: number;
|
|
244
|
+
readonly HEADERS_RECEIVED: number;
|
|
245
|
+
readonly LOADING: number;
|
|
246
|
+
readonly DONE: number;
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* XMLHttpRequest.open, always async, user and password not supported. When
|
|
250
|
+
* this method invoked, headers should becomes empty again.
|
|
251
|
+
* @param method Request method
|
|
252
|
+
* @param url Request URL
|
|
253
|
+
* @param async Always async
|
|
254
|
+
* @param user NOT SUPPORTED
|
|
255
|
+
* @param password NOT SUPPORTED
|
|
256
|
+
*/
|
|
257
|
+
open(
|
|
258
|
+
method: string,
|
|
259
|
+
url: string,
|
|
260
|
+
async: true,
|
|
261
|
+
user: any,
|
|
262
|
+
password: any
|
|
263
|
+
): void;
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Invoke this function to send HTTP request, and set body.
|
|
267
|
+
* @param body Body in ReactNativeBlobUtil flavor
|
|
268
|
+
*/
|
|
269
|
+
send(body: any): void;
|
|
270
|
+
|
|
271
|
+
overrideMimeType(mime: string): void;
|
|
272
|
+
|
|
273
|
+
setRequestHeader(name: string, value: string): void;
|
|
274
|
+
|
|
275
|
+
abort(): void;
|
|
276
|
+
|
|
277
|
+
getResponseHeader(field: string): string | null;
|
|
278
|
+
|
|
279
|
+
getAllResponseHeaders(): string | null;
|
|
280
|
+
|
|
281
|
+
onreadystatechange(e: Event): void;
|
|
282
|
+
|
|
283
|
+
readyState: number;
|
|
284
|
+
status: number;
|
|
285
|
+
statusText: string;
|
|
286
|
+
response: any;
|
|
287
|
+
responseText: any;
|
|
288
|
+
responseURL: string;
|
|
289
|
+
responseHeaders: any;
|
|
290
|
+
timeout: number;
|
|
291
|
+
responseType: string;
|
|
278
292
|
}
|
|
279
293
|
|
|
280
294
|
export declare namespace PolyfillXMLHttpRequest {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
295
|
+
const binaryContentTypes: string[];
|
|
296
|
+
const UNSENT: number;
|
|
297
|
+
const OPENED: number;
|
|
298
|
+
const HEADERS_RECEIVED: number;
|
|
299
|
+
const LOADING: number;
|
|
300
|
+
const DONE: number;
|
|
287
301
|
|
|
288
|
-
|
|
302
|
+
function setLog(level: number): void;
|
|
289
303
|
|
|
290
|
-
|
|
304
|
+
function addBinaryContentType(substr: string): void;
|
|
291
305
|
|
|
292
|
-
|
|
306
|
+
function removeBinaryContentType(): void;
|
|
293
307
|
}
|
|
294
308
|
|
|
295
309
|
export interface PolyfillXMLHttpRequestEventTarget extends EventTarget {
|
|
296
|
-
|
|
310
|
+
onabort(e: Event): void;
|
|
297
311
|
|
|
298
|
-
|
|
312
|
+
onerror(e: Event): void;
|
|
299
313
|
|
|
300
|
-
|
|
314
|
+
onload(e: Event): void;
|
|
301
315
|
|
|
302
|
-
|
|
316
|
+
onloadstart(e: Event): void;
|
|
303
317
|
|
|
304
|
-
|
|
318
|
+
onprogress(e: Event): void;
|
|
305
319
|
|
|
306
|
-
|
|
320
|
+
ontimeout(e: Event): void;
|
|
307
321
|
|
|
308
|
-
|
|
322
|
+
onloadend(e: Event): void;
|
|
309
323
|
}
|
|
310
324
|
|
|
311
325
|
export interface Net {
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
326
|
+
/**
|
|
327
|
+
* Get cookie according to the given url.
|
|
328
|
+
* @param domain Domain of the cookies to be removed, remove all
|
|
329
|
+
* @return Cookies of a specific domain.
|
|
330
|
+
*/
|
|
331
|
+
getCookies(domain: string): Promise<string[]>;
|
|
318
332
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
333
|
+
/**
|
|
334
|
+
* Remove cookies for a specific domain
|
|
335
|
+
* @param domain Domain of the cookies to be removed, remove all
|
|
336
|
+
* cookies when this is null.
|
|
337
|
+
*/
|
|
338
|
+
removeCookies(domain?: string): Promise<null>;
|
|
325
339
|
}
|
|
326
340
|
|
|
327
|
-
type HashAlgorithm =
|
|
341
|
+
type HashAlgorithm = 'md5' | 'sha1' | 'sha224' | 'sha256' | 'sha384' | 'sha512';
|
|
328
342
|
|
|
329
343
|
export interface FS {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
344
|
+
ReactNativeBlobUtilSession: ReactNativeBlobUtilSession;
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Remove file at path.
|
|
348
|
+
* @param path:string Path of target file.
|
|
349
|
+
*/
|
|
350
|
+
unlink(path: string): Promise<void>;
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Create a directory.
|
|
354
|
+
* @param path Path of directory to be created
|
|
355
|
+
*/
|
|
356
|
+
mkdir(path: string): Promise<void>;
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Get a file cache session
|
|
360
|
+
* @param name Stream ID
|
|
361
|
+
*/
|
|
362
|
+
session(name: string): ReactNativeBlobUtilSession;
|
|
363
|
+
|
|
364
|
+
ls(path: string): Promise<string[]>;
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Read the file from the given path and calculate a cryptographic hash sum over its contents.
|
|
368
|
+
*
|
|
369
|
+
* @param path Path to the file
|
|
370
|
+
* @param algorithm The hash algorithm to use
|
|
371
|
+
*/
|
|
372
|
+
hash(path: string, algorithm: HashAlgorithm): Promise<string>;
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Create file stream from file at `path`.
|
|
376
|
+
* @param path The file path.
|
|
377
|
+
* @param encoding Data encoding, should be one of `base64`, `utf8`, `ascii`
|
|
378
|
+
* @param bufferSize Size of stream buffer.
|
|
379
|
+
* @return ReactNativeBlobUtilStream stream instance.
|
|
380
|
+
*/
|
|
381
|
+
readStream(
|
|
382
|
+
path: string,
|
|
383
|
+
encoding: Encoding,
|
|
384
|
+
bufferSize?: number,
|
|
385
|
+
tick?: number
|
|
386
|
+
): Promise<ReactNativeBlobUtilReadStream>;
|
|
387
|
+
|
|
388
|
+
mv(path: string, dest: string): Promise<boolean>;
|
|
389
|
+
|
|
390
|
+
cp(path: string, dest: string): Promise<boolean>;
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Create write stream to a file.
|
|
394
|
+
* @param path Target path of file stream.
|
|
395
|
+
* @param encoding Encoding of input data.
|
|
396
|
+
* @param append A flag represent if data append to existing ones.
|
|
397
|
+
* @return A promise resolves a `WriteStream` object.
|
|
398
|
+
*/
|
|
399
|
+
writeStream(
|
|
400
|
+
path: string,
|
|
401
|
+
encoding: Encoding,
|
|
402
|
+
append?: boolean
|
|
403
|
+
): Promise<ReactNativeBlobUtilWriteStream>;
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* Write data to file.
|
|
407
|
+
* @param path Path of the file.
|
|
408
|
+
* @param data Data to write to the file.
|
|
409
|
+
* @param encoding Encoding of data (Optional).
|
|
410
|
+
*/
|
|
411
|
+
writeFile(
|
|
412
|
+
path: string,
|
|
413
|
+
data: string | number[],
|
|
414
|
+
encoding?: Encoding
|
|
415
|
+
): Promise<void>;
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Processes the data and then writes to the file.
|
|
419
|
+
* @param path Path of the file.
|
|
420
|
+
* @param data Data to write to the file.
|
|
421
|
+
* @param encoding Encoding of data (Optional).
|
|
422
|
+
*/
|
|
423
|
+
writeFileWithTransform(
|
|
424
|
+
path: string,
|
|
425
|
+
data: string | number[],
|
|
426
|
+
encoding?: Encoding
|
|
427
|
+
): Promise<void>;
|
|
428
|
+
|
|
429
|
+
appendFile(
|
|
430
|
+
path: string,
|
|
431
|
+
data: string | number[],
|
|
432
|
+
encoding?: Encoding | 'uri'
|
|
433
|
+
): Promise<number>;
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* Wrapper method of readStream.
|
|
437
|
+
* @param path Path of the file.
|
|
438
|
+
* @param encoding Encoding of read stream.
|
|
439
|
+
*/
|
|
440
|
+
readFile(path: string, encoding: Encoding, bufferSize?: number): Promise<any>;
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* Reads from a file and then processes the data before returning
|
|
444
|
+
* @param path Path of the file.
|
|
445
|
+
* @param encoding Encoding of read stream.
|
|
446
|
+
*/
|
|
447
|
+
readFileWithTransform(
|
|
448
|
+
path: string,
|
|
449
|
+
encoding: Encoding,
|
|
450
|
+
bufferSize?: number
|
|
451
|
+
): Promise<any>;
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* Check if file exists and if it is a folder.
|
|
455
|
+
* @param path Path to check
|
|
456
|
+
*/
|
|
457
|
+
exists(path: string): Promise<boolean>;
|
|
458
|
+
|
|
459
|
+
createFile(path: string, data: string, encoding: Encoding): Promise<void>;
|
|
460
|
+
|
|
461
|
+
isDir(path: string): Promise<boolean>;
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* Show statistic data of a path.
|
|
465
|
+
* @param path Target path
|
|
466
|
+
*/
|
|
467
|
+
stat(path: string): Promise<ReactNativeBlobUtilStat>;
|
|
468
|
+
|
|
469
|
+
lstat(path: string): Promise<ReactNativeBlobUtilStat[]>;
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* Android only method, request media scanner to scan the file.
|
|
473
|
+
* @param pairs Array contains Key value pairs with key `path` and `mime`.
|
|
474
|
+
*/
|
|
475
|
+
scanFile(pairs: Array<{ [key: string]: string }>): Promise<void>;
|
|
476
|
+
|
|
477
|
+
dirs: Dirs;
|
|
478
|
+
|
|
479
|
+
slice(src: string, dest: string, start: number, end: number): Promise<void>;
|
|
480
|
+
|
|
481
|
+
asset(path: string): string;
|
|
482
|
+
|
|
483
|
+
df(): Promise<RNFetchBlobDf>;
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* Returns the path for the app group.
|
|
487
|
+
* @param {string} groupName Name of app group
|
|
488
|
+
*/
|
|
489
|
+
pathForAppGroup(groupName: string): Promise<string>;
|
|
451
490
|
}
|
|
452
491
|
|
|
453
492
|
export interface RNFetchBlobDfIOS {
|
|
454
|
-
|
|
455
|
-
|
|
493
|
+
free?: number;
|
|
494
|
+
total?: number;
|
|
456
495
|
}
|
|
457
496
|
|
|
458
497
|
export interface RNFetchBlobDfAndroid {
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
498
|
+
external_free?: string;
|
|
499
|
+
external_total?: string;
|
|
500
|
+
internal_free?: string;
|
|
501
|
+
internal_total?: string;
|
|
463
502
|
}
|
|
464
503
|
|
|
465
504
|
export type RNFetchBlobDf = RNFetchBlobDfIOS & RNFetchBlobDfAndroid;
|
|
466
505
|
|
|
467
506
|
export interface Dirs {
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
507
|
+
DocumentDir: string;
|
|
508
|
+
CacheDir: string;
|
|
509
|
+
PictureDir: string;
|
|
510
|
+
LibraryDir: string;
|
|
511
|
+
MusicDir: string;
|
|
512
|
+
MovieDir: string;
|
|
513
|
+
DownloadDir: string;
|
|
514
|
+
DCIMDir: string;
|
|
515
|
+
SDCardDir: string;
|
|
516
|
+
MainBundleDir: string;
|
|
517
|
+
|
|
518
|
+
LegacyPictureDir: string;
|
|
519
|
+
LegacyMusicDir: string;
|
|
520
|
+
LegacyMovieDir: string;
|
|
521
|
+
LegacyDownloadDir: string;
|
|
522
|
+
LegacyDCIMDir: string;
|
|
523
|
+
LegacySDCardDir: string; // Depracated
|
|
485
524
|
}
|
|
486
525
|
|
|
487
526
|
export interface ReactNativeBlobUtilWriteStream {
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
527
|
+
id: string;
|
|
528
|
+
encoding: string;
|
|
529
|
+
append: boolean;
|
|
491
530
|
|
|
492
|
-
|
|
531
|
+
write(data: string): Promise<void>;
|
|
493
532
|
|
|
494
|
-
|
|
533
|
+
close(): Promise<void>;
|
|
495
534
|
}
|
|
496
535
|
|
|
497
536
|
export interface ReactNativeBlobUtilReadStream {
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
537
|
+
path: string;
|
|
538
|
+
encoding: Encoding;
|
|
539
|
+
bufferSize?: number;
|
|
540
|
+
closed: boolean;
|
|
541
|
+
tick: number;
|
|
503
542
|
|
|
504
|
-
|
|
543
|
+
open(): void;
|
|
505
544
|
|
|
506
|
-
|
|
545
|
+
onData(fn: (chunk: string | number[]) => void): void;
|
|
507
546
|
|
|
508
|
-
|
|
547
|
+
onError(fn: (err: any) => void): void;
|
|
509
548
|
|
|
510
|
-
|
|
549
|
+
onEnd(fn: () => void): void;
|
|
511
550
|
}
|
|
512
551
|
|
|
513
|
-
export type Encoding =
|
|
552
|
+
export type Encoding = 'utf8' | 'ascii' | 'base64';
|
|
514
553
|
|
|
515
554
|
/* tslint:disable-next-line interface-name*/
|
|
516
555
|
export interface IOSApi {
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
556
|
+
/**
|
|
557
|
+
* Open a file in {@link https://developer.apple.com/reference/uikit/uidocumentinteractioncontroller UIDocumentInteractionController},
|
|
558
|
+
* this is the default document viewer of iOS, supports several kinds of files. On Android, there's an similar method {@link android.actionViewIntent}.
|
|
559
|
+
* @param path This is a required field, the path to the document. The path should NOT contain any scheme prefix.
|
|
560
|
+
* @param {string} scheme URI scheme that needs to support, optional
|
|
561
|
+
*/
|
|
562
|
+
previewDocument(path: string, scheme?: string): void;
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* Show options menu for interact with the file.
|
|
566
|
+
* @param path This is a required field, the path to the document. The path should NOT contain any scheme prefix.
|
|
567
|
+
* @param {string} scheme URI scheme that needs to support, optional
|
|
568
|
+
*/
|
|
569
|
+
openDocument(path: string, scheme?: string): Promise<void>;
|
|
570
|
+
|
|
571
|
+
/**
|
|
572
|
+
* Displays an options menu using [UIDocumentInteractionController](https://developer.apple.com/reference/uikit/uidocumentinteractioncontroller).[presentOptionsMenu](https://developer.apple.com/documentation/uikit/uidocumentinteractioncontroller/1616814-presentoptionsmenu)
|
|
573
|
+
* @param {string} path Path of the file to be open.
|
|
574
|
+
* @param {string} scheme URI scheme that needs to support, optional
|
|
575
|
+
*/
|
|
576
|
+
presentOptionsMenu(path: string, scheme?: string): void;
|
|
577
|
+
|
|
578
|
+
/**
|
|
579
|
+
* Displays a menu for opening the document using [UIDocumentInteractionController](https://developer.apple.com/reference/uikit/uidocumentinteractioncontroller).[presentOpenInMenu](https://developer.apple.com/documentation/uikit/uidocumentinteractioncontroller/1616807-presentopeninmenu)
|
|
580
|
+
* @param {string} path Path of the file to be open.
|
|
581
|
+
* @param {string} scheme URI scheme that needs to support, optional
|
|
582
|
+
*/
|
|
583
|
+
presentOpenInMenu(path: string, scheme?: string): void;
|
|
584
|
+
|
|
585
|
+
/**
|
|
586
|
+
* Displays a full-screen preview of the target document using [UIDocumentInteractionController](https://developer.apple.com/reference/uikit/uidocumentinteractioncontroller).[presentPreview](https://developer.apple.com/documentation/uikit/uidocumentinteractioncontroller/1616828-presentpreview)
|
|
587
|
+
* @param {string} path Path of the file to be open.
|
|
588
|
+
* @param {string} scheme URI scheme that needs to support, optional
|
|
589
|
+
*/
|
|
590
|
+
presentPreview(path: string, scheme?: string): void;
|
|
591
|
+
|
|
592
|
+
/**
|
|
593
|
+
* Marks the file to be excluded from icloud/itunes backup. Works recursively if path is to a directory
|
|
594
|
+
* @param {string} path Path to a file or directory to mark to be excluded.
|
|
595
|
+
*/
|
|
596
|
+
excludeFromBackupKey(path: string): Promise<void>;
|
|
558
597
|
}
|
|
559
598
|
|
|
560
599
|
export interface AndroidDownloadOption {
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
600
|
+
/**
|
|
601
|
+
* Title string to be displayed when the file added to Downloads app.
|
|
602
|
+
*/
|
|
603
|
+
title: string;
|
|
565
604
|
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
605
|
+
/**
|
|
606
|
+
* File description to be displayed when the file added to Downloads app.
|
|
607
|
+
*/
|
|
608
|
+
description: string;
|
|
570
609
|
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
610
|
+
/**
|
|
611
|
+
* MIME string of the file.
|
|
612
|
+
*/
|
|
613
|
+
mime: string;
|
|
575
614
|
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
615
|
+
/**
|
|
616
|
+
* URI string of the file.
|
|
617
|
+
*/
|
|
618
|
+
path: string;
|
|
580
619
|
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
620
|
+
/**
|
|
621
|
+
* Boolean value that determines if notification will be displayed.
|
|
622
|
+
*/
|
|
623
|
+
showNotification: boolean;
|
|
585
624
|
}
|
|
586
625
|
|
|
587
626
|
export interface AndroidApi {
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
627
|
+
/**
|
|
628
|
+
* When sending an ACTION_VIEW intent with given file path and MIME type, system will try to open an
|
|
629
|
+
* App to handle the file. For example, open Gallery app to view an image, or install APK.
|
|
630
|
+
* @param path Path of the file to be opened.
|
|
631
|
+
* @param mime Basically system will open an app according to this MIME type.
|
|
632
|
+
* @param chooserTitle title for chooser, if not set the chooser won't be displayed (see [Android docs](https://developer.android.com/reference/android/content/Intent.html#createChooser(android.content.Intent,%20java.lang.CharSequence)))
|
|
633
|
+
*/
|
|
634
|
+
actionViewIntent(
|
|
635
|
+
path: string,
|
|
636
|
+
mime: string,
|
|
637
|
+
chooserTitle?: string
|
|
638
|
+
): Promise<boolean | null>;
|
|
639
|
+
|
|
640
|
+
/**
|
|
641
|
+
*
|
|
642
|
+
* This method brings up OS default file picker and resolves a file URI when the user selected a file.
|
|
643
|
+
* However, it does not resolve or reject when user dismiss the file picker via pressing hardware back button,
|
|
644
|
+
* but you can still handle this behavior via AppState.
|
|
645
|
+
* @param mime MIME type filter, only the files matches the MIME will be shown.
|
|
646
|
+
*/
|
|
647
|
+
getContentIntent(mime: string): Promise<any>;
|
|
648
|
+
|
|
649
|
+
/**
|
|
650
|
+
* Using this function to add an existing file to Downloads app.
|
|
651
|
+
* @param options An object that for setting the title, description, mime, and notification of the item.
|
|
652
|
+
*/
|
|
653
|
+
addCompleteDownload(options: AndroidDownloadOption): Promise<void>;
|
|
654
|
+
|
|
655
|
+
getSDCardDir(): Promise<string>;
|
|
656
|
+
|
|
657
|
+
getSDCardApplicationDir(): Promise<string>;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
type Methods =
|
|
661
|
+
| 'POST'
|
|
662
|
+
| 'GET'
|
|
663
|
+
| 'DELETE'
|
|
664
|
+
| 'PUT'
|
|
665
|
+
| 'PATCH'
|
|
666
|
+
| 'post'
|
|
667
|
+
| 'get'
|
|
668
|
+
| 'delete'
|
|
669
|
+
| 'put'
|
|
670
|
+
| 'patch';
|
|
618
671
|
|
|
619
672
|
/**
|
|
620
673
|
* A declare class inherits Promise, it has extra method like progress, uploadProgress,
|
|
621
674
|
* and cancel which can help managing an asynchronous task's state.
|
|
622
675
|
*/
|
|
623
676
|
export interface StatefulPromise<T> extends Promise<T> {
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
677
|
+
/**
|
|
678
|
+
* Cancel the request when invoke this method.
|
|
679
|
+
*/
|
|
680
|
+
cancel(cb?: (reason: any) => void): StatefulPromise<FetchBlobResponse>;
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* Add an event listener which triggers when data receiving from server.
|
|
684
|
+
*/
|
|
685
|
+
progress(
|
|
686
|
+
callback: (received: string, total: string) => void
|
|
687
|
+
): StatefulPromise<FetchBlobResponse>;
|
|
688
|
+
|
|
689
|
+
/**
|
|
690
|
+
* Add an event listener with custom configuration
|
|
691
|
+
*/
|
|
692
|
+
progress(
|
|
693
|
+
config: { count?: number; interval?: number },
|
|
694
|
+
callback: (received: number, total: number) => void
|
|
695
|
+
): StatefulPromise<FetchBlobResponse>;
|
|
696
|
+
|
|
697
|
+
/**
|
|
698
|
+
* Add an event listener with custom configuration.
|
|
699
|
+
*/
|
|
700
|
+
uploadProgress(
|
|
701
|
+
callback: (sent: number, total: number) => void
|
|
702
|
+
): StatefulPromise<FetchBlobResponse>;
|
|
703
|
+
|
|
704
|
+
/**
|
|
705
|
+
* Add an event listener with custom configuration
|
|
706
|
+
*/
|
|
707
|
+
uploadProgress(
|
|
708
|
+
config: { count?: number; interval?: number },
|
|
709
|
+
callback: (sent: number, total: number) => void
|
|
710
|
+
): StatefulPromise<FetchBlobResponse>;
|
|
711
|
+
|
|
712
|
+
/**
|
|
713
|
+
* An IOS only API, when IOS app turns into background network tasks will be terminated after ~180 seconds,
|
|
714
|
+
* in order to handle these expired tasks, you can register an event handler, which will be called after the
|
|
715
|
+
* app become active.
|
|
716
|
+
*/
|
|
717
|
+
expire(callback: () => void): StatefulPromise<void>;
|
|
655
718
|
}
|
|
656
719
|
|
|
657
720
|
export declare class ReactNativeBlobUtilSession {
|
|
658
|
-
|
|
721
|
+
constructor(name: string, list: string[]);
|
|
659
722
|
|
|
660
|
-
|
|
723
|
+
add(path: string): ReactNativeBlobUtilSession;
|
|
661
724
|
|
|
662
|
-
|
|
725
|
+
remove(path: string): ReactNativeBlobUtilSession;
|
|
663
726
|
|
|
664
|
-
|
|
727
|
+
dispose(): Promise<void>;
|
|
665
728
|
|
|
666
|
-
|
|
729
|
+
list(): string[];
|
|
667
730
|
|
|
668
|
-
|
|
731
|
+
name: string;
|
|
669
732
|
|
|
670
|
-
|
|
733
|
+
static getSession(name: string): any;
|
|
671
734
|
|
|
672
|
-
|
|
735
|
+
static setSession(name: string): void;
|
|
673
736
|
|
|
674
|
-
|
|
737
|
+
static removeSession(name: string): void;
|
|
675
738
|
}
|
|
676
739
|
|
|
677
740
|
/**
|
|
678
741
|
* A set of configurations that will be injected into a fetch method, with the following properties.
|
|
679
742
|
*/
|
|
680
743
|
export interface ReactNativeBlobUtilConfig {
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
744
|
+
Progress?: { count?: number; interval?: number };
|
|
745
|
+
UploadProgress?: { count?: number; interval?: number };
|
|
746
|
+
|
|
747
|
+
/**
|
|
748
|
+
* When this property is true, the downloaded data will overwrite the existing file. (true by default)
|
|
749
|
+
*/
|
|
750
|
+
overwrite?: boolean;
|
|
751
|
+
|
|
752
|
+
/**
|
|
753
|
+
* Set timeout of the request (in milliseconds).
|
|
754
|
+
*/
|
|
755
|
+
timeout?: number;
|
|
756
|
+
|
|
757
|
+
/**
|
|
758
|
+
* Set this property to true to display a network indicator on status bar, this feature is only supported on IOS.
|
|
759
|
+
*/
|
|
760
|
+
indicator?: boolean;
|
|
761
|
+
|
|
762
|
+
/**
|
|
763
|
+
* Set this property to true will allow the request create connection with server have self-signed SSL
|
|
764
|
+
* certification. This is not recommended to use in production.
|
|
765
|
+
*/
|
|
766
|
+
trusty?: boolean;
|
|
767
|
+
|
|
768
|
+
/**
|
|
769
|
+
* Set this property to true will only do requests through the WiFi interface, and fail otherwise.
|
|
770
|
+
*/
|
|
771
|
+
wifiOnly?: boolean;
|
|
772
|
+
|
|
773
|
+
/**
|
|
774
|
+
* Set this property so redirects are not automatically followed.
|
|
775
|
+
*/
|
|
776
|
+
followRedirect?: boolean;
|
|
777
|
+
|
|
778
|
+
/**
|
|
779
|
+
* Set this property to true will makes response data of the fetch stored in a temp file, by default the temp
|
|
780
|
+
* file will stored in App's own root folder with file name template ReactNativeBlobUtil_tmp${timestamp}.
|
|
781
|
+
*/
|
|
782
|
+
fileCache?: boolean;
|
|
783
|
+
|
|
784
|
+
/**
|
|
785
|
+
* Set this property to true if you want the data to be processed before it gets written onto disk.
|
|
786
|
+
* This only has effect if the FileTransformer has been registered and the library is configured to write
|
|
787
|
+
* response onto disk.
|
|
788
|
+
*/
|
|
789
|
+
transformFile?: boolean;
|
|
790
|
+
|
|
791
|
+
/**
|
|
792
|
+
* Set this property to change temp file extension that created by fetch response data.
|
|
793
|
+
*/
|
|
794
|
+
appendExt?: string;
|
|
795
|
+
|
|
796
|
+
/**
|
|
797
|
+
* When this property has value, fetch API will try to store response data in the path ignoring fileCache and
|
|
798
|
+
* appendExt property.
|
|
799
|
+
*/
|
|
800
|
+
path?: string;
|
|
801
|
+
|
|
802
|
+
session?: string;
|
|
803
|
+
|
|
804
|
+
addAndroidDownloads?: AddAndroidDownloads;
|
|
805
|
+
|
|
806
|
+
/**
|
|
807
|
+
* Fix IOS request timeout issue #368 by change default request setting to defaultSessionConfiguration, and make backgroundSessionConfigurationWithIdentifier optional
|
|
808
|
+
*/
|
|
809
|
+
IOSBackgroundTask?: boolean;
|
|
747
810
|
}
|
|
748
811
|
|
|
749
812
|
export interface AddAndroidDownloads {
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
813
|
+
/**
|
|
814
|
+
* download file using Android download manager or not.
|
|
815
|
+
*/
|
|
816
|
+
useDownloadManager?: boolean;
|
|
817
|
+
/**
|
|
818
|
+
* title of the file
|
|
819
|
+
*/
|
|
820
|
+
title?: string;
|
|
821
|
+
/**
|
|
822
|
+
* File description of the file.
|
|
823
|
+
*/
|
|
824
|
+
description?: string;
|
|
825
|
+
/**
|
|
826
|
+
* The destination which the file will be downloaded, it SHOULD be a location on external storage (DCIMDir).
|
|
827
|
+
*/
|
|
828
|
+
path?: string;
|
|
829
|
+
/**
|
|
830
|
+
* MIME type of the file. By default is text/plain
|
|
831
|
+
*/
|
|
832
|
+
mime?: string;
|
|
833
|
+
/**
|
|
834
|
+
* A boolean value, see Officail Document
|
|
835
|
+
* (https://developer.android.com/reference/android/app/DownloadManager.html#addCompletedDownload(java.lang.String, java.lang.String, boolean, java.lang.String, java.lang.String, long, boolean))
|
|
836
|
+
*/
|
|
837
|
+
mediaScannable?: boolean;
|
|
838
|
+
/**
|
|
839
|
+
* Only for Android >= Q; Enforces the file being stored to the MediaCollection Downloads. This might overwrite any value given in "path"
|
|
840
|
+
*/
|
|
841
|
+
storeInDownloads?: boolean;
|
|
842
|
+
/**
|
|
843
|
+
* A boolean value decide whether show a notification when download complete.
|
|
844
|
+
*/
|
|
845
|
+
notification?: boolean;
|
|
783
846
|
}
|
|
784
847
|
|
|
785
848
|
export interface ReactNativeBlobUtilResponseInfo {
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
849
|
+
taskId: string;
|
|
850
|
+
state: string;
|
|
851
|
+
headers: any;
|
|
852
|
+
redirects: string[];
|
|
853
|
+
status: number;
|
|
854
|
+
respType: 'text' | 'blob' | '' | 'json';
|
|
855
|
+
rnfbEncode: 'path' | 'base64' | 'ascii' | 'utf8';
|
|
856
|
+
timeout: boolean;
|
|
794
857
|
}
|
|
795
858
|
|
|
796
859
|
export interface ReactNativeBlobUtilStream {
|
|
797
|
-
|
|
860
|
+
onData(): void;
|
|
798
861
|
|
|
799
|
-
|
|
862
|
+
onError(): void;
|
|
800
863
|
|
|
801
|
-
|
|
864
|
+
onEnd(): void;
|
|
802
865
|
}
|
|
803
866
|
|
|
804
867
|
export declare class ReactNativeBlobUtilFile {}
|
|
805
868
|
|
|
806
869
|
export declare class ReactNativeBlobUtilStat {
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
870
|
+
lastModified: number;
|
|
871
|
+
size: number;
|
|
872
|
+
type: 'directory' | 'file';
|
|
873
|
+
path: string;
|
|
874
|
+
filename: string;
|
|
812
875
|
}
|
|
813
876
|
|
|
814
|
-
export type Mediatype =
|
|
877
|
+
export type Mediatype = 'Audio' | 'Image' | 'Video' | 'Download';
|
|
815
878
|
|
|
816
879
|
export interface MediaCollection {
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
880
|
+
/**
|
|
881
|
+
* Creates a new File in the collection.
|
|
882
|
+
* Promise will resolve to content UIR or error message
|
|
883
|
+
* @param filedata descriptor for the media store entry
|
|
884
|
+
* @param mediatype
|
|
885
|
+
* @param path path of the file being copied
|
|
886
|
+
*/
|
|
887
|
+
copyToMediaStore(
|
|
888
|
+
filedata: filedescriptor,
|
|
889
|
+
mediatype: Mediatype,
|
|
890
|
+
path: string
|
|
891
|
+
): Promise<string>;
|
|
892
|
+
|
|
893
|
+
/**
|
|
894
|
+
* Creates a new File in the collection.
|
|
895
|
+
* @param filedata
|
|
896
|
+
* @param mediatype
|
|
897
|
+
*/
|
|
898
|
+
createMediafile(
|
|
899
|
+
filedata: filedescriptor,
|
|
900
|
+
mediatype: Mediatype
|
|
901
|
+
): Promise<string>;
|
|
902
|
+
|
|
903
|
+
/**
|
|
904
|
+
* Copies an existing file to a mediastore file
|
|
905
|
+
* @param uri URI of the destination mediastore file
|
|
906
|
+
* @param path Path to the existing file which should be copied
|
|
907
|
+
*/
|
|
908
|
+
writeToMediafile(uri: string, path: string): Promise<string>;
|
|
909
|
+
|
|
910
|
+
/**
|
|
911
|
+
* Copies and transforms an existing file to a mediastore file. Make sure FileTransformer is set
|
|
912
|
+
* @param uri URI of the destination mediastore file
|
|
913
|
+
* @param path Path to the existing file which should be copied
|
|
914
|
+
*/
|
|
915
|
+
writeToMediafileWithTransform(uri: string, path: string): Promise<string>;
|
|
916
|
+
|
|
917
|
+
/**
|
|
918
|
+
* Copies a file from the mediastore to the apps internal storage
|
|
919
|
+
* @param contenturi URI of the mediastore file
|
|
920
|
+
* @param destpath Path for the file in the internal storage
|
|
921
|
+
*/
|
|
922
|
+
copyToInternal(contenturi: string, destpath: string): Promise<string>;
|
|
923
|
+
|
|
924
|
+
/**
|
|
925
|
+
* Gets the blob data for a given URI in the mediastore
|
|
926
|
+
* @param contenturi
|
|
927
|
+
* @param encoding
|
|
928
|
+
*/
|
|
929
|
+
getBlob(contenturi: string, encoding: string): Promise<string>;
|
|
860
930
|
}
|