UNPKG

25 kBJavaScriptView Raw
1(function (global, factory) {
2 typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('firebase/compat/app'), require('@angular/fire')) :
3 typeof define === 'function' && define.amd ? define('@angular/fire/compat', ['exports', '@angular/core', 'firebase/compat/app', '@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.compat = {}), global.ng.core, global.firebase, global.angular.fire));
5}(this, (function (exports, i0, firebase, fire) { 'use strict';
6
7 function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
9 function _interopNamespace(e) {
10 if (e && e.__esModule) return e;
11 var n = Object.create(null);
12 if (e) {
13 Object.keys(e).forEach(function (k) {
14 if (k !== 'default') {
15 var d = Object.getOwnPropertyDescriptor(e, k);
16 Object.defineProperty(n, k, d.get ? d : {
17 enumerable: true,
18 get: function () {
19 return e[k];
20 }
21 });
22 }
23 });
24 }
25 n['default'] = e;
26 return Object.freeze(n);
27 }
28
29 var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
30 var firebase__default = /*#__PURE__*/_interopDefaultLegacy(firebase);
31
32 /*! *****************************************************************************
33 Copyright (c) Microsoft Corporation.
34
35 Permission to use, copy, modify, and/or distribute this software for any
36 purpose with or without fee is hereby granted.
37
38 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
39 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
40 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
41 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
42 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
43 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
44 PERFORMANCE OF THIS SOFTWARE.
45 ***************************************************************************** */
46 /* global Reflect, Promise */
47 var extendStatics = function (d, b) {
48 extendStatics = Object.setPrototypeOf ||
49 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
50 function (d, b) { for (var p in b)
51 if (Object.prototype.hasOwnProperty.call(b, p))
52 d[p] = b[p]; };
53 return extendStatics(d, b);
54 };
55 function __extends(d, b) {
56 if (typeof b !== "function" && b !== null)
57 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
58 extendStatics(d, b);
59 function __() { this.constructor = d; }
60 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
61 }
62 var __assign = function () {
63 __assign = Object.assign || function __assign(t) {
64 for (var s, i = 1, n = arguments.length; i < n; i++) {
65 s = arguments[i];
66 for (var p in s)
67 if (Object.prototype.hasOwnProperty.call(s, p))
68 t[p] = s[p];
69 }
70 return t;
71 };
72 return __assign.apply(this, arguments);
73 };
74 function __rest(s, e) {
75 var t = {};
76 for (var p in s)
77 if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
78 t[p] = s[p];
79 if (s != null && typeof Object.getOwnPropertySymbols === "function")
80 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
81 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
82 t[p[i]] = s[p[i]];
83 }
84 return t;
85 }
86 function __decorate(decorators, target, key, desc) {
87 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
88 if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
89 r = Reflect.decorate(decorators, target, key, desc);
90 else
91 for (var i = decorators.length - 1; i >= 0; i--)
92 if (d = decorators[i])
93 r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
94 return c > 3 && r && Object.defineProperty(target, key, r), r;
95 }
96 function __param(paramIndex, decorator) {
97 return function (target, key) { decorator(target, key, paramIndex); };
98 }
99 function __metadata(metadataKey, metadataValue) {
100 if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
101 return Reflect.metadata(metadataKey, metadataValue);
102 }
103 function __awaiter(thisArg, _arguments, P, generator) {
104 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
105 return new (P || (P = Promise))(function (resolve, reject) {
106 function fulfilled(value) { try {
107 step(generator.next(value));
108 }
109 catch (e) {
110 reject(e);
111 } }
112 function rejected(value) { try {
113 step(generator["throw"](value));
114 }
115 catch (e) {
116 reject(e);
117 } }
118 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
119 step((generator = generator.apply(thisArg, _arguments || [])).next());
120 });
121 }
122 function __generator(thisArg, body) {
123 var _ = { label: 0, sent: function () { if (t[0] & 1)
124 throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
125 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
126 function verb(n) { return function (v) { return step([n, v]); }; }
127 function step(op) {
128 if (f)
129 throw new TypeError("Generator is already executing.");
130 while (_)
131 try {
132 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)
133 return t;
134 if (y = 0, t)
135 op = [op[0] & 2, t.value];
136 switch (op[0]) {
137 case 0:
138 case 1:
139 t = op;
140 break;
141 case 4:
142 _.label++;
143 return { value: op[1], done: false };
144 case 5:
145 _.label++;
146 y = op[1];
147 op = [0];
148 continue;
149 case 7:
150 op = _.ops.pop();
151 _.trys.pop();
152 continue;
153 default:
154 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
155 _ = 0;
156 continue;
157 }
158 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
159 _.label = op[1];
160 break;
161 }
162 if (op[0] === 6 && _.label < t[1]) {
163 _.label = t[1];
164 t = op;
165 break;
166 }
167 if (t && _.label < t[2]) {
168 _.label = t[2];
169 _.ops.push(op);
170 break;
171 }
172 if (t[2])
173 _.ops.pop();
174 _.trys.pop();
175 continue;
176 }
177 op = body.call(thisArg, _);
178 }
179 catch (e) {
180 op = [6, e];
181 y = 0;
182 }
183 finally {
184 f = t = 0;
185 }
186 if (op[0] & 5)
187 throw op[1];
188 return { value: op[0] ? op[1] : void 0, done: true };
189 }
190 }
191 var __createBinding = Object.create ? (function (o, m, k, k2) {
192 if (k2 === undefined)
193 k2 = k;
194 Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
195 }) : (function (o, m, k, k2) {
196 if (k2 === undefined)
197 k2 = k;
198 o[k2] = m[k];
199 });
200 function __exportStar(m, o) {
201 for (var p in m)
202 if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
203 __createBinding(o, m, p);
204 }
205 function __values(o) {
206 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
207 if (m)
208 return m.call(o);
209 if (o && typeof o.length === "number")
210 return {
211 next: function () {
212 if (o && i >= o.length)
213 o = void 0;
214 return { value: o && o[i++], done: !o };
215 }
216 };
217 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
218 }
219 function __read(o, n) {
220 var m = typeof Symbol === "function" && o[Symbol.iterator];
221 if (!m)
222 return o;
223 var i = m.call(o), r, ar = [], e;
224 try {
225 while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
226 ar.push(r.value);
227 }
228 catch (error) {
229 e = { error: error };
230 }
231 finally {
232 try {
233 if (r && !r.done && (m = i["return"]))
234 m.call(i);
235 }
236 finally {
237 if (e)
238 throw e.error;
239 }
240 }
241 return ar;
242 }
243 /** @deprecated */
244 function __spread() {
245 for (var ar = [], i = 0; i < arguments.length; i++)
246 ar = ar.concat(__read(arguments[i]));
247 return ar;
248 }
249 /** @deprecated */
250 function __spreadArrays() {
251 for (var s = 0, i = 0, il = arguments.length; i < il; i++)
252 s += arguments[i].length;
253 for (var r = Array(s), k = 0, i = 0; i < il; i++)
254 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
255 r[k] = a[j];
256 return r;
257 }
258 function __spreadArray(to, from) {
259 for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
260 to[j] = from[i];
261 return to;
262 }
263 function __await(v) {
264 return this instanceof __await ? (this.v = v, this) : new __await(v);
265 }
266 function __asyncGenerator(thisArg, _arguments, generator) {
267 if (!Symbol.asyncIterator)
268 throw new TypeError("Symbol.asyncIterator is not defined.");
269 var g = generator.apply(thisArg, _arguments || []), i, q = [];
270 return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
271 function verb(n) { if (g[n])
272 i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
273 function resume(n, v) { try {
274 step(g[n](v));
275 }
276 catch (e) {
277 settle(q[0][3], e);
278 } }
279 function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
280 function fulfill(value) { resume("next", value); }
281 function reject(value) { resume("throw", value); }
282 function settle(f, v) { if (f(v), q.shift(), q.length)
283 resume(q[0][0], q[0][1]); }
284 }
285 function __asyncDelegator(o) {
286 var i, p;
287 return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
288 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; }
289 }
290 function __asyncValues(o) {
291 if (!Symbol.asyncIterator)
292 throw new TypeError("Symbol.asyncIterator is not defined.");
293 var m = o[Symbol.asyncIterator], i;
294 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);
295 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); }); }; }
296 function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
297 }
298 function __makeTemplateObject(cooked, raw) {
299 if (Object.defineProperty) {
300 Object.defineProperty(cooked, "raw", { value: raw });
301 }
302 else {
303 cooked.raw = raw;
304 }
305 return cooked;
306 }
307 ;
308 var __setModuleDefault = Object.create ? (function (o, v) {
309 Object.defineProperty(o, "default", { enumerable: true, value: v });
310 }) : function (o, v) {
311 o["default"] = v;
312 };
313 function __importStar(mod) {
314 if (mod && mod.__esModule)
315 return mod;
316 var result = {};
317 if (mod != null)
318 for (var k in mod)
319 if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
320 __createBinding(result, mod, k);
321 __setModuleDefault(result, mod);
322 return result;
323 }
324 function __importDefault(mod) {
325 return (mod && mod.__esModule) ? mod : { default: mod };
326 }
327 function __classPrivateFieldGet(receiver, state, kind, f) {
328 if (kind === "a" && !f)
329 throw new TypeError("Private accessor was defined without a getter");
330 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
331 throw new TypeError("Cannot read private member from an object whose class did not declare it");
332 return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
333 }
334 function __classPrivateFieldSet(receiver, state, value, kind, f) {
335 if (kind === "m")
336 throw new TypeError("Private method is not writable");
337 if (kind === "a" && !f)
338 throw new TypeError("Private accessor was defined without a setter");
339 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
340 throw new TypeError("Cannot write private member to an object whose class did not declare it");
341 return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
342 }
343
344 // DEBUG quick debugger function for inline logging that typescript doesn't complain about
345 // wrote it for debugging the ɵlazySDKProxy, commenting out for now; should consider exposing a
346 // verbose mode for AngularFire in a future release that uses something like this in multiple places
347 // usage: () => log('something') || returnValue
348 // const log = (...args: any[]): false => { console.log(...args); return false }
349 // The problem here are things like ngOnDestroy are missing, then triggering the service
350 // rather than dig too far; I'm capturing these as I go.
351 var noopFunctions = ['ngOnDestroy'];
352 // INVESTIGATE should we make the Proxy revokable and do some cleanup?
353 // right now it's fairly simple but I'm sure this will grow in complexity
354 var ɵlazySDKProxy = function (klass, observable, zone, options) {
355 if (options === void 0) { options = {}; }
356 return new Proxy(klass, {
357 get: function (_, name) { return zone.runOutsideAngular(function () {
358 var _a;
359 if (klass[name]) {
360 if ((_a = options === null || options === void 0 ? void 0 : options.spy) === null || _a === void 0 ? void 0 : _a.get) {
361 options.spy.get(name, klass[name]);
362 }
363 return klass[name];
364 }
365 if (noopFunctions.indexOf(name) > -1) {
366 return function () {
367 };
368 }
369 var promise = observable.toPromise().then(function (mod) {
370 var ret = mod && mod[name];
371 // TODO move to proper type guards
372 if (typeof ret === 'function') {
373 return ret.bind(mod);
374 }
375 else if (ret && ret.then) {
376 return ret.then(function (res) { return zone.run(function () { return res; }); });
377 }
378 else {
379 return zone.run(function () { return ret; });
380 }
381 });
382 // recurse the proxy
383 return new Proxy(function () { }, {
384 get: function (_, name) { return promise[name]; },
385 // TODO handle callbacks as transparently as I can
386 apply: function (self, _, args) { return promise.then(function (it) {
387 var _a;
388 var res = it && it.apply(void 0, __spreadArray([], __read(args)));
389 if ((_a = options === null || options === void 0 ? void 0 : options.spy) === null || _a === void 0 ? void 0 : _a.apply) {
390 options.spy.apply(name, args, res);
391 }
392 return res;
393 }); }
394 });
395 }); }
396 });
397 };
398 var ɵapplyMixins = function (derivedCtor, constructors) {
399 constructors.forEach(function (baseCtor) {
400 Object.getOwnPropertyNames(baseCtor.prototype || baseCtor).forEach(function (name) {
401 Object.defineProperty(derivedCtor.prototype, name, Object.getOwnPropertyDescriptor(baseCtor.prototype || baseCtor, name));
402 });
403 });
404 };
405
406 var FirebaseApp = /** @class */ (function () {
407 function FirebaseApp(app) {
408 return app;
409 }
410 return FirebaseApp;
411 }());
412
413 var FIREBASE_OPTIONS = new i0.InjectionToken('angularfire2.app.options');
414 var FIREBASE_APP_NAME = new i0.InjectionToken('angularfire2.app.name');
415 function ɵfirebaseAppFactory(options, zone, nameOrConfig) {
416 var name = typeof nameOrConfig === 'string' && nameOrConfig || '[DEFAULT]';
417 var config = typeof nameOrConfig === 'object' && nameOrConfig || {};
418 config.name = config.name || name;
419 // Added any due to some inconsistency between @firebase/app and firebase types
420 var existingApp = firebase__default['default'].apps.filter(function (app) { return app && app.name === config.name; })[0];
421 // We support FirebaseConfig, initializeApp's public type only accepts string; need to cast as any
422 // Could be solved with https://github.com/firebase/firebase-js-sdk/pull/1206
423 var app = (existingApp || zone.runOutsideAngular(function () { return firebase__default['default'].initializeApp(options, config); }));
424 try {
425 if (JSON.stringify(options) !== JSON.stringify(app.options)) {
426 var hmr = !!module.hot;
427 log$1('error', app.name + " Firebase App already initialized with different options" + (hmr ? ', you may need to reload as Firebase is not HMR aware.' : '.'));
428 }
429 }
430 catch (e) { }
431 return new FirebaseApp(app);
432 }
433 var log$1 = function (level) {
434 var args = [];
435 for (var _i = 1; _i < arguments.length; _i++) {
436 args[_i - 1] = arguments[_i];
437 }
438 if (i0.isDevMode() && typeof console !== 'undefined') {
439 console[level].apply(console, __spreadArray([], __read(args)));
440 }
441 };
442 var FIREBASE_APP_PROVIDER = {
443 provide: FirebaseApp,
444 useFactory: ɵfirebaseAppFactory,
445 deps: [
446 FIREBASE_OPTIONS,
447 i0.NgZone,
448 [new i0.Optional(), FIREBASE_APP_NAME]
449 ]
450 };
451 var AngularFireModule = /** @class */ (function () {
452 // tslint:disable-next-line:ban-types
453 function AngularFireModule(platformId) {
454 firebase__default['default'].registerVersion('angularfire', fire.VERSION.full, 'core');
455 firebase__default['default'].registerVersion('angularfire', fire.VERSION.full, 'app-compat');
456 firebase__default['default'].registerVersion('angular', i0.VERSION.full, platformId.toString());
457 }
458 AngularFireModule.initializeApp = function (options, nameOrConfig) {
459 return {
460 ngModule: AngularFireModule,
461 providers: [
462 { provide: FIREBASE_OPTIONS, useValue: options },
463 { provide: FIREBASE_APP_NAME, useValue: nameOrConfig }
464 ]
465 };
466 };
467 return AngularFireModule;
468 }());
469 AngularFireModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.3", ngImport: i0__namespace, type: AngularFireModule, deps: [{ token: i0.PLATFORM_ID }], target: i0__namespace.ɵɵFactoryTarget.NgModule });
470 AngularFireModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.1.3", ngImport: i0__namespace, type: AngularFireModule });
471 AngularFireModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.1.3", ngImport: i0__namespace, type: AngularFireModule, providers: [FIREBASE_APP_PROVIDER] });
472 i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.3", ngImport: i0__namespace, type: AngularFireModule, decorators: [{
473 type: i0.NgModule,
474 args: [{
475 providers: [FIREBASE_APP_PROVIDER]
476 }]
477 }], ctorParameters: function () {
478 return [{ type: Object, decorators: [{
479 type: i0.Inject,
480 args: [i0.PLATFORM_ID]
481 }] }];
482 } });
483
484 function ɵcacheInstance(cacheKey, moduleName, appName, fn, deps) {
485 var _a = __read(globalThis.ɵAngularfireInstanceCache.find(function (it) { return it[0] === cacheKey; }) || [], 3), instance = _a[1], cachedDeps = _a[2];
486 if (instance) {
487 if (!matchDep(deps, cachedDeps)) {
488 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.' : ''));
489 log('warn', { is: deps, was: cachedDeps });
490 }
491 return instance;
492 }
493 else {
494 var newInstance = fn();
495 globalThis.ɵAngularfireInstanceCache.push([cacheKey, newInstance, deps]);
496 return newInstance;
497 }
498 }
499 function matchDep(a, b) {
500 try {
501 return a.toString() === b.toString();
502 }
503 catch (_) {
504 return a === b;
505 }
506 }
507 var IS_HMR = !!module.hot;
508 var log = function (level) {
509 var args = [];
510 for (var _i = 1; _i < arguments.length; _i++) {
511 args[_i - 1] = arguments[_i];
512 }
513 if (i0.isDevMode() && typeof console !== 'undefined') {
514 console[level].apply(console, __spreadArray([], __read(args)));
515 }
516 };
517 globalThis.ɵAngularfireInstanceCache || (globalThis.ɵAngularfireInstanceCache = []);
518
519 /**
520 * Generated bundle index. Do not edit.
521 */
522
523 exports.AngularFireModule = AngularFireModule;
524 exports.FIREBASE_APP_NAME = FIREBASE_APP_NAME;
525 exports.FIREBASE_OPTIONS = FIREBASE_OPTIONS;
526 exports.FirebaseApp = FirebaseApp;
527 exports.ɵapplyMixins = ɵapplyMixins;
528 exports.ɵcacheInstance = ɵcacheInstance;
529 exports.ɵfirebaseAppFactory = ɵfirebaseAppFactory;
530 exports.ɵlazySDKProxy = ɵlazySDKProxy;
531
532 Object.defineProperty(exports, '__esModule', { value: true });
533
534})));
535//# sourceMappingURL=angular-fire-compat.umd.js.map