@firebase/firestore 3.4.3-202201219200 → 3.4.3-canary.17165a8a4
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 +3 -1
- package/dist/firestore/src/api/snapshot.d.ts +6 -6
- package/dist/firestore/src/lite-api/snapshot.d.ts +2 -2
- package/dist/firestore/test/integration/bootstrap.d.ts +0 -1
- package/dist/firestore/test/integration/util/events_accumulator.d.ts +2 -2
- package/dist/firestore/test/integration/util/firebase_export.d.ts +6 -14
- package/dist/firestore/test/integration/util/helpers.d.ts +18 -18
- package/dist/firestore/test/integration/util/internal_helpers.d.ts +3 -3
- package/dist/firestore/test/integration/util/settings.d.ts +2 -2
- package/dist/firestore/test/unit/api/{blob.test.d.ts → bytes.test.d.ts} +0 -0
- package/dist/firestore/test/util/api_helpers.d.ts +1 -1
- package/dist/firestore/test/util/helpers.d.ts +3 -5
- package/dist/index.d.ts +6 -6
- package/dist/index.esm2017.js +227 -227
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +202 -202
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +2674 -24
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +2675 -25
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +438 -438
- package/dist/index.rn.js.map +1 -1
- package/dist/internal.d.ts +8 -8
- package/dist/lite/firestore/src/api/snapshot.d.ts +6 -6
- package/dist/lite/firestore/src/lite-api/snapshot.d.ts +2 -2
- package/dist/lite/firestore/test/integration/bootstrap.d.ts +0 -1
- package/dist/lite/firestore/test/integration/util/events_accumulator.d.ts +2 -2
- package/dist/lite/firestore/test/integration/util/firebase_export.d.ts +6 -14
- package/dist/lite/firestore/test/integration/util/helpers.d.ts +18 -18
- package/dist/lite/firestore/test/integration/util/internal_helpers.d.ts +3 -3
- package/dist/lite/firestore/test/integration/util/settings.d.ts +2 -2
- package/dist/lite/firestore/test/unit/api/{blob.test.d.ts → bytes.test.d.ts} +0 -0
- package/dist/lite/firestore/test/util/api_helpers.d.ts +1 -1
- package/dist/lite/firestore/test/util/helpers.d.ts +3 -5
- package/dist/lite/index.browser.esm2017.js +1136 -1136
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.browser.esm5.js +105 -105
- package/dist/lite/index.browser.esm5.js.map +1 -1
- package/dist/lite/index.d.ts +2 -2
- package/dist/lite/index.node.cjs.js +11 -12
- package/dist/lite/index.node.cjs.js.map +1 -1
- package/dist/lite/index.node.mjs +11 -12
- package/dist/lite/index.node.mjs.map +1 -1
- package/dist/lite/index.rn.esm2017.js +148 -148
- package/dist/lite/index.rn.esm2017.js.map +1 -1
- package/dist/lite/internal.d.ts +2 -2
- package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +107 -107
- package/dist/lite/packages/firestore/src/api/snapshot.d.ts +6 -6
- package/dist/lite/packages/firestore/src/lite-api/snapshot.d.ts +2 -2
- package/dist/lite/packages/firestore/test/integration/bootstrap.d.ts +0 -1
- package/dist/lite/packages/firestore/test/integration/util/events_accumulator.d.ts +2 -2
- package/dist/lite/packages/firestore/test/integration/util/firebase_export.d.ts +6 -14
- package/dist/lite/packages/firestore/test/integration/util/helpers.d.ts +18 -18
- package/dist/lite/packages/firestore/test/integration/util/internal_helpers.d.ts +3 -3
- package/dist/lite/packages/firestore/test/integration/util/settings.d.ts +2 -2
- package/dist/lite/packages/firestore/test/unit/api/{blob.test.d.ts → bytes.test.d.ts} +0 -0
- package/dist/lite/packages/firestore/test/util/api_helpers.d.ts +1 -1
- package/dist/lite/packages/firestore/test/util/helpers.d.ts +3 -5
- package/dist/lite/private.d.ts +2 -2
- package/dist/packages/firestore/dist/index.esm2017.d.ts +13 -13
- package/dist/packages/firestore/src/api/snapshot.d.ts +6 -6
- package/dist/packages/firestore/src/lite-api/snapshot.d.ts +2 -2
- package/dist/packages/firestore/test/integration/bootstrap.d.ts +0 -1
- package/dist/packages/firestore/test/integration/util/events_accumulator.d.ts +2 -2
- package/dist/packages/firestore/test/integration/util/firebase_export.d.ts +6 -14
- package/dist/packages/firestore/test/integration/util/helpers.d.ts +18 -18
- package/dist/packages/firestore/test/integration/util/internal_helpers.d.ts +3 -3
- package/dist/packages/firestore/test/integration/util/settings.d.ts +2 -2
- package/dist/packages/firestore/test/unit/api/{blob.test.d.ts → bytes.test.d.ts} +0 -0
- package/dist/packages/firestore/test/util/api_helpers.d.ts +1 -1
- package/dist/packages/firestore/test/util/helpers.d.ts +3 -5
- package/dist/private.d.ts +8 -8
- package/package.json +10 -13
- package/dist/firestore/compat/api/blob.d.ts +0 -29
- package/dist/firestore/compat/api/database.d.ts +0 -228
- package/dist/firestore/compat/api/field_path.d.ts +0 -36
- package/dist/firestore/compat/api/field_value.d.ts +0 -29
- package/dist/firestore/compat/api/geo_point.d.ts +0 -17
- package/dist/firestore/compat/api/observer.d.ts +0 -29
- package/dist/firestore/compat/api/timestamp.d.ts +0 -17
- package/dist/firestore/compat/config.d.ts +0 -28
- package/dist/firestore/compat/index.console.d.ts +0 -42
- package/dist/firestore/compat/index.d.ts +0 -49
- package/dist/firestore/compat/index.node.d.ts +0 -22
- package/dist/firestore/compat/index.rn.d.ts +0 -22
- package/dist/firestore/compat/register-module.d.ts +0 -42
- package/dist/firestore/compat/util/input_validation.d.ts +0 -18
- package/dist/lite/firestore/compat/api/blob.d.ts +0 -29
- package/dist/lite/firestore/compat/api/database.d.ts +0 -228
- package/dist/lite/firestore/compat/api/field_path.d.ts +0 -36
- package/dist/lite/firestore/compat/api/field_value.d.ts +0 -29
- package/dist/lite/firestore/compat/api/geo_point.d.ts +0 -17
- package/dist/lite/firestore/compat/api/observer.d.ts +0 -29
- package/dist/lite/firestore/compat/api/timestamp.d.ts +0 -17
- package/dist/lite/firestore/compat/config.d.ts +0 -28
- package/dist/lite/firestore/compat/index.console.d.ts +0 -42
- package/dist/lite/firestore/compat/index.d.ts +0 -49
- package/dist/lite/firestore/compat/index.node.d.ts +0 -22
- package/dist/lite/firestore/compat/index.rn.d.ts +0 -22
- package/dist/lite/firestore/compat/register-module.d.ts +0 -42
- package/dist/lite/firestore/compat/util/input_validation.d.ts +0 -18
- package/dist/lite/packages/firestore/compat/api/blob.d.ts +0 -29
- package/dist/lite/packages/firestore/compat/api/database.d.ts +0 -228
- package/dist/lite/packages/firestore/compat/api/field_path.d.ts +0 -36
- package/dist/lite/packages/firestore/compat/api/field_value.d.ts +0 -29
- package/dist/lite/packages/firestore/compat/api/geo_point.d.ts +0 -17
- package/dist/lite/packages/firestore/compat/api/observer.d.ts +0 -29
- package/dist/lite/packages/firestore/compat/api/timestamp.d.ts +0 -17
- package/dist/lite/packages/firestore/compat/config.d.ts +0 -28
- package/dist/lite/packages/firestore/compat/index.console.d.ts +0 -42
- package/dist/lite/packages/firestore/compat/index.d.ts +0 -49
- package/dist/lite/packages/firestore/compat/index.node.d.ts +0 -22
- package/dist/lite/packages/firestore/compat/index.rn.d.ts +0 -22
- package/dist/lite/packages/firestore/compat/register-module.d.ts +0 -42
- package/dist/lite/packages/firestore/compat/util/input_validation.d.ts +0 -18
- package/dist/lite/src/protos/README.md +0 -2
- package/dist/lite/src/protos/firestore/bundle.proto +0 -121
- package/dist/lite/src/protos/firestore_bundle_proto.ts +0 -93
- package/dist/lite/src/protos/firestore_proto_api.ts +0 -1259
- package/dist/lite/src/protos/google/api/annotations.proto +0 -31
- package/dist/lite/src/protos/google/api/http.proto +0 -370
- package/dist/lite/src/protos/google/firestore/v1/common.proto +0 -84
- package/dist/lite/src/protos/google/firestore/v1/document.proto +0 -151
- package/dist/lite/src/protos/google/firestore/v1/firestore.proto +0 -761
- package/dist/lite/src/protos/google/firestore/v1/query.proto +0 -302
- package/dist/lite/src/protos/google/firestore/v1/write.proto +0 -264
- package/dist/lite/src/protos/google/protobuf/any.proto +0 -155
- package/dist/lite/src/protos/google/protobuf/descriptor.proto +0 -882
- package/dist/lite/src/protos/google/protobuf/empty.proto +0 -52
- package/dist/lite/src/protos/google/protobuf/struct.proto +0 -96
- package/dist/lite/src/protos/google/protobuf/timestamp.proto +0 -137
- package/dist/lite/src/protos/google/protobuf/wrappers.proto +0 -123
- package/dist/lite/src/protos/google/rpc/status.proto +0 -92
- package/dist/lite/src/protos/google/type/latlng.proto +0 -71
- package/dist/lite/src/protos/update.sh +0 -61
- package/dist/packages/firestore/compat/api/blob.d.ts +0 -29
- package/dist/packages/firestore/compat/api/database.d.ts +0 -228
- package/dist/packages/firestore/compat/api/field_path.d.ts +0 -36
- package/dist/packages/firestore/compat/api/field_value.d.ts +0 -29
- package/dist/packages/firestore/compat/api/geo_point.d.ts +0 -17
- package/dist/packages/firestore/compat/api/observer.d.ts +0 -29
- package/dist/packages/firestore/compat/api/timestamp.d.ts +0 -17
- package/dist/packages/firestore/compat/config.d.ts +0 -28
- package/dist/packages/firestore/compat/index.console.d.ts +0 -42
- package/dist/packages/firestore/compat/index.d.ts +0 -49
- package/dist/packages/firestore/compat/index.node.d.ts +0 -22
- package/dist/packages/firestore/compat/index.rn.d.ts +0 -22
- package/dist/packages/firestore/compat/register-module.d.ts +0 -42
- package/dist/packages/firestore/compat/util/input_validation.d.ts +0 -18
- package/dist/src/protos/README.md +0 -2
- package/dist/src/protos/firestore/bundle.proto +0 -121
- package/dist/src/protos/firestore_bundle_proto.ts +0 -93
- package/dist/src/protos/firestore_proto_api.ts +0 -1259
- package/dist/src/protos/google/api/annotations.proto +0 -31
- package/dist/src/protos/google/api/http.proto +0 -370
- package/dist/src/protos/google/firestore/v1/common.proto +0 -84
- package/dist/src/protos/google/firestore/v1/document.proto +0 -151
- package/dist/src/protos/google/firestore/v1/firestore.proto +0 -761
- package/dist/src/protos/google/firestore/v1/query.proto +0 -302
- package/dist/src/protos/google/firestore/v1/write.proto +0 -264
- package/dist/src/protos/google/protobuf/any.proto +0 -155
- package/dist/src/protos/google/protobuf/descriptor.proto +0 -882
- package/dist/src/protos/google/protobuf/empty.proto +0 -52
- package/dist/src/protos/google/protobuf/struct.proto +0 -96
- package/dist/src/protos/google/protobuf/timestamp.proto +0 -137
- package/dist/src/protos/google/protobuf/wrappers.proto +0 -123
- package/dist/src/protos/google/rpc/status.proto +0 -92
- package/dist/src/protos/google/type/latlng.proto +0 -71
- package/dist/src/protos/update.sh +0 -61
package/dist/index.rn.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Logger as o, LogLevel as a } from "@firebase/logger";
|
|
|
6
6
|
|
|
7
7
|
import { FirebaseError as c, base64 as u, getUA as h, isIndexedDBAvailable as l, isSafari as f, isMobileCordova as d, isReactNative as w, isElectron as _, isIE as m, isUWP as g, isBrowserExtension as y, createMockUserToken as p, getModularInstance as T, deepEqual as E } from "@firebase/util";
|
|
8
8
|
|
|
9
|
-
import { XhrIo as I, EventType as A, ErrorCode as R, createWebChannelTransport as
|
|
9
|
+
import { XhrIo as I, EventType as A, ErrorCode as R, createWebChannelTransport as b, getStatEventTarget as P, FetchXmlHttpFactory as v, WebChannel as V, Event as S, Stat as D } from "@firebase/webchannel-wrapper";
|
|
10
10
|
|
|
11
11
|
const C = "@firebase/firestore";
|
|
12
12
|
|
|
@@ -70,7 +70,7 @@ N.MOCK_USER = new N("mock-user");
|
|
|
70
70
|
* See the License for the specific language governing permissions and
|
|
71
71
|
* limitations under the License.
|
|
72
72
|
*/
|
|
73
|
-
let k = "9.6.3-
|
|
73
|
+
let k = "9.6.3-canary.17165a8a4";
|
|
74
74
|
|
|
75
75
|
/**
|
|
76
76
|
* @license
|
|
@@ -111,14 +111,14 @@ function $() {
|
|
|
111
111
|
x.setLogLevel(t);
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
function
|
|
114
|
+
function M(t, ...e) {
|
|
115
115
|
if (x.logLevel <= a.DEBUG) {
|
|
116
116
|
const n = e.map(B);
|
|
117
117
|
x.debug(`Firestore (${k}): ${t}`, ...n);
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
function
|
|
121
|
+
function F(t, ...e) {
|
|
122
122
|
if (x.logLevel <= a.ERROR) {
|
|
123
123
|
const n = e.map(B);
|
|
124
124
|
x.error(`Firestore (${k}): ${t}`, ...n);
|
|
@@ -194,7 +194,7 @@ function M(t, ...e) {
|
|
|
194
194
|
// NOTE: We don't use FirestoreError here because these are internal failures
|
|
195
195
|
// that cannot be handled by the user. (Also it would create a circular
|
|
196
196
|
// dependency between the error and assert modules which doesn't work.)
|
|
197
|
-
throw
|
|
197
|
+
throw F(e), new Error(e);
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
/**
|
|
@@ -488,7 +488,7 @@ class Y {
|
|
|
488
488
|
await e.promise, await s(this.currentUser);
|
|
489
489
|
}));
|
|
490
490
|
}, o = t => {
|
|
491
|
-
|
|
491
|
+
M("FirebaseAuthCredentialsProvider", "Auth detected"), this.auth = t, this.auth.addAuthTokenListener(this.o),
|
|
492
492
|
r();
|
|
493
493
|
};
|
|
494
494
|
this.t.onInit((t => o(t))),
|
|
@@ -502,7 +502,7 @@ class Y {
|
|
|
502
502
|
});
|
|
503
503
|
t ? o(t) : (
|
|
504
504
|
// If auth is still not available, proceed with `null` user
|
|
505
|
-
|
|
505
|
+
M("FirebaseAuthCredentialsProvider", "Auth not yet detected"), i.resolve(), i = new G);
|
|
506
506
|
}
|
|
507
507
|
}), 0), r();
|
|
508
508
|
}
|
|
@@ -515,7 +515,7 @@ class Y {
|
|
|
515
515
|
// Cancel the request since the token changed while the request was
|
|
516
516
|
// outstanding so the response is potentially for a previous user (which
|
|
517
517
|
// user, we can't be sure).
|
|
518
|
-
this.i !== t ? (
|
|
518
|
+
this.i !== t ? (M("FirebaseAuthCredentialsProvider", "getToken aborted due to token change."),
|
|
519
519
|
this.getToken()) : e ? (q("string" == typeof e.accessToken), new z(e.accessToken, this.currentUser)) : null)) : Promise.resolve(null);
|
|
520
520
|
}
|
|
521
521
|
invalidateToken() {
|
|
@@ -579,11 +579,11 @@ class et {
|
|
|
579
579
|
}
|
|
580
580
|
start(t, e) {
|
|
581
581
|
this.o = n => {
|
|
582
|
-
t.enqueueRetryable((() => (t => (null != t.error &&
|
|
582
|
+
t.enqueueRetryable((() => (t => (null != t.error && M("FirebaseAppCheckTokenProvider", `Error getting App Check token; using placeholder token instead. Error: ${t.error.message}`),
|
|
583
583
|
e(t.token)))(n)));
|
|
584
584
|
};
|
|
585
585
|
const n = t => {
|
|
586
|
-
|
|
586
|
+
M("FirebaseAppCheckTokenProvider", "AppCheck detected"), this.appCheck = t, this.appCheck.addTokenListener(this.o);
|
|
587
587
|
};
|
|
588
588
|
this.g.onInit((t => n(t))),
|
|
589
589
|
// Our users can initialize AppCheck after Firestore, so we give it
|
|
@@ -595,7 +595,7 @@ class et {
|
|
|
595
595
|
});
|
|
596
596
|
t ? n(t) :
|
|
597
597
|
// If AppCheck is still not available, proceed without it.
|
|
598
|
-
|
|
598
|
+
M("FirebaseAppCheckTokenProvider", "AppCheck not yet detected");
|
|
599
599
|
}
|
|
600
600
|
}), 0);
|
|
601
601
|
}
|
|
@@ -1377,7 +1377,7 @@ const It = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1377
1377
|
return "number" == typeof t ? t : "string" == typeof t ? Number(t) : 0;
|
|
1378
1378
|
}
|
|
1379
1379
|
|
|
1380
|
-
/** Converts the possible Proto types for Blobs into a ByteString. */ function
|
|
1380
|
+
/** Converts the possible Proto types for Blobs into a ByteString. */ function bt(t) {
|
|
1381
1381
|
return "string" == typeof t ? Et.fromBase64String(t) : Et.fromUint8Array(t);
|
|
1382
1382
|
}
|
|
1383
1383
|
|
|
@@ -1414,7 +1414,7 @@ const It = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1414
1414
|
* FieldValueOptions to value().
|
|
1415
1415
|
* - With respect to other ServerTimestampValues, they sort by their
|
|
1416
1416
|
* localWriteTime.
|
|
1417
|
-
*/ function
|
|
1417
|
+
*/ function Pt(t) {
|
|
1418
1418
|
var e, n;
|
|
1419
1419
|
return "server_timestamp" === (null === (n = ((null === (e = null == t ? void 0 : t.mapValue) || void 0 === e ? void 0 : e.fields) || {}).__type__) || void 0 === n ? void 0 : n.stringValue);
|
|
1420
1420
|
}
|
|
@@ -1430,7 +1430,7 @@ const It = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1430
1430
|
*/
|
|
1431
1431
|
function vt(t) {
|
|
1432
1432
|
const e = t.mapValue.fields.__previous_value__;
|
|
1433
|
-
return
|
|
1433
|
+
return Pt(e) ? vt(e) : e;
|
|
1434
1434
|
}
|
|
1435
1435
|
|
|
1436
1436
|
/**
|
|
@@ -1547,7 +1547,7 @@ function St(t) {
|
|
|
1547
1547
|
* limitations under the License.
|
|
1548
1548
|
*/
|
|
1549
1549
|
/** Extracts the backend's type order for the provided value. */ function kt(t) {
|
|
1550
|
-
return "nullValue" in t ? 0 /* NullValue */ : "booleanValue" in t ? 1 /* BooleanValue */ : "integerValue" in t || "doubleValue" in t ? 2 /* NumberValue */ : "timestampValue" in t ? 3 /* TimestampValue */ : "stringValue" in t ? 5 /* StringValue */ : "bytesValue" in t ? 6 /* BlobValue */ : "referenceValue" in t ? 7 /* RefValue */ : "geoPointValue" in t ? 8 /* GeoPointValue */ : "arrayValue" in t ? 9 /* ArrayValue */ : "mapValue" in t ?
|
|
1550
|
+
return "nullValue" in t ? 0 /* NullValue */ : "booleanValue" in t ? 1 /* BooleanValue */ : "integerValue" in t || "doubleValue" in t ? 2 /* NumberValue */ : "timestampValue" in t ? 3 /* TimestampValue */ : "stringValue" in t ? 5 /* StringValue */ : "bytesValue" in t ? 6 /* BlobValue */ : "referenceValue" in t ? 7 /* RefValue */ : "geoPointValue" in t ? 8 /* GeoPointValue */ : "arrayValue" in t ? 9 /* ArrayValue */ : "mapValue" in t ? Pt(t) ? 4 /* ServerTimestampValue */ : 10 /* ObjectValue */ : U();
|
|
1551
1551
|
}
|
|
1552
1552
|
|
|
1553
1553
|
/** Tests `left` and `right` for equality based on the backend semantics. */ function xt(t, e) {
|
|
@@ -1578,7 +1578,7 @@ function St(t) {
|
|
|
1578
1578
|
|
|
1579
1579
|
case 6 /* BlobValue */ :
|
|
1580
1580
|
return function(t, e) {
|
|
1581
|
-
return
|
|
1581
|
+
return bt(t.bytesValue).isEqual(bt(e.bytesValue));
|
|
1582
1582
|
}(t, e);
|
|
1583
1583
|
|
|
1584
1584
|
case 7 /* RefValue */ :
|
|
@@ -1640,17 +1640,17 @@ function Ot(t, e) {
|
|
|
1640
1640
|
}(t, e);
|
|
1641
1641
|
|
|
1642
1642
|
case 3 /* TimestampValue */ :
|
|
1643
|
-
return
|
|
1643
|
+
return Mt(t.timestampValue, e.timestampValue);
|
|
1644
1644
|
|
|
1645
1645
|
case 4 /* ServerTimestampValue */ :
|
|
1646
|
-
return
|
|
1646
|
+
return Mt(Vt(t), Vt(e));
|
|
1647
1647
|
|
|
1648
1648
|
case 5 /* StringValue */ :
|
|
1649
1649
|
return ot(t.stringValue, e.stringValue);
|
|
1650
1650
|
|
|
1651
1651
|
case 6 /* BlobValue */ :
|
|
1652
1652
|
return function(t, e) {
|
|
1653
|
-
const n =
|
|
1653
|
+
const n = bt(t), s = bt(e);
|
|
1654
1654
|
return n.compareTo(s);
|
|
1655
1655
|
}(t.bytesValue, e.bytesValue);
|
|
1656
1656
|
|
|
@@ -1707,13 +1707,13 @@ function Ot(t, e) {
|
|
|
1707
1707
|
}
|
|
1708
1708
|
}
|
|
1709
1709
|
|
|
1710
|
-
function
|
|
1710
|
+
function Mt(t, e) {
|
|
1711
1711
|
if ("string" == typeof t && "string" == typeof e && t.length === e.length) return ot(t, e);
|
|
1712
1712
|
const n = At(t), s = At(e), i = ot(n.seconds, s.seconds);
|
|
1713
1713
|
return 0 !== i ? i : ot(n.nanos, s.nanos);
|
|
1714
1714
|
}
|
|
1715
1715
|
|
|
1716
|
-
function
|
|
1716
|
+
function Ft(t) {
|
|
1717
1717
|
return Lt(t);
|
|
1718
1718
|
}
|
|
1719
1719
|
|
|
@@ -1721,7 +1721,7 @@ function Lt(t) {
|
|
|
1721
1721
|
return "nullValue" in t ? "null" : "booleanValue" in t ? "" + t.booleanValue : "integerValue" in t ? "" + t.integerValue : "doubleValue" in t ? "" + t.doubleValue : "timestampValue" in t ? function(t) {
|
|
1722
1722
|
const e = At(t);
|
|
1723
1723
|
return `time(${e.seconds},${e.nanos})`;
|
|
1724
|
-
}(t.timestampValue) : "stringValue" in t ? t.stringValue : "bytesValue" in t ?
|
|
1724
|
+
}(t.timestampValue) : "stringValue" in t ? t.stringValue : "bytesValue" in t ? bt(t.bytesValue).toBase64() : "referenceValue" in t ? (n = t.referenceValue,
|
|
1725
1725
|
Nt.fromName(n).toString()) : "geoPointValue" in t ? `geo(${(e = t.geoPointValue).latitude},${e.longitude})` : "arrayValue" in t ? function(t) {
|
|
1726
1726
|
let e = "[", n = !0;
|
|
1727
1727
|
for (const s of t.values || []) n ? n = !1 : e += ",", e += Lt(s);
|
|
@@ -2091,7 +2091,7 @@ function Zt(t) {
|
|
|
2091
2091
|
let e = t.path.canonicalString();
|
|
2092
2092
|
return null !== t.collectionGroup && (e += " collectionGroup=" + t.collectionGroup),
|
|
2093
2093
|
t.filters.length > 0 && (e += `, filters: [${t.filters.map((t => {
|
|
2094
|
-
return `${(e = t).field.canonicalString()} ${e.op} ${
|
|
2094
|
+
return `${(e = t).field.canonicalString()} ${e.op} ${Ft(e.value)}`;
|
|
2095
2095
|
/** Returns a debug description for `filter`. */
|
|
2096
2096
|
var e;
|
|
2097
2097
|
/** Filter that matches on key fields (i.e. '__name__'). */ })).join(", ")}]`),
|
|
@@ -2167,7 +2167,7 @@ function se(t) {
|
|
|
2167
2167
|
// TODO(b/29183165): Technically, this won't be unique if two values have
|
|
2168
2168
|
// the same description, such as the int 3 and the string "3". So we should
|
|
2169
2169
|
// add the types in here somehow, too.
|
|
2170
|
-
return t.field.canonicalString() + t.op.toString() +
|
|
2170
|
+
return t.field.canonicalString() + t.op.toString() + Ft(t.value);
|
|
2171
2171
|
}
|
|
2172
2172
|
|
|
2173
2173
|
class ie extends ne {
|
|
@@ -2267,7 +2267,7 @@ function ae(t, e) {
|
|
|
2267
2267
|
|
|
2268
2268
|
function de(t) {
|
|
2269
2269
|
// TODO(b/29183165): Make this collision robust.
|
|
2270
|
-
return `${t.before ? "b" : "a"}:${t.position.map((t =>
|
|
2270
|
+
return `${t.before ? "b" : "a"}:${t.position.map((t => Ft(t))).join(",")}`;
|
|
2271
2271
|
}
|
|
2272
2272
|
|
|
2273
2273
|
/**
|
|
@@ -2380,7 +2380,7 @@ function Re(t) {
|
|
|
2380
2380
|
* Returns whether the query matches a collection group rather than a specific
|
|
2381
2381
|
* collection.
|
|
2382
2382
|
*/
|
|
2383
|
-
function
|
|
2383
|
+
function be(t) {
|
|
2384
2384
|
return null !== t.collectionGroup;
|
|
2385
2385
|
}
|
|
2386
2386
|
|
|
@@ -2388,7 +2388,7 @@ function Pe(t) {
|
|
|
2388
2388
|
* Returns the implicit order by constraint that is used to execute the Query,
|
|
2389
2389
|
* which can be different from the order by constraints the user provided (e.g.
|
|
2390
2390
|
* the SDK and backend always orders by `__name__`).
|
|
2391
|
-
*/ function
|
|
2391
|
+
*/ function Pe(t) {
|
|
2392
2392
|
const e = j(t);
|
|
2393
2393
|
if (null === e.S) {
|
|
2394
2394
|
e.S = [];
|
|
@@ -2415,10 +2415,10 @@ function Pe(t) {
|
|
|
2415
2415
|
* Converts this `Query` instance to it's corresponding `Target` representation.
|
|
2416
2416
|
*/ function ve(t) {
|
|
2417
2417
|
const e = j(t);
|
|
2418
|
-
if (!e.D) if ("F" /* First */ === e.limitType) e.D = Yt(e.path, e.collectionGroup,
|
|
2418
|
+
if (!e.D) if ("F" /* First */ === e.limitType) e.D = Yt(e.path, e.collectionGroup, Pe(e), e.filters, e.limit, e.startAt, e.endAt); else {
|
|
2419
2419
|
// Flip the orderBy directions since we want the last results
|
|
2420
2420
|
const t = [];
|
|
2421
|
-
for (const n of
|
|
2421
|
+
for (const n of Pe(e)) {
|
|
2422
2422
|
const e = "desc" /* DESCENDING */ === n.dir ? "asc" /* ASCENDING */ : "desc" /* DESCENDING */;
|
|
2423
2423
|
t.push(new we(n.field, e));
|
|
2424
2424
|
}
|
|
@@ -2467,8 +2467,8 @@ function Ce(t) {
|
|
|
2467
2467
|
return !0;
|
|
2468
2468
|
}
|
|
2469
2469
|
/** Makes sure a document is within the bounds, if provided. */ (t, e) && function(t, e) {
|
|
2470
|
-
if (t.startAt && !me(t.startAt,
|
|
2471
|
-
if (t.endAt && me(t.endAt,
|
|
2470
|
+
if (t.startAt && !me(t.startAt, Pe(t), e)) return !1;
|
|
2471
|
+
if (t.endAt && me(t.endAt, Pe(t), e)) return !1;
|
|
2472
2472
|
return !0;
|
|
2473
2473
|
}
|
|
2474
2474
|
/**
|
|
@@ -2480,7 +2480,7 @@ function Ce(t) {
|
|
|
2480
2480
|
function ke(t) {
|
|
2481
2481
|
return (e, n) => {
|
|
2482
2482
|
let s = !1;
|
|
2483
|
-
for (const i of
|
|
2483
|
+
for (const i of Pe(t)) {
|
|
2484
2484
|
const t = xe(i, e, n);
|
|
2485
2485
|
if (0 !== t) return t;
|
|
2486
2486
|
s = s || i.field.isKeyField();
|
|
@@ -2554,7 +2554,7 @@ function xe(t, e, n) {
|
|
|
2554
2554
|
* Returns a value for a number that's appropriate to put into a proto.
|
|
2555
2555
|
* The return value is an IntegerValue if it can safely represent the value,
|
|
2556
2556
|
* otherwise a DoubleValue is returned.
|
|
2557
|
-
*/ function
|
|
2557
|
+
*/ function Me(t, e) {
|
|
2558
2558
|
return Ct(e) ? Oe(e) : $e(t, e);
|
|
2559
2559
|
}
|
|
2560
2560
|
|
|
@@ -2574,7 +2574,7 @@ function xe(t, e, n) {
|
|
|
2574
2574
|
* See the License for the specific language governing permissions and
|
|
2575
2575
|
* limitations under the License.
|
|
2576
2576
|
*/
|
|
2577
|
-
/** Used to represent a field transform on a mutation. */ class
|
|
2577
|
+
/** Used to represent a field transform on a mutation. */ class Fe {
|
|
2578
2578
|
constructor() {
|
|
2579
2579
|
// Make sure that the structural type of `TransformOperation` is unique.
|
|
2580
2580
|
// See https://github.com/microsoft/TypeScript/issues/5451
|
|
@@ -2647,9 +2647,9 @@ function xe(t, e, n) {
|
|
|
2647
2647
|
}
|
|
2648
2648
|
|
|
2649
2649
|
/** Transforms a value into a server-generated timestamp. */
|
|
2650
|
-
class qe extends
|
|
2650
|
+
class qe extends Fe {}
|
|
2651
2651
|
|
|
2652
|
-
/** Transforms an array value via a union operation. */ class Ke extends
|
|
2652
|
+
/** Transforms an array value via a union operation. */ class Ke extends Fe {
|
|
2653
2653
|
constructor(t) {
|
|
2654
2654
|
super(), this.elements = t;
|
|
2655
2655
|
}
|
|
@@ -2665,7 +2665,7 @@ function je(t, e) {
|
|
|
2665
2665
|
};
|
|
2666
2666
|
}
|
|
2667
2667
|
|
|
2668
|
-
/** Transforms an array value via a remove operation. */ class Qe extends
|
|
2668
|
+
/** Transforms an array value via a remove operation. */ class Qe extends Fe {
|
|
2669
2669
|
constructor(t) {
|
|
2670
2670
|
super(), this.elements = t;
|
|
2671
2671
|
}
|
|
@@ -2686,7 +2686,7 @@ function We(t, e) {
|
|
|
2686
2686
|
* transforms. Converts all field values to integers or doubles, but unlike the
|
|
2687
2687
|
* backend does not cap integer values at 2^63. Instead, JavaScript number
|
|
2688
2688
|
* arithmetic is used and precision loss can occur for values greater than 2^53.
|
|
2689
|
-
*/ class Ge extends
|
|
2689
|
+
*/ class Ge extends Fe {
|
|
2690
2690
|
constructor(t, e) {
|
|
2691
2691
|
super(), this.k = t, this.N = e;
|
|
2692
2692
|
}
|
|
@@ -3145,7 +3145,7 @@ function pn(t) {
|
|
|
3145
3145
|
if (void 0 === t)
|
|
3146
3146
|
// This shouldn't normally happen, but in certain error cases (like trying
|
|
3147
3147
|
// to send invalid proto messages) we may get an error with no GRPC code.
|
|
3148
|
-
return
|
|
3148
|
+
return F("GRPC error has no .code"), Q.UNKNOWN;
|
|
3149
3149
|
switch (t) {
|
|
3150
3150
|
case mn.OK:
|
|
3151
3151
|
return Q.OK;
|
|
@@ -3690,10 +3690,10 @@ class Rn {
|
|
|
3690
3690
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3691
3691
|
* See the License for the specific language governing permissions and
|
|
3692
3692
|
* limitations under the License.
|
|
3693
|
-
*/ const
|
|
3693
|
+
*/ const bn = new Tn(Nt.comparator);
|
|
3694
3694
|
|
|
3695
|
-
function
|
|
3696
|
-
return
|
|
3695
|
+
function Pn() {
|
|
3696
|
+
return bn;
|
|
3697
3697
|
}
|
|
3698
3698
|
|
|
3699
3699
|
const vn = new Tn(Nt.comparator);
|
|
@@ -3778,7 +3778,7 @@ function xn() {
|
|
|
3778
3778
|
// PORTING NOTE: Multi-tab only
|
|
3779
3779
|
static createSynthesizedRemoteEventForCurrentChange(t, e) {
|
|
3780
3780
|
const n = new Map;
|
|
3781
|
-
return n.set(t, On.createSynthesizedTargetChangeForCurrentChange(t, e)), new $n(ht.min(), n, xn(),
|
|
3781
|
+
return n.set(t, On.createSynthesizedTargetChangeForCurrentChange(t, e)), new $n(ht.min(), n, xn(), Pn(), Nn());
|
|
3782
3782
|
}
|
|
3783
3783
|
}
|
|
3784
3784
|
|
|
@@ -3852,7 +3852,7 @@ function xn() {
|
|
|
3852
3852
|
* applies.
|
|
3853
3853
|
*
|
|
3854
3854
|
* If document has been deleted NoDocument will be provided.
|
|
3855
|
-
*/ class
|
|
3855
|
+
*/ class Mn {
|
|
3856
3856
|
constructor(
|
|
3857
3857
|
/** The new document applies to all of these targets. */
|
|
3858
3858
|
t,
|
|
@@ -3869,9 +3869,9 @@ function xn() {
|
|
|
3869
3869
|
}
|
|
3870
3870
|
}
|
|
3871
3871
|
|
|
3872
|
-
class
|
|
3872
|
+
class Fn {
|
|
3873
3873
|
constructor(t, e) {
|
|
3874
|
-
this.targetId = t, this.
|
|
3874
|
+
this.targetId = t, this.M = e;
|
|
3875
3875
|
}
|
|
3876
3876
|
}
|
|
3877
3877
|
|
|
@@ -3899,7 +3899,7 @@ class Ln {
|
|
|
3899
3899
|
* The number of pending responses (adds or removes) that we are waiting on.
|
|
3900
3900
|
* We only consider targets active that have no pending responses.
|
|
3901
3901
|
*/
|
|
3902
|
-
this.
|
|
3902
|
+
this.F = 0,
|
|
3903
3903
|
/**
|
|
3904
3904
|
* Keeps track of the document changes since the last raised snapshot.
|
|
3905
3905
|
*
|
|
@@ -3930,7 +3930,7 @@ class Ln {
|
|
|
3930
3930
|
return this.B;
|
|
3931
3931
|
}
|
|
3932
3932
|
/** Whether this target has pending target adds or target removes. */ get K() {
|
|
3933
|
-
return 0 !== this.
|
|
3933
|
+
return 0 !== this.F;
|
|
3934
3934
|
}
|
|
3935
3935
|
/** Whether we have modified any state that should trigger a snapshot. */ get j() {
|
|
3936
3936
|
return this.q;
|
|
@@ -3979,10 +3979,10 @@ class Ln {
|
|
|
3979
3979
|
this.q = !0, this.L = this.L.remove(t);
|
|
3980
3980
|
}
|
|
3981
3981
|
X() {
|
|
3982
|
-
this.
|
|
3982
|
+
this.F += 1;
|
|
3983
3983
|
}
|
|
3984
3984
|
Z() {
|
|
3985
|
-
this.
|
|
3985
|
+
this.F -= 1;
|
|
3986
3986
|
}
|
|
3987
3987
|
tt() {
|
|
3988
3988
|
this.q = !0, this.U = !0;
|
|
@@ -3998,7 +3998,7 @@ class Un {
|
|
|
3998
3998
|
/** The internal state of all tracked targets. */
|
|
3999
3999
|
this.nt = new Map,
|
|
4000
4000
|
/** Keeps track of the documents to update since the last raised snapshot. */
|
|
4001
|
-
this.st =
|
|
4001
|
+
this.st = Pn(),
|
|
4002
4002
|
/** A mapping of document keys to their set of target IDs. */
|
|
4003
4003
|
this.it = qn(),
|
|
4004
4004
|
/**
|
|
@@ -4071,7 +4071,7 @@ class Un {
|
|
|
4071
4071
|
* Targets that are invalidated by filter mismatches are added to
|
|
4072
4072
|
* `pendingTargetResets`.
|
|
4073
4073
|
*/ dt(t) {
|
|
4074
|
-
const e = t.targetId, n = t.
|
|
4074
|
+
const e = t.targetId, n = t.M.count, s = this.wt(e);
|
|
4075
4075
|
if (s) {
|
|
4076
4076
|
const t = s.target;
|
|
4077
4077
|
if (ee(t)) if (0 === n) {
|
|
@@ -4128,7 +4128,7 @@ class Un {
|
|
|
4128
4128
|
})), s && (n = n.add(t));
|
|
4129
4129
|
}));
|
|
4130
4130
|
const s = new $n(t, e, this.rt, this.st, n);
|
|
4131
|
-
return this.st =
|
|
4131
|
+
return this.st = Pn(), this.it = qn(), this.rt = new An(ot), s;
|
|
4132
4132
|
}
|
|
4133
4133
|
/**
|
|
4134
4134
|
* Adds the provided document to the internal list of document updates and
|
|
@@ -4187,7 +4187,7 @@ class Un {
|
|
|
4187
4187
|
* from watch.
|
|
4188
4188
|
*/ lt(t) {
|
|
4189
4189
|
const e = null !== this.wt(t);
|
|
4190
|
-
return e ||
|
|
4190
|
+
return e || M("WatchChangeAggregator", "Detected inactive target", t), e;
|
|
4191
4191
|
}
|
|
4192
4192
|
/**
|
|
4193
4193
|
* Returns the TargetData for an active target (i.e. a target that the user
|
|
@@ -4322,7 +4322,7 @@ function Yn(t, e) {
|
|
|
4322
4322
|
|
|
4323
4323
|
function Xn(t) {
|
|
4324
4324
|
const e = _t.fromString(t);
|
|
4325
|
-
return q(
|
|
4325
|
+
return q(Ps(e)), e;
|
|
4326
4326
|
}
|
|
4327
4327
|
|
|
4328
4328
|
function Zn(t, e) {
|
|
@@ -4422,19 +4422,19 @@ function cs(t, e) {
|
|
|
4422
4422
|
fields: s.document.fields
|
|
4423
4423
|
}
|
|
4424
4424
|
}), a = Ht.newFoundDocument(i, r, o), c = s.targetIds || [], u = s.removedTargetIds || [];
|
|
4425
|
-
n = new
|
|
4425
|
+
n = new Mn(c, u, a.key, a);
|
|
4426
4426
|
} else if ("documentDelete" in e) {
|
|
4427
4427
|
e.documentDelete;
|
|
4428
4428
|
const s = e.documentDelete;
|
|
4429
4429
|
s.document;
|
|
4430
4430
|
const i = ts(t, s.document), r = s.readTime ? Jn(s.readTime) : ht.min(), o = Ht.newNoDocument(i, r), a = s.removedTargetIds || [];
|
|
4431
|
-
n = new
|
|
4431
|
+
n = new Mn([], a, o.key, o);
|
|
4432
4432
|
} else if ("documentRemove" in e) {
|
|
4433
4433
|
e.documentRemove;
|
|
4434
4434
|
const s = e.documentRemove;
|
|
4435
4435
|
s.document;
|
|
4436
4436
|
const i = ts(t, s.document), r = s.removedTargetIds || [];
|
|
4437
|
-
n = new
|
|
4437
|
+
n = new Mn([], r, i, null);
|
|
4438
4438
|
} else {
|
|
4439
4439
|
if (!("filter" in e)) return U();
|
|
4440
4440
|
{
|
|
@@ -4442,7 +4442,7 @@ function cs(t, e) {
|
|
|
4442
4442
|
const t = e.filter;
|
|
4443
4443
|
t.targetId;
|
|
4444
4444
|
const s = t.count || 0, i = new _n(s), r = t.targetId;
|
|
4445
|
-
n = new
|
|
4445
|
+
n = new Fn(r, i);
|
|
4446
4446
|
}
|
|
4447
4447
|
}
|
|
4448
4448
|
return n;
|
|
@@ -4456,7 +4456,7 @@ function us(t, e) {
|
|
|
4456
4456
|
delete: Zn(t, e.key)
|
|
4457
4457
|
}; else if (e instanceof un) n = {
|
|
4458
4458
|
update: rs(t, e.key, e.data),
|
|
4459
|
-
updateMask:
|
|
4459
|
+
updateMask: bs(e.fieldMask)
|
|
4460
4460
|
}; else {
|
|
4461
4461
|
if (!(e instanceof wn)) return U();
|
|
4462
4462
|
n = {
|
|
@@ -4808,14 +4808,14 @@ function Rs(t) {
|
|
|
4808
4808
|
}
|
|
4809
4809
|
}
|
|
4810
4810
|
|
|
4811
|
-
function
|
|
4811
|
+
function bs(t) {
|
|
4812
4812
|
const e = [];
|
|
4813
4813
|
return t.fields.forEach((t => e.push(t.canonicalString()))), {
|
|
4814
4814
|
fieldPaths: e
|
|
4815
4815
|
};
|
|
4816
4816
|
}
|
|
4817
4817
|
|
|
4818
|
-
function
|
|
4818
|
+
function Ps(t) {
|
|
4819
4819
|
// Resource names have at least 4 components (project ID, database ID)
|
|
4820
4820
|
return t.length >= 4 && "projects" === t.get(0) && "databases" === t.get(2);
|
|
4821
4821
|
}
|
|
@@ -5135,7 +5135,7 @@ class Os {
|
|
|
5135
5135
|
/**
|
|
5136
5136
|
* Represents a document that is known to exist but whose data is unknown.
|
|
5137
5137
|
* Stored in IndexedDb as part of a DbRemoteDocument object.
|
|
5138
|
-
*/ class
|
|
5138
|
+
*/ class Ms {
|
|
5139
5139
|
constructor(t, e) {
|
|
5140
5140
|
this.path = t, this.version = e;
|
|
5141
5141
|
}
|
|
@@ -5153,7 +5153,7 @@ class Os {
|
|
|
5153
5153
|
*
|
|
5154
5154
|
* Note: This is the persisted equivalent of a MaybeDocument and could perhaps
|
|
5155
5155
|
* be made more general if necessary.
|
|
5156
|
-
*/ class
|
|
5156
|
+
*/ class Fs {
|
|
5157
5157
|
// TODO: We are currently storing full document keys almost three times
|
|
5158
5158
|
// (once as part of the primary key, once - partly - as `parentPath` and once
|
|
5159
5159
|
// inside the encoded documents). During our next migration, we should
|
|
@@ -5198,14 +5198,14 @@ class Os {
|
|
|
5198
5198
|
}
|
|
5199
5199
|
}
|
|
5200
5200
|
|
|
5201
|
-
|
|
5201
|
+
Fs.store = "remoteDocuments",
|
|
5202
5202
|
/**
|
|
5203
5203
|
* An index that provides access to all entries sorted by read time (which
|
|
5204
5204
|
* corresponds to the last modification time of each row).
|
|
5205
5205
|
*
|
|
5206
5206
|
* This index is used to provide a changelog for Multi-Tab.
|
|
5207
5207
|
*/
|
|
5208
|
-
|
|
5208
|
+
Fs.readTimeIndex = "readTimeIndex", Fs.readTimeIndexPath = "readTime",
|
|
5209
5209
|
/**
|
|
5210
5210
|
* An index that provides access to documents in a collection sorted by read
|
|
5211
5211
|
* time.
|
|
@@ -5213,7 +5213,7 @@ Ms.readTimeIndex = "readTimeIndex", Ms.readTimeIndexPath = "readTime",
|
|
|
5213
5213
|
* This index is used to allow the RemoteDocumentCache to fetch newly changed
|
|
5214
5214
|
* documents in a collection.
|
|
5215
5215
|
*/
|
|
5216
|
-
|
|
5216
|
+
Fs.collectionReadTimeIndex = "collectionReadTimeIndex", Fs.collectionReadTimeIndexPath = [ "parentPath", "readTime" ];
|
|
5217
5217
|
|
|
5218
5218
|
/**
|
|
5219
5219
|
* Contains a single entry that has metadata about the remote document cache.
|
|
@@ -5491,7 +5491,7 @@ class Ws {
|
|
|
5491
5491
|
/** Name of the IndexedDb object store. */ Ws.store = "namedQueries", Ws.keyPath = "name";
|
|
5492
5492
|
|
|
5493
5493
|
// Visible for testing
|
|
5494
|
-
const Gs = [ ...[ ...[ ...[ ...[ ks.store, xs.store, $s.store,
|
|
5494
|
+
const Gs = [ ...[ ...[ ...[ ...[ ks.store, xs.store, $s.store, Fs.store, Bs.store, Ns.store, qs.store, Us.store ], js.store ], Ls.store ], Ks.store ], Qs.store, Ws.store ], zs = "The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.";
|
|
5495
5495
|
|
|
5496
5496
|
// V2 is no longer usable (see comment at top of file)
|
|
5497
5497
|
// Visible for testing
|
|
@@ -5681,7 +5681,7 @@ class Ys {
|
|
|
5681
5681
|
return this.It.promise;
|
|
5682
5682
|
}
|
|
5683
5683
|
abort(t) {
|
|
5684
|
-
t && this.It.reject(t), this.aborted || (
|
|
5684
|
+
t && this.It.reject(t), this.aborted || (M("SimpleDb", "Aborting transaction:", t ? t.message : "Client-initiated abort"),
|
|
5685
5685
|
this.aborted = !0, this.transaction.abort());
|
|
5686
5686
|
}
|
|
5687
5687
|
/**
|
|
@@ -5720,12 +5720,12 @@ class Ys {
|
|
|
5720
5720
|
// bug we're checking for should exist in iOS >= 12.2 and < 13, but for
|
|
5721
5721
|
// whatever reason it's much harder to hit after 12.2 so we only proactively
|
|
5722
5722
|
// log on 12.2.
|
|
5723
|
-
12.2 === Xs.
|
|
5723
|
+
12.2 === Xs.bt(h()) && F("Firestore persistence suffers from a bug in iOS 12.2 Safari that may cause your app to stop working. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.");
|
|
5724
5724
|
}
|
|
5725
5725
|
/** Deletes the specified database. */ static delete(t) {
|
|
5726
|
-
return
|
|
5726
|
+
return M("SimpleDb", "Removing database:", t), si(window.indexedDB.deleteDatabase(t)).toPromise();
|
|
5727
5727
|
}
|
|
5728
|
-
/** Returns true if IndexedDB is available in the current environment. */ static
|
|
5728
|
+
/** Returns true if IndexedDB is available in the current environment. */ static Pt() {
|
|
5729
5729
|
if (!l()) return !1;
|
|
5730
5730
|
if (Xs.vt()) return !0;
|
|
5731
5731
|
// We extensively use indexed array values and compound keys,
|
|
@@ -5735,7 +5735,7 @@ class Ys {
|
|
|
5735
5735
|
// For tracking support of this feature, see here:
|
|
5736
5736
|
// https://developer.microsoft.com/en-us/microsoft-edge/platform/status/indexeddbarraysandmultientrysupport/
|
|
5737
5737
|
// Check the UA string to find out the browser.
|
|
5738
|
-
const t = h(), e = Xs.
|
|
5738
|
+
const t = h(), e = Xs.bt(t), n = 0 < e && e < 10, s = Xs.Vt(t), i = 0 < s && s < 4.5;
|
|
5739
5739
|
// IE 10
|
|
5740
5740
|
// ua = 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)';
|
|
5741
5741
|
// IE 11
|
|
@@ -5758,7 +5758,7 @@ class Ys {
|
|
|
5758
5758
|
}
|
|
5759
5759
|
// visible for testing
|
|
5760
5760
|
/** Parse User Agent to determine iOS version. Returns -1 if not found. */
|
|
5761
|
-
static
|
|
5761
|
+
static bt(t) {
|
|
5762
5762
|
const e = t.match(/i(?:phone|pad|pod) os ([\d_]+)/i), n = e ? e[1].split("_").slice(0, 2).join(".") : "-1";
|
|
5763
5763
|
return Number(n);
|
|
5764
5764
|
}
|
|
@@ -5771,7 +5771,7 @@ class Ys {
|
|
|
5771
5771
|
/**
|
|
5772
5772
|
* Opens the specified database, creating or upgrading it if necessary.
|
|
5773
5773
|
*/ async Ct(t) {
|
|
5774
|
-
return this.db || (
|
|
5774
|
+
return this.db || (M("SimpleDb", "Opening database:", this.name), this.db = await new Promise(((e, n) => {
|
|
5775
5775
|
// TODO(mikelehen): Investigate browser compatibility.
|
|
5776
5776
|
// https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API/Using_IndexedDB
|
|
5777
5777
|
// suggests IE9 and older WebKit browsers handle upgrade
|
|
@@ -5787,10 +5787,10 @@ class Ys {
|
|
|
5787
5787
|
const s = e.target.error;
|
|
5788
5788
|
"VersionError" === s.name ? n(new W(Q.FAILED_PRECONDITION, "A newer version of the Firestore SDK was previously used and so the persisted data is not compatible with the version of the SDK you are now using. The SDK will operate with persistence disabled. If you need persistence, please re-upgrade to a newer version of the SDK or else clear the persisted IndexedDB data for your app to start fresh.")) : "InvalidStateError" === s.name ? n(new W(Q.FAILED_PRECONDITION, "Unable to open an IndexedDB connection. This could be due to running in a private browsing session on a browser whose private browsing sessions do not support IndexedDB: " + s)) : n(new ti(t, s));
|
|
5789
5789
|
}, s.onupgradeneeded = t => {
|
|
5790
|
-
|
|
5790
|
+
M("SimpleDb", 'Database "' + this.name + '" requires upgrade from version:', t.oldVersion);
|
|
5791
5791
|
const e = t.target.result;
|
|
5792
5792
|
this.Rt.Nt(e, s.transaction, t.oldVersion, this.version).next((() => {
|
|
5793
|
-
|
|
5793
|
+
M("SimpleDb", "Database upgrade to version " + this.version + " complete");
|
|
5794
5794
|
}));
|
|
5795
5795
|
};
|
|
5796
5796
|
}))), this.kt && (this.db.onversionchange = t => this.kt(t)), this.db;
|
|
@@ -5822,7 +5822,7 @@ class Ys {
|
|
|
5822
5822
|
// Note: We cannot use an instanceof check for FirestoreException, since the
|
|
5823
5823
|
// exception is wrapped in a generic error by our async/await handling.
|
|
5824
5824
|
const e = "FirebaseError" !== t.name && r < 3;
|
|
5825
|
-
if (
|
|
5825
|
+
if (M("SimpleDb", "Transaction failed with error:", t.message, "Retrying:", e),
|
|
5826
5826
|
this.close(), !e) return Promise.reject(t);
|
|
5827
5827
|
}
|
|
5828
5828
|
}
|
|
@@ -5838,13 +5838,13 @@ class Ys {
|
|
|
5838
5838
|
* within the key range or index.
|
|
5839
5839
|
*/ class Zs {
|
|
5840
5840
|
constructor(t) {
|
|
5841
|
-
this.$t = t, this.Ot = !1, this.
|
|
5841
|
+
this.$t = t, this.Ot = !1, this.Mt = null;
|
|
5842
5842
|
}
|
|
5843
5843
|
get isDone() {
|
|
5844
5844
|
return this.Ot;
|
|
5845
5845
|
}
|
|
5846
|
-
get
|
|
5847
|
-
return this.
|
|
5846
|
+
get Ft() {
|
|
5847
|
+
return this.Mt;
|
|
5848
5848
|
}
|
|
5849
5849
|
set cursor(t) {
|
|
5850
5850
|
this.$t = t;
|
|
@@ -5858,7 +5858,7 @@ class Ys {
|
|
|
5858
5858
|
* This function can be called to skip to that next key, which could be
|
|
5859
5859
|
* an index or a primary key.
|
|
5860
5860
|
*/ Lt(t) {
|
|
5861
|
-
this.
|
|
5861
|
+
this.Mt = t;
|
|
5862
5862
|
}
|
|
5863
5863
|
/**
|
|
5864
5864
|
* Delete the current cursor value from the object store.
|
|
@@ -5896,7 +5896,7 @@ class Ys {
|
|
|
5896
5896
|
}
|
|
5897
5897
|
put(t, e) {
|
|
5898
5898
|
let n;
|
|
5899
|
-
return void 0 !== e ? (
|
|
5899
|
+
return void 0 !== e ? (M("SimpleDb", "PUT", this.store.name, t, e), n = this.store.put(e, t)) : (M("SimpleDb", "PUT", this.store.name, "<auto-key>", t),
|
|
5900
5900
|
n = this.store.put(t)), si(n);
|
|
5901
5901
|
}
|
|
5902
5902
|
/**
|
|
@@ -5906,7 +5906,7 @@ class Ys {
|
|
|
5906
5906
|
* @param value - The object to write.
|
|
5907
5907
|
* @returns The key of the value to add.
|
|
5908
5908
|
*/ add(t) {
|
|
5909
|
-
|
|
5909
|
+
M("SimpleDb", "ADD", this.store.name, t, t);
|
|
5910
5910
|
return si(this.store.add(t));
|
|
5911
5911
|
}
|
|
5912
5912
|
/**
|
|
@@ -5920,10 +5920,10 @@ class Ys {
|
|
|
5920
5920
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5921
5921
|
return si(this.store.get(t)).next((e => (
|
|
5922
5922
|
// Normalize nonexistence to null.
|
|
5923
|
-
void 0 === e && (e = null),
|
|
5923
|
+
void 0 === e && (e = null), M("SimpleDb", "GET", this.store.name, t, e), e)));
|
|
5924
5924
|
}
|
|
5925
5925
|
delete(t) {
|
|
5926
|
-
|
|
5926
|
+
M("SimpleDb", "DELETE", this.store.name, t);
|
|
5927
5927
|
return si(this.store.delete(t));
|
|
5928
5928
|
}
|
|
5929
5929
|
/**
|
|
@@ -5932,7 +5932,7 @@ class Ys {
|
|
|
5932
5932
|
*
|
|
5933
5933
|
* Returns the number of rows in the store.
|
|
5934
5934
|
*/ count() {
|
|
5935
|
-
|
|
5935
|
+
M("SimpleDb", "COUNT", this.store.name);
|
|
5936
5936
|
return si(this.store.count());
|
|
5937
5937
|
}
|
|
5938
5938
|
Bt(t, e) {
|
|
@@ -5942,7 +5942,7 @@ class Ys {
|
|
|
5942
5942
|
})).next((() => s));
|
|
5943
5943
|
}
|
|
5944
5944
|
qt(t, e) {
|
|
5945
|
-
|
|
5945
|
+
M("SimpleDb", "DELETE ALL", this.store.name);
|
|
5946
5946
|
const n = this.options(t, e);
|
|
5947
5947
|
n.Kt = !1;
|
|
5948
5948
|
const s = this.cursor(n);
|
|
@@ -5988,7 +5988,7 @@ class Ys {
|
|
|
5988
5988
|
const t = o.catch((t => (r.done(), Js.reject(t))));
|
|
5989
5989
|
n.push(t);
|
|
5990
5990
|
}
|
|
5991
|
-
r.isDone ? s() : null === r.
|
|
5991
|
+
r.isDone ? s() : null === r.Ft ? i.continue() : i.continue(r.Ft);
|
|
5992
5992
|
};
|
|
5993
5993
|
})).next((() => Js.waitFor(n)));
|
|
5994
5994
|
}
|
|
@@ -6028,7 +6028,7 @@ class Ys {
|
|
|
6028
6028
|
let ii = !1;
|
|
6029
6029
|
|
|
6030
6030
|
function ri(t) {
|
|
6031
|
-
const e = Xs.
|
|
6031
|
+
const e = Xs.bt(h());
|
|
6032
6032
|
if (e >= 12.2 && e < 13) {
|
|
6033
6033
|
const e = "An internal error was encountered in the Indexed Database server";
|
|
6034
6034
|
if (t.message.indexOf(e) >= 0) {
|
|
@@ -6287,19 +6287,19 @@ function ai(t, e) {
|
|
|
6287
6287
|
updateTime: Gn(t, e.version.toTimestamp())
|
|
6288
6288
|
};
|
|
6289
6289
|
}(t.Gt, e), r = e.hasCommittedMutations;
|
|
6290
|
-
return new
|
|
6290
|
+
return new Fs(
|
|
6291
6291
|
/* unknownDocument= */ null,
|
|
6292
6292
|
/* noDocument= */ null, n, r, s, i);
|
|
6293
6293
|
}
|
|
6294
6294
|
if (e.isNoDocument()) {
|
|
6295
6295
|
const t = e.key.path.toArray(), n = mi(e.version), r = e.hasCommittedMutations;
|
|
6296
|
-
return new
|
|
6296
|
+
return new Fs(
|
|
6297
6297
|
/* unknownDocument= */ null, new Os(t, n),
|
|
6298
6298
|
/* document= */ null, r, s, i);
|
|
6299
6299
|
}
|
|
6300
6300
|
if (e.isUnknownDocument()) {
|
|
6301
6301
|
const t = e.key.path.toArray(), n = mi(e.version);
|
|
6302
|
-
return new
|
|
6302
|
+
return new Fs(new Ms(t, n),
|
|
6303
6303
|
/* noDocument= */ null,
|
|
6304
6304
|
/* document= */ null,
|
|
6305
6305
|
/* hasCommittedMutations= */ !0, s, i);
|
|
@@ -6474,9 +6474,9 @@ class Ii {
|
|
|
6474
6474
|
*/
|
|
6475
6475
|
/**
|
|
6476
6476
|
* An in-memory implementation of IndexManager.
|
|
6477
|
-
*/ class
|
|
6477
|
+
*/ class bi {
|
|
6478
6478
|
constructor() {
|
|
6479
|
-
this.zt = new
|
|
6479
|
+
this.zt = new Pi;
|
|
6480
6480
|
}
|
|
6481
6481
|
addToCollectionParentIndex(t, e) {
|
|
6482
6482
|
return this.zt.add(e), Js.resolve();
|
|
@@ -6490,7 +6490,7 @@ class Ii {
|
|
|
6490
6490
|
* Internal implementation of the collection-parent index exposed by MemoryIndexManager.
|
|
6491
6491
|
* Also used for in-memory caching by IndexedDbIndexManager and initial index population
|
|
6492
6492
|
* in indexeddb_schema.ts
|
|
6493
|
-
*/ class
|
|
6493
|
+
*/ class Pi {
|
|
6494
6494
|
constructor() {
|
|
6495
6495
|
this.index = {};
|
|
6496
6496
|
}
|
|
@@ -6535,7 +6535,7 @@ class Ii {
|
|
|
6535
6535
|
* This is *NOT* a complete cache of what's in persistence and so can never be used to
|
|
6536
6536
|
* satisfy reads.
|
|
6537
6537
|
*/
|
|
6538
|
-
this.Ht = new
|
|
6538
|
+
this.Ht = new Pi;
|
|
6539
6539
|
}
|
|
6540
6540
|
/**
|
|
6541
6541
|
* Adds a new entry to the collection parent index.
|
|
@@ -6924,7 +6924,7 @@ class ki {
|
|
|
6924
6924
|
// PORTING NOTE: Multi-tab only (state is held in memory in other clients).
|
|
6925
6925
|
/** Returns the mutation queue's metadata from IndexedDb. */
|
|
6926
6926
|
ne(t) {
|
|
6927
|
-
return
|
|
6927
|
+
return Mi(t).get(this.userId).next((t => t || new ks(this.userId, -1,
|
|
6928
6928
|
/*lastStreamToken=*/ "")));
|
|
6929
6929
|
}
|
|
6930
6930
|
}
|
|
@@ -6960,7 +6960,7 @@ function $i(t) {
|
|
|
6960
6960
|
|
|
6961
6961
|
/**
|
|
6962
6962
|
* Helper to get a typed SimpleDbStore for the mutationQueues object store.
|
|
6963
|
-
*/ function
|
|
6963
|
+
*/ function Mi(t) {
|
|
6964
6964
|
return ai(t, ks.store);
|
|
6965
6965
|
}
|
|
6966
6966
|
|
|
@@ -6995,7 +6995,7 @@ function $i(t) {
|
|
|
6995
6995
|
* generate in-memory target IDs that are transient and can be reused after a
|
|
6996
6996
|
* restart.
|
|
6997
6997
|
*/
|
|
6998
|
-
class
|
|
6998
|
+
class Fi {
|
|
6999
6999
|
constructor(t) {
|
|
7000
7000
|
this.se = t;
|
|
7001
7001
|
}
|
|
@@ -7007,11 +7007,11 @@ class Mi {
|
|
|
7007
7007
|
// as there is no differentiation in the protocol layer between an unset
|
|
7008
7008
|
// number and the number '0'. If we were to sent a target with target ID
|
|
7009
7009
|
// '0', the backend would consider it unset and replace it with its own ID.
|
|
7010
|
-
return new
|
|
7010
|
+
return new Fi(0);
|
|
7011
7011
|
}
|
|
7012
7012
|
static re() {
|
|
7013
7013
|
// Sync engine assigns target IDs for limbo document detection.
|
|
7014
|
-
return new
|
|
7014
|
+
return new Fi(-1);
|
|
7015
7015
|
}
|
|
7016
7016
|
}
|
|
7017
7017
|
|
|
@@ -7042,7 +7042,7 @@ class Mi {
|
|
|
7042
7042
|
// out to have a meaningful performance impact.
|
|
7043
7043
|
allocateTargetId(t) {
|
|
7044
7044
|
return this.oe(t).next((e => {
|
|
7045
|
-
const n = new
|
|
7045
|
+
const n = new Fi(e.highestTargetId);
|
|
7046
7046
|
return e.highestTargetId = n.next(), this.ae(t, e).next((() => e.highestTargetId));
|
|
7047
7047
|
}));
|
|
7048
7048
|
}
|
|
@@ -7236,7 +7236,7 @@ class Mi {
|
|
|
7236
7236
|
* @returns A Promise that resolves after we recovered, or the original error.
|
|
7237
7237
|
*/ async function Ki(t) {
|
|
7238
7238
|
if (t.code !== Q.FAILED_PRECONDITION || t.message !== zs) throw t;
|
|
7239
|
-
|
|
7239
|
+
M("LocalStore", "Unexpectedly lost primary lease");
|
|
7240
7240
|
}
|
|
7241
7241
|
|
|
7242
7242
|
/**
|
|
@@ -7306,12 +7306,12 @@ class Mi {
|
|
|
7306
7306
|
}
|
|
7307
7307
|
me(t) {
|
|
7308
7308
|
const e = this.we ? 3e5 : 6e4;
|
|
7309
|
-
|
|
7309
|
+
M("LruGarbageCollector", `Garbage collection scheduled in ${e}ms`), this._e = this.asyncQueue.enqueueAfterDelay("lru_garbage_collection" /* LruGarbageCollection */ , e, (async () => {
|
|
7310
7310
|
this._e = null, this.we = !0;
|
|
7311
7311
|
try {
|
|
7312
7312
|
await t.collectGarbage(this.garbageCollector);
|
|
7313
7313
|
} catch (t) {
|
|
7314
|
-
ei(t) ?
|
|
7314
|
+
ei(t) ? M("LruGarbageCollector", "Ignoring IndexedDB error during garbage collection: ", t) : await Ki(t);
|
|
7315
7315
|
}
|
|
7316
7316
|
await this.me(t);
|
|
7317
7317
|
}));
|
|
@@ -7337,8 +7337,8 @@ class Mi {
|
|
|
7337
7337
|
return this.ge.removeOrphanedDocuments(t, e);
|
|
7338
7338
|
}
|
|
7339
7339
|
collect(t, e) {
|
|
7340
|
-
return -1 === this.params.cacheSizeCollectionThreshold ? (
|
|
7341
|
-
Js.resolve(Si)) : this.getCacheSize(t).next((n => n < this.params.cacheSizeCollectionThreshold ? (
|
|
7340
|
+
return -1 === this.params.cacheSizeCollectionThreshold ? (M("LruGarbageCollector", "Garbage collection skipped; disabled"),
|
|
7341
|
+
Js.resolve(Si)) : this.getCacheSize(t).next((n => n < this.params.cacheSizeCollectionThreshold ? (M("LruGarbageCollector", `Garbage collection skipped; Cache size ${n} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),
|
|
7342
7342
|
Si) : this.Te(t, e)));
|
|
7343
7343
|
}
|
|
7344
7344
|
getCacheSize(t) {
|
|
@@ -7349,12 +7349,12 @@ class Mi {
|
|
|
7349
7349
|
const h = Date.now();
|
|
7350
7350
|
return this.calculateTargetCount(t, this.params.percentileToCollect).next((e => (
|
|
7351
7351
|
// Cap at the configured max
|
|
7352
|
-
e > this.params.maximumSequenceNumbersToCollect ? (
|
|
7352
|
+
e > this.params.maximumSequenceNumbersToCollect ? (M("LruGarbageCollector", `Capping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${e}`),
|
|
7353
7353
|
s = this.params.maximumSequenceNumbersToCollect) : s = e, r = Date.now(), this.nthSequenceNumber(t, s)))).next((s => (n = s,
|
|
7354
7354
|
o = Date.now(), this.removeTargets(t, n, e)))).next((e => (i = e, c = Date.now(),
|
|
7355
7355
|
this.removeOrphanedDocuments(t, n)))).next((t => {
|
|
7356
7356
|
if (u = Date.now(), $() <= a.DEBUG) {
|
|
7357
|
-
|
|
7357
|
+
M("LruGarbageCollector", `LRU Garbage Collection\n\tCounted targets in ${r - h}ms\n\tDetermined least recently used ${s} in ` + (o - r) + "ms\n" + `\tRemoved ${i} targets in ` + (c - o) + "ms\n" + `\tRemoved ${t} documents in ` + (u - c) + "ms\n" + `Total Duration: ${u - h}ms`);
|
|
7358
7358
|
}
|
|
7359
7359
|
return Js.resolve({
|
|
7360
7360
|
didRun: !0,
|
|
@@ -7425,7 +7425,7 @@ class zi {
|
|
|
7425
7425
|
*/ Ae(t, e) {
|
|
7426
7426
|
return function(t, e) {
|
|
7427
7427
|
let n = !1;
|
|
7428
|
-
return
|
|
7428
|
+
return Mi(t).Qt((s => xi(t, s, e).next((t => (t && (n = !0), Js.resolve(!t)))))).next((() => n));
|
|
7429
7429
|
}(t, e);
|
|
7430
7430
|
}
|
|
7431
7431
|
removeOrphanedDocuments(t, e) {
|
|
@@ -7711,23 +7711,23 @@ function Hi(t, e) {
|
|
|
7711
7711
|
return this.getMetadata(t).next((n => (n.byteSize += e, this.Re(t, n))));
|
|
7712
7712
|
}
|
|
7713
7713
|
getEntry(t, e) {
|
|
7714
|
-
return er(t).get(nr(e)).next((t => this.
|
|
7714
|
+
return er(t).get(nr(e)).next((t => this.be(e, t)));
|
|
7715
7715
|
}
|
|
7716
7716
|
/**
|
|
7717
7717
|
* Looks up an entry in the cache.
|
|
7718
7718
|
*
|
|
7719
7719
|
* @param documentKey - The key of the entry to look up.
|
|
7720
7720
|
* @returns The cached document entry and its size.
|
|
7721
|
-
*/
|
|
7721
|
+
*/ Pe(t, e) {
|
|
7722
7722
|
return er(t).get(nr(e)).next((t => ({
|
|
7723
|
-
document: this.
|
|
7723
|
+
document: this.be(e, t),
|
|
7724
7724
|
size: Ni(t)
|
|
7725
7725
|
})));
|
|
7726
7726
|
}
|
|
7727
7727
|
getEntries(t, e) {
|
|
7728
|
-
let n =
|
|
7728
|
+
let n = Pn();
|
|
7729
7729
|
return this.ve(t, e, ((t, e) => {
|
|
7730
|
-
const s = this.
|
|
7730
|
+
const s = this.be(t, e);
|
|
7731
7731
|
n = n.insert(t, s);
|
|
7732
7732
|
})).next((() => n));
|
|
7733
7733
|
}
|
|
@@ -7738,9 +7738,9 @@ function Hi(t, e) {
|
|
|
7738
7738
|
* @returns A map of documents indexed by key and a map of sizes indexed by
|
|
7739
7739
|
* key (zero if the document does not exist).
|
|
7740
7740
|
*/ Ve(t, e) {
|
|
7741
|
-
let n =
|
|
7741
|
+
let n = Pn(), s = new Tn(Nt.comparator);
|
|
7742
7742
|
return this.ve(t, e, ((t, e) => {
|
|
7743
|
-
const i = this.
|
|
7743
|
+
const i = this.be(t, e);
|
|
7744
7744
|
n = n.insert(t, i), s = s.insert(t, Ni(e));
|
|
7745
7745
|
})).next((() => ({
|
|
7746
7746
|
documents: n,
|
|
@@ -7769,7 +7769,7 @@ function Hi(t, e) {
|
|
|
7769
7769
|
}));
|
|
7770
7770
|
}
|
|
7771
7771
|
getDocumentsMatchingQuery(t, e, n) {
|
|
7772
|
-
let s =
|
|
7772
|
+
let s = Pn();
|
|
7773
7773
|
const i = e.path.length + 1, r = {};
|
|
7774
7774
|
if (n.isEqual(ht.min())) {
|
|
7775
7775
|
// Documents are ordered by key, so we can use a prefix scan to narrow
|
|
@@ -7782,7 +7782,7 @@ function Hi(t, e) {
|
|
|
7782
7782
|
// lastLimboFreeSnapshotVersion (`sinceReadTime`) have a read time set.
|
|
7783
7783
|
const t = e.path.toArray(), s = wi(n);
|
|
7784
7784
|
r.range = IDBKeyRange.lowerBound([ t, s ],
|
|
7785
|
-
/* open= */ !0), r.index =
|
|
7785
|
+
/* open= */ !0), r.index = Fs.collectionReadTimeIndex;
|
|
7786
7786
|
}
|
|
7787
7787
|
return er(t).jt(r, ((t, n, r) => {
|
|
7788
7788
|
// The query is actually returning any path that starts with the query
|
|
@@ -7810,7 +7810,7 @@ function Hi(t, e) {
|
|
|
7810
7810
|
/**
|
|
7811
7811
|
* Decodes `remoteDoc` and returns the document (or null, if the document
|
|
7812
7812
|
* corresponds to the format used for sentinel deletes).
|
|
7813
|
-
*/
|
|
7813
|
+
*/ be(t, e) {
|
|
7814
7814
|
if (e) {
|
|
7815
7815
|
const t = fi(this.k, e);
|
|
7816
7816
|
// Whether the document is a sentinel removal and should only be used in the
|
|
@@ -7869,7 +7869,7 @@ class Zi extends Yi {
|
|
|
7869
7869
|
}
|
|
7870
7870
|
getFromCache(t, e) {
|
|
7871
7871
|
// Record the size of everything we load from the cache so we can compute a delta later.
|
|
7872
|
-
return this.De.
|
|
7872
|
+
return this.De.Pe(t, e).next((t => (this.Ce.set(e, t.size), t.document)));
|
|
7873
7873
|
}
|
|
7874
7874
|
getAllFromCache(t, e) {
|
|
7875
7875
|
// Record the size of everything we load from the cache so we can compute
|
|
@@ -7891,7 +7891,7 @@ function tr(t) {
|
|
|
7891
7891
|
/**
|
|
7892
7892
|
* Helper to get a typed SimpleDbStore for the remoteDocuments object store.
|
|
7893
7893
|
*/ function er(t) {
|
|
7894
|
-
return ai(t,
|
|
7894
|
+
return ai(t, Fs.store);
|
|
7895
7895
|
}
|
|
7896
7896
|
|
|
7897
7897
|
function nr(t) {
|
|
@@ -7944,7 +7944,7 @@ function nr(t) {
|
|
|
7944
7944
|
* Upgrade function to migrate the 'mutations' store from V1 to V3. Loads
|
|
7945
7945
|
* and rewrites all data.
|
|
7946
7946
|
*/ (t), ir(t), function(t) {
|
|
7947
|
-
t.createObjectStore(
|
|
7947
|
+
t.createObjectStore(Fs.store);
|
|
7948
7948
|
}(t));
|
|
7949
7949
|
// Migration 2 to populate the targetGlobal object no longer needed since
|
|
7950
7950
|
// migration 3 unconditionally clears it.
|
|
@@ -8005,10 +8005,10 @@ function nr(t) {
|
|
|
8005
8005
|
!function(t) {
|
|
8006
8006
|
t.objectStoreNames.contains("remoteDocumentChanges") && t.deleteObjectStore("remoteDocumentChanges");
|
|
8007
8007
|
}(t), function(t) {
|
|
8008
|
-
const e = t.objectStore(
|
|
8009
|
-
e.createIndex(
|
|
8008
|
+
const e = t.objectStore(Fs.store);
|
|
8009
|
+
e.createIndex(Fs.readTimeIndex, Fs.readTimeIndexPath, {
|
|
8010
8010
|
unique: !1
|
|
8011
|
-
}), e.createIndex(
|
|
8011
|
+
}), e.createIndex(Fs.collectionReadTimeIndex, Fs.collectionReadTimeIndexPath, {
|
|
8012
8012
|
unique: !1
|
|
8013
8013
|
});
|
|
8014
8014
|
}(e);
|
|
@@ -8042,7 +8042,7 @@ function nr(t) {
|
|
|
8042
8042
|
}
|
|
8043
8043
|
ke(t) {
|
|
8044
8044
|
let e = 0;
|
|
8045
|
-
return t.store(
|
|
8045
|
+
return t.store(Fs.store).jt(((t, n) => {
|
|
8046
8046
|
e += Ni(n);
|
|
8047
8047
|
})).next((() => {
|
|
8048
8048
|
const n = new Ls(e);
|
|
@@ -8064,7 +8064,7 @@ function nr(t) {
|
|
|
8064
8064
|
* Ensures that every document in the remote document cache has a corresponding sentinel row
|
|
8065
8065
|
* with a sequence number. Missing rows are given the most recently used sequence number.
|
|
8066
8066
|
*/ xe(t) {
|
|
8067
|
-
const e = t.store(Us.store), n = t.store(
|
|
8067
|
+
const e = t.store(Us.store), n = t.store(Fs.store);
|
|
8068
8068
|
return t.store(qs.store).get(qs.key).next((t => {
|
|
8069
8069
|
const s = [];
|
|
8070
8070
|
return n.jt(((n, i) => {
|
|
@@ -8080,7 +8080,7 @@ function nr(t) {
|
|
|
8080
8080
|
t.createObjectStore(Ks.store, {
|
|
8081
8081
|
keyPath: Ks.keyPath
|
|
8082
8082
|
});
|
|
8083
|
-
const n = e.store(Ks.store), s = new
|
|
8083
|
+
const n = e.store(Ks.store), s = new Pi, i = t => {
|
|
8084
8084
|
if (s.add(t)) {
|
|
8085
8085
|
const e = t.lastSegment(), s = t.popLast();
|
|
8086
8086
|
return n.put({
|
|
@@ -8091,7 +8091,7 @@ function nr(t) {
|
|
|
8091
8091
|
};
|
|
8092
8092
|
// Helper to add an index entry iff we haven't already written it.
|
|
8093
8093
|
// Index existing remote documents.
|
|
8094
|
-
return e.store(
|
|
8094
|
+
return e.store(Fs.store).jt({
|
|
8095
8095
|
Kt: !0
|
|
8096
8096
|
}, ((t, e) => {
|
|
8097
8097
|
const n = new _t(t);
|
|
@@ -8191,7 +8191,7 @@ class or {
|
|
|
8191
8191
|
*/
|
|
8192
8192
|
u) {
|
|
8193
8193
|
if (this.allowTabSynchronization = t, this.persistenceKey = e, this.clientId = n,
|
|
8194
|
-
this.
|
|
8194
|
+
this.Me = i, this.window = r, this.document = o, this.Fe = c, this.Le = u, this.Be = null,
|
|
8195
8195
|
this.Ue = !1, this.isPrimary = !1, this.networkEnabled = !0,
|
|
8196
8196
|
/** Our window.unload handler, if registered. */
|
|
8197
8197
|
this.qe = null, this.inForeground = !1,
|
|
@@ -8202,7 +8202,7 @@ class or {
|
|
|
8202
8202
|
/** The last time we garbage collected the client metadata object store. */
|
|
8203
8203
|
this.Qe = Number.NEGATIVE_INFINITY,
|
|
8204
8204
|
/** A listener to notify on primary state changes. */
|
|
8205
|
-
this.We = t => Promise.resolve(), !or.
|
|
8205
|
+
this.We = t => Promise.resolve(), !or.Pt()) throw new W(Q.UNIMPLEMENTED, "This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");
|
|
8206
8206
|
this.referenceDelegate = new zi(this, s), this.Ge = e + "main", this.k = new li(a),
|
|
8207
8207
|
this.ze = new Xs(this.Ge, 11, new sr(this.k)), this.He = new Li(this.referenceDelegate, this.k),
|
|
8208
8208
|
this.Jt = new vi, this.Je = function(t, e) {
|
|
@@ -8214,7 +8214,7 @@ class or {
|
|
|
8214
8214
|
*/
|
|
8215
8215
|
// PORTING NOTE: This is only used for multi-tab synchronization.
|
|
8216
8216
|
(this.k, this.Jt), this.Ye = new Ii, this.window && this.window.localStorage ? this.Xe = this.window.localStorage : (this.Xe = null,
|
|
8217
|
-
!1 === u &&
|
|
8217
|
+
!1 === u && F("IndexedDbPersistence", "LocalStorage is unavailable. As a result, persistence may not work reliably. In particular enablePersistence() could fail immediately after refreshing the page."));
|
|
8218
8218
|
}
|
|
8219
8219
|
/**
|
|
8220
8220
|
* Attempt to start IndexedDb persistence.
|
|
@@ -8231,7 +8231,7 @@ class or {
|
|
|
8231
8231
|
throw new W(Q.FAILED_PRECONDITION, rr);
|
|
8232
8232
|
return this.tn(), this.en(), this.nn(), this.runTransaction("getHighestListenSequenceNumber", "readonly", (t => this.He.getHighestSequenceNumber(t)));
|
|
8233
8233
|
})).then((t => {
|
|
8234
|
-
this.Be = new st(t, this.
|
|
8234
|
+
this.Be = new st(t, this.Fe);
|
|
8235
8235
|
})).then((() => {
|
|
8236
8236
|
this.Ue = !0;
|
|
8237
8237
|
})).catch((t => (this.ze && this.ze.close(), Promise.reject(t))));
|
|
@@ -8267,7 +8267,7 @@ class or {
|
|
|
8267
8267
|
this.networkEnabled !== t && (this.networkEnabled = t,
|
|
8268
8268
|
// Schedule a primary lease refresh for immediate execution. The eventual
|
|
8269
8269
|
// lease update will be propagated via `primaryStateListener`.
|
|
8270
|
-
this.
|
|
8270
|
+
this.Me.enqueueAndForget((async () => {
|
|
8271
8271
|
this.started && await this.Ze();
|
|
8272
8272
|
})));
|
|
8273
8273
|
}
|
|
@@ -8279,18 +8279,18 @@ class or {
|
|
|
8279
8279
|
*/ Ze() {
|
|
8280
8280
|
return this.runTransaction("updateClientMetadataAndTryBecomePrimary", "readwrite", (t => cr(t).put(new js(this.clientId, Date.now(), this.networkEnabled, this.inForeground)).next((() => {
|
|
8281
8281
|
if (this.isPrimary) return this.rn(t).next((t => {
|
|
8282
|
-
t || (this.isPrimary = !1, this.
|
|
8282
|
+
t || (this.isPrimary = !1, this.Me.enqueueRetryable((() => this.We(!1))));
|
|
8283
8283
|
}));
|
|
8284
8284
|
})).next((() => this.on(t))).next((e => this.isPrimary && !e ? this.an(t).next((() => !1)) : !!e && this.cn(t).next((() => !0)))))).catch((t => {
|
|
8285
8285
|
if (ei(t))
|
|
8286
8286
|
// Proceed with the existing state. Any subsequent access to
|
|
8287
8287
|
// IndexedDB will verify the lease.
|
|
8288
|
-
return
|
|
8288
|
+
return M("IndexedDbPersistence", "Failed to extend owner lease: ", t), this.isPrimary;
|
|
8289
8289
|
if (!this.allowTabSynchronization) throw t;
|
|
8290
|
-
return
|
|
8290
|
+
return M("IndexedDbPersistence", "Releasing owner lease after error during lease refresh", t),
|
|
8291
8291
|
/* isPrimary= */ !1;
|
|
8292
8292
|
})).then((t => {
|
|
8293
|
-
this.isPrimary !== t && this.
|
|
8293
|
+
this.isPrimary !== t && this.Me.enqueueRetryable((() => this.We(t))), this.isPrimary = t;
|
|
8294
8294
|
}));
|
|
8295
8295
|
}
|
|
8296
8296
|
rn(t) {
|
|
@@ -8326,7 +8326,7 @@ class or {
|
|
|
8326
8326
|
* Schedules a recurring timer to update the client metadata and to either
|
|
8327
8327
|
* extend or acquire the primary lease if the client is eligible.
|
|
8328
8328
|
*/ nn() {
|
|
8329
|
-
this.je = this.
|
|
8329
|
+
this.je = this.Me.enqueueAfterDelay("client_metadata_refresh" /* ClientMetadataRefresh */ , 4e3, (() => this.Ze().then((() => this.ln())).then((() => this.nn()))));
|
|
8330
8330
|
}
|
|
8331
8331
|
/** Checks whether `client` is the local client. */ un(t) {
|
|
8332
8332
|
return !!t && t.ownerId === this.clientId;
|
|
@@ -8375,7 +8375,7 @@ class or {
|
|
|
8375
8375
|
}
|
|
8376
8376
|
return !1;
|
|
8377
8377
|
}))));
|
|
8378
|
-
})).next((t => (this.isPrimary !== t &&
|
|
8378
|
+
})).next((t => (this.isPrimary !== t && M("IndexedDbPersistence", `Client ${t ? "is" : "is not"} eligible for a primary lease.`),
|
|
8379
8379
|
t)));
|
|
8380
8380
|
}
|
|
8381
8381
|
async shutdown() {
|
|
@@ -8427,15 +8427,15 @@ class or {
|
|
|
8427
8427
|
return this.Ye;
|
|
8428
8428
|
}
|
|
8429
8429
|
runTransaction(t, e, n) {
|
|
8430
|
-
|
|
8430
|
+
M("IndexedDbPersistence", "Starting transaction:", t);
|
|
8431
8431
|
const s = "readonly" === e ? "readonly" : "readwrite";
|
|
8432
8432
|
let i;
|
|
8433
8433
|
// Do all transactions as readwrite against all object stores, since we
|
|
8434
8434
|
// are the only reader/writer.
|
|
8435
8435
|
return this.ze.runTransaction(t, s, Gs, (s => (i = new oi(s, this.Be ? this.Be.next() : st.I),
|
|
8436
8436
|
"readwrite-primary" === e ? this.rn(i).next((t => !!t || this.on(i))).next((e => {
|
|
8437
|
-
if (!e) throw
|
|
8438
|
-
this.
|
|
8437
|
+
if (!e) throw F(`Failed to obtain primary lease for action '${t}'.`), this.isPrimary = !1,
|
|
8438
|
+
this.Me.enqueueRetryable((() => this.We(!1))), new W(Q.FAILED_PRECONDITION, zs);
|
|
8439
8439
|
return n(i);
|
|
8440
8440
|
})).next((t => this.cn(i).next((() => t)))) : this.En(i).next((() => n(i)))))).then((t => (i.raiseOnCommittedEvent(),
|
|
8441
8441
|
t)));
|
|
@@ -8458,22 +8458,22 @@ class or {
|
|
|
8458
8458
|
const e = new Ns(this.clientId, this.allowTabSynchronization, Date.now());
|
|
8459
8459
|
return ar(t).put(Ns.key, e);
|
|
8460
8460
|
}
|
|
8461
|
-
static
|
|
8462
|
-
return Xs.
|
|
8461
|
+
static Pt() {
|
|
8462
|
+
return Xs.Pt();
|
|
8463
8463
|
}
|
|
8464
8464
|
/** Checks the primary lease and removes it if we are the current primary. */ an(t) {
|
|
8465
8465
|
const e = ar(t);
|
|
8466
|
-
return e.get(Ns.key).next((t => this.un(t) ? (
|
|
8466
|
+
return e.get(Ns.key).next((t => this.un(t) ? (M("IndexedDbPersistence", "Releasing primary lease."),
|
|
8467
8467
|
e.delete(Ns.key)) : Js.resolve()));
|
|
8468
8468
|
}
|
|
8469
8469
|
/** Verifies that `updateTimeMs` is within `maxAgeMs`. */ fn(t, e) {
|
|
8470
8470
|
const n = Date.now();
|
|
8471
|
-
return !(t < n - e) && (!(t > n) || (
|
|
8471
|
+
return !(t < n - e) && (!(t > n) || (F(`Detected an update time that is in the future: ${t} > ${n}`),
|
|
8472
8472
|
!1));
|
|
8473
8473
|
}
|
|
8474
8474
|
tn() {
|
|
8475
8475
|
null !== this.document && "function" == typeof this.document.addEventListener && (this.Ke = () => {
|
|
8476
|
-
this.
|
|
8476
|
+
this.Me.enqueueAndForget((() => (this.inForeground = "visible" === this.document.visibilityState,
|
|
8477
8477
|
this.Ze())));
|
|
8478
8478
|
}, this.document.addEventListener("visibilitychange", this.Ke), this.inForeground = "visible" === this.document.visibilityState);
|
|
8479
8479
|
}
|
|
@@ -8500,7 +8500,7 @@ class or {
|
|
|
8500
8500
|
// trigger a bug that prevents Safari from re-opening IndexedDB during
|
|
8501
8501
|
// the next page load.
|
|
8502
8502
|
// See https://bugs.webkit.org/show_bug.cgi?id=226547
|
|
8503
|
-
this.
|
|
8503
|
+
this.Me.enterRestrictedMode(/* purgeExistingTasks= */ !0), this.Me.enqueueAndForget((() => this.shutdown()));
|
|
8504
8504
|
}, this.window.addEventListener("pagehide", this.qe));
|
|
8505
8505
|
}
|
|
8506
8506
|
yn() {
|
|
@@ -8514,11 +8514,11 @@ class or {
|
|
|
8514
8514
|
var e;
|
|
8515
8515
|
try {
|
|
8516
8516
|
const n = null !== (null === (e = this.Xe) || void 0 === e ? void 0 : e.getItem(this.wn(t)));
|
|
8517
|
-
return
|
|
8517
|
+
return M("IndexedDbPersistence", `Client '${t}' ${n ? "is" : "is not"} zombied in LocalStorage`),
|
|
8518
8518
|
n;
|
|
8519
8519
|
} catch (t) {
|
|
8520
8520
|
// Gracefully handle if LocalStorage isn't working.
|
|
8521
|
-
return
|
|
8521
|
+
return F("IndexedDbPersistence", "Failed to get zombied client id.", t), !1;
|
|
8522
8522
|
}
|
|
8523
8523
|
}
|
|
8524
8524
|
/**
|
|
@@ -8529,7 +8529,7 @@ class or {
|
|
|
8529
8529
|
this.Xe.setItem(this.wn(this.clientId), String(Date.now()));
|
|
8530
8530
|
} catch (t) {
|
|
8531
8531
|
// Gracefully handle if LocalStorage isn't available / working.
|
|
8532
|
-
|
|
8532
|
+
F("Failed to set zombie client id.", t);
|
|
8533
8533
|
}
|
|
8534
8534
|
}
|
|
8535
8535
|
/** Removes the zombied client entry if it exists. */ pn() {
|
|
@@ -8622,9 +8622,9 @@ class hr {
|
|
|
8622
8622
|
* @returns Local view of the document or null if we don't have any cached
|
|
8623
8623
|
* state for it.
|
|
8624
8624
|
*/ Rn(t, e) {
|
|
8625
|
-
return this.An.getAllMutationBatchesAffectingDocumentKey(t, e).next((n => this.
|
|
8625
|
+
return this.An.getAllMutationBatchesAffectingDocumentKey(t, e).next((n => this.bn(t, e, n)));
|
|
8626
8626
|
}
|
|
8627
|
-
/** Internal version of `getDocument` that allows reusing batches. */
|
|
8627
|
+
/** Internal version of `getDocument` that allows reusing batches. */ bn(t, e, n) {
|
|
8628
8628
|
return this.Je.getEntry(t, e).next((t => {
|
|
8629
8629
|
for (const e of n) e.applyToLocalView(t);
|
|
8630
8630
|
return t;
|
|
@@ -8632,7 +8632,7 @@ class hr {
|
|
|
8632
8632
|
}
|
|
8633
8633
|
// Returns the view of the given `docs` as they would appear after applying
|
|
8634
8634
|
// all mutations in the given `batches`.
|
|
8635
|
-
|
|
8635
|
+
Pn(t, e) {
|
|
8636
8636
|
t.forEach(((t, n) => {
|
|
8637
8637
|
for (const t of e) t.applyToLocalView(n);
|
|
8638
8638
|
}));
|
|
@@ -8649,7 +8649,7 @@ class hr {
|
|
|
8649
8649
|
* Applies the local view the given `baseDocs` without retrieving documents
|
|
8650
8650
|
* from the local store.
|
|
8651
8651
|
*/ Vn(t, e) {
|
|
8652
|
-
return this.An.getAllMutationBatchesAffectingDocumentKeys(t, e).next((t => this.
|
|
8652
|
+
return this.An.getAllMutationBatchesAffectingDocumentKeys(t, e).next((t => this.Pn(e, t)));
|
|
8653
8653
|
}
|
|
8654
8654
|
/**
|
|
8655
8655
|
* Performs a query against the local view of all documents.
|
|
@@ -8665,7 +8665,7 @@ class hr {
|
|
|
8665
8665
|
*/
|
|
8666
8666
|
return function(t) {
|
|
8667
8667
|
return Nt.isDocumentKey(t.path) && null === t.collectionGroup && 0 === t.filters.length;
|
|
8668
|
-
}(e) ? this.Sn(t, e.path) :
|
|
8668
|
+
}(e) ? this.Sn(t, e.path) : be(e) ? this.Dn(t, e, n) : this.Cn(t, e, n);
|
|
8669
8669
|
}
|
|
8670
8670
|
Sn(t, e) {
|
|
8671
8671
|
// Just do a simple document lookup.
|
|
@@ -8798,7 +8798,7 @@ class hr {
|
|
|
8798
8798
|
*/ class dr {
|
|
8799
8799
|
/** Sets the document view to query against. */
|
|
8800
8800
|
On(t) {
|
|
8801
|
-
this.
|
|
8801
|
+
this.Mn = t;
|
|
8802
8802
|
}
|
|
8803
8803
|
/** Returns all local documents matching the specified query. */ getDocumentsMatchingQuery(t, e, n, s) {
|
|
8804
8804
|
// Queries that match all documents don't benefit from using
|
|
@@ -8806,10 +8806,10 @@ class hr {
|
|
|
8806
8806
|
// collection, rather than to perform individual lookups.
|
|
8807
8807
|
return function(t) {
|
|
8808
8808
|
return 0 === t.filters.length && null === t.limit && null == t.startAt && null == t.endAt && (0 === t.explicitOrderBy.length || 1 === t.explicitOrderBy.length && t.explicitOrderBy[0].field.isKeyField());
|
|
8809
|
-
}(e) || n.isEqual(ht.min()) ? this.
|
|
8809
|
+
}(e) || n.isEqual(ht.min()) ? this.Fn(t, e) : this.Mn.vn(t, s).next((i => {
|
|
8810
8810
|
const r = this.Ln(e, i);
|
|
8811
|
-
return (Ee(e) || Ie(e)) && this.Bn(e.limitType, r, s, n) ? this.
|
|
8812
|
-
this.
|
|
8811
|
+
return (Ee(e) || Ie(e)) && this.Bn(e.limitType, r, s, n) ? this.Fn(t, e) : ($() <= a.DEBUG && M("QueryEngine", "Re-using previous result from %s to execute query: %s", n.toString(), Ce(e)),
|
|
8812
|
+
this.Mn.getDocumentsMatchingQuery(t, e, n).next((t => (
|
|
8813
8813
|
// We merge `previousResults` into `updateResults`, since
|
|
8814
8814
|
// `updateResults` is already a DocumentMap. If a document is
|
|
8815
8815
|
// contained in both lists, then its contents are the same.
|
|
@@ -8853,9 +8853,9 @@ class hr {
|
|
|
8853
8853
|
const i = "F" /* First */ === t ? e.last() : e.first();
|
|
8854
8854
|
return !!i && (i.hasPendingWrites || i.version.compareTo(s) > 0);
|
|
8855
8855
|
}
|
|
8856
|
-
|
|
8857
|
-
return $() <= a.DEBUG &&
|
|
8858
|
-
this.
|
|
8856
|
+
Fn(t, e) {
|
|
8857
|
+
return $() <= a.DEBUG && M("QueryEngine", "Using full collection scan to execute query:", Ce(e)),
|
|
8858
|
+
this.Mn.getDocumentsMatchingQuery(t, e, ht.min());
|
|
8859
8859
|
}
|
|
8860
8860
|
}
|
|
8861
8861
|
|
|
@@ -9076,7 +9076,7 @@ function yr(t) {
|
|
|
9076
9076
|
* Notifies local store of the changed views to locally pin documents.
|
|
9077
9077
|
*/ (c, u, r) && o.push(n.He.updateTargetData(t, u));
|
|
9078
9078
|
}));
|
|
9079
|
-
let a =
|
|
9079
|
+
let a = Pn();
|
|
9080
9080
|
// HACK: The only reason we allow a null snapshot version is so that we
|
|
9081
9081
|
// can synthesize remote events when we get permission denied errors while
|
|
9082
9082
|
// trying to resolve the state of a locally cached document that is in
|
|
@@ -9117,7 +9117,7 @@ function yr(t) {
|
|
|
9117
9117
|
i) {
|
|
9118
9118
|
let r = Nn();
|
|
9119
9119
|
return n.forEach((t => r = r.add(t))), e.getEntries(t, r).next((t => {
|
|
9120
|
-
let r =
|
|
9120
|
+
let r = Pn();
|
|
9121
9121
|
return n.forEach(((n, o) => {
|
|
9122
9122
|
const a = t.get(n), c = (null == i ? void 0 : i.get(n)) || s;
|
|
9123
9123
|
// Note: The order of the steps below is important, since we want
|
|
@@ -9129,7 +9129,7 @@ i) {
|
|
|
9129
9129
|
// events. We remove these documents from cache since we lost
|
|
9130
9130
|
// access.
|
|
9131
9131
|
e.removeEntry(n, c), r = r.insert(n, o)) : !a.isValidDocument() || o.version.compareTo(a.version) > 0 || 0 === o.version.compareTo(a.version) && a.hasPendingWrites ? (e.addEntry(o, c),
|
|
9132
|
-
r = r.insert(n, o)) :
|
|
9132
|
+
r = r.insert(n, o)) : M("LocalStore", "Ignoring outdated watch update for ", n, ". Current version:", a.version, " Watch version:", o.version);
|
|
9133
9133
|
})), r;
|
|
9134
9134
|
}));
|
|
9135
9135
|
}
|
|
@@ -9201,7 +9201,7 @@ async function Ar(t, e, n) {
|
|
|
9201
9201
|
// activity. If we lose this write this could cause a very slight
|
|
9202
9202
|
// difference in the order of target deletion during GC, but we
|
|
9203
9203
|
// don't define exact LRU semantics so this is acceptable.
|
|
9204
|
-
|
|
9204
|
+
M("LocalStore", `Failed to update sequence numbers for target ${e}: ${t}`);
|
|
9205
9205
|
}
|
|
9206
9206
|
s.qn = s.qn.remove(e), s.Kn.delete(i.target);
|
|
9207
9207
|
}
|
|
@@ -9230,7 +9230,7 @@ async function Ar(t, e, n) {
|
|
|
9230
9230
|
}
|
|
9231
9231
|
|
|
9232
9232
|
// PORTING NOTE: Multi-Tab only.
|
|
9233
|
-
function
|
|
9233
|
+
function br(t, e) {
|
|
9234
9234
|
const n = j(t), s = j(n.He), i = n.qn.get(e);
|
|
9235
9235
|
return i ? Promise.resolve(i.target) : n.persistence.runTransaction("Get target data", "readonly", (t => s.Et(t, e).next((t => t ? t.target : null))));
|
|
9236
9236
|
}
|
|
@@ -9242,14 +9242,14 @@ function Pr(t, e) {
|
|
|
9242
9242
|
* since the prior call.
|
|
9243
9243
|
*/
|
|
9244
9244
|
// PORTING NOTE: Multi-Tab only.
|
|
9245
|
-
function
|
|
9245
|
+
function Pr(t) {
|
|
9246
9246
|
const e = j(t);
|
|
9247
9247
|
return e.persistence.runTransaction("Get new document changes", "readonly", (t => function(t, e, n) {
|
|
9248
9248
|
const s = j(t);
|
|
9249
|
-
let i =
|
|
9249
|
+
let i = Pn(), r = wi(n);
|
|
9250
9250
|
const o = er(e), a = IDBKeyRange.lowerBound(r, !0);
|
|
9251
9251
|
return o.jt({
|
|
9252
|
-
index:
|
|
9252
|
+
index: Fs.readTimeIndex,
|
|
9253
9253
|
range: a
|
|
9254
9254
|
}, ((t, e) => {
|
|
9255
9255
|
// Unlike `getEntry()` and others, `getNewDocumentChanges()` parses
|
|
@@ -9282,7 +9282,7 @@ async function vr(t) {
|
|
|
9282
9282
|
// If there are no existing entries, we return SnapshotVersion.min().
|
|
9283
9283
|
let n = ht.min();
|
|
9284
9284
|
return e.jt({
|
|
9285
|
-
index:
|
|
9285
|
+
index: Fs.readTimeIndex,
|
|
9286
9286
|
reverse: !0
|
|
9287
9287
|
}, ((t, e, s) => {
|
|
9288
9288
|
e.readTime && (n = _i(e.readTime)), s.done();
|
|
@@ -9307,7 +9307,7 @@ async function vr(t) {
|
|
|
9307
9307
|
*/
|
|
9308
9308
|
async function Vr(t, e, n, s) {
|
|
9309
9309
|
const i = j(t);
|
|
9310
|
-
let r = Nn(), o =
|
|
9310
|
+
let r = Nn(), o = Pn(), a = Dn();
|
|
9311
9311
|
for (const t of n) {
|
|
9312
9312
|
const n = e.Hn(t.metadata.name);
|
|
9313
9313
|
t.document && (r = r.add(n)), o = o.insert(n, e.Jn(t)), a = a.insert(n, e.Yn(t.metadata.readTime));
|
|
@@ -9714,14 +9714,14 @@ class xr {
|
|
|
9714
9714
|
return Js.resolve(n ? n.document.mutableCopy() : Ht.newInvalidDocument(e));
|
|
9715
9715
|
}
|
|
9716
9716
|
getEntries(t, e) {
|
|
9717
|
-
let n =
|
|
9717
|
+
let n = Pn();
|
|
9718
9718
|
return e.forEach((t => {
|
|
9719
9719
|
const e = this.docs.get(t);
|
|
9720
9720
|
n = n.insert(t, e ? e.document.mutableCopy() : Ht.newInvalidDocument(t));
|
|
9721
9721
|
})), Js.resolve(n);
|
|
9722
9722
|
}
|
|
9723
9723
|
getDocumentsMatchingQuery(t, e, n) {
|
|
9724
|
-
let s =
|
|
9724
|
+
let s = Pn();
|
|
9725
9725
|
// Documents are ordered by key, so we can use a prefix scan to narrow down
|
|
9726
9726
|
// the documents we need to match the query against.
|
|
9727
9727
|
const i = new Nt(e.path.child("")), r = this.docs.getIteratorFrom(i);
|
|
@@ -9806,7 +9806,7 @@ class $r extends Yi {
|
|
|
9806
9806
|
* A ordered bidirectional mapping between documents and the remote target
|
|
9807
9807
|
* IDs.
|
|
9808
9808
|
*/
|
|
9809
|
-
this.Rs = new Cr, this.targetCount = 0, this.
|
|
9809
|
+
this.Rs = new Cr, this.targetCount = 0, this.bs = Fi.ie();
|
|
9810
9810
|
}
|
|
9811
9811
|
forEachTarget(t, e) {
|
|
9812
9812
|
return this.Is.forEach(((t, n) => e(n))), Js.resolve();
|
|
@@ -9818,7 +9818,7 @@ class $r extends Yi {
|
|
|
9818
9818
|
return Js.resolve(this.As);
|
|
9819
9819
|
}
|
|
9820
9820
|
allocateTargetId(t) {
|
|
9821
|
-
return this.highestTargetId = this.
|
|
9821
|
+
return this.highestTargetId = this.bs.next(), Js.resolve(this.highestTargetId);
|
|
9822
9822
|
}
|
|
9823
9823
|
setTargetsMetadata(t, e, n) {
|
|
9824
9824
|
return n && (this.lastRemoteSnapshotVersion = n), e > this.As && (this.As = e),
|
|
@@ -9827,7 +9827,7 @@ class $r extends Yi {
|
|
|
9827
9827
|
ce(t) {
|
|
9828
9828
|
this.Is.set(t.target, t);
|
|
9829
9829
|
const e = t.targetId;
|
|
9830
|
-
e > this.highestTargetId && (this.
|
|
9830
|
+
e > this.highestTargetId && (this.bs = new Fi(e), this.highestTargetId = e), t.sequenceNumber > this.As && (this.As = t.sequenceNumber);
|
|
9831
9831
|
}
|
|
9832
9832
|
addTargetData(t, e) {
|
|
9833
9833
|
return this.ce(e), this.targetCount += 1, Js.resolve();
|
|
@@ -9896,7 +9896,7 @@ class $r extends Yi {
|
|
|
9896
9896
|
* A memory-backed instance of Persistence. Data is stored only in RAM and
|
|
9897
9897
|
* not persisted across sessions.
|
|
9898
9898
|
*/
|
|
9899
|
-
class
|
|
9899
|
+
class Mr {
|
|
9900
9900
|
/**
|
|
9901
9901
|
* The constructor accepts a factory for creating a reference delegate. This
|
|
9902
9902
|
* allows both the delegate and this instance to have strong references to
|
|
@@ -9904,9 +9904,9 @@ class Fr {
|
|
|
9904
9904
|
* checked or asserted on every access.
|
|
9905
9905
|
*/
|
|
9906
9906
|
constructor(t, e) {
|
|
9907
|
-
this.
|
|
9907
|
+
this.Ps = {}, this.Be = new st(0), this.Ue = !1, this.Ue = !0, this.referenceDelegate = t(this),
|
|
9908
9908
|
this.He = new Or(this);
|
|
9909
|
-
this.Jt = new
|
|
9909
|
+
this.Jt = new bi, this.Je = function(t, e) {
|
|
9910
9910
|
return new xr(t, e);
|
|
9911
9911
|
}(this.Jt, (t => this.referenceDelegate.vs(t))), this.k = new li(e), this.Ye = new Dr(this.k);
|
|
9912
9912
|
}
|
|
@@ -9930,8 +9930,8 @@ class Fr {
|
|
|
9930
9930
|
return this.Jt;
|
|
9931
9931
|
}
|
|
9932
9932
|
getMutationQueue(t) {
|
|
9933
|
-
let e = this.
|
|
9934
|
-
return e || (e = new kr(this.Jt, this.referenceDelegate), this.
|
|
9933
|
+
let e = this.Ps[t.toKey()];
|
|
9934
|
+
return e || (e = new kr(this.Jt, this.referenceDelegate), this.Ps[t.toKey()] = e),
|
|
9935
9935
|
e;
|
|
9936
9936
|
}
|
|
9937
9937
|
getTargetCache() {
|
|
@@ -9944,20 +9944,20 @@ class Fr {
|
|
|
9944
9944
|
return this.Ye;
|
|
9945
9945
|
}
|
|
9946
9946
|
runTransaction(t, e, n) {
|
|
9947
|
-
|
|
9948
|
-
const s = new
|
|
9947
|
+
M("MemoryPersistence", "Starting transaction:", t);
|
|
9948
|
+
const s = new Fr(this.Be.next());
|
|
9949
9949
|
return this.referenceDelegate.Vs(), n(s).next((t => this.referenceDelegate.Ss(s).next((() => t)))).toPromise().then((t => (s.raiseOnCommittedEvent(),
|
|
9950
9950
|
t)));
|
|
9951
9951
|
}
|
|
9952
9952
|
Ds(t, e) {
|
|
9953
|
-
return Js.or(Object.values(this.
|
|
9953
|
+
return Js.or(Object.values(this.Ps).map((n => () => n.containsKey(t, e))));
|
|
9954
9954
|
}
|
|
9955
9955
|
}
|
|
9956
9956
|
|
|
9957
9957
|
/**
|
|
9958
9958
|
* Memory persistence is not actually transactional, but future implementations
|
|
9959
9959
|
* may have transaction-scoped state.
|
|
9960
|
-
*/ class
|
|
9960
|
+
*/ class Fr extends Hs {
|
|
9961
9961
|
constructor(t) {
|
|
9962
9962
|
super(), this.currentSequenceNumber = t;
|
|
9963
9963
|
}
|
|
@@ -10083,10 +10083,10 @@ class Kr {
|
|
|
10083
10083
|
const s = JSON.parse(n);
|
|
10084
10084
|
let i, r = "object" == typeof s && -1 !== [ "pending", "acknowledged", "rejected" ].indexOf(s.state) && (void 0 === s.error || "object" == typeof s.error);
|
|
10085
10085
|
return r && s.error && (r = "string" == typeof s.error.message && "string" == typeof s.error.code,
|
|
10086
|
-
r && (i = new W(s.error.code, s.error.message))), r ? new Kr(t, e, s.state, i) : (
|
|
10086
|
+
r && (i = new W(s.error.code, s.error.message))), r ? new Kr(t, e, s.state, i) : (F("SharedClientState", `Failed to parse mutation state for ID '${e}': ${n}`),
|
|
10087
10087
|
null);
|
|
10088
10088
|
}
|
|
10089
|
-
|
|
10089
|
+
Ms() {
|
|
10090
10090
|
const t = {
|
|
10091
10091
|
state: this.state,
|
|
10092
10092
|
updateTimeMs: Date.now()
|
|
@@ -10114,10 +10114,10 @@ class jr {
|
|
|
10114
10114
|
const n = JSON.parse(e);
|
|
10115
10115
|
let s, i = "object" == typeof n && -1 !== [ "not-current", "current", "rejected" ].indexOf(n.state) && (void 0 === n.error || "object" == typeof n.error);
|
|
10116
10116
|
return i && n.error && (i = "string" == typeof n.error.message && "string" == typeof n.error.code,
|
|
10117
|
-
i && (s = new W(n.error.code, n.error.message))), i ? new jr(t, n.state, s) : (
|
|
10117
|
+
i && (s = new W(n.error.code, n.error.message))), i ? new jr(t, n.state, s) : (F("SharedClientState", `Failed to parse target state for ID '${t}': ${e}`),
|
|
10118
10118
|
null);
|
|
10119
10119
|
}
|
|
10120
|
-
|
|
10120
|
+
Ms() {
|
|
10121
10121
|
const t = {
|
|
10122
10122
|
state: this.state,
|
|
10123
10123
|
updateTimeMs: Date.now()
|
|
@@ -10144,7 +10144,7 @@ class jr {
|
|
|
10144
10144
|
let s = "object" == typeof n && n.activeTargetIds instanceof Array, i = xn();
|
|
10145
10145
|
for (let t = 0; s && t < n.activeTargetIds.length; ++t) s = Ct(n.activeTargetIds[t]),
|
|
10146
10146
|
i = i.add(n.activeTargetIds[t]);
|
|
10147
|
-
return s ? new Qr(t, i) : (
|
|
10147
|
+
return s ? new Qr(t, i) : (F("SharedClientState", `Failed to parse client data for instance '${t}': ${e}`),
|
|
10148
10148
|
null);
|
|
10149
10149
|
}
|
|
10150
10150
|
}
|
|
@@ -10162,7 +10162,7 @@ class jr {
|
|
|
10162
10162
|
* Logs a warning and returns null if the format of the data is not valid.
|
|
10163
10163
|
*/ static Os(t) {
|
|
10164
10164
|
const e = JSON.parse(t);
|
|
10165
|
-
return "object" == typeof e && -1 !== [ "Unknown", "Online", "Offline" ].indexOf(e.onlineState) && "string" == typeof e.clientId ? new Wr(e.clientId, e.onlineState) : (
|
|
10165
|
+
return "object" == typeof e && -1 !== [ "Unknown", "Online", "Offline" ].indexOf(e.onlineState) && "string" == typeof e.clientId ? new Wr(e.clientId, e.onlineState) : (F("SharedClientState", `Failed to parse online state: ${t}`),
|
|
10166
10166
|
null);
|
|
10167
10167
|
}
|
|
10168
10168
|
}
|
|
@@ -10182,7 +10182,7 @@ class Gr {
|
|
|
10182
10182
|
constructor() {
|
|
10183
10183
|
this.activeTargetIds = xn();
|
|
10184
10184
|
}
|
|
10185
|
-
|
|
10185
|
+
Fs(t) {
|
|
10186
10186
|
this.activeTargetIds = this.activeTargetIds.add(t);
|
|
10187
10187
|
}
|
|
10188
10188
|
Ls(t) {
|
|
@@ -10191,7 +10191,7 @@ class Gr {
|
|
|
10191
10191
|
/**
|
|
10192
10192
|
* Converts this entry into a JSON-encoded format we can use for WebStorage.
|
|
10193
10193
|
* Does not encode `clientId` as it is part of the key in WebStorage.
|
|
10194
|
-
*/
|
|
10194
|
+
*/ Ms() {
|
|
10195
10195
|
const t = {
|
|
10196
10196
|
activeTargetIds: this.activeTargetIds.toArray(),
|
|
10197
10197
|
updateTimeMs: Date.now()
|
|
@@ -10206,7 +10206,7 @@ class Gr {
|
|
|
10206
10206
|
* clients and supports modifications of the local client's data.
|
|
10207
10207
|
*/ class zr {
|
|
10208
10208
|
constructor(t, e, n, s, i) {
|
|
10209
|
-
this.window = t, this.
|
|
10209
|
+
this.window = t, this.Me = e, this.persistenceKey = n, this.Bs = s, this.syncEngine = null,
|
|
10210
10210
|
this.onlineStateHandler = null, this.sequenceNumberHandler = null, this.Us = this.qs.bind(this),
|
|
10211
10211
|
this.Ks = new Tn(ot), this.started = !1,
|
|
10212
10212
|
/**
|
|
@@ -10263,7 +10263,7 @@ class Gr {
|
|
|
10263
10263
|
// mutations but before we observe WebStorage events.
|
|
10264
10264
|
this.window.addEventListener("storage", this.Us);
|
|
10265
10265
|
}
|
|
10266
|
-
/** Returns 'true' if WebStorage is available in the current environment. */ static
|
|
10266
|
+
/** Returns 'true' if WebStorage is available in the current environment. */ static Pt(t) {
|
|
10267
10267
|
return !(!t || !t.localStorage);
|
|
10268
10268
|
}
|
|
10269
10269
|
async start() {
|
|
@@ -10325,7 +10325,7 @@ class Gr {
|
|
|
10325
10325
|
s && (e = s.state);
|
|
10326
10326
|
}
|
|
10327
10327
|
}
|
|
10328
|
-
return this.ii.
|
|
10328
|
+
return this.ii.Fs(t), this.Xs(), e;
|
|
10329
10329
|
}
|
|
10330
10330
|
removeLocalQueryTarget(t) {
|
|
10331
10331
|
this.ii.Ls(t), this.Xs();
|
|
@@ -10358,21 +10358,21 @@ class Gr {
|
|
|
10358
10358
|
}
|
|
10359
10359
|
getItem(t) {
|
|
10360
10360
|
const e = this.storage.getItem(t);
|
|
10361
|
-
return
|
|
10361
|
+
return M("SharedClientState", "READ", t, e), e;
|
|
10362
10362
|
}
|
|
10363
10363
|
setItem(t, e) {
|
|
10364
|
-
|
|
10364
|
+
M("SharedClientState", "SET", t, e), this.storage.setItem(t, e);
|
|
10365
10365
|
}
|
|
10366
10366
|
removeItem(t) {
|
|
10367
|
-
|
|
10367
|
+
M("SharedClientState", "REMOVE", t), this.storage.removeItem(t);
|
|
10368
10368
|
}
|
|
10369
10369
|
qs(t) {
|
|
10370
10370
|
// Note: The function is typed to take Event to be interface-compatible with
|
|
10371
10371
|
// `Window.addEventListener`.
|
|
10372
10372
|
const e = t;
|
|
10373
10373
|
if (e.storageArea === this.storage) {
|
|
10374
|
-
if (
|
|
10375
|
-
this.
|
|
10374
|
+
if (M("SharedClientState", "EVENT", e.key, e.newValue), e.key === this.Qs) return void F("Received WebStorage notification for local change. Another client might have garbage-collected our state");
|
|
10375
|
+
this.Me.enqueueRetryable((async () => {
|
|
10376
10376
|
if (this.started) {
|
|
10377
10377
|
if (null !== e.key) if (this.Gs.test(e.key)) {
|
|
10378
10378
|
if (null == e.newValue) {
|
|
@@ -10405,7 +10405,7 @@ class Gr {
|
|
|
10405
10405
|
const n = JSON.parse(t);
|
|
10406
10406
|
q("number" == typeof n), e = n;
|
|
10407
10407
|
} catch (t) {
|
|
10408
|
-
|
|
10408
|
+
F("SharedClientState", "Failed to read sequence number from WebStorage", t);
|
|
10409
10409
|
}
|
|
10410
10410
|
return e;
|
|
10411
10411
|
}
|
|
@@ -10424,11 +10424,11 @@ class Gr {
|
|
|
10424
10424
|
return this.Ks.get(this.Bs);
|
|
10425
10425
|
}
|
|
10426
10426
|
Xs() {
|
|
10427
|
-
this.setItem(this.Qs, this.ii.
|
|
10427
|
+
this.setItem(this.Qs, this.ii.Ms());
|
|
10428
10428
|
}
|
|
10429
10429
|
ni(t, e, n) {
|
|
10430
10430
|
const s = new Kr(this.currentUser, t, e, n), i = Ur(this.persistenceKey, this.currentUser, t);
|
|
10431
|
-
this.setItem(i, s.
|
|
10431
|
+
this.setItem(i, s.Ms());
|
|
10432
10432
|
}
|
|
10433
10433
|
si(t) {
|
|
10434
10434
|
const e = Ur(this.persistenceKey, this.currentUser, t);
|
|
@@ -10443,7 +10443,7 @@ class Gr {
|
|
|
10443
10443
|
}
|
|
10444
10444
|
ri(t, e, n) {
|
|
10445
10445
|
const s = qr(this.persistenceKey, t), i = new jr(t, e, n);
|
|
10446
|
-
this.setItem(s, i.
|
|
10446
|
+
this.setItem(s, i.Ms());
|
|
10447
10447
|
}
|
|
10448
10448
|
ai() {
|
|
10449
10449
|
this.setItem(this.Ys, "value-not-used");
|
|
@@ -10484,7 +10484,7 @@ class Gr {
|
|
|
10484
10484
|
}
|
|
10485
10485
|
async fi(t) {
|
|
10486
10486
|
if (t.user.uid === this.currentUser.uid) return this.syncEngine.mi(t.batchId, t.state, t.error);
|
|
10487
|
-
|
|
10487
|
+
M("SharedClientState", `Ignoring mutation for non-active user ${t.user.uid}`);
|
|
10488
10488
|
}
|
|
10489
10489
|
wi(t) {
|
|
10490
10490
|
return this.syncEngine.gi(t.targetId, t.state, t.error);
|
|
@@ -10526,7 +10526,7 @@ class Hr {
|
|
|
10526
10526
|
// No op.
|
|
10527
10527
|
}
|
|
10528
10528
|
addLocalQueryTarget(t) {
|
|
10529
|
-
return this.pi.
|
|
10529
|
+
return this.pi.Fs(t), this.Ti[t] || "not-current";
|
|
10530
10530
|
}
|
|
10531
10531
|
updateQueryState(t, e, n) {
|
|
10532
10532
|
this.Ti[t] = e;
|
|
@@ -10609,10 +10609,10 @@ class Hr {
|
|
|
10609
10609
|
*/
|
|
10610
10610
|
class Yr {
|
|
10611
10611
|
constructor() {
|
|
10612
|
-
this.Ii = () => this.Ai(), this.Ri = () => this.
|
|
10612
|
+
this.Ii = () => this.Ai(), this.Ri = () => this.bi(), this.Pi = [], this.vi();
|
|
10613
10613
|
}
|
|
10614
10614
|
Ei(t) {
|
|
10615
|
-
this.
|
|
10615
|
+
this.Pi.push(t);
|
|
10616
10616
|
}
|
|
10617
10617
|
shutdown() {
|
|
10618
10618
|
window.removeEventListener("online", this.Ii), window.removeEventListener("offline", this.Ri);
|
|
@@ -10621,17 +10621,17 @@ class Yr {
|
|
|
10621
10621
|
window.addEventListener("online", this.Ii), window.addEventListener("offline", this.Ri);
|
|
10622
10622
|
}
|
|
10623
10623
|
Ai() {
|
|
10624
|
-
|
|
10625
|
-
for (const t of this.
|
|
10624
|
+
M("ConnectivityMonitor", "Network connectivity changed: AVAILABLE");
|
|
10625
|
+
for (const t of this.Pi) t(0 /* AVAILABLE */);
|
|
10626
10626
|
}
|
|
10627
|
-
|
|
10628
|
-
|
|
10629
|
-
for (const t of this.
|
|
10627
|
+
bi() {
|
|
10628
|
+
M("ConnectivityMonitor", "Network connectivity changed: UNAVAILABLE");
|
|
10629
|
+
for (const t of this.Pi) t(1 /* UNAVAILABLE */);
|
|
10630
10630
|
}
|
|
10631
10631
|
// TODO(chenbrian): Consider passing in window either into this component or
|
|
10632
10632
|
// here for testing via FakeWindow.
|
|
10633
10633
|
/** Checks that all used attributes of window are available. */
|
|
10634
|
-
static
|
|
10634
|
+
static Pt() {
|
|
10635
10635
|
return "undefined" != typeof window && void 0 !== window.addEventListener && void 0 !== window.removeEventListener;
|
|
10636
10636
|
}
|
|
10637
10637
|
}
|
|
@@ -10708,7 +10708,7 @@ class Zr {
|
|
|
10708
10708
|
Oi(t) {
|
|
10709
10709
|
this.ki(t);
|
|
10710
10710
|
}
|
|
10711
|
-
|
|
10711
|
+
Mi(t) {
|
|
10712
10712
|
this.xi(t);
|
|
10713
10713
|
}
|
|
10714
10714
|
}
|
|
@@ -10737,13 +10737,13 @@ class {
|
|
|
10737
10737
|
constructor(t) {
|
|
10738
10738
|
this.databaseInfo = t, this.databaseId = t.databaseId;
|
|
10739
10739
|
const e = t.ssl ? "https" : "http";
|
|
10740
|
-
this.
|
|
10740
|
+
this.Fi = e + "://" + t.host, this.Li = "projects/" + this.databaseId.projectId + "/databases/" + this.databaseId.database + "/documents";
|
|
10741
10741
|
}
|
|
10742
10742
|
Bi(t, e, n, s, i) {
|
|
10743
10743
|
const r = this.Ui(t, e);
|
|
10744
|
-
|
|
10744
|
+
M("RestConnection", "Sending: ", r, n);
|
|
10745
10745
|
const o = {};
|
|
10746
|
-
return this.qi(o, s, i), this.Ki(t, r, o, n).then((t => (
|
|
10746
|
+
return this.qi(o, s, i), this.Ki(t, r, o, n).then((t => (M("RestConnection", "Received: ", t),
|
|
10747
10747
|
t)), (e => {
|
|
10748
10748
|
throw L("RestConnection", `${t} failed with error: `, e, "url: ", r, "request:", n),
|
|
10749
10749
|
e;
|
|
@@ -10768,7 +10768,7 @@ class {
|
|
|
10768
10768
|
}
|
|
10769
10769
|
Ui(t, e) {
|
|
10770
10770
|
const n = Xr[t];
|
|
10771
|
-
return `${this.
|
|
10771
|
+
return `${this.Fi}/v1/${e}:${n}`;
|
|
10772
10772
|
}
|
|
10773
10773
|
} {
|
|
10774
10774
|
constructor(t) {
|
|
@@ -10783,16 +10783,16 @@ class {
|
|
|
10783
10783
|
switch (o.getLastErrorCode()) {
|
|
10784
10784
|
case R.NO_ERROR:
|
|
10785
10785
|
const e = o.getResponseJson();
|
|
10786
|
-
|
|
10786
|
+
M("Connection", "XHR received:", JSON.stringify(e)), i(e);
|
|
10787
10787
|
break;
|
|
10788
10788
|
|
|
10789
10789
|
case R.TIMEOUT:
|
|
10790
|
-
|
|
10790
|
+
M("Connection", 'RPC "' + t + '" timed out'), r(new W(Q.DEADLINE_EXCEEDED, "Request time out"));
|
|
10791
10791
|
break;
|
|
10792
10792
|
|
|
10793
10793
|
case R.HTTP_ERROR:
|
|
10794
10794
|
const n = o.getStatus();
|
|
10795
|
-
if (
|
|
10795
|
+
if (M("Connection", 'RPC "' + t + '" failed with status:', n, "response text:", o.getResponseText()),
|
|
10796
10796
|
n > 0) {
|
|
10797
10797
|
const t = o.getResponseJson().error;
|
|
10798
10798
|
if (t && t.status && t.message) {
|
|
@@ -10812,7 +10812,7 @@ class {
|
|
|
10812
10812
|
U();
|
|
10813
10813
|
}
|
|
10814
10814
|
} finally {
|
|
10815
|
-
|
|
10815
|
+
M("Connection", 'RPC "' + t + '" completed.');
|
|
10816
10816
|
}
|
|
10817
10817
|
}));
|
|
10818
10818
|
const a = JSON.stringify(s);
|
|
@@ -10820,7 +10820,7 @@ class {
|
|
|
10820
10820
|
}));
|
|
10821
10821
|
}
|
|
10822
10822
|
Qi(t, e, n) {
|
|
10823
|
-
const s = [ this.
|
|
10823
|
+
const s = [ this.Fi, "/", "google.firestore.v1.Firestore", "/", t, "/channel" ], i = b(), r = P(), o = {
|
|
10824
10824
|
// Required for backend stickiness, routing behavior is based on this
|
|
10825
10825
|
// parameter.
|
|
10826
10826
|
httpSessionIdParam: "gsessionid",
|
|
@@ -10862,7 +10862,7 @@ class {
|
|
|
10862
10862
|
// https://github.com/firebase/firebase-js-sdk/issues/1491.
|
|
10863
10863
|
d() || w() || _() || m() || g() || y() || (o.httpHeadersOverwriteParam = "$httpHeaders");
|
|
10864
10864
|
const a = s.join("");
|
|
10865
|
-
|
|
10865
|
+
M("Connection", "Creating WebChannel: " + a, o);
|
|
10866
10866
|
const c = i.createWebChannel(a, o);
|
|
10867
10867
|
// WebChannel supports sending the first message with the handshake - saving
|
|
10868
10868
|
// a network round trip. However, it will have to call send in the same
|
|
@@ -10875,8 +10875,8 @@ class {
|
|
|
10875
10875
|
// on a closed stream
|
|
10876
10876
|
const l = new Zr({
|
|
10877
10877
|
Vi: t => {
|
|
10878
|
-
h ?
|
|
10879
|
-
c.open(), u = !0),
|
|
10878
|
+
h ? M("Connection", "Not sending because WebChannel is closed:", t) : (u || (M("Connection", "Opening WebChannel transport."),
|
|
10879
|
+
c.open(), u = !0), M("Connection", "WebChannel sending:", t), c.send(t));
|
|
10880
10880
|
},
|
|
10881
10881
|
Si: () => c.close()
|
|
10882
10882
|
}), f = (t, e, n) => {
|
|
@@ -10897,9 +10897,9 @@ class {
|
|
|
10897
10897
|
// Note that eventually this function could go away if we are confident
|
|
10898
10898
|
// enough the code is exception free.
|
|
10899
10899
|
return f(c, V.EventType.OPEN, (() => {
|
|
10900
|
-
h ||
|
|
10900
|
+
h || M("Connection", "WebChannel transport opened.");
|
|
10901
10901
|
})), f(c, V.EventType.CLOSE, (() => {
|
|
10902
|
-
h || (h = !0,
|
|
10902
|
+
h || (h = !0, M("Connection", "WebChannel transport closed"), l.Oi());
|
|
10903
10903
|
})), f(c, V.EventType.ERROR, (t => {
|
|
10904
10904
|
h || (h = !0, L("Connection", "WebChannel transport errored:", t), l.Oi(new W(Q.UNAVAILABLE, "The operation could not be completed")));
|
|
10905
10905
|
})), f(c, V.EventType.MESSAGE, (t => {
|
|
@@ -10914,7 +10914,7 @@ class {
|
|
|
10914
10914
|
// Use any because msgData.error is not typed.
|
|
10915
10915
|
const s = n, i = s.error || (null === (e = s[0]) || void 0 === e ? void 0 : e.error);
|
|
10916
10916
|
if (i) {
|
|
10917
|
-
|
|
10917
|
+
M("Connection", "WebChannel received error:", i);
|
|
10918
10918
|
// error.status will be a string like 'OK' or 'NOT_FOUND'.
|
|
10919
10919
|
const t = i.status;
|
|
10920
10920
|
let e =
|
|
@@ -10933,10 +10933,10 @@ class {
|
|
|
10933
10933
|
void 0 === e && (e = Q.INTERNAL, n = "Unknown error status: " + t + " with message " + i.message),
|
|
10934
10934
|
// Mark closed so no further events are propagated
|
|
10935
10935
|
h = !0, l.Oi(new W(e, n)), c.close();
|
|
10936
|
-
} else
|
|
10936
|
+
} else M("Connection", "WebChannel received:", n), l.Mi(n);
|
|
10937
10937
|
}
|
|
10938
10938
|
})), f(r, S.STAT_EVENT, (t => {
|
|
10939
|
-
t.stat === D.PROXY ?
|
|
10939
|
+
t.stat === D.PROXY ? M("Connection", "Detected buffering proxy") : t.stat === D.NOPROXY && M("Connection", "Detected no buffering proxy");
|
|
10940
10940
|
})), setTimeout((() => {
|
|
10941
10941
|
// Technically we could/should wait for the WebChannel opened event,
|
|
10942
10942
|
// but because we want to send the first message with the WebChannel
|
|
@@ -11049,7 +11049,7 @@ class io {
|
|
|
11049
11049
|
* Note that jitter will still be applied, so the actual delay could be as
|
|
11050
11050
|
* much as 1.5*maxDelayMs.
|
|
11051
11051
|
*/ , i = 6e4) {
|
|
11052
|
-
this.
|
|
11052
|
+
this.Me = t, this.timerId = e, this.Wi = n, this.Gi = s, this.zi = i, this.Hi = 0,
|
|
11053
11053
|
this.Ji = null,
|
|
11054
11054
|
/** The last backoff attempt, as epoch milliseconds. */
|
|
11055
11055
|
this.Yi = Date.now(), this.reset();
|
|
@@ -11080,8 +11080,8 @@ class io {
|
|
|
11080
11080
|
// honored as such).
|
|
11081
11081
|
const e = Math.floor(this.Hi + this.tr()), n = Math.max(0, Date.now() - this.Yi), s = Math.max(0, e - n);
|
|
11082
11082
|
// Guard against lastAttemptTime being in the future due to a clock change.
|
|
11083
|
-
s > 0 &&
|
|
11084
|
-
this.Ji = this.
|
|
11083
|
+
s > 0 && M("ExponentialBackoff", `Backing off for ${s} ms (base delay: ${this.Hi} ms, delay with jitter: ${e} ms, last attempt: ${n} ms ago)`),
|
|
11084
|
+
this.Ji = this.Me.enqueueAfterDelay(this.timerId, s, (() => (this.Yi = Date.now(),
|
|
11085
11085
|
t()))),
|
|
11086
11086
|
// Apply backoff factor to determine next delay and ensure it is within
|
|
11087
11087
|
// bounds.
|
|
@@ -11148,7 +11148,7 @@ class io {
|
|
|
11148
11148
|
*/
|
|
11149
11149
|
class ro {
|
|
11150
11150
|
constructor(t, e, n, s, i, r, o, a) {
|
|
11151
|
-
this.
|
|
11151
|
+
this.Me = t, this.nr = n, this.sr = s, this.ir = i, this.authCredentialsProvider = r,
|
|
11152
11152
|
this.appCheckCredentialsProvider = o, this.listener = a, this.state = 0 /* Initial */ ,
|
|
11153
11153
|
/**
|
|
11154
11154
|
* A close count that's incremented every time the stream is closed; used by
|
|
@@ -11211,7 +11211,7 @@ class ro {
|
|
|
11211
11211
|
*/ _r() {
|
|
11212
11212
|
// Starts the idle time if we are in state 'Open' and are not yet already
|
|
11213
11213
|
// running a timer (in which case the previous idle timeout still applies).
|
|
11214
|
-
this.lr() && null === this.ar && (this.ar = this.
|
|
11214
|
+
this.lr() && null === this.ar && (this.ar = this.Me.enqueueAfterDelay(this.nr, 6e4, (() => this.mr())));
|
|
11215
11215
|
}
|
|
11216
11216
|
/** Sends a message to the underlying stream. */ gr(t) {
|
|
11217
11217
|
this.yr(), this.stream.send(t);
|
|
@@ -11249,7 +11249,7 @@ class ro {
|
|
|
11249
11249
|
// If this is an intentional close ensure we don't delay our next connection attempt.
|
|
11250
11250
|
this.ur.reset() : e && e.code === Q.RESOURCE_EXHAUSTED ? (
|
|
11251
11251
|
// Log the error. (Probably either 'quota exceeded' or 'max queue length reached'.)
|
|
11252
|
-
|
|
11252
|
+
F(e.toString()), F("Using maximum backoff delay to prevent overloading the backend."),
|
|
11253
11253
|
this.ur.Xi()) : e && e.code === Q.UNAUTHENTICATED && 3 /* Healthy */ !== this.state && (
|
|
11254
11254
|
// "unauthenticated" error means the token was rejected. This should rarely
|
|
11255
11255
|
// happen since both Auth and AppCheck ensure a sufficient TTL when we
|
|
@@ -11294,7 +11294,7 @@ class ro {
|
|
|
11294
11294
|
Ir(t, e) {
|
|
11295
11295
|
const n = this.Er(this.rr);
|
|
11296
11296
|
this.stream = this.Rr(t, e), this.stream.Di((() => {
|
|
11297
|
-
n((() => (this.state = 2 /* Open */ , this.cr = this.
|
|
11297
|
+
n((() => (this.state = 2 /* Open */ , this.cr = this.Me.enqueueAfterDelay(this.sr, 1e4, (() => (this.lr() && (this.state = 3 /* Healthy */),
|
|
11298
11298
|
Promise.resolve()))), this.listener.Di())));
|
|
11299
11299
|
})), this.stream.Ni((t => {
|
|
11300
11300
|
n((() => this.Ar(t)));
|
|
@@ -11313,7 +11313,7 @@ class ro {
|
|
|
11313
11313
|
// we never expect this to happen because if we stop a stream ourselves,
|
|
11314
11314
|
// this callback will never be called. To prevent cases where we retry
|
|
11315
11315
|
// without a backoff accidentally, we set the stream to error in all cases.
|
|
11316
|
-
return
|
|
11316
|
+
return M("PersistentStream", `close with error: ${t}`), this.stream = null, this.close(4 /* Error */ , t);
|
|
11317
11317
|
}
|
|
11318
11318
|
/**
|
|
11319
11319
|
* Returns a "dispatcher" function that dispatches operations onto the
|
|
@@ -11322,7 +11322,7 @@ class ro {
|
|
|
11322
11322
|
* re-opened, etc.
|
|
11323
11323
|
*/ Er(t) {
|
|
11324
11324
|
return e => {
|
|
11325
|
-
this.
|
|
11325
|
+
this.Me.enqueueAndForget((() => this.rr === t ? e() : (M("PersistentStream", "stream callback skipped by getCloseGuardedDispatcher."),
|
|
11326
11326
|
Promise.resolve())));
|
|
11327
11327
|
};
|
|
11328
11328
|
}
|
|
@@ -11353,14 +11353,14 @@ class ro {
|
|
|
11353
11353
|
const e = t.targetChange;
|
|
11354
11354
|
return e.targetIds && e.targetIds.length ? ht.min() : e.readTime ? Jn(e.readTime) : ht.min();
|
|
11355
11355
|
}(t);
|
|
11356
|
-
return this.listener.
|
|
11356
|
+
return this.listener.br(e, n);
|
|
11357
11357
|
}
|
|
11358
11358
|
/**
|
|
11359
11359
|
* Registers interest in the results of the given target. If the target
|
|
11360
11360
|
* includes a resumeToken it will be included in the request. Results that
|
|
11361
11361
|
* affect the target will be streamed back as WatchChange messages that
|
|
11362
11362
|
* reference the targetId.
|
|
11363
|
-
*/
|
|
11363
|
+
*/ Pr(t) {
|
|
11364
11364
|
const e = {};
|
|
11365
11365
|
e.database = ss(this.k), e.addTarget = function(t, e) {
|
|
11366
11366
|
let n;
|
|
@@ -11530,13 +11530,13 @@ class uo {
|
|
|
11530
11530
|
* maximum defined by MAX_WATCH_STREAM_FAILURES, we'll set the OnlineState to
|
|
11531
11531
|
* Offline.
|
|
11532
11532
|
*/
|
|
11533
|
-
this.
|
|
11533
|
+
this.Mr = 0,
|
|
11534
11534
|
/**
|
|
11535
11535
|
* A timer that elapses after ONLINE_STATE_TIMEOUT_MS, at which point we
|
|
11536
11536
|
* transition from OnlineState.Unknown to OnlineState.Offline without waiting
|
|
11537
11537
|
* for the stream to actually fail (MAX_WATCH_STREAM_FAILURES times).
|
|
11538
11538
|
*/
|
|
11539
|
-
this.
|
|
11539
|
+
this.Fr = null,
|
|
11540
11540
|
/**
|
|
11541
11541
|
* Whether the client should log a warning message if it fails to connect to
|
|
11542
11542
|
* the backend (initially true, cleared after a successful stream, or if we've
|
|
@@ -11551,7 +11551,7 @@ class uo {
|
|
|
11551
11551
|
* If this is the first attempt, it sets the OnlineState to Unknown and starts
|
|
11552
11552
|
* the onlineStateTimer.
|
|
11553
11553
|
*/ Br() {
|
|
11554
|
-
0 === this.
|
|
11554
|
+
0 === this.Mr && (this.Ur("Unknown" /* Unknown */), this.Fr = this.asyncQueue.enqueueAfterDelay("online_state_timeout" /* OnlineStateTimeout */ , 1e4, (() => (this.Fr = null,
|
|
11555
11555
|
this.qr("Backend didn't respond within 10 seconds."), this.Ur("Offline" /* Offline */),
|
|
11556
11556
|
Promise.resolve()))));
|
|
11557
11557
|
}
|
|
@@ -11561,8 +11561,8 @@ class uo {
|
|
|
11561
11561
|
* allow multiple failures (based on MAX_WATCH_STREAM_FAILURES) before we
|
|
11562
11562
|
* actually transition to the 'Offline' state.
|
|
11563
11563
|
*/ Kr(t) {
|
|
11564
|
-
"Online" /* Online */ === this.state ? this.Ur("Unknown" /* Unknown */) : (this.
|
|
11565
|
-
this.
|
|
11564
|
+
"Online" /* Online */ === this.state ? this.Ur("Unknown" /* Unknown */) : (this.Mr++,
|
|
11565
|
+
this.Mr >= 1 && (this.jr(), this.qr(`Connection failed 1 times. Most recent error: ${t.toString()}`),
|
|
11566
11566
|
this.Ur("Offline" /* Offline */)));
|
|
11567
11567
|
}
|
|
11568
11568
|
/**
|
|
@@ -11572,7 +11572,7 @@ class uo {
|
|
|
11572
11572
|
* Offline heuristics, so must not be used in place of
|
|
11573
11573
|
* handleWatchStreamStart() and handleWatchStreamFailure().
|
|
11574
11574
|
*/ set(t) {
|
|
11575
|
-
this.jr(), this.
|
|
11575
|
+
this.jr(), this.Mr = 0, "Online" /* Online */ === t && (
|
|
11576
11576
|
// We've connected to watch at least once. Don't warn the developer
|
|
11577
11577
|
// about being offline going forward.
|
|
11578
11578
|
this.Lr = !1), this.Ur(t);
|
|
@@ -11582,10 +11582,10 @@ class uo {
|
|
|
11582
11582
|
}
|
|
11583
11583
|
qr(t) {
|
|
11584
11584
|
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.`;
|
|
11585
|
-
this.Lr ? (
|
|
11585
|
+
this.Lr ? (F(e), this.Lr = !1) : M("OnlineStateTracker", e);
|
|
11586
11586
|
}
|
|
11587
11587
|
jr() {
|
|
11588
|
-
null !== this.
|
|
11588
|
+
null !== this.Fr && (this.Fr.cancel(), this.Fr = null);
|
|
11589
11589
|
}
|
|
11590
11590
|
}
|
|
11591
11591
|
|
|
@@ -11658,7 +11658,7 @@ class uo {
|
|
|
11658
11658
|
// Porting Note: Unlike iOS, `restartNetwork()` is called even when the
|
|
11659
11659
|
// network becomes unreachable as we don't have any other way to tear
|
|
11660
11660
|
// down our streams.
|
|
11661
|
-
To(this) && (
|
|
11661
|
+
To(this) && (M("RemoteStore", "Restarting streams for network reachability change."),
|
|
11662
11662
|
await async function(t) {
|
|
11663
11663
|
const e = j(t);
|
|
11664
11664
|
e.Gr.add(4 /* ConnectivityChange */), await fo(e), e.Jr.set("Unknown" /* Unknown */),
|
|
@@ -11690,14 +11690,14 @@ function wo(t, e) {
|
|
|
11690
11690
|
// Mark this as something the client is currently listening for.
|
|
11691
11691
|
n.Wr.set(e.targetId, e), po(n) ?
|
|
11692
11692
|
// The listen will be sent in onWatchStreamOpen
|
|
11693
|
-
yo(n) :
|
|
11693
|
+
yo(n) : Mo(n).lr() && mo(n, e));
|
|
11694
11694
|
}
|
|
11695
11695
|
|
|
11696
11696
|
/**
|
|
11697
11697
|
* Removes the listen from server. It is a no-op if the given target id is
|
|
11698
11698
|
* not being listened to.
|
|
11699
11699
|
*/ function _o(t, e) {
|
|
11700
|
-
const n = j(t), s =
|
|
11700
|
+
const n = j(t), s = Mo(n);
|
|
11701
11701
|
n.Wr.delete(e), s.lr() && go(n, e), 0 === n.Wr.size && (s.lr() ? s._r() : To(n) &&
|
|
11702
11702
|
// Revert to OnlineState.Unknown if the watch stream is not open and we
|
|
11703
11703
|
// have no listeners, since without any listens to send we cannot
|
|
@@ -11709,7 +11709,7 @@ function wo(t, e) {
|
|
|
11709
11709
|
* We need to increment the the expected number of pending responses we're due
|
|
11710
11710
|
* from watch so we wait for the ack to process any messages from this target.
|
|
11711
11711
|
*/ function mo(t, e) {
|
|
11712
|
-
t.Yr.X(e.targetId),
|
|
11712
|
+
t.Yr.X(e.targetId), Mo(t).Pr(e);
|
|
11713
11713
|
}
|
|
11714
11714
|
|
|
11715
11715
|
/**
|
|
@@ -11717,21 +11717,21 @@ function wo(t, e) {
|
|
|
11717
11717
|
* from watch so we wait for the removal on the server before we process any
|
|
11718
11718
|
* messages from this target.
|
|
11719
11719
|
*/ function go(t, e) {
|
|
11720
|
-
t.Yr.X(e),
|
|
11720
|
+
t.Yr.X(e), Mo(t).vr(e);
|
|
11721
11721
|
}
|
|
11722
11722
|
|
|
11723
11723
|
function yo(t) {
|
|
11724
11724
|
t.Yr = new Un({
|
|
11725
11725
|
getRemoteKeysForTarget: e => t.remoteSyncer.getRemoteKeysForTarget(e),
|
|
11726
11726
|
Et: e => t.Wr.get(e) || null
|
|
11727
|
-
}),
|
|
11727
|
+
}), Mo(t).start(), t.Jr.Br();
|
|
11728
11728
|
}
|
|
11729
11729
|
|
|
11730
11730
|
/**
|
|
11731
11731
|
* Returns whether the watch stream should be started because it's necessary
|
|
11732
11732
|
* and has not yet been started.
|
|
11733
11733
|
*/ function po(t) {
|
|
11734
|
-
return To(t) && !
|
|
11734
|
+
return To(t) && !Mo(t).hr() && t.Wr.size > 0;
|
|
11735
11735
|
}
|
|
11736
11736
|
|
|
11737
11737
|
function To(t) {
|
|
@@ -11782,9 +11782,9 @@ async function Ro(t, e, n) {
|
|
|
11782
11782
|
* Starts the write stream if necessary.
|
|
11783
11783
|
*/ (t, e);
|
|
11784
11784
|
} catch (n) {
|
|
11785
|
-
|
|
11786
|
-
await
|
|
11787
|
-
} else if (e instanceof
|
|
11785
|
+
M("RemoteStore", "Failed to remove targets %s: %s ", e.targetIds.join(","), n),
|
|
11786
|
+
await bo(t, n);
|
|
11787
|
+
} else if (e instanceof Mn ? t.Yr.ot(e) : e instanceof Fn ? t.Yr.dt(e) : t.Yr.ut(e),
|
|
11788
11788
|
!n.isEqual(ht.min())) try {
|
|
11789
11789
|
const e = await yr(t.localStore);
|
|
11790
11790
|
n.compareTo(e) >= 0 &&
|
|
@@ -11829,7 +11829,7 @@ async function Ro(t, e, n) {
|
|
|
11829
11829
|
})), t.remoteSyncer.applyRemoteEvent(n);
|
|
11830
11830
|
}(t, n);
|
|
11831
11831
|
} catch (e) {
|
|
11832
|
-
|
|
11832
|
+
M("RemoteStore", "Failed to raise snapshot:", e), await bo(t, e);
|
|
11833
11833
|
}
|
|
11834
11834
|
}
|
|
11835
11835
|
|
|
@@ -11841,7 +11841,7 @@ async function Ro(t, e, n) {
|
|
|
11841
11841
|
*
|
|
11842
11842
|
* The returned Promise is resolved once the network is disabled and before
|
|
11843
11843
|
* any retry attempt.
|
|
11844
|
-
*/ async function
|
|
11844
|
+
*/ async function bo(t, e, n) {
|
|
11845
11845
|
if (!ei(e)) throw e;
|
|
11846
11846
|
t.Gr.add(1 /* IndexedDbFailed */),
|
|
11847
11847
|
// Disable network and raise offline snapshots
|
|
@@ -11852,7 +11852,7 @@ async function Ro(t, e, n) {
|
|
|
11852
11852
|
n = () => yr(t.localStore)),
|
|
11853
11853
|
// Probe IndexedDB periodically and re-enable network
|
|
11854
11854
|
t.asyncQueue.enqueueRetryable((async () => {
|
|
11855
|
-
|
|
11855
|
+
M("RemoteStore", "Retrying IndexedDB access"), await n(), t.Gr.delete(1 /* IndexedDbFailed */),
|
|
11856
11856
|
await lo(t);
|
|
11857
11857
|
}));
|
|
11858
11858
|
}
|
|
@@ -11860,12 +11860,12 @@ async function Ro(t, e, n) {
|
|
|
11860
11860
|
/**
|
|
11861
11861
|
* Executes `op`. If `op` fails, takes the network offline until `op`
|
|
11862
11862
|
* succeeds. Returns after the first attempt.
|
|
11863
|
-
*/ function
|
|
11864
|
-
return e().catch((n =>
|
|
11863
|
+
*/ function Po(t, e) {
|
|
11864
|
+
return e().catch((n => bo(t, n, e)));
|
|
11865
11865
|
}
|
|
11866
11866
|
|
|
11867
11867
|
async function vo(t) {
|
|
11868
|
-
const e = j(t), n =
|
|
11868
|
+
const e = j(t), n = Fo(e);
|
|
11869
11869
|
let s = e.Qr.length > 0 ? e.Qr[e.Qr.length - 1].batchId : -1;
|
|
11870
11870
|
for (;Vo(e); ) try {
|
|
11871
11871
|
const t = await Er(e.localStore, s);
|
|
@@ -11875,7 +11875,7 @@ async function vo(t) {
|
|
|
11875
11875
|
}
|
|
11876
11876
|
s = t.batchId, So(e, t);
|
|
11877
11877
|
} catch (t) {
|
|
11878
|
-
await
|
|
11878
|
+
await bo(e, t);
|
|
11879
11879
|
}
|
|
11880
11880
|
Do(e) && Co(e);
|
|
11881
11881
|
}
|
|
@@ -11892,31 +11892,31 @@ async function vo(t) {
|
|
|
11892
11892
|
* immediately if the write stream is established.
|
|
11893
11893
|
*/ function So(t, e) {
|
|
11894
11894
|
t.Qr.push(e);
|
|
11895
|
-
const n =
|
|
11895
|
+
const n = Fo(t);
|
|
11896
11896
|
n.lr() && n.Sr && n.Dr(e.mutations);
|
|
11897
11897
|
}
|
|
11898
11898
|
|
|
11899
11899
|
function Do(t) {
|
|
11900
|
-
return To(t) && !
|
|
11900
|
+
return To(t) && !Fo(t).hr() && t.Qr.length > 0;
|
|
11901
11901
|
}
|
|
11902
11902
|
|
|
11903
11903
|
function Co(t) {
|
|
11904
|
-
|
|
11904
|
+
Fo(t).start();
|
|
11905
11905
|
}
|
|
11906
11906
|
|
|
11907
11907
|
async function No(t) {
|
|
11908
|
-
|
|
11908
|
+
Fo(t).kr();
|
|
11909
11909
|
}
|
|
11910
11910
|
|
|
11911
11911
|
async function ko(t) {
|
|
11912
|
-
const e =
|
|
11912
|
+
const e = Fo(t);
|
|
11913
11913
|
// Send the write pipeline now that the stream is established.
|
|
11914
11914
|
for (const n of t.Qr) e.Dr(n.mutations);
|
|
11915
11915
|
}
|
|
11916
11916
|
|
|
11917
11917
|
async function xo(t, e, n) {
|
|
11918
11918
|
const s = t.Qr.shift(), i = ui.from(s, e, n);
|
|
11919
|
-
await
|
|
11919
|
+
await Po(t, (() => t.remoteSyncer.applySuccessfulWrite(i))),
|
|
11920
11920
|
// It's possible that with the completion of this mutation another
|
|
11921
11921
|
// slot has freed up.
|
|
11922
11922
|
await vo(t);
|
|
@@ -11925,7 +11925,7 @@ async function xo(t, e, n) {
|
|
|
11925
11925
|
async function $o(t, e) {
|
|
11926
11926
|
// If the write stream closed after the write handshake completes, a write
|
|
11927
11927
|
// operation failed and we fail the pending operation.
|
|
11928
|
-
e &&
|
|
11928
|
+
e && Fo(t).Sr &&
|
|
11929
11929
|
// This error affects the actual write.
|
|
11930
11930
|
await async function(t, e) {
|
|
11931
11931
|
// Only handle permanent errors here. If it's transient, just let the retry
|
|
@@ -11937,7 +11937,7 @@ async function $o(t, e) {
|
|
|
11937
11937
|
// In this case it's also unlikely that the server itself is melting
|
|
11938
11938
|
// down -- this was just a bad request so inhibit backoff on the next
|
|
11939
11939
|
// restart.
|
|
11940
|
-
|
|
11940
|
+
Fo(t).wr(), await Po(t, (() => t.remoteSyncer.rejectFailedWrite(n.batchId, e))),
|
|
11941
11941
|
// It's possible that with the completion of this mutation
|
|
11942
11942
|
// another slot has freed up.
|
|
11943
11943
|
await vo(t);
|
|
@@ -11965,7 +11965,7 @@ async function Oo(t, e) {
|
|
|
11965
11965
|
*
|
|
11966
11966
|
* PORTING NOTE: On iOS and Android, the WatchStream gets registered on startup.
|
|
11967
11967
|
* This is not done on Web to allow it to be tree-shaken.
|
|
11968
|
-
*/ function
|
|
11968
|
+
*/ function Mo(t) {
|
|
11969
11969
|
return t.Xr || (
|
|
11970
11970
|
// Create stream (but note that it is not started yet).
|
|
11971
11971
|
t.Xr = function(t, e, n) {
|
|
@@ -11990,7 +11990,7 @@ async function Oo(t, e) {
|
|
|
11990
11990
|
*/ (t.datastore, t.asyncQueue, {
|
|
11991
11991
|
Di: Io.bind(null, t),
|
|
11992
11992
|
Ni: Ao.bind(null, t),
|
|
11993
|
-
|
|
11993
|
+
br: Ro.bind(null, t)
|
|
11994
11994
|
}), t.zr.push((async e => {
|
|
11995
11995
|
e ? (t.Xr.wr(), po(t) ? yo(t) : t.Jr.set("Unknown" /* Unknown */)) : (await t.Xr.stop(),
|
|
11996
11996
|
Eo(t));
|
|
@@ -12004,7 +12004,7 @@ async function Oo(t, e) {
|
|
|
12004
12004
|
*
|
|
12005
12005
|
* PORTING NOTE: On iOS and Android, the WriteStream gets registered on startup.
|
|
12006
12006
|
* This is not done on Web to allow it to be tree-shaken.
|
|
12007
|
-
*/ function
|
|
12007
|
+
*/ function Fo(t) {
|
|
12008
12008
|
return t.Zr || (
|
|
12009
12009
|
// Create stream (but note that it is not started yet).
|
|
12010
12010
|
t.Zr = function(t, e, n) {
|
|
@@ -12018,7 +12018,7 @@ async function Oo(t, e) {
|
|
|
12018
12018
|
}), t.zr.push((async e => {
|
|
12019
12019
|
e ? (t.Zr.wr(),
|
|
12020
12020
|
// This will start the write stream if necessary.
|
|
12021
|
-
await vo(t)) : (await t.Zr.stop(), t.Qr.length > 0 && (
|
|
12021
|
+
await vo(t)) : (await t.Zr.stop(), t.Qr.length > 0 && (M("RemoteStore", `Stopping write stream with ${t.Qr.length} pending writes`),
|
|
12022
12022
|
t.Qr = []));
|
|
12023
12023
|
}))), t.Zr;
|
|
12024
12024
|
}
|
|
@@ -12111,7 +12111,7 @@ class Lo {
|
|
|
12111
12111
|
* Returns a FirestoreError that can be surfaced to the user if the provided
|
|
12112
12112
|
* error is an IndexedDbTransactionError. Re-throws the error otherwise.
|
|
12113
12113
|
*/ function Bo(t, e) {
|
|
12114
|
-
if (
|
|
12114
|
+
if (F("AsyncQueue", `${e}: ${t}`), ei(t)) return new W(Q.UNAVAILABLE, `${e}: ${t}`);
|
|
12115
12115
|
throw t;
|
|
12116
12116
|
}
|
|
12117
12117
|
|
|
@@ -12632,7 +12632,7 @@ class sa {
|
|
|
12632
12632
|
/**
|
|
12633
12633
|
* The set of remote documents that the server has told us belongs to the target associated with
|
|
12634
12634
|
* this view.
|
|
12635
|
-
*/ get
|
|
12635
|
+
*/ get bo() {
|
|
12636
12636
|
return this.To;
|
|
12637
12637
|
}
|
|
12638
12638
|
/**
|
|
@@ -12644,7 +12644,7 @@ class sa {
|
|
|
12644
12644
|
* @param previousChanges - If this is being called with a refill, then start
|
|
12645
12645
|
* with this set of docs and changes instead of the current view.
|
|
12646
12646
|
* @returns a new set of docs, changes, and refill flag.
|
|
12647
|
-
*/
|
|
12647
|
+
*/ Po(t, e) {
|
|
12648
12648
|
const n = e ? e.vo : new qo, s = e ? e.Ro : this.Ro;
|
|
12649
12649
|
let i = e ? e.mutatedKeys : this.mutatedKeys, r = s, o = !1;
|
|
12650
12650
|
// Track the last doc in a (full) limit. This is necessary, because some
|
|
@@ -12852,7 +12852,7 @@ class sa {
|
|
|
12852
12852
|
// PORTING NOTE: Multi-tab only.
|
|
12853
12853
|
ko(t) {
|
|
12854
12854
|
this.To = t.zn, this.Io = Nn();
|
|
12855
|
-
const e = this.
|
|
12855
|
+
const e = this.Po(t.documents);
|
|
12856
12856
|
return this.applyChanges(e, /*updateLimboDocuments=*/ !0);
|
|
12857
12857
|
}
|
|
12858
12858
|
/**
|
|
@@ -12922,8 +12922,8 @@ class ra {
|
|
|
12922
12922
|
// PORTING NOTE: Manages state synchronization in multi-tab environments.
|
|
12923
12923
|
s, i, r) {
|
|
12924
12924
|
this.localStore = t, this.remoteStore = e, this.eventManager = n, this.sharedClientState = s,
|
|
12925
|
-
this.currentUser = i, this.maxConcurrentLimboResolutions = r, this.Oo = {}, this.
|
|
12926
|
-
this.
|
|
12925
|
+
this.currentUser = i, this.maxConcurrentLimboResolutions = r, this.Oo = {}, this.Mo = new Ji((t => De(t)), Se),
|
|
12926
|
+
this.Fo = new Map,
|
|
12927
12927
|
/**
|
|
12928
12928
|
* The keys of documents that are in limbo for which we haven't yet started a
|
|
12929
12929
|
* limbo resolution query. The strings in this set are the result of calling
|
|
@@ -12947,7 +12947,7 @@ class ra {
|
|
|
12947
12947
|
/** Stores user completion handlers, indexed by User and BatchId. */
|
|
12948
12948
|
this.Ko = {},
|
|
12949
12949
|
/** Stores user callbacks waiting for all pending writes to be acknowledged. */
|
|
12950
|
-
this.jo = new Map, this.Qo =
|
|
12950
|
+
this.jo = new Map, this.Qo = Fi.re(), this.onlineState = "Unknown" /* Unknown */ ,
|
|
12951
12951
|
// The primary state is set to `true` or `false` immediately after Firestore
|
|
12952
12952
|
// startup. In the interim, a client should only be considered primary if
|
|
12953
12953
|
// `isPrimary` is true.
|
|
@@ -12964,9 +12964,9 @@ class ra {
|
|
|
12964
12964
|
* subscribed handlers. Returns the initial snapshot.
|
|
12965
12965
|
*/
|
|
12966
12966
|
async function ca(t, e) {
|
|
12967
|
-
const n =
|
|
12967
|
+
const n = Ma(t);
|
|
12968
12968
|
let s, i;
|
|
12969
|
-
const r = n.
|
|
12969
|
+
const r = n.Mo.get(e);
|
|
12970
12970
|
if (r)
|
|
12971
12971
|
// PORTING NOTE: With Multi-Tab Web, it is possible that a query view
|
|
12972
12972
|
// already exists when EventManager calls us for the first time. This
|
|
@@ -12989,28 +12989,28 @@ async function ca(t, e) {
|
|
|
12989
12989
|
// targets based on view changes. This allows us to only depend on Limbo
|
|
12990
12990
|
// changes when user code includes queries.
|
|
12991
12991
|
t.Go = (e, n, s) => async function(t, e, n, s) {
|
|
12992
|
-
let i = e.view.
|
|
12992
|
+
let i = e.view.Po(n);
|
|
12993
12993
|
i.Bn && (
|
|
12994
12994
|
// The query has a limit and some docs were removed, so we need
|
|
12995
12995
|
// to re-run the query against the local store to make sure we
|
|
12996
12996
|
// didn't lose any good docs that had been past the limit.
|
|
12997
12997
|
i = await Rr(t.localStore, e.query,
|
|
12998
|
-
/* usePreviousResults= */ !1).then((({documents: t}) => e.view.
|
|
12998
|
+
/* usePreviousResults= */ !1).then((({documents: t}) => e.view.Po(t, i))));
|
|
12999
12999
|
const r = s && s.targetChanges.get(e.targetId), o = e.view.applyChanges(i,
|
|
13000
13000
|
/* updateLimboDocuments= */ t.isPrimaryClient, r);
|
|
13001
13001
|
return Ia(t, e.targetId, o.Co), o.snapshot;
|
|
13002
13002
|
}(t, e, n, s);
|
|
13003
13003
|
const i = await Rr(t.localStore, e,
|
|
13004
|
-
/* usePreviousResults= */ !0), r = new ia(e, i.zn), o = r.
|
|
13004
|
+
/* usePreviousResults= */ !0), r = new ia(e, i.zn), o = r.Po(i.documents), a = On.createSynthesizedTargetChangeForCurrentChange(n, s && "Offline" /* Offline */ !== t.onlineState), c = r.applyChanges(o,
|
|
13005
13005
|
/* updateLimboDocuments= */ t.isPrimaryClient, a);
|
|
13006
13006
|
Ia(t, n, c.Co);
|
|
13007
13007
|
const u = new ra(e, n, r);
|
|
13008
|
-
return t.
|
|
13008
|
+
return t.Mo.set(e, u), t.Fo.has(n) ? t.Fo.get(n).push(e) : t.Fo.set(n, [ e ]), c.snapshot;
|
|
13009
13009
|
}
|
|
13010
13010
|
|
|
13011
13011
|
/** Stops listening to the query. */ async function ha(t, e) {
|
|
13012
|
-
const n = j(t), s = n.
|
|
13013
|
-
if (i.length > 1) return n.
|
|
13012
|
+
const n = j(t), s = n.Mo.get(e), i = n.Fo.get(s.targetId);
|
|
13013
|
+
if (i.length > 1) return n.Fo.set(s.targetId, i.filter((t => !Se(t, e)))), void n.Mo.delete(e);
|
|
13014
13014
|
// No other queries are mapped to the target, clean up the query and the target.
|
|
13015
13015
|
if (n.isPrimaryClient) {
|
|
13016
13016
|
// We need to remove the local query target first to allow us to verify
|
|
@@ -13035,7 +13035,7 @@ async function ca(t, e) {
|
|
|
13035
13035
|
* userCallback is resolved once the write was acked/rejected by the
|
|
13036
13036
|
* backend (or failed locally for any other reason).
|
|
13037
13037
|
*/ async function la(t, e, n) {
|
|
13038
|
-
const s =
|
|
13038
|
+
const s = Fa(t);
|
|
13039
13039
|
try {
|
|
13040
13040
|
const t = await function(t, e) {
|
|
13041
13041
|
const n = j(t), s = ut.now(), i = e.reduce(((t, e) => t.add(e.key)), Nn());
|
|
@@ -13070,7 +13070,7 @@ async function ca(t, e) {
|
|
|
13070
13070
|
/**
|
|
13071
13071
|
* Resolves or rejects the user callback for the given batch and then discards
|
|
13072
13072
|
* it.
|
|
13073
|
-
*/ (s, t.batchId, n), await
|
|
13073
|
+
*/ (s, t.batchId, n), await ba(s, t.changes), await vo(s.remoteStore);
|
|
13074
13074
|
} catch (t) {
|
|
13075
13075
|
// If we can't persist the mutation, we reject the user callback and
|
|
13076
13076
|
// don't send the mutation. The user can then retry the write.
|
|
@@ -13096,7 +13096,7 @@ async function ca(t, e) {
|
|
|
13096
13096
|
q(t.addedDocuments.size + t.modifiedDocuments.size + t.removedDocuments.size <= 1),
|
|
13097
13097
|
t.addedDocuments.size > 0 ? s.$o = !0 : t.modifiedDocuments.size > 0 ? q(s.$o) : t.removedDocuments.size > 0 && (q(s.$o),
|
|
13098
13098
|
s.$o = !1));
|
|
13099
|
-
})), await
|
|
13099
|
+
})), await ba(n, t, e);
|
|
13100
13100
|
} catch (t) {
|
|
13101
13101
|
await Ki(t);
|
|
13102
13102
|
}
|
|
@@ -13113,7 +13113,7 @@ async function ca(t, e) {
|
|
|
13113
13113
|
// SharedClientState.
|
|
13114
13114
|
if (s.isPrimaryClient && 0 /* RemoteStore */ === n || !s.isPrimaryClient && 1 /* SharedClientState */ === n) {
|
|
13115
13115
|
const t = [];
|
|
13116
|
-
s.
|
|
13116
|
+
s.Mo.forEach(((n, s) => {
|
|
13117
13117
|
const i = s.view.ro(e);
|
|
13118
13118
|
i.snapshot && t.push(i.snapshot);
|
|
13119
13119
|
})), function(t, e) {
|
|
@@ -13125,7 +13125,7 @@ async function ca(t, e) {
|
|
|
13125
13125
|
// Run global snapshot listeners if a consistent snapshot has been emitted.
|
|
13126
13126
|
t.ro(e) && (s = !0);
|
|
13127
13127
|
})), s && Jo(n);
|
|
13128
|
-
}(s.eventManager, e), t.length && s.Oo.
|
|
13128
|
+
}(s.eventManager, e), t.length && s.Oo.br(t), s.onlineState = e, s.isPrimaryClient && s.sharedClientState.setOnlineState(e);
|
|
13129
13129
|
}
|
|
13130
13130
|
}
|
|
13131
13131
|
|
|
@@ -13176,7 +13176,7 @@ async function _a(t, e) {
|
|
|
13176
13176
|
// up), so we raise user callbacks first so that they consistently happen
|
|
13177
13177
|
// before listen events.
|
|
13178
13178
|
pa(n, s, /*error=*/ null), ya(n, s), n.sharedClientState.updateMutationState(s, "acknowledged"),
|
|
13179
|
-
await
|
|
13179
|
+
await ba(n, t);
|
|
13180
13180
|
} catch (t) {
|
|
13181
13181
|
await Ki(t);
|
|
13182
13182
|
}
|
|
@@ -13203,7 +13203,7 @@ async function ma(t, e, n) {
|
|
|
13203
13203
|
// so we raise user callbacks first so that they consistently happen before
|
|
13204
13204
|
// listen events.
|
|
13205
13205
|
pa(s, e, n), ya(s, e), s.sharedClientState.updateMutationState(e, "rejected", n),
|
|
13206
|
-
await
|
|
13206
|
+
await ba(s, t);
|
|
13207
13207
|
} catch (n) {
|
|
13208
13208
|
await Ki(n);
|
|
13209
13209
|
}
|
|
@@ -13214,7 +13214,7 @@ async function ma(t, e, n) {
|
|
|
13214
13214
|
* are acknowledged .
|
|
13215
13215
|
*/ async function ga(t, e) {
|
|
13216
13216
|
const n = j(t);
|
|
13217
|
-
To(n.remoteStore) ||
|
|
13217
|
+
To(n.remoteStore) || M("SyncEngine", "The network is disabled. The task returned by 'awaitPendingWrites()' will not complete until the network is enabled.");
|
|
13218
13218
|
try {
|
|
13219
13219
|
const t = await function(t) {
|
|
13220
13220
|
const e = j(t);
|
|
@@ -13253,8 +13253,8 @@ async function ma(t, e, n) {
|
|
|
13253
13253
|
|
|
13254
13254
|
function Ta(t, e, n = null) {
|
|
13255
13255
|
t.sharedClientState.removeLocalQueryTarget(e);
|
|
13256
|
-
for (const s of t.
|
|
13257
|
-
if (t.
|
|
13256
|
+
for (const s of t.Fo.get(e)) t.Mo.delete(s), n && t.Oo.zo(s, n);
|
|
13257
|
+
if (t.Fo.delete(e), t.isPrimaryClient) {
|
|
13258
13258
|
t.qo.us(e).forEach((e => {
|
|
13259
13259
|
t.qo.containsKey(e) ||
|
|
13260
13260
|
// We removed the last reference for this key
|
|
@@ -13273,7 +13273,7 @@ function Ea(t, e) {
|
|
|
13273
13273
|
|
|
13274
13274
|
function Ia(t, e, n) {
|
|
13275
13275
|
for (const s of n) if (s instanceof na) t.qo.addReference(s.key, e), Aa(t, s); else if (s instanceof sa) {
|
|
13276
|
-
|
|
13276
|
+
M("SyncEngine", "Document no longer in limbo: " + s.key), t.qo.removeReference(s.key, e);
|
|
13277
13277
|
t.qo.containsKey(s.key) ||
|
|
13278
13278
|
// We removed the last reference for this key
|
|
13279
13279
|
Ea(t, s.key);
|
|
@@ -13282,7 +13282,7 @@ function Ia(t, e, n) {
|
|
|
13282
13282
|
|
|
13283
13283
|
function Aa(t, e) {
|
|
13284
13284
|
const n = e.key, s = n.path.canonicalString();
|
|
13285
|
-
t.Bo.get(n) || t.Lo.has(s) || (
|
|
13285
|
+
t.Bo.get(n) || t.Lo.has(s) || (M("SyncEngine", "New document in limbo: " + n), t.Lo.add(s),
|
|
13286
13286
|
Ra(t));
|
|
13287
13287
|
}
|
|
13288
13288
|
|
|
@@ -13302,9 +13302,9 @@ function Aa(t, e) {
|
|
|
13302
13302
|
}
|
|
13303
13303
|
}
|
|
13304
13304
|
|
|
13305
|
-
async function
|
|
13305
|
+
async function ba(t, e, n) {
|
|
13306
13306
|
const s = j(t), i = [], r = [], o = [];
|
|
13307
|
-
s.
|
|
13307
|
+
s.Mo.isEmpty() || (s.Mo.forEach(((t, a) => {
|
|
13308
13308
|
o.push(s.Go(a, e, n).then((t => {
|
|
13309
13309
|
if (t) {
|
|
13310
13310
|
s.isPrimaryClient && s.sharedClientState.updateQueryState(a.targetId, t.fromCache ? "not-current" : "current"),
|
|
@@ -13313,7 +13313,7 @@ async function Pa(t, e, n) {
|
|
|
13313
13313
|
r.push(e);
|
|
13314
13314
|
}
|
|
13315
13315
|
})));
|
|
13316
|
-
})), await Promise.all(o), s.Oo.
|
|
13316
|
+
})), await Promise.all(o), s.Oo.br(i), await async function(t, e) {
|
|
13317
13317
|
const n = j(t);
|
|
13318
13318
|
try {
|
|
13319
13319
|
await n.persistence.runTransaction("notifyLocalViewChanges", "readwrite", (t => Js.forEach(e, (e => Js.forEach(e.kn, (s => n.persistence.referenceDelegate.addReference(t, e.targetId, s))).next((() => Js.forEach(e.xn, (s => n.persistence.referenceDelegate.removeReference(t, e.targetId, s)))))))));
|
|
@@ -13323,7 +13323,7 @@ async function Pa(t, e, n) {
|
|
|
13323
13323
|
// number for the documents that were included in this transaction.
|
|
13324
13324
|
// This might trigger them to be deleted earlier than they otherwise
|
|
13325
13325
|
// would have, but it should not invalidate the integrity of the data.
|
|
13326
|
-
|
|
13326
|
+
M("LocalStore", "Failed to update sequence numbers: " + t);
|
|
13327
13327
|
}
|
|
13328
13328
|
for (const t of e) {
|
|
13329
13329
|
const e = t.targetId;
|
|
@@ -13336,10 +13336,10 @@ async function Pa(t, e, n) {
|
|
|
13336
13336
|
}(s.localStore, r));
|
|
13337
13337
|
}
|
|
13338
13338
|
|
|
13339
|
-
async function
|
|
13339
|
+
async function Pa(t, e) {
|
|
13340
13340
|
const n = j(t);
|
|
13341
13341
|
if (!n.currentUser.isEqual(e)) {
|
|
13342
|
-
|
|
13342
|
+
M("SyncEngine", "User change. New user:", e.toKey());
|
|
13343
13343
|
const t = await mr(n.localStore, e);
|
|
13344
13344
|
n.currentUser = e,
|
|
13345
13345
|
// Fails tasks waiting for pending writes requested by previous user.
|
|
@@ -13351,7 +13351,7 @@ async function ba(t, e) {
|
|
|
13351
13351
|
})), t.jo.clear();
|
|
13352
13352
|
}(n, "'waitForPendingWrites' promise is rejected due to a user change."),
|
|
13353
13353
|
// TODO(b/114226417): Consider calling this only in the primary tab.
|
|
13354
|
-
n.sharedClientState.handleUserChange(e, t.removedBatchIds, t.addedBatchIds), await
|
|
13354
|
+
n.sharedClientState.handleUserChange(e, t.removedBatchIds, t.addedBatchIds), await ba(n, t.Gn);
|
|
13355
13355
|
}
|
|
13356
13356
|
}
|
|
13357
13357
|
|
|
@@ -13360,11 +13360,11 @@ function va(t, e) {
|
|
|
13360
13360
|
if (s && s.$o) return Nn().add(s.key);
|
|
13361
13361
|
{
|
|
13362
13362
|
let t = Nn();
|
|
13363
|
-
const s = n.
|
|
13363
|
+
const s = n.Fo.get(e);
|
|
13364
13364
|
if (!s) return t;
|
|
13365
13365
|
for (const e of s) {
|
|
13366
|
-
const s = n.
|
|
13367
|
-
t = t.unionWith(s.view.
|
|
13366
|
+
const s = n.Mo.get(e);
|
|
13367
|
+
t = t.unionWith(s.view.bo);
|
|
13368
13368
|
}
|
|
13369
13369
|
return t;
|
|
13370
13370
|
}
|
|
@@ -13386,7 +13386,7 @@ function va(t, e) {
|
|
|
13386
13386
|
// PORTING NOTE: Multi-Tab only.
|
|
13387
13387
|
async function Sa(t) {
|
|
13388
13388
|
const e = j(t);
|
|
13389
|
-
return
|
|
13389
|
+
return Pr(e.localStore).then((t => ba(e, t)));
|
|
13390
13390
|
}
|
|
13391
13391
|
|
|
13392
13392
|
/** Applies a mutation state to an existing batch. */
|
|
@@ -13409,7 +13409,7 @@ async function Da(t, e, n, s) {
|
|
|
13409
13409
|
j(j(t).An).ee(e);
|
|
13410
13410
|
}
|
|
13411
13411
|
// PORTING NOTE: Multi-Tab only.
|
|
13412
|
-
(i.localStore, e)) : U(), await
|
|
13412
|
+
(i.localStore, e)) : U(), await ba(i, r)) :
|
|
13413
13413
|
// A throttled tab may not have seen the mutation before it was completed
|
|
13414
13414
|
// and removed from the mutation queue, in which case we won't have cached
|
|
13415
13415
|
// the affected documents. In this case we can safely ignore the update
|
|
@@ -13417,14 +13417,14 @@ async function Da(t, e, n, s) {
|
|
|
13417
13417
|
// had, we would have cached the affected documents), and so we will just
|
|
13418
13418
|
// see any resulting document changes via normal remote document updates
|
|
13419
13419
|
// as applicable.
|
|
13420
|
-
|
|
13420
|
+
M("SyncEngine", "Cannot apply mutation batch with id: " + e);
|
|
13421
13421
|
}
|
|
13422
13422
|
|
|
13423
13423
|
/** Applies a query target change from a different tab. */
|
|
13424
13424
|
// PORTING NOTE: Multi-Tab only.
|
|
13425
13425
|
async function Ca(t, e) {
|
|
13426
13426
|
const n = j(t);
|
|
13427
|
-
if (
|
|
13427
|
+
if (Ma(n), Fa(n), !0 === e && !0 !== n.Wo) {
|
|
13428
13428
|
// Secondary tabs only maintain Views for their local listeners and the
|
|
13429
13429
|
// Views internal state may not be 100% populated (in particular
|
|
13430
13430
|
// secondary tabs don't track syncedDocuments, the set of documents the
|
|
@@ -13437,7 +13437,7 @@ async function Ca(t, e) {
|
|
|
13437
13437
|
} else if (!1 === e && !1 !== n.Wo) {
|
|
13438
13438
|
const t = [];
|
|
13439
13439
|
let e = Promise.resolve();
|
|
13440
|
-
n.
|
|
13440
|
+
n.Fo.forEach(((s, i) => {
|
|
13441
13441
|
n.sharedClientState.isLocalQueryTarget(i) ? t.push(i) : e = e.then((() => (Ta(n, i),
|
|
13442
13442
|
Ar(n.localStore, i,
|
|
13443
13443
|
/*keepPersistedTargetData=*/ !0)))), _o(n.remoteStore, i);
|
|
@@ -13468,7 +13468,7 @@ async function Na(t, e, n) {
|
|
|
13468
13468
|
const s = j(t), i = [], r = [];
|
|
13469
13469
|
for (const t of e) {
|
|
13470
13470
|
let e;
|
|
13471
|
-
const n = s.
|
|
13471
|
+
const n = s.Fo.get(t);
|
|
13472
13472
|
if (n && 0 !== n.length) {
|
|
13473
13473
|
// For queries that have a local View, we fetch their current state
|
|
13474
13474
|
// from LocalStore (as the resume token and the snapshot version
|
|
@@ -13476,19 +13476,19 @@ async function Na(t, e, n) {
|
|
|
13476
13476
|
// state (the list of syncedDocuments may have gotten out of sync).
|
|
13477
13477
|
e = await Ir(s.localStore, ve(n[0]));
|
|
13478
13478
|
for (const t of n) {
|
|
13479
|
-
const e = s.
|
|
13479
|
+
const e = s.Mo.get(t), n = await Va(s, e);
|
|
13480
13480
|
n.snapshot && r.push(n.snapshot);
|
|
13481
13481
|
}
|
|
13482
13482
|
} else {
|
|
13483
13483
|
// For queries that never executed on this client, we need to
|
|
13484
13484
|
// allocate the target in LocalStore and initialize a new View.
|
|
13485
|
-
const n = await
|
|
13485
|
+
const n = await br(s.localStore, t);
|
|
13486
13486
|
e = await Ir(s.localStore, n), await ua(s, ka(n), t,
|
|
13487
13487
|
/*current=*/ !1);
|
|
13488
13488
|
}
|
|
13489
13489
|
i.push(e);
|
|
13490
13490
|
}
|
|
13491
|
-
return s.Oo.
|
|
13491
|
+
return s.Oo.br(r), i;
|
|
13492
13492
|
}
|
|
13493
13493
|
|
|
13494
13494
|
/**
|
|
@@ -13520,12 +13520,12 @@ async function $a(t, e, n, s) {
|
|
|
13520
13520
|
if (i.Wo)
|
|
13521
13521
|
// If we receive a target state notification via WebStorage, we are
|
|
13522
13522
|
// either already secondary or another tab has taken the primary lease.
|
|
13523
|
-
|
|
13523
|
+
M("SyncEngine", "Ignoring unexpected query state notification."); else if (i.Fo.has(e)) switch (n) {
|
|
13524
13524
|
case "current":
|
|
13525
13525
|
case "not-current":
|
|
13526
13526
|
{
|
|
13527
|
-
const t = await
|
|
13528
|
-
await
|
|
13527
|
+
const t = await Pr(i.localStore), s = $n.createSynthesizedRemoteEventForCurrentChange(e, "current" === n);
|
|
13528
|
+
await ba(i, t, s);
|
|
13529
13529
|
break;
|
|
13530
13530
|
}
|
|
13531
13531
|
|
|
@@ -13540,22 +13540,22 @@ async function $a(t, e, n, s) {
|
|
|
13540
13540
|
}
|
|
13541
13541
|
|
|
13542
13542
|
/** Adds or removes Watch targets for queries from different tabs. */ async function Oa(t, e, n) {
|
|
13543
|
-
const s =
|
|
13543
|
+
const s = Ma(t);
|
|
13544
13544
|
if (s.Wo) {
|
|
13545
13545
|
for (const t of e) {
|
|
13546
|
-
if (s.
|
|
13546
|
+
if (s.Fo.has(t)) {
|
|
13547
13547
|
// A target might have been added in a previous attempt
|
|
13548
|
-
|
|
13548
|
+
M("SyncEngine", "Adding an already active target " + t);
|
|
13549
13549
|
continue;
|
|
13550
13550
|
}
|
|
13551
|
-
const e = await
|
|
13551
|
+
const e = await br(s.localStore, t), n = await Ir(s.localStore, e);
|
|
13552
13552
|
await ua(s, ka(e), n.targetId,
|
|
13553
13553
|
/*current=*/ !1), wo(s.remoteStore, n);
|
|
13554
13554
|
}
|
|
13555
13555
|
for (const t of n)
|
|
13556
13556
|
// Check that the target is still active since the target might have been
|
|
13557
13557
|
// removed if it has been rejected by the backend.
|
|
13558
|
-
s.
|
|
13558
|
+
s.Fo.has(t) &&
|
|
13559
13559
|
// Release queries that are still active.
|
|
13560
13560
|
await Ar(s.localStore, t,
|
|
13561
13561
|
/* keepPersistedTargetData */ !1).then((() => {
|
|
@@ -13564,14 +13564,14 @@ async function $a(t, e, n, s) {
|
|
|
13564
13564
|
}
|
|
13565
13565
|
}
|
|
13566
13566
|
|
|
13567
|
-
function
|
|
13567
|
+
function Ma(t) {
|
|
13568
13568
|
const e = j(t);
|
|
13569
13569
|
return e.remoteStore.remoteSyncer.applyRemoteEvent = fa.bind(null, e), e.remoteStore.remoteSyncer.getRemoteKeysForTarget = va.bind(null, e),
|
|
13570
|
-
e.remoteStore.remoteSyncer.rejectListen = wa.bind(null, e), e.Oo.
|
|
13570
|
+
e.remoteStore.remoteSyncer.rejectListen = wa.bind(null, e), e.Oo.br = zo.bind(null, e.eventManager),
|
|
13571
13571
|
e.Oo.zo = Ho.bind(null, e.eventManager), e;
|
|
13572
13572
|
}
|
|
13573
13573
|
|
|
13574
|
-
function
|
|
13574
|
+
function Fa(t) {
|
|
13575
13575
|
const e = j(t);
|
|
13576
13576
|
return e.remoteStore.remoteSyncer.applySuccessfulWrite = _a.bind(null, e), e.remoteStore.remoteSyncer.rejectFailedWrite = ma.bind(null, e),
|
|
13577
13577
|
e;
|
|
@@ -13616,7 +13616,7 @@ function Ma(t) {
|
|
|
13616
13616
|
// TODO(b/160876443): This currently raises snapshots with
|
|
13617
13617
|
// `fromCache=false` if users already listen to some queries and bundles
|
|
13618
13618
|
// has newer version.
|
|
13619
|
-
await
|
|
13619
|
+
await ba(t, o.In,
|
|
13620
13620
|
/* remoteEvent */ void 0),
|
|
13621
13621
|
// Save metadata, so loading the same bundle will skip.
|
|
13622
13622
|
await function(t, e) {
|
|
@@ -13670,7 +13670,7 @@ class Ba {
|
|
|
13670
13670
|
return _r(this.persistence, new dr, t.initialUser, this.k);
|
|
13671
13671
|
}
|
|
13672
13672
|
Yo(t) {
|
|
13673
|
-
return new
|
|
13673
|
+
return new Mr(Lr.ks, this.k);
|
|
13674
13674
|
}
|
|
13675
13675
|
Jo(t) {
|
|
13676
13676
|
return new Hr;
|
|
@@ -13690,7 +13690,7 @@ class Ba {
|
|
|
13690
13690
|
async initialize(t) {
|
|
13691
13691
|
await super.initialize(t), await vr(this.localStore), await this.ta.initialize(this, t),
|
|
13692
13692
|
// Enqueue writes from a previous session
|
|
13693
|
-
await
|
|
13693
|
+
await Fa(this.ta.syncEngine), await vo(this.ta.remoteStore),
|
|
13694
13694
|
// NOTE: This will immediately call the listener, so we make sure to
|
|
13695
13695
|
// set it after localStore / remoteStore are started.
|
|
13696
13696
|
await this.persistence.sn((() => (this.gcScheduler && !this.gcScheduler.started && this.gcScheduler.start(this.localStore),
|
|
@@ -13741,7 +13741,7 @@ class Ba {
|
|
|
13741
13741
|
}
|
|
13742
13742
|
Jo(t) {
|
|
13743
13743
|
const e = eo();
|
|
13744
|
-
if (!zr.
|
|
13744
|
+
if (!zr.Pt(e)) throw new W(Q.UNIMPLEMENTED, "IndexedDB persistence is only available on platforms that support LocalStorage.");
|
|
13745
13745
|
const n = ur(t.databaseInfo.databaseId, t.databaseInfo.persistenceKey);
|
|
13746
13746
|
return new zr(e, t.asyncQueue, n, t.clientId, t.initialUser);
|
|
13747
13747
|
}
|
|
@@ -13756,7 +13756,7 @@ class Ba {
|
|
|
13756
13756
|
this.datastore = this.createDatastore(e), this.remoteStore = this.createRemoteStore(e),
|
|
13757
13757
|
this.eventManager = this.createEventManager(e), this.syncEngine = this.createSyncEngine(e,
|
|
13758
13758
|
/* startAsPrimary=*/ !t.synchronizeTabs), this.sharedClientState.onlineStateHandler = t => da(this.syncEngine, t, 1 /* SharedClientState */),
|
|
13759
|
-
this.remoteStore.remoteSyncer.handleCredentialChange =
|
|
13759
|
+
this.remoteStore.remoteSyncer.handleCredentialChange = Pa.bind(null, this.syncEngine),
|
|
13760
13760
|
await Oo(this.remoteStore, this.syncEngine.isPrimaryClient));
|
|
13761
13761
|
}
|
|
13762
13762
|
createEventManager(t) {
|
|
@@ -13771,7 +13771,7 @@ class Ba {
|
|
|
13771
13771
|
}
|
|
13772
13772
|
createRemoteStore(t) {
|
|
13773
13773
|
return e = this.localStore, n = this.datastore, s = t.asyncQueue, i = t => da(this.syncEngine, t, 0 /* RemoteStore */),
|
|
13774
|
-
r = Yr.
|
|
13774
|
+
r = Yr.Pt() ? new Yr : new Jr, new ho(e, n, s, i, r);
|
|
13775
13775
|
var e, n, s, i, r;
|
|
13776
13776
|
/** Re-enables the network. Idempotent. */ }
|
|
13777
13777
|
createSyncEngine(t, e) {
|
|
@@ -13785,7 +13785,7 @@ class Ba {
|
|
|
13785
13785
|
terminate() {
|
|
13786
13786
|
return async function(t) {
|
|
13787
13787
|
const e = j(t);
|
|
13788
|
-
|
|
13788
|
+
M("RemoteStore", "RemoteStore shutting down."), e.Gr.add(5 /* Shutdown */), await fo(e),
|
|
13789
13789
|
e.Hr.shutdown(),
|
|
13790
13790
|
// Set the OnlineState to Unknown (rather than Offline) to avoid potentially
|
|
13791
13791
|
// triggering spurious listener events with cached data, etc.
|
|
@@ -14273,7 +14273,7 @@ class Ha {
|
|
|
14273
14273
|
this.authCredentials = t, this.appCheckCredentials = e, this.asyncQueue = n, this.databaseInfo = s,
|
|
14274
14274
|
this.user = N.UNAUTHENTICATED, this.clientId = rt.A(), this.authCredentialListener = () => Promise.resolve(),
|
|
14275
14275
|
this.authCredentials.start(n, (async t => {
|
|
14276
|
-
|
|
14276
|
+
M("FirestoreClient", "Received user=", t.uid), await this.authCredentialListener(t),
|
|
14277
14277
|
this.user = t;
|
|
14278
14278
|
})),
|
|
14279
14279
|
// Register an empty credentials change listener to activate token refresh.
|
|
@@ -14318,7 +14318,7 @@ class Ha {
|
|
|
14318
14318
|
}
|
|
14319
14319
|
|
|
14320
14320
|
async function Ja(t, e) {
|
|
14321
|
-
t.asyncQueue.verifyOperationInProgress(),
|
|
14321
|
+
t.asyncQueue.verifyOperationInProgress(), M("FirestoreClient", "Initializing OfflineComponentProvider");
|
|
14322
14322
|
const n = await t.getConfiguration();
|
|
14323
14323
|
await e.initialize(n);
|
|
14324
14324
|
let s = n.initialUser;
|
|
@@ -14333,14 +14333,14 @@ async function Ja(t, e) {
|
|
|
14333
14333
|
async function Ya(t, e) {
|
|
14334
14334
|
t.asyncQueue.verifyOperationInProgress();
|
|
14335
14335
|
const n = await Xa(t);
|
|
14336
|
-
|
|
14336
|
+
M("FirestoreClient", "Initializing OnlineComponentProvider");
|
|
14337
14337
|
const s = await t.getConfiguration();
|
|
14338
14338
|
await e.initialize(n, s),
|
|
14339
14339
|
// The CredentialChangeListener of the online component provider takes
|
|
14340
14340
|
// precedence over the offline component provider.
|
|
14341
14341
|
t.setCredentialChangeListener((t => async function(t, e) {
|
|
14342
14342
|
const n = j(t);
|
|
14343
|
-
n.asyncQueue.verifyOperationInProgress(),
|
|
14343
|
+
n.asyncQueue.verifyOperationInProgress(), M("RemoteStore", "RemoteStore received new credentials");
|
|
14344
14344
|
const s = To(n);
|
|
14345
14345
|
// Tear down and re-create our network streams. This will ensure we get a
|
|
14346
14346
|
// fresh auth token for the new user and re-fill the write pipeline with
|
|
@@ -14353,12 +14353,12 @@ async function Ya(t, e) {
|
|
|
14353
14353
|
}
|
|
14354
14354
|
|
|
14355
14355
|
async function Xa(t) {
|
|
14356
|
-
return t.offlineComponents || (
|
|
14356
|
+
return t.offlineComponents || (M("FirestoreClient", "Using default OfflineComponentProvider"),
|
|
14357
14357
|
await Ja(t, new Ba)), t.offlineComponents;
|
|
14358
14358
|
}
|
|
14359
14359
|
|
|
14360
14360
|
async function Za(t) {
|
|
14361
|
-
return t.onlineComponents || (
|
|
14361
|
+
return t.onlineComponents || (M("FirestoreClient", "Using default OnlineComponentProvider"),
|
|
14362
14362
|
await Ya(t, new Ka)), t.onlineComponents;
|
|
14363
14363
|
}
|
|
14364
14364
|
|
|
@@ -14463,7 +14463,7 @@ function uc(t, e) {
|
|
|
14463
14463
|
return t.asyncQueue.enqueueAndForget((async () => async function(t, e, n) {
|
|
14464
14464
|
try {
|
|
14465
14465
|
const s = await Rr(t, e,
|
|
14466
|
-
/* usePreviousResults= */ !0), i = new ia(e, s.zn), r = i.
|
|
14466
|
+
/* usePreviousResults= */ !0), i = new ia(e, s.zn), r = i.Po(s.documents), o = i.applyChanges(r,
|
|
14467
14467
|
/* updateLimboDocuments= */ !1);
|
|
14468
14468
|
n.resolve(o.snapshot);
|
|
14469
14469
|
} catch (t) {
|
|
@@ -14753,7 +14753,7 @@ function Rc(t, e) {
|
|
|
14753
14753
|
* user-supplied `FirestoreSettings` object. This is a separate type so that
|
|
14754
14754
|
* defaults can be supplied and the value can be checked for equality.
|
|
14755
14755
|
*/
|
|
14756
|
-
class
|
|
14756
|
+
class bc {
|
|
14757
14757
|
constructor(t) {
|
|
14758
14758
|
var e;
|
|
14759
14759
|
if (void 0 === t.host) {
|
|
@@ -14793,14 +14793,14 @@ class Pc {
|
|
|
14793
14793
|
* The Cloud Firestore service interface.
|
|
14794
14794
|
*
|
|
14795
14795
|
* Do not call this constructor directly. Instead, use {@link getFirestore}.
|
|
14796
|
-
*/ class
|
|
14796
|
+
*/ class Pc {
|
|
14797
14797
|
/** @hideconstructor */
|
|
14798
14798
|
constructor(t, e, n) {
|
|
14799
14799
|
this._authCredentials = e, this._appCheckCredentials = n,
|
|
14800
14800
|
/**
|
|
14801
14801
|
* Whether it's a Firestore or Firestore Lite instance.
|
|
14802
14802
|
*/
|
|
14803
|
-
this.type = "firestore-lite", this._persistenceKey = "(lite)", this._settings = new
|
|
14803
|
+
this.type = "firestore-lite", this._persistenceKey = "(lite)", this._settings = new bc({}),
|
|
14804
14804
|
this._settingsFrozen = !1, t instanceof mc ? this._databaseId = t : (this._app = t,
|
|
14805
14805
|
this._databaseId = function(t) {
|
|
14806
14806
|
if (!Object.prototype.hasOwnProperty.apply(t.options, [ "projectId" ])) throw new W(Q.INVALID_ARGUMENT, '"projectId" not provided in firebase.initializeApp.');
|
|
@@ -14835,7 +14835,7 @@ class Pc {
|
|
|
14835
14835
|
}
|
|
14836
14836
|
_setSettings(t) {
|
|
14837
14837
|
if (this._settingsFrozen) throw new W(Q.FAILED_PRECONDITION, "Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.");
|
|
14838
|
-
this._settings = new
|
|
14838
|
+
this._settings = new bc(t), void 0 !== t.credentials && (this._authCredentials = function(t) {
|
|
14839
14839
|
if (!t) return new H;
|
|
14840
14840
|
switch (t.type) {
|
|
14841
14841
|
case "gapi":
|
|
@@ -14881,14 +14881,14 @@ class Pc {
|
|
|
14881
14881
|
*/
|
|
14882
14882
|
return function(t) {
|
|
14883
14883
|
const e = gc.get(t);
|
|
14884
|
-
e && (
|
|
14884
|
+
e && (M("ComponentProvider", "Removing Datastore"), gc.delete(t), e.terminate());
|
|
14885
14885
|
}(this), Promise.resolve();
|
|
14886
14886
|
}
|
|
14887
14887
|
}
|
|
14888
14888
|
|
|
14889
14889
|
function vc(t, e, n, s = {}) {
|
|
14890
14890
|
var i;
|
|
14891
|
-
const r = (t = Ac(t,
|
|
14891
|
+
const r = (t = Ac(t, Pc))._getSettings();
|
|
14892
14892
|
if ("firestore.googleapis.com" !== r.host && r.host !== e && L("Host has been set in both settings() and useEmulator(), emulator host will be used"),
|
|
14893
14893
|
t._setSettings(Object.assign(Object.assign({}, r), {
|
|
14894
14894
|
host: `${e}:${n}`,
|
|
@@ -15015,7 +15015,7 @@ function vc(t, e, n, s = {}) {
|
|
|
15015
15015
|
}
|
|
15016
15016
|
|
|
15017
15017
|
function Cc(t, e, ...n) {
|
|
15018
|
-
if (t = T(t), yc("collection", "path", e), t instanceof
|
|
15018
|
+
if (t = T(t), yc("collection", "path", e), t instanceof Pc) {
|
|
15019
15019
|
const s = _t.fromString(e, ...n);
|
|
15020
15020
|
return Ec(s), new Dc(t, /* converter= */ null, s);
|
|
15021
15021
|
}
|
|
@@ -15040,7 +15040,7 @@ function Cc(t, e, ...n) {
|
|
|
15040
15040
|
* will be included. Cannot contain a slash.
|
|
15041
15041
|
* @returns The created `Query`.
|
|
15042
15042
|
*/ function Nc(t, e) {
|
|
15043
|
-
if (t = Ac(t,
|
|
15043
|
+
if (t = Ac(t, Pc), yc("collectionGroup", "collection id", e), e.indexOf("/") >= 0) throw new W(Q.INVALID_ARGUMENT, `Invalid collection ID '${e}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);
|
|
15044
15044
|
return new Sc(t,
|
|
15045
15045
|
/* converter= */ null,
|
|
15046
15046
|
/**
|
|
@@ -15056,7 +15056,7 @@ function kc(t, e, ...n) {
|
|
|
15056
15056
|
if (t = T(t),
|
|
15057
15057
|
// We allow omission of 'pathString' but explicitly prohibit passing in both
|
|
15058
15058
|
// 'undefined' and 'null'.
|
|
15059
|
-
1 === arguments.length && (e = rt.A()), yc("doc", "path", e), t instanceof
|
|
15059
|
+
1 === arguments.length && (e = rt.A()), yc("doc", "path", e), t instanceof Pc) {
|
|
15060
15060
|
const s = _t.fromString(e, ...n);
|
|
15061
15061
|
return Tc(s), new Vc(t,
|
|
15062
15062
|
/* converter= */ null, new Nt(s));
|
|
@@ -15135,7 +15135,7 @@ function kc(t, e, ...n) {
|
|
|
15135
15135
|
// after page comes into foreground.
|
|
15136
15136
|
this.Ra = () => {
|
|
15137
15137
|
const t = no();
|
|
15138
|
-
t &&
|
|
15138
|
+
t && M("AsyncQueue", "Visibility state changed to " + t.visibilityState), this.ur.er();
|
|
15139
15139
|
};
|
|
15140
15140
|
const t = no();
|
|
15141
15141
|
t && "function" == typeof t.addEventListener && t.addEventListener("visibilitychange", this.Ra);
|
|
@@ -15151,9 +15151,9 @@ function kc(t, e, ...n) {
|
|
|
15151
15151
|
this.enqueue(t);
|
|
15152
15152
|
}
|
|
15153
15153
|
enqueueAndForgetEvenWhileRestricted(t) {
|
|
15154
|
-
this.
|
|
15154
|
+
this.ba(),
|
|
15155
15155
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
15156
|
-
this.
|
|
15156
|
+
this.Pa(t);
|
|
15157
15157
|
}
|
|
15158
15158
|
enterRestrictedMode(t) {
|
|
15159
15159
|
if (!this.ya) {
|
|
@@ -15163,14 +15163,14 @@ function kc(t, e, ...n) {
|
|
|
15163
15163
|
}
|
|
15164
15164
|
}
|
|
15165
15165
|
enqueue(t) {
|
|
15166
|
-
if (this.
|
|
15166
|
+
if (this.ba(), this.ya)
|
|
15167
15167
|
// Return a Promise which never resolves.
|
|
15168
15168
|
return new Promise((() => {}));
|
|
15169
15169
|
// Create a deferred Promise that we can return to the callee. This
|
|
15170
15170
|
// allows us to return a "hanging Promise" only to the callee and still
|
|
15171
15171
|
// advance the queue even when the operation is not run.
|
|
15172
15172
|
const e = new G;
|
|
15173
|
-
return this.
|
|
15173
|
+
return this.Pa((() => this.ya && this.Ia ? Promise.resolve() : (t().then(e.resolve, e.reject),
|
|
15174
15174
|
e.promise))).then((() => e.promise));
|
|
15175
15175
|
}
|
|
15176
15176
|
enqueueRetryable(t) {
|
|
@@ -15186,7 +15186,7 @@ function kc(t, e, ...n) {
|
|
|
15186
15186
|
} catch (t) {
|
|
15187
15187
|
if (!ei(t)) throw t;
|
|
15188
15188
|
// Failure will be handled by AsyncQueue
|
|
15189
|
-
|
|
15189
|
+
M("AsyncQueue", "Operation failed with retryable error: " + t);
|
|
15190
15190
|
}
|
|
15191
15191
|
this.ga.length > 0 &&
|
|
15192
15192
|
// If there are additional operations, we re-schedule `retryNextOp()`.
|
|
@@ -15202,7 +15202,7 @@ function kc(t, e, ...n) {
|
|
|
15202
15202
|
this.ur.Zi((() => this.va()));
|
|
15203
15203
|
}
|
|
15204
15204
|
}
|
|
15205
|
-
|
|
15205
|
+
Pa(t) {
|
|
15206
15206
|
const e = this.ma.then((() => (this.Ea = !0, t().catch((t => {
|
|
15207
15207
|
this.Ta = t, this.Ea = !1;
|
|
15208
15208
|
const e =
|
|
@@ -15235,18 +15235,18 @@ function kc(t, e, ...n) {
|
|
|
15235
15235
|
// Re-throw the error so that this.tail becomes a rejected Promise and
|
|
15236
15236
|
// all further attempts to chain (via .then) will just short-circuit
|
|
15237
15237
|
// and return the rejected Promise.
|
|
15238
|
-
throw
|
|
15238
|
+
throw F("INTERNAL UNHANDLED ERROR: ", e), t;
|
|
15239
15239
|
})).then((t => (this.Ea = !1, t))))));
|
|
15240
15240
|
return this.ma = e, e;
|
|
15241
15241
|
}
|
|
15242
15242
|
enqueueAfterDelay(t, e, n) {
|
|
15243
|
-
this.
|
|
15243
|
+
this.ba(),
|
|
15244
15244
|
// Fast-forward delays for timerIds that have been overriden.
|
|
15245
15245
|
this.Aa.indexOf(t) > -1 && (e = 0);
|
|
15246
15246
|
const s = Lo.createAndSchedule(this, t, e, n, (t => this.Va(t)));
|
|
15247
15247
|
return this.pa.push(s), s;
|
|
15248
15248
|
}
|
|
15249
|
-
|
|
15249
|
+
ba() {
|
|
15250
15250
|
this.Ta && U();
|
|
15251
15251
|
}
|
|
15252
15252
|
verifyOperationInProgress() {}
|
|
@@ -15297,7 +15297,7 @@ function kc(t, e, ...n) {
|
|
|
15297
15297
|
}
|
|
15298
15298
|
}
|
|
15299
15299
|
|
|
15300
|
-
function
|
|
15300
|
+
function Mc(t) {
|
|
15301
15301
|
/**
|
|
15302
15302
|
* Returns true if obj is an object and contains at least one of the specified
|
|
15303
15303
|
* methods.
|
|
@@ -15332,7 +15332,7 @@ function Fc(t) {
|
|
|
15332
15332
|
*/ (t, [ "next", "error", "complete" ]);
|
|
15333
15333
|
}
|
|
15334
15334
|
|
|
15335
|
-
class
|
|
15335
|
+
class Fc {
|
|
15336
15336
|
constructor() {
|
|
15337
15337
|
this._progressObserver = {}, this._taskCompletionResolver = new G, this._lastProgress = {
|
|
15338
15338
|
taskState: "Running",
|
|
@@ -15423,7 +15423,7 @@ class Mc {
|
|
|
15423
15423
|
*
|
|
15424
15424
|
* Do not call this constructor directly. Instead, use {@link getFirestore}.
|
|
15425
15425
|
*/
|
|
15426
|
-
class Bc extends
|
|
15426
|
+
class Bc extends Pc {
|
|
15427
15427
|
/** @hideconstructor */
|
|
15428
15428
|
constructor(t, e, n) {
|
|
15429
15429
|
super(t, e, n),
|
|
@@ -15613,7 +15613,7 @@ function zc(t) {
|
|
|
15613
15613
|
return t._queue.enqueueAndForgetEvenWhileRestricted((async () => {
|
|
15614
15614
|
try {
|
|
15615
15615
|
await async function(t) {
|
|
15616
|
-
if (!Xs.
|
|
15616
|
+
if (!Xs.Pt()) return Promise.resolve();
|
|
15617
15617
|
const e = t + "main";
|
|
15618
15618
|
await Xs.delete(e);
|
|
15619
15619
|
}(ur(t._databaseId, t._persistenceKey)), e.resolve();
|
|
@@ -15701,7 +15701,7 @@ function zc(t) {
|
|
|
15701
15701
|
* A `LoadBundleTask` object, which notifies callers with progress updates, and completion
|
|
15702
15702
|
* or error events. It can be used as a `Promise<LoadBundleTaskProgress>`.
|
|
15703
15703
|
*/ function Zc(t, e) {
|
|
15704
|
-
const n = Kc(t = Ac(t, Bc)), s = new
|
|
15704
|
+
const n = Kc(t = Ac(t, Bc)), s = new Fc;
|
|
15705
15705
|
return dc(n, t._databaseId, e, s), s;
|
|
15706
15706
|
}
|
|
15707
15707
|
|
|
@@ -16048,15 +16048,15 @@ function hu(t) {
|
|
|
16048
16048
|
var e;
|
|
16049
16049
|
const n = null === (e = this.path) || void 0 === e ? void 0 : e.child(t), s = this.$a({
|
|
16050
16050
|
path: n,
|
|
16051
|
-
|
|
16051
|
+
Ma: !1
|
|
16052
16052
|
});
|
|
16053
|
-
return s.
|
|
16053
|
+
return s.Fa(t), s;
|
|
16054
16054
|
}
|
|
16055
16055
|
La(t) {
|
|
16056
16056
|
var e;
|
|
16057
16057
|
const n = null === (e = this.path) || void 0 === e ? void 0 : e.child(t), s = this.$a({
|
|
16058
16058
|
path: n,
|
|
16059
|
-
|
|
16059
|
+
Ma: !1
|
|
16060
16060
|
});
|
|
16061
16061
|
return s.ka(), s;
|
|
16062
16062
|
}
|
|
@@ -16065,7 +16065,7 @@ function hu(t) {
|
|
|
16065
16065
|
// undefined.
|
|
16066
16066
|
return this.$a({
|
|
16067
16067
|
path: void 0,
|
|
16068
|
-
|
|
16068
|
+
Ma: !0
|
|
16069
16069
|
});
|
|
16070
16070
|
}
|
|
16071
16071
|
Ua(t) {
|
|
@@ -16077,9 +16077,9 @@ function hu(t) {
|
|
|
16077
16077
|
ka() {
|
|
16078
16078
|
// TODO(b/34871131): Remove null check once we have proper paths for fields
|
|
16079
16079
|
// within arrays.
|
|
16080
|
-
if (this.path) for (let t = 0; t < this.path.length; t++) this.
|
|
16080
|
+
if (this.path) for (let t = 0; t < this.path.length; t++) this.Fa(this.path.get(t));
|
|
16081
16081
|
}
|
|
16082
|
-
|
|
16082
|
+
Fa(t) {
|
|
16083
16083
|
if (0 === t.length) throw this.Ua("Document fields must not be empty");
|
|
16084
16084
|
if (hu(this.xa) && au.test(t)) throw this.Ua('Document fields cannot begin and end with "__"');
|
|
16085
16085
|
}
|
|
@@ -16098,7 +16098,7 @@ function hu(t) {
|
|
|
16098
16098
|
methodName: e,
|
|
16099
16099
|
Ka: n,
|
|
16100
16100
|
path: gt.emptyPath(),
|
|
16101
|
-
|
|
16101
|
+
Ma: !1,
|
|
16102
16102
|
qa: s
|
|
16103
16103
|
}, this.databaseId, this.k, this.ignoreUndefinedProperties);
|
|
16104
16104
|
}
|
|
@@ -16112,7 +16112,7 @@ function du(t) {
|
|
|
16112
16112
|
/** Parse document data from a set() call. */ function wu(t, e, n, s, i, r = {}) {
|
|
16113
16113
|
const o = t.ja(r.merge || r.mergeFields ? 2 /* MergeSet */ : 0 /* Set */ , e, n, i);
|
|
16114
16114
|
vu("Data must be an object, but it was:", o, s);
|
|
16115
|
-
const a =
|
|
16115
|
+
const a = bu(s, o);
|
|
16116
16116
|
let c, u;
|
|
16117
16117
|
if (r.merge) c = new yt(o.fieldMask), u = o.fieldTransforms; else if (r.mergeFields) {
|
|
16118
16118
|
const t = [];
|
|
@@ -16158,7 +16158,7 @@ class _u extends ru {
|
|
|
16158
16158
|
xa: 3 /* Argument */ ,
|
|
16159
16159
|
Ka: e.settings.Ka,
|
|
16160
16160
|
methodName: t._methodName,
|
|
16161
|
-
|
|
16161
|
+
Ma: n
|
|
16162
16162
|
}, e.databaseId, e.k, e.ignoreUndefinedProperties);
|
|
16163
16163
|
}
|
|
16164
16164
|
|
|
@@ -16206,7 +16206,7 @@ class Tu extends ru {
|
|
|
16206
16206
|
super(t), this.Wa = e;
|
|
16207
16207
|
}
|
|
16208
16208
|
_toFieldTransform(t) {
|
|
16209
|
-
const e = new Ge(t.k,
|
|
16209
|
+
const e = new Ge(t.k, Me(t.k, this.Wa));
|
|
16210
16210
|
return new Je(t.path, e);
|
|
16211
16211
|
}
|
|
16212
16212
|
isEqual(t) {
|
|
@@ -16280,12 +16280,12 @@ class Tu extends ru {
|
|
|
16280
16280
|
* @returns The parsed value, or null if the value was a FieldValue sentinel
|
|
16281
16281
|
* that should not be included in the resulting parsed data.
|
|
16282
16282
|
*/ function Ru(t, e) {
|
|
16283
|
-
if (
|
|
16283
|
+
if (Pu(
|
|
16284
16284
|
// Unwrap the API type from the Compat SDK. This will return the API type
|
|
16285
16285
|
// from firestore-exp.
|
|
16286
|
-
t = T(t))) return vu("Unsupported field value:", e, t),
|
|
16286
|
+
t = T(t))) return vu("Unsupported field value:", e, t), bu(t, e);
|
|
16287
16287
|
if (t instanceof ru)
|
|
16288
|
-
// FieldValues usually parse into transforms (except
|
|
16288
|
+
// FieldValues usually parse into transforms (except deleteField())
|
|
16289
16289
|
// in which case we do not want to include this field in our parsed data
|
|
16290
16290
|
// (as doing so will overwrite the field directly prior to the transform
|
|
16291
16291
|
// trying to transform it). So we don't add this location to
|
|
@@ -16321,7 +16321,7 @@ class Tu extends ru {
|
|
|
16321
16321
|
// the set of values to be included for the IN query) that may directly
|
|
16322
16322
|
// contain additional arrays (each representing an individual field
|
|
16323
16323
|
// value), so we disable this validation.
|
|
16324
|
-
if (e.settings.
|
|
16324
|
+
if (e.settings.Ma && 4 /* ArrayArgument */ !== e.xa) throw e.Ua("Nested arrays are not supported");
|
|
16325
16325
|
return function(t, e) {
|
|
16326
16326
|
const n = [];
|
|
16327
16327
|
let s = 0;
|
|
@@ -16345,7 +16345,7 @@ class Tu extends ru {
|
|
|
16345
16345
|
if (null === (t = T(t))) return {
|
|
16346
16346
|
nullValue: "NULL_VALUE"
|
|
16347
16347
|
};
|
|
16348
|
-
if ("number" == typeof t) return
|
|
16348
|
+
if ("number" == typeof t) return Me(e.k, t);
|
|
16349
16349
|
if ("boolean" == typeof t) return {
|
|
16350
16350
|
booleanValue: t
|
|
16351
16351
|
};
|
|
@@ -16394,7 +16394,7 @@ class Tu extends ru {
|
|
|
16394
16394
|
*/ (t, e);
|
|
16395
16395
|
}
|
|
16396
16396
|
|
|
16397
|
-
function
|
|
16397
|
+
function bu(t, e) {
|
|
16398
16398
|
const n = {};
|
|
16399
16399
|
return dt(t) ?
|
|
16400
16400
|
// If we encounter an empty object, we explicitly add it to the update
|
|
@@ -16409,12 +16409,12 @@ function Pu(t, e) {
|
|
|
16409
16409
|
};
|
|
16410
16410
|
}
|
|
16411
16411
|
|
|
16412
|
-
function
|
|
16412
|
+
function Pu(t) {
|
|
16413
16413
|
return !("object" != typeof t || null === t || t instanceof Array || t instanceof Date || t instanceof ut || t instanceof ou || t instanceof iu || t instanceof Vc || t instanceof ru);
|
|
16414
16414
|
}
|
|
16415
16415
|
|
|
16416
16416
|
function vu(t, e, n) {
|
|
16417
|
-
if (!
|
|
16417
|
+
if (!Pu(n) || !function(t) {
|
|
16418
16418
|
return "object" == typeof t && null !== t && (Object.getPrototypeOf(t) === Object.prototype || null === Object.getPrototypeOf(t));
|
|
16419
16419
|
}(n)) {
|
|
16420
16420
|
const s = Ic(n);
|
|
@@ -16430,7 +16430,7 @@ function vu(t, e, n) {
|
|
|
16430
16430
|
// FieldPath.
|
|
16431
16431
|
e = T(e)) instanceof nu) return e._internalPath;
|
|
16432
16432
|
if ("string" == typeof e) return Du(t, e);
|
|
16433
|
-
throw Cu("Field path arguments must be of type string or
|
|
16433
|
+
throw Cu("Field path arguments must be of type string or ", t,
|
|
16434
16434
|
/* hasConverter= */ !1,
|
|
16435
16435
|
/* path= */ void 0, n);
|
|
16436
16436
|
}
|
|
@@ -16628,7 +16628,7 @@ function Cu(t, e, n, s, i) {
|
|
|
16628
16628
|
* For a `DocumentSnapshot` that points to a non-existing document, any data
|
|
16629
16629
|
* access will return 'undefined'. You can use the `exists()` method to
|
|
16630
16630
|
* explicitly verify a document's existence.
|
|
16631
|
-
*/ class
|
|
16631
|
+
*/ class Mu extends ku {
|
|
16632
16632
|
/** @hideconstructor protected */
|
|
16633
16633
|
constructor(t, e, n, s, i, r) {
|
|
16634
16634
|
super(t, e, n, s, r), this._firestore = t, this._firestoreImpl = t, this.metadata = i;
|
|
@@ -16643,7 +16643,7 @@ function Cu(t, e, n, s, i) {
|
|
|
16643
16643
|
* Retrieves all fields in the document as an `Object`. Returns `undefined` if
|
|
16644
16644
|
* the document doesn't exist.
|
|
16645
16645
|
*
|
|
16646
|
-
* By default, `
|
|
16646
|
+
* By default, `serverTimestamp()` values that have not yet been
|
|
16647
16647
|
* set to their final value will be returned as `null`. You can override
|
|
16648
16648
|
* this by passing an options object.
|
|
16649
16649
|
*
|
|
@@ -16657,7 +16657,7 @@ function Cu(t, e, n, s, i) {
|
|
|
16657
16657
|
if (this._converter) {
|
|
16658
16658
|
// We only want to use the converter and create a new DocumentSnapshot
|
|
16659
16659
|
// if a converter has been provided.
|
|
16660
|
-
const e = new
|
|
16660
|
+
const e = new Fu(this._firestore, this._userDataWriter, this._key, this._document, this.metadata,
|
|
16661
16661
|
/* converter= */ null);
|
|
16662
16662
|
return this._converter.fromFirestore(e, t);
|
|
16663
16663
|
}
|
|
@@ -16668,7 +16668,7 @@ function Cu(t, e, n, s, i) {
|
|
|
16668
16668
|
* Retrieves the field specified by `fieldPath`. Returns `undefined` if the
|
|
16669
16669
|
* document or field doesn't exist.
|
|
16670
16670
|
*
|
|
16671
|
-
* By default, a `
|
|
16671
|
+
* By default, a `serverTimestamp()` that has not yet been set to
|
|
16672
16672
|
* its final value will be returned as `null`. You can override this by
|
|
16673
16673
|
* passing an options object.
|
|
16674
16674
|
*
|
|
@@ -16700,11 +16700,11 @@ function Cu(t, e, n, s, i) {
|
|
|
16700
16700
|
* `DocumentSnapshot`. Since query results contain only existing documents, the
|
|
16701
16701
|
* `exists` property will always be true and `data()` will never return
|
|
16702
16702
|
* 'undefined'.
|
|
16703
|
-
*/ class
|
|
16703
|
+
*/ class Fu extends Mu {
|
|
16704
16704
|
/**
|
|
16705
16705
|
* Retrieves all fields in the document as an `Object`.
|
|
16706
16706
|
*
|
|
16707
|
-
* By default, `
|
|
16707
|
+
* By default, `serverTimestamp()` values that have not yet been
|
|
16708
16708
|
* set to their final value will be returned as `null`. You can override
|
|
16709
16709
|
* this by passing an options object.
|
|
16710
16710
|
*
|
|
@@ -16749,7 +16749,7 @@ function Cu(t, e, n, s, i) {
|
|
|
16749
16749
|
* @param thisArg - The `this` binding for the callback.
|
|
16750
16750
|
*/ forEach(t, e) {
|
|
16751
16751
|
this._snapshot.docs.forEach((n => {
|
|
16752
|
-
t.call(e, new
|
|
16752
|
+
t.call(e, new Fu(this._firestore, this._userDataWriter, n.key, n, new Ou(this._snapshot.mutatedKeys.has(n.key), this._snapshot.fromCache), this.query.converter));
|
|
16753
16753
|
}));
|
|
16754
16754
|
}
|
|
16755
16755
|
/**
|
|
@@ -16770,7 +16770,7 @@ function Cu(t, e, n, s, i) {
|
|
|
16770
16770
|
let e = 0;
|
|
16771
16771
|
return t._snapshot.docChanges.map((n => ({
|
|
16772
16772
|
type: "added",
|
|
16773
|
-
doc: new
|
|
16773
|
+
doc: new Fu(t._firestore, t._userDataWriter, n.doc.key, n.doc, new Ou(t._snapshot.mutatedKeys.has(n.doc.key), t._snapshot.fromCache), t.query.converter),
|
|
16774
16774
|
oldIndex: -1,
|
|
16775
16775
|
newIndex: e++
|
|
16776
16776
|
})));
|
|
@@ -16780,7 +16780,7 @@ function Cu(t, e, n, s, i) {
|
|
|
16780
16780
|
// to lookup the index of a document.
|
|
16781
16781
|
let n = t._snapshot.oldDocs;
|
|
16782
16782
|
return t._snapshot.docChanges.filter((t => e || 3 /* Metadata */ !== t.type)).map((e => {
|
|
16783
|
-
const s = new
|
|
16783
|
+
const s = new Fu(t._firestore, t._userDataWriter, e.doc.key, e.doc, new Ou(t._snapshot.mutatedKeys.has(e.doc.key), t._snapshot.fromCache), t.query.converter);
|
|
16784
16784
|
let i = -1, r = -1;
|
|
16785
16785
|
return 0 /* Added */ !== e.type && (i = n.indexOf(e.doc.key), n = n.delete(e.doc.key)),
|
|
16786
16786
|
1 /* Removed */ !== e.type && (n = n.add(e.doc), r = n.indexOf(e.doc.key)), {
|
|
@@ -16821,7 +16821,7 @@ function Bu(t) {
|
|
|
16821
16821
|
* @param right - A snapshot to compare.
|
|
16822
16822
|
* @returns true if the snapshots are equal.
|
|
16823
16823
|
*/ function Uu(t, e) {
|
|
16824
|
-
return t instanceof
|
|
16824
|
+
return t instanceof Mu && e instanceof Mu ? t._firestore === e._firestore && t._key.isEqual(e._key) && (null === t._document ? null === e._document : t._document.isEqual(e._document)) && t._converter === e._converter : t instanceof Lu && e instanceof Lu && (t._firestore === e._firestore && $c(t.query, e.query) && t.metadata.isEqual(e.metadata) && t._snapshot.isEqual(e._snapshot));
|
|
16825
16825
|
}
|
|
16826
16826
|
|
|
16827
16827
|
/**
|
|
@@ -16873,7 +16873,7 @@ class Qu extends Ku {
|
|
|
16873
16873
|
const e = du(t.firestore), n = function(t, e, n, s, i, r, o) {
|
|
16874
16874
|
let a;
|
|
16875
16875
|
if (i.isKeyField()) {
|
|
16876
|
-
if ("array-contains" /* ARRAY_CONTAINS */ === r || "array-contains-any" /* ARRAY_CONTAINS_ANY */ === r) throw new W(Q.INVALID_ARGUMENT, `Invalid Query. You can't perform '${r}' queries on
|
|
16876
|
+
if ("array-contains" /* ARRAY_CONTAINS */ === r || "array-contains-any" /* ARRAY_CONTAINS_ANY */ === r) throw new W(Q.INVALID_ARGUMENT, `Invalid Query. You can't perform '${r}' queries on documentId().`);
|
|
16877
16877
|
if ("in" /* IN */ === r || "not-in" /* NOT_IN */ === r) {
|
|
16878
16878
|
oh(o, r);
|
|
16879
16879
|
const e = [];
|
|
@@ -17090,9 +17090,9 @@ function sh(...t) {
|
|
|
17090
17090
|
// the provided document. Without the key (by using the explicit sort
|
|
17091
17091
|
// orders), multiple documents could match the position, yielding duplicate
|
|
17092
17092
|
// results.
|
|
17093
|
-
for (const n of
|
|
17093
|
+
for (const n of Pe(t)) if (n.field.isKeyField()) r.push(Bt(e, s.key)); else {
|
|
17094
17094
|
const t = s.data.field(n.field);
|
|
17095
|
-
if (
|
|
17095
|
+
if (Pt(t)) throw new W(Q.INVALID_ARGUMENT, 'Invalid query. You are trying to start or end a query using a document for which the field "' + n.field + '" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)');
|
|
17096
17096
|
if (null === t) {
|
|
17097
17097
|
const t = n.field.canonicalString();
|
|
17098
17098
|
throw new W(Q.INVALID_ARGUMENT, `Invalid query. You are trying to start or end a query using a document for which the field '${t}' (used as the orderBy) does not exist.`);
|
|
@@ -17115,9 +17115,9 @@ function sh(...t) {
|
|
|
17115
17115
|
const c = i[r];
|
|
17116
17116
|
if (o[r].field.isKeyField()) {
|
|
17117
17117
|
if ("string" != typeof c) throw new W(Q.INVALID_ARGUMENT, `Invalid query. Expected a string for document ID in ${s}(), but got a ${typeof c}`);
|
|
17118
|
-
if (!
|
|
17118
|
+
if (!be(t) && -1 !== c.indexOf("/")) throw new W(Q.INVALID_ARGUMENT, `Invalid query. When querying a collection and ordering by documentId(), the value passed to ${s}() must be a plain document ID, but '${c}' contains a slash.`);
|
|
17119
17119
|
const n = t.path.child(_t.fromString(c));
|
|
17120
|
-
if (!Nt.isDocumentKey(n)) throw new W(Q.INVALID_ARGUMENT, `Invalid query. When querying a collection group and ordering by
|
|
17120
|
+
if (!Nt.isDocumentKey(n)) throw new W(Q.INVALID_ARGUMENT, `Invalid query. When querying a collection group and ordering by documentId(), the value passed to ${s}() must result in a valid document path, but '${n}' is not because it contains an odd number of segments.`);
|
|
17121
17121
|
const i = new Nt(n);
|
|
17122
17122
|
a.push(Bt(e, i));
|
|
17123
17123
|
} else {
|
|
@@ -17137,14 +17137,14 @@ function sh(...t) {
|
|
|
17137
17137
|
|
|
17138
17138
|
function rh(t, e, n) {
|
|
17139
17139
|
if ("string" == typeof (n = T(n))) {
|
|
17140
|
-
if ("" === n) throw new W(Q.INVALID_ARGUMENT, "Invalid query. When querying with
|
|
17141
|
-
if (!
|
|
17140
|
+
if ("" === n) throw new W(Q.INVALID_ARGUMENT, "Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");
|
|
17141
|
+
if (!be(e) && -1 !== n.indexOf("/")) throw new W(Q.INVALID_ARGUMENT, `Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${n}' contains a '/' character.`);
|
|
17142
17142
|
const s = e.path.child(_t.fromString(n));
|
|
17143
|
-
if (!Nt.isDocumentKey(s)) throw new W(Q.INVALID_ARGUMENT, `Invalid query. When querying a collection group by
|
|
17143
|
+
if (!Nt.isDocumentKey(s)) throw new W(Q.INVALID_ARGUMENT, `Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${s}' is not because it has an odd number of segments (${s.length}).`);
|
|
17144
17144
|
return Bt(t, new Nt(s));
|
|
17145
17145
|
}
|
|
17146
17146
|
if (n instanceof Vc) return Bt(t, n._key);
|
|
17147
|
-
throw new W(Q.INVALID_ARGUMENT, `Invalid query. When querying with
|
|
17147
|
+
throw new W(Q.INVALID_ARGUMENT, `Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${Ic(n)}.`);
|
|
17148
17148
|
}
|
|
17149
17149
|
|
|
17150
17150
|
/**
|
|
@@ -17202,7 +17202,7 @@ function ah(t, e, n) {
|
|
|
17202
17202
|
return t.stringValue;
|
|
17203
17203
|
|
|
17204
17204
|
case 6 /* BlobValue */ :
|
|
17205
|
-
return this.convertBytes(
|
|
17205
|
+
return this.convertBytes(bt(t.bytesValue));
|
|
17206
17206
|
|
|
17207
17207
|
case 7 /* RefValue */ :
|
|
17208
17208
|
return this.convertReference(t.referenceValue);
|
|
@@ -17251,11 +17251,11 @@ function ah(t, e, n) {
|
|
|
17251
17251
|
}
|
|
17252
17252
|
convertDocumentKey(t, e) {
|
|
17253
17253
|
const n = _t.fromString(t);
|
|
17254
|
-
q(
|
|
17254
|
+
q(Ps(n));
|
|
17255
17255
|
const s = new mc(n.get(1), n.get(3)), i = new Nt(n.popFirst(5));
|
|
17256
17256
|
return s.isEqual(e) ||
|
|
17257
17257
|
// TODO(b/64130202): Somehow support foreign references.
|
|
17258
|
-
|
|
17258
|
+
F(`Document ${i} contains a document reference within a different database (${s.projectId}/${s.database}) which is not supported. It will be treated as a reference in the current database (${e.projectId}/${e.database}) instead.`),
|
|
17259
17259
|
i;
|
|
17260
17260
|
}
|
|
17261
17261
|
}
|
|
@@ -17464,7 +17464,7 @@ class wh extends ch {
|
|
|
17464
17464
|
*/ function _h(t) {
|
|
17465
17465
|
t = Ac(t, Vc);
|
|
17466
17466
|
const e = Ac(t.firestore, Bc), n = Kc(e), s = new wh(e);
|
|
17467
|
-
return ac(n, t._key).then((n => new
|
|
17467
|
+
return ac(n, t._key).then((n => new Mu(e, s, t._key, n, new Ou(null !== n && n.hasLocalMutations,
|
|
17468
17468
|
/* fromCache= */ !0), t.converter)));
|
|
17469
17469
|
}
|
|
17470
17470
|
|
|
@@ -17524,7 +17524,7 @@ class wh extends ch {
|
|
|
17524
17524
|
function Th(t, e, n) {
|
|
17525
17525
|
t = Ac(t, Vc);
|
|
17526
17526
|
const s = Ac(t.firestore, Bc), i = uh(t.converter, e, n);
|
|
17527
|
-
return
|
|
17527
|
+
return Ph(s, [ wu(du(s), "setDoc", t._key, i, null !== t.converter, n).toMutation(t._key, Ze.none()) ]);
|
|
17528
17528
|
}
|
|
17529
17529
|
|
|
17530
17530
|
function Eh(t, e, n, ...s) {
|
|
@@ -17535,7 +17535,7 @@ function Eh(t, e, n, ...s) {
|
|
|
17535
17535
|
// For Compat types, we have to "extract" the underlying types before
|
|
17536
17536
|
// performing validation.
|
|
17537
17537
|
e = T(e)) || e instanceof nu ? Iu(r, "updateDoc", t._key, e, n, s) : Eu(r, "updateDoc", t._key, e);
|
|
17538
|
-
return
|
|
17538
|
+
return Ph(i, [ o.toMutation(t._key, Ze.exists(!0)) ]);
|
|
17539
17539
|
}
|
|
17540
17540
|
|
|
17541
17541
|
/**
|
|
@@ -17545,7 +17545,7 @@ function Eh(t, e, n, ...s) {
|
|
|
17545
17545
|
* @returns A Promise resolved once the document has been successfully
|
|
17546
17546
|
* deleted from the backend (note that it won't resolve while you're offline).
|
|
17547
17547
|
*/ function Ih(t) {
|
|
17548
|
-
return
|
|
17548
|
+
return Ph(Ac(t.firestore, Bc), [ new dn(t._key, Ze.none()) ]);
|
|
17549
17549
|
}
|
|
17550
17550
|
|
|
17551
17551
|
/**
|
|
@@ -17559,7 +17559,7 @@ function Eh(t, e, n, ...s) {
|
|
|
17559
17559
|
* won't resolve while you're offline).
|
|
17560
17560
|
*/ function Ah(t, e) {
|
|
17561
17561
|
const n = Ac(t.firestore, Bc), s = kc(t), i = uh(t.converter, e);
|
|
17562
|
-
return
|
|
17562
|
+
return Ph(n, [ wu(du(t.firestore), "addDoc", s._key, i, null !== t.converter, {}).toMutation(s._key, Ze.exists(!1)) ]).then((() => s));
|
|
17563
17563
|
}
|
|
17564
17564
|
|
|
17565
17565
|
function Rh(t, ...e) {
|
|
@@ -17568,11 +17568,11 @@ function Rh(t, ...e) {
|
|
|
17568
17568
|
let r = {
|
|
17569
17569
|
includeMetadataChanges: !1
|
|
17570
17570
|
}, o = 0;
|
|
17571
|
-
"object" != typeof e[o] ||
|
|
17571
|
+
"object" != typeof e[o] || Mc(e[o]) || (r = e[o], o++);
|
|
17572
17572
|
const a = {
|
|
17573
17573
|
includeMetadataChanges: r.includeMetadataChanges
|
|
17574
17574
|
};
|
|
17575
|
-
if (
|
|
17575
|
+
if (Mc(e[o])) {
|
|
17576
17576
|
const t = e[o];
|
|
17577
17577
|
e[o] = null === (n = t.next) || void 0 === n ? void 0 : n.bind(t), e[o + 1] = null === (s = t.error) || void 0 === s ? void 0 : s.bind(t),
|
|
17578
17578
|
e[o + 2] = null === (i = t.complete) || void 0 === i ? void 0 : i.bind(t);
|
|
@@ -17604,8 +17604,8 @@ function Rh(t, ...e) {
|
|
|
17604
17604
|
}(Kc(u), h, a, c);
|
|
17605
17605
|
}
|
|
17606
17606
|
|
|
17607
|
-
function
|
|
17608
|
-
return lc(Kc(t = Ac(t, Bc)),
|
|
17607
|
+
function bh(t, e) {
|
|
17608
|
+
return lc(Kc(t = Ac(t, Bc)), Mc(e) ? e : {
|
|
17609
17609
|
next: e
|
|
17610
17610
|
});
|
|
17611
17611
|
}
|
|
@@ -17613,7 +17613,7 @@ function Ph(t, e) {
|
|
|
17613
17613
|
/**
|
|
17614
17614
|
* Locally writes `mutations` on the async queue.
|
|
17615
17615
|
* @internal
|
|
17616
|
-
*/ function
|
|
17616
|
+
*/ function Ph(t, e) {
|
|
17617
17617
|
return function(t, e) {
|
|
17618
17618
|
const n = new G;
|
|
17619
17619
|
return t.asyncQueue.enqueueAndForget((async () => la(await sc(t), e, n))), n.promise;
|
|
@@ -17625,7 +17625,7 @@ function Ph(t, e) {
|
|
|
17625
17625
|
* to a {@link DocumentSnapshot}.
|
|
17626
17626
|
*/ function vh(t, e, n) {
|
|
17627
17627
|
const s = n.docs.get(e._key), i = new wh(t);
|
|
17628
|
-
return new
|
|
17628
|
+
return new Mu(t, i, e._key, s, new Ou(n.hasPendingWrites, n.fromCache), e.converter);
|
|
17629
17629
|
}
|
|
17630
17630
|
|
|
17631
17631
|
/**
|
|
@@ -17705,7 +17705,7 @@ function Ph(t, e) {
|
|
|
17705
17705
|
* @returns A `DocumentSnapshot` with the read data.
|
|
17706
17706
|
*/ get(t) {
|
|
17707
17707
|
const e = fh(t, this._firestore), n = new wh(this._firestore);
|
|
17708
|
-
return super.get(t).then((t => new
|
|
17708
|
+
return super.get(t).then((t => new Mu(this._firestore, n, e._key, t._document, new Ou(
|
|
17709
17709
|
/* hasPendingWrites= */ !1,
|
|
17710
17710
|
/* fromCache= */ !1), e.converter)));
|
|
17711
17711
|
}
|
|
@@ -17843,7 +17843,7 @@ function Ph(t, e) {
|
|
|
17843
17843
|
* @returns A {@link WriteBatch} that can be used to atomically execute multiple
|
|
17844
17844
|
* writes.
|
|
17845
17845
|
*/ function $h(t) {
|
|
17846
|
-
return Kc(t = Ac(t, Bc)), new lh(t, (e =>
|
|
17846
|
+
return Kc(t = Ac(t, Bc)), new lh(t, (e => Ph(t, e)));
|
|
17847
17847
|
}
|
|
17848
17848
|
|
|
17849
17849
|
/**
|
|
@@ -17869,10 +17869,10 @@ function Ph(t, e) {
|
|
|
17869
17869
|
return n = Object.assign({
|
|
17870
17870
|
useFetchStreams: e
|
|
17871
17871
|
}, n), i._setSettings(n), i;
|
|
17872
|
-
}), "PUBLIC")), s(C, "3.4.3-
|
|
17872
|
+
}), "PUBLIC")), s(C, "3.4.3-canary.17165a8a4", t),
|
|
17873
17873
|
// BUILD_TARGET will be replaced by values like esm5, esm2017, cjs5, etc during the compilation
|
|
17874
|
-
s(C, "3.4.3-
|
|
17874
|
+
s(C, "3.4.3-canary.17165a8a4", "esm2017");
|
|
17875
17875
|
}("rn", /* useFetchStreams= */ !1);
|
|
17876
17876
|
|
|
17877
|
-
export { ch as AbstractUserDataWriter, iu as Bytes, Lc as CACHE_SIZE_UNLIMITED, Dc as CollectionReference, Vc as DocumentReference,
|
|
17877
|
+
export { ch as AbstractUserDataWriter, iu as Bytes, Lc as CACHE_SIZE_UNLIMITED, Dc as CollectionReference, Vc as DocumentReference, Mu as DocumentSnapshot, nu as FieldPath, ru as FieldValue, Bc as Firestore, W as FirestoreError, ou as GeoPoint, Fc as LoadBundleTask, Sc as Query, Ku as QueryConstraint, Fu as QueryDocumentSnapshot, Lu as QuerySnapshot, Ou as SnapshotMetadata, ut as Timestamp, Vh as Transaction, lh as WriteBatch, mc as _DatabaseId, Nt as _DocumentKey, nt as _EmptyAppCheckTokenProvider, H as _EmptyAuthCredentialsProvider, gt as _FieldPath, Ac as _cast, K as _debugAssert, Tt as _isBase64Available, L as _logWarn, pc as _validateIsNotUsedTogether, Ah as addDoc, kh as arrayRemove, Nh as arrayUnion, zc as clearIndexedDbPersistence, Cc as collection, Nc as collectionGroup, vc as connectFirestoreEmulator, Ih as deleteDoc, Dh as deleteField, Yc as disableNetwork, kc as doc, su as documentId, Qc as enableIndexedDbPersistence, Wc as enableMultiTabIndexedDbPersistence, Jc as enableNetwork, sh as endAt, nh as endBefore, Kc as ensureFirestoreConfigured, Ph as executeWrite, dh as getDoc, _h as getDocFromCache, mh as getDocFromServer, gh as getDocs, yh as getDocsFromCache, ph as getDocsFromServer, qc as getFirestore, xh as increment, Uc as initializeFirestore, Ju as limit, Yu as limitToLast, Zc as loadBundle, tu as namedQuery, Rh as onSnapshot, bh as onSnapshotsInSync, zu as orderBy, ju as query, $c as queryEqual, xc as refEqual, Sh as runTransaction, Ch as serverTimestamp, Th as setDoc, O as setLogLevel, Uu as snapshotEqual, th as startAfter, Zu as startAt, Xc as terminate, Eh as updateDoc, Hc as waitForPendingWrites, Wu as where, $h as writeBatch };
|
|
17878
17878
|
//# sourceMappingURL=index.rn.js.map
|