@firebase/firestore 4.7.9 → 4.7.10-20250318131644

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.
@@ -4,7 +4,7 @@ import { Logger, LogLevel } from '@firebase/logger';
4
4
  import { FirebaseError, getDefaultEmulatorHostnameAndPort, deepEqual, createMockUserToken, getModularInstance } from '@firebase/util';
5
5
  import { Integer } from '@firebase/webchannel-wrapper/bloom-blob';
6
6
 
7
- const E = "4.7.9";
7
+ const E = "4.7.10-20250318131644";
8
8
 
9
9
  /**
10
10
  * @license
@@ -65,7 +65,7 @@ User.MOCK_USER = new User("mock-user");
65
65
  * See the License for the specific language governing permissions and
66
66
  * limitations under the License.
67
67
  */
68
- let m = "11.4.0";
68
+ let m = "11.5.0-20250318131644";
69
69
 
70
70
  /**
71
71
  * @license
@@ -476,6 +476,57 @@ class DatabaseInfo {
476
476
  }
477
477
  }
478
478
 
479
+ /**
480
+ * @license
481
+ * Copyright 2020 Google LLC
482
+ *
483
+ * Licensed under the Apache License, Version 2.0 (the "License");
484
+ * you may not use this file except in compliance with the License.
485
+ * You may obtain a copy of the License at
486
+ *
487
+ * http://www.apache.org/licenses/LICENSE-2.0
488
+ *
489
+ * Unless required by applicable law or agreed to in writing, software
490
+ * distributed under the License is distributed on an "AS IS" BASIS,
491
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
492
+ * See the License for the specific language governing permissions and
493
+ * limitations under the License.
494
+ */
495
+ /**
496
+ * Generates `nBytes` of random bytes.
497
+ *
498
+ * If `nBytes < 0` , an error will be thrown.
499
+ */
500
+ function __PRIVATE_randomBytes(t) {
501
+ // Polyfills for IE and WebWorker by using `self` and `msCrypto` when `crypto` is not available.
502
+ const e =
503
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
504
+ "undefined" != typeof self && (self.crypto || self.msCrypto), r = new Uint8Array(t);
505
+ if (e && "function" == typeof e.getRandomValues) e.getRandomValues(r); else
506
+ // Falls back to Math.random
507
+ for (let e = 0; e < t; e++) r[e] = Math.floor(256 * Math.random());
508
+ return r;
509
+ }
510
+
511
+ /**
512
+ * @license
513
+ * Copyright 2023 Google LLC
514
+ *
515
+ * Licensed under the Apache License, Version 2.0 (the "License");
516
+ * you may not use this file except in compliance with the License.
517
+ * You may obtain a copy of the License at
518
+ *
519
+ * http://www.apache.org/licenses/LICENSE-2.0
520
+ *
521
+ * Unless required by applicable law or agreed to in writing, software
522
+ * distributed under the License is distributed on an "AS IS" BASIS,
523
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
524
+ * See the License for the specific language governing permissions and
525
+ * limitations under the License.
526
+ */
527
+ /**
528
+ * An instance of the Platform's 'TextEncoder' implementation.
529
+ */
479
530
  /**
480
531
  * @license
481
532
  * Copyright 2017 Google LLC
@@ -492,7 +543,84 @@ class DatabaseInfo {
492
543
  * See the License for the specific language governing permissions and
493
544
  * limitations under the License.
494
545
  */
495
- const B = "__name__";
546
+ /**
547
+ * A utility class for generating unique alphanumeric IDs of a specified length.
548
+ *
549
+ * @internal
550
+ * Exported internally for testing purposes.
551
+ */
552
+ class __PRIVATE_AutoId {
553
+ static newId() {
554
+ // Alphanumeric characters
555
+ const t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", e = 62 * Math.floor(256 / 62);
556
+ // The largest byte value that is a multiple of `char.length`.
557
+ let r = "";
558
+ for (;r.length < 20; ) {
559
+ const n = __PRIVATE_randomBytes(40);
560
+ for (let i = 0; i < n.length; ++i)
561
+ // Only accept values that are [0, maxMultiple), this ensures they can
562
+ // be evenly mapped to indices of `chars` via a modulo operation.
563
+ r.length < 20 && n[i] < e && (r += t.charAt(n[i] % 62));
564
+ }
565
+ return r;
566
+ }
567
+ }
568
+
569
+ function __PRIVATE_primitiveComparator(t, e) {
570
+ return t < e ? -1 : t > e ? 1 : 0;
571
+ }
572
+
573
+ /** Compare strings in UTF-8 encoded byte order */ function __PRIVATE_compareUtf8Strings(t, e) {
574
+ let r = 0;
575
+ for (;r < t.length && r < e.length; ) {
576
+ const n = t.codePointAt(r), i = e.codePointAt(r);
577
+ if (n !== i) {
578
+ if (n < 128 && i < 128)
579
+ // ASCII comparison
580
+ return __PRIVATE_primitiveComparator(n, i);
581
+ {
582
+ // Lazy instantiate TextEncoder
583
+ const s = new TextEncoder, o = __PRIVATE_compareByteArrays(s.encode(__PRIVATE_getUtf8SafeSubstring(t, r)), s.encode(__PRIVATE_getUtf8SafeSubstring(e, r)));
584
+ // UTF-8 encode the character at index i for byte comparison.
585
+ return 0 !== o ? o : __PRIVATE_primitiveComparator(n, i);
586
+ }
587
+ }
588
+ // Increment by 2 for surrogate pairs, 1 otherwise
589
+ r += n > 65535 ? 2 : 1;
590
+ }
591
+ // Compare lengths if all characters are equal
592
+ return __PRIVATE_primitiveComparator(t.length, e.length);
593
+ }
594
+
595
+ function __PRIVATE_getUtf8SafeSubstring(t, e) {
596
+ return t.codePointAt(e) > 65535 ? t.substring(e, e + 2) : t.substring(e, e + 1);
597
+ }
598
+
599
+ function __PRIVATE_compareByteArrays(t, e) {
600
+ for (let r = 0; r < t.length && r < e.length; ++r) if (t[r] !== e[r]) return __PRIVATE_primitiveComparator(t[r], e[r]);
601
+ return __PRIVATE_primitiveComparator(t.length, e.length);
602
+ }
603
+
604
+ /** Helper to compare arrays using isEqual(). */ function __PRIVATE_arrayEquals(t, e, r) {
605
+ return t.length === e.length && t.every(((t, n) => r(t, e[n])));
606
+ }
607
+
608
+ /**
609
+ * @license
610
+ * Copyright 2017 Google LLC
611
+ *
612
+ * Licensed under the Apache License, Version 2.0 (the "License");
613
+ * you may not use this file except in compliance with the License.
614
+ * You may obtain a copy of the License at
615
+ *
616
+ * http://www.apache.org/licenses/LICENSE-2.0
617
+ *
618
+ * Unless required by applicable law or agreed to in writing, software
619
+ * distributed under the License is distributed on an "AS IS" BASIS,
620
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
621
+ * See the License for the specific language governing permissions and
622
+ * limitations under the License.
623
+ */ const B = "__name__";
496
624
 
497
625
  /**
498
626
  * Path represents an ordered sequence of string segments.
@@ -560,13 +688,11 @@ const B = "__name__";
560
688
  const r = BasePath.compareSegments(t.get(n), e.get(n));
561
689
  if (0 !== r) return r;
562
690
  }
563
- return Math.sign(t.length - e.length);
691
+ return __PRIVATE_primitiveComparator(t.length, e.length);
564
692
  }
565
693
  static compareSegments(t, e) {
566
694
  const r = BasePath.isNumericId(t), n = BasePath.isNumericId(e);
567
- return r && !n ? -1 : !r && n ? 1 : r && n ? BasePath.extractNumericId(t).compare(BasePath.extractNumericId(e)) :
568
- // both non-numeric
569
- t < e ? -1 : t > e ? 1 : 0;
695
+ return r && !n ? -1 : !r && n ? 1 : r && n ? BasePath.extractNumericId(t).compare(BasePath.extractNumericId(e)) : __PRIVATE_compareUtf8Strings(t, e);
570
696
  }
571
697
  // Checks if a segment is a numeric ID (starts with "__id" and ends with "__").
572
698
  static isNumericId(t) {
@@ -1072,7 +1198,7 @@ class __PRIVATE_RestConnection {
1072
1198
  * Important! The names of these identifiers matter because the string forms
1073
1199
  * are used for reverse lookups from the webchannel stream. Do NOT change the
1074
1200
  * names of these identifiers or change this into a const enum.
1075
- */ var x, k;
1201
+ */ var U, x;
1076
1202
 
1077
1203
  /**
1078
1204
  * Converts an HTTP Status Code to the equivalent error code.
@@ -1175,13 +1301,13 @@ function __PRIVATE_mapCodeFromHttpStatus(t) {
1175
1301
  /**
1176
1302
  * A Rest-based connection that relies on the native HTTP stack
1177
1303
  * (e.g. `fetch` or a polyfill).
1178
- */ (k = x || (x = {}))[k.OK = 0] = "OK", k[k.CANCELLED = 1] = "CANCELLED", k[k.UNKNOWN = 2] = "UNKNOWN",
1179
- k[k.INVALID_ARGUMENT = 3] = "INVALID_ARGUMENT", k[k.DEADLINE_EXCEEDED = 4] = "DEADLINE_EXCEEDED",
1180
- k[k.NOT_FOUND = 5] = "NOT_FOUND", k[k.ALREADY_EXISTS = 6] = "ALREADY_EXISTS", k[k.PERMISSION_DENIED = 7] = "PERMISSION_DENIED",
1181
- k[k.UNAUTHENTICATED = 16] = "UNAUTHENTICATED", k[k.RESOURCE_EXHAUSTED = 8] = "RESOURCE_EXHAUSTED",
1182
- k[k.FAILED_PRECONDITION = 9] = "FAILED_PRECONDITION", k[k.ABORTED = 10] = "ABORTED",
1183
- k[k.OUT_OF_RANGE = 11] = "OUT_OF_RANGE", k[k.UNIMPLEMENTED = 12] = "UNIMPLEMENTED",
1184
- k[k.INTERNAL = 13] = "INTERNAL", k[k.UNAVAILABLE = 14] = "UNAVAILABLE", k[k.DATA_LOSS = 15] = "DATA_LOSS";
1304
+ */ (x = U || (U = {}))[x.OK = 0] = "OK", x[x.CANCELLED = 1] = "CANCELLED", x[x.UNKNOWN = 2] = "UNKNOWN",
1305
+ x[x.INVALID_ARGUMENT = 3] = "INVALID_ARGUMENT", x[x.DEADLINE_EXCEEDED = 4] = "DEADLINE_EXCEEDED",
1306
+ x[x.NOT_FOUND = 5] = "NOT_FOUND", x[x.ALREADY_EXISTS = 6] = "ALREADY_EXISTS", x[x.PERMISSION_DENIED = 7] = "PERMISSION_DENIED",
1307
+ x[x.UNAUTHENTICATED = 16] = "UNAUTHENTICATED", x[x.RESOURCE_EXHAUSTED = 8] = "RESOURCE_EXHAUSTED",
1308
+ x[x.FAILED_PRECONDITION = 9] = "FAILED_PRECONDITION", x[x.ABORTED = 10] = "ABORTED",
1309
+ x[x.OUT_OF_RANGE = 11] = "OUT_OF_RANGE", x[x.UNIMPLEMENTED = 12] = "UNIMPLEMENTED",
1310
+ x[x.INTERNAL = 13] = "INTERNAL", x[x.UNAVAILABLE = 14] = "UNAVAILABLE", x[x.DATA_LOSS = 15] = "DATA_LOSS";
1185
1311
 
1186
1312
  class __PRIVATE_FetchConnection extends __PRIVATE_RestConnection {
1187
1313
  D(t, e) {
@@ -1253,83 +1379,6 @@ class __PRIVATE_AggregateImpl {
1253
1379
  }
1254
1380
  }
1255
1381
 
1256
- /**
1257
- * @license
1258
- * Copyright 2020 Google LLC
1259
- *
1260
- * Licensed under the Apache License, Version 2.0 (the "License");
1261
- * you may not use this file except in compliance with the License.
1262
- * You may obtain a copy of the License at
1263
- *
1264
- * http://www.apache.org/licenses/LICENSE-2.0
1265
- *
1266
- * Unless required by applicable law or agreed to in writing, software
1267
- * distributed under the License is distributed on an "AS IS" BASIS,
1268
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1269
- * See the License for the specific language governing permissions and
1270
- * limitations under the License.
1271
- */
1272
- /**
1273
- * Generates `nBytes` of random bytes.
1274
- *
1275
- * If `nBytes < 0` , an error will be thrown.
1276
- */ function __PRIVATE_randomBytes(t) {
1277
- // Polyfills for IE and WebWorker by using `self` and `msCrypto` when `crypto` is not available.
1278
- const e =
1279
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1280
- "undefined" != typeof self && (self.crypto || self.msCrypto), r = new Uint8Array(t);
1281
- if (e && "function" == typeof e.getRandomValues) e.getRandomValues(r); else
1282
- // Falls back to Math.random
1283
- for (let e = 0; e < t; e++) r[e] = Math.floor(256 * Math.random());
1284
- return r;
1285
- }
1286
-
1287
- /**
1288
- * @license
1289
- * Copyright 2017 Google LLC
1290
- *
1291
- * Licensed under the Apache License, Version 2.0 (the "License");
1292
- * you may not use this file except in compliance with the License.
1293
- * You may obtain a copy of the License at
1294
- *
1295
- * http://www.apache.org/licenses/LICENSE-2.0
1296
- *
1297
- * Unless required by applicable law or agreed to in writing, software
1298
- * distributed under the License is distributed on an "AS IS" BASIS,
1299
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1300
- * See the License for the specific language governing permissions and
1301
- * limitations under the License.
1302
- */
1303
- /**
1304
- * A utility class for generating unique alphanumeric IDs of a specified length.
1305
- *
1306
- * @internal
1307
- * Exported internally for testing purposes.
1308
- */ class __PRIVATE_AutoId {
1309
- static newId() {
1310
- // Alphanumeric characters
1311
- const t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", e = 62 * Math.floor(256 / 62);
1312
- // The largest byte value that is a multiple of `char.length`.
1313
- let r = "";
1314
- for (;r.length < 20; ) {
1315
- const n = __PRIVATE_randomBytes(40);
1316
- for (let i = 0; i < n.length; ++i)
1317
- // Only accept values that are [0, maxMultiple), this ensures they can
1318
- // be evenly mapped to indices of `chars` via a modulo operation.
1319
- r.length < 20 && n[i] < e && (r += t.charAt(n[i] % 62));
1320
- }
1321
- return r;
1322
- }
1323
- }
1324
-
1325
- function __PRIVATE_primitiveComparator(t, e) {
1326
- return t < e ? -1 : t > e ? 1 : 0;
1327
- }
1328
-
1329
- /** Helper to compare arrays using isEqual(). */ function __PRIVATE_arrayEquals(t, e, r) {
1330
- return t.length === e.length && t.every(((t, n) => r(t, e[n])));
1331
- }
1332
-
1333
1382
  /**
1334
1383
  * @license
1335
1384
  * Copyright 2017 Google LLC
@@ -1512,7 +1561,7 @@ class ByteString {
1512
1561
 
1513
1562
  ByteString.EMPTY_BYTE_STRING = new ByteString("");
1514
1563
 
1515
- const U = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
1564
+ const k = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
1516
1565
 
1517
1566
  /**
1518
1567
  * Converts the possible Proto values for a timestamp value into a "seconds and
@@ -1526,7 +1575,7 @@ const U = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
1526
1575
  // (millis), so we do some custom parsing here.
1527
1576
  // Parse the nanos right out of the string.
1528
1577
  let e = 0;
1529
- const r = U.exec(t);
1578
+ const r = k.exec(t);
1530
1579
  if (__PRIVATE_hardAssert(!!r), r[1]) {
1531
1580
  // Pad the fraction out to 9 digits (nanos).
1532
1581
  let t = r[1];
@@ -1925,7 +1974,7 @@ function __PRIVATE_valueCompare(t, e) {
1925
1974
  return __PRIVATE_compareTimestamps(__PRIVATE_getLocalWriteTime(t), __PRIVATE_getLocalWriteTime(e));
1926
1975
 
1927
1976
  case 5 /* TypeOrder.StringValue */ :
1928
- return __PRIVATE_primitiveComparator(t.stringValue, e.stringValue);
1977
+ return __PRIVATE_compareUtf8Strings(t.stringValue, e.stringValue);
1929
1978
 
1930
1979
  case 6 /* TypeOrder.BlobValue */ :
1931
1980
  return function __PRIVATE_compareBlobs(t, e) {
@@ -1973,7 +2022,7 @@ function __PRIVATE_valueCompare(t, e) {
1973
2022
  // canonical IDs are independent of insertion order.
1974
2023
  n.sort(), s.sort();
1975
2024
  for (let t = 0; t < n.length && t < s.length; ++t) {
1976
- const e = __PRIVATE_primitiveComparator(n[t], s[t]);
2025
+ const e = __PRIVATE_compareUtf8Strings(n[t], s[t]);
1977
2026
  if (0 !== e) return e;
1978
2027
  const o = __PRIVATE_valueCompare(r[n[t]], i[s[t]]);
1979
2028
  if (0 !== o) return o;
@@ -3921,7 +3970,7 @@ class __PRIVATE_ExponentialBackoff {
3921
3970
  * Note that jitter will still be applied, so the actual delay could be as
3922
3971
  * much as 1.5*maxDelayMs.
3923
3972
  */ , i = 6e4) {
3924
- this.L = t, this.timerId = e, this.M = r, this.k = n, this.U = i, this.j = 0, this.W = null,
3973
+ this.L = t, this.timerId = e, this.M = r, this.U = n, this.k = i, this.j = 0, this.W = null,
3925
3974
  /** The last backoff attempt, as epoch milliseconds. */
3926
3975
  this.K = Date.now(), this.reset();
3927
3976
  }
@@ -3938,7 +3987,7 @@ class __PRIVATE_ExponentialBackoff {
3938
3987
  * Resets the backoff delay to the maximum delay (e.g. for use after a
3939
3988
  * RESOURCE_EXHAUSTED error).
3940
3989
  */ G() {
3941
- this.j = this.U;
3990
+ this.j = this.k;
3942
3991
  }
3943
3992
  /**
3944
3993
  * Returns a promise that resolves after currentDelayMs, and increases the
@@ -3956,7 +4005,7 @@ class __PRIVATE_ExponentialBackoff {
3956
4005
  t()))),
3957
4006
  // Apply backoff factor to determine next delay and ensure it is within
3958
4007
  // bounds.
3959
- this.j *= this.k, this.j < this.M && (this.j = this.M), this.j > this.U && (this.j = this.U);
4008
+ this.j *= this.U, this.j < this.M && (this.j = this.M), this.j > this.k && (this.j = this.k);
3960
4009
  }
3961
4010
  Y() {
3962
4011
  null !== this.W && (this.W.skipDelay(), this.W = null);
@@ -7311,7 +7360,7 @@ class __PRIVATE_AsyncQueueImpl {
7311
7360
  }
7312
7361
  /**
7313
7362
  * For Tests: Skip all subsequent delays for a timer id.
7314
- */ xt(t) {
7363
+ */ Ut(t) {
7315
7364
  this.Ct.push(t);
7316
7365
  }
7317
7366
  /** Called once a DelayedOperation is run or canceled. */ $t(t) {