@firebase/firestore 4.3.2-canary.b782bb270 → 4.3.2-canary.e9ff107ee

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.
@@ -34,7 +34,7 @@ var grpc__namespace = /*#__PURE__*/_interopNamespace(grpc);
34
34
  var protoLoader__namespace = /*#__PURE__*/_interopNamespace(protoLoader);
35
35
 
36
36
  const name = "@firebase/firestore";
37
- const version$1 = "4.3.2-canary.b782bb270";
37
+ const version$1 = "4.3.2-canary.e9ff107ee";
38
38
 
39
39
  /**
40
40
  * @license
@@ -87,7 +87,7 @@ User.GOOGLE_CREDENTIALS = new User('google-credentials-uid');
87
87
  User.FIRST_PARTY = new User('first-party-uid');
88
88
  User.MOCK_USER = new User('mock-user');
89
89
 
90
- const version = "10.6.0-canary.b782bb270";
90
+ const version = "10.6.0-canary.e9ff107ee";
91
91
 
92
92
  /**
93
93
  * @license
@@ -8338,6 +8338,7 @@ class TargetState {
8338
8338
  }
8339
8339
  recordTargetResponse() {
8340
8340
  this.pendingResponses -= 1;
8341
+ hardAssert(this.pendingResponses >= 0);
8341
8342
  }
8342
8343
  markCurrent() {
8343
8344
  this._hasPendingChanges = true;
@@ -24536,14 +24537,17 @@ class View {
24536
24537
  * Updates the view with the given ViewDocumentChanges and optionally updates
24537
24538
  * limbo docs and sync state from the provided target change.
24538
24539
  * @param docChanges - The set of changes to make to the view's docs.
24539
- * @param updateLimboDocuments - Whether to update limbo documents based on
24540
+ * @param limboResolutionEnabled - Whether to update limbo documents based on
24540
24541
  * this change.
24541
24542
  * @param targetChange - A target change to apply for computing limbo docs and
24542
24543
  * sync state.
24544
+ * @param targetIsPendingReset - Whether the target is pending to reset due to
24545
+ * existence filter mismatch. If not explicitly specified, it is treated
24546
+ * equivalently to `false`.
24543
24547
  * @returns A new ViewChange with the given docs, changes, and sync state.
24544
24548
  */
24545
24549
  // PORTING NOTE: The iOS/Android clients always compute limbo document changes.
24546
- applyChanges(docChanges, updateLimboDocuments, targetChange) {
24550
+ applyChanges(docChanges, limboResolutionEnabled, targetChange, targetIsPendingReset) {
24547
24551
  const oldDocs = this.documentSet;
24548
24552
  this.documentSet = docChanges.documentSet;
24549
24553
  this.mutatedKeys = docChanges.mutatedKeys;
@@ -24554,10 +24558,13 @@ class View {
24554
24558
  this.docComparator(c1.doc, c2.doc));
24555
24559
  });
24556
24560
  this.applyTargetChange(targetChange);
24557
- const limboChanges = updateLimboDocuments
24561
+ targetIsPendingReset = targetIsPendingReset !== null && targetIsPendingReset !== void 0 ? targetIsPendingReset : false;
24562
+ const limboChanges = limboResolutionEnabled && !targetIsPendingReset
24558
24563
  ? this.updateLimboDocuments()
24559
24564
  : [];
24560
- const synced = this.limboDocuments.size === 0 && this.current;
24565
+ // We are at synced state if there is no limbo docs are waiting to be resolved, view is current
24566
+ // with the backend, and the query is not pending to reset due to existence filter mismatch.
24567
+ const synced = this.limboDocuments.size === 0 && this.current && !targetIsPendingReset;
24561
24568
  const newSyncState = synced ? 1 /* SyncState.Synced */ : 0 /* SyncState.Local */;
24562
24569
  const syncStateChanged = newSyncState !== this.syncState;
24563
24570
  this.syncState = newSyncState;
@@ -24593,7 +24600,7 @@ class View {
24593
24600
  mutatedKeys: this.mutatedKeys,
24594
24601
  needsRefill: false
24595
24602
  },
24596
- /* updateLimboDocuments= */ false);
24603
+ /* limboResolutionEnabled= */ false);
24597
24604
  }
24598
24605
  else {
24599
24606
  // No effect, just return a no-op ViewChange.
@@ -24687,7 +24694,7 @@ class View {
24687
24694
  this._syncedDocuments = queryResult.remoteKeys;
24688
24695
  this.limboDocuments = documentKeySet();
24689
24696
  const docChanges = this.computeDocChanges(queryResult.documents);
24690
- return this.applyChanges(docChanges, /*updateLimboDocuments=*/ true);
24697
+ return this.applyChanges(docChanges, /* limboResolutionEnabled= */ true);
24691
24698
  }
24692
24699
  /**
24693
24700
  * Returns a view snapshot as if this query was just listened to. Contains
@@ -24895,7 +24902,7 @@ async function initializeViewAndComputeSnapshot(syncEngineImpl, query, targetId,
24895
24902
  const viewDocChanges = view.computeDocChanges(queryResult.documents);
24896
24903
  const synthesizedTargetChange = TargetChange.createSynthesizedTargetChangeForCurrentChange(targetId, current && syncEngineImpl.onlineState !== "Offline" /* OnlineState.Offline */, resumeToken);
24897
24904
  const viewChange = view.applyChanges(viewDocChanges,
24898
- /* updateLimboDocuments= */ syncEngineImpl.isPrimaryClient, synthesizedTargetChange);
24905
+ /* limboResolutionEnabled= */ syncEngineImpl.isPrimaryClient, synthesizedTargetChange);
24899
24906
  updateTrackedLimbos(syncEngineImpl, targetId, viewChange.limboChanges);
24900
24907
  const data = new QueryView(query, targetId, view);
24901
24908
  syncEngineImpl.queryViewsByQuery.set(query, data);
@@ -25336,8 +25343,9 @@ async function applyDocChanges(syncEngineImpl, queryView, changes, remoteEvent)
25336
25343
  });
25337
25344
  }
25338
25345
  const targetChange = remoteEvent && remoteEvent.targetChanges.get(queryView.targetId);
25346
+ const targetIsPendingReset = remoteEvent && remoteEvent.targetMismatches.get(queryView.targetId) != null;
25339
25347
  const viewChange = queryView.view.applyChanges(viewDocChanges,
25340
- /* updateLimboDocuments= */ syncEngineImpl.isPrimaryClient, targetChange);
25348
+ /* limboResolutionEnabled= */ syncEngineImpl.isPrimaryClient, targetChange, targetIsPendingReset);
25341
25349
  updateTrackedLimbos(syncEngineImpl, queryView.targetId, viewChange.limboChanges);
25342
25350
  return viewChange.snapshot;
25343
25351
  }
@@ -27078,7 +27086,7 @@ async function executeQueryFromCache(localStore, query, result) {
27078
27086
  const view = new View(query, queryResult.remoteKeys);
27079
27087
  const viewDocChanges = view.computeDocChanges(queryResult.documents);
27080
27088
  const viewChange = view.applyChanges(viewDocChanges,
27081
- /* updateLimboDocuments= */ false);
27089
+ /* limboResolutionEnabled= */ false);
27082
27090
  result.resolve(viewChange.snapshot);
27083
27091
  }
27084
27092
  catch (e) {