@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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @firebase/firestore
2
2
 
3
+ ## 3.7.0-20221010190246
4
+
5
+ ### Minor Changes
6
+
7
+ - [`397317b53`](https://github.com/firebase/firebase-js-sdk/commit/397317b53c4d9d8aee761f566adf3616aef844ed) [#6643](https://github.com/firebase/firebase-js-sdk/pull/6643) - Set withCredentials=true when making requests via non-streaming RPCs, like is done for streaming RPCs.
8
+
9
+ ### Patch Changes
10
+
11
+ - [`0a112bd2a`](https://github.com/firebase/firebase-js-sdk/commit/0a112bd2aee2e709d6733b1a36876e6fae1e347f) [#6624](https://github.com/firebase/firebase-js-sdk/pull/6624) (fixes [#5873](https://github.com/firebase/firebase-js-sdk/issues/5873)) - Fix Firestore failing to raise initial snapshot from empty local cache result
12
+
13
+ - Updated dependencies [[`397317b53`](https://github.com/firebase/firebase-js-sdk/commit/397317b53c4d9d8aee761f566adf3616aef844ed), [`29d034072`](https://github.com/firebase/firebase-js-sdk/commit/29d034072c20af394ce384e42aa10a37d5dfcb18)]:
14
+ - @firebase/webchannel-wrapper@0.8.0-20221010190246
15
+ - @firebase/util@1.7.1-20221010190246
16
+ - @firebase/app@0.8.1-20221010190246
17
+ - @firebase/component@0.5.19-20221010190246
18
+
3
19
  ## 3.6.0
4
20
 
5
21
  ### Minor Changes
@@ -59,6 +59,7 @@ export declare class View {
59
59
  /** Documents included in the remote target */
60
60
  private _syncedDocuments;
61
61
  private syncState;
62
+ private hasCachedResults;
62
63
  /**
63
64
  * A flag whether the view is current with the backend. A view is considered
64
65
  * current after it has seen the current flag from the backend and did not
@@ -50,9 +50,10 @@ export declare class ViewSnapshot {
50
50
  readonly fromCache: boolean;
51
51
  readonly syncStateChanged: boolean;
52
52
  readonly excludesMetadataChanges: boolean;
53
- constructor(query: Query, docs: DocumentSet, oldDocs: DocumentSet, docChanges: DocumentViewChange[], mutatedKeys: DocumentKeySet, fromCache: boolean, syncStateChanged: boolean, excludesMetadataChanges: boolean);
53
+ readonly hasCachedResults: boolean;
54
+ constructor(query: Query, docs: DocumentSet, oldDocs: DocumentSet, docChanges: DocumentViewChange[], mutatedKeys: DocumentKeySet, fromCache: boolean, syncStateChanged: boolean, excludesMetadataChanges: boolean, hasCachedResults: boolean);
54
55
  /** Returns a view snapshot as if all documents in the snapshot were added. */
55
- static fromInitialDocuments(query: Query, documents: DocumentSet, mutatedKeys: DocumentKeySet, fromCache: boolean): ViewSnapshot;
56
+ static fromInitialDocuments(query: Query, documents: DocumentSet, mutatedKeys: DocumentKeySet, fromCache: boolean, hasCachedResults: boolean): ViewSnapshot;
56
57
  get hasPendingWrites(): boolean;
57
58
  isEqual(other: ViewSnapshot): boolean;
58
59
  }
@@ -76,7 +76,7 @@ export declare class RemoteEvent {
76
76
  * used to create a synthesized RemoteEvent that can be used to apply a
77
77
  * CURRENT status change to a View, for queries executed in a different tab.
78
78
  */
79
- static createSynthesizedRemoteEventForCurrentChange(targetId: TargetId, current: boolean): RemoteEvent;
79
+ static createSynthesizedRemoteEventForCurrentChange(targetId: TargetId, current: boolean, resumeToken: ByteString): RemoteEvent;
80
80
  }
81
81
  /**
82
82
  * A TargetChange specifies the set of changes for a specific target as part of
@@ -149,5 +149,5 @@ export declare class TargetChange {
149
149
  * apply a CURRENT status change to a View (for queries executed in a different
150
150
  * tab) or for new queries (to raise snapshots with correct CURRENT status).
151
151
  */
152
- static createSynthesizedTargetChangeForCurrentChange(targetId: TargetId, current: boolean): TargetChange;
152
+ static createSynthesizedTargetChangeForCurrentChange(targetId: TargetId, current: boolean, resumeToken: ByteString): TargetChange;
153
153
  }
@@ -46,4 +46,4 @@ export declare function querySnapshot(path: string, oldDocs: {
46
46
  [key: string]: JsonObject<unknown>;
47
47
  }, docsToAdd: {
48
48
  [key: string]: JsonObject<unknown>;
49
- }, mutatedKeys: DocumentKeySet, fromCache: boolean, syncStateChanged: boolean): QuerySnapshot;
49
+ }, mutatedKeys: DocumentKeySet, fromCache: boolean, syncStateChanged: boolean, hasCachedResults?: boolean): QuerySnapshot;
@@ -66,7 +66,7 @@ P.MOCK_USER = new P("mock-user");
66
66
  * See the License for the specific language governing permissions and
67
67
  * limitations under the License.
68
68
  */
69
- let v = "9.11.0";
69
+ let v = "9.12.0-20221010190246";
70
70
 
71
71
  /**
72
72
  * @license
@@ -5116,9 +5116,9 @@ function _s() {
5116
5116
  * CURRENT status change to a View, for queries executed in a different tab.
5117
5117
  */
5118
5118
  // PORTING NOTE: Multi-tab only
5119
- static createSynthesizedRemoteEventForCurrentChange(t, e) {
5120
- const n = new Map;
5121
- return n.set(t, ms.createSynthesizedTargetChangeForCurrentChange(t, e)), new ws(st.min(), n, _s(), ss(), fs());
5119
+ static createSynthesizedRemoteEventForCurrentChange(t, e, n) {
5120
+ const s = new Map;
5121
+ return s.set(t, ms.createSynthesizedTargetChangeForCurrentChange(t, e, n)), new ws(st.min(), s, _s(), ss(), fs());
5122
5122
  }
5123
5123
  }
5124
5124
 
@@ -5166,8 +5166,8 @@ function _s() {
5166
5166
  * This method is used to create a synthesized TargetChanges that can be used to
5167
5167
  * apply a CURRENT status change to a View (for queries executed in a different
5168
5168
  * tab) or for new queries (to raise snapshots with correct CURRENT status).
5169
- */ static createSynthesizedTargetChangeForCurrentChange(t, e) {
5170
- return new ms(Wt.EMPTY_BYTE_STRING, e, fs(), fs(), fs());
5169
+ */ static createSynthesizedTargetChangeForCurrentChange(t, e, n) {
5170
+ return new ms(n, e, fs(), fs(), fs());
5171
5171
  }
5172
5172
  }
5173
5173
 
@@ -12519,7 +12519,7 @@ class {
12519
12519
  fo(t, e, n, s) {
12520
12520
  return new Promise(((i, r) => {
12521
12521
  const o = new XhrIo;
12522
- o.listenOnce(EventType.COMPLETE, (() => {
12522
+ o.setWithCredentials(!0), o.listenOnce(EventType.COMPLETE, (() => {
12523
12523
  try {
12524
12524
  switch (o.getLastErrorCode()) {
12525
12525
  case ErrorCode.NO_ERROR:
@@ -14035,26 +14035,27 @@ class Mu {
14035
14035
  }
14036
14036
 
14037
14037
  class Lu {
14038
- constructor(t, e, n, s, i, r, o, u) {
14038
+ constructor(t, e, n, s, i, r, o, u, c) {
14039
14039
  this.query = t, this.docs = e, this.oldDocs = n, this.docChanges = s, this.mutatedKeys = i,
14040
- this.fromCache = r, this.syncStateChanged = o, this.excludesMetadataChanges = u;
14040
+ this.fromCache = r, this.syncStateChanged = o, this.excludesMetadataChanges = u,
14041
+ this.hasCachedResults = c;
14041
14042
  }
14042
- /** Returns a view snapshot as if all documents in the snapshot were added. */ static fromInitialDocuments(t, e, n, s) {
14043
- const i = [];
14043
+ /** Returns a view snapshot as if all documents in the snapshot were added. */ static fromInitialDocuments(t, e, n, s, i) {
14044
+ const r = [];
14044
14045
  return e.forEach((t => {
14045
- i.push({
14046
+ r.push({
14046
14047
  type: 0 /* Added */ ,
14047
14048
  doc: t
14048
14049
  });
14049
- })), new Lu(t, e, $u.emptySet(e), i, n, s,
14050
+ })), new Lu(t, e, $u.emptySet(e), r, n, s,
14050
14051
  /* syncStateChanged= */ !0,
14051
- /* excludesMetadataChanges= */ !1);
14052
+ /* excludesMetadataChanges= */ !1, i);
14052
14053
  }
14053
14054
  get hasPendingWrites() {
14054
14055
  return !this.mutatedKeys.isEmpty();
14055
14056
  }
14056
14057
  isEqual(t) {
14057
- if (!(this.fromCache === t.fromCache && this.syncStateChanged === t.syncStateChanged && this.mutatedKeys.isEqual(t.mutatedKeys) && hn(this.query, t.query) && this.docs.isEqual(t.docs) && this.oldDocs.isEqual(t.oldDocs))) return !1;
14058
+ if (!(this.fromCache === t.fromCache && this.hasCachedResults === t.hasCachedResults && this.syncStateChanged === t.syncStateChanged && this.mutatedKeys.isEqual(t.mutatedKeys) && hn(this.query, t.query) && this.docs.isEqual(t.docs) && this.oldDocs.isEqual(t.oldDocs))) return !1;
14058
14059
  const e = this.docChanges, n = t.docChanges;
14059
14060
  if (e.length !== n.length) return !1;
14060
14061
  for (let t = 0; t < e.length; t++) if (e[t].type !== n[t].type || !e[t].doc.isEqual(n[t].doc)) return !1;
@@ -14174,7 +14175,7 @@ function Wu(t) {
14174
14175
  const e = [];
14175
14176
  for (const n of t.docChanges) 3 /* Metadata */ !== n.type && e.push(n);
14176
14177
  t = new Lu(t.query, t.docs, t.oldDocs, e, t.mutatedKeys, t.fromCache, t.syncStateChanged,
14177
- /* excludesMetadataChanges= */ !0);
14178
+ /* excludesMetadataChanges= */ !0, t.hasCachedResults);
14178
14179
  }
14179
14180
  let e = !1;
14180
14181
  return this.Su ? this.Cu(t) && (this.Vu.next(t), e = !0) : this.xu(t, this.onlineState) && (this.Nu(t),
@@ -14197,8 +14198,9 @@ function Wu(t) {
14197
14198
  const n = "Offline" /* Offline */ !== e;
14198
14199
  // Don't raise the event if we're online, aren't synced yet (checked
14199
14200
  // above) and are waiting for a sync.
14200
- return (!this.options.ku || !n) && (!t.docs.isEmpty() || "Offline" /* Offline */ === e);
14201
- // Raise data from cache if we have any documents or we are offline
14201
+ return (!this.options.ku || !n) && (!t.docs.isEmpty() || t.hasCachedResults || "Offline" /* Offline */ === e);
14202
+ // Raise data from cache if we have any documents, have cached results before,
14203
+ // or we are offline.
14202
14204
  }
14203
14205
  Cu(t) {
14204
14206
  // We don't need to handle includeDocumentMetadataChanges here because
@@ -14213,8 +14215,8 @@ function Wu(t) {
14213
14215
  // stripped out.
14214
14216
  }
14215
14217
  Nu(t) {
14216
- t = Lu.fromInitialDocuments(t.query, t.docs, t.mutatedKeys, t.fromCache), this.Su = !0,
14217
- this.Vu.next(t);
14218
+ t = Lu.fromInitialDocuments(t.query, t.docs, t.mutatedKeys, t.fromCache, t.hasCachedResults),
14219
+ this.Su = !0, this.Vu.next(t);
14218
14220
  }
14219
14221
  }
14220
14222
 
@@ -14392,7 +14394,7 @@ class tc {
14392
14394
  constructor(t,
14393
14395
  /** Documents included in the remote target */
14394
14396
  e) {
14395
- this.query = t, this.Uu = e, this.qu = null,
14397
+ this.query = t, this.Uu = e, this.qu = null, this.hasCachedResults = !1,
14396
14398
  /**
14397
14399
  * A flag whether the view is current with the backend. A view is considered
14398
14400
  * current after it has seen the current flag from the backend and did not
@@ -14546,7 +14548,7 @@ class tc {
14546
14548
  if (this.qu = o, 0 !== i.length || u) {
14547
14549
  return {
14548
14550
  snapshot: new Lu(this.query, t.Qu, s, i, t.mutatedKeys, 0 /* Local */ === o, u,
14549
- /* excludesMetadataChanges= */ !1),
14551
+ /* excludesMetadataChanges= */ !1, !!n && n.resumeToken.approximateByteSize() > 0),
14550
14552
  Xu: r
14551
14553
  };
14552
14554
  }
@@ -14638,7 +14640,7 @@ class tc {
14638
14640
  */
14639
14641
  // PORTING NOTE: Multi-tab only.
14640
14642
  ec() {
14641
- return Lu.fromInitialDocuments(this.query, this.Qu, this.mutatedKeys, 0 /* Local */ === this.qu);
14643
+ return Lu.fromInitialDocuments(this.query, this.Qu, this.mutatedKeys, 0 /* Local */ === this.qu, this.hasCachedResults);
14642
14644
  }
14643
14645
  }
14644
14646
 
@@ -14754,7 +14756,7 @@ async function rc(t, e) {
14754
14756
  const t = await Vo(n.localStore, cn(e));
14755
14757
  n.isPrimaryClient && hu(n.remoteStore, t);
14756
14758
  const r = n.sharedClientState.addLocalQueryTarget(t.targetId);
14757
- s = t.targetId, i = await oc(n, e, s, "current" === r);
14759
+ s = t.targetId, i = await oc(n, e, s, "current" === r, t.resumeToken);
14758
14760
  }
14759
14761
  return i;
14760
14762
  }
@@ -14762,7 +14764,7 @@ async function rc(t, e) {
14762
14764
  /**
14763
14765
  * Registers a view for a previously unknown query and computes its initial
14764
14766
  * snapshot.
14765
- */ async function oc(t, e, n, s) {
14767
+ */ async function oc(t, e, n, s, i) {
14766
14768
  // PORTING NOTE: On Web only, we inject the code that registers new Limbo
14767
14769
  // targets based on view changes. This allows us to only depend on Limbo
14768
14770
  // changes when user code includes queries.
@@ -14778,12 +14780,12 @@ async function rc(t, e) {
14778
14780
  /* updateLimboDocuments= */ t.isPrimaryClient, r);
14779
14781
  return pc(t, e.targetId, o.Xu), o.snapshot;
14780
14782
  }(t, e, n, s);
14781
- const i = await Do(t.localStore, e,
14782
- /* usePreviousResults= */ !0), r = new ec(e, i.Hi), o = r.Wu(i.documents), u = ms.createSynthesizedTargetChangeForCurrentChange(n, s && "Offline" /* Offline */ !== t.onlineState), c = r.applyChanges(o,
14783
- /* updateLimboDocuments= */ t.isPrimaryClient, u);
14784
- pc(t, n, c.Xu);
14785
- const a = new nc(e, n, r);
14786
- return t.ic.set(e, a), t.rc.has(n) ? t.rc.get(n).push(e) : t.rc.set(n, [ e ]), c.snapshot;
14783
+ const r = await Do(t.localStore, e,
14784
+ /* usePreviousResults= */ !0), o = new ec(e, r.Hi), u = o.Wu(r.documents), c = ms.createSynthesizedTargetChangeForCurrentChange(n, s && "Offline" /* Offline */ !== t.onlineState, i), a = o.applyChanges(u,
14785
+ /* updateLimboDocuments= */ t.isPrimaryClient, c);
14786
+ pc(t, n, a.Xu);
14787
+ const h = new nc(e, n, o);
14788
+ return t.ic.set(e, h), t.rc.has(n) ? t.rc.get(n).push(e) : t.rc.set(n, [ e ]), a.snapshot;
14787
14789
  }
14788
14790
 
14789
14791
  /** Stops listening to the query. */ async function uc(t, e) {
@@ -15287,7 +15289,7 @@ async function Sc(t, e, n) {
15287
15289
  // allocate the target in LocalStore and initialize a new View.
15288
15290
  const n = await Co(s.localStore, t);
15289
15291
  e = await Vo(s.localStore, n), await oc(s, Dc(n), t,
15290
- /*current=*/ !1);
15292
+ /*current=*/ !1, e.resumeToken);
15291
15293
  }
15292
15294
  i.push(e);
15293
15295
  }
@@ -15329,7 +15331,7 @@ async function xc(t, e, n, s) {
15329
15331
  case "current":
15330
15332
  case "not-current":
15331
15333
  {
15332
- const t = await xo(i.localStore, _n(r[0])), s = ws.createSynthesizedRemoteEventForCurrentChange(e, "current" === n);
15334
+ const t = await xo(i.localStore, _n(r[0])), s = ws.createSynthesizedRemoteEventForCurrentChange(e, "current" === n, Wt.EMPTY_BYTE_STRING);
15333
15335
  await Ec(i, t, s);
15334
15336
  break;
15335
15337
  }
@@ -15355,7 +15357,7 @@ async function xc(t, e, n, s) {
15355
15357
  }
15356
15358
  const e = await Co(s.localStore, t), n = await Vo(s.localStore, e);
15357
15359
  await oc(s, Dc(e), n.targetId,
15358
- /*current=*/ !1), hu(s.remoteStore, n);
15360
+ /*current=*/ !1, n.resumeToken), hu(s.remoteStore, n);
15359
15361
  }
15360
15362
  for (const t of n)
15361
15363
  // Check that the target is still active since the target might have been
@@ -19954,9 +19956,9 @@ function $l(t, e) {
19954
19956
  return s = Object.assign({
19955
19957
  useFetchStreams: e
19956
19958
  }, s), r._setSettings(s), r;
19957
- }), "PUBLIC").setMultipleInstances(!0)), registerVersion(b, "3.6.0", t),
19959
+ }), "PUBLIC").setMultipleInstances(!0)), registerVersion(b, "3.7.0-20221010190246", t),
19958
19960
  // BUILD_TARGET will be replaced by values like esm5, esm2017, cjs5, etc during the compilation
19959
- registerVersion(b, "3.6.0", "esm2017");
19961
+ registerVersion(b, "3.7.0-20221010190246", "esm2017");
19960
19962
  }();
19961
19963
 
19962
19964
  export { tl as AbstractUserDataWriter, aa as AggregateField, ha as AggregateQuerySnapshot, th as Bytes, Fa as CACHE_SIZE_UNLIMITED, ta as CollectionReference, Xc as DocumentReference, il as DocumentSnapshot, eh as FieldPath, sh as FieldValue, $a as Firestore, L as FirestoreError, ih as GeoPoint, Ma as LoadBundleTask, Zc as Query, Oh as QueryConstraint, rl as QueryDocumentSnapshot, ol as QuerySnapshot, sl as SnapshotMetadata, nt as Timestamp, Sl as Transaction, vl as WriteBatch, ne as _DatabaseId, ct as _DocumentKey, J as _EmptyAppCheckTokenProvider, K as _EmptyAuthCredentialsProvider, ut as _FieldPath, jc as _cast, F as _debugAssert, jt as _isBase64Available, N as _logWarn, qc as _validateIsNotUsedTogether, pl as addDoc, Rl as aggregateQuerySnapshotEqual, kl as arrayRemove, Nl as arrayUnion, ja as clearIndexedDbPersistence, ea as collection, na as collectionGroup, Yc as connectFirestoreEmulator, yl as deleteDoc, Cl as deleteField, Ha as disableNetwork, sa as doc, nh as documentId, Ka as enableIndexedDbPersistence, Ga as enableMultiTabIndexedDbPersistence, za as enableNetwork, Hh as endAt, zh as endBefore, Ua as ensureFirestoreConfigured, El as executeWrite, bl as getCountFromServer, al as getDoc, ll as getDocFromCache, fl as getDocFromServer, dl as getDocs, _l as getDocsFromCache, wl as getDocsFromServer, La as getFirestore, Ol as increment, Ba as initializeFirestore, qh as limit, Kh as limitToLast, Ya as loadBundle, Xa as namedQuery, Il as onSnapshot, Tl as onSnapshotsInSync, Lh as orderBy, Mh as query, ra as queryEqual, ia as refEqual, Dl as runTransaction, xl as serverTimestamp, ml as setDoc, Fl as setIndexConfiguration, D as setLogLevel, cl as snapshotEqual, jh as startAfter, Qh as startAt, Ja as terminate, gl as updateDoc, Wa as waitForPendingWrites, $h as where, Ml as writeBatch };