@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.
@@ -9,7 +9,7 @@ import * as grpc from '@grpc/grpc-js';
9
9
  import * as protoLoader from '@grpc/proto-loader';
10
10
 
11
11
  const name = "@firebase/firestore";
12
- const version$1 = "4.7.5";
12
+ const version$1 = "4.7.6-canary.144bc3709";
13
13
 
14
14
  /**
15
15
  * @license
@@ -62,7 +62,7 @@ User.GOOGLE_CREDENTIALS = new User('google-credentials-uid');
62
62
  User.FIRST_PARTY = new User('first-party-uid');
63
63
  User.MOCK_USER = new User('mock-user');
64
64
 
65
- const version = "11.0.2";
65
+ const version = "11.2.0-canary.144bc3709";
66
66
 
67
67
  /**
68
68
  * @license
@@ -1213,25 +1213,53 @@ class BasePath {
1213
1213
  toArray() {
1214
1214
  return this.segments.slice(this.offset, this.limit());
1215
1215
  }
1216
+ /**
1217
+ * Compare 2 paths segment by segment, prioritizing numeric IDs
1218
+ * (e.g., "__id123__") in numeric ascending order, followed by string
1219
+ * segments in lexicographical order.
1220
+ */
1216
1221
  static comparator(p1, p2) {
1217
1222
  const len = Math.min(p1.length, p2.length);
1218
1223
  for (let i = 0; i < len; i++) {
1219
- const left = p1.get(i);
1220
- const right = p2.get(i);
1221
- if (left < right) {
1222
- return -1;
1223
- }
1224
- if (left > right) {
1225
- return 1;
1224
+ const comparison = BasePath.compareSegments(p1.get(i), p2.get(i));
1225
+ if (comparison !== 0) {
1226
+ return comparison;
1226
1227
  }
1227
1228
  }
1228
- if (p1.length < p2.length) {
1229
+ return Math.sign(p1.length - p2.length);
1230
+ }
1231
+ static compareSegments(lhs, rhs) {
1232
+ const isLhsNumeric = BasePath.isNumericId(lhs);
1233
+ const isRhsNumeric = BasePath.isNumericId(rhs);
1234
+ if (isLhsNumeric && !isRhsNumeric) {
1235
+ // Only lhs is numeric
1229
1236
  return -1;
1230
1237
  }
1231
- if (p1.length > p2.length) {
1238
+ else if (!isLhsNumeric && isRhsNumeric) {
1239
+ // Only rhs is numeric
1232
1240
  return 1;
1233
1241
  }
1234
- return 0;
1242
+ else if (isLhsNumeric && isRhsNumeric) {
1243
+ // both numeric
1244
+ return BasePath.extractNumericId(lhs).compare(BasePath.extractNumericId(rhs));
1245
+ }
1246
+ else {
1247
+ // both non-numeric
1248
+ if (lhs < rhs) {
1249
+ return -1;
1250
+ }
1251
+ if (lhs > rhs) {
1252
+ return 1;
1253
+ }
1254
+ return 0;
1255
+ }
1256
+ }
1257
+ // Checks if a segment is a numeric ID (starts with "__id" and ends with "__").
1258
+ static isNumericId(segment) {
1259
+ return segment.startsWith('__id') && segment.endsWith('__');
1260
+ }
1261
+ static extractNumericId(segment) {
1262
+ return Integer.fromString(segment.substring(4, segment.length - 2));
1235
1263
  }
1236
1264
  }
1237
1265
  /**
@@ -14981,6 +15009,10 @@ class MemoryMutationQueue {
14981
15009
  * See the License for the specific language governing permissions and
14982
15010
  * limitations under the License.
14983
15011
  */
15012
+ /**
15013
+ * The smallest value representable by a 64-bit signed integer (long).
15014
+ */
15015
+ const MIN_LONG_VALUE = '-9223372036854775808';
14984
15016
  function documentEntryMap() {
14985
15017
  return new SortedMap(DocumentKey.comparator);
14986
15018
  }
@@ -15056,7 +15088,10 @@ class MemoryRemoteDocumentCacheImpl {
15056
15088
  // Documents are ordered by key, so we can use a prefix scan to narrow down
15057
15089
  // the documents we need to match the query against.
15058
15090
  const collectionPath = query.path;
15059
- const prefix = new DocumentKey(collectionPath.child(''));
15091
+ // Document keys are ordered first by numeric value ("__id<Long>__"),
15092
+ // then lexicographically by string value. Start the iterator at the minimum
15093
+ // possible Document key value.
15094
+ const prefix = new DocumentKey(collectionPath.child('__id' + MIN_LONG_VALUE + '__'));
15060
15095
  const iterator = this.docs.getIteratorFrom(prefix);
15061
15096
  while (iterator.hasNext()) {
15062
15097
  const { key, value: { document } } = iterator.getNext();