react-native-cloud-storage 2.2.2 → 3.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 +1 -1
- package/android/build.gradle +88 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/voicekit/CloudStorageError.kt +86 -0
- package/android/src/main/java/com/voicekit/CloudStorageLocalFileSystemModule.kt +232 -0
- package/android/src/main/java/com/voicekit/CloudStoragePackage.kt +32 -0
- package/android/src/main/java/com/voicekit/FileUtils.kt +41 -0
- package/android/src/main/java/com/voicekit/Types.kt +6 -0
- package/app.plugin.js +1 -1
- package/{lib/commonjs/RNCloudStorage.js → dist/commonjs/cloud-storage.js} +177 -92
- package/dist/commonjs/cloud-storage.js.map +1 -0
- package/dist/commonjs/expo-plugin/index.js +13 -0
- package/dist/commonjs/expo-plugin/index.js.map +1 -0
- package/{lib/commonjs/expo-plugin/withRNCloudStorageIos.js → dist/commonjs/expo-plugin/ios.js} +1 -1
- package/dist/commonjs/expo-plugin/ios.js.map +1 -0
- package/{lib/commonjs/hooks/useCloudFile.js → dist/commonjs/hooks/use-cloud-file.js} +26 -8
- package/dist/commonjs/hooks/use-cloud-file.js.map +1 -0
- package/{lib/commonjs/hooks/useIsCloudAvailable.js → dist/commonjs/hooks/use-is-cloud-available.js} +3 -3
- package/dist/commonjs/hooks/use-is-cloud-available.js.map +1 -0
- package/{lib → dist}/commonjs/index.js +10 -10
- package/dist/commonjs/index.js.map +1 -0
- package/dist/commonjs/specs/NativeCloudStorageCloudKitIOS.js +9 -0
- package/dist/commonjs/specs/NativeCloudStorageCloudKitIOS.js.map +1 -0
- package/dist/commonjs/specs/NativeCloudStorageLocalFileSystem.js +9 -0
- package/dist/commonjs/specs/NativeCloudStorageLocalFileSystem.js.map +1 -0
- package/dist/commonjs/storages/cloudkit.js +12 -0
- package/dist/commonjs/storages/cloudkit.js.map +1 -0
- package/{lib/commonjs → dist/commonjs/storages}/google-drive/client.js +83 -40
- package/dist/commonjs/storages/google-drive/client.js.map +1 -0
- package/dist/commonjs/storages/google-drive/index.js +399 -0
- package/dist/commonjs/storages/google-drive/index.js.map +1 -0
- package/dist/commonjs/storages/google-drive/types.js.map +1 -0
- package/{lib → dist}/commonjs/types/main.js.map +1 -1
- package/dist/commonjs/types/native.js +28 -0
- package/dist/commonjs/types/native.js.map +1 -0
- package/{lib/commonjs/utils/CloudStorageError.js → dist/commonjs/utils/cloud-storage-error.js} +3 -1
- package/dist/commonjs/utils/cloud-storage-error.js.map +1 -0
- package/dist/commonjs/utils/constants.js +25 -0
- package/dist/commonjs/utils/constants.js.map +1 -0
- package/dist/commonjs/utils/local-fs.js +17 -0
- package/dist/commonjs/utils/local-fs.js.map +1 -0
- package/dist/commonjs/utils/native.js +35 -0
- package/dist/commonjs/utils/native.js.map +1 -0
- package/{lib/module/RNCloudStorage.js → dist/module/cloud-storage.js} +178 -93
- package/dist/module/cloud-storage.js.map +1 -0
- package/dist/module/expo-plugin/index.js +8 -0
- package/dist/module/expo-plugin/index.js.map +1 -0
- package/{lib/module/expo-plugin/withRNCloudStorageIos.js → dist/module/expo-plugin/ios.js} +1 -1
- package/dist/module/expo-plugin/ios.js.map +1 -0
- package/{lib/module/hooks/useCloudFile.js → dist/module/hooks/use-cloud-file.js} +25 -7
- package/dist/module/hooks/use-cloud-file.js.map +1 -0
- package/{lib/module/hooks/useIsCloudAvailable.js → dist/module/hooks/use-is-cloud-available.js} +2 -2
- package/dist/module/hooks/use-is-cloud-available.js.map +1 -0
- package/dist/module/index.js +9 -0
- package/dist/module/index.js.map +1 -0
- package/dist/module/specs/NativeCloudStorageCloudKitIOS.js +5 -0
- package/dist/module/specs/NativeCloudStorageCloudKitIOS.js.map +1 -0
- package/dist/module/specs/NativeCloudStorageLocalFileSystem.js +5 -0
- package/dist/module/specs/NativeCloudStorageLocalFileSystem.js.map +1 -0
- package/dist/module/storages/cloudkit.js +7 -0
- package/dist/module/storages/cloudkit.js.map +1 -0
- package/{lib/module → dist/module/storages}/google-drive/client.js +83 -40
- package/dist/module/storages/google-drive/client.js.map +1 -0
- package/dist/module/storages/google-drive/index.js +392 -0
- package/dist/module/storages/google-drive/index.js.map +1 -0
- package/dist/module/storages/google-drive/types.js.map +1 -0
- package/{lib → dist}/module/types/main.js.map +1 -1
- package/dist/module/types/native.js +24 -0
- package/dist/module/types/native.js.map +1 -0
- package/{lib/module/utils/CloudStorageError.js → dist/module/utils/cloud-storage-error.js} +3 -1
- package/dist/module/utils/cloud-storage-error.js.map +1 -0
- package/dist/module/utils/constants.js +21 -0
- package/dist/module/utils/constants.js.map +1 -0
- package/dist/module/utils/local-fs.js +12 -0
- package/dist/module/utils/local-fs.js.map +1 -0
- package/dist/module/utils/native.js +30 -0
- package/dist/module/utils/native.js.map +1 -0
- package/{lib/typescript/RNCloudStorage.d.ts → dist/typescript/cloud-storage.d.ts} +67 -8
- package/dist/typescript/cloud-storage.d.ts.map +1 -0
- package/{lib/typescript/expo-plugin/withRNCloudStorage.d.ts → dist/typescript/expo-plugin/index.d.ts} +1 -1
- package/dist/typescript/expo-plugin/index.d.ts.map +1 -0
- package/{lib/typescript/expo-plugin/withRNCloudStorageIos.d.ts → dist/typescript/expo-plugin/ios.d.ts} +1 -1
- package/dist/typescript/expo-plugin/ios.d.ts.map +1 -0
- package/{lib/typescript/hooks/useCloudFile.d.ts → dist/typescript/hooks/use-cloud-file.d.ts} +22 -4
- package/dist/typescript/hooks/use-cloud-file.d.ts.map +1 -0
- package/{lib/typescript/hooks/useIsCloudAvailable.d.ts → dist/typescript/hooks/use-is-cloud-available.d.ts} +2 -2
- package/dist/typescript/hooks/use-is-cloud-available.d.ts.map +1 -0
- package/dist/typescript/index.d.ts +7 -0
- package/dist/typescript/index.d.ts.map +1 -0
- package/dist/typescript/specs/NativeCloudStorageCloudKitIOS.d.ts +30 -0
- package/dist/typescript/specs/NativeCloudStorageCloudKitIOS.d.ts.map +1 -0
- package/dist/typescript/specs/NativeCloudStorageLocalFileSystem.d.ts +24 -0
- package/dist/typescript/specs/NativeCloudStorageLocalFileSystem.d.ts.map +1 -0
- package/dist/typescript/storages/cloudkit.d.ts +6 -0
- package/dist/typescript/storages/cloudkit.d.ts.map +1 -0
- package/{lib/typescript → dist/typescript/storages}/google-drive/client.d.ts +10 -3
- package/dist/typescript/storages/google-drive/client.d.ts.map +1 -0
- package/dist/typescript/storages/google-drive/index.d.ts +41 -0
- package/dist/typescript/storages/google-drive/index.d.ts.map +1 -0
- package/dist/typescript/storages/google-drive/types.d.ts.map +1 -0
- package/{lib → dist}/typescript/types/main.d.ts +8 -0
- package/dist/typescript/types/main.d.ts.map +1 -0
- package/dist/typescript/types/native.d.ts +27 -0
- package/dist/typescript/types/native.d.ts.map +1 -0
- package/dist/typescript/utils/cloud-storage-error.d.ts +8 -0
- package/dist/typescript/utils/cloud-storage-error.d.ts.map +1 -0
- package/dist/typescript/utils/constants.d.ts +4 -0
- package/dist/typescript/utils/constants.d.ts.map +1 -0
- package/{lib → dist}/typescript/utils/helpers.d.ts.map +1 -1
- package/dist/typescript/utils/local-fs.d.ts +2 -0
- package/dist/typescript/utils/local-fs.d.ts.map +1 -0
- package/dist/typescript/utils/native.d.ts +7 -0
- package/dist/typescript/utils/native.d.ts.map +1 -0
- package/ios/CloudStorage-Bridging-Header.h +0 -1
- package/ios/CloudStorage.xcodeproj/project.pbxproj +12 -6
- package/ios/CloudStorageCloudKit.swift +159 -0
- package/ios/CloudStorageLocalFileSystem.swift +216 -0
- package/ios/RCTCloudStorageCloudKit.mm +209 -0
- package/ios/RCTCloudStorageLocalFileSystem.mm +149 -0
- package/ios/Utils/CloudKitUtils.swift +12 -6
- package/ios/Utils/CloudStorageError.swift +8 -0
- package/ios/Utils/FileUtils.swift +21 -4
- package/ios/Utils/Promise.swift +1 -0
- package/ios/Utils/Types.swift +8 -1
- package/ios/react_native_cloud_storage.h +6 -0
- package/package.json +64 -110
- package/react-native-cloud-storage.podspec +2 -0
- package/src/{RNCloudStorage.ts → cloud-storage.ts} +210 -100
- package/src/expo-plugin/{withRNCloudStorage.ts → index.ts} +2 -2
- package/src/hooks/{useCloudFile.ts → use-cloud-file.ts} +24 -6
- package/src/hooks/{useIsCloudAvailable.ts → use-is-cloud-available.ts} +1 -1
- package/src/index.ts +5 -6
- package/src/specs/NativeCloudStorageCloudKitIOS.ts +33 -0
- package/src/specs/NativeCloudStorageLocalFileSystem.ts +28 -0
- package/src/storages/cloudkit.ts +13 -0
- package/src/{google-drive → storages/google-drive}/client.ts +100 -41
- package/src/storages/google-drive/index.ts +488 -0
- package/src/types/main.ts +9 -0
- package/src/types/native.ts +14 -22
- package/src/utils/cloud-storage-error.ts +15 -0
- package/src/utils/constants.ts +21 -0
- package/src/utils/local-fs.ts +19 -0
- package/src/utils/native.ts +40 -0
- package/ios/CloudStorage.m +0 -22
- package/ios/CloudStorage.swift +0 -103
- package/ios/CloudStorageEventEmitter.m +0 -16
- package/ios/CloudStorageEventEmitter.swift +0 -30
- package/lib/commonjs/RNCloudStorage.js.map +0 -1
- package/lib/commonjs/expo-plugin/withRNCloudStorage.js +0 -13
- package/lib/commonjs/expo-plugin/withRNCloudStorage.js.map +0 -1
- package/lib/commonjs/expo-plugin/withRNCloudStorageIos.js.map +0 -1
- package/lib/commonjs/google-drive/client.js.map +0 -1
- package/lib/commonjs/google-drive/index.js +0 -321
- package/lib/commonjs/google-drive/index.js.map +0 -1
- package/lib/commonjs/google-drive/types.js.map +0 -1
- package/lib/commonjs/hooks/useCloudFile.js.map +0 -1
- package/lib/commonjs/hooks/useIsCloudAvailable.js.map +0 -1
- package/lib/commonjs/index.js.map +0 -1
- package/lib/commonjs/types/native.js +0 -26
- package/lib/commonjs/types/native.js.map +0 -1
- package/lib/commonjs/utils/CloudStorageError.js.map +0 -1
- package/lib/module/RNCloudStorage.js.map +0 -1
- package/lib/module/expo-plugin/withRNCloudStorage.js +0 -8
- package/lib/module/expo-plugin/withRNCloudStorage.js.map +0 -1
- package/lib/module/expo-plugin/withRNCloudStorageIos.js.map +0 -1
- package/lib/module/google-drive/client.js.map +0 -1
- package/lib/module/google-drive/index.js +0 -313
- package/lib/module/google-drive/index.js.map +0 -1
- package/lib/module/google-drive/types.js.map +0 -1
- package/lib/module/hooks/useCloudFile.js.map +0 -1
- package/lib/module/hooks/useIsCloudAvailable.js.map +0 -1
- package/lib/module/index.js +0 -10
- package/lib/module/index.js.map +0 -1
- package/lib/module/types/native.js +0 -22
- package/lib/module/types/native.js.map +0 -1
- package/lib/module/utils/CloudStorageError.js.map +0 -1
- package/lib/typescript/RNCloudStorage.d.ts.map +0 -1
- package/lib/typescript/expo-plugin/withRNCloudStorage.d.ts.map +0 -1
- package/lib/typescript/expo-plugin/withRNCloudStorageIos.d.ts.map +0 -1
- package/lib/typescript/google-drive/client.d.ts.map +0 -1
- package/lib/typescript/google-drive/index.d.ts +0 -34
- package/lib/typescript/google-drive/index.d.ts.map +0 -1
- package/lib/typescript/google-drive/types.d.ts.map +0 -1
- package/lib/typescript/hooks/useCloudFile.d.ts.map +0 -1
- package/lib/typescript/hooks/useIsCloudAvailable.d.ts.map +0 -1
- package/lib/typescript/index.d.ts +0 -8
- package/lib/typescript/index.d.ts.map +0 -1
- package/lib/typescript/types/main.d.ts.map +0 -1
- package/lib/typescript/types/native.d.ts +0 -40
- package/lib/typescript/types/native.d.ts.map +0 -1
- package/lib/typescript/utils/CloudStorageError.d.ts +0 -8
- package/lib/typescript/utils/CloudStorageError.d.ts.map +0 -1
- package/src/google-drive/index.ts +0 -399
- package/src/utils/CloudStorageError.ts +0 -14
- /package/{lib → dist}/commonjs/expo-plugin/types/index.js +0 -0
- /package/{lib → dist}/commonjs/expo-plugin/types/index.js.map +0 -0
- /package/{lib/commonjs → dist/commonjs/storages}/google-drive/types.js +0 -0
- /package/{lib → dist}/commonjs/types/main.js +0 -0
- /package/{lib → dist}/commonjs/utils/helpers.js +0 -0
- /package/{lib → dist}/commonjs/utils/helpers.js.map +0 -0
- /package/{lib → dist}/module/expo-plugin/types/index.js +0 -0
- /package/{lib → dist}/module/expo-plugin/types/index.js.map +0 -0
- /package/{lib → dist}/module/package.json +0 -0
- /package/{lib/module → dist/module/storages}/google-drive/types.js +0 -0
- /package/{lib → dist}/module/types/main.js +0 -0
- /package/{lib → dist}/module/utils/helpers.js +0 -0
- /package/{lib → dist}/module/utils/helpers.js.map +0 -0
- /package/{lib → dist}/typescript/expo-plugin/types/index.d.ts +0 -0
- /package/{lib → dist}/typescript/expo-plugin/types/index.d.ts.map +0 -0
- /package/{lib/typescript → dist/typescript/storages}/google-drive/types.d.ts +0 -0
- /package/{lib → dist}/typescript/utils/helpers.d.ts +0 -0
- /package/src/expo-plugin/{withRNCloudStorageIos.ts → ios.ts} +0 -0
- /package/src/{google-drive → storages/google-drive}/types.ts +0 -0
|
@@ -5,51 +5,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _main = require("./types/main");
|
|
8
|
+
var _native = require("./types/native");
|
|
8
9
|
var _helpers = require("./utils/helpers");
|
|
9
10
|
var _reactNative = require("react-native");
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
11
|
+
var _googleDrive = _interopRequireDefault(require("./storages/google-drive"));
|
|
12
|
+
var _cloudkit = require("./storages/cloudkit");
|
|
13
|
+
var _constants = require("./utils/constants");
|
|
14
|
+
var _cloudStorageError = _interopRequireDefault(require("./utils/cloud-storage-error"));
|
|
13
15
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
-
const LINKING_ERROR = `The package 'react-native-cloud-storage' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
|
|
15
|
-
ios: "- You have run 'pod install'\n",
|
|
16
|
-
default: ''
|
|
17
|
-
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
|
|
18
|
-
|
|
19
|
-
// proxy NativeModules.CloudStorage to catch any errors thrown by the native module and wrap them in a CloudStorageError
|
|
20
|
-
const nativeIosInstance = _reactNative.NativeModules.CloudStorage ? new Proxy(_reactNative.NativeModules.CloudStorage, {
|
|
21
|
-
get(target, prop) {
|
|
22
|
-
const originalFunction = target[prop];
|
|
23
|
-
if (typeof originalFunction === 'function') {
|
|
24
|
-
return async (...args) => {
|
|
25
|
-
try {
|
|
26
|
-
// @ts-expect-error - we can't know the types of the functions and their arguments
|
|
27
|
-
return await originalFunction(...args);
|
|
28
|
-
} catch (error) {
|
|
29
|
-
if (error?.code && Object.values(_native.CloudStorageErrorCode).includes(error.code)) {
|
|
30
|
-
throw new _CloudStorageError.default(error?.message || '', error.code);
|
|
31
|
-
} else {
|
|
32
|
-
throw new _CloudStorageError.default('Unknown error', _native.CloudStorageErrorCode.UNKNOWN, error);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
return originalFunction;
|
|
38
|
-
}
|
|
39
|
-
}) : null;
|
|
40
|
-
const defaultProviderOptions = {
|
|
41
|
-
[_main.CloudStorageProvider.ICloud]: {
|
|
42
|
-
scope: _main.CloudStorageScope.AppData
|
|
43
|
-
},
|
|
44
|
-
[_main.CloudStorageProvider.GoogleDrive]: {
|
|
45
|
-
scope: _main.CloudStorageScope.AppData,
|
|
46
|
-
accessToken: null,
|
|
47
|
-
strictFilenames: false,
|
|
48
|
-
timeout: 3000
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
16
|
class RNCloudStorage {
|
|
52
17
|
cloudAvailabilityListeners = [];
|
|
18
|
+
cloudAvailabilitySubscription = null;
|
|
53
19
|
|
|
54
20
|
//#region Constructor and configuration
|
|
55
21
|
/**
|
|
@@ -62,23 +28,27 @@ class RNCloudStorage {
|
|
|
62
28
|
}
|
|
63
29
|
this.provider = {
|
|
64
30
|
provider: provider ?? RNCloudStorage.getDefaultProvider(),
|
|
65
|
-
options:
|
|
31
|
+
options: _constants.DEFAULT_PROVIDER_OPTIONS[provider ?? RNCloudStorage.getDefaultProvider()]
|
|
66
32
|
};
|
|
67
33
|
this.setProvider(provider ?? RNCloudStorage.getDefaultProvider());
|
|
68
34
|
if (options) {
|
|
69
35
|
this.setProviderOptions(options);
|
|
70
36
|
}
|
|
71
37
|
}
|
|
72
|
-
get
|
|
38
|
+
get nativeStorage() {
|
|
73
39
|
switch (this.provider.provider) {
|
|
74
40
|
case _main.CloudStorageProvider.ICloud:
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
41
|
+
{
|
|
42
|
+
return _cloudkit.NativeCloudKit ?? new Proxy({}, {
|
|
43
|
+
get() {
|
|
44
|
+
throw new Error(_constants.LINKING_ERROR);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
80
48
|
default:
|
|
81
|
-
|
|
49
|
+
{
|
|
50
|
+
return new _googleDrive.default(this.provider.options);
|
|
51
|
+
}
|
|
82
52
|
}
|
|
83
53
|
}
|
|
84
54
|
|
|
@@ -89,9 +59,13 @@ class RNCloudStorage {
|
|
|
89
59
|
static getDefaultProvider() {
|
|
90
60
|
switch (_reactNative.Platform.OS) {
|
|
91
61
|
case 'ios':
|
|
92
|
-
|
|
62
|
+
{
|
|
63
|
+
return _main.CloudStorageProvider.ICloud;
|
|
64
|
+
}
|
|
93
65
|
default:
|
|
94
|
-
|
|
66
|
+
{
|
|
67
|
+
return _main.CloudStorageProvider.GoogleDrive;
|
|
68
|
+
}
|
|
95
69
|
}
|
|
96
70
|
}
|
|
97
71
|
|
|
@@ -100,7 +74,7 @@ class RNCloudStorage {
|
|
|
100
74
|
* @returns An array of supported CloudStorageProviders.
|
|
101
75
|
*/
|
|
102
76
|
static getSupportedProviders() {
|
|
103
|
-
return Object.values(_main.CloudStorageProvider).filter(_helpers.isProviderSupported);
|
|
77
|
+
return Object.values(_main.CloudStorageProvider).filter(provider => (0, _helpers.isProviderSupported)(provider));
|
|
104
78
|
}
|
|
105
79
|
|
|
106
80
|
/**
|
|
@@ -110,6 +84,38 @@ class RNCloudStorage {
|
|
|
110
84
|
getProvider() {
|
|
111
85
|
return this.provider.provider;
|
|
112
86
|
}
|
|
87
|
+
notifyCloudAvailabilityListeners(available) {
|
|
88
|
+
for (const listener of this.cloudAvailabilityListeners) {
|
|
89
|
+
listener(available);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
refreshCloudAvailability() {
|
|
93
|
+
this.nativeStorage.isCloudAvailable().then(available => {
|
|
94
|
+
this.notifyCloudAvailabilityListeners(available);
|
|
95
|
+
}).catch(() => {
|
|
96
|
+
// ignore errors when refreshing availability after provider changes
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
getNativeCloudKitModule() {
|
|
100
|
+
return this.provider.provider === _main.CloudStorageProvider.ICloud ? _cloudkit.NativeCloudKitModule : null;
|
|
101
|
+
}
|
|
102
|
+
removeCloudAvailabilitySubscription() {
|
|
103
|
+
this.cloudAvailabilitySubscription?.remove();
|
|
104
|
+
this.cloudAvailabilitySubscription = null;
|
|
105
|
+
}
|
|
106
|
+
configureCloudAvailabilitySubscription() {
|
|
107
|
+
this.removeCloudAvailabilitySubscription();
|
|
108
|
+
if (this.cloudAvailabilityListeners.length === 0) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const nativeCloudKitModule = this.getNativeCloudKitModule();
|
|
112
|
+
if (!nativeCloudKitModule) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
this.cloudAvailabilitySubscription = nativeCloudKitModule.onCloudAvailabilityChanged(event => {
|
|
116
|
+
this.notifyCloudAvailabilityListeners(event.available);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
113
119
|
|
|
114
120
|
/**
|
|
115
121
|
* Sets the current CloudStorageProvider.
|
|
@@ -121,24 +127,10 @@ class RNCloudStorage {
|
|
|
121
127
|
}
|
|
122
128
|
this.provider = {
|
|
123
129
|
provider,
|
|
124
|
-
options:
|
|
130
|
+
options: _constants.DEFAULT_PROVIDER_OPTIONS[provider]
|
|
125
131
|
};
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
this.nativeInstance.isCloudAvailable().then(available => {
|
|
129
|
-
this.cloudAvailabilityListeners.forEach(listener => {
|
|
130
|
-
listener(available);
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
if (provider === _main.CloudStorageProvider.ICloud) {
|
|
134
|
-
// Listen to native cloud availability change events
|
|
135
|
-
const eventEmitter = new _reactNative.NativeEventEmitter(_reactNative.NativeModules.CloudStorageEventEmitter);
|
|
136
|
-
eventEmitter.addListener('RNCloudStorage.cloud.availability-changed', event => {
|
|
137
|
-
this.cloudAvailabilityListeners.forEach(listener => {
|
|
138
|
-
listener(event.available);
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
}
|
|
132
|
+
this.refreshCloudAvailability();
|
|
133
|
+
this.configureCloudAvailabilitySubscription();
|
|
142
134
|
}
|
|
143
135
|
|
|
144
136
|
/**
|
|
@@ -161,16 +153,32 @@ class RNCloudStorage {
|
|
|
161
153
|
};
|
|
162
154
|
if (this.provider.provider === _main.CloudStorageProvider.GoogleDrive && 'accessToken' in newOptions) {
|
|
163
155
|
// Emit an event to notify useIsCloudAvailable() hook consumers of the new cloud availability status
|
|
164
|
-
this.
|
|
165
|
-
listener(!!newOptions.accessToken?.length);
|
|
166
|
-
});
|
|
156
|
+
this.notifyCloudAvailabilityListeners(!!newOptions.accessToken?.length);
|
|
167
157
|
}
|
|
168
158
|
}
|
|
169
159
|
subscribeToCloudAvailability(listener) {
|
|
170
160
|
this.cloudAvailabilityListeners.push(listener);
|
|
161
|
+
if (this.cloudAvailabilityListeners.length === 1) {
|
|
162
|
+
this.configureCloudAvailabilitySubscription();
|
|
163
|
+
this.refreshCloudAvailability();
|
|
164
|
+
}
|
|
171
165
|
}
|
|
172
166
|
unsubscribeFromCloudAvailability(listener) {
|
|
173
167
|
this.cloudAvailabilityListeners = this.cloudAvailabilityListeners.filter(l => l !== listener);
|
|
168
|
+
if (this.cloudAvailabilityListeners.length === 0) {
|
|
169
|
+
this.removeCloudAvailabilitySubscription();
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
resolveNativeScope(scope) {
|
|
173
|
+
const resolvedScope = scope ?? this.provider.options.scope;
|
|
174
|
+
if (this.provider.provider !== _main.CloudStorageProvider.ICloud || resolvedScope !== _main.CloudStorageScope.Documents) {
|
|
175
|
+
return resolvedScope;
|
|
176
|
+
}
|
|
177
|
+
const iCloudOptions = this.provider.options;
|
|
178
|
+
if (iCloudOptions.documentsMode === 'legacy_sandbox') {
|
|
179
|
+
return 'documents_legacy';
|
|
180
|
+
}
|
|
181
|
+
return resolvedScope;
|
|
174
182
|
}
|
|
175
183
|
//#endregion
|
|
176
184
|
|
|
@@ -181,7 +189,7 @@ class RNCloudStorage {
|
|
|
181
189
|
* @returns A promise that resolves to true if the cloud storage is available, false otherwise.
|
|
182
190
|
*/
|
|
183
191
|
isCloudAvailable() {
|
|
184
|
-
return this.
|
|
192
|
+
return this.nativeStorage.isCloudAvailable();
|
|
185
193
|
}
|
|
186
194
|
|
|
187
195
|
/**
|
|
@@ -192,7 +200,7 @@ class RNCloudStorage {
|
|
|
192
200
|
* @returns A promise that resolves when the data has been appended.
|
|
193
201
|
*/
|
|
194
202
|
appendFile(path, data, scope) {
|
|
195
|
-
return this.
|
|
203
|
+
return this.nativeStorage.appendToFile(path, data, this.resolveNativeScope(scope));
|
|
196
204
|
}
|
|
197
205
|
|
|
198
206
|
/**
|
|
@@ -202,7 +210,7 @@ class RNCloudStorage {
|
|
|
202
210
|
* @returns A promise that resolves to true if the path exists, false otherwise.
|
|
203
211
|
*/
|
|
204
212
|
exists(path, scope) {
|
|
205
|
-
return this.
|
|
213
|
+
return this.nativeStorage.fileExists(path, this.resolveNativeScope(scope));
|
|
206
214
|
}
|
|
207
215
|
|
|
208
216
|
/**
|
|
@@ -213,7 +221,7 @@ class RNCloudStorage {
|
|
|
213
221
|
* @returns A promise that resolves when the file has been written.
|
|
214
222
|
*/
|
|
215
223
|
writeFile(path, data, scope) {
|
|
216
|
-
return this.
|
|
224
|
+
return this.nativeStorage.createFile(path, data, this.resolveNativeScope(scope), true);
|
|
217
225
|
}
|
|
218
226
|
|
|
219
227
|
/**
|
|
@@ -223,7 +231,7 @@ class RNCloudStorage {
|
|
|
223
231
|
* @returns A promise that resolves when the directory has been created.
|
|
224
232
|
*/
|
|
225
233
|
mkdir(path, scope) {
|
|
226
|
-
return this.
|
|
234
|
+
return this.nativeStorage.createDirectory(path, this.resolveNativeScope(scope));
|
|
227
235
|
}
|
|
228
236
|
|
|
229
237
|
/**
|
|
@@ -233,7 +241,7 @@ class RNCloudStorage {
|
|
|
233
241
|
* @returns A promise that resolves to an array of file names, excluding '.' and '..'.
|
|
234
242
|
*/
|
|
235
243
|
readdir(path, scope) {
|
|
236
|
-
return this.
|
|
244
|
+
return this.nativeStorage.listFiles(path, this.resolveNativeScope(scope));
|
|
237
245
|
}
|
|
238
246
|
|
|
239
247
|
/**
|
|
@@ -243,17 +251,55 @@ class RNCloudStorage {
|
|
|
243
251
|
* @returns A promise that resolves to the contents of the file.
|
|
244
252
|
*/
|
|
245
253
|
readFile(path, scope) {
|
|
246
|
-
return this.
|
|
254
|
+
return this.nativeStorage.readFile(path, this.resolveNativeScope(scope));
|
|
247
255
|
}
|
|
248
256
|
|
|
249
257
|
/**
|
|
250
|
-
*
|
|
251
|
-
* @param path The file to trigger
|
|
258
|
+
* Triggers synchronization for the file at the given path. Does not have any effect on Google Drive.
|
|
259
|
+
* @param path The file to trigger synchronization for.
|
|
252
260
|
* @param scope The directory scope the path is in. Defaults to set default scope set for the current provider.
|
|
253
|
-
* @returns A promise that resolves once the
|
|
261
|
+
* @returns A promise that resolves once the synchronization has been triggered.
|
|
254
262
|
*/
|
|
255
|
-
|
|
256
|
-
return this.
|
|
263
|
+
triggerSync(path, scope) {
|
|
264
|
+
return this.nativeStorage.triggerSync(path, this.resolveNativeScope(scope));
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Uploads the file at the given local path to the given path, creating it if it doesn't exist or overwriting it if it does.
|
|
269
|
+
* @param remotePath The remote path to upload to.
|
|
270
|
+
* @param localPath The local path of the file to upload.
|
|
271
|
+
* @param options The options for the upload. Must contain a `mimeType` property.
|
|
272
|
+
* @param scope The directory scope the path is in. Defaults to set default scope set for the current provider.
|
|
273
|
+
* @returns A promise that resolves when the file has been uploaded.
|
|
274
|
+
*/
|
|
275
|
+
uploadFile(remotePath, localPath, options, scope) {
|
|
276
|
+
return this.nativeStorage.uploadFile(remotePath, localPath, options.mimeType, this.resolveNativeScope(scope), true);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Triggers synchronization for the file at the given path. Does not have any effect on Google Drive.
|
|
281
|
+
* @param path The file to trigger synchronization for.
|
|
282
|
+
* @param scope The directory scope the path is in. Defaults to set default scope set for the current provider.
|
|
283
|
+
* @returns A promise that resolves once the synchronization has been triggered.
|
|
284
|
+
* @deprecated Use `triggerSync` instead.
|
|
285
|
+
*/
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Downloads the cloud file at the given remote path to the given local path.
|
|
289
|
+
* @param remotePath The remote path of the file to download from the cloud.
|
|
290
|
+
* @param localPath The local path to download the cloud file to.
|
|
291
|
+
* @param scope The directory scope the path is in. Defaults to set default scope set for the current provider.
|
|
292
|
+
*/
|
|
293
|
+
|
|
294
|
+
downloadFile(remotePathOrPath, localPathOrScope, scope) {
|
|
295
|
+
if (!localPathOrScope || !scope && typeof localPathOrScope === 'string' && Object.values(_main.CloudStorageScope).includes(localPathOrScope)) {
|
|
296
|
+
// deprecated `triggerSync` call
|
|
297
|
+
return this.triggerSync(remotePathOrPath, scope);
|
|
298
|
+
}
|
|
299
|
+
if (!localPathOrScope) {
|
|
300
|
+
throw new _cloudStorageError.default('Invalid arguments provided to downloadFile', _native.NativeCloudStorageErrorCode.UNKNOWN);
|
|
301
|
+
}
|
|
302
|
+
return this.nativeStorage.downloadFile(remotePathOrPath, localPathOrScope, this.resolveNativeScope(scope));
|
|
257
303
|
}
|
|
258
304
|
|
|
259
305
|
/**
|
|
@@ -263,7 +309,7 @@ class RNCloudStorage {
|
|
|
263
309
|
* @returns A promise that resolves when the file has been deleted.
|
|
264
310
|
*/
|
|
265
311
|
unlink(path, scope) {
|
|
266
|
-
return this.
|
|
312
|
+
return this.nativeStorage.deleteFile(path, this.resolveNativeScope(scope));
|
|
267
313
|
}
|
|
268
314
|
|
|
269
315
|
/**
|
|
@@ -274,7 +320,7 @@ class RNCloudStorage {
|
|
|
274
320
|
* @returns A promise that resolves when the directory has been deleted.
|
|
275
321
|
*/
|
|
276
322
|
rmdir(path, options, scope) {
|
|
277
|
-
return this.
|
|
323
|
+
return this.nativeStorage.deleteDirectory(path, options?.recursive ?? false, this.resolveNativeScope(scope));
|
|
278
324
|
}
|
|
279
325
|
|
|
280
326
|
/**
|
|
@@ -284,7 +330,7 @@ class RNCloudStorage {
|
|
|
284
330
|
* @returns A promise that resolves to the CloudStorageFileStat object.
|
|
285
331
|
*/
|
|
286
332
|
async stat(path, scope) {
|
|
287
|
-
const native = await this.
|
|
333
|
+
const native = await this.nativeStorage.statFile(path, this.resolveNativeScope(scope));
|
|
288
334
|
return {
|
|
289
335
|
...native,
|
|
290
336
|
birthtime: new Date(native.birthtimeMs),
|
|
@@ -407,13 +453,52 @@ class RNCloudStorage {
|
|
|
407
453
|
}
|
|
408
454
|
|
|
409
455
|
/**
|
|
410
|
-
*
|
|
411
|
-
* @param path The file to trigger
|
|
456
|
+
* Triggers synchronization for the file at the given path in the provider of the default static instance. Does not have any effect on Google Drive.
|
|
457
|
+
* @param path The file to trigger synchronization for.
|
|
412
458
|
* @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 once the
|
|
459
|
+
* @returns A promise that resolves once the synchronization has been triggered.
|
|
414
460
|
*/
|
|
415
|
-
static
|
|
416
|
-
return RNCloudStorage.getDefaultInstance().
|
|
461
|
+
static triggerSync(path, scope) {
|
|
462
|
+
return RNCloudStorage.getDefaultInstance().triggerSync(path, scope);
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* Uploads the file at the given local path to the given path in the provider of the default static instance, creating it if it doesn't exist or overwriting it if it does.
|
|
467
|
+
* @param remotePath The remote path to upload to.
|
|
468
|
+
* @param localPath The local path of the file to upload.
|
|
469
|
+
* @param options The options for the upload. Must contain a `mimeType` property.
|
|
470
|
+
* @param scope The directory scope the path is in. Defaults to set default scope set for the current provider.
|
|
471
|
+
* @returns A promise that resolves when the file has been uploaded.
|
|
472
|
+
*/
|
|
473
|
+
static uploadFile(remotePath, localPath, options, scope) {
|
|
474
|
+
return RNCloudStorage.getDefaultInstance().uploadFile(remotePath, localPath, options, scope);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* Triggers synchronization for the file at the given path in the provider of the default static instance. Does not have any effect on Google Drive.
|
|
479
|
+
* @param path The file to trigger synchronization for.
|
|
480
|
+
* @param scope The directory scope the path is in. Defaults to set default scope set for the current provider.
|
|
481
|
+
* @returns A promise that resolves once the synchronization has been triggered.
|
|
482
|
+
* @deprecated Use `triggerSync` instead.
|
|
483
|
+
*/
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* Downloads the cloud file at the given remote path to the given local path.
|
|
487
|
+
* @param remotePath The remote path of the file to download from the cloud.
|
|
488
|
+
* @param localPath The local path to download the cloud file to.
|
|
489
|
+
* @param scope The directory scope the path is in. Defaults to set default scope set for the current provider.
|
|
490
|
+
*/
|
|
491
|
+
|
|
492
|
+
static downloadFile(remotePathOrPath, localPathOrScope, scope) {
|
|
493
|
+
if (typeof scope === 'string') {
|
|
494
|
+
if (!localPathOrScope) {
|
|
495
|
+
throw new _cloudStorageError.default('Invalid arguments provided to downloadFile', _native.NativeCloudStorageErrorCode.UNKNOWN);
|
|
496
|
+
}
|
|
497
|
+
return RNCloudStorage.getDefaultInstance().downloadFile(remotePathOrPath, localPathOrScope, scope);
|
|
498
|
+
} else {
|
|
499
|
+
// deprecated `triggerSync` call
|
|
500
|
+
return RNCloudStorage.getDefaultInstance().triggerSync(remotePathOrPath, scope);
|
|
501
|
+
}
|
|
417
502
|
}
|
|
418
503
|
|
|
419
504
|
/**
|
|
@@ -449,4 +534,4 @@ class RNCloudStorage {
|
|
|
449
534
|
//#endregion
|
|
450
535
|
}
|
|
451
536
|
exports.default = RNCloudStorage;
|
|
452
|
-
//# sourceMappingURL=
|
|
537
|
+
//# sourceMappingURL=cloud-storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_main","require","_native","_helpers","_reactNative","_googleDrive","_interopRequireDefault","_cloudkit","_constants","_cloudStorageError","e","__esModule","default","RNCloudStorage","cloudAvailabilityListeners","cloudAvailabilitySubscription","constructor","provider","options","isProviderSupported","Error","getDefaultProvider","DEFAULT_PROVIDER_OPTIONS","setProvider","setProviderOptions","nativeStorage","CloudStorageProvider","ICloud","NativeCloudKit","Proxy","get","LINKING_ERROR","GoogleDrive","Platform","OS","getSupportedProviders","Object","values","filter","getProvider","notifyCloudAvailabilityListeners","available","listener","refreshCloudAvailability","isCloudAvailable","then","catch","getNativeCloudKitModule","NativeCloudKitModule","removeCloudAvailabilitySubscription","remove","configureCloudAvailabilitySubscription","length","nativeCloudKitModule","onCloudAvailabilityChanged","event","getProviderOptions","newOptions","fromEntries","entries","_","v","undefined","accessToken","subscribeToCloudAvailability","push","unsubscribeFromCloudAvailability","l","resolveNativeScope","scope","resolvedScope","CloudStorageScope","Documents","iCloudOptions","documentsMode","appendFile","path","data","appendToFile","exists","fileExists","writeFile","createFile","mkdir","createDirectory","readdir","listFiles","readFile","triggerSync","uploadFile","remotePath","localPath","mimeType","downloadFile","remotePathOrPath","localPathOrScope","includes","CloudStorageError","NativeCloudStorageErrorCode","UNKNOWN","unlink","deleteFile","rmdir","deleteDirectory","recursive","stat","native","statFile","birthtime","Date","birthtimeMs","mtime","mtimeMs","isDirectory","isFile","getDefaultInstance","defaultInstance","exports"],"sourceRoot":"../../src","sources":["cloud-storage.ts"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAOA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AACA,IAAAO,UAAA,GAAAP,OAAA;AACA,IAAAQ,kBAAA,GAAAH,sBAAA,CAAAL,OAAA;AAA4D,SAAAK,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE7C,MAAMG,cAAc,CAAC;EAM1BC,0BAA0B,GAAqC,EAAE;EACjEC,6BAA6B,GAA6B,IAAI;;EAEtE;EACA;AACF;AACA;AACA;EACEC,WAAWA,CACTC,QAA+B,EAC/BC,OAAwE,EACxE;IACA,IAAID,QAAQ,IAAI,CAAC,IAAAE,4BAAmB,EAACF,QAAQ,CAAC,EAAE;MAC9C,MAAM,IAAIG,KAAK,CAAC,YAAYH,QAAQ,4CAA4C,CAAC;IACnF;IAEA,IAAI,CAACA,QAAQ,GAAG;MACdA,QAAQ,EAAEA,QAAQ,IAAIJ,cAAc,CAACQ,kBAAkB,CAAC,CAAC;MACzDH,OAAO,EAAEI,mCAAwB,CAACL,QAAQ,IAAIJ,cAAc,CAACQ,kBAAkB,CAAC,CAAC;IACnF,CAAC;IAED,IAAI,CAACE,WAAW,CAACN,QAAQ,IAAIJ,cAAc,CAACQ,kBAAkB,CAAC,CAAC,CAAC;IACjE,IAAIH,OAAO,EAAE;MACX,IAAI,CAACM,kBAAkB,CAACN,OAAO,CAAC;IAClC;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gD,OAAA,CAAAzG,OAAA,GAAAC,cAAA","ignoreList":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _ios = _interopRequireDefault(require("./ios"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
// Android config plugin not needed as there's nothing to configure.
|
|
10
|
+
|
|
11
|
+
const withRNCloudStorage = (config, options) => (0, _ios.default)(config, options);
|
|
12
|
+
var _default = exports.default = withRNCloudStorage;
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_ios","_interopRequireDefault","require","e","__esModule","default","withRNCloudStorage","config","options","withRNCloudStorageIos","_default","exports"],"sourceRoot":"../../../src","sources":["expo-plugin/index.ts"],"mappings":";;;;;;AACA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA0C,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAG1C;;AAEA,MAAMG,kBAAmE,GAAGA,CAACC,MAAM,EAAEC,OAAO,KAC1F,IAAAC,YAAqB,EAACF,MAAM,EAAEC,OAAO,CAAC;AAAC,IAAAE,QAAA,GAAAC,OAAA,CAAAN,OAAA,GAE1BC,kBAAkB","ignoreList":[]}
|
package/{lib/commonjs/expo-plugin/withRNCloudStorageIos.js → dist/commonjs/expo-plugin/ios.js}
RENAMED
|
@@ -34,4 +34,4 @@ const withRNCloudStorageEntitlementsPlist = (config, options) => (0, _configPlug
|
|
|
34
34
|
});
|
|
35
35
|
const withRNCloudStorageIos = (config, options) => (0, _configPlugins.withPlugins)(config, [[withRNCloudStorageInfoPlist, options], [withRNCloudStorageEntitlementsPlist, options]]);
|
|
36
36
|
var _default = exports.default = withRNCloudStorageIos;
|
|
37
|
-
//# sourceMappingURL=
|
|
37
|
+
//# sourceMappingURL=ios.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_configPlugins","require","getICloudContainerIdentifier","config","options","iCloudContainerIdentifier","ios","bundleIdentifier","Error","withRNCloudStorageInfoPlist","withInfoPlist","newConfig","infoPlist","modResults","NSUbiquitousContainers","NSUbiquitousContainerIsDocumentScopePublic","NSUbiquitousContainerSupportedFolderLevels","NSUbiquitousContainerName","slug","withRNCloudStorageEntitlementsPlist","withEntitlementsPlist","entitlementsPlist","iCloudContainerEnvironment","withRNCloudStorageIos","withPlugins","_default","exports","default"],"sourceRoot":"../../../src","sources":["expo-plugin/ios.ts"],"mappings":";;;;;;AAAA,IAAAA,cAAA,GAAAC,OAAA;AAIA,MAAMC,4BAA4B,GAAGA,CAACC,MAAkB,EAAEC,OAA0C,KAAK;EACvG,IAAIA,OAAO,EAAEC,yBAAyB,EAAE,OAAOD,OAAO,CAACC,yBAAyB;EAEhF,IAAI,CAACF,MAAM,EAAEG,GAAG,EAAEC,gBAAgB,EAAE,MAAM,IAAIC,KAAK,CAAC,+BAA+B,CAAC;EACpF,OAAO,UAAUL,MAAM,CAACG,GAAG,CAACC,gBAAgB,EAAE;AAChD,CAAC;AAED,MAAME,2BAA4E,GAAGA,CAACN,MAAM,EAAEC,OAAO,KACnG,IAAAM,4BAAa,EAACP,MAAM,EAAE,MAAOQ,SAAS,IAAK;EACzC,MAAMC,SAAS,GAAGD,SAAS,CAACE,UAAU;EACtCD,SAAS,CAACE,sBAAsB,GAAG;IACjC,CAACZ,4BAA4B,CAACC,MAAM,EAAEC,OAAO,CAAC,GAAG;MAC/CW,0CAA0C,EAAE,IAAI;MAChDC,0CAA0C,EAAE,KAAK;MACjDC,yBAAyB,EAAEd,MAAM,CAACe;IACpC;EACF,CAAC;EAED,OAAOP,SAAS;AAClB,CAAC,CAAC;AAEJ,MAAMQ,mCAAoF,GAAGA,CAAChB,MAAM,EAAEC,OAAO,KAC3G,IAAAgB,oCAAqB,EAACjB,MAAM,EAAE,MAAOQ,SAAS,IAAK;EACjD,IAAI,CAACR,MAAM,CAACG,GAAG,EAAEC,gBAAgB,EAAE;IACjC,MAAM,IAAIC,KAAK,CAAC,+BAA+B,CAAC;EAClD;EACA,MAAMa,iBAAiB,GAAGV,SAAS,CAACE,UAAU;EAC9CQ,iBAAiB,CAAC,kDAAkD,CAAC,GAAG,CACtEnB,4BAA4B,CAACC,MAAM,EAAEC,OAAO,CAAC,CAC9C;EACDiB,iBAAiB,CAAC,qCAAqC,CAAC,GAAG,CAAC,gBAAgB,CAAC;EAC7EA,iBAAiB,CAAC,kDAAkD,CAAC,GACnEjB,OAAO,EAAEkB,0BAA0B,IAAI,YAAY;EACrDD,iBAAiB,CAAC,oDAAoD,CAAC,GAAG,CACxEnB,4BAA4B,CAACC,MAAM,EAAEC,OAAO,CAAC,CAC9C;EAED,OAAOO,SAAS;AAClB,CAAC,CAAC;AAEJ,MAAMY,qBAAsE,GAAGA,CAACpB,MAAM,EAAEC,OAAO,KAC7F,IAAAoB,0BAAW,EAACrB,MAAM,EAAE,CAClB,CAACM,2BAA2B,EAAEL,OAAO,CAAC,EACtC,CAACe,mCAAmC,EAAEf,OAAO,CAAC,CAC/C,CAAC;AAAC,IAAAqB,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEUJ,qBAAqB","ignoreList":[]}
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.useCloudFile = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _cloudStorage = _interopRequireDefault(require("../cloud-storage"));
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
10
|
/**
|
|
@@ -16,7 +16,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
16
16
|
*/
|
|
17
17
|
const useCloudFile = (path, scope, cloudStorageInstance) => {
|
|
18
18
|
const [content, setContent] = (0, _react.useState)(null);
|
|
19
|
-
const instance = cloudStorageInstance ??
|
|
19
|
+
const instance = cloudStorageInstance ?? _cloudStorage.default;
|
|
20
20
|
const read = (0, _react.useCallback)(async () => {
|
|
21
21
|
const exists = await instance.exists(path, scope);
|
|
22
22
|
if (!exists) {
|
|
@@ -36,20 +36,38 @@ const useCloudFile = (path, scope, cloudStorageInstance) => {
|
|
|
36
36
|
await instance.unlink(path, scope);
|
|
37
37
|
setContent(null);
|
|
38
38
|
}, [path, scope, instance]);
|
|
39
|
-
const
|
|
40
|
-
await instance.
|
|
39
|
+
const sync = (0, _react.useCallback)(async () => {
|
|
40
|
+
await instance.triggerSync(path, scope);
|
|
41
41
|
}, [path, scope, instance]);
|
|
42
42
|
return {
|
|
43
|
+
/**
|
|
44
|
+
* The content of the file.
|
|
45
|
+
*/
|
|
43
46
|
content,
|
|
47
|
+
/**
|
|
48
|
+
* Reads the file from the cloud.
|
|
49
|
+
*/
|
|
44
50
|
read,
|
|
51
|
+
/**
|
|
52
|
+
* Writes new content to the file.
|
|
53
|
+
*/
|
|
45
54
|
write,
|
|
55
|
+
/**
|
|
56
|
+
* Deletes the file.
|
|
57
|
+
*/
|
|
46
58
|
remove,
|
|
47
59
|
/**
|
|
48
|
-
*
|
|
49
|
-
* Google Drive.
|
|
60
|
+
* Triggers synchronization for the file. Needed if the file hasn't been synced yet from iCloud.
|
|
61
|
+
* Has no effect on Google Drive.
|
|
62
|
+
*/
|
|
63
|
+
sync,
|
|
64
|
+
/**
|
|
65
|
+
* Triggers synchronization for the file. Needed if the file hasn't been synced yet from iCloud.
|
|
66
|
+
* Has no effect on Google Drive.
|
|
67
|
+
* @deprecated Use `sync` instead.
|
|
50
68
|
*/
|
|
51
|
-
download
|
|
69
|
+
download: sync
|
|
52
70
|
};
|
|
53
71
|
};
|
|
54
72
|
exports.useCloudFile = useCloudFile;
|
|
55
|
-
//# sourceMappingURL=
|
|
73
|
+
//# sourceMappingURL=use-cloud-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_cloudStorage","_interopRequireDefault","require","_react","e","__esModule","default","useCloudFile","path","scope","cloudStorageInstance","content","setContent","useState","instance","RNCloudStorage","read","useCallback","exists","readFile","then","useEffect","write","newContent","writeFile","remove","unlink","sync","triggerSync","download","exports"],"sourceRoot":"../../../src","sources":["hooks/use-cloud-file.ts"],"mappings":";;;;;;AACA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAAyD,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEzD;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMG,YAAY,GAAGA,CAACC,IAAY,EAAEC,KAAyB,EAAEC,oBAAqC,KAAK;EAC9G,MAAM,CAACC,OAAO,EAAEC,UAAU,CAAC,GAAG,IAAAC,eAAQ,EAAgB,IAAI,CAAC;EAC3D,MAAMC,QAAQ,GAAGJ,oBAAoB,IAAIK,qBAAc;EAEvD,MAAMC,IAAI,GAAG,IAAAC,kBAAW,EAAC,YAAY;IACnC,MAAMC,MAAM,GAAG,MAAMJ,QAAQ,CAACI,MAAM,CAACV,IAAI,EAAEC,KAAK,CAAC;IACjD,IAAI,CAACS,MAAM,EAAE;MACXN,UAAU,CAAC,IAAI,CAAC;MAChB;IACF;IACAE,QAAQ,CAACK,QAAQ,CAACX,IAAI,EAAEC,KAAK,CAAC,CAACW,IAAI,CAACR,UAAU,CAAC;EACjD,CAAC,EAAE,CAACJ,IAAI,EAAEC,KAAK,EAAEK,QAAQ,CAAC,CAAC;EAE3B,IAAAO,gBAAS,EAAC,MAAM;IACdL,IAAI,CAAC,CAAC;EACR,CAAC,EAAE,CAACA,IAAI,CAAC,CAAC;EAEV,MAAMM,KAAK,GAAG,IAAAL,kBAAW,EACvB,MAAOM,UAAkB,IAAK;IAC5B,MAAMT,QAAQ,CAACU,SAAS,CAAChB,IAAI,EAAEe,UAAU,EAAEd,KAAK,CAAC;IACjDO,IAAI,CAAC,CAAC;EACR,CAAC,EACD,CAACR,IAAI,EAAEC,KAAK,EAAEO,IAAI,EAAEF,QAAQ,CAC9B,CAAC;EAED,MAAMW,MAAM,GAAG,IAAAR,kBAAW,EAAC,YAAY;IACrC,MAAMH,QAAQ,CAACY,MAAM,CAAClB,IAAI,EAAEC,KAAK,CAAC;IAClCG,UAAU,CAAC,IAAI,CAAC;EAClB,CAAC,EAAE,CAACJ,IAAI,EAAEC,KAAK,EAAEK,QAAQ,CAAC,CAAC;EAE3B,MAAMa,IAAI,GAAG,IAAAV,kBAAW,EAAC,YAAY;IACnC,MAAMH,QAAQ,CAACc,WAAW,CAACpB,IAAI,EAAEC,KAAK,CAAC;EACzC,CAAC,EAAE,CAACD,IAAI,EAAEC,KAAK,EAAEK,QAAQ,CAAC,CAAC;EAE3B,OAAO;IACL;AACJ;AACA;IACIH,OAAO;IACP;AACJ;AACA;IACIK,IAAI;IACJ;AACJ;AACA;IACIM,KAAK;IACL;AACJ;AACA;IACIG,MAAM;IACN;AACJ;AACA;AACA;IACIE,IAAI;IACJ;AACJ;AACA;AACA;AACA;IACIE,QAAQ,EAAEF;EACZ,CAAC;AACH,CAAC;AAACG,OAAA,CAAAvB,YAAA,GAAAA,YAAA","ignoreList":[]}
|
package/{lib/commonjs/hooks/useIsCloudAvailable.js → dist/commonjs/hooks/use-is-cloud-available.js}
RENAMED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.useIsCloudAvailable = void 0;
|
|
7
7
|
var _react = require("react");
|
|
8
|
-
var
|
|
8
|
+
var _cloudStorage = _interopRequireDefault(require("../cloud-storage"));
|
|
9
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
10
|
/**
|
|
11
11
|
* A hook that tests whether or not the cloud storage is available.
|
|
@@ -14,7 +14,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
14
14
|
*/
|
|
15
15
|
const useIsCloudAvailable = cloudStorageInstance => {
|
|
16
16
|
const [isAvailable, setIsAvailable] = (0, _react.useState)(false);
|
|
17
|
-
const instance = cloudStorageInstance ??
|
|
17
|
+
const instance = cloudStorageInstance ?? _cloudStorage.default.getDefaultInstance();
|
|
18
18
|
const handleAvailabilityChange = (0, _react.useCallback)(available => {
|
|
19
19
|
setIsAvailable(available);
|
|
20
20
|
}, []);
|
|
@@ -31,4 +31,4 @@ const useIsCloudAvailable = cloudStorageInstance => {
|
|
|
31
31
|
return isAvailable;
|
|
32
32
|
};
|
|
33
33
|
exports.useIsCloudAvailable = useIsCloudAvailable;
|
|
34
|
-
//# sourceMappingURL=
|
|
34
|
+
//# sourceMappingURL=use-is-cloud-available.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_cloudStorage","_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/use-is-cloud-available.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAC,sBAAA,CAAAF,OAAA;AAA8C,SAAAE,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE9C;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,qBAAc,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":[]}
|
|
@@ -4,30 +4,28 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
var _exportNames = {
|
|
7
|
-
CloudStorage: true,
|
|
8
7
|
CloudStorageErrorCode: true,
|
|
9
|
-
CloudStorageError: true
|
|
8
|
+
CloudStorageError: true,
|
|
9
|
+
CloudStorage: true
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "CloudStorage", {
|
|
12
12
|
enumerable: true,
|
|
13
13
|
get: function () {
|
|
14
|
-
return
|
|
14
|
+
return _cloudStorage.default;
|
|
15
15
|
}
|
|
16
16
|
});
|
|
17
17
|
Object.defineProperty(exports, "CloudStorageError", {
|
|
18
18
|
enumerable: true,
|
|
19
19
|
get: function () {
|
|
20
|
-
return
|
|
20
|
+
return _cloudStorageError.default;
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
23
|
Object.defineProperty(exports, "CloudStorageErrorCode", {
|
|
24
24
|
enumerable: true,
|
|
25
25
|
get: function () {
|
|
26
|
-
return _native.
|
|
26
|
+
return _native.NativeCloudStorageErrorCode;
|
|
27
27
|
}
|
|
28
28
|
});
|
|
29
|
-
var _RNCloudStorage = _interopRequireDefault(require("./RNCloudStorage"));
|
|
30
|
-
var _native = require("./types/native");
|
|
31
29
|
var _main = require("./types/main");
|
|
32
30
|
Object.keys(_main).forEach(function (key) {
|
|
33
31
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -40,7 +38,7 @@ Object.keys(_main).forEach(function (key) {
|
|
|
40
38
|
}
|
|
41
39
|
});
|
|
42
40
|
});
|
|
43
|
-
var _useCloudFile = require("./hooks/
|
|
41
|
+
var _useCloudFile = require("./hooks/use-cloud-file");
|
|
44
42
|
Object.keys(_useCloudFile).forEach(function (key) {
|
|
45
43
|
if (key === "default" || key === "__esModule") return;
|
|
46
44
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -52,7 +50,7 @@ Object.keys(_useCloudFile).forEach(function (key) {
|
|
|
52
50
|
}
|
|
53
51
|
});
|
|
54
52
|
});
|
|
55
|
-
var _useIsCloudAvailable = require("./hooks/
|
|
53
|
+
var _useIsCloudAvailable = require("./hooks/use-is-cloud-available");
|
|
56
54
|
Object.keys(_useIsCloudAvailable).forEach(function (key) {
|
|
57
55
|
if (key === "default" || key === "__esModule") return;
|
|
58
56
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -64,6 +62,8 @@ Object.keys(_useIsCloudAvailable).forEach(function (key) {
|
|
|
64
62
|
}
|
|
65
63
|
});
|
|
66
64
|
});
|
|
67
|
-
var
|
|
65
|
+
var _native = require("./types/native");
|
|
66
|
+
var _cloudStorageError = _interopRequireDefault(require("./utils/cloud-storage-error"));
|
|
67
|
+
var _cloudStorage = _interopRequireDefault(require("./cloud-storage"));
|
|
68
68
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
69
69
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_main","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_useCloudFile","_useIsCloudAvailable","_native","_cloudStorageError","_interopRequireDefault","_cloudStorage","e","__esModule","default"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,KAAA,EAAAI,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,MAAAL,KAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAb,KAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,aAAA,GAAAb,OAAA;AAAAC,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,GAAAd,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAY,oBAAA,EAAAX,OAAA,WAA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