@firebase/firestore 4.4.3-canary.2b22838aa → 4.4.3-canary.ce88e71e7
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/api/reference_impl.d.ts +12 -0
- package/dist/firestore/src/api.d.ts +1 -1
- package/dist/firestore/src/core/event_manager.d.ts +26 -4
- package/dist/firestore/src/core/sync_engine_impl.d.ts +6 -2
- package/dist/firestore/src/global_index.d.ts +17 -3
- package/dist/firestore/src/local/shared_client_state.d.ts +1 -1
- package/dist/firestore/test/integration/api/query.test.d.ts +2 -1
- package/dist/firestore/test/integration/api/snasphot_listener_source.test.d.ts +17 -0
- package/dist/firestore/test/unit/specs/bundle_spec.test.d.ts +19 -0
- package/dist/firestore/test/unit/specs/listen_source_spec.test.d.ts +17 -0
- package/dist/firestore/test/unit/specs/spec_builder.d.ts +10 -1
- package/dist/firestore/test/unit/specs/spec_test_runner.d.ts +2 -0
- package/dist/index.cjs.js +518 -445
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +12 -0
- package/dist/index.esm2017.js +518 -445
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +1571 -1456
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +131 -35
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +131 -35
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +518 -445
- package/dist/index.rn.js.map +1 -1
- package/dist/internal.d.ts +17 -2
- package/dist/lite/firestore/src/api/reference_impl.d.ts +12 -0
- package/dist/lite/firestore/src/api.d.ts +1 -1
- package/dist/lite/firestore/src/core/event_manager.d.ts +26 -4
- package/dist/lite/firestore/src/core/sync_engine_impl.d.ts +6 -2
- package/dist/lite/firestore/src/local/shared_client_state.d.ts +1 -1
- package/dist/lite/firestore/test/integration/api/query.test.d.ts +2 -1
- package/dist/lite/firestore/test/integration/api/snasphot_listener_source.test.d.ts +17 -0
- package/dist/lite/firestore/test/unit/specs/bundle_spec.test.d.ts +19 -0
- package/dist/lite/firestore/test/unit/specs/listen_source_spec.test.d.ts +17 -0
- package/dist/lite/firestore/test/unit/specs/spec_builder.d.ts +10 -1
- package/dist/lite/firestore/test/unit/specs/spec_test_runner.d.ts +2 -0
- package/dist/lite/index.browser.esm2017.js +2 -2
- package/dist/lite/index.browser.esm5.js +2 -2
- package/dist/lite/index.cjs.js +2 -2
- package/dist/lite/index.node.cjs.js +2 -2
- package/dist/lite/index.node.mjs +2 -2
- package/dist/lite/index.rn.esm2017.js +2 -2
- package/dist/lite/internal.d.ts +4 -2
- package/dist/lite/packages/firestore/src/api/reference_impl.d.ts +12 -0
- package/dist/lite/packages/firestore/src/api.d.ts +1 -1
- package/dist/lite/packages/firestore/src/core/event_manager.d.ts +26 -4
- package/dist/lite/packages/firestore/src/core/sync_engine_impl.d.ts +6 -2
- package/dist/lite/packages/firestore/src/local/shared_client_state.d.ts +1 -1
- package/dist/lite/packages/firestore/test/integration/api/query.test.d.ts +2 -1
- package/dist/lite/packages/firestore/test/integration/api/snasphot_listener_source.test.d.ts +17 -0
- package/dist/lite/packages/firestore/test/unit/specs/bundle_spec.test.d.ts +19 -0
- package/dist/lite/packages/firestore/test/unit/specs/listen_source_spec.test.d.ts +17 -0
- package/dist/lite/packages/firestore/test/unit/specs/spec_builder.d.ts +10 -1
- package/dist/lite/packages/firestore/test/unit/specs/spec_test_runner.d.ts +2 -0
- package/dist/lite/private.d.ts +4 -2
- package/dist/packages/firestore/dist/index.esm2017.d.ts +55 -55
- package/dist/packages/firestore/src/api/reference_impl.d.ts +12 -0
- package/dist/packages/firestore/src/api.d.ts +1 -1
- package/dist/packages/firestore/src/core/event_manager.d.ts +26 -4
- package/dist/packages/firestore/src/core/sync_engine_impl.d.ts +6 -2
- package/dist/packages/firestore/src/local/shared_client_state.d.ts +1 -1
- package/dist/packages/firestore/test/integration/api/query.test.d.ts +2 -1
- package/dist/packages/firestore/test/integration/api/snasphot_listener_source.test.d.ts +17 -0
- package/dist/packages/firestore/test/unit/specs/bundle_spec.test.d.ts +19 -0
- package/dist/packages/firestore/test/unit/specs/listen_source_spec.test.d.ts +17 -0
- package/dist/packages/firestore/test/unit/specs/spec_builder.d.ts +10 -1
- package/dist/packages/firestore/test/unit/specs/spec_test_runner.d.ts +2 -0
- package/dist/private.d.ts +17 -2
- package/package.json +9 -9
package/dist/index.esm2017.js
CHANGED
|
@@ -66,7 +66,7 @@ User.MOCK_USER = new User("mock-user");
|
|
|
66
66
|
* See the License for the specific language governing permissions and
|
|
67
67
|
* limitations under the License.
|
|
68
68
|
*/
|
|
69
|
-
let S = "10.8.1-canary.
|
|
69
|
+
let S = "10.8.1-canary.ce88e71e7";
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
72
|
* @license
|
|
@@ -1732,10 +1732,10 @@ class __PRIVATE_SimpleDbTransaction {
|
|
|
1732
1732
|
__PRIVATE_logDebug("SimpleDb", "Database upgrade to version " + this.version + " complete");
|
|
1733
1733
|
}));
|
|
1734
1734
|
};
|
|
1735
|
-
}))), this.
|
|
1735
|
+
}))), this.L && (this.db.onversionchange = e => this.L(e)), this.db;
|
|
1736
1736
|
}
|
|
1737
|
-
|
|
1738
|
-
this.
|
|
1737
|
+
B(e) {
|
|
1738
|
+
this.L = e, this.db && (this.db.onversionchange = t => e(t));
|
|
1739
1739
|
}
|
|
1740
1740
|
async runTransaction(e, t, n, r) {
|
|
1741
1741
|
const i = "readonly" === t;
|
|
@@ -2301,7 +2301,7 @@ function __PRIVATE_newDbDocumentMutationPrefixForPath(e, t) {
|
|
|
2301
2301
|
* there is no useful information to store as the value. The raw (unencoded)
|
|
2302
2302
|
* path cannot be stored because IndexedDb doesn't store prototype
|
|
2303
2303
|
* information.
|
|
2304
|
-
*/ const x = {}, O = [ "prefixPath", "collectionGroup", "readTime", "documentId" ], N = [ "prefixPath", "collectionGroup", "documentId" ],
|
|
2304
|
+
*/ const x = {}, O = [ "prefixPath", "collectionGroup", "readTime", "documentId" ], N = [ "prefixPath", "collectionGroup", "documentId" ], L = [ "collectionGroup", "readTime", "prefixPath", "documentId" ], B = [ "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" ];
|
|
2305
2305
|
|
|
2306
2306
|
/**
|
|
2307
2307
|
* @license
|
|
@@ -6157,7 +6157,7 @@ class __PRIVATE_WatchTargetChange {
|
|
|
6157
6157
|
Ne() {
|
|
6158
6158
|
this.ge -= 1, __PRIVATE_hardAssert(this.ge >= 0);
|
|
6159
6159
|
}
|
|
6160
|
-
|
|
6160
|
+
Le() {
|
|
6161
6161
|
this.Se = !0, this.we = !0;
|
|
6162
6162
|
}
|
|
6163
6163
|
}
|
|
@@ -6167,7 +6167,7 @@ class __PRIVATE_WatchTargetChange {
|
|
|
6167
6167
|
*/
|
|
6168
6168
|
class __PRIVATE_WatchChangeAggregator {
|
|
6169
6169
|
constructor(e) {
|
|
6170
|
-
this.
|
|
6170
|
+
this.Be = e,
|
|
6171
6171
|
/** The internal state of all tracked targets. */
|
|
6172
6172
|
this.ke = new Map,
|
|
6173
6173
|
/** Keeps track of the documents to update since the last raised snapshot. */
|
|
@@ -6214,7 +6214,7 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6214
6214
|
break;
|
|
6215
6215
|
|
|
6216
6216
|
case 3 /* WatchTargetChangeState.Current */ :
|
|
6217
|
-
this.je(t) && (n.
|
|
6217
|
+
this.je(t) && (n.Le(), n.Ce(e.resumeToken));
|
|
6218
6218
|
break;
|
|
6219
6219
|
|
|
6220
6220
|
case 4 /* WatchTargetChangeState.Reset */ :
|
|
@@ -6305,7 +6305,7 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6305
6305
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
6306
6306
|
* See the License for the specific language governing permissions and
|
|
6307
6307
|
* limitations under the License.
|
|
6308
|
-
*/ (r, e.fe, this.
|
|
6308
|
+
*/ (r, e.fe, this.Be.nt(), n, i));
|
|
6309
6309
|
}
|
|
6310
6310
|
}
|
|
6311
6311
|
}
|
|
@@ -6344,10 +6344,10 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6344
6344
|
* Filter out removed documents based on bloom filter membership result and
|
|
6345
6345
|
* return number of documents removed.
|
|
6346
6346
|
*/ rt(e, t) {
|
|
6347
|
-
const n = this.
|
|
6347
|
+
const n = this.Be.getRemoteKeysForTarget(t);
|
|
6348
6348
|
let r = 0;
|
|
6349
6349
|
return n.forEach((n => {
|
|
6350
|
-
const i = this.
|
|
6350
|
+
const i = this.Be.nt(), s = `projects/${i.projectId}/databases/${i.database}/documents/${n.path.canonicalString()}`;
|
|
6351
6351
|
e.mightContain(s) || (this.We(t, n, /*updatedDocument=*/ null), r++);
|
|
6352
6352
|
})), r;
|
|
6353
6353
|
}
|
|
@@ -6427,7 +6427,7 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6427
6427
|
* target as well as any accumulated changes.
|
|
6428
6428
|
*/ Ze(e) {
|
|
6429
6429
|
const t = this.ze(e).ve();
|
|
6430
|
-
return this.
|
|
6430
|
+
return this.Be.getRemoteKeysForTarget(e).size + t.addedDocuments.size - t.removedDocuments.size;
|
|
6431
6431
|
}
|
|
6432
6432
|
/**
|
|
6433
6433
|
* Increment the number of acks needed from watch before we can consider the
|
|
@@ -6458,7 +6458,7 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6458
6458
|
* is still interested in that has no outstanding target change requests).
|
|
6459
6459
|
*/ Ye(e) {
|
|
6460
6460
|
const t = this.ke.get(e);
|
|
6461
|
-
return t && t.be ? null : this.
|
|
6461
|
+
return t && t.be ? null : this.Be._t(e);
|
|
6462
6462
|
}
|
|
6463
6463
|
/**
|
|
6464
6464
|
* Resets the state of a Watch target to its initial state (e.g. sets
|
|
@@ -6466,7 +6466,7 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6466
6466
|
* from all documents).
|
|
6467
6467
|
*/ He(e) {
|
|
6468
6468
|
this.ke.set(e, new __PRIVATE_TargetState);
|
|
6469
|
-
this.
|
|
6469
|
+
this.Be.getRemoteKeysForTarget(e).forEach((t => {
|
|
6470
6470
|
this.We(e, t, /*updatedDocument=*/ null);
|
|
6471
6471
|
}));
|
|
6472
6472
|
}
|
|
@@ -6474,7 +6474,7 @@ class __PRIVATE_WatchChangeAggregator {
|
|
|
6474
6474
|
* Returns whether the LocalStore considers the document to be part of the
|
|
6475
6475
|
* specified target.
|
|
6476
6476
|
*/ st(e, t) {
|
|
6477
|
-
return this.
|
|
6477
|
+
return this.Be.getRemoteKeysForTarget(e).has(t);
|
|
6478
6478
|
}
|
|
6479
6479
|
}
|
|
6480
6480
|
|
|
@@ -7729,10 +7729,10 @@ function __PRIVATE_unsignedNumLength(e) {
|
|
|
7729
7729
|
}
|
|
7730
7730
|
this.xt();
|
|
7731
7731
|
}
|
|
7732
|
-
|
|
7732
|
+
Lt(e) {
|
|
7733
7733
|
// Values are encoded with a single byte length prefix, followed by the
|
|
7734
7734
|
// actual value in big-endian format with leading 0 bytes dropped.
|
|
7735
|
-
const t = this.
|
|
7735
|
+
const t = this.Bt(e), n = __PRIVATE_unsignedNumLength(t);
|
|
7736
7736
|
this.kt(1 + n), this.buffer[this.position++] = 255 & n;
|
|
7737
7737
|
// Write the length
|
|
7738
7738
|
for (let e = t.length - n; e < t.length; ++e) this.buffer[this.position++] = 255 & t[e];
|
|
@@ -7740,7 +7740,7 @@ function __PRIVATE_unsignedNumLength(e) {
|
|
|
7740
7740
|
qt(e) {
|
|
7741
7741
|
// Values are encoded with a single byte length prefix, followed by the
|
|
7742
7742
|
// inverted value in big-endian format with leading 0 bytes dropped.
|
|
7743
|
-
const t = this.
|
|
7743
|
+
const t = this.Bt(e), n = __PRIVATE_unsignedNumLength(t);
|
|
7744
7744
|
this.kt(1 + n), this.buffer[this.position++] = ~(255 & n);
|
|
7745
7745
|
// Write the length
|
|
7746
7746
|
for (let e = t.length - n; e < t.length; ++e) this.buffer[this.position++] = ~(255 & t[e]);
|
|
@@ -7775,7 +7775,7 @@ function __PRIVATE_unsignedNumLength(e) {
|
|
|
7775
7775
|
* -0.0 < 0.0
|
|
7776
7776
|
* all non-NaN < NaN
|
|
7777
7777
|
* NaN = NaN
|
|
7778
|
-
*/
|
|
7778
|
+
*/ Bt(e) {
|
|
7779
7779
|
const t =
|
|
7780
7780
|
/** Converts a JavaScript number to a byte array (using big endian encoding). */
|
|
7781
7781
|
function __PRIVATE_doubleToLongBits(e) {
|
|
@@ -7834,7 +7834,7 @@ class __PRIVATE_AscendingIndexByteEncoder {
|
|
|
7834
7834
|
this.Gt.Ot(e);
|
|
7835
7835
|
}
|
|
7836
7836
|
dt(e) {
|
|
7837
|
-
this.Gt.
|
|
7837
|
+
this.Gt.Lt(e);
|
|
7838
7838
|
}
|
|
7839
7839
|
Tt() {
|
|
7840
7840
|
this.Gt.Qt();
|
|
@@ -9350,7 +9350,7 @@ class __PRIVATE_TargetIdGenerator {
|
|
|
9350
9350
|
// '0', the backend would consider it unset and replace it with its own ID.
|
|
9351
9351
|
return new __PRIVATE_TargetIdGenerator(0);
|
|
9352
9352
|
}
|
|
9353
|
-
static
|
|
9353
|
+
static Ln() {
|
|
9354
9354
|
// Sync engine assigns target IDs for limbo document detection.
|
|
9355
9355
|
return new __PRIVATE_TargetIdGenerator(-1);
|
|
9356
9356
|
}
|
|
@@ -9382,30 +9382,30 @@ class __PRIVATE_TargetIdGenerator {
|
|
|
9382
9382
|
// to IndexedDb whenever we need to read metadata. We can revisit if it turns
|
|
9383
9383
|
// out to have a meaningful performance impact.
|
|
9384
9384
|
allocateTargetId(e) {
|
|
9385
|
-
return this.
|
|
9385
|
+
return this.Bn(e).next((t => {
|
|
9386
9386
|
const n = new __PRIVATE_TargetIdGenerator(t.highestTargetId);
|
|
9387
9387
|
return t.highestTargetId = n.next(), this.kn(e, t).next((() => t.highestTargetId));
|
|
9388
9388
|
}));
|
|
9389
9389
|
}
|
|
9390
9390
|
getLastRemoteSnapshotVersion(e) {
|
|
9391
|
-
return this.
|
|
9391
|
+
return this.Bn(e).next((e => SnapshotVersion.fromTimestamp(new Timestamp(e.lastRemoteSnapshotVersion.seconds, e.lastRemoteSnapshotVersion.nanoseconds))));
|
|
9392
9392
|
}
|
|
9393
9393
|
getHighestSequenceNumber(e) {
|
|
9394
|
-
return this.
|
|
9394
|
+
return this.Bn(e).next((e => e.highestListenSequenceNumber));
|
|
9395
9395
|
}
|
|
9396
9396
|
setTargetsMetadata(e, t, n) {
|
|
9397
|
-
return this.
|
|
9397
|
+
return this.Bn(e).next((r => (r.highestListenSequenceNumber = t, n && (r.lastRemoteSnapshotVersion = n.toTimestamp()),
|
|
9398
9398
|
t > r.highestListenSequenceNumber && (r.highestListenSequenceNumber = t), this.kn(e, r))));
|
|
9399
9399
|
}
|
|
9400
9400
|
addTargetData(e, t) {
|
|
9401
|
-
return this.qn(e, t).next((() => this.
|
|
9401
|
+
return this.qn(e, t).next((() => this.Bn(e).next((n => (n.targetCount += 1, this.Qn(t, n),
|
|
9402
9402
|
this.kn(e, n))))));
|
|
9403
9403
|
}
|
|
9404
9404
|
updateTargetData(e, t) {
|
|
9405
9405
|
return this.qn(e, t);
|
|
9406
9406
|
}
|
|
9407
9407
|
removeTargetData(e, t) {
|
|
9408
|
-
return this.removeMatchingKeysForTargetId(e, t.targetId).next((() => __PRIVATE_targetsStore(e).delete(t.targetId))).next((() => this.
|
|
9408
|
+
return this.removeMatchingKeysForTargetId(e, t.targetId).next((() => __PRIVATE_targetsStore(e).delete(t.targetId))).next((() => this.Bn(e))).next((t => (__PRIVATE_hardAssert(t.targetCount > 0),
|
|
9409
9409
|
t.targetCount -= 1, this.kn(e, t))));
|
|
9410
9410
|
}
|
|
9411
9411
|
/**
|
|
@@ -9428,7 +9428,7 @@ class __PRIVATE_TargetIdGenerator {
|
|
|
9428
9428
|
t(r);
|
|
9429
9429
|
}));
|
|
9430
9430
|
}
|
|
9431
|
-
|
|
9431
|
+
Bn(e) {
|
|
9432
9432
|
return __PRIVATE_globalTargetStore(e).get("targetGlobalKey").next((e => (__PRIVATE_hardAssert(null !== e),
|
|
9433
9433
|
e)));
|
|
9434
9434
|
}
|
|
@@ -9449,7 +9449,7 @@ class __PRIVATE_TargetIdGenerator {
|
|
|
9449
9449
|
n = !0), n;
|
|
9450
9450
|
}
|
|
9451
9451
|
getTargetCount(e) {
|
|
9452
|
-
return this.
|
|
9452
|
+
return this.Bn(e).next((e => e.targetCount));
|
|
9453
9453
|
}
|
|
9454
9454
|
getTargetData(e, t) {
|
|
9455
9455
|
// Iterating by the canonicalId may yield more than one result because
|
|
@@ -11083,7 +11083,7 @@ class __PRIVATE_MemoryRemoteDocumentChangeBuffer extends RemoteDocumentChangeBuf
|
|
|
11083
11083
|
* A ordered bidirectional mapping between documents and the remote target
|
|
11084
11084
|
* IDs.
|
|
11085
11085
|
*/
|
|
11086
|
-
this.Nr = new __PRIVATE_ReferenceSet, this.targetCount = 0, this.
|
|
11086
|
+
this.Nr = new __PRIVATE_ReferenceSet, this.targetCount = 0, this.Lr = __PRIVATE_TargetIdGenerator.Nn();
|
|
11087
11087
|
}
|
|
11088
11088
|
forEachTarget(e, t) {
|
|
11089
11089
|
return this.Mr.forEach(((e, n) => t(n))), PersistencePromise.resolve();
|
|
@@ -11095,7 +11095,7 @@ class __PRIVATE_MemoryRemoteDocumentChangeBuffer extends RemoteDocumentChangeBuf
|
|
|
11095
11095
|
return PersistencePromise.resolve(this.Or);
|
|
11096
11096
|
}
|
|
11097
11097
|
allocateTargetId(e) {
|
|
11098
|
-
return this.highestTargetId = this.
|
|
11098
|
+
return this.highestTargetId = this.Lr.next(), PersistencePromise.resolve(this.highestTargetId);
|
|
11099
11099
|
}
|
|
11100
11100
|
setTargetsMetadata(e, t, n) {
|
|
11101
11101
|
return n && (this.lastRemoteSnapshotVersion = n), t > this.Or && (this.Or = t),
|
|
@@ -11104,7 +11104,7 @@ class __PRIVATE_MemoryRemoteDocumentChangeBuffer extends RemoteDocumentChangeBuf
|
|
|
11104
11104
|
qn(e) {
|
|
11105
11105
|
this.Mr.set(e.target, e);
|
|
11106
11106
|
const t = e.targetId;
|
|
11107
|
-
t > this.highestTargetId && (this.
|
|
11107
|
+
t > this.highestTargetId && (this.Lr = new __PRIVATE_TargetIdGenerator(t), this.highestTargetId = t),
|
|
11108
11108
|
e.sequenceNumber > this.Or && (this.Or = e.sequenceNumber);
|
|
11109
11109
|
}
|
|
11110
11110
|
addTargetData(e, t) {
|
|
@@ -11182,7 +11182,7 @@ class __PRIVATE_MemoryPersistence {
|
|
|
11182
11182
|
* checked or asserted on every access.
|
|
11183
11183
|
*/
|
|
11184
11184
|
constructor(e, t) {
|
|
11185
|
-
this.
|
|
11185
|
+
this.Br = {}, this.overlays = {}, this.kr = new __PRIVATE_ListenSequence(0), this.qr = !1,
|
|
11186
11186
|
this.qr = !0, this.referenceDelegate = e(this), this.Qr = new __PRIVATE_MemoryTargetCache(this);
|
|
11187
11187
|
this.indexManager = new __PRIVATE_MemoryIndexManager, this.remoteDocumentCache = function __PRIVATE_newMemoryRemoteDocumentCache(e) {
|
|
11188
11188
|
return new __PRIVATE_MemoryRemoteDocumentCacheImpl(e);
|
|
@@ -11216,8 +11216,8 @@ class __PRIVATE_MemoryPersistence {
|
|
|
11216
11216
|
t;
|
|
11217
11217
|
}
|
|
11218
11218
|
getMutationQueue(e, t) {
|
|
11219
|
-
let n = this.
|
|
11220
|
-
return n || (n = new __PRIVATE_MemoryMutationQueue(t, this.referenceDelegate), this.
|
|
11219
|
+
let n = this.Br[e.toKey()];
|
|
11220
|
+
return n || (n = new __PRIVATE_MemoryMutationQueue(t, this.referenceDelegate), this.Br[e.toKey()] = n),
|
|
11221
11221
|
n;
|
|
11222
11222
|
}
|
|
11223
11223
|
getTargetCache() {
|
|
@@ -11236,7 +11236,7 @@ class __PRIVATE_MemoryPersistence {
|
|
|
11236
11236
|
e)));
|
|
11237
11237
|
}
|
|
11238
11238
|
Gr(e, t) {
|
|
11239
|
-
return PersistencePromise.or(Object.values(this.
|
|
11239
|
+
return PersistencePromise.or(Object.values(this.Br).map((n => () => n.containsKey(e, t))));
|
|
11240
11240
|
}
|
|
11241
11241
|
}
|
|
11242
11242
|
|
|
@@ -11509,7 +11509,7 @@ class __PRIVATE_MemoryLruDelegate {
|
|
|
11509
11509
|
const t = e.createObjectStore("remoteDocumentsV14", {
|
|
11510
11510
|
keyPath: O
|
|
11511
11511
|
});
|
|
11512
|
-
t.createIndex("documentKeyIndex", N), t.createIndex("collectionGroupIndex",
|
|
11512
|
+
t.createIndex("documentKeyIndex", N), t.createIndex("collectionGroupIndex", L);
|
|
11513
11513
|
}(e))).next((() => this.ii(e, i))).next((() => e.deleteObjectStore("remoteDocuments")))),
|
|
11514
11514
|
n < 14 && r >= 14 && (s = s.next((() => this.si(e, i)))), n < 15 && r >= 15 && (s = s.next((() => function __PRIVATE_createFieldIndex(e) {
|
|
11515
11515
|
e.createObjectStore("indexConfiguration", {
|
|
@@ -11666,7 +11666,7 @@ function __PRIVATE_createQueryCache(e) {
|
|
|
11666
11666
|
// NOTE: This is unique only because the TargetId is the suffix.
|
|
11667
11667
|
e.createObjectStore("targets", {
|
|
11668
11668
|
keyPath: "targetId"
|
|
11669
|
-
}).createIndex("queryTargetsIndex",
|
|
11669
|
+
}).createIndex("queryTargetsIndex", B, {
|
|
11670
11670
|
unique: !0
|
|
11671
11671
|
}), e.createObjectStore("targetGlobal");
|
|
11672
11672
|
}
|
|
@@ -11792,7 +11792,7 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
11792
11792
|
*
|
|
11793
11793
|
* PORTING NOTE: This is only used for Web multi-tab.
|
|
11794
11794
|
*/ setDatabaseDeletedListener(e) {
|
|
11795
|
-
this.Ei.
|
|
11795
|
+
this.Ei.B((async t => {
|
|
11796
11796
|
// Check if an attempt is made to delete IndexedDB.
|
|
11797
11797
|
null === t.newVersion && await e();
|
|
11798
11798
|
}));
|
|
@@ -11936,7 +11936,7 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
11936
11936
|
})), this.Ei.close(),
|
|
11937
11937
|
// Remove the entry marking the client as zombied from LocalStorage since
|
|
11938
11938
|
// we successfully deleted its metadata from IndexedDb.
|
|
11939
|
-
this.
|
|
11939
|
+
this.Li();
|
|
11940
11940
|
}
|
|
11941
11941
|
/**
|
|
11942
11942
|
* Returns clients that are not zombied and have an updateTime within the
|
|
@@ -11950,7 +11950,7 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
11950
11950
|
* ID.
|
|
11951
11951
|
*
|
|
11952
11952
|
* PORTING NOTE: This is only used for Web multi-tab.
|
|
11953
|
-
*/
|
|
11953
|
+
*/ Bi() {
|
|
11954
11954
|
return this.runTransaction("getActiveClients", "readonly", (e => __PRIVATE_clientMetadataStore(e).W().next((e => this.vi(e, 18e5).map((e => e.clientId))))));
|
|
11955
11955
|
}
|
|
11956
11956
|
get started() {
|
|
@@ -12091,7 +12091,7 @@ class __PRIVATE_IndexedDbPersistence {
|
|
|
12091
12091
|
__PRIVATE_logError("Failed to set zombie client id.", e);
|
|
12092
12092
|
}
|
|
12093
12093
|
}
|
|
12094
|
-
/** Removes the zombied client entry if it exists. */
|
|
12094
|
+
/** Removes the zombied client entry if it exists. */ Li() {
|
|
12095
12095
|
if (this.di) try {
|
|
12096
12096
|
this.di.removeItem(this.Fi(this.clientId));
|
|
12097
12097
|
} catch (e) {
|
|
@@ -13103,7 +13103,7 @@ class __PRIVATE_LocalClientState {
|
|
|
13103
13103
|
async start() {
|
|
13104
13104
|
// Retrieve the list of existing clients to backfill the data in
|
|
13105
13105
|
// SharedClientState.
|
|
13106
|
-
const e = await this.syncEngine.
|
|
13106
|
+
const e = await this.syncEngine.Bi();
|
|
13107
13107
|
for (const t of e) {
|
|
13108
13108
|
if (t === this.Vs) continue;
|
|
13109
13109
|
const e = this.getItem(createWebStorageClientStateKey(this.persistenceKey, t));
|
|
@@ -13139,14 +13139,14 @@ class __PRIVATE_LocalClientState {
|
|
|
13139
13139
|
})), t;
|
|
13140
13140
|
}
|
|
13141
13141
|
addPendingMutation(e) {
|
|
13142
|
-
this.
|
|
13142
|
+
this.Ls(e, "pending");
|
|
13143
13143
|
}
|
|
13144
13144
|
updateMutationState(e, t, n) {
|
|
13145
|
-
this.
|
|
13145
|
+
this.Ls(e, t, n),
|
|
13146
13146
|
// Once a final mutation result is observed by other clients, they no longer
|
|
13147
13147
|
// access the mutation's metadata entry. Since WebStorage replays events
|
|
13148
13148
|
// in order, it is safe to delete the entry right after updating it.
|
|
13149
|
-
this.
|
|
13149
|
+
this.Bs(e);
|
|
13150
13150
|
}
|
|
13151
13151
|
addLocalQueryTarget(e) {
|
|
13152
13152
|
let t = "not-current";
|
|
@@ -13175,7 +13175,7 @@ class __PRIVATE_LocalClientState {
|
|
|
13175
13175
|
}
|
|
13176
13176
|
handleUserChange(e, t, n) {
|
|
13177
13177
|
t.forEach((e => {
|
|
13178
|
-
this.
|
|
13178
|
+
this.Bs(e);
|
|
13179
13179
|
})), this.currentUser = e, n.forEach((e => {
|
|
13180
13180
|
this.addPendingMutation(e);
|
|
13181
13181
|
}));
|
|
@@ -13263,11 +13263,11 @@ class __PRIVATE_LocalClientState {
|
|
|
13263
13263
|
Ms() {
|
|
13264
13264
|
this.setItem(this.ws, this.ks.ds());
|
|
13265
13265
|
}
|
|
13266
|
-
|
|
13266
|
+
Ls(e, t, n) {
|
|
13267
13267
|
const r = new __PRIVATE_MutationMetadata(this.currentUser, e, t, n), i = createWebStorageMutationBatchKey(this.persistenceKey, this.currentUser, e);
|
|
13268
13268
|
this.setItem(i, r.ds());
|
|
13269
13269
|
}
|
|
13270
|
-
|
|
13270
|
+
Bs(e) {
|
|
13271
13271
|
const t = createWebStorageMutationBatchKey(this.persistenceKey, this.currentUser, e);
|
|
13272
13272
|
this.removeItem(t);
|
|
13273
13273
|
}
|
|
@@ -13979,9 +13979,9 @@ class __PRIVATE_ExponentialBackoff {
|
|
|
13979
13979
|
* much as 1.5*maxDelayMs.
|
|
13980
13980
|
*/ , i = 6e4) {
|
|
13981
13981
|
this.oi = e, this.timerId = t, this.Mo = n, this.xo = r, this.Oo = i, this.No = 0,
|
|
13982
|
-
this.
|
|
13982
|
+
this.Lo = null,
|
|
13983
13983
|
/** The last backoff attempt, as epoch milliseconds. */
|
|
13984
|
-
this.
|
|
13984
|
+
this.Bo = Date.now(), this.reset();
|
|
13985
13985
|
}
|
|
13986
13986
|
/**
|
|
13987
13987
|
* Resets the backoff delay.
|
|
@@ -14007,20 +14007,20 @@ class __PRIVATE_ExponentialBackoff {
|
|
|
14007
14007
|
this.cancel();
|
|
14008
14008
|
// First schedule using the current base (which may be 0 and should be
|
|
14009
14009
|
// honored as such).
|
|
14010
|
-
const t = Math.floor(this.No + this.Qo()), n = Math.max(0, Date.now() - this.
|
|
14010
|
+
const t = Math.floor(this.No + this.Qo()), n = Math.max(0, Date.now() - this.Bo), r = Math.max(0, t - n);
|
|
14011
14011
|
// Guard against lastAttemptTime being in the future due to a clock change.
|
|
14012
14012
|
r > 0 && __PRIVATE_logDebug("ExponentialBackoff", `Backing off for ${r} ms (base delay: ${this.No} ms, delay with jitter: ${t} ms, last attempt: ${n} ms ago)`),
|
|
14013
|
-
this.
|
|
14013
|
+
this.Lo = this.oi.enqueueAfterDelay(this.timerId, r, (() => (this.Bo = Date.now(),
|
|
14014
14014
|
e()))),
|
|
14015
14015
|
// Apply backoff factor to determine next delay and ensure it is within
|
|
14016
14016
|
// bounds.
|
|
14017
14017
|
this.No *= this.xo, this.No < this.Mo && (this.No = this.Mo), this.No > this.Oo && (this.No = this.Oo);
|
|
14018
14018
|
}
|
|
14019
14019
|
Ko() {
|
|
14020
|
-
null !== this.
|
|
14020
|
+
null !== this.Lo && (this.Lo.skipDelay(), this.Lo = null);
|
|
14021
14021
|
}
|
|
14022
14022
|
cancel() {
|
|
14023
|
-
null !== this.
|
|
14023
|
+
null !== this.Lo && (this.Lo.cancel(), this.Lo = null);
|
|
14024
14024
|
}
|
|
14025
14025
|
/** Returns a random value in the range [-currentBaseMs/2, currentBaseMs/2] */ Qo() {
|
|
14026
14026
|
return (Math.random() - .5) * this.No;
|
|
@@ -15019,9 +15019,9 @@ async function __PRIVATE_remoteStoreHandleCredentialChange(e, t) {
|
|
|
15019
15019
|
* PORTING NOTE: On iOS and Android, the WriteStream gets registered on startup.
|
|
15020
15020
|
* This is not done on Web to allow it to be tree-shaken.
|
|
15021
15021
|
*/ function __PRIVATE_ensureWriteStream(e) {
|
|
15022
|
-
return e.
|
|
15022
|
+
return e.L_ || (
|
|
15023
15023
|
// Create stream (but note that it is not started yet).
|
|
15024
|
-
e.
|
|
15024
|
+
e.L_ = function __PRIVATE_newPersistentWriteStream(e, t, n) {
|
|
15025
15025
|
const r = __PRIVATE_debugCast(e);
|
|
15026
15026
|
return r.R_(), new __PRIVATE_PersistentWriteStream(t, r.connection, r.authCredentials, r.appCheckCredentials, r.serializer, n);
|
|
15027
15027
|
}(e.datastore, e.asyncQueue, {
|
|
@@ -15030,11 +15030,11 @@ async function __PRIVATE_remoteStoreHandleCredentialChange(e, t) {
|
|
|
15030
15030
|
E_: __PRIVATE_onWriteHandshakeComplete.bind(null, e),
|
|
15031
15031
|
T_: __PRIVATE_onMutationResult.bind(null, e)
|
|
15032
15032
|
}), e.F_.push((async t => {
|
|
15033
|
-
t ? (e.
|
|
15033
|
+
t ? (e.L_.Zo(),
|
|
15034
15034
|
// This will start the write stream if necessary.
|
|
15035
|
-
await __PRIVATE_fillWritePipeline(e)) : (await e.
|
|
15035
|
+
await __PRIVATE_fillWritePipeline(e)) : (await e.L_.stop(), e.D_.length > 0 && (__PRIVATE_logDebug("RemoteStore", `Stopping write stream with ${e.D_.length} pending writes`),
|
|
15036
15036
|
e.D_ = []));
|
|
15037
|
-
}))), e.
|
|
15037
|
+
}))), e.L_;
|
|
15038
15038
|
}
|
|
15039
15039
|
|
|
15040
15040
|
/**
|
|
@@ -15247,25 +15247,25 @@ class DelayedOperation {
|
|
|
15247
15247
|
* duplicate events for the same doc.
|
|
15248
15248
|
*/ class __PRIVATE_DocumentChangeSet {
|
|
15249
15249
|
constructor() {
|
|
15250
|
-
this.
|
|
15250
|
+
this.B_ = new SortedMap(DocumentKey.comparator);
|
|
15251
15251
|
}
|
|
15252
15252
|
track(e) {
|
|
15253
|
-
const t = e.doc.key, n = this.
|
|
15253
|
+
const t = e.doc.key, n = this.B_.get(t);
|
|
15254
15254
|
n ?
|
|
15255
15255
|
// Merge the new change with the existing change.
|
|
15256
|
-
0 /* ChangeType.Added */ !== e.type && 3 /* ChangeType.Metadata */ === n.type ? this.
|
|
15256
|
+
0 /* ChangeType.Added */ !== e.type && 3 /* ChangeType.Metadata */ === n.type ? this.B_ = this.B_.insert(t, e) : 3 /* ChangeType.Metadata */ === e.type && 1 /* ChangeType.Removed */ !== n.type ? this.B_ = this.B_.insert(t, {
|
|
15257
15257
|
type: n.type,
|
|
15258
15258
|
doc: e.doc
|
|
15259
|
-
}) : 2 /* ChangeType.Modified */ === e.type && 2 /* ChangeType.Modified */ === n.type ? this.
|
|
15259
|
+
}) : 2 /* ChangeType.Modified */ === e.type && 2 /* ChangeType.Modified */ === n.type ? this.B_ = this.B_.insert(t, {
|
|
15260
15260
|
type: 2 /* ChangeType.Modified */ ,
|
|
15261
15261
|
doc: e.doc
|
|
15262
|
-
}) : 2 /* ChangeType.Modified */ === e.type && 0 /* ChangeType.Added */ === n.type ? this.
|
|
15262
|
+
}) : 2 /* ChangeType.Modified */ === e.type && 0 /* ChangeType.Added */ === n.type ? this.B_ = this.B_.insert(t, {
|
|
15263
15263
|
type: 0 /* ChangeType.Added */ ,
|
|
15264
15264
|
doc: e.doc
|
|
15265
|
-
}) : 1 /* ChangeType.Removed */ === e.type && 0 /* ChangeType.Added */ === n.type ? this.
|
|
15265
|
+
}) : 1 /* ChangeType.Removed */ === e.type && 0 /* ChangeType.Added */ === n.type ? this.B_ = this.B_.remove(t) : 1 /* ChangeType.Removed */ === e.type && 2 /* ChangeType.Modified */ === n.type ? this.B_ = this.B_.insert(t, {
|
|
15266
15266
|
type: 1 /* ChangeType.Removed */ ,
|
|
15267
15267
|
doc: n.doc
|
|
15268
|
-
}) : 0 /* ChangeType.Added */ === e.type && 1 /* ChangeType.Removed */ === n.type ? this.
|
|
15268
|
+
}) : 0 /* ChangeType.Added */ === e.type && 1 /* ChangeType.Removed */ === n.type ? this.B_ = this.B_.insert(t, {
|
|
15269
15269
|
type: 2 /* ChangeType.Modified */ ,
|
|
15270
15270
|
doc: e.doc
|
|
15271
15271
|
}) :
|
|
@@ -15276,11 +15276,11 @@ class DelayedOperation {
|
|
|
15276
15276
|
// Removed->Modified
|
|
15277
15277
|
// Metadata->Added
|
|
15278
15278
|
// Removed->Metadata
|
|
15279
|
-
fail() : this.
|
|
15279
|
+
fail() : this.B_ = this.B_.insert(t, e);
|
|
15280
15280
|
}
|
|
15281
15281
|
k_() {
|
|
15282
15282
|
const e = [];
|
|
15283
|
-
return this.
|
|
15283
|
+
return this.B_.inorderTraversal(((t, n) => {
|
|
15284
15284
|
e.push(n);
|
|
15285
15285
|
})), e;
|
|
15286
15286
|
}
|
|
@@ -15338,40 +15338,79 @@ class ViewSnapshot {
|
|
|
15338
15338
|
constructor() {
|
|
15339
15339
|
this.q_ = void 0, this.Q_ = [];
|
|
15340
15340
|
}
|
|
15341
|
+
// Helper methods that checks if the query has listeners that listening to remote store
|
|
15342
|
+
K_() {
|
|
15343
|
+
return this.Q_.some((e => e.U_()));
|
|
15344
|
+
}
|
|
15341
15345
|
}
|
|
15342
15346
|
|
|
15343
15347
|
class __PRIVATE_EventManagerImpl {
|
|
15344
15348
|
constructor() {
|
|
15345
15349
|
this.queries = new ObjectMap((e => __PRIVATE_canonifyQuery(e)), __PRIVATE_queryEquals),
|
|
15346
|
-
this.onlineState = "Unknown" /* OnlineState.Unknown */ , this.
|
|
15350
|
+
this.onlineState = "Unknown" /* OnlineState.Unknown */ , this.W_ = new Set;
|
|
15347
15351
|
}
|
|
15348
15352
|
}
|
|
15349
15353
|
|
|
15350
15354
|
async function __PRIVATE_eventManagerListen(e, t) {
|
|
15351
|
-
const n = __PRIVATE_debugCast(e)
|
|
15352
|
-
let
|
|
15353
|
-
|
|
15354
|
-
|
|
15355
|
+
const n = __PRIVATE_debugCast(e);
|
|
15356
|
+
let r = 3 /* ListenerSetupAction.NoActionRequired */;
|
|
15357
|
+
const i = t.query;
|
|
15358
|
+
let s = n.queries.get(i);
|
|
15359
|
+
s ? !s.K_() && t.U_() && (
|
|
15360
|
+
// Query has been listening to local cache, and tries to add a new listener sourced from watch.
|
|
15361
|
+
r = 2 /* ListenerSetupAction.RequireWatchConnectionOnly */) : (s = new __PRIVATE_QueryListenersInfo,
|
|
15362
|
+
r = t.U_() ? 0 /* ListenerSetupAction.InitializeLocalListenAndRequireWatchConnection */ : 1 /* ListenerSetupAction.InitializeLocalListenOnly */);
|
|
15363
|
+
try {
|
|
15364
|
+
switch (r) {
|
|
15365
|
+
case 0 /* ListenerSetupAction.InitializeLocalListenAndRequireWatchConnection */ :
|
|
15366
|
+
s.q_ = await n.onListen(i,
|
|
15367
|
+
/** enableRemoteListen= */ !0);
|
|
15368
|
+
break;
|
|
15369
|
+
|
|
15370
|
+
case 1 /* ListenerSetupAction.InitializeLocalListenOnly */ :
|
|
15371
|
+
s.q_ = await n.onListen(i,
|
|
15372
|
+
/** enableRemoteListen= */ !1);
|
|
15373
|
+
break;
|
|
15374
|
+
|
|
15375
|
+
case 2 /* ListenerSetupAction.RequireWatchConnectionOnly */ :
|
|
15376
|
+
await n.onFirstRemoteStoreListen(i);
|
|
15377
|
+
}
|
|
15355
15378
|
} catch (e) {
|
|
15356
15379
|
const n = __PRIVATE_wrapInUserErrorIfRecoverable(e, `Initialization of query '${__PRIVATE_stringifyQuery(t.query)}' failed`);
|
|
15357
15380
|
return void t.onError(n);
|
|
15358
15381
|
}
|
|
15359
|
-
if (n.queries.set(
|
|
15382
|
+
if (n.queries.set(i, s), s.Q_.push(t),
|
|
15360
15383
|
// Run global snapshot listeners if a consistent snapshot has been emitted.
|
|
15361
|
-
t.
|
|
15362
|
-
t.
|
|
15384
|
+
t.G_(n.onlineState), s.q_) {
|
|
15385
|
+
t.z_(s.q_) && __PRIVATE_raiseSnapshotsInSyncEvent(n);
|
|
15363
15386
|
}
|
|
15364
15387
|
}
|
|
15365
15388
|
|
|
15366
15389
|
async function __PRIVATE_eventManagerUnlisten(e, t) {
|
|
15367
15390
|
const n = __PRIVATE_debugCast(e), r = t.query;
|
|
15368
|
-
let i =
|
|
15391
|
+
let i = 3 /* ListenerRemovalAction.NoActionRequired */;
|
|
15369
15392
|
const s = n.queries.get(r);
|
|
15370
15393
|
if (s) {
|
|
15371
15394
|
const e = s.Q_.indexOf(t);
|
|
15372
|
-
e >= 0 && (s.Q_.splice(e, 1), i = 0
|
|
15395
|
+
e >= 0 && (s.Q_.splice(e, 1), 0 === s.Q_.length ? i = t.U_() ? 0 /* ListenerRemovalAction.TerminateLocalListenAndRequireWatchDisconnection */ : 1 /* ListenerRemovalAction.TerminateLocalListenOnly */ : !s.K_() && t.U_() && (
|
|
15396
|
+
// The removed listener is the last one that sourced from watch.
|
|
15397
|
+
i = 2 /* ListenerRemovalAction.RequireWatchDisconnectionOnly */));
|
|
15398
|
+
}
|
|
15399
|
+
switch (i) {
|
|
15400
|
+
case 0 /* ListenerRemovalAction.TerminateLocalListenAndRequireWatchDisconnection */ :
|
|
15401
|
+
return n.queries.delete(r), n.onUnlisten(r,
|
|
15402
|
+
/** disableRemoteListen= */ !0);
|
|
15403
|
+
|
|
15404
|
+
case 1 /* ListenerRemovalAction.TerminateLocalListenOnly */ :
|
|
15405
|
+
return n.queries.delete(r), n.onUnlisten(r,
|
|
15406
|
+
/** disableRemoteListen= */ !1);
|
|
15407
|
+
|
|
15408
|
+
case 2 /* ListenerRemovalAction.RequireWatchDisconnectionOnly */ :
|
|
15409
|
+
return n.onLastRemoteStoreUnlisten(r);
|
|
15410
|
+
|
|
15411
|
+
default:
|
|
15412
|
+
return;
|
|
15373
15413
|
}
|
|
15374
|
-
if (i) return n.queries.delete(r), n.onUnlisten(r);
|
|
15375
15414
|
}
|
|
15376
15415
|
|
|
15377
15416
|
function __PRIVATE_eventManagerOnWatchChange(e, t) {
|
|
@@ -15380,7 +15419,7 @@ function __PRIVATE_eventManagerOnWatchChange(e, t) {
|
|
|
15380
15419
|
for (const e of t) {
|
|
15381
15420
|
const t = e.query, i = n.queries.get(t);
|
|
15382
15421
|
if (i) {
|
|
15383
|
-
for (const t of i.Q_) t.
|
|
15422
|
+
for (const t of i.Q_) t.z_(e) && (r = !0);
|
|
15384
15423
|
i.q_ = e;
|
|
15385
15424
|
}
|
|
15386
15425
|
}
|
|
@@ -15397,24 +15436,32 @@ function __PRIVATE_eventManagerOnWatchError(e, t, n) {
|
|
|
15397
15436
|
|
|
15398
15437
|
// Call all global snapshot listeners that have been set.
|
|
15399
15438
|
function __PRIVATE_raiseSnapshotsInSyncEvent(e) {
|
|
15400
|
-
e.
|
|
15439
|
+
e.W_.forEach((e => {
|
|
15401
15440
|
e.next();
|
|
15402
15441
|
}));
|
|
15403
15442
|
}
|
|
15404
15443
|
|
|
15444
|
+
var me, fe;
|
|
15445
|
+
|
|
15446
|
+
/** Listen to both cache and server changes */
|
|
15447
|
+
(fe = me || (me = {})).j_ = "default",
|
|
15448
|
+
/** Listen to changes in cache only */
|
|
15449
|
+
fe.Cache = "cache";
|
|
15450
|
+
|
|
15405
15451
|
/**
|
|
15406
15452
|
* QueryListener takes a series of internal view snapshots and determines
|
|
15407
15453
|
* when to raise the event.
|
|
15408
15454
|
*
|
|
15409
15455
|
* It uses an Observer to dispatch events.
|
|
15410
|
-
*/
|
|
15456
|
+
*/
|
|
15457
|
+
class __PRIVATE_QueryListener {
|
|
15411
15458
|
constructor(e, t, n) {
|
|
15412
|
-
this.query = e, this.
|
|
15459
|
+
this.query = e, this.H_ = t,
|
|
15413
15460
|
/**
|
|
15414
15461
|
* Initial snapshots (e.g. from cache) may not be propagated to the wrapped
|
|
15415
15462
|
* observer. This flag is set to true once we've actually raised an event.
|
|
15416
15463
|
*/
|
|
15417
|
-
this.
|
|
15464
|
+
this.J_ = !1, this.Y_ = null, this.onlineState = "Unknown" /* OnlineState.Unknown */ ,
|
|
15418
15465
|
this.options = n || {};
|
|
15419
15466
|
}
|
|
15420
15467
|
/**
|
|
@@ -15422,7 +15469,7 @@ function __PRIVATE_raiseSnapshotsInSyncEvent(e) {
|
|
|
15422
15469
|
* if applicable (depending on what changed, whether the user has opted into
|
|
15423
15470
|
* metadata-only changes, etc.). Returns true if a user-facing event was
|
|
15424
15471
|
* indeed raised.
|
|
15425
|
-
*/
|
|
15472
|
+
*/ z_(e) {
|
|
15426
15473
|
if (!this.options.includeMetadataChanges) {
|
|
15427
15474
|
// Remove the metadata only changes.
|
|
15428
15475
|
const t = [];
|
|
@@ -15431,45 +15478,50 @@ function __PRIVATE_raiseSnapshotsInSyncEvent(e) {
|
|
|
15431
15478
|
/* excludesMetadataChanges= */ !0, e.hasCachedResults);
|
|
15432
15479
|
}
|
|
15433
15480
|
let t = !1;
|
|
15434
|
-
return this.
|
|
15435
|
-
t = !0), this.
|
|
15481
|
+
return this.J_ ? this.Z_(e) && (this.H_.next(e), t = !0) : this.X_(e, this.onlineState) && (this.ea(e),
|
|
15482
|
+
t = !0), this.Y_ = e, t;
|
|
15436
15483
|
}
|
|
15437
15484
|
onError(e) {
|
|
15438
|
-
this.
|
|
15485
|
+
this.H_.error(e);
|
|
15439
15486
|
}
|
|
15440
|
-
/** Returns whether a snapshot was raised. */
|
|
15487
|
+
/** Returns whether a snapshot was raised. */ G_(e) {
|
|
15441
15488
|
this.onlineState = e;
|
|
15442
15489
|
let t = !1;
|
|
15443
|
-
return this.
|
|
15490
|
+
return this.Y_ && !this.J_ && this.X_(this.Y_, e) && (this.ea(this.Y_), t = !0),
|
|
15444
15491
|
t;
|
|
15445
15492
|
}
|
|
15446
|
-
|
|
15493
|
+
X_(e, t) {
|
|
15447
15494
|
// Always raise the first event when we're synced
|
|
15448
15495
|
if (!e.fromCache) return !0;
|
|
15496
|
+
// Always raise event if listening to cache
|
|
15497
|
+
if (!this.U_()) return !0;
|
|
15449
15498
|
// NOTE: We consider OnlineState.Unknown as online (it should become Offline
|
|
15450
15499
|
// or Online if we wait long enough).
|
|
15451
15500
|
const n = "Offline" /* OnlineState.Offline */ !== t;
|
|
15452
15501
|
// Don't raise the event if we're online, aren't synced yet (checked
|
|
15453
15502
|
// above) and are waiting for a sync.
|
|
15454
|
-
return (!this.options.
|
|
15503
|
+
return (!this.options.ta || !n) && (!e.docs.isEmpty() || e.hasCachedResults || "Offline" /* OnlineState.Offline */ === t);
|
|
15455
15504
|
// Raise data from cache if we have any documents, have cached results before,
|
|
15456
15505
|
// or we are offline.
|
|
15457
15506
|
}
|
|
15458
|
-
|
|
15507
|
+
Z_(e) {
|
|
15459
15508
|
// We don't need to handle includeDocumentMetadataChanges here because
|
|
15460
15509
|
// the Metadata only changes have already been stripped out if needed.
|
|
15461
15510
|
// At this point the only changes we will see are the ones we should
|
|
15462
15511
|
// propagate.
|
|
15463
15512
|
if (e.docChanges.length > 0) return !0;
|
|
15464
|
-
const t = this.
|
|
15513
|
+
const t = this.Y_ && this.Y_.hasPendingWrites !== e.hasPendingWrites;
|
|
15465
15514
|
return !(!e.syncStateChanged && !t) && !0 === this.options.includeMetadataChanges;
|
|
15466
15515
|
// Generally we should have hit one of the cases above, but it's possible
|
|
15467
15516
|
// to get here if there were only metadata docChanges and they got
|
|
15468
15517
|
// stripped out.
|
|
15469
15518
|
}
|
|
15470
|
-
|
|
15519
|
+
ea(e) {
|
|
15471
15520
|
e = ViewSnapshot.fromInitialDocuments(e.query, e.docs, e.mutatedKeys, e.fromCache, e.hasCachedResults),
|
|
15472
|
-
this.
|
|
15521
|
+
this.J_ = !0, this.H_.next(e);
|
|
15522
|
+
}
|
|
15523
|
+
U_() {
|
|
15524
|
+
return this.options.source !== me.Cache;
|
|
15473
15525
|
}
|
|
15474
15526
|
}
|
|
15475
15527
|
|
|
@@ -15496,10 +15548,10 @@ function __PRIVATE_raiseSnapshotsInSyncEvent(e) {
|
|
|
15496
15548
|
constructor(e,
|
|
15497
15549
|
// How many bytes this element takes to store in the bundle.
|
|
15498
15550
|
t) {
|
|
15499
|
-
this.
|
|
15551
|
+
this.na = e, this.byteLength = t;
|
|
15500
15552
|
}
|
|
15501
|
-
|
|
15502
|
-
return "metadata" in this.
|
|
15553
|
+
ra() {
|
|
15554
|
+
return "metadata" in this.na;
|
|
15503
15555
|
}
|
|
15504
15556
|
}
|
|
15505
15557
|
|
|
@@ -15543,7 +15595,7 @@ function __PRIVATE_raiseSnapshotsInSyncEvent(e) {
|
|
|
15543
15595
|
* storage and provide progress update while loading.
|
|
15544
15596
|
*/ class __PRIVATE_BundleLoader {
|
|
15545
15597
|
constructor(e, t, n) {
|
|
15546
|
-
this.
|
|
15598
|
+
this.ia = e, this.localStore = t, this.serializer = n,
|
|
15547
15599
|
/** Batched queries to be saved into storage */
|
|
15548
15600
|
this.queries = [],
|
|
15549
15601
|
/** Batched documents to be saved into storage */
|
|
@@ -15556,21 +15608,21 @@ function __PRIVATE_raiseSnapshotsInSyncEvent(e) {
|
|
|
15556
15608
|
*
|
|
15557
15609
|
* Returns a new progress if adding the element leads to a new progress,
|
|
15558
15610
|
* otherwise returns null.
|
|
15559
|
-
*/
|
|
15611
|
+
*/ sa(e) {
|
|
15560
15612
|
this.progress.bytesLoaded += e.byteLength;
|
|
15561
15613
|
let t = this.progress.documentsLoaded;
|
|
15562
|
-
if (e.
|
|
15614
|
+
if (e.na.namedQuery) this.queries.push(e.na.namedQuery); else if (e.na.documentMetadata) {
|
|
15563
15615
|
this.documents.push({
|
|
15564
|
-
metadata: e.
|
|
15565
|
-
}), e.
|
|
15566
|
-
const n = ResourcePath.fromString(e.
|
|
15616
|
+
metadata: e.na.documentMetadata
|
|
15617
|
+
}), e.na.documentMetadata.exists || ++t;
|
|
15618
|
+
const n = ResourcePath.fromString(e.na.documentMetadata.name);
|
|
15567
15619
|
this.collectionGroups.add(n.get(n.length - 2));
|
|
15568
|
-
} else e.
|
|
15620
|
+
} else e.na.document && (this.documents[this.documents.length - 1].document = e.na.document,
|
|
15569
15621
|
++t);
|
|
15570
15622
|
return t !== this.progress.documentsLoaded ? (this.progress.documentsLoaded = t,
|
|
15571
15623
|
Object.assign({}, this.progress)) : null;
|
|
15572
15624
|
}
|
|
15573
|
-
|
|
15625
|
+
oa(e) {
|
|
15574
15626
|
const t = new Map, n = new __PRIVATE_BundleConverterImpl(this.serializer);
|
|
15575
15627
|
for (const r of e) if (r.metadata.queries) {
|
|
15576
15628
|
const e = n.Ps(r.metadata.name);
|
|
@@ -15584,12 +15636,12 @@ function __PRIVATE_raiseSnapshotsInSyncEvent(e) {
|
|
|
15584
15636
|
/**
|
|
15585
15637
|
* Update the progress to 'Success' and return the updated progress.
|
|
15586
15638
|
*/ async complete() {
|
|
15587
|
-
const e = await __PRIVATE_localStoreApplyBundledDocuments(this.localStore, new __PRIVATE_BundleConverterImpl(this.serializer), this.documents, this.
|
|
15639
|
+
const e = await __PRIVATE_localStoreApplyBundledDocuments(this.localStore, new __PRIVATE_BundleConverterImpl(this.serializer), this.documents, this.ia.id), t = this.oa(this.documents);
|
|
15588
15640
|
for (const e of this.queries) await __PRIVATE_localStoreSaveNamedQuery(this.localStore, e, t.get(e.name));
|
|
15589
15641
|
return this.progress.taskState = "Success", {
|
|
15590
15642
|
progress: this.progress,
|
|
15591
|
-
|
|
15592
|
-
|
|
15643
|
+
_a: this.collectionGroups,
|
|
15644
|
+
aa: e
|
|
15593
15645
|
};
|
|
15594
15646
|
}
|
|
15595
15647
|
}
|
|
@@ -15647,7 +15699,7 @@ class __PRIVATE_RemovedLimboDocument {
|
|
|
15647
15699
|
constructor(e,
|
|
15648
15700
|
/** Documents included in the remote target */
|
|
15649
15701
|
t) {
|
|
15650
|
-
this.query = e, this.
|
|
15702
|
+
this.query = e, this.ua = t, this.ca = null, this.hasCachedResults = !1,
|
|
15651
15703
|
/**
|
|
15652
15704
|
* A flag whether the view is current with the backend. A view is considered
|
|
15653
15705
|
* current after it has seen the current flag from the backend and did not
|
|
@@ -15656,16 +15708,16 @@ class __PRIVATE_RemovedLimboDocument {
|
|
|
15656
15708
|
*/
|
|
15657
15709
|
this.current = !1,
|
|
15658
15710
|
/** Documents in the view but not in the remote target */
|
|
15659
|
-
this.
|
|
15711
|
+
this.la = __PRIVATE_documentKeySet(),
|
|
15660
15712
|
/** Document Keys that have local changes */
|
|
15661
|
-
this.mutatedKeys = __PRIVATE_documentKeySet(), this.
|
|
15662
|
-
this.
|
|
15713
|
+
this.mutatedKeys = __PRIVATE_documentKeySet(), this.ha = __PRIVATE_newQueryComparator(e),
|
|
15714
|
+
this.Pa = new DocumentSet(this.ha);
|
|
15663
15715
|
}
|
|
15664
15716
|
/**
|
|
15665
15717
|
* The set of remote documents that the server has told us belongs to the target associated with
|
|
15666
15718
|
* this view.
|
|
15667
|
-
*/ get
|
|
15668
|
-
return this.
|
|
15719
|
+
*/ get Ia() {
|
|
15720
|
+
return this.ua;
|
|
15669
15721
|
}
|
|
15670
15722
|
/**
|
|
15671
15723
|
* Iterates over a set of doc changes, applies the query limit, and computes
|
|
@@ -15676,8 +15728,8 @@ class __PRIVATE_RemovedLimboDocument {
|
|
|
15676
15728
|
* @param previousChanges - If this is being called with a refill, then start
|
|
15677
15729
|
* with this set of docs and changes instead of the current view.
|
|
15678
15730
|
* @returns a new set of docs, changes, and refill flag.
|
|
15679
|
-
*/
|
|
15680
|
-
const n = t ? t.
|
|
15731
|
+
*/ Ta(e, t) {
|
|
15732
|
+
const n = t ? t.Ea : new __PRIVATE_DocumentChangeSet, r = t ? t.Pa : this.Pa;
|
|
15681
15733
|
let i = t ? t.mutatedKeys : this.mutatedKeys, s = r, o = !1;
|
|
15682
15734
|
// Track the last doc in a (full) limit. This is necessary, because some
|
|
15683
15735
|
// update (a delete, or an update moving a doc past the old limit) might
|
|
@@ -15700,10 +15752,10 @@ class __PRIVATE_RemovedLimboDocument {
|
|
|
15700
15752
|
u.data.isEqual(c.data) ? l !== h && (n.track({
|
|
15701
15753
|
type: 3 /* ChangeType.Metadata */ ,
|
|
15702
15754
|
doc: c
|
|
15703
|
-
}), P = !0) : this.
|
|
15755
|
+
}), P = !0) : this.da(u, c) || (n.track({
|
|
15704
15756
|
type: 2 /* ChangeType.Modified */ ,
|
|
15705
15757
|
doc: c
|
|
15706
|
-
}), P = !0, (_ && this.
|
|
15758
|
+
}), P = !0, (_ && this.ha(c, _) > 0 || a && this.ha(c, a) < 0) && (
|
|
15707
15759
|
// This doc moved from inside the limit to outside the limit.
|
|
15708
15760
|
// That means there may be some other doc in the local cache
|
|
15709
15761
|
// that should be included instead.
|
|
@@ -15728,13 +15780,13 @@ class __PRIVATE_RemovedLimboDocument {
|
|
|
15728
15780
|
});
|
|
15729
15781
|
}
|
|
15730
15782
|
return {
|
|
15731
|
-
|
|
15732
|
-
|
|
15783
|
+
Pa: s,
|
|
15784
|
+
Ea: n,
|
|
15733
15785
|
Xi: o,
|
|
15734
15786
|
mutatedKeys: i
|
|
15735
15787
|
};
|
|
15736
15788
|
}
|
|
15737
|
-
|
|
15789
|
+
da(e, t) {
|
|
15738
15790
|
// We suppress the initial change event for documents that were modified as
|
|
15739
15791
|
// part of a write acknowledgment (e.g. when the value of a server transform
|
|
15740
15792
|
// is applied) as Watch will send us the same document again.
|
|
@@ -15759,10 +15811,10 @@ class __PRIVATE_RemovedLimboDocument {
|
|
|
15759
15811
|
*/
|
|
15760
15812
|
// PORTING NOTE: The iOS/Android clients always compute limbo document changes.
|
|
15761
15813
|
applyChanges(e, t, n, r) {
|
|
15762
|
-
const i = this.
|
|
15763
|
-
this.
|
|
15814
|
+
const i = this.Pa;
|
|
15815
|
+
this.Pa = e.Pa, this.mutatedKeys = e.mutatedKeys;
|
|
15764
15816
|
// Sort changes based on type and query comparator
|
|
15765
|
-
const s = e.
|
|
15817
|
+
const s = e.Ea.k_();
|
|
15766
15818
|
s.sort(((e, t) => function __PRIVATE_compareChangeType(e, t) {
|
|
15767
15819
|
const order = e => {
|
|
15768
15820
|
switch (e) {
|
|
@@ -15800,70 +15852,70 @@ class __PRIVATE_RemovedLimboDocument {
|
|
|
15800
15852
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15801
15853
|
* See the License for the specific language governing permissions and
|
|
15802
15854
|
* limitations under the License.
|
|
15803
|
-
*/ (e.type, t.type) || this.
|
|
15804
|
-
const o = t && !r ? this.
|
|
15855
|
+
*/ (e.type, t.type) || this.ha(e.doc, t.doc))), this.Aa(n), r = null != r && r;
|
|
15856
|
+
const o = t && !r ? this.Ra() : [], _ = 0 === this.la.size && this.current && !r ? 1 /* SyncState.Synced */ : 0 /* SyncState.Local */ , a = _ !== this.ca;
|
|
15805
15857
|
// We are at synced state if there is no limbo docs are waiting to be resolved, view is current
|
|
15806
15858
|
// with the backend, and the query is not pending to reset due to existence filter mismatch.
|
|
15807
|
-
if (this.
|
|
15859
|
+
if (this.ca = _, 0 !== s.length || a) {
|
|
15808
15860
|
return {
|
|
15809
|
-
snapshot: new ViewSnapshot(this.query, e.
|
|
15861
|
+
snapshot: new ViewSnapshot(this.query, e.Pa, i, s, e.mutatedKeys, 0 /* SyncState.Local */ === _, a,
|
|
15810
15862
|
/* excludesMetadataChanges= */ !1, !!n && n.resumeToken.approximateByteSize() > 0),
|
|
15811
|
-
|
|
15863
|
+
Va: o
|
|
15812
15864
|
};
|
|
15813
15865
|
}
|
|
15814
15866
|
// no changes
|
|
15815
15867
|
return {
|
|
15816
|
-
|
|
15868
|
+
Va: o
|
|
15817
15869
|
};
|
|
15818
15870
|
}
|
|
15819
15871
|
/**
|
|
15820
15872
|
* Applies an OnlineState change to the view, potentially generating a
|
|
15821
15873
|
* ViewChange if the view's syncState changes as a result.
|
|
15822
|
-
*/
|
|
15874
|
+
*/ G_(e) {
|
|
15823
15875
|
return this.current && "Offline" /* OnlineState.Offline */ === e ? (
|
|
15824
15876
|
// If we're offline, set `current` to false and then call applyChanges()
|
|
15825
15877
|
// to refresh our syncState and generate a ViewChange as appropriate. We
|
|
15826
15878
|
// are guaranteed to get a new TargetChange that sets `current` back to
|
|
15827
15879
|
// true once the client is back online.
|
|
15828
15880
|
this.current = !1, this.applyChanges({
|
|
15829
|
-
|
|
15830
|
-
|
|
15881
|
+
Pa: this.Pa,
|
|
15882
|
+
Ea: new __PRIVATE_DocumentChangeSet,
|
|
15831
15883
|
mutatedKeys: this.mutatedKeys,
|
|
15832
15884
|
Xi: !1
|
|
15833
15885
|
},
|
|
15834
15886
|
/* limboResolutionEnabled= */ !1)) : {
|
|
15835
|
-
|
|
15887
|
+
Va: []
|
|
15836
15888
|
};
|
|
15837
15889
|
}
|
|
15838
15890
|
/**
|
|
15839
15891
|
* Returns whether the doc for the given key should be in limbo.
|
|
15840
|
-
*/
|
|
15892
|
+
*/ ma(e) {
|
|
15841
15893
|
// If the remote end says it's part of this query, it's not in limbo.
|
|
15842
|
-
return !this.
|
|
15894
|
+
return !this.ua.has(e) && (
|
|
15843
15895
|
// The local store doesn't think it's a result, so it shouldn't be in limbo.
|
|
15844
|
-
!!this.
|
|
15896
|
+
!!this.Pa.has(e) && !this.Pa.get(e).hasLocalMutations);
|
|
15845
15897
|
}
|
|
15846
15898
|
/**
|
|
15847
15899
|
* Updates syncedDocuments, current, and limbo docs based on the given change.
|
|
15848
15900
|
* Returns the list of changes to which docs are in limbo.
|
|
15849
|
-
*/
|
|
15850
|
-
e && (e.addedDocuments.forEach((e => this.
|
|
15851
|
-
e.removedDocuments.forEach((e => this.
|
|
15901
|
+
*/ Aa(e) {
|
|
15902
|
+
e && (e.addedDocuments.forEach((e => this.ua = this.ua.add(e))), e.modifiedDocuments.forEach((e => {})),
|
|
15903
|
+
e.removedDocuments.forEach((e => this.ua = this.ua.delete(e))), this.current = e.current);
|
|
15852
15904
|
}
|
|
15853
|
-
|
|
15905
|
+
Ra() {
|
|
15854
15906
|
// We can only determine limbo documents when we're in-sync with the server.
|
|
15855
15907
|
if (!this.current) return [];
|
|
15856
15908
|
// TODO(klimt): Do this incrementally so that it's not quadratic when
|
|
15857
15909
|
// updating many documents.
|
|
15858
|
-
const e = this.
|
|
15859
|
-
this.
|
|
15860
|
-
this.
|
|
15910
|
+
const e = this.la;
|
|
15911
|
+
this.la = __PRIVATE_documentKeySet(), this.Pa.forEach((e => {
|
|
15912
|
+
this.ma(e.key) && (this.la = this.la.add(e.key));
|
|
15861
15913
|
}));
|
|
15862
15914
|
// Diff the new limbo docs with the old limbo docs.
|
|
15863
15915
|
const t = [];
|
|
15864
15916
|
return e.forEach((e => {
|
|
15865
|
-
this.
|
|
15866
|
-
})), this.
|
|
15917
|
+
this.la.has(e) || t.push(new __PRIVATE_RemovedLimboDocument(e));
|
|
15918
|
+
})), this.la.forEach((n => {
|
|
15867
15919
|
e.has(n) || t.push(new __PRIVATE_AddedLimboDocument(n));
|
|
15868
15920
|
})), t;
|
|
15869
15921
|
}
|
|
@@ -15887,9 +15939,9 @@ class __PRIVATE_RemovedLimboDocument {
|
|
|
15887
15939
|
* @returns The ViewChange that resulted from this synchronization.
|
|
15888
15940
|
*/
|
|
15889
15941
|
// PORTING NOTE: Multi-tab only.
|
|
15890
|
-
|
|
15891
|
-
this.
|
|
15892
|
-
const t = this.
|
|
15942
|
+
fa(e) {
|
|
15943
|
+
this.ua = e.hs, this.la = __PRIVATE_documentKeySet();
|
|
15944
|
+
const t = this.Ta(e.documents);
|
|
15893
15945
|
return this.applyChanges(t, /* limboResolutionEnabled= */ !0);
|
|
15894
15946
|
}
|
|
15895
15947
|
/**
|
|
@@ -15898,8 +15950,8 @@ class __PRIVATE_RemovedLimboDocument {
|
|
|
15898
15950
|
* `hasPendingWrites` status of the already established view.
|
|
15899
15951
|
*/
|
|
15900
15952
|
// PORTING NOTE: Multi-tab only.
|
|
15901
|
-
|
|
15902
|
-
return ViewSnapshot.fromInitialDocuments(this.query, this.
|
|
15953
|
+
ga() {
|
|
15954
|
+
return ViewSnapshot.fromInitialDocuments(this.query, this.Pa, this.mutatedKeys, 0 /* SyncState.Local */ === this.ca, this.hasCachedResults);
|
|
15903
15955
|
}
|
|
15904
15956
|
}
|
|
15905
15957
|
|
|
@@ -15938,7 +15990,7 @@ class __PRIVATE_QueryView {
|
|
|
15938
15990
|
* decide whether it needs to manufacture a delete event for the target once
|
|
15939
15991
|
* the target is CURRENT.
|
|
15940
15992
|
*/
|
|
15941
|
-
this.
|
|
15993
|
+
this.pa = !1;
|
|
15942
15994
|
}
|
|
15943
15995
|
}
|
|
15944
15996
|
|
|
@@ -15959,8 +16011,8 @@ class __PRIVATE_QueryView {
|
|
|
15959
16011
|
// PORTING NOTE: Manages state synchronization in multi-tab environments.
|
|
15960
16012
|
r, i, s) {
|
|
15961
16013
|
this.localStore = e, this.remoteStore = t, this.eventManager = n, this.sharedClientState = r,
|
|
15962
|
-
this.currentUser = i, this.maxConcurrentLimboResolutions = s, this.
|
|
15963
|
-
this.
|
|
16014
|
+
this.currentUser = i, this.maxConcurrentLimboResolutions = s, this.ya = {}, this.wa = new ObjectMap((e => __PRIVATE_canonifyQuery(e)), __PRIVATE_queryEquals),
|
|
16015
|
+
this.Sa = new Map,
|
|
15964
16016
|
/**
|
|
15965
16017
|
* The keys of documents that are in limbo for which we haven't yet started a
|
|
15966
16018
|
* limbo resolution query. The strings in this set are the result of calling
|
|
@@ -15970,28 +16022,28 @@ class __PRIVATE_QueryView {
|
|
|
15970
16022
|
* of arbitrary elements and it also maintains insertion order, providing the
|
|
15971
16023
|
* desired queue-like FIFO semantics.
|
|
15972
16024
|
*/
|
|
15973
|
-
this.
|
|
16025
|
+
this.ba = new Set,
|
|
15974
16026
|
/**
|
|
15975
16027
|
* Keeps track of the target ID for each document that is in limbo with an
|
|
15976
16028
|
* active target.
|
|
15977
16029
|
*/
|
|
15978
|
-
this.
|
|
16030
|
+
this.Da = new SortedMap(DocumentKey.comparator),
|
|
15979
16031
|
/**
|
|
15980
16032
|
* Keeps track of the information about an active limbo resolution for each
|
|
15981
16033
|
* active target ID that was started for the purpose of limbo resolution.
|
|
15982
16034
|
*/
|
|
15983
|
-
this.
|
|
16035
|
+
this.Ca = new Map, this.va = new __PRIVATE_ReferenceSet,
|
|
15984
16036
|
/** Stores user completion handlers, indexed by User and BatchId. */
|
|
15985
|
-
this.
|
|
16037
|
+
this.Fa = {},
|
|
15986
16038
|
/** Stores user callbacks waiting for all pending writes to be acknowledged. */
|
|
15987
|
-
this.
|
|
16039
|
+
this.Ma = new Map, this.xa = __PRIVATE_TargetIdGenerator.Ln(), this.onlineState = "Unknown" /* OnlineState.Unknown */ ,
|
|
15988
16040
|
// The primary state is set to `true` or `false` immediately after Firestore
|
|
15989
16041
|
// startup. In the interim, a client should only be considered primary if
|
|
15990
16042
|
// `isPrimary` is true.
|
|
15991
|
-
this.
|
|
16043
|
+
this.Oa = void 0;
|
|
15992
16044
|
}
|
|
15993
16045
|
get isPrimaryClient() {
|
|
15994
|
-
return !0 === this.
|
|
16046
|
+
return !0 === this.Oa;
|
|
15995
16047
|
}
|
|
15996
16048
|
}
|
|
15997
16049
|
|
|
@@ -16000,23 +16052,33 @@ class __PRIVATE_QueryView {
|
|
|
16000
16052
|
* server. All the subsequent view snapshots or errors are sent to the
|
|
16001
16053
|
* subscribed handlers. Returns the initial snapshot.
|
|
16002
16054
|
*/
|
|
16003
|
-
async function __PRIVATE_syncEngineListen(e, t) {
|
|
16004
|
-
const
|
|
16005
|
-
let
|
|
16006
|
-
const s =
|
|
16007
|
-
|
|
16055
|
+
async function __PRIVATE_syncEngineListen(e, t, n = !0) {
|
|
16056
|
+
const r = __PRIVATE_ensureWatchCallbacks(e);
|
|
16057
|
+
let i;
|
|
16058
|
+
const s = r.wa.get(t);
|
|
16059
|
+
return s ? (
|
|
16008
16060
|
// PORTING NOTE: With Multi-Tab Web, it is possible that a query view
|
|
16009
16061
|
// already exists when EventManager calls us for the first time. This
|
|
16010
16062
|
// happens when the primary tab is already listening to this query on
|
|
16011
16063
|
// behalf of another tab and the user of the primary also starts listening
|
|
16012
16064
|
// to the query. EventManager will not have an assigned target ID in this
|
|
16013
16065
|
// case and calls `listen` to obtain this ID.
|
|
16014
|
-
r
|
|
16015
|
-
|
|
16016
|
-
|
|
16017
|
-
|
|
16018
|
-
|
|
16019
|
-
|
|
16066
|
+
r.sharedClientState.addLocalQueryTarget(s.targetId), i = s.view.ga()) : i = await __PRIVATE_allocateTargetAndMaybeListen(r, t, n,
|
|
16067
|
+
/** shouldInitializeView= */ !0), i;
|
|
16068
|
+
}
|
|
16069
|
+
|
|
16070
|
+
/** Query has been listening to the cache, and tries to initiate the remote store listen */ async function __PRIVATE_triggerRemoteStoreListen(e, t) {
|
|
16071
|
+
const n = __PRIVATE_ensureWatchCallbacks(e);
|
|
16072
|
+
await __PRIVATE_allocateTargetAndMaybeListen(n, t,
|
|
16073
|
+
/** shouldListenToRemote= */ !0,
|
|
16074
|
+
/** shouldInitializeView= */ !1);
|
|
16075
|
+
}
|
|
16076
|
+
|
|
16077
|
+
async function __PRIVATE_allocateTargetAndMaybeListen(e, t, n, r) {
|
|
16078
|
+
const i = await __PRIVATE_localStoreAllocateTarget(e.localStore, __PRIVATE_queryToTarget(t)), s = i.targetId, o = n ? e.sharedClientState.addLocalQueryTarget(s) : "not-current";
|
|
16079
|
+
let _;
|
|
16080
|
+
return r && (_ = await __PRIVATE_initializeViewAndComputeSnapshot(e, t, s, "current" === o, i.resumeToken)),
|
|
16081
|
+
e.isPrimaryClient && n && __PRIVATE_remoteStoreListen(e.remoteStore, i), _;
|
|
16020
16082
|
}
|
|
16021
16083
|
|
|
16022
16084
|
/**
|
|
@@ -16026,44 +16088,52 @@ async function __PRIVATE_syncEngineListen(e, t) {
|
|
|
16026
16088
|
// PORTING NOTE: On Web only, we inject the code that registers new Limbo
|
|
16027
16089
|
// targets based on view changes. This allows us to only depend on Limbo
|
|
16028
16090
|
// changes when user code includes queries.
|
|
16029
|
-
e.
|
|
16030
|
-
let i = t.view.
|
|
16091
|
+
e.Na = (t, n, r) => async function __PRIVATE_applyDocChanges(e, t, n, r) {
|
|
16092
|
+
let i = t.view.Ta(n);
|
|
16031
16093
|
i.Xi && (
|
|
16032
16094
|
// The query has a limit and some docs were removed, so we need
|
|
16033
16095
|
// to re-run the query against the local store to make sure we
|
|
16034
16096
|
// didn't lose any good docs that had been past the limit.
|
|
16035
16097
|
i = await __PRIVATE_localStoreExecuteQuery(e.localStore, t.query,
|
|
16036
|
-
/* usePreviousResults= */ !1).then((({documents: e}) => t.view.
|
|
16098
|
+
/* usePreviousResults= */ !1).then((({documents: e}) => t.view.Ta(e, i))));
|
|
16037
16099
|
const s = r && r.targetChanges.get(t.targetId), o = r && null != r.targetMismatches.get(t.targetId), _ = t.view.applyChanges(i,
|
|
16038
16100
|
/* limboResolutionEnabled= */ e.isPrimaryClient, s, o);
|
|
16039
|
-
return __PRIVATE_updateTrackedLimbos(e, t.targetId, _.
|
|
16101
|
+
return __PRIVATE_updateTrackedLimbos(e, t.targetId, _.Va), _.snapshot;
|
|
16040
16102
|
}(e, t, n, r);
|
|
16041
16103
|
const s = await __PRIVATE_localStoreExecuteQuery(e.localStore, t,
|
|
16042
|
-
/* usePreviousResults= */ !0), o = new __PRIVATE_View(t, s.hs), _ = o.
|
|
16104
|
+
/* usePreviousResults= */ !0), o = new __PRIVATE_View(t, s.hs), _ = o.Ta(s.documents), a = TargetChange.createSynthesizedTargetChangeForCurrentChange(n, r && "Offline" /* OnlineState.Offline */ !== e.onlineState, i), u = o.applyChanges(_,
|
|
16043
16105
|
/* limboResolutionEnabled= */ e.isPrimaryClient, a);
|
|
16044
|
-
__PRIVATE_updateTrackedLimbos(e, n, u.
|
|
16106
|
+
__PRIVATE_updateTrackedLimbos(e, n, u.Va);
|
|
16045
16107
|
const c = new __PRIVATE_QueryView(t, n, o);
|
|
16046
|
-
return e.
|
|
16108
|
+
return e.wa.set(t, c), e.Sa.has(n) ? e.Sa.get(n).push(t) : e.Sa.set(n, [ t ]), u.snapshot;
|
|
16047
16109
|
}
|
|
16048
16110
|
|
|
16049
|
-
/** Stops listening to the query. */ async function __PRIVATE_syncEngineUnlisten(e, t) {
|
|
16050
|
-
const
|
|
16051
|
-
if (
|
|
16052
|
-
void
|
|
16111
|
+
/** Stops listening to the query. */ async function __PRIVATE_syncEngineUnlisten(e, t, n) {
|
|
16112
|
+
const r = __PRIVATE_debugCast(e), i = r.wa.get(t), s = r.Sa.get(i.targetId);
|
|
16113
|
+
if (s.length > 1) return r.Sa.set(i.targetId, s.filter((e => !__PRIVATE_queryEquals(e, t)))),
|
|
16114
|
+
void r.wa.delete(t);
|
|
16053
16115
|
// No other queries are mapped to the target, clean up the query and the target.
|
|
16054
|
-
if (
|
|
16116
|
+
if (r.isPrimaryClient) {
|
|
16055
16117
|
// We need to remove the local query target first to allow us to verify
|
|
16056
16118
|
// whether any other client is still interested in this target.
|
|
16057
|
-
|
|
16058
|
-
|
|
16119
|
+
r.sharedClientState.removeLocalQueryTarget(i.targetId);
|
|
16120
|
+
r.sharedClientState.isActiveQueryTarget(i.targetId) || await __PRIVATE_localStoreReleaseTarget(r.localStore, i.targetId,
|
|
16059
16121
|
/*keepPersistedTargetData=*/ !1).then((() => {
|
|
16060
|
-
|
|
16061
|
-
__PRIVATE_removeAndCleanupTarget(
|
|
16122
|
+
r.sharedClientState.clearQueryState(i.targetId), n && __PRIVATE_remoteStoreUnlisten(r.remoteStore, i.targetId),
|
|
16123
|
+
__PRIVATE_removeAndCleanupTarget(r, i.targetId);
|
|
16062
16124
|
})).catch(__PRIVATE_ignoreIfPrimaryLeaseLoss);
|
|
16063
|
-
} else __PRIVATE_removeAndCleanupTarget(
|
|
16125
|
+
} else __PRIVATE_removeAndCleanupTarget(r, i.targetId), await __PRIVATE_localStoreReleaseTarget(r.localStore, i.targetId,
|
|
16064
16126
|
/*keepPersistedTargetData=*/ !0);
|
|
16065
16127
|
}
|
|
16066
16128
|
|
|
16129
|
+
/** Unlistens to the remote store while still listening to the cache. */ async function __PRIVATE_triggerRemoteStoreUnlisten(e, t) {
|
|
16130
|
+
const n = __PRIVATE_debugCast(e), r = n.wa.get(t), i = n.Sa.get(r.targetId);
|
|
16131
|
+
n.isPrimaryClient && 1 === i.length && (
|
|
16132
|
+
// PORTING NOTE: Unregister the target ID with local Firestore client as
|
|
16133
|
+
// watch target.
|
|
16134
|
+
n.sharedClientState.removeLocalQueryTarget(r.targetId), __PRIVATE_remoteStoreUnlisten(n.remoteStore, r.targetId));
|
|
16135
|
+
}
|
|
16136
|
+
|
|
16067
16137
|
/**
|
|
16068
16138
|
* Initiates the write of local mutation batch which involves adding the
|
|
16069
16139
|
* writes to the mutation queue, notifying the remote store about new
|
|
@@ -16119,9 +16189,9 @@ async function __PRIVATE_syncEngineListen(e, t) {
|
|
|
16119
16189
|
})));
|
|
16120
16190
|
}(r.localStore, t);
|
|
16121
16191
|
r.sharedClientState.addPendingMutation(e.batchId), function __PRIVATE_addMutationCallback(e, t, n) {
|
|
16122
|
-
let r = e.
|
|
16192
|
+
let r = e.Fa[e.currentUser.toKey()];
|
|
16123
16193
|
r || (r = new SortedMap(__PRIVATE_primitiveComparator));
|
|
16124
|
-
r = r.insert(t, n), e.
|
|
16194
|
+
r = r.insert(t, n), e.Fa[e.currentUser.toKey()] = r;
|
|
16125
16195
|
}
|
|
16126
16196
|
/**
|
|
16127
16197
|
* Resolves or rejects the user callback for the given batch and then discards
|
|
@@ -16146,13 +16216,13 @@ async function __PRIVATE_syncEngineListen(e, t) {
|
|
|
16146
16216
|
const e = await __PRIVATE_localStoreApplyRemoteEventToLocalCache(n.localStore, t);
|
|
16147
16217
|
// Update `receivedDocument` as appropriate for any limbo targets.
|
|
16148
16218
|
t.targetChanges.forEach(((e, t) => {
|
|
16149
|
-
const r = n.
|
|
16219
|
+
const r = n.Ca.get(t);
|
|
16150
16220
|
r && (
|
|
16151
16221
|
// Since this is a limbo resolution lookup, it's for a single document
|
|
16152
16222
|
// and it could be added, modified, or removed, but not a combination.
|
|
16153
16223
|
__PRIVATE_hardAssert(e.addedDocuments.size + e.modifiedDocuments.size + e.removedDocuments.size <= 1),
|
|
16154
|
-
e.addedDocuments.size > 0 ? r.
|
|
16155
|
-
r.
|
|
16224
|
+
e.addedDocuments.size > 0 ? r.pa = !0 : e.modifiedDocuments.size > 0 ? __PRIVATE_hardAssert(r.pa) : e.removedDocuments.size > 0 && (__PRIVATE_hardAssert(r.pa),
|
|
16225
|
+
r.pa = !1));
|
|
16156
16226
|
})), await __PRIVATE_syncEngineEmitNewSnapsAndNotifyLocalStore(n, e, t);
|
|
16157
16227
|
} catch (e) {
|
|
16158
16228
|
await __PRIVATE_ignoreIfPrimaryLeaseLoss(e);
|
|
@@ -16170,8 +16240,8 @@ async function __PRIVATE_syncEngineListen(e, t) {
|
|
|
16170
16240
|
// SharedClientState.
|
|
16171
16241
|
if (r.isPrimaryClient && 0 /* OnlineStateSource.RemoteStore */ === n || !r.isPrimaryClient && 1 /* OnlineStateSource.SharedClientState */ === n) {
|
|
16172
16242
|
const e = [];
|
|
16173
|
-
r.
|
|
16174
|
-
const i = r.view.
|
|
16243
|
+
r.wa.forEach(((n, r) => {
|
|
16244
|
+
const i = r.view.G_(t);
|
|
16175
16245
|
i.snapshot && e.push(i.snapshot);
|
|
16176
16246
|
})), function __PRIVATE_eventManagerOnOnlineStateChange(e, t) {
|
|
16177
16247
|
const n = __PRIVATE_debugCast(e);
|
|
@@ -16180,9 +16250,9 @@ async function __PRIVATE_syncEngineListen(e, t) {
|
|
|
16180
16250
|
n.queries.forEach(((e, n) => {
|
|
16181
16251
|
for (const e of n.Q_)
|
|
16182
16252
|
// Run global snapshot listeners if a consistent snapshot has been emitted.
|
|
16183
|
-
e.
|
|
16253
|
+
e.G_(t) && (r = !0);
|
|
16184
16254
|
})), r && __PRIVATE_raiseSnapshotsInSyncEvent(n);
|
|
16185
|
-
}(r.eventManager, t), e.length && r.
|
|
16255
|
+
}(r.eventManager, t), e.length && r.ya.u_(e), r.onlineState = t, r.isPrimaryClient && r.sharedClientState.setOnlineState(t);
|
|
16186
16256
|
}
|
|
16187
16257
|
}
|
|
16188
16258
|
|
|
@@ -16200,7 +16270,7 @@ async function __PRIVATE_syncEngineListen(e, t) {
|
|
|
16200
16270
|
const r = __PRIVATE_debugCast(e);
|
|
16201
16271
|
// PORTING NOTE: Multi-tab only.
|
|
16202
16272
|
r.sharedClientState.updateQueryState(t, "rejected", n);
|
|
16203
|
-
const i = r.
|
|
16273
|
+
const i = r.Ca.get(t), s = i && i.key;
|
|
16204
16274
|
if (s) {
|
|
16205
16275
|
// TODO(klimt): We really only should do the following on permission
|
|
16206
16276
|
// denied errors, but we don't have the cause code here.
|
|
@@ -16222,7 +16292,7 @@ async function __PRIVATE_syncEngineListen(e, t) {
|
|
|
16222
16292
|
// RemoteEvent. If `applyRemoteEvent()` throws, we want to re-listen to
|
|
16223
16293
|
// this query when the RemoteStore restarts the Watch stream, which should
|
|
16224
16294
|
// re-trigger the target failure.
|
|
16225
|
-
r.
|
|
16295
|
+
r.Da = r.Da.remove(s), r.Ca.delete(t), __PRIVATE_pumpEnqueuedLimboResolutions(r);
|
|
16226
16296
|
} else await __PRIVATE_localStoreReleaseTarget(r.localStore, t,
|
|
16227
16297
|
/* keepPersistedTargetData */ !1).then((() => __PRIVATE_removeAndCleanupTarget(r, t, n))).catch(__PRIVATE_ignoreIfPrimaryLeaseLoss);
|
|
16228
16298
|
}
|
|
@@ -16284,8 +16354,8 @@ async function __PRIVATE_syncEngineRejectFailedWrite(e, t, n) {
|
|
|
16284
16354
|
if (-1 === e)
|
|
16285
16355
|
// Trigger the callback right away if there is no pending writes at the moment.
|
|
16286
16356
|
return void t.resolve();
|
|
16287
|
-
const r = n.
|
|
16288
|
-
r.push(t), n.
|
|
16357
|
+
const r = n.Ma.get(e) || [];
|
|
16358
|
+
r.push(t), n.Ma.set(e, r);
|
|
16289
16359
|
} catch (e) {
|
|
16290
16360
|
const n = __PRIVATE_wrapInUserErrorIfRecoverable(e, "Initialization of waitForPendingWrites() operation failed");
|
|
16291
16361
|
t.reject(n);
|
|
@@ -16296,28 +16366,28 @@ async function __PRIVATE_syncEngineRejectFailedWrite(e, t, n) {
|
|
|
16296
16366
|
* Triggers the callbacks that are waiting for this batch id to get acknowledged by server,
|
|
16297
16367
|
* if there are any.
|
|
16298
16368
|
*/ function __PRIVATE_triggerPendingWritesCallbacks(e, t) {
|
|
16299
|
-
(e.
|
|
16369
|
+
(e.Ma.get(t) || []).forEach((e => {
|
|
16300
16370
|
e.resolve();
|
|
16301
|
-
})), e.
|
|
16371
|
+
})), e.Ma.delete(t);
|
|
16302
16372
|
}
|
|
16303
16373
|
|
|
16304
16374
|
/** Reject all outstanding callbacks waiting for pending writes to complete. */ function __PRIVATE_processUserCallback(e, t, n) {
|
|
16305
16375
|
const r = __PRIVATE_debugCast(e);
|
|
16306
|
-
let i = r.
|
|
16376
|
+
let i = r.Fa[r.currentUser.toKey()];
|
|
16307
16377
|
// NOTE: Mutations restored from persistence won't have callbacks, so it's
|
|
16308
16378
|
// okay for there to be no callback for this ID.
|
|
16309
16379
|
if (i) {
|
|
16310
16380
|
const e = i.get(t);
|
|
16311
|
-
e && (n ? e.reject(n) : e.resolve(), i = i.remove(t)), r.
|
|
16381
|
+
e && (n ? e.reject(n) : e.resolve(), i = i.remove(t)), r.Fa[r.currentUser.toKey()] = i;
|
|
16312
16382
|
}
|
|
16313
16383
|
}
|
|
16314
16384
|
|
|
16315
16385
|
function __PRIVATE_removeAndCleanupTarget(e, t, n = null) {
|
|
16316
16386
|
e.sharedClientState.removeLocalQueryTarget(t);
|
|
16317
|
-
for (const r of e.
|
|
16318
|
-
if (e.
|
|
16319
|
-
e.
|
|
16320
|
-
e.
|
|
16387
|
+
for (const r of e.Sa.get(t)) e.wa.delete(r), n && e.ya.La(r, n);
|
|
16388
|
+
if (e.Sa.delete(t), e.isPrimaryClient) {
|
|
16389
|
+
e.va.Vr(t).forEach((t => {
|
|
16390
|
+
e.va.containsKey(t) ||
|
|
16321
16391
|
// We removed the last reference for this key
|
|
16322
16392
|
__PRIVATE_removeLimboTarget(e, t);
|
|
16323
16393
|
}));
|
|
@@ -16325,19 +16395,19 @@ function __PRIVATE_removeAndCleanupTarget(e, t, n = null) {
|
|
|
16325
16395
|
}
|
|
16326
16396
|
|
|
16327
16397
|
function __PRIVATE_removeLimboTarget(e, t) {
|
|
16328
|
-
e.
|
|
16398
|
+
e.ba.delete(t.path.canonicalString());
|
|
16329
16399
|
// It's possible that the target already got removed because the query failed. In that case,
|
|
16330
16400
|
// the key won't exist in `limboTargetsByKey`. Only do the cleanup if we still have the target.
|
|
16331
|
-
const n = e.
|
|
16332
|
-
null !== n && (__PRIVATE_remoteStoreUnlisten(e.remoteStore, n), e.
|
|
16333
|
-
e.
|
|
16401
|
+
const n = e.Da.get(t);
|
|
16402
|
+
null !== n && (__PRIVATE_remoteStoreUnlisten(e.remoteStore, n), e.Da = e.Da.remove(t),
|
|
16403
|
+
e.Ca.delete(n), __PRIVATE_pumpEnqueuedLimboResolutions(e));
|
|
16334
16404
|
}
|
|
16335
16405
|
|
|
16336
16406
|
function __PRIVATE_updateTrackedLimbos(e, t, n) {
|
|
16337
|
-
for (const r of n) if (r instanceof __PRIVATE_AddedLimboDocument) e.
|
|
16407
|
+
for (const r of n) if (r instanceof __PRIVATE_AddedLimboDocument) e.va.addReference(r.key, t),
|
|
16338
16408
|
__PRIVATE_trackLimboChange(e, r); else if (r instanceof __PRIVATE_RemovedLimboDocument) {
|
|
16339
|
-
__PRIVATE_logDebug("SyncEngine", "Document no longer in limbo: " + r.key), e.
|
|
16340
|
-
e.
|
|
16409
|
+
__PRIVATE_logDebug("SyncEngine", "Document no longer in limbo: " + r.key), e.va.removeReference(r.key, t);
|
|
16410
|
+
e.va.containsKey(r.key) ||
|
|
16341
16411
|
// We removed the last reference for this key
|
|
16342
16412
|
__PRIVATE_removeLimboTarget(e, r.key);
|
|
16343
16413
|
} else fail();
|
|
@@ -16345,8 +16415,8 @@ function __PRIVATE_updateTrackedLimbos(e, t, n) {
|
|
|
16345
16415
|
|
|
16346
16416
|
function __PRIVATE_trackLimboChange(e, t) {
|
|
16347
16417
|
const n = t.key, r = n.path.canonicalString();
|
|
16348
|
-
e.
|
|
16349
|
-
e.
|
|
16418
|
+
e.Da.get(n) || e.ba.has(r) || (__PRIVATE_logDebug("SyncEngine", "New document in limbo: " + n),
|
|
16419
|
+
e.ba.add(r), __PRIVATE_pumpEnqueuedLimboResolutions(e));
|
|
16350
16420
|
}
|
|
16351
16421
|
|
|
16352
16422
|
/**
|
|
@@ -16357,18 +16427,18 @@ function __PRIVATE_trackLimboChange(e, t) {
|
|
|
16357
16427
|
* with "resource exhausted" errors which can lead to pathological client
|
|
16358
16428
|
* behavior as seen in https://github.com/firebase/firebase-js-sdk/issues/2683.
|
|
16359
16429
|
*/ function __PRIVATE_pumpEnqueuedLimboResolutions(e) {
|
|
16360
|
-
for (;e.
|
|
16361
|
-
const t = e.
|
|
16362
|
-
e.
|
|
16363
|
-
const n = new DocumentKey(ResourcePath.fromString(t)), r = e.
|
|
16364
|
-
e.
|
|
16430
|
+
for (;e.ba.size > 0 && e.Da.size < e.maxConcurrentLimboResolutions; ) {
|
|
16431
|
+
const t = e.ba.values().next().value;
|
|
16432
|
+
e.ba.delete(t);
|
|
16433
|
+
const n = new DocumentKey(ResourcePath.fromString(t)), r = e.xa.next();
|
|
16434
|
+
e.Ca.set(r, new LimboResolution(n)), e.Da = e.Da.insert(n, r), __PRIVATE_remoteStoreListen(e.remoteStore, new TargetData(__PRIVATE_queryToTarget(__PRIVATE_newQueryForPath(n.path)), r, "TargetPurposeLimboResolution" /* TargetPurpose.LimboResolution */ , __PRIVATE_ListenSequence._e));
|
|
16365
16435
|
}
|
|
16366
16436
|
}
|
|
16367
16437
|
|
|
16368
16438
|
async function __PRIVATE_syncEngineEmitNewSnapsAndNotifyLocalStore(e, t, n) {
|
|
16369
16439
|
const r = __PRIVATE_debugCast(e), i = [], s = [], o = [];
|
|
16370
|
-
r.
|
|
16371
|
-
o.push(r.
|
|
16440
|
+
r.wa.isEmpty() || (r.wa.forEach(((e, _) => {
|
|
16441
|
+
o.push(r.Na(_, t, n).then((e => {
|
|
16372
16442
|
// Update views if there are actual changes.
|
|
16373
16443
|
if (
|
|
16374
16444
|
// If there are changes, or we are handling a global snapshot, notify
|
|
@@ -16380,7 +16450,7 @@ async function __PRIVATE_syncEngineEmitNewSnapsAndNotifyLocalStore(e, t, n) {
|
|
|
16380
16450
|
s.push(t);
|
|
16381
16451
|
}
|
|
16382
16452
|
})));
|
|
16383
|
-
})), await Promise.all(o), r.
|
|
16453
|
+
})), await Promise.all(o), r.ya.u_(i), await async function __PRIVATE_localStoreNotifyLocalViewChanges(e, t) {
|
|
16384
16454
|
const n = __PRIVATE_debugCast(e);
|
|
16385
16455
|
try {
|
|
16386
16456
|
await n.persistence.runTransaction("notifyLocalViewChanges", "readwrite", (e => PersistencePromise.forEach(t, (t => PersistencePromise.forEach(t.qi, (r => n.persistence.referenceDelegate.addReference(e, t.targetId, r))).next((() => PersistencePromise.forEach(t.Qi, (r => n.persistence.referenceDelegate.removeReference(e, t.targetId, r)))))))));
|
|
@@ -16411,11 +16481,11 @@ async function __PRIVATE_syncEngineHandleCredentialChange(e, t) {
|
|
|
16411
16481
|
n.currentUser = t,
|
|
16412
16482
|
// Fails tasks waiting for pending writes requested by previous user.
|
|
16413
16483
|
function __PRIVATE_rejectOutstandingPendingWritesCallbacks(e, t) {
|
|
16414
|
-
e.
|
|
16484
|
+
e.Ma.forEach((e => {
|
|
16415
16485
|
e.forEach((e => {
|
|
16416
16486
|
e.reject(new FirestoreError(D.CANCELLED, t));
|
|
16417
16487
|
}));
|
|
16418
|
-
})), e.
|
|
16488
|
+
})), e.Ma.clear();
|
|
16419
16489
|
}(n, "'waitForPendingWrites' promise is rejected due to a user change."),
|
|
16420
16490
|
// TODO(b/114226417): Consider calling this only in the primary tab.
|
|
16421
16491
|
n.sharedClientState.handleUserChange(t, e.removedBatchIds, e.addedBatchIds), await __PRIVATE_syncEngineEmitNewSnapsAndNotifyLocalStore(n, e.us);
|
|
@@ -16423,15 +16493,15 @@ async function __PRIVATE_syncEngineHandleCredentialChange(e, t) {
|
|
|
16423
16493
|
}
|
|
16424
16494
|
|
|
16425
16495
|
function __PRIVATE_syncEngineGetRemoteKeysForTarget(e, t) {
|
|
16426
|
-
const n = __PRIVATE_debugCast(e), r = n.
|
|
16427
|
-
if (r && r.
|
|
16496
|
+
const n = __PRIVATE_debugCast(e), r = n.Ca.get(t);
|
|
16497
|
+
if (r && r.pa) return __PRIVATE_documentKeySet().add(r.key);
|
|
16428
16498
|
{
|
|
16429
16499
|
let e = __PRIVATE_documentKeySet();
|
|
16430
|
-
const r = n.
|
|
16500
|
+
const r = n.Sa.get(t);
|
|
16431
16501
|
if (!r) return e;
|
|
16432
16502
|
for (const t of r) {
|
|
16433
|
-
const r = n.
|
|
16434
|
-
e = e.unionWith(r.view.
|
|
16503
|
+
const r = n.wa.get(t);
|
|
16504
|
+
e = e.unionWith(r.view.Ia);
|
|
16435
16505
|
}
|
|
16436
16506
|
return e;
|
|
16437
16507
|
}
|
|
@@ -16442,8 +16512,8 @@ function __PRIVATE_syncEngineGetRemoteKeysForTarget(e, t) {
|
|
|
16442
16512
|
* from persistence.
|
|
16443
16513
|
*/ async function __PRIVATE_synchronizeViewAndComputeSnapshot(e, t) {
|
|
16444
16514
|
const n = __PRIVATE_debugCast(e), r = await __PRIVATE_localStoreExecuteQuery(n.localStore, t.query,
|
|
16445
|
-
/* usePreviousResults= */ !0), i = t.view.
|
|
16446
|
-
return n.isPrimaryClient && __PRIVATE_updateTrackedLimbos(n, t.targetId, i.
|
|
16515
|
+
/* usePreviousResults= */ !0), i = t.view.fa(r);
|
|
16516
|
+
return n.isPrimaryClient && __PRIVATE_updateTrackedLimbos(n, t.targetId, i.Va),
|
|
16447
16517
|
i;
|
|
16448
16518
|
}
|
|
16449
16519
|
|
|
@@ -16494,7 +16564,7 @@ async function __PRIVATE_syncEngineApplyBatchState(e, t, n, r) {
|
|
|
16494
16564
|
async function __PRIVATE_syncEngineApplyPrimaryState(e, t) {
|
|
16495
16565
|
const n = __PRIVATE_debugCast(e);
|
|
16496
16566
|
if (__PRIVATE_ensureWatchCallbacks(n), __PRIVATE_syncEngineEnsureWriteCallbacks(n),
|
|
16497
|
-
!0 === t && !0 !== n.
|
|
16567
|
+
!0 === t && !0 !== n.Oa) {
|
|
16498
16568
|
// Secondary tabs only maintain Views for their local listeners and the
|
|
16499
16569
|
// Views internal state may not be 100% populated (in particular
|
|
16500
16570
|
// secondary tabs don't track syncedDocuments, the set of documents the
|
|
@@ -16502,12 +16572,12 @@ async function __PRIVATE_syncEngineApplyPrimaryState(e, t) {
|
|
|
16502
16572
|
// primary, we need to need to make sure that all views for all targets
|
|
16503
16573
|
// match the state on disk.
|
|
16504
16574
|
const e = n.sharedClientState.getAllActiveQueryTargets(), t = await __PRIVATE_synchronizeQueryViewsAndRaiseSnapshots(n, e.toArray());
|
|
16505
|
-
n.
|
|
16575
|
+
n.Oa = !0, await __PRIVATE_remoteStoreApplyPrimaryState(n.remoteStore, !0);
|
|
16506
16576
|
for (const e of t) __PRIVATE_remoteStoreListen(n.remoteStore, e);
|
|
16507
|
-
} else if (!1 === t && !1 !== n.
|
|
16577
|
+
} else if (!1 === t && !1 !== n.Oa) {
|
|
16508
16578
|
const e = [];
|
|
16509
16579
|
let t = Promise.resolve();
|
|
16510
|
-
n.
|
|
16580
|
+
n.Sa.forEach(((r, i) => {
|
|
16511
16581
|
n.sharedClientState.isLocalQueryTarget(i) ? e.push(i) : t = t.then((() => (__PRIVATE_removeAndCleanupTarget(n, i),
|
|
16512
16582
|
__PRIVATE_localStoreReleaseTarget(n.localStore, i,
|
|
16513
16583
|
/*keepPersistedTargetData=*/ !0)))), __PRIVATE_remoteStoreUnlisten(n.remoteStore, i);
|
|
@@ -16515,9 +16585,9 @@ async function __PRIVATE_syncEngineApplyPrimaryState(e, t) {
|
|
|
16515
16585
|
// PORTING NOTE: Multi-Tab only.
|
|
16516
16586
|
function __PRIVATE_resetLimboDocuments(e) {
|
|
16517
16587
|
const t = __PRIVATE_debugCast(e);
|
|
16518
|
-
t.
|
|
16588
|
+
t.Ca.forEach(((e, n) => {
|
|
16519
16589
|
__PRIVATE_remoteStoreUnlisten(t.remoteStore, n);
|
|
16520
|
-
})), t.
|
|
16590
|
+
})), t.va.mr(), t.Ca = new Map, t.Da = new SortedMap(DocumentKey.comparator);
|
|
16521
16591
|
}
|
|
16522
16592
|
/**
|
|
16523
16593
|
* Reconcile the query views of the provided query targets with the state from
|
|
@@ -16530,7 +16600,7 @@ async function __PRIVATE_syncEngineApplyPrimaryState(e, t) {
|
|
|
16530
16600
|
* tab to a primary tab
|
|
16531
16601
|
*/
|
|
16532
16602
|
// PORTING NOTE: Multi-Tab only.
|
|
16533
|
-
(n), n.
|
|
16603
|
+
(n), n.Oa = !1, await __PRIVATE_remoteStoreApplyPrimaryState(n.remoteStore, !1);
|
|
16534
16604
|
}
|
|
16535
16605
|
}
|
|
16536
16606
|
|
|
@@ -16538,7 +16608,7 @@ async function __PRIVATE_synchronizeQueryViewsAndRaiseSnapshots(e, t, n) {
|
|
|
16538
16608
|
const r = __PRIVATE_debugCast(e), i = [], s = [];
|
|
16539
16609
|
for (const e of t) {
|
|
16540
16610
|
let t;
|
|
16541
|
-
const n = r.
|
|
16611
|
+
const n = r.Sa.get(e);
|
|
16542
16612
|
if (n && 0 !== n.length) {
|
|
16543
16613
|
// For queries that have a local View, we fetch their current state
|
|
16544
16614
|
// from LocalStore (as the resume token and the snapshot version
|
|
@@ -16546,7 +16616,7 @@ async function __PRIVATE_synchronizeQueryViewsAndRaiseSnapshots(e, t, n) {
|
|
|
16546
16616
|
// state (the list of syncedDocuments may have gotten out of sync).
|
|
16547
16617
|
t = await __PRIVATE_localStoreAllocateTarget(r.localStore, __PRIVATE_queryToTarget(n[0]));
|
|
16548
16618
|
for (const e of n) {
|
|
16549
|
-
const t = r.
|
|
16619
|
+
const t = r.wa.get(e), n = await __PRIVATE_synchronizeViewAndComputeSnapshot(r, t);
|
|
16550
16620
|
n.snapshot && s.push(n.snapshot);
|
|
16551
16621
|
}
|
|
16552
16622
|
} else {
|
|
@@ -16558,7 +16628,7 @@ async function __PRIVATE_synchronizeQueryViewsAndRaiseSnapshots(e, t, n) {
|
|
|
16558
16628
|
}
|
|
16559
16629
|
i.push(t);
|
|
16560
16630
|
}
|
|
16561
|
-
return r.
|
|
16631
|
+
return r.ya.u_(s), i;
|
|
16562
16632
|
}
|
|
16563
16633
|
|
|
16564
16634
|
/**
|
|
@@ -16580,7 +16650,7 @@ function __PRIVATE_synthesizeTargetToQuery(e) {
|
|
|
16580
16650
|
// PORTING NOTE: Multi-Tab only.
|
|
16581
16651
|
function __PRIVATE_syncEngineGetActiveClients(e) {
|
|
16582
16652
|
return function __PRIVATE_localStoreGetActiveClients(e) {
|
|
16583
|
-
return __PRIVATE_debugCast(__PRIVATE_debugCast(e).persistence).
|
|
16653
|
+
return __PRIVATE_debugCast(__PRIVATE_debugCast(e).persistence).Bi();
|
|
16584
16654
|
}(__PRIVATE_debugCast(e).localStore);
|
|
16585
16655
|
}
|
|
16586
16656
|
|
|
@@ -16588,11 +16658,11 @@ function __PRIVATE_syncEngineGetActiveClients(e) {
|
|
|
16588
16658
|
// PORTING NOTE: Multi-Tab only.
|
|
16589
16659
|
async function __PRIVATE_syncEngineApplyTargetState(e, t, n, r) {
|
|
16590
16660
|
const i = __PRIVATE_debugCast(e);
|
|
16591
|
-
if (i.
|
|
16661
|
+
if (i.Oa)
|
|
16592
16662
|
// If we receive a target state notification via WebStorage, we are
|
|
16593
16663
|
// either already secondary or another tab has taken the primary lease.
|
|
16594
16664
|
return void __PRIVATE_logDebug("SyncEngine", "Ignoring unexpected query state notification.");
|
|
16595
|
-
const s = i.
|
|
16665
|
+
const s = i.Sa.get(t);
|
|
16596
16666
|
if (s && s.length > 0) switch (n) {
|
|
16597
16667
|
case "current":
|
|
16598
16668
|
case "not-current":
|
|
@@ -16614,10 +16684,9 @@ async function __PRIVATE_syncEngineApplyTargetState(e, t, n, r) {
|
|
|
16614
16684
|
|
|
16615
16685
|
/** Adds or removes Watch targets for queries from different tabs. */ async function __PRIVATE_syncEngineApplyActiveTargetsChange(e, t, n) {
|
|
16616
16686
|
const r = __PRIVATE_ensureWatchCallbacks(e);
|
|
16617
|
-
if (r.
|
|
16687
|
+
if (r.Oa) {
|
|
16618
16688
|
for (const e of t) {
|
|
16619
|
-
if (r.
|
|
16620
|
-
// A target might have been added in a previous attempt
|
|
16689
|
+
if (r.Sa.has(e) && r.sharedClientState.isActiveQueryTarget(e)) {
|
|
16621
16690
|
__PRIVATE_logDebug("SyncEngine", "Adding an already active target " + e);
|
|
16622
16691
|
continue;
|
|
16623
16692
|
}
|
|
@@ -16628,7 +16697,7 @@ async function __PRIVATE_syncEngineApplyTargetState(e, t, n, r) {
|
|
|
16628
16697
|
for (const e of n)
|
|
16629
16698
|
// Check that the target is still active since the target might have been
|
|
16630
16699
|
// removed if it has been rejected by the backend.
|
|
16631
|
-
r.
|
|
16700
|
+
r.Sa.has(e) &&
|
|
16632
16701
|
// Release queries that are still active.
|
|
16633
16702
|
await __PRIVATE_localStoreReleaseTarget(r.localStore, e,
|
|
16634
16703
|
/* keepPersistedTargetData */ !1).then((() => {
|
|
@@ -16642,7 +16711,7 @@ function __PRIVATE_ensureWatchCallbacks(e) {
|
|
|
16642
16711
|
return t.remoteStore.remoteSyncer.applyRemoteEvent = __PRIVATE_syncEngineApplyRemoteEvent.bind(null, t),
|
|
16643
16712
|
t.remoteStore.remoteSyncer.getRemoteKeysForTarget = __PRIVATE_syncEngineGetRemoteKeysForTarget.bind(null, t),
|
|
16644
16713
|
t.remoteStore.remoteSyncer.rejectListen = __PRIVATE_syncEngineRejectListen.bind(null, t),
|
|
16645
|
-
t.
|
|
16714
|
+
t.ya.u_ = __PRIVATE_eventManagerOnWatchChange.bind(null, t.eventManager), t.ya.La = __PRIVATE_eventManagerOnWatchError.bind(null, t.eventManager),
|
|
16646
16715
|
t;
|
|
16647
16716
|
}
|
|
16648
16717
|
|
|
@@ -16685,13 +16754,13 @@ function __PRIVATE_syncEngineEnsureWriteCallbacks(e) {
|
|
|
16685
16754
|
}(r)), Promise.resolve(new Set);
|
|
16686
16755
|
n._updateProgress(__PRIVATE_bundleInitialProgress(r));
|
|
16687
16756
|
const i = new __PRIVATE_BundleLoader(r, e.localStore, t.serializer);
|
|
16688
|
-
let s = await t.
|
|
16757
|
+
let s = await t.Ba();
|
|
16689
16758
|
for (;s; ) {
|
|
16690
|
-
const e = await i.
|
|
16691
|
-
e && n._updateProgress(e), s = await t.
|
|
16759
|
+
const e = await i.sa(s);
|
|
16760
|
+
e && n._updateProgress(e), s = await t.Ba();
|
|
16692
16761
|
}
|
|
16693
16762
|
const o = await i.complete();
|
|
16694
|
-
return await __PRIVATE_syncEngineEmitNewSnapsAndNotifyLocalStore(e, o.
|
|
16763
|
+
return await __PRIVATE_syncEngineEmitNewSnapsAndNotifyLocalStore(e, o.aa,
|
|
16695
16764
|
/* remoteEvent */ void 0),
|
|
16696
16765
|
// Save metadata, so loading the same bundle will skip.
|
|
16697
16766
|
await function __PRIVATE_localStoreSaveBundle(e, t) {
|
|
@@ -16701,7 +16770,7 @@ function __PRIVATE_syncEngineEnsureWriteCallbacks(e) {
|
|
|
16701
16770
|
/**
|
|
16702
16771
|
* Returns a promise of a `NamedQuery` associated with given query name. Promise
|
|
16703
16772
|
* resolves to undefined if no persisted data can be found.
|
|
16704
|
-
*/ (e.localStore, r), n._completeWith(o.progress), Promise.resolve(o.
|
|
16773
|
+
*/ (e.localStore, r), n._completeWith(o.progress), Promise.resolve(o._a);
|
|
16705
16774
|
} catch (e) {
|
|
16706
16775
|
return __PRIVATE_logWarn("SyncEngine", `Loading bundle failed with ${e}`), n._failWith(e),
|
|
16707
16776
|
Promise.resolve(new Set);
|
|
@@ -16781,12 +16850,12 @@ class __PRIVATE_LruGcMemoryOfflineComponentProvider extends MemoryOfflineCompone
|
|
|
16781
16850
|
* Provides all components needed for Firestore with IndexedDB persistence.
|
|
16782
16851
|
*/ class __PRIVATE_IndexedDbOfflineComponentProvider extends MemoryOfflineComponentProvider {
|
|
16783
16852
|
constructor(e, t, n) {
|
|
16784
|
-
super(), this.
|
|
16853
|
+
super(), this.ka = e, this.cacheSizeBytes = t, this.forceOwnership = n, this.synchronizeTabs = !1;
|
|
16785
16854
|
}
|
|
16786
16855
|
async initialize(e) {
|
|
16787
|
-
await super.initialize(e), await this.
|
|
16856
|
+
await super.initialize(e), await this.ka.initialize(this, e),
|
|
16788
16857
|
// Enqueue writes from a previous session
|
|
16789
|
-
await __PRIVATE_syncEngineEnsureWriteCallbacks(this.
|
|
16858
|
+
await __PRIVATE_syncEngineEnsureWriteCallbacks(this.ka.syncEngine), await __PRIVATE_fillWritePipeline(this.ka.remoteStore),
|
|
16790
16859
|
// NOTE: This will immediately call the listener, so we make sure to
|
|
16791
16860
|
// set it after localStore / remoteStore are started.
|
|
16792
16861
|
await this.persistence.fi((() => (this.gcScheduler && !this.gcScheduler.started && this.gcScheduler.start(),
|
|
@@ -16822,22 +16891,22 @@ class __PRIVATE_LruGcMemoryOfflineComponentProvider extends MemoryOfflineCompone
|
|
|
16822
16891
|
* `synchronizeTabs` will be enabled.
|
|
16823
16892
|
*/ class __PRIVATE_MultiTabOfflineComponentProvider extends __PRIVATE_IndexedDbOfflineComponentProvider {
|
|
16824
16893
|
constructor(e, t) {
|
|
16825
|
-
super(e, t, /* forceOwnership= */ !1), this.
|
|
16894
|
+
super(e, t, /* forceOwnership= */ !1), this.ka = e, this.cacheSizeBytes = t, this.synchronizeTabs = !0;
|
|
16826
16895
|
}
|
|
16827
16896
|
async initialize(e) {
|
|
16828
16897
|
await super.initialize(e);
|
|
16829
|
-
const t = this.
|
|
16898
|
+
const t = this.ka.syncEngine;
|
|
16830
16899
|
this.sharedClientState instanceof __PRIVATE_WebStorageSharedClientState && (this.sharedClientState.syncEngine = {
|
|
16831
16900
|
Zs: __PRIVATE_syncEngineApplyBatchState.bind(null, t),
|
|
16832
16901
|
Xs: __PRIVATE_syncEngineApplyTargetState.bind(null, t),
|
|
16833
16902
|
eo: __PRIVATE_syncEngineApplyActiveTargetsChange.bind(null, t),
|
|
16834
|
-
|
|
16903
|
+
Bi: __PRIVATE_syncEngineGetActiveClients.bind(null, t),
|
|
16835
16904
|
Ys: __PRIVATE_syncEngineSynchronizeWithChangedDocuments.bind(null, t)
|
|
16836
16905
|
}, await this.sharedClientState.start()),
|
|
16837
16906
|
// NOTE: This will immediately call the listener, so we make sure to
|
|
16838
16907
|
// set it after localStore / remoteStore are started.
|
|
16839
16908
|
await this.persistence.fi((async e => {
|
|
16840
|
-
await __PRIVATE_syncEngineApplyPrimaryState(this.
|
|
16909
|
+
await __PRIVATE_syncEngineApplyPrimaryState(this.ka.syncEngine, e), this.gcScheduler && (e && !this.gcScheduler.started ? this.gcScheduler.start() : e || this.gcScheduler.stop()),
|
|
16841
16910
|
this.indexBackfillerScheduler && (e && !this.indexBackfillerScheduler.started ? this.indexBackfillerScheduler.start() : e || this.indexBackfillerScheduler.stop());
|
|
16842
16911
|
}));
|
|
16843
16912
|
}
|
|
@@ -16888,7 +16957,7 @@ class __PRIVATE_LruGcMemoryOfflineComponentProvider extends MemoryOfflineCompone
|
|
|
16888
16957
|
// PORTING NOTE: Manages state synchronization in multi-tab environments.
|
|
16889
16958
|
r, i, s, o) {
|
|
16890
16959
|
const _ = new __PRIVATE_SyncEngineImpl(e, t, n, r, i, s);
|
|
16891
|
-
return o && (_.
|
|
16960
|
+
return o && (_.Oa = !0), _;
|
|
16892
16961
|
}(this.localStore, this.remoteStore, this.eventManager, this.sharedClientState, e.initialUser, e.maxConcurrentLimboResolutions, t);
|
|
16893
16962
|
}
|
|
16894
16963
|
async terminate() {
|
|
@@ -17007,15 +17076,15 @@ class __PRIVATE_AsyncObserver {
|
|
|
17007
17076
|
this.muted = !1;
|
|
17008
17077
|
}
|
|
17009
17078
|
next(e) {
|
|
17010
|
-
this.observer.next && this.
|
|
17079
|
+
this.observer.next && this.qa(this.observer.next, e);
|
|
17011
17080
|
}
|
|
17012
17081
|
error(e) {
|
|
17013
|
-
this.observer.error ? this.
|
|
17082
|
+
this.observer.error ? this.qa(this.observer.error, e) : __PRIVATE_logError("Uncaught Error in snapshot listener:", e.toString());
|
|
17014
17083
|
}
|
|
17015
|
-
|
|
17084
|
+
Qa() {
|
|
17016
17085
|
this.muted = !0;
|
|
17017
17086
|
}
|
|
17018
|
-
|
|
17087
|
+
qa(e, t) {
|
|
17019
17088
|
this.muted || setTimeout((() => {
|
|
17020
17089
|
this.muted || e(t);
|
|
17021
17090
|
}), 0);
|
|
@@ -17047,30 +17116,30 @@ class __PRIVATE_AsyncObserver {
|
|
|
17047
17116
|
constructor(
|
|
17048
17117
|
/** The reader to read from underlying binary bundle data source. */
|
|
17049
17118
|
e, t) {
|
|
17050
|
-
this.
|
|
17119
|
+
this.Ka = e, this.serializer = t,
|
|
17051
17120
|
/** Cached bundle metadata. */
|
|
17052
17121
|
this.metadata = new __PRIVATE_Deferred,
|
|
17053
17122
|
/**
|
|
17054
17123
|
* Internal buffer to hold bundle content, accumulating incomplete element
|
|
17055
17124
|
* content.
|
|
17056
17125
|
*/
|
|
17057
|
-
this.buffer = new Uint8Array, this
|
|
17126
|
+
this.buffer = new Uint8Array, this.$a = function __PRIVATE_newTextDecoder() {
|
|
17058
17127
|
return new TextDecoder("utf-8");
|
|
17059
17128
|
}(),
|
|
17060
17129
|
// Read the metadata (which is the first element).
|
|
17061
|
-
this.
|
|
17062
|
-
e && e.
|
|
17130
|
+
this.Ua().then((e => {
|
|
17131
|
+
e && e.ra() ? this.metadata.resolve(e.na.metadata) : this.metadata.reject(new Error(`The first element of the bundle is not a metadata, it is\n ${JSON.stringify(null == e ? void 0 : e.na)}`));
|
|
17063
17132
|
}), (e => this.metadata.reject(e)));
|
|
17064
17133
|
}
|
|
17065
17134
|
close() {
|
|
17066
|
-
return this.
|
|
17135
|
+
return this.Ka.cancel();
|
|
17067
17136
|
}
|
|
17068
17137
|
async getMetadata() {
|
|
17069
17138
|
return this.metadata.promise;
|
|
17070
17139
|
}
|
|
17071
|
-
async
|
|
17140
|
+
async Ba() {
|
|
17072
17141
|
// Makes sure metadata is read before proceeding.
|
|
17073
|
-
return await this.getMetadata(), this.
|
|
17142
|
+
return await this.getMetadata(), this.Ua();
|
|
17074
17143
|
}
|
|
17075
17144
|
/**
|
|
17076
17145
|
* Reads from the head of internal buffer, and pulling more data from
|
|
@@ -17081,15 +17150,15 @@ class __PRIVATE_AsyncObserver {
|
|
|
17081
17150
|
*
|
|
17082
17151
|
* Returns either the bundled element, or null if we have reached the end of
|
|
17083
17152
|
* the stream.
|
|
17084
|
-
*/ async
|
|
17085
|
-
const e = await this.
|
|
17153
|
+
*/ async Ua() {
|
|
17154
|
+
const e = await this.Wa();
|
|
17086
17155
|
if (null === e) return null;
|
|
17087
|
-
const t = this.
|
|
17088
|
-
isNaN(n) && this
|
|
17089
|
-
const r = await this.
|
|
17156
|
+
const t = this.$a.decode(e), n = Number(t);
|
|
17157
|
+
isNaN(n) && this.Ga(`length string (${t}) is not valid number`);
|
|
17158
|
+
const r = await this.za(n);
|
|
17090
17159
|
return new __PRIVATE_SizedBundleElement(JSON.parse(r), e.length + n);
|
|
17091
17160
|
}
|
|
17092
|
-
/** First index of '{' from the underlying buffer. */
|
|
17161
|
+
/** First index of '{' from the underlying buffer. */ ja() {
|
|
17093
17162
|
return this.buffer.findIndex((e => e === "{".charCodeAt(0)));
|
|
17094
17163
|
}
|
|
17095
17164
|
/**
|
|
@@ -17097,17 +17166,17 @@ class __PRIVATE_AsyncObserver {
|
|
|
17097
17166
|
* return the content.
|
|
17098
17167
|
*
|
|
17099
17168
|
* If reached end of the stream, returns a null.
|
|
17100
|
-
*/ async
|
|
17101
|
-
for (;this.
|
|
17102
|
-
if (await this.
|
|
17169
|
+
*/ async Wa() {
|
|
17170
|
+
for (;this.ja() < 0; ) {
|
|
17171
|
+
if (await this.Ha()) break;
|
|
17103
17172
|
}
|
|
17104
17173
|
// Broke out of the loop because underlying stream is closed, and there
|
|
17105
17174
|
// happens to be no more data to process.
|
|
17106
17175
|
if (0 === this.buffer.length) return null;
|
|
17107
|
-
const e = this.
|
|
17176
|
+
const e = this.ja();
|
|
17108
17177
|
// Broke out of the loop because underlying stream is closed, but still
|
|
17109
17178
|
// cannot find an open bracket.
|
|
17110
|
-
e < 0 && this
|
|
17179
|
+
e < 0 && this.Ga("Reached the end of bundle when a length string is expected.");
|
|
17111
17180
|
const t = this.buffer.slice(0, e);
|
|
17112
17181
|
// Update the internal buffer to drop the read length.
|
|
17113
17182
|
return this.buffer = this.buffer.slice(e), t;
|
|
@@ -17117,23 +17186,23 @@ class __PRIVATE_AsyncObserver {
|
|
|
17117
17186
|
* number of bytes, pulling more data from the underlying stream if needed.
|
|
17118
17187
|
*
|
|
17119
17188
|
* Returns a string decoded from the read bytes.
|
|
17120
|
-
*/ async
|
|
17189
|
+
*/ async za(e) {
|
|
17121
17190
|
for (;this.buffer.length < e; ) {
|
|
17122
|
-
await this.
|
|
17191
|
+
await this.Ha() && this.Ga("Reached the end of bundle when more is expected.");
|
|
17123
17192
|
}
|
|
17124
|
-
const t = this.
|
|
17193
|
+
const t = this.$a.decode(this.buffer.slice(0, e));
|
|
17125
17194
|
// Update the internal buffer to drop the read json string.
|
|
17126
17195
|
return this.buffer = this.buffer.slice(e), t;
|
|
17127
17196
|
}
|
|
17128
|
-
|
|
17197
|
+
Ga(e) {
|
|
17129
17198
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
17130
|
-
throw this.
|
|
17199
|
+
throw this.Ka.cancel(), new Error(`Invalid bundle format: ${e}`);
|
|
17131
17200
|
}
|
|
17132
17201
|
/**
|
|
17133
17202
|
* Pulls more data from underlying stream to internal buffer.
|
|
17134
17203
|
* Returns a boolean indicating whether the stream is finished.
|
|
17135
|
-
*/ async
|
|
17136
|
-
const e = await this.
|
|
17204
|
+
*/ async Ha() {
|
|
17205
|
+
const e = await this.Ka.read();
|
|
17137
17206
|
if (!e.done) {
|
|
17138
17207
|
const t = new Uint8Array(this.buffer.length + e.value.length);
|
|
17139
17208
|
t.set(this.buffer), t.set(e.value, this.buffer.length), this.buffer = t;
|
|
@@ -17306,26 +17375,26 @@ class Transaction$2 {
|
|
|
17306
17375
|
*/ class __PRIVATE_TransactionRunner {
|
|
17307
17376
|
constructor(e, t, n, r, i) {
|
|
17308
17377
|
this.asyncQueue = e, this.datastore = t, this.options = n, this.updateFunction = r,
|
|
17309
|
-
this.deferred = i, this.
|
|
17378
|
+
this.deferred = i, this.Ja = n.maxAttempts, this.jo = new __PRIVATE_ExponentialBackoff(this.asyncQueue, "transaction_retry" /* TimerId.TransactionRetry */);
|
|
17310
17379
|
}
|
|
17311
|
-
/** Runs the transaction and sets the result on deferred. */
|
|
17312
|
-
this.
|
|
17380
|
+
/** Runs the transaction and sets the result on deferred. */ Ya() {
|
|
17381
|
+
this.Ja -= 1, this.Za();
|
|
17313
17382
|
}
|
|
17314
|
-
|
|
17383
|
+
Za() {
|
|
17315
17384
|
this.jo.qo((async () => {
|
|
17316
|
-
const e = new Transaction$2(this.datastore), t = this.
|
|
17385
|
+
const e = new Transaction$2(this.datastore), t = this.Xa(e);
|
|
17317
17386
|
t && t.then((t => {
|
|
17318
17387
|
this.asyncQueue.enqueueAndForget((() => e.commit().then((() => {
|
|
17319
17388
|
this.deferred.resolve(t);
|
|
17320
17389
|
})).catch((e => {
|
|
17321
|
-
this.
|
|
17390
|
+
this.eu(e);
|
|
17322
17391
|
}))));
|
|
17323
17392
|
})).catch((e => {
|
|
17324
|
-
this.
|
|
17393
|
+
this.eu(e);
|
|
17325
17394
|
}));
|
|
17326
17395
|
}));
|
|
17327
17396
|
}
|
|
17328
|
-
|
|
17397
|
+
Xa(e) {
|
|
17329
17398
|
try {
|
|
17330
17399
|
const t = this.updateFunction(e);
|
|
17331
17400
|
return !__PRIVATE_isNullOrUndefined(t) && t.catch && t.then ? t : (this.deferred.reject(Error("Transaction callback must return a Promise")),
|
|
@@ -17335,11 +17404,11 @@ class Transaction$2 {
|
|
|
17335
17404
|
return this.deferred.reject(e), null;
|
|
17336
17405
|
}
|
|
17337
17406
|
}
|
|
17338
|
-
|
|
17339
|
-
this.
|
|
17407
|
+
eu(e) {
|
|
17408
|
+
this.Ja > 0 && this.tu(e) ? (this.Ja -= 1, this.asyncQueue.enqueueAndForget((() => (this.Za(),
|
|
17340
17409
|
Promise.resolve())))) : this.deferred.reject(e);
|
|
17341
17410
|
}
|
|
17342
|
-
|
|
17411
|
+
tu(e) {
|
|
17343
17412
|
if ("FirebaseError" === e.name) {
|
|
17344
17413
|
// In transactions, the backend will fail outdated reads with FAILED_PRECONDITION and
|
|
17345
17414
|
// non-matching document versions with ABORTED. These errors should be retried.
|
|
@@ -17514,6 +17583,8 @@ function __PRIVATE_getDatastore(e) {
|
|
|
17514
17583
|
async function __PRIVATE_getEventManager(e) {
|
|
17515
17584
|
const t = await __PRIVATE_ensureOnlineComponents(e), n = t.eventManager;
|
|
17516
17585
|
return n.onListen = __PRIVATE_syncEngineListen.bind(null, t.syncEngine), n.onUnlisten = __PRIVATE_syncEngineUnlisten.bind(null, t.syncEngine),
|
|
17586
|
+
n.onFirstRemoteStoreListen = __PRIVATE_triggerRemoteStoreListen.bind(null, t.syncEngine),
|
|
17587
|
+
n.onLastRemoteStoreUnlisten = __PRIVATE_triggerRemoteStoreUnlisten.bind(null, t.syncEngine),
|
|
17517
17588
|
n;
|
|
17518
17589
|
}
|
|
17519
17590
|
|
|
@@ -17585,7 +17656,7 @@ function __PRIVATE_firestoreClientGetDocumentViaSnapshotListener(e, t, n = {}) {
|
|
|
17585
17656
|
error: e => i.reject(e)
|
|
17586
17657
|
}), o = new __PRIVATE_QueryListener(__PRIVATE_newQueryForPath(n.path), s, {
|
|
17587
17658
|
includeMetadataChanges: !0,
|
|
17588
|
-
|
|
17659
|
+
ta: !0
|
|
17589
17660
|
});
|
|
17590
17661
|
return __PRIVATE_eventManagerListen(e, o);
|
|
17591
17662
|
}(await __PRIVATE_getEventManager(e), e.asyncQueue, t, n, r))), r.promise;
|
|
@@ -17596,7 +17667,7 @@ function __PRIVATE_firestoreClientGetDocumentsFromLocalCache(e, t) {
|
|
|
17596
17667
|
return e.asyncQueue.enqueueAndForget((async () => async function __PRIVATE_executeQueryFromCache(e, t, n) {
|
|
17597
17668
|
try {
|
|
17598
17669
|
const r = await __PRIVATE_localStoreExecuteQuery(e, t,
|
|
17599
|
-
/* usePreviousResults= */ !0), i = new __PRIVATE_View(t, r.hs), s = i.
|
|
17670
|
+
/* usePreviousResults= */ !0), i = new __PRIVATE_View(t, r.hs), s = i.Ta(r.documents), o = i.applyChanges(s,
|
|
17600
17671
|
/* limboResolutionEnabled= */ !1);
|
|
17601
17672
|
n.resolve(o.snapshot);
|
|
17602
17673
|
} catch (e) {
|
|
@@ -17622,7 +17693,7 @@ function __PRIVATE_firestoreClientGetDocumentsViaSnapshotListener(e, t, n = {})
|
|
|
17622
17693
|
error: e => i.reject(e)
|
|
17623
17694
|
}), o = new __PRIVATE_QueryListener(n, s, {
|
|
17624
17695
|
includeMetadataChanges: !0,
|
|
17625
|
-
|
|
17696
|
+
ta: !0
|
|
17626
17697
|
});
|
|
17627
17698
|
return __PRIVATE_eventManagerListen(e, o);
|
|
17628
17699
|
}(await __PRIVATE_getEventManager(e), e.asyncQueue, t, n, r))), r.promise;
|
|
@@ -17631,13 +17702,13 @@ function __PRIVATE_firestoreClientGetDocumentsViaSnapshotListener(e, t, n = {})
|
|
|
17631
17702
|
function __PRIVATE_firestoreClientAddSnapshotsInSyncListener(e, t) {
|
|
17632
17703
|
const n = new __PRIVATE_AsyncObserver(t);
|
|
17633
17704
|
return e.asyncQueue.enqueueAndForget((async () => function __PRIVATE_addSnapshotsInSyncListener(e, t) {
|
|
17634
|
-
__PRIVATE_debugCast(e).
|
|
17705
|
+
__PRIVATE_debugCast(e).W_.add(t),
|
|
17635
17706
|
// Immediately fire an initial event, indicating all existing listeners
|
|
17636
17707
|
// are in-sync.
|
|
17637
17708
|
t.next();
|
|
17638
17709
|
}(await __PRIVATE_getEventManager(e), n))), () => {
|
|
17639
|
-
n.
|
|
17640
|
-
__PRIVATE_debugCast(e).
|
|
17710
|
+
n.Qa(), e.asyncQueue.enqueueAndForget((async () => function __PRIVATE_removeSnapshotsInSyncListener(e, t) {
|
|
17711
|
+
__PRIVATE_debugCast(e).W_.delete(t);
|
|
17641
17712
|
}(await __PRIVATE_getEventManager(e), n)));
|
|
17642
17713
|
};
|
|
17643
17714
|
}
|
|
@@ -17817,7 +17888,7 @@ function __PRIVATE_cloneLongPollingOptions(e) {
|
|
|
17817
17888
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17818
17889
|
* See the License for the specific language governing permissions and
|
|
17819
17890
|
* limitations under the License.
|
|
17820
|
-
*/ const
|
|
17891
|
+
*/ const ge = new Map;
|
|
17821
17892
|
|
|
17822
17893
|
/**
|
|
17823
17894
|
* An instance map that ensures only one Datastore exists per Firestore
|
|
@@ -18063,8 +18134,8 @@ class Firestore$1 {
|
|
|
18063
18134
|
* when the `Firestore` instance is terminated.
|
|
18064
18135
|
*/
|
|
18065
18136
|
return function __PRIVATE_removeComponents(e) {
|
|
18066
|
-
const t =
|
|
18067
|
-
t && (__PRIVATE_logDebug("ComponentProvider", "Removing Datastore"),
|
|
18137
|
+
const t = ge.get(e);
|
|
18138
|
+
t && (__PRIVATE_logDebug("ComponentProvider", "Removing Datastore"), ge.delete(e),
|
|
18068
18139
|
t.terminate());
|
|
18069
18140
|
}(this), Promise.resolve();
|
|
18070
18141
|
}
|
|
@@ -18302,40 +18373,40 @@ function doc(e, t, ...n) {
|
|
|
18302
18373
|
*/ class __PRIVATE_AsyncQueueImpl {
|
|
18303
18374
|
constructor() {
|
|
18304
18375
|
// The last promise in the queue.
|
|
18305
|
-
this.
|
|
18376
|
+
this.nu = Promise.resolve(),
|
|
18306
18377
|
// A list of retryable operations. Retryable operations are run in order and
|
|
18307
18378
|
// retried with backoff.
|
|
18308
|
-
this.
|
|
18379
|
+
this.ru = [],
|
|
18309
18380
|
// Is this AsyncQueue being shut down? Once it is set to true, it will not
|
|
18310
18381
|
// be changed again.
|
|
18311
|
-
this.
|
|
18382
|
+
this.iu = !1,
|
|
18312
18383
|
// Operations scheduled to be queued in the future. Operations are
|
|
18313
18384
|
// automatically removed after they are run or canceled.
|
|
18314
|
-
this.
|
|
18385
|
+
this.su = [],
|
|
18315
18386
|
// visible for testing
|
|
18316
|
-
this.
|
|
18387
|
+
this.ou = null,
|
|
18317
18388
|
// Flag set while there's an outstanding AsyncQueue operation, used for
|
|
18318
18389
|
// assertion sanity-checks.
|
|
18319
|
-
this.
|
|
18390
|
+
this._u = !1,
|
|
18320
18391
|
// Enabled during shutdown on Safari to prevent future access to IndexedDB.
|
|
18321
|
-
this.
|
|
18392
|
+
this.au = !1,
|
|
18322
18393
|
// List of TimerIds to fast-forward delays for.
|
|
18323
|
-
this.
|
|
18394
|
+
this.uu = [],
|
|
18324
18395
|
// Backoff timer used to schedule retries for retryable operations
|
|
18325
18396
|
this.jo = new __PRIVATE_ExponentialBackoff(this, "async_queue_retry" /* TimerId.AsyncQueueRetry */),
|
|
18326
18397
|
// Visibility handler that triggers an immediate retry of all retryable
|
|
18327
18398
|
// operations. Meant to speed up recovery when we regain file system access
|
|
18328
18399
|
// after page comes into foreground.
|
|
18329
|
-
this.
|
|
18400
|
+
this.cu = () => {
|
|
18330
18401
|
const e = getDocument();
|
|
18331
18402
|
e && __PRIVATE_logDebug("AsyncQueue", "Visibility state changed to " + e.visibilityState),
|
|
18332
18403
|
this.jo.Ko();
|
|
18333
18404
|
};
|
|
18334
18405
|
const e = getDocument();
|
|
18335
|
-
e && "function" == typeof e.addEventListener && e.addEventListener("visibilitychange", this.
|
|
18406
|
+
e && "function" == typeof e.addEventListener && e.addEventListener("visibilitychange", this.cu);
|
|
18336
18407
|
}
|
|
18337
18408
|
get isShuttingDown() {
|
|
18338
|
-
return this.
|
|
18409
|
+
return this.iu;
|
|
18339
18410
|
}
|
|
18340
18411
|
/**
|
|
18341
18412
|
* Adds a new operation to the queue without waiting for it to complete (i.e.
|
|
@@ -18345,44 +18416,44 @@ function doc(e, t, ...n) {
|
|
|
18345
18416
|
this.enqueue(e);
|
|
18346
18417
|
}
|
|
18347
18418
|
enqueueAndForgetEvenWhileRestricted(e) {
|
|
18348
|
-
this.
|
|
18419
|
+
this.lu(),
|
|
18349
18420
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
18350
|
-
this.
|
|
18421
|
+
this.hu(e);
|
|
18351
18422
|
}
|
|
18352
18423
|
enterRestrictedMode(e) {
|
|
18353
|
-
if (!this.
|
|
18354
|
-
this.
|
|
18424
|
+
if (!this.iu) {
|
|
18425
|
+
this.iu = !0, this.au = e || !1;
|
|
18355
18426
|
const t = getDocument();
|
|
18356
|
-
t && "function" == typeof t.removeEventListener && t.removeEventListener("visibilitychange", this.
|
|
18427
|
+
t && "function" == typeof t.removeEventListener && t.removeEventListener("visibilitychange", this.cu);
|
|
18357
18428
|
}
|
|
18358
18429
|
}
|
|
18359
18430
|
enqueue(e) {
|
|
18360
|
-
if (this.
|
|
18431
|
+
if (this.lu(), this.iu)
|
|
18361
18432
|
// Return a Promise which never resolves.
|
|
18362
18433
|
return new Promise((() => {}));
|
|
18363
18434
|
// Create a deferred Promise that we can return to the callee. This
|
|
18364
18435
|
// allows us to return a "hanging Promise" only to the callee and still
|
|
18365
18436
|
// advance the queue even when the operation is not run.
|
|
18366
18437
|
const t = new __PRIVATE_Deferred;
|
|
18367
|
-
return this.
|
|
18438
|
+
return this.hu((() => this.iu && this.au ? Promise.resolve() : (e().then(t.resolve, t.reject),
|
|
18368
18439
|
t.promise))).then((() => t.promise));
|
|
18369
18440
|
}
|
|
18370
18441
|
enqueueRetryable(e) {
|
|
18371
|
-
this.enqueueAndForget((() => (this.
|
|
18442
|
+
this.enqueueAndForget((() => (this.ru.push(e), this.Pu())));
|
|
18372
18443
|
}
|
|
18373
18444
|
/**
|
|
18374
18445
|
* Runs the next operation from the retryable queue. If the operation fails,
|
|
18375
18446
|
* reschedules with backoff.
|
|
18376
|
-
*/ async
|
|
18377
|
-
if (0 !== this.
|
|
18447
|
+
*/ async Pu() {
|
|
18448
|
+
if (0 !== this.ru.length) {
|
|
18378
18449
|
try {
|
|
18379
|
-
await this.
|
|
18450
|
+
await this.ru[0](), this.ru.shift(), this.jo.reset();
|
|
18380
18451
|
} catch (e) {
|
|
18381
18452
|
if (!__PRIVATE_isIndexedDbTransactionError(e)) throw e;
|
|
18382
18453
|
// Failure will be handled by AsyncQueue
|
|
18383
18454
|
__PRIVATE_logDebug("AsyncQueue", "Operation failed with retryable error: " + e);
|
|
18384
18455
|
}
|
|
18385
|
-
this.
|
|
18456
|
+
this.ru.length > 0 &&
|
|
18386
18457
|
// If there are additional operations, we re-schedule `retryNextOp()`.
|
|
18387
18458
|
// This is necessary to run retryable operations that failed during
|
|
18388
18459
|
// their initial attempt since we don't know whether they are already
|
|
@@ -18393,12 +18464,12 @@ function doc(e, t, ...n) {
|
|
|
18393
18464
|
// Since `backoffAndRun()` cancels an existing backoff and schedules a
|
|
18394
18465
|
// new backoff on every call, there is only ever a single additional
|
|
18395
18466
|
// operation in the queue.
|
|
18396
|
-
this.jo.qo((() => this.
|
|
18467
|
+
this.jo.qo((() => this.Pu()));
|
|
18397
18468
|
}
|
|
18398
18469
|
}
|
|
18399
|
-
|
|
18400
|
-
const t = this.
|
|
18401
|
-
this.
|
|
18470
|
+
hu(e) {
|
|
18471
|
+
const t = this.nu.then((() => (this._u = !0, e().catch((e => {
|
|
18472
|
+
this.ou = e, this._u = !1;
|
|
18402
18473
|
const t =
|
|
18403
18474
|
/**
|
|
18404
18475
|
* Chrome includes Error.message in Error.stack. Other browsers do not.
|
|
@@ -18430,38 +18501,38 @@ function doc(e, t, ...n) {
|
|
|
18430
18501
|
// all further attempts to chain (via .then) will just short-circuit
|
|
18431
18502
|
// and return the rejected Promise.
|
|
18432
18503
|
throw __PRIVATE_logError("INTERNAL UNHANDLED ERROR: ", t), e;
|
|
18433
|
-
})).then((e => (this.
|
|
18434
|
-
return this.
|
|
18504
|
+
})).then((e => (this._u = !1, e))))));
|
|
18505
|
+
return this.nu = t, t;
|
|
18435
18506
|
}
|
|
18436
18507
|
enqueueAfterDelay(e, t, n) {
|
|
18437
|
-
this.
|
|
18508
|
+
this.lu(),
|
|
18438
18509
|
// Fast-forward delays for timerIds that have been overriden.
|
|
18439
|
-
this.
|
|
18440
|
-
const r = DelayedOperation.createAndSchedule(this, e, t, n, (e => this.
|
|
18441
|
-
return this.
|
|
18510
|
+
this.uu.indexOf(e) > -1 && (t = 0);
|
|
18511
|
+
const r = DelayedOperation.createAndSchedule(this, e, t, n, (e => this.Iu(e)));
|
|
18512
|
+
return this.su.push(r), r;
|
|
18442
18513
|
}
|
|
18443
|
-
|
|
18444
|
-
this.
|
|
18514
|
+
lu() {
|
|
18515
|
+
this.ou && fail();
|
|
18445
18516
|
}
|
|
18446
18517
|
verifyOperationInProgress() {}
|
|
18447
18518
|
/**
|
|
18448
18519
|
* Waits until all currently queued tasks are finished executing. Delayed
|
|
18449
18520
|
* operations are not run.
|
|
18450
|
-
*/ async
|
|
18521
|
+
*/ async Tu() {
|
|
18451
18522
|
// Operations in the queue prior to draining may have enqueued additional
|
|
18452
18523
|
// operations. Keep draining the queue until the tail is no longer advanced,
|
|
18453
18524
|
// which indicates that no more new operations were enqueued and that all
|
|
18454
18525
|
// operations were executed.
|
|
18455
18526
|
let e;
|
|
18456
18527
|
do {
|
|
18457
|
-
e = this.
|
|
18458
|
-
} while (e !== this.
|
|
18528
|
+
e = this.nu, await e;
|
|
18529
|
+
} while (e !== this.nu);
|
|
18459
18530
|
}
|
|
18460
18531
|
/**
|
|
18461
18532
|
* For Tests: Determine if a delayed operation with a particular TimerId
|
|
18462
18533
|
* exists.
|
|
18463
|
-
*/
|
|
18464
|
-
for (const t of this.
|
|
18534
|
+
*/ Eu(e) {
|
|
18535
|
+
for (const t of this.su) if (t.timerId === e) return !0;
|
|
18465
18536
|
return !1;
|
|
18466
18537
|
}
|
|
18467
18538
|
/**
|
|
@@ -18470,24 +18541,24 @@ function doc(e, t, ...n) {
|
|
|
18470
18541
|
* @param lastTimerId - Delayed operations up to and including this TimerId
|
|
18471
18542
|
* will be drained. Pass TimerId.All to run all delayed operations.
|
|
18472
18543
|
* @returns a Promise that resolves once all operations have been run.
|
|
18473
|
-
*/
|
|
18544
|
+
*/ du(e) {
|
|
18474
18545
|
// Note that draining may generate more delayed ops, so we do that first.
|
|
18475
|
-
return this.
|
|
18546
|
+
return this.Tu().then((() => {
|
|
18476
18547
|
// Run ops in the same order they'd run if they ran naturally.
|
|
18477
|
-
this.
|
|
18478
|
-
for (const t of this.
|
|
18479
|
-
return this.
|
|
18548
|
+
this.su.sort(((e, t) => e.targetTimeMs - t.targetTimeMs));
|
|
18549
|
+
for (const t of this.su) if (t.skipDelay(), "all" /* TimerId.All */ !== e && t.timerId === e) break;
|
|
18550
|
+
return this.Tu();
|
|
18480
18551
|
}));
|
|
18481
18552
|
}
|
|
18482
18553
|
/**
|
|
18483
18554
|
* For Tests: Skip all subsequent delays for a timer id.
|
|
18484
|
-
*/
|
|
18485
|
-
this.
|
|
18555
|
+
*/ Au(e) {
|
|
18556
|
+
this.uu.push(e);
|
|
18486
18557
|
}
|
|
18487
|
-
/** Called once a DelayedOperation is run or canceled. */
|
|
18558
|
+
/** Called once a DelayedOperation is run or canceled. */ Iu(e) {
|
|
18488
18559
|
// NOTE: indexOf / slice are O(n), but delayedOperations is expected to be small.
|
|
18489
|
-
const t = this.
|
|
18490
|
-
this.
|
|
18560
|
+
const t = this.su.indexOf(e);
|
|
18561
|
+
this.su.splice(t, 1);
|
|
18491
18562
|
}
|
|
18492
18563
|
}
|
|
18493
18564
|
|
|
@@ -18615,7 +18686,7 @@ class LoadBundleTask {
|
|
|
18615
18686
|
* Constant used to indicate the LRU garbage collection should be disabled.
|
|
18616
18687
|
* Set this value as the `cacheSizeBytes` on the settings passed to the
|
|
18617
18688
|
* {@link Firestore} instance.
|
|
18618
|
-
*/ const
|
|
18689
|
+
*/ const pe = -1;
|
|
18619
18690
|
|
|
18620
18691
|
/**
|
|
18621
18692
|
* The Cloud Firestore service interface.
|
|
@@ -19238,7 +19309,7 @@ class AggregateField {
|
|
|
19238
19309
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19239
19310
|
* See the License for the specific language governing permissions and
|
|
19240
19311
|
* limitations under the License.
|
|
19241
|
-
*/ const
|
|
19312
|
+
*/ const ye = /^__.*__$/;
|
|
19242
19313
|
|
|
19243
19314
|
/** The result of parsing document data (e.g. for a setData call). */ class ParsedSetData {
|
|
19244
19315
|
constructor(e, t, n) {
|
|
@@ -19301,55 +19372,55 @@ function __PRIVATE_isWrite(e) {
|
|
|
19301
19372
|
this.settings = e, this.databaseId = t, this.serializer = n, this.ignoreUndefinedProperties = r,
|
|
19302
19373
|
// Minor hack: If fieldTransforms is undefined, we assume this is an
|
|
19303
19374
|
// external call and we need to validate the entire path.
|
|
19304
|
-
void 0 === i && this.
|
|
19375
|
+
void 0 === i && this.Ru(), this.fieldTransforms = i || [], this.fieldMask = s || [];
|
|
19305
19376
|
}
|
|
19306
19377
|
get path() {
|
|
19307
19378
|
return this.settings.path;
|
|
19308
19379
|
}
|
|
19309
|
-
get
|
|
19310
|
-
return this.settings.
|
|
19380
|
+
get Vu() {
|
|
19381
|
+
return this.settings.Vu;
|
|
19311
19382
|
}
|
|
19312
|
-
/** Returns a new context with the specified settings overwritten. */
|
|
19383
|
+
/** Returns a new context with the specified settings overwritten. */ mu(e) {
|
|
19313
19384
|
return new __PRIVATE_ParseContextImpl(Object.assign(Object.assign({}, this.settings), e), this.databaseId, this.serializer, this.ignoreUndefinedProperties, this.fieldTransforms, this.fieldMask);
|
|
19314
19385
|
}
|
|
19315
|
-
|
|
19386
|
+
fu(e) {
|
|
19316
19387
|
var t;
|
|
19317
|
-
const n = null === (t = this.path) || void 0 === t ? void 0 : t.child(e), r = this.
|
|
19388
|
+
const n = null === (t = this.path) || void 0 === t ? void 0 : t.child(e), r = this.mu({
|
|
19318
19389
|
path: n,
|
|
19319
|
-
|
|
19390
|
+
gu: !1
|
|
19320
19391
|
});
|
|
19321
|
-
return r.
|
|
19392
|
+
return r.pu(e), r;
|
|
19322
19393
|
}
|
|
19323
|
-
|
|
19394
|
+
yu(e) {
|
|
19324
19395
|
var t;
|
|
19325
|
-
const n = null === (t = this.path) || void 0 === t ? void 0 : t.child(e), r = this.
|
|
19396
|
+
const n = null === (t = this.path) || void 0 === t ? void 0 : t.child(e), r = this.mu({
|
|
19326
19397
|
path: n,
|
|
19327
|
-
|
|
19398
|
+
gu: !1
|
|
19328
19399
|
});
|
|
19329
|
-
return r.
|
|
19400
|
+
return r.Ru(), r;
|
|
19330
19401
|
}
|
|
19331
|
-
|
|
19402
|
+
wu(e) {
|
|
19332
19403
|
// TODO(b/34871131): We don't support array paths right now; so make path
|
|
19333
19404
|
// undefined.
|
|
19334
|
-
return this.
|
|
19405
|
+
return this.mu({
|
|
19335
19406
|
path: void 0,
|
|
19336
|
-
|
|
19407
|
+
gu: !0
|
|
19337
19408
|
});
|
|
19338
19409
|
}
|
|
19339
|
-
|
|
19340
|
-
return __PRIVATE_createError(e, this.settings.methodName, this.settings.
|
|
19410
|
+
Su(e) {
|
|
19411
|
+
return __PRIVATE_createError(e, this.settings.methodName, this.settings.bu || !1, this.path, this.settings.Du);
|
|
19341
19412
|
}
|
|
19342
19413
|
/** Returns 'true' if 'fieldPath' was traversed when creating this context. */ contains(e) {
|
|
19343
19414
|
return void 0 !== this.fieldMask.find((t => e.isPrefixOf(t))) || void 0 !== this.fieldTransforms.find((t => e.isPrefixOf(t.field)));
|
|
19344
19415
|
}
|
|
19345
|
-
|
|
19416
|
+
Ru() {
|
|
19346
19417
|
// TODO(b/34871131): Remove null check once we have proper paths for fields
|
|
19347
19418
|
// within arrays.
|
|
19348
|
-
if (this.path) for (let e = 0; e < this.path.length; e++) this.
|
|
19419
|
+
if (this.path) for (let e = 0; e < this.path.length; e++) this.pu(this.path.get(e));
|
|
19349
19420
|
}
|
|
19350
|
-
|
|
19351
|
-
if (0 === e.length) throw this.
|
|
19352
|
-
if (__PRIVATE_isWrite(this.
|
|
19421
|
+
pu(e) {
|
|
19422
|
+
if (0 === e.length) throw this.Su("Document fields must not be empty");
|
|
19423
|
+
if (__PRIVATE_isWrite(this.Vu) && ye.test(e)) throw this.Su('Document fields cannot begin and end with "__"');
|
|
19353
19424
|
}
|
|
19354
19425
|
}
|
|
19355
19426
|
|
|
@@ -19360,14 +19431,14 @@ function __PRIVATE_isWrite(e) {
|
|
|
19360
19431
|
constructor(e, t, n) {
|
|
19361
19432
|
this.databaseId = e, this.ignoreUndefinedProperties = t, this.serializer = n || __PRIVATE_newSerializer(e);
|
|
19362
19433
|
}
|
|
19363
|
-
/** Creates a new top-level parse context. */
|
|
19434
|
+
/** Creates a new top-level parse context. */ Cu(e, t, n, r = !1) {
|
|
19364
19435
|
return new __PRIVATE_ParseContextImpl({
|
|
19365
|
-
|
|
19436
|
+
Vu: e,
|
|
19366
19437
|
methodName: t,
|
|
19367
|
-
|
|
19438
|
+
Du: n,
|
|
19368
19439
|
path: FieldPath$1.emptyPath(),
|
|
19369
|
-
|
|
19370
|
-
|
|
19440
|
+
gu: !1,
|
|
19441
|
+
bu: r
|
|
19371
19442
|
}, this.databaseId, this.serializer, this.ignoreUndefinedProperties);
|
|
19372
19443
|
}
|
|
19373
19444
|
}
|
|
@@ -19378,7 +19449,7 @@ function __PRIVATE_newUserDataReader(e) {
|
|
|
19378
19449
|
}
|
|
19379
19450
|
|
|
19380
19451
|
/** Parse document data from a set() call. */ function __PRIVATE_parseSetData(e, t, n, r, i, s = {}) {
|
|
19381
|
-
const o = e.
|
|
19452
|
+
const o = e.Cu(s.merge || s.mergeFields ? 2 /* UserDataSource.MergeSet */ : 0 /* UserDataSource.Set */ , t, n, i);
|
|
19382
19453
|
__PRIVATE_validatePlainObject("Data must be an object, but it was:", o, r);
|
|
19383
19454
|
const _ = __PRIVATE_parseObject(r, o);
|
|
19384
19455
|
let a, u;
|
|
@@ -19396,7 +19467,7 @@ function __PRIVATE_newUserDataReader(e) {
|
|
|
19396
19467
|
|
|
19397
19468
|
class __PRIVATE_DeleteFieldValueImpl extends FieldValue {
|
|
19398
19469
|
_toFieldTransform(e) {
|
|
19399
|
-
if (2 /* UserDataSource.MergeSet */ !== e.
|
|
19470
|
+
if (2 /* UserDataSource.MergeSet */ !== e.Vu) throw 1 /* UserDataSource.Update */ === e.Vu ? e.Su(`${this._methodName}() can only appear at the top level of your update data`) : e.Su(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);
|
|
19400
19471
|
// No transform to add for a delete, but we need to add it to our
|
|
19401
19472
|
// fieldMask so it gets deleted.
|
|
19402
19473
|
return e.fieldMask.push(e.path), null;
|
|
@@ -19423,10 +19494,10 @@ class __PRIVATE_DeleteFieldValueImpl extends FieldValue {
|
|
|
19423
19494
|
* @param arrayElement - Whether or not the FieldValue has an array.
|
|
19424
19495
|
*/ function __PRIVATE_createSentinelChildContext(e, t, n) {
|
|
19425
19496
|
return new __PRIVATE_ParseContextImpl({
|
|
19426
|
-
|
|
19427
|
-
|
|
19497
|
+
Vu: 3 /* UserDataSource.Argument */ ,
|
|
19498
|
+
Du: t.settings.Du,
|
|
19428
19499
|
methodName: e._methodName,
|
|
19429
|
-
|
|
19500
|
+
gu: n
|
|
19430
19501
|
}, t.databaseId, t.serializer, t.ignoreUndefinedProperties);
|
|
19431
19502
|
}
|
|
19432
19503
|
|
|
@@ -19441,47 +19512,47 @@ class __PRIVATE_ServerTimestampFieldValueImpl extends FieldValue {
|
|
|
19441
19512
|
|
|
19442
19513
|
class __PRIVATE_ArrayUnionFieldValueImpl extends FieldValue {
|
|
19443
19514
|
constructor(e, t) {
|
|
19444
|
-
super(e), this.
|
|
19515
|
+
super(e), this.vu = t;
|
|
19445
19516
|
}
|
|
19446
19517
|
_toFieldTransform(e) {
|
|
19447
19518
|
const t = __PRIVATE_createSentinelChildContext(this, e,
|
|
19448
|
-
/*array=*/ !0), n = this.
|
|
19519
|
+
/*array=*/ !0), n = this.vu.map((e => __PRIVATE_parseData(e, t))), r = new __PRIVATE_ArrayUnionTransformOperation(n);
|
|
19449
19520
|
return new FieldTransform(e.path, r);
|
|
19450
19521
|
}
|
|
19451
19522
|
isEqual(e) {
|
|
19452
|
-
return e instanceof __PRIVATE_ArrayUnionFieldValueImpl && deepEqual(this.
|
|
19523
|
+
return e instanceof __PRIVATE_ArrayUnionFieldValueImpl && deepEqual(this.vu, e.vu);
|
|
19453
19524
|
}
|
|
19454
19525
|
}
|
|
19455
19526
|
|
|
19456
19527
|
class __PRIVATE_ArrayRemoveFieldValueImpl extends FieldValue {
|
|
19457
19528
|
constructor(e, t) {
|
|
19458
|
-
super(e), this.
|
|
19529
|
+
super(e), this.vu = t;
|
|
19459
19530
|
}
|
|
19460
19531
|
_toFieldTransform(e) {
|
|
19461
19532
|
const t = __PRIVATE_createSentinelChildContext(this, e,
|
|
19462
|
-
/*array=*/ !0), n = this.
|
|
19533
|
+
/*array=*/ !0), n = this.vu.map((e => __PRIVATE_parseData(e, t))), r = new __PRIVATE_ArrayRemoveTransformOperation(n);
|
|
19463
19534
|
return new FieldTransform(e.path, r);
|
|
19464
19535
|
}
|
|
19465
19536
|
isEqual(e) {
|
|
19466
|
-
return e instanceof __PRIVATE_ArrayRemoveFieldValueImpl && deepEqual(this.
|
|
19537
|
+
return e instanceof __PRIVATE_ArrayRemoveFieldValueImpl && deepEqual(this.vu, e.vu);
|
|
19467
19538
|
}
|
|
19468
19539
|
}
|
|
19469
19540
|
|
|
19470
19541
|
class __PRIVATE_NumericIncrementFieldValueImpl extends FieldValue {
|
|
19471
19542
|
constructor(e, t) {
|
|
19472
|
-
super(e), this.
|
|
19543
|
+
super(e), this.Fu = t;
|
|
19473
19544
|
}
|
|
19474
19545
|
_toFieldTransform(e) {
|
|
19475
|
-
const t = new __PRIVATE_NumericIncrementTransformOperation(e.serializer, toNumber(e.serializer, this.
|
|
19546
|
+
const t = new __PRIVATE_NumericIncrementTransformOperation(e.serializer, toNumber(e.serializer, this.Fu));
|
|
19476
19547
|
return new FieldTransform(e.path, t);
|
|
19477
19548
|
}
|
|
19478
19549
|
isEqual(e) {
|
|
19479
|
-
return e instanceof __PRIVATE_NumericIncrementFieldValueImpl && this.
|
|
19550
|
+
return e instanceof __PRIVATE_NumericIncrementFieldValueImpl && this.Fu === e.Fu;
|
|
19480
19551
|
}
|
|
19481
19552
|
}
|
|
19482
19553
|
|
|
19483
19554
|
/** Parse update data from an update() call. */ function __PRIVATE_parseUpdateData(e, t, n, r) {
|
|
19484
|
-
const i = e.
|
|
19555
|
+
const i = e.Cu(1 /* UserDataSource.Update */ , t, n);
|
|
19485
19556
|
__PRIVATE_validatePlainObject("Data must be an object, but it was:", i, r);
|
|
19486
19557
|
const s = [], o = ObjectValue.empty();
|
|
19487
19558
|
forEach(r, ((e, r) => {
|
|
@@ -19489,7 +19560,7 @@ class __PRIVATE_NumericIncrementFieldValueImpl extends FieldValue {
|
|
|
19489
19560
|
// For Compat types, we have to "extract" the underlying types before
|
|
19490
19561
|
// performing validation.
|
|
19491
19562
|
r = getModularInstance(r);
|
|
19492
|
-
const a = i.
|
|
19563
|
+
const a = i.yu(_);
|
|
19493
19564
|
if (r instanceof __PRIVATE_DeleteFieldValueImpl)
|
|
19494
19565
|
// Add it to the field mask, but don't add anything to updateData.
|
|
19495
19566
|
s.push(_); else {
|
|
@@ -19502,7 +19573,7 @@ class __PRIVATE_NumericIncrementFieldValueImpl extends FieldValue {
|
|
|
19502
19573
|
}
|
|
19503
19574
|
|
|
19504
19575
|
/** Parse update data from a list of field/value arguments. */ function __PRIVATE_parseUpdateVarargs(e, t, n, r, i, s) {
|
|
19505
|
-
const o = e.
|
|
19576
|
+
const o = e.Cu(1 /* UserDataSource.Update */ , t, n), _ = [ __PRIVATE_fieldPathFromArgument$1(t, r, n) ], a = [ i ];
|
|
19506
19577
|
if (s.length % 2 != 0) throw new FirestoreError(D.INVALID_ARGUMENT, `Function ${t}() needs to be called with an even number of arguments that alternate between field names and values.`);
|
|
19507
19578
|
for (let e = 0; e < s.length; e += 2) _.push(__PRIVATE_fieldPathFromArgument$1(t, s[e])),
|
|
19508
19579
|
a.push(s[e + 1]);
|
|
@@ -19515,7 +19586,7 @@ class __PRIVATE_NumericIncrementFieldValueImpl extends FieldValue {
|
|
|
19515
19586
|
// For Compat types, we have to "extract" the underlying types before
|
|
19516
19587
|
// performing validation.
|
|
19517
19588
|
n = getModularInstance(n);
|
|
19518
|
-
const r = o.
|
|
19589
|
+
const r = o.yu(t);
|
|
19519
19590
|
if (n instanceof __PRIVATE_DeleteFieldValueImpl)
|
|
19520
19591
|
// Add it to the field mask, but don't add anything to updateData.
|
|
19521
19592
|
u.push(t); else {
|
|
@@ -19534,7 +19605,7 @@ class __PRIVATE_NumericIncrementFieldValueImpl extends FieldValue {
|
|
|
19534
19605
|
* @param allowArrays - Whether the query value is an array that may directly
|
|
19535
19606
|
* contain additional arrays (e.g. the operand of an `in` query).
|
|
19536
19607
|
*/ function __PRIVATE_parseQueryValue(e, t, n, r = !1) {
|
|
19537
|
-
return __PRIVATE_parseData(n, e.
|
|
19608
|
+
return __PRIVATE_parseData(n, e.Cu(r ? 4 /* UserDataSource.ArrayArgument */ : 3 /* UserDataSource.Argument */ , t));
|
|
19538
19609
|
}
|
|
19539
19610
|
|
|
19540
19611
|
/**
|
|
@@ -19563,8 +19634,8 @@ class __PRIVATE_NumericIncrementFieldValueImpl extends FieldValue {
|
|
|
19563
19634
|
*/
|
|
19564
19635
|
return function __PRIVATE_parseSentinelFieldValue(e, t) {
|
|
19565
19636
|
// Sentinels are only supported with writes, and not within arrays.
|
|
19566
|
-
if (!__PRIVATE_isWrite(t.
|
|
19567
|
-
if (!t.path) throw t.
|
|
19637
|
+
if (!__PRIVATE_isWrite(t.Vu)) throw t.Su(`${e._methodName}() can only be used with update() and set()`);
|
|
19638
|
+
if (!t.path) throw t.Su(`${e._methodName}() is not currently supported inside arrays`);
|
|
19568
19639
|
const n = e._toFieldTransform(t);
|
|
19569
19640
|
n && t.fieldTransforms.push(n);
|
|
19570
19641
|
}
|
|
@@ -19588,12 +19659,12 @@ class __PRIVATE_NumericIncrementFieldValueImpl extends FieldValue {
|
|
|
19588
19659
|
// the set of values to be included for the IN query) that may directly
|
|
19589
19660
|
// contain additional arrays (each representing an individual field
|
|
19590
19661
|
// value), so we disable this validation.
|
|
19591
|
-
if (t.settings.
|
|
19662
|
+
if (t.settings.gu && 4 /* UserDataSource.ArrayArgument */ !== t.Vu) throw t.Su("Nested arrays are not supported");
|
|
19592
19663
|
return function __PRIVATE_parseArray(e, t) {
|
|
19593
19664
|
const n = [];
|
|
19594
19665
|
let r = 0;
|
|
19595
19666
|
for (const i of e) {
|
|
19596
|
-
let e = __PRIVATE_parseData(i, t.
|
|
19667
|
+
let e = __PRIVATE_parseData(i, t.wu(r));
|
|
19597
19668
|
null == e && (
|
|
19598
19669
|
// Just include nulls in the array for fields being replaced with a
|
|
19599
19670
|
// sentinel.
|
|
@@ -19645,12 +19716,12 @@ class __PRIVATE_NumericIncrementFieldValueImpl extends FieldValue {
|
|
|
19645
19716
|
};
|
|
19646
19717
|
if (e instanceof DocumentReference) {
|
|
19647
19718
|
const n = t.databaseId, r = e.firestore._databaseId;
|
|
19648
|
-
if (!r.isEqual(n)) throw t.
|
|
19719
|
+
if (!r.isEqual(n)) throw t.Su(`Document reference is for database ${r.projectId}/${r.database} but should be for database ${n.projectId}/${n.database}`);
|
|
19649
19720
|
return {
|
|
19650
19721
|
referenceValue: __PRIVATE_toResourceName(e.firestore._databaseId || t.databaseId, e._key.path)
|
|
19651
19722
|
};
|
|
19652
19723
|
}
|
|
19653
|
-
throw t.
|
|
19724
|
+
throw t.Su(`Unsupported field value: ${__PRIVATE_valueDescription(e)}`);
|
|
19654
19725
|
}
|
|
19655
19726
|
/**
|
|
19656
19727
|
* Checks whether an object looks like a JSON object that should be converted
|
|
@@ -19667,7 +19738,7 @@ function __PRIVATE_parseObject(e, t) {
|
|
|
19667
19738
|
// If we encounter an empty object, we explicitly add it to the update
|
|
19668
19739
|
// mask to ensure that the server creates a map entry.
|
|
19669
19740
|
t.path && t.path.length > 0 && t.fieldMask.push(t.path) : forEach(e, ((e, r) => {
|
|
19670
|
-
const i = __PRIVATE_parseData(r, t.
|
|
19741
|
+
const i = __PRIVATE_parseData(r, t.fu(e));
|
|
19671
19742
|
null != i && (n[e] = i);
|
|
19672
19743
|
})), {
|
|
19673
19744
|
mapValue: {
|
|
@@ -19685,7 +19756,7 @@ function __PRIVATE_validatePlainObject(e, t, n) {
|
|
|
19685
19756
|
return "object" == typeof e && null !== e && (Object.getPrototypeOf(e) === Object.prototype || null === Object.getPrototypeOf(e));
|
|
19686
19757
|
}(n)) {
|
|
19687
19758
|
const r = __PRIVATE_valueDescription(n);
|
|
19688
|
-
throw "an object" === r ? t.
|
|
19759
|
+
throw "an object" === r ? t.Su(e + " a custom object") : t.Su(e + " " + r);
|
|
19689
19760
|
}
|
|
19690
19761
|
}
|
|
19691
19762
|
|
|
@@ -19704,7 +19775,7 @@ function __PRIVATE_validatePlainObject(e, t, n) {
|
|
|
19704
19775
|
|
|
19705
19776
|
/**
|
|
19706
19777
|
* Matches any characters in a field path string that are reserved.
|
|
19707
|
-
*/ const
|
|
19778
|
+
*/ const we = new RegExp("[~\\*/\\[\\]]");
|
|
19708
19779
|
|
|
19709
19780
|
/**
|
|
19710
19781
|
* Wraps fromDotSeparatedString with an error message about the method that
|
|
@@ -19715,7 +19786,7 @@ function __PRIVATE_validatePlainObject(e, t, n) {
|
|
|
19715
19786
|
* @param targetDoc - The document against which the field path will be
|
|
19716
19787
|
* evaluated.
|
|
19717
19788
|
*/ function __PRIVATE_fieldPathFromDotSeparatedString(e, t, n) {
|
|
19718
|
-
if (t.search(
|
|
19789
|
+
if (t.search(we) >= 0) throw __PRIVATE_createError(`Invalid field path (${t}). Paths must not contain '~', '*', '/', '[', or ']'`, e,
|
|
19719
19790
|
/* hasConverter= */ !1,
|
|
19720
19791
|
/* path= */ void 0, n);
|
|
19721
19792
|
try {
|
|
@@ -20935,11 +21006,13 @@ function onSnapshot(e, ...t) {
|
|
|
20935
21006
|
var n, r, i;
|
|
20936
21007
|
e = getModularInstance(e);
|
|
20937
21008
|
let s = {
|
|
20938
|
-
includeMetadataChanges: !1
|
|
21009
|
+
includeMetadataChanges: !1,
|
|
21010
|
+
source: "default"
|
|
20939
21011
|
}, o = 0;
|
|
20940
21012
|
"object" != typeof t[o] || __PRIVATE_isPartialObserver(t[o]) || (s = t[o], o++);
|
|
20941
21013
|
const _ = {
|
|
20942
|
-
includeMetadataChanges: s.includeMetadataChanges
|
|
21014
|
+
includeMetadataChanges: s.includeMetadataChanges,
|
|
21015
|
+
source: s.source
|
|
20943
21016
|
};
|
|
20944
21017
|
if (__PRIVATE_isPartialObserver(t[o])) {
|
|
20945
21018
|
const e = t[o];
|
|
@@ -20970,7 +21043,7 @@ function onSnapshot(e, ...t) {
|
|
|
20970
21043
|
const i = new __PRIVATE_AsyncObserver(r), s = new __PRIVATE_QueryListener(t, i, n);
|
|
20971
21044
|
return e.asyncQueue.enqueueAndForget((async () => __PRIVATE_eventManagerListen(await __PRIVATE_getEventManager(e), s))),
|
|
20972
21045
|
() => {
|
|
20973
|
-
i.
|
|
21046
|
+
i.Qa(), e.asyncQueue.enqueueAndForget((async () => __PRIVATE_eventManagerUnlisten(await __PRIVATE_getEventManager(e), s)));
|
|
20974
21047
|
};
|
|
20975
21048
|
}(ensureFirestoreConfigured(u), c, _, a);
|
|
20976
21049
|
}
|
|
@@ -21267,7 +21340,7 @@ class __PRIVATE_MultiTabManagerImpl {
|
|
|
21267
21340
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
21268
21341
|
* See the License for the specific language governing permissions and
|
|
21269
21342
|
* limitations under the License.
|
|
21270
|
-
*/ const
|
|
21343
|
+
*/ const Se = {
|
|
21271
21344
|
maxAttempts: 5
|
|
21272
21345
|
};
|
|
21273
21346
|
|
|
@@ -21479,7 +21552,7 @@ class Transaction extends class Transaction$1 {
|
|
|
21479
21552
|
* rejected promise with the corresponding failure error is returned.
|
|
21480
21553
|
*/ function runTransaction(e, t, n) {
|
|
21481
21554
|
e = __PRIVATE_cast(e, Firestore);
|
|
21482
|
-
const r = Object.assign(Object.assign({},
|
|
21555
|
+
const r = Object.assign(Object.assign({}, Se), n);
|
|
21483
21556
|
!function __PRIVATE_validateTransactionOptions(e) {
|
|
21484
21557
|
if (e.maxAttempts < 1) throw new FirestoreError(D.INVALID_ARGUMENT, "Max attempts must be at least 1");
|
|
21485
21558
|
}(r);
|
|
@@ -21487,7 +21560,7 @@ class Transaction extends class Transaction$1 {
|
|
|
21487
21560
|
const r = new __PRIVATE_Deferred;
|
|
21488
21561
|
return e.asyncQueue.enqueueAndForget((async () => {
|
|
21489
21562
|
const i = await __PRIVATE_getDatastore(e);
|
|
21490
|
-
new __PRIVATE_TransactionRunner(e.asyncQueue, i, n, t, r).
|
|
21563
|
+
new __PRIVATE_TransactionRunner(e.asyncQueue, i, n, t, r).Ya();
|
|
21491
21564
|
})), r.promise;
|
|
21492
21565
|
}(ensureFirestoreConfigured(e), (n => t(new Transaction(e, n))), r);
|
|
21493
21566
|
}
|
|
@@ -21695,12 +21768,12 @@ function __PRIVATE_tryGetString(e, t) {
|
|
|
21695
21768
|
*/ function getPersistentCacheIndexManager(e) {
|
|
21696
21769
|
var t;
|
|
21697
21770
|
e = __PRIVATE_cast(e, Firestore);
|
|
21698
|
-
const n =
|
|
21771
|
+
const n = be.get(e);
|
|
21699
21772
|
if (n) return n;
|
|
21700
21773
|
const r = ensureFirestoreConfigured(e);
|
|
21701
21774
|
if ("persistent" !== (null === (t = r._uninitializedComponentsProvider) || void 0 === t ? void 0 : t._offlineKind)) return null;
|
|
21702
21775
|
const i = new PersistentCacheIndexManager(r);
|
|
21703
|
-
return
|
|
21776
|
+
return be.set(e, i), i;
|
|
21704
21777
|
}
|
|
21705
21778
|
|
|
21706
21779
|
/**
|
|
@@ -21743,7 +21816,7 @@ function __PRIVATE_setPersistentCacheIndexAutoCreationEnabled(e, t) {
|
|
|
21743
21816
|
* Use a `WeakMap` so that the mapping will be automatically dropped when the
|
|
21744
21817
|
* `Firestore` instance is garbage collected. This emulates a private member
|
|
21745
21818
|
* as described in https://goo.gle/454yvug.
|
|
21746
|
-
*/ const
|
|
21819
|
+
*/ const be = new WeakMap;
|
|
21747
21820
|
|
|
21748
21821
|
/**
|
|
21749
21822
|
* @license
|
|
@@ -21793,24 +21866,24 @@ function __PRIVATE_setPersistentCacheIndexAutoCreationEnabled(e, t) {
|
|
|
21793
21866
|
* The implementation of `TestingHooksSpi`.
|
|
21794
21867
|
*/ class __PRIVATE_TestingHooksSpiImpl {
|
|
21795
21868
|
constructor() {
|
|
21796
|
-
this.
|
|
21869
|
+
this.Mu = new Map;
|
|
21797
21870
|
}
|
|
21798
21871
|
static get instance() {
|
|
21799
|
-
return
|
|
21872
|
+
return De || (De = new __PRIVATE_TestingHooksSpiImpl, function __PRIVATE_setTestingHooksSpi(e) {
|
|
21800
21873
|
if (ce) throw new Error("a TestingHooksSpi instance is already set");
|
|
21801
21874
|
ce = e;
|
|
21802
|
-
}(
|
|
21875
|
+
}(De)), De;
|
|
21803
21876
|
}
|
|
21804
21877
|
tt(e) {
|
|
21805
|
-
this.
|
|
21878
|
+
this.Mu.forEach((t => t(e)));
|
|
21806
21879
|
}
|
|
21807
21880
|
onExistenceFilterMismatch(e) {
|
|
21808
|
-
const t = Symbol(), n = this.
|
|
21881
|
+
const t = Symbol(), n = this.Mu;
|
|
21809
21882
|
return n.set(t, e), () => n.delete(t);
|
|
21810
21883
|
}
|
|
21811
21884
|
}
|
|
21812
21885
|
|
|
21813
|
-
let
|
|
21886
|
+
let De = null;
|
|
21814
21887
|
|
|
21815
21888
|
/**
|
|
21816
21889
|
* Cloud Firestore
|
|
@@ -21827,10 +21900,10 @@ let Se = null;
|
|
|
21827
21900
|
return r = Object.assign({
|
|
21828
21901
|
useFetchStreams: t
|
|
21829
21902
|
}, r), s._setSettings(r), s;
|
|
21830
|
-
}), "PUBLIC").setMultipleInstances(!0)), registerVersion(w, "4.4.3-canary.
|
|
21903
|
+
}), "PUBLIC").setMultipleInstances(!0)), registerVersion(w, "4.4.3-canary.ce88e71e7", e),
|
|
21831
21904
|
// BUILD_TARGET will be replaced by values like esm5, esm2017, cjs5, etc during the compilation
|
|
21832
|
-
registerVersion(w, "4.4.3-canary.
|
|
21905
|
+
registerVersion(w, "4.4.3-canary.ce88e71e7", "esm2017");
|
|
21833
21906
|
}();
|
|
21834
21907
|
|
|
21835
|
-
export { AbstractUserDataWriter, AggregateField, AggregateQuerySnapshot, Bytes,
|
|
21908
|
+
export { AbstractUserDataWriter, AggregateField, AggregateQuerySnapshot, Bytes, pe as CACHE_SIZE_UNLIMITED, CollectionReference, DocumentReference, DocumentSnapshot, FieldPath, FieldValue, Firestore, FirestoreError, GeoPoint, LoadBundleTask, PersistentCacheIndexManager, Query, QueryCompositeFilterConstraint, QueryConstraint, QueryDocumentSnapshot, QueryEndAtConstraint, QueryFieldFilterConstraint, QueryLimitConstraint, QueryOrderByConstraint, QuerySnapshot, QueryStartAtConstraint, SnapshotMetadata, Timestamp, Transaction, WriteBatch, __PRIVATE_AutoId as _AutoId, ByteString as _ByteString, DatabaseId as _DatabaseId, DocumentKey as _DocumentKey, __PRIVATE_EmptyAppCheckTokenProvider as _EmptyAppCheckTokenProvider, __PRIVATE_EmptyAuthCredentialsProvider as _EmptyAuthCredentialsProvider, FieldPath$1 as _FieldPath, TestingHooks as _TestingHooks, __PRIVATE_cast as _cast, __PRIVATE_debugAssert as _debugAssert, __PRIVATE_isBase64Available as _isBase64Available, __PRIVATE_logWarn as _logWarn, __PRIVATE_validateIsNotUsedTogether as _validateIsNotUsedTogether, addDoc, aggregateFieldEqual, aggregateQuerySnapshotEqual, and, arrayRemove, arrayUnion, average, clearIndexedDbPersistence, collection, collectionGroup, connectFirestoreEmulator, count, deleteAllPersistentCacheIndexes, deleteDoc, deleteField, disableNetwork, disablePersistentCacheIndexAutoCreation, doc, documentId, enableIndexedDbPersistence, enableMultiTabIndexedDbPersistence, enableNetwork, enablePersistentCacheIndexAutoCreation, endAt, endBefore, ensureFirestoreConfigured, executeWrite, getAggregateFromServer, getCountFromServer, getDoc, getDocFromCache, getDocFromServer, getDocs, getDocsFromCache, getDocsFromServer, getFirestore, getPersistentCacheIndexManager, increment, initializeFirestore, limit, limitToLast, loadBundle, memoryEagerGarbageCollector, memoryLocalCache, memoryLruGarbageCollector, namedQuery, onSnapshot, onSnapshotsInSync, or, orderBy, persistentLocalCache, persistentMultipleTabManager, persistentSingleTabManager, query, queryEqual, refEqual, runTransaction, serverTimestamp, setDoc, setIndexConfiguration, setLogLevel, snapshotEqual, startAfter, startAt, sum, terminate, updateDoc, waitForPendingWrites, where, writeBatch };
|
|
21836
21909
|
//# sourceMappingURL=index.esm2017.js.map
|