Skip to content

Commit 6174061

Browse files
Merge
2 parents 5648cde + 338dbfa commit 6174061

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+2996
-4697
lines changed

common/api-review/app-exp.api.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ export function _registerComponent(component: Component): boolean;
5858
// @public
5959
export function registerVersion(libraryKeyOrName: string, version: string, variant?: string): void;
6060

61+
// @internal (undocumented)
62+
export function _removeServiceInstance<T extends Name>(app: FirebaseApp, name: T, instanceIdentifier?: string): void;
63+
6164
// @public
6265
export const SDK_VERSION: string;
6366

integration/browserify/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"test:ci": "node ../../scripts/run_tests_in_ci.js"
99
},
1010
"dependencies": {
11-
"firebase": "7.15.1"
11+
"firebase": "7.15.2"
1212
},
1313
"devDependencies": {
1414
"@babel/core": "7.9.6",

integration/firebase-typings/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"test:ci": "node ../../scripts/run_tests_in_ci.js"
88
},
99
"dependencies": {
10-
"firebase": "7.15.1"
10+
"firebase": "7.15.2"
1111
},
1212
"devDependencies": {
1313
"typescript": "3.8.3"

integration/messaging/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"test:manual": "mocha --exit"
99
},
1010
"dependencies": {
11-
"firebase": "7.15.1"
11+
"firebase": "7.15.2"
1212
},
1313
"devDependencies": {
1414
"chai": "4.2.0",

integration/typescript/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"test:ci": "node ../../scripts/run_tests_in_ci.js"
88
},
99
"dependencies": {
10-
"firebase": "7.15.1"
10+
"firebase": "7.15.2"
1111
},
1212
"devDependencies": {
1313
"@babel/core": "7.9.6",

integration/webpack/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"test:ci": "node ../../scripts/run_tests_in_ci.js"
99
},
1010
"dependencies": {
11-
"firebase": "7.15.1"
11+
"firebase": "7.15.2"
1212
},
1313
"devDependencies": {
1414
"@babel/core": "7.9.6",

packages-exp/app-exp/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@
3333
},
3434
"dependencies": {
3535
"@firebase/app-types-exp": "0.0.800",
36-
"@firebase/util": "0.2.48",
36+
"@firebase/util": "0.2.49",
3737
"@firebase/logger": "0.2.5",
38-
"@firebase/component": "0.1.13",
38+
"@firebase/component": "0.1.14",
3939
"tslib": "^1.11.1"
4040
},
4141
"license": "Apache-2.0",

packages-exp/app-exp/src/constants.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
* limitations under the License.
1616
*/
1717

18-
export const DEFAULT_ENTRY_NAME = '[DEFAULT]';
1918
import { name as appName } from '../package.json';
2019
import { name as analyticsName } from '../../../packages/analytics/package.json';
2120
import { name as authName } from '../../../packages/auth/package.json';
@@ -29,6 +28,8 @@ import { name as storageName } from '../../../packages/storage/package.json';
2928
import { name as firestoreName } from '../../../packages/firestore/package.json';
3029
import { name as packageName } from '../../../packages/firebase/package.json';
3130

31+
export const DEFAULT_ENTRY_NAME = '[DEFAULT]';
32+
3233
export const PLATFORM_LOG_STRING = {
3334
[appName]: 'fire-core',
3435
[analyticsName]: 'fire-analytics',

packages-exp/app-exp/src/internal.test.ts

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ import {
2525
_addOrOverwriteComponent,
2626
_registerComponent,
2727
_components,
28-
_clearComponents
28+
_clearComponents,
29+
_getProvider,
30+
_removeServiceInstance
2931
} from './internal';
3032
import { _FirebaseAppInternal } from '@firebase/app-types-exp';
3133

@@ -40,9 +42,10 @@ describe('Internal API tests', () => {
4042
for (const app of getApps()) {
4143
deleteApp(app).catch(() => {});
4244
}
45+
_clearComponents();
4346
});
4447

45-
describe('addComponent', () => {
48+
describe('_addComponent', () => {
4649
it('registers component with App', () => {
4750
const app = initializeApp({}) as _FirebaseAppInternal;
4851
const testComp = createTestComponent('test');
@@ -67,7 +70,7 @@ describe('Internal API tests', () => {
6770
});
6871
});
6972

70-
describe('addOrOverwriteComponent', () => {
73+
describe('_addOrOverwriteComponent', () => {
7174
it('registers component with App', () => {
7275
const app = initializeApp({}) as _FirebaseAppInternal;
7376
const testComp = createTestComponent('test');
@@ -93,11 +96,7 @@ describe('Internal API tests', () => {
9396
});
9497
});
9598

96-
describe('registerComponent', () => {
97-
afterEach(() => {
98-
_clearComponents();
99-
});
100-
99+
describe('_registerComponent', () => {
101100
it('caches a component and registers it with all Apps', () => {
102101
const app1 = initializeApp({}) as _FirebaseAppInternal;
103102
const app2 = initializeApp({}, 'app2') as _FirebaseAppInternal;
@@ -130,4 +129,33 @@ describe('Internal API tests', () => {
130129
expect(_components.get('test')).to.equal(testComp1);
131130
});
132131
});
132+
133+
describe('_getProvider', () => {
134+
it('gets provider for a service', () => {
135+
const app1 = initializeApp({}) as _FirebaseAppInternal;
136+
const testComp = createTestComponent('test');
137+
_registerComponent(testComp);
138+
139+
const provider = _getProvider(app1, 'test');
140+
expect(provider.getComponent()).to.equal(testComp);
141+
});
142+
});
143+
144+
describe('_removeServiceInstance', () => {
145+
it('removes a service instance', () => {
146+
const app1 = initializeApp({}) as _FirebaseAppInternal;
147+
const testComp = createTestComponent('test');
148+
_registerComponent(testComp);
149+
const provider = app1.container.getProvider('test');
150+
151+
// instantiate a service instance
152+
const instance1 = provider.getImmediate();
153+
_removeServiceInstance(app1, 'test');
154+
155+
// should get a new instance since the previous instance has been removed
156+
const instance2 = provider.getImmediate();
157+
158+
expect(instance1).to.not.equal(instance2);
159+
});
160+
});
133161
});

packages-exp/app-exp/src/internal.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import { _FirebaseAppInternal, FirebaseApp } from '@firebase/app-types-exp';
1919
import { Component, Provider, Name } from '@firebase/component';
2020
import { logger } from './logger';
21+
import { DEFAULT_ENTRY_NAME } from './constants';
2122

2223
/**
2324
* @internal
@@ -102,6 +103,22 @@ export function _getProvider<T extends Name>(
102103
return (app as _FirebaseAppInternal).container.getProvider(name);
103104
}
104105

106+
/**
107+
*
108+
* @param app - FirebaseApp instance
109+
* @param name - service name
110+
* @param instanceIdentifier - service instance identifier in case the service supports multiple instances
111+
*
112+
* @internal
113+
*/
114+
export function _removeServiceInstance<T extends Name>(
115+
app: FirebaseApp,
116+
name: T,
117+
instanceIdentifier: string = DEFAULT_ENTRY_NAME
118+
): void {
119+
_getProvider(app, name).clearInstance(instanceIdentifier);
120+
}
121+
105122
/**
106123
* Test only
107124
*

packages-exp/app-exp/test/util.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { FirebaseService } from '@firebase/app-types/private';
19-
import { FirebaseApp } from '@firebase/app-types';
18+
import { FirebaseApp, _FirebaseService } from '@firebase/app-types-exp';
2019
import { ComponentType, Component } from '@firebase/component';
2120

22-
export class TestService implements FirebaseService {
21+
export class TestService implements _FirebaseService {
2322
constructor(private app_: FirebaseApp, public instanceIdentifier?: string) {}
2423

2524
get app(): FirebaseApp {
@@ -41,7 +40,8 @@ export function createTestComponent(
4140
const component = new Component(
4241
// eslint-disable-next-line @typescript-eslint/no-explicit-any
4342
name as any,
44-
container => new TestService(container.getProvider('app').getImmediate()),
43+
container =>
44+
new TestService(container.getProvider('app-exp').getImmediate()),
4545
type
4646
);
4747
component.setMultipleInstances(multiInstances);

packages-exp/app-types-exp/index.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,15 @@ export interface _FirebaseService {
116116
delete(): Promise<void>;
117117
}
118118

119+
export interface VersionService {
120+
library: string;
121+
version: string;
122+
}
123+
119124
declare module '@firebase/component' {
120125
interface NameServiceMapping {
121126
'app-exp': FirebaseApp;
127+
'app-version': VersionService;
122128
'platform-logger': PlatformLoggerService;
123129
}
124130
}

packages/analytics/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@firebase/analytics",
3-
"version": "0.3.6",
3+
"version": "0.3.7",
44
"description": "A analytics package for new firebase packages",
55
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
66
"main": "dist/index.cjs.js",
@@ -27,10 +27,10 @@
2727
},
2828
"dependencies": {
2929
"@firebase/analytics-types": "0.3.1",
30-
"@firebase/installations": "0.4.11",
30+
"@firebase/installations": "0.4.12",
3131
"@firebase/logger": "0.2.5",
32-
"@firebase/util": "0.2.48",
33-
"@firebase/component": "0.1.13",
32+
"@firebase/util": "0.2.49",
33+
"@firebase/component": "0.1.14",
3434
"tslib": "^1.11.1"
3535
},
3636
"license": "Apache-2.0",

packages/app/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@firebase/app",
3-
"version": "0.6.5",
3+
"version": "0.6.6",
44
"description": "The primary entrypoint to the Firebase JS SDK",
55
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
66
"main": "dist/index.node.cjs.js",
@@ -30,9 +30,9 @@
3030
"license": "Apache-2.0",
3131
"dependencies": {
3232
"@firebase/app-types": "0.6.1",
33-
"@firebase/util": "0.2.48",
33+
"@firebase/util": "0.2.49",
3434
"@firebase/logger": "0.2.5",
35-
"@firebase/component": "0.1.13",
35+
"@firebase/component": "0.1.14",
3636
"tslib": "^1.11.1",
3737
"dom-storage": "2.1.0",
3838
"xmlhttprequest": "1.8.0"

0 commit comments

Comments
 (0)