@celljs/core 4.0.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 (529) hide show
  1. package/README.md +49 -68
  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/application/application-protocol.js +1 -1
  46. package/esm/common/application/application-protocol.js.map +1 -1
  47. package/esm/common/config/config-provider.js +2 -1
  48. package/esm/common/config/config-provider.js.map +1 -1
  49. package/esm/common/container/auto-bind.d.ts +7 -3
  50. package/esm/common/container/auto-bind.js +54 -71
  51. package/esm/common/container/auto-bind.js.map +1 -1
  52. package/esm/common/container/container-error.d.ts +21 -0
  53. package/esm/common/container/container-error.js +22 -0
  54. package/esm/common/container/container-error.js.map +1 -0
  55. package/esm/common/container/container-provider.d.ts +5 -4
  56. package/esm/common/container/container-provider.js +2 -1
  57. package/esm/common/container/container-provider.js.map +1 -1
  58. package/esm/common/container/container-util.d.ts +5 -7
  59. package/esm/common/container/container-util.js +8 -19
  60. package/esm/common/container/container-util.js.map +1 -1
  61. package/esm/common/container/container.d.ts +104 -0
  62. package/esm/common/container/container.js +299 -0
  63. package/esm/common/container/container.js.map +1 -0
  64. package/esm/common/container/dynamic-container.d.ts +1 -1
  65. package/esm/common/container/dynamic-container.js +2 -2
  66. package/esm/common/container/dynamic-container.js.map +1 -1
  67. package/esm/common/container/index.d.ts +5 -6
  68. package/esm/common/container/index.js +5 -3
  69. package/esm/common/container/index.js.map +1 -1
  70. package/esm/common/container/injection.d.ts +40 -0
  71. package/esm/common/container/injection.js +109 -0
  72. package/esm/common/container/injection.js.map +1 -0
  73. package/esm/common/container/scope.d.ts +2 -3
  74. package/esm/common/container/scope.js +2 -3
  75. package/esm/common/container/scope.js.map +1 -1
  76. package/esm/common/el/application-expression-engine.d.ts +7 -0
  77. package/esm/common/{provider/provider-creator.js → el/application-expression-engine.js} +11 -11
  78. package/esm/common/el/application-expression-engine.js.map +1 -0
  79. package/esm/common/el/core-context-initializer.d.ts +3 -2
  80. package/esm/common/el/core-context-initializer.js +10 -8
  81. package/esm/common/el/core-context-initializer.js.map +1 -1
  82. package/esm/common/el/expression-compiler.d.ts +7 -17
  83. package/esm/common/el/expression-compiler.js +10 -166
  84. package/esm/common/el/expression-compiler.js.map +1 -1
  85. package/esm/common/el/expression-engine.d.ts +61 -0
  86. package/esm/common/el/expression-engine.js +459 -0
  87. package/esm/common/el/expression-engine.js.map +1 -0
  88. package/esm/common/el/expression-handler.d.ts +8 -4
  89. package/esm/common/el/expression-handler.js +15 -58
  90. package/esm/common/el/expression-handler.js.map +1 -1
  91. package/esm/common/el/expression-protocol.d.ts +3 -5
  92. package/esm/common/el/expression-protocol.js +0 -1
  93. package/esm/common/el/expression-protocol.js.map +1 -1
  94. package/esm/common/el/expression-util.d.ts +69 -0
  95. package/esm/common/el/expression-util.js +346 -0
  96. package/esm/common/el/expression-util.js.map +1 -0
  97. package/esm/common/el/index.d.ts +3 -1
  98. package/esm/common/el/index.js +3 -1
  99. package/esm/common/el/index.js.map +1 -1
  100. package/esm/common/logger/abstract-logger.d.ts +4 -2
  101. package/esm/common/logger/abstract-logger.js +11 -6
  102. package/esm/common/logger/abstract-logger.js.map +1 -1
  103. package/esm/common/logger/logger-protocol.d.ts +4 -0
  104. package/esm/common/logger/logger-protocol.js +2 -0
  105. package/esm/common/logger/logger-protocol.js.map +1 -1
  106. package/esm/common/logger/logger.js +7 -7
  107. package/esm/common/logger/logger.js.map +1 -1
  108. package/esm/common/provider/index.d.ts +0 -1
  109. package/esm/common/provider/index.js +0 -1
  110. package/esm/common/provider/index.js.map +1 -1
  111. package/esm/common/provider/provider-protocol.d.ts +5 -9
  112. package/esm/common/provider/provider-protocol.js +0 -1
  113. package/esm/common/provider/provider-protocol.js.map +1 -1
  114. package/esm/common/provider/provider-util.d.ts +1 -1
  115. package/esm/common/provider/provider-util.js +2 -2
  116. package/esm/common/provider/provider-util.js.map +1 -1
  117. package/esm/common/provider/provider.d.ts +7 -6
  118. package/esm/common/provider/provider.js +15 -26
  119. package/esm/common/provider/provider.js.map +1 -1
  120. package/esm/common/static-module.d.ts +1 -1
  121. package/esm/common/static-module.js +1 -1
  122. package/esm/common/static-module.js.map +1 -1
  123. package/esm/common/test/mock-logger.d.ts +1 -0
  124. package/esm/common/test/mock-logger.js +5 -13
  125. package/esm/common/test/mock-logger.js.map +1 -1
  126. package/esm/common/test/test-module.d.ts +1 -1
  127. package/esm/common/test/test-module.js +1 -1
  128. package/esm/common/test/test-module.js.map +1 -1
  129. package/esm/common/utils/annotation-util.js +2 -1
  130. package/esm/common/utils/annotation-util.js.map +1 -1
  131. package/esm/common/utils/emitter.d.ts +1 -10
  132. package/esm/common/utils/emitter.js +0 -56
  133. package/esm/common/utils/emitter.js.map +1 -1
  134. package/esm/common/utils/mime-type-util.js +1 -1
  135. package/esm/common/utils/mime-type-util.js.map +1 -1
  136. package/esm/common/utils/mime-type.js +1 -1
  137. package/esm/common/utils/mime-type.js.map +1 -1
  138. package/esm/common/utils/proxy-util.d.ts +5 -2
  139. package/esm/common/utils/proxy-util.js +10 -28
  140. package/esm/common/utils/proxy-util.js.map +1 -1
  141. package/esm/node/context/context.d.ts +11 -2
  142. package/esm/node/context/context.js +36 -12
  143. package/esm/node/context/context.js.map +1 -1
  144. package/esm/node/index.d.ts +0 -1
  145. package/esm/node/index.js +0 -1
  146. package/esm/node/index.js.map +1 -1
  147. package/esm/node/static-module.d.ts +1 -1
  148. package/lib/browser/static-module.d.ts +1 -1
  149. package/lib/common/annotation/aspect.d.ts +2 -1
  150. package/lib/common/annotation/aspect.d.ts.map +1 -1
  151. package/lib/common/annotation/aspect.js.map +1 -1
  152. package/lib/common/annotation/autowired-provider.d.ts +0 -2
  153. package/lib/common/annotation/autowired-provider.d.ts.map +1 -1
  154. package/lib/common/annotation/autowired-provider.js +4 -14
  155. package/lib/common/annotation/autowired-provider.js.map +1 -1
  156. package/lib/common/annotation/autowired.d.ts +1 -1
  157. package/lib/common/annotation/autowired.d.ts.map +1 -1
  158. package/lib/common/annotation/autowired.js +11 -3
  159. package/lib/common/annotation/autowired.js.map +1 -1
  160. package/lib/common/annotation/component.d.ts +4 -8
  161. package/lib/common/annotation/component.d.ts.map +1 -1
  162. package/lib/common/annotation/component.js +0 -6
  163. package/lib/common/annotation/component.js.map +1 -1
  164. package/lib/common/annotation/constant.d.ts +1 -1
  165. package/lib/common/annotation/constant.d.ts.map +1 -1
  166. package/lib/common/annotation/constant.js +6 -3
  167. package/lib/common/annotation/constant.js.map +1 -1
  168. package/lib/common/annotation/detached/autowired-provider.js +2 -2
  169. package/lib/common/annotation/detached/autowired-provider.js.map +1 -1
  170. package/lib/common/annotation/index.d.ts +0 -6
  171. package/lib/common/annotation/index.d.ts.map +1 -1
  172. package/lib/common/annotation/index.js +0 -6
  173. package/lib/common/annotation/index.js.map +1 -1
  174. package/lib/common/annotation/named.d.ts +2 -1
  175. package/lib/common/annotation/named.d.ts.map +1 -1
  176. package/lib/common/annotation/named.js +6 -2
  177. package/lib/common/annotation/named.js.map +1 -1
  178. package/lib/common/annotation/optional.d.ts +2 -1
  179. package/lib/common/annotation/optional.d.ts.map +1 -1
  180. package/lib/common/annotation/optional.js +6 -2
  181. package/lib/common/annotation/optional.js.map +1 -1
  182. package/lib/common/annotation/post-construct.d.ts +2 -1
  183. package/lib/common/annotation/post-construct.d.ts.map +1 -1
  184. package/lib/common/annotation/post-construct.js +6 -2
  185. package/lib/common/annotation/post-construct.js.map +1 -1
  186. package/lib/common/annotation/tagged.d.ts +2 -1
  187. package/lib/common/annotation/tagged.d.ts.map +1 -1
  188. package/lib/common/annotation/tagged.js +7 -2
  189. package/lib/common/annotation/tagged.js.map +1 -1
  190. package/lib/common/annotation/value.d.ts +3 -2
  191. package/lib/common/annotation/value.d.ts.map +1 -1
  192. package/lib/common/annotation/value.js +7 -10
  193. package/lib/common/annotation/value.js.map +1 -1
  194. package/lib/common/aop/aop-proxy-factory.d.ts +6 -2
  195. package/lib/common/aop/aop-proxy-factory.d.ts.map +1 -1
  196. package/lib/common/aop/aop-proxy-factory.js +45 -29
  197. package/lib/common/aop/aop-proxy-factory.js.map +1 -1
  198. package/lib/common/aop/aop.spec.d.ts +2 -0
  199. package/lib/common/aop/aop.spec.d.ts.map +1 -0
  200. package/lib/common/aop/aop.spec.js +170 -0
  201. package/lib/common/aop/aop.spec.js.map +1 -0
  202. package/lib/common/aop/class-filter.js +7 -7
  203. package/lib/common/aop/class-filter.js.map +1 -1
  204. package/lib/common/application/application-factory.d.ts +1 -1
  205. package/lib/common/application/application-factory.d.ts.map +1 -1
  206. package/lib/common/application/application-factory.js +4 -4
  207. package/lib/common/application/application-factory.js.map +1 -1
  208. package/lib/common/application/application-protocol.js +1 -1
  209. package/lib/common/application/application-protocol.js.map +1 -1
  210. package/lib/common/application/lifecycle.spec.d.ts +2 -0
  211. package/lib/common/application/lifecycle.spec.d.ts.map +1 -0
  212. package/lib/common/application/lifecycle.spec.js +155 -0
  213. package/lib/common/application/lifecycle.spec.js.map +1 -0
  214. package/lib/common/config/config-provider.js +2 -1
  215. package/lib/common/config/config-provider.js.map +1 -1
  216. package/lib/common/container/assembly.spec.d.ts +2 -0
  217. package/lib/common/container/assembly.spec.d.ts.map +1 -0
  218. package/lib/common/container/assembly.spec.js +464 -0
  219. package/lib/common/container/assembly.spec.js.map +1 -0
  220. package/lib/common/container/auto-bind.d.ts +7 -3
  221. package/lib/common/container/auto-bind.d.ts.map +1 -1
  222. package/lib/common/container/auto-bind.js +54 -72
  223. package/lib/common/container/auto-bind.js.map +1 -1
  224. package/lib/common/container/container-error.d.ts +22 -0
  225. package/lib/common/container/container-error.d.ts.map +1 -0
  226. package/lib/common/container/container-error.js +26 -0
  227. package/lib/common/container/container-error.js.map +1 -0
  228. package/lib/common/container/container-provider.d.ts +5 -4
  229. package/lib/common/container/container-provider.d.ts.map +1 -1
  230. package/lib/common/container/container-provider.js +3 -2
  231. package/lib/common/container/container-provider.js.map +1 -1
  232. package/lib/common/container/container-util.d.ts +5 -7
  233. package/lib/common/container/container-util.d.ts.map +1 -1
  234. package/lib/common/container/container-util.js +8 -19
  235. package/lib/common/container/container-util.js.map +1 -1
  236. package/lib/common/container/container.d.ts +105 -0
  237. package/lib/common/container/container.d.ts.map +1 -0
  238. package/lib/common/container/container.js +305 -0
  239. package/lib/common/container/container.js.map +1 -0
  240. package/lib/common/container/container.spec.d.ts +2 -0
  241. package/lib/common/container/container.spec.d.ts.map +1 -0
  242. package/lib/common/container/container.spec.js +334 -0
  243. package/lib/common/container/container.spec.js.map +1 -0
  244. package/lib/common/container/dynamic-container.d.ts +1 -1
  245. package/lib/common/container/dynamic-container.d.ts.map +1 -1
  246. package/lib/common/container/dynamic-container.js +3 -3
  247. package/lib/common/container/dynamic-container.js.map +1 -1
  248. package/lib/common/container/index.d.ts +5 -6
  249. package/lib/common/container/index.d.ts.map +1 -1
  250. package/lib/common/container/index.js +5 -3
  251. package/lib/common/container/index.js.map +1 -1
  252. package/lib/common/container/injection.d.ts +41 -0
  253. package/lib/common/container/injection.d.ts.map +1 -0
  254. package/lib/common/container/injection.js +112 -0
  255. package/lib/common/container/injection.js.map +1 -0
  256. package/lib/common/container/scope.d.ts +2 -3
  257. package/lib/common/container/scope.d.ts.map +1 -1
  258. package/lib/common/container/scope.js +2 -3
  259. package/lib/common/container/scope.js.map +1 -1
  260. package/lib/common/el/application-expression-engine.d.ts +8 -0
  261. package/lib/common/el/application-expression-engine.d.ts.map +1 -0
  262. package/lib/common/el/application-expression-engine.js +22 -0
  263. package/lib/common/el/application-expression-engine.js.map +1 -0
  264. package/lib/common/el/core-context-initializer.d.ts +3 -2
  265. package/lib/common/el/core-context-initializer.d.ts.map +1 -1
  266. package/lib/common/el/core-context-initializer.js +9 -7
  267. package/lib/common/el/core-context-initializer.js.map +1 -1
  268. package/lib/common/el/expression-compiler.d.ts +7 -17
  269. package/lib/common/el/expression-compiler.d.ts.map +1 -1
  270. package/lib/common/el/expression-compiler.js +10 -166
  271. package/lib/common/el/expression-compiler.js.map +1 -1
  272. package/lib/common/el/expression-engine.d.ts +62 -0
  273. package/lib/common/el/expression-engine.d.ts.map +1 -0
  274. package/lib/common/el/expression-engine.js +465 -0
  275. package/lib/common/el/expression-engine.js.map +1 -0
  276. package/lib/common/el/expression-engine.spec.d.ts +2 -0
  277. package/lib/common/el/expression-engine.spec.d.ts.map +1 -0
  278. package/lib/common/el/expression-engine.spec.js +100 -0
  279. package/lib/common/el/expression-engine.spec.js.map +1 -0
  280. package/lib/common/el/expression-handler.d.ts +8 -4
  281. package/lib/common/el/expression-handler.d.ts.map +1 -1
  282. package/lib/common/el/expression-handler.js +14 -60
  283. package/lib/common/el/expression-handler.js.map +1 -1
  284. package/lib/common/el/expression-handler.spec.d.ts +2 -0
  285. package/lib/common/el/expression-handler.spec.d.ts.map +1 -0
  286. package/lib/common/el/expression-handler.spec.js +98 -0
  287. package/lib/common/el/expression-handler.spec.js.map +1 -0
  288. package/lib/common/el/expression-protocol.d.ts +3 -5
  289. package/lib/common/el/expression-protocol.d.ts.map +1 -1
  290. package/lib/common/el/expression-protocol.js +1 -2
  291. package/lib/common/el/expression-protocol.js.map +1 -1
  292. package/lib/common/el/expression-util.d.ts +70 -0
  293. package/lib/common/el/expression-util.d.ts.map +1 -0
  294. package/lib/common/el/expression-util.js +351 -0
  295. package/lib/common/el/expression-util.js.map +1 -0
  296. package/lib/common/el/expression-util.spec.d.ts +2 -0
  297. package/lib/common/el/expression-util.spec.d.ts.map +1 -0
  298. package/lib/common/el/expression-util.spec.js +45 -0
  299. package/lib/common/el/expression-util.spec.js.map +1 -0
  300. package/lib/common/el/index.d.ts +3 -1
  301. package/lib/common/el/index.d.ts.map +1 -1
  302. package/lib/common/el/index.js +3 -1
  303. package/lib/common/el/index.js.map +1 -1
  304. package/lib/common/el/value-and-el.spec.d.ts +2 -0
  305. package/lib/common/el/value-and-el.spec.d.ts.map +1 -0
  306. package/lib/common/el/value-and-el.spec.js +216 -0
  307. package/lib/common/el/value-and-el.spec.js.map +1 -0
  308. package/lib/common/logger/abstract-logger.d.ts +4 -2
  309. package/lib/common/logger/abstract-logger.d.ts.map +1 -1
  310. package/lib/common/logger/abstract-logger.js +10 -5
  311. package/lib/common/logger/abstract-logger.js.map +1 -1
  312. package/lib/common/logger/logger-protocol.d.ts +4 -0
  313. package/lib/common/logger/logger-protocol.d.ts.map +1 -1
  314. package/lib/common/logger/logger-protocol.js +3 -1
  315. package/lib/common/logger/logger-protocol.js.map +1 -1
  316. package/lib/common/logger/logger.js +7 -7
  317. package/lib/common/logger/logger.js.map +1 -1
  318. package/lib/common/logger/logger.spec.d.ts +2 -0
  319. package/lib/common/logger/logger.spec.d.ts.map +1 -0
  320. package/lib/common/logger/logger.spec.js +57 -0
  321. package/lib/common/logger/logger.spec.js.map +1 -0
  322. package/lib/common/provider/index.d.ts +0 -1
  323. package/lib/common/provider/index.d.ts.map +1 -1
  324. package/lib/common/provider/index.js +0 -1
  325. package/lib/common/provider/index.js.map +1 -1
  326. package/lib/common/provider/provider-protocol.d.ts +5 -9
  327. package/lib/common/provider/provider-protocol.d.ts.map +1 -1
  328. package/lib/common/provider/provider-protocol.js +1 -2
  329. package/lib/common/provider/provider-protocol.js.map +1 -1
  330. package/lib/common/provider/provider-util.d.ts +1 -1
  331. package/lib/common/provider/provider-util.d.ts.map +1 -1
  332. package/lib/common/provider/provider-util.js +2 -2
  333. package/lib/common/provider/provider-util.js.map +1 -1
  334. package/lib/common/provider/provider.d.ts +7 -6
  335. package/lib/common/provider/provider.d.ts.map +1 -1
  336. package/lib/common/provider/provider.js +16 -26
  337. package/lib/common/provider/provider.js.map +1 -1
  338. package/lib/common/static-module.d.ts +1 -1
  339. package/lib/common/static-module.js +2 -2
  340. package/lib/common/static-module.js.map +1 -1
  341. package/lib/common/test/mock-logger.d.ts +1 -0
  342. package/lib/common/test/mock-logger.d.ts.map +1 -1
  343. package/lib/common/test/mock-logger.js +5 -12
  344. package/lib/common/test/mock-logger.js.map +1 -1
  345. package/lib/common/test/test-module.d.ts +1 -1
  346. package/lib/common/test/test-module.d.ts.map +1 -1
  347. package/lib/common/test/test-module.js +2 -2
  348. package/lib/common/test/test-module.js.map +1 -1
  349. package/lib/common/utils/annotation-util.js +2 -1
  350. package/lib/common/utils/annotation-util.js.map +1 -1
  351. package/lib/common/utils/emitter.d.ts +1 -10
  352. package/lib/common/utils/emitter.d.ts.map +1 -1
  353. package/lib/common/utils/emitter.js +1 -58
  354. package/lib/common/utils/emitter.js.map +1 -1
  355. package/lib/common/utils/mime-type-util.js +1 -1
  356. package/lib/common/utils/mime-type-util.js.map +1 -1
  357. package/lib/common/utils/mime-type.js +1 -1
  358. package/lib/common/utils/mime-type.js.map +1 -1
  359. package/lib/common/utils/proxy-util.d.ts +5 -2
  360. package/lib/common/utils/proxy-util.d.ts.map +1 -1
  361. package/lib/common/utils/proxy-util.js +12 -30
  362. package/lib/common/utils/proxy-util.js.map +1 -1
  363. package/lib/common/utils/utils-behavior.spec.d.ts +2 -0
  364. package/lib/common/utils/utils-behavior.spec.d.ts.map +1 -0
  365. package/lib/common/utils/utils-behavior.spec.js +232 -0
  366. package/lib/common/utils/utils-behavior.spec.js.map +1 -0
  367. package/lib/node/context/context.d.ts +11 -2
  368. package/lib/node/context/context.d.ts.map +1 -1
  369. package/lib/node/context/context.js +36 -10
  370. package/lib/node/context/context.js.map +1 -1
  371. package/lib/node/context/context.spec.d.ts +2 -0
  372. package/lib/node/context/context.spec.d.ts.map +1 -0
  373. package/lib/node/context/context.spec.js +202 -0
  374. package/lib/node/context/context.spec.js.map +1 -0
  375. package/lib/node/index.d.ts +0 -1
  376. package/lib/node/index.d.ts.map +1 -1
  377. package/lib/node/index.js +0 -1
  378. package/lib/node/index.js.map +1 -1
  379. package/lib/node/static-module.d.ts +1 -1
  380. package/package.json +9 -21
  381. package/src/common/annotation/aspect.ts +2 -1
  382. package/src/common/annotation/autowired-provider.ts +4 -17
  383. package/src/common/annotation/autowired.ts +14 -6
  384. package/src/common/annotation/component.ts +6 -26
  385. package/src/common/annotation/constant.ts +10 -7
  386. package/src/common/annotation/detached/autowired-provider.ts +2 -2
  387. package/src/common/annotation/index.ts +0 -6
  388. package/src/common/annotation/named.ts +7 -1
  389. package/src/common/annotation/optional.ts +6 -1
  390. package/src/common/annotation/post-construct.ts +6 -1
  391. package/src/common/annotation/tagged.ts +8 -1
  392. package/src/common/annotation/value.ts +9 -11
  393. package/src/common/aop/aop-proxy-factory.ts +52 -30
  394. package/src/common/aop/aop.spec.ts +145 -0
  395. package/src/common/aop/class-filter.ts +6 -6
  396. package/src/common/application/application-factory.ts +4 -5
  397. package/src/common/application/application-protocol.ts +1 -1
  398. package/src/common/application/lifecycle.spec.ts +148 -0
  399. package/src/common/config/config-provider.ts +1 -1
  400. package/src/common/container/assembly.spec.ts +288 -0
  401. package/src/common/container/auto-bind.ts +56 -74
  402. package/src/common/container/container-error.ts +31 -0
  403. package/src/common/container/container-provider.ts +9 -7
  404. package/src/common/container/container-util.ts +8 -19
  405. package/src/common/container/container.spec.ts +262 -0
  406. package/src/common/container/container.ts +363 -0
  407. package/src/common/container/dynamic-container.ts +2 -2
  408. package/src/common/container/index.ts +5 -7
  409. package/src/common/container/injection.ts +135 -0
  410. package/src/common/container/scope.ts +2 -1
  411. package/src/common/el/application-expression-engine.ts +9 -0
  412. package/src/common/el/core-context-initializer.ts +9 -8
  413. package/src/common/el/expression-compiler.ts +9 -168
  414. package/src/common/el/expression-engine.spec.ts +107 -0
  415. package/src/common/el/expression-engine.ts +487 -0
  416. package/src/common/el/expression-handler.spec.ts +109 -0
  417. package/src/common/el/expression-handler.ts +17 -57
  418. package/src/common/el/expression-protocol.ts +4 -8
  419. package/src/common/el/expression-util.spec.ts +45 -0
  420. package/src/common/el/expression-util.ts +362 -0
  421. package/src/common/el/index.ts +3 -1
  422. package/src/common/el/value-and-el.spec.ts +186 -0
  423. package/src/common/logger/abstract-logger.ts +12 -6
  424. package/src/common/logger/logger-protocol.ts +5 -0
  425. package/src/common/logger/logger.spec.ts +61 -0
  426. package/src/common/logger/logger.ts +7 -7
  427. package/src/common/provider/index.ts +0 -2
  428. package/src/common/provider/provider-protocol.ts +5 -11
  429. package/src/common/provider/provider-util.ts +3 -3
  430. package/src/common/provider/provider.ts +17 -29
  431. package/src/common/static-module.ts +1 -1
  432. package/src/common/test/mock-logger.ts +3 -2
  433. package/src/common/test/test-module.ts +1 -1
  434. package/src/common/utils/annotation-util.ts +2 -2
  435. package/src/common/utils/emitter.ts +1 -63
  436. package/src/common/utils/mime-type-util.ts +1 -1
  437. package/src/common/utils/mime-type.ts +1 -1
  438. package/src/common/utils/proxy-util.ts +8 -28
  439. package/src/common/utils/utils-behavior.spec.ts +259 -0
  440. package/src/node/context/context.spec.ts +219 -0
  441. package/src/node/context/context.ts +35 -10
  442. package/src/node/index.ts +0 -1
  443. package/esm/common/annotation/decorate.d.ts +0 -1
  444. package/esm/common/annotation/decorate.js +0 -2
  445. package/esm/common/annotation/decorate.js.map +0 -1
  446. package/esm/common/annotation/inject.d.ts +0 -1
  447. package/esm/common/annotation/inject.js +0 -2
  448. package/esm/common/annotation/inject.js.map +0 -1
  449. package/esm/common/annotation/injectable.d.ts +0 -1
  450. package/esm/common/annotation/injectable.js +0 -2
  451. package/esm/common/annotation/injectable.js.map +0 -1
  452. package/esm/common/annotation/pre-destroy.d.ts +0 -1
  453. package/esm/common/annotation/pre-destroy.js +0 -2
  454. package/esm/common/annotation/pre-destroy.js.map +0 -1
  455. package/esm/common/annotation/target-name.d.ts +0 -1
  456. package/esm/common/annotation/target-name.js +0 -2
  457. package/esm/common/annotation/target-name.js.map +0 -1
  458. package/esm/common/annotation/unmanaged.d.ts +0 -1
  459. package/esm/common/annotation/unmanaged.js +0 -2
  460. package/esm/common/annotation/unmanaged.js.map +0 -1
  461. package/esm/common/container/container-factory.d.ts +0 -4
  462. package/esm/common/container/container-factory.js +0 -9
  463. package/esm/common/container/container-factory.js.map +0 -1
  464. package/esm/common/el/jexl-engine-provider.d.ts +0 -5
  465. package/esm/common/el/jexl-engine-provider.js +0 -22
  466. package/esm/common/el/jexl-engine-provider.js.map +0 -1
  467. package/esm/common/provider/provider-creator.d.ts +0 -6
  468. package/esm/common/provider/provider-creator.js.map +0 -1
  469. package/esm/node/utils/crc.d.ts +0 -1
  470. package/esm/node/utils/crc.js +0 -7
  471. package/esm/node/utils/crc.js.map +0 -1
  472. package/esm/node/utils/index.d.ts +0 -1
  473. package/esm/node/utils/index.js +0 -2
  474. package/esm/node/utils/index.js.map +0 -1
  475. package/lib/common/annotation/decorate.d.ts +0 -2
  476. package/lib/common/annotation/decorate.d.ts.map +0 -1
  477. package/lib/common/annotation/decorate.js +0 -6
  478. package/lib/common/annotation/decorate.js.map +0 -1
  479. package/lib/common/annotation/inject.d.ts +0 -2
  480. package/lib/common/annotation/inject.d.ts.map +0 -1
  481. package/lib/common/annotation/inject.js +0 -6
  482. package/lib/common/annotation/inject.js.map +0 -1
  483. package/lib/common/annotation/injectable.d.ts +0 -2
  484. package/lib/common/annotation/injectable.d.ts.map +0 -1
  485. package/lib/common/annotation/injectable.js +0 -6
  486. package/lib/common/annotation/injectable.js.map +0 -1
  487. package/lib/common/annotation/pre-destroy.d.ts +0 -2
  488. package/lib/common/annotation/pre-destroy.d.ts.map +0 -1
  489. package/lib/common/annotation/pre-destroy.js +0 -6
  490. package/lib/common/annotation/pre-destroy.js.map +0 -1
  491. package/lib/common/annotation/target-name.d.ts +0 -2
  492. package/lib/common/annotation/target-name.d.ts.map +0 -1
  493. package/lib/common/annotation/target-name.js +0 -6
  494. package/lib/common/annotation/target-name.js.map +0 -1
  495. package/lib/common/annotation/unmanaged.d.ts +0 -2
  496. package/lib/common/annotation/unmanaged.d.ts.map +0 -1
  497. package/lib/common/annotation/unmanaged.js +0 -6
  498. package/lib/common/annotation/unmanaged.js.map +0 -1
  499. package/lib/common/container/container-factory.d.ts +0 -5
  500. package/lib/common/container/container-factory.d.ts.map +0 -1
  501. package/lib/common/container/container-factory.js +0 -13
  502. package/lib/common/container/container-factory.js.map +0 -1
  503. package/lib/common/el/jexl-engine-provider.d.ts +0 -6
  504. package/lib/common/el/jexl-engine-provider.d.ts.map +0 -1
  505. package/lib/common/el/jexl-engine-provider.js +0 -25
  506. package/lib/common/el/jexl-engine-provider.js.map +0 -1
  507. package/lib/common/provider/provider-creator.d.ts +0 -7
  508. package/lib/common/provider/provider-creator.d.ts.map +0 -1
  509. package/lib/common/provider/provider-creator.js +0 -22
  510. package/lib/common/provider/provider-creator.js.map +0 -1
  511. package/lib/node/utils/crc.d.ts +0 -2
  512. package/lib/node/utils/crc.d.ts.map +0 -1
  513. package/lib/node/utils/crc.js +0 -10
  514. package/lib/node/utils/crc.js.map +0 -1
  515. package/lib/node/utils/index.d.ts +0 -2
  516. package/lib/node/utils/index.d.ts.map +0 -1
  517. package/lib/node/utils/index.js +0 -18
  518. package/lib/node/utils/index.js.map +0 -1
  519. package/src/common/annotation/decorate.ts +0 -1
  520. package/src/common/annotation/inject.ts +0 -1
  521. package/src/common/annotation/injectable.ts +0 -1
  522. package/src/common/annotation/pre-destroy.ts +0 -1
  523. package/src/common/annotation/target-name.ts +0 -1
  524. package/src/common/annotation/unmanaged.ts +0 -1
  525. package/src/common/container/container-factory.ts +0 -9
  526. package/src/common/el/jexl-engine-provider.ts +0 -18
  527. package/src/common/provider/provider-creator.ts +0 -12
  528. package/src/node/utils/crc.ts +0 -7
  529. package/src/node/utils/index.ts +0 -1
package/lib/node/index.js CHANGED
@@ -16,5 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./application"), exports);
18
18
  __exportStar(require("./context"), exports);
19
- __exportStar(require("./utils"), exports);
20
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,4CAA0B;AAC1B,0CAAwB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,4CAA0B"}
@@ -1,4 +1,4 @@
1
1
  import './index';
2
- declare const _default: import("inversify").interfaces.ContainerModule;
2
+ declare const _default: import("../common").ContainerModule;
3
3
  export default _default;
4
4
  //# sourceMappingURL=static-module.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celljs/core",
3
- "version": "4.0.0",
3
+ "version": "4.2.0",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "cell-component"
@@ -14,6 +14,9 @@
14
14
  "url": "https://github.com/cellbang/cell.git"
15
15
  },
16
16
  "license": "MIT",
17
+ "engines": {
18
+ "node": ">=18.0.0"
19
+ },
17
20
  "main": "lib/common/index.js",
18
21
  "typings": "lib/common/index.d.ts",
19
22
  "files": [
@@ -30,22 +33,7 @@
30
33
  "watch": "tsc -b -w --preserveWatchOutput"
31
34
  },
32
35
  "dependencies": {
33
- "@types/lodash.debounce": "4.0.3",
34
- "@types/lodash.throttle": "^4.1.3",
35
- "cls-hooked": "^4.2.2",
36
- "inversify": "6.1.4",
37
- "jexl": "2.3.0",
38
- "lodash.debounce": "^4.0.8",
39
- "lodash.throttle": "^4.1.1",
40
- "reflect-metadata": "^0.1.13",
41
- "setimmediate": "^1.0.5",
42
- "source-map-support": "^0.5.13",
43
- "traverse": "^0.6.7",
44
- "tslib": "^2.8.0"
45
- },
46
- "devDependencies": {
47
- "@types/jexl": "^2.2.0",
48
- "@types/traverse": "^0.6.32"
36
+ "reflect-metadata": "^0.1.13"
49
37
  },
50
38
  "publishConfig": {
51
39
  "access": "public"
@@ -56,6 +44,10 @@
56
44
  "default": "./lib/common/index.js"
57
45
  },
58
46
  "./package.json": "./package.json",
47
+ "./el": {
48
+ "import": "./esm/common/el/expression-util.js",
49
+ "default": "./lib/common/el/expression-util.js"
50
+ },
59
51
  "./lib/browser": {
60
52
  "import": "./esm/browser/index.js",
61
53
  "default": "./lib/browser/index.js"
@@ -132,10 +124,6 @@
132
124
  "import": "./esm/node/context/index.js",
133
125
  "default": "./lib/node/context/index.js"
134
126
  },
135
- "./lib/node/utils": {
136
- "import": "./esm/node/utils/index.js",
137
- "default": "./lib/node/utils/index.js"
138
- },
139
127
  "./lib/*.js": {
140
128
  "import": "./esm/*.js",
141
129
  "default": "./lib/*.js"
@@ -1,5 +1,6 @@
1
1
  import { AOP_TAG } from '../aop/aop-protocol';
2
- import { ComponentOption, applyComponentDecorator, COMPONENT_TAG, ComponentId, parseComponentOption } from './component';
2
+ import { ComponentOption, applyComponentDecorator, COMPONENT_TAG, parseComponentOption } from './component';
3
+ import type { ComponentId } from '../container/container';
3
4
 
4
5
  export interface AspectOption extends ComponentOption {
5
6
  id: ComponentId;
@@ -1,9 +1,5 @@
1
- import { interfaces } from 'inversify';
2
1
  import { applyAutowiredDecorator, DoInject, parseAutowiredOption, IdOrAutowiredOptionWithoutMulti } from './autowired';
3
- import { Inject } from './inject';
4
- import { Tagged } from './tagged';
5
- import { ProviderCreator } from '../provider/provider-protocol';
6
- import { ComponentId } from './component';
2
+ import { InjectionUtil } from '../container/injection';
7
3
 
8
4
  export const PROVIDER = Symbol('PROVIDER');
9
5
  export const ID_KEY = Symbol('ID_KEY');
@@ -16,16 +12,7 @@ export const AutowiredProvider = function (idOrOption?: IdOrAutowiredOptionWitho
16
12
  };
17
13
 
18
14
  export const doInjectForAutowiredProvider: DoInject = (option, t, k, i) => {
19
- Inject(PROVIDER)(t, k, i);
20
- Tagged(ID_KEY, option.id!)(t, k, i);
15
+ const point = InjectionUtil.point(t, k, i);
16
+ point.id = PROVIDER;
17
+ point.tags = { ...point.tags, [ID_KEY]: option.id };
21
18
  };
22
-
23
- export function bindAutowiredProvider(bind: interfaces.Bind): any {
24
- bind(PROVIDER).toDynamicValue(ctx => {
25
- const id = ctx.currentRequest.target.getCustomTags()?.find(m => m.key === ID_KEY)!.value as ComponentId;
26
- const providerCreator = ctx.container.get<ProviderCreator<any>>(ProviderCreator);
27
-
28
- return providerCreator.create(id, ctx.container);
29
- });
30
- }
31
-
@@ -1,6 +1,6 @@
1
- import { inject, multiInject } from 'inversify';
2
- import { ContainerUtil } from '../container';
3
- import { ComponentId } from './component';
1
+ import { ContainerUtil } from '../container/container-util';
2
+ import { InjectionUtil } from '../container/injection';
3
+ import type { ComponentId } from '../container/container';
4
4
  import { AnnotationUtil } from '../utils';
5
5
 
6
6
  export interface AutowiredOption {
@@ -44,18 +44,26 @@ export function parseAutowiredOption(target: any, targetKey: string, index?: num
44
44
  return { ...defaultAutowiredOption, ...option };
45
45
  }
46
46
 
47
+ const doInjectDefault: DoInject = ({ id, multi }, t, k, i) => {
48
+ const point = InjectionUtil.point(t, k, i);
49
+ point.id = id;
50
+ point.multi = multi;
51
+ };
52
+
53
+ const doGetValueDefault: DoGetValue = ({ id, multi }) => multi ? ContainerUtil.getAll(id!) : ContainerUtil.get(id!);
54
+
47
55
  export function applyAutowiredDecorator(option: AutowiredOption, target: any, targetKey: string, index?: number,
48
- doInject: DoInject = ({ id, multi }, t: any, k, i) => multi ? multiInject(id!)(t, k, i) : inject(id!)(t, k, i),
49
- doGetValue: DoGetValue = ({ id, multi }, t, property) => multi ? ContainerUtil.getAll(id!) : ContainerUtil.get(id!)) {
56
+ doInject: DoInject = doInjectDefault, doGetValue: DoGetValue = doGetValueDefault) {
50
57
 
51
58
  if (option.detached) {
52
59
  if (index !== undefined) {
53
60
  throw new Error(`The ${target.constructor.name} itself is not injected into the container, so the parameter injection of the constructor is not supported.`);
54
61
  }
62
+ // The value comes from the getter: the container leaves the property alone.
63
+ InjectionUtil.remove(target, targetKey);
55
64
  createAutowiredProperty(option, doGetValue, target, targetKey);
56
65
  } else {
57
66
  doInject(option, target, targetKey, index);
58
-
59
67
  }
60
68
  return option;
61
69
  }
@@ -1,10 +1,8 @@
1
- import { decorate, injectable, interfaces, METADATA_KEY as inversify_METADATA_KEY } from 'inversify';
2
1
  import { METADATA_KEY } from '../constants';
3
2
  import { ConfigUtil } from '../config/config-util';
4
3
  import { AnnotationUtil } from '../utils';
5
4
  import { Scope } from '../container/scope';
6
-
7
- export type ComponentId<T = any> = interfaces.ServiceIdentifier<T>;
5
+ import type { ActivationHandler, ComponentId } from '../container/container';
8
6
 
9
7
  export const COMPONENT_TAG = 'Component';
10
8
 
@@ -14,24 +12,22 @@ export interface ComponentOption {
14
12
  name?: string | number | symbol;
15
13
  tag?: { tag: string | number | symbol, value: any };
16
14
  default?: boolean;
17
- when?: (request: interfaces.Request) => boolean;
18
15
  rebind?: boolean;
19
16
  proxy?: boolean;
20
17
  sysTags?: string[];
21
- onActivation?: (context: interfaces.Context, t: any) => any;
18
+ onActivation?: ActivationHandler;
22
19
  }
23
20
 
24
21
  export interface ComponentMetadata {
25
- ids: ComponentId[];
22
+ ids: ComponentId[];
26
23
  scope: Scope;
27
24
  name?: string | number | symbol;
28
25
  tag?: { tag: string | number | symbol, value: any },
29
26
  default?: boolean;
30
- when?: (request: interfaces.Request) => boolean
31
27
  rebind: boolean;
32
28
  proxy: boolean;
33
29
  sysTags: string[]
34
- onActivation?: (context: interfaces.Context, t: any) => any;
30
+ onActivation?: ActivationHandler;
35
31
  target: any;
36
32
  }
37
33
 
@@ -81,13 +77,6 @@ export function parseComponentOption(target: any, idOrOption: any) {
81
77
  }
82
78
 
83
79
  export function applyComponentDecorator(option: ComponentOption, target: any) {
84
-
85
- const isAlreadyDecorated = Reflect.hasOwnMetadata(inversify_METADATA_KEY.PARAM_TYPES, target);
86
-
87
- if (!isAlreadyDecorated) {
88
- decorate(injectable(), target);
89
- }
90
-
91
80
  const metadata: ComponentMetadata = {
92
81
  target,
93
82
  ids: Array.isArray(option.id) ? option.id : [ option.id || target ],
@@ -98,22 +87,13 @@ export function applyComponentDecorator(option: ComponentOption, target: any) {
98
87
  name: option.name,
99
88
  tag: option.tag,
100
89
  default: option.default,
101
- when: option.when,
102
90
  onActivation: option.onActivation
103
91
  };
104
92
 
105
- let metadatas: ComponentMetadata[] = Reflect.getMetadata(
106
- METADATA_KEY.component,
107
- Reflect
108
- );
109
-
93
+ let metadatas: ComponentMetadata[] = Reflect.getMetadata(METADATA_KEY.component, Reflect);
110
94
  if (!metadatas) {
111
95
  metadatas = [];
112
- Reflect.defineMetadata(
113
- METADATA_KEY.component,
114
- metadatas,
115
- Reflect
116
- );
96
+ Reflect.defineMetadata(METADATA_KEY.component, metadatas, Reflect);
117
97
  }
118
98
  metadatas.push(metadata);
119
99
  return metadata;
@@ -1,5 +1,5 @@
1
1
  import { METADATA_KEY } from '../constants';
2
- import { ComponentId } from './component';
2
+ import type { ComponentId } from '../container/container';
3
3
 
4
4
  export interface ConstantOption {
5
5
  id: ComponentId | ComponentId[];
@@ -8,13 +8,16 @@ export interface ConstantOption {
8
8
  }
9
9
 
10
10
  export const Constant = function (id: ComponentId | ComponentId[], constantValue: any, rebind = false): ClassDecorator {
11
- return (t: any) => {
12
- applyConstantDecorator({ id, constantValue, rebind }, t);
13
- };
11
+ return (t: any) => {
12
+ applyConstantDecorator({ id, constantValue, rebind }, t);
14
13
  };
14
+ };
15
15
 
16
16
  export function applyConstantDecorator(option: ConstantOption, target: any): void {
17
- const previousMetadata = Reflect.getMetadata(METADATA_KEY.constantValue, Reflect) || [];
18
- const newMetadata = [option].concat(previousMetadata);
19
- Reflect.defineMetadata(METADATA_KEY.constantValue, newMetadata, Reflect);
17
+ let metadata: ConstantOption[] = Reflect.getMetadata(METADATA_KEY.constantValue, Reflect);
18
+ if (!metadata) {
19
+ metadata = [];
20
+ Reflect.defineMetadata(METADATA_KEY.constantValue, metadata, Reflect);
21
+ }
22
+ metadata.push(option);
20
23
  }
@@ -6,8 +6,8 @@ export const AutowiredProvider = function (idOrOption?: IdOrAutowiredOptionWitho
6
6
  return (target: any, targetKey: string, index?: number) => {
7
7
  const option = parseAutowiredOption(target, targetKey, index, idOrOption);
8
8
  option.detached = true;
9
- applyAutowiredDecorator(option, target, targetKey, index, doInjectForAutowiredProvider, doGetValueForAutorpc);
9
+ applyAutowiredDecorator(option, target, targetKey, index, doInjectForAutowiredProvider, doGetValueForProvider);
10
10
  };
11
11
  };
12
12
 
13
- const doGetValueForAutorpc: DoGetValue = (option, t, property) => ContainerUtil.getTagged(PROVIDER, ID_KEY, option.id!);
13
+ const doGetValueForProvider: DoGetValue = option => ContainerUtil.get(PROVIDER, { tags: { [ID_KEY]: option.id } });
@@ -6,12 +6,6 @@ export * from './constant';
6
6
  export * from './named';
7
7
  export * from './tagged';
8
8
  export * from './post-construct';
9
- export * from './pre-destroy';
10
- export * from './target-name';
11
- export * from './injectable';
12
- export * from './inject';
13
9
  export * from './aspect';
14
10
  export * from './service';
15
- export * from './unmanaged';
16
- export * from './decorate';
17
11
  export * from './autowired-provider';
@@ -1 +1,7 @@
1
- export { named as Named } from 'inversify';
1
+ import { InjectionUtil } from '../container/injection';
2
+
3
+ /** Injects the binding with this name (`@Component({ id, name })`, `whenTargetNamed`). */
4
+ export const Named = (name: string | number | symbol): PropertyDecorator & ParameterDecorator =>
5
+ (target: any, key: string | symbol | undefined, index?: number) => {
6
+ InjectionUtil.point(target, key, index).name = name;
7
+ };
@@ -1 +1,6 @@
1
- export { optional as Optional } from 'inversify';
1
+ import { InjectionUtil } from '../container/injection';
2
+
3
+ /** The parameter or property gets `undefined` (or `[]` for an array) when nothing is bound. */
4
+ export const Optional = (): PropertyDecorator & ParameterDecorator => (target: any, key: string | symbol | undefined, index?: number) => {
5
+ InjectionUtil.point(target, key, index).optional = true;
6
+ };
@@ -1 +1,6 @@
1
- export { postConstruct as PostConstruct } from 'inversify';
1
+ import { InjectionUtil } from '../container/injection';
2
+
3
+ /** Called once the container has injected the properties; one method per class, subclasses inherit it. */
4
+ export const PostConstruct = (): MethodDecorator => (target: any, key: string | symbol) => {
5
+ InjectionUtil.setPostConstruct(target, key);
6
+ };
@@ -1 +1,8 @@
1
- export { tagged as Tagged } from 'inversify';
1
+ import { InjectionUtil } from '../container/injection';
2
+
3
+ /** Injects the binding with this tag (`@Component({ id, tag })`, `whenTargetTagged`). */
4
+ export const Tagged = (key: string | number | symbol, value: unknown): PropertyDecorator & ParameterDecorator =>
5
+ (target: any, propertyKey: string | symbol | undefined, index?: number) => {
6
+ const point = InjectionUtil.point(target, propertyKey, index);
7
+ point.tags = { ...point.tags, [key]: value };
8
+ };
@@ -1,7 +1,8 @@
1
- import { inject, named, interfaces } from 'inversify';
2
1
  import { ConfigUtil } from '../config/config-util';
3
2
  import { AnnotationUtil } from '../utils';
4
3
  import { ConfigProvider } from '../config/config-protocol';
4
+ import { InjectionUtil } from '../container/injection';
5
+ import type { Binding, ComponentId } from '../container/container';
5
6
 
6
7
  export const VALUE = Symbol('Value');
7
8
 
@@ -34,13 +35,14 @@ export function applyValueDecorator(option: ValueOption, target: any, targetKey:
34
35
  if (index !== undefined) {
35
36
  throw new Error(`The ${target.constructor.name} itself is not injected into the container, so the parameter injection of the constructor is not supported.`);
36
37
  }
38
+ InjectionUtil.remove(target, targetKey);
37
39
  createValueProperty(option, target, targetKey);
38
40
  return;
39
41
  }
40
42
 
41
- const el = option.el!;
42
- inject(VALUE)(target, targetKey, index);
43
- named(el)(target, targetKey, index);
43
+ const point = InjectionUtil.point(target, targetKey, index);
44
+ point.id = VALUE;
45
+ point.name = option.el!;
44
46
  return option;
45
47
  }
46
48
 
@@ -54,11 +56,7 @@ export function createValueProperty(option: ValueOption, target: any, property:
54
56
  });
55
57
  }
56
58
 
57
- export function bindValue(bind: interfaces.Bind): any {
58
- bind(VALUE).toDynamicValue(ctx => {
59
- const namedMetadata = ctx.currentRequest.target.getNamedTag();
60
- const el = namedMetadata!.value.toString();
61
- const configProvider = ctx.container.get<ConfigProvider>(ConfigProvider);
62
- return configProvider.get(el);
63
- });
59
+ /** `@Value('a.b')` is an injection of `VALUE` named `a.b`: the configuration value of that key. */
60
+ export function bindValue(bind: <T>(id: ComponentId<T>) => Binding<T>): void {
61
+ bind(VALUE).toDynamicValue(ctx => ctx.container.get<ConfigProvider>(ConfigProvider).get(String(ctx.target.name)));
64
62
  }
@@ -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 {
@@ -0,0 +1,145 @@
1
+ import { describe, it } from 'bun:test';
2
+ import { expect } from 'chai';
3
+ import { ApplicationFactory } from '../application/application-factory';
4
+ import { Component, Aspect } from '../annotation';
5
+ import { ContainerUtil } from '../container/container-util';
6
+ import { MethodBeforeAdvice, AfterReturningAdvice, AfterThrowsAdvice } from './aop-protocol';
7
+
8
+ /**
9
+ * AOP 的约定(阶段 1.E 行为测试):@Aspect 登记通知,proxy: true 的组件被代理。
10
+ * 需要 cell.aop.enabled(core 的 cell.yml 默认 true;这里直接放进配置)。
11
+ */
12
+ const AOP_ON = { cell: { aop: { enabled: true } } };
13
+
14
+ function recordingAspects(log: string[], pointcut?: string) {
15
+ const opt = <T>(id: T) => (pointcut ? { id, pointcut } : id) as any;
16
+ @Aspect(opt(MethodBeforeAdvice))
17
+ class Before implements MethodBeforeAdvice {
18
+ async before(method: string | number | symbol, args: any[]) {
19
+ log.push(`before:${String(method)}(${args.join(',')})`);
20
+ }
21
+ }
22
+ @Aspect(opt(AfterReturningAdvice))
23
+ class AfterReturning implements AfterReturningAdvice {
24
+ async afterReturning(returnValue: any, method: string | number | symbol) {
25
+ log.push(`after:${String(method)}=${returnValue}`);
26
+ }
27
+ }
28
+ @Aspect(opt(AfterThrowsAdvice))
29
+ class AfterThrows implements AfterThrowsAdvice {
30
+ async afterThrows(error: any, method: string | number | symbol) {
31
+ log.push(`throws:${String(method)}:${error.message}`);
32
+ }
33
+ }
34
+ return [Before, AfterReturning, AfterThrows];
35
+ }
36
+
37
+ describe('core AOP', () => {
38
+
39
+ it('proxy: true 的组件:before → 方法 → afterReturning,通知拿到方法名、参数和返回值', async () => {
40
+ const log: string[] = [];
41
+ recordingAspects(log);
42
+ @Component({ proxy: true })
43
+ class Calc {
44
+ async add(a: number, b: number) {
45
+ log.push('run');
46
+ return a + b;
47
+ }
48
+ }
49
+ await ApplicationFactory.create(AOP_ON);
50
+ expect(await ContainerUtil.get(Calc).add(1, 2)).to.equal(3);
51
+ expect(log).to.deep.equal(['before:add(1,2)', 'run', 'after:add=3']);
52
+ });
53
+
54
+ it('方法抛错:调用 afterThrows,然后把原错误抛给调用方,不调用 afterReturning', async () => {
55
+ const log: string[] = [];
56
+ recordingAspects(log);
57
+ @Component({ proxy: true })
58
+ class Failing {
59
+ async go() {
60
+ throw new Error('nope');
61
+ }
62
+ }
63
+ await ApplicationFactory.create(AOP_ON);
64
+ let caught: Error | undefined;
65
+ try {
66
+ await ContainerUtil.get(Failing).go();
67
+ } catch (e) {
68
+ caught = e as Error;
69
+ }
70
+ expect(caught?.message).to.equal('nope');
71
+ expect(log).to.deep.equal(['before:go()', 'throws:go:nope']);
72
+ });
73
+
74
+ it('现状:被代理后,同步方法也变成返回 Promise', async () => {
75
+ const log: string[] = [];
76
+ recordingAspects(log);
77
+ @Component({ proxy: true })
78
+ class Sync {
79
+ twice(n: number) { return n * 2; }
80
+ }
81
+ await ApplicationFactory.create(AOP_ON);
82
+ const result = ContainerUtil.get(Sync).twice(4) as unknown;
83
+ expect(result).to.be.instanceOf(Promise);
84
+ expect(await result).to.equal(8);
85
+ });
86
+
87
+ it('没有 proxy: true 的组件不被代理;cell.aop.enabled 为 false 时也不代理', async () => {
88
+ const log: string[] = [];
89
+ recordingAspects(log);
90
+ @Component()
91
+ class NotProxied {
92
+ hi() { return 'hi'; }
93
+ }
94
+ await ApplicationFactory.create(AOP_ON);
95
+ expect(ContainerUtil.get(NotProxied).hi()).to.equal('hi');
96
+
97
+ recordingAspects(log);
98
+ @Component({ proxy: true })
99
+ class Disabled {
100
+ hi() { return 'hi'; }
101
+ }
102
+ await ApplicationFactory.create({ cell: { aop: { enabled: false } } });
103
+ expect(ContainerUtil.get(Disabled).hi()).to.equal('hi');
104
+ expect(log).to.deep.equal([]);
105
+ });
106
+
107
+ it('没有任何通知时,proxy: true 的组件也不代理(ClassFilter 不匹配)', async () => {
108
+ @Component({ proxy: true })
109
+ class Lonely {
110
+ hi() { return 'hi'; }
111
+ }
112
+ await ApplicationFactory.create(AOP_ON);
113
+ expect(ContainerUtil.get(Lonely).hi()).to.equal('hi');
114
+ });
115
+
116
+ it('pointcut:只作用于 sysTags 里带该标签的组件', async () => {
117
+ const log: string[] = [];
118
+ recordingAspects(log, 'Audited');
119
+ @Component({ proxy: true, sysTags: ['Audited'] })
120
+ class Audited {
121
+ async save(x: string) { return `saved ${x}`; }
122
+ }
123
+ @Component({ proxy: true })
124
+ class Other {
125
+ save(x: string) { return `other ${x}`; }
126
+ }
127
+ await ApplicationFactory.create(AOP_ON);
128
+ expect(await ContainerUtil.get(Audited).save('a')).to.equal('saved a');
129
+ expect(ContainerUtil.get(Other).save('b')).to.equal('other b');
130
+ expect(log).to.deep.equal(['before:save(a)', 'after:save=saved a']);
131
+ });
132
+
133
+ it('非函数属性原样透出', async () => {
134
+ const log: string[] = [];
135
+ recordingAspects(log);
136
+ @Component({ proxy: true })
137
+ class WithField {
138
+ readonly label = 'L';
139
+ async m() { return 1; }
140
+ }
141
+ await ApplicationFactory.create(AOP_ON);
142
+ expect(ContainerUtil.get(WithField).label).to.equal('L');
143
+ expect(log).to.deep.equal([]);
144
+ });
145
+ });
@@ -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
  }