react-native-cloud-storage 1.5.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +6 -5
- package/ios/CloudStorage.swift +52 -262
- package/ios/CloudStorage.xcodeproj/project.pbxproj +28 -0
- package/ios/CloudStorageEventEmitter.swift +4 -4
- package/ios/Utils/CloudKitUtils.swift +112 -0
- package/ios/Utils/CloudStorageError.swift +78 -0
- package/ios/Utils/FileUtils.swift +132 -0
- package/ios/Utils/Promise.swift +58 -0
- package/ios/Utils/Types.swift +36 -0
- package/lib/commonjs/RNCloudStorage.js +361 -66
- package/lib/commonjs/RNCloudStorage.js.map +1 -1
- package/lib/commonjs/expo-plugin/types/index.js.map +1 -1
- package/lib/commonjs/expo-plugin/withRNCloudStorage.js +2 -3
- package/lib/commonjs/expo-plugin/withRNCloudStorage.js.map +1 -1
- package/lib/commonjs/expo-plugin/withRNCloudStorageIos.js +4 -7
- package/lib/commonjs/expo-plugin/withRNCloudStorageIos.js.map +1 -1
- package/lib/commonjs/google-drive/client.js +16 -20
- package/lib/commonjs/google-drive/client.js.map +1 -1
- package/lib/commonjs/google-drive/index.js +42 -64
- package/lib/commonjs/google-drive/index.js.map +1 -1
- package/lib/commonjs/google-drive/types.js +1 -2
- package/lib/commonjs/google-drive/types.js.map +1 -1
- package/lib/commonjs/hooks/useCloudFile.js +14 -17
- package/lib/commonjs/hooks/useCloudFile.js.map +1 -1
- package/lib/commonjs/hooks/useIsCloudAvailable.js +11 -21
- package/lib/commonjs/hooks/useIsCloudAvailable.js.map +1 -1
- package/lib/commonjs/index.js +1 -7
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/types/main.js +8 -3
- package/lib/commonjs/types/main.js.map +1 -1
- package/lib/commonjs/types/native.js +3 -3
- package/lib/commonjs/types/native.js.map +1 -1
- package/lib/commonjs/utils/CloudStorageError.js +1 -2
- package/lib/commonjs/utils/CloudStorageError.js.map +1 -1
- package/lib/commonjs/utils/helpers.js +8 -15
- package/lib/commonjs/utils/helpers.js.map +1 -1
- package/lib/module/RNCloudStorage.js +362 -65
- package/lib/module/RNCloudStorage.js.map +1 -1
- package/lib/module/expo-plugin/types/index.js +1 -1
- package/lib/module/expo-plugin/types/index.js.map +1 -1
- package/lib/module/expo-plugin/withRNCloudStorage.js +2 -0
- package/lib/module/expo-plugin/withRNCloudStorage.js.map +1 -1
- package/lib/module/expo-plugin/withRNCloudStorageIos.js +5 -5
- package/lib/module/expo-plugin/withRNCloudStorageIos.js.map +1 -1
- package/lib/module/google-drive/client.js +18 -20
- package/lib/module/google-drive/client.js.map +1 -1
- package/lib/module/google-drive/index.js +41 -62
- package/lib/module/google-drive/index.js.map +1 -1
- package/lib/module/google-drive/types.js +2 -0
- package/lib/module/google-drive/types.js.map +1 -1
- package/lib/module/hooks/useCloudFile.js +15 -16
- package/lib/module/hooks/useCloudFile.js.map +1 -1
- package/lib/module/hooks/useIsCloudAvailable.js +13 -21
- package/lib/module/hooks/useIsCloudAvailable.js.map +1 -1
- package/lib/module/index.js +2 -5
- package/lib/module/index.js.map +1 -1
- package/lib/module/package.json +1 -0
- package/lib/module/types/main.js +9 -0
- package/lib/module/types/main.js.map +1 -1
- package/lib/module/types/native.js +4 -1
- package/lib/module/types/native.js.map +1 -1
- package/lib/module/utils/CloudStorageError.js +2 -0
- package/lib/module/utils/CloudStorageError.js.map +1 -1
- package/lib/module/utils/helpers.js +8 -13
- package/lib/module/utils/helpers.js.map +1 -1
- package/lib/typescript/RNCloudStorage.d.ts +159 -39
- package/lib/typescript/RNCloudStorage.d.ts.map +1 -1
- package/lib/typescript/google-drive/client.d.ts +3 -3
- package/lib/typescript/google-drive/client.d.ts.map +1 -1
- package/lib/typescript/google-drive/index.d.ts +6 -18
- package/lib/typescript/google-drive/index.d.ts.map +1 -1
- package/lib/typescript/hooks/useCloudFile.d.ts +4 -7
- package/lib/typescript/hooks/useCloudFile.d.ts.map +1 -1
- package/lib/typescript/hooks/useIsCloudAvailable.d.ts +3 -2
- package/lib/typescript/hooks/useIsCloudAvailable.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +0 -4
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/types/main.d.ts +33 -0
- package/lib/typescript/types/main.d.ts.map +1 -1
- package/lib/typescript/types/native.d.ts +2 -1
- package/lib/typescript/types/native.d.ts.map +1 -1
- package/lib/typescript/utils/helpers.d.ts +2 -9
- package/lib/typescript/utils/helpers.d.ts.map +1 -1
- package/package.json +9 -11
- package/src/RNCloudStorage.ts +387 -68
- package/src/google-drive/client.ts +8 -7
- package/src/google-drive/index.ts +38 -63
- package/src/hooks/useCloudFile.ts +13 -16
- package/src/hooks/useIsCloudAvailable.ts +12 -25
- package/src/index.ts +0 -5
- package/src/types/main.ts +38 -0
- package/src/types/native.ts +2 -1
- package/src/utils/helpers.ts +8 -15
- package/lib/commonjs/createRNCloudStorage.js +0 -48
- package/lib/commonjs/createRNCloudStorage.js.map +0 -1
- package/lib/module/createRNCloudStorage.js +0 -41
- package/lib/module/createRNCloudStorage.js.map +0 -1
- package/lib/typescript/createRNCloudStorage.d.ts +0 -3
- package/lib/typescript/createRNCloudStorage.d.ts.map +0 -1
- package/src/createRNCloudStorage.ts +0 -53
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["RNCloudStorage","useCallback","useEffect","useState","useCloudFile","path","scope","content","setContent","read","exists","readFile","then","write","newContent","writeFile","remove","unlink","download","downloadFile"
|
|
1
|
+
{"version":3,"names":["RNCloudStorage","useCallback","useEffect","useState","useCloudFile","path","scope","cloudStorageInstance","content","setContent","instance","read","exists","readFile","then","write","newContent","writeFile","remove","unlink","download","downloadFile"],"sourceRoot":"../../../src","sources":["hooks/useCloudFile.ts"],"mappings":";;AACA,OAAOA,cAAc,MAAM,mBAAmB;AAC9C,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,OA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AY,CAAChB,IAAI,EAAEC,KAAK,CAAC;EAC1C,CAAC,EAAE,CAACD,IAAI,EAAEC,KAAK,EAAEI,QAAQ,CAAC,CAAC;EAE3B,OAAO;IACLF,OAAO;IACPG,IAAI;IACJI,KAAK;IACLG,MAAM;IACN;AACJ;AACA;AACA;IACIE;EACF,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -1,37 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
3
4
|
import RNCloudStorage from '../RNCloudStorage';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* A hook that tests whether or not the cloud storage is available.
|
|
7
|
-
* @param
|
|
8
|
+
* @param cloudStorageInstance - An optional instance of RNCloudStorage to use instead of the default instance.
|
|
8
9
|
* @returns A boolean indicating whether or not the cloud storage is available.
|
|
9
10
|
*/
|
|
10
|
-
export const useIsCloudAvailable =
|
|
11
|
+
export const useIsCloudAvailable = cloudStorageInstance => {
|
|
11
12
|
const [isAvailable, setIsAvailable] = useState(false);
|
|
13
|
+
const instance = cloudStorageInstance ?? RNCloudStorage.getDefaultInstance();
|
|
14
|
+
const handleAvailabilityChange = useCallback(available => {
|
|
15
|
+
setIsAvailable(available);
|
|
16
|
+
}, []);
|
|
12
17
|
useEffect(() => {
|
|
13
18
|
// Set the initial availability state
|
|
14
|
-
|
|
19
|
+
instance.isCloudAvailable().then(setIsAvailable);
|
|
15
20
|
|
|
16
21
|
// Listen for changes to the cloud availability using the native event emitter
|
|
17
|
-
|
|
18
|
-
if (Platform.OS === 'ios') {
|
|
19
|
-
eventEmitter = new NativeEventEmitter(NativeModules.CloudStorageEventEmitter);
|
|
20
|
-
} else {
|
|
21
|
-
eventEmitter = DeviceEventEmitter;
|
|
22
|
-
}
|
|
23
|
-
eventEmitter.addListener('RNCloudStorage.cloud.availability-changed', event => {
|
|
24
|
-
setIsAvailable(event.available);
|
|
25
|
-
});
|
|
22
|
+
instance.subscribeToCloudAvailability(handleAvailabilityChange);
|
|
26
23
|
return () => {
|
|
27
|
-
|
|
24
|
+
instance.unsubscribeFromCloudAvailability(handleAvailabilityChange);
|
|
28
25
|
};
|
|
29
|
-
}, []);
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
if (_iCloudTimeout !== undefined) {
|
|
32
|
-
console.warn('The iCloudTimeout parameter for useIsCloudFile is deprecated and has no effect. It will be removed in a future version. Please remove it from your code.');
|
|
33
|
-
}
|
|
34
|
-
}, [_iCloudTimeout]);
|
|
26
|
+
}, [instance, handleAvailabilityChange]);
|
|
35
27
|
return isAvailable;
|
|
36
28
|
};
|
|
37
29
|
//# sourceMappingURL=useIsCloudAvailable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["useCallback","useEffect","useState","RNCloudStorage","useIsCloudAvailable","cloudStorageInstance","isAvailable","setIsAvailable","instance","getDefaultInstance","handleAvailabilityChange","available","isCloudAvailable","then","subscribeToCloudAvailability","unsubscribeFromCloudAvailability"],"sourceRoot":"../../../src","sources":["hooks/useIsCloudAvailable.ts"],"mappings":";;AAAA,SAASA,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AACxD,OAAOC,cAAc,MAAM,mBAAmB;;AAE9C;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,mBAAmB,GAAIC,oBAAqC,IAAK;EAC5E,MAAM,CAACC,WAAW,EAAEC,cAAc,CAAC,GAAGL,QAAQ,CAAC,KAAK,CAAC;EACrD,MAAMM,QAAQ,GAAGH,oBAAoB,IAAIF,cAAc,CAACM,kBAAkB,CAAC,CAAC;EAE5E,MAAMC,wBAAwB,GAAGV,WAAW,CAAEW,SAAkB,IAAK;IACnEJ,cAAc,CAACI,SAAS,CAAC;EAC3B,CAAC,EAAE,EAAE,CAAC;EAENV,SAAS,CAAC,MAAM;IACd;IACAO,QAAQ,CAACI,gBAAgB,CAAC,CAAC,CAACC,IAAI,CAACN,cAAc,CAAC;;IAEhD;IACAC,QAAQ,CAACM,4BAA4B,CAACJ,wBAAwB,CAAC;IAE/D,OAAO,MAAM;MACXF,QAAQ,CAACO,gCAAgC,CAACL,wBAAwB,CAAC;IACrE,CAAC;EACH,CAAC,EAAE,CAACF,QAAQ,EAAEE,wBAAwB,CAAC,CAAC;EAExC,OAAOJ,WAAW;AACpB,CAAC","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
1
3
|
import RNCloudStorage from './RNCloudStorage';
|
|
2
4
|
import { CloudStorageErrorCode } from './types/native';
|
|
3
5
|
export * from './types/main';
|
|
@@ -5,9 +7,4 @@ export * from './hooks/useCloudFile';
|
|
|
5
7
|
export * from './hooks/useIsCloudAvailable';
|
|
6
8
|
import CloudStorageError from './utils/CloudStorageError';
|
|
7
9
|
export { RNCloudStorage as CloudStorage, CloudStorageError, CloudStorageErrorCode };
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @deprecated Use the named export `CloudStorage` instead.
|
|
11
|
-
*/
|
|
12
|
-
export default RNCloudStorage;
|
|
13
10
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["RNCloudStorage","CloudStorageErrorCode","CloudStorageError","CloudStorage"],"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,SAASF,cAAc,IAAIG,YAAY,EAAED,iBAAiB,EAAED,qBAAqB
|
|
1
|
+
{"version":3,"names":["RNCloudStorage","CloudStorageErrorCode","CloudStorageError","CloudStorage"],"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,SAASF,cAAc,IAAIG,YAAY,EAAED,iBAAiB,EAAED,qBAAqB","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
package/lib/module/types/main.js
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/* Custom utility type to make properties required, but still allow null if defined */
|
|
4
|
+
|
|
1
5
|
export let CloudStorageScope = /*#__PURE__*/function (CloudStorageScope) {
|
|
2
6
|
CloudStorageScope["Documents"] = "documents";
|
|
3
7
|
CloudStorageScope["AppData"] = "app_data";
|
|
4
8
|
return CloudStorageScope;
|
|
5
9
|
}({});
|
|
10
|
+
export let CloudStorageProvider = /*#__PURE__*/function (CloudStorageProvider) {
|
|
11
|
+
CloudStorageProvider["ICloud"] = "icloud";
|
|
12
|
+
CloudStorageProvider["GoogleDrive"] = "googledrive";
|
|
13
|
+
return CloudStorageProvider;
|
|
14
|
+
}({});
|
|
6
15
|
//# sourceMappingURL=main.js.map
|
|
@@ -1 +1 @@
|
|
|
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
|
+
{"version":3,"names":["CloudStorageScope","CloudStorageProvider"],"sourceRoot":"../../../src","sources":["types/main.ts"],"mappings":";;AAAA;;AAKA,WAAYA,iBAAiB,0BAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAA,OAAjBA,iBAAiB;AAAA;AAe7B,WAAYC,oBAAoB,0BAApBA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;EAAA,OAApBA,oBAAoB;AAAA","ignoreList":[]}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
1
3
|
export let CloudStorageErrorCode = /*#__PURE__*/function (CloudStorageErrorCode) {
|
|
4
|
+
CloudStorageErrorCode["INVALID_SCOPE"] = "ERR_INVALID_SCOPE";
|
|
2
5
|
CloudStorageErrorCode["FILE_NOT_FOUND"] = "ERR_FILE_NOT_FOUND";
|
|
3
6
|
CloudStorageErrorCode["PATH_IS_FILE"] = "ERR_PATH_IS_FILE";
|
|
4
7
|
CloudStorageErrorCode["PATH_IS_DIRECTORY"] = "ERR_PATH_IS_DIRECTORY";
|
|
@@ -13,7 +16,7 @@ export let CloudStorageErrorCode = /*#__PURE__*/function (CloudStorageErrorCode)
|
|
|
13
16
|
CloudStorageErrorCode["STAT_ERROR"] = "ERR_STAT_ERROR";
|
|
14
17
|
CloudStorageErrorCode["UNKNOWN"] = "ERR_UNKNOWN";
|
|
15
18
|
CloudStorageErrorCode["FILE_NOT_DOWNLOADABLE"] = "ERR_FILE_NOT_DOWNLOADABLE";
|
|
16
|
-
CloudStorageErrorCode["
|
|
19
|
+
CloudStorageErrorCode["ACCESS_TOKEN_MISSING"] = "ERR_ACCESS_TOKEN_MISSING";
|
|
17
20
|
return CloudStorageErrorCode;
|
|
18
21
|
}({});
|
|
19
22
|
//# sourceMappingURL=native.js.map
|
|
@@ -1 +1 @@
|
|
|
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;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAAA,OAArBA,qBAAqB;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;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAAA,OAArBA,qBAAqB;AAAA","ignoreList":[]}
|
|
@@ -1 +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
|
+
{"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","ignoreList":[]}
|
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*/
|
|
9
|
-
export const verifyLeadingSlash = path => {
|
|
10
|
-
if (!path.startsWith('/')) {
|
|
11
|
-
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.`);
|
|
12
|
-
return `/${path}`;
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { CloudStorageProvider } from '../types/main';
|
|
4
|
+
import { Platform } from 'react-native';
|
|
5
|
+
export const isProviderSupported = provider => {
|
|
6
|
+
if (Platform.OS !== 'ios' && provider === CloudStorageProvider.ICloud) {
|
|
7
|
+
return false;
|
|
13
8
|
}
|
|
14
|
-
return
|
|
9
|
+
return true;
|
|
15
10
|
};
|
|
16
11
|
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["CloudStorageProvider","Platform","isProviderSupported","provider","OS","ICloud"],"sourceRoot":"../../../src","sources":["utils/helpers.ts"],"mappings":";;AAAA,SAASA,oBAAoB,QAAQ,eAAe;AACpD,SAASC,QAAQ,QAAQ,cAAc;AAEvC,OAAO,MAAMC,mBAAmB,GAAIC,QAA8B,IAAc;EAC9E,IAAIF,QAAQ,CAACG,EAAE,KAAK,KAAK,IAAID,QAAQ,KAAKH,oBAAoB,CAACK,MAAM,EAAE;IACrE,OAAO,KAAK;EACd;EAEA,OAAO,IAAI;AACb,CAAC","ignoreList":[]}
|
|
@@ -1,98 +1,218 @@
|
|
|
1
|
-
import { CloudStorageScope, type CloudStorageFileStat } from './types/main';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { CloudStorageProvider, CloudStorageScope, type CloudStorageFileStat, type CloudStorageProviderOptions } from './types/main';
|
|
2
|
+
export default class RNCloudStorage {
|
|
3
|
+
private static defaultInstance;
|
|
4
|
+
private provider;
|
|
5
|
+
private cloudAvailabilityListeners;
|
|
6
|
+
/**
|
|
7
|
+
* Creates a new RNCloudStorage instance for the given provider.
|
|
8
|
+
* @param provider The provider to create the instance for. Defaults to the default provider for the current platform.
|
|
9
|
+
*/
|
|
10
|
+
constructor(provider?: CloudStorageProvider, options?: CloudStorageProviderOptions[keyof CloudStorageProviderOptions]);
|
|
11
|
+
private get nativeInstance();
|
|
12
|
+
/**
|
|
13
|
+
* Gets the default CloudStorageProvider for the current platform.
|
|
14
|
+
* @returns The default CloudStorageProvider.
|
|
15
|
+
*/
|
|
16
|
+
static getDefaultProvider(): CloudStorageProvider;
|
|
17
|
+
/**
|
|
18
|
+
* Gets the list of supported CloudStorageProviders on the current platform.
|
|
19
|
+
* @returns An array of supported CloudStorageProviders.
|
|
20
|
+
*/
|
|
21
|
+
static getSupportedProviders(): CloudStorageProvider[];
|
|
22
|
+
/**
|
|
23
|
+
* Gets the current CloudStorageProvider.
|
|
24
|
+
* @returns The current CloudStorageProvider.
|
|
25
|
+
*/
|
|
26
|
+
getProvider(): CloudStorageProvider;
|
|
27
|
+
/**
|
|
28
|
+
* Sets the current CloudStorageProvider.
|
|
29
|
+
* @param provider The provider to set.
|
|
30
|
+
*/
|
|
31
|
+
setProvider(provider: CloudStorageProvider): void;
|
|
32
|
+
/**
|
|
33
|
+
* Gets the current options for the current provider.
|
|
34
|
+
* @returns The current options for the current provider.
|
|
35
|
+
*/
|
|
36
|
+
getProviderOptions(): CloudStorageProviderOptions[keyof CloudStorageProviderOptions];
|
|
37
|
+
/**
|
|
38
|
+
* Sets the options for the current provider.
|
|
39
|
+
* @param options The options to set for the provider.
|
|
40
|
+
*/
|
|
41
|
+
setProviderOptions(options: CloudStorageProviderOptions[keyof CloudStorageProviderOptions]): void;
|
|
42
|
+
subscribeToCloudAvailability(listener: (available: boolean) => void): void;
|
|
43
|
+
unsubscribeFromCloudAvailability(listener: (available: boolean) => void): void;
|
|
15
44
|
/**
|
|
16
45
|
* Tests whether or not the cloud storage is available. Always returns true for Google Drive. iCloud may be
|
|
17
46
|
* unavailable right after app launch or if the user is not logged in.
|
|
18
47
|
* @returns A promise that resolves to true if the cloud storage is available, false otherwise.
|
|
19
48
|
*/
|
|
20
|
-
isCloudAvailable
|
|
49
|
+
isCloudAvailable(): Promise<boolean>;
|
|
21
50
|
/**
|
|
22
51
|
* Appends the data to the file at the given path, creating the file if it doesn't exist.
|
|
23
52
|
* @param path The file to append to.
|
|
24
53
|
* @param data The data to append.
|
|
25
|
-
* @param scope The directory scope the path is in. Defaults to the set
|
|
54
|
+
* @param scope The directory scope the path is in. Defaults to the default scope set for the current provider.
|
|
26
55
|
* @returns A promise that resolves when the data has been appended.
|
|
27
56
|
*/
|
|
28
|
-
appendFile
|
|
57
|
+
appendFile(path: string, data: string, scope?: CloudStorageScope): Promise<void>;
|
|
29
58
|
/**
|
|
30
59
|
* Tests whether or not the file at the given path exists.
|
|
31
60
|
* @param path The path to test.
|
|
32
|
-
* @param scope The directory scope the path is in. Defaults to
|
|
61
|
+
* @param scope The directory scope the path is in. Defaults to set default scope set for the current provider.
|
|
33
62
|
* @returns A promise that resolves to true if the path exists, false otherwise.
|
|
34
63
|
*/
|
|
35
|
-
exists
|
|
64
|
+
exists(path: string, scope?: CloudStorageScope): Promise<boolean>;
|
|
36
65
|
/**
|
|
37
66
|
* Writes to the file at the given path, creating it if it doesn't exist or overwriting it if it does.
|
|
38
67
|
* @param path The file to write to.
|
|
39
68
|
* @param data The data to write.
|
|
40
|
-
* @param scope The directory scope the path is in. Defaults to
|
|
69
|
+
* @param scope The directory scope the path is in. Defaults to set default scope set for the current provider.
|
|
41
70
|
* @returns A promise that resolves when the file has been written.
|
|
42
71
|
*/
|
|
43
|
-
writeFile
|
|
72
|
+
writeFile(path: string, data: string, scope?: CloudStorageScope): Promise<void>;
|
|
44
73
|
/**
|
|
45
74
|
* Creates a new directory at the given path.
|
|
46
75
|
* @param path The directory to create.
|
|
47
|
-
* @param scope The directory scope the path is in. Defaults to
|
|
76
|
+
* @param scope The directory scope the path is in. Defaults to set default scope set for the current provider.
|
|
48
77
|
* @returns A promise that resolves when the directory has been created.
|
|
49
78
|
*/
|
|
50
|
-
mkdir
|
|
79
|
+
mkdir(path: string, scope?: CloudStorageScope): Promise<void>;
|
|
51
80
|
/**
|
|
52
81
|
* Lists the contents of the directory at the given path.
|
|
53
82
|
* @param path The directory to list.
|
|
54
|
-
* @param scope The directory scope the path is in. Defaults to
|
|
83
|
+
* @param scope The directory scope the path is in. Defaults to set default scope set for the current provider.
|
|
55
84
|
* @returns A promise that resolves to an array of file names, excluding '.' and '..'.
|
|
56
85
|
*/
|
|
57
|
-
readdir
|
|
86
|
+
readdir(path: string, scope?: CloudStorageScope): Promise<string[]>;
|
|
58
87
|
/**
|
|
59
88
|
* Reads the contents of the file at the given path.
|
|
60
89
|
* @param path The file to read.
|
|
61
|
-
* @param scope The directory scope the path is in. Defaults to
|
|
90
|
+
* @param scope The directory scope the path is in. Defaults to set default scope set for the current provider.
|
|
62
91
|
* @returns A promise that resolves to the contents of the file.
|
|
63
92
|
*/
|
|
64
|
-
readFile
|
|
93
|
+
readFile(path: string, scope?: CloudStorageScope): Promise<string>;
|
|
65
94
|
/**
|
|
66
|
-
* Downloads the file at the given path
|
|
95
|
+
* Downloads the file at the given path. Does not have any effect on Google Drive.
|
|
67
96
|
* @param path The file to trigger the download for.
|
|
68
|
-
* @param scope The directory scope the path is in. Defaults to
|
|
97
|
+
* @param scope The directory scope the path is in. Defaults to set default scope set for the current provider.
|
|
69
98
|
* @returns A promise that resolves once the download has been triggered.
|
|
70
99
|
*/
|
|
71
|
-
downloadFile
|
|
100
|
+
downloadFile(path: string, scope?: CloudStorageScope): Promise<void>;
|
|
72
101
|
/**
|
|
73
102
|
* Deletes the file at the given path.
|
|
74
103
|
* @param path The file to delete.
|
|
75
|
-
* @param scope The directory scope the path is in. Defaults to
|
|
104
|
+
* @param scope The directory scope the path is in. Defaults to set default scope set for the current provider.
|
|
76
105
|
* @returns A promise that resolves when the file has been deleted.
|
|
77
106
|
*/
|
|
78
|
-
unlink
|
|
107
|
+
unlink(path: string, scope?: CloudStorageScope): Promise<void>;
|
|
79
108
|
/**
|
|
80
109
|
* Deletes the directory at the given path.
|
|
81
110
|
* @param path The directory to delete.
|
|
82
111
|
* @param options Options for the delete operation. Defaults to { recursive: false }.
|
|
83
|
-
* @param scope The directory scope the path is in. Defaults to
|
|
112
|
+
* @param scope The directory scope the path is in. Defaults to set default scope set for the current provider.
|
|
84
113
|
* @returns A promise that resolves when the directory has been deleted.
|
|
85
114
|
*/
|
|
86
|
-
rmdir
|
|
115
|
+
rmdir(path: string, options?: {
|
|
87
116
|
recursive?: boolean;
|
|
88
|
-
}, scope?: CloudStorageScope)
|
|
117
|
+
}, scope?: CloudStorageScope): Promise<void>;
|
|
89
118
|
/**
|
|
90
119
|
* Gets the size, creation time, and modification time of the file at the given path.
|
|
91
120
|
* @param path The file to stat.
|
|
92
|
-
* @param scope The directory scope the path is in. Defaults to
|
|
121
|
+
* @param scope The directory scope the path is in. Defaults to set default scope set for the current provider.
|
|
122
|
+
* @returns A promise that resolves to the CloudStorageFileStat object.
|
|
123
|
+
*/
|
|
124
|
+
stat(path: string, scope?: CloudStorageScope): Promise<CloudStorageFileStat>;
|
|
125
|
+
static getDefaultInstance(): RNCloudStorage;
|
|
126
|
+
/**
|
|
127
|
+
* Gets the current options for the provider of the default static instance.
|
|
128
|
+
* @returns The current options for the provider of the default static instance.
|
|
129
|
+
*/
|
|
130
|
+
static getProviderOptions(): CloudStorageProviderOptions[keyof CloudStorageProviderOptions];
|
|
131
|
+
/**
|
|
132
|
+
* Sets the options for the provider of the default static instance.
|
|
133
|
+
* @param options The options to set for the provider of the default static instance.
|
|
134
|
+
*/
|
|
135
|
+
static setProviderOptions(options: CloudStorageProviderOptions[keyof CloudStorageProviderOptions]): void;
|
|
136
|
+
/**
|
|
137
|
+
* Tests whether or not the file at the given path exists in the provider of the default static instance.
|
|
138
|
+
* @param path The path to test.
|
|
139
|
+
* @param scope The directory scope the path is in. Defaults to set default scope set for the current provider.
|
|
140
|
+
* @returns A promise that resolves to true if the path exists, false otherwise.
|
|
141
|
+
*/
|
|
142
|
+
static exists(path: string, scope?: CloudStorageScope): Promise<boolean>;
|
|
143
|
+
/**
|
|
144
|
+
* 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
|
|
145
|
+
* unavailable right after app launch or if the user is not logged in.
|
|
146
|
+
* @returns A promise that resolves to true if the cloud storage is available, false otherwise.
|
|
147
|
+
*/
|
|
148
|
+
static isCloudAvailable(): Promise<boolean>;
|
|
149
|
+
/**
|
|
150
|
+
* 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.
|
|
151
|
+
* @param path The file to append to.
|
|
152
|
+
* @param data The data to append.
|
|
153
|
+
* @param scope The directory scope the path is in. Defaults to the default scope set for the default static instance.
|
|
154
|
+
* @returns A promise that resolves when the data has been appended.
|
|
155
|
+
*/
|
|
156
|
+
static appendFile(path: string, data: string, scope?: CloudStorageScope): Promise<void>;
|
|
157
|
+
/**
|
|
158
|
+
* 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.
|
|
159
|
+
* @param path The file to write to.
|
|
160
|
+
* @param data The data to write.
|
|
161
|
+
* @param scope The directory scope the path is in. Defaults to the default scope set for the default static instance.
|
|
162
|
+
* @returns A promise that resolves when the file has been written.
|
|
163
|
+
*/
|
|
164
|
+
static writeFile(path: string, data: string, scope?: CloudStorageScope): Promise<void>;
|
|
165
|
+
/**
|
|
166
|
+
* Creates a new directory at the given path in the provider of the default static instance.
|
|
167
|
+
* @param path The directory to create.
|
|
168
|
+
* @param scope The directory scope the path is in. Defaults to the default scope set for the default static instance.
|
|
169
|
+
* @returns A promise that resolves when the directory has been created.
|
|
170
|
+
*/
|
|
171
|
+
static mkdir(path: string, scope?: CloudStorageScope): Promise<void>;
|
|
172
|
+
/**
|
|
173
|
+
* Lists the contents of the directory at the given path in the provider of the default static instance.
|
|
174
|
+
* @param path The directory to list.
|
|
175
|
+
* @param scope The directory scope the path is in. Defaults to the default scope set for the default static instance.
|
|
176
|
+
* @returns A promise that resolves to an array of file names, excluding '.' and '..'.
|
|
177
|
+
*/
|
|
178
|
+
static readdir(path: string, scope?: CloudStorageScope): Promise<string[]>;
|
|
179
|
+
/**
|
|
180
|
+
* Reads the contents of the file at the given path in the provider of the default static instance.
|
|
181
|
+
* @param path The file to read.
|
|
182
|
+
* @param scope The directory scope the path is in. Defaults to the default scope set for the default static instance.
|
|
183
|
+
* @returns A promise that resolves to the contents of the file.
|
|
184
|
+
*/
|
|
185
|
+
static readFile(path: string, scope?: CloudStorageScope): Promise<string>;
|
|
186
|
+
/**
|
|
187
|
+
* Downloads the file at the given path in the provider of the default static instance. Does not have any effect on Google Drive.
|
|
188
|
+
* @param path The file to trigger the download for.
|
|
189
|
+
* @param scope The directory scope the path is in. Defaults to the default scope set for the default static instance.
|
|
190
|
+
* @returns A promise that resolves once the download has been triggered.
|
|
191
|
+
*/
|
|
192
|
+
static downloadFile(path: string, scope?: CloudStorageScope): Promise<void>;
|
|
193
|
+
/**
|
|
194
|
+
* Deletes the file at the given path in the provider of the default static instance.
|
|
195
|
+
* @param path The file to delete.
|
|
196
|
+
* @param scope The directory scope the path is in. Defaults to the default scope set for the default static instance.
|
|
197
|
+
* @returns A promise that resolves when the file has been deleted.
|
|
198
|
+
*/
|
|
199
|
+
static unlink(path: string, scope?: CloudStorageScope): Promise<void>;
|
|
200
|
+
/**
|
|
201
|
+
* Deletes the directory at the given path in the provider of the default static instance.
|
|
202
|
+
* @param path The directory to delete.
|
|
203
|
+
* @param options Options for the delete operation. Defaults to { recursive: false }.
|
|
204
|
+
* @param scope The directory scope the path is in. Defaults to the default scope set for the default static instance.
|
|
205
|
+
* @returns A promise that resolves when the directory has been deleted.
|
|
206
|
+
*/
|
|
207
|
+
static rmdir(path: string, options?: {
|
|
208
|
+
recursive?: boolean;
|
|
209
|
+
}, scope?: CloudStorageScope): Promise<void>;
|
|
210
|
+
/**
|
|
211
|
+
* Gets the size, creation time, and modification time of the file at the given path in the provider of the default static instance.
|
|
212
|
+
* @param path The file to stat.
|
|
213
|
+
* @param scope The directory scope the path is in. Defaults to the default scope set for the default static instance.
|
|
93
214
|
* @returns A promise that resolves to the CloudStorageFileStat object.
|
|
94
215
|
*/
|
|
95
|
-
stat
|
|
96
|
-
}
|
|
97
|
-
export default RNCloudStorage;
|
|
216
|
+
static stat(path: string, scope?: CloudStorageScope): Promise<CloudStorageFileStat>;
|
|
217
|
+
}
|
|
98
218
|
//# sourceMappingURL=RNCloudStorage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RNCloudStorage.d.ts","sourceRoot":"","sources":["../../src/RNCloudStorage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RNCloudStorage.d.ts","sourceRoot":"","sources":["../../src/RNCloudStorage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,KAAK,oBAAoB,EACzB,KAAK,2BAA2B,EAEjC,MAAM,cAAc,CAAC;AAkDtB,MAAM,CAAC,OAAO,OAAO,cAAc;IACjC,OAAO,CAAC,MAAM,CAAC,eAAe,CAAiB;IAC/C,OAAO,CAAC,QAAQ,CAGd;IACF,OAAO,CAAC,0BAA0B,CAAwC;IAG1E;;;OAGG;gBAED,QAAQ,CAAC,EAAE,oBAAoB,EAC/B,OAAO,CAAC,EAAE,2BAA2B,CAAC,MAAM,2BAA2B,CAAC;IAiB1E,OAAO,KAAK,cAAc,GAiBzB;IAED;;;OAGG;IACH,MAAM,CAAC,kBAAkB,IAAI,oBAAoB;IASjD;;;OAGG;IACH,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EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAItF;;;;;OAKG;IACH,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAIpE;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAI1E;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC;IAIzE;;;;;OAKG;IACH,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAI3E;;;;;OAKG;IACH,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAIrE;;;;;;OAMG;IACH,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,EAAE,KAAK,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvG;;;;;OAKG;IACH,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAIpF"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type CloudStorageProviderOptions, type DeepRequired } from '../types/main';
|
|
1
2
|
import { type GoogleDriveFile, type GoogleDriveFileSpace } from './types';
|
|
2
3
|
export declare class GoogleDriveHttpError extends Error {
|
|
3
4
|
status: number;
|
|
@@ -5,10 +6,9 @@ export declare class GoogleDriveHttpError extends Error {
|
|
|
5
6
|
constructor(message: string, status: number, json: any);
|
|
6
7
|
}
|
|
7
8
|
export default class GoogleDriveApiClient {
|
|
8
|
-
accessToken: string;
|
|
9
|
-
timeout: number;
|
|
10
9
|
private _fetchTimeout;
|
|
11
|
-
|
|
10
|
+
private options;
|
|
11
|
+
constructor(options: DeepRequired<CloudStorageProviderOptions['googledrive']>);
|
|
12
12
|
private buildQueryString;
|
|
13
13
|
private request;
|
|
14
14
|
private buildMultiPartBody;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/google-drive/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,oBAAoB,EAG1B,MAAM,SAAS,CAAC;AAMjB,qBAAa,oBAAqB,SAAQ,KAAK;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,GAAG,CAAC;gBAEL,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG;CAKvD;AAID,MAAM,CAAC,OAAO,OAAO,oBAAoB;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/google-drive/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,2BAA2B,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AACpF,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,oBAAoB,EAG1B,MAAM,SAAS,CAAC;AAMjB,qBAAa,oBAAqB,SAAQ,KAAK;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,GAAG,CAAC;gBAEL,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG;CAKvD;AAID,MAAM,CAAC,OAAO,OAAO,oBAAoB;IACvC,OAAO,CAAC,aAAa,CAAM;IAC3B,OAAO,CAAC,OAAO,CAA2D;gBAE9D,OAAO,EAAE,YAAY,CAAC,2BAA2B,CAAC,aAAa,CAAC,CAAC;IAI7E,OAAO,CAAC,gBAAgB;YAeV,OAAO;IA4CrB,OAAO,CAAC,kBAAkB;IAab,SAAS,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAoBlE,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IASjD,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAO5C,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAMzC,UAAU,CACrB,QAAQ,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,EAC9C,KAAK,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GACxC,OAAO,CAAC,IAAI,CAAC;IAeH,eAAe,CAAC,QAAQ,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAU9E,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAYlG"}
|
|
@@ -1,25 +1,13 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type NativeproviderService from '../types/native';
|
|
2
2
|
import { type NativeRNCloudCloudStorageFileStat, type NativeRNCloudCloudStorageScope } from '../types/native';
|
|
3
|
+
import { type CloudStorageProviderOptions, type DeepRequired } from '../types/main';
|
|
3
4
|
/**
|
|
4
5
|
* A proxy class that wraps the Google Drive API client implementation to match the native iOS interface.
|
|
5
6
|
*/
|
|
6
|
-
export default class GoogleDrive implements
|
|
7
|
-
private
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
path: string;
|
|
11
|
-
fileIds: string[];
|
|
12
|
-
}) => void)[];
|
|
13
|
-
constructor();
|
|
14
|
-
static set accessToken(accessToken: string | null);
|
|
15
|
-
static set timeout(timeout: number);
|
|
16
|
-
static get accessToken(): string | null;
|
|
17
|
-
subscribeToFilesWithSameName(subscriber: ({ path, fileIds }: {
|
|
18
|
-
path: string;
|
|
19
|
-
fileIds: string[];
|
|
20
|
-
}) => void): {
|
|
21
|
-
remove: () => void;
|
|
22
|
-
};
|
|
7
|
+
export default class GoogleDrive implements NativeproviderService {
|
|
8
|
+
private drive;
|
|
9
|
+
private options;
|
|
10
|
+
constructor(options: DeepRequired<CloudStorageProviderOptions['googledrive']>);
|
|
23
11
|
isCloudAvailable: () => Promise<boolean>;
|
|
24
12
|
private getRootDirectory;
|
|
25
13
|
private resolvePathToDirectories;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/google-drive/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/google-drive/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,qBAAqB,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAEL,KAAK,iCAAiC,EACtC,KAAK,8BAA8B,EACpC,MAAM,iBAAiB,CAAC;AAIzB,OAAO,EAAE,KAAK,2BAA2B,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAEpF;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,WAAY,YAAW,qBAAqB;IAC/D,OAAO,CAAC,KAAK,CAAuB;IACpC,OAAO,CAAC,OAAO,CAA2D;gBAE9D,OAAO,EAAE,YAAY,CAAC,2BAA2B,CAAC,aAAa,CAAC,CAAC;IAuBtE,gBAAgB,EAAE,MAAM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;CAYhH"}
|
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
import type { CloudStorageScope } from '../types/main';
|
|
2
|
+
import RNCloudStorage from '../RNCloudStorage';
|
|
2
3
|
/**
|
|
3
4
|
* A utility hook for reading and writing to a single file in the cloud.
|
|
4
5
|
* @param path The path to the file.
|
|
5
|
-
* @param scope The directory scope the path is in.
|
|
6
|
+
* @param scope The directory scope the path is in. Defaults to the default scope set for the current provider.
|
|
7
|
+
* @param cloudStorageInstance An optional instance of RNCloudStorage to use instead of the default instance.
|
|
6
8
|
* @returns An object containing the file's contents and functions for downloading, reading, writing, and removing the file.
|
|
7
9
|
*/
|
|
8
|
-
export declare const useCloudFile: (path: string, scope?: CloudStorageScope) => {
|
|
10
|
+
export declare const useCloudFile: (path: string, scope?: CloudStorageScope, cloudStorageInstance?: RNCloudStorage) => {
|
|
9
11
|
content: string | null;
|
|
10
12
|
read: () => Promise<void>;
|
|
11
13
|
write: (newContent: string) => Promise<void>;
|
|
12
14
|
remove: () => Promise<void>;
|
|
13
|
-
/**
|
|
14
|
-
* @deprecated Use `write` instead.
|
|
15
|
-
* @alias write
|
|
16
|
-
*/
|
|
17
|
-
update: (newContent: string) => Promise<void>;
|
|
18
15
|
/**
|
|
19
16
|
* Downloads the file from iCloud to the device. Needed if the file hasn't been synced yet. Has no effect on
|
|
20
17
|
* Google Drive.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCloudFile.d.ts","sourceRoot":"","sources":["../../../src/hooks/useCloudFile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,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;AACvD,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAG/C;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,SAAU,MAAM,UAAU,iBAAiB,yBAAyB,cAAc;;;wBAkBpF,MAAM;;IAqBzB;;;OAGG;;CAGN,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import RNCloudStorage from '../RNCloudStorage';
|
|
1
2
|
/**
|
|
2
3
|
* A hook that tests whether or not the cloud storage is available.
|
|
3
|
-
* @param
|
|
4
|
+
* @param cloudStorageInstance - An optional instance of RNCloudStorage to use instead of the default instance.
|
|
4
5
|
* @returns A boolean indicating whether or not the cloud storage is available.
|
|
5
6
|
*/
|
|
6
|
-
export declare const useIsCloudAvailable: (
|
|
7
|
+
export declare const useIsCloudAvailable: (cloudStorageInstance?: RNCloudStorage) => boolean;
|
|
7
8
|
//# sourceMappingURL=useIsCloudAvailable.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIsCloudAvailable.d.ts","sourceRoot":"","sources":["../../../src/hooks/useIsCloudAvailable.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useIsCloudAvailable.d.ts","sourceRoot":"","sources":["../../../src/hooks/useIsCloudAvailable.ts"],"names":[],"mappings":"AACA,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAE/C;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,0BAA2B,cAAc,YAqBxE,CAAC"}
|
|
@@ -5,8 +5,4 @@ export * from './hooks/useCloudFile';
|
|
|
5
5
|
export * from './hooks/useIsCloudAvailable';
|
|
6
6
|
import CloudStorageError from './utils/CloudStorageError';
|
|
7
7
|
export { RNCloudStorage as CloudStorage, CloudStorageError, CloudStorageErrorCode };
|
|
8
|
-
/**
|
|
9
|
-
* @deprecated Use the named export `CloudStorage` instead.
|
|
10
|
-
*/
|
|
11
|
-
export default RNCloudStorage;
|
|
12
8
|
//# 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,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,cAAc,IAAI,YAAY,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,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,cAAc,IAAI,YAAY,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,CAAC"}
|