Skip to content

Commit 9eca578

Browse files
authored
chore(release): 7.0.2 (#2911)
1 parent 7875df9 commit 9eca578

40 files changed

+932
-311
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
<a name="7.0.2"></a>
2+
# [7.0.2](https://github.com/angular/angularfire2/compare/7.0.1...7.0.2) (2021-08-30)
3+
4+
### Bug fixes
5+
6+
* **types:** `firebase/*` types were not being reexported from the `@angular/fire/*` modules (modular)
7+
18
<a name="7.0.1"></a>
29
# [7.0.1](https://github.com/angular/angularfire2/compare/7.0.0...7.0.1) (2021-08-30)
310

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angular/fire",
3-
"version": "7.0.1",
3+
"version": "7.0.2",
44
"description": "The official Angular library for Firebase.",
55
"private": true,
66
"scripts": {
@@ -93,6 +93,7 @@
9393
"codelyzer": "^6.0.0",
9494
"concurrently": "^2.2.0",
9595
"conventional-changelog-cli": "^1.2.0",
96+
"file-loader": "^6.2.0",
9697
"firebase-functions-test": "^0.2.2",
9798
"globalthis": "^1.0.1",
9899
"gzip-size": "^5.1.1",

sample-compat/firestore-protos.ts

-8
This file was deleted.

sample-compat/server.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ global['XMLHttpRequest'] = require('xhr2');
1414
global['WebSocket'] = require('ws');
1515
/* tslint:enable:no-string-literal */
1616

17-
// include the protos required to bundle firestore
18-
// import 'dir-loader!./firestore-protos';
17+
import '@angular/fire/firestore-protos';
1918

2019
// The Express app is exported so that it can be used by serverless Functions.
2120
export function app() {

sample-compat/src/app/app.module.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ import { UpboatsComponent } from './upboats/upboats.component';
8888
{ provide: REMOTE_CONFIG_DEFAULTS, useValue: { background_color: 'red' } },
8989
{ provide: USE_DEVICE_LANGUAGE, useValue: true },
9090
{ provide: VAPID_KEY, useValue: environment.vapidKey },
91-
{ provide: SERVICE_WORKER, useFactory: () => typeof navigator !== 'undefined' && navigator.serviceWorker?.register('firebase-messaging-sw.js') || undefined },
91+
{ provide: SERVICE_WORKER, useFactory: () => typeof navigator !== 'undefined' && navigator.serviceWorker?.register('firebase-messaging-sw.js', { scope: '__' }) || undefined },
9292
{ provide: APP_VERSION, useValue: '0.0.0' },
9393
{ provide: APP_NAME, useValue: 'Angular' },
9494
],

sample-compat/src/firebase-messaging-sw.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
importScripts('https://www.gstatic.com/firebasejs/9.0.0-20217250818/firebase-app-compat.js');
2-
importScripts('https://www.gstatic.com/firebasejs/9.0.0-20217250818/firebase-messaging-compat.js');
1+
importScripts('https://www.gstatic.com/firebasejs/9.0.1/firebase-app-compat.js');
2+
importScripts('https://www.gstatic.com/firebasejs/9.0.1/firebase-messaging-compat.js');
33

44
firebase.initializeApp({
55
apiKey: 'AIzaSyA7CNE9aHbcSEbt9y03QReJ-Xr0nwKg7Yg',

sample-compat/tsconfig.server.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
},
1111
"files": [
1212
"src/main.server.ts",
13-
"server.ts",
14-
"firestore-protos.ts"
13+
"server.ts"
1514
],
1615
"angularCompilerOptions": {
1716
"entryModule": "./src/app/app.server.module#AppServerModule"

sample-compat/yarn.lock

+105-86
Large diffs are not rendered by default.

sample/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"@types/express": "^4.17.0",
5050
"@types/jasmine": "~3.6.0",
5151
"@types/node": "^12.11.1",
52+
"file-loader": "^6.2.0",
5253
"firebase-tools": "^9.0.0",
5354
"fuzzy": "^0.1.3",
5455
"inquirer": "^6.2.2",
@@ -71,4 +72,4 @@
7172
"resolutions": {
7273
"webpack": "^5.35.0"
7374
}
74-
}
75+
}

sample/server.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,14 @@ import { AppServerModule } from './src/main.server';
88
import { APP_BASE_HREF } from '@angular/common';
99
import { existsSync } from 'fs';
1010

11-
// Polyfills
12-
require('cross-fetch/polyfill');
13-
14-
1511
// Polyfill XMLHttpRequest and WS for Firebase
1612
/* tslint:disable:no-string-literal */
1713
global['XMLHttpRequest'] = require('xhr2');
1814
global['WebSocket'] = require('ws');
1915
/* tslint:enable:no-string-literal */
2016

17+
import '@angular/fire/firestore-protos';
18+
2119
// The Express app is exported so that it can be used by serverless Functions.
2220
export function app(): express.Express {
2321
const server = express();

sample/src/app/app-routing.module.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { NgModule } from '@angular/core';
22
import { RouterModule, Routes } from '@angular/router';
3+
import { HomeComponent } from './home/home.component';
34

4-
const routes: Routes = [];
5+
const routes: Routes = [
6+
{ path: '', component: HomeComponent, outlet: 'primary', pathMatch: 'prefix' },
7+
];
58

69
@NgModule({
710
imports: [RouterModule.forRoot(routes, {

sample/src/app/app.browser.module.ts

+2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ import { AppModule } from './app.module';
88
import { AppComponent } from './app.component';
99
import { ServiceWorkerModule } from '@angular/service-worker';
1010
import { environment } from '../environments/environment';
11+
import { BrowserTransferStateModule } from '@angular/platform-browser';
1112

1213
@NgModule({
1314
imports: [
1415
AppModule,
16+
BrowserTransferStateModule,
1517
provideRemoteConfig(() => getRemoteConfig()),
1618
provideAnalytics(() => getAnalytics()),
1719
provideMessaging(() => getMessaging()),

sample/src/app/app.component.ts

+1-24
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,18 @@
1-
import { ApplicationRef, Component, Optional } from '@angular/core';
2-
import { Auth, authState } from '@angular/fire/auth';
3-
import { Firestore, getDoc, doc, DocumentSnapshot } from '@angular/fire/firestore';
4-
import { DocumentData } from 'rxfire/firestore/lite/interfaces';
1+
import { ApplicationRef, Component } from '@angular/core';
52
import { distinctUntilChanged } from 'rxjs/operators';
6-
import { Messaging, onMessage } from '@angular/fire/messaging';
7-
import { getToken } from '@angular/fire/messaging';
8-
9-
import { environment } from '../environments/environment';
103

114
@Component({
125
selector: 'app-root',
136
template: `
14-
<pre>{{ (myDocData | async)?.data() | json }}</pre>
157
<router-outlet></router-outlet>
168
`,
179
styles: []
1810
})
1911
export class AppComponent {
20-
myDocData: Promise<DocumentSnapshot<DocumentData>>;
2112
title = 'sample';
2213
constructor(
2314
appRef: ApplicationRef,
24-
auth: Auth,
25-
firestore: Firestore,
26-
@Optional() messaging: Messaging,
2715
) {
28-
authState(auth).subscribe(it => console.log('authState', it));
2916
appRef.isStable.pipe(distinctUntilChanged()).subscribe(it => console.log('isStable', it));
30-
this.myDocData = getDoc(doc(firestore, 'animals/NJdGQCv1P92SWsp4nSE7'));
31-
if (messaging) {
32-
navigator.serviceWorker.register('firebase-messaging-sw.js', { type: 'module' }).then(serviceWorkerRegistration => {
33-
getToken(messaging, {
34-
serviceWorkerRegistration,
35-
vapidKey: environment.vapidKey,
36-
}).then(it => console.log(it));
37-
});
38-
onMessage(messaging, it => console.log('onMessage', it));
39-
}
4017
}
4118
}

sample/src/app/app.module.ts

+20-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { NgModule } from '@angular/core';
22
import { BrowserModule } from '@angular/platform-browser';
3-
import { provideFirebaseApp, initializeApp, getApp } from '@angular/fire/app';
3+
import { provideFirebaseApp, initializeApp } from '@angular/fire/app';
44
import { provideAuth, getAuth, connectAuthEmulator } from '@angular/fire/auth';
55
import { getStorage, provideStorage, connectStorageEmulator } from '@angular/fire/storage';
66
import { getDatabase, provideDatabase, connectDatabaseEmulator } from '@angular/fire/database';
@@ -11,11 +11,28 @@ import { FunctionsModule } from '@angular/fire/functions';
1111
import { AppRoutingModule } from './app-routing.module';
1212
import { AppComponent } from './app.component';
1313
import { environment } from '../environments/environment';
14-
14+
import { HomeComponent } from './home/home.component';
15+
import { UpboatsComponent } from './upboats/upboats.component';
16+
import { AuthComponent } from './auth/auth.component';
17+
import { FirestoreComponent } from './firestore/firestore.component';
18+
import { DatabaseComponent } from './database/database.component';
19+
import { FunctionsComponent } from './functions/functions.component';
20+
import { MessagingComponent } from './messaging/messaging.component';
21+
import { RemoteConfigComponent } from './remote-config/remote-config.component';
22+
import { StorageComponent } from './storage/storage.component';
1523

1624
@NgModule({
1725
declarations: [
1826
AppComponent,
27+
HomeComponent,
28+
UpboatsComponent,
29+
AuthComponent,
30+
FirestoreComponent,
31+
DatabaseComponent,
32+
FunctionsComponent,
33+
MessagingComponent,
34+
RemoteConfigComponent,
35+
StorageComponent,
1936
],
2037
imports: [
2138
BrowserModule.withServerTransition({ appId: 'serverApp' }),
@@ -45,16 +62,7 @@ import { environment } from '../environments/environment';
4562
return database;
4663
}),
4764
provideStorage(() => {
48-
// While I've provided two instances this should be the default, since it
49-
// uses the default app
50-
const storage = getStorage(getApp(), 'another-bucket');
51-
if (environment.useEmulators) {
52-
connectStorageEmulator(storage, 'localhost', 9199);
53-
}
54-
return storage;
55-
}),
56-
provideStorage(() => {
57-
const storage = getStorage(getApp('second'));
65+
const storage = getStorage();
5866
if (environment.useEmulators) {
5967
connectStorageEmulator(storage, 'localhost', 9199);
6068
}

sample/src/app/app.server.module.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { NgModule } from '@angular/core';
2-
import { ServerModule } from '@angular/platform-server';
2+
import { ServerModule, ServerTransferStateModule } from '@angular/platform-server';
33

44
import { AppModule } from './app.module';
55
import { AppComponent } from './app.component';
@@ -8,6 +8,7 @@ import { AppComponent } from './app.component';
88
imports: [
99
AppModule,
1010
ServerModule,
11+
ServerTransferStateModule,
1112
],
1213
bootstrap: [AppComponent],
1314
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { GoogleAuthProvider, signInWithPopup } from '@angular/fire/auth';
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { AuthComponent } from './auth.component';
4+
5+
describe('AuthComponent', () => {
6+
let component: AuthComponent;
7+
let fixture: ComponentFixture<AuthComponent>;
8+
9+
beforeEach(waitForAsync(() => {
10+
TestBed.configureTestingModule({
11+
declarations: [ AuthComponent ]
12+
})
13+
.compileComponents();
14+
}));
15+
16+
beforeEach(() => {
17+
fixture = TestBed.createComponent(AuthComponent);
18+
component = fixture.componentInstance;
19+
fixture.detectChanges();
20+
});
21+
22+
it('should create', () => {
23+
expect(component).toBeTruthy();
24+
});
25+
});

sample/src/app/auth/auth.component.ts

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import { Component, OnInit, OnDestroy, PLATFORM_ID } from '@angular/core';
2+
import { Auth, authState, signInAnonymously, signOut, User } from '@angular/fire/auth';
3+
import { Observable, Subscription } from 'rxjs';
4+
import { map } from 'rxjs/operators';
5+
import { traceUntilFirst } from '@angular/fire/performance';
6+
import { Inject } from '@angular/core';
7+
8+
@Component({
9+
selector: 'app-auth',
10+
template: `
11+
<p>
12+
Auth!
13+
{{ (user | async)?.uid | json }}
14+
<button (click)="login()" *ngIf="showLoginButton">Log in with Google</button>
15+
<button (click)="loginAnonymously()" *ngIf="showLoginButton">Log in anonymously</button>
16+
<button (click)="logout()" *ngIf="showLogoutButton">Log out</button>
17+
</p>
18+
`,
19+
styles: []
20+
})
21+
export class AuthComponent implements OnInit, OnDestroy {
22+
23+
private readonly userDisposable: Subscription|undefined;
24+
public readonly user: Observable<User | null>;
25+
26+
showLoginButton = false;
27+
showLogoutButton = false;
28+
29+
constructor(public readonly auth: Auth, @Inject(PLATFORM_ID) platformId: object) {
30+
this.user = authState(this.auth);
31+
this.userDisposable = authState(this.auth).pipe(
32+
traceUntilFirst('auth'),
33+
map(u => !!u)
34+
).subscribe(isLoggedIn => {
35+
this.showLoginButton = !isLoggedIn;
36+
this.showLogoutButton = isLoggedIn;
37+
});
38+
}
39+
40+
ngOnInit(): void { }
41+
42+
ngOnDestroy(): void {
43+
if (this.userDisposable) {
44+
this.userDisposable.unsubscribe();
45+
}
46+
}
47+
48+
async login() {
49+
const { GoogleAuthProvider, signInWithPopup } = await import('./GoogleAuthProvider');
50+
return await signInWithPopup(this.auth, new GoogleAuthProvider());
51+
}
52+
53+
async loginAnonymously() {
54+
return await signInAnonymously(this.auth);
55+
}
56+
57+
async logout() {
58+
return await signOut(this.auth);
59+
}
60+
61+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { DatabaseComponent } from './database.component';
4+
5+
describe('DatabaseComponent', () => {
6+
let component: DatabaseComponent;
7+
let fixture: ComponentFixture<DatabaseComponent>;
8+
9+
beforeEach(waitForAsync(() => {
10+
TestBed.configureTestingModule({
11+
declarations: [ DatabaseComponent ]
12+
})
13+
.compileComponents();
14+
}));
15+
16+
beforeEach(() => {
17+
fixture = TestBed.createComponent(DatabaseComponent);
18+
component = fixture.componentInstance;
19+
fixture.detectChanges();
20+
});
21+
22+
it('should create', () => {
23+
expect(component).toBeTruthy();
24+
});
25+
});

0 commit comments

Comments
 (0)