@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
@@ -1,5 +1,8 @@
1
1
  import { INJECTABLE_KEY, INJECT_ACCESSOR_KEY, LIFECYCLE_KEY, constructorMetadataMap, lifecycleByConstructorMetadataMap, lifecycleMetadataMap } from "./metadata-keys.mjs";
2
2
  //#region src/metadata/symbol-metadata-reader.ts
3
+ /**
4
+ * @since 0.3.16-canary.0
5
+ */
3
6
  var SymbolMetadataReader = class {
4
7
  getConstructorMetadata(target) {
5
8
  const fromWeakMap = constructorMetadataMap.get(target);
@@ -33,6 +36,9 @@ var SymbolMetadataReader = class {
33
36
  return meta[INJECT_ACCESSOR_KEY];
34
37
  }
35
38
  };
39
+ /**
40
+ * @since 0.3.16-canary.0
41
+ */
36
42
  const defaultMetadataReader = new SymbolMetadataReader();
37
43
  //#endregion
38
44
  export { SymbolMetadataReader, defaultMetadataReader };
package/dist/module.d.mts CHANGED
@@ -5,34 +5,58 @@ import { BindToBuilder } from "./binding.mjs";
5
5
  //#region src/module.d.ts
6
6
  declare const SYNC_MODULE_BRAND: unique symbol;
7
7
  declare const ASYNC_MODULE_BRAND: unique symbol;
8
+ /**
9
+ * @since 0.3.16-canary.0
10
+ */
8
11
  interface SyncModule {
9
12
  readonly name: string;
10
13
  readonly [SYNC_MODULE_BRAND]: true;
11
14
  readonly _setup: (builder: ModuleBuilder) => void;
12
15
  }
16
+ /**
17
+ * @since 0.3.16-canary.0
18
+ */
13
19
  interface AsyncModule {
14
20
  readonly name: string;
15
21
  readonly [ASYNC_MODULE_BRAND]: true;
16
22
  readonly _setup: (builder: AsyncModuleBuilder) => Promise<void>;
17
23
  }
24
+ /**
25
+ * @since 0.3.16-canary.0
26
+ */
18
27
  interface ModuleBuilder {
19
28
  bind<const Value>(token: Token<Value> | Constructor<Value>): BindToBuilder<Value>;
20
29
  import(...modules: SyncModule[]): void;
21
30
  }
31
+ /**
32
+ * @since 0.3.16-canary.0
33
+ */
22
34
  interface AsyncModuleBuilder {
23
35
  bind<const Value>(token: Token<Value> | Constructor<Value>): BindToBuilder<Value>;
24
36
  import(...modules: Array<SyncModule | AsyncModule>): void;
25
37
  }
38
+ /**
39
+ * @since 0.3.16-canary.0
40
+ */
26
41
  declare const SyncModule: {
27
42
  create(name: string, setup: (builder: ModuleBuilder) => void): SyncModule;
28
43
  };
44
+ /**
45
+ * @since 0.3.16-canary.0
46
+ */
29
47
  declare const AsyncModule: {
30
48
  create(name: string, setup: (builder: AsyncModuleBuilder) => Promise<void>): AsyncModule;
31
49
  };
50
+ /**
51
+ * @since 0.3.16-canary.0
52
+ */
32
53
  declare const Module: {
33
54
  create(name: string, setup: (builder: ModuleBuilder) => void): SyncModule;
34
55
  createAsync(name: string, setup: (builder: AsyncModuleBuilder) => Promise<void>): AsyncModule;
35
56
  };
57
+ /**
58
+ * @since 0.3.16-canary.0
59
+ */
36
60
  declare function isSyncModule(m: SyncModule | AsyncModule): m is SyncModule;
37
61
  //#endregion
38
62
  export { AsyncModule, AsyncModuleBuilder, Module, ModuleBuilder, SyncModule, isSyncModule };
package/dist/module.mjs CHANGED
@@ -1,6 +1,9 @@
1
1
  //#region src/module.ts
2
2
  const SYNC_MODULE_BRAND = Symbol("di:sync-module");
3
3
  const ASYNC_MODULE_BRAND = Symbol("di:async-module");
4
+ /**
5
+ * @since 0.3.16-canary.0
6
+ */
4
7
  const SyncModule = { create(name, setup) {
5
8
  return {
6
9
  name,
@@ -8,6 +11,9 @@ const SyncModule = { create(name, setup) {
8
11
  _setup: setup
9
12
  };
10
13
  } };
14
+ /**
15
+ * @since 0.3.16-canary.0
16
+ */
11
17
  const AsyncModule = { create(name, setup) {
12
18
  return {
13
19
  name,
@@ -15,6 +21,9 @@ const AsyncModule = { create(name, setup) {
15
21
  _setup: setup
16
22
  };
17
23
  } };
24
+ /**
25
+ * @since 0.3.16-canary.0
26
+ */
18
27
  const Module = {
19
28
  create(name, setup) {
20
29
  return SyncModule.create(name, setup);
@@ -23,6 +32,9 @@ const Module = {
23
32
  return AsyncModule.create(name, setup);
24
33
  }
25
34
  };
35
+ /**
36
+ * @since 0.3.16-canary.0
37
+ */
26
38
  function isSyncModule(m) {
27
39
  return m[SYNC_MODULE_BRAND] === true;
28
40
  }
@@ -4,6 +4,9 @@ import { BindingIdentifier } from "./types.mjs";
4
4
  import { Binding } from "./binding.mjs";
5
5
 
6
6
  //#region src/registry.d.ts
7
+ /**
8
+ * @since 0.3.16-canary.0
9
+ */
7
10
  declare class BindingRegistry {
8
11
  private readonly _bindings;
9
12
  private readonly _byId;
package/dist/registry.mjs CHANGED
@@ -1,5 +1,8 @@
1
1
  import { slotKeyEquals } from "./binding.mjs";
2
2
  //#region src/registry.ts
3
+ /**
4
+ * @since 0.3.16-canary.0
5
+ */
3
6
  var BindingRegistry = class {
4
7
  _bindings = /* @__PURE__ */ new Map();
5
8
  _byId = /* @__PURE__ */ new Map();
@@ -5,6 +5,8 @@ import { SlotKey } from "./binding.mjs";
5
5
  /**
6
6
  * Builds a {@link ResolveOptions} safe for `exactOptionalPropertyTypes`:
7
7
  * omits keys instead of assigning `undefined`.
8
+ *
9
+ * @since 0.3.16-canary.0
8
10
  */
9
11
  declare function injectableSlotToResolveOptions(slot: {
10
12
  readonly name?: string;
@@ -12,6 +14,8 @@ declare function injectableSlotToResolveOptions(slot: {
12
14
  }): ResolveOptions | undefined;
13
15
  /**
14
16
  * Hint from a binding {@link SlotKey} (tags may be empty; omits when nothing to match).
17
+ *
18
+ * @since 0.3.16-canary.0
15
19
  */
16
20
  declare function slotKeyToResolveOptions(slot: SlotKey): ResolveOptions | undefined;
17
21
  //#endregion
@@ -2,6 +2,8 @@
2
2
  /**
3
3
  * Builds a {@link ResolveOptions} safe for `exactOptionalPropertyTypes`:
4
4
  * omits keys instead of assigning `undefined`.
5
+ *
6
+ * @since 0.3.16-canary.0
5
7
  */
6
8
  function injectableSlotToResolveOptions(slot) {
7
9
  const options = {};
@@ -11,6 +13,8 @@ function injectableSlotToResolveOptions(slot) {
11
13
  }
12
14
  /**
13
15
  * Hint from a binding {@link SlotKey} (tags may be empty; omits when nothing to match).
16
+ *
17
+ * @since 0.3.16-canary.0
14
18
  */
15
19
  function slotKeyToResolveOptions(slot) {
16
20
  const options = {};
@@ -8,6 +8,9 @@ import { Container } from "./container.mjs";
8
8
  import { LifecycleManager } from "./lifecycle.mjs";
9
9
 
10
10
  //#region src/resolver.d.ts
11
+ /**
12
+ * @since 0.3.16-canary.0
13
+ */
11
14
  declare class DependencyResolver {
12
15
  private readonly _registry;
13
16
  private readonly _scope;
package/dist/resolver.mjs CHANGED
@@ -15,6 +15,9 @@ const ROOT_CONSTRAINT_CONTEXT = {
15
15
  ancestors: EMPTY_FRAME_LIST,
16
16
  currentResolveHint: void 0
17
17
  };
18
+ /**
19
+ * @since 0.3.16-canary.0
20
+ */
18
21
  var DependencyResolver = class {
19
22
  _frameByBindingId = /* @__PURE__ */ new Map();
20
23
  _syncResolutionContextPool = [];
package/dist/scope.d.mts CHANGED
@@ -1,6 +1,9 @@
1
1
  import { BindingIdentifier } from "./types.mjs";
2
2
 
3
3
  //#region src/scope.d.ts
4
+ /**
5
+ * @since 0.3.16-canary.0
6
+ */
4
7
  declare class ScopeManager {
5
8
  private readonly _singletons;
6
9
  private readonly _inflight;
package/dist/scope.mjs CHANGED
@@ -1,5 +1,8 @@
1
1
  import { MissingScopeContextError } from "./errors.mjs";
2
2
  //#region src/scope.ts
3
+ /**
4
+ * @since 0.3.16-canary.0
5
+ */
3
6
  var ScopeManager = class {
4
7
  _singletons = /* @__PURE__ */ new Map();
5
8
  _inflight = /* @__PURE__ */ new Map();
package/dist/token.d.mts CHANGED
@@ -2,12 +2,24 @@ import { Constructor } from "./constructor-type.mjs";
2
2
 
3
3
  //#region src/token.d.ts
4
4
  declare const TOKEN_BRAND: unique symbol;
5
+ /**
6
+ * @since 0.3.16-canary.0
7
+ */
5
8
  interface Token<Value> {
6
9
  readonly name: string;
7
10
  readonly [TOKEN_BRAND]: Value;
8
11
  }
12
+ /**
13
+ * @since 0.3.16-canary.0
14
+ */
9
15
  declare function token<Value>(name: string): Token<Value>;
16
+ /**
17
+ * @since 0.3.16-canary.0
18
+ */
10
19
  declare function tokenName(t: Token<unknown> | Constructor): string;
20
+ /**
21
+ * @since 0.3.16-canary.0
22
+ */
11
23
  declare function isToken(value: unknown): value is Token<unknown>;
12
24
  //#endregion
13
25
  export { Token, isToken, token, tokenName };
package/dist/token.mjs CHANGED
@@ -1,11 +1,20 @@
1
1
  //#region src/token.ts
2
+ /**
3
+ * @since 0.3.16-canary.0
4
+ */
2
5
  function token(name) {
3
6
  return { name };
4
7
  }
8
+ /**
9
+ * @since 0.3.16-canary.0
10
+ */
5
11
  function tokenName(t) {
6
12
  if (typeof t === "function") return t.name;
7
13
  return t.name;
8
14
  }
15
+ /**
16
+ * @since 0.3.16-canary.0
17
+ */
9
18
  function isToken(value) {
10
19
  return typeof value === "object" && value !== null && "name" in value && typeof value["name"] === "string" && typeof value !== "function";
11
20
  }
package/dist/types.d.mts CHANGED
@@ -2,21 +2,46 @@ import { Constructor } from "./constructor-type.mjs";
2
2
  import { Token } from "./token.mjs";
3
3
 
4
4
  //#region src/types.d.ts
5
- /** Token or class constructor used as a binding / injection / resolve key. */
5
+ /**
6
+ * Token or class constructor used as a binding / injection / resolve key.
7
+ *
8
+ * @since 0.3.16-canary.0
9
+ */
6
10
  type DependencyKey = Token<unknown> | Constructor;
11
+ /**
12
+ * @since 0.3.16-canary.0
13
+ */
7
14
  type BindingScope = "singleton" | "transient" | "scoped";
8
15
  declare const BINDING_ID_BRAND: unique symbol;
16
+ /**
17
+ * @since 0.3.16-canary.0
18
+ */
9
19
  type BindingIdentifier = string & {
10
20
  readonly [BINDING_ID_BRAND]: true;
11
21
  };
22
+ /**
23
+ * @since 0.3.16-canary.0
24
+ */
12
25
  type BindingKind = "class" | "dynamic" | "dynamic-async" | "resolved" | "resolved-async" | "constant" | "alias";
26
+ /**
27
+ * @since 0.3.16-canary.0
28
+ */
13
29
  type ActivationHandler<Value> = (ctx: ResolutionContext, instance: Value) => Value | Promise<Value>;
30
+ /**
31
+ * @since 0.3.16-canary.0
32
+ */
14
33
  type DeactivationHandler<Value> = (instance: Value) => void | Promise<void>;
34
+ /**
35
+ * @since 0.3.16-canary.0
36
+ */
15
37
  interface ResolveOptions {
16
38
  name?: string;
17
39
  tag?: readonly [tag: string, value: unknown];
18
40
  tags?: ReadonlyArray<readonly [tag: string, value: unknown]>;
19
41
  }
42
+ /**
43
+ * @since 0.3.16-canary.0
44
+ */
20
45
  interface MaterializationFrame {
21
46
  readonly tokenName: string;
22
47
  readonly scope: BindingScope;
@@ -27,6 +52,9 @@ interface MaterializationFrame {
27
52
  readonly tags: ReadonlyArray<readonly [tag: string, value: unknown]>;
28
53
  };
29
54
  }
55
+ /**
56
+ * @since 0.3.16-canary.0
57
+ */
30
58
  interface ConstraintContext {
31
59
  readonly resolutionPath: readonly string[];
32
60
  readonly materializationStack: readonly MaterializationFrame[];
@@ -34,6 +62,9 @@ interface ConstraintContext {
34
62
  readonly ancestors: readonly MaterializationFrame[];
35
63
  readonly currentResolveHint: ResolveOptions | undefined;
36
64
  }
65
+ /**
66
+ * @since 0.3.16-canary.0
67
+ */
37
68
  interface ResolutionContext {
38
69
  resolve<const Value>(token: Token<Value> | Constructor<Value>, hint?: ResolveOptions): Value;
39
70
  resolveAsync<const Value>(token: Token<Value> | Constructor<Value>, hint?: ResolveOptions): Promise<Value>;
@@ -43,6 +74,9 @@ interface ResolutionContext {
43
74
  resolveAllAsync<const Value>(token: Token<Value> | Constructor<Value>, hint?: ResolveOptions): Promise<Value[]>;
44
75
  readonly graph: ConstraintContext;
45
76
  }
77
+ /**
78
+ * @since 0.3.16-canary.0
79
+ */
46
80
  type TokenValue<Type> = Type extends Token<infer Value> ? Value : Type extends Constructor<infer Value> ? Value : never;
47
81
  //#endregion
48
82
  export { ActivationHandler, BindingIdentifier, BindingKind, BindingScope, ConstraintContext, type Constructor, DeactivationHandler, DependencyKey, MaterializationFrame, ResolutionContext, ResolveOptions, TokenValue };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codefast/di",
3
- "version": "0.3.15",
3
+ "version": "0.3.16-canary.0",
4
4
  "description": "Lightweight dependency injection primitives for Codefast",
5
5
  "keywords": [
6
6
  "codefast",
@@ -171,13 +171,13 @@
171
171
  },
172
172
  "devDependencies": {
173
173
  "@types/node": "^25.6.0",
174
- "@typescript/native-preview": "7.0.0-dev.20260502.1",
174
+ "@typescript/native-preview": "7.0.0-dev.20260504.1",
175
175
  "@vitest/coverage-v8": "^4.1.5",
176
176
  "expect-type": "^1.3.0",
177
177
  "typescript": "^6.0.3",
178
178
  "unplugin-swc": "^1.5.9",
179
179
  "vitest": "^4.1.5",
180
- "@codefast/typescript-config": "0.3.15"
180
+ "@codefast/typescript-config": "0.3.16-canary.0"
181
181
  },
182
182
  "engines": {
183
183
  "node": ">=22.0.0"