@firebase/firestore 4.7.7-canary.4d2fc6e82 → 4.7.7-canary.554c7bdc1

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.
Files changed (34) hide show
  1. package/dist/firestore/src/global_index.d.ts +7 -0
  2. package/dist/firestore/src/lite-api/database.d.ts +4 -0
  3. package/dist/firestore/src/lite-api/settings.d.ts +4 -0
  4. package/dist/firestore/src/util/misc.d.ts +0 -2
  5. package/dist/firestore/test/integration/util/settings.d.ts +1 -0
  6. package/dist/index.cjs.js +243 -241
  7. package/dist/index.cjs.js.map +1 -1
  8. package/dist/index.esm2017.js +244 -242
  9. package/dist/index.esm2017.js.map +1 -1
  10. package/dist/index.node.cjs.js +54 -53
  11. package/dist/index.node.cjs.js.map +1 -1
  12. package/dist/index.node.mjs +55 -54
  13. package/dist/index.node.mjs.map +1 -1
  14. package/dist/index.rn.js +196 -194
  15. package/dist/index.rn.js.map +1 -1
  16. package/dist/internal.d.ts +7 -0
  17. package/dist/lite/firestore/src/lite-api/database.d.ts +4 -0
  18. package/dist/lite/firestore/src/lite-api/settings.d.ts +4 -0
  19. package/dist/lite/firestore/src/util/misc.d.ts +0 -2
  20. package/dist/lite/firestore/test/integration/util/settings.d.ts +1 -0
  21. package/dist/lite/index.browser.esm2017.js +146 -166
  22. package/dist/lite/index.browser.esm2017.js.map +1 -1
  23. package/dist/lite/index.cjs.js +146 -166
  24. package/dist/lite/index.cjs.js.map +1 -1
  25. package/dist/lite/index.node.cjs.js +110 -128
  26. package/dist/lite/index.node.cjs.js.map +1 -1
  27. package/dist/lite/index.node.mjs +111 -129
  28. package/dist/lite/index.node.mjs.map +1 -1
  29. package/dist/lite/index.rn.esm2017.js +159 -179
  30. package/dist/lite/index.rn.esm2017.js.map +1 -1
  31. package/dist/lite/internal.d.ts +7 -0
  32. package/dist/lite/private.d.ts +4 -0
  33. package/dist/private.d.ts +4 -0
  34. package/package.json +9 -9
@@ -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.7-canary.4d2fc6e82";
13
+ const version$1 = "4.7.7-canary.554c7bdc1";
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.3.0-canary.4d2fc6e82";
66
+ const version = "11.3.0-canary.554c7bdc1";
67
67
 
68
68
  /**
69
69
  * @license
@@ -703,127 +703,6 @@ 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
- // Convert the string to UTF-8 encoded bytes
809
- const encodedLeft = newTextEncoder().encode(left);
810
- const encodedRight = newTextEncoder().encode(right);
811
- for (let i = 0; i < Math.min(encodedLeft.length, encodedRight.length); i++) {
812
- const comparison = primitiveComparator(encodedLeft[i], encodedRight[i]);
813
- if (comparison !== 0) {
814
- return comparison;
815
- }
816
- }
817
- return primitiveComparator(encodedLeft.length, encodedRight.length);
818
- }
819
- /** Helper to compare arrays using isEqual(). */
820
- function arrayEquals(left, right, comparator) {
821
- if (left.length !== right.length) {
822
- return false;
823
- }
824
- return left.every((value, index) => comparator(value, right[index]));
825
- }
826
-
827
706
  /**
828
707
  * @license
829
708
  * Copyright 2017 Google LLC
@@ -946,7 +825,7 @@ class BasePath {
946
825
  return comparison;
947
826
  }
948
827
  }
949
- return primitiveComparator(p1.length, p2.length);
828
+ return Math.sign(p1.length - p2.length);
950
829
  }
951
830
  static compareSegments(lhs, rhs) {
952
831
  const isLhsNumeric = BasePath.isNumericId(lhs);
@@ -965,7 +844,13 @@ class BasePath {
965
844
  }
966
845
  else {
967
846
  // both non-numeric
968
- return compareUtf8Strings(lhs, rhs);
847
+ if (lhs < rhs) {
848
+ return -1;
849
+ }
850
+ if (lhs > rhs) {
851
+ return 1;
852
+ }
853
+ return 0;
969
854
  }
970
855
  }
971
856
  // Checks if a segment is a numeric ID (starts with "__id" and ends with "__").
@@ -1765,6 +1650,91 @@ function newConnection(databaseInfo) {
1765
1650
  return new FetchConnection(databaseInfo);
1766
1651
  }
1767
1652
 
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
+
1768
1738
  /**
1769
1739
  * @license
1770
1740
  * Copyright 2017 Google LLC
@@ -2478,7 +2448,7 @@ function valueCompare(left, right) {
2478
2448
  case 4 /* TypeOrder.ServerTimestampValue */:
2479
2449
  return compareTimestamps(getLocalWriteTime(left), getLocalWriteTime(right));
2480
2450
  case 5 /* TypeOrder.StringValue */:
2481
- return compareUtf8Strings(left.stringValue, right.stringValue);
2451
+ return primitiveComparator(left.stringValue, right.stringValue);
2482
2452
  case 6 /* TypeOrder.BlobValue */:
2483
2453
  return compareBlobs(left.bytesValue, right.bytesValue);
2484
2454
  case 7 /* TypeOrder.RefValue */:
@@ -2599,7 +2569,7 @@ function compareMaps(left, right) {
2599
2569
  leftKeys.sort();
2600
2570
  rightKeys.sort();
2601
2571
  for (let i = 0; i < leftKeys.length && i < rightKeys.length; ++i) {
2602
- const keyCompare = compareUtf8Strings(leftKeys[i], rightKeys[i]);
2572
+ const keyCompare = primitiveComparator(leftKeys[i], rightKeys[i]);
2603
2573
  if (keyCompare !== 0) {
2604
2574
  return keyCompare;
2605
2575
  }
@@ -5708,6 +5678,7 @@ class Firestore {
5708
5678
  this._persistenceKey = '(lite)';
5709
5679
  this._settings = new FirestoreSettingsImpl({});
5710
5680
  this._settingsFrozen = false;
5681
+ this._emulatorOptions = {};
5711
5682
  // A task that is assigned when the terminate() is invoked and resolved when
5712
5683
  // all components have shut down. Otherwise, Firestore is not terminated,
5713
5684
  // which can mean either the FirestoreClient is in the process of starting,
@@ -5738,6 +5709,7 @@ class Firestore {
5738
5709
  'methods on a Firestore object.');
5739
5710
  }
5740
5711
  this._settings = new FirestoreSettingsImpl(settings);
5712
+ this._emulatorOptions = settings.emulatorOptions || {};
5741
5713
  if (settings.credentials !== undefined) {
5742
5714
  this._authCredentials = makeAuthCredentialsProvider(settings.credentials);
5743
5715
  }
@@ -5745,6 +5717,9 @@ class Firestore {
5745
5717
  _getSettings() {
5746
5718
  return this._settings;
5747
5719
  }
5720
+ _getEmulatorOptions() {
5721
+ return this._emulatorOptions;
5722
+ }
5748
5723
  _freezeSettings() {
5749
5724
  this._settingsFrozen = true;
5750
5725
  return this._settings;
@@ -5834,12 +5809,19 @@ function connectFirestoreEmulator(firestore, host, port, options = {}) {
5834
5809
  var _a;
5835
5810
  firestore = cast(firestore, Firestore);
5836
5811
  const settings = firestore._getSettings();
5812
+ const existingConfig = Object.assign(Object.assign({}, settings), { emulatorOptions: firestore._getEmulatorOptions() });
5837
5813
  const newHostSetting = `${host}:${port}`;
5838
5814
  if (settings.host !== DEFAULT_HOST && settings.host !== newHostSetting) {
5839
5815
  logWarn('Host has been set in both settings() and connectFirestoreEmulator(), emulator host ' +
5840
5816
  'will be used.');
5841
5817
  }
5842
- firestore._setSettings(Object.assign(Object.assign({}, settings), { host: newHostSetting, ssl: false }));
5818
+ const newConfig = Object.assign(Object.assign({}, settings), { host: newHostSetting, ssl: false, emulatorOptions: options });
5819
+ // No-op if the new configuration matches the current configuration. This supports SSR
5820
+ // enviornments which might call `connectFirestoreEmulator` multiple times as a standard practice.
5821
+ if (util.deepEqual(newConfig, existingConfig)) {
5822
+ return;
5823
+ }
5824
+ firestore._setSettings(newConfig);
5843
5825
  if (options.mockUserToken) {
5844
5826
  let token;
5845
5827
  let user;