Skip to content

Commit 60e8a8e

Browse files
committed
Revert non functions-compat changes
1 parent 0453815 commit 60e8a8e

File tree

12 files changed

+60
-30
lines changed

12 files changed

+60
-30
lines changed

packages-exp/functions-compat/src/register.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ import {
2929
} from '@firebase/component';
3030
import { Functions as FunctionsServiceExp } from '@firebase/functions-exp';
3131

32+
const DEFAULT_REGION = 'us-central1';
33+
3234
declare module '@firebase/component' {
3335
interface NameServiceMapping {
3436
'app-compat': FirebaseApp;
@@ -39,14 +41,15 @@ declare module '@firebase/component' {
3941

4042
const factory: InstanceFactory<'functions-compat'> = (
4143
container: ComponentContainer,
42-
{ instanceIdentifier: regionOrCustomDomain }: InstanceFactoryOptions
44+
options?: InstanceFactoryOptions
4345
) => {
4446
// Dependencies
4547
const app = container.getProvider('app-compat').getImmediate();
4648
const functionsServiceExp = container
4749
.getProvider('functions-exp')
4850
.getImmediate({
49-
identifier: regionOrCustomDomain
51+
// This value is used as regionOrCustomDomain
52+
identifier: options?.instanceIdentifier ?? DEFAULT_REGION
5053
});
5154

5255
return new FunctionsService(app, functionsServiceExp);

packages-exp/functions-exp/src/config.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,15 @@ import {
2121
Component,
2222
ComponentType,
2323
ComponentContainer,
24-
InstanceFactory
24+
InstanceFactory,
25+
InstanceFactoryOptions
2526
} from '@firebase/component';
2627
import { FUNCTIONS_TYPE } from './constants';
2728

28-
export const DEFAULT_REGION = 'us-central1';
29-
3029
export function registerFunctions(fetchImpl: typeof fetch): void {
3130
const factory: InstanceFactory<'functions'> = (
3231
container: ComponentContainer,
33-
{ instanceIdentifier: regionOrCustomDomain }
32+
options?: InstanceFactoryOptions
3433
) => {
3534
// Dependencies
3635
const app = container.getProvider('app-exp').getImmediate();
@@ -42,7 +41,8 @@ export function registerFunctions(fetchImpl: typeof fetch): void {
4241
app,
4342
authProvider,
4443
messagingProvider,
45-
regionOrCustomDomain,
44+
// regionOrCustomDomain
45+
options?.instanceIdentifier,
4646
fetchImpl
4747
);
4848
};

packages-exp/performance-exp/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export function trace(
9191

9292
const factory: InstanceFactory<'performance-exp'> = (
9393
container: ComponentContainer,
94-
{ options: settings }: { options?: PerformanceSettings }
94+
instanceFactoryOptions?: { options?: PerformanceSettings }
9595
) => {
9696
// Dependencies
9797
const app = container.getProvider('app-exp').getImmediate();
@@ -107,7 +107,7 @@ const factory: InstanceFactory<'performance-exp'> = (
107107
}
108108
setupApi(window);
109109
const perfInstance = new PerformanceController(app, installations);
110-
perfInstance._init(settings);
110+
perfInstance._init(instanceFactoryOptions.options);
111111

112112
return perfInstance;
113113
};

packages-exp/remote-config-compat/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ function registerRemoteConfigCompat(
4949

5050
function remoteConfigFactory(
5151
container: ComponentContainer,
52-
{ instanceIdentifier: namespace }: InstanceFactoryOptions
52+
options?: InstanceFactoryOptions
5353
): RemoteConfigCompatImpl {
5454
const app = container.getProvider('app-compat').getImmediate();
5555
// The following call will always succeed because rc `import {...} from '@firebase/remote-config-exp'`
5656
const remoteConfig = container.getProvider('remote-config-exp').getImmediate({
57-
identifier: namespace
57+
identifier: options?.instanceIdentifier // namespace
5858
});
5959

6060
return new RemoteConfigCompatImpl(app, remoteConfig);

packages-exp/remote-config-exp/src/register.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export function registerRemoteConfig(): void {
5454

5555
function remoteConfigFactory(
5656
container: ComponentContainer,
57-
{ instanceIdentifier: namespace }: InstanceFactoryOptions
57+
options?: InstanceFactoryOptions
5858
): RemoteConfig {
5959
/* Dependencies */
6060
// getImmediate for FirebaseApp will always succeed
@@ -80,7 +80,7 @@ export function registerRemoteConfig(): void {
8080
if (!appId) {
8181
throw ERROR_FACTORY.create(ErrorCode.REGISTRATION_APP_ID);
8282
}
83-
namespace = namespace || 'firebase';
83+
const namespace = options?.instanceIdentifier || 'firebase';
8484

8585
const storage = new Storage(appId, app.name, namespace);
8686
const storageCache = new StorageCache(storage);

packages/database/exp/index.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@
1717

1818
// eslint-disable-next-line import/no-extraneous-dependencies
1919
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';
2125

2226
import { version } from '../package.json';
2327
import { FirebaseDatabase } from '../src/exp/Database';
@@ -35,10 +39,14 @@ function registerDatabase(): void {
3539
_registerComponent(
3640
new Component(
3741
'database-exp',
38-
(container, { instanceIdentifier: url }) => {
42+
(container, options?: InstanceFactoryOptions) => {
3943
const app = container.getProvider('app-exp').getImmediate()!;
4044
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+
);
4250
},
4351
ComponentType.PUBLIC
4452
).setMultipleInstances(true)

packages/database/index.node.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ import { setSDKVersion } from './src/core/version';
3030
import { CONSTANTS, isNodeSdk } from '@firebase/util';
3131
import { setWebSocketImpl } from './src/realtime/WebSocketConnection';
3232
import { Client } from 'faye-websocket';
33-
import { Component, ComponentType } from '@firebase/component';
33+
import {
34+
Component,
35+
ComponentType,
36+
InstanceFactoryOptions
37+
} from '@firebase/component';
3438
import { FirebaseAuthInternal } from '@firebase/auth-interop-types';
3539

3640
import { name, version } from './package.json';
@@ -84,13 +88,18 @@ export function registerDatabase(instance: FirebaseNamespace) {
8488
const namespace = (instance as _FirebaseNamespace).INTERNAL.registerComponent(
8589
new Component(
8690
'database',
87-
(container, { instanceIdentifier: url }) => {
91+
(container, options?: InstanceFactoryOptions) => {
8892
/* Dependencies */
8993
// getImmediate for FirebaseApp will always succeed
9094
const app = container.getProvider('app').getImmediate();
9195
const authProvider = container.getProvider('auth-internal');
9296

93-
return repoManagerDatabaseFromApp(app, authProvider, url, undefined);
97+
return repoManagerDatabaseFromApp(
98+
app,
99+
authProvider,
100+
options?.instanceIdentifier, // url
101+
undefined
102+
);
94103
},
95104
ComponentType.PUBLIC
96105
)

packages/database/index.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ import * as TEST_ACCESS from './src/api/test_access';
3030
import { isNodeSdk } from '@firebase/util';
3131
import * as types from '@firebase/database-types';
3232
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';
3438

3539
import { name, version } from './package.json';
3640

@@ -44,13 +48,18 @@ export function registerDatabase(instance: FirebaseNamespace) {
4448
const namespace = (instance as _FirebaseNamespace).INTERNAL.registerComponent(
4549
new Component(
4650
'database',
47-
(container, { instanceIdentifier: url }) => {
51+
(container, options: InstanceFactoryOptions) => {
4852
/* Dependencies */
4953
// getImmediate for FirebaseApp will always succeed
5054
const app = container.getProvider('app').getImmediate();
5155
const authProvider = container.getProvider('auth-internal');
5256

53-
return repoManagerDatabaseFromApp(app, authProvider, url, undefined);
57+
return repoManagerDatabaseFromApp(
58+
app,
59+
authProvider,
60+
options?.instanceIdentifier, // url
61+
undefined
62+
);
5463
},
5564
ComponentType.PUBLIC
5665
)

packages/functions/src/config.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export function registerFunctions(
4040

4141
function factory(
4242
container: ComponentContainer,
43-
{ instanceIdentifier: regionOrCustomDomain }: InstanceFactoryOptions
43+
options?: InstanceFactoryOptions
4444
): Service {
4545
// Dependencies
4646
const app = container.getProvider('app').getImmediate();
@@ -52,7 +52,8 @@ export function registerFunctions(
5252
app,
5353
authProvider,
5454
messagingProvider,
55-
regionOrCustomDomain,
55+
// regionOrCustomDomain
56+
options?.instanceIdentifier,
5657
fetchImpl
5758
);
5859
}

packages/remote-config/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export function registerRemoteConfig(
6060

6161
function remoteConfigFactory(
6262
container: ComponentContainer,
63-
{ instanceIdentifier: namespace }: InstanceFactoryOptions
63+
options?: InstanceFactoryOptions
6464
): RemoteConfig {
6565
/* Dependencies */
6666
// getImmediate for FirebaseApp will always succeed
@@ -84,7 +84,7 @@ export function registerRemoteConfig(
8484
if (!appId) {
8585
throw ERROR_FACTORY.create(ErrorCode.REGISTRATION_APP_ID);
8686
}
87-
namespace = namespace || 'firebase';
87+
const namespace = options?.instanceIdentifier || 'firebase';
8888

8989
const storage = new Storage(appId, app.name, namespace);
9090
const storageCache = new StorageCache(storage);

packages/storage/compat/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const STORAGE_TYPE = 'storage';
4141

4242
function factory(
4343
container: ComponentContainer,
44-
{ instanceIdentifier: url }: InstanceFactoryOptions
44+
options?: InstanceFactoryOptions
4545
): types.FirebaseStorage {
4646
// Dependencies
4747
// TODO: This should eventually be 'app-compat'
@@ -56,7 +56,7 @@ function factory(
5656
app,
5757
authProvider,
5858
new XhrIoPool(),
59-
url,
59+
options?.instanceIdentifier, // url
6060
firebase.SDK_VERSION
6161
)
6262
);

packages/storage/exp/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ export function getStorage(
298298

299299
function factory(
300300
container: ComponentContainer,
301-
{ instanceIdentifier: url }: InstanceFactoryOptions
301+
options?: InstanceFactoryOptions
302302
): StorageService {
303303
const app = container.getProvider('app-exp').getImmediate();
304304
const authProvider = container.getProvider('auth-internal');
@@ -307,7 +307,7 @@ function factory(
307307
app,
308308
authProvider,
309309
new XhrIoPool(),
310-
url,
310+
options?.instanceIdentifier, // url
311311
SDK_VERSION
312312
);
313313
}

0 commit comments

Comments
 (0)