@celljs/core 4.1.0 → 4.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 (410) hide show
  1. package/README.md +49 -62
  2. package/esm/browser/static-module.d.ts +1 -1
  3. package/esm/common/annotation/aspect.d.ts +2 -1
  4. package/esm/common/annotation/aspect.js.map +1 -1
  5. package/esm/common/annotation/autowired-provider.d.ts +0 -2
  6. package/esm/common/annotation/autowired-provider.js +4 -13
  7. package/esm/common/annotation/autowired-provider.js.map +1 -1
  8. package/esm/common/annotation/autowired.d.ts +1 -1
  9. package/esm/common/annotation/autowired.js +11 -3
  10. package/esm/common/annotation/autowired.js.map +1 -1
  11. package/esm/common/annotation/component.d.ts +4 -8
  12. package/esm/common/annotation/component.js +0 -6
  13. package/esm/common/annotation/component.js.map +1 -1
  14. package/esm/common/annotation/constant.d.ts +1 -1
  15. package/esm/common/annotation/constant.js +6 -3
  16. package/esm/common/annotation/constant.js.map +1 -1
  17. package/esm/common/annotation/detached/autowired-provider.js +2 -2
  18. package/esm/common/annotation/detached/autowired-provider.js.map +1 -1
  19. package/esm/common/annotation/index.d.ts +0 -6
  20. package/esm/common/annotation/index.js +0 -6
  21. package/esm/common/annotation/index.js.map +1 -1
  22. package/esm/common/annotation/named.d.ts +2 -1
  23. package/esm/common/annotation/named.js +5 -1
  24. package/esm/common/annotation/named.js.map +1 -1
  25. package/esm/common/annotation/optional.d.ts +2 -1
  26. package/esm/common/annotation/optional.js +5 -1
  27. package/esm/common/annotation/optional.js.map +1 -1
  28. package/esm/common/annotation/post-construct.d.ts +2 -1
  29. package/esm/common/annotation/post-construct.js +5 -1
  30. package/esm/common/annotation/post-construct.js.map +1 -1
  31. package/esm/common/annotation/tagged.d.ts +2 -1
  32. package/esm/common/annotation/tagged.js +6 -1
  33. package/esm/common/annotation/tagged.js.map +1 -1
  34. package/esm/common/annotation/value.d.ts +3 -2
  35. package/esm/common/annotation/value.js +7 -10
  36. package/esm/common/annotation/value.js.map +1 -1
  37. package/esm/common/aop/aop-proxy-factory.d.ts +6 -2
  38. package/esm/common/aop/aop-proxy-factory.js +44 -28
  39. package/esm/common/aop/aop-proxy-factory.js.map +1 -1
  40. package/esm/common/aop/class-filter.js +6 -6
  41. package/esm/common/aop/class-filter.js.map +1 -1
  42. package/esm/common/application/application-factory.d.ts +1 -1
  43. package/esm/common/application/application-factory.js +4 -4
  44. package/esm/common/application/application-factory.js.map +1 -1
  45. package/esm/common/container/auto-bind.d.ts +7 -3
  46. package/esm/common/container/auto-bind.js +49 -80
  47. package/esm/common/container/auto-bind.js.map +1 -1
  48. package/esm/common/container/container-error.d.ts +21 -0
  49. package/esm/common/container/container-error.js +22 -0
  50. package/esm/common/container/container-error.js.map +1 -0
  51. package/esm/common/container/container-provider.d.ts +5 -4
  52. package/esm/common/container/container-provider.js +2 -1
  53. package/esm/common/container/container-provider.js.map +1 -1
  54. package/esm/common/container/container-util.d.ts +5 -7
  55. package/esm/common/container/container-util.js +8 -19
  56. package/esm/common/container/container-util.js.map +1 -1
  57. package/esm/common/container/container.d.ts +104 -0
  58. package/esm/common/container/container.js +299 -0
  59. package/esm/common/container/container.js.map +1 -0
  60. package/esm/common/container/dynamic-container.d.ts +1 -1
  61. package/esm/common/container/dynamic-container.js +2 -2
  62. package/esm/common/container/dynamic-container.js.map +1 -1
  63. package/esm/common/container/index.d.ts +5 -6
  64. package/esm/common/container/index.js +5 -3
  65. package/esm/common/container/index.js.map +1 -1
  66. package/esm/common/container/injection.d.ts +40 -0
  67. package/esm/common/container/injection.js +109 -0
  68. package/esm/common/container/injection.js.map +1 -0
  69. package/esm/common/container/scope.d.ts +2 -3
  70. package/esm/common/container/scope.js +2 -3
  71. package/esm/common/container/scope.js.map +1 -1
  72. package/esm/common/el/application-expression-engine.d.ts +7 -0
  73. package/esm/common/{provider/provider-creator.js → el/application-expression-engine.js} +11 -11
  74. package/esm/common/el/application-expression-engine.js.map +1 -0
  75. package/esm/common/el/core-context-initializer.d.ts +3 -2
  76. package/esm/common/el/core-context-initializer.js +10 -8
  77. package/esm/common/el/core-context-initializer.js.map +1 -1
  78. package/esm/common/el/expression-compiler.d.ts +5 -4
  79. package/esm/common/el/expression-compiler.js +7 -6
  80. package/esm/common/el/expression-compiler.js.map +1 -1
  81. package/esm/common/el/expression-engine.d.ts +61 -0
  82. package/esm/common/el/expression-engine.js +459 -0
  83. package/esm/common/el/expression-engine.js.map +1 -0
  84. package/esm/common/el/expression-handler.d.ts +1 -2
  85. package/esm/common/el/expression-handler.js +1 -5
  86. package/esm/common/el/expression-handler.js.map +1 -1
  87. package/esm/common/el/expression-protocol.d.ts +3 -5
  88. package/esm/common/el/expression-protocol.js +0 -1
  89. package/esm/common/el/expression-protocol.js.map +1 -1
  90. package/esm/common/el/expression-util.d.ts +9 -8
  91. package/esm/common/el/expression-util.js +8 -9
  92. package/esm/common/el/expression-util.js.map +1 -1
  93. package/esm/common/el/index.d.ts +2 -1
  94. package/esm/common/el/index.js +2 -1
  95. package/esm/common/el/index.js.map +1 -1
  96. package/esm/common/provider/index.d.ts +0 -1
  97. package/esm/common/provider/index.js +0 -1
  98. package/esm/common/provider/index.js.map +1 -1
  99. package/esm/common/provider/provider-protocol.d.ts +5 -9
  100. package/esm/common/provider/provider-protocol.js +0 -1
  101. package/esm/common/provider/provider-protocol.js.map +1 -1
  102. package/esm/common/provider/provider-util.d.ts +1 -1
  103. package/esm/common/provider/provider-util.js +2 -2
  104. package/esm/common/provider/provider-util.js.map +1 -1
  105. package/esm/common/provider/provider.d.ts +7 -6
  106. package/esm/common/provider/provider.js +15 -26
  107. package/esm/common/provider/provider.js.map +1 -1
  108. package/esm/common/static-module.d.ts +1 -1
  109. package/esm/common/static-module.js +1 -1
  110. package/esm/common/static-module.js.map +1 -1
  111. package/esm/common/test/mock-logger.js +2 -13
  112. package/esm/common/test/mock-logger.js.map +1 -1
  113. package/esm/common/test/test-module.d.ts +1 -1
  114. package/esm/common/test/test-module.js +1 -1
  115. package/esm/common/test/test-module.js.map +1 -1
  116. package/esm/common/utils/annotation-util.js +2 -1
  117. package/esm/common/utils/annotation-util.js.map +1 -1
  118. package/esm/common/utils/proxy-util.d.ts +5 -2
  119. package/esm/common/utils/proxy-util.js +10 -28
  120. package/esm/common/utils/proxy-util.js.map +1 -1
  121. package/esm/node/static-module.d.ts +1 -1
  122. package/lib/browser/static-module.d.ts +1 -1
  123. package/lib/common/annotation/aspect.d.ts +2 -1
  124. package/lib/common/annotation/aspect.d.ts.map +1 -1
  125. package/lib/common/annotation/aspect.js.map +1 -1
  126. package/lib/common/annotation/autowired-provider.d.ts +0 -2
  127. package/lib/common/annotation/autowired-provider.d.ts.map +1 -1
  128. package/lib/common/annotation/autowired-provider.js +4 -14
  129. package/lib/common/annotation/autowired-provider.js.map +1 -1
  130. package/lib/common/annotation/autowired.d.ts +1 -1
  131. package/lib/common/annotation/autowired.d.ts.map +1 -1
  132. package/lib/common/annotation/autowired.js +11 -3
  133. package/lib/common/annotation/autowired.js.map +1 -1
  134. package/lib/common/annotation/component.d.ts +4 -8
  135. package/lib/common/annotation/component.d.ts.map +1 -1
  136. package/lib/common/annotation/component.js +0 -6
  137. package/lib/common/annotation/component.js.map +1 -1
  138. package/lib/common/annotation/constant.d.ts +1 -1
  139. package/lib/common/annotation/constant.d.ts.map +1 -1
  140. package/lib/common/annotation/constant.js +6 -3
  141. package/lib/common/annotation/constant.js.map +1 -1
  142. package/lib/common/annotation/detached/autowired-provider.js +2 -2
  143. package/lib/common/annotation/detached/autowired-provider.js.map +1 -1
  144. package/lib/common/annotation/index.d.ts +0 -6
  145. package/lib/common/annotation/index.d.ts.map +1 -1
  146. package/lib/common/annotation/index.js +0 -6
  147. package/lib/common/annotation/index.js.map +1 -1
  148. package/lib/common/annotation/named.d.ts +2 -1
  149. package/lib/common/annotation/named.d.ts.map +1 -1
  150. package/lib/common/annotation/named.js +6 -2
  151. package/lib/common/annotation/named.js.map +1 -1
  152. package/lib/common/annotation/optional.d.ts +2 -1
  153. package/lib/common/annotation/optional.d.ts.map +1 -1
  154. package/lib/common/annotation/optional.js +6 -2
  155. package/lib/common/annotation/optional.js.map +1 -1
  156. package/lib/common/annotation/post-construct.d.ts +2 -1
  157. package/lib/common/annotation/post-construct.d.ts.map +1 -1
  158. package/lib/common/annotation/post-construct.js +6 -2
  159. package/lib/common/annotation/post-construct.js.map +1 -1
  160. package/lib/common/annotation/tagged.d.ts +2 -1
  161. package/lib/common/annotation/tagged.d.ts.map +1 -1
  162. package/lib/common/annotation/tagged.js +7 -2
  163. package/lib/common/annotation/tagged.js.map +1 -1
  164. package/lib/common/annotation/value.d.ts +3 -2
  165. package/lib/common/annotation/value.d.ts.map +1 -1
  166. package/lib/common/annotation/value.js +7 -10
  167. package/lib/common/annotation/value.js.map +1 -1
  168. package/lib/common/aop/aop-proxy-factory.d.ts +6 -2
  169. package/lib/common/aop/aop-proxy-factory.d.ts.map +1 -1
  170. package/lib/common/aop/aop-proxy-factory.js +45 -29
  171. package/lib/common/aop/aop-proxy-factory.js.map +1 -1
  172. package/lib/common/aop/class-filter.js +7 -7
  173. package/lib/common/aop/class-filter.js.map +1 -1
  174. package/lib/common/application/application-factory.d.ts +1 -1
  175. package/lib/common/application/application-factory.d.ts.map +1 -1
  176. package/lib/common/application/application-factory.js +4 -4
  177. package/lib/common/application/application-factory.js.map +1 -1
  178. package/lib/common/container/assembly.spec.js +11 -11
  179. package/lib/common/container/assembly.spec.js.map +1 -1
  180. package/lib/common/container/auto-bind.d.ts +7 -3
  181. package/lib/common/container/auto-bind.d.ts.map +1 -1
  182. package/lib/common/container/auto-bind.js +49 -81
  183. package/lib/common/container/auto-bind.js.map +1 -1
  184. package/lib/common/container/container-error.d.ts +22 -0
  185. package/lib/common/container/container-error.d.ts.map +1 -0
  186. package/lib/common/container/container-error.js +26 -0
  187. package/lib/common/container/container-error.js.map +1 -0
  188. package/lib/common/container/container-provider.d.ts +5 -4
  189. package/lib/common/container/container-provider.d.ts.map +1 -1
  190. package/lib/common/container/container-provider.js +3 -2
  191. package/lib/common/container/container-provider.js.map +1 -1
  192. package/lib/common/container/container-util.d.ts +5 -7
  193. package/lib/common/container/container-util.d.ts.map +1 -1
  194. package/lib/common/container/container-util.js +8 -19
  195. package/lib/common/container/container-util.js.map +1 -1
  196. package/lib/common/container/container.d.ts +105 -0
  197. package/lib/common/container/container.d.ts.map +1 -0
  198. package/lib/common/container/container.js +305 -0
  199. package/lib/common/container/container.js.map +1 -0
  200. package/lib/common/container/container.spec.d.ts +2 -0
  201. package/lib/common/container/container.spec.d.ts.map +1 -0
  202. package/lib/common/container/container.spec.js +334 -0
  203. package/lib/common/container/container.spec.js.map +1 -0
  204. package/lib/common/container/dynamic-container.d.ts +1 -1
  205. package/lib/common/container/dynamic-container.d.ts.map +1 -1
  206. package/lib/common/container/dynamic-container.js +3 -3
  207. package/lib/common/container/dynamic-container.js.map +1 -1
  208. package/lib/common/container/index.d.ts +5 -6
  209. package/lib/common/container/index.d.ts.map +1 -1
  210. package/lib/common/container/index.js +5 -3
  211. package/lib/common/container/index.js.map +1 -1
  212. package/lib/common/container/injection.d.ts +41 -0
  213. package/lib/common/container/injection.d.ts.map +1 -0
  214. package/lib/common/container/injection.js +112 -0
  215. package/lib/common/container/injection.js.map +1 -0
  216. package/lib/common/container/scope.d.ts +2 -3
  217. package/lib/common/container/scope.d.ts.map +1 -1
  218. package/lib/common/container/scope.js +2 -3
  219. package/lib/common/container/scope.js.map +1 -1
  220. package/lib/common/el/application-expression-engine.d.ts +8 -0
  221. package/lib/common/el/application-expression-engine.d.ts.map +1 -0
  222. package/lib/common/el/application-expression-engine.js +22 -0
  223. package/lib/common/el/application-expression-engine.js.map +1 -0
  224. package/lib/common/el/core-context-initializer.d.ts +3 -2
  225. package/lib/common/el/core-context-initializer.d.ts.map +1 -1
  226. package/lib/common/el/core-context-initializer.js +9 -7
  227. package/lib/common/el/core-context-initializer.js.map +1 -1
  228. package/lib/common/el/expression-compiler.d.ts +5 -4
  229. package/lib/common/el/expression-compiler.d.ts.map +1 -1
  230. package/lib/common/el/expression-compiler.js +6 -5
  231. package/lib/common/el/expression-compiler.js.map +1 -1
  232. package/lib/common/el/expression-engine.d.ts +62 -0
  233. package/lib/common/el/expression-engine.d.ts.map +1 -0
  234. package/lib/common/el/expression-engine.js +465 -0
  235. package/lib/common/el/expression-engine.js.map +1 -0
  236. package/lib/common/el/expression-engine.spec.d.ts +2 -0
  237. package/lib/common/el/expression-engine.spec.d.ts.map +1 -0
  238. package/lib/common/el/expression-engine.spec.js +100 -0
  239. package/lib/common/el/expression-engine.spec.js.map +1 -0
  240. package/lib/common/el/expression-handler.d.ts +1 -2
  241. package/lib/common/el/expression-handler.d.ts.map +1 -1
  242. package/lib/common/el/expression-handler.js +0 -4
  243. package/lib/common/el/expression-handler.js.map +1 -1
  244. package/lib/common/el/expression-handler.spec.js +5 -6
  245. package/lib/common/el/expression-handler.spec.js.map +1 -1
  246. package/lib/common/el/expression-protocol.d.ts +3 -5
  247. package/lib/common/el/expression-protocol.d.ts.map +1 -1
  248. package/lib/common/el/expression-protocol.js +1 -2
  249. package/lib/common/el/expression-protocol.js.map +1 -1
  250. package/lib/common/el/expression-util.d.ts +9 -8
  251. package/lib/common/el/expression-util.d.ts.map +1 -1
  252. package/lib/common/el/expression-util.js +8 -9
  253. package/lib/common/el/expression-util.js.map +1 -1
  254. package/lib/common/el/index.d.ts +2 -1
  255. package/lib/common/el/index.d.ts.map +1 -1
  256. package/lib/common/el/index.js +2 -1
  257. package/lib/common/el/index.js.map +1 -1
  258. package/lib/common/el/value-and-el.spec.js +2 -2
  259. package/lib/common/el/value-and-el.spec.js.map +1 -1
  260. package/lib/common/provider/index.d.ts +0 -1
  261. package/lib/common/provider/index.d.ts.map +1 -1
  262. package/lib/common/provider/index.js +0 -1
  263. package/lib/common/provider/index.js.map +1 -1
  264. package/lib/common/provider/provider-protocol.d.ts +5 -9
  265. package/lib/common/provider/provider-protocol.d.ts.map +1 -1
  266. package/lib/common/provider/provider-protocol.js +1 -2
  267. package/lib/common/provider/provider-protocol.js.map +1 -1
  268. package/lib/common/provider/provider-util.d.ts +1 -1
  269. package/lib/common/provider/provider-util.d.ts.map +1 -1
  270. package/lib/common/provider/provider-util.js +2 -2
  271. package/lib/common/provider/provider-util.js.map +1 -1
  272. package/lib/common/provider/provider.d.ts +7 -6
  273. package/lib/common/provider/provider.d.ts.map +1 -1
  274. package/lib/common/provider/provider.js +16 -26
  275. package/lib/common/provider/provider.js.map +1 -1
  276. package/lib/common/static-module.d.ts +1 -1
  277. package/lib/common/static-module.js +2 -2
  278. package/lib/common/static-module.js.map +1 -1
  279. package/lib/common/test/mock-logger.d.ts.map +1 -1
  280. package/lib/common/test/mock-logger.js +2 -12
  281. package/lib/common/test/mock-logger.js.map +1 -1
  282. package/lib/common/test/test-module.d.ts +1 -1
  283. package/lib/common/test/test-module.d.ts.map +1 -1
  284. package/lib/common/test/test-module.js +2 -2
  285. package/lib/common/test/test-module.js.map +1 -1
  286. package/lib/common/utils/annotation-util.js +2 -1
  287. package/lib/common/utils/annotation-util.js.map +1 -1
  288. package/lib/common/utils/proxy-util.d.ts +5 -2
  289. package/lib/common/utils/proxy-util.d.ts.map +1 -1
  290. package/lib/common/utils/proxy-util.js +12 -30
  291. package/lib/common/utils/proxy-util.js.map +1 -1
  292. package/lib/node/static-module.d.ts +1 -1
  293. package/package.json +4 -6
  294. package/src/common/annotation/aspect.ts +2 -1
  295. package/src/common/annotation/autowired-provider.ts +4 -17
  296. package/src/common/annotation/autowired.ts +14 -6
  297. package/src/common/annotation/component.ts +6 -26
  298. package/src/common/annotation/constant.ts +10 -7
  299. package/src/common/annotation/detached/autowired-provider.ts +2 -2
  300. package/src/common/annotation/index.ts +0 -6
  301. package/src/common/annotation/named.ts +7 -1
  302. package/src/common/annotation/optional.ts +6 -1
  303. package/src/common/annotation/post-construct.ts +6 -1
  304. package/src/common/annotation/tagged.ts +8 -1
  305. package/src/common/annotation/value.ts +9 -11
  306. package/src/common/aop/aop-proxy-factory.ts +52 -30
  307. package/src/common/aop/class-filter.ts +6 -6
  308. package/src/common/application/application-factory.ts +4 -5
  309. package/src/common/container/assembly.spec.ts +7 -12
  310. package/src/common/container/auto-bind.ts +54 -85
  311. package/src/common/container/container-error.ts +31 -0
  312. package/src/common/container/container-provider.ts +9 -7
  313. package/src/common/container/container-util.ts +8 -19
  314. package/src/common/container/container.spec.ts +262 -0
  315. package/src/common/container/container.ts +363 -0
  316. package/src/common/container/dynamic-container.ts +2 -2
  317. package/src/common/container/index.ts +5 -7
  318. package/src/common/container/injection.ts +135 -0
  319. package/src/common/container/scope.ts +2 -1
  320. package/src/common/el/application-expression-engine.ts +9 -0
  321. package/src/common/el/core-context-initializer.ts +9 -8
  322. package/src/common/el/expression-compiler.ts +7 -6
  323. package/src/common/el/expression-engine.spec.ts +107 -0
  324. package/src/common/el/expression-engine.ts +487 -0
  325. package/src/common/el/expression-handler.spec.ts +6 -7
  326. package/src/common/el/expression-handler.ts +2 -5
  327. package/src/common/el/expression-protocol.ts +4 -8
  328. package/src/common/el/expression-util.ts +12 -13
  329. package/src/common/el/index.ts +3 -2
  330. package/src/common/el/value-and-el.spec.ts +2 -2
  331. package/src/common/provider/index.ts +0 -2
  332. package/src/common/provider/provider-protocol.ts +5 -11
  333. package/src/common/provider/provider-util.ts +3 -3
  334. package/src/common/provider/provider.ts +17 -29
  335. package/src/common/static-module.ts +1 -1
  336. package/src/common/test/mock-logger.ts +0 -2
  337. package/src/common/test/test-module.ts +1 -1
  338. package/src/common/utils/annotation-util.ts +2 -2
  339. package/src/common/utils/proxy-util.ts +8 -28
  340. package/esm/common/annotation/decorate.d.ts +0 -1
  341. package/esm/common/annotation/decorate.js +0 -2
  342. package/esm/common/annotation/decorate.js.map +0 -1
  343. package/esm/common/annotation/inject.d.ts +0 -1
  344. package/esm/common/annotation/inject.js +0 -2
  345. package/esm/common/annotation/inject.js.map +0 -1
  346. package/esm/common/annotation/injectable.d.ts +0 -1
  347. package/esm/common/annotation/injectable.js +0 -2
  348. package/esm/common/annotation/injectable.js.map +0 -1
  349. package/esm/common/annotation/pre-destroy.d.ts +0 -1
  350. package/esm/common/annotation/pre-destroy.js +0 -2
  351. package/esm/common/annotation/pre-destroy.js.map +0 -1
  352. package/esm/common/annotation/target-name.d.ts +0 -1
  353. package/esm/common/annotation/target-name.js +0 -2
  354. package/esm/common/annotation/target-name.js.map +0 -1
  355. package/esm/common/annotation/unmanaged.d.ts +0 -1
  356. package/esm/common/annotation/unmanaged.js +0 -2
  357. package/esm/common/annotation/unmanaged.js.map +0 -1
  358. package/esm/common/container/container-factory.d.ts +0 -4
  359. package/esm/common/container/container-factory.js +0 -9
  360. package/esm/common/container/container-factory.js.map +0 -1
  361. package/esm/common/el/jexl-engine-provider.d.ts +0 -5
  362. package/esm/common/el/jexl-engine-provider.js +0 -22
  363. package/esm/common/el/jexl-engine-provider.js.map +0 -1
  364. package/esm/common/provider/provider-creator.d.ts +0 -6
  365. package/esm/common/provider/provider-creator.js.map +0 -1
  366. package/lib/common/annotation/decorate.d.ts +0 -2
  367. package/lib/common/annotation/decorate.d.ts.map +0 -1
  368. package/lib/common/annotation/decorate.js +0 -6
  369. package/lib/common/annotation/decorate.js.map +0 -1
  370. package/lib/common/annotation/inject.d.ts +0 -2
  371. package/lib/common/annotation/inject.d.ts.map +0 -1
  372. package/lib/common/annotation/inject.js +0 -6
  373. package/lib/common/annotation/inject.js.map +0 -1
  374. package/lib/common/annotation/injectable.d.ts +0 -2
  375. package/lib/common/annotation/injectable.d.ts.map +0 -1
  376. package/lib/common/annotation/injectable.js +0 -6
  377. package/lib/common/annotation/injectable.js.map +0 -1
  378. package/lib/common/annotation/pre-destroy.d.ts +0 -2
  379. package/lib/common/annotation/pre-destroy.d.ts.map +0 -1
  380. package/lib/common/annotation/pre-destroy.js +0 -6
  381. package/lib/common/annotation/pre-destroy.js.map +0 -1
  382. package/lib/common/annotation/target-name.d.ts +0 -2
  383. package/lib/common/annotation/target-name.d.ts.map +0 -1
  384. package/lib/common/annotation/target-name.js +0 -6
  385. package/lib/common/annotation/target-name.js.map +0 -1
  386. package/lib/common/annotation/unmanaged.d.ts +0 -2
  387. package/lib/common/annotation/unmanaged.d.ts.map +0 -1
  388. package/lib/common/annotation/unmanaged.js +0 -6
  389. package/lib/common/annotation/unmanaged.js.map +0 -1
  390. package/lib/common/container/container-factory.d.ts +0 -5
  391. package/lib/common/container/container-factory.d.ts.map +0 -1
  392. package/lib/common/container/container-factory.js +0 -13
  393. package/lib/common/container/container-factory.js.map +0 -1
  394. package/lib/common/el/jexl-engine-provider.d.ts +0 -6
  395. package/lib/common/el/jexl-engine-provider.d.ts.map +0 -1
  396. package/lib/common/el/jexl-engine-provider.js +0 -25
  397. package/lib/common/el/jexl-engine-provider.js.map +0 -1
  398. package/lib/common/provider/provider-creator.d.ts +0 -7
  399. package/lib/common/provider/provider-creator.d.ts.map +0 -1
  400. package/lib/common/provider/provider-creator.js +0 -22
  401. package/lib/common/provider/provider-creator.js.map +0 -1
  402. package/src/common/annotation/decorate.ts +0 -1
  403. package/src/common/annotation/inject.ts +0 -1
  404. package/src/common/annotation/injectable.ts +0 -1
  405. package/src/common/annotation/pre-destroy.ts +0 -1
  406. package/src/common/annotation/target-name.ts +0 -1
  407. package/src/common/annotation/unmanaged.ts +0 -1
  408. package/src/common/container/container-factory.ts +0 -9
  409. package/src/common/el/jexl-engine-provider.ts +0 -18
  410. package/src/common/provider/provider-creator.ts +0 -12
@@ -1,54 +1,76 @@
1
- import { isResolveMode } from '../utils';
2
- import { ContainerProvider } from '../container';
1
+ import { PROXY_TARGET } from '../utils/proxy-util';
2
+ import { ContainerProvider } from '../container/container-provider';
3
+ import type { ComponentId } from '../container/container';
3
4
  import { AfterReturningAdvice, AfterThrowsAdvice, AopProxy, AopProxyFactory, AOP_TAG, MethodBeforeAdvice, ProxyConfig } from './aop-protocol';
4
5
  import { Component } from '../annotation';
5
- import { interfaces } from 'inversify';
6
+
7
+ interface Advices {
8
+ before: MethodBeforeAdvice[];
9
+ afterReturning: AfterReturningAdvice[];
10
+ afterThrows: AfterThrowsAdvice[];
11
+ }
6
12
 
7
13
  @Component({ id: AopProxyFactory, proxy: false })
8
14
  export class AopProxyFactoryImpl implements AopProxyFactory {
9
15
 
10
- protected getAdvices<T>(id: interfaces.ServiceIdentifier<T>, tagValues: string[]) {
16
+ protected getAdvices<T>(id: ComponentId<T>, tagValues: string[]): T[] {
11
17
  const container = ContainerProvider.provide();
12
18
  const advices: T[] = [];
13
19
  for (const tagValue of tagValues) {
14
- if (container.isBoundTagged(id, AOP_TAG, tagValue)) {
15
- advices.push(...container.getAllTagged<T>(id, AOP_TAG, tagValue));
20
+ const query = { tags: { [AOP_TAG]: tagValue } };
21
+ if (container.isBound(id, query)) {
22
+ advices.push(...container.getAll<T>(id, query));
16
23
  }
17
24
  }
18
25
  return advices;
19
26
  }
20
27
 
28
+ /**
29
+ * Methods become async: they await the before advices, the method, then the after advices. The
30
+ * advices are looked up on the first call and the wrapped methods are created once per method.
31
+ */
21
32
  create(config: ProxyConfig): AopProxy {
22
33
  const { metadata: { sysTags } } = config;
34
+ let advices: Advices | undefined;
35
+ const getAdvices = () => advices ??= {
36
+ before: this.getAdvices<MethodBeforeAdvice>(MethodBeforeAdvice, sysTags),
37
+ afterReturning: this.getAdvices<AfterReturningAdvice>(AfterReturningAdvice, sysTags),
38
+ afterThrows: this.getAdvices<AfterThrowsAdvice>(AfterThrowsAdvice, sysTags)
39
+ };
40
+ const wrappers = new Map<PropertyKey, { func: Function, wrapper: Function }>();
23
41
  const proxy = new Proxy(config.target, {
24
- get: (target, method, receiver) => {
25
- if (isResolveMode()) {
42
+ get: (target, method) => {
43
+ if (method === PROXY_TARGET) {
26
44
  return target;
27
45
  }
28
46
  const func = target[method];
29
- if (typeof func === 'function') {
30
- return async (...args: any[]) => {
31
- try {
32
- const beforeAdvices = this.getAdvices<MethodBeforeAdvice>(MethodBeforeAdvice, sysTags!);
33
- for (const advice of beforeAdvices) {
34
- await advice.before(method, args, target);
35
- }
36
- const returnValue = await func.apply(target, args);
37
- const afterReturningAdvices = this.getAdvices<AfterReturningAdvice>(AfterReturningAdvice, sysTags!);
38
- for (const advice of afterReturningAdvices) {
39
- await advice.afterReturning(returnValue, method, args, target);
40
- }
41
- return returnValue;
42
- } catch (error) {
43
- const afterThrowsAdvices = this.getAdvices<AfterThrowsAdvice>(AfterThrowsAdvice, sysTags!);
44
- for (const advice of afterThrowsAdvices) {
45
- await advice.afterThrows(error, method, args, target);
46
- }
47
- throw error;
48
- }
49
- };
47
+ if (typeof func !== 'function') {
48
+ return func;
50
49
  }
51
- return func;
50
+ const cached = wrappers.get(method);
51
+ if (cached && cached.func === func) {
52
+ return cached.wrapper;
53
+ }
54
+ const wrapper = async (...args: any[]) => {
55
+ const { before, afterReturning, afterThrows } = getAdvices();
56
+ try {
57
+ for (const advice of before) {
58
+ await advice.before(method, args, target);
59
+ }
60
+ const returnValue = await func.apply(target, args);
61
+ for (const advice of afterReturning) {
62
+ await advice.afterReturning(returnValue, method, args, target);
63
+ }
64
+ return returnValue;
65
+ } catch (error) {
66
+ for (const advice of afterThrows) {
67
+ await advice.afterThrows(error, method, args, target);
68
+ }
69
+ throw error;
70
+ }
71
+ };
72
+ wrappers.set(method, { func, wrapper });
73
+ return wrapper;
52
74
  }
53
75
  });
54
76
  return {
@@ -1,5 +1,5 @@
1
1
  import { Newable } from '../utils';
2
- import { ContainerProvider } from '../container';
2
+ import { ContainerProvider } from '../container/container-provider';
3
3
  import { AfterReturningAdvice, AfterThrowsAdvice, AOP_TAG, ClassFilter, MethodBeforeAdvice } from './aop-protocol';
4
4
  import { Component, ComponentMetadata } from '../annotation';
5
5
 
@@ -8,11 +8,11 @@ export class ClassFilterImpl implements ClassFilter {
8
8
 
9
9
  matches(clazz: Newable<any>, metadata: ComponentMetadata): boolean {
10
10
  const container = ContainerProvider.provide();
11
- const tagKeys = metadata.sysTags;
12
- for (const tagValue of tagKeys) {
13
- if (container.isBoundTagged(MethodBeforeAdvice, AOP_TAG, tagValue)
14
- || container.isBoundTagged(AfterThrowsAdvice, AOP_TAG, tagValue)
15
- || container.isBoundTagged(AfterReturningAdvice, AOP_TAG, tagValue)) {
11
+ for (const tagValue of metadata.sysTags) {
12
+ const query = { tags: { [AOP_TAG]: tagValue } };
13
+ if (container.isBound(MethodBeforeAdvice, query)
14
+ || container.isBound(AfterThrowsAdvice, query)
15
+ || container.isBound(AfterReturningAdvice, query)) {
16
16
  return true;
17
17
  }
18
18
  }
@@ -6,15 +6,14 @@ import './application-state';
6
6
  import { autoBind } from '../container/auto-bind';
7
7
  import commonModule from '../static-module';
8
8
  import { currentThis } from '../utils';
9
- import { ContainerModule } from 'inversify';
10
- import { ContainerFactory } from '../container/container-factory';
9
+ import { Container, ContainerModule } from '../container/container';
11
10
 
12
11
  export class ApplicationFactory {
13
12
  static async create(applicationProps: ApplicationProps, ...modules: ContainerModule[]): Promise<Application> {
14
13
  currentThis.cellProps = applicationProps;
15
- const container = ContainerFactory.create(commonModule, autoBind(), ...modules);
14
+ const container = new Container();
15
+ container.load(commonModule, autoBind(), ...modules);
16
16
  ContainerProvider.set(container);
17
- const application = container.get<Application>(Application);
18
- return application;
17
+ return container.get<Application>(Application);
19
18
  }
20
19
  }
@@ -156,8 +156,8 @@ describe('core 组件装配', () => {
156
156
  await boot();
157
157
  const c = ContainerUtil.get(Consumer);
158
158
  expect([c.redis.kind, c.eu.kind, c.fallback.kind]).to.deep.equal(['redis', 'eu', 'memory']);
159
- expect(ContainerUtil.getNamed<{ kind: string }>(Store, 'redis')).to.equal(ContainerUtil.get(RedisStore));
160
- expect(ContainerUtil.getTagged<{ kind: string }>(Store, 'region', 'eu')).to.equal(ContainerUtil.get(EuStore));
159
+ expect(ContainerUtil.get<{ kind: string }>(Store, { name: 'redis' })).to.equal(ContainerUtil.get(RedisStore));
160
+ expect(ContainerUtil.get<{ kind: string }>(Store, { tags: { region: 'eu' } })).to.equal(ContainerUtil.get(EuStore));
161
161
  expect(ContainerUtil.get(Store)).to.equal(ContainerUtil.get(MemoryStore));
162
162
  });
163
163
 
@@ -174,19 +174,14 @@ describe('core 组件装配', () => {
174
174
  expect([DefaultMailer, CustomMailer]).to.have.length(2);
175
175
  });
176
176
 
177
- it('现状:同一批 autoBind 里 rebind 本批先定义的组件会失败(按定义的逆序登记,rebind 先于 bind 执行)', async () => {
177
+ it('同一批 autoBind 里也可以 rebind 本批先定义的组件(按定义顺序登记)', async () => {
178
178
  const Mailer = Symbol('SameBatchMailer');
179
179
  @Component(Mailer)
180
- class DefaultMailer { }
180
+ class DefaultMailer { readonly who = 'default'; }
181
181
  @Component({ id: Mailer, rebind: true })
182
- class CustomMailer { }
183
- let error: Error | undefined;
184
- try {
185
- await boot();
186
- } catch (e) {
187
- error = e as Error;
188
- }
189
- expect(error?.message).to.match(/unbind.*SameBatchMailer/i);
182
+ class CustomMailer { readonly who = 'custom'; }
183
+ await boot();
184
+ expect(ContainerUtil.getAll<{ who: string }>(Mailer).map(m => m.who)).to.deep.equal(['custom']);
190
185
  expect([DefaultMailer, CustomMailer]).to.have.length(2);
191
186
  });
192
187
 
@@ -1,114 +1,83 @@
1
- import { interfaces, ContainerModule } from 'inversify';
2
1
  import { METADATA_KEY } from '../constants';
3
- import { ComponentMetadata, ConstantOption } from '../annotation';
2
+ import type { ComponentMetadata, ConstantOption } from '../annotation';
4
3
  import { ConfigUtil } from '../config/config-util';
5
4
  import { AopProxyFactory, ClassFilter } from '../aop/aop-protocol';
6
- import { ContainerUtil } from './container-util';
5
+ import { Binding, ComponentId, Container, ContainerModule, ContainerModuleRegistry } from './container';
7
6
  import { Scope } from './scope';
8
7
 
9
- export function manualBind(registry?: interfaces.ContainerModuleCallBack): interfaces.ContainerModule {
10
- return new ContainerModule((bind, unbind, isBound, rebind, ...rest) => {
11
- if (registry) {
12
- registry(bind, unbind, isBound, rebind, ...rest);
13
- }
14
- });
15
- }
8
+ type Bind = <T>(id: ComponentId<T>) => Binding<T>;
16
9
 
17
- export function autoBind(registry?: interfaces.ContainerModuleCallBack): interfaces.ContainerModule {
18
- const metadatas: ComponentMetadata[] = Reflect.getMetadata(METADATA_KEY.component, Reflect) || [];
19
- const constantMetadata: ConstantOption[] = Reflect.getMetadata(METADATA_KEY.constantValue, Reflect) || [];
10
+ /**
11
+ * A module of the components registered (`@Component`, `@Constant` and the decorators built on them)
12
+ * since the previous `autoBind()`, in the order they were defined; `registry` adds bindings by hand.
13
+ * A DI module file imports its components, then exports `autoBind()`.
14
+ */
15
+ export function autoBind(registry?: ContainerModuleRegistry): ContainerModule {
16
+ const components: ComponentMetadata[] = Reflect.getMetadata(METADATA_KEY.component, Reflect) || [];
17
+ const constants: ConstantOption[] = Reflect.getMetadata(METADATA_KEY.constantValue, Reflect) || [];
20
18
  Reflect.defineMetadata(METADATA_KEY.component, [], Reflect);
21
19
  Reflect.defineMetadata(METADATA_KEY.constantValue, [], Reflect);
22
- return new ContainerModule((bind, unbind, isBound, rebind, ...rest) => {
23
- for (let index = metadatas!.length - 1; index >= 0; index--) {
24
- const metadata = metadatas![index];
25
- resolve(metadata, bind, rebind);
20
+ return new ContainerModule((bind, unbind, isBound, rebind) => {
21
+ for (const metadata of components) {
22
+ bindComponent(metadata, bind, rebind);
26
23
  }
27
- constantMetadata!.map(metadata => resolveConstant(metadata, bind, rebind));
28
-
29
- if (registry) {
30
- registry(bind, unbind, isBound, rebind, ...rest);
24
+ for (const metadata of constants) {
25
+ bindConstant(metadata, bind, rebind);
31
26
  }
27
+ registry?.(bind, unbind, isBound, rebind);
32
28
  });
33
29
  }
34
30
 
35
- function doProxyIfNeed(metadata: ComponentMetadata, target: any) {
36
- const enabled = ConfigUtil.getRaw().cell?.aop?.enabled;
37
- if (enabled && metadata.proxy) {
38
- const classFilter = ContainerUtil.get<ClassFilter>(ClassFilter);
39
- if (target.constructor && classFilter.matches(target.constructor, metadata)) {
40
- const aopProxyFactory = ContainerUtil.get<AopProxyFactory>(AopProxyFactory);
41
- return aopProxyFactory.create({
42
- target,
43
- metadata
44
- }).getProxy();
31
+ function proxyIfNeeded(container: Container, metadata: ComponentMetadata, instance: any) {
32
+ if (ConfigUtil.getRaw().cell?.aop?.enabled && instance?.constructor) {
33
+ if (container.get<ClassFilter>(ClassFilter).matches(instance.constructor, metadata)) {
34
+ return container.get<AopProxyFactory>(AopProxyFactory).create({ target: instance, metadata }).getProxy();
45
35
  }
46
36
  }
47
-
48
- return target;
37
+ return instance;
49
38
  }
50
39
 
51
- function resolve(metadata: ComponentMetadata, bind: interfaces.Bind, rebind: interfaces.Rebind): void {
52
- let mid: any;
53
- const { ids, scope, name, tag, when, proxy, onActivation, target } = metadata;
54
- const _ids = [...ids];
55
- const id = _ids.shift()!;
56
- if (metadata.rebind) {
57
- const id2 = _ids.shift();
58
- mid = rebind(id2 || id).to(target);
59
- } else {
60
- mid = bind(id).to(target);
61
- }
40
+ /**
41
+ * The first identifier (the class itself unless the decorator says otherwise) is bound to the class,
42
+ * the others resolve to it. `rebind` replaces the bindings of the first other identifier.
43
+ */
44
+ function bindComponent(metadata: ComponentMetadata, bind: Bind, rebind: Bind): void {
45
+ const { ids: [primary, ...aliases], scope, name, tag, proxy, onActivation, target } = metadata;
46
+ const main = (metadata.rebind && aliases.length === 0 ? rebind : bind)(primary).to(target);
62
47
  if (scope === Scope.Singleton) {
63
- mid = mid.inSingletonScope();
64
- } else if (scope === Scope.Transient) {
65
- mid = mid.inTransientScope();
48
+ main.inSingletonScope();
66
49
  }
67
-
68
- const constrain = (syntax: any) => {
69
- if (name) {
70
- return syntax.whenTargetNamed(name);
50
+ if (onActivation) {
51
+ main.onActivation(onActivation);
52
+ } else if (proxy) {
53
+ main.onActivation((context, instance) => proxyIfNeeded(context.container, metadata, instance));
54
+ }
55
+ const constrain = (binding: Binding) => {
56
+ if (name !== undefined) {
57
+ binding.whenTargetNamed(name);
71
58
  } else if (tag) {
72
- return syntax.whenTargetTagged(tag.tag, tag.value);
59
+ binding.whenTargetTagged(tag.tag, tag.value);
73
60
  } else if (metadata.default) {
74
- return syntax.whenTargetIsDefault();
75
- } else if (when) {
76
- return syntax.when(when);
61
+ binding.whenTargetIsDefault();
77
62
  }
78
- return syntax;
79
63
  };
80
- // name / tag / default / when choose among the implementations of an id, so they go on the bindings of
81
- // the ids (`@Component({ id, name })`); the class itself stays reachable without them.
82
- const aliases = !metadata.rebind && (name || tag || metadata.default || when) ? _ids : [];
83
64
  if (aliases.length === 0) {
84
- mid = constrain(mid);
65
+ constrain(main);
85
66
  }
86
-
87
- if (onActivation) {
88
- mid.onActivation(onActivation);
89
- } else if (proxy) {
90
- mid.onActivation((context: interfaces.Context, t: any) => doProxyIfNeed(metadata, t));
91
- }
92
-
93
- for (const item of _ids) {
94
- if (aliases.includes(item)) {
95
- constrain(bind(item).toDynamicValue(context => context.container.get(id)));
96
- } else {
97
- bind(item).toService(id);
67
+ aliases.forEach((alias, index) => {
68
+ const binding = (metadata.rebind && index === 0 ? rebind : bind)(alias).toService(primary);
69
+ // An alias of a singleton is that singleton: it is cached too.
70
+ if (scope === Scope.Singleton) {
71
+ binding.inSingletonScope();
98
72
  }
99
- }
73
+ constrain(binding);
74
+ });
100
75
  }
101
76
 
102
- function resolveConstant(metadata: ConstantOption, bind: interfaces.Bind, rebind: interfaces.Rebind): void {
103
- const ids = Array.isArray(metadata.id) ? [...metadata.id] : [ metadata.id ];
104
- const id = ids.shift();
105
- if (metadata.rebind) {
106
- rebind(id!).toConstantValue(metadata.constantValue);
107
- } else {
108
- bind(id!).toConstantValue(metadata.constantValue);
77
+ function bindConstant(metadata: ConstantOption, bind: Bind, rebind: Bind): void {
78
+ const [first, ...others] = Array.isArray(metadata.id) ? metadata.id : [metadata.id];
79
+ (metadata.rebind ? rebind : bind)(first).toConstantValue(metadata.constantValue);
80
+ for (const id of others) {
81
+ bind(id).toConstantValue(metadata.constantValue);
109
82
  }
110
-
111
- for (const item of ids) {
112
- bind(item!).toService(id!);
113
- }
114
- }
83
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Why the container could not give a component. `code` is stable (the same codes `cell check` reports),
3
+ * `hint` says how to fix it in one sentence and `path` is the chain of identifiers being resolved,
4
+ * outermost first (docs/design/agent-first.md R5).
5
+ */
6
+ export class ContainerError extends Error {
7
+ override readonly name = 'ContainerError';
8
+ readonly code: ContainerError.Code;
9
+ readonly hint: string;
10
+ readonly path: string[];
11
+
12
+ constructor(options: { code: ContainerError.Code, message: string, hint: string, path?: string[] }) {
13
+ super(options.message);
14
+ this.code = options.code;
15
+ this.hint = options.hint;
16
+ this.path = options.path ?? [];
17
+ }
18
+ }
19
+
20
+ export namespace ContainerError {
21
+ export type Code =
22
+ | 'CELL_DI_NO_BINDING'
23
+ | 'CELL_DI_AMBIGUOUS'
24
+ | 'CELL_DI_CIRCULAR'
25
+ | 'CELL_DI_MISSING_INJECT'
26
+ | 'CELL_DI_INCOMPLETE_BINDING';
27
+
28
+ export function is(error: unknown, code?: Code): error is ContainerError {
29
+ return error instanceof ContainerError && (code === undefined || error.code === code);
30
+ }
31
+ }
@@ -1,23 +1,25 @@
1
- import { interfaces } from 'inversify';
2
- import { Deferred } from '../utils';
1
+ import type { Container } from './container';
2
+ import { Deferred } from '../utils/promise-util';
3
3
 
4
- let _container: interfaces.Container;
4
+ let _container: Container | undefined;
5
5
 
6
- const _containerDeferred = new Deferred<interfaces.Container>();
6
+ const _containerDeferred = new Deferred<Container>();
7
7
 
8
+ /** The container of the running application, for code that is not a component. */
8
9
  export namespace ContainerProvider {
9
- export function set(container: interfaces.Container): void {
10
+ export function set(container: Container): void {
10
11
  _container = container;
11
12
  _containerDeferred.resolve(container);
12
13
  }
13
- export function provide(): interfaces.Container {
14
+
15
+ export function provide(): Container {
14
16
  if (!_container) {
15
17
  throw new Error('Container is not ready yet, the timing is incorrect.');
16
18
  }
17
19
  return _container;
18
20
  }
19
21
 
20
- export function asyncProvide(): Promise<interfaces.Container> {
22
+ export function asyncProvide(): Promise<Container> {
21
23
  return _containerDeferred.promise;
22
24
  }
23
25
  }
@@ -1,28 +1,17 @@
1
- import { interfaces } from 'inversify';
1
+ import type { BindingQuery, ComponentId } from './container';
2
2
  import { ContainerProvider } from './container-provider';
3
3
 
4
+ /** Components of the running application's container, for code that is not a component. */
4
5
  export namespace ContainerUtil {
5
- export function get<T>(serviceIdentifier: interfaces.ServiceIdentifier<T>): T {
6
- return ContainerProvider.provide().get(serviceIdentifier);
6
+ export function get<T>(id: ComponentId<T>, query?: BindingQuery): T {
7
+ return ContainerProvider.provide().get(id, query);
7
8
  }
8
9
 
9
- export function getAll<T>(serviceIdentifier: interfaces.ServiceIdentifier<T>): T[] {
10
- return ContainerProvider.provide().getAll(serviceIdentifier);
10
+ export function getAll<T>(id: ComponentId<T>, query?: BindingQuery): T[] {
11
+ return ContainerProvider.provide().getAll(id, query);
11
12
  }
12
13
 
13
- export function getAllNamed<T>(serviceIdentifier: interfaces.ServiceIdentifier<T>, named: string | number | symbol): T[] {
14
- return ContainerProvider.provide().getAllNamed(serviceIdentifier, named);
15
- }
16
-
17
- export function getNamed<T>(serviceIdentifier: interfaces.ServiceIdentifier<T>, named: string | number | symbol): T {
18
- return ContainerProvider.provide().getNamed(serviceIdentifier, named);
19
- }
20
-
21
- export function getAllTagged<T>(serviceIdentifier: interfaces.ServiceIdentifier<T>, key: string | number | symbol, value: any): T[] {
22
- return ContainerProvider.provide().getAllTagged(serviceIdentifier, key, value);
23
- }
24
-
25
- export function getTagged<T>(serviceIdentifier: interfaces.ServiceIdentifier<T>, key: string | number | symbol, value: any): T {
26
- return ContainerProvider.provide().getTagged(serviceIdentifier, key, value);
14
+ export function isBound(id: ComponentId, query?: BindingQuery): boolean {
15
+ return ContainerProvider.provide().isBound(id, query);
27
16
  }
28
17
  }