From b7f366be762df482dbeb39fe06643170c86fbc22 Mon Sep 17 00:00:00 2001 From: crusader Date: Mon, 1 Jan 2018 21:42:46 +0900 Subject: [PATCH] ing --- .../commons/application/application.ts | 7 +- .../application/decorators/configuration.ts | 17 ++-- .../application/decorators/instance.ts | 16 ++-- .../commons/application/decorators/runner.ts | 11 ++- .../application/decorators/web_application.ts | 8 +- .../commons/core/reflect/accessible_object.ts | 4 +- .../commons/core/reflect/annotation.ts | 33 ++++--- .../commons/core/reflect/decorator.ts | 90 +++++++++++-------- src/ts/@overflow/commons/core/type/error.ts | 6 ++ src/ts/@overflow/commons/core/type/index.ts | 1 + .../@overflow/commons/di/decorators/inject.ts | 21 +++-- .../commons/di/decorators/injectable.ts | 18 ++-- .../commons/di/decorators/post_construct.ts | 16 ++-- .../commons/di/decorators/pre_destroy.ts | 16 ++-- .../commons/di/decorators/resource.ts | 20 ++--- .../@overflow/commons/di/decorators/value.ts | 18 ++-- .../redux/decorators/action_mapping.ts | 18 ++-- .../commons/redux/decorators/reducer.ts | 16 ++-- .../commons/redux/decorators/rest_api.ts | 13 +-- .../commons/redux/decorators/rpc_api.ts | 13 +-- src/ts/@overflow/webapp/index.tsx | 19 +++- .../webapp/redux/webapp_dispatch_reducer.ts | 2 +- 22 files changed, 214 insertions(+), 169 deletions(-) create mode 100644 src/ts/@overflow/commons/core/type/error.ts diff --git a/src/ts/@overflow/commons/application/application.ts b/src/ts/@overflow/commons/application/application.ts index fdd98be..1152919 100644 --- a/src/ts/@overflow/commons/application/application.ts +++ b/src/ts/@overflow/commons/application/application.ts @@ -2,7 +2,9 @@ import { Class, Method, } from '@overflow/commons/core/reflect'; -import { ClassType, PropertyKeyType } from '@overflow/commons/core/type'; +import { + ClassType, PropertyKeyType, TypeUtil, +} from '@overflow/commons/core/type'; import { ApplicationContext } from './context'; import { ConfigurationAnnotation, @@ -65,11 +67,12 @@ export class Application { private createContext(): ApplicationContext { let clazz: Class = Class.forClassType(this._primaryClass); + let ans = TypeUtil.ancestorsOf(this._primaryClass); + let wa: WebApplicationAnnotation = clazz.getOwnAnnotation(WebApplicationAnnotation); if (undefined === wa) { throw new Error(`Class is not WebApplication type. add @WebApplication annotation to class[${this._primaryClass.name}]`); } - this._applicationContext = new ApplicationContext(wa.attributes.injectables); this.registerJSONSources(wa.attributes.jsonSources); diff --git a/src/ts/@overflow/commons/application/decorators/configuration.ts b/src/ts/@overflow/commons/application/decorators/configuration.ts index f810f52..17a9447 100644 --- a/src/ts/@overflow/commons/application/decorators/configuration.ts +++ b/src/ts/@overflow/commons/application/decorators/configuration.ts @@ -14,27 +14,24 @@ import { } from '@overflow/commons/di/decorators'; export interface ConfigurationAnnotationAttributes { - name?: string[]; + name?: string; } @Injectable() -export class ConfigurationAnnotation implements Annotation { - public readonly attributes: ConfigurationAnnotationAttributes; +export class ConfigurationAnnotation extends Annotation { + public readonly attributes: ConfigurationAnnotationAttributes = { + }; public constructor(name: string | ConfigurationAnnotationAttributes) { - + super(); if (undefined === name) { - this.attributes = { - }; return; } if (TypeUtil.isString(name)) { - this.attributes = { - name: [name], - }; + this.attributes.name = name; } else { - this.attributes = name; + this.copyAttributes(this.attributes, name); } } diff --git a/src/ts/@overflow/commons/application/decorators/instance.ts b/src/ts/@overflow/commons/application/decorators/instance.ts index 07eabf2..6191811 100644 --- a/src/ts/@overflow/commons/application/decorators/instance.ts +++ b/src/ts/@overflow/commons/application/decorators/instance.ts @@ -16,24 +16,20 @@ export interface InstanceAnnotationAttributes { name?: InstanceNameType; } -export class InstanceAnnotation implements Annotation { - public readonly attributes: InstanceAnnotationAttributes; +export class InstanceAnnotation extends Annotation { + public readonly attributes: InstanceAnnotationAttributes = { + }; public constructor(name: InstanceNameType | InstanceNameType[] | InstanceAnnotationAttributes) { - + super(); if (undefined === name) { - this.attributes = { - name: null, - }; return; } if (TypeUtil.isString(name)) { - this.attributes = { - name: name, - }; + this.attributes.name = name; } else { - this.attributes = name; + this.copyAttributes(this.attributes, name); } } diff --git a/src/ts/@overflow/commons/application/decorators/runner.ts b/src/ts/@overflow/commons/application/decorators/runner.ts index 162b469..55d617e 100644 --- a/src/ts/@overflow/commons/application/decorators/runner.ts +++ b/src/ts/@overflow/commons/application/decorators/runner.ts @@ -7,7 +7,16 @@ import { PropertyKeyType, } from '@overflow/commons/core/type'; -export class RunnerAnnotation implements Annotation { +export interface RunnerAnnotationAttributes { +} + +export class RunnerAnnotation extends Annotation { + public readonly attributes: RunnerAnnotationAttributes = { + }; + + public constructor() { + super(); + } public methodDecorator(target: Object, propertyKey: PropertyKeyType, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor | void { diff --git a/src/ts/@overflow/commons/application/decorators/web_application.ts b/src/ts/@overflow/commons/application/decorators/web_application.ts index 28fa4d3..d0b4ddb 100644 --- a/src/ts/@overflow/commons/application/decorators/web_application.ts +++ b/src/ts/@overflow/commons/application/decorators/web_application.ts @@ -14,11 +14,13 @@ export interface WebApplicationAnnotationAttributes { configurations?: ClassType[]; } -export class WebApplicationAnnotation implements Annotation { - public readonly attributes: WebApplicationAnnotationAttributes; +export class WebApplicationAnnotation extends Annotation { + public readonly attributes: WebApplicationAnnotationAttributes = { + }; public constructor(attributes: WebApplicationAnnotationAttributes) { - this.attributes = attributes; + super(); + this.copyAttributes(this.attributes, attributes); } public classDecorator(target: TFunction): TFunction | void { diff --git a/src/ts/@overflow/commons/core/reflect/accessible_object.ts b/src/ts/@overflow/commons/core/reflect/accessible_object.ts index c398391..e33125a 100644 --- a/src/ts/@overflow/commons/core/reflect/accessible_object.ts +++ b/src/ts/@overflow/commons/core/reflect/accessible_object.ts @@ -4,7 +4,9 @@ import { } from '@overflow/commons/core/type'; import {AnnotatedElement} from './annotated_element'; -import {Annotation} from './annotation'; +import { + Annotation, +} from './annotation'; export abstract class AccessibleObject implements AnnotatedElement { private _annotations: Map; diff --git a/src/ts/@overflow/commons/core/reflect/annotation.ts b/src/ts/@overflow/commons/core/reflect/annotation.ts index 3f0b0f7..e198b5a 100644 --- a/src/ts/@overflow/commons/core/reflect/annotation.ts +++ b/src/ts/@overflow/commons/core/reflect/annotation.ts @@ -1,17 +1,30 @@ import { MetadataKeyType, PropertyKeyType, + NotSupportedDecoratorError, + TypeUtil, } from '@overflow/commons/core/type'; -export interface Annotation { - classDecorator?(target: TFunction): TFunction | void; - propertyDecorator?(target: Object, propertyKey: PropertyKeyType): void; - methodDecorator?(target: Object, propertyKey: PropertyKeyType, - descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor | void; - parameterDecorator?(target: Object, propertyKey: PropertyKeyType, parameterIndex: number): void; -} - export abstract class Annotation { -} + protected copyAttributes(destination: AttributesType, source: AttributesType): void { + for (const key in source) { + if (source.hasOwnProperty(key)) { + destination[key] = source[key]; + } + } + } -export default Annotation; + public classDecorator(target: TFunction): TFunction | void { + throw new NotSupportedDecoratorError(); + } + public propertyDecorator(target: Object, propertyKey: PropertyKeyType): void { + throw new NotSupportedDecoratorError(); + } + public methodDecorator(target: Object, propertyKey: PropertyKeyType, + descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor | void { + throw new NotSupportedDecoratorError(); + } + public parameterDecorator(target: Object, propertyKey: PropertyKeyType, parameterIndex: number): void { + throw new NotSupportedDecoratorError(); + } +} diff --git a/src/ts/@overflow/commons/core/reflect/decorator.ts b/src/ts/@overflow/commons/core/reflect/decorator.ts index 2d841f7..5b085df 100644 --- a/src/ts/@overflow/commons/core/reflect/decorator.ts +++ b/src/ts/@overflow/commons/core/reflect/decorator.ts @@ -3,10 +3,13 @@ import { DecoratorType, MetadataKeyType, Metadata, + NotSupportedDecoratorError, TypeUtil, } from '@overflow/commons/core/type'; -import {Annotation} from './annotation'; +import { + Annotation, +} from './annotation'; import {Class} from './class'; import {Constructor} from './constructor'; import {Field} from './field'; @@ -35,52 +38,63 @@ export class Decorator { switch(decoratorType) { case DecoratorType.CLASS: - if (typeof(annotation.classDecorator) === 'undefined') { - throw new Error(`Cannot apply @${name} decorator on Class.`); + try { + cons = clazz._defineConstructor(Metadata.getOwnParamTypes(target)); + clazz._addAnnotation(annotation); + return annotation.classDecorator.call(annotation, target); + } catch (e) { + if (e instanceof NotSupportedDecoratorError) { + throw new NotSupportedDecoratorError(`Cannot apply @${name} decorator on Class.`); + } + throw e; } - cons = clazz._defineConstructor(Metadata.getOwnParamTypes(target)); - - clazz._addAnnotation(annotation); - - return annotation.classDecorator.call(annotation, target); case DecoratorType.PROPERTY: - if (typeof(annotation.propertyDecorator) === 'undefined') { - throw new Error(`Cannot apply @${name} decorator on Property.`); + try { + field = clazz._defineField(propertyKey, Metadata.getOwnType(target, propertyKey)); + field._addAnnotation(annotation); + return annotation.propertyDecorator.call(annotation, target, propertyKey); + } catch (e) { + if (e instanceof NotSupportedDecoratorError) { + throw new NotSupportedDecoratorError(`Cannot apply @${name} decorator on Property.`); + } + throw e; } - - field = clazz._defineField(propertyKey, Metadata.getOwnType(target, propertyKey)); - field._addAnnotation(annotation); - - return annotation.propertyDecorator.call(annotation, target, propertyKey); case DecoratorType.METHOD: - if (typeof(annotation.methodDecorator) === 'undefined') { - throw new Error(`Cannot apply @${name} decorator on Method.`); - } - method = clazz._defineMethod(propertyKey, - Metadata.getOwnParamTypes(target, propertyKey), - Metadata.getOwnReturnType(target, propertyKey)); - method._addAnnotation(annotation); - - return annotation.methodDecorator.call(annotation, target, propertyKey, descriptorOrParameterIndex); - case DecoratorType.PARAMETER: - if (typeof(annotation.parameterDecorator) === 'undefined') { - throw new Error(`Cannot apply @${name} decorator on Parameter.`); - } - - if (undefined === propertyKey) { - cons = clazz.getConstructor(); - parameter = cons.getParameter(descriptorOrParameterIndex); - } else { + try { method = clazz._defineMethod(propertyKey, Metadata.getOwnParamTypes(target, propertyKey), Metadata.getOwnReturnType(target, propertyKey)); - parameter = method.getParameter(descriptorOrParameterIndex); - } - parameter._addAnnotation(annotation); + method._addAnnotation(annotation); - return annotation.parameterDecorator.call(annotation, target, propertyKey, descriptorOrParameterIndex); + return annotation.methodDecorator.call(annotation, target, propertyKey, descriptorOrParameterIndex); + } catch (e) { + if (e instanceof NotSupportedDecoratorError) { + throw new NotSupportedDecoratorError(`Cannot apply @${name} decorator on Method.`); + } + throw e; + } + case DecoratorType.PARAMETER: + try { + if (undefined === propertyKey) { + cons = clazz.getConstructor(); + parameter = cons.getParameter(descriptorOrParameterIndex); + } else { + method = clazz._defineMethod(propertyKey, + Metadata.getOwnParamTypes(target, propertyKey), + Metadata.getOwnReturnType(target, propertyKey)); + parameter = method.getParameter(descriptorOrParameterIndex); + } + parameter._addAnnotation(annotation); + + return annotation.parameterDecorator.call(annotation, target, propertyKey, descriptorOrParameterIndex); + } catch (e) { + if (e instanceof NotSupportedDecoratorError) { + throw new NotSupportedDecoratorError(`Cannot apply @${name} decorator on Parameter.`); + } + throw e; + } default: - throw new Error(`Cannot determine decorator[@${name}] type.`); + throw new NotSupportedDecoratorError(`Cannot determine decorator[@${name}] type.`); } }; }; diff --git a/src/ts/@overflow/commons/core/type/error.ts b/src/ts/@overflow/commons/core/type/error.ts new file mode 100644 index 0000000..79d65b2 --- /dev/null +++ b/src/ts/@overflow/commons/core/type/error.ts @@ -0,0 +1,6 @@ +export class NotSupportedDecoratorError extends Error { + public constructor(message?: string) { + super(message); + Object.setPrototypeOf(this, new.target.prototype); + } +} diff --git a/src/ts/@overflow/commons/core/type/index.ts b/src/ts/@overflow/commons/core/type/index.ts index 09189c3..a4e41f3 100644 --- a/src/ts/@overflow/commons/core/type/index.ts +++ b/src/ts/@overflow/commons/core/type/index.ts @@ -1,3 +1,4 @@ +export * from './error'; export * from './metadata'; export * from './type'; export * from './util'; diff --git a/src/ts/@overflow/commons/di/decorators/inject.ts b/src/ts/@overflow/commons/di/decorators/inject.ts index 07a91ba..bf5b2b5 100644 --- a/src/ts/@overflow/commons/di/decorators/inject.ts +++ b/src/ts/@overflow/commons/di/decorators/inject.ts @@ -16,23 +16,22 @@ export interface InjectAnnotationAttributes { name?: InstanceNameType; } -export class InjectAnnotation implements Annotation { - public readonly attributes: InjectAnnotationAttributes; +export class InjectAnnotation extends Annotation { + public readonly attributes: InjectAnnotationAttributes = { - public constructor(name: InstanceNameType | InstanceNameType[] | InjectAnnotationAttributes) { + }; + + public constructor(name: InstanceNameType | InjectAnnotationAttributes) { + super(); if (undefined === name) { - this.attributes = { - }; return; } if (TypeUtil.isString(name)) { - this.attributes = { - name: name, - }; + this.attributes.name = name; } else { - this.attributes = name; + this.copyAttributes(this.attributes, name); } } @@ -40,7 +39,7 @@ export class InjectAnnotation implements Annotation { console.log('Inject'); } - public propertyDecorator?(target: Object, propertyKey: PropertyKeyType): void { + public propertyDecorator(target: Object, propertyKey: PropertyKeyType): void { console.log('Inject'); } @@ -49,7 +48,7 @@ export class InjectAnnotation implements Annotation { console.log('Inject'); } - public parameterDecorator?(target: Object, propertyKey: PropertyKeyType, parameterIndex: number): void { + public parameterDecorator(target: Object, propertyKey: PropertyKeyType, parameterIndex: number): void { console.log('Inject'); } diff --git a/src/ts/@overflow/commons/di/decorators/injectable.ts b/src/ts/@overflow/commons/di/decorators/injectable.ts index 77e126d..4eac262 100644 --- a/src/ts/@overflow/commons/di/decorators/injectable.ts +++ b/src/ts/@overflow/commons/di/decorators/injectable.ts @@ -16,23 +16,23 @@ export interface InjectableAnnotationAttributes { name?: InstanceNameType[]; } -export class InjectableAnnotation implements Annotation { - public readonly attributes: InjectableAnnotationAttributes; +export class InjectableAnnotation extends Annotation { + public readonly attributes: InjectableAnnotationAttributes = { + + }; public constructor(name: InstanceNameType | InstanceNameType[] | InjectableAnnotationAttributes) { - + super(); if (undefined === name) { - this.attributes = { - }; return; } if (TypeUtil.isString(name)) { - this.attributes = { - name: [name], - }; + this.attributes.name = [name]; + } else if (TypeUtil.isArray(name)) { + this.attributes.name = name; } else { - this.attributes = name; + this.copyAttributes(this.attributes, name); } } diff --git a/src/ts/@overflow/commons/di/decorators/post_construct.ts b/src/ts/@overflow/commons/di/decorators/post_construct.ts index c2185dc..4f4f464 100644 --- a/src/ts/@overflow/commons/di/decorators/post_construct.ts +++ b/src/ts/@overflow/commons/di/decorators/post_construct.ts @@ -12,23 +12,21 @@ export interface PostConstructAnnotationAttributes { name?: string[]; } -export class PostConstructAnnotation implements Annotation { - public readonly attributes: PostConstructAnnotationAttributes; +export class PostConstructAnnotation extends Annotation { + public readonly attributes: PostConstructAnnotationAttributes = { + + }; public constructor(name: string | string[] | PostConstructAnnotationAttributes) { - + super(); if (undefined === name) { - this.attributes = { - }; return; } if (TypeUtil.isString(name)) { - this.attributes = { - name: [name], - }; + this.attributes.name = [name]; } else { - this.attributes = name; + this.copyAttributes(this.attributes, name); } } diff --git a/src/ts/@overflow/commons/di/decorators/pre_destroy.ts b/src/ts/@overflow/commons/di/decorators/pre_destroy.ts index 87b0199..7ce453c 100644 --- a/src/ts/@overflow/commons/di/decorators/pre_destroy.ts +++ b/src/ts/@overflow/commons/di/decorators/pre_destroy.ts @@ -12,23 +12,21 @@ export interface PreDestroyAnnotationAttributes { name?: string[]; } -export class PreDestroyAnnotation implements Annotation { - public readonly attributes: PreDestroyAnnotationAttributes; +export class PreDestroyAnnotation extends Annotation { + public readonly attributes: PreDestroyAnnotationAttributes = { + + }; public constructor(name: string | string[] | PreDestroyAnnotationAttributes) { - + super(); if (undefined === name) { - this.attributes = { - }; return; } if (TypeUtil.isString(name)) { - this.attributes = { - name: [name], - }; + this.attributes.name = [name]; } else { - this.attributes = name; + this.copyAttributes(this.attributes, name); } } diff --git a/src/ts/@overflow/commons/di/decorators/resource.ts b/src/ts/@overflow/commons/di/decorators/resource.ts index 11a78b1..b0fadc0 100644 --- a/src/ts/@overflow/commons/di/decorators/resource.ts +++ b/src/ts/@overflow/commons/di/decorators/resource.ts @@ -16,23 +16,21 @@ export interface ResourceAnnotationAttributes { name?: InstanceNameType; } -export class ResourceAnnotation implements Annotation { - public readonly attributes: ResourceAnnotationAttributes; +export class ResourceAnnotation extends Annotation { + public readonly attributes: ResourceAnnotationAttributes = { + name: undefined, + }; public constructor(name: InstanceNameType | ResourceAnnotationAttributes) { - + super(); if (undefined === name) { - this.attributes = { - }; return; } if (TypeUtil.isString(name)) { - this.attributes = { - name: name, - }; + this.attributes.name = name; } else { - this.attributes = name; + this.copyAttributes(this.attributes, name); } } @@ -40,7 +38,7 @@ export class ResourceAnnotation implements Annotation { console.log('Resource'); } - public propertyDecorator?(target: Object, propertyKey: PropertyKeyType): void { + public propertyDecorator(target: Object, propertyKey: PropertyKeyType): void { console.log('Resource'); } @@ -49,7 +47,7 @@ export class ResourceAnnotation implements Annotation { console.log('Resource'); } - public parameterDecorator?(target: Object, propertyKey: PropertyKeyType, parameterIndex: number): void { + public parameterDecorator(target: Object, propertyKey: PropertyKeyType, parameterIndex: number): void { console.log('Resource'); } } diff --git a/src/ts/@overflow/commons/di/decorators/value.ts b/src/ts/@overflow/commons/di/decorators/value.ts index 16c83f3..78d5a0f 100644 --- a/src/ts/@overflow/commons/di/decorators/value.ts +++ b/src/ts/@overflow/commons/di/decorators/value.ts @@ -12,29 +12,29 @@ export interface ValueAnnotationAttributes { value: string; } -export class ValueAnnotation implements Annotation { - public readonly attributes: ValueAnnotationAttributes; +export class ValueAnnotation extends Annotation { + public readonly attributes: ValueAnnotationAttributes = { + value: undefined, + }; public constructor(value: string | ValueAnnotationAttributes) { - + super(); if (undefined === value) { throw new Error(`value attribute must be specified.`); } if (TypeUtil.isString(value)) { - this.attributes = { - value: value, - }; + this.attributes.value = value; } else { - this.attributes = value; + this.copyAttributes(this.attributes, value); } } - public propertyDecorator?(target: Object, propertyKey: PropertyKeyType): void { + public propertyDecorator(target: Object, propertyKey: PropertyKeyType): void { console.log('Value'); } - public parameterDecorator?(target: Object, propertyKey: PropertyKeyType, parameterIndex: number): void { + public parameterDecorator(target: Object, propertyKey: PropertyKeyType, parameterIndex: number): void { console.log('Value'); } } diff --git a/src/ts/@overflow/commons/redux/decorators/action_mapping.ts b/src/ts/@overflow/commons/redux/decorators/action_mapping.ts index 674dd81..243e5ef 100644 --- a/src/ts/@overflow/commons/redux/decorators/action_mapping.ts +++ b/src/ts/@overflow/commons/redux/decorators/action_mapping.ts @@ -12,25 +12,23 @@ export interface ActionMappingAnnotationAttributes { value: string[]; } -export class ActionMappingAnnotation implements Annotation { - public readonly attributes: ActionMappingAnnotationAttributes; +export class ActionMappingAnnotation extends Annotation { + public readonly attributes: ActionMappingAnnotationAttributes = { + value: undefined, + }; public constructor(value: string | string[] | ActionMappingAnnotationAttributes) { - + super(); if (undefined === value) { throw new Error(`value attribute must be specified.`); } if (TypeUtil.isString(value)) { - this.attributes = { - value: [value], - }; + this.attributes.value = [value]; } else if (TypeUtil.isArray(value)) { - this.attributes = { - value: value, - }; + this.attributes.value = value; } else { - this.attributes = value; + this.copyAttributes(this.attributes, value); } } diff --git a/src/ts/@overflow/commons/redux/decorators/reducer.ts b/src/ts/@overflow/commons/redux/decorators/reducer.ts index 62efa35..7196994 100644 --- a/src/ts/@overflow/commons/redux/decorators/reducer.ts +++ b/src/ts/@overflow/commons/redux/decorators/reducer.ts @@ -12,23 +12,21 @@ export interface ReducerAnnotationAttributes { name?: string; } -export class ReducerAnnotation implements Annotation { - public readonly attributes: ReducerAnnotationAttributes; +export class ReducerAnnotation extends Annotation { + public readonly attributes: ReducerAnnotationAttributes = { + + }; public constructor(name: string | ReducerAnnotationAttributes) { + super(); if (undefined === name) { - this.attributes = { - name: '', - }; return; } if (TypeUtil.isString(name)) { - this.attributes = { - name: name, - }; + this.attributes.name = name; } else { - this.attributes = name; + this.copyAttributes(this.attributes, name); } } diff --git a/src/ts/@overflow/commons/redux/decorators/rest_api.ts b/src/ts/@overflow/commons/redux/decorators/rest_api.ts index 2640443..b29e6d2 100644 --- a/src/ts/@overflow/commons/redux/decorators/rest_api.ts +++ b/src/ts/@overflow/commons/redux/decorators/rest_api.ts @@ -12,20 +12,21 @@ export interface RestAPIAnnotationAttributes { entryPath: string; } -export class RestAPIAnnotation implements Annotation { - public readonly attributes: RestAPIAnnotationAttributes; +export class RestAPIAnnotation extends Annotation { + public readonly attributes: RestAPIAnnotationAttributes = { + entryPath: undefined, + }; public constructor(entryPath: string | RestAPIAnnotationAttributes) { + super(); if (undefined === entryPath) { throw new Error(`entryPath attribute must be specified.`); } if (TypeUtil.isString(entryPath)) { - this.attributes = { - entryPath: entryPath, - }; + this.attributes.entryPath = entryPath; } else { - this.attributes = entryPath; + this.copyAttributes(this.attributes, entryPath); } } diff --git a/src/ts/@overflow/commons/redux/decorators/rpc_api.ts b/src/ts/@overflow/commons/redux/decorators/rpc_api.ts index 95bdf31..1eec31b 100644 --- a/src/ts/@overflow/commons/redux/decorators/rpc_api.ts +++ b/src/ts/@overflow/commons/redux/decorators/rpc_api.ts @@ -12,20 +12,21 @@ export interface RpcAPIAnnotationAttributes { method: string; } -export class RpcAPIAnnotation implements Annotation { - public readonly attributes: RpcAPIAnnotationAttributes; +export class RpcAPIAnnotation extends Annotation { + public readonly attributes: RpcAPIAnnotationAttributes = { + method: undefined, + }; public constructor(method: string | RpcAPIAnnotationAttributes) { + super(); if (undefined === method) { throw new Error(`method attribute must be specified.`); } if (TypeUtil.isString(method)) { - this.attributes = { - method: method, - }; + this.attributes.method = method; } else { - this.attributes = method; + this.copyAttributes(this.attributes, method); } } diff --git a/src/ts/@overflow/webapp/index.tsx b/src/ts/@overflow/webapp/index.tsx index 02b4d5b..ea833f8 100644 --- a/src/ts/@overflow/webapp/index.tsx +++ b/src/ts/@overflow/webapp/index.tsx @@ -59,11 +59,14 @@ declare global { const module: { hot: any }; } -class A { -} -class B extends A { +abstract class B { + public abstract b(): void; } +// abstract class C { +// public abstract c(): void; +// } + @WebApplication({ injectables: injectables, jsonSources: jsonSources, @@ -74,10 +77,18 @@ class B extends A { WebAppConfiguration, ], }) -class WebAppApplication extends B { +class WebAppApplication implements B { private static isProduction:boolean = process.env.NODE_ENV === 'production' ? true : false; private static useReduxDevTools:boolean = window.devToolsExtension && !WebAppApplication.isProduction ? true : false; + public b(): void { + // + } + + public c(): void { + // + } + @Resource() private containerPromise: Promise; private container: HTMLElement; diff --git a/src/ts/@overflow/webapp/redux/webapp_dispatch_reducer.ts b/src/ts/@overflow/webapp/redux/webapp_dispatch_reducer.ts index 3c52199..fe9ed6c 100644 --- a/src/ts/@overflow/webapp/redux/webapp_dispatch_reducer.ts +++ b/src/ts/@overflow/webapp/redux/webapp_dispatch_reducer.ts @@ -1,7 +1,7 @@ import { ClassType } from '@overflow/commons/core/type'; import { - Injectable, Inject, Resource, + Injectable, Inject, Resource, InjectableAnnotation, } from '@overflow/commons/di/decorators'; import {DispatcherReducer} from '@overflow/commons/redux';