15
15
* limitations under the License.
16
16
*/
17
17
18
- import * as firestore from '../../../exp-types' ;
19
-
20
18
import { _getProvider , _removeServiceInstance } from '@firebase/app-exp' ;
21
19
import { _FirebaseService , FirebaseApp } from '@firebase/app-types-exp' ;
22
20
import { Provider } from '@firebase/component' ;
@@ -37,7 +35,10 @@ import {
37
35
MultiTabOfflineComponentProvider ,
38
36
OnlineComponentProvider
39
37
} from '../../../src/core/component_provider' ;
40
- import { Firestore as LiteFirestore } from '../../../lite/src/api/database' ;
38
+ import {
39
+ Firestore as LiteFirestore ,
40
+ Settings as LiteSettings
41
+ } from '../../../lite/src/api/database' ;
41
42
import { cast } from '../../../lite/src/api/util' ;
42
43
import { Code , FirestoreError } from '../../../src/util/error' ;
43
44
import { Deferred } from '../../../src/util/promise' ;
@@ -65,12 +66,15 @@ import { logDebug } from '../../../src/util/log';
65
66
66
67
const LOG_TAG = 'Firestore' ;
67
68
69
+ export interface Settings extends LiteSettings {
70
+ cacheSizeBytes ?: number ;
71
+ }
72
+
68
73
/**
69
74
* The root reference to the Firestore database and the entry point for the
70
75
* tree-shakeable SDK.
71
76
*/
72
- export class Firestore extends LiteFirestore
73
- implements firestore . FirebaseFirestore , _FirebaseService {
77
+ export class Firestore extends LiteFirestore implements _FirebaseService {
74
78
readonly _queue = new AsyncQueue ( ) ;
75
79
readonly _persistenceKey : string ;
76
80
readonly _clientId = AutoId . newId ( ) ;
@@ -81,7 +85,7 @@ export class Firestore extends LiteFirestore
81
85
82
86
// We override the Settings property of the Lite SDK since the full Firestore
83
87
// SDK supports more settings.
84
- protected _settings ?: firestore . Settings ;
88
+ protected _settings ?: Settings ;
85
89
86
90
constructor (
87
91
app : FirebaseApp ,
@@ -128,7 +132,7 @@ export class Firestore extends LiteFirestore
128
132
} ;
129
133
}
130
134
131
- _getSettings ( ) : firestore . Settings {
135
+ _getSettings ( ) : Settings {
132
136
return super . _getSettings ( ) ;
133
137
}
134
138
@@ -160,7 +164,7 @@ export class Firestore extends LiteFirestore
160
164
161
165
export function initializeFirestore (
162
166
app : FirebaseApp ,
163
- settings : firestore . Settings
167
+ settings : Settings
164
168
) : Firestore {
165
169
const firestore = _getProvider (
166
170
app ,
@@ -187,7 +191,7 @@ export function getFirestore(app: FirebaseApp): Firestore {
187
191
}
188
192
189
193
export function enableIndexedDbPersistence (
190
- firestore : firestore . FirebaseFirestore
194
+ firestore : Firestore
191
195
) : Promise < void > {
192
196
const firestoreImpl = cast ( firestore , Firestore ) ;
193
197
verifyNotInitialized ( firestoreImpl ) ;
@@ -213,7 +217,7 @@ export function enableIndexedDbPersistence(
213
217
}
214
218
215
219
export function enableMultiTabIndexedDbPersistence (
216
- firestore : firestore . FirebaseFirestore
220
+ firestore : Firestore
217
221
) : Promise < void > {
218
222
const firestoreImpl = cast ( firestore , Firestore ) ;
219
223
verifyNotInitialized ( firestoreImpl ) ;
@@ -243,9 +247,7 @@ export function enableMultiTabIndexedDbPersistence(
243
247
) ;
244
248
}
245
249
246
- export function clearIndexedDbPersistence (
247
- firestore : firestore . FirebaseFirestore
248
- ) : Promise < void > {
250
+ export function clearIndexedDbPersistence ( firestore : Firestore ) : Promise < void > {
249
251
const firestoreImpl = cast ( firestore , Firestore ) ;
250
252
if ( firestoreImpl . _initialized && ! firestoreImpl . _terminated ) {
251
253
throw new FirestoreError (
@@ -272,18 +274,14 @@ export function clearIndexedDbPersistence(
272
274
return deferred . promise ;
273
275
}
274
276
275
- export function waitForPendingWrites (
276
- firestore : firestore . FirebaseFirestore
277
- ) : Promise < void > {
277
+ export function waitForPendingWrites ( firestore : Firestore ) : Promise < void > {
278
278
const firestoreImpl = cast ( firestore , Firestore ) ;
279
279
return getSyncEngine ( firestoreImpl ) . then ( syncEngine =>
280
280
enqueueWaitForPendingWrites ( firestoreImpl . _queue , syncEngine )
281
281
) ;
282
282
}
283
283
284
- export function enableNetwork (
285
- firestore : firestore . FirebaseFirestore
286
- ) : Promise < void > {
284
+ export function enableNetwork ( firestore : Firestore ) : Promise < void > {
287
285
const firestoreImpl = cast ( firestore , Firestore ) ;
288
286
return Promise . all ( [
289
287
getRemoteStore ( firestoreImpl ) ,
@@ -298,9 +296,7 @@ export function enableNetwork(
298
296
) ;
299
297
}
300
298
301
- export function disableNetwork (
302
- firestore : firestore . FirebaseFirestore
303
- ) : Promise < void > {
299
+ export function disableNetwork ( firestore : Firestore ) : Promise < void > {
304
300
const firestoreImpl = cast ( firestore , Firestore ) ;
305
301
return Promise . all ( [
306
302
getRemoteStore ( firestoreImpl ) ,
@@ -315,9 +311,7 @@ export function disableNetwork(
315
311
) ;
316
312
}
317
313
318
- export function terminate (
319
- firestore : firestore . FirebaseFirestore
320
- ) : Promise < void > {
314
+ export function terminate ( firestore : Firestore ) : Promise < void > {
321
315
_removeServiceInstance ( firestore . app , 'firestore-exp' ) ;
322
316
const firestoreImpl = cast ( firestore , Firestore ) ;
323
317
return firestoreImpl . delete ( ) ;
0 commit comments