1
0
mirror of https://github.com/musix-org/musix-oss synced 2025-06-17 04:26:00 +00:00
This commit is contained in:
MatteZ02
2020-03-03 22:30:50 +02:00
parent edfcc6f474
commit 30022c7634
11800 changed files with 1984416 additions and 1 deletions

20
node_modules/@firebase/component/README.md generated vendored Normal file
View File

@ -0,0 +1,20 @@
# @firebase/component
_NOTE: This is specifically tailored for Firebase JS SDK usage, if you are not a
member of the Firebase team, please avoid using this package_
## Installation
You can install this wrapper by running the following in your project:
```bash
$ npm install @firebase/component
```
## Usage
**ES Modules**
```javascript
import { Component } from '@firebase/component';
```

315
node_modules/@firebase/component/dist/index.cjs.js generated vendored Normal file
View File

@ -0,0 +1,315 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var tslib = require('tslib');
var util = require('@firebase/util');
/**
* Component for service name T, e.g. `auth`, `auth-internal`
*/
var Component = /** @class */ (function () {
/**
*
* @param name The public service name, e.g. app, auth, firestore, database
* @param instanceFactory Service factory responsible for creating the public interface
* @param type whether the service provided by the component is public or private
*/
function Component(name, instanceFactory, type) {
this.name = name;
this.instanceFactory = instanceFactory;
this.type = type;
this.multipleInstances = false;
/**
* Properties to be added to the service namespace
*/
this.serviceProps = {};
this.instantiationMode = "LAZY" /* LAZY */;
}
Component.prototype.setInstantiationMode = function (mode) {
this.instantiationMode = mode;
return this;
};
Component.prototype.setMultipleInstances = function (multipleInstances) {
this.multipleInstances = multipleInstances;
return this;
};
Component.prototype.setServiceProps = function (props) {
this.serviceProps = props;
return this;
};
return Component;
}());
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var DEFAULT_ENTRY_NAME = '[DEFAULT]';
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Provider for instance for service name T, e.g. 'auth', 'auth-internal'
* NameServiceMapping[T] is an alias for the type of the instance
*/
var Provider = /** @class */ (function () {
function Provider(name, container) {
this.name = name;
this.container = container;
this.component = null;
this.instances = new Map();
this.instancesDeferred = new Map();
}
/**
* @param identifier A provider can provide mulitple instances of a service
* if this.component.multipleInstances is true.
*/
Provider.prototype.get = function (identifier) {
if (identifier === void 0) { identifier = DEFAULT_ENTRY_NAME; }
// if multipleInstances is not supported, use the default name
var normalizedIdentifier = this.normalizeInstanceIdentifier(identifier);
if (!this.instancesDeferred.has(normalizedIdentifier)) {
var deferred = new util.Deferred();
this.instancesDeferred.set(normalizedIdentifier, deferred);
// If the service instance is available, resolve the promise with it immediately
try {
var instance = this.getOrInitializeService(normalizedIdentifier);
if (instance) {
deferred.resolve(instance);
}
}
catch (e) {
// when the instance factory throws an exception during get(), it should not cause
// a fatal error. We just return the unresolved promise in this case.
}
}
return this.instancesDeferred.get(normalizedIdentifier).promise;
};
Provider.prototype.getImmediate = function (options) {
var _a = tslib.__assign({ identifier: DEFAULT_ENTRY_NAME, optional: false }, options), identifier = _a.identifier, optional = _a.optional;
// if multipleInstances is not supported, use the default name
var normalizedIdentifier = this.normalizeInstanceIdentifier(identifier);
try {
var instance = this.getOrInitializeService(normalizedIdentifier);
if (!instance) {
if (optional) {
return null;
}
throw Error("Service " + this.name + " is not available");
}
return instance;
}
catch (e) {
if (optional) {
return null;
}
else {
throw e;
}
}
};
Provider.prototype.getComponent = function () {
return this.component;
};
Provider.prototype.setComponent = function (component) {
var e_1, _a;
if (component.name !== this.name) {
throw Error("Mismatching Component " + component.name + " for Provider " + this.name + ".");
}
if (this.component) {
throw Error("Component for " + this.name + " has already been provided");
}
this.component = component;
// if the service is eager, initialize the default instance
if (isComponentEager(component)) {
try {
this.getOrInitializeService(DEFAULT_ENTRY_NAME);
}
catch (e) {
// when the instance factory for an eager Component throws an exception during the eager
// initialization, it should not cause a fatal error.
// TODO: Investigate if we need to make it configurable, because some component may want to cause
// a fatal error in this case?
}
}
try {
// Create service instances for the pending promises and resolve them
// NOTE: if this.multipleInstances is false, only the default instance will be created
// and all promises with resolve with it regardless of the identifier.
for (var _b = tslib.__values(this.instancesDeferred.entries()), _c = _b.next(); !_c.done; _c = _b.next()) {
var _d = tslib.__read(_c.value, 2), instanceIdentifier = _d[0], instanceDeferred = _d[1];
var normalizedIdentifier = this.normalizeInstanceIdentifier(instanceIdentifier);
try {
// `getOrInitializeService()` should always return a valid instance since a component is guaranteed. use ! to make typescript happy.
var instance = this.getOrInitializeService(normalizedIdentifier);
instanceDeferred.resolve(instance);
}
catch (e) {
// when the instance factory throws an exception, it should not cause
// a fatal error. We just leave the promise unresolved.
}
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_1) throw e_1.error; }
}
};
Provider.prototype.clearInstance = function (identifier) {
if (identifier === void 0) { identifier = DEFAULT_ENTRY_NAME; }
this.instancesDeferred.delete(identifier);
this.instances.delete(identifier);
};
// app.delete() will call this method on every provider to delete the services
// TODO: should we mark the provider as deleted?
Provider.prototype.delete = function () {
return tslib.__awaiter(this, void 0, void 0, function () {
var services;
return tslib.__generator(this, function (_a) {
switch (_a.label) {
case 0:
services = Array.from(this.instances.values());
return [4 /*yield*/, Promise.all(services
.filter(function (service) { return 'INTERNAL' in service; })
// eslint-disable-next-line @typescript-eslint/no-explicit-any
.map(function (service) { return service.INTERNAL.delete(); }))];
case 1:
_a.sent();
return [2 /*return*/];
}
});
});
};
Provider.prototype.isComponentSet = function () {
return this.component != null;
};
Provider.prototype.getOrInitializeService = function (identifier) {
var instance = this.instances.get(identifier);
if (!instance && this.component) {
instance = this.component.instanceFactory(this.container, normalizeIdentifierForFactory(identifier));
this.instances.set(identifier, instance);
}
return instance || null;
};
Provider.prototype.normalizeInstanceIdentifier = function (identifier) {
if (this.component) {
return this.component.multipleInstances ? identifier : DEFAULT_ENTRY_NAME;
}
else {
return identifier; // assume multiple instances are supported before the component is provided.
}
};
return Provider;
}());
// undefined should be passed to the service factory for the default instance
function normalizeIdentifierForFactory(identifier) {
return identifier === DEFAULT_ENTRY_NAME ? undefined : identifier;
}
function isComponentEager(component) {
return component.instantiationMode === "EAGER" /* EAGER */;
}
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* ComponentContainer that provides Providers for service name T, e.g. `auth`, `auth-internal`
*/
var ComponentContainer = /** @class */ (function () {
function ComponentContainer(name) {
this.name = name;
this.providers = new Map();
}
/**
*
* @param component Component being added
* @param overwrite When a component with the same name has already been registered,
* if overwrite is true: overwrite the existing component with the new component and create a new
* provider with the new component. It can be useful in tests where you want to use different mocks
* for different tests.
* if overwrite is false: throw an exception
*/
ComponentContainer.prototype.addComponent = function (component) {
var provider = this.getProvider(component.name);
if (provider.isComponentSet()) {
throw new Error("Component " + component.name + " has already been registered with " + this.name);
}
provider.setComponent(component);
};
ComponentContainer.prototype.addOrOverwriteComponent = function (component) {
var provider = this.getProvider(component.name);
if (provider.isComponentSet()) {
// delete the existing provider from the container, so we can register the new component
this.providers.delete(component.name);
}
this.addComponent(component);
};
/**
* getProvider provides a type safe interface where it can only be called with a field name
* present in NameServiceMapping interface.
*
* Firebase SDKs providing services should extend NameServiceMapping interface to register
* themselves.
*/
ComponentContainer.prototype.getProvider = function (name) {
if (this.providers.has(name)) {
return this.providers.get(name);
}
// create a Provider for a service that hasn't registered with Firebase
var provider = new Provider(name, this);
this.providers.set(name, provider);
return provider;
};
ComponentContainer.prototype.getProviders = function () {
return Array.from(this.providers.values());
};
return ComponentContainer;
}());
exports.Component = Component;
exports.ComponentContainer = ComponentContainer;
exports.Provider = Provider;
//# sourceMappingURL=index.cjs.js.map

File diff suppressed because one or more lines are too long

20
node_modules/@firebase/component/dist/index.d.ts generated vendored Normal file
View File

@ -0,0 +1,20 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export { Component } from './src/component';
export { ComponentContainer } from './src/component_container';
export { Provider } from './src/provider';
export { ComponentType, InstanceFactory, InstantiationMode, NameServiceMapping, Name } from './src/types';

309
node_modules/@firebase/component/dist/index.esm.js generated vendored Normal file
View File

@ -0,0 +1,309 @@
import { __assign, __values, __read, __awaiter, __generator } from 'tslib';
import { Deferred } from '@firebase/util';
/**
* Component for service name T, e.g. `auth`, `auth-internal`
*/
var Component = /** @class */ (function () {
/**
*
* @param name The public service name, e.g. app, auth, firestore, database
* @param instanceFactory Service factory responsible for creating the public interface
* @param type whether the service provided by the component is public or private
*/
function Component(name, instanceFactory, type) {
this.name = name;
this.instanceFactory = instanceFactory;
this.type = type;
this.multipleInstances = false;
/**
* Properties to be added to the service namespace
*/
this.serviceProps = {};
this.instantiationMode = "LAZY" /* LAZY */;
}
Component.prototype.setInstantiationMode = function (mode) {
this.instantiationMode = mode;
return this;
};
Component.prototype.setMultipleInstances = function (multipleInstances) {
this.multipleInstances = multipleInstances;
return this;
};
Component.prototype.setServiceProps = function (props) {
this.serviceProps = props;
return this;
};
return Component;
}());
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var DEFAULT_ENTRY_NAME = '[DEFAULT]';
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Provider for instance for service name T, e.g. 'auth', 'auth-internal'
* NameServiceMapping[T] is an alias for the type of the instance
*/
var Provider = /** @class */ (function () {
function Provider(name, container) {
this.name = name;
this.container = container;
this.component = null;
this.instances = new Map();
this.instancesDeferred = new Map();
}
/**
* @param identifier A provider can provide mulitple instances of a service
* if this.component.multipleInstances is true.
*/
Provider.prototype.get = function (identifier) {
if (identifier === void 0) { identifier = DEFAULT_ENTRY_NAME; }
// if multipleInstances is not supported, use the default name
var normalizedIdentifier = this.normalizeInstanceIdentifier(identifier);
if (!this.instancesDeferred.has(normalizedIdentifier)) {
var deferred = new Deferred();
this.instancesDeferred.set(normalizedIdentifier, deferred);
// If the service instance is available, resolve the promise with it immediately
try {
var instance = this.getOrInitializeService(normalizedIdentifier);
if (instance) {
deferred.resolve(instance);
}
}
catch (e) {
// when the instance factory throws an exception during get(), it should not cause
// a fatal error. We just return the unresolved promise in this case.
}
}
return this.instancesDeferred.get(normalizedIdentifier).promise;
};
Provider.prototype.getImmediate = function (options) {
var _a = __assign({ identifier: DEFAULT_ENTRY_NAME, optional: false }, options), identifier = _a.identifier, optional = _a.optional;
// if multipleInstances is not supported, use the default name
var normalizedIdentifier = this.normalizeInstanceIdentifier(identifier);
try {
var instance = this.getOrInitializeService(normalizedIdentifier);
if (!instance) {
if (optional) {
return null;
}
throw Error("Service " + this.name + " is not available");
}
return instance;
}
catch (e) {
if (optional) {
return null;
}
else {
throw e;
}
}
};
Provider.prototype.getComponent = function () {
return this.component;
};
Provider.prototype.setComponent = function (component) {
var e_1, _a;
if (component.name !== this.name) {
throw Error("Mismatching Component " + component.name + " for Provider " + this.name + ".");
}
if (this.component) {
throw Error("Component for " + this.name + " has already been provided");
}
this.component = component;
// if the service is eager, initialize the default instance
if (isComponentEager(component)) {
try {
this.getOrInitializeService(DEFAULT_ENTRY_NAME);
}
catch (e) {
// when the instance factory for an eager Component throws an exception during the eager
// initialization, it should not cause a fatal error.
// TODO: Investigate if we need to make it configurable, because some component may want to cause
// a fatal error in this case?
}
}
try {
// Create service instances for the pending promises and resolve them
// NOTE: if this.multipleInstances is false, only the default instance will be created
// and all promises with resolve with it regardless of the identifier.
for (var _b = __values(this.instancesDeferred.entries()), _c = _b.next(); !_c.done; _c = _b.next()) {
var _d = __read(_c.value, 2), instanceIdentifier = _d[0], instanceDeferred = _d[1];
var normalizedIdentifier = this.normalizeInstanceIdentifier(instanceIdentifier);
try {
// `getOrInitializeService()` should always return a valid instance since a component is guaranteed. use ! to make typescript happy.
var instance = this.getOrInitializeService(normalizedIdentifier);
instanceDeferred.resolve(instance);
}
catch (e) {
// when the instance factory throws an exception, it should not cause
// a fatal error. We just leave the promise unresolved.
}
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_1) throw e_1.error; }
}
};
Provider.prototype.clearInstance = function (identifier) {
if (identifier === void 0) { identifier = DEFAULT_ENTRY_NAME; }
this.instancesDeferred.delete(identifier);
this.instances.delete(identifier);
};
// app.delete() will call this method on every provider to delete the services
// TODO: should we mark the provider as deleted?
Provider.prototype.delete = function () {
return __awaiter(this, void 0, void 0, function () {
var services;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
services = Array.from(this.instances.values());
return [4 /*yield*/, Promise.all(services
.filter(function (service) { return 'INTERNAL' in service; })
// eslint-disable-next-line @typescript-eslint/no-explicit-any
.map(function (service) { return service.INTERNAL.delete(); }))];
case 1:
_a.sent();
return [2 /*return*/];
}
});
});
};
Provider.prototype.isComponentSet = function () {
return this.component != null;
};
Provider.prototype.getOrInitializeService = function (identifier) {
var instance = this.instances.get(identifier);
if (!instance && this.component) {
instance = this.component.instanceFactory(this.container, normalizeIdentifierForFactory(identifier));
this.instances.set(identifier, instance);
}
return instance || null;
};
Provider.prototype.normalizeInstanceIdentifier = function (identifier) {
if (this.component) {
return this.component.multipleInstances ? identifier : DEFAULT_ENTRY_NAME;
}
else {
return identifier; // assume multiple instances are supported before the component is provided.
}
};
return Provider;
}());
// undefined should be passed to the service factory for the default instance
function normalizeIdentifierForFactory(identifier) {
return identifier === DEFAULT_ENTRY_NAME ? undefined : identifier;
}
function isComponentEager(component) {
return component.instantiationMode === "EAGER" /* EAGER */;
}
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* ComponentContainer that provides Providers for service name T, e.g. `auth`, `auth-internal`
*/
var ComponentContainer = /** @class */ (function () {
function ComponentContainer(name) {
this.name = name;
this.providers = new Map();
}
/**
*
* @param component Component being added
* @param overwrite When a component with the same name has already been registered,
* if overwrite is true: overwrite the existing component with the new component and create a new
* provider with the new component. It can be useful in tests where you want to use different mocks
* for different tests.
* if overwrite is false: throw an exception
*/
ComponentContainer.prototype.addComponent = function (component) {
var provider = this.getProvider(component.name);
if (provider.isComponentSet()) {
throw new Error("Component " + component.name + " has already been registered with " + this.name);
}
provider.setComponent(component);
};
ComponentContainer.prototype.addOrOverwriteComponent = function (component) {
var provider = this.getProvider(component.name);
if (provider.isComponentSet()) {
// delete the existing provider from the container, so we can register the new component
this.providers.delete(component.name);
}
this.addComponent(component);
};
/**
* getProvider provides a type safe interface where it can only be called with a field name
* present in NameServiceMapping interface.
*
* Firebase SDKs providing services should extend NameServiceMapping interface to register
* themselves.
*/
ComponentContainer.prototype.getProvider = function (name) {
if (this.providers.has(name)) {
return this.providers.get(name);
}
// create a Provider for a service that hasn't registered with Firebase
var provider = new Provider(name, this);
this.providers.set(name, provider);
return provider;
};
ComponentContainer.prototype.getProviders = function () {
return Array.from(this.providers.values());
};
return ComponentContainer;
}());
export { Component, ComponentContainer, Provider };
//# sourceMappingURL=index.esm.js.map

File diff suppressed because one or more lines are too long

281
node_modules/@firebase/component/dist/index.esm2017.js generated vendored Normal file
View File

@ -0,0 +1,281 @@
import { Deferred } from '@firebase/util';
/**
* Component for service name T, e.g. `auth`, `auth-internal`
*/
class Component {
/**
*
* @param name The public service name, e.g. app, auth, firestore, database
* @param instanceFactory Service factory responsible for creating the public interface
* @param type whether the service provided by the component is public or private
*/
constructor(name, instanceFactory, type) {
this.name = name;
this.instanceFactory = instanceFactory;
this.type = type;
this.multipleInstances = false;
/**
* Properties to be added to the service namespace
*/
this.serviceProps = {};
this.instantiationMode = "LAZY" /* LAZY */;
}
setInstantiationMode(mode) {
this.instantiationMode = mode;
return this;
}
setMultipleInstances(multipleInstances) {
this.multipleInstances = multipleInstances;
return this;
}
setServiceProps(props) {
this.serviceProps = props;
return this;
}
}
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const DEFAULT_ENTRY_NAME = '[DEFAULT]';
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Provider for instance for service name T, e.g. 'auth', 'auth-internal'
* NameServiceMapping[T] is an alias for the type of the instance
*/
class Provider {
constructor(name, container) {
this.name = name;
this.container = container;
this.component = null;
this.instances = new Map();
this.instancesDeferred = new Map();
}
/**
* @param identifier A provider can provide mulitple instances of a service
* if this.component.multipleInstances is true.
*/
get(identifier = DEFAULT_ENTRY_NAME) {
// if multipleInstances is not supported, use the default name
const normalizedIdentifier = this.normalizeInstanceIdentifier(identifier);
if (!this.instancesDeferred.has(normalizedIdentifier)) {
const deferred = new Deferred();
this.instancesDeferred.set(normalizedIdentifier, deferred);
// If the service instance is available, resolve the promise with it immediately
try {
const instance = this.getOrInitializeService(normalizedIdentifier);
if (instance) {
deferred.resolve(instance);
}
}
catch (e) {
// when the instance factory throws an exception during get(), it should not cause
// a fatal error. We just return the unresolved promise in this case.
}
}
return this.instancesDeferred.get(normalizedIdentifier).promise;
}
getImmediate(options) {
const { identifier, optional } = Object.assign({ identifier: DEFAULT_ENTRY_NAME, optional: false }, options);
// if multipleInstances is not supported, use the default name
const normalizedIdentifier = this.normalizeInstanceIdentifier(identifier);
try {
const instance = this.getOrInitializeService(normalizedIdentifier);
if (!instance) {
if (optional) {
return null;
}
throw Error(`Service ${this.name} is not available`);
}
return instance;
}
catch (e) {
if (optional) {
return null;
}
else {
throw e;
}
}
}
getComponent() {
return this.component;
}
setComponent(component) {
if (component.name !== this.name) {
throw Error(`Mismatching Component ${component.name} for Provider ${this.name}.`);
}
if (this.component) {
throw Error(`Component for ${this.name} has already been provided`);
}
this.component = component;
// if the service is eager, initialize the default instance
if (isComponentEager(component)) {
try {
this.getOrInitializeService(DEFAULT_ENTRY_NAME);
}
catch (e) {
// when the instance factory for an eager Component throws an exception during the eager
// initialization, it should not cause a fatal error.
// TODO: Investigate if we need to make it configurable, because some component may want to cause
// a fatal error in this case?
}
}
// Create service instances for the pending promises and resolve them
// NOTE: if this.multipleInstances is false, only the default instance will be created
// and all promises with resolve with it regardless of the identifier.
for (const [instanceIdentifier, instanceDeferred] of this.instancesDeferred.entries()) {
const normalizedIdentifier = this.normalizeInstanceIdentifier(instanceIdentifier);
try {
// `getOrInitializeService()` should always return a valid instance since a component is guaranteed. use ! to make typescript happy.
const instance = this.getOrInitializeService(normalizedIdentifier);
instanceDeferred.resolve(instance);
}
catch (e) {
// when the instance factory throws an exception, it should not cause
// a fatal error. We just leave the promise unresolved.
}
}
}
clearInstance(identifier = DEFAULT_ENTRY_NAME) {
this.instancesDeferred.delete(identifier);
this.instances.delete(identifier);
}
// app.delete() will call this method on every provider to delete the services
// TODO: should we mark the provider as deleted?
async delete() {
const services = Array.from(this.instances.values());
await Promise.all(services
.filter(service => 'INTERNAL' in service)
// eslint-disable-next-line @typescript-eslint/no-explicit-any
.map(service => service.INTERNAL.delete()));
}
isComponentSet() {
return this.component != null;
}
getOrInitializeService(identifier) {
let instance = this.instances.get(identifier);
if (!instance && this.component) {
instance = this.component.instanceFactory(this.container, normalizeIdentifierForFactory(identifier));
this.instances.set(identifier, instance);
}
return instance || null;
}
normalizeInstanceIdentifier(identifier) {
if (this.component) {
return this.component.multipleInstances ? identifier : DEFAULT_ENTRY_NAME;
}
else {
return identifier; // assume multiple instances are supported before the component is provided.
}
}
}
// undefined should be passed to the service factory for the default instance
function normalizeIdentifierForFactory(identifier) {
return identifier === DEFAULT_ENTRY_NAME ? undefined : identifier;
}
function isComponentEager(component) {
return component.instantiationMode === "EAGER" /* EAGER */;
}
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* ComponentContainer that provides Providers for service name T, e.g. `auth`, `auth-internal`
*/
class ComponentContainer {
constructor(name) {
this.name = name;
this.providers = new Map();
}
/**
*
* @param component Component being added
* @param overwrite When a component with the same name has already been registered,
* if overwrite is true: overwrite the existing component with the new component and create a new
* provider with the new component. It can be useful in tests where you want to use different mocks
* for different tests.
* if overwrite is false: throw an exception
*/
addComponent(component) {
const provider = this.getProvider(component.name);
if (provider.isComponentSet()) {
throw new Error(`Component ${component.name} has already been registered with ${this.name}`);
}
provider.setComponent(component);
}
addOrOverwriteComponent(component) {
const provider = this.getProvider(component.name);
if (provider.isComponentSet()) {
// delete the existing provider from the container, so we can register the new component
this.providers.delete(component.name);
}
this.addComponent(component);
}
/**
* getProvider provides a type safe interface where it can only be called with a field name
* present in NameServiceMapping interface.
*
* Firebase SDKs providing services should extend NameServiceMapping interface to register
* themselves.
*/
getProvider(name) {
if (this.providers.has(name)) {
return this.providers.get(name);
}
// create a Provider for a service that hasn't registered with Firebase
const provider = new Provider(name, this);
this.providers.set(name, provider);
return provider;
}
getProviders() {
return Array.from(this.providers.values());
}
}
export { Component, ComponentContainer, Provider };
//# sourceMappingURL=index.esm2017.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,41 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { InstantiationMode, InstanceFactory, ComponentType, Dictionary, Name } from './types';
/**
* Component for service name T, e.g. `auth`, `auth-internal`
*/
export declare class Component<T extends Name = Name> {
readonly name: T;
readonly instanceFactory: InstanceFactory<T>;
readonly type: ComponentType;
multipleInstances: boolean;
/**
* Properties to be added to the service namespace
*/
serviceProps: Dictionary;
instantiationMode: InstantiationMode;
/**
*
* @param name The public service name, e.g. app, auth, firestore, database
* @param instanceFactory Service factory responsible for creating the public interface
* @param type whether the service provided by the component is public or private
*/
constructor(name: T, instanceFactory: InstanceFactory<T>, type: ComponentType);
setInstantiationMode(mode: InstantiationMode): this;
setMultipleInstances(multipleInstances: boolean): this;
setServiceProps(props: Dictionary): this;
}

View File

@ -0,0 +1,47 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Provider } from './provider';
import { Component } from './component';
import { Name } from './types';
/**
* ComponentContainer that provides Providers for service name T, e.g. `auth`, `auth-internal`
*/
export declare class ComponentContainer {
private readonly name;
private readonly providers;
constructor(name: string);
/**
*
* @param component Component being added
* @param overwrite When a component with the same name has already been registered,
* if overwrite is true: overwrite the existing component with the new component and create a new
* provider with the new component. It can be useful in tests where you want to use different mocks
* for different tests.
* if overwrite is false: throw an exception
*/
addComponent<T extends Name>(component: Component<T>): void;
addOrOverwriteComponent<T extends Name>(component: Component<T>): void;
/**
* getProvider provides a type safe interface where it can only be called with a field name
* present in NameServiceMapping interface.
*
* Firebase SDKs providing services should extend NameServiceMapping interface to register
* themselves.
*/
getProvider<T extends Name>(name: T): Provider<T>;
getProviders(): Array<Provider<Name>>;
}

View File

@ -0,0 +1,24 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import '../test/setup';
declare module './types' {
interface NameServiceMapping {
rocket: {};
ship: {};
fireball: {};
}
}

View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export declare const DEFAULT_ENTRY_NAME = "[DEFAULT]";

View File

@ -0,0 +1,59 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ComponentContainer } from './component_container';
import { Name, NameServiceMapping } from './types';
import { Component } from './component';
/**
* Provider for instance for service name T, e.g. 'auth', 'auth-internal'
* NameServiceMapping[T] is an alias for the type of the instance
*/
export declare class Provider<T extends Name> {
private readonly name;
private readonly container;
private component;
private readonly instances;
private readonly instancesDeferred;
constructor(name: T, container: ComponentContainer);
/**
* @param identifier A provider can provide mulitple instances of a service
* if this.component.multipleInstances is true.
*/
get(identifier?: string): Promise<NameServiceMapping[T]>;
/**
*
* @param options.identifier A provider can provide mulitple instances of a service
* if this.component.multipleInstances is true.
* @param options.optional If optional is false or not provided, the method throws an error when
* the service is not immediately available.
* If optional is true, the method returns null if the service is not immediately available.
*/
getImmediate(options: {
identifier?: string;
optional: true;
}): NameServiceMapping[T] | null;
getImmediate(options?: {
identifier?: string;
optional?: false;
}): NameServiceMapping[T];
getComponent(): Component<T> | null;
setComponent(component: Component<T>): void;
clearInstance(identifier?: string): void;
delete(): Promise<void>;
isComponentSet(): boolean;
private getOrInitializeService;
private normalizeInstanceIdentifier;
}

View File

@ -0,0 +1,23 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import '../test/setup';
declare module './types' {
interface NameServiceMapping {
test: {};
badtest: {};
}
}

54
node_modules/@firebase/component/dist/src/types.d.ts generated vendored Normal file
View File

@ -0,0 +1,54 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ComponentContainer } from './component_container';
export declare const enum InstantiationMode {
LAZY = "LAZY",
EAGER = "EAGER"
}
/**
* PUBLIC: A public component provides a set of public APIs to customers. A service namespace will be patched
* onto `firebase` namespace. Assume the component name is `test`, customers will be able
* to get the service by calling `firebase.test()` or `app.test()` where `app` is a `FirebaseApp` instance.
*
* PRIVATE: A private component provides a set of private APIs that are used internally by other
* Firebase SDKs. No serivce namespace is created in `firebase` namespace and customers have no way to get them.
*/
export declare const enum ComponentType {
PUBLIC = "PUBLIC",
PRIVATE = "PRIVATE",
VERSION = "VERSION"
}
/**
* Factory to create an instance of type T, given a ComponentContainer.
* ComponentContainer is the IOC container that provides {@link Provider}
* for dependencies.
*
* NOTE: The container only provides {@link Provider} rather than the actual instances of dependencies.
* It is useful for lazily loaded dependencies and optional dependencies.
*/
export declare type InstanceFactory<T extends Name> = (container: ComponentContainer, instanceIdentifier?: string) => NameServiceMapping[T];
export interface Dictionary {
[key: string]: unknown;
}
/**
* This interface will be extended by Firebase SDKs to provide service name and service type mapping.
* It is used as a generic constraint to ensure type safety.
*/
export interface NameServiceMapping {
}
export declare type Name = keyof NameServiceMapping;
export declare type Service = NameServiceMapping[Name];

17
node_modules/@firebase/component/dist/test/setup.d.ts generated vendored Normal file
View File

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

5
node_modules/@firebase/component/dist/test/util.d.ts generated vendored Normal file
View File

@ -0,0 +1,5 @@
import { FirebaseApp } from '@firebase/app-types';
import { InstanceFactory, InstantiationMode, Name } from '../src/types';
import { Component } from '../src/component';
export declare function getFakeApp(appName?: string): FirebaseApp;
export declare function getFakeComponent<T extends Name>(name: T, factory: InstanceFactory<T>, multipleInstance?: boolean, instantiationMode?: InstantiationMode): Component<T>;

89
node_modules/@firebase/component/package.json generated vendored Normal file
View File

@ -0,0 +1,89 @@
{
"_from": "@firebase/component@0.1.4",
"_id": "@firebase/component@0.1.4",
"_inBundle": false,
"_integrity": "sha512-k3JZFUyHnSWC/7v+x+pIHLDNJPYA6xd7nqrQASOXH5TXhCR9meg0VsnJb+knD18491iRMKJnQWNSHdqPK9AX5w==",
"_location": "/@firebase/component",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@firebase/component@0.1.4",
"name": "@firebase/component",
"escapedName": "@firebase%2fcomponent",
"scope": "@firebase",
"rawSpec": "0.1.4",
"saveSpec": null,
"fetchSpec": "0.1.4"
},
"_requiredBy": [
"/@firebase/analytics",
"/@firebase/app",
"/@firebase/database",
"/@firebase/firestore",
"/@firebase/functions",
"/@firebase/installations",
"/@firebase/messaging",
"/@firebase/performance",
"/@firebase/remote-config",
"/@firebase/storage"
],
"_resolved": "https://registry.npmjs.org/@firebase/component/-/component-0.1.4.tgz",
"_shasum": "ed348a3e2997918b1c4ea13103b7b3e216c12ab9",
"_spec": "@firebase/component@0.1.4",
"_where": "C:\\Users\\matia\\Documents\\GitHub\\Musix-V3\\node_modules\\@firebase\\analytics",
"author": {
"name": "Firebase",
"email": "firebase-support@google.com",
"url": "https://firebase.google.com/"
},
"browser": "dist/index.cjs.js",
"bugs": {
"url": "https://github.com/firebase/firebase-js-sdk/issues"
},
"bundleDependencies": false,
"dependencies": {
"@firebase/util": "0.2.39",
"tslib": "1.10.0"
},
"deprecated": false,
"description": "Firebase Component Platform",
"devDependencies": {
"rollup": "1.28.0",
"rollup-plugin-typescript2": "0.25.3",
"typescript": "3.7.3"
},
"esm2017": "dist/index.esm2017.js",
"files": [
"dist"
],
"homepage": "https://github.com/firebase/firebase-js-sdk#readme",
"license": "Apache-2.0",
"main": "dist/index.cjs.js",
"module": "dist/index.esm.js",
"name": "@firebase/component",
"nyc": {
"extension": [
".ts"
],
"reportDir": "./coverage/node"
},
"repository": {
"directory": "packages/component",
"type": "git",
"url": "git+https://github.com/firebase/firebase-js-sdk.git"
},
"scripts": {
"build": "rollup -c",
"dev": "rollup -c -w",
"lint": "eslint -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
"lint:fix": "eslint --fix -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
"prepare": "yarn build",
"test": "yarn type-check && run-p lint test:browser test:node",
"test:browser": "karma start --single-run",
"test:node": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha src/**/*.test.ts --opts ../../config/mocha.node.opts",
"type-check": "tsc -p . --noEmit"
},
"typings": "dist/index.d.ts",
"version": "0.1.4"
}