@firebase/firestore 4.4.3-canary.6d487d7de → 4.4.3-canary.ce88e71e7
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/firestore/src/api/reference_impl.d.ts +12 -0
- package/dist/firestore/src/api.d.ts +1 -1
- package/dist/firestore/src/core/event_manager.d.ts +26 -4
- package/dist/firestore/src/core/sync_engine_impl.d.ts +6 -2
- package/dist/firestore/src/global_index.d.ts +17 -3
- package/dist/firestore/src/local/shared_client_state.d.ts +1 -1
- package/dist/firestore/test/integration/api/query.test.d.ts +2 -1
- package/dist/firestore/test/integration/api/snasphot_listener_source.test.d.ts +17 -0
- package/dist/firestore/test/unit/specs/bundle_spec.test.d.ts +19 -0
- package/dist/firestore/test/unit/specs/listen_source_spec.test.d.ts +17 -0
- package/dist/firestore/test/unit/specs/spec_builder.d.ts +10 -1
- package/dist/firestore/test/unit/specs/spec_test_runner.d.ts +2 -0
- package/dist/index.cjs.js +587 -514
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +12 -0
- package/dist/index.esm2017.js +587 -514
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +1635 -1520
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +131 -35
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +131 -35
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +589 -516
- package/dist/index.rn.js.map +1 -1
- package/dist/internal.d.ts +17 -2
- package/dist/lite/firestore/src/api/reference_impl.d.ts +12 -0
- package/dist/lite/firestore/src/api.d.ts +1 -1
- package/dist/lite/firestore/src/core/event_manager.d.ts +26 -4
- package/dist/lite/firestore/src/core/sync_engine_impl.d.ts +6 -2
- package/dist/lite/firestore/src/local/shared_client_state.d.ts +1 -1
- package/dist/lite/firestore/test/integration/api/query.test.d.ts +2 -1
- package/dist/lite/firestore/test/integration/api/snasphot_listener_source.test.d.ts +17 -0
- package/dist/lite/firestore/test/unit/specs/bundle_spec.test.d.ts +19 -0
- package/dist/lite/firestore/test/unit/specs/listen_source_spec.test.d.ts +17 -0
- package/dist/lite/firestore/test/unit/specs/spec_builder.d.ts +10 -1
- package/dist/lite/firestore/test/unit/specs/spec_test_runner.d.ts +2 -0
- package/dist/lite/index.browser.esm2017.js +2 -2
- package/dist/lite/index.browser.esm5.js +2 -2
- package/dist/lite/index.cjs.js +2 -2
- package/dist/lite/index.node.cjs.js +2 -2
- package/dist/lite/index.node.mjs +2 -2
- package/dist/lite/index.rn.esm2017.js +2 -2
- package/dist/lite/internal.d.ts +4 -2
- package/dist/lite/packages/firestore/src/api/reference_impl.d.ts +12 -0
- package/dist/lite/packages/firestore/src/api.d.ts +1 -1
- package/dist/lite/packages/firestore/src/core/event_manager.d.ts +26 -4
- package/dist/lite/packages/firestore/src/core/sync_engine_impl.d.ts +6 -2
- package/dist/lite/packages/firestore/src/local/shared_client_state.d.ts +1 -1
- package/dist/lite/packages/firestore/test/integration/api/query.test.d.ts +2 -1
- package/dist/lite/packages/firestore/test/integration/api/snasphot_listener_source.test.d.ts +17 -0
- package/dist/lite/packages/firestore/test/unit/specs/bundle_spec.test.d.ts +19 -0
- package/dist/lite/packages/firestore/test/unit/specs/listen_source_spec.test.d.ts +17 -0
- package/dist/lite/packages/firestore/test/unit/specs/spec_builder.d.ts +10 -1
- package/dist/lite/packages/firestore/test/unit/specs/spec_test_runner.d.ts +2 -0
- package/dist/lite/private.d.ts +4 -2
- package/dist/packages/firestore/dist/index.esm2017.d.ts +69 -69
- package/dist/packages/firestore/src/api/reference_impl.d.ts +12 -0
- package/dist/packages/firestore/src/api.d.ts +1 -1
- package/dist/packages/firestore/src/core/event_manager.d.ts +26 -4
- package/dist/packages/firestore/src/core/sync_engine_impl.d.ts +6 -2
- package/dist/packages/firestore/src/local/shared_client_state.d.ts +1 -1
- package/dist/packages/firestore/test/integration/api/query.test.d.ts +2 -1
- package/dist/packages/firestore/test/integration/api/snasphot_listener_source.test.d.ts +17 -0
- package/dist/packages/firestore/test/unit/specs/bundle_spec.test.d.ts +19 -0
- package/dist/packages/firestore/test/unit/specs/listen_source_spec.test.d.ts +17 -0
- package/dist/packages/firestore/test/unit/specs/spec_builder.d.ts +10 -1
- package/dist/packages/firestore/test/unit/specs/spec_test_runner.d.ts +2 -0
- package/dist/private.d.ts +17 -2
- package/package.json +9 -9
package/dist/index.cjs.js
CHANGED
|
@@ -70,7 +70,7 @@ User.MOCK_USER = new User("mock-user");
|
|
|
70
70
|
* See the License for the specific language governing permissions and
|
|
71
71
|
* limitations under the License.
|
|
72
72
|
*/
|
|
73
|
-
let S = "10.8.1-canary.
|
|
73
|
+
let S = "10.8.1-canary.ce88e71e7";
|
|
74
74
|
|
|
75
75
|
/**
|
|
76
76
|
* @license
|
|
@@ -1736,10 +1736,10 @@ class __PRIVATE_SimpleDbTransaction {
|
|
|
1736
1736
|
__PRIVATE_logDebug("SimpleDb", "Database upgrade to version " + this.version + " complete");
|
|
1737
1737
|
}));
|
|
1738
1738
|
};
|
|
1739
|
-
}))), this.
|
|
1739
|
+
}))), this.L && (this.db.onversionchange = e => this.L(e)), this.db;
|
|
1740
1740
|
}
|
|
1741
|
-
|
|
1742
|
-
this.
|
|
1741
|
+
B(e) {
|
|
1742
|
+
this.L = e, this.db && (this.db.onversionchange = t => e(t));
|
|
1743
1743
|
}
|
|
1744
1744
|
async runTransaction(e, t, n, r) {
|
|
1745
1745
|
const i = "readonly" === t;
|
|
@@ -2305,7 +2305,7 @@ function __PRIVATE_newDbDocumentMutationPrefixForPath(e, t) {
|
|
|
2305
2305
|
* there is no useful information to store as the value. The raw (unencoded)
|
|
2306
2306
|
* path cannot be stored because IndexedDb doesn't store prototype
|
|
2307
2307
|
* information.
|
|
2308
|
-
*/ const x = {}, O = [ "prefixPath", "collectionGroup", "readTime", "documentId" ], N = [ "prefixPath", "collectionGroup", "documentId" ],
|
|
2308
|
+
*/ const x = {}, O = [ "prefixPath", "collectionGroup", "readTime", "documentId" ], N = [ "prefixPath", "collectionGroup", "documentId" ], L = [ "collectionGroup", "readTime", "prefixPath", "documentId" ], B = [ "canonicalId", "targetId" ], k = [ "targetId", "path" ], q = [ "path", "targetId" ], Q = [ "collectionId", "parent" ], K = [ "indexId", "uid" ], $ = [ "uid", "sequenceNumber" ], U = [ "indexId", "uid", "arrayValue", "directionalValue", "orderedDocumentKey", "documentKey" ], W = [ "indexId", "uid", "orderedDocumentKey" ], G = [ "userId", "collectionPath", "documentId" ], z = [ "userId", "collectionPath", "largestBatchId" ], j = [ "userId", "collectionGroup", "largestBatchId" ], H = [ ...[ ...[ ...[ ...[ "mutationQueues", "mutations", "documentMutations", "remoteDocuments", "targets", "owner", "targetGlobal", "targetDocuments" ], "clientMetadata" ], "remoteDocumentGlobal" ], "collectionParents" ], "bundles", "namedQueries" ], J = [ ...H, "documentOverlays" ], Y = [ "mutationQueues", "mutations", "documentMutations", "remoteDocumentsV14", "targets", "owner", "targetGlobal", "targetDocuments", "clientMetadata", "remoteDocumentGlobal", "collectionParents", "bundles", "namedQueries", "documentOverlays" ], Z = Y, X = [ ...Z, "indexConfiguration", "indexState", "indexEntries" ];
|
|
2309
2309
|
|
|
2310
2310
|
/**
|
|
2311
2311
|
* @license
|
|
@@ -5848,16 +5848,16 @@ class BloomFilter {
|
|
|
5848
5848
|
throw new __PRIVATE_BloomFilterError(`Invalid padding when bitmap length is 0: ${t}`);
|
|
5849
5849
|
this.Te = 8 * e.length - t,
|
|
5850
5850
|
// Set the bit count in Integer to avoid repetition in mightContain().
|
|
5851
|
-
this.
|
|
5851
|
+
this.Ee = webchannelWrapper.Integer.fromNumber(this.Te);
|
|
5852
5852
|
}
|
|
5853
5853
|
// Calculate the ith hash value based on the hashed 64bit integers,
|
|
5854
5854
|
// and calculate its corresponding bit index in the bitmap to be checked.
|
|
5855
|
-
|
|
5855
|
+
de(e, t, n) {
|
|
5856
5856
|
// Calculate hashed value h(i) = h1 + (i * h2).
|
|
5857
5857
|
let r = e.add(t.multiply(webchannelWrapper.Integer.fromNumber(n)));
|
|
5858
5858
|
// Wrap if hash value overflow 64bit.
|
|
5859
5859
|
return 1 === r.compare(le) && (r = new webchannelWrapper.Integer([ r.getBits(0), r.getBits(1) ], 0)),
|
|
5860
|
-
r.modulo(this.
|
|
5860
|
+
r.modulo(this.Ee).toNumber();
|
|
5861
5861
|
}
|
|
5862
5862
|
// Return whether the bit on the given index in the bitmap is set to 1.
|
|
5863
5863
|
Ae(e) {
|
|
@@ -5868,7 +5868,7 @@ class BloomFilter {
|
|
|
5868
5868
|
if (0 === this.Te) return !1;
|
|
5869
5869
|
const t = __PRIVATE_getMd5HashValue(e), [n, r] = __PRIVATE_get64BitUints(t);
|
|
5870
5870
|
for (let e = 0; e < this.hashCount; e++) {
|
|
5871
|
-
const t = this.
|
|
5871
|
+
const t = this.de(n, r, e);
|
|
5872
5872
|
if (!this.Ae(t)) return !1;
|
|
5873
5873
|
}
|
|
5874
5874
|
return !0;
|
|
@@ -5881,7 +5881,7 @@ class BloomFilter {
|
|
|
5881
5881
|
if (0 === this.Te) return;
|
|
5882
5882
|
const t = __PRIVATE_getMd5HashValue(e), [n, r] = __PRIVATE_get64BitUints(t);
|
|
5883
5883
|
for (let e = 0; e < this.hashCount; e++) {
|
|
5884
|
-
const t = this.
|
|
5884
|
+
const t = this.de(n, r, e);
|
|
5885
5885
|
this.Re(t);
|
|
5886
5886
|
}
|
|
5887
5887
|
}
|
|
@@ -6161,7 +6161,7 @@ class __PRIVATE_WatchTargetChange {
|
|
|
6161
6161
|
Ne() {
|
|
6162
6162
|
this.ge -= 1, __PRIVATE_hardAssert(this.ge >= 0);
|
|
6163
6163
|
}
|
|
6164
|
-
|
|
6164
|
+
Le() {
|
|
6165
6165
|
this.Se = !0, this.we = !0;
|
|
6166
6166
|
}
|
|
6167
6167
|
}
|
|
@@ -6171,7 +6171,7 @@ class __PRIVATE_WatchTargetChange {
|
|
|
6171
6171
|
*/
|
|
6172
6172
|
class __PRIVATE_WatchChangeAggregator {
|
|
6173
6173
|
constructor(e) {
|
|
6174
|
-
this.
|
|
6174
|
+
this.Be = e,
|
|
6175
6175
|
/** The internal state of all tracked targets. */
|
|
6176
6176
|
this.ke = new Map,
|
|
6177
6177
|
/** Keeps track of the documents to update since the last raised snapshot. */
|
|
@@ -6218,7 +6218,7 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6218
6218
|
break;
|
|
6219
6219
|
|
|
6220
6220
|
case 3 /* WatchTargetChangeState.Current */ :
|
|
6221
|
-
this.je(t) && (n.
|
|
6221
|
+
this.je(t) && (n.Le(), n.Ce(e.resumeToken));
|
|
6222
6222
|
break;
|
|
6223
6223
|
|
|
6224
6224
|
case 4 /* WatchTargetChangeState.Reset */ :
|
|
@@ -6309,7 +6309,7 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6309
6309
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
6310
6310
|
* See the License for the specific language governing permissions and
|
|
6311
6311
|
* limitations under the License.
|
|
6312
|
-
*/ (r, e.fe, this.
|
|
6312
|
+
*/ (r, e.fe, this.Be.nt(), n, i));
|
|
6313
6313
|
}
|
|
6314
6314
|
}
|
|
6315
6315
|
}
|
|
@@ -6348,10 +6348,10 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6348
6348
|
* Filter out removed documents based on bloom filter membership result and
|
|
6349
6349
|
* return number of documents removed.
|
|
6350
6350
|
*/ rt(e, t) {
|
|
6351
|
-
const n = this.
|
|
6351
|
+
const n = this.Be.getRemoteKeysForTarget(t);
|
|
6352
6352
|
let r = 0;
|
|
6353
6353
|
return n.forEach((n => {
|
|
6354
|
-
const i = this.
|
|
6354
|
+
const i = this.Be.nt(), s = `projects/${i.projectId}/databases/${i.database}/documents/${n.path.canonicalString()}`;
|
|
6355
6355
|
e.mightContain(s) || (this.We(t, n, /*updatedDocument=*/ null), r++);
|
|
6356
6356
|
})), r;
|
|
6357
6357
|
}
|
|
@@ -6431,7 +6431,7 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6431
6431
|
* target as well as any accumulated changes.
|
|
6432
6432
|
*/ Ze(e) {
|
|
6433
6433
|
const t = this.ze(e).ve();
|
|
6434
|
-
return this.
|
|
6434
|
+
return this.Be.getRemoteKeysForTarget(e).size + t.addedDocuments.size - t.removedDocuments.size;
|
|
6435
6435
|
}
|
|
6436
6436
|
/**
|
|
6437
6437
|
* Increment the number of acks needed from watch before we can consider the
|
|
@@ -6462,7 +6462,7 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6462
6462
|
* is still interested in that has no outstanding target change requests).
|
|
6463
6463
|
*/ Ye(e) {
|
|
6464
6464
|
const t = this.ke.get(e);
|
|
6465
|
-
return t && t.be ? null : this.
|
|
6465
|
+
return t && t.be ? null : this.Be._t(e);
|
|
6466
6466
|
}
|
|
6467
6467
|
/**
|
|
6468
6468
|
* Resets the state of a Watch target to its initial state (e.g. sets
|
|
@@ -6470,7 +6470,7 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6470
6470
|
* from all documents).
|
|
6471
6471
|
*/ He(e) {
|
|
6472
6472
|
this.ke.set(e, new __PRIVATE_TargetState);
|
|
6473
|
-
this.
|
|
6473
|
+
this.Be.getRemoteKeysForTarget(e).forEach((t => {
|
|
6474
6474
|
this.We(e, t, /*updatedDocument=*/ null);
|
|
6475
6475
|
}));
|
|
6476
6476
|
}
|
|
@@ -6478,7 +6478,7 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6478
6478
|
* Returns whether the LocalStore considers the document to be part of the
|
|
6479
6479
|
* specified target.
|
|
6480
6480
|
*/ st(e, t) {
|
|
6481
|
-
return this.
|
|
6481
|
+
return this.Be.getRemoteKeysForTarget(e).has(t);
|
|
6482
6482
|
}
|
|
6483
6483
|
}
|
|
6484
6484
|
|
|
@@ -7602,52 +7602,52 @@ class __PRIVATE_FirestoreIndexValueWriter {
|
|
|
7602
7602
|
t.Tt();
|
|
7603
7603
|
}
|
|
7604
7604
|
It(e, t) {
|
|
7605
|
-
if ("nullValue" in e) this.
|
|
7606
|
-
t.
|
|
7605
|
+
if ("nullValue" in e) this.Et(t, 5); else if ("booleanValue" in e) this.Et(t, 10),
|
|
7606
|
+
t.dt(e.booleanValue ? 1 : 0); else if ("integerValue" in e) this.Et(t, 15), t.dt(__PRIVATE_normalizeNumber(e.integerValue)); else if ("doubleValue" in e) {
|
|
7607
7607
|
const n = __PRIVATE_normalizeNumber(e.doubleValue);
|
|
7608
|
-
isNaN(n) ? this.
|
|
7608
|
+
isNaN(n) ? this.Et(t, 13) : (this.Et(t, 15), __PRIVATE_isNegativeZero(n) ?
|
|
7609
7609
|
// -0.0, 0 and 0.0 are all considered the same
|
|
7610
|
-
t.
|
|
7610
|
+
t.dt(0) : t.dt(n));
|
|
7611
7611
|
} else if ("timestampValue" in e) {
|
|
7612
7612
|
const n = e.timestampValue;
|
|
7613
|
-
this.
|
|
7614
|
-
} else if ("stringValue" in e) this.Rt(e.stringValue, t), this.Vt(t); else if ("bytesValue" in e) this.
|
|
7613
|
+
this.Et(t, 20), "string" == typeof n ? t.At(n) : (t.At(`${n.seconds || ""}`), t.dt(n.nanos || 0));
|
|
7614
|
+
} else if ("stringValue" in e) this.Rt(e.stringValue, t), this.Vt(t); else if ("bytesValue" in e) this.Et(t, 30),
|
|
7615
7615
|
t.ft(__PRIVATE_normalizeByteString(e.bytesValue)), this.Vt(t); else if ("referenceValue" in e) this.gt(e.referenceValue, t); else if ("geoPointValue" in e) {
|
|
7616
7616
|
const n = e.geoPointValue;
|
|
7617
|
-
this.
|
|
7618
|
-
} else "mapValue" in e ? __PRIVATE_isMaxValue(e) ? this.
|
|
7617
|
+
this.Et(t, 45), t.dt(n.latitude || 0), t.dt(n.longitude || 0);
|
|
7618
|
+
} else "mapValue" in e ? __PRIVATE_isMaxValue(e) ? this.Et(t, Number.MAX_SAFE_INTEGER) : (this.yt(e.mapValue, t),
|
|
7619
7619
|
this.Vt(t)) : "arrayValue" in e ? (this.wt(e.arrayValue, t), this.Vt(t)) : fail();
|
|
7620
7620
|
}
|
|
7621
7621
|
Rt(e, t) {
|
|
7622
|
-
this.
|
|
7622
|
+
this.Et(t, 25), this.St(e, t);
|
|
7623
7623
|
}
|
|
7624
7624
|
St(e, t) {
|
|
7625
7625
|
t.At(e);
|
|
7626
7626
|
}
|
|
7627
7627
|
yt(e, t) {
|
|
7628
7628
|
const n = e.fields || {};
|
|
7629
|
-
this.
|
|
7629
|
+
this.Et(t, 55);
|
|
7630
7630
|
for (const e of Object.keys(n)) this.Rt(e, t), this.It(n[e], t);
|
|
7631
7631
|
}
|
|
7632
7632
|
wt(e, t) {
|
|
7633
7633
|
const n = e.values || [];
|
|
7634
|
-
this.
|
|
7634
|
+
this.Et(t, 50);
|
|
7635
7635
|
for (const e of n) this.It(e, t);
|
|
7636
7636
|
}
|
|
7637
7637
|
gt(e, t) {
|
|
7638
|
-
this.
|
|
7638
|
+
this.Et(t, 37);
|
|
7639
7639
|
DocumentKey.fromName(e).path.forEach((e => {
|
|
7640
|
-
this.
|
|
7640
|
+
this.Et(t, 60), this.St(e, t);
|
|
7641
7641
|
}));
|
|
7642
7642
|
}
|
|
7643
|
-
|
|
7644
|
-
e.
|
|
7643
|
+
Et(e, t) {
|
|
7644
|
+
e.dt(t);
|
|
7645
7645
|
}
|
|
7646
7646
|
Vt(e) {
|
|
7647
7647
|
// While the SDK does not implement truncation, the truncation marker is
|
|
7648
7648
|
// used to terminate all variable length values (which are strings, bytes,
|
|
7649
7649
|
// references, arrays and maps).
|
|
7650
|
-
e.
|
|
7650
|
+
e.dt(2);
|
|
7651
7651
|
}
|
|
7652
7652
|
}
|
|
7653
7653
|
|
|
@@ -7733,10 +7733,10 @@ function __PRIVATE_unsignedNumLength(e) {
|
|
|
7733
7733
|
}
|
|
7734
7734
|
this.xt();
|
|
7735
7735
|
}
|
|
7736
|
-
|
|
7736
|
+
Lt(e) {
|
|
7737
7737
|
// Values are encoded with a single byte length prefix, followed by the
|
|
7738
7738
|
// actual value in big-endian format with leading 0 bytes dropped.
|
|
7739
|
-
const t = this.
|
|
7739
|
+
const t = this.Bt(e), n = __PRIVATE_unsignedNumLength(t);
|
|
7740
7740
|
this.kt(1 + n), this.buffer[this.position++] = 255 & n;
|
|
7741
7741
|
// Write the length
|
|
7742
7742
|
for (let e = t.length - n; e < t.length; ++e) this.buffer[this.position++] = 255 & t[e];
|
|
@@ -7744,7 +7744,7 @@ function __PRIVATE_unsignedNumLength(e) {
|
|
|
7744
7744
|
qt(e) {
|
|
7745
7745
|
// Values are encoded with a single byte length prefix, followed by the
|
|
7746
7746
|
// inverted value in big-endian format with leading 0 bytes dropped.
|
|
7747
|
-
const t = this.
|
|
7747
|
+
const t = this.Bt(e), n = __PRIVATE_unsignedNumLength(t);
|
|
7748
7748
|
this.kt(1 + n), this.buffer[this.position++] = ~(255 & n);
|
|
7749
7749
|
// Write the length
|
|
7750
7750
|
for (let e = t.length - n; e < t.length; ++e) this.buffer[this.position++] = ~(255 & t[e]);
|
|
@@ -7779,7 +7779,7 @@ function __PRIVATE_unsignedNumLength(e) {
|
|
|
7779
7779
|
* -0.0 < 0.0
|
|
7780
7780
|
* all non-NaN < NaN
|
|
7781
7781
|
* NaN = NaN
|
|
7782
|
-
*/
|
|
7782
|
+
*/ Bt(e) {
|
|
7783
7783
|
const t =
|
|
7784
7784
|
/** Converts a JavaScript number to a byte array (using big endian encoding). */
|
|
7785
7785
|
function __PRIVATE_doubleToLongBits(e) {
|
|
@@ -7837,8 +7837,8 @@ class __PRIVATE_AscendingIndexByteEncoder {
|
|
|
7837
7837
|
At(e) {
|
|
7838
7838
|
this.Gt.Ot(e);
|
|
7839
7839
|
}
|
|
7840
|
-
|
|
7841
|
-
this.Gt.
|
|
7840
|
+
dt(e) {
|
|
7841
|
+
this.Gt.Lt(e);
|
|
7842
7842
|
}
|
|
7843
7843
|
Tt() {
|
|
7844
7844
|
this.Gt.Qt();
|
|
@@ -7855,7 +7855,7 @@ class __PRIVATE_DescendingIndexByteEncoder {
|
|
|
7855
7855
|
At(e) {
|
|
7856
7856
|
this.Gt.Nt(e);
|
|
7857
7857
|
}
|
|
7858
|
-
|
|
7858
|
+
dt(e) {
|
|
7859
7859
|
this.Gt.qt(e);
|
|
7860
7860
|
}
|
|
7861
7861
|
Tt() {
|
|
@@ -8586,17 +8586,17 @@ class __PRIVATE_IndexedDbIndexManager {
|
|
|
8586
8586
|
// combined with the values from the query bounds.
|
|
8587
8587
|
const _ = (null != t ? t.length : 1) * Math.max(n.length, i.length), a = _ / (null != t ? t.length : 1), u = [];
|
|
8588
8588
|
for (let c = 0; c < _; ++c) {
|
|
8589
|
-
const _ = t ? this.Tn(t[c / a]) : Te, l = this.
|
|
8589
|
+
const _ = t ? this.Tn(t[c / a]) : Te, l = this.En(e, _, n[c % a], r), h = this.dn(e, _, i[c % a], s), P = o.map((t => this.En(e, _, t,
|
|
8590
8590
|
/* inclusive= */ !0)));
|
|
8591
8591
|
u.push(...this.createRange(l, h, P));
|
|
8592
8592
|
}
|
|
8593
8593
|
return u;
|
|
8594
8594
|
}
|
|
8595
|
-
/** Generates the lower bound for `arrayValue` and `directionalValue`. */
|
|
8595
|
+
/** Generates the lower bound for `arrayValue` and `directionalValue`. */ En(e, t, n, r) {
|
|
8596
8596
|
const i = new __PRIVATE_IndexEntry(e, DocumentKey.empty(), t, n);
|
|
8597
8597
|
return r ? i : i.Jt();
|
|
8598
8598
|
}
|
|
8599
|
-
/** Generates the upper bound for `arrayValue` and `directionalValue`. */
|
|
8599
|
+
/** Generates the upper bound for `arrayValue` and `directionalValue`. */ dn(e, t, n, r) {
|
|
8600
8600
|
const i = new __PRIVATE_IndexEntry(e, DocumentKey.empty(), t, n);
|
|
8601
8601
|
return r ? i.Jt() : i;
|
|
8602
8602
|
}
|
|
@@ -8926,7 +8926,7 @@ function __PRIVATE_getMinOffsetFromFieldIndexes(e) {
|
|
|
8926
8926
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
8927
8927
|
* See the License for the specific language governing permissions and
|
|
8928
8928
|
* limitations under the License.
|
|
8929
|
-
*/ const
|
|
8929
|
+
*/ const Ee = {
|
|
8930
8930
|
didRun: !1,
|
|
8931
8931
|
sequenceNumbersCollected: 0,
|
|
8932
8932
|
targetsRemoved: 0,
|
|
@@ -9354,7 +9354,7 @@ class __PRIVATE_TargetIdGenerator {
|
|
|
9354
9354
|
// '0', the backend would consider it unset and replace it with its own ID.
|
|
9355
9355
|
return new __PRIVATE_TargetIdGenerator(0);
|
|
9356
9356
|
}
|
|
9357
|
-
static
|
|
9357
|
+
static Ln() {
|
|
9358
9358
|
// Sync engine assigns target IDs for limbo document detection.
|
|
9359
9359
|
return new __PRIVATE_TargetIdGenerator(-1);
|
|
9360
9360
|
}
|
|
@@ -9386,30 +9386,30 @@ class __PRIVATE_TargetIdGenerator {
|
|
|
9386
9386
|
// to IndexedDb whenever we need to read metadata. We can revisit if it turns
|
|
9387
9387
|
// out to have a meaningful performance impact.
|
|
9388
9388
|
allocateTargetId(e) {
|
|
9389
|
-
return this.
|
|
9389
|
+
return this.Bn(e).next((t => {
|
|
9390
9390
|
const n = new __PRIVATE_TargetIdGenerator(t.highestTargetId);
|
|
9391
9391
|
return t.highestTargetId = n.next(), this.kn(e, t).next((() => t.highestTargetId));
|
|
9392
9392
|
}));
|
|
9393
9393
|
}
|
|
9394
9394
|
getLastRemoteSnapshotVersion(e) {
|
|
9395
|
-
return this.
|
|
9395
|
+
return this.Bn(e).next((e => SnapshotVersion.fromTimestamp(new Timestamp(e.lastRemoteSnapshotVersion.seconds, e.lastRemoteSnapshotVersion.nanoseconds))));
|
|
9396
9396
|
}
|
|
9397
9397
|
getHighestSequenceNumber(e) {
|
|
9398
|
-
return this.
|
|
9398
|
+
return this.Bn(e).next((e => e.highestListenSequenceNumber));
|
|
9399
9399
|
}
|
|
9400
9400
|
setTargetsMetadata(e, t, n) {
|
|
9401
|
-
return this.
|
|
9401
|
+
return this.Bn(e).next((r => (r.highestListenSequenceNumber = t, n && (r.lastRemoteSnapshotVersion = n.toTimestamp()),
|
|
9402
9402
|
t > r.highestListenSequenceNumber && (r.highestListenSequenceNumber = t), this.kn(e, r))));
|
|
9403
9403
|
}
|
|
9404
9404
|
addTargetData(e, t) {
|
|
9405
|
-
return this.qn(e, t).next((() => this.
|
|
9405
|
+
return this.qn(e, t).next((() => this.Bn(e).next((n => (n.targetCount += 1, this.Qn(t, n),
|
|
9406
9406
|
this.kn(e, n))))));
|
|
9407
9407
|
}
|
|
9408
9408
|
updateTargetData(e, t) {
|
|
9409
9409
|
return this.qn(e, t);
|
|
9410
9410
|
}
|
|
9411
9411
|
removeTargetData(e, t) {
|
|
9412
|
-
return this.removeMatchingKeysForTargetId(e, t.targetId).next((() => __PRIVATE_targetsStore(e).delete(t.targetId))).next((() => this.
|
|
9412
|
+
return this.removeMatchingKeysForTargetId(e, t.targetId).next((() => __PRIVATE_targetsStore(e).delete(t.targetId))).next((() => this.Bn(e))).next((t => (__PRIVATE_hardAssert(t.targetCount > 0),
|
|
9413
9413
|
t.targetCount -= 1, this.kn(e, t))));
|
|
9414
9414
|
}
|
|
9415
9415
|
/**
|
|
@@ -9432,7 +9432,7 @@ class __PRIVATE_TargetIdGenerator {
|
|
|
9432
9432
|
t(r);
|
|
9433
9433
|
}));
|
|
9434
9434
|
}
|
|
9435
|
-
|
|
9435
|
+
Bn(e) {
|
|
9436
9436
|
return __PRIVATE_globalTargetStore(e).get("targetGlobalKey").next((e => (__PRIVATE_hardAssert(null !== e),
|
|
9437
9437
|
e)));
|
|
9438
9438
|
}
|
|
@@ -9453,7 +9453,7 @@ class __PRIVATE_TargetIdGenerator {
|
|
|
9453
9453
|
n = !0), n;
|
|
9454
9454
|
}
|
|
9455
9455
|
getTargetCount(e) {
|
|
9456
|
-
return this.
|
|
9456
|
+
return this.Bn(e).next((e => e.targetCount));
|
|
9457
9457
|
}
|
|
9458
9458
|
getTargetData(e, t) {
|
|
9459
9459
|
// Iterating by the canonicalId may yield more than one result because
|
|
@@ -9659,8 +9659,8 @@ class __PRIVATE_TargetIdGenerator {
|
|
|
9659
9659
|
}
|
|
9660
9660
|
collect(e, t) {
|
|
9661
9661
|
return -1 === this.params.cacheSizeCollectionThreshold ? (__PRIVATE_logDebug("LruGarbageCollector", "Garbage collection skipped; disabled"),
|
|
9662
|
-
PersistencePromise.resolve(
|
|
9663
|
-
|
|
9662
|
+
PersistencePromise.resolve(Ee)) : this.getCacheSize(e).next((n => n < this.params.cacheSizeCollectionThreshold ? (__PRIVATE_logDebug("LruGarbageCollector", `Garbage collection skipped; Cache size ${n} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),
|
|
9663
|
+
Ee) : this.Yn(e, t)));
|
|
9664
9664
|
}
|
|
9665
9665
|
getCacheSize(e) {
|
|
9666
9666
|
return this.jn.getCacheSize(e);
|
|
@@ -10702,7 +10702,7 @@ class OverlayedDocument {
|
|
|
10702
10702
|
// A set of outstanding references to a document sorted by key.
|
|
10703
10703
|
this.Pr = new SortedSet(__PRIVATE_DocReference.Ir),
|
|
10704
10704
|
// A set of outstanding references to a document sorted by target id.
|
|
10705
|
-
this.Tr = new SortedSet(__PRIVATE_DocReference.
|
|
10705
|
+
this.Tr = new SortedSet(__PRIVATE_DocReference.Er);
|
|
10706
10706
|
}
|
|
10707
10707
|
/** Returns true if the reference set contains no references. */ isEmpty() {
|
|
10708
10708
|
return this.Pr.isEmpty();
|
|
@@ -10711,7 +10711,7 @@ class OverlayedDocument {
|
|
|
10711
10711
|
const n = new __PRIVATE_DocReference(e, t);
|
|
10712
10712
|
this.Pr = this.Pr.add(n), this.Tr = this.Tr.add(n);
|
|
10713
10713
|
}
|
|
10714
|
-
/** Add references to the given document keys for the given ID. */
|
|
10714
|
+
/** Add references to the given document keys for the given ID. */ dr(e, t) {
|
|
10715
10715
|
e.forEach((e => this.addReference(e, t)));
|
|
10716
10716
|
}
|
|
10717
10717
|
/**
|
|
@@ -10758,7 +10758,7 @@ class __PRIVATE_DocReference {
|
|
|
10758
10758
|
/** Compare by key then by ID */ static Ir(e, t) {
|
|
10759
10759
|
return DocumentKey.comparator(e.key, t.key) || __PRIVATE_primitiveComparator(e.pr, t.pr);
|
|
10760
10760
|
}
|
|
10761
|
-
/** Compare by ID then by key */ static
|
|
10761
|
+
/** Compare by ID then by key */ static Er(e, t) {
|
|
10762
10762
|
return __PRIVATE_primitiveComparator(e.pr, t.pr) || DocumentKey.comparator(e.key, t.key);
|
|
10763
10763
|
}
|
|
10764
10764
|
}
|
|
@@ -11087,7 +11087,7 @@ class __PRIVATE_MemoryRemoteDocumentChangeBuffer extends RemoteDocumentChangeBuf
|
|
|
11087
11087
|
* A ordered bidirectional mapping between documents and the remote target
|
|
11088
11088
|
* IDs.
|
|
11089
11089
|
*/
|
|
11090
|
-
this.Nr = new __PRIVATE_ReferenceSet, this.targetCount = 0, this.
|
|
11090
|
+
this.Nr = new __PRIVATE_ReferenceSet, this.targetCount = 0, this.Lr = __PRIVATE_TargetIdGenerator.Nn();
|
|
11091
11091
|
}
|
|
11092
11092
|
forEachTarget(e, t) {
|
|
11093
11093
|
return this.Mr.forEach(((e, n) => t(n))), PersistencePromise.resolve();
|
|
@@ -11099,7 +11099,7 @@ class __PRIVATE_MemoryRemoteDocumentChangeBuffer extends RemoteDocumentChangeBuf
|
|
|
11099
11099
|
return PersistencePromise.resolve(this.Or);
|
|
11100
11100
|
}
|
|
11101
11101
|
allocateTargetId(e) {
|
|
11102
|
-
return this.highestTargetId = this.
|
|
11102
|
+
return this.highestTargetId = this.Lr.next(), PersistencePromise.resolve(this.highestTargetId);
|
|
11103
11103
|
}
|
|
11104
11104
|
setTargetsMetadata(e, t, n) {
|
|
11105
11105
|
return n && (this.lastRemoteSnapshotVersion = n), t > this.Or && (this.Or = t),
|
|
@@ -11108,7 +11108,7 @@ class __PRIVATE_MemoryRemoteDocumentChangeBuffer extends RemoteDocumentChangeBuf
|
|
|
11108
11108
|
qn(e) {
|
|
11109
11109
|
this.Mr.set(e.target, e);
|
|
11110
11110
|
const t = e.targetId;
|
|
11111
|
-
t > this.highestTargetId && (this.
|
|
11111
|
+
t > this.highestTargetId && (this.Lr = new __PRIVATE_TargetIdGenerator(t), this.highestTargetId = t),
|
|
11112
11112
|
e.sequenceNumber > this.Or && (this.Or = e.sequenceNumber);
|
|
11113
11113
|
}
|
|
11114
11114
|
addTargetData(e, t) {
|
|
@@ -11137,7 +11137,7 @@ class __PRIVATE_MemoryRemoteDocumentChangeBuffer extends RemoteDocumentChangeBuf
|
|
|
11137
11137
|
return PersistencePromise.resolve(n);
|
|
11138
11138
|
}
|
|
11139
11139
|
addMatchingKeys(e, t, n) {
|
|
11140
|
-
return this.Nr.
|
|
11140
|
+
return this.Nr.dr(t, n), PersistencePromise.resolve();
|
|
11141
11141
|
}
|
|
11142
11142
|
removeMatchingKeys(e, t, n) {
|
|
11143
11143
|
this.Nr.Rr(t, n);
|
|
@@ -11186,7 +11186,7 @@ class __PRIVATE_MemoryPersistence {
|
|
|
11186
11186
|
* checked or asserted on every access.
|
|
11187
11187
|
*/
|
|
11188
11188
|
constructor(e, t) {
|
|
11189
|
-
this.
|
|
11189
|
+
this.Br = {}, this.overlays = {}, this.kr = new __PRIVATE_ListenSequence(0), this.qr = !1,
|
|
11190
11190
|
this.qr = !0, this.referenceDelegate = e(this), this.Qr = new __PRIVATE_MemoryTargetCache(this);
|
|
11191
11191
|
this.indexManager = new __PRIVATE_MemoryIndexManager, this.remoteDocumentCache = function __PRIVATE_newMemoryRemoteDocumentCache(e) {
|
|
11192
11192
|
return new __PRIVATE_MemoryRemoteDocumentCacheImpl(e);
|
|
@@ -11220,8 +11220,8 @@ class __PRIVATE_MemoryPersistence {
|
|
|
11220
11220
|
t;
|
|
11221
11221
|
}
|
|
11222
11222
|
getMutationQueue(e, t) {
|
|
11223
|
-
let n = this.
|
|
11224
|
-
return n || (n = new __PRIVATE_MemoryMutationQueue(t, this.referenceDelegate), this.
|
|
11223
|
+
let n = this.Br[e.toKey()];
|
|
11224
|
+
return n || (n = new __PRIVATE_MemoryMutationQueue(t, this.referenceDelegate), this.Br[e.toKey()] = n),
|
|
11225
11225
|
n;
|
|
11226
11226
|
}
|
|
11227
11227
|
getTargetCache() {
|
|
@@ -11240,7 +11240,7 @@ class __PRIVATE_MemoryPersistence {
|
|
|
11240
11240
|
e)));
|
|
11241
11241
|
}
|
|
11242
11242
|
Gr(e, t) {
|
|
11243
|
-
return PersistencePromise.or(Object.values(this.
|
|
11243
|
+
return PersistencePromise.or(Object.values(this.Br).map((n => () => n.containsKey(e, t))));
|
|
11244
11244
|
}
|
|
11245
11245
|
}
|
|
11246
11246
|
|
|
@@ -11513,7 +11513,7 @@ class __PRIVATE_MemoryLruDelegate {
|
|
|
11513
11513
|
const t = e.createObjectStore("remoteDocumentsV14", {
|
|
11514
11514
|
keyPath: O
|
|
11515
11515
|
});
|
|
11516
|
-
t.createIndex("documentKeyIndex", N), t.createIndex("collectionGroupIndex",
|
|
11516
|
+
t.createIndex("documentKeyIndex", N), t.createIndex("collectionGroupIndex", L);
|
|
11517
11517
|
}(e))).next((() => this.ii(e, i))).next((() => e.deleteObjectStore("remoteDocuments")))),
|
|
11518
11518
|
n < 14 && r >= 14 && (s = s.next((() => this.si(e, i)))), n < 15 && r >= 15 && (s = s.next((() => function __PRIVATE_createFieldIndex(e) {
|
|
11519
11519
|
e.createObjectStore("indexConfiguration", {
|
|
@@ -11670,12 +11670,12 @@ function __PRIVATE_createQueryCache(e) {
|
|
|
11670
11670
|
// NOTE: This is unique only because the TargetId is the suffix.
|
|
11671
11671
|
e.createObjectStore("targets", {
|
|
11672
11672
|
keyPath: "targetId"
|
|
11673
|
-
}).createIndex("queryTargetsIndex",
|
|
11673
|
+
}).createIndex("queryTargetsIndex", B, {
|
|
11674
11674
|
unique: !0
|
|
11675
11675
|
}), e.createObjectStore("targetGlobal");
|
|
11676
11676
|
}
|
|
11677
11677
|
|
|
11678
|
-
const
|
|
11678
|
+
const de = "Failed to obtain exclusive access to the persistence layer. To allow shared access, multi-tab synchronization has to be enabled in all tabs. If you are using `experimentalForceOwningTab:true`, make sure that only one tab has persistence enabled at any given time.";
|
|
11679
11679
|
|
|
11680
11680
|
/**
|
|
11681
11681
|
* Oldest acceptable age in milliseconds for client metadata before the client
|
|
@@ -11753,10 +11753,10 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
11753
11753
|
/** A listener to notify on primary state changes. */
|
|
11754
11754
|
this.Ii = e => Promise.resolve(), !__PRIVATE_IndexedDbPersistence.D()) throw new FirestoreError(D.UNIMPLEMENTED, "This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");
|
|
11755
11755
|
this.referenceDelegate = new __PRIVATE_IndexedDbLruDelegateImpl(this, r), this.Ti = t + "main",
|
|
11756
|
-
this.serializer = new __PRIVATE_LocalSerializer(_), this.
|
|
11756
|
+
this.serializer = new __PRIVATE_LocalSerializer(_), this.Ei = new __PRIVATE_SimpleDb(this.Ti, this.ui, new __PRIVATE_SchemaConverter(this.serializer)),
|
|
11757
11757
|
this.Qr = new __PRIVATE_IndexedDbTargetCache(this.referenceDelegate, this.serializer),
|
|
11758
11758
|
this.remoteDocumentCache = __PRIVATE_newIndexedDbRemoteDocumentCache(this.serializer),
|
|
11759
|
-
this.$r = new __PRIVATE_IndexedDbBundleCache, this.window && this.window.localStorage ? this.
|
|
11759
|
+
this.$r = new __PRIVATE_IndexedDbBundleCache, this.window && this.window.localStorage ? this.di = this.window.localStorage : (this.di = null,
|
|
11760
11760
|
!1 === u && __PRIVATE_logError("IndexedDbPersistence", "LocalStorage is unavailable. As a result, persistence may not work reliably. In particular enablePersistence() could fail immediately after refreshing the page."));
|
|
11761
11761
|
}
|
|
11762
11762
|
/**
|
|
@@ -11771,13 +11771,13 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
11771
11771
|
if (!this.isPrimary && !this.allowTabSynchronization)
|
|
11772
11772
|
// Fail `start()` if `synchronizeTabs` is disabled and we cannot
|
|
11773
11773
|
// obtain the primary lease.
|
|
11774
|
-
throw new FirestoreError(D.FAILED_PRECONDITION,
|
|
11774
|
+
throw new FirestoreError(D.FAILED_PRECONDITION, de);
|
|
11775
11775
|
return this.Ri(), this.Vi(), this.mi(), this.runTransaction("getHighestListenSequenceNumber", "readonly", (e => this.Qr.getHighestSequenceNumber(e)));
|
|
11776
11776
|
})).then((e => {
|
|
11777
11777
|
this.kr = new __PRIVATE_ListenSequence(e, this._i);
|
|
11778
11778
|
})).then((() => {
|
|
11779
11779
|
this.qr = !0;
|
|
11780
|
-
})).catch((e => (this.
|
|
11780
|
+
})).catch((e => (this.Ei && this.Ei.close(), Promise.reject(e))));
|
|
11781
11781
|
}
|
|
11782
11782
|
/**
|
|
11783
11783
|
* Registers a listener that gets called when the primary state of the
|
|
@@ -11796,7 +11796,7 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
11796
11796
|
*
|
|
11797
11797
|
* PORTING NOTE: This is only used for Web multi-tab.
|
|
11798
11798
|
*/ setDatabaseDeletedListener(e) {
|
|
11799
|
-
this.
|
|
11799
|
+
this.Ei.B((async t => {
|
|
11800
11800
|
// Check if an attempt is made to delete IndexedDB.
|
|
11801
11801
|
null === t.newVersion && await e();
|
|
11802
11802
|
}));
|
|
@@ -11868,7 +11868,7 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
11868
11868
|
// Ideally we'd delete the IndexedDb and LocalStorage zombie entries for
|
|
11869
11869
|
// the client atomically, but we can't. So we opt to delete the IndexedDb
|
|
11870
11870
|
// entries first to avoid potentially reviving a zombied client.
|
|
11871
|
-
if (this.
|
|
11871
|
+
if (this.di) for (const t of e) this.di.removeItem(this.Fi(t.clientId));
|
|
11872
11872
|
}
|
|
11873
11873
|
}
|
|
11874
11874
|
/**
|
|
@@ -11913,7 +11913,7 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
11913
11913
|
// settings is not supported.
|
|
11914
11914
|
// TODO(b/114226234): Remove this check when `synchronizeTabs` can
|
|
11915
11915
|
// no longer be turned off.
|
|
11916
|
-
throw new FirestoreError(D.FAILED_PRECONDITION,
|
|
11916
|
+
throw new FirestoreError(D.FAILED_PRECONDITION, de);
|
|
11917
11917
|
return !1;
|
|
11918
11918
|
}
|
|
11919
11919
|
}
|
|
@@ -11934,13 +11934,13 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
11934
11934
|
this.Ni(),
|
|
11935
11935
|
// Use `SimpleDb.runTransaction` directly to avoid failing if another tab
|
|
11936
11936
|
// has obtained the primary lease.
|
|
11937
|
-
await this.
|
|
11937
|
+
await this.Ei.runTransaction("shutdown", "readwrite", [ "owner", "clientMetadata" ], (e => {
|
|
11938
11938
|
const t = new __PRIVATE_IndexedDbTransaction(e, __PRIVATE_ListenSequence._e);
|
|
11939
11939
|
return this.yi(t).next((() => this.bi(t)));
|
|
11940
|
-
})), this.
|
|
11940
|
+
})), this.Ei.close(),
|
|
11941
11941
|
// Remove the entry marking the client as zombied from LocalStorage since
|
|
11942
11942
|
// we successfully deleted its metadata from IndexedDb.
|
|
11943
|
-
this.
|
|
11943
|
+
this.Li();
|
|
11944
11944
|
}
|
|
11945
11945
|
/**
|
|
11946
11946
|
* Returns clients that are not zombied and have an updateTime within the
|
|
@@ -11954,7 +11954,7 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
11954
11954
|
* ID.
|
|
11955
11955
|
*
|
|
11956
11956
|
* PORTING NOTE: This is only used for Web multi-tab.
|
|
11957
|
-
*/
|
|
11957
|
+
*/ Bi() {
|
|
11958
11958
|
return this.runTransaction("getActiveClients", "readonly", (e => __PRIVATE_clientMetadataStore(e).W().next((e => this.vi(e, 18e5).map((e => e.clientId))))));
|
|
11959
11959
|
}
|
|
11960
11960
|
get started() {
|
|
@@ -11988,7 +11988,7 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
11988
11988
|
let s;
|
|
11989
11989
|
// Do all transactions as readwrite against all object stores, since we
|
|
11990
11990
|
// are the only reader/writer.
|
|
11991
|
-
return this.
|
|
11991
|
+
return this.Ei.runTransaction(e, r, i, (r => (s = new __PRIVATE_IndexedDbTransaction(r, this.kr ? this.kr.next() : __PRIVATE_ListenSequence._e),
|
|
11992
11992
|
"readwrite-primary" === t ? this.gi(s).next((e => !!e || this.pi(s))).next((t => {
|
|
11993
11993
|
if (!t) throw __PRIVATE_logError(`Failed to obtain primary lease for action '${e}'.`),
|
|
11994
11994
|
this.isPrimary = !1, this.oi.enqueueRetryable((() => this.Ii(!1))), new FirestoreError(D.FAILED_PRECONDITION, v);
|
|
@@ -12004,7 +12004,7 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12004
12004
|
// be turned off.
|
|
12005
12005
|
ki(e) {
|
|
12006
12006
|
return __PRIVATE_primaryClientStore(e).get("owner").next((e => {
|
|
12007
|
-
if (null !== e && this.Ci(e.leaseTimestampMs, 5e3) && !this.Mi(e.ownerId) && !this.Si(e) && !(this.ai || this.allowTabSynchronization && e.allowTabSynchronization)) throw new FirestoreError(D.FAILED_PRECONDITION,
|
|
12007
|
+
if (null !== e && this.Ci(e.leaseTimestampMs, 5e3) && !this.Mi(e.ownerId) && !this.Si(e) && !(this.ai || this.allowTabSynchronization && e.allowTabSynchronization)) throw new FirestoreError(D.FAILED_PRECONDITION, de);
|
|
12008
12008
|
}));
|
|
12009
12009
|
}
|
|
12010
12010
|
/**
|
|
@@ -12075,7 +12075,7 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12075
12075
|
*/ Mi(e) {
|
|
12076
12076
|
var t;
|
|
12077
12077
|
try {
|
|
12078
|
-
const n = null !== (null === (t = this.
|
|
12078
|
+
const n = null !== (null === (t = this.di) || void 0 === t ? void 0 : t.getItem(this.Fi(e)));
|
|
12079
12079
|
return __PRIVATE_logDebug("IndexedDbPersistence", `Client '${e}' ${n ? "is" : "is not"} zombied in LocalStorage`),
|
|
12080
12080
|
n;
|
|
12081
12081
|
} catch (e) {
|
|
@@ -12088,16 +12088,16 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12088
12088
|
* Record client as zombied (a client that had its tab closed). Zombied
|
|
12089
12089
|
* clients are ignored during primary tab selection.
|
|
12090
12090
|
*/ xi() {
|
|
12091
|
-
if (this.
|
|
12092
|
-
this.
|
|
12091
|
+
if (this.di) try {
|
|
12092
|
+
this.di.setItem(this.Fi(this.clientId), String(Date.now()));
|
|
12093
12093
|
} catch (e) {
|
|
12094
12094
|
// Gracefully handle if LocalStorage isn't available / working.
|
|
12095
12095
|
__PRIVATE_logError("Failed to set zombie client id.", e);
|
|
12096
12096
|
}
|
|
12097
12097
|
}
|
|
12098
|
-
/** Removes the zombied client entry if it exists. */
|
|
12099
|
-
if (this.
|
|
12100
|
-
this.
|
|
12098
|
+
/** Removes the zombied client entry if it exists. */ Li() {
|
|
12099
|
+
if (this.di) try {
|
|
12100
|
+
this.di.removeItem(this.Fi(this.clientId));
|
|
12101
12101
|
} catch (e) {
|
|
12102
12102
|
// Ignore
|
|
12103
12103
|
}
|
|
@@ -12916,14 +12916,14 @@ class __PRIVATE_MutationMetadata {
|
|
|
12916
12916
|
/**
|
|
12917
12917
|
* Parses a MutationMetadata from its JSON representation in WebStorage.
|
|
12918
12918
|
* Logs a warning and returns null if the format of the data is not valid.
|
|
12919
|
-
*/ static
|
|
12919
|
+
*/ static Es(e, t, n) {
|
|
12920
12920
|
const r = JSON.parse(n);
|
|
12921
12921
|
let i, s = "object" == typeof r && -1 !== [ "pending", "acknowledged", "rejected" ].indexOf(r.state) && (void 0 === r.error || "object" == typeof r.error);
|
|
12922
12922
|
return s && r.error && (s = "string" == typeof r.error.message && "string" == typeof r.error.code,
|
|
12923
12923
|
s && (i = new FirestoreError(r.error.code, r.error.message))), s ? new __PRIVATE_MutationMetadata(e, t, r.state, i) : (__PRIVATE_logError("SharedClientState", `Failed to parse mutation state for ID '${t}': ${n}`),
|
|
12924
12924
|
null);
|
|
12925
12925
|
}
|
|
12926
|
-
|
|
12926
|
+
ds() {
|
|
12927
12927
|
const e = {
|
|
12928
12928
|
state: this.state,
|
|
12929
12929
|
updateTimeMs: Date.now()
|
|
@@ -12947,14 +12947,14 @@ class __PRIVATE_QueryTargetMetadata {
|
|
|
12947
12947
|
/**
|
|
12948
12948
|
* Parses a QueryTargetMetadata from its JSON representation in WebStorage.
|
|
12949
12949
|
* Logs a warning and returns null if the format of the data is not valid.
|
|
12950
|
-
*/ static
|
|
12950
|
+
*/ static Es(e, t) {
|
|
12951
12951
|
const n = JSON.parse(t);
|
|
12952
12952
|
let r, i = "object" == typeof n && -1 !== [ "not-current", "current", "rejected" ].indexOf(n.state) && (void 0 === n.error || "object" == typeof n.error);
|
|
12953
12953
|
return i && n.error && (i = "string" == typeof n.error.message && "string" == typeof n.error.code,
|
|
12954
12954
|
i && (r = new FirestoreError(n.error.code, n.error.message))), i ? new __PRIVATE_QueryTargetMetadata(e, n.state, r) : (__PRIVATE_logError("SharedClientState", `Failed to parse target state for ID '${e}': ${t}`),
|
|
12955
12955
|
null);
|
|
12956
12956
|
}
|
|
12957
|
-
|
|
12957
|
+
ds() {
|
|
12958
12958
|
const e = {
|
|
12959
12959
|
state: this.state,
|
|
12960
12960
|
updateTimeMs: Date.now()
|
|
@@ -12976,7 +12976,7 @@ class __PRIVATE_QueryTargetMetadata {
|
|
|
12976
12976
|
/**
|
|
12977
12977
|
* Parses a RemoteClientState from the JSON representation in WebStorage.
|
|
12978
12978
|
* Logs a warning and returns null if the format of the data is not valid.
|
|
12979
|
-
*/ static
|
|
12979
|
+
*/ static Es(e, t) {
|
|
12980
12980
|
const n = JSON.parse(t);
|
|
12981
12981
|
let r = "object" == typeof n && n.activeTargetIds instanceof Array, i = __PRIVATE_targetIdSet();
|
|
12982
12982
|
for (let e = 0; r && e < n.activeTargetIds.length; ++e) r = isSafeInteger(n.activeTargetIds[e]),
|
|
@@ -12997,7 +12997,7 @@ class __PRIVATE_QueryTargetMetadata {
|
|
|
12997
12997
|
/**
|
|
12998
12998
|
* Parses a SharedOnlineState from its JSON representation in WebStorage.
|
|
12999
12999
|
* Logs a warning and returns null if the format of the data is not valid.
|
|
13000
|
-
*/ static
|
|
13000
|
+
*/ static Es(e) {
|
|
13001
13001
|
const t = JSON.parse(e);
|
|
13002
13002
|
return "object" == typeof t && -1 !== [ "Unknown", "Online", "Offline" ].indexOf(t.onlineState) && "string" == typeof t.clientId ? new __PRIVATE_SharedOnlineState(t.clientId, t.onlineState) : (__PRIVATE_logError("SharedClientState", `Failed to parse online state: ${e}`),
|
|
13003
13003
|
null);
|
|
@@ -13028,7 +13028,7 @@ class __PRIVATE_LocalClientState {
|
|
|
13028
13028
|
/**
|
|
13029
13029
|
* Converts this entry into a JSON-encoded format we can use for WebStorage.
|
|
13030
13030
|
* Does not encode `clientId` as it is part of the key in WebStorage.
|
|
13031
|
-
*/
|
|
13031
|
+
*/ ds() {
|
|
13032
13032
|
const e = {
|
|
13033
13033
|
activeTargetIds: this.activeTargetIds.toArray(),
|
|
13034
13034
|
updateTimeMs: Date.now()
|
|
@@ -13107,12 +13107,12 @@ class __PRIVATE_LocalClientState {
|
|
|
13107
13107
|
async start() {
|
|
13108
13108
|
// Retrieve the list of existing clients to backfill the data in
|
|
13109
13109
|
// SharedClientState.
|
|
13110
|
-
const e = await this.syncEngine.
|
|
13110
|
+
const e = await this.syncEngine.Bi();
|
|
13111
13111
|
for (const t of e) {
|
|
13112
13112
|
if (t === this.Vs) continue;
|
|
13113
13113
|
const e = this.getItem(createWebStorageClientStateKey(this.persistenceKey, t));
|
|
13114
13114
|
if (e) {
|
|
13115
|
-
const n = __PRIVATE_RemoteClientState.
|
|
13115
|
+
const n = __PRIVATE_RemoteClientState.Es(t, e);
|
|
13116
13116
|
n && (this.ps = this.ps.insert(n.clientId, n));
|
|
13117
13117
|
}
|
|
13118
13118
|
}
|
|
@@ -13143,14 +13143,14 @@ class __PRIVATE_LocalClientState {
|
|
|
13143
13143
|
})), t;
|
|
13144
13144
|
}
|
|
13145
13145
|
addPendingMutation(e) {
|
|
13146
|
-
this.
|
|
13146
|
+
this.Ls(e, "pending");
|
|
13147
13147
|
}
|
|
13148
13148
|
updateMutationState(e, t, n) {
|
|
13149
|
-
this.
|
|
13149
|
+
this.Ls(e, t, n),
|
|
13150
13150
|
// Once a final mutation result is observed by other clients, they no longer
|
|
13151
13151
|
// access the mutation's metadata entry. Since WebStorage replays events
|
|
13152
13152
|
// in order, it is safe to delete the entry right after updating it.
|
|
13153
|
-
this.
|
|
13153
|
+
this.Bs(e);
|
|
13154
13154
|
}
|
|
13155
13155
|
addLocalQueryTarget(e) {
|
|
13156
13156
|
let t = "not-current";
|
|
@@ -13159,7 +13159,7 @@ class __PRIVATE_LocalClientState {
|
|
|
13159
13159
|
if (this.isActiveQueryTarget(e)) {
|
|
13160
13160
|
const n = this.storage.getItem(createWebStorageQueryTargetMetadataKey(this.persistenceKey, e));
|
|
13161
13161
|
if (n) {
|
|
13162
|
-
const r = __PRIVATE_QueryTargetMetadata.
|
|
13162
|
+
const r = __PRIVATE_QueryTargetMetadata.Es(e, n);
|
|
13163
13163
|
r && (t = r.state);
|
|
13164
13164
|
}
|
|
13165
13165
|
}
|
|
@@ -13179,7 +13179,7 @@ class __PRIVATE_LocalClientState {
|
|
|
13179
13179
|
}
|
|
13180
13180
|
handleUserChange(e, t, n) {
|
|
13181
13181
|
t.forEach((e => {
|
|
13182
|
-
this.
|
|
13182
|
+
this.Bs(e);
|
|
13183
13183
|
})), this.currentUser = e, n.forEach((e => {
|
|
13184
13184
|
this.addPendingMutation(e);
|
|
13185
13185
|
}));
|
|
@@ -13265,13 +13265,13 @@ class __PRIVATE_LocalClientState {
|
|
|
13265
13265
|
return this.ps.get(this.Vs);
|
|
13266
13266
|
}
|
|
13267
13267
|
Ms() {
|
|
13268
|
-
this.setItem(this.ws, this.ks.
|
|
13268
|
+
this.setItem(this.ws, this.ks.ds());
|
|
13269
13269
|
}
|
|
13270
|
-
|
|
13270
|
+
Ls(e, t, n) {
|
|
13271
13271
|
const r = new __PRIVATE_MutationMetadata(this.currentUser, e, t, n), i = createWebStorageMutationBatchKey(this.persistenceKey, this.currentUser, e);
|
|
13272
|
-
this.setItem(i, r.
|
|
13272
|
+
this.setItem(i, r.ds());
|
|
13273
13273
|
}
|
|
13274
|
-
|
|
13274
|
+
Bs(e) {
|
|
13275
13275
|
const t = createWebStorageMutationBatchKey(this.persistenceKey, this.currentUser, e);
|
|
13276
13276
|
this.removeItem(t);
|
|
13277
13277
|
}
|
|
@@ -13284,7 +13284,7 @@ class __PRIVATE_LocalClientState {
|
|
|
13284
13284
|
}
|
|
13285
13285
|
qs(e, t, n) {
|
|
13286
13286
|
const r = createWebStorageQueryTargetMetadataKey(this.persistenceKey, e), i = new __PRIVATE_QueryTargetMetadata(e, t, n);
|
|
13287
|
-
this.setItem(r, i.
|
|
13287
|
+
this.setItem(r, i.ds());
|
|
13288
13288
|
}
|
|
13289
13289
|
Ks(e) {
|
|
13290
13290
|
const t = JSON.stringify(Array.from(e));
|
|
@@ -13302,27 +13302,27 @@ class __PRIVATE_LocalClientState {
|
|
|
13302
13302
|
* be parsed.
|
|
13303
13303
|
*/ Ws(e, t) {
|
|
13304
13304
|
const n = this.$s(e);
|
|
13305
|
-
return __PRIVATE_RemoteClientState.
|
|
13305
|
+
return __PRIVATE_RemoteClientState.Es(n, t);
|
|
13306
13306
|
}
|
|
13307
13307
|
/**
|
|
13308
13308
|
* Parses a mutation batch state in WebStorage. Returns 'null' if the value
|
|
13309
13309
|
* could not be parsed.
|
|
13310
13310
|
*/ Gs(e, t) {
|
|
13311
13311
|
const n = this.Ds.exec(e), r = Number(n[1]), i = void 0 !== n[2] ? n[2] : null;
|
|
13312
|
-
return __PRIVATE_MutationMetadata.
|
|
13312
|
+
return __PRIVATE_MutationMetadata.Es(new User(i), r, t);
|
|
13313
13313
|
}
|
|
13314
13314
|
/**
|
|
13315
13315
|
* Parses a query target state from WebStorage. Returns 'null' if the value
|
|
13316
13316
|
* could not be parsed.
|
|
13317
13317
|
*/ js(e, t) {
|
|
13318
13318
|
const n = this.Cs.exec(e), r = Number(n[1]);
|
|
13319
|
-
return __PRIVATE_QueryTargetMetadata.
|
|
13319
|
+
return __PRIVATE_QueryTargetMetadata.Es(r, t);
|
|
13320
13320
|
}
|
|
13321
13321
|
/**
|
|
13322
13322
|
* Parses an online state from WebStorage. Returns 'null' if the value
|
|
13323
13323
|
* could not be parsed.
|
|
13324
13324
|
*/ xs(e) {
|
|
13325
|
-
return __PRIVATE_SharedOnlineState.
|
|
13325
|
+
return __PRIVATE_SharedOnlineState.Es(e);
|
|
13326
13326
|
}
|
|
13327
13327
|
Js(e) {
|
|
13328
13328
|
return JSON.parse(e);
|
|
@@ -13983,9 +13983,9 @@ class __PRIVATE_ExponentialBackoff {
|
|
|
13983
13983
|
* much as 1.5*maxDelayMs.
|
|
13984
13984
|
*/ , i = 6e4) {
|
|
13985
13985
|
this.oi = e, this.timerId = t, this.Mo = n, this.xo = r, this.Oo = i, this.No = 0,
|
|
13986
|
-
this.
|
|
13986
|
+
this.Lo = null,
|
|
13987
13987
|
/** The last backoff attempt, as epoch milliseconds. */
|
|
13988
|
-
this.
|
|
13988
|
+
this.Bo = Date.now(), this.reset();
|
|
13989
13989
|
}
|
|
13990
13990
|
/**
|
|
13991
13991
|
* Resets the backoff delay.
|
|
@@ -14011,20 +14011,20 @@ class __PRIVATE_ExponentialBackoff {
|
|
|
14011
14011
|
this.cancel();
|
|
14012
14012
|
// First schedule using the current base (which may be 0 and should be
|
|
14013
14013
|
// honored as such).
|
|
14014
|
-
const t = Math.floor(this.No + this.Qo()), n = Math.max(0, Date.now() - this.
|
|
14014
|
+
const t = Math.floor(this.No + this.Qo()), n = Math.max(0, Date.now() - this.Bo), r = Math.max(0, t - n);
|
|
14015
14015
|
// Guard against lastAttemptTime being in the future due to a clock change.
|
|
14016
14016
|
r > 0 && __PRIVATE_logDebug("ExponentialBackoff", `Backing off for ${r} ms (base delay: ${this.No} ms, delay with jitter: ${t} ms, last attempt: ${n} ms ago)`),
|
|
14017
|
-
this.
|
|
14017
|
+
this.Lo = this.oi.enqueueAfterDelay(this.timerId, r, (() => (this.Bo = Date.now(),
|
|
14018
14018
|
e()))),
|
|
14019
14019
|
// Apply backoff factor to determine next delay and ensure it is within
|
|
14020
14020
|
// bounds.
|
|
14021
14021
|
this.No *= this.xo, this.No < this.Mo && (this.No = this.Mo), this.No > this.Oo && (this.No = this.Oo);
|
|
14022
14022
|
}
|
|
14023
14023
|
Ko() {
|
|
14024
|
-
null !== this.
|
|
14024
|
+
null !== this.Lo && (this.Lo.skipDelay(), this.Lo = null);
|
|
14025
14025
|
}
|
|
14026
14026
|
cancel() {
|
|
14027
|
-
null !== this.
|
|
14027
|
+
null !== this.Lo && (this.Lo.cancel(), this.Lo = null);
|
|
14028
14028
|
}
|
|
14029
14029
|
/** Returns a random value in the range [-currentBaseMs/2, currentBaseMs/2] */ Qo() {
|
|
14030
14030
|
return (Math.random() - .5) * this.No;
|
|
@@ -14380,13 +14380,13 @@ class __PRIVATE_PersistentStream {
|
|
|
14380
14380
|
}
|
|
14381
14381
|
// The first response is always the handshake response
|
|
14382
14382
|
return __PRIVATE_hardAssert(!e.writeResults || 0 === e.writeResults.length), this.h_ = !0,
|
|
14383
|
-
this.listener.
|
|
14383
|
+
this.listener.E_();
|
|
14384
14384
|
}
|
|
14385
14385
|
/**
|
|
14386
14386
|
* Sends an initial streamToken to the server, performing the handshake
|
|
14387
14387
|
* required to make the StreamingWrite RPC work. Subsequent
|
|
14388
14388
|
* calls should wait until onHandshakeComplete was called.
|
|
14389
|
-
*/
|
|
14389
|
+
*/ d_() {
|
|
14390
14390
|
// TODO(dimond): Support stream resumption. We intentionally do not set the
|
|
14391
14391
|
// stream token on the handshake, ignoring any stream token we might have.
|
|
14392
14392
|
const e = {};
|
|
@@ -14909,7 +14909,7 @@ function __PRIVATE_startWriteStream(e) {
|
|
|
14909
14909
|
}
|
|
14910
14910
|
|
|
14911
14911
|
async function __PRIVATE_onWriteStreamOpen(e) {
|
|
14912
|
-
__PRIVATE_ensureWriteStream(e).
|
|
14912
|
+
__PRIVATE_ensureWriteStream(e).d_();
|
|
14913
14913
|
}
|
|
14914
14914
|
|
|
14915
14915
|
async function __PRIVATE_onWriteHandshakeComplete(e) {
|
|
@@ -15023,22 +15023,22 @@ async function __PRIVATE_remoteStoreHandleCredentialChange(e, t) {
|
|
|
15023
15023
|
* PORTING NOTE: On iOS and Android, the WriteStream gets registered on startup.
|
|
15024
15024
|
* This is not done on Web to allow it to be tree-shaken.
|
|
15025
15025
|
*/ function __PRIVATE_ensureWriteStream(e) {
|
|
15026
|
-
return e.
|
|
15026
|
+
return e.L_ || (
|
|
15027
15027
|
// Create stream (but note that it is not started yet).
|
|
15028
|
-
e.
|
|
15028
|
+
e.L_ = function __PRIVATE_newPersistentWriteStream(e, t, n) {
|
|
15029
15029
|
const r = __PRIVATE_debugCast(e);
|
|
15030
15030
|
return r.R_(), new __PRIVATE_PersistentWriteStream(t, r.connection, r.authCredentials, r.appCheckCredentials, r.serializer, n);
|
|
15031
15031
|
}(e.datastore, e.asyncQueue, {
|
|
15032
15032
|
Po: __PRIVATE_onWriteStreamOpen.bind(null, e),
|
|
15033
15033
|
To: __PRIVATE_onWriteStreamClose.bind(null, e),
|
|
15034
|
-
|
|
15034
|
+
E_: __PRIVATE_onWriteHandshakeComplete.bind(null, e),
|
|
15035
15035
|
T_: __PRIVATE_onMutationResult.bind(null, e)
|
|
15036
15036
|
}), e.F_.push((async t => {
|
|
15037
|
-
t ? (e.
|
|
15037
|
+
t ? (e.L_.Zo(),
|
|
15038
15038
|
// This will start the write stream if necessary.
|
|
15039
|
-
await __PRIVATE_fillWritePipeline(e)) : (await e.
|
|
15039
|
+
await __PRIVATE_fillWritePipeline(e)) : (await e.L_.stop(), e.D_.length > 0 && (__PRIVATE_logDebug("RemoteStore", `Stopping write stream with ${e.D_.length} pending writes`),
|
|
15040
15040
|
e.D_ = []));
|
|
15041
|
-
}))), e.
|
|
15041
|
+
}))), e.L_;
|
|
15042
15042
|
}
|
|
15043
15043
|
|
|
15044
15044
|
/**
|
|
@@ -15251,25 +15251,25 @@ class DelayedOperation {
|
|
|
15251
15251
|
* duplicate events for the same doc.
|
|
15252
15252
|
*/ class __PRIVATE_DocumentChangeSet {
|
|
15253
15253
|
constructor() {
|
|
15254
|
-
this.
|
|
15254
|
+
this.B_ = new SortedMap(DocumentKey.comparator);
|
|
15255
15255
|
}
|
|
15256
15256
|
track(e) {
|
|
15257
|
-
const t = e.doc.key, n = this.
|
|
15257
|
+
const t = e.doc.key, n = this.B_.get(t);
|
|
15258
15258
|
n ?
|
|
15259
15259
|
// Merge the new change with the existing change.
|
|
15260
|
-
0 /* ChangeType.Added */ !== e.type && 3 /* ChangeType.Metadata */ === n.type ? this.
|
|
15260
|
+
0 /* ChangeType.Added */ !== e.type && 3 /* ChangeType.Metadata */ === n.type ? this.B_ = this.B_.insert(t, e) : 3 /* ChangeType.Metadata */ === e.type && 1 /* ChangeType.Removed */ !== n.type ? this.B_ = this.B_.insert(t, {
|
|
15261
15261
|
type: n.type,
|
|
15262
15262
|
doc: e.doc
|
|
15263
|
-
}) : 2 /* ChangeType.Modified */ === e.type && 2 /* ChangeType.Modified */ === n.type ? this.
|
|
15263
|
+
}) : 2 /* ChangeType.Modified */ === e.type && 2 /* ChangeType.Modified */ === n.type ? this.B_ = this.B_.insert(t, {
|
|
15264
15264
|
type: 2 /* ChangeType.Modified */ ,
|
|
15265
15265
|
doc: e.doc
|
|
15266
|
-
}) : 2 /* ChangeType.Modified */ === e.type && 0 /* ChangeType.Added */ === n.type ? this.
|
|
15266
|
+
}) : 2 /* ChangeType.Modified */ === e.type && 0 /* ChangeType.Added */ === n.type ? this.B_ = this.B_.insert(t, {
|
|
15267
15267
|
type: 0 /* ChangeType.Added */ ,
|
|
15268
15268
|
doc: e.doc
|
|
15269
|
-
}) : 1 /* ChangeType.Removed */ === e.type && 0 /* ChangeType.Added */ === n.type ? this.
|
|
15269
|
+
}) : 1 /* ChangeType.Removed */ === e.type && 0 /* ChangeType.Added */ === n.type ? this.B_ = this.B_.remove(t) : 1 /* ChangeType.Removed */ === e.type && 2 /* ChangeType.Modified */ === n.type ? this.B_ = this.B_.insert(t, {
|
|
15270
15270
|
type: 1 /* ChangeType.Removed */ ,
|
|
15271
15271
|
doc: n.doc
|
|
15272
|
-
}) : 0 /* ChangeType.Added */ === e.type && 1 /* ChangeType.Removed */ === n.type ? this.
|
|
15272
|
+
}) : 0 /* ChangeType.Added */ === e.type && 1 /* ChangeType.Removed */ === n.type ? this.B_ = this.B_.insert(t, {
|
|
15273
15273
|
type: 2 /* ChangeType.Modified */ ,
|
|
15274
15274
|
doc: e.doc
|
|
15275
15275
|
}) :
|
|
@@ -15280,11 +15280,11 @@ class DelayedOperation {
|
|
|
15280
15280
|
// Removed->Modified
|
|
15281
15281
|
// Metadata->Added
|
|
15282
15282
|
// Removed->Metadata
|
|
15283
|
-
fail() : this.
|
|
15283
|
+
fail() : this.B_ = this.B_.insert(t, e);
|
|
15284
15284
|
}
|
|
15285
15285
|
k_() {
|
|
15286
15286
|
const e = [];
|
|
15287
|
-
return this.
|
|
15287
|
+
return this.B_.inorderTraversal(((t, n) => {
|
|
15288
15288
|
e.push(n);
|
|
15289
15289
|
})), e;
|
|
15290
15290
|
}
|
|
@@ -15342,40 +15342,79 @@ class ViewSnapshot {
|
|
|
15342
15342
|
constructor() {
|
|
15343
15343
|
this.q_ = void 0, this.Q_ = [];
|
|
15344
15344
|
}
|
|
15345
|
+
// Helper methods that checks if the query has listeners that listening to remote store
|
|
15346
|
+
K_() {
|
|
15347
|
+
return this.Q_.some((e => e.U_()));
|
|
15348
|
+
}
|
|
15345
15349
|
}
|
|
15346
15350
|
|
|
15347
15351
|
class __PRIVATE_EventManagerImpl {
|
|
15348
15352
|
constructor() {
|
|
15349
15353
|
this.queries = new ObjectMap((e => __PRIVATE_canonifyQuery(e)), __PRIVATE_queryEquals),
|
|
15350
|
-
this.onlineState = "Unknown" /* OnlineState.Unknown */ , this.
|
|
15354
|
+
this.onlineState = "Unknown" /* OnlineState.Unknown */ , this.W_ = new Set;
|
|
15351
15355
|
}
|
|
15352
15356
|
}
|
|
15353
15357
|
|
|
15354
15358
|
async function __PRIVATE_eventManagerListen(e, t) {
|
|
15355
|
-
const n = __PRIVATE_debugCast(e)
|
|
15356
|
-
let
|
|
15357
|
-
|
|
15358
|
-
|
|
15359
|
+
const n = __PRIVATE_debugCast(e);
|
|
15360
|
+
let r = 3 /* ListenerSetupAction.NoActionRequired */;
|
|
15361
|
+
const i = t.query;
|
|
15362
|
+
let s = n.queries.get(i);
|
|
15363
|
+
s ? !s.K_() && t.U_() && (
|
|
15364
|
+
// Query has been listening to local cache, and tries to add a new listener sourced from watch.
|
|
15365
|
+
r = 2 /* ListenerSetupAction.RequireWatchConnectionOnly */) : (s = new __PRIVATE_QueryListenersInfo,
|
|
15366
|
+
r = t.U_() ? 0 /* ListenerSetupAction.InitializeLocalListenAndRequireWatchConnection */ : 1 /* ListenerSetupAction.InitializeLocalListenOnly */);
|
|
15367
|
+
try {
|
|
15368
|
+
switch (r) {
|
|
15369
|
+
case 0 /* ListenerSetupAction.InitializeLocalListenAndRequireWatchConnection */ :
|
|
15370
|
+
s.q_ = await n.onListen(i,
|
|
15371
|
+
/** enableRemoteListen= */ !0);
|
|
15372
|
+
break;
|
|
15373
|
+
|
|
15374
|
+
case 1 /* ListenerSetupAction.InitializeLocalListenOnly */ :
|
|
15375
|
+
s.q_ = await n.onListen(i,
|
|
15376
|
+
/** enableRemoteListen= */ !1);
|
|
15377
|
+
break;
|
|
15378
|
+
|
|
15379
|
+
case 2 /* ListenerSetupAction.RequireWatchConnectionOnly */ :
|
|
15380
|
+
await n.onFirstRemoteStoreListen(i);
|
|
15381
|
+
}
|
|
15359
15382
|
} catch (e) {
|
|
15360
15383
|
const n = __PRIVATE_wrapInUserErrorIfRecoverable(e, `Initialization of query '${__PRIVATE_stringifyQuery(t.query)}' failed`);
|
|
15361
15384
|
return void t.onError(n);
|
|
15362
15385
|
}
|
|
15363
|
-
if (n.queries.set(
|
|
15386
|
+
if (n.queries.set(i, s), s.Q_.push(t),
|
|
15364
15387
|
// Run global snapshot listeners if a consistent snapshot has been emitted.
|
|
15365
|
-
t.
|
|
15366
|
-
t.
|
|
15388
|
+
t.G_(n.onlineState), s.q_) {
|
|
15389
|
+
t.z_(s.q_) && __PRIVATE_raiseSnapshotsInSyncEvent(n);
|
|
15367
15390
|
}
|
|
15368
15391
|
}
|
|
15369
15392
|
|
|
15370
15393
|
async function __PRIVATE_eventManagerUnlisten(e, t) {
|
|
15371
15394
|
const n = __PRIVATE_debugCast(e), r = t.query;
|
|
15372
|
-
let i =
|
|
15395
|
+
let i = 3 /* ListenerRemovalAction.NoActionRequired */;
|
|
15373
15396
|
const s = n.queries.get(r);
|
|
15374
15397
|
if (s) {
|
|
15375
15398
|
const e = s.Q_.indexOf(t);
|
|
15376
|
-
e >= 0 && (s.Q_.splice(e, 1), i = 0
|
|
15399
|
+
e >= 0 && (s.Q_.splice(e, 1), 0 === s.Q_.length ? i = t.U_() ? 0 /* ListenerRemovalAction.TerminateLocalListenAndRequireWatchDisconnection */ : 1 /* ListenerRemovalAction.TerminateLocalListenOnly */ : !s.K_() && t.U_() && (
|
|
15400
|
+
// The removed listener is the last one that sourced from watch.
|
|
15401
|
+
i = 2 /* ListenerRemovalAction.RequireWatchDisconnectionOnly */));
|
|
15402
|
+
}
|
|
15403
|
+
switch (i) {
|
|
15404
|
+
case 0 /* ListenerRemovalAction.TerminateLocalListenAndRequireWatchDisconnection */ :
|
|
15405
|
+
return n.queries.delete(r), n.onUnlisten(r,
|
|
15406
|
+
/** disableRemoteListen= */ !0);
|
|
15407
|
+
|
|
15408
|
+
case 1 /* ListenerRemovalAction.TerminateLocalListenOnly */ :
|
|
15409
|
+
return n.queries.delete(r), n.onUnlisten(r,
|
|
15410
|
+
/** disableRemoteListen= */ !1);
|
|
15411
|
+
|
|
15412
|
+
case 2 /* ListenerRemovalAction.RequireWatchDisconnectionOnly */ :
|
|
15413
|
+
return n.onLastRemoteStoreUnlisten(r);
|
|
15414
|
+
|
|
15415
|
+
default:
|
|
15416
|
+
return;
|
|
15377
15417
|
}
|
|
15378
|
-
if (i) return n.queries.delete(r), n.onUnlisten(r);
|
|
15379
15418
|
}
|
|
15380
15419
|
|
|
15381
15420
|
function __PRIVATE_eventManagerOnWatchChange(e, t) {
|
|
@@ -15384,7 +15423,7 @@ function __PRIVATE_eventManagerOnWatchChange(e, t) {
|
|
|
15384
15423
|
for (const e of t) {
|
|
15385
15424
|
const t = e.query, i = n.queries.get(t);
|
|
15386
15425
|
if (i) {
|
|
15387
|
-
for (const t of i.Q_) t.
|
|
15426
|
+
for (const t of i.Q_) t.z_(e) && (r = !0);
|
|
15388
15427
|
i.q_ = e;
|
|
15389
15428
|
}
|
|
15390
15429
|
}
|
|
@@ -15401,24 +15440,32 @@ function __PRIVATE_eventManagerOnWatchError(e, t, n) {
|
|
|
15401
15440
|
|
|
15402
15441
|
// Call all global snapshot listeners that have been set.
|
|
15403
15442
|
function __PRIVATE_raiseSnapshotsInSyncEvent(e) {
|
|
15404
|
-
e.
|
|
15443
|
+
e.W_.forEach((e => {
|
|
15405
15444
|
e.next();
|
|
15406
15445
|
}));
|
|
15407
15446
|
}
|
|
15408
15447
|
|
|
15448
|
+
var me, fe;
|
|
15449
|
+
|
|
15450
|
+
/** Listen to both cache and server changes */
|
|
15451
|
+
(fe = me || (me = {})).j_ = "default",
|
|
15452
|
+
/** Listen to changes in cache only */
|
|
15453
|
+
fe.Cache = "cache";
|
|
15454
|
+
|
|
15409
15455
|
/**
|
|
15410
15456
|
* QueryListener takes a series of internal view snapshots and determines
|
|
15411
15457
|
* when to raise the event.
|
|
15412
15458
|
*
|
|
15413
15459
|
* It uses an Observer to dispatch events.
|
|
15414
|
-
*/
|
|
15460
|
+
*/
|
|
15461
|
+
class __PRIVATE_QueryListener {
|
|
15415
15462
|
constructor(e, t, n) {
|
|
15416
|
-
this.query = e, this.
|
|
15463
|
+
this.query = e, this.H_ = t,
|
|
15417
15464
|
/**
|
|
15418
15465
|
* Initial snapshots (e.g. from cache) may not be propagated to the wrapped
|
|
15419
15466
|
* observer. This flag is set to true once we've actually raised an event.
|
|
15420
15467
|
*/
|
|
15421
|
-
this.
|
|
15468
|
+
this.J_ = !1, this.Y_ = null, this.onlineState = "Unknown" /* OnlineState.Unknown */ ,
|
|
15422
15469
|
this.options = n || {};
|
|
15423
15470
|
}
|
|
15424
15471
|
/**
|
|
@@ -15426,7 +15473,7 @@ function __PRIVATE_raiseSnapshotsInSyncEvent(e) {
|
|
|
15426
15473
|
* if applicable (depending on what changed, whether the user has opted into
|
|
15427
15474
|
* metadata-only changes, etc.). Returns true if a user-facing event was
|
|
15428
15475
|
* indeed raised.
|
|
15429
|
-
*/
|
|
15476
|
+
*/ z_(e) {
|
|
15430
15477
|
if (!this.options.includeMetadataChanges) {
|
|
15431
15478
|
// Remove the metadata only changes.
|
|
15432
15479
|
const t = [];
|
|
@@ -15435,45 +15482,50 @@ function __PRIVATE_raiseSnapshotsInSyncEvent(e) {
|
|
|
15435
15482
|
/* excludesMetadataChanges= */ !0, e.hasCachedResults);
|
|
15436
15483
|
}
|
|
15437
15484
|
let t = !1;
|
|
15438
|
-
return this.
|
|
15439
|
-
t = !0), this.
|
|
15485
|
+
return this.J_ ? this.Z_(e) && (this.H_.next(e), t = !0) : this.X_(e, this.onlineState) && (this.ea(e),
|
|
15486
|
+
t = !0), this.Y_ = e, t;
|
|
15440
15487
|
}
|
|
15441
15488
|
onError(e) {
|
|
15442
|
-
this.
|
|
15489
|
+
this.H_.error(e);
|
|
15443
15490
|
}
|
|
15444
|
-
/** Returns whether a snapshot was raised. */
|
|
15491
|
+
/** Returns whether a snapshot was raised. */ G_(e) {
|
|
15445
15492
|
this.onlineState = e;
|
|
15446
15493
|
let t = !1;
|
|
15447
|
-
return this.
|
|
15494
|
+
return this.Y_ && !this.J_ && this.X_(this.Y_, e) && (this.ea(this.Y_), t = !0),
|
|
15448
15495
|
t;
|
|
15449
15496
|
}
|
|
15450
|
-
|
|
15497
|
+
X_(e, t) {
|
|
15451
15498
|
// Always raise the first event when we're synced
|
|
15452
15499
|
if (!e.fromCache) return !0;
|
|
15500
|
+
// Always raise event if listening to cache
|
|
15501
|
+
if (!this.U_()) return !0;
|
|
15453
15502
|
// NOTE: We consider OnlineState.Unknown as online (it should become Offline
|
|
15454
15503
|
// or Online if we wait long enough).
|
|
15455
15504
|
const n = "Offline" /* OnlineState.Offline */ !== t;
|
|
15456
15505
|
// Don't raise the event if we're online, aren't synced yet (checked
|
|
15457
15506
|
// above) and are waiting for a sync.
|
|
15458
|
-
return (!this.options.
|
|
15507
|
+
return (!this.options.ta || !n) && (!e.docs.isEmpty() || e.hasCachedResults || "Offline" /* OnlineState.Offline */ === t);
|
|
15459
15508
|
// Raise data from cache if we have any documents, have cached results before,
|
|
15460
15509
|
// or we are offline.
|
|
15461
15510
|
}
|
|
15462
|
-
|
|
15511
|
+
Z_(e) {
|
|
15463
15512
|
// We don't need to handle includeDocumentMetadataChanges here because
|
|
15464
15513
|
// the Metadata only changes have already been stripped out if needed.
|
|
15465
15514
|
// At this point the only changes we will see are the ones we should
|
|
15466
15515
|
// propagate.
|
|
15467
15516
|
if (e.docChanges.length > 0) return !0;
|
|
15468
|
-
const t = this.
|
|
15517
|
+
const t = this.Y_ && this.Y_.hasPendingWrites !== e.hasPendingWrites;
|
|
15469
15518
|
return !(!e.syncStateChanged && !t) && !0 === this.options.includeMetadataChanges;
|
|
15470
15519
|
// Generally we should have hit one of the cases above, but it's possible
|
|
15471
15520
|
// to get here if there were only metadata docChanges and they got
|
|
15472
15521
|
// stripped out.
|
|
15473
15522
|
}
|
|
15474
|
-
|
|
15523
|
+
ea(e) {
|
|
15475
15524
|
e = ViewSnapshot.fromInitialDocuments(e.query, e.docs, e.mutatedKeys, e.fromCache, e.hasCachedResults),
|
|
15476
|
-
this.
|
|
15525
|
+
this.J_ = !0, this.H_.next(e);
|
|
15526
|
+
}
|
|
15527
|
+
U_() {
|
|
15528
|
+
return this.options.source !== me.Cache;
|
|
15477
15529
|
}
|
|
15478
15530
|
}
|
|
15479
15531
|
|
|
@@ -15500,10 +15552,10 @@ function __PRIVATE_raiseSnapshotsInSyncEvent(e) {
|
|
|
15500
15552
|
constructor(e,
|
|
15501
15553
|
// How many bytes this element takes to store in the bundle.
|
|
15502
15554
|
t) {
|
|
15503
|
-
this.
|
|
15555
|
+
this.na = e, this.byteLength = t;
|
|
15504
15556
|
}
|
|
15505
|
-
|
|
15506
|
-
return "metadata" in this.
|
|
15557
|
+
ra() {
|
|
15558
|
+
return "metadata" in this.na;
|
|
15507
15559
|
}
|
|
15508
15560
|
}
|
|
15509
15561
|
|
|
@@ -15547,7 +15599,7 @@ function __PRIVATE_raiseSnapshotsInSyncEvent(e) {
|
|
|
15547
15599
|
* storage and provide progress update while loading.
|
|
15548
15600
|
*/ class __PRIVATE_BundleLoader {
|
|
15549
15601
|
constructor(e, t, n) {
|
|
15550
|
-
this.
|
|
15602
|
+
this.ia = e, this.localStore = t, this.serializer = n,
|
|
15551
15603
|
/** Batched queries to be saved into storage */
|
|
15552
15604
|
this.queries = [],
|
|
15553
15605
|
/** Batched documents to be saved into storage */
|
|
@@ -15560,21 +15612,21 @@ function __PRIVATE_raiseSnapshotsInSyncEvent(e) {
|
|
|
15560
15612
|
*
|
|
15561
15613
|
* Returns a new progress if adding the element leads to a new progress,
|
|
15562
15614
|
* otherwise returns null.
|
|
15563
|
-
*/
|
|
15615
|
+
*/ sa(e) {
|
|
15564
15616
|
this.progress.bytesLoaded += e.byteLength;
|
|
15565
15617
|
let t = this.progress.documentsLoaded;
|
|
15566
|
-
if (e.
|
|
15618
|
+
if (e.na.namedQuery) this.queries.push(e.na.namedQuery); else if (e.na.documentMetadata) {
|
|
15567
15619
|
this.documents.push({
|
|
15568
|
-
metadata: e.
|
|
15569
|
-
}), e.
|
|
15570
|
-
const n = ResourcePath.fromString(e.
|
|
15620
|
+
metadata: e.na.documentMetadata
|
|
15621
|
+
}), e.na.documentMetadata.exists || ++t;
|
|
15622
|
+
const n = ResourcePath.fromString(e.na.documentMetadata.name);
|
|
15571
15623
|
this.collectionGroups.add(n.get(n.length - 2));
|
|
15572
|
-
} else e.
|
|
15624
|
+
} else e.na.document && (this.documents[this.documents.length - 1].document = e.na.document,
|
|
15573
15625
|
++t);
|
|
15574
15626
|
return t !== this.progress.documentsLoaded ? (this.progress.documentsLoaded = t,
|
|
15575
15627
|
Object.assign({}, this.progress)) : null;
|
|
15576
15628
|
}
|
|
15577
|
-
|
|
15629
|
+
oa(e) {
|
|
15578
15630
|
const t = new Map, n = new __PRIVATE_BundleConverterImpl(this.serializer);
|
|
15579
15631
|
for (const r of e) if (r.metadata.queries) {
|
|
15580
15632
|
const e = n.Ps(r.metadata.name);
|
|
@@ -15588,12 +15640,12 @@ function __PRIVATE_raiseSnapshotsInSyncEvent(e) {
|
|
|
15588
15640
|
/**
|
|
15589
15641
|
* Update the progress to 'Success' and return the updated progress.
|
|
15590
15642
|
*/ async complete() {
|
|
15591
|
-
const e = await __PRIVATE_localStoreApplyBundledDocuments(this.localStore, new __PRIVATE_BundleConverterImpl(this.serializer), this.documents, this.
|
|
15643
|
+
const e = await __PRIVATE_localStoreApplyBundledDocuments(this.localStore, new __PRIVATE_BundleConverterImpl(this.serializer), this.documents, this.ia.id), t = this.oa(this.documents);
|
|
15592
15644
|
for (const e of this.queries) await __PRIVATE_localStoreSaveNamedQuery(this.localStore, e, t.get(e.name));
|
|
15593
15645
|
return this.progress.taskState = "Success", {
|
|
15594
15646
|
progress: this.progress,
|
|
15595
|
-
|
|
15596
|
-
|
|
15647
|
+
_a: this.collectionGroups,
|
|
15648
|
+
aa: e
|
|
15597
15649
|
};
|
|
15598
15650
|
}
|
|
15599
15651
|
}
|
|
@@ -15651,7 +15703,7 @@ class __PRIVATE_RemovedLimboDocument {
|
|
|
15651
15703
|
constructor(e,
|
|
15652
15704
|
/** Documents included in the remote target */
|
|
15653
15705
|
t) {
|
|
15654
|
-
this.query = e, this.
|
|
15706
|
+
this.query = e, this.ua = t, this.ca = null, this.hasCachedResults = !1,
|
|
15655
15707
|
/**
|
|
15656
15708
|
* A flag whether the view is current with the backend. A view is considered
|
|
15657
15709
|
* current after it has seen the current flag from the backend and did not
|
|
@@ -15660,16 +15712,16 @@ class __PRIVATE_RemovedLimboDocument {
|
|
|
15660
15712
|
*/
|
|
15661
15713
|
this.current = !1,
|
|
15662
15714
|
/** Documents in the view but not in the remote target */
|
|
15663
|
-
this.
|
|
15715
|
+
this.la = __PRIVATE_documentKeySet(),
|
|
15664
15716
|
/** Document Keys that have local changes */
|
|
15665
|
-
this.mutatedKeys = __PRIVATE_documentKeySet(), this.
|
|
15666
|
-
this.
|
|
15717
|
+
this.mutatedKeys = __PRIVATE_documentKeySet(), this.ha = __PRIVATE_newQueryComparator(e),
|
|
15718
|
+
this.Pa = new DocumentSet(this.ha);
|
|
15667
15719
|
}
|
|
15668
15720
|
/**
|
|
15669
15721
|
* The set of remote documents that the server has told us belongs to the target associated with
|
|
15670
15722
|
* this view.
|
|
15671
|
-
*/ get
|
|
15672
|
-
return this.
|
|
15723
|
+
*/ get Ia() {
|
|
15724
|
+
return this.ua;
|
|
15673
15725
|
}
|
|
15674
15726
|
/**
|
|
15675
15727
|
* Iterates over a set of doc changes, applies the query limit, and computes
|
|
@@ -15680,8 +15732,8 @@ class __PRIVATE_RemovedLimboDocument {
|
|
|
15680
15732
|
* @param previousChanges - If this is being called with a refill, then start
|
|
15681
15733
|
* with this set of docs and changes instead of the current view.
|
|
15682
15734
|
* @returns a new set of docs, changes, and refill flag.
|
|
15683
|
-
*/
|
|
15684
|
-
const n = t ? t.
|
|
15735
|
+
*/ Ta(e, t) {
|
|
15736
|
+
const n = t ? t.Ea : new __PRIVATE_DocumentChangeSet, r = t ? t.Pa : this.Pa;
|
|
15685
15737
|
let i = t ? t.mutatedKeys : this.mutatedKeys, s = r, o = !1;
|
|
15686
15738
|
// Track the last doc in a (full) limit. This is necessary, because some
|
|
15687
15739
|
// update (a delete, or an update moving a doc past the old limit) might
|
|
@@ -15704,10 +15756,10 @@ class __PRIVATE_RemovedLimboDocument {
|
|
|
15704
15756
|
u.data.isEqual(c.data) ? l !== h && (n.track({
|
|
15705
15757
|
type: 3 /* ChangeType.Metadata */ ,
|
|
15706
15758
|
doc: c
|
|
15707
|
-
}), P = !0) : this.
|
|
15759
|
+
}), P = !0) : this.da(u, c) || (n.track({
|
|
15708
15760
|
type: 2 /* ChangeType.Modified */ ,
|
|
15709
15761
|
doc: c
|
|
15710
|
-
}), P = !0, (_ && this.
|
|
15762
|
+
}), P = !0, (_ && this.ha(c, _) > 0 || a && this.ha(c, a) < 0) && (
|
|
15711
15763
|
// This doc moved from inside the limit to outside the limit.
|
|
15712
15764
|
// That means there may be some other doc in the local cache
|
|
15713
15765
|
// that should be included instead.
|
|
@@ -15732,13 +15784,13 @@ class __PRIVATE_RemovedLimboDocument {
|
|
|
15732
15784
|
});
|
|
15733
15785
|
}
|
|
15734
15786
|
return {
|
|
15735
|
-
|
|
15736
|
-
|
|
15787
|
+
Pa: s,
|
|
15788
|
+
Ea: n,
|
|
15737
15789
|
Xi: o,
|
|
15738
15790
|
mutatedKeys: i
|
|
15739
15791
|
};
|
|
15740
15792
|
}
|
|
15741
|
-
|
|
15793
|
+
da(e, t) {
|
|
15742
15794
|
// We suppress the initial change event for documents that were modified as
|
|
15743
15795
|
// part of a write acknowledgment (e.g. when the value of a server transform
|
|
15744
15796
|
// is applied) as Watch will send us the same document again.
|
|
@@ -15763,10 +15815,10 @@ class __PRIVATE_RemovedLimboDocument {
|
|
|
15763
15815
|
*/
|
|
15764
15816
|
// PORTING NOTE: The iOS/Android clients always compute limbo document changes.
|
|
15765
15817
|
applyChanges(e, t, n, r) {
|
|
15766
|
-
const i = this.
|
|
15767
|
-
this.
|
|
15818
|
+
const i = this.Pa;
|
|
15819
|
+
this.Pa = e.Pa, this.mutatedKeys = e.mutatedKeys;
|
|
15768
15820
|
// Sort changes based on type and query comparator
|
|
15769
|
-
const s = e.
|
|
15821
|
+
const s = e.Ea.k_();
|
|
15770
15822
|
s.sort(((e, t) => function __PRIVATE_compareChangeType(e, t) {
|
|
15771
15823
|
const order = e => {
|
|
15772
15824
|
switch (e) {
|
|
@@ -15804,70 +15856,70 @@ class __PRIVATE_RemovedLimboDocument {
|
|
|
15804
15856
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15805
15857
|
* See the License for the specific language governing permissions and
|
|
15806
15858
|
* limitations under the License.
|
|
15807
|
-
*/ (e.type, t.type) || this.
|
|
15808
|
-
const o = t && !r ? this.
|
|
15859
|
+
*/ (e.type, t.type) || this.ha(e.doc, t.doc))), this.Aa(n), r = null != r && r;
|
|
15860
|
+
const o = t && !r ? this.Ra() : [], _ = 0 === this.la.size && this.current && !r ? 1 /* SyncState.Synced */ : 0 /* SyncState.Local */ , a = _ !== this.ca;
|
|
15809
15861
|
// We are at synced state if there is no limbo docs are waiting to be resolved, view is current
|
|
15810
15862
|
// with the backend, and the query is not pending to reset due to existence filter mismatch.
|
|
15811
|
-
if (this.
|
|
15863
|
+
if (this.ca = _, 0 !== s.length || a) {
|
|
15812
15864
|
return {
|
|
15813
|
-
snapshot: new ViewSnapshot(this.query, e.
|
|
15865
|
+
snapshot: new ViewSnapshot(this.query, e.Pa, i, s, e.mutatedKeys, 0 /* SyncState.Local */ === _, a,
|
|
15814
15866
|
/* excludesMetadataChanges= */ !1, !!n && n.resumeToken.approximateByteSize() > 0),
|
|
15815
|
-
|
|
15867
|
+
Va: o
|
|
15816
15868
|
};
|
|
15817
15869
|
}
|
|
15818
15870
|
// no changes
|
|
15819
15871
|
return {
|
|
15820
|
-
|
|
15872
|
+
Va: o
|
|
15821
15873
|
};
|
|
15822
15874
|
}
|
|
15823
15875
|
/**
|
|
15824
15876
|
* Applies an OnlineState change to the view, potentially generating a
|
|
15825
15877
|
* ViewChange if the view's syncState changes as a result.
|
|
15826
|
-
*/
|
|
15878
|
+
*/ G_(e) {
|
|
15827
15879
|
return this.current && "Offline" /* OnlineState.Offline */ === e ? (
|
|
15828
15880
|
// If we're offline, set `current` to false and then call applyChanges()
|
|
15829
15881
|
// to refresh our syncState and generate a ViewChange as appropriate. We
|
|
15830
15882
|
// are guaranteed to get a new TargetChange that sets `current` back to
|
|
15831
15883
|
// true once the client is back online.
|
|
15832
15884
|
this.current = !1, this.applyChanges({
|
|
15833
|
-
|
|
15834
|
-
|
|
15885
|
+
Pa: this.Pa,
|
|
15886
|
+
Ea: new __PRIVATE_DocumentChangeSet,
|
|
15835
15887
|
mutatedKeys: this.mutatedKeys,
|
|
15836
15888
|
Xi: !1
|
|
15837
15889
|
},
|
|
15838
15890
|
/* limboResolutionEnabled= */ !1)) : {
|
|
15839
|
-
|
|
15891
|
+
Va: []
|
|
15840
15892
|
};
|
|
15841
15893
|
}
|
|
15842
15894
|
/**
|
|
15843
15895
|
* Returns whether the doc for the given key should be in limbo.
|
|
15844
|
-
*/
|
|
15896
|
+
*/ ma(e) {
|
|
15845
15897
|
// If the remote end says it's part of this query, it's not in limbo.
|
|
15846
|
-
return !this.
|
|
15898
|
+
return !this.ua.has(e) && (
|
|
15847
15899
|
// The local store doesn't think it's a result, so it shouldn't be in limbo.
|
|
15848
|
-
!!this.
|
|
15900
|
+
!!this.Pa.has(e) && !this.Pa.get(e).hasLocalMutations);
|
|
15849
15901
|
}
|
|
15850
15902
|
/**
|
|
15851
15903
|
* Updates syncedDocuments, current, and limbo docs based on the given change.
|
|
15852
15904
|
* Returns the list of changes to which docs are in limbo.
|
|
15853
|
-
*/
|
|
15854
|
-
e && (e.addedDocuments.forEach((e => this.
|
|
15855
|
-
e.removedDocuments.forEach((e => this.
|
|
15905
|
+
*/ Aa(e) {
|
|
15906
|
+
e && (e.addedDocuments.forEach((e => this.ua = this.ua.add(e))), e.modifiedDocuments.forEach((e => {})),
|
|
15907
|
+
e.removedDocuments.forEach((e => this.ua = this.ua.delete(e))), this.current = e.current);
|
|
15856
15908
|
}
|
|
15857
|
-
|
|
15909
|
+
Ra() {
|
|
15858
15910
|
// We can only determine limbo documents when we're in-sync with the server.
|
|
15859
15911
|
if (!this.current) return [];
|
|
15860
15912
|
// TODO(klimt): Do this incrementally so that it's not quadratic when
|
|
15861
15913
|
// updating many documents.
|
|
15862
|
-
const e = this.
|
|
15863
|
-
this.
|
|
15864
|
-
this.
|
|
15914
|
+
const e = this.la;
|
|
15915
|
+
this.la = __PRIVATE_documentKeySet(), this.Pa.forEach((e => {
|
|
15916
|
+
this.ma(e.key) && (this.la = this.la.add(e.key));
|
|
15865
15917
|
}));
|
|
15866
15918
|
// Diff the new limbo docs with the old limbo docs.
|
|
15867
15919
|
const t = [];
|
|
15868
15920
|
return e.forEach((e => {
|
|
15869
|
-
this.
|
|
15870
|
-
})), this.
|
|
15921
|
+
this.la.has(e) || t.push(new __PRIVATE_RemovedLimboDocument(e));
|
|
15922
|
+
})), this.la.forEach((n => {
|
|
15871
15923
|
e.has(n) || t.push(new __PRIVATE_AddedLimboDocument(n));
|
|
15872
15924
|
})), t;
|
|
15873
15925
|
}
|
|
@@ -15891,9 +15943,9 @@ class __PRIVATE_RemovedLimboDocument {
|
|
|
15891
15943
|
* @returns The ViewChange that resulted from this synchronization.
|
|
15892
15944
|
*/
|
|
15893
15945
|
// PORTING NOTE: Multi-tab only.
|
|
15894
|
-
|
|
15895
|
-
this.
|
|
15896
|
-
const t = this.
|
|
15946
|
+
fa(e) {
|
|
15947
|
+
this.ua = e.hs, this.la = __PRIVATE_documentKeySet();
|
|
15948
|
+
const t = this.Ta(e.documents);
|
|
15897
15949
|
return this.applyChanges(t, /* limboResolutionEnabled= */ !0);
|
|
15898
15950
|
}
|
|
15899
15951
|
/**
|
|
@@ -15902,8 +15954,8 @@ class __PRIVATE_RemovedLimboDocument {
|
|
|
15902
15954
|
* `hasPendingWrites` status of the already established view.
|
|
15903
15955
|
*/
|
|
15904
15956
|
// PORTING NOTE: Multi-tab only.
|
|
15905
|
-
|
|
15906
|
-
return ViewSnapshot.fromInitialDocuments(this.query, this.
|
|
15957
|
+
ga() {
|
|
15958
|
+
return ViewSnapshot.fromInitialDocuments(this.query, this.Pa, this.mutatedKeys, 0 /* SyncState.Local */ === this.ca, this.hasCachedResults);
|
|
15907
15959
|
}
|
|
15908
15960
|
}
|
|
15909
15961
|
|
|
@@ -15942,7 +15994,7 @@ class __PRIVATE_QueryView {
|
|
|
15942
15994
|
* decide whether it needs to manufacture a delete event for the target once
|
|
15943
15995
|
* the target is CURRENT.
|
|
15944
15996
|
*/
|
|
15945
|
-
this.
|
|
15997
|
+
this.pa = !1;
|
|
15946
15998
|
}
|
|
15947
15999
|
}
|
|
15948
16000
|
|
|
@@ -15963,8 +16015,8 @@ class __PRIVATE_QueryView {
|
|
|
15963
16015
|
// PORTING NOTE: Manages state synchronization in multi-tab environments.
|
|
15964
16016
|
r, i, s) {
|
|
15965
16017
|
this.localStore = e, this.remoteStore = t, this.eventManager = n, this.sharedClientState = r,
|
|
15966
|
-
this.currentUser = i, this.maxConcurrentLimboResolutions = s, this.
|
|
15967
|
-
this.
|
|
16018
|
+
this.currentUser = i, this.maxConcurrentLimboResolutions = s, this.ya = {}, this.wa = new ObjectMap((e => __PRIVATE_canonifyQuery(e)), __PRIVATE_queryEquals),
|
|
16019
|
+
this.Sa = new Map,
|
|
15968
16020
|
/**
|
|
15969
16021
|
* The keys of documents that are in limbo for which we haven't yet started a
|
|
15970
16022
|
* limbo resolution query. The strings in this set are the result of calling
|
|
@@ -15974,28 +16026,28 @@ class __PRIVATE_QueryView {
|
|
|
15974
16026
|
* of arbitrary elements and it also maintains insertion order, providing the
|
|
15975
16027
|
* desired queue-like FIFO semantics.
|
|
15976
16028
|
*/
|
|
15977
|
-
this.
|
|
16029
|
+
this.ba = new Set,
|
|
15978
16030
|
/**
|
|
15979
16031
|
* Keeps track of the target ID for each document that is in limbo with an
|
|
15980
16032
|
* active target.
|
|
15981
16033
|
*/
|
|
15982
|
-
this.
|
|
16034
|
+
this.Da = new SortedMap(DocumentKey.comparator),
|
|
15983
16035
|
/**
|
|
15984
16036
|
* Keeps track of the information about an active limbo resolution for each
|
|
15985
16037
|
* active target ID that was started for the purpose of limbo resolution.
|
|
15986
16038
|
*/
|
|
15987
|
-
this.
|
|
16039
|
+
this.Ca = new Map, this.va = new __PRIVATE_ReferenceSet,
|
|
15988
16040
|
/** Stores user completion handlers, indexed by User and BatchId. */
|
|
15989
|
-
this.
|
|
16041
|
+
this.Fa = {},
|
|
15990
16042
|
/** Stores user callbacks waiting for all pending writes to be acknowledged. */
|
|
15991
|
-
this.
|
|
16043
|
+
this.Ma = new Map, this.xa = __PRIVATE_TargetIdGenerator.Ln(), this.onlineState = "Unknown" /* OnlineState.Unknown */ ,
|
|
15992
16044
|
// The primary state is set to `true` or `false` immediately after Firestore
|
|
15993
16045
|
// startup. In the interim, a client should only be considered primary if
|
|
15994
16046
|
// `isPrimary` is true.
|
|
15995
|
-
this.
|
|
16047
|
+
this.Oa = void 0;
|
|
15996
16048
|
}
|
|
15997
16049
|
get isPrimaryClient() {
|
|
15998
|
-
return !0 === this.
|
|
16050
|
+
return !0 === this.Oa;
|
|
15999
16051
|
}
|
|
16000
16052
|
}
|
|
16001
16053
|
|
|
@@ -16004,23 +16056,33 @@ class __PRIVATE_QueryView {
|
|
|
16004
16056
|
* server. All the subsequent view snapshots or errors are sent to the
|
|
16005
16057
|
* subscribed handlers. Returns the initial snapshot.
|
|
16006
16058
|
*/
|
|
16007
|
-
async function __PRIVATE_syncEngineListen(e, t) {
|
|
16008
|
-
const
|
|
16009
|
-
let
|
|
16010
|
-
const s =
|
|
16011
|
-
|
|
16059
|
+
async function __PRIVATE_syncEngineListen(e, t, n = !0) {
|
|
16060
|
+
const r = __PRIVATE_ensureWatchCallbacks(e);
|
|
16061
|
+
let i;
|
|
16062
|
+
const s = r.wa.get(t);
|
|
16063
|
+
return s ? (
|
|
16012
16064
|
// PORTING NOTE: With Multi-Tab Web, it is possible that a query view
|
|
16013
16065
|
// already exists when EventManager calls us for the first time. This
|
|
16014
16066
|
// happens when the primary tab is already listening to this query on
|
|
16015
16067
|
// behalf of another tab and the user of the primary also starts listening
|
|
16016
16068
|
// to the query. EventManager will not have an assigned target ID in this
|
|
16017
16069
|
// case and calls `listen` to obtain this ID.
|
|
16018
|
-
r
|
|
16019
|
-
|
|
16020
|
-
|
|
16021
|
-
|
|
16022
|
-
|
|
16023
|
-
|
|
16070
|
+
r.sharedClientState.addLocalQueryTarget(s.targetId), i = s.view.ga()) : i = await __PRIVATE_allocateTargetAndMaybeListen(r, t, n,
|
|
16071
|
+
/** shouldInitializeView= */ !0), i;
|
|
16072
|
+
}
|
|
16073
|
+
|
|
16074
|
+
/** Query has been listening to the cache, and tries to initiate the remote store listen */ async function __PRIVATE_triggerRemoteStoreListen(e, t) {
|
|
16075
|
+
const n = __PRIVATE_ensureWatchCallbacks(e);
|
|
16076
|
+
await __PRIVATE_allocateTargetAndMaybeListen(n, t,
|
|
16077
|
+
/** shouldListenToRemote= */ !0,
|
|
16078
|
+
/** shouldInitializeView= */ !1);
|
|
16079
|
+
}
|
|
16080
|
+
|
|
16081
|
+
async function __PRIVATE_allocateTargetAndMaybeListen(e, t, n, r) {
|
|
16082
|
+
const i = await __PRIVATE_localStoreAllocateTarget(e.localStore, __PRIVATE_queryToTarget(t)), s = i.targetId, o = n ? e.sharedClientState.addLocalQueryTarget(s) : "not-current";
|
|
16083
|
+
let _;
|
|
16084
|
+
return r && (_ = await __PRIVATE_initializeViewAndComputeSnapshot(e, t, s, "current" === o, i.resumeToken)),
|
|
16085
|
+
e.isPrimaryClient && n && __PRIVATE_remoteStoreListen(e.remoteStore, i), _;
|
|
16024
16086
|
}
|
|
16025
16087
|
|
|
16026
16088
|
/**
|
|
@@ -16030,44 +16092,52 @@ async function __PRIVATE_syncEngineListen(e, t) {
|
|
|
16030
16092
|
// PORTING NOTE: On Web only, we inject the code that registers new Limbo
|
|
16031
16093
|
// targets based on view changes. This allows us to only depend on Limbo
|
|
16032
16094
|
// changes when user code includes queries.
|
|
16033
|
-
e.
|
|
16034
|
-
let i = t.view.
|
|
16095
|
+
e.Na = (t, n, r) => async function __PRIVATE_applyDocChanges(e, t, n, r) {
|
|
16096
|
+
let i = t.view.Ta(n);
|
|
16035
16097
|
i.Xi && (
|
|
16036
16098
|
// The query has a limit and some docs were removed, so we need
|
|
16037
16099
|
// to re-run the query against the local store to make sure we
|
|
16038
16100
|
// didn't lose any good docs that had been past the limit.
|
|
16039
16101
|
i = await __PRIVATE_localStoreExecuteQuery(e.localStore, t.query,
|
|
16040
|
-
/* usePreviousResults= */ !1).then((({documents: e}) => t.view.
|
|
16102
|
+
/* usePreviousResults= */ !1).then((({documents: e}) => t.view.Ta(e, i))));
|
|
16041
16103
|
const s = r && r.targetChanges.get(t.targetId), o = r && null != r.targetMismatches.get(t.targetId), _ = t.view.applyChanges(i,
|
|
16042
16104
|
/* limboResolutionEnabled= */ e.isPrimaryClient, s, o);
|
|
16043
|
-
return __PRIVATE_updateTrackedLimbos(e, t.targetId, _.
|
|
16105
|
+
return __PRIVATE_updateTrackedLimbos(e, t.targetId, _.Va), _.snapshot;
|
|
16044
16106
|
}(e, t, n, r);
|
|
16045
16107
|
const s = await __PRIVATE_localStoreExecuteQuery(e.localStore, t,
|
|
16046
|
-
/* usePreviousResults= */ !0), o = new __PRIVATE_View(t, s.hs), _ = o.
|
|
16108
|
+
/* usePreviousResults= */ !0), o = new __PRIVATE_View(t, s.hs), _ = o.Ta(s.documents), a = TargetChange.createSynthesizedTargetChangeForCurrentChange(n, r && "Offline" /* OnlineState.Offline */ !== e.onlineState, i), u = o.applyChanges(_,
|
|
16047
16109
|
/* limboResolutionEnabled= */ e.isPrimaryClient, a);
|
|
16048
|
-
__PRIVATE_updateTrackedLimbos(e, n, u.
|
|
16110
|
+
__PRIVATE_updateTrackedLimbos(e, n, u.Va);
|
|
16049
16111
|
const c = new __PRIVATE_QueryView(t, n, o);
|
|
16050
|
-
return e.
|
|
16112
|
+
return e.wa.set(t, c), e.Sa.has(n) ? e.Sa.get(n).push(t) : e.Sa.set(n, [ t ]), u.snapshot;
|
|
16051
16113
|
}
|
|
16052
16114
|
|
|
16053
|
-
/** Stops listening to the query. */ async function __PRIVATE_syncEngineUnlisten(e, t) {
|
|
16054
|
-
const
|
|
16055
|
-
if (
|
|
16056
|
-
void
|
|
16115
|
+
/** Stops listening to the query. */ async function __PRIVATE_syncEngineUnlisten(e, t, n) {
|
|
16116
|
+
const r = __PRIVATE_debugCast(e), i = r.wa.get(t), s = r.Sa.get(i.targetId);
|
|
16117
|
+
if (s.length > 1) return r.Sa.set(i.targetId, s.filter((e => !__PRIVATE_queryEquals(e, t)))),
|
|
16118
|
+
void r.wa.delete(t);
|
|
16057
16119
|
// No other queries are mapped to the target, clean up the query and the target.
|
|
16058
|
-
if (
|
|
16120
|
+
if (r.isPrimaryClient) {
|
|
16059
16121
|
// We need to remove the local query target first to allow us to verify
|
|
16060
16122
|
// whether any other client is still interested in this target.
|
|
16061
|
-
|
|
16062
|
-
|
|
16123
|
+
r.sharedClientState.removeLocalQueryTarget(i.targetId);
|
|
16124
|
+
r.sharedClientState.isActiveQueryTarget(i.targetId) || await __PRIVATE_localStoreReleaseTarget(r.localStore, i.targetId,
|
|
16063
16125
|
/*keepPersistedTargetData=*/ !1).then((() => {
|
|
16064
|
-
|
|
16065
|
-
__PRIVATE_removeAndCleanupTarget(
|
|
16126
|
+
r.sharedClientState.clearQueryState(i.targetId), n && __PRIVATE_remoteStoreUnlisten(r.remoteStore, i.targetId),
|
|
16127
|
+
__PRIVATE_removeAndCleanupTarget(r, i.targetId);
|
|
16066
16128
|
})).catch(__PRIVATE_ignoreIfPrimaryLeaseLoss);
|
|
16067
|
-
} else __PRIVATE_removeAndCleanupTarget(
|
|
16129
|
+
} else __PRIVATE_removeAndCleanupTarget(r, i.targetId), await __PRIVATE_localStoreReleaseTarget(r.localStore, i.targetId,
|
|
16068
16130
|
/*keepPersistedTargetData=*/ !0);
|
|
16069
16131
|
}
|
|
16070
16132
|
|
|
16133
|
+
/** Unlistens to the remote store while still listening to the cache. */ async function __PRIVATE_triggerRemoteStoreUnlisten(e, t) {
|
|
16134
|
+
const n = __PRIVATE_debugCast(e), r = n.wa.get(t), i = n.Sa.get(r.targetId);
|
|
16135
|
+
n.isPrimaryClient && 1 === i.length && (
|
|
16136
|
+
// PORTING NOTE: Unregister the target ID with local Firestore client as
|
|
16137
|
+
// watch target.
|
|
16138
|
+
n.sharedClientState.removeLocalQueryTarget(r.targetId), __PRIVATE_remoteStoreUnlisten(n.remoteStore, r.targetId));
|
|
16139
|
+
}
|
|
16140
|
+
|
|
16071
16141
|
/**
|
|
16072
16142
|
* Initiates the write of local mutation batch which involves adding the
|
|
16073
16143
|
* writes to the mutation queue, notifying the remote store about new
|
|
@@ -16123,9 +16193,9 @@ async function __PRIVATE_syncEngineListen(e, t) {
|
|
|
16123
16193
|
})));
|
|
16124
16194
|
}(r.localStore, t);
|
|
16125
16195
|
r.sharedClientState.addPendingMutation(e.batchId), function __PRIVATE_addMutationCallback(e, t, n) {
|
|
16126
|
-
let r = e.
|
|
16196
|
+
let r = e.Fa[e.currentUser.toKey()];
|
|
16127
16197
|
r || (r = new SortedMap(__PRIVATE_primitiveComparator));
|
|
16128
|
-
r = r.insert(t, n), e.
|
|
16198
|
+
r = r.insert(t, n), e.Fa[e.currentUser.toKey()] = r;
|
|
16129
16199
|
}
|
|
16130
16200
|
/**
|
|
16131
16201
|
* Resolves or rejects the user callback for the given batch and then discards
|
|
@@ -16150,13 +16220,13 @@ async function __PRIVATE_syncEngineListen(e, t) {
|
|
|
16150
16220
|
const e = await __PRIVATE_localStoreApplyRemoteEventToLocalCache(n.localStore, t);
|
|
16151
16221
|
// Update `receivedDocument` as appropriate for any limbo targets.
|
|
16152
16222
|
t.targetChanges.forEach(((e, t) => {
|
|
16153
|
-
const r = n.
|
|
16223
|
+
const r = n.Ca.get(t);
|
|
16154
16224
|
r && (
|
|
16155
16225
|
// Since this is a limbo resolution lookup, it's for a single document
|
|
16156
16226
|
// and it could be added, modified, or removed, but not a combination.
|
|
16157
16227
|
__PRIVATE_hardAssert(e.addedDocuments.size + e.modifiedDocuments.size + e.removedDocuments.size <= 1),
|
|
16158
|
-
e.addedDocuments.size > 0 ? r.
|
|
16159
|
-
r.
|
|
16228
|
+
e.addedDocuments.size > 0 ? r.pa = !0 : e.modifiedDocuments.size > 0 ? __PRIVATE_hardAssert(r.pa) : e.removedDocuments.size > 0 && (__PRIVATE_hardAssert(r.pa),
|
|
16229
|
+
r.pa = !1));
|
|
16160
16230
|
})), await __PRIVATE_syncEngineEmitNewSnapsAndNotifyLocalStore(n, e, t);
|
|
16161
16231
|
} catch (e) {
|
|
16162
16232
|
await __PRIVATE_ignoreIfPrimaryLeaseLoss(e);
|
|
@@ -16174,8 +16244,8 @@ async function __PRIVATE_syncEngineListen(e, t) {
|
|
|
16174
16244
|
// SharedClientState.
|
|
16175
16245
|
if (r.isPrimaryClient && 0 /* OnlineStateSource.RemoteStore */ === n || !r.isPrimaryClient && 1 /* OnlineStateSource.SharedClientState */ === n) {
|
|
16176
16246
|
const e = [];
|
|
16177
|
-
r.
|
|
16178
|
-
const i = r.view.
|
|
16247
|
+
r.wa.forEach(((n, r) => {
|
|
16248
|
+
const i = r.view.G_(t);
|
|
16179
16249
|
i.snapshot && e.push(i.snapshot);
|
|
16180
16250
|
})), function __PRIVATE_eventManagerOnOnlineStateChange(e, t) {
|
|
16181
16251
|
const n = __PRIVATE_debugCast(e);
|
|
@@ -16184,9 +16254,9 @@ async function __PRIVATE_syncEngineListen(e, t) {
|
|
|
16184
16254
|
n.queries.forEach(((e, n) => {
|
|
16185
16255
|
for (const e of n.Q_)
|
|
16186
16256
|
// Run global snapshot listeners if a consistent snapshot has been emitted.
|
|
16187
|
-
e.
|
|
16257
|
+
e.G_(t) && (r = !0);
|
|
16188
16258
|
})), r && __PRIVATE_raiseSnapshotsInSyncEvent(n);
|
|
16189
|
-
}(r.eventManager, t), e.length && r.
|
|
16259
|
+
}(r.eventManager, t), e.length && r.ya.u_(e), r.onlineState = t, r.isPrimaryClient && r.sharedClientState.setOnlineState(t);
|
|
16190
16260
|
}
|
|
16191
16261
|
}
|
|
16192
16262
|
|
|
@@ -16204,7 +16274,7 @@ async function __PRIVATE_syncEngineListen(e, t) {
|
|
|
16204
16274
|
const r = __PRIVATE_debugCast(e);
|
|
16205
16275
|
// PORTING NOTE: Multi-tab only.
|
|
16206
16276
|
r.sharedClientState.updateQueryState(t, "rejected", n);
|
|
16207
|
-
const i = r.
|
|
16277
|
+
const i = r.Ca.get(t), s = i && i.key;
|
|
16208
16278
|
if (s) {
|
|
16209
16279
|
// TODO(klimt): We really only should do the following on permission
|
|
16210
16280
|
// denied errors, but we don't have the cause code here.
|
|
@@ -16226,7 +16296,7 @@ async function __PRIVATE_syncEngineListen(e, t) {
|
|
|
16226
16296
|
// RemoteEvent. If `applyRemoteEvent()` throws, we want to re-listen to
|
|
16227
16297
|
// this query when the RemoteStore restarts the Watch stream, which should
|
|
16228
16298
|
// re-trigger the target failure.
|
|
16229
|
-
r.
|
|
16299
|
+
r.Da = r.Da.remove(s), r.Ca.delete(t), __PRIVATE_pumpEnqueuedLimboResolutions(r);
|
|
16230
16300
|
} else await __PRIVATE_localStoreReleaseTarget(r.localStore, t,
|
|
16231
16301
|
/* keepPersistedTargetData */ !1).then((() => __PRIVATE_removeAndCleanupTarget(r, t, n))).catch(__PRIVATE_ignoreIfPrimaryLeaseLoss);
|
|
16232
16302
|
}
|
|
@@ -16288,8 +16358,8 @@ async function __PRIVATE_syncEngineRejectFailedWrite(e, t, n) {
|
|
|
16288
16358
|
if (-1 === e)
|
|
16289
16359
|
// Trigger the callback right away if there is no pending writes at the moment.
|
|
16290
16360
|
return void t.resolve();
|
|
16291
|
-
const r = n.
|
|
16292
|
-
r.push(t), n.
|
|
16361
|
+
const r = n.Ma.get(e) || [];
|
|
16362
|
+
r.push(t), n.Ma.set(e, r);
|
|
16293
16363
|
} catch (e) {
|
|
16294
16364
|
const n = __PRIVATE_wrapInUserErrorIfRecoverable(e, "Initialization of waitForPendingWrites() operation failed");
|
|
16295
16365
|
t.reject(n);
|
|
@@ -16300,28 +16370,28 @@ async function __PRIVATE_syncEngineRejectFailedWrite(e, t, n) {
|
|
|
16300
16370
|
* Triggers the callbacks that are waiting for this batch id to get acknowledged by server,
|
|
16301
16371
|
* if there are any.
|
|
16302
16372
|
*/ function __PRIVATE_triggerPendingWritesCallbacks(e, t) {
|
|
16303
|
-
(e.
|
|
16373
|
+
(e.Ma.get(t) || []).forEach((e => {
|
|
16304
16374
|
e.resolve();
|
|
16305
|
-
})), e.
|
|
16375
|
+
})), e.Ma.delete(t);
|
|
16306
16376
|
}
|
|
16307
16377
|
|
|
16308
16378
|
/** Reject all outstanding callbacks waiting for pending writes to complete. */ function __PRIVATE_processUserCallback(e, t, n) {
|
|
16309
16379
|
const r = __PRIVATE_debugCast(e);
|
|
16310
|
-
let i = r.
|
|
16380
|
+
let i = r.Fa[r.currentUser.toKey()];
|
|
16311
16381
|
// NOTE: Mutations restored from persistence won't have callbacks, so it's
|
|
16312
16382
|
// okay for there to be no callback for this ID.
|
|
16313
16383
|
if (i) {
|
|
16314
16384
|
const e = i.get(t);
|
|
16315
|
-
e && (n ? e.reject(n) : e.resolve(), i = i.remove(t)), r.
|
|
16385
|
+
e && (n ? e.reject(n) : e.resolve(), i = i.remove(t)), r.Fa[r.currentUser.toKey()] = i;
|
|
16316
16386
|
}
|
|
16317
16387
|
}
|
|
16318
16388
|
|
|
16319
16389
|
function __PRIVATE_removeAndCleanupTarget(e, t, n = null) {
|
|
16320
16390
|
e.sharedClientState.removeLocalQueryTarget(t);
|
|
16321
|
-
for (const r of e.
|
|
16322
|
-
if (e.
|
|
16323
|
-
e.
|
|
16324
|
-
e.
|
|
16391
|
+
for (const r of e.Sa.get(t)) e.wa.delete(r), n && e.ya.La(r, n);
|
|
16392
|
+
if (e.Sa.delete(t), e.isPrimaryClient) {
|
|
16393
|
+
e.va.Vr(t).forEach((t => {
|
|
16394
|
+
e.va.containsKey(t) ||
|
|
16325
16395
|
// We removed the last reference for this key
|
|
16326
16396
|
__PRIVATE_removeLimboTarget(e, t);
|
|
16327
16397
|
}));
|
|
@@ -16329,19 +16399,19 @@ function __PRIVATE_removeAndCleanupTarget(e, t, n = null) {
|
|
|
16329
16399
|
}
|
|
16330
16400
|
|
|
16331
16401
|
function __PRIVATE_removeLimboTarget(e, t) {
|
|
16332
|
-
e.
|
|
16402
|
+
e.ba.delete(t.path.canonicalString());
|
|
16333
16403
|
// It's possible that the target already got removed because the query failed. In that case,
|
|
16334
16404
|
// the key won't exist in `limboTargetsByKey`. Only do the cleanup if we still have the target.
|
|
16335
|
-
const n = e.
|
|
16336
|
-
null !== n && (__PRIVATE_remoteStoreUnlisten(e.remoteStore, n), e.
|
|
16337
|
-
e.
|
|
16405
|
+
const n = e.Da.get(t);
|
|
16406
|
+
null !== n && (__PRIVATE_remoteStoreUnlisten(e.remoteStore, n), e.Da = e.Da.remove(t),
|
|
16407
|
+
e.Ca.delete(n), __PRIVATE_pumpEnqueuedLimboResolutions(e));
|
|
16338
16408
|
}
|
|
16339
16409
|
|
|
16340
16410
|
function __PRIVATE_updateTrackedLimbos(e, t, n) {
|
|
16341
|
-
for (const r of n) if (r instanceof __PRIVATE_AddedLimboDocument) e.
|
|
16411
|
+
for (const r of n) if (r instanceof __PRIVATE_AddedLimboDocument) e.va.addReference(r.key, t),
|
|
16342
16412
|
__PRIVATE_trackLimboChange(e, r); else if (r instanceof __PRIVATE_RemovedLimboDocument) {
|
|
16343
|
-
__PRIVATE_logDebug("SyncEngine", "Document no longer in limbo: " + r.key), e.
|
|
16344
|
-
e.
|
|
16413
|
+
__PRIVATE_logDebug("SyncEngine", "Document no longer in limbo: " + r.key), e.va.removeReference(r.key, t);
|
|
16414
|
+
e.va.containsKey(r.key) ||
|
|
16345
16415
|
// We removed the last reference for this key
|
|
16346
16416
|
__PRIVATE_removeLimboTarget(e, r.key);
|
|
16347
16417
|
} else fail();
|
|
@@ -16349,8 +16419,8 @@ function __PRIVATE_updateTrackedLimbos(e, t, n) {
|
|
|
16349
16419
|
|
|
16350
16420
|
function __PRIVATE_trackLimboChange(e, t) {
|
|
16351
16421
|
const n = t.key, r = n.path.canonicalString();
|
|
16352
|
-
e.
|
|
16353
|
-
e.
|
|
16422
|
+
e.Da.get(n) || e.ba.has(r) || (__PRIVATE_logDebug("SyncEngine", "New document in limbo: " + n),
|
|
16423
|
+
e.ba.add(r), __PRIVATE_pumpEnqueuedLimboResolutions(e));
|
|
16354
16424
|
}
|
|
16355
16425
|
|
|
16356
16426
|
/**
|
|
@@ -16361,18 +16431,18 @@ function __PRIVATE_trackLimboChange(e, t) {
|
|
|
16361
16431
|
* with "resource exhausted" errors which can lead to pathological client
|
|
16362
16432
|
* behavior as seen in https://github.com/firebase/firebase-js-sdk/issues/2683.
|
|
16363
16433
|
*/ function __PRIVATE_pumpEnqueuedLimboResolutions(e) {
|
|
16364
|
-
for (;e.
|
|
16365
|
-
const t = e.
|
|
16366
|
-
e.
|
|
16367
|
-
const n = new DocumentKey(ResourcePath.fromString(t)), r = e.
|
|
16368
|
-
e.
|
|
16434
|
+
for (;e.ba.size > 0 && e.Da.size < e.maxConcurrentLimboResolutions; ) {
|
|
16435
|
+
const t = e.ba.values().next().value;
|
|
16436
|
+
e.ba.delete(t);
|
|
16437
|
+
const n = new DocumentKey(ResourcePath.fromString(t)), r = e.xa.next();
|
|
16438
|
+
e.Ca.set(r, new LimboResolution(n)), e.Da = e.Da.insert(n, r), __PRIVATE_remoteStoreListen(e.remoteStore, new TargetData(__PRIVATE_queryToTarget(__PRIVATE_newQueryForPath(n.path)), r, "TargetPurposeLimboResolution" /* TargetPurpose.LimboResolution */ , __PRIVATE_ListenSequence._e));
|
|
16369
16439
|
}
|
|
16370
16440
|
}
|
|
16371
16441
|
|
|
16372
16442
|
async function __PRIVATE_syncEngineEmitNewSnapsAndNotifyLocalStore(e, t, n) {
|
|
16373
16443
|
const r = __PRIVATE_debugCast(e), i = [], s = [], o = [];
|
|
16374
|
-
r.
|
|
16375
|
-
o.push(r.
|
|
16444
|
+
r.wa.isEmpty() || (r.wa.forEach(((e, _) => {
|
|
16445
|
+
o.push(r.Na(_, t, n).then((e => {
|
|
16376
16446
|
// Update views if there are actual changes.
|
|
16377
16447
|
if (
|
|
16378
16448
|
// If there are changes, or we are handling a global snapshot, notify
|
|
@@ -16384,7 +16454,7 @@ async function __PRIVATE_syncEngineEmitNewSnapsAndNotifyLocalStore(e, t, n) {
|
|
|
16384
16454
|
s.push(t);
|
|
16385
16455
|
}
|
|
16386
16456
|
})));
|
|
16387
|
-
})), await Promise.all(o), r.
|
|
16457
|
+
})), await Promise.all(o), r.ya.u_(i), await async function __PRIVATE_localStoreNotifyLocalViewChanges(e, t) {
|
|
16388
16458
|
const n = __PRIVATE_debugCast(e);
|
|
16389
16459
|
try {
|
|
16390
16460
|
await n.persistence.runTransaction("notifyLocalViewChanges", "readwrite", (e => PersistencePromise.forEach(t, (t => PersistencePromise.forEach(t.qi, (r => n.persistence.referenceDelegate.addReference(e, t.targetId, r))).next((() => PersistencePromise.forEach(t.Qi, (r => n.persistence.referenceDelegate.removeReference(e, t.targetId, r)))))))));
|
|
@@ -16415,11 +16485,11 @@ async function __PRIVATE_syncEngineHandleCredentialChange(e, t) {
|
|
|
16415
16485
|
n.currentUser = t,
|
|
16416
16486
|
// Fails tasks waiting for pending writes requested by previous user.
|
|
16417
16487
|
function __PRIVATE_rejectOutstandingPendingWritesCallbacks(e, t) {
|
|
16418
|
-
e.
|
|
16488
|
+
e.Ma.forEach((e => {
|
|
16419
16489
|
e.forEach((e => {
|
|
16420
16490
|
e.reject(new FirestoreError(D.CANCELLED, t));
|
|
16421
16491
|
}));
|
|
16422
|
-
})), e.
|
|
16492
|
+
})), e.Ma.clear();
|
|
16423
16493
|
}(n, "'waitForPendingWrites' promise is rejected due to a user change."),
|
|
16424
16494
|
// TODO(b/114226417): Consider calling this only in the primary tab.
|
|
16425
16495
|
n.sharedClientState.handleUserChange(t, e.removedBatchIds, e.addedBatchIds), await __PRIVATE_syncEngineEmitNewSnapsAndNotifyLocalStore(n, e.us);
|
|
@@ -16427,15 +16497,15 @@ async function __PRIVATE_syncEngineHandleCredentialChange(e, t) {
|
|
|
16427
16497
|
}
|
|
16428
16498
|
|
|
16429
16499
|
function __PRIVATE_syncEngineGetRemoteKeysForTarget(e, t) {
|
|
16430
|
-
const n = __PRIVATE_debugCast(e), r = n.
|
|
16431
|
-
if (r && r.
|
|
16500
|
+
const n = __PRIVATE_debugCast(e), r = n.Ca.get(t);
|
|
16501
|
+
if (r && r.pa) return __PRIVATE_documentKeySet().add(r.key);
|
|
16432
16502
|
{
|
|
16433
16503
|
let e = __PRIVATE_documentKeySet();
|
|
16434
|
-
const r = n.
|
|
16504
|
+
const r = n.Sa.get(t);
|
|
16435
16505
|
if (!r) return e;
|
|
16436
16506
|
for (const t of r) {
|
|
16437
|
-
const r = n.
|
|
16438
|
-
e = e.unionWith(r.view.
|
|
16507
|
+
const r = n.wa.get(t);
|
|
16508
|
+
e = e.unionWith(r.view.Ia);
|
|
16439
16509
|
}
|
|
16440
16510
|
return e;
|
|
16441
16511
|
}
|
|
@@ -16446,8 +16516,8 @@ function __PRIVATE_syncEngineGetRemoteKeysForTarget(e, t) {
|
|
|
16446
16516
|
* from persistence.
|
|
16447
16517
|
*/ async function __PRIVATE_synchronizeViewAndComputeSnapshot(e, t) {
|
|
16448
16518
|
const n = __PRIVATE_debugCast(e), r = await __PRIVATE_localStoreExecuteQuery(n.localStore, t.query,
|
|
16449
|
-
/* usePreviousResults= */ !0), i = t.view.
|
|
16450
|
-
return n.isPrimaryClient && __PRIVATE_updateTrackedLimbos(n, t.targetId, i.
|
|
16519
|
+
/* usePreviousResults= */ !0), i = t.view.fa(r);
|
|
16520
|
+
return n.isPrimaryClient && __PRIVATE_updateTrackedLimbos(n, t.targetId, i.Va),
|
|
16451
16521
|
i;
|
|
16452
16522
|
}
|
|
16453
16523
|
|
|
@@ -16498,7 +16568,7 @@ async function __PRIVATE_syncEngineApplyBatchState(e, t, n, r) {
|
|
|
16498
16568
|
async function __PRIVATE_syncEngineApplyPrimaryState(e, t) {
|
|
16499
16569
|
const n = __PRIVATE_debugCast(e);
|
|
16500
16570
|
if (__PRIVATE_ensureWatchCallbacks(n), __PRIVATE_syncEngineEnsureWriteCallbacks(n),
|
|
16501
|
-
!0 === t && !0 !== n.
|
|
16571
|
+
!0 === t && !0 !== n.Oa) {
|
|
16502
16572
|
// Secondary tabs only maintain Views for their local listeners and the
|
|
16503
16573
|
// Views internal state may not be 100% populated (in particular
|
|
16504
16574
|
// secondary tabs don't track syncedDocuments, the set of documents the
|
|
@@ -16506,12 +16576,12 @@ async function __PRIVATE_syncEngineApplyPrimaryState(e, t) {
|
|
|
16506
16576
|
// primary, we need to need to make sure that all views for all targets
|
|
16507
16577
|
// match the state on disk.
|
|
16508
16578
|
const e = n.sharedClientState.getAllActiveQueryTargets(), t = await __PRIVATE_synchronizeQueryViewsAndRaiseSnapshots(n, e.toArray());
|
|
16509
|
-
n.
|
|
16579
|
+
n.Oa = !0, await __PRIVATE_remoteStoreApplyPrimaryState(n.remoteStore, !0);
|
|
16510
16580
|
for (const e of t) __PRIVATE_remoteStoreListen(n.remoteStore, e);
|
|
16511
|
-
} else if (!1 === t && !1 !== n.
|
|
16581
|
+
} else if (!1 === t && !1 !== n.Oa) {
|
|
16512
16582
|
const e = [];
|
|
16513
16583
|
let t = Promise.resolve();
|
|
16514
|
-
n.
|
|
16584
|
+
n.Sa.forEach(((r, i) => {
|
|
16515
16585
|
n.sharedClientState.isLocalQueryTarget(i) ? e.push(i) : t = t.then((() => (__PRIVATE_removeAndCleanupTarget(n, i),
|
|
16516
16586
|
__PRIVATE_localStoreReleaseTarget(n.localStore, i,
|
|
16517
16587
|
/*keepPersistedTargetData=*/ !0)))), __PRIVATE_remoteStoreUnlisten(n.remoteStore, i);
|
|
@@ -16519,9 +16589,9 @@ async function __PRIVATE_syncEngineApplyPrimaryState(e, t) {
|
|
|
16519
16589
|
// PORTING NOTE: Multi-Tab only.
|
|
16520
16590
|
function __PRIVATE_resetLimboDocuments(e) {
|
|
16521
16591
|
const t = __PRIVATE_debugCast(e);
|
|
16522
|
-
t.
|
|
16592
|
+
t.Ca.forEach(((e, n) => {
|
|
16523
16593
|
__PRIVATE_remoteStoreUnlisten(t.remoteStore, n);
|
|
16524
|
-
})), t.
|
|
16594
|
+
})), t.va.mr(), t.Ca = new Map, t.Da = new SortedMap(DocumentKey.comparator);
|
|
16525
16595
|
}
|
|
16526
16596
|
/**
|
|
16527
16597
|
* Reconcile the query views of the provided query targets with the state from
|
|
@@ -16534,7 +16604,7 @@ async function __PRIVATE_syncEngineApplyPrimaryState(e, t) {
|
|
|
16534
16604
|
* tab to a primary tab
|
|
16535
16605
|
*/
|
|
16536
16606
|
// PORTING NOTE: Multi-Tab only.
|
|
16537
|
-
(n), n.
|
|
16607
|
+
(n), n.Oa = !1, await __PRIVATE_remoteStoreApplyPrimaryState(n.remoteStore, !1);
|
|
16538
16608
|
}
|
|
16539
16609
|
}
|
|
16540
16610
|
|
|
@@ -16542,7 +16612,7 @@ async function __PRIVATE_synchronizeQueryViewsAndRaiseSnapshots(e, t, n) {
|
|
|
16542
16612
|
const r = __PRIVATE_debugCast(e), i = [], s = [];
|
|
16543
16613
|
for (const e of t) {
|
|
16544
16614
|
let t;
|
|
16545
|
-
const n = r.
|
|
16615
|
+
const n = r.Sa.get(e);
|
|
16546
16616
|
if (n && 0 !== n.length) {
|
|
16547
16617
|
// For queries that have a local View, we fetch their current state
|
|
16548
16618
|
// from LocalStore (as the resume token and the snapshot version
|
|
@@ -16550,7 +16620,7 @@ async function __PRIVATE_synchronizeQueryViewsAndRaiseSnapshots(e, t, n) {
|
|
|
16550
16620
|
// state (the list of syncedDocuments may have gotten out of sync).
|
|
16551
16621
|
t = await __PRIVATE_localStoreAllocateTarget(r.localStore, __PRIVATE_queryToTarget(n[0]));
|
|
16552
16622
|
for (const e of n) {
|
|
16553
|
-
const t = r.
|
|
16623
|
+
const t = r.wa.get(e), n = await __PRIVATE_synchronizeViewAndComputeSnapshot(r, t);
|
|
16554
16624
|
n.snapshot && s.push(n.snapshot);
|
|
16555
16625
|
}
|
|
16556
16626
|
} else {
|
|
@@ -16562,7 +16632,7 @@ async function __PRIVATE_synchronizeQueryViewsAndRaiseSnapshots(e, t, n) {
|
|
|
16562
16632
|
}
|
|
16563
16633
|
i.push(t);
|
|
16564
16634
|
}
|
|
16565
|
-
return r.
|
|
16635
|
+
return r.ya.u_(s), i;
|
|
16566
16636
|
}
|
|
16567
16637
|
|
|
16568
16638
|
/**
|
|
@@ -16584,7 +16654,7 @@ function __PRIVATE_synthesizeTargetToQuery(e) {
|
|
|
16584
16654
|
// PORTING NOTE: Multi-Tab only.
|
|
16585
16655
|
function __PRIVATE_syncEngineGetActiveClients(e) {
|
|
16586
16656
|
return function __PRIVATE_localStoreGetActiveClients(e) {
|
|
16587
|
-
return __PRIVATE_debugCast(__PRIVATE_debugCast(e).persistence).
|
|
16657
|
+
return __PRIVATE_debugCast(__PRIVATE_debugCast(e).persistence).Bi();
|
|
16588
16658
|
}(__PRIVATE_debugCast(e).localStore);
|
|
16589
16659
|
}
|
|
16590
16660
|
|
|
@@ -16592,11 +16662,11 @@ function __PRIVATE_syncEngineGetActiveClients(e) {
|
|
|
16592
16662
|
// PORTING NOTE: Multi-Tab only.
|
|
16593
16663
|
async function __PRIVATE_syncEngineApplyTargetState(e, t, n, r) {
|
|
16594
16664
|
const i = __PRIVATE_debugCast(e);
|
|
16595
|
-
if (i.
|
|
16665
|
+
if (i.Oa)
|
|
16596
16666
|
// If we receive a target state notification via WebStorage, we are
|
|
16597
16667
|
// either already secondary or another tab has taken the primary lease.
|
|
16598
16668
|
return void __PRIVATE_logDebug("SyncEngine", "Ignoring unexpected query state notification.");
|
|
16599
|
-
const s = i.
|
|
16669
|
+
const s = i.Sa.get(t);
|
|
16600
16670
|
if (s && s.length > 0) switch (n) {
|
|
16601
16671
|
case "current":
|
|
16602
16672
|
case "not-current":
|
|
@@ -16618,10 +16688,9 @@ async function __PRIVATE_syncEngineApplyTargetState(e, t, n, r) {
|
|
|
16618
16688
|
|
|
16619
16689
|
/** Adds or removes Watch targets for queries from different tabs. */ async function __PRIVATE_syncEngineApplyActiveTargetsChange(e, t, n) {
|
|
16620
16690
|
const r = __PRIVATE_ensureWatchCallbacks(e);
|
|
16621
|
-
if (r.
|
|
16691
|
+
if (r.Oa) {
|
|
16622
16692
|
for (const e of t) {
|
|
16623
|
-
if (r.
|
|
16624
|
-
// A target might have been added in a previous attempt
|
|
16693
|
+
if (r.Sa.has(e) && r.sharedClientState.isActiveQueryTarget(e)) {
|
|
16625
16694
|
__PRIVATE_logDebug("SyncEngine", "Adding an already active target " + e);
|
|
16626
16695
|
continue;
|
|
16627
16696
|
}
|
|
@@ -16632,7 +16701,7 @@ async function __PRIVATE_syncEngineApplyTargetState(e, t, n, r) {
|
|
|
16632
16701
|
for (const e of n)
|
|
16633
16702
|
// Check that the target is still active since the target might have been
|
|
16634
16703
|
// removed if it has been rejected by the backend.
|
|
16635
|
-
r.
|
|
16704
|
+
r.Sa.has(e) &&
|
|
16636
16705
|
// Release queries that are still active.
|
|
16637
16706
|
await __PRIVATE_localStoreReleaseTarget(r.localStore, e,
|
|
16638
16707
|
/* keepPersistedTargetData */ !1).then((() => {
|
|
@@ -16646,7 +16715,7 @@ function __PRIVATE_ensureWatchCallbacks(e) {
|
|
|
16646
16715
|
return t.remoteStore.remoteSyncer.applyRemoteEvent = __PRIVATE_syncEngineApplyRemoteEvent.bind(null, t),
|
|
16647
16716
|
t.remoteStore.remoteSyncer.getRemoteKeysForTarget = __PRIVATE_syncEngineGetRemoteKeysForTarget.bind(null, t),
|
|
16648
16717
|
t.remoteStore.remoteSyncer.rejectListen = __PRIVATE_syncEngineRejectListen.bind(null, t),
|
|
16649
|
-
t.
|
|
16718
|
+
t.ya.u_ = __PRIVATE_eventManagerOnWatchChange.bind(null, t.eventManager), t.ya.La = __PRIVATE_eventManagerOnWatchError.bind(null, t.eventManager),
|
|
16650
16719
|
t;
|
|
16651
16720
|
}
|
|
16652
16721
|
|
|
@@ -16689,13 +16758,13 @@ function __PRIVATE_syncEngineEnsureWriteCallbacks(e) {
|
|
|
16689
16758
|
}(r)), Promise.resolve(new Set);
|
|
16690
16759
|
n._updateProgress(__PRIVATE_bundleInitialProgress(r));
|
|
16691
16760
|
const i = new __PRIVATE_BundleLoader(r, e.localStore, t.serializer);
|
|
16692
|
-
let s = await t.
|
|
16761
|
+
let s = await t.Ba();
|
|
16693
16762
|
for (;s; ) {
|
|
16694
|
-
const e = await i.
|
|
16695
|
-
e && n._updateProgress(e), s = await t.
|
|
16763
|
+
const e = await i.sa(s);
|
|
16764
|
+
e && n._updateProgress(e), s = await t.Ba();
|
|
16696
16765
|
}
|
|
16697
16766
|
const o = await i.complete();
|
|
16698
|
-
return await __PRIVATE_syncEngineEmitNewSnapsAndNotifyLocalStore(e, o.
|
|
16767
|
+
return await __PRIVATE_syncEngineEmitNewSnapsAndNotifyLocalStore(e, o.aa,
|
|
16699
16768
|
/* remoteEvent */ void 0),
|
|
16700
16769
|
// Save metadata, so loading the same bundle will skip.
|
|
16701
16770
|
await function __PRIVATE_localStoreSaveBundle(e, t) {
|
|
@@ -16705,7 +16774,7 @@ function __PRIVATE_syncEngineEnsureWriteCallbacks(e) {
|
|
|
16705
16774
|
/**
|
|
16706
16775
|
* Returns a promise of a `NamedQuery` associated with given query name. Promise
|
|
16707
16776
|
* resolves to undefined if no persisted data can be found.
|
|
16708
|
-
*/ (e.localStore, r), n._completeWith(o.progress), Promise.resolve(o.
|
|
16777
|
+
*/ (e.localStore, r), n._completeWith(o.progress), Promise.resolve(o._a);
|
|
16709
16778
|
} catch (e) {
|
|
16710
16779
|
return __PRIVATE_logWarn("SyncEngine", `Loading bundle failed with ${e}`), n._failWith(e),
|
|
16711
16780
|
Promise.resolve(new Set);
|
|
@@ -16785,12 +16854,12 @@ class __PRIVATE_LruGcMemoryOfflineComponentProvider extends MemoryOfflineCompone
|
|
|
16785
16854
|
* Provides all components needed for Firestore with IndexedDB persistence.
|
|
16786
16855
|
*/ class __PRIVATE_IndexedDbOfflineComponentProvider extends MemoryOfflineComponentProvider {
|
|
16787
16856
|
constructor(e, t, n) {
|
|
16788
|
-
super(), this.
|
|
16857
|
+
super(), this.ka = e, this.cacheSizeBytes = t, this.forceOwnership = n, this.synchronizeTabs = !1;
|
|
16789
16858
|
}
|
|
16790
16859
|
async initialize(e) {
|
|
16791
|
-
await super.initialize(e), await this.
|
|
16860
|
+
await super.initialize(e), await this.ka.initialize(this, e),
|
|
16792
16861
|
// Enqueue writes from a previous session
|
|
16793
|
-
await __PRIVATE_syncEngineEnsureWriteCallbacks(this.
|
|
16862
|
+
await __PRIVATE_syncEngineEnsureWriteCallbacks(this.ka.syncEngine), await __PRIVATE_fillWritePipeline(this.ka.remoteStore),
|
|
16794
16863
|
// NOTE: This will immediately call the listener, so we make sure to
|
|
16795
16864
|
// set it after localStore / remoteStore are started.
|
|
16796
16865
|
await this.persistence.fi((() => (this.gcScheduler && !this.gcScheduler.started && this.gcScheduler.start(),
|
|
@@ -16826,22 +16895,22 @@ class __PRIVATE_LruGcMemoryOfflineComponentProvider extends MemoryOfflineCompone
|
|
|
16826
16895
|
* `synchronizeTabs` will be enabled.
|
|
16827
16896
|
*/ class __PRIVATE_MultiTabOfflineComponentProvider extends __PRIVATE_IndexedDbOfflineComponentProvider {
|
|
16828
16897
|
constructor(e, t) {
|
|
16829
|
-
super(e, t, /* forceOwnership= */ !1), this.
|
|
16898
|
+
super(e, t, /* forceOwnership= */ !1), this.ka = e, this.cacheSizeBytes = t, this.synchronizeTabs = !0;
|
|
16830
16899
|
}
|
|
16831
16900
|
async initialize(e) {
|
|
16832
16901
|
await super.initialize(e);
|
|
16833
|
-
const t = this.
|
|
16902
|
+
const t = this.ka.syncEngine;
|
|
16834
16903
|
this.sharedClientState instanceof __PRIVATE_WebStorageSharedClientState && (this.sharedClientState.syncEngine = {
|
|
16835
16904
|
Zs: __PRIVATE_syncEngineApplyBatchState.bind(null, t),
|
|
16836
16905
|
Xs: __PRIVATE_syncEngineApplyTargetState.bind(null, t),
|
|
16837
16906
|
eo: __PRIVATE_syncEngineApplyActiveTargetsChange.bind(null, t),
|
|
16838
|
-
|
|
16907
|
+
Bi: __PRIVATE_syncEngineGetActiveClients.bind(null, t),
|
|
16839
16908
|
Ys: __PRIVATE_syncEngineSynchronizeWithChangedDocuments.bind(null, t)
|
|
16840
16909
|
}, await this.sharedClientState.start()),
|
|
16841
16910
|
// NOTE: This will immediately call the listener, so we make sure to
|
|
16842
16911
|
// set it after localStore / remoteStore are started.
|
|
16843
16912
|
await this.persistence.fi((async e => {
|
|
16844
|
-
await __PRIVATE_syncEngineApplyPrimaryState(this.
|
|
16913
|
+
await __PRIVATE_syncEngineApplyPrimaryState(this.ka.syncEngine, e), this.gcScheduler && (e && !this.gcScheduler.started ? this.gcScheduler.start() : e || this.gcScheduler.stop()),
|
|
16845
16914
|
this.indexBackfillerScheduler && (e && !this.indexBackfillerScheduler.started ? this.indexBackfillerScheduler.start() : e || this.indexBackfillerScheduler.stop());
|
|
16846
16915
|
}));
|
|
16847
16916
|
}
|
|
@@ -16892,7 +16961,7 @@ class __PRIVATE_LruGcMemoryOfflineComponentProvider extends MemoryOfflineCompone
|
|
|
16892
16961
|
// PORTING NOTE: Manages state synchronization in multi-tab environments.
|
|
16893
16962
|
r, i, s, o) {
|
|
16894
16963
|
const _ = new __PRIVATE_SyncEngineImpl(e, t, n, r, i, s);
|
|
16895
|
-
return o && (_.
|
|
16964
|
+
return o && (_.Oa = !0), _;
|
|
16896
16965
|
}(this.localStore, this.remoteStore, this.eventManager, this.sharedClientState, e.initialUser, e.maxConcurrentLimboResolutions, t);
|
|
16897
16966
|
}
|
|
16898
16967
|
async terminate() {
|
|
@@ -17011,15 +17080,15 @@ class __PRIVATE_AsyncObserver {
|
|
|
17011
17080
|
this.muted = !1;
|
|
17012
17081
|
}
|
|
17013
17082
|
next(e) {
|
|
17014
|
-
this.observer.next && this.
|
|
17083
|
+
this.observer.next && this.qa(this.observer.next, e);
|
|
17015
17084
|
}
|
|
17016
17085
|
error(e) {
|
|
17017
|
-
this.observer.error ? this.
|
|
17086
|
+
this.observer.error ? this.qa(this.observer.error, e) : __PRIVATE_logError("Uncaught Error in snapshot listener:", e.toString());
|
|
17018
17087
|
}
|
|
17019
|
-
|
|
17088
|
+
Qa() {
|
|
17020
17089
|
this.muted = !0;
|
|
17021
17090
|
}
|
|
17022
|
-
|
|
17091
|
+
qa(e, t) {
|
|
17023
17092
|
this.muted || setTimeout((() => {
|
|
17024
17093
|
this.muted || e(t);
|
|
17025
17094
|
}), 0);
|
|
@@ -17051,30 +17120,30 @@ class __PRIVATE_AsyncObserver {
|
|
|
17051
17120
|
constructor(
|
|
17052
17121
|
/** The reader to read from underlying binary bundle data source. */
|
|
17053
17122
|
e, t) {
|
|
17054
|
-
this.
|
|
17123
|
+
this.Ka = e, this.serializer = t,
|
|
17055
17124
|
/** Cached bundle metadata. */
|
|
17056
17125
|
this.metadata = new __PRIVATE_Deferred,
|
|
17057
17126
|
/**
|
|
17058
17127
|
* Internal buffer to hold bundle content, accumulating incomplete element
|
|
17059
17128
|
* content.
|
|
17060
17129
|
*/
|
|
17061
|
-
this.buffer = new Uint8Array, this
|
|
17130
|
+
this.buffer = new Uint8Array, this.$a = function __PRIVATE_newTextDecoder() {
|
|
17062
17131
|
return new TextDecoder("utf-8");
|
|
17063
17132
|
}(),
|
|
17064
17133
|
// Read the metadata (which is the first element).
|
|
17065
|
-
this.
|
|
17066
|
-
e && e.
|
|
17134
|
+
this.Ua().then((e => {
|
|
17135
|
+
e && e.ra() ? this.metadata.resolve(e.na.metadata) : this.metadata.reject(new Error(`The first element of the bundle is not a metadata, it is\n ${JSON.stringify(null == e ? void 0 : e.na)}`));
|
|
17067
17136
|
}), (e => this.metadata.reject(e)));
|
|
17068
17137
|
}
|
|
17069
17138
|
close() {
|
|
17070
|
-
return this.
|
|
17139
|
+
return this.Ka.cancel();
|
|
17071
17140
|
}
|
|
17072
17141
|
async getMetadata() {
|
|
17073
17142
|
return this.metadata.promise;
|
|
17074
17143
|
}
|
|
17075
|
-
async
|
|
17144
|
+
async Ba() {
|
|
17076
17145
|
// Makes sure metadata is read before proceeding.
|
|
17077
|
-
return await this.getMetadata(), this.
|
|
17146
|
+
return await this.getMetadata(), this.Ua();
|
|
17078
17147
|
}
|
|
17079
17148
|
/**
|
|
17080
17149
|
* Reads from the head of internal buffer, and pulling more data from
|
|
@@ -17085,15 +17154,15 @@ class __PRIVATE_AsyncObserver {
|
|
|
17085
17154
|
*
|
|
17086
17155
|
* Returns either the bundled element, or null if we have reached the end of
|
|
17087
17156
|
* the stream.
|
|
17088
|
-
*/ async
|
|
17089
|
-
const e = await this.
|
|
17157
|
+
*/ async Ua() {
|
|
17158
|
+
const e = await this.Wa();
|
|
17090
17159
|
if (null === e) return null;
|
|
17091
|
-
const t = this.
|
|
17092
|
-
isNaN(n) && this
|
|
17093
|
-
const r = await this.
|
|
17160
|
+
const t = this.$a.decode(e), n = Number(t);
|
|
17161
|
+
isNaN(n) && this.Ga(`length string (${t}) is not valid number`);
|
|
17162
|
+
const r = await this.za(n);
|
|
17094
17163
|
return new __PRIVATE_SizedBundleElement(JSON.parse(r), e.length + n);
|
|
17095
17164
|
}
|
|
17096
|
-
/** First index of '{' from the underlying buffer. */
|
|
17165
|
+
/** First index of '{' from the underlying buffer. */ ja() {
|
|
17097
17166
|
return this.buffer.findIndex((e => e === "{".charCodeAt(0)));
|
|
17098
17167
|
}
|
|
17099
17168
|
/**
|
|
@@ -17101,17 +17170,17 @@ class __PRIVATE_AsyncObserver {
|
|
|
17101
17170
|
* return the content.
|
|
17102
17171
|
*
|
|
17103
17172
|
* If reached end of the stream, returns a null.
|
|
17104
|
-
*/ async
|
|
17105
|
-
for (;this.
|
|
17106
|
-
if (await this.
|
|
17173
|
+
*/ async Wa() {
|
|
17174
|
+
for (;this.ja() < 0; ) {
|
|
17175
|
+
if (await this.Ha()) break;
|
|
17107
17176
|
}
|
|
17108
17177
|
// Broke out of the loop because underlying stream is closed, and there
|
|
17109
17178
|
// happens to be no more data to process.
|
|
17110
17179
|
if (0 === this.buffer.length) return null;
|
|
17111
|
-
const e = this.
|
|
17180
|
+
const e = this.ja();
|
|
17112
17181
|
// Broke out of the loop because underlying stream is closed, but still
|
|
17113
17182
|
// cannot find an open bracket.
|
|
17114
|
-
e < 0 && this
|
|
17183
|
+
e < 0 && this.Ga("Reached the end of bundle when a length string is expected.");
|
|
17115
17184
|
const t = this.buffer.slice(0, e);
|
|
17116
17185
|
// Update the internal buffer to drop the read length.
|
|
17117
17186
|
return this.buffer = this.buffer.slice(e), t;
|
|
@@ -17121,23 +17190,23 @@ class __PRIVATE_AsyncObserver {
|
|
|
17121
17190
|
* number of bytes, pulling more data from the underlying stream if needed.
|
|
17122
17191
|
*
|
|
17123
17192
|
* Returns a string decoded from the read bytes.
|
|
17124
|
-
*/ async
|
|
17193
|
+
*/ async za(e) {
|
|
17125
17194
|
for (;this.buffer.length < e; ) {
|
|
17126
|
-
await this.
|
|
17195
|
+
await this.Ha() && this.Ga("Reached the end of bundle when more is expected.");
|
|
17127
17196
|
}
|
|
17128
|
-
const t = this.
|
|
17197
|
+
const t = this.$a.decode(this.buffer.slice(0, e));
|
|
17129
17198
|
// Update the internal buffer to drop the read json string.
|
|
17130
17199
|
return this.buffer = this.buffer.slice(e), t;
|
|
17131
17200
|
}
|
|
17132
|
-
|
|
17201
|
+
Ga(e) {
|
|
17133
17202
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
17134
|
-
throw this.
|
|
17203
|
+
throw this.Ka.cancel(), new Error(`Invalid bundle format: ${e}`);
|
|
17135
17204
|
}
|
|
17136
17205
|
/**
|
|
17137
17206
|
* Pulls more data from underlying stream to internal buffer.
|
|
17138
17207
|
* Returns a boolean indicating whether the stream is finished.
|
|
17139
|
-
*/ async
|
|
17140
|
-
const e = await this.
|
|
17208
|
+
*/ async Ha() {
|
|
17209
|
+
const e = await this.Ka.read();
|
|
17141
17210
|
if (!e.done) {
|
|
17142
17211
|
const t = new Uint8Array(this.buffer.length + e.value.length);
|
|
17143
17212
|
t.set(this.buffer), t.set(e.value, this.buffer.length), this.buffer = t;
|
|
@@ -17310,26 +17379,26 @@ class Transaction$2 {
|
|
|
17310
17379
|
*/ class __PRIVATE_TransactionRunner {
|
|
17311
17380
|
constructor(e, t, n, r, i) {
|
|
17312
17381
|
this.asyncQueue = e, this.datastore = t, this.options = n, this.updateFunction = r,
|
|
17313
|
-
this.deferred = i, this.
|
|
17382
|
+
this.deferred = i, this.Ja = n.maxAttempts, this.jo = new __PRIVATE_ExponentialBackoff(this.asyncQueue, "transaction_retry" /* TimerId.TransactionRetry */);
|
|
17314
17383
|
}
|
|
17315
|
-
/** Runs the transaction and sets the result on deferred. */
|
|
17316
|
-
this.
|
|
17384
|
+
/** Runs the transaction and sets the result on deferred. */ Ya() {
|
|
17385
|
+
this.Ja -= 1, this.Za();
|
|
17317
17386
|
}
|
|
17318
|
-
|
|
17387
|
+
Za() {
|
|
17319
17388
|
this.jo.qo((async () => {
|
|
17320
|
-
const e = new Transaction$2(this.datastore), t = this.
|
|
17389
|
+
const e = new Transaction$2(this.datastore), t = this.Xa(e);
|
|
17321
17390
|
t && t.then((t => {
|
|
17322
17391
|
this.asyncQueue.enqueueAndForget((() => e.commit().then((() => {
|
|
17323
17392
|
this.deferred.resolve(t);
|
|
17324
17393
|
})).catch((e => {
|
|
17325
|
-
this.
|
|
17394
|
+
this.eu(e);
|
|
17326
17395
|
}))));
|
|
17327
17396
|
})).catch((e => {
|
|
17328
|
-
this.
|
|
17397
|
+
this.eu(e);
|
|
17329
17398
|
}));
|
|
17330
17399
|
}));
|
|
17331
17400
|
}
|
|
17332
|
-
|
|
17401
|
+
Xa(e) {
|
|
17333
17402
|
try {
|
|
17334
17403
|
const t = this.updateFunction(e);
|
|
17335
17404
|
return !__PRIVATE_isNullOrUndefined(t) && t.catch && t.then ? t : (this.deferred.reject(Error("Transaction callback must return a Promise")),
|
|
@@ -17339,11 +17408,11 @@ class Transaction$2 {
|
|
|
17339
17408
|
return this.deferred.reject(e), null;
|
|
17340
17409
|
}
|
|
17341
17410
|
}
|
|
17342
|
-
|
|
17343
|
-
this.
|
|
17411
|
+
eu(e) {
|
|
17412
|
+
this.Ja > 0 && this.tu(e) ? (this.Ja -= 1, this.asyncQueue.enqueueAndForget((() => (this.Za(),
|
|
17344
17413
|
Promise.resolve())))) : this.deferred.reject(e);
|
|
17345
17414
|
}
|
|
17346
|
-
|
|
17415
|
+
tu(e) {
|
|
17347
17416
|
if ("FirebaseError" === e.name) {
|
|
17348
17417
|
// In transactions, the backend will fail outdated reads with FAILED_PRECONDITION and
|
|
17349
17418
|
// non-matching document versions with ABORTED. These errors should be retried.
|
|
@@ -17518,6 +17587,8 @@ function __PRIVATE_getDatastore(e) {
|
|
|
17518
17587
|
async function __PRIVATE_getEventManager(e) {
|
|
17519
17588
|
const t = await __PRIVATE_ensureOnlineComponents(e), n = t.eventManager;
|
|
17520
17589
|
return n.onListen = __PRIVATE_syncEngineListen.bind(null, t.syncEngine), n.onUnlisten = __PRIVATE_syncEngineUnlisten.bind(null, t.syncEngine),
|
|
17590
|
+
n.onFirstRemoteStoreListen = __PRIVATE_triggerRemoteStoreListen.bind(null, t.syncEngine),
|
|
17591
|
+
n.onLastRemoteStoreUnlisten = __PRIVATE_triggerRemoteStoreUnlisten.bind(null, t.syncEngine),
|
|
17521
17592
|
n;
|
|
17522
17593
|
}
|
|
17523
17594
|
|
|
@@ -17589,7 +17660,7 @@ function __PRIVATE_firestoreClientGetDocumentViaSnapshotListener(e, t, n = {}) {
|
|
|
17589
17660
|
error: e => i.reject(e)
|
|
17590
17661
|
}), o = new __PRIVATE_QueryListener(__PRIVATE_newQueryForPath(n.path), s, {
|
|
17591
17662
|
includeMetadataChanges: !0,
|
|
17592
|
-
|
|
17663
|
+
ta: !0
|
|
17593
17664
|
});
|
|
17594
17665
|
return __PRIVATE_eventManagerListen(e, o);
|
|
17595
17666
|
}(await __PRIVATE_getEventManager(e), e.asyncQueue, t, n, r))), r.promise;
|
|
@@ -17600,7 +17671,7 @@ function __PRIVATE_firestoreClientGetDocumentsFromLocalCache(e, t) {
|
|
|
17600
17671
|
return e.asyncQueue.enqueueAndForget((async () => async function __PRIVATE_executeQueryFromCache(e, t, n) {
|
|
17601
17672
|
try {
|
|
17602
17673
|
const r = await __PRIVATE_localStoreExecuteQuery(e, t,
|
|
17603
|
-
/* usePreviousResults= */ !0), i = new __PRIVATE_View(t, r.hs), s = i.
|
|
17674
|
+
/* usePreviousResults= */ !0), i = new __PRIVATE_View(t, r.hs), s = i.Ta(r.documents), o = i.applyChanges(s,
|
|
17604
17675
|
/* limboResolutionEnabled= */ !1);
|
|
17605
17676
|
n.resolve(o.snapshot);
|
|
17606
17677
|
} catch (e) {
|
|
@@ -17626,7 +17697,7 @@ function __PRIVATE_firestoreClientGetDocumentsViaSnapshotListener(e, t, n = {})
|
|
|
17626
17697
|
error: e => i.reject(e)
|
|
17627
17698
|
}), o = new __PRIVATE_QueryListener(n, s, {
|
|
17628
17699
|
includeMetadataChanges: !0,
|
|
17629
|
-
|
|
17700
|
+
ta: !0
|
|
17630
17701
|
});
|
|
17631
17702
|
return __PRIVATE_eventManagerListen(e, o);
|
|
17632
17703
|
}(await __PRIVATE_getEventManager(e), e.asyncQueue, t, n, r))), r.promise;
|
|
@@ -17635,13 +17706,13 @@ function __PRIVATE_firestoreClientGetDocumentsViaSnapshotListener(e, t, n = {})
|
|
|
17635
17706
|
function __PRIVATE_firestoreClientAddSnapshotsInSyncListener(e, t) {
|
|
17636
17707
|
const n = new __PRIVATE_AsyncObserver(t);
|
|
17637
17708
|
return e.asyncQueue.enqueueAndForget((async () => function __PRIVATE_addSnapshotsInSyncListener(e, t) {
|
|
17638
|
-
__PRIVATE_debugCast(e).
|
|
17709
|
+
__PRIVATE_debugCast(e).W_.add(t),
|
|
17639
17710
|
// Immediately fire an initial event, indicating all existing listeners
|
|
17640
17711
|
// are in-sync.
|
|
17641
17712
|
t.next();
|
|
17642
17713
|
}(await __PRIVATE_getEventManager(e), n))), () => {
|
|
17643
|
-
n.
|
|
17644
|
-
__PRIVATE_debugCast(e).
|
|
17714
|
+
n.Qa(), e.asyncQueue.enqueueAndForget((async () => function __PRIVATE_removeSnapshotsInSyncListener(e, t) {
|
|
17715
|
+
__PRIVATE_debugCast(e).W_.delete(t);
|
|
17645
17716
|
}(await __PRIVATE_getEventManager(e), n)));
|
|
17646
17717
|
};
|
|
17647
17718
|
}
|
|
@@ -17821,7 +17892,7 @@ function __PRIVATE_cloneLongPollingOptions(e) {
|
|
|
17821
17892
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17822
17893
|
* See the License for the specific language governing permissions and
|
|
17823
17894
|
* limitations under the License.
|
|
17824
|
-
*/ const
|
|
17895
|
+
*/ const ge = new Map;
|
|
17825
17896
|
|
|
17826
17897
|
/**
|
|
17827
17898
|
* An instance map that ensures only one Datastore exists per Firestore
|
|
@@ -18067,8 +18138,8 @@ class Firestore$1 {
|
|
|
18067
18138
|
* when the `Firestore` instance is terminated.
|
|
18068
18139
|
*/
|
|
18069
18140
|
return function __PRIVATE_removeComponents(e) {
|
|
18070
|
-
const t =
|
|
18071
|
-
t && (__PRIVATE_logDebug("ComponentProvider", "Removing Datastore"),
|
|
18141
|
+
const t = ge.get(e);
|
|
18142
|
+
t && (__PRIVATE_logDebug("ComponentProvider", "Removing Datastore"), ge.delete(e),
|
|
18072
18143
|
t.terminate());
|
|
18073
18144
|
}(this), Promise.resolve();
|
|
18074
18145
|
}
|
|
@@ -18306,40 +18377,40 @@ function doc(e, t, ...n) {
|
|
|
18306
18377
|
*/ class __PRIVATE_AsyncQueueImpl {
|
|
18307
18378
|
constructor() {
|
|
18308
18379
|
// The last promise in the queue.
|
|
18309
|
-
this.
|
|
18380
|
+
this.nu = Promise.resolve(),
|
|
18310
18381
|
// A list of retryable operations. Retryable operations are run in order and
|
|
18311
18382
|
// retried with backoff.
|
|
18312
|
-
this.
|
|
18383
|
+
this.ru = [],
|
|
18313
18384
|
// Is this AsyncQueue being shut down? Once it is set to true, it will not
|
|
18314
18385
|
// be changed again.
|
|
18315
|
-
this.
|
|
18386
|
+
this.iu = !1,
|
|
18316
18387
|
// Operations scheduled to be queued in the future. Operations are
|
|
18317
18388
|
// automatically removed after they are run or canceled.
|
|
18318
|
-
this.
|
|
18389
|
+
this.su = [],
|
|
18319
18390
|
// visible for testing
|
|
18320
|
-
this.
|
|
18391
|
+
this.ou = null,
|
|
18321
18392
|
// Flag set while there's an outstanding AsyncQueue operation, used for
|
|
18322
18393
|
// assertion sanity-checks.
|
|
18323
|
-
this.
|
|
18394
|
+
this._u = !1,
|
|
18324
18395
|
// Enabled during shutdown on Safari to prevent future access to IndexedDB.
|
|
18325
|
-
this.
|
|
18396
|
+
this.au = !1,
|
|
18326
18397
|
// List of TimerIds to fast-forward delays for.
|
|
18327
|
-
this.
|
|
18398
|
+
this.uu = [],
|
|
18328
18399
|
// Backoff timer used to schedule retries for retryable operations
|
|
18329
18400
|
this.jo = new __PRIVATE_ExponentialBackoff(this, "async_queue_retry" /* TimerId.AsyncQueueRetry */),
|
|
18330
18401
|
// Visibility handler that triggers an immediate retry of all retryable
|
|
18331
18402
|
// operations. Meant to speed up recovery when we regain file system access
|
|
18332
18403
|
// after page comes into foreground.
|
|
18333
|
-
this.
|
|
18404
|
+
this.cu = () => {
|
|
18334
18405
|
const e = getDocument();
|
|
18335
18406
|
e && __PRIVATE_logDebug("AsyncQueue", "Visibility state changed to " + e.visibilityState),
|
|
18336
18407
|
this.jo.Ko();
|
|
18337
18408
|
};
|
|
18338
18409
|
const e = getDocument();
|
|
18339
|
-
e && "function" == typeof e.addEventListener && e.addEventListener("visibilitychange", this.
|
|
18410
|
+
e && "function" == typeof e.addEventListener && e.addEventListener("visibilitychange", this.cu);
|
|
18340
18411
|
}
|
|
18341
18412
|
get isShuttingDown() {
|
|
18342
|
-
return this.
|
|
18413
|
+
return this.iu;
|
|
18343
18414
|
}
|
|
18344
18415
|
/**
|
|
18345
18416
|
* Adds a new operation to the queue without waiting for it to complete (i.e.
|
|
@@ -18349,44 +18420,44 @@ function doc(e, t, ...n) {
|
|
|
18349
18420
|
this.enqueue(e);
|
|
18350
18421
|
}
|
|
18351
18422
|
enqueueAndForgetEvenWhileRestricted(e) {
|
|
18352
|
-
this.
|
|
18423
|
+
this.lu(),
|
|
18353
18424
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
18354
|
-
this.
|
|
18425
|
+
this.hu(e);
|
|
18355
18426
|
}
|
|
18356
18427
|
enterRestrictedMode(e) {
|
|
18357
|
-
if (!this.
|
|
18358
|
-
this.
|
|
18428
|
+
if (!this.iu) {
|
|
18429
|
+
this.iu = !0, this.au = e || !1;
|
|
18359
18430
|
const t = getDocument();
|
|
18360
|
-
t && "function" == typeof t.removeEventListener && t.removeEventListener("visibilitychange", this.
|
|
18431
|
+
t && "function" == typeof t.removeEventListener && t.removeEventListener("visibilitychange", this.cu);
|
|
18361
18432
|
}
|
|
18362
18433
|
}
|
|
18363
18434
|
enqueue(e) {
|
|
18364
|
-
if (this.
|
|
18435
|
+
if (this.lu(), this.iu)
|
|
18365
18436
|
// Return a Promise which never resolves.
|
|
18366
18437
|
return new Promise((() => {}));
|
|
18367
18438
|
// Create a deferred Promise that we can return to the callee. This
|
|
18368
18439
|
// allows us to return a "hanging Promise" only to the callee and still
|
|
18369
18440
|
// advance the queue even when the operation is not run.
|
|
18370
18441
|
const t = new __PRIVATE_Deferred;
|
|
18371
|
-
return this.
|
|
18442
|
+
return this.hu((() => this.iu && this.au ? Promise.resolve() : (e().then(t.resolve, t.reject),
|
|
18372
18443
|
t.promise))).then((() => t.promise));
|
|
18373
18444
|
}
|
|
18374
18445
|
enqueueRetryable(e) {
|
|
18375
|
-
this.enqueueAndForget((() => (this.
|
|
18446
|
+
this.enqueueAndForget((() => (this.ru.push(e), this.Pu())));
|
|
18376
18447
|
}
|
|
18377
18448
|
/**
|
|
18378
18449
|
* Runs the next operation from the retryable queue. If the operation fails,
|
|
18379
18450
|
* reschedules with backoff.
|
|
18380
|
-
*/ async
|
|
18381
|
-
if (0 !== this.
|
|
18451
|
+
*/ async Pu() {
|
|
18452
|
+
if (0 !== this.ru.length) {
|
|
18382
18453
|
try {
|
|
18383
|
-
await this.
|
|
18454
|
+
await this.ru[0](), this.ru.shift(), this.jo.reset();
|
|
18384
18455
|
} catch (e) {
|
|
18385
18456
|
if (!__PRIVATE_isIndexedDbTransactionError(e)) throw e;
|
|
18386
18457
|
// Failure will be handled by AsyncQueue
|
|
18387
18458
|
__PRIVATE_logDebug("AsyncQueue", "Operation failed with retryable error: " + e);
|
|
18388
18459
|
}
|
|
18389
|
-
this.
|
|
18460
|
+
this.ru.length > 0 &&
|
|
18390
18461
|
// If there are additional operations, we re-schedule `retryNextOp()`.
|
|
18391
18462
|
// This is necessary to run retryable operations that failed during
|
|
18392
18463
|
// their initial attempt since we don't know whether they are already
|
|
@@ -18397,12 +18468,12 @@ function doc(e, t, ...n) {
|
|
|
18397
18468
|
// Since `backoffAndRun()` cancels an existing backoff and schedules a
|
|
18398
18469
|
// new backoff on every call, there is only ever a single additional
|
|
18399
18470
|
// operation in the queue.
|
|
18400
|
-
this.jo.qo((() => this.
|
|
18471
|
+
this.jo.qo((() => this.Pu()));
|
|
18401
18472
|
}
|
|
18402
18473
|
}
|
|
18403
|
-
|
|
18404
|
-
const t = this.
|
|
18405
|
-
this.
|
|
18474
|
+
hu(e) {
|
|
18475
|
+
const t = this.nu.then((() => (this._u = !0, e().catch((e => {
|
|
18476
|
+
this.ou = e, this._u = !1;
|
|
18406
18477
|
const t =
|
|
18407
18478
|
/**
|
|
18408
18479
|
* Chrome includes Error.message in Error.stack. Other browsers do not.
|
|
@@ -18434,38 +18505,38 @@ function doc(e, t, ...n) {
|
|
|
18434
18505
|
// all further attempts to chain (via .then) will just short-circuit
|
|
18435
18506
|
// and return the rejected Promise.
|
|
18436
18507
|
throw __PRIVATE_logError("INTERNAL UNHANDLED ERROR: ", t), e;
|
|
18437
|
-
})).then((e => (this.
|
|
18438
|
-
return this.
|
|
18508
|
+
})).then((e => (this._u = !1, e))))));
|
|
18509
|
+
return this.nu = t, t;
|
|
18439
18510
|
}
|
|
18440
18511
|
enqueueAfterDelay(e, t, n) {
|
|
18441
|
-
this.
|
|
18512
|
+
this.lu(),
|
|
18442
18513
|
// Fast-forward delays for timerIds that have been overriden.
|
|
18443
|
-
this.
|
|
18444
|
-
const r = DelayedOperation.createAndSchedule(this, e, t, n, (e => this.
|
|
18445
|
-
return this.
|
|
18514
|
+
this.uu.indexOf(e) > -1 && (t = 0);
|
|
18515
|
+
const r = DelayedOperation.createAndSchedule(this, e, t, n, (e => this.Iu(e)));
|
|
18516
|
+
return this.su.push(r), r;
|
|
18446
18517
|
}
|
|
18447
|
-
|
|
18448
|
-
this.
|
|
18518
|
+
lu() {
|
|
18519
|
+
this.ou && fail();
|
|
18449
18520
|
}
|
|
18450
18521
|
verifyOperationInProgress() {}
|
|
18451
18522
|
/**
|
|
18452
18523
|
* Waits until all currently queued tasks are finished executing. Delayed
|
|
18453
18524
|
* operations are not run.
|
|
18454
|
-
*/ async
|
|
18525
|
+
*/ async Tu() {
|
|
18455
18526
|
// Operations in the queue prior to draining may have enqueued additional
|
|
18456
18527
|
// operations. Keep draining the queue until the tail is no longer advanced,
|
|
18457
18528
|
// which indicates that no more new operations were enqueued and that all
|
|
18458
18529
|
// operations were executed.
|
|
18459
18530
|
let e;
|
|
18460
18531
|
do {
|
|
18461
|
-
e = this.
|
|
18462
|
-
} while (e !== this.
|
|
18532
|
+
e = this.nu, await e;
|
|
18533
|
+
} while (e !== this.nu);
|
|
18463
18534
|
}
|
|
18464
18535
|
/**
|
|
18465
18536
|
* For Tests: Determine if a delayed operation with a particular TimerId
|
|
18466
18537
|
* exists.
|
|
18467
|
-
*/
|
|
18468
|
-
for (const t of this.
|
|
18538
|
+
*/ Eu(e) {
|
|
18539
|
+
for (const t of this.su) if (t.timerId === e) return !0;
|
|
18469
18540
|
return !1;
|
|
18470
18541
|
}
|
|
18471
18542
|
/**
|
|
@@ -18474,24 +18545,24 @@ function doc(e, t, ...n) {
|
|
|
18474
18545
|
* @param lastTimerId - Delayed operations up to and including this TimerId
|
|
18475
18546
|
* will be drained. Pass TimerId.All to run all delayed operations.
|
|
18476
18547
|
* @returns a Promise that resolves once all operations have been run.
|
|
18477
|
-
*/
|
|
18548
|
+
*/ du(e) {
|
|
18478
18549
|
// Note that draining may generate more delayed ops, so we do that first.
|
|
18479
|
-
return this.
|
|
18550
|
+
return this.Tu().then((() => {
|
|
18480
18551
|
// Run ops in the same order they'd run if they ran naturally.
|
|
18481
|
-
this.
|
|
18482
|
-
for (const t of this.
|
|
18483
|
-
return this.
|
|
18552
|
+
this.su.sort(((e, t) => e.targetTimeMs - t.targetTimeMs));
|
|
18553
|
+
for (const t of this.su) if (t.skipDelay(), "all" /* TimerId.All */ !== e && t.timerId === e) break;
|
|
18554
|
+
return this.Tu();
|
|
18484
18555
|
}));
|
|
18485
18556
|
}
|
|
18486
18557
|
/**
|
|
18487
18558
|
* For Tests: Skip all subsequent delays for a timer id.
|
|
18488
|
-
*/
|
|
18489
|
-
this.
|
|
18559
|
+
*/ Au(e) {
|
|
18560
|
+
this.uu.push(e);
|
|
18490
18561
|
}
|
|
18491
|
-
/** Called once a DelayedOperation is run or canceled. */
|
|
18562
|
+
/** Called once a DelayedOperation is run or canceled. */ Iu(e) {
|
|
18492
18563
|
// NOTE: indexOf / slice are O(n), but delayedOperations is expected to be small.
|
|
18493
|
-
const t = this.
|
|
18494
|
-
this.
|
|
18564
|
+
const t = this.su.indexOf(e);
|
|
18565
|
+
this.su.splice(t, 1);
|
|
18495
18566
|
}
|
|
18496
18567
|
}
|
|
18497
18568
|
|
|
@@ -18619,7 +18690,7 @@ class LoadBundleTask {
|
|
|
18619
18690
|
* Constant used to indicate the LRU garbage collection should be disabled.
|
|
18620
18691
|
* Set this value as the `cacheSizeBytes` on the settings passed to the
|
|
18621
18692
|
* {@link Firestore} instance.
|
|
18622
|
-
*/ const
|
|
18693
|
+
*/ const pe = -1;
|
|
18623
18694
|
|
|
18624
18695
|
/**
|
|
18625
18696
|
* The Cloud Firestore service interface.
|
|
@@ -19242,7 +19313,7 @@ class AggregateField {
|
|
|
19242
19313
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19243
19314
|
* See the License for the specific language governing permissions and
|
|
19244
19315
|
* limitations under the License.
|
|
19245
|
-
*/ const
|
|
19316
|
+
*/ const ye = /^__.*__$/;
|
|
19246
19317
|
|
|
19247
19318
|
/** The result of parsing document data (e.g. for a setData call). */ class ParsedSetData {
|
|
19248
19319
|
constructor(e, t, n) {
|
|
@@ -19305,55 +19376,55 @@ function __PRIVATE_isWrite(e) {
|
|
|
19305
19376
|
this.settings = e, this.databaseId = t, this.serializer = n, this.ignoreUndefinedProperties = r,
|
|
19306
19377
|
// Minor hack: If fieldTransforms is undefined, we assume this is an
|
|
19307
19378
|
// external call and we need to validate the entire path.
|
|
19308
|
-
void 0 === i && this.
|
|
19379
|
+
void 0 === i && this.Ru(), this.fieldTransforms = i || [], this.fieldMask = s || [];
|
|
19309
19380
|
}
|
|
19310
19381
|
get path() {
|
|
19311
19382
|
return this.settings.path;
|
|
19312
19383
|
}
|
|
19313
|
-
get
|
|
19314
|
-
return this.settings.
|
|
19384
|
+
get Vu() {
|
|
19385
|
+
return this.settings.Vu;
|
|
19315
19386
|
}
|
|
19316
|
-
/** Returns a new context with the specified settings overwritten. */
|
|
19387
|
+
/** Returns a new context with the specified settings overwritten. */ mu(e) {
|
|
19317
19388
|
return new __PRIVATE_ParseContextImpl(Object.assign(Object.assign({}, this.settings), e), this.databaseId, this.serializer, this.ignoreUndefinedProperties, this.fieldTransforms, this.fieldMask);
|
|
19318
19389
|
}
|
|
19319
|
-
|
|
19390
|
+
fu(e) {
|
|
19320
19391
|
var t;
|
|
19321
|
-
const n = null === (t = this.path) || void 0 === t ? void 0 : t.child(e), r = this.
|
|
19392
|
+
const n = null === (t = this.path) || void 0 === t ? void 0 : t.child(e), r = this.mu({
|
|
19322
19393
|
path: n,
|
|
19323
|
-
|
|
19394
|
+
gu: !1
|
|
19324
19395
|
});
|
|
19325
|
-
return r.
|
|
19396
|
+
return r.pu(e), r;
|
|
19326
19397
|
}
|
|
19327
|
-
|
|
19398
|
+
yu(e) {
|
|
19328
19399
|
var t;
|
|
19329
|
-
const n = null === (t = this.path) || void 0 === t ? void 0 : t.child(e), r = this.
|
|
19400
|
+
const n = null === (t = this.path) || void 0 === t ? void 0 : t.child(e), r = this.mu({
|
|
19330
19401
|
path: n,
|
|
19331
|
-
|
|
19402
|
+
gu: !1
|
|
19332
19403
|
});
|
|
19333
|
-
return r.
|
|
19404
|
+
return r.Ru(), r;
|
|
19334
19405
|
}
|
|
19335
|
-
|
|
19406
|
+
wu(e) {
|
|
19336
19407
|
// TODO(b/34871131): We don't support array paths right now; so make path
|
|
19337
19408
|
// undefined.
|
|
19338
|
-
return this.
|
|
19409
|
+
return this.mu({
|
|
19339
19410
|
path: void 0,
|
|
19340
|
-
|
|
19411
|
+
gu: !0
|
|
19341
19412
|
});
|
|
19342
19413
|
}
|
|
19343
|
-
|
|
19344
|
-
return __PRIVATE_createError(e, this.settings.methodName, this.settings.
|
|
19414
|
+
Su(e) {
|
|
19415
|
+
return __PRIVATE_createError(e, this.settings.methodName, this.settings.bu || !1, this.path, this.settings.Du);
|
|
19345
19416
|
}
|
|
19346
19417
|
/** Returns 'true' if 'fieldPath' was traversed when creating this context. */ contains(e) {
|
|
19347
19418
|
return void 0 !== this.fieldMask.find((t => e.isPrefixOf(t))) || void 0 !== this.fieldTransforms.find((t => e.isPrefixOf(t.field)));
|
|
19348
19419
|
}
|
|
19349
|
-
|
|
19420
|
+
Ru() {
|
|
19350
19421
|
// TODO(b/34871131): Remove null check once we have proper paths for fields
|
|
19351
19422
|
// within arrays.
|
|
19352
|
-
if (this.path) for (let e = 0; e < this.path.length; e++) this.
|
|
19423
|
+
if (this.path) for (let e = 0; e < this.path.length; e++) this.pu(this.path.get(e));
|
|
19353
19424
|
}
|
|
19354
|
-
|
|
19355
|
-
if (0 === e.length) throw this.
|
|
19356
|
-
if (__PRIVATE_isWrite(this.
|
|
19425
|
+
pu(e) {
|
|
19426
|
+
if (0 === e.length) throw this.Su("Document fields must not be empty");
|
|
19427
|
+
if (__PRIVATE_isWrite(this.Vu) && ye.test(e)) throw this.Su('Document fields cannot begin and end with "__"');
|
|
19357
19428
|
}
|
|
19358
19429
|
}
|
|
19359
19430
|
|
|
@@ -19364,14 +19435,14 @@ function __PRIVATE_isWrite(e) {
|
|
|
19364
19435
|
constructor(e, t, n) {
|
|
19365
19436
|
this.databaseId = e, this.ignoreUndefinedProperties = t, this.serializer = n || __PRIVATE_newSerializer(e);
|
|
19366
19437
|
}
|
|
19367
|
-
/** Creates a new top-level parse context. */
|
|
19438
|
+
/** Creates a new top-level parse context. */ Cu(e, t, n, r = !1) {
|
|
19368
19439
|
return new __PRIVATE_ParseContextImpl({
|
|
19369
|
-
|
|
19440
|
+
Vu: e,
|
|
19370
19441
|
methodName: t,
|
|
19371
|
-
|
|
19442
|
+
Du: n,
|
|
19372
19443
|
path: FieldPath$1.emptyPath(),
|
|
19373
|
-
|
|
19374
|
-
|
|
19444
|
+
gu: !1,
|
|
19445
|
+
bu: r
|
|
19375
19446
|
}, this.databaseId, this.serializer, this.ignoreUndefinedProperties);
|
|
19376
19447
|
}
|
|
19377
19448
|
}
|
|
@@ -19382,7 +19453,7 @@ function __PRIVATE_newUserDataReader(e) {
|
|
|
19382
19453
|
}
|
|
19383
19454
|
|
|
19384
19455
|
/** Parse document data from a set() call. */ function __PRIVATE_parseSetData(e, t, n, r, i, s = {}) {
|
|
19385
|
-
const o = e.
|
|
19456
|
+
const o = e.Cu(s.merge || s.mergeFields ? 2 /* UserDataSource.MergeSet */ : 0 /* UserDataSource.Set */ , t, n, i);
|
|
19386
19457
|
__PRIVATE_validatePlainObject("Data must be an object, but it was:", o, r);
|
|
19387
19458
|
const _ = __PRIVATE_parseObject(r, o);
|
|
19388
19459
|
let a, u;
|
|
@@ -19400,7 +19471,7 @@ function __PRIVATE_newUserDataReader(e) {
|
|
|
19400
19471
|
|
|
19401
19472
|
class __PRIVATE_DeleteFieldValueImpl extends FieldValue {
|
|
19402
19473
|
_toFieldTransform(e) {
|
|
19403
|
-
if (2 /* UserDataSource.MergeSet */ !== e.
|
|
19474
|
+
if (2 /* UserDataSource.MergeSet */ !== e.Vu) throw 1 /* UserDataSource.Update */ === e.Vu ? e.Su(`${this._methodName}() can only appear at the top level of your update data`) : e.Su(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);
|
|
19404
19475
|
// No transform to add for a delete, but we need to add it to our
|
|
19405
19476
|
// fieldMask so it gets deleted.
|
|
19406
19477
|
return e.fieldMask.push(e.path), null;
|
|
@@ -19427,10 +19498,10 @@ class __PRIVATE_DeleteFieldValueImpl extends FieldValue {
|
|
|
19427
19498
|
* @param arrayElement - Whether or not the FieldValue has an array.
|
|
19428
19499
|
*/ function __PRIVATE_createSentinelChildContext(e, t, n) {
|
|
19429
19500
|
return new __PRIVATE_ParseContextImpl({
|
|
19430
|
-
|
|
19431
|
-
|
|
19501
|
+
Vu: 3 /* UserDataSource.Argument */ ,
|
|
19502
|
+
Du: t.settings.Du,
|
|
19432
19503
|
methodName: e._methodName,
|
|
19433
|
-
|
|
19504
|
+
gu: n
|
|
19434
19505
|
}, t.databaseId, t.serializer, t.ignoreUndefinedProperties);
|
|
19435
19506
|
}
|
|
19436
19507
|
|
|
@@ -19445,47 +19516,47 @@ class __PRIVATE_ServerTimestampFieldValueImpl extends FieldValue {
|
|
|
19445
19516
|
|
|
19446
19517
|
class __PRIVATE_ArrayUnionFieldValueImpl extends FieldValue {
|
|
19447
19518
|
constructor(e, t) {
|
|
19448
|
-
super(e), this.
|
|
19519
|
+
super(e), this.vu = t;
|
|
19449
19520
|
}
|
|
19450
19521
|
_toFieldTransform(e) {
|
|
19451
19522
|
const t = __PRIVATE_createSentinelChildContext(this, e,
|
|
19452
|
-
/*array=*/ !0), n = this.
|
|
19523
|
+
/*array=*/ !0), n = this.vu.map((e => __PRIVATE_parseData(e, t))), r = new __PRIVATE_ArrayUnionTransformOperation(n);
|
|
19453
19524
|
return new FieldTransform(e.path, r);
|
|
19454
19525
|
}
|
|
19455
19526
|
isEqual(e) {
|
|
19456
|
-
return e instanceof __PRIVATE_ArrayUnionFieldValueImpl && util.deepEqual(this.
|
|
19527
|
+
return e instanceof __PRIVATE_ArrayUnionFieldValueImpl && util.deepEqual(this.vu, e.vu);
|
|
19457
19528
|
}
|
|
19458
19529
|
}
|
|
19459
19530
|
|
|
19460
19531
|
class __PRIVATE_ArrayRemoveFieldValueImpl extends FieldValue {
|
|
19461
19532
|
constructor(e, t) {
|
|
19462
|
-
super(e), this.
|
|
19533
|
+
super(e), this.vu = t;
|
|
19463
19534
|
}
|
|
19464
19535
|
_toFieldTransform(e) {
|
|
19465
19536
|
const t = __PRIVATE_createSentinelChildContext(this, e,
|
|
19466
|
-
/*array=*/ !0), n = this.
|
|
19537
|
+
/*array=*/ !0), n = this.vu.map((e => __PRIVATE_parseData(e, t))), r = new __PRIVATE_ArrayRemoveTransformOperation(n);
|
|
19467
19538
|
return new FieldTransform(e.path, r);
|
|
19468
19539
|
}
|
|
19469
19540
|
isEqual(e) {
|
|
19470
|
-
return e instanceof __PRIVATE_ArrayRemoveFieldValueImpl && util.deepEqual(this.
|
|
19541
|
+
return e instanceof __PRIVATE_ArrayRemoveFieldValueImpl && util.deepEqual(this.vu, e.vu);
|
|
19471
19542
|
}
|
|
19472
19543
|
}
|
|
19473
19544
|
|
|
19474
19545
|
class __PRIVATE_NumericIncrementFieldValueImpl extends FieldValue {
|
|
19475
19546
|
constructor(e, t) {
|
|
19476
|
-
super(e), this.
|
|
19547
|
+
super(e), this.Fu = t;
|
|
19477
19548
|
}
|
|
19478
19549
|
_toFieldTransform(e) {
|
|
19479
|
-
const t = new __PRIVATE_NumericIncrementTransformOperation(e.serializer, toNumber(e.serializer, this.
|
|
19550
|
+
const t = new __PRIVATE_NumericIncrementTransformOperation(e.serializer, toNumber(e.serializer, this.Fu));
|
|
19480
19551
|
return new FieldTransform(e.path, t);
|
|
19481
19552
|
}
|
|
19482
19553
|
isEqual(e) {
|
|
19483
|
-
return e instanceof __PRIVATE_NumericIncrementFieldValueImpl && this.
|
|
19554
|
+
return e instanceof __PRIVATE_NumericIncrementFieldValueImpl && this.Fu === e.Fu;
|
|
19484
19555
|
}
|
|
19485
19556
|
}
|
|
19486
19557
|
|
|
19487
19558
|
/** Parse update data from an update() call. */ function __PRIVATE_parseUpdateData(e, t, n, r) {
|
|
19488
|
-
const i = e.
|
|
19559
|
+
const i = e.Cu(1 /* UserDataSource.Update */ , t, n);
|
|
19489
19560
|
__PRIVATE_validatePlainObject("Data must be an object, but it was:", i, r);
|
|
19490
19561
|
const s = [], o = ObjectValue.empty();
|
|
19491
19562
|
forEach(r, ((e, r) => {
|
|
@@ -19493,7 +19564,7 @@ class __PRIVATE_NumericIncrementFieldValueImpl extends FieldValue {
|
|
|
19493
19564
|
// For Compat types, we have to "extract" the underlying types before
|
|
19494
19565
|
// performing validation.
|
|
19495
19566
|
r = util.getModularInstance(r);
|
|
19496
|
-
const a = i.
|
|
19567
|
+
const a = i.yu(_);
|
|
19497
19568
|
if (r instanceof __PRIVATE_DeleteFieldValueImpl)
|
|
19498
19569
|
// Add it to the field mask, but don't add anything to updateData.
|
|
19499
19570
|
s.push(_); else {
|
|
@@ -19506,7 +19577,7 @@ class __PRIVATE_NumericIncrementFieldValueImpl extends FieldValue {
|
|
|
19506
19577
|
}
|
|
19507
19578
|
|
|
19508
19579
|
/** Parse update data from a list of field/value arguments. */ function __PRIVATE_parseUpdateVarargs(e, t, n, r, i, s) {
|
|
19509
|
-
const o = e.
|
|
19580
|
+
const o = e.Cu(1 /* UserDataSource.Update */ , t, n), _ = [ __PRIVATE_fieldPathFromArgument$1(t, r, n) ], a = [ i ];
|
|
19510
19581
|
if (s.length % 2 != 0) throw new FirestoreError(D.INVALID_ARGUMENT, `Function ${t}() needs to be called with an even number of arguments that alternate between field names and values.`);
|
|
19511
19582
|
for (let e = 0; e < s.length; e += 2) _.push(__PRIVATE_fieldPathFromArgument$1(t, s[e])),
|
|
19512
19583
|
a.push(s[e + 1]);
|
|
@@ -19519,7 +19590,7 @@ class __PRIVATE_NumericIncrementFieldValueImpl extends FieldValue {
|
|
|
19519
19590
|
// For Compat types, we have to "extract" the underlying types before
|
|
19520
19591
|
// performing validation.
|
|
19521
19592
|
n = util.getModularInstance(n);
|
|
19522
|
-
const r = o.
|
|
19593
|
+
const r = o.yu(t);
|
|
19523
19594
|
if (n instanceof __PRIVATE_DeleteFieldValueImpl)
|
|
19524
19595
|
// Add it to the field mask, but don't add anything to updateData.
|
|
19525
19596
|
u.push(t); else {
|
|
@@ -19538,7 +19609,7 @@ class __PRIVATE_NumericIncrementFieldValueImpl extends FieldValue {
|
|
|
19538
19609
|
* @param allowArrays - Whether the query value is an array that may directly
|
|
19539
19610
|
* contain additional arrays (e.g. the operand of an `in` query).
|
|
19540
19611
|
*/ function __PRIVATE_parseQueryValue(e, t, n, r = !1) {
|
|
19541
|
-
return __PRIVATE_parseData(n, e.
|
|
19612
|
+
return __PRIVATE_parseData(n, e.Cu(r ? 4 /* UserDataSource.ArrayArgument */ : 3 /* UserDataSource.Argument */ , t));
|
|
19542
19613
|
}
|
|
19543
19614
|
|
|
19544
19615
|
/**
|
|
@@ -19567,8 +19638,8 @@ class __PRIVATE_NumericIncrementFieldValueImpl extends FieldValue {
|
|
|
19567
19638
|
*/
|
|
19568
19639
|
return function __PRIVATE_parseSentinelFieldValue(e, t) {
|
|
19569
19640
|
// Sentinels are only supported with writes, and not within arrays.
|
|
19570
|
-
if (!__PRIVATE_isWrite(t.
|
|
19571
|
-
if (!t.path) throw t.
|
|
19641
|
+
if (!__PRIVATE_isWrite(t.Vu)) throw t.Su(`${e._methodName}() can only be used with update() and set()`);
|
|
19642
|
+
if (!t.path) throw t.Su(`${e._methodName}() is not currently supported inside arrays`);
|
|
19572
19643
|
const n = e._toFieldTransform(t);
|
|
19573
19644
|
n && t.fieldTransforms.push(n);
|
|
19574
19645
|
}
|
|
@@ -19592,12 +19663,12 @@ class __PRIVATE_NumericIncrementFieldValueImpl extends FieldValue {
|
|
|
19592
19663
|
// the set of values to be included for the IN query) that may directly
|
|
19593
19664
|
// contain additional arrays (each representing an individual field
|
|
19594
19665
|
// value), so we disable this validation.
|
|
19595
|
-
if (t.settings.
|
|
19666
|
+
if (t.settings.gu && 4 /* UserDataSource.ArrayArgument */ !== t.Vu) throw t.Su("Nested arrays are not supported");
|
|
19596
19667
|
return function __PRIVATE_parseArray(e, t) {
|
|
19597
19668
|
const n = [];
|
|
19598
19669
|
let r = 0;
|
|
19599
19670
|
for (const i of e) {
|
|
19600
|
-
let e = __PRIVATE_parseData(i, t.
|
|
19671
|
+
let e = __PRIVATE_parseData(i, t.wu(r));
|
|
19601
19672
|
null == e && (
|
|
19602
19673
|
// Just include nulls in the array for fields being replaced with a
|
|
19603
19674
|
// sentinel.
|
|
@@ -19649,12 +19720,12 @@ class __PRIVATE_NumericIncrementFieldValueImpl extends FieldValue {
|
|
|
19649
19720
|
};
|
|
19650
19721
|
if (e instanceof DocumentReference) {
|
|
19651
19722
|
const n = t.databaseId, r = e.firestore._databaseId;
|
|
19652
|
-
if (!r.isEqual(n)) throw t.
|
|
19723
|
+
if (!r.isEqual(n)) throw t.Su(`Document reference is for database ${r.projectId}/${r.database} but should be for database ${n.projectId}/${n.database}`);
|
|
19653
19724
|
return {
|
|
19654
19725
|
referenceValue: __PRIVATE_toResourceName(e.firestore._databaseId || t.databaseId, e._key.path)
|
|
19655
19726
|
};
|
|
19656
19727
|
}
|
|
19657
|
-
throw t.
|
|
19728
|
+
throw t.Su(`Unsupported field value: ${__PRIVATE_valueDescription(e)}`);
|
|
19658
19729
|
}
|
|
19659
19730
|
/**
|
|
19660
19731
|
* Checks whether an object looks like a JSON object that should be converted
|
|
@@ -19671,7 +19742,7 @@ function __PRIVATE_parseObject(e, t) {
|
|
|
19671
19742
|
// If we encounter an empty object, we explicitly add it to the update
|
|
19672
19743
|
// mask to ensure that the server creates a map entry.
|
|
19673
19744
|
t.path && t.path.length > 0 && t.fieldMask.push(t.path) : forEach(e, ((e, r) => {
|
|
19674
|
-
const i = __PRIVATE_parseData(r, t.
|
|
19745
|
+
const i = __PRIVATE_parseData(r, t.fu(e));
|
|
19675
19746
|
null != i && (n[e] = i);
|
|
19676
19747
|
})), {
|
|
19677
19748
|
mapValue: {
|
|
@@ -19689,7 +19760,7 @@ function __PRIVATE_validatePlainObject(e, t, n) {
|
|
|
19689
19760
|
return "object" == typeof e && null !== e && (Object.getPrototypeOf(e) === Object.prototype || null === Object.getPrototypeOf(e));
|
|
19690
19761
|
}(n)) {
|
|
19691
19762
|
const r = __PRIVATE_valueDescription(n);
|
|
19692
|
-
throw "an object" === r ? t.
|
|
19763
|
+
throw "an object" === r ? t.Su(e + " a custom object") : t.Su(e + " " + r);
|
|
19693
19764
|
}
|
|
19694
19765
|
}
|
|
19695
19766
|
|
|
@@ -19708,7 +19779,7 @@ function __PRIVATE_validatePlainObject(e, t, n) {
|
|
|
19708
19779
|
|
|
19709
19780
|
/**
|
|
19710
19781
|
* Matches any characters in a field path string that are reserved.
|
|
19711
|
-
*/ const
|
|
19782
|
+
*/ const we = new RegExp("[~\\*/\\[\\]]");
|
|
19712
19783
|
|
|
19713
19784
|
/**
|
|
19714
19785
|
* Wraps fromDotSeparatedString with an error message about the method that
|
|
@@ -19719,7 +19790,7 @@ function __PRIVATE_validatePlainObject(e, t, n) {
|
|
|
19719
19790
|
* @param targetDoc - The document against which the field path will be
|
|
19720
19791
|
* evaluated.
|
|
19721
19792
|
*/ function __PRIVATE_fieldPathFromDotSeparatedString(e, t, n) {
|
|
19722
|
-
if (t.search(
|
|
19793
|
+
if (t.search(we) >= 0) throw __PRIVATE_createError(`Invalid field path (${t}). Paths must not contain '~', '*', '/', '[', or ']'`, e,
|
|
19723
19794
|
/* hasConverter= */ !1,
|
|
19724
19795
|
/* path= */ void 0, n);
|
|
19725
19796
|
try {
|
|
@@ -20939,11 +21010,13 @@ function onSnapshot(e, ...t) {
|
|
|
20939
21010
|
var n, r, i;
|
|
20940
21011
|
e = util.getModularInstance(e);
|
|
20941
21012
|
let s = {
|
|
20942
|
-
includeMetadataChanges: !1
|
|
21013
|
+
includeMetadataChanges: !1,
|
|
21014
|
+
source: "default"
|
|
20943
21015
|
}, o = 0;
|
|
20944
21016
|
"object" != typeof t[o] || __PRIVATE_isPartialObserver(t[o]) || (s = t[o], o++);
|
|
20945
21017
|
const _ = {
|
|
20946
|
-
includeMetadataChanges: s.includeMetadataChanges
|
|
21018
|
+
includeMetadataChanges: s.includeMetadataChanges,
|
|
21019
|
+
source: s.source
|
|
20947
21020
|
};
|
|
20948
21021
|
if (__PRIVATE_isPartialObserver(t[o])) {
|
|
20949
21022
|
const e = t[o];
|
|
@@ -20974,7 +21047,7 @@ function onSnapshot(e, ...t) {
|
|
|
20974
21047
|
const i = new __PRIVATE_AsyncObserver(r), s = new __PRIVATE_QueryListener(t, i, n);
|
|
20975
21048
|
return e.asyncQueue.enqueueAndForget((async () => __PRIVATE_eventManagerListen(await __PRIVATE_getEventManager(e), s))),
|
|
20976
21049
|
() => {
|
|
20977
|
-
i.
|
|
21050
|
+
i.Qa(), e.asyncQueue.enqueueAndForget((async () => __PRIVATE_eventManagerUnlisten(await __PRIVATE_getEventManager(e), s)));
|
|
20978
21051
|
};
|
|
20979
21052
|
}(ensureFirestoreConfigured(u), c, _, a);
|
|
20980
21053
|
}
|
|
@@ -21271,7 +21344,7 @@ class __PRIVATE_MultiTabManagerImpl {
|
|
|
21271
21344
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
21272
21345
|
* See the License for the specific language governing permissions and
|
|
21273
21346
|
* limitations under the License.
|
|
21274
|
-
*/ const
|
|
21347
|
+
*/ const Se = {
|
|
21275
21348
|
maxAttempts: 5
|
|
21276
21349
|
};
|
|
21277
21350
|
|
|
@@ -21483,7 +21556,7 @@ class Transaction extends class Transaction$1 {
|
|
|
21483
21556
|
* rejected promise with the corresponding failure error is returned.
|
|
21484
21557
|
*/ function runTransaction(e, t, n) {
|
|
21485
21558
|
e = __PRIVATE_cast(e, Firestore);
|
|
21486
|
-
const r = Object.assign(Object.assign({},
|
|
21559
|
+
const r = Object.assign(Object.assign({}, Se), n);
|
|
21487
21560
|
!function __PRIVATE_validateTransactionOptions(e) {
|
|
21488
21561
|
if (e.maxAttempts < 1) throw new FirestoreError(D.INVALID_ARGUMENT, "Max attempts must be at least 1");
|
|
21489
21562
|
}(r);
|
|
@@ -21491,7 +21564,7 @@ class Transaction extends class Transaction$1 {
|
|
|
21491
21564
|
const r = new __PRIVATE_Deferred;
|
|
21492
21565
|
return e.asyncQueue.enqueueAndForget((async () => {
|
|
21493
21566
|
const i = await __PRIVATE_getDatastore(e);
|
|
21494
|
-
new __PRIVATE_TransactionRunner(e.asyncQueue, i, n, t, r).
|
|
21567
|
+
new __PRIVATE_TransactionRunner(e.asyncQueue, i, n, t, r).Ya();
|
|
21495
21568
|
})), r.promise;
|
|
21496
21569
|
}(ensureFirestoreConfigured(e), (n => t(new Transaction(e, n))), r);
|
|
21497
21570
|
}
|
|
@@ -21699,12 +21772,12 @@ function __PRIVATE_tryGetString(e, t) {
|
|
|
21699
21772
|
*/ function getPersistentCacheIndexManager(e) {
|
|
21700
21773
|
var t;
|
|
21701
21774
|
e = __PRIVATE_cast(e, Firestore);
|
|
21702
|
-
const n =
|
|
21775
|
+
const n = be.get(e);
|
|
21703
21776
|
if (n) return n;
|
|
21704
21777
|
const r = ensureFirestoreConfigured(e);
|
|
21705
21778
|
if ("persistent" !== (null === (t = r._uninitializedComponentsProvider) || void 0 === t ? void 0 : t._offlineKind)) return null;
|
|
21706
21779
|
const i = new PersistentCacheIndexManager(r);
|
|
21707
|
-
return
|
|
21780
|
+
return be.set(e, i), i;
|
|
21708
21781
|
}
|
|
21709
21782
|
|
|
21710
21783
|
/**
|
|
@@ -21747,7 +21820,7 @@ function __PRIVATE_setPersistentCacheIndexAutoCreationEnabled(e, t) {
|
|
|
21747
21820
|
* Use a `WeakMap` so that the mapping will be automatically dropped when the
|
|
21748
21821
|
* `Firestore` instance is garbage collected. This emulates a private member
|
|
21749
21822
|
* as described in https://goo.gle/454yvug.
|
|
21750
|
-
*/ const
|
|
21823
|
+
*/ const be = new WeakMap;
|
|
21751
21824
|
|
|
21752
21825
|
/**
|
|
21753
21826
|
* @license
|
|
@@ -21797,24 +21870,24 @@ function __PRIVATE_setPersistentCacheIndexAutoCreationEnabled(e, t) {
|
|
|
21797
21870
|
* The implementation of `TestingHooksSpi`.
|
|
21798
21871
|
*/ class __PRIVATE_TestingHooksSpiImpl {
|
|
21799
21872
|
constructor() {
|
|
21800
|
-
this.
|
|
21873
|
+
this.Mu = new Map;
|
|
21801
21874
|
}
|
|
21802
21875
|
static get instance() {
|
|
21803
|
-
return
|
|
21876
|
+
return De || (De = new __PRIVATE_TestingHooksSpiImpl, function __PRIVATE_setTestingHooksSpi(e) {
|
|
21804
21877
|
if (ce) throw new Error("a TestingHooksSpi instance is already set");
|
|
21805
21878
|
ce = e;
|
|
21806
|
-
}(
|
|
21879
|
+
}(De)), De;
|
|
21807
21880
|
}
|
|
21808
21881
|
tt(e) {
|
|
21809
|
-
this.
|
|
21882
|
+
this.Mu.forEach((t => t(e)));
|
|
21810
21883
|
}
|
|
21811
21884
|
onExistenceFilterMismatch(e) {
|
|
21812
|
-
const t = Symbol(), n = this.
|
|
21885
|
+
const t = Symbol(), n = this.Mu;
|
|
21813
21886
|
return n.set(t, e), () => n.delete(t);
|
|
21814
21887
|
}
|
|
21815
21888
|
}
|
|
21816
21889
|
|
|
21817
|
-
let
|
|
21890
|
+
let De = null;
|
|
21818
21891
|
|
|
21819
21892
|
/**
|
|
21820
21893
|
* Cloud Firestore
|
|
@@ -21831,16 +21904,16 @@ let Se = null;
|
|
|
21831
21904
|
return r = Object.assign({
|
|
21832
21905
|
useFetchStreams: t
|
|
21833
21906
|
}, r), s._setSettings(r), s;
|
|
21834
|
-
}), "PUBLIC").setMultipleInstances(!0)), app.registerVersion(w, "4.4.3-canary.
|
|
21907
|
+
}), "PUBLIC").setMultipleInstances(!0)), app.registerVersion(w, "4.4.3-canary.ce88e71e7", e),
|
|
21835
21908
|
// BUILD_TARGET will be replaced by values like esm5, esm2017, cjs5, etc during the compilation
|
|
21836
|
-
app.registerVersion(w, "4.4.3-canary.
|
|
21909
|
+
app.registerVersion(w, "4.4.3-canary.ce88e71e7", "cjs2017");
|
|
21837
21910
|
}();
|
|
21838
21911
|
|
|
21839
21912
|
exports.AbstractUserDataWriter = AbstractUserDataWriter;
|
|
21840
21913
|
exports.AggregateField = AggregateField;
|
|
21841
21914
|
exports.AggregateQuerySnapshot = AggregateQuerySnapshot;
|
|
21842
21915
|
exports.Bytes = Bytes;
|
|
21843
|
-
exports.CACHE_SIZE_UNLIMITED =
|
|
21916
|
+
exports.CACHE_SIZE_UNLIMITED = pe;
|
|
21844
21917
|
exports.CollectionReference = CollectionReference;
|
|
21845
21918
|
exports.DocumentReference = DocumentReference;
|
|
21846
21919
|
exports.DocumentSnapshot = DocumentSnapshot;
|