@codefast/di 0.3.16-canary.0 → 0.3.16-canary.2
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 +12 -0
- package/README.md +8 -5
- package/dist/binding-select.d.mts +2 -2
- package/dist/binding-select.mjs +5 -5
- package/dist/binding.d.mts +12 -12
- package/dist/binding.mjs +8 -8
- package/dist/constraints.d.mts +25 -9
- package/dist/constraints.mjs +47 -19
- package/dist/constructor-type.d.mts +2 -2
- package/dist/container.d.mts +6 -6
- package/dist/container.mjs +202 -121
- package/dist/decorators/inject.d.mts +4 -4
- package/dist/decorators/inject.mjs +21 -19
- package/dist/decorators/injectable.d.mts +1 -1
- package/dist/decorators/injectable.mjs +18 -14
- package/dist/decorators/lifecycle-decorators.mjs +3 -0
- package/dist/dependency-graph.d.mts +2 -2
- package/dist/dependency-graph.mjs +13 -13
- package/dist/environment.d.mts +17 -17
- package/dist/environment.mjs +21 -21
- package/dist/errors.d.mts +18 -8
- package/dist/errors.mjs +17 -1
- package/dist/graph-adapters/reactflow.d.mts +2 -2
- package/dist/index.d.mts +6 -5
- package/dist/index.mjs +5 -4
- package/dist/inspector.d.mts +2 -3
- package/dist/inspector.mjs +18 -16
- package/dist/lifecycle.d.mts +5 -6
- package/dist/lifecycle.mjs +45 -52
- package/dist/metadata/metadata-keys.d.mts +24 -1
- package/dist/metadata/metadata-keys.mjs +14 -1
- package/dist/metadata/metadata-types.d.mts +5 -5
- package/dist/metadata/symbol-metadata-reader.mjs +31 -24
- package/dist/module.d.mts +2 -2
- package/dist/module.mjs +2 -2
- package/dist/registry.d.mts +6 -6
- package/dist/registry.mjs +55 -62
- package/dist/resolve-options.d.mts +5 -5
- package/dist/resolve-options.mjs +8 -8
- package/dist/resolver.d.mts +22 -10
- package/dist/resolver.mjs +206 -185
- package/dist/token.d.mts +1 -1
- package/dist/token.mjs +4 -4
- package/dist/types.d.mts +12 -8
- package/package.json +15 -8
package/dist/token.d.mts
CHANGED
|
@@ -16,7 +16,7 @@ declare function token<Value>(name: string): Token<Value>;
|
|
|
16
16
|
/**
|
|
17
17
|
* @since 0.3.16-canary.0
|
|
18
18
|
*/
|
|
19
|
-
declare function tokenName(
|
|
19
|
+
declare function tokenName(dependency: Token<unknown> | Constructor): string;
|
|
20
20
|
/**
|
|
21
21
|
* @since 0.3.16-canary.0
|
|
22
22
|
*/
|
package/dist/token.mjs
CHANGED
|
@@ -8,15 +8,15 @@ function token(name) {
|
|
|
8
8
|
/**
|
|
9
9
|
* @since 0.3.16-canary.0
|
|
10
10
|
*/
|
|
11
|
-
function tokenName(
|
|
12
|
-
if (typeof
|
|
13
|
-
return
|
|
11
|
+
function tokenName(dependency) {
|
|
12
|
+
if (typeof dependency === "function") return dependency.name;
|
|
13
|
+
return dependency.name;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* @since 0.3.16-canary.0
|
|
17
17
|
*/
|
|
18
18
|
function isToken(value) {
|
|
19
|
-
return typeof value === "object" && value !== null && "name" in value && typeof value["name"] === "string"
|
|
19
|
+
return typeof value === "object" && value !== null && "name" in value && typeof value["name"] === "string";
|
|
20
20
|
}
|
|
21
21
|
//#endregion
|
|
22
22
|
export { isToken, token, tokenName };
|
package/dist/types.d.mts
CHANGED
|
@@ -36,13 +36,17 @@ type DeactivationHandler<Value> = (instance: Value) => void | Promise<void>;
|
|
|
36
36
|
*/
|
|
37
37
|
interface ResolveOptions {
|
|
38
38
|
name?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Single-tag shorthand — semantics match including one pair in `tags`.
|
|
41
|
+
* Enables fast-path lookup alongside `tags`.
|
|
42
|
+
*/
|
|
39
43
|
tag?: readonly [tag: string, value: unknown];
|
|
40
44
|
tags?: ReadonlyArray<readonly [tag: string, value: unknown]>;
|
|
41
45
|
}
|
|
42
46
|
/**
|
|
43
47
|
* @since 0.3.16-canary.0
|
|
44
48
|
*/
|
|
45
|
-
interface
|
|
49
|
+
interface ResolutionFrame {
|
|
46
50
|
readonly tokenName: string;
|
|
47
51
|
readonly scope: BindingScope;
|
|
48
52
|
readonly bindingId: BindingIdentifier;
|
|
@@ -56,10 +60,10 @@ interface MaterializationFrame {
|
|
|
56
60
|
* @since 0.3.16-canary.0
|
|
57
61
|
*/
|
|
58
62
|
interface ConstraintContext {
|
|
59
|
-
readonly resolutionPath:
|
|
60
|
-
readonly
|
|
61
|
-
readonly parent:
|
|
62
|
-
readonly ancestors:
|
|
63
|
+
readonly resolutionPath: ReadonlyArray<string>;
|
|
64
|
+
readonly resolutionStack: ReadonlyArray<ResolutionFrame>;
|
|
65
|
+
readonly parent: ResolutionFrame | undefined;
|
|
66
|
+
readonly ancestors: ReadonlyArray<ResolutionFrame>;
|
|
63
67
|
readonly currentResolveHint: ResolveOptions | undefined;
|
|
64
68
|
}
|
|
65
69
|
/**
|
|
@@ -70,8 +74,8 @@ interface ResolutionContext {
|
|
|
70
74
|
resolveAsync<const Value>(token: Token<Value> | Constructor<Value>, hint?: ResolveOptions): Promise<Value>;
|
|
71
75
|
resolveOptional<const Value>(token: Token<Value> | Constructor<Value>, hint?: ResolveOptions): Value | undefined;
|
|
72
76
|
resolveOptionalAsync<const Value>(token: Token<Value> | Constructor<Value>, hint?: ResolveOptions): Promise<Value | undefined>;
|
|
73
|
-
resolveAll<const Value>(token: Token<Value> | Constructor<Value>, hint?: ResolveOptions): Value
|
|
74
|
-
resolveAllAsync<const Value>(token: Token<Value> | Constructor<Value>, hint?: ResolveOptions): Promise<Value
|
|
77
|
+
resolveAll<const Value>(token: Token<Value> | Constructor<Value>, hint?: ResolveOptions): Array<Value>;
|
|
78
|
+
resolveAllAsync<const Value>(token: Token<Value> | Constructor<Value>, hint?: ResolveOptions): Promise<Array<Value>>;
|
|
75
79
|
readonly graph: ConstraintContext;
|
|
76
80
|
}
|
|
77
81
|
/**
|
|
@@ -79,4 +83,4 @@ interface ResolutionContext {
|
|
|
79
83
|
*/
|
|
80
84
|
type TokenValue<Type> = Type extends Token<infer Value> ? Value : Type extends Constructor<infer Value> ? Value : never;
|
|
81
85
|
//#endregion
|
|
82
|
-
export { ActivationHandler, BindingIdentifier, BindingKind, BindingScope, ConstraintContext, type Constructor, DeactivationHandler, DependencyKey,
|
|
86
|
+
export { ActivationHandler, BindingIdentifier, BindingKind, BindingScope, ConstraintContext, type Constructor, DeactivationHandler, DependencyKey, ResolutionContext, ResolutionFrame, ResolveOptions, TokenValue };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codefast/di",
|
|
3
|
-
"version": "0.3.16-canary.
|
|
3
|
+
"version": "0.3.16-canary.2",
|
|
4
4
|
"description": "Lightweight dependency injection primitives for Codefast",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"codefast",
|
|
@@ -170,14 +170,17 @@
|
|
|
170
170
|
"access": "public"
|
|
171
171
|
},
|
|
172
172
|
"devDependencies": {
|
|
173
|
-
"@
|
|
174
|
-
"@
|
|
175
|
-
"@
|
|
173
|
+
"@babel/plugin-proposal-decorators": "^7.29.0",
|
|
174
|
+
"@rolldown/plugin-babel": "^0.2.3",
|
|
175
|
+
"@types/node": "^25.7.0",
|
|
176
|
+
"@typescript/native-preview": "7.0.0-dev.20260514.1",
|
|
177
|
+
"@vitest/coverage-v8": "^4.1.6",
|
|
176
178
|
"expect-type": "^1.3.0",
|
|
179
|
+
"tsdown": "^0.22.0",
|
|
180
|
+
"tsx": "^4.22.0",
|
|
177
181
|
"typescript": "^6.0.3",
|
|
178
|
-
"
|
|
179
|
-
"
|
|
180
|
-
"@codefast/typescript-config": "0.3.16-canary.0"
|
|
182
|
+
"vitest": "^4.1.6",
|
|
183
|
+
"@codefast/typescript-config": "0.3.16-canary.2"
|
|
181
184
|
},
|
|
182
185
|
"engines": {
|
|
183
186
|
"node": ">=22.0.0"
|
|
@@ -186,9 +189,13 @@
|
|
|
186
189
|
"build": "tsdown",
|
|
187
190
|
"check-types": "tsgo --noEmit",
|
|
188
191
|
"clean": "rm -rf dist",
|
|
189
|
-
"examples": "for file in examples/*/*.ts; do echo \"=== Running $file ===\"; tsx \"$file\"; echo \"\n\" || exit 1; done",
|
|
192
|
+
"examples": "for file in examples/*/*.ts; do echo \"=== Running $file ===\"; node --import tsx/esm \"$file\"; echo \"\n\" || exit 1; done",
|
|
190
193
|
"test": "vitest run",
|
|
191
194
|
"test:coverage": "vitest run --coverage",
|
|
195
|
+
"test:e2e": "vitest run tests/e2e",
|
|
196
|
+
"test:integration": "vitest run tests/integration",
|
|
197
|
+
"test:type": "vitest run tests/types",
|
|
198
|
+
"test:unit": "vitest run tests/unit",
|
|
192
199
|
"test:watch": "vitest"
|
|
193
200
|
}
|
|
194
201
|
}
|