@firebase/app-compat
Advanced tools
Comparing version 0.0.900-exp.f919db6a9 to 0.1.0-20217250818
@@ -54,17 +54,16 @@ 'use strict'; | ||
var FirebaseAppImpl = /** @class */ (function () { | ||
function FirebaseAppImpl(app, firebase) { | ||
function FirebaseAppImpl(_delegate, firebase) { | ||
var _this = this; | ||
this.app = app; | ||
this._delegate = _delegate; | ||
this.firebase = firebase; | ||
// add itself to container | ||
// TODO: change the component name to 'app-compat' before the official release | ||
modularAPIs._addComponent(app, new component.Component('app', function () { return _this; }, "PUBLIC" /* PUBLIC */)); | ||
this.container = app.container; | ||
modularAPIs._addComponent(_delegate, new component.Component('app-compat', function () { return _this; }, "PUBLIC" /* PUBLIC */)); | ||
this.container = _delegate.container; | ||
} | ||
Object.defineProperty(FirebaseAppImpl.prototype, "automaticDataCollectionEnabled", { | ||
get: function () { | ||
return this.app.automaticDataCollectionEnabled; | ||
return this._delegate.automaticDataCollectionEnabled; | ||
}, | ||
set: function (val) { | ||
this.app.automaticDataCollectionEnabled = val; | ||
this._delegate.automaticDataCollectionEnabled = val; | ||
}, | ||
@@ -76,3 +75,3 @@ enumerable: false, | ||
get: function () { | ||
return this.app.name; | ||
return this._delegate.name; | ||
}, | ||
@@ -84,3 +83,3 @@ enumerable: false, | ||
get: function () { | ||
return this.app.options; | ||
return this._delegate.options; | ||
}, | ||
@@ -93,7 +92,7 @@ enumerable: false, | ||
return new Promise(function (resolve) { | ||
_this.app.checkDestroyed(); | ||
_this._delegate.checkDestroyed(); | ||
resolve(); | ||
}).then(function () { | ||
_this.firebase.INTERNAL.removeApp(_this.name); | ||
return modularAPIs.deleteApp(_this.app); | ||
return modularAPIs.deleteApp(_this._delegate); | ||
}); | ||
@@ -116,6 +115,13 @@ }; | ||
FirebaseAppImpl.prototype._getService = function (name, instanceIdentifier) { | ||
var _a; | ||
if (instanceIdentifier === void 0) { instanceIdentifier = modularAPIs._DEFAULT_ENTRY_NAME; } | ||
this.app.checkDestroyed(); | ||
this._delegate.checkDestroyed(); | ||
// Initialize instance if InstatiationMode is `EXPLICIT`. | ||
var provider = this._delegate.container.getProvider(name); | ||
if (!provider.isInitialized() && | ||
((_a = provider.getComponent()) === null || _a === void 0 ? void 0 : _a.instantiationMode) === "EXPLICIT" /* EXPLICIT */) { | ||
provider.initialize(); | ||
} | ||
// getImmediate will always succeed because _getService is only called for registered components. | ||
return this.app.container.getProvider(name).getImmediate({ | ||
return provider.getImmediate({ | ||
identifier: instanceIdentifier | ||
@@ -136,3 +142,3 @@ }); | ||
if (instanceIdentifier === void 0) { instanceIdentifier = modularAPIs._DEFAULT_ENTRY_NAME; } | ||
this.app.container | ||
this._delegate.container | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
@@ -147,7 +153,14 @@ .getProvider(name) | ||
FirebaseAppImpl.prototype._addComponent = function (component) { | ||
modularAPIs._addComponent(this.app, component); | ||
modularAPIs._addComponent(this._delegate, component); | ||
}; | ||
FirebaseAppImpl.prototype._addOrOverwriteComponent = function (component) { | ||
modularAPIs._addOrOverwriteComponent(this.app, component); | ||
modularAPIs._addOrOverwriteComponent(this._delegate, component); | ||
}; | ||
FirebaseAppImpl.prototype.toJSON = function () { | ||
return { | ||
name: this.name, | ||
automaticDataCollectionEnabled: this.automaticDataCollectionEnabled, | ||
options: this.options | ||
}; | ||
}; | ||
return FirebaseAppImpl; | ||
@@ -223,8 +236,8 @@ }()); | ||
app: app, | ||
registerVersion: modularAPIs.registerVersion, | ||
setLogLevel: modularAPIs.setLogLevel, | ||
onLog: modularAPIs.onLog, | ||
registerVersion: modularAPIs__namespace.registerVersion, | ||
setLogLevel: modularAPIs__namespace.setLogLevel, | ||
onLog: modularAPIs__namespace.onLog, | ||
// @ts-ignore | ||
apps: null, | ||
SDK_VERSION: modularAPIs.SDK_VERSION, | ||
SDK_VERSION: modularAPIs__namespace.SDK_VERSION, | ||
INTERNAL: { | ||
@@ -264,3 +277,3 @@ registerComponent: registerComponentCompat, | ||
function app(name) { | ||
name = name || modularAPIs._DEFAULT_ENTRY_NAME; | ||
name = name || modularAPIs__namespace._DEFAULT_ENTRY_NAME; | ||
if (!util.contains(apps, name)) { | ||
@@ -275,6 +288,11 @@ throw ERROR_FACTORY.create("no-app" /* NO_APP */, { appName: name }); | ||
* Create a new App instance (name must be unique). | ||
* | ||
* This function is idempotent. It can be called more than once and return the same instance using the same options and config. | ||
*/ | ||
function initializeAppCompat(options, rawConfig) { | ||
if (rawConfig === void 0) { rawConfig = {}; } | ||
var app = modularAPIs.initializeApp(options, rawConfig); | ||
var app = modularAPIs__namespace.initializeApp(options, rawConfig); | ||
if (util.contains(apps, app.name)) { | ||
return apps[app.name]; | ||
} | ||
var appCompat = new firebaseAppImpl(app, namespace); | ||
@@ -293,3 +311,4 @@ apps[app.name] = appCompat; | ||
var componentName = component.name; | ||
if (modularAPIs._registerComponent(component) && | ||
var componentNameWithoutCompat = componentName.replace('-compat', ''); | ||
if (modularAPIs__namespace._registerComponent(component) && | ||
component.type === "PUBLIC" /* PUBLIC */) { | ||
@@ -301,3 +320,3 @@ // create service namespace for public components | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
if (typeof appArg[componentName] !== 'function') { | ||
if (typeof appArg[componentNameWithoutCompat] !== 'function') { | ||
// Invalid argument. | ||
@@ -311,3 +330,3 @@ // This happens in the following case: firebase.storage('gs:/') | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
return appArg[componentName](); | ||
return appArg[componentNameWithoutCompat](); | ||
}; | ||
@@ -319,6 +338,6 @@ // ... and a container for service-level properties. | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
namespace[componentName] = serviceNamespace; | ||
namespace[componentNameWithoutCompat] = serviceNamespace; | ||
// Patch the FirebaseAppImpl prototype | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
firebaseAppImpl.prototype[componentName] = | ||
firebaseAppImpl.prototype[componentNameWithoutCompat] = | ||
// TODO: The eslint disable can be removed and the 'ignoreRestArgs' | ||
@@ -338,3 +357,3 @@ // option added to the no-explicit-any rule when ESlint releases it. | ||
? // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
namespace[componentName] | ||
namespace[componentNameWithoutCompat] | ||
: null; | ||
@@ -394,3 +413,3 @@ } | ||
} | ||
var firebase = createFirebaseNamespace(); | ||
var firebase$1 = createFirebaseNamespace(); | ||
@@ -416,3 +435,3 @@ /** | ||
var name = "@firebase/app-compat"; | ||
var version = "0.0.900"; | ||
var version = "0.1.0-20217250818"; | ||
@@ -466,7 +485,7 @@ /** | ||
} | ||
var firebase$1 = firebase; | ||
var firebase = firebase$1; | ||
registerCoreComponents(); | ||
exports.default = firebase$1; | ||
exports.firebase = firebase$1; | ||
exports.default = firebase; | ||
exports.firebase = firebase; | ||
//# sourceMappingURL=index.cjs.js.map |
import { ErrorFactory, contains, deepExtend, createSubscribe, isBrowser } from '@firebase/util'; | ||
import { Component } from '@firebase/component'; | ||
import * as modularAPIs from '@firebase/app'; | ||
import { _addComponent, deleteApp, _DEFAULT_ENTRY_NAME, _addOrOverwriteComponent, registerVersion, setLogLevel, onLog, SDK_VERSION, initializeApp, _registerComponent } from '@firebase/app'; | ||
import { _addComponent, deleteApp, _DEFAULT_ENTRY_NAME, _addOrOverwriteComponent, registerVersion } from '@firebase/app'; | ||
import { Logger } from '@firebase/logger'; | ||
@@ -28,29 +28,28 @@ | ||
class FirebaseAppImpl { | ||
constructor(app, firebase) { | ||
this.app = app; | ||
constructor(_delegate, firebase) { | ||
this._delegate = _delegate; | ||
this.firebase = firebase; | ||
// add itself to container | ||
// TODO: change the component name to 'app-compat' before the official release | ||
_addComponent(app, new Component('app', () => this, "PUBLIC" /* PUBLIC */)); | ||
this.container = app.container; | ||
_addComponent(_delegate, new Component('app-compat', () => this, "PUBLIC" /* PUBLIC */)); | ||
this.container = _delegate.container; | ||
} | ||
get automaticDataCollectionEnabled() { | ||
return this.app.automaticDataCollectionEnabled; | ||
return this._delegate.automaticDataCollectionEnabled; | ||
} | ||
set automaticDataCollectionEnabled(val) { | ||
this.app.automaticDataCollectionEnabled = val; | ||
this._delegate.automaticDataCollectionEnabled = val; | ||
} | ||
get name() { | ||
return this.app.name; | ||
return this._delegate.name; | ||
} | ||
get options() { | ||
return this.app.options; | ||
return this._delegate.options; | ||
} | ||
delete() { | ||
return new Promise(resolve => { | ||
this.app.checkDestroyed(); | ||
this._delegate.checkDestroyed(); | ||
resolve(); | ||
}).then(() => { | ||
this.firebase.INTERNAL.removeApp(this.name); | ||
return deleteApp(this.app); | ||
return deleteApp(this._delegate); | ||
}); | ||
@@ -73,5 +72,12 @@ } | ||
_getService(name, instanceIdentifier = _DEFAULT_ENTRY_NAME) { | ||
this.app.checkDestroyed(); | ||
var _a; | ||
this._delegate.checkDestroyed(); | ||
// Initialize instance if InstatiationMode is `EXPLICIT`. | ||
const provider = this._delegate.container.getProvider(name); | ||
if (!provider.isInitialized() && | ||
((_a = provider.getComponent()) === null || _a === void 0 ? void 0 : _a.instantiationMode) === "EXPLICIT" /* EXPLICIT */) { | ||
provider.initialize(); | ||
} | ||
// getImmediate will always succeed because _getService is only called for registered components. | ||
return this.app.container.getProvider(name).getImmediate({ | ||
return provider.getImmediate({ | ||
identifier: instanceIdentifier | ||
@@ -91,3 +97,3 @@ }); | ||
_removeServiceInstance(name, instanceIdentifier = _DEFAULT_ENTRY_NAME) { | ||
this.app.container | ||
this._delegate.container | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
@@ -102,7 +108,14 @@ .getProvider(name) | ||
_addComponent(component) { | ||
_addComponent(this.app, component); | ||
_addComponent(this._delegate, component); | ||
} | ||
_addOrOverwriteComponent(component) { | ||
_addOrOverwriteComponent(this.app, component); | ||
_addOrOverwriteComponent(this._delegate, component); | ||
} | ||
toJSON() { | ||
return { | ||
name: this.name, | ||
automaticDataCollectionEnabled: this.automaticDataCollectionEnabled, | ||
options: this.options | ||
}; | ||
} | ||
} | ||
@@ -176,8 +189,8 @@ // TODO: investigate why the following needs to be commented out | ||
app, | ||
registerVersion: registerVersion, | ||
setLogLevel: setLogLevel, | ||
onLog: onLog, | ||
registerVersion: modularAPIs.registerVersion, | ||
setLogLevel: modularAPIs.setLogLevel, | ||
onLog: modularAPIs.onLog, | ||
// @ts-ignore | ||
apps: null, | ||
SDK_VERSION: SDK_VERSION, | ||
SDK_VERSION: modularAPIs.SDK_VERSION, | ||
INTERNAL: { | ||
@@ -217,3 +230,3 @@ registerComponent: registerComponentCompat, | ||
function app(name) { | ||
name = name || _DEFAULT_ENTRY_NAME; | ||
name = name || modularAPIs._DEFAULT_ENTRY_NAME; | ||
if (!contains(apps, name)) { | ||
@@ -228,5 +241,10 @@ throw ERROR_FACTORY.create("no-app" /* NO_APP */, { appName: name }); | ||
* Create a new App instance (name must be unique). | ||
* | ||
* This function is idempotent. It can be called more than once and return the same instance using the same options and config. | ||
*/ | ||
function initializeAppCompat(options, rawConfig = {}) { | ||
const app = initializeApp(options, rawConfig); | ||
const app = modularAPIs.initializeApp(options, rawConfig); | ||
if (contains(apps, app.name)) { | ||
return apps[app.name]; | ||
} | ||
const appCompat = new firebaseAppImpl(app, namespace); | ||
@@ -245,3 +263,4 @@ apps[app.name] = appCompat; | ||
const componentName = component.name; | ||
if (_registerComponent(component) && | ||
const componentNameWithoutCompat = componentName.replace('-compat', ''); | ||
if (modularAPIs._registerComponent(component) && | ||
component.type === "PUBLIC" /* PUBLIC */) { | ||
@@ -252,3 +271,3 @@ // create service namespace for public components | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
if (typeof appArg[componentName] !== 'function') { | ||
if (typeof appArg[componentNameWithoutCompat] !== 'function') { | ||
// Invalid argument. | ||
@@ -262,3 +281,3 @@ // This happens in the following case: firebase.storage('gs:/') | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
return appArg[componentName](); | ||
return appArg[componentNameWithoutCompat](); | ||
}; | ||
@@ -270,6 +289,6 @@ // ... and a container for service-level properties. | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
namespace[componentName] = serviceNamespace; | ||
namespace[componentNameWithoutCompat] = serviceNamespace; | ||
// Patch the FirebaseAppImpl prototype | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
firebaseAppImpl.prototype[componentName] = | ||
firebaseAppImpl.prototype[componentNameWithoutCompat] = | ||
// TODO: The eslint disable can be removed and the 'ignoreRestArgs' | ||
@@ -285,3 +304,3 @@ // option added to the no-explicit-any rule when ESlint releases it. | ||
? // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
namespace[componentName] | ||
namespace[componentNameWithoutCompat] | ||
: null; | ||
@@ -341,3 +360,3 @@ } | ||
} | ||
const firebase = createFirebaseNamespace(); | ||
const firebase$1 = createFirebaseNamespace(); | ||
@@ -363,3 +382,3 @@ /** | ||
const name = "@firebase/app-compat"; | ||
const version = "0.0.900"; | ||
const version = "0.1.0-20217250818"; | ||
@@ -419,7 +438,7 @@ /** | ||
} | ||
const firebase$1 = firebase; | ||
const firebase = firebase$1; | ||
registerCoreComponents(); | ||
export default firebase$1; | ||
export { firebase$1 as firebase }; | ||
export default firebase; | ||
export { firebase }; | ||
//# sourceMappingURL=index.esm2017.js.map |
@@ -5,3 +5,3 @@ import { ErrorFactory, contains, deepExtend, createSubscribe, isBrowser } from '@firebase/util'; | ||
import * as modularAPIs from '@firebase/app'; | ||
import { deleteApp, _addComponent, _addOrOverwriteComponent, _DEFAULT_ENTRY_NAME, registerVersion, setLogLevel, onLog, SDK_VERSION, initializeApp, _registerComponent } from '@firebase/app'; | ||
import { deleteApp, _addComponent, _addOrOverwriteComponent, _DEFAULT_ENTRY_NAME, registerVersion } from '@firebase/app'; | ||
import { Logger } from '@firebase/logger'; | ||
@@ -30,17 +30,16 @@ | ||
var FirebaseAppImpl = /** @class */ (function () { | ||
function FirebaseAppImpl(app, firebase) { | ||
function FirebaseAppImpl(_delegate, firebase) { | ||
var _this = this; | ||
this.app = app; | ||
this._delegate = _delegate; | ||
this.firebase = firebase; | ||
// add itself to container | ||
// TODO: change the component name to 'app-compat' before the official release | ||
_addComponent(app, new Component('app', function () { return _this; }, "PUBLIC" /* PUBLIC */)); | ||
this.container = app.container; | ||
_addComponent(_delegate, new Component('app-compat', function () { return _this; }, "PUBLIC" /* PUBLIC */)); | ||
this.container = _delegate.container; | ||
} | ||
Object.defineProperty(FirebaseAppImpl.prototype, "automaticDataCollectionEnabled", { | ||
get: function () { | ||
return this.app.automaticDataCollectionEnabled; | ||
return this._delegate.automaticDataCollectionEnabled; | ||
}, | ||
set: function (val) { | ||
this.app.automaticDataCollectionEnabled = val; | ||
this._delegate.automaticDataCollectionEnabled = val; | ||
}, | ||
@@ -52,3 +51,3 @@ enumerable: false, | ||
get: function () { | ||
return this.app.name; | ||
return this._delegate.name; | ||
}, | ||
@@ -60,3 +59,3 @@ enumerable: false, | ||
get: function () { | ||
return this.app.options; | ||
return this._delegate.options; | ||
}, | ||
@@ -69,7 +68,7 @@ enumerable: false, | ||
return new Promise(function (resolve) { | ||
_this.app.checkDestroyed(); | ||
_this._delegate.checkDestroyed(); | ||
resolve(); | ||
}).then(function () { | ||
_this.firebase.INTERNAL.removeApp(_this.name); | ||
return deleteApp(_this.app); | ||
return deleteApp(_this._delegate); | ||
}); | ||
@@ -92,6 +91,13 @@ }; | ||
FirebaseAppImpl.prototype._getService = function (name, instanceIdentifier) { | ||
var _a; | ||
if (instanceIdentifier === void 0) { instanceIdentifier = _DEFAULT_ENTRY_NAME; } | ||
this.app.checkDestroyed(); | ||
this._delegate.checkDestroyed(); | ||
// Initialize instance if InstatiationMode is `EXPLICIT`. | ||
var provider = this._delegate.container.getProvider(name); | ||
if (!provider.isInitialized() && | ||
((_a = provider.getComponent()) === null || _a === void 0 ? void 0 : _a.instantiationMode) === "EXPLICIT" /* EXPLICIT */) { | ||
provider.initialize(); | ||
} | ||
// getImmediate will always succeed because _getService is only called for registered components. | ||
return this.app.container.getProvider(name).getImmediate({ | ||
return provider.getImmediate({ | ||
identifier: instanceIdentifier | ||
@@ -112,3 +118,3 @@ }); | ||
if (instanceIdentifier === void 0) { instanceIdentifier = _DEFAULT_ENTRY_NAME; } | ||
this.app.container | ||
this._delegate.container | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
@@ -123,7 +129,14 @@ .getProvider(name) | ||
FirebaseAppImpl.prototype._addComponent = function (component) { | ||
_addComponent(this.app, component); | ||
_addComponent(this._delegate, component); | ||
}; | ||
FirebaseAppImpl.prototype._addOrOverwriteComponent = function (component) { | ||
_addOrOverwriteComponent(this.app, component); | ||
_addOrOverwriteComponent(this._delegate, component); | ||
}; | ||
FirebaseAppImpl.prototype.toJSON = function () { | ||
return { | ||
name: this.name, | ||
automaticDataCollectionEnabled: this.automaticDataCollectionEnabled, | ||
options: this.options | ||
}; | ||
}; | ||
return FirebaseAppImpl; | ||
@@ -199,8 +212,8 @@ }()); | ||
app: app, | ||
registerVersion: registerVersion, | ||
setLogLevel: setLogLevel, | ||
onLog: onLog, | ||
registerVersion: modularAPIs.registerVersion, | ||
setLogLevel: modularAPIs.setLogLevel, | ||
onLog: modularAPIs.onLog, | ||
// @ts-ignore | ||
apps: null, | ||
SDK_VERSION: SDK_VERSION, | ||
SDK_VERSION: modularAPIs.SDK_VERSION, | ||
INTERNAL: { | ||
@@ -240,3 +253,3 @@ registerComponent: registerComponentCompat, | ||
function app(name) { | ||
name = name || _DEFAULT_ENTRY_NAME; | ||
name = name || modularAPIs._DEFAULT_ENTRY_NAME; | ||
if (!contains(apps, name)) { | ||
@@ -251,6 +264,11 @@ throw ERROR_FACTORY.create("no-app" /* NO_APP */, { appName: name }); | ||
* Create a new App instance (name must be unique). | ||
* | ||
* This function is idempotent. It can be called more than once and return the same instance using the same options and config. | ||
*/ | ||
function initializeAppCompat(options, rawConfig) { | ||
if (rawConfig === void 0) { rawConfig = {}; } | ||
var app = initializeApp(options, rawConfig); | ||
var app = modularAPIs.initializeApp(options, rawConfig); | ||
if (contains(apps, app.name)) { | ||
return apps[app.name]; | ||
} | ||
var appCompat = new firebaseAppImpl(app, namespace); | ||
@@ -269,3 +287,4 @@ apps[app.name] = appCompat; | ||
var componentName = component.name; | ||
if (_registerComponent(component) && | ||
var componentNameWithoutCompat = componentName.replace('-compat', ''); | ||
if (modularAPIs._registerComponent(component) && | ||
component.type === "PUBLIC" /* PUBLIC */) { | ||
@@ -277,3 +296,3 @@ // create service namespace for public components | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
if (typeof appArg[componentName] !== 'function') { | ||
if (typeof appArg[componentNameWithoutCompat] !== 'function') { | ||
// Invalid argument. | ||
@@ -287,3 +306,3 @@ // This happens in the following case: firebase.storage('gs:/') | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
return appArg[componentName](); | ||
return appArg[componentNameWithoutCompat](); | ||
}; | ||
@@ -295,6 +314,6 @@ // ... and a container for service-level properties. | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
namespace[componentName] = serviceNamespace; | ||
namespace[componentNameWithoutCompat] = serviceNamespace; | ||
// Patch the FirebaseAppImpl prototype | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
firebaseAppImpl.prototype[componentName] = | ||
firebaseAppImpl.prototype[componentNameWithoutCompat] = | ||
// TODO: The eslint disable can be removed and the 'ignoreRestArgs' | ||
@@ -314,3 +333,3 @@ // option added to the no-explicit-any rule when ESlint releases it. | ||
? // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
namespace[componentName] | ||
namespace[componentNameWithoutCompat] | ||
: null; | ||
@@ -370,3 +389,3 @@ } | ||
} | ||
var firebase = createFirebaseNamespace(); | ||
var firebase$1 = createFirebaseNamespace(); | ||
@@ -392,3 +411,3 @@ /** | ||
var name = "@firebase/app-compat"; | ||
var version = "0.0.900"; | ||
var version = "0.1.0-20217250818"; | ||
@@ -442,7 +461,7 @@ /** | ||
} | ||
var firebase$1 = firebase; | ||
var firebase = firebase$1; | ||
registerCoreComponents(); | ||
export default firebase$1; | ||
export { firebase$1 as firebase }; | ||
export default firebase; | ||
export { firebase }; | ||
//# sourceMappingURL=index.esm5.js.map |
import * as modularAPIs from '@firebase/app'; | ||
import { deleteApp, _addComponent, _DEFAULT_ENTRY_NAME, registerVersion, setLogLevel, onLog, SDK_VERSION, initializeApp, _registerComponent } from '@firebase/app'; | ||
import { _addComponent, deleteApp, _DEFAULT_ENTRY_NAME, registerVersion } from '@firebase/app'; | ||
import { Component } from '@firebase/component'; | ||
@@ -26,38 +26,25 @@ import { ErrorFactory, contains, deepExtend } from '@firebase/util'; | ||
*/ | ||
var FirebaseAppLiteImpl = /** @class */ (function () { | ||
function FirebaseAppLiteImpl(app, firebase) { | ||
var _this = this; | ||
this.app = app; | ||
class FirebaseAppLiteImpl { | ||
constructor(_delegate, firebase) { | ||
this._delegate = _delegate; | ||
this.firebase = firebase; | ||
// add itself to container | ||
_addComponent(app, new Component('app', function () { return _this; }, "PUBLIC" /* PUBLIC */)); | ||
_addComponent(_delegate, new Component('app-compat', () => this, "PUBLIC" /* PUBLIC */)); | ||
} | ||
Object.defineProperty(FirebaseAppLiteImpl.prototype, "automaticDataCollectionEnabled", { | ||
get: function () { | ||
return this.app.automaticDataCollectionEnabled; | ||
}, | ||
set: function (val) { | ||
this.automaticDataCollectionEnabled = val; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
Object.defineProperty(FirebaseAppLiteImpl.prototype, "name", { | ||
get: function () { | ||
return this.app.name; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
Object.defineProperty(FirebaseAppLiteImpl.prototype, "options", { | ||
get: function () { | ||
return this.app.options; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
FirebaseAppLiteImpl.prototype.delete = function () { | ||
get automaticDataCollectionEnabled() { | ||
return this._delegate.automaticDataCollectionEnabled; | ||
} | ||
set automaticDataCollectionEnabled(val) { | ||
this.automaticDataCollectionEnabled = val; | ||
} | ||
get name() { | ||
return this._delegate.name; | ||
} | ||
get options() { | ||
return this._delegate.options; | ||
} | ||
delete() { | ||
this.firebase.INTERNAL.removeApp(this.name); | ||
return deleteApp(this.app); | ||
}; | ||
return deleteApp(this._delegate); | ||
} | ||
/** | ||
@@ -77,12 +64,10 @@ * Return a service instance associated with this app (creating it | ||
*/ | ||
FirebaseAppLiteImpl.prototype._getService = function (name, instanceIdentifier) { | ||
if (instanceIdentifier === void 0) { instanceIdentifier = _DEFAULT_ENTRY_NAME; } | ||
this.app.checkDestroyed(); | ||
_getService(name, instanceIdentifier = _DEFAULT_ENTRY_NAME) { | ||
this._delegate.checkDestroyed(); | ||
// getImmediate will always succeed because _getService is only called for registered components. | ||
return this.app.container.getProvider(name).getImmediate({ | ||
return this._delegate.container.getProvider(name).getImmediate({ | ||
identifier: instanceIdentifier | ||
}); | ||
}; | ||
return FirebaseAppLiteImpl; | ||
}()); | ||
} | ||
} | ||
@@ -105,10 +90,9 @@ /** | ||
*/ | ||
var _a; | ||
var ERRORS = (_a = {}, | ||
_a["no-app" /* NO_APP */] = "No Firebase App '{$appName}' has been created - " + | ||
const ERRORS = { | ||
["no-app" /* NO_APP */]: "No Firebase App '{$appName}' has been created - " + | ||
'call Firebase App.initializeApp()', | ||
_a["invalid-app-argument" /* INVALID_APP_ARGUMENT */] = 'firebase.{$appName}() takes either no argument or a ' + | ||
'Firebase App instance.', | ||
_a); | ||
var ERROR_FACTORY = new ErrorFactory('app-compat', 'Firebase', ERRORS); | ||
["invalid-app-argument" /* INVALID_APP_ARGUMENT */]: 'firebase.{$appName}() takes either no argument or a ' + | ||
'Firebase App instance.' | ||
}; | ||
const ERROR_FACTORY = new ErrorFactory('app-compat', 'Firebase', ERRORS); | ||
@@ -139,7 +123,7 @@ /** | ||
function createFirebaseNamespaceCore(firebaseAppImpl) { | ||
var apps = {}; | ||
const apps = {}; | ||
// // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
// const components = new Map<string, Component<any>>(); | ||
// A namespace is a plain JavaScript Object. | ||
var namespace = { | ||
const namespace = { | ||
// Hack to prevent Babel from modifying the object returned | ||
@@ -151,14 +135,14 @@ // as the firebase namespace. | ||
// @ts-ignore | ||
app: app, | ||
registerVersion: registerVersion, | ||
setLogLevel: setLogLevel, | ||
onLog: onLog, | ||
app, | ||
registerVersion: modularAPIs.registerVersion, | ||
setLogLevel: modularAPIs.setLogLevel, | ||
onLog: modularAPIs.onLog, | ||
// @ts-ignore | ||
apps: null, | ||
SDK_VERSION: SDK_VERSION, | ||
SDK_VERSION: modularAPIs.SDK_VERSION, | ||
INTERNAL: { | ||
registerComponent: registerComponentCompat, | ||
removeApp: removeApp, | ||
useAsService: useAsService, | ||
modularAPIs: modularAPIs | ||
removeApp, | ||
useAsService, | ||
modularAPIs | ||
} | ||
@@ -193,3 +177,3 @@ }; | ||
function app(name) { | ||
name = name || _DEFAULT_ENTRY_NAME; | ||
name = name || modularAPIs._DEFAULT_ENTRY_NAME; | ||
if (!contains(apps, name)) { | ||
@@ -204,7 +188,11 @@ throw ERROR_FACTORY.create("no-app" /* NO_APP */, { appName: name }); | ||
* Create a new App instance (name must be unique). | ||
* | ||
* This function is idempotent. It can be called more than once and return the same instance using the same options and config. | ||
*/ | ||
function initializeAppCompat(options, rawConfig) { | ||
if (rawConfig === void 0) { rawConfig = {}; } | ||
var app = initializeApp(options, rawConfig); | ||
var appCompat = new firebaseAppImpl(app, namespace); | ||
function initializeAppCompat(options, rawConfig = {}) { | ||
const app = modularAPIs.initializeApp(options, rawConfig); | ||
if (contains(apps, app.name)) { | ||
return apps[app.name]; | ||
} | ||
const appCompat = new firebaseAppImpl(app, namespace); | ||
apps[app.name] = appCompat; | ||
@@ -218,14 +206,14 @@ return appCompat; | ||
// Make a copy so caller cannot mutate the apps list. | ||
return Object.keys(apps).map(function (name) { return apps[name]; }); | ||
return Object.keys(apps).map(name => apps[name]); | ||
} | ||
function registerComponentCompat(component) { | ||
var componentName = component.name; | ||
if (_registerComponent(component) && | ||
const componentName = component.name; | ||
const componentNameWithoutCompat = componentName.replace('-compat', ''); | ||
if (modularAPIs._registerComponent(component) && | ||
component.type === "PUBLIC" /* PUBLIC */) { | ||
// create service namespace for public components | ||
// The Service namespace is an accessor function ... | ||
var serviceNamespace = function (appArg) { | ||
if (appArg === void 0) { appArg = app(); } | ||
const serviceNamespace = (appArg = app()) => { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
if (typeof appArg[componentName] !== 'function') { | ||
if (typeof appArg[componentNameWithoutCompat] !== 'function') { | ||
// Invalid argument. | ||
@@ -239,3 +227,3 @@ // This happens in the following case: firebase.storage('gs:/') | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
return appArg[componentName](); | ||
return appArg[componentNameWithoutCompat](); | ||
}; | ||
@@ -247,15 +235,11 @@ // ... and a container for service-level properties. | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
namespace[componentName] = serviceNamespace; | ||
namespace[componentNameWithoutCompat] = serviceNamespace; | ||
// Patch the FirebaseAppImpl prototype | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
firebaseAppImpl.prototype[componentName] = | ||
firebaseAppImpl.prototype[componentNameWithoutCompat] = | ||
// TODO: The eslint disable can be removed and the 'ignoreRestArgs' | ||
// option added to the no-explicit-any rule when ESlint releases it. | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
var serviceFxn = this._getService.bind(this, componentName); | ||
function (...args) { | ||
const serviceFxn = this._getService.bind(this, componentName); | ||
return serviceFxn.apply(this, component.multipleInstances ? args : []); | ||
@@ -266,3 +250,3 @@ }; | ||
? // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
namespace[componentName] | ||
namespace[componentNameWithoutCompat] | ||
: null; | ||
@@ -276,3 +260,3 @@ } | ||
} | ||
var useService = name; | ||
const useService = name; | ||
return useService; | ||
@@ -300,6 +284,5 @@ } | ||
function createFirebaseNamespaceLite() { | ||
var namespace = createFirebaseNamespaceCore(FirebaseAppLiteImpl); | ||
namespace.SDK_VERSION = namespace.SDK_VERSION + "_LITE"; | ||
var registerComponent = namespace.INTERNAL | ||
.registerComponent; | ||
const namespace = createFirebaseNamespaceCore(FirebaseAppLiteImpl); | ||
namespace.SDK_VERSION = `${namespace.SDK_VERSION}_LITE`; | ||
const registerComponent = namespace.INTERNAL.registerComponent; | ||
namespace.INTERNAL.registerComponent = registerComponentForLite; | ||
@@ -315,5 +298,5 @@ /** | ||
if (component.type === "PUBLIC" /* PUBLIC */ && | ||
component.name !== 'performance' && | ||
component.name !== 'installations') { | ||
throw Error(name + " cannot register with the standalone perf instance"); | ||
!component.name.includes('performance') && | ||
!component.name.includes('installations')) { | ||
throw Error(`${name} cannot register with the standalone perf instance`); | ||
} | ||
@@ -325,4 +308,4 @@ return registerComponent(component); | ||
var name$1 = "@firebase/app-compat"; | ||
var version = "0.0.900"; | ||
const name$1 = "@firebase/app-compat"; | ||
const version = "0.1.0-20217250818"; | ||
@@ -366,3 +349,3 @@ /** | ||
*/ | ||
var firebase = createFirebaseNamespaceLite(); | ||
const firebase = createFirebaseNamespaceLite(); | ||
registerCoreComponents('lite'); | ||
@@ -369,0 +352,0 @@ |
@@ -17,6 +17,26 @@ /** | ||
*/ | ||
import { FirebaseApp, FirebaseOptions } from '@firebase/app-types'; | ||
import { _FirebaseNamespace, FirebaseService } from '@firebase/app-types/private'; | ||
import { FirebaseOptions } from './public-types'; | ||
import { Component } from '@firebase/component'; | ||
import { _FirebaseAppInternal } from "@firebase/app-types"; | ||
import { _FirebaseAppInternal as _FirebaseAppExp } from '@firebase/app'; | ||
import { _FirebaseService, _FirebaseNamespace } from './types'; | ||
import { Compat } from '@firebase/util'; | ||
export interface _FirebaseApp { | ||
/** | ||
* The (read-only) name (identifier) for this App. '[DEFAULT]' is the default | ||
* App. | ||
*/ | ||
name: string; | ||
/** | ||
* The (read-only) configuration options from the app initialization. | ||
*/ | ||
options: FirebaseOptions; | ||
/** | ||
* The settable config flag for GDPR opt-in/opt-out | ||
*/ | ||
automaticDataCollectionEnabled: boolean; | ||
/** | ||
* Make the given App unusable and free resources. | ||
*/ | ||
delete(): Promise<void>; | ||
} | ||
/** | ||
@@ -26,7 +46,7 @@ * Global context object for a collection of services using | ||
*/ | ||
export declare class FirebaseAppImpl implements FirebaseApp { | ||
private readonly app; | ||
export declare class FirebaseAppImpl implements Compat<_FirebaseAppExp>, _FirebaseApp { | ||
readonly _delegate: _FirebaseAppExp; | ||
private readonly firebase; | ||
private readonly container; | ||
constructor(app: _FirebaseAppInternal, firebase: _FirebaseNamespace); | ||
private container; | ||
constructor(_delegate: _FirebaseAppExp, firebase: _FirebaseNamespace); | ||
get automaticDataCollectionEnabled(): boolean; | ||
@@ -51,3 +71,3 @@ set automaticDataCollectionEnabled(val: boolean); | ||
*/ | ||
_getService(name: string, instanceIdentifier?: string): FirebaseService; | ||
_getService(name: string, instanceIdentifier?: string): _FirebaseService; | ||
/** | ||
@@ -70,2 +90,3 @@ * Remove a service instance from the cache, so we will create a new instance for this service | ||
_addOrOverwriteComponent(component: Component): void; | ||
toJSON(): object; | ||
} |
@@ -17,3 +17,3 @@ /** | ||
*/ | ||
import { FirebaseNamespace } from '@firebase/app-types'; | ||
import { FirebaseNamespace } from './public-types'; | ||
/** | ||
@@ -20,0 +20,0 @@ * Return a firebase namespace object. |
@@ -17,3 +17,3 @@ /** | ||
*/ | ||
import { FirebaseNamespace } from '@firebase/app-types'; | ||
import { _FirebaseNamespace } from './types'; | ||
import { FirebaseAppImpl } from './firebaseApp'; | ||
@@ -28,2 +28,2 @@ import { FirebaseAppLiteImpl } from './lite/firebaseAppLite'; | ||
*/ | ||
export declare function createFirebaseNamespaceCore(firebaseAppImpl: typeof FirebaseAppImpl | typeof FirebaseAppLiteImpl): FirebaseNamespace; | ||
export declare function createFirebaseNamespaceCore(firebaseAppImpl: typeof FirebaseAppImpl | typeof FirebaseAppLiteImpl): _FirebaseNamespace; |
@@ -17,4 +17,6 @@ /** | ||
*/ | ||
import { FirebaseNamespace } from '@firebase/app-types'; | ||
import { FirebaseNamespace } from './public-types'; | ||
export declare const firebase: FirebaseNamespace; | ||
export default firebase; | ||
export { _FirebaseNamespace, _FirebaseService } from './types'; | ||
export { FirebaseApp, FirebaseNamespace } from './public-types'; |
@@ -17,3 +17,3 @@ /** | ||
*/ | ||
export declare const firebase: import("@firebase/app-types").FirebaseNamespace; | ||
export declare const firebase: import("./public-types").FirebaseNamespace; | ||
export default firebase; |
@@ -17,5 +17,6 @@ /** | ||
*/ | ||
import { FirebaseApp, FirebaseOptions } from '@firebase/app-types'; | ||
import { _FirebaseNamespace, FirebaseService } from '@firebase/app-types/private'; | ||
import { _FirebaseAppInternal } from "@firebase/app-types"; | ||
import { FirebaseApp, FirebaseOptions } from '../public-types'; | ||
import { _FirebaseNamespace, _FirebaseService } from '../types'; | ||
import { _FirebaseAppInternal as FirebaseAppExp } from '@firebase/app'; | ||
import { Compat } from '@firebase/util'; | ||
/** | ||
@@ -25,6 +26,6 @@ * Global context object for a collection of services using | ||
*/ | ||
export declare class FirebaseAppLiteImpl implements FirebaseApp { | ||
private readonly app; | ||
export declare class FirebaseAppLiteImpl implements FirebaseApp, Compat<FirebaseAppExp> { | ||
readonly _delegate: FirebaseAppExp; | ||
private readonly firebase; | ||
constructor(app: _FirebaseAppInternal, firebase: _FirebaseNamespace); | ||
constructor(_delegate: FirebaseAppExp, firebase: _FirebaseNamespace); | ||
get automaticDataCollectionEnabled(): boolean; | ||
@@ -49,3 +50,3 @@ set automaticDataCollectionEnabled(val: boolean); | ||
*/ | ||
_getService(name: string, instanceIdentifier?: string): FirebaseService; | ||
_getService(name: string, instanceIdentifier?: string): _FirebaseService; | ||
} |
@@ -17,3 +17,3 @@ /** | ||
*/ | ||
import { FirebaseNamespace } from '@firebase/app-types'; | ||
import { FirebaseNamespace } from '../public-types'; | ||
export declare function createFirebaseNamespaceLite(): FirebaseNamespace; |
@@ -17,8 +17,9 @@ /** | ||
*/ | ||
import { FirebaseService } from '@firebase/app-types/private'; | ||
import { FirebaseApp } from '@firebase/app-types'; | ||
import { _FirebaseService } from '../src/types'; | ||
import { FirebaseApp } from '../src/public-types'; | ||
import { ComponentType, Component } from '@firebase/component'; | ||
export declare class TestService implements FirebaseService { | ||
export declare class TestService implements _FirebaseService { | ||
private app_; | ||
instanceIdentifier?: string | undefined; | ||
readonly _delegate: {}; | ||
constructor(app_: FirebaseApp, instanceIdentifier?: string | undefined); | ||
@@ -25,0 +26,0 @@ get app(): FirebaseApp; |
{ | ||
"name": "@firebase/app-compat", | ||
"version": "0.0.900-exp.f919db6a9", | ||
"version": "0.1.0-20217250818", | ||
"description": "The primary entrypoint to the Firebase JS SDK", | ||
"author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)", | ||
"private": false, | ||
"main": "dist/index.cjs.js", | ||
"browser": "dist/index.esm5.js", | ||
"module": "dist/index.esm5.js", | ||
"esm2017": "dist/index.esm2017.js", | ||
"browser": "dist/index.esm2017.js", | ||
"module": "dist/index.esm2017.js", | ||
"lite": "dist/index.lite.js", | ||
"lite-esm2017": "dist/index.lite.esm2017.js", | ||
"lite-esm5": "dist/index.lite.esm5.js", | ||
"files": [ | ||
@@ -20,3 +18,2 @@ "dist" | ||
"build": "rollup -c", | ||
"build:release": "rollup -c rollup.config.release.js", | ||
"build:deps": "lerna run --scope @firebase/app-compat --include-dependencies build", | ||
@@ -33,19 +30,17 @@ "dev": "rollup -c -w", | ||
"dependencies": { | ||
"@firebase/app": "0.0.900-exp.f919db6a9", | ||
"@firebase/util": "0.3.4", | ||
"@firebase/app": "0.7.0-20217250818", | ||
"@firebase/util": "1.3.0", | ||
"@firebase/logger": "0.2.6", | ||
"@firebase/component": "0.1.21", | ||
"tslib": "^1.11.1", | ||
"dom-storage": "2.1.0", | ||
"xmlhttprequest": "1.8.0" | ||
"@firebase/component": "0.5.6", | ||
"tslib": "^2.1.0" | ||
}, | ||
"devDependencies": { | ||
"rollup": "2.35.1", | ||
"rollup": "2.52.2", | ||
"@rollup/plugin-json": "4.1.0", | ||
"rollup-plugin-replace": "2.2.0", | ||
"rollup-plugin-typescript2": "0.29.0", | ||
"typescript": "4.0.5" | ||
"rollup-plugin-typescript2": "0.30.0", | ||
"typescript": "4.2.2" | ||
}, | ||
"repository": { | ||
"directory": "packages-exp/app-compat", | ||
"directory": "packages/app-compat", | ||
"type": "git", | ||
@@ -64,3 +59,3 @@ "url": "https://github.com/firebase/firebase-js-sdk.git" | ||
}, | ||
"peerDependencies": {} | ||
} | ||
"esm5": "dist/index.esm5.js" | ||
} |
# @firebase/app-compat | ||
This is the compat package that recreates the v7 APIs. | ||
This is the compatibility layer for the Firebase App package, which recreates the v8 API. | ||
**This package is not intended for direct usage, and should only be used via the officially supported [firebase](https://www.npmjs.com/package/firebase) package.** |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
219558
5
27
2542
+ Added@firebase/app@0.7.0-20217250818(transitive)
+ Added@firebase/component@0.5.6(transitive)
+ Added@firebase/util@1.3.0(transitive)
+ Addedtslib@2.8.1(transitive)
- Removeddom-storage@2.1.0
- Removedxmlhttprequest@1.8.0
- Removed@firebase/app@0.0.900-exp.f919db6a9(transitive)
- Removed@firebase/app-types@0.0.900-exp.f919db6a9(transitive)
- Removed@firebase/component@0.1.21(transitive)
- Removed@firebase/util@0.3.4(transitive)
- Removeddom-storage@2.1.0(transitive)
- Removedtslib@1.14.1(transitive)
- Removedxmlhttprequest@1.8.0(transitive)
Updated@firebase/component@0.5.6
Updated@firebase/util@1.3.0
Updatedtslib@^2.1.0