@celljs/core 4.1.0 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (410) hide show
  1. package/README.md +49 -62
  2. package/esm/browser/static-module.d.ts +1 -1
  3. package/esm/common/annotation/aspect.d.ts +2 -1
  4. package/esm/common/annotation/aspect.js.map +1 -1
  5. package/esm/common/annotation/autowired-provider.d.ts +0 -2
  6. package/esm/common/annotation/autowired-provider.js +4 -13
  7. package/esm/common/annotation/autowired-provider.js.map +1 -1
  8. package/esm/common/annotation/autowired.d.ts +1 -1
  9. package/esm/common/annotation/autowired.js +11 -3
  10. package/esm/common/annotation/autowired.js.map +1 -1
  11. package/esm/common/annotation/component.d.ts +4 -8
  12. package/esm/common/annotation/component.js +0 -6
  13. package/esm/common/annotation/component.js.map +1 -1
  14. package/esm/common/annotation/constant.d.ts +1 -1
  15. package/esm/common/annotation/constant.js +6 -3
  16. package/esm/common/annotation/constant.js.map +1 -1
  17. package/esm/common/annotation/detached/autowired-provider.js +2 -2
  18. package/esm/common/annotation/detached/autowired-provider.js.map +1 -1
  19. package/esm/common/annotation/index.d.ts +0 -6
  20. package/esm/common/annotation/index.js +0 -6
  21. package/esm/common/annotation/index.js.map +1 -1
  22. package/esm/common/annotation/named.d.ts +2 -1
  23. package/esm/common/annotation/named.js +5 -1
  24. package/esm/common/annotation/named.js.map +1 -1
  25. package/esm/common/annotation/optional.d.ts +2 -1
  26. package/esm/common/annotation/optional.js +5 -1
  27. package/esm/common/annotation/optional.js.map +1 -1
  28. package/esm/common/annotation/post-construct.d.ts +2 -1
  29. package/esm/common/annotation/post-construct.js +5 -1
  30. package/esm/common/annotation/post-construct.js.map +1 -1
  31. package/esm/common/annotation/tagged.d.ts +2 -1
  32. package/esm/common/annotation/tagged.js +6 -1
  33. package/esm/common/annotation/tagged.js.map +1 -1
  34. package/esm/common/annotation/value.d.ts +3 -2
  35. package/esm/common/annotation/value.js +7 -10
  36. package/esm/common/annotation/value.js.map +1 -1
  37. package/esm/common/aop/aop-proxy-factory.d.ts +6 -2
  38. package/esm/common/aop/aop-proxy-factory.js +44 -28
  39. package/esm/common/aop/aop-proxy-factory.js.map +1 -1
  40. package/esm/common/aop/class-filter.js +6 -6
  41. package/esm/common/aop/class-filter.js.map +1 -1
  42. package/esm/common/application/application-factory.d.ts +1 -1
  43. package/esm/common/application/application-factory.js +4 -4
  44. package/esm/common/application/application-factory.js.map +1 -1
  45. package/esm/common/container/auto-bind.d.ts +7 -3
  46. package/esm/common/container/auto-bind.js +49 -80
  47. package/esm/common/container/auto-bind.js.map +1 -1
  48. package/esm/common/container/container-error.d.ts +21 -0
  49. package/esm/common/container/container-error.js +22 -0
  50. package/esm/common/container/container-error.js.map +1 -0
  51. package/esm/common/container/container-provider.d.ts +5 -4
  52. package/esm/common/container/container-provider.js +2 -1
  53. package/esm/common/container/container-provider.js.map +1 -1
  54. package/esm/common/container/container-util.d.ts +5 -7
  55. package/esm/common/container/container-util.js +8 -19
  56. package/esm/common/container/container-util.js.map +1 -1
  57. package/esm/common/container/container.d.ts +104 -0
  58. package/esm/common/container/container.js +299 -0
  59. package/esm/common/container/container.js.map +1 -0
  60. package/esm/common/container/dynamic-container.d.ts +1 -1
  61. package/esm/common/container/dynamic-container.js +2 -2
  62. package/esm/common/container/dynamic-container.js.map +1 -1
  63. package/esm/common/container/index.d.ts +5 -6
  64. package/esm/common/container/index.js +5 -3
  65. package/esm/common/container/index.js.map +1 -1
  66. package/esm/common/container/injection.d.ts +40 -0
  67. package/esm/common/container/injection.js +109 -0
  68. package/esm/common/container/injection.js.map +1 -0
  69. package/esm/common/container/scope.d.ts +2 -3
  70. package/esm/common/container/scope.js +2 -3
  71. package/esm/common/container/scope.js.map +1 -1
  72. package/esm/common/el/application-expression-engine.d.ts +7 -0
  73. package/esm/common/{provider/provider-creator.js → el/application-expression-engine.js} +11 -11
  74. package/esm/common/el/application-expression-engine.js.map +1 -0
  75. package/esm/common/el/core-context-initializer.d.ts +3 -2
  76. package/esm/common/el/core-context-initializer.js +10 -8
  77. package/esm/common/el/core-context-initializer.js.map +1 -1
  78. package/esm/common/el/expression-compiler.d.ts +5 -4
  79. package/esm/common/el/expression-compiler.js +7 -6
  80. package/esm/common/el/expression-compiler.js.map +1 -1
  81. package/esm/common/el/expression-engine.d.ts +61 -0
  82. package/esm/common/el/expression-engine.js +459 -0
  83. package/esm/common/el/expression-engine.js.map +1 -0
  84. package/esm/common/el/expression-handler.d.ts +1 -2
  85. package/esm/common/el/expression-handler.js +1 -5
  86. package/esm/common/el/expression-handler.js.map +1 -1
  87. package/esm/common/el/expression-protocol.d.ts +3 -5
  88. package/esm/common/el/expression-protocol.js +0 -1
  89. package/esm/common/el/expression-protocol.js.map +1 -1
  90. package/esm/common/el/expression-util.d.ts +9 -8
  91. package/esm/common/el/expression-util.js +8 -9
  92. package/esm/common/el/expression-util.js.map +1 -1
  93. package/esm/common/el/index.d.ts +2 -1
  94. package/esm/common/el/index.js +2 -1
  95. package/esm/common/el/index.js.map +1 -1
  96. package/esm/common/provider/index.d.ts +0 -1
  97. package/esm/common/provider/index.js +0 -1
  98. package/esm/common/provider/index.js.map +1 -1
  99. package/esm/common/provider/provider-protocol.d.ts +5 -9
  100. package/esm/common/provider/provider-protocol.js +0 -1
  101. package/esm/common/provider/provider-protocol.js.map +1 -1
  102. package/esm/common/provider/provider-util.d.ts +1 -1
  103. package/esm/common/provider/provider-util.js +2 -2
  104. package/esm/common/provider/provider-util.js.map +1 -1
  105. package/esm/common/provider/provider.d.ts +7 -6
  106. package/esm/common/provider/provider.js +15 -26
  107. package/esm/common/provider/provider.js.map +1 -1
  108. package/esm/common/static-module.d.ts +1 -1
  109. package/esm/common/static-module.js +1 -1
  110. package/esm/common/static-module.js.map +1 -1
  111. package/esm/common/test/mock-logger.js +2 -13
  112. package/esm/common/test/mock-logger.js.map +1 -1
  113. package/esm/common/test/test-module.d.ts +1 -1
  114. package/esm/common/test/test-module.js +1 -1
  115. package/esm/common/test/test-module.js.map +1 -1
  116. package/esm/common/utils/annotation-util.js +2 -1
  117. package/esm/common/utils/annotation-util.js.map +1 -1
  118. package/esm/common/utils/proxy-util.d.ts +5 -2
  119. package/esm/common/utils/proxy-util.js +10 -28
  120. package/esm/common/utils/proxy-util.js.map +1 -1
  121. package/esm/node/static-module.d.ts +1 -1
  122. package/lib/browser/static-module.d.ts +1 -1
  123. package/lib/common/annotation/aspect.d.ts +2 -1
  124. package/lib/common/annotation/aspect.d.ts.map +1 -1
  125. package/lib/common/annotation/aspect.js.map +1 -1
  126. package/lib/common/annotation/autowired-provider.d.ts +0 -2
  127. package/lib/common/annotation/autowired-provider.d.ts.map +1 -1
  128. package/lib/common/annotation/autowired-provider.js +4 -14
  129. package/lib/common/annotation/autowired-provider.js.map +1 -1
  130. package/lib/common/annotation/autowired.d.ts +1 -1
  131. package/lib/common/annotation/autowired.d.ts.map +1 -1
  132. package/lib/common/annotation/autowired.js +11 -3
  133. package/lib/common/annotation/autowired.js.map +1 -1
  134. package/lib/common/annotation/component.d.ts +4 -8
  135. package/lib/common/annotation/component.d.ts.map +1 -1
  136. package/lib/common/annotation/component.js +0 -6
  137. package/lib/common/annotation/component.js.map +1 -1
  138. package/lib/common/annotation/constant.d.ts +1 -1
  139. package/lib/common/annotation/constant.d.ts.map +1 -1
  140. package/lib/common/annotation/constant.js +6 -3
  141. package/lib/common/annotation/constant.js.map +1 -1
  142. package/lib/common/annotation/detached/autowired-provider.js +2 -2
  143. package/lib/common/annotation/detached/autowired-provider.js.map +1 -1
  144. package/lib/common/annotation/index.d.ts +0 -6
  145. package/lib/common/annotation/index.d.ts.map +1 -1
  146. package/lib/common/annotation/index.js +0 -6
  147. package/lib/common/annotation/index.js.map +1 -1
  148. package/lib/common/annotation/named.d.ts +2 -1
  149. package/lib/common/annotation/named.d.ts.map +1 -1
  150. package/lib/common/annotation/named.js +6 -2
  151. package/lib/common/annotation/named.js.map +1 -1
  152. package/lib/common/annotation/optional.d.ts +2 -1
  153. package/lib/common/annotation/optional.d.ts.map +1 -1
  154. package/lib/common/annotation/optional.js +6 -2
  155. package/lib/common/annotation/optional.js.map +1 -1
  156. package/lib/common/annotation/post-construct.d.ts +2 -1
  157. package/lib/common/annotation/post-construct.d.ts.map +1 -1
  158. package/lib/common/annotation/post-construct.js +6 -2
  159. package/lib/common/annotation/post-construct.js.map +1 -1
  160. package/lib/common/annotation/tagged.d.ts +2 -1
  161. package/lib/common/annotation/tagged.d.ts.map +1 -1
  162. package/lib/common/annotation/tagged.js +7 -2
  163. package/lib/common/annotation/tagged.js.map +1 -1
  164. package/lib/common/annotation/value.d.ts +3 -2
  165. package/lib/common/annotation/value.d.ts.map +1 -1
  166. package/lib/common/annotation/value.js +7 -10
  167. package/lib/common/annotation/value.js.map +1 -1
  168. package/lib/common/aop/aop-proxy-factory.d.ts +6 -2
  169. package/lib/common/aop/aop-proxy-factory.d.ts.map +1 -1
  170. package/lib/common/aop/aop-proxy-factory.js +45 -29
  171. package/lib/common/aop/aop-proxy-factory.js.map +1 -1
  172. package/lib/common/aop/class-filter.js +7 -7
  173. package/lib/common/aop/class-filter.js.map +1 -1
  174. package/lib/common/application/application-factory.d.ts +1 -1
  175. package/lib/common/application/application-factory.d.ts.map +1 -1
  176. package/lib/common/application/application-factory.js +4 -4
  177. package/lib/common/application/application-factory.js.map +1 -1
  178. package/lib/common/container/assembly.spec.js +11 -11
  179. package/lib/common/container/assembly.spec.js.map +1 -1
  180. package/lib/common/container/auto-bind.d.ts +7 -3
  181. package/lib/common/container/auto-bind.d.ts.map +1 -1
  182. package/lib/common/container/auto-bind.js +49 -81
  183. package/lib/common/container/auto-bind.js.map +1 -1
  184. package/lib/common/container/container-error.d.ts +22 -0
  185. package/lib/common/container/container-error.d.ts.map +1 -0
  186. package/lib/common/container/container-error.js +26 -0
  187. package/lib/common/container/container-error.js.map +1 -0
  188. package/lib/common/container/container-provider.d.ts +5 -4
  189. package/lib/common/container/container-provider.d.ts.map +1 -1
  190. package/lib/common/container/container-provider.js +3 -2
  191. package/lib/common/container/container-provider.js.map +1 -1
  192. package/lib/common/container/container-util.d.ts +5 -7
  193. package/lib/common/container/container-util.d.ts.map +1 -1
  194. package/lib/common/container/container-util.js +8 -19
  195. package/lib/common/container/container-util.js.map +1 -1
  196. package/lib/common/container/container.d.ts +105 -0
  197. package/lib/common/container/container.d.ts.map +1 -0
  198. package/lib/common/container/container.js +305 -0
  199. package/lib/common/container/container.js.map +1 -0
  200. package/lib/common/container/container.spec.d.ts +2 -0
  201. package/lib/common/container/container.spec.d.ts.map +1 -0
  202. package/lib/common/container/container.spec.js +334 -0
  203. package/lib/common/container/container.spec.js.map +1 -0
  204. package/lib/common/container/dynamic-container.d.ts +1 -1
  205. package/lib/common/container/dynamic-container.d.ts.map +1 -1
  206. package/lib/common/container/dynamic-container.js +3 -3
  207. package/lib/common/container/dynamic-container.js.map +1 -1
  208. package/lib/common/container/index.d.ts +5 -6
  209. package/lib/common/container/index.d.ts.map +1 -1
  210. package/lib/common/container/index.js +5 -3
  211. package/lib/common/container/index.js.map +1 -1
  212. package/lib/common/container/injection.d.ts +41 -0
  213. package/lib/common/container/injection.d.ts.map +1 -0
  214. package/lib/common/container/injection.js +112 -0
  215. package/lib/common/container/injection.js.map +1 -0
  216. package/lib/common/container/scope.d.ts +2 -3
  217. package/lib/common/container/scope.d.ts.map +1 -1
  218. package/lib/common/container/scope.js +2 -3
  219. package/lib/common/container/scope.js.map +1 -1
  220. package/lib/common/el/application-expression-engine.d.ts +8 -0
  221. package/lib/common/el/application-expression-engine.d.ts.map +1 -0
  222. package/lib/common/el/application-expression-engine.js +22 -0
  223. package/lib/common/el/application-expression-engine.js.map +1 -0
  224. package/lib/common/el/core-context-initializer.d.ts +3 -2
  225. package/lib/common/el/core-context-initializer.d.ts.map +1 -1
  226. package/lib/common/el/core-context-initializer.js +9 -7
  227. package/lib/common/el/core-context-initializer.js.map +1 -1
  228. package/lib/common/el/expression-compiler.d.ts +5 -4
  229. package/lib/common/el/expression-compiler.d.ts.map +1 -1
  230. package/lib/common/el/expression-compiler.js +6 -5
  231. package/lib/common/el/expression-compiler.js.map +1 -1
  232. package/lib/common/el/expression-engine.d.ts +62 -0
  233. package/lib/common/el/expression-engine.d.ts.map +1 -0
  234. package/lib/common/el/expression-engine.js +465 -0
  235. package/lib/common/el/expression-engine.js.map +1 -0
  236. package/lib/common/el/expression-engine.spec.d.ts +2 -0
  237. package/lib/common/el/expression-engine.spec.d.ts.map +1 -0
  238. package/lib/common/el/expression-engine.spec.js +100 -0
  239. package/lib/common/el/expression-engine.spec.js.map +1 -0
  240. package/lib/common/el/expression-handler.d.ts +1 -2
  241. package/lib/common/el/expression-handler.d.ts.map +1 -1
  242. package/lib/common/el/expression-handler.js +0 -4
  243. package/lib/common/el/expression-handler.js.map +1 -1
  244. package/lib/common/el/expression-handler.spec.js +5 -6
  245. package/lib/common/el/expression-handler.spec.js.map +1 -1
  246. package/lib/common/el/expression-protocol.d.ts +3 -5
  247. package/lib/common/el/expression-protocol.d.ts.map +1 -1
  248. package/lib/common/el/expression-protocol.js +1 -2
  249. package/lib/common/el/expression-protocol.js.map +1 -1
  250. package/lib/common/el/expression-util.d.ts +9 -8
  251. package/lib/common/el/expression-util.d.ts.map +1 -1
  252. package/lib/common/el/expression-util.js +8 -9
  253. package/lib/common/el/expression-util.js.map +1 -1
  254. package/lib/common/el/index.d.ts +2 -1
  255. package/lib/common/el/index.d.ts.map +1 -1
  256. package/lib/common/el/index.js +2 -1
  257. package/lib/common/el/index.js.map +1 -1
  258. package/lib/common/el/value-and-el.spec.js +2 -2
  259. package/lib/common/el/value-and-el.spec.js.map +1 -1
  260. package/lib/common/provider/index.d.ts +0 -1
  261. package/lib/common/provider/index.d.ts.map +1 -1
  262. package/lib/common/provider/index.js +0 -1
  263. package/lib/common/provider/index.js.map +1 -1
  264. package/lib/common/provider/provider-protocol.d.ts +5 -9
  265. package/lib/common/provider/provider-protocol.d.ts.map +1 -1
  266. package/lib/common/provider/provider-protocol.js +1 -2
  267. package/lib/common/provider/provider-protocol.js.map +1 -1
  268. package/lib/common/provider/provider-util.d.ts +1 -1
  269. package/lib/common/provider/provider-util.d.ts.map +1 -1
  270. package/lib/common/provider/provider-util.js +2 -2
  271. package/lib/common/provider/provider-util.js.map +1 -1
  272. package/lib/common/provider/provider.d.ts +7 -6
  273. package/lib/common/provider/provider.d.ts.map +1 -1
  274. package/lib/common/provider/provider.js +16 -26
  275. package/lib/common/provider/provider.js.map +1 -1
  276. package/lib/common/static-module.d.ts +1 -1
  277. package/lib/common/static-module.js +2 -2
  278. package/lib/common/static-module.js.map +1 -1
  279. package/lib/common/test/mock-logger.d.ts.map +1 -1
  280. package/lib/common/test/mock-logger.js +2 -12
  281. package/lib/common/test/mock-logger.js.map +1 -1
  282. package/lib/common/test/test-module.d.ts +1 -1
  283. package/lib/common/test/test-module.d.ts.map +1 -1
  284. package/lib/common/test/test-module.js +2 -2
  285. package/lib/common/test/test-module.js.map +1 -1
  286. package/lib/common/utils/annotation-util.js +2 -1
  287. package/lib/common/utils/annotation-util.js.map +1 -1
  288. package/lib/common/utils/proxy-util.d.ts +5 -2
  289. package/lib/common/utils/proxy-util.d.ts.map +1 -1
  290. package/lib/common/utils/proxy-util.js +12 -30
  291. package/lib/common/utils/proxy-util.js.map +1 -1
  292. package/lib/node/static-module.d.ts +1 -1
  293. package/package.json +4 -6
  294. package/src/common/annotation/aspect.ts +2 -1
  295. package/src/common/annotation/autowired-provider.ts +4 -17
  296. package/src/common/annotation/autowired.ts +14 -6
  297. package/src/common/annotation/component.ts +6 -26
  298. package/src/common/annotation/constant.ts +10 -7
  299. package/src/common/annotation/detached/autowired-provider.ts +2 -2
  300. package/src/common/annotation/index.ts +0 -6
  301. package/src/common/annotation/named.ts +7 -1
  302. package/src/common/annotation/optional.ts +6 -1
  303. package/src/common/annotation/post-construct.ts +6 -1
  304. package/src/common/annotation/tagged.ts +8 -1
  305. package/src/common/annotation/value.ts +9 -11
  306. package/src/common/aop/aop-proxy-factory.ts +52 -30
  307. package/src/common/aop/class-filter.ts +6 -6
  308. package/src/common/application/application-factory.ts +4 -5
  309. package/src/common/container/assembly.spec.ts +7 -12
  310. package/src/common/container/auto-bind.ts +54 -85
  311. package/src/common/container/container-error.ts +31 -0
  312. package/src/common/container/container-provider.ts +9 -7
  313. package/src/common/container/container-util.ts +8 -19
  314. package/src/common/container/container.spec.ts +262 -0
  315. package/src/common/container/container.ts +363 -0
  316. package/src/common/container/dynamic-container.ts +2 -2
  317. package/src/common/container/index.ts +5 -7
  318. package/src/common/container/injection.ts +135 -0
  319. package/src/common/container/scope.ts +2 -1
  320. package/src/common/el/application-expression-engine.ts +9 -0
  321. package/src/common/el/core-context-initializer.ts +9 -8
  322. package/src/common/el/expression-compiler.ts +7 -6
  323. package/src/common/el/expression-engine.spec.ts +107 -0
  324. package/src/common/el/expression-engine.ts +487 -0
  325. package/src/common/el/expression-handler.spec.ts +6 -7
  326. package/src/common/el/expression-handler.ts +2 -5
  327. package/src/common/el/expression-protocol.ts +4 -8
  328. package/src/common/el/expression-util.ts +12 -13
  329. package/src/common/el/index.ts +3 -2
  330. package/src/common/el/value-and-el.spec.ts +2 -2
  331. package/src/common/provider/index.ts +0 -2
  332. package/src/common/provider/provider-protocol.ts +5 -11
  333. package/src/common/provider/provider-util.ts +3 -3
  334. package/src/common/provider/provider.ts +17 -29
  335. package/src/common/static-module.ts +1 -1
  336. package/src/common/test/mock-logger.ts +0 -2
  337. package/src/common/test/test-module.ts +1 -1
  338. package/src/common/utils/annotation-util.ts +2 -2
  339. package/src/common/utils/proxy-util.ts +8 -28
  340. package/esm/common/annotation/decorate.d.ts +0 -1
  341. package/esm/common/annotation/decorate.js +0 -2
  342. package/esm/common/annotation/decorate.js.map +0 -1
  343. package/esm/common/annotation/inject.d.ts +0 -1
  344. package/esm/common/annotation/inject.js +0 -2
  345. package/esm/common/annotation/inject.js.map +0 -1
  346. package/esm/common/annotation/injectable.d.ts +0 -1
  347. package/esm/common/annotation/injectable.js +0 -2
  348. package/esm/common/annotation/injectable.js.map +0 -1
  349. package/esm/common/annotation/pre-destroy.d.ts +0 -1
  350. package/esm/common/annotation/pre-destroy.js +0 -2
  351. package/esm/common/annotation/pre-destroy.js.map +0 -1
  352. package/esm/common/annotation/target-name.d.ts +0 -1
  353. package/esm/common/annotation/target-name.js +0 -2
  354. package/esm/common/annotation/target-name.js.map +0 -1
  355. package/esm/common/annotation/unmanaged.d.ts +0 -1
  356. package/esm/common/annotation/unmanaged.js +0 -2
  357. package/esm/common/annotation/unmanaged.js.map +0 -1
  358. package/esm/common/container/container-factory.d.ts +0 -4
  359. package/esm/common/container/container-factory.js +0 -9
  360. package/esm/common/container/container-factory.js.map +0 -1
  361. package/esm/common/el/jexl-engine-provider.d.ts +0 -5
  362. package/esm/common/el/jexl-engine-provider.js +0 -22
  363. package/esm/common/el/jexl-engine-provider.js.map +0 -1
  364. package/esm/common/provider/provider-creator.d.ts +0 -6
  365. package/esm/common/provider/provider-creator.js.map +0 -1
  366. package/lib/common/annotation/decorate.d.ts +0 -2
  367. package/lib/common/annotation/decorate.d.ts.map +0 -1
  368. package/lib/common/annotation/decorate.js +0 -6
  369. package/lib/common/annotation/decorate.js.map +0 -1
  370. package/lib/common/annotation/inject.d.ts +0 -2
  371. package/lib/common/annotation/inject.d.ts.map +0 -1
  372. package/lib/common/annotation/inject.js +0 -6
  373. package/lib/common/annotation/inject.js.map +0 -1
  374. package/lib/common/annotation/injectable.d.ts +0 -2
  375. package/lib/common/annotation/injectable.d.ts.map +0 -1
  376. package/lib/common/annotation/injectable.js +0 -6
  377. package/lib/common/annotation/injectable.js.map +0 -1
  378. package/lib/common/annotation/pre-destroy.d.ts +0 -2
  379. package/lib/common/annotation/pre-destroy.d.ts.map +0 -1
  380. package/lib/common/annotation/pre-destroy.js +0 -6
  381. package/lib/common/annotation/pre-destroy.js.map +0 -1
  382. package/lib/common/annotation/target-name.d.ts +0 -2
  383. package/lib/common/annotation/target-name.d.ts.map +0 -1
  384. package/lib/common/annotation/target-name.js +0 -6
  385. package/lib/common/annotation/target-name.js.map +0 -1
  386. package/lib/common/annotation/unmanaged.d.ts +0 -2
  387. package/lib/common/annotation/unmanaged.d.ts.map +0 -1
  388. package/lib/common/annotation/unmanaged.js +0 -6
  389. package/lib/common/annotation/unmanaged.js.map +0 -1
  390. package/lib/common/container/container-factory.d.ts +0 -5
  391. package/lib/common/container/container-factory.d.ts.map +0 -1
  392. package/lib/common/container/container-factory.js +0 -13
  393. package/lib/common/container/container-factory.js.map +0 -1
  394. package/lib/common/el/jexl-engine-provider.d.ts +0 -6
  395. package/lib/common/el/jexl-engine-provider.d.ts.map +0 -1
  396. package/lib/common/el/jexl-engine-provider.js +0 -25
  397. package/lib/common/el/jexl-engine-provider.js.map +0 -1
  398. package/lib/common/provider/provider-creator.d.ts +0 -7
  399. package/lib/common/provider/provider-creator.d.ts.map +0 -1
  400. package/lib/common/provider/provider-creator.js +0 -22
  401. package/lib/common/provider/provider-creator.js.map +0 -1
  402. package/src/common/annotation/decorate.ts +0 -1
  403. package/src/common/annotation/inject.ts +0 -1
  404. package/src/common/annotation/injectable.ts +0 -1
  405. package/src/common/annotation/pre-destroy.ts +0 -1
  406. package/src/common/annotation/target-name.ts +0 -1
  407. package/src/common/annotation/unmanaged.ts +0 -1
  408. package/src/common/container/container-factory.ts +0 -9
  409. package/src/common/el/jexl-engine-provider.ts +0 -18
  410. package/src/common/provider/provider-creator.ts +0 -12
@@ -0,0 +1,487 @@
1
+ /**
2
+ * The expression language of Cell: what `${...}` in the configuration, `@Value` and the security
3
+ * policies evaluate. Its grammar is the one of jexl 2, which Cell used before:
4
+ *
5
+ * - literals: `'text'`, `"text"`, `42`, `1.5`, `true`, `false`, `[a, b]`, `{ key: value }`;
6
+ * - names: `cell.server.port`, `list[0]`, `map['key']`, filters `users[.age > 18]` (`.age` is a
7
+ * property of each element); a missing property is `undefined`, never an error; a property of an
8
+ * array is the property of its first element;
9
+ * - operators, loosest first: `a ? b : c` and `a ?: b` (`b` when `a` is falsy), `||` and `&&` (same
10
+ * precedence, left to right), `== != > >= < <= in`, `+ -`, `* / //` (`//` rounds down), `% ^`
11
+ * (`^` is power), then `!` and `-` in front;
12
+ * - transforms `value|name(args)` and functions `name(args)`: only the ones added to the engine.
13
+ *
14
+ * Evaluation is synchronous. Expressions cannot call methods, so they only read what the context gives.
15
+ */
16
+
17
+ /** The code of an {@link ExpressionSyntaxError}. */
18
+ export type ExpressionErrorCode = 'CELL_EL_SYNTAX' | 'CELL_EL_UNKNOWN_TRANSFORM' | 'CELL_EL_UNKNOWN_FUNCTION';
19
+
20
+ /** An expression that cannot be parsed, or that uses a transform or function the engine does not have. */
21
+ export class ExpressionSyntaxError extends Error {
22
+ override readonly name = 'ExpressionSyntaxError';
23
+ readonly code: ExpressionErrorCode;
24
+ readonly hint: string;
25
+ readonly expression: string;
26
+ /** Where in `expression` parsing failed. */
27
+ readonly position?: number;
28
+
29
+ constructor(options: { code: ExpressionErrorCode, message: string, hint: string, expression: string, position?: number }) {
30
+ super(options.message);
31
+ this.code = options.code;
32
+ this.hint = options.hint;
33
+ this.expression = options.expression;
34
+ this.position = options.position;
35
+ }
36
+ }
37
+
38
+ type Evaluate = (context: any, element: any) => any;
39
+
40
+ /** A compiled expression; evaluate it as many times as needed. */
41
+ export class Expression {
42
+ constructor(readonly source: string, protected readonly run: Evaluate) { }
43
+
44
+ /** The value of the expression; names are properties of `context`. */
45
+ evaluate(context: object = {}): any {
46
+ return this.run(context, context);
47
+ }
48
+ }
49
+
50
+ /** Compiles and evaluates expressions; holds the transforms and functions they may call. */
51
+ export class ExpressionEngine {
52
+ protected static readonly CACHE_SIZE = 1000;
53
+
54
+ protected readonly transforms = new Map<string, Function>();
55
+ protected readonly functions = new Map<string, Function>();
56
+ protected readonly cache = new Map<string, Expression>();
57
+
58
+ /** `value|name(a, b)` calls `transform(value, a, b)`. */
59
+ addTransform(name: string, transform: (value: any, ...args: any[]) => any): this {
60
+ this.transforms.set(name, transform);
61
+ return this;
62
+ }
63
+
64
+ addTransforms(transforms: Record<string, (value: any, ...args: any[]) => any>): this {
65
+ for (const [name, transform] of Object.entries(transforms)) {
66
+ this.addTransform(name, transform);
67
+ }
68
+ return this;
69
+ }
70
+
71
+ /** `name(a, b)` calls `fn(a, b)`. */
72
+ addFunction(name: string, fn: (...args: any[]) => any): this {
73
+ this.functions.set(name, fn);
74
+ return this;
75
+ }
76
+
77
+ addFunctions(functions: Record<string, (...args: any[]) => any>): this {
78
+ for (const [name, fn] of Object.entries(functions)) {
79
+ this.addFunction(name, fn);
80
+ }
81
+ return this;
82
+ }
83
+
84
+ /** Compiles once per source text (the latest ones are kept). Throws an {@link ExpressionSyntaxError}. */
85
+ compile(source: string): Expression {
86
+ let expression = this.cache.get(source);
87
+ if (!expression) {
88
+ expression = new Expression(source, new ExpressionParser(source, this).parse());
89
+ if (this.cache.size >= ExpressionEngine.CACHE_SIZE) {
90
+ this.cache.clear();
91
+ }
92
+ this.cache.set(source, expression);
93
+ }
94
+ return expression;
95
+ }
96
+
97
+ evaluate(source: string, context: object = {}): any {
98
+ return this.compile(source).evaluate(context);
99
+ }
100
+
101
+ /** @internal what the compiled expressions call */
102
+ call(pool: 'transform' | 'function', name: string, args: any[], source: string): any {
103
+ const fn = (pool === 'transform' ? this.transforms : this.functions).get(name);
104
+ if (!fn) {
105
+ throw new ExpressionSyntaxError({
106
+ code: pool === 'transform' ? 'CELL_EL_UNKNOWN_TRANSFORM' : 'CELL_EL_UNKNOWN_FUNCTION',
107
+ message: `The ${pool} ${name} is not defined (in: ${source}).`,
108
+ hint: `Add it with addT${pool.slice(1)}('${name}', ...) on the ExpressionEngine of the application, or check its spelling.`,
109
+ expression: source
110
+ });
111
+ }
112
+ return fn(...args);
113
+ }
114
+ }
115
+
116
+ interface Token {
117
+ type: 'number' | 'string' | 'boolean' | 'identifier' | 'operator' | 'punctuation' | 'end';
118
+ value: any;
119
+ start: number;
120
+ }
121
+
122
+ /** Longest first, so that `//` is not `/`. */
123
+ const OPERATORS = ['//', '==', '!=', '>=', '<=', '&&', '||', '+', '-', '*', '/', '%', '^', '>', '<', '!'];
124
+ const PUNCTUATION = '.[]|{}:,()?';
125
+ const PRECEDENCE: Record<string, number> = {
126
+ '||': 10, '&&': 10,
127
+ '==': 20, '!=': 20, '>': 20, '>=': 20, '<': 20, '<=': 20, in: 20,
128
+ '+': 30, '-': 30,
129
+ '*': 40, '/': 40, '//': 40,
130
+ '%': 50, '^': 50
131
+ };
132
+ const BINARY: Record<string, (left: any, right: any) => any> = {
133
+ // eslint-disable-next-line eqeqeq
134
+ '==': (l, r) => l == r,
135
+ // eslint-disable-next-line eqeqeq
136
+ '!=': (l, r) => l != r,
137
+ '>': (l, r) => l > r,
138
+ '>=': (l, r) => l >= r,
139
+ '<': (l, r) => l < r,
140
+ '<=': (l, r) => l <= r,
141
+ in: (l, r) => typeof r === 'string' ? r.indexOf(l) !== -1 : Array.isArray(r) ? r.some(e => e === l) : false,
142
+ '+': (l, r) => l + r,
143
+ '-': (l, r) => l - r,
144
+ '*': (l, r) => l * r,
145
+ '/': (l, r) => l / r,
146
+ '//': (l, r) => Math.floor(l / r),
147
+ '%': (l, r) => l % r,
148
+ '^': (l, r) => Math.pow(l, r)
149
+ };
150
+ const IDENTIFIER_START = /[\p{L}_$]/u;
151
+ const IDENTIFIER_PART = /[\p{L}\p{N}_$]/u;
152
+
153
+ /** A recursive descent parser that compiles to closures: `(context, element) => value`. */
154
+ class ExpressionParser {
155
+ protected readonly tokens: Token[];
156
+ protected index = 0;
157
+ /** Whether the expression being parsed reads `.name`: then a filter keeps the elements it is true for. */
158
+ protected relative = false;
159
+
160
+ constructor(protected readonly source: string, protected readonly engine: ExpressionEngine) {
161
+ this.tokens = this.tokenize();
162
+ }
163
+
164
+ parse(): Evaluate {
165
+ if (this.peek().type === 'end') {
166
+ return () => undefined;
167
+ }
168
+ const evaluate = this.ternary();
169
+ if (this.peek().type !== 'end') {
170
+ throw this.unexpected();
171
+ }
172
+ return evaluate;
173
+ }
174
+
175
+ protected ternary(): Evaluate {
176
+ const test = this.binary(0);
177
+ if (!this.accept('?')) {
178
+ return test;
179
+ }
180
+ const consequent = this.accept(':') ? undefined : this.ternaryThen();
181
+ const alternate = this.ternary();
182
+ if (!consequent) {
183
+ return (c, e) => test(c, e) || alternate(c, e);
184
+ }
185
+ return (c, e) => test(c, e) ? consequent(c, e) : alternate(c, e);
186
+ }
187
+
188
+ protected ternaryThen(): Evaluate {
189
+ const consequent = this.ternary();
190
+ this.expect(':');
191
+ return consequent;
192
+ }
193
+
194
+ /** Operators of `minPrecedence` or more, left to right. */
195
+ protected binary(minPrecedence: number): Evaluate {
196
+ let left = this.unary();
197
+ for (;;) {
198
+ const token = this.peek();
199
+ const precedence = token.type === 'operator' ? PRECEDENCE[token.value] : undefined;
200
+ if (precedence === undefined || precedence < minPrecedence) {
201
+ return left;
202
+ }
203
+ this.index++;
204
+ const l = left;
205
+ const r = this.binary(precedence + 1);
206
+ if (token.value === '&&') {
207
+ left = (c, e) => l(c, e) && r(c, e);
208
+ } else if (token.value === '||') {
209
+ left = (c, e) => l(c, e) || r(c, e);
210
+ } else {
211
+ const apply = BINARY[token.value];
212
+ left = (c, e) => apply(l(c, e), r(c, e));
213
+ }
214
+ }
215
+ }
216
+
217
+ protected unary(): Evaluate {
218
+ const token = this.peek();
219
+ if (token.type === 'operator' && (token.value === '!' || token.value === '-')) {
220
+ this.index++;
221
+ const operand = this.unary();
222
+ if (token.value === '!') {
223
+ return (c, e) => !operand(c, e);
224
+ }
225
+ return (c, e) => -operand(c, e);
226
+ }
227
+ return this.postfix(this.primary());
228
+ }
229
+
230
+ protected primary(): Evaluate {
231
+ const token = this.next();
232
+ switch (token.type) {
233
+ case 'number':
234
+ case 'string':
235
+ case 'boolean': {
236
+ const value = token.value;
237
+ return () => value;
238
+ }
239
+ case 'identifier': {
240
+ const name: string = token.value;
241
+ if (this.accept('(')) {
242
+ const args = this.list(')');
243
+ const { engine, source } = this;
244
+ return (c, e) => engine.call('function', name, args.map(arg => arg(c, e)), source);
245
+ }
246
+ return c => c?.[name];
247
+ }
248
+ case 'punctuation':
249
+ switch (token.value) {
250
+ case '.': {
251
+ const name = this.identifier();
252
+ this.relative = true;
253
+ return (c, e) => e?.[name];
254
+ }
255
+ case '(': {
256
+ const inner = this.ternary();
257
+ this.expect(')');
258
+ return inner;
259
+ }
260
+ case '[': {
261
+ const items = this.list(']');
262
+ return (c, e) => items.map(item => item(c, e));
263
+ }
264
+ case '{':
265
+ return this.object();
266
+ }
267
+ }
268
+ this.index--;
269
+ throw this.unexpected();
270
+ }
271
+
272
+ protected object(): Evaluate {
273
+ const entries: [string, Evaluate][] = [];
274
+ while (!this.accept('}')) {
275
+ const key = this.next();
276
+ if (key.type !== 'identifier' && key.type !== 'string') {
277
+ this.index--;
278
+ throw this.unexpected('a key');
279
+ }
280
+ this.expect(':');
281
+ entries.push([key.value, this.ternary()]);
282
+ if (!this.accept(',')) {
283
+ this.expect('}');
284
+ break;
285
+ }
286
+ }
287
+ return (c, e) => {
288
+ const result: Record<string, any> = {};
289
+ for (const [key, value] of entries) {
290
+ result[key] = value(c, e);
291
+ }
292
+ return result;
293
+ };
294
+ }
295
+
296
+ /** `.name`, `[filter]` and `|transform(args)` after an operand. */
297
+ protected postfix(subject: Evaluate): Evaluate {
298
+ for (;;) {
299
+ if (this.accept('.')) {
300
+ const name = this.identifier();
301
+ const from = subject;
302
+ subject = (c, e) => {
303
+ let value = from(c, e);
304
+ if (value === undefined || value === null) {
305
+ return undefined;
306
+ }
307
+ if (Array.isArray(value)) {
308
+ value = value[0];
309
+ }
310
+ return value?.[name];
311
+ };
312
+ } else if (this.accept('[')) {
313
+ subject = this.filter(subject);
314
+ } else if (this.accept('|')) {
315
+ const name = this.identifier();
316
+ const args = this.accept('(') ? this.list(')') : [];
317
+ const { engine, source } = this;
318
+ const from = subject;
319
+ subject = (c, e) => engine.call('transform', name, [from(c, e), ...args.map(arg => arg(c, e))], source);
320
+ } else {
321
+ return subject;
322
+ }
323
+ }
324
+ }
325
+
326
+ /**
327
+ * `subject[.x > 1]` keeps the elements the filter is true for; any other `subject[key]` is a property
328
+ * (the subject itself or nothing when the key is a boolean).
329
+ */
330
+ protected filter(subject: Evaluate): Evaluate {
331
+ const outer = this.relative;
332
+ this.relative = false;
333
+ const expression = this.ternary();
334
+ const relative = this.relative;
335
+ this.relative = outer;
336
+ this.expect(']');
337
+ if (relative) {
338
+ return (c, e) => {
339
+ const value = subject(c, e);
340
+ const elements = Array.isArray(value) ? value : value === undefined ? [] : [value];
341
+ return elements.filter(element => expression(c, element));
342
+ };
343
+ }
344
+ return (c, e) => {
345
+ const value = subject(c, e);
346
+ const key = expression(c, e);
347
+ if (typeof key === 'boolean') {
348
+ return key ? value : undefined;
349
+ }
350
+ return value === undefined || value === null ? undefined : value[key];
351
+ };
352
+ }
353
+
354
+ /** Comma separated expressions up to `close`; empty items are skipped, like jexl did. */
355
+ protected list(close: string): Evaluate[] {
356
+ const items: Evaluate[] = [];
357
+ while (!this.accept(close)) {
358
+ if (this.accept(',')) {
359
+ continue;
360
+ }
361
+ items.push(this.ternary());
362
+ if (!this.accept(',')) {
363
+ this.expect(close);
364
+ break;
365
+ }
366
+ }
367
+ return items;
368
+ }
369
+
370
+ protected identifier(): string {
371
+ const token = this.next();
372
+ if (token.type !== 'identifier') {
373
+ this.index--;
374
+ throw this.unexpected('a name');
375
+ }
376
+ return token.value;
377
+ }
378
+
379
+ protected peek(): Token {
380
+ return this.tokens[this.index];
381
+ }
382
+
383
+ protected next(): Token {
384
+ const token = this.tokens[this.index];
385
+ if (token.type !== 'end') {
386
+ this.index++;
387
+ }
388
+ return token;
389
+ }
390
+
391
+ protected accept(punctuation: string): boolean {
392
+ const token = this.tokens[this.index];
393
+ if (token.type === 'punctuation' && token.value === punctuation) {
394
+ this.index++;
395
+ return true;
396
+ }
397
+ return false;
398
+ }
399
+
400
+ protected expect(punctuation: string): void {
401
+ if (!this.accept(punctuation)) {
402
+ throw this.unexpected(`'${punctuation}'`);
403
+ }
404
+ }
405
+
406
+ protected unexpected(expected?: string): ExpressionSyntaxError {
407
+ const token = this.peek();
408
+ const found = token.type === 'end' ? 'end of expression' : `'${this.source.slice(token.start, this.tokens[this.index + 1]?.start ?? this.source.length).trim()}'`;
409
+ return this.syntaxError(token.start, `Unexpected ${found}${expected ? `, expected ${expected}` : ''}`);
410
+ }
411
+
412
+ protected syntaxError(position: number, message: string): ExpressionSyntaxError {
413
+ return new ExpressionSyntaxError({
414
+ code: 'CELL_EL_SYNTAX',
415
+ message: `${message} at position ${position} of: ${this.source}`,
416
+ hint: 'Check quotes, brackets and operators; expressions are names, literals, operators, value|transform and function() calls.',
417
+ expression: this.source,
418
+ position
419
+ });
420
+ }
421
+
422
+ protected tokenize(): Token[] {
423
+ const source = this.source;
424
+ const tokens: Token[] = [];
425
+ const isDigit = (c: string | undefined) => c !== undefined && c >= '0' && c <= '9';
426
+ let i = 0;
427
+ while (i < source.length) {
428
+ const c = source[i];
429
+ const start = i;
430
+ if (/\s/.test(c)) {
431
+ i++;
432
+ } else if (c === '\'' || c === '"') {
433
+ // Only \<quote> and \\ are escapes; any other backslash is kept (\d stays \d).
434
+ let value = '';
435
+ i++;
436
+ while (i < source.length && source[i] !== c) {
437
+ if (source[i] === '\\' && i + 1 < source.length) {
438
+ const next = source[i + 1];
439
+ value += next === c || next === '\\' ? next : '\\' + next;
440
+ i += 2;
441
+ } else {
442
+ value += source[i++];
443
+ }
444
+ }
445
+ if (i >= source.length) {
446
+ throw this.syntaxError(start, 'Unterminated string');
447
+ }
448
+ i++;
449
+ tokens.push({ type: 'string', value, start });
450
+ } else if (isDigit(c)) {
451
+ while (isDigit(source[i])) {
452
+ i++;
453
+ }
454
+ if (source[i] === '.' && isDigit(source[i + 1])) {
455
+ i++;
456
+ while (isDigit(source[i])) {
457
+ i++;
458
+ }
459
+ }
460
+ tokens.push({ type: 'number', value: parseFloat(source.slice(start, i)), start });
461
+ } else if (IDENTIFIER_START.test(c)) {
462
+ while (i < source.length && IDENTIFIER_PART.test(source[i])) {
463
+ i++;
464
+ }
465
+ const word = source.slice(start, i);
466
+ if (word === 'true' || word === 'false') {
467
+ tokens.push({ type: 'boolean', value: word === 'true', start });
468
+ } else {
469
+ tokens.push({ type: word === 'in' ? 'operator' : 'identifier', value: word, start });
470
+ }
471
+ } else {
472
+ const operator = OPERATORS.find(op => source.startsWith(op, i));
473
+ if (operator) {
474
+ tokens.push({ type: 'operator', value: operator, start });
475
+ i += operator.length;
476
+ } else if (PUNCTUATION.includes(c)) {
477
+ tokens.push({ type: 'punctuation', value: c, start });
478
+ i++;
479
+ } else {
480
+ throw this.syntaxError(start, `Unexpected character '${c}'`);
481
+ }
482
+ }
483
+ }
484
+ tokens.push({ type: 'end', value: undefined, start: source.length });
485
+ return tokens;
486
+ }
487
+ }
@@ -2,14 +2,13 @@ import { describe, it } from 'bun:test';
2
2
  import { expect } from 'chai';
3
3
  import { ExpressionCompilerImpl } from './expression-compiler';
4
4
  import { ExpressionHandlerImpl } from './expression-handler';
5
- import { JexlEngineProviderImpl } from './jexl-engine-provider';
5
+ import { ExpressionEngine } from './expression-engine';
6
6
 
7
7
  function handler(configuration?: Record<string, unknown>): ExpressionHandlerImpl {
8
- const jexlEngineProvider = new JexlEngineProviderImpl();
8
+ const engine = new ExpressionEngine();
9
9
  const compiler = new ExpressionCompilerImpl();
10
- Object.defineProperty(compiler, 'jexlEngineProvider', { value: jexlEngineProvider });
10
+ Object.defineProperty(compiler, 'engine', { value: engine });
11
11
  const instance = new ExpressionHandlerImpl();
12
- Object.defineProperty(instance, 'jexlEngineProvider', { value: jexlEngineProvider });
13
12
  Object.defineProperty(instance, 'expressionCompiler', { value: compiler });
14
13
  Object.defineProperty(instance, 'expressionContextProvider', { value: { provide: () => configuration } });
15
14
  return instance;
@@ -102,9 +101,9 @@ describe('ExpressionHandler', () => {
102
101
 
103
102
  it('evaluating a value is still possible on purpose, with the eval transform', () => {
104
103
  const instance = handler({ cell: { secret, a: '${env.X | eval}' }, env: env('${cell.secret}') });
105
- const jexl = (instance as unknown as { jexlEngineProvider: { provide(): any } }).jexlEngineProvider.provide();
106
- jexl.addTransform('eval', (text: string) => instance.handle(text));
104
+ const engine = (instance as unknown as { expressionCompiler: { engine: ExpressionEngine } }).expressionCompiler.engine;
105
+ engine.addTransform('eval', (text: string) => instance.handle(text));
107
106
  expect(instance.handle('${cell.a}')).to.equal(secret);
108
107
  });
109
108
  });
110
- });
109
+ });
@@ -1,5 +1,5 @@
1
1
  import { Component, Autowired } from '../annotation';
2
- import { JexlEngineProvider, ExpressionHandler, ExpressionContextProvider, ExpressionCompiler, ExpressionContext, ExpressionCompilerOptions } from './expression-protocol';
2
+ import { ExpressionHandler, ExpressionContextProvider, ExpressionCompiler, ExpressionContext, ExpressionCompilerOptions } from './expression-protocol';
3
3
  import { ExpressionUtil } from './expression-util';
4
4
 
5
5
  /**
@@ -10,9 +10,6 @@ import { ExpressionUtil } from './expression-util';
10
10
  @Component(ExpressionHandler)
11
11
  export class ExpressionHandlerImpl implements ExpressionHandler {
12
12
 
13
- @Autowired(JexlEngineProvider)
14
- protected readonly jexlEngineProvider: JexlEngineProvider<any>;
15
-
16
13
  @Autowired(ExpressionContextProvider)
17
14
  protected readonly expressionContextProvider: ExpressionContextProvider;
18
15
 
@@ -45,4 +42,4 @@ export class ExpressionHandlerImpl implements ExpressionHandler {
45
42
  return { compiler: this.expressionCompiler, compilerOptions };
46
43
  }
47
44
 
48
- }
45
+ }
@@ -1,11 +1,13 @@
1
+ import type { Expression } from './expression-engine';
2
+
1
3
  export const ExpressionCompiler = Symbol('ExpressionCompiler');
2
4
  export const ExpressionHandler = Symbol('ExpressionHandler');
3
5
  export const ContextInitializer = Symbol('ContextInitializer');
4
6
  export const ExpressionContextProvider = Symbol('ExpressionContextProvider');
5
- export const JexlEngineProvider = Symbol('JexlEngineProvider');
6
7
 
8
+ /** Splits a text into literal sections and compiled `${...}` expressions. */
7
9
  export interface ExpressionCompiler {
8
- compileSections(text: string, options?: ExpressionCompilerOptions): any[]
10
+ compileSections(text: string, options?: ExpressionCompilerOptions): (string | Expression)[]
9
11
  }
10
12
 
11
13
  export interface ExpressionHandler {
@@ -37,9 +39,3 @@ export interface ExpressionContextProvider {
37
39
 
38
40
  provide(): ExpressionContext;
39
41
  }
40
-
41
- export interface JexlEngineProvider<T> {
42
-
43
- provide(): T
44
- }
45
-
@@ -1,21 +1,21 @@
1
- import { Jexl } from 'jexl';
2
1
  import { ExpressionCompiler, ExpressionCompilerOptions, ExpressionContext } from './expression-protocol';
2
+ import { Expression, ExpressionEngine } from './expression-engine';
3
3
 
4
4
  interface MiddleExpression {
5
- expression: any;
5
+ expression: string | Expression;
6
6
  nextText?: string;
7
7
  }
8
8
 
9
9
  /**
10
- * Splits a text into literal sections and compiled `${...}` expressions (jexl). It has no dependency
10
+ * Splits a text into literal sections and compiled `${...}` expressions. It has no dependency
11
11
  * injection, so the build (@celljs/vite) and the runtime share it through `@celljs/core/el`.
12
12
  */
13
13
  export class ExpressionSectionCompiler implements ExpressionCompiler {
14
14
 
15
- protected static jexlEngine?: any;
15
+ protected static defaultEngine?: ExpressionEngine;
16
16
 
17
- /** @param jexl the engine; the runtime passes the one of its JexlEngineProvider, which has the transforms */
18
- constructor(protected readonly jexl: () => any = () => (ExpressionSectionCompiler.jexlEngine ??= new Jexl())) { }
17
+ /** @param engine the runtime passes the ExpressionEngine of its container, which has the transforms */
18
+ constructor(protected readonly engine: () => ExpressionEngine = () => (ExpressionSectionCompiler.defaultEngine ??= new ExpressionEngine())) { }
19
19
 
20
20
  private ESCAPE_CHAR = '\\';
21
21
  private SPECIAL_CHAR = '$';
@@ -36,7 +36,7 @@ export class ExpressionSectionCompiler implements ExpressionCompiler {
36
36
  return char === opitons.specialChar;
37
37
  }
38
38
 
39
- compileSections(text: string, options: ExpressionCompilerOptions): any[] {
39
+ compileSections(text: string, options: ExpressionCompilerOptions): (string | Expression)[] {
40
40
  const merged = {
41
41
  ...{ escapeChar: this.ESCAPE_CHAR, specialChar: this.SPECIAL_CHAR, bracketBegin: this.BRACKET_BEGIN, bracketEnd: this.BRACKET_END, ...options }
42
42
  } as Required<ExpressionCompilerOptions>;
@@ -44,7 +44,7 @@ export class ExpressionSectionCompiler implements ExpressionCompiler {
44
44
  return [];
45
45
  }
46
46
 
47
- const sections: any[] = [];
47
+ const sections: (string | Expression)[] = [];
48
48
  let middleText: string | undefined = text;
49
49
  while (middleText) {
50
50
  const me: MiddleExpression | undefined = this.middleCompile(middleText, merged);
@@ -110,8 +110,7 @@ export class ExpressionSectionCompiler implements ExpressionCompiler {
110
110
  section.push(c);
111
111
  } else if (options.bracketEnd === c) {
112
112
  if (bracketBeginCharFound === 0 && bracketBeginCharNum === 1) {
113
- const jexlEngine = this.jexl();
114
- const expression = jexlEngine.createExpression(section.join(''));
113
+ const expression = this.engine().compile(section.join(''));
115
114
  let nextText;
116
115
  if (i !== text.length - 1) {
117
116
  nextText = text.substring(i + 1);
@@ -202,7 +201,7 @@ export class ExpressionError extends Error {
202
201
  export namespace ExpressionUtil {
203
202
 
204
203
  export interface Options {
205
- /** Defaults to an {@link ExpressionSectionCompiler} on a plain jexl engine (no transforms). */
204
+ /** Defaults to an {@link ExpressionSectionCompiler} on a plain {@link ExpressionEngine} (no transforms). */
206
205
  compiler?: ExpressionCompiler;
207
206
  compilerOptions?: ExpressionCompilerOptions;
208
207
  }
@@ -225,9 +224,9 @@ export namespace ExpressionUtil {
225
224
  }
226
225
  const c = typeof context === 'function' ? context() : context;
227
226
  if (sections.length === 1) {
228
- return sections[0].evalSync(c);
227
+ return (sections[0] as Expression).evaluate(c);
229
228
  }
230
- return sections.map(section => (typeof section === 'string' ? section : section.evalSync(c))).join('');
229
+ return sections.map(section => (typeof section === 'string' ? section : section.evaluate(c))).join('');
231
230
  }
232
231
 
233
232
  /**
@@ -1,7 +1,8 @@
1
1
  export * from './expression-protocol';
2
+ export * from './expression-engine';
3
+ export * from './application-expression-engine';
2
4
  export * from './expression-compiler';
3
5
  export * from './expression-context-provider';
4
6
  export * from './expression-handler';
5
7
  export * from './expression-util';
6
- export * from './jexl-engine-provider';
7
- export * from './core-context-initializer';
8
+ export * from './core-context-initializer';
@@ -7,7 +7,7 @@ import { ConfigUtil } from '../config/config-util';
7
7
  import { ExpressionHandler } from './expression-protocol';
8
8
 
9
9
  /**
10
- * @Value、ConfigUtil 与 EL(${...},jexl)的约定(阶段 1.E 行为测试)。
10
+ * @Value、ConfigUtil 与 EL(${...},ExpressionEngine)的约定(阶段 1.E 行为测试)。
11
11
  * 配置就是 ApplicationFactory.create() 的第一个参数(CLI 生成的入口会把合并后的 cell.yml 传进来)。
12
12
  */
13
13
  const boot = (props: Record<string, any>) => ApplicationFactory.create(props);
@@ -130,7 +130,7 @@ describe('core EL(ExpressionHandler)', () => {
130
130
  expect(el().handle('n=${cell.n}, n2=${cell.n * cell.n}')).to.equal('n=2, n2=4');
131
131
  });
132
132
 
133
- it('jexl 的运算、三元、字符串里的 } 都能正确切分', async () => {
133
+ it('表达式的运算、三元、字符串里的 } 都能正确切分', async () => {
134
134
  await boot({ cell: { port: 3000, name: 'x' } });
135
135
  expect(el().handle('${cell.port > 1000 ? "high" : "low"}')).to.equal('high');
136
136
  expect(el().handle('${"a}b" + cell.name}')).to.equal('a}bx');
@@ -1,6 +1,4 @@
1
1
  export * from './component-filter-registry';
2
2
  export * from './provider';
3
- export * from './provider-creator';
4
3
  export * from './provider-protocol';
5
4
  export * from './provider-util';
6
-