Skip to content

Commit 4df1939

Browse files
jamesdanielsdavideast
authored andcommitted
feat(): support Angular and rxjs 6 (#1625)
* fix(): Angular/rxjs 6 and dropping database-depricated Co-authored-by: Yuki Kawamoto <[email protected]> * Brought database-deprecated back in * Changelog and version update for rc8 * Had some bad merges and updating build test * Drop package-lock from test/ng6 * fixed the ng-build yarn command
1 parent 7d2fd53 commit 4df1939

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2170
-1612
lines changed

Diff for: .travis.yml

+2
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,5 @@ script:
4343
- ./node_modules/.bin/karma start --single-run --browsers ChromeHeadlessTravis --reporters mocha
4444
# Run integration test to make sure our typings are correct for user-land.
4545
- node tools/run-typings-test.js
46+
# Run the ng6 build test
47+
- cd test/ng-build/ng6 && yarn && yarn build:prod

Diff for: CHANGELOG.md

+26
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
1+
<a name="5.0.0-rc.8"></a>
2+
# [5.0.0-rc.8](https://github.com/angular/angularfire2/compare/5.0.0-rc.7...5.0.0-rc.8) (2018-05-12)
3+
4+
### Bug Fixes
5+
6+
* Zone was already loaded, type is implied ([#1631](https://github.com/angular/angularfire2/issues/1631)) ([7d2fd53](https://github.com/angular/angularfire2/commit/7d2fd53)), closes [#1599](https://github.com/angular/angularfire2/issues/1599)
7+
8+
### Features
9+
10+
* Supporting Angular and rxjs 6 ([dd4a36c](https://github.com/angular/angularfire2/commit/dd4a36c))
11+
* Support Firebase JS SDK 5.0 ([#1628](https://github.com/angular/angularfire2/issues/1628)) ([b99bfa3](https://github.com/angular/angularfire2/commit/b99bfa3))
12+
* Support FirebaseAppConfig, clean up injection tokens ([#1627](https://github.com/angular/angularfire2/issues/1627)) ([57906bd](https://github.com/angular/angularfire2/commit/57906bd))
13+
* **firestore:** Support Firestore Settings, timestampsInSnapshots default to true ([#1629](https://github.com/angular/angularfire2/issues/1629)) ([570c0a7](https://github.com/angular/angularfire2/commit/570c0a7))
14+
* **auth:** Update to rxjs pipeable operators ([#1621](https://github.com/angular/angularfire2/issues/1621)) ([0c3b215](https://github.com/angular/angularfire2/commit/0c3b215))
15+
* **core:** Update to rxjs pipeable operators ([#1620](https://github.com/angular/angularfire2/issues/1620)) ([3fbbb7d](https://github.com/angular/angularfire2/commit/3fbbb7d))
16+
* **database:** Update to rxjs pipeable operators ([#1622](https://github.com/angular/angularfire2/issues/1622)) ([5c3681d](https://github.com/angular/angularfire2/commit/5c3681d))
17+
* **firestore:** Update to rxjs pipeable operators ([#1623](https://github.com/angular/angularfire2/issues/1623)) ([97b26e3](https://github.com/angular/angularfire2/commit/97b26e3))
18+
* **storage:** Update to rxjs pipeable operators ([#1624](https://github.com/angular/angularfire2/issues/1624)) ([014be21](https://github.com/angular/angularfire2/commit/014be21))
19+
20+
### Breaking changes
21+
22+
* Due to the addition of a conflicting `FirebaseAppConfig` interface in Firebase 4.13 we've now changed our `FirebaseAppConfig` Injection Token to be `FirebaseOptionsToken`
23+
* For consistency the `FirebaseAppName` Injection Token is now `FirebaseAppNameToken`
24+
* rxjs 5 is no longer supported, upgrade to 6 ([see the rxjs migration guide for more information](https://github.com/ReactiveX/rxjs/blob/master/MIGRATION.md))
25+
* Firebase JS SDK 4.x is no longer supported, upgrade to 5 ([see the changelog for more information](https://firebase.google.com/support/release-notes/js#version_500_may_8_2018))
26+
127
<a name="5.0.0-rc.7"></a>
228
# [5.0.0-rc.7](https://github.com/angular/angularfire2/compare/5.0.0-rc.6...5.0.0-rc.7) (2018-05-04)
329

Diff for: karma.conf.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module.exports = function(config) {
2020
'node_modules/zone.js/dist/async-test.js',
2121
'node_modules/zone.js/dist/fake-async-test.js',
2222

23-
'node_modules/rxjs/bundles/Rx.{js,map}',
23+
'node_modules/rxjs/bundles/rxjs.umd.{js,map}',
2424

2525
...getAngularFiles(['core','common','compiler','platform-browser','platform-browser-dynamic']),
2626

Diff for: package.json

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angularfire2",
3-
"version": "5.0.0-rc.7",
3+
"version": "5.0.0-rc.8",
44
"description": "The official library of Firebase and Angular.",
55
"private": true,
66
"scripts": {
@@ -29,11 +29,11 @@
2929
},
3030
"homepage": "https://github.com/angular/angularfire2#readme",
3131
"dependencies": {
32-
"@angular/common": "^5.0.0",
33-
"@angular/compiler": "^5.0.0",
34-
"@angular/core": "^5.0.0",
35-
"@angular/platform-browser": "^5.0.0",
36-
"@angular/platform-browser-dynamic": "^5.0.0",
32+
"@angular/common": "^6.0.0",
33+
"@angular/compiler": "^6.0.0",
34+
"@angular/core": "^6.0.0",
35+
"@angular/platform-browser": "^6.0.0",
36+
"@angular/platform-browser-dynamic": "^6.0.0",
3737
"@firebase/app": "^0.3.1",
3838
"@firebase/app-types": "^0.3.1",
3939
"@firebase/auth": "^0.5.2",
@@ -47,15 +47,15 @@
4747
"@firebase/storage-types": "^0.2.2",
4848
"bufferutil": "^3.0.3",
4949
"firebase": "^5.0.2",
50-
"rxjs": "^5.5.4",
50+
"rxjs": "^6.0.0",
5151
"utf-8-validate": "^4.0.0",
5252
"ws": "^3.3.2",
5353
"xmlhttprequest": "^1.8.0",
5454
"zone.js": "^0.8.0"
5555
},
5656
"devDependencies": {
57-
"@angular/compiler-cli": "^5.0.0",
58-
"@angular/platform-server": "^5.0.0",
57+
"@angular/compiler-cli": "^6.0.0",
58+
"@angular/platform-server": "^6.0.0",
5959
"@types/jasmine": "^2.5.36",
6060
"@types/request": "0.0.30",
6161
"concurrently": "^2.2.0",
@@ -90,7 +90,7 @@
9090
"systemjs": "^0.19.16",
9191
"systemjs-builder": "^0.15.7",
9292
"traceur": "0.0.96",
93-
"typescript": ">=2.4.2 <2.5"
93+
"typescript": ">=2.7.2 <2.8.0"
9494
},
9595
"typings": "index.d.ts"
9696
}

Diff for: src/auth/auth.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import { FirebaseAuth, User } from '@firebase/auth-types';
22
import { FirebaseOptions, FirebaseAppConfig } from '@firebase/app-types';
33
import { Injectable, Inject, Optional, NgZone, PLATFORM_ID } from '@angular/core';
4-
import { Observable } from 'rxjs';
4+
import { Observable, of, from } from 'rxjs';
55
import { switchMap } from 'rxjs/operators';
6-
import { of } from 'rxjs/observable/of';
7-
import { from } from 'rxjs/observable/from';
86

97
import { FirebaseOptionsToken, FirebaseAppConfigToken, FirebaseAppNameToken, _firebaseAppFactory, FirebaseZoneScheduler } from 'angularfire2';
108

Diff for: src/core/angularfire2.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { InjectionToken, NgZone } from '@angular/core';
22
import { isPlatformServer } from '@angular/common';
3-
import { Observable, Subscription } from 'rxjs';
4-
import { queue } from 'rxjs/scheduler/queue';
3+
import { Observable, Subscription, queueScheduler as queue } from 'rxjs';
54
import { first } from 'rxjs/operators';
65

76
import firebase from '@firebase/app';

Diff for: src/database-deprecated/database.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export class AngularFireDatabase {
2525
zone: NgZone
2626
) {
2727
this.database = zone.runOutsideAngular(() => {
28-
const app = _firebaseAppFactory(config, name);
28+
const app = _firebaseAppFactory(options, name, config);
2929
return app.database(databaseURL || undefined);
3030
});
3131
}

Diff for: src/database-deprecated/firebase_list_factory.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ import { FirebaseZoneScheduler } from 'angularfire2';
44
import * as utils from './utils';
55
import { AFUnwrappedDataSnapshot } from './interfaces';
66
import { FirebaseListObservable } from './firebase_list_observable';
7-
import { Observer } from 'rxjs/Observer';
8-
import { observeOn } from 'rxjs/operator/observeOn';
7+
import { Observer } from 'rxjs';
8+
import { observeOn, switchMap, map } from 'rxjs/operators';
99
import { observeQuery } from './query_observable';
1010
import { Query, FirebaseListFactoryOpts, DatabaseReference, DatabaseQuery, DatabaseSnapshot } from './interfaces';
11-
import { switchMap } from 'rxjs/operator/switchMap';
12-
import { map } from 'rxjs/operator/map';
1311

1412
export function FirebaseListFactory (
1513
ref: DatabaseReference,

Diff for: src/database-deprecated/firebase_list_observable.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
import { Observable } from 'rxjs/Observable';
2-
import { Operator } from 'rxjs/Operator';
3-
import { Subscriber } from 'rxjs/Subscriber';
4-
import { Subscription } from 'rxjs/Subscription';
1+
import { Observable, Operator, Subscriber, Subscription } from 'rxjs';
52
import { Reference, DataSnapshot, ThenableReference } from '@firebase/database-types';
63
import * as utils from './utils';
74
import { AFUnwrappedDataSnapshot, FirebaseOperationCases, QueryReference, DatabaseSnapshot, DatabaseReference } from './interfaces';

Diff for: src/database-deprecated/firebase_object_factory.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { NgZone } from '@angular/core';
22
import { FirebaseObjectObservable } from './firebase_object_observable';
33
import { FirebaseZoneScheduler } from 'angularfire2';
4-
import { Observer } from 'rxjs/Observer';
5-
import { observeOn } from 'rxjs/operator/observeOn';
4+
import { Observer } from 'rxjs';
5+
import { observeOn } from 'rxjs/operators';
66
import { DataSnapshot } from '@firebase/database-types';
77
import * as utils from './utils';
88
import { FirebaseObjectFactoryOpts, DatabaseReference } from './interfaces';

Diff for: src/database-deprecated/firebase_object_observable.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
import { Observable } from 'rxjs/Observable';
2-
import { Operator } from 'rxjs/Operator';
3-
import { Subscriber } from 'rxjs/Subscriber';
4-
import { Subscription } from 'rxjs/Subscription';
1+
import { Observable, Operator, Subscriber, Subscription } from 'rxjs';
52
import { Reference } from '@firebase/database-types';
63

74
export class FirebaseObjectObservable<T> extends Observable<T> {

Diff for: src/database-deprecated/interfaces.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Observable } from 'rxjs/Observable';
1+
import { Observable } from 'rxjs';
22
import { Reference, DataSnapshot, Query } from '@firebase/database-types';
33

44
export interface FirebaseOperationCases {

Diff for: src/database-deprecated/query_observable.ts

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
1-
import { Observable } from 'rxjs/Observable';
2-
import { of as observableOf } from 'rxjs/observable/of';
3-
import { Operator } from 'rxjs/Operator';
4-
import { Observer } from 'rxjs/Observer';
5-
import { combineLatest } from 'rxjs/operator/combineLatest';
6-
import { merge } from 'rxjs/operator/merge';
7-
import { map } from 'rxjs/operator/map';
8-
import { auditTime } from 'rxjs/operator/auditTime';
1+
import { Observable, of as observableOf, Operator, Observer } from 'rxjs';
2+
import { auditTime, combineLatest, merge, map } from 'rxjs/operators';
93
import { Query, ScalarQuery, OrderByOptions, OrderBySelection, LimitToOptions, LimitToSelection, Primitive } from './interfaces';
104
import { hasKey, isNil } from './utils';
115

Diff for: src/database-deprecated/utils.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { DataSnapshot, FirebaseDatabase } from '@firebase/database-types';
2-
import { Subscription } from 'rxjs/Subscription';
3-
import { Scheduler } from 'rxjs/Scheduler';
4-
import { queue } from 'rxjs/scheduler/queue';
2+
import { Subscription, Scheduler, queueScheduler as queue } from 'rxjs';
53
import { AFUnwrappedDataSnapshot, PathReference, DatabaseReference } from './interfaces';
64

75
const REGEX_ABSOLUTE_URL = /^[a-z]+:\/\/.*/;

Diff for: src/database/list/changes.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { fromRef } from '../observable/fromRef';
2-
import { Observable } from 'rxjs';
3-
import { of } from 'rxjs/observable/of';
4-
import { merge } from 'rxjs/observable/merge';
2+
import { Observable, of, merge } from 'rxjs';
53

64
import { DatabaseQuery, ChildEvent, AngularFireAction, SnapshotAction } from '../interfaces';
75
import { isNil } from '../utils';

Diff for: src/database/list/snapshot-changes.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ describe('snapshotChanges', () => {
5454

5555
it('should listen to all events by default', (done) => {
5656
const { snapChanges, ref } = prepareSnapshotChanges();
57-
snapChanges.take(1).subscribe(actions => {
57+
snapChanges.pipe(take(1)).subscribe(actions => {
5858
const data = actions.map(a => a.payload!.val());
5959
expect(data).toEqual(items);
6060
}).add(done);

Diff for: src/database/list/state-changes.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { DatabaseQuery, ChildEvent, AngularFireAction, SnapshotAction } from '../interfaces';
22
import { fromRef } from '../observable/fromRef';
33
import { validateEventsArray } from './utils';
4-
import { Observable } from 'rxjs';
5-
import { merge } from 'rxjs/observable/merge';
4+
import { Observable, merge } from 'rxjs';
65

76
import { DataSnapshot } from '@firebase/database-types';
87
import { AngularFireDatabase } from '../database';

Diff for: src/database/utils.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Subscription, Scheduler } from 'rxjs';
2-
import { queue } from 'rxjs/scheduler/queue';
32
import { PathReference, DatabaseReference, FirebaseOperation, FirebaseOperationCases } from './interfaces';
43
import { FirebaseDatabase } from '@firebase/database-types';
54

Diff for: src/firestore/collection/collection.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { DocumentChangeType, CollectionReference, Query, DocumentReference } from '@firebase/firestore-types';
22
import { Observable, Subscriber } from 'rxjs';
33
import { fromCollectionRef } from '../observable/fromRef';
4-
import { map, filter } from 'rxjs/operators';
4+
import { map, filter, scan } from 'rxjs/operators';
55

66
import { Injectable } from '@angular/core';
77

@@ -87,7 +87,7 @@ export class AngularFirestoreCollection<T> {
8787
* @param events
8888
*/
8989
auditTrail(events?: DocumentChangeType[]): Observable<DocumentChangeAction[]> {
90-
return this.stateChanges(events).scan((current, action) => [...current, ...action], []);
90+
return this.stateChanges(events).pipe(scan((current, action) => [...current, ...action], []));
9191
}
9292

9393
/**

Diff for: src/firestore/firestore.ts

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
import { InjectionToken, NgZone, PLATFORM_ID } from '@angular/core';
1+
import { InjectionToken, NgZone, PLATFORM_ID, Injectable, Inject, Optional } from '@angular/core';
22
import { FirebaseFirestore, CollectionReference, DocumentReference, Settings } from '@firebase/firestore-types';
33

4-
import { Observable, Subscriber } from 'rxjs';
4+
import { Observable, Subscriber, of, from } from 'rxjs';
55
import { map, catchError } from 'rxjs/operators';
6-
import { of } from 'rxjs/observable/of';
7-
import { from } from 'rxjs/observable/from';
86
import { FirebaseOptions, FirebaseAppConfig } from '@firebase/app-types';
9-
import { Injectable, Inject, Optional } from '@angular/core';
107

118
import { QueryFn, AssociatedReference } from './interfaces';
129
import { AngularFirestoreDocument } from './document/document';
@@ -118,7 +115,7 @@ export class AngularFirestore {
118115
) {
119116
this.scheduler = new FirebaseZoneScheduler(zone, platformId);
120117
this.firestore = zone.runOutsideAngular(() => {
121-
const app = _firebaseAppFactory(config, name);
118+
const app = _firebaseAppFactory(options, name, config);
122119
const firestore = app.firestore();
123120
firestore.settings(settings || DefaultFirestoreSettings);
124121
return firestore;

Diff for: src/storage/ref.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { SettableMetadata, UploadMetadata, Reference, StringFormat } from '@firebase/storage-types';
22
import { createUploadTask, AngularFireUploadTask } from './task';
3-
import { Observable } from 'rxjs';
4-
import { from } from 'rxjs/observable/from';
3+
import { Observable, from } from 'rxjs';
54
import { FirebaseZoneScheduler } from 'angularfire2';
65

76
export interface AngularFireStorageReference {
@@ -31,9 +30,9 @@ export function createStorageRef(ref: Reference, scheduler: FirebaseZoneSchedule
3130
from(ref.getMetadata())
3231
)
3332
),
34-
delete: () => Observable.from(ref.delete()),
33+
delete: () => from(ref.delete()),
3534
child: (path: string) => createStorageRef(ref.child(path), scheduler),
36-
updateMetatdata: (meta: SettableMetadata) => Observable.from(ref.updateMetadata(meta)),
35+
updateMetatdata: (meta: SettableMetadata) => from(ref.updateMetadata(meta)),
3736
put: (data: any, metadata?: UploadMetadata) => {
3837
const task = ref.put(data, metadata);
3938
return createUploadTask(task);

Diff for: src/storage/storage.spec.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { Observable } from 'rxjs'
2-
import { forkJoin } from 'rxjs/observable/forkJoin';
1+
import { Observable, forkJoin } from 'rxjs'
32
import { map, mergeMap, tap } from 'rxjs/operators';
43
import { TestBed, inject } from '@angular/core/testing';
54
import { FirebaseApp, FirebaseOptionsToken, AngularFireModule, FirebaseAppNameToken } from 'angularfire2';

Diff for: src/storage/task.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { UploadTaskSnapshot, UploadTask } from '@firebase/storage-types';
22
import { fromTask } from './observable/fromTask';
3-
import { Observable } from 'rxjs';
3+
import { Observable, from } from 'rxjs';
44
import { map, filter } from 'rxjs/operators';
5-
import { from } from 'rxjs/observable/from';
65

76
export interface AngularFireUploadTask {
87
task: UploadTask,

Diff for: test/ng-build/build.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
cd ng5 && ng build --prod
1+
cd ng6 && ng build --prod

Diff for: test/ng-build/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const fs = require('fs');
22
const { spawn, spawnSync } = require('child_process');
3-
const ng5Pkg = require(`${__dirname}/ng5/package.json`);
3+
const ng5Pkg = require(`${__dirname}/ng6/package.json`);
44
const pkg = require('../../package.json');
55
const shell = require('shelljs');
66

@@ -11,7 +11,7 @@ function packageAngularFire() {
1111
const res = spawnSync('sh', ['pack.sh']);
1212
console.log(`------------ FINISHED PACKAGING VERSION ${PACKAGED_VERSION} ------------`);
1313
console.log(`------------ INSTALLING VERSION ${PACKAGED_VERSION} ------------`);
14-
if (shell.exec(`cd ng5 && npm i firebase ../${PACKAGED_VERSION}`).code !== 0) {
14+
if (shell.exec(`cd ng5 && yarn add firebase ../${PACKAGED_VERSION}`).code !== 0) {
1515
shell.echo('Error');
1616
shell.exit(1);
1717
}
@@ -30,7 +30,7 @@ function buildVersion5() {
3030
});
3131
cmd.on('close', () => {
3232
try {
33-
const dir = fs.readdirSync(__dirname + '/ng5/dist');
33+
const dir = fs.readdirSync(__dirname + '/ng6/dist');
3434
console.log(dir);
3535
console.log(`------------ SUCCESS VERSION ${ng5Pkg.dependencies['@angular/core']} ------------`);
3636
} catch (e) {

Diff for: test/ng-build/ng5/package.json

-35
This file was deleted.

0 commit comments

Comments
 (0)