@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.
@@ -9,7 +9,7 @@ import * as grpc from '@grpc/grpc-js';
9
9
  import * as protoLoader from '@grpc/proto-loader';
10
10
 
11
11
  const name = "@firebase/firestore";
12
- const version$1 = "4.3.2-canary.b782bb270";
12
+ const version$1 = "4.3.2-canary.e9ff107ee";
13
13
 
14
14
  /**
15
15
  * @license
@@ -62,7 +62,7 @@ User.GOOGLE_CREDENTIALS = new User('google-credentials-uid');
62
62
  User.FIRST_PARTY = new User('first-party-uid');
63
63
  User.MOCK_USER = new User('mock-user');
64
64
 
65
- const version = "10.6.0-canary.b782bb270";
65
+ const version = "10.6.0-canary.e9ff107ee";
66
66
 
67
67
  /**
68
68
  * @license
@@ -8313,6 +8313,7 @@ class TargetState {
8313
8313
  }
8314
8314
  recordTargetResponse() {
8315
8315
  this.pendingResponses -= 1;
8316
+ hardAssert(this.pendingResponses >= 0);
8316
8317
  }
8317
8318
  markCurrent() {
8318
8319
  this._hasPendingChanges = true;
@@ -24511,14 +24512,17 @@ class View {
24511
24512
  * Updates the view with the given ViewDocumentChanges and optionally updates
24512
24513
  * limbo docs and sync state from the provided target change.
24513
24514
  * @param docChanges - The set of changes to make to the view's docs.
24514
- * @param updateLimboDocuments - Whether to update limbo documents based on
24515
+ * @param limboResolutionEnabled - Whether to update limbo documents based on
24515
24516
  * this change.
24516
24517
  * @param targetChange - A target change to apply for computing limbo docs and
24517
24518
  * sync state.
24519
+ * @param targetIsPendingReset - Whether the target is pending to reset due to
24520
+ * existence filter mismatch. If not explicitly specified, it is treated
24521
+ * equivalently to `false`.
24518
24522
  * @returns A new ViewChange with the given docs, changes, and sync state.
24519
24523
  */
24520
24524
  // PORTING NOTE: The iOS/Android clients always compute limbo document changes.
24521
- applyChanges(docChanges, updateLimboDocuments, targetChange) {
24525
+ applyChanges(docChanges, limboResolutionEnabled, targetChange, targetIsPendingReset) {
24522
24526
  const oldDocs = this.documentSet;
24523
24527
  this.documentSet = docChanges.documentSet;
24524
24528
  this.mutatedKeys = docChanges.mutatedKeys;
@@ -24529,10 +24533,13 @@ class View {
24529
24533
  this.docComparator(c1.doc, c2.doc));
24530
24534
  });
24531
24535
  this.applyTargetChange(targetChange);
24532
- const limboChanges = updateLimboDocuments
24536
+ targetIsPendingReset = targetIsPendingReset !== null && targetIsPendingReset !== void 0 ? targetIsPendingReset : false;
24537
+ const limboChanges = limboResolutionEnabled && !targetIsPendingReset
24533
24538
  ? this.updateLimboDocuments()
24534
24539
  : [];
24535
- const synced = this.limboDocuments.size === 0 && this.current;
24540
+ // We are at synced state if there is no limbo docs are waiting to be resolved, view is current
24541
+ // with the backend, and the query is not pending to reset due to existence filter mismatch.
24542
+ const synced = this.limboDocuments.size === 0 && this.current && !targetIsPendingReset;
24536
24543
  const newSyncState = synced ? 1 /* SyncState.Synced */ : 0 /* SyncState.Local */;
24537
24544
  const syncStateChanged = newSyncState !== this.syncState;
24538
24545
  this.syncState = newSyncState;
@@ -24568,7 +24575,7 @@ class View {
24568
24575
  mutatedKeys: this.mutatedKeys,
24569
24576
  needsRefill: false
24570
24577
  },
24571
- /* updateLimboDocuments= */ false);
24578
+ /* limboResolutionEnabled= */ false);
24572
24579
  }
24573
24580
  else {
24574
24581
  // No effect, just return a no-op ViewChange.
@@ -24662,7 +24669,7 @@ class View {
24662
24669
  this._syncedDocuments = queryResult.remoteKeys;
24663
24670
  this.limboDocuments = documentKeySet();
24664
24671
  const docChanges = this.computeDocChanges(queryResult.documents);
24665
- return this.applyChanges(docChanges, /*updateLimboDocuments=*/ true);
24672
+ return this.applyChanges(docChanges, /* limboResolutionEnabled= */ true);
24666
24673
  }
24667
24674
  /**
24668
24675
  * Returns a view snapshot as if this query was just listened to. Contains
@@ -24870,7 +24877,7 @@ async function initializeViewAndComputeSnapshot(syncEngineImpl, query, targetId,
24870
24877
  const viewDocChanges = view.computeDocChanges(queryResult.documents);
24871
24878
  const synthesizedTargetChange = TargetChange.createSynthesizedTargetChangeForCurrentChange(targetId, current && syncEngineImpl.onlineState !== "Offline" /* OnlineState.Offline */, resumeToken);
24872
24879
  const viewChange = view.applyChanges(viewDocChanges,
24873
- /* updateLimboDocuments= */ syncEngineImpl.isPrimaryClient, synthesizedTargetChange);
24880
+ /* limboResolutionEnabled= */ syncEngineImpl.isPrimaryClient, synthesizedTargetChange);
24874
24881
  updateTrackedLimbos(syncEngineImpl, targetId, viewChange.limboChanges);
24875
24882
  const data = new QueryView(query, targetId, view);
24876
24883
  syncEngineImpl.queryViewsByQuery.set(query, data);
@@ -25311,8 +25318,9 @@ async function applyDocChanges(syncEngineImpl, queryView, changes, remoteEvent)
25311
25318
  });
25312
25319
  }
25313
25320
  const targetChange = remoteEvent && remoteEvent.targetChanges.get(queryView.targetId);
25321
+ const targetIsPendingReset = remoteEvent && remoteEvent.targetMismatches.get(queryView.targetId) != null;
25314
25322
  const viewChange = queryView.view.applyChanges(viewDocChanges,
25315
- /* updateLimboDocuments= */ syncEngineImpl.isPrimaryClient, targetChange);
25323
+ /* limboResolutionEnabled= */ syncEngineImpl.isPrimaryClient, targetChange, targetIsPendingReset);
25316
25324
  updateTrackedLimbos(syncEngineImpl, queryView.targetId, viewChange.limboChanges);
25317
25325
  return viewChange.snapshot;
25318
25326
  }
@@ -27053,7 +27061,7 @@ async function executeQueryFromCache(localStore, query, result) {
27053
27061
  const view = new View(query, queryResult.remoteKeys);
27054
27062
  const viewDocChanges = view.computeDocChanges(queryResult.documents);
27055
27063
  const viewChange = view.applyChanges(viewDocChanges,
27056
- /* updateLimboDocuments= */ false);
27064
+ /* limboResolutionEnabled= */ false);
27057
27065
  result.resolve(viewChange.snapshot);
27058
27066
  }
27059
27067
  catch (e) {