react-native-cloud-storage 1.5.0 → 1.5.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 (106) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +5 -6
  3. package/ios/CloudStorage.swift +262 -52
  4. package/ios/CloudStorage.xcodeproj/project.pbxproj +0 -28
  5. package/ios/CloudStorage.xcodeproj/project.xcworkspace/contents.xcworkspacedata +4 -0
  6. package/ios/CloudStorage.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  7. package/ios/CloudStorage.xcodeproj/project.xcworkspace/xcuserdata/max.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  8. package/ios/CloudStorage.xcodeproj/xcuserdata/max.xcuserdatad/xcschemes/xcschememanagement.plist +22 -0
  9. package/ios/CloudStorageEventEmitter.swift +4 -4
  10. package/lib/commonjs/RNCloudStorage.js +66 -361
  11. package/lib/commonjs/RNCloudStorage.js.map +1 -1
  12. package/lib/commonjs/createRNCloudStorage.js +48 -0
  13. package/lib/commonjs/createRNCloudStorage.js.map +1 -0
  14. package/lib/commonjs/expo-plugin/types/index.js.map +1 -1
  15. package/lib/commonjs/expo-plugin/withRNCloudStorage.js +3 -2
  16. package/lib/commonjs/expo-plugin/withRNCloudStorage.js.map +1 -1
  17. package/lib/commonjs/expo-plugin/withRNCloudStorageIos.js +7 -4
  18. package/lib/commonjs/expo-plugin/withRNCloudStorageIos.js.map +1 -1
  19. package/lib/commonjs/google-drive/client.js +20 -16
  20. package/lib/commonjs/google-drive/client.js.map +1 -1
  21. package/lib/commonjs/google-drive/index.js +64 -42
  22. package/lib/commonjs/google-drive/index.js.map +1 -1
  23. package/lib/commonjs/google-drive/types.js +2 -1
  24. package/lib/commonjs/google-drive/types.js.map +1 -1
  25. package/lib/commonjs/hooks/useCloudFile.js +17 -14
  26. package/lib/commonjs/hooks/useCloudFile.js.map +1 -1
  27. package/lib/commonjs/hooks/useIsCloudAvailable.js +21 -11
  28. package/lib/commonjs/hooks/useIsCloudAvailable.js.map +1 -1
  29. package/lib/commonjs/index.js +7 -1
  30. package/lib/commonjs/index.js.map +1 -1
  31. package/lib/commonjs/types/main.js +3 -8
  32. package/lib/commonjs/types/main.js.map +1 -1
  33. package/lib/commonjs/types/native.js +3 -3
  34. package/lib/commonjs/types/native.js.map +1 -1
  35. package/lib/commonjs/utils/CloudStorageError.js +2 -1
  36. package/lib/commonjs/utils/CloudStorageError.js.map +1 -1
  37. package/lib/commonjs/utils/helpers.js +15 -8
  38. package/lib/commonjs/utils/helpers.js.map +1 -1
  39. package/lib/module/RNCloudStorage.js +65 -362
  40. package/lib/module/RNCloudStorage.js.map +1 -1
  41. package/lib/module/createRNCloudStorage.js +41 -0
  42. package/lib/module/createRNCloudStorage.js.map +1 -0
  43. package/lib/module/expo-plugin/types/index.js +1 -1
  44. package/lib/module/expo-plugin/types/index.js.map +1 -1
  45. package/lib/module/expo-plugin/withRNCloudStorage.js +0 -2
  46. package/lib/module/expo-plugin/withRNCloudStorage.js.map +1 -1
  47. package/lib/module/expo-plugin/withRNCloudStorageIos.js +5 -5
  48. package/lib/module/expo-plugin/withRNCloudStorageIos.js.map +1 -1
  49. package/lib/module/google-drive/client.js +20 -18
  50. package/lib/module/google-drive/client.js.map +1 -1
  51. package/lib/module/google-drive/index.js +62 -41
  52. package/lib/module/google-drive/index.js.map +1 -1
  53. package/lib/module/google-drive/types.js +0 -2
  54. package/lib/module/google-drive/types.js.map +1 -1
  55. package/lib/module/hooks/useCloudFile.js +16 -15
  56. package/lib/module/hooks/useCloudFile.js.map +1 -1
  57. package/lib/module/hooks/useIsCloudAvailable.js +21 -13
  58. package/lib/module/hooks/useIsCloudAvailable.js.map +1 -1
  59. package/lib/module/index.js +5 -2
  60. package/lib/module/index.js.map +1 -1
  61. package/lib/module/types/main.js +0 -9
  62. package/lib/module/types/main.js.map +1 -1
  63. package/lib/module/types/native.js +1 -4
  64. package/lib/module/types/native.js.map +1 -1
  65. package/lib/module/utils/CloudStorageError.js +0 -2
  66. package/lib/module/utils/CloudStorageError.js.map +1 -1
  67. package/lib/module/utils/helpers.js +13 -8
  68. package/lib/module/utils/helpers.js.map +1 -1
  69. package/lib/typescript/RNCloudStorage.d.ts +39 -159
  70. package/lib/typescript/RNCloudStorage.d.ts.map +1 -1
  71. package/lib/typescript/createRNCloudStorage.d.ts +3 -0
  72. package/lib/typescript/createRNCloudStorage.d.ts.map +1 -0
  73. package/lib/typescript/google-drive/client.d.ts +3 -3
  74. package/lib/typescript/google-drive/client.d.ts.map +1 -1
  75. package/lib/typescript/google-drive/index.d.ts +18 -6
  76. package/lib/typescript/google-drive/index.d.ts.map +1 -1
  77. package/lib/typescript/hooks/useCloudFile.d.ts +7 -4
  78. package/lib/typescript/hooks/useCloudFile.d.ts.map +1 -1
  79. package/lib/typescript/hooks/useIsCloudAvailable.d.ts +2 -3
  80. package/lib/typescript/hooks/useIsCloudAvailable.d.ts.map +1 -1
  81. package/lib/typescript/index.d.ts +4 -0
  82. package/lib/typescript/index.d.ts.map +1 -1
  83. package/lib/typescript/types/main.d.ts +0 -33
  84. package/lib/typescript/types/main.d.ts.map +1 -1
  85. package/lib/typescript/types/native.d.ts +1 -2
  86. package/lib/typescript/types/native.d.ts.map +1 -1
  87. package/lib/typescript/utils/helpers.d.ts +9 -2
  88. package/lib/typescript/utils/helpers.d.ts.map +1 -1
  89. package/package.json +11 -9
  90. package/src/RNCloudStorage.ts +68 -387
  91. package/src/createRNCloudStorage.ts +53 -0
  92. package/src/google-drive/client.ts +7 -8
  93. package/src/google-drive/index.ts +63 -38
  94. package/src/hooks/useCloudFile.ts +16 -13
  95. package/src/hooks/useIsCloudAvailable.ts +25 -12
  96. package/src/index.ts +5 -0
  97. package/src/types/main.ts +0 -38
  98. package/src/types/native.ts +1 -2
  99. package/src/utils/helpers.ts +15 -8
  100. package/ios/Utils/CloudKitUtils.swift +0 -112
  101. package/ios/Utils/CloudStorageError.swift +0 -78
  102. package/ios/Utils/FileUtils.swift +0 -132
  103. package/ios/Utils/Promise.swift +0 -58
  104. package/ios/Utils/Types.swift +0 -36
  105. package/lib/commonjs/package.json +0 -1
  106. package/lib/module/package.json +0 -1
@@ -1 +1 @@
1
- {"version":3,"names":["_react","require","_RNCloudStorage","_interopRequireDefault","e","__esModule","default","useIsCloudAvailable","cloudStorageInstance","isAvailable","setIsAvailable","useState","instance","RNCloudStorage","getDefaultInstance","handleAvailabilityChange","useCallback","available","useEffect","isCloudAvailable","then","subscribeToCloudAvailability","unsubscribeFromCloudAvailability","exports"],"sourceRoot":"../../../src","sources":["hooks/useIsCloudAvailable.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,eAAA,GAAAC,sBAAA,CAAAF,OAAA;AAA+C,SAAAE,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE/C;AACA;AACA;AACA;AACA;AACO,MAAMG,mBAAmB,GAAIC,oBAAqC,IAAK;EAC5E,MAAM,CAACC,WAAW,EAAEC,cAAc,CAAC,GAAG,IAAAC,eAAQ,EAAC,KAAK,CAAC;EACrD,MAAMC,QAAQ,GAAGJ,oBAAoB,IAAIK,uBAAc,CAACC,kBAAkB,CAAC,CAAC;EAE5E,MAAMC,wBAAwB,GAAG,IAAAC,kBAAW,EAAEC,SAAkB,IAAK;IACnEP,cAAc,CAACO,SAAS,CAAC;EAC3B,CAAC,EAAE,EAAE,CAAC;EAEN,IAAAC,gBAAS,EAAC,MAAM;IACd;IACAN,QAAQ,CAACO,gBAAgB,CAAC,CAAC,CAACC,IAAI,CAACV,cAAc,CAAC;;IAEhD;IACAE,QAAQ,CAACS,4BAA4B,CAACN,wBAAwB,CAAC;IAE/D,OAAO,MAAM;MACXH,QAAQ,CAACU,gCAAgC,CAACP,wBAAwB,CAAC;IACrE,CAAC;EACH,CAAC,EAAE,CAACH,QAAQ,EAAEG,wBAAwB,CAAC,CAAC;EAExC,OAAON,WAAW;AACpB,CAAC;AAACc,OAAA,CAAAhB,mBAAA,GAAAA,mBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_react","require","_reactNative","_RNCloudStorage","_interopRequireDefault","obj","__esModule","default","useIsCloudAvailable","_iCloudTimeout","isAvailable","setIsAvailable","useState","useEffect","RNCloudStorage","isCloudAvailable","then","eventEmitter","Platform","OS","NativeEventEmitter","NativeModules","CloudStorageEventEmitter","DeviceEventEmitter","addListener","event","available","removeAllListeners","undefined","console","warn","exports"],"sourceRoot":"../../../src","sources":["hooks/useIsCloudAvailable.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAC,sBAAA,CAAAH,OAAA;AAA+C,SAAAG,uBAAAC,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAE/C;AACA;AACA;AACA;AACA;AACO,MAAMG,mBAAmB,GAAIC,cAAuB,IAAK;EAC9D,MAAM,CAACC,WAAW,EAAEC,cAAc,CAAC,GAAG,IAAAC,eAAQ,EAAC,KAAK,CAAC;EAErD,IAAAC,gBAAS,EAAC,MAAM;IACd;IACAC,uBAAc,CAACC,gBAAgB,EAAE,CAACC,IAAI,CAACL,cAAc,CAAC;;IAEtD;IACA,IAAIM,YAA4D;IAChE,IAAIC,qBAAQ,CAACC,EAAE,KAAK,KAAK,EAAE;MACzBF,YAAY,GAAG,IAAIG,+BAAkB,CAACC,0BAAa,CAACC,wBAAwB,CAAC;IAC/E,CAAC,MAAM;MACLL,YAAY,GAAGM,+BAAkB;IACnC;IAEAN,YAAY,CAACO,WAAW,CAAC,2CAA2C,EAAGC,KAA6B,IAAK;MACvGd,cAAc,CAACc,KAAK,CAACC,SAAS,CAAC;IACjC,CAAC,CAAC;IAEF,OAAO,MAAM;MACXT,YAAY,CAACU,kBAAkB,CAAC,2CAA2C,CAAC;IAC9E,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,IAAAd,gBAAS,EAAC,MAAM;IACd,IAAIJ,cAAc,KAAKmB,SAAS,EAAE;MAChCC,OAAO,CAACC,IAAI,CACV,0JAA0J,CAC3J;IACH;EACF,CAAC,EAAE,CAACrB,cAAc,CAAC,CAAC;EAEpB,OAAOC,WAAW;AACpB,CAAC;AAACqB,OAAA,CAAAvB,mBAAA,GAAAA,mBAAA"}
@@ -26,6 +26,7 @@ Object.defineProperty(exports, "CloudStorageErrorCode", {
26
26
  return _native.CloudStorageErrorCode;
27
27
  }
28
28
  });
29
+ exports.default = void 0;
29
30
  var _RNCloudStorage = _interopRequireDefault(require("./RNCloudStorage"));
30
31
  var _native = require("./types/native");
31
32
  var _main = require("./types/main");
@@ -65,5 +66,10 @@ Object.keys(_useIsCloudAvailable).forEach(function (key) {
65
66
  });
66
67
  });
67
68
  var _CloudStorageError = _interopRequireDefault(require("./utils/CloudStorageError"));
68
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
69
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
70
+ /**
71
+ * @deprecated Use the named export `CloudStorage` instead.
72
+ */
73
+ var _default = _RNCloudStorage.default;
74
+ exports.default = _default;
69
75
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_RNCloudStorage","_interopRequireDefault","require","_native","_main","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_useCloudFile","_useIsCloudAvailable","_CloudStorageError","e","__esModule","default"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,eAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAAAG,MAAA,CAAAC,IAAA,CAAAF,KAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,KAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,KAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,aAAA,GAAAf,OAAA;AAAAG,MAAA,CAAAC,IAAA,CAAAW,aAAA,EAAAV,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAS,aAAA,CAAAT,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,aAAA,CAAAT,GAAA;IAAA;EAAA;AAAA;AACA,IAAAU,oBAAA,GAAAhB,OAAA;AAAAG,MAAA,CAAAC,IAAA,CAAAY,oBAAA,EAAAX,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAU,oBAAA,CAAAV,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAE,oBAAA,CAAAV,GAAA;IAAA;EAAA;AAAA;AACA,IAAAW,kBAAA,GAAAlB,sBAAA,CAAAC,OAAA;AAA0D,SAAAD,uBAAAmB,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA","ignoreList":[]}
1
+ {"version":3,"names":["_RNCloudStorage","_interopRequireDefault","require","_native","_main","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_useCloudFile","_useIsCloudAvailable","_CloudStorageError","obj","__esModule","default","_default","RNCloudStorage"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,eAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAAAG,MAAA,CAAAC,IAAA,CAAAF,KAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,KAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,KAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,aAAA,GAAAf,OAAA;AAAAG,MAAA,CAAAC,IAAA,CAAAW,aAAA,EAAAV,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAS,aAAA,CAAAT,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,aAAA,CAAAT,GAAA;IAAA;EAAA;AAAA;AACA,IAAAU,oBAAA,GAAAhB,OAAA;AAAAG,MAAA,CAAAC,IAAA,CAAAY,oBAAA,EAAAX,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAU,oBAAA,CAAAV,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAE,oBAAA,CAAAV,GAAA;IAAA;EAAA;AAAA;AACA,IAAAW,kBAAA,GAAAlB,sBAAA,CAAAC,OAAA;AAA0D,SAAAD,uBAAAmB,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAI1D;AACA;AACA;AAFA,IAAAG,QAAA,GAGeC,uBAAc;AAAAX,OAAA,CAAAS,OAAA,GAAAC,QAAA"}
@@ -3,16 +3,11 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.CloudStorageScope = exports.CloudStorageProvider = void 0;
7
- /* Custom utility type to make properties required, but still allow null if defined */
8
- let CloudStorageScope = exports.CloudStorageScope = /*#__PURE__*/function (CloudStorageScope) {
6
+ exports.CloudStorageScope = void 0;
7
+ let CloudStorageScope = /*#__PURE__*/function (CloudStorageScope) {
9
8
  CloudStorageScope["Documents"] = "documents";
10
9
  CloudStorageScope["AppData"] = "app_data";
11
10
  return CloudStorageScope;
12
11
  }({});
13
- let CloudStorageProvider = exports.CloudStorageProvider = /*#__PURE__*/function (CloudStorageProvider) {
14
- CloudStorageProvider["ICloud"] = "icloud";
15
- CloudStorageProvider["GoogleDrive"] = "googledrive";
16
- return CloudStorageProvider;
17
- }({});
12
+ exports.CloudStorageScope = CloudStorageScope;
18
13
  //# sourceMappingURL=main.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["CloudStorageScope","exports","CloudStorageProvider"],"sourceRoot":"../../../src","sources":["types/main.ts"],"mappings":";;;;;;AAAA;AAAA,IAKYA,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,0BAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAA,OAAjBA,iBAAiB;AAAA;AAAA,IAejBE,oBAAoB,GAAAD,OAAA,CAAAC,oBAAA,0BAApBA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;EAAA,OAApBA,oBAAoB;AAAA","ignoreList":[]}
1
+ {"version":3,"names":["CloudStorageScope","exports"],"sourceRoot":"../../../src","sources":["types/main.ts"],"mappings":";;;;;;IAAYA,iBAAiB,0BAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAA,OAAjBA,iBAAiB;AAAA;AAAAC,OAAA,CAAAD,iBAAA,GAAAA,iBAAA"}
@@ -4,8 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.CloudStorageErrorCode = void 0;
7
- let CloudStorageErrorCode = exports.CloudStorageErrorCode = /*#__PURE__*/function (CloudStorageErrorCode) {
8
- CloudStorageErrorCode["INVALID_SCOPE"] = "ERR_INVALID_SCOPE";
7
+ let CloudStorageErrorCode = /*#__PURE__*/function (CloudStorageErrorCode) {
9
8
  CloudStorageErrorCode["FILE_NOT_FOUND"] = "ERR_FILE_NOT_FOUND";
10
9
  CloudStorageErrorCode["PATH_IS_FILE"] = "ERR_PATH_IS_FILE";
11
10
  CloudStorageErrorCode["PATH_IS_DIRECTORY"] = "ERR_PATH_IS_DIRECTORY";
@@ -20,7 +19,8 @@ let CloudStorageErrorCode = exports.CloudStorageErrorCode = /*#__PURE__*/functio
20
19
  CloudStorageErrorCode["STAT_ERROR"] = "ERR_STAT_ERROR";
21
20
  CloudStorageErrorCode["UNKNOWN"] = "ERR_UNKNOWN";
22
21
  CloudStorageErrorCode["FILE_NOT_DOWNLOADABLE"] = "ERR_FILE_NOT_DOWNLOADABLE";
23
- CloudStorageErrorCode["ACCESS_TOKEN_MISSING"] = "ERR_ACCESS_TOKEN_MISSING";
22
+ CloudStorageErrorCode["GOOGLE_DRIVE_ACCESS_TOKEN_MISSING"] = "ERR_GOOGLE_DRIVE_ACCESS_TOKEN_MISSING";
24
23
  return CloudStorageErrorCode;
25
24
  }({});
25
+ exports.CloudStorageErrorCode = CloudStorageErrorCode;
26
26
  //# sourceMappingURL=native.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["CloudStorageErrorCode","exports"],"sourceRoot":"../../../src","sources":["types/native.ts"],"mappings":";;;;;;IAUYA,qBAAqB,GAAAC,OAAA,CAAAD,qBAAA,0BAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAAA,OAArBA,qBAAqB;AAAA","ignoreList":[]}
1
+ {"version":3,"names":["CloudStorageErrorCode","exports"],"sourceRoot":"../../../src","sources":["types/native.ts"],"mappings":";;;;;;IAUYA,qBAAqB,0BAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAAA,OAArBA,qBAAqB;AAAA;AAAAC,OAAA,CAAAD,qBAAA,GAAAA,qBAAA"}
@@ -11,5 +11,6 @@ class CloudStorageError extends Error {
11
11
  this.details = details;
12
12
  }
13
13
  }
14
- var _default = exports.default = CloudStorageError;
14
+ var _default = CloudStorageError;
15
+ exports.default = _default;
15
16
  //# sourceMappingURL=CloudStorageError.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["CloudStorageError","Error","constructor","message","code","details","_default","exports","default"],"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;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcR,iBAAiB","ignoreList":[]}
1
+ {"version":3,"names":["CloudStorageError","Error","constructor","message","code","details","_default","exports","default"],"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;AAAC,IAAAC,QAAA,GAEcN,iBAAiB;AAAAO,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
@@ -3,14 +3,21 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.isProviderSupported = void 0;
7
- var _main = require("../types/main");
8
- var _reactNative = require("react-native");
9
- const isProviderSupported = provider => {
10
- if (_reactNative.Platform.OS !== 'ios' && provider === _main.CloudStorageProvider.ICloud) {
11
- return false;
6
+ exports.verifyLeadingSlash = void 0;
7
+ /**
8
+ * Checks if the path starts with a leading slash and adds one if it doesn't to maintain backwards compatibility.
9
+ * Will log a warning to the console if it had to add a leading slash. Will throw an error in the future.
10
+ *
11
+ * @param path The path to check.
12
+ * @returns The path with a leading slash, if it didn't have one already.
13
+ * @private
14
+ */
15
+ const verifyLeadingSlash = path => {
16
+ if (!path.startsWith('/')) {
17
+ console.warn(`[react-native-cloud-storage] Path "${path}" did not start with a leading slash. This is deprecated and will be an error in the future.`);
18
+ return `/${path}`;
12
19
  }
13
- return true;
20
+ return path;
14
21
  };
15
- exports.isProviderSupported = isProviderSupported;
22
+ exports.verifyLeadingSlash = verifyLeadingSlash;
16
23
  //# sourceMappingURL=helpers.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_main","require","_reactNative","isProviderSupported","provider","Platform","OS","CloudStorageProvider","ICloud","exports"],"sourceRoot":"../../../src","sources":["utils/helpers.ts"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEO,MAAME,mBAAmB,GAAIC,QAA8B,IAAc;EAC9E,IAAIC,qBAAQ,CAACC,EAAE,KAAK,KAAK,IAAIF,QAAQ,KAAKG,0BAAoB,CAACC,MAAM,EAAE;IACrE,OAAO,KAAK;EACd;EAEA,OAAO,IAAI;AACb,CAAC;AAACC,OAAA,CAAAN,mBAAA,GAAAA,mBAAA","ignoreList":[]}
1
+ {"version":3,"names":["verifyLeadingSlash","path","startsWith","console","warn","exports"],"sourceRoot":"../../../src","sources":["utils/helpers.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,kBAAkB,GAAIC,IAAY,IAAK;EAClD,IAAI,CAACA,IAAI,CAACC,UAAU,CAAC,GAAG,CAAC,EAAE;IACzBC,OAAO,CAACC,IAAI,CACT,sCAAqCH,IAAK,8FAA6F,CACzI;IACD,OAAQ,IAAGA,IAAK,EAAC;EACnB;EACA,OAAOA,IAAI;AACb,CAAC;AAACI,OAAA,CAAAL,kBAAA,GAAAA,kBAAA"}
@@ -1,285 +1,125 @@
1
- "use strict";
2
-
3
- import { CloudStorageProvider, CloudStorageScope } from './types/main';
4
- import { isProviderSupported } from './utils/helpers';
5
- import { NativeEventEmitter, NativeModules, Platform } from 'react-native';
6
- import CloudStorageError from './utils/CloudStorageError';
7
- import { CloudStorageErrorCode } from './types/native';
1
+ import { Platform } from 'react-native';
2
+ import createRNCloudStorage from './createRNCloudStorage';
8
3
  import GoogleDrive from './google-drive';
9
- const LINKING_ERROR = `The package 'react-native-cloud-storage' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
10
- ios: "- You have run 'pod install'\n",
11
- default: ''
12
- }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
13
-
14
- // proxy NativeModules.CloudStorage to catch any errors thrown by the native module and wrap them in a CloudStorageError
15
- const nativeIosInstance = NativeModules.CloudStorage ? new Proxy(NativeModules.CloudStorage, {
16
- get(target, prop) {
17
- const originalFunction = target[prop];
18
- if (typeof originalFunction === 'function') {
19
- return async (...args) => {
20
- try {
21
- // @ts-expect-error - we can't know the types of the functions and their arguments
22
- return await originalFunction(...args);
23
- } catch (error) {
24
- if (error?.code && Object.values(CloudStorageErrorCode).includes(error.code)) {
25
- throw new CloudStorageError(error?.message || '', error.code);
26
- } else {
27
- throw new CloudStorageError('Unknown error', CloudStorageErrorCode.UNKNOWN, error);
28
- }
29
- }
30
- };
31
- }
32
- return originalFunction;
33
- }
34
- }) : null;
35
- const defaultProviderOptions = {
36
- [CloudStorageProvider.ICloud]: {
37
- scope: CloudStorageScope.AppData
38
- },
39
- [CloudStorageProvider.GoogleDrive]: {
40
- scope: CloudStorageScope.AppData,
41
- accessToken: null,
42
- strictFilenames: false,
43
- timeout: 3000
44
- }
45
- };
46
- export default class RNCloudStorage {
47
- cloudAvailabilityListeners = [];
48
-
49
- //#region Constructor and configuration
50
- /**
51
- * Creates a new RNCloudStorage instance for the given provider.
52
- * @param provider The provider to create the instance for. Defaults to the default provider for the current platform.
53
- */
54
- constructor(provider, options) {
55
- if (provider && !isProviderSupported(provider)) {
56
- throw new Error(`Provider ${provider} is not supported on the current platform.`);
57
- }
58
- this.provider = {
59
- provider: provider ?? RNCloudStorage.getDefaultProvider(),
60
- options: defaultProviderOptions[provider ?? RNCloudStorage.getDefaultProvider()]
61
- };
62
- this.setProvider(provider ?? RNCloudStorage.getDefaultProvider());
63
- if (options) {
64
- this.setProviderOptions(options);
65
- }
66
- }
67
- get nativeInstance() {
68
- switch (this.provider.provider) {
69
- case CloudStorageProvider.ICloud:
70
- return nativeIosInstance ?? new Proxy({}, {
71
- get() {
72
- throw new Error(LINKING_ERROR);
73
- }
74
- });
75
- default:
76
- return new GoogleDrive(this.provider.options);
77
- }
78
- }
79
-
80
- /**
81
- * Gets the default CloudStorageProvider for the current platform.
82
- * @returns The default CloudStorageProvider.
83
- */
84
- static getDefaultProvider() {
85
- switch (Platform.OS) {
86
- case 'ios':
87
- return CloudStorageProvider.ICloud;
88
- default:
89
- return CloudStorageProvider.GoogleDrive;
90
- }
91
- }
92
-
93
- /**
94
- * Gets the list of supported CloudStorageProviders on the current platform.
95
- * @returns An array of supported CloudStorageProviders.
96
- */
97
- static getSupportedProviders() {
98
- return Object.values(CloudStorageProvider).filter(isProviderSupported);
99
- }
100
-
101
- /**
102
- * Gets the current CloudStorageProvider.
103
- * @returns The current CloudStorageProvider.
104
- */
105
- getProvider() {
106
- return this.provider.provider;
107
- }
108
-
109
- /**
110
- * Sets the current CloudStorageProvider.
111
- * @param provider The provider to set.
112
- */
113
- setProvider(provider) {
114
- if (!isProviderSupported(provider)) {
115
- throw new Error(`Provider ${provider} is not supported on the current platform.`);
116
- }
117
- this.provider = {
118
- provider,
119
- options: defaultProviderOptions[provider]
120
- };
121
-
122
- // Emit an event to notify useIsCloudAvailable() hook consumers of the new cloud availability status
123
- this.nativeInstance.isCloudAvailable().then(available => {
124
- this.cloudAvailabilityListeners.forEach(listener => {
125
- listener(available);
126
- });
127
- });
128
- if (provider === CloudStorageProvider.ICloud) {
129
- // Listen to native cloud availability change events
130
- const eventEmitter = new NativeEventEmitter(NativeModules.CloudStorageEventEmitter);
131
- eventEmitter.addListener('RNCloudStorage.cloud.availability-changed', event => {
132
- this.cloudAvailabilityListeners.forEach(listener => {
133
- listener(event.available);
134
- });
135
- });
136
- }
137
- }
138
-
139
- /**
140
- * Gets the current options for the current provider.
141
- * @returns The current options for the current provider.
142
- */
143
- getProviderOptions() {
144
- return this.provider.options;
145
- }
146
-
147
- /**
148
- * Sets the options for the current provider.
149
- * @param options The options to set for the provider.
150
- */
151
- setProviderOptions(options) {
152
- const newOptions = Object.fromEntries(Object.entries(options).filter(([_, v]) => v !== undefined));
153
- this.provider.options = {
154
- ...this.provider.options,
155
- ...newOptions
156
- };
157
- if (this.provider.provider === CloudStorageProvider.GoogleDrive && 'accessToken' in newOptions) {
158
- // Emit an event to notify useIsCloudAvailable() hook consumers of the new cloud availability status
159
- this.cloudAvailabilityListeners.forEach(listener => {
160
- listener(!!newOptions.accessToken?.length);
161
- });
162
- }
163
- }
164
- subscribeToCloudAvailability(listener) {
165
- this.cloudAvailabilityListeners.push(listener);
166
- }
167
- unsubscribeFromCloudAvailability(listener) {
168
- this.cloudAvailabilityListeners = this.cloudAvailabilityListeners.filter(l => l !== listener);
169
- }
170
- //#endregion
4
+ import { CloudStorageScope } from './types/main';
5
+ import { verifyLeadingSlash } from './utils/helpers';
6
+ const nativeInstance = createRNCloudStorage();
7
+ let defaultScope = CloudStorageScope.AppData;
8
+ const RNCloudStorage = {
9
+ getDefaultScope: () => defaultScope,
10
+ setDefaultScope: scope => defaultScope = scope,
11
+ getGoogleDriveAccessToken: () => GoogleDrive.accessToken,
12
+ setGoogleDriveAccessToken: accessToken => GoogleDrive.accessToken = accessToken,
13
+ setThrowOnFilesWithSameName: enable => GoogleDrive.throwOnFilesWithSameName = enable,
14
+ setTimeout: timeout => GoogleDrive.timeout = timeout,
15
+ /* eslint-disable @typescript-eslint/no-unused-vars */
16
+ subscribeToFilesWithSameName: Platform.OS === 'ios' ?
17
+ // @ts-expect-error - subscriber is undefined; just a mock
18
+ subscriber => ({
19
+ remove: () => {}
20
+ }) : nativeInstance.subscribeToFilesWithSameName.bind(nativeInstance),
21
+ /* eslint-enable @typescript-eslint/no-unused-vars */
171
22
 
172
- //#region File system operations
173
23
  /**
174
24
  * Tests whether or not the cloud storage is available. Always returns true for Google Drive. iCloud may be
175
25
  * unavailable right after app launch or if the user is not logged in.
176
26
  * @returns A promise that resolves to true if the cloud storage is available, false otherwise.
177
27
  */
178
- isCloudAvailable() {
179
- return this.nativeInstance.isCloudAvailable();
180
- }
181
-
28
+ isCloudAvailable: async () => {
29
+ return nativeInstance.isCloudAvailable();
30
+ },
182
31
  /**
183
32
  * Appends the data to the file at the given path, creating the file if it doesn't exist.
184
33
  * @param path The file to append to.
185
34
  * @param data The data to append.
186
- * @param scope The directory scope the path is in. Defaults to the default scope set for the current provider.
35
+ * @param scope The directory scope the path is in. Defaults to the set default scope.
187
36
  * @returns A promise that resolves when the data has been appended.
188
37
  */
189
- appendFile(path, data, scope) {
190
- return this.nativeInstance.appendToFile(path, data, scope ?? this.provider.options.scope);
191
- }
192
-
38
+ appendFile: (path, data, scope) => {
39
+ return nativeInstance.appendToFile(verifyLeadingSlash(path), data, scope ?? defaultScope);
40
+ },
193
41
  /**
194
42
  * Tests whether or not the file at the given path exists.
195
43
  * @param path The path to test.
196
- * @param scope The directory scope the path is in. Defaults to set default scope set for the current provider.
44
+ * @param scope The directory scope the path is in. Defaults to the set default scope.
197
45
  * @returns A promise that resolves to true if the path exists, false otherwise.
198
46
  */
199
- exists(path, scope) {
200
- return this.nativeInstance.fileExists(path, scope ?? this.provider.options.scope);
201
- }
202
-
47
+ exists: (path, scope) => {
48
+ return nativeInstance.fileExists(verifyLeadingSlash(path), scope ?? defaultScope);
49
+ },
203
50
  /**
204
51
  * Writes to the file at the given path, creating it if it doesn't exist or overwriting it if it does.
205
52
  * @param path The file to write to.
206
53
  * @param data The data to write.
207
- * @param scope The directory scope the path is in. Defaults to set default scope set for the current provider.
54
+ * @param scope The directory scope the path is in. Defaults to the set default scope.
208
55
  * @returns A promise that resolves when the file has been written.
209
56
  */
210
- writeFile(path, data, scope) {
211
- return this.nativeInstance.createFile(path, data, scope ?? this.provider.options.scope, true);
212
- }
213
-
57
+ writeFile: (path, data, scope) => {
58
+ return nativeInstance.createFile(verifyLeadingSlash(path), data, scope ?? defaultScope, true);
59
+ },
214
60
  /**
215
61
  * Creates a new directory at the given path.
216
62
  * @param path The directory to create.
217
- * @param scope The directory scope the path is in. Defaults to set default scope set for the current provider.
63
+ * @param scope The directory scope the path is in. Defaults to the set default scope.
218
64
  * @returns A promise that resolves when the directory has been created.
219
65
  */
220
- mkdir(path, scope) {
221
- return this.nativeInstance.createDirectory(path, scope ?? this.provider.options.scope);
222
- }
223
-
66
+ mkdir: (path, scope) => {
67
+ return nativeInstance.createDirectory(verifyLeadingSlash(path), scope ?? defaultScope);
68
+ },
224
69
  /**
225
70
  * Lists the contents of the directory at the given path.
226
71
  * @param path The directory to list.
227
- * @param scope The directory scope the path is in. Defaults to set default scope set for the current provider.
72
+ * @param scope The directory scope the path is in. Defaults to the set default scope.
228
73
  * @returns A promise that resolves to an array of file names, excluding '.' and '..'.
229
74
  */
230
- readdir(path, scope) {
231
- return this.nativeInstance.listFiles(path, scope ?? this.provider.options.scope);
232
- }
233
-
75
+ readdir: (path, scope) => {
76
+ return nativeInstance.listFiles(verifyLeadingSlash(path), scope ?? defaultScope);
77
+ },
234
78
  /**
235
79
  * Reads the contents of the file at the given path.
236
80
  * @param path The file to read.
237
- * @param scope The directory scope the path is in. Defaults to set default scope set for the current provider.
81
+ * @param scope The directory scope the path is in. Defaults to the set default scope.
238
82
  * @returns A promise that resolves to the contents of the file.
239
83
  */
240
- readFile(path, scope) {
241
- return this.nativeInstance.readFile(path, scope ?? this.provider.options.scope);
242
- }
243
-
84
+ readFile: (path, scope) => {
85
+ return nativeInstance.readFile(verifyLeadingSlash(path), scope ?? defaultScope);
86
+ },
244
87
  /**
245
- * Downloads the file at the given path. Does not have any effect on Google Drive.
88
+ * Downloads the file at the given path from iCloud. Does not have any effect on Google Drive.
246
89
  * @param path The file to trigger the download for.
247
- * @param scope The directory scope the path is in. Defaults to set default scope set for the current provider.
90
+ * @param scope The directory scope the path is in. Defaults to the set default scope.
248
91
  * @returns A promise that resolves once the download has been triggered.
249
92
  */
250
- downloadFile(path, scope) {
251
- return this.nativeInstance.downloadFile(path, scope ?? this.provider.options.scope);
252
- }
253
-
93
+ downloadFile: (path, scope) => {
94
+ return nativeInstance.downloadFile(verifyLeadingSlash(path), scope ?? defaultScope);
95
+ },
254
96
  /**
255
97
  * Deletes the file at the given path.
256
98
  * @param path The file to delete.
257
- * @param scope The directory scope the path is in. Defaults to set default scope set for the current provider.
99
+ * @param scope The directory scope the path is in. Defaults to the set default scope.
258
100
  * @returns A promise that resolves when the file has been deleted.
259
101
  */
260
- unlink(path, scope) {
261
- return this.nativeInstance.deleteFile(path, scope ?? this.provider.options.scope);
262
- }
263
-
102
+ unlink: (path, scope) => {
103
+ return nativeInstance.deleteFile(verifyLeadingSlash(path), scope ?? defaultScope);
104
+ },
264
105
  /**
265
106
  * Deletes the directory at the given path.
266
107
  * @param path The directory to delete.
267
108
  * @param options Options for the delete operation. Defaults to { recursive: false }.
268
- * @param scope The directory scope the path is in. Defaults to set default scope set for the current provider.
109
+ * @param scope The directory scope the path is in. Defaults to the set default scope.
269
110
  * @returns A promise that resolves when the directory has been deleted.
270
111
  */
271
- rmdir(path, options, scope) {
272
- return this.nativeInstance.deleteDirectory(path, options?.recursive ?? false, scope ?? this.provider.options.scope);
273
- }
274
-
112
+ rmdir: (path, options, scope) => {
113
+ return nativeInstance.deleteDirectory(verifyLeadingSlash(path), (options === null || options === void 0 ? void 0 : options.recursive) ?? false, scope ?? defaultScope);
114
+ },
275
115
  /**
276
116
  * Gets the size, creation time, and modification time of the file at the given path.
277
117
  * @param path The file to stat.
278
- * @param scope The directory scope the path is in. Defaults to set default scope set for the current provider.
118
+ * @param scope The directory scope the path is in. Defaults to the set default scope.
279
119
  * @returns A promise that resolves to the CloudStorageFileStat object.
280
120
  */
281
- async stat(path, scope) {
282
- const native = await this.nativeInstance.statFile(path, scope ?? this.provider.options.scope);
121
+ stat: async (path, scope) => {
122
+ const native = await nativeInstance.statFile(verifyLeadingSlash(path), scope ?? defaultScope);
283
123
  return {
284
124
  ...native,
285
125
  birthtime: new Date(native.birthtimeMs),
@@ -288,143 +128,6 @@ export default class RNCloudStorage {
288
128
  isFile: () => native.isFile
289
129
  };
290
130
  }
291
- //#endregion
292
-
293
- //#region Static methods for default static instance
294
- static getDefaultInstance() {
295
- if (!RNCloudStorage.defaultInstance) {
296
- RNCloudStorage.defaultInstance = new RNCloudStorage();
297
- }
298
- return RNCloudStorage.defaultInstance;
299
- }
300
-
301
- /**
302
- * Gets the current options for the provider of the default static instance.
303
- * @returns The current options for the provider of the default static instance.
304
- */
305
- static getProviderOptions() {
306
- return RNCloudStorage.getDefaultInstance().getProviderOptions();
307
- }
308
-
309
- /**
310
- * Sets the options for the provider of the default static instance.
311
- * @param options The options to set for the provider of the default static instance.
312
- */
313
- static setProviderOptions(options) {
314
- RNCloudStorage.getDefaultInstance().setProviderOptions(options);
315
- }
316
-
317
- /**
318
- * Tests whether or not the file at the given path exists in the provider of the default static instance.
319
- * @param path The path to test.
320
- * @param scope The directory scope the path is in. Defaults to set default scope set for the current provider.
321
- * @returns A promise that resolves to true if the path exists, false otherwise.
322
- */
323
- static exists(path, scope) {
324
- return RNCloudStorage.getDefaultInstance().exists(path, scope);
325
- }
326
-
327
- /**
328
- * Tests whether or not the cloud storage is available for the provider of the default static instance. Always returns true for Google Drive. iCloud may be
329
- * unavailable right after app launch or if the user is not logged in.
330
- * @returns A promise that resolves to true if the cloud storage is available, false otherwise.
331
- */
332
- static isCloudAvailable() {
333
- return RNCloudStorage.getDefaultInstance().isCloudAvailable();
334
- }
335
-
336
- /**
337
- * Appends the data to the file at the given path in the provider of the default static instance, creating the file if it doesn't exist.
338
- * @param path The file to append to.
339
- * @param data The data to append.
340
- * @param scope The directory scope the path is in. Defaults to the default scope set for the default static instance.
341
- * @returns A promise that resolves when the data has been appended.
342
- */
343
- static appendFile(path, data, scope) {
344
- return RNCloudStorage.getDefaultInstance().appendFile(path, data, scope);
345
- }
346
-
347
- /**
348
- * Writes to the file at the given path in the provider of the default static instance, creating it if it doesn't exist or overwriting it if it does.
349
- * @param path The file to write to.
350
- * @param data The data to write.
351
- * @param scope The directory scope the path is in. Defaults to the default scope set for the default static instance.
352
- * @returns A promise that resolves when the file has been written.
353
- */
354
- static writeFile(path, data, scope) {
355
- return RNCloudStorage.getDefaultInstance().writeFile(path, data, scope);
356
- }
357
-
358
- /**
359
- * Creates a new directory at the given path in the provider of the default static instance.
360
- * @param path The directory to create.
361
- * @param scope The directory scope the path is in. Defaults to the default scope set for the default static instance.
362
- * @returns A promise that resolves when the directory has been created.
363
- */
364
- static mkdir(path, scope) {
365
- return RNCloudStorage.getDefaultInstance().mkdir(path, scope);
366
- }
367
-
368
- /**
369
- * Lists the contents of the directory at the given path in the provider of the default static instance.
370
- * @param path The directory to list.
371
- * @param scope The directory scope the path is in. Defaults to the default scope set for the default static instance.
372
- * @returns A promise that resolves to an array of file names, excluding '.' and '..'.
373
- */
374
- static readdir(path, scope) {
375
- return RNCloudStorage.getDefaultInstance().readdir(path, scope);
376
- }
377
-
378
- /**
379
- * Reads the contents of the file at the given path in the provider of the default static instance.
380
- * @param path The file to read.
381
- * @param scope The directory scope the path is in. Defaults to the default scope set for the default static instance.
382
- * @returns A promise that resolves to the contents of the file.
383
- */
384
- static readFile(path, scope) {
385
- return RNCloudStorage.getDefaultInstance().readFile(path, scope);
386
- }
387
-
388
- /**
389
- * Downloads the file at the given path in the provider of the default static instance. Does not have any effect on Google Drive.
390
- * @param path The file to trigger the download for.
391
- * @param scope The directory scope the path is in. Defaults to the default scope set for the default static instance.
392
- * @returns A promise that resolves once the download has been triggered.
393
- */
394
- static downloadFile(path, scope) {
395
- return RNCloudStorage.getDefaultInstance().downloadFile(path, scope);
396
- }
397
-
398
- /**
399
- * Deletes the file at the given path in the provider of the default static instance.
400
- * @param path The file to delete.
401
- * @param scope The directory scope the path is in. Defaults to the default scope set for the default static instance.
402
- * @returns A promise that resolves when the file has been deleted.
403
- */
404
- static unlink(path, scope) {
405
- return RNCloudStorage.getDefaultInstance().unlink(path, scope);
406
- }
407
-
408
- /**
409
- * Deletes the directory at the given path in the provider of the default static instance.
410
- * @param path The directory to delete.
411
- * @param options Options for the delete operation. Defaults to { recursive: false }.
412
- * @param scope The directory scope the path is in. Defaults to the default scope set for the default static instance.
413
- * @returns A promise that resolves when the directory has been deleted.
414
- */
415
- static rmdir(path, options, scope) {
416
- return RNCloudStorage.getDefaultInstance().rmdir(path, options, scope);
417
- }
418
-
419
- /**
420
- * Gets the size, creation time, and modification time of the file at the given path in the provider of the default static instance.
421
- * @param path The file to stat.
422
- * @param scope The directory scope the path is in. Defaults to the default scope set for the default static instance.
423
- * @returns A promise that resolves to the CloudStorageFileStat object.
424
- */
425
- static stat(path, scope) {
426
- return RNCloudStorage.getDefaultInstance().stat(path, scope);
427
- }
428
- //#endregion
429
- }
131
+ };
132
+ export default RNCloudStorage;
430
133
  //# sourceMappingURL=RNCloudStorage.js.map