@react-native-documents/picker 9.3.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.
- package/LICENSE.md +21 -0
- package/android/.gradle/8.9/checksums/checksums.lock +0 -0
- package/android/.gradle/8.9/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/8.9/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.9/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/build.gradle +80 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/java/com/reactnativedocumentpicker/CopyDestination.kt +12 -0
- package/android/src/main/java/com/reactnativedocumentpicker/DocumentMetadataBuilder.kt +79 -0
- package/android/src/main/java/com/reactnativedocumentpicker/FileOperations.kt +203 -0
- package/android/src/main/java/com/reactnativedocumentpicker/IntentFactory.kt +36 -0
- package/android/src/main/java/com/reactnativedocumentpicker/IsKnownTypeImpl.kt +40 -0
- package/android/src/main/java/com/reactnativedocumentpicker/MetadataGetter.kt +150 -0
- package/android/src/main/java/com/reactnativedocumentpicker/PickOptions.kt +63 -0
- package/android/src/main/java/com/reactnativedocumentpicker/PromiseWrapper.java +105 -0
- package/android/src/main/java/com/reactnativedocumentpicker/RNDocumentPickerModule.kt +352 -0
- package/android/src/main/java/com/reactnativedocumentpicker/RNDocumentPickerPackage.java +49 -0
- package/android/src/paper/java/com/reactnativedocumentpicker/NativeDocumentPickerSpec.java +69 -0
- package/ios/RCTConvert+RNDocumentPicker.h +8 -0
- package/ios/RCTConvert+RNDocumentPicker.mm +16 -0
- package/ios/RNDocumentPicker.h +19 -0
- package/ios/RNDocumentPicker.mm +128 -0
- package/ios/swift/DocPicker.swift +84 -0
- package/ios/swift/DocSaver.swift +41 -0
- package/ios/swift/DocumentMetadataBuilder.swift +69 -0
- package/ios/swift/FileOperations.swift +68 -0
- package/ios/swift/IsKnownTypeImpl.swift +42 -0
- package/ios/swift/LocalCopyResponse.swift +27 -0
- package/ios/swift/PickerBase.swift +78 -0
- package/ios/swift/PickerOptions.swift +44 -0
- package/ios/swift/PromiseSupport.swift +2 -0
- package/ios/swift/PromiseWrapper.swift +92 -0
- package/ios/swift/SaverOptions.swift +30 -0
- package/jest/build/jest/setup.js +70 -0
- package/jest/build/src/errors.js +47 -0
- package/jest/build/src/fileTypes.js +53 -0
- package/jest/build/src/index.js +22 -0
- package/jest/build/src/isKnownType.js +16 -0
- package/jest/build/src/keepLocalCopy.js +17 -0
- package/jest/build/src/pick.js +50 -0
- package/jest/build/src/pickDirectory.js +31 -0
- package/jest/build/src/release.js +22 -0
- package/jest/build/src/saveDocuments.js +40 -0
- package/jest/build/src/spec/NativeDocumentPicker.js +5 -0
- package/jest/build/src/types.js +4 -0
- package/jest/build/src/validateTypes.js +23 -0
- package/jest/build/tsconfig.tsbuildinfo +1 -0
- package/lib/commonjs/errors.js +53 -0
- package/lib/commonjs/errors.js.map +1 -0
- package/lib/commonjs/fileTypes.js +84 -0
- package/lib/commonjs/fileTypes.js.map +1 -0
- package/lib/commonjs/index.js +74 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/isKnownType.js +27 -0
- package/lib/commonjs/isKnownType.js.map +1 -0
- package/lib/commonjs/keepLocalCopy.js +34 -0
- package/lib/commonjs/keepLocalCopy.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/pick.js +93 -0
- package/lib/commonjs/pick.js.map +1 -0
- package/lib/commonjs/pickDirectory.js +71 -0
- package/lib/commonjs/pickDirectory.js.map +1 -0
- package/lib/commonjs/release.js +31 -0
- package/lib/commonjs/release.js.map +1 -0
- package/lib/commonjs/saveDocuments.js +55 -0
- package/lib/commonjs/saveDocuments.js.map +1 -0
- package/lib/commonjs/spec/NativeDocumentPicker.js +16 -0
- package/lib/commonjs/spec/NativeDocumentPicker.js.map +1 -0
- package/lib/commonjs/types.js +37 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/commonjs/validateTypes.js +29 -0
- package/lib/commonjs/validateTypes.js.map +1 -0
- package/lib/module/errors.js +48 -0
- package/lib/module/errors.js.map +1 -0
- package/lib/module/fileTypes.js +81 -0
- package/lib/module/fileTypes.js.map +1 -0
- package/lib/module/index.js +13 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/isKnownType.js +24 -0
- package/lib/module/isKnownType.js.map +1 -0
- package/lib/module/keepLocalCopy.js +31 -0
- package/lib/module/keepLocalCopy.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/pick.js +90 -0
- package/lib/module/pick.js.map +1 -0
- package/lib/module/pickDirectory.js +68 -0
- package/lib/module/pickDirectory.js.map +1 -0
- package/lib/module/release.js +26 -0
- package/lib/module/release.js.map +1 -0
- package/lib/module/saveDocuments.js +52 -0
- package/lib/module/saveDocuments.js.map +1 -0
- package/lib/module/spec/NativeDocumentPicker.js +13 -0
- package/lib/module/spec/NativeDocumentPicker.js.map +1 -0
- package/lib/module/types.js +33 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/validateTypes.js +24 -0
- package/lib/module/validateTypes.js.map +1 -0
- package/lib/typescript/errors.d.ts +40 -0
- package/lib/typescript/errors.d.ts.map +1 -0
- package/lib/typescript/fileTypes.d.ts +94 -0
- package/lib/typescript/fileTypes.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +13 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/isKnownType.d.ts +41 -0
- package/lib/typescript/isKnownType.d.ts.map +1 -0
- package/lib/typescript/keepLocalCopy.d.ts +46 -0
- package/lib/typescript/keepLocalCopy.d.ts.map +1 -0
- package/lib/typescript/pick.d.ts +84 -0
- package/lib/typescript/pick.d.ts.map +1 -0
- package/lib/typescript/pickDirectory.d.ts +62 -0
- package/lib/typescript/pickDirectory.d.ts.map +1 -0
- package/lib/typescript/release.d.ts +24 -0
- package/lib/typescript/release.d.ts.map +1 -0
- package/lib/typescript/saveDocuments.d.ts +55 -0
- package/lib/typescript/saveDocuments.d.ts.map +1 -0
- package/lib/typescript/spec/NativeDocumentPicker.d.ts +29 -0
- package/lib/typescript/spec/NativeDocumentPicker.d.ts.map +1 -0
- package/lib/typescript/types.d.ts +95 -0
- package/lib/typescript/types.d.ts.map +1 -0
- package/lib/typescript/validateTypes.d.ts +3 -0
- package/lib/typescript/validateTypes.d.ts.map +1 -0
- package/package.json +92 -0
- package/react-native-document-picker.podspec +30 -0
- package/src/errors.ts +49 -0
- package/src/fileTypes.ts +92 -0
- package/src/index.ts +47 -0
- package/src/isKnownType.ts +48 -0
- package/src/keepLocalCopy.ts +51 -0
- package/src/pick.ts +151 -0
- package/src/pickDirectory.ts +93 -0
- package/src/release.ts +36 -0
- package/src/saveDocuments.ts +99 -0
- package/src/spec/NativeDocumentPicker.ts +31 -0
- package/src/types.ts +119 -0
- package/src/validateTypes.ts +26 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "errorCodes", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _errors.errorCodes;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "isErrorWithCode", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _errors.isErrorWithCode;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "isKnownType", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _isKnownType.isKnownType;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "keepLocalCopy", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _keepLocalCopy.keepLocalCopy;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "pick", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _pick.pick;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "pickDirectory", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _pickDirectory.pickDirectory;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports, "releaseLongTermAccess", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function () {
|
|
45
|
+
return _release.releaseLongTermAccess;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(exports, "releaseSecureAccess", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function () {
|
|
51
|
+
return _release.releaseSecureAccess;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(exports, "saveDocuments", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return _saveDocuments.saveDocuments;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(exports, "types", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function () {
|
|
63
|
+
return _fileTypes.types;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
var _isKnownType = require("./isKnownType");
|
|
67
|
+
var _keepLocalCopy = require("./keepLocalCopy");
|
|
68
|
+
var _fileTypes = require("./fileTypes");
|
|
69
|
+
var _errors = require("./errors");
|
|
70
|
+
var _pickDirectory = require("./pickDirectory");
|
|
71
|
+
var _pick = require("./pick");
|
|
72
|
+
var _saveDocuments = require("./saveDocuments");
|
|
73
|
+
var _release = require("./release");
|
|
74
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_isKnownType","require","_keepLocalCopy","_fileTypes","_errors","_pickDirectory","_pick","_saveDocuments","_release"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AAQA,IAAAE,UAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,cAAA,GAAAJ,OAAA;AASA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,cAAA,GAAAN,OAAA;AAqBA,IAAAO,QAAA,GAAAP,OAAA","ignoreList":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isKnownType = isKnownType;
|
|
7
|
+
var _NativeDocumentPicker = require("./spec/NativeDocumentPicker");
|
|
8
|
+
/**
|
|
9
|
+
* The result of calling {@link isKnownType}
|
|
10
|
+
* */
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* Checks if the given value (which can be a file extension, UTType identifier or mime) is known to the system.
|
|
15
|
+
* Also returns the mime type which you can use to filter files on Android.
|
|
16
|
+
*
|
|
17
|
+
* @group DocumentPicker
|
|
18
|
+
* */
|
|
19
|
+
function isKnownType(options) {
|
|
20
|
+
const {
|
|
21
|
+
kind,
|
|
22
|
+
value
|
|
23
|
+
} = options;
|
|
24
|
+
const result = _NativeDocumentPicker.NativeDocumentPicker.isKnownType(kind, value);
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=isKnownType.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_NativeDocumentPicker","require","isKnownType","options","kind","value","result","NativeDocumentPicker"],"sourceRoot":"../../src","sources":["isKnownType.ts"],"mappings":";;;;;;AAAA,IAAAA,qBAAA,GAAAC,OAAA;AAEA;AACA;AACA;;AAgCA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,WAAWA,CAACC,OAA2B,EAAuB;EAC5E,MAAM;IAAEC,IAAI;IAAEC;EAAM,CAAC,GAAGF,OAAO;EAC/B,MAAMG,MAAM,GAAGC,0CAAoB,CAACL,WAAW,CAACE,IAAI,EAAEC,KAAK,CAAwB;EACnF,OAAOC,MAAM;AACf","ignoreList":[]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.keepLocalCopy = keepLocalCopy;
|
|
7
|
+
var _NativeDocumentPicker = require("./spec/NativeDocumentPicker");
|
|
8
|
+
/**
|
|
9
|
+
* Parameter of {@link keepLocalCopy}. Object type representing the file(s) whose copy should be kept in the app's storage.
|
|
10
|
+
* */
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* options for {@link keepLocalCopy}
|
|
14
|
+
*
|
|
15
|
+
* */
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Result of the call to {@link keepLocalCopy}. Please note the promise always resolves, even if there was an error processing any uri(s) (as indicated by the `status` field, and `copyError` field).
|
|
19
|
+
* */
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Makes the file available in the app's storage. The behavior is different on iOS and Android, and for simple use cases (such as uploading file to remote server), you may not need to call this method at all.
|
|
23
|
+
*
|
|
24
|
+
* On Android, it can be used to "convert" a `content://` Uri into a local file. It also "exports" virtual files (such as Google docs or sheets) into local files.
|
|
25
|
+
*
|
|
26
|
+
* However, note that for some use cases, such as uploading the picked file to a server, you may not need to call `keepLocalCopy` at all. React Native's `fetch` can handle `content://` uris.
|
|
27
|
+
*
|
|
28
|
+
* @group DocumentPicker
|
|
29
|
+
* */
|
|
30
|
+
function keepLocalCopy(options) {
|
|
31
|
+
const response = _NativeDocumentPicker.NativeDocumentPicker.keepLocalCopy(options);
|
|
32
|
+
return response;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=keepLocalCopy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_NativeDocumentPicker","require","keepLocalCopy","options","response","NativeDocumentPicker"],"sourceRoot":"../../src","sources":["keepLocalCopy.ts"],"mappings":";;;;;;AACA,IAAAA,qBAAA,GAAAC,OAAA;AAEA;AACA;AACA;;AAmBA;AACA;AACA;AACA;;AAMA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,aAAaA,CAACC,OAA6B,EAAkC;EAC3F,MAAMC,QAAQ,GAAGC,0CAAoB,CAACH,aAAa,CAACC,OAAO,CAAC;EAC5D,OAAOC,QAAQ;AACjB","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.pick = pick;
|
|
7
|
+
var _NativeDocumentPicker = require("./spec/NativeDocumentPicker");
|
|
8
|
+
var _fileTypes = require("./fileTypes");
|
|
9
|
+
var _reactNative = require("react-native");
|
|
10
|
+
var _validateTypes = require("./validateTypes");
|
|
11
|
+
/**
|
|
12
|
+
* Base options object for the document picker.
|
|
13
|
+
* You'd rarely use this type directly, but instead use one of
|
|
14
|
+
*
|
|
15
|
+
* {@link DocumentPickerOptionsImport}, {@link DocumentPickerOptionsOpenOnce} or {@link DocumentPickerOptionsOpenLongTerm}
|
|
16
|
+
*
|
|
17
|
+
* which extend this type
|
|
18
|
+
* @group pick() types
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Present the document picker in import mode.
|
|
23
|
+
*
|
|
24
|
+
* @group pick() types
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Present the document picker in open mode, with permissions to access the file for a limited time (until the app terminates).
|
|
29
|
+
*
|
|
30
|
+
* @group pick() types
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Present the document picker in open mode, with long-term permissions to access the opened file.
|
|
35
|
+
*
|
|
36
|
+
* @group pick() types
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @hidden
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The result of calling {@link pick} with `mode: 'open'` and `requestLongTermAccess: true`
|
|
45
|
+
*
|
|
46
|
+
* @group pick() types
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
// TODO not entirely sure this is a good idea but let's try
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* The method for picking a file, both for `import` and `open` modes.
|
|
53
|
+
*
|
|
54
|
+
* For result types, see {@link DocumentPickerResponse} or {@link DocumentPickerResponseOpenLongTerm}.
|
|
55
|
+
*
|
|
56
|
+
* For options, see {@link DocumentPickerOptionsImport}, {@link DocumentPickerOptionsOpenOnce} or {@link DocumentPickerOptionsOpenLongTerm}.
|
|
57
|
+
*
|
|
58
|
+
* @group DocumentPicker
|
|
59
|
+
* */
|
|
60
|
+
async function pick(options) {
|
|
61
|
+
const type = (() => {
|
|
62
|
+
if (!options?.type) {
|
|
63
|
+
return [_fileTypes.types.allFiles];
|
|
64
|
+
}
|
|
65
|
+
const newType = Array.isArray(options.type) ? options.type : [options.type];
|
|
66
|
+
return newType.flat().map(it => it.trim());
|
|
67
|
+
})();
|
|
68
|
+
const newOpts = {
|
|
69
|
+
mode: 'import',
|
|
70
|
+
// allowMultiSelection must be false to maintain old (v5) behavior
|
|
71
|
+
allowMultiSelection: false,
|
|
72
|
+
allowVirtualFiles: false,
|
|
73
|
+
...options,
|
|
74
|
+
type
|
|
75
|
+
};
|
|
76
|
+
if (!newOpts.type.every(it => typeof it === 'string')) {
|
|
77
|
+
throw new TypeError(`Unexpected type option in ${newOpts.type}, did you try using a DocumentPicker.types.* that does not exist?`);
|
|
78
|
+
}
|
|
79
|
+
if ('mode' in newOpts && !['import', 'open'].includes(newOpts.mode)) {
|
|
80
|
+
throw new TypeError('Invalid mode option: ' + newOpts.mode);
|
|
81
|
+
}
|
|
82
|
+
const response = _NativeDocumentPicker.NativeDocumentPicker.pick(newOpts);
|
|
83
|
+
const awaitedResult = await response;
|
|
84
|
+
for (const res of awaitedResult) {
|
|
85
|
+
if (_reactNative.Platform.OS === 'android') {
|
|
86
|
+
res.hasRequestedType = (0, _validateTypes.safeValidate)(newOpts.type, res);
|
|
87
|
+
} else {
|
|
88
|
+
res.hasRequestedType = true;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return awaitedResult;
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=pick.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_NativeDocumentPicker","require","_fileTypes","_reactNative","_validateTypes","pick","options","type","types","allFiles","newType","Array","isArray","flat","map","it","trim","newOpts","mode","allowMultiSelection","allowVirtualFiles","every","TypeError","includes","response","NativeDocumentPicker","awaitedResult","res","Platform","OS","hasRequestedType","safeValidate"],"sourceRoot":"../../src","sources":["pick.ts"],"mappings":";;;;;;AAAA,IAAAA,qBAAA,GAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AAQA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAgCA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;;AAOA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;;AAGA;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAeI,IAAIA,CAAkCC,OAAW,EAAmB;EACxF,MAAMC,IAAc,GAAG,CAAC,MAAM;IAC5B,IAAI,CAACD,OAAO,EAAEC,IAAI,EAAE;MAClB,OAAO,CAACC,gBAAK,CAACC,QAAQ,CAAC;IACzB;IACA,MAAMC,OAAO,GAAGC,KAAK,CAACC,OAAO,CAACN,OAAO,CAACC,IAAI,CAAC,GAAGD,OAAO,CAACC,IAAI,GAAG,CAACD,OAAO,CAACC,IAAI,CAAC;IAC3E,OAAOG,OAAO,CAACG,IAAI,CAAC,CAAC,CAACC,GAAG,CAAEC,EAAE,IAAKA,EAAE,CAACC,IAAI,CAAC,CAAC,CAAC;EAC9C,CAAC,EAAE,CAAC;EACJ,MAAMC,OAAsB,GAAG;IAC7BC,IAAI,EAAE,QAAQ;IACd;IACAC,mBAAmB,EAAE,KAAK;IAC1BC,iBAAiB,EAAE,KAAK;IACxB,GAAGd,OAAO;IACVC;EACF,CAAC;EAED,IAAI,CAACU,OAAO,CAACV,IAAI,CAACc,KAAK,CAAEN,EAAW,IAAK,OAAOA,EAAE,KAAK,QAAQ,CAAC,EAAE;IAChE,MAAM,IAAIO,SAAS,CACjB,6BAA6BL,OAAO,CAACV,IAAI,mEAC3C,CAAC;EACH;EAEA,IAAI,MAAM,IAAIU,OAAO,IAAI,CAAC,CAAC,QAAQ,EAAE,MAAM,CAAC,CAACM,QAAQ,CAACN,OAAO,CAACC,IAAI,CAAC,EAAE;IACnE,MAAM,IAAII,SAAS,CAAC,uBAAuB,GAAGL,OAAO,CAACC,IAAI,CAAC;EAC7D;EAEA,MAAMM,QAA2C,GAAGC,0CAAoB,CAACpB,IAAI,CAACY,OAAO,CAAC;EACtF,MAAMS,aAAa,GAAG,MAAMF,QAAQ;EACpC,KAAK,MAAMG,GAAG,IAAID,aAAa,EAAE;IAC/B,IAAIE,qBAAQ,CAACC,EAAE,KAAK,SAAS,EAAE;MAC7BF,GAAG,CAACG,gBAAgB,GAAG,IAAAC,2BAAY,EAACd,OAAO,CAACV,IAAI,EAAEoB,GAAG,CAAC;IACxD,CAAC,MAAM;MACLA,GAAG,CAACG,gBAAgB,GAAG,IAAI;IAC7B;EACF;EAEA,OAAOJ,aAAa;AACtB","ignoreList":[]}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.pickDirectory = pickDirectory;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
8
|
+
var _NativeDocumentPicker = require("./spec/NativeDocumentPicker");
|
|
9
|
+
/**
|
|
10
|
+
* Base options object for the directory picker. They only slightly influence the appearance of the picker modal on iOS.
|
|
11
|
+
* You'd rarely use this type directly, but instead use {@link DirectoryPickerOptions}
|
|
12
|
+
*
|
|
13
|
+
* which extend this type
|
|
14
|
+
* @group pickDirectory() types
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @hidden
|
|
19
|
+
* */
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Options for {@link pickDirectory}.
|
|
23
|
+
*
|
|
24
|
+
* @group pickDirectory() types
|
|
25
|
+
* */
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* This object represents the response from the directory picker, when long-term access was not requested.
|
|
29
|
+
*
|
|
30
|
+
* @group pickDirectory() types
|
|
31
|
+
* */
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* This object represents the response from the directory picker, when long-term access was requested.
|
|
35
|
+
*
|
|
36
|
+
* @group pickDirectory() types
|
|
37
|
+
* */
|
|
38
|
+
|
|
39
|
+
// TODO not entirely sure this is a good idea but let's try
|
|
40
|
+
/**
|
|
41
|
+
* You likely won't use this type directly, but instead use {@link DirectoryPickerResponse} or {@link DirectoryPickerResponseLongTerm}.
|
|
42
|
+
*
|
|
43
|
+
* @group pickDirectory() types
|
|
44
|
+
* */
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Opens a directory picker.
|
|
48
|
+
*
|
|
49
|
+
* @group DocumentPicker
|
|
50
|
+
* */
|
|
51
|
+
async function pickDirectory(options) {
|
|
52
|
+
const optionsOverride = (() => {
|
|
53
|
+
if (_reactNative.Platform.OS === 'ios') {
|
|
54
|
+
return {
|
|
55
|
+
...options,
|
|
56
|
+
mode: 'open',
|
|
57
|
+
allowMultiSelection: false,
|
|
58
|
+
type: ['public.folder']
|
|
59
|
+
};
|
|
60
|
+
} else {
|
|
61
|
+
return {
|
|
62
|
+
// technically, "mode" is ignored here, and we shouldn't need to specify anything but the PickOptions data class
|
|
63
|
+
// requires mode to be set
|
|
64
|
+
mode: 'open',
|
|
65
|
+
...options
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
})();
|
|
69
|
+
return _NativeDocumentPicker.NativeDocumentPicker.pickDirectory(optionsOverride);
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=pickDirectory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_NativeDocumentPicker","pickDirectory","options","optionsOverride","Platform","OS","mode","allowMultiSelection","type","NativeDocumentPicker"],"sourceRoot":"../../src","sources":["pickDirectory.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAD,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAWA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;AACO,eAAeE,aAAaA,CACjCC,OAAW,EACe;EAC1B,MAAMC,eAAe,GAAG,CAAC,MAAM;IAC7B,IAAIC,qBAAQ,CAACC,EAAE,KAAK,KAAK,EAAE;MACzB,OAAO;QACL,GAAGH,OAAO;QACVI,IAAI,EAAE,MAAM;QACZC,mBAAmB,EAAE,KAAK;QAC1BC,IAAI,EAAE,CAAC,eAAe;MACxB,CAAC;IACH,CAAC,MAAM;MACL,OAAO;QACL;QACA;QACAF,IAAI,EAAE,MAAM;QACZ,GAAGJ;MACL,CAAC;IACH;EACF,CAAC,EAAE,CAAC;EACJ,OAAOO,0CAAoB,CAACR,aAAa,CAACE,eAAe,CAAC;AAG5D","ignoreList":[]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.releaseSecureAccess = exports.releaseLongTermAccess = void 0;
|
|
7
|
+
var _NativeDocumentPicker = require("./spec/NativeDocumentPicker");
|
|
8
|
+
/**
|
|
9
|
+
* For each uri whose release was requested, the result will contain an object with the uri and a status.
|
|
10
|
+
* */
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Android only - Releases long-term access to the given URIs. There's no need to call this method on iOS - there's no iOS equivalent.
|
|
14
|
+
*
|
|
15
|
+
* See [Android documentation](https://developer.android.com/reference/android/content/ContentResolver#releasePersistableUriPermission(android.net.Uri,%20int)) for more information.
|
|
16
|
+
*/
|
|
17
|
+
const releaseLongTermAccess = async uris => {
|
|
18
|
+
return _NativeDocumentPicker.NativeDocumentPicker.releaseLongTermAccess(uris);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* iOS only - Releases (stops) secure access to the given URIs. Use with URIs obtained with Open mode or with the Directory Picker.
|
|
23
|
+
* See [iOS documentation](https://developer.apple.com/documentation/foundation/nsurl/1413736-stopaccessingsecurityscopedresou) for more information.
|
|
24
|
+
* There's no need to call this method on Android - there's no equivalent method on Android.
|
|
25
|
+
* */
|
|
26
|
+
exports.releaseLongTermAccess = releaseLongTermAccess;
|
|
27
|
+
const releaseSecureAccess = async uris => {
|
|
28
|
+
return _NativeDocumentPicker.NativeDocumentPicker.releaseSecureAccess(uris);
|
|
29
|
+
};
|
|
30
|
+
exports.releaseSecureAccess = releaseSecureAccess;
|
|
31
|
+
//# sourceMappingURL=release.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_NativeDocumentPicker","require","releaseLongTermAccess","uris","NativeDocumentPicker","exports","releaseSecureAccess"],"sourceRoot":"../../src","sources":["release.ts"],"mappings":";;;;;;AAAA,IAAAA,qBAAA,GAAAC,OAAA;AAEA;AACA;AACA;;AAaA;AACA;AACA;AACA;AACA;AACO,MAAMC,qBAAqB,GAAG,MACnCC,IAAc,IAC2B;EACzC,OAAOC,0CAAoB,CAACF,qBAAqB,CAACC,IAAI,CAAC;AACzD,CAAC;;AAED;AACA;AACA;AACA;AACA;AAJAE,OAAA,CAAAH,qBAAA,GAAAA,qBAAA;AAKO,MAAMI,mBAAmB,GAAG,MAAOH,IAAc,IAAoB;EAC1E,OAAOC,0CAAoB,CAACE,mBAAmB,CAACH,IAAI,CAAC;AACvD,CAAC;AAAAE,OAAA,CAAAC,mBAAA,GAAAA,mBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.saveDocuments = saveDocuments;
|
|
7
|
+
var _NativeDocumentPicker = require("./spec/NativeDocumentPicker");
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
/**
|
|
10
|
+
* Options object for the {@link saveDocuments} method. `sourceUris` is the only required field.
|
|
11
|
+
*
|
|
12
|
+
* @group saveDocuments() types
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The result of calling {@link saveDocuments}. It is very unlikely that the metadata fields would be `null`, but in theory, it can happen.
|
|
17
|
+
*
|
|
18
|
+
* @group saveDocuments() types
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The method for opening a "save as" dialog and saving source file(s) to a new location.
|
|
23
|
+
*
|
|
24
|
+
* On Android, only one file can be saved at a time.
|
|
25
|
+
*
|
|
26
|
+
* @group DocumentPicker
|
|
27
|
+
* */
|
|
28
|
+
async function saveDocuments(options) {
|
|
29
|
+
const writeDocumentResponse = await (async () => {
|
|
30
|
+
if (_reactNative.Platform.OS === 'android') {
|
|
31
|
+
const length = options.sourceUris.length;
|
|
32
|
+
if (length > 1) {
|
|
33
|
+
console.warn(`DocumentPicker.saveDocuments: Android only allows to save one file at a time.\n
|
|
34
|
+
You provided an array with ${length} entries.`);
|
|
35
|
+
}
|
|
36
|
+
// making this division into 2 calls might be an overkill... but who knows
|
|
37
|
+
const objectWithSingleUri = await _NativeDocumentPicker.NativeDocumentPicker.saveDocument(options);
|
|
38
|
+
const response = await _NativeDocumentPicker.NativeDocumentPicker.writeDocuments(objectWithSingleUri);
|
|
39
|
+
return response;
|
|
40
|
+
} else {
|
|
41
|
+
return _NativeDocumentPicker.NativeDocumentPicker.writeDocuments(options);
|
|
42
|
+
}
|
|
43
|
+
})();
|
|
44
|
+
return writeDocumentResponse.map(keepOnlySpecifiedFields);
|
|
45
|
+
}
|
|
46
|
+
function keepOnlySpecifiedFields(source) {
|
|
47
|
+
return {
|
|
48
|
+
uri: source.uri,
|
|
49
|
+
name: source.name,
|
|
50
|
+
error: source.error
|
|
51
|
+
// type: source.type,
|
|
52
|
+
// nativeType: source.nativeType,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=saveDocuments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_NativeDocumentPicker","require","_reactNative","saveDocuments","options","writeDocumentResponse","Platform","OS","length","sourceUris","console","warn","objectWithSingleUri","NativeDocumentPicker","saveDocument","response","writeDocuments","map","keepOnlySpecifiedFields","source","uri","name","error"],"sourceRoot":"../../src","sources":["saveDocuments.ts"],"mappings":";;;;;;AAAA,IAAAA,qBAAA,GAAAC,OAAA;AAGA,IAAAC,YAAA,GAAAD,OAAA;AAEA;AACA;AACA;AACA;AACA;;AAwBA;AACA;AACA;AACA;AACA;;AAuBA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAeE,aAAaA,CACjCC,OAA6B,EACkB;EAC/C,MAAMC,qBAAqB,GAAG,MAAM,CAAC,YAAY;IAC/C,IAAIC,qBAAQ,CAACC,EAAE,KAAK,SAAS,EAAE;MAC7B,MAAMC,MAAM,GAAGJ,OAAO,CAACK,UAAU,CAACD,MAAM;MACxC,IAAIA,MAAM,GAAG,CAAC,EAAE;QACdE,OAAO,CAACC,IAAI,CAAC;AACrB,mCAAmCH,MAAM,WAAW,CAAC;MAC/C;MACA;MACA,MAAMI,mBAAmB,GAAG,MAAMC,0CAAoB,CAACC,YAAY,CAACV,OAAO,CAAC;MAC5E,MAAMW,QAAQ,GAAG,MAAMF,0CAAoB,CAACG,cAAc,CAACJ,mBAAmB,CAAC;MAC/E,OAAOG,QAAQ;IACjB,CAAC,MAAM;MACL,OAAOF,0CAAoB,CAACG,cAAc,CAACZ,OAAO,CAAC;IAGrD;EACF,CAAC,EAAE,CAAC;EACJ,OAAOC,qBAAqB,CAACY,GAAG,CAACC,uBAAuB,CAAC;AAC3D;AAEA,SAASA,uBAAuBA,CAACC,MAA8B,EAAyB;EACtF,OAAO;IACLC,GAAG,EAAED,MAAM,CAACC,GAAG;IACfC,IAAI,EAAEF,MAAM,CAACE,IAAI;IACjBC,KAAK,EAAEH,MAAM,CAACG;IACd;IACA;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.NativeDocumentPicker = void 0;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
8
|
+
/**
|
|
9
|
+
* Indicates, for each Uri that was passed to {@link keepLocalCopy}, whether the local copy was successfully created or not.
|
|
10
|
+
*
|
|
11
|
+
* If the copy was successful, the status field is `success` and `localUri` contains the local Uri.
|
|
12
|
+
* If the copy was not successful, the status field is `error` and `copyError` field contains the error message.
|
|
13
|
+
* */
|
|
14
|
+
|
|
15
|
+
const NativeDocumentPicker = exports.NativeDocumentPicker = _reactNative.TurboModuleRegistry.getEnforcing('RNDocumentPicker');
|
|
16
|
+
//# sourceMappingURL=NativeDocumentPicker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","NativeDocumentPicker","exports","TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../../src","sources":["spec/NativeDocumentPicker.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAGA;AACA;AACA;AACA;AACA;AACA;;AAqBO,MAAMC,oBAAoB,GAAAC,OAAA,CAAAD,oBAAA,GAAGE,gCAAmB,CAACC,YAAY,CAAO,kBAAkB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.typesAreEqual = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* If you've requested long-term access to a directory or file, this object will be returned in the response.
|
|
9
|
+
* In order to access the same directory or file in the future, you must store the `bookmark` opaque string,
|
|
10
|
+
* and then pass it to the document viewer if you want to preview the file.
|
|
11
|
+
*
|
|
12
|
+
* See the Document viewer source on how to retrieve the file from the bookmark, if you need to do that (advanced use case).
|
|
13
|
+
* */
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @group pick() types
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @group pick() types
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* iOS only. Configure the transition style of the picker.
|
|
25
|
+
* */
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* iOS only. Configure the presentation style of the picker.
|
|
29
|
+
* */
|
|
30
|
+
|
|
31
|
+
/*
|
|
32
|
+
* really, PresentationStyle shouldn't be here and we should just use ModalPropsIOS['presentationStyle']>
|
|
33
|
+
* but I'm not sure how to get that working with TypeDoc producing a nice output so we duplicate it here
|
|
34
|
+
* */
|
|
35
|
+
|
|
36
|
+
const typesAreEqual = exports.typesAreEqual = true;
|
|
37
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["typesAreEqual","exports"],"sourceRoot":"../../src","sources":["types.ts"],"mappings":";;;;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;AAWA;AACA;AACA;;AAkBA;AACA;AACA;;AAiDA;AACA;AACA;;AAQA;AACA;AACA;;AAOA;AACA;AACA;AACA;;AAIO,MAAMA,aAAoF,GAAAC,OAAA,CAAAD,aAAA,GAC/F,IAAI","ignoreList":[]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.safeValidate = void 0;
|
|
7
|
+
const safeValidate = (requestedTypes, singlePickResult) => {
|
|
8
|
+
const {
|
|
9
|
+
nativeType
|
|
10
|
+
} = singlePickResult;
|
|
11
|
+
return requestedTypes.some(it => nativeTypeMatches(it, nativeType));
|
|
12
|
+
};
|
|
13
|
+
exports.safeValidate = safeValidate;
|
|
14
|
+
const nativeTypeMatches = (requiredType, actualType) => {
|
|
15
|
+
if (requiredType === actualType || requiredType === '*/*') {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
if (actualType === null) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
if (requiredType.endsWith('/*')) {
|
|
22
|
+
const requiredTypeWithoutStar = requiredType.slice(0, -2);
|
|
23
|
+
if (actualType.startsWith(requiredTypeWithoutStar)) {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=validateTypes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["safeValidate","requestedTypes","singlePickResult","nativeType","some","it","nativeTypeMatches","exports","requiredType","actualType","endsWith","requiredTypeWithoutStar","slice","startsWith"],"sourceRoot":"../../src","sources":["validateTypes.ts"],"mappings":";;;;;;AAEO,MAAMA,YAAY,GAAGA,CAC1BC,cAAwB,EACxBC,gBAA4D,KACzD;EACH,MAAM;IAAEC;EAAW,CAAC,GAAGD,gBAAgB;EACvC,OAAOD,cAAc,CAACG,IAAI,CAAEC,EAAE,IAAKC,iBAAiB,CAACD,EAAE,EAAEF,UAAU,CAAC,CAAC;AACvE,CAAC;AAAAI,OAAA,CAAAP,YAAA,GAAAA,YAAA;AAED,MAAMM,iBAAiB,GAAGA,CAACE,YAAoB,EAAEC,UAAyB,KAAK;EAC7E,IAAID,YAAY,KAAKC,UAAU,IAAID,YAAY,KAAK,KAAK,EAAE;IACzD,OAAO,IAAI;EACb;EACA,IAAIC,UAAU,KAAK,IAAI,EAAE;IACvB,OAAO,KAAK;EACd;EACA,IAAID,YAAY,CAACE,QAAQ,CAAC,IAAI,CAAC,EAAE;IAC/B,MAAMC,uBAAuB,GAAGH,YAAY,CAACI,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACzD,IAAIH,UAAU,CAACI,UAAU,CAACF,uBAAuB,CAAC,EAAE;MAClD,OAAO,IAAI;IACb;EACF;EAEA,OAAO,KAAK;AACd,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const OPERATION_CANCELED = 'OPERATION_CANCELED';
|
|
4
|
+
const IN_PROGRESS = 'ASYNC_OP_IN_PROGRESS';
|
|
5
|
+
const UNABLE_TO_OPEN_FILE_TYPE = 'UNABLE_TO_OPEN_FILE_TYPE';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Error codes that can be returned by the module, and are available on the `code` property of the error.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const handleError = (err: unknown) => {
|
|
13
|
+
* if (isErrorWithCode(err)) {
|
|
14
|
+
* switch (err.code) {
|
|
15
|
+
* case errorCodes.IN_PROGRESS:
|
|
16
|
+
* ...
|
|
17
|
+
* break
|
|
18
|
+
* case errorCodes.UNABLE_TO_OPEN_FILE_TYPE:
|
|
19
|
+
* ...
|
|
20
|
+
* break
|
|
21
|
+
* case errorCodes.OPERATION_CANCELED:
|
|
22
|
+
* // ignore
|
|
23
|
+
* break
|
|
24
|
+
* default:
|
|
25
|
+
* console.error(err)
|
|
26
|
+
* }
|
|
27
|
+
* } else {
|
|
28
|
+
* console.error(err)
|
|
29
|
+
* }
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
* */
|
|
33
|
+
export const errorCodes = Object.freeze({
|
|
34
|
+
OPERATION_CANCELED,
|
|
35
|
+
IN_PROGRESS,
|
|
36
|
+
UNABLE_TO_OPEN_FILE_TYPE
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* TypeScript helper to check if an object has the `code` property.
|
|
41
|
+
* This is used to avoid `as` casting when you access the `code` property on errors returned by the module.
|
|
42
|
+
*/
|
|
43
|
+
export const isErrorWithCode = error => {
|
|
44
|
+
// to account for https://github.com/facebook/react-native/issues/41950
|
|
45
|
+
const isNewArchErrorIOS = typeof error === 'object' && error != null;
|
|
46
|
+
return (error instanceof Error || isNewArchErrorIOS) && 'code' in error;
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["OPERATION_CANCELED","IN_PROGRESS","UNABLE_TO_OPEN_FILE_TYPE","errorCodes","Object","freeze","isErrorWithCode","error","isNewArchErrorIOS","Error"],"sourceRoot":"../../src","sources":["errors.ts"],"mappings":";;AAIA,MAAMA,kBAAkB,GAAG,oBAAoB;AAC/C,MAAMC,WAAW,GAAG,sBAAsB;AAC1C,MAAMC,wBAAwB,GAAG,0BAA0B;;AAE3D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,UAAU,GAAGC,MAAM,CAACC,MAAM,CAAC;EACtCL,kBAAkB;EAClBC,WAAW;EACXC;AACF,CAAC,CAAC;;AAEF;AACA;AACA;AACA;AACA,OAAO,MAAMI,eAAe,GAAIC,KAAU,IAAiC;EACzE;EACA,MAAMC,iBAAiB,GAAG,OAAOD,KAAK,KAAK,QAAQ,IAAIA,KAAK,IAAI,IAAI;EACpE,OAAO,CAACA,KAAK,YAAYE,KAAK,IAAID,iBAAiB,KAAK,MAAM,IAAID,KAAK;AACzE,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { Platform } from 'react-native';
|
|
4
|
+
|
|
5
|
+
// TODO split this into platform-specific files, and / or topic-specific files
|
|
6
|
+
|
|
7
|
+
const mimeTypes = Object.freeze({
|
|
8
|
+
allFiles: '*/*',
|
|
9
|
+
audio: 'audio/*',
|
|
10
|
+
csv: ['text/csv', 'text/comma-separated-values'],
|
|
11
|
+
doc: 'application/msword',
|
|
12
|
+
docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
13
|
+
images: 'image/*',
|
|
14
|
+
pdf: 'application/pdf',
|
|
15
|
+
plainText: 'text/plain',
|
|
16
|
+
json: 'application/json',
|
|
17
|
+
ppt: 'application/vnd.ms-powerpoint',
|
|
18
|
+
pptx: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
|
19
|
+
video: 'video/*',
|
|
20
|
+
xls: 'application/vnd.ms-excel',
|
|
21
|
+
xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
22
|
+
zip: 'application/zip'
|
|
23
|
+
}); //satisfies TypeOfFileTypes
|
|
24
|
+
|
|
25
|
+
const utis = Object.freeze({
|
|
26
|
+
allFiles: 'public.item',
|
|
27
|
+
audio: 'public.audio',
|
|
28
|
+
csv: 'public.comma-separated-values-text',
|
|
29
|
+
doc: 'com.microsoft.word.doc',
|
|
30
|
+
docx: 'org.openxmlformats.wordprocessingml.document',
|
|
31
|
+
images: 'public.image',
|
|
32
|
+
pdf: 'com.adobe.pdf',
|
|
33
|
+
plainText: 'public.plain-text',
|
|
34
|
+
json: 'public.json',
|
|
35
|
+
ppt: 'com.microsoft.powerpoint.ppt',
|
|
36
|
+
pptx: 'org.openxmlformats.presentationml.presentation',
|
|
37
|
+
video: 'public.movie',
|
|
38
|
+
xls: 'com.microsoft.excel.xls',
|
|
39
|
+
xlsx: 'org.openxmlformats.spreadsheetml.sheet',
|
|
40
|
+
zip: 'public.zip-archive'
|
|
41
|
+
}); // satisfies TypeOfFileTypes
|
|
42
|
+
|
|
43
|
+
const perPlatformTypes = {
|
|
44
|
+
android: mimeTypes,
|
|
45
|
+
ios: utis,
|
|
46
|
+
// unsupported, but added to make TS happy
|
|
47
|
+
macos: utis,
|
|
48
|
+
windows: mimeTypes,
|
|
49
|
+
web: mimeTypes
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @hidden
|
|
54
|
+
* */
|
|
55
|
+
export const types = perPlatformTypes[Platform.OS];
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* You'd rarely use this type directly.
|
|
59
|
+
* It represents the predefined file types which are exported as `types` and can be used to limit the kinds of files that can be picked.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* import {
|
|
64
|
+
* pick,
|
|
65
|
+
* types,
|
|
66
|
+
* } from '@react-native-documents/picker'
|
|
67
|
+
* // ...
|
|
68
|
+
* const result = await pick({
|
|
69
|
+
* type: [types.pdf, types.docx],
|
|
70
|
+
* })
|
|
71
|
+
* ```
|
|
72
|
+
* */
|
|
73
|
+
|
|
74
|
+
// export type PlatformTypes = typeof perPlatformTypes
|
|
75
|
+
|
|
76
|
+
// ensure shapes of platformTypes are the same: https://stackoverflow.com/a/67027347/2070942
|
|
77
|
+
// let me know if there's a nicer way
|
|
78
|
+
|
|
79
|
+
const mimesAndUtisAreEqual = true;
|
|
80
|
+
export const typesAreEqual = mimesAndUtisAreEqual;
|
|
81
|
+
//# sourceMappingURL=fileTypes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Platform","mimeTypes","Object","freeze","allFiles","audio","csv","doc","docx","images","pdf","plainText","json","ppt","pptx","video","xls","xlsx","zip","utis","perPlatformTypes","android","ios","macos","windows","web","types","OS","mimesAndUtisAreEqual","typesAreEqual"],"sourceRoot":"../../src","sources":["fileTypes.ts"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,cAAc;;AAEvC;;AAEA,MAAMC,SAAS,GAAGC,MAAM,CAACC,MAAM,CAAC;EAC9BC,QAAQ,EAAE,KAAK;EACfC,KAAK,EAAE,SAAS;EAChBC,GAAG,EAAE,CAAC,UAAU,EAAE,6BAA6B,CAAC;EAChDC,GAAG,EAAE,oBAAoB;EACzBC,IAAI,EAAE,yEAAyE;EAC/EC,MAAM,EAAE,SAAS;EACjBC,GAAG,EAAE,iBAAiB;EACtBC,SAAS,EAAE,YAAY;EACvBC,IAAI,EAAE,kBAAkB;EACxBC,GAAG,EAAE,+BAA+B;EACpCC,IAAI,EAAE,2EAA2E;EACjFC,KAAK,EAAE,SAAS;EAChBC,GAAG,EAAE,0BAA0B;EAC/BC,IAAI,EAAE,mEAAmE;EACzEC,GAAG,EAAE;AACP,CAAU,CAAC,EAAC;;AAEZ,MAAMC,IAAI,GAAGjB,MAAM,CAACC,MAAM,CAAC;EACzBC,QAAQ,EAAE,aAAa;EACvBC,KAAK,EAAE,cAAc;EACrBC,GAAG,EAAE,oCAAoC;EACzCC,GAAG,EAAE,wBAAwB;EAC7BC,IAAI,EAAE,8CAA8C;EACpDC,MAAM,EAAE,cAAc;EACtBC,GAAG,EAAE,eAAe;EACpBC,SAAS,EAAE,mBAAmB;EAC9BC,IAAI,EAAE,aAAa;EACnBC,GAAG,EAAE,8BAA8B;EACnCC,IAAI,EAAE,gDAAgD;EACtDC,KAAK,EAAE,cAAc;EACrBC,GAAG,EAAE,yBAAyB;EAC9BC,IAAI,EAAE,wCAAwC;EAC9CC,GAAG,EAAE;AACP,CAAU,CAAC,EAAC;;AAEZ,MAAME,gBAAgB,GAAG;EACvBC,OAAO,EAAEpB,SAAS;EAClBqB,GAAG,EAAEH,IAAI;EACT;EACAI,KAAK,EAAEJ,IAAI;EACXK,OAAO,EAAEvB,SAAS;EAClBwB,GAAG,EAAExB;AACP,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMyB,KAAK,GAAGN,gBAAgB,CAACpB,QAAQ,CAAC2B,EAAE,CAAC;;AAQlD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;;AAEA;AACA;;AASA,MAAMC,oBAAoE,GAAG,IAAI;AACjF,OAAO,MAAMC,aAAa,GAAGD,oBAAoB","ignoreList":[]}
|