ts-ioc-container 33.0.1 → 33.0.2
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/cjm/container/AutoMockedContainer.js +1 -3
- package/cjm/container/Container.js +3 -4
- package/cjm/container/EmptyContainer.js +1 -3
- package/esm/container/AutoMockedContainer.js +1 -3
- package/esm/container/Container.js +3 -4
- package/esm/container/EmptyContainer.js +1 -3
- package/package.json +2 -2
- package/typings/container/AutoMockedContainer.d.ts +1 -1
- package/typings/container/Container.d.ts +1 -1
- package/typings/container/EmptyContainer.d.ts +1 -1
- package/typings/container/IContainer.d.ts +2 -1
|
@@ -8,6 +8,7 @@ class AutoMockedContainer {
|
|
|
8
8
|
this.id = '0';
|
|
9
9
|
this.level = 0;
|
|
10
10
|
this.tags = new Set();
|
|
11
|
+
this.isDisposed = false;
|
|
11
12
|
}
|
|
12
13
|
findChild(matchFn) {
|
|
13
14
|
return undefined;
|
|
@@ -53,8 +54,5 @@ class AutoMockedContainer {
|
|
|
53
54
|
hasInstance(value) {
|
|
54
55
|
throw new MethodNotImplementedError_1.MethodNotImplementedError();
|
|
55
56
|
}
|
|
56
|
-
hasOwnInstance(value) {
|
|
57
|
-
throw new MethodNotImplementedError_1.MethodNotImplementedError();
|
|
58
|
-
}
|
|
59
57
|
}
|
|
60
58
|
exports.AutoMockedContainer = AutoMockedContainer;
|
|
@@ -62,9 +62,9 @@ class Container {
|
|
|
62
62
|
}
|
|
63
63
|
getInstances(direction = 'child') {
|
|
64
64
|
if (direction === 'parent') {
|
|
65
|
-
return this.parent.getInstances('parent')
|
|
65
|
+
return [...this.parent.getInstances('parent'), ...this.instances];
|
|
66
66
|
}
|
|
67
|
-
const instances =
|
|
67
|
+
const instances = Array.from(this.instances);
|
|
68
68
|
for (const scope of this.scopes) {
|
|
69
69
|
instances.push(...scope.getInstances('child'));
|
|
70
70
|
}
|
|
@@ -132,8 +132,7 @@ class Container {
|
|
|
132
132
|
* @private
|
|
133
133
|
*/
|
|
134
134
|
getRegistrations() {
|
|
135
|
-
|
|
136
|
-
return this.registrations.length > 0 ? registrations.concat(this.registrations) : registrations;
|
|
135
|
+
return [...this.parent.getRegistrations(), ...this.registrations];
|
|
137
136
|
}
|
|
138
137
|
/**
|
|
139
138
|
* @private
|
|
@@ -8,13 +8,11 @@ class EmptyContainer {
|
|
|
8
8
|
this.level = -1;
|
|
9
9
|
this.id = 'empty';
|
|
10
10
|
this.tags = new Set();
|
|
11
|
+
this.isDisposed = false;
|
|
11
12
|
}
|
|
12
13
|
hasInstance(value) {
|
|
13
14
|
throw new MethodNotImplementedError_1.MethodNotImplementedError();
|
|
14
15
|
}
|
|
15
|
-
hasOwnInstance(value) {
|
|
16
|
-
throw new MethodNotImplementedError_1.MethodNotImplementedError();
|
|
17
|
-
}
|
|
18
16
|
reduceToRoot(fn, initial) {
|
|
19
17
|
return initial;
|
|
20
18
|
}
|
|
@@ -5,6 +5,7 @@ export class AutoMockedContainer {
|
|
|
5
5
|
this.id = '0';
|
|
6
6
|
this.level = 0;
|
|
7
7
|
this.tags = new Set();
|
|
8
|
+
this.isDisposed = false;
|
|
8
9
|
}
|
|
9
10
|
findChild(matchFn) {
|
|
10
11
|
return undefined;
|
|
@@ -50,7 +51,4 @@ export class AutoMockedContainer {
|
|
|
50
51
|
hasInstance(value) {
|
|
51
52
|
throw new MethodNotImplementedError();
|
|
52
53
|
}
|
|
53
|
-
hasOwnInstance(value) {
|
|
54
|
-
throw new MethodNotImplementedError();
|
|
55
|
-
}
|
|
56
54
|
}
|
|
@@ -59,9 +59,9 @@ export class Container {
|
|
|
59
59
|
}
|
|
60
60
|
getInstances(direction = 'child') {
|
|
61
61
|
if (direction === 'parent') {
|
|
62
|
-
return this.parent.getInstances('parent')
|
|
62
|
+
return [...this.parent.getInstances('parent'), ...this.instances];
|
|
63
63
|
}
|
|
64
|
-
const instances =
|
|
64
|
+
const instances = Array.from(this.instances);
|
|
65
65
|
for (const scope of this.scopes) {
|
|
66
66
|
instances.push(...scope.getInstances('child'));
|
|
67
67
|
}
|
|
@@ -129,8 +129,7 @@ export class Container {
|
|
|
129
129
|
* @private
|
|
130
130
|
*/
|
|
131
131
|
getRegistrations() {
|
|
132
|
-
|
|
133
|
-
return this.registrations.length > 0 ? registrations.concat(this.registrations) : registrations;
|
|
132
|
+
return [...this.parent.getRegistrations(), ...this.registrations];
|
|
134
133
|
}
|
|
135
134
|
/**
|
|
136
135
|
* @private
|
|
@@ -5,13 +5,11 @@ export class EmptyContainer {
|
|
|
5
5
|
this.level = -1;
|
|
6
6
|
this.id = 'empty';
|
|
7
7
|
this.tags = new Set();
|
|
8
|
+
this.isDisposed = false;
|
|
8
9
|
}
|
|
9
10
|
hasInstance(value) {
|
|
10
11
|
throw new MethodNotImplementedError();
|
|
11
12
|
}
|
|
12
|
-
hasOwnInstance(value) {
|
|
13
|
-
throw new MethodNotImplementedError();
|
|
14
|
-
}
|
|
15
13
|
reduceToRoot(fn, initial) {
|
|
16
14
|
return initial;
|
|
17
15
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-ioc-container",
|
|
3
|
-
"version": "33.0.
|
|
3
|
+
"version": "33.0.2",
|
|
4
4
|
"description": "Typescript IoC container",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"ts-node": "^10.9.1",
|
|
60
60
|
"typescript": "5.4.3"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "2fc46f490e00dfdf60d77861dee309bdcf039d39"
|
|
63
63
|
}
|
|
@@ -4,6 +4,7 @@ export declare abstract class AutoMockedContainer implements IContainer {
|
|
|
4
4
|
id: string;
|
|
5
5
|
level: number;
|
|
6
6
|
tags: Set<string>;
|
|
7
|
+
isDisposed: boolean;
|
|
7
8
|
findChild(matchFn: (s: IContainer) => boolean): IContainer | undefined;
|
|
8
9
|
findParent(matchFn: (s: IContainer) => boolean): IContainer | undefined;
|
|
9
10
|
hasDependency(key: string): boolean;
|
|
@@ -21,5 +22,4 @@ export declare abstract class AutoMockedContainer implements IContainer {
|
|
|
21
22
|
resolveManyByAlias(predicate: AliasPredicate, options?: ResolveOptions, result?: Map<DependencyKey, unknown>): Map<DependencyKey, unknown>;
|
|
22
23
|
resolveOneByAlias<T>(predicate: AliasPredicate, options?: ResolveOptions): [DependencyKey, T];
|
|
23
24
|
hasInstance(value: object): boolean;
|
|
24
|
-
hasOwnInstance(value: object): boolean;
|
|
25
25
|
}
|
|
@@ -5,11 +5,11 @@ import { IRegistration } from '../registration/IRegistration';
|
|
|
5
5
|
import { Counter } from './Counter';
|
|
6
6
|
export declare class Container implements IContainer {
|
|
7
7
|
private readonly injector;
|
|
8
|
+
isDisposed: boolean;
|
|
8
9
|
readonly id: string;
|
|
9
10
|
readonly tags: Set<Tag>;
|
|
10
11
|
readonly level: number;
|
|
11
12
|
private parent;
|
|
12
|
-
private isDisposed;
|
|
13
13
|
private readonly providers;
|
|
14
14
|
private readonly scopes;
|
|
15
15
|
private readonly instances;
|
|
@@ -5,8 +5,8 @@ export declare class EmptyContainer implements IContainer {
|
|
|
5
5
|
level: number;
|
|
6
6
|
id: string;
|
|
7
7
|
tags: Set<string>;
|
|
8
|
+
isDisposed: boolean;
|
|
8
9
|
hasInstance(value: object): boolean;
|
|
9
|
-
hasOwnInstance(value: object): boolean;
|
|
10
10
|
reduceToRoot<TResult>(fn: ReduceScope<TResult>, initial: TResult): TResult;
|
|
11
11
|
findChild(matchFn: (s: IContainer) => boolean): IContainer | undefined;
|
|
12
12
|
findParent(matchFn: (s: IContainer) => boolean): IContainer | undefined;
|
|
@@ -26,7 +26,8 @@ export type Alias = string;
|
|
|
26
26
|
export type AliasPredicate = (aliases: Set<Alias>) => boolean;
|
|
27
27
|
export type ReduceScope<TResult> = (acc: TResult, container: IContainer) => TResult;
|
|
28
28
|
export interface IContainer extends Resolvable, Tagged {
|
|
29
|
-
tags: Set<Tag>;
|
|
29
|
+
readonly tags: Set<Tag>;
|
|
30
|
+
readonly isDisposed: boolean;
|
|
30
31
|
createScope(...tags: Tag[]): IContainer;
|
|
31
32
|
register(key: DependencyKey, value: IProvider): this;
|
|
32
33
|
add(registration: IRegistration): this;
|