@react-native-documents/picker 12.0.3 → 12.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Package.swift +115 -0
- package/package.json +7 -1
- package/spm-headers/converter-public/RCTConvert+RNDocumentPicker.h +1 -0
- package/spm-headers/public/module.modulemap +3 -0
- package/spm-headers/react_native_document_picker-Swift.h +39 -0
- package/spm-support/Imports.swift +2 -0
- package/spm-support/SwiftHeaderPin.swift +64 -0
package/Package.swift
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// swift-tools-version: 6.0
|
|
2
|
+
|
|
3
|
+
import Foundation
|
|
4
|
+
import PackageDescription
|
|
5
|
+
|
|
6
|
+
// React Native evaluates this package through build/generated/autolinking/libs/.
|
|
7
|
+
let reactHeaders: [Target.Dependency] = [
|
|
8
|
+
.product(name: "ReactHeaders", package: "ReactNative"),
|
|
9
|
+
.product(name: "ReactNativeHeaders", package: "ReactNative"),
|
|
10
|
+
.product(name: "ReactNativeDependenciesHeaders", package: "ReactNative"),
|
|
11
|
+
.product(name: "ReactAppHeaders", package: "React-GeneratedCode"),
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
// Root targets at "." while excluding all unrelated npm/repository contents.
|
|
15
|
+
let usedRootEntries: Set<String> = ["ios", "spm-headers", "spm-support", "Package.swift"]
|
|
16
|
+
let unusedRootEntries = try! FileManager.default.contentsOfDirectory(atPath: Context.packageDirectory)
|
|
17
|
+
.filter { !usedRootEntries.contains($0) }
|
|
18
|
+
.sorted()
|
|
19
|
+
|
|
20
|
+
let iosDirectory = URL(fileURLWithPath: Context.packageDirectory).appendingPathComponent("ios")
|
|
21
|
+
let iosEntries = try! FileManager.default.subpathsOfDirectory(atPath: iosDirectory.path)
|
|
22
|
+
.filter { !$0.contains(".xcodeproj/") }
|
|
23
|
+
|
|
24
|
+
func unusedIosEntries(keeping kept: Set<String>) -> [String] {
|
|
25
|
+
iosEntries.filter { entry in
|
|
26
|
+
let url = iosDirectory.appendingPathComponent(entry)
|
|
27
|
+
if url.pathExtension == "xcodeproj" { return true }
|
|
28
|
+
let isFile = try! url.resourceValues(forKeys: [.isRegularFileKey]).isRegularFile == true
|
|
29
|
+
return isFile && !kept.contains(entry)
|
|
30
|
+
}
|
|
31
|
+
.map { "ios/" + $0 }
|
|
32
|
+
.sorted()
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
let swiftIosEntries = Set(iosEntries.filter { $0.hasPrefix("swift/") && $0.hasSuffix(".swift") })
|
|
36
|
+
let converterIosEntries: Set<String> = [
|
|
37
|
+
"RCTConvert+RNDocumentPicker.h",
|
|
38
|
+
"RCTConvert+RNDocumentPicker.mm",
|
|
39
|
+
]
|
|
40
|
+
let moduleIosEntries: Set<String> = [
|
|
41
|
+
"RNDocumentPicker.h",
|
|
42
|
+
"RNDocumentPicker.mm",
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
let package = Package(
|
|
46
|
+
name: "react_native_document_picker",
|
|
47
|
+
platforms: [.iOS("15.1")],
|
|
48
|
+
products: [
|
|
49
|
+
.library(
|
|
50
|
+
name: "react_native_document_picker",
|
|
51
|
+
targets: [
|
|
52
|
+
"react_native_document_picker",
|
|
53
|
+
"RNDocumentPickerConvert",
|
|
54
|
+
"RNDocumentPickerObjC",
|
|
55
|
+
]
|
|
56
|
+
),
|
|
57
|
+
],
|
|
58
|
+
dependencies: [
|
|
59
|
+
.package(name: "ReactNative", path: "../../../../xcframeworks"),
|
|
60
|
+
.package(name: "React-GeneratedCode", path: "../../../ios"),
|
|
61
|
+
],
|
|
62
|
+
targets: [
|
|
63
|
+
// PickerOptions needs this custom RCTConvert category as a Clang module.
|
|
64
|
+
.target(
|
|
65
|
+
name: "RNDocumentPickerConvert",
|
|
66
|
+
dependencies: reactHeaders,
|
|
67
|
+
path: ".",
|
|
68
|
+
exclude: unusedRootEntries
|
|
69
|
+
+ ["spm-support", "spm-headers/public", "spm-headers/react_native_document_picker-Swift.h"]
|
|
70
|
+
+ unusedIosEntries(keeping: converterIosEntries),
|
|
71
|
+
sources: ["ios/RCTConvert+RNDocumentPicker.mm"],
|
|
72
|
+
publicHeadersPath: "spm-headers/converter-public",
|
|
73
|
+
cSettings: [
|
|
74
|
+
.define("RCT_NEW_ARCH_ENABLED", to: "1"),
|
|
75
|
+
],
|
|
76
|
+
cxxSettings: [
|
|
77
|
+
.define("RCT_NEW_ARCH_ENABLED", to: "1"),
|
|
78
|
+
]
|
|
79
|
+
),
|
|
80
|
+
// Preserve CocoaPods' normalized Swift module name. The ObjC++ bridge
|
|
81
|
+
// depends on Swift, avoiding a target dependency cycle.
|
|
82
|
+
.target(
|
|
83
|
+
name: "react_native_document_picker",
|
|
84
|
+
dependencies: ["RNDocumentPickerConvert"] + reactHeaders,
|
|
85
|
+
path: ".",
|
|
86
|
+
exclude: unusedRootEntries
|
|
87
|
+
+ ["spm-headers"]
|
|
88
|
+
+ unusedIosEntries(keeping: swiftIosEntries),
|
|
89
|
+
sources: ["ios/swift", "spm-support"]
|
|
90
|
+
),
|
|
91
|
+
.target(
|
|
92
|
+
name: "RNDocumentPickerObjC",
|
|
93
|
+
dependencies: [
|
|
94
|
+
"react_native_document_picker",
|
|
95
|
+
"RNDocumentPickerConvert",
|
|
96
|
+
] + reactHeaders,
|
|
97
|
+
path: ".",
|
|
98
|
+
exclude: unusedRootEntries
|
|
99
|
+
+ ["spm-support", "spm-headers/converter-public"]
|
|
100
|
+
+ unusedIosEntries(keeping: moduleIosEntries),
|
|
101
|
+
sources: ["ios/RNDocumentPicker.mm"],
|
|
102
|
+
publicHeadersPath: "spm-headers/public",
|
|
103
|
+
cSettings: [
|
|
104
|
+
.define("RCT_NEW_ARCH_ENABLED", to: "1"),
|
|
105
|
+
.headerSearchPath("spm-headers"),
|
|
106
|
+
],
|
|
107
|
+
cxxSettings: [
|
|
108
|
+
.define("RCT_NEW_ARCH_ENABLED", to: "1"),
|
|
109
|
+
.headerSearchPath("spm-headers"),
|
|
110
|
+
]
|
|
111
|
+
),
|
|
112
|
+
],
|
|
113
|
+
swiftLanguageModes: [.v6],
|
|
114
|
+
cxxLanguageStandard: .cxx20
|
|
115
|
+
)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-documents/picker",
|
|
3
|
-
"version": "12.0
|
|
3
|
+
"version": "12.1.0",
|
|
4
4
|
"description": "A react native interface to access documents from dropbox, google drive, iCloud...",
|
|
5
5
|
"funding": "https://github.com/react-native-documents/document-picker?sponsor=1",
|
|
6
6
|
"main": "./lib/module/index.js",
|
|
@@ -18,6 +18,9 @@
|
|
|
18
18
|
"lib",
|
|
19
19
|
"android",
|
|
20
20
|
"ios",
|
|
21
|
+
"Package.swift",
|
|
22
|
+
"spm-headers",
|
|
23
|
+
"spm-support",
|
|
21
24
|
"windows",
|
|
22
25
|
"cpp",
|
|
23
26
|
"LICENSE.md",
|
|
@@ -74,6 +77,9 @@
|
|
|
74
77
|
"react": "*",
|
|
75
78
|
"react-native": ">=0.79.0"
|
|
76
79
|
},
|
|
80
|
+
"swiftpmConfig": {
|
|
81
|
+
"name": "react_native_document_picker"
|
|
82
|
+
},
|
|
77
83
|
"jest": {
|
|
78
84
|
"preset": "react-native",
|
|
79
85
|
"modulePathIgnorePatterns": [
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#import "../../ios/RCTConvert+RNDocumentPicker.h"
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Private SwiftPM declarations used by RNDocumentPicker.mm. Keep this narrow
|
|
2
|
+
// interface in sync with the @objc APIs pinned by SwiftHeaderPin.swift.
|
|
3
|
+
#pragma once
|
|
4
|
+
|
|
5
|
+
#import <Foundation/Foundation.h>
|
|
6
|
+
#import <React/RCTBridgeModule.h>
|
|
7
|
+
|
|
8
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
9
|
+
|
|
10
|
+
__attribute__((objc_runtime_name("_TtC28react_native_document_picker9DocPicker")))
|
|
11
|
+
@interface DocPicker : NSObject
|
|
12
|
+
- (instancetype)init;
|
|
13
|
+
- (void)presentWithOptionsDict:(NSDictionary *)optionsDict
|
|
14
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
15
|
+
reject:(RCTPromiseRejectBlock)reject;
|
|
16
|
+
- (void)stopAccessingOpenedUrls:(NSArray<NSString *> *)urlStrings;
|
|
17
|
+
@end
|
|
18
|
+
|
|
19
|
+
__attribute__((objc_runtime_name("_TtC28react_native_document_picker8DocSaver")))
|
|
20
|
+
@interface DocSaver : NSObject
|
|
21
|
+
- (instancetype)init;
|
|
22
|
+
- (void)presentWithOptionsDict:(NSDictionary *)optionsDict
|
|
23
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
24
|
+
reject:(RCTPromiseRejectBlock)reject;
|
|
25
|
+
@end
|
|
26
|
+
|
|
27
|
+
__attribute__((objc_runtime_name("_TtC28react_native_document_picker14FileOperations")))
|
|
28
|
+
@interface FileOperations : NSObject
|
|
29
|
+
+ (void)keepLocalCopyAtUniqueDestinationFrom:(NSArray<NSDictionary<NSString *, NSString *> *> *)files
|
|
30
|
+
destinationPreset:(NSString *)destinationPreset
|
|
31
|
+
resolve:(RCTPromiseResolveBlock)resolve;
|
|
32
|
+
@end
|
|
33
|
+
|
|
34
|
+
__attribute__((objc_runtime_name("_TtC28react_native_document_picker15IsKnownTypeImpl")))
|
|
35
|
+
@interface IsKnownTypeImpl : NSObject
|
|
36
|
+
+ (NSDictionary<NSString *, id> *)checkType:(NSString *)kind value:(NSString *)value;
|
|
37
|
+
@end
|
|
38
|
+
|
|
39
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// Pins the Swift API mirrored by
|
|
2
|
+
// spm-headers/react_native_document_picker-Swift.h. If this file fails to
|
|
3
|
+
// compile, update both files together.
|
|
4
|
+
import React
|
|
5
|
+
|
|
6
|
+
private let _docPickerType: NSObject.Type = DocPicker.self
|
|
7
|
+
private let _docSaverType: NSObject.Type = DocSaver.self
|
|
8
|
+
private let _fileOperationsType: NSObject.Type = FileOperations.self
|
|
9
|
+
private let _isKnownTypeType: NSObject.Type = IsKnownTypeImpl.self
|
|
10
|
+
private let _docPickerBase: PickerBase.Type = DocPicker.self
|
|
11
|
+
private let _docSaverBase: PickerBase.Type = DocSaver.self
|
|
12
|
+
|
|
13
|
+
// Swift cannot validate Objective-C nullability/lightweight generics or the
|
|
14
|
+
// generated class runtime names. Calls pin types; selectors pin method names.
|
|
15
|
+
@MainActor
|
|
16
|
+
private func _pinDocPickerPresent(
|
|
17
|
+
_ picker: DocPicker,
|
|
18
|
+
options: NSDictionary,
|
|
19
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
20
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
21
|
+
) {
|
|
22
|
+
picker.present(optionsDict: options, resolve: resolve, reject: reject)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@MainActor
|
|
26
|
+
private func _pinStopAccessing(_ picker: DocPicker, urls: [String]) {
|
|
27
|
+
picker.stopAccessingOpenedUrls(urls)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@MainActor
|
|
31
|
+
private func _pinDocSaverPresent(
|
|
32
|
+
_ saver: DocSaver,
|
|
33
|
+
options: NSDictionary,
|
|
34
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
35
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
36
|
+
) {
|
|
37
|
+
saver.present(optionsDict: options, resolve: resolve, reject: reject)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
private func _pinKeepLocalCopy(
|
|
41
|
+
files: [[String: String]],
|
|
42
|
+
destination: String,
|
|
43
|
+
resolve: @escaping RCTPromiseResolveBlock
|
|
44
|
+
) {
|
|
45
|
+
FileOperations.keepLocalCopyAtUniqueDestination(
|
|
46
|
+
from: files,
|
|
47
|
+
destinationPreset: destination,
|
|
48
|
+
resolve: resolve
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
private func _pinCheckType(_ kind: String, value: String) -> [String: Any] {
|
|
53
|
+
IsKnownTypeImpl.checkType(kind, value: value)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
private let _swiftHeaderSelectors: [Selector] = [
|
|
57
|
+
#selector(DocPicker.init),
|
|
58
|
+
#selector(DocPicker.present(optionsDict:resolve:reject:)),
|
|
59
|
+
#selector(DocPicker.stopAccessingOpenedUrls(_:)),
|
|
60
|
+
#selector(DocSaver.init),
|
|
61
|
+
#selector(DocSaver.present(optionsDict:resolve:reject:)),
|
|
62
|
+
#selector(FileOperations.keepLocalCopyAtUniqueDestination(from:destinationPreset:resolve:)),
|
|
63
|
+
#selector(IsKnownTypeImpl.checkType(_:value:)),
|
|
64
|
+
]
|