@codefast/di 0.7.1 → 0.8.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 +40 -0
- package/README.md +242 -159
- package/dist/ambient/active-container.d.ts +1 -2
- package/dist/ambient/active-container.js +1 -2
- package/dist/container/binding-builders.d.ts +1 -2
- package/dist/container/binding-builders.js +5 -7
- package/dist/container/container.d.ts +1 -2
- package/dist/container/container.js +4 -6
- package/dist/core/binding-scope.d.ts +1 -2
- package/dist/core/binding-scope.js +1 -2
- package/dist/core/binding.d.ts +16 -4
- package/dist/core/binding.js +30 -6
- package/dist/core/constraint-requirement.d.ts +1 -2
- package/dist/core/constraint-requirement.js +1 -2
- package/dist/core/constructor-type.d.ts +1 -2
- package/dist/core/constructor-type.js +1 -2
- package/dist/core/map-upsert.d.ts +1 -2
- package/dist/core/map-upsert.js +1 -2
- package/dist/core/module.d.ts +1 -2
- package/dist/core/module.js +1 -2
- package/dist/core/registry.d.ts +1 -5
- package/dist/core/registry.js +15 -63
- package/dist/core/tag.d.ts +27 -2
- package/dist/core/tag.js +55 -13
- package/dist/core/token.d.ts +1 -2
- package/dist/core/token.js +1 -2
- package/dist/core/types.d.ts +1 -2
- package/dist/core/types.js +1 -2
- package/dist/decorators/inject.d.ts +1 -2
- package/dist/decorators/inject.js +1 -2
- package/dist/decorators/injectable.d.ts +1 -2
- package/dist/decorators/injectable.js +1 -2
- package/dist/decorators/lifecycle-decorators.d.ts +1 -2
- package/dist/decorators/lifecycle-decorators.js +1 -2
- package/dist/errors/diagnostics.d.ts +1 -2
- package/dist/errors/diagnostics.js +1 -2
- package/dist/errors/errors.d.ts +1 -2
- package/dist/errors/errors.js +29 -5
- package/dist/index.d.ts +2 -3
- package/dist/index.js +2 -3
- package/dist/injection/descriptor.d.ts +1 -2
- package/dist/injection/descriptor.js +1 -2
- package/dist/injection/resolve-options.d.ts +18 -14
- package/dist/injection/resolve-options.js +70 -17
- package/dist/introspection/dependency-graph.d.ts +1 -2
- package/dist/introspection/dependency-graph.js +23 -11
- package/dist/introspection/graph-adapters/cytoscape.d.ts +1 -2
- package/dist/introspection/graph-adapters/cytoscape.js +1 -2
- package/dist/introspection/graph-adapters/dot.d.ts +1 -2
- package/dist/introspection/graph-adapters/dot.js +1 -2
- package/dist/introspection/graph-adapters/mermaid.d.ts +1 -2
- package/dist/introspection/graph-adapters/mermaid.js +1 -2
- package/dist/introspection/graph-adapters/reactflow.d.ts +1 -2
- package/dist/introspection/graph-adapters/reactflow.js +1 -2
- package/dist/introspection/inspector.d.ts +1 -2
- package/dist/introspection/inspector.js +1 -2
- package/dist/lifecycle/lifecycle-manager.d.ts +1 -2
- package/dist/lifecycle/lifecycle-manager.js +1 -2
- package/dist/lifecycle/scope-manager.d.ts +1 -2
- package/dist/lifecycle/scope-manager.js +1 -2
- package/dist/metadata/metadata-keys.d.ts +1 -2
- package/dist/metadata/metadata-keys.js +1 -2
- package/dist/metadata/metadata-reader-token.d.ts +1 -2
- package/dist/metadata/metadata-reader-token.js +1 -2
- package/dist/metadata/metadata-types.d.ts +1 -2
- package/dist/metadata/metadata-types.js +1 -2
- package/dist/metadata/symbol-metadata-reader.d.ts +1 -2
- package/dist/metadata/symbol-metadata-reader.js +1 -2
- package/dist/metadata/verifying-metadata-reader.d.ts +1 -2
- package/dist/metadata/verifying-metadata-reader.js +1 -2
- package/dist/resolution/cache/activation-need.d.ts +1 -2
- package/dist/resolution/cache/activation-need.js +1 -2
- package/dist/resolution/cache/binding-lookup-cache.d.ts +2 -5
- package/dist/resolution/cache/binding-lookup-cache.js +2 -40
- package/dist/resolution/cache/class-introspector.d.ts +1 -2
- package/dist/resolution/cache/class-introspector.js +1 -2
- package/dist/resolution/context.d.ts +1 -2
- package/dist/resolution/context.js +1 -2
- package/dist/resolution/path/resolution-path.d.ts +1 -2
- package/dist/resolution/path/resolution-path.js +1 -2
- package/dist/resolution/plan/instantiation-plan.d.ts +5 -14
- package/dist/resolution/plan/instantiation-plan.js +10 -29
- package/dist/resolution/resolver.d.ts +13 -7
- package/dist/resolution/resolver.js +107 -143
- package/dist/resolution/select/binding-select.d.ts +5 -7
- package/dist/resolution/select/binding-select.js +19 -22
- package/dist/resolution/select/constraints.d.ts +1 -2
- package/dist/resolution/select/constraints.js +1 -2
- package/package.json +6 -58
- package/dist/ambient/active-container.d.ts.map +0 -1
- package/dist/ambient/active-container.js.map +0 -1
- package/dist/container/binding-builders.d.ts.map +0 -1
- package/dist/container/binding-builders.js.map +0 -1
- package/dist/container/container.d.ts.map +0 -1
- package/dist/container/container.js.map +0 -1
- package/dist/core/binding-scope.d.ts.map +0 -1
- package/dist/core/binding-scope.js.map +0 -1
- package/dist/core/binding.d.ts.map +0 -1
- package/dist/core/binding.js.map +0 -1
- package/dist/core/constraint-requirement.d.ts.map +0 -1
- package/dist/core/constraint-requirement.js.map +0 -1
- package/dist/core/constructor-type.d.ts.map +0 -1
- package/dist/core/constructor-type.js.map +0 -1
- package/dist/core/map-upsert.d.ts.map +0 -1
- package/dist/core/map-upsert.js.map +0 -1
- package/dist/core/module.d.ts.map +0 -1
- package/dist/core/module.js.map +0 -1
- package/dist/core/registry.d.ts.map +0 -1
- package/dist/core/registry.js.map +0 -1
- package/dist/core/tag.d.ts.map +0 -1
- package/dist/core/tag.js.map +0 -1
- package/dist/core/token.d.ts.map +0 -1
- package/dist/core/token.js.map +0 -1
- package/dist/core/types.d.ts.map +0 -1
- package/dist/core/types.js.map +0 -1
- package/dist/decorators/inject.d.ts.map +0 -1
- package/dist/decorators/inject.js.map +0 -1
- package/dist/decorators/injectable.d.ts.map +0 -1
- package/dist/decorators/injectable.js.map +0 -1
- package/dist/decorators/lifecycle-decorators.d.ts.map +0 -1
- package/dist/decorators/lifecycle-decorators.js.map +0 -1
- package/dist/errors/diagnostics.d.ts.map +0 -1
- package/dist/errors/diagnostics.js.map +0 -1
- package/dist/errors/errors.d.ts.map +0 -1
- package/dist/errors/errors.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/injection/descriptor.d.ts.map +0 -1
- package/dist/injection/descriptor.js.map +0 -1
- package/dist/injection/resolve-options.d.ts.map +0 -1
- package/dist/injection/resolve-options.js.map +0 -1
- package/dist/introspection/dependency-graph.d.ts.map +0 -1
- package/dist/introspection/dependency-graph.js.map +0 -1
- package/dist/introspection/graph-adapters/cytoscape.d.ts.map +0 -1
- package/dist/introspection/graph-adapters/cytoscape.js.map +0 -1
- package/dist/introspection/graph-adapters/dot.d.ts.map +0 -1
- package/dist/introspection/graph-adapters/dot.js.map +0 -1
- package/dist/introspection/graph-adapters/mermaid.d.ts.map +0 -1
- package/dist/introspection/graph-adapters/mermaid.js.map +0 -1
- package/dist/introspection/graph-adapters/reactflow.d.ts.map +0 -1
- package/dist/introspection/graph-adapters/reactflow.js.map +0 -1
- package/dist/introspection/inspector.d.ts.map +0 -1
- package/dist/introspection/inspector.js.map +0 -1
- package/dist/lifecycle/lifecycle-manager.d.ts.map +0 -1
- package/dist/lifecycle/lifecycle-manager.js.map +0 -1
- package/dist/lifecycle/scope-manager.d.ts.map +0 -1
- package/dist/lifecycle/scope-manager.js.map +0 -1
- package/dist/metadata/metadata-keys.d.ts.map +0 -1
- package/dist/metadata/metadata-keys.js.map +0 -1
- package/dist/metadata/metadata-reader-token.d.ts.map +0 -1
- package/dist/metadata/metadata-reader-token.js.map +0 -1
- package/dist/metadata/metadata-types.d.ts.map +0 -1
- package/dist/metadata/metadata-types.js.map +0 -1
- package/dist/metadata/symbol-metadata-reader.d.ts.map +0 -1
- package/dist/metadata/symbol-metadata-reader.js.map +0 -1
- package/dist/metadata/verifying-metadata-reader.d.ts.map +0 -1
- package/dist/metadata/verifying-metadata-reader.js.map +0 -1
- package/dist/resolution/cache/activation-need.d.ts.map +0 -1
- package/dist/resolution/cache/activation-need.js.map +0 -1
- package/dist/resolution/cache/binding-lookup-cache.d.ts.map +0 -1
- package/dist/resolution/cache/binding-lookup-cache.js.map +0 -1
- package/dist/resolution/cache/class-introspector.d.ts.map +0 -1
- package/dist/resolution/cache/class-introspector.js.map +0 -1
- package/dist/resolution/context.d.ts.map +0 -1
- package/dist/resolution/context.js.map +0 -1
- package/dist/resolution/path/resolution-path.d.ts.map +0 -1
- package/dist/resolution/path/resolution-path.js.map +0 -1
- package/dist/resolution/plan/instantiation-plan.d.ts.map +0 -1
- package/dist/resolution/plan/instantiation-plan.js.map +0 -1
- package/dist/resolution/resolver.d.ts.map +0 -1
- package/dist/resolution/resolver.js.map +0 -1
- package/dist/resolution/select/binding-select.d.ts.map +0 -1
- package/dist/resolution/select/binding-select.js.map +0 -1
- package/dist/resolution/select/constraints.d.ts.map +0 -1
- package/dist/resolution/select/constraints.js.map +0 -1
- package/src/ambient/active-container.ts +0 -69
- package/src/container/binding-builders.ts +0 -332
- package/src/container/container.ts +0 -973
- package/src/core/binding-scope.ts +0 -15
- package/src/core/binding.ts +0 -477
- package/src/core/constraint-requirement.ts +0 -94
- package/src/core/constructor-type.ts +0 -18
- package/src/core/map-upsert.ts +0 -53
- package/src/core/module.ts +0 -117
- package/src/core/registry.ts +0 -371
- package/src/core/tag.ts +0 -158
- package/src/core/token.ts +0 -31
- package/src/core/types.ts +0 -149
- package/src/decorators/inject.ts +0 -101
- package/src/decorators/injectable.ts +0 -134
- package/src/decorators/lifecycle-decorators.ts +0 -43
- package/src/errors/diagnostics.ts +0 -45
- package/src/errors/errors.ts +0 -476
- package/src/index.ts +0 -139
- package/src/injection/descriptor.ts +0 -218
- package/src/injection/resolve-options.ts +0 -144
- package/src/introspection/dependency-graph.ts +0 -282
- package/src/introspection/graph-adapters/cytoscape.ts +0 -78
- package/src/introspection/graph-adapters/dot.ts +0 -32
- package/src/introspection/graph-adapters/mermaid.ts +0 -61
- package/src/introspection/graph-adapters/reactflow.ts +0 -84
- package/src/introspection/inspector.ts +0 -134
- package/src/lifecycle/lifecycle-manager.ts +0 -272
- package/src/lifecycle/scope-manager.ts +0 -158
- package/src/metadata/metadata-keys.ts +0 -28
- package/src/metadata/metadata-reader-token.ts +0 -10
- package/src/metadata/metadata-types.ts +0 -57
- package/src/metadata/symbol-metadata-reader.ts +0 -126
- package/src/metadata/verifying-metadata-reader.ts +0 -41
- package/src/resolution/cache/activation-need.ts +0 -87
- package/src/resolution/cache/binding-lookup-cache.ts +0 -209
- package/src/resolution/cache/class-introspector.ts +0 -256
- package/src/resolution/context.ts +0 -331
- package/src/resolution/path/resolution-path.ts +0 -167
- package/src/resolution/plan/instantiation-plan.ts +0 -617
- package/src/resolution/resolver.ts +0 -1675
- package/src/resolution/select/binding-select.ts +0 -210
- package/src/resolution/select/constraints.ts +0 -146
package/dist/errors/errors.d.ts
CHANGED
|
@@ -289,5 +289,4 @@ export declare class AsyncActivationError extends DiError {
|
|
|
289
289
|
readonly hookKind: "postConstruct" | "onActivation";
|
|
290
290
|
readonly methodName: string | undefined;
|
|
291
291
|
constructor(tokenName: string, hookKind: "postConstruct" | "onActivation", methodName?: string);
|
|
292
|
-
}
|
|
293
|
-
//# sourceMappingURL=errors.d.ts.map
|
|
292
|
+
}
|
package/dist/errors/errors.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { slotName } from "#/core/tag";
|
|
1
2
|
/**
|
|
2
3
|
* Base class for every error the library throws, each carrying a machine-readable `code`.
|
|
3
4
|
*
|
|
@@ -34,11 +35,35 @@ export class TokenNotBoundError extends DiError {
|
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
37
|
// Options carry caller values a tag may hold — a bigint or a circular object must not make the
|
|
37
|
-
// diagnostic itself throw and mask the real error.
|
|
38
|
+
// diagnostic itself throw and mask the real error. The reserved criterion renders as `name`.
|
|
38
39
|
function describeResolveOptions(options) {
|
|
39
40
|
try {
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
let name = options.name;
|
|
42
|
+
const criteria = [];
|
|
43
|
+
const add = (criterion) => {
|
|
44
|
+
if (criterion.key === slotName) {
|
|
45
|
+
name ??= String(criterion.value);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
criteria.push(`${criterion.key.name}=${String(criterion.value)}`);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
if (options.tag !== undefined) {
|
|
52
|
+
add(options.tag);
|
|
53
|
+
}
|
|
54
|
+
if (options.tags !== undefined) {
|
|
55
|
+
for (const criterion of options.tags) {
|
|
56
|
+
add(criterion);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const display = {};
|
|
60
|
+
if (name !== undefined) {
|
|
61
|
+
display.name = name;
|
|
62
|
+
}
|
|
63
|
+
if (criteria.length > 0) {
|
|
64
|
+
display.tags = criteria;
|
|
65
|
+
}
|
|
66
|
+
return JSON.stringify(display) ?? "undefined";
|
|
42
67
|
}
|
|
43
68
|
catch {
|
|
44
69
|
return "[unserializable options]";
|
|
@@ -377,5 +402,4 @@ export class AsyncActivationError extends DiError {
|
|
|
377
402
|
this.hookKind = hookKind;
|
|
378
403
|
this.methodName = methodName;
|
|
379
404
|
}
|
|
380
|
-
}
|
|
381
|
-
//# sourceMappingURL=errors.js.map
|
|
405
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export type { ActivationHandler, BindingConstraint, BindingIdentifier, BindingKind, BindingScope, BindingTag, ConstraintContext, Constructor, DependencyKey, DeactivationHandler, ResolutionFrame, ResolveOptions, ResolutionContext, TokenValue, } from "#/core/types";
|
|
2
2
|
export { token, tokenName } from "#/core/token";
|
|
3
3
|
export type { Token } from "#/core/token";
|
|
4
|
-
export { coversTagKeys, NO_TAG_KEYS, tag, tagKeyMaskOf } from "#/core/tag";
|
|
4
|
+
export { coversTagKeys, NO_TAG_KEYS, slotName, tag, tagKeyMaskOf } from "#/core/tag";
|
|
5
5
|
export type { TagKey, TagKeyMask } from "#/core/tag";
|
|
6
6
|
export type { AliasBindingBuilder, BindToBuilder, BindingBuilder, ConstantBindingBuilder, ScopedBindingBuilder, SingletonBindingBuilder, SingletonLifecycleBuilder, SlotConstrainedBuilder, TransientBindingBuilder, } from "#/core/binding";
|
|
7
7
|
export { Container } from "#/container/container";
|
|
@@ -32,5 +32,4 @@ export { toCytoscapeGraph } from "#/introspection/graph-adapters/cytoscape";
|
|
|
32
32
|
export type { CytoscapeEdge, CytoscapeElements, CytoscapeNode } from "#/introspection/graph-adapters/cytoscape";
|
|
33
33
|
export { toReactFlowGraph } from "#/introspection/graph-adapters/reactflow";
|
|
34
34
|
export type { ReactFlowEdge, ReactFlowGraph, ReactFlowNode } from "#/introspection/graph-adapters/reactflow";
|
|
35
|
-
export { toMermaidGraph } from "#/introspection/graph-adapters/mermaid";
|
|
36
|
-
//# sourceMappingURL=index.d.ts.map
|
|
35
|
+
export { toMermaidGraph } from "#/introspection/graph-adapters/mermaid";
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Token
|
|
2
2
|
export { token, tokenName } from "#/core/token";
|
|
3
3
|
// Tag — the interned slot criteria a `whenTagged` and a resolve both take
|
|
4
|
-
export { coversTagKeys, NO_TAG_KEYS, tag, tagKeyMaskOf } from "#/core/tag";
|
|
4
|
+
export { coversTagKeys, NO_TAG_KEYS, slotName, tag, tagKeyMaskOf } from "#/core/tag";
|
|
5
5
|
// Container
|
|
6
6
|
export { Container } from "#/container/container";
|
|
7
7
|
// Ambient container — the context an `@inject` accessor initializer resolves from. `resolution/context`
|
|
@@ -30,5 +30,4 @@ export { AmbiguousBindingError, AsyncActivationError, AsyncDeactivationError, As
|
|
|
30
30
|
export { toDotGraph } from "#/introspection/graph-adapters/dot";
|
|
31
31
|
export { toCytoscapeGraph } from "#/introspection/graph-adapters/cytoscape";
|
|
32
32
|
export { toReactFlowGraph } from "#/introspection/graph-adapters/reactflow";
|
|
33
|
-
export { toMermaidGraph } from "#/introspection/graph-adapters/mermaid";
|
|
34
|
-
//# sourceMappingURL=index.js.map
|
|
33
|
+
export { toMermaidGraph } from "#/introspection/graph-adapters/mermaid";
|
|
@@ -87,5 +87,4 @@ export declare function optional<Value>(token: Token<Value> | Constructor<Value>
|
|
|
87
87
|
* @since 0.3.16-canary.0
|
|
88
88
|
*/
|
|
89
89
|
export declare function injectAll<Value>(token: Token<Value> | Constructor<Value>, options?: InjectOptions): InjectionDescriptor<Array<Value>>;
|
|
90
|
-
export {};
|
|
91
|
-
//# sourceMappingURL=descriptor.d.ts.map
|
|
90
|
+
export {};
|
|
@@ -17,22 +17,15 @@ export interface DependencySlot {
|
|
|
17
17
|
readonly tags?: ReadonlyArray<BindingTag> | undefined;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
20
|
+
* The lone criterion of a request that carries exactly one, whatever its spelling — the shape the
|
|
21
|
+
* registry has a direct index for.
|
|
21
22
|
*
|
|
22
|
-
* @
|
|
23
|
-
|
|
24
|
-
export declare function isNameOnlyOptions(options: ResolveOptions): options is ResolveOptions & {
|
|
25
|
-
name: string;
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* The lone tag of a request that asks for exactly one, written either way — the shape the registry
|
|
29
|
-
* has a direct tag index for.
|
|
30
|
-
*
|
|
31
|
-
* @remarks Both spellings answer here, so the index is not something one of them silently misses.
|
|
23
|
+
* @remarks Every spelling answers here, so the index is not something one of them silently misses;
|
|
24
|
+
* a name folds to the reserved `slotName` criterion, making the name lane the tag lane.
|
|
32
25
|
*
|
|
33
26
|
* @since 0.5.0-canary.9
|
|
34
27
|
*/
|
|
35
|
-
export declare function
|
|
28
|
+
export declare function singleCriterionOnlyOf(options: ResolveOptions | undefined): BindingTag | undefined;
|
|
36
29
|
/**
|
|
37
30
|
* Builds a {@link ResolveOptions} safe for `exactOptionalPropertyTypes`:
|
|
38
31
|
* omits keys instead of assigning `undefined`.
|
|
@@ -50,6 +43,18 @@ export declare function injectionSlotToResolveOptions(injectionSlot: Pick<Depend
|
|
|
50
43
|
* @since 0.6.0
|
|
51
44
|
*/
|
|
52
45
|
export declare function resolveOptionsForSlot(injectionSlot: DependencySlot): ResolveOptions | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* The lone criterion a dependency's fixed criteria fold to, memoized on the slot like its options —
|
|
48
|
+
* `null` means the fold answered "none".
|
|
49
|
+
*
|
|
50
|
+
* @remarks A slot's criteria never change after declaration, so the fold happens once per slot
|
|
51
|
+
* rather than per hop — which is what keeps a named dependency's resolve off the intern map. A
|
|
52
|
+
* lone name whose criterion is not interned yet is left unmemoized: a later `whenNamed` binding
|
|
53
|
+
* mints it, and the next fold must see that.
|
|
54
|
+
*
|
|
55
|
+
* @since 0.8.0
|
|
56
|
+
*/
|
|
57
|
+
export declare function singleCriterionForSlot(injectionSlot: DependencySlot): BindingTag | null;
|
|
53
58
|
/**
|
|
54
59
|
* Resolve options derived from a binding slot (tags may be empty; omits when nothing to match).
|
|
55
60
|
*
|
|
@@ -62,5 +67,4 @@ export declare function resolveOptionsForSlot(injectionSlot: DependencySlot): Re
|
|
|
62
67
|
export declare function bindingSlotToResolveOptions(bindingSlot: {
|
|
63
68
|
readonly name?: string | undefined;
|
|
64
69
|
readonly tags?: ReadonlyArray<BindingTag> | undefined;
|
|
65
|
-
}): ResolveOptions | undefined;
|
|
66
|
-
//# sourceMappingURL=resolve-options.d.ts.map
|
|
70
|
+
}): ResolveOptions | undefined;
|
|
@@ -1,31 +1,36 @@
|
|
|
1
|
+
import { slotName, slotNameCriterionOf } from "#/core/tag";
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
+
* The lone criterion of a request that carries exactly one, whatever its spelling — the shape the
|
|
4
|
+
* registry has a direct index for.
|
|
3
5
|
*
|
|
4
|
-
* @
|
|
5
|
-
|
|
6
|
-
export function isNameOnlyOptions(options) {
|
|
7
|
-
return (options.name !== undefined && options.tag === undefined && (options.tags === undefined || options.tags.length === 0));
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* The lone tag of a request that asks for exactly one, written either way — the shape the registry
|
|
11
|
-
* has a direct tag index for.
|
|
12
|
-
*
|
|
13
|
-
* @remarks Both spellings answer here, so the index is not something one of them silently misses.
|
|
6
|
+
* @remarks Every spelling answers here, so the index is not something one of them silently misses;
|
|
7
|
+
* a name folds to the reserved `slotName` criterion, making the name lane the tag lane.
|
|
14
8
|
*
|
|
15
9
|
* @since 0.5.0-canary.9
|
|
16
10
|
*/
|
|
17
|
-
export function
|
|
18
|
-
if (options
|
|
11
|
+
export function singleCriterionOnlyOf(options) {
|
|
12
|
+
if (options === undefined) {
|
|
19
13
|
return undefined;
|
|
20
14
|
}
|
|
15
|
+
if (options.name !== undefined) {
|
|
16
|
+
return loneNameCriterionOf(options);
|
|
17
|
+
}
|
|
21
18
|
const listed = options.tags;
|
|
22
19
|
const shorthand = options.tag;
|
|
23
20
|
if (shorthand !== undefined) {
|
|
24
|
-
// Both sources present means the request carries two tags, which no single-tag index can answer.
|
|
25
21
|
return listed === undefined || listed.length === 0 ? shorthand : undefined;
|
|
26
22
|
}
|
|
27
23
|
return listed !== undefined && listed.length === 1 ? listed[0] : undefined;
|
|
28
24
|
}
|
|
25
|
+
/** The name spelling's half of the fold, kept apart so the common body stays small enough to inline. */
|
|
26
|
+
function loneNameCriterionOf(options) {
|
|
27
|
+
// A name next to any tag means the request carries two criteria, which no single index answers.
|
|
28
|
+
if (options.tag !== undefined || (options.tags !== undefined && options.tags.length > 0)) {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
// Read, not minted: a request must not retain a name no binding ever declared.
|
|
32
|
+
return slotNameCriterionOf(options.name);
|
|
33
|
+
}
|
|
29
34
|
/** Shared core: build a ResolveOptions from already-normalised name + tags. */
|
|
30
35
|
function buildOptions(name, tags) {
|
|
31
36
|
if (name === undefined && tags === undefined) {
|
|
@@ -51,6 +56,8 @@ export function injectionSlotToResolveOptions(injectionSlot) {
|
|
|
51
56
|
}
|
|
52
57
|
/** Where a slot's derived options are memoized, so the same object is handed out every resolve. */
|
|
53
58
|
const MEMOIZED_RESOLVE_OPTIONS = Symbol("di:resolve-options");
|
|
59
|
+
/** Where a slot's folded lone criterion is memoized — `null` records "computed: none". */
|
|
60
|
+
const MEMOIZED_SINGLE_CRITERION = Symbol("di:single-criterion");
|
|
54
61
|
/**
|
|
55
62
|
* The options a dependency resolves with — one object per slot, since a slot's criteria are fixed
|
|
56
63
|
* when it is declared.
|
|
@@ -85,6 +92,41 @@ function memoizeResolveOptions(slot, name, tags) {
|
|
|
85
92
|
}
|
|
86
93
|
return built;
|
|
87
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* The lone criterion a dependency's fixed criteria fold to, memoized on the slot like its options —
|
|
97
|
+
* `null` means the fold answered "none".
|
|
98
|
+
*
|
|
99
|
+
* @remarks A slot's criteria never change after declaration, so the fold happens once per slot
|
|
100
|
+
* rather than per hop — which is what keeps a named dependency's resolve off the intern map. A
|
|
101
|
+
* lone name whose criterion is not interned yet is left unmemoized: a later `whenNamed` binding
|
|
102
|
+
* mints it, and the next fold must see that.
|
|
103
|
+
*
|
|
104
|
+
* @since 0.8.0
|
|
105
|
+
*/
|
|
106
|
+
export function singleCriterionForSlot(injectionSlot) {
|
|
107
|
+
const slot = injectionSlot;
|
|
108
|
+
const memoized = slot[MEMOIZED_SINGLE_CRITERION];
|
|
109
|
+
if (memoized !== undefined) {
|
|
110
|
+
return memoized;
|
|
111
|
+
}
|
|
112
|
+
const options = resolveOptionsForSlot(injectionSlot);
|
|
113
|
+
const criterion = singleCriterionOnlyOf(options);
|
|
114
|
+
const folded = criterion ?? null;
|
|
115
|
+
if (criterion !== undefined || !isLoneNameOptions(options)) {
|
|
116
|
+
try {
|
|
117
|
+
slot[MEMOIZED_SINGLE_CRITERION] = folded;
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
// A frozen slot re-folds on every hop rather than throwing.
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return folded;
|
|
124
|
+
}
|
|
125
|
+
/** A slot request whose only criterion is a name — the one shape whose fold can change after a bind. */
|
|
126
|
+
function isLoneNameOptions(options) {
|
|
127
|
+
// Slot-derived options never carry the `tag` shorthand — `buildOptions` folds it into `tags`.
|
|
128
|
+
return (options !== undefined && options.name !== undefined && (options.tags === undefined || options.tags.length === 0));
|
|
129
|
+
}
|
|
88
130
|
/**
|
|
89
131
|
* Resolve options derived from a binding slot (tags may be empty; omits when nothing to match).
|
|
90
132
|
*
|
|
@@ -96,6 +138,17 @@ function memoizeResolveOptions(slot, name, tags) {
|
|
|
96
138
|
*/
|
|
97
139
|
export function bindingSlotToResolveOptions(bindingSlot) {
|
|
98
140
|
const tags = bindingSlot.tags;
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
141
|
+
let name = bindingSlot.name;
|
|
142
|
+
let criteria = tags !== undefined && tags.length > 0 ? tags : undefined;
|
|
143
|
+
if (criteria !== undefined) {
|
|
144
|
+
// A reserved criterion folds into `name` — carried in `tags` it would be said twice or, on a
|
|
145
|
+
// descriptor that spells its name as a tag, not at all.
|
|
146
|
+
const reserved = criteria.find((criterion) => criterion.key === slotName);
|
|
147
|
+
if (reserved !== undefined) {
|
|
148
|
+
name ??= reserved.value;
|
|
149
|
+
const rest = criteria.filter((criterion) => criterion.key !== slotName);
|
|
150
|
+
criteria = rest.length > 0 ? rest : undefined;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return buildOptions(name, criteria);
|
|
154
|
+
}
|
|
@@ -53,5 +53,4 @@ export interface GraphOptions {
|
|
|
53
53
|
*
|
|
54
54
|
* @since 0.3.16-canary.0
|
|
55
55
|
*/
|
|
56
|
-
export declare function buildDependencyGraph(registry: BindingRegistry, metadataReader: MetadataReader, options: GraphOptions | undefined, parentRegistry?: BindingRegistry): ContainerGraphJson;
|
|
57
|
-
//# sourceMappingURL=dependency-graph.d.ts.map
|
|
56
|
+
export declare function buildDependencyGraph(registry: BindingRegistry, metadataReader: MetadataReader, options: GraphOptions | undefined, parentRegistry?: BindingRegistry): ContainerGraphJson;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { effectiveBindingScope } from "#/core/binding-scope";
|
|
2
|
+
import { slotName } from "#/core/tag";
|
|
2
3
|
import { tokenName } from "#/core/token";
|
|
3
4
|
import { bindingSlotToResolveOptions } from "#/injection/resolve-options";
|
|
4
5
|
import { matchesSlot } from "#/resolution/select/binding-select";
|
|
@@ -26,11 +27,21 @@ function matchingTargets(candidates, ref) {
|
|
|
26
27
|
}
|
|
27
28
|
return candidates.filter((candidate) => matchesSlot(candidate.slot, criterion));
|
|
28
29
|
}
|
|
30
|
+
/** The name a dependency asks for, whichever spelling carries it. */
|
|
31
|
+
function refSlotName(ref) {
|
|
32
|
+
if (ref.name !== undefined) {
|
|
33
|
+
return ref.name;
|
|
34
|
+
}
|
|
35
|
+
const reserved = ref.tags?.find((criterion) => criterion.key === slotName);
|
|
36
|
+
return reserved === undefined ? undefined : String(reserved.value);
|
|
37
|
+
}
|
|
29
38
|
function edgeLabel(ref, index) {
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
39
|
+
const name = refSlotName(ref);
|
|
40
|
+
const firstPlainTag = ref.tags?.find((criterion) => criterion.key !== slotName);
|
|
41
|
+
const criterion = name !== undefined
|
|
42
|
+
? `name:${name}`
|
|
43
|
+
: firstPlainTag !== undefined
|
|
44
|
+
? `tag:${firstPlainTag.key.name}=${String(firstPlainTag.value)}`
|
|
34
45
|
: `[${index}]`;
|
|
35
46
|
return ref.optional ? `${criterion} optional` : criterion;
|
|
36
47
|
}
|
|
@@ -70,27 +81,29 @@ function addDependencyEdges(accumulator, from, ref, index, lookup) {
|
|
|
70
81
|
if (!ref.optional) {
|
|
71
82
|
return;
|
|
72
83
|
}
|
|
84
|
+
const unboundSlotName = refSlotName(ref);
|
|
73
85
|
accumulator.edges.push({
|
|
74
86
|
from,
|
|
75
87
|
to: unboundNodeIdFor(accumulator, ref.token),
|
|
76
88
|
label,
|
|
77
89
|
optional: true,
|
|
78
|
-
...(
|
|
90
|
+
...(unboundSlotName !== undefined ? { slotName: unboundSlotName } : {}),
|
|
79
91
|
});
|
|
80
92
|
return;
|
|
81
93
|
}
|
|
94
|
+
const requestedName = refSlotName(ref);
|
|
82
95
|
for (const target of targets) {
|
|
83
96
|
// A multi dep with no criterion of its own fans out — each edge names the slot it hits.
|
|
84
|
-
const
|
|
85
|
-
const perTargetLabel = ref.multi &&
|
|
86
|
-
? edgeLabel({ ...ref, name:
|
|
97
|
+
const edgeSlotName = target.slot.name ?? requestedName;
|
|
98
|
+
const perTargetLabel = ref.multi && requestedName === undefined && edgeSlotName !== undefined
|
|
99
|
+
? edgeLabel({ ...ref, name: edgeSlotName }, index)
|
|
87
100
|
: label;
|
|
88
101
|
accumulator.edges.push({
|
|
89
102
|
from,
|
|
90
103
|
to: target.id,
|
|
91
104
|
label: perTargetLabel,
|
|
92
105
|
optional: ref.optional,
|
|
93
|
-
...(
|
|
106
|
+
...(edgeSlotName !== undefined ? { slotName: edgeSlotName } : {}),
|
|
94
107
|
});
|
|
95
108
|
}
|
|
96
109
|
}
|
|
@@ -145,5 +158,4 @@ export function buildDependencyGraph(registry, metadataReader, options, parentRe
|
|
|
145
158
|
addRegistryBindings(accumulator, parentRegistry, metadataReader, true);
|
|
146
159
|
}
|
|
147
160
|
return { nodes: accumulator.nodes, edges: accumulator.edges, includesParent };
|
|
148
|
-
}
|
|
149
|
-
//# sourceMappingURL=dependency-graph.js.map
|
|
161
|
+
}
|
|
@@ -40,5 +40,4 @@ export type CytoscapeElements = ReadonlyArray<CytoscapeNode | CytoscapeEdge>;
|
|
|
40
40
|
*
|
|
41
41
|
* @since 0.3.16-canary.0
|
|
42
42
|
*/
|
|
43
|
-
export declare function toCytoscapeGraph(graph: ContainerGraphJson): CytoscapeElements;
|
|
44
|
-
//# sourceMappingURL=cytoscape.d.ts.map
|
|
43
|
+
export declare function toCytoscapeGraph(graph: ContainerGraphJson): CytoscapeElements;
|
|
@@ -4,5 +4,4 @@ import type { ContainerGraphJson } from "#/introspection/dependency-graph";
|
|
|
4
4
|
*
|
|
5
5
|
* @since 0.3.16-canary.0
|
|
6
6
|
*/
|
|
7
|
-
export declare function toDotGraph(graph: ContainerGraphJson): string;
|
|
8
|
-
//# sourceMappingURL=dot.d.ts.map
|
|
7
|
+
export declare function toDotGraph(graph: ContainerGraphJson): string;
|
|
@@ -5,5 +5,4 @@ import type { ContainerGraphJson } from "#/introspection/dependency-graph";
|
|
|
5
5
|
*
|
|
6
6
|
* @since 0.6.0
|
|
7
7
|
*/
|
|
8
|
-
export declare function toMermaidGraph(graph: ContainerGraphJson): string;
|
|
9
|
-
//# sourceMappingURL=mermaid.d.ts.map
|
|
8
|
+
export declare function toMermaidGraph(graph: ContainerGraphJson): string;
|
|
@@ -45,5 +45,4 @@ export interface ReactFlowGraph {
|
|
|
45
45
|
*
|
|
46
46
|
* @since 0.5.0-canary.7
|
|
47
47
|
*/
|
|
48
|
-
export declare function toReactFlowGraph(graph: ContainerGraphJson): ReactFlowGraph;
|
|
49
|
-
//# sourceMappingURL=reactflow.d.ts.map
|
|
48
|
+
export declare function toReactFlowGraph(graph: ContainerGraphJson): ReactFlowGraph;
|
|
@@ -40,5 +40,4 @@ export declare class Inspector {
|
|
|
40
40
|
lookupBindings<Value>(token: Token<Value> | Constructor<Value>): ReadonlyArray<BindingSnapshot>;
|
|
41
41
|
has(token: Token<unknown> | Constructor, options?: ResolveOptions, parentHas?: () => boolean): boolean;
|
|
42
42
|
hasOwn(token: Token<unknown> | Constructor, options?: ResolveOptions): boolean;
|
|
43
|
-
}
|
|
44
|
-
//# sourceMappingURL=inspector.d.ts.map
|
|
43
|
+
}
|
|
@@ -25,5 +25,4 @@ export declare class LifecycleManager {
|
|
|
25
25
|
runDeactivationSync<Value>(binding: Binding<Value>, instance: Value, metadataReader: MetadataReader): void;
|
|
26
26
|
/** Whether the deferred activation-hook table has had to be built. */
|
|
27
27
|
get isActivationTableBuilt(): boolean;
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=lifecycle-manager.d.ts.map
|
|
28
|
+
}
|
|
@@ -24,5 +24,4 @@ export const INJECT_ACCESSOR_KEY = Symbol("di:inject-accessor");
|
|
|
24
24
|
*
|
|
25
25
|
* @since 0.3.16-canary.0
|
|
26
26
|
*/
|
|
27
|
-
export const METADATA_SYMBOL = Symbol.metadata ?? Symbol.for("Symbol.metadata");
|
|
28
|
-
//# sourceMappingURL=metadata-keys.js.map
|
|
27
|
+
export const METADATA_SYMBOL = Symbol.metadata ?? Symbol.for("Symbol.metadata");
|
|
@@ -5,5 +5,4 @@ import type { MetadataReader } from "#/metadata/metadata-types";
|
|
|
5
5
|
*
|
|
6
6
|
* @since 0.3.16-canary.0
|
|
7
7
|
*/
|
|
8
|
-
export declare const MetadataReaderToken: Token<MetadataReader>;
|
|
9
|
-
//# sourceMappingURL=metadata-reader-token.d.ts.map
|
|
8
|
+
export declare const MetadataReaderToken: Token<MetadataReader>;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export {};
|
|
2
|
-
//# sourceMappingURL=metadata-types.js.map
|
|
1
|
+
export {};
|
|
@@ -114,5 +114,4 @@ function mergeUniqueNames(lists) {
|
|
|
114
114
|
*
|
|
115
115
|
* @since 0.3.16-canary.0
|
|
116
116
|
*/
|
|
117
|
-
export const defaultMetadataReader = new SymbolMetadataReader();
|
|
118
|
-
//# sourceMappingURL=symbol-metadata-reader.js.map
|
|
117
|
+
export const defaultMetadataReader = new SymbolMetadataReader();
|
|
@@ -12,5 +12,4 @@ import type { MetadataReader } from "#/metadata/metadata-types";
|
|
|
12
12
|
*
|
|
13
13
|
* @since 0.6.0
|
|
14
14
|
*/
|
|
15
|
-
export declare function verifyingMetadataReader(reader: MetadataReader): MetadataReader;
|
|
16
|
-
//# sourceMappingURL=verifying-metadata-reader.d.ts.map
|
|
15
|
+
export declare function verifyingMetadataReader(reader: MetadataReader): MetadataReader;
|
|
@@ -28,7 +28,7 @@ export interface DefaultLookupEntry<Owner> {
|
|
|
28
28
|
*/
|
|
29
29
|
export declare const ALIAS_HOP_LIMIT = 32;
|
|
30
30
|
/**
|
|
31
|
-
* A version-stamped cache of binding lookups by token
|
|
31
|
+
* A version-stamped cache of binding lookups by token and criterion across the container chain.
|
|
32
32
|
*
|
|
33
33
|
* @since 0.5.0-canary.9
|
|
34
34
|
*/
|
|
@@ -39,9 +39,6 @@ export declare class BindingLookupCache<Owner> {
|
|
|
39
39
|
chainVersion(): number;
|
|
40
40
|
/** `null` when the token's shape needs the full selection path. */
|
|
41
41
|
defaultEntry(token: Token<unknown> | Constructor): DefaultLookupEntry<Owner> | null;
|
|
42
|
-
/** `null` when the name's shape needs the full selection path. */
|
|
43
|
-
namedEntry(token: Token<unknown> | Constructor, name: string): DefaultLookupEntry<Owner> | null;
|
|
44
42
|
/** `null` when the tag's shape needs the full selection path. */
|
|
45
43
|
taggedEntry(token: Token<unknown> | Constructor, tag: BindingTag): DefaultLookupEntry<Owner> | null;
|
|
46
|
-
}
|
|
47
|
-
//# sourceMappingURL=binding-lookup-cache.d.ts.map
|
|
44
|
+
}
|