@firebase/firestore 4.7.5-canary.cbec4b985 → 4.7.5-canary.ddc3192b5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/firestore/src/global_index.d.ts +8 -0
- package/dist/firestore/src/model/path.d.ts +8 -0
- package/dist/index.cjs.js +292 -270
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm2017.js +292 -270
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.node.cjs.js +48 -13
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +48 -13
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +317 -295
- package/dist/index.rn.js.map +1 -1
- package/dist/internal.d.ts +8 -0
- package/dist/lite/firestore/src/model/path.d.ts +8 -0
- package/dist/lite/index.browser.esm2017.js +193 -176
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.cjs.js +193 -176
- package/dist/lite/index.cjs.js.map +1 -1
- package/dist/lite/index.node.cjs.js +41 -12
- package/dist/lite/index.node.cjs.js.map +1 -1
- package/dist/lite/index.node.mjs +41 -12
- package/dist/lite/index.node.mjs.map +1 -1
- package/dist/lite/index.rn.esm2017.js +181 -163
- package/dist/lite/index.rn.esm2017.js.map +1 -1
- package/dist/lite/internal.d.ts +8 -0
- package/dist/lite/private.d.ts +8 -0
- package/dist/packages/firestore/src/model/path.d.ts +8 -0
- package/dist/private.d.ts +8 -0
- package/package.json +9 -9
package/dist/index.cjs.js
CHANGED
|
@@ -71,7 +71,7 @@ User.MOCK_USER = new User("mock-user");
|
|
|
71
71
|
* See the License for the specific language governing permissions and
|
|
72
72
|
* limitations under the License.
|
|
73
73
|
*/
|
|
74
|
-
let
|
|
74
|
+
let S = "11.1.0-canary.ddc3192b5";
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
77
|
* @license
|
|
@@ -89,11 +89,11 @@ let b = "11.0.2-canary.cbec4b985";
|
|
|
89
89
|
* See the License for the specific language governing permissions and
|
|
90
90
|
* limitations under the License.
|
|
91
91
|
*/
|
|
92
|
-
const
|
|
92
|
+
const b = new logger.Logger("@firebase/firestore");
|
|
93
93
|
|
|
94
94
|
// Helper methods are needed because variables can't be exported as read/write
|
|
95
95
|
function __PRIVATE_getLogLevel() {
|
|
96
|
-
return
|
|
96
|
+
return b.logLevel;
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
/**
|
|
@@ -109,29 +109,29 @@ function __PRIVATE_getLogLevel() {
|
|
|
109
109
|
* <li><code>`silent` to turn off logging.</li>
|
|
110
110
|
* </ul>
|
|
111
111
|
*/ function setLogLevel(e) {
|
|
112
|
-
|
|
112
|
+
b.setLogLevel(e);
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
function __PRIVATE_logDebug(e, ...t) {
|
|
116
|
-
if (
|
|
116
|
+
if (b.logLevel <= logger.LogLevel.DEBUG) {
|
|
117
117
|
const n = t.map(__PRIVATE_argToString);
|
|
118
|
-
|
|
118
|
+
b.debug(`Firestore (${S}): ${e}`, ...n);
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
function __PRIVATE_logError(e, ...t) {
|
|
123
|
-
if (
|
|
123
|
+
if (b.logLevel <= logger.LogLevel.ERROR) {
|
|
124
124
|
const n = t.map(__PRIVATE_argToString);
|
|
125
|
-
|
|
125
|
+
b.error(`Firestore (${S}): ${e}`, ...n);
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
/**
|
|
130
130
|
* @internal
|
|
131
131
|
*/ function __PRIVATE_logWarn(e, ...t) {
|
|
132
|
-
if (
|
|
132
|
+
if (b.logLevel <= logger.LogLevel.WARN) {
|
|
133
133
|
const n = t.map(__PRIVATE_argToString);
|
|
134
|
-
|
|
134
|
+
b.warn(`Firestore (${S}): ${e}`, ...n);
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
|
|
@@ -192,7 +192,7 @@ function __PRIVATE_logError(e, ...t) {
|
|
|
192
192
|
*/ function fail(e = "Unexpected state") {
|
|
193
193
|
// Log the failure in addition to throw an exception, just in case the
|
|
194
194
|
// exception is swallowed.
|
|
195
|
-
const t = `FIRESTORE (${
|
|
195
|
+
const t = `FIRESTORE (${S}) INTERNAL ASSERTION FAILED: ` + e;
|
|
196
196
|
// NOTE: We don't use FirestoreError here because these are internal failures
|
|
197
197
|
// that cannot be handled by the user. (Also it would create a circular
|
|
198
198
|
// dependency between the error and assert modules which doesn't work.)
|
|
@@ -1005,14 +1005,30 @@ class BasePath {
|
|
|
1005
1005
|
toArray() {
|
|
1006
1006
|
return this.segments.slice(this.offset, this.limit());
|
|
1007
1007
|
}
|
|
1008
|
-
|
|
1008
|
+
/**
|
|
1009
|
+
* Compare 2 paths segment by segment, prioritizing numeric IDs
|
|
1010
|
+
* (e.g., "__id123__") in numeric ascending order, followed by string
|
|
1011
|
+
* segments in lexicographical order.
|
|
1012
|
+
*/ static comparator(e, t) {
|
|
1009
1013
|
const n = Math.min(e.length, t.length);
|
|
1010
1014
|
for (let r = 0; r < n; r++) {
|
|
1011
|
-
const n = e.get(r),
|
|
1012
|
-
if (
|
|
1013
|
-
if (n > i) return 1;
|
|
1015
|
+
const n = BasePath.compareSegments(e.get(r), t.get(r));
|
|
1016
|
+
if (0 !== n) return n;
|
|
1014
1017
|
}
|
|
1015
|
-
return e.length
|
|
1018
|
+
return Math.sign(e.length - t.length);
|
|
1019
|
+
}
|
|
1020
|
+
static compareSegments(e, t) {
|
|
1021
|
+
const n = BasePath.isNumericId(e), r = BasePath.isNumericId(t);
|
|
1022
|
+
return n && !r ? -1 : !n && r ? 1 : n && r ? BasePath.extractNumericId(e).compare(BasePath.extractNumericId(t)) :
|
|
1023
|
+
// both non-numeric
|
|
1024
|
+
e < t ? -1 : e > t ? 1 : 0;
|
|
1025
|
+
}
|
|
1026
|
+
// Checks if a segment is a numeric ID (starts with "__id" and ends with "__").
|
|
1027
|
+
static isNumericId(e) {
|
|
1028
|
+
return e.startsWith("__id") && e.endsWith("__");
|
|
1029
|
+
}
|
|
1030
|
+
static extractNumericId(e) {
|
|
1031
|
+
return bloomBlob.Integer.fromString(e.substring(4, e.length - 2));
|
|
1016
1032
|
}
|
|
1017
1033
|
}
|
|
1018
1034
|
|
|
@@ -1735,7 +1751,7 @@ class __PRIVATE_SimpleDbTransaction {
|
|
|
1735
1751
|
};
|
|
1736
1752
|
}))), this.N && (this.db.onversionchange = e => this.N(e)), this.db;
|
|
1737
1753
|
}
|
|
1738
|
-
|
|
1754
|
+
B(e) {
|
|
1739
1755
|
this.N = e, this.db && (this.db.onversionchange = t => e(t));
|
|
1740
1756
|
}
|
|
1741
1757
|
async runTransaction(e, t, n, r) {
|
|
@@ -1784,7 +1800,7 @@ class __PRIVATE_SimpleDbTransaction {
|
|
|
1784
1800
|
* within the key range or index.
|
|
1785
1801
|
*/ class __PRIVATE_IterationController {
|
|
1786
1802
|
constructor(e) {
|
|
1787
|
-
this.
|
|
1803
|
+
this.L = e, this.k = !1, this.q = null;
|
|
1788
1804
|
}
|
|
1789
1805
|
get isDone() {
|
|
1790
1806
|
return this.k;
|
|
@@ -1793,7 +1809,7 @@ class __PRIVATE_SimpleDbTransaction {
|
|
|
1793
1809
|
return this.q;
|
|
1794
1810
|
}
|
|
1795
1811
|
set cursor(e) {
|
|
1796
|
-
this.
|
|
1812
|
+
this.L = e;
|
|
1797
1813
|
}
|
|
1798
1814
|
/**
|
|
1799
1815
|
* This function can be called to stop iteration at any point.
|
|
@@ -1811,7 +1827,7 @@ class __PRIVATE_SimpleDbTransaction {
|
|
|
1811
1827
|
*
|
|
1812
1828
|
* NOTE: You CANNOT do this with a keysOnly query.
|
|
1813
1829
|
*/ delete() {
|
|
1814
|
-
return __PRIVATE_wrapRequest(this.
|
|
1830
|
+
return __PRIVATE_wrapRequest(this.L.delete());
|
|
1815
1831
|
}
|
|
1816
1832
|
}
|
|
1817
1833
|
|
|
@@ -2307,7 +2323,7 @@ function __PRIVATE_newDbDocumentMutationPrefixForPath(e, t) {
|
|
|
2307
2323
|
* there is no useful information to store as the value. The raw (unencoded)
|
|
2308
2324
|
* path cannot be stored because IndexedDb doesn't store prototype
|
|
2309
2325
|
* information.
|
|
2310
|
-
*/ const x = {}, O = [ "prefixPath", "collectionGroup", "readTime", "documentId" ], N = [ "prefixPath", "collectionGroup", "documentId" ],
|
|
2326
|
+
*/ const x = {}, O = [ "prefixPath", "collectionGroup", "readTime", "documentId" ], N = [ "prefixPath", "collectionGroup", "documentId" ], B = [ "collectionGroup", "readTime", "prefixPath", "documentId" ], L = [ "canonicalId", "targetId" ], k = [ "targetId", "path" ], q = [ "path", "targetId" ], Q = [ "collectionId", "parent" ], K = [ "indexId", "uid" ], $ = [ "uid", "sequenceNumber" ], U = [ "indexId", "uid", "arrayValue", "directionalValue", "orderedDocumentKey", "documentKey" ], W = [ "indexId", "uid", "orderedDocumentKey" ], G = [ "userId", "collectionPath", "documentId" ], z = [ "userId", "collectionPath", "largestBatchId" ], j = [ "userId", "collectionGroup", "largestBatchId" ], H = [ ...[ ...[ ...[ ...[ "mutationQueues", "mutations", "documentMutations", "remoteDocuments", "targets", "owner", "targetGlobal", "targetDocuments" ], "clientMetadata" ], "remoteDocumentGlobal" ], "collectionParents" ], "bundles", "namedQueries" ], J = [ ...H, "documentOverlays" ], Y = [ "mutationQueues", "mutations", "documentMutations", "remoteDocumentsV14", "targets", "owner", "targetGlobal", "targetDocuments", "clientMetadata", "remoteDocumentGlobal", "collectionParents", "bundles", "namedQueries", "documentOverlays" ], Z = Y, X = [ ...Z, "indexConfiguration", "indexState", "indexEntries" ], ee = X, te = [ ...X, "globals" ];
|
|
2311
2327
|
|
|
2312
2328
|
/**
|
|
2313
2329
|
* @license
|
|
@@ -5897,7 +5913,7 @@ class BloomFilter {
|
|
|
5897
5913
|
}
|
|
5898
5914
|
// Calculate the ith hash value based on the hashed 64bit integers,
|
|
5899
5915
|
// and calculate its corresponding bit index in the bitmap to be checked.
|
|
5900
|
-
|
|
5916
|
+
de(e, t, n) {
|
|
5901
5917
|
// Calculate hashed value h(i) = h1 + (i * h2).
|
|
5902
5918
|
let r = e.add(t.multiply(bloomBlob.Integer.fromNumber(n)));
|
|
5903
5919
|
// Wrap if hash value overflow 64bit.
|
|
@@ -5905,7 +5921,7 @@ class BloomFilter {
|
|
|
5905
5921
|
r.modulo(this.Ie).toNumber();
|
|
5906
5922
|
}
|
|
5907
5923
|
// Return whether the bit on the given index in the bitmap is set to 1.
|
|
5908
|
-
|
|
5924
|
+
Ee(e) {
|
|
5909
5925
|
return 0 != (this.bitmap[Math.floor(e / 8)] & 1 << e % 8);
|
|
5910
5926
|
}
|
|
5911
5927
|
mightContain(e) {
|
|
@@ -5913,8 +5929,8 @@ class BloomFilter {
|
|
|
5913
5929
|
if (0 === this.Te) return !1;
|
|
5914
5930
|
const t = __PRIVATE_getMd5HashValue(e), [n, r] = __PRIVATE_get64BitUints(t);
|
|
5915
5931
|
for (let e = 0; e < this.hashCount; e++) {
|
|
5916
|
-
const t = this.
|
|
5917
|
-
if (!this.
|
|
5932
|
+
const t = this.de(n, r, e);
|
|
5933
|
+
if (!this.Ee(t)) return !1;
|
|
5918
5934
|
}
|
|
5919
5935
|
return !0;
|
|
5920
5936
|
}
|
|
@@ -5926,7 +5942,7 @@ class BloomFilter {
|
|
|
5926
5942
|
if (0 === this.Te) return;
|
|
5927
5943
|
const t = __PRIVATE_getMd5HashValue(e), [n, r] = __PRIVATE_get64BitUints(t);
|
|
5928
5944
|
for (let e = 0; e < this.hashCount; e++) {
|
|
5929
|
-
const t = this.
|
|
5945
|
+
const t = this.de(n, r, e);
|
|
5930
5946
|
this.Ae(t);
|
|
5931
5947
|
}
|
|
5932
5948
|
}
|
|
@@ -6151,10 +6167,10 @@ class __PRIVATE_WatchTargetChange {
|
|
|
6151
6167
|
/** The last resume token sent to us for this target. */ get resumeToken() {
|
|
6152
6168
|
return this.pe;
|
|
6153
6169
|
}
|
|
6154
|
-
/** Whether this target has pending target adds or target removes. */ get
|
|
6170
|
+
/** Whether this target has pending target adds or target removes. */ get Se() {
|
|
6155
6171
|
return 0 !== this.fe;
|
|
6156
6172
|
}
|
|
6157
|
-
/** Whether we have modified any state that should trigger a snapshot. */ get
|
|
6173
|
+
/** Whether we have modified any state that should trigger a snapshot. */ get be() {
|
|
6158
6174
|
return this.we;
|
|
6159
6175
|
}
|
|
6160
6176
|
/**
|
|
@@ -6216,9 +6232,9 @@ class __PRIVATE_WatchTargetChange {
|
|
|
6216
6232
|
*/
|
|
6217
6233
|
class __PRIVATE_WatchChangeAggregator {
|
|
6218
6234
|
constructor(e) {
|
|
6219
|
-
this.
|
|
6235
|
+
this.Be = e,
|
|
6220
6236
|
/** The internal state of all tracked targets. */
|
|
6221
|
-
this.
|
|
6237
|
+
this.Le = new Map,
|
|
6222
6238
|
/** Keeps track of the documents to update since the last raised snapshot. */
|
|
6223
6239
|
this.ke = __PRIVATE_mutableDocumentMap(), this.qe = __PRIVATE_documentTargetMap(),
|
|
6224
6240
|
/** A mapping of document keys to their set of target IDs. */
|
|
@@ -6247,7 +6263,7 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6247
6263
|
case 1 /* WatchTargetChangeState.Added */ :
|
|
6248
6264
|
// We need to decrement the number of pending acks needed from watch
|
|
6249
6265
|
// for this targetId.
|
|
6250
|
-
n.Oe(), n.
|
|
6266
|
+
n.Oe(), n.Se ||
|
|
6251
6267
|
// We have a freshly added target, so we need to reset any state
|
|
6252
6268
|
// that we had previously. This can happen e.g. when remove and add
|
|
6253
6269
|
// back a target for existence filter mismatches.
|
|
@@ -6259,7 +6275,7 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6259
6275
|
// remove any target changes.
|
|
6260
6276
|
// We need to decrement the number of pending acks needed from watch
|
|
6261
6277
|
// for this targetId.
|
|
6262
|
-
n.Oe(), n.
|
|
6278
|
+
n.Oe(), n.Se || this.removeTarget(t);
|
|
6263
6279
|
break;
|
|
6264
6280
|
|
|
6265
6281
|
case 3 /* WatchTargetChangeState.Current */ :
|
|
@@ -6284,7 +6300,7 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6284
6300
|
* targetIds explicitly listed in the change or the targetIds of all currently
|
|
6285
6301
|
* active targets.
|
|
6286
6302
|
*/ forEachTarget(e, t) {
|
|
6287
|
-
e.targetIds.length > 0 ? e.targetIds.forEach(t) : this.
|
|
6303
|
+
e.targetIds.length > 0 ? e.targetIds.forEach(t) : this.Le.forEach(((e, n) => {
|
|
6288
6304
|
this.je(n) && t(n);
|
|
6289
6305
|
}));
|
|
6290
6306
|
}
|
|
@@ -6354,7 +6370,7 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6354
6370
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
6355
6371
|
* See the License for the specific language governing permissions and
|
|
6356
6372
|
* limitations under the License.
|
|
6357
|
-
*/ (r, e.me, this.
|
|
6373
|
+
*/ (r, e.me, this.Be.nt(), n, i));
|
|
6358
6374
|
}
|
|
6359
6375
|
}
|
|
6360
6376
|
}
|
|
@@ -6393,10 +6409,10 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6393
6409
|
* Filter out removed documents based on bloom filter membership result and
|
|
6394
6410
|
* return number of documents removed.
|
|
6395
6411
|
*/ rt(e, t) {
|
|
6396
|
-
const n = this.
|
|
6412
|
+
const n = this.Be.getRemoteKeysForTarget(t);
|
|
6397
6413
|
let r = 0;
|
|
6398
6414
|
return n.forEach((n => {
|
|
6399
|
-
const i = this.
|
|
6415
|
+
const i = this.Be.nt(), s = `projects/${i.projectId}/databases/${i.database}/documents/${n.path.canonicalString()}`;
|
|
6400
6416
|
e.mightContain(s) || (this.We(t, n, /*updatedDocument=*/ null), r++);
|
|
6401
6417
|
})), r;
|
|
6402
6418
|
}
|
|
@@ -6405,7 +6421,7 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6405
6421
|
* provided snapshot version. Resets the accumulated changes before returning.
|
|
6406
6422
|
*/ it(e) {
|
|
6407
6423
|
const t = new Map;
|
|
6408
|
-
this.
|
|
6424
|
+
this.Le.forEach(((n, r) => {
|
|
6409
6425
|
const i = this.Ye(r);
|
|
6410
6426
|
if (i) {
|
|
6411
6427
|
if (n.current && __PRIVATE_targetIsDocumentTarget(i.target)) {
|
|
@@ -6420,7 +6436,7 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6420
6436
|
const t = new DocumentKey(i.target.path);
|
|
6421
6437
|
this.st(t).has(r) || this.ot(r, t) || this.We(r, t, MutableDocument.newNoDocument(t, e));
|
|
6422
6438
|
}
|
|
6423
|
-
n.
|
|
6439
|
+
n.be && (t.set(r, n.ve()), n.Ce());
|
|
6424
6440
|
}
|
|
6425
6441
|
}));
|
|
6426
6442
|
let n = __PRIVATE_documentKeySet();
|
|
@@ -6471,7 +6487,7 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6471
6487
|
n && (this.ke = this.ke.insert(t, n));
|
|
6472
6488
|
}
|
|
6473
6489
|
removeTarget(e) {
|
|
6474
|
-
this.
|
|
6490
|
+
this.Le.delete(e);
|
|
6475
6491
|
}
|
|
6476
6492
|
/**
|
|
6477
6493
|
* Returns the current count of documents in the target. This includes both
|
|
@@ -6479,7 +6495,7 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6479
6495
|
* target as well as any accumulated changes.
|
|
6480
6496
|
*/ Ze(e) {
|
|
6481
6497
|
const t = this.ze(e).ve();
|
|
6482
|
-
return this.
|
|
6498
|
+
return this.Be.getRemoteKeysForTarget(e).size + t.addedDocuments.size - t.removedDocuments.size;
|
|
6483
6499
|
}
|
|
6484
6500
|
/**
|
|
6485
6501
|
* Increment the number of acks needed from watch before we can consider the
|
|
@@ -6488,8 +6504,8 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6488
6504
|
this.ze(e).xe();
|
|
6489
6505
|
}
|
|
6490
6506
|
ze(e) {
|
|
6491
|
-
let t = this.
|
|
6492
|
-
return t || (t = new __PRIVATE_TargetState, this.
|
|
6507
|
+
let t = this.Le.get(e);
|
|
6508
|
+
return t || (t = new __PRIVATE_TargetState, this.Le.set(e, t)), t;
|
|
6493
6509
|
}
|
|
6494
6510
|
_t(e) {
|
|
6495
6511
|
let t = this.Qe.get(e);
|
|
@@ -6514,16 +6530,16 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6514
6530
|
* Returns the TargetData for an active target (i.e. a target that the user
|
|
6515
6531
|
* is still interested in that has no outstanding target change requests).
|
|
6516
6532
|
*/ Ye(e) {
|
|
6517
|
-
const t = this.
|
|
6518
|
-
return t && t.
|
|
6533
|
+
const t = this.Le.get(e);
|
|
6534
|
+
return t && t.Se ? null : this.Be.ut(e);
|
|
6519
6535
|
}
|
|
6520
6536
|
/**
|
|
6521
6537
|
* Resets the state of a Watch target to its initial state (e.g. sets
|
|
6522
6538
|
* 'current' to false, clears the resume token and removes its target mapping
|
|
6523
6539
|
* from all documents).
|
|
6524
6540
|
*/ He(e) {
|
|
6525
|
-
this.
|
|
6526
|
-
this.
|
|
6541
|
+
this.Le.set(e, new __PRIVATE_TargetState);
|
|
6542
|
+
this.Be.getRemoteKeysForTarget(e).forEach((t => {
|
|
6527
6543
|
this.We(e, t, /*updatedDocument=*/ null);
|
|
6528
6544
|
}));
|
|
6529
6545
|
}
|
|
@@ -6531,7 +6547,7 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6531
6547
|
* Returns whether the LocalStore considers the document to be part of the
|
|
6532
6548
|
* specified target.
|
|
6533
6549
|
*/ ot(e, t) {
|
|
6534
|
-
return this.
|
|
6550
|
+
return this.Be.getRemoteKeysForTarget(e).has(t);
|
|
6535
6551
|
}
|
|
6536
6552
|
}
|
|
6537
6553
|
|
|
@@ -6549,7 +6565,7 @@ const Ie = (() => {
|
|
|
6549
6565
|
desc: "DESCENDING"
|
|
6550
6566
|
};
|
|
6551
6567
|
return e;
|
|
6552
|
-
})(),
|
|
6568
|
+
})(), de = (() => {
|
|
6553
6569
|
const e = {
|
|
6554
6570
|
"<": "LESS_THAN",
|
|
6555
6571
|
"<=": "LESS_THAN_OR_EQUAL",
|
|
@@ -6563,7 +6579,7 @@ const Ie = (() => {
|
|
|
6563
6579
|
"array-contains-any": "ARRAY_CONTAINS_ANY"
|
|
6564
6580
|
};
|
|
6565
6581
|
return e;
|
|
6566
|
-
})(),
|
|
6582
|
+
})(), Ee = (() => {
|
|
6567
6583
|
const e = {
|
|
6568
6584
|
and: "AND",
|
|
6569
6585
|
or: "OR"
|
|
@@ -7139,11 +7155,11 @@ function __PRIVATE_toDirection(e) {
|
|
|
7139
7155
|
}
|
|
7140
7156
|
|
|
7141
7157
|
function __PRIVATE_toOperatorName(e) {
|
|
7142
|
-
return
|
|
7158
|
+
return de[e];
|
|
7143
7159
|
}
|
|
7144
7160
|
|
|
7145
7161
|
function __PRIVATE_toCompositeOperatorName(e) {
|
|
7146
|
-
return
|
|
7162
|
+
return Ee[e];
|
|
7147
7163
|
}
|
|
7148
7164
|
|
|
7149
7165
|
function __PRIVATE_toFieldPathReference(e) {
|
|
@@ -7720,13 +7736,13 @@ class __PRIVATE_FirestoreIndexValueWriter {
|
|
|
7720
7736
|
// ["bar", [2, truncated("foo")]] -> (STRING, "bar", TERM, ARRAY, NUMBER, 2, STRING, "foo", TRUNC)
|
|
7721
7737
|
// ["bar", truncated(["foo"])] -> (STRING, "bar", TERM, ARRAY. STRING, "foo", TERM, TRUNC)
|
|
7722
7738
|
/** Writes an index value. */
|
|
7723
|
-
|
|
7724
|
-
this.
|
|
7739
|
+
dt(e, t) {
|
|
7740
|
+
this.Et(e, t),
|
|
7725
7741
|
// Write separator to split index values
|
|
7726
7742
|
// (see go/firestore-storage-format#encodings).
|
|
7727
7743
|
t.At();
|
|
7728
7744
|
}
|
|
7729
|
-
|
|
7745
|
+
Et(e, t) {
|
|
7730
7746
|
if ("nullValue" in e) this.Rt(t, 5); else if ("booleanValue" in e) this.Rt(t, 10),
|
|
7731
7747
|
t.Vt(e.booleanValue ? 1 : 0); else if ("integerValue" in e) this.Rt(t, 15), t.Vt(__PRIVATE_normalizeNumber(e.integerValue)); else if ("doubleValue" in e) {
|
|
7732
7748
|
const n = __PRIVATE_normalizeNumber(e.doubleValue);
|
|
@@ -7738,10 +7754,10 @@ class __PRIVATE_FirestoreIndexValueWriter {
|
|
|
7738
7754
|
this.Rt(t, 20), "string" == typeof n && (n = __PRIVATE_normalizeTimestamp(n)), t.ft(`${n.seconds || ""}`),
|
|
7739
7755
|
t.Vt(n.nanos || 0);
|
|
7740
7756
|
} else if ("stringValue" in e) this.gt(e.stringValue, t), this.yt(t); else if ("bytesValue" in e) this.Rt(t, 30),
|
|
7741
|
-
t.wt(__PRIVATE_normalizeByteString(e.bytesValue)), this.yt(t); else if ("referenceValue" in e) this.
|
|
7757
|
+
t.wt(__PRIVATE_normalizeByteString(e.bytesValue)), this.yt(t); else if ("referenceValue" in e) this.St(e.referenceValue, t); else if ("geoPointValue" in e) {
|
|
7742
7758
|
const n = e.geoPointValue;
|
|
7743
7759
|
this.Rt(t, 45), t.Vt(n.latitude || 0), t.Vt(n.longitude || 0);
|
|
7744
|
-
} else "mapValue" in e ? __PRIVATE_isMaxValue(e) ? this.Rt(t, Number.MAX_SAFE_INTEGER) : __PRIVATE_isVectorValue(e) ? this.
|
|
7760
|
+
} else "mapValue" in e ? __PRIVATE_isMaxValue(e) ? this.Rt(t, Number.MAX_SAFE_INTEGER) : __PRIVATE_isVectorValue(e) ? this.bt(e.mapValue, t) : (this.Dt(e.mapValue, t),
|
|
7745
7761
|
this.yt(t)) : "arrayValue" in e ? (this.vt(e.arrayValue, t), this.yt(t)) : fail();
|
|
7746
7762
|
}
|
|
7747
7763
|
gt(e, t) {
|
|
@@ -7753,9 +7769,9 @@ class __PRIVATE_FirestoreIndexValueWriter {
|
|
|
7753
7769
|
Dt(e, t) {
|
|
7754
7770
|
const n = e.fields || {};
|
|
7755
7771
|
this.Rt(t, 55);
|
|
7756
|
-
for (const e of Object.keys(n)) this.gt(e, t), this.
|
|
7772
|
+
for (const e of Object.keys(n)) this.gt(e, t), this.Et(n[e], t);
|
|
7757
7773
|
}
|
|
7758
|
-
|
|
7774
|
+
bt(e, t) {
|
|
7759
7775
|
var n, r;
|
|
7760
7776
|
const i = e.fields || {};
|
|
7761
7777
|
this.Rt(t, 53);
|
|
@@ -7763,14 +7779,14 @@ class __PRIVATE_FirestoreIndexValueWriter {
|
|
|
7763
7779
|
const s = "value", o = (null === (r = null === (n = i[s].arrayValue) || void 0 === n ? void 0 : n.values) || void 0 === r ? void 0 : r.length) || 0;
|
|
7764
7780
|
this.Rt(t, 15), t.Vt(__PRIVATE_normalizeNumber(o)),
|
|
7765
7781
|
// Vectors then sort by position value
|
|
7766
|
-
this.gt(s, t), this.
|
|
7782
|
+
this.gt(s, t), this.Et(i[s], t);
|
|
7767
7783
|
}
|
|
7768
7784
|
vt(e, t) {
|
|
7769
7785
|
const n = e.values || [];
|
|
7770
7786
|
this.Rt(t, 50);
|
|
7771
|
-
for (const e of n) this.
|
|
7787
|
+
for (const e of n) this.Et(e, t);
|
|
7772
7788
|
}
|
|
7773
|
-
|
|
7789
|
+
St(e, t) {
|
|
7774
7790
|
this.Rt(t, 37);
|
|
7775
7791
|
DocumentKey.fromName(e).path.forEach((e => {
|
|
7776
7792
|
this.Rt(t, 60), this.Ct(e, t);
|
|
@@ -7842,8 +7858,8 @@ function __PRIVATE_unsignedNumLength(e) {
|
|
|
7842
7858
|
Nt(e) {
|
|
7843
7859
|
const t = e[Symbol.iterator]();
|
|
7844
7860
|
let n = t.next();
|
|
7845
|
-
for (;!n.done; ) this.
|
|
7846
|
-
this.
|
|
7861
|
+
for (;!n.done; ) this.Bt(n.value), n = t.next();
|
|
7862
|
+
this.Lt();
|
|
7847
7863
|
}
|
|
7848
7864
|
/** Writes utf8 bytes into this byte sequence, ascending. */ kt(e) {
|
|
7849
7865
|
for (const t of e) {
|
|
@@ -7860,14 +7876,14 @@ function __PRIVATE_unsignedNumLength(e) {
|
|
|
7860
7876
|
/** Writes utf8 bytes into this byte sequence, descending */ qt(e) {
|
|
7861
7877
|
for (const t of e) {
|
|
7862
7878
|
const e = t.charCodeAt(0);
|
|
7863
|
-
if (e < 128) this.
|
|
7864
|
-
this.
|
|
7879
|
+
if (e < 128) this.Bt(e); else if (e < 2048) this.Bt(960 | e >>> 6), this.Bt(128 | 63 & e); else if (t < "\ud800" || "\udbff" < t) this.Bt(480 | e >>> 12),
|
|
7880
|
+
this.Bt(128 | 63 & e >>> 6), this.Bt(128 | 63 & e); else {
|
|
7865
7881
|
const e = t.codePointAt(0);
|
|
7866
|
-
this.
|
|
7867
|
-
this.
|
|
7882
|
+
this.Bt(240 | e >>> 18), this.Bt(128 | 63 & e >>> 12), this.Bt(128 | 63 & e >>> 6),
|
|
7883
|
+
this.Bt(128 | 63 & e);
|
|
7868
7884
|
}
|
|
7869
7885
|
}
|
|
7870
|
-
this.
|
|
7886
|
+
this.Lt();
|
|
7871
7887
|
}
|
|
7872
7888
|
Qt(e) {
|
|
7873
7889
|
// Values are encoded with a single byte length prefix, followed by the
|
|
@@ -7933,14 +7949,14 @@ function __PRIVATE_unsignedNumLength(e) {
|
|
|
7933
7949
|
const t = 255 & e;
|
|
7934
7950
|
0 === t ? (this.Gt(0), this.Gt(255)) : 255 === t ? (this.Gt(255), this.Gt(0)) : this.Gt(t);
|
|
7935
7951
|
}
|
|
7936
|
-
/** Writes a single byte descending to the buffer. */
|
|
7952
|
+
/** Writes a single byte descending to the buffer. */ Bt(e) {
|
|
7937
7953
|
const t = 255 & e;
|
|
7938
7954
|
0 === t ? (this.jt(0), this.jt(255)) : 255 === t ? (this.jt(255), this.jt(0)) : this.jt(e);
|
|
7939
7955
|
}
|
|
7940
7956
|
Ot() {
|
|
7941
7957
|
this.Gt(0), this.Gt(1);
|
|
7942
7958
|
}
|
|
7943
|
-
|
|
7959
|
+
Lt() {
|
|
7944
7960
|
this.jt(0), this.jt(1);
|
|
7945
7961
|
}
|
|
7946
7962
|
Gt(e) {
|
|
@@ -8692,7 +8708,7 @@ class __PRIVATE_IndexedDbIndexManager {
|
|
|
8692
8708
|
n.push(t.value), r && (r = t.inclusive);
|
|
8693
8709
|
}
|
|
8694
8710
|
return new Bound(n, r);
|
|
8695
|
-
}(s, i), c = this.
|
|
8711
|
+
}(s, i), c = this.dn(i, s, a), l = this.dn(i, s, u), h = this.En(i, s, _), P = this.An(i.indexId, o, c, a.inclusive, l, u.inclusive, h);
|
|
8696
8712
|
return PersistencePromise.forEach(P, (i => n.G(i, t.limit).next((t => {
|
|
8697
8713
|
t.forEach((t => {
|
|
8698
8714
|
const n = DocumentKey.fromSegments(t.documentKey);
|
|
@@ -8786,13 +8802,13 @@ class __PRIVATE_IndexedDbIndexManager {
|
|
|
8786
8802
|
const e = t.data.field(r.fieldPath);
|
|
8787
8803
|
if (null == e) return null;
|
|
8788
8804
|
const i = n.Xt(r.kind);
|
|
8789
|
-
__PRIVATE_FirestoreIndexValueWriter.Ft.
|
|
8805
|
+
__PRIVATE_FirestoreIndexValueWriter.Ft.dt(e, i);
|
|
8790
8806
|
}
|
|
8791
8807
|
return n.Ht();
|
|
8792
8808
|
}
|
|
8793
8809
|
/** Encodes a single value to the ascending index format. */ Rn(e) {
|
|
8794
8810
|
const t = new __PRIVATE_IndexByteEncoder;
|
|
8795
|
-
return __PRIVATE_FirestoreIndexValueWriter.Ft.
|
|
8811
|
+
return __PRIVATE_FirestoreIndexValueWriter.Ft.dt(e, t.Xt(0 /* IndexKind.ASCENDING */)),
|
|
8796
8812
|
t.Ht();
|
|
8797
8813
|
}
|
|
8798
8814
|
/**
|
|
@@ -8800,7 +8816,7 @@ class __PRIVATE_IndexedDbIndexManager {
|
|
|
8800
8816
|
* ordering of the field index.
|
|
8801
8817
|
*/ gn(e, t) {
|
|
8802
8818
|
const n = new __PRIVATE_IndexByteEncoder;
|
|
8803
|
-
return __PRIVATE_FirestoreIndexValueWriter.Ft.
|
|
8819
|
+
return __PRIVATE_FirestoreIndexValueWriter.Ft.dt(__PRIVATE_refValue(this.databaseId, t), n.Xt(function __PRIVATE_fieldIndexGetKeyOrder(e) {
|
|
8804
8820
|
const t = __PRIVATE_fieldIndexGetDirectionalSegments(e);
|
|
8805
8821
|
return 0 === t.length ? 0 /* IndexKind.ASCENDING */ : t[t.length - 1].kind;
|
|
8806
8822
|
}(e))), n.Ht();
|
|
@@ -8808,7 +8824,7 @@ class __PRIVATE_IndexedDbIndexManager {
|
|
|
8808
8824
|
/**
|
|
8809
8825
|
* Encodes the given field values according to the specification in `target`.
|
|
8810
8826
|
* For IN queries, a list of possible values is returned.
|
|
8811
|
-
*/
|
|
8827
|
+
*/ En(e, t, n) {
|
|
8812
8828
|
if (null === n) return [];
|
|
8813
8829
|
let r = [];
|
|
8814
8830
|
r.push(new __PRIVATE_IndexByteEncoder);
|
|
@@ -8817,7 +8833,7 @@ class __PRIVATE_IndexedDbIndexManager {
|
|
|
8817
8833
|
const e = n[i++];
|
|
8818
8834
|
for (const n of r) if (this.pn(t, s.fieldPath) && isArray(e)) r = this.yn(r, s, e); else {
|
|
8819
8835
|
const t = n.Xt(s.kind);
|
|
8820
|
-
__PRIVATE_FirestoreIndexValueWriter.Ft.
|
|
8836
|
+
__PRIVATE_FirestoreIndexValueWriter.Ft.dt(e, t);
|
|
8821
8837
|
}
|
|
8822
8838
|
}
|
|
8823
8839
|
return this.wn(r);
|
|
@@ -8825,8 +8841,8 @@ class __PRIVATE_IndexedDbIndexManager {
|
|
|
8825
8841
|
/**
|
|
8826
8842
|
* Encodes the given bounds according to the specification in `target`. For IN
|
|
8827
8843
|
* queries, a list of possible values is returned.
|
|
8828
|
-
*/
|
|
8829
|
-
return this.
|
|
8844
|
+
*/ dn(e, t, n) {
|
|
8845
|
+
return this.En(e, t, n.position);
|
|
8830
8846
|
}
|
|
8831
8847
|
/** Returns the byte representation for the provided encoders. */ wn(e) {
|
|
8832
8848
|
const t = [];
|
|
@@ -8843,7 +8859,7 @@ class __PRIVATE_IndexedDbIndexManager {
|
|
|
8843
8859
|
const r = [ ...e ], i = [];
|
|
8844
8860
|
for (const e of n.arrayValue.values || []) for (const n of r) {
|
|
8845
8861
|
const r = new __PRIVATE_IndexByteEncoder;
|
|
8846
|
-
r.seed(n.Ht()), __PRIVATE_FirestoreIndexValueWriter.Ft.
|
|
8862
|
+
r.seed(n.Ht()), __PRIVATE_FirestoreIndexValueWriter.Ft.dt(e, r.Xt(t.kind)), i.push(r);
|
|
8847
8863
|
}
|
|
8848
8864
|
return i;
|
|
8849
8865
|
}
|
|
@@ -8870,7 +8886,7 @@ class __PRIVATE_IndexedDbIndexManager {
|
|
|
8870
8886
|
}
|
|
8871
8887
|
updateCollectionGroup(e, t, n) {
|
|
8872
8888
|
const r = __PRIVATE_indexConfigurationStore(e), i = __PRIVATE_indexStateStore(e);
|
|
8873
|
-
return this.
|
|
8889
|
+
return this.Sn(e).next((e => r.U("collectionGroupIndex", IDBKeyRange.bound(t, t)).next((t => PersistencePromise.forEach(t, (t => i.put(__PRIVATE_toDbIndexState(t.indexId, this.uid, e, n))))))));
|
|
8874
8890
|
}
|
|
8875
8891
|
updateIndexEntries(e, t) {
|
|
8876
8892
|
// Porting Note: `getFieldIndexes()` on Web does not cache index lookups as
|
|
@@ -8882,7 +8898,7 @@ class __PRIVATE_IndexedDbIndexManager {
|
|
|
8882
8898
|
return PersistencePromise.forEach(t, ((t, r) => {
|
|
8883
8899
|
const i = n.get(t.collectionGroup);
|
|
8884
8900
|
return (i ? PersistencePromise.resolve(i) : this.getFieldIndexes(e, t.collectionGroup)).next((i => (n.set(t.collectionGroup, i),
|
|
8885
|
-
PersistencePromise.forEach(i, (n => this.
|
|
8901
|
+
PersistencePromise.forEach(i, (n => this.bn(e, t, n).next((t => {
|
|
8886
8902
|
const i = this.Dn(r, n);
|
|
8887
8903
|
return t.isEqual(i) ? PersistencePromise.resolve() : this.vn(e, r, n, t, i);
|
|
8888
8904
|
})))))));
|
|
@@ -8901,7 +8917,7 @@ class __PRIVATE_IndexedDbIndexManager {
|
|
|
8901
8917
|
Fn(e, t, n, r) {
|
|
8902
8918
|
return __PRIVATE_indexEntriesStore(e).delete([ r.indexId, this.uid, r.arrayValue, r.directionalValue, this.gn(n, t.key), t.key.path.toArray() ]);
|
|
8903
8919
|
}
|
|
8904
|
-
|
|
8920
|
+
bn(e, t, n) {
|
|
8905
8921
|
const r = __PRIVATE_indexEntriesStore(e);
|
|
8906
8922
|
let i = new SortedSet(__PRIVATE_indexEntryComparator);
|
|
8907
8923
|
return r.J({
|
|
@@ -8957,7 +8973,7 @@ class __PRIVATE_IndexedDbIndexManager {
|
|
|
8957
8973
|
s.push(this.Fn(e, t, n, r));
|
|
8958
8974
|
})), PersistencePromise.waitFor(s);
|
|
8959
8975
|
}
|
|
8960
|
-
|
|
8976
|
+
Sn(e) {
|
|
8961
8977
|
let t = 1;
|
|
8962
8978
|
return __PRIVATE_indexStateStore(e).J({
|
|
8963
8979
|
index: "sequenceNumberIndex",
|
|
@@ -9356,7 +9372,7 @@ class __PRIVATE_IndexedDbMutationQueue {
|
|
|
9356
9372
|
}
|
|
9357
9373
|
removeMutationBatch(e, t) {
|
|
9358
9374
|
return removeMutationBatch(e._e, this.userId, t).next((n => (e.addOnCommittedListener((() => {
|
|
9359
|
-
this.
|
|
9375
|
+
this.Bn(t.batchId);
|
|
9360
9376
|
})), PersistencePromise.forEach(n, (t => this.referenceDelegate.markPotentiallyOrphaned(e, t))))));
|
|
9361
9377
|
}
|
|
9362
9378
|
/**
|
|
@@ -9368,7 +9384,7 @@ class __PRIVATE_IndexedDbMutationQueue {
|
|
|
9368
9384
|
* rejected batch is removed from the mutation queue.
|
|
9369
9385
|
*/
|
|
9370
9386
|
// PORTING NOTE: Multi-tab only
|
|
9371
|
-
|
|
9387
|
+
Bn(e) {
|
|
9372
9388
|
delete this.xn[e];
|
|
9373
9389
|
}
|
|
9374
9390
|
performConsistencyCheck(e) {
|
|
@@ -9401,7 +9417,7 @@ class __PRIVATE_IndexedDbMutationQueue {
|
|
|
9401
9417
|
}
|
|
9402
9418
|
// PORTING NOTE: Multi-tab only (state is held in memory in other clients).
|
|
9403
9419
|
/** Returns the mutation queue's metadata from IndexedDb. */
|
|
9404
|
-
|
|
9420
|
+
Ln(e) {
|
|
9405
9421
|
return __PRIVATE_mutationQueuesStore(e).get(this.userId).next((e => e || {
|
|
9406
9422
|
userId: this.userId,
|
|
9407
9423
|
lastAcknowledgedBatchId: -1,
|
|
@@ -10742,7 +10758,7 @@ class OverlayedDocument {
|
|
|
10742
10758
|
constructor() {
|
|
10743
10759
|
// A map sorted by DocumentKey, whose value is a pair of the largest batch id
|
|
10744
10760
|
// for the overlay and the overlay itself.
|
|
10745
|
-
this.overlays = new SortedMap(DocumentKey.comparator), this.
|
|
10761
|
+
this.overlays = new SortedMap(DocumentKey.comparator), this.dr = new Map;
|
|
10746
10762
|
}
|
|
10747
10763
|
getOverlay(e, t) {
|
|
10748
10764
|
return PersistencePromise.resolve(this.overlays.get(t));
|
|
@@ -10759,9 +10775,9 @@ class OverlayedDocument {
|
|
|
10759
10775
|
})), PersistencePromise.resolve();
|
|
10760
10776
|
}
|
|
10761
10777
|
removeOverlaysForBatchId(e, t, n) {
|
|
10762
|
-
const r = this.
|
|
10778
|
+
const r = this.dr.get(n);
|
|
10763
10779
|
return void 0 !== r && (r.forEach((e => this.overlays = this.overlays.remove(e))),
|
|
10764
|
-
this.
|
|
10780
|
+
this.dr.delete(n)), PersistencePromise.resolve();
|
|
10765
10781
|
}
|
|
10766
10782
|
getOverlaysForCollection(e, t, n) {
|
|
10767
10783
|
const r = __PRIVATE_newOverlayMap(), i = t.length + 1, s = new DocumentKey(t.child("")), o = this.overlays.getIteratorFrom(s);
|
|
@@ -10794,13 +10810,13 @@ class OverlayedDocument {
|
|
|
10794
10810
|
// Remove the association of the overlay to its batch id.
|
|
10795
10811
|
const r = this.overlays.get(n.key);
|
|
10796
10812
|
if (null !== r) {
|
|
10797
|
-
const e = this.
|
|
10798
|
-
this.
|
|
10813
|
+
const e = this.dr.get(r.largestBatchId).delete(n.key);
|
|
10814
|
+
this.dr.set(r.largestBatchId, e);
|
|
10799
10815
|
}
|
|
10800
10816
|
this.overlays = this.overlays.insert(n.key, new Overlay(t, n));
|
|
10801
10817
|
// Create the association of this overlay to the given largestBatchId.
|
|
10802
|
-
let i = this.
|
|
10803
|
-
void 0 === i && (i = __PRIVATE_documentKeySet(), this.
|
|
10818
|
+
let i = this.dr.get(t);
|
|
10819
|
+
void 0 === i && (i = __PRIVATE_documentKeySet(), this.dr.set(t, i)), this.dr.set(t, i.add(n.key));
|
|
10804
10820
|
}
|
|
10805
10821
|
}
|
|
10806
10822
|
|
|
@@ -10864,16 +10880,16 @@ class OverlayedDocument {
|
|
|
10864
10880
|
*/ class __PRIVATE_ReferenceSet {
|
|
10865
10881
|
constructor() {
|
|
10866
10882
|
// A set of outstanding references to a document sorted by key.
|
|
10867
|
-
this.
|
|
10883
|
+
this.Er = new SortedSet(__PRIVATE_DocReference.Ar),
|
|
10868
10884
|
// A set of outstanding references to a document sorted by target id.
|
|
10869
10885
|
this.Rr = new SortedSet(__PRIVATE_DocReference.Vr);
|
|
10870
10886
|
}
|
|
10871
10887
|
/** Returns true if the reference set contains no references. */ isEmpty() {
|
|
10872
|
-
return this.
|
|
10888
|
+
return this.Er.isEmpty();
|
|
10873
10889
|
}
|
|
10874
10890
|
/** Adds a reference to the given document key for the given ID. */ addReference(e, t) {
|
|
10875
10891
|
const n = new __PRIVATE_DocReference(e, t);
|
|
10876
|
-
this.
|
|
10892
|
+
this.Er = this.Er.add(n), this.Rr = this.Rr.add(n);
|
|
10877
10893
|
}
|
|
10878
10894
|
/** Add references to the given document keys for the given ID. */ mr(e, t) {
|
|
10879
10895
|
e.forEach((e => this.addReference(e, t)));
|
|
@@ -10897,12 +10913,12 @@ class OverlayedDocument {
|
|
|
10897
10913
|
})), i;
|
|
10898
10914
|
}
|
|
10899
10915
|
wr() {
|
|
10900
|
-
this.
|
|
10916
|
+
this.Er.forEach((e => this.gr(e)));
|
|
10901
10917
|
}
|
|
10902
10918
|
gr(e) {
|
|
10903
|
-
this.
|
|
10919
|
+
this.Er = this.Er.delete(e), this.Rr = this.Rr.delete(e);
|
|
10904
10920
|
}
|
|
10905
|
-
|
|
10921
|
+
Sr(e) {
|
|
10906
10922
|
const t = new DocumentKey(new ResourcePath([])), n = new __PRIVATE_DocReference(t, e), r = new __PRIVATE_DocReference(t, e + 1);
|
|
10907
10923
|
let i = __PRIVATE_documentKeySet();
|
|
10908
10924
|
return this.Rr.forEachInRange([ n, r ], (e => {
|
|
@@ -10910,20 +10926,20 @@ class OverlayedDocument {
|
|
|
10910
10926
|
})), i;
|
|
10911
10927
|
}
|
|
10912
10928
|
containsKey(e) {
|
|
10913
|
-
const t = new __PRIVATE_DocReference(e, 0), n = this.
|
|
10929
|
+
const t = new __PRIVATE_DocReference(e, 0), n = this.Er.firstAfterOrEqual(t);
|
|
10914
10930
|
return null !== n && e.isEqual(n.key);
|
|
10915
10931
|
}
|
|
10916
10932
|
}
|
|
10917
10933
|
|
|
10918
10934
|
class __PRIVATE_DocReference {
|
|
10919
10935
|
constructor(e, t) {
|
|
10920
|
-
this.key = e, this.
|
|
10936
|
+
this.key = e, this.br = t;
|
|
10921
10937
|
}
|
|
10922
10938
|
/** Compare by key then by ID */ static Ar(e, t) {
|
|
10923
|
-
return DocumentKey.comparator(e.key, t.key) || __PRIVATE_primitiveComparator(e.
|
|
10939
|
+
return DocumentKey.comparator(e.key, t.key) || __PRIVATE_primitiveComparator(e.br, t.br);
|
|
10924
10940
|
}
|
|
10925
10941
|
/** Compare by ID then by key */ static Vr(e, t) {
|
|
10926
|
-
return __PRIVATE_primitiveComparator(e.
|
|
10942
|
+
return __PRIVATE_primitiveComparator(e.br, t.br) || DocumentKey.comparator(e.key, t.key);
|
|
10927
10943
|
}
|
|
10928
10944
|
}
|
|
10929
10945
|
|
|
@@ -10986,7 +11002,7 @@ class __PRIVATE_DocReference {
|
|
|
10986
11002
|
getAllMutationBatchesAffectingDocumentKey(e, t) {
|
|
10987
11003
|
const n = new __PRIVATE_DocReference(t, 0), r = new __PRIVATE_DocReference(t, Number.POSITIVE_INFINITY), i = [];
|
|
10988
11004
|
return this.vr.forEachInRange([ n, r ], (e => {
|
|
10989
|
-
const t = this.Cr(e.
|
|
11005
|
+
const t = this.Cr(e.br);
|
|
10990
11006
|
i.push(t);
|
|
10991
11007
|
})), PersistencePromise.resolve(i);
|
|
10992
11008
|
}
|
|
@@ -10995,7 +11011,7 @@ class __PRIVATE_DocReference {
|
|
|
10995
11011
|
return t.forEach((e => {
|
|
10996
11012
|
const t = new __PRIVATE_DocReference(e, 0), r = new __PRIVATE_DocReference(e, Number.POSITIVE_INFINITY);
|
|
10997
11013
|
this.vr.forEachInRange([ t, r ], (e => {
|
|
10998
|
-
n = n.add(e.
|
|
11014
|
+
n = n.add(e.br);
|
|
10999
11015
|
}));
|
|
11000
11016
|
})), PersistencePromise.resolve(this.Mr(n));
|
|
11001
11017
|
}
|
|
@@ -11021,7 +11037,7 @@ class __PRIVATE_DocReference {
|
|
|
11021
11037
|
// the document /rooms/abc/messages/xyx.
|
|
11022
11038
|
// TODO(mcg): we'll need a different scanner when we implement
|
|
11023
11039
|
// ancestor queries.
|
|
11024
|
-
t.length === r && (o = o.add(e.
|
|
11040
|
+
t.length === r && (o = o.add(e.br)), !0);
|
|
11025
11041
|
}), s), PersistencePromise.resolve(this.Mr(o));
|
|
11026
11042
|
}
|
|
11027
11043
|
Mr(e) {
|
|
@@ -11043,7 +11059,7 @@ class __PRIVATE_DocReference {
|
|
|
11043
11059
|
this.vr = n;
|
|
11044
11060
|
}));
|
|
11045
11061
|
}
|
|
11046
|
-
|
|
11062
|
+
Bn(e) {
|
|
11047
11063
|
// No-op since the memory mutation queue does not maintain a separate cache.
|
|
11048
11064
|
}
|
|
11049
11065
|
containsKey(e, t) {
|
|
@@ -11107,6 +11123,9 @@ class __PRIVATE_DocReference {
|
|
|
11107
11123
|
* See the License for the specific language governing permissions and
|
|
11108
11124
|
* limitations under the License.
|
|
11109
11125
|
*/
|
|
11126
|
+
/**
|
|
11127
|
+
* The smallest value representable by a 64-bit signed integer (long).
|
|
11128
|
+
*/
|
|
11110
11129
|
/**
|
|
11111
11130
|
* The memory-only RemoteDocumentCache for IndexedDb. To construct, invoke
|
|
11112
11131
|
* `newMemoryRemoteDocumentCache()`.
|
|
@@ -11165,8 +11184,11 @@ class __PRIVATE_MemoryRemoteDocumentCacheImpl {
|
|
|
11165
11184
|
let i = __PRIVATE_mutableDocumentMap();
|
|
11166
11185
|
// Documents are ordered by key, so we can use a prefix scan to narrow down
|
|
11167
11186
|
// the documents we need to match the query against.
|
|
11168
|
-
const s = t.path, o = new DocumentKey(s.child("")), _ = this.docs.getIteratorFrom(o);
|
|
11169
|
-
|
|
11187
|
+
const s = t.path, o = new DocumentKey(s.child("__id-9223372036854775808__")), _ = this.docs.getIteratorFrom(o);
|
|
11188
|
+
// Document keys are ordered first by numeric value ("__id<Long>__"),
|
|
11189
|
+
// then lexicographically by string value. Start the iterator at the minimum
|
|
11190
|
+
// possible Document key value.
|
|
11191
|
+
for (;_.hasNext(); ) {
|
|
11170
11192
|
const {key: e, value: {document: o}} = _.getNext();
|
|
11171
11193
|
if (!s.isPrefixOf(e.path)) break;
|
|
11172
11194
|
e.path.length > s.length + 1 || (__PRIVATE_indexOffsetComparator(__PRIVATE_newIndexOffsetFromDocument(o), n) <= 0 || (r.has(o.key) || __PRIVATE_queryMatches(t, o)) && (i = i.insert(o.key, o.mutableCopy())));
|
|
@@ -11178,7 +11200,7 @@ class __PRIVATE_MemoryRemoteDocumentCacheImpl {
|
|
|
11178
11200
|
// is enabled.
|
|
11179
11201
|
fail();
|
|
11180
11202
|
}
|
|
11181
|
-
|
|
11203
|
+
Br(e, t) {
|
|
11182
11204
|
return PersistencePromise.forEach(this.docs, (e => t(e)));
|
|
11183
11205
|
}
|
|
11184
11206
|
newChangeBuffer(e) {
|
|
@@ -11240,7 +11262,7 @@ class __PRIVATE_MemoryRemoteDocumentChangeBuffer extends RemoteDocumentChangeBuf
|
|
|
11240
11262
|
/**
|
|
11241
11263
|
* Maps a target to the data about that target
|
|
11242
11264
|
*/
|
|
11243
|
-
this.
|
|
11265
|
+
this.Lr = new ObjectMap((e => __PRIVATE_canonifyTarget(e)), __PRIVATE_targetEquals),
|
|
11244
11266
|
/** The last received snapshot version. */
|
|
11245
11267
|
this.lastRemoteSnapshotVersion = SnapshotVersion.min(),
|
|
11246
11268
|
/** The highest numbered target ID encountered. */
|
|
@@ -11254,7 +11276,7 @@ class __PRIVATE_MemoryRemoteDocumentChangeBuffer extends RemoteDocumentChangeBuf
|
|
|
11254
11276
|
this.qr = new __PRIVATE_ReferenceSet, this.targetCount = 0, this.Qr = __PRIVATE_TargetIdGenerator.qn();
|
|
11255
11277
|
}
|
|
11256
11278
|
forEachTarget(e, t) {
|
|
11257
|
-
return this.
|
|
11279
|
+
return this.Lr.forEach(((e, n) => t(n))), PersistencePromise.resolve();
|
|
11258
11280
|
}
|
|
11259
11281
|
getLastRemoteSnapshotVersion(e) {
|
|
11260
11282
|
return PersistencePromise.resolve(this.lastRemoteSnapshotVersion);
|
|
@@ -11270,7 +11292,7 @@ class __PRIVATE_MemoryRemoteDocumentChangeBuffer extends RemoteDocumentChangeBuf
|
|
|
11270
11292
|
PersistencePromise.resolve();
|
|
11271
11293
|
}
|
|
11272
11294
|
Un(e) {
|
|
11273
|
-
this.
|
|
11295
|
+
this.Lr.set(e.target, e);
|
|
11274
11296
|
const t = e.targetId;
|
|
11275
11297
|
t > this.highestTargetId && (this.Qr = new __PRIVATE_TargetIdGenerator(t), this.highestTargetId = t),
|
|
11276
11298
|
e.sequenceNumber > this.kr && (this.kr = e.sequenceNumber);
|
|
@@ -11282,14 +11304,14 @@ class __PRIVATE_MemoryRemoteDocumentChangeBuffer extends RemoteDocumentChangeBuf
|
|
|
11282
11304
|
return this.Un(t), PersistencePromise.resolve();
|
|
11283
11305
|
}
|
|
11284
11306
|
removeTargetData(e, t) {
|
|
11285
|
-
return this.
|
|
11307
|
+
return this.Lr.delete(t.target), this.qr.yr(t.targetId), this.targetCount -= 1,
|
|
11286
11308
|
PersistencePromise.resolve();
|
|
11287
11309
|
}
|
|
11288
11310
|
removeTargets(e, t, n) {
|
|
11289
11311
|
let r = 0;
|
|
11290
11312
|
const i = [];
|
|
11291
|
-
return this.
|
|
11292
|
-
o.sequenceNumber <= t && null === n.get(o.targetId) && (this.
|
|
11313
|
+
return this.Lr.forEach(((s, o) => {
|
|
11314
|
+
o.sequenceNumber <= t && null === n.get(o.targetId) && (this.Lr.delete(s), i.push(this.removeMatchingKeysForTargetId(e, o.targetId)),
|
|
11293
11315
|
r++);
|
|
11294
11316
|
})), PersistencePromise.waitFor(i).next((() => r));
|
|
11295
11317
|
}
|
|
@@ -11297,7 +11319,7 @@ class __PRIVATE_MemoryRemoteDocumentChangeBuffer extends RemoteDocumentChangeBuf
|
|
|
11297
11319
|
return PersistencePromise.resolve(this.targetCount);
|
|
11298
11320
|
}
|
|
11299
11321
|
getTargetData(e, t) {
|
|
11300
|
-
const n = this.
|
|
11322
|
+
const n = this.Lr.get(t) || null;
|
|
11301
11323
|
return PersistencePromise.resolve(n);
|
|
11302
11324
|
}
|
|
11303
11325
|
addMatchingKeys(e, t, n) {
|
|
@@ -11314,7 +11336,7 @@ class __PRIVATE_MemoryRemoteDocumentChangeBuffer extends RemoteDocumentChangeBuf
|
|
|
11314
11336
|
return this.qr.yr(t), PersistencePromise.resolve();
|
|
11315
11337
|
}
|
|
11316
11338
|
getMatchingKeysForTargetId(e, t) {
|
|
11317
|
-
const n = this.qr.
|
|
11339
|
+
const n = this.qr.Sr(t);
|
|
11318
11340
|
return PersistencePromise.resolve(n);
|
|
11319
11341
|
}
|
|
11320
11342
|
containsKey(e, t) {
|
|
@@ -11515,7 +11537,7 @@ class __PRIVATE_MemoryLruDelegate {
|
|
|
11515
11537
|
removeOrphanedDocuments(e, t) {
|
|
11516
11538
|
let n = 0;
|
|
11517
11539
|
const r = this.persistence.getRemoteDocumentCache(), i = r.newChangeBuffer();
|
|
11518
|
-
return r.
|
|
11540
|
+
return r.Br(e, (r => this.ir(e, r, t).next((e => {
|
|
11519
11541
|
e || (n++, i.removeEntry(r, SnapshotVersion.min()));
|
|
11520
11542
|
})))).next((() => i.apply(e))).next((() => n));
|
|
11521
11543
|
}
|
|
@@ -11681,7 +11703,7 @@ class __PRIVATE_MemoryLruDelegate {
|
|
|
11681
11703
|
const t = e.createObjectStore("remoteDocumentsV14", {
|
|
11682
11704
|
keyPath: O
|
|
11683
11705
|
});
|
|
11684
|
-
t.createIndex("documentKeyIndex", N), t.createIndex("collectionGroupIndex",
|
|
11706
|
+
t.createIndex("documentKeyIndex", N), t.createIndex("collectionGroupIndex", B);
|
|
11685
11707
|
}(e))).next((() => this.ui(e, i))).next((() => e.deleteObjectStore("remoteDocuments")))),
|
|
11686
11708
|
n < 14 && r >= 14 && (s = s.next((() => this.ci(e, i)))), n < 15 && r >= 15 && (s = s.next((() => function __PRIVATE_createFieldIndex(e) {
|
|
11687
11709
|
e.createObjectStore("indexConfiguration", {
|
|
@@ -11850,7 +11872,7 @@ function __PRIVATE_createQueryCache(e) {
|
|
|
11850
11872
|
// NOTE: This is unique only because the TargetId is the suffix.
|
|
11851
11873
|
e.createObjectStore("targets", {
|
|
11852
11874
|
keyPath: "targetId"
|
|
11853
|
-
}).createIndex("queryTargetsIndex",
|
|
11875
|
+
}).createIndex("queryTargetsIndex", L, {
|
|
11854
11876
|
unique: !0
|
|
11855
11877
|
}), e.createObjectStore("targetGlobal");
|
|
11856
11878
|
}
|
|
@@ -11925,9 +11947,9 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
11925
11947
|
/** Our window.unload handler, if registered. */
|
|
11926
11948
|
this.Ii = null, this.inForeground = !1,
|
|
11927
11949
|
/** Our 'visibilitychange' listener if registered. */
|
|
11928
|
-
this.Ei = null,
|
|
11929
|
-
/** The client metadata refresh task. */
|
|
11930
11950
|
this.di = null,
|
|
11951
|
+
/** The client metadata refresh task. */
|
|
11952
|
+
this.Ei = null,
|
|
11931
11953
|
/** The last time we garbage collected the client metadata object store. */
|
|
11932
11954
|
this.Ai = Number.NEGATIVE_INFINITY,
|
|
11933
11955
|
/** A listener to notify on primary state changes. */
|
|
@@ -11965,7 +11987,7 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
11965
11987
|
* with the current primary state.
|
|
11966
11988
|
*
|
|
11967
11989
|
* PORTING NOTE: This is only used for Web multi-tab.
|
|
11968
|
-
*/
|
|
11990
|
+
*/ Si(e) {
|
|
11969
11991
|
return this.Ri = async t => {
|
|
11970
11992
|
if (this.started) return e(t);
|
|
11971
11993
|
}, e(this.isPrimary);
|
|
@@ -11976,7 +11998,7 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
11976
11998
|
*
|
|
11977
11999
|
* PORTING NOTE: This is only used for Web multi-tab.
|
|
11978
12000
|
*/ setDatabaseDeletedListener(e) {
|
|
11979
|
-
this.mi.
|
|
12001
|
+
this.mi.B((async t => {
|
|
11980
12002
|
// Check if an attempt is made to delete IndexedDB.
|
|
11981
12003
|
null === t.newVersion && await e();
|
|
11982
12004
|
}));
|
|
@@ -12006,7 +12028,7 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12006
12028
|
networkEnabled: this.networkEnabled,
|
|
12007
12029
|
inForeground: this.inForeground
|
|
12008
12030
|
}).next((() => {
|
|
12009
|
-
if (this.isPrimary) return this.
|
|
12031
|
+
if (this.isPrimary) return this.bi(e).next((e => {
|
|
12010
12032
|
e || (this.isPrimary = !1, this.li.enqueueRetryable((() => this.Ri(!1))));
|
|
12011
12033
|
}));
|
|
12012
12034
|
})).next((() => this.Di(e))).next((t => this.isPrimary && !t ? this.vi(e).next((() => !1)) : !!t && this.Ci(e).next((() => !0)))))).catch((e => {
|
|
@@ -12022,7 +12044,7 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12022
12044
|
this.isPrimary !== e && this.li.enqueueRetryable((() => this.Ri(e))), this.isPrimary = e;
|
|
12023
12045
|
}));
|
|
12024
12046
|
}
|
|
12025
|
-
|
|
12047
|
+
bi(e) {
|
|
12026
12048
|
return __PRIVATE_primaryClientStore(e).get("owner").next((e => PersistencePromise.resolve(this.Fi(e))));
|
|
12027
12049
|
}
|
|
12028
12050
|
Mi(e) {
|
|
@@ -12048,14 +12070,14 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12048
12070
|
// Ideally we'd delete the IndexedDb and LocalStorage zombie entries for
|
|
12049
12071
|
// the client atomically, but we can't. So we opt to delete the IndexedDb
|
|
12050
12072
|
// entries first to avoid potentially reviving a zombied client.
|
|
12051
|
-
if (this.fi) for (const t of e) this.fi.removeItem(this.
|
|
12073
|
+
if (this.fi) for (const t of e) this.fi.removeItem(this.Bi(t.clientId));
|
|
12052
12074
|
}
|
|
12053
12075
|
}
|
|
12054
12076
|
/**
|
|
12055
12077
|
* Schedules a recurring timer to update the client metadata and to either
|
|
12056
12078
|
* extend or acquire the primary lease if the client is eligible.
|
|
12057
12079
|
*/ wi() {
|
|
12058
|
-
this.
|
|
12080
|
+
this.Ei = this.li.enqueueAfterDelay("client_metadata_refresh" /* TimerId.ClientMetadataRefresh */ , 4e3, (() => this.gi().then((() => this.xi())).then((() => this.wi()))));
|
|
12059
12081
|
}
|
|
12060
12082
|
/** Checks whether `client` is the local client. */ Fi(e) {
|
|
12061
12083
|
return !!e && e.ownerId === this.clientId;
|
|
@@ -12078,7 +12100,7 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12078
12100
|
// - every clients network is disabled and no other client's tab is in
|
|
12079
12101
|
// the foreground.
|
|
12080
12102
|
// - the `forceOwningTab` setting was passed in.
|
|
12081
|
-
if (null !== t && this.Oi(t.leaseTimestampMs, 5e3) && !this.
|
|
12103
|
+
if (null !== t && this.Oi(t.leaseTimestampMs, 5e3) && !this.Li(t.ownerId)) {
|
|
12082
12104
|
if (this.Fi(t) && this.networkEnabled) return !0;
|
|
12083
12105
|
if (!this.Fi(t)) {
|
|
12084
12106
|
if (!t.allowTabSynchronization)
|
|
@@ -12110,7 +12132,7 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12110
12132
|
async shutdown() {
|
|
12111
12133
|
// The shutdown() operations are idempotent and can be called even when
|
|
12112
12134
|
// start() aborted (e.g. because it couldn't acquire the persistence lease).
|
|
12113
|
-
this.Ur = !1, this.ki(), this.
|
|
12135
|
+
this.Ur = !1, this.ki(), this.Ei && (this.Ei.cancel(), this.Ei = null), this.qi(),
|
|
12114
12136
|
this.Qi(),
|
|
12115
12137
|
// Use `SimpleDb.runTransaction` directly to avoid failing if another tab
|
|
12116
12138
|
// has obtained the primary lease.
|
|
@@ -12126,7 +12148,7 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12126
12148
|
* Returns clients that are not zombied and have an updateTime within the
|
|
12127
12149
|
* provided threshold.
|
|
12128
12150
|
*/ Ni(e, t) {
|
|
12129
|
-
return e.filter((e => this.Oi(e.updateTimeMs, t) && !this.
|
|
12151
|
+
return e.filter((e => this.Oi(e.updateTimeMs, t) && !this.Li(e.clientId)));
|
|
12130
12152
|
}
|
|
12131
12153
|
/**
|
|
12132
12154
|
* Returns the IDs of the clients that are currently active. If multi-tab
|
|
@@ -12172,7 +12194,7 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12172
12194
|
// Do all transactions as readwrite against all object stores, since we
|
|
12173
12195
|
// are the only reader/writer.
|
|
12174
12196
|
return this.mi.runTransaction(e, r, i, (r => (s = new __PRIVATE_IndexedDbTransaction(r, this.$r ? this.$r.next() : __PRIVATE_ListenSequence.oe),
|
|
12175
|
-
"readwrite-primary" === t ? this.
|
|
12197
|
+
"readwrite-primary" === t ? this.bi(s).next((e => !!e || this.Di(s))).next((t => {
|
|
12176
12198
|
if (!t) throw __PRIVATE_logError(`Failed to obtain primary lease for action '${e}'.`),
|
|
12177
12199
|
this.isPrimary = !1, this.li.enqueueRetryable((() => this.Ri(!1))), new FirestoreError(D.FAILED_PRECONDITION, C);
|
|
12178
12200
|
return n(s);
|
|
@@ -12187,7 +12209,7 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12187
12209
|
// be turned off.
|
|
12188
12210
|
Ui(e) {
|
|
12189
12211
|
return __PRIVATE_primaryClientStore(e).get("owner").next((e => {
|
|
12190
|
-
if (null !== e && this.Oi(e.leaseTimestampMs, 5e3) && !this.
|
|
12212
|
+
if (null !== e && this.Oi(e.leaseTimestampMs, 5e3) && !this.Li(e.ownerId) && !this.Fi(e) && !(this.Pi || this.allowTabSynchronization && e.allowTabSynchronization)) throw new FirestoreError(D.FAILED_PRECONDITION, Ve);
|
|
12191
12213
|
}));
|
|
12192
12214
|
}
|
|
12193
12215
|
/**
|
|
@@ -12215,13 +12237,13 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12215
12237
|
!1));
|
|
12216
12238
|
}
|
|
12217
12239
|
pi() {
|
|
12218
|
-
null !== this.document && "function" == typeof this.document.addEventListener && (this.
|
|
12240
|
+
null !== this.document && "function" == typeof this.document.addEventListener && (this.di = () => {
|
|
12219
12241
|
this.li.enqueueAndForget((() => (this.inForeground = "visible" === this.document.visibilityState,
|
|
12220
12242
|
this.gi())));
|
|
12221
|
-
}, this.document.addEventListener("visibilitychange", this.
|
|
12243
|
+
}, this.document.addEventListener("visibilitychange", this.di), this.inForeground = "visible" === this.document.visibilityState);
|
|
12222
12244
|
}
|
|
12223
12245
|
qi() {
|
|
12224
|
-
this.
|
|
12246
|
+
this.di && (this.document.removeEventListener("visibilitychange", this.di), this.di = null);
|
|
12225
12247
|
}
|
|
12226
12248
|
/**
|
|
12227
12249
|
* Attaches a window.unload handler that will synchronously write our
|
|
@@ -12255,10 +12277,10 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12255
12277
|
* Returns whether a client is "zombied" based on its LocalStorage entry.
|
|
12256
12278
|
* Clients become zombied when their tab closes without running all of the
|
|
12257
12279
|
* cleanup logic in `shutdown()`.
|
|
12258
|
-
*/
|
|
12280
|
+
*/ Li(e) {
|
|
12259
12281
|
var t;
|
|
12260
12282
|
try {
|
|
12261
|
-
const n = null !== (null === (t = this.fi) || void 0 === t ? void 0 : t.getItem(this.
|
|
12283
|
+
const n = null !== (null === (t = this.fi) || void 0 === t ? void 0 : t.getItem(this.Bi(e)));
|
|
12262
12284
|
return __PRIVATE_logDebug("IndexedDbPersistence", `Client '${e}' ${n ? "is" : "is not"} zombied in LocalStorage`),
|
|
12263
12285
|
n;
|
|
12264
12286
|
} catch (e) {
|
|
@@ -12272,7 +12294,7 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12272
12294
|
* clients are ignored during primary tab selection.
|
|
12273
12295
|
*/ ki() {
|
|
12274
12296
|
if (this.fi) try {
|
|
12275
|
-
this.fi.setItem(this.
|
|
12297
|
+
this.fi.setItem(this.Bi(this.clientId), String(Date.now()));
|
|
12276
12298
|
} catch (e) {
|
|
12277
12299
|
// Gracefully handle if LocalStorage isn't available / working.
|
|
12278
12300
|
__PRIVATE_logError("Failed to set zombie client id.", e);
|
|
@@ -12280,12 +12302,12 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12280
12302
|
}
|
|
12281
12303
|
/** Removes the zombied client entry if it exists. */ Ki() {
|
|
12282
12304
|
if (this.fi) try {
|
|
12283
|
-
this.fi.removeItem(this.
|
|
12305
|
+
this.fi.removeItem(this.Bi(this.clientId));
|
|
12284
12306
|
} catch (e) {
|
|
12285
12307
|
// Ignore
|
|
12286
12308
|
}
|
|
12287
12309
|
}
|
|
12288
|
-
|
|
12310
|
+
Bi(e) {
|
|
12289
12311
|
return `firestore_zombie_${this.persistenceKey}_${e}`;
|
|
12290
12312
|
}
|
|
12291
12313
|
}
|
|
@@ -12825,7 +12847,7 @@ function __PRIVATE_localStoreGetLastRemoteSnapshotVersion(e) {
|
|
|
12825
12847
|
// Each loop iteration only affects its "own" doc, so it's safe to get all
|
|
12826
12848
|
// the remote documents in advance in a single call.
|
|
12827
12849
|
o.push(__PRIVATE_populateDocumentChangeBuffer(e, s, t.documentUpdates).next((e => {
|
|
12828
|
-
_ = e.Is, a = e.
|
|
12850
|
+
_ = e.Is, a = e.ds;
|
|
12829
12851
|
}))), !r.isEqual(SnapshotVersion.min())) {
|
|
12830
12852
|
const t = n.Gr.getLastRemoteSnapshotVersion(e).next((t => n.Gr.setTargetsMetadata(e, e.currentSequenceNumber, r)));
|
|
12831
12853
|
o.push(t);
|
|
@@ -12863,7 +12885,7 @@ function __PRIVATE_localStoreGetLastRemoteSnapshotVersion(e) {
|
|
|
12863
12885
|
r = r.insert(n, s)) : __PRIVATE_logDebug("LocalStore", "Ignoring outdated watch update for ", n, ". Current version:", o.version, " Watch version:", s.version);
|
|
12864
12886
|
})), {
|
|
12865
12887
|
Is: r,
|
|
12866
|
-
|
|
12888
|
+
ds: i
|
|
12867
12889
|
};
|
|
12868
12890
|
}));
|
|
12869
12891
|
}
|
|
@@ -12962,7 +12984,7 @@ async function __PRIVATE_localStoreReleaseTarget(e, t, n) {
|
|
|
12962
12984
|
})).next((() => r._s.getDocumentsMatchingQuery(e, t, n ? i : SnapshotVersion.min(), n ? s : __PRIVATE_documentKeySet()))).next((e => (__PRIVATE_setMaxReadTime(r, __PRIVATE_queryCollectionGroup(t), e),
|
|
12963
12985
|
{
|
|
12964
12986
|
documents: e,
|
|
12965
|
-
|
|
12987
|
+
Es: s
|
|
12966
12988
|
})))));
|
|
12967
12989
|
}
|
|
12968
12990
|
|
|
@@ -13031,7 +13053,7 @@ async function __PRIVATE_localStoreApplyBundledDocuments(e, t, n, r) {
|
|
|
13031
13053
|
// Allocates a target to hold all document keys from the bundle, such that
|
|
13032
13054
|
// they will not get garbage collected right away.
|
|
13033
13055
|
return i.persistence.runTransaction("Apply bundle documents", "readwrite", (e => __PRIVATE_populateDocumentChangeBuffer(e, _, o).next((t => (_.apply(e),
|
|
13034
|
-
t))).next((t => i.Gr.removeMatchingKeysForTargetId(e, a.targetId).next((() => i.Gr.addMatchingKeys(e, s, a.targetId))).next((() => i.localDocuments.getLocalViewOfDocuments(e, t.Is, t.
|
|
13056
|
+
t))).next((t => i.Gr.removeMatchingKeysForTargetId(e, a.targetId).next((() => i.Gr.addMatchingKeys(e, s, a.targetId))).next((() => i.localDocuments.getLocalViewOfDocuments(e, t.Is, t.ds))).next((() => t.Is))))));
|
|
13035
13057
|
}
|
|
13036
13058
|
|
|
13037
13059
|
/**
|
|
@@ -13227,7 +13249,7 @@ class __PRIVATE_LocalClientState {
|
|
|
13227
13249
|
*/ class __PRIVATE_WebStorageSharedClientState {
|
|
13228
13250
|
constructor(e, t, n, r, i) {
|
|
13229
13251
|
this.window = e, this.li = t, this.persistenceKey = n, this.ws = r, this.syncEngine = null,
|
|
13230
|
-
this.onlineStateHandler = null, this.sequenceNumberHandler = null, this.
|
|
13252
|
+
this.onlineStateHandler = null, this.sequenceNumberHandler = null, this.Ss = this.bs.bind(this),
|
|
13231
13253
|
this.Ds = new SortedMap(__PRIVATE_primitiveComparator), this.started = !1,
|
|
13232
13254
|
/**
|
|
13233
13255
|
* Captures WebStorage events that occur before `start()` is called. These
|
|
@@ -13270,7 +13292,7 @@ class __PRIVATE_LocalClientState {
|
|
|
13270
13292
|
// format of the key is:
|
|
13271
13293
|
// firestore_bundle_loaded_v2_<persistenceKey>
|
|
13272
13294
|
// The version ending with "v2" stores the list of modified collection groups.
|
|
13273
|
-
(this.persistenceKey), this.
|
|
13295
|
+
(this.persistenceKey), this.Bs = function createBundleLoadedKey(e) {
|
|
13274
13296
|
return `firestore_bundle_loaded_v2_${e}`;
|
|
13275
13297
|
}
|
|
13276
13298
|
// The WebStorage key prefix for the key that stores the last sequence number allocated. The key
|
|
@@ -13282,7 +13304,7 @@ class __PRIVATE_LocalClientState {
|
|
|
13282
13304
|
// respective start() calls). Otherwise, we might for example miss a
|
|
13283
13305
|
// mutation that is added after LocalStore's start() processed the existing
|
|
13284
13306
|
// mutations but before we observe WebStorage events.
|
|
13285
|
-
this.window.addEventListener("storage", this.
|
|
13307
|
+
this.window.addEventListener("storage", this.Ss);
|
|
13286
13308
|
}
|
|
13287
13309
|
/** Returns 'true' if WebStorage is available in the current environment. */ static p(e) {
|
|
13288
13310
|
return !(!e || !e.localStorage);
|
|
@@ -13299,7 +13321,7 @@ class __PRIVATE_LocalClientState {
|
|
|
13299
13321
|
n && (this.Ds = this.Ds.insert(n.clientId, n));
|
|
13300
13322
|
}
|
|
13301
13323
|
}
|
|
13302
|
-
this.
|
|
13324
|
+
this.Ls();
|
|
13303
13325
|
// Check if there is an existing online state and call the callback handler
|
|
13304
13326
|
// if applicable.
|
|
13305
13327
|
const t = this.storage.getItem(this.Ns);
|
|
@@ -13307,7 +13329,7 @@ class __PRIVATE_LocalClientState {
|
|
|
13307
13329
|
const e = this.ks(t);
|
|
13308
13330
|
e && this.qs(e);
|
|
13309
13331
|
}
|
|
13310
|
-
for (const e of this.vs) this.
|
|
13332
|
+
for (const e of this.vs) this.bs(e);
|
|
13311
13333
|
this.vs = [],
|
|
13312
13334
|
// Register a window unload hook to remove the client metadata entry from
|
|
13313
13335
|
// WebStorage even if `shutdown()` was not called.
|
|
@@ -13348,10 +13370,10 @@ class __PRIVATE_LocalClientState {
|
|
|
13348
13370
|
}
|
|
13349
13371
|
// If the query is listening to cache only, the target ID should not be registered with the
|
|
13350
13372
|
// local Firestore client as an active watch target.
|
|
13351
|
-
return t && this.Us.ps(e), this.
|
|
13373
|
+
return t && this.Us.ps(e), this.Ls(), n;
|
|
13352
13374
|
}
|
|
13353
13375
|
removeLocalQueryTarget(e) {
|
|
13354
|
-
this.Us.ys(e), this.
|
|
13376
|
+
this.Us.ys(e), this.Ls();
|
|
13355
13377
|
}
|
|
13356
13378
|
isLocalQueryTarget(e) {
|
|
13357
13379
|
return this.Us.activeTargetIds.has(e);
|
|
@@ -13376,7 +13398,7 @@ class __PRIVATE_LocalClientState {
|
|
|
13376
13398
|
this.zs(e);
|
|
13377
13399
|
}
|
|
13378
13400
|
shutdown() {
|
|
13379
|
-
this.started && (this.window.removeEventListener("storage", this.
|
|
13401
|
+
this.started && (this.window.removeEventListener("storage", this.Ss), this.removeItem(this.Cs),
|
|
13380
13402
|
this.started = !1);
|
|
13381
13403
|
}
|
|
13382
13404
|
getItem(e) {
|
|
@@ -13389,7 +13411,7 @@ class __PRIVATE_LocalClientState {
|
|
|
13389
13411
|
removeItem(e) {
|
|
13390
13412
|
__PRIVATE_logDebug("SharedClientState", "REMOVE", e), this.storage.removeItem(e);
|
|
13391
13413
|
}
|
|
13392
|
-
|
|
13414
|
+
bs(e) {
|
|
13393
13415
|
// Note: The function is typed to take Event to be interface-compatible with
|
|
13394
13416
|
// `Window.addEventListener`.
|
|
13395
13417
|
const t = e;
|
|
@@ -13438,7 +13460,7 @@ class __PRIVATE_LocalClientState {
|
|
|
13438
13460
|
* isolated and no synchronization is performed.
|
|
13439
13461
|
*/ (t.newValue);
|
|
13440
13462
|
e !== __PRIVATE_ListenSequence.oe && this.sequenceNumberHandler(e);
|
|
13441
|
-
} else if (t.key === this.
|
|
13463
|
+
} else if (t.key === this.Bs) {
|
|
13442
13464
|
const e = this.no(t.newValue);
|
|
13443
13465
|
await Promise.all(e.map((e => this.syncEngine.ro(e))));
|
|
13444
13466
|
}
|
|
@@ -13449,7 +13471,7 @@ class __PRIVATE_LocalClientState {
|
|
|
13449
13471
|
get Us() {
|
|
13450
13472
|
return this.Ds.get(this.ws);
|
|
13451
13473
|
}
|
|
13452
|
-
|
|
13474
|
+
Ls() {
|
|
13453
13475
|
this.setItem(this.Cs, this.Us.gs());
|
|
13454
13476
|
}
|
|
13455
13477
|
Ks(e, t, n) {
|
|
@@ -13473,7 +13495,7 @@ class __PRIVATE_LocalClientState {
|
|
|
13473
13495
|
}
|
|
13474
13496
|
zs(e) {
|
|
13475
13497
|
const t = JSON.stringify(Array.from(e));
|
|
13476
|
-
this.setItem(this.
|
|
13498
|
+
this.setItem(this.Bs, t);
|
|
13477
13499
|
}
|
|
13478
13500
|
/**
|
|
13479
13501
|
* Parses a client state key in WebStorage. Returns null if the key does not
|
|
@@ -13786,10 +13808,10 @@ class __PRIVATE_StreamBridge {
|
|
|
13786
13808
|
send(e) {
|
|
13787
13809
|
this.Eo(e);
|
|
13788
13810
|
}
|
|
13789
|
-
|
|
13811
|
+
So() {
|
|
13790
13812
|
this.Vo();
|
|
13791
13813
|
}
|
|
13792
|
-
|
|
13814
|
+
bo() {
|
|
13793
13815
|
this.fo();
|
|
13794
13816
|
}
|
|
13795
13817
|
Do(e) {
|
|
@@ -13840,7 +13862,7 @@ class __PRIVATE_RestConnection {
|
|
|
13840
13862
|
"google-cloud-resource-prefix": this.Mo,
|
|
13841
13863
|
"x-goog-request-params": this.xo
|
|
13842
13864
|
};
|
|
13843
|
-
return this.
|
|
13865
|
+
return this.Bo(_, r, i), this.Lo(e, o, _, n).then((t => (__PRIVATE_logDebug("RestConnection", `Received RPC '${e}' ${s}: `, t),
|
|
13844
13866
|
t)), (t => {
|
|
13845
13867
|
throw __PRIVATE_logWarn("RestConnection", `RPC '${e}' ${s} failed with error: `, t, "url: ", o, "request:", n),
|
|
13846
13868
|
t;
|
|
@@ -13854,12 +13876,12 @@ class __PRIVATE_RestConnection {
|
|
|
13854
13876
|
/**
|
|
13855
13877
|
* Modifies the headers for a request, adding any authorization token if
|
|
13856
13878
|
* present and any additional headers for the request.
|
|
13857
|
-
*/
|
|
13879
|
+
*/ Bo(e, t, n) {
|
|
13858
13880
|
e["X-Goog-Api-Client"] =
|
|
13859
13881
|
// SDK_VERSION is updated to different value at runtime depending on the entry point,
|
|
13860
13882
|
// so we need to get its value when we need it in a function.
|
|
13861
13883
|
function __PRIVATE_getGoogApiClientValue() {
|
|
13862
|
-
return "gl-js/ fire/" +
|
|
13884
|
+
return "gl-js/ fire/" + S;
|
|
13863
13885
|
}(),
|
|
13864
13886
|
// Content-Type: text/plain will avoid preflight requests which might
|
|
13865
13887
|
// mess with CORS and redirects by proxies. If we add custom headers
|
|
@@ -13884,7 +13906,7 @@ class __PRIVATE_RestConnection {
|
|
|
13884
13906
|
super(e), this.forceLongPolling = e.forceLongPolling, this.autoDetectLongPolling = e.autoDetectLongPolling,
|
|
13885
13907
|
this.useFetchStreams = e.useFetchStreams, this.longPollingOptions = e.longPollingOptions;
|
|
13886
13908
|
}
|
|
13887
|
-
|
|
13909
|
+
Lo(e, t, n, r) {
|
|
13888
13910
|
const i = __PRIVATE_generateUniqueDebugId();
|
|
13889
13911
|
return new Promise(((s, o) => {
|
|
13890
13912
|
const _ = new webchannelBlob.XhrIo;
|
|
@@ -13958,7 +13980,7 @@ class __PRIVATE_RestConnection {
|
|
|
13958
13980
|
detectBufferingProxy: this.autoDetectLongPolling
|
|
13959
13981
|
}, a = this.longPollingOptions.timeoutSeconds;
|
|
13960
13982
|
void 0 !== a && (_.longPollingTimeout = Math.round(1e3 * a)), this.useFetchStreams && (_.useFetchStreams = !0),
|
|
13961
|
-
this.
|
|
13983
|
+
this.Bo(_.initMessageHeaders, t, n),
|
|
13962
13984
|
// Sending the custom headers we just added to request.initMessageHeaders
|
|
13963
13985
|
// (Authorization, etc.) will trigger the browser to make a CORS preflight
|
|
13964
13986
|
// request because the XHR will no longer meet the criteria for a "simple"
|
|
@@ -14006,7 +14028,7 @@ class __PRIVATE_RestConnection {
|
|
|
14006
14028
|
// Note that eventually this function could go away if we are confident
|
|
14007
14029
|
// enough the code is exception free.
|
|
14008
14030
|
return __PRIVATE_unguardedEventListen(c, webchannelBlob.WebChannel.EventType.OPEN, (() => {
|
|
14009
|
-
h || (__PRIVATE_logDebug(ge, `RPC '${e}' stream ${r} transport opened.`), P.
|
|
14031
|
+
h || (__PRIVATE_logDebug(ge, `RPC '${e}' stream ${r} transport opened.`), P.So());
|
|
14010
14032
|
})), __PRIVATE_unguardedEventListen(c, webchannelBlob.WebChannel.EventType.CLOSE, (() => {
|
|
14011
14033
|
h || (h = !0, __PRIVATE_logDebug(ge, `RPC '${e}' stream ${r} transport closed`),
|
|
14012
14034
|
P.Do());
|
|
@@ -14053,7 +14075,7 @@ class __PRIVATE_RestConnection {
|
|
|
14053
14075
|
// but because we want to send the first message with the WebChannel
|
|
14054
14076
|
// handshake we pretend the channel opened here (asynchronously), and
|
|
14055
14077
|
// then delay the actual open until the first message is sent.
|
|
14056
|
-
P.
|
|
14078
|
+
P.bo();
|
|
14057
14079
|
}), 0), P;
|
|
14058
14080
|
}
|
|
14059
14081
|
}
|
|
@@ -14415,19 +14437,19 @@ class __PRIVATE_PersistentStream {
|
|
|
14415
14437
|
}), (t => {
|
|
14416
14438
|
e((() => {
|
|
14417
14439
|
const e = new FirestoreError(D.UNKNOWN, "Fetching auth token failed: " + t.message);
|
|
14418
|
-
return this.
|
|
14440
|
+
return this.d_(e);
|
|
14419
14441
|
}));
|
|
14420
14442
|
}));
|
|
14421
14443
|
}
|
|
14422
14444
|
I_(e, t) {
|
|
14423
14445
|
const n = this.T_(this.Xo);
|
|
14424
|
-
this.stream = this.
|
|
14446
|
+
this.stream = this.E_(e, t), this.stream.Ro((() => {
|
|
14425
14447
|
n((() => this.listener.Ro()));
|
|
14426
14448
|
})), this.stream.mo((() => {
|
|
14427
14449
|
n((() => (this.state = 2 /* PersistentStreamState.Open */ , this.t_ = this.li.enqueueAfterDelay(this.Zo, 1e4, (() => (this.s_() && (this.state = 3 /* PersistentStreamState.Healthy */),
|
|
14428
14450
|
Promise.resolve()))), this.listener.mo())));
|
|
14429
14451
|
})), this.stream.po((e => {
|
|
14430
|
-
n((() => this.
|
|
14452
|
+
n((() => this.d_(e)));
|
|
14431
14453
|
})), this.stream.onMessage((e => {
|
|
14432
14454
|
n((() => 1 == ++this.n_ ? this.A_(e) : this.onNext(e)));
|
|
14433
14455
|
}));
|
|
@@ -14438,7 +14460,7 @@ class __PRIVATE_PersistentStream {
|
|
|
14438
14460
|
}));
|
|
14439
14461
|
}
|
|
14440
14462
|
// Visible for tests
|
|
14441
|
-
|
|
14463
|
+
d_(e) {
|
|
14442
14464
|
// In theory the stream could close cleanly, however, in our current model
|
|
14443
14465
|
// we never expect this to happen because if we stop a stream ourselves,
|
|
14444
14466
|
// this callback will never be called. To prevent cases where we retry
|
|
@@ -14470,7 +14492,7 @@ class __PRIVATE_PersistentStream {
|
|
|
14470
14492
|
super(e, "listen_stream_connection_backoff" /* TimerId.ListenStreamConnectionBackoff */ , "listen_stream_idle" /* TimerId.ListenStreamIdle */ , "health_check_timeout" /* TimerId.HealthCheckTimeout */ , t, n, r, s),
|
|
14471
14493
|
this.serializer = i;
|
|
14472
14494
|
}
|
|
14473
|
-
|
|
14495
|
+
E_(e, t) {
|
|
14474
14496
|
return this.connection.qo("Listen", e, t);
|
|
14475
14497
|
}
|
|
14476
14498
|
A_(e) {
|
|
@@ -14564,7 +14586,7 @@ class __PRIVATE_PersistentStream {
|
|
|
14564
14586
|
P_() {
|
|
14565
14587
|
this.f_ && this.g_([]);
|
|
14566
14588
|
}
|
|
14567
|
-
|
|
14589
|
+
E_(e, t) {
|
|
14568
14590
|
return this.connection.qo("Write", e, t);
|
|
14569
14591
|
}
|
|
14570
14592
|
A_(e) {
|
|
@@ -14630,25 +14652,25 @@ class __PRIVATE_PersistentStream {
|
|
|
14630
14652
|
class __PRIVATE_DatastoreImpl extends class Datastore {} {
|
|
14631
14653
|
constructor(e, t, n, r) {
|
|
14632
14654
|
super(), this.authCredentials = e, this.appCheckCredentials = t, this.connection = n,
|
|
14633
|
-
this.serializer = r, this.
|
|
14655
|
+
this.serializer = r, this.S_ = !1;
|
|
14634
14656
|
}
|
|
14635
|
-
|
|
14636
|
-
if (this.
|
|
14657
|
+
b_() {
|
|
14658
|
+
if (this.S_) throw new FirestoreError(D.FAILED_PRECONDITION, "The client has already been terminated.");
|
|
14637
14659
|
}
|
|
14638
14660
|
/** Invokes the provided RPC with auth and AppCheck tokens. */ Oo(e, t, n, r) {
|
|
14639
|
-
return this.
|
|
14661
|
+
return this.b_(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([i, s]) => this.connection.Oo(e, __PRIVATE_toResourcePath(t, n), r, i, s))).catch((e => {
|
|
14640
14662
|
throw "FirebaseError" === e.name ? (e.code === D.UNAUTHENTICATED && (this.authCredentials.invalidateToken(),
|
|
14641
14663
|
this.appCheckCredentials.invalidateToken()), e) : new FirestoreError(D.UNKNOWN, e.toString());
|
|
14642
14664
|
}));
|
|
14643
14665
|
}
|
|
14644
14666
|
/** Invokes the provided RPC with streamed results with auth and AppCheck tokens. */ ko(e, t, n, r, i) {
|
|
14645
|
-
return this.
|
|
14667
|
+
return this.b_(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([s, o]) => this.connection.ko(e, __PRIVATE_toResourcePath(t, n), r, s, o, i))).catch((e => {
|
|
14646
14668
|
throw "FirebaseError" === e.name ? (e.code === D.UNAUTHENTICATED && (this.authCredentials.invalidateToken(),
|
|
14647
14669
|
this.appCheckCredentials.invalidateToken()), e) : new FirestoreError(D.UNKNOWN, e.toString());
|
|
14648
14670
|
}));
|
|
14649
14671
|
}
|
|
14650
14672
|
terminate() {
|
|
14651
|
-
this.
|
|
14673
|
+
this.S_ = !0, this.connection.terminate();
|
|
14652
14674
|
}
|
|
14653
14675
|
}
|
|
14654
14676
|
|
|
@@ -14775,7 +14797,7 @@ class __PRIVATE_OnlineStateTracker {
|
|
|
14775
14797
|
* purely based on order, and so we can just shift() writes from the front of
|
|
14776
14798
|
* the writePipeline as we receive responses.
|
|
14777
14799
|
*/
|
|
14778
|
-
this.
|
|
14800
|
+
this.B_ = [],
|
|
14779
14801
|
/**
|
|
14780
14802
|
* A mapping of watched targets that the client cares about tracking and the
|
|
14781
14803
|
* user has explicitly called a 'listen' for this target.
|
|
@@ -14785,7 +14807,7 @@ class __PRIVATE_OnlineStateTracker {
|
|
|
14785
14807
|
* to the server. The targets removed with unlistens are removed eagerly
|
|
14786
14808
|
* without waiting for confirmation from the listen stream.
|
|
14787
14809
|
*/
|
|
14788
|
-
this.
|
|
14810
|
+
this.L_ = new Map,
|
|
14789
14811
|
/**
|
|
14790
14812
|
* A set of reasons for why the RemoteStore may be offline. If empty, the
|
|
14791
14813
|
* RemoteStore may start its network connections.
|
|
@@ -14832,9 +14854,9 @@ async function __PRIVATE_enableNetworkInternal(e) {
|
|
|
14832
14854
|
*/
|
|
14833
14855
|
function __PRIVATE_remoteStoreListen(e, t) {
|
|
14834
14856
|
const n = __PRIVATE_debugCast(e);
|
|
14835
|
-
n.
|
|
14857
|
+
n.L_.has(t.targetId) || (
|
|
14836
14858
|
// Mark this as something the client is currently listening for.
|
|
14837
|
-
n.
|
|
14859
|
+
n.L_.set(t.targetId, t), __PRIVATE_shouldStartWatchStream(n) ?
|
|
14838
14860
|
// The listen will be sent in onWatchStreamOpen
|
|
14839
14861
|
__PRIVATE_startWatchStream(n) : __PRIVATE_ensureWatchStream(n).s_() && __PRIVATE_sendWatchRequest(n, t));
|
|
14840
14862
|
}
|
|
@@ -14844,7 +14866,7 @@ function __PRIVATE_remoteStoreListen(e, t) {
|
|
|
14844
14866
|
* not being listened to.
|
|
14845
14867
|
*/ function __PRIVATE_remoteStoreUnlisten(e, t) {
|
|
14846
14868
|
const n = __PRIVATE_debugCast(e), r = __PRIVATE_ensureWatchStream(n);
|
|
14847
|
-
n.
|
|
14869
|
+
n.L_.delete(t), r.s_() && __PRIVATE_sendUnwatchRequest(n, t), 0 === n.L_.size && (r.s_() ? r.a_() : __PRIVATE_canUseNetwork(n) &&
|
|
14848
14870
|
// Revert to OnlineState.Unknown if the watch stream is not open and we
|
|
14849
14871
|
// have no listeners, since without any listens to send we cannot
|
|
14850
14872
|
// confirm if the stream is healthy and upgrade to OnlineState.Online.
|
|
@@ -14873,7 +14895,7 @@ function __PRIVATE_remoteStoreListen(e, t) {
|
|
|
14873
14895
|
function __PRIVATE_startWatchStream(e) {
|
|
14874
14896
|
e.U_ = new __PRIVATE_WatchChangeAggregator({
|
|
14875
14897
|
getRemoteKeysForTarget: t => e.remoteSyncer.getRemoteKeysForTarget(t),
|
|
14876
|
-
ut: t => e.
|
|
14898
|
+
ut: t => e.L_.get(t) || null,
|
|
14877
14899
|
nt: () => e.datastore.serializer.databaseId
|
|
14878
14900
|
}), __PRIVATE_ensureWatchStream(e).start(), e.K_.F_();
|
|
14879
14901
|
}
|
|
@@ -14882,7 +14904,7 @@ function __PRIVATE_startWatchStream(e) {
|
|
|
14882
14904
|
* Returns whether the watch stream should be started because it's necessary
|
|
14883
14905
|
* and has not yet been started.
|
|
14884
14906
|
*/ function __PRIVATE_shouldStartWatchStream(e) {
|
|
14885
|
-
return __PRIVATE_canUseNetwork(e) && !__PRIVATE_ensureWatchStream(e).i_() && e.
|
|
14907
|
+
return __PRIVATE_canUseNetwork(e) && !__PRIVATE_ensureWatchStream(e).i_() && e.L_.size > 0;
|
|
14886
14908
|
}
|
|
14887
14909
|
|
|
14888
14910
|
function __PRIVATE_canUseNetwork(e) {
|
|
@@ -14899,7 +14921,7 @@ async function __PRIVATE_onWatchStreamConnected(e) {
|
|
|
14899
14921
|
}
|
|
14900
14922
|
|
|
14901
14923
|
async function __PRIVATE_onWatchStreamOpen(e) {
|
|
14902
|
-
e.
|
|
14924
|
+
e.L_.forEach(((t, n) => {
|
|
14903
14925
|
__PRIVATE_sendWatchRequest(e, t);
|
|
14904
14926
|
}));
|
|
14905
14927
|
}
|
|
@@ -14927,7 +14949,7 @@ async function __PRIVATE_onWatchStreamChange(e, t, n) {
|
|
|
14927
14949
|
const n = t.cause;
|
|
14928
14950
|
for (const r of t.targetIds)
|
|
14929
14951
|
// A watched target might have been removed already.
|
|
14930
|
-
e.
|
|
14952
|
+
e.L_.has(r) && (await e.remoteSyncer.rejectListen(r, n), e.L_.delete(r), e.U_.removeTarget(r));
|
|
14931
14953
|
}
|
|
14932
14954
|
/**
|
|
14933
14955
|
* Attempts to fill our write pipeline with writes from the LocalStore.
|
|
@@ -14958,21 +14980,21 @@ async function __PRIVATE_onWatchStreamChange(e, t, n) {
|
|
|
14958
14980
|
// persistent view of these when applying the completed RemoteEvent.
|
|
14959
14981
|
return n.targetChanges.forEach(((n, r) => {
|
|
14960
14982
|
if (n.resumeToken.approximateByteSize() > 0) {
|
|
14961
|
-
const i = e.
|
|
14983
|
+
const i = e.L_.get(r);
|
|
14962
14984
|
// A watched target might have been removed already.
|
|
14963
|
-
i && e.
|
|
14985
|
+
i && e.L_.set(r, i.withResumeToken(n.resumeToken, t));
|
|
14964
14986
|
}
|
|
14965
14987
|
})),
|
|
14966
14988
|
// Re-establish listens for the targets that have been invalidated by
|
|
14967
14989
|
// existence filter mismatches.
|
|
14968
14990
|
n.targetMismatches.forEach(((t, n) => {
|
|
14969
|
-
const r = e.
|
|
14991
|
+
const r = e.L_.get(t);
|
|
14970
14992
|
if (!r)
|
|
14971
14993
|
// A watched target might have been removed already.
|
|
14972
14994
|
return;
|
|
14973
14995
|
// Clear the resume token for the target, since we're in a known mismatch
|
|
14974
14996
|
// state.
|
|
14975
|
-
e.
|
|
14997
|
+
e.L_.set(t, r.withResumeToken(ByteString.EMPTY_BYTE_STRING, r.snapshotVersion)),
|
|
14976
14998
|
// Cause a hard reset by unwatching and rewatching immediately, but
|
|
14977
14999
|
// deliberately don't send a resume token so that we get a full update.
|
|
14978
15000
|
__PRIVATE_sendUnwatchRequest(e, t);
|
|
@@ -15023,11 +15045,11 @@ async function __PRIVATE_onWatchStreamChange(e, t, n) {
|
|
|
15023
15045
|
|
|
15024
15046
|
async function __PRIVATE_fillWritePipeline(e) {
|
|
15025
15047
|
const t = __PRIVATE_debugCast(e), n = __PRIVATE_ensureWriteStream(t);
|
|
15026
|
-
let r = t.
|
|
15048
|
+
let r = t.B_.length > 0 ? t.B_[t.B_.length - 1].batchId : -1;
|
|
15027
15049
|
for (;__PRIVATE_canAddToWritePipeline(t); ) try {
|
|
15028
15050
|
const e = await __PRIVATE_localStoreGetNextMutationBatch(t.localStore, r);
|
|
15029
15051
|
if (null === e) {
|
|
15030
|
-
0 === t.
|
|
15052
|
+
0 === t.B_.length && n.a_();
|
|
15031
15053
|
break;
|
|
15032
15054
|
}
|
|
15033
15055
|
r = e.batchId, __PRIVATE_addToWritePipeline(t, e);
|
|
@@ -15041,20 +15063,20 @@ async function __PRIVATE_fillWritePipeline(e) {
|
|
|
15041
15063
|
* Returns true if we can add to the write pipeline (i.e. the network is
|
|
15042
15064
|
* enabled and the write pipeline is not full).
|
|
15043
15065
|
*/ function __PRIVATE_canAddToWritePipeline(e) {
|
|
15044
|
-
return __PRIVATE_canUseNetwork(e) && e.
|
|
15066
|
+
return __PRIVATE_canUseNetwork(e) && e.B_.length < 10;
|
|
15045
15067
|
}
|
|
15046
15068
|
|
|
15047
15069
|
/**
|
|
15048
15070
|
* Queues additional writes to be sent to the write stream, sending them
|
|
15049
15071
|
* immediately if the write stream is established.
|
|
15050
15072
|
*/ function __PRIVATE_addToWritePipeline(e, t) {
|
|
15051
|
-
e.
|
|
15073
|
+
e.B_.push(t);
|
|
15052
15074
|
const n = __PRIVATE_ensureWriteStream(e);
|
|
15053
15075
|
n.s_() && n.f_ && n.g_(t.mutations);
|
|
15054
15076
|
}
|
|
15055
15077
|
|
|
15056
15078
|
function __PRIVATE_shouldStartWriteStream(e) {
|
|
15057
|
-
return __PRIVATE_canUseNetwork(e) && !__PRIVATE_ensureWriteStream(e).i_() && e.
|
|
15079
|
+
return __PRIVATE_canUseNetwork(e) && !__PRIVATE_ensureWriteStream(e).i_() && e.B_.length > 0;
|
|
15058
15080
|
}
|
|
15059
15081
|
|
|
15060
15082
|
function __PRIVATE_startWriteStream(e) {
|
|
@@ -15068,11 +15090,11 @@ async function __PRIVATE_onWriteStreamOpen(e) {
|
|
|
15068
15090
|
async function __PRIVATE_onWriteHandshakeComplete(e) {
|
|
15069
15091
|
const t = __PRIVATE_ensureWriteStream(e);
|
|
15070
15092
|
// Send the write pipeline now that the stream is established.
|
|
15071
|
-
for (const n of e.
|
|
15093
|
+
for (const n of e.B_) t.g_(n.mutations);
|
|
15072
15094
|
}
|
|
15073
15095
|
|
|
15074
15096
|
async function __PRIVATE_onMutationResult(e, t, n) {
|
|
15075
|
-
const r = e.
|
|
15097
|
+
const r = e.B_.shift(), i = MutationBatchResult.from(r, t, n);
|
|
15076
15098
|
await __PRIVATE_executeWithRecovery(e, (() => e.remoteSyncer.applySuccessfulWrite(i))),
|
|
15077
15099
|
// It's possible that with the completion of this mutation another
|
|
15078
15100
|
// slot has freed up.
|
|
@@ -15092,7 +15114,7 @@ async function __PRIVATE_onWriteStreamClose(e, t) {
|
|
|
15092
15114
|
}(t.code)) {
|
|
15093
15115
|
// This was a permanent error, the request itself was the problem
|
|
15094
15116
|
// so it's not going to succeed if we resend it.
|
|
15095
|
-
const n = e.
|
|
15117
|
+
const n = e.B_.shift();
|
|
15096
15118
|
// In this case it's also unlikely that the server itself is melting
|
|
15097
15119
|
// down -- this was just a bad request so inhibit backoff on the next
|
|
15098
15120
|
// restart.
|
|
@@ -15141,7 +15163,7 @@ async function __PRIVATE_remoteStoreHandleCredentialChange(e, t) {
|
|
|
15141
15163
|
// Create stream (but note that it is not started yet).
|
|
15142
15164
|
e.W_ = function __PRIVATE_newPersistentWatchStream(e, t, n) {
|
|
15143
15165
|
const r = __PRIVATE_debugCast(e);
|
|
15144
|
-
return r.
|
|
15166
|
+
return r.b_(), new __PRIVATE_PersistentListenStream(t, r.connection, r.authCredentials, r.appCheckCredentials, r.serializer, n);
|
|
15145
15167
|
}
|
|
15146
15168
|
/**
|
|
15147
15169
|
* @license
|
|
@@ -15181,7 +15203,7 @@ async function __PRIVATE_remoteStoreHandleCredentialChange(e, t) {
|
|
|
15181
15203
|
// Create stream (but note that it is not started yet).
|
|
15182
15204
|
e.G_ = function __PRIVATE_newPersistentWriteStream(e, t, n) {
|
|
15183
15205
|
const r = __PRIVATE_debugCast(e);
|
|
15184
|
-
return r.
|
|
15206
|
+
return r.b_(), new __PRIVATE_PersistentWriteStream(t, r.connection, r.authCredentials, r.appCheckCredentials, r.serializer, n);
|
|
15185
15207
|
}(e.datastore, e.asyncQueue, {
|
|
15186
15208
|
Ro: () => Promise.resolve(),
|
|
15187
15209
|
mo: __PRIVATE_onWriteStreamOpen.bind(null, e),
|
|
@@ -15191,8 +15213,8 @@ async function __PRIVATE_remoteStoreHandleCredentialChange(e, t) {
|
|
|
15191
15213
|
}), e.q_.push((async t => {
|
|
15192
15214
|
t ? (e.G_.__(),
|
|
15193
15215
|
// This will start the write stream if necessary.
|
|
15194
|
-
await __PRIVATE_fillWritePipeline(e)) : (await e.G_.stop(), e.
|
|
15195
|
-
e.
|
|
15216
|
+
await __PRIVATE_fillWritePipeline(e)) : (await e.G_.stop(), e.B_.length > 0 && (__PRIVATE_logDebug("RemoteStore", `Stopping write stream with ${e.B_.length} pending writes`),
|
|
15217
|
+
e.B_ = []));
|
|
15196
15218
|
}))), e.G_;
|
|
15197
15219
|
}
|
|
15198
15220
|
|
|
@@ -15814,7 +15836,7 @@ class __PRIVATE_QueryListener {
|
|
|
15814
15836
|
return this.progress.taskState = "Success", {
|
|
15815
15837
|
progress: this.progress,
|
|
15816
15838
|
Ia: this.collectionGroups,
|
|
15817
|
-
|
|
15839
|
+
da: e
|
|
15818
15840
|
};
|
|
15819
15841
|
}
|
|
15820
15842
|
}
|
|
@@ -15872,7 +15894,7 @@ class __PRIVATE_RemovedLimboDocument {
|
|
|
15872
15894
|
constructor(e,
|
|
15873
15895
|
/** Documents included in the remote target */
|
|
15874
15896
|
t) {
|
|
15875
|
-
this.query = e, this.
|
|
15897
|
+
this.query = e, this.Ea = t, this.Aa = null, this.hasCachedResults = !1,
|
|
15876
15898
|
/**
|
|
15877
15899
|
* A flag whether the view is current with the backend. A view is considered
|
|
15878
15900
|
* current after it has seen the current flag from the backend and did not
|
|
@@ -15890,7 +15912,7 @@ class __PRIVATE_RemovedLimboDocument {
|
|
|
15890
15912
|
* The set of remote documents that the server has told us belongs to the target associated with
|
|
15891
15913
|
* this view.
|
|
15892
15914
|
*/ get fa() {
|
|
15893
|
-
return this.
|
|
15915
|
+
return this.Ea;
|
|
15894
15916
|
}
|
|
15895
15917
|
/**
|
|
15896
15918
|
* Iterates over a set of doc changes, applies the query limit, and computes
|
|
@@ -16026,19 +16048,19 @@ class __PRIVATE_RemovedLimboDocument {
|
|
|
16026
16048
|
* See the License for the specific language governing permissions and
|
|
16027
16049
|
* limitations under the License.
|
|
16028
16050
|
*/ (e.type, t.type) || this.Va(e.doc, t.doc))), this.wa(n), r = null != r && r;
|
|
16029
|
-
const o = t && !r ? this.
|
|
16051
|
+
const o = t && !r ? this.Sa() : [], _ = 0 === this.Ra.size && this.current && !r ? 1 /* SyncState.Synced */ : 0 /* SyncState.Local */ , a = _ !== this.Aa;
|
|
16030
16052
|
// We are at synced state if there is no limbo docs are waiting to be resolved, view is current
|
|
16031
16053
|
// with the backend, and the query is not pending to reset due to existence filter mismatch.
|
|
16032
16054
|
if (this.Aa = _, 0 !== s.length || a) {
|
|
16033
16055
|
return {
|
|
16034
16056
|
snapshot: new ViewSnapshot(this.query, e.ma, i, s, e.mutatedKeys, 0 /* SyncState.Local */ === _, a,
|
|
16035
16057
|
/* excludesMetadataChanges= */ !1, !!n && n.resumeToken.approximateByteSize() > 0),
|
|
16036
|
-
|
|
16058
|
+
ba: o
|
|
16037
16059
|
};
|
|
16038
16060
|
}
|
|
16039
16061
|
// no changes
|
|
16040
16062
|
return {
|
|
16041
|
-
|
|
16063
|
+
ba: o
|
|
16042
16064
|
};
|
|
16043
16065
|
}
|
|
16044
16066
|
/**
|
|
@@ -16057,14 +16079,14 @@ class __PRIVATE_RemovedLimboDocument {
|
|
|
16057
16079
|
ss: !1
|
|
16058
16080
|
},
|
|
16059
16081
|
/* limboResolutionEnabled= */ !1)) : {
|
|
16060
|
-
|
|
16082
|
+
ba: []
|
|
16061
16083
|
};
|
|
16062
16084
|
}
|
|
16063
16085
|
/**
|
|
16064
16086
|
* Returns whether the doc for the given key should be in limbo.
|
|
16065
16087
|
*/ Da(e) {
|
|
16066
16088
|
// If the remote end says it's part of this query, it's not in limbo.
|
|
16067
|
-
return !this.
|
|
16089
|
+
return !this.Ea.has(e) && (
|
|
16068
16090
|
// The local store doesn't think it's a result, so it shouldn't be in limbo.
|
|
16069
16091
|
!!this.ma.has(e) && !this.ma.get(e).hasLocalMutations);
|
|
16070
16092
|
}
|
|
@@ -16072,10 +16094,10 @@ class __PRIVATE_RemovedLimboDocument {
|
|
|
16072
16094
|
* Updates syncedDocuments, current, and limbo docs based on the given change.
|
|
16073
16095
|
* Returns the list of changes to which docs are in limbo.
|
|
16074
16096
|
*/ wa(e) {
|
|
16075
|
-
e && (e.addedDocuments.forEach((e => this.
|
|
16076
|
-
e.removedDocuments.forEach((e => this.
|
|
16097
|
+
e && (e.addedDocuments.forEach((e => this.Ea = this.Ea.add(e))), e.modifiedDocuments.forEach((e => {})),
|
|
16098
|
+
e.removedDocuments.forEach((e => this.Ea = this.Ea.delete(e))), this.current = e.current);
|
|
16077
16099
|
}
|
|
16078
|
-
|
|
16100
|
+
Sa() {
|
|
16079
16101
|
// We can only determine limbo documents when we're in-sync with the server.
|
|
16080
16102
|
if (!this.current) return [];
|
|
16081
16103
|
// TODO(klimt): Do this incrementally so that it's not quadratic when
|
|
@@ -16113,7 +16135,7 @@ class __PRIVATE_RemovedLimboDocument {
|
|
|
16113
16135
|
*/
|
|
16114
16136
|
// PORTING NOTE: Multi-tab only.
|
|
16115
16137
|
va(e) {
|
|
16116
|
-
this.
|
|
16138
|
+
this.Ea = e.Es, this.Ra = __PRIVATE_documentKeySet();
|
|
16117
16139
|
const t = this.ga(e.documents);
|
|
16118
16140
|
return this.applyChanges(t, /* limboResolutionEnabled= */ !0);
|
|
16119
16141
|
}
|
|
@@ -16200,12 +16222,12 @@ class __PRIVATE_QueryView {
|
|
|
16200
16222
|
* Keeps track of the target ID for each document that is in limbo with an
|
|
16201
16223
|
* active target.
|
|
16202
16224
|
*/
|
|
16203
|
-
this.
|
|
16225
|
+
this.Ba = new SortedMap(DocumentKey.comparator),
|
|
16204
16226
|
/**
|
|
16205
16227
|
* Keeps track of the information about an active limbo resolution for each
|
|
16206
16228
|
* active target ID that was started for the purpose of limbo resolution.
|
|
16207
16229
|
*/
|
|
16208
|
-
this.
|
|
16230
|
+
this.La = new Map, this.ka = new __PRIVATE_ReferenceSet,
|
|
16209
16231
|
/** Stores user completion handlers, indexed by User and BatchId. */
|
|
16210
16232
|
this.qa = {},
|
|
16211
16233
|
/** Stores user callbacks waiting for all pending writes to be acknowledged. */
|
|
@@ -16271,12 +16293,12 @@ async function __PRIVATE_allocateTargetAndMaybeListen(e, t, n, r) {
|
|
|
16271
16293
|
/* usePreviousResults= */ !1).then((({documents: e}) => t.view.ga(e, i))));
|
|
16272
16294
|
const s = r && r.targetChanges.get(t.targetId), o = r && null != r.targetMismatches.get(t.targetId), _ = t.view.applyChanges(i,
|
|
16273
16295
|
/* limboResolutionEnabled= */ e.isPrimaryClient, s, o);
|
|
16274
|
-
return __PRIVATE_updateTrackedLimbos(e, t.targetId, _.
|
|
16296
|
+
return __PRIVATE_updateTrackedLimbos(e, t.targetId, _.ba), _.snapshot;
|
|
16275
16297
|
}(e, t, n, r);
|
|
16276
16298
|
const s = await __PRIVATE_localStoreExecuteQuery(e.localStore, t,
|
|
16277
|
-
/* usePreviousResults= */ !0), o = new __PRIVATE_View(t, s.
|
|
16299
|
+
/* usePreviousResults= */ !0), o = new __PRIVATE_View(t, s.Es), _ = o.ga(s.documents), a = TargetChange.createSynthesizedTargetChangeForCurrentChange(n, r && "Offline" /* OnlineState.Offline */ !== e.onlineState, i), u = o.applyChanges(_,
|
|
16278
16300
|
/* limboResolutionEnabled= */ e.isPrimaryClient, a);
|
|
16279
|
-
__PRIVATE_updateTrackedLimbos(e, n, u.
|
|
16301
|
+
__PRIVATE_updateTrackedLimbos(e, n, u.ba);
|
|
16280
16302
|
const c = new __PRIVATE_QueryView(t, n, o);
|
|
16281
16303
|
return e.xa.set(t, c), e.Oa.has(n) ? e.Oa.get(n).push(t) : e.Oa.set(n, [ t ]), u.snapshot;
|
|
16282
16304
|
}
|
|
@@ -16389,7 +16411,7 @@ async function __PRIVATE_allocateTargetAndMaybeListen(e, t, n, r) {
|
|
|
16389
16411
|
const e = await __PRIVATE_localStoreApplyRemoteEventToLocalCache(n.localStore, t);
|
|
16390
16412
|
// Update `receivedDocument` as appropriate for any limbo targets.
|
|
16391
16413
|
t.targetChanges.forEach(((e, t) => {
|
|
16392
|
-
const r = n.
|
|
16414
|
+
const r = n.La.get(t);
|
|
16393
16415
|
r && (
|
|
16394
16416
|
// Since this is a limbo resolution lookup, it's for a single document
|
|
16395
16417
|
// and it could be added, modified, or removed, but not a combination.
|
|
@@ -16443,7 +16465,7 @@ async function __PRIVATE_allocateTargetAndMaybeListen(e, t, n, r) {
|
|
|
16443
16465
|
const r = __PRIVATE_debugCast(e);
|
|
16444
16466
|
// PORTING NOTE: Multi-tab only.
|
|
16445
16467
|
r.sharedClientState.updateQueryState(t, "rejected", n);
|
|
16446
|
-
const i = r.
|
|
16468
|
+
const i = r.La.get(t), s = i && i.key;
|
|
16447
16469
|
if (s) {
|
|
16448
16470
|
// TODO(klimt): We really only should do the following on permission
|
|
16449
16471
|
// denied errors, but we don't have the cause code here.
|
|
@@ -16465,7 +16487,7 @@ async function __PRIVATE_allocateTargetAndMaybeListen(e, t, n, r) {
|
|
|
16465
16487
|
// RemoteEvent. If `applyRemoteEvent()` throws, we want to re-listen to
|
|
16466
16488
|
// this query when the RemoteStore restarts the Watch stream, which should
|
|
16467
16489
|
// re-trigger the target failure.
|
|
16468
|
-
r.
|
|
16490
|
+
r.Ba = r.Ba.remove(s), r.La.delete(t), __PRIVATE_pumpEnqueuedLimboResolutions(r);
|
|
16469
16491
|
} else await __PRIVATE_localStoreReleaseTarget(r.localStore, t,
|
|
16470
16492
|
/* keepPersistedTargetData */ !1).then((() => __PRIVATE_removeAndCleanupTarget(r, t, n))).catch(__PRIVATE_ignoreIfPrimaryLeaseLoss);
|
|
16471
16493
|
}
|
|
@@ -16571,9 +16593,9 @@ function __PRIVATE_removeLimboTarget(e, t) {
|
|
|
16571
16593
|
e.Na.delete(t.path.canonicalString());
|
|
16572
16594
|
// It's possible that the target already got removed because the query failed. In that case,
|
|
16573
16595
|
// the key won't exist in `limboTargetsByKey`. Only do the cleanup if we still have the target.
|
|
16574
|
-
const n = e.
|
|
16575
|
-
null !== n && (__PRIVATE_remoteStoreUnlisten(e.remoteStore, n), e.
|
|
16576
|
-
e.
|
|
16596
|
+
const n = e.Ba.get(t);
|
|
16597
|
+
null !== n && (__PRIVATE_remoteStoreUnlisten(e.remoteStore, n), e.Ba = e.Ba.remove(t),
|
|
16598
|
+
e.La.delete(n), __PRIVATE_pumpEnqueuedLimboResolutions(e));
|
|
16577
16599
|
}
|
|
16578
16600
|
|
|
16579
16601
|
function __PRIVATE_updateTrackedLimbos(e, t, n) {
|
|
@@ -16588,7 +16610,7 @@ function __PRIVATE_updateTrackedLimbos(e, t, n) {
|
|
|
16588
16610
|
|
|
16589
16611
|
function __PRIVATE_trackLimboChange(e, t) {
|
|
16590
16612
|
const n = t.key, r = n.path.canonicalString();
|
|
16591
|
-
e.
|
|
16613
|
+
e.Ba.get(n) || e.Na.has(r) || (__PRIVATE_logDebug("SyncEngine", "New document in limbo: " + n),
|
|
16592
16614
|
e.Na.add(r), __PRIVATE_pumpEnqueuedLimboResolutions(e));
|
|
16593
16615
|
}
|
|
16594
16616
|
|
|
@@ -16600,11 +16622,11 @@ function __PRIVATE_trackLimboChange(e, t) {
|
|
|
16600
16622
|
* with "resource exhausted" errors which can lead to pathological client
|
|
16601
16623
|
* behavior as seen in https://github.com/firebase/firebase-js-sdk/issues/2683.
|
|
16602
16624
|
*/ function __PRIVATE_pumpEnqueuedLimboResolutions(e) {
|
|
16603
|
-
for (;e.Na.size > 0 && e.
|
|
16625
|
+
for (;e.Na.size > 0 && e.Ba.size < e.maxConcurrentLimboResolutions; ) {
|
|
16604
16626
|
const t = e.Na.values().next().value;
|
|
16605
16627
|
e.Na.delete(t);
|
|
16606
16628
|
const n = new DocumentKey(ResourcePath.fromString(t)), r = e.Ka.next();
|
|
16607
|
-
e.
|
|
16629
|
+
e.La.set(r, new LimboResolution(n)), e.Ba = e.Ba.insert(n, r), __PRIVATE_remoteStoreListen(e.remoteStore, new TargetData(__PRIVATE_queryToTarget(__PRIVATE_newQueryForPath(n.path)), r, "TargetPurposeLimboResolution" /* TargetPurpose.LimboResolution */ , __PRIVATE_ListenSequence.oe));
|
|
16608
16630
|
}
|
|
16609
16631
|
}
|
|
16610
16632
|
|
|
@@ -16672,7 +16694,7 @@ async function __PRIVATE_syncEngineHandleCredentialChange(e, t) {
|
|
|
16672
16694
|
}
|
|
16673
16695
|
|
|
16674
16696
|
function __PRIVATE_syncEngineGetRemoteKeysForTarget(e, t) {
|
|
16675
|
-
const n = __PRIVATE_debugCast(e), r = n.
|
|
16697
|
+
const n = __PRIVATE_debugCast(e), r = n.La.get(t);
|
|
16676
16698
|
if (r && r.Fa) return __PRIVATE_documentKeySet().add(r.key);
|
|
16677
16699
|
{
|
|
16678
16700
|
let e = __PRIVATE_documentKeySet();
|
|
@@ -16692,7 +16714,7 @@ function __PRIVATE_syncEngineGetRemoteKeysForTarget(e, t) {
|
|
|
16692
16714
|
*/ async function __PRIVATE_synchronizeViewAndComputeSnapshot(e, t) {
|
|
16693
16715
|
const n = __PRIVATE_debugCast(e), r = await __PRIVATE_localStoreExecuteQuery(n.localStore, t.query,
|
|
16694
16716
|
/* usePreviousResults= */ !0), i = t.view.va(r);
|
|
16695
|
-
return n.isPrimaryClient && __PRIVATE_updateTrackedLimbos(n, t.targetId, i.
|
|
16717
|
+
return n.isPrimaryClient && __PRIVATE_updateTrackedLimbos(n, t.targetId, i.ba),
|
|
16696
16718
|
i;
|
|
16697
16719
|
}
|
|
16698
16720
|
|
|
@@ -16724,7 +16746,7 @@ async function __PRIVATE_syncEngineApplyBatchState(e, t, n, r) {
|
|
|
16724
16746
|
// other clients.
|
|
16725
16747
|
__PRIVATE_processUserCallback(i, t, r || null), __PRIVATE_triggerPendingWritesCallbacks(i, t),
|
|
16726
16748
|
function __PRIVATE_localStoreRemoveCachedMutationBatchMetadata(e, t) {
|
|
16727
|
-
__PRIVATE_debugCast(__PRIVATE_debugCast(e).mutationQueue).
|
|
16749
|
+
__PRIVATE_debugCast(__PRIVATE_debugCast(e).mutationQueue).Bn(t);
|
|
16728
16750
|
}
|
|
16729
16751
|
// PORTING NOTE: Multi-Tab only.
|
|
16730
16752
|
(i.localStore, t)) : fail(), await __PRIVATE_syncEngineEmitNewSnapsAndNotifyLocalStore(i, s)) :
|
|
@@ -16764,9 +16786,9 @@ async function __PRIVATE_syncEngineApplyPrimaryState(e, t) {
|
|
|
16764
16786
|
// PORTING NOTE: Multi-Tab only.
|
|
16765
16787
|
function __PRIVATE_resetLimboDocuments(e) {
|
|
16766
16788
|
const t = __PRIVATE_debugCast(e);
|
|
16767
|
-
t.
|
|
16789
|
+
t.La.forEach(((e, n) => {
|
|
16768
16790
|
__PRIVATE_remoteStoreUnlisten(t.remoteStore, n);
|
|
16769
|
-
})), t.ka.wr(), t.
|
|
16791
|
+
})), t.ka.wr(), t.La = new Map, t.Ba = new SortedMap(DocumentKey.comparator);
|
|
16770
16792
|
}
|
|
16771
16793
|
/**
|
|
16772
16794
|
* Reconcile the query views of the provided query targets with the state from
|
|
@@ -16939,7 +16961,7 @@ function __PRIVATE_syncEngineEnsureWriteCallbacks(e) {
|
|
|
16939
16961
|
e && n._updateProgress(e), s = await t.Ga();
|
|
16940
16962
|
}
|
|
16941
16963
|
const o = await i.complete();
|
|
16942
|
-
return await __PRIVATE_syncEngineEmitNewSnapsAndNotifyLocalStore(e, o.
|
|
16964
|
+
return await __PRIVATE_syncEngineEmitNewSnapsAndNotifyLocalStore(e, o.da,
|
|
16943
16965
|
/* remoteEvent */ void 0),
|
|
16944
16966
|
// Save metadata, so loading the same bundle will skip.
|
|
16945
16967
|
await function __PRIVATE_localStoreSaveBundle(e, t) {
|
|
@@ -17042,7 +17064,7 @@ class __PRIVATE_LruGcMemoryOfflineComponentProvider extends __PRIVATE_MemoryOffl
|
|
|
17042
17064
|
await __PRIVATE_syncEngineEnsureWriteCallbacks(this.Za.syncEngine), await __PRIVATE_fillWritePipeline(this.Za.remoteStore),
|
|
17043
17065
|
// NOTE: This will immediately call the listener, so we make sure to
|
|
17044
17066
|
// set it after localStore / remoteStore are started.
|
|
17045
|
-
await this.persistence.
|
|
17067
|
+
await this.persistence.Si((() => (this.gcScheduler && !this.gcScheduler.started && this.gcScheduler.start(),
|
|
17046
17068
|
this.indexBackfillerScheduler && !this.indexBackfillerScheduler.started && this.indexBackfillerScheduler.start(),
|
|
17047
17069
|
Promise.resolve())));
|
|
17048
17070
|
}
|
|
@@ -17089,7 +17111,7 @@ class __PRIVATE_LruGcMemoryOfflineComponentProvider extends __PRIVATE_MemoryOffl
|
|
|
17089
17111
|
}, await this.sharedClientState.start()),
|
|
17090
17112
|
// NOTE: This will immediately call the listener, so we make sure to
|
|
17091
17113
|
// set it after localStore / remoteStore are started.
|
|
17092
|
-
await this.persistence.
|
|
17114
|
+
await this.persistence.Si((async e => {
|
|
17093
17115
|
await __PRIVATE_syncEngineApplyPrimaryState(this.Za.syncEngine, e), this.gcScheduler && (e && !this.gcScheduler.started ? this.gcScheduler.start() : e || this.gcScheduler.stop()),
|
|
17094
17116
|
this.indexBackfillerScheduler && (e && !this.indexBackfillerScheduler.started ? this.indexBackfillerScheduler.start() : e || this.indexBackfillerScheduler.stop());
|
|
17095
17117
|
}));
|
|
@@ -17828,7 +17850,7 @@ function __PRIVATE_firestoreClientGetDocumentsFromLocalCache(e, t) {
|
|
|
17828
17850
|
return e.asyncQueue.enqueueAndForget((async () => async function __PRIVATE_executeQueryFromCache(e, t, n) {
|
|
17829
17851
|
try {
|
|
17830
17852
|
const r = await __PRIVATE_localStoreExecuteQuery(e, t,
|
|
17831
|
-
/* usePreviousResults= */ !0), i = new __PRIVATE_View(t, r.
|
|
17853
|
+
/* usePreviousResults= */ !0), i = new __PRIVATE_View(t, r.Es), s = i.ga(r.documents), o = i.applyChanges(s,
|
|
17832
17854
|
/* limboResolutionEnabled= */ !1);
|
|
17833
17855
|
n.resolve(o.snapshot);
|
|
17834
17856
|
} catch (e) {
|
|
@@ -18590,10 +18612,10 @@ function doc(e, t, ...n) {
|
|
|
18590
18612
|
this.Iu = [],
|
|
18591
18613
|
// Is this AsyncQueue being shut down? Once it is set to true, it will not
|
|
18592
18614
|
// be changed again.
|
|
18593
|
-
this.
|
|
18615
|
+
this.du = !1,
|
|
18594
18616
|
// Operations scheduled to be queued in the future. Operations are
|
|
18595
18617
|
// automatically removed after they are run or canceled.
|
|
18596
|
-
this.
|
|
18618
|
+
this.Eu = [],
|
|
18597
18619
|
// visible for testing
|
|
18598
18620
|
this.Au = null,
|
|
18599
18621
|
// Flag set while there's an outstanding AsyncQueue operation, used for
|
|
@@ -18617,7 +18639,7 @@ function doc(e, t, ...n) {
|
|
|
18617
18639
|
t && "function" == typeof t.addEventListener && t.addEventListener("visibilitychange", this.fu);
|
|
18618
18640
|
}
|
|
18619
18641
|
get isShuttingDown() {
|
|
18620
|
-
return this.
|
|
18642
|
+
return this.du;
|
|
18621
18643
|
}
|
|
18622
18644
|
/**
|
|
18623
18645
|
* Adds a new operation to the queue without waiting for it to complete (i.e.
|
|
@@ -18632,21 +18654,21 @@ function doc(e, t, ...n) {
|
|
|
18632
18654
|
this.yu(e);
|
|
18633
18655
|
}
|
|
18634
18656
|
enterRestrictedMode(e) {
|
|
18635
|
-
if (!this.
|
|
18636
|
-
this.
|
|
18657
|
+
if (!this.du) {
|
|
18658
|
+
this.du = !0, this.Vu = e || !1;
|
|
18637
18659
|
const t = getDocument();
|
|
18638
18660
|
t && "function" == typeof t.removeEventListener && t.removeEventListener("visibilitychange", this.fu);
|
|
18639
18661
|
}
|
|
18640
18662
|
}
|
|
18641
18663
|
enqueue(e) {
|
|
18642
|
-
if (this.pu(), this.
|
|
18664
|
+
if (this.pu(), this.du)
|
|
18643
18665
|
// Return a Promise which never resolves.
|
|
18644
18666
|
return new Promise((() => {}));
|
|
18645
18667
|
// Create a deferred Promise that we can return to the callee. This
|
|
18646
18668
|
// allows us to return a "hanging Promise" only to the callee and still
|
|
18647
18669
|
// advance the queue even when the operation is not run.
|
|
18648
18670
|
const t = new __PRIVATE_Deferred;
|
|
18649
|
-
return this.yu((() => this.
|
|
18671
|
+
return this.yu((() => this.du && this.Vu ? Promise.resolve() : (e().then(t.resolve, t.reject),
|
|
18650
18672
|
t.promise))).then((() => t.promise));
|
|
18651
18673
|
}
|
|
18652
18674
|
enqueueRetryable(e) {
|
|
@@ -18719,8 +18741,8 @@ function doc(e, t, ...n) {
|
|
|
18719
18741
|
this.pu(),
|
|
18720
18742
|
// Fast-forward delays for timerIds that have been overridden.
|
|
18721
18743
|
this.mu.indexOf(e) > -1 && (t = 0);
|
|
18722
|
-
const r = DelayedOperation.createAndSchedule(this, e, t, n, (e => this.
|
|
18723
|
-
return this.
|
|
18744
|
+
const r = DelayedOperation.createAndSchedule(this, e, t, n, (e => this.Su(e)));
|
|
18745
|
+
return this.Eu.push(r), r;
|
|
18724
18746
|
}
|
|
18725
18747
|
pu() {
|
|
18726
18748
|
this.Au && fail();
|
|
@@ -18729,7 +18751,7 @@ function doc(e, t, ...n) {
|
|
|
18729
18751
|
/**
|
|
18730
18752
|
* Waits until all currently queued tasks are finished executing. Delayed
|
|
18731
18753
|
* operations are not run.
|
|
18732
|
-
*/ async
|
|
18754
|
+
*/ async bu() {
|
|
18733
18755
|
// Operations in the queue prior to draining may have enqueued additional
|
|
18734
18756
|
// operations. Keep draining the queue until the tail is no longer advanced,
|
|
18735
18757
|
// which indicates that no more new operations were enqueued and that all
|
|
@@ -18743,7 +18765,7 @@ function doc(e, t, ...n) {
|
|
|
18743
18765
|
* For Tests: Determine if a delayed operation with a particular TimerId
|
|
18744
18766
|
* exists.
|
|
18745
18767
|
*/ Du(e) {
|
|
18746
|
-
for (const t of this.
|
|
18768
|
+
for (const t of this.Eu) if (t.timerId === e) return !0;
|
|
18747
18769
|
return !1;
|
|
18748
18770
|
}
|
|
18749
18771
|
/**
|
|
@@ -18754,12 +18776,12 @@ function doc(e, t, ...n) {
|
|
|
18754
18776
|
* @returns a Promise that resolves once all operations have been run.
|
|
18755
18777
|
*/ vu(e) {
|
|
18756
18778
|
// Note that draining may generate more delayed ops, so we do that first.
|
|
18757
|
-
return this.
|
|
18779
|
+
return this.bu().then((() => {
|
|
18758
18780
|
// Run ops in the same order they'd run if they ran naturally.
|
|
18759
18781
|
/* eslint-disable-next-line @typescript-eslint/no-floating-promises */
|
|
18760
|
-
this.
|
|
18761
|
-
for (const t of this.
|
|
18762
|
-
return this.
|
|
18782
|
+
this.Eu.sort(((e, t) => e.targetTimeMs - t.targetTimeMs));
|
|
18783
|
+
for (const t of this.Eu) if (t.skipDelay(), "all" /* TimerId.All */ !== e && t.timerId === e) break;
|
|
18784
|
+
return this.bu();
|
|
18763
18785
|
}));
|
|
18764
18786
|
}
|
|
18765
18787
|
/**
|
|
@@ -18767,10 +18789,10 @@ function doc(e, t, ...n) {
|
|
|
18767
18789
|
*/ Cu(e) {
|
|
18768
18790
|
this.mu.push(e);
|
|
18769
18791
|
}
|
|
18770
|
-
/** Called once a DelayedOperation is run or canceled. */
|
|
18792
|
+
/** Called once a DelayedOperation is run or canceled. */ Su(e) {
|
|
18771
18793
|
// NOTE: indexOf / slice are O(n), but delayedOperations is expected to be small.
|
|
18772
|
-
const t = this.
|
|
18773
|
-
/* eslint-disable-next-line @typescript-eslint/no-floating-promises */ this.
|
|
18794
|
+
const t = this.Eu.indexOf(e);
|
|
18795
|
+
/* eslint-disable-next-line @typescript-eslint/no-floating-promises */ this.Eu.splice(t, 1);
|
|
18774
18796
|
}
|
|
18775
18797
|
}
|
|
18776
18798
|
|
|
@@ -18898,7 +18920,7 @@ class LoadBundleTask {
|
|
|
18898
18920
|
* Constant used to indicate the LRU garbage collection should be disabled.
|
|
18899
18921
|
* Set this value as the `cacheSizeBytes` on the settings passed to the
|
|
18900
18922
|
* {@link Firestore} instance.
|
|
18901
|
-
*/ const
|
|
18923
|
+
*/ const Se = -1;
|
|
18902
18924
|
|
|
18903
18925
|
/**
|
|
18904
18926
|
* The Cloud Firestore service interface.
|
|
@@ -19558,7 +19580,7 @@ class AggregateField {
|
|
|
19558
19580
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19559
19581
|
* See the License for the specific language governing permissions and
|
|
19560
19582
|
* limitations under the License.
|
|
19561
|
-
*/ const
|
|
19583
|
+
*/ const be = /^__.*__$/;
|
|
19562
19584
|
|
|
19563
19585
|
/** The result of parsing document data (e.g. for a setData call). */ class ParsedSetData {
|
|
19564
19586
|
constructor(e, t, n) {
|
|
@@ -19638,9 +19660,9 @@ function __PRIVATE_isWrite(e) {
|
|
|
19638
19660
|
path: n,
|
|
19639
19661
|
Nu: !1
|
|
19640
19662
|
});
|
|
19641
|
-
return r.
|
|
19663
|
+
return r.Bu(e), r;
|
|
19642
19664
|
}
|
|
19643
|
-
|
|
19665
|
+
Lu(e) {
|
|
19644
19666
|
var t;
|
|
19645
19667
|
const n = null === (t = this.path) || void 0 === t ? void 0 : t.child(e), r = this.xu({
|
|
19646
19668
|
path: n,
|
|
@@ -19665,11 +19687,11 @@ function __PRIVATE_isWrite(e) {
|
|
|
19665
19687
|
Fu() {
|
|
19666
19688
|
// TODO(b/34871131): Remove null check once we have proper paths for fields
|
|
19667
19689
|
// within arrays.
|
|
19668
|
-
if (this.path) for (let e = 0; e < this.path.length; e++) this.
|
|
19690
|
+
if (this.path) for (let e = 0; e < this.path.length; e++) this.Bu(this.path.get(e));
|
|
19669
19691
|
}
|
|
19670
|
-
|
|
19692
|
+
Bu(e) {
|
|
19671
19693
|
if (0 === e.length) throw this.qu("Document fields must not be empty");
|
|
19672
|
-
if (__PRIVATE_isWrite(this.Mu) &&
|
|
19694
|
+
if (__PRIVATE_isWrite(this.Mu) && be.test(e)) throw this.qu('Document fields cannot begin and end with "__"');
|
|
19673
19695
|
}
|
|
19674
19696
|
}
|
|
19675
19697
|
|
|
@@ -19809,7 +19831,7 @@ class __PRIVATE_NumericIncrementFieldValueImpl extends FieldValue {
|
|
|
19809
19831
|
// For Compat types, we have to "extract" the underlying types before
|
|
19810
19832
|
// performing validation.
|
|
19811
19833
|
r = util.getModularInstance(r);
|
|
19812
|
-
const a = i.
|
|
19834
|
+
const a = i.Lu(_);
|
|
19813
19835
|
if (r instanceof __PRIVATE_DeleteFieldValueImpl)
|
|
19814
19836
|
// Add it to the field mask, but don't add anything to updateData.
|
|
19815
19837
|
s.push(_); else {
|
|
@@ -19835,7 +19857,7 @@ class __PRIVATE_NumericIncrementFieldValueImpl extends FieldValue {
|
|
|
19835
19857
|
// For Compat types, we have to "extract" the underlying types before
|
|
19836
19858
|
// performing validation.
|
|
19837
19859
|
n = util.getModularInstance(n);
|
|
19838
|
-
const r = o.
|
|
19860
|
+
const r = o.Lu(t);
|
|
19839
19861
|
if (n instanceof __PRIVATE_DeleteFieldValueImpl)
|
|
19840
19862
|
// Add it to the field mask, but don't add anything to updateData.
|
|
19841
19863
|
u.push(t); else {
|
|
@@ -22224,7 +22246,7 @@ let Fe = null;
|
|
|
22224
22246
|
* @packageDocumentation
|
|
22225
22247
|
*/ !function __PRIVATE_registerFirestore(e, t = !0) {
|
|
22226
22248
|
!function __PRIVATE_setSDKVersion(e) {
|
|
22227
|
-
|
|
22249
|
+
S = e;
|
|
22228
22250
|
}(app.SDK_VERSION), app._registerComponent(new component.Component("firestore", ((e, {instanceIdentifier: n, options: r}) => {
|
|
22229
22251
|
const i = e.getProvider("app").getImmediate(), s = new Firestore(new __PRIVATE_FirebaseAuthCredentialsProvider(e.getProvider("auth-internal")), new __PRIVATE_FirebaseAppCheckTokenProvider(e.getProvider("app-check-internal")), function __PRIVATE_databaseIdFromApp(e, t) {
|
|
22230
22252
|
if (!Object.prototype.hasOwnProperty.apply(e.options, [ "projectId" ])) throw new FirestoreError(D.INVALID_ARGUMENT, '"projectId" not provided in firebase.initializeApp.');
|
|
@@ -22233,16 +22255,16 @@ let Fe = null;
|
|
|
22233
22255
|
return r = Object.assign({
|
|
22234
22256
|
useFetchStreams: t
|
|
22235
22257
|
}, r), s._setSettings(r), s;
|
|
22236
|
-
}), "PUBLIC").setMultipleInstances(!0)), app.registerVersion(w, "4.7.5-canary.
|
|
22258
|
+
}), "PUBLIC").setMultipleInstances(!0)), app.registerVersion(w, "4.7.5-canary.ddc3192b5", e),
|
|
22237
22259
|
// BUILD_TARGET will be replaced by values like esm2017, cjs2017, etc during the compilation
|
|
22238
|
-
app.registerVersion(w, "4.7.5-canary.
|
|
22260
|
+
app.registerVersion(w, "4.7.5-canary.ddc3192b5", "cjs2017");
|
|
22239
22261
|
}();
|
|
22240
22262
|
|
|
22241
22263
|
exports.AbstractUserDataWriter = AbstractUserDataWriter;
|
|
22242
22264
|
exports.AggregateField = AggregateField;
|
|
22243
22265
|
exports.AggregateQuerySnapshot = AggregateQuerySnapshot;
|
|
22244
22266
|
exports.Bytes = Bytes;
|
|
22245
|
-
exports.CACHE_SIZE_UNLIMITED =
|
|
22267
|
+
exports.CACHE_SIZE_UNLIMITED = Se;
|
|
22246
22268
|
exports.CollectionReference = CollectionReference;
|
|
22247
22269
|
exports.DocumentReference = DocumentReference;
|
|
22248
22270
|
exports.DocumentSnapshot = DocumentSnapshot;
|