@@ -72,6 +72,7 @@ export class Firestore implements FirestoreService {
72
72
73
73
private _settings = new FirestoreSettingsImpl ( { } ) ;
74
74
private _settingsFrozen = false ;
75
+ private _emulatorOptions ? : { mockUserToken ?: EmulatorMockTokenOptions | string ; } ;
75
76
76
77
// A task that is assigned when the terminate() is invoked and resolved when
77
78
// all components have shut down. Otherwise, Firestore is not terminated,
@@ -120,6 +121,8 @@ export class Firestore implements FirestoreService {
120
121
) ;
121
122
}
122
123
this . _settings = new FirestoreSettingsImpl ( settings ) ;
124
+ this . _emulatorOptions = settings . emulatorOptions ;
125
+
123
126
if ( settings . credentials !== undefined ) {
124
127
this . _authCredentials = makeAuthCredentialsProvider ( settings . credentials ) ;
125
128
}
@@ -129,6 +132,17 @@ export class Firestore implements FirestoreService {
129
132
return this . _settings ;
130
133
}
131
134
135
+ _getPrivateSettings ( ) : PrivateSettings {
136
+ const privateSettings : PrivateSettings = {
137
+ ...this . _settings ,
138
+ emulatorOptions : this . _emulatorOptions
139
+ } ;
140
+ if ( this . _settings . localCache !== undefined ) {
141
+ privateSettings . localCache = this . _settings . localCache ;
142
+ }
143
+ return privateSettings ;
144
+ }
145
+
132
146
_freezeSettings ( ) : FirestoreSettingsImpl {
133
147
this . _settingsFrozen = true ;
134
148
return this . _settings ;
@@ -316,7 +330,7 @@ export function connectFirestoreEmulator(
316
330
} = { }
317
331
) : void {
318
332
firestore = cast ( firestore , Firestore ) ;
319
- const settings = firestore . _getSettings ( ) ;
333
+ const settings = firestore . _getPrivateSettings ( ) ;
320
334
const newHostSetting = `${ host } :${ port } ` ;
321
335
322
336
if ( settings . host !== DEFAULT_HOST && settings . host !== newHostSetting ) {
@@ -325,20 +339,22 @@ export function connectFirestoreEmulator(
325
339
'will be used.'
326
340
) ;
327
341
}
328
- const privateSettings = {
342
+ const newSettings = {
329
343
...settings ,
330
344
host : newHostSetting ,
331
- ssl : false
345
+ ssl : false ,
346
+ emulatorOptions : options
332
347
} ;
333
348
334
- // Turn this invocation into a no -op if the new configuration matches the current configuration.
335
- // This helps support SSR enviornments where `connectFirestoreEmulator` could be called multiple
336
- // times.
337
- if ( deepEqual ( privateSettings , settings ) ) {
349
+ // No -op if the new configuration matches the current configuration. This supports SSR
350
+ // enviornments which might call `connectFirestoreEmulator` multiple times as a standard practice.
351
+ if ( deepEqual ( newSettings , settings ) ) {
352
+ console . error ( "DEDB settings are the same!" ) ;
338
353
return ;
339
354
}
355
+ console . error ( "DEDB settings differ!" )
340
356
341
- firestore . _setSettings ( privateSettings ) ;
357
+ firestore . _setSettings ( newSettings ) ;
342
358
343
359
if ( options . mockUserToken ) {
344
360
let token : string ;
0 commit comments