UNPKG

21.5 kBJavaScriptView Raw
1(function (global, factory) {
2 typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('firebase/app'), require('rxjs'), require('rxjs/operators'), require('@angular/core'), require('@angular/fire')) :
3 typeof define === 'function' && define.amd ? define('@angular/fire/app', ['exports', 'firebase/app', 'rxjs', 'rxjs/operators', '@angular/core', '@angular/fire'], factory) :
4 (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.angular = global.angular || {}, global.angular.fire = global.angular.fire || {}, global.angular.fire.app = {}), global['firebase-app'], global.rxjs, global.rxjs.operators, global.ng.core, global.angular.fire));
5}(this, (function (exports, app, rxjs, operators, i0, fire) { 'use strict';
6
7 function _interopNamespace(e) {
8 if (e && e.__esModule) return e;
9 var n = Object.create(null);
10 if (e) {
11 Object.keys(e).forEach(function (k) {
12 if (k !== 'default') {
13 var d = Object.getOwnPropertyDescriptor(e, k);
14 Object.defineProperty(n, k, d.get ? d : {
15 enumerable: true,
16 get: function () {
17 return e[k];
18 }
19 });
20 }
21 });
22 }
23 n['default'] = e;
24 return Object.freeze(n);
25 }
26
27 var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
28
29 var FirebaseApp = /** @class */ (function () {
30 function FirebaseApp(app) {
31 return app;
32 }
33 return FirebaseApp;
34 }());
35 var FirebaseApps = /** @class */ (function () {
36 function FirebaseApps() {
37 return app.getApps();
38 }
39 return FirebaseApps;
40 }());
41 var firebaseApp$ = rxjs.timer(0, 300).pipe(operators.concatMap(function () { return rxjs.from(app.getApps()); }), operators.distinct());
42
43 /*! *****************************************************************************
44 Copyright (c) Microsoft Corporation.
45
46 Permission to use, copy, modify, and/or distribute this software for any
47 purpose with or without fee is hereby granted.
48
49 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
50 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
51 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
52 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
53 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
54 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
55 PERFORMANCE OF THIS SOFTWARE.
56 ***************************************************************************** */
57 /* global Reflect, Promise */
58 var extendStatics = function (d, b) {
59 extendStatics = Object.setPrototypeOf ||
60 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
61 function (d, b) { for (var p in b)
62 if (Object.prototype.hasOwnProperty.call(b, p))
63 d[p] = b[p]; };
64 return extendStatics(d, b);
65 };
66 function __extends(d, b) {
67 if (typeof b !== "function" && b !== null)
68 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
69 extendStatics(d, b);
70 function __() { this.constructor = d; }
71 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
72 }
73 var __assign = function () {
74 __assign = Object.assign || function __assign(t) {
75 for (var s, i = 1, n = arguments.length; i < n; i++) {
76 s = arguments[i];
77 for (var p in s)
78 if (Object.prototype.hasOwnProperty.call(s, p))
79 t[p] = s[p];
80 }
81 return t;
82 };
83 return __assign.apply(this, arguments);
84 };
85 function __rest(s, e) {
86 var t = {};
87 for (var p in s)
88 if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
89 t[p] = s[p];
90 if (s != null && typeof Object.getOwnPropertySymbols === "function")
91 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
92 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
93 t[p[i]] = s[p[i]];
94 }
95 return t;
96 }
97 function __decorate(decorators, target, key, desc) {
98 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
99 if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
100 r = Reflect.decorate(decorators, target, key, desc);
101 else
102 for (var i = decorators.length - 1; i >= 0; i--)
103 if (d = decorators[i])
104 r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
105 return c > 3 && r && Object.defineProperty(target, key, r), r;
106 }
107 function __param(paramIndex, decorator) {
108 return function (target, key) { decorator(target, key, paramIndex); };
109 }
110 function __metadata(metadataKey, metadataValue) {
111 if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
112 return Reflect.metadata(metadataKey, metadataValue);
113 }
114 function __awaiter(thisArg, _arguments, P, generator) {
115 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
116 return new (P || (P = Promise))(function (resolve, reject) {
117 function fulfilled(value) { try {
118 step(generator.next(value));
119 }
120 catch (e) {
121 reject(e);
122 } }
123 function rejected(value) { try {
124 step(generator["throw"](value));
125 }
126 catch (e) {
127 reject(e);
128 } }
129 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
130 step((generator = generator.apply(thisArg, _arguments || [])).next());
131 });
132 }
133 function __generator(thisArg, body) {
134 var _ = { label: 0, sent: function () { if (t[0] & 1)
135 throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
136 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
137 function verb(n) { return function (v) { return step([n, v]); }; }
138 function step(op) {
139 if (f)
140 throw new TypeError("Generator is already executing.");
141 while (_)
142 try {
143 if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
144 return t;
145 if (y = 0, t)
146 op = [op[0] & 2, t.value];
147 switch (op[0]) {
148 case 0:
149 case 1:
150 t = op;
151 break;
152 case 4:
153 _.label++;
154 return { value: op[1], done: false };
155 case 5:
156 _.label++;
157 y = op[1];
158 op = [0];
159 continue;
160 case 7:
161 op = _.ops.pop();
162 _.trys.pop();
163 continue;
164 default:
165 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
166 _ = 0;
167 continue;
168 }
169 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
170 _.label = op[1];
171 break;
172 }
173 if (op[0] === 6 && _.label < t[1]) {
174 _.label = t[1];
175 t = op;
176 break;
177 }
178 if (t && _.label < t[2]) {
179 _.label = t[2];
180 _.ops.push(op);
181 break;
182 }
183 if (t[2])
184 _.ops.pop();
185 _.trys.pop();
186 continue;
187 }
188 op = body.call(thisArg, _);
189 }
190 catch (e) {
191 op = [6, e];
192 y = 0;
193 }
194 finally {
195 f = t = 0;
196 }
197 if (op[0] & 5)
198 throw op[1];
199 return { value: op[0] ? op[1] : void 0, done: true };
200 }
201 }
202 var __createBinding = Object.create ? (function (o, m, k, k2) {
203 if (k2 === undefined)
204 k2 = k;
205 Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
206 }) : (function (o, m, k, k2) {
207 if (k2 === undefined)
208 k2 = k;
209 o[k2] = m[k];
210 });
211 function __exportStar(m, o) {
212 for (var p in m)
213 if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
214 __createBinding(o, m, p);
215 }
216 function __values(o) {
217 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
218 if (m)
219 return m.call(o);
220 if (o && typeof o.length === "number")
221 return {
222 next: function () {
223 if (o && i >= o.length)
224 o = void 0;
225 return { value: o && o[i++], done: !o };
226 }
227 };
228 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
229 }
230 function __read(o, n) {
231 var m = typeof Symbol === "function" && o[Symbol.iterator];
232 if (!m)
233 return o;
234 var i = m.call(o), r, ar = [], e;
235 try {
236 while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
237 ar.push(r.value);
238 }
239 catch (error) {
240 e = { error: error };
241 }
242 finally {
243 try {
244 if (r && !r.done && (m = i["return"]))
245 m.call(i);
246 }
247 finally {
248 if (e)
249 throw e.error;
250 }
251 }
252 return ar;
253 }
254 /** @deprecated */
255 function __spread() {
256 for (var ar = [], i = 0; i < arguments.length; i++)
257 ar = ar.concat(__read(arguments[i]));
258 return ar;
259 }
260 /** @deprecated */
261 function __spreadArrays() {
262 for (var s = 0, i = 0, il = arguments.length; i < il; i++)
263 s += arguments[i].length;
264 for (var r = Array(s), k = 0, i = 0; i < il; i++)
265 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
266 r[k] = a[j];
267 return r;
268 }
269 function __spreadArray(to, from) {
270 for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
271 to[j] = from[i];
272 return to;
273 }
274 function __await(v) {
275 return this instanceof __await ? (this.v = v, this) : new __await(v);
276 }
277 function __asyncGenerator(thisArg, _arguments, generator) {
278 if (!Symbol.asyncIterator)
279 throw new TypeError("Symbol.asyncIterator is not defined.");
280 var g = generator.apply(thisArg, _arguments || []), i, q = [];
281 return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
282 function verb(n) { if (g[n])
283 i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
284 function resume(n, v) { try {
285 step(g[n](v));
286 }
287 catch (e) {
288 settle(q[0][3], e);
289 } }
290 function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
291 function fulfill(value) { resume("next", value); }
292 function reject(value) { resume("throw", value); }
293 function settle(f, v) { if (f(v), q.shift(), q.length)
294 resume(q[0][0], q[0][1]); }
295 }
296 function __asyncDelegator(o) {
297 var i, p;
298 return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
299 function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
300 }
301 function __asyncValues(o) {
302 if (!Symbol.asyncIterator)
303 throw new TypeError("Symbol.asyncIterator is not defined.");
304 var m = o[Symbol.asyncIterator], i;
305 return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
306 function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
307 function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
308 }
309 function __makeTemplateObject(cooked, raw) {
310 if (Object.defineProperty) {
311 Object.defineProperty(cooked, "raw", { value: raw });
312 }
313 else {
314 cooked.raw = raw;
315 }
316 return cooked;
317 }
318 ;
319 var __setModuleDefault = Object.create ? (function (o, v) {
320 Object.defineProperty(o, "default", { enumerable: true, value: v });
321 }) : function (o, v) {
322 o["default"] = v;
323 };
324 function __importStar(mod) {
325 if (mod && mod.__esModule)
326 return mod;
327 var result = {};
328 if (mod != null)
329 for (var k in mod)
330 if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
331 __createBinding(result, mod, k);
332 __setModuleDefault(result, mod);
333 return result;
334 }
335 function __importDefault(mod) {
336 return (mod && mod.__esModule) ? mod : { default: mod };
337 }
338 function __classPrivateFieldGet(receiver, state, kind, f) {
339 if (kind === "a" && !f)
340 throw new TypeError("Private accessor was defined without a getter");
341 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
342 throw new TypeError("Cannot read private member from an object whose class did not declare it");
343 return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
344 }
345 function __classPrivateFieldSet(receiver, state, value, kind, f) {
346 if (kind === "m")
347 throw new TypeError("Private method is not writable");
348 if (kind === "a" && !f)
349 throw new TypeError("Private accessor was defined without a setter");
350 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
351 throw new TypeError("Cannot write private member to an object whose class did not declare it");
352 return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
353 }
354
355 function defaultFirebaseAppFactory(provided) {
356 // Use the provided app, if there is only one, otherwise fetch the default app
357 if (provided && provided.length === 1) {
358 return provided[0];
359 }
360 return new FirebaseApp(app.getApp());
361 }
362 // With FIREBASE_APPS I wanted to capture the default app instance, if it is initialized by
363 // the reserved URL; ɵPROVIDED_FIREBASE_APPS is not for public consumption and serves to ensure that all
364 // provideFirebaseApp(...) calls are satisfied before FirebaseApp$ or FirebaseApp is resolved
365 var PROVIDED_FIREBASE_APPS = new i0.InjectionToken('angularfire2._apps');
366 // Injecting FirebaseApp will now only inject the default Firebase App
367 // this allows allows beginners to import /__/firebase/init.js to auto initialize Firebase App
368 // from the reserved URL.
369 var DEFAULT_FIREBASE_APP_PROVIDER = {
370 provide: FirebaseApp,
371 useFactory: defaultFirebaseAppFactory,
372 deps: [
373 [new i0.Optional(), PROVIDED_FIREBASE_APPS],
374 ],
375 };
376 var FIREBASE_APPS_PROVIDER = {
377 provide: FirebaseApps,
378 deps: [
379 [new i0.Optional(), PROVIDED_FIREBASE_APPS],
380 ],
381 };
382 function firebaseAppFactory(fn) {
383 return function (zone, injector) {
384 var app = zone.runOutsideAngular(function () { return fn(injector); });
385 return new FirebaseApp(app);
386 };
387 }
388 var FirebaseAppModule = /** @class */ (function () {
389 // tslint:disable-next-line:ban-types
390 function FirebaseAppModule(platformId) {
391 app.registerVersion('angularfire', fire.VERSION.full, 'core');
392 app.registerVersion('angularfire', fire.VERSION.full, 'app');
393 app.registerVersion('angular', i0.VERSION.full, platformId.toString());
394 }
395 return FirebaseAppModule;
396 }());
397 FirebaseAppModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.3", ngImport: i0__namespace, type: FirebaseAppModule, deps: [{ token: i0.PLATFORM_ID }], target: i0__namespace.ɵɵFactoryTarget.NgModule });
398 FirebaseAppModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.1.3", ngImport: i0__namespace, type: FirebaseAppModule });
399 FirebaseAppModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.1.3", ngImport: i0__namespace, type: FirebaseAppModule, providers: [
400 DEFAULT_FIREBASE_APP_PROVIDER,
401 FIREBASE_APPS_PROVIDER,
402 ] });
403 i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.3", ngImport: i0__namespace, type: FirebaseAppModule, decorators: [{
404 type: i0.NgModule,
405 args: [{
406 providers: [
407 DEFAULT_FIREBASE_APP_PROVIDER,
408 FIREBASE_APPS_PROVIDER,
409 ]
410 }]
411 }], ctorParameters: function () {
412 return [{ type: Object, decorators: [{
413 type: i0.Inject,
414 args: [i0.PLATFORM_ID]
415 }] }];
416 } });
417 // Calling initializeApp({ ... }, 'name') multiple times will add more FirebaseApps into the FIREBASE_APPS
418 // injection scope. This allows developers to more easily work with multiple Firebase Applications. Downside
419 // is that DI for app name and options doesn't really make sense anymore.
420 function provideFirebaseApp(fn) {
421 var deps = [];
422 for (var _i = 1; _i < arguments.length; _i++) {
423 deps[_i - 1] = arguments[_i];
424 }
425 return {
426 ngModule: FirebaseAppModule,
427 providers: [{
428 provide: PROVIDED_FIREBASE_APPS,
429 useFactory: firebaseAppFactory(fn),
430 multi: true,
431 deps: __spreadArray([
432 i0.NgZone,
433 i0.Injector,
434 fire.ɵAngularFireSchedulers
435 ], __read(deps)),
436 }],
437 };
438 }
439
440 // DO NOT MODIFY, this file is autogenerated by tools/build.ts
441 var deleteApp = fire.ɵzoneWrap(app.deleteApp, true);
442 var getApp = fire.ɵzoneWrap(app.getApp, true);
443 var getApps = fire.ɵzoneWrap(app.getApps, true);
444 var initializeApp = fire.ɵzoneWrap(app.initializeApp, true);
445 var onLog = fire.ɵzoneWrap(app.onLog, true);
446 var registerVersion = fire.ɵzoneWrap(app.registerVersion, true);
447 var setLogLevel = fire.ɵzoneWrap(app.setLogLevel, true);
448
449 /**
450 * Generated bundle index. Do not edit.
451 */
452
453 exports.FirebaseApp = FirebaseApp;
454 exports.FirebaseAppModule = FirebaseAppModule;
455 exports.FirebaseApps = FirebaseApps;
456 exports.deleteApp = deleteApp;
457 exports.firebaseApp$ = firebaseApp$;
458 exports.getApp = getApp;
459 exports.getApps = getApps;
460 exports.initializeApp = initializeApp;
461 exports.onLog = onLog;
462 exports.provideFirebaseApp = provideFirebaseApp;
463 exports.registerVersion = registerVersion;
464 exports.setLogLevel = setLogLevel;
465 Object.keys(app).forEach(function (k) {
466 if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
467 enumerable: true,
468 get: function () {
469 return app[k];
470 }
471 });
472 });
473
474 Object.defineProperty(exports, '__esModule', { value: true });
475
476})));
477//# sourceMappingURL=angular-fire-app.umd.js.map