@firebase/firestore 4.7.5 → 4.7.6-canary.144bc3709
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/global_index.d.ts +8 -0
- package/dist/firestore/src/model/path.d.ts +8 -0
- package/dist/index.cjs.js +219 -197
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm2017.js +219 -197
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.node.cjs.js +48 -13
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +48 -13
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +317 -295
- package/dist/index.rn.js.map +1 -1
- package/dist/internal.d.ts +8 -0
- package/dist/lite/firestore/src/model/path.d.ts +8 -0
- package/dist/lite/index.browser.esm2017.js +193 -176
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.cjs.js +193 -176
- package/dist/lite/index.cjs.js.map +1 -1
- package/dist/lite/index.node.cjs.js +41 -12
- package/dist/lite/index.node.cjs.js.map +1 -1
- package/dist/lite/index.node.mjs +41 -12
- package/dist/lite/index.node.mjs.map +1 -1
- package/dist/lite/index.rn.esm2017.js +181 -163
- package/dist/lite/index.rn.esm2017.js.map +1 -1
- package/dist/lite/internal.d.ts +8 -0
- package/dist/lite/private.d.ts +8 -0
- package/dist/packages/firestore/src/model/path.d.ts +8 -0
- package/dist/private.d.ts +8 -0
- package/package.json +9 -9
package/dist/index.cjs.js
CHANGED
|
@@ -71,7 +71,7 @@ User.MOCK_USER = new User("mock-user");
|
|
|
71
71
|
* See the License for the specific language governing permissions and
|
|
72
72
|
* limitations under the License.
|
|
73
73
|
*/
|
|
74
|
-
let S = "11.0.
|
|
74
|
+
let S = "11.2.0-canary.144bc3709";
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
77
|
* @license
|
|
@@ -1005,14 +1005,30 @@ class BasePath {
|
|
|
1005
1005
|
toArray() {
|
|
1006
1006
|
return this.segments.slice(this.offset, this.limit());
|
|
1007
1007
|
}
|
|
1008
|
-
|
|
1008
|
+
/**
|
|
1009
|
+
* Compare 2 paths segment by segment, prioritizing numeric IDs
|
|
1010
|
+
* (e.g., "__id123__") in numeric ascending order, followed by string
|
|
1011
|
+
* segments in lexicographical order.
|
|
1012
|
+
*/ static comparator(e, t) {
|
|
1009
1013
|
const n = Math.min(e.length, t.length);
|
|
1010
1014
|
for (let r = 0; r < n; r++) {
|
|
1011
|
-
const n = e.get(r),
|
|
1012
|
-
if (
|
|
1013
|
-
if (n > i) return 1;
|
|
1015
|
+
const n = BasePath.compareSegments(e.get(r), t.get(r));
|
|
1016
|
+
if (0 !== n) return n;
|
|
1014
1017
|
}
|
|
1015
|
-
return e.length
|
|
1018
|
+
return Math.sign(e.length - t.length);
|
|
1019
|
+
}
|
|
1020
|
+
static compareSegments(e, t) {
|
|
1021
|
+
const n = BasePath.isNumericId(e), r = BasePath.isNumericId(t);
|
|
1022
|
+
return n && !r ? -1 : !n && r ? 1 : n && r ? BasePath.extractNumericId(e).compare(BasePath.extractNumericId(t)) :
|
|
1023
|
+
// both non-numeric
|
|
1024
|
+
e < t ? -1 : e > t ? 1 : 0;
|
|
1025
|
+
}
|
|
1026
|
+
// Checks if a segment is a numeric ID (starts with "__id" and ends with "__").
|
|
1027
|
+
static isNumericId(e) {
|
|
1028
|
+
return e.startsWith("__id") && e.endsWith("__");
|
|
1029
|
+
}
|
|
1030
|
+
static extractNumericId(e) {
|
|
1031
|
+
return bloomBlob.Integer.fromString(e.substring(4, e.length - 2));
|
|
1016
1032
|
}
|
|
1017
1033
|
}
|
|
1018
1034
|
|
|
@@ -1735,7 +1751,7 @@ class __PRIVATE_SimpleDbTransaction {
|
|
|
1735
1751
|
};
|
|
1736
1752
|
}))), this.N && (this.db.onversionchange = e => this.N(e)), this.db;
|
|
1737
1753
|
}
|
|
1738
|
-
|
|
1754
|
+
B(e) {
|
|
1739
1755
|
this.N = e, this.db && (this.db.onversionchange = t => e(t));
|
|
1740
1756
|
}
|
|
1741
1757
|
async runTransaction(e, t, n, r) {
|
|
@@ -1784,7 +1800,7 @@ class __PRIVATE_SimpleDbTransaction {
|
|
|
1784
1800
|
* within the key range or index.
|
|
1785
1801
|
*/ class __PRIVATE_IterationController {
|
|
1786
1802
|
constructor(e) {
|
|
1787
|
-
this.
|
|
1803
|
+
this.L = e, this.k = !1, this.q = null;
|
|
1788
1804
|
}
|
|
1789
1805
|
get isDone() {
|
|
1790
1806
|
return this.k;
|
|
@@ -1793,7 +1809,7 @@ class __PRIVATE_SimpleDbTransaction {
|
|
|
1793
1809
|
return this.q;
|
|
1794
1810
|
}
|
|
1795
1811
|
set cursor(e) {
|
|
1796
|
-
this.
|
|
1812
|
+
this.L = e;
|
|
1797
1813
|
}
|
|
1798
1814
|
/**
|
|
1799
1815
|
* This function can be called to stop iteration at any point.
|
|
@@ -1811,7 +1827,7 @@ class __PRIVATE_SimpleDbTransaction {
|
|
|
1811
1827
|
*
|
|
1812
1828
|
* NOTE: You CANNOT do this with a keysOnly query.
|
|
1813
1829
|
*/ delete() {
|
|
1814
|
-
return __PRIVATE_wrapRequest(this.
|
|
1830
|
+
return __PRIVATE_wrapRequest(this.L.delete());
|
|
1815
1831
|
}
|
|
1816
1832
|
}
|
|
1817
1833
|
|
|
@@ -2307,7 +2323,7 @@ function __PRIVATE_newDbDocumentMutationPrefixForPath(e, t) {
|
|
|
2307
2323
|
* there is no useful information to store as the value. The raw (unencoded)
|
|
2308
2324
|
* path cannot be stored because IndexedDb doesn't store prototype
|
|
2309
2325
|
* information.
|
|
2310
|
-
*/ const x = {}, O = [ "prefixPath", "collectionGroup", "readTime", "documentId" ], N = [ "prefixPath", "collectionGroup", "documentId" ],
|
|
2326
|
+
*/ const x = {}, O = [ "prefixPath", "collectionGroup", "readTime", "documentId" ], N = [ "prefixPath", "collectionGroup", "documentId" ], B = [ "collectionGroup", "readTime", "prefixPath", "documentId" ], L = [ "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" ], ee = X, te = [ ...X, "globals" ];
|
|
2311
2327
|
|
|
2312
2328
|
/**
|
|
2313
2329
|
* @license
|
|
@@ -5897,7 +5913,7 @@ class BloomFilter {
|
|
|
5897
5913
|
}
|
|
5898
5914
|
// Calculate the ith hash value based on the hashed 64bit integers,
|
|
5899
5915
|
// and calculate its corresponding bit index in the bitmap to be checked.
|
|
5900
|
-
|
|
5916
|
+
de(e, t, n) {
|
|
5901
5917
|
// Calculate hashed value h(i) = h1 + (i * h2).
|
|
5902
5918
|
let r = e.add(t.multiply(bloomBlob.Integer.fromNumber(n)));
|
|
5903
5919
|
// Wrap if hash value overflow 64bit.
|
|
@@ -5905,7 +5921,7 @@ class BloomFilter {
|
|
|
5905
5921
|
r.modulo(this.Ie).toNumber();
|
|
5906
5922
|
}
|
|
5907
5923
|
// Return whether the bit on the given index in the bitmap is set to 1.
|
|
5908
|
-
|
|
5924
|
+
Ee(e) {
|
|
5909
5925
|
return 0 != (this.bitmap[Math.floor(e / 8)] & 1 << e % 8);
|
|
5910
5926
|
}
|
|
5911
5927
|
mightContain(e) {
|
|
@@ -5913,8 +5929,8 @@ class BloomFilter {
|
|
|
5913
5929
|
if (0 === this.Te) return !1;
|
|
5914
5930
|
const t = __PRIVATE_getMd5HashValue(e), [n, r] = __PRIVATE_get64BitUints(t);
|
|
5915
5931
|
for (let e = 0; e < this.hashCount; e++) {
|
|
5916
|
-
const t = this.
|
|
5917
|
-
if (!this.
|
|
5932
|
+
const t = this.de(n, r, e);
|
|
5933
|
+
if (!this.Ee(t)) return !1;
|
|
5918
5934
|
}
|
|
5919
5935
|
return !0;
|
|
5920
5936
|
}
|
|
@@ -5926,7 +5942,7 @@ class BloomFilter {
|
|
|
5926
5942
|
if (0 === this.Te) return;
|
|
5927
5943
|
const t = __PRIVATE_getMd5HashValue(e), [n, r] = __PRIVATE_get64BitUints(t);
|
|
5928
5944
|
for (let e = 0; e < this.hashCount; e++) {
|
|
5929
|
-
const t = this.
|
|
5945
|
+
const t = this.de(n, r, e);
|
|
5930
5946
|
this.Ae(t);
|
|
5931
5947
|
}
|
|
5932
5948
|
}
|
|
@@ -6216,9 +6232,9 @@ class __PRIVATE_WatchTargetChange {
|
|
|
6216
6232
|
*/
|
|
6217
6233
|
class __PRIVATE_WatchChangeAggregator {
|
|
6218
6234
|
constructor(e) {
|
|
6219
|
-
this.
|
|
6235
|
+
this.Be = e,
|
|
6220
6236
|
/** The internal state of all tracked targets. */
|
|
6221
|
-
this.
|
|
6237
|
+
this.Le = new Map,
|
|
6222
6238
|
/** Keeps track of the documents to update since the last raised snapshot. */
|
|
6223
6239
|
this.ke = __PRIVATE_mutableDocumentMap(), this.qe = __PRIVATE_documentTargetMap(),
|
|
6224
6240
|
/** A mapping of document keys to their set of target IDs. */
|
|
@@ -6284,7 +6300,7 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6284
6300
|
* targetIds explicitly listed in the change or the targetIds of all currently
|
|
6285
6301
|
* active targets.
|
|
6286
6302
|
*/ forEachTarget(e, t) {
|
|
6287
|
-
e.targetIds.length > 0 ? e.targetIds.forEach(t) : this.
|
|
6303
|
+
e.targetIds.length > 0 ? e.targetIds.forEach(t) : this.Le.forEach(((e, n) => {
|
|
6288
6304
|
this.je(n) && t(n);
|
|
6289
6305
|
}));
|
|
6290
6306
|
}
|
|
@@ -6354,7 +6370,7 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6354
6370
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
6355
6371
|
* See the License for the specific language governing permissions and
|
|
6356
6372
|
* limitations under the License.
|
|
6357
|
-
*/ (r, e.me, this.
|
|
6373
|
+
*/ (r, e.me, this.Be.nt(), n, i));
|
|
6358
6374
|
}
|
|
6359
6375
|
}
|
|
6360
6376
|
}
|
|
@@ -6393,10 +6409,10 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6393
6409
|
* Filter out removed documents based on bloom filter membership result and
|
|
6394
6410
|
* return number of documents removed.
|
|
6395
6411
|
*/ rt(e, t) {
|
|
6396
|
-
const n = this.
|
|
6412
|
+
const n = this.Be.getRemoteKeysForTarget(t);
|
|
6397
6413
|
let r = 0;
|
|
6398
6414
|
return n.forEach((n => {
|
|
6399
|
-
const i = this.
|
|
6415
|
+
const i = this.Be.nt(), s = `projects/${i.projectId}/databases/${i.database}/documents/${n.path.canonicalString()}`;
|
|
6400
6416
|
e.mightContain(s) || (this.We(t, n, /*updatedDocument=*/ null), r++);
|
|
6401
6417
|
})), r;
|
|
6402
6418
|
}
|
|
@@ -6405,7 +6421,7 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6405
6421
|
* provided snapshot version. Resets the accumulated changes before returning.
|
|
6406
6422
|
*/ it(e) {
|
|
6407
6423
|
const t = new Map;
|
|
6408
|
-
this.
|
|
6424
|
+
this.Le.forEach(((n, r) => {
|
|
6409
6425
|
const i = this.Ye(r);
|
|
6410
6426
|
if (i) {
|
|
6411
6427
|
if (n.current && __PRIVATE_targetIsDocumentTarget(i.target)) {
|
|
@@ -6471,7 +6487,7 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6471
6487
|
n && (this.ke = this.ke.insert(t, n));
|
|
6472
6488
|
}
|
|
6473
6489
|
removeTarget(e) {
|
|
6474
|
-
this.
|
|
6490
|
+
this.Le.delete(e);
|
|
6475
6491
|
}
|
|
6476
6492
|
/**
|
|
6477
6493
|
* Returns the current count of documents in the target. This includes both
|
|
@@ -6479,7 +6495,7 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6479
6495
|
* target as well as any accumulated changes.
|
|
6480
6496
|
*/ Ze(e) {
|
|
6481
6497
|
const t = this.ze(e).ve();
|
|
6482
|
-
return this.
|
|
6498
|
+
return this.Be.getRemoteKeysForTarget(e).size + t.addedDocuments.size - t.removedDocuments.size;
|
|
6483
6499
|
}
|
|
6484
6500
|
/**
|
|
6485
6501
|
* Increment the number of acks needed from watch before we can consider the
|
|
@@ -6488,8 +6504,8 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6488
6504
|
this.ze(e).xe();
|
|
6489
6505
|
}
|
|
6490
6506
|
ze(e) {
|
|
6491
|
-
let t = this.
|
|
6492
|
-
return t || (t = new __PRIVATE_TargetState, this.
|
|
6507
|
+
let t = this.Le.get(e);
|
|
6508
|
+
return t || (t = new __PRIVATE_TargetState, this.Le.set(e, t)), t;
|
|
6493
6509
|
}
|
|
6494
6510
|
_t(e) {
|
|
6495
6511
|
let t = this.Qe.get(e);
|
|
@@ -6514,16 +6530,16 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6514
6530
|
* Returns the TargetData for an active target (i.e. a target that the user
|
|
6515
6531
|
* is still interested in that has no outstanding target change requests).
|
|
6516
6532
|
*/ Ye(e) {
|
|
6517
|
-
const t = this.
|
|
6518
|
-
return t && t.Se ? null : this.
|
|
6533
|
+
const t = this.Le.get(e);
|
|
6534
|
+
return t && t.Se ? null : this.Be.ut(e);
|
|
6519
6535
|
}
|
|
6520
6536
|
/**
|
|
6521
6537
|
* Resets the state of a Watch target to its initial state (e.g. sets
|
|
6522
6538
|
* 'current' to false, clears the resume token and removes its target mapping
|
|
6523
6539
|
* from all documents).
|
|
6524
6540
|
*/ He(e) {
|
|
6525
|
-
this.
|
|
6526
|
-
this.
|
|
6541
|
+
this.Le.set(e, new __PRIVATE_TargetState);
|
|
6542
|
+
this.Be.getRemoteKeysForTarget(e).forEach((t => {
|
|
6527
6543
|
this.We(e, t, /*updatedDocument=*/ null);
|
|
6528
6544
|
}));
|
|
6529
6545
|
}
|
|
@@ -6531,7 +6547,7 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6531
6547
|
* Returns whether the LocalStore considers the document to be part of the
|
|
6532
6548
|
* specified target.
|
|
6533
6549
|
*/ ot(e, t) {
|
|
6534
|
-
return this.
|
|
6550
|
+
return this.Be.getRemoteKeysForTarget(e).has(t);
|
|
6535
6551
|
}
|
|
6536
6552
|
}
|
|
6537
6553
|
|
|
@@ -6549,7 +6565,7 @@ const Ie = (() => {
|
|
|
6549
6565
|
desc: "DESCENDING"
|
|
6550
6566
|
};
|
|
6551
6567
|
return e;
|
|
6552
|
-
})(),
|
|
6568
|
+
})(), de = (() => {
|
|
6553
6569
|
const e = {
|
|
6554
6570
|
"<": "LESS_THAN",
|
|
6555
6571
|
"<=": "LESS_THAN_OR_EQUAL",
|
|
@@ -6563,7 +6579,7 @@ const Ie = (() => {
|
|
|
6563
6579
|
"array-contains-any": "ARRAY_CONTAINS_ANY"
|
|
6564
6580
|
};
|
|
6565
6581
|
return e;
|
|
6566
|
-
})(),
|
|
6582
|
+
})(), Ee = (() => {
|
|
6567
6583
|
const e = {
|
|
6568
6584
|
and: "AND",
|
|
6569
6585
|
or: "OR"
|
|
@@ -7139,11 +7155,11 @@ function __PRIVATE_toDirection(e) {
|
|
|
7139
7155
|
}
|
|
7140
7156
|
|
|
7141
7157
|
function __PRIVATE_toOperatorName(e) {
|
|
7142
|
-
return
|
|
7158
|
+
return de[e];
|
|
7143
7159
|
}
|
|
7144
7160
|
|
|
7145
7161
|
function __PRIVATE_toCompositeOperatorName(e) {
|
|
7146
|
-
return
|
|
7162
|
+
return Ee[e];
|
|
7147
7163
|
}
|
|
7148
7164
|
|
|
7149
7165
|
function __PRIVATE_toFieldPathReference(e) {
|
|
@@ -7720,13 +7736,13 @@ class __PRIVATE_FirestoreIndexValueWriter {
|
|
|
7720
7736
|
// ["bar", [2, truncated("foo")]] -> (STRING, "bar", TERM, ARRAY, NUMBER, 2, STRING, "foo", TRUNC)
|
|
7721
7737
|
// ["bar", truncated(["foo"])] -> (STRING, "bar", TERM, ARRAY. STRING, "foo", TERM, TRUNC)
|
|
7722
7738
|
/** Writes an index value. */
|
|
7723
|
-
|
|
7724
|
-
this.
|
|
7739
|
+
dt(e, t) {
|
|
7740
|
+
this.Et(e, t),
|
|
7725
7741
|
// Write separator to split index values
|
|
7726
7742
|
// (see go/firestore-storage-format#encodings).
|
|
7727
7743
|
t.At();
|
|
7728
7744
|
}
|
|
7729
|
-
|
|
7745
|
+
Et(e, t) {
|
|
7730
7746
|
if ("nullValue" in e) this.Rt(t, 5); else if ("booleanValue" in e) this.Rt(t, 10),
|
|
7731
7747
|
t.Vt(e.booleanValue ? 1 : 0); else if ("integerValue" in e) this.Rt(t, 15), t.Vt(__PRIVATE_normalizeNumber(e.integerValue)); else if ("doubleValue" in e) {
|
|
7732
7748
|
const n = __PRIVATE_normalizeNumber(e.doubleValue);
|
|
@@ -7753,7 +7769,7 @@ class __PRIVATE_FirestoreIndexValueWriter {
|
|
|
7753
7769
|
Dt(e, t) {
|
|
7754
7770
|
const n = e.fields || {};
|
|
7755
7771
|
this.Rt(t, 55);
|
|
7756
|
-
for (const e of Object.keys(n)) this.gt(e, t), this.
|
|
7772
|
+
for (const e of Object.keys(n)) this.gt(e, t), this.Et(n[e], t);
|
|
7757
7773
|
}
|
|
7758
7774
|
bt(e, t) {
|
|
7759
7775
|
var n, r;
|
|
@@ -7763,12 +7779,12 @@ class __PRIVATE_FirestoreIndexValueWriter {
|
|
|
7763
7779
|
const s = "value", o = (null === (r = null === (n = i[s].arrayValue) || void 0 === n ? void 0 : n.values) || void 0 === r ? void 0 : r.length) || 0;
|
|
7764
7780
|
this.Rt(t, 15), t.Vt(__PRIVATE_normalizeNumber(o)),
|
|
7765
7781
|
// Vectors then sort by position value
|
|
7766
|
-
this.gt(s, t), this.
|
|
7782
|
+
this.gt(s, t), this.Et(i[s], t);
|
|
7767
7783
|
}
|
|
7768
7784
|
vt(e, t) {
|
|
7769
7785
|
const n = e.values || [];
|
|
7770
7786
|
this.Rt(t, 50);
|
|
7771
|
-
for (const e of n) this.
|
|
7787
|
+
for (const e of n) this.Et(e, t);
|
|
7772
7788
|
}
|
|
7773
7789
|
St(e, t) {
|
|
7774
7790
|
this.Rt(t, 37);
|
|
@@ -7842,8 +7858,8 @@ function __PRIVATE_unsignedNumLength(e) {
|
|
|
7842
7858
|
Nt(e) {
|
|
7843
7859
|
const t = e[Symbol.iterator]();
|
|
7844
7860
|
let n = t.next();
|
|
7845
|
-
for (;!n.done; ) this.
|
|
7846
|
-
this.
|
|
7861
|
+
for (;!n.done; ) this.Bt(n.value), n = t.next();
|
|
7862
|
+
this.Lt();
|
|
7847
7863
|
}
|
|
7848
7864
|
/** Writes utf8 bytes into this byte sequence, ascending. */ kt(e) {
|
|
7849
7865
|
for (const t of e) {
|
|
@@ -7860,14 +7876,14 @@ function __PRIVATE_unsignedNumLength(e) {
|
|
|
7860
7876
|
/** Writes utf8 bytes into this byte sequence, descending */ qt(e) {
|
|
7861
7877
|
for (const t of e) {
|
|
7862
7878
|
const e = t.charCodeAt(0);
|
|
7863
|
-
if (e < 128) this.
|
|
7864
|
-
this.
|
|
7879
|
+
if (e < 128) this.Bt(e); else if (e < 2048) this.Bt(960 | e >>> 6), this.Bt(128 | 63 & e); else if (t < "\ud800" || "\udbff" < t) this.Bt(480 | e >>> 12),
|
|
7880
|
+
this.Bt(128 | 63 & e >>> 6), this.Bt(128 | 63 & e); else {
|
|
7865
7881
|
const e = t.codePointAt(0);
|
|
7866
|
-
this.
|
|
7867
|
-
this.
|
|
7882
|
+
this.Bt(240 | e >>> 18), this.Bt(128 | 63 & e >>> 12), this.Bt(128 | 63 & e >>> 6),
|
|
7883
|
+
this.Bt(128 | 63 & e);
|
|
7868
7884
|
}
|
|
7869
7885
|
}
|
|
7870
|
-
this.
|
|
7886
|
+
this.Lt();
|
|
7871
7887
|
}
|
|
7872
7888
|
Qt(e) {
|
|
7873
7889
|
// Values are encoded with a single byte length prefix, followed by the
|
|
@@ -7933,14 +7949,14 @@ function __PRIVATE_unsignedNumLength(e) {
|
|
|
7933
7949
|
const t = 255 & e;
|
|
7934
7950
|
0 === t ? (this.Gt(0), this.Gt(255)) : 255 === t ? (this.Gt(255), this.Gt(0)) : this.Gt(t);
|
|
7935
7951
|
}
|
|
7936
|
-
/** Writes a single byte descending to the buffer. */
|
|
7952
|
+
/** Writes a single byte descending to the buffer. */ Bt(e) {
|
|
7937
7953
|
const t = 255 & e;
|
|
7938
7954
|
0 === t ? (this.jt(0), this.jt(255)) : 255 === t ? (this.jt(255), this.jt(0)) : this.jt(e);
|
|
7939
7955
|
}
|
|
7940
7956
|
Ot() {
|
|
7941
7957
|
this.Gt(0), this.Gt(1);
|
|
7942
7958
|
}
|
|
7943
|
-
|
|
7959
|
+
Lt() {
|
|
7944
7960
|
this.jt(0), this.jt(1);
|
|
7945
7961
|
}
|
|
7946
7962
|
Gt(e) {
|
|
@@ -8692,7 +8708,7 @@ class __PRIVATE_IndexedDbIndexManager {
|
|
|
8692
8708
|
n.push(t.value), r && (r = t.inclusive);
|
|
8693
8709
|
}
|
|
8694
8710
|
return new Bound(n, r);
|
|
8695
|
-
}(s, i), c = this.
|
|
8711
|
+
}(s, i), c = this.dn(i, s, a), l = this.dn(i, s, u), h = this.En(i, s, _), P = this.An(i.indexId, o, c, a.inclusive, l, u.inclusive, h);
|
|
8696
8712
|
return PersistencePromise.forEach(P, (i => n.G(i, t.limit).next((t => {
|
|
8697
8713
|
t.forEach((t => {
|
|
8698
8714
|
const n = DocumentKey.fromSegments(t.documentKey);
|
|
@@ -8786,13 +8802,13 @@ class __PRIVATE_IndexedDbIndexManager {
|
|
|
8786
8802
|
const e = t.data.field(r.fieldPath);
|
|
8787
8803
|
if (null == e) return null;
|
|
8788
8804
|
const i = n.Xt(r.kind);
|
|
8789
|
-
__PRIVATE_FirestoreIndexValueWriter.Ft.
|
|
8805
|
+
__PRIVATE_FirestoreIndexValueWriter.Ft.dt(e, i);
|
|
8790
8806
|
}
|
|
8791
8807
|
return n.Ht();
|
|
8792
8808
|
}
|
|
8793
8809
|
/** Encodes a single value to the ascending index format. */ Rn(e) {
|
|
8794
8810
|
const t = new __PRIVATE_IndexByteEncoder;
|
|
8795
|
-
return __PRIVATE_FirestoreIndexValueWriter.Ft.
|
|
8811
|
+
return __PRIVATE_FirestoreIndexValueWriter.Ft.dt(e, t.Xt(0 /* IndexKind.ASCENDING */)),
|
|
8796
8812
|
t.Ht();
|
|
8797
8813
|
}
|
|
8798
8814
|
/**
|
|
@@ -8800,7 +8816,7 @@ class __PRIVATE_IndexedDbIndexManager {
|
|
|
8800
8816
|
* ordering of the field index.
|
|
8801
8817
|
*/ gn(e, t) {
|
|
8802
8818
|
const n = new __PRIVATE_IndexByteEncoder;
|
|
8803
|
-
return __PRIVATE_FirestoreIndexValueWriter.Ft.
|
|
8819
|
+
return __PRIVATE_FirestoreIndexValueWriter.Ft.dt(__PRIVATE_refValue(this.databaseId, t), n.Xt(function __PRIVATE_fieldIndexGetKeyOrder(e) {
|
|
8804
8820
|
const t = __PRIVATE_fieldIndexGetDirectionalSegments(e);
|
|
8805
8821
|
return 0 === t.length ? 0 /* IndexKind.ASCENDING */ : t[t.length - 1].kind;
|
|
8806
8822
|
}(e))), n.Ht();
|
|
@@ -8808,7 +8824,7 @@ class __PRIVATE_IndexedDbIndexManager {
|
|
|
8808
8824
|
/**
|
|
8809
8825
|
* Encodes the given field values according to the specification in `target`.
|
|
8810
8826
|
* For IN queries, a list of possible values is returned.
|
|
8811
|
-
*/
|
|
8827
|
+
*/ En(e, t, n) {
|
|
8812
8828
|
if (null === n) return [];
|
|
8813
8829
|
let r = [];
|
|
8814
8830
|
r.push(new __PRIVATE_IndexByteEncoder);
|
|
@@ -8817,7 +8833,7 @@ class __PRIVATE_IndexedDbIndexManager {
|
|
|
8817
8833
|
const e = n[i++];
|
|
8818
8834
|
for (const n of r) if (this.pn(t, s.fieldPath) && isArray(e)) r = this.yn(r, s, e); else {
|
|
8819
8835
|
const t = n.Xt(s.kind);
|
|
8820
|
-
__PRIVATE_FirestoreIndexValueWriter.Ft.
|
|
8836
|
+
__PRIVATE_FirestoreIndexValueWriter.Ft.dt(e, t);
|
|
8821
8837
|
}
|
|
8822
8838
|
}
|
|
8823
8839
|
return this.wn(r);
|
|
@@ -8825,8 +8841,8 @@ class __PRIVATE_IndexedDbIndexManager {
|
|
|
8825
8841
|
/**
|
|
8826
8842
|
* Encodes the given bounds according to the specification in `target`. For IN
|
|
8827
8843
|
* queries, a list of possible values is returned.
|
|
8828
|
-
*/
|
|
8829
|
-
return this.
|
|
8844
|
+
*/ dn(e, t, n) {
|
|
8845
|
+
return this.En(e, t, n.position);
|
|
8830
8846
|
}
|
|
8831
8847
|
/** Returns the byte representation for the provided encoders. */ wn(e) {
|
|
8832
8848
|
const t = [];
|
|
@@ -8843,7 +8859,7 @@ class __PRIVATE_IndexedDbIndexManager {
|
|
|
8843
8859
|
const r = [ ...e ], i = [];
|
|
8844
8860
|
for (const e of n.arrayValue.values || []) for (const n of r) {
|
|
8845
8861
|
const r = new __PRIVATE_IndexByteEncoder;
|
|
8846
|
-
r.seed(n.Ht()), __PRIVATE_FirestoreIndexValueWriter.Ft.
|
|
8862
|
+
r.seed(n.Ht()), __PRIVATE_FirestoreIndexValueWriter.Ft.dt(e, r.Xt(t.kind)), i.push(r);
|
|
8847
8863
|
}
|
|
8848
8864
|
return i;
|
|
8849
8865
|
}
|
|
@@ -9356,7 +9372,7 @@ class __PRIVATE_IndexedDbMutationQueue {
|
|
|
9356
9372
|
}
|
|
9357
9373
|
removeMutationBatch(e, t) {
|
|
9358
9374
|
return removeMutationBatch(e._e, this.userId, t).next((n => (e.addOnCommittedListener((() => {
|
|
9359
|
-
this.
|
|
9375
|
+
this.Bn(t.batchId);
|
|
9360
9376
|
})), PersistencePromise.forEach(n, (t => this.referenceDelegate.markPotentiallyOrphaned(e, t))))));
|
|
9361
9377
|
}
|
|
9362
9378
|
/**
|
|
@@ -9368,7 +9384,7 @@ class __PRIVATE_IndexedDbMutationQueue {
|
|
|
9368
9384
|
* rejected batch is removed from the mutation queue.
|
|
9369
9385
|
*/
|
|
9370
9386
|
// PORTING NOTE: Multi-tab only
|
|
9371
|
-
|
|
9387
|
+
Bn(e) {
|
|
9372
9388
|
delete this.xn[e];
|
|
9373
9389
|
}
|
|
9374
9390
|
performConsistencyCheck(e) {
|
|
@@ -9401,7 +9417,7 @@ class __PRIVATE_IndexedDbMutationQueue {
|
|
|
9401
9417
|
}
|
|
9402
9418
|
// PORTING NOTE: Multi-tab only (state is held in memory in other clients).
|
|
9403
9419
|
/** Returns the mutation queue's metadata from IndexedDb. */
|
|
9404
|
-
|
|
9420
|
+
Ln(e) {
|
|
9405
9421
|
return __PRIVATE_mutationQueuesStore(e).get(this.userId).next((e => e || {
|
|
9406
9422
|
userId: this.userId,
|
|
9407
9423
|
lastAcknowledgedBatchId: -1,
|
|
@@ -10742,7 +10758,7 @@ class OverlayedDocument {
|
|
|
10742
10758
|
constructor() {
|
|
10743
10759
|
// A map sorted by DocumentKey, whose value is a pair of the largest batch id
|
|
10744
10760
|
// for the overlay and the overlay itself.
|
|
10745
|
-
this.overlays = new SortedMap(DocumentKey.comparator), this.
|
|
10761
|
+
this.overlays = new SortedMap(DocumentKey.comparator), this.dr = new Map;
|
|
10746
10762
|
}
|
|
10747
10763
|
getOverlay(e, t) {
|
|
10748
10764
|
return PersistencePromise.resolve(this.overlays.get(t));
|
|
@@ -10759,9 +10775,9 @@ class OverlayedDocument {
|
|
|
10759
10775
|
})), PersistencePromise.resolve();
|
|
10760
10776
|
}
|
|
10761
10777
|
removeOverlaysForBatchId(e, t, n) {
|
|
10762
|
-
const r = this.
|
|
10778
|
+
const r = this.dr.get(n);
|
|
10763
10779
|
return void 0 !== r && (r.forEach((e => this.overlays = this.overlays.remove(e))),
|
|
10764
|
-
this.
|
|
10780
|
+
this.dr.delete(n)), PersistencePromise.resolve();
|
|
10765
10781
|
}
|
|
10766
10782
|
getOverlaysForCollection(e, t, n) {
|
|
10767
10783
|
const r = __PRIVATE_newOverlayMap(), i = t.length + 1, s = new DocumentKey(t.child("")), o = this.overlays.getIteratorFrom(s);
|
|
@@ -10794,13 +10810,13 @@ class OverlayedDocument {
|
|
|
10794
10810
|
// Remove the association of the overlay to its batch id.
|
|
10795
10811
|
const r = this.overlays.get(n.key);
|
|
10796
10812
|
if (null !== r) {
|
|
10797
|
-
const e = this.
|
|
10798
|
-
this.
|
|
10813
|
+
const e = this.dr.get(r.largestBatchId).delete(n.key);
|
|
10814
|
+
this.dr.set(r.largestBatchId, e);
|
|
10799
10815
|
}
|
|
10800
10816
|
this.overlays = this.overlays.insert(n.key, new Overlay(t, n));
|
|
10801
10817
|
// Create the association of this overlay to the given largestBatchId.
|
|
10802
|
-
let i = this.
|
|
10803
|
-
void 0 === i && (i = __PRIVATE_documentKeySet(), this.
|
|
10818
|
+
let i = this.dr.get(t);
|
|
10819
|
+
void 0 === i && (i = __PRIVATE_documentKeySet(), this.dr.set(t, i)), this.dr.set(t, i.add(n.key));
|
|
10804
10820
|
}
|
|
10805
10821
|
}
|
|
10806
10822
|
|
|
@@ -10864,16 +10880,16 @@ class OverlayedDocument {
|
|
|
10864
10880
|
*/ class __PRIVATE_ReferenceSet {
|
|
10865
10881
|
constructor() {
|
|
10866
10882
|
// A set of outstanding references to a document sorted by key.
|
|
10867
|
-
this.
|
|
10883
|
+
this.Er = new SortedSet(__PRIVATE_DocReference.Ar),
|
|
10868
10884
|
// A set of outstanding references to a document sorted by target id.
|
|
10869
10885
|
this.Rr = new SortedSet(__PRIVATE_DocReference.Vr);
|
|
10870
10886
|
}
|
|
10871
10887
|
/** Returns true if the reference set contains no references. */ isEmpty() {
|
|
10872
|
-
return this.
|
|
10888
|
+
return this.Er.isEmpty();
|
|
10873
10889
|
}
|
|
10874
10890
|
/** Adds a reference to the given document key for the given ID. */ addReference(e, t) {
|
|
10875
10891
|
const n = new __PRIVATE_DocReference(e, t);
|
|
10876
|
-
this.
|
|
10892
|
+
this.Er = this.Er.add(n), this.Rr = this.Rr.add(n);
|
|
10877
10893
|
}
|
|
10878
10894
|
/** Add references to the given document keys for the given ID. */ mr(e, t) {
|
|
10879
10895
|
e.forEach((e => this.addReference(e, t)));
|
|
@@ -10897,10 +10913,10 @@ class OverlayedDocument {
|
|
|
10897
10913
|
})), i;
|
|
10898
10914
|
}
|
|
10899
10915
|
wr() {
|
|
10900
|
-
this.
|
|
10916
|
+
this.Er.forEach((e => this.gr(e)));
|
|
10901
10917
|
}
|
|
10902
10918
|
gr(e) {
|
|
10903
|
-
this.
|
|
10919
|
+
this.Er = this.Er.delete(e), this.Rr = this.Rr.delete(e);
|
|
10904
10920
|
}
|
|
10905
10921
|
Sr(e) {
|
|
10906
10922
|
const t = new DocumentKey(new ResourcePath([])), n = new __PRIVATE_DocReference(t, e), r = new __PRIVATE_DocReference(t, e + 1);
|
|
@@ -10910,7 +10926,7 @@ class OverlayedDocument {
|
|
|
10910
10926
|
})), i;
|
|
10911
10927
|
}
|
|
10912
10928
|
containsKey(e) {
|
|
10913
|
-
const t = new __PRIVATE_DocReference(e, 0), n = this.
|
|
10929
|
+
const t = new __PRIVATE_DocReference(e, 0), n = this.Er.firstAfterOrEqual(t);
|
|
10914
10930
|
return null !== n && e.isEqual(n.key);
|
|
10915
10931
|
}
|
|
10916
10932
|
}
|
|
@@ -11043,7 +11059,7 @@ class __PRIVATE_DocReference {
|
|
|
11043
11059
|
this.vr = n;
|
|
11044
11060
|
}));
|
|
11045
11061
|
}
|
|
11046
|
-
|
|
11062
|
+
Bn(e) {
|
|
11047
11063
|
// No-op since the memory mutation queue does not maintain a separate cache.
|
|
11048
11064
|
}
|
|
11049
11065
|
containsKey(e, t) {
|
|
@@ -11107,6 +11123,9 @@ class __PRIVATE_DocReference {
|
|
|
11107
11123
|
* See the License for the specific language governing permissions and
|
|
11108
11124
|
* limitations under the License.
|
|
11109
11125
|
*/
|
|
11126
|
+
/**
|
|
11127
|
+
* The smallest value representable by a 64-bit signed integer (long).
|
|
11128
|
+
*/
|
|
11110
11129
|
/**
|
|
11111
11130
|
* The memory-only RemoteDocumentCache for IndexedDb. To construct, invoke
|
|
11112
11131
|
* `newMemoryRemoteDocumentCache()`.
|
|
@@ -11165,8 +11184,11 @@ class __PRIVATE_MemoryRemoteDocumentCacheImpl {
|
|
|
11165
11184
|
let i = __PRIVATE_mutableDocumentMap();
|
|
11166
11185
|
// Documents are ordered by key, so we can use a prefix scan to narrow down
|
|
11167
11186
|
// the documents we need to match the query against.
|
|
11168
|
-
const s = t.path, o = new DocumentKey(s.child("")), _ = this.docs.getIteratorFrom(o);
|
|
11169
|
-
|
|
11187
|
+
const s = t.path, o = new DocumentKey(s.child("__id-9223372036854775808__")), _ = this.docs.getIteratorFrom(o);
|
|
11188
|
+
// Document keys are ordered first by numeric value ("__id<Long>__"),
|
|
11189
|
+
// then lexicographically by string value. Start the iterator at the minimum
|
|
11190
|
+
// possible Document key value.
|
|
11191
|
+
for (;_.hasNext(); ) {
|
|
11170
11192
|
const {key: e, value: {document: o}} = _.getNext();
|
|
11171
11193
|
if (!s.isPrefixOf(e.path)) break;
|
|
11172
11194
|
e.path.length > s.length + 1 || (__PRIVATE_indexOffsetComparator(__PRIVATE_newIndexOffsetFromDocument(o), n) <= 0 || (r.has(o.key) || __PRIVATE_queryMatches(t, o)) && (i = i.insert(o.key, o.mutableCopy())));
|
|
@@ -11178,7 +11200,7 @@ class __PRIVATE_MemoryRemoteDocumentCacheImpl {
|
|
|
11178
11200
|
// is enabled.
|
|
11179
11201
|
fail();
|
|
11180
11202
|
}
|
|
11181
|
-
|
|
11203
|
+
Br(e, t) {
|
|
11182
11204
|
return PersistencePromise.forEach(this.docs, (e => t(e)));
|
|
11183
11205
|
}
|
|
11184
11206
|
newChangeBuffer(e) {
|
|
@@ -11240,7 +11262,7 @@ class __PRIVATE_MemoryRemoteDocumentChangeBuffer extends RemoteDocumentChangeBuf
|
|
|
11240
11262
|
/**
|
|
11241
11263
|
* Maps a target to the data about that target
|
|
11242
11264
|
*/
|
|
11243
|
-
this.
|
|
11265
|
+
this.Lr = new ObjectMap((e => __PRIVATE_canonifyTarget(e)), __PRIVATE_targetEquals),
|
|
11244
11266
|
/** The last received snapshot version. */
|
|
11245
11267
|
this.lastRemoteSnapshotVersion = SnapshotVersion.min(),
|
|
11246
11268
|
/** The highest numbered target ID encountered. */
|
|
@@ -11254,7 +11276,7 @@ class __PRIVATE_MemoryRemoteDocumentChangeBuffer extends RemoteDocumentChangeBuf
|
|
|
11254
11276
|
this.qr = new __PRIVATE_ReferenceSet, this.targetCount = 0, this.Qr = __PRIVATE_TargetIdGenerator.qn();
|
|
11255
11277
|
}
|
|
11256
11278
|
forEachTarget(e, t) {
|
|
11257
|
-
return this.
|
|
11279
|
+
return this.Lr.forEach(((e, n) => t(n))), PersistencePromise.resolve();
|
|
11258
11280
|
}
|
|
11259
11281
|
getLastRemoteSnapshotVersion(e) {
|
|
11260
11282
|
return PersistencePromise.resolve(this.lastRemoteSnapshotVersion);
|
|
@@ -11270,7 +11292,7 @@ class __PRIVATE_MemoryRemoteDocumentChangeBuffer extends RemoteDocumentChangeBuf
|
|
|
11270
11292
|
PersistencePromise.resolve();
|
|
11271
11293
|
}
|
|
11272
11294
|
Un(e) {
|
|
11273
|
-
this.
|
|
11295
|
+
this.Lr.set(e.target, e);
|
|
11274
11296
|
const t = e.targetId;
|
|
11275
11297
|
t > this.highestTargetId && (this.Qr = new __PRIVATE_TargetIdGenerator(t), this.highestTargetId = t),
|
|
11276
11298
|
e.sequenceNumber > this.kr && (this.kr = e.sequenceNumber);
|
|
@@ -11282,14 +11304,14 @@ class __PRIVATE_MemoryRemoteDocumentChangeBuffer extends RemoteDocumentChangeBuf
|
|
|
11282
11304
|
return this.Un(t), PersistencePromise.resolve();
|
|
11283
11305
|
}
|
|
11284
11306
|
removeTargetData(e, t) {
|
|
11285
|
-
return this.
|
|
11307
|
+
return this.Lr.delete(t.target), this.qr.yr(t.targetId), this.targetCount -= 1,
|
|
11286
11308
|
PersistencePromise.resolve();
|
|
11287
11309
|
}
|
|
11288
11310
|
removeTargets(e, t, n) {
|
|
11289
11311
|
let r = 0;
|
|
11290
11312
|
const i = [];
|
|
11291
|
-
return this.
|
|
11292
|
-
o.sequenceNumber <= t && null === n.get(o.targetId) && (this.
|
|
11313
|
+
return this.Lr.forEach(((s, o) => {
|
|
11314
|
+
o.sequenceNumber <= t && null === n.get(o.targetId) && (this.Lr.delete(s), i.push(this.removeMatchingKeysForTargetId(e, o.targetId)),
|
|
11293
11315
|
r++);
|
|
11294
11316
|
})), PersistencePromise.waitFor(i).next((() => r));
|
|
11295
11317
|
}
|
|
@@ -11297,7 +11319,7 @@ class __PRIVATE_MemoryRemoteDocumentChangeBuffer extends RemoteDocumentChangeBuf
|
|
|
11297
11319
|
return PersistencePromise.resolve(this.targetCount);
|
|
11298
11320
|
}
|
|
11299
11321
|
getTargetData(e, t) {
|
|
11300
|
-
const n = this.
|
|
11322
|
+
const n = this.Lr.get(t) || null;
|
|
11301
11323
|
return PersistencePromise.resolve(n);
|
|
11302
11324
|
}
|
|
11303
11325
|
addMatchingKeys(e, t, n) {
|
|
@@ -11515,7 +11537,7 @@ class __PRIVATE_MemoryLruDelegate {
|
|
|
11515
11537
|
removeOrphanedDocuments(e, t) {
|
|
11516
11538
|
let n = 0;
|
|
11517
11539
|
const r = this.persistence.getRemoteDocumentCache(), i = r.newChangeBuffer();
|
|
11518
|
-
return r.
|
|
11540
|
+
return r.Br(e, (r => this.ir(e, r, t).next((e => {
|
|
11519
11541
|
e || (n++, i.removeEntry(r, SnapshotVersion.min()));
|
|
11520
11542
|
})))).next((() => i.apply(e))).next((() => n));
|
|
11521
11543
|
}
|
|
@@ -11681,7 +11703,7 @@ class __PRIVATE_MemoryLruDelegate {
|
|
|
11681
11703
|
const t = e.createObjectStore("remoteDocumentsV14", {
|
|
11682
11704
|
keyPath: O
|
|
11683
11705
|
});
|
|
11684
|
-
t.createIndex("documentKeyIndex", N), t.createIndex("collectionGroupIndex",
|
|
11706
|
+
t.createIndex("documentKeyIndex", N), t.createIndex("collectionGroupIndex", B);
|
|
11685
11707
|
}(e))).next((() => this.ui(e, i))).next((() => e.deleteObjectStore("remoteDocuments")))),
|
|
11686
11708
|
n < 14 && r >= 14 && (s = s.next((() => this.ci(e, i)))), n < 15 && r >= 15 && (s = s.next((() => function __PRIVATE_createFieldIndex(e) {
|
|
11687
11709
|
e.createObjectStore("indexConfiguration", {
|
|
@@ -11850,7 +11872,7 @@ function __PRIVATE_createQueryCache(e) {
|
|
|
11850
11872
|
// NOTE: This is unique only because the TargetId is the suffix.
|
|
11851
11873
|
e.createObjectStore("targets", {
|
|
11852
11874
|
keyPath: "targetId"
|
|
11853
|
-
}).createIndex("queryTargetsIndex",
|
|
11875
|
+
}).createIndex("queryTargetsIndex", L, {
|
|
11854
11876
|
unique: !0
|
|
11855
11877
|
}), e.createObjectStore("targetGlobal");
|
|
11856
11878
|
}
|
|
@@ -11925,9 +11947,9 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
11925
11947
|
/** Our window.unload handler, if registered. */
|
|
11926
11948
|
this.Ii = null, this.inForeground = !1,
|
|
11927
11949
|
/** Our 'visibilitychange' listener if registered. */
|
|
11928
|
-
this.Ei = null,
|
|
11929
|
-
/** The client metadata refresh task. */
|
|
11930
11950
|
this.di = null,
|
|
11951
|
+
/** The client metadata refresh task. */
|
|
11952
|
+
this.Ei = null,
|
|
11931
11953
|
/** The last time we garbage collected the client metadata object store. */
|
|
11932
11954
|
this.Ai = Number.NEGATIVE_INFINITY,
|
|
11933
11955
|
/** A listener to notify on primary state changes. */
|
|
@@ -11976,7 +11998,7 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
11976
11998
|
*
|
|
11977
11999
|
* PORTING NOTE: This is only used for Web multi-tab.
|
|
11978
12000
|
*/ setDatabaseDeletedListener(e) {
|
|
11979
|
-
this.mi.
|
|
12001
|
+
this.mi.B((async t => {
|
|
11980
12002
|
// Check if an attempt is made to delete IndexedDB.
|
|
11981
12003
|
null === t.newVersion && await e();
|
|
11982
12004
|
}));
|
|
@@ -12048,14 +12070,14 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12048
12070
|
// Ideally we'd delete the IndexedDb and LocalStorage zombie entries for
|
|
12049
12071
|
// the client atomically, but we can't. So we opt to delete the IndexedDb
|
|
12050
12072
|
// entries first to avoid potentially reviving a zombied client.
|
|
12051
|
-
if (this.fi) for (const t of e) this.fi.removeItem(this.
|
|
12073
|
+
if (this.fi) for (const t of e) this.fi.removeItem(this.Bi(t.clientId));
|
|
12052
12074
|
}
|
|
12053
12075
|
}
|
|
12054
12076
|
/**
|
|
12055
12077
|
* Schedules a recurring timer to update the client metadata and to either
|
|
12056
12078
|
* extend or acquire the primary lease if the client is eligible.
|
|
12057
12079
|
*/ wi() {
|
|
12058
|
-
this.
|
|
12080
|
+
this.Ei = this.li.enqueueAfterDelay("client_metadata_refresh" /* TimerId.ClientMetadataRefresh */ , 4e3, (() => this.gi().then((() => this.xi())).then((() => this.wi()))));
|
|
12059
12081
|
}
|
|
12060
12082
|
/** Checks whether `client` is the local client. */ Fi(e) {
|
|
12061
12083
|
return !!e && e.ownerId === this.clientId;
|
|
@@ -12078,7 +12100,7 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12078
12100
|
// - every clients network is disabled and no other client's tab is in
|
|
12079
12101
|
// the foreground.
|
|
12080
12102
|
// - the `forceOwningTab` setting was passed in.
|
|
12081
|
-
if (null !== t && this.Oi(t.leaseTimestampMs, 5e3) && !this.
|
|
12103
|
+
if (null !== t && this.Oi(t.leaseTimestampMs, 5e3) && !this.Li(t.ownerId)) {
|
|
12082
12104
|
if (this.Fi(t) && this.networkEnabled) return !0;
|
|
12083
12105
|
if (!this.Fi(t)) {
|
|
12084
12106
|
if (!t.allowTabSynchronization)
|
|
@@ -12110,7 +12132,7 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12110
12132
|
async shutdown() {
|
|
12111
12133
|
// The shutdown() operations are idempotent and can be called even when
|
|
12112
12134
|
// start() aborted (e.g. because it couldn't acquire the persistence lease).
|
|
12113
|
-
this.Ur = !1, this.ki(), this.
|
|
12135
|
+
this.Ur = !1, this.ki(), this.Ei && (this.Ei.cancel(), this.Ei = null), this.qi(),
|
|
12114
12136
|
this.Qi(),
|
|
12115
12137
|
// Use `SimpleDb.runTransaction` directly to avoid failing if another tab
|
|
12116
12138
|
// has obtained the primary lease.
|
|
@@ -12126,7 +12148,7 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12126
12148
|
* Returns clients that are not zombied and have an updateTime within the
|
|
12127
12149
|
* provided threshold.
|
|
12128
12150
|
*/ Ni(e, t) {
|
|
12129
|
-
return e.filter((e => this.Oi(e.updateTimeMs, t) && !this.
|
|
12151
|
+
return e.filter((e => this.Oi(e.updateTimeMs, t) && !this.Li(e.clientId)));
|
|
12130
12152
|
}
|
|
12131
12153
|
/**
|
|
12132
12154
|
* Returns the IDs of the clients that are currently active. If multi-tab
|
|
@@ -12187,7 +12209,7 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12187
12209
|
// be turned off.
|
|
12188
12210
|
Ui(e) {
|
|
12189
12211
|
return __PRIVATE_primaryClientStore(e).get("owner").next((e => {
|
|
12190
|
-
if (null !== e && this.Oi(e.leaseTimestampMs, 5e3) && !this.
|
|
12212
|
+
if (null !== e && this.Oi(e.leaseTimestampMs, 5e3) && !this.Li(e.ownerId) && !this.Fi(e) && !(this.Pi || this.allowTabSynchronization && e.allowTabSynchronization)) throw new FirestoreError(D.FAILED_PRECONDITION, Ve);
|
|
12191
12213
|
}));
|
|
12192
12214
|
}
|
|
12193
12215
|
/**
|
|
@@ -12215,13 +12237,13 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12215
12237
|
!1));
|
|
12216
12238
|
}
|
|
12217
12239
|
pi() {
|
|
12218
|
-
null !== this.document && "function" == typeof this.document.addEventListener && (this.
|
|
12240
|
+
null !== this.document && "function" == typeof this.document.addEventListener && (this.di = () => {
|
|
12219
12241
|
this.li.enqueueAndForget((() => (this.inForeground = "visible" === this.document.visibilityState,
|
|
12220
12242
|
this.gi())));
|
|
12221
|
-
}, this.document.addEventListener("visibilitychange", this.
|
|
12243
|
+
}, this.document.addEventListener("visibilitychange", this.di), this.inForeground = "visible" === this.document.visibilityState);
|
|
12222
12244
|
}
|
|
12223
12245
|
qi() {
|
|
12224
|
-
this.
|
|
12246
|
+
this.di && (this.document.removeEventListener("visibilitychange", this.di), this.di = null);
|
|
12225
12247
|
}
|
|
12226
12248
|
/**
|
|
12227
12249
|
* Attaches a window.unload handler that will synchronously write our
|
|
@@ -12255,10 +12277,10 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12255
12277
|
* Returns whether a client is "zombied" based on its LocalStorage entry.
|
|
12256
12278
|
* Clients become zombied when their tab closes without running all of the
|
|
12257
12279
|
* cleanup logic in `shutdown()`.
|
|
12258
|
-
*/
|
|
12280
|
+
*/ Li(e) {
|
|
12259
12281
|
var t;
|
|
12260
12282
|
try {
|
|
12261
|
-
const n = null !== (null === (t = this.fi) || void 0 === t ? void 0 : t.getItem(this.
|
|
12283
|
+
const n = null !== (null === (t = this.fi) || void 0 === t ? void 0 : t.getItem(this.Bi(e)));
|
|
12262
12284
|
return __PRIVATE_logDebug("IndexedDbPersistence", `Client '${e}' ${n ? "is" : "is not"} zombied in LocalStorage`),
|
|
12263
12285
|
n;
|
|
12264
12286
|
} catch (e) {
|
|
@@ -12272,7 +12294,7 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12272
12294
|
* clients are ignored during primary tab selection.
|
|
12273
12295
|
*/ ki() {
|
|
12274
12296
|
if (this.fi) try {
|
|
12275
|
-
this.fi.setItem(this.
|
|
12297
|
+
this.fi.setItem(this.Bi(this.clientId), String(Date.now()));
|
|
12276
12298
|
} catch (e) {
|
|
12277
12299
|
// Gracefully handle if LocalStorage isn't available / working.
|
|
12278
12300
|
__PRIVATE_logError("Failed to set zombie client id.", e);
|
|
@@ -12280,12 +12302,12 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12280
12302
|
}
|
|
12281
12303
|
/** Removes the zombied client entry if it exists. */ Ki() {
|
|
12282
12304
|
if (this.fi) try {
|
|
12283
|
-
this.fi.removeItem(this.
|
|
12305
|
+
this.fi.removeItem(this.Bi(this.clientId));
|
|
12284
12306
|
} catch (e) {
|
|
12285
12307
|
// Ignore
|
|
12286
12308
|
}
|
|
12287
12309
|
}
|
|
12288
|
-
|
|
12310
|
+
Bi(e) {
|
|
12289
12311
|
return `firestore_zombie_${this.persistenceKey}_${e}`;
|
|
12290
12312
|
}
|
|
12291
12313
|
}
|
|
@@ -12825,7 +12847,7 @@ function __PRIVATE_localStoreGetLastRemoteSnapshotVersion(e) {
|
|
|
12825
12847
|
// Each loop iteration only affects its "own" doc, so it's safe to get all
|
|
12826
12848
|
// the remote documents in advance in a single call.
|
|
12827
12849
|
o.push(__PRIVATE_populateDocumentChangeBuffer(e, s, t.documentUpdates).next((e => {
|
|
12828
|
-
_ = e.Is, a = e.
|
|
12850
|
+
_ = e.Is, a = e.ds;
|
|
12829
12851
|
}))), !r.isEqual(SnapshotVersion.min())) {
|
|
12830
12852
|
const t = n.Gr.getLastRemoteSnapshotVersion(e).next((t => n.Gr.setTargetsMetadata(e, e.currentSequenceNumber, r)));
|
|
12831
12853
|
o.push(t);
|
|
@@ -12863,7 +12885,7 @@ function __PRIVATE_localStoreGetLastRemoteSnapshotVersion(e) {
|
|
|
12863
12885
|
r = r.insert(n, s)) : __PRIVATE_logDebug("LocalStore", "Ignoring outdated watch update for ", n, ". Current version:", o.version, " Watch version:", s.version);
|
|
12864
12886
|
})), {
|
|
12865
12887
|
Is: r,
|
|
12866
|
-
|
|
12888
|
+
ds: i
|
|
12867
12889
|
};
|
|
12868
12890
|
}));
|
|
12869
12891
|
}
|
|
@@ -12962,7 +12984,7 @@ async function __PRIVATE_localStoreReleaseTarget(e, t, n) {
|
|
|
12962
12984
|
})).next((() => r._s.getDocumentsMatchingQuery(e, t, n ? i : SnapshotVersion.min(), n ? s : __PRIVATE_documentKeySet()))).next((e => (__PRIVATE_setMaxReadTime(r, __PRIVATE_queryCollectionGroup(t), e),
|
|
12963
12985
|
{
|
|
12964
12986
|
documents: e,
|
|
12965
|
-
|
|
12987
|
+
Es: s
|
|
12966
12988
|
})))));
|
|
12967
12989
|
}
|
|
12968
12990
|
|
|
@@ -13031,7 +13053,7 @@ async function __PRIVATE_localStoreApplyBundledDocuments(e, t, n, r) {
|
|
|
13031
13053
|
// Allocates a target to hold all document keys from the bundle, such that
|
|
13032
13054
|
// they will not get garbage collected right away.
|
|
13033
13055
|
return i.persistence.runTransaction("Apply bundle documents", "readwrite", (e => __PRIVATE_populateDocumentChangeBuffer(e, _, o).next((t => (_.apply(e),
|
|
13034
|
-
t))).next((t => i.Gr.removeMatchingKeysForTargetId(e, a.targetId).next((() => i.Gr.addMatchingKeys(e, s, a.targetId))).next((() => i.localDocuments.getLocalViewOfDocuments(e, t.Is, t.
|
|
13056
|
+
t))).next((t => i.Gr.removeMatchingKeysForTargetId(e, a.targetId).next((() => i.Gr.addMatchingKeys(e, s, a.targetId))).next((() => i.localDocuments.getLocalViewOfDocuments(e, t.Is, t.ds))).next((() => t.Is))))));
|
|
13035
13057
|
}
|
|
13036
13058
|
|
|
13037
13059
|
/**
|
|
@@ -13270,7 +13292,7 @@ class __PRIVATE_LocalClientState {
|
|
|
13270
13292
|
// format of the key is:
|
|
13271
13293
|
// firestore_bundle_loaded_v2_<persistenceKey>
|
|
13272
13294
|
// The version ending with "v2" stores the list of modified collection groups.
|
|
13273
|
-
(this.persistenceKey), this.
|
|
13295
|
+
(this.persistenceKey), this.Bs = function createBundleLoadedKey(e) {
|
|
13274
13296
|
return `firestore_bundle_loaded_v2_${e}`;
|
|
13275
13297
|
}
|
|
13276
13298
|
// The WebStorage key prefix for the key that stores the last sequence number allocated. The key
|
|
@@ -13299,7 +13321,7 @@ class __PRIVATE_LocalClientState {
|
|
|
13299
13321
|
n && (this.Ds = this.Ds.insert(n.clientId, n));
|
|
13300
13322
|
}
|
|
13301
13323
|
}
|
|
13302
|
-
this.
|
|
13324
|
+
this.Ls();
|
|
13303
13325
|
// Check if there is an existing online state and call the callback handler
|
|
13304
13326
|
// if applicable.
|
|
13305
13327
|
const t = this.storage.getItem(this.Ns);
|
|
@@ -13348,10 +13370,10 @@ class __PRIVATE_LocalClientState {
|
|
|
13348
13370
|
}
|
|
13349
13371
|
// If the query is listening to cache only, the target ID should not be registered with the
|
|
13350
13372
|
// local Firestore client as an active watch target.
|
|
13351
|
-
return t && this.Us.ps(e), this.
|
|
13373
|
+
return t && this.Us.ps(e), this.Ls(), n;
|
|
13352
13374
|
}
|
|
13353
13375
|
removeLocalQueryTarget(e) {
|
|
13354
|
-
this.Us.ys(e), this.
|
|
13376
|
+
this.Us.ys(e), this.Ls();
|
|
13355
13377
|
}
|
|
13356
13378
|
isLocalQueryTarget(e) {
|
|
13357
13379
|
return this.Us.activeTargetIds.has(e);
|
|
@@ -13438,7 +13460,7 @@ class __PRIVATE_LocalClientState {
|
|
|
13438
13460
|
* isolated and no synchronization is performed.
|
|
13439
13461
|
*/ (t.newValue);
|
|
13440
13462
|
e !== __PRIVATE_ListenSequence.oe && this.sequenceNumberHandler(e);
|
|
13441
|
-
} else if (t.key === this.
|
|
13463
|
+
} else if (t.key === this.Bs) {
|
|
13442
13464
|
const e = this.no(t.newValue);
|
|
13443
13465
|
await Promise.all(e.map((e => this.syncEngine.ro(e))));
|
|
13444
13466
|
}
|
|
@@ -13449,7 +13471,7 @@ class __PRIVATE_LocalClientState {
|
|
|
13449
13471
|
get Us() {
|
|
13450
13472
|
return this.Ds.get(this.ws);
|
|
13451
13473
|
}
|
|
13452
|
-
|
|
13474
|
+
Ls() {
|
|
13453
13475
|
this.setItem(this.Cs, this.Us.gs());
|
|
13454
13476
|
}
|
|
13455
13477
|
Ks(e, t, n) {
|
|
@@ -13473,7 +13495,7 @@ class __PRIVATE_LocalClientState {
|
|
|
13473
13495
|
}
|
|
13474
13496
|
zs(e) {
|
|
13475
13497
|
const t = JSON.stringify(Array.from(e));
|
|
13476
|
-
this.setItem(this.
|
|
13498
|
+
this.setItem(this.Bs, t);
|
|
13477
13499
|
}
|
|
13478
13500
|
/**
|
|
13479
13501
|
* Parses a client state key in WebStorage. Returns null if the key does not
|
|
@@ -13840,7 +13862,7 @@ class __PRIVATE_RestConnection {
|
|
|
13840
13862
|
"google-cloud-resource-prefix": this.Mo,
|
|
13841
13863
|
"x-goog-request-params": this.xo
|
|
13842
13864
|
};
|
|
13843
|
-
return this.
|
|
13865
|
+
return this.Bo(_, r, i), this.Lo(e, o, _, n).then((t => (__PRIVATE_logDebug("RestConnection", `Received RPC '${e}' ${s}: `, t),
|
|
13844
13866
|
t)), (t => {
|
|
13845
13867
|
throw __PRIVATE_logWarn("RestConnection", `RPC '${e}' ${s} failed with error: `, t, "url: ", o, "request:", n),
|
|
13846
13868
|
t;
|
|
@@ -13854,7 +13876,7 @@ class __PRIVATE_RestConnection {
|
|
|
13854
13876
|
/**
|
|
13855
13877
|
* Modifies the headers for a request, adding any authorization token if
|
|
13856
13878
|
* present and any additional headers for the request.
|
|
13857
|
-
*/
|
|
13879
|
+
*/ Bo(e, t, n) {
|
|
13858
13880
|
e["X-Goog-Api-Client"] =
|
|
13859
13881
|
// SDK_VERSION is updated to different value at runtime depending on the entry point,
|
|
13860
13882
|
// so we need to get its value when we need it in a function.
|
|
@@ -13884,7 +13906,7 @@ class __PRIVATE_RestConnection {
|
|
|
13884
13906
|
super(e), this.forceLongPolling = e.forceLongPolling, this.autoDetectLongPolling = e.autoDetectLongPolling,
|
|
13885
13907
|
this.useFetchStreams = e.useFetchStreams, this.longPollingOptions = e.longPollingOptions;
|
|
13886
13908
|
}
|
|
13887
|
-
|
|
13909
|
+
Lo(e, t, n, r) {
|
|
13888
13910
|
const i = __PRIVATE_generateUniqueDebugId();
|
|
13889
13911
|
return new Promise(((s, o) => {
|
|
13890
13912
|
const _ = new webchannelBlob.XhrIo;
|
|
@@ -13958,7 +13980,7 @@ class __PRIVATE_RestConnection {
|
|
|
13958
13980
|
detectBufferingProxy: this.autoDetectLongPolling
|
|
13959
13981
|
}, a = this.longPollingOptions.timeoutSeconds;
|
|
13960
13982
|
void 0 !== a && (_.longPollingTimeout = Math.round(1e3 * a)), this.useFetchStreams && (_.useFetchStreams = !0),
|
|
13961
|
-
this.
|
|
13983
|
+
this.Bo(_.initMessageHeaders, t, n),
|
|
13962
13984
|
// Sending the custom headers we just added to request.initMessageHeaders
|
|
13963
13985
|
// (Authorization, etc.) will trigger the browser to make a CORS preflight
|
|
13964
13986
|
// request because the XHR will no longer meet the criteria for a "simple"
|
|
@@ -14415,19 +14437,19 @@ class __PRIVATE_PersistentStream {
|
|
|
14415
14437
|
}), (t => {
|
|
14416
14438
|
e((() => {
|
|
14417
14439
|
const e = new FirestoreError(D.UNKNOWN, "Fetching auth token failed: " + t.message);
|
|
14418
|
-
return this.
|
|
14440
|
+
return this.d_(e);
|
|
14419
14441
|
}));
|
|
14420
14442
|
}));
|
|
14421
14443
|
}
|
|
14422
14444
|
I_(e, t) {
|
|
14423
14445
|
const n = this.T_(this.Xo);
|
|
14424
|
-
this.stream = this.
|
|
14446
|
+
this.stream = this.E_(e, t), this.stream.Ro((() => {
|
|
14425
14447
|
n((() => this.listener.Ro()));
|
|
14426
14448
|
})), this.stream.mo((() => {
|
|
14427
14449
|
n((() => (this.state = 2 /* PersistentStreamState.Open */ , this.t_ = this.li.enqueueAfterDelay(this.Zo, 1e4, (() => (this.s_() && (this.state = 3 /* PersistentStreamState.Healthy */),
|
|
14428
14450
|
Promise.resolve()))), this.listener.mo())));
|
|
14429
14451
|
})), this.stream.po((e => {
|
|
14430
|
-
n((() => this.
|
|
14452
|
+
n((() => this.d_(e)));
|
|
14431
14453
|
})), this.stream.onMessage((e => {
|
|
14432
14454
|
n((() => 1 == ++this.n_ ? this.A_(e) : this.onNext(e)));
|
|
14433
14455
|
}));
|
|
@@ -14438,7 +14460,7 @@ class __PRIVATE_PersistentStream {
|
|
|
14438
14460
|
}));
|
|
14439
14461
|
}
|
|
14440
14462
|
// Visible for tests
|
|
14441
|
-
|
|
14463
|
+
d_(e) {
|
|
14442
14464
|
// In theory the stream could close cleanly, however, in our current model
|
|
14443
14465
|
// we never expect this to happen because if we stop a stream ourselves,
|
|
14444
14466
|
// this callback will never be called. To prevent cases where we retry
|
|
@@ -14470,7 +14492,7 @@ class __PRIVATE_PersistentStream {
|
|
|
14470
14492
|
super(e, "listen_stream_connection_backoff" /* TimerId.ListenStreamConnectionBackoff */ , "listen_stream_idle" /* TimerId.ListenStreamIdle */ , "health_check_timeout" /* TimerId.HealthCheckTimeout */ , t, n, r, s),
|
|
14471
14493
|
this.serializer = i;
|
|
14472
14494
|
}
|
|
14473
|
-
|
|
14495
|
+
E_(e, t) {
|
|
14474
14496
|
return this.connection.qo("Listen", e, t);
|
|
14475
14497
|
}
|
|
14476
14498
|
A_(e) {
|
|
@@ -14564,7 +14586,7 @@ class __PRIVATE_PersistentStream {
|
|
|
14564
14586
|
P_() {
|
|
14565
14587
|
this.f_ && this.g_([]);
|
|
14566
14588
|
}
|
|
14567
|
-
|
|
14589
|
+
E_(e, t) {
|
|
14568
14590
|
return this.connection.qo("Write", e, t);
|
|
14569
14591
|
}
|
|
14570
14592
|
A_(e) {
|
|
@@ -14775,7 +14797,7 @@ class __PRIVATE_OnlineStateTracker {
|
|
|
14775
14797
|
* purely based on order, and so we can just shift() writes from the front of
|
|
14776
14798
|
* the writePipeline as we receive responses.
|
|
14777
14799
|
*/
|
|
14778
|
-
this.
|
|
14800
|
+
this.B_ = [],
|
|
14779
14801
|
/**
|
|
14780
14802
|
* A mapping of watched targets that the client cares about tracking and the
|
|
14781
14803
|
* user has explicitly called a 'listen' for this target.
|
|
@@ -14785,7 +14807,7 @@ class __PRIVATE_OnlineStateTracker {
|
|
|
14785
14807
|
* to the server. The targets removed with unlistens are removed eagerly
|
|
14786
14808
|
* without waiting for confirmation from the listen stream.
|
|
14787
14809
|
*/
|
|
14788
|
-
this.
|
|
14810
|
+
this.L_ = new Map,
|
|
14789
14811
|
/**
|
|
14790
14812
|
* A set of reasons for why the RemoteStore may be offline. If empty, the
|
|
14791
14813
|
* RemoteStore may start its network connections.
|
|
@@ -14832,9 +14854,9 @@ async function __PRIVATE_enableNetworkInternal(e) {
|
|
|
14832
14854
|
*/
|
|
14833
14855
|
function __PRIVATE_remoteStoreListen(e, t) {
|
|
14834
14856
|
const n = __PRIVATE_debugCast(e);
|
|
14835
|
-
n.
|
|
14857
|
+
n.L_.has(t.targetId) || (
|
|
14836
14858
|
// Mark this as something the client is currently listening for.
|
|
14837
|
-
n.
|
|
14859
|
+
n.L_.set(t.targetId, t), __PRIVATE_shouldStartWatchStream(n) ?
|
|
14838
14860
|
// The listen will be sent in onWatchStreamOpen
|
|
14839
14861
|
__PRIVATE_startWatchStream(n) : __PRIVATE_ensureWatchStream(n).s_() && __PRIVATE_sendWatchRequest(n, t));
|
|
14840
14862
|
}
|
|
@@ -14844,7 +14866,7 @@ function __PRIVATE_remoteStoreListen(e, t) {
|
|
|
14844
14866
|
* not being listened to.
|
|
14845
14867
|
*/ function __PRIVATE_remoteStoreUnlisten(e, t) {
|
|
14846
14868
|
const n = __PRIVATE_debugCast(e), r = __PRIVATE_ensureWatchStream(n);
|
|
14847
|
-
n.
|
|
14869
|
+
n.L_.delete(t), r.s_() && __PRIVATE_sendUnwatchRequest(n, t), 0 === n.L_.size && (r.s_() ? r.a_() : __PRIVATE_canUseNetwork(n) &&
|
|
14848
14870
|
// Revert to OnlineState.Unknown if the watch stream is not open and we
|
|
14849
14871
|
// have no listeners, since without any listens to send we cannot
|
|
14850
14872
|
// confirm if the stream is healthy and upgrade to OnlineState.Online.
|
|
@@ -14873,7 +14895,7 @@ function __PRIVATE_remoteStoreListen(e, t) {
|
|
|
14873
14895
|
function __PRIVATE_startWatchStream(e) {
|
|
14874
14896
|
e.U_ = new __PRIVATE_WatchChangeAggregator({
|
|
14875
14897
|
getRemoteKeysForTarget: t => e.remoteSyncer.getRemoteKeysForTarget(t),
|
|
14876
|
-
ut: t => e.
|
|
14898
|
+
ut: t => e.L_.get(t) || null,
|
|
14877
14899
|
nt: () => e.datastore.serializer.databaseId
|
|
14878
14900
|
}), __PRIVATE_ensureWatchStream(e).start(), e.K_.F_();
|
|
14879
14901
|
}
|
|
@@ -14882,7 +14904,7 @@ function __PRIVATE_startWatchStream(e) {
|
|
|
14882
14904
|
* Returns whether the watch stream should be started because it's necessary
|
|
14883
14905
|
* and has not yet been started.
|
|
14884
14906
|
*/ function __PRIVATE_shouldStartWatchStream(e) {
|
|
14885
|
-
return __PRIVATE_canUseNetwork(e) && !__PRIVATE_ensureWatchStream(e).i_() && e.
|
|
14907
|
+
return __PRIVATE_canUseNetwork(e) && !__PRIVATE_ensureWatchStream(e).i_() && e.L_.size > 0;
|
|
14886
14908
|
}
|
|
14887
14909
|
|
|
14888
14910
|
function __PRIVATE_canUseNetwork(e) {
|
|
@@ -14899,7 +14921,7 @@ async function __PRIVATE_onWatchStreamConnected(e) {
|
|
|
14899
14921
|
}
|
|
14900
14922
|
|
|
14901
14923
|
async function __PRIVATE_onWatchStreamOpen(e) {
|
|
14902
|
-
e.
|
|
14924
|
+
e.L_.forEach(((t, n) => {
|
|
14903
14925
|
__PRIVATE_sendWatchRequest(e, t);
|
|
14904
14926
|
}));
|
|
14905
14927
|
}
|
|
@@ -14927,7 +14949,7 @@ async function __PRIVATE_onWatchStreamChange(e, t, n) {
|
|
|
14927
14949
|
const n = t.cause;
|
|
14928
14950
|
for (const r of t.targetIds)
|
|
14929
14951
|
// A watched target might have been removed already.
|
|
14930
|
-
e.
|
|
14952
|
+
e.L_.has(r) && (await e.remoteSyncer.rejectListen(r, n), e.L_.delete(r), e.U_.removeTarget(r));
|
|
14931
14953
|
}
|
|
14932
14954
|
/**
|
|
14933
14955
|
* Attempts to fill our write pipeline with writes from the LocalStore.
|
|
@@ -14958,21 +14980,21 @@ async function __PRIVATE_onWatchStreamChange(e, t, n) {
|
|
|
14958
14980
|
// persistent view of these when applying the completed RemoteEvent.
|
|
14959
14981
|
return n.targetChanges.forEach(((n, r) => {
|
|
14960
14982
|
if (n.resumeToken.approximateByteSize() > 0) {
|
|
14961
|
-
const i = e.
|
|
14983
|
+
const i = e.L_.get(r);
|
|
14962
14984
|
// A watched target might have been removed already.
|
|
14963
|
-
i && e.
|
|
14985
|
+
i && e.L_.set(r, i.withResumeToken(n.resumeToken, t));
|
|
14964
14986
|
}
|
|
14965
14987
|
})),
|
|
14966
14988
|
// Re-establish listens for the targets that have been invalidated by
|
|
14967
14989
|
// existence filter mismatches.
|
|
14968
14990
|
n.targetMismatches.forEach(((t, n) => {
|
|
14969
|
-
const r = e.
|
|
14991
|
+
const r = e.L_.get(t);
|
|
14970
14992
|
if (!r)
|
|
14971
14993
|
// A watched target might have been removed already.
|
|
14972
14994
|
return;
|
|
14973
14995
|
// Clear the resume token for the target, since we're in a known mismatch
|
|
14974
14996
|
// state.
|
|
14975
|
-
e.
|
|
14997
|
+
e.L_.set(t, r.withResumeToken(ByteString.EMPTY_BYTE_STRING, r.snapshotVersion)),
|
|
14976
14998
|
// Cause a hard reset by unwatching and rewatching immediately, but
|
|
14977
14999
|
// deliberately don't send a resume token so that we get a full update.
|
|
14978
15000
|
__PRIVATE_sendUnwatchRequest(e, t);
|
|
@@ -15023,11 +15045,11 @@ async function __PRIVATE_onWatchStreamChange(e, t, n) {
|
|
|
15023
15045
|
|
|
15024
15046
|
async function __PRIVATE_fillWritePipeline(e) {
|
|
15025
15047
|
const t = __PRIVATE_debugCast(e), n = __PRIVATE_ensureWriteStream(t);
|
|
15026
|
-
let r = t.
|
|
15048
|
+
let r = t.B_.length > 0 ? t.B_[t.B_.length - 1].batchId : -1;
|
|
15027
15049
|
for (;__PRIVATE_canAddToWritePipeline(t); ) try {
|
|
15028
15050
|
const e = await __PRIVATE_localStoreGetNextMutationBatch(t.localStore, r);
|
|
15029
15051
|
if (null === e) {
|
|
15030
|
-
0 === t.
|
|
15052
|
+
0 === t.B_.length && n.a_();
|
|
15031
15053
|
break;
|
|
15032
15054
|
}
|
|
15033
15055
|
r = e.batchId, __PRIVATE_addToWritePipeline(t, e);
|
|
@@ -15041,20 +15063,20 @@ async function __PRIVATE_fillWritePipeline(e) {
|
|
|
15041
15063
|
* Returns true if we can add to the write pipeline (i.e. the network is
|
|
15042
15064
|
* enabled and the write pipeline is not full).
|
|
15043
15065
|
*/ function __PRIVATE_canAddToWritePipeline(e) {
|
|
15044
|
-
return __PRIVATE_canUseNetwork(e) && e.
|
|
15066
|
+
return __PRIVATE_canUseNetwork(e) && e.B_.length < 10;
|
|
15045
15067
|
}
|
|
15046
15068
|
|
|
15047
15069
|
/**
|
|
15048
15070
|
* Queues additional writes to be sent to the write stream, sending them
|
|
15049
15071
|
* immediately if the write stream is established.
|
|
15050
15072
|
*/ function __PRIVATE_addToWritePipeline(e, t) {
|
|
15051
|
-
e.
|
|
15073
|
+
e.B_.push(t);
|
|
15052
15074
|
const n = __PRIVATE_ensureWriteStream(e);
|
|
15053
15075
|
n.s_() && n.f_ && n.g_(t.mutations);
|
|
15054
15076
|
}
|
|
15055
15077
|
|
|
15056
15078
|
function __PRIVATE_shouldStartWriteStream(e) {
|
|
15057
|
-
return __PRIVATE_canUseNetwork(e) && !__PRIVATE_ensureWriteStream(e).i_() && e.
|
|
15079
|
+
return __PRIVATE_canUseNetwork(e) && !__PRIVATE_ensureWriteStream(e).i_() && e.B_.length > 0;
|
|
15058
15080
|
}
|
|
15059
15081
|
|
|
15060
15082
|
function __PRIVATE_startWriteStream(e) {
|
|
@@ -15068,11 +15090,11 @@ async function __PRIVATE_onWriteStreamOpen(e) {
|
|
|
15068
15090
|
async function __PRIVATE_onWriteHandshakeComplete(e) {
|
|
15069
15091
|
const t = __PRIVATE_ensureWriteStream(e);
|
|
15070
15092
|
// Send the write pipeline now that the stream is established.
|
|
15071
|
-
for (const n of e.
|
|
15093
|
+
for (const n of e.B_) t.g_(n.mutations);
|
|
15072
15094
|
}
|
|
15073
15095
|
|
|
15074
15096
|
async function __PRIVATE_onMutationResult(e, t, n) {
|
|
15075
|
-
const r = e.
|
|
15097
|
+
const r = e.B_.shift(), i = MutationBatchResult.from(r, t, n);
|
|
15076
15098
|
await __PRIVATE_executeWithRecovery(e, (() => e.remoteSyncer.applySuccessfulWrite(i))),
|
|
15077
15099
|
// It's possible that with the completion of this mutation another
|
|
15078
15100
|
// slot has freed up.
|
|
@@ -15092,7 +15114,7 @@ async function __PRIVATE_onWriteStreamClose(e, t) {
|
|
|
15092
15114
|
}(t.code)) {
|
|
15093
15115
|
// This was a permanent error, the request itself was the problem
|
|
15094
15116
|
// so it's not going to succeed if we resend it.
|
|
15095
|
-
const n = e.
|
|
15117
|
+
const n = e.B_.shift();
|
|
15096
15118
|
// In this case it's also unlikely that the server itself is melting
|
|
15097
15119
|
// down -- this was just a bad request so inhibit backoff on the next
|
|
15098
15120
|
// restart.
|
|
@@ -15191,8 +15213,8 @@ async function __PRIVATE_remoteStoreHandleCredentialChange(e, t) {
|
|
|
15191
15213
|
}), e.q_.push((async t => {
|
|
15192
15214
|
t ? (e.G_.__(),
|
|
15193
15215
|
// This will start the write stream if necessary.
|
|
15194
|
-
await __PRIVATE_fillWritePipeline(e)) : (await e.G_.stop(), e.
|
|
15195
|
-
e.
|
|
15216
|
+
await __PRIVATE_fillWritePipeline(e)) : (await e.G_.stop(), e.B_.length > 0 && (__PRIVATE_logDebug("RemoteStore", `Stopping write stream with ${e.B_.length} pending writes`),
|
|
15217
|
+
e.B_ = []));
|
|
15196
15218
|
}))), e.G_;
|
|
15197
15219
|
}
|
|
15198
15220
|
|
|
@@ -15814,7 +15836,7 @@ class __PRIVATE_QueryListener {
|
|
|
15814
15836
|
return this.progress.taskState = "Success", {
|
|
15815
15837
|
progress: this.progress,
|
|
15816
15838
|
Ia: this.collectionGroups,
|
|
15817
|
-
|
|
15839
|
+
da: e
|
|
15818
15840
|
};
|
|
15819
15841
|
}
|
|
15820
15842
|
}
|
|
@@ -15872,7 +15894,7 @@ class __PRIVATE_RemovedLimboDocument {
|
|
|
15872
15894
|
constructor(e,
|
|
15873
15895
|
/** Documents included in the remote target */
|
|
15874
15896
|
t) {
|
|
15875
|
-
this.query = e, this.
|
|
15897
|
+
this.query = e, this.Ea = t, this.Aa = null, this.hasCachedResults = !1,
|
|
15876
15898
|
/**
|
|
15877
15899
|
* A flag whether the view is current with the backend. A view is considered
|
|
15878
15900
|
* current after it has seen the current flag from the backend and did not
|
|
@@ -15890,7 +15912,7 @@ class __PRIVATE_RemovedLimboDocument {
|
|
|
15890
15912
|
* The set of remote documents that the server has told us belongs to the target associated with
|
|
15891
15913
|
* this view.
|
|
15892
15914
|
*/ get fa() {
|
|
15893
|
-
return this.
|
|
15915
|
+
return this.Ea;
|
|
15894
15916
|
}
|
|
15895
15917
|
/**
|
|
15896
15918
|
* Iterates over a set of doc changes, applies the query limit, and computes
|
|
@@ -16064,7 +16086,7 @@ class __PRIVATE_RemovedLimboDocument {
|
|
|
16064
16086
|
* Returns whether the doc for the given key should be in limbo.
|
|
16065
16087
|
*/ Da(e) {
|
|
16066
16088
|
// If the remote end says it's part of this query, it's not in limbo.
|
|
16067
|
-
return !this.
|
|
16089
|
+
return !this.Ea.has(e) && (
|
|
16068
16090
|
// The local store doesn't think it's a result, so it shouldn't be in limbo.
|
|
16069
16091
|
!!this.ma.has(e) && !this.ma.get(e).hasLocalMutations);
|
|
16070
16092
|
}
|
|
@@ -16072,8 +16094,8 @@ class __PRIVATE_RemovedLimboDocument {
|
|
|
16072
16094
|
* Updates syncedDocuments, current, and limbo docs based on the given change.
|
|
16073
16095
|
* Returns the list of changes to which docs are in limbo.
|
|
16074
16096
|
*/ wa(e) {
|
|
16075
|
-
e && (e.addedDocuments.forEach((e => this.
|
|
16076
|
-
e.removedDocuments.forEach((e => this.
|
|
16097
|
+
e && (e.addedDocuments.forEach((e => this.Ea = this.Ea.add(e))), e.modifiedDocuments.forEach((e => {})),
|
|
16098
|
+
e.removedDocuments.forEach((e => this.Ea = this.Ea.delete(e))), this.current = e.current);
|
|
16077
16099
|
}
|
|
16078
16100
|
Sa() {
|
|
16079
16101
|
// We can only determine limbo documents when we're in-sync with the server.
|
|
@@ -16113,7 +16135,7 @@ class __PRIVATE_RemovedLimboDocument {
|
|
|
16113
16135
|
*/
|
|
16114
16136
|
// PORTING NOTE: Multi-tab only.
|
|
16115
16137
|
va(e) {
|
|
16116
|
-
this.
|
|
16138
|
+
this.Ea = e.Es, this.Ra = __PRIVATE_documentKeySet();
|
|
16117
16139
|
const t = this.ga(e.documents);
|
|
16118
16140
|
return this.applyChanges(t, /* limboResolutionEnabled= */ !0);
|
|
16119
16141
|
}
|
|
@@ -16200,12 +16222,12 @@ class __PRIVATE_QueryView {
|
|
|
16200
16222
|
* Keeps track of the target ID for each document that is in limbo with an
|
|
16201
16223
|
* active target.
|
|
16202
16224
|
*/
|
|
16203
|
-
this.
|
|
16225
|
+
this.Ba = new SortedMap(DocumentKey.comparator),
|
|
16204
16226
|
/**
|
|
16205
16227
|
* Keeps track of the information about an active limbo resolution for each
|
|
16206
16228
|
* active target ID that was started for the purpose of limbo resolution.
|
|
16207
16229
|
*/
|
|
16208
|
-
this.
|
|
16230
|
+
this.La = new Map, this.ka = new __PRIVATE_ReferenceSet,
|
|
16209
16231
|
/** Stores user completion handlers, indexed by User and BatchId. */
|
|
16210
16232
|
this.qa = {},
|
|
16211
16233
|
/** Stores user callbacks waiting for all pending writes to be acknowledged. */
|
|
@@ -16274,7 +16296,7 @@ async function __PRIVATE_allocateTargetAndMaybeListen(e, t, n, r) {
|
|
|
16274
16296
|
return __PRIVATE_updateTrackedLimbos(e, t.targetId, _.ba), _.snapshot;
|
|
16275
16297
|
}(e, t, n, r);
|
|
16276
16298
|
const s = await __PRIVATE_localStoreExecuteQuery(e.localStore, t,
|
|
16277
|
-
/* usePreviousResults= */ !0), o = new __PRIVATE_View(t, s.
|
|
16299
|
+
/* usePreviousResults= */ !0), o = new __PRIVATE_View(t, s.Es), _ = o.ga(s.documents), a = TargetChange.createSynthesizedTargetChangeForCurrentChange(n, r && "Offline" /* OnlineState.Offline */ !== e.onlineState, i), u = o.applyChanges(_,
|
|
16278
16300
|
/* limboResolutionEnabled= */ e.isPrimaryClient, a);
|
|
16279
16301
|
__PRIVATE_updateTrackedLimbos(e, n, u.ba);
|
|
16280
16302
|
const c = new __PRIVATE_QueryView(t, n, o);
|
|
@@ -16389,7 +16411,7 @@ async function __PRIVATE_allocateTargetAndMaybeListen(e, t, n, r) {
|
|
|
16389
16411
|
const e = await __PRIVATE_localStoreApplyRemoteEventToLocalCache(n.localStore, t);
|
|
16390
16412
|
// Update `receivedDocument` as appropriate for any limbo targets.
|
|
16391
16413
|
t.targetChanges.forEach(((e, t) => {
|
|
16392
|
-
const r = n.
|
|
16414
|
+
const r = n.La.get(t);
|
|
16393
16415
|
r && (
|
|
16394
16416
|
// Since this is a limbo resolution lookup, it's for a single document
|
|
16395
16417
|
// and it could be added, modified, or removed, but not a combination.
|
|
@@ -16443,7 +16465,7 @@ async function __PRIVATE_allocateTargetAndMaybeListen(e, t, n, r) {
|
|
|
16443
16465
|
const r = __PRIVATE_debugCast(e);
|
|
16444
16466
|
// PORTING NOTE: Multi-tab only.
|
|
16445
16467
|
r.sharedClientState.updateQueryState(t, "rejected", n);
|
|
16446
|
-
const i = r.
|
|
16468
|
+
const i = r.La.get(t), s = i && i.key;
|
|
16447
16469
|
if (s) {
|
|
16448
16470
|
// TODO(klimt): We really only should do the following on permission
|
|
16449
16471
|
// denied errors, but we don't have the cause code here.
|
|
@@ -16465,7 +16487,7 @@ async function __PRIVATE_allocateTargetAndMaybeListen(e, t, n, r) {
|
|
|
16465
16487
|
// RemoteEvent. If `applyRemoteEvent()` throws, we want to re-listen to
|
|
16466
16488
|
// this query when the RemoteStore restarts the Watch stream, which should
|
|
16467
16489
|
// re-trigger the target failure.
|
|
16468
|
-
r.
|
|
16490
|
+
r.Ba = r.Ba.remove(s), r.La.delete(t), __PRIVATE_pumpEnqueuedLimboResolutions(r);
|
|
16469
16491
|
} else await __PRIVATE_localStoreReleaseTarget(r.localStore, t,
|
|
16470
16492
|
/* keepPersistedTargetData */ !1).then((() => __PRIVATE_removeAndCleanupTarget(r, t, n))).catch(__PRIVATE_ignoreIfPrimaryLeaseLoss);
|
|
16471
16493
|
}
|
|
@@ -16571,9 +16593,9 @@ function __PRIVATE_removeLimboTarget(e, t) {
|
|
|
16571
16593
|
e.Na.delete(t.path.canonicalString());
|
|
16572
16594
|
// It's possible that the target already got removed because the query failed. In that case,
|
|
16573
16595
|
// the key won't exist in `limboTargetsByKey`. Only do the cleanup if we still have the target.
|
|
16574
|
-
const n = e.
|
|
16575
|
-
null !== n && (__PRIVATE_remoteStoreUnlisten(e.remoteStore, n), e.
|
|
16576
|
-
e.
|
|
16596
|
+
const n = e.Ba.get(t);
|
|
16597
|
+
null !== n && (__PRIVATE_remoteStoreUnlisten(e.remoteStore, n), e.Ba = e.Ba.remove(t),
|
|
16598
|
+
e.La.delete(n), __PRIVATE_pumpEnqueuedLimboResolutions(e));
|
|
16577
16599
|
}
|
|
16578
16600
|
|
|
16579
16601
|
function __PRIVATE_updateTrackedLimbos(e, t, n) {
|
|
@@ -16588,7 +16610,7 @@ function __PRIVATE_updateTrackedLimbos(e, t, n) {
|
|
|
16588
16610
|
|
|
16589
16611
|
function __PRIVATE_trackLimboChange(e, t) {
|
|
16590
16612
|
const n = t.key, r = n.path.canonicalString();
|
|
16591
|
-
e.
|
|
16613
|
+
e.Ba.get(n) || e.Na.has(r) || (__PRIVATE_logDebug("SyncEngine", "New document in limbo: " + n),
|
|
16592
16614
|
e.Na.add(r), __PRIVATE_pumpEnqueuedLimboResolutions(e));
|
|
16593
16615
|
}
|
|
16594
16616
|
|
|
@@ -16600,11 +16622,11 @@ function __PRIVATE_trackLimboChange(e, t) {
|
|
|
16600
16622
|
* with "resource exhausted" errors which can lead to pathological client
|
|
16601
16623
|
* behavior as seen in https://github.com/firebase/firebase-js-sdk/issues/2683.
|
|
16602
16624
|
*/ function __PRIVATE_pumpEnqueuedLimboResolutions(e) {
|
|
16603
|
-
for (;e.Na.size > 0 && e.
|
|
16625
|
+
for (;e.Na.size > 0 && e.Ba.size < e.maxConcurrentLimboResolutions; ) {
|
|
16604
16626
|
const t = e.Na.values().next().value;
|
|
16605
16627
|
e.Na.delete(t);
|
|
16606
16628
|
const n = new DocumentKey(ResourcePath.fromString(t)), r = e.Ka.next();
|
|
16607
|
-
e.
|
|
16629
|
+
e.La.set(r, new LimboResolution(n)), e.Ba = e.Ba.insert(n, r), __PRIVATE_remoteStoreListen(e.remoteStore, new TargetData(__PRIVATE_queryToTarget(__PRIVATE_newQueryForPath(n.path)), r, "TargetPurposeLimboResolution" /* TargetPurpose.LimboResolution */ , __PRIVATE_ListenSequence.oe));
|
|
16608
16630
|
}
|
|
16609
16631
|
}
|
|
16610
16632
|
|
|
@@ -16672,7 +16694,7 @@ async function __PRIVATE_syncEngineHandleCredentialChange(e, t) {
|
|
|
16672
16694
|
}
|
|
16673
16695
|
|
|
16674
16696
|
function __PRIVATE_syncEngineGetRemoteKeysForTarget(e, t) {
|
|
16675
|
-
const n = __PRIVATE_debugCast(e), r = n.
|
|
16697
|
+
const n = __PRIVATE_debugCast(e), r = n.La.get(t);
|
|
16676
16698
|
if (r && r.Fa) return __PRIVATE_documentKeySet().add(r.key);
|
|
16677
16699
|
{
|
|
16678
16700
|
let e = __PRIVATE_documentKeySet();
|
|
@@ -16724,7 +16746,7 @@ async function __PRIVATE_syncEngineApplyBatchState(e, t, n, r) {
|
|
|
16724
16746
|
// other clients.
|
|
16725
16747
|
__PRIVATE_processUserCallback(i, t, r || null), __PRIVATE_triggerPendingWritesCallbacks(i, t),
|
|
16726
16748
|
function __PRIVATE_localStoreRemoveCachedMutationBatchMetadata(e, t) {
|
|
16727
|
-
__PRIVATE_debugCast(__PRIVATE_debugCast(e).mutationQueue).
|
|
16749
|
+
__PRIVATE_debugCast(__PRIVATE_debugCast(e).mutationQueue).Bn(t);
|
|
16728
16750
|
}
|
|
16729
16751
|
// PORTING NOTE: Multi-Tab only.
|
|
16730
16752
|
(i.localStore, t)) : fail(), await __PRIVATE_syncEngineEmitNewSnapsAndNotifyLocalStore(i, s)) :
|
|
@@ -16764,9 +16786,9 @@ async function __PRIVATE_syncEngineApplyPrimaryState(e, t) {
|
|
|
16764
16786
|
// PORTING NOTE: Multi-Tab only.
|
|
16765
16787
|
function __PRIVATE_resetLimboDocuments(e) {
|
|
16766
16788
|
const t = __PRIVATE_debugCast(e);
|
|
16767
|
-
t.
|
|
16789
|
+
t.La.forEach(((e, n) => {
|
|
16768
16790
|
__PRIVATE_remoteStoreUnlisten(t.remoteStore, n);
|
|
16769
|
-
})), t.ka.wr(), t.
|
|
16791
|
+
})), t.ka.wr(), t.La = new Map, t.Ba = new SortedMap(DocumentKey.comparator);
|
|
16770
16792
|
}
|
|
16771
16793
|
/**
|
|
16772
16794
|
* Reconcile the query views of the provided query targets with the state from
|
|
@@ -16939,7 +16961,7 @@ function __PRIVATE_syncEngineEnsureWriteCallbacks(e) {
|
|
|
16939
16961
|
e && n._updateProgress(e), s = await t.Ga();
|
|
16940
16962
|
}
|
|
16941
16963
|
const o = await i.complete();
|
|
16942
|
-
return await __PRIVATE_syncEngineEmitNewSnapsAndNotifyLocalStore(e, o.
|
|
16964
|
+
return await __PRIVATE_syncEngineEmitNewSnapsAndNotifyLocalStore(e, o.da,
|
|
16943
16965
|
/* remoteEvent */ void 0),
|
|
16944
16966
|
// Save metadata, so loading the same bundle will skip.
|
|
16945
16967
|
await function __PRIVATE_localStoreSaveBundle(e, t) {
|
|
@@ -17828,7 +17850,7 @@ function __PRIVATE_firestoreClientGetDocumentsFromLocalCache(e, t) {
|
|
|
17828
17850
|
return e.asyncQueue.enqueueAndForget((async () => async function __PRIVATE_executeQueryFromCache(e, t, n) {
|
|
17829
17851
|
try {
|
|
17830
17852
|
const r = await __PRIVATE_localStoreExecuteQuery(e, t,
|
|
17831
|
-
/* usePreviousResults= */ !0), i = new __PRIVATE_View(t, r.
|
|
17853
|
+
/* usePreviousResults= */ !0), i = new __PRIVATE_View(t, r.Es), s = i.ga(r.documents), o = i.applyChanges(s,
|
|
17832
17854
|
/* limboResolutionEnabled= */ !1);
|
|
17833
17855
|
n.resolve(o.snapshot);
|
|
17834
17856
|
} catch (e) {
|
|
@@ -18590,10 +18612,10 @@ function doc(e, t, ...n) {
|
|
|
18590
18612
|
this.Iu = [],
|
|
18591
18613
|
// Is this AsyncQueue being shut down? Once it is set to true, it will not
|
|
18592
18614
|
// be changed again.
|
|
18593
|
-
this.
|
|
18615
|
+
this.du = !1,
|
|
18594
18616
|
// Operations scheduled to be queued in the future. Operations are
|
|
18595
18617
|
// automatically removed after they are run or canceled.
|
|
18596
|
-
this.
|
|
18618
|
+
this.Eu = [],
|
|
18597
18619
|
// visible for testing
|
|
18598
18620
|
this.Au = null,
|
|
18599
18621
|
// Flag set while there's an outstanding AsyncQueue operation, used for
|
|
@@ -18617,7 +18639,7 @@ function doc(e, t, ...n) {
|
|
|
18617
18639
|
t && "function" == typeof t.addEventListener && t.addEventListener("visibilitychange", this.fu);
|
|
18618
18640
|
}
|
|
18619
18641
|
get isShuttingDown() {
|
|
18620
|
-
return this.
|
|
18642
|
+
return this.du;
|
|
18621
18643
|
}
|
|
18622
18644
|
/**
|
|
18623
18645
|
* Adds a new operation to the queue without waiting for it to complete (i.e.
|
|
@@ -18632,21 +18654,21 @@ function doc(e, t, ...n) {
|
|
|
18632
18654
|
this.yu(e);
|
|
18633
18655
|
}
|
|
18634
18656
|
enterRestrictedMode(e) {
|
|
18635
|
-
if (!this.
|
|
18636
|
-
this.
|
|
18657
|
+
if (!this.du) {
|
|
18658
|
+
this.du = !0, this.Vu = e || !1;
|
|
18637
18659
|
const t = getDocument();
|
|
18638
18660
|
t && "function" == typeof t.removeEventListener && t.removeEventListener("visibilitychange", this.fu);
|
|
18639
18661
|
}
|
|
18640
18662
|
}
|
|
18641
18663
|
enqueue(e) {
|
|
18642
|
-
if (this.pu(), this.
|
|
18664
|
+
if (this.pu(), this.du)
|
|
18643
18665
|
// Return a Promise which never resolves.
|
|
18644
18666
|
return new Promise((() => {}));
|
|
18645
18667
|
// Create a deferred Promise that we can return to the callee. This
|
|
18646
18668
|
// allows us to return a "hanging Promise" only to the callee and still
|
|
18647
18669
|
// advance the queue even when the operation is not run.
|
|
18648
18670
|
const t = new __PRIVATE_Deferred;
|
|
18649
|
-
return this.yu((() => this.
|
|
18671
|
+
return this.yu((() => this.du && this.Vu ? Promise.resolve() : (e().then(t.resolve, t.reject),
|
|
18650
18672
|
t.promise))).then((() => t.promise));
|
|
18651
18673
|
}
|
|
18652
18674
|
enqueueRetryable(e) {
|
|
@@ -18720,7 +18742,7 @@ function doc(e, t, ...n) {
|
|
|
18720
18742
|
// Fast-forward delays for timerIds that have been overridden.
|
|
18721
18743
|
this.mu.indexOf(e) > -1 && (t = 0);
|
|
18722
18744
|
const r = DelayedOperation.createAndSchedule(this, e, t, n, (e => this.Su(e)));
|
|
18723
|
-
return this.
|
|
18745
|
+
return this.Eu.push(r), r;
|
|
18724
18746
|
}
|
|
18725
18747
|
pu() {
|
|
18726
18748
|
this.Au && fail();
|
|
@@ -18743,7 +18765,7 @@ function doc(e, t, ...n) {
|
|
|
18743
18765
|
* For Tests: Determine if a delayed operation with a particular TimerId
|
|
18744
18766
|
* exists.
|
|
18745
18767
|
*/ Du(e) {
|
|
18746
|
-
for (const t of this.
|
|
18768
|
+
for (const t of this.Eu) if (t.timerId === e) return !0;
|
|
18747
18769
|
return !1;
|
|
18748
18770
|
}
|
|
18749
18771
|
/**
|
|
@@ -18757,8 +18779,8 @@ function doc(e, t, ...n) {
|
|
|
18757
18779
|
return this.bu().then((() => {
|
|
18758
18780
|
// Run ops in the same order they'd run if they ran naturally.
|
|
18759
18781
|
/* eslint-disable-next-line @typescript-eslint/no-floating-promises */
|
|
18760
|
-
this.
|
|
18761
|
-
for (const t of this.
|
|
18782
|
+
this.Eu.sort(((e, t) => e.targetTimeMs - t.targetTimeMs));
|
|
18783
|
+
for (const t of this.Eu) if (t.skipDelay(), "all" /* TimerId.All */ !== e && t.timerId === e) break;
|
|
18762
18784
|
return this.bu();
|
|
18763
18785
|
}));
|
|
18764
18786
|
}
|
|
@@ -18769,8 +18791,8 @@ function doc(e, t, ...n) {
|
|
|
18769
18791
|
}
|
|
18770
18792
|
/** Called once a DelayedOperation is run or canceled. */ Su(e) {
|
|
18771
18793
|
// NOTE: indexOf / slice are O(n), but delayedOperations is expected to be small.
|
|
18772
|
-
const t = this.
|
|
18773
|
-
/* eslint-disable-next-line @typescript-eslint/no-floating-promises */ this.
|
|
18794
|
+
const t = this.Eu.indexOf(e);
|
|
18795
|
+
/* eslint-disable-next-line @typescript-eslint/no-floating-promises */ this.Eu.splice(t, 1);
|
|
18774
18796
|
}
|
|
18775
18797
|
}
|
|
18776
18798
|
|
|
@@ -19638,9 +19660,9 @@ function __PRIVATE_isWrite(e) {
|
|
|
19638
19660
|
path: n,
|
|
19639
19661
|
Nu: !1
|
|
19640
19662
|
});
|
|
19641
|
-
return r.
|
|
19663
|
+
return r.Bu(e), r;
|
|
19642
19664
|
}
|
|
19643
|
-
|
|
19665
|
+
Lu(e) {
|
|
19644
19666
|
var t;
|
|
19645
19667
|
const n = null === (t = this.path) || void 0 === t ? void 0 : t.child(e), r = this.xu({
|
|
19646
19668
|
path: n,
|
|
@@ -19665,9 +19687,9 @@ function __PRIVATE_isWrite(e) {
|
|
|
19665
19687
|
Fu() {
|
|
19666
19688
|
// TODO(b/34871131): Remove null check once we have proper paths for fields
|
|
19667
19689
|
// within arrays.
|
|
19668
|
-
if (this.path) for (let e = 0; e < this.path.length; e++) this.
|
|
19690
|
+
if (this.path) for (let e = 0; e < this.path.length; e++) this.Bu(this.path.get(e));
|
|
19669
19691
|
}
|
|
19670
|
-
|
|
19692
|
+
Bu(e) {
|
|
19671
19693
|
if (0 === e.length) throw this.qu("Document fields must not be empty");
|
|
19672
19694
|
if (__PRIVATE_isWrite(this.Mu) && be.test(e)) throw this.qu('Document fields cannot begin and end with "__"');
|
|
19673
19695
|
}
|
|
@@ -19809,7 +19831,7 @@ class __PRIVATE_NumericIncrementFieldValueImpl extends FieldValue {
|
|
|
19809
19831
|
// For Compat types, we have to "extract" the underlying types before
|
|
19810
19832
|
// performing validation.
|
|
19811
19833
|
r = util.getModularInstance(r);
|
|
19812
|
-
const a = i.
|
|
19834
|
+
const a = i.Lu(_);
|
|
19813
19835
|
if (r instanceof __PRIVATE_DeleteFieldValueImpl)
|
|
19814
19836
|
// Add it to the field mask, but don't add anything to updateData.
|
|
19815
19837
|
s.push(_); else {
|
|
@@ -19835,7 +19857,7 @@ class __PRIVATE_NumericIncrementFieldValueImpl extends FieldValue {
|
|
|
19835
19857
|
// For Compat types, we have to "extract" the underlying types before
|
|
19836
19858
|
// performing validation.
|
|
19837
19859
|
n = util.getModularInstance(n);
|
|
19838
|
-
const r = o.
|
|
19860
|
+
const r = o.Lu(t);
|
|
19839
19861
|
if (n instanceof __PRIVATE_DeleteFieldValueImpl)
|
|
19840
19862
|
// Add it to the field mask, but don't add anything to updateData.
|
|
19841
19863
|
u.push(t); else {
|
|
@@ -22233,9 +22255,9 @@ let Fe = null;
|
|
|
22233
22255
|
return r = Object.assign({
|
|
22234
22256
|
useFetchStreams: t
|
|
22235
22257
|
}, r), s._setSettings(r), s;
|
|
22236
|
-
}), "PUBLIC").setMultipleInstances(!0)), app.registerVersion(w, "4.7.
|
|
22258
|
+
}), "PUBLIC").setMultipleInstances(!0)), app.registerVersion(w, "4.7.6-canary.144bc3709", e),
|
|
22237
22259
|
// BUILD_TARGET will be replaced by values like esm2017, cjs2017, etc during the compilation
|
|
22238
|
-
app.registerVersion(w, "4.7.
|
|
22260
|
+
app.registerVersion(w, "4.7.6-canary.144bc3709", "cjs2017");
|
|
22239
22261
|
}();
|
|
22240
22262
|
|
|
22241
22263
|
exports.AbstractUserDataWriter = AbstractUserDataWriter;
|