@codefast/di 0.7.0 → 0.7.1
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 +6 -0
- package/README.md +1 -1
- package/dist/ambient/active-container.d.ts +4 -0
- package/dist/ambient/active-container.d.ts.map +1 -1
- package/dist/ambient/active-container.js +4 -0
- package/dist/ambient/active-container.js.map +1 -1
- package/dist/container/container.d.ts +6 -0
- package/dist/container/container.d.ts.map +1 -1
- package/dist/container/container.js +2 -0
- package/dist/container/container.js.map +1 -1
- package/dist/core/module.d.ts +16 -0
- package/dist/core/module.d.ts.map +1 -1
- package/dist/core/module.js +8 -0
- package/dist/core/module.js.map +1 -1
- package/dist/core/registry.d.ts +2 -0
- package/dist/core/registry.d.ts.map +1 -1
- package/dist/core/registry.js +2 -0
- package/dist/core/registry.js.map +1 -1
- package/dist/core/token.d.ts +6 -0
- package/dist/core/token.d.ts.map +1 -1
- package/dist/core/token.js +4 -0
- package/dist/core/token.js.map +1 -1
- package/dist/core/types.d.ts +20 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/decorators/inject.d.ts +2 -0
- package/dist/decorators/inject.d.ts.map +1 -1
- package/dist/decorators/inject.js +2 -0
- package/dist/decorators/inject.js.map +1 -1
- package/dist/decorators/injectable.d.ts +6 -0
- package/dist/decorators/injectable.d.ts.map +1 -1
- package/dist/decorators/injectable.js +4 -0
- package/dist/decorators/injectable.js.map +1 -1
- package/dist/decorators/lifecycle-decorators.d.ts +4 -0
- package/dist/decorators/lifecycle-decorators.d.ts.map +1 -1
- package/dist/decorators/lifecycle-decorators.js +4 -0
- package/dist/decorators/lifecycle-decorators.js.map +1 -1
- package/dist/errors/errors.d.ts +34 -0
- package/dist/errors/errors.d.ts.map +1 -1
- package/dist/errors/errors.js +32 -0
- package/dist/errors/errors.js.map +1 -1
- package/dist/injection/descriptor.d.ts +12 -0
- package/dist/injection/descriptor.d.ts.map +1 -1
- package/dist/injection/descriptor.js +8 -0
- package/dist/injection/descriptor.js.map +1 -1
- package/dist/introspection/dependency-graph.d.ts +6 -0
- package/dist/introspection/dependency-graph.d.ts.map +1 -1
- package/dist/introspection/dependency-graph.js +2 -0
- package/dist/introspection/dependency-graph.js.map +1 -1
- package/dist/introspection/graph-adapters/cytoscape.d.ts +8 -0
- package/dist/introspection/graph-adapters/cytoscape.d.ts.map +1 -1
- package/dist/introspection/graph-adapters/cytoscape.js +2 -0
- package/dist/introspection/graph-adapters/cytoscape.js.map +1 -1
- package/dist/introspection/graph-adapters/dot.d.ts +2 -0
- package/dist/introspection/graph-adapters/dot.d.ts.map +1 -1
- package/dist/introspection/graph-adapters/dot.js +2 -0
- package/dist/introspection/graph-adapters/dot.js.map +1 -1
- package/dist/introspection/graph-adapters/reactflow.d.ts +8 -0
- package/dist/introspection/graph-adapters/reactflow.d.ts.map +1 -1
- package/dist/introspection/graph-adapters/reactflow.js +2 -0
- package/dist/introspection/graph-adapters/reactflow.js.map +1 -1
- package/dist/introspection/inspector.d.ts +6 -0
- package/dist/introspection/inspector.d.ts.map +1 -1
- package/dist/introspection/inspector.js +2 -0
- package/dist/introspection/inspector.js.map +1 -1
- package/dist/lifecycle/lifecycle-manager.d.ts +2 -0
- package/dist/lifecycle/lifecycle-manager.d.ts.map +1 -1
- package/dist/lifecycle/lifecycle-manager.js +2 -0
- package/dist/lifecycle/lifecycle-manager.js.map +1 -1
- package/dist/lifecycle/scope-manager.d.ts +2 -0
- package/dist/lifecycle/scope-manager.d.ts.map +1 -1
- package/dist/lifecycle/scope-manager.js +2 -0
- package/dist/lifecycle/scope-manager.js.map +1 -1
- package/dist/metadata/metadata-keys.d.ts +6 -0
- package/dist/metadata/metadata-keys.d.ts.map +1 -1
- package/dist/metadata/metadata-keys.js +6 -0
- package/dist/metadata/metadata-keys.js.map +1 -1
- package/dist/metadata/metadata-reader-token.d.ts +2 -0
- package/dist/metadata/metadata-reader-token.d.ts.map +1 -1
- package/dist/metadata/metadata-reader-token.js +2 -0
- package/dist/metadata/metadata-reader-token.js.map +1 -1
- package/dist/metadata/metadata-types.d.ts +6 -0
- package/dist/metadata/metadata-types.d.ts.map +1 -1
- package/dist/metadata/symbol-metadata-reader.d.ts +4 -0
- package/dist/metadata/symbol-metadata-reader.d.ts.map +1 -1
- package/dist/metadata/symbol-metadata-reader.js +4 -0
- package/dist/metadata/symbol-metadata-reader.js.map +1 -1
- package/dist/resolution/cache/activation-need.d.ts +2 -0
- package/dist/resolution/cache/activation-need.d.ts.map +1 -1
- package/dist/resolution/cache/activation-need.js +2 -0
- package/dist/resolution/cache/activation-need.js.map +1 -1
- package/dist/resolution/cache/binding-lookup-cache.d.ts +2 -0
- package/dist/resolution/cache/binding-lookup-cache.d.ts.map +1 -1
- package/dist/resolution/cache/binding-lookup-cache.js +2 -0
- package/dist/resolution/cache/binding-lookup-cache.js.map +1 -1
- package/dist/resolution/cache/class-introspector.d.ts +2 -0
- package/dist/resolution/cache/class-introspector.d.ts.map +1 -1
- package/dist/resolution/cache/class-introspector.js +2 -0
- package/dist/resolution/cache/class-introspector.js.map +1 -1
- package/dist/resolution/context.d.ts +6 -0
- package/dist/resolution/context.d.ts.map +1 -1
- package/dist/resolution/context.js +4 -0
- package/dist/resolution/context.js.map +1 -1
- package/dist/resolution/plan/instantiation-plan.d.ts +2 -0
- package/dist/resolution/plan/instantiation-plan.d.ts.map +1 -1
- package/dist/resolution/plan/instantiation-plan.js +2 -0
- package/dist/resolution/plan/instantiation-plan.js.map +1 -1
- package/dist/resolution/resolver.d.ts +2 -0
- package/dist/resolution/resolver.d.ts.map +1 -1
- package/dist/resolution/resolver.js +2 -0
- package/dist/resolution/resolver.js.map +1 -1
- package/dist/resolution/select/constraints.d.ts +16 -0
- package/dist/resolution/select/constraints.d.ts.map +1 -1
- package/dist/resolution/select/constraints.js +16 -0
- package/dist/resolution/select/constraints.js.map +1 -1
- package/package.json +12 -5
- package/src/ambient/active-container.ts +4 -0
- package/src/container/container.ts +6 -0
- package/src/core/module.ts +16 -0
- package/src/core/registry.ts +2 -0
- package/src/core/token.ts +6 -0
- package/src/core/types.ts +20 -0
- package/src/decorators/inject.ts +2 -0
- package/src/decorators/injectable.ts +8 -0
- package/src/decorators/lifecycle-decorators.ts +4 -0
- package/src/errors/errors.ts +34 -0
- package/src/injection/descriptor.ts +12 -0
- package/src/introspection/dependency-graph.ts +6 -0
- package/src/introspection/graph-adapters/cytoscape.ts +8 -0
- package/src/introspection/graph-adapters/dot.ts +2 -0
- package/src/introspection/graph-adapters/reactflow.ts +8 -0
- package/src/introspection/inspector.ts +6 -0
- package/src/lifecycle/lifecycle-manager.ts +2 -0
- package/src/lifecycle/scope-manager.ts +2 -0
- package/src/metadata/metadata-keys.ts +6 -0
- package/src/metadata/metadata-reader-token.ts +2 -0
- package/src/metadata/metadata-types.ts +6 -0
- package/src/metadata/symbol-metadata-reader.ts +4 -0
- package/src/resolution/cache/activation-need.ts +2 -0
- package/src/resolution/cache/binding-lookup-cache.ts +2 -0
- package/src/resolution/cache/class-introspector.ts +2 -0
- package/src/resolution/context.ts +6 -0
- package/src/resolution/plan/instantiation-plan.ts +2 -0
- package/src/resolution/resolver.ts +2 -0
- package/src/resolution/select/constraints.ts +16 -0
|
@@ -4,6 +4,8 @@ import type { BindingTag, Constructor, TokenValue } from "#/core/types";
|
|
|
4
4
|
import type { DependencySlot } from "#/injection/resolve-options";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
+
* Slot-selection options — a name and tags — a declared dependency narrows its binding with.
|
|
8
|
+
*
|
|
7
9
|
* @since 0.3.16-canary.0
|
|
8
10
|
*/
|
|
9
11
|
export interface InjectOptions {
|
|
@@ -31,6 +33,8 @@ export interface InjectionDescriptor<out Value = unknown> extends DependencySlot
|
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
/**
|
|
36
|
+
* A dependency as declared: a bare token, a class, or a full injection descriptor.
|
|
37
|
+
*
|
|
34
38
|
* @since 0.3.16-canary.0
|
|
35
39
|
*/
|
|
36
40
|
export type InjectableDependency<Value = unknown> = Token<Value> | Constructor<Value> | InjectionDescriptor<Value>;
|
|
@@ -60,6 +64,8 @@ export type ResolvedDependencyValue<Dependency> = Dependency extends { readonly
|
|
|
60
64
|
type DescribedValue<Dependency> = Dependency extends InjectionDescriptor<infer Value> ? Value : TokenValue<Dependency>;
|
|
61
65
|
|
|
62
66
|
/**
|
|
67
|
+
* Returns whether the value is an `InjectionDescriptor`, dual-role `inject()` functions included.
|
|
68
|
+
*
|
|
63
69
|
* @since 0.3.16-canary.0
|
|
64
70
|
*/
|
|
65
71
|
export function isInjectionDescriptor(value: unknown): value is InjectionDescriptor {
|
|
@@ -81,6 +87,8 @@ export function isInjectionDescriptor(value: unknown): value is InjectionDescrip
|
|
|
81
87
|
}
|
|
82
88
|
|
|
83
89
|
/**
|
|
90
|
+
* Normalises a declared dependency to a plain `InjectionDescriptor`.
|
|
91
|
+
*
|
|
84
92
|
* @since 0.3.16-canary.0
|
|
85
93
|
*/
|
|
86
94
|
export function normalizeToDescriptor(dependency: InjectableDependency): InjectionDescriptor {
|
|
@@ -172,6 +180,8 @@ export function buildInjectionDescriptor<Value>(
|
|
|
172
180
|
}
|
|
173
181
|
|
|
174
182
|
/**
|
|
183
|
+
* Creates a descriptor that resolves to `undefined` instead of throwing when no binding matches.
|
|
184
|
+
*
|
|
175
185
|
* @since 0.3.16-canary.0
|
|
176
186
|
*/
|
|
177
187
|
export function optional<Value>(
|
|
@@ -189,6 +199,8 @@ export function optional<Value>(
|
|
|
189
199
|
}
|
|
190
200
|
|
|
191
201
|
/**
|
|
202
|
+
* Creates a descriptor that resolves every matching binding for the token into an array.
|
|
203
|
+
*
|
|
192
204
|
* @since 0.3.16-canary.0
|
|
193
205
|
*/
|
|
194
206
|
export function injectAll<Value>(
|
|
@@ -43,6 +43,8 @@ export interface GraphEdge {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
|
+
* A container's dependency graph as plain JSON — nodes, edges, and whether the parent is included.
|
|
47
|
+
*
|
|
46
48
|
* @since 0.3.16-canary.0
|
|
47
49
|
*/
|
|
48
50
|
export interface ContainerGraphJson {
|
|
@@ -52,6 +54,8 @@ export interface ContainerGraphJson {
|
|
|
52
54
|
}
|
|
53
55
|
|
|
54
56
|
/**
|
|
57
|
+
* Options controlling what a dependency graph includes.
|
|
58
|
+
*
|
|
55
59
|
* @since 0.3.16-canary.0
|
|
56
60
|
*/
|
|
57
61
|
export interface GraphOptions {
|
|
@@ -255,6 +259,8 @@ function addRegistryBindings(
|
|
|
255
259
|
}
|
|
256
260
|
|
|
257
261
|
/**
|
|
262
|
+
* Builds the JSON dependency graph of a registry's bindings, optionally including the parent's.
|
|
263
|
+
*
|
|
258
264
|
* @since 0.3.16-canary.0
|
|
259
265
|
*/
|
|
260
266
|
export function buildDependencyGraph(
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { ContainerGraphJson, GraphNode } from "#/introspection/dependency-graph";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
+
* A dependency-graph node in Cytoscape's element format.
|
|
5
|
+
*
|
|
4
6
|
* @since 0.3.16-canary.0
|
|
5
7
|
*/
|
|
6
8
|
export interface CytoscapeNode {
|
|
@@ -15,6 +17,8 @@ export interface CytoscapeNode {
|
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
/**
|
|
20
|
+
* A dependency-graph edge in Cytoscape's element format.
|
|
21
|
+
*
|
|
18
22
|
* @since 0.3.16-canary.0
|
|
19
23
|
*/
|
|
20
24
|
export interface CytoscapeEdge {
|
|
@@ -29,11 +33,15 @@ export interface CytoscapeEdge {
|
|
|
29
33
|
}
|
|
30
34
|
|
|
31
35
|
/**
|
|
36
|
+
* The flat node-and-edge list Cytoscape takes as its `elements` input.
|
|
37
|
+
*
|
|
32
38
|
* @since 0.3.16-canary.0
|
|
33
39
|
*/
|
|
34
40
|
export type CytoscapeElements = ReadonlyArray<CytoscapeNode | CytoscapeEdge>;
|
|
35
41
|
|
|
36
42
|
/**
|
|
43
|
+
* Converts a container's dependency graph into Cytoscape's element list.
|
|
44
|
+
*
|
|
37
45
|
* @since 0.3.16-canary.0
|
|
38
46
|
*/
|
|
39
47
|
export function toCytoscapeGraph(graph: ContainerGraphJson): CytoscapeElements {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { ContainerGraphJson, GraphNode } from "#/introspection/dependency-graph";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
+
* A dependency-graph node in React Flow's node format.
|
|
5
|
+
*
|
|
4
6
|
* @since 0.3.16-canary.0
|
|
5
7
|
*/
|
|
6
8
|
export interface ReactFlowNode {
|
|
@@ -16,6 +18,8 @@ export interface ReactFlowNode {
|
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
/**
|
|
21
|
+
* A dependency-graph edge in React Flow's edge format.
|
|
22
|
+
*
|
|
19
23
|
* @since 0.3.16-canary.0
|
|
20
24
|
*/
|
|
21
25
|
export interface ReactFlowEdge {
|
|
@@ -28,6 +32,8 @@ export interface ReactFlowEdge {
|
|
|
28
32
|
}
|
|
29
33
|
|
|
30
34
|
/**
|
|
35
|
+
* The nodes-and-edges pair a React Flow viewer renders.
|
|
36
|
+
*
|
|
31
37
|
* @since 0.3.16-canary.0
|
|
32
38
|
*/
|
|
33
39
|
export interface ReactFlowGraph {
|
|
@@ -45,6 +51,8 @@ const GRID_CELL_WIDTH_PX = 200;
|
|
|
45
51
|
const GRID_CELL_HEIGHT_PX = 100;
|
|
46
52
|
|
|
47
53
|
/**
|
|
54
|
+
* Converts a container's dependency graph into React Flow nodes and edges on an initial grid.
|
|
55
|
+
*
|
|
48
56
|
* @since 0.5.0-canary.7
|
|
49
57
|
*/
|
|
50
58
|
export function toReactFlowGraph(graph: ContainerGraphJson): ReactFlowGraph {
|
|
@@ -18,6 +18,8 @@ import { selectAllBindings } from "#/resolution/select/binding-select";
|
|
|
18
18
|
// ── Public types ─────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
|
+
* A read-only view of one binding: token, kind, scope, slot, and id.
|
|
22
|
+
*
|
|
21
23
|
* @since 0.3.16-canary.0
|
|
22
24
|
*/
|
|
23
25
|
export interface BindingSnapshot {
|
|
@@ -32,6 +34,8 @@ export interface BindingSnapshot {
|
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
/**
|
|
37
|
+
* A read-only view of one container's own bindings and state.
|
|
38
|
+
*
|
|
35
39
|
* @since 0.3.16-canary.0
|
|
36
40
|
*/
|
|
37
41
|
export interface ContainerSnapshot {
|
|
@@ -44,6 +48,8 @@ export interface ContainerSnapshot {
|
|
|
44
48
|
// ── Inspector ────────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
45
49
|
|
|
46
50
|
/**
|
|
51
|
+
* The read-only introspection surface behind a container's `inspect()`.
|
|
52
|
+
*
|
|
47
53
|
* @since 0.3.16-canary.0
|
|
48
54
|
*/
|
|
49
55
|
export class Inspector {
|
|
@@ -13,6 +13,8 @@ import { AsyncActivationError, AsyncDeactivationError, InvalidMetadataError } fr
|
|
|
13
13
|
import type { MetadataReader } from "#/metadata/metadata-types";
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
+
* One container's registry of container-level activation and deactivation hooks, keyed by token.
|
|
17
|
+
*
|
|
16
18
|
* @since 0.3.16-canary.0
|
|
17
19
|
*/
|
|
18
20
|
export class LifecycleManager {
|
|
@@ -5,6 +5,8 @@ import type { BindingIdentifier } from "#/core/types";
|
|
|
5
5
|
import { MissingScopeContextError } from "#/errors/errors";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
+
* One container's instance caches — singletons, in-flight async creations, and the scoped cache.
|
|
9
|
+
*
|
|
8
10
|
* @since 0.3.16-canary.0
|
|
9
11
|
*/
|
|
10
12
|
export class ScopeManager {
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* The metadata key `@injectable` writes a class's constructor dependencies under.
|
|
3
|
+
*
|
|
2
4
|
* @since 0.3.16-canary.0
|
|
3
5
|
*/
|
|
4
6
|
export const INJECTABLE_KEY: unique symbol = Symbol("di:injectable");
|
|
5
7
|
/**
|
|
8
|
+
* The metadata key `@postConstruct` and `@preDestroy` record method names under.
|
|
9
|
+
*
|
|
6
10
|
* @since 0.3.16-canary.0
|
|
7
11
|
*/
|
|
8
12
|
export const LIFECYCLE_KEY: unique symbol = Symbol("di:lifecycle");
|
|
9
13
|
/**
|
|
14
|
+
* The metadata key `@inject` accessors record their injection descriptors under.
|
|
15
|
+
*
|
|
10
16
|
* @since 0.3.16-canary.0
|
|
11
17
|
*/
|
|
12
18
|
export const INJECT_ACCESSOR_KEY: unique symbol = Symbol("di:inject-accessor");
|
|
@@ -3,6 +3,8 @@ import type { Token } from "#/core/token";
|
|
|
3
3
|
import type { MetadataReader } from "#/metadata/metadata-types";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
+
* The token a custom `MetadataReader` is bound to for a container to pick up.
|
|
7
|
+
*
|
|
6
8
|
* @since 0.3.16-canary.0
|
|
7
9
|
*/
|
|
8
10
|
export const MetadataReaderToken: Token<MetadataReader> = token<MetadataReader>("MetadataReader");
|
|
@@ -15,6 +15,8 @@ export interface ParamMetadata extends DependencySlot {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
+
* A class's declared constructor dependencies, as a `MetadataReader` reports them.
|
|
19
|
+
*
|
|
18
20
|
* @since 0.3.16-canary.0
|
|
19
21
|
*/
|
|
20
22
|
export interface ConstructorMetadata {
|
|
@@ -22,6 +24,8 @@ export interface ConstructorMetadata {
|
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
/**
|
|
27
|
+
* The `postConstruct` and `preDestroy` method names a class declares.
|
|
28
|
+
*
|
|
25
29
|
* @since 0.3.16-canary.0
|
|
26
30
|
*/
|
|
27
31
|
export interface LifecycleMetadata {
|
|
@@ -40,6 +44,8 @@ export interface MutableLifecycleMetadata {
|
|
|
40
44
|
}
|
|
41
45
|
|
|
42
46
|
/**
|
|
47
|
+
* The port a container reads class metadata through — constructor deps, lifecycle, and accessors.
|
|
48
|
+
*
|
|
43
49
|
* @since 0.3.16-canary.0
|
|
44
50
|
*/
|
|
45
51
|
export interface MetadataReader {
|
|
@@ -6,6 +6,8 @@ import type { ConstructorMetadata, LifecycleMetadata, MetadataReader } from "#/m
|
|
|
6
6
|
type AccessorEntry = { readonly key: string | symbol; readonly descriptor: InjectionDescriptor };
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
+
* The default `MetadataReader`, reading decorator metadata stored under `Symbol.metadata`.
|
|
10
|
+
*
|
|
9
11
|
* @since 0.3.16-canary.0
|
|
10
12
|
*/
|
|
11
13
|
export class SymbolMetadataReader implements MetadataReader {
|
|
@@ -117,6 +119,8 @@ function mergeUniqueNames(lists: Array<ReadonlyArray<string>>): Array<string> {
|
|
|
117
119
|
}
|
|
118
120
|
|
|
119
121
|
/**
|
|
122
|
+
* The shared reader a container falls back to when given no custom `MetadataReader`.
|
|
123
|
+
*
|
|
120
124
|
* @since 0.3.16-canary.0
|
|
121
125
|
*/
|
|
122
126
|
export const defaultMetadataReader: SymbolMetadataReader = new SymbolMetadataReader();
|
|
@@ -11,6 +11,8 @@ import type { LifecycleManager } from "#/lifecycle/lifecycle-manager";
|
|
|
11
11
|
import type { ClassIntrospector } from "#/resolution/cache/class-introspector";
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
+
* A per-binding cache of whether activation work — hooks or `@postConstruct` — is needed on resolve.
|
|
15
|
+
*
|
|
14
16
|
* @since 0.5.0-canary.8
|
|
15
17
|
*/
|
|
16
18
|
export class ActivationNeedCache {
|
|
@@ -39,6 +39,8 @@ const newNameToEntryMap = <Owner>(): Map<string, DefaultLookupEntry<Owner> | nul
|
|
|
39
39
|
const newTagToEntryMap = <Owner>(): Map<BindingTag, DefaultLookupEntry<Owner> | null> => new Map();
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
|
+
* A version-stamped cache of binding lookups by token, name, and tag across the container chain.
|
|
43
|
+
*
|
|
42
44
|
* @since 0.5.0-canary.9
|
|
43
45
|
*/
|
|
44
46
|
export class BindingLookupCache<Owner> {
|
|
@@ -16,6 +16,8 @@ import { UNOWNED_BRANCH } from "#/resolution/path/resolution-path";
|
|
|
16
16
|
// ── ResolutionContext implementation ─────────────────────────────────────────────────────────────────────────────────
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
+
* The engine surface a resolution context calls back into to resolve further dependencies.
|
|
20
|
+
*
|
|
19
21
|
* @since 0.3.16-canary.0
|
|
20
22
|
*/
|
|
21
23
|
export interface ResolverCallbacks {
|
|
@@ -60,6 +62,8 @@ export interface ResolverCallbacks {
|
|
|
60
62
|
}
|
|
61
63
|
|
|
62
64
|
/**
|
|
65
|
+
* The `ResolutionContext` handed to factories and hooks, backed by the engine's callbacks.
|
|
66
|
+
*
|
|
63
67
|
* @since 0.3.16-canary.0
|
|
64
68
|
*/
|
|
65
69
|
export class DefaultResolutionContext implements ResolutionContext {
|
|
@@ -312,6 +316,8 @@ class DefaultConstraintContext implements ConstraintContext {
|
|
|
312
316
|
}
|
|
313
317
|
|
|
314
318
|
/**
|
|
319
|
+
* Creates the resolution-stack frame for one in-flight resolve.
|
|
320
|
+
*
|
|
315
321
|
* @since 0.3.16-canary.0
|
|
316
322
|
*/
|
|
317
323
|
export function buildResolutionFrame(
|
|
@@ -161,6 +161,8 @@ export interface InstantiationPlanHost {
|
|
|
161
161
|
export type EscapeArity = "all" | "optional" | "single";
|
|
162
162
|
|
|
163
163
|
/**
|
|
164
|
+
* The compiler that flattens a class or resolved binding's dependencies into an instantiation plan.
|
|
165
|
+
*
|
|
164
166
|
* @since 0.3.16-canary.1
|
|
165
167
|
*/
|
|
166
168
|
export class InstantiationPlanCompiler {
|
|
@@ -7,6 +7,8 @@ import type { BindingConstraint, Constructor } from "#/core/types";
|
|
|
7
7
|
import { EmptyTagCriteriaError } from "#/errors/errors";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
+
* Matches when the direct parent frame resolves the given token.
|
|
11
|
+
*
|
|
10
12
|
* @since 0.3.16-canary.0
|
|
11
13
|
*/
|
|
12
14
|
export function whenParentIs(token: Token<unknown> | Constructor): BindingConstraint {
|
|
@@ -16,6 +18,8 @@ export function whenParentIs(token: Token<unknown> | Constructor): BindingConstr
|
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
/**
|
|
21
|
+
* Matches when there is no direct parent frame, or it resolves a different token.
|
|
22
|
+
*
|
|
19
23
|
* @since 0.3.16-canary.0
|
|
20
24
|
*/
|
|
21
25
|
export function whenNoParentIs(token: Token<unknown> | Constructor): BindingConstraint {
|
|
@@ -25,6 +29,8 @@ export function whenNoParentIs(token: Token<unknown> | Constructor): BindingCons
|
|
|
25
29
|
}
|
|
26
30
|
|
|
27
31
|
/**
|
|
32
|
+
* Matches when at least one ancestor frame resolves the given token.
|
|
33
|
+
*
|
|
28
34
|
* @since 0.3.16-canary.0
|
|
29
35
|
*/
|
|
30
36
|
export function whenAnyAncestorIs(token: Token<unknown> | Constructor): BindingConstraint {
|
|
@@ -34,6 +40,8 @@ export function whenAnyAncestorIs(token: Token<unknown> | Constructor): BindingC
|
|
|
34
40
|
}
|
|
35
41
|
|
|
36
42
|
/**
|
|
43
|
+
* Matches when no ancestor frame resolves the given token.
|
|
44
|
+
*
|
|
37
45
|
* @since 0.3.16-canary.0
|
|
38
46
|
*/
|
|
39
47
|
export function whenNoAncestorIs(token: Token<unknown> | Constructor): BindingConstraint {
|
|
@@ -43,6 +51,8 @@ export function whenNoAncestorIs(token: Token<unknown> | Constructor): BindingCo
|
|
|
43
51
|
}
|
|
44
52
|
|
|
45
53
|
/**
|
|
54
|
+
* Matches when the direct parent slot carries the given name.
|
|
55
|
+
*
|
|
46
56
|
* @since 0.3.16-canary.0
|
|
47
57
|
*/
|
|
48
58
|
export function whenParentNamed(name: string): BindingConstraint {
|
|
@@ -54,6 +64,8 @@ export function whenParentNamed(name: string): BindingConstraint {
|
|
|
54
64
|
}
|
|
55
65
|
|
|
56
66
|
/**
|
|
67
|
+
* Matches when at least one ancestor slot carries the given name.
|
|
68
|
+
*
|
|
57
69
|
* @since 0.3.16-canary.0
|
|
58
70
|
*/
|
|
59
71
|
export function whenAnyAncestorNamed(name: string): BindingConstraint {
|
|
@@ -65,6 +77,8 @@ export function whenAnyAncestorNamed(name: string): BindingConstraint {
|
|
|
65
77
|
}
|
|
66
78
|
|
|
67
79
|
/**
|
|
80
|
+
* Matches when the direct parent slot carries the given tag pair.
|
|
81
|
+
*
|
|
68
82
|
* @since 0.3.16-canary.0
|
|
69
83
|
*/
|
|
70
84
|
export function whenParentTagged(criterion: BindingTag): BindingConstraint {
|
|
@@ -73,6 +87,8 @@ export function whenParentTagged(criterion: BindingTag): BindingConstraint {
|
|
|
73
87
|
}
|
|
74
88
|
|
|
75
89
|
/**
|
|
90
|
+
* Matches when at least one ancestor slot carries the given tag pair.
|
|
91
|
+
*
|
|
76
92
|
* @since 0.3.16-canary.0
|
|
77
93
|
*/
|
|
78
94
|
export function whenAnyAncestorTagged(criterion: BindingTag): BindingConstraint {
|