@codefast/di 0.3.16-canary.0 → 0.3.16-canary.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +8 -5
  3. package/dist/binding-select.d.mts +2 -2
  4. package/dist/binding-select.mjs +5 -5
  5. package/dist/binding.d.mts +12 -12
  6. package/dist/binding.mjs +8 -8
  7. package/dist/constraints.d.mts +25 -9
  8. package/dist/constraints.mjs +47 -19
  9. package/dist/constructor-type.d.mts +2 -2
  10. package/dist/container.d.mts +6 -6
  11. package/dist/container.mjs +202 -121
  12. package/dist/decorators/inject.d.mts +4 -4
  13. package/dist/decorators/inject.mjs +21 -19
  14. package/dist/decorators/injectable.d.mts +1 -1
  15. package/dist/decorators/injectable.mjs +18 -14
  16. package/dist/decorators/lifecycle-decorators.mjs +3 -0
  17. package/dist/dependency-graph.d.mts +2 -2
  18. package/dist/dependency-graph.mjs +13 -13
  19. package/dist/environment.d.mts +17 -17
  20. package/dist/environment.mjs +21 -21
  21. package/dist/errors.d.mts +18 -8
  22. package/dist/errors.mjs +17 -1
  23. package/dist/graph-adapters/reactflow.d.mts +2 -2
  24. package/dist/index.d.mts +6 -5
  25. package/dist/index.mjs +5 -4
  26. package/dist/inspector.d.mts +2 -3
  27. package/dist/inspector.mjs +18 -16
  28. package/dist/lifecycle.d.mts +5 -6
  29. package/dist/lifecycle.mjs +45 -52
  30. package/dist/metadata/metadata-keys.d.mts +24 -1
  31. package/dist/metadata/metadata-keys.mjs +14 -1
  32. package/dist/metadata/metadata-types.d.mts +5 -5
  33. package/dist/metadata/symbol-metadata-reader.mjs +31 -24
  34. package/dist/module.d.mts +2 -2
  35. package/dist/module.mjs +2 -2
  36. package/dist/registry.d.mts +6 -6
  37. package/dist/registry.mjs +55 -62
  38. package/dist/resolve-options.d.mts +5 -5
  39. package/dist/resolve-options.mjs +8 -8
  40. package/dist/resolver.d.mts +22 -10
  41. package/dist/resolver.mjs +206 -185
  42. package/dist/token.d.mts +1 -1
  43. package/dist/token.mjs +4 -4
  44. package/dist/types.d.mts +12 -8
  45. package/package.json +15 -8
@@ -1,11 +1,11 @@
1
1
  import { effectiveBindingScope } from "./binding-scope.mjs";
2
- import { DisposedContainerError, RebindUnboundTokenError, ScopeViolationError, SyncDisposalNotSupportedError } from "./errors.mjs";
3
- import { DEFAULT_SLOT, generateBindingId } from "./binding.mjs";
2
+ import { AsyncModuleLoadError, CircularDependencyError, DisposedContainerError, InternalError, RebindUnboundTokenError, ScopeViolationError, SyncDisposalNotSupportedError } from "./errors.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 { 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,18 +64,18 @@ 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();
@@ -130,8 +130,8 @@ var DefaultContainer = class DefaultContainer {
130
130
  }
131
131
  _getBindingsForTokenOrId(tokenOrId) {
132
132
  if (typeof tokenOrId === "string") {
133
- const b = this._registry.getById(tokenOrId);
134
- return b !== void 0 ? [b] : [];
133
+ const binding = this._registry.getById(tokenOrId);
134
+ return binding !== void 0 ? [binding] : [];
135
135
  }
136
136
  return [...this._registry.getAll(tokenOrId)];
137
137
  }
@@ -141,71 +141,72 @@ var DefaultContainer = class DefaultContainer {
141
141
  }
142
142
  _loadSyncModules(modules) {
143
143
  const toLoad = this._collectModuleDeps(modules);
144
- for (const mod of toLoad) {
145
- const ref = mod;
146
- const existing = this._moduleRefs.get(ref);
144
+ for (const module of toLoad) {
145
+ if (!isSyncModule(module)) throw new AsyncModuleLoadError(module.name);
146
+ const moduleRef = module;
147
+ const existing = this._moduleRefs.get(moduleRef);
147
148
  if (existing !== void 0) {
148
- this._moduleRefs.set(ref, existing + 1);
149
+ this._moduleRefs.set(moduleRef, existing + 1);
149
150
  continue;
150
151
  }
151
- this._moduleRefs.set(ref, 1);
152
- const builder = this._createModuleBuilder(ref);
153
- mod._setup(builder);
152
+ this._moduleRefs.set(moduleRef, 1);
153
+ const builder = this._createModuleBuilder(moduleRef);
154
+ module._setup(builder);
154
155
  }
155
156
  }
156
157
  _collectModuleDeps(modules) {
157
158
  const seen = /* @__PURE__ */ new Set();
158
159
  const result = [];
159
- const visit = (mod) => {
160
- const ref = mod;
161
- if (seen.has(ref)) return;
162
- seen.add(ref);
163
- result.push(mod);
160
+ const visit = (module) => {
161
+ const moduleRef = module;
162
+ if (seen.has(moduleRef)) return;
163
+ seen.add(moduleRef);
164
+ result.push(module);
164
165
  };
165
- for (const m of modules) visit(m);
166
+ for (const module of modules) visit(module);
166
167
  return result;
167
168
  }
168
169
  async loadAsync(...modules) {
169
170
  this._assertNotDisposed();
170
- for (const mod of modules) await this._loadOneModuleAsync(mod);
171
+ for (const module of modules) await this._loadOneModuleAsync(module);
171
172
  }
172
- async _loadOneModuleAsync(mod) {
173
- const ref = mod;
174
- const existing = this._moduleRefs.get(ref);
173
+ async _loadOneModuleAsync(module) {
174
+ const moduleRef = module;
175
+ const existing = this._moduleRefs.get(moduleRef);
175
176
  if (existing !== void 0) {
176
- this._moduleRefs.set(ref, existing + 1);
177
+ this._moduleRefs.set(moduleRef, existing + 1);
177
178
  return;
178
179
  }
179
- this._moduleRefs.set(ref, 1);
180
- if (isSyncModule(mod)) {
181
- const builder = this._createModuleBuilder(ref);
182
- mod._setup(builder);
180
+ this._moduleRefs.set(moduleRef, 1);
181
+ if (isSyncModule(module)) {
182
+ const builder = this._createModuleBuilder(moduleRef);
183
+ module._setup(builder);
183
184
  } else {
184
185
  const importPromises = [];
185
- const builder = this._createAsyncModuleBuilder(ref, importPromises);
186
- await mod._setup(builder);
186
+ const builder = this._createAsyncModuleBuilder(moduleRef, importPromises);
187
+ await module._setup(builder);
187
188
  if (importPromises.length > 0) await Promise.all(importPromises);
188
189
  }
189
190
  }
190
191
  _createModuleBuilder(moduleRef) {
191
192
  return {
192
- bind: (t) => this._createBindToBuilder(t, moduleRef),
193
- import: (...mods) => {
194
- this._loadSyncModules(mods);
193
+ bind: (token) => this._createBindToBuilder(token, moduleRef),
194
+ import: (...modules) => {
195
+ this._loadSyncModules(modules);
195
196
  }
196
197
  };
197
198
  }
198
199
  _createAsyncModuleBuilder(moduleRef, importPromises) {
199
200
  return {
200
- bind: (t) => this._createBindToBuilder(t, moduleRef),
201
- import: (...mods) => {
202
- for (const mod of mods) importPromises.push(this._loadOneModuleAsync(mod));
201
+ bind: (token) => this._createBindToBuilder(token, moduleRef),
202
+ import: (...modules) => {
203
+ for (const module of modules) importPromises.push(this._loadOneModuleAsync(module));
203
204
  }
204
205
  };
205
206
  }
206
207
  unload(...modules) {
207
208
  this._assertNotDisposed();
208
- for (const mod of modules) this._unloadModuleSync(mod);
209
+ for (const module of modules) this._unloadModuleSync(module);
209
210
  }
210
211
  _unloadModuleSync(ref) {
211
212
  const count = this._moduleRefs.get(ref) ?? 0;
@@ -228,7 +229,7 @@ var DefaultContainer = class DefaultContainer {
228
229
  }
229
230
  async unloadAsync(...modules) {
230
231
  this._assertNotDisposed();
231
- for (const mod of modules) await this._unloadModuleAsync(mod);
232
+ for (const module of modules) await this._unloadModuleAsync(module);
232
233
  }
233
234
  async _unloadModuleAsync(ref) {
234
235
  const count = this._moduleRefs.get(ref) ?? 0;
@@ -253,10 +254,10 @@ var DefaultContainer = class DefaultContainer {
253
254
  this._assertNotDisposed();
254
255
  const entries = registry.entries();
255
256
  for (const { target, scope } of entries) {
256
- const bb = this._createBindToBuilder(target).toSelf();
257
- if (scope === "singleton") bb.singleton();
258
- else if (scope === "scoped") bb.scoped();
259
- else bb.transient();
257
+ const bindingBuilder = this._createBindToBuilder(target).toSelf();
258
+ if (scope === "singleton") bindingBuilder.singleton();
259
+ else if (scope === "scoped") bindingBuilder.scoped();
260
+ else bindingBuilder.transient();
260
261
  }
261
262
  return entries.length;
262
263
  }
@@ -322,7 +323,7 @@ var DefaultContainer = class DefaultContainer {
322
323
  if (effectiveBindingScope(binding) === "singleton" && !this._scope.hasSingleton(binding.id)) {
323
324
  if (binding.predicate !== void 0) continue;
324
325
  if (binding.kind === "constant" && binding.onActivation === void 0) continue;
325
- const slotHint = slotKeyToResolveOptions(binding.slot);
326
+ const slotHint = bindingSlotToResolveOptions(binding.slot);
326
327
  await this.resolveAsync(binding.token, slotHint);
327
328
  }
328
329
  }
@@ -332,43 +333,116 @@ var DefaultContainer = class DefaultContainer {
332
333
  const reader = this._getMetadataReader();
333
334
  const allBindings = this._registry.allBindings();
334
335
  for (const binding of allBindings) {
335
- if (binding.kind === "alias" || binding.kind === "constant" || binding.kind === "dynamic" || binding.kind === "dynamic-async") continue;
336
- const scope = effectiveBindingScope(binding);
337
- if (scope !== "singleton") continue;
338
- const deps = this._getDepsForBinding(binding, reader);
339
- for (const dep of deps) this._validateDep(tokenName(binding.token), scope, dep, [tokenName(binding.token)], reader);
336
+ if (!this._isSingletonStaticAnalyzableBinding(binding)) continue;
337
+ this._validateSingletonBindingGraph(binding, reader);
340
338
  }
341
339
  }
342
- _getDepsForBinding(binding, reader) {
343
- const result = [];
344
- if (binding.kind === "class") {
345
- const meta = reader.getConstructorMetadata(binding.target);
346
- if (meta !== void 0) for (const param of meta.params) {
347
- const depBindings = this._registry.getAll(param.token);
348
- for (const db of depBindings) if (db.kind !== "alias") result.push({
349
- token: param.token,
350
- scope: effectiveBindingScope(db)
340
+ _isSingletonStaticAnalyzableBinding(binding) {
341
+ if (effectiveBindingScope(binding) !== "singleton") return false;
342
+ return binding.kind === "class" || binding.kind === "resolved" || binding.kind === "resolved-async";
343
+ }
344
+ /**
345
+ * DFS over explicit constructor / `toResolved*` dependency edges. Follows `toAlias` chains to the
346
+ * terminal binding for scope checks (SPEC §6.9). Skips `toDynamic*` subtrees (opaque).
347
+ */
348
+ _validateSingletonBindingGraph(root, reader) {
349
+ const rootName = tokenName(root.token);
350
+ const dfs = (current, pathNames, pathBindingIds) => {
351
+ if (pathBindingIds.has(current.id)) return;
352
+ const extendedPathIds = new Set(pathBindingIds);
353
+ extendedPathIds.add(current.id);
354
+ for (const edge of this._collectStaticDependencyEdges(current, reader)) {
355
+ const { terminal, depTokenName } = edge;
356
+ const depScope = this._validationScopeFromTerminal(terminal);
357
+ if (depScope === "opaque") continue;
358
+ if (depScope === "scoped" || depScope === "transient") throw new ScopeViolationError({
359
+ consumerToken: rootName,
360
+ consumerScope: "singleton",
361
+ dependencyToken: depTokenName,
362
+ dependencyScope: depScope,
363
+ path: [...pathNames, depTokenName]
351
364
  });
365
+ if (terminal.kind === "class" || terminal.kind === "resolved" || terminal.kind === "resolved-async") dfs(terminal, [...pathNames, depTokenName], extendedPathIds);
352
366
  }
353
- } else if (binding.kind === "resolved" || binding.kind === "resolved-async") for (const dep of binding.deps) {
354
- const depBindings = this._registry.getAll(dep.token);
355
- for (const db of depBindings) if (db.kind !== "alias") result.push({
356
- token: dep.token,
357
- scope: effectiveBindingScope(db)
358
- });
367
+ };
368
+ dfs(root, [rootName], /* @__PURE__ */ new Set());
369
+ }
370
+ _validationScopeFromTerminal(terminal) {
371
+ switch (terminal.kind) {
372
+ case "constant": return "singleton";
373
+ case "dynamic":
374
+ case "dynamic-async": return "opaque";
375
+ case "class":
376
+ case "resolved":
377
+ case "resolved-async": return terminal.scope;
378
+ case "alias": throw new InternalError("validate: expected terminal binding after alias resolution");
379
+ default: return terminal;
359
380
  }
360
- return result;
361
381
  }
362
- _validateDep(consumerToken, consumerScope, dep, path, _reader) {
363
- if (consumerScope === "singleton") {
364
- if (dep.scope === "scoped" || dep.scope === "transient") throw new ScopeViolationError({
365
- consumerToken,
366
- consumerScope,
367
- dependencyToken: tokenName(dep.token),
368
- dependencyScope: dep.scope,
369
- path
382
+ _followAliasChainToTerminal(binding, hint) {
383
+ const cyclePath = [];
384
+ const seenAliasIds = /* @__PURE__ */ new Set();
385
+ let current = binding;
386
+ while (current !== void 0 && current.kind === "alias") {
387
+ if (seenAliasIds.has(current.id)) throw new CircularDependencyError(cyclePath);
388
+ seenAliasIds.add(current.id);
389
+ cyclePath.push(tokenName(current.token));
390
+ const nextToken = current.target;
391
+ const next = this._resolver.peekBindingForValidate(nextToken, hint);
392
+ if (next === void 0) return;
393
+ current = next.binding;
394
+ }
395
+ return current;
396
+ }
397
+ _collectStaticDependencyEdges(binding, reader) {
398
+ const edges = [];
399
+ const pushTerminal = (terminal, displayName) => {
400
+ if (terminal === void 0) return;
401
+ edges.push({
402
+ terminal,
403
+ depTokenName: displayName
370
404
  });
405
+ };
406
+ if (binding.kind === "class") {
407
+ const meta = reader.getConstructorMetadata(binding.target);
408
+ if (meta === void 0) return edges;
409
+ for (const param of meta.params) {
410
+ const paramHint = injectionSlotToResolveOptions(param);
411
+ if (param.optional) continue;
412
+ const tokenRef = param.token;
413
+ if (param.multi) {
414
+ const candidates = this._resolver.peekCandidateBindingsForValidate(tokenRef, paramHint);
415
+ for (const cand of candidates) {
416
+ const term = this._followAliasChainToTerminal(cand, paramHint);
417
+ pushTerminal(term, term !== void 0 ? tokenName(term.token) : "");
418
+ }
419
+ continue;
420
+ }
421
+ const found = paramHint === void 0 ? this._resolver.peekBindingForValidate(tokenRef, void 0) : this._resolver.peekBindingForValidate(tokenRef, paramHint);
422
+ if (found === void 0) continue;
423
+ const term = this._followAliasChainToTerminal(found.binding, paramHint);
424
+ pushTerminal(term, term !== void 0 ? tokenName(term.token) : "");
425
+ }
426
+ return edges;
371
427
  }
428
+ if (binding.kind === "resolved" || binding.kind === "resolved-async") for (const dep of binding.deps) {
429
+ const depHint = injectionSlotToResolveOptions(dep);
430
+ if (dep.optional) continue;
431
+ const tokenRef = dep.token;
432
+ if (dep.multi) {
433
+ const candidates = this._resolver.peekCandidateBindingsForValidate(tokenRef, depHint);
434
+ for (const cand of candidates) {
435
+ const term = this._followAliasChainToTerminal(cand, depHint);
436
+ pushTerminal(term, term !== void 0 ? tokenName(term.token) : "");
437
+ }
438
+ continue;
439
+ }
440
+ const found = depHint === void 0 ? this._resolver.peekBindingForValidate(tokenRef, void 0) : this._resolver.peekBindingForValidate(tokenRef, depHint);
441
+ if (found === void 0) continue;
442
+ const term = this._followAliasChainToTerminal(found.binding, depHint);
443
+ pushTerminal(term, term !== void 0 ? tokenName(term.token) : "");
444
+ }
445
+ return edges;
372
446
  }
373
447
  has(token, hint) {
374
448
  this._assertNotDisposed();
@@ -394,13 +468,25 @@ var DefaultContainer = class DefaultContainer {
394
468
  if (this._disposed) throw new DisposedContainerError();
395
469
  }
396
470
  };
397
- var BindToBuilderImpl = class {
471
+ function updateSlotTag(slot, tag, value) {
472
+ const existing = [...slot.tags];
473
+ const idx = existing.findIndex(([k]) => k === tag);
474
+ if (idx !== -1) existing[idx] = [tag, value];
475
+ else existing.push([tag, value]);
476
+ return {
477
+ ...slot,
478
+ tags: existing
479
+ };
480
+ }
481
+ var BindingEntry = class {
482
+ _token;
483
+ _commit;
398
484
  constructor(_token, _commit) {
399
485
  this._token = _token;
400
486
  this._commit = _commit;
401
487
  }
402
488
  to(type) {
403
- return new BindingBuilderImpl(this._token, {
489
+ return new ConstraintBuilder(this._token, {
404
490
  kind: "class",
405
491
  target: type,
406
492
  scope: "transient"
@@ -408,32 +494,32 @@ var BindToBuilderImpl = class {
408
494
  }
409
495
  toSelf() {
410
496
  if (typeof this._token !== "function") throw new Error("toSelf() requires token to be a Constructor");
411
- return new BindingBuilderImpl(this._token, {
497
+ return new ConstraintBuilder(this._token, {
412
498
  kind: "class",
413
499
  target: this._token,
414
500
  scope: "transient"
415
501
  }, this._commit);
416
502
  }
417
503
  toConstantValue(value) {
418
- return new ConstantBindingBuilderImpl(this._token, value, this._commit);
504
+ return new ConstantBuilder(this._token, value, this._commit);
419
505
  }
420
506
  toDynamic(factory) {
421
- return new BindingBuilderImpl(this._token, {
507
+ return new ConstraintBuilder(this._token, {
422
508
  kind: "dynamic",
423
509
  factory,
424
510
  scope: "transient"
425
511
  }, this._commit);
426
512
  }
427
513
  toDynamicAsync(factory) {
428
- return new BindingBuilderImpl(this._token, {
514
+ return new ConstraintBuilder(this._token, {
429
515
  kind: "dynamic-async",
430
516
  factory,
431
517
  scope: "transient"
432
518
  }, this._commit);
433
519
  }
434
520
  toResolved(factory, deps) {
435
- const normalizedDeps = deps.map((d) => normalizeToDescriptor(d));
436
- return new BindingBuilderImpl(this._token, {
521
+ const normalizedDeps = deps.map((dependency) => normalizeToDescriptor(dependency));
522
+ return new ConstraintBuilder(this._token, {
437
523
  kind: "resolved",
438
524
  factory,
439
525
  deps: normalizedDeps,
@@ -441,8 +527,8 @@ var BindToBuilderImpl = class {
441
527
  }, this._commit);
442
528
  }
443
529
  toResolvedAsync(factory, deps) {
444
- const normalizedDeps = deps.map((d) => normalizeToDescriptor(d));
445
- return new BindingBuilderImpl(this._token, {
530
+ const normalizedDeps = deps.map((dependency) => normalizeToDescriptor(dependency));
531
+ return new ConstraintBuilder(this._token, {
446
532
  kind: "resolved-async",
447
533
  factory,
448
534
  deps: normalizedDeps,
@@ -450,10 +536,13 @@ var BindToBuilderImpl = class {
450
536
  }, this._commit);
451
537
  }
452
538
  toAlias(target) {
453
- return new AliasBindingBuilderImpl(this._token, target, this._commit);
539
+ return new AliasBuilder(this._token, target, this._commit);
454
540
  }
455
541
  };
456
- var BindingBuilderImpl = class {
542
+ var ConstraintBuilder = class {
543
+ _token;
544
+ _partial;
545
+ _commit;
457
546
  _slot;
458
547
  _predicate;
459
548
  _committed;
@@ -462,7 +551,7 @@ var BindingBuilderImpl = class {
462
551
  this._partial = _partial;
463
552
  this._commit = _commit;
464
553
  this._slot = {
465
- ...DEFAULT_SLOT,
554
+ ...DEFAULT_BINDING_SLOT,
466
555
  tags: []
467
556
  };
468
557
  this._doCommit();
@@ -492,14 +581,7 @@ var BindingBuilderImpl = class {
492
581
  return this;
493
582
  }
494
583
  whenTagged(tag, value) {
495
- const existing = [...this._slot.tags];
496
- const idx = existing.findIndex(([k]) => k === tag);
497
- if (idx !== -1) existing[idx] = [tag, value];
498
- else existing.push([tag, value]);
499
- this._slot = {
500
- ...this._slot,
501
- tags: existing
502
- };
584
+ this._slot = updateSlotTag(this._slot, tag, value);
503
585
  this._doCommit();
504
586
  return this;
505
587
  }
@@ -509,7 +591,7 @@ var BindingBuilderImpl = class {
509
591
  singleton() {
510
592
  const previousId = this._committed;
511
593
  this._committed = void 0;
512
- return new ScopeBuilderImpl(this._token, {
594
+ return new ScopeBuilder(this._token, {
513
595
  ...this._partial,
514
596
  scope: "singleton"
515
597
  }, this._slot, this._predicate, this._commit, "singleton", previousId);
@@ -517,7 +599,7 @@ var BindingBuilderImpl = class {
517
599
  transient() {
518
600
  const previousId = this._committed;
519
601
  this._committed = void 0;
520
- return new ScopeBuilderImpl(this._token, {
602
+ return new ScopeBuilder(this._token, {
521
603
  ...this._partial,
522
604
  scope: "transient"
523
605
  }, this._slot, this._predicate, this._commit, "transient", previousId);
@@ -525,7 +607,7 @@ var BindingBuilderImpl = class {
525
607
  scoped() {
526
608
  const previousId = this._committed;
527
609
  this._committed = void 0;
528
- return new ScopeBuilderImpl(this._token, {
610
+ return new ScopeBuilder(this._token, {
529
611
  ...this._partial,
530
612
  scope: "scoped"
531
613
  }, this._slot, this._predicate, this._commit, "scoped", previousId);
@@ -534,7 +616,14 @@ var BindingBuilderImpl = class {
534
616
  return this._committed;
535
617
  }
536
618
  };
537
- var ScopeBuilderImpl = class {
619
+ var ScopeBuilder = class {
620
+ _token;
621
+ _partial;
622
+ _slot;
623
+ _predicate;
624
+ _commit;
625
+ _scope;
626
+ _initialPreviousId;
538
627
  _onActivation;
539
628
  _onDeactivation;
540
629
  _committed;
@@ -575,7 +664,10 @@ var ScopeBuilderImpl = class {
575
664
  return this._committed;
576
665
  }
577
666
  };
578
- var ConstantBindingBuilderImpl = class {
667
+ var ConstantBuilder = class {
668
+ _token;
669
+ _value;
670
+ _commit;
579
671
  _slot;
580
672
  _predicate;
581
673
  _onActivation;
@@ -586,7 +678,7 @@ var ConstantBindingBuilderImpl = class {
586
678
  this._value = _value;
587
679
  this._commit = _commit;
588
680
  this._slot = {
589
- ...DEFAULT_SLOT,
681
+ ...DEFAULT_BINDING_SLOT,
590
682
  tags: []
591
683
  };
592
684
  this._doCommit();
@@ -620,14 +712,7 @@ var ConstantBindingBuilderImpl = class {
620
712
  return this;
621
713
  }
622
714
  whenTagged(tag, value) {
623
- const existing = [...this._slot.tags];
624
- const idx = existing.findIndex(([k]) => k === tag);
625
- if (idx !== -1) existing[idx] = [tag, value];
626
- else existing.push([tag, value]);
627
- this._slot = {
628
- ...this._slot,
629
- tags: existing
630
- };
715
+ this._slot = updateSlotTag(this._slot, tag, value);
631
716
  this._doCommit();
632
717
  return this;
633
718
  }
@@ -648,7 +733,10 @@ var ConstantBindingBuilderImpl = class {
648
733
  return this._committed;
649
734
  }
650
735
  };
651
- var AliasBindingBuilderImpl = class {
736
+ var AliasBuilder = class {
737
+ _token;
738
+ _target;
739
+ _commit;
652
740
  _slot;
653
741
  _predicate;
654
742
  _committed;
@@ -657,7 +745,7 @@ var AliasBindingBuilderImpl = class {
657
745
  this._target = _target;
658
746
  this._commit = _commit;
659
747
  this._slot = {
660
- ...DEFAULT_SLOT,
748
+ ...DEFAULT_BINDING_SLOT,
661
749
  tags: []
662
750
  };
663
751
  this._doCommit();
@@ -688,14 +776,7 @@ var AliasBindingBuilderImpl = class {
688
776
  return this;
689
777
  }
690
778
  whenTagged(tag, value) {
691
- const existing = [...this._slot.tags];
692
- const idx = existing.findIndex(([k]) => k === tag);
693
- if (idx !== -1) existing[idx] = [tag, value];
694
- else existing.push([tag, value]);
695
- this._slot = {
696
- ...this._slot,
697
- tags: existing
698
- };
779
+ this._slot = updateSlotTag(this._slot, tag, value);
699
780
  this._doCommit();
700
781
  return this;
701
782
  }
@@ -30,19 +30,19 @@ declare function isInjectionDescriptor(value: unknown): value is InjectionDescri
30
30
  /**
31
31
  * @since 0.3.16-canary.0
32
32
  */
33
- declare function normalizeToDescriptor(dep: InjectableDependency): InjectionDescriptor;
33
+ declare function normalizeToDescriptor(dependency: InjectableDependency): InjectionDescriptor;
34
34
  type ClassAccessorDecorator<This, Value> = (target: ClassAccessorDecoratorTarget<This, Value>, context: ClassAccessorDecoratorContext<This, Value>) => ClassAccessorDecoratorResult<This, Value> | void;
35
35
  /**
36
36
  * @since 0.3.16-canary.0
37
37
  */
38
- declare function inject<const Value>(t: Token<Value> | Constructor<Value>, options?: InjectOptions): InjectionDescriptor<Value> & ClassAccessorDecorator<unknown, Value>;
38
+ declare function inject<const Value>(token: Token<Value> | Constructor<Value>, options?: InjectOptions): InjectionDescriptor<Value> & ClassAccessorDecorator<unknown, Value>;
39
39
  /**
40
40
  * @since 0.3.16-canary.0
41
41
  */
42
- declare function optional<const Value>(t: Token<Value> | Constructor<Value>, options?: InjectOptions): InjectionDescriptor<Value | undefined>;
42
+ declare function optional<const Value>(token: Token<Value> | Constructor<Value>, options?: InjectOptions): InjectionDescriptor<Value | undefined>;
43
43
  /**
44
44
  * @since 0.3.16-canary.0
45
45
  */
46
- declare function injectAll<const Value>(t: Token<Value> | Constructor<Value>, options?: InjectOptions): InjectionDescriptor<Value[]>;
46
+ declare function injectAll<const Value>(token: Token<Value> | Constructor<Value>, options?: InjectOptions): InjectionDescriptor<Array<Value>>;
47
47
  //#endregion
48
48
  export { InjectOptions, InjectableDependency, InjectionDescriptor, inject, injectAll, isInjectionDescriptor, normalizeToDescriptor, optional };