@firebase/firestore 3.1.1 → 3.2.0
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/firestore/src/register.d.ts +1 -1
- package/dist/firestore/src/remote/persistent_stream.d.ts +5 -1
- package/dist/firestore/src/util/async_queue.d.ts +4 -2
- package/dist/index.esm2017.js +1055 -1047
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +1483 -1474
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +7049 -9102
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/{index.node.cjs.esm2017.js → index.node.mjs} +51 -20
- package/dist/index.node.mjs.map +1 -0
- package/dist/index.rn.js +534 -526
- package/dist/index.rn.js.map +1 -1
- package/dist/internal.d.ts +4 -2
- package/dist/lite/firestore/src/register.d.ts +1 -1
- package/dist/lite/firestore/src/remote/persistent_stream.d.ts +5 -1
- package/dist/lite/firestore/src/util/async_queue.d.ts +4 -2
- package/dist/lite/index.browser.esm2017.js +2 -2
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.browser.esm5.js +2 -2
- package/dist/lite/index.browser.esm5.js.map +1 -1
- package/dist/lite/index.node.cjs.js +1804 -2261
- package/dist/lite/index.node.cjs.js.map +1 -1
- package/dist/lite/{index.node.esm2017.js → index.node.mjs} +3 -3
- package/dist/lite/index.node.mjs.map +1 -0
- package/dist/lite/index.rn.esm2017.js +2 -2
- package/dist/lite/index.rn.esm2017.js.map +1 -1
- package/dist/lite/internal.d.ts +4 -2
- package/dist/lite/packages/firestore/src/register.d.ts +1 -1
- package/dist/lite/packages/firestore/src/remote/persistent_stream.d.ts +5 -1
- package/dist/lite/packages/firestore/src/util/async_queue.d.ts +4 -2
- package/dist/lite/private.d.ts +4 -2
- package/dist/packages/firestore/dist/index.esm2017.d.ts +102 -102
- package/dist/packages/firestore/src/register.d.ts +1 -1
- package/dist/packages/firestore/src/remote/persistent_stream.d.ts +5 -1
- package/dist/packages/firestore/src/util/async_queue.d.ts +4 -2
- package/dist/private.d.ts +4 -2
- package/lite/package.json +1 -1
- package/package.json +15 -9
- package/dist/index.node.cjs.esm2017.js.map +0 -1
- package/dist/lite/firestore/dist/lite/index.node.esm2017.d.ts +0 -1195
- package/dist/lite/index.node.esm2017.js.map +0 -1
- package/dist/packages/firestore/dist/index.node.cjs.esm2017.d.ts +0 -1844
package/dist/index.rn.js
CHANGED
|
@@ -70,7 +70,7 @@ C.MOCK_USER = new C("mock-user");
|
|
|
70
70
|
* See the License for the specific language governing permissions and
|
|
71
71
|
* limitations under the License.
|
|
72
72
|
*/
|
|
73
|
-
let N = "9.
|
|
73
|
+
let N = "9.2.0";
|
|
74
74
|
|
|
75
75
|
/**
|
|
76
76
|
* @license
|
|
@@ -11089,15 +11089,15 @@ class to {
|
|
|
11089
11089
|
* ListenerType: The type of the listener that will be used for callbacks
|
|
11090
11090
|
*/
|
|
11091
11091
|
class eo {
|
|
11092
|
-
constructor(t, e, n, s, i, r) {
|
|
11093
|
-
this.Oe = t, this.er = n, this.nr = s, this.
|
|
11094
|
-
this.state = 0 /* Initial */ ,
|
|
11092
|
+
constructor(t, e, n, s, i, r, o) {
|
|
11093
|
+
this.Oe = t, this.er = n, this.nr = s, this.sr = i, this.credentialsProvider = r,
|
|
11094
|
+
this.listener = o, this.state = 0 /* Initial */ ,
|
|
11095
11095
|
/**
|
|
11096
11096
|
* A close count that's incremented every time the stream is closed; used by
|
|
11097
11097
|
* getCloseGuardedDispatcher() to invalidate callbacks that happen after
|
|
11098
11098
|
* close.
|
|
11099
11099
|
*/
|
|
11100
|
-
this.
|
|
11100
|
+
this.ir = 0, this.rr = null, this.cr = null, this.stream = null, this.ar = new to(t, e);
|
|
11101
11101
|
}
|
|
11102
11102
|
/**
|
|
11103
11103
|
* Returns true if start() has been called and no error has occurred. True
|
|
@@ -11105,14 +11105,14 @@ class eo {
|
|
|
11105
11105
|
* encompasses respecting backoff, getting auth tokens, and starting the
|
|
11106
11106
|
* actual RPC). Use isOpen() to determine if the stream is open and ready for
|
|
11107
11107
|
* outbound requests.
|
|
11108
|
-
*/
|
|
11109
|
-
return 1 /* Starting */ === this.state ||
|
|
11108
|
+
*/ ur() {
|
|
11109
|
+
return 1 /* Starting */ === this.state || 5 /* Backoff */ === this.state || this.hr();
|
|
11110
11110
|
}
|
|
11111
11111
|
/**
|
|
11112
11112
|
* Returns true if the underlying RPC is open (the onOpen() listener has been
|
|
11113
11113
|
* called) and the stream is ready for outbound requests.
|
|
11114
|
-
*/
|
|
11115
|
-
return 2 /* Open */ === this.state;
|
|
11114
|
+
*/ hr() {
|
|
11115
|
+
return 2 /* Open */ === this.state || 3 /* Healthy */ === this.state;
|
|
11116
11116
|
}
|
|
11117
11117
|
/**
|
|
11118
11118
|
* Starts the RPC. Only allowed if isStarted() returns false. The stream is
|
|
@@ -11121,7 +11121,7 @@ class eo {
|
|
|
11121
11121
|
*
|
|
11122
11122
|
* When start returns, isStarted() will return true.
|
|
11123
11123
|
*/ start() {
|
|
11124
|
-
|
|
11124
|
+
4 /* Error */ !== this.state ? this.auth() : this.lr();
|
|
11125
11125
|
}
|
|
11126
11126
|
/**
|
|
11127
11127
|
* Stops the RPC. This call is idempotent and allowed regardless of the
|
|
@@ -11129,7 +11129,7 @@ class eo {
|
|
|
11129
11129
|
*
|
|
11130
11130
|
* When stop returns, isStarted() and isOpen() will both return false.
|
|
11131
11131
|
*/ async stop() {
|
|
11132
|
-
this.
|
|
11132
|
+
this.ur() && await this.close(0 /* Initial */);
|
|
11133
11133
|
}
|
|
11134
11134
|
/**
|
|
11135
11135
|
* After an error the stream will usually back off on the next attempt to
|
|
@@ -11138,8 +11138,8 @@ class eo {
|
|
|
11138
11138
|
*
|
|
11139
11139
|
* Each error will call the onClose() listener. That function can decide to
|
|
11140
11140
|
* inhibit backoff if required.
|
|
11141
|
-
*/
|
|
11142
|
-
this.state = 0 /* Initial */ , this.
|
|
11141
|
+
*/ dr() {
|
|
11142
|
+
this.state = 0 /* Initial */ , this.ar.reset();
|
|
11143
11143
|
}
|
|
11144
11144
|
/**
|
|
11145
11145
|
* Marks this stream as idle. If no further actions are performed on the
|
|
@@ -11150,22 +11150,25 @@ class eo {
|
|
|
11150
11150
|
*
|
|
11151
11151
|
* Only streams that are in state 'Open' can be marked idle, as all other
|
|
11152
11152
|
* states imply pending network operations.
|
|
11153
|
-
*/
|
|
11153
|
+
*/ wr() {
|
|
11154
11154
|
// Starts the idle time if we are in state 'Open' and are not yet already
|
|
11155
11155
|
// running a timer (in which case the previous idle timeout still applies).
|
|
11156
|
-
this.
|
|
11156
|
+
this.hr() && null === this.rr && (this.rr = this.Oe.enqueueAfterDelay(this.er, 6e4, (() => this._r())));
|
|
11157
11157
|
}
|
|
11158
|
-
/** Sends a message to the underlying stream. */
|
|
11159
|
-
this.
|
|
11158
|
+
/** Sends a message to the underlying stream. */ mr(t) {
|
|
11159
|
+
this.gr(), this.stream.send(t);
|
|
11160
11160
|
}
|
|
11161
|
-
/** Called by the idle timer when the stream should close due to inactivity. */ async
|
|
11162
|
-
if (this.
|
|
11161
|
+
/** Called by the idle timer when the stream should close due to inactivity. */ async _r() {
|
|
11162
|
+
if (this.hr())
|
|
11163
11163
|
// When timing out an idle stream there's no reason to force the stream into backoff when
|
|
11164
11164
|
// it restarts so set the stream state to Initial instead of Error.
|
|
11165
11165
|
return this.close(0 /* Initial */);
|
|
11166
11166
|
}
|
|
11167
|
-
/** Marks the stream as active again. */
|
|
11168
|
-
this.
|
|
11167
|
+
/** Marks the stream as active again. */ gr() {
|
|
11168
|
+
this.rr && (this.rr.cancel(), this.rr = null);
|
|
11169
|
+
}
|
|
11170
|
+
/** Cancels the health check delayed operation. */ yr() {
|
|
11171
|
+
this.cr && (this.cr.cancel(), this.cr = null);
|
|
11169
11172
|
}
|
|
11170
11173
|
/**
|
|
11171
11174
|
* Closes the stream and cleans up as necessary:
|
|
@@ -11181,20 +11184,24 @@ class eo {
|
|
|
11181
11184
|
* @param error - the error the connection was closed with.
|
|
11182
11185
|
*/ async close(t, e) {
|
|
11183
11186
|
// Cancel any outstanding timers (they're guaranteed not to execute).
|
|
11184
|
-
this.
|
|
11187
|
+
this.gr(), this.yr(), this.ar.cancel(),
|
|
11185
11188
|
// Invalidates any stream-related callbacks (e.g. from auth or the
|
|
11186
11189
|
// underlying stream), guaranteeing they won't execute.
|
|
11187
|
-
this.
|
|
11190
|
+
this.ir++, 4 /* Error */ !== t ?
|
|
11188
11191
|
// If this is an intentional close ensure we don't delay our next connection attempt.
|
|
11189
|
-
this.
|
|
11192
|
+
this.ar.reset() : e && e.code === j.RESOURCE_EXHAUSTED ? (
|
|
11190
11193
|
// Log the error. (Probably either 'quota exceeded' or 'max queue length reached'.)
|
|
11191
11194
|
F(e.toString()), F("Using maximum backoff delay to prevent overloading the backend."),
|
|
11192
|
-
this.
|
|
11193
|
-
// "unauthenticated" error means the token was rejected.
|
|
11194
|
-
//
|
|
11195
|
+
this.ar.Yi()) : e && e.code === j.UNAUTHENTICATED && 3 /* Healthy */ !== this.state &&
|
|
11196
|
+
// "unauthenticated" error means the token was rejected. This should rarely
|
|
11197
|
+
// happen since both Auth and AppCheck ensure a sufficient TTL when we
|
|
11198
|
+
// request a token. If a user manually resets their system clock this can
|
|
11199
|
+
// fail, however. In this case, we should get a Code.UNAUTHENTICATED error
|
|
11200
|
+
// before we received the first message and we need to invalidate the token
|
|
11201
|
+
// to ensure that we fetch a new token.
|
|
11195
11202
|
this.credentialsProvider.invalidateToken(),
|
|
11196
11203
|
// Clean up the underlying stream because we are no longer interested in events.
|
|
11197
|
-
null !== this.stream && (this.
|
|
11204
|
+
null !== this.stream && (this.pr(), this.stream.close(), this.stream = null),
|
|
11198
11205
|
// This state must be assigned before calling onClose() to allow the callback to
|
|
11199
11206
|
// inhibit backoff or otherwise manipulate the state in its non-started state.
|
|
11200
11207
|
this.state = t,
|
|
@@ -11204,59 +11211,60 @@ class eo {
|
|
|
11204
11211
|
/**
|
|
11205
11212
|
* Can be overridden to perform additional cleanup before the stream is closed.
|
|
11206
11213
|
* Calling super.tearDown() is not required.
|
|
11207
|
-
*/
|
|
11214
|
+
*/ pr() {}
|
|
11208
11215
|
auth() {
|
|
11209
11216
|
this.state = 1 /* Starting */;
|
|
11210
|
-
const t = this.
|
|
11217
|
+
const t = this.Tr(this.ir), e = this.ir;
|
|
11211
11218
|
// TODO(mikelehen): Just use dispatchIfNotClosed, but see TODO below.
|
|
11212
11219
|
this.credentialsProvider.getToken().then((t => {
|
|
11213
11220
|
// Stream can be stopped while waiting for authentication.
|
|
11214
11221
|
// TODO(mikelehen): We really should just use dispatchIfNotClosed
|
|
11215
11222
|
// and let this dispatch onto the queue, but that opened a spec test can
|
|
11216
11223
|
// of worms that I don't want to deal with in this PR.
|
|
11217
|
-
this.
|
|
11224
|
+
this.ir === e &&
|
|
11218
11225
|
// Normally we'd have to schedule the callback on the AsyncQueue.
|
|
11219
11226
|
// However, the following calls are safe to be called outside the
|
|
11220
11227
|
// AsyncQueue since they don't chain asynchronous calls
|
|
11221
|
-
this.
|
|
11228
|
+
this.Er(t);
|
|
11222
11229
|
}), (e => {
|
|
11223
11230
|
t((() => {
|
|
11224
11231
|
const t = new Q(j.UNKNOWN, "Fetching auth token failed: " + e.message);
|
|
11225
|
-
return this.
|
|
11232
|
+
return this.Ir(t);
|
|
11226
11233
|
}));
|
|
11227
11234
|
}));
|
|
11228
11235
|
}
|
|
11229
|
-
|
|
11230
|
-
const e = this.
|
|
11231
|
-
this.stream = this.
|
|
11232
|
-
e((() => (this.state = 2 /* Open */ , this.
|
|
11236
|
+
Er(t) {
|
|
11237
|
+
const e = this.Tr(this.ir);
|
|
11238
|
+
this.stream = this.Ar(t), this.stream.Si((() => {
|
|
11239
|
+
e((() => (this.state = 2 /* Open */ , this.cr = this.Oe.enqueueAfterDelay(this.nr, 1e4, (() => (this.hr() && (this.state = 3 /* Healthy */),
|
|
11240
|
+
Promise.resolve()))), this.listener.Si())));
|
|
11233
11241
|
})), this.stream.Ci((t => {
|
|
11234
|
-
e((() => this.
|
|
11242
|
+
e((() => this.Ir(t)));
|
|
11235
11243
|
})), this.stream.onMessage((t => {
|
|
11236
11244
|
e((() => this.onMessage(t)));
|
|
11237
11245
|
}));
|
|
11238
11246
|
}
|
|
11239
|
-
|
|
11240
|
-
this.state =
|
|
11247
|
+
lr() {
|
|
11248
|
+
this.state = 5 /* Backoff */ , this.ar.Xi((async () => {
|
|
11241
11249
|
this.state = 0 /* Initial */ , this.start();
|
|
11242
11250
|
}));
|
|
11243
11251
|
}
|
|
11244
11252
|
// Visible for tests
|
|
11245
|
-
|
|
11253
|
+
Ir(t) {
|
|
11246
11254
|
// In theory the stream could close cleanly, however, in our current model
|
|
11247
11255
|
// we never expect this to happen because if we stop a stream ourselves,
|
|
11248
11256
|
// this callback will never be called. To prevent cases where we retry
|
|
11249
11257
|
// without a backoff accidentally, we set the stream to error in all cases.
|
|
11250
|
-
return O("PersistentStream", `close with error: ${t}`), this.stream = null, this.close(
|
|
11258
|
+
return O("PersistentStream", `close with error: ${t}`), this.stream = null, this.close(4 /* Error */ , t);
|
|
11251
11259
|
}
|
|
11252
11260
|
/**
|
|
11253
11261
|
* Returns a "dispatcher" function that dispatches operations onto the
|
|
11254
11262
|
* AsyncQueue but only runs them if closeCount remains unchanged. This allows
|
|
11255
11263
|
* us to turn auth / stream callbacks into no-ops if the stream is closed /
|
|
11256
11264
|
* re-opened, etc.
|
|
11257
|
-
*/
|
|
11265
|
+
*/ Tr(t) {
|
|
11258
11266
|
return e => {
|
|
11259
|
-
this.Oe.enqueueAndForget((() => this.
|
|
11267
|
+
this.Oe.enqueueAndForget((() => this.ir === t ? e() : (O("PersistentStream", "stream callback skipped by getCloseGuardedDispatcher."),
|
|
11260
11268
|
Promise.resolve())));
|
|
11261
11269
|
};
|
|
11262
11270
|
}
|
|
@@ -11270,15 +11278,15 @@ class eo {
|
|
|
11270
11278
|
* sent from the server for ListenResponses.
|
|
11271
11279
|
*/ class no extends eo {
|
|
11272
11280
|
constructor(t, e, n, s, i) {
|
|
11273
|
-
super(t, "listen_stream_connection_backoff" /* ListenStreamConnectionBackoff */ , "listen_stream_idle" /* ListenStreamIdle */ , e, n, i),
|
|
11281
|
+
super(t, "listen_stream_connection_backoff" /* ListenStreamConnectionBackoff */ , "listen_stream_idle" /* ListenStreamIdle */ , "health_check_timeout" /* HealthCheckTimeout */ , e, n, i),
|
|
11274
11282
|
this.N = s;
|
|
11275
11283
|
}
|
|
11276
|
-
|
|
11277
|
-
return this.
|
|
11284
|
+
Ar(t) {
|
|
11285
|
+
return this.sr.ji("Listen", t);
|
|
11278
11286
|
}
|
|
11279
11287
|
onMessage(t) {
|
|
11280
11288
|
// A successful response means the stream is healthy
|
|
11281
|
-
this.
|
|
11289
|
+
this.ar.reset();
|
|
11282
11290
|
const e = is(this.N, t), n = function(t) {
|
|
11283
11291
|
// We have only reached a consistent snapshot for the entire stream if there
|
|
11284
11292
|
// is a read_time set and it applies to all targets (i.e. the list of
|
|
@@ -11287,14 +11295,14 @@ class eo {
|
|
|
11287
11295
|
const e = t.targetChange;
|
|
11288
11296
|
return e.targetIds && e.targetIds.length ? ot.min() : e.readTime ? Wn(e.readTime) : ot.min();
|
|
11289
11297
|
}(t);
|
|
11290
|
-
return this.listener.
|
|
11298
|
+
return this.listener.Rr(e, n);
|
|
11291
11299
|
}
|
|
11292
11300
|
/**
|
|
11293
11301
|
* Registers interest in the results of the given target. If the target
|
|
11294
11302
|
* includes a resumeToken it will be included in the request. Results that
|
|
11295
11303
|
* affect the target will be streamed back as WatchChange messages that
|
|
11296
11304
|
* reference the targetId.
|
|
11297
|
-
*/
|
|
11305
|
+
*/ br(t) {
|
|
11298
11306
|
const e = {};
|
|
11299
11307
|
e.database = Zn(this.N), e.addTarget = function(t, e) {
|
|
11300
11308
|
let n;
|
|
@@ -11310,14 +11318,14 @@ class eo {
|
|
|
11310
11318
|
n.readTime = Kn(t, e.snapshotVersion.toTimestamp())), n;
|
|
11311
11319
|
}(this.N, t);
|
|
11312
11320
|
const n = ls(this.N, t);
|
|
11313
|
-
n && (e.labels = n), this.
|
|
11321
|
+
n && (e.labels = n), this.mr(e);
|
|
11314
11322
|
}
|
|
11315
11323
|
/**
|
|
11316
11324
|
* Unregisters interest in the results of the target associated with the
|
|
11317
11325
|
* given targetId.
|
|
11318
|
-
*/
|
|
11326
|
+
*/ Pr(t) {
|
|
11319
11327
|
const e = {};
|
|
11320
|
-
e.database = Zn(this.N), e.removeTarget = t, this.
|
|
11328
|
+
e.database = Zn(this.N), e.removeTarget = t, this.mr(e);
|
|
11321
11329
|
}
|
|
11322
11330
|
}
|
|
11323
11331
|
|
|
@@ -11339,55 +11347,55 @@ class eo {
|
|
|
11339
11347
|
* TODO(b/33271235): Use proto types
|
|
11340
11348
|
*/ class so extends eo {
|
|
11341
11349
|
constructor(t, e, n, s, i) {
|
|
11342
|
-
super(t, "write_stream_connection_backoff" /* WriteStreamConnectionBackoff */ , "write_stream_idle" /* WriteStreamIdle */ , e, n, i),
|
|
11343
|
-
this.N = s, this.
|
|
11350
|
+
super(t, "write_stream_connection_backoff" /* WriteStreamConnectionBackoff */ , "write_stream_idle" /* WriteStreamIdle */ , "health_check_timeout" /* HealthCheckTimeout */ , e, n, i),
|
|
11351
|
+
this.N = s, this.vr = !1;
|
|
11344
11352
|
}
|
|
11345
11353
|
/**
|
|
11346
11354
|
* Tracks whether or not a handshake has been successfully exchanged and
|
|
11347
11355
|
* the stream is ready to accept mutations.
|
|
11348
|
-
*/ get
|
|
11349
|
-
return this.
|
|
11356
|
+
*/ get Vr() {
|
|
11357
|
+
return this.vr;
|
|
11350
11358
|
}
|
|
11351
11359
|
// Override of PersistentStream.start
|
|
11352
11360
|
start() {
|
|
11353
|
-
this.
|
|
11361
|
+
this.vr = !1, this.lastStreamToken = void 0, super.start();
|
|
11354
11362
|
}
|
|
11355
|
-
|
|
11356
|
-
this.
|
|
11363
|
+
pr() {
|
|
11364
|
+
this.vr && this.Sr([]);
|
|
11357
11365
|
}
|
|
11358
|
-
|
|
11359
|
-
return this.
|
|
11366
|
+
Ar(t) {
|
|
11367
|
+
return this.sr.ji("Write", t);
|
|
11360
11368
|
}
|
|
11361
11369
|
onMessage(t) {
|
|
11362
11370
|
if (
|
|
11363
11371
|
// Always capture the last stream token.
|
|
11364
|
-
U(!!t.streamToken), this.lastStreamToken = t.streamToken, this.
|
|
11372
|
+
U(!!t.streamToken), this.lastStreamToken = t.streamToken, this.vr) {
|
|
11365
11373
|
// A successful first write response means the stream is healthy,
|
|
11366
11374
|
// Note, that we could consider a successful handshake healthy, however,
|
|
11367
11375
|
// the write itself might be causing an error we want to back off from.
|
|
11368
|
-
this.
|
|
11376
|
+
this.ar.reset();
|
|
11369
11377
|
const e = cs(t.writeResults, t.commitTime), n = Wn(t.commitTime);
|
|
11370
|
-
return this.listener.
|
|
11378
|
+
return this.listener.Dr(n, e);
|
|
11371
11379
|
}
|
|
11372
11380
|
// The first response is always the handshake response
|
|
11373
|
-
return U(!t.writeResults || 0 === t.writeResults.length), this.
|
|
11381
|
+
return U(!t.writeResults || 0 === t.writeResults.length), this.vr = !0, this.listener.Cr();
|
|
11374
11382
|
}
|
|
11375
11383
|
/**
|
|
11376
11384
|
* Sends an initial streamToken to the server, performing the handshake
|
|
11377
11385
|
* required to make the StreamingWrite RPC work. Subsequent
|
|
11378
11386
|
* calls should wait until onHandshakeComplete was called.
|
|
11379
|
-
*/
|
|
11387
|
+
*/ Nr() {
|
|
11380
11388
|
// TODO(dimond): Support stream resumption. We intentionally do not set the
|
|
11381
11389
|
// stream token on the handshake, ignoring any stream token we might have.
|
|
11382
11390
|
const t = {};
|
|
11383
|
-
t.database = Zn(this.N), this.
|
|
11391
|
+
t.database = Zn(this.N), this.mr(t);
|
|
11384
11392
|
}
|
|
11385
|
-
/** Sends a group of mutations to the Firestore backend to apply. */
|
|
11393
|
+
/** Sends a group of mutations to the Firestore backend to apply. */ Sr(t) {
|
|
11386
11394
|
const e = {
|
|
11387
11395
|
streamToken: this.lastStreamToken,
|
|
11388
11396
|
writes: t.map((t => rs(this.N, t)))
|
|
11389
11397
|
};
|
|
11390
|
-
this.
|
|
11398
|
+
this.mr(e);
|
|
11391
11399
|
}
|
|
11392
11400
|
}
|
|
11393
11401
|
|
|
@@ -11418,25 +11426,25 @@ class eo {
|
|
|
11418
11426
|
*/
|
|
11419
11427
|
class io extends class {} {
|
|
11420
11428
|
constructor(t, e, n) {
|
|
11421
|
-
super(), this.credentials = t, this.
|
|
11429
|
+
super(), this.credentials = t, this.sr = e, this.N = n, this.kr = !1;
|
|
11422
11430
|
}
|
|
11423
|
-
|
|
11424
|
-
if (this.
|
|
11431
|
+
$r() {
|
|
11432
|
+
if (this.kr) throw new Q(j.FAILED_PRECONDITION, "The client has already been terminated.");
|
|
11425
11433
|
}
|
|
11426
11434
|
/** Gets an auth token and invokes the provided RPC. */ Li(t, e, n) {
|
|
11427
|
-
return this
|
|
11435
|
+
return this.$r(), this.credentials.getToken().then((s => this.sr.Li(t, e, n, s))).catch((t => {
|
|
11428
11436
|
throw "FirebaseError" === t.name ? (t.code === j.UNAUTHENTICATED && this.credentials.invalidateToken(),
|
|
11429
11437
|
t) : new Q(j.UNKNOWN, t.toString());
|
|
11430
11438
|
}));
|
|
11431
11439
|
}
|
|
11432
11440
|
/** Gets an auth token and invokes the provided RPC with streamed results. */ Ki(t, e, n) {
|
|
11433
|
-
return this
|
|
11441
|
+
return this.$r(), this.credentials.getToken().then((s => this.sr.Ki(t, e, n, s))).catch((t => {
|
|
11434
11442
|
throw "FirebaseError" === t.name ? (t.code === j.UNAUTHENTICATED && this.credentials.invalidateToken(),
|
|
11435
11443
|
t) : new Q(j.UNKNOWN, t.toString());
|
|
11436
11444
|
}));
|
|
11437
11445
|
}
|
|
11438
11446
|
terminate() {
|
|
11439
|
-
this.
|
|
11447
|
+
this.kr = !0;
|
|
11440
11448
|
}
|
|
11441
11449
|
}
|
|
11442
11450
|
|
|
@@ -11463,19 +11471,19 @@ class ro {
|
|
|
11463
11471
|
* maximum defined by MAX_WATCH_STREAM_FAILURES, we'll set the OnlineState to
|
|
11464
11472
|
* Offline.
|
|
11465
11473
|
*/
|
|
11466
|
-
this.
|
|
11474
|
+
this.Or = 0,
|
|
11467
11475
|
/**
|
|
11468
11476
|
* A timer that elapses after ONLINE_STATE_TIMEOUT_MS, at which point we
|
|
11469
11477
|
* transition from OnlineState.Unknown to OnlineState.Offline without waiting
|
|
11470
11478
|
* for the stream to actually fail (MAX_WATCH_STREAM_FAILURES times).
|
|
11471
11479
|
*/
|
|
11472
|
-
this.
|
|
11480
|
+
this.Fr = null,
|
|
11473
11481
|
/**
|
|
11474
11482
|
* Whether the client should log a warning message if it fails to connect to
|
|
11475
11483
|
* the backend (initially true, cleared after a successful stream, or if we've
|
|
11476
11484
|
* logged the message already).
|
|
11477
11485
|
*/
|
|
11478
|
-
this
|
|
11486
|
+
this.Mr = !0;
|
|
11479
11487
|
}
|
|
11480
11488
|
/**
|
|
11481
11489
|
* Called by RemoteStore when a watch stream is started (including on each
|
|
@@ -11483,9 +11491,9 @@ class ro {
|
|
|
11483
11491
|
*
|
|
11484
11492
|
* If this is the first attempt, it sets the OnlineState to Unknown and starts
|
|
11485
11493
|
* the onlineStateTimer.
|
|
11486
|
-
*/
|
|
11487
|
-
0 === this.
|
|
11488
|
-
this.
|
|
11494
|
+
*/ Lr() {
|
|
11495
|
+
0 === this.Or && (this.Br("Unknown" /* Unknown */), this.Fr = this.asyncQueue.enqueueAfterDelay("online_state_timeout" /* OnlineStateTimeout */ , 1e4, (() => (this.Fr = null,
|
|
11496
|
+
this.Ur("Backend didn't respond within 10 seconds."), this.Br("Offline" /* Offline */),
|
|
11489
11497
|
Promise.resolve()))));
|
|
11490
11498
|
}
|
|
11491
11499
|
/**
|
|
@@ -11493,10 +11501,10 @@ class ro {
|
|
|
11493
11501
|
* failure. The first failure moves us to the 'Unknown' state. We then may
|
|
11494
11502
|
* allow multiple failures (based on MAX_WATCH_STREAM_FAILURES) before we
|
|
11495
11503
|
* actually transition to the 'Offline' state.
|
|
11496
|
-
*/
|
|
11497
|
-
"Online" /* Online */ === this.state ? this.
|
|
11498
|
-
this.
|
|
11499
|
-
this.
|
|
11504
|
+
*/ qr(t) {
|
|
11505
|
+
"Online" /* Online */ === this.state ? this.Br("Unknown" /* Unknown */) : (this.Or++,
|
|
11506
|
+
this.Or >= 1 && (this.Kr(), this.Ur(`Connection failed 1 times. Most recent error: ${t.toString()}`),
|
|
11507
|
+
this.Br("Offline" /* Offline */)));
|
|
11500
11508
|
}
|
|
11501
11509
|
/**
|
|
11502
11510
|
* Explicitly sets the OnlineState to the specified state.
|
|
@@ -11505,20 +11513,20 @@ class ro {
|
|
|
11505
11513
|
* Offline heuristics, so must not be used in place of
|
|
11506
11514
|
* handleWatchStreamStart() and handleWatchStreamFailure().
|
|
11507
11515
|
*/ set(t) {
|
|
11508
|
-
this.
|
|
11516
|
+
this.Kr(), this.Or = 0, "Online" /* Online */ === t && (
|
|
11509
11517
|
// We've connected to watch at least once. Don't warn the developer
|
|
11510
11518
|
// about being offline going forward.
|
|
11511
|
-
this
|
|
11519
|
+
this.Mr = !1), this.Br(t);
|
|
11512
11520
|
}
|
|
11513
|
-
|
|
11521
|
+
Br(t) {
|
|
11514
11522
|
t !== this.state && (this.state = t, this.onlineStateHandler(t));
|
|
11515
11523
|
}
|
|
11516
|
-
|
|
11524
|
+
Ur(t) {
|
|
11517
11525
|
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.`;
|
|
11518
|
-
this
|
|
11526
|
+
this.Mr ? (F(e), this.Mr = !1) : O("OnlineStateTracker", e);
|
|
11519
11527
|
}
|
|
11520
|
-
|
|
11521
|
-
null !== this.
|
|
11528
|
+
Kr() {
|
|
11529
|
+
null !== this.Fr && (this.Fr.cancel(), this.Fr = null);
|
|
11522
11530
|
}
|
|
11523
11531
|
}
|
|
11524
11532
|
|
|
@@ -11563,7 +11571,7 @@ class ro {
|
|
|
11563
11571
|
* purely based on order, and so we can just shift() writes from the front of
|
|
11564
11572
|
* the writePipeline as we receive responses.
|
|
11565
11573
|
*/
|
|
11566
|
-
this.
|
|
11574
|
+
this.jr = [],
|
|
11567
11575
|
/**
|
|
11568
11576
|
* A mapping of watched targets that the client cares about tracking and the
|
|
11569
11577
|
* user has explicitly called a 'listen' for this target.
|
|
@@ -11573,12 +11581,12 @@ class ro {
|
|
|
11573
11581
|
* to the server. The targets removed with unlistens are removed eagerly
|
|
11574
11582
|
* without waiting for confirmation from the listen stream.
|
|
11575
11583
|
*/
|
|
11576
|
-
this.
|
|
11584
|
+
this.Qr = new Map,
|
|
11577
11585
|
/**
|
|
11578
11586
|
* A set of reasons for why the RemoteStore may be offline. If empty, the
|
|
11579
11587
|
* RemoteStore may start its network connections.
|
|
11580
11588
|
*/
|
|
11581
|
-
this.
|
|
11589
|
+
this.Wr = new Set,
|
|
11582
11590
|
/**
|
|
11583
11591
|
* Event handlers that get called when the network is disabled or enabled.
|
|
11584
11592
|
*
|
|
@@ -11586,7 +11594,7 @@ class ro {
|
|
|
11586
11594
|
* underlying streams (to support tree-shakeable streams). On Android and iOS,
|
|
11587
11595
|
* the streams are created during construction of RemoteStore.
|
|
11588
11596
|
*/
|
|
11589
|
-
this.
|
|
11597
|
+
this.Gr = [], this.zr = i, this.zr.Ti((t => {
|
|
11590
11598
|
n.enqueueAndForget((async () => {
|
|
11591
11599
|
// Porting Note: Unlike iOS, `restartNetwork()` is called even when the
|
|
11592
11600
|
// network becomes unreachable as we don't have any other way to tear
|
|
@@ -11594,23 +11602,23 @@ class ro {
|
|
|
11594
11602
|
mo(this) && (O("RemoteStore", "Restarting streams for network reachability change."),
|
|
11595
11603
|
await async function(t) {
|
|
11596
11604
|
const e = K(t);
|
|
11597
|
-
e.
|
|
11598
|
-
e.
|
|
11605
|
+
e.Wr.add(4 /* ConnectivityChange */), await ao(e), e.Hr.set("Unknown" /* Unknown */),
|
|
11606
|
+
e.Wr.delete(4 /* ConnectivityChange */), await co(e);
|
|
11599
11607
|
}(this));
|
|
11600
11608
|
}));
|
|
11601
|
-
})), this.
|
|
11609
|
+
})), this.Hr = new ro(n, s);
|
|
11602
11610
|
}
|
|
11603
11611
|
}
|
|
11604
11612
|
|
|
11605
11613
|
async function co(t) {
|
|
11606
|
-
if (mo(t)) for (const e of t.
|
|
11614
|
+
if (mo(t)) for (const e of t.Gr) await e(/* enabled= */ !0);
|
|
11607
11615
|
}
|
|
11608
11616
|
|
|
11609
11617
|
/**
|
|
11610
11618
|
* Temporarily disables the network. The network can be re-enabled using
|
|
11611
11619
|
* enableNetwork().
|
|
11612
11620
|
*/ async function ao(t) {
|
|
11613
|
-
for (const e of t.
|
|
11621
|
+
for (const e of t.Gr) await e(/* enabled= */ !1);
|
|
11614
11622
|
}
|
|
11615
11623
|
|
|
11616
11624
|
/**
|
|
@@ -11619,11 +11627,11 @@ async function co(t) {
|
|
|
11619
11627
|
*/
|
|
11620
11628
|
function uo(t, e) {
|
|
11621
11629
|
const n = K(t);
|
|
11622
|
-
n.
|
|
11630
|
+
n.Qr.has(e.targetId) || (
|
|
11623
11631
|
// Mark this as something the client is currently listening for.
|
|
11624
|
-
n.
|
|
11632
|
+
n.Qr.set(e.targetId, e), _o(n) ?
|
|
11625
11633
|
// The listen will be sent in onWatchStreamOpen
|
|
11626
|
-
wo(n) : xo(n).
|
|
11634
|
+
wo(n) : xo(n).hr() && lo(n, e));
|
|
11627
11635
|
}
|
|
11628
11636
|
|
|
11629
11637
|
/**
|
|
@@ -11631,18 +11639,18 @@ function uo(t, e) {
|
|
|
11631
11639
|
* not being listened to.
|
|
11632
11640
|
*/ function ho(t, e) {
|
|
11633
11641
|
const n = K(t), s = xo(n);
|
|
11634
|
-
n.
|
|
11642
|
+
n.Qr.delete(e), s.hr() && fo(n, e), 0 === n.Qr.size && (s.hr() ? s.wr() : mo(n) &&
|
|
11635
11643
|
// Revert to OnlineState.Unknown if the watch stream is not open and we
|
|
11636
11644
|
// have no listeners, since without any listens to send we cannot
|
|
11637
11645
|
// confirm if the stream is healthy and upgrade to OnlineState.Online.
|
|
11638
|
-
n.
|
|
11646
|
+
n.Hr.set("Unknown" /* Unknown */));
|
|
11639
11647
|
}
|
|
11640
11648
|
|
|
11641
11649
|
/**
|
|
11642
11650
|
* We need to increment the the expected number of pending responses we're due
|
|
11643
11651
|
* from watch so we wait for the ack to process any messages from this target.
|
|
11644
11652
|
*/ function lo(t, e) {
|
|
11645
|
-
t.
|
|
11653
|
+
t.Jr.Y(e.targetId), xo(t).br(e);
|
|
11646
11654
|
}
|
|
11647
11655
|
|
|
11648
11656
|
/**
|
|
@@ -11650,33 +11658,33 @@ function uo(t, e) {
|
|
|
11650
11658
|
* from watch so we wait for the removal on the server before we process any
|
|
11651
11659
|
* messages from this target.
|
|
11652
11660
|
*/ function fo(t, e) {
|
|
11653
|
-
t.
|
|
11661
|
+
t.Jr.Y(e), xo(t).Pr(e);
|
|
11654
11662
|
}
|
|
11655
11663
|
|
|
11656
11664
|
function wo(t) {
|
|
11657
|
-
t.
|
|
11665
|
+
t.Jr = new Fn({
|
|
11658
11666
|
getRemoteKeysForTarget: e => t.remoteSyncer.getRemoteKeysForTarget(e),
|
|
11659
|
-
Tt: e => t.
|
|
11660
|
-
}), xo(t).start(), t.
|
|
11667
|
+
Tt: e => t.Qr.get(e) || null
|
|
11668
|
+
}), xo(t).start(), t.Hr.Lr();
|
|
11661
11669
|
}
|
|
11662
11670
|
|
|
11663
11671
|
/**
|
|
11664
11672
|
* Returns whether the watch stream should be started because it's necessary
|
|
11665
11673
|
* and has not yet been started.
|
|
11666
11674
|
*/ function _o(t) {
|
|
11667
|
-
return mo(t) && !xo(t).
|
|
11675
|
+
return mo(t) && !xo(t).ur() && t.Qr.size > 0;
|
|
11668
11676
|
}
|
|
11669
11677
|
|
|
11670
11678
|
function mo(t) {
|
|
11671
|
-
return 0 === K(t).
|
|
11679
|
+
return 0 === K(t).Wr.size;
|
|
11672
11680
|
}
|
|
11673
11681
|
|
|
11674
11682
|
function go(t) {
|
|
11675
|
-
t.
|
|
11683
|
+
t.Jr = void 0;
|
|
11676
11684
|
}
|
|
11677
11685
|
|
|
11678
11686
|
async function yo(t) {
|
|
11679
|
-
t.
|
|
11687
|
+
t.Qr.forEach(((e, n) => {
|
|
11680
11688
|
lo(t, e);
|
|
11681
11689
|
}));
|
|
11682
11690
|
}
|
|
@@ -11684,17 +11692,17 @@ async function yo(t) {
|
|
|
11684
11692
|
async function po(t, e) {
|
|
11685
11693
|
go(t),
|
|
11686
11694
|
// If we still need the watch stream, retry the connection.
|
|
11687
|
-
_o(t) ? (t.
|
|
11695
|
+
_o(t) ? (t.Hr.qr(e), wo(t)) :
|
|
11688
11696
|
// No need to restart watch stream because there are no active targets.
|
|
11689
11697
|
// The online state is set to unknown because there is no active attempt
|
|
11690
11698
|
// at establishing a connection
|
|
11691
|
-
t.
|
|
11699
|
+
t.Hr.set("Unknown" /* Unknown */);
|
|
11692
11700
|
}
|
|
11693
11701
|
|
|
11694
11702
|
async function To(t, e, n) {
|
|
11695
11703
|
if (
|
|
11696
11704
|
// Mark the client as online since we got a message from the server
|
|
11697
|
-
t.
|
|
11705
|
+
t.Hr.set("Online" /* Online */), e instanceof $n && 2 /* Removed */ === e.state && e.cause)
|
|
11698
11706
|
// There was an error on a target, don't wait for a consistent snapshot
|
|
11699
11707
|
// to raise events
|
|
11700
11708
|
try {
|
|
@@ -11704,7 +11712,7 @@ async function To(t, e, n) {
|
|
|
11704
11712
|
const n = e.cause;
|
|
11705
11713
|
for (const s of e.targetIds)
|
|
11706
11714
|
// A watched target might have been removed already.
|
|
11707
|
-
t.
|
|
11715
|
+
t.Qr.has(s) && (await t.remoteSyncer.rejectListen(s, n), t.Qr.delete(s), t.Jr.removeTarget(s));
|
|
11708
11716
|
}
|
|
11709
11717
|
/**
|
|
11710
11718
|
* Attempts to fill our write pipeline with writes from the LocalStore.
|
|
@@ -11717,7 +11725,7 @@ async function To(t, e, n) {
|
|
|
11717
11725
|
} catch (n) {
|
|
11718
11726
|
O("RemoteStore", "Failed to remove targets %s: %s ", e.targetIds.join(","), n),
|
|
11719
11727
|
await Eo(t, n);
|
|
11720
|
-
} else if (e instanceof xn ? t.
|
|
11728
|
+
} else if (e instanceof xn ? t.Jr.rt(e) : e instanceof kn ? t.Jr.ft(e) : t.Jr.at(e),
|
|
11721
11729
|
!n.isEqual(ot.min())) try {
|
|
11722
11730
|
const e = await wr(t.localStore);
|
|
11723
11731
|
n.compareTo(e) >= 0 &&
|
|
@@ -11730,26 +11738,26 @@ async function To(t, e, n) {
|
|
|
11730
11738
|
* SyncEngine.
|
|
11731
11739
|
*/
|
|
11732
11740
|
function(t, e) {
|
|
11733
|
-
const n = t.
|
|
11741
|
+
const n = t.Jr._t(e);
|
|
11734
11742
|
// Update in-memory resume tokens. LocalStore will update the
|
|
11735
11743
|
// persistent view of these when applying the completed RemoteEvent.
|
|
11736
11744
|
return n.targetChanges.forEach(((n, s) => {
|
|
11737
11745
|
if (n.resumeToken.approximateByteSize() > 0) {
|
|
11738
|
-
const i = t.
|
|
11746
|
+
const i = t.Qr.get(s);
|
|
11739
11747
|
// A watched target might have been removed already.
|
|
11740
|
-
i && t.
|
|
11748
|
+
i && t.Qr.set(s, i.withResumeToken(n.resumeToken, e));
|
|
11741
11749
|
}
|
|
11742
11750
|
})),
|
|
11743
11751
|
// Re-establish listens for the targets that have been invalidated by
|
|
11744
11752
|
// existence filter mismatches.
|
|
11745
11753
|
n.targetMismatches.forEach((e => {
|
|
11746
|
-
const n = t.
|
|
11754
|
+
const n = t.Qr.get(e);
|
|
11747
11755
|
if (!n)
|
|
11748
11756
|
// A watched target might have been removed already.
|
|
11749
11757
|
return;
|
|
11750
11758
|
// Clear the resume token for the target, since we're in a known mismatch
|
|
11751
11759
|
// state.
|
|
11752
|
-
t.
|
|
11760
|
+
t.Qr.set(e, n.withResumeToken(gt.EMPTY_BYTE_STRING, n.snapshotVersion)),
|
|
11753
11761
|
// Cause a hard reset by unwatching and rewatching immediately, but
|
|
11754
11762
|
// deliberately don't send a resume token so that we get a full update.
|
|
11755
11763
|
fo(t, e);
|
|
@@ -11776,16 +11784,16 @@ async function To(t, e, n) {
|
|
|
11776
11784
|
* any retry attempt.
|
|
11777
11785
|
*/ async function Eo(t, e, n) {
|
|
11778
11786
|
if (!Ys(e)) throw e;
|
|
11779
|
-
t.
|
|
11787
|
+
t.Wr.add(1 /* IndexedDbFailed */),
|
|
11780
11788
|
// Disable network and raise offline snapshots
|
|
11781
|
-
await ao(t), t.
|
|
11789
|
+
await ao(t), t.Hr.set("Offline" /* Offline */), n || (
|
|
11782
11790
|
// Use a simple read operation to determine if IndexedDB recovered.
|
|
11783
11791
|
// Ideally, we would expose a health check directly on SimpleDb, but
|
|
11784
11792
|
// RemoteStore only has access to persistence through LocalStore.
|
|
11785
11793
|
n = () => wr(t.localStore)),
|
|
11786
11794
|
// Probe IndexedDB periodically and re-enable network
|
|
11787
11795
|
t.asyncQueue.enqueueRetryable((async () => {
|
|
11788
|
-
O("RemoteStore", "Retrying IndexedDB access"), await n(), t.
|
|
11796
|
+
O("RemoteStore", "Retrying IndexedDB access"), await n(), t.Wr.delete(1 /* IndexedDbFailed */),
|
|
11789
11797
|
await co(t);
|
|
11790
11798
|
}));
|
|
11791
11799
|
}
|
|
@@ -11799,11 +11807,11 @@ async function To(t, e, n) {
|
|
|
11799
11807
|
|
|
11800
11808
|
async function Ao(t) {
|
|
11801
11809
|
const e = K(t), n = ko(e);
|
|
11802
|
-
let s = e.
|
|
11810
|
+
let s = e.jr.length > 0 ? e.jr[e.jr.length - 1].batchId : -1;
|
|
11803
11811
|
for (;Ro(e); ) try {
|
|
11804
11812
|
const t = await gr(e.localStore, s);
|
|
11805
11813
|
if (null === t) {
|
|
11806
|
-
0 === e.
|
|
11814
|
+
0 === e.jr.length && n.wr();
|
|
11807
11815
|
break;
|
|
11808
11816
|
}
|
|
11809
11817
|
s = t.batchId, bo(e, t);
|
|
@@ -11817,20 +11825,20 @@ async function Ao(t) {
|
|
|
11817
11825
|
* Returns true if we can add to the write pipeline (i.e. the network is
|
|
11818
11826
|
* enabled and the write pipeline is not full).
|
|
11819
11827
|
*/ function Ro(t) {
|
|
11820
|
-
return mo(t) && t.
|
|
11828
|
+
return mo(t) && t.jr.length < 10;
|
|
11821
11829
|
}
|
|
11822
11830
|
|
|
11823
11831
|
/**
|
|
11824
11832
|
* Queues additional writes to be sent to the write stream, sending them
|
|
11825
11833
|
* immediately if the write stream is established.
|
|
11826
11834
|
*/ function bo(t, e) {
|
|
11827
|
-
t.
|
|
11835
|
+
t.jr.push(e);
|
|
11828
11836
|
const n = ko(t);
|
|
11829
|
-
n.
|
|
11837
|
+
n.hr() && n.Vr && n.Sr(e.mutations);
|
|
11830
11838
|
}
|
|
11831
11839
|
|
|
11832
11840
|
function Po(t) {
|
|
11833
|
-
return mo(t) && !ko(t).
|
|
11841
|
+
return mo(t) && !ko(t).ur() && t.jr.length > 0;
|
|
11834
11842
|
}
|
|
11835
11843
|
|
|
11836
11844
|
function vo(t) {
|
|
@@ -11838,17 +11846,17 @@ function vo(t) {
|
|
|
11838
11846
|
}
|
|
11839
11847
|
|
|
11840
11848
|
async function Vo(t) {
|
|
11841
|
-
ko(t).
|
|
11849
|
+
ko(t).Nr();
|
|
11842
11850
|
}
|
|
11843
11851
|
|
|
11844
11852
|
async function So(t) {
|
|
11845
11853
|
const e = ko(t);
|
|
11846
11854
|
// Send the write pipeline now that the stream is established.
|
|
11847
|
-
for (const n of t.
|
|
11855
|
+
for (const n of t.jr) e.Sr(n.mutations);
|
|
11848
11856
|
}
|
|
11849
11857
|
|
|
11850
11858
|
async function Do(t, e, n) {
|
|
11851
|
-
const s = t.
|
|
11859
|
+
const s = t.jr.shift(), i = ri.from(s, e, n);
|
|
11852
11860
|
await Io(t, (() => t.remoteSyncer.applySuccessfulWrite(i))),
|
|
11853
11861
|
// It's possible that with the completion of this mutation another
|
|
11854
11862
|
// slot has freed up.
|
|
@@ -11858,7 +11866,7 @@ async function Do(t, e, n) {
|
|
|
11858
11866
|
async function Co(t, e) {
|
|
11859
11867
|
// If the write stream closed after the write handshake completes, a write
|
|
11860
11868
|
// operation failed and we fail the pending operation.
|
|
11861
|
-
e && ko(t).
|
|
11869
|
+
e && ko(t).Vr &&
|
|
11862
11870
|
// This error affects the actual write.
|
|
11863
11871
|
await async function(t, e) {
|
|
11864
11872
|
// Only handle permanent errors here. If it's transient, just let the retry
|
|
@@ -11866,11 +11874,11 @@ async function Co(t, e) {
|
|
|
11866
11874
|
if (n = e.code, wn(n) && n !== j.ABORTED) {
|
|
11867
11875
|
// This was a permanent error, the request itself was the problem
|
|
11868
11876
|
// so it's not going to succeed if we resend it.
|
|
11869
|
-
const n = t.
|
|
11877
|
+
const n = t.jr.shift();
|
|
11870
11878
|
// In this case it's also unlikely that the server itself is melting
|
|
11871
11879
|
// down -- this was just a bad request so inhibit backoff on the next
|
|
11872
11880
|
// restart.
|
|
11873
|
-
ko(t).
|
|
11881
|
+
ko(t).dr(), await Io(t, (() => t.remoteSyncer.rejectFailedWrite(n.batchId, e))),
|
|
11874
11882
|
// It's possible that with the completion of this mutation
|
|
11875
11883
|
// another slot has freed up.
|
|
11876
11884
|
await Ao(t);
|
|
@@ -11887,8 +11895,8 @@ async function Co(t, e) {
|
|
|
11887
11895
|
*/
|
|
11888
11896
|
async function No(t, e) {
|
|
11889
11897
|
const n = K(t);
|
|
11890
|
-
e ? (n.
|
|
11891
|
-
await ao(n), n.
|
|
11898
|
+
e ? (n.Wr.delete(2 /* IsSecondary */), await co(n)) : e || (n.Wr.add(2 /* IsSecondary */),
|
|
11899
|
+
await ao(n), n.Hr.set("Unknown" /* Unknown */));
|
|
11892
11900
|
}
|
|
11893
11901
|
|
|
11894
11902
|
/**
|
|
@@ -11899,11 +11907,11 @@ async function No(t, e) {
|
|
|
11899
11907
|
* PORTING NOTE: On iOS and Android, the WatchStream gets registered on startup.
|
|
11900
11908
|
* This is not done on Web to allow it to be tree-shaken.
|
|
11901
11909
|
*/ function xo(t) {
|
|
11902
|
-
return t.
|
|
11910
|
+
return t.Yr || (
|
|
11903
11911
|
// Create stream (but note that it is not started yet).
|
|
11904
|
-
t.
|
|
11912
|
+
t.Yr = function(t, e, n) {
|
|
11905
11913
|
const s = K(t);
|
|
11906
|
-
return s
|
|
11914
|
+
return s.$r(), new no(e, s.sr, s.credentials, s.N, n);
|
|
11907
11915
|
}
|
|
11908
11916
|
/**
|
|
11909
11917
|
* @license
|
|
@@ -11923,11 +11931,11 @@ async function No(t, e) {
|
|
|
11923
11931
|
*/ (t.datastore, t.asyncQueue, {
|
|
11924
11932
|
Si: yo.bind(null, t),
|
|
11925
11933
|
Ci: po.bind(null, t),
|
|
11926
|
-
|
|
11927
|
-
}), t.
|
|
11928
|
-
e ? (t.
|
|
11934
|
+
Rr: To.bind(null, t)
|
|
11935
|
+
}), t.Gr.push((async e => {
|
|
11936
|
+
e ? (t.Yr.dr(), _o(t) ? wo(t) : t.Hr.set("Unknown" /* Unknown */)) : (await t.Yr.stop(),
|
|
11929
11937
|
go(t));
|
|
11930
|
-
}))), t.
|
|
11938
|
+
}))), t.Yr;
|
|
11931
11939
|
}
|
|
11932
11940
|
|
|
11933
11941
|
/**
|
|
@@ -11938,22 +11946,22 @@ async function No(t, e) {
|
|
|
11938
11946
|
* PORTING NOTE: On iOS and Android, the WriteStream gets registered on startup.
|
|
11939
11947
|
* This is not done on Web to allow it to be tree-shaken.
|
|
11940
11948
|
*/ function ko(t) {
|
|
11941
|
-
return t.
|
|
11949
|
+
return t.Xr || (
|
|
11942
11950
|
// Create stream (but note that it is not started yet).
|
|
11943
|
-
t.
|
|
11951
|
+
t.Xr = function(t, e, n) {
|
|
11944
11952
|
const s = K(t);
|
|
11945
|
-
return s
|
|
11953
|
+
return s.$r(), new so(e, s.sr, s.credentials, s.N, n);
|
|
11946
11954
|
}(t.datastore, t.asyncQueue, {
|
|
11947
11955
|
Si: Vo.bind(null, t),
|
|
11948
11956
|
Ci: Co.bind(null, t),
|
|
11949
|
-
|
|
11950
|
-
|
|
11951
|
-
}), t.
|
|
11952
|
-
e ? (t.
|
|
11957
|
+
Cr: So.bind(null, t),
|
|
11958
|
+
Dr: Do.bind(null, t)
|
|
11959
|
+
}), t.Gr.push((async e => {
|
|
11960
|
+
e ? (t.Xr.dr(),
|
|
11953
11961
|
// This will start the write stream if necessary.
|
|
11954
|
-
await Ao(t)) : (await t.
|
|
11955
|
-
t.
|
|
11956
|
-
}))), t.
|
|
11962
|
+
await Ao(t)) : (await t.Xr.stop(), t.jr.length > 0 && (O("RemoteStore", `Stopping write stream with ${t.jr.length} pending writes`),
|
|
11963
|
+
t.jr = []));
|
|
11964
|
+
}))), t.Xr;
|
|
11957
11965
|
}
|
|
11958
11966
|
|
|
11959
11967
|
/**
|
|
@@ -12163,25 +12171,25 @@ class $o {
|
|
|
12163
12171
|
* duplicate events for the same doc.
|
|
12164
12172
|
*/ class Mo {
|
|
12165
12173
|
constructor() {
|
|
12166
|
-
this.
|
|
12174
|
+
this.Zr = new mn(Vt.comparator);
|
|
12167
12175
|
}
|
|
12168
12176
|
track(t) {
|
|
12169
|
-
const e = t.doc.key, n = this.
|
|
12177
|
+
const e = t.doc.key, n = this.Zr.get(e);
|
|
12170
12178
|
n ?
|
|
12171
12179
|
// Merge the new change with the existing change.
|
|
12172
|
-
0 /* Added */ !== t.type && 3 /* Metadata */ === n.type ? this.
|
|
12180
|
+
0 /* Added */ !== t.type && 3 /* Metadata */ === n.type ? this.Zr = this.Zr.insert(e, t) : 3 /* Metadata */ === t.type && 1 /* Removed */ !== n.type ? this.Zr = this.Zr.insert(e, {
|
|
12173
12181
|
type: n.type,
|
|
12174
12182
|
doc: t.doc
|
|
12175
|
-
}) : 2 /* Modified */ === t.type && 2 /* Modified */ === n.type ? this.
|
|
12183
|
+
}) : 2 /* Modified */ === t.type && 2 /* Modified */ === n.type ? this.Zr = this.Zr.insert(e, {
|
|
12176
12184
|
type: 2 /* Modified */ ,
|
|
12177
12185
|
doc: t.doc
|
|
12178
|
-
}) : 2 /* Modified */ === t.type && 0 /* Added */ === n.type ? this.
|
|
12186
|
+
}) : 2 /* Modified */ === t.type && 0 /* Added */ === n.type ? this.Zr = this.Zr.insert(e, {
|
|
12179
12187
|
type: 0 /* Added */ ,
|
|
12180
12188
|
doc: t.doc
|
|
12181
|
-
}) : 1 /* Removed */ === t.type && 0 /* Added */ === n.type ? this.
|
|
12189
|
+
}) : 1 /* Removed */ === t.type && 0 /* Added */ === n.type ? this.Zr = this.Zr.remove(e) : 1 /* Removed */ === t.type && 2 /* Modified */ === n.type ? this.Zr = this.Zr.insert(e, {
|
|
12182
12190
|
type: 1 /* Removed */ ,
|
|
12183
12191
|
doc: n.doc
|
|
12184
|
-
}) : 0 /* Added */ === t.type && 1 /* Removed */ === n.type ? this.
|
|
12192
|
+
}) : 0 /* Added */ === t.type && 1 /* Removed */ === n.type ? this.Zr = this.Zr.insert(e, {
|
|
12185
12193
|
type: 2 /* Modified */ ,
|
|
12186
12194
|
doc: t.doc
|
|
12187
12195
|
}) :
|
|
@@ -12192,11 +12200,11 @@ class $o {
|
|
|
12192
12200
|
// Removed->Modified
|
|
12193
12201
|
// Metadata->Added
|
|
12194
12202
|
// Removed->Metadata
|
|
12195
|
-
B() : this.
|
|
12203
|
+
B() : this.Zr = this.Zr.insert(e, t);
|
|
12196
12204
|
}
|
|
12197
|
-
|
|
12205
|
+
eo() {
|
|
12198
12206
|
const t = [];
|
|
12199
|
-
return this.
|
|
12207
|
+
return this.Zr.inorderTraversal(((e, n) => {
|
|
12200
12208
|
t.push(n);
|
|
12201
12209
|
})), t;
|
|
12202
12210
|
}
|
|
@@ -12251,14 +12259,14 @@ class Lo {
|
|
|
12251
12259
|
* tracked by EventManager.
|
|
12252
12260
|
*/ class Bo {
|
|
12253
12261
|
constructor() {
|
|
12254
|
-
this.
|
|
12262
|
+
this.no = void 0, this.listeners = [];
|
|
12255
12263
|
}
|
|
12256
12264
|
}
|
|
12257
12265
|
|
|
12258
12266
|
class Uo {
|
|
12259
12267
|
constructor() {
|
|
12260
12268
|
this.queries = new Wi((t => Pe(t)), be), this.onlineState = "Unknown" /* Unknown */ ,
|
|
12261
|
-
this.
|
|
12269
|
+
this.so = new Set;
|
|
12262
12270
|
}
|
|
12263
12271
|
}
|
|
12264
12272
|
|
|
@@ -12266,15 +12274,15 @@ async function qo(t, e) {
|
|
|
12266
12274
|
const n = K(t), s = e.query;
|
|
12267
12275
|
let i = !1, r = n.queries.get(s);
|
|
12268
12276
|
if (r || (i = !0, r = new Bo), i) try {
|
|
12269
|
-
r.
|
|
12277
|
+
r.no = await n.onListen(s);
|
|
12270
12278
|
} catch (t) {
|
|
12271
12279
|
const n = Oo(t, `Initialization of query '${ve(e.query)}' failed`);
|
|
12272
12280
|
return void e.onError(n);
|
|
12273
12281
|
}
|
|
12274
12282
|
if (n.queries.set(s, r), r.listeners.push(e),
|
|
12275
12283
|
// Run global snapshot listeners if a consistent snapshot has been emitted.
|
|
12276
|
-
e.
|
|
12277
|
-
e.
|
|
12284
|
+
e.io(n.onlineState), r.no) {
|
|
12285
|
+
e.ro(r.no) && Wo(n);
|
|
12278
12286
|
}
|
|
12279
12287
|
}
|
|
12280
12288
|
|
|
@@ -12295,8 +12303,8 @@ function jo(t, e) {
|
|
|
12295
12303
|
for (const t of e) {
|
|
12296
12304
|
const e = t.query, i = n.queries.get(e);
|
|
12297
12305
|
if (i) {
|
|
12298
|
-
for (const e of i.listeners) e.
|
|
12299
|
-
i.
|
|
12306
|
+
for (const e of i.listeners) e.ro(t) && (s = !0);
|
|
12307
|
+
i.no = t;
|
|
12300
12308
|
}
|
|
12301
12309
|
}
|
|
12302
12310
|
s && Wo(n);
|
|
@@ -12312,7 +12320,7 @@ function Qo(t, e, n) {
|
|
|
12312
12320
|
|
|
12313
12321
|
// Call all global snapshot listeners that have been set.
|
|
12314
12322
|
function Wo(t) {
|
|
12315
|
-
t.
|
|
12323
|
+
t.so.forEach((t => {
|
|
12316
12324
|
t.next();
|
|
12317
12325
|
}));
|
|
12318
12326
|
}
|
|
@@ -12324,19 +12332,19 @@ function Wo(t) {
|
|
|
12324
12332
|
* It uses an Observer to dispatch events.
|
|
12325
12333
|
*/ class Go {
|
|
12326
12334
|
constructor(t, e, n) {
|
|
12327
|
-
this.query = t, this.
|
|
12335
|
+
this.query = t, this.oo = e,
|
|
12328
12336
|
/**
|
|
12329
12337
|
* Initial snapshots (e.g. from cache) may not be propagated to the wrapped
|
|
12330
12338
|
* observer. This flag is set to true once we've actually raised an event.
|
|
12331
12339
|
*/
|
|
12332
|
-
this.
|
|
12340
|
+
this.co = !1, this.ao = null, this.onlineState = "Unknown" /* Unknown */ , this.options = n || {};
|
|
12333
12341
|
}
|
|
12334
12342
|
/**
|
|
12335
12343
|
* Applies the new ViewSnapshot to this listener, raising a user-facing event
|
|
12336
12344
|
* if applicable (depending on what changed, whether the user has opted into
|
|
12337
12345
|
* metadata-only changes, etc.). Returns true if a user-facing event was
|
|
12338
12346
|
* indeed raised.
|
|
12339
|
-
*/
|
|
12347
|
+
*/ ro(t) {
|
|
12340
12348
|
if (!this.options.includeMetadataChanges) {
|
|
12341
12349
|
// Remove the metadata only changes.
|
|
12342
12350
|
const e = [];
|
|
@@ -12345,19 +12353,19 @@ function Wo(t) {
|
|
|
12345
12353
|
/* excludesMetadataChanges= */ !0);
|
|
12346
12354
|
}
|
|
12347
12355
|
let e = !1;
|
|
12348
|
-
return this.
|
|
12349
|
-
e = !0), this.
|
|
12356
|
+
return this.co ? this.uo(t) && (this.oo.next(t), e = !0) : this.ho(t, this.onlineState) && (this.lo(t),
|
|
12357
|
+
e = !0), this.ao = t, e;
|
|
12350
12358
|
}
|
|
12351
12359
|
onError(t) {
|
|
12352
|
-
this.
|
|
12360
|
+
this.oo.error(t);
|
|
12353
12361
|
}
|
|
12354
|
-
/** Returns whether a snapshot was raised. */
|
|
12362
|
+
/** Returns whether a snapshot was raised. */ io(t) {
|
|
12355
12363
|
this.onlineState = t;
|
|
12356
12364
|
let e = !1;
|
|
12357
|
-
return this.
|
|
12365
|
+
return this.ao && !this.co && this.ho(this.ao, t) && (this.lo(this.ao), e = !0),
|
|
12358
12366
|
e;
|
|
12359
12367
|
}
|
|
12360
|
-
|
|
12368
|
+
ho(t, e) {
|
|
12361
12369
|
// Always raise the first event when we're synced
|
|
12362
12370
|
if (!t.fromCache) return !0;
|
|
12363
12371
|
// NOTE: We consider OnlineState.Unknown as online (it should become Offline
|
|
@@ -12365,24 +12373,24 @@ function Wo(t) {
|
|
|
12365
12373
|
const n = "Offline" /* Offline */ !== e;
|
|
12366
12374
|
// Don't raise the event if we're online, aren't synced yet (checked
|
|
12367
12375
|
// above) and are waiting for a sync.
|
|
12368
|
-
return (!this.options.
|
|
12376
|
+
return (!this.options.fo || !n) && (!t.docs.isEmpty() || "Offline" /* Offline */ === e);
|
|
12369
12377
|
// Raise data from cache if we have any documents or we are offline
|
|
12370
12378
|
}
|
|
12371
|
-
|
|
12379
|
+
uo(t) {
|
|
12372
12380
|
// We don't need to handle includeDocumentMetadataChanges here because
|
|
12373
12381
|
// the Metadata only changes have already been stripped out if needed.
|
|
12374
12382
|
// At this point the only changes we will see are the ones we should
|
|
12375
12383
|
// propagate.
|
|
12376
12384
|
if (t.docChanges.length > 0) return !0;
|
|
12377
|
-
const e = this.
|
|
12385
|
+
const e = this.ao && this.ao.hasPendingWrites !== t.hasPendingWrites;
|
|
12378
12386
|
return !(!t.syncStateChanged && !e) && !0 === this.options.includeMetadataChanges;
|
|
12379
12387
|
// Generally we should have hit one of the cases above, but it's possible
|
|
12380
12388
|
// to get here if there were only metadata docChanges and they got
|
|
12381
12389
|
// stripped out.
|
|
12382
12390
|
}
|
|
12383
|
-
|
|
12384
|
-
t = Lo.fromInitialDocuments(t.query, t.docs, t.mutatedKeys, t.fromCache), this.
|
|
12385
|
-
this.
|
|
12391
|
+
lo(t) {
|
|
12392
|
+
t = Lo.fromInitialDocuments(t.query, t.docs, t.mutatedKeys, t.fromCache), this.co = !0,
|
|
12393
|
+
this.oo.next(t);
|
|
12386
12394
|
}
|
|
12387
12395
|
}
|
|
12388
12396
|
|
|
@@ -12411,7 +12419,7 @@ function Wo(t) {
|
|
|
12411
12419
|
e) {
|
|
12412
12420
|
this.payload = t, this.byteLength = e;
|
|
12413
12421
|
}
|
|
12414
|
-
|
|
12422
|
+
wo() {
|
|
12415
12423
|
return "metadata" in this.payload;
|
|
12416
12424
|
}
|
|
12417
12425
|
}
|
|
@@ -12456,7 +12464,7 @@ function Wo(t) {
|
|
|
12456
12464
|
* storage and provide progress update while loading.
|
|
12457
12465
|
*/ class Jo {
|
|
12458
12466
|
constructor(t, e, n) {
|
|
12459
|
-
this.
|
|
12467
|
+
this._o = t, this.localStore = e, this.N = n,
|
|
12460
12468
|
/** Batched queries to be saved into storage */
|
|
12461
12469
|
this.queries = [],
|
|
12462
12470
|
/** Batched documents to be saved into storage */
|
|
@@ -12467,7 +12475,7 @@ function Wo(t) {
|
|
|
12467
12475
|
*
|
|
12468
12476
|
* Returns a new progress if adding the element leads to a new progress,
|
|
12469
12477
|
* otherwise returns null.
|
|
12470
|
-
*/
|
|
12478
|
+
*/ mo(t) {
|
|
12471
12479
|
this.progress.bytesLoaded += t.byteLength;
|
|
12472
12480
|
let e = this.progress.documentsLoaded;
|
|
12473
12481
|
return t.payload.namedQuery ? this.queries.push(t.payload.namedQuery) : t.payload.documentMetadata ? (this.documents.push({
|
|
@@ -12476,7 +12484,7 @@ function Wo(t) {
|
|
|
12476
12484
|
++e), e !== this.progress.documentsLoaded ? (this.progress.documentsLoaded = e,
|
|
12477
12485
|
Object.assign({}, this.progress)) : null;
|
|
12478
12486
|
}
|
|
12479
|
-
|
|
12487
|
+
yo(t) {
|
|
12480
12488
|
const e = new Map, n = new Ho(this.N);
|
|
12481
12489
|
for (const s of t) if (s.metadata.queries) {
|
|
12482
12490
|
const t = n.zn(s.metadata.name);
|
|
@@ -12490,7 +12498,7 @@ function Wo(t) {
|
|
|
12490
12498
|
/**
|
|
12491
12499
|
* Update the progress to 'Success' and return the updated progress.
|
|
12492
12500
|
*/ async complete() {
|
|
12493
|
-
const t = await Rr(this.localStore, new Ho(this.N), this.documents, this.
|
|
12501
|
+
const t = await Rr(this.localStore, new Ho(this.N), this.documents, this._o.id), e = this.yo(this.documents);
|
|
12494
12502
|
for (const t of this.queries) await br(this.localStore, t, e.get(t.name));
|
|
12495
12503
|
return this.progress.taskState = "Success", new or(Object.assign({}, this.progress), t);
|
|
12496
12504
|
}
|
|
@@ -12549,7 +12557,7 @@ class Zo {
|
|
|
12549
12557
|
constructor(t,
|
|
12550
12558
|
/** Documents included in the remote target */
|
|
12551
12559
|
e) {
|
|
12552
|
-
this.query = t, this.
|
|
12560
|
+
this.query = t, this.po = e, this.To = null,
|
|
12553
12561
|
/**
|
|
12554
12562
|
* A flag whether the view is current with the backend. A view is considered
|
|
12555
12563
|
* current after it has seen the current flag from the backend and did not
|
|
@@ -12558,15 +12566,15 @@ class Zo {
|
|
|
12558
12566
|
*/
|
|
12559
12567
|
this.current = !1,
|
|
12560
12568
|
/** Documents in the view but not in the remote target */
|
|
12561
|
-
this.
|
|
12569
|
+
this.Eo = Vn(),
|
|
12562
12570
|
/** Document Keys that have local changes */
|
|
12563
|
-
this.mutatedKeys = Vn(), this.
|
|
12571
|
+
this.mutatedKeys = Vn(), this.Io = Se(t), this.Ao = new Fo(this.Io);
|
|
12564
12572
|
}
|
|
12565
12573
|
/**
|
|
12566
12574
|
* The set of remote documents that the server has told us belongs to the target associated with
|
|
12567
12575
|
* this view.
|
|
12568
|
-
*/ get
|
|
12569
|
-
return this.
|
|
12576
|
+
*/ get Ro() {
|
|
12577
|
+
return this.po;
|
|
12570
12578
|
}
|
|
12571
12579
|
/**
|
|
12572
12580
|
* Iterates over a set of doc changes, applies the query limit, and computes
|
|
@@ -12577,8 +12585,8 @@ class Zo {
|
|
|
12577
12585
|
* @param previousChanges - If this is being called with a refill, then start
|
|
12578
12586
|
* with this set of docs and changes instead of the current view.
|
|
12579
12587
|
* @returns a new set of docs, changes, and refill flag.
|
|
12580
|
-
*/
|
|
12581
|
-
const n = e ? e.
|
|
12588
|
+
*/ bo(t, e) {
|
|
12589
|
+
const n = e ? e.Po : new Mo, s = e ? e.Ao : this.Ao;
|
|
12582
12590
|
let i = e ? e.mutatedKeys : this.mutatedKeys, r = s, o = !1;
|
|
12583
12591
|
// Track the last doc in a (full) limit. This is necessary, because some
|
|
12584
12592
|
// update (a delete, or an update moving a doc past the old limit) might
|
|
@@ -12601,10 +12609,10 @@ class Zo {
|
|
|
12601
12609
|
u.data.isEqual(h.data) ? l !== f && (n.track({
|
|
12602
12610
|
type: 3 /* Metadata */ ,
|
|
12603
12611
|
doc: h
|
|
12604
|
-
}), d = !0) : this.
|
|
12612
|
+
}), d = !0) : this.vo(u, h) || (n.track({
|
|
12605
12613
|
type: 2 /* Modified */ ,
|
|
12606
12614
|
doc: h
|
|
12607
|
-
}), d = !0, (c && this.
|
|
12615
|
+
}), d = !0, (c && this.Io(h, c) > 0 || a && this.Io(h, a) < 0) && (
|
|
12608
12616
|
// This doc moved from inside the limit to outside the limit.
|
|
12609
12617
|
// That means there may be some other doc in the local cache
|
|
12610
12618
|
// that should be included instead.
|
|
@@ -12629,13 +12637,13 @@ class Zo {
|
|
|
12629
12637
|
});
|
|
12630
12638
|
}
|
|
12631
12639
|
return {
|
|
12632
|
-
|
|
12633
|
-
|
|
12640
|
+
Ao: r,
|
|
12641
|
+
Po: n,
|
|
12634
12642
|
Ln: o,
|
|
12635
12643
|
mutatedKeys: i
|
|
12636
12644
|
};
|
|
12637
12645
|
}
|
|
12638
|
-
|
|
12646
|
+
vo(t, e) {
|
|
12639
12647
|
// We suppress the initial change event for documents that were modified as
|
|
12640
12648
|
// part of a write acknowledgment (e.g. when the value of a server transform
|
|
12641
12649
|
// is applied) as Watch will send us the same document again.
|
|
@@ -12657,10 +12665,10 @@ class Zo {
|
|
|
12657
12665
|
*/
|
|
12658
12666
|
// PORTING NOTE: The iOS/Android clients always compute limbo document changes.
|
|
12659
12667
|
applyChanges(t, e, n) {
|
|
12660
|
-
const s = this.
|
|
12661
|
-
this.
|
|
12668
|
+
const s = this.Ao;
|
|
12669
|
+
this.Ao = t.Ao, this.mutatedKeys = t.mutatedKeys;
|
|
12662
12670
|
// Sort changes based on type and query comparator
|
|
12663
|
-
const i = t.
|
|
12671
|
+
const i = t.Po.eo();
|
|
12664
12672
|
i.sort(((t, e) => function(t, e) {
|
|
12665
12673
|
const n = t => {
|
|
12666
12674
|
switch (t) {
|
|
@@ -12698,68 +12706,68 @@ class Zo {
|
|
|
12698
12706
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12699
12707
|
* See the License for the specific language governing permissions and
|
|
12700
12708
|
* limitations under the License.
|
|
12701
|
-
*/ (t.type, e.type) || this.
|
|
12702
|
-
const r = e ? this.
|
|
12703
|
-
if (this.
|
|
12709
|
+
*/ (t.type, e.type) || this.Io(t.doc, e.doc))), this.Vo(n);
|
|
12710
|
+
const r = e ? this.So() : [], o = 0 === this.Eo.size && this.current ? 1 /* Synced */ : 0 /* Local */ , c = o !== this.To;
|
|
12711
|
+
if (this.To = o, 0 !== i.length || c) {
|
|
12704
12712
|
return {
|
|
12705
|
-
snapshot: new Lo(this.query, t.
|
|
12713
|
+
snapshot: new Lo(this.query, t.Ao, s, i, t.mutatedKeys, 0 /* Local */ === o, c,
|
|
12706
12714
|
/* excludesMetadataChanges= */ !1),
|
|
12707
|
-
|
|
12715
|
+
Do: r
|
|
12708
12716
|
};
|
|
12709
12717
|
}
|
|
12710
12718
|
// no changes
|
|
12711
12719
|
return {
|
|
12712
|
-
|
|
12720
|
+
Do: r
|
|
12713
12721
|
};
|
|
12714
12722
|
}
|
|
12715
12723
|
/**
|
|
12716
12724
|
* Applies an OnlineState change to the view, potentially generating a
|
|
12717
12725
|
* ViewChange if the view's syncState changes as a result.
|
|
12718
|
-
*/
|
|
12726
|
+
*/ io(t) {
|
|
12719
12727
|
return this.current && "Offline" /* Offline */ === t ? (
|
|
12720
12728
|
// If we're offline, set `current` to false and then call applyChanges()
|
|
12721
12729
|
// to refresh our syncState and generate a ViewChange as appropriate. We
|
|
12722
12730
|
// are guaranteed to get a new TargetChange that sets `current` back to
|
|
12723
12731
|
// true once the client is back online.
|
|
12724
12732
|
this.current = !1, this.applyChanges({
|
|
12725
|
-
|
|
12726
|
-
|
|
12733
|
+
Ao: this.Ao,
|
|
12734
|
+
Po: new Mo,
|
|
12727
12735
|
mutatedKeys: this.mutatedKeys,
|
|
12728
12736
|
Ln: !1
|
|
12729
12737
|
},
|
|
12730
12738
|
/* updateLimboDocuments= */ !1)) : {
|
|
12731
|
-
|
|
12739
|
+
Do: []
|
|
12732
12740
|
};
|
|
12733
12741
|
}
|
|
12734
12742
|
/**
|
|
12735
12743
|
* Returns whether the doc for the given key should be in limbo.
|
|
12736
|
-
*/
|
|
12744
|
+
*/ Co(t) {
|
|
12737
12745
|
// If the remote end says it's part of this query, it's not in limbo.
|
|
12738
|
-
return !this.
|
|
12746
|
+
return !this.po.has(t) && (
|
|
12739
12747
|
// The local store doesn't think it's a result, so it shouldn't be in limbo.
|
|
12740
|
-
!!this.
|
|
12748
|
+
!!this.Ao.has(t) && !this.Ao.get(t).hasLocalMutations);
|
|
12741
12749
|
}
|
|
12742
12750
|
/**
|
|
12743
12751
|
* Updates syncedDocuments, current, and limbo docs based on the given change.
|
|
12744
12752
|
* Returns the list of changes to which docs are in limbo.
|
|
12745
|
-
*/
|
|
12746
|
-
t && (t.addedDocuments.forEach((t => this.
|
|
12747
|
-
t.removedDocuments.forEach((t => this.
|
|
12753
|
+
*/ Vo(t) {
|
|
12754
|
+
t && (t.addedDocuments.forEach((t => this.po = this.po.add(t))), t.modifiedDocuments.forEach((t => {})),
|
|
12755
|
+
t.removedDocuments.forEach((t => this.po = this.po.delete(t))), this.current = t.current);
|
|
12748
12756
|
}
|
|
12749
|
-
|
|
12757
|
+
So() {
|
|
12750
12758
|
// We can only determine limbo documents when we're in-sync with the server.
|
|
12751
12759
|
if (!this.current) return [];
|
|
12752
12760
|
// TODO(klimt): Do this incrementally so that it's not quadratic when
|
|
12753
12761
|
// updating many documents.
|
|
12754
|
-
const t = this.
|
|
12755
|
-
this.
|
|
12756
|
-
this.
|
|
12762
|
+
const t = this.Eo;
|
|
12763
|
+
this.Eo = Vn(), this.Ao.forEach((t => {
|
|
12764
|
+
this.Co(t.key) && (this.Eo = this.Eo.add(t.key));
|
|
12757
12765
|
}));
|
|
12758
12766
|
// Diff the new limbo docs with the old limbo docs.
|
|
12759
12767
|
const e = [];
|
|
12760
12768
|
return t.forEach((t => {
|
|
12761
|
-
this.
|
|
12762
|
-
})), this.
|
|
12769
|
+
this.Eo.has(t) || e.push(new Zo(t));
|
|
12770
|
+
})), this.Eo.forEach((n => {
|
|
12763
12771
|
t.has(n) || e.push(new Xo(n));
|
|
12764
12772
|
})), e;
|
|
12765
12773
|
}
|
|
@@ -12783,9 +12791,9 @@ class Zo {
|
|
|
12783
12791
|
* @returns The ViewChange that resulted from this synchronization.
|
|
12784
12792
|
*/
|
|
12785
12793
|
// PORTING NOTE: Multi-tab only.
|
|
12786
|
-
|
|
12787
|
-
this.
|
|
12788
|
-
const e = this.
|
|
12794
|
+
No(t) {
|
|
12795
|
+
this.po = t.Gn, this.Eo = Vn();
|
|
12796
|
+
const e = this.bo(t.documents);
|
|
12789
12797
|
return this.applyChanges(e, /*updateLimboDocuments=*/ !0);
|
|
12790
12798
|
}
|
|
12791
12799
|
/**
|
|
@@ -12794,8 +12802,8 @@ class Zo {
|
|
|
12794
12802
|
* `hasPendingWrites` status of the already established view.
|
|
12795
12803
|
*/
|
|
12796
12804
|
// PORTING NOTE: Multi-tab only.
|
|
12797
|
-
|
|
12798
|
-
return Lo.fromInitialDocuments(this.query, this.
|
|
12805
|
+
xo() {
|
|
12806
|
+
return Lo.fromInitialDocuments(this.query, this.Ao, this.mutatedKeys, 0 /* Local */ === this.To);
|
|
12799
12807
|
}
|
|
12800
12808
|
}
|
|
12801
12809
|
|
|
@@ -12834,7 +12842,7 @@ class ec {
|
|
|
12834
12842
|
* decide whether it needs to manufacture a delete event for the target once
|
|
12835
12843
|
* the target is CURRENT.
|
|
12836
12844
|
*/
|
|
12837
|
-
this.
|
|
12845
|
+
this.ko = !1;
|
|
12838
12846
|
}
|
|
12839
12847
|
}
|
|
12840
12848
|
|
|
@@ -12855,8 +12863,8 @@ class ec {
|
|
|
12855
12863
|
// PORTING NOTE: Manages state synchronization in multi-tab environments.
|
|
12856
12864
|
s, i, r) {
|
|
12857
12865
|
this.localStore = t, this.remoteStore = e, this.eventManager = n, this.sharedClientState = s,
|
|
12858
|
-
this.currentUser = i, this.maxConcurrentLimboResolutions = r, this
|
|
12859
|
-
this.
|
|
12866
|
+
this.currentUser = i, this.maxConcurrentLimboResolutions = r, this.$o = {}, this.Oo = new Wi((t => Pe(t)), be),
|
|
12867
|
+
this.Fo = new Map,
|
|
12860
12868
|
/**
|
|
12861
12869
|
* The keys of documents that are in limbo for which we haven't yet started a
|
|
12862
12870
|
* limbo resolution query. The strings in this set are the result of calling
|
|
@@ -12866,28 +12874,28 @@ class ec {
|
|
|
12866
12874
|
* of arbitrary elements and it also maintains insertion order, providing the
|
|
12867
12875
|
* desired queue-like FIFO semantics.
|
|
12868
12876
|
*/
|
|
12869
|
-
this
|
|
12877
|
+
this.Mo = new Set,
|
|
12870
12878
|
/**
|
|
12871
12879
|
* Keeps track of the target ID for each document that is in limbo with an
|
|
12872
12880
|
* active target.
|
|
12873
12881
|
*/
|
|
12874
|
-
this.
|
|
12882
|
+
this.Lo = new mn(Vt.comparator),
|
|
12875
12883
|
/**
|
|
12876
12884
|
* Keeps track of the information about an active limbo resolution for each
|
|
12877
12885
|
* active target ID that was started for the purpose of limbo resolution.
|
|
12878
12886
|
*/
|
|
12879
|
-
this.
|
|
12887
|
+
this.Bo = new Map, this.Uo = new vr,
|
|
12880
12888
|
/** Stores user completion handlers, indexed by User and BatchId. */
|
|
12881
|
-
this.
|
|
12889
|
+
this.qo = {},
|
|
12882
12890
|
/** Stores user callbacks waiting for all pending writes to be acknowledged. */
|
|
12883
|
-
this.
|
|
12891
|
+
this.Ko = new Map, this.jo = ki.ie(), this.onlineState = "Unknown" /* Unknown */ ,
|
|
12884
12892
|
// The primary state is set to `true` or `false` immediately after Firestore
|
|
12885
12893
|
// startup. In the interim, a client should only be considered primary if
|
|
12886
12894
|
// `isPrimary` is true.
|
|
12887
|
-
this.
|
|
12895
|
+
this.Qo = void 0;
|
|
12888
12896
|
}
|
|
12889
12897
|
get isPrimaryClient() {
|
|
12890
|
-
return !0 === this.
|
|
12898
|
+
return !0 === this.Qo;
|
|
12891
12899
|
}
|
|
12892
12900
|
}
|
|
12893
12901
|
|
|
@@ -12899,7 +12907,7 @@ class ec {
|
|
|
12899
12907
|
async function ic(t, e) {
|
|
12900
12908
|
const n = xc(t);
|
|
12901
12909
|
let s, i;
|
|
12902
|
-
const r = n.
|
|
12910
|
+
const r = n.Oo.get(e);
|
|
12903
12911
|
if (r)
|
|
12904
12912
|
// PORTING NOTE: With Multi-Tab Web, it is possible that a query view
|
|
12905
12913
|
// already exists when EventManager calls us for the first time. This
|
|
@@ -12907,7 +12915,7 @@ async function ic(t, e) {
|
|
|
12907
12915
|
// behalf of another tab and the user of the primary also starts listening
|
|
12908
12916
|
// to the query. EventManager will not have an assigned target ID in this
|
|
12909
12917
|
// case and calls `listen` to obtain this ID.
|
|
12910
|
-
s = r.targetId, n.sharedClientState.addLocalQueryTarget(s), i = r.view.
|
|
12918
|
+
s = r.targetId, n.sharedClientState.addLocalQueryTarget(s), i = r.view.xo(); else {
|
|
12911
12919
|
const t = await yr(n.localStore, Ae(e)), r = n.sharedClientState.addLocalQueryTarget(t.targetId);
|
|
12912
12920
|
s = t.targetId, i = await rc(n, e, s, "current" === r), n.isPrimaryClient && uo(n.remoteStore, t);
|
|
12913
12921
|
}
|
|
@@ -12921,29 +12929,29 @@ async function ic(t, e) {
|
|
|
12921
12929
|
// PORTING NOTE: On Web only, we inject the code that registers new Limbo
|
|
12922
12930
|
// targets based on view changes. This allows us to only depend on Limbo
|
|
12923
12931
|
// changes when user code includes queries.
|
|
12924
|
-
t.
|
|
12925
|
-
let i = e.view.
|
|
12932
|
+
t.Wo = (e, n, s) => async function(t, e, n, s) {
|
|
12933
|
+
let i = e.view.bo(n);
|
|
12926
12934
|
i.Ln && (
|
|
12927
12935
|
// The query has a limit and some docs were removed, so we need
|
|
12928
12936
|
// to re-run the query against the local store to make sure we
|
|
12929
12937
|
// didn't lose any good docs that had been past the limit.
|
|
12930
12938
|
i = await Tr(t.localStore, e.query,
|
|
12931
|
-
/* usePreviousResults= */ !1).then((({documents: t}) => e.view.
|
|
12939
|
+
/* usePreviousResults= */ !1).then((({documents: t}) => e.view.bo(t, i))));
|
|
12932
12940
|
const r = s && s.targetChanges.get(e.targetId), o = e.view.applyChanges(i,
|
|
12933
12941
|
/* updateLimboDocuments= */ t.isPrimaryClient, r);
|
|
12934
|
-
return yc(t, e.targetId, o.
|
|
12942
|
+
return yc(t, e.targetId, o.Do), o.snapshot;
|
|
12935
12943
|
}(t, e, n, s);
|
|
12936
12944
|
const i = await Tr(t.localStore, e,
|
|
12937
|
-
/* usePreviousResults= */ !0), r = new tc(e, i.Gn), o = r.
|
|
12945
|
+
/* usePreviousResults= */ !0), r = new tc(e, i.Gn), o = r.bo(i.documents), c = Nn.createSynthesizedTargetChangeForCurrentChange(n, s && "Offline" /* Offline */ !== t.onlineState), a = r.applyChanges(o,
|
|
12938
12946
|
/* updateLimboDocuments= */ t.isPrimaryClient, c);
|
|
12939
|
-
yc(t, n, a.
|
|
12947
|
+
yc(t, n, a.Do);
|
|
12940
12948
|
const u = new ec(e, n, r);
|
|
12941
|
-
return t.
|
|
12949
|
+
return t.Oo.set(e, u), t.Fo.has(n) ? t.Fo.get(n).push(e) : t.Fo.set(n, [ e ]), a.snapshot;
|
|
12942
12950
|
}
|
|
12943
12951
|
|
|
12944
12952
|
/** Stops listening to the query. */ async function oc(t, e) {
|
|
12945
|
-
const n = K(t), s = n.
|
|
12946
|
-
if (i.length > 1) return n.
|
|
12953
|
+
const n = K(t), s = n.Oo.get(e), i = n.Fo.get(s.targetId);
|
|
12954
|
+
if (i.length > 1) return n.Fo.set(s.targetId, i.filter((t => !be(t, e)))), void n.Oo.delete(e);
|
|
12947
12955
|
// No other queries are mapped to the target, clean up the query and the target.
|
|
12948
12956
|
if (n.isPrimaryClient) {
|
|
12949
12957
|
// We need to remove the local query target first to allow us to verify
|
|
@@ -12996,9 +13004,9 @@ async function ic(t, e) {
|
|
|
12996
13004
|
})));
|
|
12997
13005
|
}(s.localStore, e);
|
|
12998
13006
|
s.sharedClientState.addPendingMutation(t.batchId), function(t, e, n) {
|
|
12999
|
-
let s = t.
|
|
13007
|
+
let s = t.qo[t.currentUser.toKey()];
|
|
13000
13008
|
s || (s = new mn(nt));
|
|
13001
|
-
s = s.insert(e, n), t.
|
|
13009
|
+
s = s.insert(e, n), t.qo[t.currentUser.toKey()] = s;
|
|
13002
13010
|
}
|
|
13003
13011
|
/**
|
|
13004
13012
|
* Resolves or rejects the user callback for the given batch and then discards
|
|
@@ -13022,13 +13030,13 @@ async function ic(t, e) {
|
|
|
13022
13030
|
const t = await _r(n.localStore, e);
|
|
13023
13031
|
// Update `receivedDocument` as appropriate for any limbo targets.
|
|
13024
13032
|
e.targetChanges.forEach(((t, e) => {
|
|
13025
|
-
const s = n.
|
|
13033
|
+
const s = n.Bo.get(e);
|
|
13026
13034
|
s && (
|
|
13027
13035
|
// Since this is a limbo resolution lookup, it's for a single document
|
|
13028
13036
|
// and it could be added, modified, or removed, but not a combination.
|
|
13029
13037
|
U(t.addedDocuments.size + t.modifiedDocuments.size + t.removedDocuments.size <= 1),
|
|
13030
|
-
t.addedDocuments.size > 0 ? s.
|
|
13031
|
-
s.
|
|
13038
|
+
t.addedDocuments.size > 0 ? s.ko = !0 : t.modifiedDocuments.size > 0 ? U(s.ko) : t.removedDocuments.size > 0 && (U(s.ko),
|
|
13039
|
+
s.ko = !1));
|
|
13032
13040
|
})), await Ec(n, t, e);
|
|
13033
13041
|
} catch (t) {
|
|
13034
13042
|
await Li(t);
|
|
@@ -13046,8 +13054,8 @@ async function ic(t, e) {
|
|
|
13046
13054
|
// SharedClientState.
|
|
13047
13055
|
if (s.isPrimaryClient && 0 /* RemoteStore */ === n || !s.isPrimaryClient && 1 /* SharedClientState */ === n) {
|
|
13048
13056
|
const t = [];
|
|
13049
|
-
s.
|
|
13050
|
-
const i = s.view.
|
|
13057
|
+
s.Oo.forEach(((n, s) => {
|
|
13058
|
+
const i = s.view.io(e);
|
|
13051
13059
|
i.snapshot && t.push(i.snapshot);
|
|
13052
13060
|
})), function(t, e) {
|
|
13053
13061
|
const n = K(t);
|
|
@@ -13056,9 +13064,9 @@ async function ic(t, e) {
|
|
|
13056
13064
|
n.queries.forEach(((t, n) => {
|
|
13057
13065
|
for (const t of n.listeners)
|
|
13058
13066
|
// Run global snapshot listeners if a consistent snapshot has been emitted.
|
|
13059
|
-
t.
|
|
13067
|
+
t.io(e) && (s = !0);
|
|
13060
13068
|
})), s && Wo(n);
|
|
13061
|
-
}(s.eventManager, e), t.length && s.
|
|
13069
|
+
}(s.eventManager, e), t.length && s.$o.Rr(t), s.onlineState = e, s.isPrimaryClient && s.sharedClientState.setOnlineState(e);
|
|
13062
13070
|
}
|
|
13063
13071
|
}
|
|
13064
13072
|
|
|
@@ -13076,7 +13084,7 @@ async function ic(t, e) {
|
|
|
13076
13084
|
const s = K(t);
|
|
13077
13085
|
// PORTING NOTE: Multi-tab only.
|
|
13078
13086
|
s.sharedClientState.updateQueryState(e, "rejected", n);
|
|
13079
|
-
const i = s.
|
|
13087
|
+
const i = s.Bo.get(e), r = i && i.key;
|
|
13080
13088
|
if (r) {
|
|
13081
13089
|
// TODO(klimt): We really only should do the following on permission
|
|
13082
13090
|
// denied errors, but we don't have the cause code here.
|
|
@@ -13095,7 +13103,7 @@ async function ic(t, e) {
|
|
|
13095
13103
|
// RemoteEvent. If `applyRemoteEvent()` throws, we want to re-listen to
|
|
13096
13104
|
// this query when the RemoteStore restarts the Watch stream, which should
|
|
13097
13105
|
// re-trigger the target failure.
|
|
13098
|
-
s.
|
|
13106
|
+
s.Lo = s.Lo.remove(r), s.Bo.delete(e), Tc(s);
|
|
13099
13107
|
} else await pr(s.localStore, e,
|
|
13100
13108
|
/* keepPersistedTargetData */ !1).then((() => mc(s, e, n))).catch(Li);
|
|
13101
13109
|
}
|
|
@@ -13156,8 +13164,8 @@ async function fc(t, e, n) {
|
|
|
13156
13164
|
if (-1 === t)
|
|
13157
13165
|
// Trigger the callback right away if there is no pending writes at the moment.
|
|
13158
13166
|
return void e.resolve();
|
|
13159
|
-
const s = n.
|
|
13160
|
-
s.push(e), n.
|
|
13167
|
+
const s = n.Ko.get(t) || [];
|
|
13168
|
+
s.push(e), n.Ko.set(t, s);
|
|
13161
13169
|
} catch (t) {
|
|
13162
13170
|
const n = Oo(t, "Initialization of waitForPendingWrites() operation failed");
|
|
13163
13171
|
e.reject(n);
|
|
@@ -13168,28 +13176,28 @@ async function fc(t, e, n) {
|
|
|
13168
13176
|
* Triggers the callbacks that are waiting for this batch id to get acknowledged by server,
|
|
13169
13177
|
* if there are any.
|
|
13170
13178
|
*/ function wc(t, e) {
|
|
13171
|
-
(t.
|
|
13179
|
+
(t.Ko.get(e) || []).forEach((t => {
|
|
13172
13180
|
t.resolve();
|
|
13173
|
-
})), t.
|
|
13181
|
+
})), t.Ko.delete(e);
|
|
13174
13182
|
}
|
|
13175
13183
|
|
|
13176
13184
|
/** Reject all outstanding callbacks waiting for pending writes to complete. */ function _c(t, e, n) {
|
|
13177
13185
|
const s = K(t);
|
|
13178
|
-
let i = s.
|
|
13186
|
+
let i = s.qo[s.currentUser.toKey()];
|
|
13179
13187
|
// NOTE: Mutations restored from persistence won't have callbacks, so it's
|
|
13180
13188
|
// okay for there to be no callback for this ID.
|
|
13181
13189
|
if (i) {
|
|
13182
13190
|
const t = i.get(e);
|
|
13183
|
-
t && (n ? t.reject(n) : t.resolve(), i = i.remove(e)), s.
|
|
13191
|
+
t && (n ? t.reject(n) : t.resolve(), i = i.remove(e)), s.qo[s.currentUser.toKey()] = i;
|
|
13184
13192
|
}
|
|
13185
13193
|
}
|
|
13186
13194
|
|
|
13187
13195
|
function mc(t, e, n = null) {
|
|
13188
13196
|
t.sharedClientState.removeLocalQueryTarget(e);
|
|
13189
|
-
for (const s of t.
|
|
13190
|
-
if (t.
|
|
13191
|
-
t.
|
|
13192
|
-
t.
|
|
13197
|
+
for (const s of t.Fo.get(e)) t.Oo.delete(s), n && t.$o.Go(s, n);
|
|
13198
|
+
if (t.Fo.delete(e), t.isPrimaryClient) {
|
|
13199
|
+
t.Uo.cs(e).forEach((e => {
|
|
13200
|
+
t.Uo.containsKey(e) ||
|
|
13193
13201
|
// We removed the last reference for this key
|
|
13194
13202
|
gc(t, e);
|
|
13195
13203
|
}));
|
|
@@ -13197,17 +13205,17 @@ function mc(t, e, n = null) {
|
|
|
13197
13205
|
}
|
|
13198
13206
|
|
|
13199
13207
|
function gc(t, e) {
|
|
13200
|
-
t
|
|
13208
|
+
t.Mo.delete(e.path.canonicalString());
|
|
13201
13209
|
// It's possible that the target already got removed because the query failed. In that case,
|
|
13202
13210
|
// the key won't exist in `limboTargetsByKey`. Only do the cleanup if we still have the target.
|
|
13203
|
-
const n = t.
|
|
13204
|
-
null !== n && (ho(t.remoteStore, n), t.
|
|
13211
|
+
const n = t.Lo.get(e);
|
|
13212
|
+
null !== n && (ho(t.remoteStore, n), t.Lo = t.Lo.remove(e), t.Bo.delete(n), Tc(t));
|
|
13205
13213
|
}
|
|
13206
13214
|
|
|
13207
13215
|
function yc(t, e, n) {
|
|
13208
|
-
for (const s of n) if (s instanceof Xo) t.
|
|
13209
|
-
O("SyncEngine", "Document no longer in limbo: " + s.key), t.
|
|
13210
|
-
t.
|
|
13216
|
+
for (const s of n) if (s instanceof Xo) t.Uo.addReference(s.key, e), pc(t, s); else if (s instanceof Zo) {
|
|
13217
|
+
O("SyncEngine", "Document no longer in limbo: " + s.key), t.Uo.removeReference(s.key, e);
|
|
13218
|
+
t.Uo.containsKey(s.key) ||
|
|
13211
13219
|
// We removed the last reference for this key
|
|
13212
13220
|
gc(t, s.key);
|
|
13213
13221
|
} else B();
|
|
@@ -13215,7 +13223,7 @@ function yc(t, e, n) {
|
|
|
13215
13223
|
|
|
13216
13224
|
function pc(t, e) {
|
|
13217
13225
|
const n = e.key, s = n.path.canonicalString();
|
|
13218
|
-
t.
|
|
13226
|
+
t.Lo.get(n) || t.Mo.has(s) || (O("SyncEngine", "New document in limbo: " + n), t.Mo.add(s),
|
|
13219
13227
|
Tc(t));
|
|
13220
13228
|
}
|
|
13221
13229
|
|
|
@@ -13227,18 +13235,18 @@ function pc(t, e) {
|
|
|
13227
13235
|
* with "resource exhausted" errors which can lead to pathological client
|
|
13228
13236
|
* behavior as seen in https://github.com/firebase/firebase-js-sdk/issues/2683.
|
|
13229
13237
|
*/ function Tc(t) {
|
|
13230
|
-
for (;t
|
|
13231
|
-
const e = t
|
|
13232
|
-
t
|
|
13233
|
-
const n = new Vt(lt.fromString(e)), s = t.
|
|
13234
|
-
t.
|
|
13238
|
+
for (;t.Mo.size > 0 && t.Lo.size < t.maxConcurrentLimboResolutions; ) {
|
|
13239
|
+
const e = t.Mo.values().next().value;
|
|
13240
|
+
t.Mo.delete(e);
|
|
13241
|
+
const n = new Vt(lt.fromString(e)), s = t.jo.next();
|
|
13242
|
+
t.Bo.set(s, new nc(n)), t.Lo = t.Lo.insert(n, s), uo(t.remoteStore, new oi(Ae(me(n.path)), s, 2 /* LimboResolution */ , Z.T));
|
|
13235
13243
|
}
|
|
13236
13244
|
}
|
|
13237
13245
|
|
|
13238
13246
|
async function Ec(t, e, n) {
|
|
13239
13247
|
const s = K(t), i = [], r = [], o = [];
|
|
13240
|
-
s.
|
|
13241
|
-
o.push(s.
|
|
13248
|
+
s.Oo.isEmpty() || (s.Oo.forEach(((t, c) => {
|
|
13249
|
+
o.push(s.Wo(c, e, n).then((t => {
|
|
13242
13250
|
if (t) {
|
|
13243
13251
|
s.isPrimaryClient && s.sharedClientState.updateQueryState(c.targetId, t.fromCache ? "not-current" : "current"),
|
|
13244
13252
|
i.push(t);
|
|
@@ -13246,7 +13254,7 @@ async function Ec(t, e, n) {
|
|
|
13246
13254
|
r.push(e);
|
|
13247
13255
|
}
|
|
13248
13256
|
})));
|
|
13249
|
-
})), await Promise.all(o), s.
|
|
13257
|
+
})), await Promise.all(o), s.$o.Rr(i), await async function(t, e) {
|
|
13250
13258
|
const n = K(t);
|
|
13251
13259
|
try {
|
|
13252
13260
|
await n.persistence.runTransaction("notifyLocalViewChanges", "readwrite", (t => Ws.forEach(e, (e => Ws.forEach(e.Nn, (s => n.persistence.referenceDelegate.addReference(t, e.targetId, s))).next((() => Ws.forEach(e.xn, (s => n.persistence.referenceDelegate.removeReference(t, e.targetId, s)))))))));
|
|
@@ -13277,11 +13285,11 @@ async function Ic(t, e) {
|
|
|
13277
13285
|
n.currentUser = e,
|
|
13278
13286
|
// Fails tasks waiting for pending writes requested by previous user.
|
|
13279
13287
|
function(t, e) {
|
|
13280
|
-
t.
|
|
13288
|
+
t.Ko.forEach((t => {
|
|
13281
13289
|
t.forEach((t => {
|
|
13282
13290
|
t.reject(new Q(j.CANCELLED, e));
|
|
13283
13291
|
}));
|
|
13284
|
-
})), t.
|
|
13292
|
+
})), t.Ko.clear();
|
|
13285
13293
|
}(n, "'waitForPendingWrites' promise is rejected due to a user change."),
|
|
13286
13294
|
// TODO(b/114226417): Consider calling this only in the primary tab.
|
|
13287
13295
|
n.sharedClientState.handleUserChange(e, t.removedBatchIds, t.addedBatchIds), await Ec(n, t.Wn);
|
|
@@ -13289,15 +13297,15 @@ async function Ic(t, e) {
|
|
|
13289
13297
|
}
|
|
13290
13298
|
|
|
13291
13299
|
function Ac(t, e) {
|
|
13292
|
-
const n = K(t), s = n.
|
|
13293
|
-
if (s && s.
|
|
13300
|
+
const n = K(t), s = n.Bo.get(e);
|
|
13301
|
+
if (s && s.ko) return Vn().add(s.key);
|
|
13294
13302
|
{
|
|
13295
13303
|
let t = Vn();
|
|
13296
|
-
const s = n.
|
|
13304
|
+
const s = n.Fo.get(e);
|
|
13297
13305
|
if (!s) return t;
|
|
13298
13306
|
for (const e of s) {
|
|
13299
|
-
const s = n.
|
|
13300
|
-
t = t.unionWith(s.view.
|
|
13307
|
+
const s = n.Oo.get(e);
|
|
13308
|
+
t = t.unionWith(s.view.Ro);
|
|
13301
13309
|
}
|
|
13302
13310
|
return t;
|
|
13303
13311
|
}
|
|
@@ -13308,8 +13316,8 @@ function Ac(t, e) {
|
|
|
13308
13316
|
* from persistence.
|
|
13309
13317
|
*/ async function Rc(t, e) {
|
|
13310
13318
|
const n = K(t), s = await Tr(n.localStore, e.query,
|
|
13311
|
-
/* usePreviousResults= */ !0), i = e.view.
|
|
13312
|
-
return n.isPrimaryClient && yc(n, e.targetId, i.
|
|
13319
|
+
/* usePreviousResults= */ !0), i = e.view.No(s);
|
|
13320
|
+
return n.isPrimaryClient && yc(n, e.targetId, i.Do), i;
|
|
13313
13321
|
}
|
|
13314
13322
|
|
|
13315
13323
|
/**
|
|
@@ -13357,7 +13365,7 @@ async function Pc(t, e, n, s) {
|
|
|
13357
13365
|
// PORTING NOTE: Multi-Tab only.
|
|
13358
13366
|
async function vc(t, e) {
|
|
13359
13367
|
const n = K(t);
|
|
13360
|
-
if (xc(n), kc(n), !0 === e && !0 !== n.
|
|
13368
|
+
if (xc(n), kc(n), !0 === e && !0 !== n.Qo) {
|
|
13361
13369
|
// Secondary tabs only maintain Views for their local listeners and the
|
|
13362
13370
|
// Views internal state may not be 100% populated (in particular
|
|
13363
13371
|
// secondary tabs don't track syncedDocuments, the set of documents the
|
|
@@ -13365,12 +13373,12 @@ async function vc(t, e) {
|
|
|
13365
13373
|
// primary, we need to need to make sure that all views for all targets
|
|
13366
13374
|
// match the state on disk.
|
|
13367
13375
|
const t = n.sharedClientState.getAllActiveQueryTargets(), e = await Vc(n, t.toArray());
|
|
13368
|
-
n.
|
|
13376
|
+
n.Qo = !0, await No(n.remoteStore, !0);
|
|
13369
13377
|
for (const t of e) uo(n.remoteStore, t);
|
|
13370
|
-
} else if (!1 === e && !1 !== n.
|
|
13378
|
+
} else if (!1 === e && !1 !== n.Qo) {
|
|
13371
13379
|
const t = [];
|
|
13372
13380
|
let e = Promise.resolve();
|
|
13373
|
-
n.
|
|
13381
|
+
n.Fo.forEach(((s, i) => {
|
|
13374
13382
|
n.sharedClientState.isLocalQueryTarget(i) ? t.push(i) : e = e.then((() => (mc(n, i),
|
|
13375
13383
|
pr(n.localStore, i,
|
|
13376
13384
|
/*keepPersistedTargetData=*/ !0)))), ho(n.remoteStore, i);
|
|
@@ -13378,9 +13386,9 @@ async function vc(t, e) {
|
|
|
13378
13386
|
// PORTING NOTE: Multi-Tab only.
|
|
13379
13387
|
function(t) {
|
|
13380
13388
|
const e = K(t);
|
|
13381
|
-
e.
|
|
13389
|
+
e.Bo.forEach(((t, n) => {
|
|
13382
13390
|
ho(e.remoteStore, n);
|
|
13383
|
-
})), e.
|
|
13391
|
+
})), e.Uo.us(), e.Bo = new Map, e.Lo = new mn(Vt.comparator);
|
|
13384
13392
|
}
|
|
13385
13393
|
/**
|
|
13386
13394
|
* Reconcile the query views of the provided query targets with the state from
|
|
@@ -13393,7 +13401,7 @@ async function vc(t, e) {
|
|
|
13393
13401
|
* tab to a primary tab
|
|
13394
13402
|
*/
|
|
13395
13403
|
// PORTING NOTE: Multi-Tab only.
|
|
13396
|
-
(n), n.
|
|
13404
|
+
(n), n.Qo = !1, await No(n.remoteStore, !1);
|
|
13397
13405
|
}
|
|
13398
13406
|
}
|
|
13399
13407
|
|
|
@@ -13401,7 +13409,7 @@ async function Vc(t, e, n) {
|
|
|
13401
13409
|
const s = K(t), i = [], r = [];
|
|
13402
13410
|
for (const t of e) {
|
|
13403
13411
|
let e;
|
|
13404
|
-
const n = s.
|
|
13412
|
+
const n = s.Fo.get(t);
|
|
13405
13413
|
if (n && 0 !== n.length) {
|
|
13406
13414
|
// For queries that have a local View, we fetch their current state
|
|
13407
13415
|
// from LocalStore (as the resume token and the snapshot version
|
|
@@ -13409,7 +13417,7 @@ async function Vc(t, e, n) {
|
|
|
13409
13417
|
// state (the list of syncedDocuments may have gotten out of sync).
|
|
13410
13418
|
e = await yr(s.localStore, Ae(n[0]));
|
|
13411
13419
|
for (const t of n) {
|
|
13412
|
-
const e = s.
|
|
13420
|
+
const e = s.Oo.get(t), n = await Rc(s, e);
|
|
13413
13421
|
n.snapshot && r.push(n.snapshot);
|
|
13414
13422
|
}
|
|
13415
13423
|
} else {
|
|
@@ -13421,7 +13429,7 @@ async function Vc(t, e, n) {
|
|
|
13421
13429
|
}
|
|
13422
13430
|
i.push(e);
|
|
13423
13431
|
}
|
|
13424
|
-
return s.
|
|
13432
|
+
return s.$o.Rr(r), i;
|
|
13425
13433
|
}
|
|
13426
13434
|
|
|
13427
13435
|
/**
|
|
@@ -13450,10 +13458,10 @@ function Dc(t) {
|
|
|
13450
13458
|
// PORTING NOTE: Multi-Tab only.
|
|
13451
13459
|
async function Cc(t, e, n, s) {
|
|
13452
13460
|
const i = K(t);
|
|
13453
|
-
if (i.
|
|
13461
|
+
if (i.Qo)
|
|
13454
13462
|
// If we receive a target state notification via WebStorage, we are
|
|
13455
13463
|
// either already secondary or another tab has taken the primary lease.
|
|
13456
|
-
O("SyncEngine", "Ignoring unexpected query state notification."); else if (i.
|
|
13464
|
+
O("SyncEngine", "Ignoring unexpected query state notification."); else if (i.Fo.has(e)) switch (n) {
|
|
13457
13465
|
case "current":
|
|
13458
13466
|
case "not-current":
|
|
13459
13467
|
{
|
|
@@ -13474,9 +13482,9 @@ async function Cc(t, e, n, s) {
|
|
|
13474
13482
|
|
|
13475
13483
|
/** Adds or removes Watch targets for queries from different tabs. */ async function Nc(t, e, n) {
|
|
13476
13484
|
const s = xc(t);
|
|
13477
|
-
if (s.
|
|
13485
|
+
if (s.Qo) {
|
|
13478
13486
|
for (const t of e) {
|
|
13479
|
-
if (s.
|
|
13487
|
+
if (s.Fo.has(t)) {
|
|
13480
13488
|
// A target might have been added in a previous attempt
|
|
13481
13489
|
O("SyncEngine", "Adding an already active target " + t);
|
|
13482
13490
|
continue;
|
|
@@ -13488,7 +13496,7 @@ async function Cc(t, e, n, s) {
|
|
|
13488
13496
|
for (const t of n)
|
|
13489
13497
|
// Check that the target is still active since the target might have been
|
|
13490
13498
|
// removed if it has been rejected by the backend.
|
|
13491
|
-
s.
|
|
13499
|
+
s.Fo.has(t) &&
|
|
13492
13500
|
// Release queries that are still active.
|
|
13493
13501
|
await pr(s.localStore, t,
|
|
13494
13502
|
/* keepPersistedTargetData */ !1).then((() => {
|
|
@@ -13500,8 +13508,8 @@ async function Cc(t, e, n, s) {
|
|
|
13500
13508
|
function xc(t) {
|
|
13501
13509
|
const e = K(t);
|
|
13502
13510
|
return e.remoteStore.remoteSyncer.applyRemoteEvent = ac.bind(null, e), e.remoteStore.remoteSyncer.getRemoteKeysForTarget = Ac.bind(null, e),
|
|
13503
|
-
e.remoteStore.remoteSyncer.rejectListen = hc.bind(null, e), e.
|
|
13504
|
-
e.
|
|
13511
|
+
e.remoteStore.remoteSyncer.rejectListen = hc.bind(null, e), e.$o.Rr = jo.bind(null, e.eventManager),
|
|
13512
|
+
e.$o.Go = Qo.bind(null, e.eventManager), e;
|
|
13505
13513
|
}
|
|
13506
13514
|
|
|
13507
13515
|
function kc(t) {
|
|
@@ -13540,10 +13548,10 @@ function kc(t) {
|
|
|
13540
13548
|
}(s));
|
|
13541
13549
|
n._updateProgress(Yo(s));
|
|
13542
13550
|
const i = new Jo(s, t.localStore, e.N);
|
|
13543
|
-
let r = await e.
|
|
13551
|
+
let r = await e.zo();
|
|
13544
13552
|
for (;r; ) {
|
|
13545
|
-
const t = await i.
|
|
13546
|
-
t && n._updateProgress(t), r = await e.
|
|
13553
|
+
const t = await i.mo(r);
|
|
13554
|
+
t && n._updateProgress(t), r = await e.zo();
|
|
13547
13555
|
}
|
|
13548
13556
|
const o = await i.complete();
|
|
13549
13557
|
// TODO(b/160876443): This currently raises snapshots with
|
|
@@ -13593,19 +13601,19 @@ class Oc {
|
|
|
13593
13601
|
this.synchronizeTabs = !1;
|
|
13594
13602
|
}
|
|
13595
13603
|
async initialize(t) {
|
|
13596
|
-
this.N = Zr(t.databaseInfo.databaseId), this.sharedClientState = this.
|
|
13597
|
-
await this.persistence.start(), this.gcScheduler = this.
|
|
13604
|
+
this.N = Zr(t.databaseInfo.databaseId), this.sharedClientState = this.Ho(t), this.persistence = this.Jo(t),
|
|
13605
|
+
await this.persistence.start(), this.gcScheduler = this.Yo(t), this.localStore = this.Xo(t);
|
|
13598
13606
|
}
|
|
13599
|
-
|
|
13607
|
+
Yo(t) {
|
|
13600
13608
|
return null;
|
|
13601
13609
|
}
|
|
13602
|
-
|
|
13610
|
+
Xo(t) {
|
|
13603
13611
|
return lr(this.persistence, new ur, t.initialUser, this.N);
|
|
13604
13612
|
}
|
|
13605
|
-
|
|
13613
|
+
Jo(t) {
|
|
13606
13614
|
return new xr($r.Ns, this.N);
|
|
13607
13615
|
}
|
|
13608
|
-
|
|
13616
|
+
Ho(t) {
|
|
13609
13617
|
return new Qr;
|
|
13610
13618
|
}
|
|
13611
13619
|
async terminate() {
|
|
@@ -13618,29 +13626,29 @@ class Oc {
|
|
|
13618
13626
|
* Provides all components needed for Firestore with IndexedDB persistence.
|
|
13619
13627
|
*/ class Fc extends Oc {
|
|
13620
13628
|
constructor(t, e, n) {
|
|
13621
|
-
super(), this.
|
|
13629
|
+
super(), this.Zo = t, this.cacheSizeBytes = e, this.forceOwnership = n, this.synchronizeTabs = !1;
|
|
13622
13630
|
}
|
|
13623
13631
|
async initialize(t) {
|
|
13624
|
-
await super.initialize(t), await Ar(this.localStore), await this.
|
|
13632
|
+
await super.initialize(t), await Ar(this.localStore), await this.Zo.initialize(this, t),
|
|
13625
13633
|
// Enqueue writes from a previous session
|
|
13626
|
-
await kc(this.
|
|
13634
|
+
await kc(this.Zo.syncEngine), await Ao(this.Zo.remoteStore),
|
|
13627
13635
|
// NOTE: This will immediately call the listener, so we make sure to
|
|
13628
13636
|
// set it after localStore / remoteStore are started.
|
|
13629
13637
|
await this.persistence.nn((() => (this.gcScheduler && !this.gcScheduler.started && this.gcScheduler.start(this.localStore),
|
|
13630
13638
|
Promise.resolve())));
|
|
13631
13639
|
}
|
|
13632
|
-
|
|
13640
|
+
Xo(t) {
|
|
13633
13641
|
return lr(this.persistence, new ur, t.initialUser, this.N);
|
|
13634
13642
|
}
|
|
13635
|
-
|
|
13643
|
+
Yo(t) {
|
|
13636
13644
|
const e = this.persistence.referenceDelegate.garbageCollector;
|
|
13637
13645
|
return new qi(e, t.asyncQueue);
|
|
13638
13646
|
}
|
|
13639
|
-
|
|
13647
|
+
Jo(t) {
|
|
13640
13648
|
const e = rr(t.databaseInfo.databaseId, t.databaseInfo.persistenceKey), n = void 0 !== this.cacheSizeBytes ? Pi.withCacheSize(this.cacheSizeBytes) : Pi.DEFAULT;
|
|
13641
13649
|
return new nr(this.synchronizeTabs, e, t.clientId, n, t.asyncQueue, Yr(), Xr(), this.N, this.sharedClientState, !!this.forceOwnership);
|
|
13642
13650
|
}
|
|
13643
|
-
|
|
13651
|
+
Ho(t) {
|
|
13644
13652
|
return new Qr;
|
|
13645
13653
|
}
|
|
13646
13654
|
}
|
|
@@ -13654,11 +13662,11 @@ class Oc {
|
|
|
13654
13662
|
* `synchronizeTabs` will be enabled.
|
|
13655
13663
|
*/ class Mc extends Fc {
|
|
13656
13664
|
constructor(t, e) {
|
|
13657
|
-
super(t, e, /* forceOwnership= */ !1), this.
|
|
13665
|
+
super(t, e, /* forceOwnership= */ !1), this.Zo = t, this.cacheSizeBytes = e, this.synchronizeTabs = !0;
|
|
13658
13666
|
}
|
|
13659
13667
|
async initialize(t) {
|
|
13660
13668
|
await super.initialize(t);
|
|
13661
|
-
const e = this.
|
|
13669
|
+
const e = this.Zo.syncEngine;
|
|
13662
13670
|
this.sharedClientState instanceof jr && (this.sharedClientState.syncEngine = {
|
|
13663
13671
|
_i: Pc.bind(null, e),
|
|
13664
13672
|
mi: Cc.bind(null, e),
|
|
@@ -13669,10 +13677,10 @@ class Oc {
|
|
|
13669
13677
|
// NOTE: This will immediately call the listener, so we make sure to
|
|
13670
13678
|
// set it after localStore / remoteStore are started.
|
|
13671
13679
|
await this.persistence.nn((async t => {
|
|
13672
|
-
await vc(this.
|
|
13680
|
+
await vc(this.Zo.syncEngine, t), this.gcScheduler && (t && !this.gcScheduler.started ? this.gcScheduler.start(this.localStore) : t || this.gcScheduler.stop());
|
|
13673
13681
|
}));
|
|
13674
13682
|
}
|
|
13675
|
-
|
|
13683
|
+
Ho(t) {
|
|
13676
13684
|
const e = Yr();
|
|
13677
13685
|
if (!jr.bt(e)) throw new Q(j.UNIMPLEMENTED, "IndexedDB persistence is only available on platforms that support LocalStorage.");
|
|
13678
13686
|
const n = rr(t.databaseInfo.databaseId, t.databaseInfo.persistenceKey);
|
|
@@ -13712,17 +13720,17 @@ class Oc {
|
|
|
13712
13720
|
// PORTING NOTE: Manages state synchronization in multi-tab environments.
|
|
13713
13721
|
s, i, r, o) {
|
|
13714
13722
|
const c = new sc(t, e, n, s, i, r);
|
|
13715
|
-
return o && (c.
|
|
13723
|
+
return o && (c.Qo = !0), c;
|
|
13716
13724
|
}(this.localStore, this.remoteStore, this.eventManager, this.sharedClientState, t.initialUser, t.maxConcurrentLimboResolutions, e);
|
|
13717
13725
|
}
|
|
13718
13726
|
terminate() {
|
|
13719
13727
|
return async function(t) {
|
|
13720
13728
|
const e = K(t);
|
|
13721
|
-
O("RemoteStore", "RemoteStore shutting down."), e.
|
|
13722
|
-
e.
|
|
13729
|
+
O("RemoteStore", "RemoteStore shutting down."), e.Wr.add(5 /* Shutdown */), await ao(e),
|
|
13730
|
+
e.zr.shutdown(),
|
|
13723
13731
|
// Set the OnlineState to Unknown (rather than Offline) to avoid potentially
|
|
13724
13732
|
// triggering spurious listener events with cached data, etc.
|
|
13725
|
-
e.
|
|
13733
|
+
e.Hr.set("Unknown" /* Unknown */);
|
|
13726
13734
|
}(this.remoteStore);
|
|
13727
13735
|
}
|
|
13728
13736
|
}
|
|
@@ -13830,15 +13838,15 @@ class Uc {
|
|
|
13830
13838
|
this.muted = !1;
|
|
13831
13839
|
}
|
|
13832
13840
|
next(t) {
|
|
13833
|
-
this.observer.next && this.
|
|
13841
|
+
this.observer.next && this.tc(this.observer.next, t);
|
|
13834
13842
|
}
|
|
13835
13843
|
error(t) {
|
|
13836
|
-
this.observer.error ? this.
|
|
13844
|
+
this.observer.error ? this.tc(this.observer.error, t) : console.error("Uncaught Error in snapshot listener:", t);
|
|
13837
13845
|
}
|
|
13838
|
-
|
|
13846
|
+
ec() {
|
|
13839
13847
|
this.muted = !0;
|
|
13840
13848
|
}
|
|
13841
|
-
|
|
13849
|
+
tc(t, e) {
|
|
13842
13850
|
this.muted || setTimeout((() => {
|
|
13843
13851
|
this.muted || t(e);
|
|
13844
13852
|
}), 0);
|
|
@@ -13870,28 +13878,28 @@ class Uc {
|
|
|
13870
13878
|
constructor(
|
|
13871
13879
|
/** The reader to read from underlying binary bundle data source. */
|
|
13872
13880
|
t, e) {
|
|
13873
|
-
this.
|
|
13881
|
+
this.nc = t, this.N = e,
|
|
13874
13882
|
/** Cached bundle metadata. */
|
|
13875
13883
|
this.metadata = new W,
|
|
13876
13884
|
/**
|
|
13877
13885
|
* Internal buffer to hold bundle content, accumulating incomplete element
|
|
13878
13886
|
* content.
|
|
13879
13887
|
*/
|
|
13880
|
-
this.buffer = new Uint8Array, this.
|
|
13888
|
+
this.buffer = new Uint8Array, this.sc = new TextDecoder("utf-8"),
|
|
13881
13889
|
// Read the metadata (which is the first element).
|
|
13882
|
-
this.
|
|
13883
|
-
t && t.
|
|
13890
|
+
this.ic().then((t => {
|
|
13891
|
+
t && t.wo() ? this.metadata.resolve(t.payload.metadata) : this.metadata.reject(new Error(`The first element of the bundle is not a metadata, it is\n ${JSON.stringify(null == t ? void 0 : t.payload)}`));
|
|
13884
13892
|
}), (t => this.metadata.reject(t)));
|
|
13885
13893
|
}
|
|
13886
13894
|
close() {
|
|
13887
|
-
return this.
|
|
13895
|
+
return this.nc.cancel();
|
|
13888
13896
|
}
|
|
13889
13897
|
async getMetadata() {
|
|
13890
13898
|
return this.metadata.promise;
|
|
13891
13899
|
}
|
|
13892
|
-
async
|
|
13900
|
+
async zo() {
|
|
13893
13901
|
// Makes sure metadata is read before proceeding.
|
|
13894
|
-
return await this.getMetadata(), this.
|
|
13902
|
+
return await this.getMetadata(), this.ic();
|
|
13895
13903
|
}
|
|
13896
13904
|
/**
|
|
13897
13905
|
* Reads from the head of internal buffer, and pulling more data from
|
|
@@ -13902,15 +13910,15 @@ class Uc {
|
|
|
13902
13910
|
*
|
|
13903
13911
|
* Returns either the bundled element, or null if we have reached the end of
|
|
13904
13912
|
* the stream.
|
|
13905
|
-
*/ async
|
|
13906
|
-
const t = await this.
|
|
13913
|
+
*/ async ic() {
|
|
13914
|
+
const t = await this.rc();
|
|
13907
13915
|
if (null === t) return null;
|
|
13908
|
-
const e = this.
|
|
13909
|
-
isNaN(n) && this.
|
|
13910
|
-
const s = await this.
|
|
13916
|
+
const e = this.sc.decode(t), n = Number(e);
|
|
13917
|
+
isNaN(n) && this.oc(`length string (${e}) is not valid number`);
|
|
13918
|
+
const s = await this.cc(n);
|
|
13911
13919
|
return new zo(JSON.parse(s), t.length + n);
|
|
13912
13920
|
}
|
|
13913
|
-
/** First index of '{' from the underlying buffer. */
|
|
13921
|
+
/** First index of '{' from the underlying buffer. */ ac() {
|
|
13914
13922
|
return this.buffer.findIndex((t => t === "{".charCodeAt(0)));
|
|
13915
13923
|
}
|
|
13916
13924
|
/**
|
|
@@ -13918,17 +13926,17 @@ class Uc {
|
|
|
13918
13926
|
* return the content.
|
|
13919
13927
|
*
|
|
13920
13928
|
* If reached end of the stream, returns a null.
|
|
13921
|
-
*/ async
|
|
13922
|
-
for (;this.
|
|
13923
|
-
if (await this.
|
|
13929
|
+
*/ async rc() {
|
|
13930
|
+
for (;this.ac() < 0; ) {
|
|
13931
|
+
if (await this.uc()) break;
|
|
13924
13932
|
}
|
|
13925
13933
|
// Broke out of the loop because underlying stream is closed, and there
|
|
13926
13934
|
// happens to be no more data to process.
|
|
13927
13935
|
if (0 === this.buffer.length) return null;
|
|
13928
|
-
const t = this.
|
|
13936
|
+
const t = this.ac();
|
|
13929
13937
|
// Broke out of the loop because underlying stream is closed, but still
|
|
13930
13938
|
// cannot find an open bracket.
|
|
13931
|
-
t < 0 && this.
|
|
13939
|
+
t < 0 && this.oc("Reached the end of bundle when a length string is expected.");
|
|
13932
13940
|
const e = this.buffer.slice(0, t);
|
|
13933
13941
|
// Update the internal buffer to drop the read length.
|
|
13934
13942
|
return this.buffer = this.buffer.slice(t), e;
|
|
@@ -13938,23 +13946,23 @@ class Uc {
|
|
|
13938
13946
|
* number of bytes, pulling more data from the underlying stream if needed.
|
|
13939
13947
|
*
|
|
13940
13948
|
* Returns a string decoded from the read bytes.
|
|
13941
|
-
*/ async
|
|
13949
|
+
*/ async cc(t) {
|
|
13942
13950
|
for (;this.buffer.length < t; ) {
|
|
13943
|
-
await this.
|
|
13951
|
+
await this.uc() && this.oc("Reached the end of bundle when more is expected.");
|
|
13944
13952
|
}
|
|
13945
|
-
const e = this.
|
|
13953
|
+
const e = this.sc.decode(this.buffer.slice(0, t));
|
|
13946
13954
|
// Update the internal buffer to drop the read json string.
|
|
13947
13955
|
return this.buffer = this.buffer.slice(t), e;
|
|
13948
13956
|
}
|
|
13949
|
-
|
|
13957
|
+
oc(t) {
|
|
13950
13958
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
13951
|
-
throw this.
|
|
13959
|
+
throw this.nc.cancel(), new Error(`Invalid bundle format: ${t}`);
|
|
13952
13960
|
}
|
|
13953
13961
|
/**
|
|
13954
13962
|
* Pulls more data from underlying stream to internal buffer.
|
|
13955
13963
|
* Returns a boolean indicating whether the stream is finished.
|
|
13956
|
-
*/ async
|
|
13957
|
-
const t = await this.
|
|
13964
|
+
*/ async uc() {
|
|
13965
|
+
const t = await this.nc.read();
|
|
13958
13966
|
if (!t.done) {
|
|
13959
13967
|
const e = new Uint8Array(this.buffer.length + t.value.length);
|
|
13960
13968
|
e.set(this.buffer), e.set(t.value, this.buffer.length), this.buffer = e;
|
|
@@ -14127,26 +14135,26 @@ class Kc {
|
|
|
14127
14135
|
class jc {
|
|
14128
14136
|
constructor(t, e, n, s) {
|
|
14129
14137
|
this.asyncQueue = t, this.datastore = e, this.updateFunction = n, this.deferred = s,
|
|
14130
|
-
this.
|
|
14138
|
+
this.hc = 5, this.ar = new to(this.asyncQueue, "transaction_retry" /* TransactionRetry */);
|
|
14131
14139
|
}
|
|
14132
14140
|
/** Runs the transaction and sets the result on deferred. */ run() {
|
|
14133
|
-
this.
|
|
14141
|
+
this.hc -= 1, this.lc();
|
|
14134
14142
|
}
|
|
14135
|
-
|
|
14136
|
-
this.
|
|
14137
|
-
const t = new Kc(this.datastore), e = this.
|
|
14143
|
+
lc() {
|
|
14144
|
+
this.ar.Xi((async () => {
|
|
14145
|
+
const t = new Kc(this.datastore), e = this.fc(t);
|
|
14138
14146
|
e && e.then((e => {
|
|
14139
14147
|
this.asyncQueue.enqueueAndForget((() => t.commit().then((() => {
|
|
14140
14148
|
this.deferred.resolve(e);
|
|
14141
14149
|
})).catch((t => {
|
|
14142
|
-
this.
|
|
14150
|
+
this.dc(t);
|
|
14143
14151
|
}))));
|
|
14144
14152
|
})).catch((t => {
|
|
14145
|
-
this.
|
|
14153
|
+
this.dc(t);
|
|
14146
14154
|
}));
|
|
14147
14155
|
}));
|
|
14148
14156
|
}
|
|
14149
|
-
|
|
14157
|
+
fc(t) {
|
|
14150
14158
|
try {
|
|
14151
14159
|
const e = this.updateFunction(t);
|
|
14152
14160
|
return !bt(e) && e.catch && e.then ? e : (this.deferred.reject(Error("Transaction callback must return a Promise")),
|
|
@@ -14156,11 +14164,11 @@ class jc {
|
|
|
14156
14164
|
return this.deferred.reject(t), null;
|
|
14157
14165
|
}
|
|
14158
14166
|
}
|
|
14159
|
-
|
|
14160
|
-
this.
|
|
14167
|
+
dc(t) {
|
|
14168
|
+
this.hc > 0 && this.wc(t) ? (this.hc -= 1, this.asyncQueue.enqueueAndForget((() => (this.lc(),
|
|
14161
14169
|
Promise.resolve())))) : this.deferred.reject(t);
|
|
14162
14170
|
}
|
|
14163
|
-
|
|
14171
|
+
wc(t) {
|
|
14164
14172
|
if ("FirebaseError" === t.name) {
|
|
14165
14173
|
// In transactions, the backend will fail outdated reads with FAILED_PRECONDITION and
|
|
14166
14174
|
// non-matching document versions with ABORTED. These errors should be retried.
|
|
@@ -14274,10 +14282,10 @@ async function Gc(t, e) {
|
|
|
14274
14282
|
// Tear down and re-create our network streams. This will ensure we get a
|
|
14275
14283
|
// fresh auth token for the new user and re-fill the write pipeline with
|
|
14276
14284
|
// new mutations from the LocalStore (since mutations are per-user).
|
|
14277
|
-
n.
|
|
14285
|
+
n.Wr.add(3 /* CredentialChange */), await ao(n), s &&
|
|
14278
14286
|
// Don't set the network status to Unknown if we are offline.
|
|
14279
|
-
n.
|
|
14280
|
-
n.
|
|
14287
|
+
n.Hr.set("Unknown" /* Unknown */), await n.remoteSyncer.handleCredentialChange(e),
|
|
14288
|
+
n.Wr.delete(3 /* CredentialChange */), await co(n);
|
|
14281
14289
|
}(e.remoteStore, t))), t.onlineComponents = e;
|
|
14282
14290
|
}
|
|
14283
14291
|
|
|
@@ -14318,7 +14326,7 @@ async function ta(t) {
|
|
|
14318
14326
|
const e = await Jc(t), n = await Xc(t);
|
|
14319
14327
|
return e.setNetworkEnabled(!0), function(t) {
|
|
14320
14328
|
const e = K(t);
|
|
14321
|
-
return e.
|
|
14329
|
+
return e.Wr.delete(0 /* UserDisabled */), co(e);
|
|
14322
14330
|
}(n);
|
|
14323
14331
|
}));
|
|
14324
14332
|
}
|
|
@@ -14328,9 +14336,9 @@ async function ta(t) {
|
|
|
14328
14336
|
const e = await Jc(t), n = await Xc(t);
|
|
14329
14337
|
return e.setNetworkEnabled(!1), async function(t) {
|
|
14330
14338
|
const e = K(t);
|
|
14331
|
-
e.
|
|
14339
|
+
e.Wr.add(0 /* UserDisabled */), await ao(e),
|
|
14332
14340
|
// Set the OnlineState to Offline so get()s return from cache, etc.
|
|
14333
|
-
e.
|
|
14341
|
+
e.Hr.set("Offline" /* Offline */);
|
|
14334
14342
|
}(n);
|
|
14335
14343
|
}));
|
|
14336
14344
|
}
|
|
@@ -14381,7 +14389,7 @@ function ia(t, e, n = {}) {
|
|
|
14381
14389
|
error: t => i.reject(t)
|
|
14382
14390
|
}), o = new Go(me(n.path), r, {
|
|
14383
14391
|
includeMetadataChanges: !0,
|
|
14384
|
-
|
|
14392
|
+
fo: !0
|
|
14385
14393
|
});
|
|
14386
14394
|
return qo(t, o);
|
|
14387
14395
|
}(await ta(t), t.asyncQueue, e, n, s))), s.promise;
|
|
@@ -14392,7 +14400,7 @@ function ra(t, e) {
|
|
|
14392
14400
|
return t.asyncQueue.enqueueAndForget((async () => async function(t, e, n) {
|
|
14393
14401
|
try {
|
|
14394
14402
|
const s = await Tr(t, e,
|
|
14395
|
-
/* usePreviousResults= */ !0), i = new tc(e, s.Gn), r = i.
|
|
14403
|
+
/* usePreviousResults= */ !0), i = new tc(e, s.Gn), r = i.bo(s.documents), o = i.applyChanges(r,
|
|
14396
14404
|
/* updateLimboDocuments= */ !1);
|
|
14397
14405
|
n.resolve(o.snapshot);
|
|
14398
14406
|
} catch (t) {
|
|
@@ -14418,7 +14426,7 @@ function oa(t, e, n = {}) {
|
|
|
14418
14426
|
error: t => i.reject(t)
|
|
14419
14427
|
}), o = new Go(n, r, {
|
|
14420
14428
|
includeMetadataChanges: !0,
|
|
14421
|
-
|
|
14429
|
+
fo: !0
|
|
14422
14430
|
});
|
|
14423
14431
|
return qo(t, o);
|
|
14424
14432
|
}(await ta(t), t.asyncQueue, e, n, s))), s.promise;
|
|
@@ -14427,13 +14435,13 @@ function oa(t, e, n = {}) {
|
|
|
14427
14435
|
function ca(t, e) {
|
|
14428
14436
|
const n = new Uc(e);
|
|
14429
14437
|
return t.asyncQueue.enqueueAndForget((async () => function(t, e) {
|
|
14430
|
-
K(t).
|
|
14438
|
+
K(t).so.add(e),
|
|
14431
14439
|
// Immediately fire an initial event, indicating all existing listeners
|
|
14432
14440
|
// are in-sync.
|
|
14433
14441
|
e.next();
|
|
14434
14442
|
}(await ta(t), n))), () => {
|
|
14435
|
-
n.
|
|
14436
|
-
K(t).
|
|
14443
|
+
n.ec(), t.asyncQueue.enqueueAndForget((async () => function(t, e) {
|
|
14444
|
+
K(t).so.delete(e);
|
|
14437
14445
|
}(await ta(t), n)));
|
|
14438
14446
|
};
|
|
14439
14447
|
}
|
|
@@ -15038,39 +15046,39 @@ function Sa(t, e, ...n) {
|
|
|
15038
15046
|
*/ class Na {
|
|
15039
15047
|
constructor() {
|
|
15040
15048
|
// The last promise in the queue.
|
|
15041
|
-
this.
|
|
15049
|
+
this._c = Promise.resolve(),
|
|
15042
15050
|
// A list of retryable operations. Retryable operations are run in order and
|
|
15043
15051
|
// retried with backoff.
|
|
15044
|
-
this.
|
|
15052
|
+
this.mc = [],
|
|
15045
15053
|
// Is this AsyncQueue being shut down? Once it is set to true, it will not
|
|
15046
15054
|
// be changed again.
|
|
15047
|
-
this.
|
|
15055
|
+
this.gc = !1,
|
|
15048
15056
|
// Operations scheduled to be queued in the future. Operations are
|
|
15049
15057
|
// automatically removed after they are run or canceled.
|
|
15050
|
-
this.
|
|
15058
|
+
this.yc = [],
|
|
15051
15059
|
// visible for testing
|
|
15052
|
-
this.
|
|
15060
|
+
this.Tc = null,
|
|
15053
15061
|
// Flag set while there's an outstanding AsyncQueue operation, used for
|
|
15054
15062
|
// assertion sanity-checks.
|
|
15055
|
-
this.
|
|
15063
|
+
this.Ec = !1,
|
|
15056
15064
|
// Enabled during shutdown on Safari to prevent future access to IndexedDB.
|
|
15057
|
-
this.
|
|
15065
|
+
this.Ic = !1,
|
|
15058
15066
|
// List of TimerIds to fast-forward delays for.
|
|
15059
|
-
this.
|
|
15067
|
+
this.Ac = [],
|
|
15060
15068
|
// Backoff timer used to schedule retries for retryable operations
|
|
15061
|
-
this.
|
|
15069
|
+
this.ar = new to(this, "async_queue_retry" /* AsyncQueueRetry */),
|
|
15062
15070
|
// Visibility handler that triggers an immediate retry of all retryable
|
|
15063
15071
|
// operations. Meant to speed up recovery when we regain file system access
|
|
15064
15072
|
// after page comes into foreground.
|
|
15065
|
-
this.
|
|
15073
|
+
this.Rc = () => {
|
|
15066
15074
|
const t = Xr();
|
|
15067
|
-
t && O("AsyncQueue", "Visibility state changed to " + t.visibilityState), this.
|
|
15075
|
+
t && O("AsyncQueue", "Visibility state changed to " + t.visibilityState), this.ar.tr();
|
|
15068
15076
|
};
|
|
15069
15077
|
const t = Xr();
|
|
15070
|
-
t && "function" == typeof t.addEventListener && t.addEventListener("visibilitychange", this.
|
|
15078
|
+
t && "function" == typeof t.addEventListener && t.addEventListener("visibilitychange", this.Rc);
|
|
15071
15079
|
}
|
|
15072
15080
|
get isShuttingDown() {
|
|
15073
|
-
return this.
|
|
15081
|
+
return this.gc;
|
|
15074
15082
|
}
|
|
15075
15083
|
/**
|
|
15076
15084
|
* Adds a new operation to the queue without waiting for it to complete (i.e.
|
|
@@ -15080,44 +15088,44 @@ function Sa(t, e, ...n) {
|
|
|
15080
15088
|
this.enqueue(t);
|
|
15081
15089
|
}
|
|
15082
15090
|
enqueueAndForgetEvenWhileRestricted(t) {
|
|
15083
|
-
this.
|
|
15091
|
+
this.bc(),
|
|
15084
15092
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
15085
|
-
this.
|
|
15093
|
+
this.Pc(t);
|
|
15086
15094
|
}
|
|
15087
15095
|
enterRestrictedMode(t) {
|
|
15088
|
-
if (!this.
|
|
15089
|
-
this.
|
|
15096
|
+
if (!this.gc) {
|
|
15097
|
+
this.gc = !0, this.Ic = t || !1;
|
|
15090
15098
|
const e = Xr();
|
|
15091
|
-
e && "function" == typeof e.removeEventListener && e.removeEventListener("visibilitychange", this.
|
|
15099
|
+
e && "function" == typeof e.removeEventListener && e.removeEventListener("visibilitychange", this.Rc);
|
|
15092
15100
|
}
|
|
15093
15101
|
}
|
|
15094
15102
|
enqueue(t) {
|
|
15095
|
-
if (this.
|
|
15103
|
+
if (this.bc(), this.gc)
|
|
15096
15104
|
// Return a Promise which never resolves.
|
|
15097
15105
|
return new Promise((() => {}));
|
|
15098
15106
|
// Create a deferred Promise that we can return to the callee. This
|
|
15099
15107
|
// allows us to return a "hanging Promise" only to the callee and still
|
|
15100
15108
|
// advance the queue even when the operation is not run.
|
|
15101
15109
|
const e = new W;
|
|
15102
|
-
return this.
|
|
15110
|
+
return this.Pc((() => this.gc && this.Ic ? Promise.resolve() : (t().then(e.resolve, e.reject),
|
|
15103
15111
|
e.promise))).then((() => e.promise));
|
|
15104
15112
|
}
|
|
15105
15113
|
enqueueRetryable(t) {
|
|
15106
|
-
this.enqueueAndForget((() => (this.
|
|
15114
|
+
this.enqueueAndForget((() => (this.mc.push(t), this.vc())));
|
|
15107
15115
|
}
|
|
15108
15116
|
/**
|
|
15109
15117
|
* Runs the next operation from the retryable queue. If the operation fails,
|
|
15110
15118
|
* reschedules with backoff.
|
|
15111
|
-
*/ async
|
|
15112
|
-
if (0 !== this.
|
|
15119
|
+
*/ async vc() {
|
|
15120
|
+
if (0 !== this.mc.length) {
|
|
15113
15121
|
try {
|
|
15114
|
-
await this.
|
|
15122
|
+
await this.mc[0](), this.mc.shift(), this.ar.reset();
|
|
15115
15123
|
} catch (t) {
|
|
15116
15124
|
if (!Ys(t)) throw t;
|
|
15117
15125
|
// Failure will be handled by AsyncQueue
|
|
15118
15126
|
O("AsyncQueue", "Operation failed with retryable error: " + t);
|
|
15119
15127
|
}
|
|
15120
|
-
this.
|
|
15128
|
+
this.mc.length > 0 &&
|
|
15121
15129
|
// If there are additional operations, we re-schedule `retryNextOp()`.
|
|
15122
15130
|
// This is necessary to run retryable operations that failed during
|
|
15123
15131
|
// their initial attempt since we don't know whether they are already
|
|
@@ -15128,12 +15136,12 @@ function Sa(t, e, ...n) {
|
|
|
15128
15136
|
// Since `backoffAndRun()` cancels an existing backoff and schedules a
|
|
15129
15137
|
// new backoff on every call, there is only ever a single additional
|
|
15130
15138
|
// operation in the queue.
|
|
15131
|
-
this.
|
|
15139
|
+
this.ar.Xi((() => this.vc()));
|
|
15132
15140
|
}
|
|
15133
15141
|
}
|
|
15134
|
-
|
|
15135
|
-
const e = this.
|
|
15136
|
-
this.
|
|
15142
|
+
Pc(t) {
|
|
15143
|
+
const e = this._c.then((() => (this.Ec = !0, t().catch((t => {
|
|
15144
|
+
this.Tc = t, this.Ec = !1;
|
|
15137
15145
|
const e =
|
|
15138
15146
|
/**
|
|
15139
15147
|
* Chrome includes Error.message in Error.stack. Other browsers do not.
|
|
@@ -15165,38 +15173,38 @@ function Sa(t, e, ...n) {
|
|
|
15165
15173
|
// all further attempts to chain (via .then) will just short-circuit
|
|
15166
15174
|
// and return the rejected Promise.
|
|
15167
15175
|
throw F("INTERNAL UNHANDLED ERROR: ", e), t;
|
|
15168
|
-
})).then((t => (this.
|
|
15169
|
-
return this.
|
|
15176
|
+
})).then((t => (this.Ec = !1, t))))));
|
|
15177
|
+
return this._c = e, e;
|
|
15170
15178
|
}
|
|
15171
15179
|
enqueueAfterDelay(t, e, n) {
|
|
15172
|
-
this.
|
|
15180
|
+
this.bc(),
|
|
15173
15181
|
// Fast-forward delays for timerIds that have been overriden.
|
|
15174
|
-
this.
|
|
15175
|
-
const s = $o.createAndSchedule(this, t, e, n, (t => this.
|
|
15176
|
-
return this.
|
|
15182
|
+
this.Ac.indexOf(t) > -1 && (e = 0);
|
|
15183
|
+
const s = $o.createAndSchedule(this, t, e, n, (t => this.Vc(t)));
|
|
15184
|
+
return this.yc.push(s), s;
|
|
15177
15185
|
}
|
|
15178
|
-
|
|
15179
|
-
this.
|
|
15186
|
+
bc() {
|
|
15187
|
+
this.Tc && B();
|
|
15180
15188
|
}
|
|
15181
15189
|
verifyOperationInProgress() {}
|
|
15182
15190
|
/**
|
|
15183
15191
|
* Waits until all currently queued tasks are finished executing. Delayed
|
|
15184
15192
|
* operations are not run.
|
|
15185
|
-
*/ async
|
|
15193
|
+
*/ async Sc() {
|
|
15186
15194
|
// Operations in the queue prior to draining may have enqueued additional
|
|
15187
15195
|
// operations. Keep draining the queue until the tail is no longer advanced,
|
|
15188
15196
|
// which indicates that no more new operations were enqueued and that all
|
|
15189
15197
|
// operations were executed.
|
|
15190
15198
|
let t;
|
|
15191
15199
|
do {
|
|
15192
|
-
t = this.
|
|
15193
|
-
} while (t !== this.
|
|
15200
|
+
t = this._c, await t;
|
|
15201
|
+
} while (t !== this._c);
|
|
15194
15202
|
}
|
|
15195
15203
|
/**
|
|
15196
15204
|
* For Tests: Determine if a delayed operation with a particular TimerId
|
|
15197
15205
|
* exists.
|
|
15198
|
-
*/
|
|
15199
|
-
for (const e of this.
|
|
15206
|
+
*/ Dc(t) {
|
|
15207
|
+
for (const e of this.yc) if (e.timerId === t) return !0;
|
|
15200
15208
|
return !1;
|
|
15201
15209
|
}
|
|
15202
15210
|
/**
|
|
@@ -15205,24 +15213,24 @@ function Sa(t, e, ...n) {
|
|
|
15205
15213
|
* @param lastTimerId - Delayed operations up to and including this TimerId
|
|
15206
15214
|
* will be drained. Pass TimerId.All to run all delayed operations.
|
|
15207
15215
|
* @returns a Promise that resolves once all operations have been run.
|
|
15208
|
-
*/
|
|
15216
|
+
*/ Cc(t) {
|
|
15209
15217
|
// Note that draining may generate more delayed ops, so we do that first.
|
|
15210
|
-
return this.
|
|
15218
|
+
return this.Sc().then((() => {
|
|
15211
15219
|
// Run ops in the same order they'd run if they ran naturally.
|
|
15212
|
-
this.
|
|
15213
|
-
for (const e of this.
|
|
15214
|
-
return this.
|
|
15220
|
+
this.yc.sort(((t, e) => t.targetTimeMs - e.targetTimeMs));
|
|
15221
|
+
for (const e of this.yc) if (e.skipDelay(), "all" /* All */ !== t && e.timerId === t) break;
|
|
15222
|
+
return this.Sc();
|
|
15215
15223
|
}));
|
|
15216
15224
|
}
|
|
15217
15225
|
/**
|
|
15218
15226
|
* For Tests: Skip all subsequent delays for a timer id.
|
|
15219
|
-
*/
|
|
15220
|
-
this.
|
|
15227
|
+
*/ Nc(t) {
|
|
15228
|
+
this.Ac.push(t);
|
|
15221
15229
|
}
|
|
15222
|
-
/** Called once a DelayedOperation is run or canceled. */
|
|
15230
|
+
/** Called once a DelayedOperation is run or canceled. */ Vc(t) {
|
|
15223
15231
|
// NOTE: indexOf / slice are O(n), but delayedOperations is expected to be small.
|
|
15224
|
-
const e = this.
|
|
15225
|
-
this.
|
|
15232
|
+
const e = this.yc.indexOf(t);
|
|
15233
|
+
this.yc.splice(e, 1);
|
|
15226
15234
|
}
|
|
15227
15235
|
}
|
|
15228
15236
|
|
|
@@ -15962,55 +15970,55 @@ function ou(t) {
|
|
|
15962
15970
|
this.settings = t, this.databaseId = e, this.N = n, this.ignoreUndefinedProperties = s,
|
|
15963
15971
|
// Minor hack: If fieldTransforms is undefined, we assume this is an
|
|
15964
15972
|
// external call and we need to validate the entire path.
|
|
15965
|
-
void 0 === i && this.
|
|
15973
|
+
void 0 === i && this.xc(), this.fieldTransforms = i || [], this.fieldMask = r || [];
|
|
15966
15974
|
}
|
|
15967
15975
|
get path() {
|
|
15968
15976
|
return this.settings.path;
|
|
15969
15977
|
}
|
|
15970
|
-
get
|
|
15971
|
-
return this.settings.
|
|
15978
|
+
get kc() {
|
|
15979
|
+
return this.settings.kc;
|
|
15972
15980
|
}
|
|
15973
|
-
/** Returns a new context with the specified settings overwritten. */
|
|
15981
|
+
/** Returns a new context with the specified settings overwritten. */ $c(t) {
|
|
15974
15982
|
return new cu(Object.assign(Object.assign({}, this.settings), t), this.databaseId, this.N, this.ignoreUndefinedProperties, this.fieldTransforms, this.fieldMask);
|
|
15975
15983
|
}
|
|
15976
|
-
|
|
15984
|
+
Oc(t) {
|
|
15977
15985
|
var e;
|
|
15978
|
-
const n = null === (e = this.path) || void 0 === e ? void 0 : e.child(t), s = this
|
|
15986
|
+
const n = null === (e = this.path) || void 0 === e ? void 0 : e.child(t), s = this.$c({
|
|
15979
15987
|
path: n,
|
|
15980
|
-
|
|
15988
|
+
Fc: !1
|
|
15981
15989
|
});
|
|
15982
|
-
return s
|
|
15990
|
+
return s.Mc(t), s;
|
|
15983
15991
|
}
|
|
15984
|
-
|
|
15992
|
+
Lc(t) {
|
|
15985
15993
|
var e;
|
|
15986
|
-
const n = null === (e = this.path) || void 0 === e ? void 0 : e.child(t), s = this
|
|
15994
|
+
const n = null === (e = this.path) || void 0 === e ? void 0 : e.child(t), s = this.$c({
|
|
15987
15995
|
path: n,
|
|
15988
|
-
|
|
15996
|
+
Fc: !1
|
|
15989
15997
|
});
|
|
15990
|
-
return s.
|
|
15998
|
+
return s.xc(), s;
|
|
15991
15999
|
}
|
|
15992
|
-
|
|
16000
|
+
Bc(t) {
|
|
15993
16001
|
// TODO(b/34871131): We don't support array paths right now; so make path
|
|
15994
16002
|
// undefined.
|
|
15995
|
-
return this
|
|
16003
|
+
return this.$c({
|
|
15996
16004
|
path: void 0,
|
|
15997
|
-
|
|
16005
|
+
Fc: !0
|
|
15998
16006
|
});
|
|
15999
16007
|
}
|
|
16000
|
-
|
|
16001
|
-
return vu(t, this.settings.methodName, this.settings.
|
|
16008
|
+
Uc(t) {
|
|
16009
|
+
return vu(t, this.settings.methodName, this.settings.qc || !1, this.path, this.settings.Kc);
|
|
16002
16010
|
}
|
|
16003
16011
|
/** Returns 'true' if 'fieldPath' was traversed when creating this context. */ contains(t) {
|
|
16004
16012
|
return void 0 !== this.fieldMask.find((e => t.isPrefixOf(e))) || void 0 !== this.fieldTransforms.find((e => t.isPrefixOf(e.field)));
|
|
16005
16013
|
}
|
|
16006
|
-
|
|
16014
|
+
xc() {
|
|
16007
16015
|
// TODO(b/34871131): Remove null check once we have proper paths for fields
|
|
16008
16016
|
// within arrays.
|
|
16009
|
-
if (this.path) for (let t = 0; t < this.path.length; t++) this
|
|
16017
|
+
if (this.path) for (let t = 0; t < this.path.length; t++) this.Mc(this.path.get(t));
|
|
16010
16018
|
}
|
|
16011
|
-
|
|
16012
|
-
if (0 === t.length) throw this.
|
|
16013
|
-
if (ou(this.
|
|
16019
|
+
Mc(t) {
|
|
16020
|
+
if (0 === t.length) throw this.Uc("Document fields must not be empty");
|
|
16021
|
+
if (ou(this.kc) && su.test(t)) throw this.Uc('Document fields cannot begin and end with "__"');
|
|
16014
16022
|
}
|
|
16015
16023
|
}
|
|
16016
16024
|
|
|
@@ -16021,14 +16029,14 @@ function ou(t) {
|
|
|
16021
16029
|
constructor(t, e, n) {
|
|
16022
16030
|
this.databaseId = t, this.ignoreUndefinedProperties = e, this.N = n || Zr(t);
|
|
16023
16031
|
}
|
|
16024
|
-
/** Creates a new top-level parse context. */
|
|
16032
|
+
/** Creates a new top-level parse context. */ jc(t, e, n, s = !1) {
|
|
16025
16033
|
return new cu({
|
|
16026
|
-
|
|
16034
|
+
kc: t,
|
|
16027
16035
|
methodName: e,
|
|
16028
|
-
|
|
16036
|
+
Kc: n,
|
|
16029
16037
|
path: dt.emptyPath(),
|
|
16030
|
-
|
|
16031
|
-
|
|
16038
|
+
Fc: !1,
|
|
16039
|
+
qc: s
|
|
16032
16040
|
}, this.databaseId, this.N, this.ignoreUndefinedProperties);
|
|
16033
16041
|
}
|
|
16034
16042
|
}
|
|
@@ -16039,7 +16047,7 @@ function uu(t) {
|
|
|
16039
16047
|
}
|
|
16040
16048
|
|
|
16041
16049
|
/** Parse document data from a set() call. */ function hu(t, e, n, s, i, r = {}) {
|
|
16042
|
-
const o = t.
|
|
16050
|
+
const o = t.jc(r.merge || r.mergeFields ? 2 /* MergeSet */ : 0 /* Set */ , e, n, i);
|
|
16043
16051
|
Au("Data must be an object, but it was:", o, s);
|
|
16044
16052
|
const c = Eu(s, o);
|
|
16045
16053
|
let a, u;
|
|
@@ -16057,7 +16065,7 @@ function uu(t) {
|
|
|
16057
16065
|
|
|
16058
16066
|
class lu extends eu {
|
|
16059
16067
|
_toFieldTransform(t) {
|
|
16060
|
-
if (2 /* MergeSet */ !== t.
|
|
16068
|
+
if (2 /* MergeSet */ !== t.kc) throw 1 /* Update */ === t.kc ? t.Uc(`${this._methodName}() can only appear at the top level of your update data`) : t.Uc(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);
|
|
16061
16069
|
// No transform to add for a delete, but we need to add it to our
|
|
16062
16070
|
// fieldMask so it gets deleted.
|
|
16063
16071
|
return t.fieldMask.push(t.path), null;
|
|
@@ -16084,10 +16092,10 @@ class lu extends eu {
|
|
|
16084
16092
|
* @param arrayElement - Whether or not the FieldValue has an array.
|
|
16085
16093
|
*/ function fu(t, e, n) {
|
|
16086
16094
|
return new cu({
|
|
16087
|
-
|
|
16088
|
-
|
|
16095
|
+
kc: 3 /* Argument */ ,
|
|
16096
|
+
Kc: e.settings.Kc,
|
|
16089
16097
|
methodName: t._methodName,
|
|
16090
|
-
|
|
16098
|
+
Fc: n
|
|
16091
16099
|
}, e.databaseId, e.N, e.ignoreUndefinedProperties);
|
|
16092
16100
|
}
|
|
16093
16101
|
|
|
@@ -16102,11 +16110,11 @@ class du extends eu {
|
|
|
16102
16110
|
|
|
16103
16111
|
class wu extends eu {
|
|
16104
16112
|
constructor(t, e) {
|
|
16105
|
-
super(t), this.
|
|
16113
|
+
super(t), this.Qc = e;
|
|
16106
16114
|
}
|
|
16107
16115
|
_toFieldTransform(t) {
|
|
16108
16116
|
const e = fu(this, t,
|
|
16109
|
-
/*array=*/ !0), n = this.
|
|
16117
|
+
/*array=*/ !0), n = this.Qc.map((t => Tu(t, e))), s = new Le(n);
|
|
16110
16118
|
return new We(t.path, s);
|
|
16111
16119
|
}
|
|
16112
16120
|
isEqual(t) {
|
|
@@ -16117,11 +16125,11 @@ class wu extends eu {
|
|
|
16117
16125
|
|
|
16118
16126
|
class _u extends eu {
|
|
16119
16127
|
constructor(t, e) {
|
|
16120
|
-
super(t), this.
|
|
16128
|
+
super(t), this.Qc = e;
|
|
16121
16129
|
}
|
|
16122
16130
|
_toFieldTransform(t) {
|
|
16123
16131
|
const e = fu(this, t,
|
|
16124
|
-
/*array=*/ !0), n = this.
|
|
16132
|
+
/*array=*/ !0), n = this.Qc.map((t => Tu(t, e))), s = new Ue(n);
|
|
16125
16133
|
return new We(t.path, s);
|
|
16126
16134
|
}
|
|
16127
16135
|
isEqual(t) {
|
|
@@ -16132,10 +16140,10 @@ class _u extends eu {
|
|
|
16132
16140
|
|
|
16133
16141
|
class mu extends eu {
|
|
16134
16142
|
constructor(t, e) {
|
|
16135
|
-
super(t), this.
|
|
16143
|
+
super(t), this.Wc = e;
|
|
16136
16144
|
}
|
|
16137
16145
|
_toFieldTransform(t) {
|
|
16138
|
-
const e = new Ke(t.N, xe(t.N, this.
|
|
16146
|
+
const e = new Ke(t.N, xe(t.N, this.Wc));
|
|
16139
16147
|
return new We(t.path, e);
|
|
16140
16148
|
}
|
|
16141
16149
|
isEqual(t) {
|
|
@@ -16145,7 +16153,7 @@ class mu extends eu {
|
|
|
16145
16153
|
}
|
|
16146
16154
|
|
|
16147
16155
|
/** Parse update data from an update() call. */ function gu(t, e, n, s) {
|
|
16148
|
-
const i = t.
|
|
16156
|
+
const i = t.jc(1 /* Update */ , e, n);
|
|
16149
16157
|
Au("Data must be an object, but it was:", i, s);
|
|
16150
16158
|
const r = [], o = Kt.empty();
|
|
16151
16159
|
at(s, ((t, s) => {
|
|
@@ -16153,7 +16161,7 @@ class mu extends eu {
|
|
|
16153
16161
|
// For Compat types, we have to "extract" the underlying types before
|
|
16154
16162
|
// performing validation.
|
|
16155
16163
|
s = p(s);
|
|
16156
|
-
const a = i.
|
|
16164
|
+
const a = i.Lc(c);
|
|
16157
16165
|
if (s instanceof lu)
|
|
16158
16166
|
// Add it to the field mask, but don't add anything to updateData.
|
|
16159
16167
|
r.push(c); else {
|
|
@@ -16166,7 +16174,7 @@ class mu extends eu {
|
|
|
16166
16174
|
}
|
|
16167
16175
|
|
|
16168
16176
|
/** Parse update data from a list of field/value arguments. */ function yu(t, e, n, s, i, r) {
|
|
16169
|
-
const o = t.
|
|
16177
|
+
const o = t.jc(1 /* Update */ , e, n), c = [ Ru(e, s, n) ], a = [ i ];
|
|
16170
16178
|
if (r.length % 2 != 0) throw new Q(j.INVALID_ARGUMENT, `Function ${e}() needs to be called with an even number of arguments that alternate between field names and values.`);
|
|
16171
16179
|
for (let t = 0; t < r.length; t += 2) c.push(Ru(e, r[t])), a.push(r[t + 1]);
|
|
16172
16180
|
const u = [], h = Kt.empty();
|
|
@@ -16178,7 +16186,7 @@ class mu extends eu {
|
|
|
16178
16186
|
// For Compat types, we have to "extract" the underlying types before
|
|
16179
16187
|
// performing validation.
|
|
16180
16188
|
n = p(n);
|
|
16181
|
-
const s = o.
|
|
16189
|
+
const s = o.Lc(e);
|
|
16182
16190
|
if (n instanceof lu)
|
|
16183
16191
|
// Add it to the field mask, but don't add anything to updateData.
|
|
16184
16192
|
u.push(e); else {
|
|
@@ -16197,7 +16205,7 @@ class mu extends eu {
|
|
|
16197
16205
|
* @param allowArrays - Whether the query value is an array that may directly
|
|
16198
16206
|
* contain additional arrays (e.g. the operand of an `in` query).
|
|
16199
16207
|
*/ function pu(t, e, n, s = !1) {
|
|
16200
|
-
return Tu(n, t.
|
|
16208
|
+
return Tu(n, t.jc(s ? 4 /* ArrayArgument */ : 3 /* Argument */ , e));
|
|
16201
16209
|
}
|
|
16202
16210
|
|
|
16203
16211
|
/**
|
|
@@ -16225,8 +16233,8 @@ class mu extends eu {
|
|
|
16225
16233
|
*/
|
|
16226
16234
|
return function(t, e) {
|
|
16227
16235
|
// Sentinels are only supported with writes, and not within arrays.
|
|
16228
|
-
if (!ou(e.
|
|
16229
|
-
if (!e.path) throw e.
|
|
16236
|
+
if (!ou(e.kc)) throw e.Uc(`${t._methodName}() can only be used with update() and set()`);
|
|
16237
|
+
if (!e.path) throw e.Uc(`${t._methodName}() is not currently supported inside arrays`);
|
|
16230
16238
|
const n = t._toFieldTransform(e);
|
|
16231
16239
|
n && e.fieldTransforms.push(n);
|
|
16232
16240
|
}
|
|
@@ -16250,12 +16258,12 @@ class mu extends eu {
|
|
|
16250
16258
|
// the set of values to be included for the IN query) that may directly
|
|
16251
16259
|
// contain additional arrays (each representing an individual field
|
|
16252
16260
|
// value), so we disable this validation.
|
|
16253
|
-
if (e.settings.
|
|
16261
|
+
if (e.settings.Fc && 4 /* ArrayArgument */ !== e.kc) throw e.Uc("Nested arrays are not supported");
|
|
16254
16262
|
return function(t, e) {
|
|
16255
16263
|
const n = [];
|
|
16256
16264
|
let s = 0;
|
|
16257
16265
|
for (const i of t) {
|
|
16258
|
-
let t = Tu(i, e.
|
|
16266
|
+
let t = Tu(i, e.Bc(s));
|
|
16259
16267
|
null == t && (
|
|
16260
16268
|
// Just include nulls in the array for fields being replaced with a
|
|
16261
16269
|
// sentinel.
|
|
@@ -16307,12 +16315,12 @@ class mu extends eu {
|
|
|
16307
16315
|
};
|
|
16308
16316
|
if (t instanceof Ra) {
|
|
16309
16317
|
const n = e.databaseId, s = t.firestore._databaseId;
|
|
16310
|
-
if (!s.isEqual(n)) throw e.
|
|
16318
|
+
if (!s.isEqual(n)) throw e.Uc(`Document reference is for database ${s.projectId}/${s.database} but should be for database ${n.projectId}/${n.database}`);
|
|
16311
16319
|
return {
|
|
16312
16320
|
referenceValue: Gn(t.firestore._databaseId || e.databaseId, t._key.path)
|
|
16313
16321
|
};
|
|
16314
16322
|
}
|
|
16315
|
-
throw e.
|
|
16323
|
+
throw e.Uc(`Unsupported field value: ${ya(t)}`);
|
|
16316
16324
|
}
|
|
16317
16325
|
/**
|
|
16318
16326
|
* Checks whether an object looks like a JSON object that should be converted
|
|
@@ -16329,7 +16337,7 @@ function Eu(t, e) {
|
|
|
16329
16337
|
// If we encounter an empty object, we explicitly add it to the update
|
|
16330
16338
|
// mask to ensure that the server creates a map entry.
|
|
16331
16339
|
e.path && e.path.length > 0 && e.fieldMask.push(e.path) : at(t, ((t, s) => {
|
|
16332
|
-
const i = Tu(s, e.
|
|
16340
|
+
const i = Tu(s, e.Oc(t));
|
|
16333
16341
|
null != i && (n[t] = i);
|
|
16334
16342
|
})), {
|
|
16335
16343
|
mapValue: {
|
|
@@ -16347,7 +16355,7 @@ function Au(t, e, n) {
|
|
|
16347
16355
|
return "object" == typeof t && null !== t && (Object.getPrototypeOf(t) === Object.prototype || null === Object.getPrototypeOf(t));
|
|
16348
16356
|
}(n)) {
|
|
16349
16357
|
const s = ya(n);
|
|
16350
|
-
throw "an object" === s ? e.
|
|
16358
|
+
throw "an object" === s ? e.Uc(t + " a custom object") : e.Uc(t + " " + s);
|
|
16351
16359
|
}
|
|
16352
16360
|
}
|
|
16353
16361
|
|
|
@@ -16796,7 +16804,7 @@ function Ou(t) {
|
|
|
16796
16804
|
|
|
16797
16805
|
class Uu extends Lu {
|
|
16798
16806
|
constructor(t, e, n) {
|
|
16799
|
-
super(), this.
|
|
16807
|
+
super(), this.Gc = t, this.zc = e, this.Hc = n, this.type = "where";
|
|
16800
16808
|
}
|
|
16801
16809
|
_apply(t) {
|
|
16802
16810
|
const e = uu(t.firestore), n = function(t, e, n, s, i, r, o) {
|
|
@@ -16865,7 +16873,7 @@ class Uu extends Lu {
|
|
|
16865
16873
|
// Special case when it's a duplicate op to give a slightly clearer error message.
|
|
16866
16874
|
throw n === e.op ? new Q(j.INVALID_ARGUMENT, `Invalid query. You cannot use more than one '${e.op.toString()}' filter.`) : new Q(j.INVALID_ARGUMENT, `Invalid query. You cannot use '${e.op.toString()}' filters with '${n.toString()}' filters.`);
|
|
16867
16875
|
}(t, a), a;
|
|
16868
|
-
}(t._query, "where", e, t.firestore._databaseId, this.
|
|
16876
|
+
}(t._query, "where", e, t.firestore._databaseId, this.Gc, this.zc, this.Hc);
|
|
16869
16877
|
return new ba(t.firestore, t.converter, function(t, e) {
|
|
16870
16878
|
const n = t.filters.concat([ e ]);
|
|
16871
16879
|
return new we(t.path, t.collectionGroup, t.explicitOrderBy.slice(), n, t.limit, t.limitType, t.startAt, t.endAt);
|
|
@@ -16890,7 +16898,7 @@ class Uu extends Lu {
|
|
|
16890
16898
|
|
|
16891
16899
|
class Ku extends Lu {
|
|
16892
16900
|
constructor(t, e) {
|
|
16893
|
-
super(), this.
|
|
16901
|
+
super(), this.Gc = t, this.Jc = e, this.type = "orderBy";
|
|
16894
16902
|
}
|
|
16895
16903
|
_apply(t) {
|
|
16896
16904
|
const e = function(t, e, n) {
|
|
@@ -16915,7 +16923,7 @@ class Ku extends Lu {
|
|
|
16915
16923
|
* Will throw if the document does not contain all fields of the order by
|
|
16916
16924
|
* of the query or if any of the fields in the order by are an uncommitted
|
|
16917
16925
|
* server timestamp.
|
|
16918
|
-
*/ (t._query, this.
|
|
16926
|
+
*/ (t._query, this.Gc, this.Jc);
|
|
16919
16927
|
return new ba(t.firestore, t.converter, function(t, e) {
|
|
16920
16928
|
// TODO(dimond): validate that orderBy does not list the same key twice.
|
|
16921
16929
|
const n = t.explicitOrderBy.concat([ e ]);
|
|
@@ -16939,10 +16947,10 @@ class Ku extends Lu {
|
|
|
16939
16947
|
|
|
16940
16948
|
class Qu extends Lu {
|
|
16941
16949
|
constructor(t, e, n) {
|
|
16942
|
-
super(), this.type = t, this.
|
|
16950
|
+
super(), this.type = t, this.Yc = e, this.Xc = n;
|
|
16943
16951
|
}
|
|
16944
16952
|
_apply(t) {
|
|
16945
|
-
return new ba(t.firestore, t.converter, Re(t._query, this.
|
|
16953
|
+
return new ba(t.firestore, t.converter, Re(t._query, this.Yc, this.Xc));
|
|
16946
16954
|
}
|
|
16947
16955
|
}
|
|
16948
16956
|
|
|
@@ -16969,10 +16977,10 @@ class Qu extends Lu {
|
|
|
16969
16977
|
|
|
16970
16978
|
class zu extends Lu {
|
|
16971
16979
|
constructor(t, e, n) {
|
|
16972
|
-
super(), this.type = t, this.
|
|
16980
|
+
super(), this.type = t, this.Zc = e, this.ta = n;
|
|
16973
16981
|
}
|
|
16974
16982
|
_apply(t) {
|
|
16975
|
-
const e = th(t, this.type, this.
|
|
16983
|
+
const e = th(t, this.type, this.Zc, this.ta);
|
|
16976
16984
|
return new ba(t.firestore, t.converter, function(t, e) {
|
|
16977
16985
|
return new we(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), t.limit, t.limitType, e, t.endAt);
|
|
16978
16986
|
}(t._query, e));
|
|
@@ -16990,10 +16998,10 @@ function Ju(...t) {
|
|
|
16990
16998
|
|
|
16991
16999
|
class Yu extends Lu {
|
|
16992
17000
|
constructor(t, e, n) {
|
|
16993
|
-
super(), this.type = t, this.
|
|
17001
|
+
super(), this.type = t, this.Zc = e, this.ta = n;
|
|
16994
17002
|
}
|
|
16995
17003
|
_apply(t) {
|
|
16996
|
-
const e = th(t, this.type, this.
|
|
17004
|
+
const e = th(t, this.type, this.Zc, this.ta);
|
|
16997
17005
|
return new ba(t.firestore, t.converter, function(t, e) {
|
|
16998
17006
|
return new we(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), t.limit, t.limitType, t.startAt, e);
|
|
16999
17007
|
}(t._query, e));
|
|
@@ -17528,7 +17536,7 @@ function Th(t, ...e) {
|
|
|
17528
17536
|
return function(t, e, n, s) {
|
|
17529
17537
|
const i = new Uc(s), r = new Go(e, i, n);
|
|
17530
17538
|
return t.asyncQueue.enqueueAndForget((async () => qo(await ta(t), r))), () => {
|
|
17531
|
-
i.
|
|
17539
|
+
i.ec(), t.asyncQueue.enqueueAndForget((async () => Ko(await ta(t), r)));
|
|
17532
17540
|
};
|
|
17533
17541
|
}(La(u), h, c, a);
|
|
17534
17542
|
}
|
|
@@ -17657,7 +17665,7 @@ function Eh(t, e) {
|
|
|
17657
17665
|
* `updateFunction `is returned here. Otherwise, if the transaction failed, a
|
|
17658
17666
|
* rejected promise with the corresponding failure error is returned.
|
|
17659
17667
|
*/ function bh(t, e) {
|
|
17660
|
-
return aa(La(t), (n => e(new Rh(t, n))));
|
|
17668
|
+
return aa(La(t = pa(t, Oa)), (n => e(new Rh(t, n))));
|
|
17661
17669
|
}
|
|
17662
17670
|
|
|
17663
17671
|
/**
|
|
@@ -17790,18 +17798,18 @@ function Eh(t, e) {
|
|
|
17790
17798
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17791
17799
|
* See the License for the specific language governing permissions and
|
|
17792
17800
|
* limitations under the License.
|
|
17793
|
-
*/
|
|
17794
|
-
|
|
17795
|
-
|
|
17796
|
-
|
|
17797
|
-
|
|
17798
|
-
|
|
17799
|
-
|
|
17800
|
-
|
|
17801
|
-
},
|
|
17802
|
-
|
|
17803
|
-
|
|
17804
|
-
|
|
17801
|
+
*/ !function(t, e = !0) {
|
|
17802
|
+
!function(t) {
|
|
17803
|
+
N = t;
|
|
17804
|
+
}(i), n(new r("firestore", ((t, {options: n}) => {
|
|
17805
|
+
const s = t.getProvider("app").getImmediate(), i = new Oa(s, new J(t.getProvider("auth-internal")));
|
|
17806
|
+
return n = Object.assign({
|
|
17807
|
+
useFetchStreams: e
|
|
17808
|
+
}, n), i._setSettings(n), i;
|
|
17809
|
+
}), "PUBLIC" /* PUBLIC */)), s(D, "3.2.0", t),
|
|
17810
|
+
// BUILD_TARGET will be replaced by values like esm5, esm2017, cjs5, etc during the compilation
|
|
17811
|
+
s(D, "3.2.0", "esm2017");
|
|
17812
|
+
}("rn", /* useFetchStreams= */ !1);
|
|
17805
17813
|
|
|
17806
17814
|
export { ih as AbstractUserDataWriter, tu as Bytes, $a as CACHE_SIZE_UNLIMITED, Pa as CollectionReference, Ra as DocumentReference, xu as DocumentSnapshot, Xa as FieldPath, eu as FieldValue, Oa as Firestore, Q as FirestoreError, nu as GeoPoint, ka as LoadBundleTask, ba as Query, Lu as QueryConstraint, ku as QueryDocumentSnapshot, $u as QuerySnapshot, Nu as SnapshotMetadata, rt as Timestamp, Rh as Transaction, ch as WriteBatch, fa as _DatabaseId, Vt as _DocumentKey, z as _EmptyCredentialsProvider, dt as _FieldPath, pa as _cast, q as _debugAssert, mt as _isBase64Available, M as _logWarn, _a as _validateIsNotUsedTogether, ph as addDoc, Sh as arrayRemove, Vh as arrayUnion, ja as clearIndexedDbPersistence, va as collection, Va as collectionGroup, Aa as connectFirestoreEmulator, yh as deleteDoc, Ph as deleteField, Ga as disableNetwork, Sa as doc, Za as documentId, Ua as enableIndexedDbPersistence, qa as enableMultiTabIndexedDbPersistence, Wa as enableNetwork, Zu as endAt, Xu as endBefore, La as ensureFirestoreConfigured, Ih as executeWrite, uh as getDoc, lh as getDocFromCache, fh as getDocFromServer, dh as getDocs, wh as getDocsFromCache, _h as getDocsFromServer, Ma as getFirestore, Dh as increment, Fa as initializeFirestore, Wu as limit, Gu as limitToLast, Ha as loadBundle, Ja as namedQuery, Th as onSnapshot, Eh as onSnapshotsInSync, ju as orderBy, Bu as query, Ca as queryEqual, Da as refEqual, bh as runTransaction, vh as serverTimestamp, mh as setDoc, $ as setLogLevel, Fu as snapshotEqual, Ju as startAfter, Hu as startAt, za as terminate, gh as updateDoc, Qa as waitForPendingWrites, qu as where, Ch as writeBatch };
|
|
17807
17815
|
//# sourceMappingURL=index.rn.js.map
|