@firebase/firestore 3.4.3-canary.4dd6abaea → 3.4.3-canary.67b6decbb
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/index.esm2017.js +701 -701
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +1093 -1093
- package/dist/index.node.cjs.js +2 -2
- package/dist/index.node.mjs +2 -2
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +713 -713
- package/dist/lite/index.browser.esm2017.js +2 -2
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.browser.esm5.js +2 -2
- package/dist/lite/index.node.cjs.js +2 -2
- package/dist/lite/index.node.mjs +2 -2
- package/dist/lite/index.node.mjs.map +1 -1
- package/dist/lite/index.rn.esm2017.js +2 -2
- package/dist/packages/firestore/dist/index.esm2017.d.ts +96 -96
- package/package.json +9 -9
package/dist/index.rn.js
CHANGED
|
@@ -2,9 +2,9 @@ import { _getProvider, getApp as t, _removeServiceInstance as e, _registerCompon
|
|
|
2
2
|
|
|
3
3
|
import { Component as r } from "@firebase/component";
|
|
4
4
|
|
|
5
|
-
import { Logger as o, LogLevel as
|
|
5
|
+
import { Logger as o, LogLevel as c } from "@firebase/logger";
|
|
6
6
|
|
|
7
|
-
import { FirebaseError as
|
|
7
|
+
import { FirebaseError as a, base64 as u, getUA as h, isIndexedDBAvailable as l, isSafari as f, isMobileCordova as d, isReactNative as w, isElectron as _, isIE as m, isUWP as g, isBrowserExtension as y, createMockUserToken as p, getModularInstance as T, deepEqual as E } from "@firebase/util";
|
|
8
8
|
|
|
9
9
|
import { XhrIo as I, EventType as A, ErrorCode as R, createWebChannelTransport as b, getStatEventTarget as P, FetchXmlHttpFactory as v, WebChannel as V, Event as S, Stat as D } from "@firebase/webchannel-wrapper";
|
|
10
10
|
|
|
@@ -70,7 +70,7 @@ N.MOCK_USER = new N("mock-user");
|
|
|
70
70
|
* See the License for the specific language governing permissions and
|
|
71
71
|
* limitations under the License.
|
|
72
72
|
*/
|
|
73
|
-
let k = "9.6.3-canary.
|
|
73
|
+
let k = "9.6.3-canary.67b6decbb";
|
|
74
74
|
|
|
75
75
|
/**
|
|
76
76
|
* @license
|
|
@@ -112,14 +112,14 @@ function $() {
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
function M(t, ...e) {
|
|
115
|
-
if (x.logLevel <=
|
|
115
|
+
if (x.logLevel <= c.DEBUG) {
|
|
116
116
|
const n = e.map(B);
|
|
117
117
|
x.debug(`Firestore (${k}): ${t}`, ...n);
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
function F(t, ...e) {
|
|
122
|
-
if (x.logLevel <=
|
|
122
|
+
if (x.logLevel <= c.ERROR) {
|
|
123
123
|
const n = e.map(B);
|
|
124
124
|
x.error(`Firestore (${k}): ${t}`, ...n);
|
|
125
125
|
}
|
|
@@ -128,7 +128,7 @@ function F(t, ...e) {
|
|
|
128
128
|
/**
|
|
129
129
|
* @internal
|
|
130
130
|
*/ function L(t, ...e) {
|
|
131
|
-
if (x.logLevel <=
|
|
131
|
+
if (x.logLevel <= c.WARN) {
|
|
132
132
|
const n = e.map(B);
|
|
133
133
|
x.warn(`Firestore (${k}): ${t}`, ...n);
|
|
134
134
|
}
|
|
@@ -356,7 +356,7 @@ e) {
|
|
|
356
356
|
DATA_LOSS: "data-loss"
|
|
357
357
|
};
|
|
358
358
|
|
|
359
|
-
/** An error returned by a Firestore operation. */ class W extends
|
|
359
|
+
/** An error returned by a Firestore operation. */ class W extends a {
|
|
360
360
|
/** @hideconstructor */
|
|
361
361
|
constructor(
|
|
362
362
|
/**
|
|
@@ -733,14 +733,14 @@ function ot(t, e) {
|
|
|
733
733
|
return t < e ? -1 : t > e ? 1 : 0;
|
|
734
734
|
}
|
|
735
735
|
|
|
736
|
-
/** Helper to compare arrays using isEqual(). */ function
|
|
736
|
+
/** Helper to compare arrays using isEqual(). */ function ct(t, e, n) {
|
|
737
737
|
return t.length === e.length && t.every(((t, s) => n(t, e[s])));
|
|
738
738
|
}
|
|
739
739
|
|
|
740
740
|
/**
|
|
741
741
|
* Returns the immediate lexicographically-following string. This is useful to
|
|
742
742
|
* construct an inclusive range for indexeddb iterators.
|
|
743
|
-
*/ function
|
|
743
|
+
*/ function at(t) {
|
|
744
744
|
// Return the input string, with an additional NUL byte appended.
|
|
745
745
|
return t + "\0";
|
|
746
746
|
}
|
|
@@ -1195,7 +1195,7 @@ const mt = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
1195
1195
|
return !1;
|
|
1196
1196
|
}
|
|
1197
1197
|
isEqual(t) {
|
|
1198
|
-
return
|
|
1198
|
+
return ct(this.fields, t.fields, ((t, e) => t.isEqual(e)));
|
|
1199
1199
|
}
|
|
1200
1200
|
}
|
|
1201
1201
|
|
|
@@ -1600,7 +1600,7 @@ function St(t) {
|
|
|
1600
1600
|
}(t, e);
|
|
1601
1601
|
|
|
1602
1602
|
case 9 /* ArrayValue */ :
|
|
1603
|
-
return
|
|
1603
|
+
return ct(t.arrayValue.values || [], e.arrayValue.values || [], xt);
|
|
1604
1604
|
|
|
1605
1605
|
case 10 /* ObjectValue */ :
|
|
1606
1606
|
return function(t, e) {
|
|
@@ -2123,7 +2123,7 @@ class ne extends class {} {
|
|
|
2123
2123
|
/**
|
|
2124
2124
|
* Creates a filter based on the provided arguments.
|
|
2125
2125
|
*/ static create(t, e, n) {
|
|
2126
|
-
return t.isKeyField() ? "in" /* IN */ === e || "not-in" /* NOT_IN */ === e ? this.P(t, e, n) : new ie(t, e, n) : "array-contains" /* ARRAY_CONTAINS */ === e ? new
|
|
2126
|
+
return t.isKeyField() ? "in" /* IN */ === e || "not-in" /* NOT_IN */ === e ? this.P(t, e, n) : new ie(t, e, n) : "array-contains" /* ARRAY_CONTAINS */ === e ? new ae(t, n) : "in" /* IN */ === e ? new ue(t, n) : "not-in" /* NOT_IN */ === e ? new he(t, n) : "array-contains-any" /* ARRAY_CONTAINS_ANY */ === e ? new le(t, n) : new ne(t, e, n);
|
|
2127
2127
|
}
|
|
2128
2128
|
static P(t, e, n) {
|
|
2129
2129
|
return "in" /* IN */ === e ? new re(t, n) : new oe(t, n);
|
|
@@ -2182,7 +2182,7 @@ class ie extends ne {
|
|
|
2182
2182
|
|
|
2183
2183
|
/** Filter that matches on key fields within an array. */ class re extends ne {
|
|
2184
2184
|
constructor(t, e) {
|
|
2185
|
-
super(t, "in" /* IN */ , e), this.keys =
|
|
2185
|
+
super(t, "in" /* IN */ , e), this.keys = ce("in" /* IN */ , e);
|
|
2186
2186
|
}
|
|
2187
2187
|
matches(t) {
|
|
2188
2188
|
return this.keys.some((e => e.isEqual(t.key)));
|
|
@@ -2191,19 +2191,19 @@ class ie extends ne {
|
|
|
2191
2191
|
|
|
2192
2192
|
/** Filter that matches on key fields not present within an array. */ class oe extends ne {
|
|
2193
2193
|
constructor(t, e) {
|
|
2194
|
-
super(t, "not-in" /* NOT_IN */ , e), this.keys =
|
|
2194
|
+
super(t, "not-in" /* NOT_IN */ , e), this.keys = ce("not-in" /* NOT_IN */ , e);
|
|
2195
2195
|
}
|
|
2196
2196
|
matches(t) {
|
|
2197
2197
|
return !this.keys.some((e => e.isEqual(t.key)));
|
|
2198
2198
|
}
|
|
2199
2199
|
}
|
|
2200
2200
|
|
|
2201
|
-
function
|
|
2201
|
+
function ce(t, e) {
|
|
2202
2202
|
var n;
|
|
2203
2203
|
return ((null === (n = e.arrayValue) || void 0 === n ? void 0 : n.values) || []).map((t => Nt.fromName(t.referenceValue)));
|
|
2204
2204
|
}
|
|
2205
2205
|
|
|
2206
|
-
/** A Filter that implements the array-contains operator. */ class
|
|
2206
|
+
/** A Filter that implements the array-contains operator. */ class ae extends ne {
|
|
2207
2207
|
constructor(t, e) {
|
|
2208
2208
|
super(t, "array-contains" /* ARRAY_CONTAINS */ , e);
|
|
2209
2209
|
}
|
|
@@ -2334,16 +2334,16 @@ function ge(t, e) {
|
|
|
2334
2334
|
* Initializes a Query with a path and optional additional query constraints.
|
|
2335
2335
|
* Path must currently be empty if this is a collection group query.
|
|
2336
2336
|
*/
|
|
2337
|
-
constructor(t, e = null, n = [], s = [], i = null, r = "F" /* First */ , o = null,
|
|
2337
|
+
constructor(t, e = null, n = [], s = [], i = null, r = "F" /* First */ , o = null, c = null) {
|
|
2338
2338
|
this.path = t, this.collectionGroup = e, this.explicitOrderBy = n, this.filters = s,
|
|
2339
|
-
this.limit = i, this.limitType = r, this.startAt = o, this.endAt =
|
|
2339
|
+
this.limit = i, this.limitType = r, this.startAt = o, this.endAt = c, this.S = null,
|
|
2340
2340
|
// The corresponding `Target` of this `Query` instance.
|
|
2341
2341
|
this.D = null, this.startAt, this.endAt;
|
|
2342
2342
|
}
|
|
2343
2343
|
}
|
|
2344
2344
|
|
|
2345
|
-
/** Creates a new Query instance with the options provided. */ function pe(t, e, n, s, i, r, o,
|
|
2346
|
-
return new ye(t, e, n, s, i, r, o,
|
|
2345
|
+
/** Creates a new Query instance with the options provided. */ function pe(t, e, n, s, i, r, o, c) {
|
|
2346
|
+
return new ye(t, e, n, s, i, r, o, c);
|
|
2347
2347
|
}
|
|
2348
2348
|
|
|
2349
2349
|
/** Creates a new Query for a query that matches all documents at `path` */ function Te(t) {
|
|
@@ -2724,7 +2724,7 @@ function He(t) {
|
|
|
2724
2724
|
|
|
2725
2725
|
function Ye(t, e) {
|
|
2726
2726
|
return t.field.isEqual(e.field) && function(t, e) {
|
|
2727
|
-
return t instanceof Ke && e instanceof Ke || t instanceof Qe && e instanceof Qe ?
|
|
2727
|
+
return t instanceof Ke && e instanceof Ke || t instanceof Qe && e instanceof Qe ? ct(t.elements, e.elements, xt) : t instanceof Ge && e instanceof Ge ? xt(t.N, e.N) : t instanceof qe && e instanceof qe;
|
|
2728
2728
|
}(t.transform, e.transform);
|
|
2729
2729
|
}
|
|
2730
2730
|
|
|
@@ -2840,7 +2840,7 @@ class Xe {
|
|
|
2840
2840
|
* of the document.
|
|
2841
2841
|
* @param mutationResult - The result of applying the mutation from the backend.
|
|
2842
2842
|
*/ function nn(t, e, n) {
|
|
2843
|
-
t instanceof
|
|
2843
|
+
t instanceof an ? function(t, e, n) {
|
|
2844
2844
|
// Unlike setMutationApplyToLocalView, if we're applying a mutation to a
|
|
2845
2845
|
// remote document the server has accepted the mutation so the precondition
|
|
2846
2846
|
// must have held.
|
|
@@ -2875,13 +2875,13 @@ class Xe {
|
|
|
2875
2875
|
* @param localWriteTime - A timestamp indicating the local write time of the
|
|
2876
2876
|
* batch this mutation is a part of.
|
|
2877
2877
|
*/ function sn(t, e, n) {
|
|
2878
|
-
t instanceof
|
|
2878
|
+
t instanceof an ? function(t, e, n) {
|
|
2879
2879
|
if (!tn(t.precondition, e))
|
|
2880
2880
|
// The mutation failed to apply (e.g. a document ID created with add()
|
|
2881
2881
|
// caused a name collision).
|
|
2882
2882
|
return;
|
|
2883
2883
|
const s = t.value.clone(), i = fn(t.fieldTransforms, n, e);
|
|
2884
|
-
s.setAll(i), e.convertToFoundDocument(
|
|
2884
|
+
s.setAll(i), e.convertToFoundDocument(cn(e), s).setHasLocalMutations();
|
|
2885
2885
|
}
|
|
2886
2886
|
/**
|
|
2887
2887
|
* A mutation that modifies fields of the document at the given key with the
|
|
@@ -2898,7 +2898,7 @@ class Xe {
|
|
|
2898
2898
|
*/ (t, e, n) : t instanceof un ? function(t, e, n) {
|
|
2899
2899
|
if (!tn(t.precondition, e)) return;
|
|
2900
2900
|
const s = fn(t.fieldTransforms, n, e), i = e.data;
|
|
2901
|
-
i.setAll(hn(t)), i.setAll(s), e.convertToFoundDocument(
|
|
2901
|
+
i.setAll(hn(t)), i.setAll(s), e.convertToFoundDocument(cn(e), i).setHasLocalMutations();
|
|
2902
2902
|
}
|
|
2903
2903
|
/**
|
|
2904
2904
|
* Returns a FieldPath/Value map with the content of the PatchMutation.
|
|
@@ -2943,7 +2943,7 @@ class Xe {
|
|
|
2943
2943
|
|
|
2944
2944
|
function on(t, e) {
|
|
2945
2945
|
return t.type === e.type && (!!t.key.isEqual(e.key) && (!!t.precondition.isEqual(e.precondition) && (!!function(t, e) {
|
|
2946
|
-
return void 0 === t && void 0 === e || !(!t || !e) &&
|
|
2946
|
+
return void 0 === t && void 0 === e || !(!t || !e) && ct(t, e, ((t, e) => Ye(t, e)));
|
|
2947
2947
|
}(t.fieldTransforms, e.fieldTransforms) && (0 /* Set */ === t.type ? t.value.isEqual(e.value) : 1 /* Patch */ !== t.type || t.data.isEqual(e.data) && t.fieldMask.isEqual(e.fieldMask)))));
|
|
2948
2948
|
}
|
|
2949
2949
|
|
|
@@ -2952,14 +2952,14 @@ function on(t, e) {
|
|
|
2952
2952
|
* mutation. Mutations are defined to return the version of the base document
|
|
2953
2953
|
* only if it is an existing document. Deleted and unknown documents have a
|
|
2954
2954
|
* post-mutation version of SnapshotVersion.min().
|
|
2955
|
-
*/ function
|
|
2955
|
+
*/ function cn(t) {
|
|
2956
2956
|
return t.isFoundDocument() ? t.version : ht.min();
|
|
2957
2957
|
}
|
|
2958
2958
|
|
|
2959
2959
|
/**
|
|
2960
2960
|
* A mutation that creates or replaces the document at the given key with the
|
|
2961
2961
|
* object value contents.
|
|
2962
|
-
*/ class
|
|
2962
|
+
*/ class an extends en {
|
|
2963
2963
|
constructor(t, e, n, s = []) {
|
|
2964
2964
|
super(), this.key = t, this.value = e, this.precondition = n, this.fieldTransforms = s,
|
|
2965
2965
|
this.type = 0 /* Set */;
|
|
@@ -2997,8 +2997,8 @@ function hn(t) {
|
|
|
2997
2997
|
const s = new Map;
|
|
2998
2998
|
q(t.length === n.length);
|
|
2999
2999
|
for (let i = 0; i < n.length; i++) {
|
|
3000
|
-
const r = t[i], o = r.transform,
|
|
3001
|
-
s.set(r.field, Be(o,
|
|
3000
|
+
const r = t[i], o = r.transform, c = e.data.field(r.field);
|
|
3001
|
+
s.set(r.field, Be(o, c, n[i]));
|
|
3002
3002
|
}
|
|
3003
3003
|
return s;
|
|
3004
3004
|
}
|
|
@@ -4011,8 +4011,8 @@ class Un {
|
|
|
4011
4011
|
/**
|
|
4012
4012
|
* Processes and adds the DocumentWatchChange to the current set of changes.
|
|
4013
4013
|
*/ ot(t) {
|
|
4014
|
-
for (const e of t.$) t.O && t.O.isFoundDocument() ? this.
|
|
4015
|
-
for (const e of t.removedTargetIds) this.
|
|
4014
|
+
for (const e of t.$) t.O && t.O.isFoundDocument() ? this.ct(e, t.O) : this.at(e, t.key, t.O);
|
|
4015
|
+
for (const e of t.removedTargetIds) this.at(e, t.key, t.O);
|
|
4016
4016
|
}
|
|
4017
4017
|
/** Processes and adds the WatchTargetChange to the current set of changes. */ ut(t) {
|
|
4018
4018
|
this.forEachTarget(t, (e => {
|
|
@@ -4082,7 +4082,7 @@ class Un {
|
|
|
4082
4082
|
// until it is resolved, essentially exposing inconsistency between
|
|
4083
4083
|
// queries.
|
|
4084
4084
|
const n = new Nt(t.path);
|
|
4085
|
-
this.
|
|
4085
|
+
this.at(e, n, Ht.newNoDocument(n, ht.min()));
|
|
4086
4086
|
} else q(1 === n); else {
|
|
4087
4087
|
this._t(e) !== n && (
|
|
4088
4088
|
// Existence filter mismatch: We reset the mapping and raise a new
|
|
@@ -4109,7 +4109,7 @@ class Un {
|
|
|
4109
4109
|
// instead resulting in an explicit delete message and we could
|
|
4110
4110
|
// remove this special logic.
|
|
4111
4111
|
const e = new Nt(i.target.path);
|
|
4112
|
-
null !== this.st.get(e) || this.yt(s, e) || this.
|
|
4112
|
+
null !== this.st.get(e) || this.yt(s, e) || this.at(s, e, Ht.newNoDocument(e, t));
|
|
4113
4113
|
}
|
|
4114
4114
|
n.j && (e.set(s, n.G()), n.H());
|
|
4115
4115
|
}
|
|
@@ -4135,7 +4135,7 @@ class Un {
|
|
|
4135
4135
|
* its document key to the given target's mapping.
|
|
4136
4136
|
*/
|
|
4137
4137
|
// Visible for testing.
|
|
4138
|
-
|
|
4138
|
+
ct(t, e) {
|
|
4139
4139
|
if (!this.lt(t)) return;
|
|
4140
4140
|
const n = this.yt(t, e.key) ? 2 /* Modified */ : 0 /* Added */;
|
|
4141
4141
|
this.ht(t).J(e.key, n), this.st = this.st.insert(e.key, e), this.it = this.it.insert(e.key, this.Tt(e.key).add(t));
|
|
@@ -4148,7 +4148,7 @@ class Un {
|
|
|
4148
4148
|
* to update the remote document cache.
|
|
4149
4149
|
*/
|
|
4150
4150
|
// Visible for testing.
|
|
4151
|
-
|
|
4151
|
+
at(t, e, n) {
|
|
4152
4152
|
if (!this.lt(t)) return;
|
|
4153
4153
|
const s = this.ht(t);
|
|
4154
4154
|
this.yt(t, e) ? s.J(e, 1 /* Removed */) :
|
|
@@ -4203,7 +4203,7 @@ class Un {
|
|
|
4203
4203
|
*/ ft(t) {
|
|
4204
4204
|
this.nt.set(t, new Bn);
|
|
4205
4205
|
this.et.getRemoteKeysForTarget(t).forEach((e => {
|
|
4206
|
-
this.
|
|
4206
|
+
this.at(t, e, /*updatedDocument=*/ null);
|
|
4207
4207
|
}));
|
|
4208
4208
|
}
|
|
4209
4209
|
/**
|
|
@@ -4373,7 +4373,7 @@ function os(t, e, n) {
|
|
|
4373
4373
|
return n && o.setHasCommittedMutations(), n ? o.setHasCommittedMutations() : o;
|
|
4374
4374
|
}
|
|
4375
4375
|
|
|
4376
|
-
function
|
|
4376
|
+
function cs(t, e) {
|
|
4377
4377
|
return "found" in e ? function(t, e) {
|
|
4378
4378
|
q(!!e.found), e.found.name, e.found.updateTime;
|
|
4379
4379
|
const n = ts(t, e.found.name), s = Jn(e.found.updateTime), i = new Gt({
|
|
@@ -4389,7 +4389,7 @@ function as(t, e) {
|
|
|
4389
4389
|
}(t, e) : U();
|
|
4390
4390
|
}
|
|
4391
4391
|
|
|
4392
|
-
function
|
|
4392
|
+
function as(t, e) {
|
|
4393
4393
|
let n;
|
|
4394
4394
|
if ("targetChange" in e) {
|
|
4395
4395
|
e.targetChange;
|
|
@@ -4400,7 +4400,7 @@ function cs(t, e) {
|
|
|
4400
4400
|
}(e.targetChange.targetChangeType || "NO_CHANGE"), i = e.targetChange.targetIds || [], r = function(t, e) {
|
|
4401
4401
|
return t.C ? (q(void 0 === e || "string" == typeof e), Et.fromBase64String(e || "")) : (q(void 0 === e || e instanceof Uint8Array),
|
|
4402
4402
|
Et.fromUint8Array(e || new Uint8Array));
|
|
4403
|
-
}(t, e.targetChange.resumeToken), o = e.targetChange.cause,
|
|
4403
|
+
}(t, e.targetChange.resumeToken), o = e.targetChange.cause, c = o && function(t) {
|
|
4404
4404
|
const e = void 0 === t.code ? Q.UNKNOWN : pn(t.code);
|
|
4405
4405
|
return new W(e, t.message || "");
|
|
4406
4406
|
}
|
|
@@ -4412,7 +4412,7 @@ function cs(t, e) {
|
|
|
4412
4412
|
* our generated proto interfaces say Int32Value must be. But GRPC actually
|
|
4413
4413
|
* expects a { value: <number> } struct.
|
|
4414
4414
|
*/ (o);
|
|
4415
|
-
n = new Ln(s, i, r,
|
|
4415
|
+
n = new Ln(s, i, r, c || null);
|
|
4416
4416
|
} else if ("documentChange" in e) {
|
|
4417
4417
|
e.documentChange;
|
|
4418
4418
|
const s = e.documentChange;
|
|
@@ -4421,14 +4421,14 @@ function cs(t, e) {
|
|
|
4421
4421
|
mapValue: {
|
|
4422
4422
|
fields: s.document.fields
|
|
4423
4423
|
}
|
|
4424
|
-
}),
|
|
4425
|
-
n = new Mn(
|
|
4424
|
+
}), c = Ht.newFoundDocument(i, r, o), a = s.targetIds || [], u = s.removedTargetIds || [];
|
|
4425
|
+
n = new Mn(a, u, c.key, c);
|
|
4426
4426
|
} else if ("documentDelete" in e) {
|
|
4427
4427
|
e.documentDelete;
|
|
4428
4428
|
const s = e.documentDelete;
|
|
4429
4429
|
s.document;
|
|
4430
|
-
const i = ts(t, s.document), r = s.readTime ? Jn(s.readTime) : ht.min(), o = Ht.newNoDocument(i, r),
|
|
4431
|
-
n = new Mn([],
|
|
4430
|
+
const i = ts(t, s.document), r = s.readTime ? Jn(s.readTime) : ht.min(), o = Ht.newNoDocument(i, r), c = s.removedTargetIds || [];
|
|
4431
|
+
n = new Mn([], c, o.key, o);
|
|
4432
4432
|
} else if ("documentRemove" in e) {
|
|
4433
4433
|
e.documentRemove;
|
|
4434
4434
|
const s = e.documentRemove;
|
|
@@ -4450,7 +4450,7 @@ function cs(t, e) {
|
|
|
4450
4450
|
|
|
4451
4451
|
function us(t, e) {
|
|
4452
4452
|
let n;
|
|
4453
|
-
if (e instanceof
|
|
4453
|
+
if (e instanceof an) n = {
|
|
4454
4454
|
update: rs(t, e.key, e.value)
|
|
4455
4455
|
}; else if (e instanceof dn) n = {
|
|
4456
4456
|
delete: Zn(t, e.key)
|
|
@@ -4524,7 +4524,7 @@ function hs(t, e) {
|
|
|
4524
4524
|
}(e.updateMask);
|
|
4525
4525
|
return new un(i, r, t, n, s);
|
|
4526
4526
|
}
|
|
4527
|
-
return new
|
|
4527
|
+
return new an(i, r, n, s);
|
|
4528
4528
|
}
|
|
4529
4529
|
if (e.delete) {
|
|
4530
4530
|
const s = ts(t, e.delete);
|
|
@@ -4671,15 +4671,15 @@ function ws(t) {
|
|
|
4671
4671
|
// visible for testing
|
|
4672
4672
|
(t.direction));
|
|
4673
4673
|
}(t))));
|
|
4674
|
-
let
|
|
4675
|
-
n.limit && (
|
|
4674
|
+
let c = null;
|
|
4675
|
+
n.limit && (c = function(t) {
|
|
4676
4676
|
let e;
|
|
4677
4677
|
return e = "object" == typeof t ? t.value : t, St(e) ? null : e;
|
|
4678
4678
|
}(n.limit));
|
|
4679
|
-
let
|
|
4680
|
-
n.startAt && (
|
|
4679
|
+
let a = null;
|
|
4680
|
+
n.startAt && (a = ys(n.startAt));
|
|
4681
4681
|
let u = null;
|
|
4682
|
-
return n.endAt && (u = ys(n.endAt)), pe(e, i, o, r,
|
|
4682
|
+
return n.endAt && (u = ys(n.endAt)), pe(e, i, o, r, c, "F" /* First */ , a, u);
|
|
4683
4683
|
}
|
|
4684
4684
|
|
|
4685
4685
|
function _s(t, e) {
|
|
@@ -6066,7 +6066,7 @@ function ri(t) {
|
|
|
6066
6066
|
}
|
|
6067
6067
|
}
|
|
6068
6068
|
|
|
6069
|
-
function
|
|
6069
|
+
function ci(t, e) {
|
|
6070
6070
|
const n = j(t);
|
|
6071
6071
|
return Xs.Dt(n.Wt, e);
|
|
6072
6072
|
}
|
|
@@ -6089,7 +6089,7 @@ function ai(t, e) {
|
|
|
6089
6089
|
*/
|
|
6090
6090
|
/**
|
|
6091
6091
|
* A batch of mutations that will be sent as one unit to the backend.
|
|
6092
|
-
*/ class
|
|
6092
|
+
*/ class ai {
|
|
6093
6093
|
/**
|
|
6094
6094
|
* @param batchId - The unique ID of this mutation batch.
|
|
6095
6095
|
* @param localWriteTime - The original write time of this mutation.
|
|
@@ -6150,7 +6150,7 @@ function ai(t, e) {
|
|
|
6150
6150
|
return this.mutations.reduce(((t, e) => t.add(e.key)), Nn());
|
|
6151
6151
|
}
|
|
6152
6152
|
isEqual(t) {
|
|
6153
|
-
return this.batchId === t.batchId &&
|
|
6153
|
+
return this.batchId === t.batchId && ct(this.mutations, t.mutations, ((t, e) => on(t, e))) && ct(this.baseMutations, t.baseMutations, ((t, e) => on(t, e)));
|
|
6154
6154
|
}
|
|
6155
6155
|
}
|
|
6156
6156
|
|
|
@@ -6345,7 +6345,7 @@ function yi(t, e) {
|
|
|
6345
6345
|
}
|
|
6346
6346
|
}
|
|
6347
6347
|
const s = e.mutations.map((e => hs(t.Gt, e))), i = ut.fromMillis(e.localWriteTimeMs);
|
|
6348
|
-
return new
|
|
6348
|
+
return new ai(e.batchId, i, n, s);
|
|
6349
6349
|
}
|
|
6350
6350
|
|
|
6351
6351
|
/** Decodes a DbTarget into TargetData */ function pi(t) {
|
|
@@ -6447,13 +6447,13 @@ class Ii {
|
|
|
6447
6447
|
/**
|
|
6448
6448
|
* Helper to get a typed SimpleDbStore for the bundles object store.
|
|
6449
6449
|
*/ function Ai(t) {
|
|
6450
|
-
return
|
|
6450
|
+
return ci(t, Qs.store);
|
|
6451
6451
|
}
|
|
6452
6452
|
|
|
6453
6453
|
/**
|
|
6454
6454
|
* Helper to get a typed SimpleDbStore for the namedQueries object store.
|
|
6455
6455
|
*/ function Ri(t) {
|
|
6456
|
-
return
|
|
6456
|
+
return ci(t, Ws.store);
|
|
6457
6457
|
}
|
|
6458
6458
|
|
|
6459
6459
|
/**
|
|
@@ -6560,7 +6560,7 @@ class Ii {
|
|
|
6560
6560
|
return Js.resolve();
|
|
6561
6561
|
}
|
|
6562
6562
|
getCollectionParents(t, e) {
|
|
6563
|
-
const n = [], s = IDBKeyRange.bound([ e, "" ], [
|
|
6563
|
+
const n = [], s = IDBKeyRange.bound([ e, "" ], [ at(e), "" ],
|
|
6564
6564
|
/*lowerOpen=*/ !1,
|
|
6565
6565
|
/*upperOpen=*/ !0);
|
|
6566
6566
|
return Vi(t).Bt(s).next((t => {
|
|
@@ -6581,7 +6581,7 @@ class Ii {
|
|
|
6581
6581
|
* Helper to get a typed SimpleDbStore for the collectionParents
|
|
6582
6582
|
* document store.
|
|
6583
6583
|
*/ function Vi(t) {
|
|
6584
|
-
return
|
|
6584
|
+
return ci(t, Ks.store);
|
|
6585
6585
|
}
|
|
6586
6586
|
|
|
6587
6587
|
/**
|
|
@@ -6645,12 +6645,12 @@ class Di {
|
|
|
6645
6645
|
*/
|
|
6646
6646
|
function Ci(t, e, n) {
|
|
6647
6647
|
const s = t.store(xs.store), i = t.store($s.store), r = [], o = IDBKeyRange.only(n.batchId);
|
|
6648
|
-
let
|
|
6649
|
-
const
|
|
6648
|
+
let c = 0;
|
|
6649
|
+
const a = s.jt({
|
|
6650
6650
|
range: o
|
|
6651
|
-
}, ((t, e, n) => (
|
|
6652
|
-
r.push(
|
|
6653
|
-
q(1 ===
|
|
6651
|
+
}, ((t, e, n) => (c++, n.delete())));
|
|
6652
|
+
r.push(a.next((() => {
|
|
6653
|
+
q(1 === c);
|
|
6654
6654
|
})));
|
|
6655
6655
|
const u = [];
|
|
6656
6656
|
for (const t of n.mutations) {
|
|
@@ -6750,20 +6750,20 @@ class ki {
|
|
|
6750
6750
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6751
6751
|
return r.add({}).next((o => {
|
|
6752
6752
|
q("number" == typeof o);
|
|
6753
|
-
const
|
|
6753
|
+
const c = new ai(o, e, n, s), a = function(t, e, n) {
|
|
6754
6754
|
const s = n.baseMutations.map((e => us(t.Gt, e))), i = n.mutations.map((e => us(t.Gt, e)));
|
|
6755
6755
|
return new xs(e, n.batchId, n.localWriteTime.toMillis(), s, i);
|
|
6756
|
-
}(this.k, this.userId,
|
|
6756
|
+
}(this.k, this.userId, c), u = [];
|
|
6757
6757
|
let h = new An(((t, e) => ot(t.canonicalString(), e.canonicalString())));
|
|
6758
6758
|
for (const t of s) {
|
|
6759
6759
|
const e = $s.key(this.userId, t.key.path, o);
|
|
6760
|
-
h = h.add(t.key.path.popLast()), u.push(r.put(
|
|
6760
|
+
h = h.add(t.key.path.popLast()), u.push(r.put(a)), u.push(i.put(e, $s.PLACEHOLDER));
|
|
6761
6761
|
}
|
|
6762
6762
|
return h.forEach((e => {
|
|
6763
6763
|
u.push(this.Jt.addToCollectionParentIndex(t, e));
|
|
6764
6764
|
})), t.addOnCommittedListener((() => {
|
|
6765
|
-
this.Yt[o] =
|
|
6766
|
-
})), Js.waitFor(u).next((() =>
|
|
6765
|
+
this.Yt[o] = c.keys();
|
|
6766
|
+
})), Js.waitFor(u).next((() => c));
|
|
6767
6767
|
}));
|
|
6768
6768
|
}
|
|
6769
6769
|
lookupMutationBatch(t, e) {
|
|
@@ -6817,7 +6817,7 @@ class ki {
|
|
|
6817
6817
|
return Oi(t).jt({
|
|
6818
6818
|
range: s
|
|
6819
6819
|
}, ((n, s, r) => {
|
|
6820
|
-
const [o,
|
|
6820
|
+
const [o, c, a] = n, u = Ds(c);
|
|
6821
6821
|
// Only consider rows matching exactly the specific key of
|
|
6822
6822
|
// interest. Note that because we order by path first, and we
|
|
6823
6823
|
// order terminators before path separators, we'll encounter all
|
|
@@ -6827,7 +6827,7 @@ class ki {
|
|
|
6827
6827
|
// can stop as soon as we hit any such row.
|
|
6828
6828
|
if (o === this.userId && e.path.isEqual(u))
|
|
6829
6829
|
// Look up the mutation batch in the store.
|
|
6830
|
-
return $i(t).get(
|
|
6830
|
+
return $i(t).get(a).next((t => {
|
|
6831
6831
|
if (!t) throw U();
|
|
6832
6832
|
q(t.userId === this.userId), i.push(yi(this.k, t));
|
|
6833
6833
|
}));
|
|
@@ -6841,7 +6841,7 @@ class ki {
|
|
|
6841
6841
|
const i = $s.prefixForPath(this.userId, e.path), r = IDBKeyRange.lowerBound(i), o = Oi(t).jt({
|
|
6842
6842
|
range: r
|
|
6843
6843
|
}, ((t, s, i) => {
|
|
6844
|
-
const [r, o,
|
|
6844
|
+
const [r, o, c] = t, a = Ds(o);
|
|
6845
6845
|
// Only consider rows matching exactly the specific key of
|
|
6846
6846
|
// interest. Note that because we order by path first, and we
|
|
6847
6847
|
// order terminators before path separators, we'll encounter all
|
|
@@ -6849,7 +6849,7 @@ class ki {
|
|
|
6849
6849
|
// the rows for documentKey will occur before any rows for
|
|
6850
6850
|
// documents nested in a subcollection beneath documentKey so we
|
|
6851
6851
|
// can stop as soon as we hit any such row.
|
|
6852
|
-
r === this.userId && e.path.isEqual(
|
|
6852
|
+
r === this.userId && e.path.isEqual(a) ? n = n.add(c) : i.done();
|
|
6853
6853
|
}));
|
|
6854
6854
|
s.push(o);
|
|
6855
6855
|
})), Js.waitFor(s).next((() => this.te(t, n)));
|
|
@@ -6863,14 +6863,14 @@ class ki {
|
|
|
6863
6863
|
return Oi(t).jt({
|
|
6864
6864
|
range: r
|
|
6865
6865
|
}, ((t, e, i) => {
|
|
6866
|
-
const [r,
|
|
6866
|
+
const [r, c, a] = t, u = Ds(c);
|
|
6867
6867
|
r === this.userId && n.isPrefixOf(u) ?
|
|
6868
6868
|
// Rows with document keys more than one segment longer than the
|
|
6869
6869
|
// query path can't be matches. For example, a query on 'rooms'
|
|
6870
6870
|
// can't match the document /rooms/abc/messages/xyx.
|
|
6871
6871
|
// TODO(mcg): we'll need a different scanner when we implement
|
|
6872
6872
|
// ancestor queries.
|
|
6873
|
-
u.length === s && (o = o.add(
|
|
6873
|
+
u.length === s && (o = o.add(a)) : i.done();
|
|
6874
6874
|
})).next((() => this.te(t, o)));
|
|
6875
6875
|
}
|
|
6876
6876
|
te(t, e) {
|
|
@@ -6939,8 +6939,8 @@ class ki {
|
|
|
6939
6939
|
range: r,
|
|
6940
6940
|
Kt: !0
|
|
6941
6941
|
}, ((t, n, s) => {
|
|
6942
|
-
const [r,
|
|
6943
|
-
r === e &&
|
|
6942
|
+
const [r, c, /*batchID*/ a] = t;
|
|
6943
|
+
r === e && c === i && (o = !0), s.done();
|
|
6944
6944
|
})).next((() => o));
|
|
6945
6945
|
}
|
|
6946
6946
|
|
|
@@ -6949,19 +6949,19 @@ class ki {
|
|
|
6949
6949
|
* Helper to get a typed SimpleDbStore for the mutations object store.
|
|
6950
6950
|
*/
|
|
6951
6951
|
function $i(t) {
|
|
6952
|
-
return
|
|
6952
|
+
return ci(t, xs.store);
|
|
6953
6953
|
}
|
|
6954
6954
|
|
|
6955
6955
|
/**
|
|
6956
6956
|
* Helper to get a typed SimpleDbStore for the mutationQueues object store.
|
|
6957
6957
|
*/ function Oi(t) {
|
|
6958
|
-
return
|
|
6958
|
+
return ci(t, $s.store);
|
|
6959
6959
|
}
|
|
6960
6960
|
|
|
6961
6961
|
/**
|
|
6962
6962
|
* Helper to get a typed SimpleDbStore for the mutationQueues object store.
|
|
6963
6963
|
*/ function Mi(t) {
|
|
6964
|
-
return
|
|
6964
|
+
return ci(t, ks.store);
|
|
6965
6965
|
}
|
|
6966
6966
|
|
|
6967
6967
|
/**
|
|
@@ -7043,7 +7043,7 @@ class Fi {
|
|
|
7043
7043
|
allocateTargetId(t) {
|
|
7044
7044
|
return this.oe(t).next((e => {
|
|
7045
7045
|
const n = new Fi(e.highestTargetId);
|
|
7046
|
-
return e.highestTargetId = n.next(), this.
|
|
7046
|
+
return e.highestTargetId = n.next(), this.ce(t, e).next((() => e.highestTargetId));
|
|
7047
7047
|
}));
|
|
7048
7048
|
}
|
|
7049
7049
|
getLastRemoteSnapshotVersion(t) {
|
|
@@ -7054,18 +7054,18 @@ class Fi {
|
|
|
7054
7054
|
}
|
|
7055
7055
|
setTargetsMetadata(t, e, n) {
|
|
7056
7056
|
return this.oe(t).next((s => (s.highestListenSequenceNumber = e, n && (s.lastRemoteSnapshotVersion = n.toTimestamp()),
|
|
7057
|
-
e > s.highestListenSequenceNumber && (s.highestListenSequenceNumber = e), this.
|
|
7057
|
+
e > s.highestListenSequenceNumber && (s.highestListenSequenceNumber = e), this.ce(t, s))));
|
|
7058
7058
|
}
|
|
7059
7059
|
addTargetData(t, e) {
|
|
7060
|
-
return this.
|
|
7061
|
-
this.
|
|
7060
|
+
return this.ae(t, e).next((() => this.oe(t).next((n => (n.targetCount += 1, this.ue(e, n),
|
|
7061
|
+
this.ce(t, n))))));
|
|
7062
7062
|
}
|
|
7063
7063
|
updateTargetData(t, e) {
|
|
7064
|
-
return this.
|
|
7064
|
+
return this.ae(t, e);
|
|
7065
7065
|
}
|
|
7066
7066
|
removeTargetData(t, e) {
|
|
7067
7067
|
return this.removeMatchingKeysForTargetId(t, e.targetId).next((() => Bi(t).delete(e.targetId))).next((() => this.oe(t))).next((e => (q(e.targetCount > 0),
|
|
7068
|
-
e.targetCount -= 1, this.
|
|
7068
|
+
e.targetCount -= 1, this.ce(t, e))));
|
|
7069
7069
|
}
|
|
7070
7070
|
/**
|
|
7071
7071
|
* Drops any targets with sequence number less than or equal to the upper bound, excepting those
|
|
@@ -7075,8 +7075,8 @@ class Fi {
|
|
|
7075
7075
|
let s = 0;
|
|
7076
7076
|
const i = [];
|
|
7077
7077
|
return Bi(t).jt(((r, o) => {
|
|
7078
|
-
const
|
|
7079
|
-
|
|
7078
|
+
const c = pi(o);
|
|
7079
|
+
c.sequenceNumber <= e && null === n.get(c.targetId) && (s++, i.push(this.removeTargetData(t, c)));
|
|
7080
7080
|
})).next((() => Js.waitFor(i))).next((() => s));
|
|
7081
7081
|
}
|
|
7082
7082
|
/**
|
|
@@ -7090,10 +7090,10 @@ class Fi {
|
|
|
7090
7090
|
oe(t) {
|
|
7091
7091
|
return Ui(t).get(qs.key).next((t => (q(null !== t), t)));
|
|
7092
7092
|
}
|
|
7093
|
-
|
|
7093
|
+
ce(t, e) {
|
|
7094
7094
|
return Ui(t).put(qs.key, e);
|
|
7095
7095
|
}
|
|
7096
|
-
|
|
7096
|
+
ae(t, e) {
|
|
7097
7097
|
return Bi(t).put(Ti(this.k, e));
|
|
7098
7098
|
}
|
|
7099
7099
|
/**
|
|
@@ -7163,7 +7163,7 @@ class Fi {
|
|
|
7163
7163
|
})).next((() => i));
|
|
7164
7164
|
}
|
|
7165
7165
|
containsKey(t, e) {
|
|
7166
|
-
const n = vs(e.path), s = IDBKeyRange.bound([ n ], [
|
|
7166
|
+
const n = vs(e.path), s = IDBKeyRange.bound([ n ], [ at(n) ],
|
|
7167
7167
|
/*lowerOpen=*/ !1,
|
|
7168
7168
|
/*upperOpen=*/ !0);
|
|
7169
7169
|
let i = 0;
|
|
@@ -7194,19 +7194,19 @@ class Fi {
|
|
|
7194
7194
|
/**
|
|
7195
7195
|
* Helper to get a typed SimpleDbStore for the queries object store.
|
|
7196
7196
|
*/ function Bi(t) {
|
|
7197
|
-
return
|
|
7197
|
+
return ci(t, Bs.store);
|
|
7198
7198
|
}
|
|
7199
7199
|
|
|
7200
7200
|
/**
|
|
7201
7201
|
* Helper to get a typed SimpleDbStore for the target globals object store.
|
|
7202
7202
|
*/ function Ui(t) {
|
|
7203
|
-
return
|
|
7203
|
+
return ci(t, qs.store);
|
|
7204
7204
|
}
|
|
7205
7205
|
|
|
7206
7206
|
/**
|
|
7207
7207
|
* Helper to get a typed SimpleDbStore for the document target object store.
|
|
7208
7208
|
*/ function qi(t) {
|
|
7209
|
-
return
|
|
7209
|
+
return ci(t, Us.store);
|
|
7210
7210
|
}
|
|
7211
7211
|
|
|
7212
7212
|
/**
|
|
@@ -7345,16 +7345,16 @@ class Fi {
|
|
|
7345
7345
|
return this.ge.getCacheSize(t);
|
|
7346
7346
|
}
|
|
7347
7347
|
Te(t, e) {
|
|
7348
|
-
let n, s, i, r, o,
|
|
7348
|
+
let n, s, i, r, o, a, u;
|
|
7349
7349
|
const h = Date.now();
|
|
7350
7350
|
return this.calculateTargetCount(t, this.params.percentileToCollect).next((e => (
|
|
7351
7351
|
// Cap at the configured max
|
|
7352
7352
|
e > this.params.maximumSequenceNumbersToCollect ? (M("LruGarbageCollector", `Capping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${e}`),
|
|
7353
7353
|
s = this.params.maximumSequenceNumbersToCollect) : s = e, r = Date.now(), this.nthSequenceNumber(t, s)))).next((s => (n = s,
|
|
7354
|
-
o = Date.now(), this.removeTargets(t, n, e)))).next((e => (i = e,
|
|
7354
|
+
o = Date.now(), this.removeTargets(t, n, e)))).next((e => (i = e, a = Date.now(),
|
|
7355
7355
|
this.removeOrphanedDocuments(t, n)))).next((t => {
|
|
7356
|
-
if (u = Date.now(), $() <=
|
|
7357
|
-
M("LruGarbageCollector", `LRU Garbage Collection\n\tCounted targets in ${r - h}ms\n\tDetermined least recently used ${s} in ` + (o - r) + "ms\n" + `\tRemoved ${i} targets in ` + (
|
|
7356
|
+
if (u = Date.now(), $() <= c.DEBUG) {
|
|
7357
|
+
M("LruGarbageCollector", `LRU Garbage Collection\n\tCounted targets in ${r - h}ms\n\tDetermined least recently used ${s} in ` + (o - r) + "ms\n" + `\tRemoved ${i} targets in ` + (a - o) + "ms\n" + `\tRemoved ${t} documents in ` + (u - a) + "ms\n" + `Total Duration: ${u - h}ms`);
|
|
7358
7358
|
}
|
|
7359
7359
|
return Js.resolve({
|
|
7360
7360
|
didRun: !0,
|
|
@@ -7851,10 +7851,10 @@ class Zi extends Yi {
|
|
|
7851
7851
|
return this.changes.forEach(((i, r) => {
|
|
7852
7852
|
const o = this.Ce.get(i);
|
|
7853
7853
|
if (r.document.isValidDocument()) {
|
|
7854
|
-
const
|
|
7854
|
+
const c = di(this.De.k, r.document, this.getReadTime(i));
|
|
7855
7855
|
s = s.add(i.path.popLast());
|
|
7856
|
-
const
|
|
7857
|
-
n +=
|
|
7856
|
+
const a = Ni(c);
|
|
7857
|
+
n += a - o, e.push(this.De.addEntry(t, i, c));
|
|
7858
7858
|
} else if (n -= o, this.trackRemovals) {
|
|
7859
7859
|
// In order to track removals, we store a "sentinel delete" in the
|
|
7860
7860
|
// RemoteDocumentCache. This entry is represented by a NoDocument
|
|
@@ -7885,13 +7885,13 @@ class Zi extends Yi {
|
|
|
7885
7885
|
}
|
|
7886
7886
|
|
|
7887
7887
|
function tr(t) {
|
|
7888
|
-
return
|
|
7888
|
+
return ci(t, Ls.store);
|
|
7889
7889
|
}
|
|
7890
7890
|
|
|
7891
7891
|
/**
|
|
7892
7892
|
* Helper to get a typed SimpleDbStore for the remoteDocuments object store.
|
|
7893
7893
|
*/ function er(t) {
|
|
7894
|
-
return
|
|
7894
|
+
return ci(t, Fs.store);
|
|
7895
7895
|
}
|
|
7896
7896
|
|
|
7897
7897
|
function nr(t) {
|
|
@@ -8184,14 +8184,14 @@ class or {
|
|
|
8184
8184
|
* Whether to synchronize the in-memory state of multiple tabs and share
|
|
8185
8185
|
* access to local persistence.
|
|
8186
8186
|
*/
|
|
8187
|
-
t, e, n, s, i, r, o,
|
|
8187
|
+
t, e, n, s, i, r, o, c, a,
|
|
8188
8188
|
/**
|
|
8189
8189
|
* If set to true, forcefully obtains database access. Existing tabs will
|
|
8190
8190
|
* no longer be able to access IndexedDB.
|
|
8191
8191
|
*/
|
|
8192
8192
|
u) {
|
|
8193
8193
|
if (this.allowTabSynchronization = t, this.persistenceKey = e, this.clientId = n,
|
|
8194
|
-
this.Me = i, this.window = r, this.document = o, this.Fe =
|
|
8194
|
+
this.Me = i, this.window = r, this.document = o, this.Fe = a, this.Le = u, this.Be = null,
|
|
8195
8195
|
this.Ue = !1, this.isPrimary = !1, this.networkEnabled = !0,
|
|
8196
8196
|
/** Our window.unload handler, if registered. */
|
|
8197
8197
|
this.qe = null, this.inForeground = !1,
|
|
@@ -8203,7 +8203,7 @@ class or {
|
|
|
8203
8203
|
this.Qe = Number.NEGATIVE_INFINITY,
|
|
8204
8204
|
/** A listener to notify on primary state changes. */
|
|
8205
8205
|
this.We = t => Promise.resolve(), !or.Pt()) throw new W(Q.UNIMPLEMENTED, "This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");
|
|
8206
|
-
this.referenceDelegate = new zi(this, s), this.Ge = e + "main", this.k = new li(
|
|
8206
|
+
this.referenceDelegate = new zi(this, s), this.Ge = e + "main", this.k = new li(c),
|
|
8207
8207
|
this.ze = new Xs(this.Ge, 11, new sr(this.k)), this.He = new Li(this.referenceDelegate, this.k),
|
|
8208
8208
|
this.Jt = new vi, this.Je = function(t, e) {
|
|
8209
8209
|
return new Xi(t, e);
|
|
@@ -8277,11 +8277,11 @@ class or {
|
|
|
8277
8277
|
* primary state listener if the client either newly obtained or released its
|
|
8278
8278
|
* primary lease.
|
|
8279
8279
|
*/ Ze() {
|
|
8280
|
-
return this.runTransaction("updateClientMetadataAndTryBecomePrimary", "readwrite", (t =>
|
|
8280
|
+
return this.runTransaction("updateClientMetadataAndTryBecomePrimary", "readwrite", (t => ar(t).put(new js(this.clientId, Date.now(), this.networkEnabled, this.inForeground)).next((() => {
|
|
8281
8281
|
if (this.isPrimary) return this.rn(t).next((t => {
|
|
8282
8282
|
t || (this.isPrimary = !1, this.Me.enqueueRetryable((() => this.We(!1))));
|
|
8283
8283
|
}));
|
|
8284
|
-
})).next((() => this.on(t))).next((e => this.isPrimary && !e ? this.
|
|
8284
|
+
})).next((() => this.on(t))).next((e => this.isPrimary && !e ? this.cn(t).next((() => !1)) : !!e && this.an(t).next((() => !0)))))).catch((t => {
|
|
8285
8285
|
if (ei(t))
|
|
8286
8286
|
// Proceed with the existing state. Any subsequent access to
|
|
8287
8287
|
// IndexedDB will verify the lease.
|
|
@@ -8294,10 +8294,10 @@ class or {
|
|
|
8294
8294
|
}));
|
|
8295
8295
|
}
|
|
8296
8296
|
rn(t) {
|
|
8297
|
-
return
|
|
8297
|
+
return cr(t).get(Ns.key).next((t => Js.resolve(this.un(t))));
|
|
8298
8298
|
}
|
|
8299
8299
|
hn(t) {
|
|
8300
|
-
return
|
|
8300
|
+
return ar(t).delete(this.clientId);
|
|
8301
8301
|
}
|
|
8302
8302
|
/**
|
|
8303
8303
|
* If the garbage collection threshold has passed, prunes the
|
|
@@ -8307,7 +8307,7 @@ class or {
|
|
|
8307
8307
|
if (this.isPrimary && !this.fn(this.Qe, 18e5)) {
|
|
8308
8308
|
this.Qe = Date.now();
|
|
8309
8309
|
const t = await this.runTransaction("maybeGarbageCollectMultiClientState", "readwrite-primary", (t => {
|
|
8310
|
-
const e =
|
|
8310
|
+
const e = ci(t, js.store);
|
|
8311
8311
|
return e.Bt().next((t => {
|
|
8312
8312
|
const n = this.dn(t, 18e5), s = t.filter((t => -1 === n.indexOf(t)));
|
|
8313
8313
|
// Delete metadata for clients that are no longer considered active.
|
|
@@ -8339,7 +8339,7 @@ class or {
|
|
|
8339
8339
|
* (foreground) client should become leaseholder instead.
|
|
8340
8340
|
*/ on(t) {
|
|
8341
8341
|
if (this.Le) return Js.resolve(!0);
|
|
8342
|
-
return
|
|
8342
|
+
return cr(t).get(Ns.key).next((e => {
|
|
8343
8343
|
// A client is eligible for the primary lease if:
|
|
8344
8344
|
// - its network is enabled and the client's tab is in the foreground.
|
|
8345
8345
|
// - its network is enabled and no other client's tab is in the
|
|
@@ -8368,7 +8368,7 @@ class or {
|
|
|
8368
8368
|
return !1;
|
|
8369
8369
|
}
|
|
8370
8370
|
}
|
|
8371
|
-
return !(!this.networkEnabled || !this.inForeground) ||
|
|
8371
|
+
return !(!this.networkEnabled || !this.inForeground) || ar(t).Bt().next((t => void 0 === this.dn(t, 5e3).find((t => {
|
|
8372
8372
|
if (this.clientId !== t.clientId) {
|
|
8373
8373
|
const e = !this.networkEnabled && t.networkEnabled, n = !this.inForeground && t.inForeground, s = this.networkEnabled === t.networkEnabled;
|
|
8374
8374
|
if (e || n && s) return !0;
|
|
@@ -8387,7 +8387,7 @@ class or {
|
|
|
8387
8387
|
// has obtained the primary lease.
|
|
8388
8388
|
await this.ze.runTransaction("shutdown", "readwrite", [ Ns.store, js.store ], (t => {
|
|
8389
8389
|
const e = new oi(t, st.I);
|
|
8390
|
-
return this.
|
|
8390
|
+
return this.cn(e).next((() => this.hn(e)));
|
|
8391
8391
|
})), this.ze.close(),
|
|
8392
8392
|
// Remove the entry marking the client as zombied from LocalStorage since
|
|
8393
8393
|
// we successfully deleted its metadata from IndexedDb.
|
|
@@ -8406,7 +8406,7 @@ class or {
|
|
|
8406
8406
|
*
|
|
8407
8407
|
* PORTING NOTE: This is only used for Web multi-tab.
|
|
8408
8408
|
*/ Tn() {
|
|
8409
|
-
return this.runTransaction("getActiveClients", "readonly", (t =>
|
|
8409
|
+
return this.runTransaction("getActiveClients", "readonly", (t => ar(t).Bt().next((t => this.dn(t, 18e5).map((t => t.clientId))))));
|
|
8410
8410
|
}
|
|
8411
8411
|
get started() {
|
|
8412
8412
|
return this.Ue;
|
|
@@ -8437,7 +8437,7 @@ class or {
|
|
|
8437
8437
|
if (!e) throw F(`Failed to obtain primary lease for action '${t}'.`), this.isPrimary = !1,
|
|
8438
8438
|
this.Me.enqueueRetryable((() => this.We(!1))), new W(Q.FAILED_PRECONDITION, zs);
|
|
8439
8439
|
return n(i);
|
|
8440
|
-
})).next((t => this.
|
|
8440
|
+
})).next((t => this.an(i).next((() => t)))) : this.En(i).next((() => n(i)))))).then((t => (i.raiseOnCommittedEvent(),
|
|
8441
8441
|
t)));
|
|
8442
8442
|
}
|
|
8443
8443
|
/**
|
|
@@ -8447,22 +8447,22 @@ class or {
|
|
|
8447
8447
|
// TODO(b/114226234): Remove this check when `synchronizeTabs` can no longer
|
|
8448
8448
|
// be turned off.
|
|
8449
8449
|
En(t) {
|
|
8450
|
-
return
|
|
8450
|
+
return cr(t).get(Ns.key).next((t => {
|
|
8451
8451
|
if (null !== t && this.fn(t.leaseTimestampMs, 5e3) && !this._n(t.ownerId) && !this.un(t) && !(this.Le || this.allowTabSynchronization && t.allowTabSynchronization)) throw new W(Q.FAILED_PRECONDITION, rr);
|
|
8452
8452
|
}));
|
|
8453
8453
|
}
|
|
8454
8454
|
/**
|
|
8455
8455
|
* Obtains or extends the new primary lease for the local client. This
|
|
8456
8456
|
* method does not verify that the client is eligible for this lease.
|
|
8457
|
-
*/
|
|
8457
|
+
*/ an(t) {
|
|
8458
8458
|
const e = new Ns(this.clientId, this.allowTabSynchronization, Date.now());
|
|
8459
|
-
return
|
|
8459
|
+
return cr(t).put(Ns.key, e);
|
|
8460
8460
|
}
|
|
8461
8461
|
static Pt() {
|
|
8462
8462
|
return Xs.Pt();
|
|
8463
8463
|
}
|
|
8464
|
-
/** Checks the primary lease and removes it if we are the current primary. */
|
|
8465
|
-
const e =
|
|
8464
|
+
/** Checks the primary lease and removes it if we are the current primary. */ cn(t) {
|
|
8465
|
+
const e = cr(t);
|
|
8466
8466
|
return e.get(Ns.key).next((t => this.un(t) ? (M("IndexedDbPersistence", "Releasing primary lease."),
|
|
8467
8467
|
e.delete(Ns.key)) : Js.resolve()));
|
|
8468
8468
|
}
|
|
@@ -8546,14 +8546,14 @@ class or {
|
|
|
8546
8546
|
|
|
8547
8547
|
/**
|
|
8548
8548
|
* Helper to get a typed SimpleDbStore for the primary client object store.
|
|
8549
|
-
*/ function
|
|
8550
|
-
return
|
|
8549
|
+
*/ function cr(t) {
|
|
8550
|
+
return ci(t, Ns.store);
|
|
8551
8551
|
}
|
|
8552
8552
|
|
|
8553
8553
|
/**
|
|
8554
8554
|
* Helper to get a typed SimpleDbStore for the client metadata object store.
|
|
8555
|
-
*/ function
|
|
8556
|
-
return
|
|
8555
|
+
*/ function ar(t) {
|
|
8556
|
+
return ci(t, js.store);
|
|
8557
8557
|
}
|
|
8558
8558
|
|
|
8559
8559
|
/**
|
|
@@ -8808,7 +8808,7 @@ class hr {
|
|
|
8808
8808
|
return 0 === t.filters.length && null === t.limit && null == t.startAt && null == t.endAt && (0 === t.explicitOrderBy.length || 1 === t.explicitOrderBy.length && t.explicitOrderBy[0].field.isKeyField());
|
|
8809
8809
|
}(e) || n.isEqual(ht.min()) ? this.Fn(t, e) : this.Mn.vn(t, s).next((i => {
|
|
8810
8810
|
const r = this.Ln(e, i);
|
|
8811
|
-
return (Ee(e) || Ie(e)) && this.Bn(e.limitType, r, s, n) ? this.Fn(t, e) : ($() <=
|
|
8811
|
+
return (Ee(e) || Ie(e)) && this.Bn(e.limitType, r, s, n) ? this.Fn(t, e) : ($() <= c.DEBUG && M("QueryEngine", "Re-using previous result from %s to execute query: %s", n.toString(), Ce(e)),
|
|
8812
8812
|
this.Mn.getDocumentsMatchingQuery(t, e, n).next((t => (
|
|
8813
8813
|
// We merge `previousResults` into `updateResults`, since
|
|
8814
8814
|
// `updateResults` is already a DocumentMap. If a document is
|
|
@@ -8854,7 +8854,7 @@ class hr {
|
|
|
8854
8854
|
return !!i && (i.hasPendingWrites || i.version.compareTo(s) > 0);
|
|
8855
8855
|
}
|
|
8856
8856
|
Fn(t, e) {
|
|
8857
|
-
return $() <=
|
|
8857
|
+
return $() <= c.DEBUG && M("QueryEngine", "Using full collection scan to execute query:", Ce(e)),
|
|
8858
8858
|
this.Mn.getDocumentsMatchingQuery(t, e, ht.min());
|
|
8859
8859
|
}
|
|
8860
8860
|
}
|
|
@@ -9033,16 +9033,16 @@ function yr(t) {
|
|
|
9033
9033
|
// Reset newTargetDataByTargetMap in case this transaction gets re-run.
|
|
9034
9034
|
i = n.qn;
|
|
9035
9035
|
const o = [];
|
|
9036
|
-
e.targetChanges.forEach(((r,
|
|
9037
|
-
const
|
|
9038
|
-
if (!
|
|
9036
|
+
e.targetChanges.forEach(((r, c) => {
|
|
9037
|
+
const a = i.get(c);
|
|
9038
|
+
if (!a) return;
|
|
9039
9039
|
// Only update the remote keys if the target is still active. This
|
|
9040
9040
|
// ensures that we can persist the updated target data along with
|
|
9041
9041
|
// the updated assignment.
|
|
9042
|
-
o.push(n.He.removeMatchingKeys(t, r.removedDocuments,
|
|
9043
|
-
let u =
|
|
9044
|
-
e.targetMismatches.has(
|
|
9045
|
-
i = i.insert(
|
|
9042
|
+
o.push(n.He.removeMatchingKeys(t, r.removedDocuments, c).next((() => n.He.addMatchingKeys(t, r.addedDocuments, c))));
|
|
9043
|
+
let u = a.withSequenceNumber(t.currentSequenceNumber);
|
|
9044
|
+
e.targetMismatches.has(c) ? u = u.withResumeToken(Et.EMPTY_BYTE_STRING, ht.min()).withLastLimboFreeSnapshotVersion(ht.min()) : r.resumeToken.approximateByteSize() > 0 && (u = u.withResumeToken(r.resumeToken, s)),
|
|
9045
|
+
i = i.insert(c, u),
|
|
9046
9046
|
// Update the target data if there are target changes (or if
|
|
9047
9047
|
// sufficient time has passed since the last update).
|
|
9048
9048
|
/**
|
|
@@ -9074,9 +9074,9 @@ function yr(t) {
|
|
|
9074
9074
|
}
|
|
9075
9075
|
/**
|
|
9076
9076
|
* Notifies local store of the changed views to locally pin documents.
|
|
9077
|
-
*/ (
|
|
9077
|
+
*/ (a, u, r) && o.push(n.He.updateTargetData(t, u));
|
|
9078
9078
|
}));
|
|
9079
|
-
let
|
|
9079
|
+
let c = Pn();
|
|
9080
9080
|
// HACK: The only reason we allow a null snapshot version is so that we
|
|
9081
9081
|
// can synthesize remote events when we get permission denied errors while
|
|
9082
9082
|
// trying to resolve the state of a locally cached document that is in
|
|
@@ -9087,12 +9087,12 @@ function yr(t) {
|
|
|
9087
9087
|
// Each loop iteration only affects its "own" doc, so it's safe to get all the remote
|
|
9088
9088
|
// documents in advance in a single call.
|
|
9089
9089
|
o.push(Tr(t, r, e.documentUpdates, s, void 0).next((t => {
|
|
9090
|
-
|
|
9090
|
+
c = t;
|
|
9091
9091
|
}))), !s.isEqual(ht.min())) {
|
|
9092
9092
|
const e = n.He.getLastRemoteSnapshotVersion(t).next((e => n.He.setTargetsMetadata(t, t.currentSequenceNumber, s)));
|
|
9093
9093
|
o.push(e);
|
|
9094
9094
|
}
|
|
9095
|
-
return Js.waitFor(o).next((() => r.apply(t))).next((() => n.Wn.Vn(t,
|
|
9095
|
+
return Js.waitFor(o).next((() => r.apply(t))).next((() => n.Wn.Vn(t, c))).next((() => c));
|
|
9096
9096
|
})).then((t => (n.qn = i, t)));
|
|
9097
9097
|
}
|
|
9098
9098
|
|
|
@@ -9119,7 +9119,7 @@ i) {
|
|
|
9119
9119
|
return n.forEach((t => r = r.add(t))), e.getEntries(t, r).next((t => {
|
|
9120
9120
|
let r = Pn();
|
|
9121
9121
|
return n.forEach(((n, o) => {
|
|
9122
|
-
const
|
|
9122
|
+
const c = t.get(n), a = (null == i ? void 0 : i.get(n)) || s;
|
|
9123
9123
|
// Note: The order of the steps below is important, since we want
|
|
9124
9124
|
// to ensure that rejected limbo resolutions (which fabricate
|
|
9125
9125
|
// NoDocuments with SnapshotVersion.min()) never add documents to
|
|
@@ -9128,8 +9128,8 @@ i) {
|
|
|
9128
9128
|
// NoDocuments with SnapshotVersion.min() are used in manufactured
|
|
9129
9129
|
// events. We remove these documents from cache since we lost
|
|
9130
9130
|
// access.
|
|
9131
|
-
e.removeEntry(n,
|
|
9132
|
-
r = r.insert(n, o)) : M("LocalStore", "Ignoring outdated watch update for ", n, ". Current version:",
|
|
9131
|
+
e.removeEntry(n, a), r = r.insert(n, o)) : !c.isValidDocument() || o.version.compareTo(c.version) > 0 || 0 === o.version.compareTo(c.version) && c.hasPendingWrites ? (e.addEntry(o, a),
|
|
9132
|
+
r = r.insert(n, o)) : M("LocalStore", "Ignoring outdated watch update for ", n, ". Current version:", c.version, " Watch version:", o.version);
|
|
9133
9133
|
})), r;
|
|
9134
9134
|
}));
|
|
9135
9135
|
}
|
|
@@ -9247,10 +9247,10 @@ function Pr(t) {
|
|
|
9247
9247
|
return e.persistence.runTransaction("Get new document changes", "readonly", (t => function(t, e, n) {
|
|
9248
9248
|
const s = j(t);
|
|
9249
9249
|
let i = Pn(), r = wi(n);
|
|
9250
|
-
const o = er(e),
|
|
9250
|
+
const o = er(e), c = IDBKeyRange.lowerBound(r, !0);
|
|
9251
9251
|
return o.jt({
|
|
9252
9252
|
index: Fs.readTimeIndex,
|
|
9253
|
-
range:
|
|
9253
|
+
range: c
|
|
9254
9254
|
}, ((t, e) => {
|
|
9255
9255
|
// Unlike `getEntry()` and others, `getNewDocumentChanges()` parses
|
|
9256
9256
|
// the documents directly since we want to keep sentinel deletes.
|
|
@@ -9307,12 +9307,12 @@ async function vr(t) {
|
|
|
9307
9307
|
*/
|
|
9308
9308
|
async function Vr(t, e, n, s) {
|
|
9309
9309
|
const i = j(t);
|
|
9310
|
-
let r = Nn(), o = Pn(),
|
|
9310
|
+
let r = Nn(), o = Pn(), c = Dn();
|
|
9311
9311
|
for (const t of n) {
|
|
9312
9312
|
const n = e.Hn(t.metadata.name);
|
|
9313
|
-
t.document && (r = r.add(n)), o = o.insert(n, e.Jn(t)),
|
|
9313
|
+
t.document && (r = r.add(n)), o = o.insert(n, e.Jn(t)), c = c.insert(n, e.Yn(t.metadata.readTime));
|
|
9314
9314
|
}
|
|
9315
|
-
const
|
|
9315
|
+
const a = i.Qn.newChangeBuffer({
|
|
9316
9316
|
trackRemovals: !0
|
|
9317
9317
|
}), u = await Ir(i, function(t) {
|
|
9318
9318
|
// It is OK that the path used for the query is not valid, because this will
|
|
@@ -9321,7 +9321,7 @@ async function Vr(t, e, n, s) {
|
|
|
9321
9321
|
}(s));
|
|
9322
9322
|
// Allocates a target to hold all document keys from the bundle, such that
|
|
9323
9323
|
// they will not get garbage collected right away.
|
|
9324
|
-
return i.persistence.runTransaction("Apply bundle documents", "readwrite", (t => Tr(t,
|
|
9324
|
+
return i.persistence.runTransaction("Apply bundle documents", "readwrite", (t => Tr(t, a, o, ht.min(), c).next((e => (a.apply(t),
|
|
9325
9325
|
e))).next((e => i.He.removeMatchingKeysForTargetId(t, u.targetId).next((() => i.He.addMatchingKeys(t, r, u.targetId))).next((() => i.Wn.Vn(t, e))).next((() => e))))));
|
|
9326
9326
|
}
|
|
9327
9327
|
|
|
@@ -9525,7 +9525,7 @@ class Nr {
|
|
|
9525
9525
|
addMutationBatch(t, e, n, s) {
|
|
9526
9526
|
const i = this.ds;
|
|
9527
9527
|
this.ds++, this.An.length > 0 && this.An[this.An.length - 1];
|
|
9528
|
-
const r = new
|
|
9528
|
+
const r = new ai(i, e, n, s);
|
|
9529
9529
|
this.An.push(r);
|
|
9530
9530
|
// Track references by document key and index collection parents.
|
|
9531
9531
|
for (const e of s) this.ws = this.ws.add(new Nr(e.key, i)), this.Jt.addToCollectionParentIndex(t, e.key.path.popLast());
|
|
@@ -9824,16 +9824,16 @@ class $r extends Yi {
|
|
|
9824
9824
|
return n && (this.lastRemoteSnapshotVersion = n), e > this.As && (this.As = e),
|
|
9825
9825
|
Js.resolve();
|
|
9826
9826
|
}
|
|
9827
|
-
|
|
9827
|
+
ae(t) {
|
|
9828
9828
|
this.Is.set(t.target, t);
|
|
9829
9829
|
const e = t.targetId;
|
|
9830
9830
|
e > this.highestTargetId && (this.bs = new Fi(e), this.highestTargetId = e), t.sequenceNumber > this.As && (this.As = t.sequenceNumber);
|
|
9831
9831
|
}
|
|
9832
9832
|
addTargetData(t, e) {
|
|
9833
|
-
return this.
|
|
9833
|
+
return this.ae(e), this.targetCount += 1, Js.resolve();
|
|
9834
9834
|
}
|
|
9835
9835
|
updateTargetData(t, e) {
|
|
9836
|
-
return this.
|
|
9836
|
+
return this.ae(e), Js.resolve();
|
|
9837
9837
|
}
|
|
9838
9838
|
removeTargetData(t, e) {
|
|
9839
9839
|
return this.Is.delete(e.target), this.Rs.us(e.targetId), this.targetCount -= 1,
|
|
@@ -10350,7 +10350,7 @@ class Gr {
|
|
|
10350
10350
|
this.oi(t);
|
|
10351
10351
|
}
|
|
10352
10352
|
notifyBundleLoaded() {
|
|
10353
|
-
this.
|
|
10353
|
+
this.ci();
|
|
10354
10354
|
}
|
|
10355
10355
|
shutdown() {
|
|
10356
10356
|
this.started && (this.window.removeEventListener("storage", this.Us), this.removeItem(this.Qs),
|
|
@@ -10376,7 +10376,7 @@ class Gr {
|
|
|
10376
10376
|
if (this.started) {
|
|
10377
10377
|
if (null !== e.key) if (this.Gs.test(e.key)) {
|
|
10378
10378
|
if (null == e.newValue) {
|
|
10379
|
-
const t = this.
|
|
10379
|
+
const t = this.ai(e.key);
|
|
10380
10380
|
return this.ui(t, null);
|
|
10381
10381
|
}
|
|
10382
10382
|
{
|
|
@@ -10445,13 +10445,13 @@ class Gr {
|
|
|
10445
10445
|
const s = qr(this.persistenceKey, t), i = new jr(t, e, n);
|
|
10446
10446
|
this.setItem(s, i.Ms());
|
|
10447
10447
|
}
|
|
10448
|
-
|
|
10448
|
+
ci() {
|
|
10449
10449
|
this.setItem(this.Ys, "value-not-used");
|
|
10450
10450
|
}
|
|
10451
10451
|
/**
|
|
10452
10452
|
* Parses a client state key in WebStorage. Returns null if the key does not
|
|
10453
10453
|
* match the expected key format.
|
|
10454
|
-
*/
|
|
10454
|
+
*/ ai(t) {
|
|
10455
10455
|
const e = this.Gs.exec(t);
|
|
10456
10456
|
return e ? e[1] : null;
|
|
10457
10457
|
}
|
|
@@ -10459,7 +10459,7 @@ class Gr {
|
|
|
10459
10459
|
* Parses a client state in WebStorage. Returns 'null' if the value could not
|
|
10460
10460
|
* be parsed.
|
|
10461
10461
|
*/ hi(t, e) {
|
|
10462
|
-
const n = this.
|
|
10462
|
+
const n = this.ai(t);
|
|
10463
10463
|
return Qr.Os(n, e);
|
|
10464
10464
|
}
|
|
10465
10465
|
/**
|
|
@@ -10815,8 +10815,8 @@ class {
|
|
|
10815
10815
|
M("Connection", 'RPC "' + t + '" completed.');
|
|
10816
10816
|
}
|
|
10817
10817
|
}));
|
|
10818
|
-
const
|
|
10819
|
-
o.send(e, "POST",
|
|
10818
|
+
const c = JSON.stringify(s);
|
|
10819
|
+
o.send(e, "POST", c, n, 15);
|
|
10820
10820
|
}));
|
|
10821
10821
|
}
|
|
10822
10822
|
Qi(t, e, n) {
|
|
@@ -10861,9 +10861,9 @@ class {
|
|
|
10861
10861
|
// known to (sometimes) not include an Origin. See
|
|
10862
10862
|
// https://github.com/firebase/firebase-js-sdk/issues/1491.
|
|
10863
10863
|
d() || w() || _() || m() || g() || y() || (o.httpHeadersOverwriteParam = "$httpHeaders");
|
|
10864
|
-
const
|
|
10865
|
-
M("Connection", "Creating WebChannel: " +
|
|
10866
|
-
const
|
|
10864
|
+
const c = s.join("");
|
|
10865
|
+
M("Connection", "Creating WebChannel: " + c, o);
|
|
10866
|
+
const a = i.createWebChannel(c, o);
|
|
10867
10867
|
// WebChannel supports sending the first message with the handshake - saving
|
|
10868
10868
|
// a network round trip. However, it will have to call send in the same
|
|
10869
10869
|
// JS event loop as open. In order to enforce this, we delay actually
|
|
@@ -10876,9 +10876,9 @@ class {
|
|
|
10876
10876
|
const l = new Zr({
|
|
10877
10877
|
Vi: t => {
|
|
10878
10878
|
h ? M("Connection", "Not sending because WebChannel is closed:", t) : (u || (M("Connection", "Opening WebChannel transport."),
|
|
10879
|
-
|
|
10879
|
+
a.open(), u = !0), M("Connection", "WebChannel sending:", t), a.send(t));
|
|
10880
10880
|
},
|
|
10881
|
-
Si: () =>
|
|
10881
|
+
Si: () => a.close()
|
|
10882
10882
|
}), f = (t, e, n) => {
|
|
10883
10883
|
// TODO(dimond): closure typing seems broken because WebChannel does
|
|
10884
10884
|
// not implement goog.events.Listenable
|
|
@@ -10896,13 +10896,13 @@ class {
|
|
|
10896
10896
|
// exception and rethrow using a setTimeout so they become visible again.
|
|
10897
10897
|
// Note that eventually this function could go away if we are confident
|
|
10898
10898
|
// enough the code is exception free.
|
|
10899
|
-
return f(
|
|
10899
|
+
return f(a, V.EventType.OPEN, (() => {
|
|
10900
10900
|
h || M("Connection", "WebChannel transport opened.");
|
|
10901
|
-
})), f(
|
|
10901
|
+
})), f(a, V.EventType.CLOSE, (() => {
|
|
10902
10902
|
h || (h = !0, M("Connection", "WebChannel transport closed"), l.Oi());
|
|
10903
|
-
})), f(
|
|
10903
|
+
})), f(a, V.EventType.ERROR, (t => {
|
|
10904
10904
|
h || (h = !0, L("Connection", "WebChannel transport errored:", t), l.Oi(new W(Q.UNAVAILABLE, "The operation could not be completed")));
|
|
10905
|
-
})), f(
|
|
10905
|
+
})), f(a, V.EventType.MESSAGE, (t => {
|
|
10906
10906
|
var e;
|
|
10907
10907
|
if (!h) {
|
|
10908
10908
|
const n = t.data[0];
|
|
@@ -10932,7 +10932,7 @@ class {
|
|
|
10932
10932
|
}(t), n = i.message;
|
|
10933
10933
|
void 0 === e && (e = Q.INTERNAL, n = "Unknown error status: " + t + " with message " + i.message),
|
|
10934
10934
|
// Mark closed so no further events are propagated
|
|
10935
|
-
h = !0, l.Oi(new W(e, n)),
|
|
10935
|
+
h = !0, l.Oi(new W(e, n)), a.close();
|
|
10936
10936
|
} else M("Connection", "WebChannel received:", n), l.Mi(n);
|
|
10937
10937
|
}
|
|
10938
10938
|
})), f(r, S.STAT_EVENT, (t => {
|
|
@@ -11147,15 +11147,15 @@ class io {
|
|
|
11147
11147
|
* ListenerType: The type of the listener that will be used for callbacks
|
|
11148
11148
|
*/
|
|
11149
11149
|
class ro {
|
|
11150
|
-
constructor(t, e, n, s, i, r, o,
|
|
11150
|
+
constructor(t, e, n, s, i, r, o, c) {
|
|
11151
11151
|
this.Me = t, this.nr = n, this.sr = s, this.ir = i, this.authCredentialsProvider = r,
|
|
11152
|
-
this.appCheckCredentialsProvider = o, this.listener =
|
|
11152
|
+
this.appCheckCredentialsProvider = o, this.listener = c, this.state = 0 /* Initial */ ,
|
|
11153
11153
|
/**
|
|
11154
11154
|
* A close count that's incremented every time the stream is closed; used by
|
|
11155
11155
|
* getCloseGuardedDispatcher() to invalidate callbacks that happen after
|
|
11156
11156
|
* close.
|
|
11157
11157
|
*/
|
|
11158
|
-
this.rr = 0, this.
|
|
11158
|
+
this.rr = 0, this.cr = null, this.ar = null, this.stream = null, this.ur = new io(t, e);
|
|
11159
11159
|
}
|
|
11160
11160
|
/**
|
|
11161
11161
|
* Returns true if start() has been called and no error has occurred. True
|
|
@@ -11211,7 +11211,7 @@ class ro {
|
|
|
11211
11211
|
*/ _r() {
|
|
11212
11212
|
// Starts the idle time if we are in state 'Open' and are not yet already
|
|
11213
11213
|
// running a timer (in which case the previous idle timeout still applies).
|
|
11214
|
-
this.lr() && null === this.
|
|
11214
|
+
this.lr() && null === this.cr && (this.cr = this.Me.enqueueAfterDelay(this.nr, 6e4, (() => this.mr())));
|
|
11215
11215
|
}
|
|
11216
11216
|
/** Sends a message to the underlying stream. */ gr(t) {
|
|
11217
11217
|
this.yr(), this.stream.send(t);
|
|
@@ -11223,10 +11223,10 @@ class ro {
|
|
|
11223
11223
|
return this.close(0 /* Initial */);
|
|
11224
11224
|
}
|
|
11225
11225
|
/** Marks the stream as active again. */ yr() {
|
|
11226
|
-
this.
|
|
11226
|
+
this.cr && (this.cr.cancel(), this.cr = null);
|
|
11227
11227
|
}
|
|
11228
11228
|
/** Cancels the health check delayed operation. */ pr() {
|
|
11229
|
-
this.
|
|
11229
|
+
this.ar && (this.ar.cancel(), this.ar = null);
|
|
11230
11230
|
}
|
|
11231
11231
|
/**
|
|
11232
11232
|
* Closes the stream and cleans up as necessary:
|
|
@@ -11294,7 +11294,7 @@ class ro {
|
|
|
11294
11294
|
Ir(t, e) {
|
|
11295
11295
|
const n = this.Er(this.rr);
|
|
11296
11296
|
this.stream = this.Rr(t, e), this.stream.Di((() => {
|
|
11297
|
-
n((() => (this.state = 2 /* Open */ , this.
|
|
11297
|
+
n((() => (this.state = 2 /* Open */ , this.ar = this.Me.enqueueAfterDelay(this.sr, 1e4, (() => (this.lr() && (this.state = 3 /* Healthy */),
|
|
11298
11298
|
Promise.resolve()))), this.listener.Di())));
|
|
11299
11299
|
})), this.stream.Ni((t => {
|
|
11300
11300
|
n((() => this.Ar(t)));
|
|
@@ -11345,7 +11345,7 @@ class ro {
|
|
|
11345
11345
|
onMessage(t) {
|
|
11346
11346
|
// A successful response means the stream is healthy
|
|
11347
11347
|
this.ur.reset();
|
|
11348
|
-
const e =
|
|
11348
|
+
const e = as(this.k, t), n = function(t) {
|
|
11349
11349
|
// We have only reached a consistent snapshot for the entire stream if there
|
|
11350
11350
|
// is a read_time set and it applies to all targets (i.e. the list of
|
|
11351
11351
|
// targets is empty). The backend is guaranteed to send such responses.
|
|
@@ -11403,7 +11403,7 @@ class ro {
|
|
|
11403
11403
|
* okay to use the same streamToken for the calls to writeMutations.
|
|
11404
11404
|
*
|
|
11405
11405
|
* TODO(b/33271235): Use proto types
|
|
11406
|
-
*/ class
|
|
11406
|
+
*/ class co extends ro {
|
|
11407
11407
|
constructor(t, e, n, s, i, r) {
|
|
11408
11408
|
super(t, "write_stream_connection_backoff" /* WriteStreamConnectionBackoff */ , "write_stream_idle" /* WriteStreamIdle */ , "health_check_timeout" /* HealthCheckTimeout */ , e, n, s, r),
|
|
11409
11409
|
this.k = i, this.Vr = !1;
|
|
@@ -11482,7 +11482,7 @@ class ro {
|
|
|
11482
11482
|
* An implementation of Datastore that exposes additional state for internal
|
|
11483
11483
|
* consumption.
|
|
11484
11484
|
*/
|
|
11485
|
-
class
|
|
11485
|
+
class ao extends class {} {
|
|
11486
11486
|
constructor(t, e, n, s) {
|
|
11487
11487
|
super(), this.authCredentials = t, this.appCheckCredentials = e, this.ir = n, this.k = s,
|
|
11488
11488
|
this.$r = !1;
|
|
@@ -12009,7 +12009,7 @@ async function Oo(t, e) {
|
|
|
12009
12009
|
// Create stream (but note that it is not started yet).
|
|
12010
12010
|
t.Zr = function(t, e, n) {
|
|
12011
12011
|
const s = j(t);
|
|
12012
|
-
return s.Or(), new
|
|
12012
|
+
return s.Or(), new co(e, s.ir, s.authCredentials, s.appCheckCredentials, s.k, n);
|
|
12013
12013
|
}(t.datastore, t.asyncQueue, {
|
|
12014
12014
|
Di: No.bind(null, t),
|
|
12015
12015
|
Ni: $o.bind(null, t),
|
|
@@ -12270,9 +12270,9 @@ class Lo {
|
|
|
12270
12270
|
}
|
|
12271
12271
|
|
|
12272
12272
|
class Ko {
|
|
12273
|
-
constructor(t, e, n, s, i, r, o,
|
|
12273
|
+
constructor(t, e, n, s, i, r, o, c) {
|
|
12274
12274
|
this.query = t, this.docs = e, this.oldDocs = n, this.docChanges = s, this.mutatedKeys = i,
|
|
12275
|
-
this.fromCache = r, this.syncStateChanged = o, this.excludesMetadataChanges =
|
|
12275
|
+
this.fromCache = r, this.syncStateChanged = o, this.excludesMetadataChanges = c;
|
|
12276
12276
|
}
|
|
12277
12277
|
/** Returns a view snapshot as if all documents in the snapshot were added. */ static fromInitialDocuments(t, e, n, s) {
|
|
12278
12278
|
const i = [];
|
|
@@ -12391,12 +12391,12 @@ function Jo(t) {
|
|
|
12391
12391
|
* It uses an Observer to dispatch events.
|
|
12392
12392
|
*/ class Yo {
|
|
12393
12393
|
constructor(t, e, n) {
|
|
12394
|
-
this.query = t, this.
|
|
12394
|
+
this.query = t, this.co = e,
|
|
12395
12395
|
/**
|
|
12396
12396
|
* Initial snapshots (e.g. from cache) may not be propagated to the wrapped
|
|
12397
12397
|
* observer. This flag is set to true once we've actually raised an event.
|
|
12398
12398
|
*/
|
|
12399
|
-
this.
|
|
12399
|
+
this.ao = !1, this.uo = null, this.onlineState = "Unknown" /* Unknown */ , this.options = n || {};
|
|
12400
12400
|
}
|
|
12401
12401
|
/**
|
|
12402
12402
|
* Applies the new ViewSnapshot to this listener, raising a user-facing event
|
|
@@ -12412,16 +12412,16 @@ function Jo(t) {
|
|
|
12412
12412
|
/* excludesMetadataChanges= */ !0);
|
|
12413
12413
|
}
|
|
12414
12414
|
let e = !1;
|
|
12415
|
-
return this.
|
|
12415
|
+
return this.ao ? this.ho(t) && (this.co.next(t), e = !0) : this.lo(t, this.onlineState) && (this.fo(t),
|
|
12416
12416
|
e = !0), this.uo = t, e;
|
|
12417
12417
|
}
|
|
12418
12418
|
onError(t) {
|
|
12419
|
-
this.
|
|
12419
|
+
this.co.error(t);
|
|
12420
12420
|
}
|
|
12421
12421
|
/** Returns whether a snapshot was raised. */ ro(t) {
|
|
12422
12422
|
this.onlineState = t;
|
|
12423
12423
|
let e = !1;
|
|
12424
|
-
return this.uo && !this.
|
|
12424
|
+
return this.uo && !this.ao && this.lo(this.uo, t) && (this.fo(this.uo), e = !0),
|
|
12425
12425
|
e;
|
|
12426
12426
|
}
|
|
12427
12427
|
lo(t, e) {
|
|
@@ -12448,8 +12448,8 @@ function Jo(t) {
|
|
|
12448
12448
|
// stripped out.
|
|
12449
12449
|
}
|
|
12450
12450
|
fo(t) {
|
|
12451
|
-
t = Ko.fromInitialDocuments(t.query, t.docs, t.mutatedKeys, t.fromCache), this.
|
|
12452
|
-
this.
|
|
12451
|
+
t = Ko.fromInitialDocuments(t.query, t.docs, t.mutatedKeys, t.fromCache), this.ao = !0,
|
|
12452
|
+
this.co.next(t);
|
|
12453
12453
|
}
|
|
12454
12454
|
}
|
|
12455
12455
|
|
|
@@ -12521,13 +12521,13 @@ function Jo(t) {
|
|
|
12521
12521
|
/**
|
|
12522
12522
|
* A class to process the elements from a bundle, load them into local
|
|
12523
12523
|
* storage and provide progress update while loading.
|
|
12524
|
-
*/ class
|
|
12524
|
+
*/ class tc {
|
|
12525
12525
|
constructor(t, e, n) {
|
|
12526
12526
|
this.mo = t, this.localStore = e, this.k = n,
|
|
12527
12527
|
/** Batched queries to be saved into storage */
|
|
12528
12528
|
this.queries = [],
|
|
12529
12529
|
/** Batched documents to be saved into storage */
|
|
12530
|
-
this.documents = [], this.progress =
|
|
12530
|
+
this.documents = [], this.progress = ec(t);
|
|
12531
12531
|
}
|
|
12532
12532
|
/**
|
|
12533
12533
|
* Adds an element from the bundle to the loader.
|
|
@@ -12566,7 +12566,7 @@ function Jo(t) {
|
|
|
12566
12566
|
/**
|
|
12567
12567
|
* Returns a `LoadBundleTaskProgress` representing the initial progress of
|
|
12568
12568
|
* loading a bundle.
|
|
12569
|
-
*/ function
|
|
12569
|
+
*/ function ec(t) {
|
|
12570
12570
|
return {
|
|
12571
12571
|
taskState: "Running",
|
|
12572
12572
|
documentsLoaded: 0,
|
|
@@ -12596,13 +12596,13 @@ function Jo(t) {
|
|
|
12596
12596
|
* See the License for the specific language governing permissions and
|
|
12597
12597
|
* limitations under the License.
|
|
12598
12598
|
*/
|
|
12599
|
-
class
|
|
12599
|
+
class nc {
|
|
12600
12600
|
constructor(t) {
|
|
12601
12601
|
this.key = t;
|
|
12602
12602
|
}
|
|
12603
12603
|
}
|
|
12604
12604
|
|
|
12605
|
-
class
|
|
12605
|
+
class sc {
|
|
12606
12606
|
constructor(t) {
|
|
12607
12607
|
this.key = t;
|
|
12608
12608
|
}
|
|
@@ -12612,7 +12612,7 @@ class sa {
|
|
|
12612
12612
|
* View is responsible for computing the final merged truth of what docs are in
|
|
12613
12613
|
* a query. It gets notified of local and remote changes to docs, and applies
|
|
12614
12614
|
* the query filters and limits to determine the most correct possible results.
|
|
12615
|
-
*/ class
|
|
12615
|
+
*/ class ic {
|
|
12616
12616
|
constructor(t,
|
|
12617
12617
|
/** Documents included in the remote target */
|
|
12618
12618
|
e) {
|
|
@@ -12655,7 +12655,7 @@ class sa {
|
|
|
12655
12655
|
// deletes. So we keep this doc at the old limit to compare the updates to.
|
|
12656
12656
|
// Note that this should never get used in a refill (when previousChanges is
|
|
12657
12657
|
// set), because there will only be adds -- no deletes or updates.
|
|
12658
|
-
const
|
|
12658
|
+
const c = Ee(this.query) && s.size === this.query.limit ? s.last() : null, a = Ie(this.query) && s.size === this.query.limit ? s.first() : null;
|
|
12659
12659
|
// Drop documents out to meet limit/limitToLast requirement.
|
|
12660
12660
|
if (t.inorderTraversal(((t, e) => {
|
|
12661
12661
|
const u = s.get(t), h = Ne(this.query, e) ? e : null, l = !!u && this.mutatedKeys.has(u.key), f = !!h && (h.hasLocalMutations ||
|
|
@@ -12671,7 +12671,7 @@ class sa {
|
|
|
12671
12671
|
}), d = !0) : this.Vo(u, h) || (n.track({
|
|
12672
12672
|
type: 2 /* Modified */ ,
|
|
12673
12673
|
doc: h
|
|
12674
|
-
}), d = !0, (
|
|
12674
|
+
}), d = !0, (c && this.Ao(h, c) > 0 || a && this.Ao(h, a) < 0) && (
|
|
12675
12675
|
// This doc moved from inside the limit to outside the limit.
|
|
12676
12676
|
// That means there may be some other doc in the local cache
|
|
12677
12677
|
// that should be included instead.
|
|
@@ -12682,7 +12682,7 @@ class sa {
|
|
|
12682
12682
|
}), d = !0) : u && !h && (n.track({
|
|
12683
12683
|
type: 1 /* Removed */ ,
|
|
12684
12684
|
doc: u
|
|
12685
|
-
}), d = !0, (
|
|
12685
|
+
}), d = !0, (c || a) && (
|
|
12686
12686
|
// A doc was removed from a full limit query. We'll need to
|
|
12687
12687
|
// requery from the local cache to see if we know about some other
|
|
12688
12688
|
// doc that should be in the results.
|
|
@@ -12766,10 +12766,10 @@ class sa {
|
|
|
12766
12766
|
* See the License for the specific language governing permissions and
|
|
12767
12767
|
* limitations under the License.
|
|
12768
12768
|
*/ (t.type, e.type) || this.Ao(t.doc, e.doc))), this.So(n);
|
|
12769
|
-
const r = e ? this.Do() : [], o = 0 === this.Io.size && this.current ? 1 /* Synced */ : 0 /* Local */ ,
|
|
12770
|
-
if (this.Eo = o, 0 !== i.length ||
|
|
12769
|
+
const r = e ? this.Do() : [], o = 0 === this.Io.size && this.current ? 1 /* Synced */ : 0 /* Local */ , c = o !== this.Eo;
|
|
12770
|
+
if (this.Eo = o, 0 !== i.length || c) {
|
|
12771
12771
|
return {
|
|
12772
|
-
snapshot: new Ko(this.query, t.Ro, s, i, t.mutatedKeys, 0 /* Local */ === o,
|
|
12772
|
+
snapshot: new Ko(this.query, t.Ro, s, i, t.mutatedKeys, 0 /* Local */ === o, c,
|
|
12773
12773
|
/* excludesMetadataChanges= */ !1),
|
|
12774
12774
|
Co: r
|
|
12775
12775
|
};
|
|
@@ -12825,9 +12825,9 @@ class sa {
|
|
|
12825
12825
|
// Diff the new limbo docs with the old limbo docs.
|
|
12826
12826
|
const e = [];
|
|
12827
12827
|
return t.forEach((t => {
|
|
12828
|
-
this.Io.has(t) || e.push(new
|
|
12828
|
+
this.Io.has(t) || e.push(new sc(t));
|
|
12829
12829
|
})), this.Io.forEach((n => {
|
|
12830
|
-
t.has(n) || e.push(new
|
|
12830
|
+
t.has(n) || e.push(new nc(n));
|
|
12831
12831
|
})), e;
|
|
12832
12832
|
}
|
|
12833
12833
|
/**
|
|
@@ -12870,7 +12870,7 @@ class sa {
|
|
|
12870
12870
|
* QueryView contains all of the data that SyncEngine needs to keep track of for
|
|
12871
12871
|
* a particular query.
|
|
12872
12872
|
*/
|
|
12873
|
-
class
|
|
12873
|
+
class rc {
|
|
12874
12874
|
constructor(
|
|
12875
12875
|
/**
|
|
12876
12876
|
* The query itself.
|
|
@@ -12892,7 +12892,7 @@ class ra {
|
|
|
12892
12892
|
}
|
|
12893
12893
|
}
|
|
12894
12894
|
|
|
12895
|
-
/** Tracks a limbo resolution. */ class
|
|
12895
|
+
/** Tracks a limbo resolution. */ class oc {
|
|
12896
12896
|
constructor(t) {
|
|
12897
12897
|
this.key = t,
|
|
12898
12898
|
/**
|
|
@@ -12917,7 +12917,7 @@ class ra {
|
|
|
12917
12917
|
* the class is not exported so they are only accessible from this module.
|
|
12918
12918
|
* This is useful to implement optional features (like bundles) in free
|
|
12919
12919
|
* functions, such that they are tree-shakeable.
|
|
12920
|
-
*/ class
|
|
12920
|
+
*/ class cc {
|
|
12921
12921
|
constructor(t, e, n,
|
|
12922
12922
|
// PORTING NOTE: Manages state synchronization in multi-tab environments.
|
|
12923
12923
|
s, i, r) {
|
|
@@ -12963,8 +12963,8 @@ class ra {
|
|
|
12963
12963
|
* server. All the subsequent view snapshots or errors are sent to the
|
|
12964
12964
|
* subscribed handlers. Returns the initial snapshot.
|
|
12965
12965
|
*/
|
|
12966
|
-
async function
|
|
12967
|
-
const n =
|
|
12966
|
+
async function ac(t, e) {
|
|
12967
|
+
const n = Mc(t);
|
|
12968
12968
|
let s, i;
|
|
12969
12969
|
const r = n.Mo.get(e);
|
|
12970
12970
|
if (r)
|
|
@@ -12976,7 +12976,7 @@ async function ca(t, e) {
|
|
|
12976
12976
|
// case and calls `listen` to obtain this ID.
|
|
12977
12977
|
s = r.targetId, n.sharedClientState.addLocalQueryTarget(s), i = r.view.xo(); else {
|
|
12978
12978
|
const t = await Ir(n.localStore, ve(e)), r = n.sharedClientState.addLocalQueryTarget(t.targetId);
|
|
12979
|
-
s = t.targetId, i = await
|
|
12979
|
+
s = t.targetId, i = await uc(n, e, s, "current" === r), n.isPrimaryClient && wo(n.remoteStore, t);
|
|
12980
12980
|
}
|
|
12981
12981
|
return i;
|
|
12982
12982
|
}
|
|
@@ -12984,7 +12984,7 @@ async function ca(t, e) {
|
|
|
12984
12984
|
/**
|
|
12985
12985
|
* Registers a view for a previously unknown query and computes its initial
|
|
12986
12986
|
* snapshot.
|
|
12987
|
-
*/ async function
|
|
12987
|
+
*/ async function uc(t, e, n, s) {
|
|
12988
12988
|
// PORTING NOTE: On Web only, we inject the code that registers new Limbo
|
|
12989
12989
|
// targets based on view changes. This allows us to only depend on Limbo
|
|
12990
12990
|
// changes when user code includes queries.
|
|
@@ -12998,17 +12998,17 @@ async function ca(t, e) {
|
|
|
12998
12998
|
/* usePreviousResults= */ !1).then((({documents: t}) => e.view.Po(t, i))));
|
|
12999
12999
|
const r = s && s.targetChanges.get(e.targetId), o = e.view.applyChanges(i,
|
|
13000
13000
|
/* updateLimboDocuments= */ t.isPrimaryClient, r);
|
|
13001
|
-
return
|
|
13001
|
+
return Ic(t, e.targetId, o.Co), o.snapshot;
|
|
13002
13002
|
}(t, e, n, s);
|
|
13003
13003
|
const i = await Rr(t.localStore, e,
|
|
13004
|
-
/* usePreviousResults= */ !0), r = new
|
|
13005
|
-
/* updateLimboDocuments= */ t.isPrimaryClient,
|
|
13006
|
-
|
|
13007
|
-
const u = new
|
|
13008
|
-
return t.Mo.set(e, u), t.Fo.has(n) ? t.Fo.get(n).push(e) : t.Fo.set(n, [ e ]),
|
|
13004
|
+
/* usePreviousResults= */ !0), r = new ic(e, i.zn), o = r.Po(i.documents), c = On.createSynthesizedTargetChangeForCurrentChange(n, s && "Offline" /* Offline */ !== t.onlineState), a = r.applyChanges(o,
|
|
13005
|
+
/* updateLimboDocuments= */ t.isPrimaryClient, c);
|
|
13006
|
+
Ic(t, n, a.Co);
|
|
13007
|
+
const u = new rc(e, n, r);
|
|
13008
|
+
return t.Mo.set(e, u), t.Fo.has(n) ? t.Fo.get(n).push(e) : t.Fo.set(n, [ e ]), a.snapshot;
|
|
13009
13009
|
}
|
|
13010
13010
|
|
|
13011
|
-
/** Stops listening to the query. */ async function
|
|
13011
|
+
/** Stops listening to the query. */ async function hc(t, e) {
|
|
13012
13012
|
const n = j(t), s = n.Mo.get(e), i = n.Fo.get(s.targetId);
|
|
13013
13013
|
if (i.length > 1) return n.Fo.set(s.targetId, i.filter((t => !Se(t, e)))), void n.Mo.delete(e);
|
|
13014
13014
|
// No other queries are mapped to the target, clean up the query and the target.
|
|
@@ -13019,9 +13019,9 @@ async function ca(t, e) {
|
|
|
13019
13019
|
n.sharedClientState.isActiveQueryTarget(s.targetId) || await Ar(n.localStore, s.targetId,
|
|
13020
13020
|
/*keepPersistedTargetData=*/ !1).then((() => {
|
|
13021
13021
|
n.sharedClientState.clearQueryState(s.targetId), _o(n.remoteStore, s.targetId),
|
|
13022
|
-
|
|
13022
|
+
Tc(n, s.targetId);
|
|
13023
13023
|
})).catch(Ki);
|
|
13024
|
-
} else
|
|
13024
|
+
} else Tc(n, s.targetId), await Ar(n.localStore, s.targetId,
|
|
13025
13025
|
/*keepPersistedTargetData=*/ !0);
|
|
13026
13026
|
}
|
|
13027
13027
|
|
|
@@ -13034,8 +13034,8 @@ async function ca(t, e) {
|
|
|
13034
13034
|
* have completed, *not* when the write was acked by the backend. The
|
|
13035
13035
|
* userCallback is resolved once the write was acked/rejected by the
|
|
13036
13036
|
* backend (or failed locally for any other reason).
|
|
13037
|
-
*/ async function
|
|
13038
|
-
const s =
|
|
13037
|
+
*/ async function lc(t, e, n) {
|
|
13038
|
+
const s = Fc(t);
|
|
13039
13039
|
try {
|
|
13040
13040
|
const t = await function(t, e) {
|
|
13041
13041
|
const n = j(t), s = ut.now(), i = e.reduce(((t, e) => t.add(e.key)), Nn());
|
|
@@ -13070,7 +13070,7 @@ async function ca(t, e) {
|
|
|
13070
13070
|
/**
|
|
13071
13071
|
* Resolves or rejects the user callback for the given batch and then discards
|
|
13072
13072
|
* it.
|
|
13073
|
-
*/ (s, t.batchId, n), await
|
|
13073
|
+
*/ (s, t.batchId, n), await bc(s, t.changes), await vo(s.remoteStore);
|
|
13074
13074
|
} catch (t) {
|
|
13075
13075
|
// If we can't persist the mutation, we reject the user callback and
|
|
13076
13076
|
// don't send the mutation. The user can then retry the write.
|
|
@@ -13083,7 +13083,7 @@ async function ca(t, e) {
|
|
|
13083
13083
|
* Applies one remote event to the sync engine, notifying any views of the
|
|
13084
13084
|
* changes, and releasing any pending mutation batches that would become
|
|
13085
13085
|
* visible because of the snapshot version the remote event contains.
|
|
13086
|
-
*/ async function
|
|
13086
|
+
*/ async function fc(t, e) {
|
|
13087
13087
|
const n = j(t);
|
|
13088
13088
|
try {
|
|
13089
13089
|
const t = await pr(n.localStore, e);
|
|
@@ -13096,7 +13096,7 @@ async function ca(t, e) {
|
|
|
13096
13096
|
q(t.addedDocuments.size + t.modifiedDocuments.size + t.removedDocuments.size <= 1),
|
|
13097
13097
|
t.addedDocuments.size > 0 ? s.$o = !0 : t.modifiedDocuments.size > 0 ? q(s.$o) : t.removedDocuments.size > 0 && (q(s.$o),
|
|
13098
13098
|
s.$o = !1));
|
|
13099
|
-
})), await
|
|
13099
|
+
})), await bc(n, t, e);
|
|
13100
13100
|
} catch (t) {
|
|
13101
13101
|
await Ki(t);
|
|
13102
13102
|
}
|
|
@@ -13105,7 +13105,7 @@ async function ca(t, e) {
|
|
|
13105
13105
|
/**
|
|
13106
13106
|
* Applies an OnlineState change to the sync engine and notifies any views of
|
|
13107
13107
|
* the change.
|
|
13108
|
-
*/ function
|
|
13108
|
+
*/ function dc(t, e, n) {
|
|
13109
13109
|
const s = j(t);
|
|
13110
13110
|
// If we are the secondary client, we explicitly ignore the remote store's
|
|
13111
13111
|
// online state (the local client may go offline, even though the primary
|
|
@@ -13139,7 +13139,7 @@ async function ca(t, e) {
|
|
|
13139
13139
|
* @param err - A description of the condition that has forced the rejection.
|
|
13140
13140
|
* Nearly always this will be an indication that the user is no longer
|
|
13141
13141
|
* authorized to see the data matching the target.
|
|
13142
|
-
*/ async function
|
|
13142
|
+
*/ async function wc(t, e, n) {
|
|
13143
13143
|
const s = j(t);
|
|
13144
13144
|
// PORTING NOTE: Multi-tab only.
|
|
13145
13145
|
s.sharedClientState.updateQueryState(e, "rejected", n);
|
|
@@ -13156,18 +13156,18 @@ async function ca(t, e) {
|
|
|
13156
13156
|
const n = Nn().add(r), i = new $n(ht.min(),
|
|
13157
13157
|
/* targetChanges= */ new Map,
|
|
13158
13158
|
/* targetMismatches= */ new An(ot), t, n);
|
|
13159
|
-
await
|
|
13159
|
+
await fc(s, i),
|
|
13160
13160
|
// Since this query failed, we won't want to manually unlisten to it.
|
|
13161
13161
|
// We only remove it from bookkeeping after we successfully applied the
|
|
13162
13162
|
// RemoteEvent. If `applyRemoteEvent()` throws, we want to re-listen to
|
|
13163
13163
|
// this query when the RemoteStore restarts the Watch stream, which should
|
|
13164
13164
|
// re-trigger the target failure.
|
|
13165
|
-
s.Bo = s.Bo.remove(r), s.Uo.delete(e),
|
|
13165
|
+
s.Bo = s.Bo.remove(r), s.Uo.delete(e), Rc(s);
|
|
13166
13166
|
} else await Ar(s.localStore, e,
|
|
13167
|
-
/* keepPersistedTargetData */ !1).then((() =>
|
|
13167
|
+
/* keepPersistedTargetData */ !1).then((() => Tc(s, e, n))).catch(Ki);
|
|
13168
13168
|
}
|
|
13169
13169
|
|
|
13170
|
-
async function
|
|
13170
|
+
async function _c(t, e) {
|
|
13171
13171
|
const n = j(t), s = e.batch.batchId;
|
|
13172
13172
|
try {
|
|
13173
13173
|
const t = await gr(n.localStore, e);
|
|
@@ -13175,14 +13175,14 @@ async function _a(t, e) {
|
|
|
13175
13175
|
// raise events immediately (depending on whether the watcher is caught
|
|
13176
13176
|
// up), so we raise user callbacks first so that they consistently happen
|
|
13177
13177
|
// before listen events.
|
|
13178
|
-
|
|
13179
|
-
await
|
|
13178
|
+
pc(n, s, /*error=*/ null), yc(n, s), n.sharedClientState.updateMutationState(s, "acknowledged"),
|
|
13179
|
+
await bc(n, t);
|
|
13180
13180
|
} catch (t) {
|
|
13181
13181
|
await Ki(t);
|
|
13182
13182
|
}
|
|
13183
13183
|
}
|
|
13184
13184
|
|
|
13185
|
-
async function
|
|
13185
|
+
async function mc(t, e, n) {
|
|
13186
13186
|
const s = j(t);
|
|
13187
13187
|
try {
|
|
13188
13188
|
const t = await function(t, e) {
|
|
@@ -13202,8 +13202,8 @@ async function ma(t, e, n) {
|
|
|
13202
13202
|
// raise events immediately (depending on whether the watcher is caught up),
|
|
13203
13203
|
// so we raise user callbacks first so that they consistently happen before
|
|
13204
13204
|
// listen events.
|
|
13205
|
-
|
|
13206
|
-
await
|
|
13205
|
+
pc(s, e, n), yc(s, e), s.sharedClientState.updateMutationState(e, "rejected", n),
|
|
13206
|
+
await bc(s, t);
|
|
13207
13207
|
} catch (n) {
|
|
13208
13208
|
await Ki(n);
|
|
13209
13209
|
}
|
|
@@ -13212,7 +13212,7 @@ async function ma(t, e, n) {
|
|
|
13212
13212
|
/**
|
|
13213
13213
|
* Registers a user callback that resolves when all pending mutations at the moment of calling
|
|
13214
13214
|
* are acknowledged .
|
|
13215
|
-
*/ async function
|
|
13215
|
+
*/ async function gc(t, e) {
|
|
13216
13216
|
const n = j(t);
|
|
13217
13217
|
To(n.remoteStore) || M("SyncEngine", "The network is disabled. The task returned by 'awaitPendingWrites()' will not complete until the network is enabled.");
|
|
13218
13218
|
try {
|
|
@@ -13234,13 +13234,13 @@ async function ma(t, e, n) {
|
|
|
13234
13234
|
/**
|
|
13235
13235
|
* Triggers the callbacks that are waiting for this batch id to get acknowledged by server,
|
|
13236
13236
|
* if there are any.
|
|
13237
|
-
*/ function
|
|
13237
|
+
*/ function yc(t, e) {
|
|
13238
13238
|
(t.jo.get(e) || []).forEach((t => {
|
|
13239
13239
|
t.resolve();
|
|
13240
13240
|
})), t.jo.delete(e);
|
|
13241
13241
|
}
|
|
13242
13242
|
|
|
13243
|
-
/** Reject all outstanding callbacks waiting for pending writes to complete. */ function
|
|
13243
|
+
/** Reject all outstanding callbacks waiting for pending writes to complete. */ function pc(t, e, n) {
|
|
13244
13244
|
const s = j(t);
|
|
13245
13245
|
let i = s.Ko[s.currentUser.toKey()];
|
|
13246
13246
|
// NOTE: Mutations restored from persistence won't have callbacks, so it's
|
|
@@ -13251,39 +13251,39 @@ async function ma(t, e, n) {
|
|
|
13251
13251
|
}
|
|
13252
13252
|
}
|
|
13253
13253
|
|
|
13254
|
-
function
|
|
13254
|
+
function Tc(t, e, n = null) {
|
|
13255
13255
|
t.sharedClientState.removeLocalQueryTarget(e);
|
|
13256
13256
|
for (const s of t.Fo.get(e)) t.Mo.delete(s), n && t.Oo.zo(s, n);
|
|
13257
13257
|
if (t.Fo.delete(e), t.isPrimaryClient) {
|
|
13258
13258
|
t.qo.us(e).forEach((e => {
|
|
13259
13259
|
t.qo.containsKey(e) ||
|
|
13260
13260
|
// We removed the last reference for this key
|
|
13261
|
-
|
|
13261
|
+
Ec(t, e);
|
|
13262
13262
|
}));
|
|
13263
13263
|
}
|
|
13264
13264
|
}
|
|
13265
13265
|
|
|
13266
|
-
function
|
|
13266
|
+
function Ec(t, e) {
|
|
13267
13267
|
t.Lo.delete(e.path.canonicalString());
|
|
13268
13268
|
// It's possible that the target already got removed because the query failed. In that case,
|
|
13269
13269
|
// the key won't exist in `limboTargetsByKey`. Only do the cleanup if we still have the target.
|
|
13270
13270
|
const n = t.Bo.get(e);
|
|
13271
|
-
null !== n && (_o(t.remoteStore, n), t.Bo = t.Bo.remove(e), t.Uo.delete(n),
|
|
13271
|
+
null !== n && (_o(t.remoteStore, n), t.Bo = t.Bo.remove(e), t.Uo.delete(n), Rc(t));
|
|
13272
13272
|
}
|
|
13273
13273
|
|
|
13274
|
-
function
|
|
13275
|
-
for (const s of n) if (s instanceof
|
|
13274
|
+
function Ic(t, e, n) {
|
|
13275
|
+
for (const s of n) if (s instanceof nc) t.qo.addReference(s.key, e), Ac(t, s); else if (s instanceof sc) {
|
|
13276
13276
|
M("SyncEngine", "Document no longer in limbo: " + s.key), t.qo.removeReference(s.key, e);
|
|
13277
13277
|
t.qo.containsKey(s.key) ||
|
|
13278
13278
|
// We removed the last reference for this key
|
|
13279
|
-
|
|
13279
|
+
Ec(t, s.key);
|
|
13280
13280
|
} else U();
|
|
13281
13281
|
}
|
|
13282
13282
|
|
|
13283
|
-
function
|
|
13283
|
+
function Ac(t, e) {
|
|
13284
13284
|
const n = e.key, s = n.path.canonicalString();
|
|
13285
13285
|
t.Bo.get(n) || t.Lo.has(s) || (M("SyncEngine", "New document in limbo: " + n), t.Lo.add(s),
|
|
13286
|
-
|
|
13286
|
+
Rc(t));
|
|
13287
13287
|
}
|
|
13288
13288
|
|
|
13289
13289
|
/**
|
|
@@ -13293,23 +13293,23 @@ function Aa(t, e) {
|
|
|
13293
13293
|
* Without bounding the number of concurrent resolutions, the server can fail
|
|
13294
13294
|
* with "resource exhausted" errors which can lead to pathological client
|
|
13295
13295
|
* behavior as seen in https://github.com/firebase/firebase-js-sdk/issues/2683.
|
|
13296
|
-
*/ function
|
|
13296
|
+
*/ function Rc(t) {
|
|
13297
13297
|
for (;t.Lo.size > 0 && t.Bo.size < t.maxConcurrentLimboResolutions; ) {
|
|
13298
13298
|
const e = t.Lo.values().next().value;
|
|
13299
13299
|
t.Lo.delete(e);
|
|
13300
13300
|
const n = new Nt(_t.fromString(e)), s = t.Qo.next();
|
|
13301
|
-
t.Uo.set(s, new
|
|
13301
|
+
t.Uo.set(s, new oc(n)), t.Bo = t.Bo.insert(n, s), wo(t.remoteStore, new hi(ve(Te(n.path)), s, 2 /* LimboResolution */ , st.I));
|
|
13302
13302
|
}
|
|
13303
13303
|
}
|
|
13304
13304
|
|
|
13305
|
-
async function
|
|
13305
|
+
async function bc(t, e, n) {
|
|
13306
13306
|
const s = j(t), i = [], r = [], o = [];
|
|
13307
|
-
s.Mo.isEmpty() || (s.Mo.forEach(((t,
|
|
13308
|
-
o.push(s.Go(
|
|
13307
|
+
s.Mo.isEmpty() || (s.Mo.forEach(((t, c) => {
|
|
13308
|
+
o.push(s.Go(c, e, n).then((t => {
|
|
13309
13309
|
if (t) {
|
|
13310
|
-
s.isPrimaryClient && s.sharedClientState.updateQueryState(
|
|
13310
|
+
s.isPrimaryClient && s.sharedClientState.updateQueryState(c.targetId, t.fromCache ? "not-current" : "current"),
|
|
13311
13311
|
i.push(t);
|
|
13312
|
-
const e = fr.$n(
|
|
13312
|
+
const e = fr.$n(c.targetId, t);
|
|
13313
13313
|
r.push(e);
|
|
13314
13314
|
}
|
|
13315
13315
|
})));
|
|
@@ -13336,7 +13336,7 @@ async function ba(t, e, n) {
|
|
|
13336
13336
|
}(s.localStore, r));
|
|
13337
13337
|
}
|
|
13338
13338
|
|
|
13339
|
-
async function
|
|
13339
|
+
async function Pc(t, e) {
|
|
13340
13340
|
const n = j(t);
|
|
13341
13341
|
if (!n.currentUser.isEqual(e)) {
|
|
13342
13342
|
M("SyncEngine", "User change. New user:", e.toKey());
|
|
@@ -13351,11 +13351,11 @@ async function Pa(t, e) {
|
|
|
13351
13351
|
})), t.jo.clear();
|
|
13352
13352
|
}(n, "'waitForPendingWrites' promise is rejected due to a user change."),
|
|
13353
13353
|
// TODO(b/114226417): Consider calling this only in the primary tab.
|
|
13354
|
-
n.sharedClientState.handleUserChange(e, t.removedBatchIds, t.addedBatchIds), await
|
|
13354
|
+
n.sharedClientState.handleUserChange(e, t.removedBatchIds, t.addedBatchIds), await bc(n, t.Gn);
|
|
13355
13355
|
}
|
|
13356
13356
|
}
|
|
13357
13357
|
|
|
13358
|
-
function
|
|
13358
|
+
function vc(t, e) {
|
|
13359
13359
|
const n = j(t), s = n.Uo.get(e);
|
|
13360
13360
|
if (s && s.$o) return Nn().add(s.key);
|
|
13361
13361
|
{
|
|
@@ -13373,10 +13373,10 @@ function va(t, e) {
|
|
|
13373
13373
|
/**
|
|
13374
13374
|
* Reconcile the list of synced documents in an existing view with those
|
|
13375
13375
|
* from persistence.
|
|
13376
|
-
*/ async function
|
|
13376
|
+
*/ async function Vc(t, e) {
|
|
13377
13377
|
const n = j(t), s = await Rr(n.localStore, e.query,
|
|
13378
13378
|
/* usePreviousResults= */ !0), i = e.view.ko(s);
|
|
13379
|
-
return n.isPrimaryClient &&
|
|
13379
|
+
return n.isPrimaryClient && Ic(n, e.targetId, i.Co), i;
|
|
13380
13380
|
}
|
|
13381
13381
|
|
|
13382
13382
|
/**
|
|
@@ -13384,14 +13384,14 @@ function va(t, e) {
|
|
|
13384
13384
|
* snapshots if needed.
|
|
13385
13385
|
*/
|
|
13386
13386
|
// PORTING NOTE: Multi-Tab only.
|
|
13387
|
-
async function
|
|
13387
|
+
async function Sc(t) {
|
|
13388
13388
|
const e = j(t);
|
|
13389
|
-
return Pr(e.localStore).then((t =>
|
|
13389
|
+
return Pr(e.localStore).then((t => bc(e, t)));
|
|
13390
13390
|
}
|
|
13391
13391
|
|
|
13392
13392
|
/** Applies a mutation state to an existing batch. */
|
|
13393
13393
|
// PORTING NOTE: Multi-Tab only.
|
|
13394
|
-
async function
|
|
13394
|
+
async function Dc(t, e, n, s) {
|
|
13395
13395
|
const i = j(t), r = await function(t, e) {
|
|
13396
13396
|
const n = j(t), s = j(n.An);
|
|
13397
13397
|
return n.persistence.runTransaction("Lookup mutation documents", "readonly", (t => s.Zt(t, e).next((e => e ? n.Wn.vn(t, e) : Js.resolve(null)))));
|
|
@@ -13405,11 +13405,11 @@ async function Da(t, e, n, s) {
|
|
|
13405
13405
|
await vo(i.remoteStore) : "acknowledged" === n || "rejected" === n ? (
|
|
13406
13406
|
// NOTE: Both these methods are no-ops for batches that originated from
|
|
13407
13407
|
// other clients.
|
|
13408
|
-
|
|
13408
|
+
pc(i, e, s || null), yc(i, e), function(t, e) {
|
|
13409
13409
|
j(j(t).An).ee(e);
|
|
13410
13410
|
}
|
|
13411
13411
|
// PORTING NOTE: Multi-Tab only.
|
|
13412
|
-
(i.localStore, e)) : U(), await
|
|
13412
|
+
(i.localStore, e)) : U(), await bc(i, r)) :
|
|
13413
13413
|
// A throttled tab may not have seen the mutation before it was completed
|
|
13414
13414
|
// and removed from the mutation queue, in which case we won't have cached
|
|
13415
13415
|
// the affected documents. In this case we can safely ignore the update
|
|
@@ -13422,26 +13422,26 @@ async function Da(t, e, n, s) {
|
|
|
13422
13422
|
|
|
13423
13423
|
/** Applies a query target change from a different tab. */
|
|
13424
13424
|
// PORTING NOTE: Multi-Tab only.
|
|
13425
|
-
async function
|
|
13425
|
+
async function Cc(t, e) {
|
|
13426
13426
|
const n = j(t);
|
|
13427
|
-
if (
|
|
13427
|
+
if (Mc(n), Fc(n), !0 === e && !0 !== n.Wo) {
|
|
13428
13428
|
// Secondary tabs only maintain Views for their local listeners and the
|
|
13429
13429
|
// Views internal state may not be 100% populated (in particular
|
|
13430
13430
|
// secondary tabs don't track syncedDocuments, the set of documents the
|
|
13431
13431
|
// server considers to be in the target). So when a secondary becomes
|
|
13432
13432
|
// primary, we need to need to make sure that all views for all targets
|
|
13433
13433
|
// match the state on disk.
|
|
13434
|
-
const t = n.sharedClientState.getAllActiveQueryTargets(), e = await
|
|
13434
|
+
const t = n.sharedClientState.getAllActiveQueryTargets(), e = await Nc(n, t.toArray());
|
|
13435
13435
|
n.Wo = !0, await Oo(n.remoteStore, !0);
|
|
13436
13436
|
for (const t of e) wo(n.remoteStore, t);
|
|
13437
13437
|
} else if (!1 === e && !1 !== n.Wo) {
|
|
13438
13438
|
const t = [];
|
|
13439
13439
|
let e = Promise.resolve();
|
|
13440
13440
|
n.Fo.forEach(((s, i) => {
|
|
13441
|
-
n.sharedClientState.isLocalQueryTarget(i) ? t.push(i) : e = e.then((() => (
|
|
13441
|
+
n.sharedClientState.isLocalQueryTarget(i) ? t.push(i) : e = e.then((() => (Tc(n, i),
|
|
13442
13442
|
Ar(n.localStore, i,
|
|
13443
13443
|
/*keepPersistedTargetData=*/ !0)))), _o(n.remoteStore, i);
|
|
13444
|
-
})), await e, await
|
|
13444
|
+
})), await e, await Nc(n, t),
|
|
13445
13445
|
// PORTING NOTE: Multi-Tab only.
|
|
13446
13446
|
function(t) {
|
|
13447
13447
|
const e = j(t);
|
|
@@ -13464,7 +13464,7 @@ async function Ca(t, e) {
|
|
|
13464
13464
|
}
|
|
13465
13465
|
}
|
|
13466
13466
|
|
|
13467
|
-
async function
|
|
13467
|
+
async function Nc(t, e, n) {
|
|
13468
13468
|
const s = j(t), i = [], r = [];
|
|
13469
13469
|
for (const t of e) {
|
|
13470
13470
|
let e;
|
|
@@ -13476,14 +13476,14 @@ async function Na(t, e, n) {
|
|
|
13476
13476
|
// state (the list of syncedDocuments may have gotten out of sync).
|
|
13477
13477
|
e = await Ir(s.localStore, ve(n[0]));
|
|
13478
13478
|
for (const t of n) {
|
|
13479
|
-
const e = s.Mo.get(t), n = await
|
|
13479
|
+
const e = s.Mo.get(t), n = await Vc(s, e);
|
|
13480
13480
|
n.snapshot && r.push(n.snapshot);
|
|
13481
13481
|
}
|
|
13482
13482
|
} else {
|
|
13483
13483
|
// For queries that never executed on this client, we need to
|
|
13484
13484
|
// allocate the target in LocalStore and initialize a new View.
|
|
13485
13485
|
const n = await br(s.localStore, t);
|
|
13486
|
-
e = await Ir(s.localStore, n), await
|
|
13486
|
+
e = await Ir(s.localStore, n), await uc(s, kc(n), t,
|
|
13487
13487
|
/*current=*/ !1);
|
|
13488
13488
|
}
|
|
13489
13489
|
i.push(e);
|
|
@@ -13502,20 +13502,20 @@ async function Na(t, e, n) {
|
|
|
13502
13502
|
* difference will not cause issues.
|
|
13503
13503
|
*/
|
|
13504
13504
|
// PORTING NOTE: Multi-Tab only.
|
|
13505
|
-
function
|
|
13505
|
+
function kc(t) {
|
|
13506
13506
|
return pe(t.path, t.collectionGroup, t.orderBy, t.filters, t.limit, "F" /* First */ , t.startAt, t.endAt);
|
|
13507
13507
|
}
|
|
13508
13508
|
|
|
13509
13509
|
/** Returns the IDs of the clients that are currently active. */
|
|
13510
13510
|
// PORTING NOTE: Multi-Tab only.
|
|
13511
|
-
function
|
|
13511
|
+
function xc(t) {
|
|
13512
13512
|
const e = j(t);
|
|
13513
13513
|
return j(j(e.localStore).persistence).Tn();
|
|
13514
13514
|
}
|
|
13515
13515
|
|
|
13516
13516
|
/** Applies a query target change from a different tab. */
|
|
13517
13517
|
// PORTING NOTE: Multi-Tab only.
|
|
13518
|
-
async function $
|
|
13518
|
+
async function $c(t, e, n, s) {
|
|
13519
13519
|
const i = j(t);
|
|
13520
13520
|
if (i.Wo)
|
|
13521
13521
|
// If we receive a target state notification via WebStorage, we are
|
|
@@ -13525,13 +13525,13 @@ async function $a(t, e, n, s) {
|
|
|
13525
13525
|
case "not-current":
|
|
13526
13526
|
{
|
|
13527
13527
|
const t = await Pr(i.localStore), s = $n.createSynthesizedRemoteEventForCurrentChange(e, "current" === n);
|
|
13528
|
-
await
|
|
13528
|
+
await bc(i, t, s);
|
|
13529
13529
|
break;
|
|
13530
13530
|
}
|
|
13531
13531
|
|
|
13532
13532
|
case "rejected":
|
|
13533
13533
|
await Ar(i.localStore, e,
|
|
13534
|
-
/* keepPersistedTargetData */ !0),
|
|
13534
|
+
/* keepPersistedTargetData */ !0), Tc(i, e, s);
|
|
13535
13535
|
break;
|
|
13536
13536
|
|
|
13537
13537
|
default:
|
|
@@ -13539,8 +13539,8 @@ async function $a(t, e, n, s) {
|
|
|
13539
13539
|
}
|
|
13540
13540
|
}
|
|
13541
13541
|
|
|
13542
|
-
/** Adds or removes Watch targets for queries from different tabs. */ async function
|
|
13543
|
-
const s =
|
|
13542
|
+
/** Adds or removes Watch targets for queries from different tabs. */ async function Oc(t, e, n) {
|
|
13543
|
+
const s = Mc(t);
|
|
13544
13544
|
if (s.Wo) {
|
|
13545
13545
|
for (const t of e) {
|
|
13546
13546
|
if (s.Fo.has(t)) {
|
|
@@ -13549,7 +13549,7 @@ async function $a(t, e, n, s) {
|
|
|
13549
13549
|
continue;
|
|
13550
13550
|
}
|
|
13551
13551
|
const e = await br(s.localStore, t), n = await Ir(s.localStore, e);
|
|
13552
|
-
await
|
|
13552
|
+
await uc(s, kc(e), n.targetId,
|
|
13553
13553
|
/*current=*/ !1), wo(s.remoteStore, n);
|
|
13554
13554
|
}
|
|
13555
13555
|
for (const t of n)
|
|
@@ -13559,21 +13559,21 @@ async function $a(t, e, n, s) {
|
|
|
13559
13559
|
// Release queries that are still active.
|
|
13560
13560
|
await Ar(s.localStore, t,
|
|
13561
13561
|
/* keepPersistedTargetData */ !1).then((() => {
|
|
13562
|
-
_o(s.remoteStore, t),
|
|
13562
|
+
_o(s.remoteStore, t), Tc(s, t);
|
|
13563
13563
|
})).catch(Ki);
|
|
13564
13564
|
}
|
|
13565
13565
|
}
|
|
13566
13566
|
|
|
13567
|
-
function
|
|
13567
|
+
function Mc(t) {
|
|
13568
13568
|
const e = j(t);
|
|
13569
|
-
return e.remoteStore.remoteSyncer.applyRemoteEvent =
|
|
13570
|
-
e.remoteStore.remoteSyncer.rejectListen =
|
|
13569
|
+
return e.remoteStore.remoteSyncer.applyRemoteEvent = fc.bind(null, e), e.remoteStore.remoteSyncer.getRemoteKeysForTarget = vc.bind(null, e),
|
|
13570
|
+
e.remoteStore.remoteSyncer.rejectListen = wc.bind(null, e), e.Oo.br = zo.bind(null, e.eventManager),
|
|
13571
13571
|
e.Oo.zo = Ho.bind(null, e.eventManager), e;
|
|
13572
13572
|
}
|
|
13573
13573
|
|
|
13574
|
-
function
|
|
13574
|
+
function Fc(t) {
|
|
13575
13575
|
const e = j(t);
|
|
13576
|
-
return e.remoteStore.remoteSyncer.applySuccessfulWrite =
|
|
13576
|
+
return e.remoteStore.remoteSyncer.applySuccessfulWrite = _c.bind(null, e), e.remoteStore.remoteSyncer.rejectFailedWrite = mc.bind(null, e),
|
|
13577
13577
|
e;
|
|
13578
13578
|
}
|
|
13579
13579
|
|
|
@@ -13584,7 +13584,7 @@ function Fa(t) {
|
|
|
13584
13584
|
* @param syncEngine - SyncEngine to use.
|
|
13585
13585
|
* @param bundleReader - Bundle to load into the SDK.
|
|
13586
13586
|
* @param task - LoadBundleTask used to update the loading progress to public API.
|
|
13587
|
-
*/ function
|
|
13587
|
+
*/ function Lc(t, e, n) {
|
|
13588
13588
|
const s = j(t);
|
|
13589
13589
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
13590
13590
|
(async function(t, e, n) {
|
|
@@ -13605,8 +13605,8 @@ function Fa(t) {
|
|
|
13605
13605
|
totalBytes: t.totalBytes
|
|
13606
13606
|
};
|
|
13607
13607
|
}(s));
|
|
13608
|
-
n._updateProgress(
|
|
13609
|
-
const i = new
|
|
13608
|
+
n._updateProgress(ec(s));
|
|
13609
|
+
const i = new tc(s, t.localStore, e.k);
|
|
13610
13610
|
let r = await e.Ho();
|
|
13611
13611
|
for (;r; ) {
|
|
13612
13612
|
const t = await i.yo(r);
|
|
@@ -13616,7 +13616,7 @@ function Fa(t) {
|
|
|
13616
13616
|
// TODO(b/160876443): This currently raises snapshots with
|
|
13617
13617
|
// `fromCache=false` if users already listen to some queries and bundles
|
|
13618
13618
|
// has newer version.
|
|
13619
|
-
await
|
|
13619
|
+
await bc(t, o.In,
|
|
13620
13620
|
/* remoteEvent */ void 0),
|
|
13621
13621
|
// Save metadata, so loading the same bundle will skip.
|
|
13622
13622
|
await function(t, e) {
|
|
@@ -13655,7 +13655,7 @@ function Fa(t) {
|
|
|
13655
13655
|
}));
|
|
13656
13656
|
}
|
|
13657
13657
|
|
|
13658
|
-
class
|
|
13658
|
+
class Bc {
|
|
13659
13659
|
constructor() {
|
|
13660
13660
|
this.synchronizeTabs = !1;
|
|
13661
13661
|
}
|
|
@@ -13683,14 +13683,14 @@ class Ba {
|
|
|
13683
13683
|
|
|
13684
13684
|
/**
|
|
13685
13685
|
* Provides all components needed for Firestore with IndexedDB persistence.
|
|
13686
|
-
*/ class
|
|
13686
|
+
*/ class Uc extends Bc {
|
|
13687
13687
|
constructor(t, e, n) {
|
|
13688
|
-
super(), this.
|
|
13688
|
+
super(), this.tc = t, this.cacheSizeBytes = e, this.forceOwnership = n, this.synchronizeTabs = !1;
|
|
13689
13689
|
}
|
|
13690
13690
|
async initialize(t) {
|
|
13691
|
-
await super.initialize(t), await vr(this.localStore), await this.
|
|
13691
|
+
await super.initialize(t), await vr(this.localStore), await this.tc.initialize(this, t),
|
|
13692
13692
|
// Enqueue writes from a previous session
|
|
13693
|
-
await
|
|
13693
|
+
await Fc(this.tc.syncEngine), await vo(this.tc.remoteStore),
|
|
13694
13694
|
// NOTE: This will immediately call the listener, so we make sure to
|
|
13695
13695
|
// set it after localStore / remoteStore are started.
|
|
13696
13696
|
await this.persistence.sn((() => (this.gcScheduler && !this.gcScheduler.started && this.gcScheduler.start(this.localStore),
|
|
@@ -13719,24 +13719,24 @@ class Ba {
|
|
|
13719
13719
|
* In the legacy client, this provider is used to provide both multi-tab and
|
|
13720
13720
|
* non-multi-tab persistence since we cannot tell at build time whether
|
|
13721
13721
|
* `synchronizeTabs` will be enabled.
|
|
13722
|
-
*/ class
|
|
13722
|
+
*/ class qc extends Uc {
|
|
13723
13723
|
constructor(t, e) {
|
|
13724
|
-
super(t, e, /* forceOwnership= */ !1), this.
|
|
13724
|
+
super(t, e, /* forceOwnership= */ !1), this.tc = t, this.cacheSizeBytes = e, this.synchronizeTabs = !0;
|
|
13725
13725
|
}
|
|
13726
13726
|
async initialize(t) {
|
|
13727
13727
|
await super.initialize(t);
|
|
13728
|
-
const e = this.
|
|
13728
|
+
const e = this.tc.syncEngine;
|
|
13729
13729
|
this.sharedClientState instanceof zr && (this.sharedClientState.syncEngine = {
|
|
13730
|
-
mi:
|
|
13731
|
-
gi: $
|
|
13732
|
-
yi:
|
|
13733
|
-
Tn:
|
|
13734
|
-
_i:
|
|
13730
|
+
mi: Dc.bind(null, e),
|
|
13731
|
+
gi: $c.bind(null, e),
|
|
13732
|
+
yi: Oc.bind(null, e),
|
|
13733
|
+
Tn: xc.bind(null, e),
|
|
13734
|
+
_i: Sc.bind(null, e)
|
|
13735
13735
|
}, await this.sharedClientState.start()),
|
|
13736
13736
|
// NOTE: This will immediately call the listener, so we make sure to
|
|
13737
13737
|
// set it after localStore / remoteStore are started.
|
|
13738
13738
|
await this.persistence.sn((async t => {
|
|
13739
|
-
await
|
|
13739
|
+
await Cc(this.tc.syncEngine, t), this.gcScheduler && (t && !this.gcScheduler.started ? this.gcScheduler.start(this.localStore) : t || this.gcScheduler.stop());
|
|
13740
13740
|
}));
|
|
13741
13741
|
}
|
|
13742
13742
|
Jo(t) {
|
|
@@ -13750,13 +13750,13 @@ class Ba {
|
|
|
13750
13750
|
/**
|
|
13751
13751
|
* Initializes and wires the components that are needed to interface with the
|
|
13752
13752
|
* network.
|
|
13753
|
-
*/ class
|
|
13753
|
+
*/ class Kc {
|
|
13754
13754
|
async initialize(t, e) {
|
|
13755
13755
|
this.localStore || (this.localStore = t.localStore, this.sharedClientState = t.sharedClientState,
|
|
13756
13756
|
this.datastore = this.createDatastore(e), this.remoteStore = this.createRemoteStore(e),
|
|
13757
13757
|
this.eventManager = this.createEventManager(e), this.syncEngine = this.createSyncEngine(e,
|
|
13758
|
-
/* startAsPrimary=*/ !t.synchronizeTabs), this.sharedClientState.onlineStateHandler = t =>
|
|
13759
|
-
this.remoteStore.remoteSyncer.handleCredentialChange =
|
|
13758
|
+
/* startAsPrimary=*/ !t.synchronizeTabs), this.sharedClientState.onlineStateHandler = t => dc(this.syncEngine, t, 1 /* SharedClientState */),
|
|
13759
|
+
this.remoteStore.remoteSyncer.handleCredentialChange = Pc.bind(null, this.syncEngine),
|
|
13760
13760
|
await Oo(this.remoteStore, this.syncEngine.isPrimaryClient));
|
|
13761
13761
|
}
|
|
13762
13762
|
createEventManager(t) {
|
|
@@ -13766,11 +13766,11 @@ class Ba {
|
|
|
13766
13766
|
const e = so(t.databaseInfo.databaseId), n = (s = t.databaseInfo, new to(s));
|
|
13767
13767
|
var s;
|
|
13768
13768
|
/** Return the Platform-specific connectivity monitor. */ return function(t, e, n, s) {
|
|
13769
|
-
return new
|
|
13769
|
+
return new ao(t, e, n, s);
|
|
13770
13770
|
}(t.authCredentials, t.appCheckCredentials, n, e);
|
|
13771
13771
|
}
|
|
13772
13772
|
createRemoteStore(t) {
|
|
13773
|
-
return e = this.localStore, n = this.datastore, s = t.asyncQueue, i = t =>
|
|
13773
|
+
return e = this.localStore, n = this.datastore, s = t.asyncQueue, i = t => dc(this.syncEngine, t, 0 /* RemoteStore */),
|
|
13774
13774
|
r = Yr.Pt() ? new Yr : new Jr, new ho(e, n, s, i, r);
|
|
13775
13775
|
var e, n, s, i, r;
|
|
13776
13776
|
/** Re-enables the network. Idempotent. */ }
|
|
@@ -13778,8 +13778,8 @@ class Ba {
|
|
|
13778
13778
|
return function(t, e, n,
|
|
13779
13779
|
// PORTING NOTE: Manages state synchronization in multi-tab environments.
|
|
13780
13780
|
s, i, r, o) {
|
|
13781
|
-
const
|
|
13782
|
-
return o && (
|
|
13781
|
+
const c = new cc(t, e, n, s, i, r);
|
|
13782
|
+
return o && (c.Wo = !0), c;
|
|
13783
13783
|
}(this.localStore, this.remoteStore, this.eventManager, this.sharedClientState, t.initialUser, t.maxConcurrentLimboResolutions, e);
|
|
13784
13784
|
}
|
|
13785
13785
|
terminate() {
|
|
@@ -13821,7 +13821,7 @@ class Ba {
|
|
|
13821
13821
|
* @param bytesPerRead - How many bytes each `read()` from the returned reader
|
|
13822
13822
|
* will read.
|
|
13823
13823
|
*/
|
|
13824
|
-
function
|
|
13824
|
+
function jc(t, e = 10240) {
|
|
13825
13825
|
let n = 0;
|
|
13826
13826
|
// The TypeScript definition for ReadableStreamReader changed. We use
|
|
13827
13827
|
// `any` here to allow this code to compile with different versions.
|
|
@@ -13887,7 +13887,7 @@ function ja(t, e = 10240) {
|
|
|
13887
13887
|
* asynchronously. To allow immediate silencing, a mute call is added which
|
|
13888
13888
|
* causes events scheduled to no longer be raised.
|
|
13889
13889
|
*/
|
|
13890
|
-
class
|
|
13890
|
+
class Qc {
|
|
13891
13891
|
constructor(t) {
|
|
13892
13892
|
this.observer = t,
|
|
13893
13893
|
/**
|
|
@@ -13897,15 +13897,15 @@ class Qa {
|
|
|
13897
13897
|
this.muted = !1;
|
|
13898
13898
|
}
|
|
13899
13899
|
next(t) {
|
|
13900
|
-
this.observer.next && this.
|
|
13900
|
+
this.observer.next && this.ec(this.observer.next, t);
|
|
13901
13901
|
}
|
|
13902
13902
|
error(t) {
|
|
13903
|
-
this.observer.error ? this.
|
|
13903
|
+
this.observer.error ? this.ec(this.observer.error, t) : console.error("Uncaught Error in snapshot listener:", t);
|
|
13904
13904
|
}
|
|
13905
|
-
|
|
13905
|
+
nc() {
|
|
13906
13906
|
this.muted = !0;
|
|
13907
13907
|
}
|
|
13908
|
-
|
|
13908
|
+
ec(t, e) {
|
|
13909
13909
|
this.muted || setTimeout((() => {
|
|
13910
13910
|
this.muted || t(e);
|
|
13911
13911
|
}), 0);
|
|
@@ -13933,32 +13933,32 @@ class Qa {
|
|
|
13933
13933
|
*
|
|
13934
13934
|
* Takes a bundle stream or buffer, and presents abstractions to read bundled
|
|
13935
13935
|
* elements out of the underlying content.
|
|
13936
|
-
*/ class
|
|
13936
|
+
*/ class Wc {
|
|
13937
13937
|
constructor(
|
|
13938
13938
|
/** The reader to read from underlying binary bundle data source. */
|
|
13939
13939
|
t, e) {
|
|
13940
|
-
this.
|
|
13940
|
+
this.sc = t, this.k = e,
|
|
13941
13941
|
/** Cached bundle metadata. */
|
|
13942
13942
|
this.metadata = new G,
|
|
13943
13943
|
/**
|
|
13944
13944
|
* Internal buffer to hold bundle content, accumulating incomplete element
|
|
13945
13945
|
* content.
|
|
13946
13946
|
*/
|
|
13947
|
-
this.buffer = new Uint8Array, this.
|
|
13947
|
+
this.buffer = new Uint8Array, this.ic = new TextDecoder("utf-8"),
|
|
13948
13948
|
// Read the metadata (which is the first element).
|
|
13949
|
-
this.
|
|
13949
|
+
this.rc().then((t => {
|
|
13950
13950
|
t && t._o() ? this.metadata.resolve(t.payload.metadata) : this.metadata.reject(new Error(`The first element of the bundle is not a metadata, it is\n ${JSON.stringify(null == t ? void 0 : t.payload)}`));
|
|
13951
13951
|
}), (t => this.metadata.reject(t)));
|
|
13952
13952
|
}
|
|
13953
13953
|
close() {
|
|
13954
|
-
return this.
|
|
13954
|
+
return this.sc.cancel();
|
|
13955
13955
|
}
|
|
13956
13956
|
async getMetadata() {
|
|
13957
13957
|
return this.metadata.promise;
|
|
13958
13958
|
}
|
|
13959
13959
|
async Ho() {
|
|
13960
13960
|
// Makes sure metadata is read before proceeding.
|
|
13961
|
-
return await this.getMetadata(), this.
|
|
13961
|
+
return await this.getMetadata(), this.rc();
|
|
13962
13962
|
}
|
|
13963
13963
|
/**
|
|
13964
13964
|
* Reads from the head of internal buffer, and pulling more data from
|
|
@@ -13969,15 +13969,15 @@ class Qa {
|
|
|
13969
13969
|
*
|
|
13970
13970
|
* Returns either the bundled element, or null if we have reached the end of
|
|
13971
13971
|
* the stream.
|
|
13972
|
-
*/ async
|
|
13973
|
-
const t = await this.
|
|
13972
|
+
*/ async rc() {
|
|
13973
|
+
const t = await this.oc();
|
|
13974
13974
|
if (null === t) return null;
|
|
13975
|
-
const e = this.
|
|
13976
|
-
isNaN(n) && this.
|
|
13977
|
-
const s = await this.
|
|
13975
|
+
const e = this.ic.decode(t), n = Number(e);
|
|
13976
|
+
isNaN(n) && this.cc(`length string (${e}) is not valid number`);
|
|
13977
|
+
const s = await this.ac(n);
|
|
13978
13978
|
return new Xo(JSON.parse(s), t.length + n);
|
|
13979
13979
|
}
|
|
13980
|
-
/** First index of '{' from the underlying buffer. */
|
|
13980
|
+
/** First index of '{' from the underlying buffer. */ uc() {
|
|
13981
13981
|
return this.buffer.findIndex((t => t === "{".charCodeAt(0)));
|
|
13982
13982
|
}
|
|
13983
13983
|
/**
|
|
@@ -13985,17 +13985,17 @@ class Qa {
|
|
|
13985
13985
|
* return the content.
|
|
13986
13986
|
*
|
|
13987
13987
|
* If reached end of the stream, returns a null.
|
|
13988
|
-
*/ async
|
|
13989
|
-
for (;this.
|
|
13990
|
-
if (await this.
|
|
13988
|
+
*/ async oc() {
|
|
13989
|
+
for (;this.uc() < 0; ) {
|
|
13990
|
+
if (await this.hc()) break;
|
|
13991
13991
|
}
|
|
13992
13992
|
// Broke out of the loop because underlying stream is closed, and there
|
|
13993
13993
|
// happens to be no more data to process.
|
|
13994
13994
|
if (0 === this.buffer.length) return null;
|
|
13995
|
-
const t = this.
|
|
13995
|
+
const t = this.uc();
|
|
13996
13996
|
// Broke out of the loop because underlying stream is closed, but still
|
|
13997
13997
|
// cannot find an open bracket.
|
|
13998
|
-
t < 0 && this.
|
|
13998
|
+
t < 0 && this.cc("Reached the end of bundle when a length string is expected.");
|
|
13999
13999
|
const e = this.buffer.slice(0, t);
|
|
14000
14000
|
// Update the internal buffer to drop the read length.
|
|
14001
14001
|
return this.buffer = this.buffer.slice(t), e;
|
|
@@ -14005,23 +14005,23 @@ class Qa {
|
|
|
14005
14005
|
* number of bytes, pulling more data from the underlying stream if needed.
|
|
14006
14006
|
*
|
|
14007
14007
|
* Returns a string decoded from the read bytes.
|
|
14008
|
-
*/ async
|
|
14008
|
+
*/ async ac(t) {
|
|
14009
14009
|
for (;this.buffer.length < t; ) {
|
|
14010
|
-
await this.
|
|
14010
|
+
await this.hc() && this.cc("Reached the end of bundle when more is expected.");
|
|
14011
14011
|
}
|
|
14012
|
-
const e = this.
|
|
14012
|
+
const e = this.ic.decode(this.buffer.slice(0, t));
|
|
14013
14013
|
// Update the internal buffer to drop the read json string.
|
|
14014
14014
|
return this.buffer = this.buffer.slice(t), e;
|
|
14015
14015
|
}
|
|
14016
|
-
|
|
14016
|
+
cc(t) {
|
|
14017
14017
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
14018
|
-
throw this.
|
|
14018
|
+
throw this.sc.cancel(), new Error(`Invalid bundle format: ${t}`);
|
|
14019
14019
|
}
|
|
14020
14020
|
/**
|
|
14021
14021
|
* Pulls more data from underlying stream to internal buffer.
|
|
14022
14022
|
* Returns a boolean indicating whether the stream is finished.
|
|
14023
|
-
*/ async
|
|
14024
|
-
const t = await this.
|
|
14023
|
+
*/ async hc() {
|
|
14024
|
+
const t = await this.sc.read();
|
|
14025
14025
|
if (!t.done) {
|
|
14026
14026
|
const e = new Uint8Array(this.buffer.length + t.value.length);
|
|
14027
14027
|
e.set(this.buffer), e.set(t.value, this.buffer.length), this.buffer = e;
|
|
@@ -14050,7 +14050,7 @@ class Qa {
|
|
|
14050
14050
|
* Internal transaction object responsible for accumulating the mutations to
|
|
14051
14051
|
* perform and the base versions for any documents read.
|
|
14052
14052
|
*/
|
|
14053
|
-
class
|
|
14053
|
+
class Gc {
|
|
14054
14054
|
constructor(t) {
|
|
14055
14055
|
this.datastore = t,
|
|
14056
14056
|
// The version of each document that was read during this transaction.
|
|
@@ -14075,14 +14075,14 @@ class Ga {
|
|
|
14075
14075
|
documents: e.map((t => Zn(n.k, t)))
|
|
14076
14076
|
}, r = await n.ji("BatchGetDocuments", s, i), o = new Map;
|
|
14077
14077
|
r.forEach((t => {
|
|
14078
|
-
const e =
|
|
14078
|
+
const e = cs(n.k, t);
|
|
14079
14079
|
o.set(e.key.toString(), e);
|
|
14080
14080
|
}));
|
|
14081
|
-
const
|
|
14081
|
+
const c = [];
|
|
14082
14082
|
return e.forEach((t => {
|
|
14083
14083
|
const e = o.get(t.toString());
|
|
14084
|
-
q(!!e),
|
|
14085
|
-
})),
|
|
14084
|
+
q(!!e), c.push(e);
|
|
14085
|
+
})), c;
|
|
14086
14086
|
}(this.datastore, t);
|
|
14087
14087
|
return e.forEach((t => this.recordVersion(t))), e;
|
|
14088
14088
|
}
|
|
@@ -14191,29 +14191,29 @@ class Ga {
|
|
|
14191
14191
|
* TransactionRunner encapsulates the logic needed to run and retry transactions
|
|
14192
14192
|
* with backoff.
|
|
14193
14193
|
*/
|
|
14194
|
-
class
|
|
14194
|
+
class zc {
|
|
14195
14195
|
constructor(t, e, n, s) {
|
|
14196
14196
|
this.asyncQueue = t, this.datastore = e, this.updateFunction = n, this.deferred = s,
|
|
14197
|
-
this.
|
|
14197
|
+
this.lc = 5, this.ur = new io(this.asyncQueue, "transaction_retry" /* TransactionRetry */);
|
|
14198
14198
|
}
|
|
14199
14199
|
/** Runs the transaction and sets the result on deferred. */ run() {
|
|
14200
|
-
this.
|
|
14200
|
+
this.lc -= 1, this.fc();
|
|
14201
14201
|
}
|
|
14202
|
-
|
|
14202
|
+
fc() {
|
|
14203
14203
|
this.ur.Zi((async () => {
|
|
14204
|
-
const t = new
|
|
14204
|
+
const t = new Gc(this.datastore), e = this.dc(t);
|
|
14205
14205
|
e && e.then((e => {
|
|
14206
14206
|
this.asyncQueue.enqueueAndForget((() => t.commit().then((() => {
|
|
14207
14207
|
this.deferred.resolve(e);
|
|
14208
14208
|
})).catch((t => {
|
|
14209
|
-
this.
|
|
14209
|
+
this.wc(t);
|
|
14210
14210
|
}))));
|
|
14211
14211
|
})).catch((t => {
|
|
14212
|
-
this.
|
|
14212
|
+
this.wc(t);
|
|
14213
14213
|
}));
|
|
14214
14214
|
}));
|
|
14215
14215
|
}
|
|
14216
|
-
|
|
14216
|
+
dc(t) {
|
|
14217
14217
|
try {
|
|
14218
14218
|
const e = this.updateFunction(t);
|
|
14219
14219
|
return !St(e) && e.catch && e.then ? e : (this.deferred.reject(Error("Transaction callback must return a Promise")),
|
|
@@ -14223,11 +14223,11 @@ class za {
|
|
|
14223
14223
|
return this.deferred.reject(t), null;
|
|
14224
14224
|
}
|
|
14225
14225
|
}
|
|
14226
|
-
|
|
14227
|
-
this.
|
|
14226
|
+
wc(t) {
|
|
14227
|
+
this.lc > 0 && this._c(t) ? (this.lc -= 1, this.asyncQueue.enqueueAndForget((() => (this.fc(),
|
|
14228
14228
|
Promise.resolve())))) : this.deferred.reject(t);
|
|
14229
14229
|
}
|
|
14230
|
-
|
|
14230
|
+
_c(t) {
|
|
14231
14231
|
if ("FirebaseError" === t.name) {
|
|
14232
14232
|
// In transactions, the backend will fail outdated reads with FAILED_PRECONDITION and
|
|
14233
14233
|
// non-matching document versions with ABORTED. These errors should be retried.
|
|
@@ -14259,7 +14259,7 @@ class za {
|
|
|
14259
14259
|
* pieces of the client SDK architecture. It is responsible for creating the
|
|
14260
14260
|
* async queue that is shared by all of the other components in the system.
|
|
14261
14261
|
*/
|
|
14262
|
-
class
|
|
14262
|
+
class Hc {
|
|
14263
14263
|
constructor(t, e,
|
|
14264
14264
|
/**
|
|
14265
14265
|
* Asynchronous queue responsible for all of our internal processing. When
|
|
@@ -14317,7 +14317,7 @@ class Ha {
|
|
|
14317
14317
|
}
|
|
14318
14318
|
}
|
|
14319
14319
|
|
|
14320
|
-
async function
|
|
14320
|
+
async function Jc(t, e) {
|
|
14321
14321
|
t.asyncQueue.verifyOperationInProgress(), M("FirestoreClient", "Initializing OfflineComponentProvider");
|
|
14322
14322
|
const n = await t.getConfiguration();
|
|
14323
14323
|
await e.initialize(n);
|
|
@@ -14330,9 +14330,9 @@ async function Ja(t, e) {
|
|
|
14330
14330
|
e.persistence.setDatabaseDeletedListener((() => t.terminate())), t.offlineComponents = e;
|
|
14331
14331
|
}
|
|
14332
14332
|
|
|
14333
|
-
async function
|
|
14333
|
+
async function Yc(t, e) {
|
|
14334
14334
|
t.asyncQueue.verifyOperationInProgress();
|
|
14335
|
-
const n = await
|
|
14335
|
+
const n = await Xc(t);
|
|
14336
14336
|
M("FirestoreClient", "Initializing OnlineComponentProvider");
|
|
14337
14337
|
const s = await t.getConfiguration();
|
|
14338
14338
|
await e.initialize(n, s),
|
|
@@ -14352,41 +14352,41 @@ async function Ya(t, e) {
|
|
|
14352
14352
|
}(e.remoteStore, t))), t.onlineComponents = e;
|
|
14353
14353
|
}
|
|
14354
14354
|
|
|
14355
|
-
async function
|
|
14355
|
+
async function Xc(t) {
|
|
14356
14356
|
return t.offlineComponents || (M("FirestoreClient", "Using default OfflineComponentProvider"),
|
|
14357
|
-
await
|
|
14357
|
+
await Jc(t, new Bc)), t.offlineComponents;
|
|
14358
14358
|
}
|
|
14359
14359
|
|
|
14360
|
-
async function
|
|
14360
|
+
async function Zc(t) {
|
|
14361
14361
|
return t.onlineComponents || (M("FirestoreClient", "Using default OnlineComponentProvider"),
|
|
14362
|
-
await
|
|
14362
|
+
await Yc(t, new Kc)), t.onlineComponents;
|
|
14363
14363
|
}
|
|
14364
14364
|
|
|
14365
|
-
function
|
|
14366
|
-
return
|
|
14365
|
+
function ta(t) {
|
|
14366
|
+
return Xc(t).then((t => t.persistence));
|
|
14367
14367
|
}
|
|
14368
14368
|
|
|
14369
|
-
function
|
|
14370
|
-
return
|
|
14369
|
+
function ea(t) {
|
|
14370
|
+
return Xc(t).then((t => t.localStore));
|
|
14371
14371
|
}
|
|
14372
14372
|
|
|
14373
|
-
function
|
|
14374
|
-
return
|
|
14373
|
+
function na(t) {
|
|
14374
|
+
return Zc(t).then((t => t.remoteStore));
|
|
14375
14375
|
}
|
|
14376
14376
|
|
|
14377
|
-
function
|
|
14378
|
-
return
|
|
14377
|
+
function sa(t) {
|
|
14378
|
+
return Zc(t).then((t => t.syncEngine));
|
|
14379
14379
|
}
|
|
14380
14380
|
|
|
14381
|
-
async function
|
|
14382
|
-
const e = await
|
|
14383
|
-
return n.onListen =
|
|
14381
|
+
async function ia(t) {
|
|
14382
|
+
const e = await Zc(t), n = e.eventManager;
|
|
14383
|
+
return n.onListen = ac.bind(null, e.syncEngine), n.onUnlisten = hc.bind(null, e.syncEngine),
|
|
14384
14384
|
n;
|
|
14385
14385
|
}
|
|
14386
14386
|
|
|
14387
|
-
/** Enables the network connection and re-enqueues all pending operations. */ function
|
|
14387
|
+
/** Enables the network connection and re-enqueues all pending operations. */ function ra(t) {
|
|
14388
14388
|
return t.asyncQueue.enqueue((async () => {
|
|
14389
|
-
const e = await
|
|
14389
|
+
const e = await ta(t), n = await na(t);
|
|
14390
14390
|
return e.setNetworkEnabled(!0), function(t) {
|
|
14391
14391
|
const e = j(t);
|
|
14392
14392
|
return e.Gr.delete(0 /* UserDisabled */), lo(e);
|
|
@@ -14394,9 +14394,9 @@ async function ic(t) {
|
|
|
14394
14394
|
}));
|
|
14395
14395
|
}
|
|
14396
14396
|
|
|
14397
|
-
/** Disables the network connection. Pending operations will not complete. */ function
|
|
14397
|
+
/** Disables the network connection. Pending operations will not complete. */ function oa(t) {
|
|
14398
14398
|
return t.asyncQueue.enqueue((async () => {
|
|
14399
|
-
const e = await
|
|
14399
|
+
const e = await ta(t), n = await na(t);
|
|
14400
14400
|
return e.setNetworkEnabled(!1), async function(t) {
|
|
14401
14401
|
const e = j(t);
|
|
14402
14402
|
e.Gr.add(0 /* UserDisabled */), await fo(e),
|
|
@@ -14410,7 +14410,7 @@ async function ic(t) {
|
|
|
14410
14410
|
* Returns a Promise that resolves when all writes that were pending at the time
|
|
14411
14411
|
* this method was called received server acknowledgement. An acknowledgement
|
|
14412
14412
|
* can be either acceptance or rejection.
|
|
14413
|
-
*/ function
|
|
14413
|
+
*/ function ca(t, e) {
|
|
14414
14414
|
const n = new G;
|
|
14415
14415
|
return t.asyncQueue.enqueueAndForget((async () => async function(t, e, n) {
|
|
14416
14416
|
try {
|
|
@@ -14427,19 +14427,19 @@ async function ic(t) {
|
|
|
14427
14427
|
/**
|
|
14428
14428
|
* Retrieves a latency-compensated document from the backend via a
|
|
14429
14429
|
* SnapshotListener.
|
|
14430
|
-
*/ (await
|
|
14430
|
+
*/ (await ea(t), e, n))), n.promise;
|
|
14431
14431
|
}
|
|
14432
14432
|
|
|
14433
|
-
function
|
|
14433
|
+
function aa(t, e, n = {}) {
|
|
14434
14434
|
const s = new G;
|
|
14435
14435
|
return t.asyncQueue.enqueueAndForget((async () => function(t, e, n, s, i) {
|
|
14436
|
-
const r = new
|
|
14436
|
+
const r = new Qc({
|
|
14437
14437
|
next: r => {
|
|
14438
14438
|
// Remove query first before passing event to user to avoid
|
|
14439
14439
|
// user actions affecting the now stale query.
|
|
14440
14440
|
e.enqueueAndForget((() => Go(t, o)));
|
|
14441
|
-
const
|
|
14442
|
-
!
|
|
14441
|
+
const c = r.docs.has(n);
|
|
14442
|
+
!c && r.fromCache ?
|
|
14443
14443
|
// TODO(dimond): If we're online and the document doesn't
|
|
14444
14444
|
// exist then we resolve with a doc.exists set to false. If
|
|
14445
14445
|
// we're offline however, we reject the Promise in this
|
|
@@ -14447,7 +14447,7 @@ function cc(t, e, n = {}) {
|
|
|
14447
14447
|
// the server so we can deliver that even when you're
|
|
14448
14448
|
// offline 2) Actually reject the Promise in the online case
|
|
14449
14449
|
// if the document doesn't exist.
|
|
14450
|
-
i.reject(new W(Q.UNAVAILABLE, "Failed to get document because the client is offline.")) :
|
|
14450
|
+
i.reject(new W(Q.UNAVAILABLE, "Failed to get document because the client is offline.")) : c && r.fromCache && s && "server" === s.source ? i.reject(new W(Q.UNAVAILABLE, 'Failed to get document from server. (However, this document does exist in the local cache. Run again without setting source to "server" to retrieve the cached document.)')) : i.resolve(r);
|
|
14451
14451
|
},
|
|
14452
14452
|
error: t => i.reject(t)
|
|
14453
14453
|
}), o = new Yo(Te(n.path), r, {
|
|
@@ -14455,15 +14455,15 @@ function cc(t, e, n = {}) {
|
|
|
14455
14455
|
wo: !0
|
|
14456
14456
|
});
|
|
14457
14457
|
return Wo(t, o);
|
|
14458
|
-
}(await
|
|
14458
|
+
}(await ia(t), t.asyncQueue, e, n, s))), s.promise;
|
|
14459
14459
|
}
|
|
14460
14460
|
|
|
14461
|
-
function
|
|
14461
|
+
function ua(t, e) {
|
|
14462
14462
|
const n = new G;
|
|
14463
14463
|
return t.asyncQueue.enqueueAndForget((async () => async function(t, e, n) {
|
|
14464
14464
|
try {
|
|
14465
14465
|
const s = await Rr(t, e,
|
|
14466
|
-
/* usePreviousResults= */ !0), i = new
|
|
14466
|
+
/* usePreviousResults= */ !0), i = new ic(e, s.zn), r = i.Po(s.documents), o = i.applyChanges(r,
|
|
14467
14467
|
/* updateLimboDocuments= */ !1);
|
|
14468
14468
|
n.resolve(o.snapshot);
|
|
14469
14469
|
} catch (t) {
|
|
@@ -14474,13 +14474,13 @@ function uc(t, e) {
|
|
|
14474
14474
|
/**
|
|
14475
14475
|
* Retrieves a latency-compensated query snapshot from the backend via a
|
|
14476
14476
|
* SnapshotListener.
|
|
14477
|
-
*/ (await
|
|
14477
|
+
*/ (await ea(t), e, n))), n.promise;
|
|
14478
14478
|
}
|
|
14479
14479
|
|
|
14480
|
-
function
|
|
14480
|
+
function ha(t, e, n = {}) {
|
|
14481
14481
|
const s = new G;
|
|
14482
14482
|
return t.asyncQueue.enqueueAndForget((async () => function(t, e, n, s, i) {
|
|
14483
|
-
const r = new
|
|
14483
|
+
const r = new Qc({
|
|
14484
14484
|
next: n => {
|
|
14485
14485
|
// Remove query first before passing event to user to avoid
|
|
14486
14486
|
// user actions affecting the now stale query.
|
|
@@ -14492,20 +14492,20 @@ function hc(t, e, n = {}) {
|
|
|
14492
14492
|
wo: !0
|
|
14493
14493
|
});
|
|
14494
14494
|
return Wo(t, o);
|
|
14495
|
-
}(await
|
|
14495
|
+
}(await ia(t), t.asyncQueue, e, n, s))), s.promise;
|
|
14496
14496
|
}
|
|
14497
14497
|
|
|
14498
|
-
function
|
|
14499
|
-
const n = new
|
|
14498
|
+
function la(t, e) {
|
|
14499
|
+
const n = new Qc(e);
|
|
14500
14500
|
return t.asyncQueue.enqueueAndForget((async () => function(t, e) {
|
|
14501
14501
|
j(t).io.add(e),
|
|
14502
14502
|
// Immediately fire an initial event, indicating all existing listeners
|
|
14503
14503
|
// are in-sync.
|
|
14504
14504
|
e.next();
|
|
14505
|
-
}(await
|
|
14506
|
-
n.
|
|
14505
|
+
}(await ia(t), n))), () => {
|
|
14506
|
+
n.nc(), t.asyncQueue.enqueueAndForget((async () => function(t, e) {
|
|
14507
14507
|
j(t).io.delete(e);
|
|
14508
|
-
}(await
|
|
14508
|
+
}(await ia(t), n)));
|
|
14509
14509
|
};
|
|
14510
14510
|
}
|
|
14511
14511
|
|
|
@@ -14523,25 +14523,25 @@ function lc(t, e) {
|
|
|
14523
14523
|
* accessed with the transaction will not reflect local changes that have not
|
|
14524
14524
|
* been committed. For this reason, it is required that all reads are
|
|
14525
14525
|
* performed before any writes. Transactions must be performed while online.
|
|
14526
|
-
*/ function
|
|
14526
|
+
*/ function fa(t, e) {
|
|
14527
14527
|
const n = new G;
|
|
14528
14528
|
return t.asyncQueue.enqueueAndForget((async () => {
|
|
14529
14529
|
const s = await function(t) {
|
|
14530
|
-
return
|
|
14530
|
+
return Zc(t).then((t => t.datastore));
|
|
14531
14531
|
}(t);
|
|
14532
|
-
new
|
|
14532
|
+
new zc(t.asyncQueue, s, e, n).run();
|
|
14533
14533
|
})), n.promise;
|
|
14534
14534
|
}
|
|
14535
14535
|
|
|
14536
|
-
function
|
|
14536
|
+
function da(t, e, n, s) {
|
|
14537
14537
|
const i = function(t, e) {
|
|
14538
14538
|
let n;
|
|
14539
14539
|
n = "string" == typeof t ? (new TextEncoder).encode(t) : t;
|
|
14540
14540
|
return function(t, e) {
|
|
14541
|
-
return new
|
|
14541
|
+
return new Wc(t, e);
|
|
14542
14542
|
}(function(t, e) {
|
|
14543
|
-
if (t instanceof Uint8Array) return
|
|
14544
|
-
if (t instanceof ArrayBuffer) return
|
|
14543
|
+
if (t instanceof Uint8Array) return jc(t, e);
|
|
14544
|
+
if (t instanceof ArrayBuffer) return jc(new Uint8Array(t), e);
|
|
14545
14545
|
if (t instanceof ReadableStream) return t.getReader();
|
|
14546
14546
|
throw new Error("Source of `toByteStreamReader` has to be a ArrayBuffer or ReadableStream");
|
|
14547
14547
|
}(n), e);
|
|
@@ -14563,18 +14563,18 @@ function dc(t, e, n, s) {
|
|
|
14563
14563
|
* limitations under the License.
|
|
14564
14564
|
*/ (n, so(e));
|
|
14565
14565
|
t.asyncQueue.enqueueAndForget((async () => {
|
|
14566
|
-
|
|
14566
|
+
Lc(await sa(t), i, s);
|
|
14567
14567
|
}));
|
|
14568
14568
|
}
|
|
14569
14569
|
|
|
14570
|
-
function
|
|
14570
|
+
function wa(t, e) {
|
|
14571
14571
|
return t.asyncQueue.enqueue((async () => function(t, e) {
|
|
14572
14572
|
const n = j(t);
|
|
14573
14573
|
return n.persistence.runTransaction("Get named query", "readonly", (t => n.Ye.getNamedQuery(t, e)));
|
|
14574
|
-
}(await
|
|
14574
|
+
}(await ea(t), e)));
|
|
14575
14575
|
}
|
|
14576
14576
|
|
|
14577
|
-
class
|
|
14577
|
+
class _a {
|
|
14578
14578
|
/**
|
|
14579
14579
|
* Constructs a DatabaseInfo using the provided host, databaseId and
|
|
14580
14580
|
* persistenceKey.
|
|
@@ -14592,9 +14592,9 @@ class _c {
|
|
|
14592
14592
|
* @param useFetchStreams Whether to use the Fetch API instead of
|
|
14593
14593
|
* XMLHTTPRequest
|
|
14594
14594
|
*/
|
|
14595
|
-
constructor(t, e, n, s, i, r, o,
|
|
14595
|
+
constructor(t, e, n, s, i, r, o, c) {
|
|
14596
14596
|
this.databaseId = t, this.appId = e, this.persistenceKey = n, this.host = s, this.ssl = i,
|
|
14597
|
-
this.forceLongPolling = r, this.autoDetectLongPolling = o, this.useFetchStreams =
|
|
14597
|
+
this.forceLongPolling = r, this.autoDetectLongPolling = o, this.useFetchStreams = c;
|
|
14598
14598
|
}
|
|
14599
14599
|
}
|
|
14600
14600
|
|
|
@@ -14603,7 +14603,7 @@ class _c {
|
|
|
14603
14603
|
* Represents the database ID a Firestore client is associated with.
|
|
14604
14604
|
* @internal
|
|
14605
14605
|
*/
|
|
14606
|
-
class
|
|
14606
|
+
class ma {
|
|
14607
14607
|
constructor(t, e) {
|
|
14608
14608
|
this.projectId = t, this.database = e || "(default)";
|
|
14609
14609
|
}
|
|
@@ -14611,7 +14611,7 @@ class mc {
|
|
|
14611
14611
|
return "(default)" === this.database;
|
|
14612
14612
|
}
|
|
14613
14613
|
isEqual(t) {
|
|
14614
|
-
return t instanceof
|
|
14614
|
+
return t instanceof ma && t.projectId === this.projectId && t.database === this.database;
|
|
14615
14615
|
}
|
|
14616
14616
|
}
|
|
14617
14617
|
|
|
@@ -14630,7 +14630,7 @@ class mc {
|
|
|
14630
14630
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14631
14631
|
* See the License for the specific language governing permissions and
|
|
14632
14632
|
* limitations under the License.
|
|
14633
|
-
*/ const
|
|
14633
|
+
*/ const ga = new Map;
|
|
14634
14634
|
|
|
14635
14635
|
/**
|
|
14636
14636
|
* An instance map that ensures only one Datastore exists per Firestore
|
|
@@ -14652,28 +14652,28 @@ class mc {
|
|
|
14652
14652
|
* See the License for the specific language governing permissions and
|
|
14653
14653
|
* limitations under the License.
|
|
14654
14654
|
*/
|
|
14655
|
-
function
|
|
14655
|
+
function ya(t, e, n) {
|
|
14656
14656
|
if (!n) throw new W(Q.INVALID_ARGUMENT, `Function ${t}() cannot be called with an empty ${e}.`);
|
|
14657
14657
|
}
|
|
14658
14658
|
|
|
14659
14659
|
/**
|
|
14660
14660
|
* Validates that two boolean options are not set at the same time.
|
|
14661
14661
|
* @internal
|
|
14662
|
-
*/ function
|
|
14662
|
+
*/ function pa(t, e, n, s) {
|
|
14663
14663
|
if (!0 === e && !0 === s) throw new W(Q.INVALID_ARGUMENT, `${t} and ${n} cannot be used together.`);
|
|
14664
14664
|
}
|
|
14665
14665
|
|
|
14666
14666
|
/**
|
|
14667
14667
|
* Validates that `path` refers to a document (indicated by the fact it contains
|
|
14668
14668
|
* an even numbers of segments).
|
|
14669
|
-
*/ function
|
|
14669
|
+
*/ function Ta(t) {
|
|
14670
14670
|
if (!Nt.isDocumentKey(t)) throw new W(Q.INVALID_ARGUMENT, `Invalid document reference. Document references must have an even number of segments, but ${t} has ${t.length}.`);
|
|
14671
14671
|
}
|
|
14672
14672
|
|
|
14673
14673
|
/**
|
|
14674
14674
|
* Validates that `path` refers to a collection (indicated by the fact it
|
|
14675
14675
|
* contains an odd numbers of segments).
|
|
14676
|
-
*/ function
|
|
14676
|
+
*/ function Ea(t) {
|
|
14677
14677
|
if (Nt.isDocumentKey(t)) throw new W(Q.INVALID_ARGUMENT, `Invalid collection reference. Collection references must have an odd number of segments, but ${t} has ${t.length}.`);
|
|
14678
14678
|
}
|
|
14679
14679
|
|
|
@@ -14682,7 +14682,7 @@ function yc(t, e, n) {
|
|
|
14682
14682
|
* (i.e. excludes Array, Date, etc.).
|
|
14683
14683
|
*/
|
|
14684
14684
|
/** Returns a string describing the type / value of the provided input. */
|
|
14685
|
-
function
|
|
14685
|
+
function Ia(t) {
|
|
14686
14686
|
if (void 0 === t) return "undefined";
|
|
14687
14687
|
if (null === t) return "null";
|
|
14688
14688
|
if ("string" == typeof t) return t.length > 20 && (t = `${t.substring(0, 20)}...`),
|
|
@@ -14711,7 +14711,7 @@ function Ic(t) {
|
|
|
14711
14711
|
return "function" == typeof t ? "a function" : U();
|
|
14712
14712
|
}
|
|
14713
14713
|
|
|
14714
|
-
function
|
|
14714
|
+
function Aa(t,
|
|
14715
14715
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14716
14716
|
e) {
|
|
14717
14717
|
if ("_delegate" in t && (
|
|
@@ -14720,14 +14720,14 @@ e) {
|
|
|
14720
14720
|
t = t._delegate), !(t instanceof e)) {
|
|
14721
14721
|
if (e.name === t.constructor.name) throw new W(Q.INVALID_ARGUMENT, "Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");
|
|
14722
14722
|
{
|
|
14723
|
-
const n =
|
|
14723
|
+
const n = Ia(t);
|
|
14724
14724
|
throw new W(Q.INVALID_ARGUMENT, `Expected type '${e.name}', but it was: ${n}`);
|
|
14725
14725
|
}
|
|
14726
14726
|
}
|
|
14727
14727
|
return t;
|
|
14728
14728
|
}
|
|
14729
14729
|
|
|
14730
|
-
function
|
|
14730
|
+
function Ra(t, e) {
|
|
14731
14731
|
if (e <= 0) throw new W(Q.INVALID_ARGUMENT, `Function ${t}() requires a positive number, but it was: ${e}.`);
|
|
14732
14732
|
}
|
|
14733
14733
|
|
|
@@ -14753,7 +14753,7 @@ function Rc(t, e) {
|
|
|
14753
14753
|
* user-supplied `FirestoreSettings` object. This is a separate type so that
|
|
14754
14754
|
* defaults can be supplied and the value can be checked for equality.
|
|
14755
14755
|
*/
|
|
14756
|
-
class
|
|
14756
|
+
class ba {
|
|
14757
14757
|
constructor(t) {
|
|
14758
14758
|
var e;
|
|
14759
14759
|
if (void 0 === t.host) {
|
|
@@ -14766,7 +14766,7 @@ class bc {
|
|
|
14766
14766
|
this.cacheSizeBytes = t.cacheSizeBytes;
|
|
14767
14767
|
}
|
|
14768
14768
|
this.experimentalForceLongPolling = !!t.experimentalForceLongPolling, this.experimentalAutoDetectLongPolling = !!t.experimentalAutoDetectLongPolling,
|
|
14769
|
-
this.useFetchStreams = !!t.useFetchStreams,
|
|
14769
|
+
this.useFetchStreams = !!t.useFetchStreams, pa("experimentalForceLongPolling", t.experimentalForceLongPolling, "experimentalAutoDetectLongPolling", t.experimentalAutoDetectLongPolling);
|
|
14770
14770
|
}
|
|
14771
14771
|
isEqual(t) {
|
|
14772
14772
|
return this.host === t.host && this.ssl === t.ssl && this.credentials === t.credentials && this.cacheSizeBytes === t.cacheSizeBytes && this.experimentalForceLongPolling === t.experimentalForceLongPolling && this.experimentalAutoDetectLongPolling === t.experimentalAutoDetectLongPolling && this.ignoreUndefinedProperties === t.ignoreUndefinedProperties && this.useFetchStreams === t.useFetchStreams;
|
|
@@ -14793,18 +14793,18 @@ class bc {
|
|
|
14793
14793
|
* The Cloud Firestore service interface.
|
|
14794
14794
|
*
|
|
14795
14795
|
* Do not call this constructor directly. Instead, use {@link getFirestore}.
|
|
14796
|
-
*/ class
|
|
14796
|
+
*/ class Pa {
|
|
14797
14797
|
/** @hideconstructor */
|
|
14798
14798
|
constructor(t, e, n) {
|
|
14799
14799
|
this._authCredentials = e, this._appCheckCredentials = n,
|
|
14800
14800
|
/**
|
|
14801
14801
|
* Whether it's a Firestore or Firestore Lite instance.
|
|
14802
14802
|
*/
|
|
14803
|
-
this.type = "firestore-lite", this._persistenceKey = "(lite)", this._settings = new
|
|
14804
|
-
this._settingsFrozen = !1, t instanceof
|
|
14803
|
+
this.type = "firestore-lite", this._persistenceKey = "(lite)", this._settings = new ba({}),
|
|
14804
|
+
this._settingsFrozen = !1, t instanceof ma ? this._databaseId = t : (this._app = t,
|
|
14805
14805
|
this._databaseId = function(t) {
|
|
14806
14806
|
if (!Object.prototype.hasOwnProperty.apply(t.options, [ "projectId" ])) throw new W(Q.INVALID_ARGUMENT, '"projectId" not provided in firebase.initializeApp.');
|
|
14807
|
-
return new
|
|
14807
|
+
return new ma(t.options.projectId);
|
|
14808
14808
|
}
|
|
14809
14809
|
/**
|
|
14810
14810
|
* Modify this instance to communicate with the Cloud Firestore emulator.
|
|
@@ -14835,7 +14835,7 @@ class bc {
|
|
|
14835
14835
|
}
|
|
14836
14836
|
_setSettings(t) {
|
|
14837
14837
|
if (this._settingsFrozen) throw new W(Q.FAILED_PRECONDITION, "Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.");
|
|
14838
|
-
this._settings = new
|
|
14838
|
+
this._settings = new ba(t), void 0 !== t.credentials && (this._authCredentials = function(t) {
|
|
14839
14839
|
if (!t) return new H;
|
|
14840
14840
|
switch (t.type) {
|
|
14841
14841
|
case "gapi":
|
|
@@ -14880,15 +14880,15 @@ class bc {
|
|
|
14880
14880
|
* when the `Firestore` instance is terminated.
|
|
14881
14881
|
*/
|
|
14882
14882
|
return function(t) {
|
|
14883
|
-
const e =
|
|
14884
|
-
e && (M("ComponentProvider", "Removing Datastore"),
|
|
14883
|
+
const e = ga.get(t);
|
|
14884
|
+
e && (M("ComponentProvider", "Removing Datastore"), ga.delete(t), e.terminate());
|
|
14885
14885
|
}(this), Promise.resolve();
|
|
14886
14886
|
}
|
|
14887
14887
|
}
|
|
14888
14888
|
|
|
14889
|
-
function
|
|
14889
|
+
function va(t, e, n, s = {}) {
|
|
14890
14890
|
var i;
|
|
14891
|
-
const r = (t =
|
|
14891
|
+
const r = (t = Aa(t, Pa))._getSettings();
|
|
14892
14892
|
if ("firestore.googleapis.com" !== r.host && r.host !== e && L("Host has been set in both settings() and useEmulator(), emulator host will be used"),
|
|
14893
14893
|
t._setSettings(Object.assign(Object.assign({}, r), {
|
|
14894
14894
|
host: `${e}:${n}`,
|
|
@@ -14927,7 +14927,7 @@ function vc(t, e, n, s = {}) {
|
|
|
14927
14927
|
* A `DocumentReference` refers to a document location in a Firestore database
|
|
14928
14928
|
* and can be used to write, read, or listen to the location. The document at
|
|
14929
14929
|
* the referenced location may or may not exist.
|
|
14930
|
-
*/ class
|
|
14930
|
+
*/ class Va {
|
|
14931
14931
|
/** @hideconstructor */
|
|
14932
14932
|
constructor(t,
|
|
14933
14933
|
/**
|
|
@@ -14955,17 +14955,17 @@ function vc(t, e, n, s = {}) {
|
|
|
14955
14955
|
/**
|
|
14956
14956
|
* The collection this `DocumentReference` belongs to.
|
|
14957
14957
|
*/ get parent() {
|
|
14958
|
-
return new
|
|
14958
|
+
return new Da(this.firestore, this.converter, this._key.path.popLast());
|
|
14959
14959
|
}
|
|
14960
14960
|
withConverter(t) {
|
|
14961
|
-
return new
|
|
14961
|
+
return new Va(this.firestore, t, this._key);
|
|
14962
14962
|
}
|
|
14963
14963
|
}
|
|
14964
14964
|
|
|
14965
14965
|
/**
|
|
14966
14966
|
* A `Query` refers to a query which you can read or listen to. You can also
|
|
14967
14967
|
* construct refined `Query` objects by adding filters and ordering.
|
|
14968
|
-
*/ class
|
|
14968
|
+
*/ class Sa {
|
|
14969
14969
|
// This is the lite version of the Query class in the main SDK.
|
|
14970
14970
|
/** @hideconstructor protected */
|
|
14971
14971
|
constructor(t,
|
|
@@ -14978,14 +14978,14 @@ function vc(t, e, n, s = {}) {
|
|
|
14978
14978
|
this.type = "query", this.firestore = t;
|
|
14979
14979
|
}
|
|
14980
14980
|
withConverter(t) {
|
|
14981
|
-
return new
|
|
14981
|
+
return new Sa(this.firestore, t, this._query);
|
|
14982
14982
|
}
|
|
14983
14983
|
}
|
|
14984
14984
|
|
|
14985
14985
|
/**
|
|
14986
14986
|
* A `CollectionReference` object can be used for adding documents, getting
|
|
14987
14987
|
* document references, and querying for documents (using {@link query}).
|
|
14988
|
-
*/ class
|
|
14988
|
+
*/ class Da extends Sa {
|
|
14989
14989
|
/** @hideconstructor */
|
|
14990
14990
|
constructor(t, e, n) {
|
|
14991
14991
|
super(t, e, Te(n)), this._path = n,
|
|
@@ -15006,23 +15006,23 @@ function vc(t, e, n, s = {}) {
|
|
|
15006
15006
|
* subcollection. If this isn't a subcollection, the reference is null.
|
|
15007
15007
|
*/ get parent() {
|
|
15008
15008
|
const t = this._path.popLast();
|
|
15009
|
-
return t.isEmpty() ? null : new
|
|
15009
|
+
return t.isEmpty() ? null : new Va(this.firestore,
|
|
15010
15010
|
/* converter= */ null, new Nt(t));
|
|
15011
15011
|
}
|
|
15012
15012
|
withConverter(t) {
|
|
15013
|
-
return new
|
|
15013
|
+
return new Da(this.firestore, t, this._path);
|
|
15014
15014
|
}
|
|
15015
15015
|
}
|
|
15016
15016
|
|
|
15017
|
-
function
|
|
15018
|
-
if (t = T(t),
|
|
15017
|
+
function Ca(t, e, ...n) {
|
|
15018
|
+
if (t = T(t), ya("collection", "path", e), t instanceof Pa) {
|
|
15019
15019
|
const s = _t.fromString(e, ...n);
|
|
15020
|
-
return
|
|
15020
|
+
return Ea(s), new Da(t, /* converter= */ null, s);
|
|
15021
15021
|
}
|
|
15022
15022
|
{
|
|
15023
|
-
if (!(t instanceof
|
|
15023
|
+
if (!(t instanceof Va || t instanceof Da)) throw new W(Q.INVALID_ARGUMENT, "Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");
|
|
15024
15024
|
const s = t._path.child(_t.fromString(e, ...n));
|
|
15025
|
-
return
|
|
15025
|
+
return Ea(s), new Da(t.firestore,
|
|
15026
15026
|
/* converter= */ null, s);
|
|
15027
15027
|
}
|
|
15028
15028
|
}
|
|
@@ -15039,9 +15039,9 @@ function Cc(t, e, ...n) {
|
|
|
15039
15039
|
* collection or subcollection with this ID as the last segment of its path
|
|
15040
15040
|
* will be included. Cannot contain a slash.
|
|
15041
15041
|
* @returns The created `Query`.
|
|
15042
|
-
*/ function
|
|
15043
|
-
if (t =
|
|
15044
|
-
return new
|
|
15042
|
+
*/ function Na(t, e) {
|
|
15043
|
+
if (t = Aa(t, Pa), ya("collectionGroup", "collection id", e), e.indexOf("/") >= 0) throw new W(Q.INVALID_ARGUMENT, `Invalid collection ID '${e}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);
|
|
15044
|
+
return new Sa(t,
|
|
15045
15045
|
/* converter= */ null,
|
|
15046
15046
|
/**
|
|
15047
15047
|
* Creates a new Query for a collection group query that matches all documents
|
|
@@ -15052,19 +15052,19 @@ function Cc(t, e, ...n) {
|
|
|
15052
15052
|
}(e));
|
|
15053
15053
|
}
|
|
15054
15054
|
|
|
15055
|
-
function
|
|
15055
|
+
function ka(t, e, ...n) {
|
|
15056
15056
|
if (t = T(t),
|
|
15057
15057
|
// We allow omission of 'pathString' but explicitly prohibit passing in both
|
|
15058
15058
|
// 'undefined' and 'null'.
|
|
15059
|
-
1 === arguments.length && (e = rt.A()),
|
|
15059
|
+
1 === arguments.length && (e = rt.A()), ya("doc", "path", e), t instanceof Pa) {
|
|
15060
15060
|
const s = _t.fromString(e, ...n);
|
|
15061
|
-
return
|
|
15061
|
+
return Ta(s), new Va(t,
|
|
15062
15062
|
/* converter= */ null, new Nt(s));
|
|
15063
15063
|
}
|
|
15064
15064
|
{
|
|
15065
|
-
if (!(t instanceof
|
|
15065
|
+
if (!(t instanceof Va || t instanceof Da)) throw new W(Q.INVALID_ARGUMENT, "Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");
|
|
15066
15066
|
const s = t._path.child(_t.fromString(e, ...n));
|
|
15067
|
-
return
|
|
15067
|
+
return Ta(s), new Va(t.firestore, t instanceof Da ? t.converter : null, new Nt(s));
|
|
15068
15068
|
}
|
|
15069
15069
|
}
|
|
15070
15070
|
|
|
@@ -15075,8 +15075,8 @@ function kc(t, e, ...n) {
|
|
|
15075
15075
|
* @param right - A reference to compare.
|
|
15076
15076
|
* @returns true if the references point to the same location in the same
|
|
15077
15077
|
* Firestore database.
|
|
15078
|
-
*/ function
|
|
15079
|
-
return t = T(t), e = T(e), (t instanceof
|
|
15078
|
+
*/ function xa(t, e) {
|
|
15079
|
+
return t = T(t), e = T(e), (t instanceof Va || t instanceof Da) && (e instanceof Va || e instanceof Da) && (t.firestore === e.firestore && t.path === e.path && t.converter === e.converter);
|
|
15080
15080
|
}
|
|
15081
15081
|
|
|
15082
15082
|
/**
|
|
@@ -15087,8 +15087,8 @@ function kc(t, e, ...n) {
|
|
|
15087
15087
|
* @param right - A `Query` to compare.
|
|
15088
15088
|
* @returns true if the references point to the same location in the same
|
|
15089
15089
|
* Firestore database.
|
|
15090
|
-
*/ function $
|
|
15091
|
-
return t = T(t), e = T(e), t instanceof
|
|
15090
|
+
*/ function $a(t, e) {
|
|
15091
|
+
return t = T(t), e = T(e), t instanceof Sa && e instanceof Sa && (t.firestore === e.firestore && Se(t._query, e._query) && t.converter === e.converter);
|
|
15092
15092
|
}
|
|
15093
15093
|
|
|
15094
15094
|
/**
|
|
@@ -15106,42 +15106,42 @@ function kc(t, e, ...n) {
|
|
|
15106
15106
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15107
15107
|
* See the License for the specific language governing permissions and
|
|
15108
15108
|
* limitations under the License.
|
|
15109
|
-
*/ class
|
|
15109
|
+
*/ class Oa {
|
|
15110
15110
|
constructor() {
|
|
15111
15111
|
// The last promise in the queue.
|
|
15112
|
-
this.
|
|
15112
|
+
this.mc = Promise.resolve(),
|
|
15113
15113
|
// A list of retryable operations. Retryable operations are run in order and
|
|
15114
15114
|
// retried with backoff.
|
|
15115
|
-
this.
|
|
15115
|
+
this.gc = [],
|
|
15116
15116
|
// Is this AsyncQueue being shut down? Once it is set to true, it will not
|
|
15117
15117
|
// be changed again.
|
|
15118
|
-
this.
|
|
15118
|
+
this.yc = !1,
|
|
15119
15119
|
// Operations scheduled to be queued in the future. Operations are
|
|
15120
15120
|
// automatically removed after they are run or canceled.
|
|
15121
|
-
this.
|
|
15121
|
+
this.Tc = [],
|
|
15122
15122
|
// visible for testing
|
|
15123
|
-
this.
|
|
15123
|
+
this.Ec = null,
|
|
15124
15124
|
// Flag set while there's an outstanding AsyncQueue operation, used for
|
|
15125
15125
|
// assertion sanity-checks.
|
|
15126
|
-
this.
|
|
15126
|
+
this.Ic = !1,
|
|
15127
15127
|
// Enabled during shutdown on Safari to prevent future access to IndexedDB.
|
|
15128
|
-
this.
|
|
15128
|
+
this.Ac = !1,
|
|
15129
15129
|
// List of TimerIds to fast-forward delays for.
|
|
15130
|
-
this.
|
|
15130
|
+
this.Rc = [],
|
|
15131
15131
|
// Backoff timer used to schedule retries for retryable operations
|
|
15132
15132
|
this.ur = new io(this, "async_queue_retry" /* AsyncQueueRetry */),
|
|
15133
15133
|
// Visibility handler that triggers an immediate retry of all retryable
|
|
15134
15134
|
// operations. Meant to speed up recovery when we regain file system access
|
|
15135
15135
|
// after page comes into foreground.
|
|
15136
|
-
this.
|
|
15136
|
+
this.bc = () => {
|
|
15137
15137
|
const t = no();
|
|
15138
15138
|
t && M("AsyncQueue", "Visibility state changed to " + t.visibilityState), this.ur.er();
|
|
15139
15139
|
};
|
|
15140
15140
|
const t = no();
|
|
15141
|
-
t && "function" == typeof t.addEventListener && t.addEventListener("visibilitychange", this.
|
|
15141
|
+
t && "function" == typeof t.addEventListener && t.addEventListener("visibilitychange", this.bc);
|
|
15142
15142
|
}
|
|
15143
15143
|
get isShuttingDown() {
|
|
15144
|
-
return this.
|
|
15144
|
+
return this.yc;
|
|
15145
15145
|
}
|
|
15146
15146
|
/**
|
|
15147
15147
|
* Adds a new operation to the queue without waiting for it to complete (i.e.
|
|
@@ -15151,44 +15151,44 @@ function kc(t, e, ...n) {
|
|
|
15151
15151
|
this.enqueue(t);
|
|
15152
15152
|
}
|
|
15153
15153
|
enqueueAndForgetEvenWhileRestricted(t) {
|
|
15154
|
-
this.
|
|
15154
|
+
this.Pc(),
|
|
15155
15155
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
15156
|
-
this.
|
|
15156
|
+
this.vc(t);
|
|
15157
15157
|
}
|
|
15158
15158
|
enterRestrictedMode(t) {
|
|
15159
|
-
if (!this.
|
|
15160
|
-
this.
|
|
15159
|
+
if (!this.yc) {
|
|
15160
|
+
this.yc = !0, this.Ac = t || !1;
|
|
15161
15161
|
const e = no();
|
|
15162
|
-
e && "function" == typeof e.removeEventListener && e.removeEventListener("visibilitychange", this.
|
|
15162
|
+
e && "function" == typeof e.removeEventListener && e.removeEventListener("visibilitychange", this.bc);
|
|
15163
15163
|
}
|
|
15164
15164
|
}
|
|
15165
15165
|
enqueue(t) {
|
|
15166
|
-
if (this.
|
|
15166
|
+
if (this.Pc(), this.yc)
|
|
15167
15167
|
// Return a Promise which never resolves.
|
|
15168
15168
|
return new Promise((() => {}));
|
|
15169
15169
|
// Create a deferred Promise that we can return to the callee. This
|
|
15170
15170
|
// allows us to return a "hanging Promise" only to the callee and still
|
|
15171
15171
|
// advance the queue even when the operation is not run.
|
|
15172
15172
|
const e = new G;
|
|
15173
|
-
return this.
|
|
15173
|
+
return this.vc((() => this.yc && this.Ac ? Promise.resolve() : (t().then(e.resolve, e.reject),
|
|
15174
15174
|
e.promise))).then((() => e.promise));
|
|
15175
15175
|
}
|
|
15176
15176
|
enqueueRetryable(t) {
|
|
15177
|
-
this.enqueueAndForget((() => (this.
|
|
15177
|
+
this.enqueueAndForget((() => (this.gc.push(t), this.Vc())));
|
|
15178
15178
|
}
|
|
15179
15179
|
/**
|
|
15180
15180
|
* Runs the next operation from the retryable queue. If the operation fails,
|
|
15181
15181
|
* reschedules with backoff.
|
|
15182
|
-
*/ async
|
|
15183
|
-
if (0 !== this.
|
|
15182
|
+
*/ async Vc() {
|
|
15183
|
+
if (0 !== this.gc.length) {
|
|
15184
15184
|
try {
|
|
15185
|
-
await this.
|
|
15185
|
+
await this.gc[0](), this.gc.shift(), this.ur.reset();
|
|
15186
15186
|
} catch (t) {
|
|
15187
15187
|
if (!ei(t)) throw t;
|
|
15188
15188
|
// Failure will be handled by AsyncQueue
|
|
15189
15189
|
M("AsyncQueue", "Operation failed with retryable error: " + t);
|
|
15190
15190
|
}
|
|
15191
|
-
this.
|
|
15191
|
+
this.gc.length > 0 &&
|
|
15192
15192
|
// If there are additional operations, we re-schedule `retryNextOp()`.
|
|
15193
15193
|
// This is necessary to run retryable operations that failed during
|
|
15194
15194
|
// their initial attempt since we don't know whether they are already
|
|
@@ -15199,12 +15199,12 @@ function kc(t, e, ...n) {
|
|
|
15199
15199
|
// Since `backoffAndRun()` cancels an existing backoff and schedules a
|
|
15200
15200
|
// new backoff on every call, there is only ever a single additional
|
|
15201
15201
|
// operation in the queue.
|
|
15202
|
-
this.ur.Zi((() => this.
|
|
15202
|
+
this.ur.Zi((() => this.Vc()));
|
|
15203
15203
|
}
|
|
15204
15204
|
}
|
|
15205
|
-
|
|
15206
|
-
const e = this.
|
|
15207
|
-
this.
|
|
15205
|
+
vc(t) {
|
|
15206
|
+
const e = this.mc.then((() => (this.Ic = !0, t().catch((t => {
|
|
15207
|
+
this.Ec = t, this.Ic = !1;
|
|
15208
15208
|
const e =
|
|
15209
15209
|
/**
|
|
15210
15210
|
* Chrome includes Error.message in Error.stack. Other browsers do not.
|
|
@@ -15236,38 +15236,38 @@ function kc(t, e, ...n) {
|
|
|
15236
15236
|
// all further attempts to chain (via .then) will just short-circuit
|
|
15237
15237
|
// and return the rejected Promise.
|
|
15238
15238
|
throw F("INTERNAL UNHANDLED ERROR: ", e), t;
|
|
15239
|
-
})).then((t => (this.
|
|
15240
|
-
return this.
|
|
15239
|
+
})).then((t => (this.Ic = !1, t))))));
|
|
15240
|
+
return this.mc = e, e;
|
|
15241
15241
|
}
|
|
15242
15242
|
enqueueAfterDelay(t, e, n) {
|
|
15243
|
-
this.
|
|
15243
|
+
this.Pc(),
|
|
15244
15244
|
// Fast-forward delays for timerIds that have been overriden.
|
|
15245
|
-
this.
|
|
15246
|
-
const s = Lo.createAndSchedule(this, t, e, n, (t => this.
|
|
15247
|
-
return this.
|
|
15245
|
+
this.Rc.indexOf(t) > -1 && (e = 0);
|
|
15246
|
+
const s = Lo.createAndSchedule(this, t, e, n, (t => this.Sc(t)));
|
|
15247
|
+
return this.Tc.push(s), s;
|
|
15248
15248
|
}
|
|
15249
|
-
|
|
15250
|
-
this.
|
|
15249
|
+
Pc() {
|
|
15250
|
+
this.Ec && U();
|
|
15251
15251
|
}
|
|
15252
15252
|
verifyOperationInProgress() {}
|
|
15253
15253
|
/**
|
|
15254
15254
|
* Waits until all currently queued tasks are finished executing. Delayed
|
|
15255
15255
|
* operations are not run.
|
|
15256
|
-
*/ async
|
|
15256
|
+
*/ async Dc() {
|
|
15257
15257
|
// Operations in the queue prior to draining may have enqueued additional
|
|
15258
15258
|
// operations. Keep draining the queue until the tail is no longer advanced,
|
|
15259
15259
|
// which indicates that no more new operations were enqueued and that all
|
|
15260
15260
|
// operations were executed.
|
|
15261
15261
|
let t;
|
|
15262
15262
|
do {
|
|
15263
|
-
t = this.
|
|
15264
|
-
} while (t !== this.
|
|
15263
|
+
t = this.mc, await t;
|
|
15264
|
+
} while (t !== this.mc);
|
|
15265
15265
|
}
|
|
15266
15266
|
/**
|
|
15267
15267
|
* For Tests: Determine if a delayed operation with a particular TimerId
|
|
15268
15268
|
* exists.
|
|
15269
|
-
*/
|
|
15270
|
-
for (const e of this.
|
|
15269
|
+
*/ Cc(t) {
|
|
15270
|
+
for (const e of this.Tc) if (e.timerId === t) return !0;
|
|
15271
15271
|
return !1;
|
|
15272
15272
|
}
|
|
15273
15273
|
/**
|
|
@@ -15276,28 +15276,28 @@ function kc(t, e, ...n) {
|
|
|
15276
15276
|
* @param lastTimerId - Delayed operations up to and including this TimerId
|
|
15277
15277
|
* will be drained. Pass TimerId.All to run all delayed operations.
|
|
15278
15278
|
* @returns a Promise that resolves once all operations have been run.
|
|
15279
|
-
*/
|
|
15279
|
+
*/ Nc(t) {
|
|
15280
15280
|
// Note that draining may generate more delayed ops, so we do that first.
|
|
15281
|
-
return this.
|
|
15281
|
+
return this.Dc().then((() => {
|
|
15282
15282
|
// Run ops in the same order they'd run if they ran naturally.
|
|
15283
|
-
this.
|
|
15284
|
-
for (const e of this.
|
|
15285
|
-
return this.
|
|
15283
|
+
this.Tc.sort(((t, e) => t.targetTimeMs - e.targetTimeMs));
|
|
15284
|
+
for (const e of this.Tc) if (e.skipDelay(), "all" /* All */ !== t && e.timerId === t) break;
|
|
15285
|
+
return this.Dc();
|
|
15286
15286
|
}));
|
|
15287
15287
|
}
|
|
15288
15288
|
/**
|
|
15289
15289
|
* For Tests: Skip all subsequent delays for a timer id.
|
|
15290
|
-
*/
|
|
15291
|
-
this.
|
|
15290
|
+
*/ kc(t) {
|
|
15291
|
+
this.Rc.push(t);
|
|
15292
15292
|
}
|
|
15293
|
-
/** Called once a DelayedOperation is run or canceled. */
|
|
15293
|
+
/** Called once a DelayedOperation is run or canceled. */ Sc(t) {
|
|
15294
15294
|
// NOTE: indexOf / slice are O(n), but delayedOperations is expected to be small.
|
|
15295
|
-
const e = this.
|
|
15296
|
-
this.
|
|
15295
|
+
const e = this.Tc.indexOf(t);
|
|
15296
|
+
this.Tc.splice(e, 1);
|
|
15297
15297
|
}
|
|
15298
15298
|
}
|
|
15299
15299
|
|
|
15300
|
-
function
|
|
15300
|
+
function Ma(t) {
|
|
15301
15301
|
/**
|
|
15302
15302
|
* Returns true if obj is an object and contains at least one of the specified
|
|
15303
15303
|
* methods.
|
|
@@ -15332,7 +15332,7 @@ function Mc(t) {
|
|
|
15332
15332
|
*/ (t, [ "next", "error", "complete" ]);
|
|
15333
15333
|
}
|
|
15334
15334
|
|
|
15335
|
-
class
|
|
15335
|
+
class Fa {
|
|
15336
15336
|
constructor() {
|
|
15337
15337
|
this._progressObserver = {}, this._taskCompletionResolver = new G, this._lastProgress = {
|
|
15338
15338
|
taskState: "Running",
|
|
@@ -15416,27 +15416,27 @@ class Fc {
|
|
|
15416
15416
|
* See the License for the specific language governing permissions and
|
|
15417
15417
|
* limitations under the License.
|
|
15418
15418
|
*/
|
|
15419
|
-
/** DOMException error code constants. */ const
|
|
15419
|
+
/** DOMException error code constants. */ const La = -1;
|
|
15420
15420
|
|
|
15421
15421
|
/**
|
|
15422
15422
|
* The Cloud Firestore service interface.
|
|
15423
15423
|
*
|
|
15424
15424
|
* Do not call this constructor directly. Instead, use {@link getFirestore}.
|
|
15425
15425
|
*/
|
|
15426
|
-
class
|
|
15426
|
+
class Ba extends Pa {
|
|
15427
15427
|
/** @hideconstructor */
|
|
15428
15428
|
constructor(t, e, n) {
|
|
15429
15429
|
super(t, e, n),
|
|
15430
15430
|
/**
|
|
15431
15431
|
* Whether it's a {@link Firestore} or Firestore Lite instance.
|
|
15432
15432
|
*/
|
|
15433
|
-
this.type = "firestore", this._queue = new
|
|
15433
|
+
this.type = "firestore", this._queue = new Oa, this._persistenceKey = "name" in t ? t.name : "[DEFAULT]";
|
|
15434
15434
|
}
|
|
15435
15435
|
_terminate() {
|
|
15436
15436
|
return this._firestoreClient ||
|
|
15437
15437
|
// The client must be initialized to ensure that all subsequent API
|
|
15438
15438
|
// usage throws an exception.
|
|
15439
|
-
|
|
15439
|
+
ja(this), this._firestoreClient.terminate();
|
|
15440
15440
|
}
|
|
15441
15441
|
}
|
|
15442
15442
|
|
|
@@ -15450,7 +15450,7 @@ class Bc extends Pc {
|
|
|
15450
15450
|
* be associated.
|
|
15451
15451
|
* @param settings - A settings object to configure the {@link Firestore} instance.
|
|
15452
15452
|
* @returns A newly initialized {@link Firestore} instance.
|
|
15453
|
-
*/ function
|
|
15453
|
+
*/ function Ua(t, e) {
|
|
15454
15454
|
const n = _getProvider(t, "firestore");
|
|
15455
15455
|
if (n.isInitialized()) {
|
|
15456
15456
|
const t = n.getImmediate(), s = n.getOptions();
|
|
@@ -15471,22 +15471,22 @@ class Bc extends Pc {
|
|
|
15471
15471
|
* @param app - The {@link @firebase/app#FirebaseApp} instance that the returned {@link Firestore}
|
|
15472
15472
|
* instance is associated with.
|
|
15473
15473
|
* @returns The {@link Firestore} instance of the provided app.
|
|
15474
|
-
*/ function
|
|
15474
|
+
*/ function qa(e = t()) {
|
|
15475
15475
|
return _getProvider(e, "firestore").getImmediate();
|
|
15476
15476
|
}
|
|
15477
15477
|
|
|
15478
15478
|
/**
|
|
15479
15479
|
* @internal
|
|
15480
|
-
*/ function
|
|
15481
|
-
return t._firestoreClient ||
|
|
15480
|
+
*/ function Ka(t) {
|
|
15481
|
+
return t._firestoreClient || ja(t), t._firestoreClient.verifyNotTerminated(), t._firestoreClient;
|
|
15482
15482
|
}
|
|
15483
15483
|
|
|
15484
|
-
function
|
|
15484
|
+
function ja(t) {
|
|
15485
15485
|
var e;
|
|
15486
15486
|
const n = t._freezeSettings(), s = function(t, e, n, s) {
|
|
15487
|
-
return new
|
|
15487
|
+
return new _a(t, e, n, s.host, s.ssl, s.experimentalForceLongPolling, s.experimentalAutoDetectLongPolling, s.useFetchStreams);
|
|
15488
15488
|
}(t._databaseId, (null === (e = t._app) || void 0 === e ? void 0 : e.options.appId) || "", t._persistenceKey, n);
|
|
15489
|
-
t._firestoreClient = new
|
|
15489
|
+
t._firestoreClient = new Hc(t._authCredentials, t._appCheckCredentials, t._queue, s);
|
|
15490
15490
|
}
|
|
15491
15491
|
|
|
15492
15492
|
/**
|
|
@@ -15511,10 +15511,10 @@ function jc(t) {
|
|
|
15511
15511
|
* @param persistenceSettings - Optional settings object to configure
|
|
15512
15512
|
* persistence.
|
|
15513
15513
|
* @returns A `Promise` that represents successfully enabling persistent storage.
|
|
15514
|
-
*/ function
|
|
15515
|
-
eu(t =
|
|
15516
|
-
const n =
|
|
15517
|
-
return
|
|
15514
|
+
*/ function Qa(t, e) {
|
|
15515
|
+
eu(t = Aa(t, Ba));
|
|
15516
|
+
const n = Ka(t), s = t._freezeSettings(), i = new Kc;
|
|
15517
|
+
return Ga(n, i, new Uc(i, s.cacheSizeBytes, null == e ? void 0 : e.forceOwnership));
|
|
15518
15518
|
}
|
|
15519
15519
|
|
|
15520
15520
|
/**
|
|
@@ -15538,10 +15538,10 @@ function jc(t) {
|
|
|
15538
15538
|
* @param firestore - The {@link Firestore} instance to enable persistence for.
|
|
15539
15539
|
* @returns A `Promise` that represents successfully enabling persistent
|
|
15540
15540
|
* storage.
|
|
15541
|
-
*/ function
|
|
15542
|
-
eu(t =
|
|
15543
|
-
const e =
|
|
15544
|
-
return
|
|
15541
|
+
*/ function Wa(t) {
|
|
15542
|
+
eu(t = Aa(t, Ba));
|
|
15543
|
+
const e = Ka(t), n = t._freezeSettings(), s = new Kc;
|
|
15544
|
+
return Ga(e, s, new qc(s, n.cacheSizeBytes));
|
|
15545
15545
|
}
|
|
15546
15546
|
|
|
15547
15547
|
/**
|
|
@@ -15549,11 +15549,11 @@ function jc(t) {
|
|
|
15549
15549
|
* If the operation fails with a recoverable error (see
|
|
15550
15550
|
* `canRecoverFromIndexedDbError()` below), the returned Promise is rejected
|
|
15551
15551
|
* but the client remains usable.
|
|
15552
|
-
*/ function
|
|
15552
|
+
*/ function Ga(t, e, n) {
|
|
15553
15553
|
const s = new G;
|
|
15554
15554
|
return t.asyncQueue.enqueue((async () => {
|
|
15555
15555
|
try {
|
|
15556
|
-
await
|
|
15556
|
+
await Jc(t, n), await Yc(t, e), s.resolve();
|
|
15557
15557
|
} catch (t) {
|
|
15558
15558
|
if (!
|
|
15559
15559
|
/**
|
|
@@ -15607,7 +15607,7 @@ function jc(t) {
|
|
|
15607
15607
|
})).then((() => s.promise));
|
|
15608
15608
|
}
|
|
15609
15609
|
|
|
15610
|
-
function
|
|
15610
|
+
function za(t) {
|
|
15611
15611
|
if (t._initialized && !t._terminated) throw new W(Q.FAILED_PRECONDITION, "Persistence can only be cleared before a Firestore instance is initialized or after it is terminated.");
|
|
15612
15612
|
const e = new G;
|
|
15613
15613
|
return t._queue.enqueueAndForgetEvenWhileRestricted((async () => {
|
|
@@ -15638,11 +15638,11 @@ function zc(t) {
|
|
|
15638
15638
|
*
|
|
15639
15639
|
* @returns A `Promise` which resolves when all currently pending writes have been
|
|
15640
15640
|
* acknowledged by the backend.
|
|
15641
|
-
*/ function
|
|
15641
|
+
*/ function Ha(t) {
|
|
15642
15642
|
return function(t) {
|
|
15643
15643
|
const e = new G;
|
|
15644
|
-
return t.asyncQueue.enqueueAndForget((async () =>
|
|
15645
|
-
}(
|
|
15644
|
+
return t.asyncQueue.enqueueAndForget((async () => gc(await sa(t), e))), e.promise;
|
|
15645
|
+
}(Ka(t = Aa(t, Ba)));
|
|
15646
15646
|
}
|
|
15647
15647
|
|
|
15648
15648
|
/**
|
|
@@ -15650,8 +15650,8 @@ function zc(t) {
|
|
|
15650
15650
|
* call to {@link disableNetwork}.
|
|
15651
15651
|
*
|
|
15652
15652
|
* @returns A `Promise` that is resolved once the network has been enabled.
|
|
15653
|
-
*/ function
|
|
15654
|
-
return
|
|
15653
|
+
*/ function Ja(t) {
|
|
15654
|
+
return ra(Ka(t = Aa(t, Ba)));
|
|
15655
15655
|
}
|
|
15656
15656
|
|
|
15657
15657
|
/**
|
|
@@ -15661,8 +15661,8 @@ function zc(t) {
|
|
|
15661
15661
|
* operations will be queued until the network is restored.
|
|
15662
15662
|
*
|
|
15663
15663
|
* @returns A `Promise` that is resolved once the network has been disabled.
|
|
15664
|
-
*/ function
|
|
15665
|
-
return
|
|
15664
|
+
*/ function Ya(t) {
|
|
15665
|
+
return oa(Ka(t = Aa(t, Ba)));
|
|
15666
15666
|
}
|
|
15667
15667
|
|
|
15668
15668
|
/**
|
|
@@ -15686,7 +15686,7 @@ function zc(t) {
|
|
|
15686
15686
|
*
|
|
15687
15687
|
* @returns A `Promise` that is resolved when the instance has been successfully
|
|
15688
15688
|
* terminated.
|
|
15689
|
-
*/ function
|
|
15689
|
+
*/ function Xa(t) {
|
|
15690
15690
|
return e(t.app, "firestore"), t._delete();
|
|
15691
15691
|
}
|
|
15692
15692
|
|
|
@@ -15700,9 +15700,9 @@ function zc(t) {
|
|
|
15700
15700
|
* @returns
|
|
15701
15701
|
* A `LoadBundleTask` object, which notifies callers with progress updates, and completion
|
|
15702
15702
|
* or error events. It can be used as a `Promise<LoadBundleTaskProgress>`.
|
|
15703
|
-
*/ function
|
|
15704
|
-
const n =
|
|
15705
|
-
return
|
|
15703
|
+
*/ function Za(t, e) {
|
|
15704
|
+
const n = Ka(t = Aa(t, Ba)), s = new Fa;
|
|
15705
|
+
return da(n, t._databaseId, e, s), s;
|
|
15706
15706
|
}
|
|
15707
15707
|
|
|
15708
15708
|
/**
|
|
@@ -15712,7 +15712,7 @@ function zc(t) {
|
|
|
15712
15712
|
* with resulting documents), and loaded to local cache using `loadBundle`. Once in local
|
|
15713
15713
|
* cache, use this method to extract a {@link Query} by name.
|
|
15714
15714
|
*/ function tu(t, e) {
|
|
15715
|
-
return
|
|
15715
|
+
return wa(Ka(t = Aa(t, Ba)), e).then((e => e ? new Sa(t, null, e.query) : null));
|
|
15716
15716
|
}
|
|
15717
15717
|
|
|
15718
15718
|
function eu(t) {
|
|
@@ -15970,14 +15970,14 @@ class nu {
|
|
|
15970
15970
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15971
15971
|
* See the License for the specific language governing permissions and
|
|
15972
15972
|
* limitations under the License.
|
|
15973
|
-
*/ const
|
|
15973
|
+
*/ const cu = /^__.*__$/;
|
|
15974
15974
|
|
|
15975
|
-
/** The result of parsing document data (e.g. for a setData call). */ class
|
|
15975
|
+
/** The result of parsing document data (e.g. for a setData call). */ class au {
|
|
15976
15976
|
constructor(t, e, n) {
|
|
15977
15977
|
this.data = t, this.fieldMask = e, this.fieldTransforms = n;
|
|
15978
15978
|
}
|
|
15979
15979
|
toMutation(t, e) {
|
|
15980
|
-
return null !== this.fieldMask ? new un(t, this.data, this.fieldMask, e, this.fieldTransforms) : new
|
|
15980
|
+
return null !== this.fieldMask ? new un(t, this.data, this.fieldMask, e, this.fieldTransforms) : new an(t, this.data, e, this.fieldTransforms);
|
|
15981
15981
|
}
|
|
15982
15982
|
}
|
|
15983
15983
|
|
|
@@ -16033,55 +16033,55 @@ function hu(t) {
|
|
|
16033
16033
|
this.settings = t, this.databaseId = e, this.k = n, this.ignoreUndefinedProperties = s,
|
|
16034
16034
|
// Minor hack: If fieldTransforms is undefined, we assume this is an
|
|
16035
16035
|
// external call and we need to validate the entire path.
|
|
16036
|
-
void 0 === i && this.
|
|
16036
|
+
void 0 === i && this.xc(), this.fieldTransforms = i || [], this.fieldMask = r || [];
|
|
16037
16037
|
}
|
|
16038
16038
|
get path() {
|
|
16039
16039
|
return this.settings.path;
|
|
16040
16040
|
}
|
|
16041
|
-
get
|
|
16042
|
-
return this.settings
|
|
16041
|
+
get $c() {
|
|
16042
|
+
return this.settings.$c;
|
|
16043
16043
|
}
|
|
16044
|
-
/** Returns a new context with the specified settings overwritten. */
|
|
16044
|
+
/** Returns a new context with the specified settings overwritten. */ Oc(t) {
|
|
16045
16045
|
return new lu(Object.assign(Object.assign({}, this.settings), t), this.databaseId, this.k, this.ignoreUndefinedProperties, this.fieldTransforms, this.fieldMask);
|
|
16046
16046
|
}
|
|
16047
|
-
|
|
16047
|
+
Mc(t) {
|
|
16048
16048
|
var e;
|
|
16049
|
-
const n = null === (e = this.path) || void 0 === e ? void 0 : e.child(t), s = this
|
|
16049
|
+
const n = null === (e = this.path) || void 0 === e ? void 0 : e.child(t), s = this.Oc({
|
|
16050
16050
|
path: n,
|
|
16051
|
-
|
|
16051
|
+
Fc: !1
|
|
16052
16052
|
});
|
|
16053
|
-
return s.
|
|
16053
|
+
return s.Lc(t), s;
|
|
16054
16054
|
}
|
|
16055
|
-
|
|
16055
|
+
Bc(t) {
|
|
16056
16056
|
var e;
|
|
16057
|
-
const n = null === (e = this.path) || void 0 === e ? void 0 : e.child(t), s = this
|
|
16057
|
+
const n = null === (e = this.path) || void 0 === e ? void 0 : e.child(t), s = this.Oc({
|
|
16058
16058
|
path: n,
|
|
16059
|
-
|
|
16059
|
+
Fc: !1
|
|
16060
16060
|
});
|
|
16061
|
-
return s.
|
|
16061
|
+
return s.xc(), s;
|
|
16062
16062
|
}
|
|
16063
|
-
|
|
16063
|
+
Uc(t) {
|
|
16064
16064
|
// TODO(b/34871131): We don't support array paths right now; so make path
|
|
16065
16065
|
// undefined.
|
|
16066
|
-
return this
|
|
16066
|
+
return this.Oc({
|
|
16067
16067
|
path: void 0,
|
|
16068
|
-
|
|
16068
|
+
Fc: !0
|
|
16069
16069
|
});
|
|
16070
16070
|
}
|
|
16071
|
-
|
|
16072
|
-
return Cu(t, this.settings.methodName, this.settings.
|
|
16071
|
+
qc(t) {
|
|
16072
|
+
return Cu(t, this.settings.methodName, this.settings.Kc || !1, this.path, this.settings.jc);
|
|
16073
16073
|
}
|
|
16074
16074
|
/** Returns 'true' if 'fieldPath' was traversed when creating this context. */ contains(t) {
|
|
16075
16075
|
return void 0 !== this.fieldMask.find((e => t.isPrefixOf(e))) || void 0 !== this.fieldTransforms.find((e => t.isPrefixOf(e.field)));
|
|
16076
16076
|
}
|
|
16077
|
-
|
|
16077
|
+
xc() {
|
|
16078
16078
|
// TODO(b/34871131): Remove null check once we have proper paths for fields
|
|
16079
16079
|
// within arrays.
|
|
16080
|
-
if (this.path) for (let t = 0; t < this.path.length; t++) this.
|
|
16080
|
+
if (this.path) for (let t = 0; t < this.path.length; t++) this.Lc(this.path.get(t));
|
|
16081
16081
|
}
|
|
16082
|
-
|
|
16083
|
-
if (0 === t.length) throw this.
|
|
16084
|
-
if (hu(this
|
|
16082
|
+
Lc(t) {
|
|
16083
|
+
if (0 === t.length) throw this.qc("Document fields must not be empty");
|
|
16084
|
+
if (hu(this.$c) && cu.test(t)) throw this.qc('Document fields cannot begin and end with "__"');
|
|
16085
16085
|
}
|
|
16086
16086
|
}
|
|
16087
16087
|
|
|
@@ -16092,14 +16092,14 @@ function hu(t) {
|
|
|
16092
16092
|
constructor(t, e, n) {
|
|
16093
16093
|
this.databaseId = t, this.ignoreUndefinedProperties = e, this.k = n || so(t);
|
|
16094
16094
|
}
|
|
16095
|
-
/** Creates a new top-level parse context. */
|
|
16095
|
+
/** Creates a new top-level parse context. */ Qc(t, e, n, s = !1) {
|
|
16096
16096
|
return new lu({
|
|
16097
|
-
|
|
16097
|
+
$c: t,
|
|
16098
16098
|
methodName: e,
|
|
16099
|
-
|
|
16099
|
+
jc: n,
|
|
16100
16100
|
path: gt.emptyPath(),
|
|
16101
|
-
|
|
16102
|
-
|
|
16101
|
+
Fc: !1,
|
|
16102
|
+
Kc: s
|
|
16103
16103
|
}, this.databaseId, this.k, this.ignoreUndefinedProperties);
|
|
16104
16104
|
}
|
|
16105
16105
|
}
|
|
@@ -16110,25 +16110,25 @@ function du(t) {
|
|
|
16110
16110
|
}
|
|
16111
16111
|
|
|
16112
16112
|
/** Parse document data from a set() call. */ function wu(t, e, n, s, i, r = {}) {
|
|
16113
|
-
const o = t.
|
|
16113
|
+
const o = t.Qc(r.merge || r.mergeFields ? 2 /* MergeSet */ : 0 /* Set */ , e, n, i);
|
|
16114
16114
|
vu("Data must be an object, but it was:", o, s);
|
|
16115
|
-
const
|
|
16116
|
-
let
|
|
16117
|
-
if (r.merge)
|
|
16115
|
+
const c = bu(s, o);
|
|
16116
|
+
let a, u;
|
|
16117
|
+
if (r.merge) a = new yt(o.fieldMask), u = o.fieldTransforms; else if (r.mergeFields) {
|
|
16118
16118
|
const t = [];
|
|
16119
16119
|
for (const s of r.mergeFields) {
|
|
16120
16120
|
const i = Vu(e, s, n);
|
|
16121
16121
|
if (!o.contains(i)) throw new W(Q.INVALID_ARGUMENT, `Field '${i}' is specified in your field mask but missing from your input data.`);
|
|
16122
16122
|
Nu(t, i) || t.push(i);
|
|
16123
16123
|
}
|
|
16124
|
-
|
|
16125
|
-
} else
|
|
16126
|
-
return new
|
|
16124
|
+
a = new yt(t), u = o.fieldTransforms.filter((t => a.covers(t.field)));
|
|
16125
|
+
} else a = null, u = o.fieldTransforms;
|
|
16126
|
+
return new au(new Gt(c), a, u);
|
|
16127
16127
|
}
|
|
16128
16128
|
|
|
16129
16129
|
class _u extends ru {
|
|
16130
16130
|
_toFieldTransform(t) {
|
|
16131
|
-
if (2 /* MergeSet */ !== t
|
|
16131
|
+
if (2 /* MergeSet */ !== t.$c) throw 1 /* Update */ === t.$c ? t.qc(`${this._methodName}() can only appear at the top level of your update data`) : t.qc(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);
|
|
16132
16132
|
// No transform to add for a delete, but we need to add it to our
|
|
16133
16133
|
// fieldMask so it gets deleted.
|
|
16134
16134
|
return t.fieldMask.push(t.path), null;
|
|
@@ -16155,10 +16155,10 @@ class _u extends ru {
|
|
|
16155
16155
|
* @param arrayElement - Whether or not the FieldValue has an array.
|
|
16156
16156
|
*/ function mu(t, e, n) {
|
|
16157
16157
|
return new lu({
|
|
16158
|
-
|
|
16159
|
-
|
|
16158
|
+
$c: 3 /* Argument */ ,
|
|
16159
|
+
jc: e.settings.jc,
|
|
16160
16160
|
methodName: t._methodName,
|
|
16161
|
-
|
|
16161
|
+
Fc: n
|
|
16162
16162
|
}, e.databaseId, e.k, e.ignoreUndefinedProperties);
|
|
16163
16163
|
}
|
|
16164
16164
|
|
|
@@ -16173,11 +16173,11 @@ class gu extends ru {
|
|
|
16173
16173
|
|
|
16174
16174
|
class yu extends ru {
|
|
16175
16175
|
constructor(t, e) {
|
|
16176
|
-
super(t), this.
|
|
16176
|
+
super(t), this.Wc = e;
|
|
16177
16177
|
}
|
|
16178
16178
|
_toFieldTransform(t) {
|
|
16179
16179
|
const e = mu(this, t,
|
|
16180
|
-
/*array=*/ !0), n = this.
|
|
16180
|
+
/*array=*/ !0), n = this.Wc.map((t => Ru(t, e))), s = new Ke(n);
|
|
16181
16181
|
return new Je(t.path, s);
|
|
16182
16182
|
}
|
|
16183
16183
|
isEqual(t) {
|
|
@@ -16188,11 +16188,11 @@ class yu extends ru {
|
|
|
16188
16188
|
|
|
16189
16189
|
class pu extends ru {
|
|
16190
16190
|
constructor(t, e) {
|
|
16191
|
-
super(t), this.
|
|
16191
|
+
super(t), this.Wc = e;
|
|
16192
16192
|
}
|
|
16193
16193
|
_toFieldTransform(t) {
|
|
16194
16194
|
const e = mu(this, t,
|
|
16195
|
-
/*array=*/ !0), n = this.
|
|
16195
|
+
/*array=*/ !0), n = this.Wc.map((t => Ru(t, e))), s = new Qe(n);
|
|
16196
16196
|
return new Je(t.path, s);
|
|
16197
16197
|
}
|
|
16198
16198
|
isEqual(t) {
|
|
@@ -16203,10 +16203,10 @@ class pu extends ru {
|
|
|
16203
16203
|
|
|
16204
16204
|
class Tu extends ru {
|
|
16205
16205
|
constructor(t, e) {
|
|
16206
|
-
super(t), this.
|
|
16206
|
+
super(t), this.Gc = e;
|
|
16207
16207
|
}
|
|
16208
16208
|
_toFieldTransform(t) {
|
|
16209
|
-
const e = new Ge(t.k, Me(t.k, this.
|
|
16209
|
+
const e = new Ge(t.k, Me(t.k, this.Gc));
|
|
16210
16210
|
return new Je(t.path, e);
|
|
16211
16211
|
}
|
|
16212
16212
|
isEqual(t) {
|
|
@@ -16216,40 +16216,40 @@ class Tu extends ru {
|
|
|
16216
16216
|
}
|
|
16217
16217
|
|
|
16218
16218
|
/** Parse update data from an update() call. */ function Eu(t, e, n, s) {
|
|
16219
|
-
const i = t.
|
|
16219
|
+
const i = t.Qc(1 /* Update */ , e, n);
|
|
16220
16220
|
vu("Data must be an object, but it was:", i, s);
|
|
16221
16221
|
const r = [], o = Gt.empty();
|
|
16222
16222
|
ft(s, ((t, s) => {
|
|
16223
|
-
const
|
|
16223
|
+
const c = Du(e, t, n);
|
|
16224
16224
|
// For Compat types, we have to "extract" the underlying types before
|
|
16225
16225
|
// performing validation.
|
|
16226
16226
|
s = T(s);
|
|
16227
|
-
const
|
|
16227
|
+
const a = i.Bc(c);
|
|
16228
16228
|
if (s instanceof _u)
|
|
16229
16229
|
// Add it to the field mask, but don't add anything to updateData.
|
|
16230
|
-
r.push(
|
|
16231
|
-
const t = Ru(s,
|
|
16232
|
-
null != t && (r.push(
|
|
16230
|
+
r.push(c); else {
|
|
16231
|
+
const t = Ru(s, a);
|
|
16232
|
+
null != t && (r.push(c), o.set(c, t));
|
|
16233
16233
|
}
|
|
16234
16234
|
}));
|
|
16235
|
-
const
|
|
16236
|
-
return new uu(o,
|
|
16235
|
+
const c = new yt(r);
|
|
16236
|
+
return new uu(o, c, i.fieldTransforms);
|
|
16237
16237
|
}
|
|
16238
16238
|
|
|
16239
16239
|
/** Parse update data from a list of field/value arguments. */ function Iu(t, e, n, s, i, r) {
|
|
16240
|
-
const o = t.
|
|
16240
|
+
const o = t.Qc(1 /* Update */ , e, n), c = [ Vu(e, s, n) ], a = [ i ];
|
|
16241
16241
|
if (r.length % 2 != 0) throw new W(Q.INVALID_ARGUMENT, `Function ${e}() needs to be called with an even number of arguments that alternate between field names and values.`);
|
|
16242
|
-
for (let t = 0; t < r.length; t += 2)
|
|
16242
|
+
for (let t = 0; t < r.length; t += 2) c.push(Vu(e, r[t])), a.push(r[t + 1]);
|
|
16243
16243
|
const u = [], h = Gt.empty();
|
|
16244
16244
|
// We iterate in reverse order to pick the last value for a field if the
|
|
16245
16245
|
// user specified the field multiple times.
|
|
16246
|
-
for (let t =
|
|
16247
|
-
const e =
|
|
16248
|
-
let n =
|
|
16246
|
+
for (let t = c.length - 1; t >= 0; --t) if (!Nu(u, c[t])) {
|
|
16247
|
+
const e = c[t];
|
|
16248
|
+
let n = a[t];
|
|
16249
16249
|
// For Compat types, we have to "extract" the underlying types before
|
|
16250
16250
|
// performing validation.
|
|
16251
16251
|
n = T(n);
|
|
16252
|
-
const s = o.
|
|
16252
|
+
const s = o.Bc(e);
|
|
16253
16253
|
if (n instanceof _u)
|
|
16254
16254
|
// Add it to the field mask, but don't add anything to updateData.
|
|
16255
16255
|
u.push(e); else {
|
|
@@ -16268,7 +16268,7 @@ class Tu extends ru {
|
|
|
16268
16268
|
* @param allowArrays - Whether the query value is an array that may directly
|
|
16269
16269
|
* contain additional arrays (e.g. the operand of an `in` query).
|
|
16270
16270
|
*/ function Au(t, e, n, s = !1) {
|
|
16271
|
-
return Ru(n, t.
|
|
16271
|
+
return Ru(n, t.Qc(s ? 4 /* ArrayArgument */ : 3 /* Argument */ , e));
|
|
16272
16272
|
}
|
|
16273
16273
|
|
|
16274
16274
|
/**
|
|
@@ -16296,8 +16296,8 @@ class Tu extends ru {
|
|
|
16296
16296
|
*/
|
|
16297
16297
|
return function(t, e) {
|
|
16298
16298
|
// Sentinels are only supported with writes, and not within arrays.
|
|
16299
|
-
if (!hu(e
|
|
16300
|
-
if (!e.path) throw e.
|
|
16299
|
+
if (!hu(e.$c)) throw e.qc(`${t._methodName}() can only be used with update() and set()`);
|
|
16300
|
+
if (!e.path) throw e.qc(`${t._methodName}() is not currently supported inside arrays`);
|
|
16301
16301
|
const n = t._toFieldTransform(e);
|
|
16302
16302
|
n && e.fieldTransforms.push(n);
|
|
16303
16303
|
}
|
|
@@ -16321,12 +16321,12 @@ class Tu extends ru {
|
|
|
16321
16321
|
// the set of values to be included for the IN query) that may directly
|
|
16322
16322
|
// contain additional arrays (each representing an individual field
|
|
16323
16323
|
// value), so we disable this validation.
|
|
16324
|
-
if (e.settings.
|
|
16324
|
+
if (e.settings.Fc && 4 /* ArrayArgument */ !== e.$c) throw e.qc("Nested arrays are not supported");
|
|
16325
16325
|
return function(t, e) {
|
|
16326
16326
|
const n = [];
|
|
16327
16327
|
let s = 0;
|
|
16328
16328
|
for (const i of t) {
|
|
16329
|
-
let t = Ru(i, e.
|
|
16329
|
+
let t = Ru(i, e.Uc(s));
|
|
16330
16330
|
null == t && (
|
|
16331
16331
|
// Just include nulls in the array for fields being replaced with a
|
|
16332
16332
|
// sentinel.
|
|
@@ -16376,14 +16376,14 @@ class Tu extends ru {
|
|
|
16376
16376
|
if (t instanceof iu) return {
|
|
16377
16377
|
bytesValue: zn(e.k, t._byteString)
|
|
16378
16378
|
};
|
|
16379
|
-
if (t instanceof
|
|
16379
|
+
if (t instanceof Va) {
|
|
16380
16380
|
const n = e.databaseId, s = t.firestore._databaseId;
|
|
16381
|
-
if (!s.isEqual(n)) throw e.
|
|
16381
|
+
if (!s.isEqual(n)) throw e.qc(`Document reference is for database ${s.projectId}/${s.database} but should be for database ${n.projectId}/${n.database}`);
|
|
16382
16382
|
return {
|
|
16383
16383
|
referenceValue: Yn(t.firestore._databaseId || e.databaseId, t._key.path)
|
|
16384
16384
|
};
|
|
16385
16385
|
}
|
|
16386
|
-
throw e.
|
|
16386
|
+
throw e.qc(`Unsupported field value: ${Ia(t)}`);
|
|
16387
16387
|
}
|
|
16388
16388
|
/**
|
|
16389
16389
|
* Checks whether an object looks like a JSON object that should be converted
|
|
@@ -16400,7 +16400,7 @@ function bu(t, e) {
|
|
|
16400
16400
|
// If we encounter an empty object, we explicitly add it to the update
|
|
16401
16401
|
// mask to ensure that the server creates a map entry.
|
|
16402
16402
|
e.path && e.path.length > 0 && e.fieldMask.push(e.path) : ft(t, ((t, s) => {
|
|
16403
|
-
const i = Ru(s, e.
|
|
16403
|
+
const i = Ru(s, e.Mc(t));
|
|
16404
16404
|
null != i && (n[t] = i);
|
|
16405
16405
|
})), {
|
|
16406
16406
|
mapValue: {
|
|
@@ -16410,15 +16410,15 @@ function bu(t, e) {
|
|
|
16410
16410
|
}
|
|
16411
16411
|
|
|
16412
16412
|
function Pu(t) {
|
|
16413
|
-
return !("object" != typeof t || null === t || t instanceof Array || t instanceof Date || t instanceof ut || t instanceof ou || t instanceof iu || t instanceof
|
|
16413
|
+
return !("object" != typeof t || null === t || t instanceof Array || t instanceof Date || t instanceof ut || t instanceof ou || t instanceof iu || t instanceof Va || t instanceof ru);
|
|
16414
16414
|
}
|
|
16415
16415
|
|
|
16416
16416
|
function vu(t, e, n) {
|
|
16417
16417
|
if (!Pu(n) || !function(t) {
|
|
16418
16418
|
return "object" == typeof t && null !== t && (Object.getPrototypeOf(t) === Object.prototype || null === Object.getPrototypeOf(t));
|
|
16419
16419
|
}(n)) {
|
|
16420
|
-
const s =
|
|
16421
|
-
throw "an object" === s ? e.
|
|
16420
|
+
const s = Ia(n);
|
|
16421
|
+
throw "an object" === s ? e.qc(t + " a custom object") : e.qc(t + " " + s);
|
|
16422
16422
|
}
|
|
16423
16423
|
}
|
|
16424
16424
|
|
|
@@ -16462,11 +16462,11 @@ function vu(t, e, n) {
|
|
|
16462
16462
|
|
|
16463
16463
|
function Cu(t, e, n, s, i) {
|
|
16464
16464
|
const r = s && !s.isEmpty(), o = void 0 !== i;
|
|
16465
|
-
let
|
|
16466
|
-
n && (
|
|
16467
|
-
let
|
|
16468
|
-
return (r || o) && (
|
|
16469
|
-
|
|
16465
|
+
let c = `Function ${e}() called with invalid data`;
|
|
16466
|
+
n && (c += " (via `toFirestore()`)"), c += ". ";
|
|
16467
|
+
let a = "";
|
|
16468
|
+
return (r || o) && (a += " (found", r && (a += ` in field ${s}`), o && (a += ` in document ${i}`),
|
|
16469
|
+
a += ")"), new W(Q.INVALID_ARGUMENT, c + t + a);
|
|
16470
16470
|
}
|
|
16471
16471
|
|
|
16472
16472
|
/** Checks `haystack` if FieldPath `needle` is present. Runs in O(n). */ function Nu(t, e) {
|
|
@@ -16513,7 +16513,7 @@ function Cu(t, e, n, s, i) {
|
|
|
16513
16513
|
/**
|
|
16514
16514
|
* The `DocumentReference` for the document included in the `DocumentSnapshot`.
|
|
16515
16515
|
*/ get ref() {
|
|
16516
|
-
return new
|
|
16516
|
+
return new Va(this._firestore, this._converter, this._key);
|
|
16517
16517
|
}
|
|
16518
16518
|
/**
|
|
16519
16519
|
* Signals whether or not the document at the snapshot's location exists.
|
|
@@ -16821,7 +16821,7 @@ function Bu(t) {
|
|
|
16821
16821
|
* @param right - A snapshot to compare.
|
|
16822
16822
|
* @returns true if the snapshots are equal.
|
|
16823
16823
|
*/ function Uu(t, e) {
|
|
16824
|
-
return t instanceof Mu && e instanceof Mu ? t._firestore === e._firestore && t._key.isEqual(e._key) && (null === t._document ? null === e._document : t._document.isEqual(e._document)) && t._converter === e._converter : t instanceof Lu && e instanceof Lu && (t._firestore === e._firestore && $
|
|
16824
|
+
return t instanceof Mu && e instanceof Mu ? t._firestore === e._firestore && t._key.isEqual(e._key) && (null === t._document ? null === e._document : t._document.isEqual(e._document)) && t._converter === e._converter : t instanceof Lu && e instanceof Lu && (t._firestore === e._firestore && $a(t.query, e.query) && t.metadata.isEqual(e.metadata) && t._snapshot.isEqual(e._snapshot));
|
|
16825
16825
|
}
|
|
16826
16826
|
|
|
16827
16827
|
/**
|
|
@@ -16867,33 +16867,33 @@ function Bu(t) {
|
|
|
16867
16867
|
|
|
16868
16868
|
class Qu extends Ku {
|
|
16869
16869
|
constructor(t, e, n) {
|
|
16870
|
-
super(), this.
|
|
16870
|
+
super(), this.zc = t, this.Hc = e, this.Jc = n, this.type = "where";
|
|
16871
16871
|
}
|
|
16872
16872
|
_apply(t) {
|
|
16873
16873
|
const e = du(t.firestore), n = function(t, e, n, s, i, r, o) {
|
|
16874
|
-
let
|
|
16874
|
+
let c;
|
|
16875
16875
|
if (i.isKeyField()) {
|
|
16876
16876
|
if ("array-contains" /* ARRAY_CONTAINS */ === r || "array-contains-any" /* ARRAY_CONTAINS_ANY */ === r) throw new W(Q.INVALID_ARGUMENT, `Invalid Query. You can't perform '${r}' queries on documentId().`);
|
|
16877
16877
|
if ("in" /* IN */ === r || "not-in" /* NOT_IN */ === r) {
|
|
16878
16878
|
oh(o, r);
|
|
16879
16879
|
const e = [];
|
|
16880
16880
|
for (const n of o) e.push(rh(s, t, n));
|
|
16881
|
-
|
|
16881
|
+
c = {
|
|
16882
16882
|
arrayValue: {
|
|
16883
16883
|
values: e
|
|
16884
16884
|
}
|
|
16885
16885
|
};
|
|
16886
|
-
} else
|
|
16886
|
+
} else c = rh(s, t, o);
|
|
16887
16887
|
} else "in" /* IN */ !== r && "not-in" /* NOT_IN */ !== r && "array-contains-any" /* ARRAY_CONTAINS_ANY */ !== r || oh(o, r),
|
|
16888
|
-
|
|
16888
|
+
c = Au(n, e, o,
|
|
16889
16889
|
/* allowArrays= */ "in" /* IN */ === r || "not-in" /* NOT_IN */ === r);
|
|
16890
|
-
const
|
|
16890
|
+
const a = ne.create(i, r, c);
|
|
16891
16891
|
return function(t, e) {
|
|
16892
16892
|
if (e.V()) {
|
|
16893
16893
|
const n = Re(t);
|
|
16894
16894
|
if (null !== n && !n.isEqual(e.field)) throw new W(Q.INVALID_ARGUMENT, `Invalid query. All where filters with an inequality (<, <=, !=, not-in, >, or >=) must be on the same field. But you have inequality filters on '${n.toString()}' and '${e.field.toString()}'`);
|
|
16895
16895
|
const s = Ae(t);
|
|
16896
|
-
null !== s &&
|
|
16896
|
+
null !== s && ch(t, e.field, s);
|
|
16897
16897
|
}
|
|
16898
16898
|
const n = function(t, e) {
|
|
16899
16899
|
for (const n of t.filters) if (e.indexOf(n.op) >= 0) return n.op;
|
|
@@ -16935,9 +16935,9 @@ class Qu extends Ku {
|
|
|
16935
16935
|
if (null !== n)
|
|
16936
16936
|
// Special case when it's a duplicate op to give a slightly clearer error message.
|
|
16937
16937
|
throw n === e.op ? new W(Q.INVALID_ARGUMENT, `Invalid query. You cannot use more than one '${e.op.toString()}' filter.`) : new W(Q.INVALID_ARGUMENT, `Invalid query. You cannot use '${e.op.toString()}' filters with '${n.toString()}' filters.`);
|
|
16938
|
-
}(t,
|
|
16939
|
-
}(t._query, "where", e, t.firestore._databaseId, this.
|
|
16940
|
-
return new
|
|
16938
|
+
}(t, a), a;
|
|
16939
|
+
}(t._query, "where", e, t.firestore._databaseId, this.zc, this.Hc, this.Jc);
|
|
16940
|
+
return new Sa(t.firestore, t.converter, function(t, e) {
|
|
16941
16941
|
const n = t.filters.concat([ e ]);
|
|
16942
16942
|
return new ye(t.path, t.collectionGroup, t.explicitOrderBy.slice(), n, t.limit, t.limitType, t.startAt, t.endAt);
|
|
16943
16943
|
}(t._query, n));
|
|
@@ -16961,7 +16961,7 @@ class Qu extends Ku {
|
|
|
16961
16961
|
|
|
16962
16962
|
class Gu extends Ku {
|
|
16963
16963
|
constructor(t, e) {
|
|
16964
|
-
super(), this.
|
|
16964
|
+
super(), this.zc = t, this.Yc = e, this.type = "orderBy";
|
|
16965
16965
|
}
|
|
16966
16966
|
_apply(t) {
|
|
16967
16967
|
const e = function(t, e, n) {
|
|
@@ -16972,7 +16972,7 @@ class Gu extends Ku {
|
|
|
16972
16972
|
if (null === Ae(t)) {
|
|
16973
16973
|
// This is the first order by. It must match any inequality.
|
|
16974
16974
|
const n = Re(t);
|
|
16975
|
-
null !== n &&
|
|
16975
|
+
null !== n && ch(t, n, e.field);
|
|
16976
16976
|
}
|
|
16977
16977
|
}(t, s), s;
|
|
16978
16978
|
}
|
|
@@ -16986,8 +16986,8 @@ class Gu extends Ku {
|
|
|
16986
16986
|
* Will throw if the document does not contain all fields of the order by
|
|
16987
16987
|
* of the query or if any of the fields in the order by are an uncommitted
|
|
16988
16988
|
* server timestamp.
|
|
16989
|
-
*/ (t._query, this.
|
|
16990
|
-
return new
|
|
16989
|
+
*/ (t._query, this.zc, this.Yc);
|
|
16990
|
+
return new Sa(t.firestore, t.converter, function(t, e) {
|
|
16991
16991
|
// TODO(dimond): validate that orderBy does not list the same key twice.
|
|
16992
16992
|
const n = t.explicitOrderBy.concat([ e ]);
|
|
16993
16993
|
return new ye(t.path, t.collectionGroup, n, t.filters.slice(), t.limit, t.limitType, t.startAt, t.endAt);
|
|
@@ -17010,10 +17010,10 @@ class Gu extends Ku {
|
|
|
17010
17010
|
|
|
17011
17011
|
class Hu extends Ku {
|
|
17012
17012
|
constructor(t, e, n) {
|
|
17013
|
-
super(), this.type = t, this.
|
|
17013
|
+
super(), this.type = t, this.Xc = e, this.Zc = n;
|
|
17014
17014
|
}
|
|
17015
17015
|
_apply(t) {
|
|
17016
|
-
return new
|
|
17016
|
+
return new Sa(t.firestore, t.converter, Ve(t._query, this.Xc, this.Zc));
|
|
17017
17017
|
}
|
|
17018
17018
|
}
|
|
17019
17019
|
|
|
@@ -17023,7 +17023,7 @@ class Hu extends Ku {
|
|
|
17023
17023
|
* @param limit - The maximum number of items to return.
|
|
17024
17024
|
* @returns The created {@link Query}.
|
|
17025
17025
|
*/ function Ju(t) {
|
|
17026
|
-
return
|
|
17026
|
+
return Ra("limit", t), new Hu("limit", t, "F" /* First */);
|
|
17027
17027
|
}
|
|
17028
17028
|
|
|
17029
17029
|
/**
|
|
@@ -17035,16 +17035,16 @@ class Hu extends Ku {
|
|
|
17035
17035
|
* @param limit - The maximum number of items to return.
|
|
17036
17036
|
* @returns The created {@link Query}.
|
|
17037
17037
|
*/ function Yu(t) {
|
|
17038
|
-
return
|
|
17038
|
+
return Ra("limitToLast", t), new Hu("limitToLast", t, "L" /* Last */);
|
|
17039
17039
|
}
|
|
17040
17040
|
|
|
17041
17041
|
class Xu extends Ku {
|
|
17042
17042
|
constructor(t, e, n) {
|
|
17043
|
-
super(), this.type = t, this.
|
|
17043
|
+
super(), this.type = t, this.ta = e, this.ea = n;
|
|
17044
17044
|
}
|
|
17045
17045
|
_apply(t) {
|
|
17046
|
-
const e = ih(t, this.type, this.
|
|
17047
|
-
return new
|
|
17046
|
+
const e = ih(t, this.type, this.ta, this.ea);
|
|
17047
|
+
return new Sa(t.firestore, t.converter, function(t, e) {
|
|
17048
17048
|
return new ye(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), t.limit, t.limitType, e, t.endAt);
|
|
17049
17049
|
}(t._query, e));
|
|
17050
17050
|
}
|
|
@@ -17061,11 +17061,11 @@ function th(...t) {
|
|
|
17061
17061
|
|
|
17062
17062
|
class eh extends Ku {
|
|
17063
17063
|
constructor(t, e, n) {
|
|
17064
|
-
super(), this.type = t, this.
|
|
17064
|
+
super(), this.type = t, this.ta = e, this.ea = n;
|
|
17065
17065
|
}
|
|
17066
17066
|
_apply(t) {
|
|
17067
|
-
const e = ih(t, this.type, this.
|
|
17068
|
-
return new
|
|
17067
|
+
const e = ih(t, this.type, this.ta, this.ea);
|
|
17068
|
+
return new Sa(t.firestore, t.converter, function(t, e) {
|
|
17069
17069
|
return new ye(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), t.limit, t.limitType, t.startAt, e);
|
|
17070
17070
|
}(t._query, e));
|
|
17071
17071
|
}
|
|
@@ -17110,22 +17110,22 @@ function sh(...t) {
|
|
|
17110
17110
|
// Use explicit order by's because it has to match the query the user made
|
|
17111
17111
|
const o = t.explicitOrderBy;
|
|
17112
17112
|
if (i.length > o.length) throw new W(Q.INVALID_ARGUMENT, `Too many arguments provided to ${s}(). The number of arguments must be less than or equal to the number of orderBy() clauses`);
|
|
17113
|
-
const
|
|
17113
|
+
const c = [];
|
|
17114
17114
|
for (let r = 0; r < i.length; r++) {
|
|
17115
|
-
const
|
|
17115
|
+
const a = i[r];
|
|
17116
17116
|
if (o[r].field.isKeyField()) {
|
|
17117
|
-
if ("string" != typeof
|
|
17118
|
-
if (!be(t) && -1 !==
|
|
17119
|
-
const n = t.path.child(_t.fromString(
|
|
17117
|
+
if ("string" != typeof a) throw new W(Q.INVALID_ARGUMENT, `Invalid query. Expected a string for document ID in ${s}(), but got a ${typeof a}`);
|
|
17118
|
+
if (!be(t) && -1 !== a.indexOf("/")) throw new W(Q.INVALID_ARGUMENT, `Invalid query. When querying a collection and ordering by documentId(), the value passed to ${s}() must be a plain document ID, but '${a}' contains a slash.`);
|
|
17119
|
+
const n = t.path.child(_t.fromString(a));
|
|
17120
17120
|
if (!Nt.isDocumentKey(n)) throw new W(Q.INVALID_ARGUMENT, `Invalid query. When querying a collection group and ordering by documentId(), the value passed to ${s}() must result in a valid document path, but '${n}' is not because it contains an odd number of segments.`);
|
|
17121
17121
|
const i = new Nt(n);
|
|
17122
|
-
|
|
17122
|
+
c.push(Bt(e, i));
|
|
17123
17123
|
} else {
|
|
17124
|
-
const t = Au(n, s,
|
|
17125
|
-
|
|
17124
|
+
const t = Au(n, s, a);
|
|
17125
|
+
c.push(t);
|
|
17126
17126
|
}
|
|
17127
17127
|
}
|
|
17128
|
-
return new fe(
|
|
17128
|
+
return new fe(c, r);
|
|
17129
17129
|
}
|
|
17130
17130
|
/**
|
|
17131
17131
|
* Parses the given `documentIdValue` into a `ReferenceValue`, throwing
|
|
@@ -17143,8 +17143,8 @@ function rh(t, e, n) {
|
|
|
17143
17143
|
if (!Nt.isDocumentKey(s)) throw new W(Q.INVALID_ARGUMENT, `Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${s}' is not because it has an odd number of segments (${s.length}).`);
|
|
17144
17144
|
return Bt(t, new Nt(s));
|
|
17145
17145
|
}
|
|
17146
|
-
if (n instanceof
|
|
17147
|
-
throw new W(Q.INVALID_ARGUMENT, `Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${
|
|
17146
|
+
if (n instanceof Va) return Bt(t, n._key);
|
|
17147
|
+
throw new W(Q.INVALID_ARGUMENT, `Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${Ia(n)}.`);
|
|
17148
17148
|
}
|
|
17149
17149
|
|
|
17150
17150
|
/**
|
|
@@ -17155,7 +17155,7 @@ function rh(t, e, n) {
|
|
|
17155
17155
|
if (t.length > 10) throw new W(Q.INVALID_ARGUMENT, `Invalid Query. '${e.toString()}' filters support a maximum of 10 elements in the value array.`);
|
|
17156
17156
|
}
|
|
17157
17157
|
|
|
17158
|
-
function
|
|
17158
|
+
function ch(t, e, n) {
|
|
17159
17159
|
if (!n.isEqual(e)) throw new W(Q.INVALID_ARGUMENT, `Invalid query. You have a where filter with an inequality (<, <=, !=, not-in, >, or >=) on field '${e.toString()}' and so you must also use '${e.toString()}' as your first argument to orderBy(), but your first orderBy() is on field '${n.toString()}' instead.`);
|
|
17160
17160
|
}
|
|
17161
17161
|
|
|
@@ -17180,7 +17180,7 @@ function ah(t, e, n) {
|
|
|
17180
17180
|
* to the user.
|
|
17181
17181
|
*
|
|
17182
17182
|
* @internal
|
|
17183
|
-
*/ class
|
|
17183
|
+
*/ class ah {
|
|
17184
17184
|
convertValue(t, e = "none") {
|
|
17185
17185
|
switch (kt(t)) {
|
|
17186
17186
|
case 0 /* NullValue */ :
|
|
@@ -17252,7 +17252,7 @@ function ah(t, e, n) {
|
|
|
17252
17252
|
convertDocumentKey(t, e) {
|
|
17253
17253
|
const n = _t.fromString(t);
|
|
17254
17254
|
q(Ps(n));
|
|
17255
|
-
const s = new
|
|
17255
|
+
const s = new ma(n.get(1), n.get(3)), i = new Nt(n.popFirst(5));
|
|
17256
17256
|
return s.isEqual(e) ||
|
|
17257
17257
|
// TODO(b/64130202): Somehow support foreign references.
|
|
17258
17258
|
F(`Document ${i} contains a document reference within a different database (${s.projectId}/${s.database}) which is not supported. It will be treated as a reference in the current database (${e.projectId}/${e.database}) instead.`),
|
|
@@ -17293,7 +17293,7 @@ function ah(t, e, n) {
|
|
|
17293
17293
|
s;
|
|
17294
17294
|
}
|
|
17295
17295
|
|
|
17296
|
-
class hh extends
|
|
17296
|
+
class hh extends ah {
|
|
17297
17297
|
constructor(t) {
|
|
17298
17298
|
super(), this.firestore = t;
|
|
17299
17299
|
}
|
|
@@ -17302,7 +17302,7 @@ class hh extends ch {
|
|
|
17302
17302
|
}
|
|
17303
17303
|
convertReference(t) {
|
|
17304
17304
|
const e = this.convertDocumentKey(t, this.firestore._databaseId);
|
|
17305
|
-
return new
|
|
17305
|
+
return new Va(this.firestore, /* converter= */ null, e);
|
|
17306
17306
|
}
|
|
17307
17307
|
}
|
|
17308
17308
|
|
|
@@ -17437,12 +17437,12 @@ function fh(t, e) {
|
|
|
17437
17437
|
* current document contents.
|
|
17438
17438
|
*/
|
|
17439
17439
|
function dh(t) {
|
|
17440
|
-
t =
|
|
17441
|
-
const e =
|
|
17442
|
-
return
|
|
17440
|
+
t = Aa(t, Va);
|
|
17441
|
+
const e = Aa(t.firestore, Ba);
|
|
17442
|
+
return aa(Ka(e), t._key).then((n => vh(e, t, n)));
|
|
17443
17443
|
}
|
|
17444
17444
|
|
|
17445
|
-
class wh extends
|
|
17445
|
+
class wh extends ah {
|
|
17446
17446
|
constructor(t) {
|
|
17447
17447
|
super(), this.firestore = t;
|
|
17448
17448
|
}
|
|
@@ -17451,7 +17451,7 @@ class wh extends ch {
|
|
|
17451
17451
|
}
|
|
17452
17452
|
convertReference(t) {
|
|
17453
17453
|
const e = this.convertDocumentKey(t, this.firestore._databaseId);
|
|
17454
|
-
return new
|
|
17454
|
+
return new Va(this.firestore, /* converter= */ null, e);
|
|
17455
17455
|
}
|
|
17456
17456
|
}
|
|
17457
17457
|
|
|
@@ -17462,9 +17462,9 @@ class wh extends ch {
|
|
|
17462
17462
|
* @returns A `Promise` resolved with a `DocumentSnapshot` containing the
|
|
17463
17463
|
* current document contents.
|
|
17464
17464
|
*/ function _h(t) {
|
|
17465
|
-
t =
|
|
17466
|
-
const e =
|
|
17467
|
-
return
|
|
17465
|
+
t = Aa(t, Va);
|
|
17466
|
+
const e = Aa(t.firestore, Ba), n = Ka(e), s = new wh(e);
|
|
17467
|
+
return ca(n, t._key).then((n => new Mu(e, s, t._key, n, new Ou(null !== n && n.hasLocalMutations,
|
|
17468
17468
|
/* fromCache= */ !0), t.converter)));
|
|
17469
17469
|
}
|
|
17470
17470
|
|
|
@@ -17475,9 +17475,9 @@ class wh extends ch {
|
|
|
17475
17475
|
* @returns A `Promise` resolved with a `DocumentSnapshot` containing the
|
|
17476
17476
|
* current document contents.
|
|
17477
17477
|
*/ function mh(t) {
|
|
17478
|
-
t =
|
|
17479
|
-
const e =
|
|
17480
|
-
return
|
|
17478
|
+
t = Aa(t, Va);
|
|
17479
|
+
const e = Aa(t.firestore, Ba);
|
|
17480
|
+
return aa(Ka(e), t._key, {
|
|
17481
17481
|
source: "server"
|
|
17482
17482
|
}).then((n => vh(e, t, n)));
|
|
17483
17483
|
}
|
|
@@ -17492,9 +17492,9 @@ class wh extends ch {
|
|
|
17492
17492
|
*
|
|
17493
17493
|
* @returns A `Promise` that will be resolved with the results of the query.
|
|
17494
17494
|
*/ function gh(t) {
|
|
17495
|
-
t =
|
|
17496
|
-
const e =
|
|
17497
|
-
return qu(t._query),
|
|
17495
|
+
t = Aa(t, Sa);
|
|
17496
|
+
const e = Aa(t.firestore, Ba), n = Ka(e), s = new wh(e);
|
|
17497
|
+
return qu(t._query), ha(n, t._query).then((n => new Lu(e, s, t, n)));
|
|
17498
17498
|
}
|
|
17499
17499
|
|
|
17500
17500
|
/**
|
|
@@ -17503,9 +17503,9 @@ class wh extends ch {
|
|
|
17503
17503
|
*
|
|
17504
17504
|
* @returns A `Promise` that will be resolved with the results of the query.
|
|
17505
17505
|
*/ function yh(t) {
|
|
17506
|
-
t =
|
|
17507
|
-
const e =
|
|
17508
|
-
return
|
|
17506
|
+
t = Aa(t, Sa);
|
|
17507
|
+
const e = Aa(t.firestore, Ba), n = Ka(e), s = new wh(e);
|
|
17508
|
+
return ua(n, t._query).then((n => new Lu(e, s, t, n)));
|
|
17509
17509
|
}
|
|
17510
17510
|
|
|
17511
17511
|
/**
|
|
@@ -17514,22 +17514,22 @@ class wh extends ch {
|
|
|
17514
17514
|
*
|
|
17515
17515
|
* @returns A `Promise` that will be resolved with the results of the query.
|
|
17516
17516
|
*/ function ph(t) {
|
|
17517
|
-
t =
|
|
17518
|
-
const e =
|
|
17519
|
-
return
|
|
17517
|
+
t = Aa(t, Sa);
|
|
17518
|
+
const e = Aa(t.firestore, Ba), n = Ka(e), s = new wh(e);
|
|
17519
|
+
return ha(n, t._query, {
|
|
17520
17520
|
source: "server"
|
|
17521
17521
|
}).then((n => new Lu(e, s, t, n)));
|
|
17522
17522
|
}
|
|
17523
17523
|
|
|
17524
17524
|
function Th(t, e, n) {
|
|
17525
|
-
t =
|
|
17526
|
-
const s =
|
|
17525
|
+
t = Aa(t, Va);
|
|
17526
|
+
const s = Aa(t.firestore, Ba), i = uh(t.converter, e, n);
|
|
17527
17527
|
return Ph(s, [ wu(du(s), "setDoc", t._key, i, null !== t.converter, n).toMutation(t._key, Ze.none()) ]);
|
|
17528
17528
|
}
|
|
17529
17529
|
|
|
17530
17530
|
function Eh(t, e, n, ...s) {
|
|
17531
|
-
t =
|
|
17532
|
-
const i =
|
|
17531
|
+
t = Aa(t, Va);
|
|
17532
|
+
const i = Aa(t.firestore, Ba), r = du(i);
|
|
17533
17533
|
let o;
|
|
17534
17534
|
o = "string" == typeof (
|
|
17535
17535
|
// For Compat types, we have to "extract" the underlying types before
|
|
@@ -17545,7 +17545,7 @@ function Eh(t, e, n, ...s) {
|
|
|
17545
17545
|
* @returns A Promise resolved once the document has been successfully
|
|
17546
17546
|
* deleted from the backend (note that it won't resolve while you're offline).
|
|
17547
17547
|
*/ function Ih(t) {
|
|
17548
|
-
return Ph(
|
|
17548
|
+
return Ph(Aa(t.firestore, Ba), [ new dn(t._key, Ze.none()) ]);
|
|
17549
17549
|
}
|
|
17550
17550
|
|
|
17551
17551
|
/**
|
|
@@ -17558,7 +17558,7 @@ function Eh(t, e, n, ...s) {
|
|
|
17558
17558
|
* newly created document after it has been written to the backend (Note that it
|
|
17559
17559
|
* won't resolve while you're offline).
|
|
17560
17560
|
*/ function Ah(t, e) {
|
|
17561
|
-
const n =
|
|
17561
|
+
const n = Aa(t.firestore, Ba), s = ka(t), i = uh(t.converter, e);
|
|
17562
17562
|
return Ph(n, [ wu(du(t.firestore), "addDoc", s._key, i, null !== t.converter, {}).toMutation(s._key, Ze.exists(!1)) ]).then((() => s));
|
|
17563
17563
|
}
|
|
17564
17564
|
|
|
@@ -17568,27 +17568,27 @@ function Rh(t, ...e) {
|
|
|
17568
17568
|
let r = {
|
|
17569
17569
|
includeMetadataChanges: !1
|
|
17570
17570
|
}, o = 0;
|
|
17571
|
-
"object" != typeof e[o] ||
|
|
17572
|
-
const
|
|
17571
|
+
"object" != typeof e[o] || Ma(e[o]) || (r = e[o], o++);
|
|
17572
|
+
const c = {
|
|
17573
17573
|
includeMetadataChanges: r.includeMetadataChanges
|
|
17574
17574
|
};
|
|
17575
|
-
if (
|
|
17575
|
+
if (Ma(e[o])) {
|
|
17576
17576
|
const t = e[o];
|
|
17577
17577
|
e[o] = null === (n = t.next) || void 0 === n ? void 0 : n.bind(t), e[o + 1] = null === (s = t.error) || void 0 === s ? void 0 : s.bind(t),
|
|
17578
17578
|
e[o + 2] = null === (i = t.complete) || void 0 === i ? void 0 : i.bind(t);
|
|
17579
17579
|
}
|
|
17580
|
-
let
|
|
17581
|
-
if (t instanceof
|
|
17580
|
+
let a, u, h;
|
|
17581
|
+
if (t instanceof Va) u = Aa(t.firestore, Ba), h = Te(t._key.path), a = {
|
|
17582
17582
|
next: n => {
|
|
17583
17583
|
e[o] && e[o](vh(u, t, n));
|
|
17584
17584
|
},
|
|
17585
17585
|
error: e[o + 1],
|
|
17586
17586
|
complete: e[o + 2]
|
|
17587
17587
|
}; else {
|
|
17588
|
-
const n =
|
|
17589
|
-
u =
|
|
17588
|
+
const n = Aa(t, Sa);
|
|
17589
|
+
u = Aa(n.firestore, Ba), h = n._query;
|
|
17590
17590
|
const s = new wh(u);
|
|
17591
|
-
|
|
17591
|
+
a = {
|
|
17592
17592
|
next: t => {
|
|
17593
17593
|
e[o] && e[o](new Lu(u, s, n, t));
|
|
17594
17594
|
},
|
|
@@ -17597,15 +17597,15 @@ function Rh(t, ...e) {
|
|
|
17597
17597
|
}, qu(t._query);
|
|
17598
17598
|
}
|
|
17599
17599
|
return function(t, e, n, s) {
|
|
17600
|
-
const i = new
|
|
17601
|
-
return t.asyncQueue.enqueueAndForget((async () => Wo(await
|
|
17602
|
-
i.
|
|
17600
|
+
const i = new Qc(s), r = new Yo(e, i, n);
|
|
17601
|
+
return t.asyncQueue.enqueueAndForget((async () => Wo(await ia(t), r))), () => {
|
|
17602
|
+
i.nc(), t.asyncQueue.enqueueAndForget((async () => Go(await ia(t), r)));
|
|
17603
17603
|
};
|
|
17604
|
-
}(
|
|
17604
|
+
}(Ka(u), h, c, a);
|
|
17605
17605
|
}
|
|
17606
17606
|
|
|
17607
17607
|
function bh(t, e) {
|
|
17608
|
-
return
|
|
17608
|
+
return la(Ka(t = Aa(t, Ba)), Ma(e) ? e : {
|
|
17609
17609
|
next: e
|
|
17610
17610
|
});
|
|
17611
17611
|
}
|
|
@@ -17616,8 +17616,8 @@ function bh(t, e) {
|
|
|
17616
17616
|
*/ function Ph(t, e) {
|
|
17617
17617
|
return function(t, e) {
|
|
17618
17618
|
const n = new G;
|
|
17619
|
-
return t.asyncQueue.enqueueAndForget((async () =>
|
|
17620
|
-
}(
|
|
17619
|
+
return t.asyncQueue.enqueueAndForget((async () => lc(await sa(t), e, n))), n.promise;
|
|
17620
|
+
}(Ka(t), e);
|
|
17621
17621
|
}
|
|
17622
17622
|
|
|
17623
17623
|
/**
|
|
@@ -17728,7 +17728,7 @@ function bh(t, e) {
|
|
|
17728
17728
|
* `updateFunction `is returned here. Otherwise, if the transaction failed, a
|
|
17729
17729
|
* rejected promise with the corresponding failure error is returned.
|
|
17730
17730
|
*/ function Sh(t, e) {
|
|
17731
|
-
return
|
|
17731
|
+
return fa(Ka(t = Aa(t, Ba)), (n => e(new Vh(t, n))));
|
|
17732
17732
|
}
|
|
17733
17733
|
|
|
17734
17734
|
/**
|
|
@@ -17843,7 +17843,7 @@ function bh(t, e) {
|
|
|
17843
17843
|
* @returns A {@link WriteBatch} that can be used to atomically execute multiple
|
|
17844
17844
|
* writes.
|
|
17845
17845
|
*/ function $h(t) {
|
|
17846
|
-
return
|
|
17846
|
+
return Ka(t = Aa(t, Ba)), new lh(t, (e => Ph(t, e)));
|
|
17847
17847
|
}
|
|
17848
17848
|
|
|
17849
17849
|
/**
|
|
@@ -17865,14 +17865,14 @@ function bh(t, e) {
|
|
|
17865
17865
|
!function(t) {
|
|
17866
17866
|
k = t;
|
|
17867
17867
|
}(i), n(new r("firestore", ((t, {options: n}) => {
|
|
17868
|
-
const s = t.getProvider("app").getImmediate(), i = new
|
|
17868
|
+
const s = t.getProvider("app").getImmediate(), i = new Ba(s, new Y(t.getProvider("auth-internal")), new et(t.getProvider("app-check-internal")));
|
|
17869
17869
|
return n = Object.assign({
|
|
17870
17870
|
useFetchStreams: e
|
|
17871
17871
|
}, n), i._setSettings(n), i;
|
|
17872
|
-
}), "PUBLIC")), s(C, "3.4.3-canary.
|
|
17872
|
+
}), "PUBLIC")), s(C, "3.4.3-canary.67b6decbb", t),
|
|
17873
17873
|
// BUILD_TARGET will be replaced by values like esm5, esm2017, cjs5, etc during the compilation
|
|
17874
|
-
s(C, "3.4.3-canary.
|
|
17874
|
+
s(C, "3.4.3-canary.67b6decbb", "esm2017");
|
|
17875
17875
|
}("rn", /* useFetchStreams= */ !1);
|
|
17876
17876
|
|
|
17877
|
-
export {
|
|
17877
|
+
export { ah as AbstractUserDataWriter, iu as Bytes, La as CACHE_SIZE_UNLIMITED, Da as CollectionReference, Va as DocumentReference, Mu as DocumentSnapshot, nu as FieldPath, ru as FieldValue, Ba as Firestore, W as FirestoreError, ou as GeoPoint, Fa as LoadBundleTask, Sa as Query, Ku as QueryConstraint, Fu as QueryDocumentSnapshot, Lu as QuerySnapshot, Ou as SnapshotMetadata, ut as Timestamp, Vh as Transaction, lh as WriteBatch, ma as _DatabaseId, Nt as _DocumentKey, nt as _EmptyAppCheckTokenProvider, H as _EmptyAuthCredentialsProvider, gt as _FieldPath, Aa as _cast, K as _debugAssert, Tt as _isBase64Available, L as _logWarn, pa as _validateIsNotUsedTogether, Ah as addDoc, kh as arrayRemove, Nh as arrayUnion, za as clearIndexedDbPersistence, Ca as collection, Na as collectionGroup, va as connectFirestoreEmulator, Ih as deleteDoc, Dh as deleteField, Ya as disableNetwork, ka as doc, su as documentId, Qa as enableIndexedDbPersistence, Wa as enableMultiTabIndexedDbPersistence, Ja as enableNetwork, sh as endAt, nh as endBefore, Ka as ensureFirestoreConfigured, Ph as executeWrite, dh as getDoc, _h as getDocFromCache, mh as getDocFromServer, gh as getDocs, yh as getDocsFromCache, ph as getDocsFromServer, qa as getFirestore, xh as increment, Ua as initializeFirestore, Ju as limit, Yu as limitToLast, Za as loadBundle, tu as namedQuery, Rh as onSnapshot, bh as onSnapshotsInSync, zu as orderBy, ju as query, $a as queryEqual, xa as refEqual, Sh as runTransaction, Ch as serverTimestamp, Th as setDoc, O as setLogLevel, Uu as snapshotEqual, th as startAfter, Zu as startAt, Xa as terminate, Eh as updateDoc, Ha as waitForPendingWrites, Wu as where, $h as writeBatch };
|
|
17878
17878
|
//# sourceMappingURL=index.rn.js.map
|