Skip to content

Updating the dependencies on Firebase products to use the exp packages #3799

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 0 additions & 83 deletions packages-exp/performance-exp/index.ts

This file was deleted.

8 changes: 4 additions & 4 deletions packages-exp/performance-exp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@
"prettier": "prettier --write '{src,test}/**/*.{js,ts}'"
},
"peerDependencies": {
"@firebase/app": "0.x",
"@firebase/app-types": "0.x"
"@firebase/app-exp": "0.x",
"@firebase/app-types-exp": "0.x"
},
"dependencies": {
"@firebase/logger": "0.2.6",
"@firebase/installations": "0.4.17",
"@firebase/installations-exp": "0.0.800",
"@firebase/util": "0.3.2",
"@firebase/performance-types-exp": "0.0.800",
"@firebase/component": "0.1.19",
"tslib": "^1.11.1"
},
"license": "Apache-2.0",
"devDependencies": {
"@firebase/app": "0.6.11",
"@firebase/app-exp": "0.0.800",
"rollup": "2.26.7",
"rollup-plugin-json": "4.0.0",
"rollup-plugin-typescript2": "0.27.2",
Expand Down
4 changes: 2 additions & 2 deletions packages-exp/performance-exp/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const es5BuildPlugins = [typescriptPlugin({ typescript }), json()];

const es5Builds = [
{
input: 'index.ts',
input: 'src/index.ts',
output: [
{ file: pkg.main, format: 'cjs', sourcemap: true },
{ file: pkg.module, format: 'es', sourcemap: true }
Expand Down Expand Up @@ -59,7 +59,7 @@ const es2017BuildPlugins = [

const es2017Builds = [
{
input: 'index.ts',
input: 'src/index.ts',
output: [{ file: pkg.esm2017, format: 'es', sourcemap: true }],
plugins: es2017BuildPlugins,
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
Expand Down
2 changes: 1 addition & 1 deletion packages-exp/performance-exp/src/controllers/perf.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { stub } from 'sinon';
import { PerformanceController } from '../controllers/perf';
import { Trace } from '../resources/trace';
import { Api, setupApi } from '../services/api_service';
import { FirebaseApp } from '@firebase/app-types';
import { FirebaseApp } from '@firebase/app-types-exp';
import * as initializationService from '../services/initialization_service';
import * as FirebaseUtil from '@firebase/util';
import { consoleLogger } from '../utils/console_logger';
Expand Down
5 changes: 3 additions & 2 deletions packages-exp/performance-exp/src/controllers/perf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ import { setupOobResources } from '../services/oob_resources_service';
import { SettingsService } from '../services/settings_service';
import { getInitializationPromise } from '../services/initialization_service';
import { Api } from '../services/api_service';
import { FirebaseApp } from '@firebase/app-types';
import { FirebasePerformance } from '@firebase/performance-types';
import { FirebaseApp } from '@firebase/app-types-exp';
import { FirebasePerformance } from '@firebase/performance-types-exp';
import { setupTransportService } from '../services/transport_service';
import { validateIndexedDBOpenable } from '@firebase/util';
import { consoleLogger } from '../utils/console_logger';

export class PerformanceController implements FirebasePerformance {
constructor(readonly app: FirebaseApp) {
if (Api.getInstance().requiredApisAvailable()) {
Expand Down
73 changes: 73 additions & 0 deletions packages-exp/performance-exp/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { FirebaseApp } from '@firebase/app-types-exp';
import { FirebasePerformance } from '@firebase/performance-types-exp';
import { ERROR_FACTORY, ErrorCode } from './utils/errors';
import { setupApi } from './services/api_service';
import { PerformanceController } from './controllers/perf';
import {
_registerComponent,
_getProvider,
registerVersion
} from '@firebase/app-exp';
import {
InstanceFactory,
ComponentContainer,
Component,
ComponentType
} from '@firebase/component';
import { SettingsService } from './services/settings_service';
import { name, version } from '../package.json';

const DEFAULT_ENTRY_NAME = '[DEFAULT]';

export function getPerformance(app: FirebaseApp): FirebasePerformance {
const provider = _getProvider(app, 'performance-exp');
const perfInstance = provider.getImmediate() as PerformanceController;
return perfInstance;
}

const factory: InstanceFactory<'performance-exp'> = (
container: ComponentContainer
) => {
// Dependencies
const app = container.getProvider('app-exp').getImmediate();
const installations = container
.getProvider('installations-exp-internal')
.getImmediate();

if (app.name !== DEFAULT_ENTRY_NAME) {
throw ERROR_FACTORY.create(ErrorCode.FB_NOT_DEFAULT);
}
if (typeof window === 'undefined') {
throw ERROR_FACTORY.create(ErrorCode.NO_WINDOW);
}
setupApi(window);
SettingsService.getInstance().firebaseAppInstance = app;
SettingsService.getInstance().installationsService = installations;
return new PerformanceController(app);
};

export function registerPerformance(): void {
_registerComponent(
new Component('performance-exp', factory, ComponentType.PUBLIC)
);
}

registerPerformance();
registerVersion(name, version);
2 changes: 1 addition & 1 deletion packages-exp/performance-exp/src/resources/trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
isValidMetricName,
convertMetricValueToInteger
} from '../utils/metric_utils';
import { PerformanceTrace } from '@firebase/performance-types';
import { PerformanceTrace } from '@firebase/performance-types-exp';

const enum TraceState {
UNINITIALIZED = 1,
Expand Down
4 changes: 2 additions & 2 deletions packages-exp/performance-exp/src/services/iid_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
getAuthTokenPromise
} from './iid_service';
import '../../test/setup';
import { FirebaseInstallations } from '@firebase/installations-types';
import { _FirebaseInstallationsInternal } from '@firebase/installations-types-exp';

describe('Firebase Perofmrance > iid_service', () => {
const IID = 'fid';
Expand All @@ -37,7 +37,7 @@ describe('Firebase Perofmrance > iid_service', () => {
SettingsService.prototype.installationsService = ({
getId,
getToken
} as unknown) as FirebaseInstallations;
} as unknown) as _FirebaseInstallationsInternal;
});

describe('getIidPromise', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
} from './initialization_service';
import { setupApi } from './api_service';
import { SettingsService } from './settings_service';
import { FirebaseApp } from '@firebase/app-types';
import { FirebaseApp } from '@firebase/app-types-exp';
import '../../test/setup';

describe('Firebase Perofmrance > initialization_service', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import * as iidService from './iid_service';
import { expect } from 'chai';
import { Api, setupApi } from './api_service';
import { SettingsService } from './settings_service';
import { FirebaseApp } from '@firebase/app-types';
import { FirebaseApp } from '@firebase/app-types-exp';
import * as initializationService from './initialization_service';
import { SDK_VERSION } from '../constants';
import * as attributeUtils from '../utils/attributes_utils';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { CONFIG_EXPIRY_LOCAL_STORAGE_KEY } from '../constants';
import { setupApi, Api } from './api_service';
import * as iidService from './iid_service';
import { getConfig } from './remote_config_service';
import { FirebaseApp } from '@firebase/app-types';
import { FirebaseApp } from '@firebase/app-types-exp';
import '../../test/setup';

describe('Performance Monitoring > remote_config_service', () => {
Expand Down
6 changes: 3 additions & 3 deletions packages-exp/performance-exp/src/services/settings_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
* limitations under the License.
*/

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

let settingsServiceInstance: SettingsService | undefined;
Expand Down Expand Up @@ -59,7 +59,7 @@ export class SettingsService {

firebaseAppInstance!: FirebaseApp;

installationsService!: FirebaseInstallations;
installationsService!: _FirebaseInstallationsInternal;

getAppId(): string {
const appId =
Expand Down
2 changes: 1 addition & 1 deletion packages-exp/performance-types-exp/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,6 @@ export interface PerformanceTrace {

declare module '@firebase/component' {
interface NameServiceMapping {
'performance': FirebasePerformance;
'performance-exp': FirebasePerformance;
}
}