@codefast/di 0.13.0 → 0.14.0

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 (43) hide show
  1. package/CHANGELOG.md +152 -0
  2. package/README.md +48 -32
  3. package/dist/ambient-container.d.ts +46 -0
  4. package/dist/ambient-container.js +72 -1
  5. package/dist/container/binding-chain.js +3 -3
  6. package/dist/container/container.d.ts +41 -29
  7. package/dist/container/container.js +49 -264
  8. package/dist/container/introspect.d.ts +47 -0
  9. package/dist/container/introspect.js +53 -0
  10. package/dist/core/binding-builders.d.ts +22 -1
  11. package/dist/core/binding-declaration.js +2 -2
  12. package/dist/core/module.d.ts +4 -25
  13. package/dist/core/module.js +3 -27
  14. package/dist/core/state-epoch.d.ts +1 -1
  15. package/dist/core/state-epoch.js +1 -1
  16. package/dist/core/types.d.ts +16 -7
  17. package/dist/decorators/inject.js +27 -22
  18. package/dist/decorators/injectable.d.ts +14 -18
  19. package/dist/decorators/injectable.js +23 -2
  20. package/dist/errors.d.ts +11 -2
  21. package/dist/errors.js +6 -3
  22. package/dist/index.d.ts +8 -7
  23. package/dist/index.js +3 -2
  24. package/dist/injection/dependency-slot.d.ts +17 -0
  25. package/dist/injection/dependency-slot.js +46 -0
  26. package/dist/injection/descriptor.d.ts +9 -3
  27. package/dist/injection/descriptor.js +10 -1
  28. package/dist/introspection/validation.d.ts +28 -0
  29. package/dist/introspection/validation.js +244 -0
  30. package/dist/lifecycle/hooks.d.ts +11 -2
  31. package/dist/lifecycle/hooks.js +30 -18
  32. package/dist/resolution/cache/class-introspector.d.ts +7 -8
  33. package/dist/resolution/cache/class-introspector.js +40 -3
  34. package/dist/resolution/cache/lookup.d.ts +10 -0
  35. package/dist/resolution/cache/lookup.js +27 -0
  36. package/dist/resolution/context.d.ts +12 -12
  37. package/dist/resolution/plan/codegen.d.ts +2 -1
  38. package/dist/resolution/plan/codegen.js +1 -1
  39. package/dist/resolution/plan/compiler.d.ts +6 -6
  40. package/dist/resolution/plan/compiler.js +152 -22
  41. package/dist/resolution/resolver.d.ts +2 -8
  42. package/dist/resolution/resolver.js +17 -93
  43. package/package.json +10 -2
@@ -1,3 +1,4 @@
1
+ import { isPreparableSlot, PreparedAccessorResolution } from "#ambient-container";
1
2
  import { NO_INSTANCE } from "#core/binding";
2
3
  import { tokenName } from "#core/token";
3
4
  import { AsyncResolutionError } from "#errors";
@@ -233,26 +234,22 @@ export class InstantiationPlanCompiler {
233
234
  if (hasPostConstruct) {
234
235
  return null;
235
236
  }
236
- // An accessor-injected class compiles only as the plan's root: its accessors resolve during
237
- // construction with the class's own frame on the path, and a root has no static ancestors to replay.
238
- const withAccessors = this.#host.needsActiveContainer(target);
239
- if (withAccessors && depth !== 0) {
237
+ const accessorSlots = this.#preparableAccessorSlots(target);
238
+ if (accessorSlots === null) {
240
239
  return null;
241
240
  }
242
241
  const invokable = target;
243
242
  const meta = this.#host.getConstructorMetadata(target);
244
- if (meta === undefined) {
245
- // Metadata-less classes with required params throw on the runtime path — keep them there.
246
- if (target.length !== 0) {
247
- return null;
248
- }
249
- return this.#classNode(binding, invokable, withAccessors, []);
243
+ // Metadata-less classes with required params throw on the runtime path — keep them there.
244
+ if (meta === undefined && target.length !== 0) {
245
+ return null;
250
246
  }
251
- const params = meta.params;
252
- if (params.length === 0) {
253
- return this.#classNode(binding, invokable, withAccessors, []);
247
+ const params = meta?.params ?? [];
248
+ if (params.length === 0 && accessorSlots.length === 0) {
249
+ return this.#classNode(invokable, []);
254
250
  }
255
251
  const deps = new Array(params.length);
252
+ const accessorDeps = new Array(accessorSlots.length);
256
253
  const depAncestors = [...ancestors, binding];
257
254
  compileStack.add(binding.identifier);
258
255
  try {
@@ -263,21 +260,98 @@ export class InstantiationPlanCompiler {
263
260
  }
264
261
  deps[index] = dep;
265
262
  }
263
+ for (let index = 0; index < accessorSlots.length; index += 1) {
264
+ const dep = this.#compileInjectionThunk(accessorSlots[index], compileStack, depth, depAncestors);
265
+ if (dep === PLAN_RETRY) {
266
+ return dep;
267
+ }
268
+ accessorDeps[index] = dep;
269
+ }
266
270
  }
267
271
  finally {
268
272
  compileStack.delete(binding.identifier);
269
273
  }
270
- return this.#classNode(binding, invokable, withAccessors, deps);
274
+ if (accessorSlots.length === 0) {
275
+ return this.#classNode(invokable, deps);
276
+ }
277
+ return this.#accessorClassNode(invokable, deps, accessorSlots, accessorDeps, depAncestors);
278
+ }
279
+ /**
280
+ * A class whose accessors take values the plan resolves before `new`, as its params do.
281
+ *
282
+ * @remarks The fallback resolves an accessor the prepared values do not cover, seeded with the class
283
+ * on the path so a cycle back into it is still caught.
284
+ */
285
+ #accessorClassNode(invokable, deps, accessorSlots, accessorDeps, ancestors) {
286
+ const host = this.#host;
287
+ const fallback = this.#seededResolution(ancestors);
288
+ const construct = (params, accessorValues) => host.constructWithAccessors(invokable, params, new PreparedAccessorResolution(fallback, accessorSlots, accessorValues));
289
+ const runs = deps.map((dep) => dep.run);
290
+ const accessorRuns = accessorDeps.map((dep) => dep.run);
291
+ const node = {
292
+ kind: "accessors",
293
+ construct,
294
+ deps: deps.map((dep) => dep.node),
295
+ accessors: accessorDeps.map((dep) => dep.node),
296
+ };
297
+ // The common shape — no constructor params, one accessor — is written out so it maps nothing.
298
+ if (runs.length === 0 && accessorRuns.length === 1) {
299
+ const accessor0 = accessorRuns[0];
300
+ return { run: () => construct([], [accessor0()]), node };
301
+ }
302
+ return {
303
+ run: () => construct(runs.map((run) => run()), accessorRuns.map((run) => run())),
304
+ node,
305
+ };
306
+ }
307
+ /** A class's accessor slots, or `null` when one is a record no `@inject` initializer will ask for. */
308
+ #preparableAccessorSlots(target) {
309
+ const accessorSlots = this.#host.accessorSlots(target);
310
+ // A custom reader's own record would be resolved for nothing, so its class stays on the interpreted lane.
311
+ for (let index = 0; index < accessorSlots.length; index += 1) {
312
+ if (!isPreparableSlot(accessorSlots[index])) {
313
+ return null;
314
+ }
315
+ }
316
+ return accessorSlots;
317
+ }
318
+ /**
319
+ * Constructs an accessor class from its settled params, resolving its accessors synchronously first.
320
+ *
321
+ * @remarks The async lane's construction, where the params may have been awaited but the accessors
322
+ * resolve on the sync lane, as their initializers would.
323
+ */
324
+ #accessorConstruct(invokable, accessorSlots, accessorDeps, ancestors) {
325
+ const host = this.#host;
326
+ const fallback = this.#seededResolution(ancestors);
327
+ const accessorRuns = accessorDeps.map((dep) => dep.run);
328
+ if (accessorRuns.length === 1) {
329
+ const accessor0 = accessorRuns[0];
330
+ return (params) => host.constructWithAccessors(invokable, params, new PreparedAccessorResolution(fallback, accessorSlots, [accessor0()]));
331
+ }
332
+ return (params) => host.constructWithAccessors(invokable, params, new PreparedAccessorResolution(fallback, accessorSlots, accessorRuns.map((run) => run())));
333
+ }
334
+ /** A path-continuing resolution seeded with fixed ancestors, for a request no thunk was compiled for. */
335
+ #seededResolution(ancestors) {
336
+ const host = this.#host;
337
+ const frames = ancestors.map((ancestor) => host.getResolutionFrame(ancestor));
338
+ const escaped = (token, options, arity) => {
339
+ const alreadyInFlight = enterSeededPath(ancestors);
340
+ try {
341
+ return host.resolveEscaped(token, options, arity, [...frames]);
342
+ }
343
+ finally {
344
+ leaveSeededPath(ancestors, alreadyInFlight);
345
+ }
346
+ };
347
+ return {
348
+ resolve: (token, options) => escaped(token, options, "single"),
349
+ resolveOptional: (token, options) => escaped(token, options, "optional"),
350
+ };
271
351
  }
272
352
  // The closure is hand-written per arity up to three so the common shapes spread nothing.
273
- #classNode(binding, invokable, withAccessors, deps) {
353
+ #classNode(invokable, deps) {
274
354
  const nodes = deps.map((dep) => dep.node);
275
- if (withAccessors) {
276
- const host = this.#host;
277
- const construct = (values) => host.constructWithAccessors(binding, invokable, values);
278
- const runs = deps.map((dep) => dep.run);
279
- return { run: () => construct(runs.map((run) => run())), node: { kind: "accessors", construct, deps: nodes } };
280
- }
281
355
  const node = { kind: "construct", target: invokable, deps: nodes };
282
356
  switch (deps.length) {
283
357
  case 0:
@@ -368,11 +442,18 @@ export class InstantiationPlanCompiler {
368
442
  if (hasPostConstruct === undefined) {
369
443
  return PLAN_RETRY;
370
444
  }
371
- if (hasPostConstruct || this.#host.needsActiveContainer(target)) {
445
+ if (hasPostConstruct) {
446
+ return null;
447
+ }
448
+ const accessorSlots = this.#preparableAccessorSlots(target);
449
+ if (accessorSlots === null) {
372
450
  return null;
373
451
  }
374
452
  const invokable = target;
375
453
  const meta = this.#host.getConstructorMetadata(target);
454
+ if (accessorSlots.length > 0) {
455
+ return this.#compileAsyncAccessorClassNode(binding, invokable, meta, accessorSlots, compileStack, depth, ancestors);
456
+ }
376
457
  const leaf = {
377
458
  run: () => new invokable(),
378
459
  promiseShape: "never",
@@ -428,6 +509,55 @@ export class InstantiationPlanCompiler {
428
509
  node: { kind: "construct", target: invokable, deps: nodes, awaits: true },
429
510
  };
430
511
  }
512
+ /**
513
+ * An accessor class on the async lane: its params settle as any class's do, then its accessors
514
+ * resolve synchronously and the class constructs, the order the interpreted async lane keeps.
515
+ */
516
+ #compileAsyncAccessorClassNode(binding, invokable, meta, accessorSlots, compileStack, depth, ancestors) {
517
+ // Metadata-less classes with required params throw on the runtime path — keep them there.
518
+ if (meta === undefined && binding.target.length !== 0) {
519
+ return null;
520
+ }
521
+ const params = meta?.params ?? [];
522
+ const depThunks = new Array(params.length);
523
+ const accessorDeps = new Array(accessorSlots.length);
524
+ const depAncestors = [...ancestors, binding];
525
+ compileStack.add(binding.identifier);
526
+ try {
527
+ for (let index = 0; index < params.length; index += 1) {
528
+ const thunk = this.#compileAsyncInjectionThunk(params[index], compileStack, depth, depAncestors);
529
+ if (thunk === PLAN_RETRY) {
530
+ return thunk;
531
+ }
532
+ depThunks[index] = thunk;
533
+ }
534
+ for (let index = 0; index < accessorSlots.length; index += 1) {
535
+ const dep = this.#compileInjectionThunk(accessorSlots[index], compileStack, depth, depAncestors);
536
+ if (dep === PLAN_RETRY) {
537
+ return dep;
538
+ }
539
+ accessorDeps[index] = dep;
540
+ }
541
+ }
542
+ finally {
543
+ compileStack.delete(binding.identifier);
544
+ }
545
+ const construct = this.#accessorConstruct(invokable, accessorSlots, accessorDeps, depAncestors);
546
+ const factory = (...values) => construct(values);
547
+ const nodes = depThunks.map((thunk) => thunk.node);
548
+ if (allSynchronous(depThunks)) {
549
+ return {
550
+ run: () => construct(depThunks.map((thunk) => thunk.run())),
551
+ promiseShape: "never",
552
+ node: { kind: "call", factory, deps: nodes, awaits: false },
553
+ };
554
+ }
555
+ return {
556
+ run: settleThenApply(depThunks, construct),
557
+ promiseShape: "always",
558
+ node: { kind: "call", factory, deps: nodes, awaits: true },
559
+ };
560
+ }
431
561
  #compileAsyncResolvedNode(binding, compileStack, depth, ancestors) {
432
562
  if (binding.activationHook !== undefined || this.#host.hasActivationHandlers(binding)) {
433
563
  return null;
@@ -3,7 +3,6 @@ import type { Binding } from "#core/binding";
3
3
  import type { BindingRegistry } from "#core/registry";
4
4
  import type { Token } from "#core/token";
5
5
  import type { BindingTag, Constructor, ResolutionFrame, ResolveOptions } from "#core/types";
6
- import { NoMatchingBindingError, TokenNotBoundError } from "#errors";
7
6
  import type { ResolutionDiagnostics } from "#introspection/diagnostics";
8
7
  import type { LifecycleManager } from "#lifecycle/hooks";
9
8
  import type { ScopeManager } from "#lifecycle/scopes";
@@ -40,13 +39,8 @@ export declare class DependencyResolver implements ResolverCallbacks {
40
39
  * Mirrors {@link DependencyResolver.resolveAll} candidate selection only (no instantiation).
41
40
  */
42
41
  peekCandidateBindingsForValidate(token: Token<unknown> | Constructor, options: ResolveOptions | undefined): ReadonlyArray<Binding>;
43
- /**
44
- * The error `resolve` raises for a request nothing selects, or `undefined` while a `when()` candidate leaves it open.
45
- *
46
- * @remarks A predicate reads the resolution path, which a static walk does not have, so a slot-matching candidate
47
- * that carries one may still be selected when the request is really made.
48
- */
49
- missForValidate(token: Token<unknown> | Constructor, options: ResolveOptions | undefined, path: ReadonlyArray<string>): TokenNotBoundError | NoMatchingBindingError | undefined;
42
+ /** Every binding the chain holds under a token, nearest container first — for `Container.validate`. */
43
+ bindingsForValidate(token: Token<unknown> | Constructor): ReadonlyArray<Binding>;
50
44
  /** The resolver whose chain a binding this one can see resolves its dependencies from, as a singleton does. */
51
45
  ownerForValidate(binding: Binding): DependencyResolver;
52
46
  /** Deactivates a scoped instance of a binding this resolver owns, with its hooks and reader, when it owes a teardown. */
@@ -1,19 +1,18 @@
1
1
  import { bindingSlotToString, NO_INSTANCE } from "#core/binding";
2
2
  import { slotNameCriterionOf } from "#core/tag";
3
3
  import { tokenName } from "#core/token";
4
- import { AsyncActivationError, AsyncResolutionError, CircularDependencyError, DisposedContainerError, InternalError, MissingMetadataError, MissingScopeContextError, NoMatchingBindingError, TokenNotBoundError, } from "#errors";
4
+ import { AsyncActivationError, AsyncResolutionError, CircularDependencyError, DisposedContainerError, InternalError, MissingScopeContextError, NoMatchingBindingError, TokenNotBoundError, } from "#errors";
5
5
  import { loneTagBesideNameOf, resolveOptionsForSlot, singleCriterionForSlot, singleCriterionOnlyOf, } from "#injection/dependency-slot";
6
6
  import { SCOPED_MISS } from "#lifecycle/scopes";
7
7
  import { settleInOrder } from "#resolution/async-fan-out";
8
8
  import { ActivationNeedCache } from "#resolution/cache/activation-need";
9
9
  import { ClassIntrospector } from "#resolution/cache/class-introspector";
10
- import { BindingLookupCache } from "#resolution/cache/lookup";
10
+ import { BindingLookupCache, stableCollectionValuesOf } from "#resolution/cache/lookup";
11
11
  import { AsyncLevelContext, DefaultConstraintContext, DefaultResolutionContext } from "#resolution/context";
12
12
  import { branchDepthOf, buildResolutionFrame, cycleNamesOf, enterSyncPath, extendResolutionBranch, leaveSyncPath, missPathOf, ROOT_BRANCH, UNOWNED_BRANCH, } from "#resolution/path";
13
13
  import { InstantiationPlanCompiler, PLAN_RETRY } from "#resolution/plan/compiler";
14
14
  import { matchesSlot, selectAllBindings, selectBinding } from "#resolution/select/candidates";
15
15
  const EMPTY_FRAME_LIST = [];
16
- const EMPTY_PARAM_LIST = [];
17
16
  // A class with no params is constructed with no arguments, so no dependency array is built for it.
18
17
  const NO_ARGUMENTS = [];
19
18
  /** Plans compiled so far, with the `null` unplannable marks left out. */
@@ -296,23 +295,9 @@ export class DependencyResolver {
296
295
  peekCandidateBindingsForValidate(token, options) {
297
296
  return this.#candidateBindings(token, options, []);
298
297
  }
299
- /**
300
- * The error `resolve` raises for a request nothing selects, or `undefined` while a `when()` candidate leaves it open.
301
- *
302
- * @remarks A predicate reads the resolution path, which a static walk does not have, so a slot-matching candidate
303
- * that carries one may still be selected when the request is really made.
304
- */
305
- missForValidate(token, options, path) {
306
- const bound = this.#allBindingsFromChain(token);
307
- if (bound.length === 0) {
308
- return new TokenNotBoundError(tokenName(token), path);
309
- }
310
- for (const binding of bound) {
311
- if (binding.predicate !== undefined && !binding.isMany && matchesSlot(binding.slot, options)) {
312
- return undefined;
313
- }
314
- }
315
- return new NoMatchingBindingError(tokenName(token), options ?? {}, bound.map((binding) => bindingSlotToString(binding.slot)), path);
298
+ /** Every binding the chain holds under a token, nearest container first — for `Container.validate`. */
299
+ bindingsForValidate(token) {
300
+ return this.#allBindingsFromChain(token);
316
301
  }
317
302
  /** The resolver whose chain a binding this one can see resolves its dependencies from, as a singleton does. */
318
303
  ownerForValidate(binding) {
@@ -488,19 +473,8 @@ export class DependencyResolver {
488
473
  return {
489
474
  hasActivationHandlers: (binding) => this.#ownerOf(binding).#lifecycle.hasActivationHandlers(binding.token),
490
475
  knownPostConstruct: (target) => classes.knownPostConstruct(target),
491
- needsActiveContainer: (target) => classes.needsActiveContainer(target),
492
- // A plan runs at the top level, so the lent root stack is free when it is; a plan reached
493
- // with the root stack held mints its own path, exactly as the interpreted lane would.
494
- constructWithAccessors: (binding, target, deps) => {
495
- const stack = this.rootStack.length === 0 ? this.rootStack : [];
496
- enterSyncPath(stack, binding, this.#getResolutionFrame(binding));
497
- try {
498
- return classes.instantiate(target, deps, this.#ambientResolutionFor(stack));
499
- }
500
- finally {
501
- leaveSyncPath(stack, binding);
502
- }
503
- },
476
+ accessorSlots: (target) => classes.accessorSlots(target),
477
+ constructWithAccessors: (target, deps, resolution) => classes.construct(target, deps, true, resolution),
504
478
  getConstructorMetadata: (target) => classes.constructorMetadata(target),
505
479
  lookupDependencyEntry: (token) => {
506
480
  const entry = this.#lookup.defaultEntry(token);
@@ -746,34 +720,10 @@ export class DependencyResolver {
746
720
  throw new InternalError("alias should have been followed before instantiation");
747
721
  }
748
722
  }
749
- /**
750
- * The parameters a class binding injects.
751
- *
752
- * @remarks A class the metadata reader knows nothing about is constructible only if it declares
753
- * no parameters; anything else is a missing `@injectable()`.
754
- */
723
+ /** The parameters a class binding injects. */
755
724
  #constructorParams(target, facts) {
756
725
  // Metadata is fixed once a class is defined, so the answer is too; only a throw is left unsettled.
757
- return (facts.params ??= this.#settleConstructorParams(target, facts));
758
- }
759
- #settleConstructorParams(target, facts) {
760
- const meta = this.#introspector().constructorMetadataOf(target, facts);
761
- if (meta !== undefined) {
762
- return meta.params;
763
- }
764
- if (target.length === 0) {
765
- // A subclass with an implicit constructor and no own metadata inherits its base's declared
766
- // deps but would be built with zero arguments, injecting `undefined` silently — reject it.
767
- const inherited = this.#introspector().inheritedConstructorMetadata(target);
768
- if (inherited !== undefined && inherited.metadata.params.length > 0) {
769
- throw new MissingMetadataError(target.name, {
770
- baseName: inherited.base.name,
771
- dependencyCount: inherited.metadata.params.length,
772
- });
773
- }
774
- return EMPTY_PARAM_LIST;
775
- }
776
- throw new MissingMetadataError(target.name);
726
+ return (facts.params ??= this.#introspector().settleParams(target, facts));
777
727
  }
778
728
  // One dispatch table for both dependency sources — constructor params and `toResolved`
779
729
  // descriptors declare the same four things.
@@ -854,10 +804,8 @@ export class DependencyResolver {
854
804
  const resolutionStack = this.rootStack;
855
805
  const memo = this.#rootCollection(token, resolutionStack);
856
806
  if (memo.values !== undefined && memo.activationVersion === this.#chainActivationVersion()) {
857
- // A copy, never the memo itself: a caller that writes into its result must not rewrite the
858
- // next caller's. Reading a frozen array is several times slower than reading a plain one, so
859
- // the copy is the cheaper guard by far, and it costs one allocation the read already paid before the memo.
860
- return memo.values.slice();
807
+ // The memo itself: the result is typed read-only, so every caller may share one list.
808
+ return memo.values;
861
809
  }
862
810
  const { candidates } = memo;
863
811
  const resolved = new Array(candidates.length);
@@ -875,7 +823,7 @@ export class DependencyResolver {
875
823
  // Selection runs `when()` predicates and follows aliases, either of which may throw.
876
824
  const memo = this.#rootCollection(token, resolutionStack);
877
825
  if (memo.values !== undefined && memo.activationVersion === this.#chainActivationVersion()) {
878
- return Promise.resolve(memo.values.slice());
826
+ return Promise.resolve(memo.values);
879
827
  }
880
828
  return asPromise(this.#settleCandidates(memo.candidates, undefined, resolutionStack, UNOWNED_BRANCH, (values) => {
881
829
  this.#settleOnRepeat(memo);
@@ -914,24 +862,16 @@ export class DependencyResolver {
914
862
  entry.readBefore = true;
915
863
  }
916
864
  }
917
- /**
918
- * Fills a collection memo's value list once every member is stable: a hook-free constant, or a
919
- * hook-free singleton whose instance is cached — anything that changes either bumps a registry
920
- * version the memo is keyed on. A member still to be materialised leaves the list unfilled.
921
- */
865
+ /** Fills a collection memo's value list once its members are stable and no activation hook exists in the chain. */
922
866
  #settleCollectionValues(entry) {
923
867
  if (entry.values !== undefined || this.#chainActivationVersion() !== 0) {
924
868
  return;
925
869
  }
926
- const { candidates } = entry;
927
- for (let index = 0; index < candidates.length; index += 1) {
928
- if (!isStableCollectionMember(candidates[index])) {
929
- return;
930
- }
870
+ const values = stableCollectionValuesOf(entry.candidates);
871
+ if (values !== undefined) {
872
+ entry.values = values;
873
+ entry.activationVersion = 0;
931
874
  }
932
- // Kept unfrozen: a frozen array reads through a slow elements kind, and every read copies it anyway.
933
- entry.values = candidates.map(stableMemberValue);
934
- entry.activationVersion = 0;
935
875
  }
936
876
  /** Every binding in the chain a `resolveAll` request matches, in chain order. */
937
877
  #candidateBindings(token, options, resolutionStack) {
@@ -1676,22 +1616,6 @@ export class DependencyResolver {
1676
1616
  return new DefaultResolutionContext(this, resolutionStack, options);
1677
1617
  }
1678
1618
  }
1679
- /**
1680
- * Whether a binding answers a collection read with a fixed value: a hook-free constant, or a
1681
- * singleton whose instance is already cached.
1682
- *
1683
- * @remarks A cached singleton reads like a constant until a registry change evicts it, which also
1684
- * drops the memo.
1685
- */
1686
- function isStableCollectionMember(binding) {
1687
- if (binding.kind === "alias" || binding.activationHook !== undefined) {
1688
- return false;
1689
- }
1690
- return binding.kind === "constant" || (binding.scope === "singleton" && binding.instance !== NO_INSTANCE);
1691
- }
1692
- function stableMemberValue(binding) {
1693
- return binding.kind === "constant" ? binding.value : binding.instance;
1694
- }
1695
1619
  function anyPredicate(bindings) {
1696
1620
  for (let index = 0; index < bindings.length; index += 1) {
1697
1621
  if (bindings[index].predicate !== undefined) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codefast/di",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "description": "Type-safe, zero-dependency dependency injection for TypeScript, on standard decorators",
5
5
  "keywords": [
6
6
  "codefast",
@@ -54,6 +54,10 @@
54
54
  "types": "./dist/container/container.d.ts",
55
55
  "import": "./dist/container/container.js"
56
56
  },
57
+ "./container/introspect": {
58
+ "types": "./dist/container/introspect.d.ts",
59
+ "import": "./dist/container/introspect.js"
60
+ },
57
61
  "./core/binding": {
58
62
  "types": "./dist/core/binding.d.ts",
59
63
  "import": "./dist/core/binding.js"
@@ -162,6 +166,10 @@
162
166
  "types": "./dist/introspection/inspector.d.ts",
163
167
  "import": "./dist/introspection/inspector.js"
164
168
  },
169
+ "./introspection/validation": {
170
+ "types": "./dist/introspection/validation.d.ts",
171
+ "import": "./dist/introspection/validation.js"
172
+ },
165
173
  "./lifecycle/hooks": {
166
174
  "types": "./dist/lifecycle/hooks.d.ts",
167
175
  "import": "./dist/lifecycle/hooks.js"
@@ -244,6 +252,6 @@
244
252
  "access": "public"
245
253
  },
246
254
  "engines": {
247
- "node": ">=24.0.0"
255
+ "node": ">=22.18.0"
248
256
  }
249
257
  }