@celljs/core 4.1.0 → 4.3.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
@@ -0,0 +1,135 @@
1
+ import type { ComponentId } from './container';
2
+ import { ContainerError } from './container-error';
3
+
4
+ /**
5
+ * A constructor parameter or property to inject: what to inject (`id`, all of them with `multi`,
6
+ * nothing when `optional` and unbound) and which binding (`name`, `tags`). Also what a dynamic value
7
+ * or constraint gets to see; `owner` and `key` are absent when the container is asked directly.
8
+ */
9
+ export interface InjectionTarget {
10
+ readonly id: ComponentId;
11
+ readonly multi?: boolean;
12
+ readonly optional?: boolean;
13
+ readonly name?: string | number | symbol;
14
+ readonly tags?: Readonly<Record<string | number | symbol, unknown>>;
15
+ /** The class that declares the parameter or property. */
16
+ readonly owner?: Function;
17
+ /** The property, or the index of the constructor parameter. */
18
+ readonly key?: string | symbol | number;
19
+ }
20
+
21
+ /** How the container creates instances of a class; computed once per class. */
22
+ export interface InjectionPlan {
23
+ readonly parameters: readonly InjectionTarget[];
24
+ readonly properties: readonly InjectionTarget[];
25
+ readonly postConstruct?: string | symbol;
26
+ }
27
+
28
+ type Point = { -readonly [K in keyof InjectionTarget]?: InjectionTarget[K] };
29
+
30
+ const PARAMETERS = 'cell:di:parameters';
31
+ const PROPERTIES = 'cell:di:properties';
32
+ const POST_CONSTRUCT = 'cell:di:post-construct';
33
+ /** What TypeScript writes for parameters whose type is an interface, a union or a primitive. */
34
+ const NOT_AN_ID: unknown[] = [Object, Function, Array, String, Number, Boolean, Symbol, BigInt, Promise];
35
+
36
+ export namespace InjectionUtil {
37
+
38
+ const plans = new WeakMap<Function, InjectionPlan>();
39
+
40
+ /**
41
+ * The injection point of a parameter or property decorator (`@Autowired`, `@Optional`, `@Named`...):
42
+ * the first decorator creates it, the others complete it. Subclasses inherit the properties.
43
+ */
44
+ export function point(target: any, key: string | symbol | undefined, index?: number): Point {
45
+ if (index !== undefined) {
46
+ if (key !== undefined) {
47
+ throw new Error(`${target.constructor.name}.${String(key)}: only constructor parameters and properties can be injected.`);
48
+ }
49
+ let parameters: Point[] | undefined = Reflect.getOwnMetadata(PARAMETERS, target);
50
+ if (!parameters) {
51
+ parameters = [];
52
+ Reflect.defineMetadata(PARAMETERS, parameters, target);
53
+ }
54
+ return parameters[index] ??= { owner: target, key: index };
55
+ }
56
+ const owner = target.constructor;
57
+ let properties: Map<string | symbol, Point> | undefined = Reflect.getOwnMetadata(PROPERTIES, owner);
58
+ if (!properties) {
59
+ properties = new Map(Reflect.getMetadata(PROPERTIES, owner));
60
+ Reflect.defineMetadata(PROPERTIES, properties, owner);
61
+ }
62
+ let point = properties.get(key!);
63
+ if (!point || point.owner !== owner) {
64
+ point = { owner, key };
65
+ properties.set(key!, point);
66
+ }
67
+ return point;
68
+ }
69
+
70
+ /** Forgets a property: its value does not come from the container (`detached` injections). */
71
+ export function remove(target: any, key: string | symbol): void {
72
+ const properties: Map<string | symbol, Point> | undefined = Reflect.getOwnMetadata(PROPERTIES, target.constructor);
73
+ properties?.delete(key);
74
+ }
75
+
76
+ export function setPostConstruct(target: any, key: string | symbol): void {
77
+ Reflect.defineMetadata(POST_CONSTRUCT, key, target.constructor);
78
+ }
79
+
80
+ export function plan(type: Function): InjectionPlan {
81
+ let plan = plans.get(type);
82
+ if (!plan) {
83
+ plan = {
84
+ parameters: parameters(type),
85
+ properties: [...(Reflect.getMetadata(PROPERTIES, type) as Map<string | symbol, Point> | undefined)?.values() ?? []].map(complete),
86
+ postConstruct: Reflect.getMetadata(POST_CONSTRUCT, type)
87
+ };
88
+ plans.set(type, plan);
89
+ }
90
+ return plan;
91
+ }
92
+
93
+ /** The parameters of the nearest constructor in the class hierarchy that TypeScript or a decorator described. */
94
+ function parameters(type: Function): InjectionTarget[] {
95
+ for (let c: any = type; c && c !== Function.prototype; c = Object.getPrototypeOf(c)) {
96
+ const points: Point[] | undefined = Reflect.getOwnMetadata(PARAMETERS, c);
97
+ const types: unknown[] | undefined = Reflect.getOwnMetadata('design:paramtypes', c);
98
+ if (points || types) {
99
+ const count = Math.max(points?.length ?? 0, types?.length ?? 0);
100
+ const result: InjectionTarget[] = [];
101
+ for (let i = 0; i < count; i++) {
102
+ const point: Point = points?.[i] ?? { owner: c, key: i };
103
+ const declared = types?.[i];
104
+ result.push(complete(point.id === undefined && typeof declared === 'function' && !NOT_AN_ID.includes(declared)
105
+ ? { ...point, id: declared as Function } : point));
106
+ }
107
+ return result;
108
+ }
109
+ }
110
+ return [];
111
+ }
112
+
113
+ function complete(point: Point): InjectionTarget {
114
+ if (point.id === undefined) {
115
+ throw missing(point);
116
+ }
117
+ return point as InjectionTarget;
118
+ }
119
+
120
+ function missing(point: Point): ContainerError {
121
+ const where = describe(point);
122
+ return new ContainerError({
123
+ code: 'CELL_DI_MISSING_INJECT',
124
+ message: `${where} has no @Autowired (or @Value), so the container does not know what to inject.`,
125
+ hint: 'Add @Autowired(<id>) to the constructor parameter or property; an interface type needs the id explicitly.',
126
+ path: [where]
127
+ });
128
+ }
129
+
130
+ /** `UserService.repository` or `UserService constructor parameter #0`. */
131
+ export function describe(target: Partial<InjectionTarget>): string {
132
+ const owner = target.owner?.name || '(anonymous class)';
133
+ return typeof target.key === 'number' ? `${owner} constructor parameter #${target.key}` : `${owner}.${String(target.key)}`;
134
+ }
135
+ }
@@ -1,3 +1,4 @@
1
1
  export enum Scope {
2
- Request, Singleton, Transient
2
+ Singleton = 'Singleton',
3
+ Transient = 'Transient'
3
4
  }
@@ -0,0 +1,9 @@
1
+ import { Component } from '../annotation/component';
2
+ import { ExpressionEngine } from './expression-engine';
3
+
4
+ /**
5
+ * The expression engine of the application, `@Autowired(ExpressionEngine)`: CoreContextInitializer adds
6
+ * the `replace`, `regexp` and `eval` transforms to it; add your own transforms and functions the same way.
7
+ */
8
+ @Component(ExpressionEngine)
9
+ export class ApplicationExpressionEngine extends ExpressionEngine { }
@@ -1,23 +1,24 @@
1
1
  import { Component, Autowired } from '../annotation';
2
2
  import { ContainerUtil } from '../container';
3
- import { ContextInitializer, ExpressionContext, JexlEngineProvider, ExpressionHandler } from './expression-protocol';
3
+ import { ContextInitializer, ExpressionContext, ExpressionHandler } from './expression-protocol';
4
+ import { ExpressionEngine } from './expression-engine';
4
5
 
5
6
  @Component(ContextInitializer)
6
7
  export class CoreContextInitializer implements ContextInitializer {
7
8
 
8
- @Autowired(JexlEngineProvider)
9
- protected readonly jexlEngineProvider: JexlEngineProvider<any>;
9
+ @Autowired(ExpressionEngine)
10
+ protected readonly engine: ExpressionEngine;
10
11
 
11
12
  initialize(ctx: ExpressionContext): void {
12
13
  if (typeof process !== 'undefined') {
13
14
  ctx.env = { ...process.env, _ignoreEl: true };
14
15
  }
15
- const jexlEngine = this.jexlEngineProvider.provide();
16
- jexlEngine.addTransform('replace',
17
- (val: string, searchValue: string | RegExp, replaceValue: string) => val && val.replace(new RegExp(searchValue, 'g'), replaceValue));
18
- jexlEngine.addTransform('regexp', (pattern: string, flags?: string) => new RegExp(pattern, flags));
19
16
  const expressionHandler = ContainerUtil.get<ExpressionHandler>(ExpressionHandler);
20
- jexlEngine.addTransform('eval', (text: string) => expressionHandler.handle(text));
17
+ this.engine.addTransforms({
18
+ replace: (val: string, searchValue: string | RegExp, replaceValue: string) => val && val.replace(new RegExp(searchValue, 'g'), replaceValue),
19
+ regexp: (pattern: string, flags?: string) => new RegExp(pattern, flags),
20
+ eval: (text: string) => expressionHandler.handle(text)
21
+ });
21
22
  }
22
23
 
23
24
  priority = 500;
@@ -1,17 +1,18 @@
1
1
  import { Component, Autowired } from '../annotation';
2
- import { ExpressionCompiler, ExpressionCompilerOptions, JexlEngineProvider } from './expression-protocol';
2
+ import { ExpressionCompiler, ExpressionCompilerOptions } from './expression-protocol';
3
+ import { Expression, ExpressionEngine } from './expression-engine';
3
4
  import { ExpressionSectionCompiler } from './expression-util';
4
5
 
5
- /** The {@link ExpressionSectionCompiler} on the jexl engine of the container (with its transforms). */
6
+ /** The {@link ExpressionSectionCompiler} on the expression engine of the container (with its transforms). */
6
7
  @Component(ExpressionCompiler)
7
8
  export class ExpressionCompilerImpl implements ExpressionCompiler {
8
9
 
9
- @Autowired(JexlEngineProvider)
10
- protected readonly jexlEngineProvider: JexlEngineProvider<any>;
10
+ @Autowired(ExpressionEngine)
11
+ protected readonly engine: ExpressionEngine;
11
12
 
12
- protected readonly sectionCompiler = new ExpressionSectionCompiler(() => this.jexlEngineProvider.provide());
13
+ protected readonly sectionCompiler = new ExpressionSectionCompiler(() => this.engine);
13
14
 
14
- compileSections(text: string, options: ExpressionCompilerOptions = {}): any[] {
15
+ compileSections(text: string, options: ExpressionCompilerOptions = {}): (string | Expression)[] {
15
16
  return this.sectionCompiler.compileSections(text, options);
16
17
  }
17
18
 
@@ -0,0 +1,107 @@
1
+ import { describe, it } from 'bun:test';
2
+ import { expect } from 'chai';
3
+ import { ExpressionEngine, ExpressionSyntaxError } from './expression-engine';
4
+
5
+ function errorOf(fn: () => unknown): ExpressionSyntaxError {
6
+ try {
7
+ fn();
8
+ } catch (error) {
9
+ expect(error).to.be.instanceOf(ExpressionSyntaxError);
10
+ return error as ExpressionSyntaxError;
11
+ }
12
+ throw new Error('expected an ExpressionSyntaxError');
13
+ }
14
+
15
+ describe('ExpressionEngine', () => {
16
+ const engine = new ExpressionEngine();
17
+ const evaluate = (source: string, context: object = {}) => engine.evaluate(source, context);
18
+ const context = {
19
+ env: { PORT: '8080', EMPTY: '' },
20
+ cell: { server: { port: 3000 } },
21
+ user: { name: 'tom', roles: ['admin', 'dev'] },
22
+ users: [{ name: 'a', age: 10 }, { name: 'b', age: 20 }, { name: 'c', age: 30 }],
23
+ n: 5
24
+ };
25
+
26
+ it('reads names; a missing one is undefined, never an error', () => {
27
+ expect(evaluate('cell.server.port', context)).to.equal(3000);
28
+ expect(evaluate('cell.missing.deep', context)).to.equal(undefined);
29
+ expect(evaluate('missing', context)).to.equal(undefined);
30
+ expect(evaluate("user['name']", context)).to.equal('tom');
31
+ expect(evaluate('users[1].name', context)).to.equal('b');
32
+ // A property of an array is the one of its first element.
33
+ expect(evaluate('users.name', context)).to.equal('a');
34
+ });
35
+
36
+ it('literals: strings keep backslashes that are not escapes', () => {
37
+ expect(evaluate("'it\\'s'")).to.equal("it's");
38
+ expect(evaluate("'\\d+'")).to.equal('\\d+');
39
+ expect(evaluate("'a\\\\b'")).to.equal('a\\b');
40
+ expect(evaluate('[1, -2.5, true, "x"]')).to.deep.equal([1, -2.5, true, 'x']);
41
+ expect(evaluate("{ a: 1, 'b-c': [2] }")).to.deep.equal({ a: 1, 'b-c': [2] });
42
+ expect(evaluate('')).to.equal(undefined);
43
+ });
44
+
45
+ it('operators and their precedence are the ones of jexl', () => {
46
+ expect(evaluate('1 + 2 * 3')).to.equal(7);
47
+ expect(evaluate('2 ^ 3 ^ 2')).to.equal(64);
48
+ expect(evaluate('-7 // 2')).to.equal(-4);
49
+ expect(evaluate('2 * 7 % 3')).to.equal(2);
50
+ // || and && have the same precedence: left to right.
51
+ expect(evaluate('true || false && false')).to.equal(false);
52
+ expect(evaluate("'5' == 5")).to.equal(true);
53
+ expect(evaluate("'om' in user.name && 'admin' in user.roles && !('x' in user.roles)", context)).to.equal(true);
54
+ expect(evaluate('-n + 1', context)).to.equal(-4);
55
+ });
56
+
57
+ it('a ? b : c, and a ?: b for defaults', () => {
58
+ expect(evaluate("env.MISSING ?: 'nobody'", context)).to.equal('nobody');
59
+ expect(evaluate("env.EMPTY ?: 'fallback'", context)).to.equal('fallback');
60
+ expect(evaluate('(env.PORT ?: 3306) * 1', context)).to.equal(8080);
61
+ expect(evaluate("n > 9 ? 'big' : n > 3 ? 'mid' : 'small'", context)).to.equal('mid');
62
+ expect(evaluate('true ? false ? 1 : 2 : 3')).to.equal(2);
63
+ });
64
+
65
+ it('filters keep the elements that .name expressions are true for', () => {
66
+ expect(evaluate('users[.age > 15].name', context)).to.equal('b');
67
+ expect(evaluate('users[.age > n * 3]', context)).to.deep.equal([{ name: 'b', age: 20 }, { name: 'c', age: 30 }]);
68
+ expect(evaluate('users[.age > 100].name', context)).to.equal(undefined);
69
+ expect(evaluate('users[true]', context)).to.equal(context.users);
70
+ expect(evaluate('users[false]', context)).to.equal(undefined);
71
+ });
72
+
73
+ it('transforms and functions that are added to the engine', () => {
74
+ const own = new ExpressionEngine()
75
+ .addTransforms({ upper: (v: string) => v.toUpperCase(), split: (v: string, c: string) => v.split(c) })
76
+ .addFunction('max', Math.max);
77
+ expect(own.evaluate("'a,b'|split(',')[1]|upper")).to.equal('B');
78
+ expect(own.evaluate("1 + 'x'|upper")).to.equal('1X');
79
+ expect(own.evaluate('max(n, 10) * 2', context)).to.equal(20);
80
+ const error = errorOf(() => own.evaluate("'a'|lower"));
81
+ expect(error.code).to.equal('CELL_EL_UNKNOWN_TRANSFORM');
82
+ expect(error.message).to.equal("The transform lower is not defined (in: 'a'|lower).");
83
+ expect(errorOf(() => own.evaluate('min(1)')).code).to.equal('CELL_EL_UNKNOWN_FUNCTION');
84
+ });
85
+
86
+ it('cannot call methods of the values it reads', () => {
87
+ expect(errorOf(() => evaluate("user.name.toUpperCase()", context)).code).to.equal('CELL_EL_SYNTAX');
88
+ expect(evaluate('user.constructor.name', context)).to.equal('Object');
89
+ });
90
+
91
+ it('syntax errors say what and where', () => {
92
+ const error = errorOf(() => evaluate('a + )'));
93
+ expect(error.code).to.equal('CELL_EL_SYNTAX');
94
+ expect(error.message).to.equal("Unexpected ')' at position 4 of: a + )");
95
+ expect(error.position).to.equal(4);
96
+ expect(errorOf(() => evaluate('(1')).message).to.equal("Unexpected end of expression, expected ')' at position 2 of: (1");
97
+ expect(errorOf(() => evaluate("'open")).message).to.equal("Unterminated string at position 0 of: 'open");
98
+ expect(errorOf(() => evaluate('1 = 1')).message).to.equal("Unexpected character '=' at position 2 of: 1 = 1");
99
+ expect(errorOf(() => evaluate('a b')).message).to.equal("Unexpected 'b' at position 2 of: a b");
100
+ });
101
+
102
+ it('compiles a source text once', () => {
103
+ const own = new ExpressionEngine();
104
+ expect(own.compile('n + 1')).to.equal(own.compile('n + 1'));
105
+ expect(own.compile('n + 1').evaluate({ n: 1 })).to.equal(2);
106
+ });
107
+ });