@firebase/firestore 4.7.5-canary.8a83d287b → 4.7.5-canary.c19a051ce
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.esm2017.js
CHANGED
|
@@ -67,7 +67,7 @@ User.MOCK_USER = new User("mock-user");
|
|
|
67
67
|
* See the License for the specific language governing permissions and
|
|
68
68
|
* limitations under the License.
|
|
69
69
|
*/
|
|
70
|
-
let S = "11.1.0-canary.
|
|
70
|
+
let S = "11.1.0-canary.c19a051ce";
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
73
|
* @license
|
|
@@ -1001,14 +1001,30 @@ class BasePath {
|
|
|
1001
1001
|
toArray() {
|
|
1002
1002
|
return this.segments.slice(this.offset, this.limit());
|
|
1003
1003
|
}
|
|
1004
|
-
|
|
1004
|
+
/**
|
|
1005
|
+
* Compare 2 paths segment by segment, prioritizing numeric IDs
|
|
1006
|
+
* (e.g., "__id123__") in numeric ascending order, followed by string
|
|
1007
|
+
* segments in lexicographical order.
|
|
1008
|
+
*/ static comparator(e, t) {
|
|
1005
1009
|
const n = Math.min(e.length, t.length);
|
|
1006
1010
|
for (let r = 0; r < n; r++) {
|
|
1007
|
-
const n = e.get(r),
|
|
1008
|
-
if (
|
|
1009
|
-
if (n > i) return 1;
|
|
1011
|
+
const n = BasePath.compareSegments(e.get(r), t.get(r));
|
|
1012
|
+
if (0 !== n) return n;
|
|
1010
1013
|
}
|
|
1011
|
-
return e.length
|
|
1014
|
+
return Math.sign(e.length - t.length);
|
|
1015
|
+
}
|
|
1016
|
+
static compareSegments(e, t) {
|
|
1017
|
+
const n = BasePath.isNumericId(e), r = BasePath.isNumericId(t);
|
|
1018
|
+
return n && !r ? -1 : !n && r ? 1 : n && r ? BasePath.extractNumericId(e).compare(BasePath.extractNumericId(t)) :
|
|
1019
|
+
// both non-numeric
|
|
1020
|
+
e < t ? -1 : e > t ? 1 : 0;
|
|
1021
|
+
}
|
|
1022
|
+
// Checks if a segment is a numeric ID (starts with "__id" and ends with "__").
|
|
1023
|
+
static isNumericId(e) {
|
|
1024
|
+
return e.startsWith("__id") && e.endsWith("__");
|
|
1025
|
+
}
|
|
1026
|
+
static extractNumericId(e) {
|
|
1027
|
+
return Integer.fromString(e.substring(4, e.length - 2));
|
|
1012
1028
|
}
|
|
1013
1029
|
}
|
|
1014
1030
|
|
|
@@ -1731,7 +1747,7 @@ class __PRIVATE_SimpleDbTransaction {
|
|
|
1731
1747
|
};
|
|
1732
1748
|
}))), this.N && (this.db.onversionchange = e => this.N(e)), this.db;
|
|
1733
1749
|
}
|
|
1734
|
-
|
|
1750
|
+
B(e) {
|
|
1735
1751
|
this.N = e, this.db && (this.db.onversionchange = t => e(t));
|
|
1736
1752
|
}
|
|
1737
1753
|
async runTransaction(e, t, n, r) {
|
|
@@ -1780,7 +1796,7 @@ class __PRIVATE_SimpleDbTransaction {
|
|
|
1780
1796
|
* within the key range or index.
|
|
1781
1797
|
*/ class __PRIVATE_IterationController {
|
|
1782
1798
|
constructor(e) {
|
|
1783
|
-
this.
|
|
1799
|
+
this.L = e, this.k = !1, this.q = null;
|
|
1784
1800
|
}
|
|
1785
1801
|
get isDone() {
|
|
1786
1802
|
return this.k;
|
|
@@ -1789,7 +1805,7 @@ class __PRIVATE_SimpleDbTransaction {
|
|
|
1789
1805
|
return this.q;
|
|
1790
1806
|
}
|
|
1791
1807
|
set cursor(e) {
|
|
1792
|
-
this.
|
|
1808
|
+
this.L = e;
|
|
1793
1809
|
}
|
|
1794
1810
|
/**
|
|
1795
1811
|
* This function can be called to stop iteration at any point.
|
|
@@ -1807,7 +1823,7 @@ class __PRIVATE_SimpleDbTransaction {
|
|
|
1807
1823
|
*
|
|
1808
1824
|
* NOTE: You CANNOT do this with a keysOnly query.
|
|
1809
1825
|
*/ delete() {
|
|
1810
|
-
return __PRIVATE_wrapRequest(this.
|
|
1826
|
+
return __PRIVATE_wrapRequest(this.L.delete());
|
|
1811
1827
|
}
|
|
1812
1828
|
}
|
|
1813
1829
|
|
|
@@ -2303,7 +2319,7 @@ function __PRIVATE_newDbDocumentMutationPrefixForPath(e, t) {
|
|
|
2303
2319
|
* there is no useful information to store as the value. The raw (unencoded)
|
|
2304
2320
|
* path cannot be stored because IndexedDb doesn't store prototype
|
|
2305
2321
|
* information.
|
|
2306
|
-
*/ const x = {}, O = [ "prefixPath", "collectionGroup", "readTime", "documentId" ], N = [ "prefixPath", "collectionGroup", "documentId" ],
|
|
2322
|
+
*/ 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" ];
|
|
2307
2323
|
|
|
2308
2324
|
/**
|
|
2309
2325
|
* @license
|
|
@@ -5893,7 +5909,7 @@ class BloomFilter {
|
|
|
5893
5909
|
}
|
|
5894
5910
|
// Calculate the ith hash value based on the hashed 64bit integers,
|
|
5895
5911
|
// and calculate its corresponding bit index in the bitmap to be checked.
|
|
5896
|
-
|
|
5912
|
+
de(e, t, n) {
|
|
5897
5913
|
// Calculate hashed value h(i) = h1 + (i * h2).
|
|
5898
5914
|
let r = e.add(t.multiply(Integer.fromNumber(n)));
|
|
5899
5915
|
// Wrap if hash value overflow 64bit.
|
|
@@ -5901,7 +5917,7 @@ class BloomFilter {
|
|
|
5901
5917
|
r.modulo(this.Ie).toNumber();
|
|
5902
5918
|
}
|
|
5903
5919
|
// Return whether the bit on the given index in the bitmap is set to 1.
|
|
5904
|
-
|
|
5920
|
+
Ee(e) {
|
|
5905
5921
|
return 0 != (this.bitmap[Math.floor(e / 8)] & 1 << e % 8);
|
|
5906
5922
|
}
|
|
5907
5923
|
mightContain(e) {
|
|
@@ -5909,8 +5925,8 @@ class BloomFilter {
|
|
|
5909
5925
|
if (0 === this.Te) return !1;
|
|
5910
5926
|
const t = __PRIVATE_getMd5HashValue(e), [n, r] = __PRIVATE_get64BitUints(t);
|
|
5911
5927
|
for (let e = 0; e < this.hashCount; e++) {
|
|
5912
|
-
const t = this.
|
|
5913
|
-
if (!this.
|
|
5928
|
+
const t = this.de(n, r, e);
|
|
5929
|
+
if (!this.Ee(t)) return !1;
|
|
5914
5930
|
}
|
|
5915
5931
|
return !0;
|
|
5916
5932
|
}
|
|
@@ -5922,7 +5938,7 @@ class BloomFilter {
|
|
|
5922
5938
|
if (0 === this.Te) return;
|
|
5923
5939
|
const t = __PRIVATE_getMd5HashValue(e), [n, r] = __PRIVATE_get64BitUints(t);
|
|
5924
5940
|
for (let e = 0; e < this.hashCount; e++) {
|
|
5925
|
-
const t = this.
|
|
5941
|
+
const t = this.de(n, r, e);
|
|
5926
5942
|
this.Ae(t);
|
|
5927
5943
|
}
|
|
5928
5944
|
}
|
|
@@ -6212,9 +6228,9 @@ class __PRIVATE_WatchTargetChange {
|
|
|
6212
6228
|
*/
|
|
6213
6229
|
class __PRIVATE_WatchChangeAggregator {
|
|
6214
6230
|
constructor(e) {
|
|
6215
|
-
this.
|
|
6231
|
+
this.Be = e,
|
|
6216
6232
|
/** The internal state of all tracked targets. */
|
|
6217
|
-
this.
|
|
6233
|
+
this.Le = new Map,
|
|
6218
6234
|
/** Keeps track of the documents to update since the last raised snapshot. */
|
|
6219
6235
|
this.ke = __PRIVATE_mutableDocumentMap(), this.qe = __PRIVATE_documentTargetMap(),
|
|
6220
6236
|
/** A mapping of document keys to their set of target IDs. */
|
|
@@ -6280,7 +6296,7 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6280
6296
|
* targetIds explicitly listed in the change or the targetIds of all currently
|
|
6281
6297
|
* active targets.
|
|
6282
6298
|
*/ forEachTarget(e, t) {
|
|
6283
|
-
e.targetIds.length > 0 ? e.targetIds.forEach(t) : this.
|
|
6299
|
+
e.targetIds.length > 0 ? e.targetIds.forEach(t) : this.Le.forEach(((e, n) => {
|
|
6284
6300
|
this.je(n) && t(n);
|
|
6285
6301
|
}));
|
|
6286
6302
|
}
|
|
@@ -6350,7 +6366,7 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6350
6366
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
6351
6367
|
* See the License for the specific language governing permissions and
|
|
6352
6368
|
* limitations under the License.
|
|
6353
|
-
*/ (r, e.me, this.
|
|
6369
|
+
*/ (r, e.me, this.Be.nt(), n, i));
|
|
6354
6370
|
}
|
|
6355
6371
|
}
|
|
6356
6372
|
}
|
|
@@ -6389,10 +6405,10 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6389
6405
|
* Filter out removed documents based on bloom filter membership result and
|
|
6390
6406
|
* return number of documents removed.
|
|
6391
6407
|
*/ rt(e, t) {
|
|
6392
|
-
const n = this.
|
|
6408
|
+
const n = this.Be.getRemoteKeysForTarget(t);
|
|
6393
6409
|
let r = 0;
|
|
6394
6410
|
return n.forEach((n => {
|
|
6395
|
-
const i = this.
|
|
6411
|
+
const i = this.Be.nt(), s = `projects/${i.projectId}/databases/${i.database}/documents/${n.path.canonicalString()}`;
|
|
6396
6412
|
e.mightContain(s) || (this.We(t, n, /*updatedDocument=*/ null), r++);
|
|
6397
6413
|
})), r;
|
|
6398
6414
|
}
|
|
@@ -6401,7 +6417,7 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6401
6417
|
* provided snapshot version. Resets the accumulated changes before returning.
|
|
6402
6418
|
*/ it(e) {
|
|
6403
6419
|
const t = new Map;
|
|
6404
|
-
this.
|
|
6420
|
+
this.Le.forEach(((n, r) => {
|
|
6405
6421
|
const i = this.Ye(r);
|
|
6406
6422
|
if (i) {
|
|
6407
6423
|
if (n.current && __PRIVATE_targetIsDocumentTarget(i.target)) {
|
|
@@ -6467,7 +6483,7 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6467
6483
|
n && (this.ke = this.ke.insert(t, n));
|
|
6468
6484
|
}
|
|
6469
6485
|
removeTarget(e) {
|
|
6470
|
-
this.
|
|
6486
|
+
this.Le.delete(e);
|
|
6471
6487
|
}
|
|
6472
6488
|
/**
|
|
6473
6489
|
* Returns the current count of documents in the target. This includes both
|
|
@@ -6475,7 +6491,7 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6475
6491
|
* target as well as any accumulated changes.
|
|
6476
6492
|
*/ Ze(e) {
|
|
6477
6493
|
const t = this.ze(e).ve();
|
|
6478
|
-
return this.
|
|
6494
|
+
return this.Be.getRemoteKeysForTarget(e).size + t.addedDocuments.size - t.removedDocuments.size;
|
|
6479
6495
|
}
|
|
6480
6496
|
/**
|
|
6481
6497
|
* Increment the number of acks needed from watch before we can consider the
|
|
@@ -6484,8 +6500,8 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6484
6500
|
this.ze(e).xe();
|
|
6485
6501
|
}
|
|
6486
6502
|
ze(e) {
|
|
6487
|
-
let t = this.
|
|
6488
|
-
return t || (t = new __PRIVATE_TargetState, this.
|
|
6503
|
+
let t = this.Le.get(e);
|
|
6504
|
+
return t || (t = new __PRIVATE_TargetState, this.Le.set(e, t)), t;
|
|
6489
6505
|
}
|
|
6490
6506
|
_t(e) {
|
|
6491
6507
|
let t = this.Qe.get(e);
|
|
@@ -6510,16 +6526,16 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6510
6526
|
* Returns the TargetData for an active target (i.e. a target that the user
|
|
6511
6527
|
* is still interested in that has no outstanding target change requests).
|
|
6512
6528
|
*/ Ye(e) {
|
|
6513
|
-
const t = this.
|
|
6514
|
-
return t && t.Se ? null : this.
|
|
6529
|
+
const t = this.Le.get(e);
|
|
6530
|
+
return t && t.Se ? null : this.Be.ut(e);
|
|
6515
6531
|
}
|
|
6516
6532
|
/**
|
|
6517
6533
|
* Resets the state of a Watch target to its initial state (e.g. sets
|
|
6518
6534
|
* 'current' to false, clears the resume token and removes its target mapping
|
|
6519
6535
|
* from all documents).
|
|
6520
6536
|
*/ He(e) {
|
|
6521
|
-
this.
|
|
6522
|
-
this.
|
|
6537
|
+
this.Le.set(e, new __PRIVATE_TargetState);
|
|
6538
|
+
this.Be.getRemoteKeysForTarget(e).forEach((t => {
|
|
6523
6539
|
this.We(e, t, /*updatedDocument=*/ null);
|
|
6524
6540
|
}));
|
|
6525
6541
|
}
|
|
@@ -6527,7 +6543,7 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6527
6543
|
* Returns whether the LocalStore considers the document to be part of the
|
|
6528
6544
|
* specified target.
|
|
6529
6545
|
*/ ot(e, t) {
|
|
6530
|
-
return this.
|
|
6546
|
+
return this.Be.getRemoteKeysForTarget(e).has(t);
|
|
6531
6547
|
}
|
|
6532
6548
|
}
|
|
6533
6549
|
|
|
@@ -6545,7 +6561,7 @@ const Ie = (() => {
|
|
|
6545
6561
|
desc: "DESCENDING"
|
|
6546
6562
|
};
|
|
6547
6563
|
return e;
|
|
6548
|
-
})(),
|
|
6564
|
+
})(), de = (() => {
|
|
6549
6565
|
const e = {
|
|
6550
6566
|
"<": "LESS_THAN",
|
|
6551
6567
|
"<=": "LESS_THAN_OR_EQUAL",
|
|
@@ -6559,7 +6575,7 @@ const Ie = (() => {
|
|
|
6559
6575
|
"array-contains-any": "ARRAY_CONTAINS_ANY"
|
|
6560
6576
|
};
|
|
6561
6577
|
return e;
|
|
6562
|
-
})(),
|
|
6578
|
+
})(), Ee = (() => {
|
|
6563
6579
|
const e = {
|
|
6564
6580
|
and: "AND",
|
|
6565
6581
|
or: "OR"
|
|
@@ -7135,11 +7151,11 @@ function __PRIVATE_toDirection(e) {
|
|
|
7135
7151
|
}
|
|
7136
7152
|
|
|
7137
7153
|
function __PRIVATE_toOperatorName(e) {
|
|
7138
|
-
return
|
|
7154
|
+
return de[e];
|
|
7139
7155
|
}
|
|
7140
7156
|
|
|
7141
7157
|
function __PRIVATE_toCompositeOperatorName(e) {
|
|
7142
|
-
return
|
|
7158
|
+
return Ee[e];
|
|
7143
7159
|
}
|
|
7144
7160
|
|
|
7145
7161
|
function __PRIVATE_toFieldPathReference(e) {
|
|
@@ -7716,13 +7732,13 @@ class __PRIVATE_FirestoreIndexValueWriter {
|
|
|
7716
7732
|
// ["bar", [2, truncated("foo")]] -> (STRING, "bar", TERM, ARRAY, NUMBER, 2, STRING, "foo", TRUNC)
|
|
7717
7733
|
// ["bar", truncated(["foo"])] -> (STRING, "bar", TERM, ARRAY. STRING, "foo", TERM, TRUNC)
|
|
7718
7734
|
/** Writes an index value. */
|
|
7719
|
-
|
|
7720
|
-
this.
|
|
7735
|
+
dt(e, t) {
|
|
7736
|
+
this.Et(e, t),
|
|
7721
7737
|
// Write separator to split index values
|
|
7722
7738
|
// (see go/firestore-storage-format#encodings).
|
|
7723
7739
|
t.At();
|
|
7724
7740
|
}
|
|
7725
|
-
|
|
7741
|
+
Et(e, t) {
|
|
7726
7742
|
if ("nullValue" in e) this.Rt(t, 5); else if ("booleanValue" in e) this.Rt(t, 10),
|
|
7727
7743
|
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) {
|
|
7728
7744
|
const n = __PRIVATE_normalizeNumber(e.doubleValue);
|
|
@@ -7749,7 +7765,7 @@ class __PRIVATE_FirestoreIndexValueWriter {
|
|
|
7749
7765
|
Dt(e, t) {
|
|
7750
7766
|
const n = e.fields || {};
|
|
7751
7767
|
this.Rt(t, 55);
|
|
7752
|
-
for (const e of Object.keys(n)) this.gt(e, t), this.
|
|
7768
|
+
for (const e of Object.keys(n)) this.gt(e, t), this.Et(n[e], t);
|
|
7753
7769
|
}
|
|
7754
7770
|
bt(e, t) {
|
|
7755
7771
|
var n, r;
|
|
@@ -7759,12 +7775,12 @@ class __PRIVATE_FirestoreIndexValueWriter {
|
|
|
7759
7775
|
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;
|
|
7760
7776
|
this.Rt(t, 15), t.Vt(__PRIVATE_normalizeNumber(o)),
|
|
7761
7777
|
// Vectors then sort by position value
|
|
7762
|
-
this.gt(s, t), this.
|
|
7778
|
+
this.gt(s, t), this.Et(i[s], t);
|
|
7763
7779
|
}
|
|
7764
7780
|
vt(e, t) {
|
|
7765
7781
|
const n = e.values || [];
|
|
7766
7782
|
this.Rt(t, 50);
|
|
7767
|
-
for (const e of n) this.
|
|
7783
|
+
for (const e of n) this.Et(e, t);
|
|
7768
7784
|
}
|
|
7769
7785
|
St(e, t) {
|
|
7770
7786
|
this.Rt(t, 37);
|
|
@@ -7838,8 +7854,8 @@ function __PRIVATE_unsignedNumLength(e) {
|
|
|
7838
7854
|
Nt(e) {
|
|
7839
7855
|
const t = e[Symbol.iterator]();
|
|
7840
7856
|
let n = t.next();
|
|
7841
|
-
for (;!n.done; ) this.
|
|
7842
|
-
this.
|
|
7857
|
+
for (;!n.done; ) this.Bt(n.value), n = t.next();
|
|
7858
|
+
this.Lt();
|
|
7843
7859
|
}
|
|
7844
7860
|
/** Writes utf8 bytes into this byte sequence, ascending. */ kt(e) {
|
|
7845
7861
|
for (const t of e) {
|
|
@@ -7856,14 +7872,14 @@ function __PRIVATE_unsignedNumLength(e) {
|
|
|
7856
7872
|
/** Writes utf8 bytes into this byte sequence, descending */ qt(e) {
|
|
7857
7873
|
for (const t of e) {
|
|
7858
7874
|
const e = t.charCodeAt(0);
|
|
7859
|
-
if (e < 128) this.
|
|
7860
|
-
this.
|
|
7875
|
+
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),
|
|
7876
|
+
this.Bt(128 | 63 & e >>> 6), this.Bt(128 | 63 & e); else {
|
|
7861
7877
|
const e = t.codePointAt(0);
|
|
7862
|
-
this.
|
|
7863
|
-
this.
|
|
7878
|
+
this.Bt(240 | e >>> 18), this.Bt(128 | 63 & e >>> 12), this.Bt(128 | 63 & e >>> 6),
|
|
7879
|
+
this.Bt(128 | 63 & e);
|
|
7864
7880
|
}
|
|
7865
7881
|
}
|
|
7866
|
-
this.
|
|
7882
|
+
this.Lt();
|
|
7867
7883
|
}
|
|
7868
7884
|
Qt(e) {
|
|
7869
7885
|
// Values are encoded with a single byte length prefix, followed by the
|
|
@@ -7929,14 +7945,14 @@ function __PRIVATE_unsignedNumLength(e) {
|
|
|
7929
7945
|
const t = 255 & e;
|
|
7930
7946
|
0 === t ? (this.Gt(0), this.Gt(255)) : 255 === t ? (this.Gt(255), this.Gt(0)) : this.Gt(t);
|
|
7931
7947
|
}
|
|
7932
|
-
/** Writes a single byte descending to the buffer. */
|
|
7948
|
+
/** Writes a single byte descending to the buffer. */ Bt(e) {
|
|
7933
7949
|
const t = 255 & e;
|
|
7934
7950
|
0 === t ? (this.jt(0), this.jt(255)) : 255 === t ? (this.jt(255), this.jt(0)) : this.jt(e);
|
|
7935
7951
|
}
|
|
7936
7952
|
Ot() {
|
|
7937
7953
|
this.Gt(0), this.Gt(1);
|
|
7938
7954
|
}
|
|
7939
|
-
|
|
7955
|
+
Lt() {
|
|
7940
7956
|
this.jt(0), this.jt(1);
|
|
7941
7957
|
}
|
|
7942
7958
|
Gt(e) {
|
|
@@ -8688,7 +8704,7 @@ class __PRIVATE_IndexedDbIndexManager {
|
|
|
8688
8704
|
n.push(t.value), r && (r = t.inclusive);
|
|
8689
8705
|
}
|
|
8690
8706
|
return new Bound(n, r);
|
|
8691
|
-
}(s, i), c = this.
|
|
8707
|
+
}(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);
|
|
8692
8708
|
return PersistencePromise.forEach(P, (i => n.G(i, t.limit).next((t => {
|
|
8693
8709
|
t.forEach((t => {
|
|
8694
8710
|
const n = DocumentKey.fromSegments(t.documentKey);
|
|
@@ -8782,13 +8798,13 @@ class __PRIVATE_IndexedDbIndexManager {
|
|
|
8782
8798
|
const e = t.data.field(r.fieldPath);
|
|
8783
8799
|
if (null == e) return null;
|
|
8784
8800
|
const i = n.Xt(r.kind);
|
|
8785
|
-
__PRIVATE_FirestoreIndexValueWriter.Ft.
|
|
8801
|
+
__PRIVATE_FirestoreIndexValueWriter.Ft.dt(e, i);
|
|
8786
8802
|
}
|
|
8787
8803
|
return n.Ht();
|
|
8788
8804
|
}
|
|
8789
8805
|
/** Encodes a single value to the ascending index format. */ Rn(e) {
|
|
8790
8806
|
const t = new __PRIVATE_IndexByteEncoder;
|
|
8791
|
-
return __PRIVATE_FirestoreIndexValueWriter.Ft.
|
|
8807
|
+
return __PRIVATE_FirestoreIndexValueWriter.Ft.dt(e, t.Xt(0 /* IndexKind.ASCENDING */)),
|
|
8792
8808
|
t.Ht();
|
|
8793
8809
|
}
|
|
8794
8810
|
/**
|
|
@@ -8796,7 +8812,7 @@ class __PRIVATE_IndexedDbIndexManager {
|
|
|
8796
8812
|
* ordering of the field index.
|
|
8797
8813
|
*/ gn(e, t) {
|
|
8798
8814
|
const n = new __PRIVATE_IndexByteEncoder;
|
|
8799
|
-
return __PRIVATE_FirestoreIndexValueWriter.Ft.
|
|
8815
|
+
return __PRIVATE_FirestoreIndexValueWriter.Ft.dt(__PRIVATE_refValue(this.databaseId, t), n.Xt(function __PRIVATE_fieldIndexGetKeyOrder(e) {
|
|
8800
8816
|
const t = __PRIVATE_fieldIndexGetDirectionalSegments(e);
|
|
8801
8817
|
return 0 === t.length ? 0 /* IndexKind.ASCENDING */ : t[t.length - 1].kind;
|
|
8802
8818
|
}(e))), n.Ht();
|
|
@@ -8804,7 +8820,7 @@ class __PRIVATE_IndexedDbIndexManager {
|
|
|
8804
8820
|
/**
|
|
8805
8821
|
* Encodes the given field values according to the specification in `target`.
|
|
8806
8822
|
* For IN queries, a list of possible values is returned.
|
|
8807
|
-
*/
|
|
8823
|
+
*/ En(e, t, n) {
|
|
8808
8824
|
if (null === n) return [];
|
|
8809
8825
|
let r = [];
|
|
8810
8826
|
r.push(new __PRIVATE_IndexByteEncoder);
|
|
@@ -8813,7 +8829,7 @@ class __PRIVATE_IndexedDbIndexManager {
|
|
|
8813
8829
|
const e = n[i++];
|
|
8814
8830
|
for (const n of r) if (this.pn(t, s.fieldPath) && isArray(e)) r = this.yn(r, s, e); else {
|
|
8815
8831
|
const t = n.Xt(s.kind);
|
|
8816
|
-
__PRIVATE_FirestoreIndexValueWriter.Ft.
|
|
8832
|
+
__PRIVATE_FirestoreIndexValueWriter.Ft.dt(e, t);
|
|
8817
8833
|
}
|
|
8818
8834
|
}
|
|
8819
8835
|
return this.wn(r);
|
|
@@ -8821,8 +8837,8 @@ class __PRIVATE_IndexedDbIndexManager {
|
|
|
8821
8837
|
/**
|
|
8822
8838
|
* Encodes the given bounds according to the specification in `target`. For IN
|
|
8823
8839
|
* queries, a list of possible values is returned.
|
|
8824
|
-
*/
|
|
8825
|
-
return this.
|
|
8840
|
+
*/ dn(e, t, n) {
|
|
8841
|
+
return this.En(e, t, n.position);
|
|
8826
8842
|
}
|
|
8827
8843
|
/** Returns the byte representation for the provided encoders. */ wn(e) {
|
|
8828
8844
|
const t = [];
|
|
@@ -8839,7 +8855,7 @@ class __PRIVATE_IndexedDbIndexManager {
|
|
|
8839
8855
|
const r = [ ...e ], i = [];
|
|
8840
8856
|
for (const e of n.arrayValue.values || []) for (const n of r) {
|
|
8841
8857
|
const r = new __PRIVATE_IndexByteEncoder;
|
|
8842
|
-
r.seed(n.Ht()), __PRIVATE_FirestoreIndexValueWriter.Ft.
|
|
8858
|
+
r.seed(n.Ht()), __PRIVATE_FirestoreIndexValueWriter.Ft.dt(e, r.Xt(t.kind)), i.push(r);
|
|
8843
8859
|
}
|
|
8844
8860
|
return i;
|
|
8845
8861
|
}
|
|
@@ -9352,7 +9368,7 @@ class __PRIVATE_IndexedDbMutationQueue {
|
|
|
9352
9368
|
}
|
|
9353
9369
|
removeMutationBatch(e, t) {
|
|
9354
9370
|
return removeMutationBatch(e._e, this.userId, t).next((n => (e.addOnCommittedListener((() => {
|
|
9355
|
-
this.
|
|
9371
|
+
this.Bn(t.batchId);
|
|
9356
9372
|
})), PersistencePromise.forEach(n, (t => this.referenceDelegate.markPotentiallyOrphaned(e, t))))));
|
|
9357
9373
|
}
|
|
9358
9374
|
/**
|
|
@@ -9364,7 +9380,7 @@ class __PRIVATE_IndexedDbMutationQueue {
|
|
|
9364
9380
|
* rejected batch is removed from the mutation queue.
|
|
9365
9381
|
*/
|
|
9366
9382
|
// PORTING NOTE: Multi-tab only
|
|
9367
|
-
|
|
9383
|
+
Bn(e) {
|
|
9368
9384
|
delete this.xn[e];
|
|
9369
9385
|
}
|
|
9370
9386
|
performConsistencyCheck(e) {
|
|
@@ -9397,7 +9413,7 @@ class __PRIVATE_IndexedDbMutationQueue {
|
|
|
9397
9413
|
}
|
|
9398
9414
|
// PORTING NOTE: Multi-tab only (state is held in memory in other clients).
|
|
9399
9415
|
/** Returns the mutation queue's metadata from IndexedDb. */
|
|
9400
|
-
|
|
9416
|
+
Ln(e) {
|
|
9401
9417
|
return __PRIVATE_mutationQueuesStore(e).get(this.userId).next((e => e || {
|
|
9402
9418
|
userId: this.userId,
|
|
9403
9419
|
lastAcknowledgedBatchId: -1,
|
|
@@ -10738,7 +10754,7 @@ class OverlayedDocument {
|
|
|
10738
10754
|
constructor() {
|
|
10739
10755
|
// A map sorted by DocumentKey, whose value is a pair of the largest batch id
|
|
10740
10756
|
// for the overlay and the overlay itself.
|
|
10741
|
-
this.overlays = new SortedMap(DocumentKey.comparator), this.
|
|
10757
|
+
this.overlays = new SortedMap(DocumentKey.comparator), this.dr = new Map;
|
|
10742
10758
|
}
|
|
10743
10759
|
getOverlay(e, t) {
|
|
10744
10760
|
return PersistencePromise.resolve(this.overlays.get(t));
|
|
@@ -10755,9 +10771,9 @@ class OverlayedDocument {
|
|
|
10755
10771
|
})), PersistencePromise.resolve();
|
|
10756
10772
|
}
|
|
10757
10773
|
removeOverlaysForBatchId(e, t, n) {
|
|
10758
|
-
const r = this.
|
|
10774
|
+
const r = this.dr.get(n);
|
|
10759
10775
|
return void 0 !== r && (r.forEach((e => this.overlays = this.overlays.remove(e))),
|
|
10760
|
-
this.
|
|
10776
|
+
this.dr.delete(n)), PersistencePromise.resolve();
|
|
10761
10777
|
}
|
|
10762
10778
|
getOverlaysForCollection(e, t, n) {
|
|
10763
10779
|
const r = __PRIVATE_newOverlayMap(), i = t.length + 1, s = new DocumentKey(t.child("")), o = this.overlays.getIteratorFrom(s);
|
|
@@ -10790,13 +10806,13 @@ class OverlayedDocument {
|
|
|
10790
10806
|
// Remove the association of the overlay to its batch id.
|
|
10791
10807
|
const r = this.overlays.get(n.key);
|
|
10792
10808
|
if (null !== r) {
|
|
10793
|
-
const e = this.
|
|
10794
|
-
this.
|
|
10809
|
+
const e = this.dr.get(r.largestBatchId).delete(n.key);
|
|
10810
|
+
this.dr.set(r.largestBatchId, e);
|
|
10795
10811
|
}
|
|
10796
10812
|
this.overlays = this.overlays.insert(n.key, new Overlay(t, n));
|
|
10797
10813
|
// Create the association of this overlay to the given largestBatchId.
|
|
10798
|
-
let i = this.
|
|
10799
|
-
void 0 === i && (i = __PRIVATE_documentKeySet(), this.
|
|
10814
|
+
let i = this.dr.get(t);
|
|
10815
|
+
void 0 === i && (i = __PRIVATE_documentKeySet(), this.dr.set(t, i)), this.dr.set(t, i.add(n.key));
|
|
10800
10816
|
}
|
|
10801
10817
|
}
|
|
10802
10818
|
|
|
@@ -10860,16 +10876,16 @@ class OverlayedDocument {
|
|
|
10860
10876
|
*/ class __PRIVATE_ReferenceSet {
|
|
10861
10877
|
constructor() {
|
|
10862
10878
|
// A set of outstanding references to a document sorted by key.
|
|
10863
|
-
this.
|
|
10879
|
+
this.Er = new SortedSet(__PRIVATE_DocReference.Ar),
|
|
10864
10880
|
// A set of outstanding references to a document sorted by target id.
|
|
10865
10881
|
this.Rr = new SortedSet(__PRIVATE_DocReference.Vr);
|
|
10866
10882
|
}
|
|
10867
10883
|
/** Returns true if the reference set contains no references. */ isEmpty() {
|
|
10868
|
-
return this.
|
|
10884
|
+
return this.Er.isEmpty();
|
|
10869
10885
|
}
|
|
10870
10886
|
/** Adds a reference to the given document key for the given ID. */ addReference(e, t) {
|
|
10871
10887
|
const n = new __PRIVATE_DocReference(e, t);
|
|
10872
|
-
this.
|
|
10888
|
+
this.Er = this.Er.add(n), this.Rr = this.Rr.add(n);
|
|
10873
10889
|
}
|
|
10874
10890
|
/** Add references to the given document keys for the given ID. */ mr(e, t) {
|
|
10875
10891
|
e.forEach((e => this.addReference(e, t)));
|
|
@@ -10893,10 +10909,10 @@ class OverlayedDocument {
|
|
|
10893
10909
|
})), i;
|
|
10894
10910
|
}
|
|
10895
10911
|
wr() {
|
|
10896
|
-
this.
|
|
10912
|
+
this.Er.forEach((e => this.gr(e)));
|
|
10897
10913
|
}
|
|
10898
10914
|
gr(e) {
|
|
10899
|
-
this.
|
|
10915
|
+
this.Er = this.Er.delete(e), this.Rr = this.Rr.delete(e);
|
|
10900
10916
|
}
|
|
10901
10917
|
Sr(e) {
|
|
10902
10918
|
const t = new DocumentKey(new ResourcePath([])), n = new __PRIVATE_DocReference(t, e), r = new __PRIVATE_DocReference(t, e + 1);
|
|
@@ -10906,7 +10922,7 @@ class OverlayedDocument {
|
|
|
10906
10922
|
})), i;
|
|
10907
10923
|
}
|
|
10908
10924
|
containsKey(e) {
|
|
10909
|
-
const t = new __PRIVATE_DocReference(e, 0), n = this.
|
|
10925
|
+
const t = new __PRIVATE_DocReference(e, 0), n = this.Er.firstAfterOrEqual(t);
|
|
10910
10926
|
return null !== n && e.isEqual(n.key);
|
|
10911
10927
|
}
|
|
10912
10928
|
}
|
|
@@ -11039,7 +11055,7 @@ class __PRIVATE_DocReference {
|
|
|
11039
11055
|
this.vr = n;
|
|
11040
11056
|
}));
|
|
11041
11057
|
}
|
|
11042
|
-
|
|
11058
|
+
Bn(e) {
|
|
11043
11059
|
// No-op since the memory mutation queue does not maintain a separate cache.
|
|
11044
11060
|
}
|
|
11045
11061
|
containsKey(e, t) {
|
|
@@ -11103,6 +11119,9 @@ class __PRIVATE_DocReference {
|
|
|
11103
11119
|
* See the License for the specific language governing permissions and
|
|
11104
11120
|
* limitations under the License.
|
|
11105
11121
|
*/
|
|
11122
|
+
/**
|
|
11123
|
+
* The smallest value representable by a 64-bit signed integer (long).
|
|
11124
|
+
*/
|
|
11106
11125
|
/**
|
|
11107
11126
|
* The memory-only RemoteDocumentCache for IndexedDb. To construct, invoke
|
|
11108
11127
|
* `newMemoryRemoteDocumentCache()`.
|
|
@@ -11161,8 +11180,11 @@ class __PRIVATE_MemoryRemoteDocumentCacheImpl {
|
|
|
11161
11180
|
let i = __PRIVATE_mutableDocumentMap();
|
|
11162
11181
|
// Documents are ordered by key, so we can use a prefix scan to narrow down
|
|
11163
11182
|
// the documents we need to match the query against.
|
|
11164
|
-
const s = t.path, o = new DocumentKey(s.child("")), _ = this.docs.getIteratorFrom(o);
|
|
11165
|
-
|
|
11183
|
+
const s = t.path, o = new DocumentKey(s.child("__id-9223372036854775808__")), _ = this.docs.getIteratorFrom(o);
|
|
11184
|
+
// Document keys are ordered first by numeric value ("__id<Long>__"),
|
|
11185
|
+
// then lexicographically by string value. Start the iterator at the minimum
|
|
11186
|
+
// possible Document key value.
|
|
11187
|
+
for (;_.hasNext(); ) {
|
|
11166
11188
|
const {key: e, value: {document: o}} = _.getNext();
|
|
11167
11189
|
if (!s.isPrefixOf(e.path)) break;
|
|
11168
11190
|
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())));
|
|
@@ -11174,7 +11196,7 @@ class __PRIVATE_MemoryRemoteDocumentCacheImpl {
|
|
|
11174
11196
|
// is enabled.
|
|
11175
11197
|
fail();
|
|
11176
11198
|
}
|
|
11177
|
-
|
|
11199
|
+
Br(e, t) {
|
|
11178
11200
|
return PersistencePromise.forEach(this.docs, (e => t(e)));
|
|
11179
11201
|
}
|
|
11180
11202
|
newChangeBuffer(e) {
|
|
@@ -11236,7 +11258,7 @@ class __PRIVATE_MemoryRemoteDocumentChangeBuffer extends RemoteDocumentChangeBuf
|
|
|
11236
11258
|
/**
|
|
11237
11259
|
* Maps a target to the data about that target
|
|
11238
11260
|
*/
|
|
11239
|
-
this.
|
|
11261
|
+
this.Lr = new ObjectMap((e => __PRIVATE_canonifyTarget(e)), __PRIVATE_targetEquals),
|
|
11240
11262
|
/** The last received snapshot version. */
|
|
11241
11263
|
this.lastRemoteSnapshotVersion = SnapshotVersion.min(),
|
|
11242
11264
|
/** The highest numbered target ID encountered. */
|
|
@@ -11250,7 +11272,7 @@ class __PRIVATE_MemoryRemoteDocumentChangeBuffer extends RemoteDocumentChangeBuf
|
|
|
11250
11272
|
this.qr = new __PRIVATE_ReferenceSet, this.targetCount = 0, this.Qr = __PRIVATE_TargetIdGenerator.qn();
|
|
11251
11273
|
}
|
|
11252
11274
|
forEachTarget(e, t) {
|
|
11253
|
-
return this.
|
|
11275
|
+
return this.Lr.forEach(((e, n) => t(n))), PersistencePromise.resolve();
|
|
11254
11276
|
}
|
|
11255
11277
|
getLastRemoteSnapshotVersion(e) {
|
|
11256
11278
|
return PersistencePromise.resolve(this.lastRemoteSnapshotVersion);
|
|
@@ -11266,7 +11288,7 @@ class __PRIVATE_MemoryRemoteDocumentChangeBuffer extends RemoteDocumentChangeBuf
|
|
|
11266
11288
|
PersistencePromise.resolve();
|
|
11267
11289
|
}
|
|
11268
11290
|
Un(e) {
|
|
11269
|
-
this.
|
|
11291
|
+
this.Lr.set(e.target, e);
|
|
11270
11292
|
const t = e.targetId;
|
|
11271
11293
|
t > this.highestTargetId && (this.Qr = new __PRIVATE_TargetIdGenerator(t), this.highestTargetId = t),
|
|
11272
11294
|
e.sequenceNumber > this.kr && (this.kr = e.sequenceNumber);
|
|
@@ -11278,14 +11300,14 @@ class __PRIVATE_MemoryRemoteDocumentChangeBuffer extends RemoteDocumentChangeBuf
|
|
|
11278
11300
|
return this.Un(t), PersistencePromise.resolve();
|
|
11279
11301
|
}
|
|
11280
11302
|
removeTargetData(e, t) {
|
|
11281
|
-
return this.
|
|
11303
|
+
return this.Lr.delete(t.target), this.qr.yr(t.targetId), this.targetCount -= 1,
|
|
11282
11304
|
PersistencePromise.resolve();
|
|
11283
11305
|
}
|
|
11284
11306
|
removeTargets(e, t, n) {
|
|
11285
11307
|
let r = 0;
|
|
11286
11308
|
const i = [];
|
|
11287
|
-
return this.
|
|
11288
|
-
o.sequenceNumber <= t && null === n.get(o.targetId) && (this.
|
|
11309
|
+
return this.Lr.forEach(((s, o) => {
|
|
11310
|
+
o.sequenceNumber <= t && null === n.get(o.targetId) && (this.Lr.delete(s), i.push(this.removeMatchingKeysForTargetId(e, o.targetId)),
|
|
11289
11311
|
r++);
|
|
11290
11312
|
})), PersistencePromise.waitFor(i).next((() => r));
|
|
11291
11313
|
}
|
|
@@ -11293,7 +11315,7 @@ class __PRIVATE_MemoryRemoteDocumentChangeBuffer extends RemoteDocumentChangeBuf
|
|
|
11293
11315
|
return PersistencePromise.resolve(this.targetCount);
|
|
11294
11316
|
}
|
|
11295
11317
|
getTargetData(e, t) {
|
|
11296
|
-
const n = this.
|
|
11318
|
+
const n = this.Lr.get(t) || null;
|
|
11297
11319
|
return PersistencePromise.resolve(n);
|
|
11298
11320
|
}
|
|
11299
11321
|
addMatchingKeys(e, t, n) {
|
|
@@ -11511,7 +11533,7 @@ class __PRIVATE_MemoryLruDelegate {
|
|
|
11511
11533
|
removeOrphanedDocuments(e, t) {
|
|
11512
11534
|
let n = 0;
|
|
11513
11535
|
const r = this.persistence.getRemoteDocumentCache(), i = r.newChangeBuffer();
|
|
11514
|
-
return r.
|
|
11536
|
+
return r.Br(e, (r => this.ir(e, r, t).next((e => {
|
|
11515
11537
|
e || (n++, i.removeEntry(r, SnapshotVersion.min()));
|
|
11516
11538
|
})))).next((() => i.apply(e))).next((() => n));
|
|
11517
11539
|
}
|
|
@@ -11677,7 +11699,7 @@ class __PRIVATE_MemoryLruDelegate {
|
|
|
11677
11699
|
const t = e.createObjectStore("remoteDocumentsV14", {
|
|
11678
11700
|
keyPath: O
|
|
11679
11701
|
});
|
|
11680
|
-
t.createIndex("documentKeyIndex", N), t.createIndex("collectionGroupIndex",
|
|
11702
|
+
t.createIndex("documentKeyIndex", N), t.createIndex("collectionGroupIndex", B);
|
|
11681
11703
|
}(e))).next((() => this.ui(e, i))).next((() => e.deleteObjectStore("remoteDocuments")))),
|
|
11682
11704
|
n < 14 && r >= 14 && (s = s.next((() => this.ci(e, i)))), n < 15 && r >= 15 && (s = s.next((() => function __PRIVATE_createFieldIndex(e) {
|
|
11683
11705
|
e.createObjectStore("indexConfiguration", {
|
|
@@ -11846,7 +11868,7 @@ function __PRIVATE_createQueryCache(e) {
|
|
|
11846
11868
|
// NOTE: This is unique only because the TargetId is the suffix.
|
|
11847
11869
|
e.createObjectStore("targets", {
|
|
11848
11870
|
keyPath: "targetId"
|
|
11849
|
-
}).createIndex("queryTargetsIndex",
|
|
11871
|
+
}).createIndex("queryTargetsIndex", L, {
|
|
11850
11872
|
unique: !0
|
|
11851
11873
|
}), e.createObjectStore("targetGlobal");
|
|
11852
11874
|
}
|
|
@@ -11921,9 +11943,9 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
11921
11943
|
/** Our window.unload handler, if registered. */
|
|
11922
11944
|
this.Ii = null, this.inForeground = !1,
|
|
11923
11945
|
/** Our 'visibilitychange' listener if registered. */
|
|
11924
|
-
this.Ei = null,
|
|
11925
|
-
/** The client metadata refresh task. */
|
|
11926
11946
|
this.di = null,
|
|
11947
|
+
/** The client metadata refresh task. */
|
|
11948
|
+
this.Ei = null,
|
|
11927
11949
|
/** The last time we garbage collected the client metadata object store. */
|
|
11928
11950
|
this.Ai = Number.NEGATIVE_INFINITY,
|
|
11929
11951
|
/** A listener to notify on primary state changes. */
|
|
@@ -11972,7 +11994,7 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
11972
11994
|
*
|
|
11973
11995
|
* PORTING NOTE: This is only used for Web multi-tab.
|
|
11974
11996
|
*/ setDatabaseDeletedListener(e) {
|
|
11975
|
-
this.mi.
|
|
11997
|
+
this.mi.B((async t => {
|
|
11976
11998
|
// Check if an attempt is made to delete IndexedDB.
|
|
11977
11999
|
null === t.newVersion && await e();
|
|
11978
12000
|
}));
|
|
@@ -12044,14 +12066,14 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12044
12066
|
// Ideally we'd delete the IndexedDb and LocalStorage zombie entries for
|
|
12045
12067
|
// the client atomically, but we can't. So we opt to delete the IndexedDb
|
|
12046
12068
|
// entries first to avoid potentially reviving a zombied client.
|
|
12047
|
-
if (this.fi) for (const t of e) this.fi.removeItem(this.
|
|
12069
|
+
if (this.fi) for (const t of e) this.fi.removeItem(this.Bi(t.clientId));
|
|
12048
12070
|
}
|
|
12049
12071
|
}
|
|
12050
12072
|
/**
|
|
12051
12073
|
* Schedules a recurring timer to update the client metadata and to either
|
|
12052
12074
|
* extend or acquire the primary lease if the client is eligible.
|
|
12053
12075
|
*/ wi() {
|
|
12054
|
-
this.
|
|
12076
|
+
this.Ei = this.li.enqueueAfterDelay("client_metadata_refresh" /* TimerId.ClientMetadataRefresh */ , 4e3, (() => this.gi().then((() => this.xi())).then((() => this.wi()))));
|
|
12055
12077
|
}
|
|
12056
12078
|
/** Checks whether `client` is the local client. */ Fi(e) {
|
|
12057
12079
|
return !!e && e.ownerId === this.clientId;
|
|
@@ -12074,7 +12096,7 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12074
12096
|
// - every clients network is disabled and no other client's tab is in
|
|
12075
12097
|
// the foreground.
|
|
12076
12098
|
// - the `forceOwningTab` setting was passed in.
|
|
12077
|
-
if (null !== t && this.Oi(t.leaseTimestampMs, 5e3) && !this.
|
|
12099
|
+
if (null !== t && this.Oi(t.leaseTimestampMs, 5e3) && !this.Li(t.ownerId)) {
|
|
12078
12100
|
if (this.Fi(t) && this.networkEnabled) return !0;
|
|
12079
12101
|
if (!this.Fi(t)) {
|
|
12080
12102
|
if (!t.allowTabSynchronization)
|
|
@@ -12106,7 +12128,7 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12106
12128
|
async shutdown() {
|
|
12107
12129
|
// The shutdown() operations are idempotent and can be called even when
|
|
12108
12130
|
// start() aborted (e.g. because it couldn't acquire the persistence lease).
|
|
12109
|
-
this.Ur = !1, this.ki(), this.
|
|
12131
|
+
this.Ur = !1, this.ki(), this.Ei && (this.Ei.cancel(), this.Ei = null), this.qi(),
|
|
12110
12132
|
this.Qi(),
|
|
12111
12133
|
// Use `SimpleDb.runTransaction` directly to avoid failing if another tab
|
|
12112
12134
|
// has obtained the primary lease.
|
|
@@ -12122,7 +12144,7 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12122
12144
|
* Returns clients that are not zombied and have an updateTime within the
|
|
12123
12145
|
* provided threshold.
|
|
12124
12146
|
*/ Ni(e, t) {
|
|
12125
|
-
return e.filter((e => this.Oi(e.updateTimeMs, t) && !this.
|
|
12147
|
+
return e.filter((e => this.Oi(e.updateTimeMs, t) && !this.Li(e.clientId)));
|
|
12126
12148
|
}
|
|
12127
12149
|
/**
|
|
12128
12150
|
* Returns the IDs of the clients that are currently active. If multi-tab
|
|
@@ -12183,7 +12205,7 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12183
12205
|
// be turned off.
|
|
12184
12206
|
Ui(e) {
|
|
12185
12207
|
return __PRIVATE_primaryClientStore(e).get("owner").next((e => {
|
|
12186
|
-
if (null !== e && this.Oi(e.leaseTimestampMs, 5e3) && !this.
|
|
12208
|
+
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);
|
|
12187
12209
|
}));
|
|
12188
12210
|
}
|
|
12189
12211
|
/**
|
|
@@ -12211,13 +12233,13 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12211
12233
|
!1));
|
|
12212
12234
|
}
|
|
12213
12235
|
pi() {
|
|
12214
|
-
null !== this.document && "function" == typeof this.document.addEventListener && (this.
|
|
12236
|
+
null !== this.document && "function" == typeof this.document.addEventListener && (this.di = () => {
|
|
12215
12237
|
this.li.enqueueAndForget((() => (this.inForeground = "visible" === this.document.visibilityState,
|
|
12216
12238
|
this.gi())));
|
|
12217
|
-
}, this.document.addEventListener("visibilitychange", this.
|
|
12239
|
+
}, this.document.addEventListener("visibilitychange", this.di), this.inForeground = "visible" === this.document.visibilityState);
|
|
12218
12240
|
}
|
|
12219
12241
|
qi() {
|
|
12220
|
-
this.
|
|
12242
|
+
this.di && (this.document.removeEventListener("visibilitychange", this.di), this.di = null);
|
|
12221
12243
|
}
|
|
12222
12244
|
/**
|
|
12223
12245
|
* Attaches a window.unload handler that will synchronously write our
|
|
@@ -12251,10 +12273,10 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12251
12273
|
* Returns whether a client is "zombied" based on its LocalStorage entry.
|
|
12252
12274
|
* Clients become zombied when their tab closes without running all of the
|
|
12253
12275
|
* cleanup logic in `shutdown()`.
|
|
12254
|
-
*/
|
|
12276
|
+
*/ Li(e) {
|
|
12255
12277
|
var t;
|
|
12256
12278
|
try {
|
|
12257
|
-
const n = null !== (null === (t = this.fi) || void 0 === t ? void 0 : t.getItem(this.
|
|
12279
|
+
const n = null !== (null === (t = this.fi) || void 0 === t ? void 0 : t.getItem(this.Bi(e)));
|
|
12258
12280
|
return __PRIVATE_logDebug("IndexedDbPersistence", `Client '${e}' ${n ? "is" : "is not"} zombied in LocalStorage`),
|
|
12259
12281
|
n;
|
|
12260
12282
|
} catch (e) {
|
|
@@ -12268,7 +12290,7 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12268
12290
|
* clients are ignored during primary tab selection.
|
|
12269
12291
|
*/ ki() {
|
|
12270
12292
|
if (this.fi) try {
|
|
12271
|
-
this.fi.setItem(this.
|
|
12293
|
+
this.fi.setItem(this.Bi(this.clientId), String(Date.now()));
|
|
12272
12294
|
} catch (e) {
|
|
12273
12295
|
// Gracefully handle if LocalStorage isn't available / working.
|
|
12274
12296
|
__PRIVATE_logError("Failed to set zombie client id.", e);
|
|
@@ -12276,12 +12298,12 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12276
12298
|
}
|
|
12277
12299
|
/** Removes the zombied client entry if it exists. */ Ki() {
|
|
12278
12300
|
if (this.fi) try {
|
|
12279
|
-
this.fi.removeItem(this.
|
|
12301
|
+
this.fi.removeItem(this.Bi(this.clientId));
|
|
12280
12302
|
} catch (e) {
|
|
12281
12303
|
// Ignore
|
|
12282
12304
|
}
|
|
12283
12305
|
}
|
|
12284
|
-
|
|
12306
|
+
Bi(e) {
|
|
12285
12307
|
return `firestore_zombie_${this.persistenceKey}_${e}`;
|
|
12286
12308
|
}
|
|
12287
12309
|
}
|
|
@@ -12821,7 +12843,7 @@ function __PRIVATE_localStoreGetLastRemoteSnapshotVersion(e) {
|
|
|
12821
12843
|
// Each loop iteration only affects its "own" doc, so it's safe to get all
|
|
12822
12844
|
// the remote documents in advance in a single call.
|
|
12823
12845
|
o.push(__PRIVATE_populateDocumentChangeBuffer(e, s, t.documentUpdates).next((e => {
|
|
12824
|
-
_ = e.Is, a = e.
|
|
12846
|
+
_ = e.Is, a = e.ds;
|
|
12825
12847
|
}))), !r.isEqual(SnapshotVersion.min())) {
|
|
12826
12848
|
const t = n.Gr.getLastRemoteSnapshotVersion(e).next((t => n.Gr.setTargetsMetadata(e, e.currentSequenceNumber, r)));
|
|
12827
12849
|
o.push(t);
|
|
@@ -12859,7 +12881,7 @@ function __PRIVATE_localStoreGetLastRemoteSnapshotVersion(e) {
|
|
|
12859
12881
|
r = r.insert(n, s)) : __PRIVATE_logDebug("LocalStore", "Ignoring outdated watch update for ", n, ". Current version:", o.version, " Watch version:", s.version);
|
|
12860
12882
|
})), {
|
|
12861
12883
|
Is: r,
|
|
12862
|
-
|
|
12884
|
+
ds: i
|
|
12863
12885
|
};
|
|
12864
12886
|
}));
|
|
12865
12887
|
}
|
|
@@ -12958,7 +12980,7 @@ async function __PRIVATE_localStoreReleaseTarget(e, t, n) {
|
|
|
12958
12980
|
})).next((() => r._s.getDocumentsMatchingQuery(e, t, n ? i : SnapshotVersion.min(), n ? s : __PRIVATE_documentKeySet()))).next((e => (__PRIVATE_setMaxReadTime(r, __PRIVATE_queryCollectionGroup(t), e),
|
|
12959
12981
|
{
|
|
12960
12982
|
documents: e,
|
|
12961
|
-
|
|
12983
|
+
Es: s
|
|
12962
12984
|
})))));
|
|
12963
12985
|
}
|
|
12964
12986
|
|
|
@@ -13027,7 +13049,7 @@ async function __PRIVATE_localStoreApplyBundledDocuments(e, t, n, r) {
|
|
|
13027
13049
|
// Allocates a target to hold all document keys from the bundle, such that
|
|
13028
13050
|
// they will not get garbage collected right away.
|
|
13029
13051
|
return i.persistence.runTransaction("Apply bundle documents", "readwrite", (e => __PRIVATE_populateDocumentChangeBuffer(e, _, o).next((t => (_.apply(e),
|
|
13030
|
-
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.
|
|
13052
|
+
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))))));
|
|
13031
13053
|
}
|
|
13032
13054
|
|
|
13033
13055
|
/**
|
|
@@ -13266,7 +13288,7 @@ class __PRIVATE_LocalClientState {
|
|
|
13266
13288
|
// format of the key is:
|
|
13267
13289
|
// firestore_bundle_loaded_v2_<persistenceKey>
|
|
13268
13290
|
// The version ending with "v2" stores the list of modified collection groups.
|
|
13269
|
-
(this.persistenceKey), this.
|
|
13291
|
+
(this.persistenceKey), this.Bs = function createBundleLoadedKey(e) {
|
|
13270
13292
|
return `firestore_bundle_loaded_v2_${e}`;
|
|
13271
13293
|
}
|
|
13272
13294
|
// The WebStorage key prefix for the key that stores the last sequence number allocated. The key
|
|
@@ -13295,7 +13317,7 @@ class __PRIVATE_LocalClientState {
|
|
|
13295
13317
|
n && (this.Ds = this.Ds.insert(n.clientId, n));
|
|
13296
13318
|
}
|
|
13297
13319
|
}
|
|
13298
|
-
this.
|
|
13320
|
+
this.Ls();
|
|
13299
13321
|
// Check if there is an existing online state and call the callback handler
|
|
13300
13322
|
// if applicable.
|
|
13301
13323
|
const t = this.storage.getItem(this.Ns);
|
|
@@ -13344,10 +13366,10 @@ class __PRIVATE_LocalClientState {
|
|
|
13344
13366
|
}
|
|
13345
13367
|
// If the query is listening to cache only, the target ID should not be registered with the
|
|
13346
13368
|
// local Firestore client as an active watch target.
|
|
13347
|
-
return t && this.Us.ps(e), this.
|
|
13369
|
+
return t && this.Us.ps(e), this.Ls(), n;
|
|
13348
13370
|
}
|
|
13349
13371
|
removeLocalQueryTarget(e) {
|
|
13350
|
-
this.Us.ys(e), this.
|
|
13372
|
+
this.Us.ys(e), this.Ls();
|
|
13351
13373
|
}
|
|
13352
13374
|
isLocalQueryTarget(e) {
|
|
13353
13375
|
return this.Us.activeTargetIds.has(e);
|
|
@@ -13434,7 +13456,7 @@ class __PRIVATE_LocalClientState {
|
|
|
13434
13456
|
* isolated and no synchronization is performed.
|
|
13435
13457
|
*/ (t.newValue);
|
|
13436
13458
|
e !== __PRIVATE_ListenSequence.oe && this.sequenceNumberHandler(e);
|
|
13437
|
-
} else if (t.key === this.
|
|
13459
|
+
} else if (t.key === this.Bs) {
|
|
13438
13460
|
const e = this.no(t.newValue);
|
|
13439
13461
|
await Promise.all(e.map((e => this.syncEngine.ro(e))));
|
|
13440
13462
|
}
|
|
@@ -13445,7 +13467,7 @@ class __PRIVATE_LocalClientState {
|
|
|
13445
13467
|
get Us() {
|
|
13446
13468
|
return this.Ds.get(this.ws);
|
|
13447
13469
|
}
|
|
13448
|
-
|
|
13470
|
+
Ls() {
|
|
13449
13471
|
this.setItem(this.Cs, this.Us.gs());
|
|
13450
13472
|
}
|
|
13451
13473
|
Ks(e, t, n) {
|
|
@@ -13469,7 +13491,7 @@ class __PRIVATE_LocalClientState {
|
|
|
13469
13491
|
}
|
|
13470
13492
|
zs(e) {
|
|
13471
13493
|
const t = JSON.stringify(Array.from(e));
|
|
13472
|
-
this.setItem(this.
|
|
13494
|
+
this.setItem(this.Bs, t);
|
|
13473
13495
|
}
|
|
13474
13496
|
/**
|
|
13475
13497
|
* Parses a client state key in WebStorage. Returns null if the key does not
|
|
@@ -13836,7 +13858,7 @@ class __PRIVATE_RestConnection {
|
|
|
13836
13858
|
"google-cloud-resource-prefix": this.Mo,
|
|
13837
13859
|
"x-goog-request-params": this.xo
|
|
13838
13860
|
};
|
|
13839
|
-
return this.
|
|
13861
|
+
return this.Bo(_, r, i), this.Lo(e, o, _, n).then((t => (__PRIVATE_logDebug("RestConnection", `Received RPC '${e}' ${s}: `, t),
|
|
13840
13862
|
t)), (t => {
|
|
13841
13863
|
throw __PRIVATE_logWarn("RestConnection", `RPC '${e}' ${s} failed with error: `, t, "url: ", o, "request:", n),
|
|
13842
13864
|
t;
|
|
@@ -13850,7 +13872,7 @@ class __PRIVATE_RestConnection {
|
|
|
13850
13872
|
/**
|
|
13851
13873
|
* Modifies the headers for a request, adding any authorization token if
|
|
13852
13874
|
* present and any additional headers for the request.
|
|
13853
|
-
*/
|
|
13875
|
+
*/ Bo(e, t, n) {
|
|
13854
13876
|
e["X-Goog-Api-Client"] =
|
|
13855
13877
|
// SDK_VERSION is updated to different value at runtime depending on the entry point,
|
|
13856
13878
|
// so we need to get its value when we need it in a function.
|
|
@@ -13880,7 +13902,7 @@ class __PRIVATE_RestConnection {
|
|
|
13880
13902
|
super(e), this.forceLongPolling = e.forceLongPolling, this.autoDetectLongPolling = e.autoDetectLongPolling,
|
|
13881
13903
|
this.useFetchStreams = e.useFetchStreams, this.longPollingOptions = e.longPollingOptions;
|
|
13882
13904
|
}
|
|
13883
|
-
|
|
13905
|
+
Lo(e, t, n, r) {
|
|
13884
13906
|
const i = __PRIVATE_generateUniqueDebugId();
|
|
13885
13907
|
return new Promise(((s, o) => {
|
|
13886
13908
|
const _ = new XhrIo;
|
|
@@ -13954,7 +13976,7 @@ class __PRIVATE_RestConnection {
|
|
|
13954
13976
|
detectBufferingProxy: this.autoDetectLongPolling
|
|
13955
13977
|
}, a = this.longPollingOptions.timeoutSeconds;
|
|
13956
13978
|
void 0 !== a && (_.longPollingTimeout = Math.round(1e3 * a)), this.useFetchStreams && (_.useFetchStreams = !0),
|
|
13957
|
-
this.
|
|
13979
|
+
this.Bo(_.initMessageHeaders, t, n),
|
|
13958
13980
|
// Sending the custom headers we just added to request.initMessageHeaders
|
|
13959
13981
|
// (Authorization, etc.) will trigger the browser to make a CORS preflight
|
|
13960
13982
|
// request because the XHR will no longer meet the criteria for a "simple"
|
|
@@ -14411,19 +14433,19 @@ class __PRIVATE_PersistentStream {
|
|
|
14411
14433
|
}), (t => {
|
|
14412
14434
|
e((() => {
|
|
14413
14435
|
const e = new FirestoreError(D.UNKNOWN, "Fetching auth token failed: " + t.message);
|
|
14414
|
-
return this.
|
|
14436
|
+
return this.d_(e);
|
|
14415
14437
|
}));
|
|
14416
14438
|
}));
|
|
14417
14439
|
}
|
|
14418
14440
|
I_(e, t) {
|
|
14419
14441
|
const n = this.T_(this.Xo);
|
|
14420
|
-
this.stream = this.
|
|
14442
|
+
this.stream = this.E_(e, t), this.stream.Ro((() => {
|
|
14421
14443
|
n((() => this.listener.Ro()));
|
|
14422
14444
|
})), this.stream.mo((() => {
|
|
14423
14445
|
n((() => (this.state = 2 /* PersistentStreamState.Open */ , this.t_ = this.li.enqueueAfterDelay(this.Zo, 1e4, (() => (this.s_() && (this.state = 3 /* PersistentStreamState.Healthy */),
|
|
14424
14446
|
Promise.resolve()))), this.listener.mo())));
|
|
14425
14447
|
})), this.stream.po((e => {
|
|
14426
|
-
n((() => this.
|
|
14448
|
+
n((() => this.d_(e)));
|
|
14427
14449
|
})), this.stream.onMessage((e => {
|
|
14428
14450
|
n((() => 1 == ++this.n_ ? this.A_(e) : this.onNext(e)));
|
|
14429
14451
|
}));
|
|
@@ -14434,7 +14456,7 @@ class __PRIVATE_PersistentStream {
|
|
|
14434
14456
|
}));
|
|
14435
14457
|
}
|
|
14436
14458
|
// Visible for tests
|
|
14437
|
-
|
|
14459
|
+
d_(e) {
|
|
14438
14460
|
// In theory the stream could close cleanly, however, in our current model
|
|
14439
14461
|
// we never expect this to happen because if we stop a stream ourselves,
|
|
14440
14462
|
// this callback will never be called. To prevent cases where we retry
|
|
@@ -14466,7 +14488,7 @@ class __PRIVATE_PersistentStream {
|
|
|
14466
14488
|
super(e, "listen_stream_connection_backoff" /* TimerId.ListenStreamConnectionBackoff */ , "listen_stream_idle" /* TimerId.ListenStreamIdle */ , "health_check_timeout" /* TimerId.HealthCheckTimeout */ , t, n, r, s),
|
|
14467
14489
|
this.serializer = i;
|
|
14468
14490
|
}
|
|
14469
|
-
|
|
14491
|
+
E_(e, t) {
|
|
14470
14492
|
return this.connection.qo("Listen", e, t);
|
|
14471
14493
|
}
|
|
14472
14494
|
A_(e) {
|
|
@@ -14560,7 +14582,7 @@ class __PRIVATE_PersistentStream {
|
|
|
14560
14582
|
P_() {
|
|
14561
14583
|
this.f_ && this.g_([]);
|
|
14562
14584
|
}
|
|
14563
|
-
|
|
14585
|
+
E_(e, t) {
|
|
14564
14586
|
return this.connection.qo("Write", e, t);
|
|
14565
14587
|
}
|
|
14566
14588
|
A_(e) {
|
|
@@ -14771,7 +14793,7 @@ class __PRIVATE_OnlineStateTracker {
|
|
|
14771
14793
|
* purely based on order, and so we can just shift() writes from the front of
|
|
14772
14794
|
* the writePipeline as we receive responses.
|
|
14773
14795
|
*/
|
|
14774
|
-
this.
|
|
14796
|
+
this.B_ = [],
|
|
14775
14797
|
/**
|
|
14776
14798
|
* A mapping of watched targets that the client cares about tracking and the
|
|
14777
14799
|
* user has explicitly called a 'listen' for this target.
|
|
@@ -14781,7 +14803,7 @@ class __PRIVATE_OnlineStateTracker {
|
|
|
14781
14803
|
* to the server. The targets removed with unlistens are removed eagerly
|
|
14782
14804
|
* without waiting for confirmation from the listen stream.
|
|
14783
14805
|
*/
|
|
14784
|
-
this.
|
|
14806
|
+
this.L_ = new Map,
|
|
14785
14807
|
/**
|
|
14786
14808
|
* A set of reasons for why the RemoteStore may be offline. If empty, the
|
|
14787
14809
|
* RemoteStore may start its network connections.
|
|
@@ -14828,9 +14850,9 @@ async function __PRIVATE_enableNetworkInternal(e) {
|
|
|
14828
14850
|
*/
|
|
14829
14851
|
function __PRIVATE_remoteStoreListen(e, t) {
|
|
14830
14852
|
const n = __PRIVATE_debugCast(e);
|
|
14831
|
-
n.
|
|
14853
|
+
n.L_.has(t.targetId) || (
|
|
14832
14854
|
// Mark this as something the client is currently listening for.
|
|
14833
|
-
n.
|
|
14855
|
+
n.L_.set(t.targetId, t), __PRIVATE_shouldStartWatchStream(n) ?
|
|
14834
14856
|
// The listen will be sent in onWatchStreamOpen
|
|
14835
14857
|
__PRIVATE_startWatchStream(n) : __PRIVATE_ensureWatchStream(n).s_() && __PRIVATE_sendWatchRequest(n, t));
|
|
14836
14858
|
}
|
|
@@ -14840,7 +14862,7 @@ function __PRIVATE_remoteStoreListen(e, t) {
|
|
|
14840
14862
|
* not being listened to.
|
|
14841
14863
|
*/ function __PRIVATE_remoteStoreUnlisten(e, t) {
|
|
14842
14864
|
const n = __PRIVATE_debugCast(e), r = __PRIVATE_ensureWatchStream(n);
|
|
14843
|
-
n.
|
|
14865
|
+
n.L_.delete(t), r.s_() && __PRIVATE_sendUnwatchRequest(n, t), 0 === n.L_.size && (r.s_() ? r.a_() : __PRIVATE_canUseNetwork(n) &&
|
|
14844
14866
|
// Revert to OnlineState.Unknown if the watch stream is not open and we
|
|
14845
14867
|
// have no listeners, since without any listens to send we cannot
|
|
14846
14868
|
// confirm if the stream is healthy and upgrade to OnlineState.Online.
|
|
@@ -14869,7 +14891,7 @@ function __PRIVATE_remoteStoreListen(e, t) {
|
|
|
14869
14891
|
function __PRIVATE_startWatchStream(e) {
|
|
14870
14892
|
e.U_ = new __PRIVATE_WatchChangeAggregator({
|
|
14871
14893
|
getRemoteKeysForTarget: t => e.remoteSyncer.getRemoteKeysForTarget(t),
|
|
14872
|
-
ut: t => e.
|
|
14894
|
+
ut: t => e.L_.get(t) || null,
|
|
14873
14895
|
nt: () => e.datastore.serializer.databaseId
|
|
14874
14896
|
}), __PRIVATE_ensureWatchStream(e).start(), e.K_.F_();
|
|
14875
14897
|
}
|
|
@@ -14878,7 +14900,7 @@ function __PRIVATE_startWatchStream(e) {
|
|
|
14878
14900
|
* Returns whether the watch stream should be started because it's necessary
|
|
14879
14901
|
* and has not yet been started.
|
|
14880
14902
|
*/ function __PRIVATE_shouldStartWatchStream(e) {
|
|
14881
|
-
return __PRIVATE_canUseNetwork(e) && !__PRIVATE_ensureWatchStream(e).i_() && e.
|
|
14903
|
+
return __PRIVATE_canUseNetwork(e) && !__PRIVATE_ensureWatchStream(e).i_() && e.L_.size > 0;
|
|
14882
14904
|
}
|
|
14883
14905
|
|
|
14884
14906
|
function __PRIVATE_canUseNetwork(e) {
|
|
@@ -14895,7 +14917,7 @@ async function __PRIVATE_onWatchStreamConnected(e) {
|
|
|
14895
14917
|
}
|
|
14896
14918
|
|
|
14897
14919
|
async function __PRIVATE_onWatchStreamOpen(e) {
|
|
14898
|
-
e.
|
|
14920
|
+
e.L_.forEach(((t, n) => {
|
|
14899
14921
|
__PRIVATE_sendWatchRequest(e, t);
|
|
14900
14922
|
}));
|
|
14901
14923
|
}
|
|
@@ -14923,7 +14945,7 @@ async function __PRIVATE_onWatchStreamChange(e, t, n) {
|
|
|
14923
14945
|
const n = t.cause;
|
|
14924
14946
|
for (const r of t.targetIds)
|
|
14925
14947
|
// A watched target might have been removed already.
|
|
14926
|
-
e.
|
|
14948
|
+
e.L_.has(r) && (await e.remoteSyncer.rejectListen(r, n), e.L_.delete(r), e.U_.removeTarget(r));
|
|
14927
14949
|
}
|
|
14928
14950
|
/**
|
|
14929
14951
|
* Attempts to fill our write pipeline with writes from the LocalStore.
|
|
@@ -14954,21 +14976,21 @@ async function __PRIVATE_onWatchStreamChange(e, t, n) {
|
|
|
14954
14976
|
// persistent view of these when applying the completed RemoteEvent.
|
|
14955
14977
|
return n.targetChanges.forEach(((n, r) => {
|
|
14956
14978
|
if (n.resumeToken.approximateByteSize() > 0) {
|
|
14957
|
-
const i = e.
|
|
14979
|
+
const i = e.L_.get(r);
|
|
14958
14980
|
// A watched target might have been removed already.
|
|
14959
|
-
i && e.
|
|
14981
|
+
i && e.L_.set(r, i.withResumeToken(n.resumeToken, t));
|
|
14960
14982
|
}
|
|
14961
14983
|
})),
|
|
14962
14984
|
// Re-establish listens for the targets that have been invalidated by
|
|
14963
14985
|
// existence filter mismatches.
|
|
14964
14986
|
n.targetMismatches.forEach(((t, n) => {
|
|
14965
|
-
const r = e.
|
|
14987
|
+
const r = e.L_.get(t);
|
|
14966
14988
|
if (!r)
|
|
14967
14989
|
// A watched target might have been removed already.
|
|
14968
14990
|
return;
|
|
14969
14991
|
// Clear the resume token for the target, since we're in a known mismatch
|
|
14970
14992
|
// state.
|
|
14971
|
-
e.
|
|
14993
|
+
e.L_.set(t, r.withResumeToken(ByteString.EMPTY_BYTE_STRING, r.snapshotVersion)),
|
|
14972
14994
|
// Cause a hard reset by unwatching and rewatching immediately, but
|
|
14973
14995
|
// deliberately don't send a resume token so that we get a full update.
|
|
14974
14996
|
__PRIVATE_sendUnwatchRequest(e, t);
|
|
@@ -15019,11 +15041,11 @@ async function __PRIVATE_onWatchStreamChange(e, t, n) {
|
|
|
15019
15041
|
|
|
15020
15042
|
async function __PRIVATE_fillWritePipeline(e) {
|
|
15021
15043
|
const t = __PRIVATE_debugCast(e), n = __PRIVATE_ensureWriteStream(t);
|
|
15022
|
-
let r = t.
|
|
15044
|
+
let r = t.B_.length > 0 ? t.B_[t.B_.length - 1].batchId : -1;
|
|
15023
15045
|
for (;__PRIVATE_canAddToWritePipeline(t); ) try {
|
|
15024
15046
|
const e = await __PRIVATE_localStoreGetNextMutationBatch(t.localStore, r);
|
|
15025
15047
|
if (null === e) {
|
|
15026
|
-
0 === t.
|
|
15048
|
+
0 === t.B_.length && n.a_();
|
|
15027
15049
|
break;
|
|
15028
15050
|
}
|
|
15029
15051
|
r = e.batchId, __PRIVATE_addToWritePipeline(t, e);
|
|
@@ -15037,20 +15059,20 @@ async function __PRIVATE_fillWritePipeline(e) {
|
|
|
15037
15059
|
* Returns true if we can add to the write pipeline (i.e. the network is
|
|
15038
15060
|
* enabled and the write pipeline is not full).
|
|
15039
15061
|
*/ function __PRIVATE_canAddToWritePipeline(e) {
|
|
15040
|
-
return __PRIVATE_canUseNetwork(e) && e.
|
|
15062
|
+
return __PRIVATE_canUseNetwork(e) && e.B_.length < 10;
|
|
15041
15063
|
}
|
|
15042
15064
|
|
|
15043
15065
|
/**
|
|
15044
15066
|
* Queues additional writes to be sent to the write stream, sending them
|
|
15045
15067
|
* immediately if the write stream is established.
|
|
15046
15068
|
*/ function __PRIVATE_addToWritePipeline(e, t) {
|
|
15047
|
-
e.
|
|
15069
|
+
e.B_.push(t);
|
|
15048
15070
|
const n = __PRIVATE_ensureWriteStream(e);
|
|
15049
15071
|
n.s_() && n.f_ && n.g_(t.mutations);
|
|
15050
15072
|
}
|
|
15051
15073
|
|
|
15052
15074
|
function __PRIVATE_shouldStartWriteStream(e) {
|
|
15053
|
-
return __PRIVATE_canUseNetwork(e) && !__PRIVATE_ensureWriteStream(e).i_() && e.
|
|
15075
|
+
return __PRIVATE_canUseNetwork(e) && !__PRIVATE_ensureWriteStream(e).i_() && e.B_.length > 0;
|
|
15054
15076
|
}
|
|
15055
15077
|
|
|
15056
15078
|
function __PRIVATE_startWriteStream(e) {
|
|
@@ -15064,11 +15086,11 @@ async function __PRIVATE_onWriteStreamOpen(e) {
|
|
|
15064
15086
|
async function __PRIVATE_onWriteHandshakeComplete(e) {
|
|
15065
15087
|
const t = __PRIVATE_ensureWriteStream(e);
|
|
15066
15088
|
// Send the write pipeline now that the stream is established.
|
|
15067
|
-
for (const n of e.
|
|
15089
|
+
for (const n of e.B_) t.g_(n.mutations);
|
|
15068
15090
|
}
|
|
15069
15091
|
|
|
15070
15092
|
async function __PRIVATE_onMutationResult(e, t, n) {
|
|
15071
|
-
const r = e.
|
|
15093
|
+
const r = e.B_.shift(), i = MutationBatchResult.from(r, t, n);
|
|
15072
15094
|
await __PRIVATE_executeWithRecovery(e, (() => e.remoteSyncer.applySuccessfulWrite(i))),
|
|
15073
15095
|
// It's possible that with the completion of this mutation another
|
|
15074
15096
|
// slot has freed up.
|
|
@@ -15088,7 +15110,7 @@ async function __PRIVATE_onWriteStreamClose(e, t) {
|
|
|
15088
15110
|
}(t.code)) {
|
|
15089
15111
|
// This was a permanent error, the request itself was the problem
|
|
15090
15112
|
// so it's not going to succeed if we resend it.
|
|
15091
|
-
const n = e.
|
|
15113
|
+
const n = e.B_.shift();
|
|
15092
15114
|
// In this case it's also unlikely that the server itself is melting
|
|
15093
15115
|
// down -- this was just a bad request so inhibit backoff on the next
|
|
15094
15116
|
// restart.
|
|
@@ -15187,8 +15209,8 @@ async function __PRIVATE_remoteStoreHandleCredentialChange(e, t) {
|
|
|
15187
15209
|
}), e.q_.push((async t => {
|
|
15188
15210
|
t ? (e.G_.__(),
|
|
15189
15211
|
// This will start the write stream if necessary.
|
|
15190
|
-
await __PRIVATE_fillWritePipeline(e)) : (await e.G_.stop(), e.
|
|
15191
|
-
e.
|
|
15212
|
+
await __PRIVATE_fillWritePipeline(e)) : (await e.G_.stop(), e.B_.length > 0 && (__PRIVATE_logDebug("RemoteStore", `Stopping write stream with ${e.B_.length} pending writes`),
|
|
15213
|
+
e.B_ = []));
|
|
15192
15214
|
}))), e.G_;
|
|
15193
15215
|
}
|
|
15194
15216
|
|
|
@@ -15810,7 +15832,7 @@ class __PRIVATE_QueryListener {
|
|
|
15810
15832
|
return this.progress.taskState = "Success", {
|
|
15811
15833
|
progress: this.progress,
|
|
15812
15834
|
Ia: this.collectionGroups,
|
|
15813
|
-
|
|
15835
|
+
da: e
|
|
15814
15836
|
};
|
|
15815
15837
|
}
|
|
15816
15838
|
}
|
|
@@ -15868,7 +15890,7 @@ class __PRIVATE_RemovedLimboDocument {
|
|
|
15868
15890
|
constructor(e,
|
|
15869
15891
|
/** Documents included in the remote target */
|
|
15870
15892
|
t) {
|
|
15871
|
-
this.query = e, this.
|
|
15893
|
+
this.query = e, this.Ea = t, this.Aa = null, this.hasCachedResults = !1,
|
|
15872
15894
|
/**
|
|
15873
15895
|
* A flag whether the view is current with the backend. A view is considered
|
|
15874
15896
|
* current after it has seen the current flag from the backend and did not
|
|
@@ -15886,7 +15908,7 @@ class __PRIVATE_RemovedLimboDocument {
|
|
|
15886
15908
|
* The set of remote documents that the server has told us belongs to the target associated with
|
|
15887
15909
|
* this view.
|
|
15888
15910
|
*/ get fa() {
|
|
15889
|
-
return this.
|
|
15911
|
+
return this.Ea;
|
|
15890
15912
|
}
|
|
15891
15913
|
/**
|
|
15892
15914
|
* Iterates over a set of doc changes, applies the query limit, and computes
|
|
@@ -16060,7 +16082,7 @@ class __PRIVATE_RemovedLimboDocument {
|
|
|
16060
16082
|
* Returns whether the doc for the given key should be in limbo.
|
|
16061
16083
|
*/ Da(e) {
|
|
16062
16084
|
// If the remote end says it's part of this query, it's not in limbo.
|
|
16063
|
-
return !this.
|
|
16085
|
+
return !this.Ea.has(e) && (
|
|
16064
16086
|
// The local store doesn't think it's a result, so it shouldn't be in limbo.
|
|
16065
16087
|
!!this.ma.has(e) && !this.ma.get(e).hasLocalMutations);
|
|
16066
16088
|
}
|
|
@@ -16068,8 +16090,8 @@ class __PRIVATE_RemovedLimboDocument {
|
|
|
16068
16090
|
* Updates syncedDocuments, current, and limbo docs based on the given change.
|
|
16069
16091
|
* Returns the list of changes to which docs are in limbo.
|
|
16070
16092
|
*/ wa(e) {
|
|
16071
|
-
e && (e.addedDocuments.forEach((e => this.
|
|
16072
|
-
e.removedDocuments.forEach((e => this.
|
|
16093
|
+
e && (e.addedDocuments.forEach((e => this.Ea = this.Ea.add(e))), e.modifiedDocuments.forEach((e => {})),
|
|
16094
|
+
e.removedDocuments.forEach((e => this.Ea = this.Ea.delete(e))), this.current = e.current);
|
|
16073
16095
|
}
|
|
16074
16096
|
Sa() {
|
|
16075
16097
|
// We can only determine limbo documents when we're in-sync with the server.
|
|
@@ -16109,7 +16131,7 @@ class __PRIVATE_RemovedLimboDocument {
|
|
|
16109
16131
|
*/
|
|
16110
16132
|
// PORTING NOTE: Multi-tab only.
|
|
16111
16133
|
va(e) {
|
|
16112
|
-
this.
|
|
16134
|
+
this.Ea = e.Es, this.Ra = __PRIVATE_documentKeySet();
|
|
16113
16135
|
const t = this.ga(e.documents);
|
|
16114
16136
|
return this.applyChanges(t, /* limboResolutionEnabled= */ !0);
|
|
16115
16137
|
}
|
|
@@ -16196,12 +16218,12 @@ class __PRIVATE_QueryView {
|
|
|
16196
16218
|
* Keeps track of the target ID for each document that is in limbo with an
|
|
16197
16219
|
* active target.
|
|
16198
16220
|
*/
|
|
16199
|
-
this.
|
|
16221
|
+
this.Ba = new SortedMap(DocumentKey.comparator),
|
|
16200
16222
|
/**
|
|
16201
16223
|
* Keeps track of the information about an active limbo resolution for each
|
|
16202
16224
|
* active target ID that was started for the purpose of limbo resolution.
|
|
16203
16225
|
*/
|
|
16204
|
-
this.
|
|
16226
|
+
this.La = new Map, this.ka = new __PRIVATE_ReferenceSet,
|
|
16205
16227
|
/** Stores user completion handlers, indexed by User and BatchId. */
|
|
16206
16228
|
this.qa = {},
|
|
16207
16229
|
/** Stores user callbacks waiting for all pending writes to be acknowledged. */
|
|
@@ -16270,7 +16292,7 @@ async function __PRIVATE_allocateTargetAndMaybeListen(e, t, n, r) {
|
|
|
16270
16292
|
return __PRIVATE_updateTrackedLimbos(e, t.targetId, _.ba), _.snapshot;
|
|
16271
16293
|
}(e, t, n, r);
|
|
16272
16294
|
const s = await __PRIVATE_localStoreExecuteQuery(e.localStore, t,
|
|
16273
|
-
/* usePreviousResults= */ !0), o = new __PRIVATE_View(t, s.
|
|
16295
|
+
/* 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(_,
|
|
16274
16296
|
/* limboResolutionEnabled= */ e.isPrimaryClient, a);
|
|
16275
16297
|
__PRIVATE_updateTrackedLimbos(e, n, u.ba);
|
|
16276
16298
|
const c = new __PRIVATE_QueryView(t, n, o);
|
|
@@ -16385,7 +16407,7 @@ async function __PRIVATE_allocateTargetAndMaybeListen(e, t, n, r) {
|
|
|
16385
16407
|
const e = await __PRIVATE_localStoreApplyRemoteEventToLocalCache(n.localStore, t);
|
|
16386
16408
|
// Update `receivedDocument` as appropriate for any limbo targets.
|
|
16387
16409
|
t.targetChanges.forEach(((e, t) => {
|
|
16388
|
-
const r = n.
|
|
16410
|
+
const r = n.La.get(t);
|
|
16389
16411
|
r && (
|
|
16390
16412
|
// Since this is a limbo resolution lookup, it's for a single document
|
|
16391
16413
|
// and it could be added, modified, or removed, but not a combination.
|
|
@@ -16439,7 +16461,7 @@ async function __PRIVATE_allocateTargetAndMaybeListen(e, t, n, r) {
|
|
|
16439
16461
|
const r = __PRIVATE_debugCast(e);
|
|
16440
16462
|
// PORTING NOTE: Multi-tab only.
|
|
16441
16463
|
r.sharedClientState.updateQueryState(t, "rejected", n);
|
|
16442
|
-
const i = r.
|
|
16464
|
+
const i = r.La.get(t), s = i && i.key;
|
|
16443
16465
|
if (s) {
|
|
16444
16466
|
// TODO(klimt): We really only should do the following on permission
|
|
16445
16467
|
// denied errors, but we don't have the cause code here.
|
|
@@ -16461,7 +16483,7 @@ async function __PRIVATE_allocateTargetAndMaybeListen(e, t, n, r) {
|
|
|
16461
16483
|
// RemoteEvent. If `applyRemoteEvent()` throws, we want to re-listen to
|
|
16462
16484
|
// this query when the RemoteStore restarts the Watch stream, which should
|
|
16463
16485
|
// re-trigger the target failure.
|
|
16464
|
-
r.
|
|
16486
|
+
r.Ba = r.Ba.remove(s), r.La.delete(t), __PRIVATE_pumpEnqueuedLimboResolutions(r);
|
|
16465
16487
|
} else await __PRIVATE_localStoreReleaseTarget(r.localStore, t,
|
|
16466
16488
|
/* keepPersistedTargetData */ !1).then((() => __PRIVATE_removeAndCleanupTarget(r, t, n))).catch(__PRIVATE_ignoreIfPrimaryLeaseLoss);
|
|
16467
16489
|
}
|
|
@@ -16567,9 +16589,9 @@ function __PRIVATE_removeLimboTarget(e, t) {
|
|
|
16567
16589
|
e.Na.delete(t.path.canonicalString());
|
|
16568
16590
|
// It's possible that the target already got removed because the query failed. In that case,
|
|
16569
16591
|
// the key won't exist in `limboTargetsByKey`. Only do the cleanup if we still have the target.
|
|
16570
|
-
const n = e.
|
|
16571
|
-
null !== n && (__PRIVATE_remoteStoreUnlisten(e.remoteStore, n), e.
|
|
16572
|
-
e.
|
|
16592
|
+
const n = e.Ba.get(t);
|
|
16593
|
+
null !== n && (__PRIVATE_remoteStoreUnlisten(e.remoteStore, n), e.Ba = e.Ba.remove(t),
|
|
16594
|
+
e.La.delete(n), __PRIVATE_pumpEnqueuedLimboResolutions(e));
|
|
16573
16595
|
}
|
|
16574
16596
|
|
|
16575
16597
|
function __PRIVATE_updateTrackedLimbos(e, t, n) {
|
|
@@ -16584,7 +16606,7 @@ function __PRIVATE_updateTrackedLimbos(e, t, n) {
|
|
|
16584
16606
|
|
|
16585
16607
|
function __PRIVATE_trackLimboChange(e, t) {
|
|
16586
16608
|
const n = t.key, r = n.path.canonicalString();
|
|
16587
|
-
e.
|
|
16609
|
+
e.Ba.get(n) || e.Na.has(r) || (__PRIVATE_logDebug("SyncEngine", "New document in limbo: " + n),
|
|
16588
16610
|
e.Na.add(r), __PRIVATE_pumpEnqueuedLimboResolutions(e));
|
|
16589
16611
|
}
|
|
16590
16612
|
|
|
@@ -16596,11 +16618,11 @@ function __PRIVATE_trackLimboChange(e, t) {
|
|
|
16596
16618
|
* with "resource exhausted" errors which can lead to pathological client
|
|
16597
16619
|
* behavior as seen in https://github.com/firebase/firebase-js-sdk/issues/2683.
|
|
16598
16620
|
*/ function __PRIVATE_pumpEnqueuedLimboResolutions(e) {
|
|
16599
|
-
for (;e.Na.size > 0 && e.
|
|
16621
|
+
for (;e.Na.size > 0 && e.Ba.size < e.maxConcurrentLimboResolutions; ) {
|
|
16600
16622
|
const t = e.Na.values().next().value;
|
|
16601
16623
|
e.Na.delete(t);
|
|
16602
16624
|
const n = new DocumentKey(ResourcePath.fromString(t)), r = e.Ka.next();
|
|
16603
|
-
e.
|
|
16625
|
+
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));
|
|
16604
16626
|
}
|
|
16605
16627
|
}
|
|
16606
16628
|
|
|
@@ -16668,7 +16690,7 @@ async function __PRIVATE_syncEngineHandleCredentialChange(e, t) {
|
|
|
16668
16690
|
}
|
|
16669
16691
|
|
|
16670
16692
|
function __PRIVATE_syncEngineGetRemoteKeysForTarget(e, t) {
|
|
16671
|
-
const n = __PRIVATE_debugCast(e), r = n.
|
|
16693
|
+
const n = __PRIVATE_debugCast(e), r = n.La.get(t);
|
|
16672
16694
|
if (r && r.Fa) return __PRIVATE_documentKeySet().add(r.key);
|
|
16673
16695
|
{
|
|
16674
16696
|
let e = __PRIVATE_documentKeySet();
|
|
@@ -16720,7 +16742,7 @@ async function __PRIVATE_syncEngineApplyBatchState(e, t, n, r) {
|
|
|
16720
16742
|
// other clients.
|
|
16721
16743
|
__PRIVATE_processUserCallback(i, t, r || null), __PRIVATE_triggerPendingWritesCallbacks(i, t),
|
|
16722
16744
|
function __PRIVATE_localStoreRemoveCachedMutationBatchMetadata(e, t) {
|
|
16723
|
-
__PRIVATE_debugCast(__PRIVATE_debugCast(e).mutationQueue).
|
|
16745
|
+
__PRIVATE_debugCast(__PRIVATE_debugCast(e).mutationQueue).Bn(t);
|
|
16724
16746
|
}
|
|
16725
16747
|
// PORTING NOTE: Multi-Tab only.
|
|
16726
16748
|
(i.localStore, t)) : fail(), await __PRIVATE_syncEngineEmitNewSnapsAndNotifyLocalStore(i, s)) :
|
|
@@ -16760,9 +16782,9 @@ async function __PRIVATE_syncEngineApplyPrimaryState(e, t) {
|
|
|
16760
16782
|
// PORTING NOTE: Multi-Tab only.
|
|
16761
16783
|
function __PRIVATE_resetLimboDocuments(e) {
|
|
16762
16784
|
const t = __PRIVATE_debugCast(e);
|
|
16763
|
-
t.
|
|
16785
|
+
t.La.forEach(((e, n) => {
|
|
16764
16786
|
__PRIVATE_remoteStoreUnlisten(t.remoteStore, n);
|
|
16765
|
-
})), t.ka.wr(), t.
|
|
16787
|
+
})), t.ka.wr(), t.La = new Map, t.Ba = new SortedMap(DocumentKey.comparator);
|
|
16766
16788
|
}
|
|
16767
16789
|
/**
|
|
16768
16790
|
* Reconcile the query views of the provided query targets with the state from
|
|
@@ -16935,7 +16957,7 @@ function __PRIVATE_syncEngineEnsureWriteCallbacks(e) {
|
|
|
16935
16957
|
e && n._updateProgress(e), s = await t.Ga();
|
|
16936
16958
|
}
|
|
16937
16959
|
const o = await i.complete();
|
|
16938
|
-
return await __PRIVATE_syncEngineEmitNewSnapsAndNotifyLocalStore(e, o.
|
|
16960
|
+
return await __PRIVATE_syncEngineEmitNewSnapsAndNotifyLocalStore(e, o.da,
|
|
16939
16961
|
/* remoteEvent */ void 0),
|
|
16940
16962
|
// Save metadata, so loading the same bundle will skip.
|
|
16941
16963
|
await function __PRIVATE_localStoreSaveBundle(e, t) {
|
|
@@ -17824,7 +17846,7 @@ function __PRIVATE_firestoreClientGetDocumentsFromLocalCache(e, t) {
|
|
|
17824
17846
|
return e.asyncQueue.enqueueAndForget((async () => async function __PRIVATE_executeQueryFromCache(e, t, n) {
|
|
17825
17847
|
try {
|
|
17826
17848
|
const r = await __PRIVATE_localStoreExecuteQuery(e, t,
|
|
17827
|
-
/* usePreviousResults= */ !0), i = new __PRIVATE_View(t, r.
|
|
17849
|
+
/* usePreviousResults= */ !0), i = new __PRIVATE_View(t, r.Es), s = i.ga(r.documents), o = i.applyChanges(s,
|
|
17828
17850
|
/* limboResolutionEnabled= */ !1);
|
|
17829
17851
|
n.resolve(o.snapshot);
|
|
17830
17852
|
} catch (e) {
|
|
@@ -18586,10 +18608,10 @@ function doc(e, t, ...n) {
|
|
|
18586
18608
|
this.Iu = [],
|
|
18587
18609
|
// Is this AsyncQueue being shut down? Once it is set to true, it will not
|
|
18588
18610
|
// be changed again.
|
|
18589
|
-
this.
|
|
18611
|
+
this.du = !1,
|
|
18590
18612
|
// Operations scheduled to be queued in the future. Operations are
|
|
18591
18613
|
// automatically removed after they are run or canceled.
|
|
18592
|
-
this.
|
|
18614
|
+
this.Eu = [],
|
|
18593
18615
|
// visible for testing
|
|
18594
18616
|
this.Au = null,
|
|
18595
18617
|
// Flag set while there's an outstanding AsyncQueue operation, used for
|
|
@@ -18613,7 +18635,7 @@ function doc(e, t, ...n) {
|
|
|
18613
18635
|
t && "function" == typeof t.addEventListener && t.addEventListener("visibilitychange", this.fu);
|
|
18614
18636
|
}
|
|
18615
18637
|
get isShuttingDown() {
|
|
18616
|
-
return this.
|
|
18638
|
+
return this.du;
|
|
18617
18639
|
}
|
|
18618
18640
|
/**
|
|
18619
18641
|
* Adds a new operation to the queue without waiting for it to complete (i.e.
|
|
@@ -18628,21 +18650,21 @@ function doc(e, t, ...n) {
|
|
|
18628
18650
|
this.yu(e);
|
|
18629
18651
|
}
|
|
18630
18652
|
enterRestrictedMode(e) {
|
|
18631
|
-
if (!this.
|
|
18632
|
-
this.
|
|
18653
|
+
if (!this.du) {
|
|
18654
|
+
this.du = !0, this.Vu = e || !1;
|
|
18633
18655
|
const t = getDocument();
|
|
18634
18656
|
t && "function" == typeof t.removeEventListener && t.removeEventListener("visibilitychange", this.fu);
|
|
18635
18657
|
}
|
|
18636
18658
|
}
|
|
18637
18659
|
enqueue(e) {
|
|
18638
|
-
if (this.pu(), this.
|
|
18660
|
+
if (this.pu(), this.du)
|
|
18639
18661
|
// Return a Promise which never resolves.
|
|
18640
18662
|
return new Promise((() => {}));
|
|
18641
18663
|
// Create a deferred Promise that we can return to the callee. This
|
|
18642
18664
|
// allows us to return a "hanging Promise" only to the callee and still
|
|
18643
18665
|
// advance the queue even when the operation is not run.
|
|
18644
18666
|
const t = new __PRIVATE_Deferred;
|
|
18645
|
-
return this.yu((() => this.
|
|
18667
|
+
return this.yu((() => this.du && this.Vu ? Promise.resolve() : (e().then(t.resolve, t.reject),
|
|
18646
18668
|
t.promise))).then((() => t.promise));
|
|
18647
18669
|
}
|
|
18648
18670
|
enqueueRetryable(e) {
|
|
@@ -18716,7 +18738,7 @@ function doc(e, t, ...n) {
|
|
|
18716
18738
|
// Fast-forward delays for timerIds that have been overridden.
|
|
18717
18739
|
this.mu.indexOf(e) > -1 && (t = 0);
|
|
18718
18740
|
const r = DelayedOperation.createAndSchedule(this, e, t, n, (e => this.Su(e)));
|
|
18719
|
-
return this.
|
|
18741
|
+
return this.Eu.push(r), r;
|
|
18720
18742
|
}
|
|
18721
18743
|
pu() {
|
|
18722
18744
|
this.Au && fail();
|
|
@@ -18739,7 +18761,7 @@ function doc(e, t, ...n) {
|
|
|
18739
18761
|
* For Tests: Determine if a delayed operation with a particular TimerId
|
|
18740
18762
|
* exists.
|
|
18741
18763
|
*/ Du(e) {
|
|
18742
|
-
for (const t of this.
|
|
18764
|
+
for (const t of this.Eu) if (t.timerId === e) return !0;
|
|
18743
18765
|
return !1;
|
|
18744
18766
|
}
|
|
18745
18767
|
/**
|
|
@@ -18753,8 +18775,8 @@ function doc(e, t, ...n) {
|
|
|
18753
18775
|
return this.bu().then((() => {
|
|
18754
18776
|
// Run ops in the same order they'd run if they ran naturally.
|
|
18755
18777
|
/* eslint-disable-next-line @typescript-eslint/no-floating-promises */
|
|
18756
|
-
this.
|
|
18757
|
-
for (const t of this.
|
|
18778
|
+
this.Eu.sort(((e, t) => e.targetTimeMs - t.targetTimeMs));
|
|
18779
|
+
for (const t of this.Eu) if (t.skipDelay(), "all" /* TimerId.All */ !== e && t.timerId === e) break;
|
|
18758
18780
|
return this.bu();
|
|
18759
18781
|
}));
|
|
18760
18782
|
}
|
|
@@ -18765,8 +18787,8 @@ function doc(e, t, ...n) {
|
|
|
18765
18787
|
}
|
|
18766
18788
|
/** Called once a DelayedOperation is run or canceled. */ Su(e) {
|
|
18767
18789
|
// NOTE: indexOf / slice are O(n), but delayedOperations is expected to be small.
|
|
18768
|
-
const t = this.
|
|
18769
|
-
/* eslint-disable-next-line @typescript-eslint/no-floating-promises */ this.
|
|
18790
|
+
const t = this.Eu.indexOf(e);
|
|
18791
|
+
/* eslint-disable-next-line @typescript-eslint/no-floating-promises */ this.Eu.splice(t, 1);
|
|
18770
18792
|
}
|
|
18771
18793
|
}
|
|
18772
18794
|
|
|
@@ -19634,9 +19656,9 @@ function __PRIVATE_isWrite(e) {
|
|
|
19634
19656
|
path: n,
|
|
19635
19657
|
Nu: !1
|
|
19636
19658
|
});
|
|
19637
|
-
return r.
|
|
19659
|
+
return r.Bu(e), r;
|
|
19638
19660
|
}
|
|
19639
|
-
|
|
19661
|
+
Lu(e) {
|
|
19640
19662
|
var t;
|
|
19641
19663
|
const n = null === (t = this.path) || void 0 === t ? void 0 : t.child(e), r = this.xu({
|
|
19642
19664
|
path: n,
|
|
@@ -19661,9 +19683,9 @@ function __PRIVATE_isWrite(e) {
|
|
|
19661
19683
|
Fu() {
|
|
19662
19684
|
// TODO(b/34871131): Remove null check once we have proper paths for fields
|
|
19663
19685
|
// within arrays.
|
|
19664
|
-
if (this.path) for (let e = 0; e < this.path.length; e++) this.
|
|
19686
|
+
if (this.path) for (let e = 0; e < this.path.length; e++) this.Bu(this.path.get(e));
|
|
19665
19687
|
}
|
|
19666
|
-
|
|
19688
|
+
Bu(e) {
|
|
19667
19689
|
if (0 === e.length) throw this.qu("Document fields must not be empty");
|
|
19668
19690
|
if (__PRIVATE_isWrite(this.Mu) && be.test(e)) throw this.qu('Document fields cannot begin and end with "__"');
|
|
19669
19691
|
}
|
|
@@ -19805,7 +19827,7 @@ class __PRIVATE_NumericIncrementFieldValueImpl extends FieldValue {
|
|
|
19805
19827
|
// For Compat types, we have to "extract" the underlying types before
|
|
19806
19828
|
// performing validation.
|
|
19807
19829
|
r = getModularInstance(r);
|
|
19808
|
-
const a = i.
|
|
19830
|
+
const a = i.Lu(_);
|
|
19809
19831
|
if (r instanceof __PRIVATE_DeleteFieldValueImpl)
|
|
19810
19832
|
// Add it to the field mask, but don't add anything to updateData.
|
|
19811
19833
|
s.push(_); else {
|
|
@@ -19831,7 +19853,7 @@ class __PRIVATE_NumericIncrementFieldValueImpl extends FieldValue {
|
|
|
19831
19853
|
// For Compat types, we have to "extract" the underlying types before
|
|
19832
19854
|
// performing validation.
|
|
19833
19855
|
n = getModularInstance(n);
|
|
19834
|
-
const r = o.
|
|
19856
|
+
const r = o.Lu(t);
|
|
19835
19857
|
if (n instanceof __PRIVATE_DeleteFieldValueImpl)
|
|
19836
19858
|
// Add it to the field mask, but don't add anything to updateData.
|
|
19837
19859
|
u.push(t); else {
|
|
@@ -22229,9 +22251,9 @@ let Fe = null;
|
|
|
22229
22251
|
return r = Object.assign({
|
|
22230
22252
|
useFetchStreams: t
|
|
22231
22253
|
}, r), s._setSettings(r), s;
|
|
22232
|
-
}), "PUBLIC").setMultipleInstances(!0)), registerVersion(w, "4.7.5-canary.
|
|
22254
|
+
}), "PUBLIC").setMultipleInstances(!0)), registerVersion(w, "4.7.5-canary.c19a051ce", e),
|
|
22233
22255
|
// BUILD_TARGET will be replaced by values like esm2017, cjs2017, etc during the compilation
|
|
22234
|
-
registerVersion(w, "4.7.5-canary.
|
|
22256
|
+
registerVersion(w, "4.7.5-canary.c19a051ce", "esm2017");
|
|
22235
22257
|
}();
|
|
22236
22258
|
|
|
22237
22259
|
export { AbstractUserDataWriter, AggregateField, AggregateQuerySnapshot, Bytes, Se as CACHE_SIZE_UNLIMITED, CollectionReference, DocumentReference, DocumentSnapshot, FieldPath, FieldValue, Firestore, FirestoreError, GeoPoint, LoadBundleTask, PersistentCacheIndexManager, Query, QueryCompositeFilterConstraint, QueryConstraint, QueryDocumentSnapshot, QueryEndAtConstraint, QueryFieldFilterConstraint, QueryLimitConstraint, QueryOrderByConstraint, QuerySnapshot, QueryStartAtConstraint, SnapshotMetadata, Timestamp, Transaction, VectorValue, WriteBatch, __PRIVATE_AutoId as _AutoId, ByteString as _ByteString, DatabaseId as _DatabaseId, DocumentKey as _DocumentKey, __PRIVATE_EmptyAppCheckTokenProvider as _EmptyAppCheckTokenProvider, __PRIVATE_EmptyAuthCredentialsProvider as _EmptyAuthCredentialsProvider, FieldPath$1 as _FieldPath, TestingHooks as _TestingHooks, __PRIVATE_cast as _cast, __PRIVATE_debugAssert as _debugAssert, _internalAggregationQueryToProtoRunAggregationQueryRequest, _internalQueryToProtoQueryTarget, __PRIVATE_isBase64Available as _isBase64Available, __PRIVATE_logWarn as _logWarn, __PRIVATE_validateIsNotUsedTogether as _validateIsNotUsedTogether, addDoc, aggregateFieldEqual, aggregateQuerySnapshotEqual, and, arrayRemove, arrayUnion, average, clearIndexedDbPersistence, collection, collectionGroup, connectFirestoreEmulator, count, deleteAllPersistentCacheIndexes, deleteDoc, deleteField, disableNetwork, disablePersistentCacheIndexAutoCreation, doc, documentId, enableIndexedDbPersistence, enableMultiTabIndexedDbPersistence, enableNetwork, enablePersistentCacheIndexAutoCreation, endAt, endBefore, ensureFirestoreConfigured, executeWrite, getAggregateFromServer, getCountFromServer, getDoc, getDocFromCache, getDocFromServer, getDocs, getDocsFromCache, getDocsFromServer, getFirestore, getPersistentCacheIndexManager, increment, initializeFirestore, limit, limitToLast, loadBundle, memoryEagerGarbageCollector, memoryLocalCache, memoryLruGarbageCollector, namedQuery, onSnapshot, onSnapshotsInSync, or, orderBy, persistentLocalCache, persistentMultipleTabManager, persistentSingleTabManager, query, queryEqual, refEqual, runTransaction, serverTimestamp, setDoc, setIndexConfiguration, setLogLevel, snapshotEqual, startAfter, startAt, sum, terminate, updateDoc, vector, waitForPendingWrites, where, writeBatch };
|