@@ -107,7 +107,7 @@ export class MemoryComponentProvider {
107
107
OnlineStateSource . SharedClientState
108
108
) ;
109
109
this . remoteStore . syncEngine = this . syncEngine ;
110
-
110
+
111
111
await this . localStore . start ( ) ;
112
112
await this . sharedClientState . start ( ) ;
113
113
await this . remoteStore . start ( ) ;
@@ -197,22 +197,17 @@ export class MemoryLruComponentProvider extends MemoryComponentProvider {
197
197
* Provides all components needed for Firestore with IndexedDB persistence.
198
198
*/
199
199
export class IndexedDbComponentProvider extends MemoryComponentProvider {
200
+ persistence ! : IndexedDbPersistence ;
201
+
202
+ // TODO(tree-shaking): Create an IndexedDbComponentProvider and a
203
+ // MultiTabComponentProvider. The IndexedDbComponentProvider should depend
204
+ // on LocalStore and SyncEngine.
205
+ localStore ! : MultiTabLocalStore ;
206
+ syncEngine ! : MultiTabSyncEngine ;
207
+
200
208
async initialize ( cfg : ComponentConfiguration ) : Promise < void > {
201
209
await super . initialize ( cfg ) ;
202
210
203
- debugAssert (
204
- this . persistence instanceof IndexedDbPersistence ,
205
- 'IndexedDbComponentProvider should provide IndexedDbPersistence'
206
- ) ;
207
- debugAssert (
208
- this . localStore instanceof MultiTabLocalStore ,
209
- 'IndexedDbComponentProvider should provide MultiTabLocalStore'
210
- ) ;
211
- debugAssert (
212
- this . syncEngine instanceof MultiTabSyncEngine ,
213
- 'IndexedDbComponentProvider should provide MultiTabSyncEngine'
214
- ) ;
215
-
216
211
// NOTE: This will immediately call the listener, so we make sure to
217
212
// set it after localStore / remoteStore are started.
218
213
await this . persistence . setPrimaryStateListener ( async isPrimary => {
@@ -230,10 +225,6 @@ export class IndexedDbComponentProvider extends MemoryComponentProvider {
230
225
}
231
226
232
227
createLocalStore ( cfg : ComponentConfiguration ) : LocalStore {
233
- debugAssert (
234
- this . persistence instanceof IndexedDbPersistence ,
235
- 'IndexedDbComponentProvider should provide IndexedDBPersistence'
236
- ) ;
237
228
return new MultiTabLocalStore (
238
229
this . persistence ,
239
230
new IndexFreeQueryEngine ( ) ,
@@ -242,10 +233,6 @@ export class IndexedDbComponentProvider extends MemoryComponentProvider {
242
233
}
243
234
244
235
createSyncEngine ( cfg : ComponentConfiguration ) : SyncEngine {
245
- debugAssert (
246
- this . localStore instanceof MultiTabLocalStore ,
247
- 'IndexedDbComponentProvider should provide MultiTabLocalStore'
248
- ) ;
249
236
const syncEngine = new MultiTabSyncEngine (
250
237
this . localStore ,
251
238
this . remoteStore ,
@@ -262,10 +249,6 @@ export class IndexedDbComponentProvider extends MemoryComponentProvider {
262
249
createGarbageCollectionScheduler (
263
250
cfg : ComponentConfiguration
264
251
) : GarbageCollectionScheduler | null {
265
- debugAssert (
266
- this . persistence instanceof IndexedDbPersistence ,
267
- 'IndexedDbComponentProvider should provide IndexedDBPersistence'
268
- ) ;
269
252
const garbageCollector = this . persistence . referenceDelegate
270
253
. garbageCollector ;
271
254
return new LruScheduler ( garbageCollector , cfg . asyncQueue ) ;
@@ -296,12 +279,10 @@ export class IndexedDbComponentProvider extends MemoryComponentProvider {
296
279
}
297
280
298
281
createSharedClientState ( cfg : ComponentConfiguration ) : SharedClientState {
299
- debugAssert (
300
- cfg . persistenceSettings . durable ,
301
- 'Can only start durable persistence'
302
- ) ;
303
-
304
- if ( cfg . persistenceSettings . synchronizeTabs ) {
282
+ if (
283
+ cfg . persistenceSettings . durable &&
284
+ cfg . persistenceSettings . synchronizeTabs
285
+ ) {
305
286
if ( ! WebStorageSharedClientState . isAvailable ( cfg . platform ) ) {
306
287
throw new FirestoreError (
307
288
Code . UNIMPLEMENTED ,
0 commit comments