@depup/firebase__component 0.7.1-depup.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -0
- package/changes.json +10 -0
- package/dist/esm/index.d.ts +20 -0
- package/dist/esm/index.esm.js +408 -0
- package/dist/esm/index.esm.js.map +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/src/component.d.ts +43 -0
- package/dist/esm/src/component_container.d.ts +47 -0
- package/dist/esm/src/constants.d.ts +17 -0
- package/dist/esm/src/provider.d.ts +79 -0
- package/dist/esm/src/types.d.ts +62 -0
- package/dist/esm/test/setup.d.ts +17 -0
- package/dist/esm/test/util.d.ts +5 -0
- package/dist/index.cjs.js +414 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/src/component.d.ts +43 -0
- package/dist/src/component_container.d.ts +47 -0
- package/dist/src/constants.d.ts +17 -0
- package/dist/src/provider.d.ts +79 -0
- package/dist/src/types.d.ts +62 -0
- package/dist/test/setup.d.ts +17 -0
- package/dist/test/util.d.ts +5 -0
- package/package.json +82 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2019 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { InstantiationMode, InstanceFactory, ComponentType, Dictionary, Name, onInstanceCreatedCallback } from './types';
|
|
18
|
+
/**
|
|
19
|
+
* Component for service name T, e.g. `auth`, `auth-internal`
|
|
20
|
+
*/
|
|
21
|
+
export declare class Component<T extends Name = Name> {
|
|
22
|
+
readonly name: T;
|
|
23
|
+
readonly instanceFactory: InstanceFactory<T>;
|
|
24
|
+
readonly type: ComponentType;
|
|
25
|
+
multipleInstances: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Properties to be added to the service namespace
|
|
28
|
+
*/
|
|
29
|
+
serviceProps: Dictionary;
|
|
30
|
+
instantiationMode: InstantiationMode;
|
|
31
|
+
onInstanceCreated: onInstanceCreatedCallback<T> | null;
|
|
32
|
+
/**
|
|
33
|
+
*
|
|
34
|
+
* @param name The public service name, e.g. app, auth, firestore, database
|
|
35
|
+
* @param instanceFactory Service factory responsible for creating the public interface
|
|
36
|
+
* @param type whether the service provided by the component is public or private
|
|
37
|
+
*/
|
|
38
|
+
constructor(name: T, instanceFactory: InstanceFactory<T>, type: ComponentType);
|
|
39
|
+
setInstantiationMode(mode: InstantiationMode): this;
|
|
40
|
+
setMultipleInstances(multipleInstances: boolean): this;
|
|
41
|
+
setServiceProps(props: Dictionary): this;
|
|
42
|
+
setInstanceCreatedCallback(callback: onInstanceCreatedCallback<T>): this;
|
|
43
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2019 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { Provider } from './provider';
|
|
18
|
+
import { Component } from './component';
|
|
19
|
+
import { Name } from './types';
|
|
20
|
+
/**
|
|
21
|
+
* ComponentContainer that provides Providers for service name T, e.g. `auth`, `auth-internal`
|
|
22
|
+
*/
|
|
23
|
+
export declare class ComponentContainer {
|
|
24
|
+
private readonly name;
|
|
25
|
+
private readonly providers;
|
|
26
|
+
constructor(name: string);
|
|
27
|
+
/**
|
|
28
|
+
*
|
|
29
|
+
* @param component Component being added
|
|
30
|
+
* @param overwrite When a component with the same name has already been registered,
|
|
31
|
+
* if overwrite is true: overwrite the existing component with the new component and create a new
|
|
32
|
+
* provider with the new component. It can be useful in tests where you want to use different mocks
|
|
33
|
+
* for different tests.
|
|
34
|
+
* if overwrite is false: throw an exception
|
|
35
|
+
*/
|
|
36
|
+
addComponent<T extends Name>(component: Component<T>): void;
|
|
37
|
+
addOrOverwriteComponent<T extends Name>(component: Component<T>): void;
|
|
38
|
+
/**
|
|
39
|
+
* getProvider provides a type safe interface where it can only be called with a field name
|
|
40
|
+
* present in NameServiceMapping interface.
|
|
41
|
+
*
|
|
42
|
+
* Firebase SDKs providing services should extend NameServiceMapping interface to register
|
|
43
|
+
* themselves.
|
|
44
|
+
*/
|
|
45
|
+
getProvider<T extends Name>(name: T): Provider<T>;
|
|
46
|
+
getProviders(): Array<Provider<Name>>;
|
|
47
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2019 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
export declare const DEFAULT_ENTRY_NAME = "[DEFAULT]";
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2019 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { ComponentContainer } from './component_container';
|
|
18
|
+
import { InitializeOptions, Name, NameServiceMapping, OnInitCallBack } from './types';
|
|
19
|
+
import { Component } from './component';
|
|
20
|
+
/**
|
|
21
|
+
* Provider for instance for service name T, e.g. 'auth', 'auth-internal'
|
|
22
|
+
* NameServiceMapping[T] is an alias for the type of the instance
|
|
23
|
+
*/
|
|
24
|
+
export declare class Provider<T extends Name> {
|
|
25
|
+
private readonly name;
|
|
26
|
+
private readonly container;
|
|
27
|
+
private component;
|
|
28
|
+
private readonly instances;
|
|
29
|
+
private readonly instancesDeferred;
|
|
30
|
+
private readonly instancesOptions;
|
|
31
|
+
private onInitCallbacks;
|
|
32
|
+
constructor(name: T, container: ComponentContainer);
|
|
33
|
+
/**
|
|
34
|
+
* @param identifier A provider can provide multiple instances of a service
|
|
35
|
+
* if this.component.multipleInstances is true.
|
|
36
|
+
*/
|
|
37
|
+
get(identifier?: string): Promise<NameServiceMapping[T]>;
|
|
38
|
+
/**
|
|
39
|
+
*
|
|
40
|
+
* @param options.identifier A provider can provide multiple instances of a service
|
|
41
|
+
* if this.component.multipleInstances is true.
|
|
42
|
+
* @param options.optional If optional is false or not provided, the method throws an error when
|
|
43
|
+
* the service is not immediately available.
|
|
44
|
+
* If optional is true, the method returns null if the service is not immediately available.
|
|
45
|
+
*/
|
|
46
|
+
getImmediate(options: {
|
|
47
|
+
identifier?: string;
|
|
48
|
+
optional: true;
|
|
49
|
+
}): NameServiceMapping[T] | null;
|
|
50
|
+
getImmediate(options?: {
|
|
51
|
+
identifier?: string;
|
|
52
|
+
optional?: false;
|
|
53
|
+
}): NameServiceMapping[T];
|
|
54
|
+
getComponent(): Component<T> | null;
|
|
55
|
+
setComponent(component: Component<T>): void;
|
|
56
|
+
clearInstance(identifier?: string): void;
|
|
57
|
+
delete(): Promise<void>;
|
|
58
|
+
isComponentSet(): boolean;
|
|
59
|
+
isInitialized(identifier?: string): boolean;
|
|
60
|
+
getOptions(identifier?: string): Record<string, unknown>;
|
|
61
|
+
initialize(opts?: InitializeOptions): NameServiceMapping[T];
|
|
62
|
+
/**
|
|
63
|
+
*
|
|
64
|
+
* @param callback - a function that will be invoked after the provider has been initialized by calling provider.initialize().
|
|
65
|
+
* The function is invoked SYNCHRONOUSLY, so it should not execute any longrunning tasks in order to not block the program.
|
|
66
|
+
*
|
|
67
|
+
* @param identifier An optional instance identifier
|
|
68
|
+
* @returns a function to unregister the callback
|
|
69
|
+
*/
|
|
70
|
+
onInit(callback: OnInitCallBack<T>, identifier?: string): () => void;
|
|
71
|
+
/**
|
|
72
|
+
* Invoke onInit callbacks synchronously
|
|
73
|
+
* @param instance the service instance`
|
|
74
|
+
*/
|
|
75
|
+
private invokeOnInitCallbacks;
|
|
76
|
+
private getOrInitializeService;
|
|
77
|
+
private normalizeInstanceIdentifier;
|
|
78
|
+
private shouldAutoInitialize;
|
|
79
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2019 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { ComponentContainer } from './component_container';
|
|
18
|
+
export declare const enum InstantiationMode {
|
|
19
|
+
LAZY = "LAZY",// Currently most components are LAZY in JS SDK
|
|
20
|
+
EAGER = "EAGER",// EAGER components are initialized immediately upon registration
|
|
21
|
+
EXPLICIT = "EXPLICIT"
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* PUBLIC: A public component provides a set of public APIs to customers. A service namespace will be patched
|
|
25
|
+
* onto `firebase` namespace. Assume the component name is `test`, customers will be able
|
|
26
|
+
* to get the service by calling `firebase.test()` or `app.test()` where `app` is a `FirebaseApp` instance.
|
|
27
|
+
*
|
|
28
|
+
* PRIVATE: A private component provides a set of private APIs that are used internally by other
|
|
29
|
+
* Firebase SDKs. No service namespace is created in `firebase` namespace and customers have no way to get them.
|
|
30
|
+
*/
|
|
31
|
+
export declare const enum ComponentType {
|
|
32
|
+
PUBLIC = "PUBLIC",
|
|
33
|
+
PRIVATE = "PRIVATE",
|
|
34
|
+
VERSION = "VERSION"
|
|
35
|
+
}
|
|
36
|
+
export interface InstanceFactoryOptions {
|
|
37
|
+
instanceIdentifier?: string;
|
|
38
|
+
options?: {};
|
|
39
|
+
}
|
|
40
|
+
export type InitializeOptions = InstanceFactoryOptions;
|
|
41
|
+
/**
|
|
42
|
+
* Factory to create an instance of type T, given a ComponentContainer.
|
|
43
|
+
* ComponentContainer is the IOC container that provides {@link Provider}
|
|
44
|
+
* for dependencies.
|
|
45
|
+
*
|
|
46
|
+
* NOTE: The container only provides {@link Provider} rather than the actual instances of dependencies.
|
|
47
|
+
* It is useful for lazily loaded dependencies and optional dependencies.
|
|
48
|
+
*/
|
|
49
|
+
export type InstanceFactory<T extends Name> = (container: ComponentContainer, options: InstanceFactoryOptions) => NameServiceMapping[T];
|
|
50
|
+
export type onInstanceCreatedCallback<T extends Name> = (container: ComponentContainer, instanceIdentifier: string, instance: NameServiceMapping[T]) => void;
|
|
51
|
+
export interface Dictionary {
|
|
52
|
+
[key: string]: unknown;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* This interface will be extended by Firebase SDKs to provide service name and service type mapping.
|
|
56
|
+
* It is used as a generic constraint to ensure type safety.
|
|
57
|
+
*/
|
|
58
|
+
export interface NameServiceMapping {
|
|
59
|
+
}
|
|
60
|
+
export type Name = keyof NameServiceMapping;
|
|
61
|
+
export type Service = NameServiceMapping[Name];
|
|
62
|
+
export type OnInitCallBack<T extends Name> = (instance: NameServiceMapping[T], identifier: string) => void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2019 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { FirebaseApp } from '@firebase/app-types';
|
|
2
|
+
import { InstanceFactory, InstantiationMode, Name } from '../src/types';
|
|
3
|
+
import { Component } from '../src/component';
|
|
4
|
+
export declare function getFakeApp(appName?: string): FirebaseApp;
|
|
5
|
+
export declare function getFakeComponent<T extends Name>(name: T, factory: InstanceFactory<T>, multipleInstance?: boolean, instantiationMode?: InstantiationMode): Component<T>;
|
package/package.json
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@depup/firebase__component",
|
|
3
|
+
"version": "0.7.1-depup.0",
|
|
4
|
+
"description": "[DepUp] Firebase Component Platform",
|
|
5
|
+
"author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",
|
|
6
|
+
"main": "dist/index.cjs.js",
|
|
7
|
+
"browser": "dist/esm/index.esm.js",
|
|
8
|
+
"module": "dist/esm/index.esm.js",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"require": "./dist/index.cjs.js",
|
|
13
|
+
"default": "./dist/esm/index.esm.js"
|
|
14
|
+
},
|
|
15
|
+
"./package.json": "./package.json"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"changes.json",
|
|
20
|
+
"README.md"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"lint": "eslint -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
|
|
24
|
+
"lint:fix": "eslint --fix -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
|
|
25
|
+
"build": "rollup -c",
|
|
26
|
+
"build:deps": "lerna run --scope @firebase/component --include-dependencies build",
|
|
27
|
+
"dev": "rollup -c -w",
|
|
28
|
+
"test": "run-p --npm-path npm lint test:all",
|
|
29
|
+
"test:all": "run-p --npm-path npm test:browser test:node",
|
|
30
|
+
"test:ci": "node ../../scripts/run_tests_in_ci.js -s test:all",
|
|
31
|
+
"test:browser": "karma start",
|
|
32
|
+
"test:node": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha src/**/*.test.ts --config ../../config/mocharc.node.js",
|
|
33
|
+
"trusted-type-check": "tsec -p tsconfig.json --noEmit"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@firebase/util": "1.14.0",
|
|
37
|
+
"tslib": "^2.8.1"
|
|
38
|
+
},
|
|
39
|
+
"license": "Apache-2.0",
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"rollup": "2.79.2",
|
|
42
|
+
"rollup-plugin-typescript2": "0.36.0",
|
|
43
|
+
"typescript": "5.5.4"
|
|
44
|
+
},
|
|
45
|
+
"repository": {
|
|
46
|
+
"directory": "packages/component",
|
|
47
|
+
"type": "git",
|
|
48
|
+
"url": "git+https://github.com/firebase/firebase-js-sdk.git"
|
|
49
|
+
},
|
|
50
|
+
"bugs": {
|
|
51
|
+
"url": "https://github.com/firebase/firebase-js-sdk/issues"
|
|
52
|
+
},
|
|
53
|
+
"typings": "dist/index.d.ts",
|
|
54
|
+
"nyc": {
|
|
55
|
+
"extension": [
|
|
56
|
+
".ts"
|
|
57
|
+
],
|
|
58
|
+
"reportDir": "./coverage/node"
|
|
59
|
+
},
|
|
60
|
+
"engines": {
|
|
61
|
+
"node": ">=20.0.0"
|
|
62
|
+
},
|
|
63
|
+
"keywords": [
|
|
64
|
+
"depup",
|
|
65
|
+
"dependency-bumped",
|
|
66
|
+
"updated-deps",
|
|
67
|
+
"@firebase/component"
|
|
68
|
+
],
|
|
69
|
+
"depup": {
|
|
70
|
+
"changes": {
|
|
71
|
+
"tslib": {
|
|
72
|
+
"from": "^2.1.0",
|
|
73
|
+
"to": "^2.8.1"
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
"depsUpdated": 1,
|
|
77
|
+
"originalPackage": "@firebase/component",
|
|
78
|
+
"originalVersion": "0.7.1",
|
|
79
|
+
"processedAt": "2026-03-17T16:32:20.508Z",
|
|
80
|
+
"smokeTest": "passed"
|
|
81
|
+
}
|
|
82
|
+
}
|