UNPKG

13.2 kBSource Map (JSON)View Raw
1{"version":3,"file":"angular-fire-compat.js","sources":["../../../src/compat/proxy.ts","../../../src/compat/firebase.app.ts","../../../src/compat/firebase.app.module.ts","../../../src/compat/cache.ts","../../../src/compat/angular-fire-compat.ts"],"sourcesContent":["import { NgZone } from '@angular/core';\nimport { Observable } from 'rxjs';\n\ntype MyFunction = (...args: any[]) => any;\ntype FunctionPropertyNames<T> = { [K in keyof T]: T[K] extends MyFunction ? K : never }[keyof T];\ntype ReturnTypeOrNever<T> = T extends MyFunction ? ReturnType<T> : never;\ntype ParametersOrNever<T> = T extends MyFunction ? Parameters<T> : never;\ntype PromiseReturningFunctionPropertyNames<T> = {\n [K in FunctionPropertyNames<T>]: ReturnTypeOrNever<T[K]> extends Promise<any> ? K : never\n}[FunctionPropertyNames<T>];\ntype NonPromiseReturningFunctionPropertyNames<T> = {\n [K in FunctionPropertyNames<T>]: ReturnTypeOrNever<T[K]> extends Promise<any> ? never : K\n}[FunctionPropertyNames<T>];\ntype NonFunctionPropertyNames<T> = { [K in keyof T]: T[K] extends MyFunction ? never : K }[keyof T];\n\nexport type ɵPromiseProxy<T> = { [K in NonFunctionPropertyNames<T>]: Promise<T[K]> } &\n { [K in NonPromiseReturningFunctionPropertyNames<T>]: (...args: ParametersOrNever<T[K]>) => Promise<ReturnTypeOrNever<T[K]>> } &\n { [K in PromiseReturningFunctionPropertyNames<T>]: T[K] };\n\n// DEBUG quick debugger function for inline logging that typescript doesn't complain about\n// wrote it for debugging the ɵlazySDKProxy, commenting out for now; should consider exposing a\n// verbose mode for AngularFire in a future release that uses something like this in multiple places\n// usage: () => log('something') || returnValue\n// const log = (...args: any[]): false => { console.log(...args); return false }\n\n// The problem here are things like ngOnDestroy are missing, then triggering the service\n// rather than dig too far; I'm capturing these as I go.\nconst noopFunctions = ['ngOnDestroy'];\n\n// INVESTIGATE should we make the Proxy revokable and do some cleanup?\n// right now it's fairly simple but I'm sure this will grow in complexity\nexport const ɵlazySDKProxy = (klass: any, observable: Observable<any>, zone: NgZone, options: {\n spy?: {\n get?: ((name: string, it: any) => void),\n apply?: ((name: string, args: any[], it: any) => void)\n }\n} = {}) => {\n return new Proxy(klass, {\n get: (_, name: string) => zone.runOutsideAngular(() => {\n if (klass[name]) {\n if (options?.spy?.get) {\n options.spy.get(name, klass[name]);\n }\n return klass[name];\n }\n if (noopFunctions.indexOf(name) > -1) {\n return () => {\n };\n }\n const promise = observable.toPromise().then(mod => {\n const ret = mod && mod[name];\n // TODO move to proper type guards\n if (typeof ret === 'function') {\n return ret.bind(mod);\n } else if (ret && ret.then) {\n return ret.then((res: any) => zone.run(() => res));\n } else {\n return zone.run(() => ret);\n }\n });\n // recurse the proxy\n return new Proxy(() => {}, {\n get: (_, name) => promise[name],\n // TODO handle callbacks as transparently as I can\n apply: (self, _, args) => promise.then(it => {\n const res = it && it(...args);\n if (options?.spy?.apply) {\n options.spy.apply(name, args, res);\n }\n return res;\n })\n }\n );\n })\n });\n};\n\nexport const ɵapplyMixins = (derivedCtor: any, constructors: any[]) => {\n constructors.forEach((baseCtor) => {\n Object.getOwnPropertyNames(baseCtor.prototype || baseCtor).forEach((name) => {\n Object.defineProperty(\n derivedCtor.prototype,\n name,\n Object.getOwnPropertyDescriptor(baseCtor.prototype || baseCtor, name)\n );\n });\n });\n};\n","import firebase from 'firebase/compat/app';\n\n// tslint:disable-next-line:no-empty-interface\nexport interface FirebaseApp extends firebase.app.App {}\n\nexport class FirebaseApp {\n constructor(app: firebase.app.App) {\n return app;\n }\n}\n","import {\n InjectionToken, Inject, isDevMode, ModuleWithProviders, NgModule, NgZone, Optional, PLATFORM_ID, VERSION as NG_VERSION, Version\n} from '@angular/core';\nimport firebase from 'firebase/compat/app';\nimport { FirebaseOptions, FirebaseAppSettings } from 'firebase/app';\nimport { VERSION } from '@angular/fire';\nimport { FirebaseApp } from './firebase.app';\n\nexport const FIREBASE_OPTIONS = new InjectionToken<FirebaseOptions>('angularfire2.app.options');\nexport const FIREBASE_APP_NAME = new InjectionToken<string | undefined>('angularfire2.app.name');\n\n\nexport function ɵfirebaseAppFactory(options: FirebaseOptions, zone: NgZone, nameOrConfig?: string | FirebaseAppSettings | null) {\n const name = typeof nameOrConfig === 'string' && nameOrConfig || '[DEFAULT]';\n const config = typeof nameOrConfig === 'object' && nameOrConfig || {};\n config.name = config.name || name;\n // Added any due to some inconsistency between @firebase/app and firebase types\n const existingApp = firebase.apps.filter(app => app && app.name === config.name)[0];\n // We support FirebaseConfig, initializeApp's public type only accepts string; need to cast as any\n // Could be solved with https://github.com/firebase/firebase-js-sdk/pull/1206\n const app = (existingApp || zone.runOutsideAngular(() => firebase.initializeApp(options, config as any)));\n try {\n if (JSON.stringify(options) !== JSON.stringify(app.options)) {\n const hmr = !!(module as any).hot;\n log('error', `${app.name} Firebase App already initialized with different options${hmr ? ', you may need to reload as Firebase is not HMR aware.' : '.'}`);\n }\n } catch (e) { }\n return new FirebaseApp(app);\n}\n\nconst log = (level: 'log'|'error'|'info'|'warn', ...args: any) => {\n if (isDevMode() && typeof console !== 'undefined') {\n console[level](...args);\n }\n};\n\nconst FIREBASE_APP_PROVIDER = {\n provide: FirebaseApp,\n useFactory: ɵfirebaseAppFactory,\n deps: [\n FIREBASE_OPTIONS,\n NgZone,\n [new Optional(), FIREBASE_APP_NAME]\n ]\n};\n\n@NgModule({\n providers: [FIREBASE_APP_PROVIDER]\n})\nexport class AngularFireModule {\n static initializeApp(options: FirebaseOptions, nameOrConfig?: string | FirebaseAppSettings): ModuleWithProviders<AngularFireModule> {\n return {\n ngModule: AngularFireModule,\n providers: [\n {provide: FIREBASE_OPTIONS, useValue: options},\n {provide: FIREBASE_APP_NAME, useValue: nameOrConfig}\n ]\n };\n }\n\n // tslint:disable-next-line:ban-types\n constructor(@Inject(PLATFORM_ID) platformId: Object) {\n firebase.registerVersion('angularfire', VERSION.full, 'core');\n firebase.registerVersion('angularfire', VERSION.full, 'app-compat');\n firebase.registerVersion('angular', NG_VERSION.full, platformId.toString());\n }\n}\n","import { isDevMode } from '@angular/core';\n\nexport function ɵcacheInstance<T>(cacheKey: any, moduleName: string, appName: string, fn: () => T, deps: any): T {\n const [, instance, cachedDeps] = globalThis.ɵAngularfireInstanceCache.find((it: any) => it[0] === cacheKey) || [];\n if (instance) {\n if (!matchDep(deps, cachedDeps)) {\n log('error', `${moduleName} was already initialized on the ${appName} Firebase App with different settings.${IS_HMR ? ' You may need to reload as Firebase is not HMR aware.' : ''}`);\n log('warn', {is: deps, was: cachedDeps});\n }\n return instance;\n } else {\n const newInstance = fn();\n globalThis.ɵAngularfireInstanceCache.push([cacheKey, newInstance, deps]);\n return newInstance;\n }\n}\n\nfunction matchDep(a: any, b: any) {\n try {\n return a.toString() === b.toString();\n } catch (_) {\n return a === b;\n }\n}\n\nconst IS_HMR = !!(module as any).hot;\n\nconst log = (level: 'log'|'error'|'info'|'warn', ...args: any) => {\n if (isDevMode() && typeof console !== 'undefined') {\n console[level](...args);\n }\n};\n\nglobalThis.ɵAngularfireInstanceCache ||= [];\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":["log","NG_VERSION"],"mappings":";;;;;AAmBA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA,MAAM,aAAa,GAAG,CAAC,aAAa,CAAC,CAAC;AAEtC;AACA;MACa,aAAa,GAAG,CAAC,KAAU,EAAE,UAA2B,EAAE,IAAY,EAAE,UAKjF,EAAE;IACJ,OAAO,IAAI,KAAK,CAAC,KAAK,EAAE;QACtB,GAAG,EAAE,CAAC,CAAC,EAAE,IAAY,KAAK,IAAI,CAAC,iBAAiB,CAAC;;YAC/C,IAAI,KAAK,CAAC,IAAI,CAAC,EAAE;gBACf,IAAI,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,GAAG,0CAAE,GAAG,EAAE;oBACrB,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;iBACpC;gBACD,OA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