web-manager 4.1.5 → 4.1.7

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/dist/index.js CHANGED
@@ -281,6 +281,9 @@ class Manager {
281
281
  autoRequest: 1000 * 60
282
282
  }
283
283
  },
284
+ env: {
285
+ FIREBASE_EMULATOR_CONNECT: false,
286
+ },
284
287
  validRedirectHosts: [],
285
288
 
286
289
  // Non-configurable defaults
@@ -27,7 +27,7 @@ class Firestore {
27
27
 
28
28
  // Dynamically import Firestore
29
29
  const { getFirestore, doc: firestoreDoc, collection: firestoreCollection, getDoc, setDoc, updateDoc, deleteDoc, getDocs, query, where, orderBy, limit, startAt, endAt } = await import('firebase/firestore');
30
-
30
+
31
31
  // Store references for later use
32
32
  this._firestoreMethods = {
33
33
  getFirestore,
@@ -48,6 +48,15 @@ class Firestore {
48
48
 
49
49
  // Initialize Firestore
50
50
  this._db = getFirestore(this.manager._firebaseApp);
51
+
52
+ // Connect to Firestore emulator in development
53
+ if (this.manager.isDevelopment() && this.manager.config.env?.FIREBASE_EMULATOR_CONNECT) {
54
+ console.log('[Firestore] Connecting to emulator at localhost:8080');
55
+ const { connectFirestoreEmulator } = await import('firebase/firestore');
56
+ connectFirestoreEmulator(this._db, 'localhost', 8080);
57
+ console.log('[Firestore] Emulator connected');
58
+ }
59
+
51
60
  this._initialized = true;
52
61
 
53
62
  return this._db;
@@ -78,7 +87,7 @@ class Firestore {
78
87
  await self._ensureInitialized();
79
88
  const docRef = self._firestoreMethods.doc(self._db, docPath);
80
89
  const docSnap = await self._firestoreMethods.getDoc(docRef);
81
-
90
+
82
91
  return {
83
92
  exists: () => docSnap.exists(),
84
93
  data: () => docSnap.data(),
@@ -110,13 +119,13 @@ class Firestore {
110
119
  // Collection method for queries
111
120
  collection(collectionPath) {
112
121
  const self = this;
113
-
122
+
114
123
  return {
115
124
  async get() {
116
125
  await self._ensureInitialized();
117
126
  const collRef = self._firestoreMethods.collection(self._db, collectionPath);
118
127
  const querySnapshot = await self._firestoreMethods.getDocs(collRef);
119
-
128
+
120
129
  return {
121
130
  docs: querySnapshot.docs.map(doc => ({
122
131
  id: doc.id,
@@ -185,7 +194,7 @@ class Firestore {
185
194
  async get() {
186
195
  await self._ensureInitialized();
187
196
  const collRef = self._firestoreMethods.collection(self._db, collectionPath);
188
-
197
+
189
198
  // Build query constraints
190
199
  const queryConstraints = [];
191
200
  for (const constraint of constraints) {
@@ -210,7 +219,7 @@ class Firestore {
210
219
 
211
220
  const q = self._firestoreMethods.query(collRef, ...queryConstraints);
212
221
  const querySnapshot = await self._firestoreMethods.getDocs(q);
213
-
222
+
214
223
  return {
215
224
  docs: querySnapshot.docs.map(doc => ({
216
225
  id: doc.id,
@@ -239,4 +248,4 @@ class Firestore {
239
248
  }
240
249
  }
241
250
 
242
- export default Firestore;
251
+ export default Firestore;
@@ -256,6 +256,7 @@ class Notifications {
256
256
  try {
257
257
  const firestore = this.manager.firestore();
258
258
  const user = this.manager.auth().getUser();
259
+ const storage = this.manager.storage();
259
260
 
260
261
  if (!token) {
261
262
  return;
@@ -300,7 +301,7 @@ class Notifications {
300
301
  ...baseData,
301
302
  token,
302
303
  tags: ['general'],
303
- // TODO: add attribution data on create
304
+ attribution: storage.get('attribution', {}),
304
305
  created: {
305
306
  timestamp,
306
307
  timestampUNIX
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-manager",
3
- "version": "4.1.5",
3
+ "version": "4.1.7",
4
4
  "description": "Easily access important variables such as the query string, current domain, and current page in a single object.",
5
5
  "main": "dist/index.js",
6
6
  "module": "src/index.js",