@umituz/react-native-firebase 3.0.2 → 3.0.3
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-firebase",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.3",
|
|
4
4
|
"description": "Unified Firebase package for React Native apps - Auth and Firestore services using Firebase JS SDK (no native modules).",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -30,9 +30,12 @@ export * from './domain';
|
|
|
30
30
|
// localCache: getReactNativePersistence(AsyncStorage)
|
|
31
31
|
// });
|
|
32
32
|
|
|
33
|
-
// Firestore type (any to avoid conflicts)
|
|
33
|
+
// Re-export Firestore type (any to avoid conflicts)
|
|
34
34
|
export type { Firestore } from './infrastructure/config/FirestoreClient';
|
|
35
35
|
|
|
36
|
+
// Re-export getFirestore for convenience (imports from Firebase SDK)
|
|
37
|
+
export { getFirestore } from 'firebase/firestore';
|
|
38
|
+
|
|
36
39
|
// Repositories
|
|
37
40
|
export { BaseRepository } from './infrastructure/repositories/BaseRepository';
|
|
38
41
|
export type { IPathResolver } from './infrastructure/repositories/BaseRepository';
|
|
@@ -19,6 +19,42 @@
|
|
|
19
19
|
* - Type definitions (import from 'firebase/firestore' in your app)
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
+
import { getFirebaseApp } from '../../../../shared/infrastructure/config/services/FirebaseInitializationService';
|
|
23
|
+
|
|
22
24
|
// Firestore type - use 'any' to avoid type conflicts with Firebase SDK
|
|
23
25
|
// The actual type checking happens in your app when you import from firebase/firestore
|
|
24
26
|
export type Firestore = any;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Get Firestore instance
|
|
30
|
+
* Returns null if Firebase app is not initialized
|
|
31
|
+
*
|
|
32
|
+
* This is a convenience wrapper that gets the Firebase app and returns
|
|
33
|
+
* a Firestore instance. For type safety, import Firestore from 'firebase/firestore'
|
|
34
|
+
* in your app.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* import { getDb } from '@umituz/react-native-firebase/firestore';
|
|
39
|
+
* import type { Firestore } from 'firebase/firestore';
|
|
40
|
+
*
|
|
41
|
+
* const db = getDb() as Firestore | null;
|
|
42
|
+
* if (db) {
|
|
43
|
+
* // Use db with Firebase SDK functions
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export function getFirestore(): Firestore | null {
|
|
48
|
+
const app = getFirebaseApp();
|
|
49
|
+
if (!app) return null;
|
|
50
|
+
|
|
51
|
+
// Import getFirestore from Firebase SDK dynamically
|
|
52
|
+
// This avoids the idb dependency during bundling
|
|
53
|
+
try {
|
|
54
|
+
const firebaseFirestore = require('firebase/firestore');
|
|
55
|
+
return firebaseFirestore.getFirestore(app);
|
|
56
|
+
} catch (error) {
|
|
57
|
+
console.warn('[Firestore] Failed to get Firestore instance:', error);
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
}
|