@codefast/di 0.5.0-canary.5 → 0.5.0-canary.7
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 +65 -0
- package/README.md +73 -496
- package/dist/binding.d.ts +211 -0
- package/dist/binding.d.ts.map +1 -0
- package/dist/binding.js +46 -0
- package/dist/binding.js.map +1 -0
- package/dist/{constructor-type.d.mts → constructor-type.d.ts} +3 -5
- package/dist/constructor-type.d.ts.map +1 -0
- package/dist/constructor-type.js +2 -0
- package/dist/constructor-type.js.map +1 -0
- package/dist/container/binding-builders.d.ts +35 -0
- package/dist/container/binding-builders.d.ts.map +1 -0
- package/dist/container/binding-builders.js +247 -0
- package/dist/container/binding-builders.js.map +1 -0
- package/dist/container/container.d.ts +58 -0
- package/dist/container/container.d.ts.map +1 -0
- package/dist/container/container.js +641 -0
- package/dist/container/container.js.map +1 -0
- package/dist/decorators/inject.d.ts +57 -0
- package/dist/decorators/inject.d.ts.map +1 -0
- package/dist/decorators/inject.js +145 -0
- package/dist/decorators/inject.js.map +1 -0
- package/dist/decorators/injectable.d.ts +29 -0
- package/dist/decorators/injectable.d.ts.map +1 -0
- package/dist/decorators/injectable.js +53 -0
- package/dist/decorators/injectable.js.map +1 -0
- package/dist/decorators/lifecycle-decorators.d.ts +9 -0
- package/dist/decorators/lifecycle-decorators.d.ts.map +1 -0
- package/dist/decorators/lifecycle-decorators.js +40 -0
- package/dist/decorators/lifecycle-decorators.js.map +1 -0
- package/dist/errors.d.ts +150 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +197 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/introspection/dependency-graph.d.ts +40 -0
- package/dist/introspection/dependency-graph.d.ts.map +1 -0
- package/dist/introspection/dependency-graph.js +66 -0
- package/dist/introspection/dependency-graph.js.map +1 -0
- package/dist/introspection/graph-adapters/cytoscape.d.ts +33 -0
- package/dist/introspection/graph-adapters/cytoscape.d.ts.map +1 -0
- package/dist/introspection/graph-adapters/cytoscape.js +30 -0
- package/dist/introspection/graph-adapters/cytoscape.js.map +1 -0
- package/dist/introspection/graph-adapters/dot.d.ts +6 -0
- package/dist/introspection/graph-adapters/dot.d.ts.map +1 -0
- package/dist/introspection/graph-adapters/dot.js +18 -0
- package/dist/introspection/graph-adapters/dot.js.map +1 -0
- package/dist/introspection/graph-adapters/reactflow.d.ts +38 -0
- package/dist/introspection/graph-adapters/reactflow.d.ts.map +1 -0
- package/dist/introspection/graph-adapters/reactflow.js +33 -0
- package/dist/introspection/graph-adapters/reactflow.js.map +1 -0
- package/dist/introspection/inspector.d.ts +39 -0
- package/dist/introspection/inspector.d.ts.map +1 -0
- package/dist/introspection/inspector.js +82 -0
- package/dist/introspection/inspector.js.map +1 -0
- package/dist/metadata/{metadata-keys.d.mts → metadata-keys.d.ts} +5 -7
- package/dist/metadata/metadata-keys.d.ts.map +1 -0
- package/dist/metadata/metadata-keys.js +25 -0
- package/dist/metadata/metadata-keys.js.map +1 -0
- package/dist/metadata/metadata-reader-token.d.ts +7 -0
- package/dist/metadata/metadata-reader-token.d.ts.map +1 -0
- package/dist/metadata/metadata-reader-token.js +6 -0
- package/dist/metadata/metadata-reader-token.js.map +1 -0
- package/dist/metadata/metadata-types.d.ts +48 -0
- package/dist/metadata/metadata-types.d.ts.map +1 -0
- package/dist/metadata/metadata-types.js +2 -0
- package/dist/metadata/metadata-types.js.map +1 -0
- package/dist/metadata/symbol-metadata-reader.d.ts +20 -0
- package/dist/metadata/symbol-metadata-reader.d.ts.map +1 -0
- package/dist/metadata/symbol-metadata-reader.js +34 -0
- package/dist/metadata/symbol-metadata-reader.js.map +1 -0
- package/dist/module.d.ts +67 -0
- package/dist/module.d.ts.map +1 -0
- package/dist/module.js +54 -0
- package/dist/module.js.map +1 -0
- package/dist/registry.d.ts +33 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +249 -0
- package/dist/registry.js.map +1 -0
- package/dist/resolution/binding-scope.d.ts +10 -0
- package/dist/resolution/binding-scope.d.ts.map +1 -0
- package/dist/resolution/binding-scope.js +24 -0
- package/dist/resolution/binding-scope.js.map +1 -0
- package/dist/resolution/binding-select.d.ts +16 -0
- package/dist/resolution/binding-select.d.ts.map +1 -0
- package/dist/resolution/binding-select.js +143 -0
- package/dist/resolution/binding-select.js.map +1 -0
- package/dist/resolution/constraints.d.ts +51 -0
- package/dist/resolution/constraints.d.ts.map +1 -0
- package/dist/resolution/constraints.js +88 -0
- package/dist/resolution/constraints.js.map +1 -0
- package/dist/resolution/environment.d.ts +47 -0
- package/dist/resolution/environment.d.ts.map +1 -0
- package/dist/resolution/environment.js +100 -0
- package/dist/resolution/environment.js.map +1 -0
- package/dist/resolution/instantiation-plan.d.ts +67 -0
- package/dist/resolution/instantiation-plan.d.ts.map +1 -0
- package/dist/resolution/instantiation-plan.js +163 -0
- package/dist/resolution/instantiation-plan.js.map +1 -0
- package/dist/resolution/lifecycle.d.ts +21 -0
- package/dist/resolution/lifecycle.d.ts.map +1 -0
- package/dist/resolution/lifecycle.js +178 -0
- package/dist/resolution/lifecycle.js.map +1 -0
- package/dist/resolution/resolution-path.d.ts +31 -0
- package/dist/resolution/resolution-path.d.ts.map +1 -0
- package/dist/resolution/resolution-path.js +53 -0
- package/dist/resolution/resolution-path.js.map +1 -0
- package/dist/resolution/resolve-options.d.ts +19 -0
- package/dist/resolution/resolve-options.d.ts.map +1 -0
- package/dist/resolution/resolve-options.js +32 -0
- package/dist/resolution/resolve-options.js.map +1 -0
- package/dist/resolution/resolver.d.ts +35 -0
- package/dist/resolution/resolver.d.ts.map +1 -0
- package/dist/resolution/resolver.js +1320 -0
- package/dist/resolution/resolver.js.map +1 -0
- package/dist/resolution/scope.d.ts +32 -0
- package/dist/resolution/scope.d.ts.map +1 -0
- package/dist/resolution/scope.js +76 -0
- package/dist/resolution/scope.js.map +1 -0
- package/dist/token.d.ts +23 -0
- package/dist/token.d.ts.map +1 -0
- package/dist/token.js +22 -0
- package/dist/token.js.map +1 -0
- package/dist/types.d.ts +90 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +143 -120
- package/src/binding.ts +38 -22
- package/src/container/binding-builders.ts +397 -0
- package/src/container/container.ts +838 -0
- package/src/decorators/inject.ts +16 -3
- package/src/decorators/injectable.ts +3 -3
- package/src/index.ts +14 -7
- package/src/{dependency-graph.ts → introspection/dependency-graph.ts} +1 -1
- package/src/{graph-adapters → introspection/graph-adapters}/cytoscape.ts +1 -1
- package/src/{graph-adapters → introspection/graph-adapters}/dot.ts +1 -1
- package/src/{graph-adapters → introspection/graph-adapters}/reactflow.ts +13 -2
- package/src/{inspector.ts → introspection/inspector.ts} +26 -21
- package/src/metadata/symbol-metadata-reader.ts +4 -4
- package/src/module.ts +14 -6
- package/src/registry.ts +115 -61
- package/src/{binding-select.ts → resolution/binding-select.ts} +16 -3
- package/src/{environment.ts → resolution/environment.ts} +35 -35
- package/src/resolution/instantiation-plan.ts +240 -0
- package/src/{lifecycle.ts → resolution/lifecycle.ts} +20 -13
- package/src/resolution/resolution-path.ts +77 -0
- package/src/resolution/resolver.ts +1755 -0
- package/src/{scope.ts → resolution/scope.ts} +35 -18
- package/src/token.ts +0 -3
- package/dist/binding-scope.d.mts +0 -13
- package/dist/binding-scope.mjs +0 -21
- package/dist/binding-select.d.mts +0 -19
- package/dist/binding-select.mjs +0 -72
- package/dist/binding.d.mts +0 -191
- package/dist/binding.mjs +0 -36
- package/dist/constraints.d.mts +0 -55
- package/dist/constraints.mjs +0 -87
- package/dist/constructor-type.mjs +0 -1
- package/dist/container.d.mts +0 -62
- package/dist/container.mjs +0 -741
- package/dist/decorators/inject.d.mts +0 -49
- package/dist/decorators/inject.mjs +0 -136
- package/dist/decorators/injectable.d.mts +0 -32
- package/dist/decorators/injectable.mjs +0 -57
- package/dist/decorators/lifecycle-decorators.d.mts +0 -11
- package/dist/decorators/lifecycle-decorators.mjs +0 -38
- package/dist/dependency-graph.d.mts +0 -43
- package/dist/dependency-graph.mjs +0 -63
- package/dist/environment.d.mts +0 -55
- package/dist/environment.mjs +0 -98
- package/dist/errors.d.mts +0 -153
- package/dist/errors.mjs +0 -197
- package/dist/graph-adapters/cytoscape.d.mts +0 -36
- package/dist/graph-adapters/cytoscape.mjs +0 -26
- package/dist/graph-adapters/dot.d.mts +0 -9
- package/dist/graph-adapters/dot.mjs +0 -20
- package/dist/graph-adapters/reactflow.d.mts +0 -41
- package/dist/graph-adapters/reactflow.mjs +0 -29
- package/dist/index.d.mts +0 -18
- package/dist/index.mjs +0 -12
- package/dist/inspector.d.mts +0 -48
- package/dist/inspector.mjs +0 -71
- package/dist/lifecycle.d.mts +0 -25
- package/dist/lifecycle.mjs +0 -118
- package/dist/metadata/metadata-keys.mjs +0 -27
- package/dist/metadata/metadata-reader-token.d.mts +0 -10
- package/dist/metadata/metadata-reader-token.mjs +0 -8
- package/dist/metadata/metadata-types.d.mts +0 -51
- package/dist/metadata/metadata-types.mjs +0 -1
- package/dist/metadata/symbol-metadata-reader.d.mts +0 -23
- package/dist/metadata/symbol-metadata-reader.mjs +0 -29
- package/dist/module.d.mts +0 -62
- package/dist/module.mjs +0 -42
- package/dist/registry.d.mts +0 -45
- package/dist/registry.mjs +0 -163
- package/dist/resolve-options.d.mts +0 -22
- package/dist/resolve-options.mjs +0 -28
- package/dist/resolver.d.mts +0 -94
- package/dist/resolver.mjs +0 -767
- package/dist/scope.d.mts +0 -28
- package/dist/scope.mjs +0 -58
- package/dist/token.d.mts +0 -25
- package/dist/token.mjs +0 -22
- package/dist/types.d.mts +0 -92
- package/dist/types.mjs +0 -1
- package/src/container.ts +0 -1141
- package/src/resolver.ts +0 -1626
- /package/src/{binding-scope.ts → resolution/binding-scope.ts} +0 -0
- /package/src/{constraints.ts → resolution/constraints.ts} +0 -0
- /package/src/{resolve-options.ts → resolution/resolve-options.ts} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codefast/di",
|
|
3
|
-
"version": "0.5.0-canary.
|
|
3
|
+
"version": "0.5.0-canary.7",
|
|
4
4
|
"description": "Lightweight dependency injection primitives for Codefast",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"codefast",
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
],
|
|
26
26
|
"type": "module",
|
|
27
27
|
"sideEffects": false,
|
|
28
|
-
"main": "./dist/index.
|
|
29
|
-
"module": "./dist/index.
|
|
30
|
-
"types": "./dist/index.d.
|
|
28
|
+
"main": "./dist/index.js",
|
|
29
|
+
"module": "./dist/index.js",
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
31
|
"imports": {
|
|
32
32
|
"#/tests/*": [
|
|
33
33
|
"./tests/*",
|
|
@@ -36,159 +36,184 @@
|
|
|
36
36
|
"./tests/*/index.ts",
|
|
37
37
|
"./tests/*/index.tsx"
|
|
38
38
|
],
|
|
39
|
-
"#/*":
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
"#/*": {
|
|
40
|
+
"source": [
|
|
41
|
+
"./src/*",
|
|
42
|
+
"./src/*.ts",
|
|
43
|
+
"./src/*.tsx",
|
|
44
|
+
"./src/*/index.ts",
|
|
45
|
+
"./src/*/index.tsx"
|
|
46
|
+
],
|
|
47
|
+
"types": [
|
|
48
|
+
"./dist/*.d.ts",
|
|
49
|
+
"./dist/*/index.d.ts"
|
|
50
|
+
],
|
|
51
|
+
"default": [
|
|
52
|
+
"./dist/*.js",
|
|
53
|
+
"./dist/*/index.js"
|
|
54
|
+
]
|
|
55
|
+
}
|
|
46
56
|
},
|
|
47
57
|
"exports": {
|
|
48
58
|
".": {
|
|
49
59
|
"source": "./src/index.ts",
|
|
50
|
-
"types": "./dist/index.d.
|
|
51
|
-
"import": "./dist/index.
|
|
60
|
+
"types": "./dist/index.d.ts",
|
|
61
|
+
"import": "./dist/index.js"
|
|
52
62
|
},
|
|
53
63
|
"./binding": {
|
|
54
64
|
"source": "./src/binding.ts",
|
|
55
|
-
"types": "./dist/binding.d.
|
|
56
|
-
"import": "./dist/binding.
|
|
57
|
-
},
|
|
58
|
-
"./binding-scope": {
|
|
59
|
-
"source": "./src/binding-scope.ts",
|
|
60
|
-
"types": "./dist/binding-scope.d.mts",
|
|
61
|
-
"import": "./dist/binding-scope.mjs"
|
|
62
|
-
},
|
|
63
|
-
"./binding-select": {
|
|
64
|
-
"source": "./src/binding-select.ts",
|
|
65
|
-
"types": "./dist/binding-select.d.mts",
|
|
66
|
-
"import": "./dist/binding-select.mjs"
|
|
67
|
-
},
|
|
68
|
-
"./constraints": {
|
|
69
|
-
"source": "./src/constraints.ts",
|
|
70
|
-
"types": "./dist/constraints.d.mts",
|
|
71
|
-
"import": "./dist/constraints.mjs"
|
|
65
|
+
"types": "./dist/binding.d.ts",
|
|
66
|
+
"import": "./dist/binding.js"
|
|
72
67
|
},
|
|
73
68
|
"./constructor-type": {
|
|
74
69
|
"source": "./src/constructor-type.ts",
|
|
75
|
-
"types": "./dist/constructor-type.d.
|
|
76
|
-
"import": "./dist/constructor-type.
|
|
70
|
+
"types": "./dist/constructor-type.d.ts",
|
|
71
|
+
"import": "./dist/constructor-type.js"
|
|
77
72
|
},
|
|
78
|
-
"./container": {
|
|
79
|
-
"source": "./src/container.ts",
|
|
80
|
-
"types": "./dist/container.d.
|
|
81
|
-
"import": "./dist/container.
|
|
73
|
+
"./container/binding-builders": {
|
|
74
|
+
"source": "./src/container/binding-builders.ts",
|
|
75
|
+
"types": "./dist/container/binding-builders.d.ts",
|
|
76
|
+
"import": "./dist/container/binding-builders.js"
|
|
77
|
+
},
|
|
78
|
+
"./container/container": {
|
|
79
|
+
"source": "./src/container/container.ts",
|
|
80
|
+
"types": "./dist/container/container.d.ts",
|
|
81
|
+
"import": "./dist/container/container.js"
|
|
82
82
|
},
|
|
83
83
|
"./decorators/inject": {
|
|
84
84
|
"source": "./src/decorators/inject.ts",
|
|
85
|
-
"types": "./dist/decorators/inject.d.
|
|
86
|
-
"import": "./dist/decorators/inject.
|
|
85
|
+
"types": "./dist/decorators/inject.d.ts",
|
|
86
|
+
"import": "./dist/decorators/inject.js"
|
|
87
87
|
},
|
|
88
88
|
"./decorators/injectable": {
|
|
89
89
|
"source": "./src/decorators/injectable.ts",
|
|
90
|
-
"types": "./dist/decorators/injectable.d.
|
|
91
|
-
"import": "./dist/decorators/injectable.
|
|
90
|
+
"types": "./dist/decorators/injectable.d.ts",
|
|
91
|
+
"import": "./dist/decorators/injectable.js"
|
|
92
92
|
},
|
|
93
93
|
"./decorators/lifecycle-decorators": {
|
|
94
94
|
"source": "./src/decorators/lifecycle-decorators.ts",
|
|
95
|
-
"types": "./dist/decorators/lifecycle-decorators.d.
|
|
96
|
-
"import": "./dist/decorators/lifecycle-decorators.
|
|
97
|
-
},
|
|
98
|
-
"./dependency-graph": {
|
|
99
|
-
"source": "./src/dependency-graph.ts",
|
|
100
|
-
"types": "./dist/dependency-graph.d.mts",
|
|
101
|
-
"import": "./dist/dependency-graph.mjs"
|
|
102
|
-
},
|
|
103
|
-
"./environment": {
|
|
104
|
-
"source": "./src/environment.ts",
|
|
105
|
-
"types": "./dist/environment.d.mts",
|
|
106
|
-
"import": "./dist/environment.mjs"
|
|
95
|
+
"types": "./dist/decorators/lifecycle-decorators.d.ts",
|
|
96
|
+
"import": "./dist/decorators/lifecycle-decorators.js"
|
|
107
97
|
},
|
|
108
98
|
"./errors": {
|
|
109
99
|
"source": "./src/errors.ts",
|
|
110
|
-
"types": "./dist/errors.d.
|
|
111
|
-
"import": "./dist/errors.
|
|
112
|
-
},
|
|
113
|
-
"./graph
|
|
114
|
-
"source": "./src/graph
|
|
115
|
-
"types": "./dist/graph
|
|
116
|
-
"import": "./dist/graph
|
|
117
|
-
},
|
|
118
|
-
"./graph-adapters/
|
|
119
|
-
"source": "./src/graph-adapters/
|
|
120
|
-
"types": "./dist/graph-adapters/
|
|
121
|
-
"import": "./dist/graph-adapters/
|
|
122
|
-
},
|
|
123
|
-
"./graph-adapters/
|
|
124
|
-
"source": "./src/graph-adapters/
|
|
125
|
-
"types": "./dist/graph-adapters/
|
|
126
|
-
"import": "./dist/graph-adapters/
|
|
127
|
-
},
|
|
128
|
-
"./
|
|
129
|
-
"source": "./src/
|
|
130
|
-
"types": "./dist/
|
|
131
|
-
"import": "./dist/
|
|
132
|
-
},
|
|
133
|
-
"./
|
|
134
|
-
"source": "./src/
|
|
135
|
-
"types": "./dist/
|
|
136
|
-
"import": "./dist/
|
|
100
|
+
"types": "./dist/errors.d.ts",
|
|
101
|
+
"import": "./dist/errors.js"
|
|
102
|
+
},
|
|
103
|
+
"./introspection/dependency-graph": {
|
|
104
|
+
"source": "./src/introspection/dependency-graph.ts",
|
|
105
|
+
"types": "./dist/introspection/dependency-graph.d.ts",
|
|
106
|
+
"import": "./dist/introspection/dependency-graph.js"
|
|
107
|
+
},
|
|
108
|
+
"./introspection/graph-adapters/cytoscape": {
|
|
109
|
+
"source": "./src/introspection/graph-adapters/cytoscape.ts",
|
|
110
|
+
"types": "./dist/introspection/graph-adapters/cytoscape.d.ts",
|
|
111
|
+
"import": "./dist/introspection/graph-adapters/cytoscape.js"
|
|
112
|
+
},
|
|
113
|
+
"./introspection/graph-adapters/dot": {
|
|
114
|
+
"source": "./src/introspection/graph-adapters/dot.ts",
|
|
115
|
+
"types": "./dist/introspection/graph-adapters/dot.d.ts",
|
|
116
|
+
"import": "./dist/introspection/graph-adapters/dot.js"
|
|
117
|
+
},
|
|
118
|
+
"./introspection/graph-adapters/reactflow": {
|
|
119
|
+
"source": "./src/introspection/graph-adapters/reactflow.ts",
|
|
120
|
+
"types": "./dist/introspection/graph-adapters/reactflow.d.ts",
|
|
121
|
+
"import": "./dist/introspection/graph-adapters/reactflow.js"
|
|
122
|
+
},
|
|
123
|
+
"./introspection/inspector": {
|
|
124
|
+
"source": "./src/introspection/inspector.ts",
|
|
125
|
+
"types": "./dist/introspection/inspector.d.ts",
|
|
126
|
+
"import": "./dist/introspection/inspector.js"
|
|
137
127
|
},
|
|
138
128
|
"./metadata/metadata-keys": {
|
|
139
129
|
"source": "./src/metadata/metadata-keys.ts",
|
|
140
|
-
"types": "./dist/metadata/metadata-keys.d.
|
|
141
|
-
"import": "./dist/metadata/metadata-keys.
|
|
130
|
+
"types": "./dist/metadata/metadata-keys.d.ts",
|
|
131
|
+
"import": "./dist/metadata/metadata-keys.js"
|
|
142
132
|
},
|
|
143
133
|
"./metadata/metadata-reader-token": {
|
|
144
134
|
"source": "./src/metadata/metadata-reader-token.ts",
|
|
145
|
-
"types": "./dist/metadata/metadata-reader-token.d.
|
|
146
|
-
"import": "./dist/metadata/metadata-reader-token.
|
|
135
|
+
"types": "./dist/metadata/metadata-reader-token.d.ts",
|
|
136
|
+
"import": "./dist/metadata/metadata-reader-token.js"
|
|
147
137
|
},
|
|
148
138
|
"./metadata/metadata-types": {
|
|
149
139
|
"source": "./src/metadata/metadata-types.ts",
|
|
150
|
-
"types": "./dist/metadata/metadata-types.d.
|
|
151
|
-
"import": "./dist/metadata/metadata-types.
|
|
140
|
+
"types": "./dist/metadata/metadata-types.d.ts",
|
|
141
|
+
"import": "./dist/metadata/metadata-types.js"
|
|
152
142
|
},
|
|
153
143
|
"./metadata/symbol-metadata-reader": {
|
|
154
144
|
"source": "./src/metadata/symbol-metadata-reader.ts",
|
|
155
|
-
"types": "./dist/metadata/symbol-metadata-reader.d.
|
|
156
|
-
"import": "./dist/metadata/symbol-metadata-reader.
|
|
145
|
+
"types": "./dist/metadata/symbol-metadata-reader.d.ts",
|
|
146
|
+
"import": "./dist/metadata/symbol-metadata-reader.js"
|
|
157
147
|
},
|
|
158
148
|
"./module": {
|
|
159
149
|
"source": "./src/module.ts",
|
|
160
|
-
"types": "./dist/module.d.
|
|
161
|
-
"import": "./dist/module.
|
|
150
|
+
"types": "./dist/module.d.ts",
|
|
151
|
+
"import": "./dist/module.js"
|
|
162
152
|
},
|
|
163
153
|
"./registry": {
|
|
164
154
|
"source": "./src/registry.ts",
|
|
165
|
-
"types": "./dist/registry.d.
|
|
166
|
-
"import": "./dist/registry.
|
|
167
|
-
},
|
|
168
|
-
"./
|
|
169
|
-
"source": "./src/
|
|
170
|
-
"types": "./dist/
|
|
171
|
-
"import": "./dist/
|
|
172
|
-
},
|
|
173
|
-
"./
|
|
174
|
-
"source": "./src/
|
|
175
|
-
"types": "./dist/
|
|
176
|
-
"import": "./dist/
|
|
177
|
-
},
|
|
178
|
-
"./
|
|
179
|
-
"source": "./src/
|
|
180
|
-
"types": "./dist/
|
|
181
|
-
"import": "./dist/
|
|
155
|
+
"types": "./dist/registry.d.ts",
|
|
156
|
+
"import": "./dist/registry.js"
|
|
157
|
+
},
|
|
158
|
+
"./resolution/binding-scope": {
|
|
159
|
+
"source": "./src/resolution/binding-scope.ts",
|
|
160
|
+
"types": "./dist/resolution/binding-scope.d.ts",
|
|
161
|
+
"import": "./dist/resolution/binding-scope.js"
|
|
162
|
+
},
|
|
163
|
+
"./resolution/binding-select": {
|
|
164
|
+
"source": "./src/resolution/binding-select.ts",
|
|
165
|
+
"types": "./dist/resolution/binding-select.d.ts",
|
|
166
|
+
"import": "./dist/resolution/binding-select.js"
|
|
167
|
+
},
|
|
168
|
+
"./resolution/class-plan": {
|
|
169
|
+
"source": "./src/resolution/class-plan.ts",
|
|
170
|
+
"types": "./dist/resolution/class-plan.d.ts",
|
|
171
|
+
"import": "./dist/resolution/class-plan.js"
|
|
172
|
+
},
|
|
173
|
+
"./resolution/constraints": {
|
|
174
|
+
"source": "./src/resolution/constraints.ts",
|
|
175
|
+
"types": "./dist/resolution/constraints.d.ts",
|
|
176
|
+
"import": "./dist/resolution/constraints.js"
|
|
177
|
+
},
|
|
178
|
+
"./resolution/environment": {
|
|
179
|
+
"source": "./src/resolution/environment.ts",
|
|
180
|
+
"types": "./dist/resolution/environment.d.ts",
|
|
181
|
+
"import": "./dist/resolution/environment.js"
|
|
182
|
+
},
|
|
183
|
+
"./resolution/lifecycle": {
|
|
184
|
+
"source": "./src/resolution/lifecycle.ts",
|
|
185
|
+
"types": "./dist/resolution/lifecycle.d.ts",
|
|
186
|
+
"import": "./dist/resolution/lifecycle.js"
|
|
187
|
+
},
|
|
188
|
+
"./resolution/resolution-path": {
|
|
189
|
+
"source": "./src/resolution/resolution-path.ts",
|
|
190
|
+
"types": "./dist/resolution/resolution-path.d.ts",
|
|
191
|
+
"import": "./dist/resolution/resolution-path.js"
|
|
192
|
+
},
|
|
193
|
+
"./resolution/resolve-options": {
|
|
194
|
+
"source": "./src/resolution/resolve-options.ts",
|
|
195
|
+
"types": "./dist/resolution/resolve-options.d.ts",
|
|
196
|
+
"import": "./dist/resolution/resolve-options.js"
|
|
197
|
+
},
|
|
198
|
+
"./resolution/resolver": {
|
|
199
|
+
"source": "./src/resolution/resolver.ts",
|
|
200
|
+
"types": "./dist/resolution/resolver.d.ts",
|
|
201
|
+
"import": "./dist/resolution/resolver.js"
|
|
202
|
+
},
|
|
203
|
+
"./resolution/scope": {
|
|
204
|
+
"source": "./src/resolution/scope.ts",
|
|
205
|
+
"types": "./dist/resolution/scope.d.ts",
|
|
206
|
+
"import": "./dist/resolution/scope.js"
|
|
182
207
|
},
|
|
183
208
|
"./token": {
|
|
184
209
|
"source": "./src/token.ts",
|
|
185
|
-
"types": "./dist/token.d.
|
|
186
|
-
"import": "./dist/token.
|
|
210
|
+
"types": "./dist/token.d.ts",
|
|
211
|
+
"import": "./dist/token.js"
|
|
187
212
|
},
|
|
188
213
|
"./types": {
|
|
189
214
|
"source": "./src/types.ts",
|
|
190
|
-
"types": "./dist/types.d.
|
|
191
|
-
"import": "./dist/types.
|
|
215
|
+
"types": "./dist/types.d.ts",
|
|
216
|
+
"import": "./dist/types.js"
|
|
192
217
|
},
|
|
193
218
|
"./package.json": "./package.json"
|
|
194
219
|
},
|
|
@@ -199,22 +224,20 @@
|
|
|
199
224
|
"@babel/core": "^8.0.1",
|
|
200
225
|
"@babel/plugin-proposal-decorators": "8.0.2",
|
|
201
226
|
"@rolldown/plugin-babel": "^0.2.3",
|
|
202
|
-
"@types/node": "^26.1.
|
|
203
|
-
"@
|
|
204
|
-
"@vitest/coverage-v8": "^4.1.9",
|
|
227
|
+
"@types/node": "^26.1.1",
|
|
228
|
+
"@vitest/coverage-v8": "^4.1.10",
|
|
205
229
|
"expect-type": "^1.4.0",
|
|
206
|
-
"
|
|
207
|
-
"
|
|
208
|
-
"
|
|
209
|
-
"
|
|
210
|
-
"@codefast/typescript-config": "0.5.0-canary.5"
|
|
230
|
+
"tsx": "^4.23.1",
|
|
231
|
+
"typescript": "^7.0.2",
|
|
232
|
+
"vitest": "^4.1.10",
|
|
233
|
+
"@codefast/typescript-config": "0.5.0-canary.7"
|
|
211
234
|
},
|
|
212
235
|
"engines": {
|
|
213
236
|
"node": ">=26.0.0"
|
|
214
237
|
},
|
|
215
238
|
"scripts": {
|
|
216
|
-
"build": "
|
|
217
|
-
"check-types": "
|
|
239
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json",
|
|
240
|
+
"check-types": "tsc --noEmit",
|
|
218
241
|
"clean": "rm -rf dist",
|
|
219
242
|
"examples": "for file in examples/*/*.ts; do echo \"=== Running $file ===\"; node --import tsx/esm \"$file\"; echo \"\n\" || exit 1; done",
|
|
220
243
|
"test": "vitest run",
|
package/src/binding.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { InjectionDescriptor } from "#/decorators/inject";
|
|
1
|
+
import type { InjectableDependency, InjectionDescriptor, ResolvedDependencyValue } from "#/decorators/inject";
|
|
2
2
|
import type { Token } from "#/token";
|
|
3
3
|
import type {
|
|
4
4
|
ActivationHandler,
|
|
@@ -7,9 +7,8 @@ import type {
|
|
|
7
7
|
BindingTag,
|
|
8
8
|
Constructor,
|
|
9
9
|
DeactivationHandler,
|
|
10
|
-
DependencyKey,
|
|
11
10
|
ResolutionContext,
|
|
12
|
-
|
|
11
|
+
ResolutionFrame,
|
|
13
12
|
ConstraintContext,
|
|
14
13
|
} from "#/types";
|
|
15
14
|
|
|
@@ -67,9 +66,26 @@ export function bindingSlotToString(slot: BindingSlot): string {
|
|
|
67
66
|
|
|
68
67
|
interface BindingBase<Value> {
|
|
69
68
|
readonly id: BindingIdentifier;
|
|
69
|
+
/**
|
|
70
|
+
* True while this binding's factory is on the sync resolution stack. The sync resolver marks
|
|
71
|
+
* it on enter and clears it on exit, making cycle detection an O(1) field read with no hashing,
|
|
72
|
+
* no path scan, and no side table. Sync resolution is single-threaded, so the flag is exactly
|
|
73
|
+
* path membership; the async lane keeps its own per-path check because chains can interleave.
|
|
74
|
+
*
|
|
75
|
+
* @remarks Resolver-owned bookkeeping — `registry.add` normalizes it, so callers never set it.
|
|
76
|
+
*/
|
|
77
|
+
inFlight?: boolean | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* Memoized resolution frame for this binding. Its contents derive only from immutable binding
|
|
80
|
+
* fields, so it is computed once on first resolve and reused instead of a per-resolver Map
|
|
81
|
+
* lookup on every hop.
|
|
82
|
+
*
|
|
83
|
+
* @remarks Resolver-owned bookkeeping — `registry.add` normalizes it, so callers never set it.
|
|
84
|
+
*/
|
|
85
|
+
frame?: ResolutionFrame | undefined;
|
|
70
86
|
readonly token: Token<Value> | Constructor<Value>;
|
|
71
87
|
readonly slot: BindingSlot;
|
|
72
|
-
readonly predicate?: (ctx: ConstraintContext) => boolean;
|
|
88
|
+
readonly predicate?: ((ctx: ConstraintContext) => boolean) | undefined;
|
|
73
89
|
}
|
|
74
90
|
|
|
75
91
|
type BindingBaseKeys = keyof BindingBase<unknown>;
|
|
@@ -83,8 +99,8 @@ export interface ClassBinding<Value> extends BindingBase<Value> {
|
|
|
83
99
|
readonly kind: "class";
|
|
84
100
|
readonly target: Constructor<Value>;
|
|
85
101
|
readonly scope: BindingScope;
|
|
86
|
-
readonly onActivation?: ActivationHandler<Value
|
|
87
|
-
readonly onDeactivation?: DeactivationHandler<Value
|
|
102
|
+
readonly onActivation?: ActivationHandler<Value> | undefined;
|
|
103
|
+
readonly onDeactivation?: DeactivationHandler<Value> | undefined;
|
|
88
104
|
}
|
|
89
105
|
|
|
90
106
|
/**
|
|
@@ -94,8 +110,8 @@ export interface DynamicBinding<Value> extends BindingBase<Value> {
|
|
|
94
110
|
readonly kind: "dynamic";
|
|
95
111
|
readonly factory: (ctx: ResolutionContext) => Value;
|
|
96
112
|
readonly scope: BindingScope;
|
|
97
|
-
readonly onActivation?: ActivationHandler<Value
|
|
98
|
-
readonly onDeactivation?: DeactivationHandler<Value
|
|
113
|
+
readonly onActivation?: ActivationHandler<Value> | undefined;
|
|
114
|
+
readonly onDeactivation?: DeactivationHandler<Value> | undefined;
|
|
99
115
|
}
|
|
100
116
|
|
|
101
117
|
/**
|
|
@@ -105,8 +121,8 @@ export interface DynamicAsyncBinding<Value> extends BindingBase<Value> {
|
|
|
105
121
|
readonly kind: "dynamic-async";
|
|
106
122
|
readonly factory: (ctx: ResolutionContext) => Promise<Value>;
|
|
107
123
|
readonly scope: BindingScope;
|
|
108
|
-
readonly onActivation?: ActivationHandler<Value
|
|
109
|
-
readonly onDeactivation?: DeactivationHandler<Value
|
|
124
|
+
readonly onActivation?: ActivationHandler<Value> | undefined;
|
|
125
|
+
readonly onDeactivation?: DeactivationHandler<Value> | undefined;
|
|
110
126
|
}
|
|
111
127
|
|
|
112
128
|
/**
|
|
@@ -117,8 +133,8 @@ export interface ResolvedBinding<Value> extends BindingBase<Value> {
|
|
|
117
133
|
readonly factory: (...args: Array<unknown>) => Value;
|
|
118
134
|
readonly deps: ReadonlyArray<InjectionDescriptor>;
|
|
119
135
|
readonly scope: BindingScope;
|
|
120
|
-
readonly onActivation?: ActivationHandler<Value
|
|
121
|
-
readonly onDeactivation?: DeactivationHandler<Value
|
|
136
|
+
readonly onActivation?: ActivationHandler<Value> | undefined;
|
|
137
|
+
readonly onDeactivation?: DeactivationHandler<Value> | undefined;
|
|
122
138
|
}
|
|
123
139
|
|
|
124
140
|
/**
|
|
@@ -129,8 +145,8 @@ export interface ResolvedAsyncBinding<Value> extends BindingBase<Value> {
|
|
|
129
145
|
readonly factory: (...args: Array<unknown>) => Promise<Value>;
|
|
130
146
|
readonly deps: ReadonlyArray<InjectionDescriptor>;
|
|
131
147
|
readonly scope: BindingScope;
|
|
132
|
-
readonly onActivation?: ActivationHandler<Value
|
|
133
|
-
readonly onDeactivation?: DeactivationHandler<Value
|
|
148
|
+
readonly onActivation?: ActivationHandler<Value> | undefined;
|
|
149
|
+
readonly onDeactivation?: DeactivationHandler<Value> | undefined;
|
|
134
150
|
}
|
|
135
151
|
|
|
136
152
|
/**
|
|
@@ -140,8 +156,8 @@ export interface ConstantBinding<Value> extends BindingBase<Value> {
|
|
|
140
156
|
readonly kind: "constant";
|
|
141
157
|
readonly value: Value;
|
|
142
158
|
readonly scope: "singleton";
|
|
143
|
-
readonly onActivation?: ActivationHandler<Value
|
|
144
|
-
readonly onDeactivation?: DeactivationHandler<Value
|
|
159
|
+
readonly onActivation?: ActivationHandler<Value> | undefined;
|
|
160
|
+
readonly onDeactivation?: DeactivationHandler<Value> | undefined;
|
|
145
161
|
}
|
|
146
162
|
|
|
147
163
|
/**
|
|
@@ -180,12 +196,12 @@ export type PartialBinding<Value> =
|
|
|
180
196
|
|
|
181
197
|
// ── ID generation ─────────────────────────────────────────────────────────────
|
|
182
198
|
|
|
183
|
-
let
|
|
199
|
+
let bindingIdCounter = 0;
|
|
184
200
|
/**
|
|
185
201
|
* @since 0.3.16-canary.0
|
|
186
202
|
*/
|
|
187
203
|
export function generateBindingId(): BindingIdentifier {
|
|
188
|
-
return String(++
|
|
204
|
+
return String(++bindingIdCounter) as BindingIdentifier;
|
|
189
205
|
}
|
|
190
206
|
|
|
191
207
|
// ── Builder interfaces ────────────────────────────────────────────────────────
|
|
@@ -212,12 +228,12 @@ export interface BindToBuilder<Value> {
|
|
|
212
228
|
toConstantValue(value: Value): ConstantBindingBuilder<Value>;
|
|
213
229
|
toDynamic(factory: (ctx: ResolutionContext) => Value): BindingBuilder<Value>;
|
|
214
230
|
toDynamicAsync(factory: (ctx: ResolutionContext) => Promise<Value>): BindingBuilder<Value>;
|
|
215
|
-
toResolved<const Deps extends ReadonlyArray<
|
|
216
|
-
factory: (...args: { [K in keyof Deps]:
|
|
231
|
+
toResolved<const Deps extends ReadonlyArray<InjectableDependency>>(
|
|
232
|
+
factory: (...args: { [K in keyof Deps]: ResolvedDependencyValue<NoInfer<Deps>[K]> }) => Value,
|
|
217
233
|
deps: Deps,
|
|
218
234
|
): BindingBuilder<Value>;
|
|
219
|
-
toResolvedAsync<const Deps extends ReadonlyArray<
|
|
220
|
-
factory: (...args: { [K in keyof Deps]:
|
|
235
|
+
toResolvedAsync<const Deps extends ReadonlyArray<InjectableDependency>>(
|
|
236
|
+
factory: (...args: { [K in keyof Deps]: ResolvedDependencyValue<NoInfer<Deps>[K]> }) => Promise<Value>,
|
|
221
237
|
deps: Deps,
|
|
222
238
|
): BindingBuilder<Value>;
|
|
223
239
|
toAlias(target: Token<Value> | Constructor<Value>): AliasBindingBuilder;
|