@codefast/di 0.3.15 → 0.3.16-canary.1

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 (58) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +4 -1
  3. package/dist/binding-scope.d.mts +2 -0
  4. package/dist/binding-scope.mjs +2 -0
  5. package/dist/binding-select.d.mts +6 -2
  6. package/dist/binding-select.mjs +4 -0
  7. package/dist/binding.d.mts +74 -7
  8. package/dist/binding.mjs +12 -0
  9. package/dist/constraints.d.mts +49 -9
  10. package/dist/constraints.mjs +71 -19
  11. package/dist/constructor-type.d.mts +6 -2
  12. package/dist/container.d.mts +15 -6
  13. package/dist/container.mjs +139 -55
  14. package/dist/decorators/inject.d.mts +27 -3
  15. package/dist/decorators/inject.mjs +28 -11
  16. package/dist/decorators/injectable.d.mts +13 -1
  17. package/dist/decorators/injectable.mjs +24 -14
  18. package/dist/decorators/lifecycle-decorators.d.mts +6 -0
  19. package/dist/decorators/lifecycle-decorators.mjs +9 -0
  20. package/dist/dependency-graph.d.mts +17 -2
  21. package/dist/dependency-graph.mjs +3 -0
  22. package/dist/environment.d.mts +27 -12
  23. package/dist/environment.mjs +12 -0
  24. package/dist/errors.d.mts +69 -8
  25. package/dist/errors.mjs +65 -1
  26. package/dist/graph-adapters/cytoscape.d.mts +12 -0
  27. package/dist/graph-adapters/cytoscape.mjs +3 -0
  28. package/dist/graph-adapters/dot.d.mts +3 -0
  29. package/dist/graph-adapters/dot.mjs +3 -0
  30. package/dist/graph-adapters/reactflow.d.mts +14 -2
  31. package/dist/graph-adapters/reactflow.mjs +3 -0
  32. package/dist/index.d.mts +4 -3
  33. package/dist/index.mjs +4 -3
  34. package/dist/inspector.d.mts +11 -3
  35. package/dist/inspector.mjs +8 -3
  36. package/dist/lifecycle.d.mts +8 -6
  37. package/dist/lifecycle.mjs +48 -52
  38. package/dist/metadata/metadata-keys.d.mts +42 -1
  39. package/dist/metadata/metadata-keys.mjs +32 -1
  40. package/dist/metadata/metadata-reader-token.d.mts +3 -0
  41. package/dist/metadata/metadata-reader-token.mjs +3 -0
  42. package/dist/metadata/metadata-types.d.mts +22 -6
  43. package/dist/metadata/symbol-metadata-reader.d.mts +6 -0
  44. package/dist/metadata/symbol-metadata-reader.mjs +37 -24
  45. package/dist/module.d.mts +25 -1
  46. package/dist/module.mjs +12 -0
  47. package/dist/registry.d.mts +8 -5
  48. package/dist/registry.mjs +38 -42
  49. package/dist/resolve-options.d.mts +4 -0
  50. package/dist/resolve-options.mjs +4 -0
  51. package/dist/resolver.d.mts +23 -8
  52. package/dist/resolver.mjs +67 -43
  53. package/dist/scope.d.mts +3 -0
  54. package/dist/scope.mjs +3 -0
  55. package/dist/token.d.mts +12 -0
  56. package/dist/token.mjs +9 -0
  57. package/dist/types.d.mts +44 -6
  58. package/package.json +11 -5
package/dist/types.d.mts CHANGED
@@ -2,21 +2,50 @@ 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;
39
+ /**
40
+ * Single-tag shorthand — semantics match including one pair in `tags`.
41
+ * Enables fast-path lookup alongside `tags`.
42
+ */
17
43
  tag?: readonly [tag: string, value: unknown];
18
44
  tags?: ReadonlyArray<readonly [tag: string, value: unknown]>;
19
45
  }
46
+ /**
47
+ * @since 0.3.16-canary.0
48
+ */
20
49
  interface MaterializationFrame {
21
50
  readonly tokenName: string;
22
51
  readonly scope: BindingScope;
@@ -27,22 +56,31 @@ interface MaterializationFrame {
27
56
  readonly tags: ReadonlyArray<readonly [tag: string, value: unknown]>;
28
57
  };
29
58
  }
59
+ /**
60
+ * @since 0.3.16-canary.0
61
+ */
30
62
  interface ConstraintContext {
31
- readonly resolutionPath: readonly string[];
32
- readonly materializationStack: readonly MaterializationFrame[];
63
+ readonly resolutionPath: ReadonlyArray<string>;
64
+ readonly materializationStack: ReadonlyArray<MaterializationFrame>;
33
65
  readonly parent: MaterializationFrame | undefined;
34
- readonly ancestors: readonly MaterializationFrame[];
66
+ readonly ancestors: ReadonlyArray<MaterializationFrame>;
35
67
  readonly currentResolveHint: ResolveOptions | undefined;
36
68
  }
69
+ /**
70
+ * @since 0.3.16-canary.0
71
+ */
37
72
  interface ResolutionContext {
38
73
  resolve<const Value>(token: Token<Value> | Constructor<Value>, hint?: ResolveOptions): Value;
39
74
  resolveAsync<const Value>(token: Token<Value> | Constructor<Value>, hint?: ResolveOptions): Promise<Value>;
40
75
  resolveOptional<const Value>(token: Token<Value> | Constructor<Value>, hint?: ResolveOptions): Value | undefined;
41
76
  resolveOptionalAsync<const Value>(token: Token<Value> | Constructor<Value>, hint?: ResolveOptions): Promise<Value | undefined>;
42
- resolveAll<const Value>(token: Token<Value> | Constructor<Value>, hint?: ResolveOptions): Value[];
43
- resolveAllAsync<const Value>(token: Token<Value> | Constructor<Value>, hint?: ResolveOptions): Promise<Value[]>;
77
+ resolveAll<const Value>(token: Token<Value> | Constructor<Value>, hint?: ResolveOptions): Array<Value>;
78
+ resolveAllAsync<const Value>(token: Token<Value> | Constructor<Value>, hint?: ResolveOptions): Promise<Array<Value>>;
44
79
  readonly graph: ConstraintContext;
45
80
  }
81
+ /**
82
+ * @since 0.3.16-canary.0
83
+ */
46
84
  type TokenValue<Type> = Type extends Token<infer Value> ? Value : Type extends Constructor<infer Value> ? Value : never;
47
85
  //#endregion
48
86
  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.1",
4
4
  "description": "Lightweight dependency injection primitives for Codefast",
5
5
  "keywords": [
6
6
  "codefast",
@@ -170,14 +170,16 @@
170
170
  "access": "public"
171
171
  },
172
172
  "devDependencies": {
173
- "@types/node": "^25.6.0",
174
- "@typescript/native-preview": "7.0.0-dev.20260502.1",
173
+ "@types/node": "^25.6.2",
174
+ "@typescript/native-preview": "7.0.0-dev.20260509.2",
175
175
  "@vitest/coverage-v8": "^4.1.5",
176
176
  "expect-type": "^1.3.0",
177
+ "tsdown": "^0.22.0",
178
+ "tsx": "^4.21.0",
177
179
  "typescript": "^6.0.3",
178
180
  "unplugin-swc": "^1.5.9",
179
181
  "vitest": "^4.1.5",
180
- "@codefast/typescript-config": "0.3.15"
182
+ "@codefast/typescript-config": "0.3.16-canary.1"
181
183
  },
182
184
  "engines": {
183
185
  "node": ">=22.0.0"
@@ -186,9 +188,13 @@
186
188
  "build": "tsdown",
187
189
  "check-types": "tsgo --noEmit",
188
190
  "clean": "rm -rf dist",
189
- "examples": "for file in examples/*/*.ts; do echo \"=== Running $file ===\"; tsx \"$file\"; echo \"\n\" || exit 1; done",
191
+ "examples": "for file in examples/*/*.ts; do echo \"=== Running $file ===\"; node --import tsx/esm \"$file\"; echo \"\n\" || exit 1; done",
190
192
  "test": "vitest run",
191
193
  "test:coverage": "vitest run --coverage",
194
+ "test:e2e": "vitest run tests/e2e",
195
+ "test:integration": "vitest run tests/integration",
196
+ "test:type": "vitest run tests/types",
197
+ "test:unit": "vitest run tests/unit",
192
198
  "test:watch": "vitest"
193
199
  }
194
200
  }