react-native-cloud-storage 1.5.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +5 -6
- package/ios/CloudStorage.swift +262 -52
- package/ios/CloudStorage.xcodeproj/project.pbxproj +0 -28
- package/ios/CloudStorage.xcodeproj/project.xcworkspace/contents.xcworkspacedata +4 -0
- package/ios/CloudStorage.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/ios/CloudStorage.xcodeproj/project.xcworkspace/xcuserdata/max.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/CloudStorage.xcodeproj/xcuserdata/max.xcuserdatad/xcschemes/xcschememanagement.plist +22 -0
- package/ios/CloudStorageEventEmitter.swift +4 -4
- package/lib/commonjs/RNCloudStorage.js +66 -361
- package/lib/commonjs/RNCloudStorage.js.map +1 -1
- package/lib/commonjs/createRNCloudStorage.js +48 -0
- package/lib/commonjs/createRNCloudStorage.js.map +1 -0
- package/lib/commonjs/expo-plugin/types/index.js.map +1 -1
- package/lib/commonjs/expo-plugin/withRNCloudStorage.js +3 -2
- package/lib/commonjs/expo-plugin/withRNCloudStorage.js.map +1 -1
- package/lib/commonjs/expo-plugin/withRNCloudStorageIos.js +7 -4
- package/lib/commonjs/expo-plugin/withRNCloudStorageIos.js.map +1 -1
- package/lib/commonjs/google-drive/client.js +20 -16
- package/lib/commonjs/google-drive/client.js.map +1 -1
- package/lib/commonjs/google-drive/index.js +64 -42
- package/lib/commonjs/google-drive/index.js.map +1 -1
- package/lib/commonjs/google-drive/types.js +2 -1
- package/lib/commonjs/google-drive/types.js.map +1 -1
- package/lib/commonjs/hooks/useCloudFile.js +17 -14
- package/lib/commonjs/hooks/useCloudFile.js.map +1 -1
- package/lib/commonjs/hooks/useIsCloudAvailable.js +21 -11
- package/lib/commonjs/hooks/useIsCloudAvailable.js.map +1 -1
- package/lib/commonjs/index.js +7 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types/main.js +3 -8
- 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 +2 -1
- package/lib/commonjs/utils/CloudStorageError.js.map +1 -1
- package/lib/commonjs/utils/helpers.js +15 -8
- package/lib/commonjs/utils/helpers.js.map +1 -1
- package/lib/module/RNCloudStorage.js +65 -362
- package/lib/module/RNCloudStorage.js.map +1 -1
- package/lib/module/createRNCloudStorage.js +41 -0
- package/lib/module/createRNCloudStorage.js.map +1 -0
- 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 +0 -2
- 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 +20 -18
- package/lib/module/google-drive/client.js.map +1 -1
- package/lib/module/google-drive/index.js +62 -41
- package/lib/module/google-drive/index.js.map +1 -1
- package/lib/module/google-drive/types.js +0 -2
- package/lib/module/google-drive/types.js.map +1 -1
- package/lib/module/hooks/useCloudFile.js +16 -15
- package/lib/module/hooks/useCloudFile.js.map +1 -1
- package/lib/module/hooks/useIsCloudAvailable.js +21 -13
- package/lib/module/hooks/useIsCloudAvailable.js.map +1 -1
- package/lib/module/index.js +5 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/types/main.js +0 -9
- package/lib/module/types/main.js.map +1 -1
- package/lib/module/types/native.js +1 -4
- package/lib/module/types/native.js.map +1 -1
- package/lib/module/utils/CloudStorageError.js +0 -2
- package/lib/module/utils/CloudStorageError.js.map +1 -1
- package/lib/module/utils/helpers.js +13 -8
- package/lib/module/utils/helpers.js.map +1 -1
- package/lib/typescript/RNCloudStorage.d.ts +39 -159
- package/lib/typescript/RNCloudStorage.d.ts.map +1 -1
- package/lib/typescript/createRNCloudStorage.d.ts +3 -0
- package/lib/typescript/createRNCloudStorage.d.ts.map +1 -0
- 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 +18 -6
- package/lib/typescript/google-drive/index.d.ts.map +1 -1
- package/lib/typescript/hooks/useCloudFile.d.ts +7 -4
- package/lib/typescript/hooks/useCloudFile.d.ts.map +1 -1
- package/lib/typescript/hooks/useIsCloudAvailable.d.ts +2 -3
- package/lib/typescript/hooks/useIsCloudAvailable.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +4 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/types/main.d.ts +0 -33
- package/lib/typescript/types/main.d.ts.map +1 -1
- package/lib/typescript/types/native.d.ts +1 -2
- package/lib/typescript/types/native.d.ts.map +1 -1
- package/lib/typescript/utils/helpers.d.ts +9 -2
- package/lib/typescript/utils/helpers.d.ts.map +1 -1
- package/package.json +11 -9
- package/src/RNCloudStorage.ts +68 -387
- package/src/createRNCloudStorage.ts +53 -0
- package/src/google-drive/client.ts +7 -8
- package/src/google-drive/index.ts +63 -38
- package/src/hooks/useCloudFile.ts +16 -13
- package/src/hooks/useIsCloudAvailable.ts +25 -12
- package/src/index.ts +5 -0
- package/src/types/main.ts +0 -38
- package/src/types/native.ts +1 -2
- package/src/utils/helpers.ts +15 -8
- package/ios/Utils/CloudKitUtils.swift +0 -112
- package/ios/Utils/CloudStorageError.swift +0 -78
- package/ios/Utils/FileUtils.swift +0 -132
- package/ios/Utils/Promise.swift +0 -58
- package/ios/Utils/Types.swift +0 -36
- package/lib/commonjs/package.json +0 -1
- package/lib/module/package.json +0 -1
|
@@ -4,287 +4,129 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _main = require("./types/main");
|
|
8
|
-
var _helpers = require("./utils/helpers");
|
|
9
7
|
var _reactNative = require("react-native");
|
|
10
|
-
var
|
|
11
|
-
var _native = require("./types/native");
|
|
8
|
+
var _createRNCloudStorage = _interopRequireDefault(require("./createRNCloudStorage"));
|
|
12
9
|
var _googleDrive = _interopRequireDefault(require("./google-drive"));
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
class RNCloudStorage {
|
|
52
|
-
cloudAvailabilityListeners = [];
|
|
53
|
-
|
|
54
|
-
//#region Constructor and configuration
|
|
55
|
-
/**
|
|
56
|
-
* Creates a new RNCloudStorage instance for the given provider.
|
|
57
|
-
* @param provider The provider to create the instance for. Defaults to the default provider for the current platform.
|
|
58
|
-
*/
|
|
59
|
-
constructor(provider, options) {
|
|
60
|
-
if (provider && !(0, _helpers.isProviderSupported)(provider)) {
|
|
61
|
-
throw new Error(`Provider ${provider} is not supported on the current platform.`);
|
|
62
|
-
}
|
|
63
|
-
this.provider = {
|
|
64
|
-
provider: provider ?? RNCloudStorage.getDefaultProvider(),
|
|
65
|
-
options: defaultProviderOptions[provider ?? RNCloudStorage.getDefaultProvider()]
|
|
66
|
-
};
|
|
67
|
-
this.setProvider(provider ?? RNCloudStorage.getDefaultProvider());
|
|
68
|
-
if (options) {
|
|
69
|
-
this.setProviderOptions(options);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
get nativeInstance() {
|
|
73
|
-
switch (this.provider.provider) {
|
|
74
|
-
case _main.CloudStorageProvider.ICloud:
|
|
75
|
-
return nativeIosInstance ?? new Proxy({}, {
|
|
76
|
-
get() {
|
|
77
|
-
throw new Error(LINKING_ERROR);
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
default:
|
|
81
|
-
return new _googleDrive.default(this.provider.options);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Gets the default CloudStorageProvider for the current platform.
|
|
87
|
-
* @returns The default CloudStorageProvider.
|
|
88
|
-
*/
|
|
89
|
-
static getDefaultProvider() {
|
|
90
|
-
switch (_reactNative.Platform.OS) {
|
|
91
|
-
case 'ios':
|
|
92
|
-
return _main.CloudStorageProvider.ICloud;
|
|
93
|
-
default:
|
|
94
|
-
return _main.CloudStorageProvider.GoogleDrive;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Gets the list of supported CloudStorageProviders on the current platform.
|
|
100
|
-
* @returns An array of supported CloudStorageProviders.
|
|
101
|
-
*/
|
|
102
|
-
static getSupportedProviders() {
|
|
103
|
-
return Object.values(_main.CloudStorageProvider).filter(_helpers.isProviderSupported);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Gets the current CloudStorageProvider.
|
|
108
|
-
* @returns The current CloudStorageProvider.
|
|
109
|
-
*/
|
|
110
|
-
getProvider() {
|
|
111
|
-
return this.provider.provider;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Sets the current CloudStorageProvider.
|
|
116
|
-
* @param provider The provider to set.
|
|
117
|
-
*/
|
|
118
|
-
setProvider(provider) {
|
|
119
|
-
if (!(0, _helpers.isProviderSupported)(provider)) {
|
|
120
|
-
throw new Error(`Provider ${provider} is not supported on the current platform.`);
|
|
121
|
-
}
|
|
122
|
-
this.provider = {
|
|
123
|
-
provider,
|
|
124
|
-
options: defaultProviderOptions[provider]
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
// Emit an event to notify useIsCloudAvailable() hook consumers of the new cloud availability status
|
|
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
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Gets the current options for the current provider.
|
|
146
|
-
* @returns The current options for the current provider.
|
|
147
|
-
*/
|
|
148
|
-
getProviderOptions() {
|
|
149
|
-
return this.provider.options;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Sets the options for the current provider.
|
|
154
|
-
* @param options The options to set for the provider.
|
|
155
|
-
*/
|
|
156
|
-
setProviderOptions(options) {
|
|
157
|
-
const newOptions = Object.fromEntries(Object.entries(options).filter(([_, v]) => v !== undefined));
|
|
158
|
-
this.provider.options = {
|
|
159
|
-
...this.provider.options,
|
|
160
|
-
...newOptions
|
|
161
|
-
};
|
|
162
|
-
if (this.provider.provider === _main.CloudStorageProvider.GoogleDrive && 'accessToken' in newOptions) {
|
|
163
|
-
// Emit an event to notify useIsCloudAvailable() hook consumers of the new cloud availability status
|
|
164
|
-
this.cloudAvailabilityListeners.forEach(listener => {
|
|
165
|
-
listener(!!newOptions.accessToken?.length);
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
subscribeToCloudAvailability(listener) {
|
|
170
|
-
this.cloudAvailabilityListeners.push(listener);
|
|
171
|
-
}
|
|
172
|
-
unsubscribeFromCloudAvailability(listener) {
|
|
173
|
-
this.cloudAvailabilityListeners = this.cloudAvailabilityListeners.filter(l => l !== listener);
|
|
174
|
-
}
|
|
175
|
-
//#endregion
|
|
10
|
+
var _main = require("./types/main");
|
|
11
|
+
var _helpers = require("./utils/helpers");
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
const nativeInstance = (0, _createRNCloudStorage.default)();
|
|
14
|
+
let defaultScope = _main.CloudStorageScope.AppData;
|
|
15
|
+
const RNCloudStorage = {
|
|
16
|
+
getDefaultScope: () => defaultScope,
|
|
17
|
+
setDefaultScope: scope => defaultScope = scope,
|
|
18
|
+
getGoogleDriveAccessToken: () => _googleDrive.default.accessToken,
|
|
19
|
+
setGoogleDriveAccessToken: accessToken => _googleDrive.default.accessToken = accessToken,
|
|
20
|
+
setThrowOnFilesWithSameName: enable => _googleDrive.default.throwOnFilesWithSameName = enable,
|
|
21
|
+
setTimeout: timeout => _googleDrive.default.timeout = timeout,
|
|
22
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
23
|
+
subscribeToFilesWithSameName: _reactNative.Platform.OS === 'ios' ?
|
|
24
|
+
// @ts-expect-error - subscriber is undefined; just a mock
|
|
25
|
+
subscriber => ({
|
|
26
|
+
remove: () => {}
|
|
27
|
+
}) : nativeInstance.subscribeToFilesWithSameName.bind(nativeInstance),
|
|
28
|
+
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
176
29
|
|
|
177
|
-
//#region File system operations
|
|
178
30
|
/**
|
|
179
31
|
* Tests whether or not the cloud storage is available. Always returns true for Google Drive. iCloud may be
|
|
180
32
|
* unavailable right after app launch or if the user is not logged in.
|
|
181
33
|
* @returns A promise that resolves to true if the cloud storage is available, false otherwise.
|
|
182
34
|
*/
|
|
183
|
-
isCloudAvailable() {
|
|
184
|
-
return
|
|
185
|
-
}
|
|
186
|
-
|
|
35
|
+
isCloudAvailable: async () => {
|
|
36
|
+
return nativeInstance.isCloudAvailable();
|
|
37
|
+
},
|
|
187
38
|
/**
|
|
188
39
|
* Appends the data to the file at the given path, creating the file if it doesn't exist.
|
|
189
40
|
* @param path The file to append to.
|
|
190
41
|
* @param data The data to append.
|
|
191
|
-
* @param scope The directory scope the path is in. Defaults to the default scope
|
|
42
|
+
* @param scope The directory scope the path is in. Defaults to the set default scope.
|
|
192
43
|
* @returns A promise that resolves when the data has been appended.
|
|
193
44
|
*/
|
|
194
|
-
appendFile(path, data, scope) {
|
|
195
|
-
return
|
|
196
|
-
}
|
|
197
|
-
|
|
45
|
+
appendFile: (path, data, scope) => {
|
|
46
|
+
return nativeInstance.appendToFile((0, _helpers.verifyLeadingSlash)(path), data, scope ?? defaultScope);
|
|
47
|
+
},
|
|
198
48
|
/**
|
|
199
49
|
* Tests whether or not the file at the given path exists.
|
|
200
50
|
* @param path The path to test.
|
|
201
|
-
* @param scope The directory scope the path is in. Defaults to set default scope
|
|
51
|
+
* @param scope The directory scope the path is in. Defaults to the set default scope.
|
|
202
52
|
* @returns A promise that resolves to true if the path exists, false otherwise.
|
|
203
53
|
*/
|
|
204
|
-
exists(path, scope) {
|
|
205
|
-
return
|
|
206
|
-
}
|
|
207
|
-
|
|
54
|
+
exists: (path, scope) => {
|
|
55
|
+
return nativeInstance.fileExists((0, _helpers.verifyLeadingSlash)(path), scope ?? defaultScope);
|
|
56
|
+
},
|
|
208
57
|
/**
|
|
209
58
|
* Writes to the file at the given path, creating it if it doesn't exist or overwriting it if it does.
|
|
210
59
|
* @param path The file to write to.
|
|
211
60
|
* @param data The data to write.
|
|
212
|
-
* @param scope The directory scope the path is in. Defaults to set default scope
|
|
61
|
+
* @param scope The directory scope the path is in. Defaults to the set default scope.
|
|
213
62
|
* @returns A promise that resolves when the file has been written.
|
|
214
63
|
*/
|
|
215
|
-
writeFile(path, data, scope) {
|
|
216
|
-
return
|
|
217
|
-
}
|
|
218
|
-
|
|
64
|
+
writeFile: (path, data, scope) => {
|
|
65
|
+
return nativeInstance.createFile((0, _helpers.verifyLeadingSlash)(path), data, scope ?? defaultScope, true);
|
|
66
|
+
},
|
|
219
67
|
/**
|
|
220
68
|
* Creates a new directory at the given path.
|
|
221
69
|
* @param path The directory to create.
|
|
222
|
-
* @param scope The directory scope the path is in. Defaults to set default scope
|
|
70
|
+
* @param scope The directory scope the path is in. Defaults to the set default scope.
|
|
223
71
|
* @returns A promise that resolves when the directory has been created.
|
|
224
72
|
*/
|
|
225
|
-
mkdir(path, scope) {
|
|
226
|
-
return
|
|
227
|
-
}
|
|
228
|
-
|
|
73
|
+
mkdir: (path, scope) => {
|
|
74
|
+
return nativeInstance.createDirectory((0, _helpers.verifyLeadingSlash)(path), scope ?? defaultScope);
|
|
75
|
+
},
|
|
229
76
|
/**
|
|
230
77
|
* Lists the contents of the directory at the given path.
|
|
231
78
|
* @param path The directory to list.
|
|
232
|
-
* @param scope The directory scope the path is in. Defaults to set default scope
|
|
79
|
+
* @param scope The directory scope the path is in. Defaults to the set default scope.
|
|
233
80
|
* @returns A promise that resolves to an array of file names, excluding '.' and '..'.
|
|
234
81
|
*/
|
|
235
|
-
readdir(path, scope) {
|
|
236
|
-
return
|
|
237
|
-
}
|
|
238
|
-
|
|
82
|
+
readdir: (path, scope) => {
|
|
83
|
+
return nativeInstance.listFiles((0, _helpers.verifyLeadingSlash)(path), scope ?? defaultScope);
|
|
84
|
+
},
|
|
239
85
|
/**
|
|
240
86
|
* Reads the contents of the file at the given path.
|
|
241
87
|
* @param path The file to read.
|
|
242
|
-
* @param scope The directory scope the path is in. Defaults to set default scope
|
|
88
|
+
* @param scope The directory scope the path is in. Defaults to the set default scope.
|
|
243
89
|
* @returns A promise that resolves to the contents of the file.
|
|
244
90
|
*/
|
|
245
|
-
readFile(path, scope) {
|
|
246
|
-
return
|
|
247
|
-
}
|
|
248
|
-
|
|
91
|
+
readFile: (path, scope) => {
|
|
92
|
+
return nativeInstance.readFile((0, _helpers.verifyLeadingSlash)(path), scope ?? defaultScope);
|
|
93
|
+
},
|
|
249
94
|
/**
|
|
250
|
-
* Downloads the file at the given path. Does not have any effect on Google Drive.
|
|
95
|
+
* Downloads the file at the given path from iCloud. Does not have any effect on Google Drive.
|
|
251
96
|
* @param path The file to trigger the download for.
|
|
252
|
-
* @param scope The directory scope the path is in. Defaults to set default scope
|
|
97
|
+
* @param scope The directory scope the path is in. Defaults to the set default scope.
|
|
253
98
|
* @returns A promise that resolves once the download has been triggered.
|
|
254
99
|
*/
|
|
255
|
-
downloadFile(path, scope) {
|
|
256
|
-
return
|
|
257
|
-
}
|
|
258
|
-
|
|
100
|
+
downloadFile: (path, scope) => {
|
|
101
|
+
return nativeInstance.downloadFile((0, _helpers.verifyLeadingSlash)(path), scope ?? defaultScope);
|
|
102
|
+
},
|
|
259
103
|
/**
|
|
260
104
|
* Deletes the file at the given path.
|
|
261
105
|
* @param path The file to delete.
|
|
262
|
-
* @param scope The directory scope the path is in. Defaults to set default scope
|
|
106
|
+
* @param scope The directory scope the path is in. Defaults to the set default scope.
|
|
263
107
|
* @returns A promise that resolves when the file has been deleted.
|
|
264
108
|
*/
|
|
265
|
-
unlink(path, scope) {
|
|
266
|
-
return
|
|
267
|
-
}
|
|
268
|
-
|
|
109
|
+
unlink: (path, scope) => {
|
|
110
|
+
return nativeInstance.deleteFile((0, _helpers.verifyLeadingSlash)(path), scope ?? defaultScope);
|
|
111
|
+
},
|
|
269
112
|
/**
|
|
270
113
|
* Deletes the directory at the given path.
|
|
271
114
|
* @param path The directory to delete.
|
|
272
115
|
* @param options Options for the delete operation. Defaults to { recursive: false }.
|
|
273
|
-
* @param scope The directory scope the path is in. Defaults to set default scope
|
|
116
|
+
* @param scope The directory scope the path is in. Defaults to the set default scope.
|
|
274
117
|
* @returns A promise that resolves when the directory has been deleted.
|
|
275
118
|
*/
|
|
276
|
-
rmdir(path, options, scope) {
|
|
277
|
-
return
|
|
278
|
-
}
|
|
279
|
-
|
|
119
|
+
rmdir: (path, options, scope) => {
|
|
120
|
+
return nativeInstance.deleteDirectory((0, _helpers.verifyLeadingSlash)(path), (options === null || options === void 0 ? void 0 : options.recursive) ?? false, scope ?? defaultScope);
|
|
121
|
+
},
|
|
280
122
|
/**
|
|
281
123
|
* Gets the size, creation time, and modification time of the file at the given path.
|
|
282
124
|
* @param path The file to stat.
|
|
283
|
-
* @param scope The directory scope the path is in. Defaults to set default scope
|
|
125
|
+
* @param scope The directory scope the path is in. Defaults to the set default scope.
|
|
284
126
|
* @returns A promise that resolves to the CloudStorageFileStat object.
|
|
285
127
|
*/
|
|
286
|
-
async
|
|
287
|
-
const native = await
|
|
128
|
+
stat: async (path, scope) => {
|
|
129
|
+
const native = await nativeInstance.statFile((0, _helpers.verifyLeadingSlash)(path), scope ?? defaultScope);
|
|
288
130
|
return {
|
|
289
131
|
...native,
|
|
290
132
|
birthtime: new Date(native.birthtimeMs),
|
|
@@ -293,144 +135,7 @@ class RNCloudStorage {
|
|
|
293
135
|
isFile: () => native.isFile
|
|
294
136
|
};
|
|
295
137
|
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
static getDefaultInstance() {
|
|
300
|
-
if (!RNCloudStorage.defaultInstance) {
|
|
301
|
-
RNCloudStorage.defaultInstance = new RNCloudStorage();
|
|
302
|
-
}
|
|
303
|
-
return RNCloudStorage.defaultInstance;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
/**
|
|
307
|
-
* Gets the current options for the provider of the default static instance.
|
|
308
|
-
* @returns The current options for the provider of the default static instance.
|
|
309
|
-
*/
|
|
310
|
-
static getProviderOptions() {
|
|
311
|
-
return RNCloudStorage.getDefaultInstance().getProviderOptions();
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
/**
|
|
315
|
-
* Sets the options for the provider of the default static instance.
|
|
316
|
-
* @param options The options to set for the provider of the default static instance.
|
|
317
|
-
*/
|
|
318
|
-
static setProviderOptions(options) {
|
|
319
|
-
RNCloudStorage.getDefaultInstance().setProviderOptions(options);
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
/**
|
|
323
|
-
* Tests whether or not the file at the given path exists in the provider of the default static instance.
|
|
324
|
-
* @param path The path to test.
|
|
325
|
-
* @param scope The directory scope the path is in. Defaults to set default scope set for the current provider.
|
|
326
|
-
* @returns A promise that resolves to true if the path exists, false otherwise.
|
|
327
|
-
*/
|
|
328
|
-
static exists(path, scope) {
|
|
329
|
-
return RNCloudStorage.getDefaultInstance().exists(path, scope);
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
/**
|
|
333
|
-
* 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
|
|
334
|
-
* unavailable right after app launch or if the user is not logged in.
|
|
335
|
-
* @returns A promise that resolves to true if the cloud storage is available, false otherwise.
|
|
336
|
-
*/
|
|
337
|
-
static isCloudAvailable() {
|
|
338
|
-
return RNCloudStorage.getDefaultInstance().isCloudAvailable();
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
/**
|
|
342
|
-
* 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.
|
|
343
|
-
* @param path The file to append to.
|
|
344
|
-
* @param data The data to append.
|
|
345
|
-
* @param scope The directory scope the path is in. Defaults to the default scope set for the default static instance.
|
|
346
|
-
* @returns A promise that resolves when the data has been appended.
|
|
347
|
-
*/
|
|
348
|
-
static appendFile(path, data, scope) {
|
|
349
|
-
return RNCloudStorage.getDefaultInstance().appendFile(path, data, scope);
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
/**
|
|
353
|
-
* 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.
|
|
354
|
-
* @param path The file to write to.
|
|
355
|
-
* @param data The data to write.
|
|
356
|
-
* @param scope The directory scope the path is in. Defaults to the default scope set for the default static instance.
|
|
357
|
-
* @returns A promise that resolves when the file has been written.
|
|
358
|
-
*/
|
|
359
|
-
static writeFile(path, data, scope) {
|
|
360
|
-
return RNCloudStorage.getDefaultInstance().writeFile(path, data, scope);
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
/**
|
|
364
|
-
* Creates a new directory at the given path in the provider of the default static instance.
|
|
365
|
-
* @param path The directory to create.
|
|
366
|
-
* @param scope The directory scope the path is in. Defaults to the default scope set for the default static instance.
|
|
367
|
-
* @returns A promise that resolves when the directory has been created.
|
|
368
|
-
*/
|
|
369
|
-
static mkdir(path, scope) {
|
|
370
|
-
return RNCloudStorage.getDefaultInstance().mkdir(path, scope);
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
/**
|
|
374
|
-
* Lists the contents of the directory at the given path in the provider of the default static instance.
|
|
375
|
-
* @param path The directory to list.
|
|
376
|
-
* @param scope The directory scope the path is in. Defaults to the default scope set for the default static instance.
|
|
377
|
-
* @returns A promise that resolves to an array of file names, excluding '.' and '..'.
|
|
378
|
-
*/
|
|
379
|
-
static readdir(path, scope) {
|
|
380
|
-
return RNCloudStorage.getDefaultInstance().readdir(path, scope);
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
/**
|
|
384
|
-
* Reads the contents of the file at the given path in the provider of the default static instance.
|
|
385
|
-
* @param path The file to read.
|
|
386
|
-
* @param scope The directory scope the path is in. Defaults to the default scope set for the default static instance.
|
|
387
|
-
* @returns A promise that resolves to the contents of the file.
|
|
388
|
-
*/
|
|
389
|
-
static readFile(path, scope) {
|
|
390
|
-
return RNCloudStorage.getDefaultInstance().readFile(path, scope);
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
/**
|
|
394
|
-
* Downloads the file at the given path in the provider of the default static instance. Does not have any effect on Google Drive.
|
|
395
|
-
* @param path The file to trigger the download for.
|
|
396
|
-
* @param scope The directory scope the path is in. Defaults to the default scope set for the default static instance.
|
|
397
|
-
* @returns A promise that resolves once the download has been triggered.
|
|
398
|
-
*/
|
|
399
|
-
static downloadFile(path, scope) {
|
|
400
|
-
return RNCloudStorage.getDefaultInstance().downloadFile(path, scope);
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
/**
|
|
404
|
-
* Deletes the file at the given path in the provider of the default static instance.
|
|
405
|
-
* @param path The file to delete.
|
|
406
|
-
* @param scope The directory scope the path is in. Defaults to the default scope set for the default static instance.
|
|
407
|
-
* @returns A promise that resolves when the file has been deleted.
|
|
408
|
-
*/
|
|
409
|
-
static unlink(path, scope) {
|
|
410
|
-
return RNCloudStorage.getDefaultInstance().unlink(path, scope);
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
/**
|
|
414
|
-
* Deletes the directory at the given path in the provider of the default static instance.
|
|
415
|
-
* @param path The directory to delete.
|
|
416
|
-
* @param options Options for the delete operation. Defaults to { recursive: false }.
|
|
417
|
-
* @param scope The directory scope the path is in. Defaults to the default scope set for the default static instance.
|
|
418
|
-
* @returns A promise that resolves when the directory has been deleted.
|
|
419
|
-
*/
|
|
420
|
-
static rmdir(path, options, scope) {
|
|
421
|
-
return RNCloudStorage.getDefaultInstance().rmdir(path, options, scope);
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
/**
|
|
425
|
-
* Gets the size, creation time, and modification time of the file at the given path in the provider of the default static instance.
|
|
426
|
-
* @param path The file to stat.
|
|
427
|
-
* @param scope The directory scope the path is in. Defaults to the default scope set for the default static instance.
|
|
428
|
-
* @returns A promise that resolves to the CloudStorageFileStat object.
|
|
429
|
-
*/
|
|
430
|
-
static stat(path, scope) {
|
|
431
|
-
return RNCloudStorage.getDefaultInstance().stat(path, scope);
|
|
432
|
-
}
|
|
433
|
-
//#endregion
|
|
434
|
-
}
|
|
435
|
-
exports.default = RNCloudStorage;
|
|
138
|
+
};
|
|
139
|
+
var _default = RNCloudStorage;
|
|
140
|
+
exports.default = _default;
|
|
436
141
|
//# sourceMappingURL=RNCloudStorage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_main","require","_helpers","_reactNative","_CloudStorageError","_interopRequireDefault","_native","_googleDrive","e","__esModule","default","LINKING_ERROR","Platform","select","ios","nativeIosInstance","NativeModules","CloudStorage","Proxy","get","target","prop","originalFunction","args","error","code","Object","values","CloudStorageErrorCode","includes","CloudStorageError","message","UNKNOWN","defaultProviderOptions","CloudStorageProvider","ICloud","scope","CloudStorageScope","AppData","GoogleDrive","accessToken","strictFilenames","timeout","RNCloudStorage","cloudAvailabilityListeners","constructor","provider","options","isProviderSupported","Error","getDefaultProvider","setProvider","setProviderOptions","nativeInstance","OS","getSupportedProviders","filter","getProvider","isCloudAvailable","then","available","forEach","listener","eventEmitter","NativeEventEmitter","CloudStorageEventEmitter","addListener","event","getProviderOptions","newOptions","fromEntries","entries","_","v","undefined","length","subscribeToCloudAvailability","push","unsubscribeFromCloudAvailability","l","appendFile","path","data","appendToFile","exists","fileExists","writeFile","createFile","mkdir","createDirectory","readdir","listFiles","readFile","downloadFile","unlink","deleteFile","rmdir","deleteDirectory","recursive","stat","native","statFile","birthtime","Date","birthtimeMs","mtime","mtimeMs","isDirectory","isFile","getDefaultInstance","defaultInstance","exports"],"sourceRoot":"../../src","sources":["RNCloudStorage.ts"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAQA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,kBAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GA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iC;IAClF,OAAOO,cAAc,CAACkE,kBAAkB,CAAC,CAAC,CAACV,IAAI,CAAClB,IAAI,EAAE7C,KAAK,CAAC;EAC9D;EACA;AACF;AAAC2E,OAAA,CAAArG,OAAA,GAAAiC,cAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_createRNCloudStorage","_interopRequireDefault","_googleDrive","_main","_helpers","obj","__esModule","default","nativeInstance","createRNCloudStorage","defaultScope","CloudStorageScope","AppData","RNCloudStorage","getDefaultScope","setDefaultScope","scope","getGoogleDriveAccessToken","GoogleDrive","accessToken","setGoogleDriveAccessToken","setThrowOnFilesWithSameName","enable","throwOnFilesWithSameName","setTimeout","timeout","subscribeToFilesWithSameName","Platform","OS","subscriber","remove","bind","isCloudAvailable","appendFile","path","data","appendToFile","verifyLeadingSlash","exists","fileExists","writeFile","createFile","mkdir","createDirectory","readdir","listFiles","readFile","downloadFile","unlink","deleteFile","rmdir","options","deleteDirectory","recursive","stat","native","statFile","birthtime","Date","birthtimeMs","mtime","mtimeMs","isDirectory","isFile","_default","exports"],"sourceRoot":"../../src","sources":["RNCloudStorage.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,YAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AAAqD,SAAAE,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAErD,MAAMG,cAAc,GAAG,IAAAC,6BAAoB,GAAE;AAC7C,IAAIC,YAAY,GAAGC,uBAAiB,CAACC,OAAO;AAE5C,MAAMC,cAAc,GAAG;EACrBC,eAAe,EAAEA,CAAA,KAAMJ,YAAY;EACnCK,eAAe,EAAGC,KAAwB,IAAMN,YAAY,GAAGM,KAAM;E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AAC,EAAE,CAAAiB,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEE,SAAS,KAAI,KAAK,EAAErC,KAAK,IAAIN,YAAY,CAAC;EACrH,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;EACE4C,IAAI,EAAE,MAAAA,CAAOpB,IAAY,EAAElB,KAAyB,KAAoC;IACtF,MAAMuC,MAAM,GAAG,MAAM/C,cAAc,CAACgD,QAAQ,CAAC,IAAAnB,2BAAkB,EAACH,IAAI,CAAC,EAAElB,KAAK,IAAIN,YAAY,CAAC;IAE7F,OAAO;MACL,GAAG6C,MAAM;MACTE,SAAS,EAAE,IAAIC,IAAI,CAACH,MAAM,CAACI,WAAW,CAAC;MACvCC,KAAK,EAAE,IAAIF,IAAI,CAACH,MAAM,CAACM,OAAO,CAAC;MAC/BC,WAAW,EAAEA,CAAA,KAAMP,MAAM,CAACO,WAAW;MACrCC,MAAM,EAAEA,CAAA,KAAMR,MAAM,CAACQ;IACvB,CAAC;EACH;AACF,CAAC;AAAC,IAAAC,QAAA,GAEanD,cAAc;AAAAoD,OAAA,CAAA1D,OAAA,GAAAyD,QAAA"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = createRNCloudStorage;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
8
|
+
var _googleDrive = _interopRequireDefault(require("./google-drive"));
|
|
9
|
+
var _native = require("./types/native");
|
|
10
|
+
var _CloudStorageError = _interopRequireDefault(require("./utils/CloudStorageError"));
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
const LINKING_ERROR = `The package 'react-native-cloud-storage' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
|
|
13
|
+
ios: "- You have run 'pod install'\n",
|
|
14
|
+
default: ''
|
|
15
|
+
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
|
|
16
|
+
|
|
17
|
+
// proxy NativeModules.CloudStorage to catch any errors thrown by the native module and wrap them in a CloudStorageError
|
|
18
|
+
const nativeIosInstance = _reactNative.NativeModules.CloudStorage ? new Proxy(_reactNative.NativeModules.CloudStorage, {
|
|
19
|
+
get(target, prop) {
|
|
20
|
+
const originalFunction = target[prop];
|
|
21
|
+
if (typeof originalFunction === 'function') {
|
|
22
|
+
return async function () {
|
|
23
|
+
try {
|
|
24
|
+
// @ts-expect-error - we can't know the types of the functions and their arguments
|
|
25
|
+
return await originalFunction(...arguments);
|
|
26
|
+
} catch (error) {
|
|
27
|
+
if (error !== null && error !== void 0 && error.code && Object.values(_native.CloudStorageErrorCode).includes(error.code)) {
|
|
28
|
+
throw new _CloudStorageError.default((error === null || error === void 0 ? void 0 : error.message) || '', error.code);
|
|
29
|
+
} else {
|
|
30
|
+
throw new _CloudStorageError.default('Unknown error', _native.CloudStorageErrorCode.UNKNOWN, error);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return originalFunction;
|
|
36
|
+
}
|
|
37
|
+
}) : null;
|
|
38
|
+
function createRNCloudStorage() {
|
|
39
|
+
if (_reactNative.Platform.OS === 'ios') {
|
|
40
|
+
return nativeIosInstance ?? new Proxy({}, {
|
|
41
|
+
get() {
|
|
42
|
+
throw new Error(LINKING_ERROR);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
return new _googleDrive.default();
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=createRNCloudStorage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_googleDrive","_interopRequireDefault","_native","_CloudStorageError","obj","__esModule","default","LINKING_ERROR","Platform","select","ios","nativeIosInstance","NativeModules","CloudStorage","Proxy","get","target","prop","originalFunction","arguments","error","code","Object","values","CloudStorageErrorCode","includes","CloudStorageError","message","UNKNOWN","createRNCloudStorage","OS","Error","GoogleDrive"],"sourceRoot":"../../src","sources":["createRNCloudStorage.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,kBAAA,GAAAF,sBAAA,CAAAF,OAAA;AAA0D,SAAAE,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAE1D,MAAMG,aAAa,GAChB,qFAAoF,GACrFC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEJ,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;;AAEjC;AACA,MAAMK,iBAAiB,GAAGC,0BAAa,CAACC,YAAY,GAChD,IAAIC,KAAK,CAACF,0BAAa,CAACC,YAAY,EAAE;EACpCE,GAAGA,CAACC,MAA4B,EAAEC,IAAgC,EAAE;IAClE,MAAMC,gBAAgB,GAAGF,MAAM,CAACC,IAAI,CAAC;IACrC,IAAI,OAAOC,gBAAgB,KAAK,UAAU,EAAE;MAC1C,OAAO,kBAA0B;QAC/B,IAAI;UACF;UACA,OAAO,MAAMA,gBAAgB,CAAC,GAAAC,SAAO,CAAC;QACxC,CAAC,CAAC,OAAOC,KAAU,EAAE;UACnB,IAAIA,KAAK,aAALA,KAAK,eAALA,KAAK,CAAEC,IAAI,IAAIC,MAAM,CAACC,MAAM,CAACC,6BAAqB,CAAC,CAACC,QAAQ,CAACL,KAAK,CAACC,IAAI,CAAC,EAAE;YAC5E,MAAM,IAAIK,0BAAiB,CAAC,CAAAN,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEO,OAAO,KAAI,EAAE,EAAEP,KAAK,CAACC,IAAI,CAA0B;UACxF,CAAC,MAAM;YACL,MAAM,IAAIK,0BAAiB,CAAC,eAAe,EAAEF,6BAAqB,CAACI,OAAO,EAAER,KAAK,CAAC;UACpF;QACF;MACF,CAAC;IACH;IACA,OAAOF,gBAAgB;EACzB;AACF,CAAC,CAAC,GACF,IAAI;AAEO,SAASW,oBAAoBA,CAAA,EAAyB;EACnE,IAAIrB,qBAAQ,CAACsB,EAAE,KAAK,KAAK,EAAE;IACzB,OACEnB,iBAAiB,IACjB,IAAIG,KAAK,CACP,CAAC,CAAC,EACF;MACEC,GAAGA,CAAA,EAAG;QACJ,MAAM,IAAIgB,KAAK,CAACxB,aAAa,CAAC;MAChC;IACF,CAAC,CACF;EAEL;EAEA,OAAO,IAAIyB,oBAAW,EAAE;AAC1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["expo-plugin/types/index.ts"],"mappings":""
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["expo-plugin/types/index.ts"],"mappings":""}
|
|
@@ -5,9 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _withRNCloudStorageIos = _interopRequireDefault(require("./withRNCloudStorageIos"));
|
|
8
|
-
function _interopRequireDefault(
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
9
|
// Android config plugin not needed as there's no native code to configure.
|
|
10
10
|
|
|
11
11
|
const withRNCloudStorage = (config, options) => (0, _withRNCloudStorageIos.default)(config, options);
|
|
12
|
-
var _default =
|
|
12
|
+
var _default = withRNCloudStorage;
|
|
13
|
+
exports.default = _default;
|
|
13
14
|
//# sourceMappingURL=withRNCloudStorage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_withRNCloudStorageIos","_interopRequireDefault","require","
|
|
1
|
+
{"version":3,"names":["_withRNCloudStorageIos","_interopRequireDefault","require","obj","__esModule","default","withRNCloudStorage","config","options","withRNCloudStorageIos","_default","exports"],"sourceRoot":"../../../src","sources":["expo-plugin/withRNCloudStorage.ts"],"mappings":";;;;;;AACA,IAAAA,sBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA4D,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAG5D;;AAEA,MAAMG,kBAAmE,GAAGA,CAACC,MAAM,EAAEC,OAAO,KAC1F,IAAAC,8BAAqB,EAACF,MAAM,EAAEC,OAAO,CAAC;AAAC,IAAAE,QAAA,GAE1BJ,kBAAkB;AAAAK,OAAA,CAAAN,OAAA,GAAAK,QAAA"}
|
|
@@ -6,7 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _configPlugins = require("@expo/config-plugins");
|
|
8
8
|
const withRNCloudStorageInfoPlist = config => (0, _configPlugins.withInfoPlist)(config, async newConfig => {
|
|
9
|
-
|
|
9
|
+
var _config$ios;
|
|
10
|
+
if (!((_config$ios = config.ios) !== null && _config$ios !== void 0 && _config$ios.bundleIdentifier)) {
|
|
10
11
|
throw new Error('Missing iOS bundle identifier');
|
|
11
12
|
}
|
|
12
13
|
const infoPlist = newConfig.modResults;
|
|
@@ -20,17 +21,19 @@ const withRNCloudStorageInfoPlist = config => (0, _configPlugins.withInfoPlist)(
|
|
|
20
21
|
return newConfig;
|
|
21
22
|
});
|
|
22
23
|
const withRNCloudStorageEntitlementsPlist = (config, options) => (0, _configPlugins.withEntitlementsPlist)(config, async newConfig => {
|
|
23
|
-
|
|
24
|
+
var _config$ios2;
|
|
25
|
+
if (!((_config$ios2 = config.ios) !== null && _config$ios2 !== void 0 && _config$ios2.bundleIdentifier)) {
|
|
24
26
|
throw new Error('Missing iOS bundle identifier');
|
|
25
27
|
}
|
|
26
28
|
const entitlementsPlist = newConfig.modResults;
|
|
27
29
|
entitlementsPlist['com.apple.developer.icloud-container-identifiers'] = [`iCloud.${config.ios.bundleIdentifier}`];
|
|
28
30
|
entitlementsPlist['com.apple.developer.icloud-services'] = ['CloudDocuments'];
|
|
29
|
-
entitlementsPlist['com.apple.developer.icloud-container-environment'] = options
|
|
31
|
+
entitlementsPlist['com.apple.developer.icloud-container-environment'] = (options === null || options === void 0 ? void 0 : options.iCloudContainerEnvironment) ?? 'Production';
|
|
30
32
|
entitlementsPlist['com.apple.developer.ubiquity-container-identifiers'] = [`iCloud.${config.ios.bundleIdentifier}`];
|
|
31
33
|
entitlementsPlist['com.apple.developer.ubiquity-kvstore-identifier'] = `$(TeamIdentifierPrefix)${config.ios.bundleIdentifier}`;
|
|
32
34
|
return newConfig;
|
|
33
35
|
});
|
|
34
36
|
const withRNCloudStorageIos = (config, options) => (0, _configPlugins.withPlugins)(config, [withRNCloudStorageInfoPlist, [withRNCloudStorageEntitlementsPlist, options]]);
|
|
35
|
-
var _default =
|
|
37
|
+
var _default = withRNCloudStorageIos;
|
|
38
|
+
exports.default = _default;
|
|
36
39
|
//# sourceMappingURL=withRNCloudStorageIos.js.map
|