@firebase/firestore 3.4.9 → 3.4.10-canary.8e952e2ee

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 (147) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/firestore/src/api/transaction.d.ts +2 -0
  3. package/dist/firestore/src/core/component_provider.d.ts +11 -6
  4. package/dist/firestore/src/lite-api/transaction.d.ts +2 -0
  5. package/dist/firestore/src/local/document_overlay_cache.d.ts +5 -0
  6. package/dist/firestore/src/local/index_backfiller.d.ts +44 -0
  7. package/dist/firestore/src/local/index_manager.d.ts +2 -0
  8. package/dist/firestore/src/local/indexeddb_document_overlay_cache.d.ts +1 -0
  9. package/dist/firestore/src/local/indexeddb_index_manager.d.ts +1 -0
  10. package/dist/firestore/src/local/indexeddb_schema.d.ts +3 -2
  11. package/dist/firestore/src/local/indexeddb_schema_converter.d.ts +1 -0
  12. package/dist/firestore/src/local/indexeddb_sentinels.d.ts +1 -0
  13. package/dist/firestore/src/local/local_documents_view.d.ts +64 -9
  14. package/dist/firestore/src/local/local_store.d.ts +9 -0
  15. package/dist/firestore/src/local/lru_garbage_collector_impl.d.ts +5 -5
  16. package/dist/firestore/src/local/memory_document_overlay_cache.d.ts +1 -0
  17. package/dist/firestore/src/local/memory_index_manager.d.ts +1 -0
  18. package/dist/firestore/src/local/overlayed_document.d.ts +36 -0
  19. package/dist/firestore/src/local/persistence.d.ts +3 -5
  20. package/dist/firestore/src/local/persistence_promise.d.ts +11 -0
  21. package/dist/firestore/src/local/query_engine.d.ts +1 -1
  22. package/dist/firestore/src/model/collections.d.ts +8 -2
  23. package/dist/firestore/src/model/field_mask.d.ts +6 -0
  24. package/dist/firestore/src/model/mutation.d.ts +19 -1
  25. package/dist/firestore/src/model/mutation_batch.d.ts +8 -4
  26. package/dist/firestore/src/tsdoc-metadata.json +11 -11
  27. package/dist/firestore/src/util/async_queue.d.ts +5 -1
  28. package/dist/firestore/test/unit/local/index_backfiller.test.d.ts +17 -0
  29. package/dist/firestore/test/unit/local/test_document_overlay_cache.d.ts +1 -0
  30. package/dist/firestore/test/unit/specs/spec_test_components.d.ts +5 -3
  31. package/dist/firestore/test/util/helpers.d.ts +13 -0
  32. package/dist/index.d.ts +4 -2
  33. package/dist/index.esm2017.js +10698 -10303
  34. package/dist/index.esm2017.js.map +1 -1
  35. package/dist/index.esm5.js +10986 -10471
  36. package/dist/index.esm5.js.map +1 -1
  37. package/dist/index.node.cjs.js +6349 -5731
  38. package/dist/index.node.cjs.js.map +1 -1
  39. package/dist/index.node.mjs +6349 -5731
  40. package/dist/index.node.mjs.map +1 -1
  41. package/dist/index.rn.js +10687 -10291
  42. package/dist/index.rn.js.map +1 -1
  43. package/dist/internal.d.ts +6137 -5964
  44. package/dist/lite/firestore/src/api/transaction.d.ts +2 -0
  45. package/dist/lite/firestore/src/core/component_provider.d.ts +11 -6
  46. package/dist/lite/firestore/src/lite-api/transaction.d.ts +2 -0
  47. package/dist/lite/firestore/src/local/document_overlay_cache.d.ts +5 -0
  48. package/dist/lite/firestore/src/local/index_backfiller.d.ts +44 -0
  49. package/dist/lite/firestore/src/local/index_manager.d.ts +2 -0
  50. package/dist/lite/firestore/src/local/indexeddb_document_overlay_cache.d.ts +1 -0
  51. package/dist/lite/firestore/src/local/indexeddb_index_manager.d.ts +1 -0
  52. package/dist/lite/firestore/src/local/indexeddb_schema.d.ts +3 -2
  53. package/dist/lite/firestore/src/local/indexeddb_schema_converter.d.ts +1 -0
  54. package/dist/lite/firestore/src/local/indexeddb_sentinels.d.ts +1 -0
  55. package/dist/lite/firestore/src/local/local_documents_view.d.ts +64 -9
  56. package/dist/lite/firestore/src/local/local_store.d.ts +9 -0
  57. package/dist/lite/firestore/src/local/lru_garbage_collector_impl.d.ts +5 -5
  58. package/dist/lite/firestore/src/local/memory_document_overlay_cache.d.ts +1 -0
  59. package/dist/lite/firestore/src/local/memory_index_manager.d.ts +1 -0
  60. package/dist/lite/firestore/src/local/overlayed_document.d.ts +36 -0
  61. package/dist/lite/firestore/src/local/persistence.d.ts +3 -5
  62. package/dist/lite/firestore/src/local/persistence_promise.d.ts +11 -0
  63. package/dist/lite/firestore/src/local/query_engine.d.ts +1 -1
  64. package/dist/lite/firestore/src/model/collections.d.ts +8 -2
  65. package/dist/lite/firestore/src/model/field_mask.d.ts +6 -0
  66. package/dist/lite/firestore/src/model/mutation.d.ts +19 -1
  67. package/dist/lite/firestore/src/model/mutation_batch.d.ts +8 -4
  68. package/dist/lite/firestore/src/util/async_queue.d.ts +5 -1
  69. package/dist/lite/firestore/test/unit/local/index_backfiller.test.d.ts +17 -0
  70. package/dist/lite/firestore/test/unit/local/test_document_overlay_cache.d.ts +1 -0
  71. package/dist/lite/firestore/test/unit/specs/spec_test_components.d.ts +5 -3
  72. package/dist/lite/firestore/test/util/helpers.d.ts +13 -0
  73. package/dist/lite/index.browser.esm2017.js +1220 -738
  74. package/dist/lite/index.browser.esm2017.js.map +1 -1
  75. package/dist/lite/index.browser.esm5.js +1156 -764
  76. package/dist/lite/index.browser.esm5.js.map +1 -1
  77. package/dist/lite/index.d.ts +2 -0
  78. package/dist/lite/index.node.cjs.js +655 -2
  79. package/dist/lite/index.node.cjs.js.map +1 -1
  80. package/dist/lite/index.node.mjs +655 -2
  81. package/dist/lite/index.node.mjs.map +1 -1
  82. package/dist/lite/index.rn.esm2017.js +1184 -702
  83. package/dist/lite/index.rn.esm2017.js.map +1 -1
  84. package/dist/lite/internal.d.ts +2916 -2898
  85. package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +106 -104
  86. package/dist/lite/packages/firestore/src/api/transaction.d.ts +2 -0
  87. package/dist/lite/packages/firestore/src/core/component_provider.d.ts +11 -6
  88. package/dist/lite/packages/firestore/src/lite-api/transaction.d.ts +2 -0
  89. package/dist/lite/packages/firestore/src/local/document_overlay_cache.d.ts +5 -0
  90. package/dist/lite/packages/firestore/src/local/index_backfiller.d.ts +44 -0
  91. package/dist/lite/packages/firestore/src/local/index_manager.d.ts +2 -0
  92. package/dist/lite/packages/firestore/src/local/indexeddb_document_overlay_cache.d.ts +1 -0
  93. package/dist/lite/packages/firestore/src/local/indexeddb_index_manager.d.ts +1 -0
  94. package/dist/lite/packages/firestore/src/local/indexeddb_schema.d.ts +3 -2
  95. package/dist/lite/packages/firestore/src/local/indexeddb_schema_converter.d.ts +1 -0
  96. package/dist/lite/packages/firestore/src/local/indexeddb_sentinels.d.ts +1 -0
  97. package/dist/lite/packages/firestore/src/local/local_documents_view.d.ts +64 -9
  98. package/dist/lite/packages/firestore/src/local/local_store.d.ts +9 -0
  99. package/dist/lite/packages/firestore/src/local/lru_garbage_collector_impl.d.ts +5 -5
  100. package/dist/lite/packages/firestore/src/local/memory_document_overlay_cache.d.ts +1 -0
  101. package/dist/lite/packages/firestore/src/local/memory_index_manager.d.ts +1 -0
  102. package/dist/lite/packages/firestore/src/local/overlayed_document.d.ts +36 -0
  103. package/dist/lite/packages/firestore/src/local/persistence.d.ts +3 -5
  104. package/dist/lite/packages/firestore/src/local/persistence_promise.d.ts +11 -0
  105. package/dist/lite/packages/firestore/src/local/query_engine.d.ts +1 -1
  106. package/dist/lite/packages/firestore/src/model/collections.d.ts +8 -2
  107. package/dist/lite/packages/firestore/src/model/field_mask.d.ts +6 -0
  108. package/dist/lite/packages/firestore/src/model/mutation.d.ts +19 -1
  109. package/dist/lite/packages/firestore/src/model/mutation_batch.d.ts +8 -4
  110. package/dist/lite/packages/firestore/src/util/async_queue.d.ts +5 -1
  111. package/dist/lite/packages/firestore/test/unit/local/index_backfiller.test.d.ts +17 -0
  112. package/dist/lite/packages/firestore/test/unit/local/test_document_overlay_cache.d.ts +1 -0
  113. package/dist/lite/packages/firestore/test/unit/specs/spec_test_components.d.ts +5 -3
  114. package/dist/lite/packages/firestore/test/util/helpers.d.ts +13 -0
  115. package/dist/lite/private.d.ts +2776 -2758
  116. package/dist/packages/firestore/dist/index.esm2017.d.ts +203 -201
  117. package/dist/packages/firestore/src/api/transaction.d.ts +2 -0
  118. package/dist/packages/firestore/src/core/component_provider.d.ts +11 -6
  119. package/dist/packages/firestore/src/lite-api/transaction.d.ts +2 -0
  120. package/dist/packages/firestore/src/local/document_overlay_cache.d.ts +5 -0
  121. package/dist/packages/firestore/src/local/index_backfiller.d.ts +44 -0
  122. package/dist/packages/firestore/src/local/index_manager.d.ts +2 -0
  123. package/dist/packages/firestore/src/local/indexeddb_document_overlay_cache.d.ts +1 -0
  124. package/dist/packages/firestore/src/local/indexeddb_index_manager.d.ts +1 -0
  125. package/dist/packages/firestore/src/local/indexeddb_schema.d.ts +3 -2
  126. package/dist/packages/firestore/src/local/indexeddb_schema_converter.d.ts +1 -0
  127. package/dist/packages/firestore/src/local/indexeddb_sentinels.d.ts +1 -0
  128. package/dist/packages/firestore/src/local/local_documents_view.d.ts +64 -9
  129. package/dist/packages/firestore/src/local/local_store.d.ts +9 -0
  130. package/dist/packages/firestore/src/local/lru_garbage_collector_impl.d.ts +5 -5
  131. package/dist/packages/firestore/src/local/memory_document_overlay_cache.d.ts +1 -0
  132. package/dist/packages/firestore/src/local/memory_index_manager.d.ts +1 -0
  133. package/dist/packages/firestore/src/local/overlayed_document.d.ts +36 -0
  134. package/dist/packages/firestore/src/local/persistence.d.ts +3 -5
  135. package/dist/packages/firestore/src/local/persistence_promise.d.ts +11 -0
  136. package/dist/packages/firestore/src/local/query_engine.d.ts +1 -1
  137. package/dist/packages/firestore/src/model/collections.d.ts +8 -2
  138. package/dist/packages/firestore/src/model/field_mask.d.ts +6 -0
  139. package/dist/packages/firestore/src/model/mutation.d.ts +19 -1
  140. package/dist/packages/firestore/src/model/mutation_batch.d.ts +8 -4
  141. package/dist/packages/firestore/src/util/async_queue.d.ts +5 -1
  142. package/dist/packages/firestore/test/unit/local/index_backfiller.test.d.ts +17 -0
  143. package/dist/packages/firestore/test/unit/local/test_document_overlay_cache.d.ts +1 -0
  144. package/dist/packages/firestore/test/unit/specs/spec_test_components.d.ts +5 -3
  145. package/dist/packages/firestore/test/util/helpers.d.ts +13 -0
  146. package/dist/private.d.ts +5845 -5672
  147. package/package.json +19 -17
@@ -14,7 +14,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
14
14
 
15
15
  var nodeFetch__default = /*#__PURE__*/_interopDefaultLegacy(nodeFetch);
16
16
 
17
- const version$1 = "3.4.9";
17
+ const version$1 = "3.4.10-canary.8e952e2ee";
18
18
 
19
19
  /**
20
20
  * @license
@@ -67,7 +67,7 @@ User.GOOGLE_CREDENTIALS = new User('google-credentials-uid');
67
67
  User.FIRST_PARTY = new User('first-party-uid');
68
68
  User.MOCK_USER = new User('mock-user');
69
69
 
70
- const version = "9.8.0";
70
+ const version = "9.8.3-canary.8e952e2ee";
71
71
 
72
72
  /**
73
73
  * @license
@@ -1824,6 +1824,627 @@ function isEmpty(obj) {
1824
1824
  return true;
1825
1825
  }
1826
1826
 
1827
+ /**
1828
+ * @license
1829
+ * Copyright 2017 Google LLC
1830
+ *
1831
+ * Licensed under the Apache License, Version 2.0 (the "License");
1832
+ * you may not use this file except in compliance with the License.
1833
+ * You may obtain a copy of the License at
1834
+ *
1835
+ * http://www.apache.org/licenses/LICENSE-2.0
1836
+ *
1837
+ * Unless required by applicable law or agreed to in writing, software
1838
+ * distributed under the License is distributed on an "AS IS" BASIS,
1839
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1840
+ * See the License for the specific language governing permissions and
1841
+ * limitations under the License.
1842
+ */
1843
+ // An immutable sorted map implementation, based on a Left-leaning Red-Black
1844
+ // tree.
1845
+ class SortedMap {
1846
+ constructor(comparator, root) {
1847
+ this.comparator = comparator;
1848
+ this.root = root ? root : LLRBNode.EMPTY;
1849
+ }
1850
+ // Returns a copy of the map, with the specified key/value added or replaced.
1851
+ insert(key, value) {
1852
+ return new SortedMap(this.comparator, this.root
1853
+ .insert(key, value, this.comparator)
1854
+ .copy(null, null, LLRBNode.BLACK, null, null));
1855
+ }
1856
+ // Returns a copy of the map, with the specified key removed.
1857
+ remove(key) {
1858
+ return new SortedMap(this.comparator, this.root
1859
+ .remove(key, this.comparator)
1860
+ .copy(null, null, LLRBNode.BLACK, null, null));
1861
+ }
1862
+ // Returns the value of the node with the given key, or null.
1863
+ get(key) {
1864
+ let node = this.root;
1865
+ while (!node.isEmpty()) {
1866
+ const cmp = this.comparator(key, node.key);
1867
+ if (cmp === 0) {
1868
+ return node.value;
1869
+ }
1870
+ else if (cmp < 0) {
1871
+ node = node.left;
1872
+ }
1873
+ else if (cmp > 0) {
1874
+ node = node.right;
1875
+ }
1876
+ }
1877
+ return null;
1878
+ }
1879
+ // Returns the index of the element in this sorted map, or -1 if it doesn't
1880
+ // exist.
1881
+ indexOf(key) {
1882
+ // Number of nodes that were pruned when descending right
1883
+ let prunedNodes = 0;
1884
+ let node = this.root;
1885
+ while (!node.isEmpty()) {
1886
+ const cmp = this.comparator(key, node.key);
1887
+ if (cmp === 0) {
1888
+ return prunedNodes + node.left.size;
1889
+ }
1890
+ else if (cmp < 0) {
1891
+ node = node.left;
1892
+ }
1893
+ else {
1894
+ // Count all nodes left of the node plus the node itself
1895
+ prunedNodes += node.left.size + 1;
1896
+ node = node.right;
1897
+ }
1898
+ }
1899
+ // Node not found
1900
+ return -1;
1901
+ }
1902
+ isEmpty() {
1903
+ return this.root.isEmpty();
1904
+ }
1905
+ // Returns the total number of nodes in the map.
1906
+ get size() {
1907
+ return this.root.size;
1908
+ }
1909
+ // Returns the minimum key in the map.
1910
+ minKey() {
1911
+ return this.root.minKey();
1912
+ }
1913
+ // Returns the maximum key in the map.
1914
+ maxKey() {
1915
+ return this.root.maxKey();
1916
+ }
1917
+ // Traverses the map in key order and calls the specified action function
1918
+ // for each key/value pair. If action returns true, traversal is aborted.
1919
+ // Returns the first truthy value returned by action, or the last falsey
1920
+ // value returned by action.
1921
+ inorderTraversal(action) {
1922
+ return this.root.inorderTraversal(action);
1923
+ }
1924
+ forEach(fn) {
1925
+ this.inorderTraversal((k, v) => {
1926
+ fn(k, v);
1927
+ return false;
1928
+ });
1929
+ }
1930
+ toString() {
1931
+ const descriptions = [];
1932
+ this.inorderTraversal((k, v) => {
1933
+ descriptions.push(`${k}:${v}`);
1934
+ return false;
1935
+ });
1936
+ return `{${descriptions.join(', ')}}`;
1937
+ }
1938
+ // Traverses the map in reverse key order and calls the specified action
1939
+ // function for each key/value pair. If action returns true, traversal is
1940
+ // aborted.
1941
+ // Returns the first truthy value returned by action, or the last falsey
1942
+ // value returned by action.
1943
+ reverseTraversal(action) {
1944
+ return this.root.reverseTraversal(action);
1945
+ }
1946
+ // Returns an iterator over the SortedMap.
1947
+ getIterator() {
1948
+ return new SortedMapIterator(this.root, null, this.comparator, false);
1949
+ }
1950
+ getIteratorFrom(key) {
1951
+ return new SortedMapIterator(this.root, key, this.comparator, false);
1952
+ }
1953
+ getReverseIterator() {
1954
+ return new SortedMapIterator(this.root, null, this.comparator, true);
1955
+ }
1956
+ getReverseIteratorFrom(key) {
1957
+ return new SortedMapIterator(this.root, key, this.comparator, true);
1958
+ }
1959
+ } // end SortedMap
1960
+ // An iterator over an LLRBNode.
1961
+ class SortedMapIterator {
1962
+ constructor(node, startKey, comparator, isReverse) {
1963
+ this.isReverse = isReverse;
1964
+ this.nodeStack = [];
1965
+ let cmp = 1;
1966
+ while (!node.isEmpty()) {
1967
+ cmp = startKey ? comparator(node.key, startKey) : 1;
1968
+ // flip the comparison if we're going in reverse
1969
+ if (startKey && isReverse) {
1970
+ cmp *= -1;
1971
+ }
1972
+ if (cmp < 0) {
1973
+ // This node is less than our start key. ignore it
1974
+ if (this.isReverse) {
1975
+ node = node.left;
1976
+ }
1977
+ else {
1978
+ node = node.right;
1979
+ }
1980
+ }
1981
+ else if (cmp === 0) {
1982
+ // This node is exactly equal to our start key. Push it on the stack,
1983
+ // but stop iterating;
1984
+ this.nodeStack.push(node);
1985
+ break;
1986
+ }
1987
+ else {
1988
+ // This node is greater than our start key, add it to the stack and move
1989
+ // to the next one
1990
+ this.nodeStack.push(node);
1991
+ if (this.isReverse) {
1992
+ node = node.right;
1993
+ }
1994
+ else {
1995
+ node = node.left;
1996
+ }
1997
+ }
1998
+ }
1999
+ }
2000
+ getNext() {
2001
+ let node = this.nodeStack.pop();
2002
+ const result = { key: node.key, value: node.value };
2003
+ if (this.isReverse) {
2004
+ node = node.left;
2005
+ while (!node.isEmpty()) {
2006
+ this.nodeStack.push(node);
2007
+ node = node.right;
2008
+ }
2009
+ }
2010
+ else {
2011
+ node = node.right;
2012
+ while (!node.isEmpty()) {
2013
+ this.nodeStack.push(node);
2014
+ node = node.left;
2015
+ }
2016
+ }
2017
+ return result;
2018
+ }
2019
+ hasNext() {
2020
+ return this.nodeStack.length > 0;
2021
+ }
2022
+ peek() {
2023
+ if (this.nodeStack.length === 0) {
2024
+ return null;
2025
+ }
2026
+ const node = this.nodeStack[this.nodeStack.length - 1];
2027
+ return { key: node.key, value: node.value };
2028
+ }
2029
+ } // end SortedMapIterator
2030
+ // Represents a node in a Left-leaning Red-Black tree.
2031
+ class LLRBNode {
2032
+ constructor(key, value, color, left, right) {
2033
+ this.key = key;
2034
+ this.value = value;
2035
+ this.color = color != null ? color : LLRBNode.RED;
2036
+ this.left = left != null ? left : LLRBNode.EMPTY;
2037
+ this.right = right != null ? right : LLRBNode.EMPTY;
2038
+ this.size = this.left.size + 1 + this.right.size;
2039
+ }
2040
+ // Returns a copy of the current node, optionally replacing pieces of it.
2041
+ copy(key, value, color, left, right) {
2042
+ return new LLRBNode(key != null ? key : this.key, value != null ? value : this.value, color != null ? color : this.color, left != null ? left : this.left, right != null ? right : this.right);
2043
+ }
2044
+ isEmpty() {
2045
+ return false;
2046
+ }
2047
+ // Traverses the tree in key order and calls the specified action function
2048
+ // for each node. If action returns true, traversal is aborted.
2049
+ // Returns the first truthy value returned by action, or the last falsey
2050
+ // value returned by action.
2051
+ inorderTraversal(action) {
2052
+ return (this.left.inorderTraversal(action) ||
2053
+ action(this.key, this.value) ||
2054
+ this.right.inorderTraversal(action));
2055
+ }
2056
+ // Traverses the tree in reverse key order and calls the specified action
2057
+ // function for each node. If action returns true, traversal is aborted.
2058
+ // Returns the first truthy value returned by action, or the last falsey
2059
+ // value returned by action.
2060
+ reverseTraversal(action) {
2061
+ return (this.right.reverseTraversal(action) ||
2062
+ action(this.key, this.value) ||
2063
+ this.left.reverseTraversal(action));
2064
+ }
2065
+ // Returns the minimum node in the tree.
2066
+ min() {
2067
+ if (this.left.isEmpty()) {
2068
+ return this;
2069
+ }
2070
+ else {
2071
+ return this.left.min();
2072
+ }
2073
+ }
2074
+ // Returns the maximum key in the tree.
2075
+ minKey() {
2076
+ return this.min().key;
2077
+ }
2078
+ // Returns the maximum key in the tree.
2079
+ maxKey() {
2080
+ if (this.right.isEmpty()) {
2081
+ return this.key;
2082
+ }
2083
+ else {
2084
+ return this.right.maxKey();
2085
+ }
2086
+ }
2087
+ // Returns new tree, with the key/value added.
2088
+ insert(key, value, comparator) {
2089
+ let n = this;
2090
+ const cmp = comparator(key, n.key);
2091
+ if (cmp < 0) {
2092
+ n = n.copy(null, null, null, n.left.insert(key, value, comparator), null);
2093
+ }
2094
+ else if (cmp === 0) {
2095
+ n = n.copy(null, value, null, null, null);
2096
+ }
2097
+ else {
2098
+ n = n.copy(null, null, null, null, n.right.insert(key, value, comparator));
2099
+ }
2100
+ return n.fixUp();
2101
+ }
2102
+ removeMin() {
2103
+ if (this.left.isEmpty()) {
2104
+ return LLRBNode.EMPTY;
2105
+ }
2106
+ let n = this;
2107
+ if (!n.left.isRed() && !n.left.left.isRed()) {
2108
+ n = n.moveRedLeft();
2109
+ }
2110
+ n = n.copy(null, null, null, n.left.removeMin(), null);
2111
+ return n.fixUp();
2112
+ }
2113
+ // Returns new tree, with the specified item removed.
2114
+ remove(key, comparator) {
2115
+ let smallest;
2116
+ let n = this;
2117
+ if (comparator(key, n.key) < 0) {
2118
+ if (!n.left.isEmpty() && !n.left.isRed() && !n.left.left.isRed()) {
2119
+ n = n.moveRedLeft();
2120
+ }
2121
+ n = n.copy(null, null, null, n.left.remove(key, comparator), null);
2122
+ }
2123
+ else {
2124
+ if (n.left.isRed()) {
2125
+ n = n.rotateRight();
2126
+ }
2127
+ if (!n.right.isEmpty() && !n.right.isRed() && !n.right.left.isRed()) {
2128
+ n = n.moveRedRight();
2129
+ }
2130
+ if (comparator(key, n.key) === 0) {
2131
+ if (n.right.isEmpty()) {
2132
+ return LLRBNode.EMPTY;
2133
+ }
2134
+ else {
2135
+ smallest = n.right.min();
2136
+ n = n.copy(smallest.key, smallest.value, null, null, n.right.removeMin());
2137
+ }
2138
+ }
2139
+ n = n.copy(null, null, null, null, n.right.remove(key, comparator));
2140
+ }
2141
+ return n.fixUp();
2142
+ }
2143
+ isRed() {
2144
+ return this.color;
2145
+ }
2146
+ // Returns new tree after performing any needed rotations.
2147
+ fixUp() {
2148
+ let n = this;
2149
+ if (n.right.isRed() && !n.left.isRed()) {
2150
+ n = n.rotateLeft();
2151
+ }
2152
+ if (n.left.isRed() && n.left.left.isRed()) {
2153
+ n = n.rotateRight();
2154
+ }
2155
+ if (n.left.isRed() && n.right.isRed()) {
2156
+ n = n.colorFlip();
2157
+ }
2158
+ return n;
2159
+ }
2160
+ moveRedLeft() {
2161
+ let n = this.colorFlip();
2162
+ if (n.right.left.isRed()) {
2163
+ n = n.copy(null, null, null, null, n.right.rotateRight());
2164
+ n = n.rotateLeft();
2165
+ n = n.colorFlip();
2166
+ }
2167
+ return n;
2168
+ }
2169
+ moveRedRight() {
2170
+ let n = this.colorFlip();
2171
+ if (n.left.left.isRed()) {
2172
+ n = n.rotateRight();
2173
+ n = n.colorFlip();
2174
+ }
2175
+ return n;
2176
+ }
2177
+ rotateLeft() {
2178
+ const nl = this.copy(null, null, LLRBNode.RED, null, this.right.left);
2179
+ return this.right.copy(null, null, this.color, nl, null);
2180
+ }
2181
+ rotateRight() {
2182
+ const nr = this.copy(null, null, LLRBNode.RED, this.left.right, null);
2183
+ return this.left.copy(null, null, this.color, null, nr);
2184
+ }
2185
+ colorFlip() {
2186
+ const left = this.left.copy(null, null, !this.left.color, null, null);
2187
+ const right = this.right.copy(null, null, !this.right.color, null, null);
2188
+ return this.copy(null, null, !this.color, left, right);
2189
+ }
2190
+ // For testing.
2191
+ checkMaxDepth() {
2192
+ const blackDepth = this.check();
2193
+ if (Math.pow(2.0, blackDepth) <= this.size + 1) {
2194
+ return true;
2195
+ }
2196
+ else {
2197
+ return false;
2198
+ }
2199
+ }
2200
+ // In a balanced RB tree, the black-depth (number of black nodes) from root to
2201
+ // leaves is equal on both sides. This function verifies that or asserts.
2202
+ check() {
2203
+ if (this.isRed() && this.left.isRed()) {
2204
+ throw fail();
2205
+ }
2206
+ if (this.right.isRed()) {
2207
+ throw fail();
2208
+ }
2209
+ const blackDepth = this.left.check();
2210
+ if (blackDepth !== this.right.check()) {
2211
+ throw fail();
2212
+ }
2213
+ else {
2214
+ return blackDepth + (this.isRed() ? 0 : 1);
2215
+ }
2216
+ }
2217
+ } // end LLRBNode
2218
+ // Empty node is shared between all LLRB trees.
2219
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2220
+ LLRBNode.EMPTY = null;
2221
+ LLRBNode.RED = true;
2222
+ LLRBNode.BLACK = false;
2223
+ // Represents an empty node (a leaf node in the Red-Black Tree).
2224
+ class LLRBEmptyNode {
2225
+ constructor() {
2226
+ this.size = 0;
2227
+ }
2228
+ get key() {
2229
+ throw fail();
2230
+ }
2231
+ get value() {
2232
+ throw fail();
2233
+ }
2234
+ get color() {
2235
+ throw fail();
2236
+ }
2237
+ get left() {
2238
+ throw fail();
2239
+ }
2240
+ get right() {
2241
+ throw fail();
2242
+ }
2243
+ // Returns a copy of the current node.
2244
+ copy(key, value, color, left, right) {
2245
+ return this;
2246
+ }
2247
+ // Returns a copy of the tree, with the specified key/value added.
2248
+ insert(key, value, comparator) {
2249
+ return new LLRBNode(key, value);
2250
+ }
2251
+ // Returns a copy of the tree, with the specified key removed.
2252
+ remove(key, comparator) {
2253
+ return this;
2254
+ }
2255
+ isEmpty() {
2256
+ return true;
2257
+ }
2258
+ inorderTraversal(action) {
2259
+ return false;
2260
+ }
2261
+ reverseTraversal(action) {
2262
+ return false;
2263
+ }
2264
+ minKey() {
2265
+ return null;
2266
+ }
2267
+ maxKey() {
2268
+ return null;
2269
+ }
2270
+ isRed() {
2271
+ return false;
2272
+ }
2273
+ // For testing.
2274
+ checkMaxDepth() {
2275
+ return true;
2276
+ }
2277
+ check() {
2278
+ return 0;
2279
+ }
2280
+ } // end LLRBEmptyNode
2281
+ LLRBNode.EMPTY = new LLRBEmptyNode();
2282
+
2283
+ /**
2284
+ * @license
2285
+ * Copyright 2017 Google LLC
2286
+ *
2287
+ * Licensed under the Apache License, Version 2.0 (the "License");
2288
+ * you may not use this file except in compliance with the License.
2289
+ * You may obtain a copy of the License at
2290
+ *
2291
+ * http://www.apache.org/licenses/LICENSE-2.0
2292
+ *
2293
+ * Unless required by applicable law or agreed to in writing, software
2294
+ * distributed under the License is distributed on an "AS IS" BASIS,
2295
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2296
+ * See the License for the specific language governing permissions and
2297
+ * limitations under the License.
2298
+ */
2299
+ /**
2300
+ * SortedSet is an immutable (copy-on-write) collection that holds elements
2301
+ * in order specified by the provided comparator.
2302
+ *
2303
+ * NOTE: if provided comparator returns 0 for two elements, we consider them to
2304
+ * be equal!
2305
+ */
2306
+ class SortedSet {
2307
+ constructor(comparator) {
2308
+ this.comparator = comparator;
2309
+ this.data = new SortedMap(this.comparator);
2310
+ }
2311
+ has(elem) {
2312
+ return this.data.get(elem) !== null;
2313
+ }
2314
+ first() {
2315
+ return this.data.minKey();
2316
+ }
2317
+ last() {
2318
+ return this.data.maxKey();
2319
+ }
2320
+ get size() {
2321
+ return this.data.size;
2322
+ }
2323
+ indexOf(elem) {
2324
+ return this.data.indexOf(elem);
2325
+ }
2326
+ /** Iterates elements in order defined by "comparator" */
2327
+ forEach(cb) {
2328
+ this.data.inorderTraversal((k, v) => {
2329
+ cb(k);
2330
+ return false;
2331
+ });
2332
+ }
2333
+ /** Iterates over `elem`s such that: range[0] &lt;= elem &lt; range[1]. */
2334
+ forEachInRange(range, cb) {
2335
+ const iter = this.data.getIteratorFrom(range[0]);
2336
+ while (iter.hasNext()) {
2337
+ const elem = iter.getNext();
2338
+ if (this.comparator(elem.key, range[1]) >= 0) {
2339
+ return;
2340
+ }
2341
+ cb(elem.key);
2342
+ }
2343
+ }
2344
+ /**
2345
+ * Iterates over `elem`s such that: start &lt;= elem until false is returned.
2346
+ */
2347
+ forEachWhile(cb, start) {
2348
+ let iter;
2349
+ if (start !== undefined) {
2350
+ iter = this.data.getIteratorFrom(start);
2351
+ }
2352
+ else {
2353
+ iter = this.data.getIterator();
2354
+ }
2355
+ while (iter.hasNext()) {
2356
+ const elem = iter.getNext();
2357
+ const result = cb(elem.key);
2358
+ if (!result) {
2359
+ return;
2360
+ }
2361
+ }
2362
+ }
2363
+ /** Finds the least element greater than or equal to `elem`. */
2364
+ firstAfterOrEqual(elem) {
2365
+ const iter = this.data.getIteratorFrom(elem);
2366
+ return iter.hasNext() ? iter.getNext().key : null;
2367
+ }
2368
+ getIterator() {
2369
+ return new SortedSetIterator(this.data.getIterator());
2370
+ }
2371
+ getIteratorFrom(key) {
2372
+ return new SortedSetIterator(this.data.getIteratorFrom(key));
2373
+ }
2374
+ /** Inserts or updates an element */
2375
+ add(elem) {
2376
+ return this.copy(this.data.remove(elem).insert(elem, true));
2377
+ }
2378
+ /** Deletes an element */
2379
+ delete(elem) {
2380
+ if (!this.has(elem)) {
2381
+ return this;
2382
+ }
2383
+ return this.copy(this.data.remove(elem));
2384
+ }
2385
+ isEmpty() {
2386
+ return this.data.isEmpty();
2387
+ }
2388
+ unionWith(other) {
2389
+ let result = this;
2390
+ // Make sure `result` always refers to the larger one of the two sets.
2391
+ if (result.size < other.size) {
2392
+ result = other;
2393
+ other = this;
2394
+ }
2395
+ other.forEach(elem => {
2396
+ result = result.add(elem);
2397
+ });
2398
+ return result;
2399
+ }
2400
+ isEqual(other) {
2401
+ if (!(other instanceof SortedSet)) {
2402
+ return false;
2403
+ }
2404
+ if (this.size !== other.size) {
2405
+ return false;
2406
+ }
2407
+ const thisIt = this.data.getIterator();
2408
+ const otherIt = other.data.getIterator();
2409
+ while (thisIt.hasNext()) {
2410
+ const thisElem = thisIt.getNext().key;
2411
+ const otherElem = otherIt.getNext().key;
2412
+ if (this.comparator(thisElem, otherElem) !== 0) {
2413
+ return false;
2414
+ }
2415
+ }
2416
+ return true;
2417
+ }
2418
+ toArray() {
2419
+ const res = [];
2420
+ this.forEach(targetId => {
2421
+ res.push(targetId);
2422
+ });
2423
+ return res;
2424
+ }
2425
+ toString() {
2426
+ const result = [];
2427
+ this.forEach(elem => result.push(elem));
2428
+ return 'SortedSet(' + result.toString() + ')';
2429
+ }
2430
+ copy(data) {
2431
+ const result = new SortedSet(this.comparator);
2432
+ result.data = data;
2433
+ return result;
2434
+ }
2435
+ }
2436
+ class SortedSetIterator {
2437
+ constructor(iter) {
2438
+ this.iter = iter;
2439
+ }
2440
+ getNext() {
2441
+ return this.iter.getNext().key;
2442
+ }
2443
+ hasNext() {
2444
+ return this.iter.hasNext();
2445
+ }
2446
+ }
2447
+
1827
2448
  /**
1828
2449
  * @license
1829
2450
  * Copyright 2020 Google LLC
@@ -1857,6 +2478,23 @@ class FieldMask {
1857
2478
  // Sort the field mask to support `FieldMask.isEqual()` and assert below.
1858
2479
  fields.sort(FieldPath$1.comparator);
1859
2480
  }
2481
+ static empty() {
2482
+ return new FieldMask([]);
2483
+ }
2484
+ /**
2485
+ * Returns a new FieldMask object that is the result of adding all the given
2486
+ * fields paths to this field mask.
2487
+ */
2488
+ unionWith(extraFields) {
2489
+ let mergedMaskSet = new SortedSet(FieldPath$1.comparator);
2490
+ for (const fieldPath of this.fields) {
2491
+ mergedMaskSet = mergedMaskSet.add(fieldPath);
2492
+ }
2493
+ for (const fieldPath of extraFields) {
2494
+ mergedMaskSet = mergedMaskSet.add(fieldPath);
2495
+ }
2496
+ return new FieldMask(mergedMaskSet.toArray());
2497
+ }
1860
2498
  /**
1861
2499
  * Verifies that `fieldPath` is included by at least one field in this field
1862
2500
  * mask.
@@ -2768,6 +3406,7 @@ class MutableDocument {
2768
3406
  }
2769
3407
  setHasLocalMutations() {
2770
3408
  this.documentState = 1 /* HAS_LOCAL_MUTATIONS */;
3409
+ this.version = SnapshotVersion.min();
2771
3410
  return this;
2772
3411
  }
2773
3412
  setReadTime(readTime) {
@@ -3509,6 +4148,9 @@ class SetMutation extends Mutation {
3509
4148
  this.fieldTransforms = fieldTransforms;
3510
4149
  this.type = 0 /* Set */;
3511
4150
  }
4151
+ getFieldMask() {
4152
+ return null;
4153
+ }
3512
4154
  }
3513
4155
  /**
3514
4156
  * A mutation that modifies fields of the document at the given key with the
@@ -3533,6 +4175,9 @@ class PatchMutation extends Mutation {
3533
4175
  this.fieldTransforms = fieldTransforms;
3534
4176
  this.type = 1 /* Patch */;
3535
4177
  }
4178
+ getFieldMask() {
4179
+ return this.fieldMask;
4180
+ }
3536
4181
  }
3537
4182
  /** A mutation that deletes the document at the given key. */
3538
4183
  class DeleteMutation extends Mutation {
@@ -3543,6 +4188,9 @@ class DeleteMutation extends Mutation {
3543
4188
  this.type = 2 /* Delete */;
3544
4189
  this.fieldTransforms = [];
3545
4190
  }
4191
+ getFieldMask() {
4192
+ return null;
4193
+ }
3546
4194
  }
3547
4195
  /**
3548
4196
  * A mutation that verifies the existence of the document at the given key with
@@ -3559,6 +4207,9 @@ class VerifyMutation extends Mutation {
3559
4207
  this.type = 3 /* Verify */;
3560
4208
  this.fieldTransforms = [];
3561
4209
  }
4210
+ getFieldMask() {
4211
+ return null;
4212
+ }
3562
4213
  }
3563
4214
 
3564
4215
  /**
@@ -7762,6 +8413,8 @@ class Transaction {
7762
8413
  * transaction against.
7763
8414
  * @param updateFunction - The function to execute within the transaction
7764
8415
  * context.
8416
+ * @param options - An options object to configure maximum number of attempts to
8417
+ * commit.
7765
8418
  * @returns If the transaction completed successfully or was explicitly aborted
7766
8419
  * (the `updateFunction` returned a failed promise), the promise returned by the
7767
8420
  * `updateFunction `is returned here. Otherwise, if the transaction failed, a