@tsed/di 8.28.2 → 8.28.5
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.
|
@@ -68,13 +68,17 @@ export class Container extends Map {
|
|
|
68
68
|
* @returns {[TokenProvider , Provider<any>][]}
|
|
69
69
|
*/
|
|
70
70
|
getProviders(type) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
if (!type) {
|
|
72
|
+
return [...this.values()];
|
|
73
|
+
}
|
|
74
|
+
const types = new Set([].concat(type).map(String));
|
|
75
|
+
const providers = [];
|
|
76
|
+
for (const [, provider] of this) {
|
|
77
|
+
if (types.has(String(provider.type))) {
|
|
78
|
+
providers.push(provider);
|
|
75
79
|
}
|
|
76
|
-
|
|
77
|
-
|
|
80
|
+
}
|
|
81
|
+
return providers;
|
|
78
82
|
}
|
|
79
83
|
addProviders(container) {
|
|
80
84
|
container.forEach((provider) => {
|
|
@@ -91,10 +91,11 @@ export class InjectorService extends Container {
|
|
|
91
91
|
* @returns The resolved provider instance
|
|
92
92
|
*/
|
|
93
93
|
get(token, options) {
|
|
94
|
-
|
|
94
|
+
const instance = this.#cache.get(token);
|
|
95
|
+
if (instance === undefined) {
|
|
95
96
|
return this.resolve(token, options);
|
|
96
97
|
}
|
|
97
|
-
return
|
|
98
|
+
return instance;
|
|
98
99
|
}
|
|
99
100
|
/**
|
|
100
101
|
* Return all instances of providers matching the specified type.
|
|
@@ -427,37 +428,39 @@ export class InjectorService extends Container {
|
|
|
427
428
|
return instance;
|
|
428
429
|
}
|
|
429
430
|
resolveImportsProviders() {
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
}
|
|
452
|
-
if ("use" in props) {
|
|
453
|
-
provider.useValue = props.use;
|
|
454
|
-
return;
|
|
455
|
-
}
|
|
456
|
-
}
|
|
431
|
+
const imports = this.settings.imports;
|
|
432
|
+
if (!imports) {
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
const resolvedImports = [];
|
|
436
|
+
for (const meta of imports) {
|
|
437
|
+
if (!isObject(meta) || !("token" in meta) || meta.token === InjectorService) {
|
|
438
|
+
continue;
|
|
439
|
+
}
|
|
440
|
+
const { token, ...props } = meta;
|
|
441
|
+
const provider = this.ensureProvider(token, true);
|
|
442
|
+
provider.useValue = undefined;
|
|
443
|
+
provider.useAsyncFactory = undefined;
|
|
444
|
+
provider.useFactory = undefined;
|
|
445
|
+
if ("useClass" in props) {
|
|
446
|
+
provider.useClass = props.useClass;
|
|
447
|
+
continue;
|
|
448
|
+
}
|
|
449
|
+
if ("useFactory" in props) {
|
|
450
|
+
provider.useFactory = props.useFactory;
|
|
451
|
+
continue;
|
|
457
452
|
}
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
453
|
+
if ("useAsyncFactory" in props) {
|
|
454
|
+
provider.useAsyncFactory = props.useAsyncFactory;
|
|
455
|
+
continue;
|
|
456
|
+
}
|
|
457
|
+
if ("use" in props) {
|
|
458
|
+
provider.useValue = props.use;
|
|
459
|
+
continue;
|
|
460
|
+
}
|
|
461
|
+
resolvedImports.push(meta);
|
|
462
|
+
}
|
|
463
|
+
this.settings.imports = resolvedImports;
|
|
461
464
|
}
|
|
462
465
|
/**
|
|
463
466
|
* Create options to invoke a provider or class.
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@tsed/di",
|
|
3
3
|
"description": "DI module for Ts.ED Framework",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "8.28.
|
|
5
|
+
"version": "8.28.5",
|
|
6
6
|
"source": "./src/index.ts",
|
|
7
7
|
"main": "./lib/esm/index.js",
|
|
8
8
|
"module": "./lib/esm/index.js",
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
"uuid": "^10.0.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@tsed/barrels": "8.28.
|
|
33
|
-
"@tsed/core": "8.28.
|
|
34
|
-
"@tsed/hooks": "8.28.
|
|
32
|
+
"@tsed/barrels": "8.28.5",
|
|
33
|
+
"@tsed/core": "8.28.5",
|
|
34
|
+
"@tsed/hooks": "8.28.5",
|
|
35
35
|
"@tsed/logger": "^8.0.0",
|
|
36
|
-
"@tsed/typescript": "8.28.
|
|
36
|
+
"@tsed/typescript": "8.28.5",
|
|
37
37
|
"cross-env": "7.0.3",
|
|
38
38
|
"eslint": "9.12.0",
|
|
39
39
|
"typescript": "6.0.2",
|