Skip to content

5.1 release: support Firebase 5.5, multi-tab sync, function region selection, and Angular 7 #1920

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 9 commits into from
Oct 19, 2018
Merged
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
<a name="5.1.0"></a>
# [5.1.0](https://github.com/angular/angularfire2/compare/5.0.0-rc.12...5.1.0) (2018-10-17)

### Features

* **afs:** Support Firebase 5.5 and Firestore PersistenceSettings ([a9cf1ca](https://github.com/angular/angularfire2/commit/a9cf1ca))


<a name="5.0.2"></a>
## [5.0.2](https://github.com/angular/angularfire2/compare/5.0.1...5.0.2) (2018-09-21)

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angularfire2",
"version": "5.0.2",
"version": "5.1.0",
"description": "The official library of Firebase and Angular.",
"private": true,
"scripts": {
Expand All @@ -12,7 +12,7 @@
"delayed_karma": "sleep 10 && karma start",
"build": "rm -rf dist && node tools/build.js",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 1",
"build:wrapper": "npm i --prefix wrapper && VERSION=5.0.2 npm run --prefix wrapper build"
"build:wrapper": "npm i --prefix wrapper && VERSION=5.1.0 npm run --prefix wrapper build"
},
"keywords": [
"angular",
Expand All @@ -35,7 +35,7 @@
"@angular/core": "^6.0.0",
"@angular/platform-browser": "^6.0.0",
"@angular/platform-browser-dynamic": "^6.0.0",
"firebase": "^5.0.3",
"firebase": "^5.5.0",
"rxjs": "^6.0.0",
"ws": "^3.3.2",
"xhr2": "^0.1.4",
Expand Down
2 changes: 1 addition & 1 deletion src/auth/auth.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { User } from 'firebase';
import { User } from 'firebase/app';
import { Observable, Subject } from 'rxjs'
import { TestBed, inject } from '@angular/core/testing';
import { FirebaseApp, FirebaseOptionsToken, AngularFireModule, FirebaseNameOrConfigToken } from '@angular/fire';
Expand Down
2 changes: 1 addition & 1 deletion src/auth/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Injectable, Inject, Optional, NgZone, PLATFORM_ID } from '@angular/core
import { Observable, of, from } from 'rxjs';
import { switchMap } from 'rxjs/operators';
import { FirebaseAppConfig, FirebaseOptions } from '@angular/fire';
import { User, auth } from 'firebase';
import { User, auth } from 'firebase/app';

import { FirebaseAuth, FirebaseOptionsToken, FirebaseNameOrConfigToken, _firebaseAppFactory, FirebaseZoneScheduler } from '@angular/fire';

Expand Down
2 changes: 1 addition & 1 deletion src/core/angularfire2.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { FirebaseApp, AngularFireModule } from '@angular/fire';
import { Subscription } from 'rxjs';
import { COMMON_CONFIG } from './test-config';
import { BrowserModule } from '@angular/platform-browser';
import { database } from 'firebase';
import { database } from 'firebase/app';

describe('angularfire', () => {
let subscription:Subscription;
Expand Down
6 changes: 4 additions & 2 deletions src/core/firebase.app.module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { InjectionToken, NgModule, Optional } from '@angular/core';
import {app, auth, database, firestore, functions, messaging, storage } from 'firebase';
import { app, auth, database, firestore, functions, messaging, storage } from 'firebase/app';
// @ts-ignore (https://github.com/firebase/firebase-js-sdk/pull/1206)
import firebase from 'firebase/app';
import firebase from 'firebase/app'; // once fixed can pull in as "default as firebase" above

// Public types don't expose FirebaseOptions or FirebaseAppConfig
export type FirebaseOptions = {[key:string]: any};
Expand All @@ -17,6 +17,8 @@ export type FirebaseStorage = storage.Storage;
export type FirebaseFirestore = firestore.Firestore;
export type FirebaseFunctions = functions.Functions;

// Have to implement as we need to return a class from the provider, we should consider exporting
// this in the firebase/app types as this is our highest risk of breaks
export class FirebaseApp implements app.App {
name: string;
options: {};
Expand Down
2 changes: 1 addition & 1 deletion src/database-deprecated/firebase_object_observable.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Observable, Operator, Subscriber, Subscription } from 'rxjs';
import { Reference } from './interfaces';
import { database } from 'firebase';
import { database } from 'firebase/app';

export class FirebaseObjectObservable<T> extends Observable<T> {
constructor(subscribe?: <R>(subscriber: Subscriber<R>) => Subscription | Function | void, public $ref?:Reference) {
Expand Down
2 changes: 1 addition & 1 deletion src/database-deprecated/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Observable } from 'rxjs';
import { database } from 'firebase';
import { database } from 'firebase/app';

export type Reference = database.Reference;
export type DataSnapshot = database.DataSnapshot;
Expand Down
2 changes: 1 addition & 1 deletion src/database/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Observable } from 'rxjs';
import { database } from 'firebase';
import { database } from 'firebase/app';

export type FirebaseOperation = string | database.Reference | database.DataSnapshot;

Expand Down
2 changes: 1 addition & 1 deletion src/database/list/changes.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { database } from 'firebase';
import { database } from 'firebase/app';
import { FirebaseApp, AngularFireModule } from '@angular/fire';
import { AngularFireDatabase, AngularFireDatabaseModule, listChanges } from '@angular/fire/database';
import { TestBed, inject } from '@angular/core/testing';
Expand Down
2 changes: 1 addition & 1 deletion src/database/list/remove.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DatabaseReference, DataSnapshot, FirebaseOperation, DatabaseSnapshot } from '../interfaces';
import { checkOperationCases } from '../utils';
import { database } from 'firebase';
import { database } from 'firebase/app';

// TODO(davideast): Find out why TS thinks this returns firebase.Primise
// instead of Promise.
Expand Down
2 changes: 1 addition & 1 deletion src/database/list/snapshot-changes.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { database } from 'firebase';
import { database } from 'firebase/app';
import { FirebaseApp, AngularFireModule } from '@angular/fire';
import { AngularFireDatabase, AngularFireDatabaseModule, snapshotChanges, ChildEvent } from '@angular/fire/database';
import { TestBed, inject } from '@angular/core/testing';
Expand Down
2 changes: 1 addition & 1 deletion src/database/list/state-changes.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { database } from 'firebase';
import { database } from 'firebase/app';
import { FirebaseApp, AngularFireModule } from '@angular/fire';
import { AngularFireDatabase, AngularFireDatabaseModule, stateChanges, ChildEvent } from '@angular/fire/database';
import { TestBed, inject } from '@angular/core/testing';
Expand Down
2 changes: 1 addition & 1 deletion src/firestore/collection/collection.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Observable, from } from 'rxjs';
import { fromCollectionRef } from '../observable/fromRef';
import { map, filter, scan } from 'rxjs/operators';
import { firestore } from 'firebase';
import { firestore } from 'firebase/app';

import { DocumentChangeType, CollectionReference, Query, DocumentReference, DocumentData, DocumentChangeAction } from '../interfaces';
import { docChanges, sortedChanges } from './changes';
Expand Down
2 changes: 1 addition & 1 deletion src/firestore/document/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { map } from 'rxjs/operators';

import { AngularFirestore, associateQuery } from '../firestore';
import { AngularFirestoreCollection } from '../collection/collection';
import { firestore } from 'firebase';
import { firestore } from 'firebase/app';
import { runInZone } from '@angular/fire';

/**
Expand Down
8 changes: 5 additions & 3 deletions src/firestore/firestore.module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { InjectionToken, ModuleWithProviders, NgModule } from '@angular/core';
import { AngularFirestore, EnablePersistenceToken } from './firestore';
import { ModuleWithProviders, NgModule } from '@angular/core';
import { AngularFirestore, EnablePersistenceToken, PersistenceSettingsToken } from './firestore';

import 'firebase/firestore';
import { firestore } from 'firebase/app';

@NgModule({
providers: [ AngularFirestore ]
Expand All @@ -10,11 +11,12 @@ export class AngularFirestoreModule {
/**
* Attempt to enable persistent storage, if possible
*/
static enablePersistence(): ModuleWithProviders {
static enablePersistence(persistenceSettings?: firestore.PersistenceSettings): ModuleWithProviders {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use PersistenceSettings from ./interface

return {
ngModule: AngularFirestoreModule,
providers: [
{ provide: EnablePersistenceToken, useValue: true },
{ provide: PersistenceSettingsToken, useValue: persistenceSettings },
]
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/firestore/firestore.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('AngularFirestore', () => {
TestBed.configureTestingModule({
imports: [
AngularFireModule.initializeApp(COMMON_CONFIG),
AngularFirestoreModule.enablePersistence()
AngularFirestoreModule.enablePersistence({experimentalTabSynchronization: true})
]
});
inject([FirebaseApp, AngularFirestore], (_app: FirebaseApp, _afs: AngularFirestore) => {
Expand Down
8 changes: 4 additions & 4 deletions src/firestore/firestore.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { InjectionToken, NgZone, PLATFORM_ID, Injectable, Inject, Optional } from '@angular/core';

import { Observable, of, from } from 'rxjs';
import { catchError } from 'rxjs/operators';
import { firestore } from 'firebase';

import { Settings, CollectionReference, DocumentReference, QueryFn, AssociatedReference } from './interfaces';
import { Settings, PersistenceSettings, CollectionReference, DocumentReference, QueryFn, AssociatedReference } from './interfaces';
import { AngularFirestoreDocument } from './document/document';
import { AngularFirestoreCollection } from './collection/collection';

Expand All @@ -15,6 +13,7 @@ import { isPlatformBrowser } from '@angular/common';
* The value of this token determines whether or not the firestore will have persistance enabled
*/
export const EnablePersistenceToken = new InjectionToken<boolean>('angularfire2.enableFirestorePersistence');
export const PersistenceSettingsToken = new InjectionToken<PersistenceSettings|undefined>('angularfire2.firestore.persistenceSettings');
export const FirestoreSettingsToken = new InjectionToken<Settings>('angularfire2.firestore.settings');

export const DefaultFirestoreSettings = {timestampsInSnapshots: true} as Settings;
Expand Down Expand Up @@ -108,6 +107,7 @@ export class AngularFirestore {
@Inject(FirebaseOptionsToken) options:FirebaseOptions,
@Optional() @Inject(FirebaseNameOrConfigToken) nameOrConfig:string|FirebaseAppConfig|undefined,
@Optional() @Inject(EnablePersistenceToken) shouldEnablePersistence: boolean,
@Optional() @Inject(PersistenceSettingsToken) persistenceSettings: PersistenceSettings|undefined,
@Optional() @Inject(FirestoreSettingsToken) settings: Settings,
@Inject(PLATFORM_ID) platformId: Object,
zone: NgZone
Expand All @@ -125,7 +125,7 @@ export class AngularFirestore {
// https://github.com/firebase/firebase-js-sdk/issues/608
const enablePersistence = () => {
try {
return from(this.firestore.enablePersistence().then(() => true, () => false));
return from(this.firestore.enablePersistence(persistenceSettings).then(() => true, () => false));
} catch(e) {
return of(false);
}
Expand Down
4 changes: 2 additions & 2 deletions src/firestore/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Subscriber } from 'rxjs';
import { firestore } from 'firebase';
import { firestore } from 'firebase/app';

export type Settings = firestore.Settings;
export type CollectionReference = firestore.CollectionReference;
export type DocumentReference = firestore.DocumentReference;

export type PersistenceSettings = firestore.PersistenceSettings;
export type DocumentChangeType = firestore.DocumentChangeType;
export type SnapshotOptions = firestore.SnapshotOptions;
export type FieldPath = firestore.FieldPath;
Expand Down
2 changes: 1 addition & 1 deletion src/firestore/utils.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { firestore } from 'firebase';
import { firestore } from 'firebase/app';
import { AngularFirestoreCollection } from './collection/collection';

export interface Stock {
Expand Down
2 changes: 1 addition & 1 deletion src/messaging/messaging.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable, Inject, Optional, NgZone, PLATFORM_ID } from '@angular/core';
import { isPlatformBrowser } from '@angular/common';
import { messaging } from 'firebase';
import { messaging } from 'firebase/app';
import { Observable, empty, from, of, throwError } from 'rxjs';
import { mergeMap, catchError, map, switchMap, concat, defaultIfEmpty } from 'rxjs/operators';
import { FirebaseOptions, FirebaseAppConfig, runOutsideAngular } from '@angular/fire';
Expand Down
2 changes: 1 addition & 1 deletion src/storage/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { storage } from 'firebase';
import { storage } from 'firebase/app';

export type UploadTask = storage.UploadTask;
export type UploadTaskSnapshot = storage.UploadTaskSnapshot;
Expand Down
2 changes: 1 addition & 1 deletion src/storage/observable/fromTask.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Observable } from 'rxjs';
import { UploadTask, UploadTaskSnapshot } from '../interfaces';
import { storage } from 'firebase';
import { storage } from 'firebase/app';

export function fromTask(task: UploadTask) {
return new Observable<UploadTaskSnapshot>(subscriber => {
Expand Down
Loading