@nmtjs/core 0.14.0 → 0.14.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/container.js +4 -3
- package/dist/injectables.d.ts +2 -0
- package/package.json +5 -5
package/dist/container.js
CHANGED
|
@@ -181,9 +181,10 @@ export class Container {
|
|
|
181
181
|
wrapper.public = injectable.pick(wrapper.private);
|
|
182
182
|
}
|
|
183
183
|
else if (isClassInjectable(injectable)) {
|
|
184
|
-
|
|
184
|
+
const instance = new injectable(context);
|
|
185
|
+
wrapper.private = instance;
|
|
185
186
|
wrapper.public = wrapper.private;
|
|
186
|
-
await
|
|
187
|
+
await instance[kClassInjectableCreate]?.call(instance);
|
|
187
188
|
}
|
|
188
189
|
else {
|
|
189
190
|
throw new Error('Invalid injectable type');
|
|
@@ -302,7 +303,7 @@ export class Container {
|
|
|
302
303
|
await dispose(instance, context);
|
|
303
304
|
}
|
|
304
305
|
else if (isClassInjectable(injectable)) {
|
|
305
|
-
await instance[kClassInjectableDispose]();
|
|
306
|
+
await instance[kClassInjectableDispose]?.();
|
|
306
307
|
}
|
|
307
308
|
}
|
|
308
309
|
}
|
package/dist/injectables.d.ts
CHANGED
|
@@ -55,6 +55,8 @@ export interface BaseClassInjectable<T, D extends Dependencies = {}, S extends S
|
|
|
55
55
|
export interface ClassInjectable<T, D extends Dependencies = {}, S extends Scope = Scope.Global, A extends any[] = []> extends Dependant<D> {
|
|
56
56
|
new ($context: DependencyContext<D>, ...args: A): T & {
|
|
57
57
|
$context: DependencyContext<D>;
|
|
58
|
+
[kClassInjectableCreate]?: () => Promise<void>;
|
|
59
|
+
[kClassInjectableDispose]?: () => Promise<void>;
|
|
58
60
|
};
|
|
59
61
|
scope: S;
|
|
60
62
|
[kInjectable]: any;
|
package/package.json
CHANGED
|
@@ -16,22 +16,22 @@
|
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"pino": "^9.6.0",
|
|
18
18
|
"pino-pretty": "^13.0.0",
|
|
19
|
-
"@nmtjs/
|
|
20
|
-
"@nmtjs/
|
|
19
|
+
"@nmtjs/type": "0.14.2",
|
|
20
|
+
"@nmtjs/common": "0.14.2"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@types/node": "^20",
|
|
24
24
|
"pino": "^9.6.0",
|
|
25
25
|
"pino-pretty": "^13.0.0",
|
|
26
|
-
"@nmtjs/common": "0.14.
|
|
27
|
-
"@nmtjs/type": "0.14.
|
|
26
|
+
"@nmtjs/common": "0.14.2",
|
|
27
|
+
"@nmtjs/type": "0.14.2"
|
|
28
28
|
},
|
|
29
29
|
"files": [
|
|
30
30
|
"dist",
|
|
31
31
|
"LICENSE.md",
|
|
32
32
|
"README.md"
|
|
33
33
|
],
|
|
34
|
-
"version": "0.14.
|
|
34
|
+
"version": "0.14.2",
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build": "tsc",
|
|
37
37
|
"type-check": "tsc --noEmit"
|