Skip to content

Commit adda7a0

Browse files
committed
More cleanup
1 parent ee9aac1 commit adda7a0

File tree

13 files changed

+64
-375
lines changed

13 files changed

+64
-375
lines changed

.npmignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
*.spec.*
22
test-config.*
3-
publish.sh
3+
publish.sh
4+
__ivy_ngcc__/
5+
*.min.js
6+
*.min.js.map
7+
*.__ivy_ngcc_bak

src/analytics/analytics.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { TestBed } from '@angular/core/testing';
22
import { AngularFireModule, FirebaseApp } from '@angular/fire';
3+
import { deleteApp } from 'firebase/app';
34
import { AngularFireAnalytics, AngularFireAnalyticsModule } from '@angular/fire/analytics';
45
import { COMMON_CONFIG } from '../test-config';
56
import { rando } from '../firestore/utils.spec';
@@ -22,7 +23,7 @@ describe('AngularFireAnalytics', () => {
2223
});
2324

2425
afterEach(() => {
25-
app.delete();
26+
deleteApp(app);
2627
});
2728

2829
it('should be exist', () => {

src/auth-guard/auth-guard.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { AngularFireAuthGuard, AngularFireAuthGuardModule } from '@angular/fire/
55
import { Router, RouterModule } from '@angular/router';
66
import { APP_BASE_HREF } from '@angular/common';
77
import { rando } from '../firestore/utils.spec';
8+
import { deleteApp } from 'firebase/app';
89

910
describe('AngularFireAuthGuard', () => {
1011
let app: FirebaseApp;
@@ -29,7 +30,7 @@ describe('AngularFireAuthGuard', () => {
2930
});
3031

3132
afterEach(done => {
32-
app.delete().then(done, done);
33+
deleteApp(app).then(done, done);
3334
});
3435

3536
it('should be injectable', () => {

src/auth/auth.spec.ts

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import firebase from 'firebase/app';
21
import { Observable, Subject } from 'rxjs';
32
import { TestBed } from '@angular/core/testing';
4-
import { AngularFireModule, FIREBASE_APP_NAME, FIREBASE_OPTIONS, FirebaseApp } from '@angular/fire';
5-
import { AngularFireAuth, AngularFireAuthModule } from '@angular/fire/auth';
3+
import { AngularFireModule, FirebaseApp, FIREBASE_APPS } from '@angular/fire';
4+
import { AngularFireAuth, AngularFireAuthModule, AUTH_INSTANCES } from '@angular/fire/auth';
65
import { COMMON_CONFIG } from '../test-config';
76
import { User } from 'firebase/auth';
87
import { rando } from '../firestore/utils.spec';
8+
import { deleteApp } from 'firebase/app';
99

1010
const firebaseUser = {
1111
uid: '12345',
@@ -14,6 +14,7 @@ const firebaseUser = {
1414

1515
describe('AngularFireAuth', () => {
1616
let app: FirebaseApp;
17+
let apps: FirebaseApp[];
1718
let afAuth: AngularFireAuth;
1819
let mockAuthState: Subject<User>;
1920

@@ -26,6 +27,7 @@ describe('AngularFireAuth', () => {
2627
});
2728

2829
app = TestBed.inject(FirebaseApp);
30+
apps = TestBed.inject(FIREBASE_APPS);
2931
afAuth = TestBed.inject(AngularFireAuth);
3032

3133
mockAuthState = new Subject<User>();
@@ -38,7 +40,7 @@ describe('AngularFireAuth', () => {
3840
});
3941

4042
afterEach(() => {
41-
app.delete();
43+
apps.forEach(app => deleteApp(app));
4244
});
4345

4446
describe('Zones', () => {
@@ -120,44 +122,46 @@ describe('AngularFireAuth', () => {
120122

121123
describe('AngularFireAuth with different app', () => {
122124
let app: FirebaseApp;
123-
let afAuth: AngularFireAuth;
125+
let apps: FirebaseApp[];
126+
let authInstances: AngularFireAuth[];
124127
let firebaseAppName: string;
125128

126129
beforeEach(() => {
127130
firebaseAppName = rando();
128131

129132
TestBed.configureTestingModule({
130133
imports: [
131-
AngularFireModule.initializeApp(COMMON_CONFIG, rando()),
132-
AngularFireAuthModule
133-
],
134-
providers: [
135-
{ provide: FIREBASE_APP_NAME, useValue: firebaseAppName },
136-
{ provide: FIREBASE_OPTIONS, useValue: COMMON_CONFIG }
134+
AngularFireModule.initializeApp(COMMON_CONFIG, firebaseAppName ),
135+
AngularFireAuthModule.initializeAuth({ appName: firebaseAppName })
137136
]
138137
});
139138

140139
app = TestBed.inject(FirebaseApp);
141-
afAuth = TestBed.inject(AngularFireAuth);
140+
apps = TestBed.inject(FIREBASE_APPS);
141+
authInstances = TestBed.inject(AUTH_INSTANCES);
142142
});
143143

144144
afterEach(() => {
145-
app.delete();
145+
apps.forEach(app => deleteApp(app));
146146
});
147147

148148
describe('<constructor>', () => {
149149

150150
it('should be an AngularFireAuth type', () => {
151-
expect(afAuth instanceof AngularFireAuth).toEqual(true);
151+
expect(authInstances.length).toBeGreaterThan(0);
152+
authInstances.forEach(afAuth => {
153+
expect(afAuth instanceof AngularFireAuth).toEqual(true);
154+
});
152155
});
153156

154157
it('should have an initialized Firebase app', () => {
155-
expect(afAuth.name).toBeDefined();
158+
authInstances.forEach(afAuth => {
159+
expect(afAuth.name).toBeDefined();
160+
});
156161
});
157162

158-
it('should have an initialized Firebase app instance member', async () => {
159-
const appName = await afAuth.name;
160-
expect(appName).toEqual(firebaseAppName);
163+
it('should have an initialized Firebase app instance member', () => {
164+
expect(authInstances.map(afAuth => afAuth.name).indexOf(firebaseAppName)).toBeGreaterThan(-1);
161165
});
162166
});
163167

src/compat/firebase.app.module.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ import {
33
} from '@angular/core';
44
import firebase from 'firebase/compat/app';
55
import { FirebaseOptions, FirebaseAppConfig } from 'firebase/app';
6+
import { VERSION } from '@angular/fire';
67

78
export const FIREBASE_OPTIONS = new InjectionToken<FirebaseOptions>('angularfire2.app.options');
89
export const FIREBASE_APP_NAME = new InjectionToken<string | undefined>('angularfire2.app.name');
910

10-
export const VERSION = new Version('ANGULARFIRE2_VERSION');
11-
1211
// tslint:disable-next-line:no-empty-interface
1312
export interface FirebaseApp extends firebase.app.App {}
1413

src/core/firebase.app.module.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
1-
import { Inject, InjectionToken, isDevMode, ModuleWithProviders, NgModule, NgZone, Optional, PLATFORM_ID, VERSION as NG_VERSION } from '@angular/core';
1+
import {
2+
Inject,
3+
InjectionToken,
4+
isDevMode,
5+
ModuleWithProviders,
6+
NgModule,
7+
NgZone,
8+
Optional,
9+
PLATFORM_ID,
10+
VERSION as NG_VERSION,
11+
Version
12+
} from '@angular/core';
213
import { FirebaseApp as IFirebaseApp, getApps, getApp, initializeApp, registerVersion, FirebaseOptions } from 'firebase/app';
3-
import { FIREBASE_OPTIONS, FIREBASE_APP_NAME, VERSION } from '@angular/fire/compat';
414
import isEqual from 'lodash.isequal';
515

6-
export { FIREBASE_OPTIONS, FIREBASE_APP_NAME, VERSION };
16+
export const VERSION = new Version('ANGULARFIRE2_VERSION');
717

818
// tslint:disable-next-line:no-empty-interface
919
export interface FirebaseApp extends IFirebaseApp {}

src/database/database.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,10 @@ import { getRef } from './utils';
44
import { createListReference } from './list/create-reference';
55
import { createObjectReference } from './object/create-reference';
66
import {
7-
FIREBASE_APP_NAME,
8-
FIREBASE_OPTIONS,
97
ɵAngularFireSchedulers,
10-
ɵfirebaseAppFactory,
118
ɵkeepUnstableUntilFirstFactory,
9+
FirebaseApp,
1210
} from '@angular/fire';
13-
import { FirebaseOptions } from 'firebase/app';
1411
import { Observable } from 'rxjs';
1512
import { FirebaseDatabase, useDatabaseEmulator, getDatabase } from 'firebase/database';
1613
import { ɵfetchInstance } from '@angular/fire';
@@ -33,8 +30,7 @@ export class AngularFireDatabase {
3330
public readonly keepUnstableUntilFirst: <T>(obs$: Observable<T>) => Observable<T>;
3431

3532
constructor(
36-
@Inject(FIREBASE_OPTIONS) options: FirebaseOptions,
37-
@Optional() @Inject(FIREBASE_APP_NAME) name: string | null | undefined,
33+
app: FirebaseApp,
3834
@Optional() @Inject(URL) databaseURL: string | null,
3935
// tslint:disable-next-line:ban-types
4036
@Inject(PLATFORM_ID) platformId: Object,
@@ -45,7 +41,6 @@ export class AngularFireDatabase {
4541
this.keepUnstableUntilFirst = ɵkeepUnstableUntilFirstFactory(this.schedulers);
4642

4743
const useEmulator: UseEmulatorArguments | null = _useEmulator;
48-
const app = ɵfirebaseAppFactory(options, zone, name);
4944

5045
// TODO(team): Figure out how to get detect potential Authentication instance
5146
// in vNext world

src/firestore/firestore.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,10 @@ import { AngularFirestoreDocument } from './document/document';
1414
import { AngularFirestoreCollection } from './collection/collection';
1515
import { AngularFirestoreCollectionGroup } from './collection-group/collection-group';
1616
import {
17-
FIREBASE_APP_NAME,
18-
FIREBASE_OPTIONS,
1917
ɵAngularFireSchedulers,
20-
ɵfirebaseAppFactory,
2118
ɵkeepUnstableUntilFirstFactory,
2219
FirebaseApp
2320
} from '@angular/fire';
24-
import { FirebaseOptions } from 'firebase/app';
2521
import { isPlatformServer } from '@angular/common';
2622
import { FirebaseFirestore, useFirestoreEmulator, enableIndexedDbPersistence, collection, collectionGroup, doc, initializeFirestore } from 'firebase/firestore';
2723
import { ɵfetchInstance } from '@angular/fire';
@@ -133,8 +129,7 @@ export class AngularFirestore {
133129
* apps and use multiple apps.
134130
*/
135131
constructor(
136-
@Inject(FIREBASE_OPTIONS) options: FirebaseOptions,
137-
@Optional() @Inject(FIREBASE_APP_NAME) name: string | null | undefined,
132+
app: FirebaseApp,
138133
@Optional() @Inject(ENABLE_PERSISTENCE) shouldEnablePersistence: boolean | null,
139134
@Optional() @Inject(SETTINGS) settings: Settings | null,
140135
// tslint:disable-next-line:ban-types
@@ -146,7 +141,6 @@ export class AngularFirestore {
146141
this.schedulers = new ɵAngularFireSchedulers(zone);
147142
this.keepUnstableUntilFirst = ɵkeepUnstableUntilFirstFactory(this.schedulers);
148143

149-
const app = ɵfirebaseAppFactory(options, zone, name);
150144
// if (!firebase.auth && useAuthEmulator) {
151145
// ɵlogAuthEmulatorError();
152146
// }

src/functions/functions.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,13 @@ import { Inject, Injectable, InjectionToken, NgZone, Optional } from '@angular/c
22
import { from, Observable, of } from 'rxjs';
33
import { map, observeOn, shareReplay, switchMap } from 'rxjs/operators';
44
import {
5-
FIREBASE_APP_NAME,
6-
FIREBASE_OPTIONS,
75
ɵAngularFireSchedulers,
8-
ɵfirebaseAppFactory,
96
ɵlazySDKProxy,
107
ɵPromiseProxy,
11-
ɵapplyMixins
8+
ɵapplyMixins,
9+
FirebaseApp,
1210
} from '@angular/fire';
1311
import {
14-
FirebaseAppConfig,
1512
FirebaseOptions } from 'firebase/app';
1613
import { proxyPolyfillCompat } from './base';
1714
import { HttpsCallableOptions, Functions, useFunctionsEmulator, httpsCallable, getFunctions } from 'firebase/functions';
@@ -38,8 +35,7 @@ export class AngularFireFunctions {
3835
public readonly httpsCallable: <T = any, R = any>(name: string, options?: HttpsCallableOptions) => (data: T) => Observable<R>;
3936

4037
constructor(
41-
@Inject(FIREBASE_OPTIONS) options: FirebaseOptions,
42-
@Optional() @Inject(FIREBASE_APP_NAME) name: string | null | undefined,
38+
app: FirebaseApp,
4339
zone: NgZone,
4440
@Optional() @Inject(REGION) region: string | null,
4541
// MARK: Breaking change
@@ -54,8 +50,7 @@ export class AngularFireFunctions {
5450
const functions = of(undefined).pipe(
5551
observeOn(schedulers.outsideAngular),
5652
switchMap(() => import('firebase/functions')),
57-
map(() => ɵfirebaseAppFactory(options, zone, name)),
58-
map(app => ɵfetchInstance(`${app.name}.functions.${region || origin}`, 'AngularFireFunctions', app.name, () => {
53+
map(() => ɵfetchInstance(`${app.name}.functions.${region || origin}`, 'AngularFireFunctions', app.name, () => {
5954
const functions = getFunctions(app, region || undefined);
6055
if (useEmulator) {
6156
const [host, port] = useEmulator;

src/messaging/messaging.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,13 @@ import { FirebaseMessaging, getMessaging, getToken, onMessage, deleteToken, Mess
33
import { concat, EMPTY, Observable, of, throwError } from 'rxjs';
44
import { catchError, defaultIfEmpty, map, mergeMap, observeOn, switchMap, switchMapTo, shareReplay, filter, subscribeOn } from 'rxjs/operators';
55
import {
6-
FIREBASE_APP_NAME,
7-
FIREBASE_OPTIONS,
86
ɵAngularFireSchedulers,
9-
ɵfirebaseAppFactory,
107
ɵlazySDKProxy,
118
ɵPromiseProxy,
12-
ɵapplyMixins
9+
ɵapplyMixins,
10+
FirebaseApp,
1311
} from '@angular/fire';
1412
import {
15-
FirebaseAppConfig,
1613
FirebaseOptions, } from 'firebase/app';
1714
import { isPlatformServer } from '@angular/common';
1815
import { proxyPolyfillCompat } from './base';
@@ -41,8 +38,7 @@ export class AngularFireMessaging {
4138
public readonly deleteToken: (token: string) => Observable<boolean>;
4239

4340
constructor(
44-
@Inject(FIREBASE_OPTIONS) options: FirebaseOptions,
45-
@Optional() @Inject(FIREBASE_APP_NAME) name: string | null | undefined,
41+
app: FirebaseApp,
4642
// tslint:disable-next-line:ban-types
4743
@Inject(PLATFORM_ID) platformId: Object,
4844
zone: NgZone,
@@ -56,8 +52,7 @@ export class AngularFireMessaging {
5652
subscribeOn(schedulers.outsideAngular),
5753
observeOn(schedulers.insideAngular),
5854
switchMap(() => isPlatformServer(platformId) ? EMPTY : import('firebase/messaging')),
59-
map(() => ɵfirebaseAppFactory(options, zone, name)),
60-
switchMap(app => ɵfetchInstance(`${app.name}.messaging`, 'AngularFireMessaging', app.name, async () => {
55+
switchMap(() => ɵfetchInstance(`${app.name}.messaging`, 'AngularFireMessaging', app.name, async () => {
6156
const messaging = getMessaging(app);
6257
// MARK: Breaking change
6358
// Removed: useVapidKey removed?

0 commit comments

Comments
 (0)