File tree Expand file tree Collapse file tree 12 files changed +60
-30
lines changed Expand file tree Collapse file tree 12 files changed +60
-30
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,8 @@ import {
29
29
} from '@firebase/component' ;
30
30
import { Functions as FunctionsServiceExp } from '@firebase/functions-exp' ;
31
31
32
+ const DEFAULT_REGION = 'us-central1' ;
33
+
32
34
declare module '@firebase/component' {
33
35
interface NameServiceMapping {
34
36
'app-compat' : FirebaseApp ;
@@ -39,14 +41,15 @@ declare module '@firebase/component' {
39
41
40
42
const factory : InstanceFactory < 'functions-compat' > = (
41
43
container : ComponentContainer ,
42
- { instanceIdentifier : regionOrCustomDomain } : InstanceFactoryOptions
44
+ options ? : InstanceFactoryOptions
43
45
) => {
44
46
// Dependencies
45
47
const app = container . getProvider ( 'app-compat' ) . getImmediate ( ) ;
46
48
const functionsServiceExp = container
47
49
. getProvider ( 'functions-exp' )
48
50
. getImmediate ( {
49
- identifier : regionOrCustomDomain
51
+ // This value is used as regionOrCustomDomain
52
+ identifier : options ?. instanceIdentifier ?? DEFAULT_REGION
50
53
} ) ;
51
54
52
55
return new FunctionsService ( app , functionsServiceExp ) ;
Original file line number Diff line number Diff line change @@ -21,16 +21,15 @@ import {
21
21
Component ,
22
22
ComponentType ,
23
23
ComponentContainer ,
24
- InstanceFactory
24
+ InstanceFactory ,
25
+ InstanceFactoryOptions
25
26
} from '@firebase/component' ;
26
27
import { FUNCTIONS_TYPE } from './constants' ;
27
28
28
- export const DEFAULT_REGION = 'us-central1' ;
29
-
30
29
export function registerFunctions ( fetchImpl : typeof fetch ) : void {
31
30
const factory : InstanceFactory < 'functions' > = (
32
31
container : ComponentContainer ,
33
- { instanceIdentifier : regionOrCustomDomain }
32
+ options ?: InstanceFactoryOptions
34
33
) => {
35
34
// Dependencies
36
35
const app = container . getProvider ( 'app-exp' ) . getImmediate ( ) ;
@@ -42,7 +41,8 @@ export function registerFunctions(fetchImpl: typeof fetch): void {
42
41
app ,
43
42
authProvider ,
44
43
messagingProvider ,
45
- regionOrCustomDomain ,
44
+ // regionOrCustomDomain
45
+ options ?. instanceIdentifier ,
46
46
fetchImpl
47
47
) ;
48
48
} ;
Original file line number Diff line number Diff line change @@ -91,7 +91,7 @@ export function trace(
91
91
92
92
const factory : InstanceFactory < 'performance-exp' > = (
93
93
container : ComponentContainer ,
94
- { options : settings } : { options ?: PerformanceSettings }
94
+ instanceFactoryOptions ? : { options ?: PerformanceSettings }
95
95
) => {
96
96
// Dependencies
97
97
const app = container . getProvider ( 'app-exp' ) . getImmediate ( ) ;
@@ -107,7 +107,7 @@ const factory: InstanceFactory<'performance-exp'> = (
107
107
}
108
108
setupApi ( window ) ;
109
109
const perfInstance = new PerformanceController ( app , installations ) ;
110
- perfInstance . _init ( settings ) ;
110
+ perfInstance . _init ( instanceFactoryOptions . options ) ;
111
111
112
112
return perfInstance ;
113
113
} ;
Original file line number Diff line number Diff line change @@ -49,12 +49,12 @@ function registerRemoteConfigCompat(
49
49
50
50
function remoteConfigFactory (
51
51
container : ComponentContainer ,
52
- { instanceIdentifier : namespace } : InstanceFactoryOptions
52
+ options ? : InstanceFactoryOptions
53
53
) : RemoteConfigCompatImpl {
54
54
const app = container . getProvider ( 'app-compat' ) . getImmediate ( ) ;
55
55
// The following call will always succeed because rc `import {...} from '@firebase/remote-config-exp'`
56
56
const remoteConfig = container . getProvider ( 'remote-config-exp' ) . getImmediate ( {
57
- identifier : namespace
57
+ identifier : options ?. instanceIdentifier // namespace
58
58
} ) ;
59
59
60
60
return new RemoteConfigCompatImpl ( app , remoteConfig ) ;
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ export function registerRemoteConfig(): void {
54
54
55
55
function remoteConfigFactory (
56
56
container : ComponentContainer ,
57
- { instanceIdentifier : namespace } : InstanceFactoryOptions
57
+ options ? : InstanceFactoryOptions
58
58
) : RemoteConfig {
59
59
/* Dependencies */
60
60
// getImmediate for FirebaseApp will always succeed
@@ -80,7 +80,7 @@ export function registerRemoteConfig(): void {
80
80
if ( ! appId ) {
81
81
throw ERROR_FACTORY . create ( ErrorCode . REGISTRATION_APP_ID ) ;
82
82
}
83
- namespace = namespace || 'firebase' ;
83
+ const namespace = options ?. instanceIdentifier || 'firebase' ;
84
84
85
85
const storage = new Storage ( appId , app . name , namespace ) ;
86
86
const storageCache = new StorageCache ( storage ) ;
Original file line number Diff line number Diff line change 17
17
18
18
// eslint-disable-next-line import/no-extraneous-dependencies
19
19
import { _registerComponent , registerVersion } from '@firebase/app-exp' ;
20
- import { Component , ComponentType } from '@firebase/component' ;
20
+ import {
21
+ Component ,
22
+ ComponentType ,
23
+ InstanceFactoryOptions
24
+ } from '@firebase/component' ;
21
25
22
26
import { version } from '../package.json' ;
23
27
import { FirebaseDatabase } from '../src/exp/Database' ;
@@ -35,10 +39,14 @@ function registerDatabase(): void {
35
39
_registerComponent (
36
40
new Component (
37
41
'database-exp' ,
38
- ( container , { instanceIdentifier : url } ) => {
42
+ ( container , options ?: InstanceFactoryOptions ) => {
39
43
const app = container . getProvider ( 'app-exp' ) . getImmediate ( ) ! ;
40
44
const authProvider = container . getProvider ( 'auth-internal' ) ;
41
- return new FirebaseDatabase ( app , authProvider , url ) ;
45
+ return new FirebaseDatabase (
46
+ app ,
47
+ authProvider ,
48
+ options ?. instanceIdentifier // url
49
+ ) ;
42
50
} ,
43
51
ComponentType . PUBLIC
44
52
) . setMultipleInstances ( true )
Original file line number Diff line number Diff line change @@ -30,7 +30,11 @@ import { setSDKVersion } from './src/core/version';
30
30
import { CONSTANTS , isNodeSdk } from '@firebase/util' ;
31
31
import { setWebSocketImpl } from './src/realtime/WebSocketConnection' ;
32
32
import { Client } from 'faye-websocket' ;
33
- import { Component , ComponentType } from '@firebase/component' ;
33
+ import {
34
+ Component ,
35
+ ComponentType ,
36
+ InstanceFactoryOptions
37
+ } from '@firebase/component' ;
34
38
import { FirebaseAuthInternal } from '@firebase/auth-interop-types' ;
35
39
36
40
import { name , version } from './package.json' ;
@@ -84,13 +88,18 @@ export function registerDatabase(instance: FirebaseNamespace) {
84
88
const namespace = ( instance as _FirebaseNamespace ) . INTERNAL . registerComponent (
85
89
new Component (
86
90
'database' ,
87
- ( container , { instanceIdentifier : url } ) => {
91
+ ( container , options ?: InstanceFactoryOptions ) => {
88
92
/* Dependencies */
89
93
// getImmediate for FirebaseApp will always succeed
90
94
const app = container . getProvider ( 'app' ) . getImmediate ( ) ;
91
95
const authProvider = container . getProvider ( 'auth-internal' ) ;
92
96
93
- return repoManagerDatabaseFromApp ( app , authProvider , url , undefined ) ;
97
+ return repoManagerDatabaseFromApp (
98
+ app ,
99
+ authProvider ,
100
+ options ?. instanceIdentifier , // url
101
+ undefined
102
+ ) ;
94
103
} ,
95
104
ComponentType . PUBLIC
96
105
)
Original file line number Diff line number Diff line change @@ -30,7 +30,11 @@ import * as TEST_ACCESS from './src/api/test_access';
30
30
import { isNodeSdk } from '@firebase/util' ;
31
31
import * as types from '@firebase/database-types' ;
32
32
import { setSDKVersion } from './src/core/version' ;
33
- import { Component , ComponentType } from '@firebase/component' ;
33
+ import {
34
+ Component ,
35
+ ComponentType ,
36
+ InstanceFactoryOptions
37
+ } from '@firebase/component' ;
34
38
35
39
import { name , version } from './package.json' ;
36
40
@@ -44,13 +48,18 @@ export function registerDatabase(instance: FirebaseNamespace) {
44
48
const namespace = ( instance as _FirebaseNamespace ) . INTERNAL . registerComponent (
45
49
new Component (
46
50
'database' ,
47
- ( container , { instanceIdentifier : url } ) => {
51
+ ( container , options : InstanceFactoryOptions ) => {
48
52
/* Dependencies */
49
53
// getImmediate for FirebaseApp will always succeed
50
54
const app = container . getProvider ( 'app' ) . getImmediate ( ) ;
51
55
const authProvider = container . getProvider ( 'auth-internal' ) ;
52
56
53
- return repoManagerDatabaseFromApp ( app , authProvider , url , undefined ) ;
57
+ return repoManagerDatabaseFromApp (
58
+ app ,
59
+ authProvider ,
60
+ options ?. instanceIdentifier , // url
61
+ undefined
62
+ ) ;
54
63
} ,
55
64
ComponentType . PUBLIC
56
65
)
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ export function registerFunctions(
40
40
41
41
function factory (
42
42
container : ComponentContainer ,
43
- { instanceIdentifier : regionOrCustomDomain } : InstanceFactoryOptions
43
+ options ? : InstanceFactoryOptions
44
44
) : Service {
45
45
// Dependencies
46
46
const app = container . getProvider ( 'app' ) . getImmediate ( ) ;
@@ -52,7 +52,8 @@ export function registerFunctions(
52
52
app ,
53
53
authProvider ,
54
54
messagingProvider ,
55
- regionOrCustomDomain ,
55
+ // regionOrCustomDomain
56
+ options ?. instanceIdentifier ,
56
57
fetchImpl
57
58
) ;
58
59
}
Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ export function registerRemoteConfig(
60
60
61
61
function remoteConfigFactory (
62
62
container : ComponentContainer ,
63
- { instanceIdentifier : namespace } : InstanceFactoryOptions
63
+ options ? : InstanceFactoryOptions
64
64
) : RemoteConfig {
65
65
/* Dependencies */
66
66
// getImmediate for FirebaseApp will always succeed
@@ -84,7 +84,7 @@ export function registerRemoteConfig(
84
84
if ( ! appId ) {
85
85
throw ERROR_FACTORY . create ( ErrorCode . REGISTRATION_APP_ID ) ;
86
86
}
87
- namespace = namespace || 'firebase' ;
87
+ const namespace = options ?. instanceIdentifier || 'firebase' ;
88
88
89
89
const storage = new Storage ( appId , app . name , namespace ) ;
90
90
const storageCache = new StorageCache ( storage ) ;
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ const STORAGE_TYPE = 'storage';
41
41
42
42
function factory (
43
43
container : ComponentContainer ,
44
- { instanceIdentifier : url } : InstanceFactoryOptions
44
+ options ? : InstanceFactoryOptions
45
45
) : types . FirebaseStorage {
46
46
// Dependencies
47
47
// TODO: This should eventually be 'app-compat'
@@ -56,7 +56,7 @@ function factory(
56
56
app ,
57
57
authProvider ,
58
58
new XhrIoPool ( ) ,
59
- url ,
59
+ options ?. instanceIdentifier , // url
60
60
firebase . SDK_VERSION
61
61
)
62
62
) ;
Original file line number Diff line number Diff line change @@ -298,7 +298,7 @@ export function getStorage(
298
298
299
299
function factory (
300
300
container : ComponentContainer ,
301
- { instanceIdentifier : url } : InstanceFactoryOptions
301
+ options ? : InstanceFactoryOptions
302
302
) : StorageService {
303
303
const app = container . getProvider ( 'app-exp' ) . getImmediate ( ) ;
304
304
const authProvider = container . getProvider ( 'auth-internal' ) ;
@@ -307,7 +307,7 @@ function factory(
307
307
app ,
308
308
authProvider ,
309
309
new XhrIoPool ( ) ,
310
- url ,
310
+ options ?. instanceIdentifier , // url
311
311
SDK_VERSION
312
312
) ;
313
313
}
You can’t perform that action at this time.
0 commit comments