@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
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { describe, it, afterAll } from 'bun:test';
|
|
2
|
+
import { expect } from 'chai';
|
|
3
|
+
import { ApplicationFactory } from '../application/application-factory';
|
|
4
|
+
import { Component, Value } from '../annotation';
|
|
5
|
+
import { ContainerUtil } from '../container/container-util';
|
|
6
|
+
import { ConfigUtil } from '../config/config-util';
|
|
7
|
+
import { ExpressionHandler } from './expression-protocol';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @Value、ConfigUtil 与 EL(${...},ExpressionEngine)的约定(阶段 1.E 行为测试)。
|
|
11
|
+
* 配置就是 ApplicationFactory.create() 的第一个参数(CLI 生成的入口会把合并后的 cell.yml 传进来)。
|
|
12
|
+
*/
|
|
13
|
+
const boot = (props: Record<string, any>) => ApplicationFactory.create(props);
|
|
14
|
+
const el = () => ContainerUtil.get<ExpressionHandler>(ExpressionHandler);
|
|
15
|
+
|
|
16
|
+
describe('core @Value 与配置', () => {
|
|
17
|
+
|
|
18
|
+
it('@Value(key) 读配置;@Value() 不带参数时以属性名为 key', async () => {
|
|
19
|
+
@Component()
|
|
20
|
+
class Settings {
|
|
21
|
+
@Value('cell.name')
|
|
22
|
+
readonly name: string;
|
|
23
|
+
@Value()
|
|
24
|
+
readonly port: number;
|
|
25
|
+
}
|
|
26
|
+
await boot({ cell: { name: 'demo' }, port: 8080 });
|
|
27
|
+
const s = ContainerUtil.get(Settings);
|
|
28
|
+
expect(s.name).to.equal('demo');
|
|
29
|
+
expect(s.port).to.equal(8080);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('值里的 ${...} 会求值,可以引用其他配置,多层引用也会继续求值', async () => {
|
|
33
|
+
@Component()
|
|
34
|
+
class Urls {
|
|
35
|
+
@Value('cell.url')
|
|
36
|
+
readonly url: string;
|
|
37
|
+
@Value('cell.chain')
|
|
38
|
+
readonly chain: string;
|
|
39
|
+
}
|
|
40
|
+
await boot({ cell: { host: 'example.com', url: 'https://${cell.host}:443/api', chain: '${cell.url}', } });
|
|
41
|
+
const u = ContainerUtil.get(Urls);
|
|
42
|
+
expect(u.url).to.equal('https://example.com:443/api');
|
|
43
|
+
expect(u.chain).to.equal('https://example.com:443/api');
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('取对象时,对象里的字符串也会求值;取不到的 key 为 undefined', async () => {
|
|
47
|
+
@Component()
|
|
48
|
+
class Db {
|
|
49
|
+
@Value('cell.db')
|
|
50
|
+
readonly db: { host: string, port: number, hosts: string[] };
|
|
51
|
+
@Value('cell.missing.deep')
|
|
52
|
+
readonly missing?: unknown;
|
|
53
|
+
}
|
|
54
|
+
await boot({ cell: { region: 'eu', db: { host: 'db.${cell.region}.local', port: 5432, hosts: ['a.${cell.region}', 'b'] } } });
|
|
55
|
+
const d = ContainerUtil.get(Db);
|
|
56
|
+
expect(d.db).to.deep.equal({ host: 'db.eu.local', port: 5432, hosts: ['a.eu', 'b'] });
|
|
57
|
+
expect(d.missing).to.equal(undefined);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('构造器参数也能用 @Value', async () => {
|
|
61
|
+
@Component()
|
|
62
|
+
class WithCtor {
|
|
63
|
+
constructor(@Value('cell.size') readonly size: number) { }
|
|
64
|
+
}
|
|
65
|
+
await boot({ cell: { size: 3 } });
|
|
66
|
+
expect(ContainerUtil.get(WithCtor).size).to.equal(3);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('detached 的 @Value:不在容器里的对象每次读取都取当前容器的配置', async () => {
|
|
70
|
+
class Plain {
|
|
71
|
+
@Value({ el: 'cell.mode', detached: true })
|
|
72
|
+
readonly mode: string;
|
|
73
|
+
}
|
|
74
|
+
const p = new Plain();
|
|
75
|
+
await boot({ cell: { mode: 'a' } });
|
|
76
|
+
expect(p.mode).to.equal('a');
|
|
77
|
+
await boot({ cell: { mode: 'b' } });
|
|
78
|
+
expect(p.mode).to.equal('b');
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('ConfigUtil.get:取值、默认值', async () => {
|
|
82
|
+
await boot({ cell: { a: 1, ref: '${cell.a}' } });
|
|
83
|
+
expect(ConfigUtil.get('cell.a')).to.equal(1);
|
|
84
|
+
expect(ConfigUtil.get('cell.ref')).to.equal(1);
|
|
85
|
+
expect(ConfigUtil.get('cell.none', 'dflt')).to.equal('dflt');
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('现状:create() 过程中第一次求值就会就地改写传入的配置对象,getRaw() 拿到的也是求值后的结果', async () => {
|
|
89
|
+
// expression-handler.ts getContext():第一次拿到上下文时 this.handle(c, c),把整份配置原地求值;
|
|
90
|
+
// 创建 Application 时注入的组件(如 Logger)读配置,这一步在 create() 返回前就发生了
|
|
91
|
+
const props = { cell: { a: 1, ref: '${cell.a}' as unknown, nested: ['${cell.a}'] as unknown[] } };
|
|
92
|
+
await boot(props);
|
|
93
|
+
expect(ConfigUtil.getRaw()).to.equal(props);
|
|
94
|
+
expect(props.cell.ref).to.equal(1);
|
|
95
|
+
expect(props.cell.nested[0]).to.equal(1);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('false、0、空串都是有效的值:@Value 拿得到,ConfigUtil.get 只在值为 undefined 时用默认值(F3)', async () => {
|
|
99
|
+
@Component()
|
|
100
|
+
class Flags {
|
|
101
|
+
@Value('cell.enabled')
|
|
102
|
+
readonly enabled: boolean;
|
|
103
|
+
@Value('cell.retries')
|
|
104
|
+
readonly retries: number;
|
|
105
|
+
@Value('cell.prefix')
|
|
106
|
+
readonly prefix: string;
|
|
107
|
+
}
|
|
108
|
+
await boot({ cell: { enabled: false, retries: 0, prefix: '' } });
|
|
109
|
+
const f = ContainerUtil.get(Flags);
|
|
110
|
+
expect(f.enabled).to.equal(false);
|
|
111
|
+
expect(f.retries).to.equal(0);
|
|
112
|
+
expect(f.prefix).to.equal('');
|
|
113
|
+
expect(ConfigUtil.get('cell.retries', 3)).to.equal(0);
|
|
114
|
+
expect(ConfigUtil.get('cell.enabled', true)).to.equal(false);
|
|
115
|
+
expect(ConfigUtil.get('cell.missing', 3)).to.equal(3);
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
describe('core EL(ExpressionHandler)', () => {
|
|
120
|
+
const ENV_KEY = 'CELL_T13_EL_PROBE';
|
|
121
|
+
afterAll(() => {
|
|
122
|
+
delete process.env[ENV_KEY];
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it('没有 ${ 的文本原样返回;只有一个表达式时保留类型,混排时拼成字符串', async () => {
|
|
126
|
+
await boot({ cell: { n: 2 } });
|
|
127
|
+
expect(el().handle('plain text')).to.equal('plain text');
|
|
128
|
+
expect(el().handle('${cell.n + 1}')).to.equal(3);
|
|
129
|
+
expect(el().handle('${cell.n > 1}')).to.equal(true);
|
|
130
|
+
expect(el().handle('n=${cell.n}, n2=${cell.n * cell.n}')).to.equal('n=2, n2=4');
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it('表达式的运算、三元、字符串里的 } 都能正确切分', async () => {
|
|
134
|
+
await boot({ cell: { port: 3000, name: 'x' } });
|
|
135
|
+
expect(el().handle('${cell.port > 1000 ? "high" : "low"}')).to.equal('high');
|
|
136
|
+
expect(el().handle('${"a}b" + cell.name}')).to.equal('a}bx');
|
|
137
|
+
expect(el().handle('[${cell.name}]')).to.equal('[x]');
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it('现状:反斜杠转义只阻止求值,反斜杠本身留在结果里', async () => {
|
|
141
|
+
await boot({ cell: { name: 'x' } });
|
|
142
|
+
expect(el().handle('cost \\${cell.name}')).to.equal('cost \\${cell.name}');
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it.todo('期望:\\${...} 得到字面量 ${...}(去掉转义符),否则配置里无法写出 ${', () => { });
|
|
146
|
+
|
|
147
|
+
it('内置 transform:replace、regexp、eval', async () => {
|
|
148
|
+
await boot({ cell: { name: 'svc', tpl: '${cell.name}-v1' } });
|
|
149
|
+
expect(el().handle('${"a-b-c"|replace("-", "_")}')).to.equal('a_b_c');
|
|
150
|
+
const re = el().handle('${"^ab+$"|regexp("i")}');
|
|
151
|
+
expect(re).to.be.instanceOf(RegExp);
|
|
152
|
+
expect(re.test('ABBB')).to.equal(true);
|
|
153
|
+
expect(el().handle('${"${cell.name}"|eval}')).to.equal('svc');
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
it('可以传入自己的上下文;未定义的变量为 undefined', async () => {
|
|
157
|
+
await boot({});
|
|
158
|
+
expect(el().handle('${a.b * 2}', { a: { b: 21 } })).to.equal(42);
|
|
159
|
+
expect(el().handle('${nothing.here}', {})).to.equal(undefined);
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
it('处理对象时就地求值;带 _ignoreEl 的子对象不求值', async () => {
|
|
163
|
+
await boot({ cell: { v: 'ok' } });
|
|
164
|
+
const obj = { a: '${cell.v}', nested: { b: ['${cell.v}!'] }, raw: { _ignoreEl: true, c: '${cell.v}' } };
|
|
165
|
+
const out = el().handle(obj);
|
|
166
|
+
expect(out).to.equal(obj);
|
|
167
|
+
expect(obj.a).to.equal('ok');
|
|
168
|
+
expect(obj.nested.b[0]).to.equal('ok!');
|
|
169
|
+
expect(obj.raw.c).to.equal('${cell.v}');
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it('env 是进程环境变量(遍历整份配置时 env 子树带 _ignoreEl,不会被就地求值)', async () => {
|
|
173
|
+
process.env[ENV_KEY] = 'plain-value';
|
|
174
|
+
await boot({ cell: {} });
|
|
175
|
+
expect(el().handle(`\${env.${ENV_KEY}}`)).to.equal('plain-value');
|
|
176
|
+
expect(ConfigUtil.getRaw().env?.[ENV_KEY]).to.equal('plain-value');
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
it('来自 env 的字符串不再求值,经配置间接引用时也一样(F6)', async () => {
|
|
180
|
+
process.env[ENV_KEY] = '${cell.other}';
|
|
181
|
+
await boot({ cell: { other: 'from-config', viaEnv: `\${env.${ENV_KEY}}`, viaKey: '${cell.viaEnv}' } });
|
|
182
|
+
expect(el().handle(`\${env.${ENV_KEY}}`)).to.equal('${cell.other}');
|
|
183
|
+
expect(el().handle('${cell.viaEnv}')).to.equal('${cell.other}');
|
|
184
|
+
expect(el().handle('${cell.viaKey}')).to.equal('${cell.other}');
|
|
185
|
+
});
|
|
186
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Autowired, Optional, Value } from '../annotation';
|
|
2
|
-
import { Logger, LOGGER_LEVEL, LogLevel, onLogEmitter, TraceIdProvider } from './logger-protocol';
|
|
2
|
+
import { Logger, LOGGER_LEVEL, LOG_LEVELS, LogLevel, onLogEmitter, TraceIdProvider } from './logger-protocol';
|
|
3
3
|
|
|
4
4
|
export abstract class AbstractLogger implements Logger {
|
|
5
5
|
protected instance: Logger;
|
|
@@ -24,18 +24,24 @@ export abstract class AbstractLogger implements Logger {
|
|
|
24
24
|
return context ? `[${context}] ` : '';
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
isEnabled(level: LogLevel): boolean {
|
|
28
|
+
const configured = LOG_LEVELS.indexOf(this.level);
|
|
29
|
+
return LOG_LEVELS.indexOf(level) >= (configured < 0 ? LOG_LEVELS.indexOf('info') : configured);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** `level` is the level of the message, not the configured one. */
|
|
33
|
+
protected resolvePrefix(level: LogLevel): string {
|
|
28
34
|
const time = new Date().toISOString();
|
|
29
|
-
return `${time} [${
|
|
35
|
+
return `${time} [${level}]`;
|
|
30
36
|
}
|
|
31
37
|
|
|
32
|
-
protected log(message: any, context?: string, logFn: (...args: any[]) => void = console.info): void {
|
|
38
|
+
protected log(message: any, context?: string, logFn: (...args: any[]) => void = console.info, level: LogLevel = 'info'): void {
|
|
33
39
|
const traceId = this.traceIdProvider?.provide();
|
|
34
40
|
const traceStr = traceId ? ` [trace: ${traceId}]` : '';
|
|
35
41
|
const contextStr = this.resolveContextString(context);
|
|
36
|
-
logFn(`${this.resolvePrefix()}${traceStr}${contextStr}${message}`);
|
|
42
|
+
logFn(`${this.resolvePrefix(level)}${traceStr}${contextStr}${message}`);
|
|
37
43
|
onLogEmitter.fire({
|
|
38
|
-
level
|
|
44
|
+
level,
|
|
39
45
|
traceId,
|
|
40
46
|
rootContext: this.context,
|
|
41
47
|
context,
|
|
@@ -7,6 +7,9 @@ export const TraceIdProvider = Symbol('TraceIdProvider');
|
|
|
7
7
|
export const LoggerService = Symbol('LoggerService');
|
|
8
8
|
|
|
9
9
|
export type LogLevel = 'verbose' | 'debug' | 'info' | 'warn' | 'error';
|
|
10
|
+
|
|
11
|
+
/** Levels from the most to the least verbose: a logger at a level writes that level and the ones after it. */
|
|
12
|
+
export const LOG_LEVELS: readonly LogLevel[] = ['verbose', 'debug', 'info', 'warn', 'error'];
|
|
10
13
|
export interface LogMessage {
|
|
11
14
|
level: LogLevel;
|
|
12
15
|
traceId?: string;
|
|
@@ -25,6 +28,8 @@ export interface Logger {
|
|
|
25
28
|
error(message: any, context?: string): void;
|
|
26
29
|
warn(message: any, context?: string): void;
|
|
27
30
|
debug(message: any, context?: string): void;
|
|
31
|
+
/** Whether messages of `level` are written; check it before building an expensive message. */
|
|
32
|
+
isEnabled(level: LogLevel): boolean;
|
|
28
33
|
time(label: string): void;
|
|
29
34
|
timeEnd(label: string, context?: string): number | undefined;
|
|
30
35
|
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { afterEach, describe, it } from 'bun:test';
|
|
2
|
+
import { expect } from 'chai';
|
|
3
|
+
import { LoggerImpl } from './logger';
|
|
4
|
+
import { LogLevel, LogMessage, onLogEmitter } from './logger-protocol';
|
|
5
|
+
|
|
6
|
+
const consoleFns = ['info', 'warn', 'error', 'debug'] as const;
|
|
7
|
+
const originals = Object.fromEntries(consoleFns.map(name => [name, console[name]]));
|
|
8
|
+
|
|
9
|
+
function capture(level: LogLevel) {
|
|
10
|
+
const lines: { fn: string; text: string }[] = [];
|
|
11
|
+
for (const name of consoleFns) {
|
|
12
|
+
console[name] = (text: string) => lines.push({ fn: name, text });
|
|
13
|
+
}
|
|
14
|
+
const logger = new LoggerImpl();
|
|
15
|
+
Object.assign(logger, { level });
|
|
16
|
+
return { logger, lines };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
afterEach(() => Object.assign(console, originals));
|
|
20
|
+
|
|
21
|
+
describe('LoggerImpl', () => {
|
|
22
|
+
it('labels each line with the level of the message, not the configured one', () => {
|
|
23
|
+
const { logger, lines } = capture('debug');
|
|
24
|
+
logger.debug('d');
|
|
25
|
+
logger.info('i');
|
|
26
|
+
logger.warn('w');
|
|
27
|
+
logger.error('e');
|
|
28
|
+
expect(lines.map(l => [l.fn, /\[(\w+)\]/.exec(l.text)?.[1], l.text.slice(-1)])).to.deep.equal([
|
|
29
|
+
['debug', 'debug', 'd'],
|
|
30
|
+
['info', 'info', 'i'],
|
|
31
|
+
['warn', 'warn', 'w'],
|
|
32
|
+
['error', 'error', 'e'],
|
|
33
|
+
]);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('writes the configured level and the ones after it', () => {
|
|
37
|
+
const { logger, lines } = capture('warn');
|
|
38
|
+
logger.debug('d');
|
|
39
|
+
logger.info('i');
|
|
40
|
+
logger.warn('w');
|
|
41
|
+
logger.error('e');
|
|
42
|
+
expect(lines.map(l => l.fn)).to.deep.equal(['warn', 'error']);
|
|
43
|
+
expect([logger.isEnabled('verbose'), logger.isEnabled('debug'), logger.isEnabled('info'), logger.isEnabled('warn'), logger.isEnabled('error')])
|
|
44
|
+
.to.deep.equal([false, false, false, true, true]);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('treats an unknown configured level as info', () => {
|
|
48
|
+
const { logger } = capture('loud' as LogLevel);
|
|
49
|
+
expect(logger.isEnabled('debug')).to.equal(false);
|
|
50
|
+
expect(logger.isEnabled('info')).to.equal(true);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('reports the level of the message to onLog', () => {
|
|
54
|
+
const { logger } = capture('info');
|
|
55
|
+
const seen: LogMessage[] = [];
|
|
56
|
+
const listener = onLogEmitter.event(m => seen.push(m));
|
|
57
|
+
logger.warn('w');
|
|
58
|
+
listener.dispose();
|
|
59
|
+
expect(seen.map(m => [m.level, m.message])).to.deep.equal([['warn', 'w']]);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -7,24 +7,24 @@ import { Logger } from './logger-protocol';
|
|
|
7
7
|
export class LoggerImpl extends AbstractLogger {
|
|
8
8
|
|
|
9
9
|
error(message: any, context?: string): void {
|
|
10
|
-
this.log(message, context, console.error.bind(console));
|
|
10
|
+
this.log(message, context, console.error.bind(console), 'error');
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
info(message: any, context?: string): void {
|
|
14
|
-
if (
|
|
15
|
-
this.log(message, context);
|
|
14
|
+
if (this.isEnabled('info')) {
|
|
15
|
+
this.log(message, context, console.info.bind(console), 'info');
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
warn(message: any, context?: string): void {
|
|
20
|
-
if (
|
|
21
|
-
this.log(message, context, console.warn.bind(console));
|
|
20
|
+
if (this.isEnabled('warn')) {
|
|
21
|
+
this.log(message, context, console.warn.bind(console), 'warn');
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
debug(message: any, context?: string): void {
|
|
26
|
-
if (this.
|
|
27
|
-
this.log(message, context, console.debug.bind(console));
|
|
26
|
+
if (this.isEnabled('debug')) {
|
|
27
|
+
this.log(message, context, console.debug.bind(console), 'debug');
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
import { ComponentId } from '../
|
|
2
|
-
import { Container } from '../container';
|
|
1
|
+
import type { ComponentId } from '../container/container';
|
|
3
2
|
import { Prioritizeable } from '../utils/prioritizeable';
|
|
4
3
|
|
|
5
|
-
export const ProviderCreator = Symbol('ProviderCreator');
|
|
6
4
|
export const ComponentFilter = Symbol('ComponentFilter');
|
|
7
5
|
export const ComponentFilterRegistry = Symbol('ComponentFilterRegistry');
|
|
8
6
|
export const ComponentFilterContribution = Symbol('ComponentFilterContribution');
|
|
9
7
|
|
|
8
|
+
/** The components of an identifier, created when first asked for; what `@AutowiredProvider` injects. */
|
|
10
9
|
export interface Provider<T extends object> {
|
|
11
|
-
get(
|
|
12
|
-
sortSync(getPriority?: Prioritizeable.GetPrioritySync<T
|
|
13
|
-
sort(getPriority?: Prioritizeable.GetPriority<T>
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface ProviderCreator<T extends object> {
|
|
17
|
-
create(id: ComponentId, container: Container): Provider<T>;
|
|
10
|
+
get(): T[];
|
|
11
|
+
sortSync(getPriority?: Prioritizeable.GetPrioritySync<T>): T[];
|
|
12
|
+
sort(getPriority?: Prioritizeable.GetPriority<T>): Promise<T[]>;
|
|
18
13
|
}
|
|
19
14
|
|
|
20
15
|
/**
|
|
@@ -23,7 +18,6 @@ export interface ProviderCreator<T extends object> {
|
|
|
23
18
|
*/
|
|
24
19
|
export type ComponentFilter<T extends Object> = (toTest: T) => boolean;
|
|
25
20
|
|
|
26
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
21
|
export type ComponentType = ComponentId;
|
|
28
22
|
|
|
29
23
|
export interface ComponentFilterRegistry {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { PROVIDER, ID_KEY } from '../annotation/autowired-provider';
|
|
2
|
-
import { ComponentId } from '../
|
|
3
|
-
import { ContainerUtil } from '../container';
|
|
2
|
+
import type { ComponentId } from '../container/container';
|
|
3
|
+
import { ContainerUtil } from '../container/container-util';
|
|
4
4
|
import { Provider } from './provider-protocol';
|
|
5
5
|
|
|
6
6
|
export namespace ProviderUtil {
|
|
7
7
|
export function get<T extends Object>(componentId: ComponentId<T>): Provider<T> {
|
|
8
|
-
return ContainerUtil.
|
|
8
|
+
return ContainerUtil.get(PROVIDER, { tags: { [ID_KEY]: componentId } });
|
|
9
9
|
}
|
|
10
10
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ComponentId } from '../
|
|
1
|
+
import type { Binding, ComponentId, Container } from '../container/container';
|
|
2
2
|
import { Provider, ComponentFilterRegistry } from './provider-protocol';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { Prioritizeable } from '../utils/prioritizeable';
|
|
4
|
+
import { ID_KEY, PROVIDER } from '../annotation/autowired-provider';
|
|
5
5
|
|
|
6
6
|
const DEFAULT_GET_PRIORITY: Prioritizeable.GetPrioritySync<any> = value => {
|
|
7
7
|
if (value) {
|
|
@@ -23,41 +23,29 @@ export class ContainerBasedProvider<T extends object> implements Provider<T> {
|
|
|
23
23
|
protected readonly container: Container
|
|
24
24
|
) { }
|
|
25
25
|
|
|
26
|
-
get(
|
|
26
|
+
get(): T[] {
|
|
27
27
|
if (this.components === undefined) {
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
while (currentContainer !== null) {
|
|
33
|
-
if (currentContainer.isBound(this.componentId)) {
|
|
34
|
-
try {
|
|
35
|
-
currentComponents.push(...currentContainer.getAll(this.componentId));
|
|
36
|
-
} catch (error) {
|
|
37
|
-
console.error(error);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
if (filterRegistry === undefined && currentContainer.isBound(ComponentFilterRegistry)) {
|
|
41
|
-
filterRegistry = currentContainer.get(ComponentFilterRegistry);
|
|
42
|
-
}
|
|
43
|
-
// eslint-disable-next-line no-null/no-null
|
|
44
|
-
currentContainer = recursive === true ? currentContainer.parent : null;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
this.components = filterRegistry ? filterRegistry.applyFilters(currentComponents, this.componentId) : currentComponents;
|
|
48
|
-
|
|
28
|
+
const components = this.container.isBound(this.componentId) ? this.container.getAll<T>(this.componentId) : [];
|
|
29
|
+
const filterRegistry = this.container.isBound(ComponentFilterRegistry)
|
|
30
|
+
? this.container.get<ComponentFilterRegistry>(ComponentFilterRegistry) : undefined;
|
|
31
|
+
this.components = filterRegistry ? filterRegistry.applyFilters(components, this.componentId) : components;
|
|
49
32
|
}
|
|
50
33
|
return this.components;
|
|
51
34
|
}
|
|
52
35
|
|
|
53
|
-
sortSync(getPriority: Prioritizeable.GetPrioritySync<T> = DEFAULT_GET_PRIORITY
|
|
54
|
-
this.components = Prioritizeable.prioritizeAllSync<T>(this.get(
|
|
36
|
+
sortSync(getPriority: Prioritizeable.GetPrioritySync<T> = DEFAULT_GET_PRIORITY): T[] {
|
|
37
|
+
this.components = Prioritizeable.prioritizeAllSync<T>(this.get(), getPriority).map(c => c.value);
|
|
55
38
|
return this.components;
|
|
56
39
|
}
|
|
57
40
|
|
|
58
|
-
async sort(getPriority: Prioritizeable.GetPriority<T> = DEFAULT_GET_PRIORITY
|
|
59
|
-
const result = await Prioritizeable.prioritizeAll<T>(this.get(
|
|
41
|
+
async sort(getPriority: Prioritizeable.GetPriority<T> = DEFAULT_GET_PRIORITY): Promise<T[]> {
|
|
42
|
+
const result = await Prioritizeable.prioritizeAll<T>(this.get(), getPriority);
|
|
60
43
|
this.components = result.map<T>(c => c.value);
|
|
61
44
|
return this.components;
|
|
62
45
|
}
|
|
63
46
|
}
|
|
47
|
+
|
|
48
|
+
/** `@AutowiredProvider(id)` is an injection of `PROVIDER` tagged with the id: a provider of its components. */
|
|
49
|
+
export function bindAutowiredProvider(bind: <B>(id: ComponentId<B>) => Binding<B>): void {
|
|
50
|
+
bind(PROVIDER).toDynamicValue(ctx => new ContainerBasedProvider(ctx.target.tags![ID_KEY] as ComponentId<object>, ctx.container));
|
|
51
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import './index';
|
|
2
2
|
import { bindValue } from './annotation/value';
|
|
3
|
-
import { bindAutowiredProvider } from './
|
|
3
|
+
import { bindAutowiredProvider } from './provider/provider';
|
|
4
4
|
import { autoBind } from './container/auto-bind';
|
|
5
5
|
|
|
6
6
|
export default autoBind(bind => {
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { Injectable } from '../annotation';
|
|
2
1
|
import { Logger, LogLevel, LogMessage } from '../logger/logger-protocol';
|
|
3
2
|
import { Emitter } from '../utils';
|
|
4
3
|
|
|
5
|
-
@Injectable()
|
|
6
4
|
export class MockLogger implements Logger {
|
|
7
5
|
level: LogLevel = 'info';
|
|
8
6
|
protected readonly onLogEmitter = new Emitter<LogMessage>();
|
|
@@ -28,4 +26,7 @@ export class MockLogger implements Logger {
|
|
|
28
26
|
debug(message: any, context?: string): void {
|
|
29
27
|
// do nothing
|
|
30
28
|
}
|
|
29
|
+
isEnabled(level: LogLevel): boolean {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
31
32
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { bindAutowiredProvider } from '../annotation/autowired-provider';
|
|
2
1
|
import { bindValue } from '../annotation/value';
|
|
2
|
+
import { bindAutowiredProvider } from '../provider/provider';
|
|
3
3
|
import { autoBind } from '../container';
|
|
4
4
|
import { Logger } from '../logger';
|
|
5
5
|
import { MockLogger } from './mock-logger';
|
|
@@ -12,10 +12,10 @@ export namespace AnnotationUtil {
|
|
|
12
12
|
|
|
13
13
|
export function getType(target: any, targetKey: string | symbol, index?: number) {
|
|
14
14
|
if (index !== undefined) {
|
|
15
|
-
return Reflect.getMetadata('design:paramtypes', target, targetKey)[index];
|
|
15
|
+
return Reflect.getMetadata('design:paramtypes', target, targetKey)?.[index];
|
|
16
16
|
} else {
|
|
17
17
|
return Reflect.getMetadata('design:type', target, targetKey);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
}
|
|
21
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Event,
|
|
1
|
+
import { Event, CallbackList } from './event';
|
|
2
2
|
import { Disposable } from './disposable';
|
|
3
3
|
import { MaybePromise } from './prioritizeable';
|
|
4
4
|
|
|
@@ -204,65 +204,3 @@ export namespace WaitUntilEvent {
|
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
|
-
|
|
208
|
-
import { CancellationToken } from './cancellation';
|
|
209
|
-
|
|
210
|
-
export class AsyncEmitter<T extends WaitUntilEvent> extends Emitter<T> {
|
|
211
|
-
|
|
212
|
-
protected deliveryQueue: Promise<void> | undefined;
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Fire listeners async one after another.
|
|
216
|
-
*/
|
|
217
|
-
override fire(event: Omit<T, 'waitUntil'>, token: CancellationToken = CancellationToken.None,
|
|
218
|
-
promiseJoin?: (p: Promise<any>, listener: Function) => Promise<any>): Promise<void> {
|
|
219
|
-
const callbacks = this._callbacks;
|
|
220
|
-
if (!callbacks) {
|
|
221
|
-
return Promise.resolve();
|
|
222
|
-
}
|
|
223
|
-
const listeners = [...callbacks];
|
|
224
|
-
if (this.deliveryQueue) {
|
|
225
|
-
return this.deliveryQueue = this.deliveryQueue.then(() => this.deliver(listeners, event, token, promiseJoin));
|
|
226
|
-
}
|
|
227
|
-
return this.deliveryQueue = this.deliver(listeners, event, token, promiseJoin);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
protected async deliver(listeners: Callback[], event: Omit<T, 'waitUntil'>, token: CancellationToken,
|
|
231
|
-
promiseJoin?: (p: Promise<any>, listener: Function) => Promise<any>): Promise<void> {
|
|
232
|
-
for (const listener of listeners) {
|
|
233
|
-
if (token.isCancellationRequested) {
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
236
|
-
const waitables: Promise<void>[] = [];
|
|
237
|
-
const asyncEvent = Object.assign(event, {
|
|
238
|
-
waitUntil: (thenable: Promise<any>) => {
|
|
239
|
-
if (Object.isFrozen(waitables)) {
|
|
240
|
-
throw new Error('waitUntil cannot be called asynchronously.');
|
|
241
|
-
}
|
|
242
|
-
if (promiseJoin) {
|
|
243
|
-
thenable = promiseJoin(thenable, listener);
|
|
244
|
-
}
|
|
245
|
-
waitables.push(thenable);
|
|
246
|
-
}
|
|
247
|
-
}) as T;
|
|
248
|
-
try {
|
|
249
|
-
listener(event);
|
|
250
|
-
// Asynchronous calls to `waitUntil` should fail.
|
|
251
|
-
Object.freeze(waitables);
|
|
252
|
-
} catch (e) {
|
|
253
|
-
console.error(e);
|
|
254
|
-
} finally {
|
|
255
|
-
delete (asyncEvent as any)['waitUntil'];
|
|
256
|
-
}
|
|
257
|
-
if (!waitables.length) {
|
|
258
|
-
return;
|
|
259
|
-
}
|
|
260
|
-
try {
|
|
261
|
-
await Promise.all(waitables);
|
|
262
|
-
} catch (e) {
|
|
263
|
-
console.error(e);
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
}
|
|
@@ -110,7 +110,7 @@ export abstract class MimeTypeUtils {
|
|
|
110
110
|
if (!mimeTypes) {
|
|
111
111
|
return [];
|
|
112
112
|
}
|
|
113
|
-
return this.tokenize(mimeTypes).filter(mimeType => !!mimeType).map(this.parseMimeType);
|
|
113
|
+
return this.tokenize(mimeTypes).filter(mimeType => !!mimeType).map(mimeType => this.parseMimeType(mimeType));
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
static tokenize(mimeTypes: string): string[] {
|
|
@@ -57,7 +57,7 @@ export class MimeType {
|
|
|
57
57
|
this.subtype = subtype.toLowerCase();
|
|
58
58
|
if (parameters) {
|
|
59
59
|
const map: Map<string, string> = new Map();
|
|
60
|
-
for (const [key, value] of
|
|
60
|
+
for (const [key, value] of parameters.entries()) {
|
|
61
61
|
this.checkParameters(key, value);
|
|
62
62
|
map.set(key.toLowerCase(), value);
|
|
63
63
|
}
|
|
@@ -1,36 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
/** What a proxy of a component (AOP) answers with the object it wraps. */
|
|
2
|
+
export const PROXY_TARGET = Symbol.for('@celljs/core/proxy-target');
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
/** The object behind a component proxy, or the object itself. */
|
|
5
|
+
export function getTarget(obj: any): any {
|
|
6
|
+
return obj?.[PROXY_TARGET] ?? obj;
|
|
5
7
|
}
|
|
6
8
|
|
|
9
|
+
/** The class of the object behind a component proxy, or of the object itself. */
|
|
7
10
|
export function getTargetClass(obj: any): any {
|
|
8
|
-
|
|
9
|
-
resolveMode = true;
|
|
10
|
-
const target = obj.target;
|
|
11
|
-
return target ? target.constructor : obj.constructor;
|
|
12
|
-
|
|
13
|
-
} finally {
|
|
14
|
-
resolveMode = false;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function getTarget(obj: any): any {
|
|
19
|
-
try {
|
|
20
|
-
resolveMode = true;
|
|
21
|
-
const target = obj.target;
|
|
22
|
-
return target || obj;
|
|
23
|
-
|
|
24
|
-
} finally {
|
|
25
|
-
resolveMode = false;
|
|
26
|
-
}
|
|
11
|
+
return getTarget(obj)?.constructor;
|
|
27
12
|
}
|
|
28
13
|
|
|
29
14
|
export function isProxy(obj: any): boolean {
|
|
30
|
-
|
|
31
|
-
resolveMode = true;
|
|
32
|
-
return !!obj.target;
|
|
33
|
-
} finally {
|
|
34
|
-
resolveMode = false;
|
|
35
|
-
}
|
|
15
|
+
return obj?.[PROXY_TARGET] !== undefined;
|
|
36
16
|
}
|