Skip to content

Commit c3c3f49

Browse files
committed
Revert "Revert non functions-compat changes"
This reverts commit 60e8a8e.
1 parent 60e8a8e commit c3c3f49

File tree

12 files changed

+30
-60
lines changed

12 files changed

+30
-60
lines changed

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

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

32-
const DEFAULT_REGION = 'us-central1';
33-
3432
declare module '@firebase/component' {
3533
interface NameServiceMapping {
3634
'app-compat': FirebaseApp;
@@ -41,15 +39,14 @@ declare module '@firebase/component' {
4139

4240
const factory: InstanceFactory<'functions-compat'> = (
4341
container: ComponentContainer,
44-
options?: InstanceFactoryOptions
42+
{ instanceIdentifier: regionOrCustomDomain }: InstanceFactoryOptions
4543
) => {
4644
// Dependencies
4745
const app = container.getProvider('app-compat').getImmediate();
4846
const functionsServiceExp = container
4947
.getProvider('functions-exp')
5048
.getImmediate({
51-
// This value is used as regionOrCustomDomain
52-
identifier: options?.instanceIdentifier ?? DEFAULT_REGION
49+
identifier: regionOrCustomDomain
5350
});
5451

5552
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,15 +21,16 @@ import {
2121
Component,
2222
ComponentType,
2323
ComponentContainer,
24-
InstanceFactory,
25-
InstanceFactoryOptions
24+
InstanceFactory
2625
} from '@firebase/component';
2726
import { FUNCTIONS_TYPE } from './constants';
2827

28+
export const DEFAULT_REGION = 'us-central1';
29+
2930
export function registerFunctions(fetchImpl: typeof fetch): void {
3031
const factory: InstanceFactory<'functions'> = (
3132
container: ComponentContainer,
32-
options?: InstanceFactoryOptions
33+
{ instanceIdentifier: regionOrCustomDomain }
3334
) => {
3435
// Dependencies
3536
const app = container.getProvider('app-exp').getImmediate();
@@ -41,8 +42,7 @@ export function registerFunctions(fetchImpl: typeof fetch): void {
4142
app,
4243
authProvider,
4344
messagingProvider,
44-
// regionOrCustomDomain
45-
options?.instanceIdentifier,
45+
regionOrCustomDomain,
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-
instanceFactoryOptions?: { options?: PerformanceSettings }
94+
{ options: settings }: { 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(instanceFactoryOptions.options);
110+
perfInstance._init(settings);
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-
options?: InstanceFactoryOptions
52+
{ instanceIdentifier: namespace }: 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: options?.instanceIdentifier // namespace
57+
identifier: 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-
options?: InstanceFactoryOptions
57+
{ instanceIdentifier: namespace }: 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-
const namespace = options?.instanceIdentifier || 'firebase';
83+
namespace = namespace || 'firebase';
8484

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

packages/database/exp/index.ts

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

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

2622
import { version } from '../package.json';
2723
import { FirebaseDatabase } from '../src/exp/Database';
@@ -39,14 +35,10 @@ function registerDatabase(): void {
3935
_registerComponent(
4036
new Component(
4137
'database-exp',
42-
(container, options?: InstanceFactoryOptions) => {
38+
(container, { instanceIdentifier: url }) => {
4339
const app = container.getProvider('app-exp').getImmediate()!;
4440
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);
5042
},
5143
ComponentType.PUBLIC
5244
).setMultipleInstances(true)

packages/database/index.node.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,7 @@ 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 {
34-
Component,
35-
ComponentType,
36-
InstanceFactoryOptions
37-
} from '@firebase/component';
33+
import { Component, ComponentType } from '@firebase/component';
3834
import { FirebaseAuthInternal } from '@firebase/auth-interop-types';
3935

4036
import { name, version } from './package.json';
@@ -88,18 +84,13 @@ export function registerDatabase(instance: FirebaseNamespace) {
8884
const namespace = (instance as _FirebaseNamespace).INTERNAL.registerComponent(
8985
new Component(
9086
'database',
91-
(container, options?: InstanceFactoryOptions) => {
87+
(container, { instanceIdentifier: url }) => {
9288
/* Dependencies */
9389
// getImmediate for FirebaseApp will always succeed
9490
const app = container.getProvider('app').getImmediate();
9591
const authProvider = container.getProvider('auth-internal');
9692

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

packages/database/index.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,7 @@ 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 {
34-
Component,
35-
ComponentType,
36-
InstanceFactoryOptions
37-
} from '@firebase/component';
33+
import { Component, ComponentType } from '@firebase/component';
3834

3935
import { name, version } from './package.json';
4036

@@ -48,18 +44,13 @@ export function registerDatabase(instance: FirebaseNamespace) {
4844
const namespace = (instance as _FirebaseNamespace).INTERNAL.registerComponent(
4945
new Component(
5046
'database',
51-
(container, options: InstanceFactoryOptions) => {
47+
(container, { instanceIdentifier: url }) => {
5248
/* Dependencies */
5349
// getImmediate for FirebaseApp will always succeed
5450
const app = container.getProvider('app').getImmediate();
5551
const authProvider = container.getProvider('auth-internal');
5652

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

packages/functions/src/config.ts

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

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

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-
options?: InstanceFactoryOptions
63+
{ instanceIdentifier: namespace }: 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-
const namespace = options?.instanceIdentifier || 'firebase';
87+
namespace = namespace || '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-
options?: InstanceFactoryOptions
44+
{ instanceIdentifier: url }: 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-
options?.instanceIdentifier, // url
59+
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-
options?: InstanceFactoryOptions
301+
{ instanceIdentifier: url }: 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-
options?.instanceIdentifier, // url
310+
url,
311311
SDK_VERSION
312312
);
313313
}

0 commit comments

Comments
 (0)