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