@firebase/firestore 3.6.0 → 3.7.0-20221010190246

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.
Files changed (39) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/firestore/src/core/view.d.ts +1 -0
  3. package/dist/firestore/src/core/view_snapshot.d.ts +3 -2
  4. package/dist/firestore/src/remote/remote_event.d.ts +2 -2
  5. package/dist/firestore/test/util/api_helpers.d.ts +1 -1
  6. package/dist/index.esm2017.js +38 -36
  7. package/dist/index.esm2017.js.map +1 -1
  8. package/dist/index.esm5.js +132 -130
  9. package/dist/index.esm5.js.map +1 -1
  10. package/dist/index.node.cjs.js +29 -21
  11. package/dist/index.node.cjs.js.map +1 -1
  12. package/dist/index.node.mjs +29 -21
  13. package/dist/index.node.mjs.map +1 -1
  14. package/dist/index.rn.js +38 -36
  15. package/dist/index.rn.js.map +1 -1
  16. package/dist/internal.d.ts +5 -4
  17. package/dist/lite/firestore/src/core/view.d.ts +1 -0
  18. package/dist/lite/firestore/src/core/view_snapshot.d.ts +3 -2
  19. package/dist/lite/firestore/src/remote/remote_event.d.ts +2 -2
  20. package/dist/lite/firestore/test/util/api_helpers.d.ts +1 -1
  21. package/dist/lite/index.browser.esm2017.js +2 -2
  22. package/dist/lite/index.browser.esm2017.js.map +1 -1
  23. package/dist/lite/index.browser.esm5.js +2 -2
  24. package/dist/lite/index.browser.esm5.js.map +1 -1
  25. package/dist/lite/index.node.cjs.js +2 -2
  26. package/dist/lite/index.node.mjs +2 -2
  27. package/dist/lite/index.node.mjs.map +1 -1
  28. package/dist/lite/index.rn.esm2017.js +2 -2
  29. package/dist/lite/index.rn.esm2017.js.map +1 -1
  30. package/dist/lite/packages/firestore/src/core/view.d.ts +1 -0
  31. package/dist/lite/packages/firestore/src/core/view_snapshot.d.ts +3 -2
  32. package/dist/lite/packages/firestore/src/remote/remote_event.d.ts +2 -2
  33. package/dist/lite/packages/firestore/test/util/api_helpers.d.ts +1 -1
  34. package/dist/packages/firestore/src/core/view.d.ts +1 -0
  35. package/dist/packages/firestore/src/core/view_snapshot.d.ts +3 -2
  36. package/dist/packages/firestore/src/remote/remote_event.d.ts +2 -2
  37. package/dist/packages/firestore/test/util/api_helpers.d.ts +1 -1
  38. package/dist/private.d.ts +5 -4
  39. package/package.json +8 -8
@@ -8,7 +8,7 @@ import * as grpc from '@grpc/grpc-js';
8
8
  import * as protoLoader from '@grpc/proto-loader';
9
9
 
10
10
  const name = "@firebase/firestore";
11
- const version$1 = "3.6.0";
11
+ const version$1 = "3.7.0-20221010190246";
12
12
 
13
13
  /**
14
14
  * @license
@@ -61,7 +61,7 @@ User.GOOGLE_CREDENTIALS = new User('google-credentials-uid');
61
61
  User.FIRST_PARTY = new User('first-party-uid');
62
62
  User.MOCK_USER = new User('mock-user');
63
63
 
64
- const version = "9.11.0";
64
+ const version = "9.12.0-20221010190246";
65
65
 
66
66
  /**
67
67
  * @license
@@ -7566,9 +7566,9 @@ class RemoteEvent {
7566
7566
  * CURRENT status change to a View, for queries executed in a different tab.
7567
7567
  */
7568
7568
  // PORTING NOTE: Multi-tab only
7569
- static createSynthesizedRemoteEventForCurrentChange(targetId, current) {
7569
+ static createSynthesizedRemoteEventForCurrentChange(targetId, current, resumeToken) {
7570
7570
  const targetChanges = new Map();
7571
- targetChanges.set(targetId, TargetChange.createSynthesizedTargetChangeForCurrentChange(targetId, current));
7571
+ targetChanges.set(targetId, TargetChange.createSynthesizedTargetChangeForCurrentChange(targetId, current, resumeToken));
7572
7572
  return new RemoteEvent(SnapshotVersion.min(), targetChanges, targetIdSet(), mutableDocumentMap(), documentKeySet());
7573
7573
  }
7574
7574
  }
@@ -7621,8 +7621,8 @@ class TargetChange {
7621
7621
  * apply a CURRENT status change to a View (for queries executed in a different
7622
7622
  * tab) or for new queries (to raise snapshots with correct CURRENT status).
7623
7623
  */
7624
- static createSynthesizedTargetChangeForCurrentChange(targetId, current) {
7625
- return new TargetChange(ByteString.EMPTY_BYTE_STRING, current, documentKeySet(), documentKeySet(), documentKeySet());
7624
+ static createSynthesizedTargetChangeForCurrentChange(targetId, current, resumeToken) {
7625
+ return new TargetChange(resumeToken, current, documentKeySet(), documentKeySet(), documentKeySet());
7626
7626
  }
7627
7627
  }
7628
7628
 
@@ -22337,7 +22337,7 @@ class DocumentChangeSet {
22337
22337
  }
22338
22338
  }
22339
22339
  class ViewSnapshot {
22340
- constructor(query, docs, oldDocs, docChanges, mutatedKeys, fromCache, syncStateChanged, excludesMetadataChanges) {
22340
+ constructor(query, docs, oldDocs, docChanges, mutatedKeys, fromCache, syncStateChanged, excludesMetadataChanges, hasCachedResults) {
22341
22341
  this.query = query;
22342
22342
  this.docs = docs;
22343
22343
  this.oldDocs = oldDocs;
@@ -22346,22 +22346,24 @@ class ViewSnapshot {
22346
22346
  this.fromCache = fromCache;
22347
22347
  this.syncStateChanged = syncStateChanged;
22348
22348
  this.excludesMetadataChanges = excludesMetadataChanges;
22349
+ this.hasCachedResults = hasCachedResults;
22349
22350
  }
22350
22351
  /** Returns a view snapshot as if all documents in the snapshot were added. */
22351
- static fromInitialDocuments(query, documents, mutatedKeys, fromCache) {
22352
+ static fromInitialDocuments(query, documents, mutatedKeys, fromCache, hasCachedResults) {
22352
22353
  const changes = [];
22353
22354
  documents.forEach(doc => {
22354
22355
  changes.push({ type: 0 /* Added */, doc });
22355
22356
  });
22356
22357
  return new ViewSnapshot(query, documents, DocumentSet.emptySet(documents), changes, mutatedKeys, fromCache,
22357
22358
  /* syncStateChanged= */ true,
22358
- /* excludesMetadataChanges= */ false);
22359
+ /* excludesMetadataChanges= */ false, hasCachedResults);
22359
22360
  }
22360
22361
  get hasPendingWrites() {
22361
22362
  return !this.mutatedKeys.isEmpty();
22362
22363
  }
22363
22364
  isEqual(other) {
22364
22365
  if (this.fromCache !== other.fromCache ||
22366
+ this.hasCachedResults !== other.hasCachedResults ||
22365
22367
  this.syncStateChanged !== other.syncStateChanged ||
22366
22368
  !this.mutatedKeys.isEqual(other.mutatedKeys) ||
22367
22369
  !queryEquals(this.query, other.query) ||
@@ -22566,7 +22568,7 @@ class QueryListener {
22566
22568
  }
22567
22569
  }
22568
22570
  snap = new ViewSnapshot(snap.query, snap.docs, snap.oldDocs, docChanges, snap.mutatedKeys, snap.fromCache, snap.syncStateChanged,
22569
- /* excludesMetadataChanges= */ true);
22571
+ /* excludesMetadataChanges= */ true, snap.hasCachedResults);
22570
22572
  }
22571
22573
  let raisedEvent = false;
22572
22574
  if (!this.raisedInitialEvent) {
@@ -22610,8 +22612,11 @@ class QueryListener {
22610
22612
  if (this.options.waitForSyncWhenOnline && maybeOnline) {
22611
22613
  return false;
22612
22614
  }
22613
- // Raise data from cache if we have any documents or we are offline
22614
- return !snap.docs.isEmpty() || onlineState === "Offline" /* Offline */;
22615
+ // Raise data from cache if we have any documents, have cached results before,
22616
+ // or we are offline.
22617
+ return (!snap.docs.isEmpty() ||
22618
+ snap.hasCachedResults ||
22619
+ onlineState === "Offline" /* Offline */);
22615
22620
  }
22616
22621
  shouldRaiseEvent(snap) {
22617
22622
  // We don't need to handle includeDocumentMetadataChanges here because
@@ -22631,7 +22636,7 @@ class QueryListener {
22631
22636
  return false;
22632
22637
  }
22633
22638
  raiseInitialEvent(snap) {
22634
- snap = ViewSnapshot.fromInitialDocuments(snap.query, snap.docs, snap.mutatedKeys, snap.fromCache);
22639
+ snap = ViewSnapshot.fromInitialDocuments(snap.query, snap.docs, snap.mutatedKeys, snap.fromCache, snap.hasCachedResults);
22635
22640
  this.raisedInitialEvent = true;
22636
22641
  this.queryObserver.next(snap);
22637
22642
  }
@@ -22868,6 +22873,7 @@ class View {
22868
22873
  this.query = query;
22869
22874
  this._syncedDocuments = _syncedDocuments;
22870
22875
  this.syncState = null;
22876
+ this.hasCachedResults = false;
22871
22877
  /**
22872
22878
  * A flag whether the view is current with the backend. A view is considered
22873
22879
  * current after it has seen the current flag from the backend and did not
@@ -23062,7 +23068,9 @@ class View {
23062
23068
  }
23063
23069
  else {
23064
23070
  const snap = new ViewSnapshot(this.query, docChanges.documentSet, oldDocs, changes, docChanges.mutatedKeys, newSyncState === 0 /* Local */, syncStateChanged,
23065
- /* excludesMetadataChanges= */ false);
23071
+ /* excludesMetadataChanges= */ false, targetChange
23072
+ ? targetChange.resumeToken.approximateByteSize() > 0
23073
+ : false);
23066
23074
  return {
23067
23075
  snapshot: snap,
23068
23076
  limboChanges
@@ -23189,7 +23197,7 @@ class View {
23189
23197
  */
23190
23198
  // PORTING NOTE: Multi-tab only.
23191
23199
  computeInitialSnapshot() {
23192
- return ViewSnapshot.fromInitialDocuments(this.query, this.documentSet, this.mutatedKeys, this.syncState === 0 /* Local */);
23200
+ return ViewSnapshot.fromInitialDocuments(this.query, this.documentSet, this.mutatedKeys, this.syncState === 0 /* Local */, this.hasCachedResults);
23193
23201
  }
23194
23202
  }
23195
23203
  function compareChangeType(c1, c2) {
@@ -23369,7 +23377,7 @@ async function syncEngineListen(syncEngine, query) {
23369
23377
  }
23370
23378
  const status = syncEngineImpl.sharedClientState.addLocalQueryTarget(targetData.targetId);
23371
23379
  targetId = targetData.targetId;
23372
- viewSnapshot = await initializeViewAndComputeSnapshot(syncEngineImpl, query, targetId, status === 'current');
23380
+ viewSnapshot = await initializeViewAndComputeSnapshot(syncEngineImpl, query, targetId, status === 'current', targetData.resumeToken);
23373
23381
  }
23374
23382
  return viewSnapshot;
23375
23383
  }
@@ -23377,7 +23385,7 @@ async function syncEngineListen(syncEngine, query) {
23377
23385
  * Registers a view for a previously unknown query and computes its initial
23378
23386
  * snapshot.
23379
23387
  */
23380
- async function initializeViewAndComputeSnapshot(syncEngineImpl, query, targetId, current) {
23388
+ async function initializeViewAndComputeSnapshot(syncEngineImpl, query, targetId, current, resumeToken) {
23381
23389
  // PORTING NOTE: On Web only, we inject the code that registers new Limbo
23382
23390
  // targets based on view changes. This allows us to only depend on Limbo
23383
23391
  // changes when user code includes queries.
@@ -23386,7 +23394,7 @@ async function initializeViewAndComputeSnapshot(syncEngineImpl, query, targetId,
23386
23394
  /* usePreviousResults= */ true);
23387
23395
  const view = new View(query, queryResult.remoteKeys);
23388
23396
  const viewDocChanges = view.computeDocChanges(queryResult.documents);
23389
- const synthesizedTargetChange = TargetChange.createSynthesizedTargetChangeForCurrentChange(targetId, current && syncEngineImpl.onlineState !== "Offline" /* Offline */);
23397
+ const synthesizedTargetChange = TargetChange.createSynthesizedTargetChangeForCurrentChange(targetId, current && syncEngineImpl.onlineState !== "Offline" /* Offline */, resumeToken);
23390
23398
  const viewChange = view.applyChanges(viewDocChanges,
23391
23399
  /* updateLimboDocuments= */ syncEngineImpl.isPrimaryClient, synthesizedTargetChange);
23392
23400
  updateTrackedLimbos(syncEngineImpl, targetId, viewChange.limboChanges);
@@ -24016,7 +24024,7 @@ async function synchronizeQueryViewsAndRaiseSnapshots(syncEngine, targets, trans
24016
24024
  const target = await localStoreGetCachedTarget(syncEngineImpl.localStore, targetId);
24017
24025
  targetData = await localStoreAllocateTarget(syncEngineImpl.localStore, target);
24018
24026
  await initializeViewAndComputeSnapshot(syncEngineImpl, synthesizeTargetToQuery(target), targetId,
24019
- /*current=*/ false);
24027
+ /*current=*/ false, targetData.resumeToken);
24020
24028
  }
24021
24029
  activeQueries.push(targetData);
24022
24030
  }
@@ -24059,7 +24067,7 @@ async function syncEngineApplyTargetState(syncEngine, targetId, state, error) {
24059
24067
  case 'current':
24060
24068
  case 'not-current': {
24061
24069
  const changes = await localStoreGetNewDocumentChanges(syncEngineImpl.localStore, queryCollectionGroup(query[0]));
24062
- const synthesizedRemoteEvent = RemoteEvent.createSynthesizedRemoteEventForCurrentChange(targetId, state === 'current');
24070
+ const synthesizedRemoteEvent = RemoteEvent.createSynthesizedRemoteEventForCurrentChange(targetId, state === 'current', ByteString.EMPTY_BYTE_STRING);
24063
24071
  await syncEngineEmitNewSnapsAndNotifyLocalStore(syncEngineImpl, changes, synthesizedRemoteEvent);
24064
24072
  break;
24065
24073
  }
@@ -24089,7 +24097,7 @@ async function syncEngineApplyActiveTargetsChange(syncEngine, added, removed) {
24089
24097
  const target = await localStoreGetCachedTarget(syncEngineImpl.localStore, targetId);
24090
24098
  const targetData = await localStoreAllocateTarget(syncEngineImpl.localStore, target);
24091
24099
  await initializeViewAndComputeSnapshot(syncEngineImpl, synthesizeTargetToQuery(target), targetData.targetId,
24092
- /*current=*/ false);
24100
+ /*current=*/ false, targetData.resumeToken);
24093
24101
  remoteStoreListen(syncEngineImpl.remoteStore, targetData);
24094
24102
  }
24095
24103
  for (const targetId of removed) {