@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
|
@@ -2,34 +2,50 @@ import type { BindingTag } from "#/core/tag";
|
|
|
2
2
|
import type { Token } from "#/core/token";
|
|
3
3
|
import type { BindingConstraint, Constructor } from "#/core/types";
|
|
4
4
|
/**
|
|
5
|
+
* Matches when the direct parent frame resolves the given token.
|
|
6
|
+
*
|
|
5
7
|
* @since 0.3.16-canary.0
|
|
6
8
|
*/
|
|
7
9
|
export declare function whenParentIs(token: Token<unknown> | Constructor): BindingConstraint;
|
|
8
10
|
/**
|
|
11
|
+
* Matches when there is no direct parent frame, or it resolves a different token.
|
|
12
|
+
*
|
|
9
13
|
* @since 0.3.16-canary.0
|
|
10
14
|
*/
|
|
11
15
|
export declare function whenNoParentIs(token: Token<unknown> | Constructor): BindingConstraint;
|
|
12
16
|
/**
|
|
17
|
+
* Matches when at least one ancestor frame resolves the given token.
|
|
18
|
+
*
|
|
13
19
|
* @since 0.3.16-canary.0
|
|
14
20
|
*/
|
|
15
21
|
export declare function whenAnyAncestorIs(token: Token<unknown> | Constructor): BindingConstraint;
|
|
16
22
|
/**
|
|
23
|
+
* Matches when no ancestor frame resolves the given token.
|
|
24
|
+
*
|
|
17
25
|
* @since 0.3.16-canary.0
|
|
18
26
|
*/
|
|
19
27
|
export declare function whenNoAncestorIs(token: Token<unknown> | Constructor): BindingConstraint;
|
|
20
28
|
/**
|
|
29
|
+
* Matches when the direct parent slot carries the given name.
|
|
30
|
+
*
|
|
21
31
|
* @since 0.3.16-canary.0
|
|
22
32
|
*/
|
|
23
33
|
export declare function whenParentNamed(name: string): BindingConstraint;
|
|
24
34
|
/**
|
|
35
|
+
* Matches when at least one ancestor slot carries the given name.
|
|
36
|
+
*
|
|
25
37
|
* @since 0.3.16-canary.0
|
|
26
38
|
*/
|
|
27
39
|
export declare function whenAnyAncestorNamed(name: string): BindingConstraint;
|
|
28
40
|
/**
|
|
41
|
+
* Matches when the direct parent slot carries the given tag pair.
|
|
42
|
+
*
|
|
29
43
|
* @since 0.3.16-canary.0
|
|
30
44
|
*/
|
|
31
45
|
export declare function whenParentTagged(criterion: BindingTag): BindingConstraint;
|
|
32
46
|
/**
|
|
47
|
+
* Matches when at least one ancestor slot carries the given tag pair.
|
|
48
|
+
*
|
|
33
49
|
* @since 0.3.16-canary.0
|
|
34
50
|
*/
|
|
35
51
|
export declare function whenAnyAncestorTagged(criterion: BindingTag): BindingConstraint;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constraints.d.ts","sourceRoot":"","sources":["../../../src/resolution/select/constraints.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,KAAK,EAAE,iBAAiB,EAAE,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Aa,CAAC,UAAU,CAAC,GAAG,iBAAiB,CAQ3F"}
|
|
@@ -3,6 +3,8 @@ import { coversTagKeys, tagKeyMaskOf } from "#/core/tag";
|
|
|
3
3
|
import { tokenName } from "#/core/token";
|
|
4
4
|
import { EmptyTagCriteriaError } from "#/errors/errors";
|
|
5
5
|
/**
|
|
6
|
+
* Matches when the direct parent frame resolves the given token.
|
|
7
|
+
*
|
|
6
8
|
* @since 0.3.16-canary.0
|
|
7
9
|
*/
|
|
8
10
|
export function whenParentIs(token) {
|
|
@@ -10,6 +12,8 @@ export function whenParentIs(token) {
|
|
|
10
12
|
return (constraintContext) => constraintContext.parent !== undefined && constraintContext.parent.tokenName === tokenDisplayName;
|
|
11
13
|
}
|
|
12
14
|
/**
|
|
15
|
+
* Matches when there is no direct parent frame, or it resolves a different token.
|
|
16
|
+
*
|
|
13
17
|
* @since 0.3.16-canary.0
|
|
14
18
|
*/
|
|
15
19
|
export function whenNoParentIs(token) {
|
|
@@ -17,6 +21,8 @@ export function whenNoParentIs(token) {
|
|
|
17
21
|
return (constraintContext) => constraintContext.parent === undefined || constraintContext.parent.tokenName !== tokenDisplayName;
|
|
18
22
|
}
|
|
19
23
|
/**
|
|
24
|
+
* Matches when at least one ancestor frame resolves the given token.
|
|
25
|
+
*
|
|
20
26
|
* @since 0.3.16-canary.0
|
|
21
27
|
*/
|
|
22
28
|
export function whenAnyAncestorIs(token) {
|
|
@@ -24,6 +30,8 @@ export function whenAnyAncestorIs(token) {
|
|
|
24
30
|
return (constraintContext) => constraintContext.ancestors.some((ancestorFrame) => ancestorFrame.tokenName === tokenDisplayName);
|
|
25
31
|
}
|
|
26
32
|
/**
|
|
33
|
+
* Matches when no ancestor frame resolves the given token.
|
|
34
|
+
*
|
|
27
35
|
* @since 0.3.16-canary.0
|
|
28
36
|
*/
|
|
29
37
|
export function whenNoAncestorIs(token) {
|
|
@@ -31,24 +39,32 @@ export function whenNoAncestorIs(token) {
|
|
|
31
39
|
return (constraintContext) => constraintContext.ancestors.every((ancestorFrame) => ancestorFrame.tokenName !== tokenDisplayName);
|
|
32
40
|
}
|
|
33
41
|
/**
|
|
42
|
+
* Matches when the direct parent slot carries the given name.
|
|
43
|
+
*
|
|
34
44
|
* @since 0.3.16-canary.0
|
|
35
45
|
*/
|
|
36
46
|
export function whenParentNamed(name) {
|
|
37
47
|
return requiringAncestorSlotName((constraintContext) => constraintContext.parent !== undefined && constraintContext.parent.slot.name === name, name, "whenParentNamed");
|
|
38
48
|
}
|
|
39
49
|
/**
|
|
50
|
+
* Matches when at least one ancestor slot carries the given name.
|
|
51
|
+
*
|
|
40
52
|
* @since 0.3.16-canary.0
|
|
41
53
|
*/
|
|
42
54
|
export function whenAnyAncestorNamed(name) {
|
|
43
55
|
return requiringAncestorSlotName((constraintContext) => constraintContext.ancestors.some((ancestorFrame) => ancestorFrame.slot.name === name), name, "whenAnyAncestorNamed");
|
|
44
56
|
}
|
|
45
57
|
/**
|
|
58
|
+
* Matches when the direct parent slot carries the given tag pair.
|
|
59
|
+
*
|
|
46
60
|
* @since 0.3.16-canary.0
|
|
47
61
|
*/
|
|
48
62
|
export function whenParentTagged(criterion) {
|
|
49
63
|
return (constraintContext) => constraintContext.parent !== undefined && constraintContext.parent.slot.tags.includes(criterion);
|
|
50
64
|
}
|
|
51
65
|
/**
|
|
66
|
+
* Matches when at least one ancestor slot carries the given tag pair.
|
|
67
|
+
*
|
|
52
68
|
* @since 0.3.16-canary.0
|
|
53
69
|
*/
|
|
54
70
|
export function whenAnyAncestorTagged(criterion) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constraints.js","sourceRoot":"","sources":["../../../src/resolution/select/constraints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAE1E,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAEzD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,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,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codefast/di",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "Lightweight dependency injection primitives for Codefast",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"codefast",
|
|
@@ -36,6 +36,13 @@
|
|
|
36
36
|
"./tests/*/index.ts",
|
|
37
37
|
"./tests/*/index.tsx"
|
|
38
38
|
],
|
|
39
|
+
"#/examples/*": [
|
|
40
|
+
"./examples/*",
|
|
41
|
+
"./examples/*.ts",
|
|
42
|
+
"./examples/*.tsx",
|
|
43
|
+
"./examples/*/index.ts",
|
|
44
|
+
"./examples/*/index.tsx"
|
|
45
|
+
],
|
|
39
46
|
"#/*": {
|
|
40
47
|
"source": [
|
|
41
48
|
"./src/*",
|
|
@@ -274,12 +281,12 @@
|
|
|
274
281
|
"@babel/plugin-proposal-decorators": "8.0.2",
|
|
275
282
|
"@rolldown/plugin-babel": "^0.2.3",
|
|
276
283
|
"@types/node": "^26.2.0",
|
|
277
|
-
"@vitest/coverage-v8": "^4.1.
|
|
284
|
+
"@vitest/coverage-v8": "^4.1.11",
|
|
278
285
|
"expect-type": "^1.4.0",
|
|
279
286
|
"tsx": "^4.23.12",
|
|
280
287
|
"typescript": "^7.0.2",
|
|
281
|
-
"vitest": "^4.1.
|
|
282
|
-
"@codefast/typescript-config": "0.
|
|
288
|
+
"vitest": "^4.1.11",
|
|
289
|
+
"@codefast/typescript-config": "0.8.0"
|
|
283
290
|
},
|
|
284
291
|
"engines": {
|
|
285
292
|
"node": ">=24.0.0"
|
|
@@ -288,7 +295,7 @@
|
|
|
288
295
|
"build": "rm -rf dist && tsc -p tsconfig.build.json",
|
|
289
296
|
"check-types": "tsc --noEmit",
|
|
290
297
|
"clean": "rm -rf dist",
|
|
291
|
-
"examples": "
|
|
298
|
+
"examples": "node examples/run.mjs",
|
|
292
299
|
"test": "vitest run",
|
|
293
300
|
"test:coverage": "vitest run --coverage",
|
|
294
301
|
"test:e2e": "vitest run tests/e2e",
|
|
@@ -20,6 +20,8 @@ let activeContainer: Container | undefined;
|
|
|
20
20
|
let activeResolution: AmbientResolution | undefined;
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
|
+
* Runs a callback with the given container installed as the ambient one and returns its result.
|
|
24
|
+
*
|
|
23
25
|
* @since 0.3.16-canary.0
|
|
24
26
|
*/
|
|
25
27
|
export function runWithContainer<Result>(container: Container, fn: () => Result): Result {
|
|
@@ -49,6 +51,8 @@ export function runWithAmbientResolution<Result>(
|
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
/**
|
|
54
|
+
* Returns the ambient container for the construction in flight, if one is installed.
|
|
55
|
+
*
|
|
52
56
|
* @since 0.3.16-canary.0
|
|
53
57
|
*/
|
|
54
58
|
export function getActiveContainer(): Container | undefined {
|
|
@@ -50,6 +50,8 @@ import { DependencyResolver } from "#/resolution/resolver";
|
|
|
50
50
|
// ── Container interface ──────────────────────────────────────────────────────────────────────────────────────────────
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
|
+
* The public surface: binding, resolving, modules, lifecycle hooks, child scopes, and disposal.
|
|
54
|
+
*
|
|
53
55
|
* @since 0.3.16-canary.0
|
|
54
56
|
*/
|
|
55
57
|
export interface Container {
|
|
@@ -114,6 +116,8 @@ export interface ContainerOptions {
|
|
|
114
116
|
}
|
|
115
117
|
|
|
116
118
|
/**
|
|
119
|
+
* The factory surface the `Container` companion object exposes.
|
|
120
|
+
*
|
|
117
121
|
* @since 0.3.16-canary.0
|
|
118
122
|
*/
|
|
119
123
|
export interface ContainerStatic {
|
|
@@ -944,6 +948,8 @@ function throwCollected(errors: ReadonlyArray<unknown>, message: string): void {
|
|
|
944
948
|
// ── Container static ─────────────────────────────────────────────────────────────────────────────────────────────────
|
|
945
949
|
|
|
946
950
|
/**
|
|
951
|
+
* The companion factory that creates containers, empty or preloaded from modules.
|
|
952
|
+
*
|
|
947
953
|
* @since 0.3.16-canary.0
|
|
948
954
|
*/
|
|
949
955
|
export const Container: ContainerStatic = {
|
package/src/core/module.ts
CHANGED
|
@@ -16,6 +16,8 @@ const ASYNC_MODULE_BRAND: unique symbol = Symbol("di:async-module");
|
|
|
16
16
|
export const MODULE_SETUP: unique symbol = Symbol("di:module-setup");
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
+
* A named, reusable group of bindings a container applies synchronously via `load()`.
|
|
20
|
+
*
|
|
19
21
|
* @since 0.3.16-canary.0
|
|
20
22
|
*/
|
|
21
23
|
export interface SyncModule {
|
|
@@ -25,6 +27,8 @@ export interface SyncModule {
|
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
/**
|
|
30
|
+
* A named group of bindings whose setup is async, applied via `loadAsync()`.
|
|
31
|
+
*
|
|
28
32
|
* @since 0.3.16-canary.0
|
|
29
33
|
*/
|
|
30
34
|
export interface AsyncModule {
|
|
@@ -36,6 +40,8 @@ export interface AsyncModule {
|
|
|
36
40
|
// ── Builder interfaces ───────────────────────────────────────────────────────────────────────────────────────────────
|
|
37
41
|
|
|
38
42
|
/**
|
|
43
|
+
* The binding surface a sync module's setup callback receives.
|
|
44
|
+
*
|
|
39
45
|
* @since 0.3.16-canary.0
|
|
40
46
|
*/
|
|
41
47
|
export interface ModuleBuilder {
|
|
@@ -44,6 +50,8 @@ export interface ModuleBuilder {
|
|
|
44
50
|
}
|
|
45
51
|
|
|
46
52
|
/**
|
|
53
|
+
* The binding surface an async module's setup callback receives; its `import` accepts async modules too.
|
|
54
|
+
*
|
|
47
55
|
* @since 0.3.16-canary.0
|
|
48
56
|
*/
|
|
49
57
|
export interface AsyncModuleBuilder {
|
|
@@ -54,6 +62,8 @@ export interface AsyncModuleBuilder {
|
|
|
54
62
|
// ── Static factories ─────────────────────────────────────────────────────────────────────────────────────────────────
|
|
55
63
|
|
|
56
64
|
/**
|
|
65
|
+
* The companion factory that creates `SyncModule` values.
|
|
66
|
+
*
|
|
57
67
|
* @since 0.3.16-canary.0
|
|
58
68
|
*/
|
|
59
69
|
export const SyncModule = {
|
|
@@ -67,6 +77,8 @@ export const SyncModule = {
|
|
|
67
77
|
};
|
|
68
78
|
|
|
69
79
|
/**
|
|
80
|
+
* The companion factory that creates `AsyncModule` values.
|
|
81
|
+
*
|
|
70
82
|
* @since 0.3.16-canary.0
|
|
71
83
|
*/
|
|
72
84
|
export const AsyncModule = {
|
|
@@ -82,6 +94,8 @@ export const AsyncModule = {
|
|
|
82
94
|
// ── Module — unified API ─────────────────────────────────────────────────────────────────────────────────────────────
|
|
83
95
|
|
|
84
96
|
/**
|
|
97
|
+
* The unified module factory — `create` for sync modules, `createAsync` for async ones.
|
|
98
|
+
*
|
|
85
99
|
* @since 0.3.16-canary.0
|
|
86
100
|
*/
|
|
87
101
|
export const Module = {
|
|
@@ -94,6 +108,8 @@ export const Module = {
|
|
|
94
108
|
};
|
|
95
109
|
|
|
96
110
|
/**
|
|
111
|
+
* Narrows a module union to `SyncModule` by checking its brand.
|
|
112
|
+
*
|
|
97
113
|
* @since 0.3.16-canary.0
|
|
98
114
|
*/
|
|
99
115
|
export function isSyncModule(module: SyncModule | AsyncModule): module is SyncModule {
|
package/src/core/registry.ts
CHANGED
|
@@ -6,6 +6,8 @@ import type { Token } from "#/core/token";
|
|
|
6
6
|
import type { BindingIdentifier, Constructor, DependencyKey } from "#/core/types";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
+
* One container's binding store, indexed by token, binding id, and slot for fast lookup.
|
|
10
|
+
*
|
|
9
11
|
* @since 0.3.16-canary.0
|
|
10
12
|
*/
|
|
11
13
|
export class BindingRegistry {
|
package/src/core/token.ts
CHANGED
|
@@ -3,6 +3,8 @@ import type { Constructor } from "#/core/constructor-type";
|
|
|
3
3
|
declare const TOKEN_BRAND: unique symbol;
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
+
* A branded identifier carrying the value type its bindings resolve to.
|
|
7
|
+
*
|
|
6
8
|
* @since 0.3.16-canary.0
|
|
7
9
|
*/
|
|
8
10
|
export interface Token<out Value> {
|
|
@@ -11,6 +13,8 @@ export interface Token<out Value> {
|
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
/**
|
|
16
|
+
* Creates a named `Token` for the given value type.
|
|
17
|
+
*
|
|
14
18
|
* @since 0.3.16-canary.0
|
|
15
19
|
*/
|
|
16
20
|
export function token<Value>(name: string): Token<Value> {
|
|
@@ -18,6 +22,8 @@ export function token<Value>(name: string): Token<Value> {
|
|
|
18
22
|
}
|
|
19
23
|
|
|
20
24
|
/**
|
|
25
|
+
* Returns the display name of a token or class used as a dependency key.
|
|
26
|
+
*
|
|
21
27
|
* @since 0.3.16-canary.0
|
|
22
28
|
*/
|
|
23
29
|
export function tokenName(dependency: Token<unknown> | Constructor): string {
|
package/src/core/types.ts
CHANGED
|
@@ -16,6 +16,8 @@ export type DependencyKey = Token<unknown> | Constructor;
|
|
|
16
16
|
// ── BindingScope ─────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
+
* The lifetime a binding's instances are cached under.
|
|
20
|
+
*
|
|
19
21
|
* @since 0.3.16-canary.0
|
|
20
22
|
*/
|
|
21
23
|
export type BindingScope = "singleton" | "transient" | "scoped";
|
|
@@ -24,6 +26,8 @@ export type BindingScope = "singleton" | "transient" | "scoped";
|
|
|
24
26
|
|
|
25
27
|
declare const BINDING_ID_BRAND: unique symbol;
|
|
26
28
|
/**
|
|
29
|
+
* A branded string that uniquely identifies one binding.
|
|
30
|
+
*
|
|
27
31
|
* @since 0.3.16-canary.0
|
|
28
32
|
*/
|
|
29
33
|
export type BindingIdentifier = string & { readonly [BINDING_ID_BRAND]: true };
|
|
@@ -31,6 +35,8 @@ export type BindingIdentifier = string & { readonly [BINDING_ID_BRAND]: true };
|
|
|
31
35
|
// ── BindingKind ──────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
32
36
|
|
|
33
37
|
/**
|
|
38
|
+
* The strategy a binding produces values with, set by the `to*()` call that created it.
|
|
39
|
+
*
|
|
34
40
|
* @since 0.3.16-canary.0
|
|
35
41
|
*/
|
|
36
42
|
export type BindingKind = "class" | "dynamic" | "dynamic-async" | "resolved" | "resolved-async" | "constant" | "alias";
|
|
@@ -38,11 +44,15 @@ export type BindingKind = "class" | "dynamic" | "dynamic-async" | "resolved" | "
|
|
|
38
44
|
// ── Handlers ─────────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
39
45
|
|
|
40
46
|
/**
|
|
47
|
+
* A hook that runs after an instance is created and returns the instance to hand out.
|
|
48
|
+
*
|
|
41
49
|
* @since 0.3.16-canary.0
|
|
42
50
|
*/
|
|
43
51
|
export type ActivationHandler<Value> = (ctx: ResolutionContext, instance: Value) => Value | Promise<Value>;
|
|
44
52
|
|
|
45
53
|
/**
|
|
54
|
+
* A hook that runs when a cached instance is released from its scope.
|
|
55
|
+
*
|
|
46
56
|
* @since 0.3.16-canary.0
|
|
47
57
|
*/
|
|
48
58
|
export type DeactivationHandler<Value> = (instance: Value) => void | Promise<void>;
|
|
@@ -50,6 +60,8 @@ export type DeactivationHandler<Value> = (instance: Value) => void | Promise<voi
|
|
|
50
60
|
// ── ResolveOptions ───────────────────────────────────────────────────────────────────────────────────────────────────
|
|
51
61
|
|
|
52
62
|
/**
|
|
63
|
+
* Slot-selection criteria — a name and tags — that narrow which binding a resolve call matches.
|
|
64
|
+
*
|
|
53
65
|
* @since 0.3.16-canary.0
|
|
54
66
|
*/
|
|
55
67
|
export interface ResolveOptions {
|
|
@@ -67,6 +79,8 @@ export interface ResolveOptions {
|
|
|
67
79
|
// ── ResolutionFrame ──────────────────────────────────────────────────────────────────────────────────────────────────
|
|
68
80
|
|
|
69
81
|
/**
|
|
82
|
+
* One entry of the resolution stack: the token, scope, binding, and slot being resolved.
|
|
83
|
+
*
|
|
70
84
|
* @since 0.3.16-canary.0
|
|
71
85
|
*/
|
|
72
86
|
export interface ResolutionFrame {
|
|
@@ -84,6 +98,8 @@ export interface ResolutionFrame {
|
|
|
84
98
|
// ── ConstraintContext ────────────────────────────────────────────────────────────────────────────────────────────────
|
|
85
99
|
|
|
86
100
|
/**
|
|
101
|
+
* The resolution-time view — path, stack, parent, and ancestors — a `BindingConstraint` inspects.
|
|
102
|
+
*
|
|
87
103
|
* @since 0.3.16-canary.0
|
|
88
104
|
*/
|
|
89
105
|
export interface ConstraintContext {
|
|
@@ -105,6 +121,8 @@ export type BindingConstraint = (ctx: ConstraintContext) => boolean;
|
|
|
105
121
|
// ── ResolutionContext ────────────────────────────────────────────────────────────────────────────────────────────────
|
|
106
122
|
|
|
107
123
|
/**
|
|
124
|
+
* The container view a dynamic factory or activation handler resolves further dependencies through.
|
|
125
|
+
*
|
|
108
126
|
* @since 0.3.16-canary.0
|
|
109
127
|
*/
|
|
110
128
|
export interface ResolutionContext {
|
|
@@ -123,6 +141,8 @@ export interface ResolutionContext {
|
|
|
123
141
|
// ── TokenValue ───────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
124
142
|
|
|
125
143
|
/**
|
|
144
|
+
* The value type a token or class constructor resolves to.
|
|
145
|
+
*
|
|
126
146
|
* @since 0.3.16-canary.0
|
|
127
147
|
*/
|
|
128
148
|
export type TokenValue<Type> =
|
package/src/decorators/inject.ts
CHANGED
|
@@ -35,6 +35,8 @@ type ClassAccessorDecorator<This, Value> = (
|
|
|
35
35
|
) => ClassAccessorDecoratorResult<This, Value> | void;
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
|
+
* Creates a dual-role value: an injection descriptor that also works as a class accessor decorator.
|
|
39
|
+
*
|
|
38
40
|
* @since 0.3.16-canary.0
|
|
39
41
|
*/
|
|
40
42
|
export function inject<Value>(
|
|
@@ -7,6 +7,8 @@ import type { ParamMetadata } from "#/metadata/metadata-types";
|
|
|
7
7
|
// ── AutoRegisterRegistry ─────────────────────────────────────────────────────────────────────────────────────────────
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
+
* The collector `@injectable` registers a class into, for a container to bind later.
|
|
11
|
+
*
|
|
10
12
|
* @since 0.3.16-canary.0
|
|
11
13
|
*/
|
|
12
14
|
export interface AutoRegisterRegistry {
|
|
@@ -15,6 +17,8 @@ export interface AutoRegisterRegistry {
|
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
/**
|
|
20
|
+
* Creates an empty auto-register registry.
|
|
21
|
+
*
|
|
18
22
|
* @since 0.3.16-canary.0
|
|
19
23
|
*/
|
|
20
24
|
export function createAutoRegisterRegistry(): AutoRegisterRegistry {
|
|
@@ -32,6 +36,8 @@ export function createAutoRegisterRegistry(): AutoRegisterRegistry {
|
|
|
32
36
|
// ── InjectableOptions ────────────────────────────────────────────────────────────────────────────────────────────────
|
|
33
37
|
|
|
34
38
|
/**
|
|
39
|
+
* Auto-registration options `@injectable` accepts alongside its deps list.
|
|
40
|
+
*
|
|
35
41
|
* @since 0.3.16-canary.0
|
|
36
42
|
*/
|
|
37
43
|
export interface InjectableOptions {
|
|
@@ -83,6 +89,8 @@ export function injectable<const Deps extends ReadonlyArray<InjectableDependency
|
|
|
83
89
|
) => void;
|
|
84
90
|
|
|
85
91
|
/**
|
|
92
|
+
* Writes the declared dependencies into the class's metadata and optionally auto-registers it.
|
|
93
|
+
*
|
|
86
94
|
* @since 0.6.0
|
|
87
95
|
*/
|
|
88
96
|
export function injectable(
|
|
@@ -25,6 +25,8 @@ function recordLifecycleMethod(phase: "postConstruct" | "preDestroy"): MethodDec
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
|
+
* Marks an instance method to run after the container constructs and wires the instance.
|
|
29
|
+
*
|
|
28
30
|
* @since 0.3.16-canary.0
|
|
29
31
|
*/
|
|
30
32
|
export function postConstruct(): MethodDecorator {
|
|
@@ -32,6 +34,8 @@ export function postConstruct(): MethodDecorator {
|
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
/**
|
|
37
|
+
* Marks an instance method to run when the instance's container or scope is disposed.
|
|
38
|
+
*
|
|
35
39
|
* @since 0.3.16-canary.0
|
|
36
40
|
*/
|
|
37
41
|
export function preDestroy(): MethodDecorator {
|
package/src/errors/errors.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { BindingIdentifier, BindingScope, ResolveOptions } from "#/core/types";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
+
* Base class for every error the library throws, each carrying a machine-readable `code`.
|
|
5
|
+
*
|
|
4
6
|
* @since 0.3.16-canary.0
|
|
5
7
|
*/
|
|
6
8
|
export abstract class DiError extends Error {
|
|
@@ -13,6 +15,8 @@ export abstract class DiError extends Error {
|
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
/**
|
|
18
|
+
* An internal assertion failure — a library bug, never caller misuse.
|
|
19
|
+
*
|
|
16
20
|
* @since 0.3.16-canary.0
|
|
17
21
|
*/
|
|
18
22
|
export class InternalError extends DiError {
|
|
@@ -24,6 +28,8 @@ export class InternalError extends DiError {
|
|
|
24
28
|
}
|
|
25
29
|
|
|
26
30
|
/**
|
|
31
|
+
* A token with no binding at all, even after walking the parent container chain.
|
|
32
|
+
*
|
|
27
33
|
* @since 0.3.16-canary.0
|
|
28
34
|
*/
|
|
29
35
|
export class TokenNotBoundError extends DiError {
|
|
@@ -50,6 +56,8 @@ function describeResolveOptions(options: ResolveOptions): string {
|
|
|
50
56
|
}
|
|
51
57
|
|
|
52
58
|
/**
|
|
59
|
+
* A token that has bindings, none of whose slots match the given `ResolveOptions`.
|
|
60
|
+
*
|
|
53
61
|
* @since 0.3.16-canary.0
|
|
54
62
|
*/
|
|
55
63
|
export class NoMatchingBindingError extends DiError {
|
|
@@ -69,6 +77,8 @@ export class NoMatchingBindingError extends DiError {
|
|
|
69
77
|
}
|
|
70
78
|
|
|
71
79
|
/**
|
|
80
|
+
* Two or more candidate bindings that matched without the more-specific rule deciding a winner.
|
|
81
|
+
*
|
|
72
82
|
* @since 0.3.16-canary.0
|
|
73
83
|
*/
|
|
74
84
|
export class AmbiguousBindingError extends DiError {
|
|
@@ -86,6 +96,8 @@ export class AmbiguousBindingError extends DiError {
|
|
|
86
96
|
}
|
|
87
97
|
|
|
88
98
|
/**
|
|
99
|
+
* A dependency cycle detected along the resolution path, alias chains included.
|
|
100
|
+
*
|
|
89
101
|
* @since 0.3.16-canary.0
|
|
90
102
|
*/
|
|
91
103
|
export class CircularDependencyError extends DiError {
|
|
@@ -99,6 +111,8 @@ export class CircularDependencyError extends DiError {
|
|
|
99
111
|
}
|
|
100
112
|
|
|
101
113
|
/**
|
|
114
|
+
* A sync `resolve()` of a token whose factory — or a dependency's factory — is async.
|
|
115
|
+
*
|
|
102
116
|
* @since 0.3.16-canary.0
|
|
103
117
|
*/
|
|
104
118
|
export class AsyncResolutionError extends DiError {
|
|
@@ -120,6 +134,8 @@ export class AsyncResolutionError extends DiError {
|
|
|
120
134
|
}
|
|
121
135
|
|
|
122
136
|
/**
|
|
137
|
+
* A sync `unbind()` of a binding whose `onDeactivation` handler is async.
|
|
138
|
+
*
|
|
123
139
|
* @since 0.3.16-canary.0
|
|
124
140
|
*/
|
|
125
141
|
export class AsyncDeactivationError extends DiError {
|
|
@@ -133,6 +149,8 @@ export class AsyncDeactivationError extends DiError {
|
|
|
133
149
|
}
|
|
134
150
|
|
|
135
151
|
/**
|
|
152
|
+
* The tokens, scopes, and resolution path describing a captive-dependency violation.
|
|
153
|
+
*
|
|
136
154
|
* @since 0.3.16-canary.0
|
|
137
155
|
*/
|
|
138
156
|
export interface ScopeViolationDetails {
|
|
@@ -144,6 +162,8 @@ export interface ScopeViolationDetails {
|
|
|
144
162
|
}
|
|
145
163
|
|
|
146
164
|
/**
|
|
165
|
+
* A captive dependency — a longer-lived binding depending on a shorter-lived one.
|
|
166
|
+
*
|
|
147
167
|
* @since 0.3.16-canary.0
|
|
148
168
|
*/
|
|
149
169
|
export class ScopeViolationError extends DiError {
|
|
@@ -251,6 +271,8 @@ export class InvalidMetadataError extends DiError {
|
|
|
251
271
|
}
|
|
252
272
|
|
|
253
273
|
/**
|
|
274
|
+
* A class the container must construct but that carries no `@injectable()` metadata.
|
|
275
|
+
*
|
|
254
276
|
* @since 0.3.16-canary.0
|
|
255
277
|
*/
|
|
256
278
|
export class MissingMetadataError extends DiError {
|
|
@@ -266,6 +288,8 @@ export class MissingMetadataError extends DiError {
|
|
|
266
288
|
}
|
|
267
289
|
|
|
268
290
|
/**
|
|
291
|
+
* A sync `load()` given a module that needs async setup.
|
|
292
|
+
*
|
|
269
293
|
* @since 0.3.16-canary.0
|
|
270
294
|
*/
|
|
271
295
|
export class AsyncModuleLoadError extends DiError {
|
|
@@ -279,6 +303,8 @@ export class AsyncModuleLoadError extends DiError {
|
|
|
279
303
|
}
|
|
280
304
|
|
|
281
305
|
/**
|
|
306
|
+
* A synchronous disposal attempt on a container whose `onDeactivation` handlers may be async.
|
|
307
|
+
*
|
|
282
308
|
* @since 0.3.16-canary.0
|
|
283
309
|
*/
|
|
284
310
|
export class SyncDisposalNotSupportedError extends DiError {
|
|
@@ -292,6 +318,8 @@ export class SyncDisposalNotSupportedError extends DiError {
|
|
|
292
318
|
}
|
|
293
319
|
|
|
294
320
|
/**
|
|
321
|
+
* A `scoped` binding resolved from a container with no child scope context.
|
|
322
|
+
*
|
|
295
323
|
* @since 0.3.16-canary.0
|
|
296
324
|
*/
|
|
297
325
|
export class MissingScopeContextError extends DiError {
|
|
@@ -355,6 +383,8 @@ export class ChainNotRegisteredError extends DiError {
|
|
|
355
383
|
}
|
|
356
384
|
|
|
357
385
|
/**
|
|
386
|
+
* A `rebind()` of a token that has no own binding in this container.
|
|
387
|
+
*
|
|
358
388
|
* @since 0.3.16-canary.0
|
|
359
389
|
*/
|
|
360
390
|
export class RebindUnboundTokenError extends DiError {
|
|
@@ -410,6 +440,8 @@ export class StaticMemberDecoratorError extends DiError {
|
|
|
410
440
|
}
|
|
411
441
|
|
|
412
442
|
/**
|
|
443
|
+
* An operation attempted on a container that has already been disposed.
|
|
444
|
+
*
|
|
413
445
|
* @since 0.3.16-canary.0
|
|
414
446
|
*/
|
|
415
447
|
export class DisposedContainerError extends DiError {
|
|
@@ -421,6 +453,8 @@ export class DisposedContainerError extends DiError {
|
|
|
421
453
|
}
|
|
422
454
|
|
|
423
455
|
/**
|
|
456
|
+
* A `@postConstruct` or `onActivation` hook that returned a `Promise` on a sync resolution path.
|
|
457
|
+
*
|
|
424
458
|
* @since 0.3.16-canary.0
|
|
425
459
|
*/
|
|
426
460
|
export class AsyncActivationError extends DiError {
|