Skip to content

Commit e3f9614

Browse files
Merge pull request #20 from angular/master
Update upstream
2 parents 656381e + 11b36ad commit e3f9614

24 files changed

+1960
-365
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ before_script:
2626

2727
script:
2828
- npm run build
29-
- ./node_modules/.bin/karma start --single-run --browsers Chrome --reporters mocha
29+
- ./node_modules/.bin/karma start --single-run --browsers Firefox --reporters mocha
3030
# Run integration test to make sure our typings are correct for user-land.
3131
- node tools/run-typings-test.js
3232

docs/firestore/collections.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export class AppComponent {
3737
}
3838
```
3939

40-
The `AngularFirestoreCollection` is service you use to create streams of the collection and perform data operations on the underyling collection.
40+
The `AngularFirestoreCollection` is a service you use to create streams of the collection and perform data operations on the underyling collection.
4141

4242
### The `DocumentChangeAction` type
4343

karma.conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ module.exports = function(config) {
4141
logLevel: config.LOG_INFO,
4242
autoWatch: true,
4343
reporters: ['mocha'],
44-
browsers: ['Chrome'],
44+
browsers: ['Firefox'],
4545
singleRun: false
4646
})
4747
};

package.json

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angularfire2",
3-
"version": "5.0.0-rc.5-next",
3+
"version": "5.0.0-rc.6",
44
"description": "The official library of Firebase and Angular.",
55
"private": true,
66
"scripts": {
@@ -34,7 +34,18 @@
3434
"@angular/core": "^5.0.0",
3535
"@angular/platform-browser": "^5.0.0",
3636
"@angular/platform-browser-dynamic": "^5.0.0",
37-
"firebase": "^4.5.0",
37+
"@firebase/app": "^0.1.6",
38+
"@firebase/app-types": "^0.1.1",
39+
"@firebase/auth": "^0.3.2",
40+
"@firebase/auth-types": "^0.1.1",
41+
"@firebase/database": "^0.1.7",
42+
"@firebase/database-types": "^0.1.1",
43+
"@firebase/firestore": "^0.2.3",
44+
"@firebase/firestore-types": "^0.1.1",
45+
"@firebase/messaging-types": "^0.1.1",
46+
"@firebase/storage": "^0.1.6",
47+
"@firebase/storage-types": "^0.1.1",
48+
"firebase": "^4.8.2",
3849
"rxjs": "^5.5.4",
3950
"zone.js": "^0.8.0"
4051
},
@@ -56,9 +67,9 @@
5667
"jasmine": "^2.4.1",
5768
"jasmine-core": "^2.4.1",
5869
"json": "^9.0.3",
59-
"karma": "^0.13.19",
60-
"karma-chrome-launcher": "^0.2.2",
61-
"karma-firefox-launcher": "^0.1.7",
70+
"karma": "^2.0.0",
71+
"karma-chrome-launcher": "^2.2.0",
72+
"karma-firefox-launcher": "^1.1.0",
6273
"karma-jasmine": "^0.3.6",
6374
"karma-mocha-reporter": "^2.0.2",
6475
"karma-systemjs": "^0.10.0",
@@ -71,6 +82,7 @@
7182
"rollup": "^0.35.11",
7283
"rollup-plugin-node-resolve": "^3.0.0",
7384
"rollup-watch": "^2.5.0",
85+
"shelljs": "^0.8.0",
7486
"systemjs": "^0.19.16",
7587
"systemjs-builder": "^0.15.7",
7688
"traceur": "0.0.96",

src/auth/auth.module.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { NgModule, NgZone } from '@angular/core';
22
import { FirebaseApp, AngularFireModule } from 'angularfire2';
33
import { AngularFireAuth } from './auth';
4+
import '@firebase/auth';
45

56
export function _getAngularFireAuth(app: FirebaseApp) {
67
return new AngularFireAuth(app);

src/auth/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"@angular/core": "ANGULAR_VERSION",
2323
"@angular/platform-browser": "ANGULAR_VERSION",
2424
"@angular/platform-browser-dynamic": "ANGULAR_VERSION",
25-
"firebase": "FIREBASE_VERSION",
25+
"@firebase/app": "FIREBASE_APP_VERSION",
26+
"@firebase/auth": "FIREBASE_AUTH_VERSION",
2627
"rxjs": "RXJS_VERSION",
2728
"zone.js": "ZONEJS_VERSION"
2829
},

src/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"@angular/core": "ANGULAR_VERSION",
2222
"@angular/platform-browser": "ANGULAR_VERSION",
2323
"@angular/platform-browser-dynamic": "ANGULAR_VERSION",
24-
"firebase": "FIREBASE_VERSION",
24+
"@firebase/app": "FIREBASE_APP_VERSION",
2525
"rxjs": "RXJS_VERSION",
2626
"zone.js": "ZONEJS_VERSION"
2727
},

src/database-deprecated/database.module.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { NgModule } from '@angular/core';
22
import { AngularFireModule, FirebaseApp } from 'angularfire2';
33
import { AngularFireDatabase } from './database';
4+
import '@firebase/database';
45

56
export function _getAngularFireDatabase(app: FirebaseApp) {
67
return new AngularFireDatabase(app);

src/database-deprecated/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"@angular/core": "ANGULAR_VERSION",
2323
"@angular/platform-browser": "ANGULAR_VERSION",
2424
"@angular/platform-browser-dynamic": "ANGULAR_VERSION",
25-
"firebase": "FIREBASE_VERSION",
25+
"@firebase/app": "FIREBASE_APP_VERSION",
26+
"@firebase/database": "FIREBASE_DATABASE_VERSION",
2627
"rxjs": "RXJS_VERSION",
2728
"zone.js": "ZONEJS_VERSION"
2829
},

src/database/database.module.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { NgModule } from '@angular/core';
22
import { AngularFireModule, FirebaseApp } from 'angularfire2';
33
import { AngularFireDatabase } from './database';
4+
import '@firebase/database';
45

56
export function _getAngularFireDatabase(app: FirebaseApp) {
67
return new AngularFireDatabase(app);

src/database/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"@angular/core": "ANGULAR_VERSION",
2323
"@angular/platform-browser": "ANGULAR_VERSION",
2424
"@angular/platform-browser-dynamic": "ANGULAR_VERSION",
25-
"firebase": "FIREBASE_VERSION",
25+
"@firebase/app": "FIREBASE_APP_VERSION",
26+
"@firebase/database": "FIREBASE_DATABASE_VERSION",
2627
"rxjs": "RXJS_VERSION",
2728
"zone.js": "ZONEJS_VERSION"
2829
},

src/firestore/firestore.module.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { InjectionToken, ModuleWithProviders, NgModule } from '@angular/core';
22
import { FirebaseApp, AngularFireModule } from 'angularfire2';
33
import { AngularFirestore } from './firestore';
44
import { from } from 'rxjs/observable/from';
5+
import '@firebase/firestore';
56

67
import { EnablePersistenceToken } from './enable-persistance-token';
78

src/firestore/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
"@angular/core": "ANGULAR_VERSION",
2323
"@angular/platform-browser": "ANGULAR_VERSION",
2424
"@angular/platform-browser-dynamic": "ANGULAR_VERSION",
25-
"firebase": "FIREBASE_VERSION",
26-
"firestore": "FIRESTORE_VERSION",
25+
"@firebase/app": "FIREBASE_APP_VERSION",
26+
"@firebase/firestore": "FIREBASE_FIRESTORE_VERSION",
2727
"rxjs": "RXJS_VERSION",
2828
"zone.js": "ZONEJS_VERSION"
2929
},

src/root.spec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ export * from './packages-dist/database/list/state-changes.spec';
1313
export * from './packages-dist/database/list/audit-trail.spec';
1414
export * from './packages-dist/storage/storage.spec';
1515

16+
// // Since this a deprecated API, we run on it on manual tests only
17+
// // It needs a network connection to run which makes it flaky on Travis
1618
// export * from './packages-dist/database-deprecated/firebase_list_factory.spec';
1719
// export * from './packages-dist/database-deprecated/firebase_object_factory.spec';
1820
// export * from './packages-dist/database-deprecated/firebase_list_observable.spec';

src/storage/observable/fromTask.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { UploadTask, UploadTaskSnapshot } from '@firebase/storage-types';
22
import { Observable } from 'rxjs/Observable';
33

44
export function fromTask(task: UploadTask) {
5-
return new Observable<UploadTaskSnapshot | undefined>(subscriber => {
5+
return new Observable<UploadTaskSnapshot>(subscriber => {
66
const progress = (snap: UploadTaskSnapshot) => subscriber.next(snap);
77
const error = e => subscriber.error(e);
88
const complete = () => subscriber.complete();

src/storage/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"@angular/core": "ANGULAR_VERSION",
2323
"@angular/platform-browser": "ANGULAR_VERSION",
2424
"@angular/platform-browser-dynamic": "ANGULAR_VERSION",
25-
"firebase": "FIREBASE_VERSION",
25+
"@firebase/app": "FIREBASE_APP_VERSION",
26+
"@firebase/storage": "FIREBASE_STORAGE_VERSION",
2627
"rxjs": "RXJS_VERSION",
2728
"zone.js": "ZONEJS_VERSION"
2829
},

src/storage/ref.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,18 @@ export interface AngularFireStorageReference {
2020
*/
2121
export function createStorageRef(ref: Reference): AngularFireStorageReference {
2222
return {
23-
getDownloadURL() { return from(ref.getDownloadURL()); },
24-
getMetadata() { return from(ref.getMetadata()) },
25-
delete() { return from(ref.delete()); },
26-
child(path: string) { return createStorageRef(ref.child(path)); },
27-
updateMetatdata(meta: SettableMetadata) {
28-
return from(ref.updateMetadata(meta));
29-
},
30-
put(data: any, metadata?: UploadMetadata) {
23+
getDownloadURL: () => from(ref.getDownloadURL()),
24+
getMetadata: () => from(ref.getMetadata()),
25+
delete: () => from(ref.delete()),
26+
child: (path: string) => createStorageRef(ref.child(path)),
27+
updateMetatdata: (meta: SettableMetadata) => from(ref.updateMetadata(meta)),
28+
put: (data: any, metadata?: UploadMetadata) => {
3129
const task = ref.put(data, metadata);
3230
return createUploadTask(task);
3331
},
34-
putString(data: string, format?: StringFormat, metadata?: UploadMetadata) {
32+
putString: (data: string, format?: StringFormat, metadata?: UploadMetadata) => {
3533
const task = ref.putString(data, format, metadata);
3634
return createUploadTask(task);
3735
}
38-
}
36+
};
3937
}

src/storage/storage.module.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { NgModule } from '@angular/core';
22
import { AngularFireModule, FirebaseApp } from 'angularfire2';
33
import { AngularFireStorage } from './storage';
4+
import '@firebase/storage';
45

56
export function _getAngularFireStorage(app: FirebaseApp) {
67
return new AngularFireStorage(app);

src/storage/storage.spec.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Observable } from 'rxjs/Observable'
33
import { forkJoin } from 'rxjs/observable/forkJoin';
44
import { TestBed, inject } from '@angular/core/testing';
55
import { FirebaseApp, FirebaseAppConfig, AngularFireModule } from 'angularfire2';
6-
import { AngularFireStorageModule, AngularFireStorage } from 'angularfire2/storage';
6+
import { AngularFireStorageModule, AngularFireStorage, AngularFireUploadTask } from 'angularfire2/storage';
77
import { COMMON_CONFIG } from './test-config';
88

99
describe('AngularFireStorage', () => {
@@ -63,6 +63,18 @@ describe('AngularFireStorage', () => {
6363
() => { ref.delete().subscribe(done, done.fail); }
6464
);
6565
});
66+
67+
it('should resolve the task as a promise', (done) => {
68+
const data = { angular: "promise" };
69+
const blob = new Blob([JSON.stringify(data)], { type : 'application/json' });
70+
const ref = afStorage.ref('afs.json');
71+
const task: AngularFireUploadTask = ref.put(blob);
72+
task.then(snap => {
73+
expect(snap).toBeDefined();
74+
done();
75+
}).catch(done.fail);
76+
});
77+
6678
});
6779

6880
describe('reference', () => {

src/storage/storage.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { Observable } from 'rxjs/Observable';
1111
* This service is the main entry point for this feature module. It provides
1212
* an API for uploading and downloading binary files from Cloud Storage for
1313
* Firebase.
14-
*
1514
*/
1615
@Injectable()
1716
export class AngularFireStorage {

src/storage/task.ts

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,42 @@ import { UploadTaskSnapshot, UploadTask } from '@firebase/storage-types';
22
import { fromTask } from './observable/fromTask';
33
import { Observable } from 'rxjs/Observable';
44
import { map, filter } from 'rxjs/operators';
5+
import { from } from 'rxjs/observable/from';
56

67
export interface AngularFireUploadTask {
8+
task: UploadTask,
79
snapshotChanges(): Observable<UploadTaskSnapshot | undefined>;
810
percentageChanges(): Observable<number | undefined>;
911
downloadURL(): Observable<string | null>;
1012
pause(): boolean;
1113
cancel(): boolean;
1214
resume(): boolean;
13-
then(): Promise<any>;
15+
then(
16+
onFulfilled?: ((a: UploadTaskSnapshot) => any) | null,
17+
onRejected?: ((a: Error) => any) | null
18+
): Promise<any>;
1419
catch(onRejected: (a: Error) => any): Promise<any>;
1520
}
1621

22+
/**
23+
* Create an AngularFireUploadTask from a regular UploadTask from the Storage SDK.
24+
* This method creates an observable of the upload and returns on object that provides
25+
* multiple methods for controlling and monitoring the file upload.
26+
* @param task
27+
*/
1728
export function createUploadTask(task: UploadTask): AngularFireUploadTask {
1829
const inner$ = fromTask(task);
1930
return {
20-
pause() { return task.pause(); },
21-
cancel() { return task.cancel(); },
22-
resume() { return task.resume(); },
23-
then() { return task.then(); },
24-
catch(onRejected: (a: Error) => any) {
25-
return task.catch(onRejected);
26-
},
27-
snapshotChanges() { return inner$; },
28-
percentageChanges() {
29-
return inner$.pipe(
30-
filter(s => s !== undefined),
31-
map(s => s!.bytesTransferred / s!.totalBytes * 100)
32-
);
33-
},
34-
downloadURL() {
35-
return inner$.pipe(
36-
filter(s => s !== undefined),
37-
filter(s => s!.bytesTransferred === s!.totalBytes),
38-
map(s => s!.downloadURL)
39-
);
40-
}
31+
task: task,
32+
then: task.then.bind(task),
33+
catch: task.catch.bind(task),
34+
pause: task.pause.bind(task),
35+
cancel: task.cancel.bind(task),
36+
resume: task.resume.bind(task),
37+
snapshotChanges: () => inner$,
38+
downloadURL: () => from(task.then(s => s.downloadURL)),
39+
percentageChanges: () => inner$.pipe(
40+
map(s => s.bytesTransferred / s.totalBytes * 100)
41+
)
4142
};
4243
}

test/ng-build/index.js

Lines changed: 1 addition & 1 deletion
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('./ng5/package.json');
3+
const ng5Pkg = require(`${__dirname}/ng5/package.json`);
44
const pkg = require('../../package.json');
55
const shell = require('shelljs');
66

tools/build.js

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,18 @@ const GLOBALS = {
5454
'@angular/core': 'ng.core',
5555
'@angular/compiler': 'ng.compiler',
5656
'@angular/platform-browser': 'ng.platformBrowser',
57+
'firebase/auth': 'firebase',
58+
'firebase/app': 'firebase',
59+
'firebase/database': 'firebase',
60+
'firebase/firestore': 'firebase',
61+
'firebase/storage': 'firebase',
5762
'@firebase/auth': 'firebase',
5863
'@firebase/app': 'firebase',
5964
'@firebase/database': 'firebase',
6065
'@firebase/firestore': 'firebase',
6166
'@firebase/storage': 'firebase',
67+
'@firebase/util': 'firebase',
68+
'@firebase/webchannel-wrapper': 'firebase',
6269
'rxjs/scheduler/queue': 'Rx.Scheduler',
6370
'@angular/core/testing': 'ng.core.testing',
6471
'angularfire2': 'angularfire2',
@@ -72,7 +79,11 @@ const GLOBALS = {
7279
// Map of dependency versions across all packages
7380
const VERSIONS = {
7481
ANGULAR_VERSION: pkg.dependencies['@angular/core'],
75-
FIREBASE_VERSION: pkg.dependencies['firebase'],
82+
FIREBASE_APP_VERSION: pkg.dependencies['@firebase/app'],
83+
FIREBASE_DATABASE_VERSION: pkg.dependencies['@firebase/database'],
84+
FIREBASE_FIRESTORE_VERSION: pkg.dependencies['@firebase/firestore'],
85+
FIREBASE_AUTH_VERSION: pkg.dependencies['@firebase/auth'],
86+
FIREBASE_STORAGE_VERSION: pkg.dependencies['@firebase/storage'],
7687
RXJS_VERSION: pkg.dependencies['rxjs'],
7788
ZONEJS_VERSION: pkg.dependencies['zone.js'],
7889
ANGULARFIRE2_VERSION: pkg.version,
@@ -115,6 +126,15 @@ const DEST_PKG_PATHS = {
115126
storage: `${process.cwd()}/dist/packages-dist/storage/package.json`
116127
};
117128

129+
const FIREBASE_FEATURE_MODULES = {
130+
app: `${process.cwd()}/node_modules/@firebase/app/dist/esm/index.js`,
131+
auth: `${process.cwd()}/node_modules/@firebase/auth/dist/auth.js`,
132+
database: `${process.cwd()}/node_modules/@firebase/database/dist/esm/index.js`,
133+
firestore: `${process.cwd()}/node_modules/@firebase/firestore/dist/esm/index.js`,
134+
storage: `${process.cwd()}/node_modules/@firebase/storage/dist/esm/index.js`,
135+
util: `${process.cwd()}/node_modules/@firebase/util/dist/esm/index.js`,
136+
};
137+
118138
// Constants for running typescript commands
119139
const TSC = 'node_modules/.bin/tsc';
120140
const NGC = 'node_modules/.bin/ngc';
@@ -149,6 +169,16 @@ function generateBundle(entry, { dest, globals, moduleName }) {
149169
});
150170
}
151171

172+
function createFirebaseBundles(featurePaths, globals) {
173+
return Object.keys(featurePaths).map(feature => {
174+
return generateBundle(featurePaths[feature], {
175+
dest: `${process.cwd()}/dist/bundles/${feature}.js`,
176+
globals,
177+
moduleName: `firebase.${feature}`
178+
});
179+
});
180+
}
181+
152182
/**
153183
* Create a UMD bundle given a module name.
154184
* @param {string} name

0 commit comments

Comments
 (0)