@umituz/react-native-firebase 3.0.13 → 3.0.15

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@umituz/react-native-firebase",
3
- "version": "3.0.13",
4
- "description": "Firebase package for React Native mobile apps - Auth and Firestore services using Firebase JS SDK. No web or Node.js support. Memory-only caching (no IndexedDB).",
3
+ "version": "3.0.15",
4
+ "description": "Firebase package for React Native mobile apps - Auth and Firestore services.",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
7
7
  "scripts": {
@@ -1,65 +1,17 @@
1
1
  /**
2
2
  * Firebase Firestore Initializer for React Native
3
3
  *
4
- * Single Responsibility: Initialize Firestore instance with memory caching
5
- *
6
- * IMPORTANT: This package is designed for React Native mobile applications ONLY.
7
- * - No web support
8
- * - No Node.js support
9
- * - No IndexedDB (idb package) support
10
- * - Memory-only caching for optimal performance
11
- *
12
- * React Native does not support IndexedDB, so we use Firebase's memory cache.
4
+ * Simple initialization for Firestore in React Native apps.
13
5
  */
14
6
 
15
- import {
16
- getFirestore,
17
- initializeFirestore,
18
- memoryLocalCache,
19
- } from 'firebase/firestore';
7
+ import { getFirestore, initializeFirestore } from 'firebase/firestore';
20
8
  import type { Firestore } from 'firebase/firestore';
21
9
  import type { FirebaseApp } from 'firebase/app';
22
10
 
23
11
  /**
24
- * Firestore configuration options for React Native
25
- */
26
- export interface FirestoreConfig {
27
- /** Custom settings to pass to Firestore */
28
- settings?: {
29
- cacheSizeBytes?: number;
30
- ignoreUndefinedProperties?: boolean;
31
- };
32
- }
33
-
34
- /**
35
- * Default configuration for React Native
36
- */
37
- const DEFAULT_CONFIG: Required<FirestoreConfig> = {
38
- settings: {
39
- cacheSizeBytes: 10 * 1024 * 1024, // 10 MB
40
- ignoreUndefinedProperties: true,
41
- },
42
- };
43
-
44
- /**
45
- * Creates memory cache configuration for React Native
46
- *
47
- * React Native uses memory cache because:
48
- * 1. IndexedDB is not supported in React Native
49
- * 2. The idb package causes import errors in React Native
50
- * 3. Memory cache is sufficient for mobile app use cases
51
- */
52
- function createMemoryCacheConfig() {
53
- return {
54
- localCache: memoryLocalCache(),
55
- };
56
- }
57
-
58
- /**
59
- * Initializes Firestore for React Native with memory caching
12
+ * Initializes Firestore for React Native
60
13
  *
61
14
  * @param app - Firebase app instance
62
- * @param config - Optional configuration
63
15
  * @returns Firestore instance
64
16
  *
65
17
  * @example
@@ -73,69 +25,17 @@ function createMemoryCacheConfig() {
73
25
  */
74
26
  export class FirebaseFirestoreInitializer {
75
27
  /**
76
- * Initialize Firestore with memory cache for React Native
77
- *
78
- * This is the recommended way to initialize Firestore in React Native apps.
79
- * Uses memory cache to avoid idb package import errors.
28
+ * Initialize Firestore
80
29
  */
81
- static initialize(
82
- app: FirebaseApp,
83
- config: FirestoreConfig = {}
84
- ): Firestore {
85
- const finalConfig = { ...DEFAULT_CONFIG, ...config };
86
-
30
+ static initialize(app: FirebaseApp): Firestore {
87
31
  try {
88
- // Initialize Firestore with memory cache
89
- const settings = createMemoryCacheConfig();
90
- return initializeFirestore(app, settings);
32
+ return initializeFirestore(app, {});
91
33
  } catch (error) {
92
34
  // If initialization fails, get existing instance
93
- // This handles cases where Firestore is already initialized
94
35
  if (__DEV__) {
95
- console.warn('[Firestore] Initialization using existing instance:', error);
36
+ console.warn('[Firestore] Using existing instance:', error);
96
37
  }
97
38
  return getFirestore(app);
98
39
  }
99
40
  }
100
-
101
- /**
102
- * Clear Firestore cache
103
- * Useful for logout or data reset scenarios
104
- *
105
- * NOTE: With memory cache, this clears in-memory cached data
106
- */
107
- static async clearCache(app: FirebaseApp): Promise<void> {
108
- try {
109
- const db = getFirestore(app);
110
- // clearPersistentCache may exist in some Firebase SDK versions
111
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
112
- if (typeof (db as any).clearPersistentCache === 'function') {
113
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
114
- await (db as any).clearPersistentCache();
115
- if (__DEV__) {
116
- console.log('[Firestore] Cache cleared successfully');
117
- }
118
- } else {
119
- if (__DEV__) {
120
- console.log('[Firestore] Memory cache does not support explicit clearing');
121
- }
122
- }
123
- } catch (error) {
124
- if (__DEV__) {
125
- console.warn('[Firestore] Cache clearing failed:', error);
126
- }
127
- // Don't throw - cache clearing is not critical
128
- }
129
- }
130
- }
131
-
132
- /**
133
- * Get current Firestore instance
134
- * Shortcut for getFirestore from Firebase SDK
135
- *
136
- * @param app - Firebase app instance
137
- * @returns Firestore instance
138
- */
139
- export function getFirestoreInstance(app: FirebaseApp): Firestore {
140
- return getFirestore(app);
141
41
  }