Skip to content

Commit b72a87b

Browse files
committed
Placeholders for sub-package, reexport rxfire/*
1 parent fadc178 commit b72a87b

27 files changed

+233
-14
lines changed

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ AngularFire smooths over the rough edges an Angular developer might encounter wh
1818

1919
```ts
2020
import { Component } from '@angular/core';
21-
import { AngularFirestore } from '@angular/fire/firestore';
22-
import { Observable } from 'rxjs';
21+
import { Firestore } from '@angular/fire';
22+
import { Observable, valueChanges } from 'rxjs';
23+
import { collection } from 'firebase/firestore';
2324

2425
@Component({
2526
selector: 'app-root',
@@ -33,8 +34,8 @@ import { Observable } from 'rxjs';
3334
})
3435
export class MyApp {
3536
item$: Observable<any[]>;
36-
constructor(firestore: AngularFirestore) {
37-
this.item$ = firestore.collection('items').valueChanges();
37+
constructor(firestore: Firestore) {
38+
this.item$ = valueChanges(collection(firestore, 'items'));
3839
}
3940
}
4041
```
@@ -47,6 +48,7 @@ AngularFire doesn't follow Angular's versioning as Firebase also has breaking ch
4748

4849
| Angular | Firebase | AngularFire |
4950
| --------|----------|--------------|
51+
| 12 | 9 | ^7.0 |
5052
| 11 | 7,8 | ^6.1 |
5153
| 10 | 8 | ^6.0.4 |
5254
| 10 | 7 | ^6.0.3 |
@@ -77,7 +79,7 @@ Neither AngularFire or Firebase ship with polyfills. To have compatability acros
7779

7880
[Stackblitz Template](https://stackblitz.com/edit/angular-fire-start) - Remember to set your Firebase configuration in `app/app.module.ts`.
7981

80-
[Upgrading to v6.0? Check out our guide.](docs/version-6-upgrade.md)
82+
[Upgrading to v7.0? Check out our guide.](docs/version-7-upgrade.md)
8183

8284
**Having troubles?** Get help on our [Q&A board](https://github.com/angular/angularfire/discussions?discussions_q=category%3AQ%26A), the official [Firebase Mailing List](https://groups.google.com/forum/#!forum/firebase-talk), the [Firebase Community Slack](https://firebase.community/) (`#angularfire2`), the [Angular Community Discord](http://discord.gg/angular) (`#firebase`), [Gitter](https://gitter.im/angular/angularfire2), the [Firebase subreddit](https://www.reddit.com/r/firebase), or [Stack Overflow](https://stackoverflow.com/questions/tagged/angularfire2).
8385

docs/version-7-upgrade.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Upgrading to AngularFire 7.0
2+
3+
Intended to be run with Angular 12, AngularFire 7.0 allows you to take full advtange of the new tree-shakable Firebase JS SDK (v9) while also providing a compatible expirience with the prior API.
4+
5+
**TBD**

src/analytics/analytics.module.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export function ɵanalyticsInstancesFactory(instances: Analytics[]) {
2828
// Hack: useFactory doesn't allow us to pass a lambda, so let's bind the arugments
2929
// Going this direction to cut down on DI token noise; also making it easier to support
3030
// multiple Firebase Apps
31-
export function ɵboundAuthInstanceFactory(zone: NgZone) {
31+
export function ɵboundAnalyticsInstanceFactory(zone: NgZone) {
3232
const analytics = ɵsmartCacheInstance<FirebaseAnalytics>(CACHE_PREFIX, this);
3333
return new Analytics(analytics);
3434
}
@@ -47,15 +47,15 @@ const DEFAULT_ANALYTICS_INSTANCE_PROVIDER = {
4747
DEFAULT_ANALYTICS_INSTANCE_PROVIDER,
4848
]
4949
})
50-
export class AngularFireAuthModule {
50+
export class AngularFireAnalyticsModule {
5151
}
5252

5353
export function provideAnalytics(fn: () => FirebaseAnalytics) {
5454
return {
55-
ngModule: AngularFireAuthModule,
55+
ngModule: AngularFireAnalyticsModule,
5656
providers: [{
5757
provide: ANALYTICS_INSTANCES,
58-
useFactory: ɵboundAuthInstanceFactory.bind(fn),
58+
useFactory: ɵboundAnalyticsInstanceFactory.bind(fn),
5959
multi: true,
6060
deps: [
6161
NgZone,

src/analytics/package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "../../node_modules/ng-packagr/package.schema.json",
3+
"ngPackage": {
4+
"lib": {
5+
"umdModuleIds": {
6+
"rxfire/analytics": "rxfire"
7+
},
8+
"entryFile": "public_api.ts"
9+
}
10+
}
11+
}

src/analytics/public_api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { Analytics, provideAnalytics, ANALYTICS_INSTANCES } from '@angular/fire';

src/app/package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "../../node_modules/ng-packagr/package.schema.json",
3+
"ngPackage": {
4+
"lib": {
5+
"umdModuleIds": {
6+
"rxfire/app": "rxfire"
7+
},
8+
"entryFile": "public_api.ts"
9+
}
10+
}
11+
}

src/app/public_api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { FirebaseApp, provideFirebaseApp, FIREBASE_APPS } from '@angular/fire';

src/auth/package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "../../node_modules/ng-packagr/package.schema.json",
3+
"ngPackage": {
4+
"lib": {
5+
"umdModuleIds": {
6+
"rxfire/auth": "rxfire"
7+
},
8+
"entryFile": "public_api.ts"
9+
}
10+
}
11+
}

src/auth/public_api.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { Auth, provideAuth, AUTH_INSTANCES } from '@angular/fire';
2+
export * from 'rxfire/auth';

src/database/package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "../../node_modules/ng-packagr/package.schema.json",
3+
"ngPackage": {
4+
"lib": {
5+
"umdModuleIds": {
6+
"rxfire/database": "rxfire"
7+
},
8+
"entryFile": "public_api.ts"
9+
}
10+
}
11+
}

src/database/public_api.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { Database, provideDatabase, DATABASE_INSTANCES } from '@angular/fire';
2+
export * from 'rxfire/database';

src/firestore/package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "../../node_modules/ng-packagr/package.schema.json",
3+
"ngPackage": {
4+
"lib": {
5+
"umdModuleIds": {
6+
"rxfire/firestore": "rxfire"
7+
},
8+
"entryFile": "public_api.ts"
9+
}
10+
}
11+
}

src/firestore/public_api.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { Firestore, provideFirestore, FIRESTORE_INSTANCES } from '@angular/fire';
2+
export * from 'rxfire/firestore';

src/functions/package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "../../node_modules/ng-packagr/package.schema.json",
3+
"ngPackage": {
4+
"lib": {
5+
"umdModuleIds": {
6+
"rxfire/functions": "rxfire"
7+
},
8+
"entryFile": "public_api.ts"
9+
}
10+
}
11+
}

src/functions/public_api.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { Functions, provideFunctions, FUNCTIONS_INSTANCES } from '@angular/fire';
2+
export * from 'rxfire/functions';

src/messaging/package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "../../node_modules/ng-packagr/package.schema.json",
3+
"ngPackage": {
4+
"lib": {
5+
"umdModuleIds": {
6+
"rxfire/messaging": "rxfire"
7+
},
8+
"entryFile": "public_api.ts"
9+
}
10+
}
11+
}

src/messaging/public_api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { Messaging, provideMessaging, MESSAGING_INSTANCES } from '@angular/fire';

src/performance/package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "../../node_modules/ng-packagr/package.schema.json",
3+
"ngPackage": {
4+
"lib": {
5+
"umdModuleIds": {
6+
"rxfire/performance": "rxfire"
7+
},
8+
"entryFile": "public_api.ts"
9+
}
10+
}
11+
}

src/performance/performance.module.ts

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import { NgModule, Optional, NgZone, InjectionToken } from '@angular/core';
2+
import { FirebasePerformance } from 'firebase/performance';
3+
4+
import { ɵsmartCacheInstance, ɵfetchCachedInstance } from '../core';
5+
import { Performance } from './performance';
6+
import { DEFAULT_APP_NAME, FIREBASE_APPS } from '../app/app.module';
7+
8+
export const PERFORMANCE_INSTANCES = new InjectionToken<Performance[]>('angularfire2.performance-instances');
9+
10+
const CACHE_PREFIX = 'Performance';
11+
12+
export function ɵdefaultPerformanceInstanceFactory(_: Performance[]) {
13+
const performance = ɵfetchCachedInstance([CACHE_PREFIX, DEFAULT_APP_NAME].join('.'));
14+
if (performance) {
15+
return new Performance(performance);
16+
}
17+
throw new Error(`No Performance Instance provided for the '${DEFAULT_APP_NAME}' Firebase App - call providePerformance(...) in your providers list.`);
18+
}
19+
20+
export function ɵwrapPerformanceInstanceInInjectable(performance: FirebasePerformance) {
21+
return new Performance(performance);
22+
}
23+
24+
export function ɵperformanceInstancesFactory(instances: Performance[]) {
25+
return instances;
26+
}
27+
28+
// Hack: useFactory doesn't allow us to pass a lambda, so let's bind the arugments
29+
// Going this direction to cut down on DI token noise; also making it easier to support
30+
// multiple Firebase Apps
31+
export function ɵboundPerformanceInstanceFactory(zone: NgZone) {
32+
const performance = ɵsmartCacheInstance<FirebasePerformance>(CACHE_PREFIX, this);
33+
return new Performance(performance);
34+
}
35+
36+
const DEFAULT_PERFORMANCE_INSTANCE_PROVIDER = {
37+
provide: Performance,
38+
useFactory: ɵdefaultPerformanceInstanceFactory,
39+
deps: [
40+
NgZone,
41+
[new Optional(), PERFORMANCE_INSTANCES ],
42+
]
43+
};
44+
45+
@NgModule({
46+
providers: [
47+
DEFAULT_PERFORMANCE_INSTANCE_PROVIDER,
48+
]
49+
})
50+
export class AngularFirePerformanceModule {
51+
}
52+
53+
export function providePerformance(fn: () => FirebasePerformance) {
54+
return {
55+
ngModule: AngularFirePerformanceModule,
56+
providers: [{
57+
provide: PERFORMANCE_INSTANCES,
58+
useFactory: ɵboundPerformanceInstanceFactory.bind(fn),
59+
multi: true,
60+
deps: [
61+
NgZone,
62+
[new Optional(), FIREBASE_APPS ]
63+
]
64+
}]
65+
};
66+
}

src/performance/performance.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { FirebasePerformance } from 'firebase/performance';
2+
3+
// see notes in core/firebase.app.module.ts for why we're building the class like this
4+
// tslint:disable-next-line:no-empty-interface
5+
export interface Performance extends FirebasePerformance {}
6+
7+
export class Performance {
8+
constructor(performance: FirebasePerformance) {
9+
return performance;
10+
}
11+
}

src/performance/public_api.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { Performance, providePerformance, PERFORMANCE_INSTANCES } from '@angular/fire';
2+
export * from 'rxfire/performance';

src/public_api.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
export * from './core';
22
export * from './zones';
33

4+
export * from './analytics/analytics';
5+
export * from './analytics/analytics.module';
6+
47
export * from './app/app';
58
export * from './app/app.module';
69

@@ -19,6 +22,9 @@ export * from './functions/functions.module';
1922
export * from './messaging/messaging';
2023
export * from './messaging/messaging.module';
2124

25+
export * from './performance/performance';
26+
export * from './performance/performance.module';
27+
2228
export * from './remote-config/remote-config';
2329
export * from './remote-config/remote-config.module';
2430

src/remote-config/package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "../../node_modules/ng-packagr/package.schema.json",
3+
"ngPackage": {
4+
"lib": {
5+
"umdModuleIds": {
6+
"rxfire/remote-config": "rxfire"
7+
},
8+
"entryFile": "public_api.ts"
9+
}
10+
}
11+
}

src/remote-config/public_api.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { RemoteConfig, provideRemoteConfig, REMOTE_CONFIG_INSTANCES } from '@angular/fire';
2+
export * from 'rxfire/remote-config';

src/storage/package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "../../node_modules/ng-packagr/package.schema.json",
3+
"ngPackage": {
4+
"lib": {
5+
"umdModuleIds": {
6+
"rxfire/storage": "rxfire"
7+
},
8+
"entryFile": "public_api.ts"
9+
}
10+
}
11+
}

src/storage/public_api.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { Storage, provideStorage, STORAGE_INSTANCES } from '@angular/fire';
2+
export * from 'rxfire/storage';

tools/build.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ import firebase from 'firebase/compat/app';
88

99
// TODO infer these from the package.json
1010
const MODULES = [
11-
'core', 'compat', 'compat/analytics', 'compat/auth-guard', 'compat/auth',
12-
'compat/database', 'compat/firestore', 'compat/functions', 'compat/remote-config',
13-
'compat/storage', 'compat/messaging', 'compat/performance'
11+
'core', 'compat', 'analytics', 'auth', 'database', 'firestore', 'functions',
12+
'remote-config', 'storage', 'messaging', 'performance', 'compat/analytics',
13+
'compat/auth-guard', 'compat/auth', 'compat/database', 'compat/firestore',
14+
'compat/functions', 'compat/remote-config', 'compat/storage', 'compat/messaging',
15+
'compat/performance'
1416
];
1517
const LAZY_MODULES = ['compat/analytics', 'compat/auth', 'compat/functions', 'compat/messaging', 'compat/remote-config'];
1618
const UMD_NAMES = MODULES.map(m => m === 'core' ? 'angular-fire' : `angular-fire-${m.replace('/', '-')}`);
@@ -142,15 +144,15 @@ async function buildDocs() {
142144
const buffer = await readFile(`./dist/typedocs/${module}.json`);
143145
const typedoc = JSON.parse(buffer.toString());
144146
if (!typedoc.children) {
145-
console.log('typedoc fail', module);
147+
console.error('typedoc fail', module);
146148
}
147149
// TODO infer the entryPoint from the package.json
148150
const entryPoint = typedoc.children.find((c: any) => c.name === '"public_api"');
149151
const allChildren = [].concat(...typedoc.children.map(child =>
150152
// TODO chop out the working directory and filename
151153
child.children ? child.children.map(c => ({ ...c, path: dirname(child.originalName.split(process.cwd())[1]) })) : []
152154
));
153-
return entryPoint.children
155+
return (entryPoint.children || [])
154156
.filter(c => c.name[0] !== 'ɵ' && c.name[0] !== '_' /* private */)
155157
.map(child => ({ ...allChildren.find(c => child.target === c.id) }))
156158
.reduce((acc, child) => ({ ...acc, [encodeURIComponent(child.name)]: child }), {});

0 commit comments

Comments
 (0)