@firebase/firestore 3.7.1 → 3.7.2-canary.457fc2eeb
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/CHANGELOG.md +12 -0
- package/dist/index.esm2017.js +249 -243
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +637 -633
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +38 -36
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +5 -3
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +249 -243
- package/dist/index.rn.js.map +1 -1
- package/dist/lite/index.browser.esm2017.js +186 -180
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.browser.esm5.js +350 -344
- package/dist/lite/index.browser.esm5.js.map +1 -1
- package/dist/lite/index.node.cjs.js +10 -3
- package/dist/lite/index.node.cjs.js.map +1 -1
- package/dist/lite/index.node.mjs +10 -3
- package/dist/lite/index.node.mjs.map +1 -1
- package/dist/lite/index.rn.esm2017.js +192 -186
- package/dist/lite/index.rn.esm2017.js.map +1 -1
- package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +26 -26
- package/dist/packages/firestore/dist/index.esm2017.d.ts +1 -1
- package/package.json +11 -11
- package/dist/firestore/test/integration/api_internal/aggregation.test.d.ts +0 -17
- package/dist/lite/firestore/test/integration/api_internal/aggregation.test.d.ts +0 -17
- package/dist/lite/packages/firestore/test/integration/api_internal/aggregation.test.d.ts +0 -17
- package/dist/packages/firestore/test/integration/api_internal/aggregation.test.d.ts +0 -17
package/dist/index.rn.js
CHANGED
|
@@ -70,7 +70,7 @@ v.MOCK_USER = new v("mock-user");
|
|
|
70
70
|
* See the License for the specific language governing permissions and
|
|
71
71
|
* limitations under the License.
|
|
72
72
|
*/
|
|
73
|
-
let V = "9.
|
|
73
|
+
let V = "9.13.0-canary.457fc2eeb";
|
|
74
74
|
|
|
75
75
|
/**
|
|
76
76
|
* @license
|
|
@@ -12537,11 +12537,12 @@ class {
|
|
|
12537
12537
|
return new Promise(((i, r) => {
|
|
12538
12538
|
const o = new g;
|
|
12539
12539
|
o.setWithCredentials(!0), o.listenOnce(y.COMPLETE, (() => {
|
|
12540
|
+
var e;
|
|
12540
12541
|
try {
|
|
12541
12542
|
switch (o.getLastErrorCode()) {
|
|
12542
12543
|
case p.NO_ERROR:
|
|
12543
|
-
const
|
|
12544
|
-
x("Connection", "XHR received:", JSON.stringify(
|
|
12544
|
+
const n = o.getResponseJson();
|
|
12545
|
+
x("Connection", "XHR received:", JSON.stringify(n)), i(n);
|
|
12545
12546
|
break;
|
|
12546
12547
|
|
|
12547
12548
|
case p.TIMEOUT:
|
|
@@ -12549,16 +12550,18 @@ class {
|
|
|
12549
12550
|
break;
|
|
12550
12551
|
|
|
12551
12552
|
case p.HTTP_ERROR:
|
|
12552
|
-
const
|
|
12553
|
-
if (x("Connection", 'RPC "' + t + '" failed with status:',
|
|
12554
|
-
|
|
12555
|
-
|
|
12556
|
-
|
|
12557
|
-
|
|
12553
|
+
const s = o.getStatus();
|
|
12554
|
+
if (x("Connection", 'RPC "' + t + '" failed with status:', s, "response text:", o.getResponseText()),
|
|
12555
|
+
s > 0) {
|
|
12556
|
+
let t = o.getResponseJson();
|
|
12557
|
+
Array.isArray(t) && (t = t[0]);
|
|
12558
|
+
const n = null === (e = t) || void 0 === e ? void 0 : e.error;
|
|
12559
|
+
if (n && n.status && n.message) {
|
|
12560
|
+
const t = function(t) {
|
|
12558
12561
|
const e = t.toLowerCase().replace(/_/g, "-");
|
|
12559
12562
|
return Object.values(L).indexOf(e) >= 0 ? e : L.UNKNOWN;
|
|
12560
|
-
}(
|
|
12561
|
-
r(new U(
|
|
12563
|
+
}(n.status);
|
|
12564
|
+
r(new U(t, n.message));
|
|
12562
12565
|
} else r(new U(L.UNKNOWN, "Server responded with status " + o.getStatus()));
|
|
12563
12566
|
} else
|
|
12564
12567
|
// If we received an HTTP_ERROR but there's no status code,
|
|
@@ -12900,14 +12903,14 @@ class nu {
|
|
|
12900
12903
|
*/
|
|
12901
12904
|
class su {
|
|
12902
12905
|
constructor(t, e, n, s, i, r, o, u) {
|
|
12903
|
-
this.Hs = t, this.vo = n, this.Vo = s, this.
|
|
12906
|
+
this.Hs = t, this.vo = n, this.Vo = s, this.connection = i, this.authCredentialsProvider = r,
|
|
12904
12907
|
this.appCheckCredentialsProvider = o, this.listener = u, this.state = 0 /* Initial */ ,
|
|
12905
12908
|
/**
|
|
12906
12909
|
* A close count that's incremented every time the stream is closed; used by
|
|
12907
12910
|
* getCloseGuardedDispatcher() to invalidate callbacks that happen after
|
|
12908
12911
|
* close.
|
|
12909
12912
|
*/
|
|
12910
|
-
this.
|
|
12913
|
+
this.So = 0, this.Do = null, this.Co = null, this.stream = null, this.xo = new nu(t, e);
|
|
12911
12914
|
}
|
|
12912
12915
|
/**
|
|
12913
12916
|
* Returns true if start() has been called and no error has occurred. True
|
|
@@ -12915,13 +12918,13 @@ class su {
|
|
|
12915
12918
|
* encompasses respecting backoff, getting auth tokens, and starting the
|
|
12916
12919
|
* actual RPC). Use isOpen() to determine if the stream is open and ready for
|
|
12917
12920
|
* outbound requests.
|
|
12918
|
-
*/
|
|
12919
|
-
return 1 /* Starting */ === this.state || 5 /* Backoff */ === this.state || this.
|
|
12921
|
+
*/ No() {
|
|
12922
|
+
return 1 /* Starting */ === this.state || 5 /* Backoff */ === this.state || this.ko();
|
|
12920
12923
|
}
|
|
12921
12924
|
/**
|
|
12922
12925
|
* Returns true if the underlying RPC is open (the onOpen() listener has been
|
|
12923
12926
|
* called) and the stream is ready for outbound requests.
|
|
12924
|
-
*/
|
|
12927
|
+
*/ ko() {
|
|
12925
12928
|
return 2 /* Open */ === this.state || 3 /* Healthy */ === this.state;
|
|
12926
12929
|
}
|
|
12927
12930
|
/**
|
|
@@ -12931,7 +12934,7 @@ class su {
|
|
|
12931
12934
|
*
|
|
12932
12935
|
* When start returns, isStarted() will return true.
|
|
12933
12936
|
*/ start() {
|
|
12934
|
-
4 /* Error */ !== this.state ? this.auth() : this.
|
|
12937
|
+
4 /* Error */ !== this.state ? this.auth() : this.Oo();
|
|
12935
12938
|
}
|
|
12936
12939
|
/**
|
|
12937
12940
|
* Stops the RPC. This call is idempotent and allowed regardless of the
|
|
@@ -12939,7 +12942,7 @@ class su {
|
|
|
12939
12942
|
*
|
|
12940
12943
|
* When stop returns, isStarted() and isOpen() will both return false.
|
|
12941
12944
|
*/ async stop() {
|
|
12942
|
-
this.
|
|
12945
|
+
this.No() && await this.close(0 /* Initial */);
|
|
12943
12946
|
}
|
|
12944
12947
|
/**
|
|
12945
12948
|
* After an error the stream will usually back off on the next attempt to
|
|
@@ -12948,8 +12951,8 @@ class su {
|
|
|
12948
12951
|
*
|
|
12949
12952
|
* Each error will call the onClose() listener. That function can decide to
|
|
12950
12953
|
* inhibit backoff if required.
|
|
12951
|
-
*/
|
|
12952
|
-
this.state = 0 /* Initial */ , this.
|
|
12954
|
+
*/ Mo() {
|
|
12955
|
+
this.state = 0 /* Initial */ , this.xo.reset();
|
|
12953
12956
|
}
|
|
12954
12957
|
/**
|
|
12955
12958
|
* Marks this stream as idle. If no further actions are performed on the
|
|
@@ -12960,25 +12963,25 @@ class su {
|
|
|
12960
12963
|
*
|
|
12961
12964
|
* Only streams that are in state 'Open' can be marked idle, as all other
|
|
12962
12965
|
* states imply pending network operations.
|
|
12963
|
-
*/
|
|
12966
|
+
*/ Fo() {
|
|
12964
12967
|
// Starts the idle time if we are in state 'Open' and are not yet already
|
|
12965
12968
|
// running a timer (in which case the previous idle timeout still applies).
|
|
12966
|
-
this.
|
|
12969
|
+
this.ko() && null === this.Do && (this.Do = this.Hs.enqueueAfterDelay(this.vo, 6e4, (() => this.$o())));
|
|
12967
12970
|
}
|
|
12968
|
-
/** Sends a message to the underlying stream. */
|
|
12969
|
-
this.
|
|
12971
|
+
/** Sends a message to the underlying stream. */ Bo(t) {
|
|
12972
|
+
this.Lo(), this.stream.send(t);
|
|
12970
12973
|
}
|
|
12971
|
-
/** Called by the idle timer when the stream should close due to inactivity. */ async
|
|
12972
|
-
if (this.
|
|
12974
|
+
/** Called by the idle timer when the stream should close due to inactivity. */ async $o() {
|
|
12975
|
+
if (this.ko())
|
|
12973
12976
|
// When timing out an idle stream there's no reason to force the stream into backoff when
|
|
12974
12977
|
// it restarts so set the stream state to Initial instead of Error.
|
|
12975
12978
|
return this.close(0 /* Initial */);
|
|
12976
12979
|
}
|
|
12977
|
-
/** Marks the stream as active again. */
|
|
12978
|
-
this.
|
|
12980
|
+
/** Marks the stream as active again. */ Lo() {
|
|
12981
|
+
this.Do && (this.Do.cancel(), this.Do = null);
|
|
12979
12982
|
}
|
|
12980
|
-
/** Cancels the health check delayed operation. */
|
|
12981
|
-
this.
|
|
12983
|
+
/** Cancels the health check delayed operation. */ Uo() {
|
|
12984
|
+
this.Co && (this.Co.cancel(), this.Co = null);
|
|
12982
12985
|
}
|
|
12983
12986
|
/**
|
|
12984
12987
|
* Closes the stream and cleans up as necessary:
|
|
@@ -12994,15 +12997,15 @@ class su {
|
|
|
12994
12997
|
* @param error - the error the connection was closed with.
|
|
12995
12998
|
*/ async close(t, e) {
|
|
12996
12999
|
// Cancel any outstanding timers (they're guaranteed not to execute).
|
|
12997
|
-
this.
|
|
13000
|
+
this.Lo(), this.Uo(), this.xo.cancel(),
|
|
12998
13001
|
// Invalidates any stream-related callbacks (e.g. from auth or the
|
|
12999
13002
|
// underlying stream), guaranteeing they won't execute.
|
|
13000
|
-
this.
|
|
13003
|
+
this.So++, 4 /* Error */ !== t ?
|
|
13001
13004
|
// If this is an intentional close ensure we don't delay our next connection attempt.
|
|
13002
|
-
this.
|
|
13005
|
+
this.xo.reset() : e && e.code === L.RESOURCE_EXHAUSTED ? (
|
|
13003
13006
|
// Log the error. (Probably either 'quota exceeded' or 'max queue length reached'.)
|
|
13004
13007
|
N(e.toString()), N("Using maximum backoff delay to prevent overloading the backend."),
|
|
13005
|
-
this.
|
|
13008
|
+
this.xo.Ao()) : e && e.code === L.UNAUTHENTICATED && 3 /* Healthy */ !== this.state && (
|
|
13006
13009
|
// "unauthenticated" error means the token was rejected. This should rarely
|
|
13007
13010
|
// happen since both Auth and AppCheck ensure a sufficient TTL when we
|
|
13008
13011
|
// request a token. If a user manually resets their system clock this can
|
|
@@ -13011,7 +13014,7 @@ class su {
|
|
|
13011
13014
|
// to ensure that we fetch a new token.
|
|
13012
13015
|
this.authCredentialsProvider.invalidateToken(), this.appCheckCredentialsProvider.invalidateToken()),
|
|
13013
13016
|
// Clean up the underlying stream because we are no longer interested in events.
|
|
13014
|
-
null !== this.stream && (this.
|
|
13017
|
+
null !== this.stream && (this.qo(), this.stream.close(), this.stream = null),
|
|
13015
13018
|
// This state must be assigned before calling onClose() to allow the callback to
|
|
13016
13019
|
// inhibit backoff or otherwise manipulate the state in its non-started state.
|
|
13017
13020
|
this.state = t,
|
|
@@ -13021,46 +13024,46 @@ class su {
|
|
|
13021
13024
|
/**
|
|
13022
13025
|
* Can be overridden to perform additional cleanup before the stream is closed.
|
|
13023
13026
|
* Calling super.tearDown() is not required.
|
|
13024
|
-
*/
|
|
13027
|
+
*/ qo() {}
|
|
13025
13028
|
auth() {
|
|
13026
13029
|
this.state = 1 /* Starting */;
|
|
13027
|
-
const t = this.
|
|
13030
|
+
const t = this.Ko(this.So), e = this.So;
|
|
13028
13031
|
// TODO(mikelehen): Just use dispatchIfNotClosed, but see TODO below.
|
|
13029
13032
|
Promise.all([ this.authCredentialsProvider.getToken(), this.appCheckCredentialsProvider.getToken() ]).then((([t, n]) => {
|
|
13030
13033
|
// Stream can be stopped while waiting for authentication.
|
|
13031
13034
|
// TODO(mikelehen): We really should just use dispatchIfNotClosed
|
|
13032
13035
|
// and let this dispatch onto the queue, but that opened a spec test can
|
|
13033
13036
|
// of worms that I don't want to deal with in this PR.
|
|
13034
|
-
this.
|
|
13037
|
+
this.So === e &&
|
|
13035
13038
|
// Normally we'd have to schedule the callback on the AsyncQueue.
|
|
13036
13039
|
// However, the following calls are safe to be called outside the
|
|
13037
13040
|
// AsyncQueue since they don't chain asynchronous calls
|
|
13038
|
-
this.
|
|
13041
|
+
this.Go(t, n);
|
|
13039
13042
|
}), (e => {
|
|
13040
13043
|
t((() => {
|
|
13041
13044
|
const t = new U(L.UNKNOWN, "Fetching auth token failed: " + e.message);
|
|
13042
|
-
return this.
|
|
13045
|
+
return this.Qo(t);
|
|
13043
13046
|
}));
|
|
13044
13047
|
}));
|
|
13045
13048
|
}
|
|
13046
|
-
|
|
13047
|
-
const n = this.
|
|
13048
|
-
this.stream = this.
|
|
13049
|
-
n((() => (this.state = 2 /* Open */ , this.
|
|
13049
|
+
Go(t, e) {
|
|
13050
|
+
const n = this.Ko(this.So);
|
|
13051
|
+
this.stream = this.jo(t, e), this.stream.Yr((() => {
|
|
13052
|
+
n((() => (this.state = 2 /* Open */ , this.Co = this.Hs.enqueueAfterDelay(this.Vo, 1e4, (() => (this.ko() && (this.state = 3 /* Healthy */),
|
|
13050
13053
|
Promise.resolve()))), this.listener.Yr())));
|
|
13051
13054
|
})), this.stream.Zr((t => {
|
|
13052
|
-
n((() => this.
|
|
13055
|
+
n((() => this.Qo(t)));
|
|
13053
13056
|
})), this.stream.onMessage((t => {
|
|
13054
13057
|
n((() => this.onMessage(t)));
|
|
13055
13058
|
}));
|
|
13056
13059
|
}
|
|
13057
|
-
|
|
13058
|
-
this.state = 5 /* Backoff */ , this.
|
|
13060
|
+
Oo() {
|
|
13061
|
+
this.state = 5 /* Backoff */ , this.xo.Ro((async () => {
|
|
13059
13062
|
this.state = 0 /* Initial */ , this.start();
|
|
13060
13063
|
}));
|
|
13061
13064
|
}
|
|
13062
13065
|
// Visible for tests
|
|
13063
|
-
|
|
13066
|
+
Qo(t) {
|
|
13064
13067
|
// In theory the stream could close cleanly, however, in our current model
|
|
13065
13068
|
// we never expect this to happen because if we stop a stream ourselves,
|
|
13066
13069
|
// this callback will never be called. To prevent cases where we retry
|
|
@@ -13072,9 +13075,9 @@ class su {
|
|
|
13072
13075
|
* AsyncQueue but only runs them if closeCount remains unchanged. This allows
|
|
13073
13076
|
* us to turn auth / stream callbacks into no-ops if the stream is closed /
|
|
13074
13077
|
* re-opened, etc.
|
|
13075
|
-
*/
|
|
13078
|
+
*/ Ko(t) {
|
|
13076
13079
|
return e => {
|
|
13077
|
-
this.Hs.enqueueAndForget((() => this.
|
|
13080
|
+
this.Hs.enqueueAndForget((() => this.So === t ? e() : (x("PersistentStream", "stream callback skipped by getCloseGuardedDispatcher."),
|
|
13078
13081
|
Promise.resolve())));
|
|
13079
13082
|
};
|
|
13080
13083
|
}
|
|
@@ -13091,12 +13094,12 @@ class su {
|
|
|
13091
13094
|
super(t, "listen_stream_connection_backoff" /* ListenStreamConnectionBackoff */ , "listen_stream_idle" /* ListenStreamIdle */ , "health_check_timeout" /* HealthCheckTimeout */ , e, n, s, r),
|
|
13092
13095
|
this.It = i;
|
|
13093
13096
|
}
|
|
13094
|
-
|
|
13095
|
-
return this.
|
|
13097
|
+
jo(t, e) {
|
|
13098
|
+
return this.connection.wo("Listen", t, e);
|
|
13096
13099
|
}
|
|
13097
13100
|
onMessage(t) {
|
|
13098
13101
|
// A successful response means the stream is healthy
|
|
13099
|
-
this.
|
|
13102
|
+
this.xo.reset();
|
|
13100
13103
|
const e = Gs(this.It, t), n = function(t) {
|
|
13101
13104
|
// We have only reached a consistent snapshot for the entire stream if there
|
|
13102
13105
|
// is a read_time set and it applies to all targets (i.e. the list of
|
|
@@ -13105,14 +13108,14 @@ class su {
|
|
|
13105
13108
|
const e = t.targetChange;
|
|
13106
13109
|
return e.targetIds && e.targetIds.length ? it.min() : e.readTime ? xs(e.readTime) : it.min();
|
|
13107
13110
|
}(t);
|
|
13108
|
-
return this.listener.
|
|
13111
|
+
return this.listener.Wo(e, n);
|
|
13109
13112
|
}
|
|
13110
13113
|
/**
|
|
13111
13114
|
* Registers interest in the results of the given target. If the target
|
|
13112
13115
|
* includes a resumeToken it will be included in the request. Results that
|
|
13113
13116
|
* affect the target will be streamed back as WatchChange messages that
|
|
13114
13117
|
* reference the targetId.
|
|
13115
|
-
*/
|
|
13118
|
+
*/ zo(t) {
|
|
13116
13119
|
const e = {};
|
|
13117
13120
|
e.database = Bs(this.It), e.addTarget = function(t, e) {
|
|
13118
13121
|
let n;
|
|
@@ -13128,14 +13131,14 @@ class su {
|
|
|
13128
13131
|
n.readTime = Ss(t, e.snapshotVersion.toTimestamp())), n;
|
|
13129
13132
|
}(this.It, t);
|
|
13130
13133
|
const n = Ys(this.It, t);
|
|
13131
|
-
n && (e.labels = n), this.
|
|
13134
|
+
n && (e.labels = n), this.Bo(e);
|
|
13132
13135
|
}
|
|
13133
13136
|
/**
|
|
13134
13137
|
* Unregisters interest in the results of the target associated with the
|
|
13135
13138
|
* given targetId.
|
|
13136
|
-
*/
|
|
13139
|
+
*/ Ho(t) {
|
|
13137
13140
|
const e = {};
|
|
13138
|
-
e.database = Bs(this.It), e.removeTarget = t, this.
|
|
13141
|
+
e.database = Bs(this.It), e.removeTarget = t, this.Bo(e);
|
|
13139
13142
|
}
|
|
13140
13143
|
}
|
|
13141
13144
|
|
|
@@ -13158,54 +13161,54 @@ class su {
|
|
|
13158
13161
|
*/ class ru extends su {
|
|
13159
13162
|
constructor(t, e, n, s, i, r) {
|
|
13160
13163
|
super(t, "write_stream_connection_backoff" /* WriteStreamConnectionBackoff */ , "write_stream_idle" /* WriteStreamIdle */ , "health_check_timeout" /* HealthCheckTimeout */ , e, n, s, r),
|
|
13161
|
-
this.It = i, this.
|
|
13164
|
+
this.It = i, this.Jo = !1;
|
|
13162
13165
|
}
|
|
13163
13166
|
/**
|
|
13164
13167
|
* Tracks whether or not a handshake has been successfully exchanged and
|
|
13165
13168
|
* the stream is ready to accept mutations.
|
|
13166
|
-
*/ get
|
|
13167
|
-
return this.
|
|
13169
|
+
*/ get Yo() {
|
|
13170
|
+
return this.Jo;
|
|
13168
13171
|
}
|
|
13169
13172
|
// Override of PersistentStream.start
|
|
13170
13173
|
start() {
|
|
13171
|
-
this.
|
|
13174
|
+
this.Jo = !1, this.lastStreamToken = void 0, super.start();
|
|
13172
13175
|
}
|
|
13173
|
-
|
|
13174
|
-
this.
|
|
13176
|
+
qo() {
|
|
13177
|
+
this.Jo && this.Xo([]);
|
|
13175
13178
|
}
|
|
13176
|
-
|
|
13177
|
-
return this.
|
|
13179
|
+
jo(t, e) {
|
|
13180
|
+
return this.connection.wo("Write", t, e);
|
|
13178
13181
|
}
|
|
13179
13182
|
onMessage(t) {
|
|
13180
13183
|
if (
|
|
13181
13184
|
// Always capture the last stream token.
|
|
13182
|
-
F(!!t.streamToken), this.lastStreamToken = t.streamToken, this.
|
|
13185
|
+
F(!!t.streamToken), this.lastStreamToken = t.streamToken, this.Jo) {
|
|
13183
13186
|
// A successful first write response means the stream is healthy,
|
|
13184
13187
|
// Note, that we could consider a successful handshake healthy, however,
|
|
13185
13188
|
// the write itself might be causing an error we want to back off from.
|
|
13186
|
-
this.
|
|
13189
|
+
this.xo.reset();
|
|
13187
13190
|
const e = Ws(t.writeResults, t.commitTime), n = xs(t.commitTime);
|
|
13188
|
-
return this.listener.
|
|
13191
|
+
return this.listener.Zo(n, e);
|
|
13189
13192
|
}
|
|
13190
13193
|
// The first response is always the handshake response
|
|
13191
|
-
return F(!t.writeResults || 0 === t.writeResults.length), this.
|
|
13194
|
+
return F(!t.writeResults || 0 === t.writeResults.length), this.Jo = !0, this.listener.tu();
|
|
13192
13195
|
}
|
|
13193
13196
|
/**
|
|
13194
13197
|
* Sends an initial streamToken to the server, performing the handshake
|
|
13195
13198
|
* required to make the StreamingWrite RPC work. Subsequent
|
|
13196
13199
|
* calls should wait until onHandshakeComplete was called.
|
|
13197
|
-
*/
|
|
13200
|
+
*/ eu() {
|
|
13198
13201
|
// TODO(dimond): Support stream resumption. We intentionally do not set the
|
|
13199
13202
|
// stream token on the handshake, ignoring any stream token we might have.
|
|
13200
13203
|
const t = {};
|
|
13201
|
-
t.database = Bs(this.It), this.
|
|
13204
|
+
t.database = Bs(this.It), this.Bo(t);
|
|
13202
13205
|
}
|
|
13203
|
-
/** Sends a group of mutations to the Firestore backend to apply. */
|
|
13206
|
+
/** Sends a group of mutations to the Firestore backend to apply. */ Xo(t) {
|
|
13204
13207
|
const e = {
|
|
13205
13208
|
streamToken: this.lastStreamToken,
|
|
13206
13209
|
writes: t.map((t => Qs(this.It, t)))
|
|
13207
13210
|
};
|
|
13208
|
-
this.
|
|
13211
|
+
this.Bo(e);
|
|
13209
13212
|
}
|
|
13210
13213
|
}
|
|
13211
13214
|
|
|
@@ -13236,26 +13239,26 @@ class su {
|
|
|
13236
13239
|
*/
|
|
13237
13240
|
class ou extends class {} {
|
|
13238
13241
|
constructor(t, e, n, s) {
|
|
13239
|
-
super(), this.authCredentials = t, this.appCheckCredentials = e, this.
|
|
13240
|
-
this.
|
|
13242
|
+
super(), this.authCredentials = t, this.appCheckCredentials = e, this.connection = n,
|
|
13243
|
+
this.It = s, this.nu = !1;
|
|
13241
13244
|
}
|
|
13242
|
-
|
|
13243
|
-
if (this.
|
|
13245
|
+
su() {
|
|
13246
|
+
if (this.nu) throw new U(L.FAILED_PRECONDITION, "The client has already been terminated.");
|
|
13244
13247
|
}
|
|
13245
13248
|
/** Invokes the provided RPC with auth and AppCheck tokens. */ ao(t, e, n) {
|
|
13246
|
-
return this.
|
|
13249
|
+
return this.su(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([s, i]) => this.connection.ao(t, e, n, s, i))).catch((t => {
|
|
13247
13250
|
throw "FirebaseError" === t.name ? (t.code === L.UNAUTHENTICATED && (this.authCredentials.invalidateToken(),
|
|
13248
13251
|
this.appCheckCredentials.invalidateToken()), t) : new U(L.UNKNOWN, t.toString());
|
|
13249
13252
|
}));
|
|
13250
13253
|
}
|
|
13251
13254
|
/** Invokes the provided RPC with streamed results with auth and AppCheck tokens. */ _o(t, e, n, s) {
|
|
13252
|
-
return this.
|
|
13255
|
+
return this.su(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([i, r]) => this.connection._o(t, e, n, i, r, s))).catch((t => {
|
|
13253
13256
|
throw "FirebaseError" === t.name ? (t.code === L.UNAUTHENTICATED && (this.authCredentials.invalidateToken(),
|
|
13254
13257
|
this.appCheckCredentials.invalidateToken()), t) : new U(L.UNKNOWN, t.toString());
|
|
13255
13258
|
}));
|
|
13256
13259
|
}
|
|
13257
13260
|
terminate() {
|
|
13258
|
-
this.
|
|
13261
|
+
this.nu = !0;
|
|
13259
13262
|
}
|
|
13260
13263
|
}
|
|
13261
13264
|
|
|
@@ -13275,7 +13278,7 @@ async function uu(t, e) {
|
|
|
13275
13278
|
parent: n.parent
|
|
13276
13279
|
};
|
|
13277
13280
|
}(n.It, hn(e)), i = s.parent;
|
|
13278
|
-
n.
|
|
13281
|
+
n.connection.co || delete s.parent;
|
|
13279
13282
|
return (await n._o("RunAggregationQuery", i, s, /*expectedResponseCount=*/ 1)).filter((t => !!t.result)).map((t => t.result.aggregateFields));
|
|
13280
13283
|
}
|
|
13281
13284
|
|
|
@@ -13300,19 +13303,19 @@ class cu {
|
|
|
13300
13303
|
* maximum defined by MAX_WATCH_STREAM_FAILURES, we'll set the OnlineState to
|
|
13301
13304
|
* Offline.
|
|
13302
13305
|
*/
|
|
13303
|
-
this.
|
|
13306
|
+
this.iu = 0,
|
|
13304
13307
|
/**
|
|
13305
13308
|
* A timer that elapses after ONLINE_STATE_TIMEOUT_MS, at which point we
|
|
13306
13309
|
* transition from OnlineState.Unknown to OnlineState.Offline without waiting
|
|
13307
13310
|
* for the stream to actually fail (MAX_WATCH_STREAM_FAILURES times).
|
|
13308
13311
|
*/
|
|
13309
|
-
this.
|
|
13312
|
+
this.ru = null,
|
|
13310
13313
|
/**
|
|
13311
13314
|
* Whether the client should log a warning message if it fails to connect to
|
|
13312
13315
|
* the backend (initially true, cleared after a successful stream, or if we've
|
|
13313
13316
|
* logged the message already).
|
|
13314
13317
|
*/
|
|
13315
|
-
this.
|
|
13318
|
+
this.ou = !0;
|
|
13316
13319
|
}
|
|
13317
13320
|
/**
|
|
13318
13321
|
* Called by RemoteStore when a watch stream is started (including on each
|
|
@@ -13320,9 +13323,9 @@ class cu {
|
|
|
13320
13323
|
*
|
|
13321
13324
|
* If this is the first attempt, it sets the OnlineState to Unknown and starts
|
|
13322
13325
|
* the onlineStateTimer.
|
|
13323
|
-
*/
|
|
13324
|
-
0 === this.
|
|
13325
|
-
this.
|
|
13326
|
+
*/ uu() {
|
|
13327
|
+
0 === this.iu && (this.cu("Unknown" /* Unknown */), this.ru = this.asyncQueue.enqueueAfterDelay("online_state_timeout" /* OnlineStateTimeout */ , 1e4, (() => (this.ru = null,
|
|
13328
|
+
this.au("Backend didn't respond within 10 seconds."), this.cu("Offline" /* Offline */),
|
|
13326
13329
|
Promise.resolve()))));
|
|
13327
13330
|
}
|
|
13328
13331
|
/**
|
|
@@ -13330,10 +13333,10 @@ class cu {
|
|
|
13330
13333
|
* failure. The first failure moves us to the 'Unknown' state. We then may
|
|
13331
13334
|
* allow multiple failures (based on MAX_WATCH_STREAM_FAILURES) before we
|
|
13332
13335
|
* actually transition to the 'Offline' state.
|
|
13333
|
-
*/
|
|
13334
|
-
"Online" /* Online */ === this.state ? this.
|
|
13335
|
-
this.
|
|
13336
|
-
this.
|
|
13336
|
+
*/ hu(t) {
|
|
13337
|
+
"Online" /* Online */ === this.state ? this.cu("Unknown" /* Unknown */) : (this.iu++,
|
|
13338
|
+
this.iu >= 1 && (this.lu(), this.au(`Connection failed 1 times. Most recent error: ${t.toString()}`),
|
|
13339
|
+
this.cu("Offline" /* Offline */)));
|
|
13337
13340
|
}
|
|
13338
13341
|
/**
|
|
13339
13342
|
* Explicitly sets the OnlineState to the specified state.
|
|
@@ -13342,20 +13345,20 @@ class cu {
|
|
|
13342
13345
|
* Offline heuristics, so must not be used in place of
|
|
13343
13346
|
* handleWatchStreamStart() and handleWatchStreamFailure().
|
|
13344
13347
|
*/ set(t) {
|
|
13345
|
-
this.
|
|
13348
|
+
this.lu(), this.iu = 0, "Online" /* Online */ === t && (
|
|
13346
13349
|
// We've connected to watch at least once. Don't warn the developer
|
|
13347
13350
|
// about being offline going forward.
|
|
13348
|
-
this.
|
|
13351
|
+
this.ou = !1), this.cu(t);
|
|
13349
13352
|
}
|
|
13350
|
-
|
|
13353
|
+
cu(t) {
|
|
13351
13354
|
t !== this.state && (this.state = t, this.onlineStateHandler(t));
|
|
13352
13355
|
}
|
|
13353
|
-
|
|
13356
|
+
au(t) {
|
|
13354
13357
|
const e = `Could not reach Cloud Firestore backend. ${t}\nThis typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.`;
|
|
13355
|
-
this.
|
|
13358
|
+
this.ou ? (N(e), this.ou = !1) : x("OnlineStateTracker", e);
|
|
13356
13359
|
}
|
|
13357
|
-
|
|
13358
|
-
null !== this.
|
|
13360
|
+
lu() {
|
|
13361
|
+
null !== this.ru && (this.ru.cancel(), this.ru = null);
|
|
13359
13362
|
}
|
|
13360
13363
|
}
|
|
13361
13364
|
|
|
@@ -13400,7 +13403,7 @@ class cu {
|
|
|
13400
13403
|
* purely based on order, and so we can just shift() writes from the front of
|
|
13401
13404
|
* the writePipeline as we receive responses.
|
|
13402
13405
|
*/
|
|
13403
|
-
this.
|
|
13406
|
+
this.fu = [],
|
|
13404
13407
|
/**
|
|
13405
13408
|
* A mapping of watched targets that the client cares about tracking and the
|
|
13406
13409
|
* user has explicitly called a 'listen' for this target.
|
|
@@ -13410,12 +13413,12 @@ class cu {
|
|
|
13410
13413
|
* to the server. The targets removed with unlistens are removed eagerly
|
|
13411
13414
|
* without waiting for confirmation from the listen stream.
|
|
13412
13415
|
*/
|
|
13413
|
-
this.
|
|
13416
|
+
this.du = new Map,
|
|
13414
13417
|
/**
|
|
13415
13418
|
* A set of reasons for why the RemoteStore may be offline. If empty, the
|
|
13416
13419
|
* RemoteStore may start its network connections.
|
|
13417
13420
|
*/
|
|
13418
|
-
this.
|
|
13421
|
+
this._u = new Set,
|
|
13419
13422
|
/**
|
|
13420
13423
|
* Event handlers that get called when the network is disabled or enabled.
|
|
13421
13424
|
*
|
|
@@ -13423,7 +13426,7 @@ class cu {
|
|
|
13423
13426
|
* underlying streams (to support tree-shakeable streams). On Android and iOS,
|
|
13424
13427
|
* the streams are created during construction of RemoteStore.
|
|
13425
13428
|
*/
|
|
13426
|
-
this.
|
|
13429
|
+
this.wu = [], this.mu = i, this.mu.qr((t => {
|
|
13427
13430
|
n.enqueueAndForget((async () => {
|
|
13428
13431
|
// Porting Note: Unlike iOS, `restartNetwork()` is called even when the
|
|
13429
13432
|
// network becomes unreachable as we don't have any other way to tear
|
|
@@ -13431,23 +13434,23 @@ class cu {
|
|
|
13431
13434
|
yu(this) && (x("RemoteStore", "Restarting streams for network reachability change."),
|
|
13432
13435
|
await async function(t) {
|
|
13433
13436
|
const e = B(t);
|
|
13434
|
-
e.
|
|
13435
|
-
e.
|
|
13437
|
+
e._u.add(4 /* ConnectivityChange */), await lu(e), e.gu.set("Unknown" /* Unknown */),
|
|
13438
|
+
e._u.delete(4 /* ConnectivityChange */), await hu(e);
|
|
13436
13439
|
}(this));
|
|
13437
13440
|
}));
|
|
13438
|
-
})), this.
|
|
13441
|
+
})), this.gu = new cu(n, s);
|
|
13439
13442
|
}
|
|
13440
13443
|
}
|
|
13441
13444
|
|
|
13442
13445
|
async function hu(t) {
|
|
13443
|
-
if (yu(t)) for (const e of t.
|
|
13446
|
+
if (yu(t)) for (const e of t.wu) await e(/* enabled= */ !0);
|
|
13444
13447
|
}
|
|
13445
13448
|
|
|
13446
13449
|
/**
|
|
13447
13450
|
* Temporarily disables the network. The network can be re-enabled using
|
|
13448
13451
|
* enableNetwork().
|
|
13449
13452
|
*/ async function lu(t) {
|
|
13450
|
-
for (const e of t.
|
|
13453
|
+
for (const e of t.wu) await e(/* enabled= */ !1);
|
|
13451
13454
|
}
|
|
13452
13455
|
|
|
13453
13456
|
/**
|
|
@@ -13456,11 +13459,11 @@ async function hu(t) {
|
|
|
13456
13459
|
*/
|
|
13457
13460
|
function fu(t, e) {
|
|
13458
13461
|
const n = B(t);
|
|
13459
|
-
n.
|
|
13462
|
+
n.du.has(e.targetId) || (
|
|
13460
13463
|
// Mark this as something the client is currently listening for.
|
|
13461
|
-
n.
|
|
13464
|
+
n.du.set(e.targetId, e), gu(n) ?
|
|
13462
13465
|
// The listen will be sent in onWatchStreamOpen
|
|
13463
|
-
mu(n) : Mu(n).
|
|
13466
|
+
mu(n) : Mu(n).ko() && _u(n, e));
|
|
13464
13467
|
}
|
|
13465
13468
|
|
|
13466
13469
|
/**
|
|
@@ -13468,18 +13471,18 @@ function fu(t, e) {
|
|
|
13468
13471
|
* not being listened to.
|
|
13469
13472
|
*/ function du(t, e) {
|
|
13470
13473
|
const n = B(t), s = Mu(n);
|
|
13471
|
-
n.
|
|
13474
|
+
n.du.delete(e), s.ko() && wu(n, e), 0 === n.du.size && (s.ko() ? s.Fo() : yu(n) &&
|
|
13472
13475
|
// Revert to OnlineState.Unknown if the watch stream is not open and we
|
|
13473
13476
|
// have no listeners, since without any listens to send we cannot
|
|
13474
13477
|
// confirm if the stream is healthy and upgrade to OnlineState.Online.
|
|
13475
|
-
n.
|
|
13478
|
+
n.gu.set("Unknown" /* Unknown */));
|
|
13476
13479
|
}
|
|
13477
13480
|
|
|
13478
13481
|
/**
|
|
13479
13482
|
* We need to increment the the expected number of pending responses we're due
|
|
13480
13483
|
* from watch so we wait for the ack to process any messages from this target.
|
|
13481
13484
|
*/ function _u(t, e) {
|
|
13482
|
-
t.
|
|
13485
|
+
t.yu.Mt(e.targetId), Mu(t).zo(e);
|
|
13483
13486
|
}
|
|
13484
13487
|
|
|
13485
13488
|
/**
|
|
@@ -13487,33 +13490,33 @@ function fu(t, e) {
|
|
|
13487
13490
|
* from watch so we wait for the removal on the server before we process any
|
|
13488
13491
|
* messages from this target.
|
|
13489
13492
|
*/ function wu(t, e) {
|
|
13490
|
-
t.
|
|
13493
|
+
t.yu.Mt(e), Mu(t).Ho(e);
|
|
13491
13494
|
}
|
|
13492
13495
|
|
|
13493
13496
|
function mu(t) {
|
|
13494
|
-
t.
|
|
13497
|
+
t.yu = new As({
|
|
13495
13498
|
getRemoteKeysForTarget: e => t.remoteSyncer.getRemoteKeysForTarget(e),
|
|
13496
|
-
se: e => t.
|
|
13497
|
-
}), Mu(t).start(), t.
|
|
13499
|
+
se: e => t.du.get(e) || null
|
|
13500
|
+
}), Mu(t).start(), t.gu.uu();
|
|
13498
13501
|
}
|
|
13499
13502
|
|
|
13500
13503
|
/**
|
|
13501
13504
|
* Returns whether the watch stream should be started because it's necessary
|
|
13502
13505
|
* and has not yet been started.
|
|
13503
13506
|
*/ function gu(t) {
|
|
13504
|
-
return yu(t) && !Mu(t).
|
|
13507
|
+
return yu(t) && !Mu(t).No() && t.du.size > 0;
|
|
13505
13508
|
}
|
|
13506
13509
|
|
|
13507
13510
|
function yu(t) {
|
|
13508
|
-
return 0 === B(t).
|
|
13511
|
+
return 0 === B(t)._u.size;
|
|
13509
13512
|
}
|
|
13510
13513
|
|
|
13511
13514
|
function pu(t) {
|
|
13512
|
-
t.
|
|
13515
|
+
t.yu = void 0;
|
|
13513
13516
|
}
|
|
13514
13517
|
|
|
13515
13518
|
async function Iu(t) {
|
|
13516
|
-
t.
|
|
13519
|
+
t.du.forEach(((e, n) => {
|
|
13517
13520
|
_u(t, e);
|
|
13518
13521
|
}));
|
|
13519
13522
|
}
|
|
@@ -13521,17 +13524,17 @@ async function Iu(t) {
|
|
|
13521
13524
|
async function Tu(t, e) {
|
|
13522
13525
|
pu(t),
|
|
13523
13526
|
// If we still need the watch stream, retry the connection.
|
|
13524
|
-
gu(t) ? (t.
|
|
13527
|
+
gu(t) ? (t.gu.hu(e), mu(t)) :
|
|
13525
13528
|
// No need to restart watch stream because there are no active targets.
|
|
13526
13529
|
// The online state is set to unknown because there is no active attempt
|
|
13527
13530
|
// at establishing a connection
|
|
13528
|
-
t.
|
|
13531
|
+
t.gu.set("Unknown" /* Unknown */);
|
|
13529
13532
|
}
|
|
13530
13533
|
|
|
13531
13534
|
async function Eu(t, e, n) {
|
|
13532
13535
|
if (
|
|
13533
13536
|
// Mark the client as online since we got a message from the server
|
|
13534
|
-
t.
|
|
13537
|
+
t.gu.set("Online" /* Online */), e instanceof Ts && 2 /* Removed */ === e.state && e.cause)
|
|
13535
13538
|
// There was an error on a target, don't wait for a consistent snapshot
|
|
13536
13539
|
// to raise events
|
|
13537
13540
|
try {
|
|
@@ -13541,7 +13544,7 @@ async function Eu(t, e, n) {
|
|
|
13541
13544
|
const n = e.cause;
|
|
13542
13545
|
for (const s of e.targetIds)
|
|
13543
13546
|
// A watched target might have been removed already.
|
|
13544
|
-
t.
|
|
13547
|
+
t.du.has(s) && (await t.remoteSyncer.rejectListen(s, n), t.du.delete(s), t.yu.removeTarget(s));
|
|
13545
13548
|
}
|
|
13546
13549
|
/**
|
|
13547
13550
|
* Attempts to fill our write pipeline with writes from the LocalStore.
|
|
@@ -13554,7 +13557,7 @@ async function Eu(t, e, n) {
|
|
|
13554
13557
|
} catch (n) {
|
|
13555
13558
|
x("RemoteStore", "Failed to remove targets %s: %s ", e.targetIds.join(","), n),
|
|
13556
13559
|
await Au(t, n);
|
|
13557
|
-
} else if (e instanceof ps ? t.
|
|
13560
|
+
} else if (e instanceof ps ? t.yu.Gt(e) : e instanceof Is ? t.yu.Yt(e) : t.yu.Wt(e),
|
|
13558
13561
|
!n.isEqual(it.min())) try {
|
|
13559
13562
|
const e = await Po(t.localStore);
|
|
13560
13563
|
n.compareTo(e) >= 0 &&
|
|
@@ -13567,26 +13570,26 @@ async function Eu(t, e, n) {
|
|
|
13567
13570
|
* SyncEngine.
|
|
13568
13571
|
*/
|
|
13569
13572
|
function(t, e) {
|
|
13570
|
-
const n = t.
|
|
13573
|
+
const n = t.yu.te(e);
|
|
13571
13574
|
// Update in-memory resume tokens. LocalStore will update the
|
|
13572
13575
|
// persistent view of these when applying the completed RemoteEvent.
|
|
13573
13576
|
return n.targetChanges.forEach(((n, s) => {
|
|
13574
13577
|
if (n.resumeToken.approximateByteSize() > 0) {
|
|
13575
|
-
const i = t.
|
|
13578
|
+
const i = t.du.get(s);
|
|
13576
13579
|
// A watched target might have been removed already.
|
|
13577
|
-
i && t.
|
|
13580
|
+
i && t.du.set(s, i.withResumeToken(n.resumeToken, e));
|
|
13578
13581
|
}
|
|
13579
13582
|
})),
|
|
13580
13583
|
// Re-establish listens for the targets that have been invalidated by
|
|
13581
13584
|
// existence filter mismatches.
|
|
13582
13585
|
n.targetMismatches.forEach((e => {
|
|
13583
|
-
const n = t.
|
|
13586
|
+
const n = t.du.get(e);
|
|
13584
13587
|
if (!n)
|
|
13585
13588
|
// A watched target might have been removed already.
|
|
13586
13589
|
return;
|
|
13587
13590
|
// Clear the resume token for the target, since we're in a known mismatch
|
|
13588
13591
|
// state.
|
|
13589
|
-
t.
|
|
13592
|
+
t.du.set(e, n.withResumeToken(Ht.EMPTY_BYTE_STRING, n.snapshotVersion)),
|
|
13590
13593
|
// Cause a hard reset by unwatching and rewatching immediately, but
|
|
13591
13594
|
// deliberately don't send a resume token so that we get a full update.
|
|
13592
13595
|
wu(t, e);
|
|
@@ -13613,16 +13616,16 @@ async function Eu(t, e, n) {
|
|
|
13613
13616
|
* any retry attempt.
|
|
13614
13617
|
*/ async function Au(t, e, n) {
|
|
13615
13618
|
if (!St(e)) throw e;
|
|
13616
|
-
t.
|
|
13619
|
+
t._u.add(1 /* IndexedDbFailed */),
|
|
13617
13620
|
// Disable network and raise offline snapshots
|
|
13618
|
-
await lu(t), t.
|
|
13621
|
+
await lu(t), t.gu.set("Offline" /* Offline */), n || (
|
|
13619
13622
|
// Use a simple read operation to determine if IndexedDB recovered.
|
|
13620
13623
|
// Ideally, we would expose a health check directly on SimpleDb, but
|
|
13621
13624
|
// RemoteStore only has access to persistence through LocalStore.
|
|
13622
13625
|
n = () => Po(t.localStore)),
|
|
13623
13626
|
// Probe IndexedDB periodically and re-enable network
|
|
13624
13627
|
t.asyncQueue.enqueueRetryable((async () => {
|
|
13625
|
-
x("RemoteStore", "Retrying IndexedDB access"), await n(), t.
|
|
13628
|
+
x("RemoteStore", "Retrying IndexedDB access"), await n(), t._u.delete(1 /* IndexedDbFailed */),
|
|
13626
13629
|
await hu(t);
|
|
13627
13630
|
}));
|
|
13628
13631
|
}
|
|
@@ -13636,11 +13639,11 @@ async function Eu(t, e, n) {
|
|
|
13636
13639
|
|
|
13637
13640
|
async function bu(t) {
|
|
13638
13641
|
const e = B(t), n = Fu(e);
|
|
13639
|
-
let s = e.
|
|
13642
|
+
let s = e.fu.length > 0 ? e.fu[e.fu.length - 1].batchId : -1;
|
|
13640
13643
|
for (;Pu(e); ) try {
|
|
13641
13644
|
const t = await So(e.localStore, s);
|
|
13642
13645
|
if (null === t) {
|
|
13643
|
-
0 === e.
|
|
13646
|
+
0 === e.fu.length && n.Fo();
|
|
13644
13647
|
break;
|
|
13645
13648
|
}
|
|
13646
13649
|
s = t.batchId, vu(e, t);
|
|
@@ -13654,20 +13657,20 @@ async function bu(t) {
|
|
|
13654
13657
|
* Returns true if we can add to the write pipeline (i.e. the network is
|
|
13655
13658
|
* enabled and the write pipeline is not full).
|
|
13656
13659
|
*/ function Pu(t) {
|
|
13657
|
-
return yu(t) && t.
|
|
13660
|
+
return yu(t) && t.fu.length < 10;
|
|
13658
13661
|
}
|
|
13659
13662
|
|
|
13660
13663
|
/**
|
|
13661
13664
|
* Queues additional writes to be sent to the write stream, sending them
|
|
13662
13665
|
* immediately if the write stream is established.
|
|
13663
13666
|
*/ function vu(t, e) {
|
|
13664
|
-
t.
|
|
13667
|
+
t.fu.push(e);
|
|
13665
13668
|
const n = Fu(t);
|
|
13666
|
-
n.
|
|
13669
|
+
n.ko() && n.Yo && n.Xo(e.mutations);
|
|
13667
13670
|
}
|
|
13668
13671
|
|
|
13669
13672
|
function Vu(t) {
|
|
13670
|
-
return yu(t) && !Fu(t).
|
|
13673
|
+
return yu(t) && !Fu(t).No() && t.fu.length > 0;
|
|
13671
13674
|
}
|
|
13672
13675
|
|
|
13673
13676
|
function Su(t) {
|
|
@@ -13675,17 +13678,17 @@ function Su(t) {
|
|
|
13675
13678
|
}
|
|
13676
13679
|
|
|
13677
13680
|
async function Du(t) {
|
|
13678
|
-
Fu(t).
|
|
13681
|
+
Fu(t).eu();
|
|
13679
13682
|
}
|
|
13680
13683
|
|
|
13681
13684
|
async function Cu(t) {
|
|
13682
13685
|
const e = Fu(t);
|
|
13683
13686
|
// Send the write pipeline now that the stream is established.
|
|
13684
|
-
for (const n of t.
|
|
13687
|
+
for (const n of t.fu) e.Xo(n.mutations);
|
|
13685
13688
|
}
|
|
13686
13689
|
|
|
13687
13690
|
async function xu(t, e, n) {
|
|
13688
|
-
const s = t.
|
|
13691
|
+
const s = t.fu.shift(), i = Fi.from(s, e, n);
|
|
13689
13692
|
await Ru(t, (() => t.remoteSyncer.applySuccessfulWrite(i))),
|
|
13690
13693
|
// It's possible that with the completion of this mutation another
|
|
13691
13694
|
// slot has freed up.
|
|
@@ -13695,7 +13698,7 @@ async function xu(t, e, n) {
|
|
|
13695
13698
|
async function Nu(t, e) {
|
|
13696
13699
|
// If the write stream closed after the write handshake completes, a write
|
|
13697
13700
|
// operation failed and we fail the pending operation.
|
|
13698
|
-
e && Fu(t).
|
|
13701
|
+
e && Fu(t).Yo &&
|
|
13699
13702
|
// This error affects the actual write.
|
|
13700
13703
|
await async function(t, e) {
|
|
13701
13704
|
// Only handle permanent errors here. If it's transient, just let the retry
|
|
@@ -13703,11 +13706,11 @@ async function Nu(t, e) {
|
|
|
13703
13706
|
if (n = e.code, es(n) && n !== L.ABORTED) {
|
|
13704
13707
|
// This was a permanent error, the request itself was the problem
|
|
13705
13708
|
// so it's not going to succeed if we resend it.
|
|
13706
|
-
const n = t.
|
|
13709
|
+
const n = t.fu.shift();
|
|
13707
13710
|
// In this case it's also unlikely that the server itself is melting
|
|
13708
13711
|
// down -- this was just a bad request so inhibit backoff on the next
|
|
13709
13712
|
// restart.
|
|
13710
|
-
Fu(t).
|
|
13713
|
+
Fu(t).Mo(), await Ru(t, (() => t.remoteSyncer.rejectFailedWrite(n.batchId, e))),
|
|
13711
13714
|
// It's possible that with the completion of this mutation
|
|
13712
13715
|
// another slot has freed up.
|
|
13713
13716
|
await bu(t);
|
|
@@ -13726,18 +13729,18 @@ async function ku(t, e) {
|
|
|
13726
13729
|
// Tear down and re-create our network streams. This will ensure we get a
|
|
13727
13730
|
// fresh auth token for the new user and re-fill the write pipeline with
|
|
13728
13731
|
// new mutations from the LocalStore (since mutations are per-user).
|
|
13729
|
-
n.
|
|
13732
|
+
n._u.add(3 /* CredentialChange */), await lu(n), s &&
|
|
13730
13733
|
// Don't set the network status to Unknown if we are offline.
|
|
13731
|
-
n.
|
|
13732
|
-
n.
|
|
13734
|
+
n.gu.set("Unknown" /* Unknown */), await n.remoteSyncer.handleCredentialChange(e),
|
|
13735
|
+
n._u.delete(3 /* CredentialChange */), await hu(n);
|
|
13733
13736
|
}
|
|
13734
13737
|
|
|
13735
13738
|
/**
|
|
13736
13739
|
* Toggles the network state when the client gains or loses its primary lease.
|
|
13737
13740
|
*/ async function Ou(t, e) {
|
|
13738
13741
|
const n = B(t);
|
|
13739
|
-
e ? (n.
|
|
13740
|
-
await lu(n), n.
|
|
13742
|
+
e ? (n._u.delete(2 /* IsSecondary */), await hu(n)) : e || (n._u.add(2 /* IsSecondary */),
|
|
13743
|
+
await lu(n), n.gu.set("Unknown" /* Unknown */));
|
|
13741
13744
|
}
|
|
13742
13745
|
|
|
13743
13746
|
/**
|
|
@@ -13748,11 +13751,11 @@ async function ku(t, e) {
|
|
|
13748
13751
|
* PORTING NOTE: On iOS and Android, the WatchStream gets registered on startup.
|
|
13749
13752
|
* This is not done on Web to allow it to be tree-shaken.
|
|
13750
13753
|
*/ function Mu(t) {
|
|
13751
|
-
return t.
|
|
13754
|
+
return t.pu || (
|
|
13752
13755
|
// Create stream (but note that it is not started yet).
|
|
13753
|
-
t.
|
|
13756
|
+
t.pu = function(t, e, n) {
|
|
13754
13757
|
const s = B(t);
|
|
13755
|
-
return s.
|
|
13758
|
+
return s.su(), new iu(e, s.connection, s.authCredentials, s.appCheckCredentials, s.It, n);
|
|
13756
13759
|
}
|
|
13757
13760
|
/**
|
|
13758
13761
|
* @license
|
|
@@ -13772,11 +13775,11 @@ async function ku(t, e) {
|
|
|
13772
13775
|
*/ (t.datastore, t.asyncQueue, {
|
|
13773
13776
|
Yr: Iu.bind(null, t),
|
|
13774
13777
|
Zr: Tu.bind(null, t),
|
|
13775
|
-
|
|
13776
|
-
}), t.
|
|
13777
|
-
e ? (t.
|
|
13778
|
+
Wo: Eu.bind(null, t)
|
|
13779
|
+
}), t.wu.push((async e => {
|
|
13780
|
+
e ? (t.pu.Mo(), gu(t) ? mu(t) : t.gu.set("Unknown" /* Unknown */)) : (await t.pu.stop(),
|
|
13778
13781
|
pu(t));
|
|
13779
|
-
}))), t.
|
|
13782
|
+
}))), t.pu;
|
|
13780
13783
|
}
|
|
13781
13784
|
|
|
13782
13785
|
/**
|
|
@@ -13787,22 +13790,22 @@ async function ku(t, e) {
|
|
|
13787
13790
|
* PORTING NOTE: On iOS and Android, the WriteStream gets registered on startup.
|
|
13788
13791
|
* This is not done on Web to allow it to be tree-shaken.
|
|
13789
13792
|
*/ function Fu(t) {
|
|
13790
|
-
return t.
|
|
13793
|
+
return t.Iu || (
|
|
13791
13794
|
// Create stream (but note that it is not started yet).
|
|
13792
|
-
t.
|
|
13795
|
+
t.Iu = function(t, e, n) {
|
|
13793
13796
|
const s = B(t);
|
|
13794
|
-
return s.
|
|
13797
|
+
return s.su(), new ru(e, s.connection, s.authCredentials, s.appCheckCredentials, s.It, n);
|
|
13795
13798
|
}(t.datastore, t.asyncQueue, {
|
|
13796
13799
|
Yr: Du.bind(null, t),
|
|
13797
13800
|
Zr: Nu.bind(null, t),
|
|
13798
|
-
|
|
13799
|
-
|
|
13800
|
-
}), t.
|
|
13801
|
-
e ? (t.
|
|
13801
|
+
tu: Cu.bind(null, t),
|
|
13802
|
+
Zo: xu.bind(null, t)
|
|
13803
|
+
}), t.wu.push((async e => {
|
|
13804
|
+
e ? (t.Iu.Mo(),
|
|
13802
13805
|
// This will start the write stream if necessary.
|
|
13803
|
-
await bu(t)) : (await t.
|
|
13804
|
-
t.
|
|
13805
|
-
}))), t.
|
|
13806
|
+
await bu(t)) : (await t.Iu.stop(), t.fu.length > 0 && (x("RemoteStore", `Stopping write stream with ${t.fu.length} pending writes`),
|
|
13807
|
+
t.fu = []));
|
|
13808
|
+
}))), t.Iu;
|
|
13806
13809
|
}
|
|
13807
13810
|
|
|
13808
13811
|
/**
|
|
@@ -14012,25 +14015,25 @@ class $u {
|
|
|
14012
14015
|
* duplicate events for the same doc.
|
|
14013
14016
|
*/ class Uu {
|
|
14014
14017
|
constructor() {
|
|
14015
|
-
this.
|
|
14018
|
+
this.Tu = new Lt(at.comparator);
|
|
14016
14019
|
}
|
|
14017
14020
|
track(t) {
|
|
14018
|
-
const e = t.doc.key, n = this.
|
|
14021
|
+
const e = t.doc.key, n = this.Tu.get(e);
|
|
14019
14022
|
n ?
|
|
14020
14023
|
// Merge the new change with the existing change.
|
|
14021
|
-
0 /* Added */ !== t.type && 3 /* Metadata */ === n.type ? this.
|
|
14024
|
+
0 /* Added */ !== t.type && 3 /* Metadata */ === n.type ? this.Tu = this.Tu.insert(e, t) : 3 /* Metadata */ === t.type && 1 /* Removed */ !== n.type ? this.Tu = this.Tu.insert(e, {
|
|
14022
14025
|
type: n.type,
|
|
14023
14026
|
doc: t.doc
|
|
14024
|
-
}) : 2 /* Modified */ === t.type && 2 /* Modified */ === n.type ? this.
|
|
14027
|
+
}) : 2 /* Modified */ === t.type && 2 /* Modified */ === n.type ? this.Tu = this.Tu.insert(e, {
|
|
14025
14028
|
type: 2 /* Modified */ ,
|
|
14026
14029
|
doc: t.doc
|
|
14027
|
-
}) : 2 /* Modified */ === t.type && 0 /* Added */ === n.type ? this.
|
|
14030
|
+
}) : 2 /* Modified */ === t.type && 0 /* Added */ === n.type ? this.Tu = this.Tu.insert(e, {
|
|
14028
14031
|
type: 0 /* Added */ ,
|
|
14029
14032
|
doc: t.doc
|
|
14030
|
-
}) : 1 /* Removed */ === t.type && 0 /* Added */ === n.type ? this.
|
|
14033
|
+
}) : 1 /* Removed */ === t.type && 0 /* Added */ === n.type ? this.Tu = this.Tu.remove(e) : 1 /* Removed */ === t.type && 2 /* Modified */ === n.type ? this.Tu = this.Tu.insert(e, {
|
|
14031
14034
|
type: 1 /* Removed */ ,
|
|
14032
14035
|
doc: n.doc
|
|
14033
|
-
}) : 0 /* Added */ === t.type && 1 /* Removed */ === n.type ? this.
|
|
14036
|
+
}) : 0 /* Added */ === t.type && 1 /* Removed */ === n.type ? this.Tu = this.Tu.insert(e, {
|
|
14034
14037
|
type: 2 /* Modified */ ,
|
|
14035
14038
|
doc: t.doc
|
|
14036
14039
|
}) :
|
|
@@ -14041,11 +14044,11 @@ class $u {
|
|
|
14041
14044
|
// Removed->Modified
|
|
14042
14045
|
// Metadata->Added
|
|
14043
14046
|
// Removed->Metadata
|
|
14044
|
-
M() : this.
|
|
14047
|
+
M() : this.Tu = this.Tu.insert(e, t);
|
|
14045
14048
|
}
|
|
14046
|
-
|
|
14049
|
+
Eu() {
|
|
14047
14050
|
const t = [];
|
|
14048
|
-
return this.
|
|
14051
|
+
return this.Tu.inorderTraversal(((e, n) => {
|
|
14049
14052
|
t.push(n);
|
|
14050
14053
|
})), t;
|
|
14051
14054
|
}
|
|
@@ -14101,14 +14104,14 @@ class qu {
|
|
|
14101
14104
|
* tracked by EventManager.
|
|
14102
14105
|
*/ class Ku {
|
|
14103
14106
|
constructor() {
|
|
14104
|
-
this.
|
|
14107
|
+
this.Au = void 0, this.listeners = [];
|
|
14105
14108
|
}
|
|
14106
14109
|
}
|
|
14107
14110
|
|
|
14108
14111
|
class Gu {
|
|
14109
14112
|
constructor() {
|
|
14110
14113
|
this.queries = new ss((t => dn(t)), fn), this.onlineState = "Unknown" /* Unknown */ ,
|
|
14111
|
-
this.
|
|
14114
|
+
this.Ru = new Set;
|
|
14112
14115
|
}
|
|
14113
14116
|
}
|
|
14114
14117
|
|
|
@@ -14116,15 +14119,15 @@ async function Qu(t, e) {
|
|
|
14116
14119
|
const n = B(t), s = e.query;
|
|
14117
14120
|
let i = !1, r = n.queries.get(s);
|
|
14118
14121
|
if (r || (i = !0, r = new Ku), i) try {
|
|
14119
|
-
r.
|
|
14122
|
+
r.Au = await n.onListen(s);
|
|
14120
14123
|
} catch (t) {
|
|
14121
14124
|
const n = Bu(t, `Initialization of query '${_n(e.query)}' failed`);
|
|
14122
14125
|
return void e.onError(n);
|
|
14123
14126
|
}
|
|
14124
14127
|
if (n.queries.set(s, r), r.listeners.push(e),
|
|
14125
14128
|
// Run global snapshot listeners if a consistent snapshot has been emitted.
|
|
14126
|
-
e.
|
|
14127
|
-
e.
|
|
14129
|
+
e.bu(n.onlineState), r.Au) {
|
|
14130
|
+
e.Pu(r.Au) && Hu(n);
|
|
14128
14131
|
}
|
|
14129
14132
|
}
|
|
14130
14133
|
|
|
@@ -14145,8 +14148,8 @@ function Wu(t, e) {
|
|
|
14145
14148
|
for (const t of e) {
|
|
14146
14149
|
const e = t.query, i = n.queries.get(e);
|
|
14147
14150
|
if (i) {
|
|
14148
|
-
for (const e of i.listeners) e.
|
|
14149
|
-
i.
|
|
14151
|
+
for (const e of i.listeners) e.Pu(t) && (s = !0);
|
|
14152
|
+
i.Au = t;
|
|
14150
14153
|
}
|
|
14151
14154
|
}
|
|
14152
14155
|
s && Hu(n);
|
|
@@ -14162,7 +14165,7 @@ function zu(t, e, n) {
|
|
|
14162
14165
|
|
|
14163
14166
|
// Call all global snapshot listeners that have been set.
|
|
14164
14167
|
function Hu(t) {
|
|
14165
|
-
t.
|
|
14168
|
+
t.Ru.forEach((t => {
|
|
14166
14169
|
t.next();
|
|
14167
14170
|
}));
|
|
14168
14171
|
}
|
|
@@ -14174,19 +14177,19 @@ function Hu(t) {
|
|
|
14174
14177
|
* It uses an Observer to dispatch events.
|
|
14175
14178
|
*/ class Ju {
|
|
14176
14179
|
constructor(t, e, n) {
|
|
14177
|
-
this.query = t, this.
|
|
14180
|
+
this.query = t, this.vu = e,
|
|
14178
14181
|
/**
|
|
14179
14182
|
* Initial snapshots (e.g. from cache) may not be propagated to the wrapped
|
|
14180
14183
|
* observer. This flag is set to true once we've actually raised an event.
|
|
14181
14184
|
*/
|
|
14182
|
-
this.
|
|
14185
|
+
this.Vu = !1, this.Su = null, this.onlineState = "Unknown" /* Unknown */ , this.options = n || {};
|
|
14183
14186
|
}
|
|
14184
14187
|
/**
|
|
14185
14188
|
* Applies the new ViewSnapshot to this listener, raising a user-facing event
|
|
14186
14189
|
* if applicable (depending on what changed, whether the user has opted into
|
|
14187
14190
|
* metadata-only changes, etc.). Returns true if a user-facing event was
|
|
14188
14191
|
* indeed raised.
|
|
14189
|
-
*/
|
|
14192
|
+
*/ Pu(t) {
|
|
14190
14193
|
if (!this.options.includeMetadataChanges) {
|
|
14191
14194
|
// Remove the metadata only changes.
|
|
14192
14195
|
const e = [];
|
|
@@ -14195,19 +14198,19 @@ function Hu(t) {
|
|
|
14195
14198
|
/* excludesMetadataChanges= */ !0, t.hasCachedResults);
|
|
14196
14199
|
}
|
|
14197
14200
|
let e = !1;
|
|
14198
|
-
return this.
|
|
14199
|
-
e = !0), this.
|
|
14201
|
+
return this.Vu ? this.Du(t) && (this.vu.next(t), e = !0) : this.Cu(t, this.onlineState) && (this.xu(t),
|
|
14202
|
+
e = !0), this.Su = t, e;
|
|
14200
14203
|
}
|
|
14201
14204
|
onError(t) {
|
|
14202
|
-
this.
|
|
14205
|
+
this.vu.error(t);
|
|
14203
14206
|
}
|
|
14204
|
-
/** Returns whether a snapshot was raised. */
|
|
14207
|
+
/** Returns whether a snapshot was raised. */ bu(t) {
|
|
14205
14208
|
this.onlineState = t;
|
|
14206
14209
|
let e = !1;
|
|
14207
|
-
return this.
|
|
14210
|
+
return this.Su && !this.Vu && this.Cu(this.Su, t) && (this.xu(this.Su), e = !0),
|
|
14208
14211
|
e;
|
|
14209
14212
|
}
|
|
14210
|
-
|
|
14213
|
+
Cu(t, e) {
|
|
14211
14214
|
// Always raise the first event when we're synced
|
|
14212
14215
|
if (!t.fromCache) return !0;
|
|
14213
14216
|
// NOTE: We consider OnlineState.Unknown as online (it should become Offline
|
|
@@ -14215,25 +14218,25 @@ function Hu(t) {
|
|
|
14215
14218
|
const n = "Offline" /* Offline */ !== e;
|
|
14216
14219
|
// Don't raise the event if we're online, aren't synced yet (checked
|
|
14217
14220
|
// above) and are waiting for a sync.
|
|
14218
|
-
return (!this.options.
|
|
14221
|
+
return (!this.options.Nu || !n) && (!t.docs.isEmpty() || t.hasCachedResults || "Offline" /* Offline */ === e);
|
|
14219
14222
|
// Raise data from cache if we have any documents, have cached results before,
|
|
14220
14223
|
// or we are offline.
|
|
14221
14224
|
}
|
|
14222
|
-
|
|
14225
|
+
Du(t) {
|
|
14223
14226
|
// We don't need to handle includeDocumentMetadataChanges here because
|
|
14224
14227
|
// the Metadata only changes have already been stripped out if needed.
|
|
14225
14228
|
// At this point the only changes we will see are the ones we should
|
|
14226
14229
|
// propagate.
|
|
14227
14230
|
if (t.docChanges.length > 0) return !0;
|
|
14228
|
-
const e = this.
|
|
14231
|
+
const e = this.Su && this.Su.hasPendingWrites !== t.hasPendingWrites;
|
|
14229
14232
|
return !(!t.syncStateChanged && !e) && !0 === this.options.includeMetadataChanges;
|
|
14230
14233
|
// Generally we should have hit one of the cases above, but it's possible
|
|
14231
14234
|
// to get here if there were only metadata docChanges and they got
|
|
14232
14235
|
// stripped out.
|
|
14233
14236
|
}
|
|
14234
|
-
|
|
14237
|
+
xu(t) {
|
|
14235
14238
|
t = qu.fromInitialDocuments(t.query, t.docs, t.mutatedKeys, t.fromCache, t.hasCachedResults),
|
|
14236
|
-
this.
|
|
14239
|
+
this.Vu = !0, this.vu.next(t);
|
|
14237
14240
|
}
|
|
14238
14241
|
}
|
|
14239
14242
|
|
|
@@ -14260,10 +14263,10 @@ function Hu(t) {
|
|
|
14260
14263
|
constructor(t,
|
|
14261
14264
|
// How many bytes this element takes to store in the bundle.
|
|
14262
14265
|
e) {
|
|
14263
|
-
this.
|
|
14266
|
+
this.ku = t, this.byteLength = e;
|
|
14264
14267
|
}
|
|
14265
14268
|
Ou() {
|
|
14266
|
-
return "metadata" in this.
|
|
14269
|
+
return "metadata" in this.ku;
|
|
14267
14270
|
}
|
|
14268
14271
|
}
|
|
14269
14272
|
|
|
@@ -14323,13 +14326,13 @@ function Hu(t) {
|
|
|
14323
14326
|
*/ Fu(t) {
|
|
14324
14327
|
this.progress.bytesLoaded += t.byteLength;
|
|
14325
14328
|
let e = this.progress.documentsLoaded;
|
|
14326
|
-
if (t.
|
|
14329
|
+
if (t.ku.namedQuery) this.queries.push(t.ku.namedQuery); else if (t.ku.documentMetadata) {
|
|
14327
14330
|
this.documents.push({
|
|
14328
|
-
metadata: t.
|
|
14329
|
-
}), t.
|
|
14330
|
-
const n = ot.fromString(t.
|
|
14331
|
+
metadata: t.ku.documentMetadata
|
|
14332
|
+
}), t.ku.documentMetadata.exists || ++e;
|
|
14333
|
+
const n = ot.fromString(t.ku.documentMetadata.name);
|
|
14331
14334
|
this.collectionGroups.add(n.get(n.length - 2));
|
|
14332
|
-
} else t.
|
|
14335
|
+
} else t.ku.document && (this.documents[this.documents.length - 1].document = t.ku.document,
|
|
14333
14336
|
++e);
|
|
14334
14337
|
return e !== this.progress.documentsLoaded ? (this.progress.documentsLoaded = e,
|
|
14335
14338
|
Object.assign({}, this.progress)) : null;
|
|
@@ -14522,7 +14525,7 @@ class nc {
|
|
|
14522
14525
|
const s = this.Qu;
|
|
14523
14526
|
this.Qu = t.Qu, this.mutatedKeys = t.mutatedKeys;
|
|
14524
14527
|
// Sort changes based on type and query comparator
|
|
14525
|
-
const i = t.zu.
|
|
14528
|
+
const i = t.zu.Eu();
|
|
14526
14529
|
i.sort(((t, e) => function(t, e) {
|
|
14527
14530
|
const n = t => {
|
|
14528
14531
|
switch (t) {
|
|
@@ -14577,7 +14580,7 @@ class nc {
|
|
|
14577
14580
|
/**
|
|
14578
14581
|
* Applies an OnlineState change to the view, potentially generating a
|
|
14579
14582
|
* ViewChange if the view's syncState changes as a result.
|
|
14580
|
-
*/
|
|
14583
|
+
*/ bu(t) {
|
|
14581
14584
|
return this.current && "Offline" /* Offline */ === t ? (
|
|
14582
14585
|
// If we're offline, set `current` to false and then call applyChanges()
|
|
14583
14586
|
// to refresh our syncState and generate a ViewChange as appropriate. We
|
|
@@ -14928,7 +14931,7 @@ async function uc(t, e) {
|
|
|
14928
14931
|
if (s.isPrimaryClient && 0 /* RemoteStore */ === n || !s.isPrimaryClient && 1 /* SharedClientState */ === n) {
|
|
14929
14932
|
const t = [];
|
|
14930
14933
|
s.ic.forEach(((n, s) => {
|
|
14931
|
-
const i = s.view.
|
|
14934
|
+
const i = s.view.bu(e);
|
|
14932
14935
|
i.snapshot && t.push(i.snapshot);
|
|
14933
14936
|
})), function(t, e) {
|
|
14934
14937
|
const n = B(t);
|
|
@@ -14937,9 +14940,9 @@ async function uc(t, e) {
|
|
|
14937
14940
|
n.queries.forEach(((t, n) => {
|
|
14938
14941
|
for (const t of n.listeners)
|
|
14939
14942
|
// Run global snapshot listeners if a consistent snapshot has been emitted.
|
|
14940
|
-
t.
|
|
14943
|
+
t.bu(e) && (s = !0);
|
|
14941
14944
|
})), s && Hu(n);
|
|
14942
|
-
}(s.eventManager, e), t.length && s.sc.
|
|
14945
|
+
}(s.eventManager, e), t.length && s.sc.Wo(t), s.onlineState = e, s.isPrimaryClient && s.sharedClientState.setOnlineState(e);
|
|
14943
14946
|
}
|
|
14944
14947
|
}
|
|
14945
14948
|
|
|
@@ -15135,7 +15138,7 @@ async function Rc(t, e, n) {
|
|
|
15135
15138
|
r.push(e);
|
|
15136
15139
|
}
|
|
15137
15140
|
})));
|
|
15138
|
-
})), await Promise.all(o), s.sc.
|
|
15141
|
+
})), await Promise.all(o), s.sc.Wo(i), await async function(t, e) {
|
|
15139
15142
|
const n = B(t);
|
|
15140
15143
|
try {
|
|
15141
15144
|
await n.persistence.runTransaction("notifyLocalViewChanges", "readwrite", (t => Rt.forEach(e, (e => Rt.forEach(e.Si, (s => n.persistence.referenceDelegate.addReference(t, e.targetId, s))).next((() => Rt.forEach(e.Di, (s => n.persistence.referenceDelegate.removeReference(t, e.targetId, s)))))))));
|
|
@@ -15310,7 +15313,7 @@ async function Cc(t, e, n) {
|
|
|
15310
15313
|
}
|
|
15311
15314
|
i.push(e);
|
|
15312
15315
|
}
|
|
15313
|
-
return s.sc.
|
|
15316
|
+
return s.sc.Wo(r), i;
|
|
15314
15317
|
}
|
|
15315
15318
|
|
|
15316
15319
|
/**
|
|
@@ -15391,7 +15394,7 @@ async function kc(t, e, n, s) {
|
|
|
15391
15394
|
function Mc(t) {
|
|
15392
15395
|
const e = B(t);
|
|
15393
15396
|
return e.remoteStore.remoteSyncer.applyRemoteEvent = lc.bind(null, e), e.remoteStore.remoteSyncer.getRemoteKeysForTarget = Pc.bind(null, e),
|
|
15394
|
-
e.remoteStore.remoteSyncer.rejectListen = dc.bind(null, e), e.sc.
|
|
15397
|
+
e.remoteStore.remoteSyncer.rejectListen = dc.bind(null, e), e.sc.Wo = Wu.bind(null, e.eventManager),
|
|
15395
15398
|
e.sc.wc = zu.bind(null, e.eventManager), e;
|
|
15396
15399
|
}
|
|
15397
15400
|
|
|
@@ -15618,11 +15621,11 @@ class Bc {
|
|
|
15618
15621
|
terminate() {
|
|
15619
15622
|
return async function(t) {
|
|
15620
15623
|
const e = B(t);
|
|
15621
|
-
x("RemoteStore", "RemoteStore shutting down."), e.
|
|
15622
|
-
e.
|
|
15624
|
+
x("RemoteStore", "RemoteStore shutting down."), e._u.add(5 /* Shutdown */), await lu(e),
|
|
15625
|
+
e.mu.shutdown(),
|
|
15623
15626
|
// Set the OnlineState to Unknown (rather than Offline) to avoid potentially
|
|
15624
15627
|
// triggering spurious listener events with cached data, etc.
|
|
15625
|
-
e.
|
|
15628
|
+
e.gu.set("Unknown" /* Unknown */);
|
|
15626
15629
|
}(this.remoteStore);
|
|
15627
15630
|
}
|
|
15628
15631
|
}
|
|
@@ -16185,7 +16188,7 @@ class aa {
|
|
|
16185
16188
|
this.observer.next && this.Rc(this.observer.next, t);
|
|
16186
16189
|
}
|
|
16187
16190
|
error(t) {
|
|
16188
|
-
this.observer.error ? this.Rc(this.observer.error, t) : N("Uncaught Error in snapshot listener:", t);
|
|
16191
|
+
this.observer.error ? this.Rc(this.observer.error, t) : N("Uncaught Error in snapshot listener:", t.toString());
|
|
16189
16192
|
}
|
|
16190
16193
|
bc() {
|
|
16191
16194
|
this.muted = !0;
|
|
@@ -16232,7 +16235,7 @@ class aa {
|
|
|
16232
16235
|
this.buffer = new Uint8Array, this.vc = new TextDecoder("utf-8"),
|
|
16233
16236
|
// Read the metadata (which is the first element).
|
|
16234
16237
|
this.Vc().then((t => {
|
|
16235
|
-
t && t.Ou() ? this.metadata.resolve(t.
|
|
16238
|
+
t && t.Ou() ? this.metadata.resolve(t.ku.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.ku)}`));
|
|
16236
16239
|
}), (t => this.metadata.reject(t)));
|
|
16237
16240
|
}
|
|
16238
16241
|
close() {
|
|
@@ -16562,13 +16565,13 @@ class la {
|
|
|
16562
16565
|
*/ class wa {
|
|
16563
16566
|
constructor(t, e, n, s, i) {
|
|
16564
16567
|
this.asyncQueue = t, this.datastore = e, this.options = n, this.updateFunction = s,
|
|
16565
|
-
this.deferred = i, this.kc = n.maxAttempts, this.
|
|
16568
|
+
this.deferred = i, this.kc = n.maxAttempts, this.xo = new nu(this.asyncQueue, "transaction_retry" /* TransactionRetry */);
|
|
16566
16569
|
}
|
|
16567
16570
|
/** Runs the transaction and sets the result on deferred. */ run() {
|
|
16568
16571
|
this.kc -= 1, this.Oc();
|
|
16569
16572
|
}
|
|
16570
16573
|
Oc() {
|
|
16571
|
-
this.
|
|
16574
|
+
this.xo.Ro((async () => {
|
|
16572
16575
|
const t = new _a(this.datastore), e = this.Mc(t);
|
|
16573
16576
|
e && e.then((e => {
|
|
16574
16577
|
this.asyncQueue.enqueueAndForget((() => t.commit().then((() => {
|
|
@@ -16600,7 +16603,7 @@ class la {
|
|
|
16600
16603
|
// In transactions, the backend will fail outdated reads with FAILED_PRECONDITION and
|
|
16601
16604
|
// non-matching document versions with ABORTED. These errors should be retried.
|
|
16602
16605
|
const e = t.code;
|
|
16603
|
-
return "aborted" === e || "failed-precondition" === e || !es(e);
|
|
16606
|
+
return "aborted" === e || "failed-precondition" === e || "already-exists" === e || !es(e);
|
|
16604
16607
|
}
|
|
16605
16608
|
return !1;
|
|
16606
16609
|
}
|
|
@@ -16753,7 +16756,7 @@ async function Pa(t) {
|
|
|
16753
16756
|
const e = await Ta(t), n = await Aa(t);
|
|
16754
16757
|
return e.setNetworkEnabled(!0), function(t) {
|
|
16755
16758
|
const e = B(t);
|
|
16756
|
-
return e.
|
|
16759
|
+
return e._u.delete(0 /* UserDisabled */), hu(e);
|
|
16757
16760
|
}(n);
|
|
16758
16761
|
}));
|
|
16759
16762
|
}
|
|
@@ -16763,9 +16766,9 @@ async function Pa(t) {
|
|
|
16763
16766
|
const e = await Ta(t), n = await Aa(t);
|
|
16764
16767
|
return e.setNetworkEnabled(!1), async function(t) {
|
|
16765
16768
|
const e = B(t);
|
|
16766
|
-
e.
|
|
16769
|
+
e._u.add(0 /* UserDisabled */), await lu(e),
|
|
16767
16770
|
// Set the OnlineState to Offline so get()s return from cache, etc.
|
|
16768
|
-
e.
|
|
16771
|
+
e.gu.set("Offline" /* Offline */);
|
|
16769
16772
|
}(n);
|
|
16770
16773
|
}));
|
|
16771
16774
|
}
|
|
@@ -16816,7 +16819,7 @@ function Da(t, e, n = {}) {
|
|
|
16816
16819
|
error: t => i.reject(t)
|
|
16817
16820
|
}), o = new Ju(sn(n.path), r, {
|
|
16818
16821
|
includeMetadataChanges: !0,
|
|
16819
|
-
|
|
16822
|
+
Nu: !0
|
|
16820
16823
|
});
|
|
16821
16824
|
return Qu(t, o);
|
|
16822
16825
|
}(await Pa(t), t.asyncQueue, e, n, s))), s.promise;
|
|
@@ -16853,7 +16856,7 @@ function xa(t, e, n = {}) {
|
|
|
16853
16856
|
error: t => i.reject(t)
|
|
16854
16857
|
}), o = new Ju(n, r, {
|
|
16855
16858
|
includeMetadataChanges: !0,
|
|
16856
|
-
|
|
16859
|
+
Nu: !0
|
|
16857
16860
|
});
|
|
16858
16861
|
return Qu(t, o);
|
|
16859
16862
|
}(await Pa(t), t.asyncQueue, e, n, s))), s.promise;
|
|
@@ -16862,13 +16865,13 @@ function xa(t, e, n = {}) {
|
|
|
16862
16865
|
function Na(t, e) {
|
|
16863
16866
|
const n = new aa(e);
|
|
16864
16867
|
return t.asyncQueue.enqueueAndForget((async () => function(t, e) {
|
|
16865
|
-
B(t).
|
|
16868
|
+
B(t).Ru.add(e),
|
|
16866
16869
|
// Immediately fire an initial event, indicating all existing listeners
|
|
16867
16870
|
// are in-sync.
|
|
16868
16871
|
e.next();
|
|
16869
16872
|
}(await Pa(t), n))), () => {
|
|
16870
16873
|
n.bc(), t.asyncQueue.enqueueAndForget((async () => function(t, e) {
|
|
16871
|
-
B(t).
|
|
16874
|
+
B(t).Ru.delete(e);
|
|
16872
16875
|
}(await Pa(t), n)));
|
|
16873
16876
|
};
|
|
16874
16877
|
}
|
|
@@ -16951,13 +16954,13 @@ class Ma {
|
|
|
16951
16954
|
// List of TimerIds to fast-forward delays for.
|
|
16952
16955
|
this.jc = [],
|
|
16953
16956
|
// Backoff timer used to schedule retries for retryable operations
|
|
16954
|
-
this.
|
|
16957
|
+
this.xo = new nu(this, "async_queue_retry" /* AsyncQueueRetry */),
|
|
16955
16958
|
// Visibility handler that triggers an immediate retry of all retryable
|
|
16956
16959
|
// operations. Meant to speed up recovery when we regain file system access
|
|
16957
16960
|
// after page comes into foreground.
|
|
16958
16961
|
this.Wc = () => {
|
|
16959
16962
|
const t = tu();
|
|
16960
|
-
t && x("AsyncQueue", "Visibility state changed to " + t.visibilityState), this.
|
|
16963
|
+
t && x("AsyncQueue", "Visibility state changed to " + t.visibilityState), this.xo.Po();
|
|
16961
16964
|
};
|
|
16962
16965
|
const t = tu();
|
|
16963
16966
|
t && "function" == typeof t.addEventListener && t.addEventListener("visibilitychange", this.Wc);
|
|
@@ -17004,7 +17007,7 @@ class Ma {
|
|
|
17004
17007
|
*/ async Jc() {
|
|
17005
17008
|
if (0 !== this.Lc.length) {
|
|
17006
17009
|
try {
|
|
17007
|
-
await this.Lc[0](), this.Lc.shift(), this.
|
|
17010
|
+
await this.Lc[0](), this.Lc.shift(), this.xo.reset();
|
|
17008
17011
|
} catch (t) {
|
|
17009
17012
|
if (!St(t)) throw t;
|
|
17010
17013
|
// Failure will be handled by AsyncQueue
|
|
@@ -17021,7 +17024,7 @@ class Ma {
|
|
|
17021
17024
|
// Since `backoffAndRun()` cancels an existing backoff and schedules a
|
|
17022
17025
|
// new backoff on every call, there is only ever a single additional
|
|
17023
17026
|
// operation in the queue.
|
|
17024
|
-
this.
|
|
17027
|
+
this.xo.Ro((() => this.Jc()));
|
|
17025
17028
|
}
|
|
17026
17029
|
}
|
|
17027
17030
|
Hc(t) {
|
|
@@ -19134,12 +19137,15 @@ class il extends nl {
|
|
|
19134
19137
|
function(t, e) {
|
|
19135
19138
|
if (t._snapshot.oldDocs.isEmpty()) {
|
|
19136
19139
|
let e = 0;
|
|
19137
|
-
return t._snapshot.docChanges.map((n =>
|
|
19138
|
-
|
|
19139
|
-
|
|
19140
|
-
|
|
19141
|
-
|
|
19142
|
-
|
|
19140
|
+
return t._snapshot.docChanges.map((n => {
|
|
19141
|
+
const s = new ul(t._firestore, t._userDataWriter, n.doc.key, n.doc, new rl(t._snapshot.mutatedKeys.has(n.doc.key), t._snapshot.fromCache), t.query.converter);
|
|
19142
|
+
return n.doc, {
|
|
19143
|
+
type: "added",
|
|
19144
|
+
doc: s,
|
|
19145
|
+
oldIndex: -1,
|
|
19146
|
+
newIndex: e++
|
|
19147
|
+
};
|
|
19148
|
+
}));
|
|
19143
19149
|
}
|
|
19144
19150
|
{
|
|
19145
19151
|
// A `DocumentSet` that is updated incrementally as changes are applied to use
|
|
@@ -19981,9 +19987,9 @@ function Ll(t, e) {
|
|
|
19981
19987
|
return s = Object.assign({
|
|
19982
19988
|
useFetchStreams: e
|
|
19983
19989
|
}, s), r._setSettings(s), r;
|
|
19984
|
-
}), "PUBLIC").setMultipleInstances(!0)), s(P, "3.7.
|
|
19990
|
+
}), "PUBLIC").setMultipleInstances(!0)), s(P, "3.7.2-canary.457fc2eeb", t),
|
|
19985
19991
|
// BUILD_TARGET will be replaced by values like esm5, esm2017, cjs5, etc during the compilation
|
|
19986
|
-
s(P, "3.7.
|
|
19992
|
+
s(P, "3.7.2-canary.457fc2eeb", "esm2017");
|
|
19987
19993
|
}("rn", /* useFetchStreams= */ !1);
|
|
19988
19994
|
|
|
19989
19995
|
export { nl as AbstractUserDataWriter, la as AggregateField, fa as AggregateQuerySnapshot, nh as Bytes, Ba as CACHE_SIZE_UNLIMITED, na as CollectionReference, ta as DocumentReference, ol as DocumentSnapshot, sh as FieldPath, rh as FieldValue, La as Firestore, U as FirestoreError, oh as GeoPoint, $a as LoadBundleTask, ea as Query, Fh as QueryConstraint, ul as QueryDocumentSnapshot, cl as QuerySnapshot, rl as SnapshotMetadata, st as Timestamp, Cl as Transaction, Sl as WriteBatch, ie as _DatabaseId, at as _DocumentKey, Y as _EmptyAppCheckTokenProvider, G as _EmptyAuthCredentialsProvider, ct as _FieldPath, zc as _cast, $ as _debugAssert, zt as _isBase64Available, k as _logWarn, Gc as _validateIsNotUsedTogether, Tl as addDoc, Pl as aggregateQuerySnapshotEqual, Ml as arrayRemove, Ol as arrayUnion, za as clearIndexedDbPersistence, sa as collection, ia as collectionGroup, Zc as connectFirestoreEmulator, Il as deleteDoc, Nl as deleteField, Ya as disableNetwork, ra as doc, ih as documentId, Qa as enableIndexedDbPersistence, ja as enableMultiTabIndexedDbPersistence, Ja as enableNetwork, Yh as endAt, Jh as endBefore, Ka as ensureFirestoreConfigured, Rl as executeWrite, vl as getCountFromServer, ll as getDoc, dl as getDocFromCache, _l as getDocFromServer, wl as getDocs, ml as getDocsFromCache, gl as getDocsFromServer, qa as getFirestore, Fl as increment, Ua as initializeFirestore, Gh as limit, Qh as limitToLast, Za as loadBundle, th as namedQuery, El as onSnapshot, Al as onSnapshotsInSync, qh as orderBy, $h as query, ua as queryEqual, oa as refEqual, xl as runTransaction, kl as serverTimestamp, yl as setDoc, Bl as setIndexConfiguration, C as setLogLevel, hl as snapshotEqual, zh as startAfter, Wh as startAt, Xa as terminate, pl as updateDoc, Ha as waitForPendingWrites, Lh as where, $l as writeBatch };
|