Skip to content

Commit 3a6e5ff

Browse files
authored
Updating the dependencies on Firebase products to use the exp packages (#3799)
* Updating the dependencies for performance-exp to use the exp packages for for Firebase deps * Moving index.ts under scr/
1 parent 9b6b06a commit 3a6e5ff

File tree

13 files changed

+93
-102
lines changed

13 files changed

+93
-102
lines changed

packages-exp/performance-exp/index.ts

Lines changed: 0 additions & 83 deletions
This file was deleted.

packages-exp/performance-exp/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,20 @@
2222
"prettier": "prettier --write '{src,test}/**/*.{js,ts}'"
2323
},
2424
"peerDependencies": {
25-
"@firebase/app": "0.x",
26-
"@firebase/app-types": "0.x"
25+
"@firebase/app-exp": "0.x",
26+
"@firebase/app-types-exp": "0.x"
2727
},
2828
"dependencies": {
2929
"@firebase/logger": "0.2.6",
30-
"@firebase/installations": "0.4.17",
30+
"@firebase/installations-exp": "0.0.800",
3131
"@firebase/util": "0.3.2",
3232
"@firebase/performance-types-exp": "0.0.800",
3333
"@firebase/component": "0.1.19",
3434
"tslib": "^1.11.1"
3535
},
3636
"license": "Apache-2.0",
3737
"devDependencies": {
38-
"@firebase/app": "0.6.11",
38+
"@firebase/app-exp": "0.0.800",
3939
"rollup": "2.26.7",
4040
"rollup-plugin-json": "4.0.0",
4141
"rollup-plugin-typescript2": "0.27.2",

packages-exp/performance-exp/rollup.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const es5BuildPlugins = [typescriptPlugin({ typescript }), json()];
3131

3232
const es5Builds = [
3333
{
34-
input: 'index.ts',
34+
input: 'src/index.ts',
3535
output: [
3636
{ file: pkg.main, format: 'cjs', sourcemap: true },
3737
{ file: pkg.module, format: 'es', sourcemap: true }
@@ -59,7 +59,7 @@ const es2017BuildPlugins = [
5959

6060
const es2017Builds = [
6161
{
62-
input: 'index.ts',
62+
input: 'src/index.ts',
6363
output: [{ file: pkg.esm2017, format: 'es', sourcemap: true }],
6464
plugins: es2017BuildPlugins,
6565
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))

packages-exp/performance-exp/src/controllers/perf.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { stub } from 'sinon';
2020
import { PerformanceController } from '../controllers/perf';
2121
import { Trace } from '../resources/trace';
2222
import { Api, setupApi } from '../services/api_service';
23-
import { FirebaseApp } from '@firebase/app-types';
23+
import { FirebaseApp } from '@firebase/app-types-exp';
2424
import * as initializationService from '../services/initialization_service';
2525
import * as FirebaseUtil from '@firebase/util';
2626
import { consoleLogger } from '../utils/console_logger';

packages-exp/performance-exp/src/controllers/perf.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ import { setupOobResources } from '../services/oob_resources_service';
1919
import { SettingsService } from '../services/settings_service';
2020
import { getInitializationPromise } from '../services/initialization_service';
2121
import { Api } from '../services/api_service';
22-
import { FirebaseApp } from '@firebase/app-types';
23-
import { FirebasePerformance } from '@firebase/performance-types';
22+
import { FirebaseApp } from '@firebase/app-types-exp';
23+
import { FirebasePerformance } from '@firebase/performance-types-exp';
2424
import { setupTransportService } from '../services/transport_service';
2525
import { validateIndexedDBOpenable } from '@firebase/util';
2626
import { consoleLogger } from '../utils/console_logger';
27+
2728
export class PerformanceController implements FirebasePerformance {
2829
constructor(readonly app: FirebaseApp) {
2930
if (Api.getInstance().requiredApisAvailable()) {
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/**
2+
* @license
3+
* Copyright 2020 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
import { FirebaseApp } from '@firebase/app-types-exp';
19+
import { FirebasePerformance } from '@firebase/performance-types-exp';
20+
import { ERROR_FACTORY, ErrorCode } from './utils/errors';
21+
import { setupApi } from './services/api_service';
22+
import { PerformanceController } from './controllers/perf';
23+
import {
24+
_registerComponent,
25+
_getProvider,
26+
registerVersion
27+
} from '@firebase/app-exp';
28+
import {
29+
InstanceFactory,
30+
ComponentContainer,
31+
Component,
32+
ComponentType
33+
} from '@firebase/component';
34+
import { SettingsService } from './services/settings_service';
35+
import { name, version } from '../package.json';
36+
37+
const DEFAULT_ENTRY_NAME = '[DEFAULT]';
38+
39+
export function getPerformance(app: FirebaseApp): FirebasePerformance {
40+
const provider = _getProvider(app, 'performance-exp');
41+
const perfInstance = provider.getImmediate() as PerformanceController;
42+
return perfInstance;
43+
}
44+
45+
const factory: InstanceFactory<'performance-exp'> = (
46+
container: ComponentContainer
47+
) => {
48+
// Dependencies
49+
const app = container.getProvider('app-exp').getImmediate();
50+
const installations = container
51+
.getProvider('installations-exp-internal')
52+
.getImmediate();
53+
54+
if (app.name !== DEFAULT_ENTRY_NAME) {
55+
throw ERROR_FACTORY.create(ErrorCode.FB_NOT_DEFAULT);
56+
}
57+
if (typeof window === 'undefined') {
58+
throw ERROR_FACTORY.create(ErrorCode.NO_WINDOW);
59+
}
60+
setupApi(window);
61+
SettingsService.getInstance().firebaseAppInstance = app;
62+
SettingsService.getInstance().installationsService = installations;
63+
return new PerformanceController(app);
64+
};
65+
66+
export function registerPerformance(): void {
67+
_registerComponent(
68+
new Component('performance-exp', factory, ComponentType.PUBLIC)
69+
);
70+
}
71+
72+
registerPerformance();
73+
registerVersion(name, version);

packages-exp/performance-exp/src/resources/trace.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import {
3535
isValidMetricName,
3636
convertMetricValueToInteger
3737
} from '../utils/metric_utils';
38-
import { PerformanceTrace } from '@firebase/performance-types';
38+
import { PerformanceTrace } from '@firebase/performance-types-exp';
3939

4040
const enum TraceState {
4141
UNINITIALIZED = 1,

packages-exp/performance-exp/src/services/iid_service.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {
2525
getAuthTokenPromise
2626
} from './iid_service';
2727
import '../../test/setup';
28-
import { FirebaseInstallations } from '@firebase/installations-types';
28+
import { _FirebaseInstallationsInternal } from '@firebase/installations-types-exp';
2929

3030
describe('Firebase Perofmrance > iid_service', () => {
3131
const IID = 'fid';
@@ -37,7 +37,7 @@ describe('Firebase Perofmrance > iid_service', () => {
3737
SettingsService.prototype.installationsService = ({
3838
getId,
3939
getToken
40-
} as unknown) as FirebaseInstallations;
40+
} as unknown) as _FirebaseInstallationsInternal;
4141
});
4242

4343
describe('getIidPromise', () => {

packages-exp/performance-exp/src/services/initialization_service.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {
2323
} from './initialization_service';
2424
import { setupApi } from './api_service';
2525
import { SettingsService } from './settings_service';
26-
import { FirebaseApp } from '@firebase/app-types';
26+
import { FirebaseApp } from '@firebase/app-types-exp';
2727
import '../../test/setup';
2828

2929
describe('Firebase Perofmrance > initialization_service', () => {

packages-exp/performance-exp/src/services/perf_logger.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import * as iidService from './iid_service';
2222
import { expect } from 'chai';
2323
import { Api, setupApi } from './api_service';
2424
import { SettingsService } from './settings_service';
25-
import { FirebaseApp } from '@firebase/app-types';
25+
import { FirebaseApp } from '@firebase/app-types-exp';
2626
import * as initializationService from './initialization_service';
2727
import { SDK_VERSION } from '../constants';
2828
import * as attributeUtils from '../utils/attributes_utils';

packages-exp/performance-exp/src/services/remote_config_service.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { CONFIG_EXPIRY_LOCAL_STORAGE_KEY } from '../constants';
2121
import { setupApi, Api } from './api_service';
2222
import * as iidService from './iid_service';
2323
import { getConfig } from './remote_config_service';
24-
import { FirebaseApp } from '@firebase/app-types';
24+
import { FirebaseApp } from '@firebase/app-types-exp';
2525
import '../../test/setup';
2626

2727
describe('Performance Monitoring > remote_config_service', () => {

packages-exp/performance-exp/src/services/settings_service.ts

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

18-
import { FirebaseApp } from '@firebase/app-types';
18+
import { FirebaseApp } from '@firebase/app-types-exp';
1919
import { ERROR_FACTORY, ErrorCode } from '../utils/errors';
20-
import { FirebaseInstallations } from '@firebase/installations-types';
20+
import { _FirebaseInstallationsInternal } from '@firebase/installations-types-exp';
2121
import { mergeStrings } from '../utils/string_merger';
2222

2323
let settingsServiceInstance: SettingsService | undefined;
@@ -59,7 +59,7 @@ export class SettingsService {
5959

6060
firebaseAppInstance!: FirebaseApp;
6161

62-
installationsService!: FirebaseInstallations;
62+
installationsService!: _FirebaseInstallationsInternal;
6363

6464
getAppId(): string {
6565
const appId =

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,6 @@ export interface PerformanceTrace {
114114

115115
declare module '@firebase/component' {
116116
interface NameServiceMapping {
117-
'performance': FirebasePerformance;
117+
'performance-exp': FirebasePerformance;
118118
}
119119
}

0 commit comments

Comments
 (0)