@angular/fire 16.0.0-canary.e04cd7f → 16.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +200 -0
- package/analytics/analytics.module.d.ts +2 -2
- package/analytics/firebase.d.ts +4 -1
- package/analytics/screen-tracking.service.d.ts +3 -3
- package/app-check/app-check.d.ts +0 -6
- package/app-check/app-check.module.d.ts +3 -4
- package/app-check/firebase.d.ts +2 -1
- package/app-check/public_api.d.ts +2 -1
- package/auth/auth.module.d.ts +2 -2
- package/auth/firebase.d.ts +3 -1
- package/auth-guard/auth-guard.d.ts +2 -2
- package/compat/analytics/analytics.d.ts +1 -3
- package/compat/analytics/analytics.module.d.ts +1 -1
- package/compat/analytics/screen-tracking.service.d.ts +1 -1
- package/compat/analytics/user-tracking.service.d.ts +1 -1
- package/compat/auth/auth.d.ts +3 -3
- package/compat/auth-guard/auth-guard.d.ts +2 -2
- package/compat/database/database.d.ts +4 -4
- package/compat/database/interfaces.d.ts +2 -2
- package/compat/database/list/audit-trail.d.ts +1 -1
- package/compat/database/list/create-reference.d.ts +1 -1
- package/compat/database/list/data-operation.d.ts +1 -1
- package/compat/database/list/state-changes.d.ts +1 -1
- package/compat/database/object/create-reference.d.ts +1 -1
- package/compat/database/observable/fromRef.d.ts +1 -1
- package/compat/database/utils.d.ts +1 -1
- package/compat/firebase.app.module.d.ts +1 -1
- package/compat/firestore/collection/collection.d.ts +2 -2
- package/compat/firestore/collection-group/collection-group.d.ts +2 -2
- package/compat/firestore/document/document.d.ts +4 -4
- package/compat/firestore/firestore.d.ts +7 -7
- package/compat/firestore/interfaces.d.ts +2 -2
- package/compat/functions/functions.d.ts +3 -3
- package/compat/messaging/messaging.d.ts +2 -2
- package/compat/performance/performance.d.ts +2 -2
- package/compat/remote-config/remote-config.d.ts +15 -49
- package/compat/storage/observable/fromTask.d.ts +1 -2
- package/compat/storage/ref.d.ts +1 -1
- package/compat/storage/storage.d.ts +3 -3
- package/compat/storage/task.d.ts +1 -1
- package/core.d.ts +7 -0
- package/database/database.module.d.ts +2 -2
- package/docs/analytics.md +67 -0
- package/docs/app-check.md +53 -0
- package/docs/auth.md +165 -0
- package/docs/compat/analytics/getting-started.md +137 -0
- package/docs/compat/auth/getting-started.md +162 -0
- package/docs/compat/auth/router-guards.md +104 -0
- package/docs/compat/emulators/emulators.md +134 -0
- package/docs/compat/firestore/collections.md +326 -0
- package/docs/compat/firestore/documents.md +115 -0
- package/docs/compat/firestore/offline-data.md +39 -0
- package/docs/compat/firestore/querying-collections.md +204 -0
- package/docs/compat/functions/functions.md +166 -0
- package/docs/compat/messaging/messaging.md +232 -0
- package/docs/compat/performance/getting-started.md +132 -0
- package/docs/compat/remote-config/getting-started.md +134 -0
- package/docs/compat/rtdb/lists.md +257 -0
- package/docs/compat/rtdb/objects.md +182 -0
- package/docs/compat/rtdb/querying-lists.md +155 -0
- package/docs/compat/storage/storage.md +257 -0
- package/docs/compat.md +70 -0
- package/docs/database.md +175 -0
- package/docs/deploy/getting-started.md +204 -0
- package/docs/firebase.json +16 -0
- package/docs/firestore.md +148 -0
- package/docs/functions.md +52 -0
- package/docs/images/analytics-illo_1x.png +0 -0
- package/docs/images/auth-illo_1x.png +0 -0
- package/docs/images/cloud-messaging-illo_1x.png +0 -0
- package/docs/images/database-illo_1x.png +0 -0
- package/docs/images/firestore-illo_1x.png +0 -0
- package/docs/images/functions-illo_1x.png +0 -0
- package/docs/images/hosting-illo_1x.png +0 -0
- package/docs/images/performance-illo_1x.png +0 -0
- package/docs/images/reCAPTCHA-logo@1x.png +0 -0
- package/docs/images/remote-config-illo_1x.png +0 -0
- package/docs/images/storage-illo_1x.png +0 -0
- package/docs/install-and-setup.md +114 -0
- package/docs/install-angular-cli-windows10.md +82 -0
- package/docs/install-firebase-tools.md +78 -0
- package/docs/messaging.md +25 -0
- package/docs/performance.md +57 -0
- package/docs/remote-config.md +53 -0
- package/docs/storage.md +90 -0
- package/docs/universal/cloud-functions.md +96 -0
- package/docs/universal/getting-started.md +28 -0
- package/docs/universal/prerendering.md +72 -0
- package/docs/version-4-upgrade.md +119 -0
- package/docs/version-5-upgrade.md +82 -0
- package/docs/version-6-upgrade.md +16 -0
- package/docs/version-7-upgrade.md +298 -0
- package/esm2022/analytics/analytics.mjs +1 -1
- package/esm2022/analytics/analytics.module.mjs +10 -10
- package/esm2022/analytics/firebase.mjs +5 -2
- package/esm2022/analytics/screen-tracking.service.mjs +11 -10
- package/esm2022/analytics/user-tracking.service.mjs +5 -5
- package/esm2022/app/app.mjs +1 -1
- package/esm2022/app/app.module.mjs +9 -8
- package/esm2022/app-check/app-check.mjs +3 -9
- package/esm2022/app-check/app-check.module.mjs +12 -14
- package/esm2022/app-check/firebase.mjs +3 -2
- package/esm2022/app-check/public_api.mjs +3 -2
- package/esm2022/auth/auth.mjs +1 -1
- package/esm2022/auth/auth.module.mjs +11 -11
- package/esm2022/auth/firebase.mjs +4 -2
- package/esm2022/auth-guard/auth-guard.mjs +8 -6
- package/esm2022/auth-guard/auth-guard.module.mjs +7 -7
- package/esm2022/compat/analytics/analytics.mjs +12 -13
- package/esm2022/compat/analytics/analytics.module.mjs +14 -11
- package/esm2022/compat/analytics/screen-tracking.service.mjs +9 -9
- package/esm2022/compat/analytics/user-tracking.service.mjs +7 -7
- package/esm2022/compat/auth/auth.mjs +13 -13
- package/esm2022/compat/auth/auth.module.mjs +7 -7
- package/esm2022/compat/auth-guard/auth-guard.mjs +8 -6
- package/esm2022/compat/auth-guard/auth-guard.module.mjs +7 -7
- package/esm2022/compat/cache.mjs +2 -1
- package/esm2022/compat/database/database.mjs +10 -10
- package/esm2022/compat/database/database.module.mjs +7 -7
- package/esm2022/compat/database/interfaces.mjs +1 -1
- package/esm2022/compat/database/list/audit-trail.mjs +3 -3
- package/esm2022/compat/database/list/changes.mjs +5 -5
- package/esm2022/compat/database/list/create-reference.mjs +5 -5
- package/esm2022/compat/database/list/data-operation.mjs +1 -1
- package/esm2022/compat/database/list/snapshot-changes.mjs +1 -1
- package/esm2022/compat/database/list/state-changes.mjs +2 -2
- package/esm2022/compat/database/object/create-reference.mjs +2 -2
- package/esm2022/compat/database/object/snapshot-changes.mjs +1 -1
- package/esm2022/compat/database/observable/fromRef.mjs +3 -2
- package/esm2022/compat/database/utils.mjs +1 -1
- package/esm2022/compat/firebase.app.mjs +1 -1
- package/esm2022/compat/firebase.app.module.mjs +11 -9
- package/esm2022/compat/firestore/collection/changes.mjs +2 -2
- package/esm2022/compat/firestore/collection/collection.mjs +4 -4
- package/esm2022/compat/firestore/collection-group/collection-group.mjs +4 -4
- package/esm2022/compat/firestore/document/document.mjs +4 -4
- package/esm2022/compat/firestore/firestore.mjs +11 -11
- package/esm2022/compat/firestore/firestore.module.mjs +7 -7
- package/esm2022/compat/firestore/interfaces.mjs +1 -1
- package/esm2022/compat/firestore/observable/fromRef.mjs +2 -2
- package/esm2022/compat/functions/functions.mjs +8 -8
- package/esm2022/compat/functions/functions.module.mjs +7 -7
- package/esm2022/compat/messaging/messaging.mjs +13 -12
- package/esm2022/compat/messaging/messaging.module.mjs +7 -7
- package/esm2022/compat/performance/performance.mjs +14 -20
- package/esm2022/compat/performance/performance.module.mjs +8 -9
- package/esm2022/compat/performance/performance.service.mjs +5 -4
- package/esm2022/compat/proxy.mjs +6 -7
- package/esm2022/compat/remote-config/remote-config.mjs +10 -11
- package/esm2022/compat/remote-config/remote-config.module.mjs +7 -7
- package/esm2022/compat/storage/observable/fromTask.mjs +3 -1
- package/esm2022/compat/storage/pipes/storageUrl.pipe.mjs +9 -9
- package/esm2022/compat/storage/ref.mjs +3 -3
- package/esm2022/compat/storage/storage.mjs +8 -8
- package/esm2022/compat/storage/storage.module.mjs +7 -7
- package/esm2022/compat/storage/task.mjs +2 -2
- package/esm2022/core.mjs +7 -1
- package/esm2022/database/database.mjs +1 -1
- package/esm2022/database/database.module.mjs +11 -11
- package/esm2022/firestore/firebase.mjs +22 -2
- package/esm2022/firestore/firestore.mjs +1 -1
- package/esm2022/firestore/firestore.module.mjs +11 -11
- package/esm2022/firestore/lite/firebase.mjs +11 -2
- package/esm2022/firestore/lite/lite.mjs +1 -1
- package/esm2022/firestore/lite/lite.module.mjs +10 -11
- package/esm2022/firestore/lite/rxfire.mjs +4 -2
- package/esm2022/firestore/rxfire.mjs +4 -4
- package/esm2022/functions/functions.mjs +1 -1
- package/esm2022/functions/functions.module.mjs +11 -11
- package/esm2022/messaging/messaging.mjs +1 -1
- package/esm2022/messaging/messaging.module.mjs +9 -9
- package/esm2022/performance/performance.mjs +1 -1
- package/esm2022/performance/performance.module.mjs +12 -12
- package/esm2022/remote-config/is-remote-config-supported-factory.mjs +2 -2
- package/esm2022/remote-config/remote-config.mjs +1 -1
- package/esm2022/remote-config/remote-config.module.mjs +9 -9
- package/esm2022/storage/storage.mjs +1 -1
- package/esm2022/storage/storage.module.mjs +11 -11
- package/esm2022/zones.mjs +9 -11
- package/fesm2022/angular-fire-analytics.mjs +18 -14
- package/fesm2022/angular-fire-analytics.mjs.map +1 -1
- package/fesm2022/angular-fire-app-check.mjs +13 -19
- package/fesm2022/angular-fire-app-check.mjs.map +1 -1
- package/fesm2022/angular-fire-app.mjs +6 -5
- package/fesm2022/angular-fire-app.mjs.map +1 -1
- package/fesm2022/angular-fire-auth-guard.mjs +13 -11
- package/fesm2022/angular-fire-auth-guard.mjs.map +1 -1
- package/fesm2022/angular-fire-auth.mjs +10 -9
- package/fesm2022/angular-fire-auth.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-analytics.mjs +29 -27
- package/fesm2022/angular-fire-compat-analytics.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-auth-guard.mjs +12 -10
- package/fesm2022/angular-fire-compat-auth-guard.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-auth.mjs +13 -13
- package/fesm2022/angular-fire-compat-auth.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-database.mjs +129 -128
- package/fesm2022/angular-fire-compat-database.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-firestore.mjs +96 -96
- package/fesm2022/angular-fire-compat-firestore.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-functions.mjs +10 -10
- package/fesm2022/angular-fire-compat-functions.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-messaging.mjs +13 -12
- package/fesm2022/angular-fire-compat-messaging.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-performance.mjs +23 -29
- package/fesm2022/angular-fire-compat-performance.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-remote-config.mjs +10 -11
- package/fesm2022/angular-fire-compat-remote-config.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-storage.mjs +21 -19
- package/fesm2022/angular-fire-compat-storage.mjs.map +1 -1
- package/fesm2022/angular-fire-compat.mjs +15 -13
- package/fesm2022/angular-fire-compat.mjs.map +1 -1
- package/fesm2022/angular-fire-database.mjs +7 -8
- package/fesm2022/angular-fire-database.mjs.map +1 -1
- package/fesm2022/angular-fire-firestore-lite.mjs +21 -11
- package/fesm2022/angular-fire-firestore-lite.mjs.map +1 -1
- package/fesm2022/angular-fire-firestore.mjs +32 -13
- package/fesm2022/angular-fire-firestore.mjs.map +1 -1
- package/fesm2022/angular-fire-functions.mjs +8 -9
- package/fesm2022/angular-fire-functions.mjs.map +1 -1
- package/fesm2022/angular-fire-messaging.mjs +4 -4
- package/fesm2022/angular-fire-messaging.mjs.map +1 -1
- package/fesm2022/angular-fire-performance.mjs +7 -7
- package/fesm2022/angular-fire-performance.mjs.map +1 -1
- package/fesm2022/angular-fire-remote-config.mjs +4 -4
- package/fesm2022/angular-fire-remote-config.mjs.map +1 -1
- package/fesm2022/angular-fire-storage.mjs +6 -7
- package/fesm2022/angular-fire-storage.mjs.map +1 -1
- package/fesm2022/angular-fire.mjs +14 -10
- package/fesm2022/angular-fire.mjs.map +1 -1
- package/firestore/firebase.d.ts +21 -1
- package/firestore/firestore.module.d.ts +2 -2
- package/firestore/lite/firebase.d.ts +10 -1
- package/firestore/lite/lite.module.d.ts +2 -2
- package/firestore/lite/rxfire.d.ts +3 -1
- package/firestore/rxfire.d.ts +3 -3
- package/functions/functions.module.d.ts +2 -2
- package/messaging/messaging.module.d.ts +2 -2
- package/package.json +18 -18
- package/performance/performance.module.d.ts +2 -2
- package/remote-config/remote-config.module.d.ts +2 -2
- package/schematics/add/index.js +1 -1
- package/schematics/add/schema.json +16 -0
- package/schematics/builders.json +10 -0
- package/schematics/collection.json +15 -0
- package/schematics/common.js +1 -1
- package/schematics/deploy/actions.js +11 -11
- package/schematics/deploy/builder.js +2 -2
- package/schematics/deploy/schema.json +119 -0
- package/schematics/interfaces.js +9 -8
- package/schematics/migration.json +15 -0
- package/schematics/setup/index.js +33 -50
- package/schematics/setup/prompts.js +5 -6
- package/schematics/setup/schema.json +16 -0
- package/schematics/update/index.js +1 -1
- package/schematics/update/v7/index.js +2 -2
- package/schematics/utils.js +79 -63
- package/storage/storage.module.d.ts +2 -2
- package/publish.sh +0 -1
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Firebase Tools Install and Setup
|
|
2
|
+
|
|
3
|
+
### 1. Install package
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install -g firebase-tools
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
or with `yarn`
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
yarn global add firebase-tools
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
You can also choose to install it as a dependency for your project rather than globally
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install --save-dev firebase-tools
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
or with `yarn`
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
yarn add -D firebase-tools
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### 2. Configure Firebase Tools
|
|
28
|
+
|
|
29
|
+
In your projects root directory run:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
firebase init
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
or if your installed it within your project rather than globally
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npx firebase init
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
or with `yarn`
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
yarn firebase init
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
This will ask you to login if you are not logged in already, the process will take you through a browser
|
|
48
|
+
redirect to log you into Firebase.
|
|
49
|
+
|
|
50
|
+
### 3. Choose what Firebase features
|
|
51
|
+
|
|
52
|
+
`firebase-tools` displays Firebase features you want to configure.
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
? Which Firebase features do you want to set up for this directory? Press Space
|
|
56
|
+
to select features, then Enter to confirm your choices. (Press <space> to select
|
|
57
|
+
, <a> to toggle all, <i> to invert selection, and <enter> to proceed)
|
|
58
|
+
◯ Realtime Database: Configure a security rules file for Realtime Database and
|
|
59
|
+
(optionally) provision default instance
|
|
60
|
+
◯ Firestore: Configure security rules and indexes files for Firestore
|
|
61
|
+
◯ Functions: Configure a Cloud Functions directory and its files
|
|
62
|
+
◯ Hosting: Configure files for Firebase Hosting and (optionally) set up GitHub
|
|
63
|
+
Action deploys
|
|
64
|
+
◯ Hosting: Set up GitHub Action deploys
|
|
65
|
+
(Move up and down to reveal more choices)
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### 4. Connect your repo to a Firebase project
|
|
69
|
+
|
|
70
|
+
The CLI will then walk you through making sure your repo is configured with a Firebase project.
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
? Please select an option:
|
|
74
|
+
◯ Use an existing project
|
|
75
|
+
◯ Create a new project
|
|
76
|
+
◯ Add Firebase to an existing Google Cloud Platform project
|
|
77
|
+
◯ Don't set up a default project
|
|
78
|
+
```
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<img align="right" width="30%" src="images/cloud-messaging-illo_1x.png">
|
|
2
|
+
|
|
3
|
+
<small>
|
|
4
|
+
<a href="https://github.com/angular/angularfire">AngularFire</a> ❱ <a href="../README.md#developer-guide">Developer Guide</a> ❱ Realtime Cloud Messaging
|
|
5
|
+
</small>
|
|
6
|
+
|
|
7
|
+
# Cloud Messaging
|
|
8
|
+
|
|
9
|
+
The FCM JavaScript API lets you receive notification messages in web apps running in browsers that support the Push API.
|
|
10
|
+
|
|
11
|
+
[Learn More](https://firebase.google.com/docs/cloud-messaging/)
|
|
12
|
+
|
|
13
|
+
## Dependency Injection
|
|
14
|
+
|
|
15
|
+
YADA YADA YADA
|
|
16
|
+
|
|
17
|
+
## Firebase API
|
|
18
|
+
|
|
19
|
+
Something something look at the offical docs
|
|
20
|
+
|
|
21
|
+
## Convenience observables
|
|
22
|
+
|
|
23
|
+
### Foo
|
|
24
|
+
|
|
25
|
+
bar baz
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<img align="right" width="30%" src="images/performance-illo_1x.png">
|
|
2
|
+
|
|
3
|
+
<small>
|
|
4
|
+
<a href="https://github.com/angular/angularfire">AngularFire</a> ❱ <a href="../README.md#developer-guide">Developer Guide</a> ❱ Realtime Performance Monitoring
|
|
5
|
+
</small>
|
|
6
|
+
|
|
7
|
+
# Performance Monitoring
|
|
8
|
+
|
|
9
|
+
Firebase Performance Monitoring is a service that helps you to gain insight into the performance characteristics of your Apple, Android, and web apps.
|
|
10
|
+
|
|
11
|
+
[Learn More](https://firebase.google.com/docs/perf-mon)
|
|
12
|
+
|
|
13
|
+
## Dependency Injection
|
|
14
|
+
|
|
15
|
+
As a prerequisite, ensure that `AngularFire` has been added to your project via
|
|
16
|
+
```bash
|
|
17
|
+
ng add @angular/fire
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Provide a Performance instance and configuration in the application's `NgModule` (`app.module.ts`):
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { provideFirebaseApp, initializeApp } from '@angular/fire/app';
|
|
24
|
+
import { getPerformance, providePerformance} from '@angular/fire/performance';
|
|
25
|
+
|
|
26
|
+
@NgModule({
|
|
27
|
+
imports: [
|
|
28
|
+
provideFirebaseApp(() => initializeApp(environment.firebase)),
|
|
29
|
+
providePerformance(() => getPerformance()),
|
|
30
|
+
]
|
|
31
|
+
})
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Next inject it into your component:
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import { Component, inject} from '@angular/core';
|
|
38
|
+
import { Performance } from '@angular/fire/performance';
|
|
39
|
+
|
|
40
|
+
@Component({ ... })
|
|
41
|
+
export class PerformanceComponent {
|
|
42
|
+
private performance: Performance = inject(Performance);
|
|
43
|
+
...
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Firebase API
|
|
48
|
+
|
|
49
|
+
The [Performance documentation](https://firebase.google.com/docs/reference/js/performance.md#performance_package) is available on the Firebase website.
|
|
50
|
+
|
|
51
|
+
## Services
|
|
52
|
+
|
|
53
|
+
Coming soon.
|
|
54
|
+
|
|
55
|
+
## Convenience observables
|
|
56
|
+
|
|
57
|
+
Coming soon.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<img align="right" width="30%" src="images/remote-config-illo_1x.png">
|
|
2
|
+
|
|
3
|
+
<small>
|
|
4
|
+
<a href="https://github.com/angular/angularfire">AngularFire</a> ❱ <a href="../README.md#developer-guide">Developer Guide</a> ❱ Realtime Remote Config
|
|
5
|
+
</small>
|
|
6
|
+
|
|
7
|
+
# Remote Config
|
|
8
|
+
|
|
9
|
+
Firebase Remote Config is a cloud service that lets you change the behavior and appearance of your app without requiring users to download an app update.
|
|
10
|
+
|
|
11
|
+
[Learn More](https://firebase.google.com/docs/remote-config/)
|
|
12
|
+
|
|
13
|
+
## Dependency Injection
|
|
14
|
+
|
|
15
|
+
As a prerequisite, ensure that `AngularFire` has been added to your project via
|
|
16
|
+
```bash
|
|
17
|
+
ng add @angular/fire
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Provide a Performance instance and configuration in the application's `NgModule` (`app.module.ts`):
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { provideFirebaseApp, initializeApp } from '@angular/fire/app';
|
|
24
|
+
import { getRemoteConfig, provideRemoteConfig} from '@angular/fire/remote-config';
|
|
25
|
+
|
|
26
|
+
@NgModule({
|
|
27
|
+
imports: [
|
|
28
|
+
provideFirebaseApp(() => initializeApp(environment.firebase)),
|
|
29
|
+
provideRemoteConfig(() => getRemoteConfig()),
|
|
30
|
+
]
|
|
31
|
+
})
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Next inject it into your component:
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import { Component, inject} from '@angular/core';
|
|
38
|
+
import { RemoteConfig } from '@angular/fire/remote-config';
|
|
39
|
+
|
|
40
|
+
@Component({ ... })
|
|
41
|
+
export class RemoteConfigComponent {
|
|
42
|
+
private remoteConfig: RemoteConfig = inject(RemoteConfig);
|
|
43
|
+
...
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Firebase API
|
|
48
|
+
|
|
49
|
+
The [Remote Config documentation](https://firebase.google.com/docs/reference/js/remote-config) is available on the Firebase website.
|
|
50
|
+
|
|
51
|
+
## Convenience observables
|
|
52
|
+
|
|
53
|
+
Coming soon.
|
package/docs/storage.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
<img align="right" width="30%" src="images/storage-illo_1x.png">
|
|
2
|
+
|
|
3
|
+
<small>
|
|
4
|
+
<a href="https://github.com/angular/angularfire">AngularFire</a> ❱ <a href="../README.md#developer-guide">Developer Guide</a> ❱ Realtime Cloud Storage
|
|
5
|
+
</small>
|
|
6
|
+
|
|
7
|
+
# Cloud Storage
|
|
8
|
+
|
|
9
|
+
Cloud Storage allows developers to upload and share user generated content such as images, video and more. Data is stored in Google Cloud Storage.
|
|
10
|
+
|
|
11
|
+
[Learn more](https://firebase.google.com/docs/storage)
|
|
12
|
+
|
|
13
|
+
## Dependency Injection
|
|
14
|
+
|
|
15
|
+
AngularFire allows you to work with Firebase Storage via Angular's Dependency Injection.
|
|
16
|
+
|
|
17
|
+
As a prerequisite, ensure that `AngularFire` has been added to your project via
|
|
18
|
+
```bash
|
|
19
|
+
ng add @angular/fire
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Provide a Firebase Storage instance in the application's `NgModule` (`app.module.ts`):
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import { provideFirebaseApp, initializeApp } from '@angular/fire/app';
|
|
26
|
+
import { getStorage, provideStorage } from '@angular/fire/storage';
|
|
27
|
+
|
|
28
|
+
@NgModule({
|
|
29
|
+
imports: [
|
|
30
|
+
provideFirebaseApp(() => initializeApp(environment.firebase)),
|
|
31
|
+
provideStorage(() => getStorage()),
|
|
32
|
+
]
|
|
33
|
+
})
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Next inject it into your component:
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import { Component, inject} from '@angular/core';
|
|
40
|
+
import { Storage } from '@angular/fire/storage';
|
|
41
|
+
|
|
42
|
+
@Component({ ... })
|
|
43
|
+
export class StorageComponent {
|
|
44
|
+
private storage: Storage = inject(Storage);
|
|
45
|
+
...
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
## Firebase API
|
|
51
|
+
|
|
52
|
+
AngularFire wraps the Firebase JS SDK to ensure proper functionality in Angular, while providing the same API.
|
|
53
|
+
|
|
54
|
+
Update the imports from `import { ... } from 'firebase/storage'` to `import { ... } from '@angular/fire/storage'` and follow the offical documentation.
|
|
55
|
+
|
|
56
|
+
[Getting Started](https://firebase.google.com/docs/storage/web/start) | [API Reference](https://firebase.google.com/docs/reference/js/storage)
|
|
57
|
+
|
|
58
|
+
## File Upload Example
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
import { Component, inject } from '@angular/core';
|
|
62
|
+
import { Storage, ref, uploadBytesResumable } from '@angular/fire/storage';
|
|
63
|
+
|
|
64
|
+
@Component({
|
|
65
|
+
selector: 'app-storage',
|
|
66
|
+
template: `
|
|
67
|
+
<h1>Storage</h1>
|
|
68
|
+
<label for="fileUpload">Choose a File</label>
|
|
69
|
+
<input id="fileUpload" type="file" #upload>
|
|
70
|
+
<button (click)="uploadFile(upload)">Upload</button>
|
|
71
|
+
`,
|
|
72
|
+
})
|
|
73
|
+
export class StorageComponent {
|
|
74
|
+
private readonly storage: Storage = inject(Storage);
|
|
75
|
+
|
|
76
|
+
uploadFile(input: HTMLInputElement) {
|
|
77
|
+
if (!input.files) return
|
|
78
|
+
|
|
79
|
+
const files: FileList = input.files;
|
|
80
|
+
|
|
81
|
+
for (let i = 0; i < files.length; i++) {
|
|
82
|
+
const file = files.item(i);
|
|
83
|
+
if (file) {
|
|
84
|
+
const storageRef = ref(this.storage, file.name);
|
|
85
|
+
uploadBytesResumable(storageRef, file);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
```
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Deploying your Universal application on Cloud Functions for Firebase
|
|
2
|
+
|
|
3
|
+
After [setting up your application with Angular Universal as outlined in Getting Started](getting-started.md), you're now ready to build your application for Firebase Hosting & Cloud Functions.
|
|
4
|
+
|
|
5
|
+
> Cloud Functions for Firebase lets you automatically run backend code in response to events triggered by Firebase features and HTTPS requests. Your code is stored in Google's cloud and runs in a managed environment. There's no need to manage and scale your own servers. [Learn more about Cloud Functions for Firebase](https://firebase.google.com/docs/functions/).
|
|
6
|
+
|
|
7
|
+
If you don't already have the Firebase CLI installed, do so:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm i -g firebase-tools
|
|
11
|
+
firebase login
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Then inside your project root, setup your Firebase CLI project:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
firebase init
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Configure whichever features you'd want to manage but make sure to select at least `functions` and `hosting`. Choose Typescript for Cloud Functions and use the default `public` directory for Hosting.
|
|
21
|
+
|
|
22
|
+
After you're configured, you should now see a `firebase.json` file in your project root. Let's add the following `rewrites` directive to it:
|
|
23
|
+
|
|
24
|
+
```js
|
|
25
|
+
{
|
|
26
|
+
// ...
|
|
27
|
+
"hosting": {
|
|
28
|
+
// ...
|
|
29
|
+
"rewrites": [
|
|
30
|
+
{ "source": "**", "function": "universal" }
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
This will inform Firebase Hosting that it should proxy all requests to Cloud Functions, if a file isn't already present in the hosting directory.
|
|
37
|
+
|
|
38
|
+
Let's go ahead and modify your `package.json` to build for Cloud Functions:
|
|
39
|
+
|
|
40
|
+
```js
|
|
41
|
+
"scripts": {
|
|
42
|
+
// ... omitted
|
|
43
|
+
"build": "ng build && npm run build:ssr && npm run copy:hosting && npm run build:functions",
|
|
44
|
+
"copy:hosting": "cp -r ./dist/YOUR_PROJECT_NAME/* ./public && rm -f ./public/index.html",
|
|
45
|
+
"build:functions": "npm run --prefix functions build"
|
|
46
|
+
},
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Change the build script in your `functions/package.json` to the following:
|
|
50
|
+
|
|
51
|
+
```js
|
|
52
|
+
"scripts": {
|
|
53
|
+
// ... omitted
|
|
54
|
+
"build": "rm -rf ./dist && cp -r ../dist . && tsc",
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
You will either need to install the dependencies from the `functions/package.json` or add them to your root `package.json`.
|
|
59
|
+
|
|
60
|
+
Finally, add the following to your `functions/src/index.ts`:
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
export const universal = functions.https.onRequest((request, response) => {
|
|
64
|
+
require(`${process.cwd()}/dist/YOUR_PROJECT_NAME/server/main`).app()(request, response);
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
In the `server.ts` file generated by the Angular CLI ensure that the `index.html` is being read from the correct place.
|
|
69
|
+
|
|
70
|
+
As of writing the Angular CLI generates:
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
const indexHtml = existsSync(join(distFolder, 'index.original.html')) ? 'index.original.html' : 'index.html';
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
this needs to be changed to:
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
const indexHtml = existsSync(join(distFolder, 'index.original.html')) ? 'index.original.html' : join(distFolder, 'index.html');
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
So that the `index.html` is read from the correct `dist` folder.
|
|
83
|
+
|
|
84
|
+
You should now be able to run `npm run build` to build your project for Firebase Hosting and Cloud Functions.
|
|
85
|
+
|
|
86
|
+
To test, spin up the emulator with `firebase serve`. Once you've confirmed its working go ahead and `firebase deploy`.
|
|
87
|
+
|
|
88
|
+
_Note: Universal will now SSR your application and serve it, depending on how you have your deployment setup some assets may fail to
|
|
89
|
+
serve because the Cloud Function is at a different route than the `APP_BASE_REF` configured._
|
|
90
|
+
|
|
91
|
+
### [Next Step: Prerendering your Universal application](prerendering.md)
|
|
92
|
+
|
|
93
|
+
## Additional Resources
|
|
94
|
+
|
|
95
|
+
- [Universal Starter Template](https://github.com/angular/universal-starter)
|
|
96
|
+
- [FireShip: Angular Universal SSR with Firebase](https://fireship.io/lessons/angular-universal-firebase/)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Getting started with AngularFire and Universal
|
|
2
|
+
|
|
3
|
+
Server-side rendering (SSR) is the process of converting a JavaScript app to plain HTML at request-time, allowing search engine crawlers and linkbots to understand page content reliably.
|
|
4
|
+
|
|
5
|
+
## 0. Prerequisites
|
|
6
|
+
|
|
7
|
+
- @angular/cli >= v6.0
|
|
8
|
+
- @angular/fire >= v5.0.0
|
|
9
|
+
|
|
10
|
+
## 1. Add Angular Universal to your project
|
|
11
|
+
|
|
12
|
+
Follow the steps from the [Angular Universal Tutorial](https://angular.io/guide/universal) to add Universal to your
|
|
13
|
+
project.
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
ng add @nguniversal/express-engine
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
This will create all the files you need and setup all the configurations for Universal rendering for your application.
|
|
20
|
+
|
|
21
|
+
## 2. Next Steps
|
|
22
|
+
|
|
23
|
+
Test your app locally by running `npm run dev:ssr`.
|
|
24
|
+
|
|
25
|
+
_Note: `dev:ssr` is a command that was added to your `package.json` by the `ng add` command that will run the dev server
|
|
26
|
+
for your Angular with Universal._
|
|
27
|
+
|
|
28
|
+
### [Next Step: Deploying your Universal application on Cloud Functions for Firebase](cloud-functions.md)
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Prerendering your Universal application
|
|
2
|
+
|
|
3
|
+
Prerendering a Universal application allows us to generate the HTML before the user requests it; increasing performance and decreasing cost. Let's configure your application to prerender and staticly serve it's most commonly accessed routes on Firebase Hosting.
|
|
4
|
+
|
|
5
|
+
First create a `static.paths.js` in your project root, which lists the URLs you'd want to prerender:
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
export default [
|
|
9
|
+
'/',
|
|
10
|
+
'/another_path',
|
|
11
|
+
'/yet_another_path'
|
|
12
|
+
];
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Let's install `mkdir-recursive` to make the next step a little easier:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm i --save-dev mkdir-recursive
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Now replace the listener in your `server.ts` with the following:
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import { readFileSync, writeFileSync, existsSync } from 'fs';
|
|
25
|
+
import { renderModuleFactory } from '@angular/platform-server';
|
|
26
|
+
import { mkdirSync } from 'mkdir-recursive';
|
|
27
|
+
|
|
28
|
+
if (process.env.PRERENDER) {
|
|
29
|
+
|
|
30
|
+
const routes = require('./static.paths').default;
|
|
31
|
+
Promise.all(
|
|
32
|
+
routes.map(route =>
|
|
33
|
+
renderModuleFactory(AppServerModuleNgFactory, {
|
|
34
|
+
document: template,
|
|
35
|
+
url: route,
|
|
36
|
+
extraProviders: [
|
|
37
|
+
provideModuleMap(LAZY_MODULE_MAP)
|
|
38
|
+
]
|
|
39
|
+
}).then(html => [route, html])
|
|
40
|
+
)
|
|
41
|
+
).then(results => {
|
|
42
|
+
results.forEach(([route, html]) => {
|
|
43
|
+
const fullPath = join('./public', route);
|
|
44
|
+
if (!existsSync(fullPath)) { mkdirSync(fullPath); }
|
|
45
|
+
writeFileSync(join(fullPath, 'index.html'), html);
|
|
46
|
+
});
|
|
47
|
+
process.exit();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
} else if (!process.env.FUNCTION_NAME) {
|
|
51
|
+
|
|
52
|
+
// If we're not in the Cloud Functions environment, spin up a Node server
|
|
53
|
+
const PORT = process.env.PORT || 4000;
|
|
54
|
+
app.listen(PORT, () => {
|
|
55
|
+
console.log(`Node server listening on http://localhost:${PORT}`);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Now if the `PRERENDER` environment variable is passed any value, instead of serving your application it will iterate over the paths in `static.paths.js`, render them, and write them to your `public` directory. *You could always make this a seperate script.*
|
|
61
|
+
|
|
62
|
+
Finally make some modifications to your `package.json`, to prerender your content when you build:
|
|
63
|
+
|
|
64
|
+
```js
|
|
65
|
+
"scripts": {
|
|
66
|
+
// ... omitted
|
|
67
|
+
"build": "ng build && npm run copy:hosting && npm run build:functions && npm run prerender:ssr",
|
|
68
|
+
"prerender:ssr": "PRERENDER=1 node dist/YOUR_PROJECT_NAME-webpack/server.js",
|
|
69
|
+
},
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Now when you run `npm run build` the prerendered content should be available in your `/public` directory, ready for deployment on Firebase Hosting.
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# Upgrading to AngularFire2 4.0
|
|
2
|
+
|
|
3
|
+
AngularFire2 4.0 is a refactor of the AngularFire2 package which implements
|
|
4
|
+
@NgModule, simplifies authentication, and better supports Angular 4.
|
|
5
|
+
|
|
6
|
+
### Removing `AngularFire` for Modularity
|
|
7
|
+
|
|
8
|
+
Prior to 4.0, AngularFire2 did not take advantage of the Firebase SDK's modularity for tree shaking. The `AngularFire` service has now been removed and the library is broken up into smaller `@NgModule`s:
|
|
9
|
+
|
|
10
|
+
* `AngularFireModule`
|
|
11
|
+
* `AngularFireDatabaseModule`
|
|
12
|
+
* `AngularFireAuthModule`
|
|
13
|
+
|
|
14
|
+
When upgrading, replace calls to `AngularFire.database` and `AngularFire.auth` with `AngularFireDatabase` and `AngularFireAuth` respectively.
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
constructor(af: AngularFire) {
|
|
18
|
+
af.database.list('foo');
|
|
19
|
+
af.auth;
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
Should now be:
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
constructor(db: AngularFireDatabase, afAuth: AngularFireAuth) {
|
|
26
|
+
db.list('foo');
|
|
27
|
+
afAuth.authState;
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Simplified Authentication API
|
|
32
|
+
|
|
33
|
+
In 4.0 we've reduced the complexity of the auth module by providing only [`firebase.User`](https://firebase.google.com/docs/reference/js/firebase.User) observers (`AngularFireAuth.authState`, `AngularFireAuth.idToken`) and cutting the methods that were wrapping the Firebase SDK.
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import { AngularFireAuth } from 'angularfire2/auth';
|
|
38
|
+
// Do not import from 'firebase' as you'd lose the tree shaking benefits
|
|
39
|
+
import firebase from 'firebase/app';
|
|
40
|
+
...
|
|
41
|
+
|
|
42
|
+
user: Observable<firebase.User>;
|
|
43
|
+
constructor(afAuth: AngularFireAuth) {
|
|
44
|
+
this.user = afAuth.authState; // only triggered on sign-in/out (for old behavior use .idToken)
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
AngularFire2 exposes the raw Firebase Auth object via `AngularFireAuth.auth`. For actions like login, logout, user creation, etc. you should use the [methods available to `firebase.auth.Auth`](https://firebase.google.com/docs/reference/js/firebase.auth.Auth).
|
|
49
|
+
|
|
50
|
+
While convenient, the pre-configured login feature added unneeded complexity. `AngularFireModule.initializeApp` no longer takes a default sign in method. Sign in should be done with the Firebase SDK via `firebase.auth.Auth`:
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
login() {
|
|
54
|
+
this.afAuth.auth.signInWithPopup(new firebase.auth.GoogleAuthProvider());
|
|
55
|
+
}
|
|
56
|
+
logout() {
|
|
57
|
+
this.afAuth.auth.signOut();
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### FirebaseListFactory and FirebaseObjectFactory API Changes
|
|
62
|
+
|
|
63
|
+
If you directly use `FirebaseListFactory` or `FirebaseObjectFactory` you will no longer be able to pass in a string, it will instead expect a Firebase database reference.
|
|
64
|
+
|
|
65
|
+
## Putting this all together
|
|
66
|
+
|
|
67
|
+
Here's an example of what AngularFire2 4.0 looks like:
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
import { NgModule, Component } from '@angular/core';
|
|
71
|
+
import { Observable } from 'rxjs/Observable';
|
|
72
|
+
import { AngularFireModule } from 'angularfire2';
|
|
73
|
+
import { AngularFireDatabaseModule, AngularFireDatabase, FirebaseListObservable } from 'angularfire2/database';
|
|
74
|
+
import { AngularFireAuthModule, AngularFireAuth } from 'angularfire2/auth';
|
|
75
|
+
import { environment } from '../environments/environment';
|
|
76
|
+
|
|
77
|
+
// Do not import from 'firebase' as you'd lose the tree shaking benefits
|
|
78
|
+
import firebase from 'firebase/app';
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
@NgModule({
|
|
82
|
+
declarations: [ App ],
|
|
83
|
+
exports: [ App ],
|
|
84
|
+
imports: [
|
|
85
|
+
AngularFireModule.initializeApp(environment.firebase, 'my-app'),
|
|
86
|
+
AngularFireDatabaseModule,
|
|
87
|
+
AngularFireAuthModule
|
|
88
|
+
],
|
|
89
|
+
bootstrap: [ App ]
|
|
90
|
+
})
|
|
91
|
+
export class MyModule { }
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
@Component({
|
|
97
|
+
selector: 'my-app',
|
|
98
|
+
template: `
|
|
99
|
+
<div> {{ (items | async)? | json }} </div>
|
|
100
|
+
<div> {{ (user | async)? | json }} </div>
|
|
101
|
+
<button (click)="login()">Login</button>
|
|
102
|
+
<button (click)="logout()">Logout</button>
|
|
103
|
+
`
|
|
104
|
+
})
|
|
105
|
+
export class App {
|
|
106
|
+
user: Observable<firebase.User>;
|
|
107
|
+
items: FirebaseListObservable<any[]>;
|
|
108
|
+
constructor(afAuth: AngularFireAuth, db: AngularFireDatabase) {
|
|
109
|
+
this.user = afAuth.authState;
|
|
110
|
+
this.items = db.list('items');
|
|
111
|
+
}
|
|
112
|
+
login() {
|
|
113
|
+
this.afAuth.auth.signInWithPopup(new firebase.auth.GoogleAuthProvider());
|
|
114
|
+
}
|
|
115
|
+
logout() {
|
|
116
|
+
this.afAuth.auth.signOut();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
```
|