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,392 @@
1
+ "use strict";
2
+
3
+ import { NativeCloudStorageErrorCode } from '../../types/native';
4
+ import CloudStorageError from '../../utils/cloud-storage-error';
5
+ import { MimeTypes } from './types';
6
+ import GoogleDriveApiClient, { GoogleDriveHttpError } from './client';
7
+ /**
8
+ * A JavaScript-based implementation of the Google Drive API that implements the cloud storage interface.
9
+ */
10
+ export default class GoogleDrive {
11
+ constructor(options) {
12
+ this.options = options;
13
+ this.drive = new GoogleDriveApiClient(options);
14
+ return new Proxy(this, {
15
+ // before calling any function, check if the access token is set
16
+ get(target, property) {
17
+ const allowedFunctions = ['isCloudAvailable'];
18
+ if (typeof target[property] === 'function' && !allowedFunctions.includes(property.toString())) {
19
+ const {
20
+ accessToken
21
+ } = options;
22
+ if (!accessToken?.length) {
23
+ throw new CloudStorageError(`Google Drive access token is not set, cannot call function ${property.toString()}`, NativeCloudStorageErrorCode.ACCESS_TOKEN_MISSING);
24
+ }
25
+ }
26
+ return target[property];
27
+ }
28
+ });
29
+ }
30
+ isCloudAvailable = async () => {
31
+ const {
32
+ accessToken
33
+ } = this.options;
34
+ return !!accessToken?.length;
35
+ };
36
+ getRootDirectory(scope) {
37
+ switch (scope) {
38
+ case 'documents':
39
+ {
40
+ return 'drive';
41
+ }
42
+ case 'documents_legacy':
43
+ {
44
+ return 'drive';
45
+ }
46
+ case 'app_data':
47
+ {
48
+ return 'appDataFolder';
49
+ }
50
+ }
51
+ }
52
+ isRootPath(path) {
53
+ return path === '' || path === '/';
54
+ }
55
+ resolvePathToDirectories(path) {
56
+ if (path.startsWith('/')) path = path.slice(1);
57
+ if (path.endsWith('/')) path = path.slice(0, -1);
58
+ const directories = path.split('/');
59
+ const actualFilename = directories.pop() ?? '';
60
+ return {
61
+ directories,
62
+ filename: actualFilename
63
+ };
64
+ }
65
+ escapeDriveQueryValue(value) {
66
+ return value.replaceAll('\\', String.raw`\\`).replaceAll("'", String.raw`\'`);
67
+ }
68
+ async getQueryRootParentId(scope) {
69
+ if (scope === 'app_data') {
70
+ return this.getRootDirectory(scope);
71
+ }
72
+ return this.getRootDirectoryId(scope);
73
+ }
74
+ async findDirectoryByNameAndParent(name, parentId, scope) {
75
+ const escapedName = this.escapeDriveQueryValue(name);
76
+ const escapedParentId = this.escapeDriveQueryValue(parentId);
77
+ const query = `name = '${escapedName}' and '${escapedParentId}' in parents and mimeType = '${MimeTypes.FOLDER}' and trashed = false`;
78
+ return this.drive.listFiles(this.getRootDirectory(scope), query);
79
+ }
80
+ async findFilesByNameAndParent(name, parentId, scope) {
81
+ const escapedName = this.escapeDriveQueryValue(name);
82
+ const escapedParentId = this.escapeDriveQueryValue(parentId);
83
+ const query = `name = '${escapedName}' and '${escapedParentId}' in parents and trashed = false`;
84
+ return this.drive.listFiles(this.getRootDirectory(scope), query);
85
+ }
86
+ async findFilesByParent(parentId, scope) {
87
+ const escapedParentId = this.escapeDriveQueryValue(parentId);
88
+ const query = `'${escapedParentId}' in parents and trashed = false`;
89
+ return this.drive.listFiles(this.getRootDirectory(scope), query);
90
+ }
91
+ async findParentDirectoryId(directoryTree, scope) {
92
+ let parentDirectoryId = await this.getQueryRootParentId(scope);
93
+ for (const directoryName of directoryTree) {
94
+ const directories = await this.findDirectoryByNameAndParent(directoryName, parentDirectoryId, scope);
95
+ if (directories.length === 0) {
96
+ return null;
97
+ }
98
+ parentDirectoryId = directories[0].id;
99
+ }
100
+ return parentDirectoryId;
101
+ }
102
+
103
+ /**
104
+ * Gets the Google Drive ID of the root directory for the given scope.
105
+ * @param scope The scope to get the root directory for.
106
+ * @returns A promise that resolves to the ID of the root directory.
107
+ */
108
+ async getRootDirectoryId(scope) {
109
+ if (scope !== 'app_data') {
110
+ return 'root';
111
+ }
112
+ const files = await this.drive.listFiles(this.getRootDirectory(scope));
113
+ for (const file of files) {
114
+ const parentId = file.parents?.[0];
115
+ if (parentId && !files.some(candidate => candidate.id === parentId)) {
116
+ return parentId;
117
+ }
118
+ }
119
+ return this.getRootDirectory(scope);
120
+ }
121
+ checkIfMultipleFilesWithSameName(path, files) {
122
+ const {
123
+ strictFilenames
124
+ } = this.options;
125
+ if (files.length <= 1) return;
126
+ if (strictFilenames) {
127
+ throw new CloudStorageError(`Multiple files with the same name found at path ${path}: ${files.map(f => f.id).join(', ')}`, NativeCloudStorageErrorCode.MULTIPLE_FILES_SAME_NAME);
128
+ }
129
+ }
130
+ async getFileId(path, scope, throwIf = false) {
131
+ try {
132
+ if (this.isRootPath(path)) {
133
+ if (throwIf === 'directory') {
134
+ throw new CloudStorageError(`Path ${path} is a directory`, NativeCloudStorageErrorCode.PATH_IS_DIRECTORY);
135
+ }
136
+ const rootDirectoryId = await this.getRootDirectoryId(scope);
137
+ if (scope !== 'app_data') {
138
+ await this.drive.getFile(rootDirectoryId);
139
+ }
140
+ return rootDirectoryId;
141
+ }
142
+ const {
143
+ directories,
144
+ filename
145
+ } = this.resolvePathToDirectories(path);
146
+ const parentDirectoryId = await this.findParentDirectoryId(directories, scope);
147
+ if (parentDirectoryId === null) {
148
+ throw new CloudStorageError(`File not found`, NativeCloudStorageErrorCode.FILE_NOT_FOUND);
149
+ }
150
+ const files = await this.findFilesByNameAndParent(filename, parentDirectoryId, scope);
151
+ this.checkIfMultipleFilesWithSameName(path, files);
152
+ const file = files[0];
153
+ if (!file) throw new CloudStorageError(`File not found`, NativeCloudStorageErrorCode.FILE_NOT_FOUND);
154
+ if (file.mimeType === MimeTypes.FOLDER && throwIf === 'directory') {
155
+ throw new CloudStorageError(`Path ${path} is a directory`, NativeCloudStorageErrorCode.PATH_IS_DIRECTORY);
156
+ } else if (file.mimeType !== MimeTypes.FOLDER && throwIf === 'file') {
157
+ throw new CloudStorageError(`Path ${path} is a file`, NativeCloudStorageErrorCode.FILE_NOT_FOUND);
158
+ }
159
+ return file.id;
160
+ } catch (error) {
161
+ if (error instanceof GoogleDriveHttpError && error.json?.error?.status === 'UNAUTHENTICATED') {
162
+ throw new CloudStorageError(`Could not authenticate with Google Drive`, NativeCloudStorageErrorCode.AUTHENTICATION_FAILED, error.json);
163
+ } else {
164
+ if (error instanceof CloudStorageError) throw error;
165
+ throw new CloudStorageError(`Could not get file id for path ${path}`, NativeCloudStorageErrorCode.UNKNOWN, error);
166
+ }
167
+ }
168
+ }
169
+ async fileExists(path, scope) {
170
+ try {
171
+ await this.getFileId(path, scope);
172
+ return true;
173
+ } catch (error) {
174
+ if (error instanceof CloudStorageError && error.code === NativeCloudStorageErrorCode.FILE_NOT_FOUND) return false;else throw error;
175
+ }
176
+ }
177
+ async appendToFile(path, data, scope) {
178
+ let fileId;
179
+ let previousContent = '';
180
+ try {
181
+ fileId = await this.getFileId(path, scope, 'directory');
182
+ previousContent = await this.drive.getFileText(fileId);
183
+ } catch (error) {
184
+ if (error instanceof CloudStorageError && error.code === NativeCloudStorageErrorCode.FILE_NOT_FOUND) {
185
+ /* do nothing, simply create the file */
186
+ } else {
187
+ throw error;
188
+ }
189
+ }
190
+ if (fileId) {
191
+ await this.drive.updateFile(fileId, {
192
+ body: previousContent + data,
193
+ mimeType: MimeTypes.TEXT
194
+ });
195
+ } else {
196
+ const {
197
+ directories,
198
+ filename
199
+ } = this.resolvePathToDirectories(path);
200
+ const parentDirectoryId = await this.findParentDirectoryId(directories, scope);
201
+ if (parentDirectoryId === null) {
202
+ throw new CloudStorageError(`Directory not found`, NativeCloudStorageErrorCode.DIRECTORY_NOT_FOUND);
203
+ }
204
+ await this.drive.createFile({
205
+ name: filename,
206
+ parents: [parentDirectoryId]
207
+ }, {
208
+ body: data,
209
+ mimeType: MimeTypes.TEXT
210
+ });
211
+ }
212
+ }
213
+ async createFile(path, data, scope, overwrite) {
214
+ let fileId;
215
+ if (overwrite) {
216
+ try {
217
+ fileId = await this.getFileId(path, scope, 'directory');
218
+ } catch (error) {
219
+ if (error instanceof CloudStorageError && error.code === NativeCloudStorageErrorCode.FILE_NOT_FOUND) {
220
+ /* do nothing, simply create the file */
221
+ } else {
222
+ throw error;
223
+ }
224
+ }
225
+ } else {
226
+ try {
227
+ await this.getFileId(path, scope, 'directory');
228
+ throw new CloudStorageError(`File ${path} already exists`, NativeCloudStorageErrorCode.FILE_ALREADY_EXISTS);
229
+ } catch (error) {
230
+ if (error instanceof CloudStorageError && error.code === NativeCloudStorageErrorCode.FILE_NOT_FOUND) {
231
+ /* do nothing, simply create the file */
232
+ } else {
233
+ throw error;
234
+ }
235
+ }
236
+ }
237
+ if (fileId) {
238
+ await this.drive.updateFile(fileId, {
239
+ body: data,
240
+ mimeType: MimeTypes.TEXT
241
+ });
242
+ } else {
243
+ const {
244
+ directories,
245
+ filename
246
+ } = this.resolvePathToDirectories(path);
247
+ const parentDirectoryId = await this.findParentDirectoryId(directories, scope);
248
+ if (parentDirectoryId === null) {
249
+ throw new CloudStorageError(`Directory not found`, NativeCloudStorageErrorCode.DIRECTORY_NOT_FOUND);
250
+ }
251
+ await this.drive.createFile({
252
+ name: filename,
253
+ parents: [parentDirectoryId]
254
+ }, {
255
+ body: data,
256
+ mimeType: MimeTypes.TEXT
257
+ });
258
+ }
259
+ }
260
+ async listFiles(path, scope) {
261
+ const parentDirectoryId = this.isRootPath(path) ? await this.getQueryRootParentId(scope) : await this.getFileId(path, scope);
262
+ const files = await this.findFilesByParent(parentDirectoryId, scope);
263
+ return [...new Set(files.map(f => f.name))];
264
+ }
265
+ async createDirectory(path, scope) {
266
+ if (this.isRootPath(path)) {
267
+ throw new CloudStorageError(`Directory ${path} already exists`, NativeCloudStorageErrorCode.FILE_ALREADY_EXISTS);
268
+ }
269
+ try {
270
+ await this.getFileId(path, scope);
271
+ throw new CloudStorageError(`File ${path} already exists`, NativeCloudStorageErrorCode.FILE_ALREADY_EXISTS);
272
+ } catch (error) {
273
+ if (error instanceof CloudStorageError && error.code === NativeCloudStorageErrorCode.FILE_NOT_FOUND) {
274
+ /* do nothing, simply create the directory */
275
+ } else if (error instanceof CloudStorageError && error.code === NativeCloudStorageErrorCode.PATH_IS_DIRECTORY) {
276
+ throw new CloudStorageError(`Directory ${path} already exists`, NativeCloudStorageErrorCode.FILE_ALREADY_EXISTS);
277
+ } else {
278
+ throw error;
279
+ }
280
+ }
281
+ const {
282
+ directories,
283
+ filename
284
+ } = this.resolvePathToDirectories(path);
285
+ const parentDirectoryId = await this.findParentDirectoryId(directories, scope);
286
+ if (parentDirectoryId === null) {
287
+ throw new CloudStorageError(`Directory not found`, NativeCloudStorageErrorCode.DIRECTORY_NOT_FOUND);
288
+ }
289
+ await this.drive.createDirectory({
290
+ name: filename,
291
+ parents: [parentDirectoryId]
292
+ });
293
+ }
294
+ async readFile(path, scope) {
295
+ const fileId = await this.getFileId(path, scope, 'directory');
296
+ const content = await this.drive.getFileText(fileId);
297
+ return content;
298
+ }
299
+ async triggerSync(_path, _scope) {
300
+ // Triggering file synchronization in Google Drive is not necessary / possible, as they need to be downloaded on every read operation via the API anyway
301
+ return;
302
+ }
303
+ async deleteFile(path, scope) {
304
+ // if trying to pass a directory, throw an error
305
+ const fileId = await this.getFileId(path, scope, 'directory');
306
+ await this.drive.deleteFile(fileId);
307
+ }
308
+ async deleteDirectory(path, recursive, scope) {
309
+ // if trying to pass a file, throw an error
310
+ const fileId = await this.getFileId(path, scope, 'file');
311
+ if (!recursive) {
312
+ // check if the directory is empty
313
+ const filesInDirectory = await this.findFilesByParent(fileId, scope);
314
+ if (filesInDirectory.length > 0) {
315
+ throw new CloudStorageError(`Directory ${path} is not empty`, NativeCloudStorageErrorCode.DELETE_ERROR, filesInDirectory);
316
+ }
317
+ }
318
+ await this.drive.deleteFile(fileId);
319
+ }
320
+ async statFile(path, scope) {
321
+ const fileId = await this.getFileId(path, scope, false);
322
+ const file = await this.drive.getFile(fileId);
323
+ return {
324
+ size: file.size ?? 0,
325
+ birthtimeMs: new Date(file.createdTime).getTime(),
326
+ mtimeMs: new Date(file.modifiedTime).getTime(),
327
+ isDirectory: file.mimeType === MimeTypes.FOLDER,
328
+ isFile: file.mimeType !== MimeTypes.FOLDER
329
+ };
330
+ }
331
+ async downloadFile(remotePath, localPath, scope) {
332
+ const fileId = await this.getFileId(remotePath, scope, 'directory');
333
+ try {
334
+ await this.drive.downloadFile(fileId, localPath);
335
+ } catch (error) {
336
+ if (error instanceof CloudStorageError) throw error;
337
+ throw new CloudStorageError(`Could not download file ${remotePath} to ${localPath}`, NativeCloudStorageErrorCode.UNKNOWN, error);
338
+ }
339
+ }
340
+ async uploadFile(remotePath, localPath, mimeType, scope, overwrite) {
341
+ let fileId;
342
+ if (overwrite) {
343
+ try {
344
+ fileId = await this.getFileId(remotePath, scope, 'directory');
345
+ } catch (error) {
346
+ if (error instanceof CloudStorageError && error.code === NativeCloudStorageErrorCode.FILE_NOT_FOUND) {
347
+ /* File doesn't exist -> we'll create it below */
348
+ } else {
349
+ throw error;
350
+ }
351
+ }
352
+ } else {
353
+ try {
354
+ await this.getFileId(remotePath, scope, 'directory');
355
+ throw new CloudStorageError(`File ${remotePath} already exists`, NativeCloudStorageErrorCode.FILE_ALREADY_EXISTS);
356
+ } catch (error) {
357
+ if (error instanceof CloudStorageError && error.code === NativeCloudStorageErrorCode.FILE_NOT_FOUND) {
358
+ /* not found -> ok, we'll create */
359
+ } else if (error instanceof CloudStorageError) {
360
+ throw error;
361
+ } else {
362
+ throw error;
363
+ }
364
+ }
365
+ }
366
+ if (fileId) {
367
+ // Overwrite existing file
368
+ await this.drive.updateFile(fileId, {
369
+ mimeType,
370
+ localPath
371
+ });
372
+ } else {
373
+ // Need to create a new file first
374
+ const {
375
+ directories,
376
+ filename
377
+ } = this.resolvePathToDirectories(remotePath);
378
+ const parentDirectoryId = await this.findParentDirectoryId(directories, scope);
379
+ if (parentDirectoryId === null) {
380
+ throw new CloudStorageError(`Directory not found`, NativeCloudStorageErrorCode.DIRECTORY_NOT_FOUND);
381
+ }
382
+ await this.drive.createFile({
383
+ name: filename,
384
+ parents: [parentDirectoryId]
385
+ }, {
386
+ mimeType,
387
+ localPath
388
+ });
389
+ }
390
+ }
391
+ }
392
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["NativeCloudStorageErrorCode","CloudStorageError","MimeTypes","GoogleDriveApiClient","GoogleDriveHttpError","GoogleDrive","constructor","options","drive","Proxy","get","target","property","allowedFunctions","includes","toString","accessToken","length","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","FOLDER","listFiles","findFilesByNameAndParent","findFilesByParent","findParentDirectoryId","directoryTree","parentDirectoryId","directoryName","id","files","file","parents","some","candidate","checkIfMultipleFilesWithSameName","strictFilenames","map","f","join","MULTIPLE_FILES_SAME_NAME","getFileId","throwIf","PATH_IS_DIRECTORY","rootDirectoryId","getFile","FILE_NOT_FOUND","mimeType","error","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"],"sourceRoot":"../../../../src","sources":["storages/google-drive/index.ts"],"mappings":";;AAAA,SACEA,2BAA2B,QAItB,oBAAoB;AAC3B,OAAOC,iBAAiB,MAAM,iCAAiC;AAC/D,SAASC,SAAS,QAAyD,SAAS;AACpF,OAAOC,oBAAoB,IAAIC,oBAAoB,QAAQ,UAAU;AAGrE;AACA;AACA;AACA,eAAe,MAAMC,WAAW,CAA0B;EAIxDC,WAAWA,CAACC,OAAiE,EAAE;IAC7E,IAAI,CAACA,OAAO,GAAGA,OAAO;IACtB,IAAI,CAACC,KAAK,GAAG,IAAIL,oBAAoB,CAACI,OAAO,CAAC;IAE9C,OAAO,IAAIE,KAAK,CAAC,IAAI,EAAE;MACrB;MACAC,GAAGA,CAACC,MAAmB,EAAEC,QAA2B,EAAE;QACpD,MAAMC,gBAAgB,GAA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ACF;AACF","ignoreList":[]}
@@ -0,0 +1 @@
1
+ {"version":3,"names":["MimeTypes"],"sourceRoot":"../../../../src","sources":["storages/google-drive/types.ts"],"mappings":";;AAEA,WAAYA,SAAS,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","CloudStorageProvider"],"sourceRoot":"../../../src","sources":["types/main.ts"],"mappings":";;AAAA;;AAKA,WAAYA,iBAAiB,0BAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAA,OAAjBA,iBAAiB;AAAA;AAe7B,WAAYC,oBAAoB,0BAApBA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;EAAA,OAApBA,oBAAoB;AAAA","ignoreList":[]}
1
+ {"version":3,"names":["CloudStorageScope","CloudStorageProvider"],"sourceRoot":"../../../src","sources":["types/main.ts"],"mappings":";;AAAA;;AAKA,WAAYA,iBAAiB,0BAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAA,OAAjBA,iBAAiB;AAAA;AAiB7B,WAAYC,oBAAoB,0BAApBA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;EAAA,OAApBA,oBAAoB;AAAA","ignoreList":[]}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ export let NativeCloudStorageErrorCode = /*#__PURE__*/function (NativeCloudStorageErrorCode) {
4
+ NativeCloudStorageErrorCode["INVALID_SCOPE"] = "ERR_INVALID_SCOPE";
5
+ NativeCloudStorageErrorCode["FILE_NOT_FOUND"] = "ERR_FILE_NOT_FOUND";
6
+ NativeCloudStorageErrorCode["PATH_IS_FILE"] = "ERR_PATH_IS_FILE";
7
+ NativeCloudStorageErrorCode["PATH_IS_DIRECTORY"] = "ERR_PATH_IS_DIRECTORY";
8
+ NativeCloudStorageErrorCode["DIRECTORY_NOT_FOUND"] = "ERR_DIRECTORY_NOT_FOUND";
9
+ NativeCloudStorageErrorCode["DIRECTORY_NOT_EMPTY"] = "ERR_DIRECTORY_NOT_EMPTY";
10
+ NativeCloudStorageErrorCode["FILE_ALREADY_EXISTS"] = "ERR_FILE_EXISTS";
11
+ NativeCloudStorageErrorCode["MULTIPLE_FILES_SAME_NAME"] = "ERR_MULTIPLE_FILES_SAME_NAME";
12
+ NativeCloudStorageErrorCode["AUTHENTICATION_FAILED"] = "ERR_AUTHENTICATION_FAILED";
13
+ NativeCloudStorageErrorCode["WRITE_ERROR"] = "ERR_WRITE_ERROR";
14
+ NativeCloudStorageErrorCode["READ_ERROR"] = "ERR_READ_ERROR";
15
+ NativeCloudStorageErrorCode["DELETE_ERROR"] = "ERR_DELETE_ERROR";
16
+ NativeCloudStorageErrorCode["STAT_ERROR"] = "ERR_STAT_ERROR";
17
+ NativeCloudStorageErrorCode["UNKNOWN"] = "ERR_UNKNOWN";
18
+ NativeCloudStorageErrorCode["FILE_NOT_DOWNLOADABLE"] = "ERR_FILE_NOT_DOWNLOADABLE";
19
+ NativeCloudStorageErrorCode["ACCESS_TOKEN_MISSING"] = "ERR_ACCESS_TOKEN_MISSING";
20
+ NativeCloudStorageErrorCode["INVALID_URL"] = "ERR_INVALID_URL";
21
+ NativeCloudStorageErrorCode["NETWORK_ERROR"] = "ERR_NETWORK_ERROR";
22
+ return NativeCloudStorageErrorCode;
23
+ }({});
24
+ //# sourceMappingURL=native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["NativeCloudStorageErrorCode"],"sourceRoot":"../../../src","sources":["types/native.ts"],"mappings":";;AAUA,WAAYA,2BAA2B,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":[]}
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ /* eslint-disable @typescript-eslint/no-explicit-any */
4
+
3
5
  class CloudStorageError extends Error {
4
6
  constructor(message, code, details) {
5
7
  super(message);
@@ -8,4 +10,4 @@ class CloudStorageError extends Error {
8
10
  }
9
11
  }
10
12
  export default CloudStorageError;
11
- //# sourceMappingURL=CloudStorageError.js.map
13
+ //# sourceMappingURL=cloud-storage-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["CloudStorageError","Error","constructor","message","code","details"],"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;AAEA,eAAeL,iBAAiB","ignoreList":[]}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ import { Platform } from 'react-native';
4
+ import { CloudStorageProvider, CloudStorageScope } from '../types/main';
5
+ export const LINKING_ERROR = `The package 'react-native-cloud-storage' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
6
+ ios: "- You have run 'pod install'\n",
7
+ default: ''
8
+ }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
9
+ export const DEFAULT_PROVIDER_OPTIONS = {
10
+ [CloudStorageProvider.ICloud]: {
11
+ scope: CloudStorageScope.AppData,
12
+ documentsMode: 'icloud'
13
+ },
14
+ [CloudStorageProvider.GoogleDrive]: {
15
+ scope: CloudStorageScope.AppData,
16
+ accessToken: null,
17
+ strictFilenames: false,
18
+ timeout: 3000
19
+ }
20
+ };
21
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Platform","CloudStorageProvider","CloudStorageScope","LINKING_ERROR","select","ios","default","DEFAULT_PROVIDER_OPTIONS","ICloud","scope","AppData","documentsMode","GoogleDrive","accessToken","strictFilenames","timeout"],"sourceRoot":"../../../src","sources":["utils/constants.ts"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,cAAc;AACvC,SAASC,oBAAoB,EAA+BC,iBAAiB,QAAsB,eAAe;AAElH,OAAO,MAAMC,aAAa,GACxB,qFAAqF,GACrFH,QAAQ,CAACI,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,OAAO,MAAMC,wBAAmE,GAAG;EACjF,CAACN,oBAAoB,CAACO,MAAM,GAAG;IAC7BC,KAAK,EAAEP,iBAAiB,CAACQ,OAAO;IAChCC,aAAa,EAAE;EACjB,CAAC;EACD,CAACV,oBAAoB,CAACW,WAAW,GAAG;IAClCH,KAAK,EAAEP,iBAAiB,CAACQ,OAAO;IAChCG,WAAW,EAAE,IAAI;IACjBC,eAAe,EAAE,KAAK;IACtBC,OAAO,EAAE;EACX;AACF,CAAC","ignoreList":[]}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ import NativeCloudStorageLocalFileSystem from '../specs/NativeCloudStorageLocalFileSystem';
4
+ import { createProxiedNativeModule } from '../utils/native';
5
+ import { LINKING_ERROR } from './constants';
6
+ const NativeLocalFileSystem = createProxiedNativeModule(NativeCloudStorageLocalFileSystem);
7
+ export const localFileSystem = NativeLocalFileSystem ?? new Proxy({}, {
8
+ get() {
9
+ throw new Error(LINKING_ERROR);
10
+ }
11
+ });
12
+ //# sourceMappingURL=local-fs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["NativeCloudStorageLocalFileSystem","createProxiedNativeModule","LINKING_ERROR","NativeLocalFileSystem","localFileSystem","Proxy","get","Error"],"sourceRoot":"../../../src","sources":["utils/local-fs.ts"],"mappings":";;AAAA,OAAOA,iCAAiC,MAAM,4CAA4C;AAE1F,SAASC,yBAAyB,QAAQ,iBAAiB;AAC3D,SAASC,aAAa,QAAQ,aAAa;AAE3C,MAAMC,qBAAqB,GAAGF,yBAAyB,CACrDD,iCACF,CAAC;AAED,OAAO,MAAMI,eAAe,GAC1BD,qBAAqB,IACpB,IAAIE,KAAK,CACR,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACL,aAAa,CAAC;EAChC;AACF,CACF,CAA4B","ignoreList":[]}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ import { NativeCloudStorageErrorCode } from '../types/native';
4
+ import CloudStorageError from './cloud-storage-error';
5
+
6
+ /**
7
+ * Creates a proxied native module that wraps thrown errors in a CloudStorageError.
8
+ * @param nativeModule The native module to proxy.
9
+ * @returns The proxied native module.
10
+ */
11
+ export const createProxiedNativeModule = nativeModule => {
12
+ if (!nativeModule) return null;
13
+ return new Proxy(nativeModule, {
14
+ get(target, property, receiver) {
15
+ const originalValue = Reflect.get(target, property, receiver);
16
+ if (typeof originalValue === 'function') {
17
+ return async (...arguments_) => {
18
+ try {
19
+ return await Reflect.apply(originalValue, target, arguments_);
20
+ } catch (error) {
21
+ const error_ = typeof error === 'object' && error !== null && 'code' in error && typeof error.code === 'string' && Object.values(NativeCloudStorageErrorCode).includes(error.code) ? new CloudStorageError('message' in error && typeof error.message === 'string' ? error.message : 'Unknown error', error.code) : new CloudStorageError('Unknown error', NativeCloudStorageErrorCode.UNKNOWN, error);
22
+ throw error_;
23
+ }
24
+ };
25
+ }
26
+ return originalValue;
27
+ }
28
+ });
29
+ };
30
+ //# sourceMappingURL=native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["NativeCloudStorageErrorCode","CloudStorageError","createProxiedNativeModule","nativeModule","Proxy","get","target","property","receiver","originalValue","Reflect","arguments_","apply","error","error_","code","Object","values","includes","message","UNKNOWN"],"sourceRoot":"../../../src","sources":["utils/native.ts"],"mappings":";;AAAA,SAASA,2BAA2B,QAAQ,iBAAiB;AAC7D,OAAOC,iBAAiB,MAAM,uBAAuB;;AAErD;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,yBAAyB,GAAsBC,YAAkC,IAAe;EAC3G,IAAI,CAACA,YAAY,EAAE,OAAO,IAAI;EAE9B,OAAO,IAAIC,KAAK,CAACD,YAAY,EAAE;IAC7BE,GAAGA,CAACC,MAAS,EAAEC,QAAyB,EAAEC,QAAiB,EAAE;MAC3D,MAAMC,aAAa,GAAGC,OAAO,CAACL,GAAG,CAACC,MAAM,EAAEC,QAAQ,EAAEC,QAAQ,CAAC;MAE7D,IAAI,OAAOC,aAAa,KAAK,UAAU,EAAE;QACvC,OAAO,OAAO,GAAGE,UAAqB,KAAK;UACzC,IAAI;YACF,OAAO,MAAMD,OAAO,CAACE,KAAK,CAACH,aAAa,EAAEH,MAAM,EAAEK,UAAU,CAAC;UAC/D,CAAC,CAAC,OAAOE,KAAc,EAAE;YACvB,MAAMC,MAAM,GACV,OAAOD,KAAK,KAAK,QAAQ,IACzBA,KAAK,KAAK,IAAI,IACd,MAAM,IAAIA,KAAK,IACf,OAAOA,KAAK,CAACE,IAAI,KAAK,QAAQ,IAC9BC,MAAM,CAACC,MAAM,CAACjB,2BAA2B,CAAC,CAACkB,QAAQ,CAACL,KAAK,CAACE,IAAmC,CAAC,GAC1F,IAAId,iBAAiB,CACnB,SAAS,IAAIY,KAAK,IAAI,OAAOA,KAAK,CAACM,OAAO,KAAK,QAAQ,GAAGN,KAAK,CAACM,OAAO,GAAG,eAAe,EACzFN,KAAK,CAACE,IACR,CAAC,GACD,IAAId,iBAAiB,CAAC,eAAe,EAAED,2BAA2B,CAACoB,OAAO,EAAEP,KA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