@codefast/di 0.3.14-canary.1 → 0.3.14
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 +58 -0
- package/README.md +42 -26
- package/dist/binding-scope.d.mts +11 -0
- package/dist/binding-scope.mjs +19 -0
- package/dist/binding-select.d.mts +8 -26
- package/dist/binding-select.mjs +56 -49
- package/dist/binding.d.mts +107 -335
- package/dist/binding.mjs +19 -332
- package/dist/constraints.d.mts +11 -29
- package/dist/constraints.mjs +32 -36
- package/dist/constructor-type.d.mts +17 -0
- package/dist/constructor-type.mjs +1 -0
- package/dist/container.d.mts +43 -122
- package/dist/container.mjs +667 -482
- package/dist/decorators/inject.d.mts +19 -50
- package/dist/decorators/inject.mjs +131 -93
- package/dist/decorators/injectable.d.mts +16 -37
- package/dist/decorators/injectable.mjs +47 -66
- package/dist/decorators/lifecycle-decorators.d.mts +2 -22
- package/dist/decorators/lifecycle-decorators.mjs +81 -37
- package/dist/dependency-graph.d.mts +24 -54
- package/dist/dependency-graph.mjs +51 -153
- package/dist/environment.d.mts +38 -12
- package/dist/environment.mjs +82 -16
- package/dist/errors.d.mts +70 -189
- package/dist/errors.mjs +92 -219
- package/dist/graph-adapters/cytoscape.d.mts +21 -7
- package/dist/graph-adapters/cytoscape.mjs +18 -35
- package/dist/graph-adapters/dot.d.mts +1 -4
- package/dist/graph-adapters/dot.mjs +6 -86
- package/dist/graph-adapters/reactflow.d.mts +26 -7
- package/dist/graph-adapters/reactflow.mjs +21 -72
- package/dist/graph-adapters/types.d.mts +2 -91
- package/dist/index.d.mts +16 -8
- package/dist/index.mjs +8 -5
- package/dist/inspector.d.mts +35 -74
- package/dist/inspector.mjs +61 -88
- package/dist/lifecycle.d.mts +20 -53
- package/dist/lifecycle.mjs +129 -99
- package/dist/metadata/metadata-keys.d.mts +9 -26
- package/dist/metadata/metadata-keys.mjs +7 -28
- package/dist/metadata/metadata-reader-token.d.mts +7 -0
- package/dist/metadata/metadata-reader-token.mjs +5 -0
- package/dist/metadata/metadata-types.d.mts +26 -75
- package/dist/metadata/symbol-metadata-reader.d.mts +10 -26
- package/dist/metadata/symbol-metadata-reader.mjs +32 -45
- package/dist/module.d.mts +30 -96
- package/dist/module.mjs +26 -72
- package/dist/registry.d.mts +32 -63
- package/dist/registry.mjs +131 -82
- package/dist/resolve-options.d.mts +18 -0
- package/dist/resolve-options.mjs +22 -0
- package/dist/resolver.d.mts +67 -190
- package/dist/resolver.mjs +715 -424
- package/dist/scope.d.mts +19 -106
- package/dist/scope.mjs +37 -196
- package/dist/token.d.mts +8 -22
- package/dist/token.mjs +9 -11
- package/dist/types.d.mts +48 -0
- package/dist/types.mjs +1 -0
- package/package.json +36 -14
- package/dist/metadata/param-registry.d.mts +0 -16
- package/dist/metadata/param-registry.mjs +0 -31
- package/dist/scope-validation.d.mts +0 -21
- package/dist/scope-validation.mjs +0 -35
|
@@ -1,40 +1,23 @@
|
|
|
1
1
|
//#region src/graph-adapters/cytoscape.ts
|
|
2
|
-
/**
|
|
3
|
-
* Converts the canonical container graph JSON into Cytoscape elements format.
|
|
4
|
-
*/
|
|
5
2
|
function toCytoscapeGraph(graph) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
isAliasEdge: edge.isAliasEdge,
|
|
25
|
-
resolutionPath: [...edge.resolutionPath]
|
|
26
|
-
} }))
|
|
27
|
-
} };
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Produces a stable Cytoscape edge id from edge metadata.
|
|
31
|
-
*/
|
|
32
|
-
function edgeIdForCytoscape(edge) {
|
|
33
|
-
const hint = edge.injectHintLabel ?? "";
|
|
34
|
-
const conditional = edge.toBindingConditional ? "conditional" : "plain";
|
|
35
|
-
const alias = edge.isAliasEdge ? "alias" : "direct";
|
|
36
|
-
const path = edge.resolutionPath.join("->");
|
|
37
|
-
return `${edge.fromBindingId}->${edge.toBindingId}:${edge.edgeKind}:${hint}:${conditional}:${alias}:${path}`;
|
|
3
|
+
const elements = [];
|
|
4
|
+
for (const node of graph.nodes) elements.push({ data: {
|
|
5
|
+
id: node.id,
|
|
6
|
+
label: node.tokenName,
|
|
7
|
+
kind: node.kind,
|
|
8
|
+
scope: node.scope,
|
|
9
|
+
fromParent: node.fromParent
|
|
10
|
+
} });
|
|
11
|
+
graph.edges.forEach((edge, idx) => {
|
|
12
|
+
const data = {
|
|
13
|
+
id: `edge-${idx}`,
|
|
14
|
+
source: edge.from,
|
|
15
|
+
target: edge.to
|
|
16
|
+
};
|
|
17
|
+
if (edge.label !== void 0) data.label = edge.label;
|
|
18
|
+
elements.push({ data });
|
|
19
|
+
});
|
|
20
|
+
return elements;
|
|
38
21
|
}
|
|
39
22
|
//#endregion
|
|
40
23
|
export { toCytoscapeGraph };
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import { ContainerGraphJson } from "../
|
|
1
|
+
import { ContainerGraphJson } from "../dependency-graph.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/graph-adapters/dot.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* Converts the canonical container graph JSON into a Graphviz DOT digraph string.
|
|
6
|
-
*/
|
|
7
4
|
declare function toDotGraph(graph: ContainerGraphJson): string;
|
|
8
5
|
//#endregion
|
|
9
6
|
export { toDotGraph };
|
|
@@ -1,97 +1,17 @@
|
|
|
1
1
|
//#region src/graph-adapters/dot.ts
|
|
2
|
-
/**
|
|
3
|
-
* Converts the canonical container graph JSON into a Graphviz DOT digraph string.
|
|
4
|
-
*/
|
|
5
2
|
function toDotGraph(graph) {
|
|
6
|
-
const lines = [
|
|
7
|
-
"digraph codefast_di {",
|
|
8
|
-
" rankdir=LR;",
|
|
9
|
-
" graph [fontname=\"Arial\", fontsize=12, nodesep=0.8, ranksep=1.2];",
|
|
10
|
-
" node [fontname=\"Arial\", fontsize=12, shape=box, style=\"filled,rounded\", fillcolor=\"#F5F5F5\"];",
|
|
11
|
-
" edge [fontname=\"Arial\", fontsize=10];"
|
|
12
|
-
];
|
|
13
|
-
const byModule = /* @__PURE__ */ new Map();
|
|
3
|
+
const lines = ["digraph DI {", " rankdir=TB;"];
|
|
14
4
|
for (const node of graph.nodes) {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
5
|
+
const label = `${node.tokenName}\\n[${node.kind}/${node.scope}]`;
|
|
6
|
+
const style = node.fromParent ? " style=\"dashed\"" : "";
|
|
7
|
+
lines.push(` "${node.id}" [label="${label}"${style}];`);
|
|
18
8
|
}
|
|
19
|
-
const moduleGroups = [...byModule.entries()].filter((entry) => entry[0] !== void 0);
|
|
20
|
-
const ungrouped = byModule.get(void 0) ?? [];
|
|
21
|
-
for (const [moduleName, nodes] of moduleGroups) {
|
|
22
|
-
const clusterId = sanitizeClusterId(moduleName);
|
|
23
|
-
lines.push(` subgraph cluster_${clusterId} {`);
|
|
24
|
-
lines.push(` label="${dotEscapeLabel(moduleName)}";`);
|
|
25
|
-
lines.push(" style=filled;");
|
|
26
|
-
lines.push(" fillcolor=lightgray;");
|
|
27
|
-
for (const node of nodes) lines.push(nodeAttributeLine(node, " "));
|
|
28
|
-
lines.push(" }");
|
|
29
|
-
}
|
|
30
|
-
for (const node of ungrouped) lines.push(nodeAttributeLine(node, " "));
|
|
31
|
-
const emittedNodeIds = new Set(graph.nodes.map((node) => node.bindingId));
|
|
32
|
-
const edgeSeen = /* @__PURE__ */ new Set();
|
|
33
9
|
for (const edge of graph.edges) {
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
edgeSeen.add(edgeKey);
|
|
37
|
-
if (!emittedNodeIds.has(edge.fromBindingId)) {
|
|
38
|
-
emittedNodeIds.add(edge.fromBindingId);
|
|
39
|
-
lines.push(` "${dotEscapeId(edge.fromBindingId)}" [shape=box, style=dashed, label="(unlisted ${dotEscapeLabel(edge.fromBindingId)})"];`);
|
|
40
|
-
}
|
|
41
|
-
if (!emittedNodeIds.has(edge.toBindingId)) {
|
|
42
|
-
emittedNodeIds.add(edge.toBindingId);
|
|
43
|
-
lines.push(` "${dotEscapeId(edge.toBindingId)}" [shape=box, style=dashed, label="(unlisted ${dotEscapeLabel(edge.toBindingId)})"];`);
|
|
44
|
-
}
|
|
45
|
-
const labelParts = [];
|
|
46
|
-
if (edge.injectHintLabel !== void 0) labelParts.push(edge.injectHintLabel);
|
|
47
|
-
labelParts.push(edge.edgeKind);
|
|
48
|
-
if (edge.toBindingConditional) labelParts.push("conditional");
|
|
49
|
-
const edgeLabel = dotEscapeLabel(labelParts.join(" | "));
|
|
50
|
-
const pathLabel = dotEscapeLabel(edge.resolutionPath.join(" -> "));
|
|
51
|
-
const edgeStyle = edge.isAliasEdge ? ", style=dashed" : "";
|
|
52
|
-
lines.push(` "${dotEscapeId(edge.fromBindingId)}" -> "${dotEscapeId(edge.toBindingId)}" [label="${edgeLabel}", xlabel="${pathLabel}"${edgeStyle}];`);
|
|
10
|
+
const label = edge.label !== void 0 ? ` [label="${edge.label}"]` : "";
|
|
11
|
+
lines.push(` "${edge.from}" -> "${edge.to}"${label};`);
|
|
53
12
|
}
|
|
54
13
|
lines.push("}");
|
|
55
14
|
return lines.join("\n");
|
|
56
15
|
}
|
|
57
|
-
function nodeAttributeLine(node, indent) {
|
|
58
|
-
const shape = nodeShapeForKind(node.kind);
|
|
59
|
-
const scopeAttrs = scopeVisualAttributes(node.scope);
|
|
60
|
-
const labelLines = [
|
|
61
|
-
node.kind,
|
|
62
|
-
node.registryKeyLabel,
|
|
63
|
-
`scope=${node.scope}`
|
|
64
|
-
];
|
|
65
|
-
if (node.hasConditionalConstraint) labelLines.push("when(...)");
|
|
66
|
-
return `${indent}"${dotEscapeId(node.bindingId)}" [shape=${shape}, ${scopeAttrs}, label="${dotEscapeLabel(labelLines.join("\n"))}"];`;
|
|
67
|
-
}
|
|
68
|
-
function dotEscapeLabel(text) {
|
|
69
|
-
return text.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"").replaceAll("\n", "\\n");
|
|
70
|
-
}
|
|
71
|
-
function dotEscapeId(id) {
|
|
72
|
-
return id.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"").replaceAll("\n", "\\n");
|
|
73
|
-
}
|
|
74
|
-
function nodeShapeForKind(kind) {
|
|
75
|
-
switch (kind) {
|
|
76
|
-
case "constant": return "ellipse";
|
|
77
|
-
case "class": return "box";
|
|
78
|
-
case "dynamic":
|
|
79
|
-
case "async-dynamic":
|
|
80
|
-
case "resolved": return "diamond";
|
|
81
|
-
case "alias": return "octagon";
|
|
82
|
-
default: return kind;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
function scopeVisualAttributes(scope) {
|
|
86
|
-
switch (scope) {
|
|
87
|
-
case "singleton": return "style=\"filled\", fillcolor=\"#FFD700\", penwidth=2";
|
|
88
|
-
case "scoped": return "style=\"filled\", fillcolor=\"#ADD8E6\"";
|
|
89
|
-
case "transient": return "style=\"dashed\"";
|
|
90
|
-
default: return scope;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
function sanitizeClusterId(moduleName) {
|
|
94
|
-
return moduleName.replace(/[^0-9a-zA-Z_]/g, "_");
|
|
95
|
-
}
|
|
96
16
|
//#endregion
|
|
97
17
|
export { toDotGraph };
|
|
@@ -1,10 +1,29 @@
|
|
|
1
|
-
import { ContainerGraphJson } from "../
|
|
2
|
-
import { ReactFlowGraphJson } from "./types.mjs";
|
|
1
|
+
import { ContainerGraphJson } from "../dependency-graph.mjs";
|
|
3
2
|
|
|
4
3
|
//#region src/graph-adapters/reactflow.d.ts
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
interface ReactFlowNode {
|
|
5
|
+
id: string;
|
|
6
|
+
data: {
|
|
7
|
+
label: string;
|
|
8
|
+
kind: string;
|
|
9
|
+
scope: string;
|
|
10
|
+
fromParent: boolean;
|
|
11
|
+
};
|
|
12
|
+
position: {
|
|
13
|
+
x: number;
|
|
14
|
+
y: number;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
interface ReactFlowEdge {
|
|
18
|
+
id: string;
|
|
19
|
+
source: string;
|
|
20
|
+
target: string;
|
|
21
|
+
label?: string;
|
|
22
|
+
}
|
|
23
|
+
interface ReactFlowGraph {
|
|
24
|
+
nodes: ReactFlowNode[];
|
|
25
|
+
edges: ReactFlowEdge[];
|
|
26
|
+
}
|
|
27
|
+
declare function toReactFlowGraph(graph: ContainerGraphJson): ReactFlowGraph;
|
|
9
28
|
//#endregion
|
|
10
|
-
export { toReactFlowGraph };
|
|
29
|
+
export { ReactFlowEdge, ReactFlowGraph, ReactFlowNode, toReactFlowGraph };
|
|
@@ -1,80 +1,29 @@
|
|
|
1
1
|
//#region src/graph-adapters/reactflow.ts
|
|
2
|
-
const DEFAULT_X_GAP = 240;
|
|
3
|
-
const DEFAULT_Y_GAP = 110;
|
|
4
|
-
/**
|
|
5
|
-
* Converts the canonical container graph JSON into React Flow nodes/edges format.
|
|
6
|
-
*/
|
|
7
2
|
function toReactFlowGraph(graph) {
|
|
8
|
-
const nodes = graph.nodes.map((node, index) => ({
|
|
9
|
-
id: node.bindingId,
|
|
10
|
-
position: {
|
|
11
|
-
x: 0,
|
|
12
|
-
y: index * DEFAULT_Y_GAP
|
|
13
|
-
},
|
|
14
|
-
data: {
|
|
15
|
-
label: node.registryKeyLabel,
|
|
16
|
-
bindingId: node.bindingId,
|
|
17
|
-
kind: node.kind,
|
|
18
|
-
scope: node.scope,
|
|
19
|
-
activationStatus: node.activationStatus,
|
|
20
|
-
hasConditionalConstraint: node.hasConditionalConstraint,
|
|
21
|
-
...node.moduleId === void 0 ? {} : { moduleId: node.moduleId }
|
|
22
|
-
}
|
|
23
|
-
}));
|
|
24
|
-
const edges = graph.edges.map((edge) => ({
|
|
25
|
-
id: edgeIdForReactFlow(edge),
|
|
26
|
-
source: edge.fromBindingId,
|
|
27
|
-
target: edge.toBindingId,
|
|
28
|
-
label: edgeLabelForReactFlow(edge),
|
|
29
|
-
data: {
|
|
30
|
-
edgeKind: edge.edgeKind,
|
|
31
|
-
...edge.injectHintLabel === void 0 ? {} : { injectHintLabel: edge.injectHintLabel },
|
|
32
|
-
toBindingConditional: edge.toBindingConditional,
|
|
33
|
-
isAliasEdge: edge.isAliasEdge,
|
|
34
|
-
resolutionPath: [...edge.resolutionPath]
|
|
35
|
-
}
|
|
36
|
-
}));
|
|
37
|
-
const moduleIndex = /* @__PURE__ */ new Map();
|
|
38
|
-
let nextColumn = 1;
|
|
39
3
|
return {
|
|
40
|
-
nodes: nodes.map((node) => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
4
|
+
nodes: graph.nodes.map((node, idx) => ({
|
|
5
|
+
id: node.id,
|
|
6
|
+
data: {
|
|
7
|
+
label: node.tokenName,
|
|
8
|
+
kind: node.kind,
|
|
9
|
+
scope: node.scope,
|
|
10
|
+
fromParent: node.fromParent
|
|
11
|
+
},
|
|
12
|
+
position: {
|
|
13
|
+
x: idx % 5 * 200,
|
|
14
|
+
y: Math.floor(idx / 5) * 100
|
|
15
|
+
}
|
|
16
|
+
})),
|
|
17
|
+
edges: graph.edges.map((edge, idx) => {
|
|
18
|
+
const reactFlowEdge = {
|
|
19
|
+
id: `edge-${idx}`,
|
|
20
|
+
source: edge.from,
|
|
21
|
+
target: edge.to
|
|
50
22
|
};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return {
|
|
55
|
-
...node,
|
|
56
|
-
position: {
|
|
57
|
-
...node.position,
|
|
58
|
-
x: column * DEFAULT_X_GAP
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
}),
|
|
62
|
-
edges
|
|
23
|
+
if (edge.label !== void 0) reactFlowEdge.label = edge.label;
|
|
24
|
+
return reactFlowEdge;
|
|
25
|
+
})
|
|
63
26
|
};
|
|
64
27
|
}
|
|
65
|
-
function edgeLabelForReactFlow(edge) {
|
|
66
|
-
const parts = [];
|
|
67
|
-
if (edge.injectHintLabel !== void 0) parts.push(edge.injectHintLabel);
|
|
68
|
-
parts.push(edge.edgeKind);
|
|
69
|
-
if (edge.toBindingConditional) parts.push("conditional");
|
|
70
|
-
return parts.join(" | ");
|
|
71
|
-
}
|
|
72
|
-
function edgeIdForReactFlow(edge) {
|
|
73
|
-
const hint = edge.injectHintLabel ?? "";
|
|
74
|
-
const conditional = edge.toBindingConditional ? "conditional" : "plain";
|
|
75
|
-
const alias = edge.isAliasEdge ? "alias" : "direct";
|
|
76
|
-
const path = edge.resolutionPath.join("->");
|
|
77
|
-
return `${edge.fromBindingId}->${edge.toBindingId}:${edge.edgeKind}:${hint}:${conditional}:${alias}:${path}`;
|
|
78
|
-
}
|
|
79
28
|
//#endregion
|
|
80
29
|
export { toReactFlowGraph };
|
|
@@ -1,91 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
//#region src/graph-adapters/types.d.ts
|
|
5
|
-
/**
|
|
6
|
-
* Cytoscape node payload emitted by graph adapters.
|
|
7
|
-
*/
|
|
8
|
-
type CytoscapeNodeData = {
|
|
9
|
-
readonly id: string;
|
|
10
|
-
readonly label: string;
|
|
11
|
-
readonly bindingId: BindingIdentifier;
|
|
12
|
-
readonly kind: Binding<unknown>["kind"];
|
|
13
|
-
readonly scope: BindingScope;
|
|
14
|
-
readonly activationStatus: "cached" | "not-cached" | "transient";
|
|
15
|
-
readonly hasConditionalConstraint: boolean;
|
|
16
|
-
readonly moduleId?: string;
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* Cytoscape edge payload emitted by graph adapters.
|
|
20
|
-
*/
|
|
21
|
-
type CytoscapeEdgeData = {
|
|
22
|
-
readonly id: string;
|
|
23
|
-
readonly source: StaticDependencyEdge["fromBindingId"];
|
|
24
|
-
readonly target: StaticDependencyEdge["toBindingId"];
|
|
25
|
-
readonly edgeKind: StaticDependencyEdge["edgeKind"];
|
|
26
|
-
readonly injectHintLabel?: string;
|
|
27
|
-
readonly toBindingConditional: boolean;
|
|
28
|
-
readonly isAliasEdge: boolean;
|
|
29
|
-
readonly resolutionPath: readonly string[];
|
|
30
|
-
};
|
|
31
|
-
type CytoscapeNode = {
|
|
32
|
-
readonly data: CytoscapeNodeData;
|
|
33
|
-
};
|
|
34
|
-
type CytoscapeEdge = {
|
|
35
|
-
readonly data: CytoscapeEdgeData;
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
* Cytoscape JSON graph output shape.
|
|
39
|
-
*/
|
|
40
|
-
type CytoscapeGraphJson = {
|
|
41
|
-
readonly elements: {
|
|
42
|
-
readonly nodes: CytoscapeNode[];
|
|
43
|
-
readonly edges: CytoscapeEdge[];
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
/**
|
|
47
|
-
* React Flow node payload emitted by graph adapters.
|
|
48
|
-
*/
|
|
49
|
-
type ReactFlowNodeData = {
|
|
50
|
-
readonly label: string;
|
|
51
|
-
readonly bindingId: BindingIdentifier;
|
|
52
|
-
readonly kind: Binding<unknown>["kind"];
|
|
53
|
-
readonly scope: BindingScope;
|
|
54
|
-
readonly activationStatus: "cached" | "not-cached" | "transient";
|
|
55
|
-
readonly hasConditionalConstraint: boolean;
|
|
56
|
-
readonly moduleId?: string;
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* React Flow edge payload emitted by graph adapters.
|
|
60
|
-
*/
|
|
61
|
-
type ReactFlowEdgeData = {
|
|
62
|
-
readonly edgeKind: StaticDependencyEdge["edgeKind"];
|
|
63
|
-
readonly injectHintLabel?: string;
|
|
64
|
-
readonly toBindingConditional: boolean;
|
|
65
|
-
readonly isAliasEdge: boolean;
|
|
66
|
-
readonly resolutionPath: readonly string[];
|
|
67
|
-
};
|
|
68
|
-
type ReactFlowNode = {
|
|
69
|
-
readonly id: string;
|
|
70
|
-
readonly position: {
|
|
71
|
-
readonly x: number;
|
|
72
|
-
readonly y: number;
|
|
73
|
-
};
|
|
74
|
-
readonly data: ReactFlowNodeData;
|
|
75
|
-
};
|
|
76
|
-
type ReactFlowEdge = {
|
|
77
|
-
readonly id: string;
|
|
78
|
-
readonly source: StaticDependencyEdge["fromBindingId"];
|
|
79
|
-
readonly target: StaticDependencyEdge["toBindingId"];
|
|
80
|
-
readonly label: string;
|
|
81
|
-
readonly data: ReactFlowEdgeData;
|
|
82
|
-
};
|
|
83
|
-
/**
|
|
84
|
-
* React Flow JSON graph output shape.
|
|
85
|
-
*/
|
|
86
|
-
type ReactFlowGraphJson = {
|
|
87
|
-
readonly nodes: ReactFlowNode[];
|
|
88
|
-
readonly edges: ReactFlowEdge[];
|
|
89
|
-
};
|
|
90
|
-
//#endregion
|
|
91
|
-
export { CytoscapeEdge, CytoscapeEdgeData, CytoscapeGraphJson, CytoscapeNode, CytoscapeNodeData, ReactFlowEdge, ReactFlowEdgeData, ReactFlowGraphJson, ReactFlowNode, ReactFlowNodeData };
|
|
1
|
+
import { ContainerGraphJson, GraphEdge, GraphNode, GraphOptions } from "../dependency-graph.mjs";
|
|
2
|
+
export { type ContainerGraphJson, type GraphEdge, type GraphNode, type GraphOptions };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { Constructor } from "./constructor-type.mjs";
|
|
2
|
+
import { Token, token } from "./token.mjs";
|
|
3
|
+
import { ActivationHandler, BindingIdentifier, BindingKind, BindingScope, ConstraintContext, DeactivationHandler, DependencyKey, MaterializationFrame, ResolutionContext, ResolveOptions, TokenValue } from "./types.mjs";
|
|
4
|
+
import { InjectOptions, InjectableDependency, InjectionDescriptor, inject, injectAll, isInjectionDescriptor, optional } from "./decorators/inject.mjs";
|
|
5
|
+
import { AliasBindingBuilder, BindToBuilder, BindingBuilder, ConstantBindingBuilder, ScopedBindingBuilder, SingletonBindingBuilder, SingletonLifecycleBuilder, TransientBindingBuilder } from "./binding.mjs";
|
|
6
|
+
import { effectiveBindingScope } from "./binding-scope.mjs";
|
|
7
|
+
import { AsyncModule, AsyncModuleBuilder, Module, ModuleBuilder, SyncModule } from "./module.mjs";
|
|
8
|
+
import { BindingSnapshot, ContainerSnapshot } from "./inspector.mjs";
|
|
9
|
+
import { MetadataReader, MutableLifecycleMetadata } from "./metadata/metadata-types.mjs";
|
|
10
|
+
import { ContainerGraphJson, GraphEdge, GraphNode, GraphOptions } from "./dependency-graph.mjs";
|
|
11
|
+
import { AutoRegisterRegistry, InjectableOptions, createAutoRegisterRegistry, injectable } from "./decorators/injectable.mjs";
|
|
12
|
+
import { Container, ContainerStatic } from "./container.mjs";
|
|
7
13
|
import { postConstruct, preDestroy } from "./decorators/lifecycle-decorators.mjs";
|
|
8
|
-
import { AsyncModuleLoadError, AsyncResolutionError, CircularDependencyError, DiError, InternalError, MissingMetadataError, NoMatchingBindingError, ScopeViolationDetails, ScopeViolationError, TokenNotBoundError } from "./errors.mjs";
|
|
9
|
-
|
|
14
|
+
import { AmbiguousBindingError, AsyncDeactivationError, AsyncModuleLoadError, AsyncResolutionError, CircularDependencyError, DiError, DisposedContainerError, InternalError, MissingContainerContextError, MissingMetadataError, MissingScopeContextError, NoMatchingBindingError, RebindUnboundTokenError, ScopeViolationDetails, ScopeViolationError, SyncDisposalNotSupportedError, TokenNotBoundError } from "./errors.mjs";
|
|
15
|
+
import { injectableSlotToResolveOptions, slotKeyToResolveOptions } from "./resolve-options.mjs";
|
|
16
|
+
import { MetadataReaderToken } from "./metadata/metadata-reader-token.mjs";
|
|
17
|
+
export { type ActivationHandler, type AliasBindingBuilder, AmbiguousBindingError, AsyncDeactivationError, AsyncModule, type AsyncModuleBuilder, AsyncModuleLoadError, AsyncResolutionError, type AutoRegisterRegistry, type BindToBuilder, type BindingBuilder, type BindingIdentifier, type BindingKind, type BindingScope, type BindingSnapshot, CircularDependencyError, type ConstantBindingBuilder, type ConstraintContext, type Constructor, Container, type ContainerGraphJson, type Container as ContainerInterface, type ContainerSnapshot, type ContainerStatic, type DeactivationHandler, type DependencyKey, DiError, DisposedContainerError, type GraphEdge, type GraphNode, type GraphOptions, type InjectOptions, type InjectableDependency, type InjectableOptions, type InjectionDescriptor, InternalError, type MaterializationFrame, type MetadataReader, MetadataReaderToken, MissingContainerContextError, MissingMetadataError, MissingScopeContextError, Module, type ModuleBuilder, type MutableLifecycleMetadata, NoMatchingBindingError, RebindUnboundTokenError, type ResolutionContext, type ResolveOptions, type ScopeViolationDetails, ScopeViolationError, type ScopedBindingBuilder, type SingletonBindingBuilder, type SingletonLifecycleBuilder, SyncDisposalNotSupportedError, SyncModule, type Token, TokenNotBoundError, type TokenValue, type TransientBindingBuilder, createAutoRegisterRegistry, effectiveBindingScope, inject, injectAll, injectable, injectableSlotToResolveOptions, isInjectionDescriptor, optional, postConstruct, preDestroy, slotKeyToResolveOptions, token };
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { effectiveBindingScope } from "./binding-scope.mjs";
|
|
2
|
+
import { AmbiguousBindingError, AsyncDeactivationError, AsyncModuleLoadError, AsyncResolutionError, CircularDependencyError, DiError, DisposedContainerError, InternalError, MissingContainerContextError, MissingMetadataError, MissingScopeContextError, NoMatchingBindingError, RebindUnboundTokenError, ScopeViolationError, SyncDisposalNotSupportedError, TokenNotBoundError } from "./errors.mjs";
|
|
3
|
+
import { token } from "./token.mjs";
|
|
4
|
+
import { injectableSlotToResolveOptions, slotKeyToResolveOptions } from "./resolve-options.mjs";
|
|
5
|
+
import { MetadataReaderToken } from "./metadata/metadata-reader-token.mjs";
|
|
2
6
|
import { inject, injectAll, isInjectionDescriptor, optional } from "./decorators/inject.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { AsyncModule, Module } from "./module.mjs";
|
|
7
|
+
import { AsyncModule, Module, SyncModule } from "./module.mjs";
|
|
5
8
|
import { Container } from "./container.mjs";
|
|
6
|
-
import {
|
|
9
|
+
import { createAutoRegisterRegistry, injectable } from "./decorators/injectable.mjs";
|
|
7
10
|
import { postConstruct, preDestroy } from "./decorators/lifecycle-decorators.mjs";
|
|
8
|
-
export { AsyncModule, AsyncModuleLoadError, AsyncResolutionError, CircularDependencyError, Container, DiError, InternalError, MissingMetadataError, Module, NoMatchingBindingError, ScopeViolationError, TokenNotBoundError,
|
|
11
|
+
export { AmbiguousBindingError, AsyncDeactivationError, AsyncModule, AsyncModuleLoadError, AsyncResolutionError, CircularDependencyError, Container, DiError, DisposedContainerError, InternalError, MetadataReaderToken, MissingContainerContextError, MissingMetadataError, MissingScopeContextError, Module, NoMatchingBindingError, RebindUnboundTokenError, ScopeViolationError, SyncDisposalNotSupportedError, SyncModule, TokenNotBoundError, createAutoRegisterRegistry, effectiveBindingScope, inject, injectAll, injectable, injectableSlotToResolveOptions, isInjectionDescriptor, optional, postConstruct, preDestroy, slotKeyToResolveOptions, token };
|
package/dist/inspector.d.mts
CHANGED
|
@@ -1,78 +1,39 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { Constructor } from "./constructor-type.mjs";
|
|
2
|
+
import { Token } from "./token.mjs";
|
|
3
|
+
import { BindingIdentifier, BindingKind, BindingScope, ResolveOptions } from "./types.mjs";
|
|
4
|
+
import { BindingRegistry } from "./registry.mjs";
|
|
5
|
+
import { ScopeManager } from "./scope.mjs";
|
|
5
6
|
|
|
6
7
|
//#region src/inspector.d.ts
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
readonly
|
|
19
|
-
readonly
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
/** Graph nodes (same shape as snapshot rows). */nodes: ContainerBindingSnapshot[]; /** Directed dependency edges between node binding ids. */
|
|
37
|
-
edges: ReturnType<typeof collectStaticDependencyEdges>[number][];
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* Read-only view of the container internals exposed to {@link ContainerInspector}.
|
|
41
|
-
*/
|
|
42
|
-
type ContainerInspectorContext = {
|
|
43
|
-
/** Enumerates every registry key visible to the inspector. */collectAllRegistryKeys(): readonly RegistryKey[]; /** Returns bindings for a given key, including hierarchy lookup behavior. */
|
|
44
|
-
lookupBindings(key: RegistryKey): readonly Binding<unknown>[] | undefined; /** Reports whether a binding currently has a cached scoped/singleton instance. */
|
|
45
|
-
isBindingCached(binding: Binding<unknown>): boolean; /** Metadata reader used for static constructor/lifecycle analysis. */
|
|
46
|
-
metadataReader: MetadataReader | undefined;
|
|
47
|
-
};
|
|
48
|
-
/**
|
|
49
|
-
* Options for {@link Container.generateDependencyGraph}.
|
|
50
|
-
*/
|
|
51
|
-
type GraphOptions = {
|
|
52
|
-
/**
|
|
53
|
-
* When true, omit registry keys whose label starts with `CODEFAST_DI_` (framework-style tokens)
|
|
54
|
-
* and any edges that would only connect hidden nodes.
|
|
55
|
-
*/
|
|
56
|
-
readonly hideInternals?: boolean;
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* Reads the container's registry and scope-cache state to produce debug snapshots
|
|
60
|
-
* and canonical dependency-graph output (`nodes` + `edges`).
|
|
61
|
-
*
|
|
62
|
-
* Constructed internally by the container; advanced consumers can also construct it
|
|
63
|
-
* directly via the `@codefast/di/inspector` subpath export.
|
|
64
|
-
*/
|
|
65
|
-
declare class ContainerInspector {
|
|
66
|
-
private readonly ctx;
|
|
67
|
-
constructor(ctx: ContainerInspectorContext);
|
|
68
|
-
/**
|
|
69
|
-
* Collects all registered bindings into a flat, serialisable snapshot.
|
|
70
|
-
*/
|
|
71
|
-
getSnapshot(): ContainerSnapshot;
|
|
72
|
-
/**
|
|
73
|
-
* Builds the canonical JSON graph (`nodes` + `edges`).
|
|
74
|
-
*/
|
|
75
|
-
generateDependencyGraph(options?: GraphOptions): ContainerGraphJson;
|
|
8
|
+
interface BindingSnapshot {
|
|
9
|
+
readonly tokenName: string;
|
|
10
|
+
readonly kind: BindingKind;
|
|
11
|
+
readonly scope: BindingScope;
|
|
12
|
+
readonly slot: {
|
|
13
|
+
readonly name?: string;
|
|
14
|
+
readonly tags: ReadonlyArray<readonly [string, unknown]>;
|
|
15
|
+
};
|
|
16
|
+
readonly id: BindingIdentifier;
|
|
17
|
+
}
|
|
18
|
+
interface ContainerSnapshot {
|
|
19
|
+
readonly ownBindings: readonly BindingSnapshot[];
|
|
20
|
+
readonly bindings: readonly BindingSnapshot[];
|
|
21
|
+
readonly cachedSingletonCount: number;
|
|
22
|
+
readonly hasParent: boolean;
|
|
23
|
+
readonly isDisposed: boolean;
|
|
24
|
+
}
|
|
25
|
+
declare class Inspector {
|
|
26
|
+
private readonly _registry;
|
|
27
|
+
private readonly _scope;
|
|
28
|
+
private readonly _hasParent;
|
|
29
|
+
private readonly _isDisposed;
|
|
30
|
+
constructor(_registry: BindingRegistry, _scope: ScopeManager, _hasParent: boolean, _isDisposed: () => boolean);
|
|
31
|
+
inspect(): ContainerSnapshot;
|
|
32
|
+
lookupBindings<Value>(token: Token<Value> | Constructor<Value>): readonly BindingSnapshot[];
|
|
33
|
+
has(token: Token<unknown> | Constructor, hint?: ResolveOptions, parentHas?: () => boolean): boolean;
|
|
34
|
+
hasOwn(token: Token<unknown> | Constructor, hint?: ResolveOptions): boolean;
|
|
35
|
+
private allBindingSnapshots;
|
|
36
|
+
private _toSnapshot;
|
|
76
37
|
}
|
|
77
38
|
//#endregion
|
|
78
|
-
export {
|
|
39
|
+
export { BindingSnapshot, ContainerSnapshot, Inspector };
|