@expressots/core 2.16.1 → 3.0.0-beta.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/README.md +2 -2
- package/lib/CHANGELOG.md +312 -310
- package/lib/README.md +2 -2
- package/lib/cjs/application/application-container.js +18 -21
- package/lib/cjs/application/application-factory.js +4 -5
- package/lib/cjs/{common/server-env.types.js → application/application.types.js} +1 -0
- package/lib/cjs/application/index.js +3 -1
- package/lib/cjs/console/console.js +8 -20
- package/lib/cjs/container-module/container-module.js +10 -18
- package/lib/cjs/decorator/scope-binding.js +12 -11
- package/lib/cjs/di/annotation/decorator_utils.js +121 -0
- package/lib/cjs/di/annotation/inject.js +44 -0
- package/lib/cjs/di/annotation/inject_base.js +17 -0
- package/lib/cjs/di/annotation/injectable.js +43 -0
- package/lib/cjs/di/annotation/lazy_service_identifier.js +12 -0
- package/lib/cjs/di/annotation/multi_inject.js +30 -0
- package/lib/cjs/di/annotation/named.js +34 -0
- package/lib/cjs/di/annotation/optional.js +32 -0
- package/lib/cjs/di/annotation/post_construct.js +31 -0
- package/lib/cjs/di/annotation/pre_destroy.js +31 -0
- package/lib/cjs/di/annotation/property_event_decorator.js +15 -0
- package/lib/cjs/di/annotation/tagged.js +9 -0
- package/lib/cjs/di/annotation/target_name.js +35 -0
- package/lib/cjs/di/annotation/unmanaged.js +35 -0
- package/lib/cjs/di/binding-decorator/constants.js +7 -0
- package/lib/cjs/di/binding-decorator/decorator/fluent_provide.js +20 -0
- package/lib/cjs/di/binding-decorator/decorator/provide.js +37 -0
- package/lib/cjs/di/binding-decorator/factory/module_factory.js +17 -0
- package/lib/cjs/di/binding-decorator/index.js +14 -0
- package/lib/cjs/di/binding-decorator/syntax/provide_done_syntax.js +42 -0
- package/lib/cjs/di/binding-decorator/syntax/provide_in_syntax.js +33 -0
- package/lib/cjs/di/binding-decorator/syntax/provide_in_when_on_syntax.js +64 -0
- package/lib/cjs/di/binding-decorator/syntax/provide_on_syntax.js +22 -0
- package/lib/cjs/di/binding-decorator/syntax/provide_when_on_syntax.js +57 -0
- package/lib/cjs/di/binding-decorator/syntax/provide_when_syntax.js +89 -0
- package/lib/cjs/di/binding-decorator/utils/auto_wire.js +18 -0
- package/lib/cjs/di/bindings/binding.js +40 -0
- package/lib/cjs/di/bindings/binding_count.js +8 -0
- package/lib/cjs/di/constants/error_msgs.js +60 -0
- package/lib/cjs/di/constants/literal_types.js +26 -0
- package/lib/cjs/di/constants/metadata_keys.js +38 -0
- package/lib/cjs/di/container/container.js +521 -0
- package/lib/cjs/di/container/container_module.js +18 -0
- package/lib/cjs/di/container/container_snapshot.js +15 -0
- package/lib/cjs/di/container/lookup.js +132 -0
- package/lib/cjs/di/container/module_activation_store.js +49 -0
- package/lib/cjs/di/interfaces/interfaces.js +2 -0
- package/lib/cjs/di/inversify.js +78 -0
- package/lib/cjs/di/planning/context.js +17 -0
- package/lib/cjs/di/planning/metadata.js +42 -0
- package/lib/cjs/di/planning/metadata_reader.js +45 -0
- package/lib/cjs/di/planning/plan.js +10 -0
- package/lib/cjs/di/planning/planner.js +186 -0
- package/lib/cjs/di/planning/queryable_string.js +27 -0
- package/lib/cjs/di/planning/reflection_utils.js +178 -0
- package/lib/cjs/di/planning/request.js +23 -0
- package/lib/cjs/di/planning/target.js +108 -0
- package/lib/cjs/di/resolution/instantiation.js +150 -0
- package/lib/cjs/di/resolution/resolver.js +188 -0
- package/lib/cjs/di/scope/scope.js +50 -0
- package/lib/cjs/di/syntax/binding_in_syntax.js +23 -0
- package/lib/cjs/di/syntax/binding_in_when_on_syntax.js +75 -0
- package/lib/cjs/di/syntax/binding_on_syntax.js +18 -0
- package/lib/cjs/di/syntax/binding_to_syntax.js +111 -0
- package/lib/cjs/di/syntax/binding_when_on_syntax.js +64 -0
- package/lib/cjs/di/syntax/binding_when_syntax.js +84 -0
- package/lib/cjs/di/syntax/constraint_helpers.js +68 -0
- package/lib/cjs/di/utils/async.js +15 -0
- package/lib/cjs/di/utils/binding_utils.js +77 -0
- package/lib/cjs/di/utils/clonable.js +9 -0
- package/lib/cjs/di/utils/exceptions.js +46 -0
- package/lib/cjs/di/utils/factory_type.js +9 -0
- package/lib/cjs/di/utils/id.js +7 -0
- package/lib/cjs/di/utils/js.js +15 -0
- package/lib/cjs/di/utils/serialization.js +132 -0
- package/lib/cjs/error/app-error.js +5 -2
- package/lib/cjs/error/error-handler-middleware.js +3 -6
- package/lib/cjs/error/report.js +24 -15
- package/lib/cjs/index.js +1 -2
- package/lib/cjs/middleware/middleware-interface.js +2 -0
- package/lib/cjs/middleware/middleware-service.js +10 -25
- package/lib/cjs/provider/db-in-memory/base-repo.repository.js +3 -8
- package/lib/cjs/provider/db-in-memory/db-in-memory.provider.js +8 -5
- package/lib/cjs/provider/dto-validator/dto-validator.provider.js +4 -4
- package/lib/cjs/provider/dto-validator/package-resolver.js +56 -0
- package/lib/cjs/provider/environment/env-validator.provider.js +14 -12
- package/lib/cjs/provider/logger/logger.provider.js +10 -5
- package/lib/cjs/provider/provider-manager.js +21 -17
- package/lib/cjs/types/application/application-container.d.ts +12 -25
- package/lib/cjs/types/application/application-factory.d.ts +10 -7
- package/lib/cjs/types/{common/server-env.types.d.ts → application/application.types.d.ts} +1 -0
- package/lib/cjs/types/application/index.d.ts +1 -0
- package/lib/cjs/types/console/console.d.ts +3 -10
- package/lib/cjs/types/console/index.d.ts +2 -1
- package/lib/cjs/types/container-module/container-module.d.ts +3 -1
- package/lib/cjs/types/decorator/scope-binding.d.ts +9 -9
- package/lib/cjs/types/di/annotation/decorator_utils.d.ts +16 -0
- package/lib/cjs/types/di/annotation/inject.d.ts +16 -0
- package/lib/cjs/types/di/annotation/inject_base.d.ts +3 -0
- package/lib/cjs/types/di/annotation/injectable.d.ts +7 -0
- package/lib/cjs/types/di/annotation/lazy_service_identifier.d.ts +7 -0
- package/lib/cjs/types/di/annotation/multi_inject.d.ts +2 -0
- package/lib/cjs/types/di/annotation/named.d.ts +2 -0
- package/lib/cjs/types/di/annotation/optional.d.ts +2 -0
- package/lib/cjs/types/di/annotation/post_construct.d.ts +4 -0
- package/lib/cjs/types/di/annotation/pre_destroy.d.ts +4 -0
- package/lib/cjs/types/di/annotation/property_event_decorator.d.ts +4 -0
- package/lib/cjs/types/di/annotation/tagged.d.ts +2 -0
- package/lib/cjs/types/di/annotation/target_name.d.ts +3 -0
- package/lib/cjs/types/di/annotation/unmanaged.d.ts +3 -0
- package/lib/cjs/types/di/binding-decorator/constants.d.ts +4 -0
- package/lib/cjs/types/di/binding-decorator/decorator/fluent_provide.d.ts +4 -0
- package/lib/cjs/types/di/binding-decorator/decorator/provide.d.ts +4 -0
- package/lib/cjs/types/di/binding-decorator/factory/module_factory.d.ts +4 -0
- package/lib/cjs/types/di/binding-decorator/index.d.ts +8 -0
- package/lib/cjs/types/di/binding-decorator/interfaces/interfaces.d.ts +39 -0
- package/lib/cjs/types/di/binding-decorator/syntax/provide_done_syntax.d.ts +7 -0
- package/lib/cjs/types/di/binding-decorator/syntax/provide_in_syntax.d.ts +11 -0
- package/lib/cjs/types/di/binding-decorator/syntax/provide_in_when_on_syntax.d.ts +27 -0
- package/lib/cjs/types/di/binding-decorator/syntax/provide_on_syntax.d.ts +10 -0
- package/lib/cjs/types/di/binding-decorator/syntax/provide_when_on_syntax.d.ts +24 -0
- package/lib/cjs/types/di/binding-decorator/syntax/provide_when_syntax.d.ts +23 -0
- package/lib/cjs/types/di/binding-decorator/utils/auto_wire.d.ts +3 -0
- package/lib/cjs/types/di/bindings/binding.d.ts +20 -0
- package/lib/cjs/types/di/bindings/binding_count.d.ts +5 -0
- package/lib/cjs/types/di/constants/error_msgs.d.ts +32 -0
- package/lib/cjs/types/di/constants/literal_types.d.ts +5 -0
- package/lib/cjs/types/di/constants/metadata_keys.d.ts +13 -0
- package/lib/cjs/types/di/container/container.d.ts +73 -0
- package/lib/cjs/types/di/container/container_module.d.ts +11 -0
- package/lib/cjs/types/di/container/container_snapshot.d.ts +10 -0
- package/lib/cjs/types/di/container/lookup.d.ts +16 -0
- package/lib/cjs/types/di/container/module_activation_store.d.ts +10 -0
- package/lib/cjs/types/di/interfaces/interfaces.d.ts +299 -0
- package/lib/cjs/types/di/inversify.d.ts +25 -0
- package/lib/cjs/types/di/planning/context.d.ts +11 -0
- package/lib/cjs/types/di/planning/metadata.d.ts +8 -0
- package/lib/cjs/types/di/planning/metadata_reader.d.ts +6 -0
- package/lib/cjs/types/di/planning/plan.d.ts +7 -0
- package/lib/cjs/types/di/planning/planner.d.ts +5 -0
- package/lib/cjs/types/di/planning/queryable_string.d.ts +11 -0
- package/lib/cjs/types/di/planning/reflection_utils.d.ts +5 -0
- package/lib/cjs/types/di/planning/request.d.ts +14 -0
- package/lib/cjs/types/di/planning/target.d.ts +23 -0
- package/lib/cjs/types/di/resolution/instantiation.d.ts +3 -0
- package/lib/cjs/types/di/resolution/resolver.d.ts +3 -0
- package/lib/cjs/types/di/scope/scope.d.ts +3 -0
- package/lib/cjs/types/di/syntax/binding_in_syntax.d.ts +9 -0
- package/lib/cjs/types/di/syntax/binding_in_when_on_syntax.d.ts +29 -0
- package/lib/cjs/types/di/syntax/binding_on_syntax.d.ts +8 -0
- package/lib/cjs/types/di/syntax/binding_to_syntax.d.ts +18 -0
- package/lib/cjs/types/di/syntax/binding_when_on_syntax.d.ts +25 -0
- package/lib/cjs/types/di/syntax/binding_when_syntax.d.ts +21 -0
- package/lib/cjs/types/di/syntax/constraint_helpers.d.ts +6 -0
- package/lib/cjs/types/di/utils/async.d.ts +3 -0
- package/lib/cjs/types/di/utils/binding_utils.d.ts +4 -0
- package/lib/cjs/types/di/utils/clonable.d.ts +3 -0
- package/lib/cjs/types/di/utils/exceptions.d.ts +2 -0
- package/lib/cjs/types/di/utils/factory_type.d.ts +5 -0
- package/lib/cjs/types/di/utils/id.d.ts +2 -0
- package/lib/cjs/types/di/utils/js.d.ts +1 -0
- package/lib/cjs/types/di/utils/serialization.d.ts +10 -0
- package/lib/cjs/types/error/error-handler-middleware.d.ts +2 -3
- package/lib/cjs/types/error/report.d.ts +7 -5
- package/lib/cjs/types/index.d.ts +1 -2
- package/lib/cjs/types/middleware/index.d.ts +2 -1
- package/lib/cjs/types/middleware/middleware-interface.d.ts +185 -0
- package/lib/cjs/types/middleware/middleware-service.d.ts +11 -163
- package/lib/cjs/types/provider/db-in-memory/db-in-memory.provider.d.ts +4 -0
- package/lib/cjs/types/provider/dto-validator/dto-validator.provider.d.ts +2 -3
- package/lib/cjs/types/{common → provider/dto-validator}/package-resolver.d.ts +1 -2
- package/lib/cjs/types/provider/environment/env-validator.provider.d.ts +7 -3
- package/lib/cjs/types/provider/logger/logger.provider.d.ts +5 -0
- package/lib/cjs/types/provider/provider-manager.d.ts +22 -2
- package/lib/package.json +9 -15
- package/package.json +9 -15
- package/lib/cjs/common/index.js +0 -5
- package/lib/cjs/common/package-resolver.js +0 -34
- package/lib/cjs/controller/base-controller.js +0 -74
- package/lib/cjs/controller/index.js +0 -5
- package/lib/cjs/types/common/index.d.ts +0 -2
- package/lib/cjs/types/common/project-config.d.ts +0 -56
- package/lib/cjs/types/controller/base-controller.d.ts +0 -48
- package/lib/cjs/types/controller/index.d.ts +0 -1
- /package/lib/cjs/{common → console}/color-codes.js +0 -0
- /package/lib/cjs/{common/project-config.js → di/binding-decorator/interfaces/interfaces.js} +0 -0
- /package/lib/cjs/types/{common → console}/color-codes.d.ts +0 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Request = void 0;
|
|
4
|
+
const id_1 = require("../utils/id");
|
|
5
|
+
class Request {
|
|
6
|
+
constructor(serviceIdentifier, parentContext, parentRequest, bindings, target) {
|
|
7
|
+
this.id = (0, id_1.id)();
|
|
8
|
+
this.serviceIdentifier = serviceIdentifier;
|
|
9
|
+
this.parentContext = parentContext;
|
|
10
|
+
this.parentRequest = parentRequest;
|
|
11
|
+
this.target = target;
|
|
12
|
+
this.childRequests = [];
|
|
13
|
+
this.bindings = Array.isArray(bindings) ? bindings : [bindings];
|
|
14
|
+
// Set requestScope if Request is the root request
|
|
15
|
+
this.requestScope = parentRequest === null ? new Map() : null;
|
|
16
|
+
}
|
|
17
|
+
addChildRequest(serviceIdentifier, bindings, target) {
|
|
18
|
+
const child = new Request(serviceIdentifier, this.parentContext, this, bindings, target);
|
|
19
|
+
this.childRequests.push(child);
|
|
20
|
+
return child;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.Request = Request;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.Target = void 0;
|
|
27
|
+
const METADATA_KEY = __importStar(require("../constants/metadata_keys"));
|
|
28
|
+
const id_1 = require("../utils/id");
|
|
29
|
+
const serialization_1 = require("../utils/serialization");
|
|
30
|
+
const metadata_1 = require("./metadata");
|
|
31
|
+
const queryable_string_1 = require("./queryable_string");
|
|
32
|
+
class Target {
|
|
33
|
+
constructor(type, identifier, serviceIdentifier, namedOrTagged) {
|
|
34
|
+
this.id = (0, id_1.id)();
|
|
35
|
+
this.type = type;
|
|
36
|
+
this.serviceIdentifier = serviceIdentifier;
|
|
37
|
+
const queryableName = typeof identifier === "symbol"
|
|
38
|
+
? (0, serialization_1.getSymbolDescription)(identifier)
|
|
39
|
+
: identifier;
|
|
40
|
+
this.name = new queryable_string_1.QueryableString(queryableName || "");
|
|
41
|
+
this.identifier = identifier;
|
|
42
|
+
this.metadata = new Array();
|
|
43
|
+
let metadataItem = null;
|
|
44
|
+
// is named target
|
|
45
|
+
if (typeof namedOrTagged === "string") {
|
|
46
|
+
metadataItem = new metadata_1.Metadata(METADATA_KEY.NAMED_TAG, namedOrTagged);
|
|
47
|
+
}
|
|
48
|
+
else if (namedOrTagged instanceof metadata_1.Metadata) {
|
|
49
|
+
// is target with metadata
|
|
50
|
+
metadataItem = namedOrTagged;
|
|
51
|
+
}
|
|
52
|
+
// target has metadata
|
|
53
|
+
if (metadataItem !== null) {
|
|
54
|
+
this.metadata.push(metadataItem);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
hasTag(key) {
|
|
58
|
+
for (const m of this.metadata) {
|
|
59
|
+
if (m.key === key) {
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
isArray() {
|
|
66
|
+
return this.hasTag(METADATA_KEY.MULTI_INJECT_TAG);
|
|
67
|
+
}
|
|
68
|
+
matchesArray(name) {
|
|
69
|
+
return this.matchesTag(METADATA_KEY.MULTI_INJECT_TAG)(name);
|
|
70
|
+
}
|
|
71
|
+
isNamed() {
|
|
72
|
+
return this.hasTag(METADATA_KEY.NAMED_TAG);
|
|
73
|
+
}
|
|
74
|
+
isTagged() {
|
|
75
|
+
return this.metadata.some((metadata) => METADATA_KEY.NON_CUSTOM_TAG_KEYS.every((key) => metadata.key !== key));
|
|
76
|
+
}
|
|
77
|
+
isOptional() {
|
|
78
|
+
return this.matchesTag(METADATA_KEY.OPTIONAL_TAG)(true);
|
|
79
|
+
}
|
|
80
|
+
getNamedTag() {
|
|
81
|
+
if (this.isNamed()) {
|
|
82
|
+
return this.metadata.filter((m) => m.key === METADATA_KEY.NAMED_TAG)[0];
|
|
83
|
+
}
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
getCustomTags() {
|
|
87
|
+
if (this.isTagged()) {
|
|
88
|
+
return this.metadata.filter((metadata) => METADATA_KEY.NON_CUSTOM_TAG_KEYS.every((key) => metadata.key !== key));
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
matchesNamedTag(name) {
|
|
95
|
+
return this.matchesTag(METADATA_KEY.NAMED_TAG)(name);
|
|
96
|
+
}
|
|
97
|
+
matchesTag(key) {
|
|
98
|
+
return (value) => {
|
|
99
|
+
for (const m of this.metadata) {
|
|
100
|
+
if (m.key === key && m.value === value) {
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return false;
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
exports.Target = Target;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.resolveInstance = resolveInstance;
|
|
27
|
+
const error_msgs_1 = require("../constants/error_msgs");
|
|
28
|
+
const literal_types_1 = require("../constants/literal_types");
|
|
29
|
+
const METADATA_KEY = __importStar(require("../constants/metadata_keys"));
|
|
30
|
+
const async_1 = require("../utils/async");
|
|
31
|
+
function _resolveRequests(childRequests, resolveRequest) {
|
|
32
|
+
return childRequests.reduce((resolvedRequests, childRequest) => {
|
|
33
|
+
const injection = resolveRequest(childRequest);
|
|
34
|
+
const targetType = childRequest.target.type;
|
|
35
|
+
if (targetType === literal_types_1.TargetTypeEnum.ConstructorArgument) {
|
|
36
|
+
resolvedRequests.constructorInjections.push(injection);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
resolvedRequests.propertyRequests.push(childRequest);
|
|
40
|
+
resolvedRequests.propertyInjections.push(injection);
|
|
41
|
+
}
|
|
42
|
+
if (!resolvedRequests.isAsync) {
|
|
43
|
+
resolvedRequests.isAsync = (0, async_1.isPromiseOrContainsPromise)(injection);
|
|
44
|
+
}
|
|
45
|
+
return resolvedRequests;
|
|
46
|
+
}, {
|
|
47
|
+
constructorInjections: [],
|
|
48
|
+
propertyInjections: [],
|
|
49
|
+
propertyRequests: [],
|
|
50
|
+
isAsync: false,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
function _createInstance(constr, childRequests, resolveRequest) {
|
|
54
|
+
let result;
|
|
55
|
+
if (childRequests.length > 0) {
|
|
56
|
+
const resolved = _resolveRequests(childRequests, resolveRequest);
|
|
57
|
+
const createInstanceWithInjectionsArg = {
|
|
58
|
+
...resolved,
|
|
59
|
+
constr,
|
|
60
|
+
};
|
|
61
|
+
if (resolved.isAsync) {
|
|
62
|
+
result = createInstanceWithInjectionsAsync(createInstanceWithInjectionsArg);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
result = createInstanceWithInjections(createInstanceWithInjectionsArg);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
result = new constr();
|
|
70
|
+
}
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
73
|
+
function createInstanceWithInjections(args) {
|
|
74
|
+
const instance = new args.constr(...args.constructorInjections);
|
|
75
|
+
args.propertyRequests.forEach((r, index) => {
|
|
76
|
+
const property = r.target.identifier;
|
|
77
|
+
const injection = args.propertyInjections[index];
|
|
78
|
+
if (!r.target.isOptional() || injection !== undefined) {
|
|
79
|
+
instance[property] = injection;
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
return instance;
|
|
83
|
+
}
|
|
84
|
+
async function createInstanceWithInjectionsAsync(args) {
|
|
85
|
+
const constructorInjections = await possiblyWaitInjections(args.constructorInjections);
|
|
86
|
+
const propertyInjections = await possiblyWaitInjections(args.propertyInjections);
|
|
87
|
+
return createInstanceWithInjections({
|
|
88
|
+
...args,
|
|
89
|
+
constructorInjections,
|
|
90
|
+
propertyInjections,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
async function possiblyWaitInjections(possiblePromiseinjections) {
|
|
94
|
+
const injections = [];
|
|
95
|
+
for (const injection of possiblePromiseinjections) {
|
|
96
|
+
if (Array.isArray(injection)) {
|
|
97
|
+
injections.push(Promise.all(injection));
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
injections.push(injection);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return Promise.all(injections);
|
|
104
|
+
}
|
|
105
|
+
function _getInstanceAfterPostConstruct(constr, result) {
|
|
106
|
+
const postConstructResult = _postConstruct(constr, result);
|
|
107
|
+
if ((0, async_1.isPromise)(postConstructResult)) {
|
|
108
|
+
return postConstructResult.then(() => result);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
return result;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function _postConstruct(constr, instance) {
|
|
115
|
+
if (Reflect.hasMetadata(METADATA_KEY.POST_CONSTRUCT, constr)) {
|
|
116
|
+
const data = Reflect.getMetadata(METADATA_KEY.POST_CONSTRUCT, constr);
|
|
117
|
+
try {
|
|
118
|
+
return instance[data.value]?.();
|
|
119
|
+
}
|
|
120
|
+
catch (e) {
|
|
121
|
+
if (e instanceof Error) {
|
|
122
|
+
throw new Error((0, error_msgs_1.POST_CONSTRUCT_ERROR)(constr.name, e.message));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function _validateInstanceResolution(binding, constr) {
|
|
128
|
+
if (binding.scope !== literal_types_1.BindingScopeEnum.Singleton) {
|
|
129
|
+
_throwIfHandlingDeactivation(binding, constr);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
function _throwIfHandlingDeactivation(binding, constr) {
|
|
133
|
+
const scopeErrorMessage = `Class cannot be instantiated in ${binding.scope === literal_types_1.BindingScopeEnum.Request ? "request" : "transient"} scope.`;
|
|
134
|
+
if (typeof binding.onDeactivation === "function") {
|
|
135
|
+
throw new Error((0, error_msgs_1.ON_DEACTIVATION_ERROR)(constr.name, scopeErrorMessage));
|
|
136
|
+
}
|
|
137
|
+
if (Reflect.hasMetadata(METADATA_KEY.PRE_DESTROY, constr)) {
|
|
138
|
+
throw new Error((0, error_msgs_1.PRE_DESTROY_ERROR)(constr.name, scopeErrorMessage));
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
function resolveInstance(binding, constr, childRequests, resolveRequest) {
|
|
142
|
+
_validateInstanceResolution(binding, constr);
|
|
143
|
+
const result = _createInstance(constr, childRequests, resolveRequest);
|
|
144
|
+
if ((0, async_1.isPromise)(result)) {
|
|
145
|
+
return result.then((resolvedResult) => _getInstanceAfterPostConstruct(constr, resolvedResult));
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
return _getInstanceAfterPostConstruct(constr, result);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.resolve = resolve;
|
|
27
|
+
const ERROR_MSGS = __importStar(require("../constants/error_msgs"));
|
|
28
|
+
const literal_types_1 = require("../constants/literal_types");
|
|
29
|
+
const planner_1 = require("../planning/planner");
|
|
30
|
+
const scope_1 = require("../scope/scope");
|
|
31
|
+
const async_1 = require("../utils/async");
|
|
32
|
+
const binding_utils_1 = require("../utils/binding_utils");
|
|
33
|
+
const exceptions_1 = require("../utils/exceptions");
|
|
34
|
+
const instantiation_1 = require("./instantiation");
|
|
35
|
+
const _resolveRequest = (requestScope) => (request) => {
|
|
36
|
+
request.parentContext.setCurrentRequest(request);
|
|
37
|
+
const bindings = request.bindings;
|
|
38
|
+
const childRequests = request.childRequests;
|
|
39
|
+
const targetIsAnArray = request.target && request.target.isArray();
|
|
40
|
+
const targetParentIsNotAnArray = !request.parentRequest ||
|
|
41
|
+
!request.parentRequest.target ||
|
|
42
|
+
!request.target ||
|
|
43
|
+
!request.parentRequest.target.matchesArray(request.target.serviceIdentifier);
|
|
44
|
+
if (targetIsAnArray && targetParentIsNotAnArray) {
|
|
45
|
+
// Create an array instead of creating an instance
|
|
46
|
+
return childRequests.map((childRequest) => {
|
|
47
|
+
const _f = _resolveRequest(requestScope);
|
|
48
|
+
return _f(childRequest);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
if (request.target.isOptional() && bindings.length === 0) {
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
const binding = bindings[0];
|
|
56
|
+
return _resolveBinding(requestScope, request, binding);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const _resolveFactoryFromBinding = (binding, context) => {
|
|
60
|
+
const factoryDetails = (0, binding_utils_1.getFactoryDetails)(binding);
|
|
61
|
+
return (0, exceptions_1.tryAndThrowErrorIfStackOverflow)(() => factoryDetails.factory.bind(binding)(context), () => new Error(ERROR_MSGS.CIRCULAR_DEPENDENCY_IN_FACTORY(factoryDetails.factoryType, context.currentRequest.serviceIdentifier.toString())));
|
|
62
|
+
};
|
|
63
|
+
const _getResolvedFromBinding = (requestScope, request, binding) => {
|
|
64
|
+
let result;
|
|
65
|
+
const childRequests = request.childRequests;
|
|
66
|
+
(0, binding_utils_1.ensureFullyBound)(binding);
|
|
67
|
+
switch (binding.type) {
|
|
68
|
+
case literal_types_1.BindingTypeEnum.ConstantValue:
|
|
69
|
+
case literal_types_1.BindingTypeEnum.Function:
|
|
70
|
+
result = binding.cache;
|
|
71
|
+
break;
|
|
72
|
+
case literal_types_1.BindingTypeEnum.Constructor:
|
|
73
|
+
result = binding.implementationType;
|
|
74
|
+
break;
|
|
75
|
+
case literal_types_1.BindingTypeEnum.Instance:
|
|
76
|
+
result = (0, instantiation_1.resolveInstance)(binding, binding.implementationType, childRequests, _resolveRequest(requestScope));
|
|
77
|
+
break;
|
|
78
|
+
default:
|
|
79
|
+
result = _resolveFactoryFromBinding(binding, request.parentContext);
|
|
80
|
+
}
|
|
81
|
+
return result;
|
|
82
|
+
};
|
|
83
|
+
const _resolveInScope = (requestScope, binding, resolveFromBinding) => {
|
|
84
|
+
let result = (0, scope_1.tryGetFromScope)(requestScope, binding);
|
|
85
|
+
if (result !== null) {
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
result = resolveFromBinding();
|
|
89
|
+
(0, scope_1.saveToScope)(requestScope, binding, result);
|
|
90
|
+
return result;
|
|
91
|
+
};
|
|
92
|
+
const _resolveBinding = (requestScope, request, binding) => {
|
|
93
|
+
return _resolveInScope(requestScope, binding, () => {
|
|
94
|
+
let result = _getResolvedFromBinding(requestScope, request, binding);
|
|
95
|
+
if ((0, async_1.isPromise)(result)) {
|
|
96
|
+
result = result.then((resolved) => _onActivation(request, binding, resolved));
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
result = _onActivation(request, binding, result);
|
|
100
|
+
}
|
|
101
|
+
return result;
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
function _onActivation(request, binding, resolved) {
|
|
105
|
+
let result = _bindingActivation(request.parentContext, binding, resolved);
|
|
106
|
+
const containersIterator = _getContainersIterator(request.parentContext.container);
|
|
107
|
+
let container;
|
|
108
|
+
let containersIteratorResult = containersIterator.next();
|
|
109
|
+
do {
|
|
110
|
+
container = containersIteratorResult.value;
|
|
111
|
+
const context = request.parentContext;
|
|
112
|
+
const serviceIdentifier = request.serviceIdentifier;
|
|
113
|
+
const activationsIterator = _getContainerActivationsForService(container, serviceIdentifier);
|
|
114
|
+
if ((0, async_1.isPromise)(result)) {
|
|
115
|
+
result = _activateContainerAsync(activationsIterator, context, result);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
result = _activateContainer(activationsIterator, context, result);
|
|
119
|
+
}
|
|
120
|
+
containersIteratorResult = containersIterator.next();
|
|
121
|
+
// make sure if we are currently on the container that owns the binding, not to keep looping down to child containers
|
|
122
|
+
} while (containersIteratorResult.done !== true &&
|
|
123
|
+
!(0, planner_1.getBindingDictionary)(container).hasKey(request.serviceIdentifier));
|
|
124
|
+
return result;
|
|
125
|
+
}
|
|
126
|
+
const _bindingActivation = (context, binding, previousResult) => {
|
|
127
|
+
let result;
|
|
128
|
+
// use activation handler if available
|
|
129
|
+
if (typeof binding.onActivation === "function") {
|
|
130
|
+
result = binding.onActivation(context, previousResult);
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
result = previousResult;
|
|
134
|
+
}
|
|
135
|
+
return result;
|
|
136
|
+
};
|
|
137
|
+
const _activateContainer = (activationsIterator, context, result) => {
|
|
138
|
+
let activation = activationsIterator.next();
|
|
139
|
+
while (!activation.done) {
|
|
140
|
+
result = activation.value(context, result);
|
|
141
|
+
if ((0, async_1.isPromise)(result)) {
|
|
142
|
+
return _activateContainerAsync(activationsIterator, context, result);
|
|
143
|
+
}
|
|
144
|
+
activation = activationsIterator.next();
|
|
145
|
+
}
|
|
146
|
+
return result;
|
|
147
|
+
};
|
|
148
|
+
const _activateContainerAsync = async (activationsIterator, context, resultPromise) => {
|
|
149
|
+
let result = await resultPromise;
|
|
150
|
+
let activation = activationsIterator.next();
|
|
151
|
+
while (!activation.done) {
|
|
152
|
+
result = await activation.value(context, result);
|
|
153
|
+
activation = activationsIterator.next();
|
|
154
|
+
}
|
|
155
|
+
return result;
|
|
156
|
+
};
|
|
157
|
+
const _getContainerActivationsForService = (container, serviceIdentifier) => {
|
|
158
|
+
// smell accessing _activations, but similar pattern is done in planner.getBindingDictionary()
|
|
159
|
+
const activations = container._activations;
|
|
160
|
+
return activations.hasKey(serviceIdentifier)
|
|
161
|
+
? activations.get(serviceIdentifier).values()
|
|
162
|
+
: [].values();
|
|
163
|
+
};
|
|
164
|
+
const _getContainersIterator = (container) => {
|
|
165
|
+
const containersStack = [container];
|
|
166
|
+
let parent = container.parent;
|
|
167
|
+
while (parent !== null) {
|
|
168
|
+
containersStack.push(parent);
|
|
169
|
+
parent = parent.parent;
|
|
170
|
+
}
|
|
171
|
+
const getNextContainer = () => {
|
|
172
|
+
const nextContainer = containersStack.pop();
|
|
173
|
+
if (nextContainer !== undefined) {
|
|
174
|
+
return { done: false, value: nextContainer };
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
return { done: true, value: undefined };
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
const containersIterator = {
|
|
181
|
+
next: getNextContainer,
|
|
182
|
+
};
|
|
183
|
+
return containersIterator;
|
|
184
|
+
};
|
|
185
|
+
function resolve(context) {
|
|
186
|
+
const _f = _resolveRequest(context.plan.rootRequest.requestScope);
|
|
187
|
+
return _f(context.plan.rootRequest);
|
|
188
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.saveToScope = exports.tryGetFromScope = void 0;
|
|
4
|
+
const literal_types_1 = require("../constants/literal_types");
|
|
5
|
+
const async_1 = require("../utils/async");
|
|
6
|
+
const tryGetFromScope = (requestScope, binding) => {
|
|
7
|
+
if (binding.scope === literal_types_1.BindingScopeEnum.Singleton && binding.activated) {
|
|
8
|
+
return binding.cache;
|
|
9
|
+
}
|
|
10
|
+
if (binding.scope === literal_types_1.BindingScopeEnum.Request &&
|
|
11
|
+
requestScope.has(binding.id)) {
|
|
12
|
+
return requestScope.get(binding.id);
|
|
13
|
+
}
|
|
14
|
+
return null;
|
|
15
|
+
};
|
|
16
|
+
exports.tryGetFromScope = tryGetFromScope;
|
|
17
|
+
const saveToScope = (requestScope, binding, result) => {
|
|
18
|
+
if (binding.scope === literal_types_1.BindingScopeEnum.Singleton) {
|
|
19
|
+
_saveToSingletonScope(binding, result);
|
|
20
|
+
}
|
|
21
|
+
if (binding.scope === literal_types_1.BindingScopeEnum.Request) {
|
|
22
|
+
_saveToRequestScope(requestScope, binding, result);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
exports.saveToScope = saveToScope;
|
|
26
|
+
const _saveToRequestScope = (requestScope, binding, result) => {
|
|
27
|
+
if (!requestScope.has(binding.id)) {
|
|
28
|
+
requestScope.set(binding.id, result);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const _saveToSingletonScope = (binding, result) => {
|
|
32
|
+
// store in cache if scope is singleton
|
|
33
|
+
binding.cache = result;
|
|
34
|
+
binding.activated = true;
|
|
35
|
+
if ((0, async_1.isPromise)(result)) {
|
|
36
|
+
void _saveAsyncResultToSingletonScope(binding, result);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const _saveAsyncResultToSingletonScope = async (binding, asyncResult) => {
|
|
40
|
+
try {
|
|
41
|
+
const result = await asyncResult;
|
|
42
|
+
binding.cache = result;
|
|
43
|
+
}
|
|
44
|
+
catch (ex) {
|
|
45
|
+
// allow binding to retry in future
|
|
46
|
+
binding.cache = null;
|
|
47
|
+
binding.activated = false;
|
|
48
|
+
throw ex;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BindingInSyntax = void 0;
|
|
4
|
+
const literal_types_1 = require("../constants/literal_types");
|
|
5
|
+
const binding_when_on_syntax_1 = require("./binding_when_on_syntax");
|
|
6
|
+
class BindingInSyntax {
|
|
7
|
+
constructor(binding) {
|
|
8
|
+
this._binding = binding;
|
|
9
|
+
}
|
|
10
|
+
inRequestScope() {
|
|
11
|
+
this._binding.scope = literal_types_1.BindingScopeEnum.Request;
|
|
12
|
+
return new binding_when_on_syntax_1.BindingWhenOnSyntax(this._binding);
|
|
13
|
+
}
|
|
14
|
+
inSingletonScope() {
|
|
15
|
+
this._binding.scope = literal_types_1.BindingScopeEnum.Singleton;
|
|
16
|
+
return new binding_when_on_syntax_1.BindingWhenOnSyntax(this._binding);
|
|
17
|
+
}
|
|
18
|
+
inTransientScope() {
|
|
19
|
+
this._binding.scope = literal_types_1.BindingScopeEnum.Transient;
|
|
20
|
+
return new binding_when_on_syntax_1.BindingWhenOnSyntax(this._binding);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.BindingInSyntax = BindingInSyntax;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BindingInWhenOnSyntax = void 0;
|
|
4
|
+
const binding_in_syntax_1 = require("./binding_in_syntax");
|
|
5
|
+
const binding_on_syntax_1 = require("./binding_on_syntax");
|
|
6
|
+
const binding_when_syntax_1 = require("./binding_when_syntax");
|
|
7
|
+
class BindingInWhenOnSyntax {
|
|
8
|
+
constructor(binding) {
|
|
9
|
+
this._binding = binding;
|
|
10
|
+
this._bindingWhenSyntax = new binding_when_syntax_1.BindingWhenSyntax(this._binding);
|
|
11
|
+
this._bindingOnSyntax = new binding_on_syntax_1.BindingOnSyntax(this._binding);
|
|
12
|
+
this._bindingInSyntax = new binding_in_syntax_1.BindingInSyntax(binding);
|
|
13
|
+
}
|
|
14
|
+
inRequestScope() {
|
|
15
|
+
return this._bindingInSyntax.inRequestScope();
|
|
16
|
+
}
|
|
17
|
+
inSingletonScope() {
|
|
18
|
+
return this._bindingInSyntax.inSingletonScope();
|
|
19
|
+
}
|
|
20
|
+
inTransientScope() {
|
|
21
|
+
return this._bindingInSyntax.inTransientScope();
|
|
22
|
+
}
|
|
23
|
+
when(constraint) {
|
|
24
|
+
return this._bindingWhenSyntax.when(constraint);
|
|
25
|
+
}
|
|
26
|
+
whenTargetNamed(name) {
|
|
27
|
+
return this._bindingWhenSyntax.whenTargetNamed(name);
|
|
28
|
+
}
|
|
29
|
+
whenTargetIsDefault() {
|
|
30
|
+
return this._bindingWhenSyntax.whenTargetIsDefault();
|
|
31
|
+
}
|
|
32
|
+
whenTargetTagged(tag, value) {
|
|
33
|
+
return this._bindingWhenSyntax.whenTargetTagged(tag, value);
|
|
34
|
+
}
|
|
35
|
+
whenInjectedInto(parent) {
|
|
36
|
+
return this._bindingWhenSyntax.whenInjectedInto(parent);
|
|
37
|
+
}
|
|
38
|
+
whenParentNamed(name) {
|
|
39
|
+
return this._bindingWhenSyntax.whenParentNamed(name);
|
|
40
|
+
}
|
|
41
|
+
whenParentTagged(tag, value) {
|
|
42
|
+
return this._bindingWhenSyntax.whenParentTagged(tag, value);
|
|
43
|
+
}
|
|
44
|
+
whenAnyAncestorIs(ancestor) {
|
|
45
|
+
return this._bindingWhenSyntax.whenAnyAncestorIs(ancestor);
|
|
46
|
+
}
|
|
47
|
+
whenNoAncestorIs(ancestor) {
|
|
48
|
+
return this._bindingWhenSyntax.whenNoAncestorIs(ancestor);
|
|
49
|
+
}
|
|
50
|
+
whenAnyAncestorNamed(name) {
|
|
51
|
+
return this._bindingWhenSyntax.whenAnyAncestorNamed(name);
|
|
52
|
+
}
|
|
53
|
+
whenAnyAncestorTagged(tag, value) {
|
|
54
|
+
return this._bindingWhenSyntax.whenAnyAncestorTagged(tag, value);
|
|
55
|
+
}
|
|
56
|
+
whenNoAncestorNamed(name) {
|
|
57
|
+
return this._bindingWhenSyntax.whenNoAncestorNamed(name);
|
|
58
|
+
}
|
|
59
|
+
whenNoAncestorTagged(tag, value) {
|
|
60
|
+
return this._bindingWhenSyntax.whenNoAncestorTagged(tag, value);
|
|
61
|
+
}
|
|
62
|
+
whenAnyAncestorMatches(constraint) {
|
|
63
|
+
return this._bindingWhenSyntax.whenAnyAncestorMatches(constraint);
|
|
64
|
+
}
|
|
65
|
+
whenNoAncestorMatches(constraint) {
|
|
66
|
+
return this._bindingWhenSyntax.whenNoAncestorMatches(constraint);
|
|
67
|
+
}
|
|
68
|
+
onActivation(handler) {
|
|
69
|
+
return this._bindingOnSyntax.onActivation(handler);
|
|
70
|
+
}
|
|
71
|
+
onDeactivation(handler) {
|
|
72
|
+
return this._bindingOnSyntax.onDeactivation(handler);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.BindingInWhenOnSyntax = BindingInWhenOnSyntax;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BindingOnSyntax = void 0;
|
|
4
|
+
const binding_when_syntax_1 = require("./binding_when_syntax");
|
|
5
|
+
class BindingOnSyntax {
|
|
6
|
+
constructor(binding) {
|
|
7
|
+
this._binding = binding;
|
|
8
|
+
}
|
|
9
|
+
onActivation(handler) {
|
|
10
|
+
this._binding.onActivation = handler;
|
|
11
|
+
return new binding_when_syntax_1.BindingWhenSyntax(this._binding);
|
|
12
|
+
}
|
|
13
|
+
onDeactivation(handler) {
|
|
14
|
+
this._binding.onDeactivation = handler;
|
|
15
|
+
return new binding_when_syntax_1.BindingWhenSyntax(this._binding);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.BindingOnSyntax = BindingOnSyntax;
|