@codefast/di 0.3.16-canary.1 → 0.3.16-canary.3

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 (73) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +4 -4
  3. package/dist/binding-select.d.mts +1 -1
  4. package/dist/binding-select.mjs +5 -5
  5. package/dist/binding.d.mts +28 -28
  6. package/dist/binding.mjs +8 -8
  7. package/dist/constraints.d.mts +3 -3
  8. package/dist/constraints.mjs +2 -2
  9. package/dist/container.mjs +146 -214
  10. package/dist/decorators/inject.d.mts +4 -3
  11. package/dist/decorators/inject.mjs +21 -48
  12. package/dist/decorators/injectable.mjs +4 -12
  13. package/dist/decorators/lifecycle-decorators.mjs +11 -72
  14. package/dist/dependency-graph.mjs +17 -15
  15. package/dist/environment.d.mts +15 -15
  16. package/dist/environment.mjs +21 -21
  17. package/dist/graph-adapters/cytoscape.d.mts +12 -12
  18. package/dist/graph-adapters/cytoscape.mjs +7 -7
  19. package/dist/graph-adapters/reactflow.d.mts +15 -15
  20. package/dist/graph-adapters/reactflow.mjs +6 -9
  21. package/dist/index.d.mts +4 -4
  22. package/dist/index.mjs +2 -2
  23. package/dist/inspector.d.mts +3 -2
  24. package/dist/inspector.mjs +19 -22
  25. package/dist/lifecycle.mjs +2 -12
  26. package/dist/metadata/metadata-keys.d.mts +8 -33
  27. package/dist/metadata/metadata-keys.mjs +8 -21
  28. package/dist/metadata/metadata-types.d.mts +5 -0
  29. package/dist/metadata/symbol-metadata-reader.d.mts +1 -0
  30. package/dist/metadata/symbol-metadata-reader.mjs +11 -33
  31. package/dist/module.d.mts +1 -1
  32. package/dist/module.mjs +2 -2
  33. package/dist/registry.d.mts +4 -4
  34. package/dist/registry.mjs +26 -45
  35. package/dist/resolve-options.d.mts +7 -7
  36. package/dist/resolve-options.mjs +14 -12
  37. package/dist/resolver.d.mts +15 -10
  38. package/dist/resolver.mjs +167 -173
  39. package/dist/token.d.mts +1 -1
  40. package/dist/token.mjs +4 -4
  41. package/dist/types.d.mts +14 -8
  42. package/package.json +40 -13
  43. package/src/binding-scope.ts +26 -0
  44. package/src/binding-select.ts +167 -0
  45. package/src/binding.ts +281 -0
  46. package/src/constraints.ts +149 -0
  47. package/src/constructor-type.ts +19 -0
  48. package/src/container.ts +1213 -0
  49. package/src/decorators/inject.ts +233 -0
  50. package/src/decorators/injectable.ts +85 -0
  51. package/src/decorators/lifecycle-decorators.ts +55 -0
  52. package/src/dependency-graph.ts +116 -0
  53. package/src/environment.ts +232 -0
  54. package/src/errors.ts +262 -0
  55. package/src/graph-adapters/cytoscape.ts +64 -0
  56. package/src/graph-adapters/dot.ts +22 -0
  57. package/src/graph-adapters/reactflow.ts +58 -0
  58. package/src/index.ts +101 -0
  59. package/src/inspector.ts +133 -0
  60. package/src/lifecycle.ts +238 -0
  61. package/src/metadata/metadata-keys.ts +25 -0
  62. package/src/metadata/metadata-reader-token.ts +8 -0
  63. package/src/metadata/metadata-types.ts +53 -0
  64. package/src/metadata/symbol-metadata-reader.ts +57 -0
  65. package/src/module.ts +93 -0
  66. package/src/registry.ts +241 -0
  67. package/src/resolve-options.ts +42 -0
  68. package/src/resolver.ts +1837 -0
  69. package/src/scope.ts +77 -0
  70. package/src/token.ts +40 -0
  71. package/src/types.ts +145 -0
  72. package/dist/graph-adapters/types.d.mts +0 -2
  73. package/dist/graph-adapters/types.mjs +0 -1
@@ -1,11 +1,11 @@
1
1
  import { effectiveBindingScope } from "./binding-scope.mjs";
2
2
  import { AsyncModuleLoadError, CircularDependencyError, DisposedContainerError, InternalError, RebindUnboundTokenError, ScopeViolationError, SyncDisposalNotSupportedError } from "./errors.mjs";
3
- import { DEFAULT_SLOT, generateBindingId } from "./binding.mjs";
3
+ import { DEFAULT_BINDING_SLOT, generateBindingId } from "./binding.mjs";
4
4
  import { tokenName } from "./token.mjs";
5
5
  import { BindingRegistry } from "./registry.mjs";
6
6
  import { ScopeManager } from "./scope.mjs";
7
7
  import { LifecycleManager } from "./lifecycle.mjs";
8
- import { injectableSlotToResolveOptions, slotKeyToResolveOptions } from "./resolve-options.mjs";
8
+ import { bindingSlotToResolveOptions, injectionSlotToResolveOptions } from "./resolve-options.mjs";
9
9
  import { DependencyResolver } from "./resolver.mjs";
10
10
  import { Inspector } from "./inspector.mjs";
11
11
  import { buildDependencyGraph } from "./dependency-graph.mjs";
@@ -53,7 +53,7 @@ var DefaultContainer = class DefaultContainer {
53
53
  }
54
54
  _createBindToBuilder(token, moduleRef) {
55
55
  const registry = this._registry;
56
- const commitBinding = (b, previousId) => {
56
+ const commitBinding = (binding, previousId) => {
57
57
  if (previousId !== void 0) {
58
58
  registry.removeById(previousId);
59
59
  if (moduleRef !== void 0) {
@@ -64,63 +64,62 @@ var DefaultContainer = class DefaultContainer {
64
64
  }
65
65
  }
66
66
  }
67
- registry.add(b);
67
+ registry.add(binding);
68
68
  if (moduleRef !== void 0) {
69
69
  let ids = this._moduleBindingIds.get(moduleRef);
70
70
  if (ids === void 0) {
71
71
  ids = [];
72
72
  this._moduleBindingIds.set(moduleRef, ids);
73
73
  }
74
- ids.push(b.id);
74
+ ids.push(binding.id);
75
75
  }
76
- return b.id;
76
+ return binding.id;
77
77
  };
78
- return new BindToBuilderImpl(token, commitBinding);
78
+ return new BindingEntry(token, commitBinding);
79
79
  }
80
80
  unbind(tokenOrId) {
81
81
  this._assertNotDisposed();
82
82
  this._unbindSync(tokenOrId);
83
83
  }
84
- _unbindSync(tokenOrId) {
85
- const bindings = this._getBindingsForTokenOrId(tokenOrId);
86
- for (const binding of bindings) {
84
+ /** Remove bindings from registry + scope and collect [binding, instance] pairs for deactivation. */
85
+ _collectDeactivationPairs(tokenOrId) {
86
+ const pairs = [];
87
+ for (const binding of this._getBindingsForTokenOrId(tokenOrId)) {
87
88
  this._registry.removeById(binding.id);
88
89
  if (this._scope.hasSingleton(binding.id)) {
89
- const instance = this._scope.getSingleton(binding.id);
90
+ pairs.push([binding, this._scope.getSingleton(binding.id)]);
90
91
  this._scope.deleteSingleton(binding.id);
91
- this._lifecycle.runDeactivationSync(binding, instance, this._getMetadataReader());
92
92
  }
93
93
  }
94
+ return pairs;
95
+ }
96
+ /** Drain singleton scope entries for a set of already-removed bindings. */
97
+ _drainSingletons(bindings) {
98
+ const pairs = [];
99
+ for (const binding of bindings) if (this._scope.hasSingleton(binding.id)) {
100
+ pairs.push([binding, this._scope.getSingleton(binding.id)]);
101
+ this._scope.deleteSingleton(binding.id);
102
+ }
103
+ return pairs;
104
+ }
105
+ _unbindSync(tokenOrId) {
106
+ const reader = this._getMetadataReader();
107
+ for (const [binding, instance] of this._collectDeactivationPairs(tokenOrId)) this._lifecycle.runDeactivationSync(binding, instance, reader);
94
108
  }
95
109
  async unbindAsync(tokenOrId) {
96
110
  this._assertNotDisposed();
97
- const bindings = this._getBindingsForTokenOrId(tokenOrId);
98
- for (const binding of bindings) {
99
- this._registry.removeById(binding.id);
100
- if (this._scope.hasSingleton(binding.id)) {
101
- const instance = this._scope.getSingleton(binding.id);
102
- this._scope.deleteSingleton(binding.id);
103
- await this._lifecycle.runDeactivation(binding, instance, this._getMetadataReader());
104
- }
105
- }
111
+ const reader = this._getMetadataReader();
112
+ for (const [binding, instance] of this._collectDeactivationPairs(tokenOrId)) await this._lifecycle.runDeactivation(binding, instance, reader);
106
113
  }
107
114
  unbindAll() {
108
115
  this._assertNotDisposed();
109
- const all = this._registry.clear();
110
- for (const binding of all) if (this._scope.hasSingleton(binding.id)) {
111
- const instance = this._scope.getSingleton(binding.id);
112
- this._scope.deleteSingleton(binding.id);
113
- this._lifecycle.runDeactivationSync(binding, instance, this._getMetadataReader());
114
- }
116
+ const reader = this._getMetadataReader();
117
+ for (const [binding, instance] of this._drainSingletons(this._registry.clear())) this._lifecycle.runDeactivationSync(binding, instance, reader);
115
118
  }
116
119
  async unbindAllAsync() {
117
120
  this._assertNotDisposed();
118
- const all = this._registry.clear();
119
- for (const binding of all) if (this._scope.hasSingleton(binding.id)) {
120
- const instance = this._scope.getSingleton(binding.id);
121
- this._scope.deleteSingleton(binding.id);
122
- await this._lifecycle.runDeactivation(binding, instance, this._getMetadataReader());
123
- }
121
+ const reader = this._getMetadataReader();
122
+ for (const [binding, instance] of this._drainSingletons(this._registry.clear())) await this._lifecycle.runDeactivation(binding, instance, reader);
124
123
  }
125
124
  rebind(token) {
126
125
  this._assertNotDisposed();
@@ -130,8 +129,8 @@ var DefaultContainer = class DefaultContainer {
130
129
  }
131
130
  _getBindingsForTokenOrId(tokenOrId) {
132
131
  if (typeof tokenOrId === "string") {
133
- const b = this._registry.getById(tokenOrId);
134
- return b !== void 0 ? [b] : [];
132
+ const binding = this._registry.getById(tokenOrId);
133
+ return binding !== void 0 ? [binding] : [];
135
134
  }
136
135
  return [...this._registry.getAll(tokenOrId)];
137
136
  }
@@ -141,123 +140,117 @@ var DefaultContainer = class DefaultContainer {
141
140
  }
142
141
  _loadSyncModules(modules) {
143
142
  const toLoad = this._collectModuleDeps(modules);
144
- for (const mod of toLoad) {
145
- if (!isSyncModule(mod)) throw new AsyncModuleLoadError(mod.name);
146
- const ref = mod;
147
- const existing = this._moduleRefs.get(ref);
143
+ for (const module of toLoad) {
144
+ if (!isSyncModule(module)) throw new AsyncModuleLoadError(module.name);
145
+ const moduleRef = module;
146
+ const existing = this._moduleRefs.get(moduleRef);
148
147
  if (existing !== void 0) {
149
- this._moduleRefs.set(ref, existing + 1);
148
+ this._moduleRefs.set(moduleRef, existing + 1);
150
149
  continue;
151
150
  }
152
- this._moduleRefs.set(ref, 1);
153
- const builder = this._createModuleBuilder(ref);
154
- mod._setup(builder);
151
+ this._moduleRefs.set(moduleRef, 1);
152
+ const builder = this._createModuleBuilder(moduleRef);
153
+ module._setup(builder);
155
154
  }
156
155
  }
157
156
  _collectModuleDeps(modules) {
158
157
  const seen = /* @__PURE__ */ new Set();
159
158
  const result = [];
160
- const visit = (mod) => {
161
- const ref = mod;
162
- if (seen.has(ref)) return;
163
- seen.add(ref);
164
- result.push(mod);
159
+ const visit = (module) => {
160
+ const moduleRef = module;
161
+ if (seen.has(moduleRef)) return;
162
+ seen.add(moduleRef);
163
+ result.push(module);
165
164
  };
166
- for (const m of modules) visit(m);
165
+ for (const module of modules) visit(module);
167
166
  return result;
168
167
  }
169
168
  async loadAsync(...modules) {
170
169
  this._assertNotDisposed();
171
- for (const mod of modules) await this._loadOneModuleAsync(mod);
170
+ for (const module of modules) await this._loadOneModuleAsync(module);
172
171
  }
173
- async _loadOneModuleAsync(mod) {
174
- const ref = mod;
175
- const existing = this._moduleRefs.get(ref);
172
+ async _loadOneModuleAsync(module) {
173
+ const moduleRef = module;
174
+ const existing = this._moduleRefs.get(moduleRef);
176
175
  if (existing !== void 0) {
177
- this._moduleRefs.set(ref, existing + 1);
176
+ this._moduleRefs.set(moduleRef, existing + 1);
178
177
  return;
179
178
  }
180
- this._moduleRefs.set(ref, 1);
181
- if (isSyncModule(mod)) {
182
- const builder = this._createModuleBuilder(ref);
183
- mod._setup(builder);
179
+ this._moduleRefs.set(moduleRef, 1);
180
+ if (isSyncModule(module)) {
181
+ const builder = this._createModuleBuilder(moduleRef);
182
+ module._setup(builder);
184
183
  } else {
185
184
  const importPromises = [];
186
- const builder = this._createAsyncModuleBuilder(ref, importPromises);
187
- await mod._setup(builder);
185
+ const builder = this._createAsyncModuleBuilder(moduleRef, importPromises);
186
+ await module._setup(builder);
188
187
  if (importPromises.length > 0) await Promise.all(importPromises);
189
188
  }
190
189
  }
191
190
  _createModuleBuilder(moduleRef) {
192
191
  return {
193
- bind: (t) => this._createBindToBuilder(t, moduleRef),
194
- import: (...mods) => {
195
- this._loadSyncModules(mods);
192
+ bind: (token) => this._createBindToBuilder(token, moduleRef),
193
+ import: (...modules) => {
194
+ this._loadSyncModules(modules);
196
195
  }
197
196
  };
198
197
  }
199
198
  _createAsyncModuleBuilder(moduleRef, importPromises) {
200
199
  return {
201
- bind: (t) => this._createBindToBuilder(t, moduleRef),
202
- import: (...mods) => {
203
- for (const mod of mods) importPromises.push(this._loadOneModuleAsync(mod));
200
+ bind: (token) => this._createBindToBuilder(token, moduleRef),
201
+ import: (...modules) => {
202
+ for (const module of modules) importPromises.push(this._loadOneModuleAsync(module));
204
203
  }
205
204
  };
206
205
  }
207
206
  unload(...modules) {
208
207
  this._assertNotDisposed();
209
- for (const mod of modules) this._unloadModuleSync(mod);
208
+ for (const module of modules) this._unloadModuleSync(module);
209
+ }
210
+ /** Unregister module bindings and collect [binding, instance] pairs for deactivation. */
211
+ _removeModuleBindings(ref) {
212
+ this._moduleRefs.delete(ref);
213
+ const ids = this._moduleBindingIds.get(ref) ?? [];
214
+ this._moduleBindingIds.delete(ref);
215
+ const pairs = [];
216
+ for (const id of ids) {
217
+ const binding = this._registry.getById(id);
218
+ if (binding !== void 0) {
219
+ this._registry.removeById(id);
220
+ if (this._scope.hasSingleton(id)) {
221
+ pairs.push([binding, this._scope.getSingleton(id)]);
222
+ this._scope.deleteSingleton(id);
223
+ }
224
+ }
225
+ }
226
+ return pairs;
210
227
  }
211
228
  _unloadModuleSync(ref) {
212
229
  const count = this._moduleRefs.get(ref) ?? 0;
213
230
  if (count <= 1) {
214
- this._moduleRefs.delete(ref);
215
- const ids = this._moduleBindingIds.get(ref) ?? [];
216
- this._moduleBindingIds.delete(ref);
217
- for (const id of ids) {
218
- const binding = this._registry.getById(id);
219
- if (binding !== void 0) {
220
- this._registry.removeById(id);
221
- if (this._scope.hasSingleton(id)) {
222
- const instance = this._scope.getSingleton(id);
223
- this._scope.deleteSingleton(id);
224
- this._lifecycle.runDeactivationSync(binding, instance, this._getMetadataReader());
225
- }
226
- }
227
- }
231
+ const reader = this._getMetadataReader();
232
+ for (const [binding, instance] of this._removeModuleBindings(ref)) this._lifecycle.runDeactivationSync(binding, instance, reader);
228
233
  } else this._moduleRefs.set(ref, count - 1);
229
234
  }
230
235
  async unloadAsync(...modules) {
231
236
  this._assertNotDisposed();
232
- for (const mod of modules) await this._unloadModuleAsync(mod);
237
+ for (const module of modules) await this._unloadModuleAsync(module);
233
238
  }
234
239
  async _unloadModuleAsync(ref) {
235
240
  const count = this._moduleRefs.get(ref) ?? 0;
236
241
  if (count <= 1) {
237
- this._moduleRefs.delete(ref);
238
- const ids = this._moduleBindingIds.get(ref) ?? [];
239
- this._moduleBindingIds.delete(ref);
240
- for (const id of ids) {
241
- const binding = this._registry.getById(id);
242
- if (binding !== void 0) {
243
- this._registry.removeById(id);
244
- if (this._scope.hasSingleton(id)) {
245
- const instance = this._scope.getSingleton(id);
246
- this._scope.deleteSingleton(id);
247
- await this._lifecycle.runDeactivation(binding, instance, this._getMetadataReader());
248
- }
249
- }
250
- }
242
+ const reader = this._getMetadataReader();
243
+ for (const [binding, instance] of this._removeModuleBindings(ref)) await this._lifecycle.runDeactivation(binding, instance, reader);
251
244
  } else this._moduleRefs.set(ref, count - 1);
252
245
  }
253
246
  loadAutoRegistered(registry) {
254
247
  this._assertNotDisposed();
255
248
  const entries = registry.entries();
256
249
  for (const { target, scope } of entries) {
257
- const bb = this._createBindToBuilder(target).toSelf();
258
- if (scope === "singleton") bb.singleton();
259
- else if (scope === "scoped") bb.scoped();
260
- else bb.transient();
250
+ const bindingBuilder = this._createBindToBuilder(target).toSelf();
251
+ if (scope === "singleton") bindingBuilder.singleton();
252
+ else if (scope === "scoped") bindingBuilder.scoped();
253
+ else bindingBuilder.transient();
261
254
  }
262
255
  return entries.length;
263
256
  }
@@ -323,7 +316,7 @@ var DefaultContainer = class DefaultContainer {
323
316
  if (effectiveBindingScope(binding) === "singleton" && !this._scope.hasSingleton(binding.id)) {
324
317
  if (binding.predicate !== void 0) continue;
325
318
  if (binding.kind === "constant" && binding.onActivation === void 0) continue;
326
- const slotHint = slotKeyToResolveOptions(binding.slot);
319
+ const slotHint = bindingSlotToResolveOptions(binding.slot);
327
320
  await this.resolveAsync(binding.token, slotHint);
328
321
  }
329
322
  }
@@ -407,7 +400,7 @@ var DefaultContainer = class DefaultContainer {
407
400
  const meta = reader.getConstructorMetadata(binding.target);
408
401
  if (meta === void 0) return edges;
409
402
  for (const param of meta.params) {
410
- const paramHint = injectableSlotToResolveOptions(param);
403
+ const paramHint = injectionSlotToResolveOptions(param);
411
404
  if (param.optional) continue;
412
405
  const tokenRef = param.token;
413
406
  if (param.multi) {
@@ -426,7 +419,7 @@ var DefaultContainer = class DefaultContainer {
426
419
  return edges;
427
420
  }
428
421
  if (binding.kind === "resolved" || binding.kind === "resolved-async") for (const dep of binding.deps) {
429
- const depHint = injectableSlotToResolveOptions(dep);
422
+ const depHint = injectionSlotToResolveOptions(dep);
430
423
  if (dep.optional) continue;
431
424
  const tokenRef = dep.token;
432
425
  if (dep.multi) {
@@ -478,7 +471,36 @@ function updateSlotTag(slot, tag, value) {
478
471
  tags: existing
479
472
  };
480
473
  }
481
- var BindToBuilderImpl = class {
474
+ var SlotBuilder = class {
475
+ _slot = DEFAULT_BINDING_SLOT;
476
+ _predicate;
477
+ _committed;
478
+ when(predicate) {
479
+ this._predicate = predicate;
480
+ this._doCommit();
481
+ return this;
482
+ }
483
+ whenNamed(name) {
484
+ this._slot = {
485
+ ...this._slot,
486
+ name
487
+ };
488
+ this._doCommit();
489
+ return this;
490
+ }
491
+ whenTagged(tag, value) {
492
+ this._slot = updateSlotTag(this._slot, tag, value);
493
+ this._doCommit();
494
+ return this;
495
+ }
496
+ whenDefault() {
497
+ return this;
498
+ }
499
+ id() {
500
+ return this._committed;
501
+ }
502
+ };
503
+ var BindingEntry = class {
482
504
  _token;
483
505
  _commit;
484
506
  constructor(_token, _commit) {
@@ -486,7 +508,7 @@ var BindToBuilderImpl = class {
486
508
  this._commit = _commit;
487
509
  }
488
510
  to(type) {
489
- return new BindingBuilderImpl(this._token, {
511
+ return new ConstraintBuilder(this._token, {
490
512
  kind: "class",
491
513
  target: type,
492
514
  scope: "transient"
@@ -494,32 +516,32 @@ var BindToBuilderImpl = class {
494
516
  }
495
517
  toSelf() {
496
518
  if (typeof this._token !== "function") throw new Error("toSelf() requires token to be a Constructor");
497
- return new BindingBuilderImpl(this._token, {
519
+ return new ConstraintBuilder(this._token, {
498
520
  kind: "class",
499
521
  target: this._token,
500
522
  scope: "transient"
501
523
  }, this._commit);
502
524
  }
503
525
  toConstantValue(value) {
504
- return new ConstantBindingBuilderImpl(this._token, value, this._commit);
526
+ return new ConstantBuilder(this._token, value, this._commit);
505
527
  }
506
528
  toDynamic(factory) {
507
- return new BindingBuilderImpl(this._token, {
529
+ return new ConstraintBuilder(this._token, {
508
530
  kind: "dynamic",
509
531
  factory,
510
532
  scope: "transient"
511
533
  }, this._commit);
512
534
  }
513
535
  toDynamicAsync(factory) {
514
- return new BindingBuilderImpl(this._token, {
536
+ return new ConstraintBuilder(this._token, {
515
537
  kind: "dynamic-async",
516
538
  factory,
517
539
  scope: "transient"
518
540
  }, this._commit);
519
541
  }
520
542
  toResolved(factory, deps) {
521
- const normalizedDeps = deps.map((d) => normalizeToDescriptor(d));
522
- return new BindingBuilderImpl(this._token, {
543
+ const normalizedDeps = deps.map((dependency) => normalizeToDescriptor(dependency));
544
+ return new ConstraintBuilder(this._token, {
523
545
  kind: "resolved",
524
546
  factory,
525
547
  deps: normalizedDeps,
@@ -527,8 +549,8 @@ var BindToBuilderImpl = class {
527
549
  }, this._commit);
528
550
  }
529
551
  toResolvedAsync(factory, deps) {
530
- const normalizedDeps = deps.map((d) => normalizeToDescriptor(d));
531
- return new BindingBuilderImpl(this._token, {
552
+ const normalizedDeps = deps.map((dependency) => normalizeToDescriptor(dependency));
553
+ return new ConstraintBuilder(this._token, {
532
554
  kind: "resolved-async",
533
555
  factory,
534
556
  deps: normalizedDeps,
@@ -536,24 +558,18 @@ var BindToBuilderImpl = class {
536
558
  }, this._commit);
537
559
  }
538
560
  toAlias(target) {
539
- return new AliasBindingBuilderImpl(this._token, target, this._commit);
561
+ return new AliasBuilder(this._token, target, this._commit);
540
562
  }
541
563
  };
542
- var BindingBuilderImpl = class {
564
+ var ConstraintBuilder = class extends SlotBuilder {
543
565
  _token;
544
566
  _partial;
545
567
  _commit;
546
- _slot;
547
- _predicate;
548
- _committed;
549
568
  constructor(_token, _partial, _commit) {
569
+ super();
550
570
  this._token = _token;
551
571
  this._partial = _partial;
552
572
  this._commit = _commit;
553
- this._slot = {
554
- ...DEFAULT_SLOT,
555
- tags: []
556
- };
557
573
  this._doCommit();
558
574
  }
559
575
  _doCommit() {
@@ -567,31 +583,10 @@ var BindingBuilderImpl = class {
567
583
  };
568
584
  this._committed = this._commit(binding, previousId);
569
585
  }
570
- when(predicate) {
571
- this._predicate = predicate;
572
- this._doCommit();
573
- return this;
574
- }
575
- whenNamed(name) {
576
- this._slot = {
577
- ...this._slot,
578
- name
579
- };
580
- this._doCommit();
581
- return this;
582
- }
583
- whenTagged(tag, value) {
584
- this._slot = updateSlotTag(this._slot, tag, value);
585
- this._doCommit();
586
- return this;
587
- }
588
- whenDefault() {
589
- return this;
590
- }
591
586
  singleton() {
592
587
  const previousId = this._committed;
593
588
  this._committed = void 0;
594
- return new ScopeBuilderImpl(this._token, {
589
+ return new ScopeBuilder(this._token, {
595
590
  ...this._partial,
596
591
  scope: "singleton"
597
592
  }, this._slot, this._predicate, this._commit, "singleton", previousId);
@@ -599,7 +594,7 @@ var BindingBuilderImpl = class {
599
594
  transient() {
600
595
  const previousId = this._committed;
601
596
  this._committed = void 0;
602
- return new ScopeBuilderImpl(this._token, {
597
+ return new ScopeBuilder(this._token, {
603
598
  ...this._partial,
604
599
  scope: "transient"
605
600
  }, this._slot, this._predicate, this._commit, "transient", previousId);
@@ -607,16 +602,13 @@ var BindingBuilderImpl = class {
607
602
  scoped() {
608
603
  const previousId = this._committed;
609
604
  this._committed = void 0;
610
- return new ScopeBuilderImpl(this._token, {
605
+ return new ScopeBuilder(this._token, {
611
606
  ...this._partial,
612
607
  scope: "scoped"
613
608
  }, this._slot, this._predicate, this._commit, "scoped", previousId);
614
609
  }
615
- id() {
616
- return this._committed;
617
- }
618
610
  };
619
- var ScopeBuilderImpl = class {
611
+ var ScopeBuilder = class {
620
612
  _token;
621
613
  _partial;
622
614
  _slot;
@@ -664,23 +656,17 @@ var ScopeBuilderImpl = class {
664
656
  return this._committed;
665
657
  }
666
658
  };
667
- var ConstantBindingBuilderImpl = class {
659
+ var ConstantBuilder = class extends SlotBuilder {
668
660
  _token;
669
661
  _value;
670
662
  _commit;
671
- _slot;
672
- _predicate;
673
663
  _onActivation;
674
664
  _onDeactivation;
675
- _committed;
676
665
  constructor(_token, _value, _commit) {
666
+ super();
677
667
  this._token = _token;
678
668
  this._value = _value;
679
669
  this._commit = _commit;
680
- this._slot = {
681
- ...DEFAULT_SLOT,
682
- tags: []
683
- };
684
670
  this._doCommit();
685
671
  }
686
672
  _doCommit() {
@@ -698,27 +684,6 @@ var ConstantBindingBuilderImpl = class {
698
684
  };
699
685
  this._committed = this._commit(binding, previousId);
700
686
  }
701
- when(predicate) {
702
- this._predicate = predicate;
703
- this._doCommit();
704
- return this;
705
- }
706
- whenNamed(name) {
707
- this._slot = {
708
- ...this._slot,
709
- name
710
- };
711
- this._doCommit();
712
- return this;
713
- }
714
- whenTagged(tag, value) {
715
- this._slot = updateSlotTag(this._slot, tag, value);
716
- this._doCommit();
717
- return this;
718
- }
719
- whenDefault() {
720
- return this;
721
- }
722
687
  onActivation(fn) {
723
688
  this._onActivation = fn;
724
689
  this._doCommit();
@@ -729,25 +694,16 @@ var ConstantBindingBuilderImpl = class {
729
694
  this._doCommit();
730
695
  return this;
731
696
  }
732
- id() {
733
- return this._committed;
734
- }
735
697
  };
736
- var AliasBindingBuilderImpl = class {
698
+ var AliasBuilder = class extends SlotBuilder {
737
699
  _token;
738
700
  _target;
739
701
  _commit;
740
- _slot;
741
- _predicate;
742
- _committed;
743
702
  constructor(_token, _target, _commit) {
703
+ super();
744
704
  this._token = _token;
745
705
  this._target = _target;
746
706
  this._commit = _commit;
747
- this._slot = {
748
- ...DEFAULT_SLOT,
749
- tags: []
750
- };
751
707
  this._doCommit();
752
708
  }
753
709
  _doCommit() {
@@ -762,30 +718,6 @@ var AliasBindingBuilderImpl = class {
762
718
  };
763
719
  this._committed = this._commit(binding, previousId);
764
720
  }
765
- when(predicate) {
766
- this._predicate = predicate;
767
- this._doCommit();
768
- return this;
769
- }
770
- whenNamed(name) {
771
- this._slot = {
772
- ...this._slot,
773
- name
774
- };
775
- this._doCommit();
776
- return this;
777
- }
778
- whenTagged(tag, value) {
779
- this._slot = updateSlotTag(this._slot, tag, value);
780
- this._doCommit();
781
- return this;
782
- }
783
- whenDefault() {
784
- return this;
785
- }
786
- id() {
787
- return this._committed;
788
- }
789
721
  };
790
722
  /**
791
723
  * @since 0.3.16-canary.0
@@ -1,5 +1,6 @@
1
1
  import { Constructor } from "../constructor-type.mjs";
2
2
  import { Token } from "../token.mjs";
3
+ import { BindingTag } from "../types.mjs";
3
4
 
4
5
  //#region src/decorators/inject.d.ts
5
6
  /**
@@ -7,7 +8,7 @@ import { Token } from "../token.mjs";
7
8
  */
8
9
  interface InjectOptions {
9
10
  name?: string;
10
- tags?: ReadonlyArray<readonly [tag: string, value: unknown]>;
11
+ tags?: ReadonlyArray<BindingTag>;
11
12
  }
12
13
  /**
13
14
  * @since 0.3.16-canary.0
@@ -17,7 +18,7 @@ interface InjectionDescriptor<Value = unknown> {
17
18
  readonly optional: boolean;
18
19
  readonly multi: boolean;
19
20
  readonly name?: string;
20
- readonly tags?: ReadonlyArray<readonly [string, unknown]>;
21
+ readonly tags?: ReadonlyArray<BindingTag>;
21
22
  }
22
23
  /**
23
24
  * @since 0.3.16-canary.0
@@ -30,7 +31,7 @@ declare function isInjectionDescriptor(value: unknown): value is InjectionDescri
30
31
  /**
31
32
  * @since 0.3.16-canary.0
32
33
  */
33
- declare function normalizeToDescriptor(dep: InjectableDependency): InjectionDescriptor;
34
+ declare function normalizeToDescriptor(dependency: InjectableDependency): InjectionDescriptor;
34
35
  type ClassAccessorDecorator<This, Value> = (target: ClassAccessorDecoratorTarget<This, Value>, context: ClassAccessorDecoratorContext<This, Value>) => ClassAccessorDecoratorResult<This, Value> | void;
35
36
  /**
36
37
  * @since 0.3.16-canary.0