@react-native-firebase/app 20.1.0 → 20.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseVersion.java +1 -1
  3. package/ios/RNFBApp/RNFBVersion.m +1 -1
  4. package/lib/common/index.js +2 -0
  5. package/lib/index.d.ts +1 -0
  6. package/lib/internal/RNFBNativeEventEmitter.js +31 -6
  7. package/lib/internal/nativeModule.android.js +2 -0
  8. package/lib/internal/nativeModule.ios.js +2 -0
  9. package/lib/internal/nativeModule.js +4 -0
  10. package/lib/internal/nativeModuleAndroidIos.js +45 -0
  11. package/lib/internal/nativeModuleWeb.js +48 -0
  12. package/lib/internal/registry/app.js +2 -1
  13. package/lib/internal/registry/nativeModule.js +11 -15
  14. package/lib/internal/web/RNFBAppModule.js +266 -0
  15. package/lib/internal/web/firebaseApp.js +3 -0
  16. package/lib/internal/web/firebaseAppCheck.js +6 -0
  17. package/lib/internal/web/firebaseAuth.js +4 -0
  18. package/lib/internal/web/firebaseDatabase.js +4 -0
  19. package/lib/internal/web/firebaseFirestore.js +4 -0
  20. package/lib/internal/web/firebaseFunctions.js +4 -0
  21. package/lib/internal/web/firebaseInstallations.js +6 -0
  22. package/lib/internal/web/firebaseRemoteConfig.js +6 -0
  23. package/lib/internal/web/firebaseStorage.js +4 -0
  24. package/lib/internal/web/memidb/FDBCursor.js +503 -0
  25. package/lib/internal/web/memidb/FDBCursorWithValue.js +11 -0
  26. package/lib/internal/web/memidb/FDBDatabase.js +172 -0
  27. package/lib/internal/web/memidb/FDBFactory.js +256 -0
  28. package/lib/internal/web/memidb/FDBIndex.js +187 -0
  29. package/lib/internal/web/memidb/FDBKeyRange.js +71 -0
  30. package/lib/internal/web/memidb/FDBObjectStore.js +411 -0
  31. package/lib/internal/web/memidb/FDBOpenDBRequest.js +9 -0
  32. package/lib/internal/web/memidb/FDBRequest.js +33 -0
  33. package/lib/internal/web/memidb/FDBTransaction.js +216 -0
  34. package/lib/internal/web/memidb/FDBVersionChangeEvent.js +12 -0
  35. package/lib/internal/web/memidb/LICENSE +208 -0
  36. package/lib/internal/web/memidb/index.js +39 -0
  37. package/lib/internal/web/memidb/lib/Database.js +32 -0
  38. package/lib/internal/web/memidb/lib/FakeDOMStringList.js +72 -0
  39. package/lib/internal/web/memidb/lib/FakeEvent.js +38 -0
  40. package/lib/internal/web/memidb/lib/FakeEventTarget.js +110 -0
  41. package/lib/internal/web/memidb/lib/Index.js +157 -0
  42. package/lib/internal/web/memidb/lib/KeyGenerator.js +22 -0
  43. package/lib/internal/web/memidb/lib/ObjectStore.js +172 -0
  44. package/lib/internal/web/memidb/lib/RecordStore.js +141 -0
  45. package/lib/internal/web/memidb/lib/binarySearch.js +78 -0
  46. package/lib/internal/web/memidb/lib/canInjectKey.js +25 -0
  47. package/lib/internal/web/memidb/lib/cmp.js +77 -0
  48. package/lib/internal/web/memidb/lib/enforceRange.js +13 -0
  49. package/lib/internal/web/memidb/lib/errors.js +69 -0
  50. package/lib/internal/web/memidb/lib/extractKey.js +39 -0
  51. package/lib/internal/web/memidb/lib/scheduling.js +30 -0
  52. package/lib/internal/web/memidb/lib/types.js +1 -0
  53. package/lib/internal/web/memidb/lib/validateKeyPath.js +54 -0
  54. package/lib/internal/web/memidb/lib/valueToKey.js +62 -0
  55. package/lib/internal/web/memidb/lib/valueToKeyRange.js +19 -0
  56. package/lib/internal/web/structuredClone/index.js +222 -0
  57. package/lib/internal/web/utils.js +35 -0
  58. package/lib/utils/UtilsStatics.js +3 -2
  59. package/lib/version.js +1 -1
  60. package/package.json +8 -7
package/CHANGELOG.md CHANGED
@@ -3,6 +3,30 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [20.2.1](https://github.com/invertase/react-native-firebase/compare/v20.2.0...v20.2.1) (2024-07-17)
7
+
8
+ **Note:** Version bump only for package @react-native-firebase/app
9
+
10
+ ## [20.2.0](https://github.com/invertase/react-native-firebase/compare/v20.1.0...v20.2.0) (2024-07-15)
11
+
12
+ ### Features
13
+
14
+ - **other:** Add analytics support ([#7899](https://github.com/invertase/react-native-firebase/issues/7899)) ([cbdf9ec](https://github.com/invertase/react-native-firebase/commit/cbdf9ec78452a73751d1afeca428842898f63134))
15
+ - **Other:** add App Check support ([#7905](https://github.com/invertase/react-native-firebase/issues/7905)) ([753b16e](https://github.com/invertase/react-native-firebase/commit/753b16e1a06f949c679fb75053c319394dd5ecfe))
16
+ - **other:** add App/Core support ([1b2e247](https://github.com/invertase/react-native-firebase/commit/1b2e2473d526c3356ab8619b226943446fd49452))
17
+ - **other:** Add Auth support ([#7878](https://github.com/invertase/react-native-firebase/issues/7878)) ([54befe7](https://github.com/invertase/react-native-firebase/commit/54befe776353f07eeab9b044d6261eeb76f1f238))
18
+ - **other:** Add Database support ([#7887](https://github.com/invertase/react-native-firebase/issues/7887)) ([fbb773a](https://github.com/invertase/react-native-firebase/commit/fbb773a87c167bdc92265fe261aeb777d4660cd7))
19
+ - **other:** Add Firestore support ([#7882](https://github.com/invertase/react-native-firebase/issues/7882)) ([0ebd1dd](https://github.com/invertase/react-native-firebase/commit/0ebd1ddd221c50dde489bce30ad5ed64037d8439))
20
+ - **Other:** Add Remote Config support ([#7895](https://github.com/invertase/react-native-firebase/issues/7895)) ([a41e556](https://github.com/invertase/react-native-firebase/commit/a41e5568869320fb91afc01403ed402e5312e15c))
21
+ - **other:** Add Storage support ([#7888](https://github.com/invertase/react-native-firebase/issues/7888)) ([9b8dda7](https://github.com/invertase/react-native-firebase/commit/9b8dda704a01243039624bfcc7614021e6c3a527))
22
+
23
+ ### Bug Fixes
24
+
25
+ - **app, android:** adopt firebase-android-sdk 31.1.1 ([dba1beb](https://github.com/invertase/react-native-firebase/commit/dba1beba97d88d1110e0838b6287fd4907cfa8a7))
26
+ - **app, android:** adopt firebase-android-sdk 33.1.2 ([0dfa2af](https://github.com/invertase/react-native-firebase/commit/0dfa2af484cfd12a282490cb82726b29859e30bf))
27
+ - **app, ios:** firebase-ios-sdk 10.28.0 ([91c626d](https://github.com/invertase/react-native-firebase/commit/91c626d0d32435a6305696fb4084553341d99ca9))
28
+ - **ios:** adopt firebase-ios-sdk 10.29.0 ([1b19cc6](https://github.com/invertase/react-native-firebase/commit/1b19cc697f21ac1e21ab3a7a399c1ef90711800b))
29
+
6
30
  ## [20.1.0](https://github.com/invertase/react-native-firebase/compare/v20.0.0...v20.1.0) (2024-06-04)
7
31
 
8
32
  ### Features
@@ -18,5 +18,5 @@ package io.invertase.firebase.app;
18
18
  */
19
19
  // generated file - do not modify or commit
20
20
  public class ReactNativeFirebaseVersion {
21
- public static String VERSION = "20.1.0";
21
+ public static String VERSION = "20.2.1";
22
22
  }
@@ -18,4 +18,4 @@
18
18
  #import <React/RCTVersion.h>
19
19
 
20
20
  // generated file - do not modify or commit
21
- NSString* const RNFBVersionString = @"20.1.0";
21
+ NSString* const RNFBVersionString = @"20.2.1";
@@ -85,6 +85,8 @@ export const isIOS = Platform.OS === 'ios';
85
85
 
86
86
  export const isAndroid = Platform.OS === 'android';
87
87
 
88
+ export const isOther = Platform.OS !== 'ios' && Platform.OS !== 'android';
89
+
88
90
  export function tryJSONParse(string) {
89
91
  try {
90
92
  return string && JSON.parse(string);
package/lib/index.d.ts CHANGED
@@ -85,6 +85,7 @@ export namespace ReactNativeFirebase {
85
85
  /**
86
86
  * The tracking ID for Google Analytics, e.g. "UA-12345678-1", used to configure Google Analytics.
87
87
  */
88
+ // TODO this should now be measurementId
88
89
  gaTrackingId?: string;
89
90
 
90
91
  /**
@@ -15,24 +15,47 @@
15
15
  *
16
16
  */
17
17
 
18
- import { NativeEventEmitter, NativeModules } from 'react-native';
19
-
20
- const { RNFBAppModule } = NativeModules;
18
+ import { NativeEventEmitter } from 'react-native';
19
+ import { getReactNativeModule } from './nativeModule';
21
20
 
22
21
  class RNFBNativeEventEmitter extends NativeEventEmitter {
23
22
  constructor() {
24
- super(RNFBAppModule);
23
+ super(getReactNativeModule('RNFBAppModule'));
25
24
  this.ready = false;
26
25
  }
27
26
 
28
27
  addListener(eventType, listener, context) {
28
+ const RNFBAppModule = getReactNativeModule('RNFBAppModule');
29
29
  if (!this.ready) {
30
30
  RNFBAppModule.eventsNotifyReady(true);
31
31
  this.ready = true;
32
32
  }
33
33
  RNFBAppModule.eventsAddListener(eventType);
34
+ if (global.RNFBDebug) {
35
+ // eslint-disable-next-line no-console
36
+ console.debug(`[RNFB-->Event][👂] ${eventType} -> listening`);
37
+ }
38
+ const listenerDebugger = (...args) => {
39
+ if (global.RNFBDebug) {
40
+ // eslint-disable-next-line no-console
41
+ console.debug(`[RNFB<--Event][📣] ${eventType} <-`, JSON.stringify(args[0]));
42
+ // Possible leaking test if events are still being received after the test.
43
+ // This is not super accurate but it's better than nothing, e.g. if doing setup/teardown
44
+ // logic outside of a test this may cause false positives.
45
+ if (global.RNFBTest && !global.RNFBDebugInTestLeakDetection) {
46
+ // eslint-disable-next-line no-console
47
+ console.debug(
48
+ `[TEST--->Leak][💡] Possible leaking test detected! An event (☝️) ` +
49
+ `was received outside of any running tests which may indicates that some ` +
50
+ `listeners/event subscriptions that have not been unsubscribed from in your ` +
51
+ `test code. The last test that ran was: "${global.RNFBDebugLastTest}".`,
52
+ );
53
+ }
54
+ }
55
+ return listener(...args);
56
+ };
34
57
 
35
- let subscription = super.addListener(`rnfb_${eventType}`, listener, context);
58
+ let subscription = super.addListener(`rnfb_${eventType}`, listenerDebugger, context);
36
59
 
37
60
  // React Native 0.65+ altered EventEmitter:
38
61
  // - removeSubscription is gone
@@ -41,7 +64,7 @@ class RNFBNativeEventEmitter extends NativeEventEmitter {
41
64
  // make sure eventType for backwards compatibility just in case
42
65
  subscription.eventType = `rnfb_${eventType}`;
43
66
 
44
- // New style is to return a remove function on the object, just in csae people call that,
67
+ // New style is to return a remove function on the object, just in case people call that,
45
68
  // we will modify it to do our native unsubscription then call the original
46
69
  let originalRemove = subscription.remove;
47
70
  let newRemove = () => {
@@ -59,12 +82,14 @@ class RNFBNativeEventEmitter extends NativeEventEmitter {
59
82
  }
60
83
 
61
84
  removeAllListeners(eventType) {
85
+ const RNFBAppModule = getReactNativeModule('RNFBAppModule');
62
86
  RNFBAppModule.eventsRemoveListener(eventType, true);
63
87
  super.removeAllListeners(`rnfb_${eventType}`);
64
88
  }
65
89
 
66
90
  // This is likely no longer ever called, but it is here for backwards compatibility with RN <= 0.64
67
91
  removeSubscription(subscription) {
92
+ const RNFBAppModule = getReactNativeModule('RNFBAppModule');
68
93
  RNFBAppModule.eventsRemoveListener(subscription.eventType.replace('rnfb_'), false);
69
94
  if (super.removeSubscription) {
70
95
  super.removeSubscription(subscription);
@@ -0,0 +1,2 @@
1
+ export { getReactNativeModule } from './nativeModuleAndroidIos';
2
+ export { setReactNativeModule } from './nativeModuleAndroidIos';
@@ -0,0 +1,2 @@
1
+ export { getReactNativeModule } from './nativeModuleAndroidIos';
2
+ export { setReactNativeModule } from './nativeModuleAndroidIos';
@@ -0,0 +1,4 @@
1
+ // This is fallback for when the platform is not with native SDKs.
2
+ // In this case we use the web Firebase JS SDK.
3
+ export { getReactNativeModule } from './nativeModuleWeb';
4
+ export { setReactNativeModule } from './nativeModuleWeb';
@@ -0,0 +1,45 @@
1
+ /* eslint-disable no-console */
2
+ import { NativeModules } from 'react-native';
3
+
4
+ /**
5
+ * This is used by Android and iOS to get a native module.
6
+ * We additionally add a Proxy to the module to intercept calls
7
+ * and log them to the console for debugging purposes, if enabled.
8
+ * @param moduleName
9
+ */
10
+ export function getReactNativeModule(moduleName) {
11
+ const nativeModule = NativeModules[moduleName];
12
+ if (!global.RNFBDebug) {
13
+ return nativeModule;
14
+ }
15
+ return new Proxy(nativeModule, {
16
+ ownKeys(target) {
17
+ return Object.keys(target);
18
+ },
19
+ get: (_, name) => {
20
+ if (typeof nativeModule[name] !== 'function') return nativeModule[name];
21
+ return (...args) => {
22
+ console.debug(`[RNFB->Native][🔵] ${moduleName}.${name} -> ${JSON.stringify(args)}`);
23
+ const result = nativeModule[name](...args);
24
+ if (result && result.then) {
25
+ return result.then(
26
+ res => {
27
+ console.debug(`[RNFB<-Native][🟢] ${moduleName}.${name} <- ${JSON.stringify(res)}`);
28
+ return res;
29
+ },
30
+ err => {
31
+ console.debug(`[RNFB<-Native][🔴] ${moduleName}.${name} <- ${JSON.stringify(err)}`);
32
+ throw err;
33
+ },
34
+ );
35
+ }
36
+ console.debug(`[RNFB<-Native][🟢] ${moduleName}.${name} <- ${JSON.stringify(result)}`);
37
+ return result;
38
+ };
39
+ },
40
+ });
41
+ }
42
+
43
+ export function setReactNativeModule() {
44
+ // No-op
45
+ }
@@ -0,0 +1,48 @@
1
+ /* eslint-disable no-console */
2
+
3
+ import RNFBAppModule from './web/RNFBAppModule';
4
+
5
+ const nativeModuleRegistry = {};
6
+
7
+ export function getReactNativeModule(moduleName) {
8
+ const nativeModule = nativeModuleRegistry[moduleName];
9
+ // Throw an error if the module is not registered.
10
+ if (!nativeModule) {
11
+ throw new Error(`Native module ${moduleName} is not registered.`);
12
+ }
13
+ if (!global.RNFBDebug) {
14
+ return nativeModule;
15
+ }
16
+ return new Proxy(nativeModule, {
17
+ ownKeys(target) {
18
+ return Object.keys(target);
19
+ },
20
+ get: (_, name) => {
21
+ if (typeof nativeModule[name] !== 'function') return nativeModule[name];
22
+ return (...args) => {
23
+ console.debug(`[RNFB->Native][🔵] ${moduleName}.${name} -> ${JSON.stringify(args)}`);
24
+ const result = nativeModule[name](...args);
25
+ if (result && result.then) {
26
+ return result.then(
27
+ res => {
28
+ console.debug(`[RNFB<-Native][🟢] ${moduleName}.${name} <- ${JSON.stringify(res)}`);
29
+ return res;
30
+ },
31
+ err => {
32
+ console.debug(`[RNFB<-Native][🔴] ${moduleName}.${name} <- ${JSON.stringify(err)}`);
33
+ throw err;
34
+ },
35
+ );
36
+ }
37
+ console.debug(`[RNFB<-Native][🟢] ${moduleName}.${name} <- ${JSON.stringify(result)}`);
38
+ return result;
39
+ };
40
+ },
41
+ });
42
+ }
43
+
44
+ export function setReactNativeModule(moduleName, nativeModule) {
45
+ nativeModuleRegistry[moduleName] = nativeModule;
46
+ }
47
+
48
+ setReactNativeModule('RNFBAppModule', RNFBAppModule);
@@ -17,6 +17,7 @@
17
17
 
18
18
  import {
19
19
  isIOS,
20
+ isOther,
20
21
  isNull,
21
22
  isObject,
22
23
  isString,
@@ -201,7 +202,7 @@ export function setLogLevel(logLevel) {
201
202
  throw new Error('LogLevel must be one of "error", "warn", "info", "debug", "verbose"');
202
203
  }
203
204
 
204
- if (isIOS) {
205
+ if (isIOS || isOther) {
205
206
  getAppModule().setLogLevel(logLevel);
206
207
  }
207
208
  }
@@ -15,11 +15,12 @@
15
15
  *
16
16
  */
17
17
 
18
- import { NativeModules, Platform } from 'react-native';
19
18
  import { APP_NATIVE_MODULE } from '../constants';
20
19
  import NativeFirebaseError from '../NativeFirebaseError';
21
20
  import RNFBNativeEventEmitter from '../RNFBNativeEventEmitter';
22
21
  import SharedEventEmitter from '../SharedEventEmitter';
22
+ import { getReactNativeModule } from '../nativeModule';
23
+ import { isAndroid, isIOS } from '../../common';
23
24
 
24
25
  const NATIVE_MODULE_REGISTRY = {};
25
26
  const NATIVE_MODULE_EVENT_SUBSCRIPTIONS = {};
@@ -102,7 +103,7 @@ function initialiseNativeModule(module) {
102
103
  const nativeModuleNames = multiModule ? nativeModuleName : [nativeModuleName];
103
104
 
104
105
  for (let i = 0; i < nativeModuleNames.length; i++) {
105
- const nativeModule = NativeModules[nativeModuleNames[i]];
106
+ const nativeModule = getReactNativeModule(nativeModuleNames[i]);
106
107
 
107
108
  // only error if there's a single native module
108
109
  // as multi modules can mean some are optional
@@ -173,24 +174,19 @@ function subscribeToNativeModuleEvent(eventName) {
173
174
  */
174
175
  function getMissingModuleHelpText(namespace) {
175
176
  const snippet = `firebase.${namespace}()`;
176
- const nativeModule = namespace.charAt(0).toUpperCase() + namespace.slice(1);
177
177
 
178
- if (Platform.OS === 'ios') {
178
+ if (isIOS || isAndroid) {
179
179
  return (
180
- `You attempted to use a firebase module that's not installed natively on your iOS project by calling ${snippet}.` +
181
- '\r\n\r\nEnsure you have either linked the module or added it to your projects Podfile.' +
182
- '\r\n\r\nSee http://invertase.link/ios for full setup instructions.'
180
+ `You attempted to use a Firebase module that's not installed natively on your project by calling ${snippet}.` +
181
+ `\r\n\r\nEnsure you have installed the npm package '@react-native-firebase/${namespace}',` +
182
+ ' have imported it in your project, and have rebuilt your native application.'
183
183
  );
184
184
  }
185
185
 
186
- const rnFirebasePackage = `'io.invertase.firebase.${namespace}.ReactNativeFirebase${nativeModule}Package'`;
187
- const newInstance = `'new ReactNativeFirebase${nativeModule}Package()'`;
188
-
189
186
  return (
190
- `You attempted to use a firebase module that's not installed on your Android project by calling ${snippet}.` +
191
- `\r\n\r\nEnsure you have:\r\n\r\n1) imported the ${rnFirebasePackage} module in your 'MainApplication.java' file.\r\n\r\n2) Added the ` +
192
- `${newInstance} line inside of the RN 'getPackages()' method list.` +
193
- '\r\n\r\nSee http://invertase.link/android for full setup instructions.'
187
+ `You attempted to use a Firebase module that's not installed on your project by calling ${snippet}.` +
188
+ `\r\n\r\nEnsure you have installed the npm package '@react-native-firebase/${namespace}' and` +
189
+ ' have imported it in your project.'
194
190
  );
195
191
  }
196
192
 
@@ -222,7 +218,7 @@ export function getAppModule() {
222
218
  }
223
219
 
224
220
  const namespace = 'app';
225
- const nativeModule = NativeModules[APP_NATIVE_MODULE];
221
+ const nativeModule = getReactNativeModule(APP_NATIVE_MODULE);
226
222
 
227
223
  if (!nativeModule) {
228
224
  throw new Error(getMissingModuleHelpText(namespace));
@@ -0,0 +1,266 @@
1
+ /* eslint-disable no-console */
2
+ import { initializeApp, setLogLevel, getApp, getApps, deleteApp } from './firebaseApp';
3
+
4
+ import { DeviceEventEmitter } from 'react-native';
5
+
6
+ // Variables for events tracking.
7
+ let jsReady = false;
8
+ let jsListenerCount = 0;
9
+ let queuedEvents = [];
10
+ let jsListeners = {};
11
+
12
+ // For compatibility we have a fake preferences storage,
13
+ // it does not persist across app restarts.
14
+ let fakePreferencesStorage = {};
15
+
16
+ function eventsGetListenersMap() {
17
+ return {
18
+ listeners: jsListenerCount,
19
+ queued: queuedEvents.length,
20
+ events: jsListeners,
21
+ };
22
+ }
23
+
24
+ function eventsSendEvent(eventName, eventBody) {
25
+ if (!jsReady || !jsListeners.hasOwnProperty(eventName)) {
26
+ const event = {
27
+ eventName,
28
+ eventBody,
29
+ };
30
+ queuedEvents.push(event);
31
+ return;
32
+ }
33
+ setImmediate(() => DeviceEventEmitter.emit('rnfb_' + eventName, eventBody));
34
+ }
35
+
36
+ function eventsSendQueuedEvents() {
37
+ if (queuedEvents.length === 0) {
38
+ return;
39
+ }
40
+ const events = Array.from(queuedEvents);
41
+ queuedEvents = [];
42
+ for (let i = 0; i < events.length; i++) {
43
+ const event = events[i];
44
+ eventsSendEvent(event.eventName, event.eventBody);
45
+ }
46
+ }
47
+
48
+ export default {
49
+ // Natively initialized apps, but in the case of web, we don't have any.
50
+ NATIVE_FIREBASE_APPS: [],
51
+ // The raw JSON string of the Firebase config, from the users firebase.json file.
52
+ // In the case of web, we can't support this.
53
+ FIREBASE_RAW_JSON: '{}',
54
+
55
+ /**
56
+ * Initializes a Firebase app.
57
+ *
58
+ * @param {object} options - The Firebase app options.
59
+ * @param {object} appConfig - The Firebase app config.
60
+ * @returns {object} - The Firebase app instance.
61
+ */
62
+ async initializeApp(options, appConfig) {
63
+ const name = appConfig.name;
64
+ const existingApp = getApps().find(app => app.name === name);
65
+ if (existingApp) {
66
+ return existingApp;
67
+ }
68
+ const newAppConfig = {
69
+ name,
70
+ };
71
+ if (
72
+ appConfig.automaticDataCollectionEnabled === true ||
73
+ appConfig.automaticDataCollectionEnabled === false
74
+ ) {
75
+ newAppConfig.automaticDataCollectionEnabled = appConfig.automaticDataCollectionEnabled;
76
+ }
77
+ const optionsCopy = Object.assign({}, options);
78
+ // TODO RNFB is using the old gaTrackingId property, we should remove this in the future
79
+ // in favor of the measurementId property.
80
+ if (optionsCopy.gaTrackingId) {
81
+ optionsCopy.measurementId = optionsCopy.gaTrackingId;
82
+ }
83
+ delete optionsCopy.clientId;
84
+ initializeApp(optionsCopy, newAppConfig);
85
+ return {
86
+ options,
87
+ appConfig,
88
+ };
89
+ },
90
+
91
+ /**
92
+ * Sets the log level for the Firebase app.
93
+ *
94
+ * @param {string} logLevel - The log level to set.
95
+ */
96
+ setLogLevel(logLevel) {
97
+ setLogLevel(logLevel);
98
+ },
99
+
100
+ /**
101
+ * Sets the automatic data collection for the Firebase app.
102
+ *
103
+ * @param {string} appName - The name of the Firebase app.
104
+ * @param {boolean} enabled - Whether to enable automatic data collection.
105
+ */
106
+ setAutomaticDataCollectionEnabled(appName, enabled) {
107
+ getApp(appName).automaticDataCollectionEnabled = enabled;
108
+ },
109
+
110
+ /**
111
+ * Deletes a Firebase app.
112
+ *
113
+ * @param {string} appName - The name of the Firebase app to delete.
114
+ */
115
+ async deleteApp(appName) {
116
+ if (getApp(appName)) {
117
+ deleteApp(appName);
118
+ }
119
+ },
120
+
121
+ /**
122
+ * Gets the meta data.
123
+ * Unsupported on web.
124
+ *
125
+ * @returns {object} - The meta data
126
+ */
127
+ metaGetAll() {
128
+ return {};
129
+ },
130
+
131
+ /**
132
+ * Gets the firebase.json data.
133
+ * Unsupported on web.
134
+ *
135
+ * @returns {object} - The JSON data for the firebase.json file.
136
+ */
137
+ jsonGetAll() {
138
+ return {};
139
+ },
140
+
141
+ /**
142
+ * Sets a boolean value for a preference.
143
+ * Unsupported on web.
144
+ *
145
+ * @param {string} key - The key of the preference.
146
+ * @param {boolean} value - The value to set.
147
+ */
148
+ async preferencesSetBool(key, value) {
149
+ fakePreferencesStorage[key] = value;
150
+ },
151
+
152
+ /**
153
+ * Sets a string value for a preference.
154
+ * Unsupported on web.
155
+ *
156
+ * @param {string} key - The key of the preference.
157
+ * @param {string} value - The value to set.
158
+ */
159
+ preferencesSetString(key, value) {
160
+ fakePreferencesStorage[key] = value;
161
+ },
162
+
163
+ /**
164
+ * Gets all preferences.
165
+ * Unsupported on web.
166
+ *
167
+ * @returns {object} - The preferences.
168
+ */
169
+ preferencesGetAll() {
170
+ return Object.assign({}, fakePreferencesStorage);
171
+ },
172
+
173
+ /**
174
+ * Clears all preferences.
175
+ * Unsupported on web.
176
+ */
177
+ preferencesClearAll() {
178
+ fakePreferencesStorage = {};
179
+ },
180
+
181
+ /**
182
+ * Adds a listener for an event.
183
+ * Unsupported on web.
184
+ *
185
+ * @param {string} eventName - The name of the event to listen for.
186
+ */
187
+ addListener() {
188
+ // Keep: Required for RN built in Event Emitter Calls.
189
+ },
190
+ /**
191
+ * Removes a listener for an event.
192
+ * Unsupported on web.
193
+ *
194
+ * @param {string} eventName - The name of the event to remove the listener for.
195
+ */
196
+ removeListeners() {
197
+ // Keep: Required for RN built in Event Emitter Calls.
198
+ },
199
+
200
+ /**
201
+ * Notifies the app that it is ready to receive events.
202
+ *
203
+ * @param {boolean} ready - Whether the app is ready to receive events.
204
+ * @returns {void}
205
+ */
206
+ eventsNotifyReady(ready) {
207
+ jsReady = ready;
208
+ if (jsReady) {
209
+ setImmediate(() => eventsSendQueuedEvents());
210
+ }
211
+ },
212
+
213
+ /**
214
+ * Gets all the listeners registered.
215
+ *
216
+ * @returns {object} - The listeners for the event.
217
+ */
218
+ eventsGetListeners() {
219
+ return eventsGetListenersMap();
220
+ },
221
+
222
+ /**
223
+ * Sends an event to the app for testing purposes.
224
+ *
225
+ * @param {string} eventName - The name of the event to send.
226
+ * @param {object} eventBody - The body of the event to send.
227
+ * @returns {void}
228
+ */
229
+ eventsPing(eventName, eventBody) {
230
+ eventsSendEvent(eventName, eventBody);
231
+ },
232
+
233
+ /**
234
+ * Adds a listener for an event.
235
+ *
236
+ * @param {string} eventName - The name of the event to listen for.
237
+ */
238
+ eventsAddListener(eventName) {
239
+ jsListenerCount++;
240
+ if (!jsListeners.hasOwnProperty(eventName)) {
241
+ jsListeners[eventName] = 1;
242
+ } else {
243
+ jsListeners[eventName]++;
244
+ }
245
+ setImmediate(() => eventsSendQueuedEvents());
246
+ },
247
+
248
+ /**
249
+ * Removes a single listener for an event or all listeners for an event.
250
+ *
251
+ * @param {string} eventName - The name of the event to remove the listener for.
252
+ * @param {boolean} all - Optional. Whether to remove all listeners for the event.
253
+ */
254
+ eventsRemoveListener(eventName, all) {
255
+ if (jsListeners.hasOwnProperty(eventName)) {
256
+ if (jsListeners[eventName] <= 1 || all) {
257
+ const count = jsListeners[eventName];
258
+ jsListenerCount -= count;
259
+ delete jsListeners[eventName];
260
+ } else {
261
+ jsListenerCount--;
262
+ jsListeners[eventName]--;
263
+ }
264
+ }
265
+ },
266
+ };
@@ -0,0 +1,3 @@
1
+ // We need to share firebase imports between modules, otherwise
2
+ // apps and instances of the firebase modules are not shared.
3
+ export * from 'firebase/app';
@@ -0,0 +1,6 @@
1
+ // We need to share firebase imports between modules, otherwise
2
+ // apps and instances of the firebase modules are not shared.
3
+ import 'firebase/app';
4
+ export { getApp } from 'firebase/app';
5
+ export * from 'firebase/app-check';
6
+ export { makeIDBAvailable } from './memidb';
@@ -0,0 +1,4 @@
1
+ // We need to share firebase imports between modules, otherwise
2
+ // apps and instances of the firebase modules are not shared.
3
+ export * from 'firebase/app';
4
+ export * from 'firebase/auth';
@@ -0,0 +1,4 @@
1
+ // We need to share firebase imports between modules, otherwise
2
+ // apps and instances of the firebase modules are not shared.
3
+ export * from 'firebase/app';
4
+ export * from 'firebase/database';
@@ -0,0 +1,4 @@
1
+ // We need to share firebase imports between modules, otherwise
2
+ // apps and instances of the firebase modules are not shared.
3
+ export { getApp } from 'firebase/app';
4
+ export * from 'firebase/firestore/lite';
@@ -0,0 +1,4 @@
1
+ // We need to share firebase imports between modules, otherwise
2
+ // apps and instances of the firebase modules are not shared.
3
+ export * from 'firebase/app';
4
+ export * from 'firebase/functions';
@@ -0,0 +1,6 @@
1
+ // We need to share firebase imports between modules, otherwise
2
+ // apps and instances of the firebase modules are not shared.
3
+ import 'firebase/app';
4
+ export { getApp } from 'firebase/app';
5
+ export * from 'firebase/installations';
6
+ export { makeIDBAvailable } from './memidb';
@@ -0,0 +1,6 @@
1
+ // We need to share firebase imports between modules, otherwise
2
+ // apps and instances of the firebase modules are not shared.
3
+ import 'firebase/app';
4
+ export { getApp } from 'firebase/app';
5
+ export * from 'firebase/remote-config';
6
+ export { makeIDBAvailable } from './memidb';
@@ -0,0 +1,4 @@
1
+ // We need to share firebase imports between modules, otherwise
2
+ // apps and instances of the firebase modules are not shared.
3
+ export * from 'firebase/app';
4
+ export * from 'firebase/storage';