@firebase/firestore 4.4.3-canary.6d487d7de → 4.4.3-canary.ce88e71e7

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 (70) hide show
  1. package/dist/firestore/src/api/reference_impl.d.ts +12 -0
  2. package/dist/firestore/src/api.d.ts +1 -1
  3. package/dist/firestore/src/core/event_manager.d.ts +26 -4
  4. package/dist/firestore/src/core/sync_engine_impl.d.ts +6 -2
  5. package/dist/firestore/src/global_index.d.ts +17 -3
  6. package/dist/firestore/src/local/shared_client_state.d.ts +1 -1
  7. package/dist/firestore/test/integration/api/query.test.d.ts +2 -1
  8. package/dist/firestore/test/integration/api/snasphot_listener_source.test.d.ts +17 -0
  9. package/dist/firestore/test/unit/specs/bundle_spec.test.d.ts +19 -0
  10. package/dist/firestore/test/unit/specs/listen_source_spec.test.d.ts +17 -0
  11. package/dist/firestore/test/unit/specs/spec_builder.d.ts +10 -1
  12. package/dist/firestore/test/unit/specs/spec_test_runner.d.ts +2 -0
  13. package/dist/index.cjs.js +587 -514
  14. package/dist/index.cjs.js.map +1 -1
  15. package/dist/index.d.ts +12 -0
  16. package/dist/index.esm2017.js +587 -514
  17. package/dist/index.esm2017.js.map +1 -1
  18. package/dist/index.esm5.js +1635 -1520
  19. package/dist/index.esm5.js.map +1 -1
  20. package/dist/index.node.cjs.js +131 -35
  21. package/dist/index.node.cjs.js.map +1 -1
  22. package/dist/index.node.mjs +131 -35
  23. package/dist/index.node.mjs.map +1 -1
  24. package/dist/index.rn.js +589 -516
  25. package/dist/index.rn.js.map +1 -1
  26. package/dist/internal.d.ts +17 -2
  27. package/dist/lite/firestore/src/api/reference_impl.d.ts +12 -0
  28. package/dist/lite/firestore/src/api.d.ts +1 -1
  29. package/dist/lite/firestore/src/core/event_manager.d.ts +26 -4
  30. package/dist/lite/firestore/src/core/sync_engine_impl.d.ts +6 -2
  31. package/dist/lite/firestore/src/local/shared_client_state.d.ts +1 -1
  32. package/dist/lite/firestore/test/integration/api/query.test.d.ts +2 -1
  33. package/dist/lite/firestore/test/integration/api/snasphot_listener_source.test.d.ts +17 -0
  34. package/dist/lite/firestore/test/unit/specs/bundle_spec.test.d.ts +19 -0
  35. package/dist/lite/firestore/test/unit/specs/listen_source_spec.test.d.ts +17 -0
  36. package/dist/lite/firestore/test/unit/specs/spec_builder.d.ts +10 -1
  37. package/dist/lite/firestore/test/unit/specs/spec_test_runner.d.ts +2 -0
  38. package/dist/lite/index.browser.esm2017.js +2 -2
  39. package/dist/lite/index.browser.esm5.js +2 -2
  40. package/dist/lite/index.cjs.js +2 -2
  41. package/dist/lite/index.node.cjs.js +2 -2
  42. package/dist/lite/index.node.mjs +2 -2
  43. package/dist/lite/index.rn.esm2017.js +2 -2
  44. package/dist/lite/internal.d.ts +4 -2
  45. package/dist/lite/packages/firestore/src/api/reference_impl.d.ts +12 -0
  46. package/dist/lite/packages/firestore/src/api.d.ts +1 -1
  47. package/dist/lite/packages/firestore/src/core/event_manager.d.ts +26 -4
  48. package/dist/lite/packages/firestore/src/core/sync_engine_impl.d.ts +6 -2
  49. package/dist/lite/packages/firestore/src/local/shared_client_state.d.ts +1 -1
  50. package/dist/lite/packages/firestore/test/integration/api/query.test.d.ts +2 -1
  51. package/dist/lite/packages/firestore/test/integration/api/snasphot_listener_source.test.d.ts +17 -0
  52. package/dist/lite/packages/firestore/test/unit/specs/bundle_spec.test.d.ts +19 -0
  53. package/dist/lite/packages/firestore/test/unit/specs/listen_source_spec.test.d.ts +17 -0
  54. package/dist/lite/packages/firestore/test/unit/specs/spec_builder.d.ts +10 -1
  55. package/dist/lite/packages/firestore/test/unit/specs/spec_test_runner.d.ts +2 -0
  56. package/dist/lite/private.d.ts +4 -2
  57. package/dist/packages/firestore/dist/index.esm2017.d.ts +69 -69
  58. package/dist/packages/firestore/src/api/reference_impl.d.ts +12 -0
  59. package/dist/packages/firestore/src/api.d.ts +1 -1
  60. package/dist/packages/firestore/src/core/event_manager.d.ts +26 -4
  61. package/dist/packages/firestore/src/core/sync_engine_impl.d.ts +6 -2
  62. package/dist/packages/firestore/src/local/shared_client_state.d.ts +1 -1
  63. package/dist/packages/firestore/test/integration/api/query.test.d.ts +2 -1
  64. package/dist/packages/firestore/test/integration/api/snasphot_listener_source.test.d.ts +17 -0
  65. package/dist/packages/firestore/test/unit/specs/bundle_spec.test.d.ts +19 -0
  66. package/dist/packages/firestore/test/unit/specs/listen_source_spec.test.d.ts +17 -0
  67. package/dist/packages/firestore/test/unit/specs/spec_builder.d.ts +10 -1
  68. package/dist/packages/firestore/test/unit/specs/spec_test_runner.d.ts +2 -0
  69. package/dist/private.d.ts +17 -2
  70. package/package.json +9 -9
@@ -108,13 +108,16 @@ export declare class SpecBuilder {
108
108
  runAsTest(name: string, tags: string[], usePersistence: boolean): Promise<void>;
109
109
  ensureManualLruGC(): this;
110
110
  withMaxConcurrentLimboResolutions(value?: number): this;
111
+ private addUserListenStep;
111
112
  userListens(query: Query, resume?: ResumeSpec): this;
113
+ userListensToCache(query: Query, resume?: ResumeSpec): this;
112
114
  /**
113
115
  * Registers a previously active target with the test expectations after a
114
116
  * stream disconnect.
115
117
  */
116
118
  restoreListen(query: Query, resumeToken: string, expectedCount?: number): this;
117
- userUnlistens(query: Query): this;
119
+ userUnlistens(query: Query, shouldRemoveWatchTarget?: boolean): this;
120
+ userUnlistensToCache(query: Query): this;
118
121
  userSets(key: string, value: JsonObject<unknown>): this;
119
122
  userPatches(key: string, value: JsonObject<unknown>): this;
120
123
  userDeletes(key: string): this;
@@ -218,10 +221,16 @@ export declare class SpecBuilder {
218
221
  metadata?: Document[];
219
222
  errorCode?: Code;
220
223
  }): this;
224
+ private registerQuery;
221
225
  /** Registers a query that is active in another tab. */
222
226
  expectListen(query: Query, resume?: ResumeSpec): this;
227
+ /** Registers a query that is listening to cache and active in another tab. */
228
+ expectListenToCache(query: Query, resume?: ResumeSpec): this;
229
+ removeQuery(query: Query, shouldRemoveWatchTarget?: boolean): this;
223
230
  /** Removes a query that is no longer active in any tab. */
224
231
  expectUnlisten(query: Query): this;
232
+ /** Removes a query that is listening to cache and no longer active in any tab. */
233
+ expectUnlistenToCache(query: Query): this;
225
234
  /**
226
235
  * Verifies the total number of requests sent to the write backend since test
227
236
  * initialization.
@@ -15,6 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  import { IndexConfiguration } from '../../../src/api/index_configuration';
18
+ import { ListenOptions } from '../../../src/core/event_manager';
18
19
  import { Query } from '../../../src/core/query';
19
20
  import { TargetId } from '../../../src/core/types';
20
21
  import { FieldIndex } from '../../../src/model/field_index';
@@ -152,6 +153,7 @@ export interface SpecStep {
152
153
  export interface SpecUserListen {
153
154
  targetId: TargetId;
154
155
  query: string | SpecQuery;
156
+ options?: ListenOptions;
155
157
  }
156
158
  /** [<target-id>, <query-path>] */
157
159
  export declare type SpecUserUnlisten = [TargetId, string | SpecQuery];
@@ -1204,8 +1204,10 @@ declare interface Entry<K, V> {
1204
1204
  * allows users to tree-shake the Watch logic.
1205
1205
  */
1206
1206
  declare interface EventManager {
1207
- onListen?: (query: Query_2) => Promise<ViewSnapshot>;
1208
- onUnlisten?: (query: Query_2) => Promise<void>;
1207
+ onListen?: (query: Query_2, enableRemoteListen: boolean) => Promise<ViewSnapshot>;
1208
+ onUnlisten?: (query: Query_2, disableRemoteListen: boolean) => Promise<void>;
1209
+ onFirstRemoteStoreListen?: (query: Query_2) => Promise<void>;
1210
+ onLastRemoteStoreUnlisten?: (query: Query_2) => Promise<void>;
1209
1211
  }
1210
1212
 
1211
1213
  /**
@@ -155,7 +155,7 @@ export class AggregateField {
155
155
  * Constant used to indicate the LRU garbage collection should be disabled.
156
156
  * Set this value as the `cacheSizeBytes` on the settings passed to the
157
157
  * {@link Firestore} instance.
158
- */ declare const fe: -1;
158
+ */ declare const pe: -1;
159
159
  /**
160
160
  * A `CollectionReference` object can be used for adding documents, getting
161
161
  * document references, and querying for documents (using {@link (query:1)}).
@@ -1945,16 +1945,16 @@ declare class Firestore$1 {
1945
1945
  * See the License for the specific language governing permissions and
1946
1946
  * limitations under the License.
1947
1947
  */ declare class __PRIVATE_AsyncQueueImpl {
1948
- Xa: Promise<void>;
1949
- eu: any[];
1950
- tu: boolean;
1951
- nu: any[];
1952
- ru: any;
1948
+ nu: Promise<void>;
1949
+ ru: any[];
1953
1950
  iu: boolean;
1954
- su: boolean;
1955
- ou: any[];
1951
+ su: any[];
1952
+ ou: any;
1953
+ _u: boolean;
1954
+ au: boolean;
1955
+ uu: any[];
1956
1956
  jo: __PRIVATE_ExponentialBackoff;
1957
- _u: () => void;
1957
+ cu: () => void;
1958
1958
  get isShuttingDown(): boolean;
1959
1959
  /**
1960
1960
  * Adds a new operation to the queue without waiting for it to complete (i.e.
@@ -1967,30 +1967,30 @@ declare class Firestore$1 {
1967
1967
  /**
1968
1968
  * Runs the next operation from the retryable queue. If the operation fails,
1969
1969
  * reschedules with backoff.
1970
- */ cu(): Promise<void>;
1971
- uu(e: any): Promise<any>;
1970
+ */ Pu(): Promise<void>;
1971
+ hu(e: any): Promise<any>;
1972
1972
  enqueueAfterDelay(e: any, t: any, n: any): DelayedOperation;
1973
- au(): void;
1973
+ lu(): void;
1974
1974
  verifyOperationInProgress(): void;
1975
1975
  /**
1976
1976
  * Waits until all currently queued tasks are finished executing. Delayed
1977
1977
  * operations are not run.
1978
- */ hu(): Promise<void>;
1978
+ */ Tu(): Promise<void>;
1979
1979
  /**
1980
1980
  * For Tests: Determine if a delayed operation with a particular TimerId
1981
1981
  * exists.
1982
- */ Pu(e: any): boolean;
1982
+ */ Eu(e: any): boolean;
1983
1983
  /**
1984
1984
  * For Tests: Runs some or all delayed operations early.
1985
1985
  *
1986
1986
  * @param lastTimerId - Delayed operations up to and including this TimerId
1987
1987
  * will be drained. Pass TimerId.All to run all delayed operations.
1988
1988
  * @returns a Promise that resolves once all operations have been run.
1989
- */ Iu(e: any): Promise<void>;
1989
+ */ du(e: any): Promise<void>;
1990
1990
  /**
1991
1991
  * For Tests: Skip all subsequent delays for a timer id.
1992
- */ Tu(e: any): void;
1993
- /** Called once a DelayedOperation is run or canceled. */ lu(e: any): void;
1992
+ */ Au(e: any): void;
1993
+ /** Called once a DelayedOperation is run or canceled. */ Iu(e: any): void;
1994
1994
  }
1995
1995
  import { FirebaseError as a } from "@firebase/util/dist/src/errors";
1996
1996
  /**
@@ -2050,7 +2050,7 @@ declare class FieldFilter extends Filter {
2050
2050
  databaseId: any;
2051
2051
  ignoreUndefinedProperties: any;
2052
2052
  serializer: any;
2053
- /** Creates a new top-level parse context. */ Su(e: any, t: any, n: any, r?: boolean): __PRIVATE_ParseContextImpl;
2053
+ /** Creates a new top-level parse context. */ Cu(e: any, t: any, n: any, r?: boolean): __PRIVATE_ParseContextImpl;
2054
2054
  }
2055
2055
  declare class AppCheckToken {
2056
2056
  constructor(e: any);
@@ -2100,13 +2100,13 @@ declare class BasePath {
2100
2100
  }
2101
2101
  declare class __PRIVATE_ArrayRemoveFieldValueImpl extends FieldValue {
2102
2102
  constructor(e: any, t: any);
2103
- bu: any;
2103
+ vu: any;
2104
2104
  _toFieldTransform(e: any): FieldTransform;
2105
2105
  isEqual(e: any): boolean;
2106
2106
  }
2107
2107
  declare class __PRIVATE_ArrayUnionFieldValueImpl extends FieldValue {
2108
2108
  constructor(e: any, t: any);
2109
- bu: any;
2109
+ vu: any;
2110
2110
  _toFieldTransform(e: any): FieldTransform;
2111
2111
  isEqual(e: any): boolean;
2112
2112
  }
@@ -2116,7 +2116,7 @@ declare class __PRIVATE_DeleteFieldValueImpl extends FieldValue {
2116
2116
  }
2117
2117
  declare class __PRIVATE_NumericIncrementFieldValueImpl extends FieldValue {
2118
2118
  constructor(e: any, t: any);
2119
- Du: any;
2119
+ Fu: any;
2120
2120
  _toFieldTransform(e: any): FieldTransform;
2121
2121
  isEqual(e: any): boolean;
2122
2122
  }
@@ -2251,9 +2251,9 @@ declare class __PRIVATE_ExponentialBackoff {
2251
2251
  xo: number;
2252
2252
  Oo: number;
2253
2253
  No: number;
2254
- Bo: any;
2254
+ Lo: any;
2255
2255
  /** The last backoff attempt, as epoch milliseconds. */
2256
- Lo: number;
2256
+ Bo: number;
2257
2257
  /**
2258
2258
  * Resets the backoff delay.
2259
2259
  *
@@ -2393,15 +2393,15 @@ declare class DelayedOperation {
2393
2393
  fieldTransforms: any;
2394
2394
  fieldMask: any;
2395
2395
  get path(): any;
2396
- get Eu(): any;
2397
- /** Returns a new context with the specified settings overwritten. */ Au(e: any): __PRIVATE_ParseContextImpl;
2398
- Ru(e: any): __PRIVATE_ParseContextImpl;
2396
+ get Vu(): any;
2397
+ /** Returns a new context with the specified settings overwritten. */ mu(e: any): __PRIVATE_ParseContextImpl;
2399
2398
  fu(e: any): __PRIVATE_ParseContextImpl;
2400
- gu(e: any): __PRIVATE_ParseContextImpl;
2401
- pu(e: any): FirestoreError;
2399
+ yu(e: any): __PRIVATE_ParseContextImpl;
2400
+ wu(e: any): __PRIVATE_ParseContextImpl;
2401
+ Su(e: any): FirestoreError;
2402
2402
  /** Returns 'true' if 'fieldPath' was traversed when creating this context. */ contains(e: any): boolean;
2403
- du(): void;
2404
- mu(e: any): void;
2403
+ Ru(): void;
2404
+ pu(e: any): void;
2405
2405
  }
2406
2406
  /**
2407
2407
  * @license
@@ -2477,7 +2477,7 @@ declare class __PRIVATE_LruGcMemoryOfflineComponentProvider extends MemoryOfflin
2477
2477
  * Provides all components needed for Firestore with IndexedDB persistence.
2478
2478
  */ declare class __PRIVATE_IndexedDbOfflineComponentProvider extends MemoryOfflineComponentProvider {
2479
2479
  constructor(e: any, t: any, n: any);
2480
- Na: any;
2480
+ ka: any;
2481
2481
  cacheSizeBytes: any;
2482
2482
  forceOwnership: any;
2483
2483
  createGarbageCollectionScheduler(e: any, t: any): __PRIVATE_LruScheduler;
@@ -2552,7 +2552,7 @@ declare class __PRIVATE_MemoryPersistence {
2552
2552
  * checked or asserted on every access.
2553
2553
  */
2554
2554
  constructor(e: any, t: any);
2555
- Lr: {};
2555
+ Br: {};
2556
2556
  overlays: {};
2557
2557
  kr: __PRIVATE_ListenSequence;
2558
2558
  qr: boolean;
@@ -2739,7 +2739,7 @@ declare class __PRIVATE_DatastoreImpl extends __PRIVATE_DatastoreImpl_base {
2739
2739
  declare class __PRIVATE_EventManagerImpl {
2740
2740
  queries: ObjectMap;
2741
2741
  onlineState: string;
2742
- K_: Set<any>;
2742
+ W_: Set<any>;
2743
2743
  }
2744
2744
  /**
2745
2745
  * An implementation of `SyncEngine` coordinating with other parts of SDK.
@@ -2761,9 +2761,9 @@ declare class __PRIVATE_EventManagerImpl {
2761
2761
  sharedClientState: any;
2762
2762
  currentUser: any;
2763
2763
  maxConcurrentLimboResolutions: any;
2764
- fa: {};
2765
- ga: ObjectMap;
2766
- pa: Map<any, any>;
2764
+ ya: {};
2765
+ wa: ObjectMap;
2766
+ Sa: Map<any, any>;
2767
2767
  /**
2768
2768
  * The keys of documents that are in limbo for which we haven't yet started a
2769
2769
  * limbo resolution query. The strings in this set are the result of calling
@@ -2773,23 +2773,23 @@ declare class __PRIVATE_EventManagerImpl {
2773
2773
  * of arbitrary elements and it also maintains insertion order, providing the
2774
2774
  * desired queue-like FIFO semantics.
2775
2775
  */
2776
- ya: Set<any>;
2776
+ ba: Set<any>;
2777
2777
  /**
2778
2778
  * Keeps track of the target ID for each document that is in limbo with an
2779
2779
  * active target.
2780
2780
  */
2781
- wa: SortedMap;
2781
+ Da: SortedMap;
2782
2782
  /**
2783
2783
  * Keeps track of the information about an active limbo resolution for each
2784
2784
  * active target ID that was started for the purpose of limbo resolution.
2785
2785
  */
2786
- Sa: Map<any, any>;
2787
- ba: __PRIVATE_ReferenceSet;
2786
+ Ca: Map<any, any>;
2787
+ va: __PRIVATE_ReferenceSet;
2788
2788
  /** Stores user completion handlers, indexed by User and BatchId. */
2789
- Da: {};
2789
+ Fa: {};
2790
2790
  /** Stores user callbacks waiting for all pending writes to be acknowledged. */
2791
- Ca: Map<any, any>;
2792
- va: __PRIVATE_TargetIdGenerator;
2791
+ Ma: Map<any, any>;
2792
+ xa: __PRIVATE_TargetIdGenerator;
2793
2793
  onlineState: string;
2794
2794
  get isPrimaryClient(): boolean;
2795
2795
  }
@@ -2859,8 +2859,8 @@ declare class __PRIVATE_EventManagerImpl {
2859
2859
  gs(e: any): undefined;
2860
2860
  get ks(): any;
2861
2861
  Ms(): void;
2862
- Bs(e: any, t: any, n: any): void;
2863
- Ls(e: any): void;
2862
+ Ls(e: any, t: any, n: any): void;
2863
+ Bs(e: any): void;
2864
2864
  Qs(e: any): void;
2865
2865
  qs(e: any, t: any, n: any): void;
2866
2866
  Ks(e: any): void;
@@ -2982,11 +2982,11 @@ declare class __PRIVATE_IndexedDbPersistence {
2982
2982
  referenceDelegate: __PRIVATE_IndexedDbLruDelegateImpl;
2983
2983
  Ti: string;
2984
2984
  serializer: __PRIVATE_LocalSerializer;
2985
- di: __PRIVATE_SimpleDb;
2985
+ Ei: __PRIVATE_SimpleDb;
2986
2986
  Qr: __PRIVATE_IndexedDbTargetCache;
2987
2987
  remoteDocumentCache: __PRIVATE_IndexedDbRemoteDocumentCacheImpl;
2988
2988
  $r: __PRIVATE_IndexedDbBundleCache;
2989
- Ei: any;
2989
+ di: any;
2990
2990
  /**
2991
2991
  * Attempt to start IndexedDb persistence.
2992
2992
  *
@@ -3047,7 +3047,7 @@ declare class __PRIVATE_IndexedDbPersistence {
3047
3047
  * ID.
3048
3048
  *
3049
3049
  * PORTING NOTE: This is only used for Web multi-tab.
3050
- */ Li(): Promise<any>;
3050
+ */ Bi(): Promise<any>;
3051
3051
  get started(): boolean;
3052
3052
  getMutationQueue(e: any, t: any): __PRIVATE_IndexedDbMutationQueue;
3053
3053
  getTargetCache(): __PRIVATE_IndexedDbTargetCache;
@@ -3089,7 +3089,7 @@ declare class __PRIVATE_IndexedDbPersistence {
3089
3089
  * Record client as zombied (a client that had its tab closed). Zombied
3090
3090
  * clients are ignored during primary tab selection.
3091
3091
  */ xi(): void;
3092
- /** Removes the zombied client entry if it exists. */ Bi(): void;
3092
+ /** Removes the zombied client entry if it exists. */ Li(): void;
3093
3093
  Fi(e: any): string;
3094
3094
  }
3095
3095
  /**
@@ -3109,7 +3109,7 @@ declare class __PRIVATE_LocalClientState {
3109
3109
  /**
3110
3110
  * Converts this entry into a JSON-encoded format we can use for WebStorage.
3111
3111
  * Does not encode `clientId` as it is part of the key in WebStorage.
3112
- */ Es(): string;
3112
+ */ ds(): string;
3113
3113
  }
3114
3114
  /**
3115
3115
  * @license
@@ -3225,7 +3225,7 @@ declare namespace __PRIVATE_ListenSequence {
3225
3225
  */
3226
3226
  Nr: __PRIVATE_ReferenceSet;
3227
3227
  targetCount: number;
3228
- Br: __PRIVATE_TargetIdGenerator;
3228
+ Lr: __PRIVATE_TargetIdGenerator;
3229
3229
  forEachTarget(e: any, t: any): PersistencePromise;
3230
3230
  getLastRemoteSnapshotVersion(e: any): PersistencePromise;
3231
3231
  getHighestSequenceNumber(e: any): PersistencePromise;
@@ -3718,7 +3718,7 @@ declare class __PRIVATE_OnlineStateTracker {
3718
3718
  Tr: SortedSet;
3719
3719
  /** Returns true if the reference set contains no references. */ isEmpty(): any;
3720
3720
  /** Adds a reference to the given document key for the given ID. */ addReference(e: any, t: any): void;
3721
- /** Add references to the given document keys for the given ID. */ Er(e: any, t: any): void;
3721
+ /** Add references to the given document keys for the given ID. */ dr(e: any, t: any): void;
3722
3722
  /**
3723
3723
  * Removes a reference to the given document key for the given
3724
3724
  * ID.
@@ -3766,7 +3766,7 @@ declare class __PRIVATE_OnlineStateTracker {
3766
3766
  */
3767
3767
  declare class __PRIVATE_TargetIdGenerator {
3768
3768
  static Nn(): __PRIVATE_TargetIdGenerator;
3769
- static Bn(): __PRIVATE_TargetIdGenerator;
3769
+ static Ln(): __PRIVATE_TargetIdGenerator;
3770
3770
  constructor(e: any);
3771
3771
  On: any;
3772
3772
  next(): any;
@@ -3778,7 +3778,7 @@ declare class __PRIVATE_TargetIdGenerator {
3778
3778
  /**
3779
3779
  * Parses a RemoteClientState from the JSON representation in WebStorage.
3780
3780
  * Logs a warning and returns null if the format of the data is not valid.
3781
- */ static ds(e: any, t: any): __PRIVATE_RemoteClientState | null;
3781
+ */ static Es(e: any, t: any): __PRIVATE_RemoteClientState | null;
3782
3782
  constructor(e: any, t: any);
3783
3783
  clientId: any;
3784
3784
  activeTargetIds: any;
@@ -3791,13 +3791,13 @@ declare class __PRIVATE_MutationMetadata {
3791
3791
  /**
3792
3792
  * Parses a MutationMetadata from its JSON representation in WebStorage.
3793
3793
  * Logs a warning and returns null if the format of the data is not valid.
3794
- */ static ds(e: any, t: any, n: any): __PRIVATE_MutationMetadata | null;
3794
+ */ static Es(e: any, t: any, n: any): __PRIVATE_MutationMetadata | null;
3795
3795
  constructor(e: any, t: any, n: any, r: any);
3796
3796
  user: any;
3797
3797
  batchId: any;
3798
3798
  state: any;
3799
3799
  error: any;
3800
- Es(): string;
3800
+ ds(): string;
3801
3801
  }
3802
3802
  /**
3803
3803
  * Holds the state of a query target, including its target ID and whether the
@@ -3807,12 +3807,12 @@ declare class __PRIVATE_QueryTargetMetadata {
3807
3807
  /**
3808
3808
  * Parses a QueryTargetMetadata from its JSON representation in WebStorage.
3809
3809
  * Logs a warning and returns null if the format of the data is not valid.
3810
- */ static ds(e: any, t: any): __PRIVATE_QueryTargetMetadata | null;
3810
+ */ static Es(e: any, t: any): __PRIVATE_QueryTargetMetadata | null;
3811
3811
  constructor(e: any, t: any, n: any);
3812
3812
  targetId: any;
3813
3813
  state: any;
3814
3814
  error: any;
3815
- Es(): string;
3815
+ ds(): string;
3816
3816
  }
3817
3817
  /**
3818
3818
  * This class represents the online state for all clients participating in
@@ -3822,7 +3822,7 @@ declare class __PRIVATE_QueryTargetMetadata {
3822
3822
  /**
3823
3823
  * Parses a SharedOnlineState from its JSON representation in WebStorage.
3824
3824
  * Logs a warning and returns null if the format of the data is not valid.
3825
- */ static ds(e: any): __PRIVATE_SharedOnlineState | null;
3825
+ */ static Es(e: any): __PRIVATE_SharedOnlineState | null;
3826
3826
  constructor(e: any, t: any);
3827
3827
  clientId: any;
3828
3828
  onlineState: any;
@@ -3898,8 +3898,8 @@ declare class __PRIVATE_QueryTargetMetadata {
3898
3898
  * Opens the specified database, creating or upgrading it if necessary.
3899
3899
  */ O(e: any): any;
3900
3900
  db: any;
3901
- L(e: any): void;
3902
- B: any;
3901
+ B(e: any): void;
3902
+ L: any;
3903
3903
  runTransaction(e: any, t: any, n: any, r: any): Promise<any>;
3904
3904
  close(): void;
3905
3905
  }
@@ -3937,7 +3937,7 @@ declare class __PRIVATE_QueryTargetMetadata {
3937
3937
  /**
3938
3938
  * Call provided function with each `TargetData` that we have cached.
3939
3939
  */ forEachTarget(e: any, t: any): any;
3940
- Ln(e: any): any;
3940
+ Bn(e: any): any;
3941
3941
  kn(e: any, t: any): any;
3942
3942
  qn(e: any, t: any): any;
3943
3943
  /**
@@ -4147,8 +4147,8 @@ declare class __PRIVATE_IndexedDbIndexManager {
4147
4147
  * Constructs a key range query on `DbIndexEntryStore` that unions all
4148
4148
  * bounds.
4149
4149
  */ In(e: any, t: any, n: any, r: any, i: any, s: any, o: any): IDBKeyRange[];
4150
- /** Generates the lower bound for `arrayValue` and `directionalValue`. */ dn(e: any, t: any, n: any, r: any): __PRIVATE_IndexEntry;
4151
- /** Generates the upper bound for `arrayValue` and `directionalValue`. */ En(e: any, t: any, n: any, r: any): __PRIVATE_IndexEntry;
4150
+ /** Generates the lower bound for `arrayValue` and `directionalValue`. */ En(e: any, t: any, n: any, r: any): __PRIVATE_IndexEntry;
4151
+ /** Generates the upper bound for `arrayValue` and `directionalValue`. */ dn(e: any, t: any, n: any, r: any): __PRIVATE_IndexEntry;
4152
4152
  ln(e: any, t: any): any;
4153
4153
  getIndexType(e: any, t: any): PersistencePromise;
4154
4154
  /**
@@ -4545,7 +4545,7 @@ declare class SortedMapIterator {
4545
4545
  Ft(e: any): void;
4546
4546
  /** Writes utf8 bytes into this byte sequence, ascending. */ Ot(e: any): void;
4547
4547
  /** Writes utf8 bytes into this byte sequence, descending */ Nt(e: any): void;
4548
- Bt(e: any): void;
4548
+ Lt(e: any): void;
4549
4549
  qt(e: any): void;
4550
4550
  /**
4551
4551
  * Writes the "infinity" byte sequence that sorts after all other byte
@@ -4567,7 +4567,7 @@ declare class SortedMapIterator {
4567
4567
  * -0.0 < 0.0
4568
4568
  * all non-NaN < NaN
4569
4569
  * NaN = NaN
4570
- */ Lt(e: any): Uint8Array;
4570
+ */ Bt(e: any): Uint8Array;
4571
4571
  /** Writes a single byte ascending to the buffer. */ Ct(e: any): void;
4572
4572
  /** Writes a single byte descending to the buffer. */ Mt(e: any): void;
4573
4573
  vt(): void;
@@ -4581,7 +4581,7 @@ declare class __PRIVATE_AscendingIndexByteEncoder {
4581
4581
  Gt: any;
4582
4582
  ft(e: any): void;
4583
4583
  At(e: any): void;
4584
- Et(e: any): void;
4584
+ dt(e: any): void;
4585
4585
  Tt(): void;
4586
4586
  }
4587
4587
  declare class __PRIVATE_DescendingIndexByteEncoder {
@@ -4589,7 +4589,7 @@ declare class __PRIVATE_DescendingIndexByteEncoder {
4589
4589
  Gt: any;
4590
4590
  ft(e: any): void;
4591
4591
  At(e: any): void;
4592
- Et(e: any): void;
4592
+ dt(e: any): void;
4593
4593
  Tt(): void;
4594
4594
  }
4595
- export { fe as CACHE_SIZE_UNLIMITED, __PRIVATE_AutoId as _AutoId, ByteString as _ByteString, DatabaseId as _DatabaseId, DocumentKey as _DocumentKey, __PRIVATE_EmptyAppCheckTokenProvider as _EmptyAppCheckTokenProvider, __PRIVATE_EmptyAuthCredentialsProvider as _EmptyAuthCredentialsProvider, FieldPath$1 as _FieldPath, TestingHooks as _TestingHooks, __PRIVATE_cast as _cast, __PRIVATE_debugAssert as _debugAssert, __PRIVATE_isBase64Available as _isBase64Available, __PRIVATE_logWarn as _logWarn, __PRIVATE_validateIsNotUsedTogether as _validateIsNotUsedTogether };
4595
+ export { pe as CACHE_SIZE_UNLIMITED, __PRIVATE_AutoId as _AutoId, ByteString as _ByteString, DatabaseId as _DatabaseId, DocumentKey as _DocumentKey, __PRIVATE_EmptyAppCheckTokenProvider as _EmptyAppCheckTokenProvider, __PRIVATE_EmptyAuthCredentialsProvider as _EmptyAuthCredentialsProvider, FieldPath$1 as _FieldPath, TestingHooks as _TestingHooks, __PRIVATE_cast as _cast, __PRIVATE_debugAssert as _debugAssert, __PRIVATE_isBase64Available as _isBase64Available, __PRIVATE_logWarn as _logWarn, __PRIVATE_validateIsNotUsedTogether as _validateIsNotUsedTogether };
@@ -34,7 +34,19 @@ export interface SnapshotListenOptions {
34
34
  * changed. Default is false.
35
35
  */
36
36
  readonly includeMetadataChanges?: boolean;
37
+ /**
38
+ * Set the source the query listens to. Default to "default", which
39
+ * listens to both cache and server.
40
+ */
41
+ readonly source?: ListenSource;
37
42
  }
43
+ /**
44
+ * Describe the source a query listens to.
45
+ *
46
+ * Set to `default` to listen to both cache and server changes. Set to `cache`
47
+ * to listen to changes in cache only.
48
+ */
49
+ export declare type ListenSource = 'default' | 'cache';
38
50
  /**
39
51
  * Reads the document referred to by this `DocumentReference`.
40
52
  *
@@ -26,7 +26,7 @@ export { ExperimentalLongPollingOptions } from './api/long_polling_options';
26
26
  export { DocumentChange, DocumentChangeType, DocumentSnapshot, FirestoreDataConverter, QueryDocumentSnapshot, QuerySnapshot, snapshotEqual, SnapshotMetadata, SnapshotOptions } from './api/snapshot';
27
27
  export { collection, collectionGroup, CollectionReference, doc, DocumentData, DocumentReference, PartialWithFieldValue, Query, queryEqual, refEqual, SetOptions, UpdateData, WithFieldValue } from './api/reference';
28
28
  export { and, endAt, endBefore, limit, limitToLast, or, orderBy, OrderByDirection, query, QueryCompositeFilterConstraint, QueryConstraint, QueryConstraintType, QueryEndAtConstraint, QueryFieldFilterConstraint, QueryFilterConstraint, QueryLimitConstraint, QueryNonFilterConstraint, QueryOrderByConstraint, QueryStartAtConstraint, startAfter, startAt, where, WhereFilterOp } from './api/filter';
29
- export { SnapshotListenOptions, Unsubscribe } from './api/reference_impl';
29
+ export { ListenSource, SnapshotListenOptions, Unsubscribe } from './api/reference_impl';
30
30
  export { TransactionOptions } from './api/transaction_options';
31
31
  export { runTransaction, Transaction } from './api/transaction';
32
32
  export { addDoc, deleteDoc, executeWrite, getDoc, getDocFromCache, getDocFromServer, getDocs, getDocsFromCache, getDocsFromServer, onSnapshot, onSnapshotsInSync, setDoc, updateDoc } from './api/reference_impl';
@@ -27,6 +27,7 @@ import { ViewSnapshot } from './view_snapshot';
27
27
  declare class QueryListenersInfo {
28
28
  viewSnap: ViewSnapshot | undefined;
29
29
  listeners: QueryListener[];
30
+ hasRemoteListeners(): boolean;
30
31
  }
31
32
  /**
32
33
  * Interface for handling events from the EventManager.
@@ -45,8 +46,10 @@ export interface Observer<T> {
45
46
  * allows users to tree-shake the Watch logic.
46
47
  */
47
48
  export interface EventManager {
48
- onListen?: (query: Query) => Promise<ViewSnapshot>;
49
- onUnlisten?: (query: Query) => Promise<void>;
49
+ onListen?: (query: Query, enableRemoteListen: boolean) => Promise<ViewSnapshot>;
50
+ onUnlisten?: (query: Query, disableRemoteListen: boolean) => Promise<void>;
51
+ onFirstRemoteStoreListen?: (query: Query) => Promise<void>;
52
+ onLastRemoteStoreUnlisten?: (query: Query) => Promise<void>;
50
53
  }
51
54
  export declare function newEventManager(): EventManager;
52
55
  export declare class EventManagerImpl implements EventManager {
@@ -54,9 +57,19 @@ export declare class EventManagerImpl implements EventManager {
54
57
  onlineState: OnlineState;
55
58
  snapshotsInSyncListeners: Set<Observer<void>>;
56
59
  /** Callback invoked when a Query is first listen to. */
57
- onListen?: (query: Query) => Promise<ViewSnapshot>;
60
+ onListen?: (query: Query, enableRemoteListen: boolean) => Promise<ViewSnapshot>;
58
61
  /** Callback invoked once all listeners to a Query are removed. */
59
- onUnlisten?: (query: Query) => Promise<void>;
62
+ onUnlisten?: (query: Query, disableRemoteListen: boolean) => Promise<void>;
63
+ /**
64
+ * Callback invoked when a Query starts listening to the remote store, while
65
+ * already listening to the cache.
66
+ */
67
+ onFirstRemoteStoreListen?: (query: Query) => Promise<void>;
68
+ /**
69
+ * Callback invoked when a Query stops listening to the remote store, while
70
+ * still listening to the cache.
71
+ */
72
+ onLastRemoteStoreUnlisten?: (query: Query) => Promise<void>;
60
73
  }
61
74
  export declare function eventManagerListen(eventManager: EventManager, listener: QueryListener): Promise<void>;
62
75
  export declare function eventManagerUnlisten(eventManager: EventManager, listener: QueryListener): Promise<void>;
@@ -65,6 +78,12 @@ export declare function eventManagerOnWatchError(eventManager: EventManager, que
65
78
  export declare function eventManagerOnOnlineStateChange(eventManager: EventManager, onlineState: OnlineState): void;
66
79
  export declare function addSnapshotsInSyncListener(eventManager: EventManager, observer: Observer<void>): void;
67
80
  export declare function removeSnapshotsInSyncListener(eventManager: EventManager, observer: Observer<void>): void;
81
+ export declare enum ListenerDataSource {
82
+ /** Listen to both cache and server changes */
83
+ Default = "default",
84
+ /** Listen to changes in cache only */
85
+ Cache = "cache"
86
+ }
68
87
  export interface ListenOptions {
69
88
  /** Raise events even when only the metadata changes */
70
89
  readonly includeMetadataChanges?: boolean;
@@ -73,6 +92,8 @@ export interface ListenOptions {
73
92
  * offline.
74
93
  */
75
94
  readonly waitForSyncWhenOnline?: boolean;
95
+ /** Set the source events raised from. */
96
+ readonly source?: ListenerDataSource;
76
97
  }
77
98
  /**
78
99
  * QueryListener takes a series of internal view snapshots and determines
@@ -105,5 +126,6 @@ export declare class QueryListener {
105
126
  private shouldRaiseInitialEvent;
106
127
  private shouldRaiseEvent;
107
128
  private raiseInitialEvent;
129
+ listensToRemoteStore(): boolean;
108
130
  }
109
131
  export {};
@@ -174,9 +174,13 @@ export declare function newSyncEngine(localStore: LocalStore, remoteStore: Remot
174
174
  * server. All the subsequent view snapshots or errors are sent to the
175
175
  * subscribed handlers. Returns the initial snapshot.
176
176
  */
177
- export declare function syncEngineListen(syncEngine: SyncEngine, query: Query): Promise<ViewSnapshot>;
177
+ export declare function syncEngineListen(syncEngine: SyncEngine, query: Query, shouldListenToRemote?: boolean): Promise<ViewSnapshot>;
178
+ /** Query has been listening to the cache, and tries to initiate the remote store listen */
179
+ export declare function triggerRemoteStoreListen(syncEngine: SyncEngine, query: Query): Promise<void>;
178
180
  /** Stops listening to the query. */
179
- export declare function syncEngineUnlisten(syncEngine: SyncEngine, query: Query): Promise<void>;
181
+ export declare function syncEngineUnlisten(syncEngine: SyncEngine, query: Query, shouldUnlistenToRemote: boolean): Promise<void>;
182
+ /** Unlistens to the remote store while still listening to the cache. */
183
+ export declare function triggerRemoteStoreUnlisten(syncEngine: SyncEngine, query: Query): Promise<void>;
180
184
  /**
181
185
  * Initiates the write of local mutation batch which involves adding the
182
186
  * writes to the mutation queue, notifying the remote store about new
@@ -153,7 +153,7 @@ export declare class QueryTargetMetadata {
153
153
  }
154
154
  /**
155
155
  * Metadata state of a single client denoting the query targets it is actively
156
- * listening to.
156
+ * listening to the watch.
157
157
  */
158
158
  export interface ClientState {
159
159
  readonly activeTargetIds: TargetIdSet;
@@ -14,4 +14,5 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- export {};
17
+ import { DocumentChange, DocumentChangeType } from '../util/firebase_export';
18
+ export declare function verifyDocumentChange<T>(change: DocumentChange<T>, id: string, oldIndex: number, newIndex: number, type: DocumentChangeType): void;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2024 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ export {};
@@ -14,4 +14,23 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
+ import { Query } from '../../../src/core/query';
18
+ import { DocumentKey } from '../../../src/model/document_key';
19
+ import { JsonObject } from '../../../src/model/object_value';
20
+ import { LimitType } from '../../../src/protos/firestore_bundle_proto';
21
+ import { TestSnapshotVersion } from '../../util/helpers';
22
+ interface TestBundleDocument {
23
+ key: DocumentKey;
24
+ readTime: TestSnapshotVersion;
25
+ createTime?: TestSnapshotVersion;
26
+ updateTime?: TestSnapshotVersion;
27
+ content?: JsonObject<unknown>;
28
+ }
29
+ interface TestBundledQuery {
30
+ name: string;
31
+ readTime: TestSnapshotVersion;
32
+ query: Query;
33
+ limitType?: LimitType;
34
+ }
35
+ export declare function bundleWithDocumentAndQuery(testDoc: TestBundleDocument, testQuery?: TestBundledQuery): string;
17
36
  export {};
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2024 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ export {};