@firebase/firestore 4.7.7-canary.3418ef807 → 4.7.7-canary.4d2fc6e82

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.7-canary.3418ef807";
12
+ const version$1 = "4.7.7-canary.4d2fc6e82";
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.3.0-canary.3418ef807";
65
+ const version = "11.3.0-canary.4d2fc6e82";
66
66
 
67
67
  /**
68
68
  * @license
@@ -820,6 +820,35 @@ function randomBytes(nBytes) {
820
820
  return randomBytes$1(nBytes);
821
821
  }
822
822
 
823
+ /**
824
+ * @license
825
+ * Copyright 2023 Google LLC
826
+ *
827
+ * Licensed under the Apache License, Version 2.0 (the "License");
828
+ * you may not use this file except in compliance with the License.
829
+ * You may obtain a copy of the License at
830
+ *
831
+ * http://www.apache.org/licenses/LICENSE-2.0
832
+ *
833
+ * Unless required by applicable law or agreed to in writing, software
834
+ * distributed under the License is distributed on an "AS IS" BASIS,
835
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
836
+ * See the License for the specific language governing permissions and
837
+ * limitations under the License.
838
+ */
839
+ /**
840
+ * An instance of the Platform's 'TextEncoder' implementation.
841
+ */
842
+ function newTextEncoder() {
843
+ return new TextEncoder();
844
+ }
845
+ /**
846
+ * An instance of the Platform's 'TextDecoder' implementation.
847
+ */
848
+ function newTextDecoder() {
849
+ return new TextDecoder('utf-8');
850
+ }
851
+
823
852
  /**
824
853
  * @license
825
854
  * Copyright 2017 Google LLC
@@ -872,6 +901,19 @@ function primitiveComparator(left, right) {
872
901
  }
873
902
  return 0;
874
903
  }
904
+ /** Compare strings in UTF-8 encoded byte order */
905
+ function compareUtf8Strings(left, right) {
906
+ // Convert the string to UTF-8 encoded bytes
907
+ const encodedLeft = newTextEncoder().encode(left);
908
+ const encodedRight = newTextEncoder().encode(right);
909
+ for (let i = 0; i < Math.min(encodedLeft.length, encodedRight.length); i++) {
910
+ const comparison = primitiveComparator(encodedLeft[i], encodedRight[i]);
911
+ if (comparison !== 0) {
912
+ return comparison;
913
+ }
914
+ }
915
+ return primitiveComparator(encodedLeft.length, encodedRight.length);
916
+ }
875
917
  /** Helper to compare arrays using isEqual(). */
876
918
  function arrayEquals(left, right, comparator) {
877
919
  if (left.length !== right.length) {
@@ -1233,7 +1275,7 @@ class BasePath {
1233
1275
  return comparison;
1234
1276
  }
1235
1277
  }
1236
- return Math.sign(p1.length - p2.length);
1278
+ return primitiveComparator(p1.length, p2.length);
1237
1279
  }
1238
1280
  static compareSegments(lhs, rhs) {
1239
1281
  const isLhsNumeric = BasePath.isNumericId(lhs);
@@ -1252,13 +1294,7 @@ class BasePath {
1252
1294
  }
1253
1295
  else {
1254
1296
  // both non-numeric
1255
- if (lhs < rhs) {
1256
- return -1;
1257
- }
1258
- if (lhs > rhs) {
1259
- return 1;
1260
- }
1261
- return 0;
1297
+ return compareUtf8Strings(lhs, rhs);
1262
1298
  }
1263
1299
  }
1264
1300
  // Checks if a segment is a numeric ID (starts with "__id" and ends with "__").
@@ -4675,7 +4711,7 @@ function valueCompare(left, right) {
4675
4711
  case 4 /* TypeOrder.ServerTimestampValue */:
4676
4712
  return compareTimestamps(getLocalWriteTime(left), getLocalWriteTime(right));
4677
4713
  case 5 /* TypeOrder.StringValue */:
4678
- return primitiveComparator(left.stringValue, right.stringValue);
4714
+ return compareUtf8Strings(left.stringValue, right.stringValue);
4679
4715
  case 6 /* TypeOrder.BlobValue */:
4680
4716
  return compareBlobs(left.bytesValue, right.bytesValue);
4681
4717
  case 7 /* TypeOrder.RefValue */:
@@ -4796,7 +4832,7 @@ function compareMaps(left, right) {
4796
4832
  leftKeys.sort();
4797
4833
  rightKeys.sort();
4798
4834
  for (let i = 0; i < leftKeys.length && i < rightKeys.length; ++i) {
4799
- const keyCompare = primitiveComparator(leftKeys[i], rightKeys[i]);
4835
+ const keyCompare = compareUtf8Strings(leftKeys[i], rightKeys[i]);
4800
4836
  if (keyCompare !== 0) {
4801
4837
  return keyCompare;
4802
4838
  }
@@ -7977,35 +8013,6 @@ function setTestingHooksSpi(instance) {
7977
8013
  testingHooksSpi = instance;
7978
8014
  }
7979
8015
 
7980
- /**
7981
- * @license
7982
- * Copyright 2023 Google LLC
7983
- *
7984
- * Licensed under the Apache License, Version 2.0 (the "License");
7985
- * you may not use this file except in compliance with the License.
7986
- * You may obtain a copy of the License at
7987
- *
7988
- * http://www.apache.org/licenses/LICENSE-2.0
7989
- *
7990
- * Unless required by applicable law or agreed to in writing, software
7991
- * distributed under the License is distributed on an "AS IS" BASIS,
7992
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7993
- * See the License for the specific language governing permissions and
7994
- * limitations under the License.
7995
- */
7996
- /**
7997
- * An instance of the Platform's 'TextEncoder' implementation.
7998
- */
7999
- function newTextEncoder() {
8000
- return new TextEncoder();
8001
- }
8002
- /**
8003
- * An instance of the Platform's 'TextDecoder' implementation.
8004
- */
8005
- function newTextDecoder() {
8006
- return new TextDecoder('utf-8');
8007
- }
8008
-
8009
8016
  /**
8010
8017
  * @license
8011
8018
  * Copyright 2022 Google LLC
@@ -14054,6 +14061,10 @@ function dbKeyComparator(l, r) {
14054
14061
  if (cmp) {
14055
14062
  return cmp;
14056
14063
  }
14064
+ // TODO(b/329441702): Document IDs should be sorted by UTF-8 encoded byte
14065
+ // order, but IndexedDB sorts strings lexicographically. Document ID
14066
+ // comparison here still relies on primitive comparison to avoid mismatches
14067
+ // observed in snapshot listeners with Unicode characters in documentIds
14057
14068
  return primitiveComparator(left[left.length - 1], right[right.length - 1]);
14058
14069
  }
14059
14070