@navios/di 0.8.0 → 0.9.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 (264) hide show
  1. package/CHANGELOG.md +87 -0
  2. package/README.md +117 -17
  3. package/lib/browser/container/abstract-container.d.mts +112 -0
  4. package/lib/browser/container/abstract-container.d.mts.map +1 -0
  5. package/lib/browser/container/abstract-container.mjs +100 -0
  6. package/lib/browser/container/abstract-container.mjs.map +1 -0
  7. package/lib/browser/container/container.d.mts +100 -0
  8. package/lib/browser/container/container.d.mts.map +1 -0
  9. package/lib/browser/container/container.mjs +424 -0
  10. package/lib/browser/container/container.mjs.map +1 -0
  11. package/lib/browser/container/scoped-container.d.mts +93 -0
  12. package/lib/browser/container/scoped-container.d.mts.map +1 -0
  13. package/lib/browser/container/scoped-container.mjs +119 -0
  14. package/lib/browser/container/scoped-container.mjs.map +1 -0
  15. package/lib/browser/decorators/factory.decorator.d.mts +26 -0
  16. package/lib/browser/decorators/factory.decorator.d.mts.map +1 -0
  17. package/lib/browser/decorators/factory.decorator.mjs +20 -0
  18. package/lib/browser/decorators/factory.decorator.mjs.map +1 -0
  19. package/lib/browser/decorators/injectable.decorator.d.mts +38 -0
  20. package/lib/browser/decorators/injectable.decorator.d.mts.map +1 -0
  21. package/lib/browser/decorators/injectable.decorator.mjs +21 -0
  22. package/lib/browser/decorators/injectable.decorator.mjs.map +1 -0
  23. package/lib/browser/enums/injectable-scope.enum.d.mts +18 -0
  24. package/lib/browser/enums/injectable-scope.enum.d.mts.map +1 -0
  25. package/lib/browser/enums/injectable-scope.enum.mjs +20 -0
  26. package/lib/browser/enums/injectable-scope.enum.mjs.map +1 -0
  27. package/lib/browser/enums/injectable-type.enum.d.mts +8 -0
  28. package/lib/browser/enums/injectable-type.enum.d.mts.map +1 -0
  29. package/lib/browser/enums/injectable-type.enum.mjs +10 -0
  30. package/lib/browser/enums/injectable-type.enum.mjs.map +1 -0
  31. package/lib/browser/errors/di-error.d.mts +43 -0
  32. package/lib/browser/errors/di-error.d.mts.map +1 -0
  33. package/lib/browser/errors/di-error.mjs +98 -0
  34. package/lib/browser/errors/di-error.mjs.map +1 -0
  35. package/lib/browser/event-emitter.d.mts +16 -0
  36. package/lib/browser/event-emitter.d.mts.map +1 -0
  37. package/lib/browser/event-emitter.mjs +320 -0
  38. package/lib/browser/event-emitter.mjs.map +1 -0
  39. package/lib/browser/index.d.mts +37 -1558
  40. package/lib/browser/index.mjs +29 -2749
  41. package/lib/browser/interfaces/container.interface.d.mts +59 -0
  42. package/lib/browser/interfaces/container.interface.d.mts.map +1 -0
  43. package/lib/browser/interfaces/factory.interface.d.mts +14 -0
  44. package/lib/browser/interfaces/factory.interface.d.mts.map +1 -0
  45. package/lib/browser/interfaces/on-service-destroy.interface.d.mts +7 -0
  46. package/lib/browser/interfaces/on-service-destroy.interface.d.mts.map +1 -0
  47. package/lib/browser/interfaces/on-service-init.interface.d.mts +7 -0
  48. package/lib/browser/interfaces/on-service-init.interface.d.mts.map +1 -0
  49. package/lib/browser/internal/context/async-local-storage.browser.mjs +20 -0
  50. package/lib/browser/internal/context/async-local-storage.browser.mjs.map +1 -0
  51. package/lib/browser/internal/context/async-local-storage.d.mts +9 -0
  52. package/lib/browser/internal/context/async-local-storage.d.mts.map +1 -0
  53. package/lib/browser/internal/context/async-local-storage.types.d.mts +11 -0
  54. package/lib/browser/internal/context/async-local-storage.types.d.mts.map +1 -0
  55. package/lib/browser/internal/context/factory-context.d.mts +23 -0
  56. package/lib/browser/internal/context/factory-context.d.mts.map +1 -0
  57. package/lib/browser/internal/context/resolution-context.d.mts +43 -0
  58. package/lib/browser/internal/context/resolution-context.d.mts.map +1 -0
  59. package/lib/browser/internal/context/resolution-context.mjs +56 -0
  60. package/lib/browser/internal/context/resolution-context.mjs.map +1 -0
  61. package/lib/browser/internal/context/service-initialization-context.d.mts +48 -0
  62. package/lib/browser/internal/context/service-initialization-context.d.mts.map +1 -0
  63. package/lib/browser/internal/context/sync-local-storage.mjs +53 -0
  64. package/lib/browser/internal/context/sync-local-storage.mjs.map +1 -0
  65. package/lib/browser/internal/core/instance-resolver.d.mts +119 -0
  66. package/lib/browser/internal/core/instance-resolver.d.mts.map +1 -0
  67. package/lib/browser/internal/core/instance-resolver.mjs +306 -0
  68. package/lib/browser/internal/core/instance-resolver.mjs.map +1 -0
  69. package/lib/browser/internal/core/name-resolver.d.mts +52 -0
  70. package/lib/browser/internal/core/name-resolver.d.mts.map +1 -0
  71. package/lib/browser/internal/core/name-resolver.mjs +118 -0
  72. package/lib/browser/internal/core/name-resolver.mjs.map +1 -0
  73. package/lib/browser/internal/core/scope-tracker.d.mts +65 -0
  74. package/lib/browser/internal/core/scope-tracker.d.mts.map +1 -0
  75. package/lib/browser/internal/core/scope-tracker.mjs +120 -0
  76. package/lib/browser/internal/core/scope-tracker.mjs.map +1 -0
  77. package/lib/browser/internal/core/service-initializer.d.mts +44 -0
  78. package/lib/browser/internal/core/service-initializer.d.mts.map +1 -0
  79. package/lib/browser/internal/core/service-initializer.mjs +109 -0
  80. package/lib/browser/internal/core/service-initializer.mjs.map +1 -0
  81. package/lib/browser/internal/core/service-invalidator.d.mts +81 -0
  82. package/lib/browser/internal/core/service-invalidator.d.mts.map +1 -0
  83. package/lib/browser/internal/core/service-invalidator.mjs +142 -0
  84. package/lib/browser/internal/core/service-invalidator.mjs.map +1 -0
  85. package/lib/browser/internal/core/token-resolver.d.mts +54 -0
  86. package/lib/browser/internal/core/token-resolver.d.mts.map +1 -0
  87. package/lib/browser/internal/core/token-resolver.mjs +77 -0
  88. package/lib/browser/internal/core/token-resolver.mjs.map +1 -0
  89. package/lib/browser/internal/holder/holder-storage.interface.d.mts +99 -0
  90. package/lib/browser/internal/holder/holder-storage.interface.d.mts.map +1 -0
  91. package/lib/browser/internal/holder/instance-holder.d.mts +101 -0
  92. package/lib/browser/internal/holder/instance-holder.d.mts.map +1 -0
  93. package/lib/browser/internal/holder/instance-holder.mjs +19 -0
  94. package/lib/browser/internal/holder/instance-holder.mjs.map +1 -0
  95. package/lib/browser/internal/holder/unified-storage.d.mts +53 -0
  96. package/lib/browser/internal/holder/unified-storage.d.mts.map +1 -0
  97. package/lib/browser/internal/holder/unified-storage.mjs +144 -0
  98. package/lib/browser/internal/holder/unified-storage.mjs.map +1 -0
  99. package/lib/browser/internal/lifecycle/circular-detector.d.mts +39 -0
  100. package/lib/browser/internal/lifecycle/circular-detector.d.mts.map +1 -0
  101. package/lib/browser/internal/lifecycle/circular-detector.mjs +55 -0
  102. package/lib/browser/internal/lifecycle/circular-detector.mjs.map +1 -0
  103. package/lib/browser/internal/lifecycle/lifecycle-event-bus.d.mts +18 -0
  104. package/lib/browser/internal/lifecycle/lifecycle-event-bus.d.mts.map +1 -0
  105. package/lib/browser/internal/lifecycle/lifecycle-event-bus.mjs +43 -0
  106. package/lib/browser/internal/lifecycle/lifecycle-event-bus.mjs.map +1 -0
  107. package/lib/browser/internal/stub-factory-class.d.mts +14 -0
  108. package/lib/browser/internal/stub-factory-class.d.mts.map +1 -0
  109. package/lib/browser/internal/stub-factory-class.mjs +18 -0
  110. package/lib/browser/internal/stub-factory-class.mjs.map +1 -0
  111. package/lib/browser/symbols/injectable-token.d.mts +5 -0
  112. package/lib/browser/symbols/injectable-token.d.mts.map +1 -0
  113. package/lib/browser/symbols/injectable-token.mjs +6 -0
  114. package/lib/browser/symbols/injectable-token.mjs.map +1 -0
  115. package/lib/browser/token/injection-token.d.mts +55 -0
  116. package/lib/browser/token/injection-token.d.mts.map +1 -0
  117. package/lib/browser/token/injection-token.mjs +100 -0
  118. package/lib/browser/token/injection-token.mjs.map +1 -0
  119. package/lib/browser/token/registry.d.mts +37 -0
  120. package/lib/browser/token/registry.d.mts.map +1 -0
  121. package/lib/browser/token/registry.mjs +86 -0
  122. package/lib/browser/token/registry.mjs.map +1 -0
  123. package/lib/browser/utils/default-injectors.d.mts +12 -0
  124. package/lib/browser/utils/default-injectors.d.mts.map +1 -0
  125. package/lib/browser/utils/default-injectors.mjs +13 -0
  126. package/lib/browser/utils/default-injectors.mjs.map +1 -0
  127. package/lib/browser/utils/get-injectable-token.d.mts +9 -0
  128. package/lib/browser/utils/get-injectable-token.d.mts.map +1 -0
  129. package/lib/browser/utils/get-injectable-token.mjs +13 -0
  130. package/lib/browser/utils/get-injectable-token.mjs.map +1 -0
  131. package/lib/browser/utils/get-injectors.d.mts +55 -0
  132. package/lib/browser/utils/get-injectors.d.mts.map +1 -0
  133. package/lib/browser/utils/get-injectors.mjs +121 -0
  134. package/lib/browser/utils/get-injectors.mjs.map +1 -0
  135. package/lib/browser/utils/types.d.mts +23 -0
  136. package/lib/browser/utils/types.d.mts.map +1 -0
  137. package/lib/{container-DAKOvAgr.mjs → container-8-z89TyQ.mjs} +1325 -1462
  138. package/lib/container-8-z89TyQ.mjs.map +1 -0
  139. package/lib/{container-Bp1W-pWJ.d.mts → container-CNiqesCL.d.mts} +598 -617
  140. package/lib/container-CNiqesCL.d.mts.map +1 -0
  141. package/lib/{container-DENMeJ87.cjs → container-CaY2fDuk.cjs} +1369 -1512
  142. package/lib/container-CaY2fDuk.cjs.map +1 -0
  143. package/lib/{container-YPwvmlK2.d.cts → container-D-0Ho3qL.d.cts} +598 -612
  144. package/lib/container-D-0Ho3qL.d.cts.map +1 -0
  145. package/lib/index.cjs +13 -15
  146. package/lib/index.cjs.map +1 -1
  147. package/lib/index.d.cts +58 -223
  148. package/lib/index.d.cts.map +1 -1
  149. package/lib/index.d.mts +62 -222
  150. package/lib/index.d.mts.map +1 -1
  151. package/lib/index.mjs +5 -6
  152. package/lib/index.mjs.map +1 -1
  153. package/lib/testing/index.cjs +569 -311
  154. package/lib/testing/index.cjs.map +1 -1
  155. package/lib/testing/index.d.cts +370 -41
  156. package/lib/testing/index.d.cts.map +1 -1
  157. package/lib/testing/index.d.mts +370 -41
  158. package/lib/testing/index.d.mts.map +1 -1
  159. package/lib/testing/index.mjs +568 -305
  160. package/lib/testing/index.mjs.map +1 -1
  161. package/package.json +2 -1
  162. package/src/__tests__/circular-detector.spec.mts +193 -0
  163. package/src/__tests__/concurrent.spec.mts +368 -0
  164. package/src/__tests__/container.spec.mts +32 -30
  165. package/src/__tests__/di-error.spec.mts +351 -0
  166. package/src/__tests__/e2e.browser.spec.mts +0 -4
  167. package/src/__tests__/e2e.spec.mts +10 -19
  168. package/src/__tests__/event-emitter.spec.mts +232 -109
  169. package/src/__tests__/get-injectors.spec.mts +250 -39
  170. package/src/__tests__/injection-token.spec.mts +293 -349
  171. package/src/__tests__/library-findings.spec.mts +8 -8
  172. package/src/__tests__/registry.spec.mts +358 -210
  173. package/src/__tests__/resolution-context.spec.mts +255 -0
  174. package/src/__tests__/scope-tracker.spec.mts +598 -0
  175. package/src/__tests__/scope-upgrade.spec.mts +808 -0
  176. package/src/__tests__/scoped-container.spec.mts +595 -0
  177. package/src/__tests__/test-container.spec.mts +293 -0
  178. package/src/__tests__/token-resolver.spec.mts +207 -0
  179. package/src/__tests__/unified-storage.spec.mts +535 -0
  180. package/src/__tests__/unit-test-container.spec.mts +405 -0
  181. package/src/__type-tests__/container.spec-d.mts +180 -0
  182. package/src/__type-tests__/factory.spec-d.mts +15 -3
  183. package/src/__type-tests__/inject.spec-d.mts +115 -20
  184. package/src/__type-tests__/injectable.spec-d.mts +69 -52
  185. package/src/__type-tests__/injection-token.spec-d.mts +176 -0
  186. package/src/__type-tests__/scoped-container.spec-d.mts +212 -0
  187. package/src/container/abstract-container.mts +327 -0
  188. package/src/container/container.mts +142 -170
  189. package/src/container/scoped-container.mts +126 -208
  190. package/src/decorators/factory.decorator.mts +16 -11
  191. package/src/decorators/injectable.decorator.mts +20 -16
  192. package/src/enums/index.mts +2 -2
  193. package/src/enums/injectable-scope.enum.mts +1 -0
  194. package/src/enums/injectable-type.enum.mts +1 -0
  195. package/src/errors/di-error.mts +96 -0
  196. package/src/event-emitter.mts +3 -27
  197. package/src/index.mts +6 -153
  198. package/src/interfaces/container.interface.mts +13 -0
  199. package/src/interfaces/factory.interface.mts +1 -1
  200. package/src/interfaces/index.mts +1 -1
  201. package/src/internal/context/async-local-storage.mts +3 -2
  202. package/src/internal/context/async-local-storage.types.mts +1 -0
  203. package/src/internal/context/factory-context.mts +1 -0
  204. package/src/internal/context/index.mts +3 -1
  205. package/src/internal/context/resolution-context.mts +1 -0
  206. package/src/internal/context/service-initialization-context.mts +43 -0
  207. package/src/internal/core/index.mts +5 -4
  208. package/src/internal/core/instance-resolver.mts +460 -302
  209. package/src/internal/core/name-resolver.mts +196 -0
  210. package/src/internal/core/scope-tracker.mts +242 -0
  211. package/src/internal/core/{instantiator.mts → service-initializer.mts} +51 -29
  212. package/src/internal/core/service-invalidator.mts +290 -0
  213. package/src/internal/core/token-resolver.mts +122 -0
  214. package/src/internal/holder/holder-storage.interface.mts +11 -5
  215. package/src/internal/holder/index.mts +2 -5
  216. package/src/internal/holder/instance-holder.mts +1 -3
  217. package/src/internal/holder/unified-storage.mts +245 -0
  218. package/src/internal/index.mts +2 -1
  219. package/src/internal/lifecycle/circular-detector.mts +1 -0
  220. package/src/internal/lifecycle/index.mts +1 -1
  221. package/src/internal/lifecycle/lifecycle-event-bus.mts +1 -0
  222. package/src/internal/stub-factory-class.mts +16 -0
  223. package/src/symbols/injectable-token.mts +3 -1
  224. package/src/testing/index.mts +2 -0
  225. package/src/testing/test-container.mts +546 -85
  226. package/src/testing/types.mts +117 -0
  227. package/src/testing/unit-test-container.mts +509 -0
  228. package/src/token/injection-token.mts +41 -4
  229. package/src/token/registry.mts +75 -9
  230. package/src/utils/default-injectors.mts +16 -0
  231. package/src/utils/get-injectable-token.mts +2 -3
  232. package/src/utils/get-injectors.mts +26 -15
  233. package/src/utils/index.mts +3 -1
  234. package/src/utils/types.mts +1 -0
  235. package/tsdown.config.mts +11 -1
  236. package/lib/browser/index.d.mts.map +0 -1
  237. package/lib/browser/index.mjs.map +0 -1
  238. package/lib/container-Bp1W-pWJ.d.mts.map +0 -1
  239. package/lib/container-DAKOvAgr.mjs.map +0 -1
  240. package/lib/container-DENMeJ87.cjs.map +0 -1
  241. package/lib/container-YPwvmlK2.d.cts.map +0 -1
  242. package/src/__tests__/async-local-storage.browser.spec.mts +0 -166
  243. package/src/__tests__/async-local-storage.spec.mts +0 -333
  244. package/src/__tests__/errors.spec.mts +0 -87
  245. package/src/__tests__/factory.spec.mts +0 -137
  246. package/src/__tests__/injectable.spec.mts +0 -246
  247. package/src/__tests__/request-scope.spec.mts +0 -416
  248. package/src/__tests__/service-instantiator.spec.mts +0 -410
  249. package/src/__tests__/service-locator-event-bus.spec.mts +0 -242
  250. package/src/__tests__/service-locator-manager.spec.mts +0 -300
  251. package/src/__tests__/service-locator.spec.mts +0 -966
  252. package/src/__tests__/unified-api.spec.mts +0 -130
  253. package/src/browser.mts +0 -11
  254. package/src/injectors.mts +0 -18
  255. package/src/internal/context/request-context.mts +0 -225
  256. package/src/internal/core/invalidator.mts +0 -437
  257. package/src/internal/core/service-locator.mts +0 -202
  258. package/src/internal/core/token-processor.mts +0 -252
  259. package/src/internal/holder/base-holder-manager.mts +0 -334
  260. package/src/internal/holder/holder-manager.mts +0 -85
  261. package/src/internal/holder/request-storage.mts +0 -127
  262. package/src/internal/holder/singleton-storage.mts +0 -92
  263. package/src/testing/README.md +0 -80
  264. package/src/testing/__tests__/test-container.spec.mts +0 -173
@@ -0,0 +1,59 @@
1
+ import { BoundInjectionToken, ClassType, ClassTypeWithArgument, FactoryInjectionToken, InjectionToken, InjectionTokenSchemaType } from "../token/injection-token.mjs";
2
+ import { Join, UnionToArray } from "../utils/types.mjs";
3
+ import { Factorable } from "./factory.interface.mjs";
4
+ import { ZodType, z } from "zod/v4";
5
+
6
+ //#region src/interfaces/container.interface.d.mts
7
+
8
+ /**
9
+ * Interface for dependency injection containers.
10
+ * Both Container and ScopedContainer implement this interface,
11
+ * allowing them to be used interchangeably in factory contexts.
12
+ */
13
+ interface IContainer {
14
+ /**
15
+ * Gets an instance from the container.
16
+ */
17
+ get<T extends ClassType>(token: T): InstanceType<T> extends Factorable<infer R> ? Promise<R> : Promise<InstanceType<T>>;
18
+ get<T extends ClassTypeWithArgument<R>, R>(token: T, args: R): Promise<InstanceType<T>>;
19
+ get<T, S extends InjectionTokenSchemaType>(token: InjectionToken<T, S>, args: z.input<S>): Promise<T>;
20
+ get<T, S extends InjectionTokenSchemaType, R extends boolean>(token: InjectionToken<T, S, R>): R extends false ? Promise<T> : S extends ZodType<infer Type> ? `Error: Your token requires args: ${Join<UnionToArray<keyof Type>, ', '>}` : 'Error: Your token requires args';
21
+ get<T>(token: InjectionToken<T, undefined>): Promise<T>;
22
+ get<T>(token: BoundInjectionToken<T, any>): Promise<T>;
23
+ get<T>(token: FactoryInjectionToken<T, any>): Promise<T>;
24
+ /**
25
+ * Invalidates a service and its dependencies.
26
+ */
27
+ invalidate(service: unknown): Promise<void>;
28
+ /**
29
+ * Checks if a service is registered in the container.
30
+ */
31
+ isRegistered(token: any): boolean;
32
+ /**
33
+ * Adds an instance to the container.
34
+ * Accepts class types, InjectionTokens, and BoundInjectionTokens.
35
+ * Rejects InjectionTokens with required schemas (use BoundInjectionToken instead).
36
+ *
37
+ * @param token The class type, InjectionToken, or BoundInjectionToken to register the instance for
38
+ * @param instance The instance to store
39
+ */
40
+ addInstance<T>(token: ClassType | InjectionToken<T, any> | BoundInjectionToken<T, any>, instance: T): void;
41
+ /**
42
+ * Disposes the container and cleans up all resources.
43
+ */
44
+ dispose(): Promise<void>;
45
+ /**
46
+ * Waits for all pending operations to complete.
47
+ */
48
+ ready(): Promise<void>;
49
+ /**
50
+ * @internal
51
+ * Attempts to get an instance synchronously if it already exists.
52
+ * Returns null if the instance doesn't exist or is not ready.
53
+ * Used internally by the inject system for synchronous property initialization.
54
+ */
55
+ tryGetSync<T>(token: any, args?: any): T | null;
56
+ }
57
+ //#endregion
58
+ export { IContainer };
59
+ //# sourceMappingURL=container.interface.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"container.interface.d.mts","names":[],"sources":["../../../src/interfaces/container.interface.mts"],"sourcesContent":[],"mappings":";;;;;;;;;AAkBA;;;AAOkB,UAPD,UAAA,CAOC;EAAb;;;EACC,GAAA,CAAA,UAHU,SAGV,CAAA,CAAA,KAAA,EAFK,CAEL,CAAA,EADD,YACC,CADY,CACZ,CAAA,SADuB,UACvB,CAAA,KAAA,EAAA,CAAA,GAAA,OAAA,CAAQ,CAAR,CAAA,GACA,OADA,CACQ,YADR,CACqB,CADrB,CAAA,CAAA;EACqB,GAAA,CAAA,UAEX,qBAFW,CAEW,CAFX,CAAA,EAAA,CAAA,CAAA,CAAA,KAAA,EAGhB,CAHgB,EAAA,IAAA,EAIjB,CAJiB,CAAA,EAKtB,OALsB,CAKd,YALc,CAKD,CALC,CAAA,CAAA;EAAb,GAAA,CAAA,CAAA,EAAA,UAOK,wBAPL,CAAA,CAAA,KAAA,EAQH,cARG,CAQY,CARZ,EAQe,CARf,CAAA,EAAA,IAAA,EASJ,CAAA,CAAE,KATE,CASI,CATJ,CAAA,CAAA,EAUT,OAVS,CAUD,CAVC,CAAA;EAAR,GAAA,CAAA,CAAA,EAAA,UAYa,wBAZb,EAAA,UAAA,OAAA,CAAA,CAAA,KAAA,EAaK,cAbL,CAaoB,CAbpB,EAauB,CAbvB,EAa0B,CAb1B,CAAA,CAAA,EAcD,CAdC,SAAA,KAAA,GAeA,OAfA,CAeQ,CAfR,CAAA,GAgBA,CAhBA,SAgBU,OAhBV,CAAA,KAAA,KAAA,CAAA,GAAA,oCAiBsC,IAjBtC,CAkBI,YAlBJ,CAAA,MAkBuB,IAlBvB,CAAA,EAAA,IAAA,CAAA,EAAA,GAAA,iCAAA;EAEgC,GAAA,CAAA,CAAA,CAAA,CAAA,KAAA,EAqBtB,cArBsB,CAqBP,CArBO,EAAA,SAAA,CAAA,CAAA,EAqBS,OArBT,CAqBiB,CArBjB,CAAA;EAAtB,GAAA,CAAA,CAAA,CAAA,CAAA,KAAA,EAsBA,mBAtBA,CAsBoB,CAtBpB,EAAA,GAAA,CAAA,CAAA,EAsB8B,OAtB9B,CAsBsC,CAtBtC,CAAA;EACL,GAAA,CAAA,CAAA,CAAA,CAAA,KAAA,EAsBK,qBAtBL,CAsB2B,CAtB3B,EAAA,GAAA,CAAA,CAAA,EAsBqC,OAtBrC,CAsB6C,CAtB7C,CAAA;EACD;;;EACL,UAAA,CAAA,OAAA,EAAA,OAAA,CAAA,EAyB2B,OAzB3B,CAAA,IAAA,CAAA;EAEc;;;EACR,YAAA,CAAA,KAAA,EAAA,GAAA,CAAA,EAAA,OAAA;EACO;;;;;;;;EAIP,WAAA,CAAA,CAAA,CAAA,CAAA,KAAA,EAiCA,SAjCA,GAiCY,cAjCZ,CAiC2B,CAjC3B,EAAA,GAAA,CAAA,GAiCqC,mBAjCrC,CAiCyD,CAjCzD,EAAA,GAAA,CAAA,EAAA,QAAA,EAkCG,CAlCH,CAAA,EAAA,IAAA;EACN;;;EAEC,OAAA,EAAA,EAqCO,OArCP,CAAA,IAAA,CAAA;EAAU;;;EAC4B,KAAA,EAAA,EAyCjC,OAzCiC,CAAA,IAAA,CAAA;EAMb;;;;;;EACuB,UAAA,CAAA,CAAA,CAAA,CAAA,KAAA,EAAA,GAAA,EAAA,IAAA,CAAA,EAAA,GAAA,CAAA,EA0Cb,CA1Ca,GAAA,IAAA"}
@@ -0,0 +1,14 @@
1
+ import { InjectionTokenSchemaType } from "../token/injection-token.mjs";
2
+ import { FactoryContext } from "../internal/context/factory-context.mjs";
3
+ import { z } from "zod/v4";
4
+
5
+ //#region src/interfaces/factory.interface.d.mts
6
+ interface Factorable<T> {
7
+ create(ctx?: FactoryContext): Promise<T> | T;
8
+ }
9
+ interface FactorableWithArgs<T, A extends InjectionTokenSchemaType> {
10
+ create(ctx?: FactoryContext, ...args: [z.output<A>]): Promise<T> | T;
11
+ }
12
+ //#endregion
13
+ export { Factorable, FactorableWithArgs };
14
+ //# sourceMappingURL=factory.interface.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.interface.d.mts","names":[],"sources":["../../../src/interfaces/factory.interface.mts"],"sourcesContent":[],"mappings":";;;;;UAKiB;eACF,iBAAiB,QAAQ,KAAK;AAD7C;AACe,UAGE,kBAHF,CAAA,CAAA,EAAA,UAGkC,wBAHlC,CAAA,CAAA;EAAyB,MAAA,CAAA,GAAA,CAAA,EAIzB,cAJyB,EAAA,GAAA,IAAA,EAAA,CAIC,CAAA,CAAE,MAJH,CAIU,CAJV,CAAA,CAAA,CAAA,EAIgB,OAJhB,CAIwB,CAJxB,CAAA,GAI6B,CAJ7B"}
@@ -0,0 +1,7 @@
1
+ //#region src/interfaces/on-service-destroy.interface.d.mts
2
+ interface OnServiceDestroy {
3
+ onServiceDestroy(): Promise<void> | void;
4
+ }
5
+ //#endregion
6
+ export { OnServiceDestroy };
7
+ //# sourceMappingURL=on-service-destroy.interface.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"on-service-destroy.interface.d.mts","names":[],"sources":["../../../src/interfaces/on-service-destroy.interface.mts"],"sourcesContent":[],"mappings":";UAAiB,gBAAA;EAAA,gBAAA,EAAA,EACK,OADW,CAAA,IACX,CAAA,GAAA,IAAO"}
@@ -0,0 +1,7 @@
1
+ //#region src/interfaces/on-service-init.interface.d.mts
2
+ interface OnServiceInit {
3
+ onServiceInit(): Promise<void> | void;
4
+ }
5
+ //#endregion
6
+ export { OnServiceInit };
7
+ //# sourceMappingURL=on-service-init.interface.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"on-service-init.interface.d.mts","names":[],"sources":["../../../src/interfaces/on-service-init.interface.mts"],"sourcesContent":[],"mappings":";UAAiB,aAAA;EAAA,aAAA,EAAA,EACE,OADW,CAAA,IACX,CAAA,GAAA,IAAO"}
@@ -0,0 +1,20 @@
1
+ import { SyncLocalStorage } from "./sync-local-storage.mjs";
2
+
3
+ //#region src/internal/context/async-local-storage.browser.mts
4
+ /**
5
+ * Browser implementation using SyncLocalStorage.
6
+ *
7
+ * This module is used in browser environments where async_hooks is not available.
8
+ * It provides synchronous-only context tracking which is sufficient for
9
+ * browser-based DI resolution.
10
+ */
11
+ function createAsyncLocalStorage() {
12
+ return new SyncLocalStorage();
13
+ }
14
+ function isUsingNativeAsyncLocalStorage() {
15
+ return false;
16
+ }
17
+
18
+ //#endregion
19
+ export { createAsyncLocalStorage, isUsingNativeAsyncLocalStorage };
20
+ //# sourceMappingURL=async-local-storage.browser.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async-local-storage.browser.mjs","names":[],"sources":["../../../../src/internal/context/async-local-storage.browser.mts"],"sourcesContent":["/**\n * Browser implementation using SyncLocalStorage.\n *\n * This module is used in browser environments where async_hooks is not available.\n * It provides synchronous-only context tracking which is sufficient for\n * browser-based DI resolution.\n */\n\nimport { SyncLocalStorage } from './sync-local-storage.mjs'\n\nexport type { IAsyncLocalStorage } from './async-local-storage.types.mjs'\n\nexport function createAsyncLocalStorage<T>() {\n return new SyncLocalStorage<T>()\n}\n\nexport function isUsingNativeAsyncLocalStorage(): boolean {\n return false\n}\n"],"mappings":";;;;;;;;;;AAYA,SAAgB,0BAA6B;AAC3C,QAAO,IAAI,kBAAqB;;AAGlC,SAAgB,iCAA0C;AACxD,QAAO"}
@@ -0,0 +1,9 @@
1
+ import { IAsyncLocalStorage } from "./async-local-storage.types.mjs";
2
+
3
+ //#region src/internal/context/async-local-storage.d.mts
4
+
5
+ declare function createAsyncLocalStorage<T>(): IAsyncLocalStorage<T>;
6
+ declare function isUsingNativeAsyncLocalStorage(): boolean;
7
+ //#endregion
8
+ export { createAsyncLocalStorage, isUsingNativeAsyncLocalStorage };
9
+ //# sourceMappingURL=async-local-storage.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async-local-storage.d.mts","names":[],"sources":["../../../../src/internal/context/async-local-storage.mts"],"sourcesContent":[],"mappings":";;;;iBA6DgB,8BAA8B,mBAAmB;iBAIjD,8BAAA,CAAA"}
@@ -0,0 +1,11 @@
1
+ //#region src/internal/context/async-local-storage.types.d.mts
2
+ /**
3
+ * Interface matching the subset of AsyncLocalStorage API we use.
4
+ */
5
+ interface IAsyncLocalStorage<T> {
6
+ run<R>(store: T, fn: () => R): R;
7
+ getStore(): T | undefined;
8
+ }
9
+ //#endregion
10
+ export { IAsyncLocalStorage };
11
+ //# sourceMappingURL=async-local-storage.types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async-local-storage.types.d.mts","names":[],"sources":["../../../../src/internal/context/async-local-storage.types.mts"],"sourcesContent":[],"mappings":";;AAGA;;AAC6B,UADZ,kBACY,CAAA,CAAA,CAAA,CAAA;EAAI,GAAA,CAAA,CAAA,CAAA,CAAA,KAAA,EAAjB,CAAiB,EAAA,EAAA,EAAA,GAAA,GAAJ,CAAI,CAAA,EAAA,CAAA;EACnB,QAAA,EAAA,EAAA,CAAA,GAAA,SAAA"}
@@ -0,0 +1,23 @@
1
+ import { IContainer } from "../../interfaces/container.interface.mjs";
2
+ import { Injectors } from "../../utils/get-injectors.mjs";
3
+
4
+ //#region src/internal/context/factory-context.d.mts
5
+
6
+ /**
7
+ * Context provided to factory functions during service instantiation.
8
+ *
9
+ * Provides access to dependency injection (via inject), the container,
10
+ * and lifecycle hooks for cleanup.
11
+ */
12
+ interface FactoryContext {
13
+ inject: Injectors['asyncInject'];
14
+ /**
15
+ * The container instance for dependency resolution.
16
+ * This may be either a Container or ScopedContainer.
17
+ */
18
+ container: IContainer;
19
+ addDestroyListener: (listener: () => void) => void;
20
+ }
21
+ //#endregion
22
+ export { FactoryContext };
23
+ //# sourceMappingURL=factory-context.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory-context.d.mts","names":[],"sources":["../../../../src/internal/context/factory-context.mts"],"sourcesContent":[],"mappings":";;;;;;;AASA;;;;UAAiB,cAAA;UACP;;;;;aAKG"}
@@ -0,0 +1,43 @@
1
+ import { InstanceHolder } from "../holder/instance-holder.mjs";
2
+
3
+ //#region src/internal/context/resolution-context.d.mts
4
+
5
+ /**
6
+ * Data stored in the resolution context during service instantiation.
7
+ */
8
+ interface ResolutionContextData {
9
+ /** The holder that is currently being instantiated */
10
+ waiterHolder: InstanceHolder;
11
+ /** Function to get a holder by name (for cycle detection) */
12
+ getHolder: (name: string) => InstanceHolder | undefined;
13
+ }
14
+ /**
15
+ * Runs a function within a resolution context.
16
+ *
17
+ * The context tracks which holder is currently being instantiated,
18
+ * allowing circular dependency detection to work correctly.
19
+ *
20
+ * @param waiterHolder The holder being instantiated
21
+ * @param getHolder Function to retrieve holders by name
22
+ * @param fn The function to run within the context
23
+ */
24
+ declare function withResolutionContext<T>(waiterHolder: InstanceHolder, getHolder: (name: string) => InstanceHolder | undefined, fn: () => T): T;
25
+ /**
26
+ * Gets the current resolution context, if any.
27
+ *
28
+ * Returns undefined if we're not inside a resolution context
29
+ * (e.g., when resolving a top-level service that has no parent).
30
+ */
31
+ declare function getCurrentResolutionContext(): ResolutionContextData | undefined;
32
+ /**
33
+ * Runs a function outside any resolution context.
34
+ *
35
+ * This is useful for async injections that should not participate
36
+ * in circular dependency detection since they don't block.
37
+ *
38
+ * @param fn The function to run without resolution context
39
+ */
40
+ declare function withoutResolutionContext<T>(fn: () => T): T;
41
+ //#endregion
42
+ export { ResolutionContextData, getCurrentResolutionContext, withResolutionContext, withoutResolutionContext };
43
+ //# sourceMappingURL=resolution-context.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolution-context.d.mts","names":[],"sources":["../../../../src/internal/context/resolution-context.mts"],"sourcesContent":[],"mappings":";;;;;;AAQA;AAsCgB,UAtCC,qBAAA,CAsCoB;EACrB;EACe,YAAA,EAtCf,cAsCe;EACnB;EACT,SAAA,EAAA,CAAA,IAAA,EAAA,MAAA,EAAA,GAtC4B,cAsC5B,GAAA,SAAA;;AAUH;AAcA;;;;;;;;;iBA5BgB,uCACA,6CACe,sCACnB,IACT;;;;;;;iBAUa,2BAAA,CAAA,GACZ;;;;;;;;;iBAaY,sCAAsC,IAAI"}
@@ -0,0 +1,56 @@
1
+ import { createAsyncLocalStorage } from "./async-local-storage.browser.mjs";
2
+
3
+ //#region src/internal/context/resolution-context.mts
4
+ /**
5
+ * AsyncLocalStorage for tracking the current resolution context.
6
+ *
7
+ * This allows tracking which service is being instantiated even across
8
+ * async boundaries (like when inject() is called inside a constructor).
9
+ * Essential for circular dependency detection.
10
+ *
11
+ * The actual implementation varies by environment:
12
+ * - Production: No-op (returns undefined, run() just calls fn directly)
13
+ * - Development: Real AsyncLocalStorage with full async tracking
14
+ * - Browser: SyncLocalStorage for synchronous-only tracking
15
+ */ let resolutionContext = null;
16
+ function getResolutionContext() {
17
+ if (!resolutionContext) resolutionContext = createAsyncLocalStorage();
18
+ return resolutionContext;
19
+ }
20
+ /**
21
+ * Runs a function within a resolution context.
22
+ *
23
+ * The context tracks which holder is currently being instantiated,
24
+ * allowing circular dependency detection to work correctly.
25
+ *
26
+ * @param waiterHolder The holder being instantiated
27
+ * @param getHolder Function to retrieve holders by name
28
+ * @param fn The function to run within the context
29
+ */ function withResolutionContext(waiterHolder, getHolder, fn) {
30
+ return getResolutionContext().run({
31
+ waiterHolder,
32
+ getHolder
33
+ }, fn);
34
+ }
35
+ /**
36
+ * Gets the current resolution context, if any.
37
+ *
38
+ * Returns undefined if we're not inside a resolution context
39
+ * (e.g., when resolving a top-level service that has no parent).
40
+ */ function getCurrentResolutionContext() {
41
+ return getResolutionContext().getStore();
42
+ }
43
+ /**
44
+ * Runs a function outside any resolution context.
45
+ *
46
+ * This is useful for async injections that should not participate
47
+ * in circular dependency detection since they don't block.
48
+ *
49
+ * @param fn The function to run without resolution context
50
+ */ function withoutResolutionContext(fn) {
51
+ return getResolutionContext().run(void 0, fn);
52
+ }
53
+
54
+ //#endregion
55
+ export { getCurrentResolutionContext, withResolutionContext, withoutResolutionContext };
56
+ //# sourceMappingURL=resolution-context.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolution-context.mjs","names":["createAsyncLocalStorage","resolutionContext","getResolutionContext","withResolutionContext","waiterHolder","getHolder","fn","run","getCurrentResolutionContext","getStore","withoutResolutionContext","undefined"],"sources":["../../../../src/internal/context/resolution-context.mts"],"sourcesContent":["import type { InstanceHolder } from '../holder/instance-holder.mjs'\nimport type { IAsyncLocalStorage } from './async-local-storage.types.mjs'\n\nimport { createAsyncLocalStorage } from './async-local-storage.mjs'\n\n/**\n * Data stored in the resolution context during service instantiation.\n */\nexport interface ResolutionContextData {\n /** The holder that is currently being instantiated */\n waiterHolder: InstanceHolder\n /** Function to get a holder by name (for cycle detection) */\n getHolder: (name: string) => InstanceHolder | undefined\n}\n\n/**\n * AsyncLocalStorage for tracking the current resolution context.\n *\n * This allows tracking which service is being instantiated even across\n * async boundaries (like when inject() is called inside a constructor).\n * Essential for circular dependency detection.\n *\n * The actual implementation varies by environment:\n * - Production: No-op (returns undefined, run() just calls fn directly)\n * - Development: Real AsyncLocalStorage with full async tracking\n * - Browser: SyncLocalStorage for synchronous-only tracking\n */\nlet resolutionContext: IAsyncLocalStorage<ResolutionContextData> | null = null\n\nfunction getResolutionContext(): IAsyncLocalStorage<ResolutionContextData> {\n if (!resolutionContext) {\n resolutionContext = createAsyncLocalStorage<ResolutionContextData>()\n }\n return resolutionContext\n}\n\n/**\n * Runs a function within a resolution context.\n *\n * The context tracks which holder is currently being instantiated,\n * allowing circular dependency detection to work correctly.\n *\n * @param waiterHolder The holder being instantiated\n * @param getHolder Function to retrieve holders by name\n * @param fn The function to run within the context\n */\nexport function withResolutionContext<T>(\n waiterHolder: InstanceHolder,\n getHolder: (name: string) => InstanceHolder | undefined,\n fn: () => T,\n): T {\n return getResolutionContext().run({ waiterHolder, getHolder }, fn)\n}\n\n/**\n * Gets the current resolution context, if any.\n *\n * Returns undefined if we're not inside a resolution context\n * (e.g., when resolving a top-level service that has no parent).\n */\nexport function getCurrentResolutionContext():\n | ResolutionContextData\n | undefined {\n return getResolutionContext().getStore()\n}\n\n/**\n * Runs a function outside any resolution context.\n *\n * This is useful for async injections that should not participate\n * in circular dependency detection since they don't block.\n *\n * @param fn The function to run without resolution context\n */\nexport function withoutResolutionContext<T>(fn: () => T): T {\n // Run with undefined context to clear any current context\n return getResolutionContext().run(\n undefined as unknown as ResolutionContextData,\n fn,\n )\n}\n\n"],"mappings":";;;;;;;;;;;;;;GA2BA,IAAIC,oBAAsE;AAE1E,SAASC,uBAAAA;AACP,KAAI,CAACD,kBACHA,qBAAoBD,yBAAAA;AAEtB,QAAOC;;;;;;;;;;;GAaT,SAAgBE,sBACdC,cACAC,WACAC,IAAW;AAEX,QAAOJ,sBAAAA,CAAuBK,IAAI;EAAEH;EAAcC;EAAU,EAAGC,GAAAA;;;;;;;GASjE,SAAgBE,8BAAAA;AAGd,QAAON,sBAAAA,CAAuBO,UAAQ;;;;;;;;;GAWxC,SAAgBC,yBAA4BJ,IAAW;AAErD,QAAOJ,sBAAAA,CAAuBK,IAC5BI,QACAL,GAAAA"}
@@ -0,0 +1,48 @@
1
+ import { IContainer } from "../../interfaces/container.interface.mjs";
2
+ import { InjectableScope } from "../../enums/injectable-scope.enum.mjs";
3
+ import { Injectors } from "../../utils/get-injectors.mjs";
4
+
5
+ //#region src/internal/context/service-initialization-context.d.mts
6
+
7
+ /**
8
+ * Context provided to injectors during service initialization.
9
+ *
10
+ * Extends FactoryContext with additional tracking information about
11
+ * the service being initialized, its dependencies, and scope.
12
+ * Used for scope upgrade tracking and dependency management.
13
+ */
14
+ interface ServiceInitializationContext {
15
+ inject: Injectors['asyncInject'];
16
+ /**
17
+ * The container instance for dependency resolution.
18
+ * This may be either a Container or ScopedContainer.
19
+ */
20
+ container: IContainer;
21
+ addDestroyListener: (listener: () => void) => void;
22
+ getDestroyListeners: () => (() => void)[];
23
+ /**
24
+ * The name of the service being initialized.
25
+ */
26
+ serviceName: string;
27
+ /**
28
+ * Set of dependency names that this service depends on.
29
+ * Automatically populated as dependencies are resolved.
30
+ */
31
+ dependencies: Set<string>;
32
+ /**
33
+ * The scope of the service being initialized.
34
+ */
35
+ scope: InjectableScope;
36
+ /**
37
+ * Track a dependency that was resolved.
38
+ * Used for scope upgrade tracking - if a Singleton service
39
+ * resolves a Request dependency, the scope can be upgraded.
40
+ *
41
+ * @param name The name of the dependency
42
+ * @param scope The scope of the dependency
43
+ */
44
+ trackDependency(name: string, scope: InjectableScope): void;
45
+ }
46
+ //#endregion
47
+ export { ServiceInitializationContext };
48
+ //# sourceMappingURL=service-initialization-context.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-initialization-context.d.mts","names":[],"sources":["../../../../src/internal/context/service-initialization-context.mts"],"sourcesContent":[],"mappings":";;;;;;;;AAWA;;;;;AA8BuC,UA9BtB,4BAAA,CA8BsB;EAAe,MAAA,EA7B5C,SA6B4C,CAAA,aAAA,CAAA;;;;;aAxBzC;;;;;;;;;;;gBAWG;;;;SAIP;;;;;;;;;uCAS8B"}
@@ -0,0 +1,53 @@
1
+ //#region src/internal/context/sync-local-storage.mts
2
+ /**
3
+ * A synchronous-only polyfill for AsyncLocalStorage.
4
+ *
5
+ * This provides the same API as Node's AsyncLocalStorage but only works
6
+ * for synchronous code paths. It uses a simple stack-based approach.
7
+ *
8
+ * Limitations:
9
+ * - Context does NOT propagate across async boundaries (setTimeout, promises, etc.)
10
+ * - Only suitable for environments where DI resolution is synchronous
11
+ *
12
+ * This is acceptable for browser environments where:
13
+ * 1. Constructors are typically synchronous
14
+ * 2. Circular dependency detection mainly needs sync tracking
15
+ */
16
+ var SyncLocalStorage = class {
17
+ stack = [];
18
+ /**
19
+ * Runs a function within the given store context.
20
+ * The context is only available synchronously within the function.
21
+ */
22
+ run(store, fn) {
23
+ this.stack.push(store);
24
+ try {
25
+ return fn();
26
+ } finally {
27
+ this.stack.pop();
28
+ }
29
+ }
30
+ /**
31
+ * Gets the current store value, or undefined if not in a context.
32
+ */
33
+ getStore() {
34
+ return this.stack.length > 0 ? this.stack[this.stack.length - 1] : void 0;
35
+ }
36
+ /**
37
+ * Exits the current context and runs the function without any store.
38
+ * This matches AsyncLocalStorage.exit() behavior.
39
+ */
40
+ exit(fn) {
41
+ const savedStack = this.stack;
42
+ this.stack = [];
43
+ try {
44
+ return fn();
45
+ } finally {
46
+ this.stack = savedStack;
47
+ }
48
+ }
49
+ };
50
+
51
+ //#endregion
52
+ export { SyncLocalStorage };
53
+ //# sourceMappingURL=sync-local-storage.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync-local-storage.mjs","names":[],"sources":["../../../../src/internal/context/sync-local-storage.mts"],"sourcesContent":["import type { IAsyncLocalStorage } from './async-local-storage.types.mjs'\n\n/**\n * A synchronous-only polyfill for AsyncLocalStorage.\n *\n * This provides the same API as Node's AsyncLocalStorage but only works\n * for synchronous code paths. It uses a simple stack-based approach.\n *\n * Limitations:\n * - Context does NOT propagate across async boundaries (setTimeout, promises, etc.)\n * - Only suitable for environments where DI resolution is synchronous\n *\n * This is acceptable for browser environments where:\n * 1. Constructors are typically synchronous\n * 2. Circular dependency detection mainly needs sync tracking\n */\nexport class SyncLocalStorage<T> implements IAsyncLocalStorage<T> {\n private stack: T[] = []\n\n /**\n * Runs a function within the given store context.\n * The context is only available synchronously within the function.\n */\n run<R>(store: T, fn: () => R): R {\n this.stack.push(store)\n try {\n return fn()\n } finally {\n this.stack.pop()\n }\n }\n\n /**\n * Gets the current store value, or undefined if not in a context.\n */\n getStore(): T | undefined {\n return this.stack.length > 0 ? this.stack[this.stack.length - 1] : undefined\n }\n\n /**\n * Exits the current context and runs the function without any store.\n * This matches AsyncLocalStorage.exit() behavior.\n */\n exit<R>(fn: () => R): R {\n const savedStack = this.stack\n this.stack = []\n try {\n return fn()\n } finally {\n this.stack = savedStack\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAgBA,IAAa,mBAAb,MAAkE;CAChE,AAAQ,QAAa,EAAE;;;;;CAMvB,IAAO,OAAU,IAAgB;AAC/B,OAAK,MAAM,KAAK,MAAM;AACtB,MAAI;AACF,UAAO,IAAI;YACH;AACR,QAAK,MAAM,KAAK;;;;;;CAOpB,WAA0B;AACxB,SAAO,KAAK,MAAM,SAAS,IAAI,KAAK,MAAM,KAAK,MAAM,SAAS,KAAK;;;;;;CAOrE,KAAQ,IAAgB;EACtB,MAAM,aAAa,KAAK;AACxB,OAAK,QAAQ,EAAE;AACf,MAAI;AACF,UAAO,IAAI;YACH;AACR,QAAK,QAAQ"}
@@ -0,0 +1,119 @@
1
+ import { AnyInjectableType } from "../../token/injection-token.mjs";
2
+ import { IContainer } from "../../interfaces/container.interface.mjs";
3
+ import { Registry } from "../../token/registry.mjs";
4
+ import { NameResolver } from "./name-resolver.mjs";
5
+ import { DIError } from "../../errors/di-error.mjs";
6
+ import { IHolderStorage } from "../holder/holder-storage.interface.mjs";
7
+ import { LifecycleEventBus } from "../lifecycle/lifecycle-event-bus.mjs";
8
+ import { ServiceInvalidator } from "./service-invalidator.mjs";
9
+ import { TokenResolver } from "./token-resolver.mjs";
10
+ import { ScopedContainer } from "../../container/scoped-container.mjs";
11
+ import { ScopeTracker } from "./scope-tracker.mjs";
12
+ import { ServiceInitializer } from "./service-initializer.mjs";
13
+
14
+ //#region src/internal/core/instance-resolver.d.mts
15
+
16
+ /**
17
+ * Resolves instances from tokens, handling caching, creation, and scope rules.
18
+ *
19
+ * Uses unified storage for both singleton and request-scoped services.
20
+ * Coordinates with ServiceInitializer for actual service creation.
21
+ * Integrates ScopeTracker for automatic scope upgrades.
22
+ */
23
+ declare class InstanceResolver {
24
+ private readonly registry;
25
+ private readonly storage;
26
+ private readonly serviceInitializer;
27
+ private readonly tokenResolver;
28
+ private readonly nameResolver;
29
+ private readonly scopeTracker;
30
+ private readonly serviceInvalidator;
31
+ private readonly eventBus;
32
+ private readonly logger;
33
+ constructor(registry: Registry, storage: IHolderStorage, serviceInitializer: ServiceInitializer, tokenResolver: TokenResolver, nameResolver: NameResolver, scopeTracker: ScopeTracker, serviceInvalidator: ServiceInvalidator, eventBus: LifecycleEventBus, logger?: Console | null);
34
+ /**
35
+ * Resolves an instance for the given token and arguments.
36
+ * This method is used for singleton and transient services.
37
+ *
38
+ * @param token The injection token
39
+ * @param args Optional arguments
40
+ * @param contextContainer The container to use for creating context
41
+ * @param requestStorage Optional request storage (for scope upgrades)
42
+ * @param requestId Optional request ID (for scope upgrades)
43
+ */
44
+ resolveInstance(token: AnyInjectableType, args: any, contextContainer: IContainer, requestStorage?: IHolderStorage, requestId?: string): Promise<[undefined, any] | [DIError]>;
45
+ /**
46
+ * Resolves a request-scoped instance for a ScopedContainer.
47
+ * The service will be stored in the ScopedContainer's request storage.
48
+ *
49
+ * @param token The injection token
50
+ * @param args Optional arguments
51
+ * @param scopedContainer The ScopedContainer that owns the request context
52
+ */
53
+ resolveRequestScopedInstance(token: AnyInjectableType, args: any, scopedContainer: ScopedContainer): Promise<[undefined, any] | [DIError]>;
54
+ /**
55
+ * Unified resolution method that works with any IHolderStorage.
56
+ * This eliminates duplication between singleton and request-scoped resolution.
57
+ *
58
+ * IMPORTANT: The check-and-store logic is carefully designed to avoid race conditions.
59
+ * The storage check and holder creation must happen synchronously (no awaits between).
60
+ *
61
+ * @param token The injection token
62
+ * @param args Optional arguments
63
+ * @param contextContainer The container for context
64
+ * @param storage The storage strategy to use
65
+ * @param scopedContainer Optional scoped container for request-scoped services
66
+ * @param requestStorage Optional request storage (for scope upgrades)
67
+ * @param requestId Optional request ID (for scope upgrades)
68
+ */
69
+ private resolveWithStorage;
70
+ /**
71
+ * Internal method to resolve token args and create instance name.
72
+ * Handles factory token resolution and validation.
73
+ */
74
+ private resolveTokenAndPrepareInstanceName;
75
+ /**
76
+ * Handles storage error states (destroying, error, etc.).
77
+ * Returns a result if handled, null if should proceed with creation.
78
+ */
79
+ private handleStorageError;
80
+ /**
81
+ * Creates a new instance and stores it using the provided storage strategy.
82
+ * This unified method replaces instantiateServiceFromRegistry and createRequestScopedInstance.
83
+ *
84
+ * For transient services, the instance is created but not stored (no caching).
85
+ */
86
+ private createAndStoreInstance;
87
+ /**
88
+ * Creates a transient instance without storage or locking.
89
+ * Each call creates a new instance.
90
+ */
91
+ private createTransientInstance;
92
+ /**
93
+ * Handles successful service instantiation.
94
+ */
95
+ private handleInstantiationSuccess;
96
+ /**
97
+ * Handles service instantiation errors.
98
+ */
99
+ private handleInstantiationError;
100
+ /**
101
+ * Handles instantiation result (success or error).
102
+ */
103
+ private handleInstantiationResult;
104
+ /**
105
+ * Waits for an instance holder to be ready and returns the appropriate result.
106
+ *
107
+ * @param holder The holder to wait for
108
+ * @param waiterHolder Optional holder that is doing the waiting (for circular dependency detection)
109
+ * @param getHolder Optional function to retrieve holders by name (required if waiterHolder is provided)
110
+ */
111
+ private waitForInstanceReady;
112
+ /**
113
+ * Creates a ServiceInitializationContext for service instantiation.
114
+ */
115
+ private createServiceInitializationContext;
116
+ }
117
+ //#endregion
118
+ export { InstanceResolver };
119
+ //# sourceMappingURL=instance-resolver.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instance-resolver.d.mts","names":[],"sources":["../../../../src/internal/core/instance-resolver.mts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;AAuCA;;;;;AAMmC,cANtB,gBAAA,CAMsB;EACA,iBAAA,QAAA;EACM,iBAAA,OAAA;EACV,iBAAA,kBAAA;EACF,iBAAA,aAAA;EAkBlB,iBAAA,YAAA;EAEW,iBAAA,YAAA;EACD,iBAAA,kBAAA;EAEY,iBAAA,QAAA;EAA5B,iBAAA,MAAA;EAqBM,WAAA,CAAA,QAAA,EApDoB,QAoDpB,EAAA,OAAA,EAnDmB,cAmDnB,EAAA,kBAAA,EAlD8B,kBAkD9B,EAAA,aAAA,EAjDyB,aAiDzB,EAAA,YAAA,EAhDwB,YAgDxB,EAAA,YAAA,EA/CwB,YA+CxB,EAAA,kBAAA,EA9C8B,kBA8C9B,EAAA,QAAA,EA7CoB,iBA6CpB,EAAA,MAAA,CAAA,EA5CkB,OA4ClB,GAAA,IAAA;EAEU;;;;;;;;;;yBA5BV,gDAEW,6BACD,qCAEhB,4BAA4B;;;;;;;;;sCAqBtB,+CAEU,kBAChB,4BAA4B"}