@react-native-firebase/app 25.1.0 → 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 +43 -0
- package/RNFBApp.podspec +7 -13
- package/android/build.gradle +25 -6
- package/android/src/reactnative/java/io/invertase/firebase/app/{ReactNativeFirebaseAppModule.java → NativeRNFBTurboApp.java} +81 -45
- package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseAppPackage.java +3 -3
- package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseVersion.java +2 -2
- package/android/src/reactnative/java/io/invertase/firebase/app/generated/java/com/facebook/fbreact/specs/NativeRNFBTurboAppSpec.java +136 -0
- package/android/src/reactnative/java/io/invertase/firebase/app/generated/java/com/facebook/fbreact/specs/NativeRNFBTurboUtilsSpec.java +94 -0
- package/android/src/reactnative/java/io/invertase/firebase/app/generated/jni/CMakeLists.txt +36 -0
- package/android/src/reactnative/java/io/invertase/firebase/app/generated/jni/RNFBAppTurboModules-generated.cpp +170 -0
- package/android/src/reactnative/java/io/invertase/firebase/app/generated/jni/RNFBAppTurboModules.h +39 -0
- package/android/src/reactnative/java/io/invertase/firebase/app/generated/jni/react/renderer/components/RNFBAppTurboModules/RNFBAppTurboModulesJSI-generated.cpp +187 -0
- package/android/src/reactnative/java/io/invertase/firebase/app/generated/jni/react/renderer/components/RNFBAppTurboModules/RNFBAppTurboModulesJSI.h +606 -0
- package/android/src/reactnative/java/io/invertase/firebase/common/RCTConvertFirebase.java +3 -3
- package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseEventEmitter.java +475 -20
- package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseMeta.java +8 -0
- package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebasePreferences.java +8 -0
- package/android/src/reactnative/java/io/invertase/firebase/utils/{ReactNativeFirebaseUtilsModule.java → NativeRNFBTurboUtils.java} +57 -40
- package/android/src/test/java/io/invertase/firebase/app/NativeRNFBTurboAppTest.java +400 -0
- package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseEventEmitterTest.java +1823 -0
- package/app.plugin.js +1 -1
- package/dist/module/FirebaseApp.js +0 -9
- package/dist/module/FirebaseApp.js.map +1 -1
- package/dist/module/common/index.js +0 -645
- package/dist/module/common/index.js.map +1 -1
- package/dist/module/common/unitTestUtils.js +18 -54
- package/dist/module/common/unitTestUtils.js.map +1 -1
- package/dist/module/index.js +0 -1
- package/dist/module/index.js.map +1 -1
- package/dist/module/internal/RNFBNativeEventEmitter.js +12 -6
- package/dist/module/internal/RNFBNativeEventEmitter.js.map +1 -1
- package/dist/module/internal/constants.js +2 -2
- package/dist/module/internal/constants.js.map +1 -1
- package/dist/module/internal/index.js +1 -1
- package/dist/module/internal/index.js.map +1 -1
- package/dist/module/internal/nativeModuleAndroidIos.js +50 -10
- package/dist/module/internal/nativeModuleAndroidIos.js.map +1 -1
- package/dist/module/internal/nativeModuleWeb.js +12 -4
- package/dist/module/internal/nativeModuleWeb.js.map +1 -1
- package/dist/module/internal/registry/app.js +20 -12
- package/dist/module/internal/registry/app.js.map +1 -1
- package/dist/module/internal/registry/modular.js +73 -0
- package/dist/module/internal/registry/modular.js.map +1 -0
- package/dist/module/internal/registry/nativeModule.js +116 -95
- package/dist/module/internal/registry/nativeModule.js.map +1 -1
- package/dist/module/modular.js +44 -37
- package/dist/module/modular.js.map +1 -1
- package/dist/module/types/app.js +0 -3
- package/dist/module/types/app.js.map +1 -1
- package/dist/module/types/internal.js +0 -2
- package/dist/module/utils/UtilsStatics.js +2 -2
- package/dist/module/utils/UtilsStatics.js.map +1 -1
- package/dist/module/utils/index.js +21 -17
- package/dist/module/utils/index.js.map +1 -1
- package/dist/module/version.js +1 -1
- package/dist/typescript/lib/FirebaseApp.d.ts +1 -2
- package/dist/typescript/lib/FirebaseApp.d.ts.map +1 -1
- package/dist/typescript/lib/common/index.d.ts +0 -8
- package/dist/typescript/lib/common/index.d.ts.map +1 -1
- package/dist/typescript/lib/common/unitTestUtils.d.ts +1 -4
- package/dist/typescript/lib/common/unitTestUtils.d.ts.map +1 -1
- package/dist/typescript/lib/index.d.ts +0 -1
- package/dist/typescript/lib/index.d.ts.map +1 -1
- package/dist/typescript/lib/internal/NativeFirebaseError.d.ts +1 -1
- package/dist/typescript/lib/internal/NativeFirebaseError.d.ts.map +1 -1
- package/dist/typescript/lib/internal/RNFBNativeEventEmitter.d.ts.map +1 -1
- package/dist/typescript/lib/internal/constants.d.ts +2 -3
- package/dist/typescript/lib/internal/constants.d.ts.map +1 -1
- package/dist/typescript/lib/internal/index.d.ts +1 -1
- package/dist/typescript/lib/internal/index.d.ts.map +1 -1
- package/dist/typescript/lib/internal/nativeModuleAndroidIos.d.ts +2 -6
- package/dist/typescript/lib/internal/nativeModuleAndroidIos.d.ts.map +1 -1
- package/dist/typescript/lib/internal/nativeModuleWeb.d.ts.map +1 -1
- package/dist/typescript/lib/internal/registry/app.d.ts +2 -2
- package/dist/typescript/lib/internal/registry/app.d.ts.map +1 -1
- package/dist/typescript/lib/internal/registry/modular.d.ts +22 -0
- package/dist/typescript/lib/internal/registry/modular.d.ts.map +1 -0
- package/dist/typescript/lib/internal/registry/nativeModule.d.ts +3 -11
- package/dist/typescript/lib/internal/registry/nativeModule.d.ts.map +1 -1
- package/dist/typescript/lib/modular.d.ts +21 -7
- package/dist/typescript/lib/modular.d.ts.map +1 -1
- package/dist/typescript/lib/types/app.d.ts +4 -4
- package/dist/typescript/lib/types/app.d.ts.map +1 -1
- package/dist/typescript/lib/types/internal.d.ts +1 -33
- package/dist/typescript/lib/types/internal.d.ts.map +1 -1
- package/dist/typescript/lib/utils/index.d.ts +7 -3
- package/dist/typescript/lib/utils/index.d.ts.map +1 -1
- package/dist/typescript/lib/version.d.ts +1 -1
- package/firebase-schema.json +5 -1
- package/ios/RNFBApp/RNFBAppModule.h +1 -3
- package/ios/RNFBApp/{RNFBAppModule.m → RNFBAppModule.mm} +74 -77
- package/ios/RNFBApp/RNFBUtilsModule.h +1 -3
- package/ios/RNFBApp/{RNFBUtilsModule.m → RNFBUtilsModule.mm} +68 -25
- package/ios/RNFBApp/RNFBVersion.m +1 -1
- package/ios/RNFBApp.xcodeproj/project.pbxproj +12 -12
- package/ios/generated/RCTAppDependencyProvider.h +25 -0
- package/ios/generated/RCTAppDependencyProvider.mm +55 -0
- package/ios/generated/RCTModuleProviders.h +16 -0
- package/ios/generated/RCTModuleProviders.mm +52 -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/RCTUnstableModulesRequiringMainQueueSetupProvider.h +14 -0
- package/ios/generated/RCTUnstableModulesRequiringMainQueueSetupProvider.mm +19 -0
- package/ios/generated/RNFBAppTurboModules/RNFBAppTurboModules-generated.mm +210 -0
- package/ios/generated/RNFBAppTurboModules/RNFBAppTurboModules.h +399 -0
- package/ios/generated/RNFBAppTurboModulesJSI-generated.cpp +187 -0
- package/ios/generated/RNFBAppTurboModulesJSI.h +606 -0
- package/ios/generated/ReactAppDependencyProvider.podspec +34 -0
- package/ios/generated/ReactCodegen.podspec +111 -0
- package/lib/FirebaseApp.ts +1 -10
- package/lib/common/index.ts +0 -742
- package/lib/common/unitTestUtils.ts +17 -73
- package/lib/index.ts +0 -1
- package/lib/internal/NativeFirebaseError.ts +1 -1
- package/lib/internal/RNFBNativeEventEmitter.ts +12 -6
- package/lib/internal/constants.ts +3 -25
- package/lib/internal/global.d.ts +0 -4
- package/lib/internal/index.ts +1 -1
- package/lib/internal/nativeModuleAndroidIos.ts +69 -12
- package/lib/internal/nativeModuleWeb.ts +11 -5
- package/lib/internal/registry/app.ts +24 -22
- package/lib/internal/registry/modular.ts +97 -0
- package/lib/internal/registry/nativeModule.ts +136 -107
- package/lib/modular.ts +47 -72
- package/lib/types/app.ts +6 -11
- package/lib/types/internal.ts +1 -46
- package/lib/utils/UtilsStatics.ts +2 -2
- package/lib/utils/index.ts +24 -18
- package/lib/version.ts +1 -1
- package/package.json +41 -3
- package/plugin/build/app.plugin.d.ts +2 -0
- package/plugin/build/app.plugin.js +6 -0
- package/plugin/src/app.plugin.ts +3 -0
- package/plugin/tsconfig.tsbuildinfo +1 -1
- package/react-native.config.js +2 -0
- package/specs/NativeRNFBTurboApp.ts +57 -0
- package/specs/NativeRNFBTurboUtils.ts +34 -0
- package/typedoc.json +1 -2
- package/dist/module/internal/registry/namespace.js +0 -262
- package/dist/module/internal/registry/namespace.js.map +0 -1
- package/dist/module/namespaced.js +0 -25
- package/dist/module/namespaced.js.map +0 -1
- package/dist/typescript/lib/internal/registry/namespace.d.ts +0 -26
- package/dist/typescript/lib/internal/registry/namespace.d.ts.map +0 -1
- package/dist/typescript/lib/namespaced.d.ts +0 -5
- package/dist/typescript/lib/namespaced.d.ts.map +0 -1
- package/lib/internal/registry/namespace.ts +0 -338
- package/lib/namespaced.ts +0 -24
|
@@ -1,338 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this library except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
import { isString, createDeprecationProxy } from '../../common';
|
|
19
|
-
import FirebaseApp from '../../FirebaseApp';
|
|
20
|
-
import { version as SDK_VERSION } from '../../version';
|
|
21
|
-
import { DEFAULT_APP_NAME, KNOWN_NAMESPACES, type KnownNamespace } from '../constants';
|
|
22
|
-
import FirebaseModule from '../FirebaseModule';
|
|
23
|
-
import type { ModuleGetter, FirebaseRoot, NamespaceConfig } from '../../types/internal';
|
|
24
|
-
import {
|
|
25
|
-
getApp,
|
|
26
|
-
getApps,
|
|
27
|
-
initializeApp,
|
|
28
|
-
setLogLevel,
|
|
29
|
-
setReactNativeAsyncStorage,
|
|
30
|
-
setOnAppCreate,
|
|
31
|
-
setOnAppDestroy,
|
|
32
|
-
} from './app';
|
|
33
|
-
|
|
34
|
-
// firebase.X
|
|
35
|
-
let FIREBASE_ROOT: FirebaseRoot | null = null;
|
|
36
|
-
|
|
37
|
-
const NAMESPACE_REGISTRY: Record<string, NamespaceConfig | undefined> = {};
|
|
38
|
-
const APP_MODULE_INSTANCE: Record<string, Record<string, FirebaseModule<any>>> = {};
|
|
39
|
-
const MODULE_GETTER_FOR_APP: Record<string, Record<string, ModuleGetter>> = {};
|
|
40
|
-
const MODULE_GETTER_FOR_ROOT: Record<string, ModuleGetter> = {};
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Attaches module namespace getters on every newly created app.
|
|
44
|
-
*
|
|
45
|
-
* Structured like this to avoid metro require cycles.
|
|
46
|
-
*/
|
|
47
|
-
setOnAppCreate(app => {
|
|
48
|
-
for (let i = 0; i < KNOWN_NAMESPACES.length; i++) {
|
|
49
|
-
const moduleNamespace = KNOWN_NAMESPACES[i];
|
|
50
|
-
if (moduleNamespace) {
|
|
51
|
-
Object.defineProperty(app, moduleNamespace, {
|
|
52
|
-
enumerable: false,
|
|
53
|
-
get: firebaseAppModuleProxy.bind(null, app, moduleNamespace),
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Destroys all APP_MODULE_INSTANCE & MODULE_GETTER_FOR_APP objects relating to the
|
|
61
|
-
* recently destroyed app.
|
|
62
|
-
*
|
|
63
|
-
* Structured like this to avoid metro require cycles.
|
|
64
|
-
*/
|
|
65
|
-
setOnAppDestroy(app => {
|
|
66
|
-
delete APP_MODULE_INSTANCE[app.name];
|
|
67
|
-
delete MODULE_GETTER_FOR_APP[app.name];
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
*
|
|
72
|
-
* @param app
|
|
73
|
-
* @param moduleNamespace
|
|
74
|
-
* @returns {*}
|
|
75
|
-
*/
|
|
76
|
-
function getOrCreateModuleForApp(app: FirebaseApp, moduleNamespace: KnownNamespace): ModuleGetter {
|
|
77
|
-
if (MODULE_GETTER_FOR_APP[app.name] && MODULE_GETTER_FOR_APP[app.name]?.[moduleNamespace]) {
|
|
78
|
-
return MODULE_GETTER_FOR_APP[app.name]![moduleNamespace]!;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (!MODULE_GETTER_FOR_APP[app.name]) {
|
|
82
|
-
MODULE_GETTER_FOR_APP[app.name] = {};
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const config = NAMESPACE_REGISTRY[moduleNamespace];
|
|
86
|
-
if (!config) {
|
|
87
|
-
throw new Error(`Module namespace '${moduleNamespace}' is not registered.`);
|
|
88
|
-
}
|
|
89
|
-
const { hasCustomUrlOrRegionSupport, hasMultiAppSupport, ModuleClass } = config;
|
|
90
|
-
|
|
91
|
-
// modules such as analytics only run on the default app
|
|
92
|
-
if (!hasMultiAppSupport && app.name !== DEFAULT_APP_NAME) {
|
|
93
|
-
throw new Error(
|
|
94
|
-
[
|
|
95
|
-
`You attempted to call "firebase.app('${app.name}').${moduleNamespace}" but; ${moduleNamespace} does not support multiple Firebase Apps.`,
|
|
96
|
-
'',
|
|
97
|
-
`Ensure you access ${moduleNamespace} from the default application only.`,
|
|
98
|
-
].join('\r\n'),
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// e.g. firebase.storage(customUrlOrRegion), firebase.functions(customUrlOrRegion), firebase.firestore(databaseId), firebase.database(url)
|
|
103
|
-
function firebaseModuleWithArgs(customUrlOrRegionOrDatabaseId?: string): FirebaseModule<any> {
|
|
104
|
-
if (customUrlOrRegionOrDatabaseId !== undefined) {
|
|
105
|
-
if (!hasCustomUrlOrRegionSupport) {
|
|
106
|
-
// TODO throw Module does not support arguments error
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (!isString(customUrlOrRegionOrDatabaseId)) {
|
|
110
|
-
// TODO throw Module first argument must be a string error
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const key = customUrlOrRegionOrDatabaseId
|
|
115
|
-
? `${customUrlOrRegionOrDatabaseId}:${moduleNamespace}`
|
|
116
|
-
: moduleNamespace;
|
|
117
|
-
|
|
118
|
-
if (!APP_MODULE_INSTANCE[app.name]) {
|
|
119
|
-
APP_MODULE_INSTANCE[app.name] = {};
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
if (!APP_MODULE_INSTANCE[app.name]?.[key]) {
|
|
123
|
-
const moduleConfig = NAMESPACE_REGISTRY[moduleNamespace];
|
|
124
|
-
if (!moduleConfig) {
|
|
125
|
-
throw new Error(`Module namespace '${moduleNamespace}' is not registered.`);
|
|
126
|
-
}
|
|
127
|
-
const module = createDeprecationProxy(
|
|
128
|
-
new ModuleClass(app, moduleConfig, customUrlOrRegionOrDatabaseId),
|
|
129
|
-
) as unknown as FirebaseModule<any>;
|
|
130
|
-
|
|
131
|
-
APP_MODULE_INSTANCE[app.name]![key] = module;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
return APP_MODULE_INSTANCE[app.name]![key]!;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
MODULE_GETTER_FOR_APP[app.name]![moduleNamespace] =
|
|
138
|
-
firebaseModuleWithArgs as unknown as ModuleGetter;
|
|
139
|
-
return MODULE_GETTER_FOR_APP[app.name]![moduleNamespace]!;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
*
|
|
144
|
-
* @param moduleNamespace
|
|
145
|
-
* @returns {*}
|
|
146
|
-
*/
|
|
147
|
-
function getOrCreateModuleForRoot(moduleNamespace: KnownNamespace): ModuleGetter {
|
|
148
|
-
if (MODULE_GETTER_FOR_ROOT[moduleNamespace]) {
|
|
149
|
-
return MODULE_GETTER_FOR_ROOT[moduleNamespace];
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
const config = NAMESPACE_REGISTRY[moduleNamespace];
|
|
153
|
-
if (!config) {
|
|
154
|
-
throw new Error(`Module namespace '${moduleNamespace}' is not registered.`);
|
|
155
|
-
}
|
|
156
|
-
const { statics, hasMultiAppSupport, ModuleClass } = config;
|
|
157
|
-
|
|
158
|
-
// e.g. firebase.storage(app)
|
|
159
|
-
function firebaseModuleWithApp(app?: FirebaseApp): FirebaseModule<any> {
|
|
160
|
-
const _app = app || getApp();
|
|
161
|
-
|
|
162
|
-
// Duck-type check for FirebaseApp (checking for required properties)
|
|
163
|
-
if (
|
|
164
|
-
!_app ||
|
|
165
|
-
typeof _app !== 'object' ||
|
|
166
|
-
!('name' in _app) ||
|
|
167
|
-
!('options' in _app) ||
|
|
168
|
-
typeof _app.name !== 'string'
|
|
169
|
-
) {
|
|
170
|
-
throw new Error(
|
|
171
|
-
[
|
|
172
|
-
`"firebase.${moduleNamespace}(app)" arg expects a FirebaseApp instance or undefined.`,
|
|
173
|
-
'',
|
|
174
|
-
'Ensure the arg provided is a Firebase app instance; or no args to use the default Firebase app.',
|
|
175
|
-
].join('\r\n'),
|
|
176
|
-
);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
// modules such as analytics only run on the default app
|
|
180
|
-
if (!hasMultiAppSupport && _app.name !== DEFAULT_APP_NAME) {
|
|
181
|
-
throw new Error(
|
|
182
|
-
[
|
|
183
|
-
`You attempted to call "firebase.${moduleNamespace}(app)" but; ${moduleNamespace} does not support multiple Firebase Apps.`,
|
|
184
|
-
'',
|
|
185
|
-
`Ensure the app provided is the default Firebase app only and not the "${_app.name}" app.`,
|
|
186
|
-
].join('\r\n'),
|
|
187
|
-
);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
if (!APP_MODULE_INSTANCE[_app.name]) {
|
|
191
|
-
APP_MODULE_INSTANCE[_app.name] = {};
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
if (!APP_MODULE_INSTANCE[_app.name]?.[moduleNamespace]) {
|
|
195
|
-
const moduleConfig = NAMESPACE_REGISTRY[moduleNamespace];
|
|
196
|
-
if (!moduleConfig) {
|
|
197
|
-
throw new Error(`Module namespace '${moduleNamespace}' is not registered.`);
|
|
198
|
-
}
|
|
199
|
-
const module = createDeprecationProxy(
|
|
200
|
-
new ModuleClass(_app, moduleConfig),
|
|
201
|
-
) as unknown as FirebaseModule<any>;
|
|
202
|
-
APP_MODULE_INSTANCE[_app.name]![moduleNamespace] = module;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
return APP_MODULE_INSTANCE[_app.name]![moduleNamespace]!;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
Object.assign(firebaseModuleWithApp, statics || {});
|
|
209
|
-
// Object.freeze(firebaseModuleWithApp);
|
|
210
|
-
// Wrap around statics, e.g. firebase.firestore.FieldValue, removed freeze as it stops proxy working. it is deprecated anyway
|
|
211
|
-
MODULE_GETTER_FOR_ROOT[moduleNamespace] = createDeprecationProxy(
|
|
212
|
-
firebaseModuleWithApp,
|
|
213
|
-
) as unknown as ModuleGetter;
|
|
214
|
-
|
|
215
|
-
return MODULE_GETTER_FOR_ROOT[moduleNamespace]!;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
*
|
|
220
|
-
* @param firebaseNamespace
|
|
221
|
-
* @param moduleNamespace
|
|
222
|
-
* @returns {*}
|
|
223
|
-
*/
|
|
224
|
-
function firebaseRootModuleProxy(
|
|
225
|
-
_firebaseNamespace: FirebaseRoot,
|
|
226
|
-
moduleNamespace: string,
|
|
227
|
-
): ModuleGetter {
|
|
228
|
-
if (NAMESPACE_REGISTRY[moduleNamespace]) {
|
|
229
|
-
return getOrCreateModuleForRoot(moduleNamespace as KnownNamespace);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
const moduleWithDashes = moduleNamespace
|
|
233
|
-
.split(/(?=[A-Z])/)
|
|
234
|
-
.join('-')
|
|
235
|
-
.toLowerCase();
|
|
236
|
-
|
|
237
|
-
throw new Error(
|
|
238
|
-
[
|
|
239
|
-
`You attempted to use 'firebase.${moduleNamespace}' but this module could not be found.`,
|
|
240
|
-
'',
|
|
241
|
-
`Ensure you have installed and imported the '@react-native-firebase/${moduleWithDashes}' package.`,
|
|
242
|
-
].join('\r\n'),
|
|
243
|
-
);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
/**
|
|
247
|
-
*
|
|
248
|
-
* @param app
|
|
249
|
-
* @param moduleNamespace
|
|
250
|
-
* @returns {*}
|
|
251
|
-
*/
|
|
252
|
-
export function firebaseAppModuleProxy(app: FirebaseApp, moduleNamespace: string): ModuleGetter {
|
|
253
|
-
if (NAMESPACE_REGISTRY[moduleNamespace]) {
|
|
254
|
-
// Call private _checkDestroyed method
|
|
255
|
-
(app as unknown as { _checkDestroyed: () => void })._checkDestroyed();
|
|
256
|
-
return getOrCreateModuleForApp(app, moduleNamespace as KnownNamespace);
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
const moduleWithDashes = moduleNamespace
|
|
260
|
-
.split(/(?=[A-Z])/)
|
|
261
|
-
.join('-')
|
|
262
|
-
.toLowerCase();
|
|
263
|
-
|
|
264
|
-
throw new Error(
|
|
265
|
-
[
|
|
266
|
-
`You attempted to use "firebase.app('${app.name}').${moduleNamespace}" but this module could not be found.`,
|
|
267
|
-
'',
|
|
268
|
-
`Ensure you have installed and imported the '@react-native-firebase/${moduleWithDashes}' package.`,
|
|
269
|
-
].join('\r\n'),
|
|
270
|
-
);
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
*
|
|
275
|
-
* @returns {*}
|
|
276
|
-
*/
|
|
277
|
-
export function createFirebaseRoot(): FirebaseRoot {
|
|
278
|
-
// Create partial root object - module namespaces like 'utils' are added dynamically below
|
|
279
|
-
const root = {
|
|
280
|
-
initializeApp,
|
|
281
|
-
setReactNativeAsyncStorage,
|
|
282
|
-
get app() {
|
|
283
|
-
return getApp;
|
|
284
|
-
},
|
|
285
|
-
get apps() {
|
|
286
|
-
return getApps();
|
|
287
|
-
},
|
|
288
|
-
SDK_VERSION,
|
|
289
|
-
setLogLevel,
|
|
290
|
-
} as FirebaseRoot;
|
|
291
|
-
|
|
292
|
-
for (let i = 0; i < KNOWN_NAMESPACES.length; i++) {
|
|
293
|
-
const namespace = KNOWN_NAMESPACES[i];
|
|
294
|
-
if (namespace) {
|
|
295
|
-
Object.defineProperty(root, namespace, {
|
|
296
|
-
enumerable: false,
|
|
297
|
-
get: firebaseRootModuleProxy.bind(null, root, namespace),
|
|
298
|
-
});
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
FIREBASE_ROOT = root;
|
|
303
|
-
return root;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
/**
|
|
307
|
-
*
|
|
308
|
-
* @returns {*}
|
|
309
|
-
*/
|
|
310
|
-
export function getFirebaseRoot(): FirebaseRoot {
|
|
311
|
-
if (FIREBASE_ROOT) {
|
|
312
|
-
return FIREBASE_ROOT;
|
|
313
|
-
}
|
|
314
|
-
return createFirebaseRoot();
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
/**
|
|
318
|
-
*
|
|
319
|
-
* @param options
|
|
320
|
-
* @returns {*}
|
|
321
|
-
*/
|
|
322
|
-
export function createModuleNamespace(options: NamespaceConfig): ModuleGetter {
|
|
323
|
-
const { namespace, ModuleClass } = options;
|
|
324
|
-
|
|
325
|
-
if (!NAMESPACE_REGISTRY[namespace]) {
|
|
326
|
-
// validation only for internal / module dev usage
|
|
327
|
-
const firebaseModuleExtended = (FirebaseModule as unknown as { __extended__: object })
|
|
328
|
-
.__extended__;
|
|
329
|
-
const moduleClassExtended = (ModuleClass as unknown as { __extended__: object }).__extended__;
|
|
330
|
-
if (firebaseModuleExtended !== moduleClassExtended) {
|
|
331
|
-
throw new Error('INTERNAL ERROR: ModuleClass must be an instance of FirebaseModule.');
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
NAMESPACE_REGISTRY[namespace] = Object.assign({}, options);
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
return getFirebaseRoot()[namespace] as ModuleGetter;
|
|
338
|
-
}
|
package/lib/namespaced.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this library except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
import { getFirebaseRoot } from './internal/registry/namespace';
|
|
19
|
-
import utils from './utils';
|
|
20
|
-
|
|
21
|
-
export const firebase = getFirebaseRoot();
|
|
22
|
-
export { utils };
|
|
23
|
-
|
|
24
|
-
export default firebase;
|