react-native-cloud-storage 2.3.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/android/build.gradle +1 -14
- package/android/src/main/java/com/voicekit/CloudStorageLocalFileSystemModule.kt +16 -20
- package/android/src/main/java/com/voicekit/CloudStoragePackage.kt +23 -8
- package/dist/commonjs/cloud-storage.js +68 -31
- package/dist/commonjs/cloud-storage.js.map +1 -1
- package/dist/commonjs/specs/NativeCloudStorageCloudKitIOS.js +9 -0
- package/dist/commonjs/specs/NativeCloudStorageCloudKitIOS.js.map +1 -0
- package/dist/commonjs/specs/NativeCloudStorageLocalFileSystem.js +9 -0
- package/dist/commonjs/specs/NativeCloudStorageLocalFileSystem.js.map +1 -0
- package/dist/commonjs/storages/cloudkit.js +5 -3
- package/dist/commonjs/storages/cloudkit.js.map +1 -1
- package/dist/commonjs/storages/google-drive/client.js +3 -2
- package/dist/commonjs/storages/google-drive/client.js.map +1 -1
- package/dist/commonjs/storages/google-drive/index.js +99 -77
- package/dist/commonjs/storages/google-drive/index.js.map +1 -1
- package/dist/commonjs/types/main.js +18 -1
- package/dist/commonjs/types/main.js.map +1 -1
- package/dist/commonjs/utils/constants.js +2 -1
- package/dist/commonjs/utils/constants.js.map +1 -1
- package/dist/commonjs/utils/local-fs.js +3 -2
- package/dist/commonjs/utils/local-fs.js.map +1 -1
- package/dist/commonjs/utils/native.js.map +1 -1
- package/dist/module/cloud-storage.js +70 -33
- package/dist/module/cloud-storage.js.map +1 -1
- package/dist/module/specs/NativeCloudStorageCloudKitIOS.js +5 -0
- package/dist/module/specs/NativeCloudStorageCloudKitIOS.js.map +1 -0
- package/dist/module/specs/NativeCloudStorageLocalFileSystem.js +5 -0
- package/dist/module/specs/NativeCloudStorageLocalFileSystem.js.map +1 -0
- package/dist/module/storages/cloudkit.js +3 -2
- package/dist/module/storages/cloudkit.js.map +1 -1
- package/dist/module/storages/google-drive/client.js +3 -2
- package/dist/module/storages/google-drive/client.js.map +1 -1
- package/dist/module/storages/google-drive/index.js +99 -77
- package/dist/module/storages/google-drive/index.js.map +1 -1
- package/dist/module/types/main.js +21 -1
- package/dist/module/types/main.js.map +1 -1
- package/dist/module/utils/constants.js +2 -1
- package/dist/module/utils/constants.js.map +1 -1
- package/dist/module/utils/local-fs.js +2 -2
- package/dist/module/utils/local-fs.js.map +1 -1
- package/dist/module/utils/native.js.map +1 -1
- package/dist/typescript/cloud-storage.d.ts +15 -6
- package/dist/typescript/cloud-storage.d.ts.map +1 -1
- package/dist/typescript/specs/NativeCloudStorageCloudKitIOS.d.ts +30 -0
- package/dist/typescript/specs/NativeCloudStorageCloudKitIOS.d.ts.map +1 -0
- package/dist/typescript/specs/NativeCloudStorageLocalFileSystem.d.ts +24 -0
- package/dist/typescript/specs/NativeCloudStorageLocalFileSystem.d.ts.map +1 -0
- package/dist/typescript/storages/cloudkit.d.ts +3 -0
- package/dist/typescript/storages/cloudkit.d.ts.map +1 -1
- package/dist/typescript/storages/google-drive/client.d.ts +1 -1
- package/dist/typescript/storages/google-drive/client.d.ts.map +1 -1
- package/dist/typescript/storages/google-drive/index.d.ts +7 -1
- package/dist/typescript/storages/google-drive/index.d.ts.map +1 -1
- package/dist/typescript/types/main.d.ts +27 -0
- package/dist/typescript/types/main.d.ts.map +1 -1
- package/dist/typescript/types/native.d.ts +6 -43
- package/dist/typescript/types/native.d.ts.map +1 -1
- package/dist/typescript/utils/constants.d.ts.map +1 -1
- package/dist/typescript/utils/local-fs.d.ts +1 -2
- package/dist/typescript/utils/local-fs.d.ts.map +1 -1
- package/dist/typescript/utils/native.d.ts +1 -1
- package/dist/typescript/utils/native.d.ts.map +1 -1
- package/ios/CloudStorage-Bridging-Header.h +0 -1
- package/ios/CloudStorageCloudKit.swift +15 -14
- package/ios/CloudStorageLocalFileSystem.swift +7 -6
- package/ios/RCTCloudStorageCloudKit.mm +218 -0
- package/ios/RCTCloudStorageLocalFileSystem.mm +149 -0
- package/ios/Utils/CloudKitUtils.swift +8 -2
- package/ios/Utils/FileUtils.swift +2 -4
- package/ios/Utils/Promise.swift +1 -0
- package/ios/Utils/Types.swift +1 -0
- package/ios/react_native_cloud_storage.h +6 -0
- package/package.json +31 -17
- package/react-native-cloud-storage.podspec +2 -0
- package/src/cloud-storage.ts +98 -50
- package/src/specs/NativeCloudStorageCloudKitIOS.ts +33 -0
- package/src/specs/NativeCloudStorageLocalFileSystem.ts +28 -0
- package/src/storages/cloudkit.ts +10 -2
- package/src/storages/google-drive/client.ts +2 -1
- package/src/storages/google-drive/index.ts +126 -120
- package/src/types/main.ts +29 -1
- package/src/types/native.ts +10 -54
- package/src/utils/constants.ts +1 -0
- package/src/utils/local-fs.ts +2 -2
- package/src/utils/native.ts +1 -1
- package/ios/CloudStorageCloudKit.m +0 -24
- package/ios/CloudStorageEventEmitter.m +0 -16
- package/ios/CloudStorageEventEmitter.swift +0 -30
- package/ios/CloudStorageLocalFileSystem.m +0 -15
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
#import <Foundation/Foundation.h>
|
|
2
|
+
|
|
3
|
+
#import <CloudStorageSpec/CloudStorageSpec.h>
|
|
4
|
+
|
|
5
|
+
#if __has_include("react_native_cloud_storage-Swift.h")
|
|
6
|
+
#import "react_native_cloud_storage-Swift.h"
|
|
7
|
+
#elif __has_include(<react_native_cloud_storage/react_native_cloud_storage-Swift.h>)
|
|
8
|
+
#import <react_native_cloud_storage/react_native_cloud_storage-Swift.h>
|
|
9
|
+
#else
|
|
10
|
+
#error "Unable to locate Swift compatibility header for react-native-cloud-storage."
|
|
11
|
+
#endif
|
|
12
|
+
|
|
13
|
+
@interface RCTCloudStorageCloudKit : NativeCloudStorageCloudKitIOSSpecBase <NativeCloudStorageCloudKitIOSSpec>
|
|
14
|
+
@end
|
|
15
|
+
|
|
16
|
+
@implementation RCTCloudStorageCloudKit {
|
|
17
|
+
CloudStorageCloudKit *_cloudStorageCloudKit;
|
|
18
|
+
id<NSObject> _ubiquityIdentityObserver;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
+ (NSString *)moduleName
|
|
22
|
+
{
|
|
23
|
+
return @"CloudStorageCloudKit";
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
+ (BOOL)requiresMainQueueSetup
|
|
27
|
+
{
|
|
28
|
+
return NO;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
- (instancetype)init
|
|
32
|
+
{
|
|
33
|
+
if (self = [super init]) {
|
|
34
|
+
_cloudStorageCloudKit = [CloudStorageCloudKit new];
|
|
35
|
+
// The ubiquity-identity observer is installed in -setEventEmitterCallback:
|
|
36
|
+
// rather than here, so it can only fire after the codegen event emitter's
|
|
37
|
+
// std::function has been bound. Otherwise a notification posted by iOS
|
|
38
|
+
// between -init and -setEventEmitterCallback: would invoke an empty
|
|
39
|
+
// std::function and crash the process with std::bad_function_call.
|
|
40
|
+
// See: https://github.com/kuatsu/react-native-cloud-storage/issues/59
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return self;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
- (void)dealloc
|
|
47
|
+
{
|
|
48
|
+
if (_ubiquityIdentityObserver != nil) {
|
|
49
|
+
[[NSNotificationCenter defaultCenter] removeObserver:_ubiquityIdentityObserver];
|
|
50
|
+
_ubiquityIdentityObserver = nil;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
- (void)setEventEmitterCallback:(EventEmitterCallbackWrapper *)eventEmitterCallbackWrapper
|
|
55
|
+
{
|
|
56
|
+
[super setEventEmitterCallback:eventEmitterCallbackWrapper];
|
|
57
|
+
|
|
58
|
+
if (_ubiquityIdentityObserver == nil) {
|
|
59
|
+
__weak __typeof__(self) weakSelf = self;
|
|
60
|
+
_ubiquityIdentityObserver = [[NSNotificationCenter defaultCenter]
|
|
61
|
+
addObserverForName:NSUbiquityIdentityDidChangeNotification
|
|
62
|
+
object:nil
|
|
63
|
+
queue:nil
|
|
64
|
+
usingBlock:^(__unused NSNotification *notification) {
|
|
65
|
+
__strong __typeof__(weakSelf) strongSelf = weakSelf;
|
|
66
|
+
[strongSelf emitCloudAvailabilityChanged];
|
|
67
|
+
}];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
[self emitCloudAvailabilityChanged];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
- (void)emitCloudAvailabilityChanged
|
|
74
|
+
{
|
|
75
|
+
BOOL isCloudAvailable = [NSFileManager defaultManager].ubiquityIdentityToken != nil;
|
|
76
|
+
[self emitOnCloudAvailabilityChanged:@{ @"available" : @(isCloudAvailable) }];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
- (void)fileExists:(NSString *)path
|
|
80
|
+
scope:(NSString *)scope
|
|
81
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
82
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
83
|
+
{
|
|
84
|
+
[_cloudStorageCloudKit fileExists:path withScope:scope withResolver:resolve withRejecter:reject];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
- (void)appendToFile:(NSString *)path
|
|
88
|
+
data:(NSString *)data
|
|
89
|
+
scope:(NSString *)scope
|
|
90
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
91
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
92
|
+
{
|
|
93
|
+
[_cloudStorageCloudKit appendToFile:path withData:data withScope:scope withResolver:resolve withRejecter:reject];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
- (void)createFile:(NSString *)path
|
|
97
|
+
data:(NSString *)data
|
|
98
|
+
scope:(NSString *)scope
|
|
99
|
+
overwrite:(BOOL)overwrite
|
|
100
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
101
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
102
|
+
{
|
|
103
|
+
[_cloudStorageCloudKit
|
|
104
|
+
createFile:path
|
|
105
|
+
withData:data
|
|
106
|
+
withScope:scope
|
|
107
|
+
withOverwrite:overwrite
|
|
108
|
+
withResolver:resolve
|
|
109
|
+
withRejecter:reject];
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
- (void)createDirectory:(NSString *)path
|
|
113
|
+
scope:(NSString *)scope
|
|
114
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
115
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
116
|
+
{
|
|
117
|
+
[_cloudStorageCloudKit createDirectory:path withScope:scope withResolver:resolve withRejecter:reject];
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
- (void)listFiles:(NSString *)path
|
|
121
|
+
scope:(NSString *)scope
|
|
122
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
123
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
124
|
+
{
|
|
125
|
+
[_cloudStorageCloudKit listFiles:path withScope:scope withResolver:resolve withRejecter:reject];
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
- (void)readFile:(NSString *)path
|
|
129
|
+
scope:(NSString *)scope
|
|
130
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
131
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
132
|
+
{
|
|
133
|
+
[_cloudStorageCloudKit readFile:path withScope:scope withResolver:resolve withRejecter:reject];
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
- (void)triggerSync:(NSString *)path
|
|
137
|
+
scope:(NSString *)scope
|
|
138
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
139
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
140
|
+
{
|
|
141
|
+
[_cloudStorageCloudKit triggerSync:path withScope:scope withResolver:resolve withRejecter:reject];
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
- (void)deleteFile:(NSString *)path
|
|
145
|
+
scope:(NSString *)scope
|
|
146
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
147
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
148
|
+
{
|
|
149
|
+
[_cloudStorageCloudKit deleteFile:path withScope:scope withResolver:resolve withRejecter:reject];
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
- (void)deleteDirectory:(NSString *)path
|
|
153
|
+
recursive:(BOOL)recursive
|
|
154
|
+
scope:(NSString *)scope
|
|
155
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
156
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
157
|
+
{
|
|
158
|
+
[_cloudStorageCloudKit
|
|
159
|
+
deleteDirectory:path
|
|
160
|
+
withRecursive:recursive
|
|
161
|
+
withScope:scope
|
|
162
|
+
withResolver:resolve
|
|
163
|
+
withRejecter:reject];
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
- (void)statFile:(NSString *)path
|
|
167
|
+
scope:(NSString *)scope
|
|
168
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
169
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
170
|
+
{
|
|
171
|
+
[_cloudStorageCloudKit statFile:path withScope:scope withResolver:resolve withRejecter:reject];
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
- (void)downloadFile:(NSString *)remotePath
|
|
175
|
+
localPath:(NSString *)localPath
|
|
176
|
+
scope:(NSString *)scope
|
|
177
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
178
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
179
|
+
{
|
|
180
|
+
[_cloudStorageCloudKit
|
|
181
|
+
downloadFile:remotePath
|
|
182
|
+
withLocalPath:localPath
|
|
183
|
+
withScope:scope
|
|
184
|
+
withResolver:resolve
|
|
185
|
+
withRejecter:reject];
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
- (void)uploadFile:(NSString *)remotePath
|
|
189
|
+
localPath:(NSString *)localPath
|
|
190
|
+
mimeType:(NSString *)mimeType
|
|
191
|
+
scope:(NSString *)scope
|
|
192
|
+
overwrite:(BOOL)overwrite
|
|
193
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
194
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
195
|
+
{
|
|
196
|
+
[_cloudStorageCloudKit
|
|
197
|
+
uploadFile:remotePath
|
|
198
|
+
withLocalPath:localPath
|
|
199
|
+
withMimeType:mimeType
|
|
200
|
+
withScope:scope
|
|
201
|
+
withOverwrite:overwrite
|
|
202
|
+
withResolver:resolve
|
|
203
|
+
withRejecter:reject];
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
- (void)isCloudAvailable:(RCTPromiseResolveBlock)resolve
|
|
207
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
208
|
+
{
|
|
209
|
+
[_cloudStorageCloudKit isCloudAvailable:resolve withRejecter:reject];
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
213
|
+
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
214
|
+
{
|
|
215
|
+
return std::make_shared<facebook::react::NativeCloudStorageCloudKitIOSSpecJSI>(params);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
@end
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
#import <Foundation/Foundation.h>
|
|
2
|
+
|
|
3
|
+
#import <CloudStorageSpec/CloudStorageSpec.h>
|
|
4
|
+
|
|
5
|
+
#if __has_include("react_native_cloud_storage-Swift.h")
|
|
6
|
+
#import "react_native_cloud_storage-Swift.h"
|
|
7
|
+
#elif __has_include(<react_native_cloud_storage/react_native_cloud_storage-Swift.h>)
|
|
8
|
+
#import <react_native_cloud_storage/react_native_cloud_storage-Swift.h>
|
|
9
|
+
#else
|
|
10
|
+
#error "Unable to locate Swift compatibility header for react-native-cloud-storage."
|
|
11
|
+
#endif
|
|
12
|
+
|
|
13
|
+
@interface RCTCloudStorageLocalFileSystem : NSObject <NativeCloudStorageLocalFileSystemSpec>
|
|
14
|
+
@end
|
|
15
|
+
|
|
16
|
+
@implementation RCTCloudStorageLocalFileSystem {
|
|
17
|
+
CloudStorageLocalFileSystem *_cloudStorageLocalFileSystem;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
+ (NSString *)moduleName
|
|
21
|
+
{
|
|
22
|
+
return @"CloudStorageLocalFileSystem";
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
+ (BOOL)requiresMainQueueSetup
|
|
26
|
+
{
|
|
27
|
+
return NO;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
- (instancetype)init
|
|
31
|
+
{
|
|
32
|
+
if (self = [super init]) {
|
|
33
|
+
_cloudStorageLocalFileSystem = [CloudStorageLocalFileSystem new];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return self;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
- (NSDictionary<NSString *, id> *)serializeDownloadOptions:
|
|
40
|
+
(JS::NativeCloudStorageLocalFileSystem::LocalFileSystemDownloadOptions &)options
|
|
41
|
+
{
|
|
42
|
+
NSMutableDictionary<NSString *, id> *serializedOptions = [NSMutableDictionary new];
|
|
43
|
+
|
|
44
|
+
id<NSObject> headers = options.headers();
|
|
45
|
+
if (headers != nil) {
|
|
46
|
+
serializedOptions[@"headers"] = headers;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return serializedOptions;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
- (NSDictionary<NSString *, id> *)serializeUploadOptions:
|
|
53
|
+
(JS::NativeCloudStorageLocalFileSystem::LocalFileSystemUploadOptions &)options
|
|
54
|
+
{
|
|
55
|
+
NSMutableDictionary<NSString *, id> *serializedOptions = [NSMutableDictionary new];
|
|
56
|
+
|
|
57
|
+
id<NSObject> headers = options.headers();
|
|
58
|
+
if (headers != nil) {
|
|
59
|
+
serializedOptions[@"headers"] = headers;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
NSString *method = options.method();
|
|
63
|
+
if (method != nil) {
|
|
64
|
+
serializedOptions[@"method"] = method;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
NSString *uploadType = options.uploadType();
|
|
68
|
+
if (uploadType != nil) {
|
|
69
|
+
serializedOptions[@"uploadType"] = uploadType;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
NSString *fieldName = options.fieldName();
|
|
73
|
+
if (fieldName != nil) {
|
|
74
|
+
serializedOptions[@"fieldName"] = fieldName;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
id<NSObject> parameters = options.parameters();
|
|
78
|
+
if (parameters != nil) {
|
|
79
|
+
serializedOptions[@"parameters"] = parameters;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return serializedOptions;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
- (facebook::react::ModuleConstants<JS::NativeCloudStorageLocalFileSystem::Constants::Builder>)constantsToExport
|
|
86
|
+
{
|
|
87
|
+
return (facebook::react::ModuleConstants<JS::NativeCloudStorageLocalFileSystem::Constants::Builder>)[self getConstants];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
- (facebook::react::ModuleConstants<JS::NativeCloudStorageLocalFileSystem::Constants::Builder>)getConstants
|
|
91
|
+
{
|
|
92
|
+
NSDictionary<NSString *, id> *constants = [_cloudStorageLocalFileSystem constantsToExport];
|
|
93
|
+
NSString *temporaryDirectory = constants[@"temporaryDirectory"];
|
|
94
|
+
|
|
95
|
+
return facebook::react::typedConstants<JS::NativeCloudStorageLocalFileSystem::Constants::Builder>({
|
|
96
|
+
.temporaryDirectory = temporaryDirectory ?: NSTemporaryDirectory(),
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
- (void)createFile:(NSString *)path
|
|
101
|
+
data:(NSString *)data
|
|
102
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
103
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
104
|
+
{
|
|
105
|
+
[_cloudStorageLocalFileSystem createFile:path withData:data withResolver:resolve withRejecter:reject];
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
- (void)readFile:(NSString *)path
|
|
109
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
110
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
111
|
+
{
|
|
112
|
+
[_cloudStorageLocalFileSystem readFile:path withResolver:resolve withRejecter:reject];
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
- (void)downloadFile:(NSString *)remoteUri
|
|
116
|
+
localPath:(NSString *)localPath
|
|
117
|
+
options:(JS::NativeCloudStorageLocalFileSystem::LocalFileSystemDownloadOptions &)options
|
|
118
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
119
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
120
|
+
{
|
|
121
|
+
[_cloudStorageLocalFileSystem
|
|
122
|
+
downloadFile:remoteUri
|
|
123
|
+
withLocalPath:localPath
|
|
124
|
+
withOptions:[self serializeDownloadOptions:options]
|
|
125
|
+
withResolver:resolve
|
|
126
|
+
withRejecter:reject];
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
- (void)uploadFile:(NSString *)localPath
|
|
130
|
+
remoteUri:(NSString *)remoteUri
|
|
131
|
+
options:(JS::NativeCloudStorageLocalFileSystem::LocalFileSystemUploadOptions &)options
|
|
132
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
133
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
134
|
+
{
|
|
135
|
+
[_cloudStorageLocalFileSystem
|
|
136
|
+
uploadFile:localPath
|
|
137
|
+
withRemoteUri:remoteUri
|
|
138
|
+
withOptions:[self serializeUploadOptions:options]
|
|
139
|
+
withResolver:resolve
|
|
140
|
+
withRejecter:reject];
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
144
|
+
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
145
|
+
{
|
|
146
|
+
return std::make_shared<facebook::react::NativeCloudStorageLocalFileSystemSpecJSI>(params);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
@end
|
|
@@ -42,10 +42,10 @@ enum CloudKitUtils {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
|
-
Returns the
|
|
45
|
+
Returns the directory URL for the given scope.
|
|
46
46
|
|
|
47
47
|
- Parameter scope: The scope of the directory.
|
|
48
|
-
- Returns: The URL of the
|
|
48
|
+
- Returns: The URL of the scope directory, or nil if no directory is found.
|
|
49
49
|
*/
|
|
50
50
|
private static func getScopeDirectory(scope: DirectoryScope) -> URL? {
|
|
51
51
|
switch scope {
|
|
@@ -53,6 +53,8 @@ enum CloudKitUtils {
|
|
|
53
53
|
appDataDirectory
|
|
54
54
|
case .documents:
|
|
55
55
|
documentsDirectory
|
|
56
|
+
case .documentsLegacy:
|
|
57
|
+
legacyDocumentsDirectory
|
|
56
58
|
}
|
|
57
59
|
}
|
|
58
60
|
|
|
@@ -107,6 +109,10 @@ enum CloudKitUtils {
|
|
|
107
109
|
}
|
|
108
110
|
|
|
109
111
|
static var documentsDirectory: URL? {
|
|
112
|
+
fileManager.url(forUbiquityContainerIdentifier: nil)?.appendingPathComponent("Documents")
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
static var legacyDocumentsDirectory: URL? {
|
|
110
116
|
fileManager.urls(for: .documentDirectory, in: .userDomainMask).first
|
|
111
117
|
}
|
|
112
118
|
}
|
|
@@ -28,8 +28,7 @@ enum FileUtils {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
do {
|
|
31
|
-
|
|
32
|
-
return fileContents
|
|
31
|
+
return try String(contentsOf: fileUrl, encoding: .utf8)
|
|
33
32
|
} catch {
|
|
34
33
|
throw CloudStorageError.readError(path: fileUrl.path)
|
|
35
34
|
}
|
|
@@ -73,8 +72,7 @@ enum FileUtils {
|
|
|
73
72
|
*/
|
|
74
73
|
static func listFiles(directoryUrl: URL) throws -> [String] {
|
|
75
74
|
do {
|
|
76
|
-
|
|
77
|
-
return fileUrls
|
|
75
|
+
return try fileManager.contentsOfDirectory(atPath: directoryUrl.path)
|
|
78
76
|
} catch {
|
|
79
77
|
throw CloudStorageError.readError(path: directoryUrl.path)
|
|
80
78
|
}
|
package/ios/Utils/Promise.swift
CHANGED
package/ios/Utils/Types.swift
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-cloud-storage",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "☁️ Save to & read from iCloud and Google Drive using React Native",
|
|
5
5
|
"main": "dist/commonjs/index",
|
|
6
6
|
"module": "dist/module/index",
|
|
@@ -37,11 +37,12 @@
|
|
|
37
37
|
],
|
|
38
38
|
"scripts": {
|
|
39
39
|
"clean": "del-cli android/build ios/build dist",
|
|
40
|
-
"build": "
|
|
41
|
-
"
|
|
40
|
+
"build": "pnpm clean && bob build && rm -f dist/commonjs/package.json",
|
|
41
|
+
"codegen": "pnpm run codegen:clean && pnpm run codegen:ios && pnpm run codegen:android",
|
|
42
|
+
"codegen:clean": "del-cli android/generated ios/generated",
|
|
43
|
+
"codegen:ios": "node ../../node_modules/react-native/scripts/generate-codegen-artifacts.js --path . --targetPlatform ios --outputPath ios/generated",
|
|
44
|
+
"codegen:android": "node ../../node_modules/react-native/scripts/generate-codegen-artifacts.js --path . --targetPlatform android --outputPath android/generated",
|
|
42
45
|
"typecheck": "tsc --noEmit",
|
|
43
|
-
"lint": "eslint src/**/*.ts",
|
|
44
|
-
"format": "prettier --write . && ./scripts/swiftformat.sh",
|
|
45
46
|
"release": "release-it",
|
|
46
47
|
"prepack": "cp ../../README.md ./README.md",
|
|
47
48
|
"postpack": "rm ./README.md"
|
|
@@ -56,36 +57,30 @@
|
|
|
56
57
|
"url": "https://github.com/kuatsu/react-native-cloud-storage/issues"
|
|
57
58
|
},
|
|
58
59
|
"homepage": "https://github.com/kuatsu/react-native-cloud-storage#readme",
|
|
59
|
-
"packageManager": "
|
|
60
|
+
"packageManager": "pnpm@10.28.2",
|
|
60
61
|
"publishConfig": {
|
|
61
62
|
"registry": "https://registry.npmjs.org/"
|
|
62
63
|
},
|
|
63
64
|
"devDependencies": {
|
|
64
65
|
"@expo/config-plugins": "^10.0.2",
|
|
65
66
|
"@release-it/conventional-changelog": "^5.0.0",
|
|
66
|
-
"@types/react": "~19.
|
|
67
|
-
"react": "19.
|
|
68
|
-
"react-native": "0.
|
|
67
|
+
"@types/react": "~19.2.14",
|
|
68
|
+
"react": "19.2.0",
|
|
69
|
+
"react-native": "0.83.2",
|
|
69
70
|
"react-native-builder-bob": "^0.30.2",
|
|
70
71
|
"release-it": "^15.0.0",
|
|
71
|
-
"typescript": "~5.
|
|
72
|
+
"typescript": "~5.9.3"
|
|
72
73
|
},
|
|
73
74
|
"peerDependencies": {
|
|
74
75
|
"expo": ">=48.0.0",
|
|
75
76
|
"react": "*",
|
|
76
|
-
"react-native": "
|
|
77
|
+
"react-native": ">=0.76"
|
|
77
78
|
},
|
|
78
79
|
"peerDependenciesMeta": {
|
|
79
80
|
"expo": {
|
|
80
81
|
"optional": true
|
|
81
82
|
}
|
|
82
83
|
},
|
|
83
|
-
"jest": {
|
|
84
|
-
"preset": "react-native",
|
|
85
|
-
"modulePathIgnorePatterns": [
|
|
86
|
-
"<rootDir>/dist/"
|
|
87
|
-
]
|
|
88
|
-
},
|
|
89
84
|
"release-it": {
|
|
90
85
|
"git": {
|
|
91
86
|
"commitMessage": "chore: release ${version}",
|
|
@@ -93,6 +88,7 @@
|
|
|
93
88
|
},
|
|
94
89
|
"npm": {
|
|
95
90
|
"publish": true,
|
|
91
|
+
"skipChecks": true,
|
|
96
92
|
"versionArgs": [
|
|
97
93
|
"--workspaces-update=false"
|
|
98
94
|
]
|
|
@@ -122,5 +118,23 @@
|
|
|
122
118
|
}
|
|
123
119
|
]
|
|
124
120
|
]
|
|
121
|
+
},
|
|
122
|
+
"codegenConfig": {
|
|
123
|
+
"name": "CloudStorageSpec",
|
|
124
|
+
"type": "modules",
|
|
125
|
+
"jsSrcsDir": "src/specs",
|
|
126
|
+
"android": {
|
|
127
|
+
"javaPackageName": "com.cloudstorage"
|
|
128
|
+
},
|
|
129
|
+
"ios": {
|
|
130
|
+
"modules": {
|
|
131
|
+
"CloudStorageCloudKit": {
|
|
132
|
+
"className": "RCTCloudStorageCloudKit"
|
|
133
|
+
},
|
|
134
|
+
"CloudStorageLocalFileSystem": {
|
|
135
|
+
"className": "RCTCloudStorageLocalFileSystem"
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
125
139
|
}
|
|
126
140
|
}
|
|
@@ -15,6 +15,8 @@ Pod::Spec.new do |s|
|
|
|
15
15
|
s.source = { :git => "https://github.com/Kuatsu/react-native-cloud-storage.git", :tag => "#{s.version}" }
|
|
16
16
|
|
|
17
17
|
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
18
|
+
s.exclude_files = "ios/generated/**/*"
|
|
19
|
+
s.public_header_files = "ios/react_native_cloud_storage.h"
|
|
18
20
|
|
|
19
21
|
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
|
|
20
22
|
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
|