123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467 |
- 'use strict';
-
- var util = require('@firebase/util');
- var tslib = require('tslib');
- var component = require('@firebase/component');
- var modularAPIs = require('@firebase/app');
- var logger$1 = require('@firebase/logger');
-
- function _interopNamespace(e) {
- if (e && e.__esModule) return e;
- var n = Object.create(null);
- if (e) {
- Object.keys(e).forEach(function (k) {
- if (k !== 'default') {
- var d = Object.getOwnPropertyDescriptor(e, k);
- Object.defineProperty(n, k, d.get ? d : {
- enumerable: true,
- get: function () { return e[k]; }
- });
- }
- });
- }
- n["default"] = e;
- return Object.freeze(n);
- }
-
- var modularAPIs__namespace = _interopNamespace(modularAPIs);
-
-
-
- var FirebaseAppImpl = (function () {
- function FirebaseAppImpl(_delegate, firebase) {
- var _this = this;
- this._delegate = _delegate;
- this.firebase = firebase;
-
- modularAPIs._addComponent(_delegate, new component.Component('app-compat', function () { return _this; }, "PUBLIC" ));
- this.container = _delegate.container;
- }
- Object.defineProperty(FirebaseAppImpl.prototype, "automaticDataCollectionEnabled", {
- get: function () {
- return this._delegate.automaticDataCollectionEnabled;
- },
- set: function (val) {
- this._delegate.automaticDataCollectionEnabled = val;
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(FirebaseAppImpl.prototype, "name", {
- get: function () {
- return this._delegate.name;
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(FirebaseAppImpl.prototype, "options", {
- get: function () {
- return this._delegate.options;
- },
- enumerable: false,
- configurable: true
- });
- FirebaseAppImpl.prototype.delete = function () {
- var _this = this;
- return new Promise(function (resolve) {
- _this._delegate.checkDestroyed();
- resolve();
- }).then(function () {
- _this.firebase.INTERNAL.removeApp(_this.name);
- return modularAPIs.deleteApp(_this._delegate);
- });
- };
-
-
- FirebaseAppImpl.prototype._getService = function (name, instanceIdentifier) {
- var _a;
- if (instanceIdentifier === void 0) { instanceIdentifier = modularAPIs._DEFAULT_ENTRY_NAME; }
- this._delegate.checkDestroyed();
-
- var provider = this._delegate.container.getProvider(name);
- if (!provider.isInitialized() &&
- ((_a = provider.getComponent()) === null || _a === void 0 ? void 0 : _a.instantiationMode) === "EXPLICIT" ) {
- provider.initialize();
- }
-
- return provider.getImmediate({
- identifier: instanceIdentifier
- });
- };
-
-
- FirebaseAppImpl.prototype._removeServiceInstance = function (name, instanceIdentifier) {
- if (instanceIdentifier === void 0) { instanceIdentifier = modularAPIs._DEFAULT_ENTRY_NAME; }
- this._delegate.container
-
- .getProvider(name)
- .clearInstance(instanceIdentifier);
- };
-
-
- FirebaseAppImpl.prototype._addComponent = function (component) {
- modularAPIs._addComponent(this._delegate, component);
- };
- FirebaseAppImpl.prototype._addOrOverwriteComponent = function (component) {
- modularAPIs._addOrOverwriteComponent(this._delegate, component);
- };
- FirebaseAppImpl.prototype.toJSON = function () {
- return {
- name: this.name,
- automaticDataCollectionEnabled: this.automaticDataCollectionEnabled,
- options: this.options
- };
- };
- return FirebaseAppImpl;
- }());
-
-
-
-
-
-
-
-
- var _a;
- var ERRORS = (_a = {},
- _a["no-app" ] = "No Firebase App '{$appName}' has been created - " +
- 'call Firebase App.initializeApp()',
- _a["invalid-app-argument" ] = 'firebase.{$appName}() takes either no argument or a ' +
- 'Firebase App instance.',
- _a);
- var ERROR_FACTORY = new util.ErrorFactory('app-compat', 'Firebase', ERRORS);
-
-
-
- function createFirebaseNamespaceCore(firebaseAppImpl) {
- var apps = {};
-
-
-
- var namespace = {
-
-
-
- __esModule: true,
- initializeApp: initializeAppCompat,
-
- app: app,
- registerVersion: modularAPIs__namespace.registerVersion,
- setLogLevel: modularAPIs__namespace.setLogLevel,
- onLog: modularAPIs__namespace.onLog,
-
- apps: null,
- SDK_VERSION: modularAPIs__namespace.SDK_VERSION,
- INTERNAL: {
- registerComponent: registerComponentCompat,
- removeApp: removeApp,
- useAsService: useAsService,
- modularAPIs: modularAPIs__namespace
- }
- };
-
-
-
-
-
-
-
-
-
-
-
- namespace['default'] = namespace;
-
- Object.defineProperty(namespace, 'apps', {
- get: getApps
- });
-
-
- function removeApp(name) {
- delete apps[name];
- }
-
-
- function app(name) {
- name = name || modularAPIs__namespace._DEFAULT_ENTRY_NAME;
- if (!util.contains(apps, name)) {
- throw ERROR_FACTORY.create("no-app" , { appName: name });
- }
- return apps[name];
- }
-
- app['App'] = firebaseAppImpl;
-
-
- function initializeAppCompat(options, rawConfig) {
- if (rawConfig === void 0) { rawConfig = {}; }
- var app = modularAPIs__namespace.initializeApp(options, rawConfig);
- if (util.contains(apps, app.name)) {
- return apps[app.name];
- }
- var appCompat = new firebaseAppImpl(app, namespace);
- apps[app.name] = appCompat;
- return appCompat;
- }
-
-
- function getApps() {
-
- return Object.keys(apps).map(function (name) { return apps[name]; });
- }
- function registerComponentCompat(component) {
- var componentName = component.name;
- var componentNameWithoutCompat = componentName.replace('-compat', '');
- if (modularAPIs__namespace._registerComponent(component) &&
- component.type === "PUBLIC" ) {
-
-
- var serviceNamespace = function (appArg) {
- if (appArg === void 0) { appArg = app(); }
-
- if (typeof appArg[componentNameWithoutCompat] !== 'function') {
-
-
- throw ERROR_FACTORY.create("invalid-app-argument" , {
- appName: componentName
- });
- }
-
-
- return appArg[componentNameWithoutCompat]();
- };
-
- if (component.serviceProps !== undefined) {
- util.deepExtend(serviceNamespace, component.serviceProps);
- }
-
- namespace[componentNameWithoutCompat] = serviceNamespace;
-
-
- firebaseAppImpl.prototype[componentNameWithoutCompat] =
-
-
-
- function () {
- var args = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- args[_i] = arguments[_i];
- }
- var serviceFxn = this._getService.bind(this, componentName);
- return serviceFxn.apply(this, component.multipleInstances ? args : []);
- };
- }
- return component.type === "PUBLIC"
- ?
- namespace[componentNameWithoutCompat]
- : null;
- }
-
-
- function useAsService(app, name) {
- if (name === 'serverAuth') {
- return null;
- }
- var useService = name;
- return useService;
- }
- return namespace;
- }
-
-
-
- function createFirebaseNamespace() {
- var namespace = createFirebaseNamespaceCore(FirebaseAppImpl);
- namespace.INTERNAL = tslib.__assign(tslib.__assign({}, namespace.INTERNAL), { createFirebaseNamespace: createFirebaseNamespace, extendNamespace: extendNamespace, createSubscribe: util.createSubscribe, ErrorFactory: util.ErrorFactory, deepExtend: util.deepExtend });
-
-
- function extendNamespace(props) {
- util.deepExtend(namespace, props);
- }
- return namespace;
- }
- var firebase$1 = createFirebaseNamespace();
-
-
- var logger = new logger$1.Logger('@firebase/app-compat');
-
- var name = "@firebase/app-compat";
- var version = "0.2.1";
-
-
- function registerCoreComponents(variant) {
-
- modularAPIs.registerVersion(name, version, variant);
- }
-
-
-
-
- if (util.isBrowser() && self.firebase !== undefined) {
- logger.warn("\n Warning: Firebase is already defined in the global scope. Please make sure\n Firebase library is only loaded once.\n ");
-
- var sdkVersion = self.firebase.SDK_VERSION;
- if (sdkVersion && sdkVersion.indexOf('LITE') >= 0) {
- logger.warn("\n Warning: You are trying to load Firebase while using Firebase Performance standalone script.\n You should load Firebase Performance with this instance of Firebase to avoid loading duplicate code.\n ");
- }
- }
- var firebase = firebase$1;
- registerCoreComponents();
-
- module.exports = firebase;
|