react-native-cloud-storage 0.4.0 → 0.4.2

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 (66) hide show
  1. package/lib/commonjs/RNCloudStorage.js +2 -1
  2. package/lib/commonjs/RNCloudStorage.js.map +1 -1
  3. package/lib/commonjs/createRNCloudStorage.js +5 -5
  4. package/lib/commonjs/createRNCloudStorage.js.map +1 -1
  5. package/lib/commonjs/google-drive/index.js +12 -9
  6. package/lib/commonjs/google-drive/index.js.map +1 -1
  7. package/lib/commonjs/hooks/useCloudFile.js.map +1 -1
  8. package/lib/commonjs/hooks/useIsCloudAvailable.js +18 -15
  9. package/lib/commonjs/hooks/useIsCloudAvailable.js.map +1 -1
  10. package/lib/commonjs/index.js +7 -7
  11. package/lib/commonjs/index.js.map +1 -1
  12. package/lib/commonjs/types/main.js +6 -6
  13. package/lib/commonjs/types/main.js.map +1 -1
  14. package/lib/commonjs/types/native.js +13 -13
  15. package/lib/commonjs/types/native.js.map +1 -1
  16. package/lib/commonjs/utils/{NativeStorageError.js → CloudStorageError.js} +3 -3
  17. package/lib/commonjs/utils/CloudStorageError.js.map +1 -0
  18. package/lib/module/RNCloudStorage.js +2 -1
  19. package/lib/module/RNCloudStorage.js.map +1 -1
  20. package/lib/module/createRNCloudStorage.js +6 -6
  21. package/lib/module/createRNCloudStorage.js.map +1 -1
  22. package/lib/module/google-drive/index.js +13 -10
  23. package/lib/module/google-drive/index.js.map +1 -1
  24. package/lib/module/hooks/useCloudFile.js.map +1 -1
  25. package/lib/module/hooks/useIsCloudAvailable.js +18 -15
  26. package/lib/module/hooks/useIsCloudAvailable.js.map +1 -1
  27. package/lib/module/index.js +4 -4
  28. package/lib/module/index.js.map +1 -1
  29. package/lib/module/types/main.js +4 -4
  30. package/lib/module/types/main.js.map +1 -1
  31. package/lib/module/types/native.js +11 -11
  32. package/lib/module/types/native.js.map +1 -1
  33. package/lib/module/utils/CloudStorageError.js +9 -0
  34. package/lib/module/utils/CloudStorageError.js.map +1 -0
  35. package/lib/typescript/RNCloudStorage.d.ts +8 -7
  36. package/lib/typescript/RNCloudStorage.d.ts.map +1 -1
  37. package/lib/typescript/google-drive/index.d.ts +8 -8
  38. package/lib/typescript/google-drive/index.d.ts.map +1 -1
  39. package/lib/typescript/hooks/useCloudFile.d.ts +2 -2
  40. package/lib/typescript/hooks/useCloudFile.d.ts.map +1 -1
  41. package/lib/typescript/hooks/useIsCloudAvailable.d.ts +1 -1
  42. package/lib/typescript/hooks/useIsCloudAvailable.d.ts.map +1 -1
  43. package/lib/typescript/index.d.ts +4 -4
  44. package/lib/typescript/index.d.ts.map +1 -1
  45. package/lib/typescript/types/main.d.ts +2 -2
  46. package/lib/typescript/types/main.d.ts.map +1 -1
  47. package/lib/typescript/types/native.d.ts +8 -8
  48. package/lib/typescript/types/native.d.ts.map +1 -1
  49. package/lib/typescript/utils/CloudStorageError.d.ts +8 -0
  50. package/lib/typescript/utils/CloudStorageError.d.ts.map +1 -0
  51. package/package.json +1 -1
  52. package/src/RNCloudStorage.ts +8 -7
  53. package/src/createRNCloudStorage.ts +6 -6
  54. package/src/google-drive/index.ts +31 -26
  55. package/src/hooks/useCloudFile.ts +2 -2
  56. package/src/hooks/useIsCloudAvailable.ts +20 -15
  57. package/src/index.ts +4 -4
  58. package/src/types/main.ts +2 -2
  59. package/src/types/native.ts +8 -8
  60. package/src/utils/CloudStorageError.ts +14 -0
  61. package/lib/commonjs/utils/NativeStorageError.js.map +0 -1
  62. package/lib/module/utils/NativeStorageError.js +0 -9
  63. package/lib/module/utils/NativeStorageError.js.map +0 -1
  64. package/lib/typescript/utils/NativeStorageError.d.ts +0 -8
  65. package/lib/typescript/utils/NativeStorageError.d.ts.map +0 -1
  66. package/src/utils/NativeStorageError.ts +0 -14
@@ -1 +1 @@
1
- {"version":3,"names":["RNCloudStorage","useCallback","useEffect","useState","useCloudFile","path","scope","content","setContent","read","exists","readFile","then","update","newContent","writeFile","remove","unlink"],"sourceRoot":"../../../src","sources":["hooks/useCloudFile.ts"],"mappings":"AACA,OAAOA,cAAc,MAAM,mBAAmB;AAC9C,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAExD,OAAO,MAAMC,YAAY,GAAGA,CAACC,IAAY,EAAEC,KAAmB,KAAK;EACjE,MAAM,CAACC,OAAO,EAAEC,UAAU,CAAC,GAAGL,QAAQ,CAAgB,IAAI,CAAC;EAE3D,MAAMM,IAAI,GAAGR,WAAW,CAAC,YAAY;IACnC,MAAMS,MAAM,GAAG,MAAMV,cAAc,CAACU,MAAM,CAACL,IAAI,EAAEC,KAAK,CAAC;IACvD,IAAI,CAACI,MAAM,EAAE;MACXF,UAAU,CAAC,IAAI,CAAC;MAChB;IACF;IACAR,cAAc,CAACW,QAAQ,CAACN,IAAI,EAAEC,KAAK,CAAC,CAACM,IAAI,CAACJ,UAAU,CAAC;EACvD,CAAC,EAAE,CAACH,IAAI,EAAEC,KAAK,CAAC,CAAC;EAEjBJ,SAAS,CAAC,MAAM;IACdO,IAAI,EAAE;EACR,CAAC,EAAE,CAACA,IAAI,CAAC,CAAC;EAEV,MAAMI,MAAM,GAAGZ,WAAW,CACxB,MAAOa,UAAkB,IAAK;IAC5B,MAAMd,cAAc,CAACe,SAAS,CAACV,IAAI,EAAES,UAAU,EAAER,KAAK,CAAC;IACvDG,IAAI,EAAE;EACR,CAAC,EACD,CAACJ,IAAI,EAAEC,KAAK,EAAEG,IAAI,CAAC,CACpB;EAED,MAAMO,MAAM,GAAGf,WAAW,CAAC,YAAY;IACrC,MAAMD,cAAc,CAACiB,MAAM,CAACZ,IAAI,EAAEC,KAAK,CAAC;IACxCE,UAAU,CAAC,IAAI,CAAC;EAClB,CAAC,EAAE,CAACH,IAAI,EAAEC,KAAK,CAAC,CAAC;EAEjB,OAAO;IACLC,OAAO;IACPE,IAAI;IACJI,MAAM;IACNG;EACF,CAAC;AACH,CAAC"}
1
+ {"version":3,"names":["RNCloudStorage","useCallback","useEffect","useState","useCloudFile","path","scope","content","setContent","read","exists","readFile","then","update","newContent","writeFile","remove","unlink"],"sourceRoot":"../../../src","sources":["hooks/useCloudFile.ts"],"mappings":"AACA,OAAOA,cAAc,MAAM,mBAAmB;AAC9C,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAExD,OAAO,MAAMC,YAAY,GAAGA,CAACC,IAAY,EAAEC,KAAwB,KAAK;EACtE,MAAM,CAACC,OAAO,EAAEC,UAAU,CAAC,GAAGL,QAAQ,CAAgB,IAAI,CAAC;EAE3D,MAAMM,IAAI,GAAGR,WAAW,CAAC,YAAY;IACnC,MAAMS,MAAM,GAAG,MAAMV,cAAc,CAACU,MAAM,CAACL,IAAI,EAAEC,KAAK,CAAC;IACvD,IAAI,CAACI,MAAM,EAAE;MACXF,UAAU,CAAC,IAAI,CAAC;MAChB;IACF;IACAR,cAAc,CAACW,QAAQ,CAACN,IAAI,EAAEC,KAAK,CAAC,CAACM,IAAI,CAACJ,UAAU,CAAC;EACvD,CAAC,EAAE,CAACH,IAAI,EAAEC,KAAK,CAAC,CAAC;EAEjBJ,SAAS,CAAC,MAAM;IACdO,IAAI,EAAE;EACR,CAAC,EAAE,CAACA,IAAI,CAAC,CAAC;EAEV,MAAMI,MAAM,GAAGZ,WAAW,CACxB,MAAOa,UAAkB,IAAK;IAC5B,MAAMd,cAAc,CAACe,SAAS,CAACV,IAAI,EAAES,UAAU,EAAER,KAAK,CAAC;IACvDG,IAAI,EAAE;EACR,CAAC,EACD,CAACJ,IAAI,EAAEC,KAAK,EAAEG,IAAI,CAAC,CACpB;EAED,MAAMO,MAAM,GAAGf,WAAW,CAAC,YAAY;IACrC,MAAMD,cAAc,CAACiB,MAAM,CAACZ,IAAI,EAAEC,KAAK,CAAC;IACxCE,UAAU,CAAC,IAAI,CAAC;EAClB,CAAC,EAAE,CAACH,IAAI,EAAEC,KAAK,CAAC,CAAC;EAEjB,OAAO;IACLC,OAAO;IACPE,IAAI;IACJI,MAAM;IACNG;EACF,CAAC;AACH,CAAC"}
@@ -4,22 +4,25 @@ import RNCloudStorage from '../RNCloudStorage';
4
4
 
5
5
  // TODO: there must be a better way to do this without a timeout?
6
6
  export const useIsCloudAvailable = function () {
7
- let timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10;
8
- const [isCloudAvailable, setIsCloudAvailable] = useState(Platform.OS !== 'ios');
9
- const [firstCheck] = useState(new Date());
7
+ let iCloudTimeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10;
8
+ const [isAvailable, setIsAvailable] = useState(false);
10
9
  useEffect(() => {
11
- const checkCloudAvailability = async () => {
12
- const isAvailable = await RNCloudStorage.isCloudAvailable();
13
- if (isAvailable) {
14
- setIsCloudAvailable(true);
15
- } else if (new Date().getTime() - firstCheck.getTime() < timeout * 1000) {
16
- setTimeout(checkCloudAvailability, 500);
17
- } else {
18
- console.log('Cloud storage is not available.');
10
+ const interval = setInterval(async () => {
11
+ const newIsAvailable = await RNCloudStorage.isCloudAvailable();
12
+ setIsAvailable(newIsAvailable);
13
+ if (Platform.OS === 'ios' && newIsAvailable) {
14
+ console.log('Stopped because iCloud became available');
15
+ clearInterval(interval);
19
16
  }
20
- };
21
- checkCloudAvailability();
22
- }, [firstCheck, timeout]);
23
- return isCloudAvailable;
17
+ }, 500);
18
+ if (Platform.OS === 'ios') {
19
+ setTimeout(() => {
20
+ console.log('Stopped because of timeout');
21
+ clearInterval(interval);
22
+ }, iCloudTimeout * 1000);
23
+ }
24
+ return () => clearInterval(interval);
25
+ }, [iCloudTimeout]);
26
+ return isAvailable;
24
27
  };
25
28
  //# sourceMappingURL=useIsCloudAvailable.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["useEffect","useState","Platform","RNCloudStorage","useIsCloudAvailable","timeout","arguments","length","undefined","isCloudAvailable","setIsCloudAvailable","OS","firstCheck","Date","checkCloudAvailability","isAvailable","getTime","setTimeout","console","log"],"sourceRoot":"../../../src","sources":["hooks/useIsCloudAvailable.ts"],"mappings":"AAAA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC3C,SAASC,QAAQ,QAAQ,cAAc;AACvC,OAAOC,cAAc,MAAM,mBAAmB;;AAE9C;AACA,OAAO,MAAMC,mBAAmB,GAAG,SAAAA,CAAA,EAAkB;EAAA,IAAjBC,OAAO,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,EAAE;EAC9C,MAAM,CAACG,gBAAgB,EAAEC,mBAAmB,CAAC,GAAGT,QAAQ,CAACC,QAAQ,CAACS,EAAE,KAAK,KAAK,CAAC;EAC/E,MAAM,CAACC,UAAU,CAAC,GAAGX,QAAQ,CAAC,IAAIY,IAAI,EAAE,CAAC;EAEzCb,SAAS,CAAC,MAAM;IACd,MAAMc,sBAAsB,GAAG,MAAAA,CAAA,KAAY;MACzC,MAAMC,WAAW,GAAG,MAAMZ,cAAc,CAACM,gBAAgB,EAAE;MAC3D,IAAIM,WAAW,EAAE;QACfL,mBAAmB,CAAC,IAAI,CAAC;MAC3B,CAAC,MAAM,IAAI,IAAIG,IAAI,EAAE,CAACG,OAAO,EAAE,GAAGJ,UAAU,CAACI,OAAO,EAAE,GAAGX,OAAO,GAAG,IAAI,EAAE;QACvEY,UAAU,CAACH,sBAAsB,EAAE,GAAG,CAAC;MACzC,CAAC,MAAM;QACLI,OAAO,CAACC,GAAG,CAAC,iCAAiC,CAAC;MAChD;IACF,CAAC;IACDL,sBAAsB,EAAE;EAC1B,CAAC,EAAE,CAACF,UAAU,EAAEP,OAAO,CAAC,CAAC;EAEzB,OAAOI,gBAAgB;AACzB,CAAC"}
1
+ {"version":3,"names":["useEffect","useState","Platform","RNCloudStorage","useIsCloudAvailable","iCloudTimeout","arguments","length","undefined","isAvailable","setIsAvailable","interval","setInterval","newIsAvailable","isCloudAvailable","OS","console","log","clearInterval","setTimeout"],"sourceRoot":"../../../src","sources":["hooks/useIsCloudAvailable.ts"],"mappings":"AAAA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC3C,SAASC,QAAQ,QAAQ,cAAc;AACvC,OAAOC,cAAc,MAAM,mBAAmB;;AAE9C;AACA,OAAO,MAAMC,mBAAmB,GAAG,SAAAA,CAAA,EAAwB;EAAA,IAAvBC,aAAa,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,EAAE;EACpD,MAAM,CAACG,WAAW,EAAEC,cAAc,CAAC,GAAGT,QAAQ,CAAC,KAAK,CAAC;EAErDD,SAAS,CAAC,MAAM;IACd,MAAMW,QAAQ,GAAGC,WAAW,CAAC,YAAY;MACvC,MAAMC,cAAc,GAAG,MAAMV,cAAc,CAACW,gBAAgB,EAAE;MAC9DJ,cAAc,CAACG,cAAc,CAAC;MAC9B,IAAIX,QAAQ,CAACa,EAAE,KAAK,KAAK,IAAIF,cAAc,EAAE;QAC3CG,OAAO,CAACC,GAAG,CAAC,yCAAyC,CAAC;QACtDC,aAAa,CAACP,QAAQ,CAAC;MACzB;IACF,CAAC,EAAE,GAAG,CAAC;IAEP,IAAIT,QAAQ,CAACa,EAAE,KAAK,KAAK,EAAE;MACzBI,UAAU,CAAC,MAAM;QACfH,OAAO,CAACC,GAAG,CAAC,4BAA4B,CAAC;QACzCC,aAAa,CAACP,QAAQ,CAAC;MACzB,CAAC,EAAEN,aAAa,GAAG,IAAI,CAAC;IAC1B;IAEA,OAAO,MAAMa,aAAa,CAACP,QAAQ,CAAC;EACtC,CAAC,EAAE,CAACN,aAAa,CAAC,CAAC;EAEnB,OAAOI,WAAW;AACpB,CAAC"}
@@ -1,10 +1,10 @@
1
1
  import RNCloudStorage from './RNCloudStorage';
2
- import { NativeStorageErrorCode } from './types/native';
2
+ import { CloudStorageErrorCode } from './types/native';
3
3
  export * from './types/main';
4
4
  export * from './hooks/useCloudFile';
5
5
  export * from './hooks/useIsCloudAvailable';
6
- import NativeStorageError from './utils/NativeStorageError';
7
- export { NativeStorageError };
8
- export { NativeStorageErrorCode };
6
+ import CloudStorageError from './utils/CloudStorageError';
7
+ export { CloudStorageError };
8
+ export { CloudStorageErrorCode };
9
9
  export default RNCloudStorage;
10
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["RNCloudStorage","NativeStorageErrorCode","NativeStorageError"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,OAAOA,cAAc,MAAM,kBAAkB;AAC7C,SAASC,sBAAsB,QAAQ,gBAAgB;AACvD,cAAc,cAAc;AAC5B,cAAc,sBAAsB;AACpC,cAAc,6BAA6B;AAC3C,OAAOC,kBAAkB,MAAM,4BAA4B;AAE3D,SAASA,kBAAkB;AAC3B,SAASD,sBAAsB;AAC/B,eAAeD,cAAc"}
1
+ {"version":3,"names":["RNCloudStorage","CloudStorageErrorCode","CloudStorageError"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,OAAOA,cAAc,MAAM,kBAAkB;AAC7C,SAASC,qBAAqB,QAAQ,gBAAgB;AACtD,cAAc,cAAc;AAC5B,cAAc,sBAAsB;AACpC,cAAc,6BAA6B;AAC3C,OAAOC,iBAAiB,MAAM,2BAA2B;AAEzD,SAASA,iBAAiB;AAC1B,SAASD,qBAAqB;AAC9B,eAAeD,cAAc"}
@@ -1,6 +1,6 @@
1
- export let StorageScope = /*#__PURE__*/function (StorageScope) {
2
- StorageScope["Documents"] = "documents";
3
- StorageScope["AppData"] = "app_data";
4
- return StorageScope;
1
+ export let CloudStorageScope = /*#__PURE__*/function (CloudStorageScope) {
2
+ CloudStorageScope["Documents"] = "documents";
3
+ CloudStorageScope["AppData"] = "app_data";
4
+ return CloudStorageScope;
5
5
  }({});
6
6
  //# sourceMappingURL=main.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["StorageScope"],"sourceRoot":"../../../src","sources":["types/main.ts"],"mappings":"AAAA,WAAYA,YAAY,0BAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAA,OAAZA,YAAY;AAAA"}
1
+ {"version":3,"names":["CloudStorageScope"],"sourceRoot":"../../../src","sources":["types/main.ts"],"mappings":"AAAA,WAAYA,iBAAiB,0BAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAA,OAAjBA,iBAAiB;AAAA"}
@@ -1,13 +1,13 @@
1
- export let NativeStorageErrorCode = /*#__PURE__*/function (NativeStorageErrorCode) {
2
- NativeStorageErrorCode["FILE_NOT_FOUND"] = "ERR_FILE_NOT_FOUND";
3
- NativeStorageErrorCode["DIRECTORY_NOT_FOUND"] = "ERR_NO_DIRECTORY_FOUND";
4
- NativeStorageErrorCode["FILE_ALREADY_EXISTS"] = "ERR_FILE_EXISTS";
5
- NativeStorageErrorCode["WRITE_ERROR"] = "ERR_WRITE_ERROR";
6
- NativeStorageErrorCode["READ_ERROR"] = "ERR_READ_ERROR";
7
- NativeStorageErrorCode["DELETE_ERROR"] = "ERR_DELETE_ERROR";
8
- NativeStorageErrorCode["STAT_ERROR"] = "ERR_STAT_ERROR";
9
- NativeStorageErrorCode["UNKNOWN"] = "ERR_UNKNOWN";
10
- NativeStorageErrorCode["GOOGLE_DRIVE_ACCESS_TOKEN_MISSING"] = "ERR_GOOGLE_DRIVE_ACCESS_TOKEN_MISSING";
11
- return NativeStorageErrorCode;
1
+ export let CloudStorageErrorCode = /*#__PURE__*/function (CloudStorageErrorCode) {
2
+ CloudStorageErrorCode["FILE_NOT_FOUND"] = "ERR_FILE_NOT_FOUND";
3
+ CloudStorageErrorCode["DIRECTORY_NOT_FOUND"] = "ERR_NO_DIRECTORY_FOUND";
4
+ CloudStorageErrorCode["FILE_ALREADY_EXISTS"] = "ERR_FILE_EXISTS";
5
+ CloudStorageErrorCode["WRITE_ERROR"] = "ERR_WRITE_ERROR";
6
+ CloudStorageErrorCode["READ_ERROR"] = "ERR_READ_ERROR";
7
+ CloudStorageErrorCode["DELETE_ERROR"] = "ERR_DELETE_ERROR";
8
+ CloudStorageErrorCode["STAT_ERROR"] = "ERR_STAT_ERROR";
9
+ CloudStorageErrorCode["UNKNOWN"] = "ERR_UNKNOWN";
10
+ CloudStorageErrorCode["GOOGLE_DRIVE_ACCESS_TOKEN_MISSING"] = "ERR_GOOGLE_DRIVE_ACCESS_TOKEN_MISSING";
11
+ return CloudStorageErrorCode;
12
12
  }({});
13
13
  //# sourceMappingURL=native.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["NativeStorageErrorCode"],"sourceRoot":"../../../src","sources":["types/native.ts"],"mappings":"AAUA,WAAYA,sBAAsB,0BAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAA,OAAtBA,sBAAsB;AAAA"}
1
+ {"version":3,"names":["CloudStorageErrorCode"],"sourceRoot":"../../../src","sources":["types/native.ts"],"mappings":"AAUA,WAAYA,qBAAqB,0BAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAAA,OAArBA,qBAAqB;AAAA"}
@@ -0,0 +1,9 @@
1
+ class CloudStorageError extends Error {
2
+ constructor(message, code, details) {
3
+ super(message);
4
+ this.code = code;
5
+ this.details = details;
6
+ }
7
+ }
8
+ export default CloudStorageError;
9
+ //# sourceMappingURL=CloudStorageError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["CloudStorageError","Error","constructor","message","code","details"],"sourceRoot":"../../../src","sources":["utils/CloudStorageError.ts"],"mappings":"AAEA,MAAMA,iBAAiB,SAASC,KAAK,CAAC;EAIpCC,WAAWA,CAACC,OAAe,EAAEC,IAA2B,EAAEC,OAAa,EAAE;IACvE,KAAK,CAACF,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAGA,IAAI;IAChB,IAAI,CAACC,OAAO,GAAGA,OAAO;EACxB;AACF;AAEA,eAAeL,iBAAiB"}
@@ -1,5 +1,6 @@
1
- import type { StorageFileStat, StorageScope } from './types/main';
1
+ import type { CloudStorageFileStat, CloudStorageScope } from './types/main';
2
2
  declare const RNCloudStorage: {
3
+ getGoogleDriveAccessToken: () => string | undefined;
3
4
  setGoogleDriveAccessToken: (accessToken: string) => string;
4
5
  /**
5
6
  * Tests whether or not the cloud storage is available. Always returns true for Google Drive. iCloud may be
@@ -13,7 +14,7 @@ declare const RNCloudStorage: {
13
14
  * @param scope The directory scope the path is in.
14
15
  * @returns A promise that resolves to true if the path exists, false otherwise.
15
16
  */
16
- exists: (path: string, scope: StorageScope) => Promise<boolean>;
17
+ exists: (path: string, scope: CloudStorageScope) => Promise<boolean>;
17
18
  /**
18
19
  * Writes to the file at the given path, creating it if it doesn't exist or overwriting it if it does.
19
20
  * @param path The file to write to.
@@ -21,28 +22,28 @@ declare const RNCloudStorage: {
21
22
  * @param scope The directory scope the path is in.
22
23
  * @returns A promise that resolves when the file has been written.
23
24
  */
24
- writeFile: (path: string, data: string, scope: StorageScope) => Promise<void>;
25
+ writeFile: (path: string, data: string, scope: CloudStorageScope) => Promise<void>;
25
26
  /**
26
27
  * Reads the contents of the file at the given path.
27
28
  * @param path The file to read.
28
29
  * @param scope The directory scope the path is in.
29
30
  * @returns A promise that resolves to the contents of the file.
30
31
  */
31
- readFile: (path: string, scope: StorageScope) => Promise<string>;
32
+ readFile: (path: string, scope: CloudStorageScope) => Promise<string>;
32
33
  /**
33
34
  * Deletes the file at the given path.
34
35
  * @param path The file to delete.
35
36
  * @param scope The directory scope the path is in.
36
37
  * @returns A promise that resolves when the file has been deleted.
37
38
  */
38
- unlink: (path: string, scope: StorageScope) => Promise<void>;
39
+ unlink: (path: string, scope: CloudStorageScope) => Promise<void>;
39
40
  /**
40
41
  * Gets the size, creation time, and modification time of the file at the given path.
41
42
  * @param path The file to stat.
42
43
  * @param scope The directory scope the path is in.
43
- * @returns A promise that resolves to the StorageFileStat object.
44
+ * @returns A promise that resolves to the CloudStorageFileStat object.
44
45
  */
45
- stat: (path: string, scope: StorageScope) => Promise<StorageFileStat>;
46
+ stat: (path: string, scope: CloudStorageScope) => Promise<CloudStorageFileStat>;
46
47
  };
47
48
  export default RNCloudStorage;
48
49
  //# sourceMappingURL=RNCloudStorage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"RNCloudStorage.d.ts","sourceRoot":"","sources":["../../src/RNCloudStorage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAGlE,QAAA,MAAM,cAAc;6CACuB,MAAM;IAE/C;;;;OAIG;4BACyB,QAAQ,OAAO,CAAC;IAI5C;;;;;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;IAI1D;;;;;OAKG;iBACgB,MAAM,SAAS,YAAY,KAAG,QAAQ,eAAe,CAAC;CAW1E,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"RNCloudStorage.d.ts","sourceRoot":"","sources":["../../src/RNCloudStorage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAG5E,QAAA,MAAM,cAAc;;6CAEuB,MAAM;IAE/C;;;;OAIG;4BACyB,QAAQ,OAAO,CAAC;IAI5C;;;;;OAKG;mBACY,MAAM,SAAS,iBAAiB,KAAG,QAAQ,OAAO,CAAC;IAIlE;;;;;;OAMG;sBACe,MAAM,QAAQ,MAAM,SAAS,iBAAiB,KAAG,QAAQ,IAAI,CAAC;IAIhF;;;;;OAKG;qBACc,MAAM,SAAS,iBAAiB,KAAG,QAAQ,MAAM,CAAC;IAInE;;;;;OAKG;mBACY,MAAM,SAAS,iBAAiB,KAAG,QAAQ,IAAI,CAAC;IAI/D;;;;;OAKG;iBACgB,MAAM,SAAS,iBAAiB,KAAG,QAAQ,oBAAoB,CAAC;CAWpF,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -1,21 +1,21 @@
1
1
  import type NativeRNCloudStorage from '../types/native';
2
- import { type NativeRNCloudStorageFileStat, type NativeRNCloudStorageScope } from '../types/native';
2
+ import { type NativeRNCloudCloudStorageFileStat, type NativeRNCloudCloudStorageScope } from '../types/native';
3
3
  declare class GoogleDriveApiClient implements NativeRNCloudStorage {
4
4
  private static drive;
5
5
  constructor();
6
- static set accessToken(accessToken: string);
7
- static get accessToken(): string;
6
+ static set accessToken(accessToken: string | undefined);
7
+ static get accessToken(): string | undefined;
8
8
  isCloudAvailable: () => Promise<boolean>;
9
9
  private getRootDirectory;
10
10
  private resolvePathToDirectories;
11
11
  private findParentDirectoryId;
12
12
  private listFiles;
13
13
  private getFileId;
14
- fileExists(path: string, scope: NativeRNCloudStorageScope): Promise<boolean>;
15
- createFile(path: string, data: string, scope: NativeRNCloudStorageScope, overwrite: boolean): Promise<void>;
16
- readFile(path: string, scope: NativeRNCloudStorageScope): Promise<string>;
17
- deleteFile(path: string, scope: NativeRNCloudStorageScope): Promise<void>;
18
- statFile(path: string, scope: NativeRNCloudStorageScope): Promise<NativeRNCloudStorageFileStat>;
14
+ fileExists(path: string, scope: NativeRNCloudCloudStorageScope): Promise<boolean>;
15
+ createFile(path: string, data: string, scope: NativeRNCloudCloudStorageScope, overwrite: boolean): Promise<void>;
16
+ readFile(path: string, scope: NativeRNCloudCloudStorageScope): Promise<string>;
17
+ deleteFile(path: string, scope: NativeRNCloudCloudStorageScope): Promise<void>;
18
+ statFile(path: string, scope: NativeRNCloudCloudStorageScope): Promise<NativeRNCloudCloudStorageFileStat>;
19
19
  }
20
20
  export default GoogleDriveApiClient;
21
21
  //# sourceMappingURL=index.d.ts.map
@@ -1 +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,EAEL,KAAK,4BAA4B,EACjC,KAAK,yBAAyB,EAC/B,MAAM,iBAAiB,CAAC;AAIzB,cAAM,oBAAqB,YAAW,oBAAoB;IACxD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAwB;;IAsB5C,WAAkB,WAAW,CAAC,WAAW,EAAE,MAAM,EAEhD;IAED,WAAkB,WAAW,IAAI,MAAM,CAEtC;IAEM,gBAAgB,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAoB;IAEnE,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,wBAAwB;IAQhC,OAAO,CAAC,qBAAqB;YAiDf,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;IAKzE,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,4BAA4B,CAAC;CAatG;AAED,eAAe,oBAAoB,CAAC"}
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,EAEL,KAAK,iCAAiC,EACtC,KAAK,8BAA8B,EACpC,MAAM,iBAAiB,CAAC;AAIzB,cAAM,oBAAqB,YAAW,oBAAoB;IACxD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAwB;;IAsB5C,WAAkB,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,EAE5D;IAED,WAAkB,WAAW,IAAI,MAAM,GAAG,SAAS,CAElD;IAEM,gBAAgB,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAA0D;IAEzG,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,wBAAwB;IAQhC,OAAO,CAAC,qBAAqB;YAiDf,SAAS;YAST,SAAS;IAgBjB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,8BAA8B,GAAG,OAAO,CAAC,OAAO,CAAC;IAUjF,UAAU,CACd,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,8BAA8B,EACrC,SAAS,EAAE,OAAO,GACjB,OAAO,CAAC,IAAI,CAAC;IA2BV,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,8BAA8B,GAAG,OAAO,CAAC,MAAM,CAAC;IAM9E,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,8BAA8B,GAAG,OAAO,CAAC,IAAI,CAAC;IAK9E,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,8BAA8B,GAAG,OAAO,CAAC,iCAAiC,CAAC;CAahH;AAED,eAAe,oBAAoB,CAAC"}
@@ -1,5 +1,5 @@
1
- import type { StorageScope } from '../types/main';
2
- export declare const useCloudFile: (path: string, scope: StorageScope) => {
1
+ import type { CloudStorageScope } from '../types/main';
2
+ export declare const useCloudFile: (path: string, scope: CloudStorageScope) => {
3
3
  content: string | null;
4
4
  read: () => Promise<void>;
5
5
  update: (newContent: string) => Promise<void>;
@@ -1 +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"}
1
+ {"version":3,"file":"useCloudFile.d.ts","sourceRoot":"","sources":["../../../src/hooks/useCloudFile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAIvD,eAAO,MAAM,YAAY,SAAU,MAAM,SAAS,iBAAiB;;;yBAiB5C,MAAM;;CAkB5B,CAAC"}
@@ -1,2 +1,2 @@
1
- export declare const useIsCloudAvailable: (timeout?: number) => boolean;
1
+ export declare const useIsCloudAvailable: (iCloudTimeout?: number) => boolean;
2
2
  //# sourceMappingURL=useIsCloudAvailable.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useIsCloudAvailable.d.ts","sourceRoot":"","sources":["../../../src/hooks/useIsCloudAvailable.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,mBAAmB,+BAmB/B,CAAC"}
1
+ {"version":3,"file":"useIsCloudAvailable.d.ts","sourceRoot":"","sources":["../../../src/hooks/useIsCloudAvailable.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,mBAAmB,qCAwB/B,CAAC"}
@@ -1,10 +1,10 @@
1
1
  import RNCloudStorage from './RNCloudStorage';
2
- import { NativeStorageErrorCode } from './types/native';
2
+ import { CloudStorageErrorCode } from './types/native';
3
3
  export * from './types/main';
4
4
  export * from './hooks/useCloudFile';
5
5
  export * from './hooks/useIsCloudAvailable';
6
- import NativeStorageError from './utils/NativeStorageError';
7
- export { NativeStorageError };
8
- export { NativeStorageErrorCode };
6
+ import CloudStorageError from './utils/CloudStorageError';
7
+ export { CloudStorageError };
8
+ export { CloudStorageErrorCode };
9
9
  export default RNCloudStorage;
10
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,OAAO,kBAAkB,MAAM,4BAA4B,CAAC;AAE5D,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAC9B,OAAO,EAAE,sBAAsB,EAAE,CAAC;AAClC,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,OAAO,iBAAiB,MAAM,2BAA2B,CAAC;AAE1D,OAAO,EAAE,iBAAiB,EAAE,CAAC;AAC7B,OAAO,EAAE,qBAAqB,EAAE,CAAC;AACjC,eAAe,cAAc,CAAC"}
@@ -1,8 +1,8 @@
1
- export declare enum StorageScope {
1
+ export declare enum CloudStorageScope {
2
2
  Documents = "documents",
3
3
  AppData = "app_data"
4
4
  }
5
- export interface StorageFileStat {
5
+ export interface CloudStorageFileStat {
6
6
  size: number;
7
7
  birthtimeMs: number;
8
8
  mtimeMs: number;
@@ -1 +1 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/types/main.ts"],"names":[],"mappings":"AAAA,oBAAY,YAAY;IACtB,SAAS,cAAc;IACvB,OAAO,aAAa;CACrB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,KAAK,EAAE,IAAI,CAAC;IACZ,WAAW,EAAE,MAAM,OAAO,CAAC;IAC3B,MAAM,EAAE,MAAM,OAAO,CAAC;CACvB"}
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/types/main.ts"],"names":[],"mappings":"AAAA,oBAAY,iBAAiB;IAC3B,SAAS,cAAc;IACvB,OAAO,aAAa;CACrB;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,KAAK,EAAE,IAAI,CAAC;IACZ,WAAW,EAAE,MAAM,OAAO,CAAC;IAC3B,MAAM,EAAE,MAAM,OAAO,CAAC;CACvB"}
@@ -1,12 +1,12 @@
1
- export type NativeRNCloudStorageScope = 'documents' | 'app_data';
2
- export interface NativeRNCloudStorageFileStat {
1
+ export type NativeRNCloudCloudStorageScope = 'documents' | 'app_data';
2
+ export interface NativeRNCloudCloudStorageFileStat {
3
3
  size: number;
4
4
  birthtimeMs: number;
5
5
  mtimeMs: number;
6
6
  isDirectory: boolean;
7
7
  isFile: boolean;
8
8
  }
9
- export declare enum NativeStorageErrorCode {
9
+ export declare enum CloudStorageErrorCode {
10
10
  FILE_NOT_FOUND = "ERR_FILE_NOT_FOUND",
11
11
  DIRECTORY_NOT_FOUND = "ERR_NO_DIRECTORY_FOUND",
12
12
  FILE_ALREADY_EXISTS = "ERR_FILE_EXISTS",
@@ -18,11 +18,11 @@ export declare enum NativeStorageErrorCode {
18
18
  GOOGLE_DRIVE_ACCESS_TOKEN_MISSING = "ERR_GOOGLE_DRIVE_ACCESS_TOKEN_MISSING"
19
19
  }
20
20
  export default interface NativeRNCloudStorage {
21
- fileExists: (path: string, scope: NativeRNCloudStorageScope) => Promise<boolean>;
22
- createFile: (path: string, data: string, scope: NativeRNCloudStorageScope, overwrite: boolean) => Promise<void>;
23
- readFile: (path: string, scope: NativeRNCloudStorageScope) => Promise<string>;
24
- deleteFile: (path: string, scope: NativeRNCloudStorageScope) => Promise<void>;
25
- statFile: (path: string, scope: NativeRNCloudStorageScope) => Promise<NativeRNCloudStorageFileStat>;
21
+ fileExists: (path: string, scope: NativeRNCloudCloudStorageScope) => Promise<boolean>;
22
+ createFile: (path: string, data: string, scope: NativeRNCloudCloudStorageScope, overwrite: boolean) => Promise<void>;
23
+ readFile: (path: string, scope: NativeRNCloudCloudStorageScope) => Promise<string>;
24
+ deleteFile: (path: string, scope: NativeRNCloudCloudStorageScope) => Promise<void>;
25
+ statFile: (path: string, scope: NativeRNCloudCloudStorageScope) => Promise<NativeRNCloudCloudStorageFileStat>;
26
26
  isCloudAvailable: () => Promise<boolean>;
27
27
  }
28
28
  //# sourceMappingURL=native.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../../../src/types/native.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,yBAAyB,GAAG,WAAW,GAAG,UAAU,CAAC;AAEjE,MAAM,WAAW,4BAA4B;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,OAAO,CAAC;IACrB,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,oBAAY,sBAAsB;IAChC,cAAc,uBAAuB;IACrC,mBAAmB,2BAA2B;IAC9C,mBAAmB,oBAAoB;IACvC,WAAW,oBAAoB;IAC/B,UAAU,mBAAmB;IAC7B,YAAY,qBAAqB;IACjC,UAAU,mBAAmB;IAC7B,OAAO,gBAAgB;IACvB,iCAAiC,0CAA0C;CAC5E;AAED,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;IAC9E,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,yBAAyB,KAAK,OAAO,CAAC,4BAA4B,CAAC,CAAC;IACpG,gBAAgB,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;CAC1C"}
1
+ {"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../../../src/types/native.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,8BAA8B,GAAG,WAAW,GAAG,UAAU,CAAC;AAEtE,MAAM,WAAW,iCAAiC;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,OAAO,CAAC;IACrB,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,oBAAY,qBAAqB;IAC/B,cAAc,uBAAuB;IACrC,mBAAmB,2BAA2B;IAC9C,mBAAmB,oBAAoB;IACvC,WAAW,oBAAoB;IAC/B,UAAU,mBAAmB;IAC7B,YAAY,qBAAqB;IACjC,UAAU,mBAAmB;IAC7B,OAAO,gBAAgB;IACvB,iCAAiC,0CAA0C;CAC5E;AAED,MAAM,CAAC,OAAO,WAAW,oBAAoB;IAC3C,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,8BAA8B,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACtF,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,8BAA8B,EAAE,SAAS,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACrH,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,8BAA8B,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACnF,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,8BAA8B,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACnF,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,8BAA8B,KAAK,OAAO,CAAC,iCAAiC,CAAC,CAAC;IAC9G,gBAAgB,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;CAC1C"}
@@ -0,0 +1,8 @@
1
+ import type { CloudStorageErrorCode } from '../types/native';
2
+ declare class CloudStorageError extends Error {
3
+ code: CloudStorageErrorCode;
4
+ details?: any;
5
+ constructor(message: string, code: CloudStorageErrorCode, details?: any);
6
+ }
7
+ export default CloudStorageError;
8
+ //# sourceMappingURL=CloudStorageError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CloudStorageError.d.ts","sourceRoot":"","sources":["../../../src/utils/CloudStorageError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAE7D,cAAM,iBAAkB,SAAQ,KAAK;IACnC,IAAI,EAAE,qBAAqB,CAAC;IAC5B,OAAO,CAAC,EAAE,GAAG,CAAC;gBAEF,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,qBAAqB,EAAE,OAAO,CAAC,EAAE,GAAG;CAKxE;AAED,eAAe,iBAAiB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-cloud-storage",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "Save to & read from iCloud and Google Drive using React Native",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -1,9 +1,10 @@
1
1
  import createRNCloudStorage from './createRNCloudStorage';
2
2
  import GoogleDriveApiClient from './google-drive';
3
- import type { StorageFileStat, StorageScope } from './types/main';
3
+ import type { CloudStorageFileStat, CloudStorageScope } from './types/main';
4
4
 
5
5
  const nativeInstance = createRNCloudStorage();
6
6
  const RNCloudStorage = {
7
+ getGoogleDriveAccessToken: () => GoogleDriveApiClient.accessToken,
7
8
  setGoogleDriveAccessToken: (accessToken: string) => (GoogleDriveApiClient.accessToken = accessToken),
8
9
 
9
10
  /**
@@ -21,7 +22,7 @@ const RNCloudStorage = {
21
22
  * @param scope The directory scope the path is in.
22
23
  * @returns A promise that resolves to true if the path exists, false otherwise.
23
24
  */
24
- exists: (path: string, scope: StorageScope): Promise<boolean> => {
25
+ exists: (path: string, scope: CloudStorageScope): Promise<boolean> => {
25
26
  return nativeInstance.fileExists(path, scope);
26
27
  },
27
28
 
@@ -32,7 +33,7 @@ const RNCloudStorage = {
32
33
  * @param scope The directory scope the path is in.
33
34
  * @returns A promise that resolves when the file has been written.
34
35
  */
35
- writeFile: (path: string, data: string, scope: StorageScope): Promise<void> => {
36
+ writeFile: (path: string, data: string, scope: CloudStorageScope): Promise<void> => {
36
37
  return nativeInstance.createFile(path, data, scope, true);
37
38
  },
38
39
 
@@ -42,7 +43,7 @@ const RNCloudStorage = {
42
43
  * @param scope The directory scope the path is in.
43
44
  * @returns A promise that resolves to the contents of the file.
44
45
  */
45
- readFile: (path: string, scope: StorageScope): Promise<string> => {
46
+ readFile: (path: string, scope: CloudStorageScope): Promise<string> => {
46
47
  return nativeInstance.readFile(path, scope);
47
48
  },
48
49
 
@@ -52,7 +53,7 @@ const RNCloudStorage = {
52
53
  * @param scope The directory scope the path is in.
53
54
  * @returns A promise that resolves when the file has been deleted.
54
55
  */
55
- unlink: (path: string, scope: StorageScope): Promise<void> => {
56
+ unlink: (path: string, scope: CloudStorageScope): Promise<void> => {
56
57
  return nativeInstance.deleteFile(path, scope);
57
58
  },
58
59
 
@@ -60,9 +61,9 @@ const RNCloudStorage = {
60
61
  * Gets the size, creation time, and modification time of the file at the given path.
61
62
  * @param path The file to stat.
62
63
  * @param scope The directory scope the path is in.
63
- * @returns A promise that resolves to the StorageFileStat object.
64
+ * @returns A promise that resolves to the CloudStorageFileStat object.
64
65
  */
65
- stat: async (path: string, scope: StorageScope): Promise<StorageFileStat> => {
66
+ stat: async (path: string, scope: CloudStorageScope): Promise<CloudStorageFileStat> => {
66
67
  const native = await nativeInstance.statFile(path, scope);
67
68
 
68
69
  return {
@@ -1,8 +1,8 @@
1
1
  import { NativeModules, Platform } from 'react-native';
2
2
  import type NativeRNCloudStorage from './types/native';
3
3
  import GoogleDriveApiClient from './google-drive';
4
- import { NativeStorageErrorCode } from './types/native';
5
- import NativeStorageError from './utils/NativeStorageError';
4
+ import { CloudStorageErrorCode } from './types/native';
5
+ import CloudStorageError from './utils/CloudStorageError';
6
6
 
7
7
  const LINKING_ERROR =
8
8
  `The package 'react-native-cloud-storage' doesn't seem to be linked. Make sure: \n\n` +
@@ -10,7 +10,7 @@ const LINKING_ERROR =
10
10
  '- You rebuilt the app after installing the package\n' +
11
11
  '- You are not using Expo Go\n';
12
12
 
13
- // proxy NativeModules.CloudStorage to catch any errors thrown by the native module and wrap them in a NativeStorageError
13
+ // proxy NativeModules.CloudStorage to catch any errors thrown by the native module and wrap them in a CloudStorageError
14
14
  const nativeIosInstance = NativeModules.CloudStorage
15
15
  ? new Proxy(NativeModules.CloudStorage, {
16
16
  get(target: NativeRNCloudStorage, prop: keyof NativeRNCloudStorage) {
@@ -21,10 +21,10 @@ const nativeIosInstance = NativeModules.CloudStorage
21
21
  // @ts-expect-error - we can't know the types of the functions and their arguments
22
22
  return await originalFunction(...args);
23
23
  } catch (error: any) {
24
- if (error?.code && Object.values(NativeStorageErrorCode).includes(error.code)) {
25
- throw new NativeStorageError(error?.message || '', error.code as NativeStorageErrorCode);
24
+ if (error?.code && Object.values(CloudStorageErrorCode).includes(error.code)) {
25
+ throw new CloudStorageError(error?.message || '', error.code as CloudStorageErrorCode);
26
26
  } else {
27
- throw new NativeStorageError('Unknown error', NativeStorageErrorCode.UNKNOWN, error);
27
+ throw new CloudStorageError('Unknown error', CloudStorageErrorCode.UNKNOWN, error);
28
28
  }
29
29
  }
30
30
  };