@firebase/firestore 4.7.9-canary.a24a76aa2 → 4.7.9-canary.cf3c8fb2a
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 +9 -9
package/dist/index.cjs.js
CHANGED
|
@@ -9,7 +9,7 @@ var util = require('@firebase/util');
|
|
|
9
9
|
var bloomBlob = require('@firebase/webchannel-wrapper/bloom-blob');
|
|
10
10
|
var webchannelBlob = require('@firebase/webchannel-wrapper/webchannel-blob');
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const S = "@firebase/firestore", b = "4.7.9-canary.cf3c8fb2a";
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* @license
|
|
@@ -71,7 +71,7 @@ User.MOCK_USER = new User("mock-user");
|
|
|
71
71
|
* See the License for the specific language governing permissions and
|
|
72
72
|
* limitations under the License.
|
|
73
73
|
*/
|
|
74
|
-
let D = "11.4.0-canary.
|
|
74
|
+
let D = "11.4.0-canary.cf3c8fb2a";
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
77
|
* @license
|
|
@@ -688,6 +688,31 @@ function __PRIVATE_randomBytes(e) {
|
|
|
688
688
|
return n;
|
|
689
689
|
}
|
|
690
690
|
|
|
691
|
+
/**
|
|
692
|
+
* @license
|
|
693
|
+
* Copyright 2023 Google LLC
|
|
694
|
+
*
|
|
695
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
696
|
+
* you may not use this file except in compliance with the License.
|
|
697
|
+
* You may obtain a copy of the License at
|
|
698
|
+
*
|
|
699
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
700
|
+
*
|
|
701
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
702
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
703
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
704
|
+
* See the License for the specific language governing permissions and
|
|
705
|
+
* limitations under the License.
|
|
706
|
+
*/
|
|
707
|
+
/**
|
|
708
|
+
* An instance of the Platform's 'TextEncoder' implementation.
|
|
709
|
+
*/ function __PRIVATE_newTextEncoder() {
|
|
710
|
+
return new TextEncoder;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
/**
|
|
714
|
+
* An instance of the Platform's 'TextDecoder' implementation.
|
|
715
|
+
*/
|
|
691
716
|
/**
|
|
692
717
|
* @license
|
|
693
718
|
* Copyright 2017 Google LLC
|
|
@@ -709,7 +734,8 @@ function __PRIVATE_randomBytes(e) {
|
|
|
709
734
|
*
|
|
710
735
|
* @internal
|
|
711
736
|
* Exported internally for testing purposes.
|
|
712
|
-
*/
|
|
737
|
+
*/
|
|
738
|
+
class __PRIVATE_AutoId {
|
|
713
739
|
static newId() {
|
|
714
740
|
// Alphanumeric characters
|
|
715
741
|
const e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", t = 62 * Math.floor(256 / 62);
|
|
@@ -730,6 +756,37 @@ function __PRIVATE_primitiveComparator(e, t) {
|
|
|
730
756
|
return e < t ? -1 : e > t ? 1 : 0;
|
|
731
757
|
}
|
|
732
758
|
|
|
759
|
+
/** Compare strings in UTF-8 encoded byte order */ function __PRIVATE_compareUtf8Strings(e, t) {
|
|
760
|
+
let n = 0;
|
|
761
|
+
for (;n < e.length && n < t.length; ) {
|
|
762
|
+
const r = e.codePointAt(n), i = t.codePointAt(n);
|
|
763
|
+
if (r !== i) {
|
|
764
|
+
if (r < 128 && i < 128)
|
|
765
|
+
// ASCII comparison
|
|
766
|
+
return __PRIVATE_primitiveComparator(r, i);
|
|
767
|
+
{
|
|
768
|
+
// Lazy instantiate TextEncoder
|
|
769
|
+
const s = __PRIVATE_newTextEncoder(), o = __PRIVATE_compareByteArrays$1(s.encode(__PRIVATE_getUtf8SafeSubstring(e, n)), s.encode(__PRIVATE_getUtf8SafeSubstring(t, n)));
|
|
770
|
+
// UTF-8 encode the character at index i for byte comparison.
|
|
771
|
+
return 0 !== o ? o : __PRIVATE_primitiveComparator(r, i);
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
// Increment by 2 for surrogate pairs, 1 otherwise
|
|
775
|
+
n += r > 65535 ? 2 : 1;
|
|
776
|
+
}
|
|
777
|
+
// Compare lengths if all characters are equal
|
|
778
|
+
return __PRIVATE_primitiveComparator(e.length, t.length);
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
function __PRIVATE_getUtf8SafeSubstring(e, t) {
|
|
782
|
+
return e.codePointAt(t) > 65535 ? e.substring(t, t + 2) : e.substring(t, t + 1);
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
function __PRIVATE_compareByteArrays$1(e, t) {
|
|
786
|
+
for (let n = 0; n < e.length && n < t.length; ++n) if (e[n] !== t[n]) return __PRIVATE_primitiveComparator(e[n], t[n]);
|
|
787
|
+
return __PRIVATE_primitiveComparator(e.length, t.length);
|
|
788
|
+
}
|
|
789
|
+
|
|
733
790
|
/** Helper to compare arrays using isEqual(). */ function __PRIVATE_arrayEquals(e, t, n) {
|
|
734
791
|
return e.length === t.length && e.every(((e, r) => n(e, t[r])));
|
|
735
792
|
}
|
|
@@ -1020,13 +1077,11 @@ class Timestamp {
|
|
|
1020
1077
|
const n = BasePath.compareSegments(e.get(r), t.get(r));
|
|
1021
1078
|
if (0 !== n) return n;
|
|
1022
1079
|
}
|
|
1023
|
-
return
|
|
1080
|
+
return __PRIVATE_primitiveComparator(e.length, t.length);
|
|
1024
1081
|
}
|
|
1025
1082
|
static compareSegments(e, t) {
|
|
1026
1083
|
const n = BasePath.isNumericId(e), r = BasePath.isNumericId(t);
|
|
1027
|
-
return n && !r ? -1 : !n && r ? 1 : n && r ? BasePath.extractNumericId(e).compare(BasePath.extractNumericId(t)) :
|
|
1028
|
-
// both non-numeric
|
|
1029
|
-
e < t ? -1 : e > t ? 1 : 0;
|
|
1084
|
+
return n && !r ? -1 : !n && r ? 1 : n && r ? BasePath.extractNumericId(e).compare(BasePath.extractNumericId(t)) : __PRIVATE_compareUtf8Strings(e, t);
|
|
1030
1085
|
}
|
|
1031
1086
|
// Checks if a segment is a numeric ID (starts with "__id" and ends with "__").
|
|
1032
1087
|
static isNumericId(e) {
|
|
@@ -1814,13 +1869,13 @@ class __PRIVATE_SimpleDbTransaction {
|
|
|
1814
1869
|
* within the key range or index.
|
|
1815
1870
|
*/ class __PRIVATE_IterationController {
|
|
1816
1871
|
constructor(e) {
|
|
1817
|
-
this.q = e, this.$ = !1, this.
|
|
1872
|
+
this.q = e, this.$ = !1, this.U = null;
|
|
1818
1873
|
}
|
|
1819
1874
|
get isDone() {
|
|
1820
1875
|
return this.$;
|
|
1821
1876
|
}
|
|
1822
|
-
get
|
|
1823
|
-
return this.
|
|
1877
|
+
get K() {
|
|
1878
|
+
return this.U;
|
|
1824
1879
|
}
|
|
1825
1880
|
set cursor(e) {
|
|
1826
1881
|
this.q = e;
|
|
@@ -1834,7 +1889,7 @@ class __PRIVATE_SimpleDbTransaction {
|
|
|
1834
1889
|
* This function can be called to skip to that next key, which could be
|
|
1835
1890
|
* an index or a primary key.
|
|
1836
1891
|
*/ W(e) {
|
|
1837
|
-
this.
|
|
1892
|
+
this.U = e;
|
|
1838
1893
|
}
|
|
1839
1894
|
/**
|
|
1840
1895
|
* Delete the current cursor value from the object store.
|
|
@@ -1993,7 +2048,7 @@ class __PRIVATE_SimpleDbTransaction {
|
|
|
1993
2048
|
const e = o.catch((e => (s.done(), PersistencePromise.reject(e))));
|
|
1994
2049
|
n.push(e);
|
|
1995
2050
|
}
|
|
1996
|
-
s.isDone ? r() : null === s.
|
|
2051
|
+
s.isDone ? r() : null === s.K ? i.continue() : i.continue(s.K);
|
|
1997
2052
|
};
|
|
1998
2053
|
})).next((() => PersistencePromise.waitFor(n)));
|
|
1999
2054
|
}
|
|
@@ -2314,7 +2369,7 @@ function __PRIVATE_encodeResourcePath(e) {
|
|
|
2314
2369
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2315
2370
|
* See the License for the specific language governing permissions and
|
|
2316
2371
|
* limitations under the License.
|
|
2317
|
-
*/ const
|
|
2372
|
+
*/ const U = "remoteDocuments", K = "owner", W = "owner", G = "mutationQueues", z = "userId", j = "mutations", H = "batchId", J = "userMutationsIndex", Y = [ "userId", "batchId" ];
|
|
2318
2373
|
|
|
2319
2374
|
/**
|
|
2320
2375
|
* @license
|
|
@@ -2359,7 +2414,7 @@ function __PRIVATE_newDbDocumentMutationPrefixForPath(e, t) {
|
|
|
2359
2414
|
* there is no useful information to store as the value. The raw (unencoded)
|
|
2360
2415
|
* path cannot be stored because IndexedDb doesn't store prototype
|
|
2361
2416
|
* information.
|
|
2362
|
-
*/ const Z = {}, X = "documentMutations", ee = "remoteDocumentsV14", te = [ "prefixPath", "collectionGroup", "readTime", "documentId" ], ne = "documentKeyIndex", re = [ "prefixPath", "collectionGroup", "documentId" ], ie = "collectionGroupIndex", se = [ "collectionGroup", "readTime", "prefixPath", "documentId" ], oe = "remoteDocumentGlobal", _e = "remoteDocumentGlobalKey", ae = "targets", ue = "queryTargetsIndex", ce = [ "canonicalId", "targetId" ], le = "targetDocuments", he = [ "targetId", "path" ], Pe = "documentTargetsIndex", Te = [ "path", "targetId" ], Ie = "targetGlobalKey", Ee = "targetGlobal", de = "collectionParents", Ae = [ "collectionId", "parent" ], Re = "clientMetadata", Ve = "clientId", me = "bundles", fe = "bundleId", ge = "namedQueries", pe = "name", ye = "indexConfiguration", we = "indexId",
|
|
2417
|
+
*/ const Z = {}, X = "documentMutations", ee = "remoteDocumentsV14", te = [ "prefixPath", "collectionGroup", "readTime", "documentId" ], ne = "documentKeyIndex", re = [ "prefixPath", "collectionGroup", "documentId" ], ie = "collectionGroupIndex", se = [ "collectionGroup", "readTime", "prefixPath", "documentId" ], oe = "remoteDocumentGlobal", _e = "remoteDocumentGlobalKey", ae = "targets", ue = "queryTargetsIndex", ce = [ "canonicalId", "targetId" ], le = "targetDocuments", he = [ "targetId", "path" ], Pe = "documentTargetsIndex", Te = [ "path", "targetId" ], Ie = "targetGlobalKey", Ee = "targetGlobal", de = "collectionParents", Ae = [ "collectionId", "parent" ], Re = "clientMetadata", Ve = "clientId", me = "bundles", fe = "bundleId", ge = "namedQueries", pe = "name", ye = "indexConfiguration", we = "indexId", Se = "collectionGroupIndex", be = "collectionGroup", De = "indexState", ve = [ "indexId", "uid" ], Ce = "sequenceNumberIndex", Fe = [ "uid", "sequenceNumber" ], Me = "indexEntries", xe = [ "indexId", "uid", "arrayValue", "directionalValue", "orderedDocumentKey", "documentKey" ], Oe = "documentKeyIndex", Ne = [ "indexId", "uid", "orderedDocumentKey" ], Be = "documentOverlays", Le = [ "userId", "collectionPath", "documentId" ], ke = "collectionPathOverlayIndex", qe = [ "userId", "collectionPath", "largestBatchId" ], Qe = "collectionGroupOverlayIndex", $e = [ "userId", "collectionGroup", "largestBatchId" ], Ue = "globals", Ke = "name", We = [ ...[ ...[ ...[ ...[ G, j, X, U, ae, K, Ee, le ], Re ], oe ], de ], me, ge ], Ge = [ ...We, Be ], ze = [ G, j, X, ee, ae, K, Ee, le, Re, oe, de, me, ge, Be ], je = ze, He = [ ...je, ye, De, Me ], Je = He, Ye = [ ...He, Ue ];
|
|
2363
2418
|
|
|
2364
2419
|
/**
|
|
2365
2420
|
* @license
|
|
@@ -3421,7 +3476,7 @@ function __PRIVATE_valueCompare(e, t) {
|
|
|
3421
3476
|
return __PRIVATE_compareTimestamps(__PRIVATE_getLocalWriteTime(e), __PRIVATE_getLocalWriteTime(t));
|
|
3422
3477
|
|
|
3423
3478
|
case 5 /* TypeOrder.StringValue */ :
|
|
3424
|
-
return
|
|
3479
|
+
return __PRIVATE_compareUtf8Strings(e.stringValue, t.stringValue);
|
|
3425
3480
|
|
|
3426
3481
|
case 6 /* TypeOrder.BlobValue */ :
|
|
3427
3482
|
return function __PRIVATE_compareBlobs(e, t) {
|
|
@@ -3469,7 +3524,7 @@ function __PRIVATE_valueCompare(e, t) {
|
|
|
3469
3524
|
// canonical IDs are independent of insertion order.
|
|
3470
3525
|
r.sort(), s.sort();
|
|
3471
3526
|
for (let e = 0; e < r.length && e < s.length; ++e) {
|
|
3472
|
-
const t =
|
|
3527
|
+
const t = __PRIVATE_compareUtf8Strings(r[e], s[e]);
|
|
3473
3528
|
if (0 !== t) return t;
|
|
3474
3529
|
const o = __PRIVATE_valueCompare(n[r[e]], i[s[e]]);
|
|
3475
3530
|
if (0 !== o) return o;
|
|
@@ -5881,32 +5936,6 @@ let At = null;
|
|
|
5881
5936
|
* Sets the value of the `testingHooksSpi` object.
|
|
5882
5937
|
* @param instance the instance to set.
|
|
5883
5938
|
*/
|
|
5884
|
-
/**
|
|
5885
|
-
* @license
|
|
5886
|
-
* Copyright 2023 Google LLC
|
|
5887
|
-
*
|
|
5888
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5889
|
-
* you may not use this file except in compliance with the License.
|
|
5890
|
-
* You may obtain a copy of the License at
|
|
5891
|
-
*
|
|
5892
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
5893
|
-
*
|
|
5894
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
5895
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
5896
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
5897
|
-
* See the License for the specific language governing permissions and
|
|
5898
|
-
* limitations under the License.
|
|
5899
|
-
*/
|
|
5900
|
-
/**
|
|
5901
|
-
* An instance of the Platform's 'TextEncoder' implementation.
|
|
5902
|
-
*/
|
|
5903
|
-
function __PRIVATE_newTextEncoder() {
|
|
5904
|
-
return new TextEncoder;
|
|
5905
|
-
}
|
|
5906
|
-
|
|
5907
|
-
/**
|
|
5908
|
-
* An instance of the Platform's 'TextDecoder' implementation.
|
|
5909
|
-
*/
|
|
5910
5939
|
/**
|
|
5911
5940
|
* @license
|
|
5912
5941
|
* Copyright 2022 Google LLC
|
|
@@ -6187,13 +6216,13 @@ class __PRIVATE_WatchTargetChange {
|
|
|
6187
6216
|
*/
|
|
6188
6217
|
this.ye = __PRIVATE_snapshotChangesMap(),
|
|
6189
6218
|
/** See public getters for explanations of these fields. */
|
|
6190
|
-
this.we = ByteString.EMPTY_BYTE_STRING, this.
|
|
6219
|
+
this.we = ByteString.EMPTY_BYTE_STRING, this.Se = !1,
|
|
6191
6220
|
/**
|
|
6192
6221
|
* Whether this target state should be included in the next snapshot. We
|
|
6193
6222
|
* initialize to true so that newly-added targets are included in the next
|
|
6194
6223
|
* RemoteEvent.
|
|
6195
6224
|
*/
|
|
6196
|
-
this.
|
|
6225
|
+
this.be = !0;
|
|
6197
6226
|
}
|
|
6198
6227
|
/**
|
|
6199
6228
|
* Whether this target has been marked 'current'.
|
|
@@ -6203,7 +6232,7 @@ class __PRIVATE_WatchTargetChange {
|
|
|
6203
6232
|
* was added and that the target is consistent with the rest of the watch
|
|
6204
6233
|
* stream.
|
|
6205
6234
|
*/ get current() {
|
|
6206
|
-
return this.
|
|
6235
|
+
return this.Se;
|
|
6207
6236
|
}
|
|
6208
6237
|
/** The last resume token sent to us for this target. */ get resumeToken() {
|
|
6209
6238
|
return this.we;
|
|
@@ -6212,13 +6241,13 @@ class __PRIVATE_WatchTargetChange {
|
|
|
6212
6241
|
return 0 !== this.pe;
|
|
6213
6242
|
}
|
|
6214
6243
|
/** Whether we have modified any state that should trigger a snapshot. */ get ve() {
|
|
6215
|
-
return this.
|
|
6244
|
+
return this.be;
|
|
6216
6245
|
}
|
|
6217
6246
|
/**
|
|
6218
6247
|
* Applies the resume token to the TargetChange, but only when it has a new
|
|
6219
6248
|
* value. Empty resumeTokens are discarded.
|
|
6220
6249
|
*/ Ce(e) {
|
|
6221
|
-
e.approximateByteSize() > 0 && (this.
|
|
6250
|
+
e.approximateByteSize() > 0 && (this.be = !0, this.we = e);
|
|
6222
6251
|
}
|
|
6223
6252
|
/**
|
|
6224
6253
|
* Creates a target change from the current set of changes.
|
|
@@ -6244,18 +6273,18 @@ class __PRIVATE_WatchTargetChange {
|
|
|
6244
6273
|
default:
|
|
6245
6274
|
fail();
|
|
6246
6275
|
}
|
|
6247
|
-
})), new TargetChange(this.we, this.
|
|
6276
|
+
})), new TargetChange(this.we, this.Se, e, t, n);
|
|
6248
6277
|
}
|
|
6249
6278
|
/**
|
|
6250
6279
|
* Resets the document changes and sets `hasPendingChanges` to false.
|
|
6251
6280
|
*/ Me() {
|
|
6252
|
-
this.
|
|
6281
|
+
this.be = !1, this.ye = __PRIVATE_snapshotChangesMap();
|
|
6253
6282
|
}
|
|
6254
6283
|
xe(e, t) {
|
|
6255
|
-
this.
|
|
6284
|
+
this.be = !0, this.ye = this.ye.insert(e, t);
|
|
6256
6285
|
}
|
|
6257
6286
|
Oe(e) {
|
|
6258
|
-
this.
|
|
6287
|
+
this.be = !0, this.ye = this.ye.remove(e);
|
|
6259
6288
|
}
|
|
6260
6289
|
Ne() {
|
|
6261
6290
|
this.pe += 1;
|
|
@@ -6264,7 +6293,7 @@ class __PRIVATE_WatchTargetChange {
|
|
|
6264
6293
|
this.pe -= 1, __PRIVATE_hardAssert(this.pe >= 0);
|
|
6265
6294
|
}
|
|
6266
6295
|
Le() {
|
|
6267
|
-
this.
|
|
6296
|
+
this.be = !0, this.Se = !0;
|
|
6268
6297
|
}
|
|
6269
6298
|
}
|
|
6270
6299
|
|
|
@@ -6279,13 +6308,13 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6279
6308
|
/** Keeps track of the documents to update since the last raised snapshot. */
|
|
6280
6309
|
this.Qe = __PRIVATE_mutableDocumentMap(), this.$e = __PRIVATE_documentTargetMap(),
|
|
6281
6310
|
/** A mapping of document keys to their set of target IDs. */
|
|
6282
|
-
this.
|
|
6311
|
+
this.Ue = __PRIVATE_documentTargetMap(),
|
|
6283
6312
|
/**
|
|
6284
6313
|
* A map of targets with existence filter mismatches. These targets are
|
|
6285
6314
|
* known to be inconsistent and their listens needs to be re-established by
|
|
6286
6315
|
* RemoteStore.
|
|
6287
6316
|
*/
|
|
6288
|
-
this.
|
|
6317
|
+
this.Ke = new SortedMap(__PRIVATE_primitiveComparator);
|
|
6289
6318
|
}
|
|
6290
6319
|
/**
|
|
6291
6320
|
* Processes and adds the DocumentWatchChange to the current set of changes.
|
|
@@ -6374,7 +6403,7 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6374
6403
|
// trigger re-run of the query.
|
|
6375
6404
|
this.Ye(t);
|
|
6376
6405
|
const e = 2 /* BloomFilterApplicationStatus.FalsePositive */ === i ? "TargetPurposeExistenceFilterMismatchBloom" /* TargetPurpose.ExistenceFilterMismatchBloom */ : "TargetPurposeExistenceFilterMismatch" /* TargetPurpose.ExistenceFilterMismatch */;
|
|
6377
|
-
this.
|
|
6406
|
+
this.Ke = this.Ke.insert(t, e);
|
|
6378
6407
|
}
|
|
6379
6408
|
null == At || At.rt(function __PRIVATE_createExistenceFilterMismatchInfoForTestingHooks(e, t, n, r, i) {
|
|
6380
6409
|
var s, o, _, a, u, c;
|
|
@@ -6486,7 +6515,7 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6486
6515
|
|
|
6487
6516
|
// TODO(gsoltis): Expand on this comment once GC is available in the JS
|
|
6488
6517
|
// client.
|
|
6489
|
-
this.
|
|
6518
|
+
this.Ue.forEach(((e, t) => {
|
|
6490
6519
|
let r = !0;
|
|
6491
6520
|
t.forEachWhile((e => {
|
|
6492
6521
|
const t = this.Xe(e);
|
|
@@ -6494,9 +6523,9 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6494
6523
|
!1);
|
|
6495
6524
|
})), r && (n = n.add(e));
|
|
6496
6525
|
})), this.Qe.forEach(((t, n) => n.setReadTime(e)));
|
|
6497
|
-
const r = new RemoteEvent(e, t, this.
|
|
6526
|
+
const r = new RemoteEvent(e, t, this.Ke, this.Qe, n);
|
|
6498
6527
|
return this.Qe = __PRIVATE_mutableDocumentMap(), this.$e = __PRIVATE_documentTargetMap(),
|
|
6499
|
-
this.
|
|
6528
|
+
this.Ue = __PRIVATE_documentTargetMap(), this.Ke = new SortedMap(__PRIVATE_primitiveComparator),
|
|
6500
6529
|
r;
|
|
6501
6530
|
}
|
|
6502
6531
|
/**
|
|
@@ -6508,7 +6537,7 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6508
6537
|
if (!this.Je(e)) return;
|
|
6509
6538
|
const n = this.ut(e, t.key) ? 2 /* ChangeType.Modified */ : 0 /* ChangeType.Added */;
|
|
6510
6539
|
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)),
|
|
6511
|
-
this.
|
|
6540
|
+
this.Ue = this.Ue.insert(t.key, this.ct(t.key).add(e));
|
|
6512
6541
|
}
|
|
6513
6542
|
/**
|
|
6514
6543
|
* Removes the provided document from the target mapping. If the
|
|
@@ -6524,7 +6553,7 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6524
6553
|
this.ut(e, t) ? r.xe(t, 1 /* ChangeType.Removed */) :
|
|
6525
6554
|
// The document may have entered and left the target before we raised a
|
|
6526
6555
|
// snapshot, so we can just ignore the change.
|
|
6527
|
-
r.Oe(t), this.
|
|
6556
|
+
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)),
|
|
6528
6557
|
n && (this.Qe = this.Qe.insert(t, n));
|
|
6529
6558
|
}
|
|
6530
6559
|
removeTarget(e) {
|
|
@@ -6549,8 +6578,8 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6549
6578
|
return t || (t = new __PRIVATE_TargetState, this.qe.set(e, t)), t;
|
|
6550
6579
|
}
|
|
6551
6580
|
ct(e) {
|
|
6552
|
-
let t = this.
|
|
6553
|
-
return t || (t = new SortedSet(__PRIVATE_primitiveComparator), this.
|
|
6581
|
+
let t = this.Ue.get(e);
|
|
6582
|
+
return t || (t = new SortedSet(__PRIVATE_primitiveComparator), this.Ue = this.Ue.insert(e, t)),
|
|
6554
6583
|
t;
|
|
6555
6584
|
}
|
|
6556
6585
|
_t(e) {
|
|
@@ -7733,7 +7762,7 @@ function __PRIVATE_toDbIndexState(e, t, n, r) {
|
|
|
7733
7762
|
* limitations under the License.
|
|
7734
7763
|
*/ class __PRIVATE_IndexedDbGlobalsCache {
|
|
7735
7764
|
dt(e) {
|
|
7736
|
-
return __PRIVATE_getStore(e,
|
|
7765
|
+
return __PRIVATE_getStore(e, Ue);
|
|
7737
7766
|
}
|
|
7738
7767
|
getSessionToken(e) {
|
|
7739
7768
|
return this.dt(e).get("sessionToken").next((e => {
|
|
@@ -7794,12 +7823,12 @@ class __PRIVATE_FirestoreIndexValueWriter {
|
|
|
7794
7823
|
let n = e.timestampValue;
|
|
7795
7824
|
this.ft(t, 20), "string" == typeof n && (n = __PRIVATE_normalizeTimestamp(n)), t.yt(`${n.seconds || ""}`),
|
|
7796
7825
|
t.gt(n.nanos || 0);
|
|
7797
|
-
} else if ("stringValue" in e) this.wt(e.stringValue, t), this.
|
|
7798
|
-
t.
|
|
7826
|
+
} else if ("stringValue" in e) this.wt(e.stringValue, t), this.St(t); else if ("bytesValue" in e) this.ft(t, 30),
|
|
7827
|
+
t.bt(__PRIVATE_normalizeByteString(e.bytesValue)), this.St(t); else if ("referenceValue" in e) this.Dt(e.referenceValue, t); else if ("geoPointValue" in e) {
|
|
7799
7828
|
const n = e.geoPointValue;
|
|
7800
7829
|
this.ft(t, 45), t.gt(n.latitude || 0), t.gt(n.longitude || 0);
|
|
7801
7830
|
} else "mapValue" in e ? __PRIVATE_isMaxValue(e) ? this.ft(t, Number.MAX_SAFE_INTEGER) : __PRIVATE_isVectorValue(e) ? this.vt(e.mapValue, t) : (this.Ct(e.mapValue, t),
|
|
7802
|
-
this.
|
|
7831
|
+
this.St(t)) : "arrayValue" in e ? (this.Ft(e.arrayValue, t), this.St(t)) : fail();
|
|
7803
7832
|
}
|
|
7804
7833
|
wt(e, t) {
|
|
7805
7834
|
this.ft(t, 25), this.Mt(e, t);
|
|
@@ -7836,7 +7865,7 @@ class __PRIVATE_FirestoreIndexValueWriter {
|
|
|
7836
7865
|
ft(e, t) {
|
|
7837
7866
|
e.gt(t);
|
|
7838
7867
|
}
|
|
7839
|
-
|
|
7868
|
+
St(e) {
|
|
7840
7869
|
// While the SDK does not implement truncation, the truncation marker is
|
|
7841
7870
|
// used to terminate all variable length values (which are strings, bytes,
|
|
7842
7871
|
// references, arrays and maps).
|
|
@@ -7945,10 +7974,10 @@ function __PRIVATE_unsignedNumLength(e) {
|
|
|
7945
7974
|
}
|
|
7946
7975
|
this.qt();
|
|
7947
7976
|
}
|
|
7948
|
-
|
|
7977
|
+
Ut(e) {
|
|
7949
7978
|
// Values are encoded with a single byte length prefix, followed by the
|
|
7950
7979
|
// actual value in big-endian format with leading 0 bytes dropped.
|
|
7951
|
-
const t = this.
|
|
7980
|
+
const t = this.Kt(e), n = __PRIVATE_unsignedNumLength(t);
|
|
7952
7981
|
this.Wt(1 + n), this.buffer[this.position++] = 255 & n;
|
|
7953
7982
|
// Write the length
|
|
7954
7983
|
for (let e = t.length - n; e < t.length; ++e) this.buffer[this.position++] = 255 & t[e];
|
|
@@ -7956,7 +7985,7 @@ function __PRIVATE_unsignedNumLength(e) {
|
|
|
7956
7985
|
Gt(e) {
|
|
7957
7986
|
// Values are encoded with a single byte length prefix, followed by the
|
|
7958
7987
|
// inverted value in big-endian format with leading 0 bytes dropped.
|
|
7959
|
-
const t = this.
|
|
7988
|
+
const t = this.Kt(e), n = __PRIVATE_unsignedNumLength(t);
|
|
7960
7989
|
this.Wt(1 + n), this.buffer[this.position++] = ~(255 & n);
|
|
7961
7990
|
// Write the length
|
|
7962
7991
|
for (let e = t.length - n; e < t.length; ++e) this.buffer[this.position++] = ~(255 & t[e]);
|
|
@@ -7991,7 +8020,7 @@ function __PRIVATE_unsignedNumLength(e) {
|
|
|
7991
8020
|
* -0.0 < 0.0
|
|
7992
8021
|
* all non-NaN < NaN
|
|
7993
8022
|
* NaN = NaN
|
|
7994
|
-
*/
|
|
8023
|
+
*/ Kt(e) {
|
|
7995
8024
|
const t =
|
|
7996
8025
|
/** Converts a JavaScript number to a byte array (using big endian encoding). */
|
|
7997
8026
|
function __PRIVATE_doubleToLongBits(e) {
|
|
@@ -8043,14 +8072,14 @@ class __PRIVATE_AscendingIndexByteEncoder {
|
|
|
8043
8072
|
constructor(e) {
|
|
8044
8073
|
this.Zt = e;
|
|
8045
8074
|
}
|
|
8046
|
-
|
|
8075
|
+
bt(e) {
|
|
8047
8076
|
this.Zt.Ot(e);
|
|
8048
8077
|
}
|
|
8049
8078
|
yt(e) {
|
|
8050
8079
|
this.Zt.Qt(e);
|
|
8051
8080
|
}
|
|
8052
8081
|
gt(e) {
|
|
8053
|
-
this.Zt.
|
|
8082
|
+
this.Zt.Ut(e);
|
|
8054
8083
|
}
|
|
8055
8084
|
Vt() {
|
|
8056
8085
|
this.Zt.zt();
|
|
@@ -8061,7 +8090,7 @@ class __PRIVATE_DescendingIndexByteEncoder {
|
|
|
8061
8090
|
constructor(e) {
|
|
8062
8091
|
this.Zt = e;
|
|
8063
8092
|
}
|
|
8064
|
-
|
|
8093
|
+
bt(e) {
|
|
8065
8094
|
this.Zt.Lt(e);
|
|
8066
8095
|
}
|
|
8067
8096
|
yt(e) {
|
|
@@ -8891,7 +8920,7 @@ class __PRIVATE_IndexedDbIndexManager {
|
|
|
8891
8920
|
let i = 0;
|
|
8892
8921
|
for (const s of __PRIVATE_fieldIndexGetDirectionalSegments(e)) {
|
|
8893
8922
|
const e = n[i++];
|
|
8894
|
-
for (const n of r) if (this.
|
|
8923
|
+
for (const n of r) if (this.Sn(t, s.fieldPath) && isArray(e)) r = this.bn(r, s, e); else {
|
|
8895
8924
|
const t = n.tn(s.kind);
|
|
8896
8925
|
__PRIVATE_FirestoreIndexValueWriter.xt.At(e, t);
|
|
8897
8926
|
}
|
|
@@ -8915,7 +8944,7 @@ class __PRIVATE_IndexedDbIndexManager {
|
|
|
8915
8944
|
* The method appends each value to all existing encoders (e.g. filter("a",
|
|
8916
8945
|
* "==", "a1").filter("b", "in", ["b1", "b2"]) becomes ["a1,b1", "a1,b2"]). A
|
|
8917
8946
|
* list of new encoders is returned.
|
|
8918
|
-
*/
|
|
8947
|
+
*/ bn(e, t, n) {
|
|
8919
8948
|
const r = [ ...e ], i = [];
|
|
8920
8949
|
for (const e of n.arrayValue.values || []) for (const n of r) {
|
|
8921
8950
|
const r = new __PRIVATE_IndexByteEncoder;
|
|
@@ -8923,12 +8952,12 @@ class __PRIVATE_IndexedDbIndexManager {
|
|
|
8923
8952
|
}
|
|
8924
8953
|
return i;
|
|
8925
8954
|
}
|
|
8926
|
-
|
|
8955
|
+
Sn(e, t) {
|
|
8927
8956
|
return !!e.filters.find((e => e instanceof FieldFilter && e.field.isEqual(t) && ("in" /* Operator.IN */ === e.op || "not-in" /* Operator.NOT_IN */ === e.op)));
|
|
8928
8957
|
}
|
|
8929
8958
|
getFieldIndexes(e, t) {
|
|
8930
8959
|
const n = __PRIVATE_indexConfigurationStore(e), r = __PRIVATE_indexStateStore(e);
|
|
8931
|
-
return (t ? n.G(
|
|
8960
|
+
return (t ? n.G(Se, IDBKeyRange.bound(t, t)) : n.G()).next((e => {
|
|
8932
8961
|
const t = [];
|
|
8933
8962
|
return PersistencePromise.forEach(e, (e => r.get([ e.indexId, this.uid ]).next((n => {
|
|
8934
8963
|
t.push(function __PRIVATE_fromDbIndexConfiguration(e, t) {
|
|
@@ -8946,7 +8975,7 @@ class __PRIVATE_IndexedDbIndexManager {
|
|
|
8946
8975
|
}
|
|
8947
8976
|
updateCollectionGroup(e, t, n) {
|
|
8948
8977
|
const r = __PRIVATE_indexConfigurationStore(e), i = __PRIVATE_indexStateStore(e);
|
|
8949
|
-
return this.vn(e).next((e => r.G(
|
|
8978
|
+
return this.vn(e).next((e => r.G(Se, IDBKeyRange.bound(t, t)).next((t => PersistencePromise.forEach(t, (t => i.put(__PRIVATE_toDbIndexState(t.indexId, this.uid, e, n))))))));
|
|
8950
8979
|
}
|
|
8951
8980
|
updateIndexEntries(e, t) {
|
|
8952
8981
|
// Porting Note: `getFieldIndexes()` on Web does not cache index lookups as
|
|
@@ -9143,7 +9172,7 @@ function __PRIVATE_getMinOffsetFromFieldIndexes(e) {
|
|
|
9143
9172
|
sequenceNumbersCollected: 0,
|
|
9144
9173
|
targetsRemoved: 0,
|
|
9145
9174
|
documentsRemoved: 0
|
|
9146
|
-
},
|
|
9175
|
+
}, St = 41943040;
|
|
9147
9176
|
|
|
9148
9177
|
class LruParams {
|
|
9149
9178
|
static withCacheSize(e) {
|
|
@@ -9228,7 +9257,7 @@ function removeMutationBatch(e, t, n) {
|
|
|
9228
9257
|
* limitations under the License.
|
|
9229
9258
|
*/
|
|
9230
9259
|
/** A mutation queue for a specific user, backed by IndexedDB. */ LruParams.DEFAULT_COLLECTION_PERCENTILE = 10,
|
|
9231
|
-
LruParams.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT = 1e3, LruParams.DEFAULT = new LruParams(
|
|
9260
|
+
LruParams.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT = 1e3, LruParams.DEFAULT = new LruParams(St, LruParams.DEFAULT_COLLECTION_PERCENTILE, LruParams.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),
|
|
9232
9261
|
LruParams.DISABLED = new LruParams(-1, 0, 0);
|
|
9233
9262
|
|
|
9234
9263
|
class __PRIVATE_IndexedDbMutationQueue {
|
|
@@ -9559,14 +9588,14 @@ class __PRIVATE_TargetIdGenerator {
|
|
|
9559
9588
|
next() {
|
|
9560
9589
|
return this.$n += 2, this.$n;
|
|
9561
9590
|
}
|
|
9562
|
-
static
|
|
9591
|
+
static Un() {
|
|
9563
9592
|
// The target cache generator must return '2' in its first call to `next()`
|
|
9564
9593
|
// as there is no differentiation in the protocol layer between an unset
|
|
9565
9594
|
// number and the number '0'. If we were to sent a target with target ID
|
|
9566
9595
|
// '0', the backend would consider it unset and replace it with its own ID.
|
|
9567
9596
|
return new __PRIVATE_TargetIdGenerator(0);
|
|
9568
9597
|
}
|
|
9569
|
-
static
|
|
9598
|
+
static Kn() {
|
|
9570
9599
|
// Sync engine assigns target IDs for limbo document detection.
|
|
9571
9600
|
return new __PRIVATE_TargetIdGenerator(-1);
|
|
9572
9601
|
}
|
|
@@ -9785,7 +9814,7 @@ class __PRIVATE_TargetIdGenerator {
|
|
|
9785
9814
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
9786
9815
|
* See the License for the specific language governing permissions and
|
|
9787
9816
|
* limitations under the License.
|
|
9788
|
-
*/ const
|
|
9817
|
+
*/ const bt = "LruGarbageCollector", Dt = 1048576;
|
|
9789
9818
|
|
|
9790
9819
|
function __PRIVATE_bufferEntryComparator([e, t], [n, r]) {
|
|
9791
9820
|
const i = __PRIVATE_primitiveComparator(e, n);
|
|
@@ -9838,12 +9867,12 @@ function __PRIVATE_bufferEntryComparator([e, t], [n, r]) {
|
|
|
9838
9867
|
return null !== this.Xn;
|
|
9839
9868
|
}
|
|
9840
9869
|
er(e) {
|
|
9841
|
-
__PRIVATE_logDebug(
|
|
9870
|
+
__PRIVATE_logDebug(bt, `Garbage collection scheduled in ${e}ms`), this.Xn = this.asyncQueue.enqueueAfterDelay("lru_garbage_collection" /* TimerId.LruGarbageCollection */ , e, (async () => {
|
|
9842
9871
|
this.Xn = null;
|
|
9843
9872
|
try {
|
|
9844
9873
|
await this.localStore.collectGarbage(this.garbageCollector);
|
|
9845
9874
|
} catch (e) {
|
|
9846
|
-
__PRIVATE_isIndexedDbTransactionError(e) ? __PRIVATE_logDebug(
|
|
9875
|
+
__PRIVATE_isIndexedDbTransactionError(e) ? __PRIVATE_logDebug(bt, "Ignoring IndexedDB error during garbage collection: ", e) : await __PRIVATE_ignoreIfPrimaryLeaseLoss(e);
|
|
9847
9876
|
}
|
|
9848
9877
|
await this.er(3e5);
|
|
9849
9878
|
}));
|
|
@@ -10961,13 +10990,13 @@ class OverlayedDocument {
|
|
|
10961
10990
|
*/ removeReference(e, t) {
|
|
10962
10991
|
this.wr(new __PRIVATE_DocReference(e, t));
|
|
10963
10992
|
}
|
|
10964
|
-
|
|
10993
|
+
Sr(e, t) {
|
|
10965
10994
|
e.forEach((e => this.removeReference(e, t)));
|
|
10966
10995
|
}
|
|
10967
10996
|
/**
|
|
10968
10997
|
* Clears all references with a given ID. Calls removeRef() for each key
|
|
10969
10998
|
* removed.
|
|
10970
|
-
*/
|
|
10999
|
+
*/ br(e) {
|
|
10971
11000
|
const t = new DocumentKey(new ResourcePath([])), n = new __PRIVATE_DocReference(t, e), r = new __PRIVATE_DocReference(t, e + 1), i = [];
|
|
10972
11001
|
return this.gr.forEachInRange([ n, r ], (e => {
|
|
10973
11002
|
this.wr(e), i.push(e.key);
|
|
@@ -11334,7 +11363,7 @@ class __PRIVATE_MemoryRemoteDocumentChangeBuffer extends RemoteDocumentChangeBuf
|
|
|
11334
11363
|
* A ordered bidirectional mapping between documents and the remote target
|
|
11335
11364
|
* IDs.
|
|
11336
11365
|
*/
|
|
11337
|
-
this.
|
|
11366
|
+
this.Ur = new __PRIVATE_ReferenceSet, this.targetCount = 0, this.Kr = __PRIVATE_TargetIdGenerator.Un();
|
|
11338
11367
|
}
|
|
11339
11368
|
forEachTarget(e, t) {
|
|
11340
11369
|
return this.Qr.forEach(((e, n) => t(n))), PersistencePromise.resolve();
|
|
@@ -11346,7 +11375,7 @@ class __PRIVATE_MemoryRemoteDocumentChangeBuffer extends RemoteDocumentChangeBuf
|
|
|
11346
11375
|
return PersistencePromise.resolve(this.$r);
|
|
11347
11376
|
}
|
|
11348
11377
|
allocateTargetId(e) {
|
|
11349
|
-
return this.highestTargetId = this.
|
|
11378
|
+
return this.highestTargetId = this.Kr.next(), PersistencePromise.resolve(this.highestTargetId);
|
|
11350
11379
|
}
|
|
11351
11380
|
setTargetsMetadata(e, t, n) {
|
|
11352
11381
|
return n && (this.lastRemoteSnapshotVersion = n), t > this.$r && (this.$r = t),
|
|
@@ -11355,7 +11384,7 @@ class __PRIVATE_MemoryRemoteDocumentChangeBuffer extends RemoteDocumentChangeBuf
|
|
|
11355
11384
|
zn(e) {
|
|
11356
11385
|
this.Qr.set(e.target, e);
|
|
11357
11386
|
const t = e.targetId;
|
|
11358
|
-
t > this.highestTargetId && (this.
|
|
11387
|
+
t > this.highestTargetId && (this.Kr = new __PRIVATE_TargetIdGenerator(t), this.highestTargetId = t),
|
|
11359
11388
|
e.sequenceNumber > this.$r && (this.$r = e.sequenceNumber);
|
|
11360
11389
|
}
|
|
11361
11390
|
addTargetData(e, t) {
|
|
@@ -11365,7 +11394,7 @@ class __PRIVATE_MemoryRemoteDocumentChangeBuffer extends RemoteDocumentChangeBuf
|
|
|
11365
11394
|
return this.zn(t), PersistencePromise.resolve();
|
|
11366
11395
|
}
|
|
11367
11396
|
removeTargetData(e, t) {
|
|
11368
|
-
return this.Qr.delete(t.target), this.
|
|
11397
|
+
return this.Qr.delete(t.target), this.Ur.br(t.targetId), this.targetCount -= 1,
|
|
11369
11398
|
PersistencePromise.resolve();
|
|
11370
11399
|
}
|
|
11371
11400
|
removeTargets(e, t, n) {
|
|
@@ -11384,24 +11413,24 @@ class __PRIVATE_MemoryRemoteDocumentChangeBuffer extends RemoteDocumentChangeBuf
|
|
|
11384
11413
|
return PersistencePromise.resolve(n);
|
|
11385
11414
|
}
|
|
11386
11415
|
addMatchingKeys(e, t, n) {
|
|
11387
|
-
return this.
|
|
11416
|
+
return this.Ur.yr(t, n), PersistencePromise.resolve();
|
|
11388
11417
|
}
|
|
11389
11418
|
removeMatchingKeys(e, t, n) {
|
|
11390
|
-
this.
|
|
11419
|
+
this.Ur.Sr(t, n);
|
|
11391
11420
|
const r = this.persistence.referenceDelegate, i = [];
|
|
11392
11421
|
return r && t.forEach((t => {
|
|
11393
11422
|
i.push(r.markPotentiallyOrphaned(e, t));
|
|
11394
11423
|
})), PersistencePromise.waitFor(i);
|
|
11395
11424
|
}
|
|
11396
11425
|
removeMatchingKeysForTargetId(e, t) {
|
|
11397
|
-
return this.
|
|
11426
|
+
return this.Ur.br(t), PersistencePromise.resolve();
|
|
11398
11427
|
}
|
|
11399
11428
|
getMatchingKeysForTargetId(e, t) {
|
|
11400
|
-
const n = this.
|
|
11429
|
+
const n = this.Ur.vr(t);
|
|
11401
11430
|
return PersistencePromise.resolve(n);
|
|
11402
11431
|
}
|
|
11403
11432
|
containsKey(e, t) {
|
|
11404
|
-
return PersistencePromise.resolve(this.
|
|
11433
|
+
return PersistencePromise.resolve(this.Ur.containsKey(t));
|
|
11405
11434
|
}
|
|
11406
11435
|
}
|
|
11407
11436
|
|
|
@@ -11529,7 +11558,7 @@ class __PRIVATE_MemoryEagerDelegate {
|
|
|
11529
11558
|
return this.ii.add(t.toString()), PersistencePromise.resolve();
|
|
11530
11559
|
}
|
|
11531
11560
|
removeTarget(e, t) {
|
|
11532
|
-
this.ti.
|
|
11561
|
+
this.ti.br(t.targetId).forEach((e => this.ii.add(e.toString())));
|
|
11533
11562
|
const n = this.persistence.getTargetCache();
|
|
11534
11563
|
return n.getMatchingKeysForTargetId(e, t.targetId).next((e => {
|
|
11535
11564
|
e.forEach((e => this.ii.add(e.toString())));
|
|
@@ -11662,7 +11691,7 @@ class __PRIVATE_MemoryLruDelegate {
|
|
|
11662
11691
|
*/ B(e, t, n, r) {
|
|
11663
11692
|
const i = new __PRIVATE_SimpleDbTransaction("createOrUpgrade", t);
|
|
11664
11693
|
n < 1 && r >= 1 && (!function __PRIVATE_createPrimaryClientStore(e) {
|
|
11665
|
-
e.createObjectStore(
|
|
11694
|
+
e.createObjectStore(K);
|
|
11666
11695
|
}(e), function __PRIVATE_createMutationQueue(e) {
|
|
11667
11696
|
e.createObjectStore(G, {
|
|
11668
11697
|
keyPath: z
|
|
@@ -11679,7 +11708,7 @@ class __PRIVATE_MemoryLruDelegate {
|
|
|
11679
11708
|
* Upgrade function to migrate the 'mutations' store from V1 to V3. Loads
|
|
11680
11709
|
* and rewrites all data.
|
|
11681
11710
|
*/ (e), __PRIVATE_createQueryCache(e), function __PRIVATE_createLegacyRemoteDocumentCache(e) {
|
|
11682
|
-
e.createObjectStore(
|
|
11711
|
+
e.createObjectStore(U);
|
|
11683
11712
|
}(e));
|
|
11684
11713
|
// Migration 2 to populate the targetGlobal object no longer needed since
|
|
11685
11714
|
// migration 3 unconditionally clears it.
|
|
@@ -11767,13 +11796,13 @@ class __PRIVATE_MemoryLruDelegate {
|
|
|
11767
11796
|
keyPath: te
|
|
11768
11797
|
});
|
|
11769
11798
|
t.createIndex(ne, re), t.createIndex(ie, se);
|
|
11770
|
-
}(e))).next((() => this.hi(e, i))).next((() => e.deleteObjectStore(
|
|
11799
|
+
}(e))).next((() => this.hi(e, i))).next((() => e.deleteObjectStore(U)))), n < 14 && r >= 14 && (s = s.next((() => this.Pi(e, i)))),
|
|
11771
11800
|
n < 15 && r >= 15 && (s = s.next((() => function __PRIVATE_createFieldIndex(e) {
|
|
11772
11801
|
const t = e.createObjectStore(ye, {
|
|
11773
11802
|
keyPath: we,
|
|
11774
11803
|
autoIncrement: !0
|
|
11775
11804
|
});
|
|
11776
|
-
t.createIndex(
|
|
11805
|
+
t.createIndex(Se, be, {
|
|
11777
11806
|
unique: !1
|
|
11778
11807
|
});
|
|
11779
11808
|
const n = e.createObjectStore(De, {
|
|
@@ -11796,15 +11825,15 @@ class __PRIVATE_MemoryLruDelegate {
|
|
|
11796
11825
|
t.objectStore(Me).clear();
|
|
11797
11826
|
}))), n < 17 && r >= 17 && (s = s.next((() => {
|
|
11798
11827
|
!function __PRIVATE_createGlobalsStore(e) {
|
|
11799
|
-
e.createObjectStore(
|
|
11800
|
-
keyPath:
|
|
11828
|
+
e.createObjectStore(Ue, {
|
|
11829
|
+
keyPath: Ke
|
|
11801
11830
|
});
|
|
11802
11831
|
}(e);
|
|
11803
11832
|
}))), s;
|
|
11804
11833
|
}
|
|
11805
11834
|
ai(e) {
|
|
11806
11835
|
let t = 0;
|
|
11807
|
-
return e.store(
|
|
11836
|
+
return e.store(U).Z(((e, n) => {
|
|
11808
11837
|
t += __PRIVATE_dbDocumentSize(n);
|
|
11809
11838
|
})).next((() => {
|
|
11810
11839
|
const n = {
|
|
@@ -11828,7 +11857,7 @@ class __PRIVATE_MemoryLruDelegate {
|
|
|
11828
11857
|
* Ensures that every document in the remote document cache has a corresponding sentinel row
|
|
11829
11858
|
* with a sequence number. Missing rows are given the most recently used sequence number.
|
|
11830
11859
|
*/ ui(e) {
|
|
11831
|
-
const t = e.store(le), n = e.store(
|
|
11860
|
+
const t = e.store(le), n = e.store(U);
|
|
11832
11861
|
return e.store(Ee).get(Ie).next((e => {
|
|
11833
11862
|
const r = [];
|
|
11834
11863
|
return n.Z(((n, i) => {
|
|
@@ -11859,7 +11888,7 @@ class __PRIVATE_MemoryLruDelegate {
|
|
|
11859
11888
|
};
|
|
11860
11889
|
// Helper to add an index entry iff we haven't already written it.
|
|
11861
11890
|
// Index existing remote documents.
|
|
11862
|
-
return t.store(
|
|
11891
|
+
return t.store(U).Z({
|
|
11863
11892
|
Y: !0
|
|
11864
11893
|
}, ((e, t) => {
|
|
11865
11894
|
const n = new ResourcePath(e);
|
|
@@ -11879,7 +11908,7 @@ class __PRIVATE_MemoryLruDelegate {
|
|
|
11879
11908
|
}));
|
|
11880
11909
|
}
|
|
11881
11910
|
hi(e, t) {
|
|
11882
|
-
const n = t.store(
|
|
11911
|
+
const n = t.store(U), r = [];
|
|
11883
11912
|
return n.Z(((e, n) => {
|
|
11884
11913
|
const i = t.store(ee), s = function __PRIVATE_extractKey(e) {
|
|
11885
11914
|
return e.document ? new DocumentKey(ResourcePath.fromString(e.document.name).popFirst(5)) : e.noDocument ? DocumentKey.fromSegments(e.noDocument.path) : e.unknownDocument ? DocumentKey.fromSegments(e.unknownDocument.path) : fail();
|
|
@@ -12040,7 +12069,7 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12040
12069
|
// Fail `start()` if `synchronizeTabs` is disabled and we cannot
|
|
12041
12070
|
// obtain the primary lease.
|
|
12042
12071
|
throw new FirestoreError(C.FAILED_PRECONDITION, Mt);
|
|
12043
|
-
return this.
|
|
12072
|
+
return this.Si(), this.bi(), this.Di(), this.runTransaction("getHighestListenSequenceNumber", "readonly", (e => this.Hr.getHighestSequenceNumber(e)));
|
|
12044
12073
|
})).then((e => {
|
|
12045
12074
|
this.Gr = new __PRIVATE_ListenSequence(e, this.Ii);
|
|
12046
12075
|
})).then((() => {
|
|
@@ -12197,11 +12226,11 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12197
12226
|
async shutdown() {
|
|
12198
12227
|
// The shutdown() operations are idempotent and can be called even when
|
|
12199
12228
|
// start() aborted (e.g. because it couldn't acquire the persistence lease).
|
|
12200
|
-
this.zr = !1, this.
|
|
12229
|
+
this.zr = !1, this.Ui(), this.Vi && (this.Vi.cancel(), this.Vi = null), this.Ki(),
|
|
12201
12230
|
this.Wi(),
|
|
12202
12231
|
// Use `SimpleDb.runTransaction` directly to avoid failing if another tab
|
|
12203
12232
|
// has obtained the primary lease.
|
|
12204
|
-
await this.pi.runTransaction("shutdown", "readwrite", [
|
|
12233
|
+
await this.pi.runTransaction("shutdown", "readwrite", [ K, Re ], (e => {
|
|
12205
12234
|
const t = new __PRIVATE_IndexedDbTransaction(e, __PRIVATE_ListenSequence.ae);
|
|
12206
12235
|
return this.xi(t).next((() => this.Bi(t)));
|
|
12207
12236
|
})), this.pi.close(),
|
|
@@ -12301,13 +12330,13 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12301
12330
|
return !(e < n - t) && (!(e > n) || (__PRIVATE_logError(`Detected an update time that is in the future: ${e} > ${n}`),
|
|
12302
12331
|
!1));
|
|
12303
12332
|
}
|
|
12304
|
-
|
|
12333
|
+
Si() {
|
|
12305
12334
|
null !== this.document && "function" == typeof this.document.addEventListener && (this.Ri = () => {
|
|
12306
12335
|
this.Ti.enqueueAndForget((() => (this.inForeground = "visible" === this.document.visibilityState,
|
|
12307
12336
|
this.wi())));
|
|
12308
12337
|
}, this.document.addEventListener("visibilitychange", this.Ri), this.inForeground = "visible" === this.document.visibilityState);
|
|
12309
12338
|
}
|
|
12310
|
-
|
|
12339
|
+
Ki() {
|
|
12311
12340
|
this.Ri && (this.document.removeEventListener("visibilitychange", this.Ri), this.Ri = null);
|
|
12312
12341
|
}
|
|
12313
12342
|
/**
|
|
@@ -12319,13 +12348,13 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12319
12348
|
* primary lease). LocalStorage is used for this rather than IndexedDb because
|
|
12320
12349
|
* it is a synchronous API and so can be used reliably from an unload
|
|
12321
12350
|
* handler.
|
|
12322
|
-
*/
|
|
12351
|
+
*/ bi() {
|
|
12323
12352
|
var e;
|
|
12324
12353
|
"function" == typeof (null === (e = this.window) || void 0 === e ? void 0 : e.addEventListener) && (this.Ai = () => {
|
|
12325
12354
|
// Note: In theory, this should be scheduled on the AsyncQueue since it
|
|
12326
12355
|
// accesses internal state. We execute this code directly during shutdown
|
|
12327
12356
|
// to make sure it gets a chance to run.
|
|
12328
|
-
this.
|
|
12357
|
+
this.Ui();
|
|
12329
12358
|
const e = /(?:Version|Mobile)\/1[456]/;
|
|
12330
12359
|
util.isSafari() && (navigator.appVersion.match(e) || navigator.userAgent.match(e)) &&
|
|
12331
12360
|
// On Safari 14, 15, and 16, we do not run any cleanup actions as it might
|
|
@@ -12356,7 +12385,7 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12356
12385
|
/**
|
|
12357
12386
|
* Record client as zombied (a client that had its tab closed). Zombied
|
|
12358
12387
|
* clients are ignored during primary tab selection.
|
|
12359
|
-
*/
|
|
12388
|
+
*/ Ui() {
|
|
12360
12389
|
if (this.yi) try {
|
|
12361
12390
|
this.yi.setItem(this.Qi(this.clientId), String(Date.now()));
|
|
12362
12391
|
} catch (e) {
|
|
@@ -12379,7 +12408,7 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12379
12408
|
/**
|
|
12380
12409
|
* Helper to get a typed SimpleDbStore for the primary client object store.
|
|
12381
12410
|
*/ function __PRIVATE_primaryClientStore(e) {
|
|
12382
|
-
return __PRIVATE_getStore(e,
|
|
12411
|
+
return __PRIVATE_getStore(e, K);
|
|
12383
12412
|
}
|
|
12384
12413
|
|
|
12385
12414
|
/**
|
|
@@ -13234,14 +13263,14 @@ class __PRIVATE_MutationMetadata {
|
|
|
13234
13263
|
/**
|
|
13235
13264
|
* Parses a MutationMetadata from its JSON representation in WebStorage.
|
|
13236
13265
|
* Logs a warning and returns null if the format of the data is not valid.
|
|
13237
|
-
*/ static
|
|
13266
|
+
*/ static Ss(e, t, n) {
|
|
13238
13267
|
const r = JSON.parse(n);
|
|
13239
13268
|
let i, s = "object" == typeof r && -1 !== [ "pending", "acknowledged", "rejected" ].indexOf(r.state) && (void 0 === r.error || "object" == typeof r.error);
|
|
13240
13269
|
return s && r.error && (s = "string" == typeof r.error.message && "string" == typeof r.error.code,
|
|
13241
13270
|
s && (i = new FirestoreError(r.error.code, r.error.message))), s ? new __PRIVATE_MutationMetadata(e, t, r.state, i) : (__PRIVATE_logError(qt, `Failed to parse mutation state for ID '${t}': ${n}`),
|
|
13242
13271
|
null);
|
|
13243
13272
|
}
|
|
13244
|
-
|
|
13273
|
+
bs() {
|
|
13245
13274
|
const e = {
|
|
13246
13275
|
state: this.state,
|
|
13247
13276
|
updateTimeMs: Date.now()
|
|
@@ -13265,14 +13294,14 @@ class __PRIVATE_QueryTargetMetadata {
|
|
|
13265
13294
|
/**
|
|
13266
13295
|
* Parses a QueryTargetMetadata from its JSON representation in WebStorage.
|
|
13267
13296
|
* Logs a warning and returns null if the format of the data is not valid.
|
|
13268
|
-
*/ static
|
|
13297
|
+
*/ static Ss(e, t) {
|
|
13269
13298
|
const n = JSON.parse(t);
|
|
13270
13299
|
let r, i = "object" == typeof n && -1 !== [ "not-current", "current", "rejected" ].indexOf(n.state) && (void 0 === n.error || "object" == typeof n.error);
|
|
13271
13300
|
return i && n.error && (i = "string" == typeof n.error.message && "string" == typeof n.error.code,
|
|
13272
13301
|
i && (r = new FirestoreError(n.error.code, n.error.message))), i ? new __PRIVATE_QueryTargetMetadata(e, n.state, r) : (__PRIVATE_logError(qt, `Failed to parse target state for ID '${e}': ${t}`),
|
|
13273
13302
|
null);
|
|
13274
13303
|
}
|
|
13275
|
-
|
|
13304
|
+
bs() {
|
|
13276
13305
|
const e = {
|
|
13277
13306
|
state: this.state,
|
|
13278
13307
|
updateTimeMs: Date.now()
|
|
@@ -13294,7 +13323,7 @@ class __PRIVATE_QueryTargetMetadata {
|
|
|
13294
13323
|
/**
|
|
13295
13324
|
* Parses a RemoteClientState from the JSON representation in WebStorage.
|
|
13296
13325
|
* Logs a warning and returns null if the format of the data is not valid.
|
|
13297
|
-
*/ static
|
|
13326
|
+
*/ static Ss(e, t) {
|
|
13298
13327
|
const n = JSON.parse(t);
|
|
13299
13328
|
let r = "object" == typeof n && n.activeTargetIds instanceof Array, i = __PRIVATE_targetIdSet();
|
|
13300
13329
|
for (let e = 0; r && e < n.activeTargetIds.length; ++e) r = isSafeInteger(n.activeTargetIds[e]),
|
|
@@ -13315,7 +13344,7 @@ class __PRIVATE_QueryTargetMetadata {
|
|
|
13315
13344
|
/**
|
|
13316
13345
|
* Parses a SharedOnlineState from its JSON representation in WebStorage.
|
|
13317
13346
|
* Logs a warning and returns null if the format of the data is not valid.
|
|
13318
|
-
*/ static
|
|
13347
|
+
*/ static Ss(e) {
|
|
13319
13348
|
const t = JSON.parse(e);
|
|
13320
13349
|
return "object" == typeof t && -1 !== [ "Unknown", "Online", "Offline" ].indexOf(t.onlineState) && "string" == typeof t.clientId ? new __PRIVATE_SharedOnlineState(t.clientId, t.onlineState) : (__PRIVATE_logError(qt, `Failed to parse online state: ${e}`),
|
|
13321
13350
|
null);
|
|
@@ -13346,7 +13375,7 @@ class __PRIVATE_LocalClientState {
|
|
|
13346
13375
|
/**
|
|
13347
13376
|
* Converts this entry into a JSON-encoded format we can use for WebStorage.
|
|
13348
13377
|
* Does not encode `clientId` as it is part of the key in WebStorage.
|
|
13349
|
-
*/
|
|
13378
|
+
*/ bs() {
|
|
13350
13379
|
const e = {
|
|
13351
13380
|
activeTargetIds: this.activeTargetIds.toArray(),
|
|
13352
13381
|
updateTimeMs: Date.now()
|
|
@@ -13414,16 +13443,16 @@ class __PRIVATE_LocalClientState {
|
|
|
13414
13443
|
if (t === this.Cs) continue;
|
|
13415
13444
|
const e = this.getItem(createWebStorageClientStateKey(this.persistenceKey, t));
|
|
13416
13445
|
if (e) {
|
|
13417
|
-
const n = __PRIVATE_RemoteClientState.
|
|
13446
|
+
const n = __PRIVATE_RemoteClientState.Ss(t, e);
|
|
13418
13447
|
n && (this.xs = this.xs.insert(n.clientId, n));
|
|
13419
13448
|
}
|
|
13420
13449
|
}
|
|
13421
|
-
this.
|
|
13450
|
+
this.Us();
|
|
13422
13451
|
// Check if there is an existing online state and call the callback handler
|
|
13423
13452
|
// if applicable.
|
|
13424
13453
|
const t = this.storage.getItem(this.Qs);
|
|
13425
13454
|
if (t) {
|
|
13426
|
-
const e = this.
|
|
13455
|
+
const e = this.Ks(t);
|
|
13427
13456
|
e && this.Ws(e);
|
|
13428
13457
|
}
|
|
13429
13458
|
for (const e of this.Os) this.Ms(e);
|
|
@@ -13461,16 +13490,16 @@ class __PRIVATE_LocalClientState {
|
|
|
13461
13490
|
if (this.isActiveQueryTarget(e)) {
|
|
13462
13491
|
const t = this.storage.getItem(createWebStorageQueryTargetMetadataKey(this.persistenceKey, e));
|
|
13463
13492
|
if (t) {
|
|
13464
|
-
const r = __PRIVATE_QueryTargetMetadata.
|
|
13493
|
+
const r = __PRIVATE_QueryTargetMetadata.Ss(e, t);
|
|
13465
13494
|
r && (n = r.state);
|
|
13466
13495
|
}
|
|
13467
13496
|
}
|
|
13468
13497
|
// If the query is listening to cache only, the target ID should not be registered with the
|
|
13469
13498
|
// local Firestore client as an active watch target.
|
|
13470
|
-
return t && this.Hs.Ds(e), this.
|
|
13499
|
+
return t && this.Hs.Ds(e), this.Us(), n;
|
|
13471
13500
|
}
|
|
13472
13501
|
removeLocalQueryTarget(e) {
|
|
13473
|
-
this.Hs.vs(e), this.
|
|
13502
|
+
this.Hs.vs(e), this.Us();
|
|
13474
13503
|
}
|
|
13475
13504
|
isLocalQueryTarget(e) {
|
|
13476
13505
|
return this.Hs.activeTargetIds.has(e);
|
|
@@ -13537,7 +13566,7 @@ class __PRIVATE_LocalClientState {
|
|
|
13537
13566
|
}
|
|
13538
13567
|
} else if (t.key === this.Qs) {
|
|
13539
13568
|
if (null !== t.newValue) {
|
|
13540
|
-
const e = this.
|
|
13569
|
+
const e = this.Ks(t.newValue);
|
|
13541
13570
|
if (e) return this.Ws(e);
|
|
13542
13571
|
}
|
|
13543
13572
|
} else if (t.key === this.Bs) {
|
|
@@ -13568,12 +13597,12 @@ class __PRIVATE_LocalClientState {
|
|
|
13568
13597
|
get Hs() {
|
|
13569
13598
|
return this.xs.get(this.Cs);
|
|
13570
13599
|
}
|
|
13571
|
-
|
|
13572
|
-
this.setItem(this.Ns, this.Hs.
|
|
13600
|
+
Us() {
|
|
13601
|
+
this.setItem(this.Ns, this.Hs.bs());
|
|
13573
13602
|
}
|
|
13574
13603
|
zs(e, t, n) {
|
|
13575
13604
|
const r = new __PRIVATE_MutationMetadata(this.currentUser, e, t, n), i = createWebStorageMutationBatchKey(this.persistenceKey, this.currentUser, e);
|
|
13576
|
-
this.setItem(i, r.
|
|
13605
|
+
this.setItem(i, r.bs());
|
|
13577
13606
|
}
|
|
13578
13607
|
js(e) {
|
|
13579
13608
|
const t = createWebStorageMutationBatchKey(this.persistenceKey, this.currentUser, e);
|
|
@@ -13588,7 +13617,7 @@ class __PRIVATE_LocalClientState {
|
|
|
13588
13617
|
}
|
|
13589
13618
|
Js(e, t, n) {
|
|
13590
13619
|
const r = createWebStorageQueryTargetMetadataKey(this.persistenceKey, e), i = new __PRIVATE_QueryTargetMetadata(e, t, n);
|
|
13591
|
-
this.setItem(r, i.
|
|
13620
|
+
this.setItem(r, i.bs());
|
|
13592
13621
|
}
|
|
13593
13622
|
Zs(e) {
|
|
13594
13623
|
const t = JSON.stringify(Array.from(e));
|
|
@@ -13606,27 +13635,27 @@ class __PRIVATE_LocalClientState {
|
|
|
13606
13635
|
* be parsed.
|
|
13607
13636
|
*/ no(e, t) {
|
|
13608
13637
|
const n = this.Xs(e);
|
|
13609
|
-
return __PRIVATE_RemoteClientState.
|
|
13638
|
+
return __PRIVATE_RemoteClientState.Ss(n, t);
|
|
13610
13639
|
}
|
|
13611
13640
|
/**
|
|
13612
13641
|
* Parses a mutation batch state in WebStorage. Returns 'null' if the value
|
|
13613
13642
|
* could not be parsed.
|
|
13614
13643
|
*/ ro(e, t) {
|
|
13615
13644
|
const n = this.ks.exec(e), r = Number(n[1]), i = void 0 !== n[2] ? n[2] : null;
|
|
13616
|
-
return __PRIVATE_MutationMetadata.
|
|
13645
|
+
return __PRIVATE_MutationMetadata.Ss(new User(i), r, t);
|
|
13617
13646
|
}
|
|
13618
13647
|
/**
|
|
13619
13648
|
* Parses a query target state from WebStorage. Returns 'null' if the value
|
|
13620
13649
|
* could not be parsed.
|
|
13621
13650
|
*/ so(e, t) {
|
|
13622
13651
|
const n = this.qs.exec(e), r = Number(n[1]);
|
|
13623
|
-
return __PRIVATE_QueryTargetMetadata.
|
|
13652
|
+
return __PRIVATE_QueryTargetMetadata.Ss(r, t);
|
|
13624
13653
|
}
|
|
13625
13654
|
/**
|
|
13626
13655
|
* Parses an online state from WebStorage. Returns 'null' if the value
|
|
13627
13656
|
* could not be parsed.
|
|
13628
|
-
*/
|
|
13629
|
-
return __PRIVATE_SharedOnlineState.
|
|
13657
|
+
*/ Ks(e) {
|
|
13658
|
+
return __PRIVATE_SharedOnlineState.Ss(e);
|
|
13630
13659
|
}
|
|
13631
13660
|
_o(e) {
|
|
13632
13661
|
return JSON.parse(e);
|
|
@@ -13850,7 +13879,7 @@ function __PRIVATE_generateUniqueDebugId() {
|
|
|
13850
13879
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13851
13880
|
* See the License for the specific language governing permissions and
|
|
13852
13881
|
* limitations under the License.
|
|
13853
|
-
*/ const
|
|
13882
|
+
*/ const Ut = "RestConnection", Kt = {
|
|
13854
13883
|
BatchGetDocuments: "batchGet",
|
|
13855
13884
|
Commit: "commit",
|
|
13856
13885
|
RunQuery: "runQuery",
|
|
@@ -13877,23 +13906,23 @@ class __PRIVATE_RestConnection {
|
|
|
13877
13906
|
const t = e.ssl ? "https" : "http", n = encodeURIComponent(this.databaseId.projectId), r = encodeURIComponent(this.databaseId.database);
|
|
13878
13907
|
this.po = t + "://" + e.host, this.yo = `projects/${n}/databases/${r}`, this.wo = this.databaseId.database === rt ? `project_id=${n}` : `project_id=${n}&database_id=${r}`;
|
|
13879
13908
|
}
|
|
13880
|
-
|
|
13881
|
-
const s = __PRIVATE_generateUniqueDebugId(), o = this.
|
|
13882
|
-
__PRIVATE_logDebug(
|
|
13909
|
+
So(e, t, n, r, i) {
|
|
13910
|
+
const s = __PRIVATE_generateUniqueDebugId(), o = this.bo(e, t.toUriEncodedString());
|
|
13911
|
+
__PRIVATE_logDebug(Ut, `Sending RPC '${e}' ${s}:`, o, n);
|
|
13883
13912
|
const _ = {
|
|
13884
13913
|
"google-cloud-resource-prefix": this.yo,
|
|
13885
13914
|
"x-goog-request-params": this.wo
|
|
13886
13915
|
};
|
|
13887
|
-
return this.Do(_, r, i), this.vo(e, o, _, n).then((t => (__PRIVATE_logDebug(
|
|
13916
|
+
return this.Do(_, r, i), this.vo(e, o, _, n).then((t => (__PRIVATE_logDebug(Ut, `Received RPC '${e}' ${s}: `, t),
|
|
13888
13917
|
t)), (t => {
|
|
13889
|
-
throw __PRIVATE_logWarn(
|
|
13918
|
+
throw __PRIVATE_logWarn(Ut, `RPC '${e}' ${s} failed with error: `, t, "url: ", o, "request:", n),
|
|
13890
13919
|
t;
|
|
13891
13920
|
}));
|
|
13892
13921
|
}
|
|
13893
13922
|
Co(e, t, n, r, i, s) {
|
|
13894
13923
|
// The REST API automatically aggregates all of the streamed results, so we
|
|
13895
13924
|
// can just use the normal invoke() method.
|
|
13896
|
-
return this.
|
|
13925
|
+
return this.So(e, t, n, r, i);
|
|
13897
13926
|
}
|
|
13898
13927
|
/**
|
|
13899
13928
|
* Modifies the headers for a request, adding any authorization token if
|
|
@@ -13912,8 +13941,8 @@ class __PRIVATE_RestConnection {
|
|
|
13912
13941
|
e["Content-Type"] = "text/plain", this.databaseInfo.appId && (e["X-Firebase-GMPID"] = this.databaseInfo.appId),
|
|
13913
13942
|
t && t.headers.forEach(((t, n) => e[n] = t)), n && n.headers.forEach(((t, n) => e[n] = t));
|
|
13914
13943
|
}
|
|
13915
|
-
|
|
13916
|
-
const n =
|
|
13944
|
+
bo(e, t) {
|
|
13945
|
+
const n = Kt[e];
|
|
13917
13946
|
return `${this.po}/v1/${t}:${n}`;
|
|
13918
13947
|
}
|
|
13919
13948
|
/**
|
|
@@ -13973,10 +14002,10 @@ class __PRIVATE_RestConnection {
|
|
|
13973
14002
|
$o() {
|
|
13974
14003
|
this.Bo();
|
|
13975
14004
|
}
|
|
13976
|
-
|
|
14005
|
+
Uo(e) {
|
|
13977
14006
|
this.ko(e);
|
|
13978
14007
|
}
|
|
13979
|
-
|
|
14008
|
+
Ko(e) {
|
|
13980
14009
|
this.qo(e);
|
|
13981
14010
|
}
|
|
13982
14011
|
}
|
|
@@ -14128,10 +14157,10 @@ class __PRIVATE_WebChannelConnection extends __PRIVATE_RestConnection {
|
|
|
14128
14157
|
h || (__PRIVATE_logDebug(Wt, `RPC '${e}' stream ${r} transport opened.`), P.Qo());
|
|
14129
14158
|
})), __PRIVATE_unguardedEventListen(c, webchannelBlob.WebChannel.EventType.CLOSE, (() => {
|
|
14130
14159
|
h || (h = !0, __PRIVATE_logDebug(Wt, `RPC '${e}' stream ${r} transport closed`),
|
|
14131
|
-
P.
|
|
14160
|
+
P.Uo());
|
|
14132
14161
|
})), __PRIVATE_unguardedEventListen(c, webchannelBlob.WebChannel.EventType.ERROR, (t => {
|
|
14133
14162
|
h || (h = !0, __PRIVATE_logWarn(Wt, `RPC '${e}' stream ${r} transport errored:`, t),
|
|
14134
|
-
P.
|
|
14163
|
+
P.Uo(new FirestoreError(C.UNAVAILABLE, "The operation could not be completed")));
|
|
14135
14164
|
})), __PRIVATE_unguardedEventListen(c, webchannelBlob.WebChannel.EventType.MESSAGE, (t => {
|
|
14136
14165
|
var n;
|
|
14137
14166
|
if (!h) {
|
|
@@ -14162,8 +14191,8 @@ class __PRIVATE_WebChannelConnection extends __PRIVATE_RestConnection {
|
|
|
14162
14191
|
}(t), i = o.message;
|
|
14163
14192
|
void 0 === n && (n = C.INTERNAL, i = "Unknown error status: " + t + " with message " + o.message),
|
|
14164
14193
|
// Mark closed so no further events are propagated
|
|
14165
|
-
h = !0, P.
|
|
14166
|
-
} else __PRIVATE_logDebug(Wt, `RPC '${e}' stream ${r} received:`, i), P.
|
|
14194
|
+
h = !0, P.Uo(new FirestoreError(n, i)), c.close();
|
|
14195
|
+
} else __PRIVATE_logDebug(Wt, `RPC '${e}' stream ${r} received:`, i), P.Ko(i);
|
|
14167
14196
|
}
|
|
14168
14197
|
})), __PRIVATE_unguardedEventListen(o, webchannelBlob.Event.STAT_EVENT, (t => {
|
|
14169
14198
|
t.stat === webchannelBlob.Stat.PROXY ? __PRIVATE_logDebug(Wt, `RPC '${e}' stream ${r} detected buffering proxy`) : t.stat === webchannelBlob.Stat.NOPROXY && __PRIVATE_logDebug(Wt, `RPC '${e}' stream ${r} detected no buffering proxy`);
|
|
@@ -14674,7 +14703,7 @@ class __PRIVATE_PersistentStream {
|
|
|
14674
14703
|
/**
|
|
14675
14704
|
* Tracks whether or not a handshake has been successfully exchanged and
|
|
14676
14705
|
* the stream is ready to accept mutations.
|
|
14677
|
-
*/ get
|
|
14706
|
+
*/ get S_() {
|
|
14678
14707
|
return this.__ > 0;
|
|
14679
14708
|
}
|
|
14680
14709
|
// Override of PersistentStream.start
|
|
@@ -14682,7 +14711,7 @@ class __PRIVATE_PersistentStream {
|
|
|
14682
14711
|
this.lastStreamToken = void 0, super.start();
|
|
14683
14712
|
}
|
|
14684
14713
|
A_() {
|
|
14685
|
-
this.
|
|
14714
|
+
this.S_ && this.b_([]);
|
|
14686
14715
|
}
|
|
14687
14716
|
f_(e, t) {
|
|
14688
14717
|
return this.connection.Wo("Write", e, t);
|
|
@@ -14713,7 +14742,7 @@ class __PRIVATE_PersistentStream {
|
|
|
14713
14742
|
const e = {};
|
|
14714
14743
|
e.database = __PRIVATE_getEncodedDatabaseId(this.serializer), this.I_(e);
|
|
14715
14744
|
}
|
|
14716
|
-
/** Sends a group of mutations to the Firestore backend to apply. */
|
|
14745
|
+
/** Sends a group of mutations to the Firestore backend to apply. */ b_(e) {
|
|
14717
14746
|
const t = {
|
|
14718
14747
|
streamToken: this.lastStreamToken,
|
|
14719
14748
|
writes: e.map((e => toMutation(this.serializer, e)))
|
|
@@ -14755,8 +14784,8 @@ class __PRIVATE_PersistentStream {
|
|
|
14755
14784
|
M_() {
|
|
14756
14785
|
if (this.F_) throw new FirestoreError(C.FAILED_PRECONDITION, "The client has already been terminated.");
|
|
14757
14786
|
}
|
|
14758
|
-
/** Invokes the provided RPC with auth and AppCheck tokens. */
|
|
14759
|
-
return this.M_(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([i, s]) => this.connection.
|
|
14787
|
+
/** Invokes the provided RPC with auth and AppCheck tokens. */ So(e, t, n, r) {
|
|
14788
|
+
return this.M_(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([i, s]) => this.connection.So(e, __PRIVATE_toResourcePath(t, n), r, i, s))).catch((e => {
|
|
14760
14789
|
throw "FirebaseError" === e.name ? (e.code === C.UNAUTHENTICATED && (this.authCredentials.invalidateToken(),
|
|
14761
14790
|
this.appCheckCredentials.invalidateToken()), e) : new FirestoreError(C.UNKNOWN, e.toString());
|
|
14762
14791
|
}));
|
|
@@ -14898,7 +14927,7 @@ class __PRIVATE_RemoteStoreImpl {
|
|
|
14898
14927
|
* purely based on order, and so we can just shift() writes from the front of
|
|
14899
14928
|
* the writePipeline as we receive responses.
|
|
14900
14929
|
*/
|
|
14901
|
-
this.
|
|
14930
|
+
this.U_ = [],
|
|
14902
14931
|
/**
|
|
14903
14932
|
* A mapping of watched targets that the client cares about tracking and the
|
|
14904
14933
|
* user has explicitly called a 'listen' for this target.
|
|
@@ -14908,7 +14937,7 @@ class __PRIVATE_RemoteStoreImpl {
|
|
|
14908
14937
|
* to the server. The targets removed with unlistens are removed eagerly
|
|
14909
14938
|
* without waiting for confirmation from the listen stream.
|
|
14910
14939
|
*/
|
|
14911
|
-
this.
|
|
14940
|
+
this.K_ = new Map,
|
|
14912
14941
|
/**
|
|
14913
14942
|
* A set of reasons for why the RemoteStore may be offline. If empty, the
|
|
14914
14943
|
* RemoteStore may start its network connections.
|
|
@@ -14955,9 +14984,9 @@ async function __PRIVATE_enableNetworkInternal(e) {
|
|
|
14955
14984
|
*/
|
|
14956
14985
|
function __PRIVATE_remoteStoreListen(e, t) {
|
|
14957
14986
|
const n = __PRIVATE_debugCast(e);
|
|
14958
|
-
n.
|
|
14987
|
+
n.K_.has(t.targetId) || (
|
|
14959
14988
|
// Mark this as something the client is currently listening for.
|
|
14960
|
-
n.
|
|
14989
|
+
n.K_.set(t.targetId, t), __PRIVATE_shouldStartWatchStream(n) ?
|
|
14961
14990
|
// The listen will be sent in onWatchStreamOpen
|
|
14962
14991
|
__PRIVATE_startWatchStream(n) : __PRIVATE_ensureWatchStream(n).c_() && __PRIVATE_sendWatchRequest(n, t));
|
|
14963
14992
|
}
|
|
@@ -14967,7 +14996,7 @@ function __PRIVATE_remoteStoreListen(e, t) {
|
|
|
14967
14996
|
* not being listened to.
|
|
14968
14997
|
*/ function __PRIVATE_remoteStoreUnlisten(e, t) {
|
|
14969
14998
|
const n = __PRIVATE_debugCast(e), r = __PRIVATE_ensureWatchStream(n);
|
|
14970
|
-
n.
|
|
14999
|
+
n.K_.delete(t), r.c_() && __PRIVATE_sendUnwatchRequest(n, t), 0 === n.K_.size && (r.c_() ? r.P_() : __PRIVATE_canUseNetwork(n) &&
|
|
14971
15000
|
// Revert to OnlineState.Unknown if the watch stream is not open and we
|
|
14972
15001
|
// have no listeners, since without any listens to send we cannot
|
|
14973
15002
|
// confirm if the stream is healthy and upgrade to OnlineState.Online.
|
|
@@ -14996,7 +15025,7 @@ function __PRIVATE_remoteStoreListen(e, t) {
|
|
|
14996
15025
|
function __PRIVATE_startWatchStream(e) {
|
|
14997
15026
|
e.H_ = new __PRIVATE_WatchChangeAggregator({
|
|
14998
15027
|
getRemoteKeysForTarget: t => e.remoteSyncer.getRemoteKeysForTarget(t),
|
|
14999
|
-
lt: t => e.
|
|
15028
|
+
lt: t => e.K_.get(t) || null,
|
|
15000
15029
|
it: () => e.datastore.serializer.databaseId
|
|
15001
15030
|
}), __PRIVATE_ensureWatchStream(e).start(), e.j_.B_();
|
|
15002
15031
|
}
|
|
@@ -15005,7 +15034,7 @@ function __PRIVATE_startWatchStream(e) {
|
|
|
15005
15034
|
* Returns whether the watch stream should be started because it's necessary
|
|
15006
15035
|
* and has not yet been started.
|
|
15007
15036
|
*/ function __PRIVATE_shouldStartWatchStream(e) {
|
|
15008
|
-
return __PRIVATE_canUseNetwork(e) && !__PRIVATE_ensureWatchStream(e).u_() && e.
|
|
15037
|
+
return __PRIVATE_canUseNetwork(e) && !__PRIVATE_ensureWatchStream(e).u_() && e.K_.size > 0;
|
|
15009
15038
|
}
|
|
15010
15039
|
|
|
15011
15040
|
function __PRIVATE_canUseNetwork(e) {
|
|
@@ -15022,7 +15051,7 @@ async function __PRIVATE_onWatchStreamConnected(e) {
|
|
|
15022
15051
|
}
|
|
15023
15052
|
|
|
15024
15053
|
async function __PRIVATE_onWatchStreamOpen(e) {
|
|
15025
|
-
e.
|
|
15054
|
+
e.K_.forEach(((t, n) => {
|
|
15026
15055
|
__PRIVATE_sendWatchRequest(e, t);
|
|
15027
15056
|
}));
|
|
15028
15057
|
}
|
|
@@ -15049,7 +15078,7 @@ async function __PRIVATE_onWatchStreamChange(e, t, n) {
|
|
|
15049
15078
|
const n = t.cause;
|
|
15050
15079
|
for (const r of t.targetIds)
|
|
15051
15080
|
// A watched target might have been removed already.
|
|
15052
|
-
e.
|
|
15081
|
+
e.K_.has(r) && (await e.remoteSyncer.rejectListen(r, n), e.K_.delete(r), e.H_.removeTarget(r));
|
|
15053
15082
|
}
|
|
15054
15083
|
/**
|
|
15055
15084
|
* Attempts to fill our write pipeline with writes from the LocalStore.
|
|
@@ -15079,21 +15108,21 @@ async function __PRIVATE_onWatchStreamChange(e, t, n) {
|
|
|
15079
15108
|
// persistent view of these when applying the completed RemoteEvent.
|
|
15080
15109
|
return n.targetChanges.forEach(((n, r) => {
|
|
15081
15110
|
if (n.resumeToken.approximateByteSize() > 0) {
|
|
15082
|
-
const i = e.
|
|
15111
|
+
const i = e.K_.get(r);
|
|
15083
15112
|
// A watched target might have been removed already.
|
|
15084
|
-
i && e.
|
|
15113
|
+
i && e.K_.set(r, i.withResumeToken(n.resumeToken, t));
|
|
15085
15114
|
}
|
|
15086
15115
|
})),
|
|
15087
15116
|
// Re-establish listens for the targets that have been invalidated by
|
|
15088
15117
|
// existence filter mismatches.
|
|
15089
15118
|
n.targetMismatches.forEach(((t, n) => {
|
|
15090
|
-
const r = e.
|
|
15119
|
+
const r = e.K_.get(t);
|
|
15091
15120
|
if (!r)
|
|
15092
15121
|
// A watched target might have been removed already.
|
|
15093
15122
|
return;
|
|
15094
15123
|
// Clear the resume token for the target, since we're in a known mismatch
|
|
15095
15124
|
// state.
|
|
15096
|
-
e.
|
|
15125
|
+
e.K_.set(t, r.withResumeToken(ByteString.EMPTY_BYTE_STRING, r.snapshotVersion)),
|
|
15097
15126
|
// Cause a hard reset by unwatching and rewatching immediately, but
|
|
15098
15127
|
// deliberately don't send a resume token so that we get a full update.
|
|
15099
15128
|
__PRIVATE_sendUnwatchRequest(e, t);
|
|
@@ -15144,11 +15173,11 @@ async function __PRIVATE_onWatchStreamChange(e, t, n) {
|
|
|
15144
15173
|
|
|
15145
15174
|
async function __PRIVATE_fillWritePipeline(e) {
|
|
15146
15175
|
const t = __PRIVATE_debugCast(e), n = __PRIVATE_ensureWriteStream(t);
|
|
15147
|
-
let r = t.
|
|
15176
|
+
let r = t.U_.length > 0 ? t.U_[t.U_.length - 1].batchId : Q;
|
|
15148
15177
|
for (;__PRIVATE_canAddToWritePipeline(t); ) try {
|
|
15149
15178
|
const e = await __PRIVATE_localStoreGetNextMutationBatch(t.localStore, r);
|
|
15150
15179
|
if (null === e) {
|
|
15151
|
-
0 === t.
|
|
15180
|
+
0 === t.U_.length && n.P_();
|
|
15152
15181
|
break;
|
|
15153
15182
|
}
|
|
15154
15183
|
r = e.batchId, __PRIVATE_addToWritePipeline(t, e);
|
|
@@ -15162,20 +15191,20 @@ async function __PRIVATE_fillWritePipeline(e) {
|
|
|
15162
15191
|
* Returns true if we can add to the write pipeline (i.e. the network is
|
|
15163
15192
|
* enabled and the write pipeline is not full).
|
|
15164
15193
|
*/ function __PRIVATE_canAddToWritePipeline(e) {
|
|
15165
|
-
return __PRIVATE_canUseNetwork(e) && e.
|
|
15194
|
+
return __PRIVATE_canUseNetwork(e) && e.U_.length < 10;
|
|
15166
15195
|
}
|
|
15167
15196
|
|
|
15168
15197
|
/**
|
|
15169
15198
|
* Queues additional writes to be sent to the write stream, sending them
|
|
15170
15199
|
* immediately if the write stream is established.
|
|
15171
15200
|
*/ function __PRIVATE_addToWritePipeline(e, t) {
|
|
15172
|
-
e.
|
|
15201
|
+
e.U_.push(t);
|
|
15173
15202
|
const n = __PRIVATE_ensureWriteStream(e);
|
|
15174
|
-
n.c_() && n.
|
|
15203
|
+
n.c_() && n.S_ && n.b_(t.mutations);
|
|
15175
15204
|
}
|
|
15176
15205
|
|
|
15177
15206
|
function __PRIVATE_shouldStartWriteStream(e) {
|
|
15178
|
-
return __PRIVATE_canUseNetwork(e) && !__PRIVATE_ensureWriteStream(e).u_() && e.
|
|
15207
|
+
return __PRIVATE_canUseNetwork(e) && !__PRIVATE_ensureWriteStream(e).u_() && e.U_.length > 0;
|
|
15179
15208
|
}
|
|
15180
15209
|
|
|
15181
15210
|
function __PRIVATE_startWriteStream(e) {
|
|
@@ -15189,11 +15218,11 @@ async function __PRIVATE_onWriteStreamOpen(e) {
|
|
|
15189
15218
|
async function __PRIVATE_onWriteHandshakeComplete(e) {
|
|
15190
15219
|
const t = __PRIVATE_ensureWriteStream(e);
|
|
15191
15220
|
// Send the write pipeline now that the stream is established.
|
|
15192
|
-
for (const n of e.
|
|
15221
|
+
for (const n of e.U_) t.b_(n.mutations);
|
|
15193
15222
|
}
|
|
15194
15223
|
|
|
15195
15224
|
async function __PRIVATE_onMutationResult(e, t, n) {
|
|
15196
|
-
const r = e.
|
|
15225
|
+
const r = e.U_.shift(), i = MutationBatchResult.from(r, t, n);
|
|
15197
15226
|
await __PRIVATE_executeWithRecovery(e, (() => e.remoteSyncer.applySuccessfulWrite(i))),
|
|
15198
15227
|
// It's possible that with the completion of this mutation another
|
|
15199
15228
|
// slot has freed up.
|
|
@@ -15203,7 +15232,7 @@ async function __PRIVATE_onMutationResult(e, t, n) {
|
|
|
15203
15232
|
async function __PRIVATE_onWriteStreamClose(e, t) {
|
|
15204
15233
|
// If the write stream closed after the write handshake completes, a write
|
|
15205
15234
|
// operation failed and we fail the pending operation.
|
|
15206
|
-
t && __PRIVATE_ensureWriteStream(e).
|
|
15235
|
+
t && __PRIVATE_ensureWriteStream(e).S_ &&
|
|
15207
15236
|
// This error affects the actual write.
|
|
15208
15237
|
await async function __PRIVATE_handleWriteError(e, t) {
|
|
15209
15238
|
// Only handle permanent errors here. If it's transient, just let the retry
|
|
@@ -15213,7 +15242,7 @@ async function __PRIVATE_onWriteStreamClose(e, t) {
|
|
|
15213
15242
|
}(t.code)) {
|
|
15214
15243
|
// This was a permanent error, the request itself was the problem
|
|
15215
15244
|
// so it's not going to succeed if we resend it.
|
|
15216
|
-
const n = e.
|
|
15245
|
+
const n = e.U_.shift();
|
|
15217
15246
|
// In this case it's also unlikely that the server itself is melting
|
|
15218
15247
|
// down -- this was just a bad request so inhibit backoff on the next
|
|
15219
15248
|
// restart.
|
|
@@ -15312,8 +15341,8 @@ async function __PRIVATE_remoteStoreHandleCredentialChange(e, t) {
|
|
|
15312
15341
|
}), e.G_.push((async t => {
|
|
15313
15342
|
t ? (e.Y_.h_(),
|
|
15314
15343
|
// This will start the write stream if necessary.
|
|
15315
|
-
await __PRIVATE_fillWritePipeline(e)) : (await e.Y_.stop(), e.
|
|
15316
|
-
e.
|
|
15344
|
+
await __PRIVATE_fillWritePipeline(e)) : (await e.Y_.stop(), e.U_.length > 0 && (__PRIVATE_logDebug(zt, `Stopping write stream with ${e.U_.length} pending writes`),
|
|
15345
|
+
e.U_ = []));
|
|
15317
15346
|
}))), e.Y_;
|
|
15318
15347
|
}
|
|
15319
15348
|
|
|
@@ -16010,7 +16039,7 @@ class __PRIVATE_RemovedLimboDocument {
|
|
|
16010
16039
|
/**
|
|
16011
16040
|
* The set of remote documents that the server has told us belongs to the target associated with
|
|
16012
16041
|
* this view.
|
|
16013
|
-
*/ get
|
|
16042
|
+
*/ get Sa() {
|
|
16014
16043
|
return this.fa;
|
|
16015
16044
|
}
|
|
16016
16045
|
/**
|
|
@@ -16022,7 +16051,7 @@ class __PRIVATE_RemovedLimboDocument {
|
|
|
16022
16051
|
* @param previousChanges - If this is being called with a refill, then start
|
|
16023
16052
|
* with this set of docs and changes instead of the current view.
|
|
16024
16053
|
* @returns a new set of docs, changes, and refill flag.
|
|
16025
|
-
*/
|
|
16054
|
+
*/ ba(e, t) {
|
|
16026
16055
|
const n = t ? t.Da : new __PRIVATE_DocumentChangeSet, r = t ? t.wa : this.wa;
|
|
16027
16056
|
let i = t ? t.mutatedKeys : this.mutatedKeys, s = r, o = !1;
|
|
16028
16057
|
// Track the last doc in a (full) limit. This is necessary, because some
|
|
@@ -16235,7 +16264,7 @@ class __PRIVATE_RemovedLimboDocument {
|
|
|
16235
16264
|
// PORTING NOTE: Multi-tab only.
|
|
16236
16265
|
Oa(e) {
|
|
16237
16266
|
this.fa = e.gs, this.pa = __PRIVATE_documentKeySet();
|
|
16238
|
-
const t = this.
|
|
16267
|
+
const t = this.ba(e.documents);
|
|
16239
16268
|
return this.applyChanges(t, /* limboResolutionEnabled= */ !0);
|
|
16240
16269
|
}
|
|
16241
16270
|
/**
|
|
@@ -16327,11 +16356,11 @@ const Jt = "SyncEngine";
|
|
|
16327
16356
|
* Keeps track of the information about an active limbo resolution for each
|
|
16328
16357
|
* active target ID that was started for the purpose of limbo resolution.
|
|
16329
16358
|
*/
|
|
16330
|
-
this.
|
|
16359
|
+
this.Ua = new Map, this.Ka = new __PRIVATE_ReferenceSet,
|
|
16331
16360
|
/** Stores user completion handlers, indexed by User and BatchId. */
|
|
16332
16361
|
this.Wa = {},
|
|
16333
16362
|
/** Stores user callbacks waiting for all pending writes to be acknowledged. */
|
|
16334
|
-
this.Ga = new Map, this.za = __PRIVATE_TargetIdGenerator.
|
|
16363
|
+
this.Ga = new Map, this.za = __PRIVATE_TargetIdGenerator.Kn(), this.onlineState = "Unknown" /* OnlineState.Unknown */ ,
|
|
16335
16364
|
// The primary state is set to `true` or `false` immediately after Firestore
|
|
16336
16365
|
// startup. In the interim, a client should only be considered primary if
|
|
16337
16366
|
// `isPrimary` is true.
|
|
@@ -16384,19 +16413,19 @@ async function __PRIVATE_allocateTargetAndMaybeListen(e, t, n, r) {
|
|
|
16384
16413
|
// targets based on view changes. This allows us to only depend on Limbo
|
|
16385
16414
|
// changes when user code includes queries.
|
|
16386
16415
|
e.Ha = (t, n, r) => async function __PRIVATE_applyDocChanges(e, t, n, r) {
|
|
16387
|
-
let i = t.view.
|
|
16416
|
+
let i = t.view.ba(n);
|
|
16388
16417
|
i.ls && (
|
|
16389
16418
|
// The query has a limit and some docs were removed, so we need
|
|
16390
16419
|
// to re-run the query against the local store to make sure we
|
|
16391
16420
|
// didn't lose any good docs that had been past the limit.
|
|
16392
16421
|
i = await __PRIVATE_localStoreExecuteQuery(e.localStore, t.query,
|
|
16393
|
-
/* usePreviousResults= */ !1).then((({documents: e}) => t.view.
|
|
16422
|
+
/* usePreviousResults= */ !1).then((({documents: e}) => t.view.ba(e, i))));
|
|
16394
16423
|
const s = r && r.targetChanges.get(t.targetId), o = r && null != r.targetMismatches.get(t.targetId), _ = t.view.applyChanges(i,
|
|
16395
16424
|
/* limboResolutionEnabled= */ e.isPrimaryClient, s, o);
|
|
16396
16425
|
return __PRIVATE_updateTrackedLimbos(e, t.targetId, _.Ma), _.snapshot;
|
|
16397
16426
|
}(e, t, n, r);
|
|
16398
16427
|
const s = await __PRIVATE_localStoreExecuteQuery(e.localStore, t,
|
|
16399
|
-
/* usePreviousResults= */ !0), o = new __PRIVATE_View(t, s.gs), _ = o.
|
|
16428
|
+
/* usePreviousResults= */ !0), o = new __PRIVATE_View(t, s.gs), _ = o.ba(s.documents), a = TargetChange.createSynthesizedTargetChangeForCurrentChange(n, r && "Offline" /* OnlineState.Offline */ !== e.onlineState, i), u = o.applyChanges(_,
|
|
16400
16429
|
/* limboResolutionEnabled= */ e.isPrimaryClient, a);
|
|
16401
16430
|
__PRIVATE_updateTrackedLimbos(e, n, u.Ma);
|
|
16402
16431
|
const c = new __PRIVATE_QueryView(t, n, o);
|
|
@@ -16511,7 +16540,7 @@ async function __PRIVATE_allocateTargetAndMaybeListen(e, t, n, r) {
|
|
|
16511
16540
|
const e = await __PRIVATE_localStoreApplyRemoteEventToLocalCache(n.localStore, t);
|
|
16512
16541
|
// Update `receivedDocument` as appropriate for any limbo targets.
|
|
16513
16542
|
t.targetChanges.forEach(((e, t) => {
|
|
16514
|
-
const r = n.
|
|
16543
|
+
const r = n.Ua.get(t);
|
|
16515
16544
|
r && (
|
|
16516
16545
|
// Since this is a limbo resolution lookup, it's for a single document
|
|
16517
16546
|
// and it could be added, modified, or removed, but not a combination.
|
|
@@ -16565,7 +16594,7 @@ async function __PRIVATE_allocateTargetAndMaybeListen(e, t, n, r) {
|
|
|
16565
16594
|
const r = __PRIVATE_debugCast(e);
|
|
16566
16595
|
// PORTING NOTE: Multi-tab only.
|
|
16567
16596
|
r.sharedClientState.updateQueryState(t, "rejected", n);
|
|
16568
|
-
const i = r.
|
|
16597
|
+
const i = r.Ua.get(t), s = i && i.key;
|
|
16569
16598
|
if (s) {
|
|
16570
16599
|
// TODO(klimt): We really only should do the following on permission
|
|
16571
16600
|
// denied errors, but we don't have the cause code here.
|
|
@@ -16587,7 +16616,7 @@ async function __PRIVATE_allocateTargetAndMaybeListen(e, t, n, r) {
|
|
|
16587
16616
|
// RemoteEvent. If `applyRemoteEvent()` throws, we want to re-listen to
|
|
16588
16617
|
// this query when the RemoteStore restarts the Watch stream, which should
|
|
16589
16618
|
// re-trigger the target failure.
|
|
16590
|
-
r.$a = r.$a.remove(s), r.
|
|
16619
|
+
r.$a = r.$a.remove(s), r.Ua.delete(t), __PRIVATE_pumpEnqueuedLimboResolutions(r);
|
|
16591
16620
|
} else await __PRIVATE_localStoreReleaseTarget(r.localStore, t,
|
|
16592
16621
|
/* keepPersistedTargetData */ !1).then((() => __PRIVATE_removeAndCleanupTarget(r, t, n))).catch(__PRIVATE_ignoreIfPrimaryLeaseLoss);
|
|
16593
16622
|
}
|
|
@@ -16681,8 +16710,8 @@ function __PRIVATE_removeAndCleanupTarget(e, t, n = null) {
|
|
|
16681
16710
|
e.sharedClientState.removeLocalQueryTarget(t);
|
|
16682
16711
|
for (const r of e.qa.get(t)) e.ka.delete(r), n && e.La.Ja(r, n);
|
|
16683
16712
|
if (e.qa.delete(t), e.isPrimaryClient) {
|
|
16684
|
-
e.
|
|
16685
|
-
e.
|
|
16713
|
+
e.Ka.br(t).forEach((t => {
|
|
16714
|
+
e.Ka.containsKey(t) ||
|
|
16686
16715
|
// We removed the last reference for this key
|
|
16687
16716
|
__PRIVATE_removeLimboTarget(e, t);
|
|
16688
16717
|
}));
|
|
@@ -16695,14 +16724,14 @@ function __PRIVATE_removeLimboTarget(e, t) {
|
|
|
16695
16724
|
// the key won't exist in `limboTargetsByKey`. Only do the cleanup if we still have the target.
|
|
16696
16725
|
const n = e.$a.get(t);
|
|
16697
16726
|
null !== n && (__PRIVATE_remoteStoreUnlisten(e.remoteStore, n), e.$a = e.$a.remove(t),
|
|
16698
|
-
e.
|
|
16727
|
+
e.Ua.delete(n), __PRIVATE_pumpEnqueuedLimboResolutions(e));
|
|
16699
16728
|
}
|
|
16700
16729
|
|
|
16701
16730
|
function __PRIVATE_updateTrackedLimbos(e, t, n) {
|
|
16702
|
-
for (const r of n) if (r instanceof __PRIVATE_AddedLimboDocument) e.
|
|
16731
|
+
for (const r of n) if (r instanceof __PRIVATE_AddedLimboDocument) e.Ka.addReference(r.key, t),
|
|
16703
16732
|
__PRIVATE_trackLimboChange(e, r); else if (r instanceof __PRIVATE_RemovedLimboDocument) {
|
|
16704
|
-
__PRIVATE_logDebug(Jt, "Document no longer in limbo: " + r.key), e.
|
|
16705
|
-
e.
|
|
16733
|
+
__PRIVATE_logDebug(Jt, "Document no longer in limbo: " + r.key), e.Ka.removeReference(r.key, t);
|
|
16734
|
+
e.Ka.containsKey(r.key) ||
|
|
16706
16735
|
// We removed the last reference for this key
|
|
16707
16736
|
__PRIVATE_removeLimboTarget(e, r.key);
|
|
16708
16737
|
} else fail();
|
|
@@ -16726,7 +16755,7 @@ function __PRIVATE_trackLimboChange(e, t) {
|
|
|
16726
16755
|
const t = e.Qa.values().next().value;
|
|
16727
16756
|
e.Qa.delete(t);
|
|
16728
16757
|
const n = new DocumentKey(ResourcePath.fromString(t)), r = e.za.next();
|
|
16729
|
-
e.
|
|
16758
|
+
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));
|
|
16730
16759
|
}
|
|
16731
16760
|
}
|
|
16732
16761
|
|
|
@@ -16794,7 +16823,7 @@ async function __PRIVATE_syncEngineHandleCredentialChange(e, t) {
|
|
|
16794
16823
|
}
|
|
16795
16824
|
|
|
16796
16825
|
function __PRIVATE_syncEngineGetRemoteKeysForTarget(e, t) {
|
|
16797
|
-
const n = __PRIVATE_debugCast(e), r = n.
|
|
16826
|
+
const n = __PRIVATE_debugCast(e), r = n.Ua.get(t);
|
|
16798
16827
|
if (r && r.Ba) return __PRIVATE_documentKeySet().add(r.key);
|
|
16799
16828
|
{
|
|
16800
16829
|
let e = __PRIVATE_documentKeySet();
|
|
@@ -16802,7 +16831,7 @@ function __PRIVATE_syncEngineGetRemoteKeysForTarget(e, t) {
|
|
|
16802
16831
|
if (!r) return e;
|
|
16803
16832
|
for (const t of r) {
|
|
16804
16833
|
const r = n.ka.get(t);
|
|
16805
|
-
e = e.unionWith(r.view.
|
|
16834
|
+
e = e.unionWith(r.view.Sa);
|
|
16806
16835
|
}
|
|
16807
16836
|
return e;
|
|
16808
16837
|
}
|
|
@@ -16886,9 +16915,9 @@ async function __PRIVATE_syncEngineApplyPrimaryState(e, t) {
|
|
|
16886
16915
|
// PORTING NOTE: Multi-Tab only.
|
|
16887
16916
|
function __PRIVATE_resetLimboDocuments(e) {
|
|
16888
16917
|
const t = __PRIVATE_debugCast(e);
|
|
16889
|
-
t.
|
|
16918
|
+
t.Ua.forEach(((e, n) => {
|
|
16890
16919
|
__PRIVATE_remoteStoreUnlisten(t.remoteStore, n);
|
|
16891
|
-
})), t.
|
|
16920
|
+
})), t.Ka.Dr(), t.Ua = new Map, t.$a = new SortedMap(DocumentKey.comparator);
|
|
16892
16921
|
}
|
|
16893
16922
|
/**
|
|
16894
16923
|
* Reconcile the query views of the provided query targets with the state from
|
|
@@ -17588,7 +17617,7 @@ class Transaction$2 {
|
|
|
17588
17617
|
const n = __PRIVATE_debugCast(e), r = {
|
|
17589
17618
|
writes: t.map((e => toMutation(n.serializer, e)))
|
|
17590
17619
|
};
|
|
17591
|
-
await n.
|
|
17620
|
+
await n.So("Commit", n.serializer.databaseId, ResourcePath.emptyPath(), r);
|
|
17592
17621
|
}(this.datastore, this.mutations), this.committed = !0;
|
|
17593
17622
|
}
|
|
17594
17623
|
recordVersion(e) {
|
|
@@ -17950,7 +17979,7 @@ function __PRIVATE_firestoreClientGetDocumentsFromLocalCache(e, t) {
|
|
|
17950
17979
|
return e.asyncQueue.enqueueAndForget((async () => async function __PRIVATE_executeQueryFromCache(e, t, n) {
|
|
17951
17980
|
try {
|
|
17952
17981
|
const r = await __PRIVATE_localStoreExecuteQuery(e, t,
|
|
17953
|
-
/* usePreviousResults= */ !0), i = new __PRIVATE_View(t, r.gs), s = i.
|
|
17982
|
+
/* usePreviousResults= */ !0), i = new __PRIVATE_View(t, r.gs), s = i.ba(r.documents), o = i.applyChanges(s,
|
|
17954
17983
|
/* limboResolutionEnabled= */ !1);
|
|
17955
17984
|
n.resolve(o.snapshot);
|
|
17956
17985
|
} catch (e) {
|
|
@@ -18323,7 +18352,7 @@ class FirestoreSettingsImpl {
|
|
|
18323
18352
|
this.host = Xt, this.ssl = en;
|
|
18324
18353
|
} else this.host = e.host, this.ssl = null !== (t = e.ssl) && void 0 !== t ? t : en;
|
|
18325
18354
|
if (this.credentials = e.credentials, this.ignoreUndefinedProperties = !!e.ignoreUndefinedProperties,
|
|
18326
|
-
this.localCache = e.localCache, void 0 === e.cacheSizeBytes) this.cacheSizeBytes =
|
|
18355
|
+
this.localCache = e.localCache, void 0 === e.cacheSizeBytes) this.cacheSizeBytes = St; else {
|
|
18327
18356
|
if (-1 !== e.cacheSizeBytes && e.cacheSizeBytes < Dt) throw new FirestoreError(C.INVALID_ARGUMENT, "cacheSizeBytes must be at least 1048576");
|
|
18328
18357
|
this.cacheSizeBytes = e.cacheSizeBytes;
|
|
18329
18358
|
}
|
|
@@ -18725,13 +18754,13 @@ class __PRIVATE_AsyncQueueImpl {
|
|
|
18725
18754
|
// Visibility handler that triggers an immediate retry of all retryable
|
|
18726
18755
|
// operations. Meant to speed up recovery when we regain file system access
|
|
18727
18756
|
// after page comes into foreground.
|
|
18728
|
-
this.
|
|
18757
|
+
this.Su = () => {
|
|
18729
18758
|
const e = getDocument();
|
|
18730
18759
|
e && __PRIVATE_logDebug(tn, "Visibility state changed to " + e.visibilityState),
|
|
18731
18760
|
this.a_.t_();
|
|
18732
|
-
}, this.
|
|
18761
|
+
}, this.bu = e;
|
|
18733
18762
|
const t = getDocument();
|
|
18734
|
-
t && "function" == typeof t.addEventListener && t.addEventListener("visibilitychange", this.
|
|
18763
|
+
t && "function" == typeof t.addEventListener && t.addEventListener("visibilitychange", this.Su);
|
|
18735
18764
|
}
|
|
18736
18765
|
get isShuttingDown() {
|
|
18737
18766
|
return this.mu;
|
|
@@ -18752,7 +18781,7 @@ class __PRIVATE_AsyncQueueImpl {
|
|
|
18752
18781
|
if (!this.mu) {
|
|
18753
18782
|
this.mu = !0, this.yu = e || !1;
|
|
18754
18783
|
const t = getDocument();
|
|
18755
|
-
t && "function" == typeof t.removeEventListener && t.removeEventListener("visibilitychange", this.
|
|
18784
|
+
t && "function" == typeof t.removeEventListener && t.removeEventListener("visibilitychange", this.Su);
|
|
18756
18785
|
}
|
|
18757
18786
|
}
|
|
18758
18787
|
enqueue(e) {
|
|
@@ -18796,7 +18825,7 @@ class __PRIVATE_AsyncQueueImpl {
|
|
|
18796
18825
|
}
|
|
18797
18826
|
}
|
|
18798
18827
|
vu(e) {
|
|
18799
|
-
const t = this.
|
|
18828
|
+
const t = this.bu.then((() => (this.pu = !0, e().catch((e => {
|
|
18800
18829
|
this.gu = e, this.pu = !1;
|
|
18801
18830
|
const t =
|
|
18802
18831
|
/**
|
|
@@ -18830,7 +18859,7 @@ class __PRIVATE_AsyncQueueImpl {
|
|
|
18830
18859
|
// and return the rejected Promise.
|
|
18831
18860
|
throw __PRIVATE_logError("INTERNAL UNHANDLED ERROR: ", t), e;
|
|
18832
18861
|
})).then((e => (this.pu = !1, e))))));
|
|
18833
|
-
return this.
|
|
18862
|
+
return this.bu = t, t;
|
|
18834
18863
|
}
|
|
18835
18864
|
enqueueAfterDelay(e, t, n) {
|
|
18836
18865
|
this.Du(),
|
|
@@ -18853,8 +18882,8 @@ class __PRIVATE_AsyncQueueImpl {
|
|
|
18853
18882
|
// operations were executed.
|
|
18854
18883
|
let e;
|
|
18855
18884
|
do {
|
|
18856
|
-
e = this.
|
|
18857
|
-
} while (e !== this.
|
|
18885
|
+
e = this.bu, await e;
|
|
18886
|
+
} while (e !== this.bu);
|
|
18858
18887
|
}
|
|
18859
18888
|
/**
|
|
18860
18889
|
* For Tests: Determine if a delayed operation with a particular TimerId
|
|
@@ -19757,7 +19786,7 @@ function __PRIVATE_isWrite(e) {
|
|
|
19757
19786
|
});
|
|
19758
19787
|
return r.$u(e), r;
|
|
19759
19788
|
}
|
|
19760
|
-
|
|
19789
|
+
Uu(e) {
|
|
19761
19790
|
var t;
|
|
19762
19791
|
const n = null === (t = this.path) || void 0 === t ? void 0 : t.child(e), r = this.ku({
|
|
19763
19792
|
path: n,
|
|
@@ -19765,7 +19794,7 @@ function __PRIVATE_isWrite(e) {
|
|
|
19765
19794
|
});
|
|
19766
19795
|
return r.Bu(), r;
|
|
19767
19796
|
}
|
|
19768
|
-
|
|
19797
|
+
Ku(e) {
|
|
19769
19798
|
// TODO(b/34871131): We don't support array paths right now; so make path
|
|
19770
19799
|
// undefined.
|
|
19771
19800
|
return this.ku({
|
|
@@ -19926,7 +19955,7 @@ class __PRIVATE_NumericIncrementFieldValueImpl extends FieldValue {
|
|
|
19926
19955
|
// For Compat types, we have to "extract" the underlying types before
|
|
19927
19956
|
// performing validation.
|
|
19928
19957
|
r = util.getModularInstance(r);
|
|
19929
|
-
const a = i.
|
|
19958
|
+
const a = i.Uu(_);
|
|
19930
19959
|
if (r instanceof __PRIVATE_DeleteFieldValueImpl)
|
|
19931
19960
|
// Add it to the field mask, but don't add anything to updateData.
|
|
19932
19961
|
s.push(_); else {
|
|
@@ -19952,7 +19981,7 @@ class __PRIVATE_NumericIncrementFieldValueImpl extends FieldValue {
|
|
|
19952
19981
|
// For Compat types, we have to "extract" the underlying types before
|
|
19953
19982
|
// performing validation.
|
|
19954
19983
|
n = util.getModularInstance(n);
|
|
19955
|
-
const r = o.
|
|
19984
|
+
const r = o.Uu(t);
|
|
19956
19985
|
if (n instanceof __PRIVATE_DeleteFieldValueImpl)
|
|
19957
19986
|
// Add it to the field mask, but don't add anything to updateData.
|
|
19958
19987
|
u.push(t); else {
|
|
@@ -20030,7 +20059,7 @@ class __PRIVATE_NumericIncrementFieldValueImpl extends FieldValue {
|
|
|
20030
20059
|
const n = [];
|
|
20031
20060
|
let r = 0;
|
|
20032
20061
|
for (const i of e) {
|
|
20033
|
-
let e = __PRIVATE_parseData(i, t.
|
|
20062
|
+
let e = __PRIVATE_parseData(i, t.Ku(r));
|
|
20034
20063
|
null == e && (
|
|
20035
20064
|
// Just include nulls in the array for fields being replaced with a
|
|
20036
20065
|
// sentinel.
|
|
@@ -22353,9 +22382,9 @@ let an = null;
|
|
|
22353
22382
|
return r = Object.assign({
|
|
22354
22383
|
useFetchStreams: t
|
|
22355
22384
|
}, r), s._setSettings(r), s;
|
|
22356
|
-
}), "PUBLIC").setMultipleInstances(!0)), app.registerVersion(
|
|
22385
|
+
}), "PUBLIC").setMultipleInstances(!0)), app.registerVersion(S, b, e),
|
|
22357
22386
|
// BUILD_TARGET will be replaced by values like esm2017, cjs2017, etc during the compilation
|
|
22358
|
-
app.registerVersion(
|
|
22387
|
+
app.registerVersion(S, b, "cjs2017");
|
|
22359
22388
|
}();
|
|
22360
22389
|
|
|
22361
22390
|
exports.AbstractUserDataWriter = AbstractUserDataWriter;
|