@tstdl/base 0.93.23 → 0.93.24
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/injector/injector.d.ts
CHANGED
|
@@ -36,7 +36,9 @@ export type ResolveManyReturnType<T extends ResolveManyItem<any, any>[]> = {
|
|
|
36
36
|
export type AddDisposeHandler = (handler: Disposable | AsyncDisposable | (() => any)) => void;
|
|
37
37
|
export declare class Injector implements AsyncDisposable {
|
|
38
38
|
#private;
|
|
39
|
+
readonly id: number;
|
|
39
40
|
readonly name: string;
|
|
41
|
+
readonly nameWithId: string;
|
|
40
42
|
get disposed(): boolean;
|
|
41
43
|
constructor(name: string, parent?: Injector | null);
|
|
42
44
|
/**
|
package/injector/injector.js
CHANGED
|
@@ -18,6 +18,7 @@ import { ResolveChain } from './resolve-chain.js';
|
|
|
18
18
|
import { ResolveError } from './resolve.error.js';
|
|
19
19
|
import { injectMetadataSymbol, injectableMetadataSymbol } from './symbols.js';
|
|
20
20
|
import { getTokenName } from './token.js';
|
|
21
|
+
let _id = 1;
|
|
21
22
|
export class Injector {
|
|
22
23
|
static #globalRegistrations = new Map();
|
|
23
24
|
#parent;
|
|
@@ -28,12 +29,15 @@ export class Injector {
|
|
|
28
29
|
#registrations = new Map();
|
|
29
30
|
#injectorScopedResolutions = new MultiKeyMap();
|
|
30
31
|
#addDisposeHandler;
|
|
32
|
+
id = _id++;
|
|
31
33
|
name;
|
|
34
|
+
nameWithId;
|
|
32
35
|
get disposed() {
|
|
33
36
|
return this.#disposableStack.disposed;
|
|
34
37
|
}
|
|
35
38
|
constructor(name, parent = null) {
|
|
36
39
|
this.name = name;
|
|
40
|
+
this.nameWithId = `${name}#${this.id}`;
|
|
37
41
|
this.#parent = parent;
|
|
38
42
|
this.register(Injector, { useValue: this });
|
|
39
43
|
this.register(CancellationSignal, { useValue: this.#disposeToken.signal });
|
|
@@ -6,7 +6,9 @@ export type ResolveChainNodeBase<Type extends string> = {
|
|
|
6
6
|
type: Type;
|
|
7
7
|
forwardRef?: true;
|
|
8
8
|
};
|
|
9
|
-
export type ResolveChainNode =
|
|
9
|
+
export type ResolveChainNode = {
|
|
10
|
+
type: 'ellipsis';
|
|
11
|
+
} | ResolveChainNodeBase<'token'> & {
|
|
10
12
|
token: InjectionToken;
|
|
11
13
|
} | ResolveChainNodeBase<'inject'> & {
|
|
12
14
|
token: InjectionToken;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { reflectionRegistry } from '../reflection/index.js';
|
|
2
2
|
import { assertDefinedPass, isDefined } from '../utils/type-guards.js';
|
|
3
|
+
import { start } from 'repl';
|
|
3
4
|
import { getTokenName } from './token.js';
|
|
4
5
|
export class ResolveChain {
|
|
5
6
|
nodes;
|
|
@@ -41,8 +42,12 @@ export class ResolveChain {
|
|
|
41
42
|
if (chain.length < this.length) {
|
|
42
43
|
chainString += '\n [...]';
|
|
43
44
|
}
|
|
44
|
-
const longestInjectorName = Math.max(...chain.nodes.map((node) => node.injector.
|
|
45
|
+
const longestInjectorName = Math.max(...chain.nodes.map((node) => (node.type == 'ellipsis') ? 0 : node.injector.nameWithId.length));
|
|
45
46
|
for (const node of chain.nodes) {
|
|
47
|
+
if (node.type == 'ellipsis') {
|
|
48
|
+
chainString += `\n ${'[...]'.padStart(longestInjectorName)}`;
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
46
51
|
const paddedInjectorName = node.injector.name.padStart(longestInjectorName);
|
|
47
52
|
const tokenName = getTokenName(node.token);
|
|
48
53
|
const forwardRefPrefix = node.forwardRef ? 'ForwardRef::' : '';
|
|
@@ -74,16 +79,29 @@ export class ResolveChain {
|
|
|
74
79
|
return chainString;
|
|
75
80
|
}
|
|
76
81
|
truncate(tokenCount) {
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
82
|
+
const startOfChain = [];
|
|
83
|
+
const endOfChain = [];
|
|
84
|
+
let startCounter = 0;
|
|
85
|
+
let index = 0;
|
|
86
|
+
for (index = 0; (index < this.nodes.length) && (startCounter < tokenCount); index++) {
|
|
87
|
+
const node = this.nodes[index];
|
|
88
|
+
startOfChain.push(node);
|
|
89
|
+
if (node.type == 'token') {
|
|
90
|
+
startCounter++;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
let endCounter = 0;
|
|
94
|
+
for (let i = this.nodes.length - 1; (i > index) && (endCounter < tokenCount); i--) {
|
|
80
95
|
const node = this.nodes[i];
|
|
81
|
-
|
|
96
|
+
endOfChain.unshift(node);
|
|
82
97
|
if (node.type == 'token') {
|
|
83
|
-
|
|
98
|
+
endCounter++;
|
|
84
99
|
}
|
|
85
100
|
}
|
|
86
|
-
|
|
101
|
+
if (endOfChain.length > 0) {
|
|
102
|
+
startOfChain.push({ type: 'ellipsis' });
|
|
103
|
+
}
|
|
104
|
+
return new ResolveChain([...startOfChain, ...endOfChain]);
|
|
87
105
|
}
|
|
88
106
|
}
|
|
89
107
|
function getPropertyKeyString(key) {
|