ts-ioc-container 72.1.0 → 72.2.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 (228) hide show
  1. package/AGENTS.md +179 -0
  2. package/cjm/container/Container.js +2 -2
  3. package/cjm/container/EmptyContainer.js +17 -15
  4. package/cjm/errors/ArgumentNotFoundError.js +1 -0
  5. package/cjm/errors/CannonSingletonApplyTwiceError.js +2 -14
  6. package/cjm/errors/CannotApplySingletonTwiceError.js +18 -0
  7. package/cjm/errors/ContainerDisposedError.js +1 -0
  8. package/cjm/errors/ContainerError.js +1 -0
  9. package/cjm/errors/ContainerNotFoundError.js +1 -0
  10. package/cjm/errors/DependencyMissingKeyError.js +1 -0
  11. package/cjm/errors/DependencyNotFoundError.js +1 -0
  12. package/cjm/errors/MethodNotImplementedError.js +1 -0
  13. package/cjm/errors/ProviderDisposedError.js +1 -0
  14. package/cjm/errors/TypedEventDisposedError.js +1 -0
  15. package/cjm/errors/UnsupportedTokenTypeError.js +1 -0
  16. package/cjm/index.js +5 -3
  17. package/cjm/provider/Provider.js +6 -6
  18. package/cjm/registration/Registration.js +2 -2
  19. package/cjm/token/ConstantToken.js +4 -4
  20. package/cjm/token/FunctionToken.js +1 -1
  21. package/cjm/token/GroupInstanceToken.js +4 -4
  22. package/cjm/token/toToken.js +1 -1
  23. package/cjm/utils/TypedEvent.js +1 -1
  24. package/cjm/utils/array.js +1 -1
  25. package/esm/container/Container.js +2 -2
  26. package/esm/container/EmptyContainer.js +17 -15
  27. package/esm/errors/ArgumentNotFoundError.js +1 -0
  28. package/esm/errors/CannonSingletonApplyTwiceError.js +2 -13
  29. package/esm/errors/CannotApplySingletonTwiceError.js +14 -0
  30. package/esm/errors/ContainerDisposedError.js +1 -0
  31. package/esm/errors/ContainerError.js +1 -0
  32. package/esm/errors/ContainerNotFoundError.js +1 -0
  33. package/esm/errors/DependencyMissingKeyError.js +1 -0
  34. package/esm/errors/DependencyNotFoundError.js +1 -0
  35. package/esm/errors/MethodNotImplementedError.js +1 -0
  36. package/esm/errors/ProviderDisposedError.js +1 -0
  37. package/esm/errors/TypedEventDisposedError.js +1 -0
  38. package/esm/errors/UnsupportedTokenTypeError.js +1 -0
  39. package/esm/index.js +1 -0
  40. package/esm/provider/Provider.js +6 -6
  41. package/esm/registration/Registration.js +2 -2
  42. package/esm/token/ConstantToken.js +4 -4
  43. package/esm/token/FunctionToken.js +1 -1
  44. package/esm/token/GroupInstanceToken.js +4 -4
  45. package/esm/token/toToken.js +1 -1
  46. package/esm/utils/TypedEvent.js +1 -1
  47. package/esm/utils/array.js +1 -1
  48. package/lib/ExecutionContext.ts +6 -0
  49. package/lib/container/AliasMap.ts +30 -0
  50. package/lib/container/AutoResolveModule.ts +24 -0
  51. package/lib/container/Container.ts +311 -0
  52. package/lib/container/EmptyContainer.ts +166 -0
  53. package/lib/container/IContainer.ts +156 -0
  54. package/lib/errors/ArgumentNotFoundError.ts +13 -0
  55. package/lib/errors/CannonSingletonApplyTwiceError.ts +6 -0
  56. package/lib/errors/CannotApplySingletonTwiceError.ts +22 -0
  57. package/lib/errors/ContainerDisposedError.ts +13 -0
  58. package/lib/errors/ContainerError.ts +15 -0
  59. package/lib/errors/ContainerNotFoundError.ts +13 -0
  60. package/lib/errors/DependencyMissingKeyError.ts +13 -0
  61. package/lib/errors/DependencyNotFoundError.ts +13 -0
  62. package/lib/errors/MethodNotImplementedError.ts +13 -0
  63. package/lib/errors/ProviderDisposedError.ts +22 -0
  64. package/lib/errors/TypedEventDisposedError.ts +22 -0
  65. package/lib/errors/UnsupportedTokenTypeError.ts +13 -0
  66. package/lib/hooks/HookCollector.ts +109 -0
  67. package/lib/hooks/HookContext.ts +85 -0
  68. package/lib/hooks/combinators.ts +51 -0
  69. package/lib/hooks/hook.ts +89 -0
  70. package/lib/hooks/injectProp.ts +14 -0
  71. package/lib/index.ts +181 -0
  72. package/lib/injector/IInjector.ts +88 -0
  73. package/lib/injector/MetadataInjector.ts +100 -0
  74. package/lib/injector/ProxyInjector.ts +31 -0
  75. package/lib/injector/SimpleInjector.ts +20 -0
  76. package/lib/metadata/class.ts +50 -0
  77. package/lib/metadata/method.ts +47 -0
  78. package/lib/metadata/parameter.ts +60 -0
  79. package/lib/metadata/target.ts +25 -0
  80. package/lib/provider/IProvider.ts +65 -0
  81. package/lib/provider/Provider.ts +174 -0
  82. package/lib/registration/IRegistration.ts +235 -0
  83. package/lib/registration/Registration.ts +122 -0
  84. package/lib/select.ts +33 -0
  85. package/lib/token/BindToken.ts +13 -0
  86. package/lib/token/ClassToken.ts +72 -0
  87. package/lib/token/ConstantToken.ts +50 -0
  88. package/lib/token/FunctionToken.ts +79 -0
  89. package/lib/token/GroupAliasToken.ts +92 -0
  90. package/lib/token/GroupInstanceToken.ts +70 -0
  91. package/lib/token/InjectionToken.ts +46 -0
  92. package/lib/token/SingleAliasToken.ts +84 -0
  93. package/lib/token/SingleToken.ts +93 -0
  94. package/lib/token/toToken.ts +46 -0
  95. package/lib/utils/ProxyRegistry.ts +149 -0
  96. package/lib/utils/TypedEvent.ts +96 -0
  97. package/lib/utils/array.ts +28 -0
  98. package/lib/utils/basic.ts +34 -0
  99. package/lib/utils/debounce.ts +18 -0
  100. package/lib/utils/errorHandler.ts +34 -0
  101. package/lib/utils/fp.ts +86 -0
  102. package/lib/utils/getConstructorChain.ts +17 -0
  103. package/lib/utils/memoize.ts +24 -0
  104. package/lib/utils/once.ts +24 -0
  105. package/lib/utils/shallowCache.ts +22 -0
  106. package/lib/utils/task.ts +33 -0
  107. package/lib/utils/throttle.ts +17 -0
  108. package/package.json +5 -3
  109. package/typings/ExecutionContext.d.ts +2 -0
  110. package/typings/ExecutionContext.d.ts.map +1 -0
  111. package/typings/container/AliasMap.d.ts +1 -0
  112. package/typings/container/AliasMap.d.ts.map +1 -0
  113. package/typings/container/AutoResolveModule.d.ts +16 -0
  114. package/typings/container/AutoResolveModule.d.ts.map +1 -0
  115. package/typings/container/Container.d.ts +60 -0
  116. package/typings/container/Container.d.ts.map +1 -0
  117. package/typings/container/EmptyContainer.d.ts +51 -0
  118. package/typings/container/EmptyContainer.d.ts.map +1 -0
  119. package/typings/container/IContainer.d.ts +75 -0
  120. package/typings/container/IContainer.d.ts.map +1 -0
  121. package/typings/errors/ArgumentNotFoundError.d.ts +3 -0
  122. package/typings/errors/ArgumentNotFoundError.d.ts.map +1 -0
  123. package/typings/errors/CannonSingletonApplyTwiceError.d.ts +6 -6
  124. package/typings/errors/CannonSingletonApplyTwiceError.d.ts.map +1 -0
  125. package/typings/errors/CannotApplySingletonTwiceError.d.ts +12 -0
  126. package/typings/errors/CannotApplySingletonTwiceError.d.ts.map +1 -0
  127. package/typings/errors/ContainerDisposedError.d.ts +3 -0
  128. package/typings/errors/ContainerDisposedError.d.ts.map +1 -0
  129. package/typings/errors/ContainerError.d.ts +7 -0
  130. package/typings/errors/ContainerError.d.ts.map +1 -0
  131. package/typings/errors/ContainerNotFoundError.d.ts +3 -0
  132. package/typings/errors/ContainerNotFoundError.d.ts.map +1 -0
  133. package/typings/errors/DependencyMissingKeyError.d.ts +3 -0
  134. package/typings/errors/DependencyMissingKeyError.d.ts.map +1 -0
  135. package/typings/errors/DependencyNotFoundError.d.ts +3 -0
  136. package/typings/errors/DependencyNotFoundError.d.ts.map +1 -0
  137. package/typings/errors/MethodNotImplementedError.d.ts +3 -0
  138. package/typings/errors/MethodNotImplementedError.d.ts.map +1 -0
  139. package/typings/errors/ProviderDisposedError.d.ts +6 -0
  140. package/typings/errors/ProviderDisposedError.d.ts.map +1 -0
  141. package/typings/errors/TypedEventDisposedError.d.ts +6 -0
  142. package/typings/errors/TypedEventDisposedError.d.ts.map +1 -0
  143. package/typings/errors/UnsupportedTokenTypeError.d.ts +3 -0
  144. package/typings/errors/UnsupportedTokenTypeError.d.ts.map +1 -0
  145. package/typings/hooks/HookCollector.d.ts +36 -0
  146. package/typings/hooks/HookCollector.d.ts.map +1 -0
  147. package/typings/hooks/HookContext.d.ts +10 -0
  148. package/typings/hooks/HookContext.d.ts.map +1 -0
  149. package/typings/hooks/combinators.d.ts +23 -0
  150. package/typings/hooks/combinators.d.ts.map +1 -0
  151. package/typings/hooks/hook.d.ts +39 -0
  152. package/typings/hooks/hook.d.ts.map +1 -0
  153. package/typings/hooks/injectProp.d.ts +9 -0
  154. package/typings/hooks/injectProp.d.ts.map +1 -0
  155. package/typings/index.d.ts +2 -0
  156. package/typings/index.d.ts.map +1 -0
  157. package/typings/injector/IInjector.d.ts +32 -0
  158. package/typings/injector/IInjector.d.ts.map +1 -0
  159. package/typings/injector/MetadataInjector.d.ts +58 -0
  160. package/typings/injector/MetadataInjector.d.ts.map +1 -0
  161. package/typings/injector/ProxyInjector.d.ts +13 -0
  162. package/typings/injector/ProxyInjector.d.ts.map +1 -0
  163. package/typings/injector/SimpleInjector.d.ts +13 -0
  164. package/typings/injector/SimpleInjector.d.ts.map +1 -0
  165. package/typings/metadata/class.d.ts +27 -0
  166. package/typings/metadata/class.d.ts.map +1 -0
  167. package/typings/metadata/method.d.ts +24 -0
  168. package/typings/metadata/method.d.ts.map +1 -0
  169. package/typings/metadata/parameter.d.ts +21 -0
  170. package/typings/metadata/parameter.d.ts.map +1 -0
  171. package/typings/metadata/target.d.ts +19 -0
  172. package/typings/metadata/target.d.ts.map +1 -0
  173. package/typings/provider/IProvider.d.ts +25 -0
  174. package/typings/provider/IProvider.d.ts.map +1 -0
  175. package/typings/provider/Provider.d.ts +30 -0
  176. package/typings/provider/Provider.d.ts.map +1 -0
  177. package/typings/registration/IRegistration.d.ts +137 -0
  178. package/typings/registration/IRegistration.d.ts.map +1 -0
  179. package/typings/registration/Registration.d.ts +23 -0
  180. package/typings/registration/Registration.d.ts.map +1 -0
  181. package/typings/select.d.ts +15 -0
  182. package/typings/select.d.ts.map +1 -0
  183. package/typings/token/BindToken.d.ts +3 -0
  184. package/typings/token/BindToken.d.ts.map +1 -0
  185. package/typings/token/ClassToken.d.ts +2 -0
  186. package/typings/token/ClassToken.d.ts.map +1 -0
  187. package/typings/token/ConstantToken.d.ts +14 -0
  188. package/typings/token/ConstantToken.d.ts.map +1 -0
  189. package/typings/token/FunctionToken.d.ts +10 -0
  190. package/typings/token/FunctionToken.d.ts.map +1 -0
  191. package/typings/token/GroupAliasToken.d.ts +14 -0
  192. package/typings/token/GroupAliasToken.d.ts.map +1 -0
  193. package/typings/token/GroupInstanceToken.d.ts +19 -0
  194. package/typings/token/GroupInstanceToken.d.ts.map +1 -0
  195. package/typings/token/InjectionToken.d.ts +8 -0
  196. package/typings/token/InjectionToken.d.ts.map +1 -0
  197. package/typings/token/SingleAliasToken.d.ts +6 -0
  198. package/typings/token/SingleAliasToken.d.ts.map +1 -0
  199. package/typings/token/SingleToken.d.ts +18 -0
  200. package/typings/token/SingleToken.d.ts.map +1 -0
  201. package/typings/token/toToken.d.ts +12 -0
  202. package/typings/token/toToken.d.ts.map +1 -0
  203. package/typings/utils/ProxyRegistry.d.ts +63 -0
  204. package/typings/utils/ProxyRegistry.d.ts.map +1 -0
  205. package/typings/utils/TypedEvent.d.ts +42 -0
  206. package/typings/utils/TypedEvent.d.ts.map +1 -0
  207. package/typings/utils/array.d.ts +7 -0
  208. package/typings/utils/array.d.ts.map +1 -0
  209. package/typings/utils/basic.d.ts +12 -0
  210. package/typings/utils/basic.d.ts.map +1 -0
  211. package/typings/utils/debounce.d.ts +2 -0
  212. package/typings/utils/debounce.d.ts.map +1 -0
  213. package/typings/utils/errorHandler.d.ts +4 -0
  214. package/typings/utils/errorHandler.d.ts.map +1 -0
  215. package/typings/utils/fp.d.ts +8 -0
  216. package/typings/utils/fp.d.ts.map +1 -0
  217. package/typings/utils/getConstructorChain.d.ts +9 -0
  218. package/typings/utils/getConstructorChain.d.ts.map +1 -0
  219. package/typings/utils/memoize.d.ts +10 -0
  220. package/typings/utils/memoize.d.ts.map +1 -0
  221. package/typings/utils/once.d.ts +2 -0
  222. package/typings/utils/once.d.ts.map +1 -0
  223. package/typings/utils/shallowCache.d.ts +2 -0
  224. package/typings/utils/shallowCache.d.ts.map +1 -0
  225. package/typings/utils/task.d.ts +13 -0
  226. package/typings/utils/task.d.ts.map +1 -0
  227. package/typings/utils/throttle.d.ts +2 -0
  228. package/typings/utils/throttle.d.ts.map +1 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IContainer.d.ts","sourceRoot":"","sources":["../../lib/container/IContainer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,KAAK,WAAW,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,gDAAgD;AAChD,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,CAAC;AAC5C,mDAAmD;AACnD,wBAAgB,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,aAAa,CAExE;AAED,uFAAuF;AACvF,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC;AACzB,KAAK,QAAQ,GAAG;IAAE,IAAI,EAAE,GAAG,EAAE,CAAA;CAAE,CAAC;AAChC,KAAK,SAAS,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AACnC,KAAK,gBAAgB,GAAG;IAAE,YAAY,EAAE,aAAa,EAAE,CAAA;CAAE,CAAC;AAC1D,mDAAmD;AACnD,MAAM,WAAW,MAAM;IACrB,MAAM,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC;IAC1B,OAAO,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;CAC/B;AAED,oFAAoF;AACpF,MAAM,MAAM,iBAAiB,GAAG,cAAc,GAAG,O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AW,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC;IAEzC,0HAA0H;IAC1H,OAAO,IAAI,IAAI,CAAC;IAEhB,gEAAgE;IAChE,WAAW,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IAEtC,oFAAoF;IACpF,WAAW,IAAI,SAAS,CAAC;CAC1B"}
@@ -1,5 +1,8 @@
1
1
  import { ContainerError } from './ContainerError.js';
2
+ /** Thrown by `findOrFail` when no runtime arg matches the predicate. Code `IOC_ARGUMENT_NOT_FOUND`. */
2
3
  export declare class ArgumentNotFoundError extends ContainerError {
3
4
  name: string;
5
+ readonly code = "IOC_ARGUMENT_NOT_FOUND";
4
6
  constructor(message?: string);
5
7
  }
8
+ //# sourceMappingURL=ArgumentNotFoundError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ArgumentNotFoundError.d.ts","sourceRoot":"","sources":["../../lib/errors/ArgumentNotFoundError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,uGAAuG;AACvG,qBAAa,qBAAsB,SAAQ,cAAc;IACvD,IAAI,SAA2B;IAC/B,QAAQ,CAAC,IAAI,4BAA4B;gBAE7B,OAAO,SAAuB;CAK3C"}
@@ -1,6 +1,6 @@
1
- import { ContainerError } from './ContainerError.js';
2
- export declare class CannonSingletonApplyTwiceError extends ContainerError {
3
- name: string;
4
- constructor(message?: string);
5
- static assert(isTrue: boolean, failMessage: string): void;
6
- }
1
+ import { CannotApplySingletonTwiceError } from './CannotApplySingletonTwiceError.js';
2
+ /** @deprecated Misspelled name kept for compatibility. Use {@link CannotApplySingletonTwiceError}. */
3
+ export declare const CannonSingletonApplyTwiceError: typeof CannotApplySingletonTwiceError;
4
+ /** @deprecated Misspelled name kept for compatibility. Use {@link CannotApplySingletonTwiceError}. */
5
+ export type CannonSingletonApplyTwiceError = CannotApplySingletonTwiceError;
6
+ //# sourceMappingURL=CannonSingletonApplyTwiceError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CannonSingletonApplyTwiceError.d.ts","sourceRoot":"","sources":["../../lib/errors/CannonSingletonApplyTwiceError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAElF,sGAAsG;AACtG,eAAO,MAAM,8BAA8B,uCAAiC,CAAC;AAC7E,sGAAsG;AACtG,MAAM,MAAM,8BAA8B,GAAG,8BAA8B,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { ContainerError } from './ContainerError.js';
2
+ /** Thrown when `singleton()` is applied twice to one provider. Code `IOC_SINGLETON_APPLIED_TWICE`. */
3
+ export declare class CannotApplySingletonTwiceError extends ContainerError {
4
+ name: string;
5
+ readonly code = "IOC_SINGLETON_APPLIED_TWICE";
6
+ constructor(message?: string);
7
+ /**
8
+ * @throws {CannotApplySingletonTwiceError} when `isTrue` is falsy.
9
+ */
10
+ static assert(isTrue: boolean, failMessage: string): void;
11
+ }
12
+ //# sourceMappingURL=CannotApplySingletonTwiceError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CannotApplySingletonTwiceError.d.ts","sourceRoot":"","sources":["../../lib/errors/CannotApplySingletonTwiceError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,sGAAsG;AACtG,qBAAa,8BAA+B,SAAQ,cAAc;IAChE,IAAI,SAAoC;IACxC,QAAQ,CAAC,IAAI,iCAAiC;gBAElC,OAAO,CAAC,EAAE,MAAM;IAM5B;;OAEG;IACH,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM;CAKnD"}
@@ -1,5 +1,8 @@
1
1
  import { ContainerError } from './ContainerError.js';
2
+ /** Thrown when a disposed scope is used. Code `IOC_CONTAINER_DISPOSED`. */
2
3
  export declare class ContainerDisposedError extends ContainerError {
3
4
  name: string;
5
+ readonly code = "IOC_CONTAINER_DISPOSED";
4
6
  constructor(message: string);
5
7
  }
8
+ //# sourceMappingURL=ContainerDisposedError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContainerDisposedError.d.ts","sourceRoot":"","sources":["../../lib/errors/ContainerDisposedError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,2EAA2E;AAC3E,qBAAa,sBAAuB,SAAQ,cAAc;IACxD,IAAI,SAA4B;IAChC,QAAQ,CAAC,IAAI,4BAA4B;gBAE7B,OAAO,EAAE,MAAM;CAK5B"}
@@ -1,4 +1,11 @@
1
+ /**
2
+ * Base class of every error the container throws. `code` is stable across
3
+ * versions (unlike `message`), so match on it — or on the subclass — rather
4
+ * than on the text. The codes are listed in the package's AGENTS.md.
5
+ */
1
6
  export declare abstract class ContainerError extends Error {
2
7
  name: string;
8
+ readonly code: string;
3
9
  protected constructor(message?: string);
4
10
  }
11
+ //# sourceMappingURL=ContainerError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContainerError.d.ts","sourceRoot":"","sources":["../../lib/errors/ContainerError.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,8BAAsB,cAAe,SAAQ,KAAK;IAChD,IAAI,SAAoB;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAyB;IAE9C,SAAS,aAAa,OAAO,CAAC,EAAE,MAAM;CAKvC"}
@@ -1,5 +1,8 @@
1
1
  import { ContainerError } from './ContainerError.js';
2
+ /** Signals that no container is associated with a target. Code `IOC_CONTAINER_NOT_FOUND`. */
2
3
  export declare class ContainerNotFoundError extends ContainerError {
3
4
  name: string;
5
+ readonly code = "IOC_CONTAINER_NOT_FOUND";
4
6
  constructor(message: string);
5
7
  }
8
+ //# sourceMappingURL=ContainerNotFoundError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContainerNotFoundError.d.ts","sourceRoot":"","sources":["../../lib/errors/ContainerNotFoundError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,6FAA6F;AAC7F,qBAAa,sBAAuB,SAAQ,cAAc;IACxD,IAAI,SAA4B;IAChC,QAAQ,CAAC,IAAI,6BAA6B;gBAE9B,OAAO,EAAE,MAAM;CAK5B"}
@@ -1,5 +1,8 @@
1
1
  import { ContainerError } from './ContainerError.js';
2
+ /** Thrown when a registration has no binding key. Code `IOC_DEPENDENCY_MISSING_KEY`. */
2
3
  export declare class DependencyMissingKeyError extends ContainerError {
3
4
  name: string;
5
+ readonly code = "IOC_DEPENDENCY_MISSING_KEY";
4
6
  constructor(message: string);
5
7
  }
8
+ //# sourceMappingURL=DependencyMissingKeyError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DependencyMissingKeyError.d.ts","sourceRoot":"","sources":["../../lib/errors/DependencyMissingKeyError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,wFAAwF;AACxF,qBAAa,yBAA0B,SAAQ,cAAc;IAC3D,IAAI,SAA+B;IACnC,QAAQ,CAAC,IAAI,gCAAgC;gBAEjC,OAAO,EAAE,MAAM;CAK5B"}
@@ -1,5 +1,8 @@
1
1
  import { ContainerError } from './ContainerError.js';
2
+ /** Thrown when a key or alias is not found in the scope or any parent. Code `IOC_DEPENDENCY_NOT_FOUND`. */
2
3
  export declare class DependencyNotFoundError extends ContainerError {
3
4
  name: string;
5
+ readonly code = "IOC_DEPENDENCY_NOT_FOUND";
4
6
  constructor(message: string);
5
7
  }
8
+ //# sourceMappingURL=DependencyNotFoundError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DependencyNotFoundError.d.ts","sourceRoot":"","sources":["../../lib/errors/DependencyNotFoundError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,2GAA2G;AAC3G,qBAAa,uBAAwB,SAAQ,cAAc;IACzD,IAAI,SAA6B;IACjC,QAAQ,CAAC,IAAI,8BAA8B;gBAE/B,OAAO,EAAE,MAAM;CAK5B"}
@@ -1,5 +1,8 @@
1
1
  import { ContainerError } from './ContainerError.js';
2
+ /** Thrown by a method the object does not support; the message names the class and method. Code `IOC_METHOD_NOT_IMPLEMENTED`. */
2
3
  export declare class MethodNotImplementedError extends ContainerError {
3
4
  name: string;
5
+ readonly code = "IOC_METHOD_NOT_IMPLEMENTED";
4
6
  constructor(message?: string);
5
7
  }
8
+ //# sourceMappingURL=MethodNotImplementedError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MethodNotImplementedError.d.ts","sourceRoot":"","sources":["../../lib/errors/MethodNotImplementedError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,iIAAiI;AACjI,qBAAa,yBAA0B,SAAQ,cAAc;IAC3D,IAAI,SAA+B;IACnC,QAAQ,CAAC,IAAI,gCAAgC;gBAEjC,OAAO,CAAC,EAAE,MAAM;CAK7B"}
@@ -1,6 +1,12 @@
1
1
  import { ContainerError } from './ContainerError.js';
2
+ /** Thrown when a provider of a disposed scope is used. Code `IOC_PROVIDER_DISPOSED`. */
2
3
  export declare class ProviderDisposedError extends ContainerError {
3
4
  name: string;
5
+ readonly code = "IOC_PROVIDER_DISPOSED";
6
+ /**
7
+ * @throws {ProviderDisposedError} when `isTrue` is falsy.
8
+ */
4
9
  static assert(isTrue: boolean, failMessage: string): void;
5
10
  constructor(message: string);
6
11
  }
12
+ //# sourceMappingURL=ProviderDisposedError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProviderDisposedError.d.ts","sourceRoot":"","sources":["../../lib/errors/ProviderDisposedError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,wFAAwF;AACxF,qBAAa,qBAAsB,SAAQ,cAAc;IACvD,IAAI,SAA2B;IAC/B,QAAQ,CAAC,IAAI,2BAA2B;IAExC;;OAEG;IACH,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM;gBAMtC,OAAO,EAAE,MAAM;CAK5B"}
@@ -1,6 +1,12 @@
1
1
  import { ContainerError } from './ContainerError.js';
2
+ /** Thrown when subscribing to an event of a disposed scope. Code `IOC_EVENT_DISPOSED`. */
2
3
  export declare class TypedEventDisposedError extends ContainerError {
3
4
  name: string;
5
+ readonly code = "IOC_EVENT_DISPOSED";
6
+ /**
7
+ * @throws {TypedEventDisposedError} when `isTrue` is falsy.
8
+ */
4
9
  static assert(isTrue: boolean, failMessage: string): void;
5
10
  constructor(message: string);
6
11
  }
12
+ //# sourceMappingURL=TypedEventDisposedError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TypedEventDisposedError.d.ts","sourceRoot":"","sources":["../../lib/errors/TypedEventDisposedError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,0FAA0F;AAC1F,qBAAa,uBAAwB,SAAQ,cAAc;IACzD,IAAI,SAA6B;IACjC,QAAQ,CAAC,IAAI,wBAAwB;IAErC;;OAEG;IACH,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM;gBAMtC,OAAO,EAAE,MAAM;CAK5B"}
@@ -1,5 +1,8 @@
1
1
  import { ContainerError } from './ContainerError.js';
2
+ /** Thrown by `toToken` for a value that is not a token, key, class or function. Code `IOC_UNSUPPORTED_TOKEN_TYPE`. */
2
3
  export declare class UnsupportedTokenTypeError extends ContainerError {
3
4
  name: string;
5
+ readonly code = "IOC_UNSUPPORTED_TOKEN_TYPE";
4
6
  constructor(message: string);
5
7
  }
8
+ //# sourceMappingURL=UnsupportedTokenTypeError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UnsupportedTokenTypeError.d.ts","sourceRoot":"","sources":["../../lib/errors/UnsupportedTokenTypeError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,sHAAsH;AACtH,qBAAa,yBAA0B,SAAQ,cAAc;IAC3D,IAAI,SAA+B;IACnC,QAAQ,CAAC,IAAI,gCAAgC;gBAEjC,OAAO,EAAE,MAAM;CAK5B"}
@@ -3,26 +3,62 @@ import { type Task } from '../utils/task.js';
3
3
  import { type Instance } from '../utils/basic.js';
4
4
  import { type HookFn } from './hook.js';
5
5
  import { type CreateHookExecutionContext, type IHookContext } from './HookContext.js';
6
+ /** Transforms each hook context before it is handed to its hook. */
6
7
  export type MapHookExecutionContext = (context: IHookContext) => IHookContext;
8
+ /**
9
+ * One decorated member's hook, resolved to a function and bound to the context
10
+ * it runs against — the model the library hands back, and the whole of what it
11
+ * says about a hook. The member it came from is `context.methodName`.
12
+ * Performing it is the caller's business (ADR 0016).
13
+ */
7
14
  export type HookAction = {
8
15
  hook: HookFn;
9
16
  context: IHookContext;
10
17
  };
18
+ /**
19
+ * Shapes what is collected: how each action's hook context is built, and which
20
+ * members take part. A collector carries defaults for all three, so a call
21
+ * names only what it overrides.
22
+ */
11
23
  export type HookCollectorOptions = {
12
24
  createExecutionContext?: CreateHookExecutionContext;
13
25
  mapExecutionContext?: MapHookExecutionContext;
14
26
  predicate?: (methodName: string) => boolean;
15
27
  };
28
+ /** What one collection runs in: the scope, plus any per-call overrides of the collector's options. */
16
29
  export type HookCollectionContext = ExecutionContext & HookCollectorOptions;
30
+ /** Options of `new HookCollector(...)`. */
17
31
  export type HookCollectorProps = HookCollectorOptions & {
32
+ /** The hook key this collector reads: `onConstruct`, `onScopeDisposed`, `onResolved`, or a custom one. */
18
33
  key: string | symbol;
19
34
  };
35
+ /**
36
+ * Reads the hooks declared under one key off a target and hands them back as
37
+ * {@link HookAction}s, in declaration order. It runs nothing: what order the
38
+ * actions are performed in, what is awaited and where a failure goes are
39
+ * answered by the caller (ADR 0016).
40
+ *
41
+ * Wire it to whichever event should collect — the injector's `onConstructed`,
42
+ * the scope's `scopeDisposed`, a provider's `onResolved` — the library ships no
43
+ * module which does that for you (ADR 0018).
44
+ *
45
+ * ```typescript
46
+ * const collector = new HookCollector({ key: 'onStart' });
47
+ *
48
+ * container.getInjector().onConstructed((instance, scope) => {
49
+ * runInOrder(collector.getActions(instance, { scope }).map(toTask))?.catch(report);
50
+ * });
51
+ * ```
52
+ */
20
53
  export declare class HookCollector {
21
54
  private readonly key;
22
55
  private readonly options;
23
56
  private readonly hooksOf;
24
57
  constructor({ key, createExecutionContext, mapExecutionContext, predicate, }: HookCollectorProps);
25
58
  hasHooks(target: Instance): boolean;
59
+ /** The actions `target` declares under this collector's key — empty when it declares none. */
26
60
  getActions(target: Instance, { scope, createExecutionContext, mapExecutionContext, predicate, }: HookCollectionContext): HookAction[];
27
61
  }
62
+ /** The {@link Task} an action runs as: `runInOrder(actions.map(toTask))`, `runAtOnce(actions.map(toTask))`. */
28
63
  export declare const toTask: ({ hook, context }: HookAction) => Task;
64
+ //# sourceMappingURL=HookCollector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HookCollector.d.ts","sourceRoot":"","sources":["../../lib/hooks/HookCollector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAsB,KAAK,MAAM,EAAY,MAAM,QAAQ,CAAC;AACnE,OAAO,EAA8B,KAAK,0BAA0B,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAE/G,oEAAoE;AACpE,MAAM,MAAM,uBAAuB,GAAG,CAAC,OAAO,EAAE,YAAY,KAAK,YAAY,CAAC;AAE9E;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,YAAY,CAAC;CACvB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC,sBAAsB,CAAC,EAAE,0BAA0B,CAAC;IACpD,mBAAmB,CAAC,EAAE,uBAAuB,CAAC;IAC9C,SAAS,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC;CAC7C,CAAC;AAEF,sGAAsG;AACtG,MAAM,MAAM,qBAAqB,GAAG,gBAAgB,GAAG,oBAAoB,CAAC;AAE5E,2CAA2C;AAC3C,MAAM,MAAM,kBAAkB,GAAG,oBAAoB,GAAG;IACtD,0GAA0G;IAC1G,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACtB,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAkB;IACtC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiC;IAGzD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;gBAEjC,EACV,GAAG,EACH,sBAAmD,EACnD,mBAA0C,EAC1C,SAAsB,GACvB,EAAE,kBAAkB;IAKrB,QAAQ,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO;IAInC,8FAA8F;IAC9F,UAAU,CACR,MAAM,EAAE,QAAQ,EAChB,EACE,KAAK,EACL,sBAA4D,EAC5D,mBAAsD,EACtD,SAAkC,GACnC,EAAE,qBAAqB,GACvB,UAAU,EAAE;CAYhB;AAED,+GAA+G;AAC/G,eAAO,MAAM,MAAM,GAChB,mBAAmB,UAAU,KAAG,IAElB,CAAC"}
@@ -1,6 +1,11 @@
1
1
  import type { IContainer } from '../container/IContainer.js';
2
2
  import { type Instance } from '../utils/basic.js';
3
3
  import { type InjectFn } from './hook.js';
4
+ /**
5
+ * What a hook receives: the `instance`, the `scope` and the decorated member's
6
+ * name. `invokeMethod({ args: resolveArgs() })` calls the member with its
7
+ * `@inject` parameters; `setProperty(fn)` assigns it (see `injectProp`).
8
+ */
4
9
  export interface IHookContext {
5
10
  instance: Instance;
6
11
  scope: IContainer;
@@ -14,6 +19,7 @@ export interface IHookContext {
14
19
  setInitialArgs(...args: unknown[]): this;
15
20
  getInitialArgs(): unknown[];
16
21
  }
22
+ /** The default {@link IHookContext}. */
17
23
  export declare class HookContext implements IHookContext {
18
24
  readonly instance: Instance;
19
25
  readonly scope: IContainer;
@@ -29,8 +35,12 @@ export declare class HookContext implements IHookContext {
29
35
  setInitialArgs(...args: unknown[]): this;
30
36
  getInitialArgs(): unknown[];
31
37
  }
38
+ /** Builds the context a hook receives. */
32
39
  export type CreateHookExecutionContext = (Target: Instance, scope: IContainer, methodName?: string) => IHookContext;
40
+ /** The default {@link CreateHookExecutionContext}: a {@link HookContext}. */
33
41
  export declare const createHookExecutionContext: CreateHookExecutionContext;
42
+ /** A {@link CreateHookExecutionContext} whose contexts start with `args` as initial args. */
34
43
  export declare const createHookContextFactory: ({ args }?: {
35
44
  args?: unknown[];
36
45
  }) => CreateHookExecutionContext;
46
+ //# sourceMappingURL=HookContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HookContext.d.ts","sourceRoot":"","sources":["../../lib/hooks/HookContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE1D,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAEvC;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,QAAQ,CAAC;IACnB,KAAK,EAAE,UAAU,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,WAAW,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,EAAE,CAAC;IAE3C,YAAY,CAAC,OAAO,CAAC,EA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AC"}
@@ -1,6 +1,29 @@
1
1
  import type { IContainer } from '../container/IContainer.js';
2
2
  import { type HookFn, type HookType } from './hook.js';
3
+ /**
4
+ * A provider hook narrowed to the dependencies that can carry hook metadata.
5
+ */
3
6
  export type ResolvedObjectHook = (dependency: object, scope: IContainer) => void;
7
+ /**
8
+ * Combines hooks into one which runs them in declaration order, staying
9
+ * synchronous until one returns a promise and awaiting the rest from that point.
10
+ *
11
+ * A member carries a single hook, so this is how several are declared together:
12
+ * `@hook('onConstruct', sequential(validate, persist))`.
13
+ */
4
14
  export declare const sequential: (...hooks: HookType[]) => HookFn;
15
+ /**
16
+ * Combines hooks into one which starts them all at once. Settles when every
17
+ * hook has; a fully synchronous run returns nothing, like {@link sequential}.
18
+ *
19
+ * Use it for hooks of one member which do not depend on each other:
20
+ * `@hook('onScopeDisposed', parallel(flush, closeSocket))`.
21
+ */
5
22
  export declare const parallel: (...hooks: HookType[]) => HookFn;
23
+ /**
24
+ * Wraps a hook so it runs a single time per instance, however often the event
25
+ * it is declared under fires. Composes with the combinators above —
26
+ * `oncePerInstance(sequential(connect, warmUp))` runs the whole sequence once.
27
+ */
6
28
  export declare const oncePerInstance: (execute: HookType) => HookFn;
29
+ //# sourceMappingURL=combinators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"combinators.d.ts","sourceRoot":"","sources":["../../lib/hooks/combinators.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE1D,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,QAAQ,EAAY,MAAM,QAAQ,CAAC;AAE9D;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;AAEjF;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,GAAI,GAAG,OAAO,QAAQ,EAAE,KAAG,MAGjD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,GAAI,GAAG,OAAO,QAAQ,EAAE,KAAG,MAG/C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,SAAS,QAAQ,KAAG,MAYnD,CAAC"}
@@ -1,14 +1,53 @@
1
1
  import { type IHookContext } from './HookContext.js';
2
2
  import { type constructor, type Instance } from '../utils/basic.js';
3
3
  import { ProviderOptions } from '../provider/IProvider.js';
4
+ /**
5
+ * What `@inject(...)` and `injectProp(...)` take: a function of the resolution
6
+ * context returning the value to inject. Usually built with `by(...)` or `arg(...)`.
7
+ */
4
8
  export type InjectFn<T = unknown> = (options: ProviderOptions) => T;
9
+ /** A hook as a function of its context. Must return `void` or `Promise<void>`. */
5
10
  export type HookFn<T extends IHookContext = IHookContext> = (context: T) => void | Promise<void>;
11
+ /** A hook as a class resolved from the scope; its `execute` receives the context. */
6
12
  export interface HookClass<T extends IHookContext = IHookContext> {
7
13
  execute(context: Omit<T, 'scope'>): void | Promise<void>;
8
14
  }
15
+ /** Anything `@hook(...)` accepts: a {@link HookFn} or a {@link HookClass} constructor. */
9
16
  export type HookType<T extends IHookContext = IHookContext> = HookFn<T> | constructor<HookClass<T>>;
17
+ /** The hooks of one class under one key, by member name: one hook per member (compose with `sequential` / `parallel`). */
10
18
  export type HooksOfClass = Map<string, HookType>;
19
+ /** Normalizes a {@link HookType} to a {@link HookFn}; a hook class is resolved from the context's scope. */
11
20
  export declare const toHookFn: <C extends IHookContext>(execute: HookFn<C> | constructor<HookClass<C>>) => HookFn<C>;
21
+ /**
22
+ * Reads the hooks declared under `key`, merging hooks declared on parent classes.
23
+ * Hooks are collected from base to derived, so a derived class's hook for the
24
+ * same member replaces the parent's.
25
+ *
26
+ * `target` is an instance or its class, a proxy of either included - it is
27
+ * normalized by `resolveConstructor`, so callers never unwrap it themselves.
28
+ *
29
+ * The merge runs on every call and returns a fresh map. Hook metadata is fixed
30
+ * once a class is defined, so a caller which reads it often can wrap this in
31
+ * `memoize` (`HookCollector` already does).
32
+ */
12
33
  export declare function getHooks(target: Instance | constructor<unknown>, key: string | symbol): HooksOfClass;
34
+ /** Whether `target` (an instance or class, proxies included) declares any hook under `key`. */
13
35
  export declare function hasHooks(target: Instance | constructor<unknown>, key: string | symbol): boolean;
36
+ /**
37
+ * Method/property decorator that declares a hook under `key`. The library only
38
+ * stores it: collect with `new HookCollector({ key })` and run the actions
39
+ * yourself. A member carries exactly one hook per key - decorating it twice
40
+ * replaces the earlier hook; compose several with `sequential(...)` / `parallel(...)`.
41
+ *
42
+ * @example
43
+ * const onInit = (fn: HookType) => hook('onInit', fn);
44
+ *
45
+ * class Service {
46
+ * @onInit((ctx) => {
47
+ * ctx.invokeMethod({ args: ctx.resolveArgs() });
48
+ * })
49
+ * init() {}
50
+ * }
51
+ */
14
52
  export declare const hook: (key: string | symbol, fn: HookType) => (target: object, propertyKey: string | symbol) => void;
53
+ //# sourceMappingURL=hook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hook.d.ts","sourceRoot":"","sources":["../../lib/hooks/hook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,QAAQ,EAAM,MAAM,gBAAgB,CAAC;AAGrE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD;;;GAGG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,GAAG,OAAO,IAAI,CAAC,OAAO,EAAE,eAAe,KAAK,CAAC,CAAC;AAEpE,kFAAkF;AAClF,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,YAAY,GAAG,YAAY,IAAI,CAAC,OAAO,EAAE,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAEjG,qFAAqF;AACrF,MAAM,WAAW,SAAS,CAAC,CAAC,SAAS,YAAY,GAAG,YAAY;IAC9D,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1D;AAED,0FAA0F;AAC1F,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,YAAY,GAAG,YAAY,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;AAEpG,0HAA0H;AAC1H,MAAM,MAAM,YAAY,GAAG,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAQjD,4GAA4G;AAC5G,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,YAAY,EAAE,SAAS,MAAM,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAG,MAAM,CAAC,CAAC,CACA,CAAC;AAE3G;;;;;;;;;;;GAWG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,QAAQ,GAAG,WAAW,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,YAAY,CAWpG;AAED,+FAA+F;AAC/F,wBAAgB,QAAQ,CAAC,MAAM,EAAE,QAAQ,GAAG,WAAW,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAE/F;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,IAAI,GAAI,KAAK,MAAM,GAAG,MAAM,EAAE,IAAI,QAAQ,MAAM,QAAQ,MAAM,EAAE,aAAa,MAAM,GAAG,MAAM,SAMxG,CAAC"}
@@ -1,2 +1,11 @@
1
1
  import { HookFn, InjectFn } from './hook.js';
2
+ /**
3
+ * Injects a dependency into the decorated property.
4
+ *
5
+ * `fn` is an `InjectFn`, exactly as for `@inject`: it receives the resolution
6
+ * context and returns the value to assign, so `injectProp(({ scope }) =>
7
+ * scope.resolve('key'))` assigns the dependency and `injectProp(pipe(fn, sanitize()))`
8
+ * a mapped one.
9
+ */
2
10
  export declare const injectProp: <T>(fn: InjectFn<T>) => HookFn;
11
+ //# sourceMappingURL=injectProp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"injectProp.d.ts","sourceRoot":"","sources":["../../lib/hooks/injectProp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAE1C;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,GACpB,CAAC,EAAE,IAAI,QAAQ,CAAC,CAAC,CAAC,KAAG,MAEG,CAAC"}
@@ -17,6 +17,7 @@ export { DependencyMissingKeyError } from './errors/DependencyMissingKeyError.js
17
17
  export { MethodNotImplementedError } from './errors/MethodNotImplementedError.js';
18
18
  export { ContainerDisposedError } from './errors/ContainerDisposedError.js';
19
19
  export { ProviderDisposedError } from './errors/ProviderDisposedError.js';
20
+ export { CannotApplySingletonTwiceError } from './errors/CannotApplySingletonTwiceError.js';
20
21
  export { CannonSingletonApplyTwiceError } from './errors/CannonSingletonApplyTwiceError.js';
21
22
  export { UnsupportedTokenTypeError } from './errors/UnsupportedTokenTypeError.js';
22
23
  export { TypedEventDisposedError } from './errors/TypedEventDisposedError.js';
@@ -54,3 +55,4 @@ export { pipe, type MapFn } from './utils/fp.js';
54
55
  export { findOrFail, type Predicate } from './utils/array.js';
55
56
  export { ProxyRegistry, unwrapProxy, type IProxyRegistry } from './utils/ProxyRegistry.js';
56
57
  export { type Branded, type constructor, type Instance, type Serializable, Is, isSerializable } from './utils/basic.js';
58
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,GAAG,EACR,KAAK,MAAM,EACX,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,SAA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CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,KAAK,WAAW,EAAE,KAAK,kBAAkB,EAAE,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAG7G,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAG3D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACxF,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,QAAQ,EAAE,KAAK,YAAY,EAAE,EAAE,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC"}
@@ -8,24 +8,56 @@ export type WithScope = {
8
8
  export type WithArgs = {
9
9
  args: unknown[];
10
10
  };
11
+ /**
12
+ * What an injector needs to build an instance: the scope it is built in, plus
13
+ * the runtime `args`. The scope travels inside the options rather than beside
14
+ * them, so every function handed a resolution context - `InjectFn`, `ArgsFn`,
15
+ * `ResolveDependency`, `IProvider.resolve`, `IInjector.resolve` - takes one
16
+ * object and destructures what it uses.
17
+ */
11
18
  export type InjectOptions = WithScope & Partial<WithArgs>;
19
+ /**
20
+ * Injector hooks - the injector's own domain: an instance was constructed.
21
+ *
22
+ * Construction is the injector's business, so the hook list belongs to the
23
+ * injector rather than to a scope. One injector is shared by a container and
24
+ * every scope created from it, so a hook added here observes construction in
25
+ * all of them.
26
+ */
12
27
  export type InjectorHook = (instance: Instance, scope: IContainer) => void;
28
+ /** Builds instances of classes for a scope. Shared by a container and every scope created from it. */
13
29
  export interface IInjector {
14
30
  resolve<T>(Target: constructor<T>, options: ProviderOptions): T;
15
31
  onConstructed(...hooks: InjectorHook[]): this;
16
32
  }
33
+ /**
34
+ * The injector counterpart of `IContainerModule`: an opt-in bundle of injector
35
+ * hooks, applied to the injector before it is handed to a container.
36
+ */
17
37
  export interface IInjectorModule {
18
38
  applyTo(injector: IInjector): void;
19
39
  }
40
+ /** Something that resolves a value from a scope. */
20
41
  export interface IInjectFnResolver<T> {
21
42
  resolve(s: IContainer, options?: ResolveOneOptions): T;
22
43
  }
44
+ /**
45
+ * Base class of the bundled injectors: tracks the instance in the scope, runs
46
+ * `onConstructed` hooks and handles `lazy`. Subclass it and implement
47
+ * `createInstance` for a custom injection strategy.
48
+ */
23
49
  export declare abstract class Injector {
24
50
  private readonly proxyRegistry;
25
51
  private readonly onConstructedHookList;
26
52
  constructor(proxyRegistry?: IProxyRegistry);
27
53
  resolve<T>(Target: constructor<T>, { scope, args, lazy }: ProviderOptions): T;
54
+ /**
55
+ * Hooks run after the constructed instance is handed to the scope, and before
56
+ * it reaches the caller. A `lazy` resolve returns a proxy first, so its hooks
57
+ * run when the proxy is first touched.
58
+ */
28
59
  onConstructed(...hooks: InjectorHook[]): this;
29
60
  useModule(module: IInjectorModule): this;
30
61
  protected abstract createInstance<T>(Target: constructor<T>, options: InjectOptions): T;
31
62
  }
63
+ //# sourceMappingURL=IInjector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IInjector.d.ts","sourceRoot":"","sources":["../../lib/injector/IInjector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,iBAAiB,EAAE,MAAM,yBAAyB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EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,eAAe,GAAG,CAAC;IAe7E;;;;OAIG;IACH,aAAa,CAAC,GAAG,KAAK,EAAE,YAAY,EAAE,GAAG,IAAI;IAK7C,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI;IAKxC,SAAS,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,aAAa,GAAG,CAAC;CACxF"}
@@ -4,12 +4,70 @@ import { ProviderOptions } from '../provider/IProvider.js';
4
4
  import { InjectFn } from '../hooks/hook.js';
5
5
  import { type DependencyKey } from '../container/IContainer.js';
6
6
  import { type InjectionToken } from '../token/InjectionToken.js';
7
+ /**
8
+ * The default injector: builds a class by calling each constructor parameter's
9
+ * `@inject(...)` function. Parameters without `@inject` receive `undefined`.
10
+ * Needs `reflect-metadata` imported once at the entrypoint.
11
+ *
12
+ * @example
13
+ * const container = new Container({ injector: new MetadataInjector() });
14
+ */
7
15
  export declare class MetadataInjector extends Injector implements IInjector {
8
16
  protected createInstance<T>(Target: constructor<T>, { scope, args: deps }: InjectOptions): T;
9
17
  }
18
+ /**
19
+ * Injects a dependency into a constructor parameter.
20
+ *
21
+ * `fn` receives the resolution context - the `scope` the instance is built in and
22
+ * the runtime `args` it is built with - and returns the value to inject. That is
23
+ * the whole contract: a token, key or class is resolved with {@link by}, a
24
+ * runtime argument picked with {@link arg}, and a mapped value is
25
+ * `pipe(fn, ...mappers)`.
26
+ *
27
+ * @example
28
+ * class App {
29
+ * constructor(
30
+ * @inject(by(ILoggerToken)) private logger: ILogger,
31
+ * @inject(pipe(by(ConfigToken), (c) => c.apiUrl)) private apiUrl: string,
32
+ * @inject(arg(0)) private tenantId: string,
33
+ * ) {}
34
+ * }
35
+ */
10
36
  export declare function inject<T>(fn: InjectFn<T>): ParameterDecorator;
37
+ /**
38
+ * The `InjectFn` which resolves `target` - an `InjectionToken`, a `DependencyKey`
39
+ * or a class - from the scope, handing it the runtime args of the class being
40
+ * constructed (see "Runtime args flow through tokens" in the README) and the
41
+ * `lazy` flag: `@inject(by(Token))`, `@inject(by('key'))`, `@inject(by(Logger))`.
42
+ * Being a function, it composes: `pipe(by(Config), (c) => c.apiUrl)`.
43
+ *
44
+ * @throws {UnsupportedTokenTypeError} when `target` is none of the three.
45
+ */
11
46
  export declare const by: <T>(target: InjectionToken<T> | DependencyKey | constructor<T>) => InjectFn<T>;
47
+ /**
48
+ * Injects the first runtime arg matching `predicate`, or `undefined`.
49
+ *
50
+ * @example
51
+ * constructor(@inject(argsFn((value) => typeof value === 'string')) readonly name: string) {}
52
+ */
12
53
  export declare const argsFn: <T = unknown>(predicate: (value: unknown, index: number) => boolean) => InjectFn<T>;
54
+ /**
55
+ * Injects the runtime arg at `index`, or `undefined`. Args arrive as passed:
56
+ * a token in the args list is not resolved.
57
+ *
58
+ * @example
59
+ * constructor(@inject(arg(0)) readonly baseUrl: string) {}
60
+ * // Token.args('https://api.example.com').resolve(scope)
61
+ */
13
62
  export declare const arg: <T = unknown>(index: number) => InjectFn<T>;
63
+ /** Injects the whole runtime args array. */
14
64
  export declare const args: InjectFn<unknown[]>;
65
+ /**
66
+ * Resolves the arguments annotated with `@inject` on `target`'s constructor, or on
67
+ * its `methodName` method, by calling each parameter's `InjectFn` with `options`.
68
+ *
69
+ * `target` is the class or any instance of it - a proxy included, since it is
70
+ * unwrapped on the way to the metadata (see {@link resolveConstructor}).
71
+ */
15
72
  export declare const resolveArgs: (target: constructor<unknown> | Instance, methodName?: string) => (options: ProviderOptions) => unknown[];
73
+ //# sourceMappingURL=MetadataInjector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MetadataInjector.d.ts","sourceRoot":"","sources":["../../lib/injector/MetadataInjector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACjE,OA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AI,QAAQ,WAAW,CAAC,OAAO,CAAC,GAAG,QAAQ,EAAE,aAAa,MAAM,MAE9E,SAAS,eAAe,KAAG,OAAO,EAC3C,CAAC"}
@@ -1,5 +1,18 @@
1
1
  import { IInjector, InjectOptions, Injector } from './IInjector.js';
2
2
  import { type constructor } from '../utils/basic.js';
3
+ /**
4
+ * Injector that passes one proxy object as the first constructor argument:
5
+ * reading `deps.someKey` resolves `'someKey'`, a property name containing
6
+ * "alias" resolves by alias, and `deps.args` returns the runtime args. Needs no
7
+ * decorators or `reflect-metadata`.
8
+ *
9
+ * @example
10
+ * class App {
11
+ * constructor({ logger }: { logger: ILogger }) {}
12
+ * }
13
+ * new Container({ injector: new ProxyInjector() });
14
+ */
3
15
  export declare class ProxyInjector extends Injector implements IInjector {
4
16
  protected createInstance<T>(Target: constructor<T>, { scope, args }: InjectOptions): T;
5
17
  }
18
+ //# sourceMappingURL=ProxyInjector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProxyInjector.d.ts","sourceRoot":"","sources":["../../lib/injector/ProxyInjector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD;;;;;;;;;;;GAWG;AACH,qBAAa,aAAc,SAAQ,QAAS,YAAW,SAAS;IAC9D,SAAS,CAAC,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,IAAS,EAAE,EAAE,aAAa,GAAG,CAAC;CAc5F"}