@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.
- package/README.md +49 -68
- package/esm/browser/static-module.d.ts +1 -1
- package/esm/common/annotation/aspect.d.ts +2 -1
- package/esm/common/annotation/aspect.js.map +1 -1
- package/esm/common/annotation/autowired-provider.d.ts +0 -2
- package/esm/common/annotation/autowired-provider.js +4 -13
- package/esm/common/annotation/autowired-provider.js.map +1 -1
- package/esm/common/annotation/autowired.d.ts +1 -1
- package/esm/common/annotation/autowired.js +11 -3
- package/esm/common/annotation/autowired.js.map +1 -1
- package/esm/common/annotation/component.d.ts +4 -8
- package/esm/common/annotation/component.js +0 -6
- package/esm/common/annotation/component.js.map +1 -1
- package/esm/common/annotation/constant.d.ts +1 -1
- package/esm/common/annotation/constant.js +6 -3
- package/esm/common/annotation/constant.js.map +1 -1
- package/esm/common/annotation/detached/autowired-provider.js +2 -2
- package/esm/common/annotation/detached/autowired-provider.js.map +1 -1
- package/esm/common/annotation/index.d.ts +0 -6
- package/esm/common/annotation/index.js +0 -6
- package/esm/common/annotation/index.js.map +1 -1
- package/esm/common/annotation/named.d.ts +2 -1
- package/esm/common/annotation/named.js +5 -1
- package/esm/common/annotation/named.js.map +1 -1
- package/esm/common/annotation/optional.d.ts +2 -1
- package/esm/common/annotation/optional.js +5 -1
- package/esm/common/annotation/optional.js.map +1 -1
- package/esm/common/annotation/post-construct.d.ts +2 -1
- package/esm/common/annotation/post-construct.js +5 -1
- package/esm/common/annotation/post-construct.js.map +1 -1
- package/esm/common/annotation/tagged.d.ts +2 -1
- package/esm/common/annotation/tagged.js +6 -1
- package/esm/common/annotation/tagged.js.map +1 -1
- package/esm/common/annotation/value.d.ts +3 -2
- package/esm/common/annotation/value.js +7 -10
- package/esm/common/annotation/value.js.map +1 -1
- package/esm/common/aop/aop-proxy-factory.d.ts +6 -2
- package/esm/common/aop/aop-proxy-factory.js +44 -28
- package/esm/common/aop/aop-proxy-factory.js.map +1 -1
- package/esm/common/aop/class-filter.js +6 -6
- package/esm/common/aop/class-filter.js.map +1 -1
- package/esm/common/application/application-factory.d.ts +1 -1
- package/esm/common/application/application-factory.js +4 -4
- package/esm/common/application/application-factory.js.map +1 -1
- package/esm/common/application/application-protocol.js +1 -1
- package/esm/common/application/application-protocol.js.map +1 -1
- package/esm/common/config/config-provider.js +2 -1
- package/esm/common/config/config-provider.js.map +1 -1
- package/esm/common/container/auto-bind.d.ts +7 -3
- package/esm/common/container/auto-bind.js +54 -71
- package/esm/common/container/auto-bind.js.map +1 -1
- package/esm/common/container/container-error.d.ts +21 -0
- package/esm/common/container/container-error.js +22 -0
- package/esm/common/container/container-error.js.map +1 -0
- package/esm/common/container/container-provider.d.ts +5 -4
- package/esm/common/container/container-provider.js +2 -1
- package/esm/common/container/container-provider.js.map +1 -1
- package/esm/common/container/container-util.d.ts +5 -7
- package/esm/common/container/container-util.js +8 -19
- package/esm/common/container/container-util.js.map +1 -1
- package/esm/common/container/container.d.ts +104 -0
- package/esm/common/container/container.js +299 -0
- package/esm/common/container/container.js.map +1 -0
- package/esm/common/container/dynamic-container.d.ts +1 -1
- package/esm/common/container/dynamic-container.js +2 -2
- package/esm/common/container/dynamic-container.js.map +1 -1
- package/esm/common/container/index.d.ts +5 -6
- package/esm/common/container/index.js +5 -3
- package/esm/common/container/index.js.map +1 -1
- package/esm/common/container/injection.d.ts +40 -0
- package/esm/common/container/injection.js +109 -0
- package/esm/common/container/injection.js.map +1 -0
- package/esm/common/container/scope.d.ts +2 -3
- package/esm/common/container/scope.js +2 -3
- package/esm/common/container/scope.js.map +1 -1
- package/esm/common/el/application-expression-engine.d.ts +7 -0
- package/esm/common/{provider/provider-creator.js → el/application-expression-engine.js} +11 -11
- package/esm/common/el/application-expression-engine.js.map +1 -0
- package/esm/common/el/core-context-initializer.d.ts +3 -2
- package/esm/common/el/core-context-initializer.js +10 -8
- package/esm/common/el/core-context-initializer.js.map +1 -1
- package/esm/common/el/expression-compiler.d.ts +7 -17
- package/esm/common/el/expression-compiler.js +10 -166
- package/esm/common/el/expression-compiler.js.map +1 -1
- package/esm/common/el/expression-engine.d.ts +61 -0
- package/esm/common/el/expression-engine.js +459 -0
- package/esm/common/el/expression-engine.js.map +1 -0
- package/esm/common/el/expression-handler.d.ts +8 -4
- package/esm/common/el/expression-handler.js +15 -58
- package/esm/common/el/expression-handler.js.map +1 -1
- package/esm/common/el/expression-protocol.d.ts +3 -5
- package/esm/common/el/expression-protocol.js +0 -1
- package/esm/common/el/expression-protocol.js.map +1 -1
- package/esm/common/el/expression-util.d.ts +69 -0
- package/esm/common/el/expression-util.js +346 -0
- package/esm/common/el/expression-util.js.map +1 -0
- package/esm/common/el/index.d.ts +3 -1
- package/esm/common/el/index.js +3 -1
- package/esm/common/el/index.js.map +1 -1
- package/esm/common/logger/abstract-logger.d.ts +4 -2
- package/esm/common/logger/abstract-logger.js +11 -6
- package/esm/common/logger/abstract-logger.js.map +1 -1
- package/esm/common/logger/logger-protocol.d.ts +4 -0
- package/esm/common/logger/logger-protocol.js +2 -0
- package/esm/common/logger/logger-protocol.js.map +1 -1
- package/esm/common/logger/logger.js +7 -7
- package/esm/common/logger/logger.js.map +1 -1
- package/esm/common/provider/index.d.ts +0 -1
- package/esm/common/provider/index.js +0 -1
- package/esm/common/provider/index.js.map +1 -1
- package/esm/common/provider/provider-protocol.d.ts +5 -9
- package/esm/common/provider/provider-protocol.js +0 -1
- package/esm/common/provider/provider-protocol.js.map +1 -1
- package/esm/common/provider/provider-util.d.ts +1 -1
- package/esm/common/provider/provider-util.js +2 -2
- package/esm/common/provider/provider-util.js.map +1 -1
- package/esm/common/provider/provider.d.ts +7 -6
- package/esm/common/provider/provider.js +15 -26
- package/esm/common/provider/provider.js.map +1 -1
- package/esm/common/static-module.d.ts +1 -1
- package/esm/common/static-module.js +1 -1
- package/esm/common/static-module.js.map +1 -1
- package/esm/common/test/mock-logger.d.ts +1 -0
- package/esm/common/test/mock-logger.js +5 -13
- package/esm/common/test/mock-logger.js.map +1 -1
- package/esm/common/test/test-module.d.ts +1 -1
- package/esm/common/test/test-module.js +1 -1
- package/esm/common/test/test-module.js.map +1 -1
- package/esm/common/utils/annotation-util.js +2 -1
- package/esm/common/utils/annotation-util.js.map +1 -1
- package/esm/common/utils/emitter.d.ts +1 -10
- package/esm/common/utils/emitter.js +0 -56
- package/esm/common/utils/emitter.js.map +1 -1
- package/esm/common/utils/mime-type-util.js +1 -1
- package/esm/common/utils/mime-type-util.js.map +1 -1
- package/esm/common/utils/mime-type.js +1 -1
- package/esm/common/utils/mime-type.js.map +1 -1
- package/esm/common/utils/proxy-util.d.ts +5 -2
- package/esm/common/utils/proxy-util.js +10 -28
- package/esm/common/utils/proxy-util.js.map +1 -1
- package/esm/node/context/context.d.ts +11 -2
- package/esm/node/context/context.js +36 -12
- package/esm/node/context/context.js.map +1 -1
- package/esm/node/index.d.ts +0 -1
- package/esm/node/index.js +0 -1
- package/esm/node/index.js.map +1 -1
- package/esm/node/static-module.d.ts +1 -1
- package/lib/browser/static-module.d.ts +1 -1
- package/lib/common/annotation/aspect.d.ts +2 -1
- package/lib/common/annotation/aspect.d.ts.map +1 -1
- package/lib/common/annotation/aspect.js.map +1 -1
- package/lib/common/annotation/autowired-provider.d.ts +0 -2
- package/lib/common/annotation/autowired-provider.d.ts.map +1 -1
- package/lib/common/annotation/autowired-provider.js +4 -14
- package/lib/common/annotation/autowired-provider.js.map +1 -1
- package/lib/common/annotation/autowired.d.ts +1 -1
- package/lib/common/annotation/autowired.d.ts.map +1 -1
- package/lib/common/annotation/autowired.js +11 -3
- package/lib/common/annotation/autowired.js.map +1 -1
- package/lib/common/annotation/component.d.ts +4 -8
- package/lib/common/annotation/component.d.ts.map +1 -1
- package/lib/common/annotation/component.js +0 -6
- package/lib/common/annotation/component.js.map +1 -1
- package/lib/common/annotation/constant.d.ts +1 -1
- package/lib/common/annotation/constant.d.ts.map +1 -1
- package/lib/common/annotation/constant.js +6 -3
- package/lib/common/annotation/constant.js.map +1 -1
- package/lib/common/annotation/detached/autowired-provider.js +2 -2
- package/lib/common/annotation/detached/autowired-provider.js.map +1 -1
- package/lib/common/annotation/index.d.ts +0 -6
- package/lib/common/annotation/index.d.ts.map +1 -1
- package/lib/common/annotation/index.js +0 -6
- package/lib/common/annotation/index.js.map +1 -1
- package/lib/common/annotation/named.d.ts +2 -1
- package/lib/common/annotation/named.d.ts.map +1 -1
- package/lib/common/annotation/named.js +6 -2
- package/lib/common/annotation/named.js.map +1 -1
- package/lib/common/annotation/optional.d.ts +2 -1
- package/lib/common/annotation/optional.d.ts.map +1 -1
- package/lib/common/annotation/optional.js +6 -2
- package/lib/common/annotation/optional.js.map +1 -1
- package/lib/common/annotation/post-construct.d.ts +2 -1
- package/lib/common/annotation/post-construct.d.ts.map +1 -1
- package/lib/common/annotation/post-construct.js +6 -2
- package/lib/common/annotation/post-construct.js.map +1 -1
- package/lib/common/annotation/tagged.d.ts +2 -1
- package/lib/common/annotation/tagged.d.ts.map +1 -1
- package/lib/common/annotation/tagged.js +7 -2
- package/lib/common/annotation/tagged.js.map +1 -1
- package/lib/common/annotation/value.d.ts +3 -2
- package/lib/common/annotation/value.d.ts.map +1 -1
- package/lib/common/annotation/value.js +7 -10
- package/lib/common/annotation/value.js.map +1 -1
- package/lib/common/aop/aop-proxy-factory.d.ts +6 -2
- package/lib/common/aop/aop-proxy-factory.d.ts.map +1 -1
- package/lib/common/aop/aop-proxy-factory.js +45 -29
- package/lib/common/aop/aop-proxy-factory.js.map +1 -1
- package/lib/common/aop/aop.spec.d.ts +2 -0
- package/lib/common/aop/aop.spec.d.ts.map +1 -0
- package/lib/common/aop/aop.spec.js +170 -0
- package/lib/common/aop/aop.spec.js.map +1 -0
- package/lib/common/aop/class-filter.js +7 -7
- package/lib/common/aop/class-filter.js.map +1 -1
- package/lib/common/application/application-factory.d.ts +1 -1
- package/lib/common/application/application-factory.d.ts.map +1 -1
- package/lib/common/application/application-factory.js +4 -4
- package/lib/common/application/application-factory.js.map +1 -1
- package/lib/common/application/application-protocol.js +1 -1
- package/lib/common/application/application-protocol.js.map +1 -1
- package/lib/common/application/lifecycle.spec.d.ts +2 -0
- package/lib/common/application/lifecycle.spec.d.ts.map +1 -0
- package/lib/common/application/lifecycle.spec.js +155 -0
- package/lib/common/application/lifecycle.spec.js.map +1 -0
- package/lib/common/config/config-provider.js +2 -1
- package/lib/common/config/config-provider.js.map +1 -1
- package/lib/common/container/assembly.spec.d.ts +2 -0
- package/lib/common/container/assembly.spec.d.ts.map +1 -0
- package/lib/common/container/assembly.spec.js +464 -0
- package/lib/common/container/assembly.spec.js.map +1 -0
- package/lib/common/container/auto-bind.d.ts +7 -3
- package/lib/common/container/auto-bind.d.ts.map +1 -1
- package/lib/common/container/auto-bind.js +54 -72
- package/lib/common/container/auto-bind.js.map +1 -1
- package/lib/common/container/container-error.d.ts +22 -0
- package/lib/common/container/container-error.d.ts.map +1 -0
- package/lib/common/container/container-error.js +26 -0
- package/lib/common/container/container-error.js.map +1 -0
- package/lib/common/container/container-provider.d.ts +5 -4
- package/lib/common/container/container-provider.d.ts.map +1 -1
- package/lib/common/container/container-provider.js +3 -2
- package/lib/common/container/container-provider.js.map +1 -1
- package/lib/common/container/container-util.d.ts +5 -7
- package/lib/common/container/container-util.d.ts.map +1 -1
- package/lib/common/container/container-util.js +8 -19
- package/lib/common/container/container-util.js.map +1 -1
- package/lib/common/container/container.d.ts +105 -0
- package/lib/common/container/container.d.ts.map +1 -0
- package/lib/common/container/container.js +305 -0
- package/lib/common/container/container.js.map +1 -0
- package/lib/common/container/container.spec.d.ts +2 -0
- package/lib/common/container/container.spec.d.ts.map +1 -0
- package/lib/common/container/container.spec.js +334 -0
- package/lib/common/container/container.spec.js.map +1 -0
- package/lib/common/container/dynamic-container.d.ts +1 -1
- package/lib/common/container/dynamic-container.d.ts.map +1 -1
- package/lib/common/container/dynamic-container.js +3 -3
- package/lib/common/container/dynamic-container.js.map +1 -1
- package/lib/common/container/index.d.ts +5 -6
- package/lib/common/container/index.d.ts.map +1 -1
- package/lib/common/container/index.js +5 -3
- package/lib/common/container/index.js.map +1 -1
- package/lib/common/container/injection.d.ts +41 -0
- package/lib/common/container/injection.d.ts.map +1 -0
- package/lib/common/container/injection.js +112 -0
- package/lib/common/container/injection.js.map +1 -0
- package/lib/common/container/scope.d.ts +2 -3
- package/lib/common/container/scope.d.ts.map +1 -1
- package/lib/common/container/scope.js +2 -3
- package/lib/common/container/scope.js.map +1 -1
- package/lib/common/el/application-expression-engine.d.ts +8 -0
- package/lib/common/el/application-expression-engine.d.ts.map +1 -0
- package/lib/common/el/application-expression-engine.js +22 -0
- package/lib/common/el/application-expression-engine.js.map +1 -0
- package/lib/common/el/core-context-initializer.d.ts +3 -2
- package/lib/common/el/core-context-initializer.d.ts.map +1 -1
- package/lib/common/el/core-context-initializer.js +9 -7
- package/lib/common/el/core-context-initializer.js.map +1 -1
- package/lib/common/el/expression-compiler.d.ts +7 -17
- package/lib/common/el/expression-compiler.d.ts.map +1 -1
- package/lib/common/el/expression-compiler.js +10 -166
- package/lib/common/el/expression-compiler.js.map +1 -1
- package/lib/common/el/expression-engine.d.ts +62 -0
- package/lib/common/el/expression-engine.d.ts.map +1 -0
- package/lib/common/el/expression-engine.js +465 -0
- package/lib/common/el/expression-engine.js.map +1 -0
- package/lib/common/el/expression-engine.spec.d.ts +2 -0
- package/lib/common/el/expression-engine.spec.d.ts.map +1 -0
- package/lib/common/el/expression-engine.spec.js +100 -0
- package/lib/common/el/expression-engine.spec.js.map +1 -0
- package/lib/common/el/expression-handler.d.ts +8 -4
- package/lib/common/el/expression-handler.d.ts.map +1 -1
- package/lib/common/el/expression-handler.js +14 -60
- package/lib/common/el/expression-handler.js.map +1 -1
- package/lib/common/el/expression-handler.spec.d.ts +2 -0
- package/lib/common/el/expression-handler.spec.d.ts.map +1 -0
- package/lib/common/el/expression-handler.spec.js +98 -0
- package/lib/common/el/expression-handler.spec.js.map +1 -0
- package/lib/common/el/expression-protocol.d.ts +3 -5
- package/lib/common/el/expression-protocol.d.ts.map +1 -1
- package/lib/common/el/expression-protocol.js +1 -2
- package/lib/common/el/expression-protocol.js.map +1 -1
- package/lib/common/el/expression-util.d.ts +70 -0
- package/lib/common/el/expression-util.d.ts.map +1 -0
- package/lib/common/el/expression-util.js +351 -0
- package/lib/common/el/expression-util.js.map +1 -0
- package/lib/common/el/expression-util.spec.d.ts +2 -0
- package/lib/common/el/expression-util.spec.d.ts.map +1 -0
- package/lib/common/el/expression-util.spec.js +45 -0
- package/lib/common/el/expression-util.spec.js.map +1 -0
- package/lib/common/el/index.d.ts +3 -1
- package/lib/common/el/index.d.ts.map +1 -1
- package/lib/common/el/index.js +3 -1
- package/lib/common/el/index.js.map +1 -1
- package/lib/common/el/value-and-el.spec.d.ts +2 -0
- package/lib/common/el/value-and-el.spec.d.ts.map +1 -0
- package/lib/common/el/value-and-el.spec.js +216 -0
- package/lib/common/el/value-and-el.spec.js.map +1 -0
- package/lib/common/logger/abstract-logger.d.ts +4 -2
- package/lib/common/logger/abstract-logger.d.ts.map +1 -1
- package/lib/common/logger/abstract-logger.js +10 -5
- package/lib/common/logger/abstract-logger.js.map +1 -1
- package/lib/common/logger/logger-protocol.d.ts +4 -0
- package/lib/common/logger/logger-protocol.d.ts.map +1 -1
- package/lib/common/logger/logger-protocol.js +3 -1
- package/lib/common/logger/logger-protocol.js.map +1 -1
- package/lib/common/logger/logger.js +7 -7
- package/lib/common/logger/logger.js.map +1 -1
- package/lib/common/logger/logger.spec.d.ts +2 -0
- package/lib/common/logger/logger.spec.d.ts.map +1 -0
- package/lib/common/logger/logger.spec.js +57 -0
- package/lib/common/logger/logger.spec.js.map +1 -0
- package/lib/common/provider/index.d.ts +0 -1
- package/lib/common/provider/index.d.ts.map +1 -1
- package/lib/common/provider/index.js +0 -1
- package/lib/common/provider/index.js.map +1 -1
- package/lib/common/provider/provider-protocol.d.ts +5 -9
- package/lib/common/provider/provider-protocol.d.ts.map +1 -1
- package/lib/common/provider/provider-protocol.js +1 -2
- package/lib/common/provider/provider-protocol.js.map +1 -1
- package/lib/common/provider/provider-util.d.ts +1 -1
- package/lib/common/provider/provider-util.d.ts.map +1 -1
- package/lib/common/provider/provider-util.js +2 -2
- package/lib/common/provider/provider-util.js.map +1 -1
- package/lib/common/provider/provider.d.ts +7 -6
- package/lib/common/provider/provider.d.ts.map +1 -1
- package/lib/common/provider/provider.js +16 -26
- package/lib/common/provider/provider.js.map +1 -1
- package/lib/common/static-module.d.ts +1 -1
- package/lib/common/static-module.js +2 -2
- package/lib/common/static-module.js.map +1 -1
- package/lib/common/test/mock-logger.d.ts +1 -0
- package/lib/common/test/mock-logger.d.ts.map +1 -1
- package/lib/common/test/mock-logger.js +5 -12
- package/lib/common/test/mock-logger.js.map +1 -1
- package/lib/common/test/test-module.d.ts +1 -1
- package/lib/common/test/test-module.d.ts.map +1 -1
- package/lib/common/test/test-module.js +2 -2
- package/lib/common/test/test-module.js.map +1 -1
- package/lib/common/utils/annotation-util.js +2 -1
- package/lib/common/utils/annotation-util.js.map +1 -1
- package/lib/common/utils/emitter.d.ts +1 -10
- package/lib/common/utils/emitter.d.ts.map +1 -1
- package/lib/common/utils/emitter.js +1 -58
- package/lib/common/utils/emitter.js.map +1 -1
- package/lib/common/utils/mime-type-util.js +1 -1
- package/lib/common/utils/mime-type-util.js.map +1 -1
- package/lib/common/utils/mime-type.js +1 -1
- package/lib/common/utils/mime-type.js.map +1 -1
- package/lib/common/utils/proxy-util.d.ts +5 -2
- package/lib/common/utils/proxy-util.d.ts.map +1 -1
- package/lib/common/utils/proxy-util.js +12 -30
- package/lib/common/utils/proxy-util.js.map +1 -1
- package/lib/common/utils/utils-behavior.spec.d.ts +2 -0
- package/lib/common/utils/utils-behavior.spec.d.ts.map +1 -0
- package/lib/common/utils/utils-behavior.spec.js +232 -0
- package/lib/common/utils/utils-behavior.spec.js.map +1 -0
- package/lib/node/context/context.d.ts +11 -2
- package/lib/node/context/context.d.ts.map +1 -1
- package/lib/node/context/context.js +36 -10
- package/lib/node/context/context.js.map +1 -1
- package/lib/node/context/context.spec.d.ts +2 -0
- package/lib/node/context/context.spec.d.ts.map +1 -0
- package/lib/node/context/context.spec.js +202 -0
- package/lib/node/context/context.spec.js.map +1 -0
- package/lib/node/index.d.ts +0 -1
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/index.js +0 -1
- package/lib/node/index.js.map +1 -1
- package/lib/node/static-module.d.ts +1 -1
- package/package.json +9 -21
- package/src/common/annotation/aspect.ts +2 -1
- package/src/common/annotation/autowired-provider.ts +4 -17
- package/src/common/annotation/autowired.ts +14 -6
- package/src/common/annotation/component.ts +6 -26
- package/src/common/annotation/constant.ts +10 -7
- package/src/common/annotation/detached/autowired-provider.ts +2 -2
- package/src/common/annotation/index.ts +0 -6
- package/src/common/annotation/named.ts +7 -1
- package/src/common/annotation/optional.ts +6 -1
- package/src/common/annotation/post-construct.ts +6 -1
- package/src/common/annotation/tagged.ts +8 -1
- package/src/common/annotation/value.ts +9 -11
- package/src/common/aop/aop-proxy-factory.ts +52 -30
- package/src/common/aop/aop.spec.ts +145 -0
- package/src/common/aop/class-filter.ts +6 -6
- package/src/common/application/application-factory.ts +4 -5
- package/src/common/application/application-protocol.ts +1 -1
- package/src/common/application/lifecycle.spec.ts +148 -0
- package/src/common/config/config-provider.ts +1 -1
- package/src/common/container/assembly.spec.ts +288 -0
- package/src/common/container/auto-bind.ts +56 -74
- package/src/common/container/container-error.ts +31 -0
- package/src/common/container/container-provider.ts +9 -7
- package/src/common/container/container-util.ts +8 -19
- package/src/common/container/container.spec.ts +262 -0
- package/src/common/container/container.ts +363 -0
- package/src/common/container/dynamic-container.ts +2 -2
- package/src/common/container/index.ts +5 -7
- package/src/common/container/injection.ts +135 -0
- package/src/common/container/scope.ts +2 -1
- package/src/common/el/application-expression-engine.ts +9 -0
- package/src/common/el/core-context-initializer.ts +9 -8
- package/src/common/el/expression-compiler.ts +9 -168
- package/src/common/el/expression-engine.spec.ts +107 -0
- package/src/common/el/expression-engine.ts +487 -0
- package/src/common/el/expression-handler.spec.ts +109 -0
- package/src/common/el/expression-handler.ts +17 -57
- package/src/common/el/expression-protocol.ts +4 -8
- package/src/common/el/expression-util.spec.ts +45 -0
- package/src/common/el/expression-util.ts +362 -0
- package/src/common/el/index.ts +3 -1
- package/src/common/el/value-and-el.spec.ts +186 -0
- package/src/common/logger/abstract-logger.ts +12 -6
- package/src/common/logger/logger-protocol.ts +5 -0
- package/src/common/logger/logger.spec.ts +61 -0
- package/src/common/logger/logger.ts +7 -7
- package/src/common/provider/index.ts +0 -2
- package/src/common/provider/provider-protocol.ts +5 -11
- package/src/common/provider/provider-util.ts +3 -3
- package/src/common/provider/provider.ts +17 -29
- package/src/common/static-module.ts +1 -1
- package/src/common/test/mock-logger.ts +3 -2
- package/src/common/test/test-module.ts +1 -1
- package/src/common/utils/annotation-util.ts +2 -2
- package/src/common/utils/emitter.ts +1 -63
- package/src/common/utils/mime-type-util.ts +1 -1
- package/src/common/utils/mime-type.ts +1 -1
- package/src/common/utils/proxy-util.ts +8 -28
- package/src/common/utils/utils-behavior.spec.ts +259 -0
- package/src/node/context/context.spec.ts +219 -0
- package/src/node/context/context.ts +35 -10
- package/src/node/index.ts +0 -1
- package/esm/common/annotation/decorate.d.ts +0 -1
- package/esm/common/annotation/decorate.js +0 -2
- package/esm/common/annotation/decorate.js.map +0 -1
- package/esm/common/annotation/inject.d.ts +0 -1
- package/esm/common/annotation/inject.js +0 -2
- package/esm/common/annotation/inject.js.map +0 -1
- package/esm/common/annotation/injectable.d.ts +0 -1
- package/esm/common/annotation/injectable.js +0 -2
- package/esm/common/annotation/injectable.js.map +0 -1
- package/esm/common/annotation/pre-destroy.d.ts +0 -1
- package/esm/common/annotation/pre-destroy.js +0 -2
- package/esm/common/annotation/pre-destroy.js.map +0 -1
- package/esm/common/annotation/target-name.d.ts +0 -1
- package/esm/common/annotation/target-name.js +0 -2
- package/esm/common/annotation/target-name.js.map +0 -1
- package/esm/common/annotation/unmanaged.d.ts +0 -1
- package/esm/common/annotation/unmanaged.js +0 -2
- package/esm/common/annotation/unmanaged.js.map +0 -1
- package/esm/common/container/container-factory.d.ts +0 -4
- package/esm/common/container/container-factory.js +0 -9
- package/esm/common/container/container-factory.js.map +0 -1
- package/esm/common/el/jexl-engine-provider.d.ts +0 -5
- package/esm/common/el/jexl-engine-provider.js +0 -22
- package/esm/common/el/jexl-engine-provider.js.map +0 -1
- package/esm/common/provider/provider-creator.d.ts +0 -6
- package/esm/common/provider/provider-creator.js.map +0 -1
- package/esm/node/utils/crc.d.ts +0 -1
- package/esm/node/utils/crc.js +0 -7
- package/esm/node/utils/crc.js.map +0 -1
- package/esm/node/utils/index.d.ts +0 -1
- package/esm/node/utils/index.js +0 -2
- package/esm/node/utils/index.js.map +0 -1
- package/lib/common/annotation/decorate.d.ts +0 -2
- package/lib/common/annotation/decorate.d.ts.map +0 -1
- package/lib/common/annotation/decorate.js +0 -6
- package/lib/common/annotation/decorate.js.map +0 -1
- package/lib/common/annotation/inject.d.ts +0 -2
- package/lib/common/annotation/inject.d.ts.map +0 -1
- package/lib/common/annotation/inject.js +0 -6
- package/lib/common/annotation/inject.js.map +0 -1
- package/lib/common/annotation/injectable.d.ts +0 -2
- package/lib/common/annotation/injectable.d.ts.map +0 -1
- package/lib/common/annotation/injectable.js +0 -6
- package/lib/common/annotation/injectable.js.map +0 -1
- package/lib/common/annotation/pre-destroy.d.ts +0 -2
- package/lib/common/annotation/pre-destroy.d.ts.map +0 -1
- package/lib/common/annotation/pre-destroy.js +0 -6
- package/lib/common/annotation/pre-destroy.js.map +0 -1
- package/lib/common/annotation/target-name.d.ts +0 -2
- package/lib/common/annotation/target-name.d.ts.map +0 -1
- package/lib/common/annotation/target-name.js +0 -6
- package/lib/common/annotation/target-name.js.map +0 -1
- package/lib/common/annotation/unmanaged.d.ts +0 -2
- package/lib/common/annotation/unmanaged.d.ts.map +0 -1
- package/lib/common/annotation/unmanaged.js +0 -6
- package/lib/common/annotation/unmanaged.js.map +0 -1
- package/lib/common/container/container-factory.d.ts +0 -5
- package/lib/common/container/container-factory.d.ts.map +0 -1
- package/lib/common/container/container-factory.js +0 -13
- package/lib/common/container/container-factory.js.map +0 -1
- package/lib/common/el/jexl-engine-provider.d.ts +0 -6
- package/lib/common/el/jexl-engine-provider.d.ts.map +0 -1
- package/lib/common/el/jexl-engine-provider.js +0 -25
- package/lib/common/el/jexl-engine-provider.js.map +0 -1
- package/lib/common/provider/provider-creator.d.ts +0 -7
- package/lib/common/provider/provider-creator.d.ts.map +0 -1
- package/lib/common/provider/provider-creator.js +0 -22
- package/lib/common/provider/provider-creator.js.map +0 -1
- package/lib/node/utils/crc.d.ts +0 -2
- package/lib/node/utils/crc.d.ts.map +0 -1
- package/lib/node/utils/crc.js +0 -10
- package/lib/node/utils/crc.js.map +0 -1
- package/lib/node/utils/index.d.ts +0 -2
- package/lib/node/utils/index.d.ts.map +0 -1
- package/lib/node/utils/index.js +0 -18
- package/lib/node/utils/index.js.map +0 -1
- package/src/common/annotation/decorate.ts +0 -1
- package/src/common/annotation/inject.ts +0 -1
- package/src/common/annotation/injectable.ts +0 -1
- package/src/common/annotation/pre-destroy.ts +0 -1
- package/src/common/annotation/target-name.ts +0 -1
- package/src/common/annotation/unmanaged.ts +0 -1
- package/src/common/container/container-factory.ts +0 -9
- package/src/common/el/jexl-engine-provider.ts +0 -18
- package/src/common/provider/provider-creator.ts +0 -12
- package/src/node/utils/crc.ts +0 -7
- 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
|
package/lib/node/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,4CAA0B
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,4CAA0B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celljs/core",
|
|
3
|
-
"version": "4.
|
|
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
|
-
"
|
|
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,
|
|
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 {
|
|
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
|
-
|
|
20
|
-
|
|
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 {
|
|
2
|
-
import {
|
|
3
|
-
import { ComponentId } from '
|
|
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 =
|
|
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?:
|
|
18
|
+
onActivation?: ActivationHandler;
|
|
22
19
|
}
|
|
23
20
|
|
|
24
21
|
export interface ComponentMetadata {
|
|
25
|
-
ids:
|
|
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?:
|
|
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 '
|
|
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
|
-
|
|
12
|
-
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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,
|
|
9
|
+
applyAutowiredDecorator(option, target, targetKey, index, doInjectForAutowiredProvider, doGetValueForProvider);
|
|
10
10
|
};
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
const
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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 {
|
|
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
|
-
|
|
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:
|
|
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
|
-
|
|
15
|
-
|
|
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
|
|
25
|
-
if (
|
|
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
|
|
30
|
-
return
|
|
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
|
-
|
|
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
|
|
12
|
-
|
|
13
|
-
if (container.
|
|
14
|
-
|
|
15
|
-
|
|
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
|
}
|