@codefast/di 0.3.15 → 0.3.16-canary.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 (55) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/dist/binding-scope.d.mts +2 -0
  3. package/dist/binding-scope.mjs +2 -0
  4. package/dist/binding-select.d.mts +4 -0
  5. package/dist/binding-select.mjs +4 -0
  6. package/dist/binding.d.mts +68 -1
  7. package/dist/binding.mjs +12 -0
  8. package/dist/constraints.d.mts +24 -0
  9. package/dist/constraints.mjs +24 -0
  10. package/dist/constructor-type.d.mts +4 -0
  11. package/dist/container.d.mts +9 -0
  12. package/dist/container.mjs +3 -0
  13. package/dist/decorators/inject.d.mts +24 -0
  14. package/dist/decorators/inject.mjs +15 -0
  15. package/dist/decorators/injectable.d.mts +12 -0
  16. package/dist/decorators/injectable.mjs +6 -0
  17. package/dist/decorators/lifecycle-decorators.d.mts +6 -0
  18. package/dist/decorators/lifecycle-decorators.mjs +6 -0
  19. package/dist/dependency-graph.d.mts +15 -0
  20. package/dist/dependency-graph.mjs +3 -0
  21. package/dist/environment.d.mts +15 -0
  22. package/dist/environment.mjs +12 -0
  23. package/dist/errors.d.mts +51 -0
  24. package/dist/errors.mjs +48 -0
  25. package/dist/graph-adapters/cytoscape.d.mts +12 -0
  26. package/dist/graph-adapters/cytoscape.mjs +3 -0
  27. package/dist/graph-adapters/dot.d.mts +3 -0
  28. package/dist/graph-adapters/dot.mjs +3 -0
  29. package/dist/graph-adapters/reactflow.d.mts +12 -0
  30. package/dist/graph-adapters/reactflow.mjs +3 -0
  31. package/dist/inspector.d.mts +9 -0
  32. package/dist/inspector.mjs +3 -0
  33. package/dist/lifecycle.d.mts +3 -0
  34. package/dist/lifecycle.mjs +3 -0
  35. package/dist/metadata/metadata-keys.d.mts +18 -0
  36. package/dist/metadata/metadata-keys.mjs +18 -0
  37. package/dist/metadata/metadata-reader-token.d.mts +3 -0
  38. package/dist/metadata/metadata-reader-token.mjs +3 -0
  39. package/dist/metadata/metadata-types.d.mts +17 -1
  40. package/dist/metadata/symbol-metadata-reader.d.mts +6 -0
  41. package/dist/metadata/symbol-metadata-reader.mjs +6 -0
  42. package/dist/module.d.mts +24 -0
  43. package/dist/module.mjs +12 -0
  44. package/dist/registry.d.mts +3 -0
  45. package/dist/registry.mjs +3 -0
  46. package/dist/resolve-options.d.mts +4 -0
  47. package/dist/resolve-options.mjs +4 -0
  48. package/dist/resolver.d.mts +3 -0
  49. package/dist/resolver.mjs +3 -0
  50. package/dist/scope.d.mts +3 -0
  51. package/dist/scope.mjs +3 -0
  52. package/dist/token.d.mts +12 -0
  53. package/dist/token.mjs +9 -0
  54. package/dist/types.d.mts +35 -1
  55. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # @codefast/di
2
2
 
3
+ ## 0.3.16-canary.0
4
+
3
5
  ## 0.3.15
4
6
 
5
7
  ### Patch Changes
@@ -5,6 +5,8 @@ import { Binding } from "./binding.mjs";
5
5
  /**
6
6
  * Runtime scope used for validation and introspection. Alias bindings are treated as transient
7
7
  * because they defer scope to the aliased target at resolve time.
8
+ *
9
+ * @since 0.3.16-canary.0
8
10
  */
9
11
  declare function effectiveBindingScope(binding: Binding): BindingScope;
10
12
  //#endregion
@@ -2,6 +2,8 @@
2
2
  /**
3
3
  * Runtime scope used for validation and introspection. Alias bindings are treated as transient
4
4
  * because they defer scope to the aliased target at resolve time.
5
+ *
6
+ * @since 0.3.16-canary.0
5
7
  */
6
8
  function effectiveBindingScope(binding) {
7
9
  switch (binding.kind) {
@@ -5,10 +5,14 @@ import { Binding } from "./binding.mjs";
5
5
  /**
6
6
  * Select a single candidate from a list of bindings using slot matching + predicates.
7
7
  * Returns undefined if no match, throws AmbiguousBindingError if multiple match.
8
+ *
9
+ * @since 0.3.16-canary.0
8
10
  */
9
11
  declare function selectBinding(bindings: readonly Binding[], hint: ResolveOptions | undefined, ctx: ConstraintContext, tName: string): Binding | undefined;
10
12
  /**
11
13
  * Select all candidates matching hint + predicates.
14
+ *
15
+ * @since 0.3.16-canary.0
12
16
  */
13
17
  declare function selectAllBindings(bindings: readonly Binding[], hint: ResolveOptions | undefined, ctx: ConstraintContext): Binding[];
14
18
  //#endregion
@@ -3,6 +3,8 @@ import { AmbiguousBindingError } from "./errors.mjs";
3
3
  /**
4
4
  * Select a single candidate from a list of bindings using slot matching + predicates.
5
5
  * Returns undefined if no match, throws AmbiguousBindingError if multiple match.
6
+ *
7
+ * @since 0.3.16-canary.0
6
8
  */
7
9
  function selectBinding(bindings, hint, ctx, tName) {
8
10
  const candidates = filterBindings(bindings, hint, ctx);
@@ -12,6 +14,8 @@ function selectBinding(bindings, hint, ctx, tName) {
12
14
  }
13
15
  /**
14
16
  * Select all candidates matching hint + predicates.
17
+ *
18
+ * @since 0.3.16-canary.0
15
19
  */
16
20
  function selectAllBindings(bindings, hint, ctx) {
17
21
  return filterBindings(bindings, hint, ctx, "all");
@@ -4,12 +4,24 @@ import { ActivationHandler, BindingIdentifier, BindingScope, ConstraintContext,
4
4
  import { InjectionDescriptor } from "./decorators/inject.mjs";
5
5
 
6
6
  //#region src/binding.d.ts
7
+ /**
8
+ * @since 0.3.16-canary.0
9
+ */
7
10
  interface SlotKey {
8
11
  readonly name: string | undefined;
9
12
  readonly tags: ReadonlyArray<readonly [tag: string, value: unknown]>;
10
13
  }
14
+ /**
15
+ * @since 0.3.16-canary.0
16
+ */
11
17
  declare function slotKeyEquals(a: SlotKey, b: SlotKey): boolean;
18
+ /**
19
+ * @since 0.3.16-canary.0
20
+ */
12
21
  declare const DEFAULT_SLOT: SlotKey;
22
+ /**
23
+ * @since 0.3.16-canary.0
24
+ */
13
25
  declare function slotKeyToString(slot: SlotKey): string;
14
26
  interface BindingBase<Value> {
15
27
  readonly id: BindingIdentifier;
@@ -17,6 +29,9 @@ interface BindingBase<Value> {
17
29
  readonly slot: SlotKey;
18
30
  readonly predicate?: (ctx: ConstraintContext) => boolean;
19
31
  }
32
+ /**
33
+ * @since 0.3.16-canary.0
34
+ */
20
35
  interface ClassBinding<Value> extends BindingBase<Value> {
21
36
  readonly kind: "class";
22
37
  readonly target: Constructor<Value>;
@@ -24,6 +39,9 @@ interface ClassBinding<Value> extends BindingBase<Value> {
24
39
  readonly onActivation?: ActivationHandler<Value>;
25
40
  readonly onDeactivation?: DeactivationHandler<Value>;
26
41
  }
42
+ /**
43
+ * @since 0.3.16-canary.0
44
+ */
27
45
  interface DynamicBinding<Value> extends BindingBase<Value> {
28
46
  readonly kind: "dynamic";
29
47
  readonly factory: (ctx: ResolutionContext) => Value;
@@ -31,6 +49,9 @@ interface DynamicBinding<Value> extends BindingBase<Value> {
31
49
  readonly onActivation?: ActivationHandler<Value>;
32
50
  readonly onDeactivation?: DeactivationHandler<Value>;
33
51
  }
52
+ /**
53
+ * @since 0.3.16-canary.0
54
+ */
34
55
  interface DynamicAsyncBinding<Value> extends BindingBase<Value> {
35
56
  readonly kind: "dynamic-async";
36
57
  readonly factory: (ctx: ResolutionContext) => Promise<Value>;
@@ -38,6 +59,9 @@ interface DynamicAsyncBinding<Value> extends BindingBase<Value> {
38
59
  readonly onActivation?: ActivationHandler<Value>;
39
60
  readonly onDeactivation?: DeactivationHandler<Value>;
40
61
  }
62
+ /**
63
+ * @since 0.3.16-canary.0
64
+ */
41
65
  interface ResolvedBinding<Value> extends BindingBase<Value> {
42
66
  readonly kind: "resolved";
43
67
  readonly factory: (...args: unknown[]) => Value;
@@ -46,6 +70,9 @@ interface ResolvedBinding<Value> extends BindingBase<Value> {
46
70
  readonly onActivation?: ActivationHandler<Value>;
47
71
  readonly onDeactivation?: DeactivationHandler<Value>;
48
72
  }
73
+ /**
74
+ * @since 0.3.16-canary.0
75
+ */
49
76
  interface ResolvedAsyncBinding<Value> extends BindingBase<Value> {
50
77
  readonly kind: "resolved-async";
51
78
  readonly factory: (...args: unknown[]) => Promise<Value>;
@@ -54,6 +81,9 @@ interface ResolvedAsyncBinding<Value> extends BindingBase<Value> {
54
81
  readonly onActivation?: ActivationHandler<Value>;
55
82
  readonly onDeactivation?: DeactivationHandler<Value>;
56
83
  }
84
+ /**
85
+ * @since 0.3.16-canary.0
86
+ */
57
87
  interface ConstantBinding<Value> extends BindingBase<Value> {
58
88
  readonly kind: "constant";
59
89
  readonly value: Value;
@@ -61,14 +91,30 @@ interface ConstantBinding<Value> extends BindingBase<Value> {
61
91
  readonly onActivation?: ActivationHandler<Value>;
62
92
  readonly onDeactivation?: DeactivationHandler<Value>;
63
93
  }
94
+ /**
95
+ * @since 0.3.16-canary.0
96
+ */
64
97
  interface AliasBinding<Value> extends BindingBase<Value> {
65
98
  readonly kind: "alias";
66
99
  readonly target: Token<Value> | Constructor<Value>;
67
100
  }
101
+ /**
102
+ * @since 0.3.16-canary.0
103
+ */
68
104
  type Binding<Value = unknown> = ClassBinding<Value> | DynamicBinding<Value> | DynamicAsyncBinding<Value> | ResolvedBinding<Value> | ResolvedAsyncBinding<Value> | ConstantBinding<Value> | AliasBinding<Value>;
69
- /** Builder-only payload before `id`, `token`, `slot`, and `predicate` are applied. */
105
+ /**
106
+ * Builder-only payload before `id`, `token`, `slot`, and `predicate` are applied.
107
+ *
108
+ * @since 0.3.16-canary.0
109
+ */
70
110
  type PartialBinding<Value> = Omit<ClassBinding<Value>, "id" | "token" | "slot" | "predicate"> | Omit<DynamicBinding<Value>, "id" | "token" | "slot" | "predicate"> | Omit<DynamicAsyncBinding<Value>, "id" | "token" | "slot" | "predicate"> | Omit<ResolvedBinding<Value>, "id" | "token" | "slot" | "predicate"> | Omit<ResolvedAsyncBinding<Value>, "id" | "token" | "slot" | "predicate"> | Omit<ConstantBinding<Value>, "id" | "token" | "slot" | "predicate"> | Omit<AliasBinding<Value>, "id" | "token" | "slot" | "predicate">;
111
+ /**
112
+ * @since 0.3.16-canary.0
113
+ */
71
114
  declare function generateBindingId(): BindingIdentifier;
115
+ /**
116
+ * @since 0.3.16-canary.0
117
+ */
72
118
  interface BindToBuilder<Value> {
73
119
  to(type: Constructor<Value>): BindingBuilder<Value>;
74
120
  toSelf(): BindingBuilder<Value>;
@@ -79,6 +125,9 @@ interface BindToBuilder<Value> {
79
125
  toResolvedAsync<const Deps extends readonly DependencyKey[]>(factory: (...args: { [K in keyof Deps]: TokenValue<NoInfer<Deps>[K]> }) => Promise<Value>, deps: Deps): BindingBuilder<Value>;
80
126
  toAlias(target: Token<Value> | Constructor<Value>): AliasBindingBuilder;
81
127
  }
128
+ /**
129
+ * @since 0.3.16-canary.0
130
+ */
82
131
  interface BindingBuilder<Value> {
83
132
  when(predicate: (ctx: ConstraintContext) => boolean): this;
84
133
  whenNamed(name: string): this;
@@ -89,6 +138,9 @@ interface BindingBuilder<Value> {
89
138
  scoped(): ScopedBindingBuilder<Value>;
90
139
  id(): BindingIdentifier;
91
140
  }
141
+ /**
142
+ * @since 0.3.16-canary.0
143
+ */
92
144
  interface ConstantBindingBuilder<Value> {
93
145
  when(predicate: (ctx: ConstraintContext) => boolean): this;
94
146
  whenNamed(name: string): this;
@@ -98,6 +150,9 @@ interface ConstantBindingBuilder<Value> {
98
150
  onDeactivation(fn: DeactivationHandler<Value>): SingletonLifecycleBuilder<Value>;
99
151
  id(): BindingIdentifier;
100
152
  }
153
+ /**
154
+ * @since 0.3.16-canary.0
155
+ */
101
156
  interface AliasBindingBuilder {
102
157
  when(predicate: (ctx: ConstraintContext) => boolean): this;
103
158
  whenNamed(name: string): this;
@@ -105,16 +160,28 @@ interface AliasBindingBuilder {
105
160
  whenDefault(): this;
106
161
  id(): BindingIdentifier;
107
162
  }
163
+ /**
164
+ * @since 0.3.16-canary.0
165
+ */
108
166
  interface SingletonBindingBuilder<Value> {
109
167
  onActivation(fn: ActivationHandler<Value>): this;
110
168
  onDeactivation(fn: DeactivationHandler<Value>): this;
111
169
  id(): BindingIdentifier;
112
170
  }
171
+ /**
172
+ * @since 0.3.16-canary.0
173
+ */
113
174
  interface TransientBindingBuilder<Value> {
114
175
  onActivation(fn: ActivationHandler<Value>): this;
115
176
  id(): BindingIdentifier;
116
177
  }
178
+ /**
179
+ * @since 0.3.16-canary.0
180
+ */
117
181
  interface ScopedBindingBuilder<Value> extends TransientBindingBuilder<Value> {}
182
+ /**
183
+ * @since 0.3.16-canary.0
184
+ */
118
185
  interface SingletonLifecycleBuilder<Value> {
119
186
  onActivation(fn: ActivationHandler<Value>): this;
120
187
  onDeactivation(fn: DeactivationHandler<Value>): this;
package/dist/binding.mjs CHANGED
@@ -1,14 +1,23 @@
1
1
  //#region src/binding.ts
2
+ /**
3
+ * @since 0.3.16-canary.0
4
+ */
2
5
  function slotKeyEquals(a, b) {
3
6
  if (a.name !== b.name) return false;
4
7
  if (a.tags.length !== b.tags.length) return false;
5
8
  for (const [tagKey, tagValue] of a.tags) if (!b.tags.some(([k, v]) => k === tagKey && Object.is(v, tagValue))) return false;
6
9
  return true;
7
10
  }
11
+ /**
12
+ * @since 0.3.16-canary.0
13
+ */
8
14
  const DEFAULT_SLOT = {
9
15
  name: void 0,
10
16
  tags: []
11
17
  };
18
+ /**
19
+ * @since 0.3.16-canary.0
20
+ */
12
21
  function slotKeyToString(slot) {
13
22
  if (slot.name === void 0 && slot.tags.length === 0) return "default";
14
23
  const parts = [];
@@ -17,6 +26,9 @@ function slotKeyToString(slot) {
17
26
  return parts.join(",");
18
27
  }
19
28
  let _idCounter = 0;
29
+ /**
30
+ * @since 0.3.16-canary.0
31
+ */
20
32
  function generateBindingId() {
21
33
  return String(++_idCounter);
22
34
  }
@@ -3,13 +3,37 @@ import { Token } from "./token.mjs";
3
3
  import { ConstraintContext } from "./types.mjs";
4
4
 
5
5
  //#region src/constraints.d.ts
6
+ /**
7
+ * @since 0.3.16-canary.0
8
+ */
6
9
  declare function whenParentIs(t: Token<unknown> | Constructor): (ctx: ConstraintContext) => boolean;
10
+ /**
11
+ * @since 0.3.16-canary.0
12
+ */
7
13
  declare function whenNoParentIs(t: Token<unknown> | Constructor): (ctx: ConstraintContext) => boolean;
14
+ /**
15
+ * @since 0.3.16-canary.0
16
+ */
8
17
  declare function whenAnyAncestorIs(t: Token<unknown> | Constructor): (ctx: ConstraintContext) => boolean;
18
+ /**
19
+ * @since 0.3.16-canary.0
20
+ */
9
21
  declare function whenNoAncestorIs(t: Token<unknown> | Constructor): (ctx: ConstraintContext) => boolean;
22
+ /**
23
+ * @since 0.3.16-canary.0
24
+ */
10
25
  declare function whenParentNamed(name: string): (ctx: ConstraintContext) => boolean;
26
+ /**
27
+ * @since 0.3.16-canary.0
28
+ */
11
29
  declare function whenAnyAncestorNamed(name: string): (ctx: ConstraintContext) => boolean;
30
+ /**
31
+ * @since 0.3.16-canary.0
32
+ */
12
33
  declare function whenParentTagged(tag: string, value: unknown): (ctx: ConstraintContext) => boolean;
34
+ /**
35
+ * @since 0.3.16-canary.0
36
+ */
13
37
  declare function whenAnyAncestorTagged(tag: string, value: unknown): (ctx: ConstraintContext) => boolean;
14
38
  //#endregion
15
39
  export { whenAnyAncestorIs, whenAnyAncestorNamed, whenAnyAncestorTagged, whenNoAncestorIs, whenNoParentIs, whenParentIs, whenParentNamed, whenParentTagged };
@@ -3,31 +3,55 @@ import { tokenName } from "./token.mjs";
3
3
  function tokenNameOf(t) {
4
4
  return tokenName(t);
5
5
  }
6
+ /**
7
+ * @since 0.3.16-canary.0
8
+ */
6
9
  function whenParentIs(t) {
7
10
  const name = tokenNameOf(t);
8
11
  return (ctx) => ctx.parent !== void 0 && ctx.parent.tokenName === name;
9
12
  }
13
+ /**
14
+ * @since 0.3.16-canary.0
15
+ */
10
16
  function whenNoParentIs(t) {
11
17
  const name = tokenNameOf(t);
12
18
  return (ctx) => ctx.parent === void 0 || ctx.parent.tokenName !== name;
13
19
  }
20
+ /**
21
+ * @since 0.3.16-canary.0
22
+ */
14
23
  function whenAnyAncestorIs(t) {
15
24
  const name = tokenNameOf(t);
16
25
  return (ctx) => ctx.ancestors.some((f) => f.tokenName === name);
17
26
  }
27
+ /**
28
+ * @since 0.3.16-canary.0
29
+ */
18
30
  function whenNoAncestorIs(t) {
19
31
  const name = tokenNameOf(t);
20
32
  return (ctx) => ctx.ancestors.every((f) => f.tokenName !== name);
21
33
  }
34
+ /**
35
+ * @since 0.3.16-canary.0
36
+ */
22
37
  function whenParentNamed(name) {
23
38
  return (ctx) => ctx.parent !== void 0 && ctx.parent.slot.name === name;
24
39
  }
40
+ /**
41
+ * @since 0.3.16-canary.0
42
+ */
25
43
  function whenAnyAncestorNamed(name) {
26
44
  return (ctx) => ctx.ancestors.some((f) => f.slot.name === name);
27
45
  }
46
+ /**
47
+ * @since 0.3.16-canary.0
48
+ */
28
49
  function whenParentTagged(tag, value) {
29
50
  return (ctx) => ctx.parent !== void 0 && ctx.parent.slot.tags.some(([t, v]) => t === tag && Object.is(v, value));
30
51
  }
52
+ /**
53
+ * @since 0.3.16-canary.0
54
+ */
31
55
  function whenAnyAncestorTagged(tag, value) {
32
56
  return (ctx) => ctx.ancestors.some((f) => f.slot.tags.some(([t, v]) => t === tag && Object.is(v, value)));
33
57
  }
@@ -5,12 +5,16 @@
5
5
  * `strictFunctionTypes` (unlike `unknown[]`, which is not assignable from
6
6
  * narrower parameter types). Runtime construction still uses the real shape;
7
7
  * this alias is the DI “class token” surface only.
8
+ *
9
+ * @since 0.3.16-canary.0
8
10
  */
9
11
  type Constructor<Value = unknown> = new (...args: never[]) => Value;
10
12
  /**
11
13
  * Class constructor as invoked by the resolver after metadata-driven
12
14
  * resolution of `unknown[]` dependencies — separate from {@link Constructor},
13
15
  * which is the public assignable class token.
16
+ *
17
+ * @since 0.3.16-canary.0
14
18
  */
15
19
  type ConstructorInvocation = new (...args: unknown[]) => unknown;
16
20
  //#endregion
@@ -8,6 +8,9 @@ import { ContainerGraphJson, GraphOptions } from "./dependency-graph.mjs";
8
8
  import { AutoRegisterRegistry } from "./decorators/injectable.mjs";
9
9
 
10
10
  //#region src/container.d.ts
11
+ /**
12
+ * @since 0.3.16-canary.0
13
+ */
11
14
  interface Container {
12
15
  readonly isDisposed: boolean;
13
16
  bind<const Value>(token: Token<Value> | Constructor<Value>): BindToBuilder<Value>;
@@ -41,11 +44,17 @@ interface Container {
41
44
  inspect(): ContainerSnapshot;
42
45
  generateDependencyGraph(options?: GraphOptions): ContainerGraphJson;
43
46
  }
47
+ /**
48
+ * @since 0.3.16-canary.0
49
+ */
44
50
  interface ContainerStatic {
45
51
  create(): Container;
46
52
  fromModules(...modules: SyncModule[]): Container;
47
53
  fromModulesAsync(...modules: Array<SyncModule | AsyncModule>): Promise<Container>;
48
54
  }
55
+ /**
56
+ * @since 0.3.16-canary.0
57
+ */
49
58
  declare const Container: ContainerStatic & {
50
59
  create(): Container;
51
60
  };
@@ -706,6 +706,9 @@ var AliasBindingBuilderImpl = class {
706
706
  return this._committed;
707
707
  }
708
708
  };
709
+ /**
710
+ * @since 0.3.16-canary.0
711
+ */
709
712
  const Container = {
710
713
  create() {
711
714
  return new DefaultContainer();
@@ -2,10 +2,16 @@ import { Constructor } from "../constructor-type.mjs";
2
2
  import { Token } from "../token.mjs";
3
3
 
4
4
  //#region src/decorators/inject.d.ts
5
+ /**
6
+ * @since 0.3.16-canary.0
7
+ */
5
8
  interface InjectOptions {
6
9
  name?: string;
7
10
  tags?: ReadonlyArray<readonly [tag: string, value: unknown]>;
8
11
  }
12
+ /**
13
+ * @since 0.3.16-canary.0
14
+ */
9
15
  interface InjectionDescriptor<Value = unknown> {
10
16
  readonly token: Token<Value> | Constructor<Value>;
11
17
  readonly optional: boolean;
@@ -13,12 +19,30 @@ interface InjectionDescriptor<Value = unknown> {
13
19
  readonly name?: string;
14
20
  readonly tags?: ReadonlyArray<readonly [string, unknown]>;
15
21
  }
22
+ /**
23
+ * @since 0.3.16-canary.0
24
+ */
16
25
  type InjectableDependency<Value = unknown> = Token<Value> | Constructor<Value> | InjectionDescriptor<Value>;
26
+ /**
27
+ * @since 0.3.16-canary.0
28
+ */
17
29
  declare function isInjectionDescriptor(value: unknown): value is InjectionDescriptor;
30
+ /**
31
+ * @since 0.3.16-canary.0
32
+ */
18
33
  declare function normalizeToDescriptor(dep: InjectableDependency): InjectionDescriptor;
19
34
  type ClassAccessorDecorator<This, Value> = (target: ClassAccessorDecoratorTarget<This, Value>, context: ClassAccessorDecoratorContext<This, Value>) => ClassAccessorDecoratorResult<This, Value> | void;
35
+ /**
36
+ * @since 0.3.16-canary.0
37
+ */
20
38
  declare function inject<const Value>(t: Token<Value> | Constructor<Value>, options?: InjectOptions): InjectionDescriptor<Value> & ClassAccessorDecorator<unknown, Value>;
39
+ /**
40
+ * @since 0.3.16-canary.0
41
+ */
21
42
  declare function optional<const Value>(t: Token<Value> | Constructor<Value>, options?: InjectOptions): InjectionDescriptor<Value | undefined>;
43
+ /**
44
+ * @since 0.3.16-canary.0
45
+ */
22
46
  declare function injectAll<const Value>(t: Token<Value> | Constructor<Value>, options?: InjectOptions): InjectionDescriptor<Value[]>;
23
47
  //#endregion
24
48
  export { InjectOptions, InjectableDependency, InjectionDescriptor, inject, injectAll, isInjectionDescriptor, normalizeToDescriptor, optional };
@@ -3,12 +3,18 @@ import { getActiveContainer } from "../environment.mjs";
3
3
  import { injectableSlotToResolveOptions } from "../resolve-options.mjs";
4
4
  import { INJECT_ACCESSOR_KEY } from "../metadata/metadata-keys.mjs";
5
5
  //#region src/decorators/inject.ts
6
+ /**
7
+ * @since 0.3.16-canary.0
8
+ */
6
9
  function isInjectionDescriptor(value) {
7
10
  if (value === null || value === void 0) return false;
8
11
  const type = typeof value;
9
12
  if (type !== "object" && type !== "function") return false;
10
13
  return "token" in value && "optional" in value && "multi" in value && typeof value.optional === "boolean" && typeof value.multi === "boolean";
11
14
  }
15
+ /**
16
+ * @since 0.3.16-canary.0
17
+ */
12
18
  function normalizeToDescriptor(dep) {
13
19
  if (isInjectionDescriptor(dep)) return materializeInjectionDescriptor(dep);
14
20
  return {
@@ -69,6 +75,9 @@ function buildInjectionDescriptor(t, options) {
69
75
  };
70
76
  return base;
71
77
  }
78
+ /**
79
+ * @since 0.3.16-canary.0
80
+ */
72
81
  function inject(t, options) {
73
82
  const descriptor = buildInjectionDescriptor(t, options);
74
83
  const decoratorFn = (_target, context) => {
@@ -100,6 +109,9 @@ function inject(t, options) {
100
109
  Object.defineProperties(decoratorFn, props);
101
110
  return decoratorFn;
102
111
  }
112
+ /**
113
+ * @since 0.3.16-canary.0
114
+ */
103
115
  function optional(t, options) {
104
116
  const base = {
105
117
  token: t,
@@ -121,6 +133,9 @@ function optional(t, options) {
121
133
  };
122
134
  return base;
123
135
  }
136
+ /**
137
+ * @since 0.3.16-canary.0
138
+ */
124
139
  function injectAll(t, options) {
125
140
  const base = {
126
141
  token: t,
@@ -3,6 +3,9 @@ import { BindingScope } from "../types.mjs";
3
3
  import { InjectableDependency } from "./inject.mjs";
4
4
 
5
5
  //#region src/decorators/injectable.d.ts
6
+ /**
7
+ * @since 0.3.16-canary.0
8
+ */
6
9
  interface AutoRegisterRegistry {
7
10
  register(target: Constructor, scope: BindingScope): void;
8
11
  entries(): ReadonlyArray<{
@@ -10,11 +13,20 @@ interface AutoRegisterRegistry {
10
13
  scope: BindingScope;
11
14
  }>;
12
15
  }
16
+ /**
17
+ * @since 0.3.16-canary.0
18
+ */
13
19
  declare function createAutoRegisterRegistry(): AutoRegisterRegistry;
20
+ /**
21
+ * @since 0.3.16-canary.0
22
+ */
14
23
  interface InjectableOptions {
15
24
  autoRegister?: AutoRegisterRegistry;
16
25
  scope?: BindingScope;
17
26
  }
27
+ /**
28
+ * @since 0.3.16-canary.0
29
+ */
18
30
  declare function injectable(deps?: readonly InjectableDependency[], options?: InjectableOptions): (target: unknown, context: ClassDecoratorContext) => void;
19
31
  //#endregion
20
32
  export { AutoRegisterRegistry, type InjectableDependency, InjectableOptions, createAutoRegisterRegistry, injectable };
@@ -1,6 +1,9 @@
1
1
  import { INJECTABLE_KEY, constructorMetadataMap } from "../metadata/metadata-keys.mjs";
2
2
  import { normalizeToDescriptor } from "./inject.mjs";
3
3
  //#region src/decorators/injectable.ts
4
+ /**
5
+ * @since 0.3.16-canary.0
6
+ */
4
7
  function createAutoRegisterRegistry() {
5
8
  const _entries = [];
6
9
  return {
@@ -15,6 +18,9 @@ function createAutoRegisterRegistry() {
15
18
  }
16
19
  };
17
20
  }
21
+ /**
22
+ * @since 0.3.16-canary.0
23
+ */
18
24
  function injectable(deps, options) {
19
25
  return function(target, context) {
20
26
  const constructorMeta = { params: (deps ?? []).map((dep, index) => {
@@ -1,5 +1,11 @@
1
1
  //#region src/decorators/lifecycle-decorators.d.ts
2
+ /**
3
+ * @since 0.3.16-canary.0
4
+ */
2
5
  declare function postConstruct(): (target: unknown, context: ClassMethodDecoratorContext) => void;
6
+ /**
7
+ * @since 0.3.16-canary.0
8
+ */
3
9
  declare function preDestroy(): (target: unknown, context: ClassMethodDecoratorContext) => void;
4
10
  //#endregion
5
11
  export { postConstruct, preDestroy };
@@ -20,6 +20,9 @@ function registerByConstructor(target, phase, methodName) {
20
20
  preDestroy: phase === "preDestroy" ? [methodName] : []
21
21
  });
22
22
  }
23
+ /**
24
+ * @since 0.3.16-canary.0
25
+ */
23
26
  function postConstruct() {
24
27
  return function(target, context) {
25
28
  const methodName = String(context.name);
@@ -53,6 +56,9 @@ function postConstruct() {
53
56
  } catch {}
54
57
  };
55
58
  }
59
+ /**
60
+ * @since 0.3.16-canary.0
61
+ */
56
62
  function preDestroy() {
57
63
  return function(target, context) {
58
64
  const methodName = String(context.name);
@@ -3,6 +3,9 @@ import { BindingRegistry } from "./registry.mjs";
3
3
  import { MetadataReader } from "./metadata/metadata-types.mjs";
4
4
 
5
5
  //#region src/dependency-graph.d.ts
6
+ /**
7
+ * @since 0.3.16-canary.0
8
+ */
6
9
  interface GraphNode {
7
10
  readonly id: string;
8
11
  readonly tokenName: string;
@@ -10,19 +13,31 @@ interface GraphNode {
10
13
  readonly scope: BindingScope;
11
14
  readonly fromParent: boolean;
12
15
  }
16
+ /**
17
+ * @since 0.3.16-canary.0
18
+ */
13
19
  interface GraphEdge {
14
20
  readonly from: string;
15
21
  readonly to: string;
16
22
  readonly label?: string;
17
23
  }
24
+ /**
25
+ * @since 0.3.16-canary.0
26
+ */
18
27
  interface ContainerGraphJson {
19
28
  readonly nodes: readonly GraphNode[];
20
29
  readonly edges: readonly GraphEdge[];
21
30
  readonly includesParent: boolean;
22
31
  }
32
+ /**
33
+ * @since 0.3.16-canary.0
34
+ */
23
35
  interface GraphOptions {
24
36
  readonly includeParent?: boolean;
25
37
  }
38
+ /**
39
+ * @since 0.3.16-canary.0
40
+ */
26
41
  declare function buildDependencyGraph(registry: BindingRegistry, metadataReader: MetadataReader, options: GraphOptions | undefined, parentRegistry?: BindingRegistry): ContainerGraphJson;
27
42
  //#endregion
28
43
  export { ContainerGraphJson, GraphEdge, GraphNode, GraphOptions, buildDependencyGraph };
@@ -1,6 +1,9 @@
1
1
  import { effectiveBindingScope } from "./binding-scope.mjs";
2
2
  import { tokenName } from "./token.mjs";
3
3
  //#region src/dependency-graph.ts
4
+ /**
5
+ * @since 0.3.16-canary.0
6
+ */
4
7
  function buildDependencyGraph(registry, metadataReader, options, parentRegistry) {
5
8
  const nodes = [];
6
9
  const edges = [];