egg-aop
Advanced tools
Comparing version 0.5.1 to 0.5.2
0.5.2 / 2018-08-09 | ||
================== | ||
* feat: add context to Promise return value for aspect. | ||
* fix: maybe trigger getter when lazyInject read default value. | ||
0.5.1 / 2018-06-26 | ||
@@ -3,0 +9,0 @@ ================== |
export declare type Throwable = Error | any; | ||
export declare const FunctionContextSymbol: unique symbol; | ||
export interface FunctionContext<T = any> { | ||
@@ -3,0 +4,0 @@ readonly inst: T; |
@@ -7,2 +7,3 @@ "use strict"; | ||
} | ||
exports.FunctionContextSymbol = Symbol('FunctionContextSymbol'); | ||
function run(func, context) { | ||
@@ -61,2 +62,7 @@ func && func(context); | ||
} | ||
Object.defineProperty(context.ret, exports.FunctionContextSymbol, { | ||
enumerable: false, | ||
configurable: true, | ||
value: context, | ||
}); | ||
return context.ret; | ||
@@ -63,0 +69,0 @@ } |
@@ -7,3 +7,3 @@ "use strict"; | ||
const appctx_1 = require("./appctx"); | ||
const decorators_1 = require("power-di/lib/helper/decorators"); | ||
const utils_1 = require("power-di/utils"); | ||
/** | ||
@@ -53,3 +53,3 @@ * register component | ||
helper_1.inject({ type })(target, key); | ||
const clsType = decorators_1.getClsTypeByDecorator(type, target, key); | ||
const clsType = utils_1.getClsTypeByDecorator(type, target, key); | ||
let value; | ||
@@ -78,4 +78,5 @@ Object.defineProperty(target, key, { | ||
helper_1.lazyInject({ type })(target, key); | ||
const clsType = decorators_1.getClsTypeByDecorator(type, target, key); | ||
const defaultValue = target[key]; | ||
const clsType = utils_1.getClsTypeByDecorator(type, target, key); | ||
const descriptor = Object.getOwnPropertyDescriptor(target, key); | ||
const defaultValue = descriptor && descriptor.value; | ||
Object.defineProperty(target, key, { | ||
@@ -82,0 +83,0 @@ configurable: true, |
@@ -32,4 +32,3 @@ "use strict"; | ||
let ioc = undefined; | ||
const useCtxProxyForAppComponent = app.config.aop.useCtxProxyForAppComponent; | ||
const autoRegisterToCtx = app.config.aop.autoRegisterToCtx; | ||
const { useCtxProxyForAppComponent, autoRegisterToCtx } = app.config.aop; | ||
if (autoRegisterToCtx && !typeLoader_1.typeLoader.has(clsType)) { | ||
@@ -36,0 +35,0 @@ typeLoader_1.register(clsType, clsType, clsType[exports.contextTypeSymbol] || 'Context'); |
{ | ||
"name": "egg-aop", | ||
"version": "0.5.1", | ||
"version": "0.5.2", | ||
"description": "aop for egg.", | ||
@@ -9,7 +9,7 @@ "main": "lib/index.js", | ||
"app/**/*.js", | ||
"app/**/*.ts", | ||
"app/**/*.d.ts", | ||
"config/**/*.js", | ||
"config/**/*.ts", | ||
"config/**/*.d.ts", | ||
"lib/**/*.js", | ||
"lib/**/*.ts" | ||
"lib/**/*.d.ts" | ||
], | ||
@@ -23,3 +23,3 @@ "eggPlugin": { | ||
"dependencies": { | ||
"power-di": "^1.4.11", | ||
"power-di": "^1.4.16", | ||
"tslib": "^1.9.0" | ||
@@ -55,3 +55,4 @@ }, | ||
"ts": "rimraf app/**/*.js lib/**/*.js && tsc", | ||
"prepublish": "npm run ts" | ||
"prepublish": "npm run ts", | ||
"postpublish": "node scripts/published.js" | ||
}, | ||
@@ -58,0 +59,0 @@ "ci": { |
22676
22
480
Updatedpower-di@^1.4.16