1 line
No EOL
9.2 KiB
Text
1 line
No EOL
9.2 KiB
Text
{"version":3,"file":"angular-fire-compat-messaging.js","sources":["../../../src/compat/messaging/base.ts","../../../src/compat/messaging/messaging.ts","../../../src/compat/messaging/messaging.module.ts","../../../src/compat/messaging/angular-fire-compat-messaging.ts"],"sourcesContent":["// DO NOT MODIFY, this file is autogenerated by tools/build.ts\n// Export a null object with the same keys as firebase/compat/messaging, so Proxy can work with proxy-polyfill in Internet Explorer\nexport const proxyPolyfillCompat = {\n deleteToken: null,\n getToken: null,\n onMessage: null,\n onBackgroundMessage: null,\n};\n","import { Inject, Injectable, InjectionToken, NgZone, Optional, PLATFORM_ID } from '@angular/core';\nimport firebase from 'firebase/compat/app';\nimport { concat, EMPTY, Observable, of } from 'rxjs';\nimport { catchError, defaultIfEmpty, map, mergeMap, observeOn, switchMap, switchMapTo, shareReplay, subscribeOn } from 'rxjs/operators';\nimport { ɵAngularFireSchedulers } from '@angular/fire';\nimport { ɵlazySDKProxy, ɵPromiseProxy, ɵapplyMixins } from '@angular/fire/compat';\nimport { ɵfirebaseAppFactory, FIREBASE_APP_NAME, FIREBASE_OPTIONS, ɵcacheInstance } from '@angular/fire/compat';\nimport { FirebaseOptions } from 'firebase/app';\nimport { proxyPolyfillCompat } from './base';\nimport { isSupported } from 'firebase/messaging';\n\nexport const VAPID_KEY = new InjectionToken<string>('angularfire2.messaging.vapid-key');\nexport const SERVICE_WORKER = new InjectionToken<Promise<ServiceWorkerRegistration>>('angularfire2.messaging.service-worker-registeration');\n\nexport interface AngularFireMessaging extends Omit<ɵPromiseProxy<firebase.messaging.Messaging>, 'deleteToken' | 'getToken' | 'requestPermission'> {\n}\n\n@Injectable({\n providedIn: 'any'\n})\nexport class AngularFireMessaging {\n\n public readonly requestPermission: Observable<NotificationPermission>;\n public readonly getToken: Observable<string | null>;\n public readonly tokenChanges: Observable<string | null>;\n public readonly messages: Observable<firebase.messaging.MessagePayload>;\n public readonly requestToken: Observable<string | null>;\n public readonly deleteToken: (token: string) => Observable<boolean>;\n\n constructor(\n @Inject(FIREBASE_OPTIONS) options: FirebaseOptions,\n @Optional() @Inject(FIREBASE_APP_NAME) name: string | null | undefined,\n // tslint:disable-next-line:ban-types\n @Inject(PLATFORM_ID) platformId: Object,\n zone: NgZone,\n schedulers: ɵAngularFireSchedulers,\n @Optional() @Inject(VAPID_KEY) vapidKey: string|null,\n @Optional() @Inject(SERVICE_WORKER) _serviceWorker: any,\n ) {\n const serviceWorker: Promise<ServiceWorkerRegistration> | null = _serviceWorker;\n\n const messaging = of(undefined).pipe(\n subscribeOn(schedulers.outsideAngular),\n observeOn(schedulers.insideAngular),\n switchMap(isSupported),\n switchMap(supported => supported ? import('firebase/compat/messaging') : EMPTY),\n map(() => ɵfirebaseAppFactory(options, zone, name)),\n switchMap(app => ɵcacheInstance(`${app.name}.messaging`, 'AngularFireMessaging', app.name, async () => {\n return app.messaging();\n }, [])),\n shareReplay({ bufferSize: 1, refCount: false })\n );\n\n\n this.requestPermission = messaging.pipe(\n subscribeOn(schedulers.outsideAngular),\n observeOn(schedulers.insideAngular),\n switchMap(() => Notification.requestPermission())\n );\n\n this.getToken = messaging.pipe(\n subscribeOn(schedulers.outsideAngular),\n observeOn(schedulers.insideAngular),\n switchMap(async messaging => {\n if (Notification.permission === 'granted') {\n const serviceWorkerRegistration = serviceWorker ? await serviceWorker : null;\n return await messaging.getToken({ vapidKey, serviceWorkerRegistration });\n } else {\n return null;\n }\n })\n );\n\n const notificationPermission$ = new Observable<string>(emitter => {\n navigator.permissions.query({ name: 'notifications' }).then(notificationPerm => {\n notificationPerm.onchange = () => emitter.next();\n });\n });\n\n\n const tokenChange$ = messaging.pipe(\n subscribeOn(schedulers.outsideAngular),\n observeOn(schedulers.insideAngular),\n switchMapTo(notificationPermission$),\n switchMapTo(this.getToken)\n );\n\n this.tokenChanges = messaging.pipe(\n subscribeOn(schedulers.outsideAngular),\n observeOn(schedulers.insideAngular),\n switchMap(() => concat(this.getToken, tokenChange$))\n );\n\n\n this.messages = messaging.pipe(\n subscribeOn(schedulers.outsideAngular),\n observeOn(schedulers.insideAngular),\n switchMap(messaging => new Observable<firebase.messaging.MessagePayload>(emitter =>\n messaging.onMessage(emitter)\n )),\n );\n\n this.requestToken = messaging.pipe(\n subscribeOn(schedulers.outsideAngular),\n observeOn(schedulers.insideAngular),\n switchMap(() => this.requestPermission),\n catchError(() => of(null)),\n mergeMap(() => this.tokenChanges)\n );\n\n this.deleteToken = () => messaging.pipe(\n subscribeOn(schedulers.outsideAngular),\n observeOn(schedulers.insideAngular),\n switchMap(messaging => messaging.deleteToken()),\n defaultIfEmpty(false)\n );\n\n return ɵlazySDKProxy(this, messaging, zone);\n }\n\n}\n\nɵapplyMixins(AngularFireMessaging, [proxyPolyfillCompat]);\n","import { NgModule } from '@angular/core';\nimport { AngularFireMessaging } from './messaging';\nimport firebase from 'firebase/compat/app';\nimport { VERSION } from '@angular/fire';\n\n@NgModule({\n providers: [ AngularFireMessaging ]\n})\nexport class AngularFireMessagingModule {\n constructor() {\n firebase.registerVersion('angularfire', VERSION.full, 'fcm-compat');\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;AACA;AACO,MAAM,mBAAmB,GAAG;IACjC,WAAW,EAAE,IAAI;IACjB,QAAQ,EAAE,IAAI;IACd,SAAS,EAAE,IAAI;IACf,mBAAmB,EAAE,IAAI;CAC1B;;MCIY,SAAS,GAAG,IAAI,cAAc,CAAS,kCAAkC,EAAE;MAC3E,cAAc,GAAG,IAAI,cAAc,CAAqC,qDAAqD,EAAE;MAQ/H,oBAAoB;IAS/B,YAC4B,OAAwB,EACX,IAA+B;;IAEjD,UAAkB,EACvC,IAAY,EACZ,UAAkC,EACH,QAAqB,EAChB,cAAmB;QAEvD,MAAM,aAAa,GAA8C,cAAc,CAAC;QAEhF,MAAM,SAAS,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC,IAAI,CAClC,W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