Skip to content

Commit 04b16b2

Browse files
committed
Bunch of stuff
1 parent 8ce95bf commit 04b16b2

File tree

28 files changed

+369
-261
lines changed

28 files changed

+369
-261
lines changed

docs/zones.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,26 @@ Observables, Promise-based APIs, and those with callbacks will purposely destabi
1414

1515
When using a Firebase or RxFire API without importing from AngularFire or if AngularFire APIs are used outside of an injection context you _may_ experience instability.
1616

17-
instability can be difficult to track down ([see Resolving zone pollution in the Angular docs](https://angular.dev/best-practices/zone-pollution)). To help with debugging, AngularFire emits warnings when it is unable to Zone wrap an API while in dev-mode. **Often these messages can be safely ignored** but we'd rather be verbose.
18-
1917
When an application is unstable change-detection, two-way binding, and rehydration may not work as expected—leading to both subtle and non-subtle bugs in your application. Further, server-side rendering (SSR) and static site generation (SSG/pre-rendering) may timeout or render a blank page.
2018

2119
There are a number of situations where AngularFire's Zone wrapping is inconsequential such adding/deleting/updating a document in response to user-input, signing a user in, calling a Cloud Function, etc. So long as no long-lived side-effects are kicked off, your application should be ok. Most Promise based APIs are fairly safe without zone wrapping.
20+
21+
## Logging
22+
23+
You may see a log warning, `Calling Firebase APIs outside of an Injection context may destabilize your application leading to subtle change-detection and hydration bugs. Find more at https://github.com/angular/angularfire/blob/main/docs/zones.md` when developing your application.
24+
25+
Instability can be difficult to track down. To help with debugging, AngularFire emits warnings when it is unable to Zone wrap an API while in dev-mode. **Often these messages can be safely ignored** but we'd rather be verbose.
26+
27+
There are three logging levels in AngularFire:
28+
29+
* **Silent**: when the logging level is set to silent only the above banner is displayed when AngularFire APIs are called outside of an injection context, this is the default when using Zoneless change-detection.
30+
* **Warn**: when the logging level is set to warn, only blocking reads, long-lived tasks, and APIs with high risk of destabilizing your application are called, this is the default when using ZoneJS.
31+
* **Verbose**: when the logging level is set to verbose, all AngularFire APIs called outside of an injection context are logged—helping you track down APIs that may be destabilizing your application
32+
33+
You can change the log-level like so:
34+
35+
```ts
36+
import { setLogLevel, LogLevel } from "@angular/fire";
37+
38+
setLogLevel(LogLevel.VERBOSE);
39+
```

sample/package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sample/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"@angular/common": "^19.0.0",
1616
"@angular/compiler": "^19.0.0",
1717
"@angular/core": "^19.0.0",
18-
"@angular/fire": "file:../angularfire/angular-fire-19.0.0.tgz",
18+
"@angular/fire": "file:../angular-fire-19.0.0.tgz",
1919
"@angular/forms": "^19.0.0",
2020
"@angular/platform-browser": "^19.0.0",
2121
"@angular/platform-browser-dynamic": "^19.0.0",

sample/src/main.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { bootstrapApplication } from '@angular/platform-browser';
22
import { config } from './app/app.config.client';
33
import { AppComponent } from './app/app.component';
4+
import { setLogLevel, LogLevel } from "@angular/fire";
5+
6+
setLogLevel(LogLevel.VERBOSE);
47

58
bootstrapApplication(AppComponent, config)
69
.catch((err) => console.error(err));

src/analytics/firebase.ts

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app-check/app-check.module.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ import {
1010
isDevMode,
1111
makeEnvironmentProviders,
1212
} from '@angular/core';
13-
import { VERSION, ɵAPP_CHECK_PROVIDER_NAME, ɵAngularFireSchedulers, ɵAppCheckInstances, ɵgetDefaultInstanceOf } from '@angular/fire';
13+
import { VERSION, ɵAngularFireSchedulers, ɵgetDefaultInstanceOf } from '@angular/fire';
1414
import { FirebaseApp, FirebaseApps } from '@angular/fire/app';
1515
import { registerVersion } from 'firebase/app';
1616
import { AppCheck as FirebaseAppCheck } from 'firebase/app-check';
17-
import { AppCheck } from './app-check';
17+
import { APP_CHECK_PROVIDER_NAME, AppCheck, AppCheckInstances } from './app-check';
1818

1919
export const PROVIDED_APP_CHECK_INSTANCES = new InjectionToken<AppCheck[]>('angularfire2.app-check-instances');
2020

2121
export function defaultAppCheckInstanceFactory(provided: FirebaseAppCheck[]|undefined, defaultApp: FirebaseApp) {
22-
const defaultAppCheck = ɵgetDefaultInstanceOf<FirebaseAppCheck>(ɵAPP_CHECK_PROVIDER_NAME, provided, defaultApp);
22+
const defaultAppCheck = ɵgetDefaultInstanceOf<FirebaseAppCheck>(APP_CHECK_PROVIDER_NAME, provided, defaultApp);
2323
return defaultAppCheck && new AppCheck(defaultAppCheck);
2424
}
2525

@@ -38,7 +38,7 @@ export function appCheckInstanceFactory(fn: (injector: Injector) => FirebaseAppC
3838
}
3939

4040
const APP_CHECK_INSTANCES_PROVIDER = {
41-
provide: ɵAppCheckInstances,
41+
provide: AppCheckInstances,
4242
deps: [
4343
[new Optional(), PROVIDED_APP_CHECK_INSTANCES ],
4444
]

src/app-check/app-check.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
import { ɵAPP_CHECK_PROVIDER_NAME, ɵgetAllInstancesOf } from '@angular/fire';
1+
import { ɵgetAllInstancesOf } from '@angular/fire';
22
import { AppCheck as FirebaseAppCheck } from 'firebase/app-check';
33
import { from, timer } from 'rxjs';
44
import { concatMap, distinct } from 'rxjs/operators';
55

6+
export const APP_CHECK_PROVIDER_NAME = 'app-check';
7+
68
// see notes in core/firebase.app.module.ts for why we're building the class like this
79
// eslint-disable-next-line @typescript-eslint/no-empty-interface
810
export interface AppCheck extends FirebaseAppCheck {}
@@ -13,7 +15,16 @@ export class AppCheck {
1315
}
1416
}
1517

18+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
19+
export interface AppCheckInstances extends Array<AppCheck> {}
20+
21+
export class AppCheckInstances {
22+
constructor() {
23+
return ɵgetAllInstancesOf<AppCheck>(APP_CHECK_PROVIDER_NAME);
24+
}
25+
}
26+
1627
export const appCheckInstance$ = timer(0, 300).pipe(
17-
concatMap(() => from(ɵgetAllInstancesOf<FirebaseAppCheck>(ɵAPP_CHECK_PROVIDER_NAME))),
28+
concatMap(() => from(ɵgetAllInstancesOf<FirebaseAppCheck>(APP_CHECK_PROVIDER_NAME))),
1829
distinct(),
1930
);

src/app-check/firebase.ts

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app-check/public_api.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
export { AppCheck, appCheckInstance$ } from './app-check';
2-
export { ɵAppCheckInstances as AppCheckInstances } from '@angular/fire';
1+
export { AppCheck, appCheckInstance$, AppCheckInstances } from './app-check';
32
export { provideAppCheck, AppCheckModule } from './app-check.module';
43
export * from './firebase';

src/auth/auth.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import {
88
makeEnvironmentProviders,
99
} from '@angular/core';
1010
import { VERSION, ɵAngularFireSchedulers, ɵgetDefaultInstanceOf } from '@angular/fire';
11-
import { ɵAppCheckInstances } from '@angular/fire';
1211
import { FirebaseApp, FirebaseApps } from '@angular/fire/app';
12+
import { AppCheckInstances } from '@angular/fire/app-check';
1313
import { registerVersion } from 'firebase/app';
1414
import { Auth as FirebaseAuth } from 'firebase/auth';
1515
import { AUTH_PROVIDER_NAME, Auth, AuthInstances } from './auth';
@@ -70,7 +70,7 @@ export function provideAuth(fn: (injector: Injector) => FirebaseAuth, ...deps: a
7070
Injector,
7171
ɵAngularFireSchedulers,
7272
FirebaseApps,
73-
[new Optional(), ɵAppCheckInstances ],
73+
[new Optional(), AppCheckInstances ],
7474
...deps,
7575
]
7676
}

0 commit comments

Comments
 (0)