@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,46 @@
|
|
|
1
|
+
import type { NonEmptyArray } from './types';
|
|
2
|
+
import { type LocalCopyResponse } from './spec/NativeDocumentPicker';
|
|
3
|
+
/**
|
|
4
|
+
* Parameter of {@link keepLocalCopy}. Object type representing the file(s) whose copy should be kept in the app's storage.
|
|
5
|
+
* */
|
|
6
|
+
export type FileToCopy = {
|
|
7
|
+
/**
|
|
8
|
+
* The uri to keep a local copy of. This would be a `content://` uri (Android), or a `file://` uri (iOS) that the user has previously picked.
|
|
9
|
+
* */
|
|
10
|
+
uri: string;
|
|
11
|
+
/**
|
|
12
|
+
* The name of the resulting file, with the file extension. You can use the `name` field from the response of the `pick()` method.
|
|
13
|
+
*
|
|
14
|
+
* Example: someFile.pdf
|
|
15
|
+
*
|
|
16
|
+
* */
|
|
17
|
+
fileName: string;
|
|
18
|
+
/**
|
|
19
|
+
* Only for Android virtual files: the type of the file to export to. For example, `application/pdf` or `text/plain`.
|
|
20
|
+
* Use one of the values from `convertibleToMimeTypes` from the response of the `pick()` method: {@link DocumentPickerResponse}.
|
|
21
|
+
* */
|
|
22
|
+
convertVirtualFileToType?: string;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* options for {@link keepLocalCopy}
|
|
26
|
+
*
|
|
27
|
+
* */
|
|
28
|
+
export type KeepLocalCopyOptions = {
|
|
29
|
+
files: NonEmptyArray<FileToCopy>;
|
|
30
|
+
destination: 'cachesDirectory' | 'documentDirectory';
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* 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).
|
|
34
|
+
* */
|
|
35
|
+
export type KeepLocalCopyResponse = NonEmptyArray<LocalCopyResponse>;
|
|
36
|
+
/**
|
|
37
|
+
* 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.
|
|
38
|
+
*
|
|
39
|
+
* 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.
|
|
40
|
+
*
|
|
41
|
+
* 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.
|
|
42
|
+
*
|
|
43
|
+
* @group DocumentPicker
|
|
44
|
+
* */
|
|
45
|
+
export declare function keepLocalCopy(options: KeepLocalCopyOptions): Promise<KeepLocalCopyResponse>;
|
|
46
|
+
//# sourceMappingURL=keepLocalCopy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keepLocalCopy.d.ts","sourceRoot":"","sources":["../../src/keepLocalCopy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC5C,OAAO,EAAE,KAAK,iBAAiB,EAAwB,MAAM,6BAA6B,CAAA;AAE1F;;KAEK;AACL,MAAM,MAAM,UAAU,GAAG;IACvB;;SAEK;IACL,GAAG,EAAE,MAAM,CAAA;IACX;;;;;SAKK;IACL,QAAQ,EAAE,MAAM,CAAA;IAChB;;;SAGK;IACL,wBAAwB,CAAC,EAAE,MAAM,CAAA;CAClC,CAAA;AACD;;;KAGK;AACL,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,EAAE,aAAa,CAAC,UAAU,CAAC,CAAA;IAChC,WAAW,EAAE,iBAAiB,GAAG,mBAAmB,CAAA;CACrD,CAAA;AAED;;KAEK;AACL,MAAM,MAAM,qBAAqB,GAAG,aAAa,CAAC,iBAAiB,CAAC,CAAA;AAEpE;;;;;;;;KAQK;AACL,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAG3F"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { PredefinedFileTypes } from './fileTypes';
|
|
2
|
+
import type { BookmarkingResponse, DocumentPickerResponse, NonEmptyArray, TransitionStyle, PresentationStyle } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Base options object for the document picker.
|
|
5
|
+
* You'd rarely use this type directly, but instead use one of
|
|
6
|
+
*
|
|
7
|
+
* {@link DocumentPickerOptionsImport}, {@link DocumentPickerOptionsOpenOnce} or {@link DocumentPickerOptionsOpenLongTerm}
|
|
8
|
+
*
|
|
9
|
+
* which extend this type
|
|
10
|
+
* @group pick() types
|
|
11
|
+
*/
|
|
12
|
+
export type DocumentPickerOptionsBase = {
|
|
13
|
+
/**
|
|
14
|
+
* Specify file type(s) that you want to pick. Use `types` for some predefined values.
|
|
15
|
+
* */
|
|
16
|
+
type?: string | PredefinedFileTypes | Array<PredefinedFileTypes | string>;
|
|
17
|
+
/**
|
|
18
|
+
* Whether to allow multiple files to be picked. False by default.
|
|
19
|
+
* */
|
|
20
|
+
allowMultiSelection?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Android only - Whether to allow virtual files (such as Google docs or sheets) to be picked. False by default.
|
|
23
|
+
* */
|
|
24
|
+
allowVirtualFiles?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* iOS only - Controls how the picker is presented, e.g. on an iPad you may want to present it fullscreen. Defaults to `pageSheet`.
|
|
27
|
+
* */
|
|
28
|
+
presentationStyle?: PresentationStyle;
|
|
29
|
+
/**
|
|
30
|
+
* iOS only - Configures the transition style of the picker. Defaults to coverVertical, when the picker is presented, its view slides up from the bottom of the screen.
|
|
31
|
+
* */
|
|
32
|
+
transitionStyle?: TransitionStyle;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Present the document picker in import mode.
|
|
36
|
+
*
|
|
37
|
+
* @group pick() types
|
|
38
|
+
*/
|
|
39
|
+
export type DocumentPickerOptionsImport = DocumentPickerOptionsBase & {
|
|
40
|
+
mode?: 'import';
|
|
41
|
+
requestLongTermAccess?: never;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Present the document picker in open mode, with permissions to access the file for a limited time (until the app terminates).
|
|
45
|
+
*
|
|
46
|
+
* @group pick() types
|
|
47
|
+
*/
|
|
48
|
+
export type DocumentPickerOptionsOpenOnce = DocumentPickerOptionsBase & {
|
|
49
|
+
mode: 'open';
|
|
50
|
+
requestLongTermAccess?: false;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Present the document picker in open mode, with long-term permissions to access the opened file.
|
|
54
|
+
*
|
|
55
|
+
* @group pick() types
|
|
56
|
+
*/
|
|
57
|
+
export type DocumentPickerOptionsOpenLongTerm = DocumentPickerOptionsBase & {
|
|
58
|
+
mode: 'open';
|
|
59
|
+
requestLongTermAccess: true;
|
|
60
|
+
};
|
|
61
|
+
type DocumentPickerOptionsOpen = DocumentPickerOptionsOpenOnce | DocumentPickerOptionsOpenLongTerm;
|
|
62
|
+
/**
|
|
63
|
+
* @hidden
|
|
64
|
+
*/
|
|
65
|
+
export type DocumentPickerOptions = DocumentPickerOptionsImport | DocumentPickerOptionsOpen;
|
|
66
|
+
/**
|
|
67
|
+
* The result of calling {@link pick} with `mode: 'open'` and `requestLongTermAccess: true`
|
|
68
|
+
*
|
|
69
|
+
* @group pick() types
|
|
70
|
+
*/
|
|
71
|
+
export type DocumentPickerResponseOpenLongTerm = DocumentPickerResponse & BookmarkingResponse;
|
|
72
|
+
type PickResponse<O extends DocumentPickerOptions> = Promise<O extends DocumentPickerOptionsOpenLongTerm ? NonEmptyArray<DocumentPickerResponseOpenLongTerm> : NonEmptyArray<DocumentPickerResponse>>;
|
|
73
|
+
/**
|
|
74
|
+
* The method for picking a file, both for `import` and `open` modes.
|
|
75
|
+
*
|
|
76
|
+
* For result types, see {@link DocumentPickerResponse} or {@link DocumentPickerResponseOpenLongTerm}.
|
|
77
|
+
*
|
|
78
|
+
* For options, see {@link DocumentPickerOptionsImport}, {@link DocumentPickerOptionsOpenOnce} or {@link DocumentPickerOptionsOpenLongTerm}.
|
|
79
|
+
*
|
|
80
|
+
* @group DocumentPicker
|
|
81
|
+
* */
|
|
82
|
+
export declare function pick<O extends DocumentPickerOptions>(options?: O): PickResponse<O>;
|
|
83
|
+
export {};
|
|
84
|
+
//# sourceMappingURL=pick.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pick.d.ts","sourceRoot":"","sources":["../../src/pick.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAS,MAAM,aAAa,CAAA;AACxD,OAAO,KAAK,EACV,mBAAmB,EACnB,sBAAsB,EACtB,aAAa,EACb,eAAe,EACf,iBAAiB,EAClB,MAAM,SAAS,CAAA;AAIhB;;;;;;;;GAQG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC;;SAEK;IACL,IAAI,CAAC,EAAE,MAAM,GAAG,mBAAmB,GAAG,KAAK,CAAC,mBAAmB,GAAG,MAAM,CAAC,CAAA;IAMzE;;SAEK;IACL,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAI7B;;SAEK;IACL,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B;;SAEK;IACL,iBAAiB,CAAC,EAAE,iBAAiB,CAAA;IACrC;;SAEK;IACL,eAAe,CAAC,EAAE,eAAe,CAAA;CAClC,CAAA;AAED;;;;GAIG;AACH,MAAM,MAAM,2BAA2B,GAAG,yBAAyB,GAAG;IACpE,IAAI,CAAC,EAAE,QAAQ,CAAA;IACf,qBAAqB,CAAC,EAAE,KAAK,CAAA;CAC9B,CAAA;AACD;;;;GAIG;AACH,MAAM,MAAM,6BAA6B,GAAG,yBAAyB,GAAG;IACtE,IAAI,EAAE,MAAM,CAAA;IACZ,qBAAqB,CAAC,EAAE,KAAK,CAAA;CAC9B,CAAA;AACD;;;;GAIG;AACH,MAAM,MAAM,iCAAiC,GAAG,yBAAyB,GAAG;IAC1E,IAAI,EAAE,MAAM,CAAA;IACZ,qBAAqB,EAAE,IAAI,CAAA;CAC5B,CAAA;AAED,KAAK,yBAAyB,GAAG,6BAA6B,GAAG,iCAAiC,CAAA;AAClG;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,2BAA2B,GAAG,yBAAyB,CAAA;AAE3F;;;;GAIG;AACH,MAAM,MAAM,kCAAkC,GAAG,sBAAsB,GAAG,mBAAmB,CAAA;AAG7F,KAAK,YAAY,CAAC,CAAC,SAAS,qBAAqB,IAAI,OAAO,CAC1D,CAAC,SAAS,iCAAiC,GACvC,aAAa,CAAC,kCAAkC,CAAC,GACjD,aAAa,CAAC,sBAAsB,CAAC,CAC1C,CAAA;AAID;;;;;;;;KAQK;AACL,wBAAsB,IAAI,CAAC,CAAC,SAAS,qBAAqB,EAAE,OAAO,CAAC,EAAE,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAsCxF"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { BookmarkingResponse, PresentationStyle, type TransitionStyle } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Base options object for the directory picker. They only slightly influence the appearance of the picker modal on iOS.
|
|
4
|
+
* You'd rarely use this type directly, but instead use {@link DirectoryPickerOptions}
|
|
5
|
+
*
|
|
6
|
+
* which extend this type
|
|
7
|
+
* @group pickDirectory() types
|
|
8
|
+
*/
|
|
9
|
+
export type DirectoryPickerOptionsBase = {
|
|
10
|
+
/**
|
|
11
|
+
* iOS only - Controls how the picker is presented, e.g. on an iPad you may want to present it fullscreen. Defaults to `pageSheet`.
|
|
12
|
+
* */
|
|
13
|
+
presentationStyle?: PresentationStyle;
|
|
14
|
+
/**
|
|
15
|
+
* iOS only - Configures the transition style of the picker. Defaults to coverVertical, when the picker is presented, its view slides up from the bottom of the screen.
|
|
16
|
+
* */
|
|
17
|
+
transitionStyle?: TransitionStyle;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* @hidden
|
|
21
|
+
* */
|
|
22
|
+
export type DirectoryPickerOptionsLongTerm = DirectoryPickerOptionsBase & {
|
|
23
|
+
requestLongTermAccess: true;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Options for {@link pickDirectory}.
|
|
27
|
+
*
|
|
28
|
+
* @group pickDirectory() types
|
|
29
|
+
* */
|
|
30
|
+
export type DirectoryPickerOptions = DirectoryPickerOptionsBase & {
|
|
31
|
+
requestLongTermAccess: boolean;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* This object represents the response from the directory picker, when long-term access was not requested.
|
|
35
|
+
*
|
|
36
|
+
* @group pickDirectory() types
|
|
37
|
+
* */
|
|
38
|
+
export type DirectoryPickerResponse = {
|
|
39
|
+
/**
|
|
40
|
+
* The (percent-encoded) directory selected by user.
|
|
41
|
+
* */
|
|
42
|
+
uri: string;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* This object represents the response from the directory picker, when long-term access was requested.
|
|
46
|
+
*
|
|
47
|
+
* @group pickDirectory() types
|
|
48
|
+
* */
|
|
49
|
+
export type DirectoryPickerResponseLongTerm = DirectoryPickerResponse & BookmarkingResponse;
|
|
50
|
+
/**
|
|
51
|
+
* You likely won't use this type directly, but instead use {@link DirectoryPickerResponse} or {@link DirectoryPickerResponseLongTerm}.
|
|
52
|
+
*
|
|
53
|
+
* @group pickDirectory() types
|
|
54
|
+
* */
|
|
55
|
+
export type PickDirectoryResponse<O extends DirectoryPickerOptions> = Promise<O extends DirectoryPickerOptionsLongTerm ? DirectoryPickerResponseLongTerm : DirectoryPickerResponse>;
|
|
56
|
+
/**
|
|
57
|
+
* Opens a directory picker.
|
|
58
|
+
*
|
|
59
|
+
* @group DocumentPicker
|
|
60
|
+
* */
|
|
61
|
+
export declare function pickDirectory<O extends DirectoryPickerOptions>(options?: O): PickDirectoryResponse<O>;
|
|
62
|
+
//# sourceMappingURL=pickDirectory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pickDirectory.d.ts","sourceRoot":"","sources":["../../src/pickDirectory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,KAAK,eAAe,EAAE,MAAM,SAAS,CAAA;AAItF;;;;;;GAMG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC;;SAEK;IACL,iBAAiB,CAAC,EAAE,iBAAiB,CAAA;IACrC;;SAEK;IACL,eAAe,CAAC,EAAE,eAAe,CAAA;CAClC,CAAA;AACD;;KAEK;AACL,MAAM,MAAM,8BAA8B,GAAG,0BAA0B,GAAG;IACxE,qBAAqB,EAAE,IAAI,CAAA;CAC5B,CAAA;AACD;;;;KAIK;AACL,MAAM,MAAM,sBAAsB,GAAG,0BAA0B,GAAG;IAAE,qBAAqB,EAAE,OAAO,CAAA;CAAE,CAAA;AAEpG;;;;KAIK;AACL,MAAM,MAAM,uBAAuB,GAAG;IACpC;;SAEK;IACL,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AACD;;;;KAIK;AACL,MAAM,MAAM,+BAA+B,GAAG,uBAAuB,GAAG,mBAAmB,CAAA;AAG3F;;;;KAIK;AACL,MAAM,MAAM,qBAAqB,CAAC,CAAC,SAAS,sBAAsB,IAAI,OAAO,CAC3E,CAAC,SAAS,8BAA8B,GACpC,+BAA+B,GAC/B,uBAAuB,CAC5B,CAAA;AAED;;;;KAIK;AACL,wBAAsB,aAAa,CAAC,CAAC,SAAS,sBAAsB,EAClE,OAAO,CAAC,EAAE,CAAC,GACV,qBAAqB,CAAC,CAAC,CAAC,CAqB1B"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* For each uri whose release was requested, the result will contain an object with the uri and a status.
|
|
3
|
+
* */
|
|
4
|
+
export type ReleaseLongTermAccessResult = Array<{
|
|
5
|
+
uri: string;
|
|
6
|
+
status: 'success';
|
|
7
|
+
} | {
|
|
8
|
+
uri: string;
|
|
9
|
+
status: 'error';
|
|
10
|
+
errorMessage: string;
|
|
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
|
+
export declare const releaseLongTermAccess: (uris: string[]) => Promise<ReleaseLongTermAccessResult>;
|
|
18
|
+
/**
|
|
19
|
+
* iOS only - Releases (stops) secure access to the given URIs. Use with URIs obtained with Open mode or with the Directory Picker.
|
|
20
|
+
* See [iOS documentation](https://developer.apple.com/documentation/foundation/nsurl/1413736-stopaccessingsecurityscopedresou) for more information.
|
|
21
|
+
* There's no need to call this method on Android - there's no equivalent method on Android.
|
|
22
|
+
* */
|
|
23
|
+
export declare const releaseSecureAccess: (uris: string[]) => Promise<null>;
|
|
24
|
+
//# sourceMappingURL=release.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"release.d.ts","sourceRoot":"","sources":["../../src/release.ts"],"names":[],"mappings":"AAEA;;KAEK;AACL,MAAM,MAAM,2BAA2B,GAAG,KAAK,CAC3C;IACE,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,SAAS,CAAA;CAClB,GACD;IACE,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,OAAO,CAAA;IACf,YAAY,EAAE,MAAM,CAAA;CACrB,CACJ,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,SAC1B,MAAM,EAAE,KACb,OAAO,CAAC,2BAA2B,CAErC,CAAA;AAED;;;;KAIK;AACL,eAAO,MAAM,mBAAmB,SAAgB,MAAM,EAAE,KAAG,OAAO,CAAC,IAAI,CAEtE,CAAA"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { NonEmptyArray } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Options object for the {@link saveDocuments} method. `sourceUris` is the only required field.
|
|
4
|
+
*
|
|
5
|
+
* @group saveDocuments() types
|
|
6
|
+
*/
|
|
7
|
+
export type SaveDocumentsOptions = {
|
|
8
|
+
/**
|
|
9
|
+
* The source URIs of the files to save, percentage-encoded. Android only allows to save one file at a time, iOS allows multiple.
|
|
10
|
+
* */
|
|
11
|
+
sourceUris: string[];
|
|
12
|
+
/**
|
|
13
|
+
* Android-only: The MIME type of the file to be stored.
|
|
14
|
+
* It is recommended to provide this value, otherwise the system will try to infer it from the sourceUri using ContentResolver.
|
|
15
|
+
* */
|
|
16
|
+
mimeType?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Android-only: The suggested title of the file to be stored, which will be pre-filled in the UI.
|
|
19
|
+
* On iOS, the target name is taken from the source uri, and is changeable only when exactly one file is being saved.
|
|
20
|
+
* */
|
|
21
|
+
fileName?: string;
|
|
22
|
+
/**
|
|
23
|
+
* iOS-only: Whether to copy the file to a new location, or move it (default).
|
|
24
|
+
* On Android, file is always copied.
|
|
25
|
+
* */
|
|
26
|
+
copy?: boolean;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* The result of calling {@link saveDocuments}. It is very unlikely that the metadata fields would be `null`, but in theory, it can happen.
|
|
30
|
+
*
|
|
31
|
+
* @group saveDocuments() types
|
|
32
|
+
*/
|
|
33
|
+
export type SaveDocumentsResponse = {
|
|
34
|
+
/**
|
|
35
|
+
* The target URI - the one user saved to. This is a percent-encoded `content://` uri (Android), or a `file://` uri (iOS).
|
|
36
|
+
* */
|
|
37
|
+
uri: string;
|
|
38
|
+
/**
|
|
39
|
+
* The name of the file that user entered, including extension.
|
|
40
|
+
* */
|
|
41
|
+
name: string | null;
|
|
42
|
+
/**
|
|
43
|
+
* Error in case the file could not be written or some metadata could not be obtained.
|
|
44
|
+
* */
|
|
45
|
+
error: string | null;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* The method for opening a "save as" dialog and saving source file(s) to a new location.
|
|
49
|
+
*
|
|
50
|
+
* On Android, only one file can be saved at a time.
|
|
51
|
+
*
|
|
52
|
+
* @group DocumentPicker
|
|
53
|
+
* */
|
|
54
|
+
export declare function saveDocuments(options: SaveDocumentsOptions): Promise<NonEmptyArray<SaveDocumentsResponse>>;
|
|
55
|
+
//# sourceMappingURL=saveDocuments.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"saveDocuments.d.ts","sourceRoot":"","sources":["../../src/saveDocuments.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAA0B,aAAa,EAAE,MAAM,SAAS,CAAA;AAGpE;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC;;SAEK;IACL,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB;;;SAGK;IACL,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;;SAGK;IACL,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;;SAGK;IACL,IAAI,CAAC,EAAE,OAAO,CAAA;CAEf,CAAA;AAED;;;;GAIG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC;;SAEK;IACL,GAAG,EAAE,MAAM,CAAA;IACX;;SAEK;IACL,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB;;SAEK;IACL,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CAQrB,CAAA;AAED;;;;;;KAMK;AACL,wBAAsB,aAAa,CACjC,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC,CAmB/C"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { TurboModule } from 'react-native';
|
|
2
|
+
import { DocumentPickerResponse } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Indicates, for each Uri that was passed to {@link keepLocalCopy}, whether the local copy was successfully created or not.
|
|
5
|
+
*
|
|
6
|
+
* If the copy was successful, the status field is `success` and `localUri` contains the local Uri.
|
|
7
|
+
* If the copy was not successful, the status field is `error` and `copyError` field contains the error message.
|
|
8
|
+
* */
|
|
9
|
+
export type LocalCopyResponse = {
|
|
10
|
+
status: 'success';
|
|
11
|
+
sourceUri: string;
|
|
12
|
+
localUri: string;
|
|
13
|
+
} | {
|
|
14
|
+
status: 'error';
|
|
15
|
+
sourceUri: string;
|
|
16
|
+
copyError: string;
|
|
17
|
+
};
|
|
18
|
+
export interface Spec extends TurboModule {
|
|
19
|
+
pick(options: Object): Promise<DocumentPickerResponse[]>;
|
|
20
|
+
saveDocument(options: Object): Promise<Object>;
|
|
21
|
+
writeDocuments(options: Object): Promise<Object[]>;
|
|
22
|
+
pickDirectory(options: Object): Promise<Object>;
|
|
23
|
+
keepLocalCopy(options: Object): Promise<LocalCopyResponse[]>;
|
|
24
|
+
isKnownType(kind: string, value: string): Object;
|
|
25
|
+
releaseSecureAccess(uris: string[]): Promise<null>;
|
|
26
|
+
releaseLongTermAccess(uris: string[]): Promise<Object>;
|
|
27
|
+
}
|
|
28
|
+
export declare const NativeDocumentPicker: Spec;
|
|
29
|
+
//# sourceMappingURL=NativeDocumentPicker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NativeDocumentPicker.d.ts","sourceRoot":"","sources":["../../../src/spec/NativeDocumentPicker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAE/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AAEjD;;;;;KAKK;AACL,MAAM,MAAM,iBAAiB,GACzB;IACE,MAAM,EAAE,SAAS,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;CACjB,GACD;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAA;AAE7D,MAAM,WAAW,IAAK,SAAQ,WAAW;IAEvC,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,EAAE,CAAC,CAAA;IACxD,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IAC9C,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;IAClD,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IAC/C,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAA;IAC5D,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;IAChD,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAClD,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;CACvD;AAED,eAAO,MAAM,oBAAoB,MAA6D,CAAA"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
export type NonEmptyArray<T> = [T, ...Array<T>];
|
|
2
|
+
import type { ModalPropsIOS } from 'react-native';
|
|
3
|
+
/**
|
|
4
|
+
* If you've requested long-term access to a directory or file, this object will be returned in the response.
|
|
5
|
+
* In order to access the same directory or file in the future, you must store the `bookmark` opaque string,
|
|
6
|
+
* and then pass it to the document viewer if you want to preview the file.
|
|
7
|
+
*
|
|
8
|
+
* See the Document viewer source on how to retrieve the file from the bookmark, if you need to do that (advanced use case).
|
|
9
|
+
* */
|
|
10
|
+
export type BookmarkingResponse = {
|
|
11
|
+
bookmarkStatus: 'success';
|
|
12
|
+
bookmark: string;
|
|
13
|
+
} | {
|
|
14
|
+
bookmarkStatus: 'error';
|
|
15
|
+
bookmarkError: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* @group pick() types
|
|
19
|
+
*/
|
|
20
|
+
export type VirtualFileMeta = {
|
|
21
|
+
/**
|
|
22
|
+
* The registered extension for the given MIME type. Note that some MIME types map to multiple extensions.
|
|
23
|
+
*
|
|
24
|
+
* This call will return the most common extension for the given MIME type.
|
|
25
|
+
*
|
|
26
|
+
* Example: `pdf`
|
|
27
|
+
*/
|
|
28
|
+
extension: string | null;
|
|
29
|
+
/**
|
|
30
|
+
* The MIME type of the file. This is necessary to export the virtual file to a local file.
|
|
31
|
+
*
|
|
32
|
+
* Example: `application/pdf`
|
|
33
|
+
*/
|
|
34
|
+
mimeType: string;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* @group pick() types
|
|
38
|
+
*/
|
|
39
|
+
export type DocumentPickerResponse = {
|
|
40
|
+
/**
|
|
41
|
+
* The URI of the picked file. This is a percent-encoded `content://` uri (Android), or a `file://` uri (iOS).
|
|
42
|
+
* */
|
|
43
|
+
uri: string;
|
|
44
|
+
/**
|
|
45
|
+
* The name of the picked file, including the extension. It's very unlikely that it'd be `null` but in theory, it can happen.
|
|
46
|
+
* */
|
|
47
|
+
name: string | null;
|
|
48
|
+
/**
|
|
49
|
+
* Error in case the file metadata could not be obtained.
|
|
50
|
+
* */
|
|
51
|
+
error: string | null;
|
|
52
|
+
/**
|
|
53
|
+
* The MIME type of the picked file.
|
|
54
|
+
* */
|
|
55
|
+
type: string | null;
|
|
56
|
+
/**
|
|
57
|
+
* The "native" type of the picked file: on Android, this is the MIME type. On iOS, it is the UTType identifier.
|
|
58
|
+
* */
|
|
59
|
+
nativeType: string | null;
|
|
60
|
+
/**
|
|
61
|
+
* The size of the picked file in bytes.
|
|
62
|
+
* */
|
|
63
|
+
size: number | null;
|
|
64
|
+
/**
|
|
65
|
+
* Android: whether the file is a virtual file (such as Google docs or sheets). Will be `null` on pre-Android 7.0 devices. On iOS, it's always `false`.
|
|
66
|
+
* */
|
|
67
|
+
isVirtual: boolean | null;
|
|
68
|
+
/**
|
|
69
|
+
* Android: The target types the virtual file can be converted to. Useful for {@link keepLocalCopy}.
|
|
70
|
+
* This field is only present if `isVirtual` is true, and only on Android 7.0+. Always `null` on iOS.
|
|
71
|
+
* */
|
|
72
|
+
convertibleToMimeTypes: VirtualFileMeta[] | null;
|
|
73
|
+
/**
|
|
74
|
+
* Android: Some document providers on Android (especially those popular in Asia, it seems)
|
|
75
|
+
* do not respect the request for limiting selectable file types.
|
|
76
|
+
* `hasRequestedType` will be false if the user picked a file that does not have one of the requested types.
|
|
77
|
+
*
|
|
78
|
+
* You need to do your own post-processing and display an error to the user if this is important to your app.
|
|
79
|
+
*
|
|
80
|
+
* Always `true` on iOS.
|
|
81
|
+
* */
|
|
82
|
+
hasRequestedType: boolean;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* iOS only. Configure the transition style of the picker.
|
|
86
|
+
* */
|
|
87
|
+
export type TransitionStyle = 'coverVertical' | 'flipHorizontal' | 'crossDissolve' | 'partialCurl' | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* iOS only. Configure the presentation style of the picker.
|
|
90
|
+
* */
|
|
91
|
+
export type PresentationStyle = 'fullScreen' | 'pageSheet' | 'formSheet' | 'overFullScreen' | undefined;
|
|
92
|
+
type AreUnionsEqual<T, U> = [T] extends [U] ? ([U] extends [T] ? true : false) : false;
|
|
93
|
+
export declare const typesAreEqual: AreUnionsEqual<PresentationStyle, ModalPropsIOS['presentationStyle']>;
|
|
94
|
+
export {};
|
|
95
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAEjD;;;;;;KAMK;AACL,MAAM,MAAM,mBAAmB,GAC3B;IACE,cAAc,EAAE,SAAS,CAAA;IACzB,QAAQ,EAAE,MAAM,CAAA;CACjB,GACD;IACE,cAAc,EAAE,OAAO,CAAA;IACvB,aAAa,EAAE,MAAM,CAAA;CACtB,CAAA;AAEL;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B;;;;;;OAMG;IACH,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB;;;;OAIG;IACH,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC;;SAEK;IACL,GAAG,EAAE,MAAM,CAAA;IACX;;SAEK;IACL,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB;;SAEK;IACL,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB;;SAEK;IACL,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB;;SAEK;IACL,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB;;SAEK;IACL,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IAEnB;;SAEK;IACL,SAAS,EAAE,OAAO,GAAG,IAAI,CAAA;IACzB;;;SAGK;IACL,sBAAsB,EAAE,eAAe,EAAE,GAAG,IAAI,CAAA;IAEhD;;;;;;;;SAQK;IACL,gBAAgB,EAAE,OAAO,CAAA;CAC1B,CAAA;AAED;;KAEK;AACL,MAAM,MAAM,eAAe,GACvB,eAAe,GACf,gBAAgB,GAChB,eAAe,GACf,aAAa,GACb,SAAS,CAAA;AAEb;;KAEK;AACL,MAAM,MAAM,iBAAiB,GACzB,YAAY,GACZ,WAAW,GACX,WAAW,GACX,gBAAgB,GAChB,SAAS,CAAA;AAMb,KAAK,cAAc,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,KAAK,CAAC,GAAG,KAAK,CAAA;AAEtF,eAAO,MAAM,aAAa,EAAE,cAAc,CAAC,iBAAiB,EAAE,aAAa,CAAC,mBAAmB,CAAC,CAC1F,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateTypes.d.ts","sourceRoot":"","sources":["../../src/validateTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA;AAErD,eAAO,MAAM,YAAY,mBACP,MAAM,EAAE,oBACN,IAAI,CAAC,sBAAsB,EAAE,YAAY,CAAC,YAI7D,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@react-native-documents/picker",
|
|
3
|
+
"version": "9.3.1",
|
|
4
|
+
"description": "A react native interface to access documents from dropbox, google drive, iCloud...",
|
|
5
|
+
"main": "lib/commonjs/index",
|
|
6
|
+
"module": "lib/module/index",
|
|
7
|
+
"types": "lib/typescript/index.d.ts",
|
|
8
|
+
"react-native": "src/index",
|
|
9
|
+
"source": "src/index",
|
|
10
|
+
"files": [
|
|
11
|
+
"src",
|
|
12
|
+
"lib",
|
|
13
|
+
"android",
|
|
14
|
+
"ios",
|
|
15
|
+
"windows",
|
|
16
|
+
"cpp",
|
|
17
|
+
"LICENSE.md",
|
|
18
|
+
"react-native-document-picker.podspec",
|
|
19
|
+
"!lib/typescript/example",
|
|
20
|
+
"!android/build",
|
|
21
|
+
"!ios/build",
|
|
22
|
+
"!**/__tests__",
|
|
23
|
+
"!**/__fixtures__",
|
|
24
|
+
"!**/__mocks__",
|
|
25
|
+
"jest/build"
|
|
26
|
+
],
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build:mock": "tsc --build jest",
|
|
29
|
+
"prepare": "bob build && yarn build:mock",
|
|
30
|
+
"release": "yarn prepare && npx semantic-release"
|
|
31
|
+
},
|
|
32
|
+
"codegenConfig": {
|
|
33
|
+
"name": "rndocumentpickerCGen",
|
|
34
|
+
"type": "modules",
|
|
35
|
+
"jsSrcsDir": "src/spec",
|
|
36
|
+
"android": {
|
|
37
|
+
"javaPackageName": "com.reactnativedocumentpicker"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"keywords": [
|
|
41
|
+
"react-native",
|
|
42
|
+
"document",
|
|
43
|
+
"picker",
|
|
44
|
+
"uidocumentmenuviewcontroller",
|
|
45
|
+
"dropbox",
|
|
46
|
+
"google-drive",
|
|
47
|
+
"icloud"
|
|
48
|
+
],
|
|
49
|
+
"repository": {
|
|
50
|
+
"type": "git",
|
|
51
|
+
"url": "git+https://github.com/react-native-documents/document-picker.git"
|
|
52
|
+
},
|
|
53
|
+
"author": "Vojtech Novak (hello@react-native-training.eu)",
|
|
54
|
+
"license": "see LICENSE file",
|
|
55
|
+
"bugs": {
|
|
56
|
+
"url": "https://github.com/react-native-documents/document-picker/issues"
|
|
57
|
+
},
|
|
58
|
+
"homepage": "https://github.com/react-native-documents/document-picker#readme",
|
|
59
|
+
"publishConfig": {
|
|
60
|
+
"access": "public"
|
|
61
|
+
},
|
|
62
|
+
"devDependencies": {
|
|
63
|
+
"@tsconfig/node18": "^18.2.4",
|
|
64
|
+
"react-native-builder-bob": "^0.30.2",
|
|
65
|
+
"typescript": "^5.6.2"
|
|
66
|
+
},
|
|
67
|
+
"peerDependencies": {
|
|
68
|
+
"react": "*",
|
|
69
|
+
"react-native": "*"
|
|
70
|
+
},
|
|
71
|
+
"jest": {
|
|
72
|
+
"preset": "react-native",
|
|
73
|
+
"modulePathIgnorePatterns": [
|
|
74
|
+
"<rootDir>/lib/"
|
|
75
|
+
]
|
|
76
|
+
},
|
|
77
|
+
"react-native-builder-bob": {
|
|
78
|
+
"source": "src",
|
|
79
|
+
"output": "lib",
|
|
80
|
+
"targets": [
|
|
81
|
+
"commonjs",
|
|
82
|
+
"module",
|
|
83
|
+
[
|
|
84
|
+
"typescript",
|
|
85
|
+
{
|
|
86
|
+
"project": "tsconfig.build.json"
|
|
87
|
+
}
|
|
88
|
+
]
|
|
89
|
+
]
|
|
90
|
+
},
|
|
91
|
+
"packageManager": "yarn@4.5.1"
|
|
92
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = "react-native-document-picker"
|
|
7
|
+
s.version = package["version"]
|
|
8
|
+
s.summary = package["description"]
|
|
9
|
+
s.homepage = package["homepage"]
|
|
10
|
+
s.license = package["license"]
|
|
11
|
+
s.authors = package["author"]
|
|
12
|
+
|
|
13
|
+
s.platforms = { :ios => "14.0" }
|
|
14
|
+
s.source = { :git => "https://github.com/react-native-documents/sponsors-only.git", :tag => "v#{s.version}" }
|
|
15
|
+
|
|
16
|
+
s.source_files = ["ios/**/*.{h,m,mm,swift}"]
|
|
17
|
+
s.frameworks = 'MobileCoreServices'
|
|
18
|
+
|
|
19
|
+
# Swift/Objective-C compatibility
|
|
20
|
+
s.pod_target_xcconfig = {
|
|
21
|
+
'DEFINES_MODULE' => 'YES',
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
|
|
25
|
+
# RN 71+
|
|
26
|
+
install_modules_dependencies(s)
|
|
27
|
+
else
|
|
28
|
+
s.dependency "React-Core"
|
|
29
|
+
end
|
|
30
|
+
end
|
package/src/errors.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export interface NativeModuleError extends Error {
|
|
2
|
+
code: string
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
const OPERATION_CANCELED = 'OPERATION_CANCELED'
|
|
6
|
+
const IN_PROGRESS = 'ASYNC_OP_IN_PROGRESS'
|
|
7
|
+
const UNABLE_TO_OPEN_FILE_TYPE = 'UNABLE_TO_OPEN_FILE_TYPE'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Error codes that can be returned by the module, and are available on the `code` property of the error.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const handleError = (err: unknown) => {
|
|
15
|
+
* if (isErrorWithCode(err)) {
|
|
16
|
+
* switch (err.code) {
|
|
17
|
+
* case errorCodes.IN_PROGRESS:
|
|
18
|
+
* ...
|
|
19
|
+
* break
|
|
20
|
+
* case errorCodes.UNABLE_TO_OPEN_FILE_TYPE:
|
|
21
|
+
* ...
|
|
22
|
+
* break
|
|
23
|
+
* case errorCodes.OPERATION_CANCELED:
|
|
24
|
+
* // ignore
|
|
25
|
+
* break
|
|
26
|
+
* default:
|
|
27
|
+
* console.error(err)
|
|
28
|
+
* }
|
|
29
|
+
* } else {
|
|
30
|
+
* console.error(err)
|
|
31
|
+
* }
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
* */
|
|
35
|
+
export const errorCodes = Object.freeze({
|
|
36
|
+
OPERATION_CANCELED,
|
|
37
|
+
IN_PROGRESS,
|
|
38
|
+
UNABLE_TO_OPEN_FILE_TYPE,
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* TypeScript helper to check if an object has the `code` property.
|
|
43
|
+
* This is used to avoid `as` casting when you access the `code` property on errors returned by the module.
|
|
44
|
+
*/
|
|
45
|
+
export const isErrorWithCode = (error: any): error is NativeModuleError => {
|
|
46
|
+
// to account for https://github.com/facebook/react-native/issues/41950
|
|
47
|
+
const isNewArchErrorIOS = typeof error === 'object' && error != null
|
|
48
|
+
return (error instanceof Error || isNewArchErrorIOS) && 'code' in error
|
|
49
|
+
}
|