react-native-blob-util 0.19.1 → 0.19.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/.eslintrc.js +56 -56
  2. package/LICENSE +21 -21
  3. package/Migration.md +41 -41
  4. package/README.md +1071 -1071
  5. package/android/gradle.properties +1 -1
  6. package/android/proguard-rules.pro +17 -17
  7. package/android/src/main/AndroidManifest.xml +39 -40
  8. package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilConfig.java +57 -57
  9. package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilConst.java +20 -20
  10. package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilFS.java +2 -2
  11. package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilFileTransformer.java +9 -9
  12. package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilImpl.java +431 -431
  13. package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilProgressConfig.java +39 -39
  14. package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilReq.java +972 -968
  15. package/android/src/main/java/com/ReactNativeBlobUtil/Response/ReactNativeBlobUtilDefaultResp.java +98 -98
  16. package/android/src/main/java/com/ReactNativeBlobUtil/Response/ReactNativeBlobUtilFileResp.java +157 -157
  17. package/android/src/main/java/com/ReactNativeBlobUtil/Utils/FileDescription.java +19 -19
  18. package/android/src/main/java/com/ReactNativeBlobUtil/Utils/FileProvider.java +4 -4
  19. package/android/src/main/java/com/ReactNativeBlobUtil/Utils/MimeType.java +70 -70
  20. package/android/src/main/java/com/ReactNativeBlobUtil/Utils/PathResolver.java +223 -223
  21. package/android/src/main/java/com/ReactNativeBlobUtil/Utils/Tls12SocketFactory.java +68 -68
  22. package/android/src/main/res/values/strings.xml +3 -3
  23. package/android/src/main/res/xml/provider_paths.xml +12 -12
  24. package/android/src/newarch/java/com/ReactNativeBlobUtil/ReactNativeBlobUtil.java +1 -1
  25. package/android.js +58 -58
  26. package/class/ReactNativeBlobUtilCanceledFetchError.js +9 -9
  27. package/class/ReactNativeBlobUtilFile.js +5 -5
  28. package/class/ReactNativeBlobUtilReadStream.js +84 -84
  29. package/class/ReactNativeBlobUtilSession.js +68 -68
  30. package/class/ReactNativeBlobUtilWriteStream.js +50 -50
  31. package/class/StatefulPromise.js +7 -7
  32. package/codegenSpecs/NativeBlobUtils.js +86 -82
  33. package/components/Fetch.onPress.js +10 -10
  34. package/components/Fetch.when.js +15 -15
  35. package/fetch.js +344 -344
  36. package/fs.js +480 -480
  37. package/index.d.ts +871 -871
  38. package/index.js +64 -64
  39. package/index.js.flow +191 -191
  40. package/index.web.js +1 -1
  41. package/ios/ReactNativeBlobUtil/ReactNativeBlobUtil.h +55 -55
  42. package/ios/ReactNativeBlobUtil/ReactNativeBlobUtil.mm +993 -993
  43. package/ios/ReactNativeBlobUtil.xcodeproj/project.pbxproj +403 -403
  44. package/ios/ReactNativeBlobUtilConst.h +58 -58
  45. package/ios/ReactNativeBlobUtilConst.mm +47 -47
  46. package/ios/ReactNativeBlobUtilFS.h +108 -108
  47. package/ios/ReactNativeBlobUtilFS.mm +977 -977
  48. package/ios/ReactNativeBlobUtilFileTransformer.h +23 -23
  49. package/ios/ReactNativeBlobUtilFileTransformer.mm +20 -20
  50. package/ios/ReactNativeBlobUtilNetwork.h +49 -49
  51. package/ios/ReactNativeBlobUtilNetwork.mm +159 -159
  52. package/ios/ReactNativeBlobUtilProgress.h +32 -32
  53. package/ios/ReactNativeBlobUtilProgress.mm +57 -57
  54. package/ios/ReactNativeBlobUtilReqBuilder.h +37 -37
  55. package/ios/ReactNativeBlobUtilReqBuilder.mm +292 -292
  56. package/ios/ReactNativeBlobUtilRequest.h +48 -48
  57. package/ios/ReactNativeBlobUtilRequest.mm +535 -535
  58. package/ios.js +61 -61
  59. package/json-stream.js +42 -42
  60. package/lib/oboe-browser.js +2703 -2703
  61. package/mediacollection.js +36 -36
  62. package/package.json +55 -55
  63. package/polyfill/Blob.js +362 -362
  64. package/polyfill/Event.js +11 -11
  65. package/polyfill/EventTarget.js +78 -78
  66. package/polyfill/Fetch.js +219 -219
  67. package/polyfill/File.js +27 -27
  68. package/polyfill/FileReader.js +91 -91
  69. package/polyfill/ProgressEvent.js +32 -32
  70. package/polyfill/XMLHttpRequest.js +466 -466
  71. package/polyfill/XMLHttpRequestEventTarget.js +126 -126
  72. package/polyfill/index.js +11 -11
  73. package/react-native-blob-util.podspec +45 -45
  74. package/types.js +69 -69
  75. package/utils/log.js +40 -40
  76. package/utils/unicode.js +7 -7
  77. package/utils/uri.js +33 -33
  78. package/utils/uuid.js +4 -4
  79. package/windows/README.md +2 -2
  80. package/windows/ReactNativeBlobUtil/PropertySheet.props +15 -15
  81. package/windows/ReactNativeBlobUtil/ReactNativeBlobUtil.cpp +1701 -1693
  82. package/windows/ReactNativeBlobUtil/ReactNativeBlobUtil.def +3 -3
  83. package/windows/ReactNativeBlobUtil/ReactNativeBlobUtil.h +379 -366
  84. package/windows/ReactNativeBlobUtil/ReactNativeBlobUtil.vcxproj +181 -181
  85. package/windows/ReactNativeBlobUtil/ReactNativeBlobUtil.vcxproj.filters +31 -31
  86. package/windows/ReactNativeBlobUtil/ReactPackageProvider.cpp +15 -15
  87. package/windows/ReactNativeBlobUtil/ReactPackageProvider.h +20 -20
  88. package/windows/ReactNativeBlobUtil/ReactPackageProvider.idl +9 -9
  89. package/windows/ReactNativeBlobUtil/packages.config +3 -3
  90. package/windows/ReactNativeBlobUtil/pch.cpp +1 -1
  91. package/windows/ReactNativeBlobUtil/pch.h +3 -3
@@ -1,126 +1,126 @@
1
- // Copyright 2016 wkh237@github. All rights reserved.
2
- // Use of this source code is governed by a MIT-style license that can be
3
- // found in the LICENSE file.
4
-
5
- import EventTarget from './EventTarget.js';
6
- import Log from '../utils/log.js';
7
-
8
- const log = new Log('XMLHttpRequestEventTarget');
9
-
10
- log.disable();
11
- // log.level(3)
12
-
13
- export default class XMLHttpRequestEventTarget extends EventTarget {
14
-
15
- _onabort: (e: Event) => void = () => {
16
- };
17
- _onerror: (e: Event) => void = () => {
18
- };
19
- _onload: (e: Event) => void = () => {
20
- };
21
- _onloadstart: (e: Event) => void = () => {
22
- };
23
- _onprogress: (e: Event) => void = () => {
24
- };
25
- _ontimeout: (e: Event) => void = () => {
26
- };
27
- _onloadend: (e: Event) => void = () => {
28
- };
29
-
30
- constructor() {
31
- super();
32
- log.info('constructor called');
33
- }
34
-
35
- dispatchEvent(event: string, e: Event) {
36
- log.debug('dispatch event', event, e);
37
- super.dispatchEvent(event, e);
38
- switch (event) {
39
- case 'abort' :
40
- this._onabort(e);
41
- break;
42
- case 'error' :
43
- this._onerror(e);
44
- break;
45
- case 'load' :
46
- this._onload(e);
47
- break;
48
- case 'loadstart' :
49
- this._onloadstart(e);
50
- break;
51
- case 'loadend' :
52
- this._onloadend(e);
53
- break;
54
- case 'progress' :
55
- this._onprogress(e);
56
- break;
57
- case 'timeout' :
58
- this._ontimeout(e);
59
- break;
60
- }
61
- }
62
-
63
- set onabort(fn: (e: Event) => void) {
64
- log.info('set onabort');
65
- this._onabort = fn;
66
- }
67
-
68
- get onabort() {
69
- return this._onabort;
70
- }
71
-
72
- set onerror(fn: (e: Event) => void) {
73
- log.info('set onerror');
74
- this._onerror = fn;
75
- }
76
-
77
- get onerror() {
78
- return this._onerror;
79
- }
80
-
81
- set onload(fn: (e: Event) => void) {
82
- log.info('set onload', fn);
83
- this._onload = fn;
84
- }
85
-
86
- get onload() {
87
- return this._onload;
88
- }
89
-
90
- set onloadstart(fn: (e: Event) => void) {
91
- log.info('set onloadstart');
92
- this._onloadstart = fn;
93
- }
94
-
95
- get onloadstart() {
96
- return this._onloadstart;
97
- }
98
-
99
- set onprogress(fn: (e: Event) => void) {
100
- log.info('set onprogress');
101
- this._onprogress = fn;
102
- }
103
-
104
- get onprogress() {
105
- return this._onprogress;
106
- }
107
-
108
- set ontimeout(fn: (e: Event) => void) {
109
- log.info('set ontimeout');
110
- this._ontimeout = fn;
111
- }
112
-
113
- get ontimeout() {
114
- return this._ontimeout;
115
- }
116
-
117
- set onloadend(fn: (e: Event) => void) {
118
- log.info('set onloadend');
119
- this._onloadend = fn;
120
- }
121
-
122
- get onloadend() {
123
- return this._onloadend;
124
- }
125
-
126
- }
1
+ // Copyright 2016 wkh237@github. All rights reserved.
2
+ // Use of this source code is governed by a MIT-style license that can be
3
+ // found in the LICENSE file.
4
+
5
+ import EventTarget from './EventTarget.js';
6
+ import Log from '../utils/log.js';
7
+
8
+ const log = new Log('XMLHttpRequestEventTarget');
9
+
10
+ log.disable();
11
+ // log.level(3)
12
+
13
+ export default class XMLHttpRequestEventTarget extends EventTarget {
14
+
15
+ _onabort: (e: Event) => void = () => {
16
+ };
17
+ _onerror: (e: Event) => void = () => {
18
+ };
19
+ _onload: (e: Event) => void = () => {
20
+ };
21
+ _onloadstart: (e: Event) => void = () => {
22
+ };
23
+ _onprogress: (e: Event) => void = () => {
24
+ };
25
+ _ontimeout: (e: Event) => void = () => {
26
+ };
27
+ _onloadend: (e: Event) => void = () => {
28
+ };
29
+
30
+ constructor() {
31
+ super();
32
+ log.info('constructor called');
33
+ }
34
+
35
+ dispatchEvent(event: string, e: Event) {
36
+ log.debug('dispatch event', event, e);
37
+ super.dispatchEvent(event, e);
38
+ switch (event) {
39
+ case 'abort' :
40
+ this._onabort(e);
41
+ break;
42
+ case 'error' :
43
+ this._onerror(e);
44
+ break;
45
+ case 'load' :
46
+ this._onload(e);
47
+ break;
48
+ case 'loadstart' :
49
+ this._onloadstart(e);
50
+ break;
51
+ case 'loadend' :
52
+ this._onloadend(e);
53
+ break;
54
+ case 'progress' :
55
+ this._onprogress(e);
56
+ break;
57
+ case 'timeout' :
58
+ this._ontimeout(e);
59
+ break;
60
+ }
61
+ }
62
+
63
+ set onabort(fn: (e: Event) => void) {
64
+ log.info('set onabort');
65
+ this._onabort = fn;
66
+ }
67
+
68
+ get onabort() {
69
+ return this._onabort;
70
+ }
71
+
72
+ set onerror(fn: (e: Event) => void) {
73
+ log.info('set onerror');
74
+ this._onerror = fn;
75
+ }
76
+
77
+ get onerror() {
78
+ return this._onerror;
79
+ }
80
+
81
+ set onload(fn: (e: Event) => void) {
82
+ log.info('set onload', fn);
83
+ this._onload = fn;
84
+ }
85
+
86
+ get onload() {
87
+ return this._onload;
88
+ }
89
+
90
+ set onloadstart(fn: (e: Event) => void) {
91
+ log.info('set onloadstart');
92
+ this._onloadstart = fn;
93
+ }
94
+
95
+ get onloadstart() {
96
+ return this._onloadstart;
97
+ }
98
+
99
+ set onprogress(fn: (e: Event) => void) {
100
+ log.info('set onprogress');
101
+ this._onprogress = fn;
102
+ }
103
+
104
+ get onprogress() {
105
+ return this._onprogress;
106
+ }
107
+
108
+ set ontimeout(fn: (e: Event) => void) {
109
+ log.info('set ontimeout');
110
+ this._ontimeout = fn;
111
+ }
112
+
113
+ get ontimeout() {
114
+ return this._ontimeout;
115
+ }
116
+
117
+ set onloadend(fn: (e: Event) => void) {
118
+ log.info('set onloadend');
119
+ this._onloadend = fn;
120
+ }
121
+
122
+ get onloadend() {
123
+ return this._onloadend;
124
+ }
125
+
126
+ }
package/polyfill/index.js CHANGED
@@ -1,11 +1,11 @@
1
- import Blob from './Blob.js';
2
- import File from './File.js';
3
- import XMLHttpRequest from './XMLHttpRequest.js';
4
- import ProgressEvent from './ProgressEvent';
5
- import Event from './Event';
6
- import FileReader from './FileReader';
7
- import Fetch from './Fetch';
8
-
9
- export default {
10
- Blob, File, XMLHttpRequest, ProgressEvent, Event, FileReader, Fetch
11
- };
1
+ import Blob from './Blob.js';
2
+ import File from './File.js';
3
+ import XMLHttpRequest from './XMLHttpRequest.js';
4
+ import ProgressEvent from './ProgressEvent';
5
+ import Event from './Event';
6
+ import FileReader from './FileReader';
7
+ import Fetch from './Fetch';
8
+
9
+ export default {
10
+ Blob, File, XMLHttpRequest, ProgressEvent, Event, FileReader, Fetch
11
+ };
@@ -1,45 +1,45 @@
1
- require "json"
2
-
3
- fabric_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
4
- package = JSON.parse(File.read(File.join(__dir__, "package.json")))
5
-
6
- Pod::Spec.new do |s|
7
- s.name = package['name']
8
- s.version = package['version']
9
- s.summary = package['description']
10
- s.requires_arc = true
11
- s.license = 'MIT'
12
- s.homepage = 'n/a'
13
- s.source = { :git => "https://github.com/RonRadtke/react-native-blob-util" }
14
- s.author = 'RonRadtke'
15
- s.source_files = 'ios/**/*.{h,m,mm,swift}'
16
- s.platforms = { :ios => "11.0" }
17
- s.framework = 'AssetsLibrary'
18
-
19
- if fabric_enabled
20
- # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
21
- # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
22
- if respond_to?(:install_modules_dependencies, true)
23
- install_modules_dependencies(s)
24
- else
25
- # just for backward compatibility: if React Native version <= 0.70.x
26
- s.compiler_flags = "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32 -DRCT_NEW_ARCH_ENABLED=1"
27
- s.pod_target_xcconfig = {
28
- "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
29
- "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
30
- "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
31
- }
32
-
33
- s.dependency 'React-Core'
34
- s.dependency "React-Codegen"
35
- s.dependency "React-RCTFabric"
36
- s.dependency "RCT-Folly"
37
- s.dependency "RCTRequired"
38
- s.dependency "RCTTypeSafety"
39
- s.dependency "ReactCommon/turbomodule/core"
40
- end
41
- else
42
- s.dependency 'React-Core'
43
- end
44
-
45
- end
1
+ require "json"
2
+
3
+ fabric_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
4
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
5
+
6
+ Pod::Spec.new do |s|
7
+ s.name = package['name']
8
+ s.version = package['version']
9
+ s.summary = package['description']
10
+ s.requires_arc = true
11
+ s.license = 'MIT'
12
+ s.homepage = 'n/a'
13
+ s.source = { :git => "https://github.com/RonRadtke/react-native-blob-util" }
14
+ s.author = 'RonRadtke'
15
+ s.source_files = 'ios/**/*.{h,m,mm,swift}'
16
+ s.platforms = { :ios => "11.0" }
17
+ s.framework = 'AssetsLibrary'
18
+
19
+ if fabric_enabled
20
+ # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
21
+ # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
22
+ if respond_to?(:install_modules_dependencies, true)
23
+ install_modules_dependencies(s)
24
+ else
25
+ # just for backward compatibility: if React Native version <= 0.70.x
26
+ s.compiler_flags = "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32 -DRCT_NEW_ARCH_ENABLED=1"
27
+ s.pod_target_xcconfig = {
28
+ "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
29
+ "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
30
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
31
+ }
32
+
33
+ s.dependency 'React-Core'
34
+ s.dependency "React-Codegen"
35
+ s.dependency "React-RCTFabric"
36
+ s.dependency "RCT-Folly"
37
+ s.dependency "RCTRequired"
38
+ s.dependency "RCTTypeSafety"
39
+ s.dependency "ReactCommon/turbomodule/core"
40
+ end
41
+ else
42
+ s.dependency 'React-Core'
43
+ end
44
+
45
+ end
package/types.js CHANGED
@@ -1,70 +1,70 @@
1
-
2
- export type ReactNativeBlobUtilConfig = {
3
- Progress: any,
4
- UploadProgress: any,
5
- fileCache : bool,
6
- transformFile: boolean;
7
- path : string,
8
- appendExt : string,
9
- session : string,
10
- addAndroidDownloads : any,
11
- indicator : bool,
12
- followRedirect : bool,
13
- trusty : bool,
14
- wifiOnly : bool
15
- };
16
-
17
- export type ReactNativeBlobUtilNative = {
18
- // API for fetch octet-stream data
19
- fetchBlob : (
20
- options:fetchConfig,
21
- taskId:string,
22
- method:string,
23
- url:string,
24
- headers:any,
25
- body:any,
26
- callback:(err:any, ...data:any) => void
27
- ) => void,
28
- // API for fetch form data
29
- fetchBlobForm : (
30
- options:fetchConfig,
31
- taskId:string,
32
- method:string,
33
- url:string,
34
- headers:any,
35
- form:Array<any>,
36
- callback:(err:any, ...data:any) => void
37
- ) => void,
38
- // open file stream
39
- readStream : (
40
- path:string,
41
- encode:'utf8' | 'ascii' | 'base64'
42
- ) => void,
43
- // get system folders
44
- getEnvironmentDirs : (dirs:any) => void,
45
- // unlink file by path
46
- unlink : (path:string, callback: (err:any) => void) => void,
47
- removeSession : (paths:Array<string>, callback: (err:any) => void) => void,
48
- ls : (path:string, callback: (err:any) => void) => void,
49
- };
50
-
51
- export type ReactNativeBlobUtilResponseInfo = {
52
- taskId : string,
53
- state : number,
54
- headers : any,
55
- status : number,
56
- respType : 'text' | 'blob' | '' | 'json',
57
- rnfbEncode : 'path' | 'base64' | 'ascii' | 'utf8'
58
- }
59
-
60
- export type ReactNativeBlobUtilStream = {
61
- onData : () => void,
62
- onError : () => void,
63
- onEnd : () => void,
64
- _onData : () => void,
65
- _onEnd : () => void,
66
- _onError : () => void,
67
- }
68
-
69
-
1
+
2
+ export type ReactNativeBlobUtilConfig = {
3
+ Progress: any,
4
+ UploadProgress: any,
5
+ fileCache : bool,
6
+ transformFile: boolean;
7
+ path : string,
8
+ appendExt : string,
9
+ session : string,
10
+ addAndroidDownloads : any,
11
+ indicator : bool,
12
+ followRedirect : bool,
13
+ trusty : bool,
14
+ wifiOnly : bool
15
+ };
16
+
17
+ export type ReactNativeBlobUtilNative = {
18
+ // API for fetch octet-stream data
19
+ fetchBlob : (
20
+ options:fetchConfig,
21
+ taskId:string,
22
+ method:string,
23
+ url:string,
24
+ headers:any,
25
+ body:any,
26
+ callback:(err:any, ...data:any) => void
27
+ ) => void,
28
+ // API for fetch form data
29
+ fetchBlobForm : (
30
+ options:fetchConfig,
31
+ taskId:string,
32
+ method:string,
33
+ url:string,
34
+ headers:any,
35
+ form:Array<any>,
36
+ callback:(err:any, ...data:any) => void
37
+ ) => void,
38
+ // open file stream
39
+ readStream : (
40
+ path:string,
41
+ encode:'utf8' | 'ascii' | 'base64'
42
+ ) => void,
43
+ // get system folders
44
+ getEnvironmentDirs : (dirs:any) => void,
45
+ // unlink file by path
46
+ unlink : (path:string, callback: (err:any) => void) => void,
47
+ removeSession : (paths:Array<string>, callback: (err:any) => void) => void,
48
+ ls : (path:string, callback: (err:any) => void) => void,
49
+ };
50
+
51
+ export type ReactNativeBlobUtilResponseInfo = {
52
+ taskId : string,
53
+ state : number,
54
+ headers : any,
55
+ status : number,
56
+ respType : 'text' | 'blob' | '' | 'json',
57
+ rnfbEncode : 'path' | 'base64' | 'ascii' | 'utf8'
58
+ }
59
+
60
+ export type ReactNativeBlobUtilStream = {
61
+ onData : () => void,
62
+ onError : () => void,
63
+ onEnd : () => void,
64
+ _onData : () => void,
65
+ _onEnd : () => void,
66
+ _onError : () => void,
67
+ }
68
+
69
+
70
70
  export type filedescriptor = { path: string, parentFolder: string, mimeType: string }
package/utils/log.js CHANGED
@@ -1,40 +1,40 @@
1
- export default class Log {
2
-
3
- _name:string;
4
- _isEnable:boolean = true
5
- _level:number = 0
6
-
7
- constructor(name:string) {
8
- this._name = name;
9
- }
10
-
11
- level(val:number) {
12
- this._isEnable = true;
13
- this._level = val;
14
- }
15
-
16
- enable() {
17
- this._isEnable = true;
18
- }
19
-
20
- disable() {
21
- this._isEnable = false;
22
- }
23
-
24
- verbose(...args) {
25
- this._isEnable && this._level > 2 && console.log(this._name, 'verbose:', ...args);
26
- }
27
-
28
- debug(...args) {
29
- this._isEnable && this._level > 1 && console.log(this._name, 'debug:', ...args);
30
- }
31
-
32
- info(...args) {
33
- this._isEnable && this._level > 0 && console.log(this._name, 'info:', ...args);
34
- }
35
-
36
- error(...args) {
37
- this._isEnable && this._level > -1 && console.warn(this._name, 'error:', ...args);
38
- }
39
-
40
- }
1
+ export default class Log {
2
+
3
+ _name:string;
4
+ _isEnable:boolean = true
5
+ _level:number = 0
6
+
7
+ constructor(name:string) {
8
+ this._name = name;
9
+ }
10
+
11
+ level(val:number) {
12
+ this._isEnable = true;
13
+ this._level = val;
14
+ }
15
+
16
+ enable() {
17
+ this._isEnable = true;
18
+ }
19
+
20
+ disable() {
21
+ this._isEnable = false;
22
+ }
23
+
24
+ verbose(...args) {
25
+ this._isEnable && this._level > 2 && console.log(this._name, 'verbose:', ...args);
26
+ }
27
+
28
+ debug(...args) {
29
+ this._isEnable && this._level > 1 && console.log(this._name, 'debug:', ...args);
30
+ }
31
+
32
+ info(...args) {
33
+ this._isEnable && this._level > 0 && console.log(this._name, 'info:', ...args);
34
+ }
35
+
36
+ error(...args) {
37
+ this._isEnable && this._level > -1 && console.warn(this._name, 'error:', ...args);
38
+ }
39
+
40
+ }
package/utils/unicode.js CHANGED
@@ -1,7 +1,7 @@
1
- export default function(x) {
2
- var r = /\\u([\d\w]{4})/gi;
3
- x = x.replace(r, function (match, grp) {
4
- return String.fromCharCode(parseInt(grp, 16));
5
- });
6
- return unescape(x);
7
- }
1
+ export default function(x) {
2
+ var r = /\\u([\d\w]{4})/gi;
3
+ x = x.replace(r, function (match, grp) {
4
+ return String.fromCharCode(parseInt(grp, 16));
5
+ });
6
+ return unescape(x);
7
+ }
package/utils/uri.js CHANGED
@@ -1,33 +1,33 @@
1
- export default {
2
-
3
- isFileURI: (uri: string): boolean => {
4
- if (typeof uri !== 'string')
5
- return false;
6
- return /^ReactNativeBlobUtil-file\:\/\//.test(uri);
7
- },
8
-
9
- isJSONStreamURI: (uri: string): boolean => {
10
- if (typeof uri !== 'string')
11
- return false;
12
- return /^JSONStream\:\/\//.test(uri);
13
- },
14
-
15
- removeURIScheme: (uri: string, iterations: number): string => {
16
- iterations = iterations || 1;
17
- let result = uri;
18
- for (let i = 0; i < iterations; i++) {
19
- result = String(result).replace(/^[^\:]+\:\/\//, '');
20
- }
21
- return String(result);
22
- },
23
-
24
- unwrapFileURI: (uri: string): string => {
25
- return String(uri).replace(/^ReactNativeBlobUtil-file\:\/\//, '');
26
- },
27
-
28
- wrap: (path: string): string => {
29
- const prefix = path.startsWith('content://') ? 'ReactNativeBlobUtil-content://' : 'ReactNativeBlobUtil-file://';
30
- return prefix + path;
31
- }
32
-
33
- };
1
+ export default {
2
+
3
+ isFileURI: (uri: string): boolean => {
4
+ if (typeof uri !== 'string')
5
+ return false;
6
+ return /^ReactNativeBlobUtil-file\:\/\//.test(uri);
7
+ },
8
+
9
+ isJSONStreamURI: (uri: string): boolean => {
10
+ if (typeof uri !== 'string')
11
+ return false;
12
+ return /^JSONStream\:\/\//.test(uri);
13
+ },
14
+
15
+ removeURIScheme: (uri: string, iterations: number): string => {
16
+ iterations = iterations || 1;
17
+ let result = uri;
18
+ for (let i = 0; i < iterations; i++) {
19
+ result = String(result).replace(/^[^\:]+\:\/\//, '');
20
+ }
21
+ return String(result);
22
+ },
23
+
24
+ unwrapFileURI: (uri: string): string => {
25
+ return String(uri).replace(/^ReactNativeBlobUtil-file\:\/\//, '');
26
+ },
27
+
28
+ wrap: (path: string): string => {
29
+ const prefix = path.startsWith('content://') ? 'ReactNativeBlobUtil-content://' : 'ReactNativeBlobUtil-file://';
30
+ return prefix + path;
31
+ }
32
+
33
+ };