@firebase/firestore 4.7.9 → 4.7.10-20250318131644
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 +254 -225
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm2017.js +254 -225
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.node.cjs.js +96 -41
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +96 -41
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +185 -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 +149 -100
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.cjs.js +149 -100
- package/dist/lite/index.cjs.js.map +1 -1
- package/dist/lite/index.node.cjs.js +171 -97
- package/dist/lite/index.node.cjs.js.map +1 -1
- package/dist/lite/index.node.mjs +171 -97
- package/dist/lite/index.node.mjs.map +1 -1
- package/dist/lite/index.rn.esm2017.js +150 -101
- package/dist/lite/index.rn.esm2017.js.map +1 -1
- package/package.json +1 -1
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.
|
|
13
|
+
const D = "@firebase/firestore", v = "4.7.10-20250318131644";
|
|
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.
|
|
75
|
+
let C = "11.5.0-20250318131644";
|
|
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,37 @@ 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
|
+
let n = 0;
|
|
762
|
+
for (;n < e.length && n < t.length; ) {
|
|
763
|
+
const r = e.codePointAt(n), i = t.codePointAt(n);
|
|
764
|
+
if (r !== i) {
|
|
765
|
+
if (r < 128 && i < 128)
|
|
766
|
+
// ASCII comparison
|
|
767
|
+
return __PRIVATE_primitiveComparator(r, i);
|
|
768
|
+
{
|
|
769
|
+
// Lazy instantiate TextEncoder
|
|
770
|
+
const s = __PRIVATE_newTextEncoder(), o = __PRIVATE_compareByteArrays$1(s.encode(__PRIVATE_getUtf8SafeSubstring(e, n)), s.encode(__PRIVATE_getUtf8SafeSubstring(t, n)));
|
|
771
|
+
// UTF-8 encode the character at index i for byte comparison.
|
|
772
|
+
return 0 !== o ? o : __PRIVATE_primitiveComparator(r, i);
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
// Increment by 2 for surrogate pairs, 1 otherwise
|
|
776
|
+
n += r > 65535 ? 2 : 1;
|
|
777
|
+
}
|
|
778
|
+
// Compare lengths if all characters are equal
|
|
779
|
+
return __PRIVATE_primitiveComparator(e.length, t.length);
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
function __PRIVATE_getUtf8SafeSubstring(e, t) {
|
|
783
|
+
return e.codePointAt(t) > 65535 ? e.substring(t, t + 2) : e.substring(t, t + 1);
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
function __PRIVATE_compareByteArrays$1(e, t) {
|
|
787
|
+
for (let n = 0; n < e.length && n < t.length; ++n) if (e[n] !== t[n]) return __PRIVATE_primitiveComparator(e[n], t[n]);
|
|
788
|
+
return __PRIVATE_primitiveComparator(e.length, t.length);
|
|
789
|
+
}
|
|
790
|
+
|
|
734
791
|
/** Helper to compare arrays using isEqual(). */ function __PRIVATE_arrayEquals(e, t, n) {
|
|
735
792
|
return e.length === t.length && e.every(((e, r) => n(e, t[r])));
|
|
736
793
|
}
|
|
@@ -1021,13 +1078,11 @@ class Timestamp {
|
|
|
1021
1078
|
const n = BasePath.compareSegments(e.get(r), t.get(r));
|
|
1022
1079
|
if (0 !== n) return n;
|
|
1023
1080
|
}
|
|
1024
|
-
return
|
|
1081
|
+
return __PRIVATE_primitiveComparator(e.length, t.length);
|
|
1025
1082
|
}
|
|
1026
1083
|
static compareSegments(e, t) {
|
|
1027
1084
|
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;
|
|
1085
|
+
return n && !r ? -1 : !n && r ? 1 : n && r ? BasePath.extractNumericId(e).compare(BasePath.extractNumericId(t)) : __PRIVATE_compareUtf8Strings(e, t);
|
|
1031
1086
|
}
|
|
1032
1087
|
// Checks if a segment is a numeric ID (starts with "__id" and ends with "__").
|
|
1033
1088
|
static isNumericId(e) {
|
|
@@ -1815,13 +1870,13 @@ class __PRIVATE_SimpleDbTransaction {
|
|
|
1815
1870
|
* within the key range or index.
|
|
1816
1871
|
*/ class __PRIVATE_IterationController {
|
|
1817
1872
|
constructor(e) {
|
|
1818
|
-
this.q = e, this.$ = !1, this.
|
|
1873
|
+
this.q = e, this.$ = !1, this.U = null;
|
|
1819
1874
|
}
|
|
1820
1875
|
get isDone() {
|
|
1821
1876
|
return this.$;
|
|
1822
1877
|
}
|
|
1823
|
-
get
|
|
1824
|
-
return this.
|
|
1878
|
+
get K() {
|
|
1879
|
+
return this.U;
|
|
1825
1880
|
}
|
|
1826
1881
|
set cursor(e) {
|
|
1827
1882
|
this.q = e;
|
|
@@ -1835,7 +1890,7 @@ class __PRIVATE_SimpleDbTransaction {
|
|
|
1835
1890
|
* This function can be called to skip to that next key, which could be
|
|
1836
1891
|
* an index or a primary key.
|
|
1837
1892
|
*/ W(e) {
|
|
1838
|
-
this.
|
|
1893
|
+
this.U = e;
|
|
1839
1894
|
}
|
|
1840
1895
|
/**
|
|
1841
1896
|
* Delete the current cursor value from the object store.
|
|
@@ -1994,7 +2049,7 @@ class __PRIVATE_SimpleDbTransaction {
|
|
|
1994
2049
|
const e = o.catch((e => (s.done(), PersistencePromise.reject(e))));
|
|
1995
2050
|
n.push(e);
|
|
1996
2051
|
}
|
|
1997
|
-
s.isDone ? r() : null === s.
|
|
2052
|
+
s.isDone ? r() : null === s.K ? i.continue() : i.continue(s.K);
|
|
1998
2053
|
};
|
|
1999
2054
|
})).next((() => PersistencePromise.waitFor(n)));
|
|
2000
2055
|
}
|
|
@@ -2180,7 +2235,7 @@ __PRIVATE_ListenSequence.ae = -1;
|
|
|
2180
2235
|
* limitations under the License.
|
|
2181
2236
|
*/
|
|
2182
2237
|
/** Sentinel value that sorts before any Mutation Batch ID. */
|
|
2183
|
-
const
|
|
2238
|
+
const U = -1;
|
|
2184
2239
|
|
|
2185
2240
|
/**
|
|
2186
2241
|
* Returns whether a variable is either undefined or null.
|
|
@@ -2216,7 +2271,7 @@ const K = -1;
|
|
|
2216
2271
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2217
2272
|
* See the License for the specific language governing permissions and
|
|
2218
2273
|
* limitations under the License.
|
|
2219
|
-
*/ const
|
|
2274
|
+
*/ const K = "";
|
|
2220
2275
|
|
|
2221
2276
|
/**
|
|
2222
2277
|
* Encodes a resource path into a IndexedDb-compatible string form.
|
|
@@ -2238,7 +2293,7 @@ function __PRIVATE_encodeResourcePath(e) {
|
|
|
2238
2293
|
n += "";
|
|
2239
2294
|
break;
|
|
2240
2295
|
|
|
2241
|
-
case
|
|
2296
|
+
case K:
|
|
2242
2297
|
n += "";
|
|
2243
2298
|
break;
|
|
2244
2299
|
|
|
@@ -2250,7 +2305,7 @@ function __PRIVATE_encodeResourcePath(e) {
|
|
|
2250
2305
|
}
|
|
2251
2306
|
|
|
2252
2307
|
/** Encodes a path separator into the given result */ function __PRIVATE_encodeSeparator(e) {
|
|
2253
|
-
return e +
|
|
2308
|
+
return e + K + "";
|
|
2254
2309
|
}
|
|
2255
2310
|
|
|
2256
2311
|
/**
|
|
@@ -2262,7 +2317,7 @@ function __PRIVATE_encodeResourcePath(e) {
|
|
|
2262
2317
|
// Event the empty path must encode as a path of at least length 2. A path
|
|
2263
2318
|
// with exactly 2 must be the empty path.
|
|
2264
2319
|
const t = e.length;
|
|
2265
|
-
if (__PRIVATE_hardAssert(t >= 2), 2 === t) return __PRIVATE_hardAssert(e.charAt(0) ===
|
|
2320
|
+
if (__PRIVATE_hardAssert(t >= 2), 2 === t) return __PRIVATE_hardAssert(e.charAt(0) === K && "" === e.charAt(1)),
|
|
2266
2321
|
ResourcePath.emptyPath();
|
|
2267
2322
|
// Escape characters cannot exist past the second-to-last position in the
|
|
2268
2323
|
// source value.
|
|
@@ -2271,7 +2326,7 @@ function __PRIVATE_encodeResourcePath(e) {
|
|
|
2271
2326
|
for (let i = 0; i < t; ) {
|
|
2272
2327
|
// The last two characters of a valid encoded path must be a separator, so
|
|
2273
2328
|
// there must be an end to this segment.
|
|
2274
|
-
const t = e.indexOf(
|
|
2329
|
+
const t = e.indexOf(K, i);
|
|
2275
2330
|
(t < 0 || t > __PRIVATE_lastReasonableEscapeIndex) && fail();
|
|
2276
2331
|
switch (e.charAt(t + 1)) {
|
|
2277
2332
|
case "":
|
|
@@ -2360,7 +2415,7 @@ function __PRIVATE_newDbDocumentMutationPrefixForPath(e, t) {
|
|
|
2360
2415
|
* there is no useful information to store as the value. The raw (unencoded)
|
|
2361
2416
|
* path cannot be stored because IndexedDb doesn't store prototype
|
|
2362
2417
|
* 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" ],
|
|
2418
|
+
*/ 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
2419
|
|
|
2365
2420
|
/**
|
|
2366
2421
|
* @license
|
|
@@ -3430,7 +3485,7 @@ function __PRIVATE_valueCompare(e, t) {
|
|
|
3430
3485
|
return __PRIVATE_compareTimestamps(__PRIVATE_getLocalWriteTime(e), __PRIVATE_getLocalWriteTime(t));
|
|
3431
3486
|
|
|
3432
3487
|
case 5 /* TypeOrder.StringValue */ :
|
|
3433
|
-
return
|
|
3488
|
+
return __PRIVATE_compareUtf8Strings(e.stringValue, t.stringValue);
|
|
3434
3489
|
|
|
3435
3490
|
case 6 /* TypeOrder.BlobValue */ :
|
|
3436
3491
|
return function __PRIVATE_compareBlobs(e, t) {
|
|
@@ -3478,7 +3533,7 @@ function __PRIVATE_valueCompare(e, t) {
|
|
|
3478
3533
|
// canonical IDs are independent of insertion order.
|
|
3479
3534
|
r.sort(), s.sort();
|
|
3480
3535
|
for (let e = 0; e < r.length && e < s.length; ++e) {
|
|
3481
|
-
const t =
|
|
3536
|
+
const t = __PRIVATE_compareUtf8Strings(r[e], s[e]);
|
|
3482
3537
|
if (0 !== t) return t;
|
|
3483
3538
|
const o = __PRIVATE_valueCompare(n[r[e]], i[s[e]]);
|
|
3484
3539
|
if (0 !== o) return o;
|
|
@@ -5890,32 +5945,6 @@ let mt = null;
|
|
|
5890
5945
|
* Sets the value of the `testingHooksSpi` object.
|
|
5891
5946
|
* @param instance the instance to set.
|
|
5892
5947
|
*/
|
|
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
5948
|
/**
|
|
5920
5949
|
* @license
|
|
5921
5950
|
* Copyright 2022 Google LLC
|
|
@@ -6288,13 +6317,13 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6288
6317
|
/** Keeps track of the documents to update since the last raised snapshot. */
|
|
6289
6318
|
this.Qe = __PRIVATE_mutableDocumentMap(), this.$e = __PRIVATE_documentTargetMap(),
|
|
6290
6319
|
/** A mapping of document keys to their set of target IDs. */
|
|
6291
|
-
this.
|
|
6320
|
+
this.Ue = __PRIVATE_documentTargetMap(),
|
|
6292
6321
|
/**
|
|
6293
6322
|
* A map of targets with existence filter mismatches. These targets are
|
|
6294
6323
|
* known to be inconsistent and their listens needs to be re-established by
|
|
6295
6324
|
* RemoteStore.
|
|
6296
6325
|
*/
|
|
6297
|
-
this.
|
|
6326
|
+
this.Ke = new SortedMap(__PRIVATE_primitiveComparator);
|
|
6298
6327
|
}
|
|
6299
6328
|
/**
|
|
6300
6329
|
* Processes and adds the DocumentWatchChange to the current set of changes.
|
|
@@ -6383,7 +6412,7 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6383
6412
|
// trigger re-run of the query.
|
|
6384
6413
|
this.Ye(t);
|
|
6385
6414
|
const e = 2 /* BloomFilterApplicationStatus.FalsePositive */ === i ? "TargetPurposeExistenceFilterMismatchBloom" /* TargetPurpose.ExistenceFilterMismatchBloom */ : "TargetPurposeExistenceFilterMismatch" /* TargetPurpose.ExistenceFilterMismatch */;
|
|
6386
|
-
this.
|
|
6415
|
+
this.Ke = this.Ke.insert(t, e);
|
|
6387
6416
|
}
|
|
6388
6417
|
null == mt || mt.rt(function __PRIVATE_createExistenceFilterMismatchInfoForTestingHooks(e, t, n, r, i) {
|
|
6389
6418
|
var s, o, _, a, u, c;
|
|
@@ -6495,7 +6524,7 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6495
6524
|
|
|
6496
6525
|
// TODO(gsoltis): Expand on this comment once GC is available in the JS
|
|
6497
6526
|
// client.
|
|
6498
|
-
this.
|
|
6527
|
+
this.Ue.forEach(((e, t) => {
|
|
6499
6528
|
let r = !0;
|
|
6500
6529
|
t.forEachWhile((e => {
|
|
6501
6530
|
const t = this.Xe(e);
|
|
@@ -6503,9 +6532,9 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6503
6532
|
!1);
|
|
6504
6533
|
})), r && (n = n.add(e));
|
|
6505
6534
|
})), this.Qe.forEach(((t, n) => n.setReadTime(e)));
|
|
6506
|
-
const r = new RemoteEvent(e, t, this.
|
|
6535
|
+
const r = new RemoteEvent(e, t, this.Ke, this.Qe, n);
|
|
6507
6536
|
return this.Qe = __PRIVATE_mutableDocumentMap(), this.$e = __PRIVATE_documentTargetMap(),
|
|
6508
|
-
this.
|
|
6537
|
+
this.Ue = __PRIVATE_documentTargetMap(), this.Ke = new SortedMap(__PRIVATE_primitiveComparator),
|
|
6509
6538
|
r;
|
|
6510
6539
|
}
|
|
6511
6540
|
/**
|
|
@@ -6517,7 +6546,7 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6517
6546
|
if (!this.Je(e)) return;
|
|
6518
6547
|
const n = this.ut(e, t.key) ? 2 /* ChangeType.Modified */ : 0 /* ChangeType.Added */;
|
|
6519
6548
|
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.
|
|
6549
|
+
this.Ue = this.Ue.insert(t.key, this.ct(t.key).add(e));
|
|
6521
6550
|
}
|
|
6522
6551
|
/**
|
|
6523
6552
|
* Removes the provided document from the target mapping. If the
|
|
@@ -6533,7 +6562,7 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6533
6562
|
this.ut(e, t) ? r.xe(t, 1 /* ChangeType.Removed */) :
|
|
6534
6563
|
// The document may have entered and left the target before we raised a
|
|
6535
6564
|
// snapshot, so we can just ignore the change.
|
|
6536
|
-
r.Oe(t), this.
|
|
6565
|
+
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
6566
|
n && (this.Qe = this.Qe.insert(t, n));
|
|
6538
6567
|
}
|
|
6539
6568
|
removeTarget(e) {
|
|
@@ -6558,8 +6587,8 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6558
6587
|
return t || (t = new __PRIVATE_TargetState, this.qe.set(e, t)), t;
|
|
6559
6588
|
}
|
|
6560
6589
|
ct(e) {
|
|
6561
|
-
let t = this.
|
|
6562
|
-
return t || (t = new SortedSet(__PRIVATE_primitiveComparator), this.
|
|
6590
|
+
let t = this.Ue.get(e);
|
|
6591
|
+
return t || (t = new SortedSet(__PRIVATE_primitiveComparator), this.Ue = this.Ue.insert(e, t)),
|
|
6563
6592
|
t;
|
|
6564
6593
|
}
|
|
6565
6594
|
_t(e) {
|
|
@@ -7693,7 +7722,7 @@ function __PRIVATE_toDbIndexState(e, t, n, r) {
|
|
|
7693
7722
|
const o = IDBKeyRange.bound([ this.userId, t, n ], [ this.userId, t, Number.POSITIVE_INFINITY ],
|
|
7694
7723
|
/*lowerOpen=*/ !0);
|
|
7695
7724
|
return __PRIVATE_documentOverlayStore(e).Z({
|
|
7696
|
-
index:
|
|
7725
|
+
index: Ue,
|
|
7697
7726
|
range: o
|
|
7698
7727
|
}, ((e, t, n) => {
|
|
7699
7728
|
// We do not want to return partial batch overlays, even if the size
|
|
@@ -7954,10 +7983,10 @@ function __PRIVATE_unsignedNumLength(e) {
|
|
|
7954
7983
|
}
|
|
7955
7984
|
this.qt();
|
|
7956
7985
|
}
|
|
7957
|
-
|
|
7986
|
+
Ut(e) {
|
|
7958
7987
|
// Values are encoded with a single byte length prefix, followed by the
|
|
7959
7988
|
// actual value in big-endian format with leading 0 bytes dropped.
|
|
7960
|
-
const t = this.
|
|
7989
|
+
const t = this.Kt(e), n = __PRIVATE_unsignedNumLength(t);
|
|
7961
7990
|
this.Wt(1 + n), this.buffer[this.position++] = 255 & n;
|
|
7962
7991
|
// Write the length
|
|
7963
7992
|
for (let e = t.length - n; e < t.length; ++e) this.buffer[this.position++] = 255 & t[e];
|
|
@@ -7965,7 +7994,7 @@ function __PRIVATE_unsignedNumLength(e) {
|
|
|
7965
7994
|
Gt(e) {
|
|
7966
7995
|
// Values are encoded with a single byte length prefix, followed by the
|
|
7967
7996
|
// inverted value in big-endian format with leading 0 bytes dropped.
|
|
7968
|
-
const t = this.
|
|
7997
|
+
const t = this.Kt(e), n = __PRIVATE_unsignedNumLength(t);
|
|
7969
7998
|
this.Wt(1 + n), this.buffer[this.position++] = ~(255 & n);
|
|
7970
7999
|
// Write the length
|
|
7971
8000
|
for (let e = t.length - n; e < t.length; ++e) this.buffer[this.position++] = ~(255 & t[e]);
|
|
@@ -8000,7 +8029,7 @@ function __PRIVATE_unsignedNumLength(e) {
|
|
|
8000
8029
|
* -0.0 < 0.0
|
|
8001
8030
|
* all non-NaN < NaN
|
|
8002
8031
|
* NaN = NaN
|
|
8003
|
-
*/
|
|
8032
|
+
*/ Kt(e) {
|
|
8004
8033
|
const t =
|
|
8005
8034
|
/** Converts a JavaScript number to a byte array (using big endian encoding). */
|
|
8006
8035
|
function __PRIVATE_doubleToLongBits(e) {
|
|
@@ -8059,7 +8088,7 @@ class __PRIVATE_AscendingIndexByteEncoder {
|
|
|
8059
8088
|
this.Zt.Qt(e);
|
|
8060
8089
|
}
|
|
8061
8090
|
gt(e) {
|
|
8062
|
-
this.Zt.
|
|
8091
|
+
this.Zt.Ut(e);
|
|
8063
8092
|
}
|
|
8064
8093
|
Vt() {
|
|
8065
8094
|
this.Zt.zt();
|
|
@@ -9353,7 +9382,7 @@ class __PRIVATE_IndexedDbMutationQueue {
|
|
|
9353
9382
|
}
|
|
9354
9383
|
getHighestUnacknowledgedBatchId(e) {
|
|
9355
9384
|
const t = IDBKeyRange.upperBound([ this.userId, Number.POSITIVE_INFINITY ]);
|
|
9356
|
-
let n =
|
|
9385
|
+
let n = U;
|
|
9357
9386
|
return __PRIVATE_mutationsStore(e).Z({
|
|
9358
9387
|
index: Z,
|
|
9359
9388
|
range: t,
|
|
@@ -9363,7 +9392,7 @@ class __PRIVATE_IndexedDbMutationQueue {
|
|
|
9363
9392
|
})).next((() => n));
|
|
9364
9393
|
}
|
|
9365
9394
|
getAllMutationBatches(e) {
|
|
9366
|
-
const t = IDBKeyRange.bound([ this.userId,
|
|
9395
|
+
const t = IDBKeyRange.bound([ this.userId, U ], [ this.userId, Number.POSITIVE_INFINITY ]);
|
|
9367
9396
|
return __PRIVATE_mutationsStore(e).G(Z, t).next((e => e.map((e => __PRIVATE_fromDbMutationBatch(this.serializer, e)))));
|
|
9368
9397
|
}
|
|
9369
9398
|
getAllMutationBatchesAffectingDocumentKey(e, t) {
|
|
@@ -9489,7 +9518,7 @@ class __PRIVATE_IndexedDbMutationQueue {
|
|
|
9489
9518
|
Qn(e) {
|
|
9490
9519
|
return __PRIVATE_mutationQueuesStore(e).get(this.userId).next((e => e || {
|
|
9491
9520
|
userId: this.userId,
|
|
9492
|
-
lastAcknowledgedBatchId:
|
|
9521
|
+
lastAcknowledgedBatchId: U,
|
|
9493
9522
|
lastStreamToken: ""
|
|
9494
9523
|
}));
|
|
9495
9524
|
}
|
|
@@ -9568,14 +9597,14 @@ class __PRIVATE_TargetIdGenerator {
|
|
|
9568
9597
|
next() {
|
|
9569
9598
|
return this.$n += 2, this.$n;
|
|
9570
9599
|
}
|
|
9571
|
-
static
|
|
9600
|
+
static Un() {
|
|
9572
9601
|
// The target cache generator must return '2' in its first call to `next()`
|
|
9573
9602
|
// as there is no differentiation in the protocol layer between an unset
|
|
9574
9603
|
// number and the number '0'. If we were to sent a target with target ID
|
|
9575
9604
|
// '0', the backend would consider it unset and replace it with its own ID.
|
|
9576
9605
|
return new __PRIVATE_TargetIdGenerator(0);
|
|
9577
9606
|
}
|
|
9578
|
-
static
|
|
9607
|
+
static Kn() {
|
|
9579
9608
|
// Sync engine assigns target IDs for limbo document detection.
|
|
9580
9609
|
return new __PRIVATE_TargetIdGenerator(-1);
|
|
9581
9610
|
}
|
|
@@ -11064,7 +11093,7 @@ class __PRIVATE_DocReference {
|
|
|
11064
11093
|
return PersistencePromise.resolve(this.mutationQueue.length > i ? this.mutationQueue[i] : null);
|
|
11065
11094
|
}
|
|
11066
11095
|
getHighestUnacknowledgedBatchId() {
|
|
11067
|
-
return PersistencePromise.resolve(0 === this.mutationQueue.length ?
|
|
11096
|
+
return PersistencePromise.resolve(0 === this.mutationQueue.length ? U : this.Fr - 1);
|
|
11068
11097
|
}
|
|
11069
11098
|
getAllMutationBatches(e) {
|
|
11070
11099
|
return PersistencePromise.resolve(this.mutationQueue.slice());
|
|
@@ -11343,7 +11372,7 @@ class __PRIVATE_MemoryRemoteDocumentChangeBuffer extends RemoteDocumentChangeBuf
|
|
|
11343
11372
|
* A ordered bidirectional mapping between documents and the remote target
|
|
11344
11373
|
* IDs.
|
|
11345
11374
|
*/
|
|
11346
|
-
this.
|
|
11375
|
+
this.Ur = new __PRIVATE_ReferenceSet, this.targetCount = 0, this.Kr = __PRIVATE_TargetIdGenerator.Un();
|
|
11347
11376
|
}
|
|
11348
11377
|
forEachTarget(e, t) {
|
|
11349
11378
|
return this.Qr.forEach(((e, n) => t(n))), PersistencePromise.resolve();
|
|
@@ -11355,7 +11384,7 @@ class __PRIVATE_MemoryRemoteDocumentChangeBuffer extends RemoteDocumentChangeBuf
|
|
|
11355
11384
|
return PersistencePromise.resolve(this.$r);
|
|
11356
11385
|
}
|
|
11357
11386
|
allocateTargetId(e) {
|
|
11358
|
-
return this.highestTargetId = this.
|
|
11387
|
+
return this.highestTargetId = this.Kr.next(), PersistencePromise.resolve(this.highestTargetId);
|
|
11359
11388
|
}
|
|
11360
11389
|
setTargetsMetadata(e, t, n) {
|
|
11361
11390
|
return n && (this.lastRemoteSnapshotVersion = n), t > this.$r && (this.$r = t),
|
|
@@ -11364,7 +11393,7 @@ class __PRIVATE_MemoryRemoteDocumentChangeBuffer extends RemoteDocumentChangeBuf
|
|
|
11364
11393
|
zn(e) {
|
|
11365
11394
|
this.Qr.set(e.target, e);
|
|
11366
11395
|
const t = e.targetId;
|
|
11367
|
-
t > this.highestTargetId && (this.
|
|
11396
|
+
t > this.highestTargetId && (this.Kr = new __PRIVATE_TargetIdGenerator(t), this.highestTargetId = t),
|
|
11368
11397
|
e.sequenceNumber > this.$r && (this.$r = e.sequenceNumber);
|
|
11369
11398
|
}
|
|
11370
11399
|
addTargetData(e, t) {
|
|
@@ -11374,7 +11403,7 @@ class __PRIVATE_MemoryRemoteDocumentChangeBuffer extends RemoteDocumentChangeBuf
|
|
|
11374
11403
|
return this.zn(t), PersistencePromise.resolve();
|
|
11375
11404
|
}
|
|
11376
11405
|
removeTargetData(e, t) {
|
|
11377
|
-
return this.Qr.delete(t.target), this.
|
|
11406
|
+
return this.Qr.delete(t.target), this.Ur.br(t.targetId), this.targetCount -= 1,
|
|
11378
11407
|
PersistencePromise.resolve();
|
|
11379
11408
|
}
|
|
11380
11409
|
removeTargets(e, t, n) {
|
|
@@ -11393,24 +11422,24 @@ class __PRIVATE_MemoryRemoteDocumentChangeBuffer extends RemoteDocumentChangeBuf
|
|
|
11393
11422
|
return PersistencePromise.resolve(n);
|
|
11394
11423
|
}
|
|
11395
11424
|
addMatchingKeys(e, t, n) {
|
|
11396
|
-
return this.
|
|
11425
|
+
return this.Ur.yr(t, n), PersistencePromise.resolve();
|
|
11397
11426
|
}
|
|
11398
11427
|
removeMatchingKeys(e, t, n) {
|
|
11399
|
-
this.
|
|
11428
|
+
this.Ur.Sr(t, n);
|
|
11400
11429
|
const r = this.persistence.referenceDelegate, i = [];
|
|
11401
11430
|
return r && t.forEach((t => {
|
|
11402
11431
|
i.push(r.markPotentiallyOrphaned(e, t));
|
|
11403
11432
|
})), PersistencePromise.waitFor(i);
|
|
11404
11433
|
}
|
|
11405
11434
|
removeMatchingKeysForTargetId(e, t) {
|
|
11406
|
-
return this.
|
|
11435
|
+
return this.Ur.br(t), PersistencePromise.resolve();
|
|
11407
11436
|
}
|
|
11408
11437
|
getMatchingKeysForTargetId(e, t) {
|
|
11409
|
-
const n = this.
|
|
11438
|
+
const n = this.Ur.vr(t);
|
|
11410
11439
|
return PersistencePromise.resolve(n);
|
|
11411
11440
|
}
|
|
11412
11441
|
containsKey(e, t) {
|
|
11413
|
-
return PersistencePromise.resolve(this.
|
|
11442
|
+
return PersistencePromise.resolve(this.Ur.containsKey(t));
|
|
11414
11443
|
}
|
|
11415
11444
|
}
|
|
11416
11445
|
|
|
@@ -11767,7 +11796,7 @@ class __PRIVATE_MemoryLruDelegate {
|
|
|
11767
11796
|
});
|
|
11768
11797
|
t.createIndex(Qe, $e, {
|
|
11769
11798
|
unique: !1
|
|
11770
|
-
}), t.createIndex(
|
|
11799
|
+
}), t.createIndex(Ue, Ke, {
|
|
11771
11800
|
unique: !1
|
|
11772
11801
|
});
|
|
11773
11802
|
}(e);
|
|
@@ -11825,7 +11854,7 @@ class __PRIVATE_MemoryLruDelegate {
|
|
|
11825
11854
|
_i(e) {
|
|
11826
11855
|
const t = e.store(j), n = e.store(J);
|
|
11827
11856
|
return t.G().next((t => PersistencePromise.forEach(t, (t => {
|
|
11828
|
-
const r = IDBKeyRange.bound([ t.userId,
|
|
11857
|
+
const r = IDBKeyRange.bound([ t.userId, U ], [ t.userId, t.lastAcknowledgedBatchId ]);
|
|
11829
11858
|
return n.G(Z, r).next((n => PersistencePromise.forEach(n, (n => {
|
|
11830
11859
|
__PRIVATE_hardAssert(n.userId === t.userId);
|
|
11831
11860
|
const r = __PRIVATE_fromDbMutationBatch(this.serializer, n);
|
|
@@ -12206,7 +12235,7 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12206
12235
|
async shutdown() {
|
|
12207
12236
|
// The shutdown() operations are idempotent and can be called even when
|
|
12208
12237
|
// start() aborted (e.g. because it couldn't acquire the persistence lease).
|
|
12209
|
-
this.zr = !1, this.
|
|
12238
|
+
this.zr = !1, this.Ui(), this.Vi && (this.Vi.cancel(), this.Vi = null), this.Ki(),
|
|
12210
12239
|
this.Wi(),
|
|
12211
12240
|
// Use `SimpleDb.runTransaction` directly to avoid failing if another tab
|
|
12212
12241
|
// has obtained the primary lease.
|
|
@@ -12316,7 +12345,7 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12316
12345
|
this.wi())));
|
|
12317
12346
|
}, this.document.addEventListener("visibilitychange", this.Ri), this.inForeground = "visible" === this.document.visibilityState);
|
|
12318
12347
|
}
|
|
12319
|
-
|
|
12348
|
+
Ki() {
|
|
12320
12349
|
this.Ri && (this.document.removeEventListener("visibilitychange", this.Ri), this.Ri = null);
|
|
12321
12350
|
}
|
|
12322
12351
|
/**
|
|
@@ -12334,7 +12363,7 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12334
12363
|
// Note: In theory, this should be scheduled on the AsyncQueue since it
|
|
12335
12364
|
// accesses internal state. We execute this code directly during shutdown
|
|
12336
12365
|
// to make sure it gets a chance to run.
|
|
12337
|
-
this.
|
|
12366
|
+
this.Ui();
|
|
12338
12367
|
const e = /(?:Version|Mobile)\/1[456]/;
|
|
12339
12368
|
T() && (navigator.appVersion.match(e) || navigator.userAgent.match(e)) &&
|
|
12340
12369
|
// On Safari 14, 15, and 16, we do not run any cleanup actions as it might
|
|
@@ -12365,7 +12394,7 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12365
12394
|
/**
|
|
12366
12395
|
* Record client as zombied (a client that had its tab closed). Zombied
|
|
12367
12396
|
* clients are ignored during primary tab selection.
|
|
12368
|
-
*/
|
|
12397
|
+
*/ Ui() {
|
|
12369
12398
|
if (this.yi) try {
|
|
12370
12399
|
this.yi.setItem(this.Qi(this.clientId), String(Date.now()));
|
|
12371
12400
|
} catch (e) {
|
|
@@ -12981,7 +13010,7 @@ function __PRIVATE_localStoreGetLastRemoteSnapshotVersion(e) {
|
|
|
12981
13010
|
*/
|
|
12982
13011
|
function __PRIVATE_localStoreGetNextMutationBatch(e, t) {
|
|
12983
13012
|
const n = __PRIVATE_debugCast(e);
|
|
12984
|
-
return n.persistence.runTransaction("Get next mutation batch", "readonly", (e => (void 0 === t && (t =
|
|
13013
|
+
return n.persistence.runTransaction("Get next mutation batch", "readonly", (e => (void 0 === t && (t = U),
|
|
12985
13014
|
n.mutationQueue.getNextMutationBatchAfterBatchId(e, t))));
|
|
12986
13015
|
}
|
|
12987
13016
|
|
|
@@ -13229,7 +13258,7 @@ const $t = "firestore_targets";
|
|
|
13229
13258
|
* See the License for the specific language governing permissions and
|
|
13230
13259
|
* limitations under the License.
|
|
13231
13260
|
*/
|
|
13232
|
-
const
|
|
13261
|
+
const Ut = "SharedClientState";
|
|
13233
13262
|
|
|
13234
13263
|
/**
|
|
13235
13264
|
* Holds the state of a mutation batch, including its user ID, batch ID and
|
|
@@ -13247,7 +13276,7 @@ class __PRIVATE_MutationMetadata {
|
|
|
13247
13276
|
const r = JSON.parse(n);
|
|
13248
13277
|
let i, s = "object" == typeof r && -1 !== [ "pending", "acknowledged", "rejected" ].indexOf(r.state) && (void 0 === r.error || "object" == typeof r.error);
|
|
13249
13278
|
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(
|
|
13279
|
+
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
13280
|
null);
|
|
13252
13281
|
}
|
|
13253
13282
|
bs() {
|
|
@@ -13278,7 +13307,7 @@ class __PRIVATE_QueryTargetMetadata {
|
|
|
13278
13307
|
const n = JSON.parse(t);
|
|
13279
13308
|
let r, i = "object" == typeof n && -1 !== [ "not-current", "current", "rejected" ].indexOf(n.state) && (void 0 === n.error || "object" == typeof n.error);
|
|
13280
13309
|
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(
|
|
13310
|
+
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
13311
|
null);
|
|
13283
13312
|
}
|
|
13284
13313
|
bs() {
|
|
@@ -13308,7 +13337,7 @@ class __PRIVATE_QueryTargetMetadata {
|
|
|
13308
13337
|
let r = "object" == typeof n && n.activeTargetIds instanceof Array, i = __PRIVATE_targetIdSet();
|
|
13309
13338
|
for (let e = 0; r && e < n.activeTargetIds.length; ++e) r = isSafeInteger(n.activeTargetIds[e]),
|
|
13310
13339
|
i = i.add(n.activeTargetIds[e]);
|
|
13311
|
-
return r ? new __PRIVATE_RemoteClientState(e, i) : (__PRIVATE_logError(
|
|
13340
|
+
return r ? new __PRIVATE_RemoteClientState(e, i) : (__PRIVATE_logError(Ut, `Failed to parse client data for instance '${e}': ${t}`),
|
|
13312
13341
|
null);
|
|
13313
13342
|
}
|
|
13314
13343
|
}
|
|
@@ -13326,7 +13355,7 @@ class __PRIVATE_QueryTargetMetadata {
|
|
|
13326
13355
|
* Logs a warning and returns null if the format of the data is not valid.
|
|
13327
13356
|
*/ static Ss(e) {
|
|
13328
13357
|
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(
|
|
13358
|
+
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
13359
|
null);
|
|
13331
13360
|
}
|
|
13332
13361
|
}
|
|
@@ -13427,12 +13456,12 @@ class __PRIVATE_LocalClientState {
|
|
|
13427
13456
|
n && (this.xs = this.xs.insert(n.clientId, n));
|
|
13428
13457
|
}
|
|
13429
13458
|
}
|
|
13430
|
-
this.
|
|
13459
|
+
this.Us();
|
|
13431
13460
|
// Check if there is an existing online state and call the callback handler
|
|
13432
13461
|
// if applicable.
|
|
13433
13462
|
const t = this.storage.getItem(this.Qs);
|
|
13434
13463
|
if (t) {
|
|
13435
|
-
const e = this.
|
|
13464
|
+
const e = this.Ks(t);
|
|
13436
13465
|
e && this.Ws(e);
|
|
13437
13466
|
}
|
|
13438
13467
|
for (const e of this.Os) this.Ms(e);
|
|
@@ -13476,10 +13505,10 @@ class __PRIVATE_LocalClientState {
|
|
|
13476
13505
|
}
|
|
13477
13506
|
// If the query is listening to cache only, the target ID should not be registered with the
|
|
13478
13507
|
// local Firestore client as an active watch target.
|
|
13479
|
-
return t && this.Hs.Ds(e), this.
|
|
13508
|
+
return t && this.Hs.Ds(e), this.Us(), n;
|
|
13480
13509
|
}
|
|
13481
13510
|
removeLocalQueryTarget(e) {
|
|
13482
|
-
this.Hs.vs(e), this.
|
|
13511
|
+
this.Hs.vs(e), this.Us();
|
|
13483
13512
|
}
|
|
13484
13513
|
isLocalQueryTarget(e) {
|
|
13485
13514
|
return this.Hs.activeTargetIds.has(e);
|
|
@@ -13509,20 +13538,20 @@ class __PRIVATE_LocalClientState {
|
|
|
13509
13538
|
}
|
|
13510
13539
|
getItem(e) {
|
|
13511
13540
|
const t = this.storage.getItem(e);
|
|
13512
|
-
return __PRIVATE_logDebug(
|
|
13541
|
+
return __PRIVATE_logDebug(Ut, "READ", e, t), t;
|
|
13513
13542
|
}
|
|
13514
13543
|
setItem(e, t) {
|
|
13515
|
-
__PRIVATE_logDebug(
|
|
13544
|
+
__PRIVATE_logDebug(Ut, "SET", e, t), this.storage.setItem(e, t);
|
|
13516
13545
|
}
|
|
13517
13546
|
removeItem(e) {
|
|
13518
|
-
__PRIVATE_logDebug(
|
|
13547
|
+
__PRIVATE_logDebug(Ut, "REMOVE", e), this.storage.removeItem(e);
|
|
13519
13548
|
}
|
|
13520
13549
|
Ms(e) {
|
|
13521
13550
|
// Note: The function is typed to take Event to be interface-compatible with
|
|
13522
13551
|
// `Window.addEventListener`.
|
|
13523
13552
|
const t = e;
|
|
13524
13553
|
if (t.storageArea === this.storage) {
|
|
13525
|
-
if (__PRIVATE_logDebug(
|
|
13554
|
+
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
13555
|
this.Ti.enqueueRetryable((async () => {
|
|
13527
13556
|
if (this.started) {
|
|
13528
13557
|
if (null !== t.key) if (this.Ls.test(t.key)) {
|
|
@@ -13546,7 +13575,7 @@ class __PRIVATE_LocalClientState {
|
|
|
13546
13575
|
}
|
|
13547
13576
|
} else if (t.key === this.Qs) {
|
|
13548
13577
|
if (null !== t.newValue) {
|
|
13549
|
-
const e = this.
|
|
13578
|
+
const e = this.Ks(t.newValue);
|
|
13550
13579
|
if (e) return this.Ws(e);
|
|
13551
13580
|
}
|
|
13552
13581
|
} else if (t.key === this.Bs) {
|
|
@@ -13556,7 +13585,7 @@ class __PRIVATE_LocalClientState {
|
|
|
13556
13585
|
const n = JSON.parse(e);
|
|
13557
13586
|
__PRIVATE_hardAssert("number" == typeof n), t = n;
|
|
13558
13587
|
} catch (e) {
|
|
13559
|
-
__PRIVATE_logError(
|
|
13588
|
+
__PRIVATE_logError(Ut, "Failed to read sequence number from WebStorage", e);
|
|
13560
13589
|
}
|
|
13561
13590
|
return t;
|
|
13562
13591
|
}
|
|
@@ -13577,7 +13606,7 @@ class __PRIVATE_LocalClientState {
|
|
|
13577
13606
|
get Hs() {
|
|
13578
13607
|
return this.xs.get(this.Cs);
|
|
13579
13608
|
}
|
|
13580
|
-
|
|
13609
|
+
Us() {
|
|
13581
13610
|
this.setItem(this.Ns, this.Hs.bs());
|
|
13582
13611
|
}
|
|
13583
13612
|
zs(e, t, n) {
|
|
@@ -13634,7 +13663,7 @@ class __PRIVATE_LocalClientState {
|
|
|
13634
13663
|
/**
|
|
13635
13664
|
* Parses an online state from WebStorage. Returns 'null' if the value
|
|
13636
13665
|
* could not be parsed.
|
|
13637
|
-
*/
|
|
13666
|
+
*/ Ks(e) {
|
|
13638
13667
|
return __PRIVATE_SharedOnlineState.Ss(e);
|
|
13639
13668
|
}
|
|
13640
13669
|
_o(e) {
|
|
@@ -13642,7 +13671,7 @@ class __PRIVATE_LocalClientState {
|
|
|
13642
13671
|
}
|
|
13643
13672
|
async io(e) {
|
|
13644
13673
|
if (e.user.uid === this.currentUser.uid) return this.syncEngine.uo(e.batchId, e.state, e.error);
|
|
13645
|
-
__PRIVATE_logDebug(
|
|
13674
|
+
__PRIVATE_logDebug(Ut, `Ignoring mutation for non-active user ${e.user.uid}`);
|
|
13646
13675
|
}
|
|
13647
13676
|
oo(e) {
|
|
13648
13677
|
return this.syncEngine.co(e.targetId, e.state, e.error);
|
|
@@ -13762,7 +13791,7 @@ class __PRIVATE_MemorySharedClientState {
|
|
|
13762
13791
|
* limitations under the License.
|
|
13763
13792
|
*/
|
|
13764
13793
|
// References to `window` are guarded by BrowserConnectivityMonitor.isAvailable()
|
|
13765
|
-
/* eslint-disable no-restricted-globals */ const
|
|
13794
|
+
/* eslint-disable no-restricted-globals */ const Kt = "ConnectivityMonitor";
|
|
13766
13795
|
|
|
13767
13796
|
/**
|
|
13768
13797
|
* Browser implementation of ConnectivityMonitor.
|
|
@@ -13780,11 +13809,11 @@ class __PRIVATE_MemorySharedClientState {
|
|
|
13780
13809
|
window.addEventListener("online", this.Io), window.addEventListener("offline", this.Ao);
|
|
13781
13810
|
}
|
|
13782
13811
|
Eo() {
|
|
13783
|
-
__PRIVATE_logDebug(
|
|
13812
|
+
__PRIVATE_logDebug(Kt, "Network connectivity changed: AVAILABLE");
|
|
13784
13813
|
for (const e of this.Vo) e(0 /* NetworkStatus.AVAILABLE */);
|
|
13785
13814
|
}
|
|
13786
13815
|
Ro() {
|
|
13787
|
-
__PRIVATE_logDebug(
|
|
13816
|
+
__PRIVATE_logDebug(Kt, "Network connectivity changed: UNAVAILABLE");
|
|
13788
13817
|
for (const e of this.Vo) e(1 /* NetworkStatus.UNAVAILABLE */);
|
|
13789
13818
|
}
|
|
13790
13819
|
// TODO(chenbrian): Consider passing in window either into this component or
|
|
@@ -13982,10 +14011,10 @@ class __PRIVATE_RestConnection {
|
|
|
13982
14011
|
$o() {
|
|
13983
14012
|
this.Bo();
|
|
13984
14013
|
}
|
|
13985
|
-
|
|
14014
|
+
Uo(e) {
|
|
13986
14015
|
this.ko(e);
|
|
13987
14016
|
}
|
|
13988
|
-
|
|
14017
|
+
Ko(e) {
|
|
13989
14018
|
this.qo(e);
|
|
13990
14019
|
}
|
|
13991
14020
|
}
|
|
@@ -14137,10 +14166,10 @@ class __PRIVATE_WebChannelConnection extends __PRIVATE_RestConnection {
|
|
|
14137
14166
|
h || (__PRIVATE_logDebug(jt, `RPC '${e}' stream ${r} transport opened.`), P.Qo());
|
|
14138
14167
|
})), __PRIVATE_unguardedEventListen(c, w.EventType.CLOSE, (() => {
|
|
14139
14168
|
h || (h = !0, __PRIVATE_logDebug(jt, `RPC '${e}' stream ${r} transport closed`),
|
|
14140
|
-
P.
|
|
14169
|
+
P.Uo());
|
|
14141
14170
|
})), __PRIVATE_unguardedEventListen(c, w.EventType.ERROR, (t => {
|
|
14142
14171
|
h || (h = !0, __PRIVATE_logWarn(jt, `RPC '${e}' stream ${r} transport errored:`, t),
|
|
14143
|
-
P.
|
|
14172
|
+
P.Uo(new FirestoreError(M.UNAVAILABLE, "The operation could not be completed")));
|
|
14144
14173
|
})), __PRIVATE_unguardedEventListen(c, w.EventType.MESSAGE, (t => {
|
|
14145
14174
|
var n;
|
|
14146
14175
|
if (!h) {
|
|
@@ -14171,8 +14200,8 @@ class __PRIVATE_WebChannelConnection extends __PRIVATE_RestConnection {
|
|
|
14171
14200
|
}(t), i = o.message;
|
|
14172
14201
|
void 0 === n && (n = M.INTERNAL, i = "Unknown error status: " + t + " with message " + o.message),
|
|
14173
14202
|
// Mark closed so no further events are propagated
|
|
14174
|
-
h = !0, P.
|
|
14175
|
-
} else __PRIVATE_logDebug(jt, `RPC '${e}' stream ${r} received:`, i), P.
|
|
14203
|
+
h = !0, P.Uo(new FirestoreError(n, i)), c.close();
|
|
14204
|
+
} else __PRIVATE_logDebug(jt, `RPC '${e}' stream ${r} received:`, i), P.Ko(i);
|
|
14176
14205
|
}
|
|
14177
14206
|
})), __PRIVATE_unguardedEventListen(o, S.STAT_EVENT, (t => {
|
|
14178
14207
|
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 +14936,7 @@ class __PRIVATE_RemoteStoreImpl {
|
|
|
14907
14936
|
* purely based on order, and so we can just shift() writes from the front of
|
|
14908
14937
|
* the writePipeline as we receive responses.
|
|
14909
14938
|
*/
|
|
14910
|
-
this.
|
|
14939
|
+
this.U_ = [],
|
|
14911
14940
|
/**
|
|
14912
14941
|
* A mapping of watched targets that the client cares about tracking and the
|
|
14913
14942
|
* user has explicitly called a 'listen' for this target.
|
|
@@ -14917,7 +14946,7 @@ class __PRIVATE_RemoteStoreImpl {
|
|
|
14917
14946
|
* to the server. The targets removed with unlistens are removed eagerly
|
|
14918
14947
|
* without waiting for confirmation from the listen stream.
|
|
14919
14948
|
*/
|
|
14920
|
-
this.
|
|
14949
|
+
this.K_ = new Map,
|
|
14921
14950
|
/**
|
|
14922
14951
|
* A set of reasons for why the RemoteStore may be offline. If empty, the
|
|
14923
14952
|
* RemoteStore may start its network connections.
|
|
@@ -14964,9 +14993,9 @@ async function __PRIVATE_enableNetworkInternal(e) {
|
|
|
14964
14993
|
*/
|
|
14965
14994
|
function __PRIVATE_remoteStoreListen(e, t) {
|
|
14966
14995
|
const n = __PRIVATE_debugCast(e);
|
|
14967
|
-
n.
|
|
14996
|
+
n.K_.has(t.targetId) || (
|
|
14968
14997
|
// Mark this as something the client is currently listening for.
|
|
14969
|
-
n.
|
|
14998
|
+
n.K_.set(t.targetId, t), __PRIVATE_shouldStartWatchStream(n) ?
|
|
14970
14999
|
// The listen will be sent in onWatchStreamOpen
|
|
14971
15000
|
__PRIVATE_startWatchStream(n) : __PRIVATE_ensureWatchStream(n).c_() && __PRIVATE_sendWatchRequest(n, t));
|
|
14972
15001
|
}
|
|
@@ -14976,7 +15005,7 @@ function __PRIVATE_remoteStoreListen(e, t) {
|
|
|
14976
15005
|
* not being listened to.
|
|
14977
15006
|
*/ function __PRIVATE_remoteStoreUnlisten(e, t) {
|
|
14978
15007
|
const n = __PRIVATE_debugCast(e), r = __PRIVATE_ensureWatchStream(n);
|
|
14979
|
-
n.
|
|
15008
|
+
n.K_.delete(t), r.c_() && __PRIVATE_sendUnwatchRequest(n, t), 0 === n.K_.size && (r.c_() ? r.P_() : __PRIVATE_canUseNetwork(n) &&
|
|
14980
15009
|
// Revert to OnlineState.Unknown if the watch stream is not open and we
|
|
14981
15010
|
// have no listeners, since without any listens to send we cannot
|
|
14982
15011
|
// confirm if the stream is healthy and upgrade to OnlineState.Online.
|
|
@@ -15005,7 +15034,7 @@ function __PRIVATE_remoteStoreListen(e, t) {
|
|
|
15005
15034
|
function __PRIVATE_startWatchStream(e) {
|
|
15006
15035
|
e.H_ = new __PRIVATE_WatchChangeAggregator({
|
|
15007
15036
|
getRemoteKeysForTarget: t => e.remoteSyncer.getRemoteKeysForTarget(t),
|
|
15008
|
-
lt: t => e.
|
|
15037
|
+
lt: t => e.K_.get(t) || null,
|
|
15009
15038
|
it: () => e.datastore.serializer.databaseId
|
|
15010
15039
|
}), __PRIVATE_ensureWatchStream(e).start(), e.j_.B_();
|
|
15011
15040
|
}
|
|
@@ -15014,7 +15043,7 @@ function __PRIVATE_startWatchStream(e) {
|
|
|
15014
15043
|
* Returns whether the watch stream should be started because it's necessary
|
|
15015
15044
|
* and has not yet been started.
|
|
15016
15045
|
*/ function __PRIVATE_shouldStartWatchStream(e) {
|
|
15017
|
-
return __PRIVATE_canUseNetwork(e) && !__PRIVATE_ensureWatchStream(e).u_() && e.
|
|
15046
|
+
return __PRIVATE_canUseNetwork(e) && !__PRIVATE_ensureWatchStream(e).u_() && e.K_.size > 0;
|
|
15018
15047
|
}
|
|
15019
15048
|
|
|
15020
15049
|
function __PRIVATE_canUseNetwork(e) {
|
|
@@ -15031,7 +15060,7 @@ async function __PRIVATE_onWatchStreamConnected(e) {
|
|
|
15031
15060
|
}
|
|
15032
15061
|
|
|
15033
15062
|
async function __PRIVATE_onWatchStreamOpen(e) {
|
|
15034
|
-
e.
|
|
15063
|
+
e.K_.forEach(((t, n) => {
|
|
15035
15064
|
__PRIVATE_sendWatchRequest(e, t);
|
|
15036
15065
|
}));
|
|
15037
15066
|
}
|
|
@@ -15058,7 +15087,7 @@ async function __PRIVATE_onWatchStreamChange(e, t, n) {
|
|
|
15058
15087
|
const n = t.cause;
|
|
15059
15088
|
for (const r of t.targetIds)
|
|
15060
15089
|
// A watched target might have been removed already.
|
|
15061
|
-
e.
|
|
15090
|
+
e.K_.has(r) && (await e.remoteSyncer.rejectListen(r, n), e.K_.delete(r), e.H_.removeTarget(r));
|
|
15062
15091
|
}
|
|
15063
15092
|
/**
|
|
15064
15093
|
* Attempts to fill our write pipeline with writes from the LocalStore.
|
|
@@ -15088,21 +15117,21 @@ async function __PRIVATE_onWatchStreamChange(e, t, n) {
|
|
|
15088
15117
|
// persistent view of these when applying the completed RemoteEvent.
|
|
15089
15118
|
return n.targetChanges.forEach(((n, r) => {
|
|
15090
15119
|
if (n.resumeToken.approximateByteSize() > 0) {
|
|
15091
|
-
const i = e.
|
|
15120
|
+
const i = e.K_.get(r);
|
|
15092
15121
|
// A watched target might have been removed already.
|
|
15093
|
-
i && e.
|
|
15122
|
+
i && e.K_.set(r, i.withResumeToken(n.resumeToken, t));
|
|
15094
15123
|
}
|
|
15095
15124
|
})),
|
|
15096
15125
|
// Re-establish listens for the targets that have been invalidated by
|
|
15097
15126
|
// existence filter mismatches.
|
|
15098
15127
|
n.targetMismatches.forEach(((t, n) => {
|
|
15099
|
-
const r = e.
|
|
15128
|
+
const r = e.K_.get(t);
|
|
15100
15129
|
if (!r)
|
|
15101
15130
|
// A watched target might have been removed already.
|
|
15102
15131
|
return;
|
|
15103
15132
|
// Clear the resume token for the target, since we're in a known mismatch
|
|
15104
15133
|
// state.
|
|
15105
|
-
e.
|
|
15134
|
+
e.K_.set(t, r.withResumeToken(ByteString.EMPTY_BYTE_STRING, r.snapshotVersion)),
|
|
15106
15135
|
// Cause a hard reset by unwatching and rewatching immediately, but
|
|
15107
15136
|
// deliberately don't send a resume token so that we get a full update.
|
|
15108
15137
|
__PRIVATE_sendUnwatchRequest(e, t);
|
|
@@ -15153,11 +15182,11 @@ async function __PRIVATE_onWatchStreamChange(e, t, n) {
|
|
|
15153
15182
|
|
|
15154
15183
|
async function __PRIVATE_fillWritePipeline(e) {
|
|
15155
15184
|
const t = __PRIVATE_debugCast(e), n = __PRIVATE_ensureWriteStream(t);
|
|
15156
|
-
let r = t.
|
|
15185
|
+
let r = t.U_.length > 0 ? t.U_[t.U_.length - 1].batchId : U;
|
|
15157
15186
|
for (;__PRIVATE_canAddToWritePipeline(t); ) try {
|
|
15158
15187
|
const e = await __PRIVATE_localStoreGetNextMutationBatch(t.localStore, r);
|
|
15159
15188
|
if (null === e) {
|
|
15160
|
-
0 === t.
|
|
15189
|
+
0 === t.U_.length && n.P_();
|
|
15161
15190
|
break;
|
|
15162
15191
|
}
|
|
15163
15192
|
r = e.batchId, __PRIVATE_addToWritePipeline(t, e);
|
|
@@ -15171,20 +15200,20 @@ async function __PRIVATE_fillWritePipeline(e) {
|
|
|
15171
15200
|
* Returns true if we can add to the write pipeline (i.e. the network is
|
|
15172
15201
|
* enabled and the write pipeline is not full).
|
|
15173
15202
|
*/ function __PRIVATE_canAddToWritePipeline(e) {
|
|
15174
|
-
return __PRIVATE_canUseNetwork(e) && e.
|
|
15203
|
+
return __PRIVATE_canUseNetwork(e) && e.U_.length < 10;
|
|
15175
15204
|
}
|
|
15176
15205
|
|
|
15177
15206
|
/**
|
|
15178
15207
|
* Queues additional writes to be sent to the write stream, sending them
|
|
15179
15208
|
* immediately if the write stream is established.
|
|
15180
15209
|
*/ function __PRIVATE_addToWritePipeline(e, t) {
|
|
15181
|
-
e.
|
|
15210
|
+
e.U_.push(t);
|
|
15182
15211
|
const n = __PRIVATE_ensureWriteStream(e);
|
|
15183
15212
|
n.c_() && n.S_ && n.b_(t.mutations);
|
|
15184
15213
|
}
|
|
15185
15214
|
|
|
15186
15215
|
function __PRIVATE_shouldStartWriteStream(e) {
|
|
15187
|
-
return __PRIVATE_canUseNetwork(e) && !__PRIVATE_ensureWriteStream(e).u_() && e.
|
|
15216
|
+
return __PRIVATE_canUseNetwork(e) && !__PRIVATE_ensureWriteStream(e).u_() && e.U_.length > 0;
|
|
15188
15217
|
}
|
|
15189
15218
|
|
|
15190
15219
|
function __PRIVATE_startWriteStream(e) {
|
|
@@ -15198,11 +15227,11 @@ async function __PRIVATE_onWriteStreamOpen(e) {
|
|
|
15198
15227
|
async function __PRIVATE_onWriteHandshakeComplete(e) {
|
|
15199
15228
|
const t = __PRIVATE_ensureWriteStream(e);
|
|
15200
15229
|
// Send the write pipeline now that the stream is established.
|
|
15201
|
-
for (const n of e.
|
|
15230
|
+
for (const n of e.U_) t.b_(n.mutations);
|
|
15202
15231
|
}
|
|
15203
15232
|
|
|
15204
15233
|
async function __PRIVATE_onMutationResult(e, t, n) {
|
|
15205
|
-
const r = e.
|
|
15234
|
+
const r = e.U_.shift(), i = MutationBatchResult.from(r, t, n);
|
|
15206
15235
|
await __PRIVATE_executeWithRecovery(e, (() => e.remoteSyncer.applySuccessfulWrite(i))),
|
|
15207
15236
|
// It's possible that with the completion of this mutation another
|
|
15208
15237
|
// slot has freed up.
|
|
@@ -15222,7 +15251,7 @@ async function __PRIVATE_onWriteStreamClose(e, t) {
|
|
|
15222
15251
|
}(t.code)) {
|
|
15223
15252
|
// This was a permanent error, the request itself was the problem
|
|
15224
15253
|
// so it's not going to succeed if we resend it.
|
|
15225
|
-
const n = e.
|
|
15254
|
+
const n = e.U_.shift();
|
|
15226
15255
|
// In this case it's also unlikely that the server itself is melting
|
|
15227
15256
|
// down -- this was just a bad request so inhibit backoff on the next
|
|
15228
15257
|
// restart.
|
|
@@ -15321,8 +15350,8 @@ async function __PRIVATE_remoteStoreHandleCredentialChange(e, t) {
|
|
|
15321
15350
|
}), e.G_.push((async t => {
|
|
15322
15351
|
t ? (e.Y_.h_(),
|
|
15323
15352
|
// This will start the write stream if necessary.
|
|
15324
|
-
await __PRIVATE_fillWritePipeline(e)) : (await e.Y_.stop(), e.
|
|
15325
|
-
e.
|
|
15353
|
+
await __PRIVATE_fillWritePipeline(e)) : (await e.Y_.stop(), e.U_.length > 0 && (__PRIVATE_logDebug(Jt, `Stopping write stream with ${e.U_.length} pending writes`),
|
|
15354
|
+
e.U_ = []));
|
|
15326
15355
|
}))), e.Y_;
|
|
15327
15356
|
}
|
|
15328
15357
|
|
|
@@ -16336,11 +16365,11 @@ const Xt = "SyncEngine";
|
|
|
16336
16365
|
* Keeps track of the information about an active limbo resolution for each
|
|
16337
16366
|
* active target ID that was started for the purpose of limbo resolution.
|
|
16338
16367
|
*/
|
|
16339
|
-
this.
|
|
16368
|
+
this.Ua = new Map, this.Ka = new __PRIVATE_ReferenceSet,
|
|
16340
16369
|
/** Stores user completion handlers, indexed by User and BatchId. */
|
|
16341
16370
|
this.Wa = {},
|
|
16342
16371
|
/** Stores user callbacks waiting for all pending writes to be acknowledged. */
|
|
16343
|
-
this.Ga = new Map, this.za = __PRIVATE_TargetIdGenerator.
|
|
16372
|
+
this.Ga = new Map, this.za = __PRIVATE_TargetIdGenerator.Kn(), this.onlineState = "Unknown" /* OnlineState.Unknown */ ,
|
|
16344
16373
|
// The primary state is set to `true` or `false` immediately after Firestore
|
|
16345
16374
|
// startup. In the interim, a client should only be considered primary if
|
|
16346
16375
|
// `isPrimary` is true.
|
|
@@ -16520,7 +16549,7 @@ async function __PRIVATE_allocateTargetAndMaybeListen(e, t, n, r) {
|
|
|
16520
16549
|
const e = await __PRIVATE_localStoreApplyRemoteEventToLocalCache(n.localStore, t);
|
|
16521
16550
|
// Update `receivedDocument` as appropriate for any limbo targets.
|
|
16522
16551
|
t.targetChanges.forEach(((e, t) => {
|
|
16523
|
-
const r = n.
|
|
16552
|
+
const r = n.Ua.get(t);
|
|
16524
16553
|
r && (
|
|
16525
16554
|
// Since this is a limbo resolution lookup, it's for a single document
|
|
16526
16555
|
// and it could be added, modified, or removed, but not a combination.
|
|
@@ -16574,7 +16603,7 @@ async function __PRIVATE_allocateTargetAndMaybeListen(e, t, n, r) {
|
|
|
16574
16603
|
const r = __PRIVATE_debugCast(e);
|
|
16575
16604
|
// PORTING NOTE: Multi-tab only.
|
|
16576
16605
|
r.sharedClientState.updateQueryState(t, "rejected", n);
|
|
16577
|
-
const i = r.
|
|
16606
|
+
const i = r.Ua.get(t), s = i && i.key;
|
|
16578
16607
|
if (s) {
|
|
16579
16608
|
// TODO(klimt): We really only should do the following on permission
|
|
16580
16609
|
// denied errors, but we don't have the cause code here.
|
|
@@ -16596,7 +16625,7 @@ async function __PRIVATE_allocateTargetAndMaybeListen(e, t, n, r) {
|
|
|
16596
16625
|
// RemoteEvent. If `applyRemoteEvent()` throws, we want to re-listen to
|
|
16597
16626
|
// this query when the RemoteStore restarts the Watch stream, which should
|
|
16598
16627
|
// re-trigger the target failure.
|
|
16599
|
-
r.$a = r.$a.remove(s), r.
|
|
16628
|
+
r.$a = r.$a.remove(s), r.Ua.delete(t), __PRIVATE_pumpEnqueuedLimboResolutions(r);
|
|
16600
16629
|
} else await __PRIVATE_localStoreReleaseTarget(r.localStore, t,
|
|
16601
16630
|
/* keepPersistedTargetData */ !1).then((() => __PRIVATE_removeAndCleanupTarget(r, t, n))).catch(__PRIVATE_ignoreIfPrimaryLeaseLoss);
|
|
16602
16631
|
}
|
|
@@ -16655,7 +16684,7 @@ async function __PRIVATE_syncEngineRejectFailedWrite(e, t, n) {
|
|
|
16655
16684
|
const t = __PRIVATE_debugCast(e);
|
|
16656
16685
|
return t.persistence.runTransaction("Get highest unacknowledged batch id", "readonly", (e => t.mutationQueue.getHighestUnacknowledgedBatchId(e)));
|
|
16657
16686
|
}(n.localStore);
|
|
16658
|
-
if (e ===
|
|
16687
|
+
if (e === U)
|
|
16659
16688
|
// Trigger the callback right away if there is no pending writes at the moment.
|
|
16660
16689
|
return void t.resolve();
|
|
16661
16690
|
const r = n.Ga.get(e) || [];
|
|
@@ -16690,8 +16719,8 @@ function __PRIVATE_removeAndCleanupTarget(e, t, n = null) {
|
|
|
16690
16719
|
e.sharedClientState.removeLocalQueryTarget(t);
|
|
16691
16720
|
for (const r of e.qa.get(t)) e.ka.delete(r), n && e.La.Ja(r, n);
|
|
16692
16721
|
if (e.qa.delete(t), e.isPrimaryClient) {
|
|
16693
|
-
e.
|
|
16694
|
-
e.
|
|
16722
|
+
e.Ka.br(t).forEach((t => {
|
|
16723
|
+
e.Ka.containsKey(t) ||
|
|
16695
16724
|
// We removed the last reference for this key
|
|
16696
16725
|
__PRIVATE_removeLimboTarget(e, t);
|
|
16697
16726
|
}));
|
|
@@ -16704,14 +16733,14 @@ function __PRIVATE_removeLimboTarget(e, t) {
|
|
|
16704
16733
|
// the key won't exist in `limboTargetsByKey`. Only do the cleanup if we still have the target.
|
|
16705
16734
|
const n = e.$a.get(t);
|
|
16706
16735
|
null !== n && (__PRIVATE_remoteStoreUnlisten(e.remoteStore, n), e.$a = e.$a.remove(t),
|
|
16707
|
-
e.
|
|
16736
|
+
e.Ua.delete(n), __PRIVATE_pumpEnqueuedLimboResolutions(e));
|
|
16708
16737
|
}
|
|
16709
16738
|
|
|
16710
16739
|
function __PRIVATE_updateTrackedLimbos(e, t, n) {
|
|
16711
|
-
for (const r of n) if (r instanceof __PRIVATE_AddedLimboDocument) e.
|
|
16740
|
+
for (const r of n) if (r instanceof __PRIVATE_AddedLimboDocument) e.Ka.addReference(r.key, t),
|
|
16712
16741
|
__PRIVATE_trackLimboChange(e, r); else if (r instanceof __PRIVATE_RemovedLimboDocument) {
|
|
16713
|
-
__PRIVATE_logDebug(Xt, "Document no longer in limbo: " + r.key), e.
|
|
16714
|
-
e.
|
|
16742
|
+
__PRIVATE_logDebug(Xt, "Document no longer in limbo: " + r.key), e.Ka.removeReference(r.key, t);
|
|
16743
|
+
e.Ka.containsKey(r.key) ||
|
|
16715
16744
|
// We removed the last reference for this key
|
|
16716
16745
|
__PRIVATE_removeLimboTarget(e, r.key);
|
|
16717
16746
|
} else fail();
|
|
@@ -16735,7 +16764,7 @@ function __PRIVATE_trackLimboChange(e, t) {
|
|
|
16735
16764
|
const t = e.Qa.values().next().value;
|
|
16736
16765
|
e.Qa.delete(t);
|
|
16737
16766
|
const n = new DocumentKey(ResourcePath.fromString(t)), r = e.za.next();
|
|
16738
|
-
e.
|
|
16767
|
+
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
16768
|
}
|
|
16740
16769
|
}
|
|
16741
16770
|
|
|
@@ -16803,7 +16832,7 @@ async function __PRIVATE_syncEngineHandleCredentialChange(e, t) {
|
|
|
16803
16832
|
}
|
|
16804
16833
|
|
|
16805
16834
|
function __PRIVATE_syncEngineGetRemoteKeysForTarget(e, t) {
|
|
16806
|
-
const n = __PRIVATE_debugCast(e), r = n.
|
|
16835
|
+
const n = __PRIVATE_debugCast(e), r = n.Ua.get(t);
|
|
16807
16836
|
if (r && r.Ba) return __PRIVATE_documentKeySet().add(r.key);
|
|
16808
16837
|
{
|
|
16809
16838
|
let e = __PRIVATE_documentKeySet();
|
|
@@ -16895,9 +16924,9 @@ async function __PRIVATE_syncEngineApplyPrimaryState(e, t) {
|
|
|
16895
16924
|
// PORTING NOTE: Multi-Tab only.
|
|
16896
16925
|
function __PRIVATE_resetLimboDocuments(e) {
|
|
16897
16926
|
const t = __PRIVATE_debugCast(e);
|
|
16898
|
-
t.
|
|
16927
|
+
t.Ua.forEach(((e, n) => {
|
|
16899
16928
|
__PRIVATE_remoteStoreUnlisten(t.remoteStore, n);
|
|
16900
|
-
})), t.
|
|
16929
|
+
})), t.Ka.Dr(), t.Ua = new Map, t.$a = new SortedMap(DocumentKey.comparator);
|
|
16901
16930
|
}
|
|
16902
16931
|
/**
|
|
16903
16932
|
* Reconcile the query views of the provided query targets with the state from
|
|
@@ -19766,7 +19795,7 @@ function __PRIVATE_isWrite(e) {
|
|
|
19766
19795
|
});
|
|
19767
19796
|
return r.$u(e), r;
|
|
19768
19797
|
}
|
|
19769
|
-
|
|
19798
|
+
Uu(e) {
|
|
19770
19799
|
var t;
|
|
19771
19800
|
const n = null === (t = this.path) || void 0 === t ? void 0 : t.child(e), r = this.ku({
|
|
19772
19801
|
path: n,
|
|
@@ -19774,7 +19803,7 @@ function __PRIVATE_isWrite(e) {
|
|
|
19774
19803
|
});
|
|
19775
19804
|
return r.Bu(), r;
|
|
19776
19805
|
}
|
|
19777
|
-
|
|
19806
|
+
Ku(e) {
|
|
19778
19807
|
// TODO(b/34871131): We don't support array paths right now; so make path
|
|
19779
19808
|
// undefined.
|
|
19780
19809
|
return this.ku({
|
|
@@ -19935,7 +19964,7 @@ class __PRIVATE_NumericIncrementFieldValueImpl extends FieldValue {
|
|
|
19935
19964
|
// For Compat types, we have to "extract" the underlying types before
|
|
19936
19965
|
// performing validation.
|
|
19937
19966
|
r = d(r);
|
|
19938
|
-
const a = i.
|
|
19967
|
+
const a = i.Uu(_);
|
|
19939
19968
|
if (r instanceof __PRIVATE_DeleteFieldValueImpl)
|
|
19940
19969
|
// Add it to the field mask, but don't add anything to updateData.
|
|
19941
19970
|
s.push(_); else {
|
|
@@ -19961,7 +19990,7 @@ class __PRIVATE_NumericIncrementFieldValueImpl extends FieldValue {
|
|
|
19961
19990
|
// For Compat types, we have to "extract" the underlying types before
|
|
19962
19991
|
// performing validation.
|
|
19963
19992
|
n = d(n);
|
|
19964
|
-
const r = o.
|
|
19993
|
+
const r = o.Uu(t);
|
|
19965
19994
|
if (n instanceof __PRIVATE_DeleteFieldValueImpl)
|
|
19966
19995
|
// Add it to the field mask, but don't add anything to updateData.
|
|
19967
19996
|
u.push(t); else {
|
|
@@ -20039,7 +20068,7 @@ class __PRIVATE_NumericIncrementFieldValueImpl extends FieldValue {
|
|
|
20039
20068
|
const n = [];
|
|
20040
20069
|
let r = 0;
|
|
20041
20070
|
for (const i of e) {
|
|
20042
|
-
let e = __PRIVATE_parseData(i, t.
|
|
20071
|
+
let e = __PRIVATE_parseData(i, t.Ku(r));
|
|
20043
20072
|
null == e && (
|
|
20044
20073
|
// Just include nulls in the array for fields being replaced with a
|
|
20045
20074
|
// sentinel.
|