This commit is contained in:
crusader 2017-08-03 23:36:03 +09:00
parent 4f5f937901
commit 72e95d73d4
33 changed files with 769 additions and 363 deletions

View File

@ -2,32 +2,34 @@ import {
ClassType, ClassType,
} from '@loafer/core/constants/types'; } from '@loafer/core/constants/types';
import AppContext from '@loafer/context/AppContext'; import AnnotationConfigApplicationContext from '@loafer/context/annotation/AnnotationConfigApplicationContext';
import DefaultAppContext from '@loafer/context/implement/DefaultAppContext';
import ApplicationStater from '@loafer/application/ApplicationStater'; import ApplicationStater from '@loafer/application/ApplicationStater';
class Application { class Application {
private appContext: AppContext; // private appContext: AppContext;
private appClass: ClassType; private appClass: ClassType;
private appInstance: ApplicationStater; // private appInstance: ApplicationStater;
public constructor(clazz: ClassType) { public constructor(clazz: ClassType) {
this.appClass = clazz; this.appClass = clazz;
} }
public run(): AppContext { public run(): void {
this.appContext = new DefaultAppContext(); let context: AnnotationConfigApplicationContext = new AnnotationConfigApplicationContext();
this.appInstance = this.appContext.getPouchByClass(this.appClass, undefined); context.register(AppConfig.prototype);
context.refresh();
this.appInstance.start(); context.getPouch('entitlement');
return this.appContext;
} }
public static run(clazz: ClassType): AppContext { public static run(clazz: ClassType): void {
return new Application(clazz).run(); new Application(clazz).run();
} }
} }
export class AppConfig {
}
export default Application; export default Application;

View File

@ -1,5 +1,5 @@
export interface ApplicationStater { export interface ApplicationStater {
start(): void; run(): void;
} }
export default ApplicationStater; export default ApplicationStater;

View File

@ -1,30 +0,0 @@
import {
PropertyType,
} from '@loafer/core/constants/types';
import {
Decorator,
DecoratorHandler,
} from '@loafer/core/decorator';
import {
Class,
} from '@loafer/core/reflect';
import {
ConfigurationAnnotation,
} from '@loafer/context/decorator/Configuration';
export class ApplicationAnnotation extends ConfigurationAnnotation implements DecoratorHandler {
public constructor(qualifier?: PropertyType) {
super(qualifier);
}
public onClassDecorator = <TFunction extends Function>(clazz: Class, target: TFunction): TFunction | void => {
console.log('Application');
}
}
export const Application = Decorator.create(ApplicationAnnotation);
export default Application;

View File

@ -0,0 +1,25 @@
import {
PropertyType,
} from '@loafer/core/constants/types';
import {
Decorator,
} from '@loafer/core/decorator';
import {
ConfigurationAnnotation,
} from '@loafer/context/decorator/Configuration';
export class ApplicationConfigurationAnnotation extends ConfigurationAnnotation {
public constructor(qualifier?: PropertyType) {
super(qualifier);
}
public onClassDecorator = <TFunction extends Function>(target: TFunction): TFunction | void => {
console.log('ApplicationConfiguration');
}
}
export const ApplicationConfiguration = Decorator.create(ApplicationConfigurationAnnotation);
export default ApplicationConfiguration;

View File

@ -1,22 +1,22 @@
import { // import {
PropertyType, // PropertyType,
} from '@loafer/core/constants/types'; // } from '@loafer/core/constants/types';
import EnvironmentCapable from '@loafer/core/env/EnvironmentCapable'; // import EnvironmentCapable from '@loafer/core/env/EnvironmentCapable';
import PouchFactory from '@loafer/pouches/factory/PouchFactory'; // import PouchFactory from '@loafer/pouches/factory/PouchFactory';
import DefaultPouchFactory from '@loafer/pouches/factory/implement/DefaultPouchFactory'; // import DefaultPouchFactory from '@loafer/pouches/factory/implement/DefaultPouchFactory';
import ListablePouchFactory from '@loafer/pouches/factory/ListablePouchFactory'; // import ListablePouchFactory from '@loafer/pouches/factory/ListablePouchFactory';
import HierarchicalPouchFactory from '@loafer/pouches/factory/HierarchicalPouchFactory'; // import HierarchicalPouchFactory from '@loafer/pouches/factory/HierarchicalPouchFactory';
import InjectCapablePouchFactory from '@loafer/pouches/factory/config/InjectCapablePouchFactory'; // import InjectCapablePouchFactory from '@loafer/pouches/factory/config/InjectCapablePouchFactory';
export interface ApplicationContext extends EnvironmentCapable, ListablePouchFactory, HierarchicalPouchFactory { // export interface ApplicationContext extends EnvironmentCapable, ListablePouchFactory, HierarchicalPouchFactory {
getId?(): PropertyType; // getId?(): PropertyType;
getApplicationName(): string; // getApplicationName(): string;
getDisplayName(): string; // getDisplayName(): string;
getParent?(): ApplicationContext; // getParent?(): ApplicationContext;
getInjectCapablePouchFactory(): InjectCapablePouchFactory; // getInjectCapablePouchFactory(): InjectCapablePouchFactory;
} // }
export default ApplicationContext; // export default ApplicationContext;

View File

@ -1,11 +1,11 @@
import { // import {
PropertyType, // PropertyType,
} from '@loafer/core/constants/types'; // } from '@loafer/core/constants/types';
import ConfigurableEnvironment from '@loafer/core/env/ConfigurableEnvironment'; // import ConfigurableEnvironment from '@loafer/core/env/ConfigurableEnvironment';
import ApplicationContext from '@loafer/context/ApplicationContext'; // import ApplicationContext from '@loafer/context/ApplicationContext';
import Lifecycle from '@loafer/context/Lifecycle'; // import Lifecycle from '@loafer/context/Lifecycle';
export interface ConfigurableApplicationContext extends ApplicationContext, Lifecycle { // export interface ConfigurableApplicationContext extends ApplicationContext, Lifecycle {
} // }
export default ConfigurableApplicationContext; // export default ConfigurableApplicationContext;

View File

@ -1,30 +0,0 @@
import {
ClassType,
PropertyType,
} from '@loafer/core/constants/types';
import ApplicationContext from '@loafer/context/ApplicationContext';
import DefaultPouchFactory from '@loafer/pouches/factory/implement/DefaultPouchFactory';
class DefaultAppContext implements ApplicationContext {
private readonly pouchFactory: DefaultPouchFactory;
public constructor() {
this.pouchFactory = new DefaultPouchFactory();
}
public getPouchFactory(): DefaultPouchFactory {
return this.pouchFactory;
}
public getPouch(qualifier: PropertyType, clazz: ClassType, ...args: any[]): any {
return this.pouchFactory.getPouch(qualifier, clazz, args);
}
public getPouchByClass(clazz: ClassType, qualifier: PropertyType, ...args: any[]): any {
return this.pouchFactory.getPouchByClass(clazz, qualifier, args);
}
}
export default DefaultAppContext;

View File

@ -0,0 +1,97 @@
import {
ClassType,
PropertyType,
} from '@loafer/core/constants/types';
import {
Assert,
} from '@loafer/core/util';
import {
Annotation,
} from '@loafer/core/annotation';
import GenericApplicationContext from '@loafer/context/support/GenericApplicationContext';
export class AnnotatedPouchDefinitionReader {
private readonly registry: PouchDefinitionRegistry;
private pouchNameGenerator: PouchNameGenerator = new AnnotationPouchNameGenerator();
private scopeMetadataResolver: ScopeMetadataResolver = new AnnotationScopeMetadataResolver();
private conditionEvaluator: ConditionEvaluator;
public constructor(registry: PouchDefinitionRegistry, environment?: Environment) {
if (undefined === environment) {
environment = this.getOrCreateEnvironment(registry);
}
Assert.notNull(registry, 'PouchDefinitionRegistry must not be null');
Assert.notNull(environment, 'Environment must not be null');
this.registry = registry;
this.conditionEvaluator = new ConditionEvaluator(registry, environment, null);
AnnotationConfigUtils.registerAnnotationConfigProcessors(this.registry);
}
public getRegistry(): PouchDefinitionRegistry {
return this.registry;
}
public setEnvironment(environment: Environment): void {
this.conditionEvaluator = new ConditionEvaluator(this.registry, environment, null);
}
public setPouchNameGenerator(pouchNameGenerator: PouchNameGenerator): void {
this.pouchNameGenerator = (pouchNameGenerator !== null ? pouchNameGenerator : new AnnotationPouchNameGenerator());
}
public setScopeMetadataResolver(scopeMetadataResolver: ScopeMetadataResolver): void {
this.scopeMetadataResolver =
(scopeMetadataResolver !== null ? scopeMetadataResolver : new AnnotationScopeMetadataResolver());
}
public register(...annotatedClasses: ClassType[]): void {
annotatedClasses.forEach(annotatedClass => {
this.registerPouch(annotatedClass);
});
}
public registerPouch<TAnnotation extends Annotation>(annotatedClass: ClassType, name: PropertyType, ...qualifiers: TAnnotation[]): void {
let abd: AnnotatedGenericPouchDefinition = new AnnotatedGenericPouchDefinition(annotatedClass);
if (this.conditionEvaluator.shouldSkip(abd.getMetadata())) {
return;
}
let scopeMetadata: ScopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(abd);
abd.setScope(scopeMetadata.getScopeName());
let pouchName: string = (name !== null ? name : this.pouchNameGenerator.generatePouchName(abd, this.registry));
AnnotationConfigUtils.processCommonDefinitionAnnotations(abd);
if (qualifiers !== undefined) {
qualifiers.forEach((qualifier, index, array) => {
if (Primary.class === qualifier) {
abd.setPrimary(true);
} else if (Lazy.class === qualifier) {
abd.setLazyInit(true);
} else {
abd.addQualifier(new AutowireCandidateQualifier(qualifier));
}
});
}
let definitionHolder: PouchDefinitionHolder = new PouchDefinitionHolder(abd, pouchName);
definitionHolder = AnnotationConfigUtils.applyScopedProxyMode(scopeMetadata, definitionHolder, this.registry);
PouchDefinitionReaderUtils.registerPouchDefinition(definitionHolder, this.registry);
}
private static getOrCreateEnvironment(registry: PouchDefinitionRegistry): Environment {
Assert.notNull(registry, 'PouchDefinitionRegistry must not be null');
if (registry instanceof EnvironmentCapable) {
return (<EnvironmentCapable>registry).getEnvironment();
}
return new StandardEnvironment();
}
}
export default AnnotatedPouchDefinitionReader;

View File

@ -1,7 +1,21 @@
import {
ClassType,
} from '@loafer/core/constants/types';
import {
Assert,
} from '@loafer/core/util';
import GenericApplicationContext from '@loafer/context/support/GenericApplicationContext'; import GenericApplicationContext from '@loafer/context/support/GenericApplicationContext';
export class AnnotationConfigApplicationContext extends GenericApplicationContext { export class AnnotationConfigApplicationContext extends GenericApplicationContext {
private readonly reader: AnnotatedBeanDefinitionReader;
public register(...annotatedClasses: ClassType[]): void {
Assert.notEmpty(annotatedClasses, 'At least one annotated class must be specified');
this.reader.register(annotatedClasses);
}
} }
export default AnnotationConfigApplicationContext; export default AnnotationConfigApplicationContext;

View File

@ -4,22 +4,17 @@ import {
import { import {
Decorator, Decorator,
DecoratorHandler,
} from '@loafer/core/decorator'; } from '@loafer/core/decorator';
import {
Class,
} from '@loafer/core/reflect';
import { import {
InjectableAnnotation, InjectableAnnotation,
} from '@loafer/pouches/decorator/Injectable'; } from '@loafer/pouches/decorator/Injectable';
export class ConfigurationAnnotation extends InjectableAnnotation implements DecoratorHandler { export class ConfigurationAnnotation extends InjectableAnnotation {
public constructor(qualifier?: PropertyType) { public constructor(qualifier?: PropertyType) {
super(qualifier); super(qualifier);
} }
public onClassDecorator = <TFunction extends Function>(clazz: Class, target: TFunction): TFunction | void => { public onClassDecorator = <TFunction extends Function>(target: TFunction): TFunction | void => {
console.log('Configuration'); console.log('Configuration');
} }

View File

@ -5,21 +5,16 @@ import {
import { import {
Decorator, Decorator,
DecoratorHandler,
} from '@loafer/core/decorator'; } from '@loafer/core/decorator';
import Annotation from '@loafer/core/annotation/Annotation'; import Annotation from '@loafer/core/annotation/Annotation';
import {
Class,
} from '@loafer/core/reflect';
export interface PouchConfig { export interface PouchConfig {
qualifier?: PropertyType; qualifier?: PropertyType;
type?: ClassType; type?: ClassType;
} }
export class PouchAnnotation extends Annotation implements DecoratorHandler { export class PouchAnnotation extends Annotation {
private readonly Qualifier: PropertyType; private readonly Qualifier: PropertyType;
private readonly Type: ClassType; private readonly Type: ClassType;
public constructor(config: PouchConfig = {}) { public constructor(config: PouchConfig = {}) {
@ -28,7 +23,7 @@ export class PouchAnnotation extends Annotation implements DecoratorHandler {
this.Type = config.type; this.Type = config.type;
} }
public onMethodDecorator = <T>(clazz: Class, target: Object, propertyKey: PropertyType, public onMethodDecorator = <T>(target: Object, propertyKey: PropertyType,
descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void => { descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void => {
console.log('Pouch'); console.log('Pouch');
} }

View File

@ -1,4 +1,22 @@
import {
ClassType,
PropertyType,
} from '@loafer/core/constants/types';
import {
Class,
} from '@loafer/core/reflect';
export interface Annotation {
onClassDecorator?: <TFunction extends Function>(target: TFunction) => TFunction | void;
onPropertyDecorator?: (target: Object, propertyKey: PropertyType) => void;
onMethodDecorator?: <T>(target: Object, propertyKey: PropertyType,
descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void;
onParameterDecorator?: (target: Object, propertyKey: PropertyType, parameterIndex: number) => void;
}
export abstract class Annotation { export abstract class Annotation {
} }
export default Annotation; export default Annotation;

View File

@ -9,9 +9,9 @@ import Annotation from '@loafer/core/annotation/Annotation';
import DecoratorType from './DecoratorType'; import DecoratorType from './DecoratorType';
export class Decorator { export class Decorator {
public static create = (Annotation: Construtorable<Annotation>) => { public static create = (AnnotationType: Construtorable<Annotation>) => {
return (...handlerArgs: any[]) => { return (...handlerArgs: any[]) => {
let annotation = new Annotation(...handlerArgs); let annotation: Annotation = new AnnotationType(...handlerArgs);
return (...decoratorArgs: any[]) => { return (...decoratorArgs: any[]) => {
let decoratorType: DecoratorType = Decorator._detectDecoratorType(name, annotation, decoratorArgs); let decoratorType: DecoratorType = Decorator._detectDecoratorType(name, annotation, decoratorArgs);

View File

@ -1,18 +0,0 @@
import {
ClassType,
PropertyType,
} from '@loafer/core/constants/types';
import {
Class,
} from '@loafer/core/reflect';
export interface DecoratorHandler {
onClassDecorator?: <TFunction extends Function>(clazz: Class, target: TFunction) => TFunction | void;
onPropertyDecorator?: (clazz: Class, target: Object, propertyKey: PropertyType) => void;
onMethodDecorator?: <T>(clazz: Class, target: Object, propertyKey: PropertyType,
descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void;
onParameterDecorator?: (clazz: Class, target: Object, propertyKey: PropertyType, parameterIndex: number) => void;
}
export default DecoratorHandler;

View File

@ -1,3 +1,2 @@
export * from './Decorator'; export * from './Decorator';
export * from './DecoratorHandler';
export * from './DecoratorType'; export * from './DecoratorType';

View File

@ -0,0 +1,7 @@
export class IllegalArgumentException extends Error {
public constructor(message?: string) {
super(message);
}
}
export default IllegalArgumentException;

View File

@ -0,0 +1,7 @@
export class IllegalStateException extends Error {
public constructor(message?: string) {
super(message);
}
}
export default IllegalStateException;

View File

@ -0,0 +1,2 @@
export * from './IllegalArgumentException';
export * from './IllegalStateException';

View File

@ -0,0 +1,132 @@
import {
ClassType,
} from '@loafer/core/constants/types';
import {
IllegalStateException,
IllegalArgumentException,
} from '@loafer/core/lang';
import {
StringUtils,
} from '@loafer/core/util';
export abstract class Assert {
public static state(expression: boolean, message: string): void {
if (!expression) {
throw new IllegalStateException(message);
}
}
public static isTrue(expression: boolean, message: string): void {
if (!expression) {
throw new IllegalArgumentException(message);
}
}
public static isNull(object: any, message: string): void {
if (object !== null) {
throw new IllegalArgumentException(message);
}
}
public static notNull(object: any, message: string): void {
if (object == null) {
throw new IllegalArgumentException(message);
}
}
public static hasLength(text: string, message: string): void {
if (!StringUtils.hasLength(text)) {
throw new IllegalArgumentException(message);
}
}
public static hasText(text: string, message: string): void {
if (!StringUtils.hasText(text)) {
throw new IllegalArgumentException(message);
}
}
public static doesNotContain(textToSearch: string, substring: string, message: string): void {
if (StringUtils.hasLength(textToSearch) && StringUtils.hasLength(substring) &&
textToSearch.includes(substring)) {
throw new IllegalArgumentException(message);
}
}
public static notEmpty(collection: any[] | Map<any, any> | Set<any>, message: string): void {
if (undefined === collection || null === collection) {
throw new IllegalArgumentException(message);
}
let valid = true;
if (collection instanceof Array) {
let array: any[] = collection;
if (0 === collection.length) {
valid = false;
}
} else if (collection instanceof Map) {
let map: Map<any, any> = collection;
if (0 === map.size) {
valid = false;
}
} else if (collection instanceof Set) {
let set: Set<any> = collection;
if (0 === set.size) {
valid = false;
}
} else {
valid = false;
}
if (!valid) {
throw new IllegalArgumentException(message);
}
}
public static noNullElements(array: any[], message: string): void {
if (array !== null) {
array.forEach(element => {
if (element === null) {
throw new IllegalArgumentException(message);
}
});
}
}
public static isInstanceOf(type: ClassType, obj: any, message: string = ''): void {
Assert.notNull(type, 'Type to check against must not be null');
if (!(obj instanceof type.constructor)) {
Assert.instanceCheckFailed(type, obj, message);
}
}
private static instanceCheckFailed(type: ClassType, obj: any, message: string): void {
let className = (obj !== undefined && obj !== null ? Object.getPrototypeOf(obj).constructor.name : 'null');
let result = '';
let defaultMessage = true;
if (StringUtils.hasLength(message)) {
if (Assert.endsWithSeparator(message)) {
result = message + ' ';
} else {
result = Assert.messageWithTypeName(message, className);
defaultMessage = false;
}
}
if (defaultMessage) {
result = result + (`Object of class [${className}] must be an instance of ${type}`);
}
throw new IllegalArgumentException(result);
}
private static endsWithSeparator(message: string): boolean {
return (message.endsWith(':') || message.endsWith(';') || message.endsWith(',') || message.endsWith('.'));
}
private static messageWithTypeName(message: string, typeName: string): string {
return message + (message.endsWith(' ') ? '' : ': ') + typeName;
}
}
export default Assert;

View File

@ -0,0 +1,223 @@
import {
IllegalStateException,
IllegalArgumentException,
} from '@loafer/core/lang';
export abstract class StringUtils {
private static readonly FOLDER_SEPARATOR: string = '/';
private static readonly WINDOWS_FOLDER_SEPARATOR: string = '\\';
private static readonly TOP_PATH: string = '..';
private static readonly CURRENT_PATH: string = '.';
private static readonly EXTENSION_SEPARATOR: string = '.';
public static isEmpty(str: any): boolean {
return (undefined === str || null === str || '' === str);
}
public static hasLength(str: string): boolean {
return (undefined !== str && null !== str && str.length > 0);
}
public static hasText(str: string): boolean {
if (!StringUtils.hasLength(str)) {
return false;
}
return str.trim() !== '';
}
public static containsWhitespace(str: string): boolean {
if (!StringUtils.hasLength(str)) {
return false;
}
return str.replace(/^\s+|\s+$/gm, '').length === 0;
}
public static trimWhitespace(str: string): string {
if (!StringUtils.hasLength(str)) {
return str;
}
return str.trim();
}
public static trimAllWhitespace(str: string): string {
if (!StringUtils.hasLength(str)) {
return str;
}
return str.replace(/\s/g, '');
}
public static trimLeadingWhitespace(str: string): string {
if (!StringUtils.hasLength(str)) {
return str;
}
return str.replace(/^\s+/gm, '');
}
public static trimTrailingWhitespace(str: string): string {
if (!StringUtils.hasLength(str)) {
return str;
}
return str.replace(/^\s+$/gm, '');
}
public static trimLeadingCharacter(str: string, leadingCharacter: string): string {
if (!StringUtils.hasLength(str)) {
return str;
}
return str.replace(new RegExp('^[' + leadingCharacter + ']+'), '');
}
public static trimTrailingCharacter(str: string, trailingCharacter: string): string {
if (!StringUtils.hasLength(str)) {
return str;
}
return str.replace(new RegExp('[' + trailingCharacter + ']+$'), '');
}
public static startsWithIgnoreCase(str: string, prefix: string): boolean {
if (undefined === str || null === str || undefined === prefix || null === prefix) {
return false;
}
if (str.startsWith(prefix)) {
return true;
}
if (str.length < prefix.length) {
return false;
}
const lcStr = str.substring(0, prefix.length).toLowerCase();
const lcPrefix = prefix.toLowerCase();
return lcStr === lcPrefix;
}
public static endsWithIgnoreCase(str: string, suffix: string): boolean {
if (str == null || suffix == null) {
return false;
}
if (str.endsWith(suffix)) {
return true;
}
if (str.length < suffix.length) {
return false;
}
const lcStr = str.substring(str.length - suffix.length).toLowerCase();
const lcSuffix = suffix.toLowerCase();
return lcStr === lcSuffix;
}
public static substringMatch(str: string, index: number, substring: string): boolean {
return str.includes(substring);
}
public static countOccurrencesOf(str: string, sub: string): number {
if (!StringUtils.hasLength(str) || !StringUtils.hasLength(sub)) {
return 0;
}
return (str.match(new RegExp(sub, 'gi')) || []).length;
}
public static replace(inString: string, oldPattern: string, newPattern: string): string {
if (!StringUtils.hasLength(inString) || !StringUtils.hasLength(oldPattern) || newPattern == null) {
return inString;
}
return inString.replace(new RegExp(oldPattern, 'g'), newPattern);
}
public static delete(inString: string, pattern: string): string {
return StringUtils.replace(inString, pattern, '');
}
public static deleteAny(inString: string, charsToDelete: string): string {
if (!StringUtils.hasLength(inString) || !StringUtils.hasLength(charsToDelete)) {
return inString;
}
return inString.replace(new RegExp('^[' + charsToDelete + ']+'), '');
}
public static quote(str: string): string {
return (str !== null ? '\'' + str + '\'' : null);
}
public static quoteIfString(obj: any): any {
return (typeof obj === 'string' ? StringUtils.quote(obj) : obj);
}
public static unqualify(qualifiedName: string, separator: string = '.'): string {
return qualifiedName.substring(qualifiedName.lastIndexOf(separator) + 1);
}
public static capitalize(str: string): string {
return StringUtils.changeFirstCharacterCase(str, true);
}
public static uncapitalize(str: string): string {
return StringUtils.changeFirstCharacterCase(str, false);
}
private static changeFirstCharacterCase(str: string, capitalize: boolean): string {
if (!StringUtils.hasLength(str)) {
return str;
}
return capitalize ? str.charAt(0).toUpperCase() + str.slice(1) : str.charAt(0).toLowerCase() + str.slice(1);
}
public static getFilename(path: string): string {
if (path === null) {
return null;
}
return path.split(StringUtils.WINDOWS_FOLDER_SEPARATOR).pop().split(StringUtils.FOLDER_SEPARATOR).pop();
}
public static getFilenameExtension(path: string): string {
if (path == null) {
return null;
}
return StringUtils.getFilename(path).split(StringUtils.EXTENSION_SEPARATOR).pop();
}
public static stripFilenameExtension(path: string): string {
if (path == null) {
return null;
}
return path.replace(new RegExp('[' + StringUtils.EXTENSION_SEPARATOR + StringUtils.getFilenameExtension(path) + ']+$'), '');
}
public static applyRelativePath(path: string, relativePath: string): string {
let separatorIndex = path.lastIndexOf(StringUtils.FOLDER_SEPARATOR);
if (separatorIndex !== -1) {
let newPath = path.substring(0, separatorIndex);
if (!relativePath.startsWith(StringUtils.FOLDER_SEPARATOR)) {
newPath += StringUtils.FOLDER_SEPARATOR;
}
return newPath + relativePath;
} else {
return relativePath;
}
}
}
export default StringUtils;

View File

@ -0,0 +1,2 @@
export * from './Assert';
export * from './StringUtils';

View File

@ -5,22 +5,17 @@ import {
import { import {
Decorator, Decorator,
DecoratorHandler,
} from '@loafer/core/decorator'; } from '@loafer/core/decorator';
import Annotation from '@loafer/core/annotation/Annotation'; import Annotation from '@loafer/core/annotation/Annotation';
import {
Class,
} from '@loafer/core/reflect';
export interface InjectConfig { export interface InjectConfig {
qualifier?: PropertyType; qualifier?: PropertyType;
required?: boolean; required?: boolean;
type?: ClassType; type?: ClassType;
} }
export class InjectAnnotation extends Annotation implements DecoratorHandler { export class InjectAnnotation extends Annotation {
private readonly Qualifier: PropertyType; private readonly Qualifier: PropertyType;
private readonly Required: boolean; private readonly Required: boolean;
private readonly Type: ClassType; private readonly Type: ClassType;
@ -32,14 +27,14 @@ export class InjectAnnotation extends Annotation implements DecoratorHandler {
this.Type = config.type; this.Type = config.type;
} }
public onPropertyDecorator = (clazz: Class, target: Object, propertyKey: PropertyType): void => { public onPropertyDecorator = (target: Object, propertyKey: PropertyType): void => {
console.log('Inject'); console.log('Inject');
} }
public onMethodDecorator = <T>(clazz: Class, target: Object, propertyKey: PropertyType, public onMethodDecorator = <T>(target: Object, propertyKey: PropertyType,
descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void => { descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void => {
console.log('Inject'); console.log('Inject');
} }
public onParameterDecorator = (clazz: Class, target: Object, propertyKey: PropertyType, parameterIndex: number): void => { public onParameterDecorator = (target: Object, propertyKey: PropertyType, parameterIndex: number): void => {
console.log('Inject'); console.log('Inject');
} }

View File

@ -4,23 +4,18 @@ import {
import { import {
Decorator, Decorator,
DecoratorHandler,
} from '@loafer/core/decorator'; } from '@loafer/core/decorator';
import Annotation from '@loafer/core/annotation/Annotation'; import Annotation from '@loafer/core/annotation/Annotation';
import { export class InjectableAnnotation extends Annotation {
Class,
} from '@loafer/core/reflect';
export class InjectableAnnotation extends Annotation implements DecoratorHandler {
private readonly Qualifier: PropertyType; private readonly Qualifier: PropertyType;
public constructor(qualifier?: PropertyType) { public constructor(qualifier?: PropertyType) {
super(); super();
this.Qualifier = qualifier; this.Qualifier = qualifier;
} }
public onClassDecorator = <TFunction extends Function>(clazz: Class, target: TFunction): TFunction | void => { public onClassDecorator = <TFunction extends Function>(target: TFunction): TFunction | void => {
console.log('Injectable'); console.log('Injectable');
} }

View File

@ -4,17 +4,12 @@ import {
import { import {
Decorator, Decorator,
DecoratorHandler,
} from '@loafer/core/decorator'; } from '@loafer/core/decorator';
import Annotation from '@loafer/core/annotation/Annotation'; import Annotation from '@loafer/core/annotation/Annotation';
import { export class PostConstructAnnotation extends Annotation {
Class, public onMethodDecorator = <T>(target: Object, propertyKey: PropertyType,
} from '@loafer/core/reflect';
export class PostConstructAnnotation extends Annotation implements DecoratorHandler {
public onMethodDecorator = <T>(clazz: Class, target: Object, propertyKey: PropertyType,
descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void => { descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void => {
console.log('PostConstruct'); console.log('PostConstruct');
} }

View File

@ -4,17 +4,12 @@ import {
import { import {
Decorator, Decorator,
DecoratorHandler,
} from '@loafer/core/decorator'; } from '@loafer/core/decorator';
import Annotation from '@loafer/core/annotation/Annotation'; import Annotation from '@loafer/core/annotation/Annotation';
import { export class PreDestroyAnnotation extends Annotation {
Class, public onMethodDecorator = <T>(target: Object, propertyKey: PropertyType,
} from '@loafer/core/reflect';
export class PreDestroyAnnotation extends Annotation implements DecoratorHandler {
public onMethodDecorator = <T>(clazz: Class, target: Object, propertyKey: PropertyType,
descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void => { descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void => {
console.log('PreDestroy'); console.log('PreDestroy');
} }

View File

@ -4,23 +4,18 @@ import {
import { import {
Decorator, Decorator,
DecoratorHandler,
} from '@loafer/core/decorator'; } from '@loafer/core/decorator';
import {
Class,
} from '@loafer/core/reflect';
import Annotation from '@loafer/core/annotation/Annotation'; import Annotation from '@loafer/core/annotation/Annotation';
export class ScopeAnnotation extends Annotation implements DecoratorHandler { export class ScopeAnnotation extends Annotation {
private readonly Qualifier: PropertyType; private readonly Qualifier: PropertyType;
public constructor(qualifier?: PropertyType) { public constructor(qualifier?: PropertyType) {
super(); super();
this.Qualifier = qualifier; this.Qualifier = qualifier;
} }
public onClassDecorator = <TFunction extends Function>(clazz: Class, target: TFunction): TFunction | void => { public onClassDecorator = <TFunction extends Function>(target: TFunction): TFunction | void => {
console.log('Scope'); console.log('Scope');
} }

View File

@ -5,16 +5,11 @@ import {
import { import {
Decorator, Decorator,
DecoratorHandler,
} from '@loafer/core/decorator'; } from '@loafer/core/decorator';
import Annotation from '@loafer/core/annotation/Annotation'; import Annotation from '@loafer/core/annotation/Annotation';
import { export class ValueAnnotation extends Annotation {
Class,
} from '@loafer/core/reflect';
export class ValueAnnotation extends Annotation implements DecoratorHandler {
private readonly Value: PropertyType; private readonly Value: PropertyType;
public constructor(value: PropertyType) { public constructor(value: PropertyType) {
@ -22,10 +17,10 @@ export class ValueAnnotation extends Annotation implements DecoratorHandler {
this.Value = value; this.Value = value;
} }
public onPropertyDecorator = (clazz: Class, target: Object, propertyKey: PropertyType): void => { public onPropertyDecorator = (target: Object, propertyKey: PropertyType): void => {
console.log('Value'); console.log('Value');
} }
public onParameterDecorator = (clazz: Class, target: Object, propertyKey: PropertyType, parameterIndex: number): void => { public onParameterDecorator = (target: Object, propertyKey: PropertyType, parameterIndex: number): void => {
console.log('Value'); console.log('Value');
} }

View File

@ -1,98 +1,98 @@
import { // import {
ClassType, // ClassType,
PropertyType, // PropertyType,
} from '@loafer/core/constants/types'; // } from '@loafer/core/constants/types';
import PouchDefinition from '@loafer/pouches/factory/config/PouchDefinition'; // import PouchDefinition from '@loafer/pouches/factory/config/PouchDefinition';
import PouchDefinitionRegistry from '@loafer/pouches/factory/registry/PouchDefinitionRegistry'; // import PouchDefinitionRegistry from '@loafer/pouches/factory/registry/PouchDefinitionRegistry';
import DefaultSingletonPouchRegistry from '@loafer/pouches/factory/implement/DefaultSingletonPouchRegistry'; // import DefaultSingletonPouchRegistry from '@loafer/pouches/factory/implement/DefaultSingletonPouchRegistry';
abstract class AbstractPouchFactory extends DefaultSingletonPouchRegistry implements PouchDefinitionRegistry { // abstract class AbstractPouchFactory extends DefaultSingletonPouchRegistry implements PouchDefinitionRegistry {
protected pouchDefinitionMap: Map<PropertyType, Map<ClassType, PouchDefinition>>; // protected pouchDefinitionMap: Map<PropertyType, Map<ClassType, PouchDefinition>>;
public constructor() { // public constructor() {
super(); // super();
this.pouchDefinitionMap = new Map(); // this.pouchDefinitionMap = new Map();
} // }
public registerPouchDefinition(pouchDefinition: PouchDefinition): void { // public registerPouchDefinition(pouchDefinition: PouchDefinition): void {
let clazz = pouchDefinition.Clazz; // let clazz = pouchDefinition.Clazz;
// let qualifier = validateQualifier(clazz, pouchDefinition.Qualifier); // // let qualifier = validateQualifier(clazz, pouchDefinition.Qualifier);
// if (this.hasPouchDefinition(qualifier, clazz)) { // // if (this.hasPouchDefinition(qualifier, clazz)) {
// throw new Error(`Pouch Definition[${clazz.constructor.name}:${qualifier}] is exist already`); // // throw new Error(`Pouch Definition[${clazz.constructor.name}:${qualifier}] is exist already`);
// } // // }
// let map = this.pouchDefinitionMap.get(qualifier); // // let map = this.pouchDefinitionMap.get(qualifier);
// if (undefined === map) { // // if (undefined === map) {
// map = new Map(); // // map = new Map();
// this.pouchDefinitionMap.set(qualifier, map); // // this.pouchDefinitionMap.set(qualifier, map);
// } // // }
// map.set(clazz, pouchDefinition); // // map.set(clazz, pouchDefinition);
} // }
public getPouchDefinition(qualifier: PropertyType, clazz?: ClassType): PouchDefinition { // public getPouchDefinition(qualifier: PropertyType, clazz?: ClassType): PouchDefinition {
if (!this.pouchDefinitionMap.has(qualifier)) { // if (!this.pouchDefinitionMap.has(qualifier)) {
return undefined; // return undefined;
} // }
let map = this.pouchDefinitionMap.get(qualifier); // let map = this.pouchDefinitionMap.get(qualifier);
let count = map.size; // let count = map.size;
let pouchDefinition: PouchDefinition; // let pouchDefinition: PouchDefinition;
try { // try {
pouchDefinition = this._getDefinition(map, clazz); // pouchDefinition = this._getDefinition(map, clazz);
} catch(e) { // } catch(e) {
console.log(`Type of Pouch Definition[${qualifier}] cannot be specified (count:${count})`); // console.log(`Type of Pouch Definition[${qualifier}] cannot be specified (count:${count})`);
} // }
return pouchDefinition; // return pouchDefinition;
} // }
public getPouchDefinitionByClass(clazz: ClassType, qualifier?: PropertyType): PouchDefinition { // public getPouchDefinitionByClass(clazz: ClassType, qualifier?: PropertyType): PouchDefinition {
// const _qualifier = validateQualifier(clazz, qualifier); // // const _qualifier = validateQualifier(clazz, qualifier);
return this.getPouchDefinition(qualifier, clazz); // return this.getPouchDefinition(qualifier, clazz);
} // }
public hasPouchDefinition(qualifier: PropertyType, clazz?: ClassType): boolean { // public hasPouchDefinition(qualifier: PropertyType, clazz?: ClassType): boolean {
return undefined === this.getPouchDefinition(qualifier, clazz) ? false : true; // return undefined === this.getPouchDefinition(qualifier, clazz) ? false : true;
} // }
public hasPouchDefinitionByClass(clazz: ClassType, qualifier?: PropertyType): boolean { // public hasPouchDefinitionByClass(clazz: ClassType, qualifier?: PropertyType): boolean {
// const _qualifier = validateQualifier(clazz, qualifier); // // const _qualifier = validateQualifier(clazz, qualifier);
return this.hasPouchDefinition(qualifier, clazz); // return this.hasPouchDefinition(qualifier, clazz);
} // }
public removePouchDefinition(qualifier: PropertyType, clazz?: ClassType): void { // public removePouchDefinition(qualifier: PropertyType, clazz?: ClassType): void {
if (!this.hasPouchDefinition(qualifier, clazz)) { // if (!this.hasPouchDefinition(qualifier, clazz)) {
console.log(`Pouch Definition[${clazz.constructor.name}:${qualifier}] is not exist`); // console.log(`Pouch Definition[${clazz.constructor.name}:${qualifier}] is not exist`);
return; // return;
} // }
this.pouchDefinitionMap.get(qualifier).delete(clazz); // this.pouchDefinitionMap.get(qualifier).delete(clazz);
if (0 === this.pouchDefinitionMap.get(qualifier).size) { // if (0 === this.pouchDefinitionMap.get(qualifier).size) {
this.pouchDefinitionMap.delete(qualifier); // this.pouchDefinitionMap.delete(qualifier);
} // }
} // }
public removePouchDefinitionByClass(clazz: ClassType, qualifier?: PropertyType): void { // public removePouchDefinitionByClass(clazz: ClassType, qualifier?: PropertyType): void {
// const _qualifier = validateQualifier(clazz, qualifier); // // const _qualifier = validateQualifier(clazz, qualifier);
// this.removePouchDefinition(_qualifier, clazz); // // this.removePouchDefinition(_qualifier, clazz);
} // }
private _getDefinition(map: Map<ClassType, PouchDefinition>, clazz?: ClassType): PouchDefinition { // private _getDefinition(map: Map<ClassType, PouchDefinition>, clazz?: ClassType): PouchDefinition {
if (undefined !== clazz) { // if (undefined !== clazz) {
return map.get(clazz); // return map.get(clazz);
} // }
const count = map.size; // const count = map.size;
if (1 < count) { // if (1 < count) {
throw new Error('Type of Pouch Definition cannot be specified.'); // throw new Error('Type of Pouch Definition cannot be specified.');
} // }
for (let value of Array.from(map.values())) { // for (let value of Array.from(map.values())) {
return value; // return value;
} // }
} // }
} // }
export default AbstractPouchFactory; // export default AbstractPouchFactory;

View File

@ -1,115 +1,115 @@
import { // import {
ClassType, // ClassType,
PropertyType, // PropertyType,
} from '@loafer/core/constants/types'; // } from '@loafer/core/constants/types';
import { // import {
PouchScope, // PouchScope,
} from '@loafer/pouches/constants/types'; // } from '@loafer/pouches/constants/types';
import PouchFactory from '@loafer/pouches/factory/PouchFactory'; // import PouchFactory from '@loafer/pouches/factory/PouchFactory';
import AbstractPouchFactory from '@loafer/pouches/factory/implement/AbstractPouchFactory'; // import AbstractPouchFactory from '@loafer/pouches/factory/implement/AbstractPouchFactory';
import PouchDefinition from '@loafer/pouches/factory/config/PouchDefinition'; // import PouchDefinition from '@loafer/pouches/factory/config/PouchDefinition';
import PouchDefinitionRegistry from '@loafer/pouches/factory/registry/PouchDefinitionRegistry'; // import PouchDefinitionRegistry from '@loafer/pouches/factory/registry/PouchDefinitionRegistry';
class DefaultPouchFactory extends AbstractPouchFactory implements PouchFactory, PouchDefinitionRegistry { // class DefaultPouchFactory extends AbstractPouchFactory implements PouchFactory, PouchDefinitionRegistry {
public constructor() { // public constructor() {
super(); // super();
} // }
public getPouch(qualifier: PropertyType, clazz: ClassType, ...args: any[]): any { // public getPouch(qualifier: PropertyType, clazz: ClassType, ...args: any[]): any {
let pouchDefinition = this._getPouchDefinition(qualifier, clazz); // let pouchDefinition = this._getPouchDefinition(qualifier, clazz);
if (undefined === pouchDefinition) { // if (undefined === pouchDefinition) {
throw new Error(`This class[${clazz.constructor.name}:${qualifier}] is not pouch.`); // throw new Error(`This class[${clazz.constructor.name}:${qualifier}] is not pouch.`);
} // }
return this._getPouch(pouchDefinition, ...args); // return this._getPouch(pouchDefinition, ...args);
} // }
public getPouchByClass(clazz: ClassType, qualifier: PropertyType, ...args: any[]): any { // public getPouchByClass(clazz: ClassType, qualifier: PropertyType, ...args: any[]): any {
// let _qualifier = validateQualifier(clazz, qualifier); // // let _qualifier = validateQualifier(clazz, qualifier);
// let pouchDefinition = this._getPouchDefinition(_qualifier, clazz); // // let pouchDefinition = this._getPouchDefinition(_qualifier, clazz);
// if (undefined === pouchDefinition) { // // if (undefined === pouchDefinition) {
// throw new Error(`This class[${clazz.constructor.name}:${qualifier}] is not pouch.`); // // throw new Error(`This class[${clazz.constructor.name}:${qualifier}] is not pouch.`);
// } // // }
// return this._getPouch(pouchDefinition, ...args); // // return this._getPouch(pouchDefinition, ...args);
} // }
private _getPouchDefinition(qualifier: PropertyType, clazz: ClassType): PouchDefinition { // private _getPouchDefinition(qualifier: PropertyType, clazz: ClassType): PouchDefinition {
let pouchDefinition = this.getPouchDefinition(qualifier, clazz); // let pouchDefinition = this.getPouchDefinition(qualifier, clazz);
if (undefined === pouchDefinition) { // if (undefined === pouchDefinition) {
// pouchDefinition = this._getInjectableDefinition(clazz); // // pouchDefinition = this._getInjectableDefinition(clazz);
if (undefined !== pouchDefinition) { // if (undefined !== pouchDefinition) {
this.registerPouchDefinition(pouchDefinition); // this.registerPouchDefinition(pouchDefinition);
} // }
} // }
return pouchDefinition; // return pouchDefinition;
} // }
private _getPouch(pouchDefinition: PouchDefinition, ...args: any[]): any { // private _getPouch(pouchDefinition: PouchDefinition, ...args: any[]): any {
let instance; // let instance;
if (pouchDefinition.isSingleton()) { // if (pouchDefinition.isSingleton()) {
instance = this.getSingleton(pouchDefinition.Qualifier, pouchDefinition.Clazz); // instance = this.getSingleton(pouchDefinition.Qualifier, pouchDefinition.Clazz);
if (undefined !== instance) { // if (undefined !== instance) {
return instance; // return instance;
} // }
} // }
instance = Object.create(pouchDefinition.Clazz); // instance = Object.create(pouchDefinition.Clazz);
instance.constructor.apply(instance, ...args); // instance.constructor.apply(instance, ...args);
this._injectDependency(instance, pouchDefinition.Clazz); // this._injectDependency(instance, pouchDefinition.Clazz);
} // }
private _injectDependency(instance: any, clazz: ClassType): void { // private _injectDependency(instance: any, clazz: ClassType): void {
if (clazz.constructor === Object) { // if (clazz.constructor === Object) {
return; // return;
} // }
// let injectDefinition: InjectDefinition = this._getInjectDefinition(clazz); // // let injectDefinition: InjectDefinition = this._getInjectDefinition(clazz);
// if (undefined !== injectDefinition) { // // if (undefined !== injectDefinition) {
// let injectors: Map<PropertyType, InjectItem> = injectDefinition.injectors; // // let injectors: Map<PropertyType, InjectItem> = injectDefinition.injectors;
// let propertyDescriptor: PropertyDescriptor; // // let propertyDescriptor: PropertyDescriptor;
// injectors.forEach((injectItem, key, map) => { // // injectors.forEach((injectItem, key, map) => {
// propertyDescriptor = Object.getOwnPropertyDescriptor(clazz, key); // // propertyDescriptor = Object.getOwnPropertyDescriptor(clazz, key);
// switch (injectItem.decoratorType) { // // switch (injectItem.decoratorType) {
// case DecoratorType.PROPERTY: // // case DecoratorType.PROPERTY:
// this._injectDependencyProperty(instance, clazz, key, propertyDescriptor, injectItem.propertyConfig); // // this._injectDependencyProperty(instance, clazz, key, propertyDescriptor, injectItem.propertyConfig);
// break; // // break;
// case DecoratorType.PARAMETER: // // case DecoratorType.PARAMETER:
// this._injectDependencyParameter(instance, propertyDescriptor, injectItem.parameterConfigMap); // // this._injectDependencyParameter(instance, propertyDescriptor, injectItem.parameterConfigMap);
// break; // // break;
// default: // // default:
// break; // // break;
// } // // }
// }); // // });
// } // // }
// this._injectDependency(instance, Object.getPrototypeOf(clazz)); // // this._injectDependency(instance, Object.getPrototypeOf(clazz));
} // }
// private _injectDependencyProperty(instance: any, clazz: ClassType, propertyKey: PropertyType, // // private _injectDependencyProperty(instance: any, clazz: ClassType, propertyKey: PropertyType,
// propertyDescriptor: PropertyDescriptor, injectConfig: InjectConfig): void { // // propertyDescriptor: PropertyDescriptor, injectConfig: InjectConfig): void {
// let pouch = this.getPouchByClass(injectConfig.clazz, injectConfig.qualifier); // // let pouch = this.getPouchByClass(injectConfig.clazz, injectConfig.qualifier);
// if (injectConfig.required && undefined === instance) { // // if (injectConfig.required && undefined === instance) {
// throw new Error(`Pouch which used by [${clazz.constructor.name}.${propertyKey}] is not exist in the context.`); // // throw new Error(`Pouch which used by [${clazz.constructor.name}.${propertyKey}] is not exist in the context.`);
// } // // }
// instance[propertyKey] = pouch; // // instance[propertyKey] = pouch;
// } // // }
// private _injectDependencyParameter(target: object, propertyDescriptor: PropertyDescriptor, // // private _injectDependencyParameter(target: object, propertyDescriptor: PropertyDescriptor,
// parameterConfigs: Map<number, InjectConfig>): void { // // parameterConfigs: Map<number, InjectConfig>): void {
// console.log(''); // // console.log('');
// } // // }
// private _getInjectableDefinition(clazz: ClassType): InjectableDefinition { // // private _getInjectableDefinition(clazz: ClassType): InjectableDefinition {
// return Reflect.getMetadata(POUCH_INJECTABLE_DEFINITION, clazz); // // return Reflect.getMetadata(POUCH_INJECTABLE_DEFINITION, clazz);
// } // // }
// private _getInjectDefinition(clazz: ClassType): InjectDefinition { // // private _getInjectDefinition(clazz: ClassType): InjectDefinition {
// return Reflect.getMetadata(POUCH_INJECT_DEFINITION, clazz); // // return Reflect.getMetadata(POUCH_INJECT_DEFINITION, clazz);
// } // // }
} // }
export default DefaultPouchFactory; // export default DefaultPouchFactory;

View File

@ -1,7 +1,7 @@
import AliasRegistry from '@loafer/core/AliasRegistry'; import AliasRegistry from '@loafer/core/AliasRegistry';
import PouchDefinition from '@loafer/pouches/factory/config/PouchDefinition'; import PouchDefinition from '@loafer/pouches/factory/config/PouchDefinition';
export abstract class AbstractInjectCapablePouchFactory extends AliasRegistry { export abstract class AbstractInjectCapablePouchFactory implements AliasRegistry {
} }
export default AbstractInjectCapablePouchFactory; export default AbstractInjectCapablePouchFactory;

View File

@ -1,7 +1,7 @@
import AliasRegistry from '@loafer/core/AliasRegistry'; import AliasRegistry from '@loafer/core/AliasRegistry';
import PouchDefinition from '@loafer/pouches/factory/config/PouchDefinition'; import PouchDefinition from '@loafer/pouches/factory/config/PouchDefinition';
export class DefaultListablePouchFactory extends AliasRegistry { export class DefaultListablePouchFactory implements AliasRegistry {
} }
export default DefaultListablePouchFactory; export default DefaultListablePouchFactory;

View File

@ -44,9 +44,7 @@ import * as injectTapEventPlugin from 'react-tap-event-plugin';
import Application from '@loafer/application/Application'; import Application from '@loafer/application/Application';
import ApplicationStater from '@loafer/application/ApplicationStater'; import ApplicationStater from '@loafer/application/ApplicationStater';
import Platform from '@overflow/commons/platform'; import Platform from '@overflow/commons/platform';
import App from '@loafer/application/decorator/App';
import Inject from '@loafer/pouches/decorator/Inject'; import Inject from '@loafer/pouches/decorator/Inject';
import AppContext from '@loafer/context/AppContext';
import WebSocketRPC from '@overflow/commons/websocket/WebSocketRPC'; import WebSocketRPC from '@overflow/commons/websocket/WebSocketRPC';
import ReducerContext from '@overflow/commons/redux/ReducerContext'; import ReducerContext from '@overflow/commons/redux/ReducerContext';
@ -68,15 +66,14 @@ declare global {
injectTapEventPlugin(); injectTapEventPlugin();
@App()
class OFApplication implements ApplicationStater { class OFApplication implements ApplicationStater {
private static isProduction:boolean = process.env.NODE_ENV === 'production' ? true : false; private static isProduction:boolean = process.env.NODE_ENV === 'production' ? true : false;
private static useReduxDevTools:boolean = window.devToolsExtension && !OFApplication.isProduction ? true : false; private static useReduxDevTools:boolean = window.devToolsExtension && !OFApplication.isProduction ? true : false;
private config: Config; private config: Config;
private container: HTMLElement; private container: HTMLElement;
@Inject() // @Inject()
private context: AppContext; // private context: AppContext;
private rpcClient: WebSocketRPC; private rpcClient: WebSocketRPC;
private store: Store<any>; private store: Store<any>;
private sagaMiddleware: SagaMiddleware<any>; private sagaMiddleware: SagaMiddleware<any>;
@ -92,7 +89,7 @@ class OFApplication implements ApplicationStater {
Application.run(OFApplication.prototype); Application.run(OFApplication.prototype);
} }
public async start(): Promise<void> { public async run(): Promise<void> {
try { try {
this.container = await Platform.getAppContainer(this.config.container.placeholderID); this.container = await Platform.getAppContainer(this.config.container.placeholderID);
this.displayLoading(); this.displayLoading();

View File

@ -1,7 +1,6 @@
import { SagaIterator } from 'redux-saga'; import { SagaIterator } from 'redux-saga';
import { call, Effect, fork, put, takeEvery } from 'redux-saga/effects'; import { call, Effect, fork, put, takeEvery } from 'redux-saga/effects';
import AppContext from '@loafer/context/AppContext';
import { SagaWatcher } from '@overflow/commons/constant'; import { SagaWatcher } from '@overflow/commons/constant';
import Action from '@overflow/commons/redux/Action'; import Action from '@overflow/commons/redux/Action';
import * as AsyncRequestActions from '@overflow/commons/redux/action/asyncRequest'; import * as AsyncRequestActions from '@overflow/commons/redux/action/asyncRequest';