react-native-cloud-storage 0.1.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 (79) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +33 -0
  3. package/app.plugin.js +1 -0
  4. package/ios/CloudStorage-Bridging-Header.h +2 -0
  5. package/ios/CloudStorage.m +19 -0
  6. package/ios/CloudStorage.swift +98 -0
  7. package/ios/CloudStorage.xcodeproj/project.pbxproj +283 -0
  8. package/lib/commonjs/RNCloudStorage.js +53 -0
  9. package/lib/commonjs/RNCloudStorage.js.map +1 -0
  10. package/lib/commonjs/createRNCloudStorage.js +27 -0
  11. package/lib/commonjs/createRNCloudStorage.js.map +1 -0
  12. package/lib/commonjs/expo-plugin/withRNCloudStorage.js +14 -0
  13. package/lib/commonjs/expo-plugin/withRNCloudStorage.js.map +1 -0
  14. package/lib/commonjs/expo-plugin/withRNCloudStorageIos.js +39 -0
  15. package/lib/commonjs/expo-plugin/withRNCloudStorageIos.js.map +1 -0
  16. package/lib/commonjs/google-drive/index.js +150 -0
  17. package/lib/commonjs/google-drive/index.js.map +1 -0
  18. package/lib/commonjs/google-drive/types.js +2 -0
  19. package/lib/commonjs/google-drive/types.js.map +1 -0
  20. package/lib/commonjs/hooks/useCloudFile.js +39 -0
  21. package/lib/commonjs/hooks/useCloudFile.js.map +1 -0
  22. package/lib/commonjs/index.js +36 -0
  23. package/lib/commonjs/index.js.map +1 -0
  24. package/lib/commonjs/types/main.js +13 -0
  25. package/lib/commonjs/types/main.js.map +1 -0
  26. package/lib/commonjs/types/native.js +2 -0
  27. package/lib/commonjs/types/native.js.map +1 -0
  28. package/lib/module/RNCloudStorage.js +45 -0
  29. package/lib/module/RNCloudStorage.js.map +1 -0
  30. package/lib/module/createRNCloudStorage.js +20 -0
  31. package/lib/module/createRNCloudStorage.js.map +1 -0
  32. package/lib/module/expo-plugin/withRNCloudStorage.js +7 -0
  33. package/lib/module/expo-plugin/withRNCloudStorage.js.map +1 -0
  34. package/lib/module/expo-plugin/withRNCloudStorageIos.js +32 -0
  35. package/lib/module/expo-plugin/withRNCloudStorageIos.js.map +1 -0
  36. package/lib/module/google-drive/index.js +143 -0
  37. package/lib/module/google-drive/index.js.map +1 -0
  38. package/lib/module/google-drive/types.js +2 -0
  39. package/lib/module/google-drive/types.js.map +1 -0
  40. package/lib/module/hooks/useCloudFile.js +31 -0
  41. package/lib/module/hooks/useCloudFile.js.map +1 -0
  42. package/lib/module/index.js +5 -0
  43. package/lib/module/index.js.map +1 -0
  44. package/lib/module/types/main.js +6 -0
  45. package/lib/module/types/main.js.map +1 -0
  46. package/lib/module/types/native.js +2 -0
  47. package/lib/module/types/native.js.map +1 -0
  48. package/lib/typescript/RNCloudStorage.d.ts +35 -0
  49. package/lib/typescript/RNCloudStorage.d.ts.map +1 -0
  50. package/lib/typescript/createRNCloudStorage.d.ts +3 -0
  51. package/lib/typescript/createRNCloudStorage.d.ts.map +1 -0
  52. package/lib/typescript/expo-plugin/withRNCloudStorage.d.ts +10 -0
  53. package/lib/typescript/expo-plugin/withRNCloudStorage.d.ts.map +1 -0
  54. package/lib/typescript/expo-plugin/withRNCloudStorageIos.d.ts +4 -0
  55. package/lib/typescript/expo-plugin/withRNCloudStorageIos.d.ts.map +1 -0
  56. package/lib/typescript/google-drive/index.d.ts +19 -0
  57. package/lib/typescript/google-drive/index.d.ts.map +1 -0
  58. package/lib/typescript/google-drive/types.d.ts +54 -0
  59. package/lib/typescript/google-drive/types.d.ts.map +1 -0
  60. package/lib/typescript/hooks/useCloudFile.d.ts +8 -0
  61. package/lib/typescript/hooks/useCloudFile.d.ts.map +1 -0
  62. package/lib/typescript/index.d.ts +5 -0
  63. package/lib/typescript/index.d.ts.map +1 -0
  64. package/lib/typescript/types/main.d.ts +5 -0
  65. package/lib/typescript/types/main.d.ts.map +1 -0
  66. package/lib/typescript/types/native.d.ts +8 -0
  67. package/lib/typescript/types/native.d.ts.map +1 -0
  68. package/package.json +186 -0
  69. package/react-native-cloud-storage.podspec +35 -0
  70. package/src/RNCloudStorage.ts +50 -0
  71. package/src/createRNCloudStorage.ts +31 -0
  72. package/src/expo-plugin/withRNCloudStorage.ts +15 -0
  73. package/src/expo-plugin/withRNCloudStorageIos.ts +44 -0
  74. package/src/google-drive/index.ts +163 -0
  75. package/src/google-drive/types.ts +61 -0
  76. package/src/hooks/useCloudFile.ts +40 -0
  77. package/src/index.ts +5 -0
  78. package/src/types/main.ts +4 -0
  79. package/src/types/native.ts +8 -0
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/native.ts"],"mappings":""}
@@ -0,0 +1,35 @@
1
+ import type { StorageScope } from './types/main';
2
+ declare const RNCloudStorage: {
3
+ setGoogleDriveAccessToken: (accessToken: string) => string;
4
+ /**
5
+ * Tests whether or not the file at the given path exists.
6
+ * @param path The path to test.
7
+ * @param scope The directory scope the path is in.
8
+ * @returns A promise that resolves to true if the path exists, false otherwise.
9
+ */
10
+ exists: (path: string, scope: StorageScope) => Promise<boolean>;
11
+ /**
12
+ * Writes to the file at the given path, creating it if it doesn't exist or overwriting it if it does.
13
+ * @param path The file to write to.
14
+ * @param data The data to write.
15
+ * @param scope The directory scope the path is in.
16
+ * @returns A promise that resolves when the file has been written.
17
+ */
18
+ writeFile: (path: string, data: string, scope: StorageScope) => Promise<void>;
19
+ /**
20
+ * Reads the contents of the file at the given path.
21
+ * @param path The file to read.
22
+ * @param scope The directory scope the path is in.
23
+ * @returns A promise that resolves to the contents of the file.
24
+ */
25
+ readFile: (path: string, scope: StorageScope) => Promise<string>;
26
+ /**
27
+ * Deletes the file at the given path.
28
+ * @param path The file to delete.
29
+ * @param scope The directory scope the path is in.
30
+ * @returns A promise that resolves when the file has been deleted.
31
+ */
32
+ unlink: (path: string, scope: StorageScope) => Promise<void>;
33
+ };
34
+ export default RNCloudStorage;
35
+ //# sourceMappingURL=RNCloudStorage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RNCloudStorage.d.ts","sourceRoot":"","sources":["../../src/RNCloudStorage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAGjD,QAAA,MAAM,cAAc;6CACuB,MAAM;IAC/C;;;;;OAKG;mBACY,MAAM,SAAS,YAAY,KAAG,QAAQ,OAAO,CAAC;IAI7D;;;;;;OAMG;sBACe,MAAM,QAAQ,MAAM,SAAS,YAAY,KAAG,QAAQ,IAAI,CAAC;IAI3E;;;;;OAKG;qBACc,MAAM,SAAS,YAAY,KAAG,QAAQ,MAAM,CAAC;IAI9D;;;;;OAKG;mBACY,MAAM,SAAS,YAAY,KAAG,QAAQ,IAAI,CAAC;CAG3D,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type NativeRNCloudStorage from './types/native';
2
+ export default function createRNCloudStorage(): NativeRNCloudStorage;
3
+ //# sourceMappingURL=createRNCloudStorage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createRNCloudStorage.d.ts","sourceRoot":"","sources":["../../src/createRNCloudStorage.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,oBAAoB,MAAM,gBAAgB,CAAC;AASvD,MAAM,CAAC,OAAO,UAAU,oBAAoB,IAAI,oBAAoB,CAoBnE"}
@@ -0,0 +1,10 @@
1
+ import type { ConfigPlugin } from '@expo/config-plugins';
2
+ interface RNCloudStorageConfigPluginOptions {
3
+ /**
4
+ * The iCloud container environment to use. Defaults to 'Production'.
5
+ */
6
+ iCloudContainerEnvironment?: 'Production' | 'Development';
7
+ }
8
+ declare const withRNCloudStorage: ConfigPlugin<RNCloudStorageConfigPluginOptions>;
9
+ export default withRNCloudStorage;
10
+ //# sourceMappingURL=withRNCloudStorage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withRNCloudStorage.d.ts","sourceRoot":"","sources":["../../../src/expo-plugin/withRNCloudStorage.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAIzD,UAAU,iCAAiC;IACzC;;OAEG;IACH,0BAA0B,CAAC,EAAE,YAAY,GAAG,aAAa,CAAC;CAC3D;AACD,QAAA,MAAM,kBAAkB,EAAE,YAAY,CAAC,iCAAiC,CACY,CAAC;AAErF,eAAe,kBAAkB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { ExpoConfig } from 'expo/config';
2
+ declare const withRNCloudStorageIos: (config: ExpoConfig, iCloudContainerEnvironment: 'Production' | 'Development') => ExpoConfig;
3
+ export default withRNCloudStorageIos;
4
+ //# sourceMappingURL=withRNCloudStorageIos.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withRNCloudStorageIos.d.ts","sourceRoot":"","sources":["../../../src/expo-plugin/withRNCloudStorageIos.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAuC9C,QAAA,MAAM,qBAAqB,WAAY,UAAU,8BAA8B,YAAY,GAAG,aAAa,eACY,CAAC;AAExH,eAAe,qBAAqB,CAAC"}
@@ -0,0 +1,19 @@
1
+ import type NativeRNCloudStorage from '../types/native';
2
+ import type { NativeRNCloudStorageScope } from '../types/native';
3
+ declare class GoogleDriveApiClient implements NativeRNCloudStorage {
4
+ private static drive;
5
+ constructor();
6
+ static set accessToken(accessToken: string);
7
+ static get accessToken(): string;
8
+ private getRootDirectory;
9
+ private resolvePathToDirectories;
10
+ private findParentDirectoryId;
11
+ private listFiles;
12
+ private getFileId;
13
+ fileExists(path: string, scope: NativeRNCloudStorageScope): Promise<boolean>;
14
+ createFile(path: string, data: string, scope: NativeRNCloudStorageScope, overwrite: boolean): Promise<void>;
15
+ readFile(path: string, scope: NativeRNCloudStorageScope): Promise<string>;
16
+ deleteFile(path: string, scope: NativeRNCloudStorageScope): Promise<void>;
17
+ }
18
+ export default GoogleDriveApiClient;
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/google-drive/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,oBAAoB,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAGjE,cAAM,oBAAqB,YAAW,oBAAoB;IACxD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAwB;;IAmB5C,WAAkB,WAAW,CAAC,WAAW,EAAE,MAAM,EAEhD;IAED,WAAkB,WAAW,IAAI,MAAM,CAEtC;IAED,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,wBAAwB;IAQhC,OAAO,CAAC,qBAAqB;YAsCf,SAAS;YAST,SAAS;IAgBjB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,OAAO,CAAC;IAU5E,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,yBAAyB,EAAE,SAAS,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IA2B3G,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,MAAM,CAAC;IAMzE,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;CAIhF;AAED,eAAe,oBAAoB,CAAC"}
@@ -0,0 +1,54 @@
1
+ export interface GoogleDriveFile {
2
+ id: string;
3
+ kind: 'drive#file';
4
+ mimeType: string;
5
+ name: string;
6
+ parents: string[];
7
+ spaces: ('appDataFolder' | 'drive')[];
8
+ }
9
+ export interface GoogleDriveListOperationQueryParameters {
10
+ corpora?: 'user' | 'drive' | 'domain' | 'allDrives';
11
+ driveId?: string;
12
+ fields?: string;
13
+ includeItemsFromAllDrives?: boolean;
14
+ includePermissionsForView?: 'published';
15
+ orderBy?: string;
16
+ pageSize?: number;
17
+ pageToken?: string;
18
+ q?: string;
19
+ spaces?: string;
20
+ supportsAllDrives?: boolean;
21
+ }
22
+ export interface GoogleDriveListOperationResponse {
23
+ files: GoogleDriveFile[];
24
+ incompleteSearch: boolean;
25
+ kind: 'drive#fileList';
26
+ nextPageToken: string;
27
+ }
28
+ export interface GoogleDriveDeleteOperationQueryParameters {
29
+ supportsAllDrives?: boolean;
30
+ }
31
+ export interface GoogleDriveGetOperationQueryParameters {
32
+ acknowledgeAbuse?: boolean;
33
+ fields?: string;
34
+ includeLabels?: string;
35
+ includePermissionsForView?: 'published';
36
+ supportsAllDrives?: boolean;
37
+ alt?: 'media';
38
+ }
39
+ export interface GoogleDriveCreateOperationRequestBody {
40
+ name?: string;
41
+ mimeType?: string;
42
+ parents?: string[];
43
+ }
44
+ export interface GoogleDriveCreateOperationQueryParameters {
45
+ uploadType: 'media' | 'multipart' | 'resumable';
46
+ ignoreDefaultVisibility?: boolean;
47
+ includeLabels?: string;
48
+ includePermissionsForView?: 'published';
49
+ keepRevisionForever?: boolean;
50
+ ocrLanguage?: string;
51
+ supportsAllDrives?: boolean;
52
+ useContentAsIndexableText?: boolean;
53
+ }
54
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/google-drive/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,YAAY,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,EAAE,CAAC,eAAe,GAAG,OAAO,CAAC,EAAE,CAAC;CACvC;AAED,MAAM,WAAW,uCAAuC;IACtD,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,WAAW,CAAC;IACpD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,yBAAyB,CAAC,EAAE,WAAW,CAAC;IAExC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,CAAC,CAAC,EAAE,MAAM,CAAC;IAEX,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,MAAM,WAAW,gCAAgC;IAC/C,KAAK,EAAE,eAAe,EAAE,CAAC;IACzB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,IAAI,EAAE,gBAAgB,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,yCAAyC;IACxD,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,MAAM,WAAW,sCAAsC;IACrD,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,yBAAyB,CAAC,EAAE,WAAW,CAAC;IACxC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,qCAAqC;IACpD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,yCAAyC;IACxD,UAAU,EAAE,OAAO,GAAG,WAAW,GAAG,WAAW,CAAC;IAChD,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,yBAAyB,CAAC,EAAE,WAAW,CAAC;IACxC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,yBAAyB,CAAC,EAAE,OAAO,CAAC;CACrC"}
@@ -0,0 +1,8 @@
1
+ import type { StorageScope } from '../types/main';
2
+ export declare const useCloudFile: (path: string, scope: StorageScope) => {
3
+ content: string | null;
4
+ read: () => Promise<void>;
5
+ update: (newContent: string) => Promise<void>;
6
+ remove: () => Promise<void>;
7
+ };
8
+ //# sourceMappingURL=useCloudFile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCloudFile.d.ts","sourceRoot":"","sources":["../../../src/hooks/useCloudFile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAIlD,eAAO,MAAM,YAAY,SAAU,MAAM,SAAS,YAAY;;;yBAiBvC,MAAM;;CAkB5B,CAAC"}
@@ -0,0 +1,5 @@
1
+ import RNCloudStorage from './RNCloudStorage';
2
+ export * from './types/main';
3
+ export * from './hooks/useCloudFile';
4
+ export default RNCloudStorage;
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AAErC,eAAe,cAAc,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare enum StorageScope {
2
+ Documents = "documents",
3
+ Hidden = "hidden"
4
+ }
5
+ //# sourceMappingURL=main.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/types/main.ts"],"names":[],"mappings":"AAAA,oBAAY,YAAY;IACtB,SAAS,cAAc;IACvB,MAAM,WAAW;CAClB"}
@@ -0,0 +1,8 @@
1
+ export type NativeRNCloudStorageScope = 'documents' | 'hidden';
2
+ export default interface NativeRNCloudStorage {
3
+ fileExists: (path: string, scope: NativeRNCloudStorageScope) => Promise<boolean>;
4
+ createFile: (path: string, data: string, scope: NativeRNCloudStorageScope, overwrite: boolean) => Promise<void>;
5
+ readFile: (path: string, scope: NativeRNCloudStorageScope) => Promise<string>;
6
+ deleteFile: (path: string, scope: NativeRNCloudStorageScope) => Promise<void>;
7
+ }
8
+ //# sourceMappingURL=native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../../../src/types/native.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,yBAAyB,GAAG,WAAW,GAAG,QAAQ,CAAC;AAE/D,MAAM,CAAC,OAAO,WAAW,oBAAoB;IAC3C,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,yBAAyB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACjF,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,yBAAyB,EAAE,SAAS,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAChH,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,yBAAyB,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAC9E,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,yBAAyB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/E"}
package/package.json ADDED
@@ -0,0 +1,186 @@
1
+ {
2
+ "name": "react-native-cloud-storage",
3
+ "version": "0.1.1",
4
+ "description": "test",
5
+ "main": "lib/commonjs/index",
6
+ "module": "lib/module/index",
7
+ "types": "lib/typescript/index.d.ts",
8
+ "react-native": "src/index",
9
+ "source": "src/index",
10
+ "files": [
11
+ "src",
12
+ "lib",
13
+ "android",
14
+ "ios",
15
+ "cpp",
16
+ "*.podspec",
17
+ "app.plugin.js",
18
+ "!lib/typescript/example",
19
+ "!ios/build",
20
+ "!android/build",
21
+ "!android/gradle",
22
+ "!android/gradlew",
23
+ "!android/gradlew.bat",
24
+ "!android/local.properties",
25
+ "!**/__tests__",
26
+ "!**/__fixtures__",
27
+ "!**/__mocks__",
28
+ "!**/.*"
29
+ ],
30
+ "scripts": {
31
+ "test": "jest",
32
+ "typecheck": "tsc --noEmit",
33
+ "lint": "eslint \"**/*.{js,ts,tsx}\"",
34
+ "prepack": "bob build",
35
+ "release": "release-it",
36
+ "example": "yarn --cwd example",
37
+ "docs": "yarn --cwd docs",
38
+ "bootstrap": "yarn example && yarn docs && yarn install && yarn example pods",
39
+ "clean": "del-cli android/build example/android/build example/android/app/build example/ios/build"
40
+ },
41
+ "keywords": [
42
+ "react-native",
43
+ "ios",
44
+ "android"
45
+ ],
46
+ "repository": "https://github.com/kuatsu/react-native-cloud-storage",
47
+ "author": "Kuatsu Digital Agency <hello@kuatsu.de> (https://github.com/kuatsu)",
48
+ "license": "MIT",
49
+ "bugs": {
50
+ "url": "https://github.com/kuatsu/react-native-cloud-storage/issues"
51
+ },
52
+ "homepage": "https://github.com/kuatsu/react-native-cloud-storage#readme",
53
+ "publishConfig": {
54
+ "registry": "https://registry.npmjs.org/"
55
+ },
56
+ "devDependencies": {
57
+ "@commitlint/config-conventional": "^17.0.2",
58
+ "@evilmartians/lefthook": "^1.2.2",
59
+ "@react-native-community/eslint-config": "^3.0.2",
60
+ "@release-it/conventional-changelog": "^5.0.0",
61
+ "@types/jest": "^28.1.2",
62
+ "@types/react": "~17.0.21",
63
+ "@types/react-native": "0.70.0",
64
+ "commitlint": "^17.0.2",
65
+ "del-cli": "^5.0.0",
66
+ "eslint": "^8.4.1",
67
+ "eslint-config-prettier": "^8.5.0",
68
+ "eslint-plugin-prettier": "^4.0.0",
69
+ "expo": "^47.0.0",
70
+ "jest": "^28.1.1",
71
+ "pod-install": "^0.1.0",
72
+ "prettier": "^2.0.5",
73
+ "react": "18.2.0",
74
+ "react-native": "0.71.6",
75
+ "react-native-builder-bob": "^0.20.4",
76
+ "release-it": "^15.0.0",
77
+ "typescript": "^4.5.2"
78
+ },
79
+ "resolutions": {
80
+ "@types/react": "17.0.21"
81
+ },
82
+ "peerDependencies": {
83
+ "expo": ">=47.0.0",
84
+ "react": "*",
85
+ "react-native": "*"
86
+ },
87
+ "peerDependenciesMeta": {
88
+ "expo": {
89
+ "optional": true
90
+ }
91
+ },
92
+ "engines": {
93
+ "node": ">= 16.0.0"
94
+ },
95
+ "packageManager": "^yarn@1.22.15",
96
+ "jest": {
97
+ "preset": "react-native",
98
+ "modulePathIgnorePatterns": [
99
+ "<rootDir>/example/node_modules",
100
+ "<rootDir>/lib/"
101
+ ]
102
+ },
103
+ "commitlint": {
104
+ "extends": [
105
+ "@commitlint/config-conventional"
106
+ ]
107
+ },
108
+ "release-it": {
109
+ "git": {
110
+ "commitMessage": "chore: release ${version}",
111
+ "tagName": "v${version}"
112
+ },
113
+ "npm": {
114
+ "publish": true
115
+ },
116
+ "github": {
117
+ "release": true
118
+ },
119
+ "plugins": {
120
+ "@release-it/conventional-changelog": {
121
+ "preset": "angular"
122
+ }
123
+ }
124
+ },
125
+ "eslintConfig": {
126
+ "root": true,
127
+ "extends": [
128
+ "@react-native-community",
129
+ "prettier"
130
+ ],
131
+ "rules": {
132
+ "prettier/prettier": [
133
+ "error",
134
+ {
135
+ "printWidth": 120,
136
+ "tabWidth": 2,
137
+ "useTabs": false,
138
+ "semi": true,
139
+ "singleQuote": true,
140
+ "quoteProps": "consistent",
141
+ "jsxSingleQuote": false,
142
+ "trailingComma": "es5",
143
+ "bracketSpacing": true,
144
+ "bracketSameLine": true,
145
+ "arrowParens": "always",
146
+ "endOfLine": "lf"
147
+ }
148
+ ]
149
+ }
150
+ },
151
+ "eslintIgnore": [
152
+ "node_modules/",
153
+ "lib/"
154
+ ],
155
+ "prettier": {
156
+ "printWidth": 120,
157
+ "tabWidth": 2,
158
+ "useTabs": false,
159
+ "semi": true,
160
+ "singleQuote": true,
161
+ "quoteProps": "consistent",
162
+ "jsxSingleQuote": false,
163
+ "trailingComma": "es5",
164
+ "bracketSpacing": true,
165
+ "bracketSameLine": true,
166
+ "arrowParens": "always",
167
+ "endOfLine": "lf"
168
+ },
169
+ "react-native-builder-bob": {
170
+ "source": "src",
171
+ "output": "lib",
172
+ "targets": [
173
+ "commonjs",
174
+ "module",
175
+ [
176
+ "typescript",
177
+ {
178
+ "project": "tsconfig.build.json"
179
+ }
180
+ ]
181
+ ]
182
+ },
183
+ "dependencies": {
184
+ "react-native-google-drive-api-wrapper-js": "^1.2.3"
185
+ }
186
+ }
@@ -0,0 +1,35 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+ folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
5
+
6
+ Pod::Spec.new do |s|
7
+ s.name = "react-native-cloud-storage"
8
+ s.version = package["version"]
9
+ s.summary = package["description"]
10
+ s.homepage = package["homepage"]
11
+ s.license = package["license"]
12
+ s.authors = package["author"]
13
+
14
+ s.platforms = { :ios => "11.0" }
15
+ s.source = { :git => "https://github.com/kuatsu/react-native-cloud-storage.git", :tag => "#{s.version}" }
16
+
17
+ s.source_files = "ios/**/*.{h,m,mm,swift}"
18
+
19
+ s.dependency "React-Core"
20
+
21
+ # Don't install the dependencies when we run `pod install` in the old architecture.
22
+ if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
23
+ s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
24
+ s.pod_target_xcconfig = {
25
+ "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
26
+ "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
27
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
28
+ }
29
+ s.dependency "React-Codegen"
30
+ s.dependency "RCT-Folly"
31
+ s.dependency "RCTRequired"
32
+ s.dependency "RCTTypeSafety"
33
+ s.dependency "ReactCommon/turbomodule/core"
34
+ end
35
+ end
@@ -0,0 +1,50 @@
1
+ import createRNCloudStorage from './createRNCloudStorage';
2
+ import GoogleDriveApiClient from './google-drive';
3
+ import type { StorageScope } from './types/main';
4
+
5
+ const nativeInstance = createRNCloudStorage();
6
+ const RNCloudStorage = {
7
+ setGoogleDriveAccessToken: (accessToken: string) => (GoogleDriveApiClient.accessToken = accessToken),
8
+ /**
9
+ * Tests whether or not the file at the given path exists.
10
+ * @param path The path to test.
11
+ * @param scope The directory scope the path is in.
12
+ * @returns A promise that resolves to true if the path exists, false otherwise.
13
+ */
14
+ exists: (path: string, scope: StorageScope): Promise<boolean> => {
15
+ return nativeInstance.fileExists(path, scope);
16
+ },
17
+
18
+ /**
19
+ * Writes to the file at the given path, creating it if it doesn't exist or overwriting it if it does.
20
+ * @param path The file to write to.
21
+ * @param data The data to write.
22
+ * @param scope The directory scope the path is in.
23
+ * @returns A promise that resolves when the file has been written.
24
+ */
25
+ writeFile: (path: string, data: string, scope: StorageScope): Promise<void> => {
26
+ return nativeInstance.createFile(path, data, scope, true);
27
+ },
28
+
29
+ /**
30
+ * Reads the contents of the file at the given path.
31
+ * @param path The file to read.
32
+ * @param scope The directory scope the path is in.
33
+ * @returns A promise that resolves to the contents of the file.
34
+ */
35
+ readFile: (path: string, scope: StorageScope): Promise<string> => {
36
+ return nativeInstance.readFile(path, scope);
37
+ },
38
+
39
+ /**
40
+ * Deletes the file at the given path.
41
+ * @param path The file to delete.
42
+ * @param scope The directory scope the path is in.
43
+ * @returns A promise that resolves when the file has been deleted.
44
+ */
45
+ unlink: (path: string, scope: StorageScope): Promise<void> => {
46
+ return nativeInstance.deleteFile(path, scope);
47
+ },
48
+ };
49
+
50
+ export default RNCloudStorage;
@@ -0,0 +1,31 @@
1
+ import { NativeModules, Platform } from 'react-native';
2
+ import type NativeRNCloudStorage from './types/native';
3
+ import GoogleDriveApiClient from './google-drive';
4
+
5
+ const LINKING_ERROR =
6
+ `The package 'react-native-cloud-storage' doesn't seem to be linked. Make sure: \n\n` +
7
+ Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
8
+ '- You rebuilt the app after installing the package\n' +
9
+ '- You are not using Expo Go\n';
10
+
11
+ export default function createRNCloudStorage(): NativeRNCloudStorage {
12
+ if (Platform.OS === 'ios') {
13
+ return (
14
+ (NativeModules.CloudStorage as NativeRNCloudStorage) ??
15
+ new Proxy(
16
+ {},
17
+ {
18
+ get() {
19
+ throw new Error(LINKING_ERROR);
20
+ },
21
+ }
22
+ )
23
+ );
24
+ }
25
+
26
+ if (Platform.OS === 'android') {
27
+ return new GoogleDriveApiClient();
28
+ }
29
+
30
+ throw new Error('Unsupported platform');
31
+ }
@@ -0,0 +1,15 @@
1
+ import withRNCloudStorageIos from './withRNCloudStorageIos';
2
+ import type { ConfigPlugin } from '@expo/config-plugins';
3
+
4
+ // Android config plugin not needed as there's no native code to configure.
5
+
6
+ interface RNCloudStorageConfigPluginOptions {
7
+ /**
8
+ * The iCloud container environment to use. Defaults to 'Production'.
9
+ */
10
+ iCloudContainerEnvironment?: 'Production' | 'Development';
11
+ }
12
+ const withRNCloudStorage: ConfigPlugin<RNCloudStorageConfigPluginOptions> = (config, options) =>
13
+ withRNCloudStorageIos(config, options?.iCloudContainerEnvironment ?? 'Production');
14
+
15
+ export default withRNCloudStorage;
@@ -0,0 +1,44 @@
1
+ import { withEntitlementsPlist, withInfoPlist, withPlugins } from '@expo/config-plugins';
2
+ import type { ExpoConfig } from 'expo/config';
3
+
4
+ const withRNCloudStorageInfoPlist = (config: ExpoConfig) =>
5
+ withInfoPlist(config, async (newConfig) => {
6
+ if (!config.ios?.bundleIdentifier) {
7
+ throw new Error('Missing iOS bundle identifier');
8
+ }
9
+ const infoPlist = newConfig.modResults;
10
+ infoPlist.NSUbiquitousContainers = {
11
+ [`iCloud.${config.ios.bundleIdentifier}`]: {
12
+ NSUbiquitousContainerIsDocumentScopePublic: true,
13
+ NSUbiquitousContainerSupportedFolderLevels: 'Any',
14
+ NSUbiquitousContainerName: config.slug,
15
+ },
16
+ };
17
+
18
+ return newConfig;
19
+ });
20
+
21
+ const withRNCloudStorageEntitlementsPlist = (
22
+ config: ExpoConfig,
23
+ iCloudContainerEnvironment: 'Production' | 'Development'
24
+ ) =>
25
+ withEntitlementsPlist(config, async (newConfig) => {
26
+ if (!config.ios?.bundleIdentifier) {
27
+ throw new Error('Missing iOS bundle identifier');
28
+ }
29
+ const entitlementsPlist = newConfig.modResults;
30
+ entitlementsPlist['com.apple.developer.icloud-container-identifiers'] = [`iCloud.${config.ios.bundleIdentifier}`];
31
+ entitlementsPlist['com.apple.developer.icloud-services'] = ['CloudDocuments'];
32
+ entitlementsPlist['com.apple.developer.icloud-container-environment'] = iCloudContainerEnvironment;
33
+ entitlementsPlist['com.apple.developer.ubiquity-container-identifiers'] = [`iCloud.${config.ios.bundleIdentifier}`];
34
+ entitlementsPlist[
35
+ 'com.apple.developer.ubiquity-kvstore-identifier'
36
+ ] = `$(TeamIdentifierPrefix)${config.ios.bundleIdentifier}`;
37
+
38
+ return newConfig;
39
+ });
40
+
41
+ const withRNCloudStorageIos = (config: ExpoConfig, iCloudContainerEnvironment: 'Production' | 'Development') =>
42
+ withPlugins(config, [withRNCloudStorageInfoPlist, [withRNCloudStorageEntitlementsPlist, iCloudContainerEnvironment]]);
43
+
44
+ export default withRNCloudStorageIos;