File tree Expand file tree Collapse file tree 12 files changed +30
-60
lines changed Expand file tree Collapse file tree 12 files changed +30
-60
lines changed Original file line number Diff line number Diff line change @@ -29,8 +29,6 @@ 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
-
34
32
declare module '@firebase/component' {
35
33
interface NameServiceMapping {
36
34
'app-compat' : FirebaseApp ;
@@ -41,15 +39,14 @@ declare module '@firebase/component' {
41
39
42
40
const factory : InstanceFactory < 'functions-compat' > = (
43
41
container : ComponentContainer ,
44
- options ? : InstanceFactoryOptions
42
+ { instanceIdentifier : regionOrCustomDomain } : InstanceFactoryOptions
45
43
) => {
46
44
// Dependencies
47
45
const app = container . getProvider ( 'app-compat' ) . getImmediate ( ) ;
48
46
const functionsServiceExp = container
49
47
. getProvider ( 'functions-exp' )
50
48
. getImmediate ( {
51
- // This value is used as regionOrCustomDomain
52
- identifier : options ?. instanceIdentifier ?? DEFAULT_REGION
49
+ identifier : regionOrCustomDomain
53
50
} ) ;
54
51
55
52
return new FunctionsService ( app , functionsServiceExp ) ;
Original file line number Diff line number Diff line change @@ -21,15 +21,16 @@ import {
21
21
Component ,
22
22
ComponentType ,
23
23
ComponentContainer ,
24
- InstanceFactory ,
25
- InstanceFactoryOptions
24
+ InstanceFactory
26
25
} from '@firebase/component' ;
27
26
import { FUNCTIONS_TYPE } from './constants' ;
28
27
28
+ export const DEFAULT_REGION = 'us-central1' ;
29
+
29
30
export function registerFunctions ( fetchImpl : typeof fetch ) : void {
30
31
const factory : InstanceFactory < 'functions' > = (
31
32
container : ComponentContainer ,
32
- options ?: InstanceFactoryOptions
33
+ { instanceIdentifier : regionOrCustomDomain }
33
34
) => {
34
35
// Dependencies
35
36
const app = container . getProvider ( 'app-exp' ) . getImmediate ( ) ;
@@ -41,8 +42,7 @@ export function registerFunctions(fetchImpl: typeof fetch): void {
41
42
app ,
42
43
authProvider ,
43
44
messagingProvider ,
44
- // regionOrCustomDomain
45
- options ?. instanceIdentifier ,
45
+ regionOrCustomDomain ,
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
- instanceFactoryOptions ? : { options ?: PerformanceSettings }
94
+ { options : settings } : { 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 ( instanceFactoryOptions . options ) ;
110
+ perfInstance . _init ( settings ) ;
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
- options ? : InstanceFactoryOptions
52
+ { instanceIdentifier : namespace } : 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 : options ?. instanceIdentifier // namespace
57
+ identifier : 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
- options ? : InstanceFactoryOptions
57
+ { instanceIdentifier : namespace } : 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
- const namespace = options ?. instanceIdentifier || 'firebase' ;
83
+ namespace = namespace || '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 {
21
- Component ,
22
- ComponentType ,
23
- InstanceFactoryOptions
24
- } from '@firebase/component' ;
20
+ import { Component , ComponentType } from '@firebase/component' ;
25
21
26
22
import { version } from '../package.json' ;
27
23
import { FirebaseDatabase } from '../src/exp/Database' ;
@@ -39,14 +35,10 @@ function registerDatabase(): void {
39
35
_registerComponent (
40
36
new Component (
41
37
'database-exp' ,
42
- ( container , options ?: InstanceFactoryOptions ) => {
38
+ ( container , { instanceIdentifier : url } ) => {
43
39
const app = container . getProvider ( 'app-exp' ) . getImmediate ( ) ! ;
44
40
const authProvider = container . getProvider ( 'auth-internal' ) ;
45
- return new FirebaseDatabase (
46
- app ,
47
- authProvider ,
48
- options ?. instanceIdentifier // url
49
- ) ;
41
+ return new FirebaseDatabase ( app , authProvider , url ) ;
50
42
} ,
51
43
ComponentType . PUBLIC
52
44
) . setMultipleInstances ( true )
Original file line number Diff line number Diff line change @@ -30,11 +30,7 @@ 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 {
34
- Component ,
35
- ComponentType ,
36
- InstanceFactoryOptions
37
- } from '@firebase/component' ;
33
+ import { Component , ComponentType } from '@firebase/component' ;
38
34
import { FirebaseAuthInternal } from '@firebase/auth-interop-types' ;
39
35
40
36
import { name , version } from './package.json' ;
@@ -88,18 +84,13 @@ export function registerDatabase(instance: FirebaseNamespace) {
88
84
const namespace = ( instance as _FirebaseNamespace ) . INTERNAL . registerComponent (
89
85
new Component (
90
86
'database' ,
91
- ( container , options ?: InstanceFactoryOptions ) => {
87
+ ( container , { instanceIdentifier : url } ) => {
92
88
/* Dependencies */
93
89
// getImmediate for FirebaseApp will always succeed
94
90
const app = container . getProvider ( 'app' ) . getImmediate ( ) ;
95
91
const authProvider = container . getProvider ( 'auth-internal' ) ;
96
92
97
- return repoManagerDatabaseFromApp (
98
- app ,
99
- authProvider ,
100
- options ?. instanceIdentifier , // url
101
- undefined
102
- ) ;
93
+ return repoManagerDatabaseFromApp ( app , authProvider , url , undefined ) ;
103
94
} ,
104
95
ComponentType . PUBLIC
105
96
)
Original file line number Diff line number Diff line change @@ -30,11 +30,7 @@ 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 {
34
- Component ,
35
- ComponentType ,
36
- InstanceFactoryOptions
37
- } from '@firebase/component' ;
33
+ import { Component , ComponentType } from '@firebase/component' ;
38
34
39
35
import { name , version } from './package.json' ;
40
36
@@ -48,18 +44,13 @@ export function registerDatabase(instance: FirebaseNamespace) {
48
44
const namespace = ( instance as _FirebaseNamespace ) . INTERNAL . registerComponent (
49
45
new Component (
50
46
'database' ,
51
- ( container , options : InstanceFactoryOptions ) => {
47
+ ( container , { instanceIdentifier : url } ) => {
52
48
/* Dependencies */
53
49
// getImmediate for FirebaseApp will always succeed
54
50
const app = container . getProvider ( 'app' ) . getImmediate ( ) ;
55
51
const authProvider = container . getProvider ( 'auth-internal' ) ;
56
52
57
- return repoManagerDatabaseFromApp (
58
- app ,
59
- authProvider ,
60
- options ?. instanceIdentifier , // url
61
- undefined
62
- ) ;
53
+ return repoManagerDatabaseFromApp ( app , authProvider , url , undefined ) ;
63
54
} ,
64
55
ComponentType . PUBLIC
65
56
)
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
- options ? : InstanceFactoryOptions
43
+ { instanceIdentifier : regionOrCustomDomain } : InstanceFactoryOptions
44
44
) : Service {
45
45
// Dependencies
46
46
const app = container . getProvider ( 'app' ) . getImmediate ( ) ;
@@ -52,8 +52,7 @@ export function registerFunctions(
52
52
app ,
53
53
authProvider ,
54
54
messagingProvider ,
55
- // regionOrCustomDomain
56
- options ?. instanceIdentifier ,
55
+ regionOrCustomDomain ,
57
56
fetchImpl
58
57
) ;
59
58
}
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
- options ? : InstanceFactoryOptions
63
+ { instanceIdentifier : namespace } : 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
- const namespace = options ?. instanceIdentifier || 'firebase' ;
87
+ namespace = namespace || '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
- options ? : InstanceFactoryOptions
44
+ { instanceIdentifier : url } : 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
- options ?. instanceIdentifier , // url
59
+ 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
- options ? : InstanceFactoryOptions
301
+ { instanceIdentifier : url } : 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
- options ?. instanceIdentifier , // url
310
+ url ,
311
311
SDK_VERSION
312
312
) ;
313
313
}
You can’t perform that action at this time.
0 commit comments