@firebase/firestore 4.7.7-canary.3418ef807 → 4.7.7-canary.4d2fc6e82
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/util/misc.d.ts +2 -0
- package/dist/index.cjs.js +153 -145
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm2017.js +153 -145
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.node.cjs.js +52 -41
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +52 -41
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +164 -156
- package/dist/index.rn.js.map +1 -1
- package/dist/lite/firestore/src/util/misc.d.ts +2 -0
- package/dist/lite/index.browser.esm2017.js +157 -127
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.cjs.js +157 -127
- package/dist/lite/index.cjs.js.map +1 -1
- package/dist/lite/index.node.cjs.js +127 -97
- package/dist/lite/index.node.cjs.js.map +1 -1
- package/dist/lite/index.node.mjs +127 -97
- package/dist/lite/index.node.mjs.map +1 -1
- package/dist/lite/index.rn.esm2017.js +150 -120
- package/dist/lite/index.rn.esm2017.js.map +1 -1
- package/package.json +9 -9
package/dist/index.rn.js
CHANGED
|
@@ -10,7 +10,7 @@ import { Integer as R, Md5 as V } from "@firebase/webchannel-wrapper/bloom-blob"
|
|
|
10
10
|
|
|
11
11
|
import { XhrIo as m, EventType as f, ErrorCode as g, createWebChannelTransport as p, getStatEventTarget as y, WebChannel as w, Event as S, Stat as b } from "@firebase/webchannel-wrapper/webchannel-blob";
|
|
12
12
|
|
|
13
|
-
const D = "@firebase/firestore", v = "4.7.7-canary.
|
|
13
|
+
const D = "@firebase/firestore", v = "4.7.7-canary.4d2fc6e82";
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* @license
|
|
@@ -72,7 +72,7 @@ User.MOCK_USER = new User("mock-user");
|
|
|
72
72
|
* See the License for the specific language governing permissions and
|
|
73
73
|
* limitations under the License.
|
|
74
74
|
*/
|
|
75
|
-
let C = "11.3.0-canary.
|
|
75
|
+
let C = "11.3.0-canary.4d2fc6e82";
|
|
76
76
|
|
|
77
77
|
/**
|
|
78
78
|
* @license
|
|
@@ -689,6 +689,31 @@ function __PRIVATE_randomBytes(e) {
|
|
|
689
689
|
return n;
|
|
690
690
|
}
|
|
691
691
|
|
|
692
|
+
/**
|
|
693
|
+
* @license
|
|
694
|
+
* Copyright 2023 Google LLC
|
|
695
|
+
*
|
|
696
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
697
|
+
* you may not use this file except in compliance with the License.
|
|
698
|
+
* You may obtain a copy of the License at
|
|
699
|
+
*
|
|
700
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
701
|
+
*
|
|
702
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
703
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
704
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
705
|
+
* See the License for the specific language governing permissions and
|
|
706
|
+
* limitations under the License.
|
|
707
|
+
*/
|
|
708
|
+
/**
|
|
709
|
+
* An instance of the Platform's 'TextEncoder' implementation.
|
|
710
|
+
*/ function __PRIVATE_newTextEncoder() {
|
|
711
|
+
return new TextEncoder;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
/**
|
|
715
|
+
* An instance of the Platform's 'TextDecoder' implementation.
|
|
716
|
+
*/
|
|
692
717
|
/**
|
|
693
718
|
* @license
|
|
694
719
|
* Copyright 2017 Google LLC
|
|
@@ -710,7 +735,8 @@ function __PRIVATE_randomBytes(e) {
|
|
|
710
735
|
*
|
|
711
736
|
* @internal
|
|
712
737
|
* Exported internally for testing purposes.
|
|
713
|
-
*/
|
|
738
|
+
*/
|
|
739
|
+
class __PRIVATE_AutoId {
|
|
714
740
|
static newId() {
|
|
715
741
|
// Alphanumeric characters
|
|
716
742
|
const e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", t = 62 * Math.floor(256 / 62);
|
|
@@ -731,6 +757,16 @@ function __PRIVATE_primitiveComparator(e, t) {
|
|
|
731
757
|
return e < t ? -1 : e > t ? 1 : 0;
|
|
732
758
|
}
|
|
733
759
|
|
|
760
|
+
/** Compare strings in UTF-8 encoded byte order */ function __PRIVATE_compareUtf8Strings(e, t) {
|
|
761
|
+
// Convert the string to UTF-8 encoded bytes
|
|
762
|
+
const n = __PRIVATE_newTextEncoder().encode(e), r = __PRIVATE_newTextEncoder().encode(t);
|
|
763
|
+
for (let e = 0; e < Math.min(n.length, r.length); e++) {
|
|
764
|
+
const t = __PRIVATE_primitiveComparator(n[e], r[e]);
|
|
765
|
+
if (0 !== t) return t;
|
|
766
|
+
}
|
|
767
|
+
return __PRIVATE_primitiveComparator(n.length, r.length);
|
|
768
|
+
}
|
|
769
|
+
|
|
734
770
|
/** Helper to compare arrays using isEqual(). */ function __PRIVATE_arrayEquals(e, t, n) {
|
|
735
771
|
return e.length === t.length && e.every(((e, r) => n(e, t[r])));
|
|
736
772
|
}
|
|
@@ -1021,13 +1057,11 @@ class Timestamp {
|
|
|
1021
1057
|
const n = BasePath.compareSegments(e.get(r), t.get(r));
|
|
1022
1058
|
if (0 !== n) return n;
|
|
1023
1059
|
}
|
|
1024
|
-
return
|
|
1060
|
+
return __PRIVATE_primitiveComparator(e.length, t.length);
|
|
1025
1061
|
}
|
|
1026
1062
|
static compareSegments(e, t) {
|
|
1027
1063
|
const n = BasePath.isNumericId(e), r = BasePath.isNumericId(t);
|
|
1028
|
-
return n && !r ? -1 : !n && r ? 1 : n && r ? BasePath.extractNumericId(e).compare(BasePath.extractNumericId(t)) :
|
|
1029
|
-
// both non-numeric
|
|
1030
|
-
e < t ? -1 : e > t ? 1 : 0;
|
|
1064
|
+
return n && !r ? -1 : !n && r ? 1 : n && r ? BasePath.extractNumericId(e).compare(BasePath.extractNumericId(t)) : __PRIVATE_compareUtf8Strings(e, t);
|
|
1031
1065
|
}
|
|
1032
1066
|
// Checks if a segment is a numeric ID (starts with "__id" and ends with "__").
|
|
1033
1067
|
static isNumericId(e) {
|
|
@@ -1815,13 +1849,13 @@ class __PRIVATE_SimpleDbTransaction {
|
|
|
1815
1849
|
* within the key range or index.
|
|
1816
1850
|
*/ class __PRIVATE_IterationController {
|
|
1817
1851
|
constructor(e) {
|
|
1818
|
-
this.q = e, this.$ = !1, this.
|
|
1852
|
+
this.q = e, this.$ = !1, this.U = null;
|
|
1819
1853
|
}
|
|
1820
1854
|
get isDone() {
|
|
1821
1855
|
return this.$;
|
|
1822
1856
|
}
|
|
1823
|
-
get
|
|
1824
|
-
return this.
|
|
1857
|
+
get K() {
|
|
1858
|
+
return this.U;
|
|
1825
1859
|
}
|
|
1826
1860
|
set cursor(e) {
|
|
1827
1861
|
this.q = e;
|
|
@@ -1835,7 +1869,7 @@ class __PRIVATE_SimpleDbTransaction {
|
|
|
1835
1869
|
* This function can be called to skip to that next key, which could be
|
|
1836
1870
|
* an index or a primary key.
|
|
1837
1871
|
*/ W(e) {
|
|
1838
|
-
this.
|
|
1872
|
+
this.U = e;
|
|
1839
1873
|
}
|
|
1840
1874
|
/**
|
|
1841
1875
|
* Delete the current cursor value from the object store.
|
|
@@ -1994,7 +2028,7 @@ class __PRIVATE_SimpleDbTransaction {
|
|
|
1994
2028
|
const e = o.catch((e => (s.done(), PersistencePromise.reject(e))));
|
|
1995
2029
|
n.push(e);
|
|
1996
2030
|
}
|
|
1997
|
-
s.isDone ? r() : null === s.
|
|
2031
|
+
s.isDone ? r() : null === s.K ? i.continue() : i.continue(s.K);
|
|
1998
2032
|
};
|
|
1999
2033
|
})).next((() => PersistencePromise.waitFor(n)));
|
|
2000
2034
|
}
|
|
@@ -2180,7 +2214,7 @@ __PRIVATE_ListenSequence.ae = -1;
|
|
|
2180
2214
|
* limitations under the License.
|
|
2181
2215
|
*/
|
|
2182
2216
|
/** Sentinel value that sorts before any Mutation Batch ID. */
|
|
2183
|
-
const
|
|
2217
|
+
const U = -1;
|
|
2184
2218
|
|
|
2185
2219
|
/**
|
|
2186
2220
|
* Returns whether a variable is either undefined or null.
|
|
@@ -2216,7 +2250,7 @@ const K = -1;
|
|
|
2216
2250
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2217
2251
|
* See the License for the specific language governing permissions and
|
|
2218
2252
|
* limitations under the License.
|
|
2219
|
-
*/ const
|
|
2253
|
+
*/ const K = "";
|
|
2220
2254
|
|
|
2221
2255
|
/**
|
|
2222
2256
|
* Encodes a resource path into a IndexedDb-compatible string form.
|
|
@@ -2238,7 +2272,7 @@ function __PRIVATE_encodeResourcePath(e) {
|
|
|
2238
2272
|
n += "";
|
|
2239
2273
|
break;
|
|
2240
2274
|
|
|
2241
|
-
case
|
|
2275
|
+
case K:
|
|
2242
2276
|
n += "";
|
|
2243
2277
|
break;
|
|
2244
2278
|
|
|
@@ -2250,7 +2284,7 @@ function __PRIVATE_encodeResourcePath(e) {
|
|
|
2250
2284
|
}
|
|
2251
2285
|
|
|
2252
2286
|
/** Encodes a path separator into the given result */ function __PRIVATE_encodeSeparator(e) {
|
|
2253
|
-
return e +
|
|
2287
|
+
return e + K + "";
|
|
2254
2288
|
}
|
|
2255
2289
|
|
|
2256
2290
|
/**
|
|
@@ -2262,7 +2296,7 @@ function __PRIVATE_encodeResourcePath(e) {
|
|
|
2262
2296
|
// Event the empty path must encode as a path of at least length 2. A path
|
|
2263
2297
|
// with exactly 2 must be the empty path.
|
|
2264
2298
|
const t = e.length;
|
|
2265
|
-
if (__PRIVATE_hardAssert(t >= 2), 2 === t) return __PRIVATE_hardAssert(e.charAt(0) ===
|
|
2299
|
+
if (__PRIVATE_hardAssert(t >= 2), 2 === t) return __PRIVATE_hardAssert(e.charAt(0) === K && "" === e.charAt(1)),
|
|
2266
2300
|
ResourcePath.emptyPath();
|
|
2267
2301
|
// Escape characters cannot exist past the second-to-last position in the
|
|
2268
2302
|
// source value.
|
|
@@ -2271,7 +2305,7 @@ function __PRIVATE_encodeResourcePath(e) {
|
|
|
2271
2305
|
for (let i = 0; i < t; ) {
|
|
2272
2306
|
// The last two characters of a valid encoded path must be a separator, so
|
|
2273
2307
|
// there must be an end to this segment.
|
|
2274
|
-
const t = e.indexOf(
|
|
2308
|
+
const t = e.indexOf(K, i);
|
|
2275
2309
|
(t < 0 || t > __PRIVATE_lastReasonableEscapeIndex) && fail();
|
|
2276
2310
|
switch (e.charAt(t + 1)) {
|
|
2277
2311
|
case "":
|
|
@@ -2360,7 +2394,7 @@ function __PRIVATE_newDbDocumentMutationPrefixForPath(e, t) {
|
|
|
2360
2394
|
* there is no useful information to store as the value. The raw (unencoded)
|
|
2361
2395
|
* path cannot be stored because IndexedDb doesn't store prototype
|
|
2362
2396
|
* information.
|
|
2363
|
-
*/ const ee = {}, te = "documentMutations", ne = "remoteDocumentsV14", re = [ "prefixPath", "collectionGroup", "readTime", "documentId" ], ie = "documentKeyIndex", se = [ "prefixPath", "collectionGroup", "documentId" ], oe = "collectionGroupIndex", _e = [ "collectionGroup", "readTime", "prefixPath", "documentId" ], ae = "remoteDocumentGlobal", ue = "remoteDocumentGlobalKey", ce = "targets", le = "queryTargetsIndex", he = [ "canonicalId", "targetId" ], Pe = "targetDocuments", Te = [ "targetId", "path" ], Ie = "documentTargetsIndex", Ee = [ "path", "targetId" ], de = "targetGlobalKey", Ae = "targetGlobal", Re = "collectionParents", Ve = [ "collectionId", "parent" ], me = "clientMetadata", fe = "clientId", ge = "bundles", pe = "bundleId", ye = "namedQueries", we = "name", Se = "indexConfiguration", be = "indexId", De = "collectionGroupIndex", ve = "collectionGroup", Ce = "indexState", Fe = [ "indexId", "uid" ], Me = "sequenceNumberIndex", xe = [ "uid", "sequenceNumber" ], Oe = "indexEntries", Ne = [ "indexId", "uid", "arrayValue", "directionalValue", "orderedDocumentKey", "documentKey" ], Be = "documentKeyIndex", Le = [ "indexId", "uid", "orderedDocumentKey" ], ke = "documentOverlays", qe = [ "userId", "collectionPath", "documentId" ], Qe = "collectionPathOverlayIndex", $e = [ "userId", "collectionPath", "largestBatchId" ],
|
|
2397
|
+
*/ const ee = {}, te = "documentMutations", ne = "remoteDocumentsV14", re = [ "prefixPath", "collectionGroup", "readTime", "documentId" ], ie = "documentKeyIndex", se = [ "prefixPath", "collectionGroup", "documentId" ], oe = "collectionGroupIndex", _e = [ "collectionGroup", "readTime", "prefixPath", "documentId" ], ae = "remoteDocumentGlobal", ue = "remoteDocumentGlobalKey", ce = "targets", le = "queryTargetsIndex", he = [ "canonicalId", "targetId" ], Pe = "targetDocuments", Te = [ "targetId", "path" ], Ie = "documentTargetsIndex", Ee = [ "path", "targetId" ], de = "targetGlobalKey", Ae = "targetGlobal", Re = "collectionParents", Ve = [ "collectionId", "parent" ], me = "clientMetadata", fe = "clientId", ge = "bundles", pe = "bundleId", ye = "namedQueries", we = "name", Se = "indexConfiguration", be = "indexId", De = "collectionGroupIndex", ve = "collectionGroup", Ce = "indexState", Fe = [ "indexId", "uid" ], Me = "sequenceNumberIndex", xe = [ "uid", "sequenceNumber" ], Oe = "indexEntries", Ne = [ "indexId", "uid", "arrayValue", "directionalValue", "orderedDocumentKey", "documentKey" ], Be = "documentKeyIndex", Le = [ "indexId", "uid", "orderedDocumentKey" ], ke = "documentOverlays", qe = [ "userId", "collectionPath", "documentId" ], Qe = "collectionPathOverlayIndex", $e = [ "userId", "collectionPath", "largestBatchId" ], Ue = "collectionGroupOverlayIndex", Ke = [ "userId", "collectionGroup", "largestBatchId" ], We = "globals", Ge = "name", ze = [ ...[ ...[ ...[ ...[ j, J, te, W, ce, G, Ae, Pe ], me ], ae ], Re ], ge, ye ], je = [ ...ze, ke ], He = [ j, J, te, ne, ce, G, Ae, Pe, me, ae, Re, ge, ye, ke ], Je = He, Ye = [ ...Je, Se, Ce, Oe ], Ze = Ye, Xe = [ ...Ye, We ];
|
|
2364
2398
|
|
|
2365
2399
|
/**
|
|
2366
2400
|
* @license
|
|
@@ -3430,7 +3464,7 @@ function __PRIVATE_valueCompare(e, t) {
|
|
|
3430
3464
|
return __PRIVATE_compareTimestamps(__PRIVATE_getLocalWriteTime(e), __PRIVATE_getLocalWriteTime(t));
|
|
3431
3465
|
|
|
3432
3466
|
case 5 /* TypeOrder.StringValue */ :
|
|
3433
|
-
return
|
|
3467
|
+
return __PRIVATE_compareUtf8Strings(e.stringValue, t.stringValue);
|
|
3434
3468
|
|
|
3435
3469
|
case 6 /* TypeOrder.BlobValue */ :
|
|
3436
3470
|
return function __PRIVATE_compareBlobs(e, t) {
|
|
@@ -3478,7 +3512,7 @@ function __PRIVATE_valueCompare(e, t) {
|
|
|
3478
3512
|
// canonical IDs are independent of insertion order.
|
|
3479
3513
|
r.sort(), s.sort();
|
|
3480
3514
|
for (let e = 0; e < r.length && e < s.length; ++e) {
|
|
3481
|
-
const t =
|
|
3515
|
+
const t = __PRIVATE_compareUtf8Strings(r[e], s[e]);
|
|
3482
3516
|
if (0 !== t) return t;
|
|
3483
3517
|
const o = __PRIVATE_valueCompare(n[r[e]], i[s[e]]);
|
|
3484
3518
|
if (0 !== o) return o;
|
|
@@ -5890,32 +5924,6 @@ let mt = null;
|
|
|
5890
5924
|
* Sets the value of the `testingHooksSpi` object.
|
|
5891
5925
|
* @param instance the instance to set.
|
|
5892
5926
|
*/
|
|
5893
|
-
/**
|
|
5894
|
-
* @license
|
|
5895
|
-
* Copyright 2023 Google LLC
|
|
5896
|
-
*
|
|
5897
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5898
|
-
* you may not use this file except in compliance with the License.
|
|
5899
|
-
* You may obtain a copy of the License at
|
|
5900
|
-
*
|
|
5901
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
5902
|
-
*
|
|
5903
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
5904
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
5905
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
5906
|
-
* See the License for the specific language governing permissions and
|
|
5907
|
-
* limitations under the License.
|
|
5908
|
-
*/
|
|
5909
|
-
/**
|
|
5910
|
-
* An instance of the Platform's 'TextEncoder' implementation.
|
|
5911
|
-
*/
|
|
5912
|
-
function __PRIVATE_newTextEncoder() {
|
|
5913
|
-
return new TextEncoder;
|
|
5914
|
-
}
|
|
5915
|
-
|
|
5916
|
-
/**
|
|
5917
|
-
* An instance of the Platform's 'TextDecoder' implementation.
|
|
5918
|
-
*/
|
|
5919
5927
|
/**
|
|
5920
5928
|
* @license
|
|
5921
5929
|
* Copyright 2022 Google LLC
|
|
@@ -6288,13 +6296,13 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6288
6296
|
/** Keeps track of the documents to update since the last raised snapshot. */
|
|
6289
6297
|
this.Qe = __PRIVATE_mutableDocumentMap(), this.$e = __PRIVATE_documentTargetMap(),
|
|
6290
6298
|
/** A mapping of document keys to their set of target IDs. */
|
|
6291
|
-
this.
|
|
6299
|
+
this.Ue = __PRIVATE_documentTargetMap(),
|
|
6292
6300
|
/**
|
|
6293
6301
|
* A map of targets with existence filter mismatches. These targets are
|
|
6294
6302
|
* known to be inconsistent and their listens needs to be re-established by
|
|
6295
6303
|
* RemoteStore.
|
|
6296
6304
|
*/
|
|
6297
|
-
this.
|
|
6305
|
+
this.Ke = new SortedMap(__PRIVATE_primitiveComparator);
|
|
6298
6306
|
}
|
|
6299
6307
|
/**
|
|
6300
6308
|
* Processes and adds the DocumentWatchChange to the current set of changes.
|
|
@@ -6383,7 +6391,7 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6383
6391
|
// trigger re-run of the query.
|
|
6384
6392
|
this.Ye(t);
|
|
6385
6393
|
const e = 2 /* BloomFilterApplicationStatus.FalsePositive */ === i ? "TargetPurposeExistenceFilterMismatchBloom" /* TargetPurpose.ExistenceFilterMismatchBloom */ : "TargetPurposeExistenceFilterMismatch" /* TargetPurpose.ExistenceFilterMismatch */;
|
|
6386
|
-
this.
|
|
6394
|
+
this.Ke = this.Ke.insert(t, e);
|
|
6387
6395
|
}
|
|
6388
6396
|
null == mt || mt.rt(function __PRIVATE_createExistenceFilterMismatchInfoForTestingHooks(e, t, n, r, i) {
|
|
6389
6397
|
var s, o, _, a, u, c;
|
|
@@ -6495,7 +6503,7 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6495
6503
|
|
|
6496
6504
|
// TODO(gsoltis): Expand on this comment once GC is available in the JS
|
|
6497
6505
|
// client.
|
|
6498
|
-
this.
|
|
6506
|
+
this.Ue.forEach(((e, t) => {
|
|
6499
6507
|
let r = !0;
|
|
6500
6508
|
t.forEachWhile((e => {
|
|
6501
6509
|
const t = this.Xe(e);
|
|
@@ -6503,9 +6511,9 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6503
6511
|
!1);
|
|
6504
6512
|
})), r && (n = n.add(e));
|
|
6505
6513
|
})), this.Qe.forEach(((t, n) => n.setReadTime(e)));
|
|
6506
|
-
const r = new RemoteEvent(e, t, this.
|
|
6514
|
+
const r = new RemoteEvent(e, t, this.Ke, this.Qe, n);
|
|
6507
6515
|
return this.Qe = __PRIVATE_mutableDocumentMap(), this.$e = __PRIVATE_documentTargetMap(),
|
|
6508
|
-
this.
|
|
6516
|
+
this.Ue = __PRIVATE_documentTargetMap(), this.Ke = new SortedMap(__PRIVATE_primitiveComparator),
|
|
6509
6517
|
r;
|
|
6510
6518
|
}
|
|
6511
6519
|
/**
|
|
@@ -6517,7 +6525,7 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6517
6525
|
if (!this.Je(e)) return;
|
|
6518
6526
|
const n = this.ut(e, t.key) ? 2 /* ChangeType.Modified */ : 0 /* ChangeType.Added */;
|
|
6519
6527
|
this.He(e).xe(t.key, n), this.Qe = this.Qe.insert(t.key, t), this.$e = this.$e.insert(t.key, this._t(t.key).add(e)),
|
|
6520
|
-
this.
|
|
6528
|
+
this.Ue = this.Ue.insert(t.key, this.ct(t.key).add(e));
|
|
6521
6529
|
}
|
|
6522
6530
|
/**
|
|
6523
6531
|
* Removes the provided document from the target mapping. If the
|
|
@@ -6533,7 +6541,7 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6533
6541
|
this.ut(e, t) ? r.xe(t, 1 /* ChangeType.Removed */) :
|
|
6534
6542
|
// The document may have entered and left the target before we raised a
|
|
6535
6543
|
// snapshot, so we can just ignore the change.
|
|
6536
|
-
r.Oe(t), this.
|
|
6544
|
+
r.Oe(t), this.Ue = this.Ue.insert(t, this.ct(t).delete(e)), this.Ue = this.Ue.insert(t, this.ct(t).add(e)),
|
|
6537
6545
|
n && (this.Qe = this.Qe.insert(t, n));
|
|
6538
6546
|
}
|
|
6539
6547
|
removeTarget(e) {
|
|
@@ -6558,8 +6566,8 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6558
6566
|
return t || (t = new __PRIVATE_TargetState, this.qe.set(e, t)), t;
|
|
6559
6567
|
}
|
|
6560
6568
|
ct(e) {
|
|
6561
|
-
let t = this.
|
|
6562
|
-
return t || (t = new SortedSet(__PRIVATE_primitiveComparator), this.
|
|
6569
|
+
let t = this.Ue.get(e);
|
|
6570
|
+
return t || (t = new SortedSet(__PRIVATE_primitiveComparator), this.Ue = this.Ue.insert(e, t)),
|
|
6563
6571
|
t;
|
|
6564
6572
|
}
|
|
6565
6573
|
_t(e) {
|
|
@@ -7693,7 +7701,7 @@ function __PRIVATE_toDbIndexState(e, t, n, r) {
|
|
|
7693
7701
|
const o = IDBKeyRange.bound([ this.userId, t, n ], [ this.userId, t, Number.POSITIVE_INFINITY ],
|
|
7694
7702
|
/*lowerOpen=*/ !0);
|
|
7695
7703
|
return __PRIVATE_documentOverlayStore(e).Z({
|
|
7696
|
-
index:
|
|
7704
|
+
index: Ue,
|
|
7697
7705
|
range: o
|
|
7698
7706
|
}, ((e, t, n) => {
|
|
7699
7707
|
// We do not want to return partial batch overlays, even if the size
|
|
@@ -7954,10 +7962,10 @@ function __PRIVATE_unsignedNumLength(e) {
|
|
|
7954
7962
|
}
|
|
7955
7963
|
this.qt();
|
|
7956
7964
|
}
|
|
7957
|
-
|
|
7965
|
+
Ut(e) {
|
|
7958
7966
|
// Values are encoded with a single byte length prefix, followed by the
|
|
7959
7967
|
// actual value in big-endian format with leading 0 bytes dropped.
|
|
7960
|
-
const t = this.
|
|
7968
|
+
const t = this.Kt(e), n = __PRIVATE_unsignedNumLength(t);
|
|
7961
7969
|
this.Wt(1 + n), this.buffer[this.position++] = 255 & n;
|
|
7962
7970
|
// Write the length
|
|
7963
7971
|
for (let e = t.length - n; e < t.length; ++e) this.buffer[this.position++] = 255 & t[e];
|
|
@@ -7965,7 +7973,7 @@ function __PRIVATE_unsignedNumLength(e) {
|
|
|
7965
7973
|
Gt(e) {
|
|
7966
7974
|
// Values are encoded with a single byte length prefix, followed by the
|
|
7967
7975
|
// inverted value in big-endian format with leading 0 bytes dropped.
|
|
7968
|
-
const t = this.
|
|
7976
|
+
const t = this.Kt(e), n = __PRIVATE_unsignedNumLength(t);
|
|
7969
7977
|
this.Wt(1 + n), this.buffer[this.position++] = ~(255 & n);
|
|
7970
7978
|
// Write the length
|
|
7971
7979
|
for (let e = t.length - n; e < t.length; ++e) this.buffer[this.position++] = ~(255 & t[e]);
|
|
@@ -8000,7 +8008,7 @@ function __PRIVATE_unsignedNumLength(e) {
|
|
|
8000
8008
|
* -0.0 < 0.0
|
|
8001
8009
|
* all non-NaN < NaN
|
|
8002
8010
|
* NaN = NaN
|
|
8003
|
-
*/
|
|
8011
|
+
*/ Kt(e) {
|
|
8004
8012
|
const t =
|
|
8005
8013
|
/** Converts a JavaScript number to a byte array (using big endian encoding). */
|
|
8006
8014
|
function __PRIVATE_doubleToLongBits(e) {
|
|
@@ -8059,7 +8067,7 @@ class __PRIVATE_AscendingIndexByteEncoder {
|
|
|
8059
8067
|
this.Zt.Qt(e);
|
|
8060
8068
|
}
|
|
8061
8069
|
gt(e) {
|
|
8062
|
-
this.Zt.
|
|
8070
|
+
this.Zt.Ut(e);
|
|
8063
8071
|
}
|
|
8064
8072
|
Vt() {
|
|
8065
8073
|
this.Zt.zt();
|
|
@@ -9353,7 +9361,7 @@ class __PRIVATE_IndexedDbMutationQueue {
|
|
|
9353
9361
|
}
|
|
9354
9362
|
getHighestUnacknowledgedBatchId(e) {
|
|
9355
9363
|
const t = IDBKeyRange.upperBound([ this.userId, Number.POSITIVE_INFINITY ]);
|
|
9356
|
-
let n =
|
|
9364
|
+
let n = U;
|
|
9357
9365
|
return __PRIVATE_mutationsStore(e).Z({
|
|
9358
9366
|
index: Z,
|
|
9359
9367
|
range: t,
|
|
@@ -9363,7 +9371,7 @@ class __PRIVATE_IndexedDbMutationQueue {
|
|
|
9363
9371
|
})).next((() => n));
|
|
9364
9372
|
}
|
|
9365
9373
|
getAllMutationBatches(e) {
|
|
9366
|
-
const t = IDBKeyRange.bound([ this.userId,
|
|
9374
|
+
const t = IDBKeyRange.bound([ this.userId, U ], [ this.userId, Number.POSITIVE_INFINITY ]);
|
|
9367
9375
|
return __PRIVATE_mutationsStore(e).G(Z, t).next((e => e.map((e => __PRIVATE_fromDbMutationBatch(this.serializer, e)))));
|
|
9368
9376
|
}
|
|
9369
9377
|
getAllMutationBatchesAffectingDocumentKey(e, t) {
|
|
@@ -9489,7 +9497,7 @@ class __PRIVATE_IndexedDbMutationQueue {
|
|
|
9489
9497
|
Qn(e) {
|
|
9490
9498
|
return __PRIVATE_mutationQueuesStore(e).get(this.userId).next((e => e || {
|
|
9491
9499
|
userId: this.userId,
|
|
9492
|
-
lastAcknowledgedBatchId:
|
|
9500
|
+
lastAcknowledgedBatchId: U,
|
|
9493
9501
|
lastStreamToken: ""
|
|
9494
9502
|
}));
|
|
9495
9503
|
}
|
|
@@ -9568,14 +9576,14 @@ class __PRIVATE_TargetIdGenerator {
|
|
|
9568
9576
|
next() {
|
|
9569
9577
|
return this.$n += 2, this.$n;
|
|
9570
9578
|
}
|
|
9571
|
-
static
|
|
9579
|
+
static Un() {
|
|
9572
9580
|
// The target cache generator must return '2' in its first call to `next()`
|
|
9573
9581
|
// as there is no differentiation in the protocol layer between an unset
|
|
9574
9582
|
// number and the number '0'. If we were to sent a target with target ID
|
|
9575
9583
|
// '0', the backend would consider it unset and replace it with its own ID.
|
|
9576
9584
|
return new __PRIVATE_TargetIdGenerator(0);
|
|
9577
9585
|
}
|
|
9578
|
-
static
|
|
9586
|
+
static Kn() {
|
|
9579
9587
|
// Sync engine assigns target IDs for limbo document detection.
|
|
9580
9588
|
return new __PRIVATE_TargetIdGenerator(-1);
|
|
9581
9589
|
}
|
|
@@ -11064,7 +11072,7 @@ class __PRIVATE_DocReference {
|
|
|
11064
11072
|
return PersistencePromise.resolve(this.mutationQueue.length > i ? this.mutationQueue[i] : null);
|
|
11065
11073
|
}
|
|
11066
11074
|
getHighestUnacknowledgedBatchId() {
|
|
11067
|
-
return PersistencePromise.resolve(0 === this.mutationQueue.length ?
|
|
11075
|
+
return PersistencePromise.resolve(0 === this.mutationQueue.length ? U : this.Fr - 1);
|
|
11068
11076
|
}
|
|
11069
11077
|
getAllMutationBatches(e) {
|
|
11070
11078
|
return PersistencePromise.resolve(this.mutationQueue.slice());
|
|
@@ -11343,7 +11351,7 @@ class __PRIVATE_MemoryRemoteDocumentChangeBuffer extends RemoteDocumentChangeBuf
|
|
|
11343
11351
|
* A ordered bidirectional mapping between documents and the remote target
|
|
11344
11352
|
* IDs.
|
|
11345
11353
|
*/
|
|
11346
|
-
this.
|
|
11354
|
+
this.Ur = new __PRIVATE_ReferenceSet, this.targetCount = 0, this.Kr = __PRIVATE_TargetIdGenerator.Un();
|
|
11347
11355
|
}
|
|
11348
11356
|
forEachTarget(e, t) {
|
|
11349
11357
|
return this.Qr.forEach(((e, n) => t(n))), PersistencePromise.resolve();
|
|
@@ -11355,7 +11363,7 @@ class __PRIVATE_MemoryRemoteDocumentChangeBuffer extends RemoteDocumentChangeBuf
|
|
|
11355
11363
|
return PersistencePromise.resolve(this.$r);
|
|
11356
11364
|
}
|
|
11357
11365
|
allocateTargetId(e) {
|
|
11358
|
-
return this.highestTargetId = this.
|
|
11366
|
+
return this.highestTargetId = this.Kr.next(), PersistencePromise.resolve(this.highestTargetId);
|
|
11359
11367
|
}
|
|
11360
11368
|
setTargetsMetadata(e, t, n) {
|
|
11361
11369
|
return n && (this.lastRemoteSnapshotVersion = n), t > this.$r && (this.$r = t),
|
|
@@ -11364,7 +11372,7 @@ class __PRIVATE_MemoryRemoteDocumentChangeBuffer extends RemoteDocumentChangeBuf
|
|
|
11364
11372
|
zn(e) {
|
|
11365
11373
|
this.Qr.set(e.target, e);
|
|
11366
11374
|
const t = e.targetId;
|
|
11367
|
-
t > this.highestTargetId && (this.
|
|
11375
|
+
t > this.highestTargetId && (this.Kr = new __PRIVATE_TargetIdGenerator(t), this.highestTargetId = t),
|
|
11368
11376
|
e.sequenceNumber > this.$r && (this.$r = e.sequenceNumber);
|
|
11369
11377
|
}
|
|
11370
11378
|
addTargetData(e, t) {
|
|
@@ -11374,7 +11382,7 @@ class __PRIVATE_MemoryRemoteDocumentChangeBuffer extends RemoteDocumentChangeBuf
|
|
|
11374
11382
|
return this.zn(t), PersistencePromise.resolve();
|
|
11375
11383
|
}
|
|
11376
11384
|
removeTargetData(e, t) {
|
|
11377
|
-
return this.Qr.delete(t.target), this.
|
|
11385
|
+
return this.Qr.delete(t.target), this.Ur.br(t.targetId), this.targetCount -= 1,
|
|
11378
11386
|
PersistencePromise.resolve();
|
|
11379
11387
|
}
|
|
11380
11388
|
removeTargets(e, t, n) {
|
|
@@ -11393,24 +11401,24 @@ class __PRIVATE_MemoryRemoteDocumentChangeBuffer extends RemoteDocumentChangeBuf
|
|
|
11393
11401
|
return PersistencePromise.resolve(n);
|
|
11394
11402
|
}
|
|
11395
11403
|
addMatchingKeys(e, t, n) {
|
|
11396
|
-
return this.
|
|
11404
|
+
return this.Ur.yr(t, n), PersistencePromise.resolve();
|
|
11397
11405
|
}
|
|
11398
11406
|
removeMatchingKeys(e, t, n) {
|
|
11399
|
-
this.
|
|
11407
|
+
this.Ur.Sr(t, n);
|
|
11400
11408
|
const r = this.persistence.referenceDelegate, i = [];
|
|
11401
11409
|
return r && t.forEach((t => {
|
|
11402
11410
|
i.push(r.markPotentiallyOrphaned(e, t));
|
|
11403
11411
|
})), PersistencePromise.waitFor(i);
|
|
11404
11412
|
}
|
|
11405
11413
|
removeMatchingKeysForTargetId(e, t) {
|
|
11406
|
-
return this.
|
|
11414
|
+
return this.Ur.br(t), PersistencePromise.resolve();
|
|
11407
11415
|
}
|
|
11408
11416
|
getMatchingKeysForTargetId(e, t) {
|
|
11409
|
-
const n = this.
|
|
11417
|
+
const n = this.Ur.vr(t);
|
|
11410
11418
|
return PersistencePromise.resolve(n);
|
|
11411
11419
|
}
|
|
11412
11420
|
containsKey(e, t) {
|
|
11413
|
-
return PersistencePromise.resolve(this.
|
|
11421
|
+
return PersistencePromise.resolve(this.Ur.containsKey(t));
|
|
11414
11422
|
}
|
|
11415
11423
|
}
|
|
11416
11424
|
|
|
@@ -11767,7 +11775,7 @@ class __PRIVATE_MemoryLruDelegate {
|
|
|
11767
11775
|
});
|
|
11768
11776
|
t.createIndex(Qe, $e, {
|
|
11769
11777
|
unique: !1
|
|
11770
|
-
}), t.createIndex(
|
|
11778
|
+
}), t.createIndex(Ue, Ke, {
|
|
11771
11779
|
unique: !1
|
|
11772
11780
|
});
|
|
11773
11781
|
}(e);
|
|
@@ -11825,7 +11833,7 @@ class __PRIVATE_MemoryLruDelegate {
|
|
|
11825
11833
|
_i(e) {
|
|
11826
11834
|
const t = e.store(j), n = e.store(J);
|
|
11827
11835
|
return t.G().next((t => PersistencePromise.forEach(t, (t => {
|
|
11828
|
-
const r = IDBKeyRange.bound([ t.userId,
|
|
11836
|
+
const r = IDBKeyRange.bound([ t.userId, U ], [ t.userId, t.lastAcknowledgedBatchId ]);
|
|
11829
11837
|
return n.G(Z, r).next((n => PersistencePromise.forEach(n, (n => {
|
|
11830
11838
|
__PRIVATE_hardAssert(n.userId === t.userId);
|
|
11831
11839
|
const r = __PRIVATE_fromDbMutationBatch(this.serializer, n);
|
|
@@ -12206,7 +12214,7 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12206
12214
|
async shutdown() {
|
|
12207
12215
|
// The shutdown() operations are idempotent and can be called even when
|
|
12208
12216
|
// start() aborted (e.g. because it couldn't acquire the persistence lease).
|
|
12209
|
-
this.zr = !1, this.
|
|
12217
|
+
this.zr = !1, this.Ui(), this.Vi && (this.Vi.cancel(), this.Vi = null), this.Ki(),
|
|
12210
12218
|
this.Wi(),
|
|
12211
12219
|
// Use `SimpleDb.runTransaction` directly to avoid failing if another tab
|
|
12212
12220
|
// has obtained the primary lease.
|
|
@@ -12316,7 +12324,7 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12316
12324
|
this.wi())));
|
|
12317
12325
|
}, this.document.addEventListener("visibilitychange", this.Ri), this.inForeground = "visible" === this.document.visibilityState);
|
|
12318
12326
|
}
|
|
12319
|
-
|
|
12327
|
+
Ki() {
|
|
12320
12328
|
this.Ri && (this.document.removeEventListener("visibilitychange", this.Ri), this.Ri = null);
|
|
12321
12329
|
}
|
|
12322
12330
|
/**
|
|
@@ -12334,7 +12342,7 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12334
12342
|
// Note: In theory, this should be scheduled on the AsyncQueue since it
|
|
12335
12343
|
// accesses internal state. We execute this code directly during shutdown
|
|
12336
12344
|
// to make sure it gets a chance to run.
|
|
12337
|
-
this.
|
|
12345
|
+
this.Ui();
|
|
12338
12346
|
const e = /(?:Version|Mobile)\/1[456]/;
|
|
12339
12347
|
T() && (navigator.appVersion.match(e) || navigator.userAgent.match(e)) &&
|
|
12340
12348
|
// On Safari 14, 15, and 16, we do not run any cleanup actions as it might
|
|
@@ -12365,7 +12373,7 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12365
12373
|
/**
|
|
12366
12374
|
* Record client as zombied (a client that had its tab closed). Zombied
|
|
12367
12375
|
* clients are ignored during primary tab selection.
|
|
12368
|
-
*/
|
|
12376
|
+
*/ Ui() {
|
|
12369
12377
|
if (this.yi) try {
|
|
12370
12378
|
this.yi.setItem(this.Qi(this.clientId), String(Date.now()));
|
|
12371
12379
|
} catch (e) {
|
|
@@ -12981,7 +12989,7 @@ function __PRIVATE_localStoreGetLastRemoteSnapshotVersion(e) {
|
|
|
12981
12989
|
*/
|
|
12982
12990
|
function __PRIVATE_localStoreGetNextMutationBatch(e, t) {
|
|
12983
12991
|
const n = __PRIVATE_debugCast(e);
|
|
12984
|
-
return n.persistence.runTransaction("Get next mutation batch", "readonly", (e => (void 0 === t && (t =
|
|
12992
|
+
return n.persistence.runTransaction("Get next mutation batch", "readonly", (e => (void 0 === t && (t = U),
|
|
12985
12993
|
n.mutationQueue.getNextMutationBatchAfterBatchId(e, t))));
|
|
12986
12994
|
}
|
|
12987
12995
|
|
|
@@ -13229,7 +13237,7 @@ const $t = "firestore_targets";
|
|
|
13229
13237
|
* See the License for the specific language governing permissions and
|
|
13230
13238
|
* limitations under the License.
|
|
13231
13239
|
*/
|
|
13232
|
-
const
|
|
13240
|
+
const Ut = "SharedClientState";
|
|
13233
13241
|
|
|
13234
13242
|
/**
|
|
13235
13243
|
* Holds the state of a mutation batch, including its user ID, batch ID and
|
|
@@ -13247,7 +13255,7 @@ class __PRIVATE_MutationMetadata {
|
|
|
13247
13255
|
const r = JSON.parse(n);
|
|
13248
13256
|
let i, s = "object" == typeof r && -1 !== [ "pending", "acknowledged", "rejected" ].indexOf(r.state) && (void 0 === r.error || "object" == typeof r.error);
|
|
13249
13257
|
return s && r.error && (s = "string" == typeof r.error.message && "string" == typeof r.error.code,
|
|
13250
|
-
s && (i = new FirestoreError(r.error.code, r.error.message))), s ? new __PRIVATE_MutationMetadata(e, t, r.state, i) : (__PRIVATE_logError(
|
|
13258
|
+
s && (i = new FirestoreError(r.error.code, r.error.message))), s ? new __PRIVATE_MutationMetadata(e, t, r.state, i) : (__PRIVATE_logError(Ut, `Failed to parse mutation state for ID '${t}': ${n}`),
|
|
13251
13259
|
null);
|
|
13252
13260
|
}
|
|
13253
13261
|
bs() {
|
|
@@ -13278,7 +13286,7 @@ class __PRIVATE_QueryTargetMetadata {
|
|
|
13278
13286
|
const n = JSON.parse(t);
|
|
13279
13287
|
let r, i = "object" == typeof n && -1 !== [ "not-current", "current", "rejected" ].indexOf(n.state) && (void 0 === n.error || "object" == typeof n.error);
|
|
13280
13288
|
return i && n.error && (i = "string" == typeof n.error.message && "string" == typeof n.error.code,
|
|
13281
|
-
i && (r = new FirestoreError(n.error.code, n.error.message))), i ? new __PRIVATE_QueryTargetMetadata(e, n.state, r) : (__PRIVATE_logError(
|
|
13289
|
+
i && (r = new FirestoreError(n.error.code, n.error.message))), i ? new __PRIVATE_QueryTargetMetadata(e, n.state, r) : (__PRIVATE_logError(Ut, `Failed to parse target state for ID '${e}': ${t}`),
|
|
13282
13290
|
null);
|
|
13283
13291
|
}
|
|
13284
13292
|
bs() {
|
|
@@ -13308,7 +13316,7 @@ class __PRIVATE_QueryTargetMetadata {
|
|
|
13308
13316
|
let r = "object" == typeof n && n.activeTargetIds instanceof Array, i = __PRIVATE_targetIdSet();
|
|
13309
13317
|
for (let e = 0; r && e < n.activeTargetIds.length; ++e) r = isSafeInteger(n.activeTargetIds[e]),
|
|
13310
13318
|
i = i.add(n.activeTargetIds[e]);
|
|
13311
|
-
return r ? new __PRIVATE_RemoteClientState(e, i) : (__PRIVATE_logError(
|
|
13319
|
+
return r ? new __PRIVATE_RemoteClientState(e, i) : (__PRIVATE_logError(Ut, `Failed to parse client data for instance '${e}': ${t}`),
|
|
13312
13320
|
null);
|
|
13313
13321
|
}
|
|
13314
13322
|
}
|
|
@@ -13326,7 +13334,7 @@ class __PRIVATE_QueryTargetMetadata {
|
|
|
13326
13334
|
* Logs a warning and returns null if the format of the data is not valid.
|
|
13327
13335
|
*/ static Ss(e) {
|
|
13328
13336
|
const t = JSON.parse(e);
|
|
13329
|
-
return "object" == typeof t && -1 !== [ "Unknown", "Online", "Offline" ].indexOf(t.onlineState) && "string" == typeof t.clientId ? new __PRIVATE_SharedOnlineState(t.clientId, t.onlineState) : (__PRIVATE_logError(
|
|
13337
|
+
return "object" == typeof t && -1 !== [ "Unknown", "Online", "Offline" ].indexOf(t.onlineState) && "string" == typeof t.clientId ? new __PRIVATE_SharedOnlineState(t.clientId, t.onlineState) : (__PRIVATE_logError(Ut, `Failed to parse online state: ${e}`),
|
|
13330
13338
|
null);
|
|
13331
13339
|
}
|
|
13332
13340
|
}
|
|
@@ -13427,12 +13435,12 @@ class __PRIVATE_LocalClientState {
|
|
|
13427
13435
|
n && (this.xs = this.xs.insert(n.clientId, n));
|
|
13428
13436
|
}
|
|
13429
13437
|
}
|
|
13430
|
-
this.
|
|
13438
|
+
this.Us();
|
|
13431
13439
|
// Check if there is an existing online state and call the callback handler
|
|
13432
13440
|
// if applicable.
|
|
13433
13441
|
const t = this.storage.getItem(this.Qs);
|
|
13434
13442
|
if (t) {
|
|
13435
|
-
const e = this.
|
|
13443
|
+
const e = this.Ks(t);
|
|
13436
13444
|
e && this.Ws(e);
|
|
13437
13445
|
}
|
|
13438
13446
|
for (const e of this.Os) this.Ms(e);
|
|
@@ -13476,10 +13484,10 @@ class __PRIVATE_LocalClientState {
|
|
|
13476
13484
|
}
|
|
13477
13485
|
// If the query is listening to cache only, the target ID should not be registered with the
|
|
13478
13486
|
// local Firestore client as an active watch target.
|
|
13479
|
-
return t && this.Hs.Ds(e), this.
|
|
13487
|
+
return t && this.Hs.Ds(e), this.Us(), n;
|
|
13480
13488
|
}
|
|
13481
13489
|
removeLocalQueryTarget(e) {
|
|
13482
|
-
this.Hs.vs(e), this.
|
|
13490
|
+
this.Hs.vs(e), this.Us();
|
|
13483
13491
|
}
|
|
13484
13492
|
isLocalQueryTarget(e) {
|
|
13485
13493
|
return this.Hs.activeTargetIds.has(e);
|
|
@@ -13509,20 +13517,20 @@ class __PRIVATE_LocalClientState {
|
|
|
13509
13517
|
}
|
|
13510
13518
|
getItem(e) {
|
|
13511
13519
|
const t = this.storage.getItem(e);
|
|
13512
|
-
return __PRIVATE_logDebug(
|
|
13520
|
+
return __PRIVATE_logDebug(Ut, "READ", e, t), t;
|
|
13513
13521
|
}
|
|
13514
13522
|
setItem(e, t) {
|
|
13515
|
-
__PRIVATE_logDebug(
|
|
13523
|
+
__PRIVATE_logDebug(Ut, "SET", e, t), this.storage.setItem(e, t);
|
|
13516
13524
|
}
|
|
13517
13525
|
removeItem(e) {
|
|
13518
|
-
__PRIVATE_logDebug(
|
|
13526
|
+
__PRIVATE_logDebug(Ut, "REMOVE", e), this.storage.removeItem(e);
|
|
13519
13527
|
}
|
|
13520
13528
|
Ms(e) {
|
|
13521
13529
|
// Note: The function is typed to take Event to be interface-compatible with
|
|
13522
13530
|
// `Window.addEventListener`.
|
|
13523
13531
|
const t = e;
|
|
13524
13532
|
if (t.storageArea === this.storage) {
|
|
13525
|
-
if (__PRIVATE_logDebug(
|
|
13533
|
+
if (__PRIVATE_logDebug(Ut, "EVENT", t.key, t.newValue), t.key === this.Ns) return void __PRIVATE_logError("Received WebStorage notification for local change. Another client might have garbage-collected our state");
|
|
13526
13534
|
this.Ti.enqueueRetryable((async () => {
|
|
13527
13535
|
if (this.started) {
|
|
13528
13536
|
if (null !== t.key) if (this.Ls.test(t.key)) {
|
|
@@ -13546,7 +13554,7 @@ class __PRIVATE_LocalClientState {
|
|
|
13546
13554
|
}
|
|
13547
13555
|
} else if (t.key === this.Qs) {
|
|
13548
13556
|
if (null !== t.newValue) {
|
|
13549
|
-
const e = this.
|
|
13557
|
+
const e = this.Ks(t.newValue);
|
|
13550
13558
|
if (e) return this.Ws(e);
|
|
13551
13559
|
}
|
|
13552
13560
|
} else if (t.key === this.Bs) {
|
|
@@ -13556,7 +13564,7 @@ class __PRIVATE_LocalClientState {
|
|
|
13556
13564
|
const n = JSON.parse(e);
|
|
13557
13565
|
__PRIVATE_hardAssert("number" == typeof n), t = n;
|
|
13558
13566
|
} catch (e) {
|
|
13559
|
-
__PRIVATE_logError(
|
|
13567
|
+
__PRIVATE_logError(Ut, "Failed to read sequence number from WebStorage", e);
|
|
13560
13568
|
}
|
|
13561
13569
|
return t;
|
|
13562
13570
|
}
|
|
@@ -13577,7 +13585,7 @@ class __PRIVATE_LocalClientState {
|
|
|
13577
13585
|
get Hs() {
|
|
13578
13586
|
return this.xs.get(this.Cs);
|
|
13579
13587
|
}
|
|
13580
|
-
|
|
13588
|
+
Us() {
|
|
13581
13589
|
this.setItem(this.Ns, this.Hs.bs());
|
|
13582
13590
|
}
|
|
13583
13591
|
zs(e, t, n) {
|
|
@@ -13634,7 +13642,7 @@ class __PRIVATE_LocalClientState {
|
|
|
13634
13642
|
/**
|
|
13635
13643
|
* Parses an online state from WebStorage. Returns 'null' if the value
|
|
13636
13644
|
* could not be parsed.
|
|
13637
|
-
*/
|
|
13645
|
+
*/ Ks(e) {
|
|
13638
13646
|
return __PRIVATE_SharedOnlineState.Ss(e);
|
|
13639
13647
|
}
|
|
13640
13648
|
_o(e) {
|
|
@@ -13642,7 +13650,7 @@ class __PRIVATE_LocalClientState {
|
|
|
13642
13650
|
}
|
|
13643
13651
|
async io(e) {
|
|
13644
13652
|
if (e.user.uid === this.currentUser.uid) return this.syncEngine.uo(e.batchId, e.state, e.error);
|
|
13645
|
-
__PRIVATE_logDebug(
|
|
13653
|
+
__PRIVATE_logDebug(Ut, `Ignoring mutation for non-active user ${e.user.uid}`);
|
|
13646
13654
|
}
|
|
13647
13655
|
oo(e) {
|
|
13648
13656
|
return this.syncEngine.co(e.targetId, e.state, e.error);
|
|
@@ -13762,7 +13770,7 @@ class __PRIVATE_MemorySharedClientState {
|
|
|
13762
13770
|
* limitations under the License.
|
|
13763
13771
|
*/
|
|
13764
13772
|
// References to `window` are guarded by BrowserConnectivityMonitor.isAvailable()
|
|
13765
|
-
/* eslint-disable no-restricted-globals */ const
|
|
13773
|
+
/* eslint-disable no-restricted-globals */ const Kt = "ConnectivityMonitor";
|
|
13766
13774
|
|
|
13767
13775
|
/**
|
|
13768
13776
|
* Browser implementation of ConnectivityMonitor.
|
|
@@ -13780,11 +13788,11 @@ class __PRIVATE_MemorySharedClientState {
|
|
|
13780
13788
|
window.addEventListener("online", this.Io), window.addEventListener("offline", this.Ao);
|
|
13781
13789
|
}
|
|
13782
13790
|
Eo() {
|
|
13783
|
-
__PRIVATE_logDebug(
|
|
13791
|
+
__PRIVATE_logDebug(Kt, "Network connectivity changed: AVAILABLE");
|
|
13784
13792
|
for (const e of this.Vo) e(0 /* NetworkStatus.AVAILABLE */);
|
|
13785
13793
|
}
|
|
13786
13794
|
Ro() {
|
|
13787
|
-
__PRIVATE_logDebug(
|
|
13795
|
+
__PRIVATE_logDebug(Kt, "Network connectivity changed: UNAVAILABLE");
|
|
13788
13796
|
for (const e of this.Vo) e(1 /* NetworkStatus.UNAVAILABLE */);
|
|
13789
13797
|
}
|
|
13790
13798
|
// TODO(chenbrian): Consider passing in window either into this component or
|
|
@@ -13982,10 +13990,10 @@ class __PRIVATE_RestConnection {
|
|
|
13982
13990
|
$o() {
|
|
13983
13991
|
this.Bo();
|
|
13984
13992
|
}
|
|
13985
|
-
|
|
13993
|
+
Uo(e) {
|
|
13986
13994
|
this.ko(e);
|
|
13987
13995
|
}
|
|
13988
|
-
|
|
13996
|
+
Ko(e) {
|
|
13989
13997
|
this.qo(e);
|
|
13990
13998
|
}
|
|
13991
13999
|
}
|
|
@@ -14137,10 +14145,10 @@ class __PRIVATE_WebChannelConnection extends __PRIVATE_RestConnection {
|
|
|
14137
14145
|
h || (__PRIVATE_logDebug(jt, `RPC '${e}' stream ${r} transport opened.`), P.Qo());
|
|
14138
14146
|
})), __PRIVATE_unguardedEventListen(c, w.EventType.CLOSE, (() => {
|
|
14139
14147
|
h || (h = !0, __PRIVATE_logDebug(jt, `RPC '${e}' stream ${r} transport closed`),
|
|
14140
|
-
P.
|
|
14148
|
+
P.Uo());
|
|
14141
14149
|
})), __PRIVATE_unguardedEventListen(c, w.EventType.ERROR, (t => {
|
|
14142
14150
|
h || (h = !0, __PRIVATE_logWarn(jt, `RPC '${e}' stream ${r} transport errored:`, t),
|
|
14143
|
-
P.
|
|
14151
|
+
P.Uo(new FirestoreError(M.UNAVAILABLE, "The operation could not be completed")));
|
|
14144
14152
|
})), __PRIVATE_unguardedEventListen(c, w.EventType.MESSAGE, (t => {
|
|
14145
14153
|
var n;
|
|
14146
14154
|
if (!h) {
|
|
@@ -14171,8 +14179,8 @@ class __PRIVATE_WebChannelConnection extends __PRIVATE_RestConnection {
|
|
|
14171
14179
|
}(t), i = o.message;
|
|
14172
14180
|
void 0 === n && (n = M.INTERNAL, i = "Unknown error status: " + t + " with message " + o.message),
|
|
14173
14181
|
// Mark closed so no further events are propagated
|
|
14174
|
-
h = !0, P.
|
|
14175
|
-
} else __PRIVATE_logDebug(jt, `RPC '${e}' stream ${r} received:`, i), P.
|
|
14182
|
+
h = !0, P.Uo(new FirestoreError(n, i)), c.close();
|
|
14183
|
+
} else __PRIVATE_logDebug(jt, `RPC '${e}' stream ${r} received:`, i), P.Ko(i);
|
|
14176
14184
|
}
|
|
14177
14185
|
})), __PRIVATE_unguardedEventListen(o, S.STAT_EVENT, (t => {
|
|
14178
14186
|
t.stat === b.PROXY ? __PRIVATE_logDebug(jt, `RPC '${e}' stream ${r} detected buffering proxy`) : t.stat === b.NOPROXY && __PRIVATE_logDebug(jt, `RPC '${e}' stream ${r} detected no buffering proxy`);
|
|
@@ -14907,7 +14915,7 @@ class __PRIVATE_RemoteStoreImpl {
|
|
|
14907
14915
|
* purely based on order, and so we can just shift() writes from the front of
|
|
14908
14916
|
* the writePipeline as we receive responses.
|
|
14909
14917
|
*/
|
|
14910
|
-
this.
|
|
14918
|
+
this.U_ = [],
|
|
14911
14919
|
/**
|
|
14912
14920
|
* A mapping of watched targets that the client cares about tracking and the
|
|
14913
14921
|
* user has explicitly called a 'listen' for this target.
|
|
@@ -14917,7 +14925,7 @@ class __PRIVATE_RemoteStoreImpl {
|
|
|
14917
14925
|
* to the server. The targets removed with unlistens are removed eagerly
|
|
14918
14926
|
* without waiting for confirmation from the listen stream.
|
|
14919
14927
|
*/
|
|
14920
|
-
this.
|
|
14928
|
+
this.K_ = new Map,
|
|
14921
14929
|
/**
|
|
14922
14930
|
* A set of reasons for why the RemoteStore may be offline. If empty, the
|
|
14923
14931
|
* RemoteStore may start its network connections.
|
|
@@ -14964,9 +14972,9 @@ async function __PRIVATE_enableNetworkInternal(e) {
|
|
|
14964
14972
|
*/
|
|
14965
14973
|
function __PRIVATE_remoteStoreListen(e, t) {
|
|
14966
14974
|
const n = __PRIVATE_debugCast(e);
|
|
14967
|
-
n.
|
|
14975
|
+
n.K_.has(t.targetId) || (
|
|
14968
14976
|
// Mark this as something the client is currently listening for.
|
|
14969
|
-
n.
|
|
14977
|
+
n.K_.set(t.targetId, t), __PRIVATE_shouldStartWatchStream(n) ?
|
|
14970
14978
|
// The listen will be sent in onWatchStreamOpen
|
|
14971
14979
|
__PRIVATE_startWatchStream(n) : __PRIVATE_ensureWatchStream(n).c_() && __PRIVATE_sendWatchRequest(n, t));
|
|
14972
14980
|
}
|
|
@@ -14976,7 +14984,7 @@ function __PRIVATE_remoteStoreListen(e, t) {
|
|
|
14976
14984
|
* not being listened to.
|
|
14977
14985
|
*/ function __PRIVATE_remoteStoreUnlisten(e, t) {
|
|
14978
14986
|
const n = __PRIVATE_debugCast(e), r = __PRIVATE_ensureWatchStream(n);
|
|
14979
|
-
n.
|
|
14987
|
+
n.K_.delete(t), r.c_() && __PRIVATE_sendUnwatchRequest(n, t), 0 === n.K_.size && (r.c_() ? r.P_() : __PRIVATE_canUseNetwork(n) &&
|
|
14980
14988
|
// Revert to OnlineState.Unknown if the watch stream is not open and we
|
|
14981
14989
|
// have no listeners, since without any listens to send we cannot
|
|
14982
14990
|
// confirm if the stream is healthy and upgrade to OnlineState.Online.
|
|
@@ -15005,7 +15013,7 @@ function __PRIVATE_remoteStoreListen(e, t) {
|
|
|
15005
15013
|
function __PRIVATE_startWatchStream(e) {
|
|
15006
15014
|
e.H_ = new __PRIVATE_WatchChangeAggregator({
|
|
15007
15015
|
getRemoteKeysForTarget: t => e.remoteSyncer.getRemoteKeysForTarget(t),
|
|
15008
|
-
lt: t => e.
|
|
15016
|
+
lt: t => e.K_.get(t) || null,
|
|
15009
15017
|
it: () => e.datastore.serializer.databaseId
|
|
15010
15018
|
}), __PRIVATE_ensureWatchStream(e).start(), e.j_.B_();
|
|
15011
15019
|
}
|
|
@@ -15014,7 +15022,7 @@ function __PRIVATE_startWatchStream(e) {
|
|
|
15014
15022
|
* Returns whether the watch stream should be started because it's necessary
|
|
15015
15023
|
* and has not yet been started.
|
|
15016
15024
|
*/ function __PRIVATE_shouldStartWatchStream(e) {
|
|
15017
|
-
return __PRIVATE_canUseNetwork(e) && !__PRIVATE_ensureWatchStream(e).u_() && e.
|
|
15025
|
+
return __PRIVATE_canUseNetwork(e) && !__PRIVATE_ensureWatchStream(e).u_() && e.K_.size > 0;
|
|
15018
15026
|
}
|
|
15019
15027
|
|
|
15020
15028
|
function __PRIVATE_canUseNetwork(e) {
|
|
@@ -15031,7 +15039,7 @@ async function __PRIVATE_onWatchStreamConnected(e) {
|
|
|
15031
15039
|
}
|
|
15032
15040
|
|
|
15033
15041
|
async function __PRIVATE_onWatchStreamOpen(e) {
|
|
15034
|
-
e.
|
|
15042
|
+
e.K_.forEach(((t, n) => {
|
|
15035
15043
|
__PRIVATE_sendWatchRequest(e, t);
|
|
15036
15044
|
}));
|
|
15037
15045
|
}
|
|
@@ -15058,7 +15066,7 @@ async function __PRIVATE_onWatchStreamChange(e, t, n) {
|
|
|
15058
15066
|
const n = t.cause;
|
|
15059
15067
|
for (const r of t.targetIds)
|
|
15060
15068
|
// A watched target might have been removed already.
|
|
15061
|
-
e.
|
|
15069
|
+
e.K_.has(r) && (await e.remoteSyncer.rejectListen(r, n), e.K_.delete(r), e.H_.removeTarget(r));
|
|
15062
15070
|
}
|
|
15063
15071
|
/**
|
|
15064
15072
|
* Attempts to fill our write pipeline with writes from the LocalStore.
|
|
@@ -15088,21 +15096,21 @@ async function __PRIVATE_onWatchStreamChange(e, t, n) {
|
|
|
15088
15096
|
// persistent view of these when applying the completed RemoteEvent.
|
|
15089
15097
|
return n.targetChanges.forEach(((n, r) => {
|
|
15090
15098
|
if (n.resumeToken.approximateByteSize() > 0) {
|
|
15091
|
-
const i = e.
|
|
15099
|
+
const i = e.K_.get(r);
|
|
15092
15100
|
// A watched target might have been removed already.
|
|
15093
|
-
i && e.
|
|
15101
|
+
i && e.K_.set(r, i.withResumeToken(n.resumeToken, t));
|
|
15094
15102
|
}
|
|
15095
15103
|
})),
|
|
15096
15104
|
// Re-establish listens for the targets that have been invalidated by
|
|
15097
15105
|
// existence filter mismatches.
|
|
15098
15106
|
n.targetMismatches.forEach(((t, n) => {
|
|
15099
|
-
const r = e.
|
|
15107
|
+
const r = e.K_.get(t);
|
|
15100
15108
|
if (!r)
|
|
15101
15109
|
// A watched target might have been removed already.
|
|
15102
15110
|
return;
|
|
15103
15111
|
// Clear the resume token for the target, since we're in a known mismatch
|
|
15104
15112
|
// state.
|
|
15105
|
-
e.
|
|
15113
|
+
e.K_.set(t, r.withResumeToken(ByteString.EMPTY_BYTE_STRING, r.snapshotVersion)),
|
|
15106
15114
|
// Cause a hard reset by unwatching and rewatching immediately, but
|
|
15107
15115
|
// deliberately don't send a resume token so that we get a full update.
|
|
15108
15116
|
__PRIVATE_sendUnwatchRequest(e, t);
|
|
@@ -15153,11 +15161,11 @@ async function __PRIVATE_onWatchStreamChange(e, t, n) {
|
|
|
15153
15161
|
|
|
15154
15162
|
async function __PRIVATE_fillWritePipeline(e) {
|
|
15155
15163
|
const t = __PRIVATE_debugCast(e), n = __PRIVATE_ensureWriteStream(t);
|
|
15156
|
-
let r = t.
|
|
15164
|
+
let r = t.U_.length > 0 ? t.U_[t.U_.length - 1].batchId : U;
|
|
15157
15165
|
for (;__PRIVATE_canAddToWritePipeline(t); ) try {
|
|
15158
15166
|
const e = await __PRIVATE_localStoreGetNextMutationBatch(t.localStore, r);
|
|
15159
15167
|
if (null === e) {
|
|
15160
|
-
0 === t.
|
|
15168
|
+
0 === t.U_.length && n.P_();
|
|
15161
15169
|
break;
|
|
15162
15170
|
}
|
|
15163
15171
|
r = e.batchId, __PRIVATE_addToWritePipeline(t, e);
|
|
@@ -15171,20 +15179,20 @@ async function __PRIVATE_fillWritePipeline(e) {
|
|
|
15171
15179
|
* Returns true if we can add to the write pipeline (i.e. the network is
|
|
15172
15180
|
* enabled and the write pipeline is not full).
|
|
15173
15181
|
*/ function __PRIVATE_canAddToWritePipeline(e) {
|
|
15174
|
-
return __PRIVATE_canUseNetwork(e) && e.
|
|
15182
|
+
return __PRIVATE_canUseNetwork(e) && e.U_.length < 10;
|
|
15175
15183
|
}
|
|
15176
15184
|
|
|
15177
15185
|
/**
|
|
15178
15186
|
* Queues additional writes to be sent to the write stream, sending them
|
|
15179
15187
|
* immediately if the write stream is established.
|
|
15180
15188
|
*/ function __PRIVATE_addToWritePipeline(e, t) {
|
|
15181
|
-
e.
|
|
15189
|
+
e.U_.push(t);
|
|
15182
15190
|
const n = __PRIVATE_ensureWriteStream(e);
|
|
15183
15191
|
n.c_() && n.S_ && n.b_(t.mutations);
|
|
15184
15192
|
}
|
|
15185
15193
|
|
|
15186
15194
|
function __PRIVATE_shouldStartWriteStream(e) {
|
|
15187
|
-
return __PRIVATE_canUseNetwork(e) && !__PRIVATE_ensureWriteStream(e).u_() && e.
|
|
15195
|
+
return __PRIVATE_canUseNetwork(e) && !__PRIVATE_ensureWriteStream(e).u_() && e.U_.length > 0;
|
|
15188
15196
|
}
|
|
15189
15197
|
|
|
15190
15198
|
function __PRIVATE_startWriteStream(e) {
|
|
@@ -15198,11 +15206,11 @@ async function __PRIVATE_onWriteStreamOpen(e) {
|
|
|
15198
15206
|
async function __PRIVATE_onWriteHandshakeComplete(e) {
|
|
15199
15207
|
const t = __PRIVATE_ensureWriteStream(e);
|
|
15200
15208
|
// Send the write pipeline now that the stream is established.
|
|
15201
|
-
for (const n of e.
|
|
15209
|
+
for (const n of e.U_) t.b_(n.mutations);
|
|
15202
15210
|
}
|
|
15203
15211
|
|
|
15204
15212
|
async function __PRIVATE_onMutationResult(e, t, n) {
|
|
15205
|
-
const r = e.
|
|
15213
|
+
const r = e.U_.shift(), i = MutationBatchResult.from(r, t, n);
|
|
15206
15214
|
await __PRIVATE_executeWithRecovery(e, (() => e.remoteSyncer.applySuccessfulWrite(i))),
|
|
15207
15215
|
// It's possible that with the completion of this mutation another
|
|
15208
15216
|
// slot has freed up.
|
|
@@ -15222,7 +15230,7 @@ async function __PRIVATE_onWriteStreamClose(e, t) {
|
|
|
15222
15230
|
}(t.code)) {
|
|
15223
15231
|
// This was a permanent error, the request itself was the problem
|
|
15224
15232
|
// so it's not going to succeed if we resend it.
|
|
15225
|
-
const n = e.
|
|
15233
|
+
const n = e.U_.shift();
|
|
15226
15234
|
// In this case it's also unlikely that the server itself is melting
|
|
15227
15235
|
// down -- this was just a bad request so inhibit backoff on the next
|
|
15228
15236
|
// restart.
|
|
@@ -15321,8 +15329,8 @@ async function __PRIVATE_remoteStoreHandleCredentialChange(e, t) {
|
|
|
15321
15329
|
}), e.G_.push((async t => {
|
|
15322
15330
|
t ? (e.Y_.h_(),
|
|
15323
15331
|
// This will start the write stream if necessary.
|
|
15324
|
-
await __PRIVATE_fillWritePipeline(e)) : (await e.Y_.stop(), e.
|
|
15325
|
-
e.
|
|
15332
|
+
await __PRIVATE_fillWritePipeline(e)) : (await e.Y_.stop(), e.U_.length > 0 && (__PRIVATE_logDebug(Jt, `Stopping write stream with ${e.U_.length} pending writes`),
|
|
15333
|
+
e.U_ = []));
|
|
15326
15334
|
}))), e.Y_;
|
|
15327
15335
|
}
|
|
15328
15336
|
|
|
@@ -16336,11 +16344,11 @@ const Xt = "SyncEngine";
|
|
|
16336
16344
|
* Keeps track of the information about an active limbo resolution for each
|
|
16337
16345
|
* active target ID that was started for the purpose of limbo resolution.
|
|
16338
16346
|
*/
|
|
16339
|
-
this.
|
|
16347
|
+
this.Ua = new Map, this.Ka = new __PRIVATE_ReferenceSet,
|
|
16340
16348
|
/** Stores user completion handlers, indexed by User and BatchId. */
|
|
16341
16349
|
this.Wa = {},
|
|
16342
16350
|
/** Stores user callbacks waiting for all pending writes to be acknowledged. */
|
|
16343
|
-
this.Ga = new Map, this.za = __PRIVATE_TargetIdGenerator.
|
|
16351
|
+
this.Ga = new Map, this.za = __PRIVATE_TargetIdGenerator.Kn(), this.onlineState = "Unknown" /* OnlineState.Unknown */ ,
|
|
16344
16352
|
// The primary state is set to `true` or `false` immediately after Firestore
|
|
16345
16353
|
// startup. In the interim, a client should only be considered primary if
|
|
16346
16354
|
// `isPrimary` is true.
|
|
@@ -16520,7 +16528,7 @@ async function __PRIVATE_allocateTargetAndMaybeListen(e, t, n, r) {
|
|
|
16520
16528
|
const e = await __PRIVATE_localStoreApplyRemoteEventToLocalCache(n.localStore, t);
|
|
16521
16529
|
// Update `receivedDocument` as appropriate for any limbo targets.
|
|
16522
16530
|
t.targetChanges.forEach(((e, t) => {
|
|
16523
|
-
const r = n.
|
|
16531
|
+
const r = n.Ua.get(t);
|
|
16524
16532
|
r && (
|
|
16525
16533
|
// Since this is a limbo resolution lookup, it's for a single document
|
|
16526
16534
|
// and it could be added, modified, or removed, but not a combination.
|
|
@@ -16574,7 +16582,7 @@ async function __PRIVATE_allocateTargetAndMaybeListen(e, t, n, r) {
|
|
|
16574
16582
|
const r = __PRIVATE_debugCast(e);
|
|
16575
16583
|
// PORTING NOTE: Multi-tab only.
|
|
16576
16584
|
r.sharedClientState.updateQueryState(t, "rejected", n);
|
|
16577
|
-
const i = r.
|
|
16585
|
+
const i = r.Ua.get(t), s = i && i.key;
|
|
16578
16586
|
if (s) {
|
|
16579
16587
|
// TODO(klimt): We really only should do the following on permission
|
|
16580
16588
|
// denied errors, but we don't have the cause code here.
|
|
@@ -16596,7 +16604,7 @@ async function __PRIVATE_allocateTargetAndMaybeListen(e, t, n, r) {
|
|
|
16596
16604
|
// RemoteEvent. If `applyRemoteEvent()` throws, we want to re-listen to
|
|
16597
16605
|
// this query when the RemoteStore restarts the Watch stream, which should
|
|
16598
16606
|
// re-trigger the target failure.
|
|
16599
|
-
r.$a = r.$a.remove(s), r.
|
|
16607
|
+
r.$a = r.$a.remove(s), r.Ua.delete(t), __PRIVATE_pumpEnqueuedLimboResolutions(r);
|
|
16600
16608
|
} else await __PRIVATE_localStoreReleaseTarget(r.localStore, t,
|
|
16601
16609
|
/* keepPersistedTargetData */ !1).then((() => __PRIVATE_removeAndCleanupTarget(r, t, n))).catch(__PRIVATE_ignoreIfPrimaryLeaseLoss);
|
|
16602
16610
|
}
|
|
@@ -16655,7 +16663,7 @@ async function __PRIVATE_syncEngineRejectFailedWrite(e, t, n) {
|
|
|
16655
16663
|
const t = __PRIVATE_debugCast(e);
|
|
16656
16664
|
return t.persistence.runTransaction("Get highest unacknowledged batch id", "readonly", (e => t.mutationQueue.getHighestUnacknowledgedBatchId(e)));
|
|
16657
16665
|
}(n.localStore);
|
|
16658
|
-
if (e ===
|
|
16666
|
+
if (e === U)
|
|
16659
16667
|
// Trigger the callback right away if there is no pending writes at the moment.
|
|
16660
16668
|
return void t.resolve();
|
|
16661
16669
|
const r = n.Ga.get(e) || [];
|
|
@@ -16690,8 +16698,8 @@ function __PRIVATE_removeAndCleanupTarget(e, t, n = null) {
|
|
|
16690
16698
|
e.sharedClientState.removeLocalQueryTarget(t);
|
|
16691
16699
|
for (const r of e.qa.get(t)) e.ka.delete(r), n && e.La.Ja(r, n);
|
|
16692
16700
|
if (e.qa.delete(t), e.isPrimaryClient) {
|
|
16693
|
-
e.
|
|
16694
|
-
e.
|
|
16701
|
+
e.Ka.br(t).forEach((t => {
|
|
16702
|
+
e.Ka.containsKey(t) ||
|
|
16695
16703
|
// We removed the last reference for this key
|
|
16696
16704
|
__PRIVATE_removeLimboTarget(e, t);
|
|
16697
16705
|
}));
|
|
@@ -16704,14 +16712,14 @@ function __PRIVATE_removeLimboTarget(e, t) {
|
|
|
16704
16712
|
// the key won't exist in `limboTargetsByKey`. Only do the cleanup if we still have the target.
|
|
16705
16713
|
const n = e.$a.get(t);
|
|
16706
16714
|
null !== n && (__PRIVATE_remoteStoreUnlisten(e.remoteStore, n), e.$a = e.$a.remove(t),
|
|
16707
|
-
e.
|
|
16715
|
+
e.Ua.delete(n), __PRIVATE_pumpEnqueuedLimboResolutions(e));
|
|
16708
16716
|
}
|
|
16709
16717
|
|
|
16710
16718
|
function __PRIVATE_updateTrackedLimbos(e, t, n) {
|
|
16711
|
-
for (const r of n) if (r instanceof __PRIVATE_AddedLimboDocument) e.
|
|
16719
|
+
for (const r of n) if (r instanceof __PRIVATE_AddedLimboDocument) e.Ka.addReference(r.key, t),
|
|
16712
16720
|
__PRIVATE_trackLimboChange(e, r); else if (r instanceof __PRIVATE_RemovedLimboDocument) {
|
|
16713
|
-
__PRIVATE_logDebug(Xt, "Document no longer in limbo: " + r.key), e.
|
|
16714
|
-
e.
|
|
16721
|
+
__PRIVATE_logDebug(Xt, "Document no longer in limbo: " + r.key), e.Ka.removeReference(r.key, t);
|
|
16722
|
+
e.Ka.containsKey(r.key) ||
|
|
16715
16723
|
// We removed the last reference for this key
|
|
16716
16724
|
__PRIVATE_removeLimboTarget(e, r.key);
|
|
16717
16725
|
} else fail();
|
|
@@ -16735,7 +16743,7 @@ function __PRIVATE_trackLimboChange(e, t) {
|
|
|
16735
16743
|
const t = e.Qa.values().next().value;
|
|
16736
16744
|
e.Qa.delete(t);
|
|
16737
16745
|
const n = new DocumentKey(ResourcePath.fromString(t)), r = e.za.next();
|
|
16738
|
-
e.
|
|
16746
|
+
e.Ua.set(r, new LimboResolution(n)), e.$a = e.$a.insert(n, r), __PRIVATE_remoteStoreListen(e.remoteStore, new TargetData(__PRIVATE_queryToTarget(__PRIVATE_newQueryForPath(n.path)), r, "TargetPurposeLimboResolution" /* TargetPurpose.LimboResolution */ , __PRIVATE_ListenSequence.ae));
|
|
16739
16747
|
}
|
|
16740
16748
|
}
|
|
16741
16749
|
|
|
@@ -16803,7 +16811,7 @@ async function __PRIVATE_syncEngineHandleCredentialChange(e, t) {
|
|
|
16803
16811
|
}
|
|
16804
16812
|
|
|
16805
16813
|
function __PRIVATE_syncEngineGetRemoteKeysForTarget(e, t) {
|
|
16806
|
-
const n = __PRIVATE_debugCast(e), r = n.
|
|
16814
|
+
const n = __PRIVATE_debugCast(e), r = n.Ua.get(t);
|
|
16807
16815
|
if (r && r.Ba) return __PRIVATE_documentKeySet().add(r.key);
|
|
16808
16816
|
{
|
|
16809
16817
|
let e = __PRIVATE_documentKeySet();
|
|
@@ -16895,9 +16903,9 @@ async function __PRIVATE_syncEngineApplyPrimaryState(e, t) {
|
|
|
16895
16903
|
// PORTING NOTE: Multi-Tab only.
|
|
16896
16904
|
function __PRIVATE_resetLimboDocuments(e) {
|
|
16897
16905
|
const t = __PRIVATE_debugCast(e);
|
|
16898
|
-
t.
|
|
16906
|
+
t.Ua.forEach(((e, n) => {
|
|
16899
16907
|
__PRIVATE_remoteStoreUnlisten(t.remoteStore, n);
|
|
16900
|
-
})), t.
|
|
16908
|
+
})), t.Ka.Dr(), t.Ua = new Map, t.$a = new SortedMap(DocumentKey.comparator);
|
|
16901
16909
|
}
|
|
16902
16910
|
/**
|
|
16903
16911
|
* Reconcile the query views of the provided query targets with the state from
|
|
@@ -19756,7 +19764,7 @@ function __PRIVATE_isWrite(e) {
|
|
|
19756
19764
|
});
|
|
19757
19765
|
return r.$u(e), r;
|
|
19758
19766
|
}
|
|
19759
|
-
|
|
19767
|
+
Uu(e) {
|
|
19760
19768
|
var t;
|
|
19761
19769
|
const n = null === (t = this.path) || void 0 === t ? void 0 : t.child(e), r = this.ku({
|
|
19762
19770
|
path: n,
|
|
@@ -19764,7 +19772,7 @@ function __PRIVATE_isWrite(e) {
|
|
|
19764
19772
|
});
|
|
19765
19773
|
return r.Bu(), r;
|
|
19766
19774
|
}
|
|
19767
|
-
|
|
19775
|
+
Ku(e) {
|
|
19768
19776
|
// TODO(b/34871131): We don't support array paths right now; so make path
|
|
19769
19777
|
// undefined.
|
|
19770
19778
|
return this.ku({
|
|
@@ -19925,7 +19933,7 @@ class __PRIVATE_NumericIncrementFieldValueImpl extends FieldValue {
|
|
|
19925
19933
|
// For Compat types, we have to "extract" the underlying types before
|
|
19926
19934
|
// performing validation.
|
|
19927
19935
|
r = E(r);
|
|
19928
|
-
const a = i.
|
|
19936
|
+
const a = i.Uu(_);
|
|
19929
19937
|
if (r instanceof __PRIVATE_DeleteFieldValueImpl)
|
|
19930
19938
|
// Add it to the field mask, but don't add anything to updateData.
|
|
19931
19939
|
s.push(_); else {
|
|
@@ -19951,7 +19959,7 @@ class __PRIVATE_NumericIncrementFieldValueImpl extends FieldValue {
|
|
|
19951
19959
|
// For Compat types, we have to "extract" the underlying types before
|
|
19952
19960
|
// performing validation.
|
|
19953
19961
|
n = E(n);
|
|
19954
|
-
const r = o.
|
|
19962
|
+
const r = o.Uu(t);
|
|
19955
19963
|
if (n instanceof __PRIVATE_DeleteFieldValueImpl)
|
|
19956
19964
|
// Add it to the field mask, but don't add anything to updateData.
|
|
19957
19965
|
u.push(t); else {
|
|
@@ -20029,7 +20037,7 @@ class __PRIVATE_NumericIncrementFieldValueImpl extends FieldValue {
|
|
|
20029
20037
|
const n = [];
|
|
20030
20038
|
let r = 0;
|
|
20031
20039
|
for (const i of e) {
|
|
20032
|
-
let e = __PRIVATE_parseData(i, t.
|
|
20040
|
+
let e = __PRIVATE_parseData(i, t.Ku(r));
|
|
20033
20041
|
null == e && (
|
|
20034
20042
|
// Just include nulls in the array for fields being replaced with a
|
|
20035
20043
|
// sentinel.
|