@firebase/firestore-compat 0.4.0-20230301000120 → 0.4.0-20250715195345

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.
Files changed (85) hide show
  1. package/dist/index.cjs.js +980 -972
  2. package/dist/index.cjs.js.map +1 -1
  3. package/dist/{index.esm2017.js → index.esm.js} +981 -973
  4. package/dist/index.esm.js.map +1 -0
  5. package/dist/index.node.cjs.js +980 -972
  6. package/dist/index.node.cjs.js.map +1 -1
  7. package/dist/index.rn.js +980 -972
  8. package/dist/index.rn.js.map +1 -1
  9. package/dist/node-esm/index.node.esm.js +980 -972
  10. package/dist/node-esm/index.node.esm.js.map +1 -1
  11. package/dist/node-esm/src/api/blob.d.ts +29 -29
  12. package/dist/node-esm/src/api/database.d.ts +228 -228
  13. package/dist/node-esm/src/api/field_path.d.ts +36 -36
  14. package/dist/node-esm/src/api/field_value.d.ts +29 -29
  15. package/dist/node-esm/src/api/geo_point.d.ts +17 -17
  16. package/dist/node-esm/src/api/observer.d.ts +29 -29
  17. package/dist/node-esm/src/api/timestamp.d.ts +17 -17
  18. package/dist/node-esm/src/config.d.ts +28 -28
  19. package/dist/node-esm/src/index.console.d.ts +48 -48
  20. package/dist/node-esm/src/index.d.ts +49 -49
  21. package/dist/node-esm/src/index.node.d.ts +22 -22
  22. package/dist/node-esm/src/index.rn.d.ts +22 -22
  23. package/dist/node-esm/src/register-module.d.ts +42 -42
  24. package/dist/node-esm/src/util/input_validation.d.ts +18 -18
  25. package/dist/node-esm/test/array_transforms.test.d.ts +17 -17
  26. package/dist/node-esm/test/batch_writes.test.d.ts +17 -17
  27. package/dist/node-esm/test/bootstrap.d.ts +17 -17
  28. package/dist/node-esm/test/bundle.test.d.ts +17 -17
  29. package/dist/node-esm/test/cursor.test.d.ts +17 -17
  30. package/dist/node-esm/test/database.test.d.ts +17 -17
  31. package/dist/node-esm/test/fields.test.d.ts +17 -17
  32. package/dist/node-esm/test/get_options.test.d.ts +17 -17
  33. package/dist/node-esm/test/numeric_transforms.test.d.ts +17 -17
  34. package/dist/node-esm/test/query.test.d.ts +17 -17
  35. package/dist/node-esm/test/server_timestamp.test.d.ts +17 -17
  36. package/dist/node-esm/test/smoke.test.d.ts +17 -17
  37. package/dist/node-esm/test/transactions.test.d.ts +17 -17
  38. package/dist/node-esm/test/type.test.d.ts +17 -17
  39. package/dist/node-esm/test/util/equality_matcher.d.ts +33 -33
  40. package/dist/node-esm/test/util/events_accumulator.d.ts +39 -39
  41. package/dist/node-esm/test/util/firebase_export.d.ts +29 -29
  42. package/dist/node-esm/test/util/helpers.d.ts +49 -49
  43. package/dist/node-esm/test/util/promise.d.ts +28 -28
  44. package/dist/node-esm/test/util/settings.d.ts +23 -23
  45. package/dist/node-esm/test/validation.test.d.ts +17 -17
  46. package/dist/src/api/blob.d.ts +29 -29
  47. package/dist/src/api/database.d.ts +228 -228
  48. package/dist/src/api/field_path.d.ts +36 -36
  49. package/dist/src/api/field_value.d.ts +29 -29
  50. package/dist/src/api/geo_point.d.ts +17 -17
  51. package/dist/src/api/observer.d.ts +29 -29
  52. package/dist/src/api/timestamp.d.ts +17 -17
  53. package/dist/src/config.d.ts +28 -28
  54. package/dist/src/index.console.d.ts +48 -48
  55. package/dist/src/index.d.ts +117 -85
  56. package/dist/src/index.node.d.ts +22 -22
  57. package/dist/src/index.rn.d.ts +22 -22
  58. package/dist/src/register-module.d.ts +42 -42
  59. package/dist/src/util/input_validation.d.ts +18 -18
  60. package/dist/test/array_transforms.test.d.ts +17 -17
  61. package/dist/test/batch_writes.test.d.ts +17 -17
  62. package/dist/test/bootstrap.d.ts +17 -17
  63. package/dist/test/bundle.test.d.ts +17 -17
  64. package/dist/test/cursor.test.d.ts +17 -17
  65. package/dist/test/database.test.d.ts +17 -17
  66. package/dist/test/fields.test.d.ts +17 -17
  67. package/dist/test/get_options.test.d.ts +17 -17
  68. package/dist/test/numeric_transforms.test.d.ts +17 -17
  69. package/dist/test/query.test.d.ts +17 -17
  70. package/dist/test/server_timestamp.test.d.ts +17 -17
  71. package/dist/test/smoke.test.d.ts +17 -17
  72. package/dist/test/transactions.test.d.ts +17 -17
  73. package/dist/test/type.test.d.ts +17 -17
  74. package/dist/test/util/equality_matcher.d.ts +33 -33
  75. package/dist/test/util/events_accumulator.d.ts +39 -39
  76. package/dist/test/util/firebase_export.d.ts +29 -29
  77. package/dist/test/util/helpers.d.ts +49 -49
  78. package/dist/test/util/promise.d.ts +28 -28
  79. package/dist/test/util/settings.d.ts +23 -23
  80. package/dist/test/validation.test.d.ts +17 -17
  81. package/package.json +25 -23
  82. package/CHANGELOG.md +0 -330
  83. package/dist/index.esm2017.js.map +0 -1
  84. package/dist/index.esm5.js +0 -1196
  85. package/dist/index.esm5.js.map +0 -1
@@ -4,994 +4,1002 @@ import { getModularInstance } from '@firebase/util';
4
4
  import { Component } from '@firebase/component';
5
5
 
6
6
  const name = "@firebase/firestore-compat";
7
- const version = "0.4.0-20230301000120";
7
+ const version = "0.4.0-20250715195345";
8
8
 
9
- /**
10
- * @license
11
- * Copyright 2021 Google LLC
12
- *
13
- * Licensed under the Apache License, Version 2.0 (the "License");
14
- * you may not use this file except in compliance with the License.
15
- * You may obtain a copy of the License at
16
- *
17
- * http://www.apache.org/licenses/LICENSE-2.0
18
- *
19
- * Unless required by applicable law or agreed to in writing, software
20
- * distributed under the License is distributed on an "AS IS" BASIS,
21
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22
- * See the License for the specific language governing permissions and
23
- * limitations under the License.
24
- */
25
- function validateSetOptions(methodName, options) {
26
- if (options === undefined) {
27
- return {
28
- merge: false
29
- };
30
- }
31
- if (options.mergeFields !== undefined && options.merge !== undefined) {
32
- throw new FirestoreError('invalid-argument', `Invalid options passed to function ${methodName}(): You cannot ` +
33
- 'specify both "merge" and "mergeFields".');
34
- }
35
- return options;
9
+ /**
10
+ * @license
11
+ * Copyright 2021 Google LLC
12
+ *
13
+ * Licensed under the Apache License, Version 2.0 (the "License");
14
+ * you may not use this file except in compliance with the License.
15
+ * You may obtain a copy of the License at
16
+ *
17
+ * http://www.apache.org/licenses/LICENSE-2.0
18
+ *
19
+ * Unless required by applicable law or agreed to in writing, software
20
+ * distributed under the License is distributed on an "AS IS" BASIS,
21
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22
+ * See the License for the specific language governing permissions and
23
+ * limitations under the License.
24
+ */
25
+ function validateSetOptions(methodName, options) {
26
+ if (options === undefined) {
27
+ return {
28
+ merge: false
29
+ };
30
+ }
31
+ if (options.mergeFields !== undefined && options.merge !== undefined) {
32
+ throw new FirestoreError('invalid-argument', `Invalid options passed to function ${methodName}(): You cannot ` +
33
+ 'specify both "merge" and "mergeFields".');
34
+ }
35
+ return options;
36
36
  }
37
37
 
38
- /**
39
- * @license
40
- * Copyright 2017 Google LLC
41
- *
42
- * Licensed under the Apache License, Version 2.0 (the "License");
43
- * you may not use this file except in compliance with the License.
44
- * You may obtain a copy of the License at
45
- *
46
- * http://www.apache.org/licenses/LICENSE-2.0
47
- *
48
- * Unless required by applicable law or agreed to in writing, software
49
- * distributed under the License is distributed on an "AS IS" BASIS,
50
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
51
- * See the License for the specific language governing permissions and
52
- * limitations under the License.
53
- */
54
- /** Helper function to assert Uint8Array is available at runtime. */
55
- function assertUint8ArrayAvailable() {
56
- if (typeof Uint8Array === 'undefined') {
57
- throw new FirestoreError('unimplemented', 'Uint8Arrays are not available in this environment.');
58
- }
59
- }
60
- /** Helper function to assert Base64 functions are available at runtime. */
61
- function assertBase64Available() {
62
- if (!_isBase64Available()) {
63
- throw new FirestoreError('unimplemented', 'Blobs are unavailable in Firestore in this environment.');
64
- }
65
- }
66
- /** Immutable class holding a blob (binary data) */
67
- class Blob {
68
- constructor(_delegate) {
69
- this._delegate = _delegate;
70
- }
71
- static fromBase64String(base64) {
72
- assertBase64Available();
73
- return new Blob(Bytes.fromBase64String(base64));
74
- }
75
- static fromUint8Array(array) {
76
- assertUint8ArrayAvailable();
77
- return new Blob(Bytes.fromUint8Array(array));
78
- }
79
- toBase64() {
80
- assertBase64Available();
81
- return this._delegate.toBase64();
82
- }
83
- toUint8Array() {
84
- assertUint8ArrayAvailable();
85
- return this._delegate.toUint8Array();
86
- }
87
- isEqual(other) {
88
- return this._delegate.isEqual(other._delegate);
89
- }
90
- toString() {
91
- return 'Blob(base64: ' + this.toBase64() + ')';
92
- }
38
+ /**
39
+ * @license
40
+ * Copyright 2017 Google LLC
41
+ *
42
+ * Licensed under the Apache License, Version 2.0 (the "License");
43
+ * you may not use this file except in compliance with the License.
44
+ * You may obtain a copy of the License at
45
+ *
46
+ * http://www.apache.org/licenses/LICENSE-2.0
47
+ *
48
+ * Unless required by applicable law or agreed to in writing, software
49
+ * distributed under the License is distributed on an "AS IS" BASIS,
50
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
51
+ * See the License for the specific language governing permissions and
52
+ * limitations under the License.
53
+ */
54
+ /** Helper function to assert Uint8Array is available at runtime. */
55
+ function assertUint8ArrayAvailable() {
56
+ if (typeof Uint8Array === 'undefined') {
57
+ throw new FirestoreError('unimplemented', 'Uint8Arrays are not available in this environment.');
58
+ }
59
+ }
60
+ /** Helper function to assert Base64 functions are available at runtime. */
61
+ function assertBase64Available() {
62
+ if (!_isBase64Available()) {
63
+ throw new FirestoreError('unimplemented', 'Blobs are unavailable in Firestore in this environment.');
64
+ }
65
+ }
66
+ /** Immutable class holding a blob (binary data) */
67
+ class Blob {
68
+ constructor(_delegate) {
69
+ this._delegate = _delegate;
70
+ }
71
+ static fromBase64String(base64) {
72
+ assertBase64Available();
73
+ return new Blob(Bytes.fromBase64String(base64));
74
+ }
75
+ static fromUint8Array(array) {
76
+ assertUint8ArrayAvailable();
77
+ return new Blob(Bytes.fromUint8Array(array));
78
+ }
79
+ toBase64() {
80
+ assertBase64Available();
81
+ return this._delegate.toBase64();
82
+ }
83
+ toUint8Array() {
84
+ assertUint8ArrayAvailable();
85
+ return this._delegate.toUint8Array();
86
+ }
87
+ isEqual(other) {
88
+ return this._delegate.isEqual(other._delegate);
89
+ }
90
+ toString() {
91
+ return 'Blob(base64: ' + this.toBase64() + ')';
92
+ }
93
93
  }
94
94
 
95
- /**
96
- * @license
97
- * Copyright 2017 Google LLC
98
- *
99
- * Licensed under the Apache License, Version 2.0 (the "License");
100
- * you may not use this file except in compliance with the License.
101
- * You may obtain a copy of the License at
102
- *
103
- * http://www.apache.org/licenses/LICENSE-2.0
104
- *
105
- * Unless required by applicable law or agreed to in writing, software
106
- * distributed under the License is distributed on an "AS IS" BASIS,
107
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
108
- * See the License for the specific language governing permissions and
109
- * limitations under the License.
110
- */
111
- function isPartialObserver(obj) {
112
- return implementsAnyMethods(obj, ['next', 'error', 'complete']);
113
- }
114
- /**
115
- * Returns true if obj is an object and contains at least one of the specified
116
- * methods.
117
- */
118
- function implementsAnyMethods(obj, methods) {
119
- if (typeof obj !== 'object' || obj === null) {
120
- return false;
121
- }
122
- const object = obj;
123
- for (const method of methods) {
124
- if (method in object && typeof object[method] === 'function') {
125
- return true;
126
- }
127
- }
128
- return false;
95
+ /**
96
+ * @license
97
+ * Copyright 2017 Google LLC
98
+ *
99
+ * Licensed under the Apache License, Version 2.0 (the "License");
100
+ * you may not use this file except in compliance with the License.
101
+ * You may obtain a copy of the License at
102
+ *
103
+ * http://www.apache.org/licenses/LICENSE-2.0
104
+ *
105
+ * Unless required by applicable law or agreed to in writing, software
106
+ * distributed under the License is distributed on an "AS IS" BASIS,
107
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
108
+ * See the License for the specific language governing permissions and
109
+ * limitations under the License.
110
+ */
111
+ function isPartialObserver(obj) {
112
+ return implementsAnyMethods(obj, ['next', 'error', 'complete']);
113
+ }
114
+ /**
115
+ * Returns true if obj is an object and contains at least one of the specified
116
+ * methods.
117
+ */
118
+ function implementsAnyMethods(obj, methods) {
119
+ if (typeof obj !== 'object' || obj === null) {
120
+ return false;
121
+ }
122
+ const object = obj;
123
+ for (const method of methods) {
124
+ if (method in object && typeof object[method] === 'function') {
125
+ return true;
126
+ }
127
+ }
128
+ return false;
129
129
  }
130
130
 
131
- /**
132
- * @license
133
- * Copyright 2017 Google LLC
134
- *
135
- * Licensed under the Apache License, Version 2.0 (the "License");
136
- * you may not use this file except in compliance with the License.
137
- * You may obtain a copy of the License at
138
- *
139
- * http://www.apache.org/licenses/LICENSE-2.0
140
- *
141
- * Unless required by applicable law or agreed to in writing, software
142
- * distributed under the License is distributed on an "AS IS" BASIS,
143
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
144
- * See the License for the specific language governing permissions and
145
- * limitations under the License.
146
- */
147
- /**
148
- * The persistence provider included with the full Firestore SDK.
149
- */
150
- class IndexedDbPersistenceProvider {
151
- enableIndexedDbPersistence(firestore, forceOwnership) {
152
- return enableIndexedDbPersistence(firestore._delegate, { forceOwnership });
153
- }
154
- enableMultiTabIndexedDbPersistence(firestore) {
155
- return enableMultiTabIndexedDbPersistence(firestore._delegate);
156
- }
157
- clearIndexedDbPersistence(firestore) {
158
- return clearIndexedDbPersistence(firestore._delegate);
159
- }
160
- }
161
- /**
162
- * Compat class for Firestore. Exposes Firestore Legacy API, but delegates
163
- * to the functional API of firestore-exp.
164
- */
165
- class Firestore {
166
- constructor(databaseIdOrApp, _delegate, _persistenceProvider) {
167
- this._delegate = _delegate;
168
- this._persistenceProvider = _persistenceProvider;
169
- this.INTERNAL = {
170
- delete: () => this.terminate()
171
- };
172
- if (!(databaseIdOrApp instanceof _DatabaseId)) {
173
- this._appCompat = databaseIdOrApp;
174
- }
175
- }
176
- get _databaseId() {
177
- return this._delegate._databaseId;
178
- }
179
- settings(settingsLiteral) {
180
- const currentSettings = this._delegate._getSettings();
181
- if (!settingsLiteral.merge &&
182
- currentSettings.host !== settingsLiteral.host) {
183
- _logWarn('You are overriding the original host. If you did not intend ' +
184
- 'to override your settings, use {merge: true}.');
185
- }
186
- if (settingsLiteral.merge) {
187
- settingsLiteral = Object.assign(Object.assign({}, currentSettings), settingsLiteral);
188
- // Remove the property from the settings once the merge is completed
189
- delete settingsLiteral.merge;
190
- }
191
- this._delegate._setSettings(settingsLiteral);
192
- }
193
- useEmulator(host, port, options = {}) {
194
- connectFirestoreEmulator(this._delegate, host, port, options);
195
- }
196
- enableNetwork() {
197
- return enableNetwork(this._delegate);
198
- }
199
- disableNetwork() {
200
- return disableNetwork(this._delegate);
201
- }
202
- enablePersistence(settings) {
203
- let synchronizeTabs = false;
204
- let experimentalForceOwningTab = false;
205
- if (settings) {
206
- synchronizeTabs = !!settings.synchronizeTabs;
207
- experimentalForceOwningTab = !!settings.experimentalForceOwningTab;
208
- _validateIsNotUsedTogether('synchronizeTabs', synchronizeTabs, 'experimentalForceOwningTab', experimentalForceOwningTab);
209
- }
210
- return synchronizeTabs
211
- ? this._persistenceProvider.enableMultiTabIndexedDbPersistence(this)
212
- : this._persistenceProvider.enableIndexedDbPersistence(this, experimentalForceOwningTab);
213
- }
214
- clearPersistence() {
215
- return this._persistenceProvider.clearIndexedDbPersistence(this);
216
- }
217
- terminate() {
218
- if (this._appCompat) {
219
- this._appCompat._removeServiceInstance('firestore-compat');
220
- this._appCompat._removeServiceInstance('firestore');
221
- }
222
- return this._delegate._delete();
223
- }
224
- waitForPendingWrites() {
225
- return waitForPendingWrites(this._delegate);
226
- }
227
- onSnapshotsInSync(arg) {
228
- return onSnapshotsInSync(this._delegate, arg);
229
- }
230
- get app() {
231
- if (!this._appCompat) {
232
- throw new FirestoreError('failed-precondition', "Firestore was not initialized using the Firebase SDK. 'app' is " +
233
- 'not available');
234
- }
235
- return this._appCompat;
236
- }
237
- collection(pathString) {
238
- try {
239
- return new CollectionReference(this, collection(this._delegate, pathString));
240
- }
241
- catch (e) {
242
- throw replaceFunctionName(e, 'collection()', 'Firestore.collection()');
243
- }
244
- }
245
- doc(pathString) {
246
- try {
247
- return new DocumentReference(this, doc(this._delegate, pathString));
248
- }
249
- catch (e) {
250
- throw replaceFunctionName(e, 'doc()', 'Firestore.doc()');
251
- }
252
- }
253
- collectionGroup(collectionId) {
254
- try {
255
- return new Query(this, collectionGroup(this._delegate, collectionId));
256
- }
257
- catch (e) {
258
- throw replaceFunctionName(e, 'collectionGroup()', 'Firestore.collectionGroup()');
259
- }
260
- }
261
- runTransaction(updateFunction) {
262
- return runTransaction(this._delegate, transaction => updateFunction(new Transaction(this, transaction)));
263
- }
264
- batch() {
265
- ensureFirestoreConfigured(this._delegate);
266
- return new WriteBatch(new WriteBatch$1(this._delegate, mutations => executeWrite(this._delegate, mutations)));
267
- }
268
- loadBundle(bundleData) {
269
- return loadBundle(this._delegate, bundleData);
270
- }
271
- namedQuery(name) {
272
- return namedQuery(this._delegate, name).then(expQuery => {
273
- if (!expQuery) {
274
- return null;
275
- }
276
- return new Query(this,
277
- // We can pass `expQuery` here directly since named queries don't have a UserDataConverter.
278
- // Otherwise, we would have to create a new ExpQuery and pass the old UserDataConverter.
279
- expQuery);
280
- });
281
- }
282
- }
283
- class UserDataWriter extends AbstractUserDataWriter {
284
- constructor(firestore) {
285
- super();
286
- this.firestore = firestore;
287
- }
288
- convertBytes(bytes) {
289
- return new Blob(new Bytes(bytes));
290
- }
291
- convertReference(name) {
292
- const key = this.convertDocumentKey(name, this.firestore._databaseId);
293
- return DocumentReference.forKey(key, this.firestore, /* converter= */ null);
294
- }
295
- }
296
- function setLogLevel(level) {
297
- setLogLevel$1(level);
298
- }
299
- /**
300
- * A reference to a transaction.
301
- */
302
- class Transaction {
303
- constructor(_firestore, _delegate) {
304
- this._firestore = _firestore;
305
- this._delegate = _delegate;
306
- this._userDataWriter = new UserDataWriter(_firestore);
307
- }
308
- get(documentRef) {
309
- const ref = castReference(documentRef);
310
- return this._delegate
311
- .get(ref)
312
- .then(result => new DocumentSnapshot(this._firestore, new DocumentSnapshot$1(this._firestore._delegate, this._userDataWriter, result._key, result._document, result.metadata, ref.converter)));
313
- }
314
- set(documentRef, data, options) {
315
- const ref = castReference(documentRef);
316
- if (options) {
317
- validateSetOptions('Transaction.set', options);
318
- this._delegate.set(ref, data, options);
319
- }
320
- else {
321
- this._delegate.set(ref, data);
322
- }
323
- return this;
324
- }
325
- update(documentRef, dataOrField, value, ...moreFieldsAndValues) {
326
- const ref = castReference(documentRef);
327
- if (arguments.length === 2) {
328
- this._delegate.update(ref, dataOrField);
329
- }
330
- else {
331
- this._delegate.update(ref, dataOrField, value, ...moreFieldsAndValues);
332
- }
333
- return this;
334
- }
335
- delete(documentRef) {
336
- const ref = castReference(documentRef);
337
- this._delegate.delete(ref);
338
- return this;
339
- }
340
- }
341
- class WriteBatch {
342
- constructor(_delegate) {
343
- this._delegate = _delegate;
344
- }
345
- set(documentRef, data, options) {
346
- const ref = castReference(documentRef);
347
- if (options) {
348
- validateSetOptions('WriteBatch.set', options);
349
- this._delegate.set(ref, data, options);
350
- }
351
- else {
352
- this._delegate.set(ref, data);
353
- }
354
- return this;
355
- }
356
- update(documentRef, dataOrField, value, ...moreFieldsAndValues) {
357
- const ref = castReference(documentRef);
358
- if (arguments.length === 2) {
359
- this._delegate.update(ref, dataOrField);
360
- }
361
- else {
362
- this._delegate.update(ref, dataOrField, value, ...moreFieldsAndValues);
363
- }
364
- return this;
365
- }
366
- delete(documentRef) {
367
- const ref = castReference(documentRef);
368
- this._delegate.delete(ref);
369
- return this;
370
- }
371
- commit() {
372
- return this._delegate.commit();
373
- }
374
- }
375
- /**
376
- * Wraps a `PublicFirestoreDataConverter` translating the types from the
377
- * experimental SDK into corresponding types from the Classic SDK before passing
378
- * them to the wrapped converter.
379
- */
380
- class FirestoreDataConverter {
381
- constructor(_firestore, _userDataWriter, _delegate) {
382
- this._firestore = _firestore;
383
- this._userDataWriter = _userDataWriter;
384
- this._delegate = _delegate;
385
- }
386
- fromFirestore(snapshot, options) {
387
- const expSnapshot = new QueryDocumentSnapshot$1(this._firestore._delegate, this._userDataWriter, snapshot._key, snapshot._document, snapshot.metadata,
388
- /* converter= */ null);
389
- return this._delegate.fromFirestore(new QueryDocumentSnapshot(this._firestore, expSnapshot), options !== null && options !== void 0 ? options : {});
390
- }
391
- toFirestore(modelObject, options) {
392
- if (!options) {
393
- return this._delegate.toFirestore(modelObject);
394
- }
395
- else {
396
- return this._delegate.toFirestore(modelObject, options);
397
- }
398
- }
399
- // Use the same instance of `FirestoreDataConverter` for the given instances
400
- // of `Firestore` and `PublicFirestoreDataConverter` so that isEqual() will
401
- // compare equal for two objects created with the same converter instance.
402
- static getInstance(firestore, converter) {
403
- const converterMapByFirestore = FirestoreDataConverter.INSTANCES;
404
- let untypedConverterByConverter = converterMapByFirestore.get(firestore);
405
- if (!untypedConverterByConverter) {
406
- untypedConverterByConverter = new WeakMap();
407
- converterMapByFirestore.set(firestore, untypedConverterByConverter);
408
- }
409
- let instance = untypedConverterByConverter.get(converter);
410
- if (!instance) {
411
- instance = new FirestoreDataConverter(firestore, new UserDataWriter(firestore), converter);
412
- untypedConverterByConverter.set(converter, instance);
413
- }
414
- return instance;
415
- }
416
- }
417
- FirestoreDataConverter.INSTANCES = new WeakMap();
418
- /**
419
- * A reference to a particular document in a collection in the database.
420
- */
421
- class DocumentReference {
422
- constructor(firestore, _delegate) {
423
- this.firestore = firestore;
424
- this._delegate = _delegate;
425
- this._userDataWriter = new UserDataWriter(firestore);
426
- }
427
- static forPath(path, firestore, converter) {
428
- if (path.length % 2 !== 0) {
429
- throw new FirestoreError('invalid-argument', 'Invalid document reference. Document ' +
430
- 'references must have an even number of segments, but ' +
431
- `${path.canonicalString()} has ${path.length}`);
432
- }
433
- return new DocumentReference(firestore, new DocumentReference$1(firestore._delegate, converter, new _DocumentKey(path)));
434
- }
435
- static forKey(key, firestore, converter) {
436
- return new DocumentReference(firestore, new DocumentReference$1(firestore._delegate, converter, key));
437
- }
438
- get id() {
439
- return this._delegate.id;
440
- }
441
- get parent() {
442
- return new CollectionReference(this.firestore, this._delegate.parent);
443
- }
444
- get path() {
445
- return this._delegate.path;
446
- }
447
- collection(pathString) {
448
- try {
449
- return new CollectionReference(this.firestore, collection(this._delegate, pathString));
450
- }
451
- catch (e) {
452
- throw replaceFunctionName(e, 'collection()', 'DocumentReference.collection()');
453
- }
454
- }
455
- isEqual(other) {
456
- other = getModularInstance(other);
457
- if (!(other instanceof DocumentReference$1)) {
458
- return false;
459
- }
460
- return refEqual(this._delegate, other);
461
- }
462
- set(value, options) {
463
- options = validateSetOptions('DocumentReference.set', options);
464
- try {
465
- if (options) {
466
- return setDoc(this._delegate, value, options);
467
- }
468
- else {
469
- return setDoc(this._delegate, value);
470
- }
471
- }
472
- catch (e) {
473
- throw replaceFunctionName(e, 'setDoc()', 'DocumentReference.set()');
474
- }
475
- }
476
- update(fieldOrUpdateData, value, ...moreFieldsAndValues) {
477
- try {
478
- if (arguments.length === 1) {
479
- return updateDoc(this._delegate, fieldOrUpdateData);
480
- }
481
- else {
482
- return updateDoc(this._delegate, fieldOrUpdateData, value, ...moreFieldsAndValues);
483
- }
484
- }
485
- catch (e) {
486
- throw replaceFunctionName(e, 'updateDoc()', 'DocumentReference.update()');
487
- }
488
- }
489
- delete() {
490
- return deleteDoc(this._delegate);
491
- }
492
- onSnapshot(...args) {
493
- const options = extractSnapshotOptions(args);
494
- const observer = wrapObserver(args, result => new DocumentSnapshot(this.firestore, new DocumentSnapshot$1(this.firestore._delegate, this._userDataWriter, result._key, result._document, result.metadata, this._delegate.converter)));
495
- return onSnapshot(this._delegate, options, observer);
496
- }
497
- get(options) {
498
- let snap;
499
- if ((options === null || options === void 0 ? void 0 : options.source) === 'cache') {
500
- snap = getDocFromCache(this._delegate);
501
- }
502
- else if ((options === null || options === void 0 ? void 0 : options.source) === 'server') {
503
- snap = getDocFromServer(this._delegate);
504
- }
505
- else {
506
- snap = getDoc(this._delegate);
507
- }
508
- return snap.then(result => new DocumentSnapshot(this.firestore, new DocumentSnapshot$1(this.firestore._delegate, this._userDataWriter, result._key, result._document, result.metadata, this._delegate.converter)));
509
- }
510
- withConverter(converter) {
511
- return new DocumentReference(this.firestore, converter
512
- ? this._delegate.withConverter(FirestoreDataConverter.getInstance(this.firestore, converter))
513
- : this._delegate.withConverter(null));
514
- }
515
- }
516
- /**
517
- * Replaces the function name in an error thrown by the firestore-exp API
518
- * with the function names used in the classic API.
519
- */
520
- function replaceFunctionName(e, original, updated) {
521
- e.message = e.message.replace(original, updated);
522
- return e;
523
- }
524
- /**
525
- * Iterates the list of arguments from an `onSnapshot` call and returns the
526
- * first argument that may be an `SnapshotListenOptions` object. Returns an
527
- * empty object if none is found.
528
- */
529
- function extractSnapshotOptions(args) {
530
- for (const arg of args) {
531
- if (typeof arg === 'object' && !isPartialObserver(arg)) {
532
- return arg;
533
- }
534
- }
535
- return {};
536
- }
537
- /**
538
- * Creates an observer that can be passed to the firestore-exp SDK. The
539
- * observer converts all observed values into the format expected by the classic
540
- * SDK.
541
- *
542
- * @param args - The list of arguments from an `onSnapshot` call.
543
- * @param wrapper - The function that converts the firestore-exp type into the
544
- * type used by this shim.
545
- */
546
- function wrapObserver(args, wrapper) {
547
- var _a, _b;
548
- let userObserver;
549
- if (isPartialObserver(args[0])) {
550
- userObserver = args[0];
551
- }
552
- else if (isPartialObserver(args[1])) {
553
- userObserver = args[1];
554
- }
555
- else if (typeof args[0] === 'function') {
556
- userObserver = {
557
- next: args[0],
558
- error: args[1],
559
- complete: args[2]
560
- };
561
- }
562
- else {
563
- userObserver = {
564
- next: args[1],
565
- error: args[2],
566
- complete: args[3]
567
- };
568
- }
569
- return {
570
- next: val => {
571
- if (userObserver.next) {
572
- userObserver.next(wrapper(val));
573
- }
574
- },
575
- error: (_a = userObserver.error) === null || _a === void 0 ? void 0 : _a.bind(userObserver),
576
- complete: (_b = userObserver.complete) === null || _b === void 0 ? void 0 : _b.bind(userObserver)
577
- };
578
- }
579
- class DocumentSnapshot {
580
- constructor(_firestore, _delegate) {
581
- this._firestore = _firestore;
582
- this._delegate = _delegate;
583
- }
584
- get ref() {
585
- return new DocumentReference(this._firestore, this._delegate.ref);
586
- }
587
- get id() {
588
- return this._delegate.id;
589
- }
590
- get metadata() {
591
- return this._delegate.metadata;
592
- }
593
- get exists() {
594
- return this._delegate.exists();
595
- }
596
- data(options) {
597
- return this._delegate.data(options);
598
- }
599
- get(fieldPath, options
600
- // We are using `any` here to avoid an explicit cast by our users.
601
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
602
- ) {
603
- return this._delegate.get(fieldPath, options);
604
- }
605
- isEqual(other) {
606
- return snapshotEqual(this._delegate, other._delegate);
607
- }
608
- }
609
- class QueryDocumentSnapshot extends DocumentSnapshot {
610
- data(options) {
611
- const data = this._delegate.data(options);
612
- _debugAssert(data !== undefined, 'Document in a QueryDocumentSnapshot should exist');
613
- return data;
614
- }
615
- }
616
- class Query {
617
- constructor(firestore, _delegate) {
618
- this.firestore = firestore;
619
- this._delegate = _delegate;
620
- this._userDataWriter = new UserDataWriter(firestore);
621
- }
622
- where(fieldPath, opStr, value) {
623
- try {
624
- // The "as string" cast is a little bit of a hack. `where` accepts the
625
- // FieldPath Compat type as input, but is not typed as such in order to
626
- // not expose this via our public typings file.
627
- return new Query(this.firestore, query(this._delegate, where(fieldPath, opStr, value)));
628
- }
629
- catch (e) {
630
- throw replaceFunctionName(e, /(orderBy|where)\(\)/, 'Query.$1()');
631
- }
632
- }
633
- orderBy(fieldPath, directionStr) {
634
- try {
635
- // The "as string" cast is a little bit of a hack. `orderBy` accepts the
636
- // FieldPath Compat type as input, but is not typed as such in order to
637
- // not expose this via our public typings file.
638
- return new Query(this.firestore, query(this._delegate, orderBy(fieldPath, directionStr)));
639
- }
640
- catch (e) {
641
- throw replaceFunctionName(e, /(orderBy|where)\(\)/, 'Query.$1()');
642
- }
643
- }
644
- limit(n) {
645
- try {
646
- return new Query(this.firestore, query(this._delegate, limit(n)));
647
- }
648
- catch (e) {
649
- throw replaceFunctionName(e, 'limit()', 'Query.limit()');
650
- }
651
- }
652
- limitToLast(n) {
653
- try {
654
- return new Query(this.firestore, query(this._delegate, limitToLast(n)));
655
- }
656
- catch (e) {
657
- throw replaceFunctionName(e, 'limitToLast()', 'Query.limitToLast()');
658
- }
659
- }
660
- startAt(...args) {
661
- try {
662
- return new Query(this.firestore, query(this._delegate, startAt(...args)));
663
- }
664
- catch (e) {
665
- throw replaceFunctionName(e, 'startAt()', 'Query.startAt()');
666
- }
667
- }
668
- startAfter(...args) {
669
- try {
670
- return new Query(this.firestore, query(this._delegate, startAfter(...args)));
671
- }
672
- catch (e) {
673
- throw replaceFunctionName(e, 'startAfter()', 'Query.startAfter()');
674
- }
675
- }
676
- endBefore(...args) {
677
- try {
678
- return new Query(this.firestore, query(this._delegate, endBefore(...args)));
679
- }
680
- catch (e) {
681
- throw replaceFunctionName(e, 'endBefore()', 'Query.endBefore()');
682
- }
683
- }
684
- endAt(...args) {
685
- try {
686
- return new Query(this.firestore, query(this._delegate, endAt(...args)));
687
- }
688
- catch (e) {
689
- throw replaceFunctionName(e, 'endAt()', 'Query.endAt()');
690
- }
691
- }
692
- isEqual(other) {
693
- return queryEqual(this._delegate, other._delegate);
694
- }
695
- get(options) {
696
- let query;
697
- if ((options === null || options === void 0 ? void 0 : options.source) === 'cache') {
698
- query = getDocsFromCache(this._delegate);
699
- }
700
- else if ((options === null || options === void 0 ? void 0 : options.source) === 'server') {
701
- query = getDocsFromServer(this._delegate);
702
- }
703
- else {
704
- query = getDocs(this._delegate);
705
- }
706
- return query.then(result => new QuerySnapshot(this.firestore, new QuerySnapshot$1(this.firestore._delegate, this._userDataWriter, this._delegate, result._snapshot)));
707
- }
708
- onSnapshot(...args) {
709
- const options = extractSnapshotOptions(args);
710
- const observer = wrapObserver(args, snap => new QuerySnapshot(this.firestore, new QuerySnapshot$1(this.firestore._delegate, this._userDataWriter, this._delegate, snap._snapshot)));
711
- return onSnapshot(this._delegate, options, observer);
712
- }
713
- withConverter(converter) {
714
- return new Query(this.firestore, converter
715
- ? this._delegate.withConverter(FirestoreDataConverter.getInstance(this.firestore, converter))
716
- : this._delegate.withConverter(null));
717
- }
718
- }
719
- class DocumentChange {
720
- constructor(_firestore, _delegate) {
721
- this._firestore = _firestore;
722
- this._delegate = _delegate;
723
- }
724
- get type() {
725
- return this._delegate.type;
726
- }
727
- get doc() {
728
- return new QueryDocumentSnapshot(this._firestore, this._delegate.doc);
729
- }
730
- get oldIndex() {
731
- return this._delegate.oldIndex;
732
- }
733
- get newIndex() {
734
- return this._delegate.newIndex;
735
- }
736
- }
737
- class QuerySnapshot {
738
- constructor(_firestore, _delegate) {
739
- this._firestore = _firestore;
740
- this._delegate = _delegate;
741
- }
742
- get query() {
743
- return new Query(this._firestore, this._delegate.query);
744
- }
745
- get metadata() {
746
- return this._delegate.metadata;
747
- }
748
- get size() {
749
- return this._delegate.size;
750
- }
751
- get empty() {
752
- return this._delegate.empty;
753
- }
754
- get docs() {
755
- return this._delegate.docs.map(doc => new QueryDocumentSnapshot(this._firestore, doc));
756
- }
757
- docChanges(options) {
758
- return this._delegate
759
- .docChanges(options)
760
- .map(docChange => new DocumentChange(this._firestore, docChange));
761
- }
762
- forEach(callback, thisArg) {
763
- this._delegate.forEach(snapshot => {
764
- callback.call(thisArg, new QueryDocumentSnapshot(this._firestore, snapshot));
765
- });
766
- }
767
- isEqual(other) {
768
- return snapshotEqual(this._delegate, other._delegate);
769
- }
770
- }
771
- class CollectionReference extends Query {
772
- constructor(firestore, _delegate) {
773
- super(firestore, _delegate);
774
- this.firestore = firestore;
775
- this._delegate = _delegate;
776
- }
777
- get id() {
778
- return this._delegate.id;
779
- }
780
- get path() {
781
- return this._delegate.path;
782
- }
783
- get parent() {
784
- const docRef = this._delegate.parent;
785
- return docRef ? new DocumentReference(this.firestore, docRef) : null;
786
- }
787
- doc(documentPath) {
788
- try {
789
- if (documentPath === undefined) {
790
- // Call `doc` without `documentPath` if `documentPath` is `undefined`
791
- // as `doc` validates the number of arguments to prevent users from
792
- // accidentally passing `undefined`.
793
- return new DocumentReference(this.firestore, doc(this._delegate));
794
- }
795
- else {
796
- return new DocumentReference(this.firestore, doc(this._delegate, documentPath));
797
- }
798
- }
799
- catch (e) {
800
- throw replaceFunctionName(e, 'doc()', 'CollectionReference.doc()');
801
- }
802
- }
803
- add(data) {
804
- return addDoc(this._delegate, data).then(docRef => new DocumentReference(this.firestore, docRef));
805
- }
806
- isEqual(other) {
807
- return refEqual(this._delegate, other._delegate);
808
- }
809
- withConverter(converter) {
810
- return new CollectionReference(this.firestore, converter
811
- ? this._delegate.withConverter(FirestoreDataConverter.getInstance(this.firestore, converter))
812
- : this._delegate.withConverter(null));
813
- }
814
- }
815
- function castReference(documentRef) {
816
- return _cast(documentRef, DocumentReference$1);
131
+ /**
132
+ * @license
133
+ * Copyright 2017 Google LLC
134
+ *
135
+ * Licensed under the Apache License, Version 2.0 (the "License");
136
+ * you may not use this file except in compliance with the License.
137
+ * You may obtain a copy of the License at
138
+ *
139
+ * http://www.apache.org/licenses/LICENSE-2.0
140
+ *
141
+ * Unless required by applicable law or agreed to in writing, software
142
+ * distributed under the License is distributed on an "AS IS" BASIS,
143
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
144
+ * See the License for the specific language governing permissions and
145
+ * limitations under the License.
146
+ */
147
+ /**
148
+ * The persistence provider included with the full Firestore SDK.
149
+ */
150
+ class IndexedDbPersistenceProvider {
151
+ enableIndexedDbPersistence(firestore, forceOwnership) {
152
+ return enableIndexedDbPersistence(firestore._delegate, { forceOwnership });
153
+ }
154
+ enableMultiTabIndexedDbPersistence(firestore) {
155
+ return enableMultiTabIndexedDbPersistence(firestore._delegate);
156
+ }
157
+ clearIndexedDbPersistence(firestore) {
158
+ return clearIndexedDbPersistence(firestore._delegate);
159
+ }
160
+ }
161
+ /**
162
+ * Compat class for Firestore. Exposes Firestore Legacy API, but delegates
163
+ * to the functional API of firestore-exp.
164
+ */
165
+ class Firestore {
166
+ constructor(databaseIdOrApp, _delegate, _persistenceProvider) {
167
+ this._delegate = _delegate;
168
+ this._persistenceProvider = _persistenceProvider;
169
+ this.INTERNAL = {
170
+ delete: () => this.terminate()
171
+ };
172
+ if (!(databaseIdOrApp instanceof _DatabaseId)) {
173
+ this._appCompat = databaseIdOrApp;
174
+ }
175
+ }
176
+ get _databaseId() {
177
+ return this._delegate._databaseId;
178
+ }
179
+ settings(settingsLiteral) {
180
+ const currentSettings = this._delegate._getSettings();
181
+ if (!settingsLiteral.merge &&
182
+ currentSettings.host !== settingsLiteral.host) {
183
+ _logWarn('You are overriding the original host. If you did not intend ' +
184
+ 'to override your settings, use {merge: true}.');
185
+ }
186
+ if (settingsLiteral.merge) {
187
+ settingsLiteral = {
188
+ ...currentSettings,
189
+ ...settingsLiteral
190
+ };
191
+ // Remove the property from the settings once the merge is completed
192
+ delete settingsLiteral.merge;
193
+ }
194
+ this._delegate._setSettings(settingsLiteral);
195
+ }
196
+ useEmulator(host, port, options = {}) {
197
+ connectFirestoreEmulator(this._delegate, host, port, options);
198
+ }
199
+ enableNetwork() {
200
+ return enableNetwork(this._delegate);
201
+ }
202
+ disableNetwork() {
203
+ return disableNetwork(this._delegate);
204
+ }
205
+ enablePersistence(settings) {
206
+ let synchronizeTabs = false;
207
+ let experimentalForceOwningTab = false;
208
+ if (settings) {
209
+ synchronizeTabs = !!settings.synchronizeTabs;
210
+ experimentalForceOwningTab = !!settings.experimentalForceOwningTab;
211
+ _validateIsNotUsedTogether('synchronizeTabs', synchronizeTabs, 'experimentalForceOwningTab', experimentalForceOwningTab);
212
+ }
213
+ return synchronizeTabs
214
+ ? this._persistenceProvider.enableMultiTabIndexedDbPersistence(this)
215
+ : this._persistenceProvider.enableIndexedDbPersistence(this, experimentalForceOwningTab);
216
+ }
217
+ clearPersistence() {
218
+ return this._persistenceProvider.clearIndexedDbPersistence(this);
219
+ }
220
+ terminate() {
221
+ if (this._appCompat) {
222
+ this._appCompat._removeServiceInstance('firestore-compat');
223
+ this._appCompat._removeServiceInstance('firestore');
224
+ }
225
+ return this._delegate._delete();
226
+ }
227
+ waitForPendingWrites() {
228
+ return waitForPendingWrites(this._delegate);
229
+ }
230
+ onSnapshotsInSync(arg) {
231
+ return onSnapshotsInSync(this._delegate, arg);
232
+ }
233
+ get app() {
234
+ if (!this._appCompat) {
235
+ throw new FirestoreError('failed-precondition', "Firestore was not initialized using the Firebase SDK. 'app' is " +
236
+ 'not available');
237
+ }
238
+ return this._appCompat;
239
+ }
240
+ collection(pathString) {
241
+ try {
242
+ return new CollectionReference(this, collection(this._delegate, pathString));
243
+ }
244
+ catch (e) {
245
+ throw replaceFunctionName(e, 'collection()', 'Firestore.collection()');
246
+ }
247
+ }
248
+ doc(pathString) {
249
+ try {
250
+ return new DocumentReference(this, doc(this._delegate, pathString));
251
+ }
252
+ catch (e) {
253
+ throw replaceFunctionName(e, 'doc()', 'Firestore.doc()');
254
+ }
255
+ }
256
+ collectionGroup(collectionId) {
257
+ try {
258
+ return new Query(this, collectionGroup(this._delegate, collectionId));
259
+ }
260
+ catch (e) {
261
+ throw replaceFunctionName(e, 'collectionGroup()', 'Firestore.collectionGroup()');
262
+ }
263
+ }
264
+ runTransaction(updateFunction) {
265
+ return runTransaction(this._delegate, transaction => updateFunction(new Transaction(this, transaction)));
266
+ }
267
+ batch() {
268
+ ensureFirestoreConfigured(this._delegate);
269
+ return new WriteBatch(new WriteBatch$1(this._delegate, mutations => executeWrite(this._delegate, mutations)));
270
+ }
271
+ loadBundle(bundleData) {
272
+ return loadBundle(this._delegate, bundleData);
273
+ }
274
+ namedQuery(name) {
275
+ return namedQuery(this._delegate, name).then(expQuery => {
276
+ if (!expQuery) {
277
+ return null;
278
+ }
279
+ return new Query(this,
280
+ // We can pass `expQuery` here directly since named queries don't have a UserDataConverter.
281
+ // Otherwise, we would have to create a new ExpQuery and pass the old UserDataConverter.
282
+ expQuery);
283
+ });
284
+ }
285
+ }
286
+ class UserDataWriter extends AbstractUserDataWriter {
287
+ constructor(firestore) {
288
+ super();
289
+ this.firestore = firestore;
290
+ }
291
+ convertBytes(bytes) {
292
+ return new Blob(new Bytes(bytes));
293
+ }
294
+ convertReference(name) {
295
+ const key = this.convertDocumentKey(name, this.firestore._databaseId);
296
+ return DocumentReference.forKey(key, this.firestore, /* converter= */ null);
297
+ }
298
+ }
299
+ function setLogLevel(level) {
300
+ setLogLevel$1(level);
301
+ }
302
+ /**
303
+ * A reference to a transaction.
304
+ */
305
+ class Transaction {
306
+ constructor(_firestore, _delegate) {
307
+ this._firestore = _firestore;
308
+ this._delegate = _delegate;
309
+ this._userDataWriter = new UserDataWriter(_firestore);
310
+ }
311
+ get(documentRef) {
312
+ const ref = castReference(documentRef);
313
+ return this._delegate
314
+ .get(ref)
315
+ .then(result => new DocumentSnapshot(this._firestore, new DocumentSnapshot$1(this._firestore._delegate, this._userDataWriter, result._key, result._document, result.metadata, ref.converter)));
316
+ }
317
+ set(documentRef, data, options) {
318
+ const ref = castReference(documentRef);
319
+ if (options) {
320
+ validateSetOptions('Transaction.set', options);
321
+ this._delegate.set(ref, data, options);
322
+ }
323
+ else {
324
+ this._delegate.set(ref, data);
325
+ }
326
+ return this;
327
+ }
328
+ update(documentRef, dataOrField, value, ...moreFieldsAndValues) {
329
+ const ref = castReference(documentRef);
330
+ if (arguments.length === 2) {
331
+ this._delegate.update(ref, dataOrField);
332
+ }
333
+ else {
334
+ this._delegate.update(ref, dataOrField, value, ...moreFieldsAndValues);
335
+ }
336
+ return this;
337
+ }
338
+ delete(documentRef) {
339
+ const ref = castReference(documentRef);
340
+ this._delegate.delete(ref);
341
+ return this;
342
+ }
343
+ }
344
+ class WriteBatch {
345
+ constructor(_delegate) {
346
+ this._delegate = _delegate;
347
+ }
348
+ set(documentRef, data, options) {
349
+ const ref = castReference(documentRef);
350
+ if (options) {
351
+ validateSetOptions('WriteBatch.set', options);
352
+ this._delegate.set(ref, data, options);
353
+ }
354
+ else {
355
+ this._delegate.set(ref, data);
356
+ }
357
+ return this;
358
+ }
359
+ update(documentRef, dataOrField, value, ...moreFieldsAndValues) {
360
+ const ref = castReference(documentRef);
361
+ if (arguments.length === 2) {
362
+ this._delegate.update(ref, dataOrField);
363
+ }
364
+ else {
365
+ this._delegate.update(ref, dataOrField, value, ...moreFieldsAndValues);
366
+ }
367
+ return this;
368
+ }
369
+ delete(documentRef) {
370
+ const ref = castReference(documentRef);
371
+ this._delegate.delete(ref);
372
+ return this;
373
+ }
374
+ commit() {
375
+ return this._delegate.commit();
376
+ }
377
+ }
378
+ /**
379
+ * Wraps a `PublicFirestoreDataConverter` translating the types from the
380
+ * experimental SDK into corresponding types from the Classic SDK before passing
381
+ * them to the wrapped converter.
382
+ */
383
+ class FirestoreDataConverter {
384
+ constructor(_firestore, _userDataWriter, _delegate) {
385
+ this._firestore = _firestore;
386
+ this._userDataWriter = _userDataWriter;
387
+ this._delegate = _delegate;
388
+ }
389
+ fromFirestore(snapshot, options) {
390
+ const expSnapshot = new QueryDocumentSnapshot$1(this._firestore._delegate, this._userDataWriter, snapshot._key, snapshot._document, snapshot.metadata,
391
+ /* converter= */ null);
392
+ return this._delegate.fromFirestore(new QueryDocumentSnapshot(this._firestore, expSnapshot), options ?? {});
393
+ }
394
+ toFirestore(modelObject, options) {
395
+ if (!options) {
396
+ return this._delegate.toFirestore(modelObject);
397
+ }
398
+ else {
399
+ return this._delegate.toFirestore(modelObject, options);
400
+ }
401
+ }
402
+ // Use the same instance of `FirestoreDataConverter` for the given instances
403
+ // of `Firestore` and `PublicFirestoreDataConverter` so that isEqual() will
404
+ // compare equal for two objects created with the same converter instance.
405
+ static getInstance(firestore, converter) {
406
+ const converterMapByFirestore = FirestoreDataConverter.INSTANCES;
407
+ let untypedConverterByConverter = converterMapByFirestore.get(firestore);
408
+ if (!untypedConverterByConverter) {
409
+ untypedConverterByConverter = new WeakMap();
410
+ converterMapByFirestore.set(firestore, untypedConverterByConverter);
411
+ }
412
+ let instance = untypedConverterByConverter.get(converter);
413
+ if (!instance) {
414
+ instance = new FirestoreDataConverter(firestore, new UserDataWriter(firestore), converter);
415
+ untypedConverterByConverter.set(converter, instance);
416
+ }
417
+ return instance;
418
+ }
419
+ }
420
+ FirestoreDataConverter.INSTANCES = new WeakMap();
421
+ /**
422
+ * A reference to a particular document in a collection in the database.
423
+ */
424
+ class DocumentReference {
425
+ constructor(firestore, _delegate) {
426
+ this.firestore = firestore;
427
+ this._delegate = _delegate;
428
+ this._userDataWriter = new UserDataWriter(firestore);
429
+ }
430
+ static forPath(path, firestore, converter) {
431
+ if (path.length % 2 !== 0) {
432
+ throw new FirestoreError('invalid-argument', 'Invalid document reference. Document ' +
433
+ 'references must have an even number of segments, but ' +
434
+ `${path.canonicalString()} has ${path.length}`);
435
+ }
436
+ return new DocumentReference(firestore, new DocumentReference$1(firestore._delegate, converter, new _DocumentKey(path)));
437
+ }
438
+ static forKey(key, firestore, converter) {
439
+ return new DocumentReference(firestore, new DocumentReference$1(firestore._delegate, converter, key));
440
+ }
441
+ get id() {
442
+ return this._delegate.id;
443
+ }
444
+ get parent() {
445
+ return new CollectionReference(this.firestore, this._delegate.parent);
446
+ }
447
+ get path() {
448
+ return this._delegate.path;
449
+ }
450
+ collection(pathString) {
451
+ try {
452
+ return new CollectionReference(this.firestore, collection(this._delegate, pathString));
453
+ }
454
+ catch (e) {
455
+ throw replaceFunctionName(e, 'collection()', 'DocumentReference.collection()');
456
+ }
457
+ }
458
+ isEqual(other) {
459
+ other = getModularInstance(other);
460
+ if (!(other instanceof DocumentReference$1)) {
461
+ return false;
462
+ }
463
+ return refEqual(this._delegate, other);
464
+ }
465
+ set(value, options) {
466
+ options = validateSetOptions('DocumentReference.set', options);
467
+ try {
468
+ if (options) {
469
+ return setDoc(this._delegate, value, options);
470
+ }
471
+ else {
472
+ return setDoc(this._delegate, value);
473
+ }
474
+ }
475
+ catch (e) {
476
+ throw replaceFunctionName(e, 'setDoc()', 'DocumentReference.set()');
477
+ }
478
+ }
479
+ update(fieldOrUpdateData, value, ...moreFieldsAndValues) {
480
+ try {
481
+ if (arguments.length === 1) {
482
+ return updateDoc(this._delegate, fieldOrUpdateData);
483
+ }
484
+ else {
485
+ return updateDoc(this._delegate, fieldOrUpdateData, value, ...moreFieldsAndValues);
486
+ }
487
+ }
488
+ catch (e) {
489
+ throw replaceFunctionName(e, 'updateDoc()', 'DocumentReference.update()');
490
+ }
491
+ }
492
+ delete() {
493
+ return deleteDoc(this._delegate);
494
+ }
495
+ onSnapshot(...args) {
496
+ const options = extractSnapshotOptions(args);
497
+ const observer = wrapObserver(args, result => new DocumentSnapshot(this.firestore, new DocumentSnapshot$1(this.firestore._delegate, this._userDataWriter, result._key, result._document, result.metadata, this._delegate.converter)));
498
+ return onSnapshot(this._delegate, options, observer);
499
+ }
500
+ get(options) {
501
+ let snap;
502
+ if (options?.source === 'cache') {
503
+ snap = getDocFromCache(this._delegate);
504
+ }
505
+ else if (options?.source === 'server') {
506
+ snap = getDocFromServer(this._delegate);
507
+ }
508
+ else {
509
+ snap = getDoc(this._delegate);
510
+ }
511
+ return snap.then(result => new DocumentSnapshot(this.firestore, new DocumentSnapshot$1(this.firestore._delegate, this._userDataWriter, result._key, result._document, result.metadata, this._delegate.converter)));
512
+ }
513
+ withConverter(converter) {
514
+ return new DocumentReference(this.firestore, converter
515
+ ? this._delegate.withConverter(FirestoreDataConverter.getInstance(this.firestore, converter))
516
+ : this._delegate.withConverter(null));
517
+ }
518
+ }
519
+ /**
520
+ * Replaces the function name in an error thrown by the firestore-exp API
521
+ * with the function names used in the classic API.
522
+ */
523
+ function replaceFunctionName(e, original, updated) {
524
+ e.message = e.message.replace(original, updated);
525
+ return e;
526
+ }
527
+ /**
528
+ * Iterates the list of arguments from an `onSnapshot` call and returns the
529
+ * first argument that may be an `SnapshotListenOptions` object. Returns an
530
+ * empty object if none is found.
531
+ */
532
+ function extractSnapshotOptions(args) {
533
+ for (const arg of args) {
534
+ if (typeof arg === 'object' && !isPartialObserver(arg)) {
535
+ return arg;
536
+ }
537
+ }
538
+ return {};
539
+ }
540
+ /**
541
+ * Creates an observer that can be passed to the firestore-exp SDK. The
542
+ * observer converts all observed values into the format expected by the classic
543
+ * SDK.
544
+ *
545
+ * @param args - The list of arguments from an `onSnapshot` call.
546
+ * @param wrapper - The function that converts the firestore-exp type into the
547
+ * type used by this shim.
548
+ */
549
+ function wrapObserver(args, wrapper) {
550
+ let userObserver;
551
+ if (isPartialObserver(args[0])) {
552
+ userObserver = args[0];
553
+ }
554
+ else if (isPartialObserver(args[1])) {
555
+ userObserver = args[1];
556
+ }
557
+ else if (typeof args[0] === 'function') {
558
+ userObserver = {
559
+ next: args[0],
560
+ error: args[1],
561
+ complete: args[2]
562
+ };
563
+ }
564
+ else {
565
+ userObserver = {
566
+ next: args[1],
567
+ error: args[2],
568
+ complete: args[3]
569
+ };
570
+ }
571
+ return {
572
+ next: val => {
573
+ if (userObserver.next) {
574
+ userObserver.next(wrapper(val));
575
+ }
576
+ },
577
+ error: userObserver.error?.bind(userObserver),
578
+ complete: userObserver.complete?.bind(userObserver)
579
+ };
580
+ }
581
+ class DocumentSnapshot {
582
+ constructor(_firestore, _delegate) {
583
+ this._firestore = _firestore;
584
+ this._delegate = _delegate;
585
+ }
586
+ get ref() {
587
+ return new DocumentReference(this._firestore, this._delegate.ref);
588
+ }
589
+ get id() {
590
+ return this._delegate.id;
591
+ }
592
+ get metadata() {
593
+ return this._delegate.metadata;
594
+ }
595
+ get exists() {
596
+ return this._delegate.exists();
597
+ }
598
+ data(options) {
599
+ return this._delegate.data(options);
600
+ }
601
+ get(fieldPath, options
602
+ // We are using `any` here to avoid an explicit cast by our users.
603
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
604
+ ) {
605
+ return this._delegate.get(fieldPath, options);
606
+ }
607
+ isEqual(other) {
608
+ return snapshotEqual(this._delegate, other._delegate);
609
+ }
610
+ }
611
+ class QueryDocumentSnapshot extends DocumentSnapshot {
612
+ data(options) {
613
+ const data = this._delegate.data(options);
614
+ if (this._delegate._converter) {
615
+ // Undefined is a possible valid value from converter.
616
+ return data;
617
+ }
618
+ else {
619
+ _debugAssert(data !== undefined, 'Document in a QueryDocumentSnapshot should exist');
620
+ return data;
621
+ }
622
+ }
623
+ }
624
+ class Query {
625
+ constructor(firestore, _delegate) {
626
+ this.firestore = firestore;
627
+ this._delegate = _delegate;
628
+ this._userDataWriter = new UserDataWriter(firestore);
629
+ }
630
+ where(fieldPath, opStr, value) {
631
+ try {
632
+ // The "as string" cast is a little bit of a hack. `where` accepts the
633
+ // FieldPath Compat type as input, but is not typed as such in order to
634
+ // not expose this via our public typings file.
635
+ return new Query(this.firestore, query(this._delegate, where(fieldPath, opStr, value)));
636
+ }
637
+ catch (e) {
638
+ throw replaceFunctionName(e, /(orderBy|where)\(\)/, 'Query.$1()');
639
+ }
640
+ }
641
+ orderBy(fieldPath, directionStr) {
642
+ try {
643
+ // The "as string" cast is a little bit of a hack. `orderBy` accepts the
644
+ // FieldPath Compat type as input, but is not typed as such in order to
645
+ // not expose this via our public typings file.
646
+ return new Query(this.firestore, query(this._delegate, orderBy(fieldPath, directionStr)));
647
+ }
648
+ catch (e) {
649
+ throw replaceFunctionName(e, /(orderBy|where)\(\)/, 'Query.$1()');
650
+ }
651
+ }
652
+ limit(n) {
653
+ try {
654
+ return new Query(this.firestore, query(this._delegate, limit(n)));
655
+ }
656
+ catch (e) {
657
+ throw replaceFunctionName(e, 'limit()', 'Query.limit()');
658
+ }
659
+ }
660
+ limitToLast(n) {
661
+ try {
662
+ return new Query(this.firestore, query(this._delegate, limitToLast(n)));
663
+ }
664
+ catch (e) {
665
+ throw replaceFunctionName(e, 'limitToLast()', 'Query.limitToLast()');
666
+ }
667
+ }
668
+ startAt(...args) {
669
+ try {
670
+ return new Query(this.firestore, query(this._delegate, startAt(...args)));
671
+ }
672
+ catch (e) {
673
+ throw replaceFunctionName(e, 'startAt()', 'Query.startAt()');
674
+ }
675
+ }
676
+ startAfter(...args) {
677
+ try {
678
+ return new Query(this.firestore, query(this._delegate, startAfter(...args)));
679
+ }
680
+ catch (e) {
681
+ throw replaceFunctionName(e, 'startAfter()', 'Query.startAfter()');
682
+ }
683
+ }
684
+ endBefore(...args) {
685
+ try {
686
+ return new Query(this.firestore, query(this._delegate, endBefore(...args)));
687
+ }
688
+ catch (e) {
689
+ throw replaceFunctionName(e, 'endBefore()', 'Query.endBefore()');
690
+ }
691
+ }
692
+ endAt(...args) {
693
+ try {
694
+ return new Query(this.firestore, query(this._delegate, endAt(...args)));
695
+ }
696
+ catch (e) {
697
+ throw replaceFunctionName(e, 'endAt()', 'Query.endAt()');
698
+ }
699
+ }
700
+ isEqual(other) {
701
+ return queryEqual(this._delegate, other._delegate);
702
+ }
703
+ get(options) {
704
+ let query;
705
+ if (options?.source === 'cache') {
706
+ query = getDocsFromCache(this._delegate);
707
+ }
708
+ else if (options?.source === 'server') {
709
+ query = getDocsFromServer(this._delegate);
710
+ }
711
+ else {
712
+ query = getDocs(this._delegate);
713
+ }
714
+ return query.then(result => new QuerySnapshot(this.firestore, new QuerySnapshot$1(this.firestore._delegate, this._userDataWriter, this._delegate, result._snapshot)));
715
+ }
716
+ onSnapshot(...args) {
717
+ const options = extractSnapshotOptions(args);
718
+ const observer = wrapObserver(args, snap => new QuerySnapshot(this.firestore, new QuerySnapshot$1(this.firestore._delegate, this._userDataWriter, this._delegate, snap._snapshot)));
719
+ return onSnapshot(this._delegate, options, observer);
720
+ }
721
+ withConverter(converter) {
722
+ return new Query(this.firestore, converter
723
+ ? this._delegate.withConverter(FirestoreDataConverter.getInstance(this.firestore, converter))
724
+ : this._delegate.withConverter(null));
725
+ }
726
+ }
727
+ class DocumentChange {
728
+ constructor(_firestore, _delegate) {
729
+ this._firestore = _firestore;
730
+ this._delegate = _delegate;
731
+ }
732
+ get type() {
733
+ return this._delegate.type;
734
+ }
735
+ get doc() {
736
+ return new QueryDocumentSnapshot(this._firestore, this._delegate.doc);
737
+ }
738
+ get oldIndex() {
739
+ return this._delegate.oldIndex;
740
+ }
741
+ get newIndex() {
742
+ return this._delegate.newIndex;
743
+ }
744
+ }
745
+ class QuerySnapshot {
746
+ constructor(_firestore, _delegate) {
747
+ this._firestore = _firestore;
748
+ this._delegate = _delegate;
749
+ }
750
+ get query() {
751
+ return new Query(this._firestore, this._delegate.query);
752
+ }
753
+ get metadata() {
754
+ return this._delegate.metadata;
755
+ }
756
+ get size() {
757
+ return this._delegate.size;
758
+ }
759
+ get empty() {
760
+ return this._delegate.empty;
761
+ }
762
+ get docs() {
763
+ return this._delegate.docs.map(doc => new QueryDocumentSnapshot(this._firestore, doc));
764
+ }
765
+ docChanges(options) {
766
+ return this._delegate
767
+ .docChanges(options)
768
+ .map(docChange => new DocumentChange(this._firestore, docChange));
769
+ }
770
+ forEach(callback, thisArg) {
771
+ this._delegate.forEach(snapshot => {
772
+ callback.call(thisArg, new QueryDocumentSnapshot(this._firestore, snapshot));
773
+ });
774
+ }
775
+ isEqual(other) {
776
+ return snapshotEqual(this._delegate, other._delegate);
777
+ }
778
+ }
779
+ class CollectionReference extends Query {
780
+ constructor(firestore, _delegate) {
781
+ super(firestore, _delegate);
782
+ this.firestore = firestore;
783
+ this._delegate = _delegate;
784
+ }
785
+ get id() {
786
+ return this._delegate.id;
787
+ }
788
+ get path() {
789
+ return this._delegate.path;
790
+ }
791
+ get parent() {
792
+ const docRef = this._delegate.parent;
793
+ return docRef ? new DocumentReference(this.firestore, docRef) : null;
794
+ }
795
+ doc(documentPath) {
796
+ try {
797
+ if (documentPath === undefined) {
798
+ // Call `doc` without `documentPath` if `documentPath` is `undefined`
799
+ // as `doc` validates the number of arguments to prevent users from
800
+ // accidentally passing `undefined`.
801
+ return new DocumentReference(this.firestore, doc(this._delegate));
802
+ }
803
+ else {
804
+ return new DocumentReference(this.firestore, doc(this._delegate, documentPath));
805
+ }
806
+ }
807
+ catch (e) {
808
+ throw replaceFunctionName(e, 'doc()', 'CollectionReference.doc()');
809
+ }
810
+ }
811
+ add(data) {
812
+ return addDoc(this._delegate, data).then(docRef => new DocumentReference(this.firestore, docRef));
813
+ }
814
+ isEqual(other) {
815
+ return refEqual(this._delegate, other._delegate);
816
+ }
817
+ withConverter(converter) {
818
+ return new CollectionReference(this.firestore, converter
819
+ ? this._delegate.withConverter(FirestoreDataConverter.getInstance(this.firestore, converter))
820
+ : this._delegate.withConverter(null));
821
+ }
822
+ }
823
+ function castReference(documentRef) {
824
+ return _cast(documentRef, DocumentReference$1);
817
825
  }
818
826
 
819
- /**
820
- * @license
821
- * Copyright 2017 Google LLC
822
- *
823
- * Licensed under the Apache License, Version 2.0 (the "License");
824
- * you may not use this file except in compliance with the License.
825
- * You may obtain a copy of the License at
826
- *
827
- * http://www.apache.org/licenses/LICENSE-2.0
828
- *
829
- * Unless required by applicable law or agreed to in writing, software
830
- * distributed under the License is distributed on an "AS IS" BASIS,
831
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
832
- * See the License for the specific language governing permissions and
833
- * limitations under the License.
834
- */
835
- // The objects that are a part of this API are exposed to third-parties as
836
- // compiled javascript so we want to flag our private members with a leading
837
- // underscore to discourage their use.
838
- /**
839
- * A `FieldPath` refers to a field in a document. The path may consist of a
840
- * single field name (referring to a top-level field in the document), or a list
841
- * of field names (referring to a nested field in the document).
842
- */
843
- class FieldPath {
844
- /**
845
- * Creates a FieldPath from the provided field names. If more than one field
846
- * name is provided, the path will point to a nested field in a document.
847
- *
848
- * @param fieldNames - A list of field names.
849
- */
850
- constructor(...fieldNames) {
851
- this._delegate = new FieldPath$1(...fieldNames);
852
- }
853
- static documentId() {
854
- /**
855
- * Internal Note: The backend doesn't technically support querying by
856
- * document ID. Instead it queries by the entire document name (full path
857
- * included), but in the cases we currently support documentId(), the net
858
- * effect is the same.
859
- */
860
- return new FieldPath(_FieldPath.keyField().canonicalString());
861
- }
862
- isEqual(other) {
863
- other = getModularInstance(other);
864
- if (!(other instanceof FieldPath$1)) {
865
- return false;
866
- }
867
- return this._delegate._internalPath.isEqual(other._internalPath);
868
- }
827
+ /**
828
+ * @license
829
+ * Copyright 2017 Google LLC
830
+ *
831
+ * Licensed under the Apache License, Version 2.0 (the "License");
832
+ * you may not use this file except in compliance with the License.
833
+ * You may obtain a copy of the License at
834
+ *
835
+ * http://www.apache.org/licenses/LICENSE-2.0
836
+ *
837
+ * Unless required by applicable law or agreed to in writing, software
838
+ * distributed under the License is distributed on an "AS IS" BASIS,
839
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
840
+ * See the License for the specific language governing permissions and
841
+ * limitations under the License.
842
+ */
843
+ // The objects that are a part of this API are exposed to third-parties as
844
+ // compiled javascript so we want to flag our private members with a leading
845
+ // underscore to discourage their use.
846
+ /**
847
+ * A `FieldPath` refers to a field in a document. The path may consist of a
848
+ * single field name (referring to a top-level field in the document), or a list
849
+ * of field names (referring to a nested field in the document).
850
+ */
851
+ class FieldPath {
852
+ /**
853
+ * Creates a FieldPath from the provided field names. If more than one field
854
+ * name is provided, the path will point to a nested field in a document.
855
+ *
856
+ * @param fieldNames - A list of field names.
857
+ */
858
+ constructor(...fieldNames) {
859
+ this._delegate = new FieldPath$1(...fieldNames);
860
+ }
861
+ static documentId() {
862
+ /**
863
+ * Internal Note: The backend doesn't technically support querying by
864
+ * document ID. Instead it queries by the entire document name (full path
865
+ * included), but in the cases we currently support documentId(), the net
866
+ * effect is the same.
867
+ */
868
+ return new FieldPath(_FieldPath.keyField().canonicalString());
869
+ }
870
+ isEqual(other) {
871
+ other = getModularInstance(other);
872
+ if (!(other instanceof FieldPath$1)) {
873
+ return false;
874
+ }
875
+ return this._delegate._internalPath.isEqual(other._internalPath);
876
+ }
869
877
  }
870
878
 
871
- /**
872
- * @license
873
- * Copyright 2017 Google LLC
874
- *
875
- * Licensed under the Apache License, Version 2.0 (the "License");
876
- * you may not use this file except in compliance with the License.
877
- * You may obtain a copy of the License at
878
- *
879
- * http://www.apache.org/licenses/LICENSE-2.0
880
- *
881
- * Unless required by applicable law or agreed to in writing, software
882
- * distributed under the License is distributed on an "AS IS" BASIS,
883
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
884
- * See the License for the specific language governing permissions and
885
- * limitations under the License.
886
- */
887
- class FieldValue {
888
- constructor(_delegate) {
889
- this._delegate = _delegate;
890
- }
891
- static serverTimestamp() {
892
- const delegate = serverTimestamp();
893
- delegate._methodName = 'FieldValue.serverTimestamp';
894
- return new FieldValue(delegate);
895
- }
896
- static delete() {
897
- const delegate = deleteField();
898
- delegate._methodName = 'FieldValue.delete';
899
- return new FieldValue(delegate);
900
- }
901
- static arrayUnion(...elements) {
902
- const delegate = arrayUnion(...elements);
903
- delegate._methodName = 'FieldValue.arrayUnion';
904
- return new FieldValue(delegate);
905
- }
906
- static arrayRemove(...elements) {
907
- const delegate = arrayRemove(...elements);
908
- delegate._methodName = 'FieldValue.arrayRemove';
909
- return new FieldValue(delegate);
910
- }
911
- static increment(n) {
912
- const delegate = increment(n);
913
- delegate._methodName = 'FieldValue.increment';
914
- return new FieldValue(delegate);
915
- }
916
- isEqual(other) {
917
- return this._delegate.isEqual(other._delegate);
918
- }
879
+ /**
880
+ * @license
881
+ * Copyright 2017 Google LLC
882
+ *
883
+ * Licensed under the Apache License, Version 2.0 (the "License");
884
+ * you may not use this file except in compliance with the License.
885
+ * You may obtain a copy of the License at
886
+ *
887
+ * http://www.apache.org/licenses/LICENSE-2.0
888
+ *
889
+ * Unless required by applicable law or agreed to in writing, software
890
+ * distributed under the License is distributed on an "AS IS" BASIS,
891
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
892
+ * See the License for the specific language governing permissions and
893
+ * limitations under the License.
894
+ */
895
+ class FieldValue {
896
+ static serverTimestamp() {
897
+ const delegate = serverTimestamp();
898
+ delegate._methodName = 'FieldValue.serverTimestamp';
899
+ return new FieldValue(delegate);
900
+ }
901
+ static delete() {
902
+ const delegate = deleteField();
903
+ delegate._methodName = 'FieldValue.delete';
904
+ return new FieldValue(delegate);
905
+ }
906
+ static arrayUnion(...elements) {
907
+ const delegate = arrayUnion(...elements);
908
+ delegate._methodName = 'FieldValue.arrayUnion';
909
+ return new FieldValue(delegate);
910
+ }
911
+ static arrayRemove(...elements) {
912
+ const delegate = arrayRemove(...elements);
913
+ delegate._methodName = 'FieldValue.arrayRemove';
914
+ return new FieldValue(delegate);
915
+ }
916
+ static increment(n) {
917
+ const delegate = increment(n);
918
+ delegate._methodName = 'FieldValue.increment';
919
+ return new FieldValue(delegate);
920
+ }
921
+ constructor(_delegate) {
922
+ this._delegate = _delegate;
923
+ }
924
+ isEqual(other) {
925
+ return this._delegate.isEqual(other._delegate);
926
+ }
919
927
  }
920
928
 
921
- /**
922
- * @license
923
- * Copyright 2021 Google LLC
924
- *
925
- * Licensed under the Apache License, Version 2.0 (the "License");
926
- * you may not use this file except in compliance with the License.
927
- * You may obtain a copy of the License at
928
- *
929
- * http://www.apache.org/licenses/LICENSE-2.0
930
- *
931
- * Unless required by applicable law or agreed to in writing, software
932
- * distributed under the License is distributed on an "AS IS" BASIS,
933
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
934
- * See the License for the specific language governing permissions and
935
- * limitations under the License.
936
- */
937
- const firestoreNamespace = {
938
- Firestore,
939
- GeoPoint,
940
- Timestamp,
941
- Blob,
942
- Transaction,
943
- WriteBatch,
944
- DocumentReference,
945
- DocumentSnapshot,
946
- Query,
947
- QueryDocumentSnapshot,
948
- QuerySnapshot,
949
- CollectionReference,
950
- FieldPath,
951
- FieldValue,
952
- setLogLevel,
953
- CACHE_SIZE_UNLIMITED
954
- };
955
- /**
956
- * Configures Firestore as part of the Firebase SDK by calling registerComponent.
957
- *
958
- * @param firebase - The FirebaseNamespace to register Firestore with
959
- * @param firestoreFactory - A factory function that returns a new Firestore
960
- * instance.
961
- */
962
- function configureForFirebase(firebase, firestoreFactory) {
963
- firebase.INTERNAL.registerComponent(new Component('firestore-compat', container => {
964
- const app = container.getProvider('app-compat').getImmediate();
965
- const firestoreExp = container.getProvider('firestore').getImmediate();
966
- return firestoreFactory(app, firestoreExp);
967
- }, 'PUBLIC').setServiceProps(Object.assign({}, firestoreNamespace)));
929
+ /**
930
+ * @license
931
+ * Copyright 2021 Google LLC
932
+ *
933
+ * Licensed under the Apache License, Version 2.0 (the "License");
934
+ * you may not use this file except in compliance with the License.
935
+ * You may obtain a copy of the License at
936
+ *
937
+ * http://www.apache.org/licenses/LICENSE-2.0
938
+ *
939
+ * Unless required by applicable law or agreed to in writing, software
940
+ * distributed under the License is distributed on an "AS IS" BASIS,
941
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
942
+ * See the License for the specific language governing permissions and
943
+ * limitations under the License.
944
+ */
945
+ const firestoreNamespace = {
946
+ Firestore,
947
+ GeoPoint,
948
+ Timestamp,
949
+ Blob,
950
+ Transaction,
951
+ WriteBatch,
952
+ DocumentReference,
953
+ DocumentSnapshot,
954
+ Query,
955
+ QueryDocumentSnapshot,
956
+ QuerySnapshot,
957
+ CollectionReference,
958
+ FieldPath,
959
+ FieldValue,
960
+ setLogLevel,
961
+ CACHE_SIZE_UNLIMITED
962
+ };
963
+ /**
964
+ * Configures Firestore as part of the Firebase SDK by calling registerComponent.
965
+ *
966
+ * @param firebase - The FirebaseNamespace to register Firestore with
967
+ * @param firestoreFactory - A factory function that returns a new Firestore
968
+ * instance.
969
+ */
970
+ function configureForFirebase(firebase, firestoreFactory) {
971
+ firebase.INTERNAL.registerComponent(new Component('firestore-compat', container => {
972
+ const app = container.getProvider('app-compat').getImmediate();
973
+ const firestoreExp = container.getProvider('firestore').getImmediate();
974
+ return firestoreFactory(app, firestoreExp);
975
+ }, 'PUBLIC').setServiceProps({ ...firestoreNamespace }));
968
976
  }
969
977
 
970
- /**
971
- * @license
972
- * Copyright 2020 Google LLC
973
- *
974
- * Licensed under the Apache License, Version 2.0 (the "License");
975
- * you may not use this file except in compliance with the License.
976
- * You may obtain a copy of the License at
977
- *
978
- * http://www.apache.org/licenses/LICENSE-2.0
979
- *
980
- * Unless required by applicable law or agreed to in writing, software
981
- * distributed under the License is distributed on an "AS IS" BASIS,
982
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
983
- * See the License for the specific language governing permissions and
984
- * limitations under the License.
985
- */
986
- /**
987
- * Registers the main Firestore build with the components framework.
988
- * Persistence can be enabled via `firebase.firestore().enablePersistence()`.
989
- */
990
- function registerFirestore(instance) {
991
- configureForFirebase(instance, (app, firestoreExp) => new Firestore(app, firestoreExp, new IndexedDbPersistenceProvider()));
992
- instance.registerVersion(name, version);
993
- }
978
+ /**
979
+ * @license
980
+ * Copyright 2020 Google LLC
981
+ *
982
+ * Licensed under the Apache License, Version 2.0 (the "License");
983
+ * you may not use this file except in compliance with the License.
984
+ * You may obtain a copy of the License at
985
+ *
986
+ * http://www.apache.org/licenses/LICENSE-2.0
987
+ *
988
+ * Unless required by applicable law or agreed to in writing, software
989
+ * distributed under the License is distributed on an "AS IS" BASIS,
990
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
991
+ * See the License for the specific language governing permissions and
992
+ * limitations under the License.
993
+ */
994
+ /**
995
+ * Registers the main Firestore build with the components framework.
996
+ * Persistence can be enabled via `firebase.firestore().enablePersistence()`.
997
+ */
998
+ function registerFirestore(instance) {
999
+ configureForFirebase(instance, (app, firestoreExp) => new Firestore(app, firestoreExp, new IndexedDbPersistenceProvider()));
1000
+ instance.registerVersion(name, version);
1001
+ }
994
1002
  registerFirestore(firebase);
995
1003
 
996
1004
  export { registerFirestore };
997
- //# sourceMappingURL=index.esm2017.js.map
1005
+ //# sourceMappingURL=index.esm.js.map