react-native-cloud-storage 2.3.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/README.md +1 -1
  2. package/android/build.gradle +1 -14
  3. package/android/src/main/java/com/voicekit/CloudStorageLocalFileSystemModule.kt +16 -20
  4. package/android/src/main/java/com/voicekit/CloudStoragePackage.kt +23 -8
  5. package/dist/commonjs/cloud-storage.js +68 -31
  6. package/dist/commonjs/cloud-storage.js.map +1 -1
  7. package/dist/commonjs/specs/NativeCloudStorageCloudKitIOS.js +9 -0
  8. package/dist/commonjs/specs/NativeCloudStorageCloudKitIOS.js.map +1 -0
  9. package/dist/commonjs/specs/NativeCloudStorageLocalFileSystem.js +9 -0
  10. package/dist/commonjs/specs/NativeCloudStorageLocalFileSystem.js.map +1 -0
  11. package/dist/commonjs/storages/cloudkit.js +5 -3
  12. package/dist/commonjs/storages/cloudkit.js.map +1 -1
  13. package/dist/commonjs/storages/google-drive/client.js +3 -2
  14. package/dist/commonjs/storages/google-drive/client.js.map +1 -1
  15. package/dist/commonjs/storages/google-drive/index.js +99 -77
  16. package/dist/commonjs/storages/google-drive/index.js.map +1 -1
  17. package/dist/commonjs/types/main.js +18 -1
  18. package/dist/commonjs/types/main.js.map +1 -1
  19. package/dist/commonjs/utils/constants.js +2 -1
  20. package/dist/commonjs/utils/constants.js.map +1 -1
  21. package/dist/commonjs/utils/local-fs.js +3 -2
  22. package/dist/commonjs/utils/local-fs.js.map +1 -1
  23. package/dist/commonjs/utils/native.js.map +1 -1
  24. package/dist/module/cloud-storage.js +70 -33
  25. package/dist/module/cloud-storage.js.map +1 -1
  26. package/dist/module/specs/NativeCloudStorageCloudKitIOS.js +5 -0
  27. package/dist/module/specs/NativeCloudStorageCloudKitIOS.js.map +1 -0
  28. package/dist/module/specs/NativeCloudStorageLocalFileSystem.js +5 -0
  29. package/dist/module/specs/NativeCloudStorageLocalFileSystem.js.map +1 -0
  30. package/dist/module/storages/cloudkit.js +3 -2
  31. package/dist/module/storages/cloudkit.js.map +1 -1
  32. package/dist/module/storages/google-drive/client.js +3 -2
  33. package/dist/module/storages/google-drive/client.js.map +1 -1
  34. package/dist/module/storages/google-drive/index.js +99 -77
  35. package/dist/module/storages/google-drive/index.js.map +1 -1
  36. package/dist/module/types/main.js +21 -1
  37. package/dist/module/types/main.js.map +1 -1
  38. package/dist/module/utils/constants.js +2 -1
  39. package/dist/module/utils/constants.js.map +1 -1
  40. package/dist/module/utils/local-fs.js +2 -2
  41. package/dist/module/utils/local-fs.js.map +1 -1
  42. package/dist/module/utils/native.js.map +1 -1
  43. package/dist/typescript/cloud-storage.d.ts +15 -6
  44. package/dist/typescript/cloud-storage.d.ts.map +1 -1
  45. package/dist/typescript/specs/NativeCloudStorageCloudKitIOS.d.ts +30 -0
  46. package/dist/typescript/specs/NativeCloudStorageCloudKitIOS.d.ts.map +1 -0
  47. package/dist/typescript/specs/NativeCloudStorageLocalFileSystem.d.ts +24 -0
  48. package/dist/typescript/specs/NativeCloudStorageLocalFileSystem.d.ts.map +1 -0
  49. package/dist/typescript/storages/cloudkit.d.ts +3 -0
  50. package/dist/typescript/storages/cloudkit.d.ts.map +1 -1
  51. package/dist/typescript/storages/google-drive/client.d.ts +1 -1
  52. package/dist/typescript/storages/google-drive/client.d.ts.map +1 -1
  53. package/dist/typescript/storages/google-drive/index.d.ts +7 -1
  54. package/dist/typescript/storages/google-drive/index.d.ts.map +1 -1
  55. package/dist/typescript/types/main.d.ts +27 -0
  56. package/dist/typescript/types/main.d.ts.map +1 -1
  57. package/dist/typescript/types/native.d.ts +6 -43
  58. package/dist/typescript/types/native.d.ts.map +1 -1
  59. package/dist/typescript/utils/constants.d.ts.map +1 -1
  60. package/dist/typescript/utils/local-fs.d.ts +1 -2
  61. package/dist/typescript/utils/local-fs.d.ts.map +1 -1
  62. package/dist/typescript/utils/native.d.ts +1 -1
  63. package/dist/typescript/utils/native.d.ts.map +1 -1
  64. package/ios/CloudStorage-Bridging-Header.h +0 -1
  65. package/ios/CloudStorageCloudKit.swift +15 -14
  66. package/ios/CloudStorageLocalFileSystem.swift +7 -6
  67. package/ios/RCTCloudStorageCloudKit.mm +218 -0
  68. package/ios/RCTCloudStorageLocalFileSystem.mm +149 -0
  69. package/ios/Utils/CloudKitUtils.swift +8 -2
  70. package/ios/Utils/FileUtils.swift +2 -4
  71. package/ios/Utils/Promise.swift +1 -0
  72. package/ios/Utils/Types.swift +1 -0
  73. package/ios/react_native_cloud_storage.h +6 -0
  74. package/package.json +31 -17
  75. package/react-native-cloud-storage.podspec +2 -0
  76. package/src/cloud-storage.ts +98 -50
  77. package/src/specs/NativeCloudStorageCloudKitIOS.ts +33 -0
  78. package/src/specs/NativeCloudStorageLocalFileSystem.ts +28 -0
  79. package/src/storages/cloudkit.ts +10 -2
  80. package/src/storages/google-drive/client.ts +2 -1
  81. package/src/storages/google-drive/index.ts +126 -120
  82. package/src/types/main.ts +29 -1
  83. package/src/types/native.ts +10 -54
  84. package/src/utils/constants.ts +1 -0
  85. package/src/utils/local-fs.ts +2 -2
  86. package/src/utils/native.ts +1 -1
  87. package/ios/CloudStorageCloudKit.m +0 -24
  88. package/ios/CloudStorageEventEmitter.m +0 -16
  89. package/ios/CloudStorageEventEmitter.swift +0 -30
  90. package/ios/CloudStorageLocalFileSystem.m +0 -15
@@ -3,13 +3,14 @@ import {
3
3
  CloudStorageScope,
4
4
  type CloudStorageFileStat,
5
5
  type CloudStorageProviderOptions,
6
+ type CloudStorageProviderOptionsValue,
6
7
  type DeepRequired,
7
8
  } from './types/main';
8
- import { NativeCloudStorageErrorCode, type NativeStorage } from './types/native';
9
+ import { NativeCloudStorageErrorCode, type NativeStorage, type NativeStorageScope } from './types/native';
9
10
  import { isProviderSupported } from './utils/helpers';
10
- import { NativeEventEmitter, NativeModules, Platform } from 'react-native';
11
+ import { Platform, type EventSubscription } from 'react-native';
11
12
  import GoogleDrive from './storages/google-drive';
12
- import { NativeCloudKit } from './storages/cloudkit';
13
+ import { NativeCloudKit, NativeCloudKitModule, type NativeCloudStorageCloudKitTurboModule } from './storages/cloudkit';
13
14
  import { DEFAULT_PROVIDER_OPTIONS, LINKING_ERROR } from './utils/constants';
14
15
  import CloudStorageError from './utils/cloud-storage-error';
15
16
 
@@ -20,16 +21,14 @@ export default class RNCloudStorage {
20
21
  options: (typeof DEFAULT_PROVIDER_OPTIONS)[keyof typeof DEFAULT_PROVIDER_OPTIONS];
21
22
  };
22
23
  private cloudAvailabilityListeners: ((available: boolean) => void)[] = [];
24
+ private cloudAvailabilitySubscription: EventSubscription | null = null;
23
25
 
24
26
  //#region Constructor and configuration
25
27
  /**
26
28
  * Creates a new RNCloudStorage instance for the given provider.
27
29
  * @param provider The provider to create the instance for. Defaults to the default provider for the current platform.
28
30
  */
29
- constructor(
30
- provider?: CloudStorageProvider,
31
- options?: CloudStorageProviderOptions[keyof CloudStorageProviderOptions]
32
- ) {
31
+ constructor(provider?: CloudStorageProvider, options?: CloudStorageProviderOptionsValue) {
33
32
  if (provider && !isProviderSupported(provider)) {
34
33
  throw new Error(`Provider ${provider} is not supported on the current platform.`);
35
34
  }
@@ -97,6 +96,49 @@ export default class RNCloudStorage {
97
96
  return this.provider.provider;
98
97
  }
99
98
 
99
+ private notifyCloudAvailabilityListeners(available: boolean): void {
100
+ for (const listener of this.cloudAvailabilityListeners) {
101
+ listener(available);
102
+ }
103
+ }
104
+
105
+ private refreshCloudAvailability(): void {
106
+ this.nativeStorage
107
+ .isCloudAvailable()
108
+ .then((available) => {
109
+ this.notifyCloudAvailabilityListeners(available);
110
+ })
111
+ .catch(() => {
112
+ // ignore errors when refreshing availability after provider changes
113
+ });
114
+ }
115
+
116
+ private getNativeCloudKitModule(): NativeCloudStorageCloudKitTurboModule | null {
117
+ return this.provider.provider === CloudStorageProvider.ICloud ? NativeCloudKitModule : null;
118
+ }
119
+
120
+ private removeCloudAvailabilitySubscription(): void {
121
+ this.cloudAvailabilitySubscription?.remove();
122
+ this.cloudAvailabilitySubscription = null;
123
+ }
124
+
125
+ private configureCloudAvailabilitySubscription(): void {
126
+ this.removeCloudAvailabilitySubscription();
127
+
128
+ if (this.cloudAvailabilityListeners.length === 0) {
129
+ return;
130
+ }
131
+
132
+ const nativeCloudKitModule = this.getNativeCloudKitModule();
133
+ if (!nativeCloudKitModule) {
134
+ return;
135
+ }
136
+
137
+ this.cloudAvailabilitySubscription = nativeCloudKitModule.onCloudAvailabilityChanged((event) => {
138
+ this.notifyCloudAvailabilityListeners(event.available);
139
+ });
140
+ }
141
+
100
142
  /**
101
143
  * Sets the current CloudStorageProvider.
102
144
  * @param provider The provider to set.
@@ -111,29 +153,15 @@ export default class RNCloudStorage {
111
153
  options: DEFAULT_PROVIDER_OPTIONS[provider],
112
154
  };
113
155
 
114
- // Emit an event to notify useIsCloudAvailable() hook consumers of the new cloud availability status
115
- this.nativeStorage.isCloudAvailable().then((available) => {
116
- for (const listener of this.cloudAvailabilityListeners) {
117
- listener(available);
118
- }
119
- });
120
-
121
- if (provider === CloudStorageProvider.ICloud) {
122
- // Listen to native cloud availability change events
123
- const eventEmitter = new NativeEventEmitter(NativeModules.CloudStorageEventEmitter);
124
- eventEmitter.addListener('RNCloudStorage.cloud.availability-changed', (event: { available: boolean }) => {
125
- for (const listener of this.cloudAvailabilityListeners) {
126
- listener(event.available);
127
- }
128
- });
129
- }
156
+ this.refreshCloudAvailability();
157
+ this.configureCloudAvailabilitySubscription();
130
158
  }
131
159
 
132
160
  /**
133
161
  * Gets the current options for the current provider.
134
162
  * @returns The current options for the current provider.
135
163
  */
136
- getProviderOptions(): CloudStorageProviderOptions[keyof CloudStorageProviderOptions] {
164
+ getProviderOptions(): CloudStorageProviderOptionsValue {
137
165
  return this.provider.options;
138
166
  }
139
167
 
@@ -141,7 +169,7 @@ export default class RNCloudStorage {
141
169
  * Sets the options for the current provider.
142
170
  * @param options The options to set for the provider.
143
171
  */
144
- setProviderOptions(options: CloudStorageProviderOptions[keyof CloudStorageProviderOptions]): void {
172
+ setProviderOptions(options: CloudStorageProviderOptionsValue): void {
145
173
  const newOptions = Object.fromEntries(Object.entries(options).filter(([_, v]) => v !== undefined));
146
174
  this.provider.options = {
147
175
  ...this.provider.options,
@@ -150,20 +178,44 @@ export default class RNCloudStorage {
150
178
 
151
179
  if (this.provider.provider === CloudStorageProvider.GoogleDrive && 'accessToken' in newOptions) {
152
180
  // Emit an event to notify useIsCloudAvailable() hook consumers of the new cloud availability status
153
- for (const listener of this.cloudAvailabilityListeners) {
154
- listener(
155
- !!(newOptions as Required<CloudStorageProviderOptions[CloudStorageProvider.GoogleDrive]>).accessToken?.length
156
- );
157
- }
181
+ this.notifyCloudAvailabilityListeners(
182
+ !!(newOptions as Required<CloudStorageProviderOptions[CloudStorageProvider.GoogleDrive]>).accessToken?.length
183
+ );
158
184
  }
159
185
  }
160
186
 
161
187
  subscribeToCloudAvailability(listener: (available: boolean) => void): void {
162
188
  this.cloudAvailabilityListeners.push(listener);
189
+
190
+ if (this.cloudAvailabilityListeners.length === 1) {
191
+ this.configureCloudAvailabilitySubscription();
192
+ this.refreshCloudAvailability();
193
+ }
163
194
  }
164
195
 
165
196
  unsubscribeFromCloudAvailability(listener: (available: boolean) => void): void {
166
197
  this.cloudAvailabilityListeners = this.cloudAvailabilityListeners.filter((l) => l !== listener);
198
+
199
+ if (this.cloudAvailabilityListeners.length === 0) {
200
+ this.removeCloudAvailabilitySubscription();
201
+ }
202
+ }
203
+
204
+ private resolveNativeScope(scope?: CloudStorageScope): NativeStorageScope {
205
+ const resolvedScope = scope ?? this.provider.options.scope;
206
+
207
+ if (this.provider.provider !== CloudStorageProvider.ICloud || resolvedScope !== CloudStorageScope.Documents) {
208
+ return resolvedScope;
209
+ }
210
+
211
+ const iCloudOptions = this.provider.options as DeepRequired<
212
+ CloudStorageProviderOptions[CloudStorageProvider.ICloud]
213
+ >;
214
+ if (iCloudOptions.documentsMode === 'legacy_sandbox') {
215
+ return 'documents_legacy';
216
+ }
217
+
218
+ return resolvedScope;
167
219
  }
168
220
  //#endregion
169
221
 
@@ -185,7 +237,7 @@ export default class RNCloudStorage {
185
237
  * @returns A promise that resolves when the data has been appended.
186
238
  */
187
239
  appendFile(path: string, data: string, scope?: CloudStorageScope): Promise<void> {
188
- return this.nativeStorage.appendToFile(path, data, scope ?? this.provider.options.scope);
240
+ return this.nativeStorage.appendToFile(path, data, this.resolveNativeScope(scope));
189
241
  }
190
242
 
191
243
  /**
@@ -195,7 +247,7 @@ export default class RNCloudStorage {
195
247
  * @returns A promise that resolves to true if the path exists, false otherwise.
196
248
  */
197
249
  exists(path: string, scope?: CloudStorageScope): Promise<boolean> {
198
- return this.nativeStorage.fileExists(path, scope ?? this.provider.options.scope);
250
+ return this.nativeStorage.fileExists(path, this.resolveNativeScope(scope));
199
251
  }
200
252
 
201
253
  /**
@@ -206,7 +258,7 @@ export default class RNCloudStorage {
206
258
  * @returns A promise that resolves when the file has been written.
207
259
  */
208
260
  writeFile(path: string, data: string, scope?: CloudStorageScope): Promise<void> {
209
- return this.nativeStorage.createFile(path, data, scope ?? this.provider.options.scope, true);
261
+ return this.nativeStorage.createFile(path, data, this.resolveNativeScope(scope), true);
210
262
  }
211
263
 
212
264
  /**
@@ -216,7 +268,7 @@ export default class RNCloudStorage {
216
268
  * @returns A promise that resolves when the directory has been created.
217
269
  */
218
270
  mkdir(path: string, scope?: CloudStorageScope): Promise<void> {
219
- return this.nativeStorage.createDirectory(path, scope ?? this.provider.options.scope);
271
+ return this.nativeStorage.createDirectory(path, this.resolveNativeScope(scope));
220
272
  }
221
273
 
222
274
  /**
@@ -226,7 +278,7 @@ export default class RNCloudStorage {
226
278
  * @returns A promise that resolves to an array of file names, excluding '.' and '..'.
227
279
  */
228
280
  readdir(path: string, scope?: CloudStorageScope): Promise<string[]> {
229
- return this.nativeStorage.listFiles(path, scope ?? this.provider.options.scope);
281
+ return this.nativeStorage.listFiles(path, this.resolveNativeScope(scope));
230
282
  }
231
283
 
232
284
  /**
@@ -236,7 +288,7 @@ export default class RNCloudStorage {
236
288
  * @returns A promise that resolves to the contents of the file.
237
289
  */
238
290
  readFile(path: string, scope?: CloudStorageScope): Promise<string> {
239
- return this.nativeStorage.readFile(path, scope ?? this.provider.options.scope);
291
+ return this.nativeStorage.readFile(path, this.resolveNativeScope(scope));
240
292
  }
241
293
 
242
294
  /**
@@ -244,9 +296,10 @@ export default class RNCloudStorage {
244
296
  * @param path The file to trigger synchronization for.
245
297
  * @param scope The directory scope the path is in. Defaults to set default scope set for the current provider.
246
298
  * @returns A promise that resolves once the synchronization has been triggered.
299
+ * @provider icloud
247
300
  */
248
301
  triggerSync(path: string, scope?: CloudStorageScope): Promise<void> {
249
- return this.nativeStorage.triggerSync(path, scope ?? this.provider.options.scope);
302
+ return this.nativeStorage.triggerSync(path, this.resolveNativeScope(scope));
250
303
  }
251
304
 
252
305
  /**
@@ -263,13 +316,7 @@ export default class RNCloudStorage {
263
316
  options: { mimeType: string },
264
317
  scope?: CloudStorageScope
265
318
  ): Promise<void> {
266
- return this.nativeStorage.uploadFile(
267
- remotePath,
268
- localPath,
269
- options.mimeType,
270
- scope ?? this.provider.options.scope,
271
- true
272
- );
319
+ return this.nativeStorage.uploadFile(remotePath, localPath, options.mimeType, this.resolveNativeScope(scope), true);
273
320
  }
274
321
 
275
322
  /**
@@ -301,7 +348,7 @@ export default class RNCloudStorage {
301
348
  if (!localPathOrScope) {
302
349
  throw new CloudStorageError('Invalid arguments provided to downloadFile', NativeCloudStorageErrorCode.UNKNOWN);
303
350
  }
304
- return this.nativeStorage.downloadFile(remotePathOrPath, localPathOrScope, scope ?? this.provider.options.scope);
351
+ return this.nativeStorage.downloadFile(remotePathOrPath, localPathOrScope, this.resolveNativeScope(scope));
305
352
  }
306
353
 
307
354
  /**
@@ -311,7 +358,7 @@ export default class RNCloudStorage {
311
358
  * @returns A promise that resolves when the file has been deleted.
312
359
  */
313
360
  unlink(path: string, scope?: CloudStorageScope): Promise<void> {
314
- return this.nativeStorage.deleteFile(path, scope ?? this.provider.options.scope);
361
+ return this.nativeStorage.deleteFile(path, this.resolveNativeScope(scope));
315
362
  }
316
363
 
317
364
  /**
@@ -322,7 +369,7 @@ export default class RNCloudStorage {
322
369
  * @returns A promise that resolves when the directory has been deleted.
323
370
  */
324
371
  rmdir(path: string, options?: { recursive?: boolean }, scope?: CloudStorageScope): Promise<void> {
325
- return this.nativeStorage.deleteDirectory(path, options?.recursive ?? false, scope ?? this.provider.options.scope);
372
+ return this.nativeStorage.deleteDirectory(path, options?.recursive ?? false, this.resolveNativeScope(scope));
326
373
  }
327
374
 
328
375
  /**
@@ -332,7 +379,7 @@ export default class RNCloudStorage {
332
379
  * @returns A promise that resolves to the CloudStorageFileStat object.
333
380
  */
334
381
  async stat(path: string, scope?: CloudStorageScope): Promise<CloudStorageFileStat> {
335
- const native = await this.nativeStorage.statFile(path, scope ?? this.provider.options.scope);
382
+ const native = await this.nativeStorage.statFile(path, this.resolveNativeScope(scope));
336
383
 
337
384
  return {
338
385
  ...native,
@@ -372,7 +419,7 @@ export default class RNCloudStorage {
372
419
  * Gets the current options for the provider of the default static instance.
373
420
  * @returns The current options for the provider of the default static instance.
374
421
  */
375
- static getProviderOptions(): CloudStorageProviderOptions[keyof CloudStorageProviderOptions] {
422
+ static getProviderOptions(): CloudStorageProviderOptionsValue {
376
423
  return RNCloudStorage.getDefaultInstance().getProviderOptions();
377
424
  }
378
425
 
@@ -380,7 +427,7 @@ export default class RNCloudStorage {
380
427
  * Sets the options for the provider of the default static instance.
381
428
  * @param options The options to set for the provider of the default static instance.
382
429
  */
383
- static setProviderOptions(options: CloudStorageProviderOptions[keyof CloudStorageProviderOptions]): void {
430
+ static setProviderOptions(options: CloudStorageProviderOptionsValue): void {
384
431
  RNCloudStorage.getDefaultInstance().setProviderOptions(options);
385
432
  }
386
433
 
@@ -460,6 +507,7 @@ export default class RNCloudStorage {
460
507
  * @param path The file to trigger synchronization for.
461
508
  * @param scope The directory scope the path is in. Defaults to the default scope set for the default static instance.
462
509
  * @returns A promise that resolves once the synchronization has been triggered.
510
+ * @provider icloud
463
511
  */
464
512
  static triggerSync(path: string, scope?: CloudStorageScope): Promise<void> {
465
513
  return RNCloudStorage.getDefaultInstance().triggerSync(path, scope);
@@ -0,0 +1,33 @@
1
+ import type { CodegenTypes, TurboModule } from 'react-native';
2
+ import { TurboModuleRegistry } from 'react-native';
3
+
4
+ export type CloudStorageFileStat = {
5
+ size: number;
6
+ birthtimeMs: number;
7
+ mtimeMs: number;
8
+ isDirectory: boolean;
9
+ isFile: boolean;
10
+ };
11
+
12
+ export type CloudAvailabilityChangedEvent = {
13
+ available: boolean;
14
+ };
15
+
16
+ export interface Spec extends TurboModule {
17
+ fileExists(path: string, scope: string): Promise<boolean>;
18
+ appendToFile(path: string, data: string, scope: string): Promise<void>;
19
+ createFile(path: string, data: string, scope: string, overwrite: boolean): Promise<void>;
20
+ createDirectory(path: string, scope: string): Promise<void>;
21
+ listFiles(path: string, scope: string): Promise<Array<string>>;
22
+ readFile(path: string, scope: string): Promise<string>;
23
+ triggerSync(path: string, scope: string): Promise<void>;
24
+ deleteFile(path: string, scope: string): Promise<void>;
25
+ deleteDirectory(path: string, recursive: boolean, scope: string): Promise<void>;
26
+ statFile(path: string, scope: string): Promise<CloudStorageFileStat>;
27
+ downloadFile(remotePath: string, localPath: string, scope: string): Promise<void>;
28
+ uploadFile(remotePath: string, localPath: string, mimeType: string, scope: string, overwrite: boolean): Promise<void>;
29
+ isCloudAvailable(): Promise<boolean>;
30
+ readonly onCloudAvailabilityChanged: CodegenTypes.EventEmitter<CloudAvailabilityChangedEvent>;
31
+ }
32
+
33
+ export default TurboModuleRegistry.get<Spec>('CloudStorageCloudKit');
@@ -0,0 +1,28 @@
1
+ import type { CodegenTypes, TurboModule } from 'react-native';
2
+ import { TurboModuleRegistry } from 'react-native';
3
+
4
+ export type LocalFileSystemConstants = {
5
+ temporaryDirectory: string;
6
+ };
7
+
8
+ export type LocalFileSystemDownloadOptions = {
9
+ headers?: CodegenTypes.UnsafeObject;
10
+ };
11
+
12
+ export type LocalFileSystemUploadOptions = {
13
+ headers?: CodegenTypes.UnsafeObject;
14
+ method?: string;
15
+ uploadType?: string;
16
+ fieldName?: string;
17
+ parameters?: CodegenTypes.UnsafeObject;
18
+ };
19
+
20
+ export interface Spec extends TurboModule {
21
+ getConstants(): LocalFileSystemConstants;
22
+ createFile(path: string, data: string): Promise<string>;
23
+ readFile(path: string): Promise<string>;
24
+ downloadFile(remoteUri: string, localPath: string, options?: LocalFileSystemDownloadOptions): Promise<void>;
25
+ uploadFile(localPath: string, remoteUri: string, options: LocalFileSystemUploadOptions): Promise<void>;
26
+ }
27
+
28
+ export default TurboModuleRegistry.get<Spec>('CloudStorageLocalFileSystem');
@@ -1,5 +1,13 @@
1
- import { NativeModules } from 'react-native';
1
+ import NativeCloudStorageCloudKitIOS, {
2
+ type Spec as NativeCloudStorageCloudKitTurboModule,
3
+ } from '../specs/NativeCloudStorageCloudKitIOS';
2
4
  import { NativeStorage } from '../types/native';
3
5
  import { createProxiedNativeModule } from '../utils/native';
4
6
 
5
- export const NativeCloudKit = createProxiedNativeModule<NativeStorage>(NativeModules.CloudStorageCloudKit);
7
+ export const NativeCloudKitModule = NativeCloudStorageCloudKitIOS;
8
+
9
+ export const NativeCloudKit = createProxiedNativeModule<NativeStorage>(
10
+ NativeCloudStorageCloudKitIOS as unknown as NativeStorage | null
11
+ );
12
+
13
+ export type { NativeCloudStorageCloudKitTurboModule };
@@ -116,7 +116,7 @@ export default class GoogleDriveApiClient {
116
116
  return body.join('');
117
117
  }
118
118
 
119
- public async listFiles(space: GoogleDriveFileSpace): Promise<GoogleDriveFile[]> {
119
+ public async listFiles(space: GoogleDriveFileSpace, query?: string): Promise<GoogleDriveFile[]> {
120
120
  const files: GoogleDriveFile[] = [];
121
121
  let pageToken: string | undefined;
122
122
  const fields = ['id', 'kind', 'mimeType', 'name', 'parents', 'spaces', 'size', 'createdTime', 'modifiedTime'];
@@ -125,6 +125,7 @@ export default class GoogleDriveApiClient {
125
125
  fields: `files(${fields.join(',')}),nextPageToken`,
126
126
  spaces: space,
127
127
  pageToken,
128
+ q: query,
128
129
  };
129
130
  const response = await this.request<GoogleDriveListOperationResponse>(`/files`, {
130
131
  queryParameters,