Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(release): 7.0.3 #2915

Merged
merged 20 commits into from
Sep 2, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Cleaning up framework logging
  • Loading branch information
jamesdaniels committed Sep 2, 2021
commit b278d728ae981923e14fd2eaa5549ff264b7d8cc
2 changes: 1 addition & 1 deletion sample/angular.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions sample/src/app/auth/auth.component.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion src/analytics/analytics.module.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { NgModule, Optional, NgZone, InjectionToken, ModuleWithProviders, APP_INITIALIZER } from '@angular/core';
import { Analytics as FirebaseAnalytics, isSupported } from 'firebase/analytics';
import { ɵgetDefaultInstanceOf, ɵmemoizeInstance, ɵAngularFireSchedulers } from '@angular/fire';
import { ɵgetDefaultInstanceOf, ɵmemoizeInstance, ɵAngularFireSchedulers, VERSION } from '@angular/fire';
import { Analytics, ANALYTICS_PROVIDER_NAME, AnalyticsInstances } from './analytics';
import { FirebaseApps, FirebaseApp } from '@angular/fire/app';
import { registerVersion } from 'firebase/app';

const PROVIDED_ANALYTICS_INSTANCES = new InjectionToken<Analytics[]>('angularfire2.analytics-instances');
const IS_SUPPORTED = new InjectionToken<boolean>('angularfire2.analytics.isSupported');
Expand Down Expand Up @@ -52,6 +53,9 @@ const DEFAULT_ANALYTICS_INSTANCE_PROVIDER = {
]
})
export class AnalyticsModule {
constructor() {
registerVersion('angularfire', VERSION.full, 'analytics');
}
}

export function provideAnalytics(fn: () => FirebaseAnalytics): ModuleWithProviders<AnalyticsModule> {
Expand Down
8 changes: 6 additions & 2 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import {
Inject,
InjectionToken,
ModuleWithProviders,
NgModule,
NgZone,
Optional,
PLATFORM_ID,
VERSION as NG_VERSION,
} from '@angular/core';
import { FirebaseApp as IFirebaseApp, getApp, registerVersion } from 'firebase/app';
Expand Down Expand Up @@ -54,9 +56,11 @@ export function firebaseAppFactory(fn: () => IFirebaseApp) {
]
})
export class FirebaseAppModule {
constructor() {
// tslint:disable-next-line:ban-types
constructor(@Inject(PLATFORM_ID) platformId: Object) {
registerVersion('angularfire', VERSION.full, 'core');
registerVersion('angular', NG_VERSION.full);
registerVersion('angularfire', VERSION.full, 'app');
registerVersion('angular', NG_VERSION.full, platformId.toString());
}
}

Expand Down
22 changes: 18 additions & 4 deletions src/auth/auth.module.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
import { NgModule, Optional, NgZone, InjectionToken, ModuleWithProviders } from '@angular/core';
import { NgModule, Optional, NgZone, InjectionToken, ModuleWithProviders, PLATFORM_ID } from '@angular/core';
import { Auth as FirebaseAuth } from 'firebase/auth';
import { ɵgetDefaultInstanceOf, ɵmemoizeInstance, ɵAngularFireSchedulers } from '@angular/fire';
import { ɵgetDefaultInstanceOf, ɵmemoizeInstance, ɵAngularFireSchedulers, VERSION } from '@angular/fire';
import { Auth, AuthInstances, AUTH_PROVIDER_NAME } from './auth';
import { FirebaseApps, FirebaseApp } from '@angular/fire/app';
import { registerVersion } from 'firebase/app';

export const PROVIDED_AUTH_INSTANCES = new InjectionToken<Auth[]>('angularfire2.auth-instances');

export function defaultAuthInstanceFactory(provided: FirebaseAuth[]|undefined, defaultApp: FirebaseApp) {
export function defaultAuthInstanceFactory(
provided: FirebaseAuth[]|undefined,
defaultApp: FirebaseApp,
// tslint:disable-next-line:ban-types
platformId: Object
) {
const defaultAuth = ɵgetDefaultInstanceOf<FirebaseAuth>(AUTH_PROVIDER_NAME, provided, defaultApp);
(defaultAuth as any)._logFramework(`angularfire-${platformId}`);
return new Auth(defaultAuth);
}

export function authInstanceFactory(fn: () => FirebaseAuth) {
return (zone: NgZone) => {
// tslint:disable-next-line:ban-types
return (zone: NgZone, platformId: Object) => {
const auth = ɵmemoizeInstance<FirebaseAuth>(fn, zone);
(auth as any)._logFramework(`angularfire-${platformId}`);
return new Auth(auth);
};
}
Expand All @@ -31,6 +40,7 @@ const DEFAULT_AUTH_INSTANCE_PROVIDER = {
deps: [
[new Optional(), PROVIDED_AUTH_INSTANCES ],
FirebaseApp,
PLATFORM_ID,
]
};

Expand All @@ -41,6 +51,9 @@ const DEFAULT_AUTH_INSTANCE_PROVIDER = {
]
})
export class AuthModule {
constructor() {
registerVersion('angularfire', VERSION.full, 'auth');
}
}

export function provideAuth(fn: () => FirebaseAuth): ModuleWithProviders<AuthModule> {
Expand All @@ -52,6 +65,7 @@ export function provideAuth(fn: () => FirebaseAuth): ModuleWithProviders<AuthMod
multi: true,
deps: [
NgZone,
PLATFORM_ID,
ɵAngularFireSchedulers,
FirebaseApps,
]
Expand Down
8 changes: 6 additions & 2 deletions src/auth/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Auth as FirebaseAuth } from 'firebase/auth';
import { ɵgetAllInstancesOf } from '@angular/fire';
import { from, timer } from 'rxjs';
import { concatMap, distinct } from 'rxjs/operators';
import { Inject, PLATFORM_ID } from '@angular/core';

export const AUTH_PROVIDER_NAME = 'auth';

Expand All @@ -19,8 +20,11 @@ export class Auth {
export interface AuthInstances extends Array<FirebaseAuth> {}

export class AuthInstances {
constructor() {
return ɵgetAllInstancesOf<FirebaseAuth>(AUTH_PROVIDER_NAME);
// tslint:disable-next-line:ban-types
constructor(@Inject(PLATFORM_ID) platformId: Object) {
const instances = ɵgetAllInstancesOf<FirebaseAuth>(AUTH_PROVIDER_NAME);
instances.forEach((it: any) => it._logFramework(`angularfire-${platformId}`));
return instances;
}
}

Expand Down
5 changes: 4 additions & 1 deletion src/compat/analytics/analytics.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { NgModule, Optional } from '@angular/core';
import { ScreenTrackingService } from './screen-tracking.service';
import { AngularFireAnalytics } from './analytics';
import { UserTrackingService } from './user-tracking.service';
import firebase from 'firebase/compat/app';
import { VERSION } from '@angular/fire';

@NgModule({
providers: [ AngularFireAnalytics ]
Expand All @@ -10,8 +12,9 @@ export class AngularFireAnalyticsModule {
constructor(
analytics: AngularFireAnalytics,
@Optional() screenTracking: ScreenTrackingService,
@Optional() userTracking: UserTrackingService
@Optional() userTracking: UserTrackingService,
) {
firebase.registerVersion('angularfire', VERSION.full, 'analytics-compat');
// calling anything on analytics will eagerly load the SDK
// tslint:disable-next-line:no-unused-expression
analytics.app.then(() => {});
Expand Down
3 changes: 3 additions & 0 deletions src/compat/analytics/screen-tracking.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { AngularFireAnalytics } from './analytics';
import { Title } from '@angular/platform-browser';
import { isPlatformBrowser } from '@angular/common';
import { UserTrackingService } from './user-tracking.service';
import firebase from 'firebase/compat/app';
import { VERSION } from '@angular/fire';

const FIREBASE_EVENT_ORIGIN_KEY = 'firebase_event_origin';
const FIREBASE_PREVIOUS_SCREEN_CLASS_KEY = 'firebase_previous_class';
Expand Down Expand Up @@ -66,6 +68,7 @@ export class ScreenTrackingService implements OnDestroy {
zone: NgZone,
@Optional() userTrackingService: UserTrackingService,
) {
firebase.registerVersion('angularfire', VERSION.full, 'compat-screen-tracking');
if (!router || !isPlatformBrowser(platformId)) {
return this;
}
Expand Down
4 changes: 3 additions & 1 deletion src/compat/analytics/user-tracking.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { Inject, Injectable, NgZone, OnDestroy, PLATFORM_ID } from '@angular/cor
import { AngularFireAnalytics } from './analytics';
import { AngularFireAuth } from '@angular/fire/compat/auth';
import { Subscription } from 'rxjs';
import firebase from 'firebase/compat/app';
import { VERSION } from '@angular/fire';

@Injectable()
export class UserTrackingService implements OnDestroy {
Expand All @@ -18,7 +20,7 @@ export class UserTrackingService implements OnDestroy {
auth: AngularFireAuth,
zone: NgZone,
) {

firebase.registerVersion('angularfire', VERSION.full, 'compat-user-tracking');
if (!isPlatformServer(platformId)) {
let resolveInitialized;
this.initialized = zone.runOutsideAngular(() => new Promise(resolve => resolveInitialized = resolve));
Expand Down
8 changes: 7 additions & 1 deletion src/compat/auth-guard/auth-guard.module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { NgModule } from '@angular/core';
import { AngularFireAuthGuard } from './auth-guard';
import firebase from 'firebase/compat/app';
import { VERSION } from '@angular/fire';

@NgModule({
providers: [ AngularFireAuthGuard ]
})
export class AngularFireAuthGuardModule { }
export class AngularFireAuthGuardModule {
constructor() {
firebase.registerVersion('angularfire', VERSION.full, 'auth-guard-compat');
}
}
14 changes: 12 additions & 2 deletions src/compat/auth/auth.module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
import { NgModule } from '@angular/core';
import { AngularFireAuth } from './auth';
import firebase from 'firebase/compat/app';
import { VERSION } from '@angular/fire';
import { FirebaseApp } from '@angular/fire/compat';

@NgModule({
providers: [ AngularFireAuth ]
providers: [{
provide: AngularFireAuth,
deps: [ FirebaseApp, ],
}]
})
export class AngularFireAuthModule { }
export class AngularFireAuthModule {
constructor() {
firebase.registerVersion('angularfire', VERSION.full, 'auth-compat');
}
}
5 changes: 4 additions & 1 deletion src/compat/auth/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ export const ɵauthFactory = (
app: FirebaseApp, zone: NgZone, useEmulator: UseEmulatorArguments|null,
tenantId: string, languageCode: string|null, useDeviceLanguage: boolean|null,
settings: firebase.auth.AuthSettings|null, persistence: string|null,
// tslint:disable-next-line:ban-types
platformId: Object,
) => ɵcacheInstance(`${app.name}.auth`, 'AngularFireAuth', app.name, () => {
const auth = zone.runOutsideAngular(() => app.auth());
(auth as any)._logFramework(`angularfire-${platformId}-compat`);
if (useEmulator) {
auth.useEmulator(...useEmulator);
}
Expand Down Expand Up @@ -100,7 +103,7 @@ export class AngularFireAuth {
observeOn(schedulers.outsideAngular),
switchMap(() => zone.runOutsideAngular(() => import('firebase/compat/auth'))),
map(() => ɵfirebaseAppFactory(options, zone, name)),
map(app => ɵauthFactory(app, zone, useEmulator, tenantId, languageCode, useDeviceLanguage, settings, persistence)),
map(app => ɵauthFactory(app, zone, useEmulator, tenantId, languageCode, useDeviceLanguage, settings, persistence, platformId)),
shareReplay({ bufferSize: 1, refCount: false }),
);

Expand Down
14 changes: 12 additions & 2 deletions src/compat/database/database.module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
import { NgModule } from '@angular/core';
import { AngularFireDatabase } from './database';
import firebase from 'firebase/compat/app';
import { VERSION } from '@angular/fire';
import { FirebaseApp } from '@angular/fire/compat';

@NgModule({
providers: [ AngularFireDatabase ]
providers: [{
provide: AngularFireDatabase,
deps: [ FirebaseApp, ],
}]
})
export class AngularFireDatabaseModule { }
export class AngularFireDatabaseModule {
constructor() {
firebase.registerVersion('angularfire', VERSION.full, 'rtdb-compat');
}
}
2 changes: 1 addition & 1 deletion src/compat/database/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class AngularFireDatabase {
const app = ɵfirebaseAppFactory(options, zone, name);

if (auth) {
ɵauthFactory(app, zone, useAuthEmulator, tenantId, languageCode, useDeviceLanguage, authSettings, persistence);
ɵauthFactory(app, zone, useAuthEmulator, tenantId, languageCode, useDeviceLanguage, authSettings, persistence, platformId);
}

this.database = ɵcacheInstance(`${app.name}.database.${databaseURL}`, 'AngularFireDatabase', app.name, () => {
Expand Down
5 changes: 3 additions & 2 deletions src/compat/firebase.app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ export class AngularFireModule {

// tslint:disable-next-line:ban-types
constructor(@Inject(PLATFORM_ID) platformId: Object) {
firebase.registerVersion('angularfire', VERSION.full, `compat-${platformId.toString()}`);
firebase.registerVersion('angular', NG_VERSION.full);
firebase.registerVersion('angularfire', VERSION.full, 'core');
firebase.registerVersion('angularfire', VERSION.full, 'app-compat');
firebase.registerVersion('angular', NG_VERSION.full, platformId.toString());
}
}
11 changes: 10 additions & 1 deletion src/compat/firestore/firestore.module.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
import { ModuleWithProviders, NgModule } from '@angular/core';
import { PersistenceSettings } from './interfaces';
import { AngularFirestore, ENABLE_PERSISTENCE, PERSISTENCE_SETTINGS } from './firestore';
import firebase from 'firebase/compat/app';
import { VERSION } from '@angular/fire';
import { FirebaseApp } from '@angular/fire/compat';

@NgModule({
providers: [ AngularFirestore ]
providers: [{
provide: AngularFirestore,
deps: [ FirebaseApp, ],
}]
})
export class AngularFirestoreModule {
constructor() {
firebase.registerVersion('angularfire', VERSION.full, 'fst-compat');
}
/**
* Attempt to enable persistent storage, if possible
*/
Expand Down
2 changes: 1 addition & 1 deletion src/compat/firestore/firestore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export class AngularFirestore {
const useEmulator: UseEmulatorArguments | null = _useEmulator;

if (auth) {
ɵauthFactory(app, zone, useAuthEmulator, tenantId, languageCode, useDeviceLanguage, authSettings, persistence);
ɵauthFactory(app, zone, useAuthEmulator, tenantId, languageCode, useDeviceLanguage, authSettings, persistence, platformId);
}

[this.firestore, this.persistenceEnabled$] = ɵcacheInstance(`${app.name}.firestore`, 'AngularFirestore', app.name, () => {
Expand Down
14 changes: 12 additions & 2 deletions src/compat/functions/functions.module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
import { NgModule } from '@angular/core';
import { AngularFireFunctions } from './functions';
import firebase from 'firebase/compat/app';
import { VERSION } from '@angular/fire';
import { FirebaseApp } from '@angular/fire/compat';

@NgModule({
providers: [ AngularFireFunctions ]
providers: [{
provide: AngularFireFunctions,
deps: [ FirebaseApp, ],
}]
})
export class AngularFireFunctionsModule { }
export class AngularFireFunctionsModule {
constructor() {
firebase.registerVersion('angularfire', VERSION.full, 'fn-compat');
}
}
14 changes: 12 additions & 2 deletions src/compat/messaging/messaging.module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
import { NgModule } from '@angular/core';
import { AngularFireMessaging } from './messaging';
import firebase from 'firebase/compat/app';
import { VERSION } from '@angular/fire';
import { FirebaseApp } from '@angular/fire/compat';

@NgModule({
providers: [ AngularFireMessaging ]
providers: [{
provide: AngularFireMessaging,
deps: [ FirebaseApp, ],
}]
})
export class AngularFireMessagingModule { }
export class AngularFireMessagingModule {
constructor() {
firebase.registerVersion('angularfire', VERSION.full, 'fcm-compat');
}
}
3 changes: 3 additions & 0 deletions src/compat/performance/performance.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { NgModule, Optional } from '@angular/core';
import { AngularFirePerformance } from './performance';
import { PerformanceMonitoringService } from './performance.service';
import firebase from 'firebase/compat/app';
import { VERSION } from '@angular/fire';

@NgModule({
providers: [ AngularFirePerformance ]
Expand All @@ -10,6 +12,7 @@ export class AngularFirePerformanceModule {
perf: AngularFirePerformance,
@Optional() _: PerformanceMonitoringService
) {
firebase.registerVersion('angularfire', VERSION.full, 'perf-compat');
// call anything here to get perf loading
// tslint:disable-next-line:no-unused-expression
perf.dataCollectionEnabled.then(() => {});
Expand Down
Loading