@codefast/di 0.3.16-canary.3 → 0.4.0-canary.5
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 +10 -0
- package/README.md +5 -17
- package/dist/container.d.mts +3 -3
- package/dist/container.mjs +7 -7
- package/dist/decorators/inject.mjs +2 -2
- package/dist/decorators/lifecycle-decorators.mjs +2 -2
- package/dist/dependency-graph.d.mts +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +1 -1
- package/dist/module.mjs +1 -1
- package/dist/resolver.d.mts +1 -1
- package/package.json +8 -8
- package/src/binding-select.ts +4 -13
- package/src/binding.ts +3 -7
- package/src/constraints.ts +16 -44
- package/src/container.ts +63 -141
- package/src/decorators/inject.ts +11 -22
- package/src/decorators/injectable.ts +2 -2
- package/src/decorators/lifecycle-decorators.ts +4 -8
- package/src/dependency-graph.ts +3 -3
- package/src/environment.ts +9 -34
- package/src/errors.ts +1 -3
- package/src/inspector.ts +9 -17
- package/src/lifecycle.ts +9 -30
- package/src/metadata/metadata-reader-token.ts +1 -1
- package/src/metadata/metadata-types.ts +3 -5
- package/src/metadata/symbol-metadata-reader.ts +4 -16
- package/src/module.ts +2 -2
- package/src/registry.ts +5 -14
- package/src/resolver.ts +76 -304
- package/src/scope.ts +1 -1
- package/src/types.ts +7 -29
package/src/scope.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Token } from "#/token";
|
|
2
1
|
import type { Constructor } from "#/constructor-type";
|
|
2
|
+
import type { Token } from "#/token";
|
|
3
3
|
|
|
4
4
|
// Re-export for consumers that import from `#/types`
|
|
5
5
|
export type { Constructor } from "#/constructor-type";
|
|
@@ -38,24 +38,14 @@ export type BindingIdentifier = string & { readonly [BINDING_ID_BRAND]: true };
|
|
|
38
38
|
/**
|
|
39
39
|
* @since 0.3.16-canary.0
|
|
40
40
|
*/
|
|
41
|
-
export type BindingKind =
|
|
42
|
-
| "class"
|
|
43
|
-
| "dynamic"
|
|
44
|
-
| "dynamic-async"
|
|
45
|
-
| "resolved"
|
|
46
|
-
| "resolved-async"
|
|
47
|
-
| "constant"
|
|
48
|
-
| "alias";
|
|
41
|
+
export type BindingKind = "class" | "dynamic" | "dynamic-async" | "resolved" | "resolved-async" | "constant" | "alias";
|
|
49
42
|
|
|
50
43
|
// ── Handlers ─────────────────────────────────────────────────────────────────
|
|
51
44
|
|
|
52
45
|
/**
|
|
53
46
|
* @since 0.3.16-canary.0
|
|
54
47
|
*/
|
|
55
|
-
export type ActivationHandler<Value> = (
|
|
56
|
-
ctx: ResolutionContext,
|
|
57
|
-
instance: Value,
|
|
58
|
-
) => Value | Promise<Value>;
|
|
48
|
+
export type ActivationHandler<Value> = (ctx: ResolutionContext, instance: Value) => Value | Promise<Value>;
|
|
59
49
|
|
|
60
50
|
/**
|
|
61
51
|
* @since 0.3.16-canary.0
|
|
@@ -113,26 +103,14 @@ export interface ConstraintContext {
|
|
|
113
103
|
*/
|
|
114
104
|
export interface ResolutionContext {
|
|
115
105
|
resolve<const Value>(token: Token<Value> | Constructor<Value>, hint?: ResolveOptions): Value;
|
|
116
|
-
resolveAsync<const Value>(
|
|
117
|
-
|
|
118
|
-
hint?: ResolveOptions,
|
|
119
|
-
): Promise<Value>;
|
|
120
|
-
resolveOptional<const Value>(
|
|
121
|
-
token: Token<Value> | Constructor<Value>,
|
|
122
|
-
hint?: ResolveOptions,
|
|
123
|
-
): Value | undefined;
|
|
106
|
+
resolveAsync<const Value>(token: Token<Value> | Constructor<Value>, hint?: ResolveOptions): Promise<Value>;
|
|
107
|
+
resolveOptional<const Value>(token: Token<Value> | Constructor<Value>, hint?: ResolveOptions): Value | undefined;
|
|
124
108
|
resolveOptionalAsync<const Value>(
|
|
125
109
|
token: Token<Value> | Constructor<Value>,
|
|
126
110
|
hint?: ResolveOptions,
|
|
127
111
|
): Promise<Value | undefined>;
|
|
128
|
-
resolveAll<const Value>(
|
|
129
|
-
|
|
130
|
-
hint?: ResolveOptions,
|
|
131
|
-
): Array<Value>;
|
|
132
|
-
resolveAllAsync<const Value>(
|
|
133
|
-
token: Token<Value> | Constructor<Value>,
|
|
134
|
-
hint?: ResolveOptions,
|
|
135
|
-
): Promise<Array<Value>>;
|
|
112
|
+
resolveAll<const Value>(token: Token<Value> | Constructor<Value>, hint?: ResolveOptions): Array<Value>;
|
|
113
|
+
resolveAllAsync<const Value>(token: Token<Value> | Constructor<Value>, hint?: ResolveOptions): Promise<Array<Value>>;
|
|
136
114
|
readonly graph: ConstraintContext;
|
|
137
115
|
}
|
|
138
116
|
|