@react-native-firebase/storage 25.0.1 → 26.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/CHANGELOG.md +25 -0
- package/RNFBStorage.podspec +17 -6
- package/android/build.gradle +23 -0
- package/android/src/main/java/io/invertase/firebase/storage/{ReactNativeFirebaseStorageModule.java → NativeRNFBTurboStorage.java} +72 -131
- package/android/src/main/java/io/invertase/firebase/storage/ReactNativeFirebaseStoragePackage.java +1 -1
- package/android/src/main/java/io/invertase/firebase/storage/generated/java/com/facebook/fbreact/specs/NativeRNFBTurboStorageSpec.java +125 -0
- package/android/src/main/java/io/invertase/firebase/storage/generated/jni/CMakeLists.txt +36 -0
- package/android/src/main/java/io/invertase/firebase/storage/generated/jni/RNFBStorageTurboModules-generated.cpp +116 -0
- package/android/src/main/java/io/invertase/firebase/storage/generated/jni/RNFBStorageTurboModules.h +31 -0
- package/android/src/main/java/io/invertase/firebase/storage/generated/jni/react/renderer/components/RNFBStorageTurboModules/RNFBStorageTurboModulesJSI-generated.cpp +153 -0
- package/android/src/main/java/io/invertase/firebase/storage/generated/jni/react/renderer/components/RNFBStorageTurboModules/RNFBStorageTurboModulesJSI.h +246 -0
- package/dist/module/StorageReference.js +4 -7
- package/dist/module/StorageReference.js.map +1 -1
- package/dist/module/StorageTask.js.map +1 -1
- package/dist/module/index.js +384 -6
- package/dist/module/index.js.map +1 -1
- package/dist/module/types/storage.js +6 -2
- package/dist/module/types/storage.js.map +1 -1
- package/dist/module/version.js +1 -1
- package/dist/module/web/RNFBStorageModule.js +9 -11
- package/dist/module/web/RNFBStorageModule.js.map +1 -1
- package/dist/typescript/lib/StorageReference.d.ts.map +1 -1
- package/dist/typescript/lib/StorageTask.d.ts +7 -8
- package/dist/typescript/lib/StorageTask.d.ts.map +1 -1
- package/dist/typescript/lib/index.d.ts +150 -4
- package/dist/typescript/lib/index.d.ts.map +1 -1
- package/dist/typescript/lib/types/internal.d.ts +5 -5
- package/dist/typescript/lib/types/internal.d.ts.map +1 -1
- package/dist/typescript/lib/types/storage.d.ts +15 -10
- package/dist/typescript/lib/types/storage.d.ts.map +1 -1
- package/dist/typescript/lib/version.d.ts +1 -1
- package/dist/typescript/lib/web/RNFBStorageModule.d.ts +3 -3
- package/dist/typescript/lib/web/RNFBStorageModule.d.ts.map +1 -1
- package/ios/RNFBStorage/RNFBStorageModule.h +2 -2
- package/ios/RNFBStorage/{RNFBStorageModule.m → RNFBStorageModule.mm} +193 -130
- package/ios/RNFBStorage.xcodeproj/project.pbxproj +8 -8
- package/ios/generated/RCTAppDependencyProvider.h +25 -0
- package/ios/generated/RCTAppDependencyProvider.mm +55 -0
- package/ios/generated/RCTModulesConformingToProtocolsProvider.h +18 -0
- package/ios/generated/RCTModulesConformingToProtocolsProvider.mm +33 -0
- package/ios/generated/RCTThirdPartyComponentsProvider.h +16 -0
- package/ios/generated/RCTThirdPartyComponentsProvider.mm +23 -0
- package/ios/generated/RNFBStorageTurboModules/RNFBStorageTurboModules-generated.mm +142 -0
- package/ios/generated/RNFBStorageTurboModules/RNFBStorageTurboModules.h +198 -0
- package/ios/generated/RNFBStorageTurboModulesJSI-generated.cpp +153 -0
- package/ios/generated/RNFBStorageTurboModulesJSI.h +246 -0
- package/ios/generated/ReactAppDependencyProvider.podspec +34 -0
- package/lib/StorageReference.ts +3 -8
- package/lib/StorageTask.ts +13 -15
- package/lib/index.ts +501 -7
- package/lib/types/internal.ts +5 -5
- package/lib/types/storage.ts +17 -10
- package/lib/version.ts +1 -1
- package/lib/web/RNFBStorageModule.ts +10 -12
- package/package.json +22 -4
- package/react-native.config.js +10 -0
- package/specs/NativeRNFBTurboStorage.ts +46 -0
- package/typedoc.json +2 -3
- package/dist/module/modular.js +0 -270
- package/dist/module/modular.js.map +0 -1
- package/dist/module/namespaced.js +0 -192
- package/dist/module/namespaced.js.map +0 -1
- package/dist/module/types/namespaced.js +0 -64
- package/dist/module/types/namespaced.js.map +0 -1
- package/dist/typescript/lib/modular.d.ts +0 -154
- package/dist/typescript/lib/modular.d.ts.map +0 -1
- package/dist/typescript/lib/namespaced.d.ts +0 -12
- package/dist/typescript/lib/namespaced.d.ts.map +0 -1
- package/dist/typescript/lib/types/namespaced.d.ts +0 -1122
- package/dist/typescript/lib/types/namespaced.d.ts.map +0 -1
- package/lib/modular.ts +0 -401
- package/lib/namespaced.ts +0 -264
- package/lib/types/namespaced.ts +0 -1248
|
@@ -247,7 +247,7 @@ export default {
|
|
|
247
247
|
* @param url - The path to the object.
|
|
248
248
|
* @return {Promise<void>}
|
|
249
249
|
*/
|
|
250
|
-
|
|
250
|
+
deleteObject(appName: string, url: string): Promise<void> {
|
|
251
251
|
return guard(async () => {
|
|
252
252
|
const ref = getReferenceFromUrl(appName, url);
|
|
253
253
|
await deleteObject(ref);
|
|
@@ -516,14 +516,10 @@ export default {
|
|
|
516
516
|
* @param appName - The app name.
|
|
517
517
|
* @param taskId - The task ID.
|
|
518
518
|
* @param status - The status.
|
|
519
|
-
* @return
|
|
519
|
+
* @return Whether the status was set.
|
|
520
520
|
*/
|
|
521
|
-
setTaskStatus(appName: string, taskId: string, status: number):
|
|
522
|
-
|
|
523
|
-
// be tested right now since we're unable
|
|
524
|
-
// to create a big enough upload to be able to
|
|
525
|
-
// pause/resume/cancel it in time.
|
|
526
|
-
return guard(async () => {
|
|
521
|
+
setTaskStatus(appName: string, taskId: string, status: number): boolean {
|
|
522
|
+
try {
|
|
527
523
|
const task = tasks[taskId];
|
|
528
524
|
|
|
529
525
|
// If the task doesn't exist, return false.
|
|
@@ -535,13 +531,13 @@ export default {
|
|
|
535
531
|
|
|
536
532
|
switch (status) {
|
|
537
533
|
case 0:
|
|
538
|
-
result =
|
|
534
|
+
result = task.pause();
|
|
539
535
|
break;
|
|
540
536
|
case 1:
|
|
541
|
-
result =
|
|
537
|
+
result = task.resume();
|
|
542
538
|
break;
|
|
543
539
|
case 2:
|
|
544
|
-
result =
|
|
540
|
+
result = task.cancel();
|
|
545
541
|
break;
|
|
546
542
|
}
|
|
547
543
|
|
|
@@ -552,6 +548,8 @@ export default {
|
|
|
552
548
|
});
|
|
553
549
|
|
|
554
550
|
return result;
|
|
555
|
-
})
|
|
551
|
+
} catch (e) {
|
|
552
|
+
throw getWebError(e as Error & { code?: string });
|
|
553
|
+
}
|
|
556
554
|
},
|
|
557
555
|
};
|
package/package.json
CHANGED
|
@@ -1,15 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-firebase/storage",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "26.0.0",
|
|
4
4
|
"author": "Invertase <oss@invertase.io> (http://invertase.io)",
|
|
5
5
|
"description": "React Native Firebase - React Native Firebase provides native integration with Cloud Storage, providing support to upload and download files directly from your device and from your Firebase Cloud Storage bucket.",
|
|
6
6
|
"main": "./dist/module/index.js",
|
|
7
7
|
"types": "./dist/typescript/lib/index.d.ts",
|
|
8
|
+
"codegenConfig": {
|
|
9
|
+
"name": "RNFBStorageTurboModules",
|
|
10
|
+
"type": "modules",
|
|
11
|
+
"jsSrcsDir": "specs",
|
|
12
|
+
"includesGeneratedCode": true,
|
|
13
|
+
"android": {
|
|
14
|
+
"javaPackageName": "io.invertase.firebase.storage"
|
|
15
|
+
},
|
|
16
|
+
"ios": {
|
|
17
|
+
"modulesProvider": {
|
|
18
|
+
"NativeRNFBTurboStorage": "RNFBStorageModule"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
},
|
|
8
22
|
"scripts": {
|
|
9
23
|
"build": "genversion --esm --semi lib/version.ts",
|
|
10
24
|
"build:clean": "rimraf android/build && rimraf ios/build",
|
|
11
25
|
"compile": "bob build",
|
|
12
|
-
"prepare": "yarn run build && yarn compile"
|
|
26
|
+
"prepare": "yarn run build && yarn compile",
|
|
27
|
+
"codegen": "yarn android:codegen && yarn ios:codegen",
|
|
28
|
+
"android:codegen": "npx @react-native-community/cli codegen --platform android --outputPath=./android/src/main/java/io/invertase/firebase/storage/generated",
|
|
29
|
+
"ios:codegen": "npx @react-native-community/cli codegen --platform ios --outputPath=./ios/generated"
|
|
13
30
|
},
|
|
14
31
|
"repository": {
|
|
15
32
|
"type": "git",
|
|
@@ -30,13 +47,14 @@
|
|
|
30
47
|
"download"
|
|
31
48
|
],
|
|
32
49
|
"peerDependencies": {
|
|
33
|
-
"@react-native-firebase/app": "
|
|
50
|
+
"@react-native-firebase/app": "26.0.0"
|
|
34
51
|
},
|
|
35
52
|
"publishConfig": {
|
|
36
53
|
"access": "public",
|
|
37
54
|
"provenance": true
|
|
38
55
|
},
|
|
39
56
|
"devDependencies": {
|
|
57
|
+
"@react-native-firebase/app": "26.0.0",
|
|
40
58
|
"react-native-builder-bob": "^0.41.0"
|
|
41
59
|
},
|
|
42
60
|
"exports": {
|
|
@@ -69,5 +87,5 @@
|
|
|
69
87
|
"node_modules/",
|
|
70
88
|
"dist/"
|
|
71
89
|
],
|
|
72
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "2a360acb2aebdd39dd40e31be386b30697270626"
|
|
73
91
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-wrapper-object-types */
|
|
2
|
+
import type { TurboModule } from 'react-native';
|
|
3
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
4
|
+
|
|
5
|
+
export interface StorageListOptions {
|
|
6
|
+
maxResults: number;
|
|
7
|
+
pageToken?: string | null;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface Spec extends TurboModule {
|
|
11
|
+
getConstants(): {
|
|
12
|
+
maxDownloadRetryTime: number;
|
|
13
|
+
maxOperationRetryTime: number;
|
|
14
|
+
maxUploadRetryTime: number;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
deleteObject(appName: string, url: string): Promise<void>;
|
|
18
|
+
getDownloadURL(appName: string, url: string): Promise<string>;
|
|
19
|
+
getMetadata(appName: string, url: string): Promise<Object>;
|
|
20
|
+
updateMetadata(appName: string, url: string, metadata: Object | null): Promise<Object>;
|
|
21
|
+
list(appName: string, url: string, listOptions: StorageListOptions): Promise<Object>;
|
|
22
|
+
listAll(appName: string, url: string): Promise<Object>;
|
|
23
|
+
setMaxDownloadRetryTime(appName: string, milliseconds: number): Promise<void>;
|
|
24
|
+
setMaxOperationRetryTime(appName: string, milliseconds: number): Promise<void>;
|
|
25
|
+
setMaxUploadRetryTime(appName: string, milliseconds: number): Promise<void>;
|
|
26
|
+
useEmulator(appName: string, host: string, port: number, bucketUrl: string): void;
|
|
27
|
+
writeToFile(appName: string, url: string, localFilePath: string, taskId: number): Promise<Object>;
|
|
28
|
+
putFile(
|
|
29
|
+
appName: string,
|
|
30
|
+
url: string,
|
|
31
|
+
localFilePath: string,
|
|
32
|
+
metadata: Object | null,
|
|
33
|
+
taskId: number,
|
|
34
|
+
): Promise<Object>;
|
|
35
|
+
putString(
|
|
36
|
+
appName: string,
|
|
37
|
+
url: string,
|
|
38
|
+
string: string,
|
|
39
|
+
format: string,
|
|
40
|
+
metadata: Object | null,
|
|
41
|
+
taskId: number,
|
|
42
|
+
): Promise<Object>;
|
|
43
|
+
setTaskStatus(appName: string, taskId: number, status: number): boolean;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('NativeRNFBTurboStorage');
|
package/typedoc.json
CHANGED
package/dist/module/modular.js
DELETED
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
5
|
-
*
|
|
6
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
-
* you may not use this library except in compliance with the License.
|
|
8
|
-
* You may obtain a copy of the License at
|
|
9
|
-
*
|
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
-
* See the License for the specific language governing permissions and
|
|
16
|
-
* limitations under the License.
|
|
17
|
-
*
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import { getApp } from '@react-native-firebase/app';
|
|
21
|
-
import { MODULAR_DEPRECATION_ARG } from '@react-native-firebase/app/dist/module/common';
|
|
22
|
-
function isUrl(path) {
|
|
23
|
-
if (typeof path !== 'string') {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
return /^[A-Za-z]+:\/\//.test(decodeURIComponent(path));
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Returns a Storage instance for the given app.
|
|
31
|
-
* @param app - FirebaseApp. Optional.
|
|
32
|
-
* @param bucketUrl - Storage bucket URL. Optional.
|
|
33
|
-
* @returns {Storage}
|
|
34
|
-
*/
|
|
35
|
-
export function getStorage(app, bucketUrl) {
|
|
36
|
-
if (app) {
|
|
37
|
-
if (bucketUrl != null) {
|
|
38
|
-
return getApp(app.name).storage(bucketUrl);
|
|
39
|
-
}
|
|
40
|
-
return getApp(app.name).storage();
|
|
41
|
-
}
|
|
42
|
-
if (bucketUrl != null) {
|
|
43
|
-
return getApp().storage(bucketUrl);
|
|
44
|
-
}
|
|
45
|
-
return getApp().storage();
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Modify this Storage instance to communicate with the Firebase Storage emulator.
|
|
50
|
-
* @param storage - Storage instance.
|
|
51
|
-
* @param host - emulator host (e.g. - 'localhost')
|
|
52
|
-
* @param port - emulator port (e.g. - 9199)
|
|
53
|
-
* @param options - `EmulatorMockTokenOptions` instance. Optional. Web only.
|
|
54
|
-
* @returns {void}
|
|
55
|
-
*/
|
|
56
|
-
export function connectStorageEmulator(storage, host, port, options) {
|
|
57
|
-
return storage.useEmulator.call(storage, host, port, options, MODULAR_DEPRECATION_ARG);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Returns a StorageReference for the given URL or path in the default bucket.
|
|
62
|
-
* @param storage - FirebaseStorage instance.
|
|
63
|
-
* @param url - Optional gs:// or https:// URL, or path. If empty, returns root reference.
|
|
64
|
-
* @returns {StorageReference}
|
|
65
|
-
*/
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Returns a StorageReference for the given path, or the same reference if path is omitted.
|
|
69
|
-
* @param storageRef - StorageReference instance.
|
|
70
|
-
* @param path - Optional child path. If omitted, returns the same reference.
|
|
71
|
-
* @returns {StorageReference}
|
|
72
|
-
*/
|
|
73
|
-
|
|
74
|
-
export function ref(storageOrRef, path) {
|
|
75
|
-
// ref(parentRef, path) → child reference; ref(parentRef) → same reference (firebase-js-sdk overload)
|
|
76
|
-
if (typeof storageOrRef.fullPath === 'string') {
|
|
77
|
-
if (path === undefined) {
|
|
78
|
-
return storageOrRef;
|
|
79
|
-
}
|
|
80
|
-
return storageOrRef.child.call(storageOrRef, path, MODULAR_DEPRECATION_ARG);
|
|
81
|
-
}
|
|
82
|
-
const storage = storageOrRef;
|
|
83
|
-
if (path != null && isUrl(path)) {
|
|
84
|
-
return storage.refFromURL.call(storage, path, MODULAR_DEPRECATION_ARG);
|
|
85
|
-
}
|
|
86
|
-
return storage.ref.call(storage, path, MODULAR_DEPRECATION_ARG);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Deletes the object at this reference's location.
|
|
91
|
-
* @param storageRef - Storage `Reference` instance.
|
|
92
|
-
* @returns {Promise<void>}
|
|
93
|
-
*/
|
|
94
|
-
export function deleteObject(storageRef) {
|
|
95
|
-
return storageRef.delete.call(storageRef, MODULAR_DEPRECATION_ARG);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Downloads the data at the object's location. Returns an error if the object is not found.
|
|
100
|
-
* @param _storageRef - Storage `Reference` instance.
|
|
101
|
-
* @param _maxDownloadSizeBytes - The maximum allowed size in bytes to retrieve. Web only.
|
|
102
|
-
* @returns {Promise<Blob>}
|
|
103
|
-
*/
|
|
104
|
-
export function getBlob(_storageRef, _maxDownloadSizeBytes) {
|
|
105
|
-
throw new Error('`getBlob()` is not implemented');
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Downloads the data at the object's location. Returns an error if the object is not found.
|
|
110
|
-
* @param _storageRef - Storage `Reference` instance.
|
|
111
|
-
* @param _maxDownloadSizeBytes - The maximum allowed size in bytes to retrieve. Web only.
|
|
112
|
-
* @returns {Promise<ArrayBuffer>}
|
|
113
|
-
*/
|
|
114
|
-
export function getBytes(_storageRef, _maxDownloadSizeBytes) {
|
|
115
|
-
throw new Error('`getBytes()` is not implemented');
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Deletes the object at this reference's location.
|
|
120
|
-
* @param storageRef - Storage `Reference` instance.
|
|
121
|
-
* @returns {Promise<string>}
|
|
122
|
-
*/
|
|
123
|
-
export function getDownloadURL(storageRef) {
|
|
124
|
-
return storageRef.getDownloadURL.call(storageRef, MODULAR_DEPRECATION_ARG);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Fetches metadata for the object at this location, if one exists.
|
|
129
|
-
* @param storageRef - Storage `Reference` instance.
|
|
130
|
-
* @returns {Promise<FullMetadata>}
|
|
131
|
-
*/
|
|
132
|
-
export function getMetadata(storageRef) {
|
|
133
|
-
return storageRef.getMetadata.call(storageRef, MODULAR_DEPRECATION_ARG);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Downloads the data at the object's location. This API is only available in Nodejs.
|
|
138
|
-
* @param _storageRef - Storage `Reference` instance.
|
|
139
|
-
* @param _maxDownloadSizeBytes - The maximum allowed size in bytes to retrieve. Web only.
|
|
140
|
-
* @returns {NodeJS.ReadableStream;}
|
|
141
|
-
*/
|
|
142
|
-
export function getStream(_storageRef, _maxDownloadSizeBytes) {
|
|
143
|
-
throw new Error('`getStream()` is not implemented');
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* List items (files) and prefixes (folders) under this storage reference
|
|
148
|
-
* @param storageRef - Storage `Reference` instance.
|
|
149
|
-
* @param options - Storage `ListOptions` instance. The options list() accepts.
|
|
150
|
-
* @returns {Promise<ListResult>}
|
|
151
|
-
*/
|
|
152
|
-
export async function list(storageRef, options) {
|
|
153
|
-
const result = await storageRef.list.call(storageRef, options, MODULAR_DEPRECATION_ARG);
|
|
154
|
-
if (result.nextPageToken === null) {
|
|
155
|
-
delete result.nextPageToken;
|
|
156
|
-
}
|
|
157
|
-
return result;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* List all items (files) and prefixes (folders) under this storage reference.
|
|
162
|
-
* @param storageRef - Storage `Reference` instance.
|
|
163
|
-
* @returns {Promise<ListResult>}
|
|
164
|
-
*/
|
|
165
|
-
export async function listAll(storageRef) {
|
|
166
|
-
const result = await storageRef.listAll.call(storageRef, MODULAR_DEPRECATION_ARG);
|
|
167
|
-
if (result.nextPageToken === null) {
|
|
168
|
-
delete result.nextPageToken;
|
|
169
|
-
}
|
|
170
|
-
return result;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* Updates the metadata for this object.
|
|
175
|
-
* @param storageRef - Storage `Reference` instance.
|
|
176
|
-
* @param metadata - A Storage `SettableMetadata` instance to update.
|
|
177
|
-
* @returns {Promise<FullMetadata>}
|
|
178
|
-
*/
|
|
179
|
-
export function updateMetadata(storageRef, metadata) {
|
|
180
|
-
return storageRef.updateMetadata.call(storageRef, metadata, MODULAR_DEPRECATION_ARG);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Uploads data to this object's location. The upload is not resumable.
|
|
185
|
-
* @param _storageRef - Storage `Reference` instance.
|
|
186
|
-
* @param _data - The data (Blob | Uint8Array | ArrayBuffer) to upload to the storage bucket at the reference location.
|
|
187
|
-
* @param _metadata - A Storage `UploadMetadata` instance to update. Optional.
|
|
188
|
-
* @returns {Promise<TaskResult>}
|
|
189
|
-
*/
|
|
190
|
-
export async function uploadBytes(_storageRef, _data, _metadata) {
|
|
191
|
-
throw new Error('`uploadBytes()` is not implemented');
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* Uploads data to this object's location. The upload is not resumable.
|
|
196
|
-
* @param storageRef - Storage `Reference` instance.
|
|
197
|
-
* @param data - The data (Blob | Uint8Array | ArrayBuffer) to upload to the storage bucket at the reference location.
|
|
198
|
-
* @param metadata - A Storage `UploadMetadata` instance to update. Optional.
|
|
199
|
-
* @returns {Task}
|
|
200
|
-
*/
|
|
201
|
-
export function uploadBytesResumable(storageRef, data, metadata) {
|
|
202
|
-
return storageRef.put.call(storageRef, data, metadata, MODULAR_DEPRECATION_ARG);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* Uploads data to this object's location. The upload is not resumable.
|
|
207
|
-
* @param storageRef - Storage `Reference` instance.
|
|
208
|
-
* @param data - The string to upload.
|
|
209
|
-
* @param format - The format of the string to upload ('raw' | 'base64' | 'base64url' | 'data_url'). Optional.
|
|
210
|
-
* @param metadata - A Storage `UploadMetadata` instance to update. Optional.
|
|
211
|
-
* @returns {Task}
|
|
212
|
-
*/
|
|
213
|
-
export function uploadString(storageRef, data, format, metadata) {
|
|
214
|
-
return storageRef.putString.call(storageRef, data, format, metadata, MODULAR_DEPRECATION_ARG);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
// Methods not on the Firebase JS SDK below
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* Sets the maximum time in milliseconds to retry a download if a failure occurs.. android & iOS only.
|
|
221
|
-
* @param storage - Storage instance.
|
|
222
|
-
* @param time - The new maximum operation retry time in milliseconds.
|
|
223
|
-
* @returns {Promise<void>}
|
|
224
|
-
*/
|
|
225
|
-
export function setMaxOperationRetryTime(storage, time) {
|
|
226
|
-
return storage.setMaxOperationRetryTime.call(storage, time, MODULAR_DEPRECATION_ARG);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* Sets the maximum time in milliseconds to retry an upload if a failure occurs. android & iOS only.
|
|
231
|
-
* @param storage - Storage instance.
|
|
232
|
-
* @param time - The new maximum operation retry time in milliseconds.
|
|
233
|
-
* @returns {Promise<void>}
|
|
234
|
-
*/
|
|
235
|
-
export function setMaxUploadRetryTime(storage, time) {
|
|
236
|
-
return storage.setMaxUploadRetryTime.call(storage, time, MODULAR_DEPRECATION_ARG);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
/**
|
|
240
|
-
* Puts a file from local disk onto the storage bucket.
|
|
241
|
-
* @param storageRef - Storage Reference instance.
|
|
242
|
-
* @param filePath The local file path to upload to the bucket at the reference location.
|
|
243
|
-
* @param metadata Any additional `UploadMetadata` for this task.
|
|
244
|
-
* @returns {Task}
|
|
245
|
-
*/
|
|
246
|
-
export function putFile(storageRef, filePath, metadata) {
|
|
247
|
-
return storageRef.putFile.call(storageRef, filePath, metadata, MODULAR_DEPRECATION_ARG);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
/**
|
|
251
|
-
* Downloads a file to the specified local file path on the device.
|
|
252
|
-
* @param storageRef - Storage Reference instance.
|
|
253
|
-
* @param filePath The local file path to upload to on the device.
|
|
254
|
-
* @returns {Task}
|
|
255
|
-
*/
|
|
256
|
-
export function writeToFile(storageRef, filePath) {
|
|
257
|
-
return storageRef.writeToFile.call(storageRef, filePath, MODULAR_DEPRECATION_ARG);
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
* Sets the maximum time in milliseconds to retry a download if a failure occurs.
|
|
262
|
-
* @param storage - Storage instance.
|
|
263
|
-
* @param time - The new maximum download retry time in milliseconds.
|
|
264
|
-
* @returns {Promise<void>}
|
|
265
|
-
*/
|
|
266
|
-
export function setMaxDownloadRetryTime(storage, time) {
|
|
267
|
-
return storage.setMaxDownloadRetryTime.call(storage, time, MODULAR_DEPRECATION_ARG);
|
|
268
|
-
}
|
|
269
|
-
export { StringFormat, TaskEvent, TaskState } from "./StorageStatics.js";
|
|
270
|
-
//# sourceMappingURL=modular.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["getApp","MODULAR_DEPRECATION_ARG","isUrl","path","test","decodeURIComponent","getStorage","app","bucketUrl","name","storage","connectStorageEmulator","host","port","options","useEmulator","call","ref","storageOrRef","fullPath","undefined","child","refFromURL","deleteObject","storageRef","delete","getBlob","_storageRef","_maxDownloadSizeBytes","Error","getBytes","getDownloadURL","getMetadata","getStream","list","result","nextPageToken","listAll","updateMetadata","metadata","uploadBytes","_data","_metadata","uploadBytesResumable","data","put","uploadString","format","putString","setMaxOperationRetryTime","time","setMaxUploadRetryTime","putFile","filePath","writeToFile","setMaxDownloadRetryTime","StringFormat","TaskEvent","TaskState"],"sourceRoot":"../../lib","sources":["modular.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,MAAM,QAAQ,4BAA4B;AACnD,SAASC,uBAAuB,QAAQ,+CAA+C;AAoBvF,SAASC,KAAKA,CAACC,IAAa,EAAW;EACrC,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;IAC5B,OAAO,KAAK;EACd;EAEA,OAAO,iBAAiB,CAACC,IAAI,CAACC,kBAAkB,CAACF,IAAI,CAAC,CAAC;AACzD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASG,UAAUA,CAACC,GAAiB,EAAEC,SAAkB,EAAmB;EACjF,IAAID,GAAG,EAAE;IACP,IAAIC,SAAS,IAAI,IAAI,EAAE;MACrB,OAAOR,MAAM,CAACO,GAAG,CAACE,IAAI,CAAC,CAACC,OAAO,CAACF,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O,CAAqBuC,wBAAwB,CAGrDjC,IAAI,CAACN,OAAO,EAAEwC,IAAI,EAAEjD,uBAAuB,CAAC;AAChD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASkD,qBAAqBA,CAACzC,OAAwB,EAAEwC,IAAY,EAAiB;EAC3F,OACGxC,OAAO,CAAqByC,qBAAqB,CAGlDnC,IAAI,CAACN,OAAO,EAAEwC,IAAI,EAAEjD,uBAAuB,CAAC;AAChD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASmD,OAAOA,CACrB5B,UAA4B,EAC5B6B,QAAgB,EAChBd,QAAyB,EACnB;EACN,OACGf,UAAU,CAA8B4B,OAAO,CAGhDpC,IAAI,CAACQ,UAAU,EAAE6B,QAAQ,EAAEd,QAAQ,EAAEtC,uBAAuB,CAAC;AACjE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASqD,WAAWA,CAAC9B,UAA4B,EAAE6B,QAAgB,EAAQ;EAChF,OACG7B,UAAU,CAA8B8B,WAAW,CAGpDtC,IAAI,CAACQ,UAAU,EAAE6B,QAAQ,EAAEpD,uBAAuB,CAAC;AACvD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASsD,uBAAuBA,CAAC7C,OAAwB,EAAEwC,IAAY,EAAiB;EAC7F,OACGxC,OAAO,CAAqB6C,uBAAuB,CAGpDvC,IAAI,CAACN,OAAO,EAAEwC,IAAI,EAAEjD,uBAAuB,CAAC;AAChD;AAEA,SAASuD,YAAY,EAAEC,SAAS,EAAEC,SAAS,QAAQ,qBAAkB","ignoreList":[]}
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
5
|
-
*
|
|
6
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
-
* you may not use this library except in compliance with the License.
|
|
8
|
-
* You may obtain a copy of the License at
|
|
9
|
-
*
|
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
-
* See the License for the specific language governing permissions and
|
|
16
|
-
* limitations under the License.
|
|
17
|
-
*
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import { isAndroid, isNumber, isString, createDeprecationProxy } from '@react-native-firebase/app/dist/module/common';
|
|
21
|
-
import { setReactNativeModule } from '@react-native-firebase/app/dist/module/internal/nativeModule';
|
|
22
|
-
import { createModuleNamespace, FirebaseModule, getFirebaseRoot } from '@react-native-firebase/app/dist/module/internal';
|
|
23
|
-
import Reference from "./StorageReference.js";
|
|
24
|
-
import { StringFormat, TaskEvent, TaskState } from "./StorageStatics.js";
|
|
25
|
-
import { getGsUrlParts, getHttpUrlParts, handleStorageEvent } from "./utils.js";
|
|
26
|
-
import { version } from "./version.js";
|
|
27
|
-
import fallBackModule from './web/RNFBStorageModule';
|
|
28
|
-
const statics = {
|
|
29
|
-
StringFormat,
|
|
30
|
-
TaskEvent,
|
|
31
|
-
TaskState
|
|
32
|
-
};
|
|
33
|
-
const namespace = 'storage';
|
|
34
|
-
const nativeEvents = ['storage_event'];
|
|
35
|
-
const nativeModuleName = 'RNFBStorageModule';
|
|
36
|
-
class FirebaseStorageModule extends FirebaseModule {
|
|
37
|
-
constructor(app, config, bucketUrl) {
|
|
38
|
-
super(app, config, bucketUrl ?? undefined);
|
|
39
|
-
if (bucketUrl == null) {
|
|
40
|
-
this._customUrlOrRegion = `gs://${app.options.storageBucket}`;
|
|
41
|
-
} else if (!isString(bucketUrl) || !bucketUrl.startsWith('gs://')) {
|
|
42
|
-
throw new Error("firebase.app().storage(*) bucket url must be a string and begin with 'gs://'");
|
|
43
|
-
}
|
|
44
|
-
const storageEvent = nativeEvents[0];
|
|
45
|
-
if (!storageEvent) {
|
|
46
|
-
throw new Error('storage_event is not defined in nativeEvents');
|
|
47
|
-
}
|
|
48
|
-
this.emitter.addListener(this.eventNameForApp(storageEvent), handleStorageEvent.bind(null, this));
|
|
49
|
-
|
|
50
|
-
// Emulator instance vars needed to send through on iOS, iOS does not persist emulator state between calls
|
|
51
|
-
this.emulatorHost = undefined;
|
|
52
|
-
this.emulatorPort = 0;
|
|
53
|
-
this._maxUploadRetryTime = this.native.maxUploadRetryTime || 0;
|
|
54
|
-
this._maxDownloadRetryTime = this.native.maxDownloadRetryTime || 0;
|
|
55
|
-
this._maxOperationRetryTime = this.native.maxOperationRetryTime || 0;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* @url https://firebase.google.com/docs/reference/js/firebase.storage.Storage#setmaxuploadretrytime
|
|
60
|
-
*/
|
|
61
|
-
get maxUploadRetryTime() {
|
|
62
|
-
return this._maxUploadRetryTime;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* @url https://firebase.google.com/docs/reference/js/firebase.storage.Storage#setmaxdownloadretrytime
|
|
67
|
-
*/
|
|
68
|
-
get maxDownloadRetryTime() {
|
|
69
|
-
return this._maxDownloadRetryTime;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* @url https://firebase.google.com/docs/reference/js/firebase.storage.Storage#maxoperationretrytime
|
|
74
|
-
*/
|
|
75
|
-
get maxOperationRetryTime() {
|
|
76
|
-
return this._maxOperationRetryTime;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* @url https://firebase.google.com/docs/reference/js/firebase.storage.Storage#ref
|
|
81
|
-
*/
|
|
82
|
-
ref(path = '/') {
|
|
83
|
-
if (!isString(path)) {
|
|
84
|
-
throw new Error("firebase.storage().ref(*) 'path' must be a string value.");
|
|
85
|
-
}
|
|
86
|
-
return createDeprecationProxy(new Reference(this, path));
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* @url https://firebase.google.com/docs/reference/js/firebase.storage.Storage#refFromURL
|
|
91
|
-
*/
|
|
92
|
-
refFromURL(url) {
|
|
93
|
-
if (!isString(url) || !url.startsWith('gs://') && !url.startsWith('http')) {
|
|
94
|
-
throw new Error("firebase.storage().refFromURL(*) 'url' must be a string value and begin with 'gs://' or 'https://'.");
|
|
95
|
-
}
|
|
96
|
-
let path;
|
|
97
|
-
let bucket;
|
|
98
|
-
if (url.startsWith('http')) {
|
|
99
|
-
const parts = getHttpUrlParts(url);
|
|
100
|
-
if (!parts) {
|
|
101
|
-
throw new Error("firebase.storage().refFromURL(*) unable to parse 'url', ensure it's a valid storage url'.");
|
|
102
|
-
}
|
|
103
|
-
({
|
|
104
|
-
bucket,
|
|
105
|
-
path
|
|
106
|
-
} = parts);
|
|
107
|
-
} else {
|
|
108
|
-
({
|
|
109
|
-
bucket,
|
|
110
|
-
path
|
|
111
|
-
} = getGsUrlParts(url));
|
|
112
|
-
}
|
|
113
|
-
const storageInstance = this.app.storage(bucket);
|
|
114
|
-
return new Reference(storageInstance, path);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* @url https://firebase.google.com/docs/reference/js/firebase.storage.Storage#setMaxOperationRetryTime
|
|
119
|
-
*/
|
|
120
|
-
setMaxOperationRetryTime(time) {
|
|
121
|
-
if (!isNumber(time)) {
|
|
122
|
-
throw new Error("firebase.storage().setMaxOperationRetryTime(*) 'time' must be a number value.");
|
|
123
|
-
}
|
|
124
|
-
this._maxOperationRetryTime = time;
|
|
125
|
-
return this.native.setMaxOperationRetryTime(time);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* @url https://firebase.google.com/docs/reference/js/firebase.storage.Storage#setMaxUploadRetryTime
|
|
130
|
-
*/
|
|
131
|
-
setMaxUploadRetryTime(time) {
|
|
132
|
-
if (!isNumber(time)) {
|
|
133
|
-
throw new Error("firebase.storage().setMaxUploadRetryTime(*) 'time' must be a number value.");
|
|
134
|
-
}
|
|
135
|
-
this._maxUploadRetryTime = time;
|
|
136
|
-
return this.native.setMaxUploadRetryTime(time);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* @url https://firebase.google.com/docs/reference/js/firebase.storage.Storage#setMaxDownloadRetryTime
|
|
141
|
-
*/
|
|
142
|
-
setMaxDownloadRetryTime(time) {
|
|
143
|
-
if (!isNumber(time)) {
|
|
144
|
-
throw new Error("firebase.storage().setMaxDownloadRetryTime(*) 'time' must be a number value.");
|
|
145
|
-
}
|
|
146
|
-
this._maxDownloadRetryTime = time;
|
|
147
|
-
return this.native.setMaxDownloadRetryTime(time);
|
|
148
|
-
}
|
|
149
|
-
useEmulator(host, port, _options) {
|
|
150
|
-
if (!host || !isString(host) || !port || !isNumber(port)) {
|
|
151
|
-
throw new Error('firebase.storage().useEmulator() takes a non-empty host and port');
|
|
152
|
-
}
|
|
153
|
-
let _host = host;
|
|
154
|
-
const androidBypassEmulatorUrlRemap = typeof this.firebaseJson.android_bypass_emulator_url_remap === 'boolean' && this.firebaseJson.android_bypass_emulator_url_remap;
|
|
155
|
-
if (!androidBypassEmulatorUrlRemap && isAndroid && _host) {
|
|
156
|
-
if (_host === 'localhost' || _host === '127.0.0.1') {
|
|
157
|
-
_host = '10.0.2.2';
|
|
158
|
-
// eslint-disable-next-line no-console
|
|
159
|
-
console.log('Mapping storage host to "10.0.2.2" for android emulators. Use real IP on real devices. You can bypass this behaviour with "android_bypass_emulator_url_remap" flag.');
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
this.emulatorHost = host;
|
|
163
|
-
this.emulatorPort = port;
|
|
164
|
-
this.native.useEmulator(_host, port, this._customUrlOrRegion);
|
|
165
|
-
// @ts-ignore undocumented return, just used to unit test android host remapping
|
|
166
|
-
return [_host, port];
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// import { SDK_VERSION } from '@react-native-firebase/storage';
|
|
171
|
-
export const SDK_VERSION = version;
|
|
172
|
-
const storageNamespace = createModuleNamespace({
|
|
173
|
-
statics,
|
|
174
|
-
version,
|
|
175
|
-
namespace,
|
|
176
|
-
nativeEvents,
|
|
177
|
-
nativeModuleName,
|
|
178
|
-
hasMultiAppSupport: true,
|
|
179
|
-
hasCustomUrlOrRegionSupport: true,
|
|
180
|
-
disablePrependCustomUrlOrRegion: true,
|
|
181
|
-
ModuleClass: FirebaseStorageModule
|
|
182
|
-
});
|
|
183
|
-
// import storage from '@react-native-firebase/storage';
|
|
184
|
-
// storage().X(...);
|
|
185
|
-
export default storageNamespace;
|
|
186
|
-
|
|
187
|
-
// import storage, { firebase } from '@react-native-firebase/storage';
|
|
188
|
-
// storage().X(...);
|
|
189
|
-
// firebase.storage().X(...);
|
|
190
|
-
export const firebase = getFirebaseRoot();
|
|
191
|
-
setReactNativeModule(nativeModuleName, fallBackModule);
|
|
192
|
-
//# sourceMappingURL=namespaced.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["isAndroid","isNumber","isString","createDeprecationProxy","setReactNativeModule","createModuleNamespace","FirebaseModule","getFirebaseRoot","Reference","StringFormat","TaskEvent","TaskState","getGsUrlParts","getHttpUrlParts","handleStorageEvent","version","fallBackModule","statics","namespace","nativeEvents","nativeModuleName","FirebaseStorageModule","constructor","app","config","bucketUrl","undefined","_customUrlOrRegion","options","storageBucket","startsWith","Error","storageEvent","emitter","addListener","eventNameForApp","bind","emulatorHost","emulatorPort","_maxUploadRetryTime","native","maxUploadRetryTime","_maxDownloadRetryTime","maxDownloadRetryTime","_maxOperationRetryTime","maxOperationRetryTime","ref","path","refFromURL","url","bucket","parts","storageInstance","storage","setMaxOperationRetryTime","time","setMaxUploadRetryTime","setMaxDownloadRetryTime","useEmulator","host","port","_options","_host","androidBypassEmulatorUrlRemap","firebaseJson","android_bypass_emulator_url_remap","console","log","SDK_VERSION","storageNamespace","hasMultiAppSupport","hasCustomUrlOrRegionSupport","disablePrependCustomUrlOrRegion","ModuleClass","firebase"],"sourceRoot":"../../lib","sources":["namespaced.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SACEA,SAAS,EACTC,QAAQ,EACRC,QAAQ,EACRC,sBAAsB,QACjB,+CAA+C;AAEtD,SAASC,oBAAoB,QAAQ,8DAA8D;AACnG,SACEC,qBAAqB,EACrBC,cAAc,EACdC,eAAe,QAEV,iDAAiD;AAExD,OAAOC,SAAS,MAAM,uBAAoB;AAC1C,SAASC,YAAY,EAAEC,SAAS,EAAEC,SAAS,QAAQ,qBAAkB;AACrE,SAASC,aAAa,EAAEC,eAAe,EAAEC,kBAAkB,QAAQ,YAAS;AAC5E,SAASC,OAAO,QAAQ,cAAW;AACnC,OAAOC,cAAc,MAAM,yBAAyB;AAIpD,MAAMC,OAAO,GAAG;EACdR,YAAY;EACZC,SAAS;EACTC;AACF,CAAC;AAED,MAAMO,SAAS,GAAG,SAAS;AAC3B,MAAMC,YAAY,GAAG,CAAC,eAAe,CAAC;AACtC,MAAMC,gBAAgB,GAAG,mBAAmB;AAE5C,MAAMC,qBAAqB,SAASf,cAAc,CAA0B;EAO1EgB,WAAWA,CACTC,GAAwC,EACxCC,MAAoB,EACpBC,SAAyB,EACzB;IACA,KAAK,CAACF,GAAG,EAAEC,MAAM,EAAEC,SAAS,IAAIC,SAAS,CAAC;IAC1C,IAAID,SAAS,IAAI,IAAI,EAAE;MACrB,IAAI,CAACE,kBAAkB,GAAG,QAAQJ,GAAG,CAACK,OAAO,CAACC,aAAa,EAAE;IAC/D,CAAC,MAAM,IAAI,CAAC3B,QAAQ,CAACuB,SAAS,CAAC,IAAI,CAACA,SAAS,CAACK,UAAU,CAAC,OAAO,CAAC,EAAE;MACjE,MAAM,IAAIC,KAAK,CACb,8EACF,CA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