@inversifyjs/core 2.1.0 → 3.0.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/CHANGELOG.md +28 -0
- package/lib/cjs/binding/models/BindingActivation.d.ts +2 -1
- package/lib/cjs/binding/models/BindingActivation.d.ts.map +1 -1
- package/lib/cjs/binding/models/Provider.d.ts +1 -1
- package/lib/cjs/binding/models/Provider.d.ts.map +1 -1
- package/lib/cjs/binding/services/BindingService.d.ts +2 -0
- package/lib/cjs/binding/services/BindingService.d.ts.map +1 -1
- package/lib/cjs/binding/services/BindingService.js +7 -1
- package/lib/cjs/binding/services/BindingService.js.map +1 -1
- package/lib/cjs/common/models/OneToManyMapStar.d.ts +1 -0
- package/lib/cjs/common/models/OneToManyMapStar.d.ts.map +1 -1
- package/lib/cjs/common/models/OneToManyMapStar.js +3 -0
- package/lib/cjs/common/models/OneToManyMapStar.js.map +1 -1
- package/lib/cjs/common/models/__mocks__/OneToManyMapStar.d.ts +1 -0
- package/lib/cjs/common/models/__mocks__/OneToManyMapStar.d.ts.map +1 -1
- package/lib/cjs/common/models/__mocks__/OneToManyMapStar.js +4 -0
- package/lib/cjs/common/models/__mocks__/OneToManyMapStar.js.map +1 -1
- package/lib/cjs/decorator/actions/decorate.d.ts +3 -3
- package/lib/cjs/decorator/actions/decorate.d.ts.map +1 -1
- package/lib/cjs/decorator/actions/decorate.js +6 -3
- package/lib/cjs/decorator/actions/decorate.js.map +1 -1
- package/lib/cjs/index.d.ts +2 -4
- package/lib/cjs/index.d.ts.map +1 -1
- package/lib/cjs/index.js +1 -3
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/metadata/actions/setIsInjectableFlag.d.ts +2 -0
- package/lib/cjs/metadata/actions/setIsInjectableFlag.d.ts.map +1 -0
- package/lib/cjs/metadata/actions/setIsInjectableFlag.js +16 -0
- package/lib/cjs/metadata/actions/setIsInjectableFlag.js.map +1 -0
- package/lib/cjs/metadata/actions/setIsInjectableFlag.spec.d.ts +2 -0
- package/lib/cjs/metadata/actions/setIsInjectableFlag.spec.d.ts.map +1 -0
- package/lib/cjs/metadata/actions/updateClassMetadataWithTypescriptParameterTypes.d.ts.map +1 -1
- package/lib/cjs/metadata/actions/updateClassMetadataWithTypescriptParameterTypes.js +3 -1
- package/lib/cjs/metadata/actions/updateClassMetadataWithTypescriptParameterTypes.js.map +1 -1
- package/lib/cjs/metadata/calculations/buildClassElementMetadataFromTypescriptParameterType.d.ts.map +1 -1
- package/lib/cjs/metadata/calculations/buildClassElementMetadataFromTypescriptParameterType.js +0 -1
- package/lib/cjs/metadata/calculations/buildClassElementMetadataFromTypescriptParameterType.js.map +1 -1
- package/lib/cjs/metadata/calculations/buildDefaultManagedMetadata.d.ts.map +1 -1
- package/lib/cjs/metadata/calculations/buildDefaultManagedMetadata.js +0 -1
- package/lib/cjs/metadata/calculations/buildDefaultManagedMetadata.js.map +1 -1
- package/lib/cjs/metadata/calculations/buildDefaultMaybeClassElementMetadata.d.ts.map +1 -1
- package/lib/cjs/metadata/calculations/buildDefaultMaybeClassElementMetadata.js +0 -1
- package/lib/cjs/metadata/calculations/buildDefaultMaybeClassElementMetadata.js.map +1 -1
- package/lib/cjs/metadata/calculations/buildUnmanagedMetadataFromMaybeManagedMetadata.js +1 -4
- package/lib/cjs/metadata/calculations/buildUnmanagedMetadataFromMaybeManagedMetadata.js.map +1 -1
- package/lib/cjs/metadata/calculations/isUserlandEmittedType.d.ts +3 -0
- package/lib/cjs/metadata/calculations/isUserlandEmittedType.d.ts.map +1 -0
- package/lib/cjs/metadata/calculations/isUserlandEmittedType.js +16 -0
- package/lib/cjs/metadata/calculations/isUserlandEmittedType.js.map +1 -0
- package/lib/cjs/metadata/calculations/isUserlandEmittedType.spec.d.ts +2 -0
- package/lib/cjs/metadata/calculations/isUserlandEmittedType.spec.d.ts.map +1 -0
- package/lib/cjs/metadata/decorators/injectFromBase.d.ts +1 -1
- package/lib/cjs/metadata/decorators/injectFromBase.d.ts.map +1 -1
- package/lib/cjs/metadata/decorators/injectFromBase.js.map +1 -1
- package/lib/cjs/metadata/decorators/injectable.d.ts.map +1 -1
- package/lib/cjs/metadata/decorators/injectable.js +2 -0
- package/lib/cjs/metadata/decorators/injectable.js.map +1 -1
- package/lib/cjs/metadata/models/ManagedClassElementMetadata.d.ts +0 -2
- package/lib/cjs/metadata/models/ManagedClassElementMetadata.d.ts.map +1 -1
- package/lib/cjs/metadata/models/MaybeManagedClassElementMetadata.d.ts +0 -2
- package/lib/cjs/metadata/models/MaybeManagedClassElementMetadata.d.ts.map +1 -1
- package/lib/cjs/reflectMetadata/data/classIsInjectableFlagReflectKey.d.ts +2 -0
- package/lib/cjs/reflectMetadata/data/classIsInjectableFlagReflectKey.d.ts.map +1 -0
- package/lib/cjs/reflectMetadata/data/classIsInjectableFlagReflectKey.js +5 -0
- package/lib/cjs/reflectMetadata/data/classIsInjectableFlagReflectKey.js.map +1 -0
- package/lib/cjs/resolution/actions/resolveBindingActivations.js +2 -2
- package/lib/cjs/resolution/actions/resolveBindingActivations.js.map +1 -1
- package/lib/cjs/resolution/actions/resolveBindingServiceActivations.d.ts.map +1 -1
- package/lib/cjs/resolution/actions/resolveBindingServiceActivations.js +7 -7
- package/lib/cjs/resolution/actions/resolveBindingServiceActivations.js.map +1 -1
- package/lib/cjs/resolution/actions/setInstanceProperties.d.ts.map +1 -1
- package/lib/cjs/resolution/actions/setInstanceProperties.js +3 -4
- package/lib/cjs/resolution/actions/setInstanceProperties.js.map +1 -1
- package/lib/esm/index.d.ts +23 -26
- package/lib/esm/index.d.ts.map +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/esm/index.js.map +1 -1
- package/package.json +4 -4
- package/lib/cjs/metadata/actions/updateMetadataTargetName.d.ts +0 -5
- package/lib/cjs/metadata/actions/updateMetadataTargetName.d.ts.map +0 -1
- package/lib/cjs/metadata/actions/updateMetadataTargetName.js +0 -15
- package/lib/cjs/metadata/actions/updateMetadataTargetName.js.map +0 -1
- package/lib/cjs/metadata/actions/updateMetadataTargetName.spec.d.ts +0 -2
- package/lib/cjs/metadata/actions/updateMetadataTargetName.spec.d.ts.map +0 -1
- package/lib/cjs/metadata/decorators/targetName.d.ts +0 -3
- package/lib/cjs/metadata/decorators/targetName.d.ts.map +0 -1
- package/lib/cjs/metadata/decorators/targetName.int.spec.d.ts +0 -2
- package/lib/cjs/metadata/decorators/targetName.int.spec.d.ts.map +0 -1
- package/lib/cjs/metadata/decorators/targetName.js +0 -25
- package/lib/cjs/metadata/decorators/targetName.js.map +0 -1
- package/lib/cjs/metadata/decorators/targetName.spec.d.ts +0 -2
- package/lib/cjs/metadata/decorators/targetName.spec.d.ts.map +0 -1
- package/lib/cjs/metadata/models/MetadataTargetName.d.ts +0 -2
- package/lib/cjs/metadata/models/MetadataTargetName.d.ts.map +0 -1
- package/lib/cjs/metadata/models/MetadataTargetName.js +0 -3
- package/lib/cjs/metadata/models/MetadataTargetName.js.map +0 -1
|
@@ -3,13 +3,11 @@ import { BaseClassElementMetadata } from './BaseClassElementMetadata';
|
|
|
3
3
|
import { ClassElementMetadataKind } from './ClassElementMetadataKind';
|
|
4
4
|
import { MetadataName } from './MetadataName';
|
|
5
5
|
import { MetadataTag } from './MetadataTag';
|
|
6
|
-
import { MetadataTargetName } from './MetadataTargetName';
|
|
7
6
|
export interface ManagedClassElementMetadata extends BaseClassElementMetadata<ClassElementMetadataKind.singleInjection | ClassElementMetadataKind.multipleInjection> {
|
|
8
7
|
isFromTypescriptParamType?: true;
|
|
9
8
|
name: MetadataName | undefined;
|
|
10
9
|
optional: boolean;
|
|
11
10
|
tags: Map<MetadataTag, unknown>;
|
|
12
|
-
targetName: MetadataTargetName | undefined;
|
|
13
11
|
value: ServiceIdentifier | LazyServiceIdentifier;
|
|
14
12
|
}
|
|
15
13
|
//# sourceMappingURL=ManagedClassElementMetadata.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ManagedClassElementMetadata.d.ts","sourceRoot":"","sources":["../../../../src/metadata/models/ManagedClassElementMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE/E,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"ManagedClassElementMetadata.d.ts","sourceRoot":"","sources":["../../../../src/metadata/models/ManagedClassElementMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE/E,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,MAAM,WAAW,2BACf,SAAQ,wBAAwB,CAC5B,wBAAwB,CAAC,eAAe,GACxC,wBAAwB,CAAC,iBAAiB,CAC7C;IACD,yBAAyB,CAAC,EAAE,IAAI,CAAC;IACjC,IAAI,EAAE,YAAY,GAAG,SAAS,CAAC;IAC/B,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,GAAG,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAChC,KAAK,EAAE,iBAAiB,GAAG,qBAAqB,CAAC;CAClD"}
|
|
@@ -2,11 +2,9 @@ import { BaseClassElementMetadata } from './BaseClassElementMetadata';
|
|
|
2
2
|
import { MaybeClassElementMetadataKind } from './MaybeClassElementMetadataKind';
|
|
3
3
|
import { MetadataName } from './MetadataName';
|
|
4
4
|
import { MetadataTag } from './MetadataTag';
|
|
5
|
-
import { MetadataTargetName } from './MetadataTargetName';
|
|
6
5
|
export interface MaybeManagedClassElementMetadata extends BaseClassElementMetadata<MaybeClassElementMetadataKind.unknown> {
|
|
7
6
|
name: MetadataName | undefined;
|
|
8
7
|
optional: boolean;
|
|
9
8
|
tags: Map<MetadataTag, unknown>;
|
|
10
|
-
targetName: MetadataTargetName | undefined;
|
|
11
9
|
}
|
|
12
10
|
//# sourceMappingURL=MaybeManagedClassElementMetadata.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MaybeManagedClassElementMetadata.d.ts","sourceRoot":"","sources":["../../../../src/metadata/models/MaybeManagedClassElementMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"MaybeManagedClassElementMetadata.d.ts","sourceRoot":"","sources":["../../../../src/metadata/models/MaybeManagedClassElementMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,MAAM,WAAW,gCACf,SAAQ,wBAAwB,CAAC,6BAA6B,CAAC,OAAO,CAAC;IACvE,IAAI,EAAE,YAAY,GAAG,SAAS,CAAC;IAC/B,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,GAAG,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;CACjC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classIsInjectableFlagReflectKey.d.ts","sourceRoot":"","sources":["../../../../src/reflectMetadata/data/classIsInjectableFlagReflectKey.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,+BAA+B,EAAE,MACO,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.classIsInjectableFlagReflectKey = void 0;
|
|
4
|
+
exports.classIsInjectableFlagReflectKey = '@inversifyjs/core/classIsInjectableFlagReflectKey';
|
|
5
|
+
//# sourceMappingURL=classIsInjectableFlagReflectKey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classIsInjectableFlagReflectKey.js","sourceRoot":"","sources":["../../../../src/reflectMetadata/data/classIsInjectableFlagReflectKey.ts"],"names":[],"mappings":";;;AAAa,QAAA,+BAA+B,GAC1C,mDAAmD,CAAC"}
|
|
@@ -8,10 +8,10 @@ function resolveBindingActivations(params, binding, value) {
|
|
|
8
8
|
if (binding.onActivation !== undefined) {
|
|
9
9
|
const onActivation = binding.onActivation;
|
|
10
10
|
if ((0, common_1.isPromise)(activationResult)) {
|
|
11
|
-
activationResult = activationResult.then((resolved) => onActivation(resolved));
|
|
11
|
+
activationResult = activationResult.then((resolved) => onActivation(params.context, resolved));
|
|
12
12
|
}
|
|
13
13
|
else {
|
|
14
|
-
activationResult = onActivation(activationResult);
|
|
14
|
+
activationResult = onActivation(params.context, activationResult);
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
return (0, resolveBindingServiceActivations_1.resolveBindingServiceActivations)(params, binding.serviceIdentifier, activationResult);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveBindingActivations.js","sourceRoot":"","sources":["../../../../src/resolution/actions/resolveBindingActivations.ts"],"names":[],"mappings":";;AAUA,8DAyBC;AAnCD,gDAAgD;AAQhD,yFAAsF;AAEtF,SAAgB,yBAAyB,CACvC,MAAwB,EACxB,OAA6D,EAC7D,KAA2B;IAE3B,IAAI,gBAAgB,GAAqC,KAAK,CAAC;IAE/D,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;QACvC,MAAM,YAAY,GAAkC,OAAO,CAAC,YAAY,CAAC;QAEzE,IAAI,IAAA,kBAAS,EAAC,gBAAgB,CAAC,EAAE,CAAC;YAChC,gBAAgB,GAAG,gBAAgB,CAAC,IAAI,CACtC,CAAC,QAAkC,EAAwB,EAAE,CAC3D,YAAY,CAAC,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"resolveBindingActivations.js","sourceRoot":"","sources":["../../../../src/resolution/actions/resolveBindingActivations.ts"],"names":[],"mappings":";;AAUA,8DAyBC;AAnCD,gDAAgD;AAQhD,yFAAsF;AAEtF,SAAgB,yBAAyB,CACvC,MAAwB,EACxB,OAA6D,EAC7D,KAA2B;IAE3B,IAAI,gBAAgB,GAAqC,KAAK,CAAC;IAE/D,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;QACvC,MAAM,YAAY,GAAkC,OAAO,CAAC,YAAY,CAAC;QAEzE,IAAI,IAAA,kBAAS,EAAC,gBAAgB,CAAC,EAAE,CAAC;YAChC,gBAAgB,GAAG,gBAAgB,CAAC,IAAI,CACtC,CAAC,QAAkC,EAAwB,EAAE,CAC3D,YAAY,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,CACzC,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,gBAAgB,GAAG,YAAY,CAAC,MAAM,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;QACpE,CAAC;IACH,CAAC;IAED,OAAO,IAAA,mEAAgC,EACrC,MAAM,EACN,OAAO,CAAC,iBAAiB,EACzB,gBAAgB,CACjB,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveBindingServiceActivations.d.ts","sourceRoot":"","sources":["../../../../src/resolution/actions/resolveBindingServiceActivations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAgB,MAAM,oBAAoB,CAAC;AAE5D,wBAAgB,gCAAgC,CAAC,UAAU,EACzD,MAAM,EAAE,gBAAgB,EACxB,iBAAiB,EAAE,iBAAiB,CAAC,UAAU,CAAC,EAChD,KAAK,EAAE,QAAQ,CAAC,UAAU,CAAC,GAC1B,QAAQ,CAAC,UAAU,CAAC,
|
|
1
|
+
{"version":3,"file":"resolveBindingServiceActivations.d.ts","sourceRoot":"","sources":["../../../../src/resolution/actions/resolveBindingServiceActivations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAgB,MAAM,oBAAoB,CAAC;AAE5D,wBAAgB,gCAAgC,CAAC,UAAU,EACzD,MAAM,EAAE,gBAAgB,EACxB,iBAAiB,EAAE,iBAAiB,CAAC,UAAU,CAAC,EAChD,KAAK,EAAE,QAAQ,CAAC,UAAU,CAAC,GAC1B,QAAQ,CAAC,UAAU,CAAC,CAqBtB"}
|
|
@@ -8,17 +8,17 @@ function resolveBindingServiceActivations(params, serviceIdentifier, value) {
|
|
|
8
8
|
return value;
|
|
9
9
|
}
|
|
10
10
|
if ((0, common_1.isPromise)(value)) {
|
|
11
|
-
return resolveBindingActivationsFromIteratorAsync(value, activations[Symbol.iterator]());
|
|
11
|
+
return resolveBindingActivationsFromIteratorAsync(params, value, activations[Symbol.iterator]());
|
|
12
12
|
}
|
|
13
|
-
return resolveBindingActivationsFromIterator(value, activations[Symbol.iterator]());
|
|
13
|
+
return resolveBindingActivationsFromIterator(params, value, activations[Symbol.iterator]());
|
|
14
14
|
}
|
|
15
|
-
function resolveBindingActivationsFromIterator(value, activationsIterator) {
|
|
15
|
+
function resolveBindingActivationsFromIterator(params, value, activationsIterator) {
|
|
16
16
|
let activatedValue = value;
|
|
17
17
|
let activationIteratorResult = activationsIterator.next();
|
|
18
18
|
while (activationIteratorResult.done !== true) {
|
|
19
|
-
const nextActivatedValue = activationIteratorResult.value(activatedValue);
|
|
19
|
+
const nextActivatedValue = activationIteratorResult.value(params.context, activatedValue);
|
|
20
20
|
if ((0, common_1.isPromise)(nextActivatedValue)) {
|
|
21
|
-
return resolveBindingActivationsFromIteratorAsync(nextActivatedValue, activationsIterator);
|
|
21
|
+
return resolveBindingActivationsFromIteratorAsync(params, nextActivatedValue, activationsIterator);
|
|
22
22
|
}
|
|
23
23
|
else {
|
|
24
24
|
activatedValue = nextActivatedValue;
|
|
@@ -27,11 +27,11 @@ function resolveBindingActivationsFromIterator(value, activationsIterator) {
|
|
|
27
27
|
}
|
|
28
28
|
return activatedValue;
|
|
29
29
|
}
|
|
30
|
-
async function resolveBindingActivationsFromIteratorAsync(value, activationsIterator) {
|
|
30
|
+
async function resolveBindingActivationsFromIteratorAsync(params, value, activationsIterator) {
|
|
31
31
|
let activatedValue = await value;
|
|
32
32
|
let activationIteratorResult = activationsIterator.next();
|
|
33
33
|
while (activationIteratorResult.done !== true) {
|
|
34
|
-
activatedValue = await activationIteratorResult.value(activatedValue);
|
|
34
|
+
activatedValue = await activationIteratorResult.value(params.context, activatedValue);
|
|
35
35
|
activationIteratorResult = activationsIterator.next();
|
|
36
36
|
}
|
|
37
37
|
return activatedValue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveBindingServiceActivations.js","sourceRoot":"","sources":["../../../../src/resolution/actions/resolveBindingServiceActivations.ts"],"names":[],"mappings":";;AAMA,
|
|
1
|
+
{"version":3,"file":"resolveBindingServiceActivations.js","sourceRoot":"","sources":["../../../../src/resolution/actions/resolveBindingServiceActivations.ts"],"names":[],"mappings":";;AAMA,4EAyBC;AA/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,CAAC;IAE3D,IAAI,wBAAwB,GAC1B,mBAAmB,CAAC,IAAI,EAAE,CAAC;IAE7B,OAAO,wBAAwB,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;QAC9C,cAAc,GAAG,MAAM,wBAAwB,CAAC,KAAK,CACnD,MAAM,CAAC,OAAO,EACd,cAAc,CACf,CAAC;QAEF,wBAAwB,GAAG,mBAAmB,CAAC,IAAI,EAAE,CAAC;IACxD,CAAC;IAED,OAAO,cAAc,CAAC;AACxB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setInstanceProperties.d.ts","sourceRoot":"","sources":["../../../../src/resolution/actions/setInstanceProperties.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE9D,wBAAgB,qBAAqB,CACnC,kBAAkB,EAAE,CAClB,MAAM,EAAE,gBAAgB,EACxB,WAAW,EAAE,eAAe,KACzB,OAAO,GACX,CACD,MAAM,EAAE,gBAAgB,EACxB,QAAQ,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,EAC1C,IAAI,EAAE,mBAAmB,KACtB,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"setInstanceProperties.d.ts","sourceRoot":"","sources":["../../../../src/resolution/actions/setInstanceProperties.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE9D,wBAAgB,qBAAqB,CACnC,kBAAkB,EAAE,CAClB,MAAM,EAAE,gBAAgB,EACxB,WAAW,EAAE,eAAe,KACzB,OAAO,GACX,CACD,MAAM,EAAE,gBAAgB,EACxB,QAAQ,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,EAC1C,IAAI,EAAE,mBAAmB,KACtB,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAoCxB"}
|
|
@@ -14,11 +14,10 @@ function setInstanceProperties(resolveServiceNode) {
|
|
|
14
14
|
throw new InversifyCoreError_1.InversifyCoreError(InversifyCoreErrorKind_1.InversifyCoreErrorKind.resolution, `Expecting metadata at property "${propertyKey.toString()}", none found`);
|
|
15
15
|
}
|
|
16
16
|
if (metadata.kind !== ClassElementMetadataKind_1.ClassElementMetadataKind.unmanaged) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if ((0, common_1.isPromise)(instance[propertyName])) {
|
|
17
|
+
instance[propertyKey] = resolveServiceNode(params, propertyNode);
|
|
18
|
+
if ((0, common_1.isPromise)(instance[propertyKey])) {
|
|
20
19
|
propertyAssignmentPromises.push((async () => {
|
|
21
|
-
instance[
|
|
20
|
+
instance[propertyKey] = await instance[propertyKey];
|
|
22
21
|
})());
|
|
23
22
|
}
|
|
24
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setInstanceProperties.js","sourceRoot":"","sources":["../../../../src/resolution/actions/setInstanceProperties.ts"],"names":[],"mappings":";;AAUA,
|
|
1
|
+
{"version":3,"file":"setInstanceProperties.js","sourceRoot":"","sources":["../../../../src/resolution/actions/setInstanceProperties.ts"],"names":[],"mappings":";;AAUA,sDA6CC;AAvDD,gDAAgD;AAEhD,8EAA2E;AAC3E,sFAAmF;AAEnF,6FAA0F;AAK1F,SAAgB,qBAAqB,CACnC,kBAGY;IAMZ,OAAO,CACL,MAAwB,EACxB,QAA0C,EAC1C,IAAyB,EACH,EAAE;QACxB,MAAM,0BAA0B,GAAoB,EAAE,CAAC;QAEvD,KAAK,MAAM,CAAC,WAAW,EAAE,YAAY,CAAC,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YAC9D,MAAM,QAAQ,GACZ,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;YAEjD,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;gBAC3B,MAAM,IAAI,uCAAkB,CAC1B,+CAAsB,CAAC,UAAU,EACjC,mCAAmC,WAAW,CAAC,QAAQ,EAAE,eAAe,CACzE,CAAC;YACJ,CAAC;YAED,IAAI,QAAQ,CAAC,IAAI,KAAK,mDAAwB,CAAC,SAAS,EAAE,CAAC;gBACzD,QAAQ,CAAC,WAAW,CAAC,GAAG,kBAAkB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;gBAEjE,IAAI,IAAA,kBAAS,EAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC;oBACrC,0BAA0B,CAAC,IAAI,CAC7B,CAAC,KAAK,IAAI,EAAE;wBACV,QAAQ,CAAC,WAAW,CAAC,GAAG,MAAM,QAAQ,CAAC,WAAW,CAAC,CAAC;oBACtD,CAAC,CAAC,EAAE,CACL,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;QAED,IAAI,0BAA0B,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC1C,OAAO,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QACvE,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
package/lib/esm/index.d.ts
CHANGED
|
@@ -32,21 +32,6 @@ declare const bindingScopeValues: {
|
|
|
32
32
|
[TKey in BindingScope]: TKey;
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
-
type BindingActivation<T = unknown> = (injectable: T) => Resolved<T>;
|
|
36
|
-
|
|
37
|
-
type BindingDeactivation<T = unknown> = (injectable: T) => void | Promise<void>;
|
|
38
|
-
|
|
39
|
-
interface ScopedBinding<TType extends BindingType, TScope extends BindingScope, TActivated> extends BaseBinding<TType, TActivated> {
|
|
40
|
-
cache: Either<undefined, Resolved<TActivated>>;
|
|
41
|
-
readonly onActivation: BindingActivation<TActivated> | undefined;
|
|
42
|
-
readonly onDeactivation: BindingDeactivation<TActivated> | undefined;
|
|
43
|
-
readonly scope: TScope;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
interface ConstantValueBinding<TActivated> extends ScopedBinding<typeof bindingTypeValues.ConstantValue, typeof bindingScopeValues.Singleton, TActivated> {
|
|
47
|
-
readonly value: Resolved<TActivated>;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
35
|
interface GetOptionsTagConstraint {
|
|
51
36
|
key: MetadataTag;
|
|
52
37
|
value: unknown;
|
|
@@ -71,6 +56,21 @@ interface ResolutionContext {
|
|
|
71
56
|
getAsync<TActivated>(serviceIdentifier: ServiceIdentifier<TActivated>, options?: GetOptions): Promise<TActivated>;
|
|
72
57
|
}
|
|
73
58
|
|
|
59
|
+
type BindingActivation<T = unknown> = (context: ResolutionContext, injectable: T) => Resolved<T>;
|
|
60
|
+
|
|
61
|
+
type BindingDeactivation<T = unknown> = (injectable: T) => void | Promise<void>;
|
|
62
|
+
|
|
63
|
+
interface ScopedBinding<TType extends BindingType, TScope extends BindingScope, TActivated> extends BaseBinding<TType, TActivated> {
|
|
64
|
+
cache: Either<undefined, Resolved<TActivated>>;
|
|
65
|
+
readonly onActivation: BindingActivation<TActivated> | undefined;
|
|
66
|
+
readonly onDeactivation: BindingDeactivation<TActivated> | undefined;
|
|
67
|
+
readonly scope: TScope;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
interface ConstantValueBinding<TActivated> extends ScopedBinding<typeof bindingTypeValues.ConstantValue, typeof bindingScopeValues.Singleton, TActivated> {
|
|
71
|
+
readonly value: Resolved<TActivated>;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
74
|
type DynamicValueBuilder<T> = (context: ResolutionContext) => Resolved<T>;
|
|
75
75
|
|
|
76
76
|
interface DynamicValueBinding<TActivated> extends ScopedBinding<typeof bindingTypeValues.DynamicValue, BindingScope, TActivated> {
|
|
@@ -87,7 +87,7 @@ interface InstanceBinding<TActivated> extends ScopedBinding<typeof bindingTypeVa
|
|
|
87
87
|
readonly implementationType: Newable<TActivated>;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
type Provider<TActivated, in TArgs extends unknown[] = any[]> = (...args: TArgs
|
|
90
|
+
type Provider<TActivated, in TArgs extends unknown[] = any[]> = (...args: TArgs) => Promise<TActivated>;
|
|
91
91
|
|
|
92
92
|
interface ProviderBinding<TActivated extends Provider<unknown>> extends ScopedBinding<typeof bindingTypeValues.Provider, typeof bindingScopeValues.Singleton, TActivated> {
|
|
93
93
|
readonly provider: (context: ResolutionContext) => TActivated;
|
|
@@ -128,6 +128,8 @@ declare class BindingService implements Cloneable<BindingService> {
|
|
|
128
128
|
static build(parent: BindingService | undefined): BindingService;
|
|
129
129
|
clone(): BindingService;
|
|
130
130
|
get<TResolved>(serviceIdentifier: ServiceIdentifier): Iterable<Binding<TResolved>> | undefined;
|
|
131
|
+
getNonParentBindings<TResolved>(serviceId: ServiceIdentifier): Iterable<Binding<TResolved>> | undefined;
|
|
132
|
+
getNonParentBoundServices(): Iterable<ServiceIdentifier>;
|
|
131
133
|
getByModuleId<TResolved>(moduleId: number): Iterable<Binding<TResolved>> | undefined;
|
|
132
134
|
removeAllByModuleId(moduleId: number): void;
|
|
133
135
|
removeAllByServiceId(serviceId: ServiceIdentifier): void;
|
|
@@ -153,9 +155,9 @@ declare class DeactivationsService implements Cloneable<DeactivationsService> {
|
|
|
153
155
|
removeAllByServiceId(serviceId: ServiceIdentifier): void;
|
|
154
156
|
}
|
|
155
157
|
|
|
156
|
-
declare function decorate(decorators: ClassDecorator[], target: Function): void;
|
|
157
|
-
declare function decorate(decorators: ParameterDecorator[], target: Function, parameterIndex: number): void;
|
|
158
|
-
declare function decorate(decorators: MethodDecorator[] | PropertyDecorator[], target: Function, property: string | symbol): void;
|
|
158
|
+
declare function decorate(decorators: ClassDecorator | ClassDecorator[], target: Function): void;
|
|
159
|
+
declare function decorate(decorators: ParameterDecorator | ParameterDecorator[], target: Function, parameterIndex: number): void;
|
|
160
|
+
declare function decorate(decorators: MethodDecorator | PropertyDecorator | MethodDecorator[] | PropertyDecorator[], target: Function, property: string | symbol): void;
|
|
159
161
|
|
|
160
162
|
interface BaseClassElementMetadata<TKind> {
|
|
161
163
|
kind: TKind;
|
|
@@ -167,14 +169,11 @@ declare enum ClassElementMetadataKind {
|
|
|
167
169
|
unmanaged = 2
|
|
168
170
|
}
|
|
169
171
|
|
|
170
|
-
type MetadataTargetName = string;
|
|
171
|
-
|
|
172
172
|
interface ManagedClassElementMetadata extends BaseClassElementMetadata<ClassElementMetadataKind.singleInjection | ClassElementMetadataKind.multipleInjection> {
|
|
173
173
|
isFromTypescriptParamType?: true;
|
|
174
174
|
name: MetadataName | undefined;
|
|
175
175
|
optional: boolean;
|
|
176
176
|
tags: Map<MetadataTag, unknown>;
|
|
177
|
-
targetName: MetadataTargetName | undefined;
|
|
178
177
|
value: ServiceIdentifier | LazyServiceIdentifier;
|
|
179
178
|
}
|
|
180
179
|
|
|
@@ -205,7 +204,7 @@ interface InjectFromBaseOptions {
|
|
|
205
204
|
extendProperties?: boolean | undefined;
|
|
206
205
|
}
|
|
207
206
|
|
|
208
|
-
declare function injectFromBase(options
|
|
207
|
+
declare function injectFromBase(options?: InjectFromBaseOptions): ClassDecorator;
|
|
209
208
|
|
|
210
209
|
declare function multiInject(serviceIdentifier: ServiceIdentifier | LazyServiceIdentifier): ParameterDecorator & PropertyDecorator;
|
|
211
210
|
|
|
@@ -219,8 +218,6 @@ declare function preDestroy(): MethodDecorator;
|
|
|
219
218
|
|
|
220
219
|
declare function tagged(key: MetadataTag, value: unknown): ParameterDecorator & PropertyDecorator;
|
|
221
220
|
|
|
222
|
-
declare function targetName(targetName: MetadataTargetName): ParameterDecorator & PropertyDecorator;
|
|
223
|
-
|
|
224
221
|
declare function unmanaged(): ParameterDecorator & PropertyDecorator;
|
|
225
222
|
|
|
226
223
|
interface BasePlanParams {
|
|
@@ -305,4 +302,4 @@ declare function resolveModuleDeactivations(params: DeactivationParams, moduleId
|
|
|
305
302
|
|
|
306
303
|
declare function resolveServiceDeactivations(params: DeactivationParams, serviceIdentifier: ServiceIdentifier): void | Promise<void>;
|
|
307
304
|
|
|
308
|
-
export { ActivationsService, type BaseBinding, type BaseBindingNode, type BasePlanParams, type Binding, type BindingActivation, type BindingActivationRelation, type BindingDeactivation, type BindingDeactivationRelation, type BindingMetadata, type BindingScope, BindingService, type BindingType, type ClassElementMetadata, ClassElementMetadataKind, type ClassMetadata, type ClassMetadataLifecycle, type ConstantValueBinding, type DeactivationParams, DeactivationsService, type DynamicValueBinding, type DynamicValueBuilder, type Factory, type FactoryBinding, type GetOptions, type GetOptionsTagConstraint, type InstanceBinding, type LeafBindingNode, type ManagedClassElementMetadata, type MetadataName, type MetadataTag, type
|
|
305
|
+
export { ActivationsService, type BaseBinding, type BaseBindingNode, type BasePlanParams, type Binding, type BindingActivation, type BindingActivationRelation, type BindingDeactivation, type BindingDeactivationRelation, type BindingMetadata, type BindingScope, BindingService, type BindingType, type ClassElementMetadata, ClassElementMetadataKind, type ClassMetadata, type ClassMetadataLifecycle, type ConstantValueBinding, type DeactivationParams, DeactivationsService, type DynamicValueBinding, type DynamicValueBuilder, type Factory, type FactoryBinding, type GetOptions, type GetOptionsTagConstraint, type InstanceBinding, type LeafBindingNode, type ManagedClassElementMetadata, type MetadataName, type MetadataTag, type OptionalGetOptions, type PlanBindingNode, type PlanParams, type PlanParamsConstraint, type PlanParamsTagConstraint, type PlanResult, type PlanServiceNode, type PlanServiceNodeParent, type PlanServiceRedirectionBindingNode, type PlanTree, type Provider, type ProviderBinding, type ResolutionContext, type ResolutionParams, type Resolved, type ScopedBinding, type ServiceRedirectionBinding, type UnmanagedClassElementMetadata, bindingScopeValues, bindingTypeValues, decorate, getClassMetadata, inject, injectFromBase, injectable, multiInject, named, optional, plan, postConstruct, preDestroy, resolve, resolveModuleDeactivations, resolveServiceDeactivations, tagged, unmanaged };
|
package/lib/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EACL,YAAY,EACZ,kBAAkB,EACnB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAC;AACvF,OAAO,EACL,kBAAkB,EAClB,yBAAyB,EAC1B,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OA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,SAAS,GACV,CAAC"}
|
package/lib/esm/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{getReflectMetadata as e,updateReflectMetadata as t}from"@inversifyjs/reflect-metadata-utils";import{getBaseType as n}from"@inversifyjs/prototype-utils";import{stringifyServiceIdentifier as o,LazyServiceIdentifier as i,isPromise as r}from"@inversifyjs/common";const s={Request:"Request",Singleton:"Singleton",Transient:"Transient"},c={ConstantValue:"ConstantValue",DynamicValue:"DynamicValue",Factory:"Factory",Instance:"Instance",Provider:"Provider",ServiceRedirection:"ServiceRedirection"};function*a(...e){for(const t of e)yield*t}class u{#e;#t;#n;constructor(e){this.#e=new Map,this.#t={};for(const t of Reflect.ownKeys(e))this.#t[t]=new Map;this.#n=e}clone(){const e=Reflect.ownKeys(this.#n),t=new u(this.#n);this.#o(this.#e,t.#e);for(const n of e)this.#o(this.#t[n],t.#t[n]);return t}get(e,t){return this.#t[e].get(t)?.values()}removeByRelation(e,t){const n=this.get(e,t);if(void 0!==n)for(const e of n){const t=this.#e.get(e);if(void 0===t)throw new Error("Expecting model relation, none found");this.#i(e,t),this.#e.delete(e)}}set(e,t){this.#e.set(e,t);for(const n of Reflect.ownKeys(t))this.#r(n,t[n]).add(e)}#r(e,t){let n=this.#t[e].get(t);return void 0===n&&(n=new Set,this.#t[e].set(t,n)),n}#o(e,t){for(const[n,o]of e)t.set(n,o)}#i(e,t){for(const n of Reflect.ownKeys(t))this.#s(e,n,t[n])}#s(e,t,n){const o=this.#t[t].get(n);void 0!==o&&(o.delete(e),0===o.size&&this.#t[t].delete(n))}}var d,l,f;!function(e){e.moduleId="moduleId",e.serviceId="serviceId"}(d||(d={}));class p{#c;#a;constructor(e,t){this.#c=t??new u({moduleId:{isOptional:!0},serviceId:{isOptional:!1}}),this.#a=e}static build(e){return new p(e)}add(e,t){this.#c.set(e,t)}clone(){return new p(this.#a,this.#c.clone())}get(e){const t=[],n=this.#c.get(d.serviceId,e);void 0!==n&&t.push(n);const o=this.#a?.get(e);if(void 0!==o&&t.push(o),0!==t.length)return a(...t)}removeAllByModuleId(e){this.#c.removeByRelation(d.moduleId,e)}removeAllByServiceId(e){this.#c.removeByRelation(d.serviceId,e)}}!function(e){e.moduleId="moduleId",e.serviceId="serviceId"}(l||(l={}));class m{#u;#a;constructor(e,t){this.#u=t??new u({moduleId:{isOptional:!0},serviceId:{isOptional:!1}}),this.#a=e}static build(e){return new m(e)}clone(){return new m(this.#a,this.#u.clone())}get(e){return this.#u.get(l.serviceId,e)??this.#a?.get(e)}getByModuleId(e){return this.#u.get(l.moduleId,e)??this.#a?.getByModuleId(e)}removeAllByModuleId(e){this.#u.removeByRelation(l.moduleId,e)}removeAllByServiceId(e){this.#u.removeByRelation(l.serviceId,e)}set(e){const t={[l.serviceId]:e.serviceIdentifier};void 0!==e.moduleId&&(t[l.moduleId]=e.moduleId),this.#u.set(e,t)}}!function(e){e.moduleId="moduleId",e.serviceId="serviceId"}(f||(f={}));class g{#d;#a;constructor(e,t){this.#d=t??new u({moduleId:{isOptional:!0},serviceId:{isOptional:!1}}),this.#a=e}static build(e){return new g(e)}add(e,t){this.#d.set(e,t)}clone(){return new g(this.#a,this.#d.clone())}get(e){const t=[],n=this.#d.get(f.serviceId,e);void 0!==n&&t.push(n);const o=this.#a?.get(e);if(void 0!==o&&t.push(o),0!==t.length)return a(...t)}removeAllByModuleId(e){this.#d.removeByRelation(f.moduleId,e)}removeAllByServiceId(e){this.#d.removeByRelation(f.serviceId,e)}}function v(e,t,n){if(void 0!==n)if("number"!=typeof n)Reflect.decorate(e,t.prototype,n);else for(const o of e)o(t,void 0,n);else Reflect.decorate(e,t)}const h="@inversifyjs/core/classMetadataReflectKey";function y(){return{constructorArguments:[],lifecycle:{postConstructMethodName:void 0,preDestroyMethodName:void 0},properties:new Map,scope:void 0}}const w="@inversifyjs/core/pendingClassMetadataCountReflectKey";const M=Symbol.for("@inversifyjs/core/InversifyCoreError");class I extends Error{[M];kind;constructor(e,t,n){super(t,n),this[M]=!0,this.kind=e}static is(e){return"object"==typeof e&&null!==e&&!0===e[M]}static isErrorOfKind(e,t){return I.is(e)&&e.kind===t}}var b,j,C;function x(t){const n=e(t,h)??y();if(!function(t){const n=e(t,w);return void 0!==n&&0!==n}(t))return function(e,t){const n=[];if(t.length<e.length)throw new I(b.missingInjectionDecorator,`Found unexpected missing metadata on type "${e.name}". "${e.name}" constructor requires at least ${e.length.toString()} arguments, found ${t.length.toString()} instead.\nAre you using @inject, @multiInject or @unmanaged decorators in every non optional constructor argument?\n\nIf you're using typescript and want to rely on auto injection, set "emitDecoratorMetadata" compiler option to true`);for(let e=0;e<t.length;++e)void 0===t[e]&&n.push(e);if(n.length>0)throw new I(b.missingInjectionDecorator,`Found unexpected missing metadata on type "${e.name}" at constructor indexes "${n.join('", "')}".\n\nAre you using @inject, @multiInject or @unmanaged decorators at those indexes?\n\nIf you're using typescript and want to rely on auto injection, set "emitDecoratorMetadata" compiler option to true`)}(t,n.constructorArguments),n;!function(e,t){const n=[];for(let o=0;o<t.constructorArguments.length;++o){const i=t.constructorArguments[o];void 0!==i&&i.kind!==j.unknown||n.push(` - Missing or incomplete metadata for type "${e.name}" at constructor argument with index ${o.toString()}.\nEvery constructor parameter must be decorated either with @inject, @multiInject or @unmanaged decorator.`)}for(const[o,i]of t.properties)i.kind===j.unknown&&n.push(` - Missing or incomplete metadata for type "${e.name}" at property "${o.toString()}".\nThis property must be decorated either with @inject or @multiInject decorator.`);if(0===n.length)throw new I(b.unknown,`Unexpected class metadata for type "${e.name}" with uncompletion traces.\nThis might be caused by one of the following reasons:\n\n1. A third party library is targeting inversify reflection metadata.\n2. A bug is causing the issue. Consider submiting an issue to fix it.`);throw new I(b.missingInjectionDecorator,`Invalid class metadata at type ${e.name}:\n\n${n.join("\n\n")}`)}(t,n)}function $(){return 0}function R(e){return n=>{void 0!==n&&n.kind===j.unknown&&t(e,w,$,(e=>e-1))}}function S(e,t){return(...n)=>o=>{if(void 0===o)return e(...n);if(o.kind===C.unmanaged)throw new I(b.injectionDecoratorConflict,"Unexpected injection found. Multiple @inject, @multiInject or @unmanaged decorators found");return t(o,...n)}}function T(e){if(e.kind!==j.unknown&&!0!==e.isFromTypescriptParamType)throw new I(b.injectionDecoratorConflict,"Unexpected injection found. Multiple @inject, @multiInject or @unmanaged decorators found")}!function(e){e[e.injectionDecoratorConflict=0]="injectionDecoratorConflict",e[e.missingInjectionDecorator=1]="missingInjectionDecorator",e[e.planning=2]="planning",e[e.resolution=3]="resolution",e[e.unknown=4]="unknown"}(b||(b={})),function(e){e[e.unknown=0]="unknown"}(j||(j={})),function(e){e[e.multipleInjection=0]="multipleInjection",e[e.singleInjection=1]="singleInjection",e[e.unmanaged=2]="unmanaged"}(C||(C={}));const D=S((function(e,t){return{kind:e,name:void 0,optional:!1,tags:new Map,targetName:void 0,value:t}}),(function(e,t,n){return T(e),{...e,kind:t,value:n}}));var A;function k(e,t,n,o){if(I.isErrorOfKind(o,b.injectionDecoratorConflict)){const i=function(e,t,n){if(void 0===n){if(void 0===t)throw new I(b.unknown,"Unexpected undefined property and index values");return{kind:A.property,property:t,targetClass:e.constructor}}return{index:n,kind:A.parameter,targetClass:e}}(e,t,n);throw new I(b.injectionDecoratorConflict,`Unexpected injection error.\n\nCause:\n\n${o.message}\n\nDetails\n\n${function(e){switch(e.kind){case A.parameter:return`[class: "${e.targetClass.name}", index: "${e.index.toString()}"]`;case A.property:return`[class: "${e.targetClass.name}", property: "${e.property.toString()}"]`}}(i)}`,{cause:o})}throw o}function B(e,n){return(o,i,r)=>{void 0===r?function(e,n){const o=N(e,n);return(e,n)=>{t(e.constructor,h,y,function(e,t){return n=>{const o=n.properties.get(t);return n.properties.set(t,e(o)),n}}(o(e),n))}}(e,n)(o,i):function(e,n){const o=N(e,n);return(e,n,i)=>{if(!function(e,t){return"function"==typeof e&&void 0===t}(e,n))throw new Error(`Found an @inject decorator in a non constructor parameter.\nFound @inject decorator at method "${n?.toString()??""}" at class "${e.constructor.name}"`);t(e,h,y,function(e,t){return n=>{const o=n.constructorArguments[t];return n.constructorArguments[t]=e(o),n}}(o(e),i))}}(e,n)(o,i,r)}}function N(e,t){return n=>{const o=t(n);return t=>(o(t),e(t))}}function E(e){const t=D(C.singleInjection,e);return(e,n,o)=>{try{void 0===o?B(t,R)(e,n):B(t,R)(e,n,o)}catch(t){k(e,n,o,t)}}}!function(e){e[e.parameter=0]="parameter",e[e.property=1]="property"}(A||(A={}));function F(n){const o=e(n,"design:paramtypes");void 0!==o&&t(n,h,y,function(e){return t=>(e.forEach(((e,n)=>{var o;void 0===t.constructorArguments[n]&&(t.constructorArguments[n]=(o=e,{isFromTypescriptParamType:!0,kind:C.singleInjection,name:void 0,optional:!1,tags:new Map,targetName:void 0,value:o}))})),t)}(o))}function P(e){return n=>{F(n),void 0!==e&&t(n,h,y,(t=>({...t,scope:e})))}}function U(e,t,n){let o;return e.extendConstructorArguments??!1?(o=[...t.constructorArguments],n.constructorArguments.map(((e,t)=>{o[t]=e}))):o=n.constructorArguments,o}function O(e,t,n){let o;return o=e.extendProperties??!1?new Map(a(t.properties,n.properties)):n.properties,o}function K(e){return n=>{const o=x(e.type);t(n,h,y,function(e,t){const n=n=>({constructorArguments:U(e,t,n),lifecycle:n.lifecycle,properties:O(e,t,n),scope:n.scope});return n}(e,o))}}function q(e){return t=>{const o=n(t);if(void 0===o)throw new I(b.injectionDecoratorConflict,`Expected base type for type "${t.name}", none found.`);K({...e,type:o})(t)}}function V(e){const t=D(C.multipleInjection,e);return(e,n,o)=>{try{void 0===o?B(t,R)(e,n):B(t,R)(e,n,o)}catch(t){k(e,n,o,t)}}}function z(e){return n=>{void 0===n&&t(e,w,$,(e=>e+1))}}function G(e){return t=>{const n=t??{kind:j.unknown,name:void 0,optional:!1,tags:new Map,targetName:void 0};if(n.kind===C.unmanaged)throw new I(b.injectionDecoratorConflict,"Unexpected injection found. Found @unmanaged injection with additional @named, @optional, @tagged or @targetName injections");return e(n)}}function H(e){const t=G(function(e){return t=>{if(void 0!==t.name)throw new I(b.injectionDecoratorConflict,"Unexpected duplicated named decorator");return t.name=e,t}}(e));return(e,n,o)=>{try{void 0===o?B(t,z)(e,n):B(t,z)(e,n,o)}catch(t){k(e,n,o,t)}}}function J(e){if(e.optional)throw new I(b.injectionDecoratorConflict,"Unexpected duplicated optional decorator");return e.optional=!0,e}function L(){const e=G(J);return(t,n,o)=>{try{void 0===o?B(e,z)(t,n):B(e,z)(t,n,o)}catch(e){k(t,n,o,e)}}}function Q(){return(e,n,o)=>{try{t(e.constructor,h,y,(i=n,e=>{if(void 0!==e.lifecycle.postConstructMethodName)throw new I(b.injectionDecoratorConflict,"Unexpected duplicated postConstruct decorator");return e.lifecycle.postConstructMethodName=i,e}))}catch(t){k(e,n,void 0,t)}var i}}function W(){return(e,n,o)=>{try{t(e.constructor,h,y,(i=n,e=>{if(void 0!==e.lifecycle.preDestroyMethodName)throw new I(b.injectionDecoratorConflict,"Unexpected duplicated preDestroy decorator");return e.lifecycle.preDestroyMethodName=i,e}))}catch(t){k(e,n,void 0,t)}var i}}function X(e,t){const n=G(function(e,t){return n=>{if(n.tags.has(e))throw new I(b.injectionDecoratorConflict,"Unexpected duplicated tag decorator with existing tag");return n.tags.set(e,t),n}}(e,t));return(e,t,o)=>{try{void 0===o?B(n,z)(e,t):B(n,z)(e,t,o)}catch(n){k(e,t,o,n)}}}function Y(e){const t=G(function(e){return t=>{if(void 0!==t.targetName)throw new I(b.injectionDecoratorConflict,"Unexpected duplicated targetName decorator");return t.targetName=e,t}}(e));return(e,n,o)=>{try{void 0===o?B(t,z)(e,n):B(t,z)(e,n,o)}catch(t){k(e,n,o,t)}}}function Z(){return{kind:C.unmanaged}}const _=S(Z,(function(e){if(T(e),function(e){return void 0!==e.name||e.optional||e.tags.size>0||void 0!==e.targetName}(e))throw new I(b.injectionDecoratorConflict,"Unexpected injection found. Found @unmanaged injection with additional @named, @optional, @tagged or @targetName injections");return Z()}));function ee(){const e=_();return(t,n,o)=>{try{void 0===o?B(e,R)(t,n):B(e,R)(t,n,o)}catch(e){k(t,n,o,e)}}}class te{last;constructor(e){this.last=e}concat(e){return new te({elem:e,previous:this.last})}[Symbol.iterator](){let e=this.last;return{next:()=>{if(void 0===e)return{done:!0,value:void 0};const t=e.elem;return e=e.previous,{done:!1,value:t}}}}}function ne(e,t){e.servicesBranch.has(t)&&function(e,t){const n=(i=[...e.servicesBranch,t],[...i].map(o).join(" -> "));var i;throw new I(b.planning,`Circular dependency found: ${n}`)}(e,t),e.servicesBranch.add(t)}class oe{#l;constructor(e){this.#l=e}get name(){return this.#l.elem.name}get tags(){return this.#l.elem.tags}get serviceIdentifier(){return this.#l.elem.serviceIdentifier}getAncestor(){if(void 0!==this.#l.previous)return new oe(this.#l.previous)}}function ie(e,t,n){const o=new oe(t.last),i=n?.customServiceIdentifier??o.serviceIdentifier;return[...e.getBindings(i)??[]].filter((e=>e.isSatisfiedBy(o)))}function re(e){return void 0!==e.redirections}function se(e,t,n){let i,r;re(n)?(i=n.binding.targetServiceIdentifier,r=n.binding.serviceIdentifier):(i=n.serviceIdentifier,r=n.parent?.binding.serviceIdentifier),Array.isArray(e)?function(e,t,n,i){if(0!==e.length){const t=`Ambiguous bindings found for service: "${o(n)}".\n\nRegistered bindings:\n\n${e.map((e=>function(e){switch(e.type){case c.Instance:return`[ type: "${e.type}", serviceIdentifier: "${o(e.serviceIdentifier)}", scope: "${e.scope}", implementationType: "${e.implementationType.name}" ]`;case c.ServiceRedirection:return`[ type: "${e.type}", serviceIdentifier: "${o(e.serviceIdentifier)}", redirection: "${o(e.targetServiceIdentifier)}" ]`;default:return`[ type: "${e.type}", serviceIdentifier: "${o(e.serviceIdentifier)}", scope: "${e.scope}" ]`}}(e.binding))).join("\n")}\n\nTrying to resolve bindings for "${ae(n,i)}".`;throw new I(b.planning,t)}t||ce(n,i)}(e,t,i,r):function(e,t,n,o){if(void 0!==e||t)return;ce(n,o)}(e,t,i,r)}function ce(e,t){const n=`No bindings found for service: "${o(e)}".\n\nTrying to resolve bindings for "${ae(e,t)}".`;throw new I(b.planning,n)}function ae(e,t){return void 0===t?`${o(e)} (Root service)`:o(t)}function ue(e,t){if(1!==e.redirections.length)se(e.redirections,t,e);else{const[n]=e.redirections;re(n)&&ue(n,t)}}function de(e,t){if(Array.isArray(e.bindings)&&1===e.bindings.length){const[n]=e.bindings;re(n)&&ue(n,t)}else se(e.bindings,t,e)}function le(e){const t=new Map;void 0!==e.rootConstraints.tag&&t.set(e.rootConstraints.tag.key,e.rootConstraints.tag.value);const n=new te({elem:{name:e.rootConstraints.name,serviceIdentifier:e.rootConstraints.serviceIdentifier,tags:t},previous:void 0}),o=ie(e,n),i=[],r={bindings:i,parent:void 0,serviceIdentifier:e.rootConstraints.serviceIdentifier};if(i.push(...me(e,n,o,r)),!e.rootConstraints.isMultiple){de(r,e.rootConstraints.isOptional??!1);const[t]=i;r.bindings=t}return{tree:{root:r}}}function fe(e,t,n,o){const i={binding:t,classMetadata:e.getClassMetadata(t.implementationType),constructorParams:[],parent:o,propertyParams:new Map};return function(e,t){const n=e.node.classMetadata;for(const[o,i]of n.constructorArguments.entries())e.node.constructorParams[o]=pe(e,t,i);for(const[o,i]of n.properties){const n=pe(e,t,i);void 0!==n&&e.node.propertyParams.set(o,n)}return e.node}({getBindings:e.getBindings,getClassMetadata:e.getClassMetadata,node:i,servicesBranch:e.servicesBranch},n)}function pe(e,t,n){if(n.kind===C.unmanaged)return;const o=i.is(n.value)?n.value.unwrap():n.value,r=t.concat({name:n.name,serviceIdentifier:o,tags:n.tags}),s=ie(e,r),c=[],a={bindings:c,parent:e.node,serviceIdentifier:o};if(c.push(...me(e,r,s,a)),n.kind===C.singleInjection){de(a,n.optional);const[e]=c;a.bindings=e}return a}function me(e,t,n,o){const i=re(o)?o.binding.targetServiceIdentifier:o.serviceIdentifier;ne(e,i);const r=[];for(const i of n)switch(i.type){case c.Instance:r.push(fe(e,i,t,o));break;case c.ServiceRedirection:{const n=ge(e,t,i,o);r.push(n);break}default:r.push({binding:i,parent:o})}return e.servicesBranch.delete(i),r}function ge(e,t,n,o){const i={binding:n,parent:o,redirections:[]},r=ie(e,t,{customServiceIdentifier:n.targetServiceIdentifier});return i.redirections.push(...me(e,t,r,i)),i}function ve(e,t,n){const o=e.getActivations(t);return void 0===o?n:r(n)?he(n,o[Symbol.iterator]()):function(e,t){let n=e,o=t.next();for(;!0!==o.done;){const e=o.value(n);if(r(e))return he(e,t);n=e,o=t.next()}return n}(n,o[Symbol.iterator]())}async function he(e,t){let n=await e,o=t.next();for(;!0!==o.done;)n=await o.value(n),o=t.next();return n}function ye(e,t,n){let o=n;if(void 0!==t.onActivation){const e=t.onActivation;o=r(o)?o.then((t=>e(t))):e(o)}return ve(e,t.serviceIdentifier,o)}function we(e){return(t,n)=>{if(n.cache.isRight)return n.cache.value;const o=ye(t,n,e(t,n));return n.cache={isRight:!0,value:o},o}}const Me=we((function(e,t){return t.value}));function Ie(e){return e}function be(e,t){return(n,o)=>{const i=e(o);switch(i.scope){case s.Singleton:{if(i.cache.isRight)return i.cache.value;const e=je(n,o,i,t);return i.cache={isRight:!0,value:e},e}case s.Request:{if(n.requestScopeCache.has(i.id))return n.requestScopeCache.get(i.id);const e=je(n,o,i,t);return n.requestScopeCache.set(i.id,e),e}case s.Transient:return je(n,o,i,t)}}}function je(e,t,n,o){return ye(e,n,o(e,t))}const Ce=(e=>be(Ie,e))((function(e,t){return t.value(e.context)}));const xe=we((function(e,t){return t.factory(e.context)}));function $e(e,t,n){const o=function(e,t,n){if(void 0===n)return;if(!(n in e))throw new I(b.resolution,`Expecting a "${n.toString()}" property when resolving "${t.implementationType.name}" class @postConstruct decorated method, none found.`);if("function"!=typeof e[n])throw new I(b.resolution,`Expecting a "${n.toString()}" method when resolving "${t.implementationType.name}" class @postConstruct decorated method, a non function property was found instead.`);{let o;try{o=e[n]()}catch(e){throw new I(b.resolution,`Unexpected error found when calling "${n.toString()}" @postConstruct decorated method on class "${t.implementationType.name}"`,{cause:e})}if(r(o))return async function(e,t,n){try{await n}catch(n){throw new I(b.resolution,`Unexpected error found when calling "${t.toString()}" @postConstruct decorated method on class "${e.implementationType.name}"`,{cause:n})}}(t,n,o)}}(e,t,n);return r(o)?o.then((()=>e)):e}function Re(e){return(t,n,o)=>{const i=new o.binding.implementationType(...t),s=e(n,i,o);return r(s)?s.then((()=>$e(i,o.binding,o.classMetadata.lifecycle.postConstructMethodName))):$e(i,o.binding,o.classMetadata.lifecycle.postConstructMethodName)}}const Se=we((function(e,t){return t.provider(e.context)}));function Te(e){return e.binding}const De=function(e){return(t,n,o)=>{const i=[];for(const[s,c]of o.propertyParams){const a=o.classMetadata.properties.get(s);if(void 0===a)throw new I(b.resolution,`Expecting metadata at property "${s.toString()}", none found`);if(a.kind!==C.unmanaged){const o=a.targetName??s;n[o]=e(t,c),r(n[o])&&i.push((async()=>{n[o]=await n[o]})())}}if(i.length>0)return Promise.all(i).then((()=>{}))}}(Fe),Ae=function(e){return function t(n,o){const i=[];for(const r of o.redirections)re(r)?i.push(...t(n,r)):i.push(e(n,r));return i}}(Ee),ke=function(e,t,n){return(o,i)=>{const s=e(o,i);return r(s)?t(s,o,i):n(s,o,i)}}(function(e){return(t,n)=>{const o=[];for(const i of n.constructorParams)void 0===i?o.push(void 0):o.push(e(t,i));return o.some(r)?Promise.all(o):o}}(Fe),function(e){return async(t,n,o)=>{const i=await t;return e(i,n,o)}}(Re(De)),Re(De)),Be=(e=>be(Te,e))(ke);function Ne(e){return Fe(e,e.planResult.tree.root)}function Ee(e,t){switch(t.binding.type){case c.ConstantValue:return Me(e,t.binding);case c.DynamicValue:return Ce(e,t.binding);case c.Factory:return xe(e,t.binding);case c.Instance:return Be(e,t);case c.Provider:return Se(e,t.binding)}}function Fe(e,t){if(void 0!==t.bindings)return Array.isArray(t.bindings)?function(e,t){const n=[];for(const o of t)re(o)?n.push(...Ae(e,o)):n.push(Ee(e,o));if(n.some(r))return Promise.all(n);return n}(e,t.bindings):function(e,t){if(re(t)){const n=Ae(e,t);if(1===n.length)return n[0];throw new I(b.resolution,"Unexpected multiple resolved values on single injection")}return Ee(e,t)}(e,t.bindings)}function Pe(e){return void 0!==e.scope}function Ue(e,t){if(void 0!==e.lifecycle.preDestroyMethodName&&"function"==typeof t[e.lifecycle.preDestroyMethodName])return t[e.lifecycle.preDestroyMethodName]()}function Oe(e,t,n){const o=e.getDeactivations(t);if(void 0!==o)return r(n)?Ke(n,o[Symbol.iterator]()):function(e,t){let n=t.next();for(;!0!==n.done;){const o=n.value(e);if(r(o))return Ke(e,t);n=t.next()}}(n,o[Symbol.iterator]())}async function Ke(e,t){const n=await e;let o=t.next();for(;!0!==o.done;)await o.value(n),o=t.next()}function qe(e,t){const n=function(e,t){if(t.type===c.Instance){const n=e.getClassMetadata(t.implementationType),o=t.cache.value;return r(o)?o.then((e=>Ue(n,e))):Ue(n,o)}}(e,t);return void 0===n?Ve(e,t):n.then((()=>Ve(e,t)))}function Ve(e,t){const n=t.cache;return r(n.value)?n.value.then((n=>ze(e,t,n))):ze(e,t,n.value)}function ze(e,t,n){let o;if(void 0!==t.onDeactivation){o=(0,t.onDeactivation)(n)}return void 0===o?Oe(e,t.serviceIdentifier,n):o.then((()=>Oe(e,t.serviceIdentifier,n)))}function Ge(e,t){if(void 0===t)return;const n=function(e){const t=[];for(const n of e)Pe(n)&&n.scope===s.Singleton&&n.cache.isRight&&t.push(n);return t}(t),o=[];for(const t of n){const n=qe(e,t);void 0!==n&&o.push(n)}return o.length>0?Promise.all(o).then((()=>{})):void 0}function He(e,t){const n=e.getBindingsFromModule(t);return Ge(e,n)}function Je(e,t){const n=e.getBindings(t);return Ge(e,n)}export{p as ActivationsService,m as BindingService,C as ClassElementMetadataKind,g as DeactivationsService,s as bindingScopeValues,c as bindingTypeValues,v as decorate,x as getClassMetadata,E as inject,q as injectFromBase,P as injectable,V as multiInject,H as named,L as optional,le as plan,Q as postConstruct,W as preDestroy,Ne as resolve,He as resolveModuleDeactivations,Je as resolveServiceDeactivations,X as tagged,Y as targetName,ee as unmanaged};
|
|
1
|
+
import{getReflectMetadata as e,updateReflectMetadata as n,setReflectMetadata as t}from"@inversifyjs/reflect-metadata-utils";import{getBaseType as o}from"@inversifyjs/prototype-utils";import{stringifyServiceIdentifier as i,LazyServiceIdentifier as r,isPromise as s}from"@inversifyjs/common";const c={Request:"Request",Singleton:"Singleton",Transient:"Transient"},a={ConstantValue:"ConstantValue",DynamicValue:"DynamicValue",Factory:"Factory",Instance:"Instance",Provider:"Provider",ServiceRedirection:"ServiceRedirection"};function*u(...e){for(const n of e)yield*n}class d{#e;#n;#t;constructor(e){this.#e=new Map,this.#n={};for(const n of Reflect.ownKeys(e))this.#n[n]=new Map;this.#t=e}clone(){const e=Reflect.ownKeys(this.#t),n=new d(this.#t);this.#o(this.#e,n.#e);for(const t of e)this.#o(this.#n[t],n.#n[t]);return n}get(e,n){return this.#n[e].get(n)?.values()}getAllKeys(e){return this.#n[e].keys()}removeByRelation(e,n){const t=this.get(e,n);if(void 0!==t)for(const e of t){const n=this.#e.get(e);if(void 0===n)throw new Error("Expecting model relation, none found");this.#i(e,n),this.#e.delete(e)}}set(e,n){this.#e.set(e,n);for(const t of Reflect.ownKeys(n))this.#r(t,n[t]).add(e)}#r(e,n){let t=this.#n[e].get(n);return void 0===t&&(t=new Set,this.#n[e].set(n,t)),t}#o(e,n){for(const[t,o]of e)n.set(t,o)}#i(e,n){for(const t of Reflect.ownKeys(n))this.#s(e,t,n[t])}#s(e,n,t){const o=this.#n[n].get(t);void 0!==o&&(o.delete(e),0===o.size&&this.#n[n].delete(t))}}var l,f,p;!function(e){e.moduleId="moduleId",e.serviceId="serviceId"}(l||(l={}));class g{#c;#a;constructor(e,n){this.#c=n??new d({moduleId:{isOptional:!0},serviceId:{isOptional:!1}}),this.#a=e}static build(e){return new g(e)}add(e,n){this.#c.set(e,n)}clone(){return new g(this.#a,this.#c.clone())}get(e){const n=[],t=this.#c.get(l.serviceId,e);void 0!==t&&n.push(t);const o=this.#a?.get(e);if(void 0!==o&&n.push(o),0!==n.length)return u(...n)}removeAllByModuleId(e){this.#c.removeByRelation(l.moduleId,e)}removeAllByServiceId(e){this.#c.removeByRelation(l.serviceId,e)}}!function(e){e.moduleId="moduleId",e.serviceId="serviceId"}(f||(f={}));class m{#u;#a;constructor(e,n){this.#u=n??new d({moduleId:{isOptional:!0},serviceId:{isOptional:!1}}),this.#a=e}static build(e){return new m(e)}clone(){return new m(this.#a,this.#u.clone())}get(e){return this.getNonParentBindings(e)??this.#a?.get(e)}getNonParentBindings(e){return this.#u.get(f.serviceId,e)}getNonParentBoundServices(){return this.#u.getAllKeys(f.serviceId)}getByModuleId(e){return this.#u.get(f.moduleId,e)??this.#a?.getByModuleId(e)}removeAllByModuleId(e){this.#u.removeByRelation(f.moduleId,e)}removeAllByServiceId(e){this.#u.removeByRelation(f.serviceId,e)}set(e){const n={[f.serviceId]:e.serviceIdentifier};void 0!==e.moduleId&&(n[f.moduleId]=e.moduleId),this.#u.set(e,n)}}!function(e){e.moduleId="moduleId",e.serviceId="serviceId"}(p||(p={}));class v{#d;#a;constructor(e,n){this.#d=n??new d({moduleId:{isOptional:!0},serviceId:{isOptional:!1}}),this.#a=e}static build(e){return new v(e)}add(e,n){this.#d.set(e,n)}clone(){return new v(this.#a,this.#d.clone())}get(e){const n=[],t=this.#d.get(p.serviceId,e);void 0!==t&&n.push(t);const o=this.#a?.get(e);if(void 0!==o&&n.push(o),0!==n.length)return u(...n)}removeAllByModuleId(e){this.#d.removeByRelation(p.moduleId,e)}removeAllByServiceId(e){this.#d.removeByRelation(p.serviceId,e)}}function h(e,n,t){const o=Array.isArray(e)?e:[e];if(void 0!==t)if("number"!=typeof t)Reflect.decorate(o,n.prototype,t);else for(const e of o)e(n,void 0,t);else Reflect.decorate(o,n)}const y="@inversifyjs/core/classMetadataReflectKey";function w(){return{constructorArguments:[],lifecycle:{postConstructMethodName:void 0,preDestroyMethodName:void 0},properties:new Map,scope:void 0}}const M="@inversifyjs/core/pendingClassMetadataCountReflectKey";const I=Symbol.for("@inversifyjs/core/InversifyCoreError");class b extends Error{[I];kind;constructor(e,n,t){super(n,t),this[I]=!0,this.kind=e}static is(e){return"object"==typeof e&&null!==e&&!0===e[I]}static isErrorOfKind(e,n){return b.is(e)&&e.kind===n}}var j,C,x;function $(n){const t=e(n,y)??w();if(!function(n){const t=e(n,M);return void 0!==t&&0!==t}(n))return function(e,n){const t=[];if(n.length<e.length)throw new b(j.missingInjectionDecorator,`Found unexpected missing metadata on type "${e.name}". "${e.name}" constructor requires at least ${e.length.toString()} arguments, found ${n.length.toString()} instead.\nAre you using @inject, @multiInject or @unmanaged decorators in every non optional constructor argument?\n\nIf you're using typescript and want to rely on auto injection, set "emitDecoratorMetadata" compiler option to true`);for(let e=0;e<n.length;++e)void 0===n[e]&&t.push(e);if(t.length>0)throw new b(j.missingInjectionDecorator,`Found unexpected missing metadata on type "${e.name}" at constructor indexes "${t.join('", "')}".\n\nAre you using @inject, @multiInject or @unmanaged decorators at those indexes?\n\nIf you're using typescript and want to rely on auto injection, set "emitDecoratorMetadata" compiler option to true`)}(n,t.constructorArguments),t;!function(e,n){const t=[];for(let o=0;o<n.constructorArguments.length;++o){const i=n.constructorArguments[o];void 0!==i&&i.kind!==C.unknown||t.push(` - Missing or incomplete metadata for type "${e.name}" at constructor argument with index ${o.toString()}.\nEvery constructor parameter must be decorated either with @inject, @multiInject or @unmanaged decorator.`)}for(const[o,i]of n.properties)i.kind===C.unknown&&t.push(` - Missing or incomplete metadata for type "${e.name}" at property "${o.toString()}".\nThis property must be decorated either with @inject or @multiInject decorator.`);if(0===t.length)throw new b(j.unknown,`Unexpected class metadata for type "${e.name}" with uncompletion traces.\nThis might be caused by one of the following reasons:\n\n1. A third party library is targeting inversify reflection metadata.\n2. A bug is causing the issue. Consider submiting an issue to fix it.`);throw new b(j.missingInjectionDecorator,`Invalid class metadata at type ${e.name}:\n\n${t.join("\n\n")}`)}(n,t)}function R(){return 0}function S(e){return t=>{void 0!==t&&t.kind===C.unknown&&n(e,M,R,(e=>e-1))}}function A(e,n){return(...t)=>o=>{if(void 0===o)return e(...t);if(o.kind===x.unmanaged)throw new b(j.injectionDecoratorConflict,"Unexpected injection found. Multiple @inject, @multiInject or @unmanaged decorators found");return n(o,...t)}}function T(e){if(e.kind!==C.unknown&&!0!==e.isFromTypescriptParamType)throw new b(j.injectionDecoratorConflict,"Unexpected injection found. Multiple @inject, @multiInject or @unmanaged decorators found")}!function(e){e[e.injectionDecoratorConflict=0]="injectionDecoratorConflict",e[e.missingInjectionDecorator=1]="missingInjectionDecorator",e[e.planning=2]="planning",e[e.resolution=3]="resolution",e[e.unknown=4]="unknown"}(j||(j={})),function(e){e[e.unknown=0]="unknown"}(C||(C={})),function(e){e[e.multipleInjection=0]="multipleInjection",e[e.singleInjection=1]="singleInjection",e[e.unmanaged=2]="unmanaged"}(x||(x={}));const D=A((function(e,n){return{kind:e,name:void 0,optional:!1,tags:new Map,value:n}}),(function(e,n,t){return T(e),{...e,kind:n,value:t}}));var k;function B(e,n,t,o){if(b.isErrorOfKind(o,j.injectionDecoratorConflict)){const i=function(e,n,t){if(void 0===t){if(void 0===n)throw new b(j.unknown,"Unexpected undefined property and index values");return{kind:k.property,property:n,targetClass:e.constructor}}return{index:t,kind:k.parameter,targetClass:e}}(e,n,t);throw new b(j.injectionDecoratorConflict,`Unexpected injection error.\n\nCause:\n\n${o.message}\n\nDetails\n\n${function(e){switch(e.kind){case k.parameter:return`[class: "${e.targetClass.name}", index: "${e.index.toString()}"]`;case k.property:return`[class: "${e.targetClass.name}", property: "${e.property.toString()}"]`}}(i)}`,{cause:o})}throw o}function P(e,t){return(o,i,r)=>{void 0===r?function(e,t){const o=F(e,t);return(e,t)=>{n(e.constructor,y,w,function(e,n){return t=>{const o=t.properties.get(n);return t.properties.set(n,e(o)),t}}(o(e),t))}}(e,t)(o,i):function(e,t){const o=F(e,t);return(e,t,i)=>{if(!function(e,n){return"function"==typeof e&&void 0===n}(e,t))throw new Error(`Found an @inject decorator in a non constructor parameter.\nFound @inject decorator at method "${t?.toString()??""}" at class "${e.constructor.name}"`);n(e,y,w,function(e,n){return t=>{const o=t.constructorArguments[n];return t.constructorArguments[n]=e(o),t}}(o(e),i))}}(e,t)(o,i,r)}}function F(e,n){return t=>{const o=n(t);return n=>(o(n),e(n))}}function N(e){const n=D(x.singleInjection,e);return(e,t,o)=>{try{void 0===o?P(n,S)(e,t):P(n,S)(e,t,o)}catch(n){B(e,t,o,n)}}}!function(e){e[e.parameter=0]="parameter",e[e.property=1]="property"}(k||(k={}));const E="@inversifyjs/core/classIsInjectableFlagReflectKey";const U=[Array,BigInt,Boolean,Function,Number,Object,String];function O(t){const o=e(t,"design:paramtypes");void 0!==o&&n(t,y,w,function(e){return n=>(e.forEach(((e,t)=>{var o;void 0!==n.constructorArguments[t]||(o=e,U.includes(o))||(n.constructorArguments[t]=function(e){return{isFromTypescriptParamType:!0,kind:x.singleInjection,name:void 0,optional:!1,tags:new Map,value:e}}(e))})),n)}(o))}function K(o){return i=>{!function(n){if(void 0!==e(n,E))throw new b(j.injectionDecoratorConflict,"Cannot apply @injectable decorator multiple times");t(n,E,!0)}(i),O(i),void 0!==o&&n(i,y,w,(e=>({...e,scope:o})))}}function q(e,n,t){let o;return e.extendConstructorArguments??!1?(o=[...n.constructorArguments],t.constructorArguments.map(((e,n)=>{o[n]=e}))):o=t.constructorArguments,o}function V(e,n,t){let o;return o=e.extendProperties??!1?new Map(u(n.properties,t.properties)):t.properties,o}function z(e){return t=>{const o=$(e.type);n(t,y,w,function(e,n){const t=t=>({constructorArguments:q(e,n,t),lifecycle:t.lifecycle,properties:V(e,n,t),scope:t.scope});return t}(e,o))}}function G(e){return n=>{const t=o(n);if(void 0===t)throw new b(j.injectionDecoratorConflict,`Expected base type for type "${n.name}", none found.`);z({...e,type:t})(n)}}function H(e){const n=D(x.multipleInjection,e);return(e,t,o)=>{try{void 0===o?P(n,S)(e,t):P(n,S)(e,t,o)}catch(n){B(e,t,o,n)}}}function J(e){return t=>{void 0===t&&n(e,M,R,(e=>e+1))}}function L(e){return n=>{const t=n??{kind:C.unknown,name:void 0,optional:!1,tags:new Map};if(t.kind===x.unmanaged)throw new b(j.injectionDecoratorConflict,"Unexpected injection found. Found @unmanaged injection with additional @named, @optional, @tagged or @targetName injections");return e(t)}}function Q(e){const n=L(function(e){return n=>{if(void 0!==n.name)throw new b(j.injectionDecoratorConflict,"Unexpected duplicated named decorator");return n.name=e,n}}(e));return(e,t,o)=>{try{void 0===o?P(n,J)(e,t):P(n,J)(e,t,o)}catch(n){B(e,t,o,n)}}}function W(e){if(e.optional)throw new b(j.injectionDecoratorConflict,"Unexpected duplicated optional decorator");return e.optional=!0,e}function X(){const e=L(W);return(n,t,o)=>{try{void 0===o?P(e,J)(n,t):P(e,J)(n,t,o)}catch(e){B(n,t,o,e)}}}function Y(){return(e,t,o)=>{try{n(e.constructor,y,w,(i=t,e=>{if(void 0!==e.lifecycle.postConstructMethodName)throw new b(j.injectionDecoratorConflict,"Unexpected duplicated postConstruct decorator");return e.lifecycle.postConstructMethodName=i,e}))}catch(n){B(e,t,void 0,n)}var i}}function Z(){return(e,t,o)=>{try{n(e.constructor,y,w,(i=t,e=>{if(void 0!==e.lifecycle.preDestroyMethodName)throw new b(j.injectionDecoratorConflict,"Unexpected duplicated preDestroy decorator");return e.lifecycle.preDestroyMethodName=i,e}))}catch(n){B(e,t,void 0,n)}var i}}function _(e,n){const t=L(function(e,n){return t=>{if(t.tags.has(e))throw new b(j.injectionDecoratorConflict,"Unexpected duplicated tag decorator with existing tag");return t.tags.set(e,n),t}}(e,n));return(e,n,o)=>{try{void 0===o?P(t,J)(e,n):P(t,J)(e,n,o)}catch(t){B(e,n,o,t)}}}function ee(){return{kind:x.unmanaged}}const ne=A(ee,(function(e){if(T(e),function(e){return void 0!==e.name||e.optional||e.tags.size>0}(e))throw new b(j.injectionDecoratorConflict,"Unexpected injection found. Found @unmanaged injection with additional @named, @optional, @tagged or @targetName injections");return ee()}));function te(){const e=ne();return(n,t,o)=>{try{void 0===o?P(e,S)(n,t):P(e,S)(n,t,o)}catch(e){B(n,t,o,e)}}}class oe{last;constructor(e){this.last=e}concat(e){return new oe({elem:e,previous:this.last})}[Symbol.iterator](){let e=this.last;return{next:()=>{if(void 0===e)return{done:!0,value:void 0};const n=e.elem;return e=e.previous,{done:!1,value:n}}}}}function ie(e,n){e.servicesBranch.has(n)&&function(e,n){const t=(o=[...e.servicesBranch,n],[...o].map(i).join(" -> "));var o;throw new b(j.planning,`Circular dependency found: ${t}`)}(e,n),e.servicesBranch.add(n)}class re{#l;constructor(e){this.#l=e}get name(){return this.#l.elem.name}get tags(){return this.#l.elem.tags}get serviceIdentifier(){return this.#l.elem.serviceIdentifier}getAncestor(){if(void 0!==this.#l.previous)return new re(this.#l.previous)}}function se(e,n,t){const o=new re(n.last),i=t?.customServiceIdentifier??o.serviceIdentifier;return[...e.getBindings(i)??[]].filter((e=>e.isSatisfiedBy(o)))}function ce(e){return void 0!==e.redirections}function ae(e,n,t){let o,r;ce(t)?(o=t.binding.targetServiceIdentifier,r=t.binding.serviceIdentifier):(o=t.serviceIdentifier,r=t.parent?.binding.serviceIdentifier),Array.isArray(e)?function(e,n,t,o){if(0!==e.length){const n=`Ambiguous bindings found for service: "${i(t)}".\n\nRegistered bindings:\n\n${e.map((e=>function(e){switch(e.type){case a.Instance:return`[ type: "${e.type}", serviceIdentifier: "${i(e.serviceIdentifier)}", scope: "${e.scope}", implementationType: "${e.implementationType.name}" ]`;case a.ServiceRedirection:return`[ type: "${e.type}", serviceIdentifier: "${i(e.serviceIdentifier)}", redirection: "${i(e.targetServiceIdentifier)}" ]`;default:return`[ type: "${e.type}", serviceIdentifier: "${i(e.serviceIdentifier)}", scope: "${e.scope}" ]`}}(e.binding))).join("\n")}\n\nTrying to resolve bindings for "${de(t,o)}".`;throw new b(j.planning,n)}n||ue(t,o)}(e,n,o,r):function(e,n,t,o){if(void 0!==e||n)return;ue(t,o)}(e,n,o,r)}function ue(e,n){const t=`No bindings found for service: "${i(e)}".\n\nTrying to resolve bindings for "${de(e,n)}".`;throw new b(j.planning,t)}function de(e,n){return void 0===n?`${i(e)} (Root service)`:i(n)}function le(e,n){if(1!==e.redirections.length)ae(e.redirections,n,e);else{const[t]=e.redirections;ce(t)&&le(t,n)}}function fe(e,n){if(Array.isArray(e.bindings)&&1===e.bindings.length){const[t]=e.bindings;ce(t)&&le(t,n)}else ae(e.bindings,n,e)}function pe(e){const n=new Map;void 0!==e.rootConstraints.tag&&n.set(e.rootConstraints.tag.key,e.rootConstraints.tag.value);const t=new oe({elem:{name:e.rootConstraints.name,serviceIdentifier:e.rootConstraints.serviceIdentifier,tags:n},previous:void 0}),o=se(e,t),i=[],r={bindings:i,parent:void 0,serviceIdentifier:e.rootConstraints.serviceIdentifier};if(i.push(...ve(e,t,o,r)),!e.rootConstraints.isMultiple){fe(r,e.rootConstraints.isOptional??!1);const[n]=i;r.bindings=n}return{tree:{root:r}}}function ge(e,n,t,o){const i={binding:n,classMetadata:e.getClassMetadata(n.implementationType),constructorParams:[],parent:o,propertyParams:new Map};return function(e,n){const t=e.node.classMetadata;for(const[o,i]of t.constructorArguments.entries())e.node.constructorParams[o]=me(e,n,i);for(const[o,i]of t.properties){const t=me(e,n,i);void 0!==t&&e.node.propertyParams.set(o,t)}return e.node}({getBindings:e.getBindings,getClassMetadata:e.getClassMetadata,node:i,servicesBranch:e.servicesBranch},t)}function me(e,n,t){if(t.kind===x.unmanaged)return;const o=r.is(t.value)?t.value.unwrap():t.value,i=n.concat({name:t.name,serviceIdentifier:o,tags:t.tags}),s=se(e,i),c=[],a={bindings:c,parent:e.node,serviceIdentifier:o};if(c.push(...ve(e,i,s,a)),t.kind===x.singleInjection){fe(a,t.optional);const[e]=c;a.bindings=e}return a}function ve(e,n,t,o){const i=ce(o)?o.binding.targetServiceIdentifier:o.serviceIdentifier;ie(e,i);const r=[];for(const i of t)switch(i.type){case a.Instance:r.push(ge(e,i,n,o));break;case a.ServiceRedirection:{const t=he(e,n,i,o);r.push(t);break}default:r.push({binding:i,parent:o})}return e.servicesBranch.delete(i),r}function he(e,n,t,o){const i={binding:t,parent:o,redirections:[]},r=se(e,n,{customServiceIdentifier:t.targetServiceIdentifier});return i.redirections.push(...ve(e,n,r,i)),i}function ye(e,n,t){const o=e.getActivations(n);return void 0===o?t:s(t)?we(e,t,o[Symbol.iterator]()):function(e,n,t){let o=n,i=t.next();for(;!0!==i.done;){const n=i.value(e.context,o);if(s(n))return we(e,n,t);o=n,i=t.next()}return o}(e,t,o[Symbol.iterator]())}async function we(e,n,t){let o=await n,i=t.next();for(;!0!==i.done;)o=await i.value(e.context,o),i=t.next();return o}function Me(e,n,t){let o=t;if(void 0!==n.onActivation){const t=n.onActivation;o=s(o)?o.then((n=>t(e.context,n))):t(e.context,o)}return ye(e,n.serviceIdentifier,o)}function Ie(e){return(n,t)=>{if(t.cache.isRight)return t.cache.value;const o=Me(n,t,e(n,t));return t.cache={isRight:!0,value:o},o}}const be=Ie((function(e,n){return n.value}));function je(e){return e}function Ce(e,n){return(t,o)=>{const i=e(o);switch(i.scope){case c.Singleton:{if(i.cache.isRight)return i.cache.value;const e=xe(t,o,i,n);return i.cache={isRight:!0,value:e},e}case c.Request:{if(t.requestScopeCache.has(i.id))return t.requestScopeCache.get(i.id);const e=xe(t,o,i,n);return t.requestScopeCache.set(i.id,e),e}case c.Transient:return xe(t,o,i,n)}}}function xe(e,n,t,o){return Me(e,t,o(e,n))}const $e=(e=>Ce(je,e))((function(e,n){return n.value(e.context)}));const Re=Ie((function(e,n){return n.factory(e.context)}));function Se(e,n,t){const o=function(e,n,t){if(void 0===t)return;if(!(t in e))throw new b(j.resolution,`Expecting a "${t.toString()}" property when resolving "${n.implementationType.name}" class @postConstruct decorated method, none found.`);if("function"!=typeof e[t])throw new b(j.resolution,`Expecting a "${t.toString()}" method when resolving "${n.implementationType.name}" class @postConstruct decorated method, a non function property was found instead.`);{let o;try{o=e[t]()}catch(e){throw new b(j.resolution,`Unexpected error found when calling "${t.toString()}" @postConstruct decorated method on class "${n.implementationType.name}"`,{cause:e})}if(s(o))return async function(e,n,t){try{await t}catch(t){throw new b(j.resolution,`Unexpected error found when calling "${n.toString()}" @postConstruct decorated method on class "${e.implementationType.name}"`,{cause:t})}}(n,t,o)}}(e,n,t);return s(o)?o.then((()=>e)):e}function Ae(e){return(n,t,o)=>{const i=new o.binding.implementationType(...n),r=e(t,i,o);return s(r)?r.then((()=>Se(i,o.binding,o.classMetadata.lifecycle.postConstructMethodName))):Se(i,o.binding,o.classMetadata.lifecycle.postConstructMethodName)}}const Te=Ie((function(e,n){return n.provider(e.context)}));function De(e){return e.binding}const ke=function(e){return(n,t,o)=>{const i=[];for(const[r,c]of o.propertyParams){const a=o.classMetadata.properties.get(r);if(void 0===a)throw new b(j.resolution,`Expecting metadata at property "${r.toString()}", none found`);a.kind!==x.unmanaged&&(t[r]=e(n,c),s(t[r])&&i.push((async()=>{t[r]=await t[r]})()))}if(i.length>0)return Promise.all(i).then((()=>{}))}}(Ue),Be=function(e){return function n(t,o){const i=[];for(const r of o.redirections)ce(r)?i.push(...n(t,r)):i.push(e(t,r));return i}}(Ee),Pe=function(e,n,t){return(o,i)=>{const r=e(o,i);return s(r)?n(r,o,i):t(r,o,i)}}(function(e){return(n,t)=>{const o=[];for(const i of t.constructorParams)void 0===i?o.push(void 0):o.push(e(n,i));return o.some(s)?Promise.all(o):o}}(Ue),function(e){return async(n,t,o)=>{const i=await n;return e(i,t,o)}}(Ae(ke)),Ae(ke)),Fe=(e=>Ce(De,e))(Pe);function Ne(e){return Ue(e,e.planResult.tree.root)}function Ee(e,n){switch(n.binding.type){case a.ConstantValue:return be(e,n.binding);case a.DynamicValue:return $e(e,n.binding);case a.Factory:return Re(e,n.binding);case a.Instance:return Fe(e,n);case a.Provider:return Te(e,n.binding)}}function Ue(e,n){if(void 0!==n.bindings)return Array.isArray(n.bindings)?function(e,n){const t=[];for(const o of n)ce(o)?t.push(...Be(e,o)):t.push(Ee(e,o));if(t.some(s))return Promise.all(t);return t}(e,n.bindings):function(e,n){if(ce(n)){const t=Be(e,n);if(1===t.length)return t[0];throw new b(j.resolution,"Unexpected multiple resolved values on single injection")}return Ee(e,n)}(e,n.bindings)}function Oe(e){return void 0!==e.scope}function Ke(e,n){if(void 0!==e.lifecycle.preDestroyMethodName&&"function"==typeof n[e.lifecycle.preDestroyMethodName])return n[e.lifecycle.preDestroyMethodName]()}function qe(e,n,t){const o=e.getDeactivations(n);if(void 0!==o)return s(t)?Ve(t,o[Symbol.iterator]()):function(e,n){let t=n.next();for(;!0!==t.done;){const o=t.value(e);if(s(o))return Ve(e,n);t=n.next()}}(t,o[Symbol.iterator]())}async function Ve(e,n){const t=await e;let o=n.next();for(;!0!==o.done;)await o.value(t),o=n.next()}function ze(e,n){const t=function(e,n){if(n.type===a.Instance){const t=e.getClassMetadata(n.implementationType),o=n.cache.value;return s(o)?o.then((e=>Ke(t,e))):Ke(t,o)}}(e,n);return void 0===t?Ge(e,n):t.then((()=>Ge(e,n)))}function Ge(e,n){const t=n.cache;return s(t.value)?t.value.then((t=>He(e,n,t))):He(e,n,t.value)}function He(e,n,t){let o;if(void 0!==n.onDeactivation){o=(0,n.onDeactivation)(t)}return void 0===o?qe(e,n.serviceIdentifier,t):o.then((()=>qe(e,n.serviceIdentifier,t)))}function Je(e,n){if(void 0===n)return;const t=function(e){const n=[];for(const t of e)Oe(t)&&t.scope===c.Singleton&&t.cache.isRight&&n.push(t);return n}(n),o=[];for(const n of t){const t=ze(e,n);void 0!==t&&o.push(t)}return o.length>0?Promise.all(o).then((()=>{})):void 0}function Le(e,n){const t=e.getBindingsFromModule(n);return Je(e,t)}function Qe(e,n){const t=e.getBindings(n);return Je(e,t)}export{g as ActivationsService,m as BindingService,x as ClassElementMetadataKind,v as DeactivationsService,c as bindingScopeValues,a as bindingTypeValues,h as decorate,$ as getClassMetadata,N as inject,G as injectFromBase,K as injectable,H as multiInject,Q as named,X as optional,pe as plan,Y as postConstruct,Z as preDestroy,Ne as resolve,Le as resolveModuleDeactivations,Qe as resolveServiceDeactivations,_ as tagged,te as unmanaged};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|