@react-native-documents/picker 11.0.4 → 12.0.1

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 (42) hide show
  1. package/README.md +20 -0
  2. package/android/src/main/java/com/reactnativedocumentpicker/CopyDestination.kt +1 -2
  3. package/android/src/main/java/com/reactnativedocumentpicker/DocumentMetadataBuilder.kt +4 -3
  4. package/android/src/main/java/com/reactnativedocumentpicker/FileOperations.kt +2 -2
  5. package/android/src/main/java/com/reactnativedocumentpicker/IsKnownTypeImpl.kt +26 -28
  6. package/android/src/main/java/com/reactnativedocumentpicker/MetadataGetter.kt +69 -45
  7. package/android/src/main/java/com/reactnativedocumentpicker/PickOptions.kt +43 -23
  8. package/android/src/main/java/com/reactnativedocumentpicker/PromiseWrapper.kt +83 -0
  9. package/android/src/main/java/com/reactnativedocumentpicker/RNDocumentPickerModule.kt +5 -5
  10. package/ios/RNDocumentPicker.mm +19 -41
  11. package/ios/swift/DocPicker.swift +46 -28
  12. package/ios/swift/DocSaver.swift +18 -23
  13. package/ios/swift/DocumentMetadataBuilder.swift +1 -1
  14. package/ios/swift/FileOperations.swift +21 -19
  15. package/ios/swift/IsKnownTypeImpl.swift +16 -10
  16. package/ios/swift/LocalCopyResponse.swift +3 -5
  17. package/ios/swift/PickerBase.swift +31 -49
  18. package/ios/swift/PickerOptions.swift +53 -23
  19. package/ios/swift/PromiseWrapper.swift +71 -58
  20. package/ios/swift/SaverOptions.swift +39 -17
  21. package/jest/build/jest/setup.js +1 -4
  22. package/jest/build/src/errors.js +2 -0
  23. package/lib/module/errors.js +3 -2
  24. package/lib/module/errors.js.map +1 -1
  25. package/lib/module/release.js +1 -1
  26. package/lib/module/types.js +2 -2
  27. package/lib/typescript/src/errors.d.ts +6 -3
  28. package/lib/typescript/src/errors.d.ts.map +1 -1
  29. package/lib/typescript/src/isKnownType.d.ts +1 -1
  30. package/lib/typescript/src/release.d.ts +1 -1
  31. package/lib/typescript/src/saveDocuments.d.ts +1 -1
  32. package/lib/typescript/src/types.d.ts +5 -5
  33. package/package.json +4 -2
  34. package/react-native-document-picker.podspec +1 -0
  35. package/src/errors.ts +8 -4
  36. package/src/isKnownType.ts +1 -1
  37. package/src/release.ts +1 -1
  38. package/src/saveDocuments.ts +1 -1
  39. package/src/types.ts +5 -5
  40. package/android/src/main/java/com/reactnativedocumentpicker/IntentFactory.kt +0 -36
  41. package/android/src/main/java/com/reactnativedocumentpicker/PromiseWrapper.java +0 -105
  42. package/ios/swift/PromiseSupport.swift +0 -2
@@ -1,105 +0,0 @@
1
- // LICENSE: see License.md in the package root
2
- package com.reactnativedocumentpicker;
3
-
4
- import android.util.Log;
5
-
6
- import androidx.annotation.NonNull;
7
-
8
- import com.facebook.react.bridge.Promise;
9
-
10
- public class PromiseWrapper {
11
-
12
- private Promise promise;
13
- private String nameOfCallInProgress;
14
- public static final String ASYNC_OP_IN_PROGRESS = "ASYNC_OP_IN_PROGRESS";
15
- public static final String E_DOCUMENT_PICKER_CANCELED = "OPERATION_CANCELED";
16
- private final String MODULE_NAME;
17
-
18
- public PromiseWrapper(String moduleName) {
19
- MODULE_NAME = moduleName;
20
- }
21
-
22
- public void setPromiseRejectingPrevious(Promise promise, @NonNull String fromCallsite) {
23
- Promise previousPromise = this.promise;
24
- if (previousPromise != null) {
25
- rejectPreviousPromiseBecauseNewOneIsInProgress(previousPromise, fromCallsite);
26
- }
27
- this.promise = promise;
28
- nameOfCallInProgress = fromCallsite;
29
- }
30
-
31
- public boolean trySetPromiseRejectingIncoming(Promise promise, @NonNull String fromCallsite) {
32
- Promise previousPromise = this.promise;
33
- if (previousPromise != null) {
34
- rejectNewPromiseBecauseOldOneIsInProgress(promise, fromCallsite);
35
- return false;
36
- }
37
- this.promise = promise;
38
- nameOfCallInProgress = fromCallsite;
39
- return true;
40
- }
41
-
42
- public void resolve(Object value) {
43
- Promise resolver = promise;
44
- if (resolver == null) {
45
- Log.e(MODULE_NAME, "cannot resolve promise because it's null");
46
- return;
47
- }
48
-
49
- resetMembers();
50
- resolver.resolve(value);
51
- }
52
-
53
- public void reject(@NonNull String code, Exception e) {
54
- String message = e.getLocalizedMessage() != null ? e.getLocalizedMessage() :
55
- e.getMessage() != null ? e.getMessage() : "unknown error";
56
-
57
- this.reject(code, message, e);
58
- }
59
-
60
- public void reject(Exception e) {
61
- String message = e.getLocalizedMessage() != null ? e.getLocalizedMessage() :
62
- e.getMessage() != null ? e.getMessage() : "unknown error";
63
-
64
- this.reject(nameOfCallInProgress, message, e);
65
- }
66
-
67
- public void rejectAsUserCancelledOperation() {
68
- this.reject(E_DOCUMENT_PICKER_CANCELED, "user canceled the document picker");
69
- }
70
-
71
- public void reject(@NonNull String code, @NonNull String message) {
72
- reject(code, message, null);
73
- }
74
- public void reject(@NonNull String code, @NonNull String message, Exception e) {
75
- Promise rejecter = promise;
76
- if (rejecter == null) {
77
- Log.e(MODULE_NAME, "cannot reject promise because it's null");
78
- return;
79
- }
80
-
81
- resetMembers();
82
- rejecter.reject(code, message, e);
83
- }
84
-
85
- public String getNameOfCallInProgress() {
86
- return nameOfCallInProgress;
87
- }
88
-
89
- private void resetMembers() {
90
- nameOfCallInProgress = null;
91
- promise = null;
92
- }
93
-
94
-
95
- private void rejectPreviousPromiseBecauseNewOneIsInProgress(Promise promise, String requestedOperation) {
96
- // TODO better message
97
- promise.reject(ASYNC_OP_IN_PROGRESS, "Warning: previous promise did not settle and was overwritten. " +
98
- "You've called \"" + requestedOperation + "\" while \"" + getNameOfCallInProgress() + "\" was already in progress and has not completed yet.");
99
- }
100
- private void rejectNewPromiseBecauseOldOneIsInProgress(Promise promise, String requestedOperation) {
101
- // TODO better message
102
- promise.reject(ASYNC_OP_IN_PROGRESS, "Warning: previous promise did not settle and you attempted to overwrite it. " +
103
- "You've called \"" + requestedOperation + "\" while \"" + getNameOfCallInProgress() + "\" was already in progress and has not completed yet.");
104
- }
105
- }
@@ -1,2 +0,0 @@
1
- public typealias RNDPPromiseResolveBlock = ((Any?) -> Void)
2
- public typealias RNDPPromiseRejectBlock = (String?, String?, Error?) -> Void