@firebase/firestore 4.7.5 → 4.7.6-canary.144bc3709

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.
@@ -34,7 +34,7 @@ var grpc__namespace = /*#__PURE__*/_interopNamespace(grpc);
34
34
  var protoLoader__namespace = /*#__PURE__*/_interopNamespace(protoLoader);
35
35
 
36
36
  const name = "@firebase/firestore";
37
- const version$1 = "4.7.5";
37
+ const version$1 = "4.7.6-canary.144bc3709";
38
38
 
39
39
  /**
40
40
  * @license
@@ -87,7 +87,7 @@ User.GOOGLE_CREDENTIALS = new User('google-credentials-uid');
87
87
  User.FIRST_PARTY = new User('first-party-uid');
88
88
  User.MOCK_USER = new User('mock-user');
89
89
 
90
- const version = "11.0.2";
90
+ const version = "11.2.0-canary.144bc3709";
91
91
 
92
92
  /**
93
93
  * @license
@@ -1238,25 +1238,53 @@ class BasePath {
1238
1238
  toArray() {
1239
1239
  return this.segments.slice(this.offset, this.limit());
1240
1240
  }
1241
+ /**
1242
+ * Compare 2 paths segment by segment, prioritizing numeric IDs
1243
+ * (e.g., "__id123__") in numeric ascending order, followed by string
1244
+ * segments in lexicographical order.
1245
+ */
1241
1246
  static comparator(p1, p2) {
1242
1247
  const len = Math.min(p1.length, p2.length);
1243
1248
  for (let i = 0; i < len; i++) {
1244
- const left = p1.get(i);
1245
- const right = p2.get(i);
1246
- if (left < right) {
1247
- return -1;
1248
- }
1249
- if (left > right) {
1250
- return 1;
1249
+ const comparison = BasePath.compareSegments(p1.get(i), p2.get(i));
1250
+ if (comparison !== 0) {
1251
+ return comparison;
1251
1252
  }
1252
1253
  }
1253
- if (p1.length < p2.length) {
1254
+ return Math.sign(p1.length - p2.length);
1255
+ }
1256
+ static compareSegments(lhs, rhs) {
1257
+ const isLhsNumeric = BasePath.isNumericId(lhs);
1258
+ const isRhsNumeric = BasePath.isNumericId(rhs);
1259
+ if (isLhsNumeric && !isRhsNumeric) {
1260
+ // Only lhs is numeric
1254
1261
  return -1;
1255
1262
  }
1256
- if (p1.length > p2.length) {
1263
+ else if (!isLhsNumeric && isRhsNumeric) {
1264
+ // Only rhs is numeric
1257
1265
  return 1;
1258
1266
  }
1259
- return 0;
1267
+ else if (isLhsNumeric && isRhsNumeric) {
1268
+ // both numeric
1269
+ return BasePath.extractNumericId(lhs).compare(BasePath.extractNumericId(rhs));
1270
+ }
1271
+ else {
1272
+ // both non-numeric
1273
+ if (lhs < rhs) {
1274
+ return -1;
1275
+ }
1276
+ if (lhs > rhs) {
1277
+ return 1;
1278
+ }
1279
+ return 0;
1280
+ }
1281
+ }
1282
+ // Checks if a segment is a numeric ID (starts with "__id" and ends with "__").
1283
+ static isNumericId(segment) {
1284
+ return segment.startsWith('__id') && segment.endsWith('__');
1285
+ }
1286
+ static extractNumericId(segment) {
1287
+ return bloomBlob.Integer.fromString(segment.substring(4, segment.length - 2));
1260
1288
  }
1261
1289
  }
1262
1290
  /**
@@ -15006,6 +15034,10 @@ class MemoryMutationQueue {
15006
15034
  * See the License for the specific language governing permissions and
15007
15035
  * limitations under the License.
15008
15036
  */
15037
+ /**
15038
+ * The smallest value representable by a 64-bit signed integer (long).
15039
+ */
15040
+ const MIN_LONG_VALUE = '-9223372036854775808';
15009
15041
  function documentEntryMap() {
15010
15042
  return new SortedMap(DocumentKey.comparator);
15011
15043
  }
@@ -15081,7 +15113,10 @@ class MemoryRemoteDocumentCacheImpl {
15081
15113
  // Documents are ordered by key, so we can use a prefix scan to narrow down
15082
15114
  // the documents we need to match the query against.
15083
15115
  const collectionPath = query.path;
15084
- const prefix = new DocumentKey(collectionPath.child(''));
15116
+ // Document keys are ordered first by numeric value ("__id<Long>__"),
15117
+ // then lexicographically by string value. Start the iterator at the minimum
15118
+ // possible Document key value.
15119
+ const prefix = new DocumentKey(collectionPath.child('__id' + MIN_LONG_VALUE + '__'));
15085
15120
  const iterator = this.docs.getIteratorFrom(prefix);
15086
15121
  while (iterator.hasNext()) {
15087
15122
  const { key, value: { document } } = iterator.getNext();