react-native-cloud-storage 2.2.2 → 3.0.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.
Files changed (216) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1 -1
  3. package/android/build.gradle +88 -0
  4. package/android/gradle.properties +5 -0
  5. package/android/src/main/AndroidManifest.xml +3 -0
  6. package/android/src/main/AndroidManifestNew.xml +2 -0
  7. package/android/src/main/java/com/voicekit/CloudStorageError.kt +86 -0
  8. package/android/src/main/java/com/voicekit/CloudStorageLocalFileSystemModule.kt +232 -0
  9. package/android/src/main/java/com/voicekit/CloudStoragePackage.kt +32 -0
  10. package/android/src/main/java/com/voicekit/FileUtils.kt +41 -0
  11. package/android/src/main/java/com/voicekit/Types.kt +6 -0
  12. package/app.plugin.js +1 -1
  13. package/{lib/commonjs/RNCloudStorage.js → dist/commonjs/cloud-storage.js} +177 -92
  14. package/dist/commonjs/cloud-storage.js.map +1 -0
  15. package/dist/commonjs/expo-plugin/index.js +13 -0
  16. package/dist/commonjs/expo-plugin/index.js.map +1 -0
  17. package/{lib/commonjs/expo-plugin/withRNCloudStorageIos.js → dist/commonjs/expo-plugin/ios.js} +1 -1
  18. package/dist/commonjs/expo-plugin/ios.js.map +1 -0
  19. package/{lib/commonjs/hooks/useCloudFile.js → dist/commonjs/hooks/use-cloud-file.js} +26 -8
  20. package/dist/commonjs/hooks/use-cloud-file.js.map +1 -0
  21. package/{lib/commonjs/hooks/useIsCloudAvailable.js → dist/commonjs/hooks/use-is-cloud-available.js} +3 -3
  22. package/dist/commonjs/hooks/use-is-cloud-available.js.map +1 -0
  23. package/{lib → dist}/commonjs/index.js +10 -10
  24. package/dist/commonjs/index.js.map +1 -0
  25. package/dist/commonjs/specs/NativeCloudStorageCloudKitIOS.js +9 -0
  26. package/dist/commonjs/specs/NativeCloudStorageCloudKitIOS.js.map +1 -0
  27. package/dist/commonjs/specs/NativeCloudStorageLocalFileSystem.js +9 -0
  28. package/dist/commonjs/specs/NativeCloudStorageLocalFileSystem.js.map +1 -0
  29. package/dist/commonjs/storages/cloudkit.js +12 -0
  30. package/dist/commonjs/storages/cloudkit.js.map +1 -0
  31. package/{lib/commonjs → dist/commonjs/storages}/google-drive/client.js +83 -40
  32. package/dist/commonjs/storages/google-drive/client.js.map +1 -0
  33. package/dist/commonjs/storages/google-drive/index.js +399 -0
  34. package/dist/commonjs/storages/google-drive/index.js.map +1 -0
  35. package/dist/commonjs/storages/google-drive/types.js.map +1 -0
  36. package/{lib → dist}/commonjs/types/main.js.map +1 -1
  37. package/dist/commonjs/types/native.js +28 -0
  38. package/dist/commonjs/types/native.js.map +1 -0
  39. package/{lib/commonjs/utils/CloudStorageError.js → dist/commonjs/utils/cloud-storage-error.js} +3 -1
  40. package/dist/commonjs/utils/cloud-storage-error.js.map +1 -0
  41. package/dist/commonjs/utils/constants.js +25 -0
  42. package/dist/commonjs/utils/constants.js.map +1 -0
  43. package/dist/commonjs/utils/local-fs.js +17 -0
  44. package/dist/commonjs/utils/local-fs.js.map +1 -0
  45. package/dist/commonjs/utils/native.js +35 -0
  46. package/dist/commonjs/utils/native.js.map +1 -0
  47. package/{lib/module/RNCloudStorage.js → dist/module/cloud-storage.js} +178 -93
  48. package/dist/module/cloud-storage.js.map +1 -0
  49. package/dist/module/expo-plugin/index.js +8 -0
  50. package/dist/module/expo-plugin/index.js.map +1 -0
  51. package/{lib/module/expo-plugin/withRNCloudStorageIos.js → dist/module/expo-plugin/ios.js} +1 -1
  52. package/dist/module/expo-plugin/ios.js.map +1 -0
  53. package/{lib/module/hooks/useCloudFile.js → dist/module/hooks/use-cloud-file.js} +25 -7
  54. package/dist/module/hooks/use-cloud-file.js.map +1 -0
  55. package/{lib/module/hooks/useIsCloudAvailable.js → dist/module/hooks/use-is-cloud-available.js} +2 -2
  56. package/dist/module/hooks/use-is-cloud-available.js.map +1 -0
  57. package/dist/module/index.js +9 -0
  58. package/dist/module/index.js.map +1 -0
  59. package/dist/module/specs/NativeCloudStorageCloudKitIOS.js +5 -0
  60. package/dist/module/specs/NativeCloudStorageCloudKitIOS.js.map +1 -0
  61. package/dist/module/specs/NativeCloudStorageLocalFileSystem.js +5 -0
  62. package/dist/module/specs/NativeCloudStorageLocalFileSystem.js.map +1 -0
  63. package/dist/module/storages/cloudkit.js +7 -0
  64. package/dist/module/storages/cloudkit.js.map +1 -0
  65. package/{lib/module → dist/module/storages}/google-drive/client.js +83 -40
  66. package/dist/module/storages/google-drive/client.js.map +1 -0
  67. package/dist/module/storages/google-drive/index.js +392 -0
  68. package/dist/module/storages/google-drive/index.js.map +1 -0
  69. package/dist/module/storages/google-drive/types.js.map +1 -0
  70. package/{lib → dist}/module/types/main.js.map +1 -1
  71. package/dist/module/types/native.js +24 -0
  72. package/dist/module/types/native.js.map +1 -0
  73. package/{lib/module/utils/CloudStorageError.js → dist/module/utils/cloud-storage-error.js} +3 -1
  74. package/dist/module/utils/cloud-storage-error.js.map +1 -0
  75. package/dist/module/utils/constants.js +21 -0
  76. package/dist/module/utils/constants.js.map +1 -0
  77. package/dist/module/utils/local-fs.js +12 -0
  78. package/dist/module/utils/local-fs.js.map +1 -0
  79. package/dist/module/utils/native.js +30 -0
  80. package/dist/module/utils/native.js.map +1 -0
  81. package/{lib/typescript/RNCloudStorage.d.ts → dist/typescript/cloud-storage.d.ts} +67 -8
  82. package/dist/typescript/cloud-storage.d.ts.map +1 -0
  83. package/{lib/typescript/expo-plugin/withRNCloudStorage.d.ts → dist/typescript/expo-plugin/index.d.ts} +1 -1
  84. package/dist/typescript/expo-plugin/index.d.ts.map +1 -0
  85. package/{lib/typescript/expo-plugin/withRNCloudStorageIos.d.ts → dist/typescript/expo-plugin/ios.d.ts} +1 -1
  86. package/dist/typescript/expo-plugin/ios.d.ts.map +1 -0
  87. package/{lib/typescript/hooks/useCloudFile.d.ts → dist/typescript/hooks/use-cloud-file.d.ts} +22 -4
  88. package/dist/typescript/hooks/use-cloud-file.d.ts.map +1 -0
  89. package/{lib/typescript/hooks/useIsCloudAvailable.d.ts → dist/typescript/hooks/use-is-cloud-available.d.ts} +2 -2
  90. package/dist/typescript/hooks/use-is-cloud-available.d.ts.map +1 -0
  91. package/dist/typescript/index.d.ts +7 -0
  92. package/dist/typescript/index.d.ts.map +1 -0
  93. package/dist/typescript/specs/NativeCloudStorageCloudKitIOS.d.ts +30 -0
  94. package/dist/typescript/specs/NativeCloudStorageCloudKitIOS.d.ts.map +1 -0
  95. package/dist/typescript/specs/NativeCloudStorageLocalFileSystem.d.ts +24 -0
  96. package/dist/typescript/specs/NativeCloudStorageLocalFileSystem.d.ts.map +1 -0
  97. package/dist/typescript/storages/cloudkit.d.ts +6 -0
  98. package/dist/typescript/storages/cloudkit.d.ts.map +1 -0
  99. package/{lib/typescript → dist/typescript/storages}/google-drive/client.d.ts +10 -3
  100. package/dist/typescript/storages/google-drive/client.d.ts.map +1 -0
  101. package/dist/typescript/storages/google-drive/index.d.ts +41 -0
  102. package/dist/typescript/storages/google-drive/index.d.ts.map +1 -0
  103. package/dist/typescript/storages/google-drive/types.d.ts.map +1 -0
  104. package/{lib → dist}/typescript/types/main.d.ts +8 -0
  105. package/dist/typescript/types/main.d.ts.map +1 -0
  106. package/dist/typescript/types/native.d.ts +27 -0
  107. package/dist/typescript/types/native.d.ts.map +1 -0
  108. package/dist/typescript/utils/cloud-storage-error.d.ts +8 -0
  109. package/dist/typescript/utils/cloud-storage-error.d.ts.map +1 -0
  110. package/dist/typescript/utils/constants.d.ts +4 -0
  111. package/dist/typescript/utils/constants.d.ts.map +1 -0
  112. package/{lib → dist}/typescript/utils/helpers.d.ts.map +1 -1
  113. package/dist/typescript/utils/local-fs.d.ts +2 -0
  114. package/dist/typescript/utils/local-fs.d.ts.map +1 -0
  115. package/dist/typescript/utils/native.d.ts +7 -0
  116. package/dist/typescript/utils/native.d.ts.map +1 -0
  117. package/ios/CloudStorage-Bridging-Header.h +0 -1
  118. package/ios/CloudStorage.xcodeproj/project.pbxproj +12 -6
  119. package/ios/CloudStorageCloudKit.swift +159 -0
  120. package/ios/CloudStorageLocalFileSystem.swift +216 -0
  121. package/ios/RCTCloudStorageCloudKit.mm +209 -0
  122. package/ios/RCTCloudStorageLocalFileSystem.mm +149 -0
  123. package/ios/Utils/CloudKitUtils.swift +12 -6
  124. package/ios/Utils/CloudStorageError.swift +8 -0
  125. package/ios/Utils/FileUtils.swift +21 -4
  126. package/ios/Utils/Promise.swift +1 -0
  127. package/ios/Utils/Types.swift +8 -1
  128. package/ios/react_native_cloud_storage.h +6 -0
  129. package/package.json +64 -110
  130. package/react-native-cloud-storage.podspec +2 -0
  131. package/src/{RNCloudStorage.ts → cloud-storage.ts} +210 -100
  132. package/src/expo-plugin/{withRNCloudStorage.ts → index.ts} +2 -2
  133. package/src/hooks/{useCloudFile.ts → use-cloud-file.ts} +24 -6
  134. package/src/hooks/{useIsCloudAvailable.ts → use-is-cloud-available.ts} +1 -1
  135. package/src/index.ts +5 -6
  136. package/src/specs/NativeCloudStorageCloudKitIOS.ts +33 -0
  137. package/src/specs/NativeCloudStorageLocalFileSystem.ts +28 -0
  138. package/src/storages/cloudkit.ts +13 -0
  139. package/src/{google-drive → storages/google-drive}/client.ts +100 -41
  140. package/src/storages/google-drive/index.ts +488 -0
  141. package/src/types/main.ts +9 -0
  142. package/src/types/native.ts +14 -22
  143. package/src/utils/cloud-storage-error.ts +15 -0
  144. package/src/utils/constants.ts +21 -0
  145. package/src/utils/local-fs.ts +19 -0
  146. package/src/utils/native.ts +40 -0
  147. package/ios/CloudStorage.m +0 -22
  148. package/ios/CloudStorage.swift +0 -103
  149. package/ios/CloudStorageEventEmitter.m +0 -16
  150. package/ios/CloudStorageEventEmitter.swift +0 -30
  151. package/lib/commonjs/RNCloudStorage.js.map +0 -1
  152. package/lib/commonjs/expo-plugin/withRNCloudStorage.js +0 -13
  153. package/lib/commonjs/expo-plugin/withRNCloudStorage.js.map +0 -1
  154. package/lib/commonjs/expo-plugin/withRNCloudStorageIos.js.map +0 -1
  155. package/lib/commonjs/google-drive/client.js.map +0 -1
  156. package/lib/commonjs/google-drive/index.js +0 -321
  157. package/lib/commonjs/google-drive/index.js.map +0 -1
  158. package/lib/commonjs/google-drive/types.js.map +0 -1
  159. package/lib/commonjs/hooks/useCloudFile.js.map +0 -1
  160. package/lib/commonjs/hooks/useIsCloudAvailable.js.map +0 -1
  161. package/lib/commonjs/index.js.map +0 -1
  162. package/lib/commonjs/types/native.js +0 -26
  163. package/lib/commonjs/types/native.js.map +0 -1
  164. package/lib/commonjs/utils/CloudStorageError.js.map +0 -1
  165. package/lib/module/RNCloudStorage.js.map +0 -1
  166. package/lib/module/expo-plugin/withRNCloudStorage.js +0 -8
  167. package/lib/module/expo-plugin/withRNCloudStorage.js.map +0 -1
  168. package/lib/module/expo-plugin/withRNCloudStorageIos.js.map +0 -1
  169. package/lib/module/google-drive/client.js.map +0 -1
  170. package/lib/module/google-drive/index.js +0 -313
  171. package/lib/module/google-drive/index.js.map +0 -1
  172. package/lib/module/google-drive/types.js.map +0 -1
  173. package/lib/module/hooks/useCloudFile.js.map +0 -1
  174. package/lib/module/hooks/useIsCloudAvailable.js.map +0 -1
  175. package/lib/module/index.js +0 -10
  176. package/lib/module/index.js.map +0 -1
  177. package/lib/module/types/native.js +0 -22
  178. package/lib/module/types/native.js.map +0 -1
  179. package/lib/module/utils/CloudStorageError.js.map +0 -1
  180. package/lib/typescript/RNCloudStorage.d.ts.map +0 -1
  181. package/lib/typescript/expo-plugin/withRNCloudStorage.d.ts.map +0 -1
  182. package/lib/typescript/expo-plugin/withRNCloudStorageIos.d.ts.map +0 -1
  183. package/lib/typescript/google-drive/client.d.ts.map +0 -1
  184. package/lib/typescript/google-drive/index.d.ts +0 -34
  185. package/lib/typescript/google-drive/index.d.ts.map +0 -1
  186. package/lib/typescript/google-drive/types.d.ts.map +0 -1
  187. package/lib/typescript/hooks/useCloudFile.d.ts.map +0 -1
  188. package/lib/typescript/hooks/useIsCloudAvailable.d.ts.map +0 -1
  189. package/lib/typescript/index.d.ts +0 -8
  190. package/lib/typescript/index.d.ts.map +0 -1
  191. package/lib/typescript/types/main.d.ts.map +0 -1
  192. package/lib/typescript/types/native.d.ts +0 -40
  193. package/lib/typescript/types/native.d.ts.map +0 -1
  194. package/lib/typescript/utils/CloudStorageError.d.ts +0 -8
  195. package/lib/typescript/utils/CloudStorageError.d.ts.map +0 -1
  196. package/src/google-drive/index.ts +0 -399
  197. package/src/utils/CloudStorageError.ts +0 -14
  198. /package/{lib → dist}/commonjs/expo-plugin/types/index.js +0 -0
  199. /package/{lib → dist}/commonjs/expo-plugin/types/index.js.map +0 -0
  200. /package/{lib/commonjs → dist/commonjs/storages}/google-drive/types.js +0 -0
  201. /package/{lib → dist}/commonjs/types/main.js +0 -0
  202. /package/{lib → dist}/commonjs/utils/helpers.js +0 -0
  203. /package/{lib → dist}/commonjs/utils/helpers.js.map +0 -0
  204. /package/{lib → dist}/module/expo-plugin/types/index.js +0 -0
  205. /package/{lib → dist}/module/expo-plugin/types/index.js.map +0 -0
  206. /package/{lib → dist}/module/package.json +0 -0
  207. /package/{lib/module → dist/module/storages}/google-drive/types.js +0 -0
  208. /package/{lib → dist}/module/types/main.js +0 -0
  209. /package/{lib → dist}/module/utils/helpers.js +0 -0
  210. /package/{lib → dist}/module/utils/helpers.js.map +0 -0
  211. /package/{lib → dist}/typescript/expo-plugin/types/index.d.ts +0 -0
  212. /package/{lib → dist}/typescript/expo-plugin/types/index.d.ts.map +0 -0
  213. /package/{lib/typescript → dist/typescript/storages}/google-drive/types.d.ts +0 -0
  214. /package/{lib → dist}/typescript/utils/helpers.d.ts +0 -0
  215. /package/src/expo-plugin/{withRNCloudStorageIos.ts → ios.ts} +0 -0
  216. /package/src/{google-drive → storages/google-drive}/types.ts +0 -0
@@ -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
@@ -21,12 +21,12 @@ enum CloudKitUtils {
21
21
  }
22
22
 
23
23
  /**
24
- Downloads a file from iCloud.
24
+ Syncs a file from iCloud to the device.
25
25
 
26
- - Parameter fileUrl: The URL of the file to download.
27
- - Throws: An NSError if the file is not downloadable or the download failed.
26
+ - Parameter fileUrl: The URL of the file to sync.
27
+ - Throws: An NSError if the file is not downloadable or the sync failed.
28
28
  */
29
- static func downloadFile(fileUrl: URL) throws {
29
+ static func triggerSync(fileUrl: URL) throws {
30
30
  let isDownloadable = fileManager.isUbiquitousItem(at: fileUrl)
31
31
 
32
32
  if !isDownloadable {
@@ -42,10 +42,10 @@ enum CloudKitUtils {
42
42
  }
43
43
 
44
44
  /**
45
- Returns the iCloud directory URL for the given scope.
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 iCloud directory, or nil if no directory is found.
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
  }
@@ -23,6 +23,8 @@ enum CloudStorageError: Error {
23
23
  case statError(path: String)
24
24
  case unknown(message: String = "An unknown error occurred")
25
25
  case fileNotDownloadable(path: String)
26
+ case invalidUrl(url: String)
27
+ case networkError(message: String)
26
28
 
27
29
  var code: String {
28
30
  switch self {
@@ -40,6 +42,8 @@ enum CloudStorageError: Error {
40
42
  case .statError: "ERR_STAT_ERROR"
41
43
  case .unknown: "ERR_UNKNOWN"
42
44
  case .fileNotDownloadable: "ERR_FILE_NOT_DOWNLOADABLE"
45
+ case .invalidUrl: "ERR_INVALID_URL"
46
+ case .networkError: "ERR_NETWORK_ERROR"
43
47
  }
44
48
  }
45
49
 
@@ -73,6 +77,10 @@ enum CloudStorageError: Error {
73
77
  message
74
78
  case let .fileNotDownloadable(path):
75
79
  "File not downloadable at path \(path)"
80
+ case let .invalidUrl(url):
81
+ "Invalid URL provided: \(url)"
82
+ case let .networkError(message):
83
+ message
76
84
  }
77
85
  }
78
86
  }
@@ -28,8 +28,7 @@ enum FileUtils {
28
28
  }
29
29
 
30
30
  do {
31
- let fileContents = try String(contentsOf: fileUrl, encoding: .utf8)
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
- let fileUrls = try fileManager.contentsOfDirectory(atPath: directoryUrl.path)
77
- return fileUrls
75
+ return try fileManager.contentsOfDirectory(atPath: directoryUrl.path)
78
76
  } catch {
79
77
  throw CloudStorageError.readError(path: directoryUrl.path)
80
78
  }
@@ -94,6 +92,21 @@ enum FileUtils {
94
92
  }
95
93
  }
96
94
 
95
+ /**
96
+ Copies a file from a source to a destination.
97
+
98
+ - Parameter sourceUrl: The URL of the file to copy from.
99
+ - Parameter destinationUrl: The URL to copy the file to.
100
+ - Throws: An NSError if the file couldn't be copied.
101
+ */
102
+ static func copyFile(from sourceUrl: URL, to destinationUrl: URL) throws {
103
+ do {
104
+ try fileManager.copyItem(at: sourceUrl, to: destinationUrl)
105
+ } catch {
106
+ throw CloudStorageError.writeError(path: destinationUrl.path)
107
+ }
108
+ }
109
+
97
110
  /**
98
111
  Gets the stats of a file.
99
112
 
@@ -129,4 +142,8 @@ enum FileUtils {
129
142
  static func sanitizePath(path: String) -> String {
130
143
  path.replacingOccurrences(of: "^/+", with: "", options: .regularExpression)
131
144
  }
145
+
146
+ static var temporaryDirectory: URL {
147
+ fileManager.temporaryDirectory
148
+ }
132
149
  }
@@ -7,6 +7,7 @@
7
7
  //
8
8
 
9
9
  import Foundation
10
+ import React
10
11
 
11
12
  // MARK: - Promise
12
13
 
@@ -8,12 +8,19 @@
8
8
 
9
9
  import Foundation
10
10
 
11
+ // MARK: - UploadType
12
+
13
+ enum UploadType: String {
14
+ case multipart
15
+ case binary
16
+ }
17
+
11
18
  // MARK: - DirectoryScope
12
19
 
13
- @frozen
14
20
  enum DirectoryScope: String {
15
21
  case appData = "app_data"
16
22
  case documents
23
+ case documentsLegacy = "documents_legacy"
17
24
  }
18
25
 
19
26
  // MARK: - FileStat
@@ -0,0 +1,6 @@
1
+ #ifndef REACT_NATIVE_CLOUD_STORAGE_H
2
+ #define REACT_NATIVE_CLOUD_STORAGE_H
3
+
4
+ #import <Foundation/Foundation.h>
5
+
6
+ #endif
package/package.json CHANGED
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "name": "react-native-cloud-storage",
3
- "version": "2.2.2",
4
- "description": "Save to & read from iCloud and Google Drive using React Native",
5
- "main": "lib/commonjs/index",
6
- "module": "lib/module/index",
7
- "types": "lib/typescript/index.d.ts",
3
+ "version": "3.0.0",
4
+ "description": "☁️ Save to & read from iCloud and Google Drive using React Native",
5
+ "main": "dist/commonjs/index",
6
+ "module": "dist/module/index",
7
+ "types": "dist/typescript/index.d.ts",
8
8
  "react-native": "src/index",
9
9
  "source": "src/index",
10
10
  "files": [
11
11
  "src",
12
- "lib",
12
+ "dist",
13
13
  "android",
14
14
  "ios",
15
15
  "cpp",
16
16
  "*.podspec",
17
17
  "app.plugin.js",
18
- "!lib/typescript/example",
18
+ "!dist/typescript/example",
19
19
  "!ios/build",
20
20
  "!android/build",
21
21
  "!android/gradle",
@@ -27,150 +27,86 @@
27
27
  "!**/__mocks__",
28
28
  "!**/.*"
29
29
  ],
30
- "scripts": {
31
- "test": "jest",
32
- "example": "yarn workspace react-native-cloud-storage-example",
33
- "docs": "yarn workspace react-native-cloud-storage-docs",
34
- "typecheck": "tsc --noEmit",
35
- "lint": "eslint \"**/*.{js,ts,tsx}\"",
36
- "clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
37
- "prepare": "yarn clean && bob build && rm -f lib/commonjs/package.json",
38
- "release": "release-it",
39
- "check": "yarn lint && scripts/swiftformat.sh"
40
- },
41
30
  "keywords": [
42
31
  "react-native",
43
32
  "ios",
44
- "android"
33
+ "android",
34
+ "icloud",
35
+ "google-drive",
36
+ "file-system"
45
37
  ],
46
- "repository": "https://github.com/Kuatsu/react-native-cloud-storage",
47
- "author": "Kuatsu App Agency <hello@kuatsu.de> (https://github.com/Kuatsu)",
38
+ "scripts": {
39
+ "clean": "del-cli android/build ios/build dist",
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",
45
+ "typecheck": "tsc --noEmit",
46
+ "release": "release-it",
47
+ "prepack": "cp ../../README.md ./README.md",
48
+ "postpack": "rm ./README.md"
49
+ },
50
+ "repository": {
51
+ "type": "git",
52
+ "url": "git+https://github.com/kuatsu/react-native-cloud-storage.git"
53
+ },
54
+ "author": "Kuatsu App Agency <hello@kuatsu.de>",
48
55
  "license": "MIT",
49
56
  "bugs": {
50
- "url": "https://github.com/Kuatsu/react-native-cloud-storage/issues"
57
+ "url": "https://github.com/kuatsu/react-native-cloud-storage/issues"
51
58
  },
52
- "homepage": "https://github.com/Kuatsu/react-native-cloud-storage#readme",
59
+ "homepage": "https://github.com/kuatsu/react-native-cloud-storage#readme",
60
+ "packageManager": "pnpm@10.28.2",
53
61
  "publishConfig": {
54
62
  "registry": "https://registry.npmjs.org/"
55
63
  },
56
64
  "devDependencies": {
57
- "@commitlint/config-conventional": "^17.0.2",
58
- "@evilmartians/lefthook": "^1.5.0",
59
- "@expo/config-plugins": "^7.2.5",
60
- "@react-native-community/eslint-config": "^3.2.0",
61
- "@react-native/eslint-config": "0.74.87",
65
+ "@expo/config-plugins": "^10.0.2",
62
66
  "@release-it/conventional-changelog": "^5.0.0",
63
- "@types/jest": "^28.1.2",
64
- "@types/react": "^18.2.6",
65
- "commitlint": "^17.0.2",
66
- "del-cli": "^5.0.0",
67
- "eslint": "^8.4.1",
68
- "eslint-config-prettier": "^8.5.0",
69
- "eslint-plugin-prettier": "^4.0.0",
70
- "jest": "^28.1.1",
71
- "pod-install": "^0.2.2",
72
- "prettier": "^2.0.5",
73
- "react": "18.2.0",
74
- "react-native": "0.74.5",
67
+ "@types/react": "~19.2.14",
68
+ "react": "19.2.0",
69
+ "react-native": "0.83.2",
75
70
  "react-native-builder-bob": "^0.30.2",
76
71
  "release-it": "^15.0.0",
77
- "typescript": "^5.0.2"
72
+ "typescript": "~5.9.3"
78
73
  },
79
74
  "peerDependencies": {
80
75
  "expo": ">=48.0.0",
81
76
  "react": "*",
82
- "react-native": "*"
77
+ "react-native": ">=0.76"
83
78
  },
84
79
  "peerDependenciesMeta": {
85
80
  "expo": {
86
81
  "optional": true
87
82
  }
88
83
  },
89
- "workspaces": [
90
- "example",
91
- "docs"
92
- ],
93
- "engines": {
94
- "node": ">= 18.0.0"
95
- },
96
- "packageManager": "yarn@3.6.1",
97
- "jest": {
98
- "preset": "react-native",
99
- "modulePathIgnorePatterns": [
100
- "<rootDir>/example/node_modules",
101
- "<rootDir>/lib/"
102
- ]
103
- },
104
- "commitlint": {
105
- "extends": [
106
- "@commitlint/config-conventional"
107
- ]
108
- },
109
84
  "release-it": {
110
85
  "git": {
111
86
  "commitMessage": "chore: release ${version}",
112
87
  "tagName": "v${version}"
113
88
  },
114
89
  "npm": {
115
- "publish": true
90
+ "publish": true,
91
+ "versionArgs": [
92
+ "--workspaces-update=false"
93
+ ]
116
94
  },
117
95
  "github": {
118
96
  "release": true
119
97
  },
120
98
  "plugins": {
121
99
  "@release-it/conventional-changelog": {
122
- "preset": "angular"
100
+ "preset": {
101
+ "name": "angular"
102
+ },
103
+ "infile": "CHANGELOG.md"
123
104
  }
124
105
  }
125
106
  },
126
- "eslintConfig": {
127
- "root": true,
128
- "extends": [
129
- "@react-native-community",
130
- "prettier"
131
- ],
132
- "rules": {
133
- "react-native/no-inline-styles": "off",
134
- "prettier/prettier": [
135
- "error",
136
- {
137
- "printWidth": 120,
138
- "tabWidth": 2,
139
- "useTabs": false,
140
- "semi": true,
141
- "singleQuote": true,
142
- "quoteProps": "consistent",
143
- "jsxSingleQuote": false,
144
- "trailingComma": "es5",
145
- "bracketSpacing": true,
146
- "bracketSameLine": true,
147
- "arrowParens": "always",
148
- "endOfLine": "lf"
149
- }
150
- ]
151
- }
152
- },
153
- "eslintIgnore": [
154
- "node_modules/",
155
- "lib/"
156
- ],
157
- "prettier": {
158
- "printWidth": 120,
159
- "tabWidth": 2,
160
- "useTabs": false,
161
- "semi": true,
162
- "singleQuote": true,
163
- "quoteProps": "consistent",
164
- "jsxSingleQuote": false,
165
- "trailingComma": "es5",
166
- "bracketSpacing": true,
167
- "bracketSameLine": true,
168
- "arrowParens": "always",
169
- "endOfLine": "lf"
170
- },
171
107
  "react-native-builder-bob": {
172
108
  "source": "src",
173
- "output": "lib",
109
+ "output": "dist",
174
110
  "targets": [
175
111
  "commonjs",
176
112
  "module",
@@ -181,5 +117,23 @@
181
117
  }
182
118
  ]
183
119
  ]
120
+ },
121
+ "codegenConfig": {
122
+ "name": "CloudStorageSpec",
123
+ "type": "modules",
124
+ "jsSrcsDir": "src/specs",
125
+ "android": {
126
+ "javaPackageName": "com.cloudstorage"
127
+ },
128
+ "ios": {
129
+ "modules": {
130
+ "CloudStorageCloudKit": {
131
+ "className": "RCTCloudStorageCloudKit"
132
+ },
133
+ "CloudStorageLocalFileSystem": {
134
+ "className": "RCTCloudStorageLocalFileSystem"
135
+ }
136
+ }
137
+ }
184
138
  }
185
139
  }
@@ -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.