@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.
@@ -8,7 +8,7 @@ import { FirebaseError as _, base64 as c, DecodeBase64StringError as l, getDefau
8
8
 
9
9
  import { Integer as m } from "@firebase/webchannel-wrapper/bloom-blob";
10
10
 
11
- const A = "4.7.9";
11
+ const A = "4.7.10-20250318131644";
12
12
 
13
13
  /**
14
14
  * @license
@@ -69,7 +69,7 @@ User.MOCK_USER = new User("mock-user");
69
69
  * See the License for the specific language governing permissions and
70
70
  * limitations under the License.
71
71
  */
72
- let T = "11.4.0";
72
+ let T = "11.5.0-20250318131644";
73
73
 
74
74
  /**
75
75
  * @license
@@ -480,6 +480,57 @@ class DatabaseInfo {
480
480
  }
481
481
  }
482
482
 
483
+ /**
484
+ * @license
485
+ * Copyright 2020 Google LLC
486
+ *
487
+ * Licensed under the Apache License, Version 2.0 (the "License");
488
+ * you may not use this file except in compliance with the License.
489
+ * You may obtain a copy of the License at
490
+ *
491
+ * http://www.apache.org/licenses/LICENSE-2.0
492
+ *
493
+ * Unless required by applicable law or agreed to in writing, software
494
+ * distributed under the License is distributed on an "AS IS" BASIS,
495
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
496
+ * See the License for the specific language governing permissions and
497
+ * limitations under the License.
498
+ */
499
+ /**
500
+ * Generates `nBytes` of random bytes.
501
+ *
502
+ * If `nBytes < 0` , an error will be thrown.
503
+ */
504
+ function __PRIVATE_randomBytes(t) {
505
+ // Polyfills for IE and WebWorker by using `self` and `msCrypto` when `crypto` is not available.
506
+ const e =
507
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
508
+ "undefined" != typeof self && (self.crypto || self.msCrypto), r = new Uint8Array(t);
509
+ if (e && "function" == typeof e.getRandomValues) e.getRandomValues(r); else
510
+ // Falls back to Math.random
511
+ for (let e = 0; e < t; e++) r[e] = Math.floor(256 * Math.random());
512
+ return r;
513
+ }
514
+
515
+ /**
516
+ * @license
517
+ * Copyright 2023 Google LLC
518
+ *
519
+ * Licensed under the Apache License, Version 2.0 (the "License");
520
+ * you may not use this file except in compliance with the License.
521
+ * You may obtain a copy of the License at
522
+ *
523
+ * http://www.apache.org/licenses/LICENSE-2.0
524
+ *
525
+ * Unless required by applicable law or agreed to in writing, software
526
+ * distributed under the License is distributed on an "AS IS" BASIS,
527
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
528
+ * See the License for the specific language governing permissions and
529
+ * limitations under the License.
530
+ */
531
+ /**
532
+ * An instance of the Platform's 'TextEncoder' implementation.
533
+ */
483
534
  /**
484
535
  * @license
485
536
  * Copyright 2017 Google LLC
@@ -496,7 +547,84 @@ class DatabaseInfo {
496
547
  * See the License for the specific language governing permissions and
497
548
  * limitations under the License.
498
549
  */
499
- const Q = "__name__";
550
+ /**
551
+ * A utility class for generating unique alphanumeric IDs of a specified length.
552
+ *
553
+ * @internal
554
+ * Exported internally for testing purposes.
555
+ */
556
+ class __PRIVATE_AutoId {
557
+ static newId() {
558
+ // Alphanumeric characters
559
+ const t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", e = 62 * Math.floor(256 / 62);
560
+ // The largest byte value that is a multiple of `char.length`.
561
+ let r = "";
562
+ for (;r.length < 20; ) {
563
+ const n = __PRIVATE_randomBytes(40);
564
+ for (let i = 0; i < n.length; ++i)
565
+ // Only accept values that are [0, maxMultiple), this ensures they can
566
+ // be evenly mapped to indices of `chars` via a modulo operation.
567
+ r.length < 20 && n[i] < e && (r += t.charAt(n[i] % 62));
568
+ }
569
+ return r;
570
+ }
571
+ }
572
+
573
+ function __PRIVATE_primitiveComparator(t, e) {
574
+ return t < e ? -1 : t > e ? 1 : 0;
575
+ }
576
+
577
+ /** Compare strings in UTF-8 encoded byte order */ function __PRIVATE_compareUtf8Strings(t, e) {
578
+ let r = 0;
579
+ for (;r < t.length && r < e.length; ) {
580
+ const n = t.codePointAt(r), i = e.codePointAt(r);
581
+ if (n !== i) {
582
+ if (n < 128 && i < 128)
583
+ // ASCII comparison
584
+ return __PRIVATE_primitiveComparator(n, i);
585
+ {
586
+ // Lazy instantiate TextEncoder
587
+ const s = new TextEncoder, o = __PRIVATE_compareByteArrays(s.encode(__PRIVATE_getUtf8SafeSubstring(t, r)), s.encode(__PRIVATE_getUtf8SafeSubstring(e, r)));
588
+ // UTF-8 encode the character at index i for byte comparison.
589
+ return 0 !== o ? o : __PRIVATE_primitiveComparator(n, i);
590
+ }
591
+ }
592
+ // Increment by 2 for surrogate pairs, 1 otherwise
593
+ r += n > 65535 ? 2 : 1;
594
+ }
595
+ // Compare lengths if all characters are equal
596
+ return __PRIVATE_primitiveComparator(t.length, e.length);
597
+ }
598
+
599
+ function __PRIVATE_getUtf8SafeSubstring(t, e) {
600
+ return t.codePointAt(e) > 65535 ? t.substring(e, e + 2) : t.substring(e, e + 1);
601
+ }
602
+
603
+ function __PRIVATE_compareByteArrays(t, e) {
604
+ for (let r = 0; r < t.length && r < e.length; ++r) if (t[r] !== e[r]) return __PRIVATE_primitiveComparator(t[r], e[r]);
605
+ return __PRIVATE_primitiveComparator(t.length, e.length);
606
+ }
607
+
608
+ /** Helper to compare arrays using isEqual(). */ function __PRIVATE_arrayEquals(t, e, r) {
609
+ return t.length === e.length && t.every(((t, n) => r(t, e[n])));
610
+ }
611
+
612
+ /**
613
+ * @license
614
+ * Copyright 2017 Google LLC
615
+ *
616
+ * Licensed under the Apache License, Version 2.0 (the "License");
617
+ * you may not use this file except in compliance with the License.
618
+ * You may obtain a copy of the License at
619
+ *
620
+ * http://www.apache.org/licenses/LICENSE-2.0
621
+ *
622
+ * Unless required by applicable law or agreed to in writing, software
623
+ * distributed under the License is distributed on an "AS IS" BASIS,
624
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
625
+ * See the License for the specific language governing permissions and
626
+ * limitations under the License.
627
+ */ const Q = "__name__";
500
628
 
501
629
  /**
502
630
  * Path represents an ordered sequence of string segments.
@@ -564,13 +692,11 @@ const Q = "__name__";
564
692
  const r = BasePath.compareSegments(t.get(n), e.get(n));
565
693
  if (0 !== r) return r;
566
694
  }
567
- return Math.sign(t.length - e.length);
695
+ return __PRIVATE_primitiveComparator(t.length, e.length);
568
696
  }
569
697
  static compareSegments(t, e) {
570
698
  const r = BasePath.isNumericId(t), n = BasePath.isNumericId(e);
571
- return r && !n ? -1 : !r && n ? 1 : r && n ? BasePath.extractNumericId(t).compare(BasePath.extractNumericId(e)) :
572
- // both non-numeric
573
- t < e ? -1 : t > e ? 1 : 0;
699
+ return r && !n ? -1 : !r && n ? 1 : r && n ? BasePath.extractNumericId(t).compare(BasePath.extractNumericId(e)) : __PRIVATE_compareUtf8Strings(t, e);
574
700
  }
575
701
  // Checks if a segment is a numeric ID (starts with "__id" and ends with "__").
576
702
  static isNumericId(t) {
@@ -898,7 +1024,7 @@ function __PRIVATE_cloneLongPollingOptions(t) {
898
1024
  /**
899
1025
  * The value returned from the most recent invocation of
900
1026
  * `generateUniqueDebugId()`, or null if it has never been invoked.
901
- */ let M = null;
1027
+ */ let U = null;
902
1028
 
903
1029
  /**
904
1030
  * Generates and returns an initial value for `lastUniqueDebugId`.
@@ -923,9 +1049,9 @@ function __PRIVATE_cloneLongPollingOptions(t) {
923
1049
  * @return the 10-character generated ID (e.g. "0xa1b2c3d4").
924
1050
  */
925
1051
  function __PRIVATE_generateUniqueDebugId() {
926
- return null === M ? M = function __PRIVATE_generateInitialUniqueDebugId() {
1052
+ return null === U ? U = function __PRIVATE_generateInitialUniqueDebugId() {
927
1053
  return 268435456 + Math.round(2147483648 * Math.random());
928
- }() : M++, "0x" + M.toString(16);
1054
+ }() : U++, "0x" + U.toString(16);
929
1055
  }
930
1056
 
931
1057
  /**
@@ -976,7 +1102,7 @@ function __PRIVATE_generateUniqueDebugId() {
976
1102
  * See the License for the specific language governing permissions and
977
1103
  * limitations under the License.
978
1104
  */
979
- const x = "RestConnection", k = {
1105
+ const M = "RestConnection", x = {
980
1106
  BatchGetDocuments: "batchGet",
981
1107
  Commit: "commit",
982
1108
  RunQuery: "runQuery",
@@ -1005,14 +1131,14 @@ class __PRIVATE_RestConnection {
1005
1131
  }
1006
1132
  V(t, e, r, n, i) {
1007
1133
  const s = __PRIVATE_generateUniqueDebugId(), o = this.I(t, e.toUriEncodedString());
1008
- __PRIVATE_logDebug(x, `Sending RPC '${t}' ${s}:`, o, r);
1134
+ __PRIVATE_logDebug(M, `Sending RPC '${t}' ${s}:`, o, r);
1009
1135
  const a = {
1010
1136
  "google-cloud-resource-prefix": this.P,
1011
1137
  "x-goog-request-params": this.R
1012
1138
  };
1013
- return this.p(a, n, i), this.F(t, o, a, r).then((e => (__PRIVATE_logDebug(x, `Received RPC '${t}' ${s}: `, e),
1139
+ return this.p(a, n, i), this.F(t, o, a, r).then((e => (__PRIVATE_logDebug(M, `Received RPC '${t}' ${s}: `, e),
1014
1140
  e)), (e => {
1015
- throw __PRIVATE_logWarn(x, `RPC '${t}' ${s} failed with error: `, e, "url: ", o, "request:", r),
1141
+ throw __PRIVATE_logWarn(M, `RPC '${t}' ${s} failed with error: `, e, "url: ", o, "request:", r),
1016
1142
  e;
1017
1143
  }));
1018
1144
  }
@@ -1039,7 +1165,7 @@ class __PRIVATE_RestConnection {
1039
1165
  e && e.headers.forEach(((e, r) => t[r] = e)), r && r.headers.forEach(((e, r) => t[r] = e));
1040
1166
  }
1041
1167
  I(t, e) {
1042
- const r = k[t];
1168
+ const r = x[t];
1043
1169
  return `${this.T}/v1/${e}:${r}`;
1044
1170
  }
1045
1171
  /**
@@ -1076,7 +1202,7 @@ class __PRIVATE_RestConnection {
1076
1202
  * Important! The names of these identifiers matter because the string forms
1077
1203
  * are used for reverse lookups from the webchannel stream. Do NOT change the
1078
1204
  * names of these identifiers or change this into a const enum.
1079
- */ var U, j;
1205
+ */ var k, j;
1080
1206
 
1081
1207
  /**
1082
1208
  * Converts an HTTP Status Code to the equivalent error code.
@@ -1179,7 +1305,7 @@ function __PRIVATE_mapCodeFromHttpStatus(t) {
1179
1305
  /**
1180
1306
  * A Rest-based connection that relies on the native HTTP stack
1181
1307
  * (e.g. `fetch` or a polyfill).
1182
- */ (j = U || (U = {}))[j.OK = 0] = "OK", j[j.CANCELLED = 1] = "CANCELLED", j[j.UNKNOWN = 2] = "UNKNOWN",
1308
+ */ (j = k || (k = {}))[j.OK = 0] = "OK", j[j.CANCELLED = 1] = "CANCELLED", j[j.UNKNOWN = 2] = "UNKNOWN",
1183
1309
  j[j.INVALID_ARGUMENT = 3] = "INVALID_ARGUMENT", j[j.DEADLINE_EXCEEDED = 4] = "DEADLINE_EXCEEDED",
1184
1310
  j[j.NOT_FOUND = 5] = "NOT_FOUND", j[j.ALREADY_EXISTS = 6] = "ALREADY_EXISTS", j[j.PERMISSION_DENIED = 7] = "PERMISSION_DENIED",
1185
1311
  j[j.UNAUTHENTICATED = 16] = "UNAUTHENTICATED", j[j.RESOURCE_EXHAUSTED = 8] = "RESOURCE_EXHAUSTED",
@@ -1257,83 +1383,6 @@ class __PRIVATE_AggregateImpl {
1257
1383
  }
1258
1384
  }
1259
1385
 
1260
- /**
1261
- * @license
1262
- * Copyright 2020 Google LLC
1263
- *
1264
- * Licensed under the Apache License, Version 2.0 (the "License");
1265
- * you may not use this file except in compliance with the License.
1266
- * You may obtain a copy of the License at
1267
- *
1268
- * http://www.apache.org/licenses/LICENSE-2.0
1269
- *
1270
- * Unless required by applicable law or agreed to in writing, software
1271
- * distributed under the License is distributed on an "AS IS" BASIS,
1272
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1273
- * See the License for the specific language governing permissions and
1274
- * limitations under the License.
1275
- */
1276
- /**
1277
- * Generates `nBytes` of random bytes.
1278
- *
1279
- * If `nBytes < 0` , an error will be thrown.
1280
- */ function __PRIVATE_randomBytes(t) {
1281
- // Polyfills for IE and WebWorker by using `self` and `msCrypto` when `crypto` is not available.
1282
- const e =
1283
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1284
- "undefined" != typeof self && (self.crypto || self.msCrypto), r = new Uint8Array(t);
1285
- if (e && "function" == typeof e.getRandomValues) e.getRandomValues(r); else
1286
- // Falls back to Math.random
1287
- for (let e = 0; e < t; e++) r[e] = Math.floor(256 * Math.random());
1288
- return r;
1289
- }
1290
-
1291
- /**
1292
- * @license
1293
- * Copyright 2017 Google LLC
1294
- *
1295
- * Licensed under the Apache License, Version 2.0 (the "License");
1296
- * you may not use this file except in compliance with the License.
1297
- * You may obtain a copy of the License at
1298
- *
1299
- * http://www.apache.org/licenses/LICENSE-2.0
1300
- *
1301
- * Unless required by applicable law or agreed to in writing, software
1302
- * distributed under the License is distributed on an "AS IS" BASIS,
1303
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1304
- * See the License for the specific language governing permissions and
1305
- * limitations under the License.
1306
- */
1307
- /**
1308
- * A utility class for generating unique alphanumeric IDs of a specified length.
1309
- *
1310
- * @internal
1311
- * Exported internally for testing purposes.
1312
- */ class __PRIVATE_AutoId {
1313
- static newId() {
1314
- // Alphanumeric characters
1315
- const t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", e = 62 * Math.floor(256 / 62);
1316
- // The largest byte value that is a multiple of `char.length`.
1317
- let r = "";
1318
- for (;r.length < 20; ) {
1319
- const n = __PRIVATE_randomBytes(40);
1320
- for (let i = 0; i < n.length; ++i)
1321
- // Only accept values that are [0, maxMultiple), this ensures they can
1322
- // be evenly mapped to indices of `chars` via a modulo operation.
1323
- r.length < 20 && n[i] < e && (r += t.charAt(n[i] % 62));
1324
- }
1325
- return r;
1326
- }
1327
- }
1328
-
1329
- function __PRIVATE_primitiveComparator(t, e) {
1330
- return t < e ? -1 : t > e ? 1 : 0;
1331
- }
1332
-
1333
- /** Helper to compare arrays using isEqual(). */ function __PRIVATE_arrayEquals(t, e, r) {
1334
- return t.length === e.length && t.every(((t, n) => r(t, e[n])));
1335
- }
1336
-
1337
1386
  /**
1338
1387
  * @license
1339
1388
  * Copyright 2017 Google LLC
@@ -1937,7 +1986,7 @@ function __PRIVATE_valueCompare(t, e) {
1937
1986
  return __PRIVATE_compareTimestamps(__PRIVATE_getLocalWriteTime(t), __PRIVATE_getLocalWriteTime(e));
1938
1987
 
1939
1988
  case 5 /* TypeOrder.StringValue */ :
1940
- return __PRIVATE_primitiveComparator(t.stringValue, e.stringValue);
1989
+ return __PRIVATE_compareUtf8Strings(t.stringValue, e.stringValue);
1941
1990
 
1942
1991
  case 6 /* TypeOrder.BlobValue */ :
1943
1992
  return function __PRIVATE_compareBlobs(t, e) {
@@ -1985,7 +2034,7 @@ function __PRIVATE_valueCompare(t, e) {
1985
2034
  // canonical IDs are independent of insertion order.
1986
2035
  n.sort(), s.sort();
1987
2036
  for (let t = 0; t < n.length && t < s.length; ++t) {
1988
- const e = __PRIVATE_primitiveComparator(n[t], s[t]);
2037
+ const e = __PRIVATE_compareUtf8Strings(n[t], s[t]);
1989
2038
  if (0 !== e) return e;
1990
2039
  const o = __PRIVATE_valueCompare(r[n[t]], i[s[t]]);
1991
2040
  if (0 !== o) return o;
@@ -3933,7 +3982,7 @@ class __PRIVATE_ExponentialBackoff {
3933
3982
  * Note that jitter will still be applied, so the actual delay could be as
3934
3983
  * much as 1.5*maxDelayMs.
3935
3984
  */ , i = 6e4) {
3936
- this.L = t, this.timerId = e, this.M = r, this.k = n, this.U = i, this.j = 0, this.W = null,
3985
+ this.L = t, this.timerId = e, this.U = r, this.M = n, this.k = i, this.j = 0, this.W = null,
3937
3986
  /** The last backoff attempt, as epoch milliseconds. */
3938
3987
  this.K = Date.now(), this.reset();
3939
3988
  }
@@ -3950,7 +3999,7 @@ class __PRIVATE_ExponentialBackoff {
3950
3999
  * Resets the backoff delay to the maximum delay (e.g. for use after a
3951
4000
  * RESOURCE_EXHAUSTED error).
3952
4001
  */ G() {
3953
- this.j = this.U;
4002
+ this.j = this.k;
3954
4003
  }
3955
4004
  /**
3956
4005
  * Returns a promise that resolves after currentDelayMs, and increases the
@@ -3968,7 +4017,7 @@ class __PRIVATE_ExponentialBackoff {
3968
4017
  t()))),
3969
4018
  // Apply backoff factor to determine next delay and ensure it is within
3970
4019
  // bounds.
3971
- this.j *= this.k, this.j < this.M && (this.j = this.M), this.j > this.U && (this.j = this.U);
4020
+ this.j *= this.M, this.j < this.U && (this.j = this.U), this.j > this.k && (this.j = this.k);
3972
4021
  }
3973
4022
  Y() {
3974
4023
  null !== this.W && (this.W.skipDelay(), this.W = null);
@@ -7311,7 +7360,7 @@ class __PRIVATE_AsyncQueueImpl {
7311
7360
  * @param lastTimerId - Delayed operations up to and including this TimerId
7312
7361
  * will be drained. Pass TimerId.All to run all delayed operations.
7313
7362
  * @returns a Promise that resolves once all operations have been run.
7314
- */ Mt(t) {
7363
+ */ Ut(t) {
7315
7364
  // Note that draining may generate more delayed ops, so we do that first.
7316
7365
  return this.Qt().then((() => {
7317
7366
  // Run ops in the same order they'd run if they ran naturally.
@@ -7323,7 +7372,7 @@ class __PRIVATE_AsyncQueueImpl {
7323
7372
  }
7324
7373
  /**
7325
7374
  * For Tests: Skip all subsequent delays for a timer id.
7326
- */ xt(t) {
7375
+ */ Mt(t) {
7327
7376
  this.Ct.push(t);
7328
7377
  }
7329
7378
  /** Called once a DelayedOperation is run or canceled. */ $t(t) {