@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.
- package/dist/firestore/src/util/misc.d.ts +2 -0
- package/dist/index.cjs.js +254 -225
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm2017.js +254 -225
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.node.cjs.js +96 -41
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +96 -41
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +185 -156
- package/dist/index.rn.js.map +1 -1
- package/dist/lite/firestore/src/util/misc.d.ts +2 -0
- package/dist/lite/index.browser.esm2017.js +149 -100
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.cjs.js +149 -100
- package/dist/lite/index.cjs.js.map +1 -1
- package/dist/lite/index.node.cjs.js +171 -97
- package/dist/lite/index.node.cjs.js.map +1 -1
- package/dist/lite/index.node.mjs +171 -97
- package/dist/lite/index.node.mjs.map +1 -1
- package/dist/lite/index.rn.esm2017.js +150 -101
- package/dist/lite/index.rn.esm2017.js.map +1 -1
- package/package.json +1 -1
|
@@ -10,7 +10,7 @@ var util = require('@firebase/util');
|
|
|
10
10
|
var bloomBlob = require('@firebase/webchannel-wrapper/bloom-blob');
|
|
11
11
|
var crypto = require('crypto');
|
|
12
12
|
|
|
13
|
-
const version$1 = "4.7.
|
|
13
|
+
const version$1 = "4.7.10-20250318131644";
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* @license
|
|
@@ -63,7 +63,7 @@ User.GOOGLE_CREDENTIALS = new User('google-credentials-uid');
|
|
|
63
63
|
User.FIRST_PARTY = new User('first-party-uid');
|
|
64
64
|
User.MOCK_USER = new User('mock-user');
|
|
65
65
|
|
|
66
|
-
const version = "11.
|
|
66
|
+
const version = "11.5.0-20250318131644";
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
69
|
* @license
|
|
@@ -703,6 +703,171 @@ function databaseIdFromApp(app, database) {
|
|
|
703
703
|
return new DatabaseId(app.options.projectId, database);
|
|
704
704
|
}
|
|
705
705
|
|
|
706
|
+
/**
|
|
707
|
+
* @license
|
|
708
|
+
* Copyright 2020 Google LLC
|
|
709
|
+
*
|
|
710
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
711
|
+
* you may not use this file except in compliance with the License.
|
|
712
|
+
* You may obtain a copy of the License at
|
|
713
|
+
*
|
|
714
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
715
|
+
*
|
|
716
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
717
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
718
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
719
|
+
* See the License for the specific language governing permissions and
|
|
720
|
+
* limitations under the License.
|
|
721
|
+
*/
|
|
722
|
+
/**
|
|
723
|
+
* Generates `nBytes` of random bytes.
|
|
724
|
+
*
|
|
725
|
+
* If `nBytes < 0` , an error will be thrown.
|
|
726
|
+
*/
|
|
727
|
+
function randomBytes(nBytes) {
|
|
728
|
+
return crypto.randomBytes(nBytes);
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
/**
|
|
732
|
+
* @license
|
|
733
|
+
* Copyright 2023 Google LLC
|
|
734
|
+
*
|
|
735
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
736
|
+
* you may not use this file except in compliance with the License.
|
|
737
|
+
* You may obtain a copy of the License at
|
|
738
|
+
*
|
|
739
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
740
|
+
*
|
|
741
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
742
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
743
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
744
|
+
* See the License for the specific language governing permissions and
|
|
745
|
+
* limitations under the License.
|
|
746
|
+
*/
|
|
747
|
+
/**
|
|
748
|
+
* An instance of the Platform's 'TextEncoder' implementation.
|
|
749
|
+
*/
|
|
750
|
+
function newTextEncoder() {
|
|
751
|
+
return new TextEncoder();
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
/**
|
|
755
|
+
* @license
|
|
756
|
+
* Copyright 2017 Google LLC
|
|
757
|
+
*
|
|
758
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
759
|
+
* you may not use this file except in compliance with the License.
|
|
760
|
+
* You may obtain a copy of the License at
|
|
761
|
+
*
|
|
762
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
763
|
+
*
|
|
764
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
765
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
766
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
767
|
+
* See the License for the specific language governing permissions and
|
|
768
|
+
* limitations under the License.
|
|
769
|
+
*/
|
|
770
|
+
/**
|
|
771
|
+
* A utility class for generating unique alphanumeric IDs of a specified length.
|
|
772
|
+
*
|
|
773
|
+
* @internal
|
|
774
|
+
* Exported internally for testing purposes.
|
|
775
|
+
*/
|
|
776
|
+
class AutoId {
|
|
777
|
+
static newId() {
|
|
778
|
+
// Alphanumeric characters
|
|
779
|
+
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
780
|
+
// The largest byte value that is a multiple of `char.length`.
|
|
781
|
+
const maxMultiple = Math.floor(256 / chars.length) * chars.length;
|
|
782
|
+
let autoId = '';
|
|
783
|
+
const targetLength = 20;
|
|
784
|
+
while (autoId.length < targetLength) {
|
|
785
|
+
const bytes = randomBytes(40);
|
|
786
|
+
for (let i = 0; i < bytes.length; ++i) {
|
|
787
|
+
// Only accept values that are [0, maxMultiple), this ensures they can
|
|
788
|
+
// be evenly mapped to indices of `chars` via a modulo operation.
|
|
789
|
+
if (autoId.length < targetLength && bytes[i] < maxMultiple) {
|
|
790
|
+
autoId += chars.charAt(bytes[i] % chars.length);
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
return autoId;
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
function primitiveComparator(left, right) {
|
|
798
|
+
if (left < right) {
|
|
799
|
+
return -1;
|
|
800
|
+
}
|
|
801
|
+
if (left > right) {
|
|
802
|
+
return 1;
|
|
803
|
+
}
|
|
804
|
+
return 0;
|
|
805
|
+
}
|
|
806
|
+
/** Compare strings in UTF-8 encoded byte order */
|
|
807
|
+
function compareUtf8Strings(left, right) {
|
|
808
|
+
let i = 0;
|
|
809
|
+
while (i < left.length && i < right.length) {
|
|
810
|
+
const leftCodePoint = left.codePointAt(i);
|
|
811
|
+
const rightCodePoint = right.codePointAt(i);
|
|
812
|
+
if (leftCodePoint !== rightCodePoint) {
|
|
813
|
+
if (leftCodePoint < 128 && rightCodePoint < 128) {
|
|
814
|
+
// ASCII comparison
|
|
815
|
+
return primitiveComparator(leftCodePoint, rightCodePoint);
|
|
816
|
+
}
|
|
817
|
+
else {
|
|
818
|
+
// Lazy instantiate TextEncoder
|
|
819
|
+
const encoder = newTextEncoder();
|
|
820
|
+
// UTF-8 encode the character at index i for byte comparison.
|
|
821
|
+
const leftBytes = encoder.encode(getUtf8SafeSubstring(left, i));
|
|
822
|
+
const rightBytes = encoder.encode(getUtf8SafeSubstring(right, i));
|
|
823
|
+
const comp = compareByteArrays(leftBytes, rightBytes);
|
|
824
|
+
if (comp !== 0) {
|
|
825
|
+
return comp;
|
|
826
|
+
}
|
|
827
|
+
else {
|
|
828
|
+
// EXTREMELY RARE CASE: Code points differ, but their UTF-8 byte
|
|
829
|
+
// representations are identical. This can happen with malformed input
|
|
830
|
+
// (invalid surrogate pairs). The backend also actively prevents invalid
|
|
831
|
+
// surrogates as INVALID_ARGUMENT errors, so we almost never receive
|
|
832
|
+
// invalid strings from backend.
|
|
833
|
+
// Fallback to code point comparison for graceful handling.
|
|
834
|
+
return primitiveComparator(leftCodePoint, rightCodePoint);
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
// Increment by 2 for surrogate pairs, 1 otherwise
|
|
839
|
+
i += leftCodePoint > 0xffff ? 2 : 1;
|
|
840
|
+
}
|
|
841
|
+
// Compare lengths if all characters are equal
|
|
842
|
+
return primitiveComparator(left.length, right.length);
|
|
843
|
+
}
|
|
844
|
+
function getUtf8SafeSubstring(str, index) {
|
|
845
|
+
const firstCodePoint = str.codePointAt(index);
|
|
846
|
+
if (firstCodePoint > 0xffff) {
|
|
847
|
+
// It's a surrogate pair, return the whole pair
|
|
848
|
+
return str.substring(index, index + 2);
|
|
849
|
+
}
|
|
850
|
+
else {
|
|
851
|
+
// It's a single code point, return it
|
|
852
|
+
return str.substring(index, index + 1);
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
function compareByteArrays(left, right) {
|
|
856
|
+
for (let i = 0; i < left.length && i < right.length; ++i) {
|
|
857
|
+
if (left[i] !== right[i]) {
|
|
858
|
+
return primitiveComparator(left[i], right[i]);
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
return primitiveComparator(left.length, right.length);
|
|
862
|
+
}
|
|
863
|
+
/** Helper to compare arrays using isEqual(). */
|
|
864
|
+
function arrayEquals(left, right, comparator) {
|
|
865
|
+
if (left.length !== right.length) {
|
|
866
|
+
return false;
|
|
867
|
+
}
|
|
868
|
+
return left.every((value, index) => comparator(value, right[index]));
|
|
869
|
+
}
|
|
870
|
+
|
|
706
871
|
/**
|
|
707
872
|
* @license
|
|
708
873
|
* Copyright 2017 Google LLC
|
|
@@ -825,7 +990,7 @@ class BasePath {
|
|
|
825
990
|
return comparison;
|
|
826
991
|
}
|
|
827
992
|
}
|
|
828
|
-
return
|
|
993
|
+
return primitiveComparator(p1.length, p2.length);
|
|
829
994
|
}
|
|
830
995
|
static compareSegments(lhs, rhs) {
|
|
831
996
|
const isLhsNumeric = BasePath.isNumericId(lhs);
|
|
@@ -844,13 +1009,7 @@ class BasePath {
|
|
|
844
1009
|
}
|
|
845
1010
|
else {
|
|
846
1011
|
// both non-numeric
|
|
847
|
-
|
|
848
|
-
return -1;
|
|
849
|
-
}
|
|
850
|
-
if (lhs > rhs) {
|
|
851
|
-
return 1;
|
|
852
|
-
}
|
|
853
|
-
return 0;
|
|
1012
|
+
return compareUtf8Strings(lhs, rhs);
|
|
854
1013
|
}
|
|
855
1014
|
}
|
|
856
1015
|
// Checks if a segment is a numeric ID (starts with "__id" and ends with "__").
|
|
@@ -1650,91 +1809,6 @@ function newConnection(databaseInfo) {
|
|
|
1650
1809
|
return new FetchConnection(databaseInfo);
|
|
1651
1810
|
}
|
|
1652
1811
|
|
|
1653
|
-
/**
|
|
1654
|
-
* @license
|
|
1655
|
-
* Copyright 2020 Google LLC
|
|
1656
|
-
*
|
|
1657
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1658
|
-
* you may not use this file except in compliance with the License.
|
|
1659
|
-
* You may obtain a copy of the License at
|
|
1660
|
-
*
|
|
1661
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1662
|
-
*
|
|
1663
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1664
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1665
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1666
|
-
* See the License for the specific language governing permissions and
|
|
1667
|
-
* limitations under the License.
|
|
1668
|
-
*/
|
|
1669
|
-
/**
|
|
1670
|
-
* Generates `nBytes` of random bytes.
|
|
1671
|
-
*
|
|
1672
|
-
* If `nBytes < 0` , an error will be thrown.
|
|
1673
|
-
*/
|
|
1674
|
-
function randomBytes(nBytes) {
|
|
1675
|
-
return crypto.randomBytes(nBytes);
|
|
1676
|
-
}
|
|
1677
|
-
|
|
1678
|
-
/**
|
|
1679
|
-
* @license
|
|
1680
|
-
* Copyright 2017 Google LLC
|
|
1681
|
-
*
|
|
1682
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1683
|
-
* you may not use this file except in compliance with the License.
|
|
1684
|
-
* You may obtain a copy of the License at
|
|
1685
|
-
*
|
|
1686
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1687
|
-
*
|
|
1688
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1689
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1690
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1691
|
-
* See the License for the specific language governing permissions and
|
|
1692
|
-
* limitations under the License.
|
|
1693
|
-
*/
|
|
1694
|
-
/**
|
|
1695
|
-
* A utility class for generating unique alphanumeric IDs of a specified length.
|
|
1696
|
-
*
|
|
1697
|
-
* @internal
|
|
1698
|
-
* Exported internally for testing purposes.
|
|
1699
|
-
*/
|
|
1700
|
-
class AutoId {
|
|
1701
|
-
static newId() {
|
|
1702
|
-
// Alphanumeric characters
|
|
1703
|
-
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
1704
|
-
// The largest byte value that is a multiple of `char.length`.
|
|
1705
|
-
const maxMultiple = Math.floor(256 / chars.length) * chars.length;
|
|
1706
|
-
let autoId = '';
|
|
1707
|
-
const targetLength = 20;
|
|
1708
|
-
while (autoId.length < targetLength) {
|
|
1709
|
-
const bytes = randomBytes(40);
|
|
1710
|
-
for (let i = 0; i < bytes.length; ++i) {
|
|
1711
|
-
// Only accept values that are [0, maxMultiple), this ensures they can
|
|
1712
|
-
// be evenly mapped to indices of `chars` via a modulo operation.
|
|
1713
|
-
if (autoId.length < targetLength && bytes[i] < maxMultiple) {
|
|
1714
|
-
autoId += chars.charAt(bytes[i] % chars.length);
|
|
1715
|
-
}
|
|
1716
|
-
}
|
|
1717
|
-
}
|
|
1718
|
-
return autoId;
|
|
1719
|
-
}
|
|
1720
|
-
}
|
|
1721
|
-
function primitiveComparator(left, right) {
|
|
1722
|
-
if (left < right) {
|
|
1723
|
-
return -1;
|
|
1724
|
-
}
|
|
1725
|
-
if (left > right) {
|
|
1726
|
-
return 1;
|
|
1727
|
-
}
|
|
1728
|
-
return 0;
|
|
1729
|
-
}
|
|
1730
|
-
/** Helper to compare arrays using isEqual(). */
|
|
1731
|
-
function arrayEquals(left, right, comparator) {
|
|
1732
|
-
if (left.length !== right.length) {
|
|
1733
|
-
return false;
|
|
1734
|
-
}
|
|
1735
|
-
return left.every((value, index) => comparator(value, right[index]));
|
|
1736
|
-
}
|
|
1737
|
-
|
|
1738
1812
|
/**
|
|
1739
1813
|
* @license
|
|
1740
1814
|
* Copyright 2017 Google LLC
|
|
@@ -2448,7 +2522,7 @@ function valueCompare(left, right) {
|
|
|
2448
2522
|
case 4 /* TypeOrder.ServerTimestampValue */:
|
|
2449
2523
|
return compareTimestamps(getLocalWriteTime(left), getLocalWriteTime(right));
|
|
2450
2524
|
case 5 /* TypeOrder.StringValue */:
|
|
2451
|
-
return
|
|
2525
|
+
return compareUtf8Strings(left.stringValue, right.stringValue);
|
|
2452
2526
|
case 6 /* TypeOrder.BlobValue */:
|
|
2453
2527
|
return compareBlobs(left.bytesValue, right.bytesValue);
|
|
2454
2528
|
case 7 /* TypeOrder.RefValue */:
|
|
@@ -2569,7 +2643,7 @@ function compareMaps(left, right) {
|
|
|
2569
2643
|
leftKeys.sort();
|
|
2570
2644
|
rightKeys.sort();
|
|
2571
2645
|
for (let i = 0; i < leftKeys.length && i < rightKeys.length; ++i) {
|
|
2572
|
-
const keyCompare =
|
|
2646
|
+
const keyCompare = compareUtf8Strings(leftKeys[i], rightKeys[i]);
|
|
2573
2647
|
if (keyCompare !== 0) {
|
|
2574
2648
|
return keyCompare;
|
|
2575
2649
|
}
|