@codefast/di 0.5.0-canary.6 → 0.5.0-canary.8

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.
Files changed (195) hide show
  1. package/CHANGELOG.md +123 -0
  2. package/README.md +15 -4
  3. package/dist/binding.d.ts +78 -19
  4. package/dist/binding.d.ts.map +1 -1
  5. package/dist/binding.js +46 -2
  6. package/dist/binding.js.map +1 -1
  7. package/dist/constructor-type.d.ts +4 -5
  8. package/dist/constructor-type.d.ts.map +1 -1
  9. package/dist/container/binding-builders.d.ts +56 -0
  10. package/dist/container/binding-builders.d.ts.map +1 -0
  11. package/dist/container/binding-builders.js +196 -0
  12. package/dist/container/binding-builders.js.map +1 -0
  13. package/dist/{container.d.ts → container/container.d.ts} +2 -2
  14. package/dist/container/container.d.ts.map +1 -0
  15. package/dist/container/container.js +624 -0
  16. package/dist/container/container.js.map +1 -0
  17. package/dist/decorators/inject.d.ts +10 -1
  18. package/dist/decorators/inject.d.ts.map +1 -1
  19. package/dist/decorators/inject.js +2 -2
  20. package/dist/decorators/inject.js.map +1 -1
  21. package/dist/decorators/injectable.js +3 -3
  22. package/dist/decorators/injectable.js.map +1 -1
  23. package/dist/errors.d.ts +14 -0
  24. package/dist/errors.d.ts.map +1 -1
  25. package/dist/errors.js +17 -0
  26. package/dist/errors.js.map +1 -1
  27. package/dist/index.d.ts +13 -8
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +9 -5
  30. package/dist/index.js.map +1 -1
  31. package/dist/introspection/dependency-graph.d.ts.map +1 -0
  32. package/dist/{dependency-graph.js → introspection/dependency-graph.js} +1 -1
  33. package/dist/introspection/dependency-graph.js.map +1 -0
  34. package/dist/{graph-adapters → introspection/graph-adapters}/cytoscape.d.ts +1 -1
  35. package/dist/introspection/graph-adapters/cytoscape.d.ts.map +1 -0
  36. package/dist/introspection/graph-adapters/cytoscape.js.map +1 -0
  37. package/dist/introspection/graph-adapters/dot.d.ts +6 -0
  38. package/dist/introspection/graph-adapters/dot.d.ts.map +1 -0
  39. package/dist/introspection/graph-adapters/dot.js.map +1 -0
  40. package/dist/{graph-adapters → introspection/graph-adapters}/reactflow.d.ts +2 -2
  41. package/dist/introspection/graph-adapters/reactflow.d.ts.map +1 -0
  42. package/dist/{graph-adapters → introspection/graph-adapters}/reactflow.js +11 -1
  43. package/dist/introspection/graph-adapters/reactflow.js.map +1 -0
  44. package/dist/{inspector.d.ts → introspection/inspector.d.ts} +3 -8
  45. package/dist/introspection/inspector.d.ts.map +1 -0
  46. package/dist/{inspector.js → introspection/inspector.js} +23 -23
  47. package/dist/introspection/inspector.js.map +1 -0
  48. package/dist/metadata/metadata-keys.d.ts +3 -6
  49. package/dist/metadata/metadata-keys.d.ts.map +1 -1
  50. package/dist/metadata/metadata-keys.js +3 -6
  51. package/dist/metadata/metadata-keys.js.map +1 -1
  52. package/dist/metadata/symbol-metadata-reader.d.ts +1 -1
  53. package/dist/metadata/symbol-metadata-reader.d.ts.map +1 -1
  54. package/dist/metadata/symbol-metadata-reader.js +4 -4
  55. package/dist/metadata/symbol-metadata-reader.js.map +1 -1
  56. package/dist/module.d.ts +9 -2
  57. package/dist/module.d.ts.map +1 -1
  58. package/dist/module.js +9 -2
  59. package/dist/module.js.map +1 -1
  60. package/dist/registry.d.ts +17 -13
  61. package/dist/registry.d.ts.map +1 -1
  62. package/dist/registry.js +94 -63
  63. package/dist/registry.js.map +1 -1
  64. package/dist/resolution/activation-need.d.ts +25 -0
  65. package/dist/resolution/activation-need.d.ts.map +1 -0
  66. package/dist/resolution/activation-need.js +64 -0
  67. package/dist/resolution/activation-need.js.map +1 -0
  68. package/dist/resolution/binding-lookup-cache.d.ts +41 -0
  69. package/dist/resolution/binding-lookup-cache.d.ts.map +1 -0
  70. package/dist/resolution/binding-lookup-cache.js +102 -0
  71. package/dist/resolution/binding-lookup-cache.js.map +1 -0
  72. package/dist/resolution/binding-scope.d.ts.map +1 -0
  73. package/dist/resolution/binding-scope.js.map +1 -0
  74. package/dist/resolution/binding-select.d.ts.map +1 -0
  75. package/dist/{binding-select.js → resolution/binding-select.js} +17 -7
  76. package/dist/resolution/binding-select.js.map +1 -0
  77. package/dist/resolution/class-introspector.d.ts +27 -0
  78. package/dist/resolution/class-introspector.d.ts.map +1 -0
  79. package/dist/resolution/class-introspector.js +60 -0
  80. package/dist/resolution/class-introspector.js.map +1 -0
  81. package/dist/resolution/constraints.d.ts.map +1 -0
  82. package/dist/resolution/constraints.js.map +1 -0
  83. package/dist/resolution/diagnostics.d.ts +41 -0
  84. package/dist/resolution/diagnostics.d.ts.map +1 -0
  85. package/dist/resolution/diagnostics.js +18 -0
  86. package/dist/resolution/diagnostics.js.map +1 -0
  87. package/dist/{environment.d.ts → resolution/environment.d.ts} +24 -7
  88. package/dist/resolution/environment.d.ts.map +1 -0
  89. package/dist/resolution/environment.js +126 -0
  90. package/dist/resolution/environment.js.map +1 -0
  91. package/dist/resolution/instantiation-plan.d.ts +67 -0
  92. package/dist/resolution/instantiation-plan.d.ts.map +1 -0
  93. package/dist/resolution/instantiation-plan.js +183 -0
  94. package/dist/resolution/instantiation-plan.js.map +1 -0
  95. package/dist/{lifecycle.d.ts → resolution/lifecycle.d.ts} +5 -3
  96. package/dist/resolution/lifecycle.d.ts.map +1 -0
  97. package/dist/{lifecycle.js → resolution/lifecycle.js} +23 -14
  98. package/dist/resolution/lifecycle.js.map +1 -0
  99. package/dist/resolution/resolution-path.d.ts +22 -0
  100. package/dist/resolution/resolution-path.d.ts.map +1 -0
  101. package/dist/resolution/resolution-path.js +40 -0
  102. package/dist/resolution/resolution-path.js.map +1 -0
  103. package/dist/resolution/resolve-options.d.ts.map +1 -0
  104. package/dist/resolution/resolve-options.js.map +1 -0
  105. package/dist/resolution/resolver.d.ts +40 -0
  106. package/dist/resolution/resolver.d.ts.map +1 -0
  107. package/dist/resolution/resolver.js +1108 -0
  108. package/dist/resolution/resolver.js.map +1 -0
  109. package/dist/{scope.d.ts → resolution/scope.d.ts} +8 -9
  110. package/dist/resolution/scope.d.ts.map +1 -0
  111. package/dist/resolution/scope.js +80 -0
  112. package/dist/resolution/scope.js.map +1 -0
  113. package/dist/token.d.ts.map +1 -1
  114. package/dist/token.js +0 -3
  115. package/dist/token.js.map +1 -1
  116. package/package.json +19 -94
  117. package/src/binding.ts +137 -22
  118. package/src/constructor-type.ts +4 -5
  119. package/src/container/binding-builders.ts +294 -0
  120. package/src/container/container.ts +825 -0
  121. package/src/decorators/inject.ts +15 -4
  122. package/src/decorators/injectable.ts +3 -3
  123. package/src/errors.ts +21 -0
  124. package/src/index.ts +15 -7
  125. package/src/{dependency-graph.ts → introspection/dependency-graph.ts} +1 -1
  126. package/src/{graph-adapters → introspection/graph-adapters}/cytoscape.ts +1 -1
  127. package/src/{graph-adapters → introspection/graph-adapters}/dot.ts +1 -1
  128. package/src/{graph-adapters → introspection/graph-adapters}/reactflow.ts +13 -2
  129. package/src/{inspector.ts → introspection/inspector.ts} +26 -21
  130. package/src/metadata/metadata-keys.ts +3 -6
  131. package/src/metadata/symbol-metadata-reader.ts +4 -4
  132. package/src/module.ts +14 -6
  133. package/src/registry.ts +97 -64
  134. package/src/resolution/activation-need.ts +81 -0
  135. package/src/resolution/binding-lookup-cache.ts +132 -0
  136. package/src/{binding-select.ts → resolution/binding-select.ts} +17 -7
  137. package/src/resolution/class-introspector.ts +74 -0
  138. package/src/resolution/diagnostics.ts +43 -0
  139. package/src/{environment.ts → resolution/environment.ts} +65 -35
  140. package/src/resolution/instantiation-plan.ts +292 -0
  141. package/src/{lifecycle.ts → resolution/lifecycle.ts} +26 -14
  142. package/src/resolution/resolution-path.ts +62 -0
  143. package/src/resolution/resolver.ts +1526 -0
  144. package/src/resolution/scope.ts +95 -0
  145. package/src/token.ts +0 -3
  146. package/dist/binding-scope.d.ts.map +0 -1
  147. package/dist/binding-scope.js.map +0 -1
  148. package/dist/binding-select.d.ts.map +0 -1
  149. package/dist/binding-select.js.map +0 -1
  150. package/dist/constraints.d.ts.map +0 -1
  151. package/dist/constraints.js.map +0 -1
  152. package/dist/container.d.ts.map +0 -1
  153. package/dist/container.js +0 -853
  154. package/dist/container.js.map +0 -1
  155. package/dist/dependency-graph.d.ts.map +0 -1
  156. package/dist/dependency-graph.js.map +0 -1
  157. package/dist/environment.d.ts.map +0 -1
  158. package/dist/environment.js +0 -100
  159. package/dist/environment.js.map +0 -1
  160. package/dist/graph-adapters/cytoscape.d.ts.map +0 -1
  161. package/dist/graph-adapters/cytoscape.js.map +0 -1
  162. package/dist/graph-adapters/dot.d.ts +0 -6
  163. package/dist/graph-adapters/dot.d.ts.map +0 -1
  164. package/dist/graph-adapters/dot.js.map +0 -1
  165. package/dist/graph-adapters/reactflow.d.ts.map +0 -1
  166. package/dist/graph-adapters/reactflow.js.map +0 -1
  167. package/dist/inspector.d.ts.map +0 -1
  168. package/dist/inspector.js.map +0 -1
  169. package/dist/lifecycle.d.ts.map +0 -1
  170. package/dist/lifecycle.js.map +0 -1
  171. package/dist/resolve-options.d.ts.map +0 -1
  172. package/dist/resolve-options.js.map +0 -1
  173. package/dist/resolver.d.ts +0 -90
  174. package/dist/resolver.d.ts.map +0 -1
  175. package/dist/resolver.js +0 -1208
  176. package/dist/resolver.js.map +0 -1
  177. package/dist/scope.d.ts.map +0 -1
  178. package/dist/scope.js +0 -61
  179. package/dist/scope.js.map +0 -1
  180. package/src/container.ts +0 -1141
  181. package/src/resolver.ts +0 -1626
  182. package/src/scope.ts +0 -77
  183. /package/dist/{dependency-graph.d.ts → introspection/dependency-graph.d.ts} +0 -0
  184. /package/dist/{graph-adapters → introspection/graph-adapters}/cytoscape.js +0 -0
  185. /package/dist/{graph-adapters → introspection/graph-adapters}/dot.js +0 -0
  186. /package/dist/{binding-scope.d.ts → resolution/binding-scope.d.ts} +0 -0
  187. /package/dist/{binding-scope.js → resolution/binding-scope.js} +0 -0
  188. /package/dist/{binding-select.d.ts → resolution/binding-select.d.ts} +0 -0
  189. /package/dist/{constraints.d.ts → resolution/constraints.d.ts} +0 -0
  190. /package/dist/{constraints.js → resolution/constraints.js} +0 -0
  191. /package/dist/{resolve-options.d.ts → resolution/resolve-options.d.ts} +0 -0
  192. /package/dist/{resolve-options.js → resolution/resolve-options.js} +0 -0
  193. /package/src/{binding-scope.ts → resolution/binding-scope.ts} +0 -0
  194. /package/src/{constraints.ts → resolution/constraints.ts} +0 -0
  195. /package/src/{resolve-options.ts → resolution/resolve-options.ts} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,128 @@
1
1
  # @codefast/di
2
2
 
3
+ ## 0.5.0-canary.8
4
+
5
+ ### Minor Changes
6
+
7
+ - [#646](https://github.com/codefastlabs/codefast/pull/646) [`0093b99`](https://github.com/codefastlabs/codefast/commit/0093b99ed711ad037b0e98e7343dee89786d328b) Thanks [@thevuong](https://github.com/thevuong)! - Build a container's rarely-used collaborators on first use instead of in its constructor: the inspector, the module ref/binding tables, the scope's in-flight and scoped caches, the registry's named and tagged slot indexes, and the class introspector's metadata caches. A container that only binds and resolves — the common case, and every per-request child container — no longer allocates eleven `Map`s it never reads.
8
+
9
+ A fresh `Container.create()` retains 2.7 KB instead of 4.8 KB (**43% lighter**), and `parent.createChild()` the same, measured by retention against a forced collection. Every deferred collaborator behaves identically whether or not something touched it first, which `tests/unit/container/deferred-subsystems.test.ts` pins by exercising each one as the first thing a fresh container does.
10
+
11
+ It is a throughput win too, on the paths that actually build containers: `Container.create()` is **1.80×** faster (230 ns → 127 ns) and a per-request child container plus a resolve through it — `createChild()` + resolve, the shape a web app runs once per request — is **1.31×** faster. Measured by an interleaved A/B with both builds loaded into one process, 13 trials in alternating order, against a control scenario that resolves from a pre-built container and so cannot benefit; the control sat at 0.997–1.009, and median and best-of agreed on both figures.
12
+
13
+ **Breaking:** `ScopeManager.getAllScoped()` is removed from the `./resolution/scope` subpath. Deferring the scoped cache raised the question of what a bulk reader returns when the cache was never allocated, and this reader had no callers anywhere in the package — so it is gone rather than carrying an empty-map fallback for nobody. `getAllSingletons()` is unaffected; its cache is still eager.
14
+
15
+ What it does **not** do is close the `realistic-graph-cold-resolve` loss against tsyringe, and the arithmetic says why: 103 ns off container construction is 2.5% of that row's 4.06 µs iteration, so the row moves ~1.5% — measured, and inside the noise floor. That row's gap is GC-attributable (the two libraries are at mutator parity; di only loses once a forced collection is in the loop), so a 13.7% allocation cut was never going to carry it.
16
+
17
+ - [#646](https://github.com/codefastlabs/codefast/pull/646) [`de80bad`](https://github.com/codefastlabs/codefast/commit/de80bad63f14afda1bd64a6d247852b24aac8e16) Thanks [@thevuong](https://github.com/thevuong)! - Publish an intentional export surface: 13 subpaths instead of 36. The engine's collaborators — `resolution/*`, `registry`, `container/*`, `binding`, `constructor-type`, and the `metadata` internals — are no longer entry points. They carry the invariants documented in ARCHITECTURE.md, and publishing them meant every internal refactor was technically a breaking change. Everything a consumer needs stays reachable from the root export, which already re-exports the builder interfaces, `Constructor`, `MetadataReader`, `effectiveBindingScope`, and the resolve-options helpers.
18
+
19
+ **This also repairs a silent break.** The surface was generated from `dist/`, so reorganising `src/` into `container/`, `resolution/` and `introspection/` renamed twelve already-published entry points — `./inspector` → `./introspection/inspector`, `./dependency-graph` → `./introspection/dependency-graph`, `./graph-adapters/*` → `./introspection/graph-adapters/*`, `./container` → `./container/container`, and the whole flat `./resolver`/`./scope`/`./lifecycle`/`./environment`/`./constraints`/`./binding-select`/`./binding-scope`/`./resolve-options` set — with no changeset saying so. The consumer-facing ones (`./inspector`, `./dependency-graph`, `./graph-adapters/*`) are back at the specifiers they shipped under; `examples/tanstack-start` imports two of them and would have broken on its next upgrade.
20
+
21
+ **Breaking:** the internal subpaths listed above are gone. Import from the package root instead.
22
+
23
+ - [#646](https://github.com/codefastlabs/codefast/pull/646) [`4ba70d1`](https://github.com/codefastlabs/codefast/commit/4ba70d1724e19580ee93ee392e413c23e669f310) Thanks [@thevuong](https://github.com/thevuong)! - Keep a singleton's instance on its binding instead of in a per-container table. A binding belongs to exactly one container, so its singleton slot is per-binding — which turns every cached-singleton read from a keyed `Map` lookup into a field read, on the most common resolve shape there is. The scope manager keeps only a lazily-created list of the bindings that have materialized, so disposal and `inspect()` can still enumerate them, and the singleton `Map` is gone entirely.
24
+
25
+ In the suite, `realistic-graph-resolve-root` — a transient controller over eight cached singletons — went from 10.66M to **12.19M** hz/op, and the `realistic` group geomean from 2.24× to **2.54×** of InversifyJS. That row carries a 2.9% IQR, so it is one of the numbers here worth reading precisely. `singleton-class-1-dep` and cold container build both moved up as well, on rows whose IQR is too wide to attribute confidently.
26
+
27
+ An interleaved A/B against the previous build, both in one process with a control that cannot benefit, put the same row between 1.09× and 1.40× across four runs — never slower, median and best-of agreeing inside each run, but with a spread that depends on what else the process had run. The suite's figure is the one to cite; the A/B established the direction. A trap worth recording: the control first read 0.88×, which was an artifact of timing an 11 ns call one at a time — batched the way the harness does it, the same control reads 1.02× with a 4% spread.
28
+
29
+ **Breaking:** `ScopeManager`'s singleton API takes a `Binding` rather than a `BindingIdentifier`, and `hasSingleton`/`getSingleton`/`peekSingleton`/`setSingleton(id, …)`/`getAllSingletons` are replaced by `setSingleton(binding, …)`, `deleteSingleton(binding)` and `cachedSingletons()`. The `SINGLETON_MISS` sentinel is gone; `NO_INSTANCE` on the binding replaces it. None of this is a published entry point any more, so it is internal — but a fork reaching into `./resolution/scope` would notice. `InstantiationPlanDependencyEntry` also drops its `ownerScope` field, which a compiled thunk no longer needs.
30
+
31
+ ### Patch Changes
32
+
33
+ - [#646](https://github.com/codefastlabs/codefast/pull/646) [`d27b76f`](https://github.com/codefastlabs/codefast/commit/d27b76fb14200ae5226ec2a05b77d44ab91b016c) Thanks [@thevuong](https://github.com/thevuong)! - Thread an async chain's resolution context through the call and pool it, instead of parking chain identity on the resolver. `ctx.resolveAsync()` now hands the callee the context it used, so an inner level reuses it when the owner matches — which removes the resolver's path-identity heuristic, its shared settle callback and its active-level counter, and makes two concurrent chains correct by construction rather than by a fallback branch.
34
+
35
+ The contexts are pooled, and that is load-bearing rather than an allocation micro-optimization: a per-chain context survives its chain's microtask hops, so under a collecting profile a freshly allocated one is promoted out of the nursery and then collected the expensive way. An ablation that allocated per chain cost **2.5×** on `dynamic-async-chain-8` under a forced GC every 100 samples, which is the reason for the shape.
36
+
37
+ It does **not** close that row. An earlier draft of this changeset claimed it went from 0.98× to 1.18× of InversifyJS; that figure came from a probe running both library builds in one process, which this harness's README warns is worth ~30% on async chains, and from a 3-trial suite run on a loaded machine. At 5 trials on a quiet machine the row is **0.87×** with a 0.6% / 0.3% IQR — among the tightest numbers in the suite. The mechanism above is real; the win over inversify was not.
38
+
39
+ A competing hypothesis was tested and rejected: a forced full GC costs the two libraries the same (1.35 ms / 9.76 MB live for di, 1.41 ms / 9.89 MB for inversify), so the cost was never the collection but what di re-established afterwards.
40
+
41
+ - [#646](https://github.com/codefastlabs/codefast/pull/646) [`864d213`](https://github.com/codefastlabs/codefast/commit/864d213a4253346dae5799ebba06fc2726e933d2) Thanks [@thevuong](https://github.com/thevuong)! - Fold the fluent chain's registry committer into the chain itself. `bind()` now allocates a `BindingEntry` that carries only the `to*()` calls, and `to*()` a `BindingChain` that commits to the registry directly — one object per bind less than the entry/chain/committer trio, and one `Map` lookup less per binding registered by a module.
42
+
43
+ The two classes now share a `BindingRegistration` describing where the chain registers, built once per container rather than once per `bind()`. Threading that instead of a loose `(registry, moduleBindingIds, moduleRef)` triple makes the module invariant type-enforced — the id list is present exactly when the chain belongs to a module load — which removes both non-null assertions from the commit path, and drops the constructors from 4 and 5 positional parameters to 2 and 3.
44
+
45
+ `BindingCommitter` is gone and `BindingEntry`'s constructor now takes `(token, registration)`. Neither is a published entry point any more, so this is internal.
46
+
47
+ This is a simplification, **not** a throughput win: removing only the committer measured no change above noise. The chain stays two objects because `tests/unit/container/bind-to-builder-order.test.ts` requires `bind()`'s result to lack `when*()` at runtime — that is the test's own guarantee, stricter than SPEC §2.4, which only claims compiler enforcement. The measured ceiling for removing every builder object is ~19% on `realistic-graph-cold-resolve` under a forced GC — recorded in ARCHITECTURE so the lead is not re-tried blind.
48
+
49
+ - [#646](https://github.com/codefastlabs/codefast/pull/646) [`d27b76f`](https://github.com/codefastlabs/codefast/commit/d27b76fb14200ae5226ec2a05b77d44ab91b016c) Thanks [@thevuong](https://github.com/thevuong)! - Compile instantiation plans around dependencies the compiler cannot see through, instead of refusing to compile the graph at all. A factory, a scoped binding, an activation hook, a class past the depth limit, or a multi/optional/named parameter now compiles to an _escape_ — a re-entry into the runtime resolver seeded with exactly the ancestors the interpreted path would have pushed at that point, dispatched through exactly the resolve the interpreter would have called. Cycle detection, constraint contexts and error paths are therefore identical to never having compiled, and only the opaque dependency pays the runtime price while its siblings and ancestors stay compiled.
50
+
51
+ Previously a single `toDynamic` dependency anywhere in a class graph dropped the whole graph to the interpreted path — a 13.9× cliff on a shape applications write constantly (a factory-provided config injected into a class tree). That graph is now ~2× faster, and the first-materialization path of a singleton dependency inside a plan gained cycle detection it did not have.
52
+
53
+ - [#646](https://github.com/codefastlabs/codefast/pull/646) [`d27b76f`](https://github.com/codefastlabs/codefast/commit/d27b76fb14200ae5226ec2a05b77d44ab91b016c) Thanks [@thevuong](https://github.com/thevuong)! - Split the resolver's self-contained caches into named collaborators — `BindingLookupCache` (the chain-versioned options-less lookup memo), `ClassIntrospector` (per-class metadata, `@postConstruct` discovery, accessor injection, instantiation) and `ActivationNeedCache` (per-binding activation need, versioned on the lifecycle manager). The engine class keeps the sync and async pipelines, which genuinely need the same private state on every hop, and `ARCHITECTURE.md` now records the layering, the invariants each hot path depends on, and the rule that separates a legitimate threshold (choosing an implementation) from the kind that was removed (choosing a semantics).
54
+
55
+ New subpaths `@codefast/di/resolution/{activation-need,binding-lookup-cache,class-introspector}`; `@codefast/di/resolution/class-plan` is now `@codefast/di/resolution/instantiation-plan`, correcting an export map that had been stale since the module was renamed.
56
+
57
+ - [#646](https://github.com/codefastlabs/codefast/pull/646) [`a720c62`](https://github.com/codefastlabs/codefast/commit/a720c6297d041ffd2d0bba2e6146af894007a367) Thanks [@thevuong](https://github.com/thevuong)! - Collapse the fluent binding chain into one object. A single `BindingChain` is now the `BindToBuilder` that `bind()` returns and the kind-specific builder that `to*()` returns, so a `bind()` allocates one builder instead of two.
58
+
59
+ The `to*()`-before-`when*()` ordering stays enforced, as a type-level guarantee — which is what SPEC §2.4 actually claims. `bind()` is typed `BindToBuilder`, so a refinement before `to*()` does not compile; `tests/types/container-api.test.ts` pins that. For a caller without types, or one who casts past them, every refinement now throws the new **`ChainNotRegisteredError`** naming the token and pointing at `to*()`, rather than silently doing nothing. `whenDefault()` asserts registration for that reason alone, since it otherwise has nothing to do.
60
+
61
+ The previous revision kept two objects because a unit test asserted the refinement methods were _absent from the object_ `bind()` returns — a stricter reading than the spec, and one that pinned an implementation detail. That test now asserts the contract instead: every refinement throws before `to*()`, nothing is registered when it does, and the chain still works normally afterwards.
62
+
63
+ This is an API simplification, **not** a throughput win: going from four builder objects per bind to three measured no change above noise, and a fluent API cannot go below one, so the ~19% ceiling recorded in ARCHITECTURE for removing all of them is unreachable rather than pending.
64
+
65
+ - [#646](https://github.com/codefastlabs/codefast/pull/646) [`1241f82`](https://github.com/codefastlabs/codefast/commit/1241f82bdb40613667c781111f2ce20409ddfd89) Thanks [@thevuong](https://github.com/thevuong)! - Register a fluent binding chain once instead of once per refinement. `bind(T).toDynamic(f).singleton()` used to insert a binding, remove it, and insert a replacement — two registry mutations, two version bumps, and a full index churn per binding. The chain now registers on its `to*()` call and refines that same registered object in place; only `when*()` re-slots, and it re-registers under the chain's original id, so `id()` stays valid for the whole chain instead of the intermediate ids being dead. Binding construction also funnels through a single `createBinding()` literal, which is what guarantees the one V8 hidden class the resolver's hot property reads depend on — so the registry stores what it is handed rather than re-copying it.
66
+
67
+ Cold container build (build, bind 10 nodes, resolve the root) went from the suite's only loss to a win against every competitor: 0.76× → 3.0× of InversifyJS, 0.43× → 1.9× of Awilix, 0.22× → 1.07× of tsyringe.
68
+
69
+ The builder's `CommitFn` type is replaced by a `BindingCommitter` interface (`commit` plus `refine`, the latter for in-place refinements the registry indexes do not care about), and `createBinding` / `refinableFields` are new exports from `@codefast/di/binding`.
70
+
71
+ ## 0.5.0-canary.7
72
+
73
+ ### Minor Changes
74
+
75
+ - [`ad11507`](https://github.com/codefastlabs/codefast/commit/ad115077e23eaed845abd1f093f32d57f2445a36) Thanks [@thevuong](https://github.com/thevuong)! - Reorganize the source tree into subsystem folders — `container/` (container + the extracted fluent binding builders), `resolution/` (resolver, scope, lifecycle, environment, selection/constraints, and the extracted cycle-guard module), and `introspection/` (inspector, dependency graph, and the graph adapters). The root entry keeps exporting everything and now also exports the graph adapters (`toDotGraph`, `toCytoscapeGraph`, `toReactFlowGraph` and their types), so `import { toReactFlowGraph } from "@codefast/di"` is the preferred path.
76
+
77
+ Breaking (0.x minor): the `@codefast/di/graph-adapters/*` subpaths are removed — import the adapters from the root entry or from `@codefast/di/introspection/graph-adapters/*`. Deep subpaths of other moved modules follow the new folders (e.g. `@codefast/di/resolver` → `@codefast/di/resolution/resolver`).
78
+
79
+ - [`6a25788`](https://github.com/codefastlabs/codefast/commit/6a25788320c73074c3ae0bb06cf7a70b7800c953) Thanks [@thevuong](https://github.com/thevuong)! - Resolver performance overhaul — the head-to-head benchmark vs InversifyJS 8 now shows 38/38 comparable scenarios won (median 1.82×, isolated mode), up from 7 losing rows. Four techniques, no public-API changes:
80
+
81
+ - **Chain-versioned lookup memo** — `BindingRegistry` gains a monotonic mutation version; resolvers memoize options-less `token → {binding, owner}` lookups across the parent chain with alias hops folded to the terminal binding. Resolving a root binding from a depth-2 child (or through `toAlias`) is now as fast as resolving it locally.
82
+ - **Compiled resolution plans** — a transient class binding whose dependency subgraph is pure static (class/constant/cached-singleton deps, no activation hooks or `postConstruct`) compiles once into a nested-constructor closure, cycle-checked at compile time. Anything dynamic keeps the runtime cycle guard, so error semantics are unchanged.
83
+ - **Uniform binding hidden class** — `Registry.add` rebuilds every binding with one fixed field superset so mixed binding kinds no longer turn the resolver's hot property reads megamorphic (~30% throughput loss in processes exercising several kinds).
84
+ - **Leaner async transient path** — cleanup runs as a FIFO side listener on the factory promise instead of a derived-promise chain (one less promise and one less microtask hop per level), and activated transient dynamic bindings get a dedicated lane that fetches container hooks once. Behavior note: an unawaited _failing_ `resolveAsync` no longer surfaces as an `unhandledRejection`; await (or `.catch`) the returned promise.
85
+
86
+ - [#643](https://github.com/codefastlabs/codefast/pull/643) [`14c3a98`](https://github.com/codefastlabs/codefast/commit/14c3a98a98ae6221df447a94afe14b2e4a147c90) Thanks [@thevuong](https://github.com/thevuong)! - `container.validate()` now reports a captive dependency when a singleton depends on a **transient or scoped `toDynamic` / `toDynamicAsync` binding**. Previously any dynamic terminal was classified opaque and its declared scope went unchecked, so the most common form of the bug — a singleton capturing one instance of something bound transient — passed validation silently.
87
+
88
+ A factory's _body_ remains opaque: `validate()` still does not descend into it, so whatever the factory resolves internally is not reported. Only the declared scope of the dependency edge is judged, which is the part the container actually knows.
89
+
90
+ **Breaking:** a container that wires a singleton to a transient or scoped dynamic binding now throws `ScopeViolationError` from `validate()` where it previously passed. Either widen the dependency's scope, or inject a factory instead of the value if a fresh instance per use is intended.
91
+
92
+ ### Patch Changes
93
+
94
+ - [`2def688`](https://github.com/codefastlabs/codefast/commit/2def688e305eebe7e14af4ae163beec13582aad5) Thanks [@thevuong](https://github.com/thevuong)! - Fix a crash on cyclic aliases: `bind(a).toAlias(b)` + `bind(b).toAlias(a)` previously recursed until `RangeError: Maximum call stack size exceeded` on both `resolve` and `resolveAsync`. Alias following is now an iterative loop with exact revisit detection — a genuine cycle throws `CircularDependencyError` naming the alias chain, and legitimately long alias chains resolve with no arbitrary hop cap.
95
+
96
+ Also splits the magic `32` that served two unrelated roles: the transient-dynamic fast lanes keep their own `DEEP_LANE_THRESHOLD = 32` (a shared-context/pool design point), while the cycle-scan Set attachment moves to a measured `RESOLUTION_SET_THRESHOLD = 128` — benchmarking showed `Array.includes` beats the Set's has/add/delete churn up to at least depth 96, so mid-depth graphs now skip the Set entirely.
97
+
98
+ - [`19199af`](https://github.com/codefastlabs/codefast/commit/19199af174d8971081d1849a36fd9df05c8541ae) Thanks [@thevuong](https://github.com/thevuong)! - Fix binding-registration order sensitivity: the fluent builder chain commits eagerly, so `bind(x).toDynamic(f).when(p)` (or `.whenNamed(...)` / `.whenTagged(...)`) momentarily registered a default-slot binding whose last-wins commit silently displaced an existing default binding of the same token — and the displaced binding was never restored once the chain narrowed to a predicate or a named/tagged slot. Registering a default binding before a constrained one on the same token therefore lost the default. The commit chain now remembers what an intermediate commit displaced and restores it when the chain settles on a non-conflicting shape; a chain that genuinely ends on the same default slot still replaces the previous default (last-wins unchanged).
99
+
100
+ Binding selection also gains a most-specific-wins rule: when both a default binding and exactly one predicate-carrying binding match, the predicate wins (it is a deliberate specialization) instead of throwing `AmbiguousBindingError` — so "default plus `when(...)` override" now works as naturally intended. Two matching predicates remain ambiguous and still throw.
101
+
102
+ - [#643](https://github.com/codefastlabs/codefast/pull/643) [`14c3a98`](https://github.com/codefastlabs/codefast/commit/14c3a98a98ae6221df447a94afe14b2e4a147c90) Thanks [@thevuong](https://github.com/thevuong)! - Unify sync transient-dynamic cycle detection on a per-binding `inFlight` flag, replacing the shallow lane's `O(depth)` `resolutionPath.includes()` scan and the deep lane's `Map` of generation marks. Sync resolution runs on a single call stack, so a binding marked on factory-enter and cleared on factory-exit is exactly path membership — detection becomes an `O(1)` field read with no hashing, no string scan, and no side table to allocate or grow. The async lane keeps its own per-path check, since async chains can interleave.
103
+
104
+ Transient-dynamic chains that previously lost now win across the whole depth range (a 32-deep chain went from ~0.55× to ~1.8× of InversifyJS), deep chains widen their lead, and cold container builds get cheaper because there is no per-resolver cycle-tracking structure to allocate. It also fixes a latent correctness bug: because the deep lane now clears a binding's mark when its factory returns, a deep (past-threshold) transient dependency resolved twice via separate sub-branches (a diamond, not a cycle) no longer throws a false `CircularDependencyError`.
105
+
106
+ - [`f9aeeb0`](https://github.com/codefastlabs/codefast/commit/f9aeeb04a271877e47a7fbbfc6d62ae0fe1ad955) Thanks [@thevuong](https://github.com/thevuong)! - Extend the compiled-plan and memoization coverage: `toResolved(...)` transient bindings with pure-static explicit deps now compile into factory-call plans (same refusal rules and sync-only check as class plans), and name-only resolves gain a chain-versioned memo that fast-paths constants and cached singletons — predicates, aliases, and anything context-dependent keep the full selection path. Measured: `named-constant-get` ~21M → ~30M hz/op, `to-resolved-3-deps` ~39M → ~52M hz/op.
107
+
108
+ - [#643](https://github.com/codefastlabs/codefast/pull/643) [`14c3a98`](https://github.com/codefastlabs/codefast/commit/14c3a98a98ae6221df447a94afe14b2e4a147c90) Thanks [@thevuong](https://github.com/thevuong)! - Collapse the async transient-dynamic resolver into a single lane and retune the cycle-set threshold.
109
+
110
+ The async lane used to split at depth 32 into a fast path (linear path scan, shared context, no stack frames) and a slow path (forced Set, fresh context per level, stack frames, extra microtask hop) — so context identity, `ctx.graph` contents, and promise shape all changed silently at that depth. Both are now one lane whose cycle guard goes through `enterResolutionPath`, the only mechanism that stays correct when chains interleave (`Promise.all`) and which adapts on its own: a linear scan while the path is short, an attached Set past `RESOLUTION_SET_THRESHOLD`. `DEEP_LANE_THRESHOLD` is gone from the package entirely.
111
+
112
+ `RESOLUTION_SET_THRESHOLD` drops from 128 to 32 on fresh measurements — at 128 an async chain costs 1275 / 3641 / 9645 / 26082 ns at depth 16 / 32 / 64 / 128 versus 1202 / 3285 / 7735 / 16837 at 32, so the old value was the worse choice at every depth measured.
113
+
114
+ - [#643](https://github.com/codefastlabs/codefast/pull/643) [`14c3a98`](https://github.com/codefastlabs/codefast/commit/14c3a98a98ae6221df447a94afe14b2e4a147c90) Thanks [@thevuong](https://github.com/thevuong)! - Collapse the sync transient-dynamic resolver into a single lane and memoize each binding's resolution frame on the binding itself.
115
+
116
+ The separate deep lane existed to escape an `O(depth)` `resolutionPath.includes()` cycle scan past ~32 levels. With cycle detection now an `O(1)` `binding.inFlight` mark there is nothing to escape, so the depth split, its shared-context bookkeeping, its reentrancy fallback, and the per-resolver frame `Map` are all gone — the smaller function also inlines better. Frames derive only from immutable binding fields, so caching one per binding replaces a `Map` lookup per hop and a `Map` insert per binding per container.
117
+
118
+ Faster at every chain depth measured (8 → 512), e.g. a 32-deep transient chain improved ~39% and cold container build ~62%, which turns the cold-build result against Awilix from a loss into a win in the default benchmark profile.
119
+
120
+ - [#643](https://github.com/codefastlabs/codefast/pull/643) [`14c3a98`](https://github.com/codefastlabs/codefast/commit/14c3a98a98ae6221df447a94afe14b2e4a147c90) Thanks [@thevuong](https://github.com/thevuong)! - `toResolved()` and `toResolvedAsync()` now accept injection descriptors — `inject()`, `optional()` and `injectAll()` — in their dependency list, matching what `@injectable([...])` already allowed and what the builder already did at runtime (it normalizes every entry through `normalizeToDescriptor`). Previously the public signature only admitted bare tokens and constructors, so an optional or multi dependency needed a cast even though resolution handled it correctly.
121
+
122
+ Factory arguments are typed from the descriptor: a bare token gives `Value`, `optional(token)` gives `Value | undefined`, and `injectAll(token)` gives `Array<Value>`. Widening only — existing bare-token call sites are unaffected.
123
+
124
+ - [#643](https://github.com/codefastlabs/codefast/pull/643) [`14c3a98`](https://github.com/codefastlabs/codefast/commit/14c3a98a98ae6221df447a94afe14b2e4a147c90) Thanks [@thevuong](https://github.com/thevuong)! - `unbind(token)` now drops the token's bindings in a single registry pass instead of removing them one id at a time. The previous path re-scanned and re-indexed the token's binding list once per binding — quadratic in the number of slots bound to that token — and bumped the registry version once per removal, invalidating resolver lookup caches repeatedly. Behaviour is unchanged, including deactivation of cached singletons.
125
+
3
126
  ## 0.5.0-canary.6
4
127
 
5
128
  ### Minor Changes
package/README.md CHANGED
@@ -12,7 +12,7 @@ Lightweight, type-safe dependency injection for modern TypeScript — built on T
12
12
  - **Modules.** Bundle bindings into reusable units; load, unload, and compose them across containers.
13
13
  - **Async-aware.** Async factories, deduped async singleton construction, and `await using` disposal.
14
14
 
15
- > Currently published as `1.0.0-canary.x` pre-releases on the way to a stable 1.0.
15
+ > Currently published as `0.x` canary pre-releases on the way to a stable 1.0 — breaking changes on 0.x ship as minor versions.
16
16
 
17
17
  ## Requirements
18
18
 
@@ -128,7 +128,7 @@ container.resolve(LoggerToken, { name: "file" });
128
128
  container.resolve(StorageToken, { tag: ["provider", "s3"] });
129
129
  ```
130
130
 
131
- For graph-aware selection, pass a predicate to `.when(...)` — helpers like `whenParentIs`, `whenAnyAncestorNamed`, and `whenParentTagged` ship in `@codefast/di/constraints`.
131
+ For graph-aware selection, pass a predicate to `.when(...)` — helpers like `whenParentIs`, `whenAnyAncestorNamed`, and `whenParentTagged` ship from the root entry (`import { whenParentIs } from "@codefast/di"`).
132
132
 
133
133
  ## Decorators
134
134
 
@@ -236,11 +236,22 @@ Every error extends `DiError` and carries a stable `code` — `TokenNotBoundErro
236
236
 
237
237
  ## Subpath exports
238
238
 
239
- The root entry re-exports the full public API. Every internal area is also published as a tree-shakeable subpath — `@codefast/di/container`, `@codefast/di/token`, `@codefast/di/module`, `@codefast/di/constraints`, `@codefast/di/errors`, and graph adapters under `@codefast/di/graph-adapters/*` (DOT, Cytoscape, React Flow) for visualizing `container.generateDependencyGraph()` output.
239
+ The root entry re-exports the full public API — prefer it (`import { Container, token, toReactFlowGraph } from "@codefast/di"`). Every module is also published as a tree-shakeable subpath mirroring the source layout:
240
+
241
+ - **Model** at the top level — `@codefast/di/token`, `/types`, `/binding`, `/registry`, `/errors`, `/module`
242
+ - **Runtime** under `/container/*` and `/resolution/*` — e.g. `@codefast/di/resolution/constraints`
243
+ - **Introspection** under `/introspection/*` — the inspector, `dependency-graph`, and the graph adapters (`@codefast/di/introspection/graph-adapters/{dot,cytoscape,reactflow}`) for visualizing `container.generateDependencyGraph()` output
244
+ - **Decorators & metadata** under `/decorators/*` and `/metadata/*`
240
245
 
241
246
  ## Benchmarks
242
247
 
243
- A head-to-head benchmark suite against InversifyJS 8 lives in the monorepo: [benchmarks/di-inversify](https://github.com/codefastlabs/codefast/tree/main/benchmarks/di-inversify). Each library runs in its canonical decorator mode, in isolated subprocesses, reported as per-trial medians with interquartile range — designed so the results are re-runnable rather than taken on faith. On the production-shaped scenarios measured there, `@codefast/di` resolves faster than InversifyJS; run `pnpm bench` in that package to reproduce the numbers on your machine.
248
+ A head-to-head benchmark suite lives in the monorepo: [benchmarks/di-inversify](https://github.com/codefastlabs/codefast/tree/main/benchmarks/di-inversify). It compares `@codefast/di` against **InversifyJS 8** on the full scenario set, plus **Awilix** and **tsyringe** on a shared core subset. Each library runs in its canonical mode, in isolated subprocesses, reported as per-trial medians with interquartile range — designed so the results are re-runnable rather than taken on faith.
249
+
250
+ Against InversifyJS — the only one of the three that covers a comparable feature surface — `@codefast/di` currently wins **all 43 comparable scenarios** in both profiles, at a median of 1.86×–2.21× and a geometric mean of 2.38×–2.76×. Against the two deliberately leaner containers it wins the shared core subset as well, with one exception: cold container build against tsyringe under the forced-GC profile. See [RESULTS.md](https://github.com/codefastlabs/codefast/blob/main/benchmarks/di-inversify/RESULTS.md) for the full tables, the caveats, and the losses that earlier revisions reported — or run `pnpm bench` in that package to reproduce them on your machine.
251
+
252
+ ## Contributing
253
+
254
+ Changing this package's source? [CONTRIBUTING.md](https://github.com/codefastlabs/codefast/blob/main/packages/di/CONTRIBUTING.md) is the full workflow — build, exports mirror, tests, the mandatory perf-guard for resolver changes, and the release gate.
244
255
 
245
256
  ## License
246
257
 
package/dist/binding.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import type { InjectionDescriptor } from "#/decorators/inject";
1
+ import type { InjectableDependency, InjectionDescriptor, ResolvedDependencyValue } from "#/decorators/inject";
2
2
  import type { Token } from "#/token";
3
- import type { ActivationHandler, BindingIdentifier, BindingScope, BindingTag, Constructor, DeactivationHandler, DependencyKey, ResolutionContext, TokenValue, ConstraintContext } from "#/types";
3
+ import type { ActivationHandler, BindingIdentifier, BindingScope, BindingTag, Constructor, DeactivationHandler, ResolutionContext, ResolutionFrame, ConstraintContext } from "#/types";
4
4
  /**
5
5
  * @since 0.3.16-canary.0
6
6
  */
@@ -12,6 +12,12 @@ export interface BindingSlot {
12
12
  * @since 0.3.16-canary.0
13
13
  */
14
14
  export declare function bindingSlotEquals(left: BindingSlot, right: BindingSlot): boolean;
15
+ /**
16
+ * Cached singleton absent — distinguishes "not resolved yet" from a cached `undefined`.
17
+ *
18
+ * @since 0.5.0-canary.8
19
+ */
20
+ export declare const NO_INSTANCE: unique symbol;
15
21
  /**
16
22
  * @since 0.3.16-canary.0
17
23
  */
@@ -25,9 +31,31 @@ export declare const DEFAULT_BINDING_SLOT: {
25
31
  export declare function bindingSlotToString(slot: BindingSlot): string;
26
32
  interface BindingBase<Value> {
27
33
  readonly id: BindingIdentifier;
34
+ /**
35
+ * True while this binding's factory is on the sync resolution stack — the sync lane's cycle check.
36
+ *
37
+ * @remarks Resolver-owned bookkeeping; callers never set it. See `ARCHITECTURE.md` for why the
38
+ * sync and async lanes detect cycles differently.
39
+ */
40
+ inFlight?: boolean | undefined;
41
+ /**
42
+ * Memoized resolution frame for this binding. Its contents derive only from immutable binding
43
+ * fields, so it is computed once on first resolve and reused instead of a per-resolver Map
44
+ * lookup on every hop.
45
+ *
46
+ * @remarks Resolver-owned bookkeeping — `registry.add` normalizes it, so callers never set it.
47
+ */
48
+ frame?: ResolutionFrame | undefined;
49
+ /**
50
+ * Cached singleton instance, or {@link NO_INSTANCE}.
51
+ *
52
+ * @remarks A binding belongs to exactly one container, so its singleton slot is per-binding —
53
+ * a field read replaces a keyed lookup on the hottest resolve shape there is.
54
+ */
55
+ instance?: unknown;
28
56
  readonly token: Token<Value> | Constructor<Value>;
29
57
  readonly slot: BindingSlot;
30
- readonly predicate?: (ctx: ConstraintContext) => boolean;
58
+ readonly predicate?: ((ctx: ConstraintContext) => boolean) | undefined;
31
59
  }
32
60
  type BindingBaseKeys = keyof BindingBase<unknown>;
33
61
  /**
@@ -37,8 +65,8 @@ export interface ClassBinding<Value> extends BindingBase<Value> {
37
65
  readonly kind: "class";
38
66
  readonly target: Constructor<Value>;
39
67
  readonly scope: BindingScope;
40
- readonly onActivation?: ActivationHandler<Value>;
41
- readonly onDeactivation?: DeactivationHandler<Value>;
68
+ readonly onActivation?: ActivationHandler<Value> | undefined;
69
+ readonly onDeactivation?: DeactivationHandler<Value> | undefined;
42
70
  }
43
71
  /**
44
72
  * @since 0.3.16-canary.0
@@ -47,8 +75,8 @@ export interface DynamicBinding<Value> extends BindingBase<Value> {
47
75
  readonly kind: "dynamic";
48
76
  readonly factory: (ctx: ResolutionContext) => Value;
49
77
  readonly scope: BindingScope;
50
- readonly onActivation?: ActivationHandler<Value>;
51
- readonly onDeactivation?: DeactivationHandler<Value>;
78
+ readonly onActivation?: ActivationHandler<Value> | undefined;
79
+ readonly onDeactivation?: DeactivationHandler<Value> | undefined;
52
80
  }
53
81
  /**
54
82
  * @since 0.3.16-canary.0
@@ -57,8 +85,8 @@ export interface DynamicAsyncBinding<Value> extends BindingBase<Value> {
57
85
  readonly kind: "dynamic-async";
58
86
  readonly factory: (ctx: ResolutionContext) => Promise<Value>;
59
87
  readonly scope: BindingScope;
60
- readonly onActivation?: ActivationHandler<Value>;
61
- readonly onDeactivation?: DeactivationHandler<Value>;
88
+ readonly onActivation?: ActivationHandler<Value> | undefined;
89
+ readonly onDeactivation?: DeactivationHandler<Value> | undefined;
62
90
  }
63
91
  /**
64
92
  * @since 0.3.16-canary.0
@@ -68,8 +96,8 @@ export interface ResolvedBinding<Value> extends BindingBase<Value> {
68
96
  readonly factory: (...args: Array<unknown>) => Value;
69
97
  readonly deps: ReadonlyArray<InjectionDescriptor>;
70
98
  readonly scope: BindingScope;
71
- readonly onActivation?: ActivationHandler<Value>;
72
- readonly onDeactivation?: DeactivationHandler<Value>;
99
+ readonly onActivation?: ActivationHandler<Value> | undefined;
100
+ readonly onDeactivation?: DeactivationHandler<Value> | undefined;
73
101
  }
74
102
  /**
75
103
  * @since 0.3.16-canary.0
@@ -79,8 +107,8 @@ export interface ResolvedAsyncBinding<Value> extends BindingBase<Value> {
79
107
  readonly factory: (...args: Array<unknown>) => Promise<Value>;
80
108
  readonly deps: ReadonlyArray<InjectionDescriptor>;
81
109
  readonly scope: BindingScope;
82
- readonly onActivation?: ActivationHandler<Value>;
83
- readonly onDeactivation?: DeactivationHandler<Value>;
110
+ readonly onActivation?: ActivationHandler<Value> | undefined;
111
+ readonly onDeactivation?: DeactivationHandler<Value> | undefined;
84
112
  }
85
113
  /**
86
114
  * @since 0.3.16-canary.0
@@ -89,8 +117,8 @@ export interface ConstantBinding<Value> extends BindingBase<Value> {
89
117
  readonly kind: "constant";
90
118
  readonly value: Value;
91
119
  readonly scope: "singleton";
92
- readonly onActivation?: ActivationHandler<Value>;
93
- readonly onDeactivation?: DeactivationHandler<Value>;
120
+ readonly onActivation?: ActivationHandler<Value> | undefined;
121
+ readonly onDeactivation?: DeactivationHandler<Value> | undefined;
94
122
  }
95
123
  /**
96
124
  * @since 0.3.16-canary.0
@@ -113,6 +141,37 @@ export type PartialBinding<Value> = Omit<ClassBinding<Value>, BindingBaseKeys> |
113
141
  * @since 0.3.16-canary.0
114
142
  */
115
143
  export declare function generateBindingId(): BindingIdentifier;
144
+ /**
145
+ * The single construction site for bindings — one literal, one V8 hidden class.
146
+ *
147
+ * @see `ARCHITECTURE.md` — why the field order and the single site are load-bearing.
148
+ *
149
+ * @param source - the kind-specific payload, or an existing binding to re-slot
150
+ * @param id - reuse a caller's id to keep a fluent chain's `id()` stable across refinements
151
+ *
152
+ * @since 0.5.0-canary.8
153
+ */
154
+ export declare function createBinding<Value>(source: PartialBinding<Value> | Binding<Value>, token: Token<Value> | Constructor<Value>, slot: BindingSlot, predicate: ((ctx: ConstraintContext) => boolean) | undefined, id?: BindingIdentifier): Binding<Value>;
155
+ /**
156
+ * Writable view of the only fields a fluent chain may refine after registration.
157
+ *
158
+ * @remarks No registry index is keyed on these, so a builder that owns the registered object
159
+ * can write them directly instead of re-registering. `token`, `slot`, `predicate` and `id`
160
+ * are excluded on purpose — changing those means re-indexing.
161
+ *
162
+ * @since 0.5.0-canary.8
163
+ */
164
+ export interface RefinableBindingFields<Value> {
165
+ onActivation: ActivationHandler<Value> | undefined;
166
+ onDeactivation: DeactivationHandler<Value> | undefined;
167
+ scope: BindingScope;
168
+ }
169
+ /**
170
+ * Narrows a registered binding to the fields a fluent chain may still refine.
171
+ *
172
+ * @since 0.5.0-canary.8
173
+ */
174
+ export declare function refinableFields<Value>(binding: Binding<Value>): RefinableBindingFields<Value>;
116
175
  /**
117
176
  * Common slot-constraint + id methods shared by all concrete binding builders.
118
177
  *
@@ -134,11 +193,11 @@ export interface BindToBuilder<Value> {
134
193
  toConstantValue(value: Value): ConstantBindingBuilder<Value>;
135
194
  toDynamic(factory: (ctx: ResolutionContext) => Value): BindingBuilder<Value>;
136
195
  toDynamicAsync(factory: (ctx: ResolutionContext) => Promise<Value>): BindingBuilder<Value>;
137
- toResolved<const Deps extends ReadonlyArray<DependencyKey>>(factory: (...args: {
138
- [K in keyof Deps]: TokenValue<NoInfer<Deps>[K]>;
196
+ toResolved<const Deps extends ReadonlyArray<InjectableDependency>>(factory: (...args: {
197
+ [K in keyof Deps]: ResolvedDependencyValue<NoInfer<Deps>[K]>;
139
198
  }) => Value, deps: Deps): BindingBuilder<Value>;
140
- toResolvedAsync<const Deps extends ReadonlyArray<DependencyKey>>(factory: (...args: {
141
- [K in keyof Deps]: TokenValue<NoInfer<Deps>[K]>;
199
+ toResolvedAsync<const Deps extends ReadonlyArray<InjectableDependency>>(factory: (...args: {
200
+ [K in keyof Deps]: ResolvedDependencyValue<NoInfer<Deps>[K]>;
142
201
  }) => Promise<Value>, deps: Deps): BindingBuilder<Value>;
143
202
  toAlias(target: Token<Value> | Constructor<Value>): AliasBindingBuilder;
144
203
  }
@@ -1 +1 @@
1
- {"version":3,"file":"binding.d.ts","sourceRoot":"","sources":["../src/binding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,KAAK,EACV,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15,12 @@ export function bindingSlotEquals(left, right) {
15
15
  }
16
16
  return true;
17
17
  }
18
+ /**
19
+ * Cached singleton absent — distinguishes "not resolved yet" from a cached `undefined`.
20
+ *
21
+ * @since 0.5.0-canary.8
22
+ */
23
+ export const NO_INSTANCE = Symbol("di:no-instance");
18
24
  /**
19
25
  * @since 0.3.16-canary.0
20
26
  */
@@ -36,11 +42,49 @@ export function bindingSlotToString(slot) {
36
42
  return parts.join(",");
37
43
  }
38
44
  // ── ID generation ─────────────────────────────────────────────────────────────
39
- let _idCounter = 0;
45
+ let bindingIdCounter = 0;
40
46
  /**
41
47
  * @since 0.3.16-canary.0
42
48
  */
43
49
  export function generateBindingId() {
44
- return String(++_idCounter);
50
+ return String(++bindingIdCounter);
51
+ }
52
+ /**
53
+ * The single construction site for bindings — one literal, one V8 hidden class.
54
+ *
55
+ * @see `ARCHITECTURE.md` — why the field order and the single site are load-bearing.
56
+ *
57
+ * @param source - the kind-specific payload, or an existing binding to re-slot
58
+ * @param id - reuse a caller's id to keep a fluent chain's `id()` stable across refinements
59
+ *
60
+ * @since 0.5.0-canary.8
61
+ */
62
+ export function createBinding(source, token, slot, predicate, id = generateBindingId()) {
63
+ const fields = source;
64
+ return {
65
+ kind: fields.kind,
66
+ id,
67
+ inFlight: false,
68
+ frame: undefined,
69
+ instance: source.instance ?? NO_INSTANCE,
70
+ token,
71
+ slot,
72
+ predicate,
73
+ scope: fields.scope,
74
+ target: fields.target,
75
+ factory: fields.factory,
76
+ deps: fields.deps,
77
+ value: fields.value,
78
+ onActivation: fields.onActivation,
79
+ onDeactivation: fields.onDeactivation,
80
+ };
81
+ }
82
+ /**
83
+ * Narrows a registered binding to the fields a fluent chain may still refine.
84
+ *
85
+ * @since 0.5.0-canary.8
86
+ */
87
+ export function refinableFields(binding) {
88
+ return binding;
45
89
  }
46
90
  //# sourceMappingURL=binding.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"binding.js","sourceRoot":"","sources":["../src/binding.ts"],"names":[],"m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,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,YAAY,EAAE,MAAM,CAAC,YAAY;QACjC,cAAc,EAAE,MAAM,CAAC,cAAc;KACe,CAAC;AACzD,CAAC;AAiBD;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAQ,OAAuB;IAC5D,OAAO,OAAwC,CAAC;AAClD,CAAC"}
@@ -1,9 +1,8 @@
1
1
  /**
2
- * A class (newable) that produces `Value`. Rest parameters are `never[]` so
3
- * real classes with typed constructors remain assignable under
4
- * `strictFunctionTypes` (unlike `unknown[]`, which is not assignable from
5
- * narrower parameter types). Runtime construction still uses the real shape;
6
- * this alias is the DI “class token” surface only.
2
+ * A class token: newable, producing `Value`.
3
+ *
4
+ * @remarks Rest parameters are `never[]` so classes with typed constructors stay assignable under
5
+ * `strictFunctionTypes`. Construction uses the real shape; this alias is the token surface only.
7
6
  *
8
7
  * @since 0.3.16-canary.0
9
8
  */
@@ -1 +1 @@
1
- {"version":3,"file":"constructor-type.d.ts","sourceRoot":"","sources":["../src/constructor-type.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,MAAM,WAAW,CAAC,KAAK,GAAG,OAAO,IAAI,KAAK,GAAG,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC;AAEhF;;;;;;GAMG;AACH,MAAM,MAAM,qBAAqB,GAAG,KAAK,GAAG,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,OAAO,CAAC"}
1
+ {"version":3,"file":"constructor-type.d.ts","sourceRoot":"","sources":["../src/constructor-type.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,CAAC,KAAK,GAAG,OAAO,IAAI,KAAK,GAAG,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC;AAEhF;;;;;;GAMG;AACH,MAAM,MAAM,qBAAqB,GAAG,KAAK,GAAG,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,OAAO,CAAC"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * The fluent chain `bind()` returns: it registers the binding and refines it in place.
3
+ *
4
+ * @see `ARCHITECTURE.md` — why one object plays every role, and what pins the ordering.
5
+ */
6
+ import type { AliasBindingBuilder, BindingBuilder, BindToBuilder, ConstantBindingBuilder, ScopedBindingBuilder, SingletonBindingBuilder, SingletonLifecycleBuilder, TransientBindingBuilder } from "#/binding";
7
+ import type { InjectableDependency, ResolvedDependencyValue } from "#/decorators/inject";
8
+ import type { BindingRegistry } from "#/registry";
9
+ import type { Token } from "#/token";
10
+ import type { ActivationHandler, BindingIdentifier, ConstraintContext, Constructor, DeactivationHandler, ResolutionContext } from "#/types";
11
+ /**
12
+ * Where a chain registers, and on whose behalf.
13
+ *
14
+ * @remarks Built once per container and shared by every chain it creates. `moduleBindingIds` is
15
+ * present exactly when the chain belongs to a module load.
16
+ *
17
+ * @since 0.5.0-canary.8
18
+ */
19
+ export interface BindingRegistration {
20
+ readonly registry: BindingRegistry;
21
+ readonly moduleBindingIds: Array<BindingIdentifier> | undefined;
22
+ }
23
+ /**
24
+ * The one builder behind `bind()` and every `to*()` return type. Each interface exposes only the
25
+ * calls that are legal at that point in the chain; the runtime object is shared because every
26
+ * refinement is the same operation — narrow the registered binding, keep its id.
27
+ *
28
+ * @since 0.5.0-canary.8
29
+ */
30
+ export declare class BindingChain<Value> implements AliasBindingBuilder, BindingBuilder<Value>, BindToBuilder<Value>, ConstantBindingBuilder<Value>, ScopedBindingBuilder<Value>, SingletonBindingBuilder<Value>, SingletonLifecycleBuilder<Value>, TransientBindingBuilder<Value> {
31
+ #private;
32
+ constructor(token: Token<Value> | Constructor<Value>, registration: BindingRegistration);
33
+ to(type: Constructor<Value>): BindingBuilder<Value>;
34
+ toSelf(): BindingBuilder<Value>;
35
+ toConstantValue(value: Value): ConstantBindingBuilder<Value>;
36
+ toDynamic(factory: (ctx: ResolutionContext) => Value): BindingBuilder<Value>;
37
+ toDynamicAsync(factory: (ctx: ResolutionContext) => Promise<Value>): BindingBuilder<Value>;
38
+ toResolved<const Deps extends ReadonlyArray<InjectableDependency>>(factory: (...args: {
39
+ [K in keyof Deps]: ResolvedDependencyValue<NoInfer<Deps>[K]>;
40
+ }) => Value, deps: Deps): BindingBuilder<Value>;
41
+ toResolvedAsync<const Deps extends ReadonlyArray<InjectableDependency>>(factory: (...args: {
42
+ [K in keyof Deps]: ResolvedDependencyValue<NoInfer<Deps>[K]>;
43
+ }) => Promise<Value>, deps: Deps): BindingBuilder<Value>;
44
+ toAlias(target: Token<Value> | Constructor<Value>): AliasBindingBuilder;
45
+ when(predicate: (ctx: ConstraintContext) => boolean): this;
46
+ whenNamed(name: string): this;
47
+ whenTagged(tag: string, value: unknown): this;
48
+ whenDefault(): this;
49
+ singleton(): SingletonBindingBuilder<Value>;
50
+ transient(): TransientBindingBuilder<Value>;
51
+ scoped(): ScopedBindingBuilder<Value>;
52
+ onActivation(fn: ActivationHandler<Value>): this;
53
+ onDeactivation(fn: DeactivationHandler<Value>): this;
54
+ id(): BindingIdentifier;
55
+ }
56
+ //# sourceMappingURL=binding-builders.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"binding-builders.d.ts","sourceRoot":"","sources":["../../src/container/binding-builders.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EACV,mBAAmB,EAEnB,cAAc,EAEd,aAAa,EACb,sBAAsB,EAEtB,oBAAoB,EACpB,uBAAuB,EACvB,yBAAyB,EACzB,uBAAuB,EACxB,MAAM,WAAW,CAAC;AAEnB,OAAO,KAAK,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAGzF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC,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