inversify 6.0.3 → 6.1.1
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/CHANGELOG.md +14 -0
- package/README.md +14 -14
- package/amd/annotation/decorator_utils.js +3 -1
- package/amd/annotation/inject_base.js +1 -1
- package/amd/annotation/lazy_service_identifier.js +0 -11
- package/amd/bindings/binding.js +3 -2
- package/amd/bindings/binding_count.js +6 -5
- package/amd/constants/error_msgs.js +18 -18
- package/amd/constants/literal_types.js +3 -3
- package/amd/container/container.js +73 -34
- package/amd/container/lookup.js +15 -14
- package/amd/container/module_activation_store.js +8 -10
- package/amd/interfaces/interfaces.js +0 -5
- package/amd/inversify.js +3 -5
- package/amd/planning/metadata_reader.js +5 -3
- package/amd/planning/planner.js +31 -13
- package/amd/planning/queryable_string.js +5 -2
- package/amd/planning/reflection_utils.js +6 -112
- package/amd/planning/request.js +2 -4
- package/amd/planning/target.js +9 -3
- package/amd/resolution/instantiation.js +10 -5
- package/amd/resolution/resolver.js +19 -10
- package/amd/scope/scope.js +1 -1
- package/amd/syntax/binding_to_syntax.js +14 -7
- package/amd/syntax/binding_when_syntax.js +13 -8
- package/amd/syntax/constraint_helpers.js +4 -3
- package/amd/utils/async.js +3 -2
- package/amd/utils/binding_utils.js +8 -3
- package/amd/utils/clonable.js +4 -4
- package/amd/utils/exceptions.js +1 -1
- package/amd/utils/serialization.js +11 -8
- package/es/annotation/decorator_utils.js +3 -1
- package/es/annotation/inject_base.js +1 -1
- package/es/annotation/lazy_service_identifier.js +1 -10
- package/es/annotation/target_name.js +3 -3
- package/es/bindings/binding.js +3 -2
- package/es/bindings/binding_count.js +6 -5
- package/es/constants/error_msgs.js +17 -17
- package/es/constants/literal_types.js +3 -3
- package/es/container/container.js +74 -35
- package/es/container/lookup.js +15 -14
- package/es/container/module_activation_store.js +8 -10
- package/es/interfaces/interfaces.js +1 -5
- package/es/inversify.js +4 -6
- package/es/planning/metadata_reader.js +5 -3
- package/es/planning/planner.js +34 -16
- package/es/planning/queryable_string.js +5 -2
- package/es/planning/reflection_utils.js +6 -114
- package/es/planning/request.js +2 -4
- package/es/planning/target.js +9 -3
- package/es/resolution/instantiation.js +11 -6
- package/es/resolution/resolver.js +20 -11
- package/es/scope/scope.js +1 -1
- package/es/syntax/binding_to_syntax.js +18 -11
- package/es/syntax/binding_when_syntax.js +14 -9
- package/es/syntax/constraint_helpers.js +5 -4
- package/es/utils/async.js +3 -2
- package/es/utils/binding_utils.js +8 -3
- package/es/utils/clonable.js +4 -4
- package/es/utils/exceptions.js +1 -1
- package/es/utils/serialization.js +12 -9
- package/es6/annotation/decorator_utils.js +5 -3
- package/es6/annotation/inject_base.js +1 -1
- package/es6/annotation/lazy_service_identifier.js +0 -10
- package/es6/bindings/binding.js +3 -2
- package/es6/bindings/binding_count.js +6 -5
- package/es6/constants/error_msgs.js +5 -9
- package/es6/constants/literal_types.js +3 -3
- package/es6/container/container.js +59 -42
- package/es6/container/lookup.js +15 -14
- package/es6/container/module_activation_store.js +8 -10
- package/es6/interfaces/interfaces.js +0 -5
- package/es6/inversify.js +3 -7
- package/es6/planning/metadata_reader.js +5 -3
- package/es6/planning/planner.js +31 -13
- package/es6/planning/queryable_string.js +5 -2
- package/es6/planning/reflection_utils.js +4 -110
- package/es6/planning/request.js +2 -4
- package/es6/planning/target.js +3 -1
- package/es6/resolution/instantiation.js +9 -5
- package/es6/resolution/resolver.js +11 -8
- package/es6/scope/scope.js +1 -1
- package/es6/syntax/binding_to_syntax.js +5 -4
- package/es6/syntax/binding_when_syntax.js +13 -8
- package/es6/syntax/constraint_helpers.js +4 -3
- package/es6/utils/async.js +3 -2
- package/es6/utils/binding_utils.js +10 -3
- package/es6/utils/clonable.js +4 -4
- package/es6/utils/exceptions.js +1 -1
- package/es6/utils/serialization.js +11 -8
- package/lib/annotation/decorator_utils.d.ts +2 -2
- package/lib/annotation/decorator_utils.js +3 -1
- package/lib/annotation/inject.d.ts +4 -1
- package/lib/annotation/inject_base.d.ts +3 -2
- package/lib/annotation/inject_base.js +1 -1
- package/lib/annotation/lazy_service_identifier.d.ts +1 -5
- package/lib/annotation/lazy_service_identifier.js +0 -11
- package/lib/annotation/multi_inject.d.ts +4 -1
- package/lib/annotation/tagged.d.ts +1 -1
- package/lib/annotation/target_name.d.ts +1 -1
- package/lib/bindings/binding.js +3 -2
- package/lib/bindings/binding_count.d.ts +5 -5
- package/lib/bindings/binding_count.js +6 -5
- package/lib/constants/error_msgs.d.ts +18 -20
- package/lib/constants/error_msgs.js +18 -18
- package/lib/constants/literal_types.js +3 -3
- package/lib/constants/metadata_keys.d.ts +12 -12
- package/lib/container/container.d.ts +2 -2
- package/lib/container/container.js +73 -34
- package/lib/container/lookup.d.ts +2 -1
- package/lib/container/lookup.js +15 -14
- package/lib/container/module_activation_store.d.ts +1 -1
- package/lib/container/module_activation_store.js +8 -10
- package/lib/interfaces/interfaces.d.ts +14 -29
- package/lib/interfaces/interfaces.js +0 -5
- package/lib/inversify.d.ts +5 -6
- package/lib/inversify.js +3 -7
- package/lib/planning/metadata_reader.js +5 -3
- package/lib/planning/planner.js +31 -13
- package/lib/planning/queryable_string.d.ts +2 -3
- package/lib/planning/queryable_string.js +5 -2
- package/lib/planning/reflection_utils.js +6 -114
- package/lib/planning/request.d.ts +2 -2
- package/lib/planning/request.js +2 -4
- package/lib/planning/target.d.ts +1 -1
- package/lib/planning/target.js +9 -3
- package/lib/resolution/instantiation.js +10 -5
- package/lib/resolution/resolver.js +19 -10
- package/lib/scope/scope.js +1 -1
- package/lib/syntax/binding_in_syntax.d.ts +1 -1
- package/lib/syntax/binding_in_when_on_syntax.d.ts +7 -7
- package/lib/syntax/binding_on_syntax.d.ts +1 -1
- package/lib/syntax/binding_to_syntax.d.ts +4 -4
- package/lib/syntax/binding_to_syntax.js +14 -7
- package/lib/syntax/binding_when_on_syntax.d.ts +6 -6
- package/lib/syntax/binding_when_syntax.d.ts +4 -4
- package/lib/syntax/binding_when_syntax.js +13 -8
- package/lib/syntax/constraint_helpers.d.ts +2 -2
- package/lib/syntax/constraint_helpers.js +4 -3
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/utils/async.js +3 -2
- package/lib/utils/binding_utils.js +8 -3
- package/lib/utils/clonable.js +4 -4
- package/lib/utils/exceptions.js +1 -1
- package/lib/utils/serialization.d.ts +3 -3
- package/lib/utils/serialization.js +11 -8
- package/package.json +19 -5
- package/.nyc_output/c29b2307-4e95-47d0-b220-9efcfa7ee49f.json +0 -1
- package/.nyc_output/processinfo/c29b2307-4e95-47d0-b220-9efcfa7ee49f.json +0 -1
- package/.nyc_output/processinfo/index.json +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -12,6 +12,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
12
12
|
|
|
13
13
|
### Fixed
|
|
14
14
|
|
|
15
|
+
## [6.1.1]
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
- Bumped `@inversifyjs/common` and `@inversifyjs/core` fixing wrong dev engines constraints.
|
|
19
|
+
|
|
20
|
+
## [6.1.0]
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
- Updated `ServiceIdentifier` to rely on `Function` instead of `Abstract<T>`.
|
|
24
|
+
- `injectable` decorator is no longer required.
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
- Fixed `Target.getNameTag` with the right type: `number | string | symbol`.
|
|
28
|
+
|
|
15
29
|
## [6.0.3]
|
|
16
30
|
|
|
17
31
|
### Fixed
|
package/README.md
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|

|
|
2
2
|
|
|
3
3
|
<p align="center">
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
<a href="https://www.npmjs.com/package/inversify" target="__blank"><img src="https://img.shields.io/npm/v/inversify?color=0476bc&label=" alt="NPM version"></a>
|
|
5
|
+
<a href="https://www.npmjs.com/package/inversify" target="__blank"><img alt="NPM Downloads" src="https://img.shields.io/npm/dm/inversify?color=3890aa&label="></a>
|
|
6
|
+
<a href="https://github.com/inversify/InversifyJS#-the-inversifyjs-features-and-api" target="__blank"><img src="https://img.shields.io/static/v1?label=&message=docs&color=1e8a7a" alt="Docs"></a>
|
|
7
|
+
<a href="https://codecov.io/gh/inversify/InversifyJS" target="__blank"><img alt="Codecov" src="https://codecov.io/gh/inversify/InversifyJS/branch/master/graph/badge.svg?token=KfAKzuGs01"></a>
|
|
8
|
+
<br>
|
|
9
|
+
<br>
|
|
10
|
+
<a href="https://github.com/inversify/InversifyJS" target="__blank"><img alt="GitHub stars" src="https://img.shields.io/github/stars/inversify/InversifyJS?style=social"></a>
|
|
11
|
+
<!--<a href="https://twitter.com/inversifyjs" target="__blank"><img alt="Twitter" src="https://img.shields.io/twitter/follow/InversifyJS.svg?maxAge=86400&style=social"></a>-->
|
|
12
|
+
<a href="https://discord.gg/jXcMagAPnm" target="__blank"><img alt="Discord Server" src="https://img.shields.io/discord/816766547879657532?style=social&logo=discord"></a>
|
|
13
13
|
</p>
|
|
14
14
|
|
|
15
15
|
# InversifyJS
|
|
@@ -144,9 +144,9 @@ export { TYPES };
|
|
|
144
144
|
> **Note**: It is recommended to use Symbols but InversifyJS also support the usage of Classes and string literals (please refer to the features section to learn more).
|
|
145
145
|
|
|
146
146
|
### Step 2: Declare dependencies using the `@injectable` & `@inject` decorators
|
|
147
|
-
Let's continue by declaring some classes (concretions). The classes are implementations of the interfaces that we just declared.
|
|
147
|
+
Let's continue by declaring some classes (concretions). The classes are implementations of the interfaces that we just declared. We will annotate them with the `@injectable` decorator.
|
|
148
148
|
|
|
149
|
-
When a class has a
|
|
149
|
+
When a class has a dependency on an interface we also need to use the `@inject` decorator to define an identifier for the interface that will be available at runtime. In this case we will use the Symbols `Symbol.for("Weapon")` and `Symbol.for("ThrowableWeapon")` as runtime identifiers.
|
|
150
150
|
|
|
151
151
|
```ts
|
|
152
152
|
// file entities.ts
|
|
@@ -176,9 +176,9 @@ class Ninja implements Warrior {
|
|
|
176
176
|
private _katana: Weapon;
|
|
177
177
|
private _shuriken: ThrowableWeapon;
|
|
178
178
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
179
|
+
constructor(
|
|
180
|
+
@inject(TYPES.Weapon) katana: Weapon,
|
|
181
|
+
@inject(TYPES.ThrowableWeapon) shuriken: ThrowableWeapon
|
|
182
182
|
) {
|
|
183
183
|
this._katana = katana;
|
|
184
184
|
this._shuriken = shuriken;
|
|
@@ -101,7 +101,9 @@ define(["require", "exports", "../constants/error_msgs", "../constants/metadata_
|
|
|
101
101
|
Reflect.decorate(decorators, target);
|
|
102
102
|
}
|
|
103
103
|
function _param(paramIndex, decorator) {
|
|
104
|
-
return function (target, key) {
|
|
104
|
+
return function (target, key) {
|
|
105
|
+
decorator(target, key, paramIndex);
|
|
106
|
+
};
|
|
105
107
|
}
|
|
106
108
|
function decorate(decorator, target, parameterIndexOrProperty) {
|
|
107
109
|
if (typeof parameterIndexOrProperty === 'number') {
|
|
@@ -9,7 +9,7 @@ define(["require", "exports", "../constants/error_msgs", "../planning/metadata",
|
|
|
9
9
|
var className = typeof target === 'function' ? target.name : target.constructor.name;
|
|
10
10
|
throw new Error((0, error_msgs_1.UNDEFINED_INJECT_ANNOTATION)(className));
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
(0, decorator_utils_1.createTaggedDecorator)(new metadata_1.Metadata(metadataKey, serviceIdentifier))(target, targetKey, indexOrPropertyDescriptor);
|
|
13
13
|
};
|
|
14
14
|
};
|
|
15
15
|
}
|
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
define(["require", "exports"], function (require, exports) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.LazyServiceIdentifier = void 0;
|
|
5
|
-
var LazyServiceIdentifier = (function () {
|
|
6
|
-
function LazyServiceIdentifier(cb) {
|
|
7
|
-
this._cb = cb;
|
|
8
|
-
}
|
|
9
|
-
LazyServiceIdentifier.prototype.unwrap = function () {
|
|
10
|
-
return this._cb();
|
|
11
|
-
};
|
|
12
|
-
return LazyServiceIdentifier;
|
|
13
|
-
}());
|
|
14
|
-
exports.LazyServiceIdentifier = LazyServiceIdentifier;
|
|
15
4
|
});
|
package/amd/bindings/binding.js
CHANGED
|
@@ -9,7 +9,7 @@ define(["require", "exports", "../constants/literal_types", "../utils/id"], func
|
|
|
9
9
|
this.serviceIdentifier = serviceIdentifier;
|
|
10
10
|
this.scope = scope;
|
|
11
11
|
this.type = literal_types_1.BindingTypeEnum.Invalid;
|
|
12
|
-
this.constraint = function (
|
|
12
|
+
this.constraint = function (_request) { return true; };
|
|
13
13
|
this.implementationType = null;
|
|
14
14
|
this.cache = null;
|
|
15
15
|
this.factory = null;
|
|
@@ -20,7 +20,8 @@ define(["require", "exports", "../constants/literal_types", "../utils/id"], func
|
|
|
20
20
|
}
|
|
21
21
|
Binding.prototype.clone = function () {
|
|
22
22
|
var clone = new Binding(this.serviceIdentifier, this.scope);
|
|
23
|
-
clone.activated =
|
|
23
|
+
clone.activated =
|
|
24
|
+
clone.scope === literal_types_1.BindingScopeEnum.Singleton ? this.activated : false;
|
|
24
25
|
clone.implementationType = this.implementationType;
|
|
25
26
|
clone.dynamicValue = this.dynamicValue;
|
|
26
27
|
clone.scope = this.scope;
|
|
@@ -2,9 +2,10 @@ define(["require", "exports"], function (require, exports) {
|
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.BindingCount = void 0;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
var BindingCount;
|
|
6
|
+
(function (BindingCount) {
|
|
7
|
+
BindingCount[BindingCount["MultipleBindingsAvailable"] = 2] = "MultipleBindingsAvailable";
|
|
8
|
+
BindingCount[BindingCount["NoBindingsAvailable"] = 0] = "NoBindingsAvailable";
|
|
9
|
+
BindingCount[BindingCount["OnlyOneBindingAvailable"] = 1] = "OnlyOneBindingAvailable";
|
|
10
|
+
})(BindingCount || (exports.BindingCount = BindingCount = {}));
|
|
10
11
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
define(["require", "exports"], function (require, exports) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.STACK_OVERFLOW = exports.CIRCULAR_DEPENDENCY_IN_FACTORY = exports.ON_DEACTIVATION_ERROR = exports.PRE_DESTROY_ERROR = exports.POST_CONSTRUCT_ERROR = exports.ASYNC_UNBIND_REQUIRED = exports.MULTIPLE_POST_CONSTRUCT_METHODS = exports.MULTIPLE_PRE_DESTROY_METHODS = exports.CONTAINER_OPTIONS_INVALID_SKIP_BASE_CHECK = exports.CONTAINER_OPTIONS_INVALID_AUTO_BIND_INJECTABLE = exports.CONTAINER_OPTIONS_INVALID_DEFAULT_SCOPE = exports.CONTAINER_OPTIONS_MUST_BE_AN_OBJECT = exports.ARGUMENTS_LENGTH_MISMATCH = exports.INVALID_DECORATOR_OPERATION = exports.INVALID_TO_SELF_VALUE = exports.LAZY_IN_SYNC = exports.INVALID_FUNCTION_BINDING = exports.INVALID_MIDDLEWARE_RETURN = exports.NO_MORE_SNAPSHOTS_AVAILABLE = exports.INVALID_BINDING_TYPE = exports.
|
|
4
|
+
exports.STACK_OVERFLOW = exports.CIRCULAR_DEPENDENCY_IN_FACTORY = exports.ON_DEACTIVATION_ERROR = exports.PRE_DESTROY_ERROR = exports.POST_CONSTRUCT_ERROR = exports.ASYNC_UNBIND_REQUIRED = exports.MULTIPLE_POST_CONSTRUCT_METHODS = exports.MULTIPLE_PRE_DESTROY_METHODS = exports.CONTAINER_OPTIONS_INVALID_SKIP_BASE_CHECK = exports.CONTAINER_OPTIONS_INVALID_AUTO_BIND_INJECTABLE = exports.CONTAINER_OPTIONS_INVALID_DEFAULT_SCOPE = exports.CONTAINER_OPTIONS_MUST_BE_AN_OBJECT = exports.ARGUMENTS_LENGTH_MISMATCH = exports.INVALID_DECORATOR_OPERATION = exports.INVALID_TO_SELF_VALUE = exports.LAZY_IN_SYNC = exports.INVALID_FUNCTION_BINDING = exports.INVALID_MIDDLEWARE_RETURN = exports.NO_MORE_SNAPSHOTS_AVAILABLE = exports.INVALID_BINDING_TYPE = exports.CIRCULAR_DEPENDENCY = exports.UNDEFINED_INJECT_ANNOTATION = exports.MISSING_INJECTABLE_ANNOTATION = exports.NOT_REGISTERED = exports.CANNOT_UNBIND = exports.AMBIGUOUS_MATCH = exports.KEY_NOT_FOUND = exports.NULL_ARGUMENT = exports.DUPLICATED_METADATA = exports.DUPLICATED_INJECTABLE_DECORATOR = void 0;
|
|
5
5
|
exports.DUPLICATED_INJECTABLE_DECORATOR = 'Cannot apply @injectable decorator multiple times.';
|
|
6
6
|
exports.DUPLICATED_METADATA = 'Metadata key was used more than once in a parameter:';
|
|
7
7
|
exports.NULL_ARGUMENT = 'NULL argument';
|
|
@@ -10,7 +10,6 @@ define(["require", "exports"], function (require, exports) {
|
|
|
10
10
|
exports.CANNOT_UNBIND = 'Could not unbind serviceIdentifier:';
|
|
11
11
|
exports.NOT_REGISTERED = 'No matching bindings found for serviceIdentifier:';
|
|
12
12
|
exports.MISSING_INJECTABLE_ANNOTATION = 'Missing required @injectable annotation in:';
|
|
13
|
-
exports.MISSING_INJECT_ANNOTATION = 'Missing required @inject or @multiInject annotation in:';
|
|
14
13
|
var UNDEFINED_INJECT_ANNOTATION = function (name) {
|
|
15
14
|
return "@inject called with undefined this could mean that the class ".concat(name, " has ") +
|
|
16
15
|
'a circular dependency problem. You can use a LazyServiceIdentifer to ' +
|
|
@@ -18,43 +17,44 @@ define(["require", "exports"], function (require, exports) {
|
|
|
18
17
|
};
|
|
19
18
|
exports.UNDEFINED_INJECT_ANNOTATION = UNDEFINED_INJECT_ANNOTATION;
|
|
20
19
|
exports.CIRCULAR_DEPENDENCY = 'Circular dependency found:';
|
|
21
|
-
exports.NOT_IMPLEMENTED = 'Sorry, this feature is not fully implemented yet.';
|
|
22
20
|
exports.INVALID_BINDING_TYPE = 'Invalid binding type:';
|
|
23
21
|
exports.NO_MORE_SNAPSHOTS_AVAILABLE = 'No snapshot available to restore.';
|
|
24
22
|
exports.INVALID_MIDDLEWARE_RETURN = 'Invalid return type in middleware. Middleware must return!';
|
|
25
23
|
exports.INVALID_FUNCTION_BINDING = 'Value provided to function binding must be a function!';
|
|
26
|
-
var LAZY_IN_SYNC = function (key) {
|
|
27
|
-
|
|
24
|
+
var LAZY_IN_SYNC = function (key) {
|
|
25
|
+
return "You are attempting to construct ".concat(keyToString(key), " in a synchronous way ") +
|
|
26
|
+
'but it has asynchronous dependencies.';
|
|
27
|
+
};
|
|
28
28
|
exports.LAZY_IN_SYNC = LAZY_IN_SYNC;
|
|
29
29
|
exports.INVALID_TO_SELF_VALUE = 'The toSelf function can only be applied when a constructor is ' +
|
|
30
30
|
'used as service identifier';
|
|
31
31
|
exports.INVALID_DECORATOR_OPERATION = 'The @inject @multiInject @tagged and @named decorators ' +
|
|
32
32
|
'must be applied to the parameters of a class constructor or a class property.';
|
|
33
|
-
var ARGUMENTS_LENGTH_MISMATCH = function () {
|
|
34
|
-
var values = [];
|
|
35
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
36
|
-
values[_i] = arguments[_i];
|
|
37
|
-
}
|
|
33
|
+
var ARGUMENTS_LENGTH_MISMATCH = function (name) {
|
|
38
34
|
return 'The number of constructor arguments in the derived class ' +
|
|
39
|
-
"".concat(
|
|
35
|
+
"".concat(name, " must be >= than the number of constructor arguments of its base class.");
|
|
40
36
|
};
|
|
41
37
|
exports.ARGUMENTS_LENGTH_MISMATCH = ARGUMENTS_LENGTH_MISMATCH;
|
|
42
38
|
exports.CONTAINER_OPTIONS_MUST_BE_AN_OBJECT = 'Invalid Container constructor argument. Container options ' +
|
|
43
39
|
'must be an object.';
|
|
44
40
|
exports.CONTAINER_OPTIONS_INVALID_DEFAULT_SCOPE = 'Invalid Container option. Default scope must ' +
|
|
45
41
|
'be a string ("singleton" or "transient").';
|
|
46
|
-
exports.CONTAINER_OPTIONS_INVALID_AUTO_BIND_INJECTABLE = 'Invalid Container option. Auto bind injectable must ' +
|
|
47
|
-
|
|
48
|
-
exports.CONTAINER_OPTIONS_INVALID_SKIP_BASE_CHECK = 'Invalid Container option. Skip base check must ' +
|
|
49
|
-
'be a boolean';
|
|
42
|
+
exports.CONTAINER_OPTIONS_INVALID_AUTO_BIND_INJECTABLE = 'Invalid Container option. Auto bind injectable must ' + 'be a boolean';
|
|
43
|
+
exports.CONTAINER_OPTIONS_INVALID_SKIP_BASE_CHECK = 'Invalid Container option. Skip base check must ' + 'be a boolean';
|
|
50
44
|
exports.MULTIPLE_PRE_DESTROY_METHODS = 'Cannot apply @preDestroy decorator multiple times in the same class';
|
|
51
45
|
exports.MULTIPLE_POST_CONSTRUCT_METHODS = 'Cannot apply @postConstruct decorator multiple times in the same class';
|
|
52
46
|
exports.ASYNC_UNBIND_REQUIRED = 'Attempting to unbind dependency with asynchronous destruction (@preDestroy or onDeactivation)';
|
|
53
|
-
var POST_CONSTRUCT_ERROR = function (clazz, errorMessage) {
|
|
47
|
+
var POST_CONSTRUCT_ERROR = function (clazz, errorMessage) {
|
|
48
|
+
return "@postConstruct error in class ".concat(clazz, ": ").concat(errorMessage);
|
|
49
|
+
};
|
|
54
50
|
exports.POST_CONSTRUCT_ERROR = POST_CONSTRUCT_ERROR;
|
|
55
|
-
var PRE_DESTROY_ERROR = function (clazz, errorMessage) {
|
|
51
|
+
var PRE_DESTROY_ERROR = function (clazz, errorMessage) {
|
|
52
|
+
return "@preDestroy error in class ".concat(clazz, ": ").concat(errorMessage);
|
|
53
|
+
};
|
|
56
54
|
exports.PRE_DESTROY_ERROR = PRE_DESTROY_ERROR;
|
|
57
|
-
var ON_DEACTIVATION_ERROR = function (clazz, errorMessage) {
|
|
55
|
+
var ON_DEACTIVATION_ERROR = function (clazz, errorMessage) {
|
|
56
|
+
return "onDeactivation() error in class ".concat(clazz, ": ").concat(errorMessage);
|
|
57
|
+
};
|
|
58
58
|
exports.ON_DEACTIVATION_ERROR = ON_DEACTIVATION_ERROR;
|
|
59
59
|
var CIRCULAR_DEPENDENCY_IN_FACTORY = function (factoryType, serviceIdentifier) {
|
|
60
60
|
return "It looks like there is a circular dependency in one of the '".concat(factoryType, "' bindings. Please investigate bindings with ") +
|
|
@@ -5,7 +5,7 @@ define(["require", "exports"], function (require, exports) {
|
|
|
5
5
|
var BindingScopeEnum = {
|
|
6
6
|
Request: 'Request',
|
|
7
7
|
Singleton: 'Singleton',
|
|
8
|
-
Transient: 'Transient'
|
|
8
|
+
Transient: 'Transient',
|
|
9
9
|
};
|
|
10
10
|
exports.BindingScopeEnum = BindingScopeEnum;
|
|
11
11
|
var BindingTypeEnum = {
|
|
@@ -16,13 +16,13 @@ define(["require", "exports"], function (require, exports) {
|
|
|
16
16
|
Function: 'Function',
|
|
17
17
|
Instance: 'Instance',
|
|
18
18
|
Invalid: 'Invalid',
|
|
19
|
-
Provider: 'Provider'
|
|
19
|
+
Provider: 'Provider',
|
|
20
20
|
};
|
|
21
21
|
exports.BindingTypeEnum = BindingTypeEnum;
|
|
22
22
|
var TargetTypeEnum = {
|
|
23
23
|
ClassProperty: 'ClassProperty',
|
|
24
24
|
ConstructorArgument: 'ConstructorArgument',
|
|
25
|
-
Variable: 'Variable'
|
|
25
|
+
Variable: 'Variable',
|
|
26
26
|
};
|
|
27
27
|
exports.TargetTypeEnum = TargetTypeEnum;
|
|
28
28
|
});
|
|
@@ -87,7 +87,7 @@ define(["require", "exports", "../bindings/binding", "../constants/error_msgs",
|
|
|
87
87
|
function Container(containerOptions) {
|
|
88
88
|
var options = containerOptions || {};
|
|
89
89
|
if (typeof options !== 'object') {
|
|
90
|
-
throw new Error(
|
|
90
|
+
throw new Error(ERROR_MSGS.CONTAINER_OPTIONS_MUST_BE_AN_OBJECT);
|
|
91
91
|
}
|
|
92
92
|
if (options.defaultScope === undefined) {
|
|
93
93
|
options.defaultScope = literal_types_1.BindingScopeEnum.Transient;
|
|
@@ -95,24 +95,24 @@ define(["require", "exports", "../bindings/binding", "../constants/error_msgs",
|
|
|
95
95
|
else if (options.defaultScope !== literal_types_1.BindingScopeEnum.Singleton &&
|
|
96
96
|
options.defaultScope !== literal_types_1.BindingScopeEnum.Transient &&
|
|
97
97
|
options.defaultScope !== literal_types_1.BindingScopeEnum.Request) {
|
|
98
|
-
throw new Error(
|
|
98
|
+
throw new Error(ERROR_MSGS.CONTAINER_OPTIONS_INVALID_DEFAULT_SCOPE);
|
|
99
99
|
}
|
|
100
100
|
if (options.autoBindInjectable === undefined) {
|
|
101
101
|
options.autoBindInjectable = false;
|
|
102
102
|
}
|
|
103
103
|
else if (typeof options.autoBindInjectable !== 'boolean') {
|
|
104
|
-
throw new Error(
|
|
104
|
+
throw new Error(ERROR_MSGS.CONTAINER_OPTIONS_INVALID_AUTO_BIND_INJECTABLE);
|
|
105
105
|
}
|
|
106
106
|
if (options.skipBaseClassChecks === undefined) {
|
|
107
107
|
options.skipBaseClassChecks = false;
|
|
108
108
|
}
|
|
109
109
|
else if (typeof options.skipBaseClassChecks !== 'boolean') {
|
|
110
|
-
throw new Error(
|
|
110
|
+
throw new Error(ERROR_MSGS.CONTAINER_OPTIONS_INVALID_SKIP_BASE_CHECK);
|
|
111
111
|
}
|
|
112
112
|
this.options = {
|
|
113
113
|
autoBindInjectable: options.autoBindInjectable,
|
|
114
114
|
defaultScope: options.defaultScope,
|
|
115
|
-
skipBaseClassChecks: options.skipBaseClassChecks
|
|
115
|
+
skipBaseClassChecks: options.skipBaseClassChecks,
|
|
116
116
|
};
|
|
117
117
|
this.id = (0, id_1.id)();
|
|
118
118
|
this._bindingDictionary = new lookup_1.Lookup();
|
|
@@ -130,7 +130,12 @@ define(["require", "exports", "../bindings/binding", "../constants/error_msgs",
|
|
|
130
130
|
containers[_i - 2] = arguments[_i];
|
|
131
131
|
}
|
|
132
132
|
var container = new Container();
|
|
133
|
-
var targetContainers = __spreadArray([
|
|
133
|
+
var targetContainers = __spreadArray([
|
|
134
|
+
container1,
|
|
135
|
+
container2
|
|
136
|
+
], containers, true).map(function (targetContainer) {
|
|
137
|
+
return (0, planner_1.getBindingDictionary)(targetContainer);
|
|
138
|
+
});
|
|
134
139
|
var bindingDictionary = (0, planner_1.getBindingDictionary)(container);
|
|
135
140
|
function copyDictionary(origin, destination) {
|
|
136
141
|
origin.traverse(function (_key, value) {
|
|
@@ -356,7 +361,9 @@ define(["require", "exports", "../bindings/binding", "../constants/error_msgs",
|
|
|
356
361
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
357
362
|
middlewares[_i] = arguments[_i];
|
|
358
363
|
}
|
|
359
|
-
var initial =
|
|
364
|
+
var initial = this._middleware
|
|
365
|
+
? this._middleware
|
|
366
|
+
: this._planAndResolve();
|
|
360
367
|
this._middleware = middlewares.reduce(function (prev, curr) { return curr(prev); }, initial);
|
|
361
368
|
};
|
|
362
369
|
Container.prototype.applyCustomMetadataReader = function (metadataReader) {
|
|
@@ -392,29 +399,47 @@ define(["require", "exports", "../bindings/binding", "../constants/error_msgs",
|
|
|
392
399
|
return this.getTagged(serviceIdentifier, METADATA_KEY.NAMED_TAG, named);
|
|
393
400
|
};
|
|
394
401
|
Container.prototype.getNamedAsync = function (serviceIdentifier, named) {
|
|
395
|
-
return this
|
|
402
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
403
|
+
return __generator(this, function (_a) {
|
|
404
|
+
return [2, this.getTaggedAsync(serviceIdentifier, METADATA_KEY.NAMED_TAG, named)];
|
|
405
|
+
});
|
|
406
|
+
});
|
|
396
407
|
};
|
|
397
408
|
Container.prototype.getAll = function (serviceIdentifier) {
|
|
398
409
|
var getArgs = this._getAllArgs(serviceIdentifier);
|
|
399
410
|
return this._getButThrowIfAsync(getArgs);
|
|
400
411
|
};
|
|
401
412
|
Container.prototype.getAllAsync = function (serviceIdentifier) {
|
|
402
|
-
|
|
403
|
-
|
|
413
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
414
|
+
var getArgs;
|
|
415
|
+
return __generator(this, function (_a) {
|
|
416
|
+
getArgs = this._getAllArgs(serviceIdentifier);
|
|
417
|
+
return [2, this._getAll(getArgs)];
|
|
418
|
+
});
|
|
419
|
+
});
|
|
404
420
|
};
|
|
405
421
|
Container.prototype.getAllTagged = function (serviceIdentifier, key, value) {
|
|
406
422
|
var getArgs = this._getNotAllArgs(serviceIdentifier, true, key, value);
|
|
407
423
|
return this._getButThrowIfAsync(getArgs);
|
|
408
424
|
};
|
|
409
425
|
Container.prototype.getAllTaggedAsync = function (serviceIdentifier, key, value) {
|
|
410
|
-
|
|
411
|
-
|
|
426
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
427
|
+
var getArgs;
|
|
428
|
+
return __generator(this, function (_a) {
|
|
429
|
+
getArgs = this._getNotAllArgs(serviceIdentifier, true, key, value);
|
|
430
|
+
return [2, this._getAll(getArgs)];
|
|
431
|
+
});
|
|
432
|
+
});
|
|
412
433
|
};
|
|
413
434
|
Container.prototype.getAllNamed = function (serviceIdentifier, named) {
|
|
414
435
|
return this.getAllTagged(serviceIdentifier, METADATA_KEY.NAMED_TAG, named);
|
|
415
436
|
};
|
|
416
437
|
Container.prototype.getAllNamedAsync = function (serviceIdentifier, named) {
|
|
417
|
-
return this
|
|
438
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
439
|
+
return __generator(this, function (_a) {
|
|
440
|
+
return [2, this.getAllTaggedAsync(serviceIdentifier, METADATA_KEY.NAMED_TAG, named)];
|
|
441
|
+
});
|
|
442
|
+
});
|
|
418
443
|
};
|
|
419
444
|
Container.prototype.resolve = function (constructorFunction) {
|
|
420
445
|
var isBound = this.isBound(constructorFunction);
|
|
@@ -449,7 +474,11 @@ define(["require", "exports", "../bindings/binding", "../constants/error_msgs",
|
|
|
449
474
|
if (this._deactivations.hasKey(binding.serviceIdentifier)) {
|
|
450
475
|
var result = this._deactivateContainer(instance, this._deactivations.get(binding.serviceIdentifier).values());
|
|
451
476
|
if ((0, async_1.isPromise)(result)) {
|
|
452
|
-
return this._handleDeactivationError(result.then(function () { return _this
|
|
477
|
+
return this._handleDeactivationError(result.then(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
478
|
+
return __generator(this, function (_a) {
|
|
479
|
+
return [2, this._propagateContainerDeactivationThenBindingAndPreDestroyAsync(binding, instance, constructor)];
|
|
480
|
+
});
|
|
481
|
+
}); }), constructor);
|
|
453
482
|
}
|
|
454
483
|
}
|
|
455
484
|
var propagateDeactivationResult = this._propagateContainerDeactivationThenBindingAndPreDestroy(binding, instance, constructor);
|
|
@@ -488,12 +517,12 @@ define(["require", "exports", "../bindings/binding", "../constants/error_msgs",
|
|
|
488
517
|
Container.prototype._deactivateContainer = function (instance, deactivationsIterator) {
|
|
489
518
|
var _this = this;
|
|
490
519
|
var deactivation = deactivationsIterator.next();
|
|
491
|
-
while (deactivation.value) {
|
|
520
|
+
while (typeof deactivation.value === 'function') {
|
|
492
521
|
var result = deactivation.value(instance);
|
|
493
522
|
if ((0, async_1.isPromise)(result)) {
|
|
494
|
-
return result.then(function () {
|
|
495
|
-
return
|
|
496
|
-
});
|
|
523
|
+
return result.then(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
524
|
+
return [2, this._deactivateContainerAsync(instance, deactivationsIterator)];
|
|
525
|
+
}); }); });
|
|
497
526
|
}
|
|
498
527
|
deactivation = deactivationsIterator.next();
|
|
499
528
|
}
|
|
@@ -507,7 +536,7 @@ define(["require", "exports", "../bindings/binding", "../constants/error_msgs",
|
|
|
507
536
|
deactivation = deactivationsIterator.next();
|
|
508
537
|
_a.label = 1;
|
|
509
538
|
case 1:
|
|
510
|
-
if (!deactivation.value) return [3, 3];
|
|
539
|
+
if (!(typeof deactivation.value === 'function')) return [3, 3];
|
|
511
540
|
return [4, deactivation.value(instance)];
|
|
512
541
|
case 2:
|
|
513
542
|
_a.sent();
|
|
@@ -530,15 +559,15 @@ define(["require", "exports", "../bindings/binding", "../constants/error_msgs",
|
|
|
530
559
|
return bindingToSyntax;
|
|
531
560
|
};
|
|
532
561
|
};
|
|
533
|
-
var getUnbindFunction = function () {
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
};
|
|
537
|
-
};
|
|
562
|
+
var getUnbindFunction = function () { return function (serviceIdentifier) {
|
|
563
|
+
_this.unbind(serviceIdentifier);
|
|
564
|
+
}; };
|
|
538
565
|
var getUnbindAsyncFunction = function () {
|
|
539
|
-
return function (serviceIdentifier) {
|
|
540
|
-
return
|
|
541
|
-
|
|
566
|
+
return function (serviceIdentifier) { return __awaiter(_this, void 0, void 0, function () {
|
|
567
|
+
return __generator(this, function (_a) {
|
|
568
|
+
return [2, this.unbindAsync(serviceIdentifier)];
|
|
569
|
+
});
|
|
570
|
+
}); };
|
|
542
571
|
};
|
|
543
572
|
var getIsboundFunction = function () {
|
|
544
573
|
return function (serviceIdentifier) {
|
|
@@ -570,12 +599,16 @@ define(["require", "exports", "../bindings/binding", "../constants/error_msgs",
|
|
|
570
599
|
onActivationFunction: getOnActivationFunction(mId),
|
|
571
600
|
onDeactivationFunction: getOnDeactivationFunction(mId),
|
|
572
601
|
rebindFunction: getRebindFunction(mId),
|
|
602
|
+
unbindAsyncFunction: getUnbindAsyncFunction(),
|
|
573
603
|
unbindFunction: getUnbindFunction(),
|
|
574
|
-
unbindAsyncFunction: getUnbindAsyncFunction()
|
|
575
604
|
}); };
|
|
576
605
|
};
|
|
577
606
|
Container.prototype._getAll = function (getArgs) {
|
|
578
|
-
return
|
|
607
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
608
|
+
return __generator(this, function (_a) {
|
|
609
|
+
return [2, Promise.all(this._get(getArgs))];
|
|
610
|
+
});
|
|
611
|
+
});
|
|
579
612
|
};
|
|
580
613
|
Container.prototype._get = function (getArgs) {
|
|
581
614
|
var planAndResolveArgs = __assign(__assign({}, getArgs), { contextInterceptor: function (context) { return context; }, targetType: literal_types_1.TargetTypeEnum.Variable });
|
|
@@ -607,8 +640,8 @@ define(["require", "exports", "../bindings/binding", "../constants/error_msgs",
|
|
|
607
640
|
var getNotAllArgs = {
|
|
608
641
|
avoidConstraints: false,
|
|
609
642
|
isMultiInject: isMultiInject,
|
|
610
|
-
serviceIdentifier: serviceIdentifier,
|
|
611
643
|
key: key,
|
|
644
|
+
serviceIdentifier: serviceIdentifier,
|
|
612
645
|
value: value,
|
|
613
646
|
};
|
|
614
647
|
return getNotAllArgs;
|
|
@@ -628,7 +661,9 @@ define(["require", "exports", "../bindings/binding", "../constants/error_msgs",
|
|
|
628
661
|
return;
|
|
629
662
|
}
|
|
630
663
|
if ((0, async_1.isPromise)(binding.cache)) {
|
|
631
|
-
return binding.cache.then(function (resolved) {
|
|
664
|
+
return binding.cache.then(function (resolved) {
|
|
665
|
+
return _this._deactivate(binding, resolved);
|
|
666
|
+
});
|
|
632
667
|
}
|
|
633
668
|
return this._deactivate(binding, binding.cache);
|
|
634
669
|
};
|
|
@@ -646,7 +681,9 @@ define(["require", "exports", "../bindings/binding", "../constants/error_msgs",
|
|
|
646
681
|
var _this = this;
|
|
647
682
|
return __generator(this, function (_a) {
|
|
648
683
|
switch (_a.label) {
|
|
649
|
-
case 0: return [4, Promise.all(bindings.map(function (b) { return _this
|
|
684
|
+
case 0: return [4, Promise.all(bindings.map(function (b) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
685
|
+
return [2, this._deactivateIfSingleton(b)];
|
|
686
|
+
}); }); }))];
|
|
650
687
|
case 1:
|
|
651
688
|
_a.sent();
|
|
652
689
|
return [2];
|
|
@@ -685,7 +722,7 @@ define(["require", "exports", "../bindings/binding", "../constants/error_msgs",
|
|
|
685
722
|
try {
|
|
686
723
|
this._bindingDictionary.remove(serviceIdentifier);
|
|
687
724
|
}
|
|
688
|
-
catch (
|
|
725
|
+
catch (_e) {
|
|
689
726
|
throw new Error("".concat(ERROR_MSGS.CANNOT_UNBIND, " ").concat((0, serialization_1.getServiceIdentifierAsString)(serviceIdentifier)));
|
|
690
727
|
}
|
|
691
728
|
};
|
|
@@ -694,7 +731,9 @@ define(["require", "exports", "../bindings/binding", "../constants/error_msgs",
|
|
|
694
731
|
if (typeof binding.onDeactivation === 'function') {
|
|
695
732
|
var result = binding.onDeactivation(instance);
|
|
696
733
|
if ((0, async_1.isPromise)(result)) {
|
|
697
|
-
return result.then(function () {
|
|
734
|
+
return result.then(function () {
|
|
735
|
+
return _this._preDestroy(constructor, instance);
|
|
736
|
+
});
|
|
698
737
|
}
|
|
699
738
|
}
|
|
700
739
|
return this._preDestroy(constructor, instance);
|
package/amd/container/lookup.js
CHANGED
|
@@ -34,9 +34,7 @@ define(["require", "exports", "../constants/error_msgs", "../utils/clonable"], f
|
|
|
34
34
|
return this._map;
|
|
35
35
|
};
|
|
36
36
|
Lookup.prototype.add = function (serviceIdentifier, value) {
|
|
37
|
-
|
|
38
|
-
throw new Error(ERROR_MSGS.NULL_ARGUMENT);
|
|
39
|
-
}
|
|
37
|
+
this._checkNonNulish(serviceIdentifier);
|
|
40
38
|
if (value === null || value === undefined) {
|
|
41
39
|
throw new Error(ERROR_MSGS.NULL_ARGUMENT);
|
|
42
40
|
}
|
|
@@ -49,9 +47,7 @@ define(["require", "exports", "../constants/error_msgs", "../utils/clonable"], f
|
|
|
49
47
|
}
|
|
50
48
|
};
|
|
51
49
|
Lookup.prototype.get = function (serviceIdentifier) {
|
|
52
|
-
|
|
53
|
-
throw new Error(ERROR_MSGS.NULL_ARGUMENT);
|
|
54
|
-
}
|
|
50
|
+
this._checkNonNulish(serviceIdentifier);
|
|
55
51
|
var entry = this._map.get(serviceIdentifier);
|
|
56
52
|
if (entry !== undefined) {
|
|
57
53
|
return entry;
|
|
@@ -61,9 +57,7 @@ define(["require", "exports", "../constants/error_msgs", "../utils/clonable"], f
|
|
|
61
57
|
}
|
|
62
58
|
};
|
|
63
59
|
Lookup.prototype.remove = function (serviceIdentifier) {
|
|
64
|
-
|
|
65
|
-
throw new Error(ERROR_MSGS.NULL_ARGUMENT);
|
|
66
|
-
}
|
|
60
|
+
this._checkNonNulish(serviceIdentifier);
|
|
67
61
|
if (!this._map.delete(serviceIdentifier)) {
|
|
68
62
|
throw new Error(ERROR_MSGS.KEY_NOT_FOUND);
|
|
69
63
|
}
|
|
@@ -71,7 +65,9 @@ define(["require", "exports", "../constants/error_msgs", "../utils/clonable"], f
|
|
|
71
65
|
Lookup.prototype.removeIntersection = function (lookup) {
|
|
72
66
|
var _this = this;
|
|
73
67
|
this.traverse(function (serviceIdentifier, value) {
|
|
74
|
-
var lookupActivations = lookup.hasKey(serviceIdentifier)
|
|
68
|
+
var lookupActivations = lookup.hasKey(serviceIdentifier)
|
|
69
|
+
? lookup.get(serviceIdentifier)
|
|
70
|
+
: undefined;
|
|
75
71
|
if (lookupActivations !== undefined) {
|
|
76
72
|
var filteredValues = value.filter(function (lookupValue) {
|
|
77
73
|
return !lookupActivations.some(function (moduleActivation) { return lookupValue === moduleActivation; });
|
|
@@ -100,15 +96,15 @@ define(["require", "exports", "../constants/error_msgs", "../utils/clonable"], f
|
|
|
100
96
|
return removals;
|
|
101
97
|
};
|
|
102
98
|
Lookup.prototype.hasKey = function (serviceIdentifier) {
|
|
103
|
-
|
|
104
|
-
throw new Error(ERROR_MSGS.NULL_ARGUMENT);
|
|
105
|
-
}
|
|
99
|
+
this._checkNonNulish(serviceIdentifier);
|
|
106
100
|
return this._map.has(serviceIdentifier);
|
|
107
101
|
};
|
|
108
102
|
Lookup.prototype.clone = function () {
|
|
109
103
|
var copy = new Lookup();
|
|
110
104
|
this._map.forEach(function (value, key) {
|
|
111
|
-
value.forEach(function (b) {
|
|
105
|
+
value.forEach(function (b) {
|
|
106
|
+
copy.add(key, (0, clonable_1.isClonable)(b) ? b.clone() : b);
|
|
107
|
+
});
|
|
112
108
|
});
|
|
113
109
|
return copy;
|
|
114
110
|
};
|
|
@@ -117,6 +113,11 @@ define(["require", "exports", "../constants/error_msgs", "../utils/clonable"], f
|
|
|
117
113
|
func(key, value);
|
|
118
114
|
});
|
|
119
115
|
};
|
|
116
|
+
Lookup.prototype._checkNonNulish = function (value) {
|
|
117
|
+
if (value == null) {
|
|
118
|
+
throw new Error(ERROR_MSGS.NULL_ARGUMENT);
|
|
119
|
+
}
|
|
120
|
+
};
|
|
120
121
|
Lookup.prototype._setValue = function (serviceIdentifier, value) {
|
|
121
122
|
if (value.length > 0) {
|
|
122
123
|
this._map.set(serviceIdentifier, value);
|
|
@@ -7,20 +7,18 @@ define(["require", "exports", "./lookup"], function (require, exports, lookup_1)
|
|
|
7
7
|
this._map = new Map();
|
|
8
8
|
}
|
|
9
9
|
ModuleActivationStore.prototype.remove = function (moduleId) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
this.
|
|
13
|
-
return handlers;
|
|
10
|
+
var handlers = this._map.get(moduleId);
|
|
11
|
+
if (handlers === undefined) {
|
|
12
|
+
return this._getEmptyHandlersStore();
|
|
14
13
|
}
|
|
15
|
-
|
|
14
|
+
this._map.delete(moduleId);
|
|
15
|
+
return handlers;
|
|
16
16
|
};
|
|
17
17
|
ModuleActivationStore.prototype.addDeactivation = function (moduleId, serviceIdentifier, onDeactivation) {
|
|
18
|
-
this._getModuleActivationHandlers(moduleId)
|
|
19
|
-
.onDeactivations.add(serviceIdentifier, onDeactivation);
|
|
18
|
+
this._getModuleActivationHandlers(moduleId).onDeactivations.add(serviceIdentifier, onDeactivation);
|
|
20
19
|
};
|
|
21
20
|
ModuleActivationStore.prototype.addActivation = function (moduleId, serviceIdentifier, onActivation) {
|
|
22
|
-
this._getModuleActivationHandlers(moduleId)
|
|
23
|
-
.onActivations.add(serviceIdentifier, onActivation);
|
|
21
|
+
this._getModuleActivationHandlers(moduleId).onActivations.add(serviceIdentifier, onActivation);
|
|
24
22
|
};
|
|
25
23
|
ModuleActivationStore.prototype.clone = function () {
|
|
26
24
|
var clone = new ModuleActivationStore();
|
|
@@ -43,7 +41,7 @@ define(["require", "exports", "./lookup"], function (require, exports, lookup_1)
|
|
|
43
41
|
ModuleActivationStore.prototype._getEmptyHandlersStore = function () {
|
|
44
42
|
var handlersStore = {
|
|
45
43
|
onActivations: new lookup_1.Lookup(),
|
|
46
|
-
onDeactivations: new lookup_1.Lookup()
|
|
44
|
+
onDeactivations: new lookup_1.Lookup(),
|
|
47
45
|
};
|
|
48
46
|
return handlersStore;
|
|
49
47
|
};
|
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
define(["require", "exports"], function (require, exports) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.interfaces = void 0;
|
|
5
|
-
var interfaces;
|
|
6
|
-
(function (interfaces) {
|
|
7
|
-
;
|
|
8
|
-
})(interfaces || (exports.interfaces = interfaces = {}));
|
|
9
4
|
});
|