@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.
@@ -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.7-canary.3418ef807";
37
+ const version$1 = "4.7.7-canary.4d2fc6e82";
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.3.0-canary.3418ef807";
90
+ const version = "11.3.0-canary.4d2fc6e82";
91
91
 
92
92
  /**
93
93
  * @license
@@ -845,6 +845,35 @@ function randomBytes(nBytes) {
845
845
  return crypto.randomBytes(nBytes);
846
846
  }
847
847
 
848
+ /**
849
+ * @license
850
+ * Copyright 2023 Google LLC
851
+ *
852
+ * Licensed under the Apache License, Version 2.0 (the "License");
853
+ * you may not use this file except in compliance with the License.
854
+ * You may obtain a copy of the License at
855
+ *
856
+ * http://www.apache.org/licenses/LICENSE-2.0
857
+ *
858
+ * Unless required by applicable law or agreed to in writing, software
859
+ * distributed under the License is distributed on an "AS IS" BASIS,
860
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
861
+ * See the License for the specific language governing permissions and
862
+ * limitations under the License.
863
+ */
864
+ /**
865
+ * An instance of the Platform's 'TextEncoder' implementation.
866
+ */
867
+ function newTextEncoder() {
868
+ return new util$1.TextEncoder();
869
+ }
870
+ /**
871
+ * An instance of the Platform's 'TextDecoder' implementation.
872
+ */
873
+ function newTextDecoder() {
874
+ return new util$1.TextDecoder('utf-8');
875
+ }
876
+
848
877
  /**
849
878
  * @license
850
879
  * Copyright 2017 Google LLC
@@ -897,6 +926,19 @@ function primitiveComparator(left, right) {
897
926
  }
898
927
  return 0;
899
928
  }
929
+ /** Compare strings in UTF-8 encoded byte order */
930
+ function compareUtf8Strings(left, right) {
931
+ // Convert the string to UTF-8 encoded bytes
932
+ const encodedLeft = newTextEncoder().encode(left);
933
+ const encodedRight = newTextEncoder().encode(right);
934
+ for (let i = 0; i < Math.min(encodedLeft.length, encodedRight.length); i++) {
935
+ const comparison = primitiveComparator(encodedLeft[i], encodedRight[i]);
936
+ if (comparison !== 0) {
937
+ return comparison;
938
+ }
939
+ }
940
+ return primitiveComparator(encodedLeft.length, encodedRight.length);
941
+ }
900
942
  /** Helper to compare arrays using isEqual(). */
901
943
  function arrayEquals(left, right, comparator) {
902
944
  if (left.length !== right.length) {
@@ -1258,7 +1300,7 @@ class BasePath {
1258
1300
  return comparison;
1259
1301
  }
1260
1302
  }
1261
- return Math.sign(p1.length - p2.length);
1303
+ return primitiveComparator(p1.length, p2.length);
1262
1304
  }
1263
1305
  static compareSegments(lhs, rhs) {
1264
1306
  const isLhsNumeric = BasePath.isNumericId(lhs);
@@ -1277,13 +1319,7 @@ class BasePath {
1277
1319
  }
1278
1320
  else {
1279
1321
  // both non-numeric
1280
- if (lhs < rhs) {
1281
- return -1;
1282
- }
1283
- if (lhs > rhs) {
1284
- return 1;
1285
- }
1286
- return 0;
1322
+ return compareUtf8Strings(lhs, rhs);
1287
1323
  }
1288
1324
  }
1289
1325
  // Checks if a segment is a numeric ID (starts with "__id" and ends with "__").
@@ -4700,7 +4736,7 @@ function valueCompare(left, right) {
4700
4736
  case 4 /* TypeOrder.ServerTimestampValue */:
4701
4737
  return compareTimestamps(getLocalWriteTime(left), getLocalWriteTime(right));
4702
4738
  case 5 /* TypeOrder.StringValue */:
4703
- return primitiveComparator(left.stringValue, right.stringValue);
4739
+ return compareUtf8Strings(left.stringValue, right.stringValue);
4704
4740
  case 6 /* TypeOrder.BlobValue */:
4705
4741
  return compareBlobs(left.bytesValue, right.bytesValue);
4706
4742
  case 7 /* TypeOrder.RefValue */:
@@ -4821,7 +4857,7 @@ function compareMaps(left, right) {
4821
4857
  leftKeys.sort();
4822
4858
  rightKeys.sort();
4823
4859
  for (let i = 0; i < leftKeys.length && i < rightKeys.length; ++i) {
4824
- const keyCompare = primitiveComparator(leftKeys[i], rightKeys[i]);
4860
+ const keyCompare = compareUtf8Strings(leftKeys[i], rightKeys[i]);
4825
4861
  if (keyCompare !== 0) {
4826
4862
  return keyCompare;
4827
4863
  }
@@ -8002,35 +8038,6 @@ function setTestingHooksSpi(instance) {
8002
8038
  testingHooksSpi = instance;
8003
8039
  }
8004
8040
 
8005
- /**
8006
- * @license
8007
- * Copyright 2023 Google LLC
8008
- *
8009
- * Licensed under the Apache License, Version 2.0 (the "License");
8010
- * you may not use this file except in compliance with the License.
8011
- * You may obtain a copy of the License at
8012
- *
8013
- * http://www.apache.org/licenses/LICENSE-2.0
8014
- *
8015
- * Unless required by applicable law or agreed to in writing, software
8016
- * distributed under the License is distributed on an "AS IS" BASIS,
8017
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8018
- * See the License for the specific language governing permissions and
8019
- * limitations under the License.
8020
- */
8021
- /**
8022
- * An instance of the Platform's 'TextEncoder' implementation.
8023
- */
8024
- function newTextEncoder() {
8025
- return new util$1.TextEncoder();
8026
- }
8027
- /**
8028
- * An instance of the Platform's 'TextDecoder' implementation.
8029
- */
8030
- function newTextDecoder() {
8031
- return new util$1.TextDecoder('utf-8');
8032
- }
8033
-
8034
8041
  /**
8035
8042
  * @license
8036
8043
  * Copyright 2022 Google LLC
@@ -14079,6 +14086,10 @@ function dbKeyComparator(l, r) {
14079
14086
  if (cmp) {
14080
14087
  return cmp;
14081
14088
  }
14089
+ // TODO(b/329441702): Document IDs should be sorted by UTF-8 encoded byte
14090
+ // order, but IndexedDB sorts strings lexicographically. Document ID
14091
+ // comparison here still relies on primitive comparison to avoid mismatches
14092
+ // observed in snapshot listeners with Unicode characters in documentIds
14082
14093
  return primitiveComparator(left[left.length - 1], right[right.length - 1]);
14083
14094
  }
14084
14095