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 @@
1
+ {"version":3,"names":["_native","require","_cloudStorageError","_interopRequireDefault","_types","_client","_interopRequireWildcard","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","GoogleDrive","constructor","options","drive","GoogleDriveApiClient","Proxy","target","property","allowedFunctions","includes","toString","accessToken","length","CloudStorageError","NativeCloudStorageErrorCode","ACCESS_TOKEN_MISSING","isCloudAvailable","getRootDirectory","scope","isRootPath","path","resolvePathToDirectories","startsWith","slice","endsWith","directories","split","actualFilename","pop","filename","escapeDriveQueryValue","value","replaceAll","String","raw","getQueryRootParentId","getRootDirectoryId","findDirectoryByNameAndParent","name","parentId","escapedName","escapedParentId","query","MimeTypes","FOLDER","listFiles","findFilesByNameAndParent","findFilesByParent","findParentDirectoryId","directoryTree","parentDirectoryId","directoryName","id","files","file","parents","some","candidate","checkIfMultipleFilesWithSameName","strictFilenames","map","join","MULTIPLE_FILES_SAME_NAME","getFileId","throwIf","PATH_IS_DIRECTORY","rootDirectoryId","getFile","FILE_NOT_FOUND","mimeType","error","GoogleDriveHttpError","json","status","AUTHENTICATION_FAILED","UNKNOWN","fileExists","code","appendToFile","data","fileId","previousContent","getFileText","updateFile","body","TEXT","DIRECTORY_NOT_FOUND","createFile","overwrite","FILE_ALREADY_EXISTS","Set","createDirectory","readFile","content","triggerSync","_path","_scope","deleteFile","deleteDirectory","recursive","filesInDirectory","DELETE_ERROR","statFile","size","birthtimeMs","Date","createdTime","getTime","mtimeMs","modifiedTime","isDirectory","isFile","downloadFile","remotePath","localPath","uploadFile","exports"],"sourceRoot":"../../../../src","sources":["storages/google-drive/index.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAMA,IAAAC,kBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAC,uBAAA,CAAAL,OAAA;AAAsE,SAAAK,wBAAAC,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAH,uBAAA,YAAAA,CAAAC,CAAA,EA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AAAS,WAAA","ignoreList":[]}
@@ -0,0 +1 @@
1
+ {"version":3,"names":["MimeTypes","exports"],"sourceRoot":"../../../../src","sources":["storages/google-drive/types.ts"],"mappings":";;;;;;IAEYA,SAAS,GAAAC,OAAA,CAAAD,SAAA,0BAATA,SAAS;EAATA,SAAS;EAATA,SAAS;EAATA,SAAS;EAATA,SAAS;EAATA,SAAS;EAATA,SAAS;EAAA,OAATA,SAAS;AAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["CloudStorageScope","exports","CloudStorageProvider"],"sourceRoot":"../../../src","sources":["types/main.ts"],"mappings":";;;;;;AAAA;AAAA,IAKYA,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,0BAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAA,OAAjBA,iBAAiB;AAAA;AAAA,IAejBE,oBAAoB,GAAAD,OAAA,CAAAC,oBAAA,0BAApBA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;EAAA,OAApBA,oBAAoB;AAAA","ignoreList":[]}
1
+ {"version":3,"names":["CloudStorageScope","exports","CloudStorageProvider"],"sourceRoot":"../../../src","sources":["types/main.ts"],"mappings":";;;;;;AAAA;AAAA,IAKYA,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,0BAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAA,OAAjBA,iBAAiB;AAAA;AAAA,IAiBjBE,oBAAoB,GAAAD,OAAA,CAAAC,oBAAA,0BAApBA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;EAAA,OAApBA,oBAAoB;AAAA","ignoreList":[]}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.NativeCloudStorageErrorCode = void 0;
7
+ let NativeCloudStorageErrorCode = exports.NativeCloudStorageErrorCode = /*#__PURE__*/function (NativeCloudStorageErrorCode) {
8
+ NativeCloudStorageErrorCode["INVALID_SCOPE"] = "ERR_INVALID_SCOPE";
9
+ NativeCloudStorageErrorCode["FILE_NOT_FOUND"] = "ERR_FILE_NOT_FOUND";
10
+ NativeCloudStorageErrorCode["PATH_IS_FILE"] = "ERR_PATH_IS_FILE";
11
+ NativeCloudStorageErrorCode["PATH_IS_DIRECTORY"] = "ERR_PATH_IS_DIRECTORY";
12
+ NativeCloudStorageErrorCode["DIRECTORY_NOT_FOUND"] = "ERR_DIRECTORY_NOT_FOUND";
13
+ NativeCloudStorageErrorCode["DIRECTORY_NOT_EMPTY"] = "ERR_DIRECTORY_NOT_EMPTY";
14
+ NativeCloudStorageErrorCode["FILE_ALREADY_EXISTS"] = "ERR_FILE_EXISTS";
15
+ NativeCloudStorageErrorCode["MULTIPLE_FILES_SAME_NAME"] = "ERR_MULTIPLE_FILES_SAME_NAME";
16
+ NativeCloudStorageErrorCode["AUTHENTICATION_FAILED"] = "ERR_AUTHENTICATION_FAILED";
17
+ NativeCloudStorageErrorCode["WRITE_ERROR"] = "ERR_WRITE_ERROR";
18
+ NativeCloudStorageErrorCode["READ_ERROR"] = "ERR_READ_ERROR";
19
+ NativeCloudStorageErrorCode["DELETE_ERROR"] = "ERR_DELETE_ERROR";
20
+ NativeCloudStorageErrorCode["STAT_ERROR"] = "ERR_STAT_ERROR";
21
+ NativeCloudStorageErrorCode["UNKNOWN"] = "ERR_UNKNOWN";
22
+ NativeCloudStorageErrorCode["FILE_NOT_DOWNLOADABLE"] = "ERR_FILE_NOT_DOWNLOADABLE";
23
+ NativeCloudStorageErrorCode["ACCESS_TOKEN_MISSING"] = "ERR_ACCESS_TOKEN_MISSING";
24
+ NativeCloudStorageErrorCode["INVALID_URL"] = "ERR_INVALID_URL";
25
+ NativeCloudStorageErrorCode["NETWORK_ERROR"] = "ERR_NETWORK_ERROR";
26
+ return NativeCloudStorageErrorCode;
27
+ }({});
28
+ //# sourceMappingURL=native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["NativeCloudStorageErrorCode","exports"],"sourceRoot":"../../../src","sources":["types/native.ts"],"mappings":";;;;;;IAUYA,2BAA2B,GAAAC,OAAA,CAAAD,2BAAA,0BAA3BA,2BAA2B;EAA3BA,2BAA2B;EAA3BA,2BAA2B;EAA3BA,2BAA2B;EAA3BA,2BAA2B;EAA3BA,2BAA2B;EAA3BA,2BAA2B;EAA3BA,2BAA2B;EAA3BA,2BAA2B;EAA3BA,2BAA2B;EAA3BA,2BAA2B;EAA3BA,2BAA2B;EAA3BA,2BAA2B;EAA3BA,2BAA2B;EAA3BA,2BAA2B;EAA3BA,2BAA2B;EAA3BA,2BAA2B;EAA3BA,2BAA2B;EAA3BA,2BAA2B;EAAA,OAA3BA,2BAA2B;AAAA","ignoreList":[]}
@@ -4,6 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+ /* eslint-disable @typescript-eslint/no-explicit-any */
8
+
7
9
  class CloudStorageError extends Error {
8
10
  constructor(message, code, details) {
9
11
  super(message);
@@ -12,4 +14,4 @@ class CloudStorageError extends Error {
12
14
  }
13
15
  }
14
16
  var _default = exports.default = CloudStorageError;
15
- //# sourceMappingURL=CloudStorageError.js.map
17
+ //# sourceMappingURL=cloud-storage-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["CloudStorageError","Error","constructor","message","code","details","_default","exports","default"],"sourceRoot":"../../../src","sources":["utils/cloud-storage-error.ts"],"mappings":";;;;;;AAAA;;AAGA,MAAMA,iBAAiB,SAASC,KAAK,CAAC;EAIpCC,WAAWA,CAACC,OAAe,EAAEC,IAAiC,EAAEC,OAAa,EAAE;IAC7E,KAAK,CAACF,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAGA,IAAI;IAChB,IAAI,CAACC,OAAO,GAAGA,OAAO;EACxB;AACF;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcR,iBAAiB","ignoreList":[]}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.LINKING_ERROR = exports.DEFAULT_PROVIDER_OPTIONS = void 0;
7
+ var _reactNative = require("react-native");
8
+ var _main = require("../types/main");
9
+ const LINKING_ERROR = exports.LINKING_ERROR = `The package 'react-native-cloud-storage' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
10
+ ios: "- You have run 'pod install'\n",
11
+ default: ''
12
+ }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
13
+ const DEFAULT_PROVIDER_OPTIONS = exports.DEFAULT_PROVIDER_OPTIONS = {
14
+ [_main.CloudStorageProvider.ICloud]: {
15
+ scope: _main.CloudStorageScope.AppData,
16
+ documentsMode: 'icloud'
17
+ },
18
+ [_main.CloudStorageProvider.GoogleDrive]: {
19
+ scope: _main.CloudStorageScope.AppData,
20
+ accessToken: null,
21
+ strictFilenames: false,
22
+ timeout: 3000
23
+ }
24
+ };
25
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNative","require","_main","LINKING_ERROR","exports","Platform","select","ios","default","DEFAULT_PROVIDER_OPTIONS","CloudStorageProvider","ICloud","scope","CloudStorageScope","AppData","documentsMode","GoogleDrive","accessToken","strictFilenames","timeout"],"sourceRoot":"../../../src","sources":["utils/constants.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAEO,MAAME,aAAa,GAAAC,OAAA,CAAAD,aAAA,GACxB,qFAAqF,GACrFE,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAE1B,MAAMC,wBAAmE,GAAAL,OAAA,CAAAK,wBAAA,GAAG;EACjF,CAACC,0BAAoB,CAACC,MAAM,GAAG;IAC7BC,KAAK,EAAEC,uBAAiB,CAACC,OAAO;IAChCC,aAAa,EAAE;EACjB,CAAC;EACD,CAACL,0BAAoB,CAACM,WAAW,GAAG;IAClCJ,KAAK,EAAEC,uBAAiB,CAACC,OAAO;IAChCG,WAAW,EAAE,IAAI;IACjBC,eAAe,EAAE,KAAK;IACtBC,OAAO,EAAE;EACX;AACF,CAAC","ignoreList":[]}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.localFileSystem = void 0;
7
+ var _NativeCloudStorageLocalFileSystem = _interopRequireDefault(require("../specs/NativeCloudStorageLocalFileSystem"));
8
+ var _native = require("../utils/native");
9
+ var _constants = require("./constants");
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+ const NativeLocalFileSystem = (0, _native.createProxiedNativeModule)(_NativeCloudStorageLocalFileSystem.default);
12
+ const localFileSystem = exports.localFileSystem = NativeLocalFileSystem ?? new Proxy({}, {
13
+ get() {
14
+ throw new Error(_constants.LINKING_ERROR);
15
+ }
16
+ });
17
+ //# sourceMappingURL=local-fs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_NativeCloudStorageLocalFileSystem","_interopRequireDefault","require","_native","_constants","e","__esModule","default","NativeLocalFileSystem","createProxiedNativeModule","NativeCloudStorageLocalFileSystem","localFileSystem","exports","Proxy","get","Error","LINKING_ERROR"],"sourceRoot":"../../../src","sources":["utils/local-fs.ts"],"mappings":";;;;;;AAAA,IAAAA,kCAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AAA4C,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE5C,MAAMG,qBAAqB,GAAG,IAAAC,iCAAyB,EACrDC,0CACF,CAAC;AAEM,MAAMC,eAAe,GAAAC,OAAA,CAAAD,eAAA,GAC1BH,qBAAqB,IACpB,IAAIK,KAAK,CACR,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACC,wBAAa,CAAC;EAChC;AACF,CACF,CAA4B","ignoreList":[]}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createProxiedNativeModule = void 0;
7
+ var _native = require("../types/native");
8
+ var _cloudStorageError = _interopRequireDefault(require("./cloud-storage-error"));
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ /**
11
+ * Creates a proxied native module that wraps thrown errors in a CloudStorageError.
12
+ * @param nativeModule The native module to proxy.
13
+ * @returns The proxied native module.
14
+ */
15
+ const createProxiedNativeModule = nativeModule => {
16
+ if (!nativeModule) return null;
17
+ return new Proxy(nativeModule, {
18
+ get(target, property, receiver) {
19
+ const originalValue = Reflect.get(target, property, receiver);
20
+ if (typeof originalValue === 'function') {
21
+ return async (...arguments_) => {
22
+ try {
23
+ return await Reflect.apply(originalValue, target, arguments_);
24
+ } catch (error) {
25
+ const error_ = typeof error === 'object' && error !== null && 'code' in error && typeof error.code === 'string' && Object.values(_native.NativeCloudStorageErrorCode).includes(error.code) ? new _cloudStorageError.default('message' in error && typeof error.message === 'string' ? error.message : 'Unknown error', error.code) : new _cloudStorageError.default('Unknown error', _native.NativeCloudStorageErrorCode.UNKNOWN, error);
26
+ throw error_;
27
+ }
28
+ };
29
+ }
30
+ return originalValue;
31
+ }
32
+ });
33
+ };
34
+ exports.createProxiedNativeModule = createProxiedNativeModule;
35
+ //# sourceMappingURL=native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_native","require","_cloudStorageError","_interopRequireDefault","e","__esModule","default","createProxiedNativeModule","nativeModule","Proxy","get","target","property","receiver","originalValue","Reflect","arguments_","apply","error","error_","code","Object","values","NativeCloudStorageErrorCode","includes","Clo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I,OAAO,EAAET,KAAK,CAAC;YACxF,MAAMC,MAAM;UACd;QACF,CAAC;MACH;MAEA,OAAOL,aAAa;IACtB;EACF,CAAC,CAAC;AACJ,CAAC;AAACc,OAAA,CAAArB,yBAAA,GAAAA,yBAAA","ignoreList":[]}
@@ -1,50 +1,16 @@
1
1
  "use strict";
2
2
 
3
3
  import { CloudStorageProvider, CloudStorageScope } from './types/main';
4
+ import { NativeCloudStorageErrorCode } from './types/native';
4
5
  import { isProviderSupported } from './utils/helpers';
5
- import { NativeEventEmitter, NativeModules, Platform } from 'react-native';
6
- import CloudStorageError from './utils/CloudStorageError';
7
- import { CloudStorageErrorCode } from './types/native';
8
- import GoogleDrive from './google-drive';
9
- const LINKING_ERROR = `The package 'react-native-cloud-storage' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
10
- ios: "- You have run 'pod install'\n",
11
- default: ''
12
- }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
13
-
14
- // proxy NativeModules.CloudStorage to catch any errors thrown by the native module and wrap them in a CloudStorageError
15
- const nativeIosInstance = NativeModules.CloudStorage ? new Proxy(NativeModules.CloudStorage, {
16
- get(target, prop) {
17
- const originalFunction = target[prop];
18
- if (typeof originalFunction === 'function') {
19
- return async (...args) => {
20
- try {
21
- // @ts-expect-error - we can't know the types of the functions and their arguments
22
- return await originalFunction(...args);
23
- } catch (error) {
24
- if (error?.code && Object.values(CloudStorageErrorCode).includes(error.code)) {
25
- throw new CloudStorageError(error?.message || '', error.code);
26
- } else {
27
- throw new CloudStorageError('Unknown error', CloudStorageErrorCode.UNKNOWN, error);
28
- }
29
- }
30
- };
31
- }
32
- return originalFunction;
33
- }
34
- }) : null;
35
- const defaultProviderOptions = {
36
- [CloudStorageProvider.ICloud]: {
37
- scope: CloudStorageScope.AppData
38
- },
39
- [CloudStorageProvider.GoogleDrive]: {
40
- scope: CloudStorageScope.AppData,
41
- accessToken: null,
42
- strictFilenames: false,
43
- timeout: 3000
44
- }
45
- };
6
+ import { Platform } from 'react-native';
7
+ import GoogleDrive from './storages/google-drive';
8
+ import { NativeCloudKit, NativeCloudKitModule } from './storages/cloudkit';
9
+ import { DEFAULT_PROVIDER_OPTIONS, LINKING_ERROR } from './utils/constants';
10
+ import CloudStorageError from './utils/cloud-storage-error';
46
11
  export default class RNCloudStorage {
47
12
  cloudAvailabilityListeners = [];
13
+ cloudAvailabilitySubscription = null;
48
14
 
49
15
  //#region Constructor and configuration
50
16
  /**
@@ -57,23 +23,27 @@ export default class RNCloudStorage {
57
23
  }
58
24
  this.provider = {
59
25
  provider: provider ?? RNCloudStorage.getDefaultProvider(),
60
- options: defaultProviderOptions[provider ?? RNCloudStorage.getDefaultProvider()]
26
+ options: DEFAULT_PROVIDER_OPTIONS[provider ?? RNCloudStorage.getDefaultProvider()]
61
27
  };
62
28
  this.setProvider(provider ?? RNCloudStorage.getDefaultProvider());
63
29
  if (options) {
64
30
  this.setProviderOptions(options);
65
31
  }
66
32
  }
67
- get nativeInstance() {
33
+ get nativeStorage() {
68
34
  switch (this.provider.provider) {
69
35
  case CloudStorageProvider.ICloud:
70
- return nativeIosInstance ?? new Proxy({}, {
71
- get() {
72
- throw new Error(LINKING_ERROR);
73
- }
74
- });
36
+ {
37
+ return NativeCloudKit ?? new Proxy({}, {
38
+ get() {
39
+ throw new Error(LINKING_ERROR);
40
+ }
41
+ });
42
+ }
75
43
  default:
76
- return new GoogleDrive(this.provider.options);
44
+ {
45
+ return new GoogleDrive(this.provider.options);
46
+ }
77
47
  }
78
48
  }
79
49
 
@@ -84,9 +54,13 @@ export default class RNCloudStorage {
84
54
  static getDefaultProvider() {
85
55
  switch (Platform.OS) {
86
56
  case 'ios':
87
- return CloudStorageProvider.ICloud;
57
+ {
58
+ return CloudStorageProvider.ICloud;
59
+ }
88
60
  default:
89
- return CloudStorageProvider.GoogleDrive;
61
+ {
62
+ return CloudStorageProvider.GoogleDrive;
63
+ }
90
64
  }
91
65
  }
92
66
 
@@ -95,7 +69,7 @@ export default class RNCloudStorage {
95
69
  * @returns An array of supported CloudStorageProviders.
96
70
  */
97
71
  static getSupportedProviders() {
98
- return Object.values(CloudStorageProvider).filter(isProviderSupported);
72
+ return Object.values(CloudStorageProvider).filter(provider => isProviderSupported(provider));
99
73
  }
100
74
 
101
75
  /**
@@ -105,6 +79,38 @@ export default class RNCloudStorage {
105
79
  getProvider() {
106
80
  return this.provider.provider;
107
81
  }
82
+ notifyCloudAvailabilityListeners(available) {
83
+ for (const listener of this.cloudAvailabilityListeners) {
84
+ listener(available);
85
+ }
86
+ }
87
+ refreshCloudAvailability() {
88
+ this.nativeStorage.isCloudAvailable().then(available => {
89
+ this.notifyCloudAvailabilityListeners(available);
90
+ }).catch(() => {
91
+ // ignore errors when refreshing availability after provider changes
92
+ });
93
+ }
94
+ getNativeCloudKitModule() {
95
+ return this.provider.provider === CloudStorageProvider.ICloud ? NativeCloudKitModule : null;
96
+ }
97
+ removeCloudAvailabilitySubscription() {
98
+ this.cloudAvailabilitySubscription?.remove();
99
+ this.cloudAvailabilitySubscription = null;
100
+ }
101
+ configureCloudAvailabilitySubscription() {
102
+ this.removeCloudAvailabilitySubscription();
103
+ if (this.cloudAvailabilityListeners.length === 0) {
104
+ return;
105
+ }
106
+ const nativeCloudKitModule = this.getNativeCloudKitModule();
107
+ if (!nativeCloudKitModule) {
108
+ return;
109
+ }
110
+ this.cloudAvailabilitySubscription = nativeCloudKitModule.onCloudAvailabilityChanged(event => {
111
+ this.notifyCloudAvailabilityListeners(event.available);
112
+ });
113
+ }
108
114
 
109
115
  /**
110
116
  * Sets the current CloudStorageProvider.
@@ -116,24 +122,10 @@ export default class RNCloudStorage {
116
122
  }
117
123
  this.provider = {
118
124
  provider,
119
- options: defaultProviderOptions[provider]
125
+ options: DEFAULT_PROVIDER_OPTIONS[provider]
120
126
  };
121
-
122
- // Emit an event to notify useIsCloudAvailable() hook consumers of the new cloud availability status
123
- this.nativeInstance.isCloudAvailable().then(available => {
124
- this.cloudAvailabilityListeners.forEach(listener => {
125
- listener(available);
126
- });
127
- });
128
- if (provider === CloudStorageProvider.ICloud) {
129
- // Listen to native cloud availability change events
130
- const eventEmitter = new NativeEventEmitter(NativeModules.CloudStorageEventEmitter);
131
- eventEmitter.addListener('RNCloudStorage.cloud.availability-changed', event => {
132
- this.cloudAvailabilityListeners.forEach(listener => {
133
- listener(event.available);
134
- });
135
- });
136
- }
127
+ this.refreshCloudAvailability();
128
+ this.configureCloudAvailabilitySubscription();
137
129
  }
138
130
 
139
131
  /**
@@ -156,16 +148,32 @@ export default class RNCloudStorage {
156
148
  };
157
149
  if (this.provider.provider === CloudStorageProvider.GoogleDrive && 'accessToken' in newOptions) {
158
150
  // Emit an event to notify useIsCloudAvailable() hook consumers of the new cloud availability status
159
- this.cloudAvailabilityListeners.forEach(listener => {
160
- listener(!!newOptions.accessToken?.length);
161
- });
151
+ this.notifyCloudAvailabilityListeners(!!newOptions.accessToken?.length);
162
152
  }
163
153
  }
164
154
  subscribeToCloudAvailability(listener) {
165
155
  this.cloudAvailabilityListeners.push(listener);
156
+ if (this.cloudAvailabilityListeners.length === 1) {
157
+ this.configureCloudAvailabilitySubscription();
158
+ this.refreshCloudAvailability();
159
+ }
166
160
  }
167
161
  unsubscribeFromCloudAvailability(listener) {
168
162
  this.cloudAvailabilityListeners = this.cloudAvailabilityListeners.filter(l => l !== listener);
163
+ if (this.cloudAvailabilityListeners.length === 0) {
164
+ this.removeCloudAvailabilitySubscription();
165
+ }
166
+ }
167
+ resolveNativeScope(scope) {
168
+ const resolvedScope = scope ?? this.provider.options.scope;
169
+ if (this.provider.provider !== CloudStorageProvider.ICloud || resolvedScope !== CloudStorageScope.Documents) {
170
+ return resolvedScope;
171
+ }
172
+ const iCloudOptions = this.provider.options;
173
+ if (iCloudOptions.documentsMode === 'legacy_sandbox') {
174
+ return 'documents_legacy';
175
+ }
176
+ return resolvedScope;
169
177
  }
170
178
  //#endregion
171
179
 
@@ -176,7 +184,7 @@ export default class RNCloudStorage {
176
184
  * @returns A promise that resolves to true if the cloud storage is available, false otherwise.
177
185
  */
178
186
  isCloudAvailable() {
179
- return this.nativeInstance.isCloudAvailable();
187
+ return this.nativeStorage.isCloudAvailable();
180
188
  }
181
189
 
182
190
  /**
@@ -187,7 +195,7 @@ export default class RNCloudStorage {
187
195
  * @returns A promise that resolves when the data has been appended.
188
196
  */
189
197
  appendFile(path, data, scope) {
190
- return this.nativeInstance.appendToFile(path, data, scope ?? this.provider.options.scope);
198
+ return this.nativeStorage.appendToFile(path, data, this.resolveNativeScope(scope));
191
199
  }
192
200
 
193
201
  /**
@@ -197,7 +205,7 @@ export default class RNCloudStorage {
197
205
  * @returns A promise that resolves to true if the path exists, false otherwise.
198
206
  */
199
207
  exists(path, scope) {
200
- return this.nativeInstance.fileExists(path, scope ?? this.provider.options.scope);
208
+ return this.nativeStorage.fileExists(path, this.resolveNativeScope(scope));
201
209
  }
202
210
 
203
211
  /**
@@ -208,7 +216,7 @@ export default class RNCloudStorage {
208
216
  * @returns A promise that resolves when the file has been written.
209
217
  */
210
218
  writeFile(path, data, scope) {
211
- return this.nativeInstance.createFile(path, data, scope ?? this.provider.options.scope, true);
219
+ return this.nativeStorage.createFile(path, data, this.resolveNativeScope(scope), true);
212
220
  }
213
221
 
214
222
  /**
@@ -218,7 +226,7 @@ export default class RNCloudStorage {
218
226
  * @returns A promise that resolves when the directory has been created.
219
227
  */
220
228
  mkdir(path, scope) {
221
- return this.nativeInstance.createDirectory(path, scope ?? this.provider.options.scope);
229
+ return this.nativeStorage.createDirectory(path, this.resolveNativeScope(scope));
222
230
  }
223
231
 
224
232
  /**
@@ -228,7 +236,7 @@ export default class RNCloudStorage {
228
236
  * @returns A promise that resolves to an array of file names, excluding '.' and '..'.
229
237
  */
230
238
  readdir(path, scope) {
231
- return this.nativeInstance.listFiles(path, scope ?? this.provider.options.scope);
239
+ return this.nativeStorage.listFiles(path, this.resolveNativeScope(scope));
232
240
  }
233
241
 
234
242
  /**
@@ -238,17 +246,55 @@ export default class RNCloudStorage {
238
246
  * @returns A promise that resolves to the contents of the file.
239
247
  */
240
248
  readFile(path, scope) {
241
- return this.nativeInstance.readFile(path, scope ?? this.provider.options.scope);
249
+ return this.nativeStorage.readFile(path, this.resolveNativeScope(scope));
250
+ }
251
+
252
+ /**
253
+ * Triggers synchronization for the file at the given path. Does not have any effect on Google Drive.
254
+ * @param path The file to trigger synchronization for.
255
+ * @param scope The directory scope the path is in. Defaults to set default scope set for the current provider.
256
+ * @returns A promise that resolves once the synchronization has been triggered.
257
+ */
258
+ triggerSync(path, scope) {
259
+ return this.nativeStorage.triggerSync(path, this.resolveNativeScope(scope));
242
260
  }
243
261
 
244
262
  /**
245
- * Downloads the file at the given path. Does not have any effect on Google Drive.
246
- * @param path The file to trigger the download for.
263
+ * Uploads the file at the given local path to the given path, creating it if it doesn't exist or overwriting it if it does.
264
+ * @param remotePath The remote path to upload to.
265
+ * @param localPath The local path of the file to upload.
266
+ * @param options The options for the upload. Must contain a `mimeType` property.
247
267
  * @param scope The directory scope the path is in. Defaults to set default scope set for the current provider.
248
- * @returns A promise that resolves once the download has been triggered.
268
+ * @returns A promise that resolves when the file has been uploaded.
249
269
  */
250
- downloadFile(path, scope) {
251
- return this.nativeInstance.downloadFile(path, scope ?? this.provider.options.scope);
270
+ uploadFile(remotePath, localPath, options, scope) {
271
+ return this.nativeStorage.uploadFile(remotePath, localPath, options.mimeType, this.resolveNativeScope(scope), true);
272
+ }
273
+
274
+ /**
275
+ * Triggers synchronization for the file at the given path. Does not have any effect on Google Drive.
276
+ * @param path The file to trigger synchronization for.
277
+ * @param scope The directory scope the path is in. Defaults to set default scope set for the current provider.
278
+ * @returns A promise that resolves once the synchronization has been triggered.
279
+ * @deprecated Use `triggerSync` instead.
280
+ */
281
+
282
+ /**
283
+ * Downloads the cloud file at the given remote path to the given local path.
284
+ * @param remotePath The remote path of the file to download from the cloud.
285
+ * @param localPath The local path to download the cloud file to.
286
+ * @param scope The directory scope the path is in. Defaults to set default scope set for the current provider.
287
+ */
288
+
289
+ downloadFile(remotePathOrPath, localPathOrScope, scope) {
290
+ if (!localPathOrScope || !scope && typeof localPathOrScope === 'string' && Object.values(CloudStorageScope).includes(localPathOrScope)) {
291
+ // deprecated `triggerSync` call
292
+ return this.triggerSync(remotePathOrPath, scope);
293
+ }
294
+ if (!localPathOrScope) {
295
+ throw new CloudStorageError('Invalid arguments provided to downloadFile', NativeCloudStorageErrorCode.UNKNOWN);
296
+ }
297
+ return this.nativeStorage.downloadFile(remotePathOrPath, localPathOrScope, this.resolveNativeScope(scope));
252
298
  }
253
299
 
254
300
  /**
@@ -258,7 +304,7 @@ export default class RNCloudStorage {
258
304
  * @returns A promise that resolves when the file has been deleted.
259
305
  */
260
306
  unlink(path, scope) {
261
- return this.nativeInstance.deleteFile(path, scope ?? this.provider.options.scope);
307
+ return this.nativeStorage.deleteFile(path, this.resolveNativeScope(scope));
262
308
  }
263
309
 
264
310
  /**
@@ -269,7 +315,7 @@ export default class RNCloudStorage {
269
315
  * @returns A promise that resolves when the directory has been deleted.
270
316
  */
271
317
  rmdir(path, options, scope) {
272
- return this.nativeInstance.deleteDirectory(path, options?.recursive ?? false, scope ?? this.provider.options.scope);
318
+ return this.nativeStorage.deleteDirectory(path, options?.recursive ?? false, this.resolveNativeScope(scope));
273
319
  }
274
320
 
275
321
  /**
@@ -279,7 +325,7 @@ export default class RNCloudStorage {
279
325
  * @returns A promise that resolves to the CloudStorageFileStat object.
280
326
  */
281
327
  async stat(path, scope) {
282
- const native = await this.nativeInstance.statFile(path, scope ?? this.provider.options.scope);
328
+ const native = await this.nativeStorage.statFile(path, this.resolveNativeScope(scope));
283
329
  return {
284
330
  ...native,
285
331
  birthtime: new Date(native.birthtimeMs),
@@ -402,13 +448,52 @@ export default class RNCloudStorage {
402
448
  }
403
449
 
404
450
  /**
405
- * Downloads the file at the given path in the provider of the default static instance. Does not have any effect on Google Drive.
406
- * @param path The file to trigger the download for.
451
+ * Triggers synchronization for the file at the given path in the provider of the default static instance. Does not have any effect on Google Drive.
452
+ * @param path The file to trigger synchronization for.
407
453
  * @param scope The directory scope the path is in. Defaults to the default scope set for the default static instance.
408
- * @returns A promise that resolves once the download has been triggered.
454
+ * @returns A promise that resolves once the synchronization has been triggered.
455
+ */
456
+ static triggerSync(path, scope) {
457
+ return RNCloudStorage.getDefaultInstance().triggerSync(path, scope);
458
+ }
459
+
460
+ /**
461
+ * Uploads the file at the given local path to the given path in the provider of the default static instance, creating it if it doesn't exist or overwriting it if it does.
462
+ * @param remotePath The remote path to upload to.
463
+ * @param localPath The local path of the file to upload.
464
+ * @param options The options for the upload. Must contain a `mimeType` property.
465
+ * @param scope The directory scope the path is in. Defaults to set default scope set for the current provider.
466
+ * @returns A promise that resolves when the file has been uploaded.
467
+ */
468
+ static uploadFile(remotePath, localPath, options, scope) {
469
+ return RNCloudStorage.getDefaultInstance().uploadFile(remotePath, localPath, options, scope);
470
+ }
471
+
472
+ /**
473
+ * Triggers synchronization for the file at the given path in the provider of the default static instance. Does not have any effect on Google Drive.
474
+ * @param path The file to trigger synchronization for.
475
+ * @param scope The directory scope the path is in. Defaults to set default scope set for the current provider.
476
+ * @returns A promise that resolves once the synchronization has been triggered.
477
+ * @deprecated Use `triggerSync` instead.
409
478
  */
410
- static downloadFile(path, scope) {
411
- return RNCloudStorage.getDefaultInstance().downloadFile(path, scope);
479
+
480
+ /**
481
+ * Downloads the cloud file at the given remote path to the given local path.
482
+ * @param remotePath The remote path of the file to download from the cloud.
483
+ * @param localPath The local path to download the cloud file to.
484
+ * @param scope The directory scope the path is in. Defaults to set default scope set for the current provider.
485
+ */
486
+
487
+ static downloadFile(remotePathOrPath, localPathOrScope, scope) {
488
+ if (typeof scope === 'string') {
489
+ if (!localPathOrScope) {
490
+ throw new CloudStorageError('Invalid arguments provided to downloadFile', NativeCloudStorageErrorCode.UNKNOWN);
491
+ }
492
+ return RNCloudStorage.getDefaultInstance().downloadFile(remotePathOrPath, localPathOrScope, scope);
493
+ } else {
494
+ // deprecated `triggerSync` call
495
+ return RNCloudStorage.getDefaultInstance().triggerSync(remotePathOrPath, scope);
496
+ }
412
497
  }
413
498
 
414
499
  /**
@@ -443,4 +528,4 @@ export default class RNCloudStorage {
443
528
  }
444
529
  //#endregion
445
530
  }
446
- //# sourceMappingURL=RNCloudStorage.js.map
531
+ //# sourceMappingURL=cloud-storage.js.map