@codefast/di 0.9.0 → 0.10.0
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 +137 -0
- package/README.md +3 -3
- package/dist/ambient/active-container.d.ts +13 -0
- package/dist/ambient/active-container.js +24 -0
- package/dist/container/binding-builders.d.ts +31 -9
- package/dist/container/binding-builders.js +155 -87
- package/dist/container/container.d.ts +2 -2
- package/dist/container/container.js +33 -16
- package/dist/core/binding.d.ts +36 -43
- package/dist/core/binding.js +11 -37
- package/dist/core/registry.d.ts +47 -4
- package/dist/core/registry.js +361 -159
- package/dist/core/state-epoch.d.ts +16 -0
- package/dist/core/state-epoch.js +21 -0
- package/dist/core/types.d.ts +7 -4
- package/dist/errors/diagnostics.d.ts +2 -0
- package/dist/errors/errors.d.ts +29 -0
- package/dist/errors/errors.js +35 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/injection/descriptor.d.ts +6 -4
- package/dist/injection/descriptor.js +3 -1
- package/dist/injection/resolve-options.d.ts +6 -0
- package/dist/injection/resolve-options.js +16 -0
- package/dist/introspection/dependency-graph.js +10 -5
- package/dist/introspection/inspector.d.ts +3 -1
- package/dist/introspection/inspector.js +10 -24
- package/dist/lifecycle/lifecycle-manager.js +10 -8
- package/dist/lifecycle/scope-manager.js +1 -1
- package/dist/resolution/cache/activation-need.d.ts +2 -0
- package/dist/resolution/cache/activation-need.js +13 -6
- package/dist/resolution/cache/binding-lookup-cache.d.ts +34 -1
- package/dist/resolution/cache/binding-lookup-cache.js +96 -12
- package/dist/resolution/cache/class-introspector.d.ts +1 -1
- package/dist/resolution/cache/class-introspector.js +28 -14
- package/dist/resolution/context.d.ts +8 -8
- package/dist/resolution/plan/instantiation-plan.d.ts +12 -0
- package/dist/resolution/plan/instantiation-plan.js +156 -65
- package/dist/resolution/plan/plan-codegen.d.ts +100 -0
- package/dist/resolution/plan/plan-codegen.js +185 -0
- package/dist/resolution/resolver.d.ts +14 -4
- package/dist/resolution/resolver.js +375 -134
- package/dist/resolution/select/binding-select.js +12 -7
- package/package.json +9 -1
|
@@ -7,7 +7,7 @@ import { AmbiguousBindingError } from "#/errors/errors";
|
|
|
7
7
|
* @since 0.3.16-canary.0
|
|
8
8
|
*/
|
|
9
9
|
export function selectBinding(bindings, options, ctx, tokenDisplayName) {
|
|
10
|
-
const candidates = filterBindings(bindings, options, ctx, true);
|
|
10
|
+
const candidates = filterBindings(bindings, options, ctx, true, false);
|
|
11
11
|
if (candidates.length === 0) {
|
|
12
12
|
return undefined;
|
|
13
13
|
}
|
|
@@ -36,7 +36,7 @@ export function selectBinding(bindings, options, ctx, tokenDisplayName) {
|
|
|
36
36
|
if (mostSpecific !== undefined) {
|
|
37
37
|
return mostSpecific;
|
|
38
38
|
}
|
|
39
|
-
throw new AmbiguousBindingError(tokenDisplayName, candidates.map((c) => c.
|
|
39
|
+
throw new AmbiguousBindingError(tokenDisplayName, candidates.map((c) => c.identifier));
|
|
40
40
|
}
|
|
41
41
|
/** The lone candidate declaring more criteria than every other, or `undefined` when that is a tie. */
|
|
42
42
|
function mostSpecificByCriterionCount(candidates) {
|
|
@@ -64,7 +64,7 @@ function mostSpecificByCriterionCount(candidates) {
|
|
|
64
64
|
export function selectAllBindings(bindings, options, ctx) {
|
|
65
65
|
// `resolveAll` matches the slot only when the request carries a criterion; with none it takes
|
|
66
66
|
// every binding, where `resolve` would read an absent criterion as "the default slot".
|
|
67
|
-
return filterBindings(bindings, options, ctx, options !== undefined && hasSlotCriterion(options));
|
|
67
|
+
return filterBindings(bindings, options, ctx, options !== undefined && hasSlotCriterion(options), true);
|
|
68
68
|
}
|
|
69
69
|
/**
|
|
70
70
|
* @param bindings - the token's candidates, in registration order
|
|
@@ -72,13 +72,18 @@ export function selectAllBindings(bindings, options, ctx) {
|
|
|
72
72
|
* @param ctx - what the constraint predicates read
|
|
73
73
|
* @param requiresSlotMatch - `resolve` always matches the slot, where an absent criterion means
|
|
74
74
|
* "the default slot"; `resolveAll` matches only when the request carries one
|
|
75
|
+
* @param includesMembers - `resolveAll` takes collection members; a single `resolve` never does
|
|
75
76
|
*/
|
|
76
|
-
function filterBindings(bindings, options, ctx, requiresSlotMatch) {
|
|
77
|
+
function filterBindings(bindings, options, ctx, requiresSlotMatch, includesMembers) {
|
|
77
78
|
const result = [];
|
|
78
|
-
// A predicate is user code that may rebind the token mid-walk
|
|
79
|
-
//
|
|
80
|
-
|
|
79
|
+
// A predicate is user code that may rebind the token mid-walk. A removal replaces the list, and an
|
|
80
|
+
// append lands past the length read here, so the walk offers exactly the candidates it started with.
|
|
81
|
+
const length = bindings.length;
|
|
82
|
+
for (let index = 0; index < length; index += 1) {
|
|
81
83
|
const binding = bindings[index];
|
|
84
|
+
if (!includesMembers && binding.isMany) {
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
82
87
|
if (requiresSlotMatch && !matchesSlot(binding.slot, options)) {
|
|
83
88
|
continue;
|
|
84
89
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codefast/di",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Lightweight dependency injection primitives for Codefast",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"codefast",
|
|
@@ -82,6 +82,10 @@
|
|
|
82
82
|
"types": "./dist/core/registry.d.ts",
|
|
83
83
|
"import": "./dist/core/registry.js"
|
|
84
84
|
},
|
|
85
|
+
"./core/state-epoch": {
|
|
86
|
+
"types": "./dist/core/state-epoch.d.ts",
|
|
87
|
+
"import": "./dist/core/state-epoch.js"
|
|
88
|
+
},
|
|
85
89
|
"./core/tag": {
|
|
86
90
|
"types": "./dist/core/tag.d.ts",
|
|
87
91
|
"import": "./dist/core/tag.js"
|
|
@@ -198,6 +202,10 @@
|
|
|
198
202
|
"types": "./dist/resolution/plan/instantiation-plan.d.ts",
|
|
199
203
|
"import": "./dist/resolution/plan/instantiation-plan.js"
|
|
200
204
|
},
|
|
205
|
+
"./resolution/plan/plan-codegen": {
|
|
206
|
+
"types": "./dist/resolution/plan/plan-codegen.d.ts",
|
|
207
|
+
"import": "./dist/resolution/plan/plan-codegen.js"
|
|
208
|
+
},
|
|
201
209
|
"./resolution/resolver": {
|
|
202
210
|
"types": "./dist/resolution/resolver.d.ts",
|
|
203
211
|
"import": "./dist/resolution/resolver.js"
|